var Total_time=0;
var Total_count=0;
var SPACE_CHAR=" ";
var SPACE_CHAR=$.browser.msie?"\xa0":" ";
var NBSP_CHAR="\xa0";
function reset_count(){
Total_time=0;
Total_count=0;
}
function QRect(x,y,_3,_4){
this.left_=x;
this.top_=y;
this.right_=x+_3;
this.bottom_=y+_4;
this.left=function(){
return this.left_;
};
this.top=function(){
return this.top_;
};
this.right=function(){
return this.right_;
};
this.bottom=function(){
return this.bottom_;
};
this.width=function(){
return this.right_-this.left_;
};
this.height=function(){
return this.bottom_-this.top_;
};
this.contains=function(x,y){
if(x<this.left_){
return false;
}
if(x>this.right_){
return false;
}
if(y<this.top_){
return false;
}
if(y>this.bottom_){
return false;
}
return true;
};
this.equals=function(_7){
if(this.left()!=_7.left()){
return false;
}
if(this.top()!=_7.left()){
return false;
}
if(this.right()!=_7.right()){
return false;
}
if(this.bottom()!=_7.bottom()){
return false;
}
return true;
};
this.above=function(_8){
return (this.bottom()<=_8.top());
};
this.below=function(_9){
return (this.top()>=_9.bottom());
};
this.y_distance=function(y){
if(y<=this.top_){
return this.top_-y;
}
if(y>=this.bottom_){
return y-this.bottom_;
}
return 0;
};
this.x_distance=function(x){
if(x<=this.left_){
return this.left_-x;
}
if(x>=this.right_){
return x-this.right_;
}
return 0;
};
}
var _get_rect_counter=0;
var _element_offsets={};
function refresh_get_rect(){
++_get_rect_counter;
_element_offsets={};
}
function QNode(){
this.get_rect_buggy=function(){
var x=0;
var y=0;
var e=this.element();
var w=e.offsetWidth;
var h=e.offsetHeight;
while(e!=null){
x+=e.offsetLeft;
y+=e.offsetTop;
e=e.offsetParent;
}
return new QRect(x,y,w,h);
};
this.last_get_rect_counter=-1;
this.get_rect=function(){
if(this.last_get_rect_counter==_get_rect_counter){
return this.saved_get_rect;
}
var _11=this.element();
var _12=$(_11).offset();
var _13=_12.left;
var top=_12.top;
var _15=_11.offsetWidth;
var _16=_11.offsetHeight;
var _17=new QRect(_13,top,_15,_16);
this.saved_get_rect=_17;
this.last_get_rect_counter=_get_rect_counter;
return _17;
};
}
function QDocContext(_18,_19){
this.init_=function(_1a,_1b){
this.html_doc=_1a;
this.root=_1b;
this.doc=new QDoc(this);
this.xlit_update_callback_=null;
};
this.set_xlit_update_callback=function(cb){
this.xlit_update_callback_=cb;
};
this.on_xlit_update=function(){
if(this.xlit_update_callback_){
this.xlit_update_callback_();
}
};
this.new_element=function(tag){
return this.html_doc.createElement(tag);
};
this.new_text_node=function(_1e){
return this.html_doc.createTextNode(_1e);
};
this.new_line=function(_1f,_20){
return new QLine(this,_1f,_20);
};
this.new_text_item=function(s){
return new QTextItem(this,s);
};
this.new_xlit_item=function(){
return new QXlitItem(this);
};
this.init_(_18,_19);
}
function QDoc(ctx){
this.init_=function(ctx){
this.ctx_=ctx;
this.element_=ctx.root;
this.lines_=[];
};
this.element=function(){
return this.element_;
};
this.line_count=function(){
return this.lines_.length;
};
this.line=function(i){
assert((i>=0)&&(i<this.line_count()));
return this.lines_[i];
};
this.line_index=function(_25){
var n=this.line_count();
for(var i=0;i<n;++i){
if(this.lines_[i]===_25){
return i;
}
}
return -1;
};
this.insert_line=function(i,_29){
assert((i>=0)&&(i<=this.line_count()));
var _2a=null;
if(i<this.line_count()){
_2a=this.lines_[i].element();
}
this.element_.insertBefore(_29.element(),_2a);
this.lines_.splice(i,0,_29);
_29.set_parent(this);
};
this.append_line=function(_2b){
this.insert_line(this.line_count(),_2b);
};
this.remove_line_at=function(i){
assert((i>=0)&&(i<this.line_count()));
var _2d=this.lines_[i];
this.lines_.splice(i,1);
this.element_.removeChild(_2d.element());
_2d.set_parent(null);
return _2d;
};
this.remove_line=function(_2e){
return this.remove_line_at(this.line_index(_2e));
};
this.begin=function(){
return new QCursor(this,0,0,0);
};
this.end=function(){
var _2f=this.line_count()-1;
var _30=this.line(_2f);
var _31=_30.item_count()-1;
return new QCursor(this,_2f,_31,0);
};
this.init_(ctx);
}
var QLineType={SIMPLE:"QLineType.SIMPLE",BULLET:"QLineType.BULLET"};
var QAlign={LEFT:"QAlign.LEFT",CENTER:"QAlign.CENTER",RIGHT:"QAlign.RIGHT"};
function QLineAttributes(_32,_33,_34){
this.type=_32;
this.level=_33;
this.align=_34;
this.merge=function(a){
if((this.type!=null)&&(this.type!=a.type)){
this.type=null;
}
if((this.level!=null)&&(this.level!=a.level)){
this.level=null;
}
if((this.align!=null)&&(this.align!=a.align)){
this.align=null;
}
};
}
function QLine(ctx,_37,_38){
this.init_=function(ctx,_3a,_3b){
this.ctx_=ctx;
this.parent_=null;
this.type_=_3a;
this.level_=_3b;
this.align_=QAlign.LEFT;
this.items_=[];
this.init_elements_();
QNode.call(this);
this.set_align(this.align_);
};
this.make_core_elements_=function(){
var _3c,_3d;
if(this.type_==QLineType.SIMPLE){
_3c=this.ctx_.new_element("div");
_3d=_3c;
}else{
var ul=this.ctx_.new_element("ul");
_3c=ul;
ul.style.marginTop="0";
ul.style.marginBottom="0";
_3d=this.ctx_.new_element("li");
ul.appendChild(_3d);
}
_3c.style.marginLeft=""+(2*this.level_)+"em";
if($.browser.msie){
_3c.style.wordWrap="break-word";
}else{
_3c.style.whiteSpace="pre-wrap";
}
return {"e_child":_3c,"c_parent":_3d};
};
this.init_elements_=function(){
var _3f=this.make_core_elements_();
this.element_=this.ctx_.new_element("span");
this.element_.appendChild(_3f.e_child);
this.container_=this.ctx_.new_element("span");
_3f.c_parent.appendChild(this.container_);
};
this.reinit_elements_=function(){
var _40=this.make_core_elements_();
this.container_.parentNode.removeChild(this.container_);
_40.c_parent.appendChild(this.container_);
this.element_.replaceChild(_40.e_child,this.element_.firstChild);
this.set_align(this.align_);
};
this.element=function(){
return this.element_;
};
this.parent=function(){
return this.parent_;
};
this.set_parent=function(p){
this.parent_=p;
};
this.type=function(){
return this.type_;
};
this.level=function(){
return this.level_;
};
this.set_type_and_level=function(_42,_43){
this.type_=_42;
this.level_=_43;
this.reinit_elements_();
};
this.align=function(){
return this.align_;
};
this.set_align=function(a){
this.align_=a;
var v;
if(a==QAlign.LEFT){
v="left";
}else{
if(a==QAlign.CENTER){
v="center";
}else{
if(a==QAlign.RIGHT){
v="right";
}else{
assert(false,"invalid alignment: "+a);
}
}
}
this.element_.firstChild.style.textAlign=v;
};
this.get_attributes=function(){
return new QLineAttributes(this.type_,this.level_,this.align_);
};
this.set_attributes=function(a){
if((a.type!=null)||(a.level!=null)){
var _47=(a.type!=null)?a.type:this.type();
var _48=(a.level!=null)?a.level:this.level();
this.set_type_and_level(_47,_48);
}
if(a.align!=null){
this.set_align(a.align);
}
};
this.item_count=function(){
return this.items_.length;
};
this.item=function(i){
assert((i>=0)&&(i<this.item_count()));
return this.items_[i];
};
this.item_index=function(_4a){
var n=this.item_count();
for(var i=0;i<n;++i){
if(this.items_[i]===_4a){
return i;
}
}
return -1;
};
this.insert_item=function(i,_4e){
assert((i>=0)&&(i<=this.item_count()));
var _4f=null;
if(i<this.item_count()){
_4f=this.items_[i].element();
}
this.container_.insertBefore(_4e.element(),_4f);
this.items_.splice(i,0,_4e);
_4e.set_parent(this);
};
this.append_item=function(_50){
this.insert_item(this.item_count(),_50);
};
this.remove_item_at=function(i){
assert((i>=0)&&(i<this.item_count()));
var _52=this.items_[i];
this.items_.splice(i,1);
this.container_.removeChild(_52.element());
_52.set_parent(null);
return _52;
};
this.remove_item=function(_53){
return this.remove_item_at(this.item_index(_53));
};
this.init_(ctx,_37,_38);
}
function QItemAttributes(_54,_55,_56,_57,_58,_59,_5a,_5b){
this.lang=_54;
this.font_name=_55;
this.font_size=_56;
this.bold=_57;
this.italic=_58;
this.underline=_59;
this.color=_5a;
this.bg_color=_5b;
this.merge=function(a){
if((this.lang!=null)&&(this.lang!=a.lang)){
this.lang=null;
}
if((this.font_name!=null)&&(this.font_name!=a.font_name)){
this.font_name=null;
}
if((this.font_size!=null)&&(this.font_size!=a.font_size)){
this.font_size=null;
}
if((this.bold!=null)&&(this.bold!=a.bold)){
this.bold=null;
}
if((this.italic!=null)&&(this.italic!=a.italic)){
this.italic=null;
}
if((this.underline!=null)&&(this.underline!=a.underline)){
this.underline=null;
}
if((this.underline!=null)&&(this.underline!=a.underline)){
this.underline=null;
}
if((this.color!=null)&&(this.color!=a.color)){
this.color=null;
}
if((this.bg_color!=null)&&(this.bg_color!=a.bg_color)){
this.bg_color=null;
}
};
this.set_lang=function(s){
this.lang=s;
};
this.set_font_name=function(v){
this.font_name=v;
};
this.set_font_size=function(v){
this.font_size=v;
};
this.set_bold=function(_60){
this.bold=_60;
};
this.set_italic=function(_61){
this.italic=_61;
};
this.set_underline=function(_62){
this.underline=_62;
};
this.set_color=function(_63){
this.color=_63;
};
this.set_bg_color=function(_64){
this.bg_color=_64;
};
}
function QFormat(){
this.lang_="";
this.font_name_="";
this.font_size_=12;
this.bold_=false;
this.italic_=false;
this.underline_=false;
this.color_="#000000";
this.bg_color_="#FFFFFF";
this.selection_color_=null;
this.lang=function(){
return this.lang_;
};
this.font_name=function(){
return this.font_name_;
};
this.font_size=function(){
return this.font_size_;
};
this.bold=function(){
return this.bold_;
};
this.italic=function(){
return this.italic_;
};
this.underline=function(){
return this.underline_;
};
this.color=function(){
return this.color_;
};
this.bg_color=function(){
return this.bg_color_;
};
this.selection_color=function(){
return this.selection_color_;
};
this.set_lang=function(s){
this.lang_=s;
};
this.set_font_name=function(fn){
this.font_name_=fn;
this.element().style.fontFamily=this.font_name_;
};
this.set_font_size=function(fs){
this.font_size_=fs;
this.element().style.fontSize=""+this.font_size_+"pt";
};
this.set_bold=function(_68){
this.bold_=_68;
this.element().style.fontWeight=this.bold_?"bold":"normal";
};
this.set_italic=function(_69){
this.italic_=_69;
this.element().style.fontStyle=this.italic_?"italic":"normal";
};
this.set_underline=function(_6a){
this.underline_=_6a;
this.element().style.textDecoration=this.underline_?"underline":"none";
};
this.update_color_=function(){
var c=(this.selection_color_==null)?this.color_:blend(this.color_,this.selection_color_,0.35);
this.element().style.color=c;
};
this.update_background_=function(){
var c=(this.selection_color_==null)?this.bg_color_:blend(this.bg_color_,this.selection_color_,0.35);
this.element().style.backgroundColor=c;
};
this.set_color=function(v){
this.color_=v;
this.update_color_();
};
this.set_bg_color=function(v){
this.bg_color_=v;
this.update_background_();
};
this.set_selection_color=function(v){
this.selection_color_=v;
this.update_color_();
this.update_background_();
};
this.set_font_size(this.font_size_);
this.get_attributes=function(){
return new QItemAttributes(this.lang_,this.font_name_,this.font_size_,this.bold_,this.italic_,this.underline_,this.color_,this.bg_color_);
};
this.set_attributes=function(a){
if(a.lang!=null){
this.set_lang(a.lang);
}
if(a.font_name!=null){
this.set_font_name(a.font_name);
}
if(a.font_size!=null){
this.set_font_size(a.font_size);
}
if(a.bold!=null){
this.set_bold(a.bold);
}
if(a.italic!=null){
this.set_italic(a.italic);
}
if(a.underline!=null){
this.set_underline(a.underline);
}
if(a.color!=null){
this.set_color(a.color);
}
if(a.bg_color!=null){
this.set_bg_color(a.bg_color);
}
};
}
function QItem(ctx){
this.init_=function(ctx){
this.ctx_=ctx;
this.element_=this.ctx_.new_element("span");
this.parent_=null;
if($.browser.msie){
this.element_.style.display="inline-block";
}
QFormat.call(this);
QNode.call(this);
};
this.element=function(){
return this.element_;
};
this.parent=function(){
return this.parent_;
};
this.set_parent=function(p){
this.parent_=p;
};
this.set_content_=function(s){
var e=this.element_;
while(e.firstChild){
e.removeChild(e.firstChild);
}
this.element_.appendChild(this.ctx_.new_text_node(s));
};
this.set_selected_all=function(_76){
var _77=_76?"#316AC5":"#000000";
this.set_selection_color(_77);
};
this.set_selected_none=function(){
this.set_selection_color(null);
};
this.init_(ctx);
}
function QTextItem(ctx,s){
this.init_=function(ctx,s){
this.is_QTextItem=true;
QItem.call(this,ctx);
if(s==NBSP_CHAR){
this.element_.style.display="";
}
this.set_text(s);
};
this.text=function(){
return this.text_;
};
this.set_text=function(s){
this.text_=s;
this.set_content_(s);
};
this.init_(ctx,s);
}
function QXlitItem(ctx){
this.init_=function(ctx){
this.is_QXlitItem=true;
this.is_num_=false;
QItem.call(this,ctx);
this.element().style.padding="1px";
this.set_lang=this.set_lang_for_xlit;
this.english_="";
this.options_=[];
this.index_=0;
this.request_=null;
};
this.english=function(){
return this.english_;
};
this.options=function(){
return this.options_;
};
this.index=function(){
return this.index_;
};
this.num=function(){
return this.is_num_;
};
this.is_updating=function(){
return this.request_!==null;
};
this.set_english=function(s){
this.english_=s;
};
this.set_num=function(s){
this.is_num_=s;
};
this.set_lang_for_xlit=function(s){
if(this.lang_!=s&&this.lang_!=""){
this.lang_=s;
this.update_xlit();
}
this.lang_=s;
};
this.set_options=function(a){
this.options_=a;
};
this.set_index=function(i){
this.index_=i;
};
this.get_text_=function(){
if((this.english_.length==0)||(this.lang_.length==0)){
return "-";
}
if(this.lang_=="english"){
return this.english_;
}
var t="";
if((this.index_>=0)&&(this.index_<this.options_.length)){
t=this.options_[this.index_];
}
if(this.is_updating()){
t+=".";
}
return t;
};
this.update_text=function(){
this.set_content_(this.get_text_());
var _85=this;
function notify_callback(){
_85.ctx_.on_xlit_update();
}
setTimeout(notify_callback,0);
};
this.update_xlit=function(){
if(this.request_!=null){
this.request_.cancel();
this.request_=null;
}
if((this.english_=="")||(this.lang_=="")||(this.lang_=="english")){
this.options_=[];
this.index_=0;
}else{
this.request_=new QuillRequest(this.lang_,this.english_,bind_this(this,this.on_response_));
}
this.update_text();
};
this.on_response_=function(_86,_87,_88){
this.request_=null;
function has_uppercase_char(str){
for(var i=1;i<str.length;i++){
if(str.charCodeAt(i)>=65&&str.charCodeAt(i)<=90){
return true;
}
}
return false;
}
function has_lowercase_char(str){
for(var i=1;i<str.length;i++){
if(str.charCodeAt(i)>=97&&str.charCodeAt(i)<=122){
return true;
}
}
return false;
}
function contains_itrans_option(_8d,_8e){
for(var i=0;i<_8d.length;i++){
if(_8d[i]==_8e){
return true;
}
}
return false;
}
if(this.is_num_){
_86=[_87,_88];
}else{
if(!contains_itrans_option(_86,_87)){
if(has_uppercase_char(this.english_)&&has_lowercase_char(this.english_)){
_86.unshift(_87);
}else{
_86.push(_87);
}
}
}
this.options_=_86;
this.index_=0;
this.update_text();
};
this.choose_option=function(_90){
this.index_=_90;
this.update_text();
};
this.get_text=function(){
return this.get_text_();
};
this.init_(ctx);
}
function QDocFragment(_91,_92){
this.initial=_91;
this.lines=_92;
}
function QDFLine(_93,_94){
this.items=_93;
this.attr=_94;
}
function QDFText(_95,_96){
this.is_QDFText=true;
this.text=_95;
this.attr=_96;
this.get_text=function(){
return this.text;
};
}
function QDFXlit(_97,_98,_99,_9a,_9b,_9c){
this.is_QDFXlit=true;
this.english=_97;
this.attr=_98;
this.is_num=_9c;
this.options=_99;
this.index=_9a;
this.is_updating=_9b;
this.get_text=function(){
if(this.english.length==0){
return "-";
}
if(this.is_updating){
return ".";
}
if((this.index>=0)&&(this.index<this.options.length)){
return this.options[this.index];
}
return ".";
};
this.get_english=function(){
return this.english;
};
}
function item_to_df_(_9d){
assert(_9d.is_QTextItem||_9d.is_QXlitItem);
if(_9d.is_QTextItem){
return new QDFText(_9d.text(),_9d.get_attributes());
}else{
return new QDFXlit(_9d.english(),_9d.get_attributes(),_9d.options(),_9d.index(),_9d.is_updating(),_9d.num());
}
}
function QCursor(doc,u,v){
this.doc=doc;
this.u=u;
this.v=v;
this.clone=function(){
return new QCursor(this.doc,this.u,this.v);
};
this.compare=function(_a1){
if(this.u<_a1.u){
return -1;
}
if(this.u>_a1.u){
return 1;
}
if(this.v<_a1.v){
return -1;
}
if(this.v>_a1.v){
return 1;
}
return 0;
};
this.equals=function(_a2){
return this.compare(_a2)==0;
};
this.not_equals=function(_a3){
return this.compare(_a3)!=0;
};
this.lesser=function(_a4){
return this.compare(_a4)<0;
};
this.lesser_equal=function(_a5){
return this.compare(_a5)<=0;
};
this.greater=function(_a6){
return this.compare(_a6)>0;
};
this.greater_equal=function(_a7){
return this.compare(_a7)>=0;
};
this.line=function(){
return this.doc.line(this.u);
};
this.item=function(){
var _a8=this.line();
return _a8.item(this.v);
};
this.previous_item=function(){
assert(!this.is_line_begin());
var _a9=this.line();
return _a9.item(this.v-1);
};
this.is_xlit=function(){
if(this.item().is_QXlitItem){
return true;
}else{
return false;
}
};
this.has_previous_xlit=function(){
if(!this.is_line_begin()&&(this.previous_item().is_QXlitItem)){
return true;
}else{
return false;
}
};
this.is_line_begin=function(){
return this.v==0;
};
this.is_line_end=function(){
var _aa=this.doc.line(this.u);
return this.v==_aa.item_count()-1;
};
this.is_first_line=function(){
return this.u==0;
};
this.is_last_line=function(){
return this.u==this.doc.line_count()-1;
};
this.is_begin=function(){
return this.is_first_line()&&this.is_line_begin();
};
this.is_end=function(){
return this.is_last_line()&&this.is_line_end();
};
this.go_line_begin=function(){
this.v=0;
};
this.go_line_end=function(){
var _ab=this.doc.line(this.u);
this.v=_ab.item_count()-1;
};
this.go_next=function(){
if(this.is_line_end()){
this.u++;
this.go_line_begin();
}else{
this.v++;
}
};
this.go_previous=function(){
if(this.is_line_begin()){
this.u--;
this.go_line_end();
}else{
this.v--;
}
};
this.go_next_line=function(){
this.u++;
this.go_line_begin();
};
this.go_previous_line=function(){
this.u--;
this.go_line_begin();
};
this.go_begin=function(){
this.u=0;
this.v=0;
};
this.go_end=function(){
this.u=this.doc.line_count()-1;
this.go_line_end();
};
this.get_rect=function(){
var _ac;
if((!this.is_line_begin())&&this.is_line_end()){
_ac=this.previous_item().get_rect();
return new QRect(_ac.right(),_ac.top(),0,_ac.height());
}
_ac=this.item().get_rect();
return new QRect(_ac.left(),_ac.top(),0,_ac.height());
};
}
function QOpAddFragment(_ad,_ae){
this.cursor=_ad;
this.fragment=_ae;
this.add_item_=function(ctx,_b0,_b1){
var _b2;
if(_b1.is_QDFXlit){
_b2=ctx.new_xlit_item();
_b2.set_english(_b1.english);
_b2.set_options(_b1.options);
_b2.set_index(_b1.index);
_b2.set_attributes(_b1.attr);
_b2.set_num(_b1.is_num);
if(_b1.is_updating){
_b2.update_xlit();
}
_b2.update_text();
}else{
if(_b1.is_QDFText){
_b2=ctx.new_text_item(_b1.text);
_b2.set_attributes(_b1.attr);
}else{
assert(false);
}
}
_b0.line().insert_item(_b0.v,_b2);
};
this.add_blank_line_=function(ctx,_b4,_b5){
var a=_b5.attr;
var _b7=ctx.new_line(a.type,a.level);
_b7.set_align(a.align);
_b7.append_item(ctx.new_text_item(NBSP_CHAR));
ctx.doc.insert_line(_b4,_b7);
};
this.perform=function(ctx){
var c=this.cursor.clone();
var i,j;
for(i=0;i<_ae.initial.length;++i){
this.add_item_(ctx,c,_ae.initial[i]);
c.v++;
}
var c2=c.clone();
for(i=0;i<_ae.lines.length;++i){
var _bd=_ae.lines[i];
this.add_blank_line_(ctx,c2.u+1,_bd);
c2.go_next_line();
for(j=0;j<_bd.items.length;++j){
this.add_item_(ctx,c2,_bd.items[j]);
c2.v++;
}
}
if(_ae.lines.length>0){
while(!c.is_line_end()){
var _be=c.line().remove_item_at(c.v);
c2.line().insert_item(c2.v,_be);
c2.v++;
}
}
};
this.get_ending_cursor=function(ctx){
var _c0=this.fragment.lines.length;
var _c1=this.cursor.u+_c0;
var _c2;
if(_c0>0){
_c2=this.fragment.lines[_c0-1].items.length;
}else{
_c2=this.cursor.v+this.fragment.initial.length;
}
return new QCursor(ctx.doc,_c1,_c2);
};
this.perform_and_invert=function(ctx){
this.perform(ctx);
processAddFrag(_ad,_ae);
return new QOpDelFragment(this.cursor,this.get_ending_cursor(ctx));
};
}
function QOpDelFragment(_c4,_c5){
this.cursor1=_c4;
this.cursor2=_c5;
this.perform=function(ctx){
this.perform_and_invert(ctx);
};
this.move_items_=function(_c7,_c8,i,j){
var _cb=j-i;
for(;_cb>0;--_cb){
var _cc=_c8.remove_item_at(i);
_c7.push(item_to_df_(_cc));
}
};
this.move_items_till_line_end_=function(_cd,_ce){
var _cf=_ce.line();
var end=_ce.clone();
end.go_line_end();
this.move_items_(_cd,_cf,_ce.v,end.v);
};
this.perform_and_invert=function(ctx){
var _d2=new QDocFragment([],[]);
var c=this.cursor1.clone();
var _d4=this.cursor2.u-c.u;
if(_d4==0){
this.move_items_(_d2.initial,c.line(),c.v,this.cursor2.v);
}else{
this.move_items_till_line_end_(_d2.initial,c);
c.go_next_line();
for(;_d4>0;--_d4){
var _d5=c.line();
var _d6=new QDFLine([],_d5.get_attributes());
_d2.lines.push(_d6);
if(_d4>1){
this.move_items_till_line_end_(_d6.items,c);
}else{
this.move_items_(_d6.items,_d5,c.v,this.cursor2.v);
var _d7=this.cursor1.clone();
while(!c.is_line_end()){
var _d8=_d5.remove_item_at(c.v);
_d7.line().insert_item(_d7.v,_d8);
_d7.v++;
}
}
ctx.doc.remove_line_at(c.u);
}
}
processDelFrag(_c4,_d2);
return new QOpAddFragment(this.cursor1,_d2);
};
}
function QOpChangeXlitItem(_d9,_da,_db,_dc,_dd,_de){
this.cursor=_d9;
this.english=_da;
this.options=_db;
this.index=_dc;
this.is_num=_dd;
this.should_update=_de;
this.perform=function(ctx){
var _e0=this.cursor.item();
_e0.set_english(this.english);
_e0.set_options(this.options);
_e0.set_index(this.index);
_e0.set_num(this.is_num);
if(this.should_update){
_e0.update_xlit();
}
_e0.update_text();
};
this.perform_and_invert=function(ctx){
var _e2=this.cursor.item();
var inv=new QOpChangeXlitItem(this.cursor,_e2.english(),_e2.options(),_e2.index(),_e2.num(),_e2.is_updating());
processChangeXlit(_d9,_da,_e2.english());
this.perform(ctx);
return inv;
};
}
function QOpFormatItem(_e4,_e5){
this.cursor=_e4;
this.item_attributes=_e5;
this.perform=function(ctx){
this.cursor.item().set_attributes(this.item_attributes);
};
this.perform_and_invert=function(ctx){
var _e8=this.cursor.item();
var inv=new QOpFormatItem(this.cursor,_e8.get_attributes());
this.perform(ctx);
return inv;
};
}
function QOpFormatLine(_ea,_eb){
this.line_index=_ea;
this.line_attributes=_eb;
this.perform=function(ctx){
ctx.doc.line(_ea).set_attributes(this.line_attributes);
};
this.perform_and_invert=function(ctx){
var _ee=ctx.doc.line(this.line_index);
var inv=new QOpFormatLine(this.line_index,_ee.get_attributes());
this.perform(ctx);
return inv;
};
}
function QOpGroup(ops){
this.ops=ops;
this.perform=function(ctx){
for(var i=0;i<this.ops.length;++i){
this.ops[i].perform(ctx);
}
};
this.perform_and_invert=function(ctx){
var _f4=[];
for(var i=0;i<this.ops.length;++i){
var _f6=this.ops[i].perform_and_invert(ctx);
_f4.push(_f6);
}
_f4.reverse();
return new QOpGroup(_f4);
};
}
function QuillPopup(_f7,_f8){
this.init_=function(_f9,_fa){
this.hdoc_=_f9;
this.choice_callback_=_fa;
var e=this.hdoc_.createElement("div");
e.style.position="absolute";
e.style.border="1px solid #40759C";
e.style.background="#F4F6FF";
this.hdoc_.body.appendChild(e);
this.element_=e;
this.container_=e;
this.visible_=true;
this.set_visible_(false);
this.offset_x_=0;
this.offset_y_=0;
this.demo=false;
this.disabled_=false;
this.max_options_=4;
};
this.set_offset=function(ox,oy){
this.offset_x_=ox;
this.offset_y_=oy;
};
this.clear_=function(){
var e=this.container_;
while(e.firstChild){
e.removeChild(e.firstChild);
}
};
this.set_visible_=function(_ff){
if(_ff&&!this.disabled_){
if(this.visible_){
return;
}
this.visible_=true;
this.element_.style.visibility="visible";
}else{
if(!this.visible_){
return;
}
this.visible_=false;
this.element_.style.visibility="hidden";
this.clear_();
}
};
this.show=function(){
this.set_visible_(true);
};
this.hide=function(){
this.set_visible_(false);
};
this.add_english_=function(s){
var d=this.hdoc_.createElement("div");
d.style.background="#86ABD5";
d.style.padding="3px";
var e=this.hdoc_.createElement("span");
e.style.fontSize="8pt";
if(this.demo){
e.style.color="red";
}else{
e.style.color="#404040";
}
e.style.paddingLeft="10px";
e.style.paddingRight="10px";
e.appendChild(this.hdoc_.createTextNode(s));
d.appendChild(e);
this.container_.appendChild(d);
};
this.add_option_=function(s,_104,_105){
var d=this.hdoc_.createElement("div");
d.style.background="transparent";
var e=this.hdoc_.createElement("span");
if(_104==_105.index()){
e.style.fontWeight="bold";
}
e.style.fontSize="10pt";
e.style.color="#000000";
e.style.paddingLeft="10px";
e.style.paddingRight="10px";
e.style.lineHeight="20px";
e.appendChild(this.hdoc_.createTextNode(s));
d.appendChild(e);
this.container_.appendChild(d);
var self=this;
$(e).hover(function(){
d.style.background="#DAE9FB";
},function(){
d.style.background="transparent";
});
$(e).mousedown(function(){
_105.choose_option(_104);
window.setTimeout(self.choice_callback_,0);
});
};
this.update_position_=function(_109){
var e=this.element_;
var r=_109.get_rect();
e.style.left=""+(r.left()+10+this.offset_x_)+"px";
e.style.top=""+(r.bottom()+10+this.offset_y_)+"px";
};
this.update=function(_10c){
this.clear_();
this.add_english_(_10c.english());
var _10d=_10c.options();
for(var i=0;i<_10d.length&&i<this.max_options_;++i){
this.add_option_(_10d[i],i,_10c);
}
this.update_position_(_10c);
};
this.disable=function(val){
this.disabled_=val;
};
this.init_(_f7,_f8);
}
function QuillEditor(_110,root,_112,lang){
this.init_=function(_114,root,_116){
this.ctx_=new QDocContext(_114,root);
this.ctx_.set_xlit_update_callback(bind_this(this,this.update_on_resize));
this.doc_=this.ctx_.doc;
var line=this.ctx_.new_line(QLineType.SIMPLE,0);
line.append_item(this.ctx_.new_text_item(NBSP_CHAR));
this.doc_.append_line(line);
this.transient_attributes_=null;
this.blink_on_count_=0;
this.anchor_=null;
this.caret_=new QCursor(this.doc_,0,0);
this.caret_on_word_=false;
this.on_which_word_=null;
this.has_focus_=false;
this.undo_list_=[];
this.redo_list_=[];
this.internal_clipboard="";
this.external_clipboard="";
this.ignore_on_resize=false;
this.caret_widget_=this.ctx_.new_element("div");
this.caret_widget_.style.position="absolute";
this.caret_widget_.style.fontSize="0px";
this.caret_widget_.style.background="#000000";
this.ctx_.html_doc.body.appendChild(this.caret_widget_);
this.popup_=_116;
this.popup_.hide();
this.popup_enabled_=false;
this.update_on_move();
this.enter_callback_=null;
this.lang_font_={"bengali":"Vrinda","gujarati":"Shruti","hindi":"Mangal","kannada":"Tunga","malayalam":"Kartika","marathi":"Mangal","tamil":"Latha","telugu":"Gautami","punjabi":"Raavi","nepali":"Mangal"};
this.init_lang_=lang.toLowerCase();
this.init_font_="Arial";
if(this.lang_font_[this.init_lang_]){
this.init_font_=this.lang_font_[this.init_lang_];
}
this.default_bg_color="#FFFFFF";
this.last_known_eng_font={"lang":"english","font":"Arial"};
this.last_known_lang_font;
this.edit_callback_;
};
this.grab_focus=function(){
if(!this.has_focus_){
this.ctx_.root.focus();
if($.browser.safari){
this.set_has_focus(true);
}
}
};
this.set_edit_callback=function(fun){
this.edit_callback_=fun;
};
this.has_focus=function(){
return this.has_focus_;
};
this.toggle_caret_blink=function(){
if(this.blink_on_count_>0){
this.blink_on_count_--;
}else{
this.blink_on_count_++;
}
this.update_caret_visibility();
};
this.update_last_known_lang=function(lang,font){
if(lang=="english"){
this.last_known_eng_font={"lang":lang,"font":font};
}else{
this.last_known_lang_font={"lang":lang,"font":font};
}
};
this.toggle_lang=function(){
var att=this.get_selection_item_attributes();
if(att==null){
att=this.get_new_item_attributes();
}
var _11c=att.lang;
if(_11c){
if(_11c=="english"){
this.set_lang(this.last_known_lang_font.lang);
this.set_font_name(this.last_known_lang_font.font);
this.update_caret_widget();
update_ui_state();
this.grab_focus();
}else{
this.set_lang(this.last_known_eng_font.lang);
this.set_font_name(this.last_known_eng_font.font);
this.update_caret_widget();
update_ui_state();
this.grab_focus();
}
}
};
this.set_has_focus=function(flag){
this.has_focus_=flag;
if(this.anchor_){
this.add_selection_highlight_();
}
this.update_caret_visibility();
if(this.has_focus_){
this.update_caret_widget();
}
};
this.set_anchor=function(val){
this.anchor_=val;
this.update_caret_visibility();
};
this.update_caret_visibility=function(){
if((this.blink_on_count_>0)&&this.has_focus_&&((this.anchor_==null)||this.anchor_.equals(this.caret_))){
this.caret_widget_.style.background="#000000";
}else{
this.caret_widget_.style.background="transparent";
}
};
this.cursor_attributes=function(_11f){
if(!_11f.is_line_begin()){
return _11f.previous_item().get_attributes();
}
if(!_11f.is_line_end()){
return _11f.item().get_attributes();
}
return null;
};
this.default_attributes=function(_120){
return new QItemAttributes(this.init_lang_,this.init_font_,12,false,false,false,"#000000",this.default_bg_color);
};
this.set_transient_attributes=function(a){
this.transient_attributes_=a;
};
this.unset_transient_attributes=function(){
this.transient_attributes_=null;
};
this.disable_popup=function(val){
this.popup_.disable(val);
};
this.set_enter_callback=function(func){
this.enter_callback_=func;
};
this.get_new_item_attributes=function(){
if(this.transient_attributes_){
return this.transient_attributes_;
}
var c=this.caret_;
if(this.caret_on_word_){
c=this.on_which_word_.clone();
c.go_next();
}
var a=this.cursor_attributes(c);
if(!a){
return this.default_attributes();
}
return a;
};
this.get_selection_item_attributes=function(){
if(this.anchor_==null){
return null;
}
var c1=this.anchor_.clone();
var c2=this.caret_.clone();
if(c1.greater(c2)){
var temp=c1;
c1=c2;
c2=temp;
}
while(c1.is_line_end()&&(c1.not_equals(c2))){
c1.go_next();
}
if(c1.equals(c2)){
return null;
}
var a=c1.item().get_attributes();
c1.go_next();
while(c1.not_equals(c2)){
if(!c1.is_line_end()){
a.merge(c1.item().get_attributes());
}
c1.go_next();
}
return a;
};
this.get_line_attributes=function(){
var _12a=this.caret_.u;
var _12b=_12a;
if(this.anchor_!=null){
_12b=this.anchor_.u;
if(_12a>_12b){
var temp=_12a;
_12a=_12b;
_12b=temp;
}
}
var a=this.doc_.line(_12a).get_attributes();
while(_12a<_12b){
++_12a;
var b=this.doc_.line(_12a).get_attributes();
a.merge(b);
}
return a;
};
this.update_caret_widget=function(){
var cw=this.caret_widget_;
var rect,item;
if(this.caret_on_word_){
item=this.on_which_word_.item();
rect=item.get_rect();
cw.style.left=""+(rect.left()-1)+"px";
cw.style.top=""+(rect.bottom()-2)+"px";
cw.style.height="1px";
cw.style.width=""+(2+rect.width())+"px";
this.popup_.update(item);
if(this.has_focus_&&this.popup_enabled_){
this.popup_.show();
}
}else{
item=this.caret_.item();
rect=this.caret_.get_rect();
cw.style.top=""+rect.top()+"px";
cw.style.left=""+rect.left()+"px";
cw.style.height=""+rect.height()+"px";
cw.style.width="2px";
this.popup_.hide();
}
function get_window_height(){
var _132=0;
if(typeof (window.innerWidth)=="number"){
_132=window.innerHeight;
}else{
if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
_132=document.documentElement.clientHeight;
}else{
if(document.body&&(document.body.clientWidth||document.body.clientHeight)){
_132=document.body.clientHeight;
}
}
}
return _132;
}
function get_scroll(){
var _133=0;
if(typeof (window.pageYOffset)=="number"){
_133=window.pageYOffset;
}else{
if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){
_133=document.body.scrollTop;
}else{
if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){
_133=document.documentElement.scrollTop;
}
}
}
return _133;
}
var _134=get_window_height();
var _135=get_scroll();
var _136=5;
if(rect.top()<_135){
var c=this.caret_.clone();
for(var i=0;i<_136;++i){
if(!c.is_first_line()){
c.go_previous_line();
}
}
c.item().element().scrollIntoView(true);
}else{
if(rect.bottom()>_135+_134){
var c=this.caret_.clone();
for(var i=0;i<_136;++i){
if(!c.is_last_line()){
c.go_next_line();
}
}
c.item().element().scrollIntoView(false);
}
}
};
this.update_on_move=function(_139){
this.blink_on_count_=2;
this.update_caret_visibility();
this.update_caret_widget();
if(!_139){
this.unset_transient_attributes();
}
};
this.update_on_resize=function(){
if(this.ignore_on_resize){
return;
}
refresh_get_rect();
this.update_caret_widget();
};
this.get_nearest_line=function(x,y){
var n=this.doc_.line_count();
assert(n>0);
var _13d=0;
var line=this.doc_.line(_13d);
var rect=line.get_rect();
var _140=rect.y_distance(y);
for(var i=1;i<n;++i){
var _142=this.doc_.line(i);
var _143=_142.get_rect();
var _144=_143.y_distance(y);
if(_144>_140){
break;
}else{
if(_144<_140){
_13d=i;
line=_142;
rect=_143;
_140=_144;
}
}
}
return _13d;
};
this.get_nearest_cursor_in_range=function(_145,end,x,y){
assert(_145.lesser_equal(end));
var c=_145.clone();
var rect=c.get_rect();
var _14b=rect.y_distance(y);
var _14c=rect.x_distance(x);
var _14d=c.clone();
while(c.not_equals(end)){
c.go_next();
var _14e=c.get_rect();
var _14f=_14e.y_distance(y);
if(_14f<_14b){
_14d=c.clone();
rect=_14e;
_14b=_14f;
_14c=_14e.x_distance(x);
}else{
if(_14f==_14b){
var _150=_14e.x_distance(x);
if(_150<_14c){
_14d=c.clone();
rect=_14e;
_14b=_14f;
_14c=_150;
}
}
}
}
return _14d;
};
this.get_nearest_cursor=function(x,y){
var _153=this.get_nearest_line(x,y);
var _154=new QCursor(this.doc_,_153,0);
var end=_154.clone();
end.go_line_end();
return this.get_nearest_cursor_in_range(_154,end,x,y);
};
this.update_selection_highlight_=function(c1,c2,_158){
if(c1.greater(c2)){
var temp=c1;
c1=c2;
c2=temp;
}
var c=c1.clone();
while(c.not_equals(c2)){
if(_158){
c.item().set_selected_all(this.has_focus_);
}else{
c.item().set_selected_none();
}
c.go_next();
}
};
this.add_selection_highlight_=function(){
this.update_selection_highlight_(this.anchor_,this.caret_,true);
};
this.remove_selection_highlight_=function(){
this.update_selection_highlight_(this.anchor_,this.caret_,false);
};
this.move_caret_to_xy=function(x,y,_15d){
var _15e=(this.anchor_!=null);
var _15f=this.get_nearest_cursor(x,y);
var _160=false;
if(_15f.equals(this.caret_)){
_160=true;
}
if(_15f.equals(this.caret_)&&_15d&&_15e){
return;
}
if(_15e){
this.remove_selection_highlight_();
if(!_15d){
this.set_anchor(null);
}
}
if(_15d&&!this.anchor_){
this.set_anchor(this.caret_.clone());
}
this.caret_on_word_=false;
this.on_which_word_=null;
if(!_15d){
if(_15f.is_xlit()&&_15f.item().get_rect().contains(x,y)){
this.caret_on_word_=true;
this.on_which_word_=_15f.clone();
this.popup_enabled_=true;
}else{
if(_15f.has_previous_xlit()&&(_15f.previous_item().get_rect().contains(x,y))){
this.caret_on_word_=true;
this.on_which_word_=_15f.clone();
this.on_which_word_.go_previous();
this.popup_enabled_=true;
}
}
}
this.caret_=_15f;
this.update_on_move(_160);
if(_15d){
this.add_selection_highlight_();
}
};
this.MOVING_LEFT="MOVING_LEFT";
this.MOVING_RIGHT="MOVING_RIGHT";
this.adjust_caret_before_select_=function(_161){
if(!this.caret_on_word_){
return;
}
this.caret_on_word_=false;
this.caret_=this.on_which_word_;
this.on_which_word_=null;
assert(this.caret_.is_xlit());
switch(_161){
case this.MOVING_LEFT:
this.caret_=this.caret_.clone();
this.caret_.go_next();
break;
case this.MOVING_RIGHT:
break;
default:
assert(false);
}
};
this.prepare_before_move_=function(_162,_163){
if(_162){
if(this.anchor_==null){
this.adjust_caret_before_select_(_163);
this.set_anchor(this.caret_.clone());
}else{
this.remove_selection_highlight_();
}
}else{
if(this.anchor_!=null){
this.remove_selection_highlight_();
this.set_anchor(null);
}
}
this.popup_enabled_=false;
this.popup_.hide();
};
this.move_left=function(_164){
this.prepare_before_move_(_164,this.MOVING_LEFT);
var _165=false;
var _166=this.caret_;
if(this.caret_on_word_){
this.caret_on_word_=false;
this.caret_=this.on_which_word_;
this.on_which_word_=null;
}else{
if(!this.caret_.is_begin()){
this.caret_=this.caret_.clone();
this.caret_.go_previous();
if((!_164)&&this.caret_.is_xlit()){
this.caret_on_word_=true;
this.on_which_word_=this.caret_;
}
}
}
if(_164){
this.add_selection_highlight_();
}
if(_166.equals(this.caret_)){
_165=true;
}
this.update_on_move(_165);
};
this.move_right=function(_167){
this.prepare_before_move_(_167,this.MOVING_RIGHT);
var _168=false;
var _169=this.caret_;
if(this.caret_on_word_){
this.caret_on_word_=false;
this.caret_=this.on_which_word_.clone();
this.caret_.go_next();
this.on_which_word_=null;
}else{
if((!_167)&&(this.caret_.is_xlit())){
this.caret_on_word_=true;
this.on_which_word_=this.caret_;
}else{
if(!this.caret_.is_end()){
this.caret_=this.caret_.clone();
this.caret_.go_next();
}
}
}
if(_167){
this.add_selection_highlight_();
}
if(_169.equals(this.caret_)){
_168=true;
}
this.update_on_move(_168);
};
this.cursor_to_home=function(_16a){
var rect=_16a.get_rect();
var c=_16a.clone();
_16a=c.clone();
while(!c.is_line_begin()){
c.go_previous();
var _16d=c.get_rect();
if(_16d.right()>rect.left()){
break;
}
rect=_16d;
_16a=c.clone();
}
return _16a;
};
this.cursor_to_end=function(_16e){
var rect=_16e.get_rect();
var c=_16e.clone();
_16e=c.clone();
while(!c.is_line_end()){
c.go_next();
var _171=c.get_rect();
if(_171.left()<rect.right()){
break;
}
rect=_171;
_16e=c.clone();
}
return _16e;
};
this.move_home=function(_172){
var _173=false;
var _174=this.caret_;
this.prepare_before_move_(_172,this.MOVING_LEFT);
this.caret_on_word_=false;
this.on_which_word_=null;
this.caret_=this.cursor_to_home(this.caret_);
if(_172){
this.add_selection_highlight_();
}
if(_174.equals(this.caret_)){
_173=true;
}
this.update_on_move(_173);
};
this.move_end=function(_175){
var _176=false;
var _177=this.caret_;
this.prepare_before_move_(_175,this.MOVING_RIGHT);
this.caret_on_word_=false;
this.on_which_word_=null;
this.caret_=this.cursor_to_end(this.caret_);
if(_175){
this.add_selection_highlight_();
}
if(_177.equals(this.caret_)){
_176=true;
}
this.update_on_move(_176);
};
this.move_up=function(_178){
var _179=false;
var _17a=this.caret_;
if(this.popup_.visible_){
var item=this.on_which_word_.item();
var _17c=item.index();
var _17d=item.options().length;
if(_17d>this.popup_.max_options_){
_17d=this.popup_.max_options_;
}
_17c=(_17c-1)%(_17d);
if(_17c<0){
_17c=_17d-1;
}
item.choose_option(_17c);
this.popup_.update(item);
return;
}
this.prepare_before_move_(_178,this.MOVING_LEFT);
this.caret_on_word_=false;
this.on_which_word_=null;
var prev=this.cursor_to_home(this.caret_);
if(!prev.is_begin()){
prev.go_previous();
var _17f=this.cursor_to_home(prev);
var rect=this.caret_.get_rect();
var x=rect.left();
var y=(rect.top()+rect.bottom())/2;
this.caret_=this.get_nearest_cursor_in_range(_17f,prev,x,y);
}else{
this.caret_=prev;
}
if(_178){
this.add_selection_highlight_();
}
if(_17a.equals(this.caret_)){
_179=true;
}
this.update_on_move(_179);
};
this.move_down=function(_183){
var _184=false;
var _185=this.caret_;
if(this.popup_.visible_){
var item=this.on_which_word_.item();
var _187=item.index();
var _188=item.options().length;
if(_188>this.popup_.max_options_){
_188=this.popup_.max_options_;
}
_187=(_187+1)%(_188);
item.choose_option(_187);
this.popup_.update(item);
return;
}
this.prepare_before_move_(_183,this.MOVING_RIGHT);
this.caret_on_word_=false;
this.on_which_word_=null;
var next=this.cursor_to_end(this.caret_);
if(!next.is_end()){
next.go_next();
var _18a=this.cursor_to_end(next);
var rect=this.caret_.get_rect();
var x=rect.left();
var y=(rect.top()+rect.bottom())/2;
this.caret_=this.get_nearest_cursor_in_range(next,_18a,x,y);
}else{
this.caret_=next;
}
if(_183){
this.add_selection_highlight_();
}
if(_185.equals(this.caret_)){
_184=true;
}
this.update_on_move(_184);
};
this.select_all=function(){
if(this.caret_on_word_){
this.caret_on_word_=false;
this.on_which_word_=null;
}
if(this.anchor_!=null){
this.remove_selection_highlight_();
}
var _18e=this.caret_.clone();
_18e.go_begin();
var end=this.caret_.clone();
end.go_end();
this.caret_=end;
this.set_anchor(_18e);
this.add_selection_highlight_();
this.update_on_move();
};
this.edit_function=function(func){
var _191=this.caret_;
var _192=this.caret_on_word_;
if(_192){
_191=this.on_which_word_;
}
var _193=[];
var _194=false;
if(this.anchor_){
this.remove_selection_highlight_();
var _195;
if(this.anchor_.lesser(this.caret_)){
_195=new QOpDelFragment(this.anchor_,this.caret_);
this.caret_=this.anchor_;
}else{
_195=new QOpDelFragment(this.caret_,this.anchor_);
}
_194=true;
this.anchor_=null;
this.caret_on_word_=false;
_193.push(_195.perform_and_invert(this.ctx_));
}
var edit={op:null,cursor:this.caret_,on_word:false,selection:_194};
bind_this(this,func)(edit);
if(edit.op){
_193.push(edit.op.perform_and_invert(this.ctx_));
}
this.caret_=edit.cursor;
this.caret_on_word_=edit.on_word;
if(edit.on_word){
this.on_which_word_=edit.cursor;
}else{
this.on_which_word_=null;
}
refresh_get_rect();
this.update_on_move();
_193.reverse();
this.undo_list_.push({caret:_191,on_word:_192,op:new QOpGroup(_193)});
this.redo_list_=[];
if(this.edit_callback_){
this.edit_callback_(true);
}
};
this.key_delete=function(){
this.edit_function(function(edit){
if(edit.selection){
return;
}
if(this.caret_on_word_){
var _198=this.on_which_word_;
var end=_198.clone();
end.go_next();
edit.op=new QOpDelFragment(_198,end);
}else{
if(!this.caret_.is_end()){
if(edit.cursor.is_xlit()){
edit.on_word=true;
}else{
var end=edit.cursor.clone();
end.go_next();
edit.op=new QOpDelFragment(edit.cursor,end);
}
}
}
});
};
this.key_backspace=function(){
var _19a=null;
this.edit_function(function(edit){
if(edit.selection){
return;
}
var line=this.caret_.line();
if(this.caret_on_word_){
var item=this.on_which_word_.item();
var _19e=item.english();
assert(_19e.length>0);
_19e=_19e.substring(0,_19e.length-1);
if(_19e.length==0){
var _19f=this.on_which_word_;
var end=_19f.clone();
end.go_next();
edit.op=new QOpDelFragment(_19f,end);
edit.cursor=_19f;
_19a=this.get_new_item_attributes();
}else{
edit.op=new QOpChangeXlitItem(this.on_which_word_,_19e,item.options(),item.index(),item.num(),true);
edit.cursor=this.on_which_word_;
edit.on_word=true;
this.popup_enabled_=true;
}
}else{
if(this.caret_.is_line_begin()&&(line.type()==QLineType.BULLET)){
var _1a1=new QLineAttributes(QLineType.SIMPLE,line.level(),line.align());
edit.op=new QOpFormatLine(this.caret_.u,_1a1);
}else{
if(this.caret_.is_line_begin()&&(this.caret_.line().level()>0)){
var _1a1=new QLineAttributes(line.type(),line.level()-1,line.align());
edit.op=new QOpFormatLine(this.caret_.u,_1a1);
}else{
if(!this.caret_.is_begin()){
var end=this.caret_;
var _19f=end.clone();
_19f.go_previous();
edit.cursor=_19f;
if(_19f.is_xlit()){
edit.on_word=true;
}else{
edit.op=new QOpDelFragment(_19f,end);
}
_19a=this.get_new_item_attributes();
}
}
}
}
});
if(_19a!=null){
this.set_transient_attributes(_19a);
}
};
this.key_enter=function(){
if(this.enter_callback_!=null){
this.enter_callback_();
return;
}
var _1a2=null;
this.edit_function(function(edit){
if(this.caret_on_word_){
this.caret_=this.on_which_word_.clone();
this.caret_.go_next();
this.on_which_word_=null;
this.caret_on_word_=false;
}
var _1a4=new QDFLine([],this.get_line_attributes());
var _1a5=new QDocFragment([],[_1a4]);
edit.op=new QOpAddFragment(this.caret_,_1a5);
edit.cursor=this.caret_.clone();
edit.cursor.u++;
edit.cursor.v=0;
_1a2=this.get_new_item_attributes();
});
this.set_transient_attributes(_1a2);
};
this.key_tab=function(){
this.edit_function(function(edit){
if(this.caret_on_word_){
edit.cursor=this.on_which_word_;
var item=this.on_which_word_.item();
var _1a8=4;
if(item.options().length<5){
_1a8=item.options().length;
}
edit.op=new QOpChangeXlitItem(edit.cursor,item.english(),item.options(),(item.index()+1)%_1a8,item.num(),item.is_updating());
edit.on_word=true;
this.popup_enabled_=true;
}
});
};
this.key_xlit_char=function(ch){
this.edit_function(function(edit){
var _1ab=this.get_new_item_attributes();
if(this.caret_on_word_){
edit.cursor=this.on_which_word_.clone();
var item=edit.cursor.item();
if(item.is_num_){
edit.cursor.go_next();
edit.on_word=true;
var _1ad=new QDFXlit(ch,_1ab,[],0,true,false);
var _1ae=new QDocFragment([_1ad],[]);
edit.op=new QOpAddFragment(edit.cursor,_1ae);
this.popup_enabled_=true;
edit.cursor=edit.cursor.clone();
}else{
edit.cursor=this.on_which_word_;
edit.on_word=true;
var item=edit.cursor.item();
edit.op=new QOpChangeXlitItem(edit.cursor,item.english()+ch,item.options(),item.index(),item.num(),true);
this.popup_enabled_=true;
}
}else{
if(_1ab.lang=="english"){
var _1ad=new QDFText(ch,_1ab);
var _1ae=new QDocFragment([_1ad],[]);
edit.op=new QOpAddFragment(this.caret_,_1ae);
edit.cursor=this.caret_.clone();
edit.cursor.v++;
}else{
var self=this;
function try_itrans_merge(){
var c=self.caret_.clone();
if(c.is_line_begin()){
return false;
}
c.go_previous();
if(c.is_line_begin()){
return false;
}
var _1b1=c.item();
if(!_1b1.is_QTextItem){
return false;
}
var s=_1b1.text();
if((s!=".")&&(s!="/")&&(s!="^")&&(s!="~")){
return false;
}
var xlit=c.previous_item();
if(!xlit.is_QXlitItem){
return false;
}
var _1b4=new QOpDelFragment(c,self.caret_);
c=c.clone();
c.go_previous();
edit.cursor=c;
edit.on_word=true;
var _1b5=new QOpChangeXlitItem(c,xlit.english()+s+ch,xlit.options(),xlit.index(),xlit.num(),true);
edit.op=new QOpGroup([_1b4,_1b5]);
return true;
}
if(!try_itrans_merge()){
var _1ad=new QDFXlit(ch,_1ab,[],0,true,false);
var _1ae=new QDocFragment([_1ad],[]);
edit.op=new QOpAddFragment(this.caret_,_1ae);
edit.cursor=this.caret_;
edit.on_word=true;
}
this.popup_enabled_=true;
}
}
});
};
this.key_num_char=function(ch){
this.edit_function(function(edit){
var _1b8=this.get_new_item_attributes();
if(this.caret_on_word_){
edit.cursor=this.on_which_word_.clone();
var item=edit.cursor.item();
if(!item.is_num_){
edit.cursor.go_next();
edit.on_word=true;
var _1ba=new QDFXlit(ch,_1b8,[],0,true,true);
var _1bb=new QDocFragment([_1ba],[]);
edit.op=new QOpAddFragment(edit.cursor,_1bb);
this.popup_enabled_=true;
edit.cursor=edit.cursor.clone();
}else{
edit.on_word=true;
edit.op=new QOpChangeXlitItem(edit.cursor,item.english()+ch,item.options(),item.index(),item.num(),true);
this.popup_enabled_=true;
}
}else{
if(_1b8.lang=="english"){
var _1ba=new QDFText(ch,_1b8);
var _1bb=new QDocFragment([_1ba],[]);
edit.op=new QOpAddFragment(this.caret_,_1bb);
edit.cursor=this.caret_.clone();
edit.cursor.v++;
}else{
var _1ba=new QDFXlit(ch,_1b8,[],0,true,true);
var _1bb=new QDocFragment([_1ba],[]);
edit.op=new QOpAddFragment(this.caret_,_1bb);
edit.cursor=this.caret_;
edit.on_word=true;
this.popup_enabled_=true;
}
}
});
};
this.key_space=function(ch){
this.key_simple_char(SPACE_CHAR);
};
this.key_simple_char=function(ch){
this.edit_function(function(edit){
if(this.caret_on_word_){
edit.cursor=this.on_which_word_.clone();
edit.cursor.go_next();
}
var _1bf=new QDFText(ch,this.get_new_item_attributes());
var _1c0=new QDocFragment([_1bf],[]);
edit.op=new QOpAddFragment(edit.cursor,_1c0);
edit.cursor=edit.cursor.clone();
edit.cursor.v++;
});
};
this.apply_item_format=function(func){
if(this.anchor_!=null){
var _1c2=this.caret_;
var c1=this.anchor_.clone();
var c2=this.caret_.clone();
if(c1.greater(c2)){
var temp=c1;
c1=c2;
c2=temp;
}
var _1c6=new QItemAttributes(null,null,null,null,null,null,null);
func(_1c6);
var ops=[];
while(c1.not_equals(c2)){
if(!c1.is_line_end()){
ops.push(new QOpFormatItem(c1.clone(),_1c6));
}
c1.go_next();
}
var op=new QOpGroup(ops);
var _1c9=op.perform_and_invert(this.ctx_);
refresh_get_rect();
this.update_on_move();
this.undo_list_.push({caret:_1c2,on_word:false,op:_1c9});
this.redo_list_=[];
}else{
if(this.caret_on_word_){
this.caret_on_word_=false;
this.caret_=this.on_which_word_.clone();
this.caret_.go_next();
this.on_which_word_=null;
}
var a=this.get_new_item_attributes();
func(a);
this.set_transient_attributes(a);
}
};
this.set_lang=function(lang){
this.apply_item_format(function(x){
x.set_lang(lang);
});
};
this.set_font_name=function(name){
this.apply_item_format(function(x){
x.set_font_name(name);
});
};
this.set_font_size=function(size){
this.apply_item_format(function(x){
x.set_font_size(size);
});
};
this.set_bold=function(flag){
this.apply_item_format(function(x){
x.set_bold(flag);
});
};
this.set_italic=function(flag){
this.apply_item_format(function(x){
x.set_italic(flag);
});
};
this.set_underline=function(flag){
this.apply_item_format(function(x){
x.set_underline(flag);
});
};
this.set_color=function(_1d7){
this.apply_item_format(function(x){
x.set_color(_1d7);
});
};
this.set_bg_color=function(_1d9){
this.apply_item_format(function(x){
x.set_bg_color(_1d9);
});
};
this.end_color_change=function(){
if(this.anchor_!=null){
this.add_selection_highlight_();
}
};
this.apply_line_format=function(func){
var _1dc=this.caret_;
var _1dd=this.caret_on_word_;
if(_1dd){
_1dc=this.on_which_word_;
}
var u1=this.caret_.u;
var u2=u1;
if(this.anchor_!=null){
u2=this.anchor_.u;
}
if(u1>u2){
var temp=u1;
u1=u2;
u2=temp;
}
var ops=[];
for(var i=u1;i<=u2;++i){
var a=this.doc_.line(i).get_attributes();
func(a);
var op=new QOpFormatLine(i,a);
ops.push(op);
}
var op=new QOpGroup(ops);
var _1e5=op.perform_and_invert(this.ctx_);
refresh_get_rect();
this.update_on_move();
this.undo_list_.push({caret:_1dc,on_word:_1dd,op:_1e5});
this.redo_list_=[];
};
this.set_align=function(_1e6){
this.apply_line_format(function(a){
a.align=_1e6;
});
};
this.listify=function(){
this.apply_line_format(function(a){
a.type=QLineType.BULLET;
});
};
this.unlistify=function(){
this.apply_line_format(function(a){
a.type=QLineType.SIMPLE;
});
};
this.increase_indent=function(){
this.apply_line_format(function(a){
a.level+=1;
});
};
this.decrease_indent=function(){
this.apply_line_format(function(a){
if(a.level>0){
a.level-=1;
}
});
};
this.can_undo=function(){
return this.undo_list_.length>0;
};
this.undo=function(){
if(this.undo_list_.length==0){
return;
}
if(this.anchor_){
this.remove_selection_highlight_();
this.anchor_=null;
}
var _1ec=this.caret_;
var _1ed=this.caret_on_word_;
if(_1ed){
_1ec=this.on_which_word_;
}
var obj=this.undo_list_.pop();
var _1ef=obj.op.perform_and_invert(this.ctx_);
this.caret_=obj.caret;
this.caret_on_word_=obj.on_word;
if(obj.on_word){
this.on_which_word_=obj.caret;
}else{
this.on_which_word_=null;
}
refresh_get_rect();
this.update_on_move();
this.redo_list_.push({caret:_1ec,on_word:_1ed,op:_1ef});
};
this.can_redo=function(){
return this.redo_list_.length>0;
};
this.redo=function(){
if(this.redo_list_.length==0){
return;
}
if(this.anchor_){
this.remove_selection_highlight_();
this.anchor_=null;
}
var _1f0=this.caret_;
var _1f1=this.caret_on_word_;
if(_1f1){
_1f0=this.on_which_word_;
}
var obj=this.redo_list_.pop();
var _1f3=obj.op.perform_and_invert(this.ctx_);
this.caret_=obj.caret;
this.caret_on_word_=obj.on_word;
if(obj.on_word){
this.on_which_word_=obj.caret;
}else{
this.on_which_word_=null;
}
refresh_get_rect();
this.update_on_move();
this.undo_list_.push({caret:_1f0,on_word:_1f1,op:_1f3});
};
this.make_doc_fragment=function(_1f4,_1f5){
function copy_items_(_1f6,_1f7,i,j){
var _1fa=j-i;
for(;_1fa>0;--_1fa){
var item=_1f7.item(i);
_1f6.push(item_to_df_(item));
i++;
}
}
function copy_items_till_line_end_(_1fc,_1fd){
var line=_1fd.line();
var end=_1fd.clone();
end.go_line_end();
copy_items_(_1fc,line,_1fd.v,end.v);
}
var _200=new QDocFragment([],[]);
var c=_1f4.clone();
var _202=_1f5.u-c.u;
if(_202==0){
copy_items_(_200.initial,c.line(),c.v,_1f5.v);
}else{
copy_items_till_line_end_(_200.initial,c);
c.go_next_line();
for(;_202>0;--_202){
var line=c.line();
var _204=new QDFLine([],line.get_attributes());
_200.lines.push(_204);
if(_202>1){
copy_items_till_line_end_(_204.items,c);
}else{
copy_items_(_204.items,line,c.v,_1f5.v);
}
c.go_next_line();
}
}
return _200;
};
this.get_document=function(){
var _205=this.caret_.clone();
_205.go_begin();
var _206=this.caret_.clone();
_206.go_end();
function copy_items_(_207,_208,i,j){
var _20b=j-i;
for(;_20b>0;--_20b){
var item=_208.item(i);
_207.push(item_to_df_(item));
i++;
}
}
function copy_items_till_line_end_(_20d,_20e){
var line=_20e.line();
var end=_20e.clone();
end.go_line_end();
copy_items_(_20d,line,_20e.v,end.v);
}
var _211=[];
var c=_205.clone();
var _213=_206.u-c.u;
for(;_213>=0;--_213){
var line=c.line();
var _215=new QDFLine([],line.get_attributes());
_211.push(_215);
if(_213>0){
copy_items_till_line_end_(_215.items,c);
}else{
copy_items_(_215.items,line,c.v,_206.v);
}
c.go_next_line();
}
return _211;
};
this.load_document=function(_216){
this.clear_doc();
var _217=this.caret_;
this.add_item_=function(ctx,_219,_21a){
var item;
if(_21a.is_QDFXlit){
item=ctx.new_xlit_item();
item.set_english(_21a.english);
item.set_options(_21a.options);
item.set_index(_21a.index);
item.set_num(_21a.num);
item.set_attributes(_21a.attr);
if(_21a.is_updating){
item.update_xlit();
}
item.update_text();
}else{
if(_21a.is_QDFText){
item=ctx.new_text_item(_21a.text);
item.set_attributes(_21a.attr);
}else{
assert(false);
}
}
_219.line().insert_item(_219.v,item);
};
this.add_blank_line_=function(ctx,_21d,_21e){
var a=_21e.attr;
var line=ctx.new_line(a.type,a.level);
line.set_align(a.align);
line.append_item(ctx.new_text_item(NBSP_CHAR));
ctx.doc.insert_line(_21d,line);
};
var c=_217.clone();
var i,j;
var c2=c.clone();
for(i=0;i<_216.length;++i){
var line=_216[i];
if(i==0){
var _226=c2.line();
var a=line.attr;
_226.set_align(a.align);
_226.set_type_and_level(a.type,a.level);
}else{
this.add_blank_line_(this.ctx_,c2.u+1,line);
c2.go_next_line();
}
for(j=0;j<line.items.length;++j){
this.add_item_(this.ctx_,c2,line.items[j]);
c2.v++;
}
}
this.grab_focus();
};
this.doc_fragment_to_text=function(_228,_229){
var _22a=[];
function add_line(_22b,_22c){
var line=[];
for(var i=0;i<_22b.length;++i){
var t;
if(_229&&_22b[i].is_QDFXlit){
t=_22b[i].get_english();
}else{
t=_22b[i].get_text();
}
if(t==SPACE_CHAR){
t=" ";
}
line.push(t);
}
var s=line.join("");
if(_22c){
s="- "+s;
}
_22a.push(s);
}
add_line(_228.initial,false);
for(var i=0;i<_228.lines.length;++i){
var line=_228.lines[i];
add_line(line.items,line.attr.type==QLineType.BULLET);
}
return _22a.join("\n");
};
this.get_language_text=function(){
var _233=this.caret_.clone();
_233.go_begin();
var end=this.caret_.clone();
end.go_end();
var _235=this.make_doc_fragment(_233,end);
return this.doc_fragment_to_text(_235);
};
this.get_english_text=function(){
var _236=this.caret_.clone();
_236.go_begin();
var end=this.caret_.clone();
end.go_end();
var _238=this.make_doc_fragment(_236,end);
return this.doc_fragment_to_text(_238,true);
};
this.cut=function(c1,c2){
this.c1=c1;
this.c2=c2;
this.edit_function(function(edit){
});
};
this.internal_cut=function(){
if(this.anchor_==null){
return;
}
var _23c=document.getElementById("paste");
_23c.style.display="block";
if(this.anchor_.lesser(this.caret_)){
this.internal_clipboard=this.make_doc_fragment(this.anchor_,this.caret_);
this.cut(this.anchor_,this.caret_);
}else{
this.internal_clipboard=this.make_doc_fragment(this.caret_,this.anchor_);
this.cut(this.caret_,this.anchor_);
}
_23c.value=this.doc_fragment_to_text(this.internal_clipboard);
this.external_clipboard=_23c.value;
_23c.focus();
_23c.select();
if($.browser.msie){
document.execCommand("Copy");
}
var that=this;
var _23e=function(){
_23c.style.display="none";
that.grab_focus();
};
setTimeout(_23e,0);
};
this.paste=function(){
var _23f=document.getElementById("paste");
_23f.style.display="block";
_23f.style.top=this.caret_.get_rect().top();
_23f.focus();
_23f.value="";
var _240=this.external_clipboard;
var that=this;
var _242=function(){
if((jQuery.trim(_23f.value)==jQuery.trim(that.external_clipboard)||(_23f.value.length==0&&that.external_clipboard.length>0))&&that.internal_clipboard){
that.internal_paste();
that.grab_focus();
}else{
that.external_paste(_23f.value);
that.grab_focus();
update_ui_state();
}
_23f.value="";
_23f.style.display="none";
};
setTimeout(_242,0);
};
this.internal_paste=function(){
this.edit_function(function(edit){
if(this.caret_on_word_){
edit.cursor=this.on_which_word_.clone();
edit.cursor.go_next();
}
edit.op=new QOpAddFragment(edit.cursor,this.internal_clipboard);
edit.cursor=edit.op.get_ending_cursor(this.ctx_);
});
};
this.external_paste=function(str){
this.edit_function(function(edit){
if(this.caret_on_word_){
this.caret_=this.on_which_word_.clone();
this.caret_.go_next();
this.on_which_word_=null;
this.caret_on_word_=false;
}
var _246=new QDocFragment([],[]);
var _247=true;
var _248;
var _249=new QLineAttributes(QLineType.SIMPLE,0,QAlign.LEFT);
var _24a=this.get_new_item_attributes();
var _24b=str.split("\n");
this.word="";
this.xlit_word="";
this.move_items_=function(_24c,word,_24e,_24f){
if(_24f){
_24c.push(new QDFText(word,_24e));
}else{
if(_24e.lang=="english"){
for(var k=0;k<word.length;k++){
_24c.push(new QDFText(word.charAt(k),_24e));
}
}else{
_24c.push(new QDFXlit(word,_24e,[],0,true,false));
}
}
};
this.is_alpha=function(ch){
var _252=ch.charCodeAt(0);
if((_252>=97&&_252<97+26)||(_252>=65&&_252<65+26)){
return true;
}
return false;
};
this.is_special=function(ch){
var _254=ch.charCodeAt(0);
if(!this.is_alpha(ch)&&_254>=32&&_254<=126){
return true;
}
return false;
};
this.is_utf=function(ch){
if(!this.is_alpha(ch)&&!this.is_special(ch)){
return true;
}
return false;
};
this.push_word=function(wd){
if(wd=="xlit"&&this.xlit_word.length>0){
this.move_items_(_257,this.xlit_word,_24a,true);
this.xlit_word="";
}
if(wd=="word"&&this.word.length>0){
this.move_items_(_257,this.word,_24a,false);
this.word="";
}
};
for(var j=0;j<_24b.length;j++){
var _257=_246.initial;
if(j>0){
_248=new QDFLine([],_249);
_246.lines.push(_248);
_257=_248.items;
}
for(var i=0;i<_24b[j].length;++i){
if(this.is_alpha(_24b[j].charAt(i))){
this.push_word("xlit");
this.word+=_24b[j].charAt(i);
}else{
if(this.is_utf(_24b[j].charAt(i))){
this.push_word("word");
this.xlit_word+=_24b[j].charAt(i);
}else{
this.push_word("xlit");
this.push_word("word");
if(_24b[j].charAt(i)==" "){
this.move_items_(_257,SPACE_CHAR,_24a,true);
}else{
this.move_items_(_257,_24b[j].charAt(i),_24a,true);
}
}
}
}
this.push_word("xlit");
this.push_word("word");
}
edit.op=new QOpAddFragment(this.caret_,_246);
edit.cursor=edit.op.get_ending_cursor(this.ctx_);
});
};
this.internal_copy=function(){
var sel;
if(this.anchor_==null){
return;
}
var _25b=document.getElementById("paste");
_25b.style.display="block";
if(this.anchor_.lesser(this.caret_)){
this.internal_clipboard=this.make_doc_fragment(this.anchor_,this.caret_);
}else{
this.internal_clipboard=this.make_doc_fragment(this.caret_,this.anchor_);
}
_25b.value=this.doc_fragment_to_text(this.internal_clipboard);
this.external_clipboard=_25b.value;
_25b.focus();
_25b.select();
if($.browser.msie){
document.execCommand("Copy");
}
var that=this;
var _25d=function(){
_25b.style.display="none";
that.grab_focus();
};
setTimeout(_25d,0);
};
this.save=function(val,_25f){
if(!_25f){
_25f="Untitled";
}
var _260="http://quillpad.in/hindi/backend2/";
var ifra=document.getElementById("saveiFrame");
var _262=ifra.contentDocument?ifra.contentDocument:ifra.contentWindow.document;
var _263=this.ctx_.root.innerHTML;
var _264=_262.getElementById("data");
var _265=_262.getElementById("filename");
if(val=="text"){
_264.value=this.get_language_text();
_260=_260+"save_as_text";
}else{
if(val=="html"){
_264.value=_263;
_260=_260+"save";
}
}
_265.value=_25f;
var _266=_262.getElementById("saveForm");
_266.action=_260;
_266.submit();
};
this.clear_doc=function(){
this.select_all();
if(this.anchor_.lesser(this.caret_)){
this.internal_clipboard=this.make_doc_fragment(this.anchor_,this.caret_);
this.cut(this.anchor_,this.caret_);
}else{
this.internal_clipboard=this.make_doc_fragment(this.caret_,this.anchor_);
this.cut(this.caret_,this.anchor_);
}
this.undo_list_=[];
this.redo_list_=[];
this.internal_clipboard;
this.external_clipboard="";
this.transient_attributes_=null;
this.anchor_=null;
this.caret_=new QCursor(this.doc_,0,0);
this.caret_on_word_=false;
this.on_which_word_=null;
update_ui_state();
};
this.init_(_110,root,_112);
}

