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