/* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.plugins.add('dialogui');(function(){var a=function(h){var k=this;k._||(k._={});k._['default']=k._.initValue=h['default']||'';var i=[k._];for(var j=1;j',i.label,'','
',k(h,i),'
');else{var p={type:'hbox',widths:i.widths,padding:0,children:[{type:'html',html:''+CKEDITOR.tools.htmlEncode(i.label)+''},{type:'html',html:''+k(h,i)+''}]};CKEDITOR.dialog._.uiElementBuilders.hbox.build(h,p,o);}return o.join('');};CKEDITOR.ui.dialog.uiElement.call(this,h,i,j,'div',null,null,n);},textInput:function(h,i,j){if(arguments.length<3)return;a.call(this,i);var k=this._.inputId=CKEDITOR.tools.getNextNumber()+'_textInput',l={'class':'cke_dialog_ui_input_'+i.type,id:k,type:'text'},m;if(i.validate)this.validate=i.validate;if(i.maxLength)l.maxlength=i.maxLength;if(i.size)l.size=i.size;var n=this,o=false;h.on('load',function(){n.getInputElement().on('keydown',function(q){if(q.data.getKeystroke()==13)o=true;});n.getInputElement().on('keyup',function(q){if(q.data.getKeystroke()==13&&o){h.getButton('ok')&&h.getButton('ok').click(); o=false;}},null,null,1000);});var p=function(){var q=['
');return q.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,h,i,j,p);},textarea:function(h,i,j){if(arguments.length<3)return;a.call(this,i);var k=this,l=this._.inputId=CKEDITOR.tools.getNextNumber()+'_textarea',m={};if(i.validate)this.validate=i.validate;m.rows=i.rows||5;m.cols=i.cols||20;var n=function(){var o=['
');return o.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,h,i,j,n);},checkbox:function(h,i,j){if(arguments.length<3)return;var k=a.call(this,i,{'default':!!i['default']});if(i.validate)this.validate=i.validate;var l=function(){var m=CKEDITOR.tools.extend({},i,{id:i.id?i.id+'_checkbox':CKEDITOR.tools.getNextNumber()+'_checkbox'},true),n=[],o={'class':'cke_dialog_ui_checkbox_input',type:'checkbox'};g(m);if(i['default'])o.checked='checked';k.checkbox=new CKEDITOR.ui.dialog.uiElement(h,m,n,'input',null,o);n.push(' ');return n.join('');};CKEDITOR.ui.dialog.uiElement.call(this,h,i,j,'span',null,null,l);},radio:function(h,i,j){if(arguments.length<3)return;a.call(this,i);if(!this._['default'])this._['default']=this._.initValue=i.items[0][1];if(i.validate)this.validate=i.valdiate;var k=[],l=this,m=function(){var n=[],o=[],p={'class':'cke_dialog_ui_radio_item'},q=i.id?i.id+'_radio':CKEDITOR.tools.getNextNumber()+'_radio';for(var r=0;r'+CKEDITOR.tools.htmlEncode(i.label)+'');},select:function(h,i,j){if(arguments.length<3)return;var k=a.call(this,i);if(i.validate)this.validate=i.validate;var l=function(){var m=CKEDITOR.tools.extend({},i,{id:i.id?i.id+'_select':CKEDITOR.tools.getNextNumber()+'_select'},true),n=[],o=[],p={'class':'cke_dialog_ui_input_select'};if(i.size!=undefined)p.size=i.size;if(i.multiple!=undefined)p.multiple=i.multiple;g(m);for(var q=0,r;q ',CKEDITOR.tools.htmlEncode(r[0]));k.select=new CKEDITOR.ui.dialog.uiElement(h,m,n,'select',null,p,o.join(''));return n.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,h,i,j,l);},file:function(h,i,j){if(arguments.length<3)return;if(i['default']===undefined)i['default']='';var k=CKEDITOR.tools.extend(a.call(this,i),{definition:i,buttons:[]});if(i.validate)this.validate=i.validate;var l=function(){k.frameId=CKEDITOR.tools.getNextNumber()+'_fileInput';var m=CKEDITOR.env.isCustomDomain(),n=['');return n.join('');};h.on('load',function(){var m=CKEDITOR.document.getById(k.frameId),n=m.getParent();n.addClass('cke_dialog_ui_input_file');});CKEDITOR.ui.dialog.labeledElement.call(this,h,i,j,l);},fileButton:function(h,i,j){if(arguments.length<3)return;var k=a.call(this,i),l=this;if(i.validate)this.validate=i.validate;var m=CKEDITOR.tools.extend({},i),n=m.onClick;m.className=(m.className?m.className+' ':'')+('cke_dialog_ui_button');m.onClick=function(o){var p=i['for'];if(!n||n.call(this,o)!==false){h.getContentElement(p[0],p[1]).submit();this.disable();}};h.on('load',function(){h.getContentElement(i['for'][0],i['for'][1])._.buttons.push(l); });CKEDITOR.ui.dialog.button.call(this,h,m,j);},html:(function(){var h=/^\s*<[\w:]+\s+([^>]*)?>/,i=/^(\s*<[\w:]+(?:\s+[^>]*)?)((?:.|\r|\n)+)$/,j=/\/$/;return function(k,l,m){if(arguments.length<3)return;var n=[],o,p=l.html,q,r;if(p.charAt(0)!='<')p=''+p+'';if(l.focus){var s=this.focus;this.focus=function(){s.call(this);l.focus.call(this);this.fire('focus');};if(l.isFocusable){var t=this.isFocusable;this.isFocusable=t;}this.keyboardFocusable=true;}CKEDITOR.ui.dialog.uiElement.call(this,k,l,n,'span',null,null,'');o=n.join('');q=o.match(h);r=p.match(i)||['','',''];if(j.test(r[1])){r[1]=r[1].slice(0,-1);r[2]='/'+r[2];}m.push([r[1],' ',q[1]||'',r[2]].join(''));};})()},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(h){var i=CKEDITOR.document.getById(this._.labelId);if(i.getChildCount()<1)new CKEDITOR.dom.text(h,CKEDITOR.document).appendTo(i);else i.getChild(0).$.nodeValue=h;return this;},getLabel:function(){var h=CKEDITOR.document.getById(this._.labelId);if(!h||h.getChildCount()<1)return '';else return h.getChild(0).getText();},eventProcessors:e},true);CKEDITOR.ui.dialog.button.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement(),{click:function(){var h=this;if(!h._.disabled)return h.fire('click',{dialog:h._.dialog});h.getElement().$.blur();return false;},enable:function(){this._.disabled=false;var h=this.getElement();h&&h.removeClass('disabled');},disable:function(){this._.disabled=true;this.getElement().addClass('disabled');},isVisible:function(){return!!this.getElement().$.firstChild.offsetHeight;},isEnabled:function(){return!this._.disabled;},eventProcessors:CKEDITOR.tools.extend({},CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,{onClick:function(h,i){this.on('click',i);}},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 h=this.selectParentTab();setTimeout(function(){var i=h.getInputElement();i&&i.$.focus();},0);},select:function(){var h=this.selectParentTab();setTimeout(function(){var i=h.getInputElement();if(i){i.$.focus();i.$.select();}},0);},accessKeyUp:function(){this.select();},setValue:function(h){h=h||'';return CKEDITOR.ui.dialog.uiElement.prototype.setValue.call(this,h); },keyboardFocusable:true},d,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(h,i,j){var k=new CKEDITOR.dom.element('option',this.getDialog().getParentEditor().document),l=this.getInputElement().$;k.$.text=h;k.$.value=i===undefined||i===null?h:i;if(j===undefined||j===null){if(CKEDITOR.env.ie)l.add(k.$);else l.add(k.$,null);}else l.add(k.$,j);return this;},remove:function(h){var i=this.getInputElement().$;i.remove(h);return this;},clear:function(){var h=this.getInputElement().$;while(h.length>0)h.remove(0);return this;},keyboardFocusable:true},d,true);CKEDITOR.ui.dialog.checkbox.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement(),{getInputElement:function(){return this._.checkbox.getElement();},setValue:function(h){this.getInputElement().$.checked=h;this.fire('change',{value:h});},getValue:function(){return this.getInputElement().$.checked;},accessKeyUp:function(){this.setValue(!this.getValue());},eventProcessors:{onChange:function(h,i){if(!CKEDITOR.env.ie)return e.onChange.apply(this,arguments);else{h.on('load',function(){var j=this._.checkbox.getElement();j.on('propertychange',function(k){k=k.data.$;if(k.propertyName=='checked')this.fire('change',{value:j.$.checked});},this);},this);this.on('change',i);}return null;}},keyboardFocusable:true},d,true);CKEDITOR.ui.dialog.radio.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement(),{setValue:function(h){var i=this._.children,j;for(var k=0;k0?new CKEDITOR.dom.element(h.$.forms[0].elements[0]):this.getElement();},submit:function(){this.getInputElement().getParent().$.submit();return this;},getAction:function(h){return this.getInputElement().getParent().$.action;},reset:function(){var h=CKEDITOR.document.getById(this._.frameId),i=h.getFrameDocument(),j=this._.definition,k=this._.buttons;function l(){i.$.open();if(CKEDITOR.env.isCustomDomain())i.$.domain=document.domain;var m='';if(j.size)m=j.size-(CKEDITOR.env.ie?7:0);i.$.write(['','
','','
',''].join(''));i.$.close();for(var n=0;n