(function(){var a=function(m,n){var o=m.document,p=o.getBody(),q=0,r=function(){q=1;};p.on(n,r);(CKEDITOR.env.version>7?o.$:o.$.selection.createRange()).execCommand(n);p.removeListener(n,r);return q;},b=CKEDITOR.env.ie?function(m,n){return a(m,n);}:function(m,n){try{return m.document.$.execCommand(n,false,null);}catch(o){return false;}},c=function(m){var n=this;n.type=m;n.canUndo=n.type=='cut';n.startDisabled=true;};c.prototype={exec:function(m,n){this.type=='cut'&&h(m);var o=b(m,this.type);if(!o)alert(m.lang.clipboard[this.type+'Error']);return o;}};var d={canUndo:false,exec:CKEDITOR.env.ie?function(m){m.focus();if(!m.document.getBody().fire('beforepaste')&&!a(m,'paste')){m.fire('pasteDialog');return false;}}:function(m){try{if(!m.document.getBody().fire('beforepaste')&&!m.document.$.execCommand('Paste',false,null))throw 0;}catch(n){setTimeout(function(){m.fire('pasteDialog');},0);return false;}}},e=function(m){if(this.mode!='wysiwyg')return;switch(m.data.keyCode){case CKEDITOR.CTRL+86:case CKEDITOR.SHIFT+45:var n=this.document.getBody();if(!CKEDITOR.env.ie&&n.fire('beforepaste'))m.cancel();else if(CKEDITOR.env.opera||CKEDITOR.env.gecko&&CKEDITOR.env.version<10900)n.fire('paste');return;case CKEDITOR.CTRL+88:case CKEDITOR.SHIFT+46:var o=this;this.fire('saveSnapshot');setTimeout(function(){o.fire('saveSnapshot');},0);}};function f(m){m.cancel();};function g(m,n,o){var p=this.document;if(p.getById('cke_pastebin'))return;if(n=='text'&&m.data&&m.data.$.clipboardData){var q=m.data.$.clipboardData.getData('text/plain');if(q){m.data.preventDefault();o(q);return;}}var r=this.getSelection(),s=new CKEDITOR.dom.range(p),t=new CKEDITOR.dom.element(n=='text'?'textarea':CKEDITOR.env.webkit?'body':'div',p);t.setAttribute('id','cke_pastebin');CKEDITOR.env.webkit&&t.append(p.createText('\xa0'));p.getBody().append(t);t.setStyles({position:'absolute',top:r.getStartElement().getDocumentPosition().y+'px',width:'1px',height:'1px',overflow:'hidden'});t.setStyle(this.config.contentsLangDirection=='ltr'?'left':'right','-1000px');var u=r.createBookmarks();this.on('selectionChange',f,null,null,0);if(n=='text')t.$.focus();else{s.setStartAt(t,CKEDITOR.POSITION_AFTER_START);s.setEndAt(t,CKEDITOR.POSITION_BEFORE_END);s.select(true);}var v=this;window.setTimeout(function(){n=='text'&&CKEDITOR.env.gecko&&v.focusGrabber.focus();t.remove();v.removeListener('selectionChange',f);var w;t=CKEDITOR.env.webkit&&(w=t.getFirst())&&w.is&&w.hasClass('Apple-style-span')?w:t;r.selectBookmarks(u);o(t['get'+(n=='text'?'Value':'Html')]());
},0);};function h(m){if(!CKEDITOR.env.ie||CKEDITOR.env.quirks)return;var n=m.getSelection(),o;if(n.getType()==CKEDITOR.SELECTION_ELEMENT&&(o=n.getSelectedElement())){var p=n.getRanges()[0],q=m.document.createText('');q.insertBefore(o);p.setStartBefore(q);p.setEndAfter(o);n.selectRanges([p]);setTimeout(function(){if(o.getParent()){q.remove();n.selectElement(o);}},0);}};var i;function j(m,n){CKEDITOR.env.ie&&(i=1);var o=CKEDITOR.TRISTATE_OFF;try{o=n.document.$.queryCommandEnabled(m)?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED;}catch(p){}i=0;return o;};var k;function l(){var n=this;if(n.mode!='wysiwyg')return;n.getCommand('cut').setState(k?CKEDITOR.TRISTATE_DISABLED:j('Cut',n));n.getCommand('copy').setState(j('Copy',n));var m=k?CKEDITOR.TRISTATE_DISABLED:CKEDITOR.env.webkit?CKEDITOR.TRISTATE_OFF:j('Paste',n);n.fire('pasteState',m);};CKEDITOR.plugins.add('clipboard',{requires:['dialog','htmldataprocessor'],init:function(m){m.on('paste',function(o){var p=o.data;if(p.html)m.insertHtml(p.html);else if(p.text)m.insertText(p.text);setTimeout(function(){m.fire('afterPaste');},0);},null,null,1000);m.on('pasteDialog',function(o){setTimeout(function(){m.openDialog('paste');},0);});m.on('pasteState',function(o){m.getCommand('paste').setState(o.data);});function n(o,p,q,r){var s=m.lang[p];m.addCommand(p,q);m.ui.addButton(o,{label:s,command:p});if(m.addMenuItems)m.addMenuItem(p,{label:s,command:p,group:'clipboard',order:r});};n('Cut','cut',new c('cut'),1);n('Copy','copy',new c('copy'),4);n('Paste','paste',d,8);CKEDITOR.dialog.add('paste',CKEDITOR.getUrl(this.path+'dialogs/paste.js'));m.on('key',e,m);m.on('contentDom',function(){var o=m.document.getBody();o.on(CKEDITOR.env.webkit?'paste':'beforepaste',function(p){if(i)return;var q={mode:'html'};m.fire('beforePaste',q);g.call(m,p,q.mode,function(r){if(!(r=CKEDITOR.tools.trim(r.replace(/<span[^>]+data-cke-bookmark[^<]*?<\/span>/ig,''))))return;var s={};s[q.mode]=r;m.fire('paste',s);});});o.on('beforecut',function(){!i&&h(m);});o.on('mouseup',function(){setTimeout(function(){l.call(m);},0);},m);o.on('keyup',l,m);});m.on('selectionChange',function(o){k=o.data.selection.getRanges()[0].checkReadOnly();l.call(m);});if(m.contextMenu)m.contextMenu.addListener(function(o,p){var q=p.getRanges()[0].checkReadOnly();return{cut:!q&&j('Cut',m),copy:j('Copy',m),paste:!q&&(CKEDITOR.env.webkit?CKEDITOR.TRISTATE_OFF:j('Paste',m))};});}});})();
