X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=plugins%2Fdialog%2Fplugin.js;h=db371c4d95f873dbeab160349fc358390acf7478;hb=HEAD;hp=49c4fa9df0310f9ab0922558c51de66f62690879;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/plugins/dialog/plugin.js b/plugins/dialog/plugin.js deleted file mode 100644 index 49c4fa9..0000000 --- a/plugins/dialog/plugin.js +++ /dev/null @@ -1,17 +0,0 @@ -/* -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(y){return!!this._.tabs[y][0].$.offsetHeight;};function b(){var C=this;var y=C._.currentTabId,z=C._.tabIdList.length,A=CKEDITOR.tools.indexOf(C._.tabIdList,y)+z;for(var B=A-1;B>A-z;B--)if(a.call(C,C._.tabIdList[B%z]))return C._.tabIdList[B%z];return null;};function c(){var C=this;var y=C._.currentTabId,z=C._.tabIdList.length,A=CKEDITOR.tools.indexOf(C._.tabIdList,y);for(var B=A+1;B0?z:0)+('px'),top:(A>0?A: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 y=this._.element,z=this.definition;if(!(y.getParent()&&y.getParent().equals(CKEDITOR.document.getBody())))y.appendTo(CKEDITOR.document.getBody());else return;if(CKEDITOR.env.gecko&&CKEDITOR.env.version<10900){var A=this.parts.dialog;A.setStyle('position','absolute');setTimeout(function(){A.setStyle('position','fixed');},0);}this.resize(z.minWidth,z.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);}else{this._.parentDialog=CKEDITOR.dialog._.currentTop;var B=this._.parentDialog.getElement().getFirst();B.$.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 C=CKEDITOR.document.getWindow().getViewPaneSize(),D=this.getSize(); -this.move((C.width-z.minWidth)/(2),(C.height-D.height)/(2));this.parts.dialog.setStyle('visibility','');this.fireOnce('load',{});this.fire('show',{});this.foreach(function(E){E.setInitValue&&E.setInitValue();});},100,this);},foreach:function(y){var B=this;for(var z in B._.contents)for(var A in B._.contents[z])y(B._.contents[z][A]);return B;},reset:(function(){var y=function(z){if(z.reset)z.reset();};return function(){this.foreach(y);return this;};})(),setupContent:function(){var y=arguments;this.foreach(function(z){if(z.setup)z.setup.apply(z,y);});},commitContent:function(){var y=arguments;this.foreach(function(z){if(z.commit)z.commit.apply(z,y);});},hide:function(){this.fire('hide',{});var y=this._.element;if(!y.getParent())return;y.remove();this.parts.dialog.setStyle('visibility','hidden');v(this);if(!this._.parentDialog)q();else{var z=this._.parentDialog.getElement().getFirst();z.setStyle('z-index',parseInt(z.$.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);var A=this._.editor;A.focus();if(A.mode=='wysiwyg'&&CKEDITOR.env.ie)A.getSelection().unlock(true);}else CKEDITOR.dialog._.currentZIndex-=10;this.foreach(function(B){B.resetInitValue&&B.resetInitValue();});},addPage:function(y){var I=this;var z=[],A=y.label?' title="'+CKEDITOR.tools.htmlEncode(y.label)+'"':'',B=y.elements,C=CKEDITOR.dialog._.uiElementBuilders.vbox.build(I,{type:'vbox',className:'cke_dialog_page_contents',children:y.elements,expand:!!y.expand,padding:y.padding,style:y.style||'width: 100%; height: 100%;'},z),D=CKEDITOR.dom.element.createFromHtml(z.join('')),E=CKEDITOR.dom.element.createFromHtml(['0?' cke_last':'cke_first',A,!!y.hidden?' style="display:none"':'',' id="',y.id+'_',CKEDITOR.tools.getNextNumber(),'" href="javascript:void(0)"',' hidefocus="true">',y.label,''].join(''));if(I._.pageCount===0)I.parts.dialog.addClass('cke_single_page');else I.parts.dialog.removeClass('cke_single_page');I._.tabs[y.id]=[E,D];I._.tabIdList.push(y.id);I._.pageCount++;I._.lastTab=E;var F=I._.contents[y.id]={},G,H=C.getChild();while(G=H.shift()){F[G.id]=G;if(typeof G.getChild=='function')H.push.apply(H,G.getChild());}D.setAttribute('name',y.id);D.appendTo(I.parts.contents);E.unselectable();I.parts.tabs.append(E);if(y.accessKey){u(I,I,'CTRL+'+y.accessKey,x,w); -I._.accessKeyMap['CTRL+'+y.accessKey]=y.id;}},selectPage:function(y){var D=this;for(var z in D._.tabs){var A=D._.tabs[z][0],B=D._.tabs[z][1];if(z!=y){A.removeClass('cke_dialog_tab_selected');B.hide();}}var C=D._.tabs[y];C[0].addClass('cke_dialog_tab_selected');C[1].show();D._.currentTabId=y;D._.currentTabIndex=CKEDITOR.tools.indexOf(D._.tabIdList,y);},hidePage:function(y){var z=this._.tabs[y]&&this._.tabs[y][0];if(!z)return;z.hide();},showPage:function(y){var z=this._.tabs[y]&&this._.tabs[y][0];if(!z)return;z.show();},getElement:function(){return this._.element;},getName:function(){return this._.name;},getContentElement:function(y,z){return this._.contents[y][z];},getValueOf:function(y,z){return this.getContentElement(y,z).getValue();},setValueOf:function(y,z,A){return this.getContentElement(y,z).setValue(A);},getButton:function(y){return this._.buttons[y];},click:function(y){return this._.buttons[y].click();},disableButton:function(y){return this._.buttons[y].disable();},enableButton:function(y){return this._.buttons[y].enable();},getPageCount:function(){return this._.pageCount;},getParentEditor:function(){return this._.editor;},getSelectedElement:function(){return this.getParentEditor().getSelection().getSelectedElement();},addFocusable:function(y,z){var B=this;if(typeof z=='undefined'){z=B._.focusList.length;B._.focusList.push(new e(B,y,z));}else{B._.focusList.splice(z,0,new e(B,y,z));for(var A=z+1;AJ.width-I.width-D)O=J.width-I.width+E[1];else O=A.x;if(A.y+E[0]J.height-I.height-D)P=J.height-I.height+E[2];else P=A.y;y.move(O,P);H.data.preventDefault();};function G(H){CKEDITOR.document.removeListener('mousemove',F);CKEDITOR.document.removeListener('mouseup',G);if(CKEDITOR.env.ie6Compat){var I=o.getChild(0).getFrameDocument();I.removeListener('mousemove',F);I.removeListener('mouseup',G);}};y.parts.title.on('mousedown',function(H){y._.updateSize=true;z={x:H.data.$.screenX,y:H.data.$.screenY};CKEDITOR.document.on('mousemove',F);CKEDITOR.document.on('mouseup',G); -A=y.getPosition();if(CKEDITOR.env.ie6Compat){var I=o.getChild(0).getFrameDocument();I.on('mousemove',F);I.on('mouseup',G);}H.data.preventDefault();},y);};function m(y){var z=y.definition,A=z.minWidth||0,B=z.minHeight||0,C=z.resizable,D=d[y.getParentEditor().skinName].margins||[0,0,0,0];function E(P,Q){P.y+=Q;};function F(P,Q){P.x2+=Q;};function G(P,Q){P.y2+=Q;};function H(P,Q){P.x+=Q;};var I=null,J=null,K=y._.editor.config.magnetDistance,L=['tl','t','tr','l','r','bl','b','br'];function M(P){var Q=P.listenerData.part,R=y.getSize();J=y.getPosition();CKEDITOR.tools.extend(J,{x2:J.x+R.width,y2:J.y+R.height});I={x:P.data.$.screenX,y:P.data.$.screenY};CKEDITOR.document.on('mousemove',N,y,{part:Q});CKEDITOR.document.on('mouseup',O,y,{part:Q});if(CKEDITOR.env.ie6Compat){var S=o.getChild(0).getFrameDocument();S.on('mousemove',N,y,{part:Q});S.on('mouseup',O,y,{part:Q});}P.data.preventDefault();};function N(P){var Q=P.data.$.screenX,R=P.data.$.screenY,S=Q-I.x,T=R-I.y,U=CKEDITOR.document.getWindow().getViewPaneSize(),V=P.listenerData.part;if(V.search('t')!=-1)E(J,T);if(V.search('l')!=-1)H(J,S);if(V.search('b')!=-1)G(J,T);if(V.search('r')!=-1)F(J,S);I={x:Q,y:R};var W,X,Y,Z;if(J.x+D[3]U.width-K)Y=U.width+D[1];else if(V.search('r')!=-1&&J.x2-J.xU.height-K)Z=U.height+D[2];else if(V.search('b')!=-1&&J.y2-J.y'];if(CKEDITOR.env.ie6Compat){var B=CKEDITOR.env.isCustomDomain();A.push(''); -}A.push('');o=CKEDITOR.dom.element.createFromHtml(A.join(''));}var C=o,D=function(){var G=z.getViewPaneSize();C.setStyles({width:G.width+'px',height:G.height+'px'});},E=function(){var G=z.getScrollPosition(),H=CKEDITOR.dialog._.currentTop;C.setStyles({left:G.x+'px',top:G.y+'px'});do{var I=H.getPosition();H.move(I.x,I.y);}while(H=H._.parentDialog)};n=D;z.on('resize',D);D();if(CKEDITOR.env.ie6Compat){var F=function(){E();arguments.callee.prevScrollHandler.apply(this,arguments);};z.$.setTimeout(function(){F.prevScrollHandler=window.onscroll||(function(){});window.onscroll=F;},0);E();}C.setOpacity(y.config.dialog_backgroundCoverOpacity);C.appendTo(CKEDITOR.document.getBody());},q=function(){if(!o)return;var y=CKEDITOR.document.getWindow();o.remove();y.removeListener('resize',n);if(CKEDITOR.env.ie6Compat)y.$.setTimeout(function(){var z=window.onscroll&&window.onscroll.prevScrollHandler;window.onscroll=z||null;},0);n=null;},r={},s=function(y){var z=y.data.$.ctrlKey||y.data.$.metaKey,A=y.data.$.altKey,B=y.data.$.shiftKey,C=String.fromCharCode(y.data.$.keyCode),D=r[(z?'CTRL+':'')+(A?'ALT+':'')+(B?'SHIFT+':'')+C];if(!D||!D.length)return;D=D[D.length-1];D.keydown&&D.keydown.call(D.uiElement,D.dialog,D.key);y.data.preventDefault();},t=function(y){var z=y.data.$.ctrlKey||y.data.$.metaKey,A=y.data.$.altKey,B=y.data.$.shiftKey,C=String.fromCharCode(y.data.$.keyCode),D=r[(z?'CTRL+':'')+(A?'ALT+':'')+(B?'SHIFT+':'')+C];if(!D||!D.length)return;D=D[D.length-1];D.keyup&&D.keyup.call(D.uiElement,D.dialog,D.key);y.data.preventDefault();},u=function(y,z,A,B,C){var D=r[A]||(r[A]=[]);D.push({uiElement:y,dialog:z,key:A,keyup:C||y.accessKeyUp,keydown:B||y.accessKeyDown});},v=function(y){for(var z in r){var A=r[z];for(var B=A.length-1;B>=0;B--)if(A[B].dialog==y||A[B].uiElement==y)A.splice(B,1);if(A.length===0)delete r[z];}},w=function(y,z){if(y._.accessKeyMap[z])y.selectPage(y._.accessKeyMap[z]);},x=function(y,z){};(function(){CKEDITOR.ui.dialog={uiElement:function(y,z,A,B,C,D,E){if(arguments.length<4)return;var F=(B.call?B(z):B)||('div'),G=['<',F,' '],H=(C&&C.call?C(z):C)||({}),I=(D&&D.call?D(z):D)||({}),J=(E&&E.call?E(y,z):E)||(''),K=this.domId=I.id||CKEDITOR.tools.getNextNumber()+'_uiElement',L=this.id=z.id,M;I.id=K;var N={};if(z.type)N['cke_dialog_ui_'+z.type]=1;if(z.className)N[z.className]=1;var O=I['class']&&I['class'].split?I['class'].split(' '):[];for(M=0;M=0;M--)if(Q[M]==='')Q.splice(M,1);if(Q.length>0)I.style=(I.style?I.style+'; ':'')+(Q.join('; '));for(M in I)G.push(M+'="'+CKEDITOR.tools.htmlEncode(I[M])+'" ');G.push('>',J,'');A.push(G.join(''));(this._||(this._={})).dialog=y;if(typeof z.isChanged=='boolean')this.isChanged=function(){return z.isChanged;};if(typeof z.isChanged=='function')this.isChanged=z.isChanged;CKEDITOR.event.implementOn(this);this.registerEvents(z);if(this.accessKeyUp&&this.accessKeyDown&&z.accessKey)u(this,y,'CTRL+'+z.accessKey);var R=this;y.on('load',function(){if(R.getInputElement())R.getInputElement().on('focus',function(){y._.tabBarMode=false;y._.hasFocus=true;R.fire('focus');},R);});if(this.keyboardFocusable){this.focusIndex=y._.focusList.push(this)-1;this.on('focus',function(){y._.currentFocusIndex=R.focusIndex;});}CKEDITOR.tools.extend(this,z);},hbox:function(y,z,A,B,C){if(arguments.length<4)return;this._||(this._={});var D=this._.children=z,E=C&&C.widths||null,F=C&&C.height||null,G={},H,I=function(){var J=[''];for(H=0;H0)J.push('style="'+L.join('; ')+'" ');J.push('>',A[H],'');}J.push('');return J.join('');};CKEDITOR.ui.dialog.uiElement.call(this,y,C||{type:'hbox'},B,'table',G,C&&C.align&&{align:C.align}||null,I);},vbox:function(y,z,A,B,C){if(arguments.length<3)return;this._||(this._={});var D=this._.children=z,E=C&&C.width||null,F=C&&C.heights||null,G=function(){var H=['');for(var I=0;I');}H.push('
0)H.push('style="',J.join('; '),'" ');H.push(' class="cke_dialog_ui_vbox_child">',A[I],'
');return H.join('');};CKEDITOR.ui.dialog.uiElement.call(this,y,C||{type:'vbox'},B,'div',null,null,G);}};})();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(y){this.getInputElement().setValue(y);this.fire('change',{value:y});return this;},getValue:function(){return this.getInputElement().getValue();},isChanged:function(){return false;},selectParentTab:function(){var B=this;var y=B.getInputElement(),z=y,A;while((z=z.getParent())&&(z.$.className.search('cke_dialog_page_contents')==-1)){}if(!z)return B;A=z.getAttribute('name');if(B._.dialog._.currentTabId!=A)B._.dialog.selectPage(A);return B;},focus:function(){this.selectParentTab().getInputElement().focus();return this;},registerEvents:function(y){var z=/^on([A-Z]\w+)/,A,B=function(D,E,F,G){E.on('load',function(){D.getInputElement().on(F,G,D);});};for(var C in y){if(!(A=C.match(z)))continue;if(this.eventProcessors[C])this.eventProcessors[C].call(this,this._.dialog,y[C]);else B(this,this._.dialog,A[1].toLowerCase(),y[C]);}return this;},eventProcessors:{onLoad:function(y,z){y.on('load',z,this);},onShow:function(y,z){y.on('show',z,this);},onHide:function(y,z){y.on('hide',z,this);}},accessKeyDown:function(y,z){this.focus();},accessKeyUp:function(y,z){},disable:function(){var y=this.getInputElement();y.setAttribute('disabled','true');y.addClass('cke_disabled');},enable:function(){var y=this.getInputElement();y.removeAttribute('disabled');y.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(y){var z=this;if(arguments.length<1)return z._.children.concat();if(!y.splice)y=[y];if(y.length<2)return z._.children[y[0]];else return z._.children[y[0]]&&z._.children[y[0]].getChild?z._.children[y[0]].getChild(y.slice(1,y.length)):null;}},true);CKEDITOR.ui.dialog.vbox.prototype=new CKEDITOR.ui.dialog.hbox();(function(){var y={build:function(z,A,B){var C=A.children,D,E=[],F=[];for(var G=0;G