JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.3
[ckeditor.git] / plugins / image / dialogs / image.js
index 09eaf4c..e71e160 100644 (file)
@@ -1,13 +1,13 @@
 /*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
-(function(){var a=1,b=2,c=4,d=8,e=/^\s*(\d+)((px)|\%)?\s*$/i,f=/(^\s*(\d+)((px)|\%)?\s*$)|^$/i,g=function(){var m=this.getValue(),n=this.getDialog(),o=m.match(e);if(o){if(o[2]=='%')i(n,false);m=o[1];}if(n.lockRatio){var p=n.originalElement;if(p.getCustomData('isReady')=='true')if(this.id=='txtHeight'){if(m&&m!='0')m=Math.round(p.$.width*(m/p.$.height));if(!isNaN(m))n.setValueOf('info','txtWidth',m);}else{if(m&&m!='0')m=Math.round(p.$.height*(m/p.$.width));if(!isNaN(m))n.setValueOf('info','txtHeight',m);}}h(n);},h=function(m){if(!m.originalElement||!m.preview)return 1;m.commitContent(c,m.preview);return 0;},i=function(m,n){var o=m.originalElement,p=CKEDITOR.document.getById('btnLockSizes');if(o.getCustomData('isReady')=='true'){if(n=='check'){var q=m.getValueOf('info','txtWidth'),r=m.getValueOf('info','txtHeight'),s=o.$.width*1000/o.$.height,t=q*1000/r;m.lockRatio=false;if(!q&&!r)m.lockRatio=true;else if(!isNaN(s)&&!isNaN(t))if(Math.round(s)==Math.round(t))m.lockRatio=true;}else if(n!=undefined)m.lockRatio=n;else m.lockRatio=!m.lockRatio;}else if(n!='check')m.lockRatio=false;if(m.lockRatio)p.removeClass('cke_btn_unlocked');else p.addClass('cke_btn_unlocked');return m.lockRatio;},j=function(m){var n=m.originalElement;if(n.getCustomData('isReady')=='true'){m.setValueOf('info','txtWidth',n.$.width);m.setValueOf('info','txtHeight',n.$.height);}h(m);},k=function(m,n){if(m!=a)return;function o(t,u){var v=t.match(e);if(v){if(v[2]=='%'){v[1]+='%';i(p,false);}return v[1];}return u;};var p=this.getDialog(),q='',r=this.id=='txtWidth'?'width':'height',s=n.getAttribute(r);if(s)q=o(s,q);q=o(n.$.style[r],q);this.setValue(q);},l=function(m,n){var o=function(){var r=this;var q=r.originalElement;q.setCustomData('isReady','true');q.removeListener('load',o);q.removeListener('error',p);q.removeListener('abort',p);CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');if(!r.dontResetSize)j(r);if(r.firstLoad)i(r,'check');r.firstLoad=false;r.dontResetSize=false;},p=function(){var s=this;var q=s.originalElement;q.removeListener('load',o);q.removeListener('error',p);q.removeListener('abort',p);var r=CKEDITOR.getUrl(m.skinPath+'images/noimage.png');if(s.preview)s.preview.setAttribute('src',r);CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');i(s,false);};return{title:n=='image'?m.lang.image.title:m.lang.image.titleButton,minWidth:420,minHeight:310,onShow:function(){var w=this;w.imageElement=false;w.linkElement=false;w.imageEditMode=false;w.linkEditMode=false;\r
-w.lockRatio=true;w.dontResetSize=false;w.firstLoad=true;w.addLink=false;CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');w.preview=CKEDITOR.document.getById('previewImage');var q=w.getParentEditor(),r=w.getParentEditor().getSelection(),s=r.getSelectedElement(),t=s&&s.getAscendant('a');w.originalElement=q.document.createElement('img');w.originalElement.setAttribute('alt','');w.originalElement.setCustomData('isReady','false');if(t){w.linkElement=t;w.linkEditMode=true;var u=t.getChildren();if(u.count()==1){var v=u.getItem(0).getName();if(v=='img'||v=='input'){w.imageElement=u.getItem(0);if(w.imageElement.getName()=='img')w.imageEditMode='img';else if(w.imageElement.getName()=='input')w.imageEditMode='input';}}if(n=='image')w.setupContent(b,t);}if(s&&s.getName()=='img'&&!s.getAttribute('_cke_protected_html'))w.imageEditMode='img';else if(s&&s.getName()=='input'&&s.getAttribute('type')&&s.getAttribute('type')=='image')w.imageEditMode='input';if(w.imageEditMode||w.imageElement){if(!w.imageElement)w.imageElement=s;w.setupContent(a,w.imageElement);i(w,true);}if(!CKEDITOR.tools.trim(w.getValueOf('info','txtUrl'))){w.preview.removeAttribute('src');w.preview.setStyle('display','none');}},onOk:function(){var r=this;if(r.imageEditMode){var q=r.imageEditMode;if(n=='image'&&q=='input'&&confirm(m.lang.image.button2Img)){q='img';r.imageElement=m.document.createElement('img');r.imageElement.setAttribute('alt','');m.insertElement(r.imageElement);}else if(n!='image'&&q=='img'&&confirm(m.lang.image.img2Button)){q='input';r.imageElement=m.document.createElement('input');r.imageElement.setAttributes({type:'image',alt:''});m.insertElement(r.imageElement);}}else{if(n=='image')r.imageElement=m.document.createElement('img');else{r.imageElement=m.document.createElement('input');r.imageElement.setAttribute('type','image');}r.imageElement.setAttribute('alt','');}if(!r.linkEditMode)r.linkElement=m.document.createElement('a');r.commitContent(a,r.imageElement);r.commitContent(b,r.linkElement);if(!r.imageEditMode){if(r.addLink){if(!r.linkEditMode){m.insertElement(r.linkElement);r.linkElement.append(r.imageElement,false);}else m.insertElement(r.imageElement);}else m.insertElement(r.imageElement);}else if(!r.linkEditMode&&r.addLink){m.insertElement(r.linkElement);r.imageElement.appendTo(r.linkElement);}else if(r.linkEditMode&&!r.addLink){m.getSelection().selectElement(r.linkElement);m.insertElement(r.imageElement);}},onLoad:function(){var r=this;if(n!='image')r.hidePage('Link');\r
-var q=r._.element.getDocument();r.addFocusable(q.getById('btnResetSize'),5);r.addFocusable(q.getById('btnLockSizes'),5);},onHide:function(){var q=this;if(q.preview)q.commitContent(d,q.preview);if(q.originalElement){q.originalElement.removeListener('load',o);q.originalElement.removeListener('error',p);q.originalElement.removeListener('abort',p);q.originalElement.remove();q.originalElement=false;}},contents:[{id:'info',label:m.lang.image.infoTab,accessKey:'I',elements:[{type:'vbox',padding:0,children:[{type:'html',html:'<span>'+CKEDITOR.tools.htmlEncode(m.lang.image.url)+'</span>'},{type:'hbox',widths:['280px','110px'],align:'right',children:[{id:'txtUrl',type:'text',label:'',onChange:function(){var q=this.getDialog(),r=this.getValue();if(r.length>0){q=this.getDialog();var s=q.originalElement;q.preview.removeStyle('display');s.setCustomData('isReady','false');var t=CKEDITOR.document.getById('ImagePreviewLoader');if(t)t.setStyle('display','');s.on('load',o,q);s.on('error',p,q);s.on('abort',p,q);s.setAttribute('src',r);q.preview.setAttribute('src',r);h(q);}else if(q.preview){q.preview.removeAttribute('src');q.preview.setStyle('display','none');}},setup:function(q,r){if(q==a){var s=r.getAttribute('_cke_saved_src')||r.getAttribute('src'),t=this;this.getDialog().dontResetSize=true;setTimeout(function(){t.setValue(s);t.setInitValue();t.focus();},0);}},commit:function(q,r){var s=this;if(q==a&&(s.getValue()||s.isChanged())){r.setAttribute('_cke_saved_src',decodeURI(s.getValue()));r.setAttribute('src',decodeURI(s.getValue()));}else if(q==d){r.setAttribute('src','');r.removeAttribute('src');}},validate:CKEDITOR.dialog.validate.notEmpty(m.lang.image.urlMissing)},{type:'button',id:'browse',align:'center',label:m.lang.common.browseServer,hidden:true,filebrowser:'info:txtUrl'}]}]},{id:'txtAlt',type:'text',label:m.lang.image.alt,accessKey:'A','default':'',onChange:function(){h(this.getDialog());},setup:function(q,r){if(q==a)this.setValue(r.getAttribute('alt'));},commit:function(q,r){var s=this;if(q==a){if(s.getValue()||s.isChanged())r.setAttribute('alt',s.getValue());}else if(q==c)r.setAttribute('alt',s.getValue());else if(q==d)r.removeAttribute('alt');}},{type:'hbox',widths:['140px','240px'],children:[{type:'vbox',padding:10,children:[{type:'hbox',widths:['70%','30%'],children:[{type:'vbox',padding:1,children:[{type:'text',width:'40px',id:'txtWidth',labelLayout:'horizontal',label:m.lang.image.width,onKeyUp:g,validate:function(){var q=this.getValue().match(f);if(!q)alert(m.lang.common.validateNumberFailed);\r
-return!!q;},setup:k,commit:function(q,r){var v=this;if(q==a){var s=v.getValue();if(s)r.setAttribute('width',s);else if(!s&&v.isChanged())r.removeAttribute('width');}else if(q==c){s=v.getValue();var t=s.match(e);if(!t){var u=v.getDialog().originalElement;if(u.getCustomData('isReady')=='true')r.setStyle('width',u.$.width+'px');}else r.setStyle('width',s+'px');}else if(q==d){r.setStyle('width','0px');r.removeAttribute('width');r.removeStyle('width');}}},{type:'text',id:'txtHeight',width:'40px',labelLayout:'horizontal',label:m.lang.image.height,onKeyUp:g,validate:function(){var q=this.getValue().match(f);if(!q)alert(m.lang.common.validateNumberFailed);return!!q;},setup:k,commit:function(q,r){var v=this;if(q==a){var s=v.getValue();if(s)r.setAttribute('height',s);else if(!s&&v.isChanged())r.removeAttribute('height');}else if(q==c){s=v.getValue();var t=s.match(e);if(!t){var u=v.getDialog().originalElement;if(u.getCustomData('isReady')=='true')r.setStyle('height',u.$.height+'px');}else r.setStyle('height',s+'px');}else if(q==d){r.setStyle('height','0px');r.removeAttribute('height');r.removeStyle('height');}}}]},{type:'html',style:'margin-top:10px;width:40px;height:40px;',onLoad:function(){var q=CKEDITOR.document.getById('btnResetSize'),r=CKEDITOR.document.getById('btnLockSizes');if(q){q.on('click',function(){j(this);},this.getDialog());q.on('mouseover',function(){this.addClass('cke_btn_over');},q);q.on('mouseout',function(){this.removeClass('cke_btn_over');},q);}if(r){r.on('click',function(){var w=this;var s=i(w),t=w.originalElement,u=w.getValueOf('info','txtWidth');if(t.getCustomData('isReady')=='true'&&u){var v=t.$.height/t.$.width*u;if(!isNaN(v)){w.setValueOf('info','txtHeight',Math.round(v));h(w);}}},this.getDialog());r.on('mouseover',function(){this.addClass('cke_btn_over');},r);r.on('mouseout',function(){this.removeClass('cke_btn_over');},r);}},html:'<div><a href="javascript:void(0)" tabindex="-1" title="'+m.lang.image.lockRatio+'" class="cke_btn_locked" id="btnLockSizes"></a>'+'<a href="javascript:void(0)" tabindex="-1" title="'+m.lang.image.resetSize+'" class="cke_btn_reset" id="btnResetSize"></a>'+'</div>'}]},{type:'vbox',padding:1,children:[{type:'text',id:'txtBorder',width:'60px',labelLayout:'horizontal',label:m.lang.image.border,'default':'',onKeyUp:function(){h(this.getDialog());},validate:function(){var q=CKEDITOR.dialog.validate.integer(m.lang.common.validateNumberFailed);return q.apply(this);},setup:function(q,r){if(q==a)this.setValue(r.getAttribute('border'));\r
-},commit:function(q,r){var t=this;if(q==a){if(t.getValue()||t.isChanged())r.setAttribute('border',t.getValue());}else if(q==c){var s=parseInt(t.getValue(),10);s=isNaN(s)?0:s;r.setAttribute('border',s);r.setStyle('border',s+'px solid black');}else if(q==d){r.removeAttribute('border');r.removeStyle('border');}}},{type:'text',id:'txtHSpace',width:'60px',labelLayout:'horizontal',label:m.lang.image.hSpace,'default':'',onKeyUp:function(){h(this.getDialog());},validate:function(){var q=CKEDITOR.dialog.validate.integer(m.lang.common.validateNumberFailed);return q.apply(this);},setup:function(q,r){if(q==a){var s=r.getAttribute('hspace');if(s!=-1)this.setValue(s);}},commit:function(q,r){var t=this;if(q==a){if(t.getValue()||t.isChanged())r.setAttribute('hspace',t.getValue());}else if(q==c){var s=parseInt(t.getValue(),10);s=isNaN(s)?0:s;r.setAttribute('hspace',s);r.setStyle('margin-left',s+'px');r.setStyle('margin-right',s+'px');}else if(q==d){r.removeAttribute('hspace');r.removeStyle('margin-left');r.removeStyle('margin-right');}}},{type:'text',id:'txtVSpace',width:'60px',labelLayout:'horizontal',label:m.lang.image.vSpace,'default':'',onKeyUp:function(){h(this.getDialog());},validate:function(){var q=CKEDITOR.dialog.validate.integer(m.lang.common.validateNumberFailed);return q.apply(this);},setup:function(q,r){if(q==a)this.setValue(r.getAttribute('vspace'));},commit:function(q,r){var t=this;if(q==a){if(t.getValue()||t.isChanged())r.setAttribute('vspace',t.getValue());}else if(q==c){var s=parseInt(t.getValue(),10);s=isNaN(s)?0:s;r.setAttribute('vspace',t.getValue());r.setStyle('margin-top',s+'px');r.setStyle('margin-bottom',s+'px');}else if(q==d){r.removeAttribute('vspace');r.removeStyle('margin-top');r.removeStyle('margin-bottom');}}},{id:'cmbAlign',type:'select',labelLayout:'horizontal',widths:['35%','65%'],style:'width:90px',label:m.lang.image.align,'default':'',items:[[m.lang.common.notSet,''],[m.lang.image.alignLeft,'left'],[m.lang.image.alignAbsBottom,'absBottom'],[m.lang.image.alignAbsMiddle,'absMiddle'],[m.lang.image.alignBaseline,'baseline'],[m.lang.image.alignBottom,'bottom'],[m.lang.image.alignMiddle,'middle'],[m.lang.image.alignRight,'right'],[m.lang.image.alignTextTop,'textTop'],[m.lang.image.alignTop,'top']],onChange:function(){h(this.getDialog());},setup:function(q,r){if(q==a)this.setValue(r.getAttribute('align'));},commit:function(q,r){var s=this.getValue();if(q==a){if(s||this.isChanged())r.setAttribute('align',s);}else if(q==c){r.setAttribute('align',this.getValue());\r
-if(s=='absMiddle'||s=='middle')r.setStyle('vertical-align','middle');else if(s=='top'||s=='textTop')r.setStyle('vertical-align','top');else r.removeStyle('vertical-align');if(s=='right'||s=='left')r.setStyle('styleFloat',s);else r.removeStyle('styleFloat');}else if(q==d)r.removeAttribute('align');}}]}]},{type:'vbox',height:'250px',children:[{type:'html',style:'width:95%;',html:'<div>'+CKEDITOR.tools.htmlEncode(m.lang.image.preview)+'<br>'+'<div id="ImagePreviewLoader" style="display:none"><div class="loading">&nbsp;</div></div>'+'<div id="ImagePreviewBox">'+'<a href="javascript:void(0)" target="_blank" onclick="return false;" id="previewLink">'+'<img id="previewImage" src="" alt="" /></a>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. '+'Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, '+'nulla. Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris.'+'</div>'+'</div>'}]}]}]},{id:'Link',label:m.lang.link.title,padding:0,elements:[{id:'txtUrl',type:'text',label:m.lang.image.url,style:'width: 100%','default':'',setup:function(q,r){if(q==b){var s=r.getAttribute('_cke_saved_href');if(!s)s=r.getAttribute('href');this.setValue(s);}},commit:function(q,r){var s=this;if(q==b)if(s.getValue()||s.isChanged()){r.setAttribute('_cke_saved_href',decodeURI(s.getValue()));r.setAttribute('href','javascript:void(0)/*'+CKEDITOR.tools.getNextNumber()+'*/');if(s.getValue()||!m.config.image_removeLinkByEmptyURL)s.getDialog().addLink=true;}}},{type:'button',id:'browse',filebrowser:'Link:txtUrl',style:'float:right',hidden:true,label:m.lang.common.browseServer},{id:'cmbTarget',type:'select',label:m.lang.link.target,'default':'',items:[[m.lang.link.targetNotSet,''],[m.lang.link.targetNew,'_blank'],[m.lang.link.targetTop,'_top'],[m.lang.link.targetSelf,'_self'],[m.lang.link.targetParent,'_parent']],setup:function(q,r){if(q==b)this.setValue(r.getAttribute('target'));\r
-},commit:function(q,r){if(q==b)if(this.getValue()||this.isChanged())r.setAttribute('target',this.getValue());}}]},{id:'Upload',hidden:true,filebrowser:'uploadButton',label:m.lang.image.upload,elements:[{type:'file',id:'upload',label:m.lang.image.btnUpload,style:'height:40px',size:38},{type:'fileButton',id:'uploadButton',filebrowser:'info:txtUrl',label:m.lang.image.btnUpload,'for':['Upload','upload']}]},{id:'advanced',label:m.lang.common.advancedTab,elements:[{type:'hbox',widths:['50%','25%','25%'],children:[{type:'text',id:'linkId',label:m.lang.common.id,setup:function(q,r){if(q==a)this.setValue(r.getAttribute('id'));},commit:function(q,r){if(q==a)if(this.getValue()||this.isChanged())r.setAttribute('id',this.getValue());}},{id:'cmbLangDir',type:'select',style:'width : 100px;',label:m.lang.common.langDir,'default':'',items:[[m.lang.common.notSet,''],[m.lang.common.langDirLtr,'ltr'],[m.lang.common.langDirRtl,'rtl']],setup:function(q,r){if(q==a)this.setValue(r.getAttribute('dir'));},commit:function(q,r){if(q==a)if(this.getValue()||this.isChanged())r.setAttribute('dir',this.getValue());}},{type:'text',id:'txtLangCode',label:m.lang.common.langCode,'default':'',setup:function(q,r){if(q==a)this.setValue(r.getAttribute('lang'));},commit:function(q,r){if(q==a)if(this.getValue()||this.isChanged())r.setAttribute('lang',this.getValue());}}]},{type:'text',id:'txtGenLongDescr',label:m.lang.common.longDescr,setup:function(q,r){if(q==a)this.setValue(r.getAttribute('longDesc'));},commit:function(q,r){if(q==a)if(this.getValue()||this.isChanged())r.setAttribute('longDesc',this.getValue());}},{type:'hbox',widths:['50%','50%'],children:[{type:'text',id:'txtGenClass',label:m.lang.common.cssClass,'default':'',setup:function(q,r){if(q==a)this.setValue(r.getAttribute('class'));},commit:function(q,r){if(q==a)if(this.getValue()||this.isChanged())r.setAttribute('class',this.getValue());}},{type:'text',id:'txtGenTitle',label:m.lang.common.advisoryTitle,'default':'',onChange:function(){h(this.getDialog());},setup:function(q,r){if(q==a)this.setValue(r.getAttribute('title'));},commit:function(q,r){var s=this;if(q==a){if(s.getValue()||s.isChanged())r.setAttribute('title',s.getValue());}else if(q==c)r.setAttribute('title',s.getValue());else if(q==d)r.removeAttribute('title');}}]},{type:'text',id:'txtdlgGenStyle',label:m.lang.common.cssStyle,'default':'',setup:function(q,r){if(q==a){var s=r.getAttribute('style');if(!s&&r.$.style.cssText)s=r.$.style.cssText;this.setValue(s);var t=r.$.style.height,u=r.$.style.width,v=(t?t:'').match(e),w=(u?u:'').match(e);\r
-this.attributesInStyle={height:!!v,width:!!w};}},commit:function(q,r){var u=this;if(q==a&&(u.getValue()||u.isChanged())){r.setAttribute('style',u.getValue());var s=r.getAttribute('height'),t=r.getAttribute('width');if(u.attributesInStyle&&u.attributesInStyle.height)if(s){if(s.match(e)[2]=='%')r.setStyle('height',s+'%');else r.setStyle('height',s+'px');}else r.removeStyle('height');if(u.attributesInStyle&&u.attributesInStyle.width)if(t){if(t.match(e)[2]=='%')r.setStyle('width',t+'%');else r.setStyle('width',t+'px');}else r.removeStyle('width');}}}]}]};};CKEDITOR.dialog.add('image',function(m){return l(m,'image');});CKEDITOR.dialog.add('imagebutton',function(m){return l(m,'imagebutton');});})();\r
+(function(){var a=function(b,c){var d=1,e=2,f=4,g=8,h=/^\s*(\d+)((px)|\%)?\s*$/i,i=/(^\s*(\d+)((px)|\%)?\s*$)|^$/i,j=/^\d+px$/,k=function(){var C=this.getValue(),D=this.getDialog(),E=C.match(h);if(E){if(E[2]=='%')p(D,false);C=E[1];}if(D.lockRatio){var F=D.originalElement;if(F.getCustomData('isReady')=='true')if(this.id=='txtHeight'){if(C&&C!='0')C=Math.round(F.$.width*(C/F.$.height));if(!isNaN(C))D.setValueOf('info','txtWidth',C);}else{if(C&&C!='0')C=Math.round(F.$.height*(C/F.$.width));if(!isNaN(C))D.setValueOf('info','txtHeight',C);}}l(D);},l=function(C){if(!C.originalElement||!C.preview)return 1;C.commitContent(f,C.preview);return 0;};function m(){var C=arguments,D=this.getContentElement('advanced','txtdlgGenStyle');D&&D.commit.apply(D,C);this.foreach(function(E){if(E.commit&&E.id!='txtdlgGenStyle')E.commit.apply(E,C);});};var n;function o(C){if(n)return;n=1;var D=this.getDialog(),E=D.imageElement;if(E){this.commit(d,E);C=[].concat(C);var F=C.length,G;for(var H=0;H<F;H++){G=D.getContentElement.apply(D,C[H].split(':'));G&&G.setup(d,E);}}n=0;};var p=function(C,D){var E=C.originalElement;if(!E)return null;var F=CKEDITOR.document.getById(w);if(E.getCustomData('isReady')=='true'){if(D=='check'){var G=C.getValueOf('info','txtWidth'),H=C.getValueOf('info','txtHeight'),I=E.$.width*1000/E.$.height,J=G*1000/H;C.lockRatio=false;if(!G&&!H)C.lockRatio=true;else if(!isNaN(I)&&!isNaN(J))if(Math.round(I)==Math.round(J))C.lockRatio=true;}else if(D!=undefined)C.lockRatio=D;else C.lockRatio=!C.lockRatio;}else if(D!='check')C.lockRatio=false;if(C.lockRatio)F.removeClass('cke_btn_unlocked');else F.addClass('cke_btn_unlocked');var K=C._.editor.lang.image,L=K[C.lockRatio?'unlockRatio':'lockRatio'];F.setAttribute('title',L);F.getFirst().setText(L);return C.lockRatio;},q=function(C){var D=C.originalElement;if(D.getCustomData('isReady')=='true'){C.setValueOf('info','txtWidth',D.$.width);C.setValueOf('info','txtHeight',D.$.height);}l(C);},r=function(C,D){if(C!=d)return;function E(J,K){var L=J.match(h);if(L){if(L[2]=='%'){L[1]+='%';p(F,false);}return L[1];}return K;};var F=this.getDialog(),G='',H=this.id=='txtWidth'?'width':'height',I=D.getAttribute(H);if(I)G=E(I,G);G=E(D.getStyle(H),G);this.setValue(G);},s,t=function(){var C=this.originalElement;C.setCustomData('isReady','true');C.removeListener('load',t);C.removeListener('error',u);C.removeListener('abort',u);CKEDITOR.document.getById(y).setStyle('display','none');if(!this.dontResetSize)q(this);if(this.firstLoad)CKEDITOR.tools.setTimeout(function(){p(this,'check');\r
+},0,this);this.firstLoad=false;this.dontResetSize=false;},u=function(){var E=this;var C=E.originalElement;C.removeListener('load',t);C.removeListener('error',u);C.removeListener('abort',u);var D=CKEDITOR.getUrl(b.skinPath+'images/noimage.png');if(E.preview)E.preview.setAttribute('src',D);CKEDITOR.document.getById(y).setStyle('display','none');p(E,false);},v=function(C){return CKEDITOR.tools.getNextId()+'_'+C;},w=v('btnLockSizes'),x=v('btnResetSize'),y=v('ImagePreviewLoader'),z=v('ImagePreviewBox'),A=v('previewLink'),B=v('previewImage');return{title:c=='image'?b.lang.image.title:b.lang.image.titleButton,minWidth:420,minHeight:310,onShow:function(){var I=this;I.imageElement=false;I.linkElement=false;I.imageEditMode=false;I.linkEditMode=false;I.lockRatio=true;I.dontResetSize=false;I.firstLoad=true;I.addLink=false;var C=I.getParentEditor(),D=I.getParentEditor().getSelection(),E=D.getSelectedElement(),F=E&&E.getAscendant('a');CKEDITOR.document.getById(y).setStyle('display','none');s=new CKEDITOR.dom.element('img',C.document);I.preview=CKEDITOR.document.getById(B);I.originalElement=C.document.createElement('img');I.originalElement.setAttribute('alt','');I.originalElement.setCustomData('isReady','false');if(F){I.linkElement=F;I.linkEditMode=true;var G=F.getChildren();if(G.count()==1){var H=G.getItem(0).getName();if(H=='img'||H=='input'){I.imageElement=G.getItem(0);if(I.imageElement.getName()=='img')I.imageEditMode='img';else if(I.imageElement.getName()=='input')I.imageEditMode='input';}}if(c=='image')I.setupContent(e,F);}if(E&&E.getName()=='img'&&!E.getAttribute('_cke_realelement')||E&&E.getName()=='input'&&E.getAttribute('type')=='image'){I.imageEditMode=E.getName();I.imageElement=E;}if(I.imageEditMode){I.cleanImageElement=I.imageElement;I.imageElement=I.cleanImageElement.clone(true,true);I.setupContent(d,I.imageElement);p(I,true);}else I.imageElement=C.document.createElement('img');if(!CKEDITOR.tools.trim(I.getValueOf('info','txtUrl'))){I.preview.removeAttribute('src');I.preview.setStyle('display','none');}},onOk:function(){var D=this;if(D.imageEditMode){var C=D.imageEditMode;if(c=='image'&&C=='input'&&confirm(b.lang.image.button2Img)){C='img';D.imageElement=b.document.createElement('img');D.imageElement.setAttribute('alt','');b.insertElement(D.imageElement);}else if(c!='image'&&C=='img'&&confirm(b.lang.image.img2Button)){C='input';D.imageElement=b.document.createElement('input');D.imageElement.setAttributes({type:'image',alt:''});b.insertElement(D.imageElement);\r
+}else{D.imageElement=D.cleanImageElement;delete D.cleanImageElement;}}else{if(c=='image')D.imageElement=b.document.createElement('img');else{D.imageElement=b.document.createElement('input');D.imageElement.setAttribute('type','image');}D.imageElement.setAttribute('alt','');}if(!D.linkEditMode)D.linkElement=b.document.createElement('a');D.commitContent(d,D.imageElement);D.commitContent(e,D.linkElement);if(!D.imageElement.getAttribute('style'))D.imageElement.removeAttribute('style');if(!D.imageEditMode){if(D.addLink){if(!D.linkEditMode){b.insertElement(D.linkElement);D.linkElement.append(D.imageElement,false);}else b.insertElement(D.imageElement);}else b.insertElement(D.imageElement);}else if(!D.linkEditMode&&D.addLink){b.insertElement(D.linkElement);D.imageElement.appendTo(D.linkElement);}else if(D.linkEditMode&&!D.addLink){b.getSelection().selectElement(D.linkElement);b.insertElement(D.imageElement);}},onLoad:function(){var D=this;if(c!='image')D.hidePage('Link');var C=D._.element.getDocument();D.addFocusable(C.getById(x),5);D.addFocusable(C.getById(w),5);D.commitContent=m;},onHide:function(){var C=this;if(C.preview)C.commitContent(g,C.preview);if(C.originalElement){C.originalElement.removeListener('load',t);C.originalElement.removeListener('error',u);C.originalElement.removeListener('abort',u);C.originalElement.remove();C.originalElement=false;}delete C.imageElement;},contents:[{id:'info',label:b.lang.image.infoTab,accessKey:'I',elements:[{type:'vbox',padding:0,children:[{type:'hbox',widths:['280px','110px'],align:'right',children:[{id:'txtUrl',type:'text',label:b.lang.common.url,required:true,onChange:function(){var C=this.getDialog(),D=this.getValue();if(D.length>0){C=this.getDialog();var E=C.originalElement;C.preview.removeStyle('display');E.setCustomData('isReady','false');var F=CKEDITOR.document.getById(y);if(F)F.setStyle('display','');E.on('load',t,C);E.on('error',u,C);E.on('abort',u,C);E.setAttribute('src',D);s.setAttribute('src',D);C.preview.setAttribute('src',s.$.src);l(C);}else if(C.preview){C.preview.removeAttribute('src');C.preview.setStyle('display','none');}},setup:function(C,D){if(C==d){var E=D.getAttribute('_cke_saved_src')||D.getAttribute('src'),F=this;this.getDialog().dontResetSize=true;F.setValue(E);F.setInitValue();}},commit:function(C,D){var E=this;if(C==d&&(E.getValue()||E.isChanged())){D.setAttribute('_cke_saved_src',decodeURI(E.getValue()));D.setAttribute('src',decodeURI(E.getValue()));}else if(C==g){D.setAttribute('src','');D.removeAttribute('src');\r
+}},validate:CKEDITOR.dialog.validate.notEmpty(b.lang.image.urlMissing)},{type:'button',id:'browse',style:'display:inline-block;margin-top:10px;',align:'center',label:b.lang.common.browseServer,hidden:true,filebrowser:'info:txtUrl'}]}]},{id:'txtAlt',type:'text',label:b.lang.image.alt,accessKey:'T','default':'',onChange:function(){l(this.getDialog());},setup:function(C,D){if(C==d)this.setValue(D.getAttribute('alt'));},commit:function(C,D){var E=this;if(C==d){if(E.getValue()||E.isChanged())D.setAttribute('alt',E.getValue());}else if(C==f)D.setAttribute('alt',E.getValue());else if(C==g)D.removeAttribute('alt');}},{type:'hbox',widths:['140px','240px'],children:[{type:'vbox',padding:10,children:[{type:'hbox',widths:['70%','30%'],children:[{type:'vbox',padding:1,children:[{type:'text',width:'40px',id:'txtWidth',labelLayout:'horizontal',label:b.lang.image.width,onKeyUp:k,onChange:function(){o.call(this,'advanced:txtdlgGenStyle');},validate:function(){var C=this.getValue().match(i);if(!C)alert(b.lang.image.validateWidth);return!!C;},setup:r,commit:function(C,D,E){var F=this.getValue();if(C==d){if(F)D.setStyle('width',CKEDITOR.tools.cssLength(F));else if(!F&&this.isChanged())D.removeStyle('width');!E&&D.removeAttribute('width');}else if(C==f){var G=F.match(h);if(!G){var H=this.getDialog().originalElement;if(H.getCustomData('isReady')=='true')D.setStyle('width',H.$.width+'px');}else D.setStyle('width',CKEDITOR.tools.cssLength(F));}else if(C==g){D.removeAttribute('width');D.removeStyle('width');}}},{type:'text',id:'txtHeight',width:'40px',labelLayout:'horizontal',label:b.lang.image.height,onKeyUp:k,onChange:function(){o.call(this,'advanced:txtdlgGenStyle');},validate:function(){var C=this.getValue().match(i);if(!C)alert(b.lang.image.validateHeight);return!!C;},setup:r,commit:function(C,D,E){var F=this.getValue();if(C==d){if(F)D.setStyle('height',CKEDITOR.tools.cssLength(F));else if(!F&&this.isChanged())D.removeStyle('height');if(!E&&C==d)D.removeAttribute('height');}else if(C==f){var G=F.match(h);if(!G){var H=this.getDialog().originalElement;if(H.getCustomData('isReady')=='true')D.setStyle('height',H.$.height+'px');}else D.setStyle('height',CKEDITOR.tools.cssLength(F));}else if(C==g){D.removeAttribute('height');D.removeStyle('height');}}}]},{type:'html',style:'margin-top:10px;width:40px;height:40px;',onLoad:function(){var C=CKEDITOR.document.getById(x),D=CKEDITOR.document.getById(w);if(C){C.on('click',function(E){q(this);E.data.preventDefault();},this.getDialog());C.on('mouseover',function(){this.addClass('cke_btn_over');\r
+},C);C.on('mouseout',function(){this.removeClass('cke_btn_over');},C);}if(D){D.on('click',function(E){var J=this;var F=p(J),G=J.originalElement,H=J.getValueOf('info','txtWidth');if(G.getCustomData('isReady')=='true'&&H){var I=G.$.height/G.$.width*H;if(!isNaN(I)){J.setValueOf('info','txtHeight',Math.round(I));l(J);}}E.data.preventDefault();},this.getDialog());D.on('mouseover',function(){this.addClass('cke_btn_over');},D);D.on('mouseout',function(){this.removeClass('cke_btn_over');},D);}},html:'<div><a href="javascript:void(0)" tabindex="-1" title="'+b.lang.image.unlockRatio+'" class="cke_btn_locked" id="'+w+'" role="button"><span class="cke_label">'+b.lang.image.unlockRatio+'</span></a>'+'<a href="javascript:void(0)" tabindex="-1" title="'+b.lang.image.resetSize+'" class="cke_btn_reset" id="'+x+'" role="button"><span class="cke_label">'+b.lang.image.resetSize+'</span></a>'+'</div>'}]},{type:'vbox',padding:1,children:[{type:'text',id:'txtBorder',width:'60px',labelLayout:'horizontal',label:b.lang.image.border,'default':'',onKeyUp:function(){l(this.getDialog());},onChange:function(){o.call(this,'advanced:txtdlgGenStyle');},validate:CKEDITOR.dialog.validate.integer(b.lang.image.validateBorder),setup:function(C,D){if(C==d){var E,F=D.getStyle('border-width');F=F&&F.match(/^(\d+px)(?: \1 \1 \1)?$/);E=F&&parseInt(F[1],10);isNaN(parseInt(E,10))&&(E=D.getAttribute('border'));this.setValue(E);}},commit:function(C,D,E){var F=parseInt(this.getValue(),10);if(C==d||C==f){if(!isNaN(F)){D.setStyle('border-width',CKEDITOR.tools.cssLength(F));D.setStyle('border-style','solid');}else if(!F&&this.isChanged()){D.removeStyle('border-width');D.removeStyle('border-style');D.removeStyle('border-color');}if(!E&&C==d)D.removeAttribute('border');}else if(C==g){D.removeAttribute('border');D.removeStyle('border-width');D.removeStyle('border-style');D.removeStyle('border-color');}}},{type:'text',id:'txtHSpace',width:'60px',labelLayout:'horizontal',label:b.lang.image.hSpace,'default':'',onKeyUp:function(){l(this.getDialog());},onChange:function(){o.call(this,'advanced:txtdlgGenStyle');},validate:CKEDITOR.dialog.validate.integer(b.lang.image.validateHSpace),setup:function(C,D){if(C==d){var E,F,G,H=D.getStyle('margin-left'),I=D.getStyle('margin-right');H=H&&H.match(j);I=I&&I.match(j);F=parseInt(H,10);G=parseInt(I,10);E=F==G&&F;isNaN(parseInt(E,10))&&(E=D.getAttribute('hspace'));this.setValue(E);}},commit:function(C,D,E){var F=parseInt(this.getValue(),10);if(C==d||C==f){if(!isNaN(F)){D.setStyle('margin-left',CKEDITOR.tools.cssLength(F));\r
+D.setStyle('margin-right',CKEDITOR.tools.cssLength(F));}else if(!F&&this.isChanged()){D.removeStyle('margin-left');D.removeStyle('margin-right');}if(!E&&C==d)D.removeAttribute('hspace');}else if(C==g){D.removeAttribute('hspace');D.removeStyle('margin-left');D.removeStyle('margin-right');}}},{type:'text',id:'txtVSpace',width:'60px',labelLayout:'horizontal',label:b.lang.image.vSpace,'default':'',onKeyUp:function(){l(this.getDialog());},onChange:function(){o.call(this,'advanced:txtdlgGenStyle');},validate:CKEDITOR.dialog.validate.integer(b.lang.image.validateVSpace),setup:function(C,D){if(C==d){var E,F,G,H=D.getStyle('margin-top'),I=D.getStyle('margin-bottom');H=H&&H.match(j);I=I&&I.match(j);F=parseInt(H,10);G=parseInt(I,10);E=F==G&&F;isNaN(parseInt(E,10))&&(E=D.getAttribute('vspace'));this.setValue(E);}},commit:function(C,D,E){var F=parseInt(this.getValue(),10);if(C==d||C==f){if(!isNaN(F)){D.setStyle('margin-top',CKEDITOR.tools.cssLength(F));D.setStyle('margin-bottom',CKEDITOR.tools.cssLength(F));}else if(!F&&this.isChanged()){D.removeStyle('margin-top');D.removeStyle('margin-bottom');}if(!E&&C==d)D.removeAttribute('vspace');}else if(C==g){D.removeAttribute('vspace');D.removeStyle('margin-top');D.removeStyle('margin-bottom');}}},{id:'cmbAlign',type:'select',labelLayout:'horizontal',widths:['35%','65%'],style:'width:90px',label:b.lang.image.align,'default':'',items:[[b.lang.common.notSet,''],[b.lang.image.alignLeft,'left'],[b.lang.image.alignRight,'right']],onChange:function(){l(this.getDialog());o.call(this,'advanced:txtdlgGenStyle');},setup:function(C,D){if(C==d){var E=D.getStyle('float');switch(E){case 'inherit':case 'none':E='';}!E&&(E=(D.getAttribute('align')||'').toLowerCase());this.setValue(E);}},commit:function(C,D,E){var F=this.getValue();if(C==d||C==f){if(F)D.setStyle('float',F);else D.removeStyle('float');if(!E&&C==d){F=(D.getAttribute('align')||'').toLowerCase();switch(F){case 'left':case 'right':D.removeAttribute('align');}}}else if(C==g)D.removeStyle('float');}}]}]},{type:'vbox',height:'250px',children:[{type:'html',style:'width:95%;',html:'<div>'+CKEDITOR.tools.htmlEncode(b.lang.common.preview)+'<br>'+'<div id="'+y+'" class="ImagePreviewLoader" style="display:none"><div class="loading">&nbsp;</div></div>'+'<div id="'+z+'" class="ImagePreviewBox"><table><tr><td>'+'<a href="javascript:void(0)" target="_blank" onclick="return false;" id="'+A+'">'+'<img id="'+B+'" alt="" /></a>'+(b.config.image_previewText||'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, nulla. Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris.')+'</td></tr></table></div></div>'}]}]}]},{id:'Link',label:b.lang.link.title,padding:0,elements:[{id:'txtUrl',type:'text',label:b.lang.common.url,style:'width: 100%','default':'',setup:function(C,D){if(C==e){var E=D.getAttribute('_cke_saved_href');\r
+if(!E)E=D.getAttribute('href');this.setValue(E);}},commit:function(C,D){var E=this;if(C==e)if(E.getValue()||E.isChanged()){D.setAttribute('_cke_saved_href',decodeURI(E.getValue()));D.setAttribute('href','javascript:void(0)/*'+CKEDITOR.tools.getNextNumber()+'*/');if(E.getValue()||!b.config.image_removeLinkByEmptyURL)E.getDialog().addLink=true;}}},{type:'button',id:'browse',filebrowser:{action:'Browse',target:'Link:txtUrl',url:b.config.filebrowserImageBrowseLinkUrl},style:'float:right',hidden:true,label:b.lang.common.browseServer},{id:'cmbTarget',type:'select',label:b.lang.common.target,'default':'',items:[[b.lang.common.notSet,''],[b.lang.common.targetNew,'_blank'],[b.lang.common.targetTop,'_top'],[b.lang.common.targetSelf,'_self'],[b.lang.common.targetParent,'_parent']],setup:function(C,D){if(C==e)this.setValue(D.getAttribute('target')||'');},commit:function(C,D){if(C==e)if(this.getValue()||this.isChanged())D.setAttribute('target',this.getValue());}}]},{id:'Upload',hidden:true,filebrowser:'uploadButton',label:b.lang.image.upload,elements:[{type:'file',id:'upload',label:b.lang.image.btnUpload,style:'height:40px',size:38},{type:'fileButton',id:'uploadButton',filebrowser:'info:txtUrl',label:b.lang.image.btnUpload,'for':['Upload','upload']}]},{id:'advanced',label:b.lang.common.advancedTab,elements:[{type:'hbox',widths:['50%','25%','25%'],children:[{type:'text',id:'linkId',label:b.lang.common.id,setup:function(C,D){if(C==d)this.setValue(D.getAttribute('id'));},commit:function(C,D){if(C==d)if(this.getValue()||this.isChanged())D.setAttribute('id',this.getValue());}},{id:'cmbLangDir',type:'select',style:'width : 100px;',label:b.lang.common.langDir,'default':'',items:[[b.lang.common.notSet,''],[b.lang.common.langDirLtr,'ltr'],[b.lang.common.langDirRtl,'rtl']],setup:function(C,D){if(C==d)this.setValue(D.getAttribute('dir'));},commit:function(C,D){if(C==d)if(this.getValue()||this.isChanged())D.setAttribute('dir',this.getValue());}},{type:'text',id:'txtLangCode',label:b.lang.common.langCode,'default':'',setup:function(C,D){if(C==d)this.setValue(D.getAttribute('lang'));},commit:function(C,D){if(C==d)if(this.getValue()||this.isChanged())D.setAttribute('lang',this.getValue());}}]},{type:'text',id:'txtGenLongDescr',label:b.lang.common.longDescr,setup:function(C,D){if(C==d)this.setValue(D.getAttribute('longDesc'));},commit:function(C,D){if(C==d)if(this.getValue()||this.isChanged())D.setAttribute('longDesc',this.getValue());}},{type:'hbox',widths:['50%','50%'],children:[{type:'text',id:'txtGenClass',label:b.lang.common.cssClass,'default':'',setup:function(C,D){if(C==d)this.setValue(D.getAttribute('class'));\r
+},commit:function(C,D){if(C==d)if(this.getValue()||this.isChanged())D.setAttribute('class',this.getValue());}},{type:'text',id:'txtGenTitle',label:b.lang.common.advisoryTitle,'default':'',onChange:function(){l(this.getDialog());},setup:function(C,D){if(C==d)this.setValue(D.getAttribute('title'));},commit:function(C,D){var E=this;if(C==d){if(E.getValue()||E.isChanged())D.setAttribute('title',E.getValue());}else if(C==f)D.setAttribute('title',E.getValue());else if(C==g)D.removeAttribute('title');}}]},{type:'text',id:'txtdlgGenStyle',label:b.lang.common.cssStyle,'default':'',setup:function(C,D){if(C==d){var E=D.getAttribute('style');if(!E&&D.$.style.cssText)E=D.$.style.cssText;this.setValue(E);var F=D.$.style.height,G=D.$.style.width,H=(F?F:'').match(h),I=(G?G:'').match(h);this.attributesInStyle={height:!!H,width:!!I};}},onChange:function(){o.call(this,['info:cmbFloat','info:cmbAlign','info:txtVSpace','info:txtHSpace','info:txtBorder','info:txtWidth','info:txtHeight']);l(this);},commit:function(C,D){if(C==d&&(this.getValue()||this.isChanged()))D.setAttribute('style',this.getValue());}}]}]};};CKEDITOR.dialog.add('image',function(b){return a(b,'image');});CKEDITOR.dialog.add('imagebutton',function(b){return a(b,'imagebutton');});})();\r