/*
 Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.md or http://ckeditor.com/license
*/
(function(){function m(a){this.editor=a;this.registered={};this.instances={};this.selected=[];this.widgetHoldingFocusedEditable=this.focused=null;this._={nextId:0,upcasts:[],filters:{}};G(this);H(this);I(this);J(this);K(this);L(this);M(this)}function i(a,b,c,d,e){var f=a.editor;CKEDITOR.tools.extend(this,d,{editor:f,id:b,inline:"span"==c.getParent().getName(),element:c,data:CKEDITOR.tools.extend({},"function"==typeof d.defaults?d.defaults():d.defaults),dataReady:!1,inited:!1,ready:!1,edit:i.prototype.edit,
focusedEditable:null,definition:d,repository:a,draggable:!1!==d.draggable,_:{downcastFn:d.downcast&&"string"==typeof d.downcast?d.downcasts[d.downcast]:d.downcast}},!0);this.inline&&(CKEDITOR.env.ie&&9>CKEDITOR.env.version)&&(this.draggable=!1);a.fire("instanceCreated",this);N(this,d);this.init&&this.init();this.inited=!0;(a=this.element.data("cke-widget-data"))&&this.setData(JSON.parse(a));e&&this.setData(e);this.dataReady=!0;q(this);this.fire("data",this.data);this.isInited()&&f.editable().contains(this.wrapper)&&
(this.ready=!0,this.fire("ready"))}function o(a,b,c){CKEDITOR.dom.element.call(this,b.$);this.editor=a;b=this.filter=c.filter;CKEDITOR.dtd[this.getName()].p?(this.enterMode=b?b.getAllowedEnterMode(a.enterMode):a.enterMode,this.shiftEnterMode=b?b.getAllowedEnterMode(a.shiftEnterMode,!0):a.shiftEnterMode):this.enterMode=this.shiftEnterMode=CKEDITOR.ENTER_BR}function O(a,b){a.addCommand(b.name,{exec:function(){function c(){a.widgets.finalizeCreation(g)}var d=a.widgets.focused;if(d&&d.name==b.name)d.edit();
else if(b.insert)b.insert();else if(b.template){var d="function"==typeof b.defaults?b.defaults():b.defaults,d=CKEDITOR.dom.element.createFromHtml(b.template.output(d)),e,f=a.widgets.wrapElement(d,b.name),g=new CKEDITOR.dom.documentFragment(f.getDocument());g.append(f);(e=a.widgets.initOn(d,b))?(d=e.once("edit",function(b){if(b.data.dialog)e.once("dialog",function(b){var b=b.data,d,f;d=b.once("ok",c,null,null,20);f=b.once("cancel",function(){a.widgets.destroy(e,!0)});b.once("hide",function(){d.removeListener();
f.removeListener()})});else c()},null,null,999),e.edit(),d.removeListener()):c()}},refresh:function(a,b){this.setState(j(a.editable(),b.blockLimit)?CKEDITOR.TRISTATE_DISABLED:CKEDITOR.TRISTATE_OFF)},context:"div",allowedContent:b.allowedContent,requiredContent:b.requiredContent,contentForms:b.contentForms,contentTransformations:b.contentTransformations})}function r(a,b){a.focused=null;b.isInited()&&(a.fire("widgetBlurred",{widget:b}),b.setFocused(!1))}function Q(a){var b=a.parent;b.type==CKEDITOR.NODE_ELEMENT&&
b.attributes["data-cke-widget-wrapper"]&&b.replaceWith(a)}function s(a,b,c){if(!c.allowedContent)return null;var d=this._.filters[a];d||(this._.filters[a]=d={});(a=d[b])||(d[b]=a=new CKEDITOR.filter(c.allowedContent));return a}function j(a,b){return!b||b.equals(a)?null:t(b)?b:j(a,b.getParent())}function u(a){return{tabindex:-1,contenteditable:"false","data-cke-widget-wrapper":1,"data-cke-filter":"off","class":"cke_widget_wrapper cke_widget_new cke_widget_"+(a?"inline":"block")}}function v(a,b,c){if(a.type==
CKEDITOR.NODE_ELEMENT){var d=CKEDITOR.dtd[a.name];if(d&&!d[c.name]){var d=a.split(b),e=a.parent,b=d.getIndex();a.children.length||(b-=1,a.remove());d.children.length||d.remove();return v(e,b,c)}}a.add(c,b)}function w(a){return a.type==CKEDITOR.NODE_ELEMENT&&!!a.attributes["data-widget"]}function p(a){return a.type==CKEDITOR.NODE_ELEMENT&&a.hasAttribute("data-widget")}function x(a,b){return"boolean"==typeof a.inline?a.inline:!!CKEDITOR.dtd.$inline[b]}function y(a){return a.type==CKEDITOR.NODE_ELEMENT&&
a.hasAttribute("data-cke-widget-wrapper")}function t(a){return a.type==CKEDITOR.NODE_ELEMENT&&a.hasAttribute("data-cke-widget-editable")}function R(a){return a.hasAttribute("data-cke-temp")}function z(a,b){var c=b.wrapper.getOuterHtml();b.wrapper.remove();a.widgets.destroy(b,!0);a.execCommand("paste",c);a.fire("unlockSnapshot")}function l(a,b,c,d){var e=a.editor;e.fire("lockSnapshot");c?(d=c.data("cke-widget-editable"),d=b.editables[d],a.widgetHoldingFocusedEditable=b,b.focusedEditable=d,c.addClass("cke_widget_editable_focused"),
d.filter&&e.setActiveFilter(d.filter),e.setActiveEnterMode(d.enterMode,d.shiftEnterMode)):(d||b.focusedEditable.removeClass("cke_widget_editable_focused"),b.focusedEditable=null,a.widgetHoldingFocusedEditable=null,e.setActiveFilter(null),e.setActiveEnterMode(null,null));e.fire("unlockSnapshot")}function S(a){a.contextMenu&&a.contextMenu.addListener(function(b){if(b=a.widgets.getByElement(b,!0))return b.fire("contextMenu",{})})}function T(a,b){return CKEDITOR.tools.trim(b)}function G(a){var b=a.editor;
U(a);V(a);b.on("contentDomUnload",function(){a.destroyAll(!0)});b.on("paste",function(a){a.data.dataValue=a.data.dataValue.replace(W,T)})}function V(a){var b=a.editor,c={};b.on("toDataFormat",function(b){var e=CKEDITOR.tools.getNextNumber(),f=[];b.data.downcastingSessionId=e;c[e]=f;b.data.dataValue.forEach(function(b){var c=b.attributes,d;if("data-cke-widget-id"in c){if(c=a.instances[c["data-cke-widget-id"]])d=b.getFirst(w),f.push({wrapper:b,element:d,widget:c}),"1"!=d.attributes["data-cke-widget-keep-attr"]&&
delete d.attributes["data-widget"]}else if("data-cke-widget-editable"in c)return delete c.contenteditable,b.setHtml(f[f.length-1].widget.editables[c["data-cke-widget-editable"]].getData()),!1},CKEDITOR.NODE_ELEMENT)},null,null,8);b.on("toDataFormat",function(a){if(a.data.downcastingSessionId)for(var a=c[a.data.downcastingSessionId],b,f,g;b=a.shift();)f=b.widget,g=b.element,(f=f._.downcastFn&&f._.downcastFn.call(f,g))||(f=g),b.wrapper.replaceWith(f)},null,null,13)}function L(a){var b=a.editor,c=CKEDITOR.plugins.lineutils;
b.on("contentDom",function(){var d=b.editable();d.attachListener(d.isInline()?d:b.document,"drop",function(c){var d=c.data.$.dataTransfer.getData("text"),g,h;if(d){try{g=JSON.parse(d)}catch(n){return}if("cke-widget"==g.type&&(c.data.preventDefault(),g.editor==b.name&&(h=a.instances[g.id])))h.focus(),b.fire("saveSnapshot"),b.fire("lockSnapshot",{dontUpdate:!0}),g=c.data.$,d=b.createRange(),c.data.testRange?c.data.testRange.select():(document.caretRangeFromPoint?(c=b.document.$.caretRangeFromPoint(g.clientX,
g.clientY),d.setStart(CKEDITOR.dom.node(c.startContainer),c.startOffset),d.collapse(!0)):g.rangeParent?(d.setStart(CKEDITOR.dom.node(g.rangeParent),g.rangeOffset),d.collapse(!0)):document.body.createTextRange&&(c=b.document.getBody().$.createTextRange(),c.moveToPoint(g.clientX,g.clientY),g="cke-temp-"+(new Date).getTime(),c.pasteHTML('<span id="'+g+'">​</span>'),c=b.document.getById(g),d.moveToPosition(c,CKEDITOR.POSITION_BEFORE_START),c.remove()),d.select()),CKEDITOR.env.gecko?setTimeout(z,0,b,h):
z(b,h)}});CKEDITOR.tools.extend(a,{finder:new c.finder(b,{lookups:{"default":function(a){if(!a.is(CKEDITOR.dtd.$listItem)&&a.is(CKEDITOR.dtd.$block)){for(;a;){if(t(a))return;a=a.getParent()}return CKEDITOR.LINEUTILS_BEFORE|CKEDITOR.LINEUTILS_AFTER}}}}),locator:new c.locator(b),liner:new c.liner(b,{lineStyle:{cursor:"move !important","border-top-color":"#666"},tipLeftStyle:{"border-left-color":"#666"},tipRightStyle:{"border-right-color":"#666"}})},!0)})}function J(a){var b=a.editor;b.on("contentDom",
function(){var c=b.editable(),d=c.isInline()?c:b.document,e,f;c.attachListener(d,"mousedown",function(b){var c=b.data.getTarget();if(!c.type)return!1;e=a.getByElement(c);f=0;e&&(e.inline&&c.type==CKEDITOR.NODE_ELEMENT&&c.hasAttribute("data-cke-widget-drag-handler")?f=1:j(e.wrapper,c)?e=null:(b.data.preventDefault(),CKEDITOR.env.ie||e.focus()))});c.attachListener(d,"mouseup",function(){e&&f&&(f=0,e.focus())});CKEDITOR.env.ie&&c.attachListener(d,"mouseup",function(){e&&setTimeout(function(){e.focus();
e=null})})});b.on("doubleclick",function(b){var d=a.getByElement(b.data.element);if(d&&!j(d.wrapper,b.data.element))return d.fire("doubleclick",{element:b.data.element})},null,null,1)}function K(a){a.editor.on("key",function(b){var c=a.focused,d=a.widgetHoldingFocusedEditable,e;c?e=c.fire("key",{keyCode:b.data.keyCode}):d&&(c=b.data.keyCode,b=d.focusedEditable,c==CKEDITOR.CTRL+65?(c=b.getBogus(),d=d.editor.createRange(),d.selectNodeContents(b),c&&d.setEndAt(c,CKEDITOR.POSITION_BEFORE_START),d.select(),
e=!1):8==c||46==c?(e=d.editor.getSelection().getRanges(),d=e[0],e=!(1==e.length&&d.collapsed&&d.checkBoundaryOfElement(b,CKEDITOR[8==c?"START":"END"]))):e=void 0);return e},null,null,1)}function M(a){function b(b){a.focused&&A(a.focused,"cut"==b.name)}var c=a.editor;c.on("contentDom",function(){var a=c.editable();a.attachListener(a,"copy",b);a.attachListener(a,"cut",b)})}function I(a){var b=a.editor;b.on("selectionCheck",function(){a.fire("checkSelection")});a.on("checkSelection",a.checkSelection,
a);b.on("selectionChange",function(c){var d=(c=j(b.editable(),c.data.selection.getStartElement()))&&a.getByElement(c),e=a.widgetHoldingFocusedEditable;if(e){if(e!==d||!e.focusedEditable.equals(c))l(a,e,null),d&&c&&l(a,d,c)}else d&&c&&l(a,d,c)});b.on("dataReady",function(){B(a).commit()});b.on("blur",function(){var b;(b=a.focused)&&r(a,b);(b=a.widgetHoldingFocusedEditable)&&l(a,b,null)})}function U(a){var b=a.editor,c=a._.upcasts,d,e;b.on("dataReady",function(){if(e)for(var c=b.editable().find(".cke_widget_wrapper"),
d,h,n=0,P=c.count();n<P;++n)d=c.getItem(n),h=d.getFirst(p),h.type==CKEDITOR.NODE_ELEMENT&&h.data("widget")?(h.replace(d),a.wrapElement(h)):d.remove();e=0;a.destroyAll(!0);a.initOnAll()});b.on("afterPaste",function(){b.fire("lockSnapshot");var c=a.initOnAll();d&&1==c.length&&c[0].focus();b.fire("unlockSnapshot")});b.on("loadSnapshot",function(b){/data-cke-widget/.test(b.data)&&(e=1);a.destroyAll(!0)},null,null,9);b.on("toHtml",function(b){var e=[],h;b.data.dataValue.forEach(function(a){if("data-cke-widget-wrapper"in
a.attributes)return(a=a.getFirst(w))&&e.push([a]),!1;if("data-widget"in a.attributes)return e.push([a]),!1;if(c.length)for(var b,d,f,h=0,i=c.length;h<i;++h)if(b=c[h],f={},d=b[0](a,f))return d instanceof CKEDITOR.htmlParser.element&&(a=d),a.attributes["data-cke-widget-data"]=JSON.stringify(f),e.push([a,b[1]]),!1},CKEDITOR.NODE_ELEMENT);for(;h=e.pop();)Q(h[0]),a.wrapElement(h[0],h[1]);d=1==b.data.dataValue.children.length&&b.data.dataValue.children[0].type==CKEDITOR.NODE_ELEMENT&&b.data.dataValue.children[0].attributes["data-cke-widget-wrapper"]},
null,null,8)}function H(a){function b(){a.fire("checkWidgets")}var c=a.editor,d=CKEDITOR.tools.eventsBuffer(a.MIN_WIDGETS_CHECK_INTERVAL,b),e={16:1,17:1,18:1,37:1,38:1,39:1,40:1,225:1};c.on("contentDom",function(){var a=c.editable();a.attachListener(a.isInline()?a:c.document,"keyup",function(a){a.data.getKey()in e||d.input()},null,null,999)});c.on("contentDomUnload",d.reset);a.on("checkWidgets",a.checkWidgets,a);c.on("contentDomInvalidated",b)}function B(a){var b=a.selected,c=[],d=b.slice(0),e=null;
return{select:function(a){0>CKEDITOR.tools.indexOf(b,a)&&c.push(a);a=CKEDITOR.tools.indexOf(d,a);0<=a&&d.splice(a,1);return this},focus:function(a){e=a;return this},commit:function(){var f=a.focused!==e,g;a.editor.fire("lockSnapshot");for(f&&(g=a.focused)&&r(a,g);g=d.pop();)b.splice(CKEDITOR.tools.indexOf(b,g),1),g.isInited()&&g.setSelected(!1);f&&e&&(a.focused=e,a.fire("widgetFocused",{widget:e}),e.setFocused(!0));for(;g=c.pop();)b.push(g),g.setSelected(!0);a.editor.fire("unlockSnapshot")}}}function C(a){a.cancel()}
function A(a,b){var c=a.editor,d=c.document;if(!d.getById("cke_copybin")){var e=c.blockless||CKEDITOR.env.ie?"span":"div",f=d.createElement(e),g=d.createElement(e),e=CKEDITOR.env.ie&&9>CKEDITOR.env.version;g.setAttributes({id:"cke_copybin","data-cke-temp":"1"});f.setStyles({position:"absolute",width:"1px",height:"1px",overflow:"hidden"});f.setStyle("ltr"==c.config.contentsLangDirection?"left":"right","-5000px");f.setHtml('<span data-cke-copybin-start="1">​</span>'+a.wrapper.getOuterHtml()+'<span data-cke-copybin-end="1">​</span>');
c.fire("saveSnapshot");c.fire("lockSnapshot");g.append(f);c.editable().append(g);var h=c.on("selectionChange",C,null,null,0),i=a.repository.on("checkSelection",C,null,null,0);if(e)var j=d.getDocumentElement().$,k=j.scrollTop;d=c.createRange();d.selectNodeContents(f);d.select();e&&(j.scrollTop=k);setTimeout(function(){b||a.focus();g.remove();h.removeListener();i.removeListener();c.fire("unlockSnapshot");if(b){a.repository.del(a);c.fire("saveSnapshot")}},100)}}function D(){var a=CKEDITOR.document.getActive(),
b=this.editor,c=b.editable();(c.isInline()?c:b.document.getWindow().getFrame()).equals(a)&&b.focusManager.focus(c)}function E(){CKEDITOR.env.gecko&&this.editor.unlockSelection();CKEDITOR.env.webkit||(this.editor.forceNextSelectionCheck(),this.editor.selectionChange(1))}function X(a){if(a.draggable){var b=a.editor;b.editable();var c=new CKEDITOR.dom.element("img",b.document),d=new CKEDITOR.dom.element("span",b.document);d.setAttributes({"class":"cke_reset cke_widget_drag_handler_container",style:"background:rgba(220,220,220,0.5);background-image:url("+
b.plugins.widget.path+"images/handle.png)"});c.setAttributes({"class":"cke_reset cke_widget_drag_handler","data-cke-widget-drag-handler":"1",src:F,width:k,title:b.lang.widget.move,height:k});if(a.inline)c.setAttribute("draggable","true"),c.on("dragstart",function(c){c.data.$.dataTransfer.setData("text",JSON.stringify({type:"cke-widget",editor:b.name,id:a.id}))});else c.on("mousedown",Y,a);d.append(c);a.wrapper.append(d);a.dragHandlerContainer=d}}function Y(){function a(){var a;for(j.reset();a=g.pop();)a.removeListener();
var b=h,c=this.repository.finder;a=this.repository.liner;var d=this.editor,e=this.editor.editable();CKEDITOR.tools.isEmpty(a.visible)||(b=c.getRange(b[0]),this.focus(),d.fire("saveSnapshot"),d.fire("lockSnapshot",{dontUpdate:1}),d.getSelection().reset(),e.insertElementIntoRange(this.wrapper,b),this.focus(),d.fire("unlockSnapshot"),d.fire("saveSnapshot"));e.removeClass("cke_widget_dragging");a.hideVisible()}var b=this.repository.finder,c=this.repository.locator,d=this.repository.liner,e=this.editor,
f=e.editable(),g=[],h=[],i=b.greedySearch(),j=CKEDITOR.tools.eventsBuffer(50,function(){k=c.locate(i);h=c.sort(l,1);h.length&&(d.prepare(i,k),d.placeLine(h[0]),d.cleanup())}),k,l;f.addClass("cke_widget_dragging");g.push(f.on("mousemove",function(a){l=a.data.$.clientY;j.input()}));g.push(e.document.once("mouseup",a,this));g.push(CKEDITOR.document.once("mouseup",a,this))}function Z(a){var b,c,d=a.editables;a.editables={};if(a.editables)for(b in d)c=d[b],a.initEditable(b,"string"==typeof c?{selector:c}:
c)}function $(a){if(a.mask){var b=new CKEDITOR.dom.element("img",a.editor.document);b.setAttributes({src:F,"class":"cke_reset cke_widget_mask"});a.wrapper.append(b);a.mask=b}}function aa(a){if(a.parts){var b={},c,d;for(d in a.parts)c=a.wrapper.findOne(a.parts[d]),b[d]=c;a.parts=b}}function N(a,b){ba(a);aa(a);Z(a);$(a);X(a);if(CKEDITOR.env.ie&&9>CKEDITOR.env.version)a.wrapper.on("dragstart",function(b){j(a,b.data.getTarget())||b.data.preventDefault()});a.wrapper.removeClass("cke_widget_new");a.element.addClass("cke_widget_element");
a.on("key",function(b){b=b.data.keyCode;if(13==b)a.edit();else{if(b==CKEDITOR.CTRL+67||b==CKEDITOR.CTRL+88){A(a,b==CKEDITOR.CTRL+88);return}if(b in ca||CKEDITOR.CTRL&b||CKEDITOR.ALT&b)return}return!1},null,null,999);a.on("doubleclick",function(b){a.edit();b.cancel()});if(b.data)a.on("data",b.data);if(b.edit)a.on("edit",b.edit);if(a.draggable)a.on("data",function(){var b=a.dragHandlerContainer;b.setStyle("top",a.element.$.offsetTop-k+"px");b.setStyle("left",a.element.$.offsetLeft+"px")},null,null,
999)}function ba(a){(a.wrapper=a.element.getParent()).setAttribute("data-cke-widget-id",a.id)}function q(a){a.element.data("cke-widget-data",JSON.stringify(a.data))}var k=15;CKEDITOR.plugins.add("widget",{lang:"en,ja,uk",requires:"lineutils",onLoad:function(){CKEDITOR.addCss(".cke_widget_wrapper{position:relative;outline:none}.cke_widget_inline{display:inline-block}.cke_widget_wrapper:hover>.cke_widget_element{outline:2px solid yellow;cursor:default}.cke_widget_wrapper:hover .cke_widget_editable{outline:2px solid yellow}.cke_widget_wrapper.cke_widget_focused>.cke_widget_element,.cke_widget_wrapper .cke_widget_editable.cke_widget_editable_focused{outline:2px solid #ace}.cke_widget_editable{cursor:text}.cke_widget_drag_handler_container{position:absolute;width:"+
k+"px;height:0;opacity:0.75;transition:height 0s 0.2s}.cke_widget_wrapper:hover>.cke_widget_drag_handler_container{height:"+k+"px;transition:none}.cke_widget_drag_handler_container:hover{opacity:1}img.cke_widget_drag_handler{cursor:move;width:"+k+"px;height:"+k+"px;display:inline-block}.cke_widget_mask{position:absolute;top:0;left:0;width:100%;height:100%;display:block}.cke_editable.cke_widget_dragging, .cke_editable.cke_widget_dragging *{cursor:move !important}")},beforeInit:function(a){a.widgets=
new m(a)},afterInit:function(a){var b=a.widgets.registered,c,d,e;for(d in b)c=b[d],(e=c.button)&&a.ui.addButton&&a.ui.addButton(CKEDITOR.tools.capitalize(c.name,!0),{label:e,command:c.name,toolbar:"insert,10"});S(a)}});m.prototype={MIN_SELECTION_CHECK_INTERVAL:500,MIN_WIDGETS_CHECK_INTERVAL:1E3,add:function(a,b){b=CKEDITOR.tools.prototypedCopy(b);b.name=a;b._=b._||{};this.editor.fire("widgetDefinition",b);b.template&&(b.template=new CKEDITOR.template(b.template));O(this.editor,b);var c=b,d=c.upcast;
if(d)if("string"==typeof d)for(d=d.split(",");d.length;)this._.upcasts.push([c.upcasts[d.pop()],c.name]);else this._.upcasts.push([d,c.name]);b.button||this.editor.addFeature(b);return this.registered[a]=b},checkSelection:function(){var a=this.editor.getSelection(),b=a.getSelectedElement(),c=B(this),d;if(b&&(d=this.getByElement(b,!0)))return c.focus(d).select(d).commit();a=a.getRanges()[0];if(!a||a.collapsed)return c.commit();a=new CKEDITOR.dom.walker(a);for(a.evaluator=y;b=a.next();)c.select(this.getByElement(b));
c.commit()},checkWidgets:function(){if("wysiwyg"==this.editor.mode){var a=this.editor.editable(),b=this.instances,c;if(a){for(c in b)a.contains(b[c].wrapper)||this.destroy(b[c],!0);var d=a.find(".cke_widget_wrapper");c=0;for(a=d.count();c<a;c++){var b=d.getItem(c),e;if(e=!this.getByElement(b,!0)){a:{e=R;for(var f=b;f=f.getParent();)if(e(f)){e=!0;break a}e=!1}e=!e}e&&(b.addClass("cke_widget_new"),this.initOn(b.getFirst(p)))}}}},del:function(a){if(this.focused===a){var b=a.editor,c=b.createRange(),
d;if(!(d=c.moveToClosestEditablePosition(a.wrapper,!0)))d=c.moveToClosestEditablePosition(a.wrapper,!1);d&&b.getSelection().selectRanges([c])}a.wrapper.remove();this.destroy(a,!0)},destroy:function(a,b){this.widgetHoldingFocusedEditable===a&&l(this,a,null,b);a.destroy(b);delete this.instances[a.id];this.fire("instanceDestroyed",a)},destroyAll:function(a){var b=this.instances,c,d;for(d in b)c=b[d],this.destroy(c,a)},finalizeCreation:function(a){if((a=a.getFirst())&&y(a))this.editor.insertElement(a),
a=this.getByElement(a),a.ready=!0,a.fire("ready"),a.focus()},getByElement:function(a,b){if(!a)return null;var c,d;for(d in this.instances)if(c=this.instances[d].wrapper,c.equals(a)||!b&&c.contains(a))return this.instances[d];return null},initOn:function(a,b,c){b?"string"==typeof b&&(b=this.registered[b]):b=this.registered[a.data("widget")];if(!b)return null;var d=this.wrapElement(a,b.name);return d?d.hasClass("cke_widget_new")?(a=new i(this,this._.nextId++,a,b,c),a.isInited()?this.instances[a.id]=
a:null):this.getByElement(a):null},initOnAll:function(a){for(var a=(a||this.editor.editable()).find(".cke_widget_new"),b=[],c,d=a.count();d--;)(c=this.initOn(a.getItem(d).getFirst(p)))&&b.push(c);return b},wrapElement:function(a,b){var c=null,d,e;if(a instanceof CKEDITOR.dom.element){d=this.registered[b||a.data("widget")];if(!d)return null;if((c=a.getParent())&&c.type==CKEDITOR.NODE_ELEMENT&&c.data("cke-widget-wrapper"))return c;a.hasAttribute("data-cke-widget-keep-attr")||a.data("cke-widget-keep-attr",
a.data("widget")?1:0);b&&a.data("widget",b);e=x(d,a.getName());c=new CKEDITOR.dom.element(e?"span":"div");c.setAttributes(u(e));c.data("cke-display-name",d.pathName?d.pathName:a.getName());a.getParent(!0)&&c.replace(a);a.appendTo(c)}else if(a instanceof CKEDITOR.htmlParser.element){d=this.registered[b||a.attributes["data-widget"]];if(!d)return null;if((c=a.parent)&&c.type==CKEDITOR.NODE_ELEMENT&&c.attributes["data-cke-widget-wrapper"])return c;"data-cke-widget-keep-attr"in a.attributes||(a.attributes["data-cke-widget-keep-attr"]=
a.attributes["data-widget"]?1:0);b&&(a.attributes["data-widget"]=b);e=x(d,a.name);c=new CKEDITOR.htmlParser.element(e?"span":"div",u(e));c.attributes["data-cke-display-name"]=d.pathName?d.pathName:a.name;d=a.parent;var f;d&&(f=a.getIndex(),a.remove());c.add(a);d&&v(d,f,c)}return c},_tests_getNestedEditable:j,_tests_createEditableFilter:s};CKEDITOR.event.implementOn(m.prototype);i.prototype={destroy:function(a){this.fire("destroy");if(this.editables)for(var b in this.editables)this.destroyEditable(b,
a);a||("0"==this.element.data("cke-widget-keep-attr")&&this.element.removeAttribute("data-widget"),this.element.removeAttributes(["data-cke-widget-data","data-cke-widget-keep-attr"]),this.element.removeClass("cke_widget_element"),this.element.replace(this.wrapper));this.wrapper=null},destroyEditable:function(a,b){var c=this.editables[a];c.removeListener("focus",E);c.removeListener("blur",D);this.editor.focusManager.remove(c);b||(c.removeClass("cke_widget_editable"),c.removeClass("cke_widget_editable_focused"),
c.removeAttributes(["contenteditable","data-cke-widget-editable","data-cke-enter-mode"]));delete this.editables[a]},edit:function(){var a={dialog:this.dialog},b=this;this.fire("edit",a)&&a.dialog&&this.editor.openDialog(a.dialog,function(a){var d,e;b.fire("dialog",a)&&(d=a.on("show",function(){a.setupContent(b)}),e=a.on("ok",function(){var d,e=b.on("data",function(a){d=1;a.cancel()},null,null,0);b.editor.fire("saveSnapshot");a.commitContent(b);e.removeListener();d&&(b.fire("data",b.data),b.editor.fire("saveSnapshot"))}),
a.once("hide",function(){d.removeListener();e.removeListener()}))})},initEditable:function(a,b){var c=this.wrapper.findOne(b.selector);return c&&c.is(CKEDITOR.dtd.$editable)?(c=new o(this.editor,c,{filter:s.call(this.repository,this.name,a,b)}),this.editables[a]=c,c.setAttributes({contenteditable:"true","data-cke-widget-editable":a,"data-cke-enter-mode":c.enterMode}),c.filter&&c.data("cke-filter",c.filter.id),c.addClass("cke_widget_editable"),c.removeClass("cke_widget_editable_focused"),b.pathName&&
c.data("cke-display-name",b.pathName),this.editor.focusManager.add(c),c.on("focus",E,this),CKEDITOR.env.ie&&c.on("blur",D,this),c.setData(c.getHtml()),!0):!1},isInited:function(){return!(!this.wrapper||!this.inited)},isReady:function(){return this.isInited()&&this.ready},focus:function(){var a=this.editor.getSelection();a&&a.fake(this.wrapper);this.editor.focus()},setData:function(a,b){var c=this.data,d=0;if("string"==typeof a)c[a]!==b&&(c[a]=b,d=1);else{var e=a;for(a in e)c[a]!==e[a]&&(d=1,c[a]=
e[a])}d&&this.dataReady&&(q(this),this.fire("data",c));return this},setFocused:function(a){this.wrapper[a?"addClass":"removeClass"]("cke_widget_focused");this.fire(a?"focus":"blur");return this},setSelected:function(a){this.wrapper[a?"addClass":"removeClass"]("cke_widget_selected");this.fire(a?"select":"deselect");return this}};CKEDITOR.event.implementOn(i.prototype);o.prototype=CKEDITOR.tools.extend(CKEDITOR.tools.prototypedCopy(CKEDITOR.dom.element.prototype),{setData:function(a){a=this.editor.dataProcessor.toHtml(a,
{context:this.getName(),filter:this.filter,enterMode:this.enterMode});this.setHtml(a)},getData:function(){return this.editor.dataProcessor.toDataFormat(this.getHtml(),{context:this.getName(),filter:this.filter,enterMode:this.enterMode})}});var W=RegExp('^(?:<(?:div|span)(?: data-cke-temp="1")?(?: id="cke_copybin")?(?: data-cke-temp="1")?>)?(?:<(?:div|span)(?: style="[^"]+")?>)?<span [^>]*data-cke-copybin-start="1"[^>]*>.?</span>([\\s\\S]+)<span [^>]*data-cke-copybin-end="1"[^>]*>.?</span>(?:</(?:div|span)>)?(?:</(?:div|span)>)?$'),
F="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D",ca={37:1,38:1,39:1,40:1,8:1,46:1};CKEDITOR.plugins.widget=i;i.repository=m;i.nestedEditable=o})();