text: !function(t){var e=function(){"undefined"!=typeof console&&i.debug===!0&&("Microsoft Internet Explorer"==navigator.appName?1==arguments.length?console.log("[KEditor]",arguments[0]):2==arguments.length?console.log("[KEditor]",arguments[0],arguments[1]):arguments.length>2&&console.log("[KEditor]",arguments[0],arguments[1],arguments[2]):console.log(["KEditor"],arguments))},n=function(t){throw new Error("[KEditor] "+t)};t.fn.draggable||n("$.fn.draggable does not exist. Please import $.fn.draggable into your document for continue using KEditor."),t.fn.droppable||n("$.fn.droppable does not exist. Please import $.fn.droppable into your document for continue using KEditor."),t.fn.sortable||n("$.fn.sortable does not exist. Please import $.fn.sortable into your document for continue using KEditor.");var i=function(e,n){this.options=t.extend({},i.DEFAULTS,n),this.init(e)};i.debug=!0,i.version="1.1.4",i.DEFAULTS={niceScrollEnabled:!0,btnMoveContainerText:'<i class="fa fa-sort"></i>',btnMoveComponentText:'<i class="fa fa-arrows"></i>',btnSettingContainerText:'<i class="fa fa-cog"></i>',btnSettingComponentText:'<i class="fa fa-cog"></i>',btnDuplicateContainerText:'<i class="fa fa-files-o"></i>',btnDuplicateComponentText:'<i class="fa fa-files-o"></i>',btnDeleteContainerText:'<i class="fa fa-times"></i>',btnDeleteComponentText:'<i class="fa fa-times"></i>',tabContainersText:"Containers",tabContainersTitle:"Containers",tabComponentsText:"Components",tabComponentsTitle:"Components",tabTooltipEnabled:!0,extraTabs:null,defaultComponentType:"blank",snippetsUrl:snippetsurl,snippetsListId:"keditor-snippets-list",snippetsTooltipEnabled:!0,snippetsTooltipPosition:"left",snippetsFilterEnabled:!0,snippetsCategoriesSeparator:";",iframeMode:!1,contentAreasSelector:null,contentAreasWrapper:'<div class="keditor-content-areas-wrapper container"></div>',containerSettingEnabled:!1,containerSettingInitFunction:null,containerSettingShowFunction:null,containerSettingHideFunction:null,onReady:function(){},onInitFrame:function(t,e,n){},onSidebarToggled:function(t){},onInitContentArea:function(t){},onContentChanged:function(t){},onInitContainer:function(t){},onBeforeContainerDeleted:function(t,e){},onContainerDeleted:function(t,e){},onContainerChanged:function(t,e){},onContainerDuplicated:function(t,e,n){},onContainerSelected:function(t,e){},onContainerSnippetDropped:function(t,e,n){},onComponentReady:function(t){},onInitComponent:function(t){},onBeforeComponentDeleted:function(t,e){},onComponentDeleted:function(t,e){},onComponentChanged:function(t,e){},onComponentDuplicated:function(t,e,n){},onComponentSelected:function(t,e){},onComponentSnippetDropped:function(t,e,n){},onBeforeDynamicContentLoad:function(t,e){},onDynamicContentLoaded:function(t,e,n,i){},onDynamicContentError:function(t,e,n,i){}},i.components={blank:{settingEnabled:!1}},i.log=e,i.error=n,i.prototype={init:function(n){var i=this,o=i.options;if(o.iframeMode)n=i.initFrame(n);else if(i.body=t(document.body),n.is("textarea")){e("Target is textarea",n);var a=n.val(),r=t("<div />"),s=i.generateId("wrapper");n.after(r),r.attr({id:s,"class":"keditor-wrapper"}),r.html(a),n.css("display","none"),n.attr("data-keditor-wrapper","#"+s),n=r}var d,c=i.body;c.hasClass("initialized-snippets-list")?e("Snippets list is already initialized!"):(d=i.initSidebar(),c.addClass("initialized-snippets-list")),c.hasClass("initialized-click-event-handlers")?e("CLick event handlers is already initialized!"):(i.initKEditorClicks(),c.addClass("initialized-click-event-handlers")),i.initContentAreas(n),d||"function"!=typeof o.onReady||o.onReady.call(i)},generateId:function(t){var e=(new Date).getTime();return"keditor-"+t+"-"+e},initNiceScroll:function(n){e("initNiceScroll",n),t.fn.niceScroll&&this.options.niceScrollEnabled?(e("Initialize $.fn.niceScroll"),n.niceScroll({cursorcolor:"#999",cursorwidth:6,railpadding:{top:0,right:0,left:0,bottom:0},cursorborder:"",disablemutationobserver:!0})):e("$.fn.niceScroll does not exist. Use default sidebar.")},initFrame:function(n){e("initFrame",n);var o=this,a=o.options,r=n.html(),s=t("<iframe />"),d=o.generateId("frame");n.after(s),s.attr({id:d,"class":"keditor-frame"}),n.css("display","none"),n.attr("data-keditor-frame","#"+d);var c=s.contents(),l=c.find("head"),p=c.find("body");e("Adding styles to iframe...");var f="";t('[data-type="keditor-style"]').each(function(){var e=t(this),n=e.attr("href")||e.attr("data-href")||"";f+=n?'<link rel="stylesheet" type="text/css" href="'+n+'" />\n':'<style type="text/css">'+e.html()+"</style>\n"}),e("Styles: \n"+f),l.append(f),e("All styles are added"),e("Adding original content to iframe...");var g;return a.contentAreasWrapper?(g=t(a.contentAreasWrapper),p.append(g),g.html(r)):p.html(r),a.snippetsListId=i.DEFAULTS.snippetsListId,o.body=p,"function"==typeof a.onInitFrame&&a.onInitFrame.call(s,s,l,p),g||p},initSidebar:function(){e("initSidebar");var o=this,a=o.options,r=o.body;return r.addClass("opened-keditor-sidebar"),a.snippetsListId===i.DEFAULTS.snippetsListId?(e("Render default KEditor snippet container"),r.append('<div id="keditor-sidebar">   <a id="keditor-sidebar-toggler"><i class="fa fa-chevron-right"></i></a>   <div id="keditor-snippets-list"></div>   <div id="keditor-snippets-content" style="display: none"></div>   <div id="keditor-setting-panel">       <div id="keditor-setting-header"><span id="keditor-setting-title"></span><a href="#" id="keditor-setting-closer"><i class="fa fa-arrow-right"></i></a></div>       <div id="keditor-setting-body"><div id="keditor-setting-forms"></div></div>   </div></div>'),o.initSidebarToggler()):(e('Render KEditor snippets content after custom snippets list with id="'+a.snippetsListId+'"'),r.find("#"+a.snippetsListId).after('<div id="keditor-snippets-content" style="display: none"></div>')),"string"==typeof a.snippetsUrl&&a.snippetsUrl.length>0?(e('Getting snippets form "'+a.snippetsUrl+'"...'),t.ajax({type:"get",dataType:"html",url:a.snippetsUrl,success:function(t){e("Success in getting snippets",t),o.renderSnippets(t),o.initSnippets(),o.initTabs(),o.initTabsSwitcher(),o.initSettingPanel(),a.snippetsFilterEnabled&&(o.initSnippetsFilter("Container"),o.initSnippetsFilter("Component")),(a.snippetsTooltipEnabled||a.tabTooltipEnabled)&&(e("Initialize Bootstrap tooltip plugin"),r.find("#"+a.snippetsListId).find('[data-toggle="tooltip"]').tooltip()),"function"==typeof a.onReady&&a.onReady.call(o)},error:function(t){e("Error when getting snippets",t)}})):void n('"snippetsUrl" must be not null!')},initSnippetsFilter:function(n){e("initSnippetsFilter",n);var i=this,o=i.options,a=i.body,r=n.toLowerCase(),s=i["snippets"+n+"Categories"],d="";d+='<div id="keditor-'+r+'-snippets-filter-wrapper" class="keditor-snippets-filter-wrapper">',d+='     <input type="text" id="keditor-'+r+'-snippets-search" class="keditor-snippets-search" value="" placeholder="Type to search..." />',d+='     <select id="keditor-'+r+'-snippets-filter" class="keditor-snippets-filter">',d+='         <option value="" selected="selected">All</option>';for(var c=0;c<s.length;c++)d+='     <option value="'+s[c]+'">'+s[c]+"</option>";d+="     </select>",d+="</div>";var l=a.find("#keditor-"+r+"-snippets-tab"),p=l.find(".keditor-snippet");l.prepend(d),p.each(function(){var e=t(this),n=e.attr("data-categories")||"",i=n.toLowerCase();n=n.split(o.snippetsCategoriesSeparator),i=i.split(o.snippetsCategoriesSeparator),e.data("categories",n),e.data("categoriesFilter",i)});var f=l.find(".keditor-snippets-search"),g=l.find(".keditor-snippets-filter"),C=function(){var n=(g.val()||"").toLowerCase(),i=(f.val()||"").toLowerCase();e('Do filter with selected category is "'+n+'" and search text is "'+i+'"'),n||i?(e("Filtering snippets"),p.each(function(){var e=t(this),o=e.data("categoriesFilter"),a=o.join(";"),r=0;if(n&&-1===t.inArray(n,o)&&r++,i){var s=e.attr("title").toLowerCase();-1===s.indexOf(i)&&-1===a.indexOf(i)&&r++}e[0===r?"removeClass":"addClass"]("not-matched")})):(e("Show all snippets"),p.removeClass("not-matched"))};g.on("change",function(){C()});var m;f.on("keydown",function(){clearTimeout(m),m=setTimeout(function(){C()},200)})},toggleSidebar:function(t){e("toggleSidebar",t);var n=this,i=n.options,o=n.body,a=o.find("#keditor-sidebar-toggler i");t?(o.addClass("opened-keditor-sidebar"),a.attr("class","fa fa-chevron-right")):(o.removeClass("opened-keditor-sidebar"),a.attr("class","fa fa-chevron-left")),"function"==typeof i.onSidebarToggled&&i.onSidebarToggled.call(null,t)},initSidebarToggler:function(){e("initSidebarToggler");var t=this,n=t.body;n.find("#keditor-sidebar-toggler").on("click",function(e){e.preventDefault(),t.toggleSidebar(!n.hasClass("opened-keditor-sidebar"))})},renderSnippets:function(n){e("renderSnippets",n);var i=this,o=i.options,a=i.body,r="",s="",d="";i.snippetsContainerCategories=[],i.snippetsComponentCategories=[],t("<div />").html(n).find("> div").each(function(n){var a=t(this),c=a.html().trim(),l=a.attr("data-preview"),p=a.attr("data-type"),f=a.attr("data-keditor-title"),g="",C=a.attr("data-categories")||"";e("Snippet #"+n+" type="+p+" categories="+C,l,c),g+='<section class="keditor-snippet" data-snippet="#keditor-snippet-'+n+'" data-type="'+p+'" '+(o.snippetsTooltipEnabled?'data-toggle="tooltip" data-placement="'+o.snippetsTooltipPosition+'"':"")+' title="'+f+'" data-categories="'+C+'">',g+='   <img class="keditor-snippet-preview" src="'+l+'" />',g+="</section>",C=C.split(o.snippetsCategoriesSeparator),"container"===p?(r+=g,i.snippetsContainerCategories=i.snippetsContainerCategories.concat(C)):-1!==p.indexOf("component")&&(s+=g,i.snippetsComponentCategories=i.snippetsComponentCategories.concat(C));var m=i.getDataAttributes(a,["data-preview","data-type","data-keditor-title","data-categories"],!0);d+='<script id="keditor-snippet-'+n+'" type="text/html" '+m.join(" ")+">"+c+"</script>"}),i.snippetsContainerCategories=i.beautifyCategories(i.snippetsContainerCategories),i.snippetsComponentCategories=i.beautifyCategories(i.snippetsComponentCategories),a.find("#"+o.snippetsListId).html('<ul id="keditor-snippets-type-switcher" class="nav nav-tabs nav-justified">    <li class="active"><a href="#keditor-container-snippets-tab"'+(o.tabTooltipEnabled?'data-toggle="tooltip" data-placement="bottom"':"")+' title="'+o.tabContainersTitle+'">'+o.tabContainersText+'</a></li>    <li><a href="#keditor-component-snippets-tab"'+(o.tabTooltipEnabled?'data-toggle="tooltip" data-placement="bottom"':"")+' title="'+o.tabComponentsTitle+'">'+o.tabComponentsText+'</a></li></ul><div id="keditor-snippets-container" class="tab-content">   <div class="tab-pane keditor-snippets active" id="keditor-container-snippets-tab"><div class="keditor-snippets-inner">'+r+'</div></div>   <div class="tab-pane keditor-snippets" id="keditor-component-snippets-tab"><div class="keditor-snippets-inner">'+s+"</div></div></div>").addClass("loaded-snippets"),a.find("#keditor-snippets-content").html(d)},beautifyCategories:function(n){e("beautifyCategories",n);for(var i=[],o=0;o<n.length;o++){var a=n[o]||"";""!==a&&-1===t.inArray(a,i)&&i.push(a)}return i.sort()},initSnippets:function(){e("initSnippets");var n=this,i=n.options,o=n.body,a=o.find("#"+i.snippetsListId);e("Initialize $.fn.draggable for container snippets list"),a.find(".keditor-snippet[data-type=container]").draggable({helper:"clone",revert:"invalid",connectToSortable:o.find(".keditor-content-area"),start:function(){t("[contenteditable]").blur(),t(".keditor-container.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"),t(".keditor-component.showed-keditor-toolbar").removeClass("showed-keditor-toolbar")},stop:function(){a.find(".keditor-snippet[data-type^=component]").draggable("option","connectToSortable",o.find(".keditor-container-content"))}}),a.find(".keditor-snippet[data-type^=component]").draggable({helper:"clone",revert:"invalid",connectToSortable:o.find(".keditor-container-content"),start:function(){o.find("[contenteditable]").blur(),o.find(".keditor-container.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"),o.find(".keditor-component.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"),o.addClass("highlighted-container-content")},stop:function(){o.removeClass("highlighted-container-content")}})},initTabs:function(){e("initTabs");var n=this,i=n.body,o=n.options,a=i.find("#keditor-snippets-type-switcher"),r=i.find("#keditor-snippets-container");if(o.extraTabs&&t.isPlainObject(o.extraTabs)){e("Add extra tabs",o.extraTabs);for(var s in o.extraTabs){var d=o.extraTabs[s];a.append('<li><a href="#keditor-extra-tab-'+s+'"'+(o.tabTooltipEnabled?'data-toggle="tooltip" data-placement="bottom" title="'+d.title+'"':"")+">"+d.text+"</a></li>"),r.append('<div class="tab-pane keditor-snippets" id="keditor-extra-tab-'+s+'"><div class="keditor-snippets-inner">'+d.content+"</div></div>")}}n.initNiceScroll(r.find(".keditor-snippets-inner"))},initTabsSwitcher:function(){e("initTabsSwitcher");var n=this,i=n.body,o=i.find("#keditor-snippets-type-switcher li"),a=i.find("#keditor-snippets-container .tab-pane");o.find("a").on("click",function(e){e.preventDefault();var r=t(this),s=r.parent(),d=r.attr("href");if(!s.hasClass("active")){var c=o.filter(".active"),l=a.filter(".active"),p=i.find(d);if(c.removeClass("active"),l.removeClass("active"),s.addClass("active"),p.addClass("active"),t.fn.niceScroll&&n.options.niceScrollEnabled){l.getNiceScroll().hide();var f=p.getNiceScroll();f.show(),f.resize()}}})},initSettingPanel:function(){e("initSettingPanel");var i=this,o=i.options,a=i.body;a.find("#keditor-setting-closer").on("click",function(t){t.preventDefault(),i.hideSettingPanel()});var r=a.find("#keditor-setting-forms");if(i.initNiceScroll(r),o.containerSettingEnabled===!0)if("function"==typeof o.containerSettingInitFunction){var s=t('<div id="keditor-container-setting" class="keditor-setting-form clearfix"></div>');r.append(s),e("Initialize container setting panel"),o.containerSettingInitFunction.call(i,s,i)}else n('"containerSettingInitFunction" is not function!')},setSettingContainer:function(t){e("setSettingContainer",t);var n=this,i=n.body;if(t){var o=t.attr("id");i.attr("data-setting-container",o)}else i.removeAttr("data-setting-container")},getSettingContainer:function(){e("getSettingContainer");var t=this,n=t.body,i=n.attr("data-setting-container");return n.find("#"+i)},setSettingComponent:function(t){e("setSettingComponent",t);var n=this,i=n.body;if(t){var o=t.attr("id");i.attr("data-setting-component",o)}else i.removeAttr("data-setting-component")},getSettingComponent:function(){e("getSettingComponent");var t=this,n=t.body,i=n.attr("data-setting-component");return n.find("#"+i)},showSettingPanel:function(n){e("showSettingPanel",n);var o=this,a=o.options,r=o.body,s=n.is(".keditor-component"),d=r.find("#keditor-setting-forms").children(".active");if(d.removeClass("active"),s){o.setSettingComponent(n),o.setSettingContainer(null);var c=o.getComponentType(n),l=i.components[c];r.find("#keditor-setting-title").html(l.settingTitle);var p=r.find("#keditor-setting-forms"),f=r.find("#keditor-setting-"+c);if(0===f.length){var l=i.components[c];if("function"==typeof l.initSettingForm){f=t('<div id="keditor-setting-'+c+'" data-type="'+c+'" class="keditor-setting-form clearfix active"></div>');var g=t("<span />").html("Loading...");p.append(f),f.append(g),e('Initializing setting form for component type "'+c+'"');var C=l.initSettingForm.call(l,f,o);t.when(C).done(function(){e('Initialized setting form for component type "'+c+'"'),setTimeout(function(){g.remove(),"function"==typeof l.showSettingForm?(e('Show setting form of component type "'+c+'"'),l.showSettingForm.call(l,f,n,o)):e('"showSettingForm" function of component type "'+c+'" does not exist')},100)})}else e('"initSettingForm" function of component type "'+c+'" does not exist')}else"function"==typeof l.showSettingForm?(e('Show setting form of component type "'+c+'"'),l.showSettingForm.call(l,f,n,o)):e('"showSettingForm" function of component type "'+c+'" does not exist'),f.addClass("active")}else{o.setSettingContainer(n),o.setSettingComponent(null),r.find("#keditor-setting-title").html("Container Settings");var f=r.find("#keditor-container-setting");"function"==typeof a.containerSettingShowFunction?(e("Show setting form of container"),a.containerSettingShowFunction.call(o,f,n,o)):e('"containerSettingShowFunction" does not exist'),f.addClass("active")}o.toggleSidebar(!0),r.addClass("opened-keditor-setting")},hideSettingPanel:function(){e("hideSettingPanel");var t=this,n=t.options,o=t.body;o.removeClass("opened-keditor-setting");var a=o.find("#keditor-setting-forms").children(".active");if(a.length>0){if(a.is("#keditor-container-setting"))"function"==typeof n.containerSettingHideFunction?(e("Hide setting form of container"),n.containerSettingHideFunction.call(t,a,t)):e('"containerSettingHideFunction" does not exist');else{var r=a.attr("data-type"),s=i.components[r];"function"==typeof s.hideSettingForm?(e('Hide setting form of component type "'+r+'"'),s.hideSettingForm.call(s,a,t)):e('"hideSettingForm" function of component type "'+r+'" does not exist')}a.removeClass("active")}o.removeClass("opened-keditor-setting"),t.setSettingComponent(null),t.setSettingContainer(null)},getContentAreas:function(n){e("getContentAreas",n);var i,o=this,a=o.options;if(a.contentAreasSelector&&(i=n.find(a.contentAreasSelector)),!i||0===i.length){e("Do not find any content area. Creating default content area..."),i=t("<div />");var r=n.html();i.html(r),n.empty().append(i)}return i},initContentAreas:function(n){e("initContentAreas",n);var i=this,o=i.getContentAreas(n);o.each(function(){var e=t(this);e.attr("id")||e.attr("id",i.generateId("content-area")),i.initContentArea(e),e.data("keditor",i)})},initContentArea:function(n){e("initContentArea",n);var i=this,o=i.options,a=i.body;if(n.addClass("keditor-content-area"),e("Initialize $.fn.droppable for content area"),n.droppable({accept:".keditor-snippet[data-type=container]",tolerance:"pointer",greedy:!0}),e("Initialize $.fn.sortable for content area"),n.sortable({handle:".btn-container-reposition",items:"> section",connectWith:".keditor-content-area",axis:"y",tolerance:"pointer",sort:function(){t(this).removeClass("ui-state-default")},receive:function(r,s){e("On received snippet",r,s);var d=s.helper,c=s.item;if(c.is(".keditor-snippet")){var l=a.find(c.attr("data-snippet")).html();e("Snippet content",l);var p=t('<section class="keditor-container">   <section class="keditor-container-inner">'+l+"</section></section>");d.replaceWith(p),p.hasClass("showed-keditor-toolbar")||(t(".keditor-container.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"),p.addClass("showed-keditor-toolbar")),"function"==typeof o.onContainerSnippetDropped&&o.onContainerSnippetDropped.call(n,r,p,s.item),i.initContainer(n,p)}i.hideSettingPanel(),"function"==typeof o.onContentChanged&&o.onContentChanged.call(n,r)}}),e("Initialize existing containers in content area"),n.children("section").each(function(){i.convertToContainer(n,t(this))}),"function"==typeof o.onInitContentArea){var r=o.onInitContentArea.call(n,n);r&&r.length>0&&t.each(r,function(){i.convertToContainer(n,t(this))})}},convertToContainer:function(t,n){e("convertToContainer",t,n);var i,o=this,a=n.is("section");a?(n.addClass("keditor-container"),n.wrapInner('<section class="keditor-container-inner"></section>'),i=n):(n.wrap('<section class="keditor-container"><section class="keditor-container-inner"></section></section>'),i=n.parent().parent()),o.initContainer(t,i)},initContainer:function(n,i){e("initContainer",n,i);var o=this,a=o.options;if(i.hasClass("keditor-initialized-container")&&i.hasClass("keditor-initializing-container"))e(i.hasClass("keditor-initialized-container")?"Container is already initialized!":"Container is initializing...");else{i.addClass("keditor-initializing-container");var r="";a.containerSettingEnabled===!0&&(r='<a href="#" class="btn-container-setting">'+a.btnSettingContainerText+"</a>"),e("Render KEditor toolbar for container",i),i.append('<div class="keditor-toolbar keditor-toolbar-container">   <a href="#" class="btn-container-reposition">'+a.btnMoveContainerText+"</a>"+r+'   <a href="#" class="btn-container-duplicate">'+a.btnDuplicateContainerText+'</a>   <a href="#" class="btn-container-delete">'+a.btnDeleteContainerText+"</a></div>"),i.attr("id",o.generateId("container"));var s=i.find('[data-type="container-content"]');e("Initialize "+s.length+" container content(s)"),s.each(function(){var e=t(this);o.initContainerContent(n,i,e)}),"function"==typeof a.onInitContainer&&a.onInitContainer.call(n,i),i.addClass("keditor-initialized-container"),i.removeClass("keditor-initializing-container")}},initContainerContent:function(n,i,o){e("initContainerContent",n,i,o);var a=this,r=a.options,s=a.body;o.addClass("keditor-container-content"),o.attr("id",a.generateId("container-content")),e("Initialize $.fn.droppable for container content"),o.droppable({accept:".keditor-snippet[data-type=component]",tolerance:"pointer",greedy:!0}),e("Initialize $.fn.sortable for container content"),o.sortable({handle:".btn-component-reposition",items:"> section",connectWith:".keditor-container-content",tolerance:"pointer",sort:function(){t(this).removeClass("ui-state-default")},receive:function(i,o){e("On received snippet",i,o);var d,c=o.helper,l=o.item;if(l.is(".keditor-snippet")){var p=s.find(l.attr("data-snippet")),f=p.html(),g=l.attr("data-type");e("Snippet content",f);var C=a.getDataAttributes(p,null,!0),m=t('<section class="keditor-component" data-type="'+g+'" '+C.join(" ")+'>   <section class="keditor-component-content">'+f+"</section></section>");c.replaceWith(m),d=m.closest(".keditor-container"),"function"==typeof r.onComponentSnippetDropped&&r.onComponentSnippetDropped.call(n,i,m,o.item),a.initComponent(n,d,m)}else d=l.closest(".keditor-container");d.hasClass("showed-keditor-toolbar")||(t(".keditor-container.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"),d.addClass("showed-keditor-toolbar")),"function"==typeof r.onContainerChanged&&r.onContainerChanged.call(n,i,d),"function"==typeof r.onContentChanged&&r.onContentChanged.call(n,i)}}),e("Initialize existing components inside container content"),o.children().each(function(){var e=t(this);a.convertToComponent(n,i,e,!0)})},convertToComponent:function(t,n,i,o){e("convertToComponent",t,n,i,o);var a,r=this,s=i.is("section");s?(i.addClass("keditor-component"),i.wrapInner('<section class="keditor-component-content"></section>'),a=i):(i.wrap('<section class="keditor-component"><section class="keditor-component-content"></section></section>'),a=i.parent().parent()),o&&a.addClass("existing-component"),r.initComponent(t,n,a)},getDataAttributes:function(n,i,o){e("getDataAttributes",n,i,o);var a=o?[]:{};return i||(i=[]),t.each(n.get(0).attributes,function(e,n){0===n.name.indexOf("data-")&&-1===t.inArray(n.name,i)&&(o?a.push(n.name+'="'+n.value+'"'):a[n.name]=n.value)}),a},getComponentType:function(t){e("getComponentType",t);var o=this,a=o.options,r=t.attr("data-type"),s=r?r.replace("component-",""):"";return s&&s in i.components?s:(e(s?'Component type "'+s+'" does not exist':"This component does not contain data-type attribute"),"string"==typeof a.defaultComponentType?s=a.defaultComponentType:"function"==typeof a.defaultComponentType&&(s=a.defaultComponentType.call(t,t)),s||n("Component type is undefined!"),e("Fallback to defaultComponentType: "+s),s)},initComponent:function(n,o,a){e("initComponent",n,o,a);var r=this,s=r.options,d=r.body;if(a.hasClass("keditor-initialized-component")&&a.hasClass("keditor-initializing-component"))e(a.hasClass("keditor-initialized-component")?"Component is already initialized!":"Component is initializing...");else{a.addClass("keditor-initializing-component"),a.attr("id",r.generateId("component"));var c=a.children(".keditor-component-content");c.attr("id",r.generateId("component-content"));var l=r.getComponentType(a);e("Component type: "+l);var p=i.components[l],f=p.settingEnabled,g="";f&&(g='<a href="#" class="btn-component-setting">'+s.btnSettingComponentText+"</a>"),e("Render KEditor toolbar for component",a),a.append('<div class="keditor-toolbar keditor-toolbar-component">   <a href="#" class="btn-component-reposition">'+s.btnMoveComponentText+"</a>"+g+'   <a href="#" class="btn-component-duplicate">'+s.btnDuplicateComponentText+'</a>   <a href="#" class="btn-component-delete">'+s.btnDeleteComponentText+"</a></div>");var C=[];a.find("[data-dynamic-href]").each(function(){var e=t(this);C.push(r.initDynamicContent(e))}),t.when.apply(null,C).then(function(){"function"==typeof p.init?p.init.call(p,n,o,a,r):(d.removeClass("highlighted-container-content"),e('"init" function of component type "'+l+'" does not exist')),"function"==typeof s.onInitComponent&&s.onInitComponent.call(n,a),a.addClass("keditor-initialized-component"),a.removeClass("keditor-initializing-component")})}},getClickedElement:function(e,n){var i=t(e.target),o=i.closest(n);return i.is(n)?i:o.length>0?o:null},initKEditorClicks:function(){e("initKEditorClicks");var n=this,i=n.options,o=n.body;o.on("click",function(t){var a=n.getClickedElement(t,"#keditor-sidebar"),r=n.getClickedElement(t,".keditor-container");if(r){if(e("Click on .keditor-container",r),!r.hasClass("showed-keditor-toolbar")){o.find(".keditor-container.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"),o.find(".keditor-component.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"),r.addClass("showed-keditor-toolbar");var s=r.parent();"function"==typeof i.onContainerSelected&&i.onContainerSelected.call(s,t,r)}}else a||(o.find(".keditor-container.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"),o.find(".keditor-component.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"));var d=n.getClickedElement(t,".keditor-component");if(d){if(e("Click on .keditor-component",d),!d.hasClass("showed-keditor-toolbar")){o.find(".keditor-component.showed-keditor-toolbar").removeClass("showed-keditor-toolbar"),d.addClass("showed-keditor-toolbar");var s=d.parent();"function"==typeof i.onComponentSelected&&i.onComponentSelected.call(s,t,d)}}else a||o.find(".keditor-component.showed-keditor-toolbar").removeClass("showed-keditor-toolbar")}),o.on("click",".btn-container-setting",function(i){i.preventDefault();var a=t(this);e("Click on .btn-container-setting",a);var r=a.closest(".keditor-container");o.hasClass("opened-keditor-setting")&&o.hasClass("opened-keditor-sidebar")&&r.is(n.getSettingContainer())?n.hideSettingPanel():n.showSettingPanel(r)}),o.on("click",".btn-container-duplicate",function(a){a.preventDefault();var r=t(this);e("Click on .btn-container-duplicate",r);var s=r.closest(".keditor-container"),d=s.parent(),c=t(n.getContainerContent(s));s.after(c),n.convertToContainer(d,c);var l=o.find("#"+i.snippetsListId),p=l.find(".keditor-snippet[data-type^=component]"),f=p.draggable("option","connectToSortable");p.draggable("option","connectToSortable",f.add(c.find(".keditor-container-content"))),e("Container is duplicated"),"function"==typeof i.onContainerDuplicated&&i.onContainerDuplicated.call(d,s,c),"function"==typeof i.onContentChanged&&i.onContentChanged.call(d,a)}),o.on("click",".btn-container-delete",function(o){o.preventDefault();var a=t(this);if(e("Click on .btn-container-delete",a),confirm("Are you sure that you want to delete this container? This action can not be undo!")){var r=a.closest(".keditor-container"),s=r.find(".keditor-component"),d=r.parent();"function"==typeof i.onBeforeContainerDeleted&&i.onBeforeContainerDeleted.call(d,o,r);var c=n.getSettingComponent();if(c){var l=c.closest(".keditor-container");l.is(r)&&(e("Deleting container is container of setting container. Close setting panel for this setting component",c),n.hideSettingPanel())}else n.getSettingContainer().is(r)&&(e("Deleting container is setting container. Close setting panel for this container",r),n.hideSettingPanel());s.length>0&&s.each(function(){n.deleteComponent(t(this))}),r.remove(),"function"==typeof i.onContainerDeleted&&i.onContainerDeleted.call(d,o,r),"function"==typeof i.onContentChanged&&i.onContentChanged.call(d,o)}}),o.on("click",".btn-component-setting",function(i){i.preventDefault();var a=t(this);e("Click on .btn-component-setting",a);var r=a.closest(".keditor-component");o.hasClass("opened-keditor-setting")&&o.hasClass("opened-keditor-sidebar")&&r.is(n.getSettingComponent())?n.hideSettingPanel():n.showSettingPanel(r)}),o.on("click",".btn-component-duplicate",function(o){o.preventDefault();var a=t(this);e("Click on .btn-component-duplicate",a);var r=a.closest(".keditor-component"),s=r.closest(".keditor-container"),d=s.parent(),c=t(n.getComponentContent(r));r.after(c),n.convertToComponent(d,s,c),e("Component is duplicated"),"function"==typeof i.onComponentDuplicated&&i.onComponentDuplicated.call(d,r,c),"function"==typeof i.onContainerChanged&&i.onContainerChanged.call(d,o,s),"function"==typeof i.onContentChanged&&i.onContentChanged.call(d,o)}),o.on("click",".btn-component-delete",function(o){o.preventDefault();var a=t(this);if(e("Click on .btn-component-delete",a),confirm("Are you sure that you want to delete this component? This action can not be undo!")){var r=a.closest(".keditor-component"),s=r.closest(".keditor-content-area");"function"==typeof i.onBeforeComponentDeleted&&i.onBeforeComponentDeleted.call(s,o,r),n.getSettingComponent().is(r)&&n.hideSettingPanel(),n.deleteComponent(r),"function"==typeof i.onComponentDeleted&&i.onComponentDeleted.call(s,o,r),"function"==typeof i.onContainerChanged&&i.onContainerChanged.call(s,o,r),"function"==typeof i.onContentChanged&&i.onContentChanged.call(s,o)}})},deleteComponent:function(t){e("deleteComponent",t);var n=this,o=n.getComponentType(t),a=i.components[o];"function"==typeof a.destroy?a.destroy.call(a,t,n):e('"destroy" function of component type "'+o+'" does not exist'),t.remove()},initDynamicContent:function(n){e("initDynamicContent",n);var i=this,o=i.options,a=n.closest(".keditor-component"),r=n.closest(".keditor-content-area");n.attr("id")||n.attr("id",i.generateId("dynamic-element")),"function"==typeof o.onBeforeDynamicContentLoad&&o.onBeforeDynamicContentLoad.call(r,n,a);var s=n.attr("data-dynamic-href"),d=i.getDataAttributes(a,["data-type","data-dynamic-href"],!1);return d=t.param(d),e("Dynamic href: "+s,"Data: "+d),t.ajax({url:s,data:d,type:"GET",dataType:"HTML",success:function(t,i,a){e("Dynamic content is loaded",n,t,i,a),n.html(t),"function"==typeof o.onDynamicContentLoaded&&o.onDynamicContentLoaded.call(r,n,t,i,a)},error:function(t,i,a){e("Error when loading dynamic content",n,t,i,a),"function"==typeof o.onDynamicContentError&&o.onDynamicContentError.call(r,n,t,i,a)}})},getComponentContent:function(n){e("getComponentContent",n);var o,a=this,r=a.getComponentType(n),s=i.components[r],d=a.getDataAttributes(n,null,!0);if("function"==typeof s.getContent)o=s.getContent.call(s,n,a);else{e('"getContent" function of component type "'+r+'" does not exist. Using default getContent method');var c=n.children(".keditor-component-content");o=c.html()}var l=t("<div />").html(o);return l.find("[data-dynamic-href]").each(function(){t(this).html("")}),o=l.html(),"<section "+d.join(" ")+">"+o+"</section>"},getContainerContent:function(n){e("getContainerContent",n);var i=this,o=(i.options,n.children(".keditor-container-inner").clone());return o.find("[data-type=container-content]").each(function(){var e=t(this);e.removeClass("keditor-container-content ui-droppable ui-sortable").removeAttr("id"),e.children(".keditor-component").each(function(){var e=t(this);e.replaceWith(i.getComponentContent(e))})}),"<section>"+o.html()+"</section>"}};var o={__init:function(n){return t(this).each(function(){var o=t(this);if(o.data("keditor"))e("KEditor is already initialized!");else{e("Initialze KEditor",o,n);var a=new i(o,n);o.data("keditor",a)}})},getContent:function(e){var n=t(this),i=n.data("keditor"),o=i.options,a=[];
  return n=o.iframeMode?i.body:n,n.find(".keditor-content-area").each(function(){var e="";t(this).children(".keditor-container").each(function(){var n=t(this);e+=i.getContainerContent(n,o)}),a.push(e)}),e?a:a.join("\n")},getOptions:function(){var e=t(this).data("keditor");return e.options}};t.keditor=i,t.fn.keditor=function(t){return o[t]&&"init"!==t?o[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void n("Method "+t+" does not exist on $.fn.keditor"):o.__init.apply(this,arguments)}}(jQuery);
  //# sourceMappingURL=keditor-1.1.4.min.js.map
  