/* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.plugins.add('dialog',{requires:['dialogui']});CKEDITOR.DIALOG_RESIZE_NONE=0;CKEDITOR.DIALOG_RESIZE_WIDTH=1;CKEDITOR.DIALOG_RESIZE_HEIGHT=2;CKEDITOR.DIALOG_RESIZE_BOTH=3;(function(){function a(A){return!!this._.tabs[A][0].$.offsetHeight;};function b(){var E=this;var A=E._.currentTabId,B=E._.tabIdList.length,C=CKEDITOR.tools.indexOf(E._.tabIdList,A)+B;for(var D=C-1;D>C-B;D--)if(a.call(E,E._.tabIdList[D%B]))return E._.tabIdList[D%B];return null;};function c(){var E=this;var A=E._.currentTabId,B=E._.tabIdList.length,C=CKEDITOR.tools.indexOf(E._.tabIdList,A);for(var D=C+1;D0?B:0)+('px'),top:(C>0?C:0)+('px')});};})(),getPosition:function(){return CKEDITOR.tools.extend({},this._.position);},show:function(){if(this._.editor.mode=='wysiwyg'&&CKEDITOR.env.ie)this._.editor.getSelection().lock();var A=this._.element,B=this.definition;if(!(A.getParent()&&A.getParent().equals(CKEDITOR.document.getBody())))A.appendTo(CKEDITOR.document.getBody());else return;if(CKEDITOR.env.gecko&&CKEDITOR.env.version<10900){var C=this.parts.dialog;C.setStyle('position','absolute');setTimeout(function(){C.setStyle('position','fixed');},0);}this.resize(B.minWidth,B.minHeight);this.selectPage(this.definition.contents[0].id);this.reset();if(CKEDITOR.dialog._.currentZIndex===null)CKEDITOR.dialog._.currentZIndex=this._.editor.config.baseFloatZIndex;this._.element.getFirst().setStyle('z-index',CKEDITOR.dialog._.currentZIndex+=10);if(CKEDITOR.dialog._.currentTop===null){CKEDITOR.dialog._.currentTop=this;this._.parentDialog=null;p(this._.editor);CKEDITOR.document.on('keydown',s);CKEDITOR.document.on('keyup',t);for(var D in {keyup:1,keydown:1,keypress:1})CKEDITOR.document.on(D,z);}else{this._.parentDialog=CKEDITOR.dialog._.currentTop;var E=this._.parentDialog.getElement().getFirst();E.$.style.zIndex-=Math.floor(this._.editor.config.baseFloatZIndex/2);CKEDITOR.dialog._.currentTop=this;}u(this,this,'\x1b',null,function(){this.getButton('cancel')&&this.getButton('cancel').click(); });this._.hasFocus=false;CKEDITOR.tools.setTimeout(function(){var F=CKEDITOR.document.getWindow().getViewPaneSize(),G=this.getSize();this.move((F.width-B.minWidth)/(2),(F.height-G.height)/(2));this.parts.dialog.setStyle('visibility','');this.fireOnce('load',{});this.fire('show',{});this.foreach(function(H){H.setInitValue&&H.setInitValue();});},100,this);},foreach:function(A){var D=this;for(var B in D._.contents)for(var C in D._.contents[B])A(D._.contents[B][C]);return D;},reset:(function(){var A=function(B){if(B.reset)B.reset();};return function(){this.foreach(A);return this;};})(),setupContent:function(){var A=arguments;this.foreach(function(B){if(B.setup)B.setup.apply(B,A);});},commitContent:function(){var A=arguments;this.foreach(function(B){if(B.commit)B.commit.apply(B,A);});},hide:function(){this.fire('hide',{});var A=this._.element;if(!A.getParent())return;A.remove();this.parts.dialog.setStyle('visibility','hidden');v(this);if(!this._.parentDialog)q();else{var B=this._.parentDialog.getElement().getFirst();B.setStyle('z-index',parseInt(B.$.style.zIndex,10)+Math.floor(this._.editor.config.baseFloatZIndex/2));}CKEDITOR.dialog._.currentTop=this._.parentDialog;if(!this._.parentDialog){CKEDITOR.dialog._.currentZIndex=null;CKEDITOR.document.removeListener('keydown',s);CKEDITOR.document.removeListener('keyup',t);CKEDITOR.document.removeListener('keypress',t);for(var C in {keyup:1,keydown:1,keypress:1})CKEDITOR.document.removeListener(C,z);var D=this._.editor;D.focus();if(D.mode=='wysiwyg'&&CKEDITOR.env.ie)D.getSelection().unlock(true);}else CKEDITOR.dialog._.currentZIndex-=10;this.foreach(function(E){E.resetInitValue&&E.resetInitValue();});},addPage:function(A){var K=this;var B=[],C=A.label?' title="'+CKEDITOR.tools.htmlEncode(A.label)+'"':'',D=A.elements,E=CKEDITOR.dialog._.uiElementBuilders.vbox.build(K,{type:'vbox',className:'cke_dialog_page_contents',children:A.elements,expand:!!A.expand,padding:A.padding,style:A.style||'width: 100%; height: 100%;'},B),F=CKEDITOR.dom.element.createFromHtml(B.join('')),G=CKEDITOR.dom.element.createFromHtml(['0?' cke_last':'cke_first',C,!!A.hidden?' style="display:none"':'',' id="',A.id+'_',CKEDITOR.tools.getNextNumber(),'" href="javascript:void(0)"',' hidefocus="true">',A.label,''].join(''));if(K._.pageCount===0)K.parts.dialog.addClass('cke_single_page');else K.parts.dialog.removeClass('cke_single_page');K._.tabs[A.id]=[G,F];K._.tabIdList.push(A.id);K._.pageCount++;K._.lastTab=G; var H=K._.contents[A.id]={},I,J=E.getChild();while(I=J.shift()){H[I.id]=I;if(typeof I.getChild=='function')J.push.apply(J,I.getChild());}F.setAttribute('name',A.id);F.appendTo(K.parts.contents);G.unselectable();K.parts.tabs.append(G);if(A.accessKey){u(K,K,'CTRL+'+A.accessKey,x,w);K._.accessKeyMap['CTRL+'+A.accessKey]=A.id;}},selectPage:function(A){var F=this;for(var B in F._.tabs){var C=F._.tabs[B][0],D=F._.tabs[B][1];if(B!=A){C.removeClass('cke_dialog_tab_selected');D.hide();}}var E=F._.tabs[A];E[0].addClass('cke_dialog_tab_selected');E[1].show();F._.currentTabId=A;F._.currentTabIndex=CKEDITOR.tools.indexOf(F._.tabIdList,A);},hidePage:function(A){var B=this._.tabs[A]&&this._.tabs[A][0];if(!B)return;B.hide();},showPage:function(A){var B=this._.tabs[A]&&this._.tabs[A][0];if(!B)return;B.show();},getElement:function(){return this._.element;},getName:function(){return this._.name;},getContentElement:function(A,B){return this._.contents[A][B];},getValueOf:function(A,B){return this.getContentElement(A,B).getValue();},setValueOf:function(A,B,C){return this.getContentElement(A,B).setValue(C);},getButton:function(A){return this._.buttons[A];},click:function(A){return this._.buttons[A].click();},disableButton:function(A){return this._.buttons[A].disable();},enableButton:function(A){return this._.buttons[A].enable();},getPageCount:function(){return this._.pageCount;},getParentEditor:function(){return this._.editor;},getSelectedElement:function(){return this.getParentEditor().getSelection().getSelectedElement();},addFocusable:function(A,B){var D=this;if(typeof B=='undefined'){B=D._.focusList.length;D._.focusList.push(new e(D,A,B));}else{D._.focusList.splice(B,0,new e(D,A,B));for(var C=B+1;CL.width-K.width-F)Q=L.width-K.width+G[1];else Q=C.x;if(C.y+G[0]L.height-K.height-F)R=L.height-K.height+G[2];else R=C.y;A.move(Q,R);J.data.preventDefault();};function I(J){CKEDITOR.document.removeListener('mousemove',H);CKEDITOR.document.removeListener('mouseup',I);if(CKEDITOR.env.ie6Compat){var K=o.getChild(0).getFrameDocument();K.removeListener('mousemove',H); K.removeListener('mouseup',I);}};A.parts.title.on('mousedown',function(J){A._.updateSize=true;B={x:J.data.$.screenX,y:J.data.$.screenY};CKEDITOR.document.on('mousemove',H);CKEDITOR.document.on('mouseup',I);C=A.getPosition();if(CKEDITOR.env.ie6Compat){var K=o.getChild(0).getFrameDocument();K.on('mousemove',H);K.on('mouseup',I);}J.data.preventDefault();},A);};function m(A){var B=A.definition,C=B.minWidth||0,D=B.minHeight||0,E=B.resizable,F=d[A.getParentEditor().skinName].margins||[0,0,0,0];function G(R,S){R.y+=S;};function H(R,S){R.x2+=S;};function I(R,S){R.y2+=S;};function J(R,S){R.x+=S;};var K=null,L=null,M=A._.editor.config.magnetDistance,N=['tl','t','tr','l','r','bl','b','br'];function O(R){var S=R.listenerData.part,T=A.getSize();L=A.getPosition();CKEDITOR.tools.extend(L,{x2:L.x+T.width,y2:L.y+T.height});K={x:R.data.$.screenX,y:R.data.$.screenY};CKEDITOR.document.on('mousemove',P,A,{part:S});CKEDITOR.document.on('mouseup',Q,A,{part:S});if(CKEDITOR.env.ie6Compat){var U=o.getChild(0).getFrameDocument();U.on('mousemove',P,A,{part:S});U.on('mouseup',Q,A,{part:S});}R.data.preventDefault();};function P(R){var S=R.data.$.screenX,T=R.data.$.screenY,U=S-K.x,V=T-K.y,W=CKEDITOR.document.getWindow().getViewPaneSize(),X=R.listenerData.part;if(X.search('t')!=-1)G(L,V);if(X.search('l')!=-1)J(L,U);if(X.search('b')!=-1)I(L,V);if(X.search('r')!=-1)H(L,U);K={x:S,y:T};var Y,Z,aa,ab;if(L.x+F[3]W.width-M)aa=W.width+F[1];else if(X.search('r')!=-1&&L.x2-L.xW.height-M)ab=W.height+F[2];else if(X.search('b')!=-1&&L.y2-L.y'];if(CKEDITOR.env.ie6Compat){var D=CKEDITOR.env.isCustomDomain();C.push('');}C.push('');o=CKEDITOR.dom.element.createFromHtml(C.join(''));}var E=o,F=function(){var J=B.getViewPaneSize();E.setStyles({width:J.width+'px',height:J.height+'px'});},G=function(){var J=B.getScrollPosition(),K=CKEDITOR.dialog._.currentTop;E.setStyles({left:J.x+'px',top:J.y+'px'});do{var L=K.getPosition();K.move(L.x,L.y);}while(K=K._.parentDialog)};n=F;B.on('resize',F);F();if(CKEDITOR.env.ie6Compat){var H=function(){G();arguments.callee.prevScrollHandler.apply(this,arguments);};B.$.setTimeout(function(){H.prevScrollHandler=window.onscroll||(function(){});window.onscroll=H;},0);G();}var I=A.config.dialog_backgroundCoverOpacity;E.setOpacity(typeof I!='undefined'?I:0.5);E.appendTo(CKEDITOR.document.getBody());},q=function(){if(!o)return;var A=CKEDITOR.document.getWindow();o.remove();A.removeListener('resize',n);if(CKEDITOR.env.ie6Compat)A.$.setTimeout(function(){var B=window.onscroll&&window.onscroll.prevScrollHandler;window.onscroll=B||null;},0);n=null;},r={},s=function(A){var B=A.data.$.ctrlKey||A.data.$.metaKey,C=A.data.$.altKey,D=A.data.$.shiftKey,E=String.fromCharCode(A.data.$.keyCode),F=r[(B?'CTRL+':'')+(C?'ALT+':'')+(D?'SHIFT+':'')+E];if(!F||!F.length)return;F=F[F.length-1];F.keydown&&F.keydown.call(F.uiElement,F.dialog,F.key);A.data.preventDefault();},t=function(A){var B=A.data.$.ctrlKey||A.data.$.metaKey,C=A.data.$.altKey,D=A.data.$.shiftKey,E=String.fromCharCode(A.data.$.keyCode),F=r[(B?'CTRL+':'')+(C?'ALT+':'')+(D?'SHIFT+':'')+E];if(!F||!F.length)return;F=F[F.length-1];F.keyup&&F.keyup.call(F.uiElement,F.dialog,F.key);A.data.preventDefault();},u=function(A,B,C,D,E){var F=r[C]||(r[C]=[]);F.push({uiElement:A,dialog:B,key:C,keyup:E||A.accessKeyUp,keydown:D||A.accessKeyDown});},v=function(A){for(var B in r){var C=r[B];for(var D=C.length-1;D>=0;D--)if(C[D].dialog==A||C[D].uiElement==A)C.splice(D,1);if(C.length===0)delete r[B];}},w=function(A,B){if(A._.accessKeyMap[B])A.selectPage(A._.accessKeyMap[B]);},x=function(A,B){},y={27:1,13:1},z=function(A){if(A.data.getKeystroke() in y)A.data.stopPropagation();};(function(){CKEDITOR.ui.dialog={uiElement:function(A,B,C,D,E,F,G){if(arguments.length<4)return;var H=(D.call?D(B):D)||('div'),I=['<',H,' '],J=(E&&E.call?E(B):E)||({}),K=(F&&F.call?F(B):F)||({}),L=(G&&G.call?G(A,B):G)||(''),M=this.domId=K.id||CKEDITOR.tools.getNextNumber()+'_uiElement',N=this.id=B.id,O; K.id=M;var P={};if(B.type)P['cke_dialog_ui_'+B.type]=1;if(B.className)P[B.className]=1;var Q=K['class']&&K['class'].split?K['class'].split(' '):[];for(O=0;O=0;O--)if(S[O]==='')S.splice(O,1);if(S.length>0)K.style=(K.style?K.style+'; ':'')+(S.join('; '));for(O in K)I.push(O+'="'+CKEDITOR.tools.htmlEncode(K[O])+'" ');I.push('>',L,'');C.push(I.join(''));(this._||(this._={})).dialog=A;if(typeof B.isChanged=='boolean')this.isChanged=function(){return B.isChanged;};if(typeof B.isChanged=='function')this.isChanged=B.isChanged;CKEDITOR.event.implementOn(this);this.registerEvents(B);if(this.accessKeyUp&&this.accessKeyDown&&B.accessKey)u(this,A,'CTRL+'+B.accessKey);var T=this;A.on('load',function(){if(T.getInputElement())T.getInputElement().on('focus',function(){A._.tabBarMode=false;A._.hasFocus=true;T.fire('focus');},T);});if(this.keyboardFocusable){this.focusIndex=A._.focusList.push(this)-1;this.on('focus',function(){A._.currentFocusIndex=T.focusIndex;});}CKEDITOR.tools.extend(this,B);},hbox:function(A,B,C,D,E){if(arguments.length<4)return;this._||(this._={});var F=this._.children=B,G=E&&E.widths||null,H=E&&E.height||null,I={},J,K=function(){var L=[''];for(J=0;J0)L.push('style="'+N.join('; ')+'" ');L.push('>',C[J],'');}L.push('');return L.join('');};CKEDITOR.ui.dialog.uiElement.call(this,A,E||{type:'hbox'},D,'table',I,E&&E.align&&{align:E.align}||null,K);},vbox:function(A,B,C,D,E){if(arguments.length<3)return;this._||(this._={});var F=this._.children=B,G=E&&E.width||null,H=E&&E.heights||null,I=function(){var J=['');for(var K=0;K');}J.push('
0)J.push('style="',L.join('; '),'" ');J.push(' class="cke_dialog_ui_vbox_child">',C[K],'
');return J.join('');};CKEDITOR.ui.dialog.uiElement.call(this,A,E||{type:'vbox'},D,'div',null,null,I);}};})();CKEDITOR.ui.dialog.uiElement.prototype={getElement:function(){return CKEDITOR.document.getById(this.domId);},getInputElement:function(){return this.getElement();},getDialog:function(){return this._.dialog;},setValue:function(A){this.getInputElement().setValue(A);this.fire('change',{value:A});return this;},getValue:function(){return this.getInputElement().getValue();},isChanged:function(){return false;},selectParentTab:function(){var D=this;var A=D.getInputElement(),B=A,C;while((B=B.getParent())&&(B.$.className.search('cke_dialog_page_contents')==-1)){}if(!B)return D;C=B.getAttribute('name');if(D._.dialog._.currentTabId!=C)D._.dialog.selectPage(C);return D;},focus:function(){this.selectParentTab().getInputElement().focus();return this;},registerEvents:function(A){var B=/^on([A-Z]\w+)/,C,D=function(F,G,H,I){G.on('load',function(){F.getInputElement().on(H,I,F);});};for(var E in A){if(!(C=E.match(B)))continue;if(this.eventProcessors[E])this.eventProcessors[E].call(this,this._.dialog,A[E]);else D(this,this._.dialog,C[1].toLowerCase(),A[E]);}return this;},eventProcessors:{onLoad:function(A,B){A.on('load',B,this);},onShow:function(A,B){A.on('show',B,this);},onHide:function(A,B){A.on('hide',B,this);}},accessKeyDown:function(A,B){this.focus();},accessKeyUp:function(A,B){},disable:function(){var A=this.getInputElement();A.setAttribute('disabled','true');A.addClass('cke_disabled');},enable:function(){var A=this.getInputElement();A.removeAttribute('disabled');A.removeClass('cke_disabled');},isEnabled:function(){return!this.getInputElement().getAttribute('disabled');},isVisible:function(){return!!this.getInputElement().$.offsetHeight;},isFocusable:function(){if(!this.isEnabled()||!this.isVisible())return false;return true;}};CKEDITOR.ui.dialog.hbox.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement(),{getChild:function(A){var B=this;if(arguments.length<1)return B._.children.concat(); if(!A.splice)A=[A];if(A.length<2)return B._.children[A[0]];else return B._.children[A[0]]&&B._.children[A[0]].getChild?B._.children[A[0]].getChild(A.slice(1,A.length)):null;}},true);CKEDITOR.ui.dialog.vbox.prototype=new CKEDITOR.ui.dialog.hbox();(function(){var A={build:function(B,C,D){var E=C.children,F,G=[],H=[];for(var I=0;I