<\/div>| )*$/,"")},a.fn.wysiwyg=function(c){var d,e,f,g=this,h=function(){e.activeToolbarClass&&a(e.toolbarSelector).find(f).each(function(){var b=a(this).data(e.commandRole);document.queryCommandState(b)?a(this).addClass(e.activeToolbarClass):a(this).removeClass(e.activeToolbarClass)})},i=function(a,b){var c=a.split(" "),d=c.shift(),e=c.join(" ")+(b||"");document.execCommand(d,0,e),h()},j=function(b){a.each(b,function(a,b){g.keydown(a,function(a){g.attr("contenteditable")&&g.is(":visible")&&(a.preventDefault(),a.stopPropagation(),i(b))}).keyup(a,function(a){g.attr("contenteditable")&&g.is(":visible")&&(a.preventDefault(),a.stopPropagation())})})},k=function(){var a=window.getSelection();return a.getRangeAt&&a.rangeCount?a.getRangeAt(0):void 0},l=function(){d=k()},m=function(){var a=window.getSelection();if(d){try{a.removeAllRanges()}catch(b){document.body.createTextRange().select(),document.selection.empty()}a.addRange(d)}},n=function(c){g.focus(),a.each(c,function(c,d){/^image\//.test(d.type)?a.when(b(d)).done(function(a){i("insertimage",a)}).fail(function(a){e.fileUploadError("file-reader",a)}):e.fileUploadError("unsupported-file-type",d.type)})},o=function(a,b){m(),document.queryCommandSupported("hiliteColor")&&document.execCommand("hiliteColor",0,b||"transparent"),l(),a.data(e.selectionMarker,b)},p=function(b,c){b.find(f).click(function(){m(),g.focus(),i(a(this).data(c.commandRole)),l()}),b.find("[data-toggle=dropdown]").click(m),b.find("input[type=text][data-"+c.commandRole+"]").on("webkitspeechchange change",function(){var b=this.value;this.value="",m(),b&&(g.focus(),i(a(this).data(c.commandRole),b)),l()}).on("focus",function(){var b=a(this);b.data(c.selectionMarker)||(o(b,c.selectionColor),b.focus())}).on("blur",function(){var b=a(this);b.data(c.selectionMarker)&&o(b,!1)}),b.find("input[type=file][data-"+c.commandRole+"]").change(function(){m(),"file"===this.type&&this.files&&this.files.length>0&&n(this.files),l(),this.value=""})},q=function(){g.on("dragenter dragover",!1).on("drop",function(a){var b=a.originalEvent.dataTransfer;a.stopPropagation(),a.preventDefault(),b&&b.files&&b.files.length>0&&n(b.files)})};return"string"==typeof c&&"destroy"==c?(g.attr("contenteditable",!1).unbind("mouseup keyup mouseout dragenter dragover"),a(window).unbind("touchend"),this):(e=a.extend({},a.fn.wysiwyg.defaults,c),f="a[data-"+e.commandRole+"],button[data-"+e.commandRole+"],input[type=button][data-"+e.commandRole+"]",j(e.hotKeys),e.dragAndDropImages&&q(),p(a(e.toolbarSelector),e),g.attr("contenteditable",!0).on("mouseup keyup mouseout",function(){l(),h()}),a(window).bind("touchend",function(a){var b=g.is(a.target)||g.has(a.target).length>0,c=k(),d=c&&c.startContainer===c.endContainer&&c.startOffset===c.endOffset;(!d||b)&&(l(),h())}),this)},a.fn.wysiwyg.defaults={hotKeys:{"ctrl+b meta+b":"bold","ctrl+i meta+i":"italic","ctrl+u meta+u":"underline","ctrl+z meta+z":"undo","ctrl+y meta+y meta+shift+z":"redo","ctrl+l meta+l":"justifyleft","ctrl+r meta+r":"justifyright","ctrl+e meta+e":"justifycenter","ctrl+j meta+j":"justifyfull","shift+tab":"outdent",tab:"indent"},toolbarSelector:"[data-role=editor-toolbar]",commandRole:"edit",activeToolbarClass:"btn-info",selectionMarker:"edit-focus-marker",selectionColor:"darkgrey",dragAndDropImages:!0,fileUploadError:function(a,b){console.log("File upload error",a,b)}},a}),c("RichTextEditor/model/CommandButton",["backbone"],function(a){return a.Model.extend({defaults:{command:"",title:"","class":"",group:""}})}),c("RichTextEditor/model/CommandButtons",["backbone","./CommandButton"],function(a,b){return a.Collection.extend({model:b})}),c("RichTextEditor/view/CommandButtonView",["backbone"],function(a){return a.View.extend({tagName:"a",initialize:function(a){this.config=a.config||{},this.className=this.config.stylePrefix+"btn "+this.model.get("class")},render:function(){return this.$el.attr("class",_.result(this,"className")),this}})}),c("RichTextEditor/view/CommandButtonsView",["backbone","./CommandButtonView"],function(a,b){return a.View.extend({className:"no-dots",attributes:{"data-role":"editor-toolbar"},initialize:function(a){this.config=a.config||{},this.id=this.config.stylePrefix+this.config.toolbarId,this.$el.data("helper",1)},updateTarget:function(a){return this.$el.attr("data-target",a),this},render:function(){var a=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(c){var d=new b({model:c,config:this.config,attributes:{title:c.get("title"),"data-edit":c.get("command")}});a.appendChild(d.render().el)},this),this.$el.append(a),this.$el.attr("id",_.result(this,"id")),this}})}),c("RichTextEditor/main",["require","./config/config","./view/TextEditorView","./model/CommandButtons","./view/CommandButtonsView"],function(a){function b(b){var c=b||{},d=a("./config/config"),e=(a("./view/TextEditorView"),a("./model/CommandButtons")),f=a("./view/CommandButtonsView");for(var g in d)g in c||(c[g]=d[g]);this.tlbPfx=c.stylePrefix,this.commands=new e(c.commands);var h={collection:this.commands,config:c};this.toolbar=new f(h),this.$toolbar=this.toolbar.render().$el}return b.prototype={bind:function(a,b){this.$contaniner||(this.$container=b,this.$toolbar.appendTo(this.$container)),a.$el.wysiwyg({hotKeys:{}}).focus(),this.updatePosition(a.$el),this.bindToolbar(a).show(),this.$toolbar.on("mousedown",this.disableProp)},unbind:function(a){a.$el.wysiwyg("destroy"),this.hide(),this.$toolbar.off("mousedown",this.disableProp)},bindToolbar:function(a){var b=this.tlbPfx+a.model.cid,c=this.tlbPfx+"inited";return a.$el.data(c)||(a.$el.data(c,1),a.$el.attr("id",b)),this.toolbar.updateTarget("#"+b),this},updatePosition:function(a){var b=this.$container.offset(),c=b?b.top:0,d=b?b.left:0,e=a.offset(),f=e.top-c+this.$container.scrollTop(),g=e.left-d+this.$container.scrollLeft();this.tlbH||(this.tlbH=this.$toolbar.outerHeight()),this.$toolbar.css({top:f-this.tlbH-5,left:g})},show:function(){this.$toolbar.show()},hide:function(){this.$toolbar.hide()},disableProp:function(a){a.stopPropagation()}},b}),c("RichTextEditor",["RichTextEditor/main"],function(a){return a}),c("DomComponents/config/config",[],function(){return{stylePrefix:"comp-",wrapperId:"wrapper",wrapper:{removable:!1,copyable:!1,stylable:["background","background-color","background-image","background-repeat","background-attachment","background-position"],movable:!1,badgable:!1,components:[]},defaults:[],rte:{},em:{},imageCompClass:"fa fa-picture-o",oAssetsOnCreate:!0}}),c("DomComponents/model/Components",["backbone","require"],function(a,b){return a.Collection.extend({initialize:function(a,c){this.model=function(a,c){var d;switch(a.type){case"text":this.mComponentText||(this.mComponentText=b("./ComponentText")),d=new this.mComponentText(a,c);break;case"image":this.mComponentImage||(this.mComponentImage=b("./ComponentImage")),d=new this.mComponentImage(a,c);break;default:this.mComponent||(this.mComponent=b("./Component")),d=new this.mComponent(a,c)}return d}}})}),c("ClassManager/model/ClassTag",["backbone"],function(a){return a.Model.extend({defaults:{label:"",name:""}})}),c("ClassManager/model/ClassTags",["backbone","./ClassTag"],function(a,b){return a.Collection.extend({model:b})}),c("DomComponents/model/Component",["backbone","./Components","ClassManager/model/ClassTags"],function(a,b,c){return a.Model.extend({defaults:{tagName:"div",type:"",editable:!1,removable:!0,movable:!0,droppable:!0,badgable:!0,stylable:!0,copyable:!0,status:"",previousModel:"",content:"",style:{},attributes:{}},initialize:function(a){this.config=a||{},this.defaultC=this.config.components||[],this.defaultCl=this.config.classes||[],this.components=new b(this.defaultC),this.set("components",this.components),this.set("classes",new c(this.defaultCl))},clone:function(){var a=_.clone(this.attributes),b=this.get("components"),c=this.get("classes");return a.components=[],a.classes=[],b.length&&b.each(function(b,c){a.components[c]=b.clone()}),c.length&&c.each(function(b,c){a.classes[c]=b.clone()}),new this.constructor(a)},getName:function(){if(!this.name){var a=this.cid.replace(/\D/g,""),b=this.get("type");this.name=b.charAt(0).toUpperCase()+b.slice(1)+"Box"+a}return this.name}})}),c("DomComponents/model/ComponentText",["./Component"],function(a){return a.extend({defaults:_.extend({},a.prototype.defaults,{content:"",droppable:!1})})}),c("DomComponents/model/ComponentImage",["./Component"],function(a){return a.extend({defaults:_.extend({},a.prototype.defaults,{src:"",droppable:!1})})}),c("DomComponents/view/ComponentsView",["backbone","require"],function(a,b){return a.View.extend({initialize:function(a){this.config=a.config,this.listenTo(this.collection,"add",this.addTo),this.listenTo(this.collection,"reset",this.render)},addTo:function(a){var b=this.collection.indexOf(a);this.addToCollection(a,null,b)},addToCollection:function(a,c,d){this.compView||(this.compView=b("./ComponentView"));var e=c||null,f=this.compView;switch(a.get("type")){case"text":this.compViewText||(this.compViewText=b("./ComponentTextView")),f=this.compViewText;break;case"image":this.compViewImage||(this.compViewImage=b("./ComponentImageView")),f=this.compViewImage}var g=new f({model:a,config:this.config}),h=g.render().el;if(e)e.appendChild(h);else{var i=this.$parent;if("undefined"!=typeof d){var j="before";i.children().length==d&&(d--,j="after"),0>d?i.append(h):i.children().eq(d)[j](h)}else i.append(h)}return h},render:function(a){var b=document.createDocumentFragment();return this.$parent=a||this.$el,this.$el.empty(),this.collection.each(function(a){this.addToCollection(a,b)},this),this.$el.append(b),this}})}),c("DomComponents/view/ComponentView",["backbone","./ComponentsView"],function(a,b){return a.View.extend({className:function(){return this.getClasses()},tagName:function(){return this.model.get("tagName")},initialize:function(a){this.config=a.config,this.pfx=this.config.stylePrefix,this.components=this.model.get("components"),this.attr=this.model.get("attributes"),this.classe=this.attr["class"]||[],this.listenTo(this.model,"destroy remove",this.remove),this.listenTo(this.model,"change:style",this.updateStyle),this.listenTo(this.model,"change:attributes",this.updateAttributes),this.listenTo(this.model,"change:status",this.updateStatus),this.listenTo(this.model.get("classes"),"add remove change",this.updateClasses),this.$el.data("model",this.model),this.$el.data("model-comp",this.components)},updateStatus:function(a){var b=this.model.get("status"),c=this.pfx;switch(b){case"selected":this.$el.addClass(c+"selected");break;case"moving":break;default:this.$el.removeClass(c+"selected")}},getClasses:function(){var a=this.model.get("attributes"),b=a["class"]||[];return b.length?b.join(" "):null},updateAttributes:function(){var a={},b=this.model.get("attributes");for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);this.model.get("src")&&(a.src=this.model.get("src")),a.style=this.getStyleString(),this.$el.attr(a)},updateStyle:function(){this.$el.attr("style",this.getStyleString())},getStyleString:function(){var a="";this.style=this.model.get("style");for(var b in this.style)this.style.hasOwnProperty(b)&&(a+=b+":"+this.style[b]+";");return a},updateClasses:function(){var a="";this.model.get("classes").each(function(b){a+=b.get("name")+" "}),this.$el.attr("class",a.trim()),this.updateStatus()},eventCall:function(a){a.viewResponse=this},render:function(){this.updateAttributes(),this.updateClasses(),this.$el.html(this.model.get("content"));var a=new b({collection:this.components,config:this.config});return this.$components=a,this.$el.append(a.render(this.$el).el.childNodes),this}})}),c("DomComponents/view/ComponentImageView",["backbone","./ComponentView"],function(a,b){return b.extend({tagName:"img",events:{dblclick:"openModal"},initialize:function(a){b.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:src",this.updateSrc),this.listenTo(this.model,"dblclick",this.openModal),this.classEmpty=this.config.stylePrefix+"image-placeholder "+this.config.imageCompClass,this.model.get("src")||this.$el.attr("class",this.classEmpty),this.config.modal&&(this.modal=this.config.modal),this.config.am&&(this.am=this.config.am)},updateSrc:function(){this.$el.attr("src",this.model.get("src"))},openModal:function(a){var b=this;this.modal&&this.am&&(this.modal.setTitle("Select image"),this.modal.setContent(this.am.render(1)),this.am.setTarget(this.model),this.modal.show(),this.am.onSelect(function(){b.modal.hide(),b.am.setTarget(null)}))},render:function(){return this.updateAttributes(),this}})}),c("DomComponents/view/ComponentTextView",["backbone","./ComponentView"],function(a,b){return b.extend({events:{dblclick:"enableEditing"},initialize:function(a){b.prototype.initialize.apply(this,arguments),_.bindAll(this,"disableEditing"),this.listenTo(this.model,"focus",this.enableEditing),this.config.rte&&(this.rte=this.config.rte)},enableEditing:function(a){if(this.rte){var b=this.config.em.get("$editor");!this.$wrapper&&b.length&&(this.$wrapper=b.find("#"+this.config.wrapperId)),this.rte.bind(this,this.$wrapper)}$(document).on("mousedown",this.disableEditing),this.$el.on("mousedown",this.disablePropagation)},disableEditing:function(a){this.rte&&this.rte.unbind(this),$(document).off("mousedown",this.disableEditing),this.$el.off("mousedown",this.disablePropagation),this.updateContents()},disablePropagation:function(a){a.stopPropagation()},updateContents:function(){this.model.set("content",this.$el.html())},render:function(){return this.updateAttributes(),this.$el.html(this.model.get("content")),this}})}),c("DomComponents/main",["require","./config/config","./model/Component","./model/ComponentText","./model/ComponentImage","./view/ComponentView","./view/ComponentImageView","./view/ComponentTextView"],function(a){function b(b){var c=b||{},d=a("./config/config"),e=a("./model/Component"),f=(a("./model/ComponentText"),a("./model/ComponentImage"),a("./view/ComponentView"));a("./view/ComponentImageView"),a("./view/ComponentTextView");for(var g in d)g in c||(c[g]=d[g]);c.wrapper.attributes||(c.wrapper.attributes={}),c.wrapper.attributes.id="wrapper",!c.wrapper.components.length&&c.defaults.length&&(c.wrapper.components=c.defaults),c.wrapper.style||(c.wrapper.style={}),c.wrapper.style.position="relative",this.component=new e(c.wrapper);var h={model:this.component,config:c};this.c=c,this.ComponentView=new f(h)}return b.prototype={getComponent:function(){return this.component},getWrapper:function(){return this.getComponent()},getComponents:function(){return this.getWrapper().get("components")},render:function(){return this.ComponentView.render().el}},b}),c("DomComponents",["DomComponents/main"],function(a){return a}),c("ClassManager/config/config",[],function(){return{stylePrefix:"clm-",classes:[],label:"Classes",statesLabel:"States"}}),c("text!ClassManager/template/classTags.html",[],function(){return'
\n
<%= label %>
\n
\n <%= statesLabel %>\n \n
\n
\n
\n'}),c("text!ClassManager/template/classTag.html",[],function(){return'<%= label %>
⨯'}),c("ClassManager/view/ClassTagView",["backbone","text!./../template/classTag.html"],function(a,b){return a.View.extend({template:_.template(b),events:{},initialize:function(a){this.config=a.config||{},this.pfx=this.config.stylePrefix,this.className=this.pfx+"tag",this.closeId=this.pfx+"close",this.events["click #"+this.closeId]="removeTag",this.delegateEvents()},removeTag:function(a){var b=this.config.target.get("selectedComponent");b&&b.get("classes").remove(this.model),this.remove()},render:function(){return this.$el.html(this.template({label:this.model.get("label"),pfx:this.pfx})),this.$el.attr("class",this.className),this}})}),c("ClassManager/view/ClassTagsView",["backbone","text!./../template/classTags.html","./ClassTagView"],function(a,b,c){return a.View.extend({template:_.template(b),events:{"click .add":"startNewClass"},initialize:function(a){this.config=a.config||{},this.pfx=this.config.stylePrefix,this.className=this.pfx+"tags",this.addBtnId=this.pfx+"add-tag",this.newInputId=this.pfx+"new",this.events["click #"+this.addBtnId]="startNewTag",this.events["blur #"+this.newInputId]="endNewTag",this.events["keyup #"+this.newInputId]="onInputKeyUp",this.target=this.config.target,this.listenTo(this.target,"change:selectedComponent",this.componentChanged),this.listenTo(this.collection,"add",this.addNew),this.listenTo(this.collection,"reset",this.renderClasses),this.delegateEvents()},addNew:function(a){this.addToClasses(a)},startNewTag:function(a){this.$addBtn.hide(),this.$input.show().focus()},endNewTag:function(a){this.$addBtn.show(),this.$input.hide().val("")},addTag:function(a){},componentChanged:function(a){this.compTarget=this.target.get("selectedComponent");var b=this.compTarget?this.compTarget.get("classes").models:[];this.collection.reset(b)},onInputKeyUp:function(a){13===a.keyCode?this.addNewTag(this.$input.val()):27===a.keyCode&&this.endNewTag()},addNewTag:function(a){if(a){if(this.target){var b=this.target.get("ClassManager"),c=b.addClass(a);this.compTarget&&this.compTarget.get("classes").add(c)}this.endNewTag()}},addToClasses:function(a,b){var d=b||null,e=new c({model:a,config:this.config}),f=e.render().el;return d?d.appendChild(f):this.$classes.append(f),f},renderClasses:function(){var a=document.createDocumentFragment();return this.collection.each(function(b){this.addToClasses(b,a)},this),this.$classes&&this.$classes.empty().append(a),this},render:function(){return this.$el.html(this.template({label:this.config.label,statesLabel:this.config.statesLabel,pfx:this.pfx})),this.$input=this.$el.find("input#"+this.newInputId),this.$addBtn=this.$el.find("#"+this.addBtnId),this.$classes=this.$el.find("#"+this.pfx+"tags-c"),this.renderClasses(),this.$el.attr("class",this.className),this}})}),c("ClassManager/main",["require","./config/config","./model/ClassTags","./view/ClassTagsView"],function(a){var b=function(b){var c=b||{},d=a("./config/config"),e=a("./model/ClassTags"),f=a("./view/ClassTagsView");for(var g in d)g in c||(c[g]=d[g]);this.classes=new e(c.classes);var h={collection:this.classes,config:c};this.tagsView=new f(h)};return b.prototype={getClasses:function(){return this.classes},getClass:function(a){var b=this.classes.where({name:a});return b.length?b[0]:null},addClass:function(a){var b=a,c=this.escapeName(a),d=this.getClass(c);return d?d:this.classes.add({name:c,label:b})},escapeName:function(a){return a.toLowerCase().replace(/([^a-z0-9\w]+)/gi,"-")},renderTags:function(){return this.tagsView.render().el}},b}),c("ClassManager",["ClassManager/main"],function(a){return a}),c("Panels/config/config",[],function(){return{stylePrefix:"pn-",defaults:[],em:null,delayBtnsShow:300}}),c("Panels/model/Button",["backbone","require"],function(a,b){return a.Model.extend({defaults:{id:"",className:"",command:"",context:"",buttons:[],attributes:{},active:!1},initialize:function(a){if(this.get("buttons").length){var c=b("./Buttons");this.set("buttons",new c(this.get("buttons")))}}})}),c("Panels/model/Buttons",["backbone","./Button"],function(a,b){return a.Collection.extend({model:b,deactivateAllExceptOne:function(a,b){this.forEach(function(c,d){c!==a&&(c.set("active",!1),b&&c.get("buttons").length&&c.get("buttons").deactivateAllExceptOne(a,b))})},deactivateAll:function(a){this.forEach(function(b,c){b.get("context")==a&&(b.set("active",!1),b.get("buttons").length&&b.get("buttons").deactivateAll(a))})}})}),c("Panels/model/Panel",["backbone","./Buttons"],function(a,b){return a.Model.extend({defaults:{id:"",content:"",visible:!0,buttons:[]},initialize:function(a){this.btn=this.get("buttons")||[],this.buttons=new b(this.btn),this.set("buttons",this.buttons)}})}),c("Panels/model/Panels",["backbone","./Panel"],function(a,b){return a.Collection.extend({model:b})}),c("Panels/view/ButtonView",["backbone","require"],function(a,b){return a.View.extend({tagName:"span",events:{click:"clicked"},initialize:function(a){_.bindAll(this,"startTimer","stopTimer","showButtons","hideButtons","closeOnKeyPress"),this.config=a.config,this.em=this.config.em||{},this.pfx=this.config.stylePrefix,this.id=this.pfx+this.model.get("id"),this.className=this.pfx+"btn "+this.model.get("className"),this.activeCls=this.pfx+"active",this.btnsVisCls=this.pfx+"visible",this.parentM=a.parentM||null,this.listenTo(this.model,"change:active updateActive",this.updateActive),this.listenTo(this.model,"checkActive",this.checkActive),this.listenTo(this.model,"change:bntsVis",this.updateBtnsVis),this.listenTo(this.model,"change:attributes",this.updateAttributes),this.listenTo(this.model,"change:className",this.updateClassName),this.model.get("buttons").length&&(this.$el.on("mousedown",this.startTimer),this.$el.append($("
",{"class":this.pfx+"arrow-rd"}))),this.em&&(this.commands=this.em.get("Commands"))},updateClassName:function(){this.$el.attr("class",this.pfx+"btn "+this.model.get("className"))},updateAttributes:function(){this.$el.attr(this.model.get("attributes"))},updateBtnsVis:function(){this.$buttons&&(this.model.get("bntsVis")?this.$buttons.addClass(this.btnsVisCls):this.$buttons.removeClass(this.btnsVisCls))},startTimer:function(){this.timeout=setTimeout(this.showButtons,this.config.delayBtnsShow),$(document).on("mouseup",this.stopTimer)},stopTimer:function(){$(document).off("mouseup",this.stopTimer),this.timeout&&clearTimeout(this.timeout)},showButtons:function(){clearTimeout(this.timeout),this.model.set("bntsVis",!0),$(document).on("mousedown",this.hideButtons),$(document).on("keypress",this.closeOnKeyPress)},hideButtons:function(a){a&&$(a.target).trigger("click"),this.model.set("bntsVis",!1),$(document).off("mousedown",this.hideButtons),$(document).off("keypress",this.closeOnKeyPress)},closeOnKeyPress:function(a){var b=a.which||a.keyCode;27==b&&this.hideButtons()},updateActive:function(){var a=null;this.commands&&(a=this.commands.get(this.model.get("command"))),this.model.get("active")?(this.model.collection.deactivateAll(this.model.get("context")),this.model.set("active",!0,{silent:!0}).trigger("checkActive"),this.parentM&&this.parentM.set("active",!0,{silent:!0}).trigger("checkActive"),a&&a.run(this.em,this.model)):(this.$el.removeClass(this.activeCls),this.model.collection.deactivateAll(this.model.get("context")),this.parentM&&this.parentM.set("active",!1,{silent:!0}).trigger("checkActive"),a&&a.stop(this.em,this.model))},checkActive:function(){this.model.get("active")?this.$el.addClass(this.activeCls):this.$el.removeClass(this.activeCls)},clicked:function(a){this.model.get("bntsVis")||(this.parentM&&this.swapParent(),this.model.set("active",!this.model.get("active")))},swapParent:function(){this.parentM.collection.deactivateAll(this.model.get("context")),this.parentM.set("attributes",this.model.get("attributes")),this.parentM.set("options",this.model.get("options")),this.parentM.set("command",this.model.get("command")),this.parentM.set("className",this.model.get("className")),this.parentM.set("active",!0,{silent:!0}).trigger("checkActive")},render:function(){if(this.updateAttributes(),this.$el.attr("class",this.className),this.model.get("buttons").length){var a=b("./ButtonsView"),c=new a({collection:this.model.get("buttons"),config:this.config,parentM:this.model});this.$buttons=c.render().$el,this.$buttons.append($("
",{"class":this.pfx+"arrow-l"})),this.$el.append(this.$buttons)}return this}})}),c("Panels/view/ButtonsView",["backbone","./ButtonView"],function(a,b){return a.View.extend({initialize:function(a){this.opt=a,this.config=a.config,this.pfx=a.config.stylePrefix,this.parentM=a.parentM||null,this.listenTo(this.collection,"add",this.addTo),this.listenTo(this.collection,"reset",this.render),this.className=this.pfx+"buttons"},addTo:function(a){this.addToCollection(a)},addToCollection:function(a,c){var d=c||null,e=b,f=new e({model:a,config:this.config,parentM:this.parentM}),g=f.render().el;return d?d.appendChild(g):this.$el.append(g),g},render:function(){var a=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(b){this.addToCollection(b,a)},this),this.$el.append(a),this.$el.attr("class",_.result(this,"className")),this}})}),c("Panels/view/PanelView",["backbone","./ButtonsView"],function(a,b){return a.View.extend({initialize:function(a){this.config=a.config,this.pfx=this.config.stylePrefix,this.buttons=this.model.get("buttons"),this.className=this.pfx+"panel",this.id=this.pfx+this.model.get("id"),this.listenTo(this.model,"change:appendContent",this.appendContent),this.listenTo(this.model,"change:content",this.updateContent)},appendContent:function(){this.$el.append(this.model.get("appendContent"))},updateContent:function(){this.$el.html(this.model.get("content"))},render:function(){if(this.$el.attr("class",_.result(this,"className")),this.$el.attr("id",this.id),this.buttons.length){var a=new b({collection:this.buttons,config:this.config});this.$el.append(a.render().el)}return this.$el.append(this.model.get("content")),this}})}),c("Panels/view/PanelsView",["backbone","./PanelView"],function(a,b){return a.View.extend({initialize:function(a){this.opt=a,this.config=a.config,this.pfx=a.config.stylePrefix,this.listenTo(this.collection,"add",this.addTo),this.listenTo(this.collection,"reset",this.render),this.className=this.pfx+"panels"},addTo:function(a){this.addToCollection(a)},addToCollection:function(a,c){var d=c||null,e=b,f=new e({model:a,config:this.config}),g=f.render().el;return d?d.appendChild(g):this.$el.append(g),g},render:function(){var a=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(b){this.addToCollection(b,a)},this),this.$el.append(a),this.$el.attr("class",_.result(this,"className")),this}})}),c("Panels/main",["require","./config/config","./model/Panels","./view/PanelsView"],function(a){function b(b){var c=b||{},d=a("./config/config"),e=a("./model/Panels"),f=a("./view/PanelsView");for(var g in d)g in c||(c[g]=d[g]);this.panels=new e(c.defaults);var h={collection:this.panels,config:c};this.PanelsView=new f(h)}return b.prototype={getPanels:function(){return this.panels},addPanel:function(a){return this.panels.add(a)},getPanel:function(a){var b=this.panels.where({id:a});return b.length?b[0]:null},addButton:function(a,b){var c=this.getPanel(a);return c?c.get("buttons").add(b):null},getButton:function(a,b){var c=this.getPanel(a);if(c){var d=c.get("buttons").where({id:b});return d.length?d[0]:null}return null},active:function(){this.getPanels().each(function(a){a.get("buttons").each(function(a){a.get("active")&&a.trigger("updateActive")})})},render:function(){return this.PanelsView.render().el}},b}),c("Panels",["Panels/main"],function(a){return a}),c("editor/model/Editor",["backbone","backboneUndo","keymaster","AssetManager","StorageManager","ModalDialog","CodeManager","Commands","Canvas","RichTextEditor","DomComponents","ClassManager","Panels"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){return a.Model.extend({defaults:{clipboard:null,selectedComponent:null,previousModel:null,changesCount:0},initialize:function(a){this.config=a,this.compName=this.config.storagePrefix+"components"+this.config.id,this.set("Config",a),this.initClassManager(),this.initStorage(),this.initModal(),this.initAssetManager(),this.initCodeManager(),this.initCommands(),this.initPanels(),this.initRichTextEditor(),this.initComponents(),this.initCanvas(),this.initUndoManager(),this.on("change:selectedComponent",this.componentSelected,this)},initClassManager:function(){var a=this.config.classManager,b=a.stylePrefix||"clm-";a.stylePrefix=this.config.stylePrefix+b,a.target=this,this.clm=new l(a),this.set("ClassManager",this.clm)},initComponents:function(){var a=this.config.components,b=this.loadComponents(),c=a.stylePrefix||"comp-";if(a.stylePrefix=this.config.stylePrefix+c,b&&(a.wrapper=b),this.rte&&(a.rte=this.rte),this.modal&&(a.modal=this.modal),this.am&&(a.am=this.am),a.em=this,this.cmp=new k(a),this.stm.isAutosave()){var d=this.cmp.getComponent();this.updateComponents(d,null,{avoidStore:1}),this.initUndoManager(),this.initChildrenComp(d)}this.set("Components",this.cmp)},initCanvas:function(){var a=this.config.canvas,b=a.stylePrefix||"cv-";a.stylePrefix=this.config.stylePrefix+b,a.canvasId=this.config.idCanvas,this.cv=new i(this.config.canvas),this.cmp&&this.cv.setWrapper(this.cmp),this.set("Canvas",this.cv)},initRichTextEditor:function(){var a=this.config.rte,b=a.stylePrefix||"rte-";a.stylePrefix=this.config.stylePrefix+b,
+this.rte=new j(a),this.set("RichTextEditor",this.rte)},initStorage:function(){this.stm=new e(this.config.storageManager),this.stm.loadDefaultProviders().setCurrentProvider(this.config.storageType),this.set("StorageManager",this.stm)},initAssetManager:function(){var a=this.config.assetManager,b=a.stylePrefix||"am-";a.stylePrefix=this.config.stylePrefix+b,this.stm&&(a.stm=this.stm),this.am=new d(a),this.set("AssetManager",this.am)},initModal:function(){var a=this.config.modal,b=a.stylePrefix||"mdl-";a.stylePrefix=this.config.stylePrefix+b,this.modal=new f(a),this.modal.render().appendTo("body"),this.set("Modal",this.modal)},initCodeManager:function(){var a=this.config.codeManager,b=a.stylePrefix||"cm-";a.stylePrefix=this.config.stylePrefix+b,this.cm=new g(a),this.cm.loadDefaultGenerators().loadDefaultEditors(),this.set("CodeManager",this.cm)},initCommands:function(){var a=this.config.commands,b=a.stylePrefix||"com-";a.stylePrefix=this.config.stylePrefix+b,a.em=this,a.canvasId=this.config.idCanvas,a.wrapperId=this.config.idWrapper,this.com=new h(a),this.com.loadDefaultCommands(),this.set("Commands",this.com)},initPanels:function(){var a=this.config.panels,b=a.stylePrefix||"pn-";a.stylePrefix=this.config.stylePrefix+b,a.em=this,this.pn=new m(a),this.pn.addPanel({id:"views-container"}),this.set("Panels",this.pn)},initUndoManager:function(){if(!this.um&&this.cmp&&this.config.undoManager){var b=this;this.um=new a.UndoManager({register:[this.cmp.getComponent().get("components")],track:!0}),this.set("UndoManager",this.um),key("⌘+z, ctrl+z",function(){b.um.undo()}),key("⌘+shift+z, ctrl+shift+z",function(){b.um.redo()}),a.UndoManager.removeUndoType("change");var c;a.UndoManager.addUndoType("change:style",{on:function(a,b,d){if(c||(c=a.toJSON()),!d||!d.avoidStore){var e={object:a,before:c,after:a.toJSON()};return c=null,e}},undo:function(a,b,c,d){a.set(b)},redo:function(a,b,c,d){a.set(c)}})}},componentsUpdated:function(a,b,c){var d=this.get("changesCount")+1,e=c?c.avoidStore:0;this.set("changesCount",d),this.stm.isAutosave()&&d