diff --git a/dist/grapes.min.js b/dist/grapes.min.js index de06c62ad..e2358fc34 100644 --- a/dist/grapes.min.js +++ b/dist/grapes.min.js @@ -11,6 +11,6 @@ uf)var l=window.scrollY;if(f.input.focus(),uf&&window.scrollTo(null,l),f.input.r tokenHooks:{"/":function(a,b){return a.eat("*")?(b.tokenize=c,c(a,b)):!1}},name:"css",helperType:"gss"})}),function(a){"object"==typeof exports&&"object"==typeof module?a(b("../../lib/codemirror"),b("../xml/xml"),b("../javascript/javascript"),b("../css/css")):"function"==typeof c&&c.amd?c("codemirror/mode/htmlmixed/htmlmixed",["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c){var d=a.current(),e=d.search(b);return e>-1?a.backUp(d.length-e):d.match(/<\/?$/)&&(a.backUp(d.length),a.match(b,!1)||a.match(d)),c}function c(a){var b=i[a];return b?b:i[a]=new RegExp("\\s+"+a+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")}function d(a,b){for(var d,e=a.pos;e>=0&&"<"!==a.string.charAt(e);)e--;return 0>e?e:(d=a.string.slice(e,a.pos).match(c(b)))?d[2]:""}function e(a,b){return new RegExp((b?"^":"")+"","i")}function f(a,b){for(var c in a)for(var d=b[c]||(b[c]=[]),e=a[c],f=e.length-1;f>=0;f--)d.unshift(e[f])}function g(a,b){for(var c=0;c"===d.current()&&(h=g(m,d))){var o=a.getMode(c,h),p=e(l,!0),q=e(l,!1);f.token=function(a,c){return a.match(p,!1)?(c.token=i,c.localState=c.localMode=null,null):b(a,q,c.localMode.token(a,c.localState))},f.localMode=o,f.localState=a.startState(o,j.indent(f.htmlState,""))}return n}var j=a.getMode(c,{name:"xml",htmlMode:!0,multilineTagIndentFactor:d.multilineTagIndentFactor,multilineTagIndentPastTag:d.multilineTagIndentPastTag}),k={},l=d&&d.tags,m=d&&d.scriptTypes;if(f(h,k),l&&f(l,k),m)for(var n=m.length-1;n>=0;n--)k.script.unshift(["type",m[n].matches,m[n].mode]);return{startState:function(){var a=j.startState();return{token:i,localMode:null,localState:null,htmlState:a}},copyState:function(b){var c;return b.localState&&(c=a.copyState(b.localMode,b.localState)),{token:b.token,localMode:b.localMode,localState:c,htmlState:a.copyState(j,b.htmlState)}},token:function(a,b){return b.token(a,b)},indent:function(b,c){return!b.localMode||/^\s*<\//.test(c)?j.indent(b.htmlState,c):b.localMode.indent?b.localMode.indent(b.localState,c):a.Pass},innerMode:function(a){return{state:a.localState||a.htmlState,mode:a.localMode||j}}}},"xml","javascript","css"),a.defineMIME("text/html","htmlmixed")}),function(a){"object"==typeof exports&&"object"==typeof module?a(b("codemirror/lib/codemirror")):"function"==typeof c&&c.amd?c("formatting",["codemirror/lib/codemirror"],a):a(CodeMirror)}(function(a){a.extendMode("css",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(a,b){return/^[;{}]$/.test(b)}}),a.extendMode("javascript",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(a,b,c,d){return this.jsonMode?/^[\[,{]$/.test(b)||/^}/.test(c):";"==b&&d.lexical&&")"==d.lexical.type?!1:/^[;{}]$/.test(b)&&!/^;/.test(c)}});var b=/^(a|abbr|acronym|area|base|bdo|big|br|button|caption|cite|code|col|colgroup|dd|del|dfn|em|frame|hr|iframe|img|input|ins|kbd|label|legend|link|map|object|optgroup|option|param|q|samp|script|select|small|span|strong|sub|sup|textarea|tt|var)$/;a.extendMode("xml",{commentStart:"",newlineAfterToken:function(a,c,d,e){var f=!1;return"html"==this.configuration&&(f=e.context?b.test(e.context.tagName):!1),!f&&("tag"==a&&/>$/.test(c)&&e.context||/^-1&&h>-1&&h>g&&(a=a.substr(0,g)+a.substring(g+f.commentStart.length,h)+a.substr(h+f.commentEnd.length)),e.replaceRange(a,c,d)}})}),a.defineExtension("autoIndentRange",function(a,b){var c=this;this.operation(function(){for(var d=a.line;d<=b.line;d++)c.indentLine(d,"smart")})}),a.defineExtension("autoFormatRange",function(b,c){function d(){j+="\n",l=!0,++k}for(var e=this,f=e.getMode(),g=e.getRange(b,c).split("\n"),h=a.copyState(f,e.getTokenAt(b).state),i=e.getOption("tabSize"),j="",k=0,l=0===b.ch,m=0;m=a;++a)e.indentLine(a,"smart");e.setSelection(b,e.getCursor(!1))})})}),c("CodeManager/model/CodeMirrorEditor",["backbone","codemirror/lib/codemirror","codemirror/mode/htmlmixed/htmlmixed","codemirror/mode/css/css","formatting"],function(a,b,c,d,e){return a.Model.extend({defaults:{input:"",label:"",codeName:"",theme:"",readOnly:!0,lineNumbers:!0},init:function(a){return this.editor=b.fromTextArea(a,{dragDrop:!1,lineNumbers:this.get("lineNumbers"),readOnly:this.get("readOnly"),mode:this.get("codeName"),theme:this.get("theme")}),this},setContent:function(a){this.editor&&(this.editor.setValue(a),this.editor.autoFormatRange&&(b.commands.selectAll(this.editor),this.editor.autoFormatRange(this.editor.getCursor(!0),this.editor.getCursor(!1)),b.commands.goDocStart(this.editor)))}})}),c("text!CodeManager/template/editor.html",[],function(){return'
\n
<%= label %>
\n
\n
\n'}),c("CodeManager/view/EditorView",["backbone","text!./../template/editor.html"],function(a,b){return a.View.extend({template:_.template(b),initialize:function(a){this.config=a.config||{},this.pfx=this.config.stylePrefix},render:function(){var a=this.model.toJSON();return a.pfx=this.pfx,this.$el.html(this.template(a)),this.$el.attr("class",this.pfx+"editor-c"),this.$el.find("#"+this.pfx+"code").html(this.model.get("input")),this}})}),c("CodeManager/main",["require","./config/config","./model/HtmlGenerator","./model/CssGenerator","./model/JsonGenerator","./model/CodeMirrorEditor","./view/EditorView"],function(a){var b=function(){var b={},c=a("./config/config"),d=a("./model/HtmlGenerator"),e=a("./model/CssGenerator"),f=a("./model/JsonGenerator"),g=a("./model/CodeMirrorEditor"),h=a("./view/EditorView"),i={},j={},k={},l={};return{getConfig:function(){return b},config:b,EditorView:h,name:"CodeManager",init:function(a){b=a||{};for(var h in c)h in b||(b[h]=c[h]);var i=b.pStylePrefix;return i&&(b.stylePrefix=i+b.stylePrefix),j.html=new d,j.css=new e,j.json=new f,l.CodeMirror=new g,this},onLoad:function(){this.loadDefaultGenerators().loadDefaultViewers()},addGenerator:function(a,b){return i[a]=b,this},getGenerator:function(a){return i[a]||null},getGenerators:function(){return i},addViewer:function(a,b){return k[a]=b,this},getViewer:function(a){return k[a]||null},getViewers:function(){return k},updateViewer:function(a,b){a.setContent(b)},getCode:function(a,b,c){var d=this.getGenerator(b);return d?d.build(a,c):""},loadDefaultGenerators:function(){for(var a in j)this.addGenerator(a,j[a]);return this},loadDefaultViewers:function(){for(var a in l)this.addViewer(a,l[a]);return this}}};return b}),c("CodeManager",["CodeManager/main"],function(a){return a}),c("Panels/config/config",[],function(){var a="create-comp",b="move-comp",c="sw-visibility",d="export-template",e="open-sm",f="open-layers",g="open-blocks",h="fullscreen",i="preview";return{stylePrefix:"pn-",defaults:[{id:"commands",buttons:[{id:a,command:a,className:"fa fa-pencil-square-o",attributes:{title:"Create element"},stopDefaultCommand:1},{id:b,command:b,className:"fa fa-arrows",attributes:{title:"Move elements"},stopDefaultCommand:1}]},{id:"options",buttons:[{active:!0,id:c,className:"fa fa-square-o",command:c,context:c,attributes:{title:"View components"}},{id:i,className:"fa fa-eye",command:i,context:i,stopDefaultCommand:1,attributes:{title:"Preview"}},{id:h,className:"fa fa-arrows-alt",command:h,context:h,attributes:{title:"Fullscreen"}},{id:d,className:"fa fa-code",command:d,attributes:{title:"View code"}}]},{id:"views",buttons:[{id:e,className:"fa fa-paint-brush",command:e,active:!0,attributes:{title:"Open Style Manager"}},{id:f,className:"fa fa-bars",command:f,attributes:{title:"Open Layer Manager"}},{id:g,className:"fa fa-th-large",command:g,attributes:{title:"Open Blocks"}}]}],em:null,delayBtnsShow:300}}),c("Panels/model/Button",["backbone","require"],function(a,b){return a.Model.extend({defaults:{id:"",className:"",command:"",context:"",buttons:[],attributes:{},options:{},active:!1,dragDrop:!1,runDefaultCommand:!0,stopDefaultCommand:!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){var b=a||"";this.forEach(function(a,c){a.get("context")==b&&(a.set("active",!1),a.get("buttons").length&&a.get("buttons").deactivateAll(b))})}})}),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",initialize:function(a){_.bindAll(this,"startTimer","stopTimer","showButtons","hideButtons","closeOnKeyPress","onDrop","initSorter","stopDrag");var b=this.model.get("className");this.config=a.config||{},this.em=this.config.em||{},this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.id=this.pfx+this.model.get("id"),this.activeCls=this.pfx+"active",this.btnsVisCls=this.pfx+"visible",this.parentM=a.parentM||null,this.className=this.pfx+"btn"+(b?" "+b:""),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.em.get&&(this.commands=this.em.get("Commands")),this.events={},this.model.get("dragDrop")?(this.events.mousedown="initDrag",this.em.on("loaded",this.initSorter)):this.events.click="clicked",this.delegateEvents()},initSorter:function(){if(this.em.Canvas){var a=this.em.Canvas;this.canvasEl=a.getBody(),this.sorter=new this.em.Utils.Sorter({container:this.canvasEl,placer:a.getPlacerEl(),containerSel:"*",itemSel:"*",pfx:this.ppfx,onMove:this.onDrag,onEndMove:this.onDrop,document:a.getFrameEl().contentDocument,direction:"a",wmargin:1,nested:1});var b=a.getOffset();this.sorter.offTop=b.top,this.sorter.offLeft=b.left}},initDrag:function(){this.model.collection.deactivateAll(this.model.get("context")),this.sorter.startSort(this.el),this.sorter.setDropContent(this.model.get("options").content),this.canvasEl.style.cursor="grabbing",$(document).on("mouseup",this.stopDrag)},stopDrag:function(){$(document).off("mouseup",this.stopDrag),this.sorter.endMove()},onDrag:function(a){},onDrop:function(a){this.canvasEl.style.cursor="default"},updateClassName:function(){var a=this.model.get("className");this.$el.attr("class",this.pfx+"btn"+(a?" "+a:""))},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,b=this.em&&this.em.get?this.em.get("Editor"):null,c=this.model.get("command");this.commands&&(a=this.commands.get(c)),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(b,this.model,this.model.get("options")),b.trigger("run:"+c))):(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(b,this.model,this.model.get("options")),b.trigger("stop:"+c)))},checkActive:function(){this.model.get("active")?this.$el.addClass(this.activeCls):this.$el.removeClass(this.activeCls)},clicked:function(a){if(!this.model.get("bntsVis")){this.parentM&&this.swapParent();var b=this.model.get("active");this.model.set("active",!b);this.em.get("Commands").get("select-comp");b?this.model.get("runDefaultCommand")&&this.em.runDefault():this.model.get("stopDefaultCommand")&&this.em.stopDefault()}},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=this.opt.config||{},this.pfx=this.config.stylePrefix||"",this.parentM=this.opt.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.id&&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=this.opt.config||{},this.pfx=this.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/Panel","./model/Panels","./view/PanelView","./view/PanelsView"],function(a){return function(){var b,c,d={},e=a("./config/config"),f=a("./model/Panel"),g=a("./model/Panels"),h=(a("./view/PanelView"),a("./view/PanelsView"));return{name:"Panels",init:function(a){d=a||{};for(var f in e)f in d||(d[f]=e[f]);var i=d.pStylePrefix;return i&&(d.stylePrefix=i+d.stylePrefix),b=new g(d.defaults),c=new h({collection:b,config:d}),this},getPanels:function(){return b},getPanelsEl:function(){return c.el},addPanel:function(a){return b.add(a)},getPanel:function(a){var c=b.where({id:a});return c.length?c[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},render:function(){return c.render().el},active:function(){this.getPanels().each(function(a){a.get("buttons").each(function(a){a.get("active")&&a.trigger("updateActive")})})},Panel:f}}}),c("Panels",["Panels/main"],function(a){return a}),c("RichTextEditor/config/config",[],function(){return{stylePrefix:"rte-",toolbarId:"toolbar",containerId:"wrapper",commands:[{command:"bold",title:"Bold","class":"fa fa-bold"},{command:"italic",title:"Italic","class":"fa fa-italic"},{command:"underline",title:"Underline","class":"fa fa-underline"},{command:"strikethrough",title:"Strikethrough","class":"fa fa-strikethrough",group:"format"}]}}),c("RichTextEditor/view/TextEditorView",["jquery"],function(a){var b=function(b){var c=a.Deferred(),d=new FileReader;return d.onload=function(a){c.resolve(a.target.result)},d.onerror=c.reject,d.onprogress=c.notify,d.readAsDataURL(b),c.promise()};return a.fn.cleanHtml=function(){var b=a(this).html();return b&&b.replace(/(
|\s|

<\/div>| )*$/,"")},a.fn.wysiwyg=function(c){var d,e,f,g=this,h=function(){var b=e.activeToolbarClass;b&&a(e.toolbarSelector).find(f).each(function(){var c=a(this),d=c.data(e.commandRole),f=g.get(0).ownerDocument;f.queryCommandState(d)?c.addClass(b):c.removeClass(b)})},i=function(a,b){var c=a.split(" "),d=c.shift(),e=c.join(" ")+(b||"");g.get(0).ownerDocument.execCommand("styleWithCSS",!1,!0),g.get(0).ownerDocument.execCommand(d,0,e),h()},j=function(){var a=window.getSelection();return a.getRangeAt&&a.rangeCount?a.getRangeAt(0):void 0},k=function(){d=j()},l=function(){var a=window.getSelection();if(d){try{a.removeAllRanges()}catch(b){document.body.createTextRange().select(),document.selection.empty()}a.addRange(d)}},m=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)})},n=function(a,b){l(),document.queryCommandSupported("hiliteColor")&&document.execCommand("hiliteColor",0,b||"transparent"),k(),a.data(e.selectionMarker,b)},o=function(b,c){b.find(f).unbind().click(function(){l(),g.get(0).ownerDocument.execCommand(a(this).data(c.commandRole)),k()}),b.find("[data-toggle=dropdown]").click(l);var d="[data-"+c.commandRole+"]";b.find("select"+d).on("webkitspeechchange change",function(){var b=this.value;l(),b&&(g.focus(),i(a(this).data(c.commandRole),b)),console.log("change isolated2 ",b),k()}),b.find("input[type=text]"+d,", select"+d).on("webkitspeechchange change",function(){console.log("on changed ",b);var b=this.value;this.value="",l(),b&&(g.focus(),i(a(this).data(c.commandRole),b)),k()}).on("focus",function(){console.log("on focus ");var b=a(this);b.data(c.selectionMarker)||(console.log("i have no ",c.selectionMarker),n(b,c.selectionColor),b.focus())}).on("blur",function(){var b=a(this);b.data(c.selectionMarker)&&n(b,!1)}),b.find("input[type=file][data-"+c.commandRole+"]").change(function(){l(),"file"===this.type&&this.files&&this.files.length>0&&m(this.files),k(),this.value=""})},p=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&&m(b.files)})};if("string"==typeof c&&"destroy"==c)return g.attr("contenteditable",!1).unbind("mouseup keyup mouseout dragenter dragover"),a(window).unbind("touchend"),this;e=a.extend({},a.fn.wysiwyg.defaults,c);var q="[data-"+e.commandRole+"]";return f="a"+q+",button"+q+",input[type=button]"+q+", select"+q,e.dragAndDropImages&&p(),o(a(e.toolbarSelector),e),g.attr("contenteditable",!0).on("mouseup keyup mouseout",function(){k(),h()}),a(window).bind("touchend",function(a){var b=g.is(a.target)||g.has(a.target).length>0,c=j(),d=c&&c.startContainer===c.endContainer&&c.startOffset===c.endOffset;(!d||b)&&(k(),h())}),this},a.fn.wysiwyg.defaults={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({idAttribute:"command",defaults:{command:"",type:"",title:"","class":"",options:[]},initialize:function(){var a=this.get("options");a.length&&this.set("type","select")}})}),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,b){this.config=b||{},this.className=this.config.stylePrefix+"btn "+this.model.get("class")},render:function(){return this.$el.addClass(this.className),this}})}),c("RichTextEditor/view/CommandButtonSelectView",["backbone"],function(a){return a.View.extend({initialize:function(a,b){this.config=b||{},this.className=this.config.stylePrefix+"btn "+this.model.get("class")},getInput:function(){var a=this.model;if(!this.input){for(var b=a.get("command"),c='",this.input=$(c)}return this.input},render:function(){return this.$el.addClass(this.className),this.$el.html(this.getInput()),this}})}),c("RichTextEditor/view/CommandButtonsView",["backbone","./CommandButtonView","./CommandButtonSelectView"],function(a,b,c){return a.View.extend({attributes:{"data-role":"editor-toolbar"},initialize:function(a){this.config=a.config||{};var b=this.config.stylePrefix||"";this.id=b+this.config.toolbarId,this.listenTo(this.collection,"add",this.addTo),this.$el.data("helper",1)},addTo:function(a){this.add(a)},add:function(a,d){var e=d||null,f=b;switch(a.get("type")){case"select":f=c}var g=new f({model:a,attributes:{title:a.get("title"),"data-edit":a.get("command")}},this.config),h=g.render().el;e?e.appendChild(h):this.$el.append(h)},render:function(){var a=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(b){this.add(b,a)},this),this.$el.append(a),this.$el.attr("id",this.id),this}})}),c("RichTextEditor/main",["require","./config/config","./view/TextEditorView","./model/CommandButtons","./view/CommandButtonsView"],function(a){return function(){var b,c,d,e={},f=a("./config/config"),g=(a("./view/TextEditorView"),a("./model/CommandButtons")),h=a("./view/CommandButtonsView");return{name:"rte",init:function(a){e=a||{};for(var i in f)i in e||(e[i]=f[i]);var j=e.pStylePrefix;return j&&(e.stylePrefix=j+e.stylePrefix),b=e.stylePrefix,d=new g(e.commands),c=new h({collection:d,config:e}),this},add:function(a,b){var c=b||{};return c.command=a,d.add(c)},get:function(a){return d.where({command:a})[0]},getAll:function(){return d},udpatePosition:function(){if(this.lastEl&&e.em){var a="px",b=e.em.get("canvasOffset"),d=e.em.get("Canvas").getCanvasView(),f=d.getElementPos(this.lastEl),g=c.el.style,h=c.$el.outerHeight();g.top=f.top-h+a,g.left=f.left+b.left+a}},attach:function(a){a.$el.wysiwyg({}).focus(),this.lastEl=a.el,e.em&&(this.udpatePosition(),e.em.off("change:canvasOffset",this.udpatePosition,this),e.em.on("change:canvasOffset",this.udpatePosition,this)),this.show(),c.$el.on("mousedown",this.disableProp)},detach:function(a){a.$el.wysiwyg("destroy"),this.hide(),c.$el.off("mousedown",this.disableProp)},show:function(){c.el.style.display="block"},hide:function(){c.el.style.display="none"},disableProp:function(a){a.stopPropagation()},getToolbarEl:function(){return c.el},render:function(){return c.render().el}}}}),c("RichTextEditor",["RichTextEditor/main"],function(a){return a}),c("StyleManager/config/config",[],function(){return{stylePrefix:"sm-",sectors:[{name:"General",open:!1,buildProps:["float","display","position","top","right","left","bottom"]},{name:"Dimension",open:!1,buildProps:["width","height","max-width","min-height","margin","padding"]},{name:"Typography",open:!1,buildProps:["font-family","font-size","font-weight","letter-spacing","color","line-height","text-align","text-shadow"],properties:[{property:"text-align",list:[{value:"left",className:"fa fa-align-left"},{value:"center",className:"fa fa-align-center"},{value:"right",className:"fa fa-align-right"},{value:"justify",className:"fa fa-align-justify"}]}]},{name:"Decorations",open:!1,buildProps:["border-radius-c","background-color","border-radius","border","box-shadow","background"]},{name:"Extra",open:!1,buildProps:["transition","perspective","transform"]}],textNoElement:"Select an element before using Style Manager"}}),c("StyleManager/model/Layer",["backbone"],function(a){return a.Model.extend({defaults:{index:"",active:!0,value:"",values:{},preview:!1},initialize:function(){var a=this.get("value");if(!a){var b="",c=this.get("values");for(var d in c)b+=" "+c[d];this.set("value",b.trim())}}})}),c("StyleManager/model/Layers",["backbone","./Layer"],function(a,b){return a.Collection.extend({model:b,initialize:function(){this.idx=1,this.on("add",this.onAdd),this.on("reset",this.onReset)},onAdd:function(a,b,c){c.noIncrement||a.set("index",this.idx++)},onReset:function(){this.idx=1}})}),c("StyleManager/model/Property",["backbone","./Layers"],function(a,b){return a.Model.extend({defaults:{name:"",property:"",type:"",units:[],unit:"",defaults:"",info:"",value:"",icon:"",preview:!1,detached:!1,functionName:"",properties:[],layers:[],list:[]},initialize:function(a){var c=this.get("type"),d=this.get("name"),e=this.get("property");switch(d||this.set("name",e.charAt(0).toUpperCase()+e.slice(1).replace(/-/g," ")),c){case"stack":this.set("layers",new b)}},getValue:function(){var a="",b=this.get("type");switch(b){case"integer":a=this.get("value")+this.get("unit");break;default:a=this.get("value")}return a}})}),c("StyleManager/model/Properties",["backbone","./Property"],function(a,b){return a.Collection.extend({model:b})}),c("StyleManager/model/PropertyFactory",["backbone"],function(a){return function(){return{build:function(a){var b=[];"string"==typeof a&&(a=[a]);for(var c=0,d=a.length;d>c;c++){var e={},f=a[c];switch(e.property=f,f){case"border-radius-c":e.property="border-radius"}switch(f){case"float":case"position":case"text-align":e.type="radio";break;case"display":case"font-family":case"font-weight":case"border-style":case"box-shadow-type":case"background-repeat":case"background-position":case"background-attachment":case"background-size":case"transition-property":case"transition-timing-function":case"cursor":case"overflow":e.type="select";break;case"top":case"right":case"bottom":case"left":case"margin-top":case"margin-right":case"margin-bottom":case"margin-left":case"padding-top":case"padding-right":case"padding-bottom":case"padding-left":case"min-height":case"min-width":case"max-height":case"max-width":case"width":case"height":case"font-size":case"letter-spacing":case"line-height":case"text-shadow-h":case"text-shadow-v":case"text-shadow-blur":case"border-radius-c":case"border-top-left-radius":case"border-top-right-radius":case"border-bottom-left-radius":case"border-bottom-right-radius":case"border-width":case"box-shadow-h":case"box-shadow-v":case"box-shadow-blur":case"box-shadow-spread":case"transition-duration":case"perspective":case"transform-rotate-x":case"transform-rotate-y":case"transform-rotate-z":case"transform-scale-x":case"transform-scale-y":case"transform-scale-z":e.type="integer";break;case"margin":case"padding":case"border-radius":case"border":case"transform":e.type="composite";break;case"color":case"text-shadow-color":case"background-color":case"border-color":case"box-shadow-color":e.type="color";break;case"text-shadow":case"box-shadow":case"background":case"transition":e.type="stack";break;case"background-image":e.type="file"}switch(f){case"float":case"background-color":case"background-image":e.defaults="none";break;case"display":e.defaults="block";break;case"position":e.defaults="static";break;case"top":case"right":case"bottom":case"left":case"margin-top":case"margin-right":case"margin-bottom":case"margin-left":case"padding-top":case"padding-right":case"padding-bottom":case"padding-left":case"text-shadow-h":case"text-shadow-v":case"text-shadow-blur":case"border-radius-c":case"border-top-left-radius":case"border-top-right-radius":case"border-bottom-left-radius":case"border-bottom-right-radius":case"box-shadow-h":case"box-shadow-v":case"box-shadow-spread":case"perspective":case"transform-rotate-x":case"transform-rotate-y":case"transform-rotate-z":e.defaults=0;break;case"transform-scale-x":case"transform-scale-y":case"transform-scale-z":e.defaults=1;break;case"box-shadow-blur":e.defaults=5;break;case"min-height":case"min-width":case"max-height":case"max-width":case"width":case"height":case"background-size":case"cursor":e.defaults="auto";break;case"font-family":e.defaults="Arial, Helvetica, sans-serif";break;case"font-size":case"border-width":e.defaults="medium";break;case"font-weight":e.defaults="400";break;case"letter-spacing":case"line-height":e.defaults="normal";break;case"color":case"text-shadow-color":case"border-color":case"box-shadow-color":e.defaults="black";break;case"text-align":e.defaults="left";break;case"border-style":e.defaults="solid";break;case"box-shadow-type":e.defaults="";break;case"background-repeat":e.defaults="repeat";break;case"background-position":e.defaults="left top";break;case"background-attachment":e.defaults="scroll";break;case"transition-property":e.defaults="width";break;case"transition-duration":e.defaults="2"; break;case"transition-timing-function":e.defaults="ease";break;case"overflow":e.defaults="visible"}switch(f){case"top":case"right":case"bottom":case"left":case"margin-top":case"margin-right":case"margin-bottom":case"margin-left":case"padding-top":case"padding-right":case"padding-bottom":case"padding-left":case"min-height":case"min-width":case"max-height":case"max-width":case"width":case"height":case"text-shadow-h":case"text-shadow-v":case"text-shadow-blur":case"border-radius-c":case"border-top-left-radius":case"border-top-right-radius":case"border-bottom-left-radius":case"border-bottom-right-radius":case"box-shadow-h":case"box-shadow-v":e.units=["px","%"];break;case"font-size":case"letter-spacing":case"line-height":e.units=["px","em","rem","%"];break;case"border-width":e.units=["px","em"];break;case"box-shadow-blur":case"box-shadow-spread":case"perspective":e.units=["px"];break;case"transition-duration":e.units=["s"];break;case"transform-rotate-x":case"transform-rotate-y":case"transform-rotate-z":e.units=["deg"]}switch(f){case"min-height":case"min-width":case"max-height":case"max-width":case"width":case"height":case"font-size":case"text-shadow-blur":case"border-radius-c":case"border-top-left-radius":case"border-top-right-radius":case"border-bottom-left-radius":case"border-bottom-right-radius":case"border-width":case"box-shadow-blur":case"transition-duration":case"perspective":e.min=0}switch(f){case"text-shadow":case"box-shadow":case"background":e.preview=!0}switch(f){case"background":e.detached=!0}switch(f){case"transform-rotate-x":e.functionName="rotateX";break;case"transform-rotate-y":e.functionName="rotateY";break;case"transform-rotate-z":e.functionName="rotateZ";break;case"transform-scale-x":e.functionName="scaleX";break;case"transform-scale-y":e.functionName="scaleY";break;case"transform-scale-z":e.functionName="scaleZ"}switch(f){case"float":e.list=[{value:"none"},{value:"left"},{value:"right"}];break;case"display":e.list=[{value:"block"},{value:"inline"},{value:"inline-block"},{value:"none"}];break;case"position":e.list=[{value:"static"},{value:"relative"},{value:"absolute"},{value:"fixed"}];break;case"font-family":var g=", sans-serif",h=["Arial, Helvetica"+g,"Arial Black, Gadget"+g,"Brush Script MT"+g,"Comic Sans MS, cursive"+g,"Courier New, Courier, monospace","Georgia, serif","Helvetica, serif","Impact, Charcoal"+g,"Lucida Sans Unicode, Lucida Grande"+g,"Tahoma, Geneva"+g,"Times New Roman, Times, serif","Trebuchet MS, Helvetica"+g,"Verdana, Geneva"+g];e.list=[];for(var i=0,j=h.length;j>i;i++){var k={};k.value=h[i],k.name=h[i].split(",")[0],k.style="font-family: "+h[i]+"; font-size:15px",e.list.push(k)}break;case"font-weight":e.list=[{value:"100",name:"Thin"},{value:"200",name:"Extra-Light"},{value:"300",name:"Light"},{value:"400",name:"Normal"},{value:"500",name:"Medium"},{value:"600",name:"Semi-Bold"},{value:"700",name:"Bold"},{value:"800",name:"Extra-Bold"},{value:"900",name:"Ultra-Bold"}];break;case"text-align":e.list=[{value:"left"},{value:"center"},{value:"right"},{value:"justify"}];break;case"border-style":e.list=[{value:"none"},{value:"solid"},{value:"dotted"},{value:"dashed"},{value:"double"},{value:"groove"},{value:"ridge"},{value:"inset"},{value:"outset"}];break;case"box-shadow-type":e.list=[{value:"",name:"Outside"},{value:"inset",name:"Inside"}];break;case"background-repeat":e.list=[{value:"repeat"},{value:"repeat-x"},{value:"repeat-y"},{value:"no-repeat"}];break;case"background-position":e.list=[{value:"left top"},{value:"left center"},{value:"left bottom"},{value:"right top"},{value:"right center"},{value:"right bottom"},{value:"center top"},{value:"center center"},{value:"center bottom"}];break;case"background-attachment":e.list=[{value:"scroll"},{value:"fixed"},{value:"local"}];break;case"background-size":e.list=[{value:"auto"},{value:"cover"},{value:"contain"}];break;case"transition-property":e.list=[{value:"all"},{value:"width"},{value:"height"},{value:"background-color"},{value:"transform"},{value:"box-shadow"},{value:"opacity"}];break;case"transition-timing-function":e.list=[{value:"linear"},{value:"ease"},{value:"ease-in"},{value:"ease-out"},{value:"ease-in-out"}];break;case"cursor":e.list=[{value:"auto"},{value:"pointer"},{value:"copy"},{value:"crosshair"},{value:"grab"},{value:"grabbing"},{value:"help"},{value:"move"},{value:"text"}];break;case"overflow":e.list=[{value:"visible"},{value:"hidden"},{value:"scroll"},{value:"auto"}]}switch(f){case"margin":e.properties=this.build(["margin-top","margin-right","margin-bottom","margin-left"]);break;case"padding":e.properties=this.build(["padding-top","padding-right","padding-bottom","padding-left"]);break;case"text-shadow":e.properties=this.build(["text-shadow-h","text-shadow-v","text-shadow-blur","text-shadow-color"]);break;case"border":e.properties=this.build(["border-width","border-style","border-color"]);break;case"border-radius":e.properties=this.build(["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"]);break;case"box-shadow":e.properties=this.build(["box-shadow-h","box-shadow-v","box-shadow-blur","box-shadow-spread","box-shadow-color","box-shadow-type"]);break;case"background":e.properties=this.build(["background-image","background-repeat","background-position","background-attachment","background-size"]);break;case"transition":e.properties=this.build(["transition-property","transition-duration","transition-timing-function"]);break;case"transform":e.properties=this.build(["transform-rotate-x","transform-rotate-y","transform-rotate-z","transform-scale-x","transform-scale-y","transform-scale-z"])}b.push(e)}return b}}}}),c("StyleManager/model/Sector",["backbone","./Properties","./PropertyFactory"],function(a,b,c){return a.Model.extend({defaults:{id:"",name:"",open:!0,buildProps:"",extendBuilded:1,properties:[]},initialize:function(a){var c=a||{},d=[],e=this.buildProperties(c.buildProps);d=e?this.extendProperties(e):this.get("properties"),this.set("properties",new b(d))},extendProperties:function(a){for(var b=a.length,c=this.get("properties"),d=this.get("extendBuilded"),e=0,f=c.length;f>e;e++){for(var g=c[e],h=0,i=0;b>i;i++){var j=a[i];g.property!=j.property||(a[i]=d?_.extend(j,g):g,h=1)}h||a.push(g)}return a},buildProperties:function(a){var b,d=a||[];return d.length?(this.propFactory||(this.propFactory=new c),b=this.propFactory.build(d)):void 0}})}),c("StyleManager/model/Sectors",["backbone","./Sector"],function(a,b){return a.Collection.extend({model:b})}),c("text!StyleManager/templates/propertyLabel.html",[],function(){return'
\n
\n <%= label %>\n
\n
'}),c("text!StyleManager/templates/propertyInput.html",[],function(){return'
\n input-holder\'>\n
\n
'}),c("StyleManager/view/PropertyView",["backbone","text!./../templates/propertyLabel.html","text!./../templates/propertyInput.html"],function(a,b,c){return a.View.extend({template:_.template(c),templateLabel:_.template(b),events:{change:"valueUpdated"},initialize:function(a){this.config=a.config||{},this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.target=a.target||{},this.propTarget=a.propTarget||{},this.onChange=a.onChange||{},this.onInputRender=a.onInputRender||{},this.customValue=a.customValue||{},this.defaultValue=this.model.get("defaults"),this.property=this.model.get("property"),this.input=this.$input=null,this.className=this.pfx+"property",this.inputHolderId="#"+this.pfx+"input-holder",this.model.get("value")||this.model.set("value",this.model.get("defaults")),this.listenTo(this.propTarget,"update",this.targetUpdated),this.listenTo(this.model,"change:value",this.valueChanged),this.listenTo(this.model,"targetUpdated",this.targetUpdated)},getTarget:function(){return this.selectedComponent?this.selectedComponent:this.propTarget?this.propTarget.model:null},valueUpdated:function(){this.$input&&this.model.set("value",this.getInputValue())},targetUpdated:function(){this.selectedComponent=this.propTarget.model,this.helperComponent=this.propTarget.helper,this.getTarget()&&(this.sameValue()||this.renderInputRequest())},sameValue:function(){return this.getComponentValue()==this.model.get("value")+this.model.get("unit")},getComponentValue:function(){var a=this.getTarget();if(a){var b=a.get("style")[this.property];if(b?this.componentValue=b:this.componentValue=this.defaultValue+(this.unit||""),this.model.get("functionName")){var c=this.fetchFromFunction(this.componentValue);c&&(this.componentValue=c)}if(this.customValue&&"function"==typeof this.customValue){var d=this.model.collection.indexOf(this.model),e=this.customValue(this,d);e&&(this.componentValue=e)}return this.componentValue}},fetchFromFunction:function(a){return a.substring(a.indexOf("(")+1,a.lastIndexOf(")"))},getValueForTarget:function(){return this.model.getValue()},getInputValue:function(){return this.$input?this.$input.val():""},valueChanged:function(a,b,c){var d=this.getValueForTarget();if(this.$input&&this.setValue(d),this.getTarget()&&this.isTargetStylable()){value=this.getValueForTarget();var e=this.model.get("functionName");e&&(value=e+"("+value+")");var f=this.getTarget(),g=this.onChange;g&&"function"==typeof g?g(f,this,c):this.updateTargetStyle(value,null,c)}},updateTargetStyle:function(a,b,c){var d=b||this.property,e=a||"",f=c?c.avoidStore:0,g=this.getTarget(),h=_.clone(g.get("style"));e?h[d]=e:delete h[d],g.set("style",h,{avoidStore:f}),this.helperComponent&&this.helperComponent.set("style",h,{avoidStore:f})},isTargetStylable:function(){var a=this.getTarget().get("stylable");return a instanceof Array&&(a=_.indexOf(a,this.property)>=0),a},setValue:function(a,b){var c=0===b?0:1,d=this.model.get("defaults"),e=this.model.get("value")||d;(a||c)&&(e=a),this.$input&&this.$input.val(e),this.model.set({value:e},{silent:!0})},renderLabel:function(){this.$el.html(this.templateLabel({pfx:this.pfx,ppfx:this.ppfx,icon:this.model.get("icon"),info:this.model.get("info"),label:this.model.get("name")}))},renderField:function(){this.renderTemplate(),this.renderInput(),delete this.componentValue},renderTemplate:function(){this.$el.append(this.template({pfx:this.pfx,ppfx:this.ppfx,icon:this.model.get("icon"),info:this.model.get("info"),label:this.model.get("name")}))},renderInput:function(){this.$input||(this.$input=$("",{placeholder:this.model.get("defaults"),type:"text"}),this.$el.find(this.inputHolderId).html(this.$input)),this.setValue(this.componentValue,0)},renderInputRequest:function(){this.renderInput()},cleanValue:function(){this.setValue("")},render:function(){return this.renderLabel(),this.renderField(),this.$el.attr("class",this.className),this}})}),c("text!StyleManager/templates/propertyInteger.html",[],function(){return'
\n input-holder\'>\n units-holder\'>\n
\n
\n
\n
\n
'}),c("StyleManager/view/PropertyIntegerView",["backbone","./PropertyView","text!./../templates/propertyInteger.html"],function(a,b,c){return b.extend({template:_.template(c),initialize:function(a){b.prototype.initialize.apply(this,arguments),_.bindAll(this,"moveIncrement","upIncrement"),this.min=this.model.get("min")||0===this.model.get("min")?this.model.get("min"):null,this.max=this.model.get("max")||0===this.model.get("max")?this.model.get("max"):null,this.units=this.model.get("units"),this.unit=this.model.get("unit")?this.model.get("unit"):this.units.length?this.units[0]:"",this.events["click ."+this.pfx+"u-arrow"]="upArrowClick",this.events["click ."+this.pfx+"d-arrow"]="downArrowClick",this.events["mousedown ."+this.pfx+"int-arrows"]="downIncrement",this.listenTo(this.model,"change:unit",this.valueChanged),this.delegateEvents()},valueUpdated:function(){this.$input&&this.$unit&&this.model.set({value:this.validateValue(this.$input.val()),unit:this.$unit.val()})},validateValue:function(a){var b=a;return null!==this.max&&(b=b>this.max?this.max:b),null!==this.min&&(b=bthis.max?this.max:b),this.model.set("value",b)},downArrowClick:function(a){var b=this.model.get("value");b=isNaN(b)?0:parseInt(b,10)-1,null!==this.min&&(b=b",{placeholder:"auto",type:"text"}),this.$el.find("#"+a+"input-holder").html(this.$input)),this.$unit||this.units&&this.units.length&&(this.unitS='",this.$unit=$(this.unitS),this.$el.find("#"+a+"units-holder").html(this.$unit)),this.setValue(this.componentValue)},setValue:function(a){var b=this.unit,c=this.model.get("value")||this.defaultValue;if(a){a+="",c=parseFloat(a.replace(",",".")),c=isNaN(c)?this.defaultValue:c;var d=a.replace(c,"");_.indexOf(this.units,d)>-1&&(b=d)}this.$input&&this.$input.val(c),this.$unit&&this.$unit.val(b),this.model.set({value:c,unit:b},{silent:!0})}})}),c("text!StyleManager/templates/propertyRadio.html",[],function(){return'
\n input-holder\'>\n
\n
'}),c("StyleManager/view/PropertyRadioView",["backbone","./PropertyView","text!./../templates/propertyRadio.html"],function(a,b,c){return b.extend({template:_.template(c),initialize:function(a){b.prototype.initialize.apply(this,arguments),this.list=this.model.get("list")||[],this.className=this.className+" "+this.pfx+"list"},renderInput:function(){var a=this.pfx;this.$input||this.list&&this.list.length&&(this.input="",_.each(this.list,function(b){var c=b.className?b.className+" "+a+"icon":"",d=this.property+"-"+b.value,e=b.name?b.name:b.value;titleAttr=b.title?'title="'+b.title+'"':"",this.input+='
"},this),this.$inputEl=$(this.input),this.$el.find("#"+a+"input-holder").html(this.$inputEl),this.$input=this.$inputEl.find('input[name="'+this.property+'"]')),this.setValue(this.componentValue)},getInputValue:function(){return this.$input?this.$el.find("input:checked").val():""},setValue:function(a){var b=this.model.get("value")||this.defaultValue;a&&(b=a),this.$input&&this.$input.filter('[value="'+b+'"]').prop("checked",!0),this.model.set({value:b},{silent:!0})}})}),c("text!StyleManager/templates/propertySelect.html",[],function(){return'
\n input-holder\'>\n
\n
\n
'}),c("StyleManager/view/PropertySelectView",["backbone","./PropertyView","text!./../templates/propertySelect.html"],function(a,b,c){return b.extend({template:_.template(c),initialize:function(a){b.prototype.initialize.apply(this,arguments),this.list=this.model.get("list")||[]},renderInput:function(){var a=this.pfx;this.$input||(this.input="",this.$input=$(this.input),this.$el.find("#"+a+"input-holder").html(this.$input)),this.setValue(this.componentValue,0)}})}),function(a){"use strict";"function"==typeof c&&c.amd?c("Spectrum",["jquery"],a):"object"==typeof exports&&"object"==typeof module?module.exports=a(b("jquery")):a(jQuery)}(function(a,b){"use strict";function c(b,c,d,e){for(var f=[],g=0;g')}else{var m="sp-clear-display";f.push(a("
").append(a('').attr("title",e.noColorSelectedText)).html())}}return"
"+f.join("")+"
"}function d(){for(var a=0;aMath.abs(b-e);ta=f?"x":"y"}}else ta=null;var g=!ta||"x"===ta,h=!ta||"y"===ta;g&&(ka=parseFloat(a/ba)),h&&(la=parseFloat((ca-b)/ca)),Xa=!1,U.showAlpha||(ma=1),K()},y,z),Ta?(H(Ta),L(),Va=U.preferredFormat||tinycolor(Ta).format,u(Ta)):L(),V&&C();var d=p?"mousedown.spectrum":"click.spectrum touchstart.spectrum";Ha.delegate(".sp-thumb-el",d,b),Ia.delegate(".sp-thumb-el:nth-child(1)",d,{ignore:!0},b)}function t(){if(X&&window.localStorage){try{var b=window.localStorage[X].split(",#");b.length>1&&(delete window.localStorage[X],a.each(b,function(a,b){u(b)}))}catch(c){}try{qa=window.localStorage[X].split(";")}catch(c){}}}function u(b){if(W){var c=tinycolor(b).toRgbString();if(!pa[c]&&-1===a.inArray(c,qa))for(qa.push(c);qa.length>ra;)qa.shift();if(X&&window.localStorage)try{window.localStorage[X]=qa.join(";")}catch(d){}}}function v(){var a=[];if(U.showPalette)for(var b=0;b=ca||0>=ba||0>=ea)&&O(),aa=!0,xa.addClass(sa),ta=null,va.trigger("dragstart.spectrum",[I()])}function z(){aa=!1,xa.removeClass(sa),va.trigger("dragstop.spectrum",[I()])}function A(){var a=Ga.val();if(null!==a&&""!==a||!Ya){var b=tinycolor(a);b.isValid()?(H(b),N(!0)):Ga.addClass("sp-validation-error")}else H(null),N(!0)}function B(){_?F():C()}function C(){var b=a.Event("beforeShow.spectrum");return _?void O():(va.trigger(b,[I()]),void(Z.beforeShow(I())===!1||b.isDefaultPrevented()||(d(),_=!0,a(ua).bind("keydown.spectrum",D),a(ua).bind("click.spectrum",E),a(window).bind("resize.spectrum",$),Qa.addClass("sp-active"),xa.removeClass("sp-hidden"),O(),L(),Ua=I(),x(),Z.show(Ua),va.trigger("show.spectrum",[Ua]))))}function D(a){27===a.keyCode&&F()}function E(a){2!=a.button&&(aa||(Wa?N(!0):G(),F()))}function F(){_&&!V&&(_=!1,a(ua).unbind("keydown.spectrum",D),a(ua).unbind("click.spectrum",E),a(window).unbind("resize.spectrum",$),Qa.removeClass("sp-active"),xa.addClass("sp-hidden"),Z.hide(I()),va.trigger("hide.spectrum",[I()]))}function G(){H(Ua,!0)}function H(a,b){if(tinycolor.equals(a,I()))return void L();var c,d;!a&&Ya?Xa=!0:(Xa=!1,c=tinycolor(a),d=c.toHsv(),ja=d.h%360/360,ka=d.s,la=d.v,ma=d.a),L(),c&&c.isValid()&&!b&&(Va=U.preferredFormat||c.getFormat())}function I(a){return a=a||{},Ya&&Xa?null:tinycolor.fromRatio({h:ja,s:ka,v:la,a:Math.round(100*ma)/100},{format:a.format||Va})}function J(){return!Ga.hasClass("sp-validation-error")}function K(){L(),Z.move(I()),va.trigger("move.spectrum",[I()])}function L(){Ga.removeClass("sp-validation-error"),M();var a=tinycolor.fromRatio({h:ja,s:1,v:1});za.css("background-color",a.toHexString());var b=Va;1>ma&&(0!==ma||"name"!==b)&&("hex"===b||"hex3"===b||"hex6"===b||"name"===b)&&(b="rgb");var c=I({format:b}),d="";if(Sa.removeClass("sp-clear-display"),Sa.css("background-color","transparent"),!c&&Ya)Sa.addClass("sp-clear-display");else{var e=c.toHexString(),f=c.toRgbString();if(q||1===c.alpha?Sa.css("background-color",f):(Sa.css("background-color","transparent"),Sa.css("filter",c.toFilter())),U.showAlpha){var g=c.toRgb();g.a=0;var h=tinycolor(g).toRgbString(),i="linear-gradient(left, "+h+", "+e+")";p?Da.css("filter",tinycolor(h).toFilter({gradientType:1},e)):(Da.css("background","-webkit-"+i),Da.css("background","-moz-"+i),Da.css("background","-ms-"+i),Da.css("background","linear-gradient(to right, "+h+", "+e+")"))}d=c.toString(b)}U.showInput&&Ga.val(d),U.showPalette&&w(),x()}function M(){var a=ka,b=la;if(Ya&&Xa)Fa.hide(),Ca.hide(),Aa.hide();else{Fa.show(),Ca.show(),Aa.show();var c=a*ba,d=ca-b*ca;c=Math.max(-da,Math.min(ba-da,c-da)),d=Math.max(-da,Math.min(ca-da,d-da)),Aa.css({top:d+"px",left:c+"px"});var e=ma*ga;Fa.css({left:e-ha/2+"px"});var f=ja*ea;Ca.css({top:f-ia+"px"})}}function N(a){var b=I(),c="",d=!tinycolor.equals(b,Ua);b&&(c=b.toString(Va),u(b)),Na&&va.val(c),a&&d&&(Z.change(b),va.trigger("change",[b]))}function O(){_&&(ba=za.width(),ca=za.height(),da=Aa.height(),fa=Ba.width(),ea=Ba.height(),ia=Ca.height(),ga=Ea.width(),ha=Fa.width(),V||(xa.css("position","absolute"),U.offset?xa.offset(U.offset):xa.offset(g(xa,Ra))),M(),U.showPalette&&w(),va.trigger("reflow.spectrum"))}function P(){va.show(),Ra.unbind("click.spectrum touchstart.spectrum"),xa.remove(),Qa.remove(),o[Za.id]=null}function Q(c,d){return c===b?a.extend({},U):d===b?U[c]:(U[c]=d,"preferredFormat"===c&&(Va=U.preferredFormat),void j())}function R(){wa=!1,va.attr("disabled",!1),Ra.removeClass("sp-disabled")}function S(){F(),wa=!0,va.attr("disabled",!0),Ra.addClass("sp-disabled")}function T(a){U.offset=a,O()}var U=e(h,f),V=U.flat,W=U.showSelectionPalette,X=U.localStorageKey,Y=U.theme,Z=U.callbacks,$=l(O,10),_=!1,aa=!1,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=1,na=[],oa=[],pa={},qa=U.selectionPalette.slice(0),ra=U.maxSelectionSize,sa="sp-dragging",ta=null,ua=f.ownerDocument,va=(ua.body,a(f)),wa=!1,xa=a(s,ua).addClass(Y),ya=xa.find(".sp-picker-container"),za=xa.find(".sp-color"),Aa=xa.find(".sp-dragger"),Ba=xa.find(".sp-hue"),Ca=xa.find(".sp-slider"),Da=xa.find(".sp-alpha-inner"),Ea=xa.find(".sp-alpha"),Fa=xa.find(".sp-alpha-handle"),Ga=xa.find(".sp-input"),Ha=xa.find(".sp-palette"),Ia=xa.find(".sp-initial"),Ja=xa.find(".sp-cancel"),Ka=xa.find(".sp-clear"),La=xa.find(".sp-choose"),Ma=xa.find(".sp-palette-toggle"),Na=va.is("input"),Oa=Na&&"color"===va.attr("type")&&m(),Pa=Na&&!V,Qa=Pa?a(r).addClass(Y).addClass(U.className).addClass(U.replacerClassName):a([]),Ra=Pa?Qa:va,Sa=Qa.find(".sp-preview-inner"),Ta=U.color||Na&&va.val(),Ua=!1,Va=U.preferredFormat,Wa=!U.showButtons||U.clickoutFiresChange,Xa=!Ta,Ya=U.allowEmpty&&!Oa;n();var Za={show:C,hide:F,toggle:B,reflow:O,option:Q,enable:R,disable:S,offset:T,set:function(a){H(a),N()},get:I,destroy:P,container:xa};return Za.id=o.push(Za)-1,Za}function g(b,c){var d=0,e=b.outerWidth(),f=b.outerHeight(),g=c.outerHeight(),h=b[0].ownerDocument,i=h.documentElement,j=i.clientWidth+a(h).scrollLeft(),k=i.clientHeight+a(h).scrollTop(),l=c.offset();return l.top+=g,l.left-=Math.min(l.left,l.left+e>j&&j>e?Math.abs(l.left+e-j):0),l.top-=Math.min(l.top,l.top+f>k&&k>f?Math.abs(f+g-d):d),l}function h(){}function i(a){a.stopPropagation()}function j(a,b){var c=Array.prototype.slice,d=c.call(arguments,2);return function(){return a.apply(b,d.concat(c.call(arguments)))}}function k(b,c,d,e){function f(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.returnValue=!1}function g(a){if(k){if(p&&j.documentMode<9&&!a.button)return i();var d=a.originalEvent&&a.originalEvent.touches&&a.originalEvent.touches[0],e=d&&d.pageX||a.pageX,g=d&&d.pageY||a.pageY,h=Math.max(0,Math.min(e-l.left,n)),q=Math.max(0,Math.min(g-l.top,m));o&&f(a),c.apply(b,[h,q,a])}}function h(c){var e=c.which?3==c.which:2==c.button;e||k||d.apply(b,arguments)!==!1&&(k=!0,m=a(b).height(),n=a(b).width(),l=a(b).offset(),a(j).bind(q),a(j.body).addClass("sp-dragging"),g(c),f(c))}function i(){k&&(a(j).unbind(q),a(j.body).removeClass("sp-dragging"),setTimeout(function(){e.apply(b,arguments)},0)),k=!1}c=c||function(){},d=d||function(){},e=e||function(){};var j=document,k=!1,l={},m=0,n=0,o="ontouchstart"in window,q={};q.selectstart=f,q.dragstart=f,q["touchmove mousemove"]=g,q["touchend mouseup"]=i,a(b).bind("touchstart mousedown",h)}function l(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,a.apply(e,f)};c&&clearTimeout(d),(c||!d)&&(d=setTimeout(g,b))}}function m(){return a.fn.spectrum.inputTypeColorSupport()}var n={beforeShow:h,move:h,change:h,show:h,hide:h,color:!1,flat:!1,showInput:!1,allowEmpty:!1,showButtons:!0,clickoutFiresChange:!0,showInitial:!1,showPalette:!1,showPaletteOnly:!1,hideAfterPaletteSelect:!1,togglePaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",togglePaletteMoreText:"more",togglePaletteLessText:"less",clearText:"Clear Color Selection",noColorSelectedText:"No Color Selected",preferredFormat:!1,className:"",containerClassName:"",replacerClassName:"",showAlpha:!1,theme:"sp-light",palette:[["#ffffff","#000000","#ff0000","#ff8000","#ffff00","#008000","#0000ff","#4b0082","#9400d3"]],selectionPalette:[],disabled:!1,offset:null},o=[],p=!!/msie/i.exec(window.navigator.userAgent),q=function(){function a(a,b){return!!~(""+a).indexOf(b)}var b=document.createElement("div"),c=b.style;return c.cssText="background-color:rgba(0,0,0,.5)",a(c.backgroundColor,"rgba")||a(c.backgroundColor,"hsla")}(),r=["
","
","
","
"].join(""),s=function(){var a="";if(p)for(var b=1;6>=b;b++)a+="
";return["
","
","
","
","","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
",a,"
","
","
","
","
","","
","
","
","","","
","
","
"].join("")}(),t="spectrum.id";a.fn.spectrum=function(b,c){if("string"==typeof b){var d=this,e=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=o[a(this).data(t)];if(c){var f=c[b];if(!f)throw new Error("Spectrum: no such method: '"+b+"'");"get"==b?d=c.get():"container"==b?d=c.container:"option"==b?d=c.option.apply(c,e):"destroy"==b?(c.destroy(),a(this).removeData(t)):f.apply(c,e)}}),d}return this.spectrum("destroy").each(function(){var c=a.extend({},b,a(this).data()),d=f(this,c);a(this).data(t,d.id)})},a.fn.spectrum.load=!0,a.fn.spectrum.loadOpts={},a.fn.spectrum.draggable=k,a.fn.spectrum.defaults=n,a.fn.spectrum.inputTypeColorSupport=function u(){if("undefined"==typeof u._cachedResult){var b=a("")[0];u._cachedResult="color"===b.type&&""!==b.value}return u._cachedResult},a.spectrum={},a.spectrum.localization={},a.spectrum.palettes={},a.fn.spectrum.processNativeColorInputs=function(){var b=a("input[type=color]");b.length&&!m()&&b.spectrum({preferredFormat:"hex6"})},function(){function a(a){var c={r:0,g:0,b:0},e=1,g=!1,h=!1;return"string"==typeof a&&(a=G(a)),"object"==typeof a&&(a.hasOwnProperty("r")&&a.hasOwnProperty("g")&&a.hasOwnProperty("b")?(c=b(a.r,a.g,a.b),g=!0,h="%"===String(a.r).substr(-1)?"prgb":"rgb"):a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("v")?(a.s=D(a.s),a.v=D(a.v),c=f(a.h,a.s,a.v),g=!0,h="hsv"):a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("l")&&(a.s=D(a.s),a.l=D(a.l),c=d(a.h,a.s,a.l),g=!0,h="hsl"),a.hasOwnProperty("a")&&(e=a.a)),e=w(e),{ok:g,format:a.format||h,r:M(255,N(c.r,0)),g:M(255,N(c.g,0)),b:M(255,N(c.b,0)),a:e}}function b(a,b,c){return{r:255*x(a,255),g:255*x(b,255),b:255*x(c,255)}}function c(a,b,c){a=x(a,255), b=x(b,255),c=x(c,255);var d,e,f=N(a,b,c),g=M(a,b,c),h=(f+g)/2;if(f==g)d=e=0;else{var i=f-g;switch(e=h>.5?i/(2-f-g):i/(f+g),f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,l:h}}function d(a,b,c){function d(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a}var e,f,g;if(a=x(a,360),b=x(b,100),c=x(c,100),0===b)e=f=g=c;else{var h=.5>c?c*(1+b):c+b-c*b,i=2*c-h;e=d(i,h,a+1/3),f=d(i,h,a),g=d(i,h,a-1/3)}return{r:255*e,g:255*f,b:255*g}}function e(a,b,c){a=x(a,255),b=x(b,255),c=x(c,255);var d,e,f=N(a,b,c),g=M(a,b,c),h=f,i=f-g;if(e=0===f?0:i/f,f==g)d=0;else{switch(f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,v:h}}function f(a,b,c){a=6*x(a,360),b=x(b,100),c=x(c,100);var d=K.floor(a),e=a-d,f=c*(1-b),g=c*(1-e*b),h=c*(1-(1-e)*b),i=d%6,j=[c,g,f,f,h,c][i],k=[h,c,c,g,f,f][i],l=[f,f,h,c,c,g][i];return{r:255*j,g:255*k,b:255*l}}function g(a,b,c,d){var e=[C(L(a).toString(16)),C(L(b).toString(16)),C(L(c).toString(16))];return d&&e[0].charAt(0)==e[0].charAt(1)&&e[1].charAt(0)==e[1].charAt(1)&&e[2].charAt(0)==e[2].charAt(1)?e[0].charAt(0)+e[1].charAt(0)+e[2].charAt(0):e.join("")}function h(a,b,c,d){var e=[C(E(d)),C(L(a).toString(16)),C(L(b).toString(16)),C(L(c).toString(16))];return e.join("")}function i(a,b){b=0===b?0:b||10;var c=P(a).toHsl();return c.s-=b/100,c.s=y(c.s),P(c)}function j(a,b){b=0===b?0:b||10;var c=P(a).toHsl();return c.s+=b/100,c.s=y(c.s),P(c)}function k(a){return P(a).desaturate(100)}function l(a,b){b=0===b?0:b||10;var c=P(a).toHsl();return c.l+=b/100,c.l=y(c.l),P(c)}function m(a,b){b=0===b?0:b||10;var c=P(a).toRgb();return c.r=N(0,M(255,c.r-L(255*-(b/100)))),c.g=N(0,M(255,c.g-L(255*-(b/100)))),c.b=N(0,M(255,c.b-L(255*-(b/100)))),P(c)}function n(a,b){b=0===b?0:b||10;var c=P(a).toHsl();return c.l-=b/100,c.l=y(c.l),P(c)}function o(a,b){var c=P(a).toHsl(),d=(L(c.h)+b)%360;return c.h=0>d?360+d:d,P(c)}function p(a){var b=P(a).toHsl();return b.h=(b.h+180)%360,P(b)}function q(a){var b=P(a).toHsl(),c=b.h;return[P(a),P({h:(c+120)%360,s:b.s,l:b.l}),P({h:(c+240)%360,s:b.s,l:b.l})]}function r(a){var b=P(a).toHsl(),c=b.h;return[P(a),P({h:(c+90)%360,s:b.s,l:b.l}),P({h:(c+180)%360,s:b.s,l:b.l}),P({h:(c+270)%360,s:b.s,l:b.l})]}function s(a){var b=P(a).toHsl(),c=b.h;return[P(a),P({h:(c+72)%360,s:b.s,l:b.l}),P({h:(c+216)%360,s:b.s,l:b.l})]}function t(a,b,c){b=b||6,c=c||30;var d=P(a).toHsl(),e=360/c,f=[P(a)];for(d.h=(d.h-(e*b>>1)+720)%360;--b;)d.h=(d.h+e)%360,f.push(P(d));return f}function u(a,b){b=b||6;for(var c=P(a).toHsv(),d=c.h,e=c.s,f=c.v,g=[],h=1/b;b--;)g.push(P({h:d,s:e,v:f})),f=(f+h)%1;return g}function v(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b}function w(a){return a=parseFloat(a),(isNaN(a)||0>a||a>1)&&(a=1),a}function x(a,b){A(a)&&(a="100%");var c=B(a);return a=M(b,N(0,parseFloat(a))),c&&(a=parseInt(a*b,10)/100),K.abs(a-b)<1e-6?1:a%b/parseFloat(b)}function y(a){return M(1,N(0,a))}function z(a){return parseInt(a,16)}function A(a){return"string"==typeof a&&-1!=a.indexOf(".")&&1===parseFloat(a)}function B(a){return"string"==typeof a&&-1!=a.indexOf("%")}function C(a){return 1==a.length?"0"+a:""+a}function D(a){return 1>=a&&(a=100*a+"%"),a}function E(a){return Math.round(255*parseFloat(a)).toString(16)}function F(a){return z(a)/255}function G(a){a=a.replace(H,"").replace(I,"").toLowerCase();var b=!1;if(Q[a])a=Q[a],b=!0;else if("transparent"==a)return{r:0,g:0,b:0,a:0,format:"name"};var c;return(c=S.rgb.exec(a))?{r:c[1],g:c[2],b:c[3]}:(c=S.rgba.exec(a))?{r:c[1],g:c[2],b:c[3],a:c[4]}:(c=S.hsl.exec(a))?{h:c[1],s:c[2],l:c[3]}:(c=S.hsla.exec(a))?{h:c[1],s:c[2],l:c[3],a:c[4]}:(c=S.hsv.exec(a))?{h:c[1],s:c[2],v:c[3]}:(c=S.hsva.exec(a))?{h:c[1],s:c[2],v:c[3],a:c[4]}:(c=S.hex8.exec(a))?{a:F(c[1]),r:z(c[2]),g:z(c[3]),b:z(c[4]),format:b?"name":"hex8"}:(c=S.hex6.exec(a))?{r:z(c[1]),g:z(c[2]),b:z(c[3]),format:b?"name":"hex"}:(c=S.hex3.exec(a))?{r:z(c[1]+""+c[1]),g:z(c[2]+""+c[2]),b:z(c[3]+""+c[3]),format:b?"name":"hex"}:!1}var H=/^[\s,#]+/,I=/\s+$/,J=0,K=Math,L=K.round,M=K.min,N=K.max,O=K.random,P=function(b,c){if(b=b?b:"",c=c||{},b instanceof P)return b;if(!(this instanceof P))return new P(b,c);var d=a(b);this._originalInput=b,this._r=d.r,this._g=d.g,this._b=d.b,this._a=d.a,this._roundA=L(100*this._a)/100,this._format=c.format||d.format,this._gradientType=c.gradientType,this._r<1&&(this._r=L(this._r)),this._g<1&&(this._g=L(this._g)),this._b<1&&(this._b=L(this._b)),this._ok=d.ok,this._tc_id=J++};P.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var a=this.toRgb();return(299*a.r+587*a.g+114*a.b)/1e3},setAlpha:function(a){return this._a=w(a),this._roundA=L(100*this._a)/100,this},toHsv:function(){var a=e(this._r,this._g,this._b);return{h:360*a.h,s:a.s,v:a.v,a:this._a}},toHsvString:function(){var a=e(this._r,this._g,this._b),b=L(360*a.h),c=L(100*a.s),d=L(100*a.v);return 1==this._a?"hsv("+b+", "+c+"%, "+d+"%)":"hsva("+b+", "+c+"%, "+d+"%, "+this._roundA+")"},toHsl:function(){var a=c(this._r,this._g,this._b);return{h:360*a.h,s:a.s,l:a.l,a:this._a}},toHslString:function(){var a=c(this._r,this._g,this._b),b=L(360*a.h),d=L(100*a.s),e=L(100*a.l);return 1==this._a?"hsl("+b+", "+d+"%, "+e+"%)":"hsla("+b+", "+d+"%, "+e+"%, "+this._roundA+")"},toHex:function(a){return g(this._r,this._g,this._b,a)},toHexString:function(a){return"#"+this.toHex(a)},toHex8:function(){return h(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:L(this._r),g:L(this._g),b:L(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+L(this._r)+", "+L(this._g)+", "+L(this._b)+")":"rgba("+L(this._r)+", "+L(this._g)+", "+L(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:L(100*x(this._r,255))+"%",g:L(100*x(this._g,255))+"%",b:L(100*x(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+L(100*x(this._r,255))+"%, "+L(100*x(this._g,255))+"%, "+L(100*x(this._b,255))+"%)":"rgba("+L(100*x(this._r,255))+"%, "+L(100*x(this._g,255))+"%, "+L(100*x(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:R[g(this._r,this._g,this._b,!0)]||!1},toFilter:function(a){var b="#"+h(this._r,this._g,this._b,this._a),c=b,d=this._gradientType?"GradientType = 1, ":"";if(a){var e=P(a);c=e.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+d+"startColorstr="+b+",endColorstr="+c+")"},toString:function(a){var b=!!a;a=a||this._format;var c=!1,d=this._a<1&&this._a>=0,e=!b&&d&&("hex"===a||"hex6"===a||"hex3"===a||"name"===a);return e?"name"===a&&0===this._a?this.toName():this.toRgbString():("rgb"===a&&(c=this.toRgbString()),"prgb"===a&&(c=this.toPercentageRgbString()),("hex"===a||"hex6"===a)&&(c=this.toHexString()),"hex3"===a&&(c=this.toHexString(!0)),"hex8"===a&&(c=this.toHex8String()),"name"===a&&(c=this.toName()),"hsl"===a&&(c=this.toHslString()),"hsv"===a&&(c=this.toHsvString()),c||this.toHexString())},_applyModification:function(a,b){var c=a.apply(null,[this].concat([].slice.call(b)));return this._r=c._r,this._g=c._g,this._b=c._b,this.setAlpha(c._a),this},lighten:function(){return this._applyModification(l,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(n,arguments)},desaturate:function(){return this._applyModification(i,arguments)},saturate:function(){return this._applyModification(j,arguments)},greyscale:function(){return this._applyModification(k,arguments)},spin:function(){return this._applyModification(o,arguments)},_applyCombination:function(a,b){return a.apply(null,[this].concat([].slice.call(b)))},analogous:function(){return this._applyCombination(t,arguments)},complement:function(){return this._applyCombination(p,arguments)},monochromatic:function(){return this._applyCombination(u,arguments)},splitcomplement:function(){return this._applyCombination(s,arguments)},triad:function(){return this._applyCombination(q,arguments)},tetrad:function(){return this._applyCombination(r,arguments)}},P.fromRatio=function(a,b){if("object"==typeof a){var c={};for(var d in a)a.hasOwnProperty(d)&&("a"===d?c[d]=a[d]:c[d]=D(a[d]));a=c}return P(a,b)},P.equals=function(a,b){return a&&b?P(a).toRgbString()==P(b).toRgbString():!1},P.random=function(){return P.fromRatio({r:O(),g:O(),b:O()})},P.mix=function(a,b,c){c=0===c?0:c||50;var d,e=P(a).toRgb(),f=P(b).toRgb(),g=c/100,h=2*g-1,i=f.a-e.a;d=h*i==-1?h:(h+i)/(1+h*i),d=(d+1)/2;var j=1-d,k={r:f.r*d+e.r*j,g:f.g*d+e.g*j,b:f.b*d+e.b*j,a:f.a*g+e.a*(1-g)};return P(k)},P.readability=function(a,b){var c=P(a),d=P(b),e=c.toRgb(),f=d.toRgb(),g=c.getBrightness(),h=d.getBrightness(),i=Math.max(e.r,f.r)-Math.min(e.r,f.r)+Math.max(e.g,f.g)-Math.min(e.g,f.g)+Math.max(e.b,f.b)-Math.min(e.b,f.b);return{brightness:Math.abs(g-h),color:i}},P.isReadable=function(a,b){var c=P.readability(a,b);return c.brightness>125&&c.color>500},P.mostReadable=function(a,b){for(var c=null,d=0,e=!1,f=0;f125&&g.color>500,i=3*(g.brightness/125)+g.color/500;(h&&!e||h&&e&&i>d||!h&&!e&&i>d)&&(e=h,d=i,c=P(b[f]))}return c};var Q=P.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},R=P.hexNames=v(Q),S=function(){var a="[-\\+]?\\d+%?",b="[-\\+]?\\d*\\.\\d+%?",c="(?:"+b+")|(?:"+a+")",d="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?",e="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?";return{rgb:new RegExp("rgb"+d),rgba:new RegExp("rgba"+e),hsl:new RegExp("hsl"+d),hsla:new RegExp("hsla"+e),hsv:new RegExp("hsv"+d),hsva:new RegExp("hsva"+e),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();window.tinycolor=P}(),a(function(){a.fn.spectrum.load&&a.fn.spectrum.processNativeColorInputs()})}),c("text!StyleManager/templates/propertyColor.html",[],function(){return'
\n input-holder\'>\n
\n
\n
\n
\n
'}),c("StyleManager/view/PropertyColorView",["backbone","./PropertyView","Spectrum","text!./../templates/propertyColor.html"],function(a,b,c,d){return b.extend({template:_.template(d),renderInput:function(){if(this.$input||(this.$input=$("",{placeholder:this.defaultValue,type:"text"}),this.$el.find("#"+this.pfx+"input-holder").html(this.$input)),!this.$colorPicker){this.$colorPicker=$("
",{"class":this.pfx+"color-picker"}),cpStyle=this.$colorPicker.get(0).style;var a=this,b=this.target.config?this.target.config.el:"";this.$colorPicker.spectrum({appendTo:b||"body",showPalette:!0,maxSelectionSize:8,palette:[],showAlpha:!0,chooseText:"Ok",cancelText:"⨯",move:function(a){var b=1==a.getAlpha()?a.toHexString():a.toRgbString();cpStyle.backgroundColor=b},change:function(b){var c=1==b.getAlpha()?b.toHexString():b.toRgbString();c=c.replace(/ /g,""),cpStyle.backgroundColor=c,a.model.set("value",c)}}),this.$el.find("."+this.pfx+"colorp-c").append(this.$colorPicker)}this.setValue(this.componentValue,0)},setValue:function(a,c){b.prototype.setValue.apply(this,arguments);var d=this.model.get("value")||this.defaultValue;d=a||d,this.$colorPicker&&(d="none"===d?"#fff":d,this.$colorPicker.spectrum("set",d),this.$colorPicker.get(0).style.backgroundColor=d)}})}),c("text!StyleManager/templates/propertyFile.html",[],function(){return'
\n
input-holder\'>\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
'}),c("StyleManager/view/PropertyFileView",["backbone","./PropertyView","text!./../templates/propertyFile.html"],function(a,b,c){return b.extend({template:_.template(c),initialize:function(a){b.prototype.initialize.apply(this,arguments),this.assets=this.target.get("assets"),this.modal=this.target.get("Modal"),this.am=this.target.get("AssetManager"),this.className=this.className+" "+this.pfx+"file",this.events["click #"+this.pfx+"close"]="removeFile",this.events["click #"+this.pfx+"images"]="openAssetManager",this.delegateEvents()},renderInput:function(){this.$input||(this.$input=$("",{placeholder:this.defaultValue,type:"text"})),this.$preview||(this.$preview=this.$el.find("#"+this.pfx+"preview-file")),this.$previewBox||(this.$previewBox=this.$el.find("#"+this.pfx+"preview-box")),this.componentValue&&this.componentValue!=this.defaultValue?this.setPreviewView(1):this.setPreviewView(0),this.setValue(this.componentValue,0)},setPreviewView:function(a){this.$previewBox&&(a?this.$previewBox.addClass(this.pfx+"show"):this.$previewBox.removeClass(this.pfx+"show"))},spreadUrl:function(a){this.setValue('url("'+a+'")'),this.setPreviewView(1)},setPreview:function(a){this.$preview&&this.$preview.css("background-image",a)},setValue:function(a,c){b.prototype.setValue.apply(this,arguments),this.setPreview(a)},renderTemplate:function(){this.$el.append(this.template({upload:"Upload",assets:"Images",pfx:this.pfx}))},cleanValue:function(){this.setPreviewView(0),this.model.set({value:""},{silent:!0})},removeFile:function(){this.model.set("value",this.defaultValue),b.prototype.cleanValue.apply(this,arguments),this.setPreviewView(0)},openAssetManager:function(a){var b=this;this.modal&&this.am&&(this.modal.setTitle("Select image"),this.modal.setContent(this.am.render()),this.am.setTarget(null),this.modal.open(),this.am.onSelect(function(c){b.modal.close(),b.spreadUrl(c.get("src")),b.valueChanged(a)}))}})}),c("text!StyleManager/templates/propertyComposite.html",[],function(){return'
\n input-holder\'>\n
\n
'}),c("StyleManager/view/PropertyCompositeView",["backbone","./PropertyView","text!./../templates/propertyComposite.html","require"],function(a,b,c,d){return b.extend({template:_.template(c),initialize:function(a){b.prototype.initialize.apply(this,arguments),_.bindAll(this,"build"),this.config=a.config||{},this.className=this.className+" "+this.pfx+"composite"},valueUpdated:function(){this.model.get("detached")||b.prototype.valueUpdated.apply(this,arguments)},renderInput:function(){var a=this.model.get("properties");this.model.get("detached");if(a&&a.length){if(this.$input||(this.$input=$("",{value:0,type:"hidden"})),!this.props){var b=d("./../model/Properties");this.props=new b(a),this.model.set("properties",this.props)}if(!this.$props){this.props.each(function(a,b){a&&"composite"==a.get("type")&&(this.props.remove(a),console.warn("Nested composite types not yet allowed."))},this);var c=d("./PropertiesView"),e=new c(this.getPropsConfig());this.$props=e.render().$el,this.$el.find("#"+this.pfx+"input-holder").html(this.$props)}}},getPropsConfig:function(a){var b=this;return result={config:this.config,collection:this.props,target:this.target,propTarget:this.propTarget,onChange:function(a,c,d){var e=b.build();b.model.set("value",e,d)},customValue:function(a,c){return b.valueOnIndex(c,a)}},this.model.get("detached")&&delete result.onChange,result},getDefaultValue:function(){var a="";return this.props.each(function(b,c){a+=b.get("defaults")+b.get("unit")+" "}),a.replace(/ +$/,"")},valueOnIndex:function(a,b){var c=null,d=this.getComponentValue().split(" ");if(d.length&&d[a]&&(c=d[a],b&&b.model&&b.model.get("functionName"))){var e=this.fetchFromFunction(c);e&&(c=e)}return c},build:function(a,b,c){var d="";return this.model.get("properties").each(function(a){var b=a.getValue();func=a.get("functionName"),func&&(b=func+"("+b+")"),d+=b+" "}),d.replace(/ +$/,"")}})}),c("text!StyleManager/templates/propertyStack.html",[],function(){return"
field <%= pfx %>stack\">\n \n \n
\n
"}),c("text!StyleManager/templates/layer.html",[],function(){return'
\n \n
\n
<%= label %>
\n
\n
\n
\n
\n
\n
'}),c("StyleManager/view/LayerView",["backbone","text!./../templates/layer.html"],function(a,b){return a.View.extend({events:{click:"updateIndex"},template:_.template(b),initialize:function(a){this.stackModel=a.stackModel||{},this.config=a.config||{},this.pfx=this.config.stylePrefix||"",this.className=this.pfx+"layer",this.sorter=a.sorter||null,this.listenTo(this.model,"destroy remove",this.remove),this.listenTo(this.model,"change:value",this.valueChanged),this.listenTo(this.model,"change:props",this.showProps),this.events["click #"+this.pfx+"close-layer"]="remove",this.events["mousedown > #"+this.pfx+"move"]="initSorter",this.model.get("preview")||this.$el.addClass(this.pfx+"no-preview"),this.$el.data("model",this.model),this.delegateEvents()},initSorter:function(a){this.sorter&&this.sorter.startSort(this.el)},getProps:function(){return this.stackModel.get?this.stackModel.get("properties"):null},valueChanged:function(){var a=this.model.get("preview");if(a){this.$preview||(this.$preview=this.$el.find("#"+this.pfx+"preview"));"function"==typeof a?a(this.getProps(),this.$preview):this.onPreview(this.getProps(),this.$preview)}},onPreview:function(a,b){var c=this.model.get("value").split(" "),d=3,e="";if(a.each(function(a,b){var f=c[b]||"";if(f&&"integer"==a.get("type")){var g=parseInt(f,10),h=f.replace(g,"");g=isNaN(g)?0:g,g>d&&(g=d),-d>g&&(g=-d),f=g+h}e+=f+" "}),this.stackModel.get){var f=this.stackModel.get("property");f&&(this.$preview.get(0).style[f]=e)}},showProps:function(){this.$props=this.model.get("props"),this.$el.find("#"+this.pfx+"inputs").html(this.$props.show()),this.model.set({props:null},{silent:!0})},remove:function(b){this.$props&&this.$props.detach(),b&&b.stopPropagation&&b.stopPropagation(),a.View.prototype.remove.apply(this,arguments),this.model.collection.contains(this.model)&&this.model.collection.remove(this.model),this.stackModel&&this.stackModel.set&&(this.stackModel.set({stackIndex:null},{silent:!0}),this.stackModel.trigger("updateValue"))},updateIndex:function(a){var b=this.getIndex();this.stackModel.set("stackIndex",b),this.model.collection&&this.model.collection.trigger("deselectAll"),this.$el.addClass(this.pfx+"active")},getIndex:function(){var a=0;return this.model.collection&&(a=this.model.collection.indexOf(this.model)),a},render:function(){return this.$el.html(this.template({label:"Layer "+this.model.get("index"),pfx:this.pfx})),this.$el.attr("class",this.className),this.valueChanged(),this}})}),c("StyleManager/view/LayersView",["backbone","./LayerView"],function(a,b){return a.View.extend({initialize:function(a){this.config=a.config||{},this.stackModel=a.stackModel,this.preview=a.preview,this.pfx=this.config.stylePrefix||"",this.className=this.pfx+"layers",this.listenTo(this.collection,"add",this.addTo),this.listenTo(this.collection,"deselectAll",this.deselectAll),this.listenTo(this.collection,"reset",this.render);var b=this.config.em||"",c=b?b.get("Utils"):"";this.sorter=c?new c.Sorter({container:this.el,containerSel:"."+this.pfx+"layers",itemSel:"."+this.pfx+"layer",pfx:this.config.pStylePrefix}):"",this.$el.data("collection",this.collection)},addTo:function(a){var b=this.collection.indexOf(a);this.addToCollection(a,null,b)},addToCollection:function(a,c,d){var e=c||null,f=b;"undefined"!=typeof this.preview&&a.set("preview",this.preview);var g=new f({model:a,stackModel:this.stackModel,config:this.config,sorter:this.sorter}),h=g.render().el;if(e)e.appendChild(h);else if("undefined"!=typeof d){var i="before";this.$el.children().length==d&&(d--,i="after"),0>d?this.$el.append(h):this.$el.children().eq(d)[i](h)}else this.$el.append(h);return h},deselectAll:function(){this.$el.find("."+this.pfx+"layer").removeClass(this.pfx+"active")},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",this.className),this.sorter&&(this.sorter.plh=null),this}})}),c("StyleManager/view/PropertyStackView",["backbone","./PropertyCompositeView","text!./../templates/propertyStack.html","./../model/Layers","./LayersView"],function(a,b,c,d,e){return b.extend({template:_.template(c),initialize:function(a){b.prototype.initialize.apply(this,arguments),this.model.set("stackIndex",null),this.className=this.pfx+"property "+this.pfx+"stack",this.events["click #"+this.pfx+"add"]="addLayer",this.listenTo(this.model,"change:stackIndex",this.indexChanged),this.listenTo(this.model,"updateValue",this.valueUpdated),this.delegateEvents()},targetUpdated:function(){this.model.get("detached")?this.refreshLayers():b.prototype.targetUpdated.apply(this,arguments)},getLayers:function(){return this.model.get("layers")},indexChanged:function(a){var b=this.getLayers().at(this.model.get("stackIndex"));b.set("props",this.$props),this.model.get("properties").each(function(a){a.trigger("targetUpdated")})},getStackValues:function(){return this.getLayers().pluck("value")},getPropsConfig:function(a){var c=this,d=b.prototype.getPropsConfig.apply(this,arguments);return d.onChange=function(a,b,d){var e=b.model,f=c.build();if(c.model.get("detached")){var g="";e.collection.indexOf(e);c.getLayers().each(function(a){var b=a.get("values")[e.get("property")];b&&(g+=(g?",":"")+b)}),b.updateTargetStyle(g,null,d)}else c.model.set("value",f,d)},d},valueOnIndex:function(a,b){var c=null;if(this.model.get("detached")){var d=b.componentValue.split(",");c=d[this.model.get("stackIndex")],c=c?c.trim():c}else{var e=this.getStackValues(),f=e[this.model.get("stackIndex")];if(!f)return;var g=f.split(" ");g.length&&g[a]&&(c=g[a])}return c},build:function(){var a=this.model.get("stackIndex");if(null!==a){var c=b.prototype.build.apply(this,arguments),d=this.getLayers().at(a);if(d){var e={};return this.model.get("properties").each(function(a){var b=a.getValue(),c=a.get("functionName");c&&(b=c+"("+b+")"),e[a.get("property")]=b}),d.set("values",e),d.set("value",c),this.createValue()}}},addLayer:function(a){if(this.getTarget()){var b=this.getLayers(),c=b.add({name:"test"}),d=b.indexOf(c);return c.set("value",this.getDefaultValue()),this.valueUpdated(),this.model.set("stackIndex",d),c}},valueUpdated:function(){this.model.get("detached")?this.model.get("properties").each(function(a){a.trigger("change:value")}):this.model.set("value",this.createValue())},createValue:function(){return this.getStackValues().join(", ")},renderLayers:function(){return this.$field||(this.$field=this.$el.find("> ."+this.pfx+"field")),this.$layers||(this.$layers=new e({collection:this.getLayers(),stackModel:this.model,preview:this.model.get("preview"),config:this.config})),this.$field.append(this.$layers.render().el),this.$props.hide(),this},renderInput:function(){b.prototype.renderInput.apply(this,arguments),this.refreshLayers()},getLayersFromTarget:function(){var a=[],b=this.getTarget();if(!b)return a;var c=b.get("style");return this.model.get("properties").each(function(b){var d=c[b.get("property")];if(d)for(var e=d.split(","),f=0,g=e.length;g>f;f++){var h=e[f].trim();if(a[f])a[f][b.get("property")]=h;else{var i={};i[b.get("property")]=h,a[f]=i}}}),a},refreshLayers:function(){var a=[],b=[],c="value";if(this.model.get("detached"))c="values",b=this.getLayersFromTarget();else{var d=this.getComponentValue();d&&(d.replace(/\(([\w\s,.]*)\)/g,function(a){var b=a.replace(/,\s*/g,",");d=d.replace(a,b)}),b=d.split(", "))}_.each(b,function(b){var d={};d[c]=b,a.push(d)},this),this.$props.detach();var e=this.getLayers();e.reset(),e.add(a),this.model.get("detached")||this.valueUpdated(),this.model.set({stackIndex:null},{silent:!0})},render:function(){return this.renderLabel(),this.renderField(),this.renderLayers(),this.$el.attr("class",this.className),this}})}),c("StyleManager/view/PropertiesView",["backbone","./PropertyView","./PropertyIntegerView","./PropertyRadioView","./PropertySelectView","./PropertyColorView","./PropertyFileView","./PropertyCompositeView","./PropertyStackView"],function(a,b,c,d,e,f,g,h,i){return a.View.extend({initialize:function(a){this.config=a.config||{},this.pfx=this.config.stylePrefix||"",this.target=a.target||{},this.propTarget=a.propTarget||{},this.onChange=a.onChange||{},this.onInputRender=a.onInputRender||{},this.customValue=a.customValue||{}},render:function(){var a=document.createDocumentFragment();return this.collection.each(function(j){var k=b;switch(j.get("type")){case"integer":k=c;break;case"radio":k=d;break;case"select":k=e;break;case"color":k=f;break;case"file":k=g;break;case"composite":k=h;break;case"stack":k=i}var l=new k({model:j,name:j.get("name"),id:this.pfx+j.get("property"),target:this.target,propTarget:this.propTarget,onChange:this.onChange,onInputRender:this.onInputRender,config:this.config});"composite"!=j.get("type")&&(l.customValue=this.customValue),a.appendChild(l.render().el)},this),this.$el.append(a),this.$el.append($("
",{"class":"clear"})),this.$el.attr("class",this.pfx+"properties"),this}})}),c("text!StyleManager/templates/sector.html",[],function(){return'
\n \n <%= label %>\n
'}),c("StyleManager/view/SectorView",["backbone","./PropertiesView","text!./../templates/sector.html"],function(a,b,c){return a.View.extend({template:_.template(c),events:{},initialize:function(a){this.config=a.config||{},this.pfx=this.config.stylePrefix||"",this.target=a.target||{},this.propTarget=a.propTarget||{},this.open=this.model.get("open"),this.caretR="fa-caret-right",this.caretD="fa-caret-down",this.listenTo(this.model,"change:open",this.updateOpen),this.events["click ."+this.pfx+"title"]="toggle",this.delegateEvents()},updateOpen:function(){this.model.get("open")?this.show():this.hide()},show:function(){this.$el.addClass(this.pfx+"open"),this.$el.find("."+this.pfx+"properties").show(),this.$caret.removeClass(this.caretR).addClass(this.caretD)},hide:function(){this.$el.removeClass(this.pfx+"open"),this.$el.find("."+this.pfx+"properties").hide(),this.$caret.removeClass(this.caretD).addClass(this.caretR)},toggle:function(){var a=this.model.get("open")?0:1;this.model.set("open",a)},render:function(){return this.$el.html(this.template({pfx:this.pfx,label:this.model.get("name")})),this.$caret=this.$el.find("#"+this.pfx+"caret"),this.renderProperties(),this.$el.attr("class",this.pfx+"sector no-select"),this.updateOpen(),this},renderProperties:function(){var a=this.model.get("properties");if(a){var c=new b({collection:a,target:this.target,propTarget:this.propTarget,config:this.config});this.$el.append(c.render().el)}}})}),c("StyleManager/view/SectorsView",["backbone","./SectorView"],function(a,b){return a.View.extend({initialize:function(b){this.config=b.config||{},this.pfx=this.config.stylePrefix||"",this.target=b.target||{},this.propTarget={},_.extend(this.propTarget,a.Events),this.listenTo(this.collection,"add",this.addTo),this.listenTo(this.collection,"reset",this.render),this.listenTo(this.target,"change:selectedComponent targetClassAdded targetClassRemoved targetClassUpdated targetStateUpdated change:device",this.targetUpdated)},addTo:function(a){this.addToCollection(a)},targetUpdated:function(){var a=this.target.get("selectedComponent");if(a){var b=a.get("classes"),c=a.get("state"),d=this.propTarget,e=this.target.getDeviceModel(),f=e?e.get("width"):"";if(d.helper=null,b.length){var g=this.target.get("CssComposer"),h=_.filter(b.models,function(a){return a.get("active")}),i=g.get(h,c,f);if(i?1==b.length&&a.set("style",{}):(i=g.add(h,c,f),i.set("style",a.get("style")),a.set("style",{})),c){var j=this.target.get("SelectorManager"),k=j.add("hc-state"),l=g.get([k]);l?(g.getAll().remove(l),g.getAll().add(l)):l=g.add([k]),l.set("style",i.get("style")),d.helper=l}return d.model=i,void d.trigger("update")}d.model=a,d.trigger("update")}},addToCollection:function(a,c){var d=c||null,e=b,f=new e({model:a,id:this.pfx+a.get("name").replace(" ","_").toLowerCase(),name:a.get("name"),properties:a.get("properties"),target:this.target,propTarget:this.propTarget,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.attr("id",this.pfx+"sectors"),this.$el.append(a),this}})}),c("StyleManager/main",["require","./config/config","./model/Sectors","./view/SectorsView"],function(a){ -return function(){var b,c,d={},e=a("./config/config"),f=a("./model/Sectors"),g=a("./view/SectorsView");return{name:"StyleManager",init:function(a){d=a||{};for(var h in e)h in d||(d[h]=e[h]);var i=d.pStylePrefix;return i&&(d.stylePrefix=i+d.stylePrefix),b=new f(d.sectors),c=new g({collection:b,target:d.em,config:d}),this},addSector:function(a,c){var d=this.getSector(a);return d||(c.id=a,d=b.add(c)),d},getSector:function(a){var c=b.where({id:a});return c.length?c[0]:null},getSectors:function(){return b},addProperty:function(a,b){var c=null,d=this.getSector(a);return d&&(c=d.get("properties").add(b)),c},getProperty:function(a,b){var c=null,d=this.getSector(a);return d&&(c=d.get("properties").where({property:b}),c=1==c.length?c[0]:c),c},getProperties:function(a){var b=null,c=this.getSector(a);return c&&(b=c.get("properties")),b},render:function(){return c.render().el}}}}),c("StyleManager",["StyleManager/main"],function(a){return a}),c("AssetManager/model/Asset",["backbone"],function(a){return a.Model.extend({idAttribute:"src",defaults:{type:"",src:""},getFilename:function(){return this.get("src").split("/").pop()},getExtension:function(){return this.getFilename().split(".").pop()}})}),c("AssetManager/model/AssetImage",["backbone","./Asset"],function(a,b){return b.extend({defaults:_.extend({},b.prototype.defaults,{type:"image",unitDim:"px",height:0,width:0})})}),c("AssetManager/model/Assets",["backbone","./Asset","./AssetImage"],function(a,b,c){return a.Collection.extend({model:c,initialize:function(a,b){this.model=function(a,b){var d;switch(a.type){default:d=new c(a,b)}return d}},addImg:function(a,b){return this.add({type:"image",src:a},b),this},add:function(b,c){var d=[];b=b instanceof Array?b:[b];for(var e=0,f=b.length;f>e;e++){var g=b[e];if("string"==typeof g&&(g={src:g,type:"image"}),g&&g.src){var h=this.where({src:g.src});h.length||d.push(g)}}return 1==d.length&&(d=d[0]),a.Collection.prototype.add.apply(this,[d,c])}})}),c("AssetManager/view/AssetView",["backbone"],function(a){return a.View.extend({initialize:function(a){this.options=a,this.config=a.config||{},this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.className=this.pfx+"asset",this.listenTo(this.model,"destroy remove",this.remove)}})}),c("text!AssetManager/template/assetImage.html",[],function(){return'
\n
\n
\n
\n
\n
<%= name %>
\n
<%= dim %>
\n
\n
\n
'}),c("AssetManager/view/AssetImageView",["./AssetView","text!./../template/assetImage.html"],function(a,b){return a.extend({events:{click:"selected",dblclick:"chosen"},template:_.template(b),initialize:function(b){a.prototype.initialize.apply(this,arguments),this.className+=" "+this.pfx+"asset-image",this.events["click #"+this.pfx+"close"]="removeItem",this.delegateEvents()},selected:function(){this.model.collection.trigger("deselectAll"),this.$el.addClass(this.pfx+"highlight"),this.updateTarget(this.model.get("src"))},chosen:function(){this.updateTarget(this.model.get("src"));var a=this.model.collection.onSelect;a&&"function"==typeof a&&a(this.model)},updateTarget:function(a){var b=this.model.collection.target;if(b&&b.set){var c=_.clone(b.get("attributes"));b.set("attributes",c),b.set("src",a)}},removeItem:function(a){a.stopPropagation(),this.model.collection.remove(this.model)},render:function(){var a=this.model.get("name"),b=this.model.get("width")&&this.model.get("height")?this.model.get("width")+" x "+this.model.get("height"):"";return a=a?a:this.model.get("src").split("/").pop(),a=a&&a.length>30?a.substring(0,30)+"...":a,b=b?b+(this.model.get("unitDim")?this.model.get("unitDim"):" px"):"",this.$el.html(this.template({name:a,src:this.model.get("src"),dim:b,pfx:this.pfx,ppfx:this.ppfx})),this.$el.attr("class",this.className),this}})}),c("text!AssetManager/template/fileUploader.html",[],function(){return'
\n
<%= title %>
\n multiple/>\n
\n
'}),c("AssetManager/view/FileUploader",["backbone","text!./../template/fileUploader.html"],function(a,b){return a.View.extend({template:_.template(b),events:{},initialize:function(a){this.options=a||{},this.config=a.config||{},this.pfx=this.config.stylePrefix||"",this.target=this.collection||{},this.uploadId=this.pfx+"uploadFile",this.disabled=!this.config.upload,this.events["change #"+this.uploadId]="uploadFile",this.delegateEvents()},uploadFile:function(a){for(var b=a.dataTransfer?a.dataTransfer.files:a.target.files,c=new FormData,d=0;d\n
\n
\n \n \n
\n
\n \n
\n
\n
\n
'}),c("AssetManager/view/AssetsView",["backbone","./AssetView","./AssetImageView","./FileUploader","text!./../template/assets.html"],function(a,b,c,d,e){return a.View.extend({template:_.template(e),initialize:function(a){this.options=a,this.config=a.config,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.listenTo(this.collection,"add",this.addToAsset),this.listenTo(this.collection,"deselectAll",this.deselectAll),this.className=this.pfx+"assets",this.events={},this.events.submit="addFromStr",this.delegateEvents()},addFromStr:function(a){a.preventDefault();var b=this.getInputUrl(),c=b.value.trim();return c?(this.collection.addImg(c,{at:0}),this.getAssetsEl().scrollTop=0,b.value="",this):void 0},getAssetsEl:function(){return this.assets=this.el.querySelector("."+this.pfx+"assets"),this.assets},getInputUrl:function(){return this.inputUrl&&this.inputUrl.value||(this.inputUrl=this.el.querySelector("."+this.pfx+"add-asset input")),this.inputUrl},addToAsset:function(a){this.addAsset(a)},addAsset:function(a,d){var e=d||null,f=b;a.get("type").indexOf("image")>-1&&(f=c);var g=new f({model:a,config:this.config}),h=g.render().el;if(e)e.appendChild(h);else{var i=this.getAssetsEl();i&&i.insertBefore(h,i.firstChild)}return h},deselectAll:function(){this.$el.find("."+this.pfx+"highlight").removeClass(this.pfx+"highlight")},render:function(){var a=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(b){this.addAsset(b,a)},this),this.$el.html(this.template({pfx:this.pfx,ppfx:this.ppfx})),this.$el.find("."+this.pfx+"assets").append(a),this}})}),c("AssetManager/config/config",[],function(){return{assets:[],stylePrefix:"am-",upload:"http://localhost/assets/upload",uploadText:"Drop files here or click to upload"}}),c("AssetManager/main",["require","./model/Assets","./view/AssetsView","./view/FileUploader","./config/config"],function(a){return function(){var b,c,d,e={},f=a("./model/Assets"),g=a("./view/AssetsView"),h=a("./view/FileUploader");return{name:"AssetManager",storageKey:"assets",init:function(i){e=i||{};var j=a("./config/config");for(var k in j)k in e||(e[k]=j[k]);var l=e.pStylePrefix;l&&(e.stylePrefix=l+e.stylePrefix),b=new f(e.assets);var m={collection:b,config:e};return c=new g(m),d=new h(m),this},add:function(a){return b.add(a)},get:function(a){return b.where({src:a})[0]},getAll:function(){return b},remove:function(a){var b=this.get(a);return this.getAll().remove(b),this},store:function(a){var b={},c=JSON.stringify(this.getAll().toJSON());return b[this.storageKey]=c,!a&&e.stm&&e.stm.store(b),b},load:function(a){var b=a||"",c=this.storageKey;!b&&e.stm&&(b=e.stm.load(c));var d=[];try{d=JSON.parse(b[c])}catch(f){}return this.getAll().add(d),d},render:function(a){return(!this.rendered||a)&&(this.rendered=c.render().$el.add(d.render().$el)),this.rendered},setTarget:function(a){c.collection.target=a},onSelect:function(a){c.collection.onSelect=a}}}}),c("AssetManager",["AssetManager/main"],function(a){return a}),c("CssComposer/config/config",[],function(){return{stylePrefix:"css-",staticRules:"",rules:[]}}),c("CssComposer/model/Selectors",["backbone","require"],function(a,b){return a.Collection.extend({initialize:function(a,c){this.model=function(a,c){var d;return this.ClassTag||(this.ClassTag=b("SelectorManager/model/Selector")),d=new this.ClassTag(a,c)}}})}),c("CssComposer/model/CssRule",["backbone","./Selectors"],function(a,b){return a.Model.extend({defaults:{selectors:{},style:{},maxWidth:"",state:"",stylable:!0},initialize:function(a,c){if(this.config=a||{},this.sm=c?c.sm||{}:{},this.slct=this.config.selectors||[],this.sm.get){for(var d=[],e=0;e=0&&(c.css=d.em.getCss()),e.indexOf("style")>=0&&(c.styles=JSON.stringify(b)),a||d.stm.store(c),c}},add:function(a,c,d){var e=c||"",g=d||"",h=this.get(a,e,g);return h?h:(h=new f({state:e,maxWidth:g}),h.get("selectors").add(a),b.add(h),h)},get:function(a,c,d){var e=null;return b.each(function(b){e||b.compare(a,c,d)&&(e=b)}),e},getAll:function(){return b},render:function(){return c.render().el}}}}),c("CssComposer",["CssComposer/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"],draggable:!1,badgable:!1,components:[]},components:[],rte:{},imageCompClass:"fa fa-picture-o",oAssetsOnCreate:!0,voidElements:["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]}}),c("DomComponents/model/Components",["backbone","require"],function(a,b){return a.Collection.extend({initialize:function(a,c){this.on("add",this.onAdd),this.config=c&&c.config?c.config:null,c&&c.sm&&(this.editor=c.sm),this.model=function(a,d){var e;switch(!d.sm&&c&&c.sm&&(d.sm=c.sm),c&&c.config&&(d.config=c.config),a.type){case"text":this.mComponentText||(this.mComponentText=b("./ComponentText")),e=new this.mComponentText(a,d);break;case"image":this.mComponentImage||(this.mComponentImage=b("./ComponentImage")),e=new this.mComponentImage(a,d);break;default:this.mComponent||(this.mComponent=b("./Component")),e=new this.mComponent(a,d)}return e}},add:function(b,c){if("string"==typeof b){var d=this.editor.get("Parser").parseHtml(b);b=d.html;var e=this.editor.get("CssComposer");d.css&&e&&e.getAll().add(d.css)}return a.Collection.prototype.add.apply(this,[b,c])},onAdd:function(a,b,c){var d=a.get("style");if(!_.isEmpty(d)&&this.editor){var e=this.editor.get("CssComposer"),f=this.editor.get("SelectorManager").add(a.cid);a.set({style:{}}),a.get("classes").add(f);var g=e.add(f);g.set("style",d)}}})}),c("DomComponents/model/Component",["backbone","./Components","SelectorManager/model/Selectors"],function(a,b,c){return a.Model.extend({defaults:{tagName:"div",type:"",editable:!1,removable:!0,draggable:!0,droppable:!0,badgable:!0,stylable:!0,copyable:!0,"void":!1,state:"",status:"",previousModel:"",content:"",style:{},attributes:{}},initialize:function(a,d){d&&d.config&&d.config.voidElements.indexOf(this.get("tagName"))>=0&&this.set("void",!0),this.sm=d?d.sm||{}:{},this.config=a||{},this.defaultC=this.config.components||[],this.defaultCl=this.normalizeClasses(this.config.classes||[]),this.components=new b(this.defaultC,d),this.set("components",this.components),this.set("classes",new c(this.defaultCl))},normalizeClasses:function(a){var b=[];if(this.sm.get){var c=this.sm.get("SelectorManager");if(c)return a.forEach(function(a){var d="";d="string"==typeof a?a:a.name;var e=c.add(d);b.push(e)}),b}},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.get("name")}),a.status="",new this.constructor(a,{sm:this.sm})},getName:function(){if(!this.name){var a=this.cid.replace(/\D/g,""),b=this.get("type"),c=this.get("tagName");c="div"==c?"box":c,c=b?b:c,this.name=c.charAt(0).toUpperCase()+c.slice(1)+" "+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.ppfx=this.config.pStylePrefix||"",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,"change:state",this.updateState),this.listenTo(this.model.get("classes"),"add remove change",this.updateClasses),this.$el.data("model",this.model),this.$el.data("collection",this.components),this.model.get("classes").length&&this.importClasses()},importClasses:function(){var a=this.config.em.get("SelectorManager");a&&this.model.get("classes").each(function(b){a.add(b.get("name"))})},updateState:function(a){var b="hc-state",c=this.model.get("state");c?this.$el.addClass(b):this.$el.removeClass(b)},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"));var d=this.getStyleString();d&&(a.style=d),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")+" "}),a=a.trim(),a?this.$el.attr("class",a):this.$el.removeAttr("class"),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.$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 active",this.openModal),this.classEmpty=this.ppfx+"plh-image",this.config.modal&&(this.modal=this.config.modal),this.config.am&&(this.am=this.config.am)},updateSrc:function(){var a=this.model.get("src");this.$el.attr("src",a),a?this.$el.removeClass(this.classEmpty):this.$el.addClass(this.classEmpty)},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.open(),this.am.onSelect(function(){b.modal.close(),b.am.setTarget(null)}))},render:function(){return this.updateAttributes(),this.updateClasses(),this.model.get("src")||this.$el.attr("class",this.classEmpty),this.$el.attr("onmousedown","return false"),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 active",this.enableEditing),this.rte=this.config.rte||""},enableEditing:function(a){this.rte&&this.rte.attach(this),this.toggleEvents(1)},disableEditing:function(a){this.rte&&this.rte.detach(this),this.toggleEvents(),this.updateContents()},disablePropagation:function(a){a.stopPropagation()},updateContents:function(){this.model.set("content",this.el.innerHTML)},toggleEvents:function(a){var b=a?"on":"off",c=[this.el.ownerDocument,document,this.rte];$(c)[b]("mousedown",this.disableEditing),this.$el[b]("mousedown",this.disablePropagation)},render:function(){return this.updateAttributes(),this.updateClasses(),this.el.innerHTML=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){return function(){var b,c,d={},e=a("./config/config"),f=a("./model/Component"),g=(a("./model/ComponentText"),a("./model/ComponentImage"),a("./view/ComponentView"));a("./view/ComponentImageView"),a("./view/ComponentTextView");return{name:"DomComponents",storageKey:function(){var a=[],b=d.stm&&d.stm.getConfig()||{};return b.storeHtml&&a.push("html"),b.storeComponents&&a.push("components"),a},init:function(a){d=a||{},d.em&&(d.components=d.em.config.components||d.components);for(var h in e)h in d||(d[h]=e[h]);var i=d.pStylePrefix;return i&&(d.stylePrefix=i+d.stylePrefix),d.em&&(d.rte=d.em.get("rte")||"",d.modal=d.em.get("Modal")||"",d.am=d.em.get("AssetManager")||""),b=new f(d.wrapper,{sm:d.em,config:d}),b.set({attributes:{id:"wrapper"}}),b.get("components").add(d.components),c=new g({model:b,config:d}),this},onLoad:function(){d.stm&&d.stm.getConfig().autoload&&this.load(),d.stm&&d.stm.isAutosave()&&(d.em.initUndoManager(),d.em.initChildrenComp(this.getWrapper()))},load:function(a){var b=a||"";!b&&d.stm&&(b=d.em.getCacheLoad());var c="";if(b.components)try{c=JSON.parse(b.components)}catch(e){}else b.html&&(c=b.html);return this.getComponents().reset(c),c},store:function(a){if(d.stm){var b={},c=this.storageKey();return c.indexOf("html")>=0&&(b.html=d.em.getHtml()),c.indexOf("components")>=0&&(b.components=JSON.stringify(d.em.getComponents())),a||d.stm.store(b),b}},getComponent:function(){return b},getWrapper:function(){return this.getComponent()},getComponents:function(){return this.getWrapper().get("components")},addComponent:function(a){return this.getComponents().add(a)},render:function(){return c.render().el},clear:function(){for(var a=this.getComponents(),b=0,c=a.length;c>b;b++)a.pop();return this},setComponents:function(a){this.clear().addComponent(a)}}}}),c("DomComponents",["DomComponents/main"],function(a){return a}),c("Canvas/config/config",[],function(){return{stylePrefix:"cv-",rulers:!1}}),c("Canvas/model/Frame",["backbone"],function(a){return a.Model.extend({defaults:{wrapper:"",width:"",height:"",attributes:{}}})}),c("Canvas/model/Canvas",["backbone","./Frame"],function(a,b){return a.Model.extend({defaults:{frame:"",wrapper:"",rulers:!1},initialize:function(a){var c=this.conf||{};this.set("frame",new b(c.frame))}})}),c("Canvas/view/FrameView",["backbone"],function(a){return a.View.extend({tagName:"iframe",attributes:{src:"about:blank"},initialize:function(a){_.bindAll(this,"udpateOffset"),this.config=a.config||{},this.ppfx=this.config.pStylePrefix||"",this.em=this.config.em,this.motionsEv="transitionend oTransitionEnd transitionend webkitTransitionEnd",this.listenTo(this.em,"change:device",this.updateWidth)},updateWidth:function(a){var b=this.em.getDeviceModel();this.el.style.width=b?b.get("width"):"",this.udpateOffset(),this.$el.on(this.motionsEv,this.udpateOffset)},udpateOffset:function(){var a=this.em.get("Canvas").getOffset();this.em.set("canvasOffset",a),this.$el.off(this.motionsEv,this.udpateOffset)},getBody:function(){this.$el.contents().find("body")},getWrapper:function(){return this.$el.contents().find("body > div")},render:function(){return this.$el.attr({"class":this.ppfx+"frame"}),this}})}),c("Canvas/view/CanvasView",["backbone","./FrameView"],function(a,b){return a.View.extend({initialize:function(a){_.bindAll(this,"renderBody","onFrameScroll"),this.config=a.config||{},this.em=this.config.em||{},this.ppfx=this.config.pStylePrefix||"",this.className=this.config.stylePrefix+"canvas",this.frame=new b({model:this.model.get("frame"),config:this.config})},onFrameScroll:function(){var a="px",b=this.frame.el.contentDocument.body;this.toolsEl.style.top="-"+b.scrollTop+a,this.toolsEl.style.left="-"+b.scrollLeft+a},renderBody:function(){var a=this.model.get("frame").get("wrapper");if(a){var b=this.frame.$el.contents().find("body"),c=this.config.em.get("CssComposer"),d=this.config.em.get("Config");b.append(a.render()).append(c.render());var e=d.protectedCss,f="."+this.ppfx+"dashed *{outline: 1px dashed rgba(170,170,170,0.7); outline-offset: -2px}."+this.ppfx+"comp-selected{outline: 3px solid #3b97e3 !important}."+this.ppfx+"no-select{user-select: none; -webkit-user-select:none; -moz-user-select: none}."+this.ppfx+"freezed{opacity: 0.5; pointer-events: none}."+this.ppfx+"plh-image{background:#f5f5f5; border:none; height:50px; width:50px; display:block; outline:3px solid #ffca6f; cursor:pointer}";e&&b.append(""),this.config.em.trigger("loaded"),this.frame.el.contentWindow.onscroll=this.onFrameScroll,this.frame.udpateOffset();var g=document,h=this.frame.el.contentDocument;h.addEventListener("keydown",function(a){g.dispatchEvent(new KeyboardEvent(a.type,a))}),h.addEventListener("keyup",function(a){g.dispatchEvent(new KeyboardEvent(a.type,a))})}},offset:function(a){var b=a.getBoundingClientRect(),c=a.ownerDocument.body;return{top:b.top+c.scrollTop,left:b.left+c.scrollLeft}},getElementPos:function(a){this.frmOff||(this.frmOff=this.offset(this.frame.el)),this.cvsOff||(this.cvsOff=this.offset(this.el));var b=this.offset(a),c=b.top+this.frmOff.top-this.cvsOff.top,d=b.left+this.frmOff.left-this.cvsOff.left;return{top:c,left:d,height:a.offsetHeight,width:a.offsetWidth}},render:function(){if(this.wrapper=this.model.get("wrapper"),this.wrapper&&"function"==typeof this.wrapper.render){this.model.get("frame").set("wrapper",this.wrapper),this.$el.append(this.frame.render().el);var a=this.frame;a.el.onload=this.renderBody}this.toolsEl=$("
",{id:this.ppfx+"tools"}).get(0),this.hlEl=$("
",{"class":this.ppfx+"highlighter"}).get(0),this.badgeEl=$("
",{"class":this.ppfx+"badge"}).get(0),this.placerEl=$("
",{"class":this.ppfx+"placeholder"}).get(0),this.placerIntEl=$("
",{"class":this.ppfx+"placeholder-int"}).get(0),this.ghostEl=$("
",{"class":this.ppfx+"ghost"}).get(0),this.placerEl.appendChild(this.placerIntEl),this.toolsEl.appendChild(this.hlEl),this.toolsEl.appendChild(this.badgeEl),this.toolsEl.appendChild(this.placerEl),this.toolsEl.appendChild(this.ghostEl),this.$el.append(this.toolsEl);var b=this.em.get("rte");return b&&this.toolsEl.appendChild(b.render()),this.$el.attr({"class":this.className}),this}})}),c("Canvas/main",["require","./config/config","./model/Canvas","./view/CanvasView"],function(a){return function(){var b,c={},d=a("./config/config"),e=a("./model/Canvas"),f=a("./view/CanvasView");return{getCanvasView:function(){return f},name:"Canvas",init:function(a){c=a||{};for(var g in d)g in c||(c[g]=d[g]);var h=c.pStylePrefix;h&&(c.stylePrefix=h+c.stylePrefix),b=new e(a),f=new f({model:b,config:c});var i=c.em.get("DomComponents");return i&&this.setWrapper(i),this},setWrapper:function(a){b.set("wrapper",a)},getElement:function(){return f.el},getFrameEl:function(){return f.frame.el},getBody:function(){return f.frame.el.contentDocument.body},getWrapperEl:function(){return this.getBody().querySelector("#wrapper")},getToolsEl:function(){return f.toolsEl},getHighlighter:function(){return f.hlEl},getBadgeEl:function(){return f.badgeEl},getPlacerEl:function(){return f.placerEl},getGhostEl:function(){return f.ghostEl},render:function(){return f.render().el},getOffset:function(){var a=this.offset(this.getFrameEl()),b=this.offset(this.getElement());return{top:a.top-b.top,left:a.left-b.left}},offset:function(a){var b=a.getBoundingClientRect();return{top:b.top+document.body.scrollTop,left:b.left+document.body.scrollLeft}},getFrameWrapperEl:function(){return f.frame.getWrapper()}}}}),c("Canvas",["Canvas/main"],function(a){return a}),c("Commands/config/config",[],function(){return{ESCAPE_KEY:27,stylePrefix:"com-",defaults:[],em:null,firstCentered:!0,newFixedH:!1,minComponentH:50,minComponentW:50}}),c("Commands/view/CommandAbstract",["backbone"],function(a){return a.View.extend({initialize:function(a){this.config=a||{},this.editorModel=this.em=this.config.em||{},this.pfx=this.config.stylePrefix,this.ppfx=this.config.pStylePrefix,this.hoverClass=this.pfx+"hover",this.badgeClass=this.pfx+"badge",this.plhClass=this.pfx+"placeholder",this.freezClass=this.ppfx+"freezed",this.canvas=this.em.get&&this.em.get("Canvas"),this.em.get&&this.setElement(this.getCanvas()),this.canvas&&(this.$canvas=this.$el,this.$wrapper=$(this.getCanvasWrapper()),this.frameEl=this.canvas.getFrameEl(),this.canvasTool=this.getCanvasTools(),this.bodyEl=this.getCanvasBody()),this.init(this.config)},onFrameScroll:function(a){},getCanvas:function(){return this.canvas.getElement()},getCanvasBody:function(){return this.canvas.getBody()},getCanvasWrapper:function(){return this.canvas.getWrapperEl(); -},getCanvasTools:function(){return this.canvas.getToolsEl()},offset:function(a){var b=a.getBoundingClientRect();return{top:b.top+a.ownerDocument.body.scrollTop,left:b.left+a.ownerDocument.body.scrollLeft}},init:function(a){},run:function(a,b){},stop:function(a,b){}})}),c("Commands/view/SelectComponent",[],function(){return{init:function(a){_.bindAll(this,"onHover","onOut","onClick","onKeyPress","clearOff")},enable:function(){_.bindAll(this,"copyComp","pasteComp","onFrameScroll"),this.frameOff=this.canvasOff=this.adjScroll=null;var a=this.config.em.get("Config");this.startSelectComponent(),this.toggleClipboard(a.copyPaste)},toggleClipboard:function(a){var b=a||0;b?(key("⌘+c, ctrl+c",this.copyComp),key("⌘+v, ctrl+v",this.pasteComp)):(key.unbind("⌘+c, ctrl+c"),key.unbind("⌘+v, ctrl+v"))},clearOff:function(){this.frameOff=null,this.canvasOff=null},copyComp:function(){var a=this.editorModel.get("selectedComponent");a&&a.get("copyable")&&this.editorModel.set("clipboard",a)},pasteComp:function(){var a=this.editorModel.get("clipboard"),b=this.editorModel.get("selectedComponent");if(a&&b&&b.collection){var c=b.collection.indexOf(b),d=a.clone();b.collection.add(d,{at:c+1})}},startSelectComponent:function(){this.listenTo(this.em,"change:canvasOffset",this.clearOff),this.selEl=$(this.getCanvasBody()).find("*"),this.selEl.on("mouseover",this.onHover).on("mouseout",this.onOut).on("click",this.onClick);var a=this.getContentWindow();a.on("scroll",this.onFrameScroll),a.on("keydown",this.onKeyPress)},stopSelectComponent:function(){this.stopListening(this.em,"change:canvasOffset",this.clearOff),this.selEl&&this.selEl.trigger("mouseout").off("mouseover",this.onHover).off("mouseout",this.onOut).off("click",this.onClick),this.selEl=null;var a=this.getContentWindow();a.off("scroll",this.onFrameScroll),a.off("keydown",this.onKeyPress)},onKeyPress:function(a){var b=a.which||a.keyCode,c=this.editorModel.get("selectedComponent"),d="BODY"!==this.frameEl.contentDocument.activeElement.tagName;if((8==b||46==b)&&(d||a.preventDefault(),c&&!d)){if(!c.get("removable"))return;c.set("status",""),c.destroy(),this.hideBadge(),this.clean(),this.editorModel.set("selectedComponent",null)}},onHover:function(a){a.stopPropagation();var b=a.target;this.adjScroll||(this.adjScroll=1,this.onFrameScroll(a)),this.updateBadge(b),this.updateHighlighter(b)},onOut:function(a){a.stopPropagation(),this.hideBadge(),this.hl&&this.hl.css({left:-1e4,top:-1e4})},onClick:function(a){var b=$(a.target).data("model");if(b){var c=b.get("stylable");(c instanceof Array||c)&&this.onSelect(a,a.target)}},updateHighlighter:function(a){this.hl||(this.hl=$(this.canvas.getHighlighter()));var b=this.getElementPos($(a));this.hl.css({left:b.left,top:b.topP,height:b.height,width:b.width})},onSelect:function(a,b){a.stopPropagation();var c=this.editorModel.get("selectedComponent");this.cleanPrevious(c);var d=$(b),e=d.data("model");if(e){this.editorModel.set("selectedComponent",e),e.set("status","selected");this.getElementPos(d)}},clean:function(){this.selEl&&this.selEl.removeClass(this.hoverClass)},updateBadge:function(a){var b=$(a);this.cacheEl=b;var c=b.data("model");if(c&&c.get("badgable")){var d=this.getBadge();d.innerHTML=c.getName();var e=d.style,f="px";e.display="block";var g=this.getElementPos(b,d);e.left=g.leftP+f,e.top=g.top+f}},getBadge:function(){return this.canvas.getBadgeEl()},onFrameScroll:function(a){this.cacheEl&&this.updateBadge(this.cacheEl)},getElementPos:function(a,b){this.frameOff||(this.frameOff=this.offset(this.canvas.getFrameEl())),this.canvasOff||(this.canvasOff=this.offset(this.canvas.getElement()));var c=a.offset(),d=this.getCanvasBody(),e=b?b:null,f=e?e.offsetHeight:0,g=e?e.offsetWidth:0,h=c.top+this.frameOff.top-this.canvasOff.top,i=c.left+this.frameOff.left-this.canvasOff.left,j=this.frameOff.top+d.scrollTop,k=this.frameOff.left+d.scrollLeft,l=h;h=j>h-f?j:h-f;var m=k>i+g?k-g:i;return{topP:l,leftP:m,top:h,left:i,height:a.outerHeight(),width:a.outerWidth()}},hideBadge:function(){this.getBadge().style.display="none"},cleanPrevious:function(a){a&&a.set({status:"",state:""})},getContentWindow:function(){return this.contWindow||(this.contWindow=$(this.frameEl.contentWindow)),this.contWindow},run:function(a,b){this.enable()},stop:function(){this.stopSelectComponent(),this.cleanPrevious(this.em.get("selectedComponent")),this.clean(),this.em.set("selectedComponent",null),this.toggleClipboard(),this.hideBadge()}}}),c("Commands/view/SelectPosition",[],function(){return{startSelectPosition:function(a,b){this.isPointed=!1;var c=this.editorModel.get("Utils");c&&!this.sorter&&(this.sorter=new c.Sorter({container:this.getCanvasBody(),placer:this.canvas.getPlacerEl(),containerSel:"*",itemSel:"*",pfx:this.ppfx,direction:"a",document:b,wmargin:1,nested:1,em:this.editorModel})),this.sorter.startSort(a)},getOffsetDim:function(){var a=this.offset(this.canvas.getFrameEl()),b=this.offset(this.canvas.getElement()),c=a.top-b.top,d=a.left-b.left;return{top:c,left:d}},stopSelectPosition:function(){this.posTargetCollection=null,this.posIndex="after"==this.posMethod&&0!==this.cDim.length?this.posIndex+1:this.posIndex,this.sorter&&(this.sorter.moved=0,this.sorter.endMove()),this.cDim&&(this.posIsLastEl=0!==this.cDim.length&&"after"==this.posMethod&&this.posIndex==this.cDim.length,this.posTargetEl=0===this.cDim.length?$(this.outsideElem):!this.posIsLastEl&&this.cDim[this.posIndex]?$(this.cDim[this.posIndex][5]).parent():$(this.outsideElem),this.posTargetModel=this.posTargetEl.data("model"),this.posTargetCollection=this.posTargetEl.data("model-comp"))},enable:function(){this.startSelectPosition()},nearFloat:function(a,b,c){var d=a||0,e=b||"before",f=c.length,g=0!==f&&"after"==e&&d==f;return 0!==f&&(!g&&!c[d][4]||c[d-1]&&!c[d-1][4]||g&&!c[d-1][4])?1:0},run:function(){this.enable()},stop:function(){this.stopSelectPosition(),this.$wrapper.css("cursor",""),this.$wrapper.unbind()}}}),c("Commands/view/CreateComponent",["backbone","./SelectPosition"],function(a,b){return _.extend({},b,{init:function(a){_.bindAll(this,"startDraw","draw","endDraw","rollback"),this.config=a||{},this.hType=this.config.newFixedH?"height":"min-height",this.allowDraw=1},enable:function(){b.enable.apply(this,arguments),this.$wr.css("cursor","crosshair"),this.allowDraw&&this.$wr.on("mousedown",this.startDraw),this.ghost=this.canvas.getGhostEl()},startDraw:function(a){a.preventDefault(),this.stopSelectPosition(),this.ghost.style.display="block",this.frameOff=this.getOffsetDim(),this.startPos={top:a.pageY+this.frameOff.top,left:a.pageX+this.frameOff.left},this.isDragged=!1,this.tempComponent={style:{}},this.beforeDraw(this.tempComponent),this.updateSize(this.startPos.top,this.startPos.left,0,0),this.toggleEvents(1)},toggleEvents:function(a){var b=a?"on":"off";this.$wr[b]("mousemove",this.draw),this.$wr[b]("mouseup",this.endDraw),this.$canvas[b]("mousemove",this.draw),$(document)[b]("mouseup",this.endDraw),$(document)[b]("keypress",this.rollback)},draw:function(a){this.isDragged=!0,this.updateComponentSize(a)},endDraw:function(a){this.toggleEvents();var b={};if(this.isDragged){this.updateComponentSize(a),this.setRequirements(this.tempComponent);var c=this.sorter.lastPos;b=this.create(this.sorter.target,this.tempComponent,c.index,c.method),this.sorter.prevTarget=null}this.ghost.style.display="none",this.startSelectPosition(),this.afterDraw(b)},create:function(a,b,c,d,e){c="after"===d?c+1:c;var f=e||{},g=$(a),h=g.data("model"),i=g.data("collection"),j=h?h.get("droppable"):1;return f.at=c,i&&j?i.add(b,f):void console.warn("Invalid target position")},setRequirements:function(a){var b=this.config,c=a.style;c.width.replace(/\D/g,"")c&&(f=c,h=d.left-c),e>b&&(e=b,g=d.top-b),this.updateSize(e,f,h,g)},updateSize:function(a,b,c,d){var e="px",f=this.ghost.style,g=this.tempComponent.style;f.top=g.top=a+e,f.left=g.left=b+e,f.width=g.width=c+e,f[this.hType]=g[this.hType]=d+e},rollback:function(a,b){var c=a.which||a.keyCode;(c==this.config.ESCAPE_KEY||b)&&(this.isDragged=!1,this.endDraw())},beforeDraw:function(a){a.editable=!1},afterDraw:function(a){},run:function(a,b,c){this.editor=a,this.sender=b,this.$wr=this.$wrapper,this.enable()},stop:function(){this.stopSelectPosition(),this.$wrapper.css("cursor",""),this.$wrapper.unbind()}})}),c("Commands/view/DeleteComponent",["backbone","./SelectComponent"],function(a,b){return _.extend({},b,{init:function(a){_.bindAll(this,"startDelete","stopDelete","onDelete"),this.hoverClass=this.pfx+"hover-delete",this.badgeClass=this.pfx+"badge-red"},enable:function(){this.$el.find("*").mouseover(this.startDelete).mouseout(this.stopDelete).click(this.onDelete)},startDelete:function(a){a.stopPropagation();var b=$(a.target);b.data("model").get("removable")&&(b.addClass(this.hoverClass),this.attachBadge(b.get(0)))},stopDelete:function(a){a.stopPropagation();var b=$(a.target);b.removeClass(this.hoverClass),this.badge&&this.badge.css({left:-1e3,top:-1e3})},onDelete:function(a){a.stopPropagation();var b=$(a.target);b.data("model").get("removable")&&(b.data("model").destroy(),this.removeBadge(),this.clean())},updateBadgeLabel:function(a){this.badge.html("Remove "+a.getName())}})}),c("Commands/view/InsertCustom",["backbone","./CreateComponent"],function(a,b){return _.extend({},b,{init:function(){b.init.apply(this,arguments),_.bindAll(this,"insertComponent"),this.allowDraw=0},run:function(a,b,c){this.em=a,this.sender=b,this.opt=c||{},this.$wr=this.$wrapper,this.enable()},enable:function(){b.enable.apply(this,arguments),this.$wr.on("click",this.insertComponent)},insertComponent:function(){this.$wr.off("click",this.insertComponent),this.stopSelectPosition();var a=this.buildContent();this.beforeInsert(a);var b=this.sorter.lastPos.index,c=this.create(this.sorter.target,a,b,null,{silent:!1});this.opt.terminateAfterInsert&&this.sender?this.sender.set("active",!1):this.enable(),c&&(this.em&&this.em.editor.initChildrenComp(c),this.afterInsert(c,this))},beforeInsert:function(a){},afterInsert:function(a){},buildContent:function(){return this.opt.content||{}}})}),c("Commands/view/ImageComponent",["backbone","./InsertCustom"],function(a,b){return _.extend({},b,{beforeInsert:function(a){a.type="image",a.style={},a.attributes={},a.attributes.onmousedown="return false",this.config.firstCentered&&this.getCanvasWrapper()==this.sorter.target&&(a.style.margin="0 auto")},afterInsert:function(a){a.trigger("dblclick"),this.sender&&this.sender.set("active",!1)}})}),c("Commands/view/MoveComponent",["backbone","./SelectComponent","./SelectPosition"],function(a,b,c){return _.extend({},c,b,{init:function(a){b.init.apply(this,arguments),_.bindAll(this,"initSorter","rollback","onEndMove"),this.opt=a,this.hoverClass=this.ppfx+"highlighter-warning",this.badgeClass=this.ppfx+"badge-warning",this.noSelClass=this.ppfx+"no-select"},enable:function(){b.enable.apply(this,arguments),this.getBadgeEl().addClass(this.badgeClass),this.getHighlighterEl().addClass(this.hoverClass);var a=this.$wrapper;a.css("cursor","move"),a.on("mousedown",this.initSorter),a.addClass(this.noSelClass)},toggleClipboard:function(){},initSorter:function(a){var b=$(a.target).data("model");b.get("draggable")&&(this.cacheEl=null,this.startSelectPosition(a.target,this.frameEl.contentDocument),this.sorter.onEndMove=this.onEndMove.bind(this),this.stopSelectComponent(),this.$wrapper.off("mousedown",this.initSorter),this.getContentWindow().on("keydown",this.rollback))},onEndMove:function(){this.enable(),this.getContentWindow().off("keydown",this.rollback)},onSelect:function(a,b){},rollback:function(a,b){var c=a.which||a.keyCode;(c==this.opt.ESCAPE_KEY||b)&&(this.sorter.moved=!1,this.sorter.endMove())},getBadgeEl:function(){return this.$badge||(this.$badge=$(this.getBadge())),this.$badge},getHighlighterEl:function(){return this.$hl||(this.$hl=$(this.canvas.getHighlighter())),this.$hl},stop:function(){b.stop.apply(this,arguments),this.getBadgeEl().removeClass(this.badgeClass),this.getHighlighterEl().removeClass(this.hoverClass);var a=this.$wrapper;a.css("cursor","").unbind().removeClass(this.noSelClass)}})}),c("Commands/view/TextComponent",["backbone","./CreateComponent"],function(a,b){return _.extend({},b,{beforeDraw:function(a){a.type="text",a.style||(a.style={}),a.style.padding="10px"},afterDraw:function(a){a&&a.set&&(a.trigger("focus"),this.sender&&this.sender.set("active",!1))}})}),c("Commands/view/ExportTemplate",[],function(){return{run:function(a,b){this.sender=b,this.components=a.DomComponents.getComponents(),this.modal=a.Modal||null,this.cm=a.CodeManager||null,this.cssc=a.CssComposer||null,this.protCss=a.Config.protectedCss,this.pfx=a.Config.stylePrefix||"",this.enable()},buildEditor:function(a,b,c){this.codeMirror||(this.codeMirror=this.cm.getViewer("CodeMirror"));var d=$("