CKEDITOR.plugins.add('dialogui');(function(){var a=function(i){var l=this;l._||(l._={});l._['default']=l._.initValue=i['default']||'';l._.required=i.required||false;var j=[l._];for(var k=1;k<arguments.length;k++)j.push(arguments[k]);j.push(true);CKEDITOR.tools.extend.apply(CKEDITOR.tools,j);return l._;},b={build:function(i,j,k){return new CKEDITOR.ui.dialog.textInput(i,j,k);}},c={build:function(i,j,k){return new CKEDITOR.ui.dialog[j.type](i,j,k);}},d={build:function(i,j,k){var l=j.children,m,n=[],o=[];for(var p=0;p<l.length&&(m=l[p]);p++){var q=[];n.push(q);o.push(CKEDITOR.dialog._.uiElementBuilders[m.type].build(i,m,q));}return new CKEDITOR.ui.dialog[j.type](i,o,n,k,j);}},e={isChanged:function(){return this.getValue()!=this.getInitValue();},reset:function(){this.setValue(this.getInitValue());},setInitValue:function(){this._.initValue=this.getValue();},resetInitValue:function(){this._.initValue=this._['default'];},getInitValue:function(){return this._.initValue;}},f=CKEDITOR.tools.extend({},CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,{onChange:function(i,j){if(!this._.domOnChangeRegistered){i.on('load',function(){this.getInputElement().on('change',function(){if(!i.parts.dialog.isVisible())return;this.fire('change',{value:this.getValue()});},this);},this);this._.domOnChangeRegistered=true;}this.on('change',j);}},true),g=/^on([A-Z]\w+)/,h=function(i){for(var j in i){if(g.test(j)||j=='title'||j=='type')delete i[j];}return i;};CKEDITOR.tools.extend(CKEDITOR.ui.dialog,{labeledElement:function(i,j,k,l){if(arguments.length<4)return;var m=a.call(this,j);m.labelId=CKEDITOR.tools.getNextNumber()+'_label';var n=this._.children=[],o=function(){var p=[];if(j.labelLayout!='horizontal')p.push('<label class="cke_dialog_ui_labeled_label" ',' id="'+m.labelId+'"',' for="'+m.inputId+'"',' style="'+j.labelStyle+'">',j.label,'</label>','<div class="cke_dialog_ui_labeled_content" role="presentation">',l.call(this,i,j),'</div>');else{var q={type:'hbox',widths:j.widths,padding:0,children:[{type:'html',html:'<label class="cke_dialog_ui_labeled_label" id="'+m.labelId+'"'+' for="'+m.inputId+'"'+' style="'+j.labelStyle+'">'+CKEDITOR.tools.htmlEncode(j.label)+'</span>'},{type:'html',html:'<span class="cke_dialog_ui_labeled_content">'+l.call(this,i,j)+'</span>'}]};CKEDITOR.dialog._.uiElementBuilders.hbox.build(i,q,p);}return p.join('');};CKEDITOR.ui.dialog.uiElement.call(this,i,j,k,'div',null,{role:'presentation'},o);},textInput:function(i,j,k){if(arguments.length<3)return;a.call(this,j);
var l=this._.inputId=CKEDITOR.tools.getNextNumber()+'_textInput',m={'class':'cke_dialog_ui_input_'+j.type,id:l,type:'text'},n;if(j.validate)this.validate=j.validate;if(j.maxLength)m.maxlength=j.maxLength;if(j.size)m.size=j.size;var o=this,p=false;i.on('load',function(){o.getInputElement().on('keydown',function(r){if(r.data.getKeystroke()==13)p=true;});o.getInputElement().on('keyup',function(r){if(r.data.getKeystroke()==13&&p){i.getButton('ok')&&setTimeout(function(){i.getButton('ok').click();},0);p=false;}},null,null,1000);});var q=function(){var r=['<div class="cke_dialog_ui_input_',j.type,'" role="presentation"'];if(j.width)r.push('style="width:'+j.width+'" ');r.push('><input ');m['aria-labelledby']=this._.labelId;this._.required&&(m['aria-required']=this._.required);for(var s in m)r.push(s+'="'+m[s]+'" ');r.push(' /></div>');return r.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,i,j,k,q);},textarea:function(i,j,k){if(arguments.length<3)return;a.call(this,j);var l=this,m=this._.inputId=CKEDITOR.tools.getNextNumber()+'_textarea',n={};if(j.validate)this.validate=j.validate;n.rows=j.rows||5;n.cols=j.cols||20;var o=function(){n['aria-labelledby']=this._.labelId;this._.required&&(n['aria-required']=this._.required);var p=['<div class="cke_dialog_ui_input_textarea" role="presentation"><textarea class="cke_dialog_ui_input_textarea" id="',m,'" '];for(var q in n)p.push(q+'="'+CKEDITOR.tools.htmlEncode(n[q])+'" ');p.push('>',CKEDITOR.tools.htmlEncode(l._['default']),'</textarea></div>');return p.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,i,j,k,o);},checkbox:function(i,j,k){if(arguments.length<3)return;var l=a.call(this,j,{'default':!!j['default']});if(j.validate)this.validate=j.validate;var m=function(){var n=CKEDITOR.tools.extend({},j,{id:j.id?j.id+'_checkbox':CKEDITOR.tools.getNextNumber()+'_checkbox'},true),o=[],p=CKEDITOR.tools.getNextNumber()+'_label',q={'class':'cke_dialog_ui_checkbox_input',type:'checkbox','aria-labelledby':p};h(n);if(j['default'])q.checked='checked';l.checkbox=new CKEDITOR.ui.dialog.uiElement(i,n,o,'input',null,q);o.push(' <label id="',p,'" for="',q.id,'">',CKEDITOR.tools.htmlEncode(j.label),'</label>');return o.join('');};CKEDITOR.ui.dialog.uiElement.call(this,i,j,k,'span',null,null,m);},radio:function(i,j,k){if(arguments.length<3)return;a.call(this,j);if(!this._['default'])this._['default']=this._.initValue=j.items[0][1];if(j.validate)this.validate=j.valdiate;var l=[],m=this,n=function(){var o=[],p=[],q={'class':'cke_dialog_ui_radio_item','aria-labelledby':this._.labelId},r=j.id?j.id+'_radio':CKEDITOR.tools.getNextNumber()+'_radio';
for(var s=0;s<j.items.length;s++){var t=j.items[s],u=t[2]!==undefined?t[2]:t[0],v=t[1]!==undefined?t[1]:t[0],w=CKEDITOR.tools.getNextNumber()+'_radio_input',x=w+'_label',y=CKEDITOR.tools.extend({},j,{id:w,title:null,type:null},true),z=CKEDITOR.tools.extend({},y,{title:u},true),A={type:'radio','class':'cke_dialog_ui_radio_input',name:r,value:v,'aria-labelledby':x},B=[];if(m._['default']==v)A.checked='checked';h(y);h(z);l.push(new CKEDITOR.ui.dialog.uiElement(i,y,B,'input',null,A));B.push(' ');new CKEDITOR.ui.dialog.uiElement(i,z,B,'label',null,{id:x,'for':A.id},t[0]);o.push(B.join(''));}new CKEDITOR.ui.dialog.hbox(i,[],o,p);return p.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,i,j,k,n);this._.children=l;},button:function(i,j,k){if(!arguments.length)return;if(typeof j=='function')j=j(i.getParentEditor());a.call(this,j,{disabled:j.disabled||false});CKEDITOR.event.implementOn(this);var l=this;i.on('load',function(o){var p=this.getElement();(function(){p.on('click',function(q){l.fire('click',{dialog:l.getDialog()});q.data.preventDefault();});p.on('keydown',function(q){if(q.data.getKeystroke() in {32:1}){l.click();q.data.preventDefault();}});})();p.unselectable();},this);var m=CKEDITOR.tools.extend({},j);delete m.style;var n=CKEDITOR.tools.getNextNumber()+'_label';CKEDITOR.ui.dialog.uiElement.call(this,i,m,k,'a',null,{style:j.style,href:'javascript:void(0)',title:j.label,hidefocus:'true','class':j['class'],role:'button','aria-labelledby':n},'<span id="'+n+'" class="cke_dialog_ui_button">'+CKEDITOR.tools.htmlEncode(j.label)+'</span>');},select:function(i,j,k){if(arguments.length<3)return;var l=a.call(this,j);if(j.validate)this.validate=j.validate;l.inputId=CKEDITOR.tools.getNextNumber()+'_select';var m=function(){var n=CKEDITOR.tools.extend({},j,{id:j.id?j.id+'_select':CKEDITOR.tools.getNextNumber()+'_select'},true),o=[],p=[],q={id:l.inputId,'class':'cke_dialog_ui_input_select','aria-labelledby':this._.labelId};if(j.size!=undefined)q.size=j.size;if(j.multiple!=undefined)q.multiple=j.multiple;h(n);for(var r=0,s;r<j.items.length&&(s=j.items[r]);r++)p.push('<option value="',CKEDITOR.tools.htmlEncode(s[1]!==undefined?s[1]:s[0]),'" /> ',CKEDITOR.tools.htmlEncode(s[0]));l.select=new CKEDITOR.ui.dialog.uiElement(i,n,o,'select',null,q,p.join(''));return o.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,i,j,k,m);},file:function(i,j,k){if(arguments.length<3)return;if(j['default']===undefined)j['default']='';var l=CKEDITOR.tools.extend(a.call(this,j),{definition:j,buttons:[]});
if(j.validate)this.validate=j.validate;var m=function(){l.frameId=CKEDITOR.tools.getNextNumber()+'_fileInput';var n=CKEDITOR.env.isCustomDomain(),o=['<iframe frameborder="0" allowtransparency="0" class="cke_dialog_ui_input_file" id="',l.frameId,'" title="',j.label,'" src="javascript:void('];o.push(n?"(function(){document.open();document.domain='"+document.domain+"';"+'document.close();'+'})()':'0');o.push(')"></iframe>');return o.join('');};i.on('load',function(){var n=CKEDITOR.document.getById(l.frameId),o=n.getParent();o.addClass('cke_dialog_ui_input_file');});CKEDITOR.ui.dialog.labeledElement.call(this,i,j,k,m);},fileButton:function(i,j,k){if(arguments.length<3)return;var l=a.call(this,j),m=this;if(j.validate)this.validate=j.validate;var n=CKEDITOR.tools.extend({},j),o=n.onClick;n.className=(n.className?n.className+' ':'')+'cke_dialog_ui_button';n.onClick=function(p){var q=j['for'];if(!o||o.call(this,p)!==false){i.getContentElement(q[0],q[1]).submit();this.disable();}};i.on('load',function(){i.getContentElement(j['for'][0],j['for'][1])._.buttons.push(m);});CKEDITOR.ui.dialog.button.call(this,i,n,k);},html:(function(){var i=/^\s*<[\w:]+\s+([^>]*)?>/,j=/^(\s*<[\w:]+(?:\s+[^>]*)?)((?:.|\r|\n)+)$/,k=/\/$/;return function(l,m,n){if(arguments.length<3)return;var o=[],p,q=m.html,r,s;if(q.charAt(0)!='<')q='<span>'+q+'</span>';var t=m.focus;if(t){var u=this.focus;this.focus=function(){u.call(this);typeof t=='function'&&t.call(this);this.fire('focus');};if(m.isFocusable){var v=this.isFocusable;this.isFocusable=v;}this.keyboardFocusable=true;}CKEDITOR.ui.dialog.uiElement.call(this,l,m,o,'span',null,null,'');p=o.join('');r=p.match(i);s=q.match(j)||['','',''];if(k.test(s[1])){s[1]=s[1].slice(0,-1);s[2]='/'+s[2];}n.push([s[1],' ',r[1]||'',s[2]].join(''));};})(),fieldset:function(i,j,k,l,m){var n=m.label,o=function(){var p=[];n&&p.push('<legend>'+n+'</legend>');for(var q=0;q<k.length;q++)p.push(k[q]);return p.join('');};this._={children:j};CKEDITOR.ui.dialog.uiElement.call(this,i,m,l,'fieldset',null,null,o);}},true);CKEDITOR.ui.dialog.html.prototype=new CKEDITOR.ui.dialog.uiElement();CKEDITOR.ui.dialog.labeledElement.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement(),{setLabel:function(i){var j=CKEDITOR.document.getById(this._.labelId);if(j.getChildCount()<1)new CKEDITOR.dom.text(i,CKEDITOR.document).appendTo(j);else j.getChild(0).$.nodeValue=i;return this;},getLabel:function(){var i=CKEDITOR.document.getById(this._.labelId);if(!i||i.getChildCount()<1)return '';
else return i.getChild(0).getText();},eventProcessors:f},true);CKEDITOR.ui.dialog.button.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement(),{click:function(){var i=this;if(!i._.disabled)return i.fire('click',{dialog:i._.dialog});i.getElement().$.blur();return false;},enable:function(){this._.disabled=false;var i=this.getElement();i&&i.removeClass('disabled');},disable:function(){this._.disabled=true;this.getElement().addClass('disabled');},isVisible:function(){return this.getElement().getFirst().isVisible();},isEnabled:function(){return!this._.disabled;},eventProcessors:CKEDITOR.tools.extend({},CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,{onClick:function(i,j){this.on('click',j);}},true),accessKeyUp:function(){this.click();},accessKeyDown:function(){this.focus();},keyboardFocusable:true},true);CKEDITOR.ui.dialog.textInput.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement(),{getInputElement:function(){return CKEDITOR.document.getById(this._.inputId);},focus:function(){var i=this.selectParentTab();setTimeout(function(){var j=i.getInputElement();j&&j.$.focus();},0);},select:function(){var i=this.selectParentTab();setTimeout(function(){var j=i.getInputElement();if(j){j.$.focus();j.$.select();}},0);},accessKeyUp:function(){this.select();},setValue:function(i){!i&&(i='');return CKEDITOR.ui.dialog.uiElement.prototype.setValue.call(this,i);},keyboardFocusable:true},e,true);CKEDITOR.ui.dialog.textarea.prototype=new CKEDITOR.ui.dialog.textInput();CKEDITOR.ui.dialog.select.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement(),{getInputElement:function(){return this._.select.getElement();},add:function(i,j,k){var l=new CKEDITOR.dom.element('option',this.getDialog().getParentEditor().document),m=this.getInputElement().$;l.$.text=i;l.$.value=j===undefined||j===null?i:j;if(k===undefined||k===null){if(CKEDITOR.env.ie)m.add(l.$);else m.add(l.$,null);}else m.add(l.$,k);return this;},remove:function(i){var j=this.getInputElement().$;j.remove(i);return this;},clear:function(){var i=this.getInputElement().$;while(i.length>0)i.remove(0);return this;},keyboardFocusable:true},e,true);CKEDITOR.ui.dialog.checkbox.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement(),{getInputElement:function(){return this._.checkbox.getElement();},setValue:function(i){this.getInputElement().$.checked=i;this.fire('change',{value:i});},getValue:function(){return this.getInputElement().$.checked;},accessKeyUp:function(){this.setValue(!this.getValue());
},eventProcessors:{onChange:function(i,j){if(!CKEDITOR.env.ie)return f.onChange.apply(this,arguments);else{i.on('load',function(){var k=this._.checkbox.getElement();k.on('propertychange',function(l){l=l.data.$;if(l.propertyName=='checked')this.fire('change',{value:k.$.checked});},this);},this);this.on('change',j);}return null;}},keyboardFocusable:true},e,true);CKEDITOR.ui.dialog.radio.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement(),{setValue:function(i){var j=this._.children,k;for(var l=0;l<j.length&&(k=j[l]);l++)k.getElement().$.checked=k.getValue()==i;this.fire('change',{value:i});},getValue:function(){var i=this._.children;for(var j=0;j<i.length;j++){if(i[j].getElement().$.checked)return i[j].getValue();}return null;},accessKeyUp:function(){var i=this._.children,j;for(j=0;j<i.length;j++){if(i[j].getElement().$.checked){i[j].getElement().focus();return;}}i[0].getElement().focus();},eventProcessors:{onChange:function(i,j){if(!CKEDITOR.env.ie)return f.onChange.apply(this,arguments);else{i.on('load',function(){var k=this._.children,l=this;for(var m=0;m<k.length;m++){var n=k[m].getElement();n.on('propertychange',function(o){o=o.data.$;if(o.propertyName=='checked'&&this.$.checked)l.fire('change',{value:this.getAttribute('value')});});}},this);this.on('change',j);}return null;}},keyboardFocusable:true},e,true);CKEDITOR.ui.dialog.file.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement(),e,{getInputElement:function(){var i=CKEDITOR.document.getById(this._.frameId).getFrameDocument();return i.$.forms.length>0?new CKEDITOR.dom.element(i.$.forms[0].elements[0]):this.getElement();},submit:function(){this.getInputElement().getParent().$.submit();return this;},getAction:function(i){return this.getInputElement().getParent().$.action;},reset:function(){var i=CKEDITOR.document.getById(this._.frameId),j=i.getFrameDocument(),k=this._.definition,l=this._.buttons;function m(){j.$.open();if(CKEDITOR.env.isCustomDomain())j.$.domain=document.domain;var n='';if(k.size)n=k.size-(CKEDITOR.env.ie?7:0);j.$.write(['<html><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">','<form enctype="multipart/form-data" method="POST" action="',CKEDITOR.tools.htmlEncode(k.action),'">','<input type="file" name="',CKEDITOR.tools.htmlEncode(k.id||'cke_upload'),'" size="',CKEDITOR.tools.htmlEncode(n>0?n:''),'" />','</form>','</body></html>'].join(''));j.$.close();for(var o=0;o<l.length;o++)l[o].enable();};if(CKEDITOR.env.gecko)setTimeout(m,500);
else m();},getValue:function(){return '';},eventProcessors:f,keyboardFocusable:true},true);CKEDITOR.ui.dialog.fileButton.prototype=new CKEDITOR.ui.dialog.button();CKEDITOR.ui.dialog.fieldset.prototype=CKEDITOR.tools.clone(CKEDITOR.ui.dialog.hbox.prototype);CKEDITOR.dialog.addUIElement('text',b);CKEDITOR.dialog.addUIElement('password',b);CKEDITOR.dialog.addUIElement('textarea',c);CKEDITOR.dialog.addUIElement('checkbox',c);CKEDITOR.dialog.addUIElement('radio',c);CKEDITOR.dialog.addUIElement('button',c);CKEDITOR.dialog.addUIElement('select',c);CKEDITOR.dialog.addUIElement('file',c);CKEDITOR.dialog.addUIElement('fileButton',c);CKEDITOR.dialog.addUIElement('html',c);CKEDITOR.dialog.addUIElement('fieldset',d);})();
