diff --git a/bower.json b/bower.json index 6136b1273..020637b8f 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "grapesjs", "description": "Open source Web Template Editor", - "version": "0.5.27", + "version": "0.5.28", "author": "Artur Arseniev", "homepage": "http://grapesjs.com", "main": [ diff --git a/dist/grapes.min.js b/dist/grapes.min.js index 4ef7e8c7c..b974c2d0d 100644 --- a/dist/grapes.min.js +++ b/dist/grapes.min.js @@ -1,4 +1,4 @@ -/*! grapesjs - v0.5.27 */ +/*! grapesjs - v0.5.28 */ !function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof exports&&"object"==typeof module?module.exports=b():a.grapesjs=a.GrapesJS=b()}(this,function(){var a,b,c;!function(d){function e(a,b){return v.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o=b&&b.split("/"),p=t.map,q=p&&p["*"]||{};if(a){for(a=a.split("/"),g=a.length-1,t.nodeIdCompat&&x.test(a[g])&&(a[g]=a[g].replace(x,"")),"."===a[0].charAt(0)&&o&&(n=o.slice(0,o.length-1),a=n.concat(a)),k=0;k0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}if((o||q)&&p){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),o)for(l=o.length;l>0;l-=1)if(e=p[o.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&q&&q[d]&&(i=q[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,b){return function(){var c=w.call(arguments,0);return"string"!=typeof c[0]&&1===c.length&&c.push(null),o.apply(d,c.concat([a,b]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){r[a]=b}}function j(a){if(e(s,a)){var b=s[a];delete s[a],u[a]=!0,n.apply(d,b)}if(!e(r,a)&&!e(u,a))throw new Error("No "+a);return r[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return a?k(a):[]}function m(a){return function(){return t&&t.config&&t.config[a]||{}}}var n,o,p,q,r={},s={},t={},u={},v=Object.prototype.hasOwnProperty,w=[].slice,x=/\.js$/;p=function(a,b){var c,d=k(a),e=d[0],g=b[1];return a=d[1],e&&(e=f(e,g),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(g)):f(a,g):(a=f(a,g),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},q={require:function(a){return g(a)},exports:function(a){var b=r[a];return"undefined"!=typeof b?b:r[a]={}},module:function(a){return{id:a,uri:"",exports:r[a],config:m(a)}}},n=function(a,b,c,f){var h,k,m,n,o,t,v,w=[],x=typeof c;if(f=f||a,t=l(f),"undefined"===x||"function"===x){for(b=!b.length&&c.length?["require","exports","module"]:b,o=0;o
",attributes:{"class":"gjs-fonts gjs-f-b1"}},{id:"b2",label:"2 Blocks",content:'
",attributes:{"class":"gjs-fonts gjs-f-b2"}},{id:"b3",label:"3 Blocks",content:'
",attributes:{"class":"gjs-fonts gjs-f-b3"}},{id:"b4",label:"3/7 Block",content:'
",attributes:{"class":"gjs-fonts gjs-f-b37"}},{id:"hero",label:"Hero section",content:'
Build your templates without coding
Try it now
',attributes:{"class":"gjs-fonts gjs-f-hero"}},{id:"h1p",label:"Text section",content:'

Insert title here

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

',attributes:{"class":"gjs-fonts gjs-f-h1p"}},{id:"3ba",label:"Badges",content:'
Adam Smith
CEO
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore ipsum dolor sit
ftln
John Black
Software Engineer
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore ipsum dolor sit
ftln
Jessica White
Web Designer
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore ipsum dolor sit
ftln
',attributes:{"class":"gjs-fonts gjs-f-3ba"}},{id:"text",label:"Text",attributes:{"class":"gjs-fonts gjs-f-text"},content:{type:"text",content:"Insert your text here",style:{padding:"10px"},activeOnRender:1}},{id:"image",label:"Image",attributes:{"class":"gjs-fonts gjs-f-image"},content:{style:{color:"black"},type:"image",activeOnRender:1}},{id:"quo",label:"Quote",content:'
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore ipsum dolor sit
',attributes:{"class":"fa fa-quote-right"}},{id:"link",label:"Link",attributes:{"class":"fa fa-link"},content:{type:"link",content:"Link",style:{color:"#d983a6"}}},{id:"map",label:"Map",attributes:{"class":"fa fa-map-o"},content:{type:"map",style:{height:"350px"}}},{id:"video",label:"Video",attributes:{"class":"fa fa-youtube-play"},content:{type:"video",src:"img/video2.webm",style:{height:"350px",width:"615px"}}}]}}}),function(){function a(a){function b(b,c,d,e,f,g){for(;f>=0&&f0?0:h-1;return arguments.length<3&&(e=c[g?g[i]:i],i+=a),b(c,d,e,g,i,h)}}function b(a){return function(b,c,d){c=v(c,d);for(var e=A(b),f=a>0?0:e-1;f>=0&&f0?g=f>=0?f:Math.max(f+h,g):h=f>=0?Math.min(f+1,h):f+h+1;else if(c&&f&&h)return f=c(d,e),d[f]===e?f:-1;if(e!==e)return f=b(l.call(d,g,h),t.isNaN),f>=0?f+g:-1;for(f=a>0?g:h-1;f>=0&&f=0&&b<=z};t.each=t.forEach=function(a,b,c){b=u(b,c);var d,e;if(B(a))for(d=0,e=a.length;d=0},t.invoke=function(a,b){var c=l.call(arguments,2),d=t.isFunction(b);return t.map(a,function(a){var e=d?b:a[b];return null==e?e:e.apply(a,c)})},t.pluck=function(a,b){return t.map(a,t.property(b))},t.where=function(a,b){return t.filter(a,t.matcher(b))},t.findWhere=function(a,b){return t.find(a,t.matcher(b))},t.max=function(a,b,c){var d,e,f=-(1/0),g=-(1/0);if(null==b&&null!=a){a=B(a)?a:t.values(a);for(var h=0,i=a.length;hf&&(f=d)}else b=v(b,c),t.each(a,function(a,c,d){e=b(a,c,d),(e>g||e===-(1/0)&&f===-(1/0))&&(f=a,g=e)});return f},t.min=function(a,b,c){var d,e,f=1/0,g=1/0;if(null==b&&null!=a){a=B(a)?a:t.values(a);for(var h=0,i=a.length;hd||void 0===c)return 1;if(cb?(g&&(clearTimeout(g),g=null),h=j,f=a.apply(d,e),g||(d=e=null)):g||c.trailing===!1||(g=setTimeout(i,k)),f}},t.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=t.now()-g;j=0?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),d||(f=e=null)))};return function(){f=this,e=arguments,g=t.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},t.wrap=function(a,b){return t.partial(b,a)},t.negate=function(a){return function(){return!a.apply(this,arguments)}},t.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},t.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}},t.before=function(a,b){var c;return function(){return--a>0&&(c=b.apply(this,arguments)),a<=1&&(b=null),c}},t.once=t.partial(t.before,2);var F=!{toString:null}.propertyIsEnumerable("toString"),G=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];t.keys=function(a){if(!t.isObject(a))return[];if(p)return p(a);var b=[];for(var c in a)t.has(a,c)&&b.push(c);return F&&e(a,b),b},t.allKeys=function(a){if(!t.isObject(a))return[];var b=[];for(var c in a)b.push(c);return F&&e(a,b),b},t.values=function(a){for(var b=t.keys(a),c=b.length,d=Array(c),e=0;e":">",'"':""","'":"'","`":"`"},J=t.invert(I),K=function(a){var b=function(b){return a[b]},c="(?:"+t.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};t.escape=K(I),t.unescape=K(J),t.result=function(a,b,c){var d=null==a?void 0:a[b];return void 0===d&&(d=c),t.isFunction(d)?d.call(a):d};var L=0;t.uniqueId=function(a){var b=++L+"";return a?a+b:b},t.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var M=/(.)^/,N={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},O=/\\|'|\r|\n|\u2028|\u2029/g,P=function(a){return"\\"+N[a]};t.template=function(a,b,c){!b&&c&&(b=c),b=t.defaults({},b,t.templateSettings);var d=RegExp([(b.escape||M).source,(b.interpolate||M).source,(b.evaluate||M).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(O,P),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(b.variable||"obj","_",f)}catch(h){throw h.source=f,h}var i=function(a){return g.call(this,a,t)},j=b.variable||"obj";return i.source="function("+j+"){\n"+f+"}",i},t.chain=function(a){var b=t(a);return b._chain=!0,b};var Q=function(a,b){return a._chain?t(b).chain():b};t.mixin=function(a){t.each(t.functions(a),function(b){var c=t[b]=a[b];t.prototype[b]=function(){var a=[this._wrapped];return k.apply(a,arguments),Q(this,c.apply(t,a))}})},t.mixin(t),t.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=h[a];t.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],Q(this,c)}}),t.each(["concat","join","slice"],function(a){var b=h[a];t.prototype[a]=function(){return Q(this,b.apply(this._wrapped,arguments))}}),t.prototype.value=function(){return this._wrapped},t.prototype.valueOf=t.prototype.toJSON=t.prototype.value,t.prototype.toString=function(){return""+this._wrapped},"function"==typeof c&&c.amd&&c("underscore",[],function(){return t})}.call(this),c("jquery",[],function(){return jQuery}),function(a){var d="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;if("function"==typeof c&&c.amd)c("backbone",["underscore","jquery","exports"],function(b,c,e){d.Backbone=a(d,e,b,c)});else if("undefined"!=typeof exports){var e,f=b("underscore");try{e=b("jquery")}catch(g){}a(d,exports,f,e)}else d.Backbone=a(d,{},d._,d.jQuery||d.Zepto||d.ender||d.$)}(function(a,b,c,d){var e=a.Backbone,f=Array.prototype.slice;b.VERSION="1.3.3",b.$=d,b.noConflict=function(){return a.Backbone=e,this},b.emulateHTTP=!1,b.emulateJSON=!1;var g=function(a,b,d){switch(a){case 1:return function(){return c[b](this[d])};case 2:return function(a){return c[b](this[d],a)};case 3:return function(a,e){return c[b](this[d],i(a,this),e)};case 4:return function(a,e,f){return c[b](this[d],i(a,this),e,f)};default:return function(){var a=f.call(arguments);return a.unshift(this[d]),c[b].apply(c,a)}}},h=function(a,b,d){c.each(b,function(b,e){c[e]&&(a.prototype[e]=g(b,e,d))})},i=function(a,b){return c.isFunction(a)?a:c.isObject(a)&&!b._isModel(a)?j(a):c.isString(a)?function(b){return b.get(a)}:a},j=function(a){var b=c.matches(a);return function(a){return b(a.attributes)}},k=b.Events={},l=/\s+/,m=function(a,b,d,e,f){var g,h=0;if(d&&"object"==typeof d){void 0!==e&&"context"in f&&void 0===f.context&&(f.context=e);for(g=c.keys(d);hthis.length&&(e=this.length),e<0&&(e+=this.length+1);var f,g,h=[],i=[],j=[],k=[],l={},m=b.add,n=b.merge,o=b.remove,p=!1,q=this.comparator&&null==e&&b.sort!==!1,r=c.isString(this.comparator)?this.comparator:null;for(g=0;g7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(L,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var b=this.root.slice(0,-1)||"/";return this.location.replace(b+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;var d=document.body,e=d.insertBefore(this.iframe,d.firstChild).contentWindow;e.document.open(),e.document.close(),e.location.hash="#"+this.fragment}var f=window.addEventListener||function(a,b){return attachEvent("on"+a,b)};if(this._usePushState?f("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?f("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var a=window.removeEventListener||function(a,b){return detachEvent("on"+a,b)};this._usePushState?a("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&a("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),J.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(a){var b=this.getFragment();return b===this.fragment&&this.iframe&&(b=this.getHash(this.iframe.contentWindow)),b!==this.fragment&&(this.iframe&&this.navigate(b),void this.loadUrl())},loadUrl:function(a){return!!this.matchRoot()&&(a=this.fragment=this.getFragment(a),c.some(this.handlers,function(b){if(b.route.test(a))return b.callback(a),!0}))},navigate:function(a,b){if(!J.started)return!1;b&&b!==!0||(b={trigger:!!b}),a=this.getFragment(a||"");var c=this.root;""!==a&&"?"!==a.charAt(0)||(c=c.slice(0,-1)||"/");var d=c+a;if(a=this.decodeFragment(a.replace(M,"")),this.fragment!==a){if(this.fragment=a,this._usePushState)this.history[b.replace?"replaceState":"pushState"]({},document.title,d);else{if(!this._wantsHashChange)return this.location.assign(d);if(this._updateHash(this.location,a,b.replace),this.iframe&&a!==this.getHash(this.iframe.contentWindow)){var e=this.iframe.contentWindow;b.replace||(e.document.open(),e.document.close()),this._updateHash(e.location,a,b.replace)}}return b.trigger?this.loadUrl(a):void 0}},_updateHash:function(a,b,c){if(c){var d=a.href.replace(/(javascript:|#).*$/,"");a.replace(d+"#"+b)}else a.hash="#"+b}}),b.history=new J;var N=function(a,b){var d,e=this;return d=a&&c.has(a,"constructor")?a.constructor:function(){return e.apply(this,arguments)},c.extend(d,e,b),d.prototype=c.create(e.prototype,a),d.prototype.constructor=d,d.__super__=e.prototype,d};t.extend=v.extend=E.extend=A.extend=J.extend=N;var O=function(){throw new Error('A "url" property or function must be specified')},P=function(a,b){var c=b.error;b.error=function(d){c&&c.call(b.context,a,d,b),a.trigger("error",a,d,b)}};return b}),function(a){"function"==typeof c&&c.amd?c("backboneUndo",["underscore","backbone"],a):"undefined"!=typeof exports?module.exports=a(b("underscore"),b("backbone")):a(_,Backbone)}(function(a,b){function c(a,b,c){return c.length<=4?a.call(b,c[0],c[1],c[2],c[3]):a.apply(b,c)}function d(a,b){return n.call(a,b)}function e(b,c){return null!=b&&(a.isArray(c)||(c=d(arguments,1)),a.all(c,function(a){return a in b}))}function f(){this.registeredObjects=[],this.cidIndexes=[]}function g(b,c,d,e){for(var f,g=0,h=c.length;ga.maximumStackLength&&(a.shift(),a.pointer--)}}}function l(){}function m(b,c,d,f){if("object"==typeof c)return a.each(c,function(a,c){2===b?m(b,a,d,f):m(b,c,a,d)});switch(b){case 0:e(d,"undo","redo","on")&&a.all(a.pick(d,"undo","redo","on"),a.isFunction)&&(f[c]=d);break;case 1:f[c]&&a.isObject(d)&&(f[c]=a.extend({},f[c],d));break;case 2:delete f[c]}return this}var n=Array.prototype.slice,o=function(){function b(){d++,c=!0,a.defer(function(){c=!1})}var c=!1,d=-1;return function(){return c||b(),d}}();f.prototype={isRegistered:function(b){return b&&b.cid?this.registeredObjects[b.cid]:a.contains(this.registeredObjects,b)},register:function(a){return!this.isRegistered(a)&&(a&&a.cid?(this.registeredObjects[a.cid]=a,this.cidIndexes.push(a.cid)):this.registeredObjects.push(a),!0)},unregister:function(b){if(this.isRegistered(b)){if(b&&b.cid)delete this.registeredObjects[b.cid],this.cidIndexes.splice(a.indexOf(this.cidIndexes,b.cid),1);else{var c=a.indexOf(this.registeredObjects,b);this.registeredObjects.splice(c,1)}return!0}return!1},get:function(){return a.map(this.cidIndexes,function(a){return this.registeredObjects[a]},this).concat(this.registeredObjects)}};var p={add:{undo:function(a,b,c,d){a.remove(c,d)},redo:function(a,b,c,d){d.index&&(d.at=d.index),a.add(c,d)},on:function(b,c,d){return{object:c,before:void 0,after:b,options:a.clone(d)}}},remove:{undo:function(a,b,c,d){"index"in d&&(d.at=d.index),a.add(b,d)},redo:function(a,b,c,d){a.remove(b,d)},on:function(b,c,d){return{object:c,before:b,after:void 0,options:a.clone(d)}}},change:{undo:function(b,c,d,e){a.isEmpty(c)?a.each(a.keys(d),b.unset,b):(b.set(c),e&&e.unsetData&&e.unsetData.before&&e.unsetData.before.length&&a.each(e.unsetData.before,b.unset,b))},redo:function(b,c,d,e){a.isEmpty(d)?a.each(a.keys(c),b.unset,b):(b.set(d),e&&e.unsetData&&e.unsetData.after&&e.unsetData.after.length&&a.each(e.unsetData.after,b.unset,b))},on:function(b,c){var d=b.changedAttributes(),e=a.keys(d),f=a.pick(b.previousAttributes(),e),g=a.keys(f),h=(c||(c={})).unsetData={after:[],before:[]};return e.length!=g.length&&(e.length>g.length?a.each(e,function(a){a in f||h.before.push(a)},this):a.each(g,function(a){a in d||h.after.push(a)})),{object:b,before:f,after:d,options:a.clone(c)}}},reset:{undo:function(a,b,c){a.reset(b)},redo:function(a,b,c){a.reset(c)},on:function(b,c){return{object:b,before:c.previousModels,after:a.clone(b.models)}}}};l.prototype=p;var q=b.Model.extend({defaults:{type:null,object:null,before:null,after:null,magicFusionIndex:null},undo:function(a){h("undo",this.attributes)},redo:function(a){h("redo",this.attributes)}}),r=b.Collection.extend({model:q,pointer:-1,track:!1,isCurrentlyUndoRedoing:!1,maximumStackLength:1/0,setMaxLength:function(a){this.maximumStackLength=a}}),s=b.Model.extend({defaults:{maximumStackLength:1/0,track:!1},initialize:function(b){this.stack=new r,this.objectRegistry=new f,this.undoTypes=new l,this.stack.setMaxLength(this.get("maximumStackLength")),this.on("change:maximumStackLength",function(a,b){this.stack.setMaxLength(b)},this),b&&b.track&&this.startTracking(),b&&b.register&&(a.isArray(b.register)||a.isArguments(b.register)?c(this.register,this,b.register):this.register(b.register))},startTracking:function(){this.set("track",!0),this.stack.track=!0},stopTracking:function(){this.set("track",!1),this.stack.track=!1},isTracking:function(){return this.get("track")},_addToStack:function(a){k(this.stack,a,d(arguments,1),this.undoTypes)},register:function(){g("on",arguments,this._addToStack,this)},unregister:function(){g("off",arguments,this._addToStack,this)},unregisterAll:function(){c(this.unregister,this,this.objectRegistry.get())},undo:function(a){i("undo",this,this.stack,a)},undoAll:function(){i("undo",this,this.stack,!1,!0)},redo:function(a){i("redo",this,this.stack,a)},redoAll:function(){i("redo",this,this.stack,!1,!0)},isAvailable:function(a){var b=this.stack,c=b.length;switch(a){case"undo":return c>0&&b.pointer>-1;case"redo":return c>0&&b.pointer0;for(f in v)(!v[f]&&b(e.mods,+f)>-1||v[f]&&b(e.mods,+f)==-1)&&(i=!1);(0!=e.mods.length||v[16]||v[18]||v[17]||v[91])&&!i||e.method(a,e)===!1&&(a.preventDefault?a.preventDefault():a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.cancelBubble&&(a.cancelBubble=!0))}}function f(a){var c,d=a.keyCode,e=b(A,d);if(e>=0&&A.splice(e,1),93!=d&&224!=d||(d=91),d in v){v[d]=!1;for(c in x)x[c]==d&&(h[c]=!1)}}function g(){for(t in v)v[t]=!1;for(t in x)h[t]=!1}function h(a,b,c){var d,e;d=p(a),void 0===c&&(c=b,b="all");for(var f=0;f1&&(e=q(a),a=[a[a.length-1]]),a=a[0],a=z(a),a in u||(u[a]=[]),u[a].push({shortcut:d[f],scope:b,method:c,key:d[f],mods:e})}function i(a,b){var d,e,f,g,h,i=[];for(d=p(a),g=0;g1&&(i=q(e),a=e[e.length-1]),a=z(a),void 0===b&&(b=n()),!u[a])return;for(f=0;fg||g>h+j-e||i+e>f||f>i+k-e)&&(d=1),!!d},findPosition:function(a,b,c){for(var d={index:0,method:"before"},e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=a.length;mf||h&&j>=h||e&&gg?d.h=Math.round(d.w/g):d.w=Math.round(d.h*g)}return~e.indexOf("l")&&(d.l=c.w-d.w),~e.indexOf("t")&&(d.t=c.h-d.h),d}}}}),c("Utils/main",["require","./Sorter","./Resizer"],function(a){var b=function(){var b=a("./Sorter"),c=a("./Resizer");return{name:"Utils",init:function(){return this},Sorter:b,Resizer:c}};return b}),c("Utils",["Utils/main"],function(a){return a}),c("StorageManager/config/config",[],function(){return{id:"gjs-",autosave:1,autoload:1,type:"local",stepsBeforeSave:1,storeComponents:!1,storeStyles:!1,storeHtml:!0,storeCss:!0,checkLocal:!0,params:{},urlStore:"",urlLoad:"",beforeSend:function(a,b){},onComplete:function(a,b){},contentTypeJson:!1}}),c("StorageManager/model/LocalStorage",["backbone"],function(a){return a.Model.extend({defaults:{checkLocal:!0},store:function(a,b){this.checkStorageEnvironment();for(var c in a)localStorage.setItem(c,a[c]);"function"==typeof b&&b()},load:function(a){this.checkStorageEnvironment();for(var b={},c=0,d=a.length;c/im,j=/]*>\s*([\s\S]+)\s*<\/body>/im,k="undefined"!=typeof location&&location.href,l=k&&location.protocol&&location.protocol.replace(/\:/,""),m=k&&location.hostname,n=k&&(location.port||void 0),o={},p=a.config&&a.config()||{};return c={version:"2.0.12",strip:function(a){if(a){a=a.replace(i,"");var b=a.match(j);b&&(a=b[1])}else a="";return a},jsEscape:function(a){return a.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:p.createXhr||function(){var a,b,c;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject)for(b=0;b<3;b+=1){c=h[b];try{a=new ActiveXObject(c)}catch(d){}if(a){h=[c];break}}return a},parseName:function(a){var b,c,d,e=!1,f=a.indexOf("."),g=0===a.indexOf("./")||0===a.indexOf("../");return f!==-1&&(!g||f>1)?(b=a.substring(0,f),c=a.substring(f+1,a.length)):b=a,d=c||b,f=d.indexOf("!"),f!==-1&&(e="strip"===d.substring(f+1),d=d.substring(0,f),c?c=d:b=d),{moduleName:b,ext:c,strip:e}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(a,b,d,e){var f,g,h,i=c.xdRegExp.exec(a);return!i||(f=i[2],g=i[3],g=g.split(":"),h=g[1],g=g[0],!(f&&f!==b||g&&g.toLowerCase()!==d.toLowerCase()||(h||g)&&h!==e))},finishLoad:function(a,b,d,e){d=b?c.strip(d):d,p.isBuild&&(o[a]=d),e(d)},load:function(a,b,d,e){if(e&&e.isBuild&&!e.inlineText)return void d();p.isBuild=e&&e.isBuild;var f=c.parseName(a),g=f.moduleName+(f.ext?"."+f.ext:""),h=b.toUrl(g),i=p.useXhr||c.useXhr;return 0===h.indexOf("empty:")?void d():void(!k||i(h,l,m,n)?c.get(h,function(b){c.finishLoad(a,f.strip,b,d)},function(a){d.error&&d.error(a)}):b([g],function(a){c.finishLoad(f.moduleName+"."+f.ext,f.strip,a,d)}))},write:function(a,b,d,e){if(o.hasOwnProperty(b)){var f=c.jsEscape(o[b]);d.asModule(a+"!"+b,"define(function () { return '"+f+"';});\n")}},writeFile:function(a,b,d,e,f){var g=c.parseName(b),h=g.ext?"."+g.ext:"",i=g.moduleName+h,j=d.toUrl(g.moduleName+h)+".js";c.load(i,d,function(b){var d=function(a){return e(j,a)};d.asModule=function(a,b){return e.asModule(a,j,b)},c.write(a,i,d,f)},f)}},"node"===p.env||!p.env&&"undefined"!=typeof process&&process.versions&&process.versions.node&&!process.versions["node-webkit"]?(d=b.nodeRequire("fs"),c.get=function(a,b,c){try{var e=d.readFileSync(a,"utf8");0===e.indexOf("\ufeff")&&(e=e.substring(1)),b(e)}catch(f){c&&c(f)}}):"xhr"===p.env||!p.env&&c.createXhr()?c.get=function(a,b,d,e){var f,g=c.createXhr();if(g.open("GET",a,!0),e)for(f in e)e.hasOwnProperty(f)&&g.setRequestHeader(f.toLowerCase(),e[f]);p.onXhr&&p.onXhr(g,a),g.onreadystatechange=function(c){var e,f;4===g.readyState&&(e=g.status||0,e>399&&e<600?(f=new Error(a+" HTTP status: "+e),f.xhr=g,d&&d(f)):b(g.responseText),p.onXhrComplete&&p.onXhrComplete(g,a))},g.send(null)}:"rhino"===p.env||!p.env&&"undefined"!=typeof Packages&&"undefined"!=typeof java?c.get=function(a,b){var c,d,e="utf-8",f=new java.io.File(a),g=java.lang.System.getProperty("line.separator"),h=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(f),e)),i="";try{for(c=new java.lang.StringBuffer,d=h.readLine(),d&&d.length()&&65279===d.charAt(0)&&(d=d.substring(1)),null!==d&&c.append(d);null!==(d=h.readLine());)c.append(g),c.append(d);i=String(c.toString())}finally{h.close()}b(i)}:("xpconnect"===p.env||!p.env&&"undefined"!=typeof Components&&Components.classes&&Components.interfaces)&&(e=Components.classes,f=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),g="@mozilla.org/windows-registry-key;1"in e,c.get=function(a,b){var c,d,h,i={};g&&(a=a.replace(/\//g,"\\")),h=new FileUtils.File(a);try{c=e["@mozilla.org/network/file-input-stream;1"].createInstance(f.nsIFileInputStream),c.init(h,1,0,!1),d=e["@mozilla.org/intl/converter-input-stream;1"].createInstance(f.nsIConverterInputStream),d.init(c,"utf-8",c.available(),f.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),d.readString(c.available(),i),d.close(),c.close(),b(i.value)}catch(j){throw new Error((h&&h.path||"")+": "+j)}}),c}),c("text!DeviceManager/template/devices.html",[],function(){return'
<%= deviceLabel %>
\n
\n \n \n \n
\n
\n
\n
\n'}),c("DeviceManager/view/DevicesView",["backbone","text!./../template/devices.html"],function(a,b){return a.View.extend({template:_.template(b),events:{change:"updateDevice"},initialize:function(a){this.config=a.config||{},this.em=this.config.em,this.ppfx=this.config.pStylePrefix||"",this.events["click ."+this.ppfx+"add-trasp"]=this.startAdd,this.listenTo(this.em,"change:device",this.updateSelect),this.delegateEvents()},startAdd:function(){},updateDevice:function(){var a=this.em;if(a){var b=this.devicesEl,c=b?b.val():"";a.set("device",c)}},updateSelect:function(){var a=this.em,b=this.devicesEl;if(a&&a.getDeviceModel&&b){var c=a.getDeviceModel(),d=c?c.get("name"):"";b.val(d)}},getOptions:function(){var a="";return this.collection.each(function(b){var c=b.get("name");a+='"}),a},render:function(){var a=this.ppfx;return this.$el.html(this.template({ppfx:a,deviceLabel:this.config.deviceLabel})),this.devicesEl=this.$el.find("."+a+"devices"),this.devicesEl.append(this.getOptions()),this.el.className=a+"devices-c",this}})}),c("DeviceManager/main",["require","./config/config","./model/Devices","./view/DevicesView"],function(a){return function(){var b,c,d={},e=a("./config/config"),f=a("./model/Devices"),g=a("./view/DevicesView");return{name:"DeviceManager",init:function(a){d=a||{};for(var h in e)h in d||(d[h]=e[h]);return b=new f(d.devices),c=new g({collection:b,config:d}),this},add:function(a,c,d){var e=d||{};return e.name=a,e.width=c,b.add(e)},get:function(a){return b.get(a)},getAll:function(){return b},render:function(){return c.render().el}}}}),c("DeviceManager",["DeviceManager/main"],function(a){return a}),c("Parser/config/config",[],function(){return{textTags:["br","b","i","u"]}}),c("Parser/model/ParserCss",["require"],function(a){return function(a){return{parseSelector:function(a){for(var b=[],c=[],d=a.split(","),e=0,f=d.length;e\n
<%= label %>
\n
\n \n
\n \n \n \n
\n
\n
\n
\n
\n
\n\n
\n
\n \n \n
\n
\n
Selected
\n
\n
\n
\n'}),c("text!SelectorManager/template/classTag.html",[],function(){return'\n \n />\n \n'}),c("SelectorManager/view/ClassTagView",["backbone","text!./../template/classTag.html"],function(a,b){return a.View.extend({template:_.template(b),events:{},initialize:function(a){this.config=a.config||{},this.coll=a.coll||null,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.inputProp="readonly",this.target=this.config.em,this.className=this.pfx+"tag",this.closeId=this.pfx+"close",this.chkId=this.pfx+"checkbox",this.labelId=this.pfx+"tag-label",this.events["click #"+this.closeId]="removeTag",this.events["click #"+this.chkId]="changeStatus",this.events["dblclick #"+this.labelId]="startEditTag",this.events["keypress #"+this.labelId+" input"]="updateInputLabel",this.events["blur #"+this.labelId+" input"]="endEditTag",this.listenTo(this.model,"change:active",this.updateStatus),this.delegateEvents()},startEditTag:function(){this.$labelInput.prop(this.inputProp,!1)},endEditTag:function(){var a=this.$labelInput.val(),b=this.model.escapeName(a);if(this.target){var c=this.target.get("SelectorManager");c&&(c.get(b)?this.$labelInput.val(this.model.get("label")):this.model.set({name:b,label:a}))}this.$labelInput.prop(this.inputProp,!0)},changeStatus:function(){this.model.set("active",!this.model.get("active")),this.target.trigger("targetClassUpdated")},removeTag:function(a){var b=this.target.get("selectedComponent");b&&b.get("classes").remove(this.model),this.coll&&(this.coll.remove(this.model),this.target.trigger("targetClassRemoved")),this.remove()},updateStatus:function(){this.$chk||(this.$chk=this.$el.find("#"+this.pfx+"checkbox")),this.model.get("active")?(this.$chk.removeClass("fa-circle-o").addClass("fa-dot-circle-o"),this.$el.removeClass("opac50")):(this.$chk.removeClass("fa-dot-circle-o").addClass("fa-circle-o"),this.$el.addClass("opac50"))},updateInputLabel:function(){this.$labelInput||(this.$labelInput=this.$el.find("input"));var a=this.$labelInput.val().length-1;a=a<1?1:a,this.$labelInput.attr("size",a)},render:function(){return this.$el.html(this.template({label:this.model.get("label"),pfx:this.pfx,ppfx:this.ppfx,inputProp:this.inputProp})),this.updateStatus(),this.$el.attr("class",this.className),this.updateInputLabel(),this}})}),c("SelectorManager/view/ClassTagsView",["backbone","text!./../template/classTags.html","./ClassTagView"],function(a,b,c){return a.View.extend({template:_.template(b),events:{},initialize:function(a){this.config=a.config||{},this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.className=this.pfx+"tags",this.addBtnId=this.pfx+"add-tag",this.newInputId=this.pfx+"new",this.stateInputId=this.pfx+"states",this.stateInputC=this.pfx+"input-c",this.states=this.config.states||[],this.events["click #"+this.addBtnId]="startNewTag",this.events["blur #"+this.newInputId]="endNewTag",this.events["keyup #"+this.newInputId]="onInputKeyUp",this.events["change #"+this.stateInputId]="stateChanged",this.target=this.config.em,this.listenTo(this.target,"change:selectedComponent",this.componentChanged),this.listenTo(this.target,"targetClassUpdated",this.updateSelector),this.listenTo(this.collection,"add",this.addNew),this.listenTo(this.collection,"reset",this.renderClasses),this.listenTo(this.collection,"remove",this.tagRemoved),this.delegateEvents()},tagRemoved:function(a){this.updateStateVis()},getStateOptions:function(){for(var a="",b=0;b'+this.states[b].label+"";return a},addNew:function(a){this.addToClasses(a)},startNewTag:function(a){this.$addBtn.hide(),this.$input.show().focus()},endNewTag:function(a){this.$addBtn.show(),this.$input.hide().val("")},onInputKeyUp:function(a){13===a.keyCode?this.addNewTag(this.$input.val()):27===a.keyCode&&this.endNewTag()},componentChanged:function(a){this.compTarget=this.target.get("selectedComponent"),this.compTarget&&this.getStates().val(this.compTarget.get("state"));var b=this.compTarget?this.compTarget.get("classes").models:[];this.collection.reset(b),this.updateStateVis()},updateStateVis:function(){this.collection.length?this.getStatesC().css("display","block"):this.getStatesC().css("display","none"),this.updateSelector()},updateSelector:function(){if(this.compTarget=this.target.get("selectedComponent"),this.compTarget&&this.compTarget.get){var a="",b=this.compTarget.get("classes");b.each(function(b){b.get("active")&&(a+="."+b.get("name"))});var c=this.compTarget.get("state");a=c?a+":"+c:a;var d=this.el.querySelector("#"+this.pfx+"sel");d&&(d.innerHTML=a)}},stateChanged:function(a){this.compTarget&&(this.compTarget.set("state",this.$states.val()),this.target&&this.target.trigger("targetStateUpdated"),this.updateSelector())},addNewTag:function(a){if(a){if(this.target){var b=this.target.get("SelectorManager"),c=b.add(a);if(this.compTarget){var d=this.compTarget.get("classes"),e=d.length;d.add(c);var f=d.length;this.collection.add(c),f>e&&this.target.trigger("targetClassAdded"),this.updateStateVis()}}this.endNewTag()}},addToClasses:function(a,b){var d=b||null,e=new c({model:a,config:this.config,coll:this.collection}),f=e.render().el;return d?d.appendChild(f):this.getClasses().append(f),f},renderClasses:function(){var a=document.createDocumentFragment();return this.collection.each(function(b){this.addToClasses(b,a)},this),this.getClasses()&&this.getClasses().empty().append(a),this},getClasses:function(){return this.$classes||(this.$classes=this.$el.find("#"+this.pfx+"tags-c")),this.$classes},getStates:function(){return this.$states||(this.$states=this.$el.find("#"+this.stateInputId)),this.$states},getStatesC:function(){return this.$statesC||(this.$statesC=this.$el.find("#"+this.stateInputC)),this.$statesC},render:function(){return this.$el.html(this.template({label:this.config.label,statesLabel:this.config.statesLabel,pfx:this.pfx,ppfx:this.ppfx})),this.$input=this.$el.find("input#"+this.newInputId),this.$addBtn=this.$el.find("#"+this.addBtnId),this.$classes=this.$el.find("#"+this.pfx+"tags-c"),this.$states=this.$el.find("#"+this.stateInputId),this.$statesC=this.$el.find("#"+this.stateInputC),this.$states.append(this.getStateOptions()),this.renderClasses(),this.$el.attr("class",this.className),this}})}),c("SelectorManager/main",["require","./config/config","./model/Selectors","./view/ClassTagsView"],function(a){return function(b){var c=b||{},d=a("./config/config");Selectors=a("./model/Selectors"),ClassTagsView=a("./view/ClassTagsView");var e,f;return{name:"SelectorManager",init:function(a){c=a||{};for(var b in d)b in c||(c[b]=d[b]);var g=c.pStylePrefix;return g&&(c.stylePrefix=g+c.stylePrefix),e=new Selectors(c.selectors),f=new ClassTagsView({collection:e,config:c}),this},add:function(a,b){var c=b||{};return c.name=a.name||a,e.add(c)},get:function(a){return e.where({name:a})[0]},getAll:function(){return e},render:function(a){if(a){var b=new ClassTagsView({collection:new Selectors(a),config:c});return b.render().el}return f.render().el}}}}),c("SelectorManager",["SelectorManager/main"],function(a){return a}),c("ModalDialog/config/config",[],function(){return{stylePrefix:"mdl-",title:"",content:"",backdrop:!0}}),c("ModalDialog/model/Modal",["backbone"],function(a){return a.Model.extend({defaults:{title:"",content:"",open:!1}})}),c("text!ModalDialog/template/modal.html",[],function(){return'
\n
\n
<%= title %>
\n
\n
\n
\n
<%= content %>
\n
\n
\n
\n
\n\n'; @@ -11,7 +11,7 @@ a.composing&&(a.composing.range.clear(),a.composing.range=b.markText(a.composing a.registerHelper("hintWords","css",x),a.defineMIME("text/css",{documentTypes:e,mediaTypes:g,mediaFeatures:i,mediaValueKeywords:k,propertyKeywords:m,nonStandardPropertyKeywords:o,fontProperties:q,counterDescriptors:s,colorKeywords:u,valueKeywords:w,tokenHooks:{"/":function(a,b){return!!a.eat("*")&&(b.tokenize=c,c(a,b))}},name:"css"}),a.defineMIME("text/x-scss",{mediaTypes:g,mediaFeatures:i,mediaValueKeywords:k,propertyKeywords:m,nonStandardPropertyKeywords:o,colorKeywords:u,valueKeywords:w,fontProperties:q,allowNested:!0,tokenHooks:{"/":function(a,b){return a.eat("/")?(a.skipToEnd(),["comment","comment"]):a.eat("*")?(b.tokenize=c,c(a,b)):["operator","operator"]},":":function(a){return!!a.match(/\s*\{/)&&[null,"{"]},$:function(a){return a.match(/^[\w-]+/),a.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(a){return!!a.eat("{")&&[null,"interpolation"]}},name:"css",helperType:"scss"}),a.defineMIME("text/x-less",{mediaTypes:g,mediaFeatures:i,mediaValueKeywords:k,propertyKeywords:m,nonStandardPropertyKeywords:o,colorKeywords:u,valueKeywords:w,fontProperties:q,allowNested:!0,tokenHooks:{"/":function(a,b){return a.eat("/")?(a.skipToEnd(),["comment","comment"]):a.eat("*")?(b.tokenize=c,c(a,b)):["operator","operator"]},"@":function(a){return a.eat("{")?[null,"interpolation"]:!a.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)&&(a.eatWhile(/[\w\\\-]/),a.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"}),a.defineMIME("text/x-gss",{documentTypes:e,mediaTypes:g,mediaFeatures:i,propertyKeywords:m,nonStandardPropertyKeywords:o,fontProperties:q,counterDescriptors:s,colorKeywords:u,valueKeywords:w,supportsAtComponent:!0,tokenHooks:{"/":function(a,b){return!!a.eat("*")&&(b.tokenize=c,c(a,b))}},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){var d=a.match(c(b));return d?/^\s*(.*?)\s*$/.exec(d[2])[1]:""}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\s\/]/.test(d.current())&&(h=f.htmlState.tagName&&f.htmlState.tagName.toLowerCase())&&k.hasOwnProperty(h))f.inTag=h+" ";else if(f.inTag&&m&&/>$/.test(d.current())){var n=/^([\S]+) (.*)/.exec(f.inTag);f.inTag=null;var o=">"==d.current()&&g(k[n[1]],n[2]),p=a.getMode(c,o),q=e(n[1],!0),r=e(n[1],!1);f.token=function(a,c){return a.match(q,!1)?(c.token=i,c.localState=c.localMode=null,null):b(a,r,c.localMode.token(a,c.localState))},f.localMode=p,f.localState=a.startState(p,j.indent(f.htmlState,""))}else f.inTag&&(f.inTag+=d.current(),d.eol()&&(f.inTag+=" "));return l}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 b=a.startState(j);return{token:i,inTag:null,localMode:null,localState:null,htmlState:b}},copyState:function(b){var c;return b.localState&&(c=a.copyState(b.localMode,b.localState)),{token:b.token,inTag:b.inTag,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)&&(/^[;{}]$/.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)),!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\n\t
<%= label %>
\n\t
\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/JsGenerator","./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/JsGenerator"),h=a("./model/CodeMirrorEditor"),i=a("./view/EditorView"),j={},k={},l={},m={};return{getConfig:function(){return b},config:b,EditorView:i,name:"CodeManager",init:function(a){b=a||{};for(var i in c)i in b||(b[i]=c[i]);var j=b.pStylePrefix;return j&&(b.stylePrefix=j+b.stylePrefix),k.html=new d,k.css=new e,k.json=new f,k.js=new g,m.CodeMirror=new h,this},onLoad:function(){this.loadDefaultGenerators().loadDefaultViewers()},addGenerator:function(a,b){return j[a]=b,this},getGenerator:function(a){return j[a]||null},getGenerators:function(){return j},addViewer:function(a,b){return l[a]=b,this},getViewer:function(a){return l[a]||null},getViewers:function(){return l},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 k)this.addGenerator(a,k[a]);return this},loadDefaultViewers:function(){for(var a in m)this.addViewer(a,m[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-tm",g="open-layers",h="open-blocks",i="fullscreen",j="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:j,className:"fa fa-eye",command:j,context:j,stopDefaultCommand:1,attributes:{title:"Preview"}},{id:i,className:"fa fa-arrows-alt",command:i,context:i,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-cog",command:f,attributes:{title:"Settings"}},{id:g,className:"fa fa-bars",command:g,attributes:{title:"Open Layer Manager"}},{id:h,className:"fa fa-th-large",command:h,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&&"string"==typeof c?a=this.commands.get(c):null!==c&&"object"==typeof c?a=c:"function"==typeof c&&(a={run: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&&(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&&(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"},{command:"insertHTML",title:"Link","class":"fa fa-link",args:'${content}'}]}}),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(),g.trigger("change")},j=function(){var a=window.getSelection();if(a.getRangeAt&&a.rangeCount)return a.getRangeAt(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();var b=g.get(0).ownerDocument,d=a(this),e=d.data(c.commandRole),f=d.data("args");f?(f=f.replace("${content}",b.getSelection()),i(e,f)):b.execCommand(e),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)),k()}),b.find("input[type=text]"+d,", select"+d).on("webkitspeechchange change",function(){var b=this.value;this.value="",l(),b&&(g.focus(),i(a(this).data(c.commandRole),b)),k()}).on("focus",function(){var b=a(this);b.data(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.ppfx=this.config.pStylePrefix||"",this.className=this.config.stylePrefix+"btn "+this.model.get("class")},render:function(){return this.$el.addClass(this.className),this}})}),c("RichTextEditor/view/CommandButtonSelectView",["backbone","./CommandButtonView"],function(a,b){return b.extend({initialize:function(a,c){b.prototype.initialize.apply(this,arguments)},getInput:function(){var a=this.model;if(!this.input){var b=a.get("command"),c='",this.input=$(c)}return this.input},getInputCont:function(){var a=this.getInput(),b=this.ppfx,c=$('
');return c.append(a)},render:function(){return b.prototype.render.apply(this,arguments),this.$el.html(this.getInputCont()),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=a.get("args"),h={title:a.get("title"),"data-edit":a.get("command")};g&&(h["data-args"]=g);var i=new f({model:a,attributes:h},this.config),j=i.render().el;e?e.appendChild(j):this.$el.append(j)},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={},g=a("./config/config"),h=(a("./view/TextEditorView"),a("./model/CommandButtons")),i=a("./view/CommandButtonsView");return{customRte:null,name:"rte",init:function(a){e=this,f=a||{};for(var j in g)j in f||(f[j]=g[j]);var k=f.pStylePrefix;return k&&(f.stylePrefix=k+f.stylePrefix),b=f.stylePrefix,d=new h(f.commands),c=new i({collection:d,config:f}),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(){var a="px",b=f.em.get("Canvas"),d=b.getTargetToElementDim(c.el,this.lastEl,{event:"rteToolbarPosUpdate"}),e=c.el.style;e.top=d.top+a,e.left=d.left+a},attach:function(a,b){this.lastEl=a.el;var d=a.getChildrenContainer(),e=this.customRte;return e?b=e.enable(d,b):$(d).wysiwyg({}).focus(),this.show(),f.em&&(setTimeout(this.udpatePosition.bind(this),0),f.em.off("change:canvasOffset",this.udpatePosition,this),f.em.on("change:canvasOffset",this.udpatePosition,this),f.em.off("canvasScroll",this.udpatePosition,this),f.em.on("canvasScroll",this.udpatePosition,this)),c.$el.on("mousedown",this.disableProp),b},detach:function(a,b){var d=this.customRte,e=a.getChildrenContainer();d?(a.model.set("content",e.innerHTML),d.disable(e,b)):$(e).wysiwyg("destroy"),this.hide(),c.$el.off("mousedown",this.disableProp)},focus:function(a,b){var c=this.customRte,d=a.getChildrenContainer();c?c.focus&&c.focus(d,b):this.attach(a)},show:function(){var a=c.el.style;a.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:[],textNoElement:"Select an element before using Style Manager",hideNotStylable:!0}}),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","require"],function(a,b,c){return a.Model.extend({defaults:{name:"",property:"",type:"",units:[],unit:"",defaults:"",info:"",value:"",icon:"",preview:!1,detached:!1,visible:!0,functionName:"",properties:[],layers:[],list:[],fixedValues:["initial","inherit"]},initialize:function(a){var d=this.get("type"),e=this.get("name"),f=this.get("property"),g=this.get("properties");if(e||this.set("name",f.charAt(0).toUpperCase()+f.slice(1).replace(/-/g," ")),g.length){var h=c("./Properties");this.set("properties",new h(g))}switch(d){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;c\n\t
\n\t\t<%= label %>\n\t
\n
'}),c("text!StyleManager/templates/propertyInput.html",[],function(){return'
\n\tinput-holder\'>\n
\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.em=this.config.em,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.sector=this.model.collection&&this.model.collection.sector,this.model.get("value")||this.model.set("value",this.model.get("defaults")),this.listenTo(this.propTarget,"update",this.targetUpdated),this.listenTo(this.model,"destroy remove",this.remove),this.listenTo(this.model,"change:value",this.valueChanged),this.listenTo(this.model,"targetUpdated",this.targetUpdated),this.listenTo(this.model,"change:visible",this.updateVisibility)},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.checkVisibility(),this.getTarget()&&(this.sameValue()||this.renderInputRequest())},checkVisibility:function(){this.config.hideNotStylable&&(this.isTargetStylable()&&this.isComponentStylable()?this.show():this.hide(),this.sector&&this.sector.trigger("updateVisibility"))},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(),e=this.config.em,f=this.model;if(this.$input&&this.setValue(d),this.getTarget()&&this.isTargetStylable()&&this.isComponentStylable()){value=this.getValueForTarget();var g=f.get("functionName");g&&(value=g+"("+value+")");var h=this.getTarget(),i=this.onChange;i&&"function"==typeof i?i(h,this,c):this.updateTargetStyle(value,null,c),e&&(e.trigger("component:update",f),e.trigger("component:styleUpdate",f),e.trigger("component:styleUpdate:"+f.get("property"),f))}},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},isComponentStylable:function(){var a=this.em,b=a&&a.get("selectedComponent");if(!b)return!0;var c=b.get("stylable");return c instanceof Array&&(c=_.indexOf(c,this.property)>=0),c},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})},updateVisibility:function(){this.el.style.display=this.model.get("visible")?"block":"none"},show:function(){this.model.set("visible",1)},hide:function(){this.model.set("visible",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!Abstract/ui/templates/inputNumber.html",[],function(){return'input-holder\'>\nfield-units\'>\n
\n\t
\n\t
\n
\n'}),c("Abstract/ui/InputNumber",["backbone","text!./templates/inputNumber.html"],function(a,b){return a.View.extend({events:{},template:_.template(b),initialize:function(a){_.bindAll(this,"moveIncrement","upIncrement");var b=a||{},c=b.ppfx||"",d=b.contClass||c+"field";this.ppfx=c,this.docEl=$(document),this.inputCls=c+"input-number",this.unitCls=c+"input-unit",this.contClass=d,this.events["click ."+c+"field-arrow-u"]="upArrowClick",this.events["click ."+c+"field-arrow-d"]="downArrowClick",this.events["mousedown ."+c+"field-arrows"]="downIncrement",this.events["change ."+this.inputCls]="handleChange",this.events["change ."+this.unitCls]="handleUnitChange",this.listenTo(this.model,"change:unit change:value",this.handleModelChange),this.delegateEvents()},setValue:function(a,b){var c=b||{},d=this.validateInputValue(a,{deepCheck:1}),e={value:d.value};(d.unit||d.force)&&(e.unit=d.unit),this.model.set(e,c),c.silent&&this.handleModelChange()},handleChange:function(a){a.stopPropagation(),this.setValue(this.getInputEl().value)},handleUnitChange:function(a){a.stopPropagation();var b=this.getUnitEl().value;this.model.set("unit",b)},handleModelChange:function(){var a=this.model;this.getInputEl().value=a.get("value");var b=this.getUnitEl();b&&(b.value=a.get("unit"))},getInputEl:function(){return this.inputEl||(this.inputEl=$("",{type:"text","class":this.inputCls,placeholder:this.model.get("defaults")})),this.inputEl.get(0)},getUnitEl:function(){if(!this.unitEl){var a=this.model,b=a.get("units")||[];if(b.length){var c='",this.unitEl=$(c)}}return this.unitEl&&this.unitEl.get(0)},upArrowClick:function(){var a=this.model.get("value");a=isNaN(a)?1:parseInt(a,10)+1;var b=this.validateInputValue(a);this.model.set("value",b.value)},downArrowClick:function(){var a=this.model.get("value");a=isNaN(a)?0:parseInt(a,10)-1;var b=this.validateInputValue(a);this.model.set("value",b.value)},downIncrement:function(a){a.preventDefault(),this.moved=0;var b=this.model.get("value");b=isNaN(b)?0:parseInt(b,10);var c={y:a.pageY,val:b};this.docEl.mouseup(c,this.upIncrement),this.docEl.mousemove(c,this.moveIncrement)},moveIncrement:function(a){this.moved=1;var b=parseInt(a.data.val-a.pageY+a.data.y,10);return this.prValue=this.validateInputValue(b).value,this.model.set("value",this.prValue,{avoidStore:1}),!1},upIncrement:function(a){if(this.docEl.off("mouseup",this.upIncrement),this.docEl.off("mousemove",this.moveIncrement),this.prValue&&this.moved){var b=this.prValue-1;this.model.set("value",b,{avoidStore:1}).set("value",b+1)}},validateInputValue:function(a,b){var c=0,d=b||{},e=this.model,f=a||e.get("defaults"),g=e.get("units")||[],h=e.get("unit")||g.length&&g[0]||"",i=e.get("max"),j=e.get("min");if(d.deepCheck){var k=e.get("fixedValues")||[];if(f){var l=new RegExp("^"+k.join("|"),"g");if(k.length&&l.test(f))f=f.match(l)[0],h="",c=1;else{var m=f+"";f+="",f=parseFloat(f.replace(",",".")),f=isNaN(f)?e.get("defaults"):f;var n=m.replace(f,"");_.indexOf(g,n)>=0&&(h=n)}}}return"undefined"!=typeof i&&""!==i&&(f=f>i?i:f),"undefined"!=typeof j&&""!==j&&(f=f\n\tinput-holder\'>\n
\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,b=this.ppfx,c=b+"radio-item-label",d=this.property;if(!this.$input&&this.list&&this.list.length){var e="";_.each(this.list,function(f){var g=f.className?f.className+" "+a+"icon "+c:"",h=d+"-"+f.value,i=f.name?f.name:f.value;titleAttr=f.title?'title="'+f.title+'"':"",e+='
"}),this.input=e,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\tinput-holder\'>\n\t
\n\t\t
\n\t
\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;if(!this.$input){var b="",this.input=b,this.$input=$(this.input),this.$el.find("#"+a+"input-holder").html(this.$input)}this.setValue(this.componentValue,0)}})}),c("text!Abstract/ui/templates/input.html",[],function(){return"\n"}),c("Abstract/ui/Input",["backbone","text!./templates/input.html"],function(a,b){return a.View.extend({events:{change:"handleChange"},template:_.template(b),initialize:function(a){var b=a||{},c=b.ppfx||"";this.target=b.target||{},this.inputClass=c+"field",this.inputHolderClass=c+"input-holder",this.ppfx=c,this.listenTo(this.model,"change:value",this.handleModelChange)},handleChange:function(a){a.stopPropagation(),this.setValue(this.getInputEl().value)},setValue:function(a,b){var c=b||{},d=this.model;d.set({value:a||d.get("defaults")},c),c.silent&&this.handleModelChange()},handleModelChange:function(){this.getInputEl().value=this.model.get("value")},getInputEl:function(){return this.inputEl||(this.inputEl=$("",{type:"text","class":this.inputCls,placeholder:this.model.get("defaults")})),this.inputEl.get(0)},render:function(){var a=this.$el;return a.addClass(this.inputClass),a.html(this.template({holderClass:this.inputHolderClass,ppfx:this.ppfx})),a.find("."+this.inputHolderClass).html(this.getInputEl()),this}})}),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]&&a.inArray(c,qa)===-1)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;bj&&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;b<=6;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+(b1&&(c-=1),c<1/6?a+6*(b-a)*c:c<.5?b:c<2/3?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=c<.5?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+(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)||a<0||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&&a.indexOf(".")!=-1&&1===parseFloat(a)}function B(a){return"string"==typeof a&&a.indexOf("%")!=-1}function C(a){return 1==a.length?"0"+a:""+a}function D(a){return a<=1&&(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"}}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)&&(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()},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!Abstract/ui/templates/inputColor.html",[],function(){return'
input-holder\'>
\n
\n\t
\n\t\t
\n\t
\n
\n'}),c("Abstract/ui/InputColor",["backbone","./Input","Spectrum","text!./templates/inputColor.html"],function(a,b,c,d){return b.extend({template:_.template(d),initialize:function(a){b.prototype.initialize.apply(this,arguments);var c=this.ppfx;this.colorCls=c+"field-color-picker",this.inputClass=c+"field "+c+"field-color",this.colorHolderClass=c+"field-colorp-c",this.listenTo(this.model,"change:value",this.handleModelChange)},handleModelChange:function(){b.prototype.handleModelChange.apply(this,arguments);var a=this.model.get("value"),c=this.getColorEl();a="none"===a?"#fff":a,c.spectrum("set",a),c.get(0).style.backgroundColor=a},getColorEl:function(){if(!this.colorEl){var a=this.model,b=$("
",{"class":this.colorCls}),c=b.get(0).style,d=this.target&&this.target.config?this.target.config.el:"";b.spectrum({appendTo:d||"body",maxSelectionSize:8,showPalette:!0,showAlpha:!0,chooseText:"Ok",cancelText:"⨯",palette:[],move:function(a){var b=1==a.getAlpha()?a.toHexString():a.toRgbString();c.backgroundColor=b},change:function(b){var d=1==b.getAlpha()?b.toHexString():b.toRgbString();d=d.replace(/ /g,""),c.backgroundColor=d,a.set("value",d)}}),this.colorEl=b}return this.colorEl},render:function(){return b.prototype.render.apply(this,arguments),this.$el.find("."+this.colorHolderClass).html(this.getColorEl()),this}})}),c("StyleManager/view/PropertyColorView",["backbone","./PropertyView","Abstract/ui/InputColor"],function(a,b,c){return b.extend({renderTemplate:function(){},renderInput:function(){if(!this.input){var a=new c({target:this.target,model:this.model,ppfx:this.ppfx});this.input=a.render(),this.$el.append(this.input.$el),this.$input=this.input.inputEl,this.$color=this.input.colorEl}this.setValue(this.componentValue)},setValue:function(a){this.input.setValue(a,{silent:1})}})}),c("text!StyleManager/templates/propertyFile.html",[],function(){return'
\n\t
input-holder\'>\n\t\t
\n\t\t\t\n\t\t
\n\t\t
\n\t
\n\t
\n\t\t
\n\t\t
\n\t
\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\tinput-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&&(this.$input||(this.$input=$("",{value:0,type:"hidden"})),this.props||(this.props=this.model.get("properties")),!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 b=d("./PropertiesView"),c=new b(this.getPropsConfig());this.$props=c.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\t\n\t\n
\n
"}),c("text!StyleManager/templates/layer.html",[],function(){return'
\n \n
\n
<%= label %>
\n
\n\t
\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),g<-d&&(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.ppfx=this.config.pStylePrefix||"",this.className=this.pfx+"layers "+this.ppfx+"field",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"),d<0?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.checkVisibility(),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;f",{"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.listenTo(this.model,"updateVisibility",this.updateVisibility),this.events["click ."+this.pfx+"title"]="toggle",this.delegateEvents()},updateVisibility:function(){var a;this.model.get("properties").each(function(b){b.get("visible")&&(a=1)}),this.el.style.display=a?"block":"none"},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 targetStyleUpdated change:device",this.targetUpdated)},addTo:function(a){this.addToCollection(a)},targetUpdated:function(){var a=this.target.get("selectedComponent");if(a){var b=this.target.get("Config").devicePreviewMode,c=a.get("classes"),d=this.propTarget,e=this.target.getDeviceModel(),f=b?"":a.get("state"),g=e&&!b?"(max-width: "+e.get("width")+")":"";if(d.helper=null,c.length){var h=this.target.get("CssComposer"),i=_.filter(c.models,function(a){return a.get("active")}),j=h.get(i,f,g);if(j||(j=h.add(i,f,g),j.set("style",a.get("style")),a.set("style",{})),f){var k=this.target.get("SelectorManager"),l=k.add("hc-state"),m=h.get([l]);m?(h.getAll().remove(m),h.getAll().add(m)):m=h.add([l]),m.set("style",j.get("style")),d.helper=m}return d.model=j,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",getConfig:function(){return d},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},getModelToStyle:function(a){var b=a.get("classes");if(d.em&&b&&b.length){var c=d.em.get("Config").devicePreviewMode,e=d.em.getDeviceModel(),f=c?"":a.get("state"),g=e&&!c?e.get("width"):"",h=d.em.get("CssComposer"),i=_.filter(b.models,function(a){return a.get("active")}),j=h.get(i,f,g);if(j)return j}return a},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;e\n
\n
\n
\n
\n\t
<%= name %>
\n\t
<%= dim %>
\n
\n
\n
'}),c("AssetManager/view/AssetImageView",["./AssetView","text!./../template/assetImage.html"],function(a,b){return a.extend({events:{click:"handleClick",dblclick:"handleDblClick"},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()},handleClick:function(){var a=this.config.onClick,b=this.model;b.collection.trigger("deselectAll"),this.$el.addClass(this.pfx+"highlight"),"function"==typeof a?a(b):this.updateTarget(b.get("src"))},handleDblClick:function(){var a=this.config.onDblClick,b=this.model;"function"==typeof a?a(b):this.updateTarget(b.get("src"));var c=b.collection.onSelect;"function"==typeof c&&c(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\t
<%= title %>
\n\t multiple/>\n\t
\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
\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();if(c)return this.collection.addImg(c,{at:0}),this.getAssetsEl().scrollTop=0,b.value="",this},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,btnText:this.config.addBtnText})),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",addBtnText:"Add image"}}),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},onClick:function(a){e.onClick=a},onDblClick:function(a){e.onDblClick=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:{},selectorsAdd:"",style:{},mediaText:"",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("styles")>=0&&(c.styles=JSON.stringify(b)),a||d.stm.store(c),c}},add:function(a,c,d,e){var g=c||"",h=d||"",i=e||{},j=this.get(a,g,h);return j?j:(i.state=g,i.mediaText=h,i.selectors="",j=new f(i),j.get("selectors").add(a),b.add(j),j)},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},addCollection:function(a,b){for(var c=b||{},e=[],f=a instanceof Array?a:[a],g=0,h=f.length;g=0&&this.set("void",!0),this.opt=e,this.sm=e?e.sm||{}:{},this.config=a||{},this.defaultC=this.config.components||[],this.defaultCl=this.normalizeClasses(this.get("classes")||this.config.classes||[]),this.components=new b(this.defaultC,e),this.components.parent=this,this.listenTo(this,"change:script",this.scriptUpdated),this.set("attributes",this.get("attributes")||{}),this.set("components",this.components),this.set("classes",new c(this.defaultCl));var f=new d;f.setTarget(this),f.add(this.get("traits")),this.set("traits",f),this.initToolbar();var g=["stylable"];g.forEach(function(a){var b=this.get(a);if("string"==typeof b){var c=b.split(",").map(function(a){return a.trim()});this.set(a,c)}},this),this.init()},init:function(){},scriptUpdated:function(){this.set("scriptUpdated",1)},initToolbar:function(){var a=this;if(!a.get("toolbar")){var b=[];a.get("draggable")&&b.push({attributes:{"class":"fa fa-arrows"},command:"tlb-move"}),a.get("copyable")&&b.push({attributes:{"class":"fa fa-clone"},command:"tlb-clone"}),a.get("removable")&&b.push({attributes:{"class":"fa fa-trash-o"},command:"tlb-delete"}),a.set("toolbar",b)}},loadTraits:function(a){var b=new d;b.setTarget(this),b.add(a),this.set("traits",b)},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(a){var b=_.clone(this.attributes),c=this.get("components"),d=this.get("traits"),e=this.get("classes");return b.components=[],b.classes=[],b.traits=[],c.each(function(a,c){b.components[c]=a.clone(1)}),d.each(function(a,c){b.traits[c]=a.clone()}),e.each(function(a,c){b.classes[c]=a.get("name")}),b.status="",b.view="",a&&(this.opt.collection=null),new this.constructor(b,this.opt)},getName:function(){if(!this.name){var a=(this.cid.replace(/\D/g,""),this.get("type")),b=this.get("tagName");b="div"==b?"box":b,b=a?a:b,this.name=b.charAt(0).toUpperCase()+b.slice(1)}return this.name},toHTML:function(a){var b="",c=this,d=c.get("tagName"),e=c.get("void"),f="",g="",h=this.getAttrToHTML();for(var i in h){var j=h[i];g+=void 0!==typeof j&&""!==j?" "+i+'="'+j+'"':""}var k="";return c.get("classes").each(function(a){k+=" "+a.get("name")}),k=""!==k?' class="'+k.trim()+'"':"",_.isEmpty(c.get("style"))||(f=' id="'+c.cid+'" '),b+="<"+d+k+f+g+(e?"/":"")+">"+c.get("content"),c.get("components").each(function(a){b+=a.toHTML()}),e||(b+=""),b},getAttrToHTML:function(){var a=this.get("attributes")||{};return delete a.style,a},toJSON:function(){var b=a.Model.prototype.toJSON.apply(this,arguments),c=this.getScriptString();return c&&(b.script=c),b},getScriptString:function(a){var b=a||this.get("script");if("function"==typeof b){var c=b.toString().trim();c=c.replace(/^function\s?\(\)\s?\{/,""),c=c.replace(/\}$/,""),b=c}return b}},{isComponent:function(a){return{tagName:a.tagName?a.tagName.toLowerCase():""}}})}),c("DomComponents/view/ComponentsView",["backbone","require"],function(a,b){return a.View.extend({initialize:function(a){this.opts=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);var c=this.config.em;c&&(c.trigger("add:component",a),c.trigger("component:add",a))},addToCollection:function(a,c,d){this.compView||(this.compView=b("./ComponentView"));for(var e=c||null,f=this.compView,g=this.opts.defaultTypes,h=this.opts.componentTypes,i=a.get("type"),j=0;j=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;b 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","clearOff"),this.config=a.config||{},this.em=this.config.em||{},this.ppfx=this.config.pStylePrefix||"",this.className=this.config.stylePrefix+"canvas",this.listenTo(this.em,"change:canvasOffset",this.clearOff),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,this.em.trigger("canvasScroll")},renderScripts:function(){var a=this.frame,b=this;a.el.onload=function(){function c(d){if(d.length>0){var e=document.createElement("script");e.type="text/javascript",e.src=d.shift(),e.onerror=e.onload=c.bind(null,d),a.el.contentDocument.head.appendChild(e)}else b.renderBody()}var d=b.config.scripts.slice(0);c(d)}},renderBody:function(){var a=this.model.get("frame").get("wrapper"),b=this.config.em;if(a){var c=this.ppfx,d=this.frame.$el.contents().find("body"),e=b.get("CssComposer"),f=b.get("Config");d.append(a.render()).append(e.render());var g=f.protectedCss,h="* {box-sizing: border-box;} body{margin:0;height:auto;background-color:#fff} #wrapper{min-height:100%; overflow:auto}."+c+"dashed :not([contenteditable]) > *{outline: 1px dashed rgba(170,170,170,0.7); outline-offset: -2px}."+c+"comp-selected{outline: 3px solid #3b97e3 !important}."+c+"no-select{user-select: none; -webkit-user-select:none; -moz-user-select: none}."+c+"freezed{opacity: 0.5; pointer-events: none}."+c+"no-pointer{pointer-events: none}."+c+"plh-image{background:#f5f5f5; border:none; height:50px; width:50px; display:block; outline:3px solid #ffca6f; cursor:pointer}."+c+"grabbing{cursor: grabbing; cursor: -webkit-grabbing}* ::-webkit-scrollbar-track {background: rgba(0, 0, 0, 0.1)}* ::-webkit-scrollbar-thumb {background: rgba(255, 255, 255, 0.2)}* ::-webkit-scrollbar {width: 10px}"+(f.canvasCss||"");h+=g||"",d.append(""),d.append(this.getJsContainer()),b.trigger("loaded"),this.frame.el.contentWindow.onscroll=this.onFrameScroll,this.frame.udpateOffset();var i=document,j=this.frame.el.contentDocument;j.addEventListener("keydown",function(a){i.dispatchEvent(new KeyboardEvent(a.type,a))}),j.addEventListener("keyup",function(a){i.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}},clearOff:function(){this.frmOff=null,this.cvsOff=null},getFrameOffset:function(){return this.frmOff||(this.frmOff=this.offset(this.frame.el)),this.frmOff},getCanvasOffset:function(){return this.cvsOff||(this.cvsOff=this.offset(this.el)),this.cvsOff},getElementPos:function(a){var b=this.getFrameOffset(),c=this.getCanvasOffset(),d=this.offset(a),e=d.top+b.top-c.top,f=d.left+b.left-c.left;return{top:e,left:f,height:a.offsetHeight,width:a.offsetWidth}},getPosition:function(){var a=this.frame.el.contentDocument.body,b=this.getFrameOffset(),c=this.getCanvasOffset();return{top:b.top+a.scrollTop-c.top,left:b.left+a.scrollLeft-c.left}},updateScript:function(a){a.scriptContainer||(a.scriptContainer=$("
"),this.getJsContainer().append(a.scriptContainer.get(0)));var b=a.model.cid,c=a.model.get("script"),d="function(){"+c+"}";d="function"==typeof c?c.toString():d,a.el.id=b,a.scriptContainer.html(""),a.scriptContainer.append('")},getJsContainer:function(){return this.jsContainer||(this.jsContainer=$("
",{"class":this.ppfx+"js-cont"}).get(0)),this.jsContainer},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;0===this.config.scripts.length?a.el.onload=this.renderBody:this.renderScripts()}var b=this.ppfx;toolsEl=$("
",{id:b+"tools"}).get(0),this.hlEl=$("
",{"class":b+"highlighter"}).get(0),this.badgeEl=$("
",{"class":b+"badge"}).get(0),this.placerEl=$("
",{"class":b+"placeholder"}).get(0),this.placerIntEl=$("
",{"class":b+"placeholder-int"}).get(0),this.ghostEl=$("
",{"class":b+"ghost"}).get(0),this.toolbarEl=$("
",{"class":b+"toolbar"}).get(0),this.resizerEl=$("
",{"class":b+"resizer"}).get(0),this.offsetEl=$("
",{"class":b+"offset-v"}).get(0),this.fixedOffsetEl=$("
",{"class":b+"offset-fixed-v"}).get(0),this.placerEl.appendChild(this.placerIntEl),toolsEl.appendChild(this.hlEl),toolsEl.appendChild(this.badgeEl),toolsEl.appendChild(this.placerEl),toolsEl.appendChild(this.ghostEl),toolsEl.appendChild(this.toolbarEl),toolsEl.appendChild(this.resizerEl),toolsEl.appendChild(this.offsetEl),toolsEl.appendChild(this.fixedOffsetEl),this.$el.append(toolsEl);var c=this.em.get("rte");return c&&toolsEl.appendChild(c.render()),this.toolsEl=toolsEl,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},getToolbarEl:function(){return f.toolbarEl},getResizerEl:function(){return f.resizerEl},getOffsetViewerEl:function(){return f.offsetEl},getFixedOffsetViewerEl:function(){return f.fixedOffsetEl},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}},getElementPos:function(a){return f.getElementPos(a)},getTargetToElementDim:function(a,b,d){var e=d||{},g=f.getPosition(),h=e.elPos||f.getElementPos(b),i=d.toRight||0,j=e.targetHeight||a.offsetHeight,k=e.targetWidth||a.offsetWidth,l=e.event||null,m=h.top-j,n=h.left;n+=i?h.width:0,n=i?n-k:n;var o=nh.top+h.height?h.top+h.height:p;var q={top:p,left:o,elementTop:h.top,elementLeft:h.left,elementWidth:h.width,elementHeight:h.height,targetWidth:a.offsetWidth,targetHeight:a.offsetHeight,canvasTop:g.top,canvasLeft:g.left};return l&&c.em&&c.em.trigger(l,q),q},getMouseRelativePos:function(a,b){var c=b||{},d=0,e=0,f=c.subWinOffset,g=a.target.ownerDocument,h=g.defaultView||g.parentWindow,i=h.frameElement,j=f?h.pageYOffset:0,k=f?h.pageXOffset:0;if(i){var l=i.getBoundingClientRect();d=l.top||0,e=l.left||0}return{y:a.clientY+d-j,x:a.clientX+e-k}},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("Abstract/view/DomainViews",["backbone"],function(a){return a.View.extend({itemView:"",itemsView:"",itemType:"type",initialize:function(a,b){this.config=b||{}},addTo:function(a){this.add(a)},add:function(a,b){var c=b||null,d=this.itemView,e=a.get(this.itemType);this.itemsView&&this.itemsView[e]&&(d=this.itemsView[e]);var f=new d({model:a,config:this.config},this.config),g=f.render().el;c?c.appendChild(g):this.$el.append(g)},render:function(){var a=document.createDocumentFragment();return this.$el.empty(), -this.collection.length&&this.collection.each(function(b){this.add(b,a)},this),this.$el.append(a),this}})}),c("DomComponents/view/ToolbarButtonView",["backbone"],function(a){return a.View.extend({events:{mousedown:"handleClick"},attributes:function(){return this.model.get("attributes")},initialize:function(a){this.editor=a.config.editor},handleClick:function(){var a=this.model.get("command");"function"==typeof a&&a(this.editor),"string"==typeof a&&this.editor.runCommand(a)},render:function(){var a=this.editor.getConfig();return this.el.className+=" "+a.stylePrefix+"toolbar-item",this}})}),c("DomComponents/view/ToolbarView",["backbone","Abstract/view/DomainViews","./ToolbarButtonView"],function(a,b,c){return b.extend({itemView:c,initialize:function(a){this.config={editor:a.editor||""},this.listenTo(this.collection,"reset",this.render)}})}),c("DomComponents/model/ToolbarButton",["backbone"],function(a){return a.Model.extend({defaults:{command:"",attributes:{}}})}),c("DomComponents/model/Toolbar",["backbone","./ToolbarButton"],function(a,b){return a.Collection.extend({model:b})}),c("Commands/view/SelectComponent",["require","DomComponents/view/ToolbarView","DomComponents/model/Toolbar"],function(a){var b=a("DomComponents/view/ToolbarView"),c=a("DomComponents/model/Toolbar");return{init:function(a){_.bindAll(this,"onHover","onOut","onClick","onKeyPress")},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);var b=this.config.em;b.on("component:update",this.updateAttached,this),b.on("change:canvasOffset",this.updateAttached,this),b.on("change:selectedComponent",this.updateToolbar,this)},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"))},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})}},getCanvasBodyEl:function(){return this.$bodyEl||(this.$bodyEl=$(this.getCanvasBody())),this.$bodyEl},startSelectComponent:function(){this.toggleSelectComponent(1)},stopSelectComponent:function(){this.toggleSelectComponent()},toggleSelectComponent:function(a){var b="*",c=a?"on":"off";this.getCanvasBodyEl()[c]("mouseover",b,this.onHover)[c]("mouseout",b,this.onOut)[c]("click",b,this.onClick);var d=this.getContentWindow();d[c]("scroll",this.onFrameScroll),d[c]("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.hideHighlighter(),this.editorModel.set("selectedComponent",null)}},onHover:function(a){a.stopPropagation();var b=a.target;this.adjScroll||(this.adjScroll=1,this.onFrameScroll(a),this.updateAttached());var c=this.getElementPos(b);this.updateBadge(b,c),this.updateHighlighter(b,c),this.showElementOffset(b,c)},onOut:function(a){a.stopPropagation(),this.hideBadge(),this.hideHighlighter(),this.hideElementOffset()},showElementOffset:function(a,b){var c=$(a),d=c.data("model");d&&"selected"==d.get("status")||this.editor.runCommand("show-offset",{el:a,elPos:b})},hideElementOffset:function(a,b){this.editor.stopCommand("show-offset")},showFixedElementOffset:function(a,b){this.editor.runCommand("show-offset",{el:a,elPos:b,state:"Fixed"})},hideFixedElementOffset:function(a,b){this.editor&&this.editor.stopCommand("show-offset",{state:"Fixed"})},hideHighlighter:function(){this.canvas.getHighlighter().style.display="none"},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)}},updateBadge:function(a,b){var c=$(a);this.cacheEl=a;var d=c.data("model");if(d&&d.get("badgable")){var e=this.getBadge();e.innerHTML=d.getName();var f=e.style,g="px";f.display="block";var h=this.canvas.getCanvasView().getPosition(),i=e?e.offsetHeight:0,j=e?e.offsetWidth:0,k=b.top-i"),e=this.codeMirror.clone().set({label:c,codeName:a,theme:b,input:d[0]}),f=new this.cm.EditorView({model:e,config:this.cm.getConfig()}).render().$el;return e.init(d[0]),{el:e,$el:f}},enable:function(){if(!this.$editors){var a=this.buildEditor("htmlmixed","hopscotch","HTML"),b=this.buildEditor("css","hopscotch","CSS");this.htmlEditor=a.el,this.cssEditor=b.el,this.$editors=$("
",{"class":this.pfx+"export-dl"}),this.$editors.append(a.$el).append(b.$el)}this.modal&&(this.modal.setTitle("Export template"),this.modal.setContent(this.$editors),this.modal.open());var c=this.protCss||"";this.htmlEditor.setContent(this.em.getHtml()),this.cssEditor.setContent(c+this.cm.getCode(this.wrapper,"css",this.cssc)),this.sender&&this.sender.set("active",!1)},stop:function(){}}}),c("Commands/view/SwitchVisibility",[],function(){return{run:function(a){a.Canvas.getBody().className=this.ppfx+"dashed"},stop:function(a){a.Canvas.getBody().className=""}}}),c("Navigator/config/config",[],function(){return{stylePrefix:"nv-",sortable:1,hidable:1,hideTextnode:1,containerId:"navigator",itemClass:"item",itemsClass:"items"}}),c("text!Navigator/template/item.html",[],function(){return'<% if (hidable) { %>\n\t\n<% } %>\n\n
\n
\n \t\n\t\t\n\t\t\n
\n
\n\n
<%= (count ? count : \'\') %>
\n\n
\n\t\n
\n\n
\n'}),c("Navigator/view/ItemView",["backbone","text!./../template/item.html","require"],function(a,b,c){return a.View.extend({template:_.template(b),initialize:function(a){this.opt=a,this.config=a.config,this.em=a.config.em,this.ppfx=this.em.get("Config").stylePrefix,this.sorter=a.sorter||{},this.pfx=this.config.stylePrefix,"undefined"==typeof this.model.get("open")&&this.model.set("open",!1),this.listenTo(this.model.components,"remove add change reset",this.checkChildren),this.listenTo(this.model,"destroy remove",this.remove),this.listenTo(this.model,"change:status",this.updateStatus),this.listenTo(this.model,"change:open",this.updateOpening),this.className=this.pfx+"item no-select",this.editBtnCls=this.pfx+"nav-item-edit",this.inputNameCls=this.ppfx+"nav-comp-name",this.caretCls=this.ppfx+"nav-item-caret",this.titleCls=this.pfx+"title",this.customNameProp="custom-name",this.events={},this.events["click > #"+this.pfx+"btn-eye"]="toggleVisibility",this.events["click ."+this.caretCls]="toggleOpening",this.events["click ."+this.titleCls]="handleSelect",this.events["click ."+this.editBtnCls]="handleEdit",this.events["blur ."+this.inputNameCls]="handleEditEnd",this.$el.data("model",this.model),this.$el.data("collection",this.model.get("components")),a.config.sortable&&(this.events["mousedown > #"+this.pfx+"move"]="startSort"),this.delegateEvents()},handleEdit:function(a){a.stopPropagation();var b=this.getInputName();b.readOnly=!1,b.focus()},handleEditEnd:function(a){a.stopPropagation();var b=this.getInputName();b.readOnly=!0,this.model.set(this.customNameProp,b.value)},getInputName:function(){return this.inputName||(this.inputName=this.el.querySelector("."+this.inputNameCls)),this.inputName},updateOpening:function(){var a=this.opt.opened||{},b=this.model;b.get("open")?(this.$el.addClass("open"),this.$caret.addClass("fa-chevron-down"),a[b.cid]=b):(this.$el.removeClass("open"),this.$caret.removeClass("fa-chevron-down"),delete a[b.cid])},toggleOpening:function(a){a.stopPropagation(),this.model.components.length&&this.model.set("open",!this.model.get("open"))},handleSelect:function(a){a.stopPropagation();var b=this.em;if(b){var c=b.get("selectedComponent");c&&c.set("status",""),this.model.set("status","selected"),b.set("selectedComponent",this.model)}},startSort:function(a){this.sorter&&this.sorter.startSort(a.target)},freeze:function(){this.$el.addClass(this.pfx+"opac50"),this.model.set("open",0)},unfreeze:function(){this.$el.removeClass(this.pfx+"opac50")},updateStatus:function(a){var b=this.model.get("status"),c=this.pfx+"selected",d=this.$el;switch(b){case"selected":d.addClass(c);break;case"moving":break;default:d.removeClass(c)}},toggleVisibility:function(a){this.$eye||(this.$eye=this.$el.find("> #"+this.pfx+"btn-eye"));var b=_.clone(this.model.get("style")),c=this.pfx+"hide";this.isVisible()?(this.$el.addClass(c),this.$eye.addClass("fa-eye-slash"),b.display="none"):(this.$el.removeClass(c),this.$eye.removeClass("fa-eye-slash"),delete b.display),this.model.set("style",b)},isVisible:function(){var a=this.model.get("style"),b=a.display;if(!b||"none"!=b)return 1},checkChildren:function(){var a=this.countChildren(this.model),b=this.pfx,c="> ."+b+"title-c > ."+b+"title";this.$counter||(this.$counter=this.$el.find("> #"+b+"counter")),a?(this.$el.find(c).removeClass(b+"no-chld"),this.$counter.html(a)):(this.$el.find(c).addClass(b+"no-chld"),this.$counter.empty(),this.model.set("open",0))},countChildren:function(a){var b=0;return a.components.each(function(a){var c=this.opt.isCountable,d=this.config.hideTextnode;c&&!c(a,d)||b++},this),b},render:function(){var a=this.pfx,b=this.isVisible(),d=this.countChildren(this.model);return this.$el.html(this.template({title:this.model.get(this.customNameProp)||this.model.getName(),addClass:d?"":a+"no-chld",editBtnCls:this.editBtnCls,inputNameCls:this.inputNameCls,caretCls:this.caretCls,count:d,visible:b,hidable:this.config.hidable,prefix:a,ppfx:this.ppfx})),"undefined"==typeof ItemsView&&(ItemsView=c("./ItemsView")),this.$components=new ItemsView({collection:this.model.components,config:this.config,sorter:this.sorter,opened:this.opt.opened,parent:this.model}).render().$el,this.$el.find("."+a+"children").html(this.$components),this.$caret=this.$el.find("> ."+a+"title-c > ."+a+"title > #"+a+"caret"),this.model.get("draggable")&&this.config.sortable||this.$el.find("> #"+a+"move").detach(),b||(this.className+=" "+a+"hide"),this.$el.attr("class",_.result(this,"className")),this.updateOpening(),this.updateStatus(),this}})}),c("Navigator/view/ItemsView",["backbone","./ItemView"],function(a,b){return a.View.extend({initialize:function(a){if(this.opt=a,this.config=a.config,this.preview=a.preview,this.ppfx=a.config.pStylePrefix||"",this.pfx=a.config.stylePrefix||"",this.parent=a.parent,this.listenTo(this.collection,"add",this.addTo),this.listenTo(this.collection,"reset resetNavigator",this.render),this.className=this.pfx+"items",this.config.sortable&&!this.opt.sorter){var b=this.pfx,c=this.config.em.get("Utils");this.opt.sorter=new c.Sorter({container:this.el,containerSel:"."+b+"items",itemSel:"."+b+"item",ppfx:this.ppfx,pfx:b,nested:1})}this.sorter=this.opt.sorter||"",this.parent||(this.className+=" "+this.pfx+this.config.containerId),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,g=new f({model:a,config:this.config,sorter:this.sorter,isCountable:this.isCountable,opened:this.opt.opened}),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"),d<0?this.$el.append(h):this.$el.children().eq(d)[i](h)}else this.$el.append(h);return h},isCountable:function(a,b){var c=a.get("type"),d=a.get("tagName");return("textnode"!=c&&"br"!=d||!b)&&!a.get("hiddenLayer")},render:function(){var a=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(b){this.isCountable(b,this.config.hideTextnode)&&this.addToCollection(b,a)},this),this.$el.append(a),this.$el.attr("class",_.result(this,"className")),this}})}),c("Navigator/main",["require","./config/config","./view/ItemsView"],function(a){function b(b,c){var d=c,e=a("./config/config"),f=a("./view/ItemsView");for(var g in e)g in d||(d[g]=e[g]);var h={collection:b,config:d,opened:c.opened||{}};this.ItemsView=new f(h)}return b.prototype={render:function(){return this.ItemsView.render().$el}},b}),c("Navigator",["Navigator/main"],function(a){return a}),c("Commands/view/OpenLayers",["Navigator"],function(a){return{run:function(b,c){if(!this.$layers){var d=b.DomComponents.getComponent().get("components"),e=b.getConfig(),f=b.Panels,g=e.layers.stylePrefix||"nv-";e.layers.stylePrefix=e.stylePrefix+g,e.layers.pStylePrefix=e.stylePrefix,e.layers.em=b.editor,e.layers.opened=b.editor.get("opened");var h=new a(d,e.layers);this.$layers=h.render(),f.getPanel("views-container")?this.panel=f.getPanel("views-container"):this.panel=f.addPanel({id:"views-container"}),this.panel.set("appendContent",this.$layers).trigger("change:appendContent")}this.$layers.show()},stop:function(){this.$layers&&this.$layers.hide()}}}),c("Commands/view/OpenStyleManager",["StyleManager"],function(a){return{run:function(a,b){if(this.sender=b,!this.$cn){var c=a.getConfig(),d=a.Panels;this.$cn=$("
"),this.$cn2=$("
"),this.$cn.append(this.$cn2);var e=a.DeviceManager;if(e&&c.showDevices){var f=d.addPanel({id:"devices-c"});f.set("appendContent",e.render()).trigger("change:appendContent")}var g=a.SelectorManager;g&&this.$cn2.append(g.render([])),this.$cn2.append(a.StyleManager.render());var h=a.StyleManager.getConfig();this.$header=$("
",{"class":h.stylePrefix+"header",text:h.textNoElement}),this.$cn.append(this.$header),d.getPanel("views-container")?this.panel=d.getPanel("views-container"):this.panel=d.addPanel({id:"views-container"}),this.panel.set("appendContent",this.$cn).trigger("change:appendContent"),this.target=a.editor,this.listenTo(this.target,"change:selectedComponent",this.toggleSm)}this.toggleSm()},toggleSm:function(){this.sender.get("active")&&(this.target.get("selectedComponent")?(this.$cn2.show(),this.$header.hide()):(this.$cn2.hide(),this.$header.show()))},stop:function(){this.$cn2&&this.$cn2.hide(),this.$header&&this.$header.hide()}}}),c("Commands/view/OpenTraitManager",[],function(){return{run:function(a,b){var c=a.Config,d=c.stylePrefix,e=a.TraitManager;if(!this.obj){var f=e.getTraitsViewer(),g=e.getConfig();this.obj=$("
").append('
'+g.labelContainer+"
").get(0),this.obj.appendChild(f.render().el);var h=a.Panels;h.getPanel("views-container")?panelC=h.getPanel("views-container"):panelC=h.addPanel({id:"views-container"}),panelC.set("appendContent",this.obj).trigger("change:appendContent")}this.obj.style.display="block"},stop:function(){this.obj&&(this.obj.style.display="none")}}}),c("Commands/view/OpenBlocks",[],function(){return{run:function(a,b){var c=a.Config,d=(c.stylePrefix,a.BlockManager);if(!this.blocks){this.blocks=$("
").get(0),this.blocks.appendChild(d.render());var e=a.Panels;e.getPanel("views-container")?panelC=e.getPanel("views-container"):panelC=e.addPanel({id:"views-container"}),panelC.set("appendContent",this.blocks).trigger("change:appendContent")}this.blocks.style.display="block"},stop:function(){this.blocks&&(this.blocks.style.display="none")}}}),c("Commands/view/OpenAssets",[],function(){return{run:function(a,b,c){var d=c||{},e=(a.getConfig(),a.Modal),f=a.AssetManager;f.onClick(d.onClick),f.onDblClick(d.onDblClick),f.setTarget(d.target),f.onSelect(d.onSelect),e.setTitle(d.modalTitle||"Select image"),e.setContent(f.render()),e.open()}}}),c("Commands/view/ShowOffset",[],function(){return{getOffsetMethod:function(a){var b=a||"";return"get"+b+"OffsetViewerEl"},run:function(a,b,c){var d=c||{},e=d.state||"",f=a.getConfig();if(f.showOffsets&&(f.showOffsetsSelected||"Fixed"!=e)){var g=a.Canvas,h=d.el||"",i=d.elPos||g.getElementPos(h),j=window.getComputedStyle(h),k=this.ppfx,l=e+"State",m=this.getOffsetMethod(e),n=g[m]();n.style.display="block";var o=this["marginT"+e],p=this["marginB"+e],q=this["marginL"+e],r=this["marginR"+e],s=this["padT"+e],t=this["padB"+e],u=this["padL"+e],v=this["padR"+e];if(!this[l]){var w=e.toLowerCase(),x=w+"margin-v",y=w+"padding-v",z=$("
",{"class":k+x}).get(0),A=$("
",{"class":k+y}).get(0),B=k+x+"-el",C=k+y+"-el";o=$("
",{"class":k+x+"-top "+B}).get(0),p=$("
",{"class":k+x+"-bottom "+B}).get(0),q=$("
",{"class":k+x+"-left "+B}).get(0),r=$("
",{"class":k+x+"-right "+B}).get(0),s=$("
",{"class":k+y+"-top "+C}).get(0),t=$("
",{"class":k+y+"-bottom "+C}).get(0),u=$("
",{"class":k+y+"-left "+C}).get(0),v=$("
",{"class":k+y+"-right "+C}).get(0),this["marginT"+e]=o,this["marginB"+e]=p,this["marginL"+e]=q,this["marginR"+e]=r,this["padT"+e]=s,this["padB"+e]=t,this["padL"+e]=u,this["padR"+e]=v,z.appendChild(o),z.appendChild(p),z.appendChild(q),z.appendChild(r),A.appendChild(s),A.appendChild(t),A.appendChild(u),A.appendChild(v),n.appendChild(z),n.appendChild(A),this[l]="1"}var D="px",E=j.marginLeft.replace(D,""),F=parseInt(j.marginTop.replace(D,"")),G=parseInt(j.marginBottom.replace(D,"")),H=o.style,I=p.style,J=q.style,K=r.style,L=s.style,M=t.style,N=u.style,O=v.style,P=parseInt(i.left);H.height=j.marginTop,H.width=j.width,H.top=i.top-j.marginTop.replace(D,"")+D,H.left=P+D,I.height=j.marginBottom,I.width=j.width,I.top=i.top+i.height+D,I.left=P+D;var Q=i.height+F+G+D,R=i.top-F+D;J.height=Q,J.width=j.marginLeft,J.top=R,J.left=P-E+D,K.height=Q,K.width=j.marginRight,K.top=R,K.left=P+i.width+D;var S=parseInt(j.paddingTop.replace(D,""));L.height=j.paddingTop,L.width=j.width,L.top=i.top+D,L.left=P+D;var T=parseInt(j.paddingBottom.replace(D,""));M.height=j.paddingBottom,M.width=j.width,M.top=i.top+i.height-T+D,M.left=P+D;var U=i.height-T-S+D,V=i.top+S+D;N.height=U,N.width=j.paddingLeft,N.top=V,N.left=i.left+D;var W=parseInt(j.paddingRight.replace(D,""));O.height=U,O.width=j.paddingRight,O.top=V,O.left=i.left+i.width-W+D}},stop:function(a,b,c){var d=c||{},e=d.state||"",f=this.getOffsetMethod(e),g=a.Canvas,h=g[f]();h.style.display="none"}}}),c("Commands/view/Fullscreen",[],function(){return{isEnabled:function(){var a=document;return a.fullscreenElement||a.webkitFullscreenElement||a.mozFullScreenElement?1:0},enable:function(a){var b="";return a.requestFullscreen?a.requestFullscreen():a.webkitRequestFullscreen?(b="webkit",a.webkitRequestFullscreen()):a.mozRequestFullScreen?(b="moz",a.mozRequestFullScreen()):a.msRequestFullscreen?a.msRequestFullscreen():console.warn("Fullscreen not supported"),b},disable:function(){var a=document;a.exitFullscreen?a.exitFullscreen():a.webkitExitFullscreen?a.webkitExitFullscreen():a.mozCancelFullScreen?a.mozCancelFullScreen():a.msExitFullscreen&&a.msExitFullscreen()},fsChanged:function(a,b){var c=(document,(a||"")+"fullscreenchange");this.isEnabled()||(this.stop(null,this.sender),document.removeEventListener(c,this.fsChanged))},run:function(a,b){this.sender=b;var c=this.enable(a.getContainer());this.fsChanged=this.fsChanged.bind(this,c),document.addEventListener(c+"fullscreenchange",this.fsChanged),a&&a.trigger("change:canvasOffset")},stop:function(a,b){b&&b.set&&b.set("active",!1),this.disable(),a&&a.trigger("change:canvasOffset")}}}),c("Commands/view/Preview",[],function(){return{getPanels:function(a){return this.panels||(this.panels=a.Panels.getPanelsEl()),this.panels},tglPointers:function(a,b){ -var c=a.Canvas.getBody().querySelectorAll("."+this.ppfx+"no-pointer");_.each(c,function(a){a.style.pointerEvents=b?"":"all"})},run:function(a,b){b&&b.set&&b.set("active",!1),a.stopCommand("sw-visibility");var c=this,d=this.getPanels(a),e=a.Canvas.getElement(),f=a.getEl(),g=a.Config.stylePrefix;this.helper||(this.helper=document.createElement("span"),this.helper.className=g+"off-prv fa fa-eye-slash",f.appendChild(this.helper),this.helper.onclick=function(){c.stop(a)}),this.helper.style.display="inline-block",this.tglPointers(a),d.style.display="none";var h=e.style;h.width="100%",h.height="100%",h.top="0",h.left="0",h.padding="0",h.margin="0",a.trigger("change:canvasOffset")},stop:function(a,b){var c=this.getPanels(a);a.runCommand("sw-visibility"),a.getModel().runDefault(),c.style.display="block";var d=a.Canvas.getElement();d.setAttribute("style",""),this.helper&&(this.helper.style.display="none"),a.trigger("change:canvasOffset"),this.tglPointers(a,1)}}}),c("Commands/view/Resize",[],function(){return{run:function(a,b,c){var d=c&&c.el||"",e=a.Canvas,f=this.canvasResizer,g=c.options||{};if(!f){var h=e.getCanvasView();g.ratioDefault=1,g.appendTo=e.getResizerEl(),g.prefix=a.getConfig().stylePrefix,g.posFetcher=h.getElementPos.bind(h),g.mousePosFetcher=e.getMouseRelativePos,this.canvasResizer=a.Utils.Resizer.init(g),f=this.canvasResizer}f.setOptions(g),f.focus(d)},stop:function(){this.canvasResizer&&this.canvasResizer.blur()}}}),c("Commands/main",["require","./config/config","./view/CommandAbstract","./view/SelectComponent","./view/CreateComponent","./view/DeleteComponent","./view/ImageComponent","./view/MoveComponent","./view/TextComponent","./view/InsertCustom","./view/ExportTemplate","./view/SwitchVisibility","./view/OpenLayers","./view/OpenStyleManager","./view/OpenTraitManager","./view/OpenBlocks","./view/OpenAssets","./view/ShowOffset","./view/Fullscreen","./view/Preview","./view/Resize"],function(a){return function(){var b={},c={},d={},e=a("./config/config"),f=a("./view/CommandAbstract"),g=function(a,b){return delete b.initialize,c[a]=f.extend(b),this};return{name:"Commands",init:function(c){b=c||{};for(var f in e)f in b||(b[f]=e[f]);var g=b.pStylePrefix;g&&(b.stylePrefix=g+b.stylePrefix);for(var h in b.defaults){var i=b.defaults[h];i.id&&this.add(i.id,i)}return d["select-comp"]=a("./view/SelectComponent"),d["create-comp"]=a("./view/CreateComponent"),d["delete-comp"]=a("./view/DeleteComponent"),d["image-comp"]=a("./view/ImageComponent"),d["move-comp"]=a("./view/MoveComponent"),d["text-comp"]=a("./view/TextComponent"),d["insert-custom"]=a("./view/InsertCustom"),d["export-template"]=a("./view/ExportTemplate"),d["sw-visibility"]=a("./view/SwitchVisibility"),d["open-layers"]=a("./view/OpenLayers"),d["open-sm"]=a("./view/OpenStyleManager"),d["open-tm"]=a("./view/OpenTraitManager"),d["open-blocks"]=a("./view/OpenBlocks"),d["open-assets"]=a("./view/OpenAssets"),d["show-offset"]=a("./view/ShowOffset"),d.fullscreen=a("./view/Fullscreen"),d.preview=a("./view/Preview"),d.resize=a("./view/Resize"),d["tlb-delete"]={run:function(a){var b=a.getSelected();return b&&b.get("removable")?(b.set("status",""),b.destroy(),a.trigger("component:update",b),void a.editor.set("selectedComponent",null)):void console.warn("The element is not removable")}},d["tlb-clone"]={run:function(a){var b=a.getSelected();if(!b||!b.get("copyable"))return void console.warn("The element is not clonable");var c=b.collection,d=c.indexOf(b);c.add(b.clone(),{at:d+1}),a.trigger("component:update",b)}},d["tlb-move"]={run:function(a){var b=a.getSelected();if(!b||!b.get("draggable"))return void console.warn("The element is not draggable");var c=a.Canvas.getToolbarEl(),d=(c.style.display,a.Commands.get("move-comp"));d.onEndMoveFromModel=function(){a.editor.runDefault(),a.editor.set("selectedComponent",b),a.trigger("component:update",b)},a.editor.stopDefault(),d.initSorterFromModel(b),b.set("status","selected"),c.style.display="none"}},b.em&&(b.model=b.em.get("Canvas")),this},onLoad:function(){this.loadDefaultCommands()},add:g,get:function(a){var d=c[a];return"function"==typeof d&&(d=new d(b),c[a]=d),d},has:function(a){return!!c[a]},loadDefaultCommands:function(){for(var a in d)this.add(a,d[a]);return this}}}}),c("Commands",["Commands/main"],function(a){return a}),c("BlockManager/config/config",[],function(){return{blocks:[]}}),c("BlockManager/model/Block",["backbone"],function(a){return a.Model.extend({defaults:{label:"",content:"",attributes:{}}})}),c("BlockManager/model/Blocks",["backbone","./Block"],function(a,b){return a.Collection.extend({model:b})}),c("BlockManager/view/BlockView",["backbone"],function(a){return a.View.extend({events:{mousedown:"onDrag"},initialize:function(a,b){_.bindAll(this,"onDrop"),this.config=b||{},this.ppfx=this.config.pStylePrefix||"",this.listenTo(this.model,"destroy",this.remove),this.doc=$(document)},onDrag:function(a){if(this.config.getSorter){this.config.em.refreshCanvas();var b=this.config.getSorter();b.setDragHelper(this.el,a),b.startSort(this.el),b.setDropContent(this.model.get("content")),this.doc.on("mouseup",this.onDrop)}},onDrop:function(){this.doc.off("mouseup",this.onDrop),this.config.getSorter().endMove()},render:function(){var a=this.ppfx+"block";return this.$el.addClass(a),this.el.innerHTML='
'+this.model.get("label")+"
",this}})}),c("BlockManager/view/BlocksView",["backbone","./BlockView"],function(a,b){return a.View.extend({initialize:function(a,b){_.bindAll(this,"getSorter","onDrag","onDrop"),this.config=b||{},this.ppfx=this.config.pStylePrefix||"",this.listenTo(this.collection,"add",this.addTo),this.em=this.config.em,this.tac="test-tac",this.grabbingCls=this.ppfx+"grabbing",this.em&&(this.config.getSorter=this.getSorter,this.canvas=this.em.get("Canvas"))},getSorter:function(){if(this.em){if(!this.sorter){var a=this.em.get("Utils"),b=this.canvas;this.sorter=new a.Sorter({container:b.getBody(),placer:b.getPlacerEl(),containerSel:"*",itemSel:"*",pfx:this.ppfx,onStart:this.onDrag,onEndMove:this.onDrop,document:b.getFrameEl().contentDocument,direction:"a",wmargin:1,nested:1,em:this.em})}return this.sorter}},onDrag:function(){this.em.stopDefault()},onDrop:function(a){this.em.runDefault(),a&&a.get&&(a.get("activeOnRender")&&(a.trigger("active"),a.set("activeOnRender",0)),this.em.initChildrenComp(a))},addTo:function(a){this.add(a)},add:function(a,c){var d=c||null,e=new b({model:a,attributes:a.get("attributes")},this.config),f=e.render().el;d?d.appendChild(f):this.$el.append(f)},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.addClass(this.ppfx+"blocks-c"),this}})}),c("BlockManager/main",["require","./config/config","./model/Blocks","./view/BlocksView"],function(a){return function(){var b,c,d={},e=a("./config/config"),f=a("./model/Blocks"),g=a("./view/BlocksView");return{name:"BlockManager",init:function(a){d=a||{};for(var h in e)h in d||(d[h]=e[h]);return b=new f(d.blocks),c=new g({collection:b},d),this},add:function(a,c){var d=c||{};return d.id=a,b.add(d)},get:function(a){return b.get(a)},getAll:function(){return b},render:function(){return c.render().el}}}}),c("BlockManager",["BlockManager/main"],function(a){return a}),c("TraitManager/config/config",[],function(){return{stylePrefix:"trt-",labelContainer:"Component settings"}}),c("TraitManager/view/TraitView",["backbone"],function(a){return a.View.extend({events:{change:"onChange"},initialize:function(a){var b=this.model;this.config=a.config||{},this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.target=b.target,this.className=this.pfx+"trait",this.labelClass=this.ppfx+"label",this.fieldClass=this.ppfx+"field "+this.ppfx+"field-"+b.get("type"),this.inputhClass=this.ppfx+"input-holder",b.off("change:value",this.onValueChange),this.listenTo(b,"change:value",this.onValueChange),this.tmpl='
'},onChange:function(){this.model.set("value",this.getInputEl().value)},getValueForTarget:function(){return this.model.get("value")},onValueChange:function(){var a=this.model,b=this.target,c=a.get("name"),d=this.getValueForTarget();if(a.get("changeProp"))b.set(c,d);else{var e=_.clone(b.get("attributes"));e[c]=d,b.set("attributes",e)}},renderLabel:function(){this.$el.html('
'+this.getLabel()+"
")},getLabel:function(){var a=this.model,b=a.get("label")||a.get("name");return b.charAt(0).toUpperCase()+b.slice(1).replace(/-/g," ")},getInputEl:function(){if(!this.$input){var a=this.model,b=this.target,c=a.get("name"),d={placeholder:a.get("placeholder")||a.get("default"),type:a.get("type")||"text"};if(a.get("changeProp"))d.value=b.get(c);else{var e=b.get("attributes");d.value=a.get("value")||e[c]}a.get("min")&&(d.min=a.get("min")),a.get("max")&&(d.max=a.get("max")),this.$input=$("",d)}return this.$input.get(0)},getModelValue:function(){var a,b=this.model,c=this.target,d=b.get("name");if(b.get("changeProp"))a=c.get(d);else{var e=c.get("attributes");a=b.get("value")||e[d]}return a},renderField:function(){if(!this.$input){this.$el.append(this.tmpl);var a=this.getInputEl();this.$el.find("."+this.inputhClass).prepend(a)}},render:function(){return this.renderLabel(),this.renderField(),this.el.className=this.className,this}})}),c("TraitManager/view/TraitSelectView",["backbone","./TraitView"],function(a,b){return b.extend({initialize:function(a){b.prototype.initialize.apply(this,arguments);var c=this.ppfx;this.tmpl='
'},getInputEl:function(){if(!this.$input){var a=this.model,b=a.get("options")||[];this.input="",this.$input=$(this.input);var c=this.target,d=a.get("name"),e=a.get("value");if(a.get("changeProp"))e=e||c.get(d);else{var f=c.get("attributes");e=f[d]}e&&this.$input.val(e)}return this.$input.get(0)}})}),c("TraitManager/view/TraitCheckboxView",["./TraitView"],function(a){return a.extend({initialize:function(b){a.prototype.initialize.apply(this,arguments);var c=this.ppfx+"chk-icon";this.tmpl='
'},onChange:function(){this.model.set("value",this.getInputEl().checked)},getInputEl:function(){var b;this.$input||(b=1);var c=a.prototype.getInputEl.apply(this,arguments);if(b){var d=this.model,e=d.get("name"),f=this.target;if(d.get("changeProp"))c.checked=f.get(e);else{var g=f.get("attributes");c.checked=!!g[e]}}return c}})}),c("TraitManager/view/TraitNumberView",["./TraitView","Abstract/ui/InputNumber"],function(a,b){return a.extend({getValueForTarget:function(){var a=this.model,b=a.get("value"),c=a.get("unit");return b?b+c:""},getInputEl:function(){if(!this.$input){var a=this.getModelValue(),c=new b({contClass:this.ppfx+"field-int",model:this.model,ppfx:this.ppfx});this.input=c.render(),this.$input=this.input.inputEl,this.$unit=this.input.unitEl,this.model.set("value",a),this.$input.val(a)}return this.$input.get(0)},renderField:function(){this.$input||(this.$el.append(this.tmpl),this.getInputEl(),this.$el.find("."+this.inputhClass).prepend(this.input.el))}})}),c("TraitManager/view/TraitColorView",["./TraitView","Abstract/ui/InputColor"],function(a,b){return a.extend({getInputEl:function(){if(!this.$input){var a=this.getModelValue(),c=new b({contClass:this.ppfx+"field-color",model:this.model,ppfx:this.ppfx});this.input=c.render(),this.$input=this.input.colorEl,a=a||"",this.model.set("value",a).trigger("change:value")}return this.$input.get(0)},renderField:function(){this.$input||(this.getInputEl(),this.$el.append(this.input.el))}})}),c("TraitManager/view/TraitsView",["require","Abstract/view/DomainViews","./TraitView","./TraitSelectView","./TraitCheckboxView","./TraitNumberView","./TraitColorView"],function(a){var b=a("Abstract/view/DomainViews"),c=a("./TraitView"),d=a("./TraitSelectView"),e=a("./TraitCheckboxView"),f=a("./TraitNumberView"),g=a("./TraitColorView");return b.extend({itemView:c,itemsView:{text:c,number:f,select:d,checkbox:e,color:g},initialize:function(a){this.config=a.config||{},this.em=a.editor,this.pfx=this.config.stylePrefix||"",this.className=this.pfx+"traits",this.listenTo(this.em,"change:selectedComponent",this.updatedCollection),this.updatedCollection()},updatedCollection:function(){this.el.className=this.className;var a=this.em.get("selectedComponent");a&&(this.collection=a.get("traits"),this.render())}})}),c("TraitManager/main",["require","./config/config","./model/Traits","./view/TraitsView"],function(a){return function(){var b,c={},d=a("./config/config"),e=(a("./model/Traits"),a("./view/TraitsView"));return{TraitsView:e,name:"TraitManager",getConfig:function(){return c},init:function(a){c=a||{};for(var f in d)f in c||(c[f]=d[f]);var g=c.pStylePrefix;return g&&(c.stylePrefix=g+c.stylePrefix),b=new e({collection:[],editor:c.em,config:c}),this},getTraitsViewer:function(){return b},addType:function(a,c){var d=b.itemView;b.itemsView[a]=d.extend(c)},getType:function(a){return b.itemsView[a]}}}}),c("TraitManager",["TraitManager/main"],function(a){return a});var d=["Utils","StorageManager","DeviceManager","Parser","SelectorManager","ModalDialog","CodeManager","Panels","RichTextEditor","StyleManager","AssetManager","CssComposer","DomComponents","Canvas","Commands","BlockManager","TraitManager"];return c("editor/model/Editor",["backbone","backboneUndo","keymaster","Utils","StorageManager","DeviceManager","Parser","SelectorManager","ModalDialog","CodeManager","Panels","RichTextEditor","StyleManager","AssetManager","CssComposer","DomComponents","Canvas","Commands","BlockManager","TraitManager"],function(){return Backbone.Model.extend({defaults:{clipboard:null,designerMode:!1,selectedComponent:null,previousModel:null,changesCount:0,storables:[],toLoad:[],opened:{},device:""},initialize:function(a){this.config=a,this.set("Config",a),a.el&&a.fromElement&&(this.config.components=a.el.innerHTML),d.forEach(function(a){this.loadModule(a)},this),this.get("toLoad").forEach(function(a){a.onLoad()}),this.initUndoManager(),this.on("change:selectedComponent",this.componentSelected,this),this.on("change:changesCount",this.updateBeforeUnload,this)},updateBeforeUnload:function(){var a=this.get("changesCount");this.config.noticeOnUnload&&a?window.onbeforeunload=function(a){return 1}:window.onbeforeunload=null},loadModule:function(a){var c=this.config,d=new b(a)(),e=d.name.charAt(0).toLowerCase()+d.name.slice(1),f=c[e]||c[d.name]||{};f.pStylePrefix=c.pStylePrefix||"";var g=this.get("StorageManager");if(d.storageKey&&d.store&&d.load&&g){f.stm=g;var h=this.get("storables");h.push(d),this.set("storables",h)}return f.em=this,d.init(Object.create(f)),d["private"]||this.set(d.name,d),d.onLoad&&this.get("toLoad").push(d),this},init:function(a){this.set("Editor",a)},listenRules:function(a){this.stopListening(a,"add remove",this.listenRule),this.listenTo(a,"add remove",this.listenRule),a.each(function(a){this.listenRule(a)},this)},listenRule:function(a){this.stopListening(a,"change:style",this.ruleUpdated),this.listenTo(a,"change:style",this.ruleUpdated)},ruleUpdated:function(a,b,c){var d=this.get("changesCount")+1,e=c?c.avoidStore:0;this.set("changesCount",d);var f=this.get("StorageManager");f.isAutosave()&&d"+a+"":""},getCss:function(){var a=this.get("CssComposer"),b=this.get("DomComponents").getComponent(),c=this.config.protectedCss;return c+this.get("CodeManager").getCode(b,"css",a)},getJs:function(){var a=this.get("DomComponents").getWrapper();return this.get("CodeManager").getCode(a,"js").trim()},store:function(a){var b=this.get("StorageManager"),c={};if(b)return this.get("storables").forEach(function(a){var b=a.store(1);for(var d in b)c[d]=b[d]}),b.store(c,a),this.set("changesCount",0),this.trigger("storage:store",c),c},load:function(a){var b=this.getCacheLoad(1);return this.get("storables").forEach(function(a){a.load(b)}),b},getCacheLoad:function(a){var b=a?1:0;if(this.cacheLoad&&!b)return this.cacheLoad;var c=this.get("StorageManager"),d=[];return c?(this.get("storables").forEach(function(a){var b=a.storageKey;b="function"==typeof b?b():b,keys=b instanceof Array?b:[b],keys.forEach(function(a){d.push(a)})}),this.cacheLoad=c.load(d),this.trigger("storage:load",this.cacheLoad),this.cacheLoad):{}},getDeviceModel:function(){var a=this.get("device");return this.get("DeviceManager").get(a)},runDefault:function(){var a=this.get("Commands").get(this.config.defaultCommand);a&&!this.defaultRunning&&(a.stop(this,this),a.run(this,this),this.defaultRunning=1)},stopDefault:function(){var a=this.get("Commands").get(this.config.defaultCommand);a&&(a.stop(this,this),this.defaultRunning=0)},refreshCanvas:function(){this.set("canvasOffset",this.get("Canvas").getOffset())},clearSelection:function(a){var b=a||window;b.getSelection().removeAllRanges()}})}),c("editor/view/EditorView",["backbone"],function(a){return a.View.extend({initialize:function(){this.pn=this.model.get("Panels"),this.conf=this.model.config,this.className=this.conf.stylePrefix+"editor",this.model.on("loaded",function(){this.pn.active(),this.model.runDefault(),this.model.trigger("load")},this)},render:function(){var a=this.model,b=a.get("UndoManager"),c=a.get("DomComponents"),d=a.get("Config");d.loadCompsOnRender&&(d.clearOnRender&&c.clear(),c.getComponents().add(d.components),b.clear(),c.onLoad());var e=this.conf,f=$(e.el||"body "+e.container);return this.$el.empty(),e.width&&f.css("width",e.width),e.height&&f.css("height",e.height),this.$el.append(a.get("Canvas").render()),this.$el.append(this.pn.render()),this.$el.attr("class",this.className),f.addClass(e.stylePrefix+"editor-cont"),f.html(this.$el),this}})}),c("editor/main",["require","./config/config","./model/Editor","./view/EditorView"],function(a){var b=function(b){var c=b||{},d=a("./config/config"),e=a("./model/Editor"),f=a("./view/EditorView");for(var g in d)g in c||(c[g]=d[g]);c.pStylePrefix=c.stylePrefix;var h=new e(c),i=new f({model:h,config:c});return{editor:h,DomComponents:h.get("DomComponents"),CssComposer:h.get("CssComposer"),StorageManager:h.get("StorageManager"),AssetManager:h.get("AssetManager"),BlockManager:h.get("BlockManager"),TraitManager:h.get("TraitManager"),SelectorManager:h.get("SelectorManager"),CodeManager:h.get("CodeManager"),Commands:h.get("Commands"),Modal:h.get("Modal"),Panels:h.get("Panels"),StyleManager:h.get("StyleManager"),Canvas:h.get("Canvas"),UndoManager:h.get("UndoManager"),DeviceManager:h.get("DeviceManager"),RichTextEditor:h.get("rte"),Utils:h.get("Utils"),Config:h.get("Config"),init:function(){return h.init(this),this},getConfig:function(){return c},getHtml:function(){return h.getHtml()},getCss:function(){return h.getCss()},getJs:function(){return h.getJs()},getComponents:function(){return h.get("DomComponents").getComponents()},setComponents:function(a){return h.setComponents(a),this},addComponents:function(a){return this.getComponents().add(a)},getStyle:function(){return h.get("CssComposer").getAll()},setStyle:function(a){return h.setStyle(a),this},getSelected:function(){return h.getSelected()},setDevice:function(a){return h.set("device",a)},getDevice:function(){return h.get("device")},runCommand:function(a,b){var c,d=h.get("Commands").get(a);return d&&(c=d.run(this,this,b),this.trigger("run:"+a)),c},stopCommand:function(a,b){var c,d=h.get("Commands").get(a);return d&&(c=d.stop(this,this,b),this.trigger("stop:"+a)),c},store:function(a){return h.store(a)},load:function(){return h.load()},getContainer:function(){return c.el},refresh:function(){h.refreshCanvas()},setCustomRte:function(a){this.RichTextEditor.customRte=a},on:function(a,b){return h.on(a,b)},trigger:function(a){return h.trigger(a)},getEl:function(){return i.el},getModel:function(){return h},render:function(){return i.render().el}}};return b}),c("PluginManager/config/config",[],function(){return{plugins:[]}}),c("PluginManager/main",["require","./config/config"],function(a){return function(b){var c=b||{},d=a("./config/config");for(var e in d)e in c||(c[e]=d[e]);var f={};return{add:function(a,b){return f[a]?this:(f[a]=b,this)},get:function(a){return f[a]},getAll:function(){return f}}}}),c("PluginManager",["PluginManager/main"],function(a){return a}),c("grapesjs/main",["require","./config/config","editor/main","PluginManager"],function(a){return function(b){var c=a("./config/config"),d=a("editor/main"),e=a("PluginManager"),f=new e,g=[];return{editors:g,plugins:f,init:function(a){var b=a||{},e=b.container;for(var h in c)h in b||(b[h]=c[h]);if(!e)throw new Error("'container' is required");b.el=document.querySelector(e);var i=new d(b).init(),j=f.getAll();for(var k in j)if(!(b.plugins.indexOf(k)<0)){var l=b.pluginsOpts[k]||{},m=f.get(k);m(i,l)}return b.autorender&&i.render(),g.push(i),i}}}()}),b(["src/config/require-config.js"],function(){b(["grapesjs/main"],function(a){return a})}),c("main",function(){}),b("grapesjs/main")}); \ No newline at end of file +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;f",{"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.listenTo(this.model,"updateVisibility",this.updateVisibility),this.events["click ."+this.pfx+"title"]="toggle",this.delegateEvents()},updateVisibility:function(){var a;this.model.get("properties").each(function(b){b.get("visible")&&(a=1)}),this.el.style.display=a?"block":"none"},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 targetStyleUpdated change:device",this.targetUpdated)},addTo:function(a){this.addToCollection(a)},targetUpdated:function(){var a=this.target.get("selectedComponent");if(a){var b=this.target.get("Config").devicePreviewMode,c=a.get("classes"),d=this.propTarget,e=this.target.getDeviceModel(),f=b?"":a.get("state"),g=e&&!b?"(max-width: "+e.get("width")+")":"";if(d.helper=null,c.length){var h=this.target.get("CssComposer"),i=_.filter(c.models,function(a){return a.get("active")}),j=h.get(i,f,g);if(j||(j=h.add(i,f,g),j.set("style",a.get("style")),a.set("style",{})),f){var k=this.target.get("SelectorManager"),l=k.add("hc-state"),m=h.get([l]);m?(h.getAll().remove(m),h.getAll().add(m)):m=h.add([l]),m.set("style",j.get("style")),d.helper=m}return d.model=j,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",getConfig:function(){return d},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},getModelToStyle:function(a){var b=a.get("classes");if(d.em&&b&&b.length){var c=d.em.get("Config").devicePreviewMode,e=d.em.getDeviceModel(),f=c?"":a.get("state"),g=e&&!c?e.get("width"):"",h=d.em.get("CssComposer"),i=_.filter(b.models,function(a){return a.get("active")}),j=h.get(i,f,g);if(j)return j}return a},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;e\n
\n
\n
\n
\n\t
<%= name %>
\n\t
<%= dim %>
\n
\n
\n
'}),c("AssetManager/view/AssetImageView",["./AssetView","text!./../template/assetImage.html"],function(a,b){return a.extend({events:{click:"handleClick",dblclick:"handleDblClick"},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()},handleClick:function(){var a=this.config.onClick,b=this.model;b.collection.trigger("deselectAll"),this.$el.addClass(this.pfx+"highlight"),"function"==typeof a?a(b):this.updateTarget(b.get("src"))},handleDblClick:function(){var a=this.config.onDblClick,b=this.model;"function"==typeof a?a(b):this.updateTarget(b.get("src"));var c=b.collection.onSelect;"function"==typeof c&&c(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\t
<%= title %>
\n\t multiple/>\n\t
\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
\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();if(c)return this.collection.addImg(c,{at:0}),this.getAssetsEl().scrollTop=0,b.value="",this},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,btnText:this.config.addBtnText})),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",addBtnText:"Add image"}}),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},onClick:function(a){e.onClick=a},onDblClick:function(a){e.onDblClick=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:{},selectorsAdd:"",style:{},mediaText:"",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("styles")>=0&&(c.styles=JSON.stringify(b)),a||d.stm.store(c),c}},add:function(a,c,d,e){var g=c||"",h=d||"",i=e||{},j=this.get(a,g,h);return j?j:(i.state=g,i.mediaText=h,i.selectors="",j=new f(i),j.get("selectors").add(a),b.add(j),j)},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},addCollection:function(a,b){for(var c=b||{},e=[],f=a instanceof Array?a:[a],g=0,h=f.length;g=0&&this.set("void",!0),this.opt=e,this.sm=e?e.sm||{}:{},this.config=a||{},this.defaultC=this.config.components||[],this.defaultCl=this.normalizeClasses(this.get("classes")||this.config.classes||[]),this.components=new b(this.defaultC,e),this.components.parent=this,this.listenTo(this,"change:script",this.scriptUpdated),this.set("attributes",this.get("attributes")||{}),this.set("components",this.components),this.set("classes",new c(this.defaultCl));var f=new d;f.setTarget(this),f.add(this.get("traits")),this.set("traits",f),this.initToolbar();var g=["stylable"];g.forEach(function(a){var b=this.get(a);if("string"==typeof b){var c=b.split(",").map(function(a){return a.trim()});this.set(a,c)}},this),this.init()},init:function(){},scriptUpdated:function(){this.set("scriptUpdated",1)},initToolbar:function(){var a=this;if(!a.get("toolbar")){var b=[];a.get("draggable")&&b.push({attributes:{"class":"fa fa-arrows"},command:"tlb-move"}),a.get("copyable")&&b.push({attributes:{"class":"fa fa-clone"},command:"tlb-clone"}),a.get("removable")&&b.push({attributes:{"class":"fa fa-trash-o"},command:"tlb-delete"}),a.set("toolbar",b)}},loadTraits:function(a){var b=new d;b.setTarget(this),b.add(a),this.set("traits",b)},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(a){var b=_.clone(this.attributes),c=this.get("components"),d=this.get("traits"),e=this.get("classes");return b.components=[],b.classes=[],b.traits=[],c.each(function(a,c){b.components[c]=a.clone(1)}),d.each(function(a,c){b.traits[c]=a.clone()}),e.each(function(a,c){b.classes[c]=a.get("name")}),b.status="",b.view="",a&&(this.opt.collection=null),new this.constructor(b,this.opt)},getName:function(){if(!this.name){var a=(this.cid.replace(/\D/g,""),this.get("type")),b=this.get("tagName");b="div"==b?"box":b,b=a?a:b,this.name=b.charAt(0).toUpperCase()+b.slice(1)}return this.name},toHTML:function(a){var b="",c=this,d=c.get("tagName"),e=c.get("void"),f="",g="",h=this.getAttrToHTML();for(var i in h){var j=h[i];g+=void 0!==typeof j&&""!==j?" "+i+'="'+j+'"':""}var k="";return c.get("classes").each(function(a){k+=" "+a.get("name")}),k=""!==k?' class="'+k.trim()+'"':"",_.isEmpty(c.get("style"))||(f=' id="'+c.cid+'" '),b+="<"+d+k+f+g+(e?"/":"")+">"+c.get("content"),c.get("components").each(function(a){b+=a.toHTML()}),e||(b+=""),b},getAttrToHTML:function(){var a=this.get("attributes")||{};return delete a.style,a},toJSON:function(){var b=a.Model.prototype.toJSON.apply(this,arguments),c=this.getScriptString();return c&&(b.script=c),b},getScriptString:function(a){var b=a||this.get("script");if("function"==typeof b){var c=b.toString().trim();c=c.replace(/^function\s?\(\)\s?\{/,""),c=c.replace(/\}$/,""),b=c}return b}},{isComponent:function(a){return{tagName:a.tagName?a.tagName.toLowerCase():""}}})}),c("DomComponents/view/ComponentsView",["backbone","require"],function(a,b){return a.View.extend({initialize:function(a){this.opts=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);var c=this.config.em;c&&(c.trigger("add:component",a),c.trigger("component:add",a))},addToCollection:function(a,c,d){this.compView||(this.compView=b("./ComponentView"));for(var e=c||null,f=this.compView,g=this.opts.defaultTypes,h=this.opts.componentTypes,i=a.get("type"),j=0;j=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;b 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","clearOff"),this.config=a.config||{},this.em=this.config.em||{},this.ppfx=this.config.pStylePrefix||"",this.className=this.config.stylePrefix+"canvas",this.listenTo(this.em,"change:canvasOffset",this.clearOff),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,this.em.trigger("canvasScroll")},renderScripts:function(){var a=this.frame,b=this;a.el.onload=function(){function c(d){if(d.length>0){var e=document.createElement("script");e.type="text/javascript",e.src=d.shift(),e.onerror=e.onload=c.bind(null,d),a.el.contentDocument.head.appendChild(e)}else b.renderBody()}var d=b.config.scripts.slice(0);c(d)}},renderBody:function(){var a=this.model.get("frame").get("wrapper"),b=this.config.em;if(a){var c=this.ppfx,d=this.frame.$el.contents().find("body"),e=b.get("CssComposer"),f=b.get("Config");d.append(a.render()).append(e.render());var g=f.protectedCss,h="* {box-sizing: border-box;} body{margin:0;height:auto;background-color:#fff} #wrapper{min-height:100%; overflow:auto}."+c+"dashed :not([contenteditable]) > *[data-highlightable]{outline: 1px dashed rgba(170,170,170,0.7); outline-offset: -2px}."+c+"comp-selected{outline: 3px solid #3b97e3 !important}."+c+"no-select{user-select: none; -webkit-user-select:none; -moz-user-select: none}."+c+"freezed{opacity: 0.5; pointer-events: none}."+c+"no-pointer{pointer-events: none}."+c+"plh-image{background:#f5f5f5; border:none; height:50px; width:50px; display:block; outline:3px solid #ffca6f; cursor:pointer}."+c+"grabbing{cursor: grabbing; cursor: -webkit-grabbing}* ::-webkit-scrollbar-track {background: rgba(0, 0, 0, 0.1)}* ::-webkit-scrollbar-thumb {background: rgba(255, 255, 255, 0.2)}* ::-webkit-scrollbar {width: 10px}"+(f.canvasCss||"");h+=g||"",d.append(""),d.append(this.getJsContainer()),b.trigger("loaded"),this.frame.el.contentWindow.onscroll=this.onFrameScroll,this.frame.udpateOffset();var i=document,j=this.frame.el.contentDocument;j.addEventListener("keydown",function(a){i.dispatchEvent(new KeyboardEvent(a.type,a))}),j.addEventListener("keyup",function(a){i.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}},clearOff:function(){this.frmOff=null,this.cvsOff=null},getFrameOffset:function(){return this.frmOff||(this.frmOff=this.offset(this.frame.el)),this.frmOff},getCanvasOffset:function(){return this.cvsOff||(this.cvsOff=this.offset(this.el)),this.cvsOff},getElementPos:function(a){var b=this.getFrameOffset(),c=this.getCanvasOffset(),d=this.offset(a),e=d.top+b.top-c.top,f=d.left+b.left-c.left;return{top:e,left:f,height:a.offsetHeight,width:a.offsetWidth}},getPosition:function(){var a=this.frame.el.contentDocument.body,b=this.getFrameOffset(),c=this.getCanvasOffset();return{top:b.top+a.scrollTop-c.top,left:b.left+a.scrollLeft-c.left}},updateScript:function(a){a.scriptContainer||(a.scriptContainer=$("
"),this.getJsContainer().append(a.scriptContainer.get(0)));var b=a.model.cid,c=a.model.get("script"),d="function(){"+c+"}";d="function"==typeof c?c.toString():d,a.el.id=b,a.scriptContainer.html(""),a.scriptContainer.append('")},getJsContainer:function(){return this.jsContainer||(this.jsContainer=$("
",{"class":this.ppfx+"js-cont"}).get(0)),this.jsContainer},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;0===this.config.scripts.length?a.el.onload=this.renderBody:this.renderScripts()}var b=this.ppfx;toolsEl=$("
",{id:b+"tools"}).get(0),this.hlEl=$("
",{"class":b+"highlighter"}).get(0),this.badgeEl=$("
",{"class":b+"badge"}).get(0),this.placerEl=$("
",{"class":b+"placeholder"}).get(0),this.placerIntEl=$("
",{"class":b+"placeholder-int"}).get(0),this.ghostEl=$("
",{"class":b+"ghost"}).get(0),this.toolbarEl=$("
",{"class":b+"toolbar"}).get(0),this.resizerEl=$("
",{"class":b+"resizer"}).get(0),this.offsetEl=$("
",{"class":b+"offset-v"}).get(0),this.fixedOffsetEl=$("
",{"class":b+"offset-fixed-v"}).get(0),this.placerEl.appendChild(this.placerIntEl),toolsEl.appendChild(this.hlEl),toolsEl.appendChild(this.badgeEl),toolsEl.appendChild(this.placerEl),toolsEl.appendChild(this.ghostEl),toolsEl.appendChild(this.toolbarEl),toolsEl.appendChild(this.resizerEl),toolsEl.appendChild(this.offsetEl),toolsEl.appendChild(this.fixedOffsetEl),this.$el.append(toolsEl);var c=this.em.get("rte");return c&&toolsEl.appendChild(c.render()),this.toolsEl=toolsEl,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},getToolbarEl:function(){return f.toolbarEl},getResizerEl:function(){return f.resizerEl},getOffsetViewerEl:function(){return f.offsetEl},getFixedOffsetViewerEl:function(){return f.fixedOffsetEl},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}},getElementPos:function(a){return f.getElementPos(a)},getTargetToElementDim:function(a,b,d){var e=d||{},g=f.getPosition(),h=e.elPos||f.getElementPos(b),i=d.toRight||0,j=e.targetHeight||a.offsetHeight,k=e.targetWidth||a.offsetWidth,l=e.event||null,m=h.top-j,n=h.left;n+=i?h.width:0,n=i?n-k:n;var o=nh.top+h.height?h.top+h.height:p;var q={top:p,left:o,elementTop:h.top,elementLeft:h.left,elementWidth:h.width,elementHeight:h.height,targetWidth:a.offsetWidth,targetHeight:a.offsetHeight,canvasTop:g.top,canvasLeft:g.left};return l&&c.em&&c.em.trigger(l,q),q},getMouseRelativePos:function(a,b){var c=b||{},d=0,e=0,f=c.subWinOffset,g=a.target.ownerDocument,h=g.defaultView||g.parentWindow,i=h.frameElement,j=f?h.pageYOffset:0,k=f?h.pageXOffset:0;if(i){var l=i.getBoundingClientRect();d=l.top||0,e=l.left||0}return{y:a.clientY+d-j,x:a.clientX+e-k}},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("Abstract/view/DomainViews",["backbone"],function(a){return a.View.extend({itemView:"",itemsView:"",itemType:"type",initialize:function(a,b){this.config=b||{}},addTo:function(a){this.add(a)},add:function(a,b){var c=b||null,d=this.itemView,e=a.get(this.itemType);this.itemsView&&this.itemsView[e]&&(d=this.itemsView[e]);var f=new d({model:a,config:this.config},this.config),g=f.render().el;c?c.appendChild(g):this.$el.append(g)},render:function(){var a=document.createDocumentFragment(); +return this.$el.empty(),this.collection.length&&this.collection.each(function(b){this.add(b,a)},this),this.$el.append(a),this}})}),c("DomComponents/view/ToolbarButtonView",["backbone"],function(a){return a.View.extend({events:{mousedown:"handleClick"},attributes:function(){return this.model.get("attributes")},initialize:function(a){this.editor=a.config.editor},handleClick:function(){var a=this.model.get("command");"function"==typeof a&&a(this.editor),"string"==typeof a&&this.editor.runCommand(a)},render:function(){var a=this.editor.getConfig();return this.el.className+=" "+a.stylePrefix+"toolbar-item",this}})}),c("DomComponents/view/ToolbarView",["backbone","Abstract/view/DomainViews","./ToolbarButtonView"],function(a,b,c){return b.extend({itemView:c,initialize:function(a){this.config={editor:a.editor||""},this.listenTo(this.collection,"reset",this.render)}})}),c("DomComponents/model/ToolbarButton",["backbone"],function(a){return a.Model.extend({defaults:{command:"",attributes:{}}})}),c("DomComponents/model/Toolbar",["backbone","./ToolbarButton"],function(a,b){return a.Collection.extend({model:b})}),c("Commands/view/SelectComponent",["require","DomComponents/view/ToolbarView","DomComponents/model/Toolbar"],function(a){var b=a("DomComponents/view/ToolbarView"),c=a("DomComponents/model/Toolbar");return{init:function(a){_.bindAll(this,"onHover","onOut","onClick","onKeyPress")},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);var b=this.config.em;b.on("component:update",this.updateAttached,this),b.on("change:canvasOffset",this.updateAttached,this),b.on("change:selectedComponent",this.updateToolbar,this)},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"))},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})}},getCanvasBodyEl:function(){return this.$bodyEl||(this.$bodyEl=$(this.getCanvasBody())),this.$bodyEl},startSelectComponent:function(){this.toggleSelectComponent(1)},stopSelectComponent:function(){this.toggleSelectComponent()},toggleSelectComponent:function(a){var b="*",c=a?"on":"off";this.getCanvasBodyEl()[c]("mouseover",b,this.onHover)[c]("mouseout",b,this.onOut)[c]("click",b,this.onClick);var d=this.getContentWindow();d[c]("scroll",this.onFrameScroll),d[c]("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.hideHighlighter(),this.editorModel.set("selectedComponent",null)}},onHover:function(a){a.stopPropagation();var b=a.target;this.adjScroll||(this.adjScroll=1,this.onFrameScroll(a),this.updateAttached());var c=this.getElementPos(b);this.updateBadge(b,c),this.updateHighlighter(b,c),this.showElementOffset(b,c)},onOut:function(a){a.stopPropagation(),this.hideBadge(),this.hideHighlighter(),this.hideElementOffset()},showElementOffset:function(a,b){var c=$(a),d=c.data("model");d&&"selected"==d.get("status")||this.editor.runCommand("show-offset",{el:a,elPos:b})},hideElementOffset:function(a,b){this.editor.stopCommand("show-offset")},showFixedElementOffset:function(a,b){this.editor.runCommand("show-offset",{el:a,elPos:b,state:"Fixed"})},hideFixedElementOffset:function(a,b){this.editor&&this.editor.stopCommand("show-offset",{state:"Fixed"})},hideHighlighter:function(){this.canvas.getHighlighter().style.display="none"},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)}},updateBadge:function(a,b){var c=$(a);this.cacheEl=a;var d=c.data("model");if(d&&d.get("badgable")){var e=this.getBadge();e.innerHTML=d.getName();var f=e.style,g="px";f.display="block";var h=this.canvas.getCanvasView().getPosition(),i=e?e.offsetHeight:0,j=e?e.offsetWidth:0,k=b.top-i"),e=this.codeMirror.clone().set({label:c,codeName:a,theme:b,input:d[0]}),f=new this.cm.EditorView({model:e,config:this.cm.getConfig()}).render().$el;return e.init(d[0]),{el:e,$el:f}},enable:function(){if(!this.$editors){var a=this.buildEditor("htmlmixed","hopscotch","HTML"),b=this.buildEditor("css","hopscotch","CSS");this.htmlEditor=a.el,this.cssEditor=b.el,this.$editors=$("
",{"class":this.pfx+"export-dl"}),this.$editors.append(a.$el).append(b.$el)}this.modal&&(this.modal.setTitle("Export template"),this.modal.setContent(this.$editors),this.modal.open());var c=this.protCss||"";this.htmlEditor.setContent(this.em.getHtml()),this.cssEditor.setContent(c+this.cm.getCode(this.wrapper,"css",this.cssc)),this.sender&&this.sender.set("active",!1)},stop:function(){}}}),c("Commands/view/SwitchVisibility",[],function(){return{run:function(a){a.Canvas.getBody().className=this.ppfx+"dashed"},stop:function(a){a.Canvas.getBody().className=""}}}),c("Navigator/config/config",[],function(){return{stylePrefix:"nv-",sortable:1,hidable:1,hideTextnode:1,containerId:"navigator",itemClass:"item",itemsClass:"items"}}),c("text!Navigator/template/item.html",[],function(){return'<% if (hidable) { %>\n\t\n<% } %>\n\n
\n
\n \t\n\t\t\n\t\t\n
\n
\n\n
<%= (count ? count : \'\') %>
\n\n
\n\t\n
\n\n
\n'}),c("Navigator/view/ItemView",["backbone","text!./../template/item.html","require"],function(a,b,c){return a.View.extend({template:_.template(b),initialize:function(a){this.opt=a,this.config=a.config,this.em=a.config.em,this.ppfx=this.em.get("Config").stylePrefix,this.sorter=a.sorter||{},this.pfx=this.config.stylePrefix,"undefined"==typeof this.model.get("open")&&this.model.set("open",!1),this.listenTo(this.model.components,"remove add change reset",this.checkChildren),this.listenTo(this.model,"destroy remove",this.remove),this.listenTo(this.model,"change:status",this.updateStatus),this.listenTo(this.model,"change:open",this.updateOpening),this.className=this.pfx+"item no-select",this.editBtnCls=this.pfx+"nav-item-edit",this.inputNameCls=this.ppfx+"nav-comp-name",this.caretCls=this.ppfx+"nav-item-caret",this.titleCls=this.pfx+"title",this.customNameProp="custom-name",this.events={},this.events["click > #"+this.pfx+"btn-eye"]="toggleVisibility",this.events["click ."+this.caretCls]="toggleOpening",this.events["click ."+this.titleCls]="handleSelect",this.events["click ."+this.editBtnCls]="handleEdit",this.events["blur ."+this.inputNameCls]="handleEditEnd",this.$el.data("model",this.model),this.$el.data("collection",this.model.get("components")),a.config.sortable&&(this.events["mousedown > #"+this.pfx+"move"]="startSort"),this.delegateEvents()},handleEdit:function(a){a.stopPropagation();var b=this.getInputName();b.readOnly=!1,b.focus()},handleEditEnd:function(a){a.stopPropagation();var b=this.getInputName();b.readOnly=!0,this.model.set(this.customNameProp,b.value)},getInputName:function(){return this.inputName||(this.inputName=this.el.querySelector("."+this.inputNameCls)),this.inputName},updateOpening:function(){var a=this.opt.opened||{},b=this.model;b.get("open")?(this.$el.addClass("open"),this.$caret.addClass("fa-chevron-down"),a[b.cid]=b):(this.$el.removeClass("open"),this.$caret.removeClass("fa-chevron-down"),delete a[b.cid])},toggleOpening:function(a){a.stopPropagation(),this.model.components.length&&this.model.set("open",!this.model.get("open"))},handleSelect:function(a){a.stopPropagation();var b=this.em;if(b){var c=b.get("selectedComponent");c&&c.set("status",""),this.model.set("status","selected"),b.set("selectedComponent",this.model)}},startSort:function(a){this.sorter&&this.sorter.startSort(a.target)},freeze:function(){this.$el.addClass(this.pfx+"opac50"),this.model.set("open",0)},unfreeze:function(){this.$el.removeClass(this.pfx+"opac50")},updateStatus:function(a){var b=this.model.get("status"),c=this.pfx+"selected",d=this.$el;switch(b){case"selected":d.addClass(c);break;case"moving":break;default:d.removeClass(c)}},toggleVisibility:function(a){this.$eye||(this.$eye=this.$el.find("> #"+this.pfx+"btn-eye"));var b=_.clone(this.model.get("style")),c=this.pfx+"hide";this.isVisible()?(this.$el.addClass(c),this.$eye.addClass("fa-eye-slash"),b.display="none"):(this.$el.removeClass(c),this.$eye.removeClass("fa-eye-slash"),delete b.display),this.model.set("style",b)},isVisible:function(){var a=this.model.get("style"),b=a.display;if(!b||"none"!=b)return 1},checkChildren:function(){var a=this.countChildren(this.model),b=this.pfx,c="> ."+b+"title-c > ."+b+"title";this.$counter||(this.$counter=this.$el.find("> #"+b+"counter")),a?(this.$el.find(c).removeClass(b+"no-chld"),this.$counter.html(a)):(this.$el.find(c).addClass(b+"no-chld"),this.$counter.empty(),this.model.set("open",0))},countChildren:function(a){var b=0;return a.components.each(function(a){var c=this.opt.isCountable,d=this.config.hideTextnode;c&&!c(a,d)||b++},this),b},render:function(){var a=this.pfx,b=this.isVisible(),d=this.countChildren(this.model);return this.$el.html(this.template({title:this.model.get(this.customNameProp)||this.model.getName(),addClass:d?"":a+"no-chld",editBtnCls:this.editBtnCls,inputNameCls:this.inputNameCls,caretCls:this.caretCls,count:d,visible:b,hidable:this.config.hidable,prefix:a,ppfx:this.ppfx})),"undefined"==typeof ItemsView&&(ItemsView=c("./ItemsView")),this.$components=new ItemsView({collection:this.model.components,config:this.config,sorter:this.sorter,opened:this.opt.opened,parent:this.model}).render().$el,this.$el.find("."+a+"children").html(this.$components),this.$caret=this.$el.find("> ."+a+"title-c > ."+a+"title > #"+a+"caret"),this.model.get("draggable")&&this.config.sortable||this.$el.find("> #"+a+"move").detach(),b||(this.className+=" "+a+"hide"),this.$el.attr("class",_.result(this,"className")),this.updateOpening(),this.updateStatus(),this}})}),c("Navigator/view/ItemsView",["backbone","./ItemView"],function(a,b){return a.View.extend({initialize:function(a){if(this.opt=a,this.config=a.config,this.preview=a.preview,this.ppfx=a.config.pStylePrefix||"",this.pfx=a.config.stylePrefix||"",this.parent=a.parent,this.listenTo(this.collection,"add",this.addTo),this.listenTo(this.collection,"reset resetNavigator",this.render),this.className=this.pfx+"items",this.config.sortable&&!this.opt.sorter){var b=this.pfx,c=this.config.em.get("Utils");this.opt.sorter=new c.Sorter({container:this.el,containerSel:"."+b+"items",itemSel:"."+b+"item",ppfx:this.ppfx,pfx:b,nested:1})}this.sorter=this.opt.sorter||"",this.parent||(this.className+=" "+this.pfx+this.config.containerId),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,g=new f({model:a,config:this.config,sorter:this.sorter,isCountable:this.isCountable,opened:this.opt.opened}),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"),d<0?this.$el.append(h):this.$el.children().eq(d)[i](h)}else this.$el.append(h);return h},isCountable:function(a,b){var c=a.get("type"),d=a.get("tagName");return("textnode"!=c&&"br"!=d||!b)&&!a.get("hiddenLayer")},render:function(){var a=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(b){this.isCountable(b,this.config.hideTextnode)&&this.addToCollection(b,a)},this),this.$el.append(a),this.$el.attr("class",_.result(this,"className")),this}})}),c("Navigator/main",["require","./config/config","./view/ItemsView"],function(a){function b(b,c){var d=c,e=a("./config/config"),f=a("./view/ItemsView");for(var g in e)g in d||(d[g]=e[g]);var h={collection:b,config:d,opened:c.opened||{}};this.ItemsView=new f(h)}return b.prototype={render:function(){return this.ItemsView.render().$el}},b}),c("Navigator",["Navigator/main"],function(a){return a}),c("Commands/view/OpenLayers",["Navigator"],function(a){return{run:function(b,c){if(!this.$layers){var d=b.DomComponents.getComponent().get("components"),e=b.getConfig(),f=b.Panels,g=e.layers.stylePrefix||"nv-";e.layers.stylePrefix=e.stylePrefix+g,e.layers.pStylePrefix=e.stylePrefix,e.layers.em=b.editor,e.layers.opened=b.editor.get("opened");var h=new a(d,e.layers);this.$layers=h.render(),f.getPanel("views-container")?this.panel=f.getPanel("views-container"):this.panel=f.addPanel({id:"views-container"}),this.panel.set("appendContent",this.$layers).trigger("change:appendContent")}this.$layers.show()},stop:function(){this.$layers&&this.$layers.hide()}}}),c("Commands/view/OpenStyleManager",["StyleManager"],function(a){return{run:function(a,b){if(this.sender=b,!this.$cn){var c=a.getConfig(),d=a.Panels;this.$cn=$("
"),this.$cn2=$("
"),this.$cn.append(this.$cn2);var e=a.DeviceManager;if(e&&c.showDevices){var f=d.addPanel({id:"devices-c"});f.set("appendContent",e.render()).trigger("change:appendContent")}var g=a.SelectorManager;g&&this.$cn2.append(g.render([])),this.$cn2.append(a.StyleManager.render());var h=a.StyleManager.getConfig();this.$header=$("
",{"class":h.stylePrefix+"header",text:h.textNoElement}),this.$cn.append(this.$header),d.getPanel("views-container")?this.panel=d.getPanel("views-container"):this.panel=d.addPanel({id:"views-container"}),this.panel.set("appendContent",this.$cn).trigger("change:appendContent"),this.target=a.editor,this.listenTo(this.target,"change:selectedComponent",this.toggleSm)}this.toggleSm()},toggleSm:function(){this.sender.get("active")&&(this.target.get("selectedComponent")?(this.$cn2.show(),this.$header.hide()):(this.$cn2.hide(),this.$header.show()))},stop:function(){this.$cn2&&this.$cn2.hide(),this.$header&&this.$header.hide()}}}),c("Commands/view/OpenTraitManager",[],function(){return{run:function(a,b){var c=a.Config,d=c.stylePrefix,e=a.TraitManager;if(!this.obj){var f=e.getTraitsViewer(),g=e.getConfig();this.obj=$("
").append('
'+g.labelContainer+"
").get(0),this.obj.appendChild(f.render().el);var h=a.Panels;h.getPanel("views-container")?panelC=h.getPanel("views-container"):panelC=h.addPanel({id:"views-container"}),panelC.set("appendContent",this.obj).trigger("change:appendContent")}this.obj.style.display="block"},stop:function(){this.obj&&(this.obj.style.display="none")}}}),c("Commands/view/OpenBlocks",[],function(){return{run:function(a,b){var c=a.Config,d=(c.stylePrefix,a.BlockManager);if(!this.blocks){this.blocks=$("
").get(0),this.blocks.appendChild(d.render());var e=a.Panels;e.getPanel("views-container")?panelC=e.getPanel("views-container"):panelC=e.addPanel({id:"views-container"}),panelC.set("appendContent",this.blocks).trigger("change:appendContent")}this.blocks.style.display="block"},stop:function(){this.blocks&&(this.blocks.style.display="none")}}}),c("Commands/view/OpenAssets",[],function(){return{run:function(a,b,c){var d=c||{},e=(a.getConfig(),a.Modal),f=a.AssetManager;f.onClick(d.onClick),f.onDblClick(d.onDblClick),f.setTarget(d.target),f.onSelect(d.onSelect),e.setTitle(d.modalTitle||"Select image"),e.setContent(f.render()),e.open()}}}),c("Commands/view/ShowOffset",[],function(){return{getOffsetMethod:function(a){var b=a||"";return"get"+b+"OffsetViewerEl"},run:function(a,b,c){var d=c||{},e=d.state||"",f=a.getConfig();if(f.showOffsets&&(f.showOffsetsSelected||"Fixed"!=e)){var g=a.Canvas,h=d.el||"",i=d.elPos||g.getElementPos(h),j=window.getComputedStyle(h),k=this.ppfx,l=e+"State",m=this.getOffsetMethod(e),n=g[m]();n.style.display="block";var o=this["marginT"+e],p=this["marginB"+e],q=this["marginL"+e],r=this["marginR"+e],s=this["padT"+e],t=this["padB"+e],u=this["padL"+e],v=this["padR"+e];if(!this[l]){var w=e.toLowerCase(),x=w+"margin-v",y=w+"padding-v",z=$("
",{"class":k+x}).get(0),A=$("
",{"class":k+y}).get(0),B=k+x+"-el",C=k+y+"-el";o=$("
",{"class":k+x+"-top "+B}).get(0),p=$("
",{"class":k+x+"-bottom "+B}).get(0),q=$("
",{"class":k+x+"-left "+B}).get(0),r=$("
",{"class":k+x+"-right "+B}).get(0),s=$("
",{"class":k+y+"-top "+C}).get(0),t=$("
",{"class":k+y+"-bottom "+C}).get(0),u=$("
",{"class":k+y+"-left "+C}).get(0),v=$("
",{"class":k+y+"-right "+C}).get(0),this["marginT"+e]=o,this["marginB"+e]=p,this["marginL"+e]=q,this["marginR"+e]=r,this["padT"+e]=s,this["padB"+e]=t,this["padL"+e]=u,this["padR"+e]=v,z.appendChild(o),z.appendChild(p),z.appendChild(q),z.appendChild(r),A.appendChild(s),A.appendChild(t),A.appendChild(u),A.appendChild(v),n.appendChild(z),n.appendChild(A),this[l]="1"}var D="px",E=j.marginLeft.replace(D,""),F=parseInt(j.marginTop.replace(D,"")),G=parseInt(j.marginBottom.replace(D,"")),H=o.style,I=p.style,J=q.style,K=r.style,L=s.style,M=t.style,N=u.style,O=v.style,P=parseInt(i.left);H.height=j.marginTop,H.width=j.width,H.top=i.top-j.marginTop.replace(D,"")+D,H.left=P+D,I.height=j.marginBottom,I.width=j.width,I.top=i.top+i.height+D,I.left=P+D;var Q=i.height+F+G+D,R=i.top-F+D;J.height=Q,J.width=j.marginLeft,J.top=R,J.left=P-E+D,K.height=Q,K.width=j.marginRight,K.top=R,K.left=P+i.width+D;var S=parseInt(j.paddingTop.replace(D,""));L.height=j.paddingTop,L.width=j.width,L.top=i.top+D,L.left=P+D;var T=parseInt(j.paddingBottom.replace(D,""));M.height=j.paddingBottom,M.width=j.width,M.top=i.top+i.height-T+D,M.left=P+D;var U=i.height-T-S+D,V=i.top+S+D;N.height=U,N.width=j.paddingLeft,N.top=V,N.left=i.left+D;var W=parseInt(j.paddingRight.replace(D,""));O.height=U,O.width=j.paddingRight,O.top=V,O.left=i.left+i.width-W+D}},stop:function(a,b,c){var d=c||{},e=d.state||"",f=this.getOffsetMethod(e),g=a.Canvas,h=g[f]();h.style.display="none"}}}),c("Commands/view/Fullscreen",[],function(){return{isEnabled:function(){var a=document;return a.fullscreenElement||a.webkitFullscreenElement||a.mozFullScreenElement?1:0},enable:function(a){var b="";return a.requestFullscreen?a.requestFullscreen():a.webkitRequestFullscreen?(b="webkit",a.webkitRequestFullscreen()):a.mozRequestFullScreen?(b="moz",a.mozRequestFullScreen()):a.msRequestFullscreen?a.msRequestFullscreen():console.warn("Fullscreen not supported"),b},disable:function(){var a=document;a.exitFullscreen?a.exitFullscreen():a.webkitExitFullscreen?a.webkitExitFullscreen():a.mozCancelFullScreen?a.mozCancelFullScreen():a.msExitFullscreen&&a.msExitFullscreen()},fsChanged:function(a,b){var c=(document,(a||"")+"fullscreenchange");this.isEnabled()||(this.stop(null,this.sender),document.removeEventListener(c,this.fsChanged))},run:function(a,b){this.sender=b;var c=this.enable(a.getContainer());this.fsChanged=this.fsChanged.bind(this,c),document.addEventListener(c+"fullscreenchange",this.fsChanged),a&&a.trigger("change:canvasOffset")},stop:function(a,b){b&&b.set&&b.set("active",!1),this.disable(),a&&a.trigger("change:canvasOffset")}}}),c("Commands/view/Preview",[],function(){return{getPanels:function(a){return this.panels||(this.panels=a.Panels.getPanelsEl()), +this.panels},tglPointers:function(a,b){var c=a.Canvas.getBody().querySelectorAll("."+this.ppfx+"no-pointer");_.each(c,function(a){a.style.pointerEvents=b?"":"all"})},run:function(a,b){b&&b.set&&b.set("active",!1),a.stopCommand("sw-visibility");var c=this,d=this.getPanels(a),e=a.Canvas.getElement(),f=a.getEl(),g=a.Config.stylePrefix;this.helper||(this.helper=document.createElement("span"),this.helper.className=g+"off-prv fa fa-eye-slash",f.appendChild(this.helper),this.helper.onclick=function(){c.stop(a)}),this.helper.style.display="inline-block",this.tglPointers(a),d.style.display="none";var h=e.style;h.width="100%",h.height="100%",h.top="0",h.left="0",h.padding="0",h.margin="0",a.trigger("change:canvasOffset")},stop:function(a,b){var c=this.getPanels(a);a.runCommand("sw-visibility"),a.getModel().runDefault(),c.style.display="block";var d=a.Canvas.getElement();d.setAttribute("style",""),this.helper&&(this.helper.style.display="none"),a.trigger("change:canvasOffset"),this.tglPointers(a,1)}}}),c("Commands/view/Resize",[],function(){return{run:function(a,b,c){var d=c&&c.el||"",e=a.Canvas,f=this.canvasResizer,g=c.options||{};if(!f){var h=e.getCanvasView();g.ratioDefault=1,g.appendTo=e.getResizerEl(),g.prefix=a.getConfig().stylePrefix,g.posFetcher=h.getElementPos.bind(h),g.mousePosFetcher=e.getMouseRelativePos,this.canvasResizer=a.Utils.Resizer.init(g),f=this.canvasResizer}f.setOptions(g),f.focus(d)},stop:function(){this.canvasResizer&&this.canvasResizer.blur()}}}),c("Commands/main",["require","./config/config","./view/CommandAbstract","./view/SelectComponent","./view/CreateComponent","./view/DeleteComponent","./view/ImageComponent","./view/MoveComponent","./view/TextComponent","./view/InsertCustom","./view/ExportTemplate","./view/SwitchVisibility","./view/OpenLayers","./view/OpenStyleManager","./view/OpenTraitManager","./view/OpenBlocks","./view/OpenAssets","./view/ShowOffset","./view/Fullscreen","./view/Preview","./view/Resize"],function(a){return function(){var b={},c={},d={},e=a("./config/config"),f=a("./view/CommandAbstract"),g=function(a,b){return delete b.initialize,c[a]=f.extend(b),this};return{name:"Commands",init:function(c){b=c||{};for(var f in e)f in b||(b[f]=e[f]);var g=b.pStylePrefix;g&&(b.stylePrefix=g+b.stylePrefix);for(var h in b.defaults){var i=b.defaults[h];i.id&&this.add(i.id,i)}return d["select-comp"]=a("./view/SelectComponent"),d["create-comp"]=a("./view/CreateComponent"),d["delete-comp"]=a("./view/DeleteComponent"),d["image-comp"]=a("./view/ImageComponent"),d["move-comp"]=a("./view/MoveComponent"),d["text-comp"]=a("./view/TextComponent"),d["insert-custom"]=a("./view/InsertCustom"),d["export-template"]=a("./view/ExportTemplate"),d["sw-visibility"]=a("./view/SwitchVisibility"),d["open-layers"]=a("./view/OpenLayers"),d["open-sm"]=a("./view/OpenStyleManager"),d["open-tm"]=a("./view/OpenTraitManager"),d["open-blocks"]=a("./view/OpenBlocks"),d["open-assets"]=a("./view/OpenAssets"),d["show-offset"]=a("./view/ShowOffset"),d.fullscreen=a("./view/Fullscreen"),d.preview=a("./view/Preview"),d.resize=a("./view/Resize"),d["tlb-delete"]={run:function(a){var b=a.getSelected();return b&&b.get("removable")?(b.set("status",""),b.destroy(),a.trigger("component:update",b),void a.editor.set("selectedComponent",null)):void console.warn("The element is not removable")}},d["tlb-clone"]={run:function(a){var b=a.getSelected();if(!b||!b.get("copyable"))return void console.warn("The element is not clonable");var c=b.collection,d=c.indexOf(b);c.add(b.clone(),{at:d+1}),a.trigger("component:update",b)}},d["tlb-move"]={run:function(a){var b=a.getSelected();if(!b||!b.get("draggable"))return void console.warn("The element is not draggable");var c=a.Canvas.getToolbarEl(),d=(c.style.display,a.Commands.get("move-comp"));d.onEndMoveFromModel=function(){a.editor.runDefault(),a.editor.set("selectedComponent",b),a.trigger("component:update",b)},a.editor.stopDefault(),d.initSorterFromModel(b),b.set("status","selected"),c.style.display="none"}},b.em&&(b.model=b.em.get("Canvas")),this},onLoad:function(){this.loadDefaultCommands()},add:g,get:function(a){var d=c[a];return"function"==typeof d&&(d=new d(b),c[a]=d),d},has:function(a){return!!c[a]},loadDefaultCommands:function(){for(var a in d)this.add(a,d[a]);return this}}}}),c("Commands",["Commands/main"],function(a){return a}),c("BlockManager/config/config",[],function(){return{blocks:[]}}),c("BlockManager/model/Block",["backbone"],function(a){return a.Model.extend({defaults:{label:"",content:"",attributes:{}}})}),c("BlockManager/model/Blocks",["backbone","./Block"],function(a,b){return a.Collection.extend({model:b})}),c("BlockManager/view/BlockView",["backbone"],function(a){return a.View.extend({events:{mousedown:"onDrag"},initialize:function(a,b){_.bindAll(this,"onDrop"),this.config=b||{},this.ppfx=this.config.pStylePrefix||"",this.listenTo(this.model,"destroy",this.remove),this.doc=$(document)},onDrag:function(a){if(this.config.getSorter){this.config.em.refreshCanvas();var b=this.config.getSorter();b.setDragHelper(this.el,a),b.startSort(this.el),b.setDropContent(this.model.get("content")),this.doc.on("mouseup",this.onDrop)}},onDrop:function(){this.doc.off("mouseup",this.onDrop),this.config.getSorter().endMove()},render:function(){var a=this.ppfx+"block";return this.$el.addClass(a),this.el.innerHTML='
'+this.model.get("label")+"
",this}})}),c("BlockManager/view/BlocksView",["backbone","./BlockView"],function(a,b){return a.View.extend({initialize:function(a,b){_.bindAll(this,"getSorter","onDrag","onDrop"),this.config=b||{},this.ppfx=this.config.pStylePrefix||"",this.listenTo(this.collection,"add",this.addTo),this.em=this.config.em,this.tac="test-tac",this.grabbingCls=this.ppfx+"grabbing",this.em&&(this.config.getSorter=this.getSorter,this.canvas=this.em.get("Canvas"))},getSorter:function(){if(this.em){if(!this.sorter){var a=this.em.get("Utils"),b=this.canvas;this.sorter=new a.Sorter({container:b.getBody(),placer:b.getPlacerEl(),containerSel:"*",itemSel:"*",pfx:this.ppfx,onStart:this.onDrag,onEndMove:this.onDrop,document:b.getFrameEl().contentDocument,direction:"a",wmargin:1,nested:1,em:this.em})}return this.sorter}},onDrag:function(){this.em.stopDefault()},onDrop:function(a){this.em.runDefault(),a&&a.get&&(a.get("activeOnRender")&&(a.trigger("active"),a.set("activeOnRender",0)),this.em.initChildrenComp(a))},addTo:function(a){this.add(a)},add:function(a,c){var d=c||null,e=new b({model:a,attributes:a.get("attributes")},this.config),f=e.render().el;d?d.appendChild(f):this.$el.append(f)},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.addClass(this.ppfx+"blocks-c"),this}})}),c("BlockManager/main",["require","./config/config","./model/Blocks","./view/BlocksView"],function(a){return function(){var b,c,d={},e=a("./config/config"),f=a("./model/Blocks"),g=a("./view/BlocksView");return{name:"BlockManager",init:function(a){d=a||{};for(var h in e)h in d||(d[h]=e[h]);return b=new f(d.blocks),c=new g({collection:b},d),this},add:function(a,c){var d=c||{};return d.id=a,b.add(d)},get:function(a){return b.get(a)},getAll:function(){return b},render:function(){return c.render().el}}}}),c("BlockManager",["BlockManager/main"],function(a){return a}),c("TraitManager/config/config",[],function(){return{stylePrefix:"trt-",labelContainer:"Component settings"}}),c("TraitManager/view/TraitView",["backbone"],function(a){return a.View.extend({events:{change:"onChange"},initialize:function(a){var b=this.model;this.config=a.config||{},this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.target=b.target,this.className=this.pfx+"trait",this.labelClass=this.ppfx+"label",this.fieldClass=this.ppfx+"field "+this.ppfx+"field-"+b.get("type"),this.inputhClass=this.ppfx+"input-holder",b.off("change:value",this.onValueChange),this.listenTo(b,"change:value",this.onValueChange),this.tmpl='
'},onChange:function(){this.model.set("value",this.getInputEl().value)},getValueForTarget:function(){return this.model.get("value")},onValueChange:function(){var a=this.model,b=this.target,c=a.get("name"),d=this.getValueForTarget();if(a.get("changeProp"))b.set(c,d);else{var e=_.clone(b.get("attributes"));e[c]=d,b.set("attributes",e)}},renderLabel:function(){this.$el.html('
'+this.getLabel()+"
")},getLabel:function(){var a=this.model,b=a.get("label")||a.get("name");return b.charAt(0).toUpperCase()+b.slice(1).replace(/-/g," ")},getInputEl:function(){if(!this.$input){var a=this.model,b=this.target,c=a.get("name"),d={placeholder:a.get("placeholder")||a.get("default"),type:a.get("type")||"text"};if(a.get("changeProp"))d.value=b.get(c);else{var e=b.get("attributes");d.value=a.get("value")||e[c]}a.get("min")&&(d.min=a.get("min")),a.get("max")&&(d.max=a.get("max")),this.$input=$("",d)}return this.$input.get(0)},getModelValue:function(){var a,b=this.model,c=this.target,d=b.get("name");if(b.get("changeProp"))a=c.get(d);else{var e=c.get("attributes");a=b.get("value")||e[d]}return a},renderField:function(){if(!this.$input){this.$el.append(this.tmpl);var a=this.getInputEl();this.$el.find("."+this.inputhClass).prepend(a)}},render:function(){return this.renderLabel(),this.renderField(),this.el.className=this.className,this}})}),c("TraitManager/view/TraitSelectView",["backbone","./TraitView"],function(a,b){return b.extend({initialize:function(a){b.prototype.initialize.apply(this,arguments);var c=this.ppfx;this.tmpl='
'},getInputEl:function(){if(!this.$input){var a=this.model,b=a.get("options")||[];this.input="",this.$input=$(this.input);var c=this.target,d=a.get("name"),e=a.get("value");if(a.get("changeProp"))e=e||c.get(d);else{var f=c.get("attributes");e=f[d]}e&&this.$input.val(e)}return this.$input.get(0)}})}),c("TraitManager/view/TraitCheckboxView",["./TraitView"],function(a){return a.extend({initialize:function(b){a.prototype.initialize.apply(this,arguments);var c=this.ppfx+"chk-icon";this.tmpl='
'},onChange:function(){this.model.set("value",this.getInputEl().checked)},getInputEl:function(){var b;this.$input||(b=1);var c=a.prototype.getInputEl.apply(this,arguments);if(b){var d=this.model,e=d.get("name"),f=this.target;if(d.get("changeProp"))c.checked=f.get(e);else{var g=f.get("attributes");c.checked=!!g[e]}}return c}})}),c("TraitManager/view/TraitNumberView",["./TraitView","Abstract/ui/InputNumber"],function(a,b){return a.extend({getValueForTarget:function(){var a=this.model,b=a.get("value"),c=a.get("unit");return b?b+c:""},getInputEl:function(){if(!this.$input){var a=this.getModelValue(),c=new b({contClass:this.ppfx+"field-int",model:this.model,ppfx:this.ppfx});this.input=c.render(),this.$input=this.input.inputEl,this.$unit=this.input.unitEl,this.model.set("value",a),this.$input.val(a)}return this.$input.get(0)},renderField:function(){this.$input||(this.$el.append(this.tmpl),this.getInputEl(),this.$el.find("."+this.inputhClass).prepend(this.input.el))}})}),c("TraitManager/view/TraitColorView",["./TraitView","Abstract/ui/InputColor"],function(a,b){return a.extend({getInputEl:function(){if(!this.$input){var a=this.getModelValue(),c=new b({contClass:this.ppfx+"field-color",model:this.model,ppfx:this.ppfx});this.input=c.render(),this.$input=this.input.colorEl,a=a||"",this.model.set("value",a).trigger("change:value")}return this.$input.get(0)},renderField:function(){this.$input||(this.getInputEl(),this.$el.append(this.input.el))}})}),c("TraitManager/view/TraitsView",["require","Abstract/view/DomainViews","./TraitView","./TraitSelectView","./TraitCheckboxView","./TraitNumberView","./TraitColorView"],function(a){var b=a("Abstract/view/DomainViews"),c=a("./TraitView"),d=a("./TraitSelectView"),e=a("./TraitCheckboxView"),f=a("./TraitNumberView"),g=a("./TraitColorView");return b.extend({itemView:c,itemsView:{text:c,number:f,select:d,checkbox:e,color:g},initialize:function(a){this.config=a.config||{},this.em=a.editor,this.pfx=this.config.stylePrefix||"",this.className=this.pfx+"traits",this.listenTo(this.em,"change:selectedComponent",this.updatedCollection),this.updatedCollection()},updatedCollection:function(){this.el.className=this.className;var a=this.em.get("selectedComponent");a&&(this.collection=a.get("traits"),this.render())}})}),c("TraitManager/main",["require","./config/config","./model/Traits","./view/TraitsView"],function(a){return function(){var b,c={},d=a("./config/config"),e=(a("./model/Traits"),a("./view/TraitsView"));return{TraitsView:e,name:"TraitManager",getConfig:function(){return c},init:function(a){c=a||{};for(var f in d)f in c||(c[f]=d[f]);var g=c.pStylePrefix;return g&&(c.stylePrefix=g+c.stylePrefix),b=new e({collection:[],editor:c.em,config:c}),this},getTraitsViewer:function(){return b},addType:function(a,c){var d=b.itemView;b.itemsView[a]=d.extend(c)},getType:function(a){return b.itemsView[a]}}}}),c("TraitManager",["TraitManager/main"],function(a){return a});var d=["Utils","StorageManager","DeviceManager","Parser","SelectorManager","ModalDialog","CodeManager","Panels","RichTextEditor","StyleManager","AssetManager","CssComposer","DomComponents","Canvas","Commands","BlockManager","TraitManager"];return c("editor/model/Editor",["backbone","backboneUndo","keymaster","Utils","StorageManager","DeviceManager","Parser","SelectorManager","ModalDialog","CodeManager","Panels","RichTextEditor","StyleManager","AssetManager","CssComposer","DomComponents","Canvas","Commands","BlockManager","TraitManager"],function(){return Backbone.Model.extend({defaults:{clipboard:null,designerMode:!1,selectedComponent:null,previousModel:null,changesCount:0,storables:[],toLoad:[],opened:{},device:""},initialize:function(a){this.config=a,this.set("Config",a),a.el&&a.fromElement&&(this.config.components=a.el.innerHTML),d.forEach(function(a){this.loadModule(a)},this),this.get("toLoad").forEach(function(a){a.onLoad()}),this.initUndoManager(),this.on("change:selectedComponent",this.componentSelected,this),this.on("change:changesCount",this.updateBeforeUnload,this)},updateBeforeUnload:function(){var a=this.get("changesCount");this.config.noticeOnUnload&&a?window.onbeforeunload=function(a){return 1}:window.onbeforeunload=null},loadModule:function(a){var c=this.config,d=new b(a)(),e=d.name.charAt(0).toLowerCase()+d.name.slice(1),f=c[e]||c[d.name]||{};f.pStylePrefix=c.pStylePrefix||"";var g=this.get("StorageManager");if(d.storageKey&&d.store&&d.load&&g){f.stm=g;var h=this.get("storables");h.push(d),this.set("storables",h)}return f.em=this,d.init(Object.create(f)),d["private"]||this.set(d.name,d),d.onLoad&&this.get("toLoad").push(d),this},init:function(a){this.set("Editor",a)},listenRules:function(a){this.stopListening(a,"add remove",this.listenRule),this.listenTo(a,"add remove",this.listenRule),a.each(function(a){this.listenRule(a)},this)},listenRule:function(a){this.stopListening(a,"change:style",this.ruleUpdated),this.listenTo(a,"change:style",this.ruleUpdated)},ruleUpdated:function(a,b,c){var d=this.get("changesCount")+1,e=c?c.avoidStore:0;this.set("changesCount",d);var f=this.get("StorageManager");f.isAutosave()&&d"+a+"":""},getCss:function(){var a=this.get("CssComposer"),b=this.get("DomComponents").getComponent(),c=this.config.protectedCss;return c+this.get("CodeManager").getCode(b,"css",a)},getJs:function(){var a=this.get("DomComponents").getWrapper();return this.get("CodeManager").getCode(a,"js").trim()},store:function(a){var b=this.get("StorageManager"),c={};if(b)return this.get("storables").forEach(function(a){var b=a.store(1);for(var d in b)c[d]=b[d]}),b.store(c,a),this.set("changesCount",0),this.trigger("storage:store",c),c},load:function(a){var b=this.getCacheLoad(1);return this.get("storables").forEach(function(a){a.load(b)}),b},getCacheLoad:function(a){var b=a?1:0;if(this.cacheLoad&&!b)return this.cacheLoad;var c=this.get("StorageManager"),d=[];return c?(this.get("storables").forEach(function(a){var b=a.storageKey;b="function"==typeof b?b():b,keys=b instanceof Array?b:[b],keys.forEach(function(a){d.push(a)})}),this.cacheLoad=c.load(d),this.trigger("storage:load",this.cacheLoad),this.cacheLoad):{}},getDeviceModel:function(){var a=this.get("device");return this.get("DeviceManager").get(a)},runDefault:function(){var a=this.get("Commands").get(this.config.defaultCommand);a&&!this.defaultRunning&&(a.stop(this,this),a.run(this,this),this.defaultRunning=1)},stopDefault:function(){var a=this.get("Commands").get(this.config.defaultCommand);a&&(a.stop(this,this),this.defaultRunning=0)},refreshCanvas:function(){this.set("canvasOffset",this.get("Canvas").getOffset())},clearSelection:function(a){var b=a||window;b.getSelection().removeAllRanges()}})}),c("editor/view/EditorView",["backbone"],function(a){return a.View.extend({initialize:function(){this.pn=this.model.get("Panels"),this.conf=this.model.config,this.className=this.conf.stylePrefix+"editor",this.model.on("loaded",function(){this.pn.active(),this.model.runDefault(),this.model.trigger("load")},this)},render:function(){var a=this.model,b=a.get("UndoManager"),c=a.get("DomComponents"),d=a.get("Config");d.loadCompsOnRender&&(d.clearOnRender&&c.clear(),c.getComponents().add(d.components),b.clear(),c.onLoad());var e=this.conf,f=$(e.el||"body "+e.container);return this.$el.empty(),e.width&&f.css("width",e.width),e.height&&f.css("height",e.height),this.$el.append(a.get("Canvas").render()),this.$el.append(this.pn.render()),this.$el.attr("class",this.className),f.addClass(e.stylePrefix+"editor-cont"),f.html(this.$el),this}})}),c("editor/main",["require","./config/config","./model/Editor","./view/EditorView"],function(a){var b=function(b){var c=b||{},d=a("./config/config"),e=a("./model/Editor"),f=a("./view/EditorView");for(var g in d)g in c||(c[g]=d[g]);c.pStylePrefix=c.stylePrefix;var h=new e(c),i=new f({model:h,config:c});return{editor:h,DomComponents:h.get("DomComponents"),CssComposer:h.get("CssComposer"),StorageManager:h.get("StorageManager"),AssetManager:h.get("AssetManager"),BlockManager:h.get("BlockManager"),TraitManager:h.get("TraitManager"),SelectorManager:h.get("SelectorManager"),CodeManager:h.get("CodeManager"),Commands:h.get("Commands"),Modal:h.get("Modal"),Panels:h.get("Panels"),StyleManager:h.get("StyleManager"),Canvas:h.get("Canvas"),UndoManager:h.get("UndoManager"),DeviceManager:h.get("DeviceManager"),RichTextEditor:h.get("rte"),Utils:h.get("Utils"),Config:h.get("Config"),init:function(){return h.init(this),this},getConfig:function(){return c},getHtml:function(){return h.getHtml()},getCss:function(){return h.getCss()},getJs:function(){return h.getJs()},getComponents:function(){return h.get("DomComponents").getComponents()},setComponents:function(a){return h.setComponents(a),this},addComponents:function(a){return this.getComponents().add(a)},getStyle:function(){return h.get("CssComposer").getAll()},setStyle:function(a){return h.setStyle(a),this},getSelected:function(){return h.getSelected()},setDevice:function(a){return h.set("device",a)},getDevice:function(){return h.get("device")},runCommand:function(a,b){var c,d=h.get("Commands").get(a);return d&&(c=d.run(this,this,b),this.trigger("run:"+a)),c},stopCommand:function(a,b){var c,d=h.get("Commands").get(a);return d&&(c=d.stop(this,this,b),this.trigger("stop:"+a)),c},store:function(a){return h.store(a)},load:function(){return h.load()},getContainer:function(){return c.el},refresh:function(){h.refreshCanvas()},setCustomRte:function(a){this.RichTextEditor.customRte=a},on:function(a,b){return h.on(a,b)},trigger:function(a){return h.trigger(a)},getEl:function(){return i.el},getModel:function(){return h},render:function(){return i.render().el}}};return b}),c("PluginManager/config/config",[],function(){return{plugins:[]}}),c("PluginManager/main",["require","./config/config"],function(a){return function(b){var c=b||{},d=a("./config/config");for(var e in d)e in c||(c[e]=d[e]);var f={};return{add:function(a,b){return f[a]?this:(f[a]=b,this)},get:function(a){return f[a]},getAll:function(){return f}}}}),c("PluginManager",["PluginManager/main"],function(a){return a}),c("grapesjs/main",["require","./config/config","editor/main","PluginManager"],function(a){return function(b){var c=a("./config/config"),d=a("editor/main"),e=a("PluginManager"),f=new e,g=[];return{editors:g,plugins:f,init:function(a){var b=a||{},e=b.container;for(var h in c)h in b||(b[h]=c[h]);if(!e)throw new Error("'container' is required");b.el=document.querySelector(e);var i=new d(b).init(),j=f.getAll();for(var k in j)if(!(b.plugins.indexOf(k)<0)){var l=b.pluginsOpts[k]||{},m=f.get(k);m(i,l)}return b.autorender&&i.render(),g.push(i),i}}}()}),b(["src/config/require-config.js"],function(){b(["grapesjs/main"],function(a){return a})}),c("main",function(){}),b("grapesjs/main")}); \ No newline at end of file diff --git a/index.html b/index.html index f1b3b2cfe..af894b0a7 100755 --- a/index.html +++ b/index.html @@ -270,7 +270,7 @@ font-family: Helvetica, serif; font-weight: 100; background-image:url("http://grapesjs.com/img/bg-gr-v.png"), url("http://grapesjs.com/img/work-desk.jpg"); - background-attachment:scroll, scroll; + background-attachment: fixed, scroll; background-position:left top, center center; background-repeat:repeat-y, no-repeat; background-size: contain, cover; diff --git a/package.json b/package.json index 168eac1da..9da475238 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grapesjs", "description": "Open source Web Template Editor", - "version": "0.5.27", + "version": "0.5.28", "author": "Artur Arseniev", "license": "BSD-3-Clause", "homepage": "http://grapesjs.com", diff --git a/src/commands/main.js b/src/commands/main.js index 972da145e..ee3bc2d5a 100644 --- a/src/commands/main.js +++ b/src/commands/main.js @@ -146,9 +146,7 @@ define(function(require) { return; } - var toolbarEl = ed.Canvas.getToolbarEl(); - var toolbarDisplay = toolbarEl.style.display; var cmdMove = ed.Commands.get('move-comp'); cmdMove.onEndMoveFromModel = function() { diff --git a/src/style_manager/model/Layer.js b/src/style_manager/model/Layer.js index 41273e547..a788f4862 100644 --- a/src/style_manager/model/Layer.js +++ b/src/style_manager/model/Layer.js @@ -1,31 +1,32 @@ define(['backbone'], - function(Backbone) { + function(Backbone) { - return Backbone.Model.extend({ + return Backbone.Model.extend({ - defaults: { - index: '', - active: true, - value: '', - values: {}, - preview: false, - }, + defaults: { + index: '', + value: '', + values: {}, + active: true, + preview: false, + }, - initialize: function(){ - var value = this.get('value'); + initialize: function(){ + var value = this.get('value'); - // If there is no value I'll try to get it from values - // I need value setted to make preview working - if(!value){ - var val = ''; - var values = this.get('values'); + // If there is no value I'll try to get it from values + // I need value setted to make preview working + if(!value){ + var val = ''; + var values = this.get('values'); - for(var prop in values) - val += ' ' + values[prop]; + for (var prop in values) { + val += ' ' + values[prop]; + } - this.set('value', val.trim()); - } + this.set('value', val.trim()); + } }, }); - }); \ No newline at end of file + }); diff --git a/src/style_manager/model/PropertyFactory.js b/src/style_manager/model/PropertyFactory.js index 5b295e5bf..8a664ef3b 100644 --- a/src/style_manager/model/PropertyFactory.js +++ b/src/style_manager/model/PropertyFactory.js @@ -254,6 +254,9 @@ define(['backbone'], case 'transform-scale-z': obj.functionName = 'scaleZ'; break; + case 'background-image': + obj.functionName = 'url'; + break; } // Options diff --git a/src/style_manager/view/LayerView.js b/src/style_manager/view/LayerView.js index 47e4d609b..14ae728b6 100644 --- a/src/style_manager/view/LayerView.js +++ b/src/style_manager/view/LayerView.js @@ -1,175 +1,180 @@ define(['backbone', 'text!./../templates/layer.html'], - function (Backbone, layerTemplate) { - /** - * @class LayerView - * */ - return Backbone.View.extend({ - - events:{ - 'click': 'updateIndex', - }, - - template: _.template(layerTemplate), - - initialize: function(o) { - this.stackModel = o.stackModel || {}; - this.config = o.config || {}; - this.pfx = this.config.stylePrefix || ''; - this.className = this.pfx + 'layer'; - this.sorter = o.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'; - - if( !this.model.get('preview') ){ - this.$el.addClass(this.pfx + 'no-preview'); - } - this.$el.data('model', this.model); - this.delegateEvents(); - }, - - /** - * Delegate sorting - * @param {Event} e - * */ - initSorter: function(e){ - if(this.sorter) - this.sorter.startSort(this.el); - }, - - /** - * Returns properties - * @return {Collection|null} - */ - getProps: function(){ - if(this.stackModel.get) - return this.stackModel.get('properties'); - else - return null; - }, - - /** - * Emitted when the value is changed - */ - valueChanged: function(){ - var preview = this.model.get('preview'); - - if(!preview) - return; - - if(!this.$preview) - this.$preview = this.$el.find('#' + this.pfx + 'preview'); - - var prw = ''; - if(typeof preview === "function") - preview(this.getProps(), this.$preview); - else - this.onPreview(this.getProps(), this.$preview); - }, - - /** - * Default method for changing preview box - * @param {Collection} props - * @param {Element} $el - */ - onPreview: function(props, $el){ - var aV = this.model.get('value').split(' '); - var lim = 3; - var nV = ''; - props.each(function(p, index){ - var v = aV[index] || ''; - if(v){ - if(p.get('type') == 'integer'){ - var vI = parseInt(v, 10), - u = v.replace(vI,''); - vI = !isNaN(vI) ? vI : 0; - if(vI > lim) - vI = lim; - if(vI < -lim) - vI = -lim; - v = vI + u; - } - } - nV += v + ' '; - }); - - if(this.stackModel.get){ - var property = this.stackModel.get('property'); - if(property) - this.$preview.get(0).style[property] = nV; - } - }, - - /** - * Show inputs on this layer - * */ - showProps:function(){ - this.$props = this.model.get('props'); - this.$el.find('#' + this.pfx + 'inputs').html(this.$props.show()); - this.model.set({props: null }, {silent: true }); - }, - - /** @inheritdoc */ - remove: function(e){ - // Prevent from revoming all events on props - if(this.$props) - this.$props.detach(); - - if(e && e.stopPropagation) - e.stopPropagation(); - - Backbone.View.prototype.remove.apply(this, arguments); - - //--- - if(this.model.collection.contains(this.model)) - this.model.collection.remove(this.model); - - if(this.stackModel && this.stackModel.set){ - this.stackModel.set({stackIndex: null}, {silent: true}); - this.stackModel.trigger('updateValue'); - } - }, - - /** - * Update index - * @param Event - * - * @return void - * */ - updateIndex: function(e){ - var i = this.getIndex(); - this.stackModel.set('stackIndex', i); - - if(this.model.collection) - this.model.collection.trigger('deselectAll'); - - this.$el.addClass(this.pfx + 'active'); - }, - - /** - * Fetch model index - * @return {number} Index - */ - getIndex: function(){ - var index = 0; - - if(this.model.collection) - index = this.model.collection.indexOf(this.model); - - return index; - }, - - render : function(){ - this.$el.html( this.template({ - label: 'Layer ' + this.model.get('index'), - pfx: this.pfx, - })); - this.$el.attr('class', this.className); - this.valueChanged(); - return this; - }, - - }); + function (Backbone, layerTemplate) { + /** + * @class LayerView + * */ + return Backbone.View.extend({ + + events:{ + 'click': 'updateIndex', + }, + + template: _.template(layerTemplate), + + initialize: function(o) { + this.stackModel = o.stackModel || {}; + this.config = o.config || {}; + this.pfx = this.config.stylePrefix || ''; + this.className = this.pfx + 'layer'; + this.sorter = o.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'; + + if( !this.model.get('preview') ){ + this.$el.addClass(this.pfx + 'no-preview'); + } + this.$el.data('model', this.model); + this.delegateEvents(); + }, + + /** + * Delegate sorting + * @param {Event} e + * */ + initSorter: function(e){ + if(this.sorter) + this.sorter.startSort(this.el); + }, + + /** + * Returns properties + * @return {Collection|null} + */ + getProps: function(){ + if(this.stackModel.get) + return this.stackModel.get('properties'); + else + return null; + }, + + /** + * Emitted when the value is changed + */ + valueChanged: function() { + var preview = this.model.get('preview'); + + if(!preview) + return; + + if(!this.$preview) + this.$preview = this.$el.find('#' + this.pfx + 'preview'); + + var prw = ''; + var props = this.getProps(); + var previewEl = this.$preview; + if (typeof preview === 'function') { + preview(props, previewEl); + } else { + this.onPreview(props, previewEl); + } + }, + + /** + * Default method for changing preview box + * @param {Collection} props + * @param {Element} $el + */ + onPreview: function(props, $el) { + var aV = this.model.get('value').split(' '); + var lim = 3; + var nV = ''; + props.each(function(p, index){ + var v = aV[index] || ''; + if(v){ + if(p.get('type') == 'integer'){ + var vI = parseInt(v, 10), + u = v.replace(vI,''); + vI = !isNaN(vI) ? vI : 0; + if(vI > lim) + vI = lim; + if(vI < -lim) + vI = -lim; + v = vI + u; + } + } + nV += v + ' '; + }); + + if(this.stackModel.get){ + var property = this.stackModel.get('property'); + if(property) + this.$preview.get(0).style[property] = nV; + } + }, + + /** + * Show inputs on this layer + * */ + showProps:function(){ + this.$props = this.model.get('props'); + this.$el.find('#' + this.pfx + 'inputs').html(this.$props.show()); + this.model.set({props: null }, {silent: true }); + }, + + /** @inheritdoc */ + remove: function(e){ + // Prevent from revoming all events on props + if(this.$props) + this.$props.detach(); + + if(e && e.stopPropagation) + e.stopPropagation(); + + Backbone.View.prototype.remove.apply(this, arguments); + + //--- + if(this.model.collection.contains(this.model)) + this.model.collection.remove(this.model); + + if(this.stackModel && this.stackModel.set){ + this.stackModel.set({stackIndex: null}, {silent: true}); + this.stackModel.trigger('updateValue'); + } + }, + + /** + * Update index + * @param Event + * + * @return void + * */ + updateIndex: function(e) { + var i = this.getIndex(); + this.stackModel.set('stackIndex', i); + + if(this.model.collection) + this.model.collection.trigger('deselectAll'); + + this.$el.addClass(this.pfx + 'active'); + }, + + /** + * Fetch model index + * @return {number} Index + */ + getIndex: function() { + var index = 0; + var model = this.model; + + if (model.collection) { + index = model.collection.indexOf(model); + } + + return index; + }, + + render : function(){ + this.$el.html( this.template({ + label: 'Layer ' + this.model.get('index'), + pfx: this.pfx, + })); + this.$el.attr('class', this.className); + this.valueChanged(); + return this; + }, + + }); }); diff --git a/src/style_manager/view/PropertyCompositeView.js b/src/style_manager/view/PropertyCompositeView.js index dd363bdd4..71ed64176 100644 --- a/src/style_manager/view/PropertyCompositeView.js +++ b/src/style_manager/view/PropertyCompositeView.js @@ -1,142 +1,145 @@ define(['backbone','./PropertyView', 'text!./../templates/propertyComposite.html','require'], - function (Backbone, PropertyView, propertyTemplate, require) { - /** - * @class PropertyCompositeView - * */ - return PropertyView.extend({ - - template: _.template(propertyTemplate), - - initialize: function(o) { - PropertyView.prototype.initialize.apply(this, arguments); - _.bindAll(this, 'build'); - this.config = o.config || {}; - this.className = this.className + ' '+ this.pfx +'composite'; - }, - - /** - * Fired when the input value is updated - */ - valueUpdated: function(){ - if(!this.model.get('detached')) - PropertyView.prototype.valueUpdated.apply(this, arguments); - }, - - /** - * Renders input - * */ - renderInput: function() { - var props = this.model.get('properties'); - var detached = this.model.get('detached'); - if(props && props.length){ - if(!this.$input) - this.$input = $('', {value: 0, type: 'hidden' }); - - if(!this.props){ - this.props = this.model.get('properties'); - } - - if(!this.$props){ - //Not yet supported nested composite - this.props.each(function(prop, index){ - if(prop && prop.get('type') == 'composite'){ - this.props.remove(prop); - console.warn('Nested composite types not yet allowed.'); - } - }, this); - - var PropertiesView = require('./PropertiesView'); - var propsView = new PropertiesView(this.getPropsConfig()); - this.$props = propsView.render().$el; - this.$el.find('#'+ this.pfx +'input-holder').html(this.$props); - } - } - }, - - /** - * Returns configurations that should be past to properties - * @param {Object} opts - * @return {Object} - */ - getPropsConfig: function(opts){ - var that = this; - - result = { - config: this.config, - collection: this.props, - target: this.target, - propTarget: this.propTarget, - // On any change made to children I need to update composite value - onChange: function(el, view, opts){ - var result = that.build(); - that.model.set('value', result, opts); - }, - // Each child property will receive a full composite string, eg. '0px 0px 10px 0px' - // I need to extract from that string the corresponding one to that property. - customValue: function(property, mIndex){ - return that.valueOnIndex(mIndex, property); - }, - }; - - // If detached let follow its standard flow - if(this.model.get('detached')) - delete result.onChange; - - return result; - }, - - /** - * Get default value of the property - * @return {string} - * */ - getDefaultValue: function(){ - var str = ''; - this.props.each(function(prop, index){ - str += prop.get('defaults') + prop.get('unit') + ' '; - }); - return str.replace(/ +$/,''); - }, - - /** - * Extract string from composite value - * @param {number} index Index - * @param {Object} view Property view - * @return {string} - * */ - valueOnIndex: function(index, view){ - var result = null; - var a = this.getComponentValue().split(' '); - if(a.length && a[index]){ - result = a[index]; - if(view && view.model && view.model.get('functionName')){ - var v = this.fetchFromFunction(result); - if(v) - result = v; - } - } - return result; - }, - - /** - * Build composite value - * @param {Object} selectedEl Selected element - * @param {Object} propertyView Property view - * @param {Object} opts Options - * @return {string} - * */ - build: function(selectedEl, propertyView, opts){ - var result = ''; - this.model.get('properties').each(function(prop){ - var v = prop.getValue(); - func = prop.get('functionName'); - - if(func) - v = func + '(' + v + ')'; - - result += v + ' '; - }); - return result.replace(/ +$/,''); - }, - - }); + function (Backbone, PropertyView, propertyTemplate, require) { + /** + * @class PropertyCompositeView + * */ + return PropertyView.extend({ + + template: _.template(propertyTemplate), + + initialize: function(o) { + PropertyView.prototype.initialize.apply(this, arguments); + _.bindAll(this, 'build'); + this.config = o.config || {}; + this.className = this.className + ' '+ this.pfx +'composite'; + }, + + /** + * Fired when the input value is updated + */ + valueUpdated: function(){ + if(!this.model.get('detached')) + PropertyView.prototype.valueUpdated.apply(this, arguments); + }, + + /** + * Renders input + * */ + renderInput: function() { + var model = this.model; + var props = model.get('properties') || []; + var self = this; + + if (props.length) { + if(!this.$input) + this.$input = $('', {value: 0, type: 'hidden' }); + + if (!this.props) { + this.props = model.get('properties'); + } + + if (!this.$props) { + //Not yet supported nested composite + this.props.each(function(prop, index) { + if(prop && prop.get('type') == 'composite') { + this.props.remove(prop); + console.warn('Nested composite types not yet allowed.'); + } + prop.parent = model; + }, this); + + var PropertiesView = require('./PropertiesView'); + var propsView = new PropertiesView(this.getPropsConfig()); + this.$props = propsView.render().$el; + this.$el.find('#'+ this.pfx +'input-holder').html(this.$props); + } + } + }, + + /** + * Returns configurations that should be past to properties + * @param {Object} opts + * @return {Object} + */ + getPropsConfig: function(opts){ + var that = this; + + result = { + config: this.config, + collection: this.props, + target: this.target, + propTarget: this.propTarget, + // On any change made to children I need to update composite value + onChange: function(el, view, opts){ + var result = that.build(); + that.model.set('value', result, opts); + }, + // Each child property will receive a full composite string, eg. '0px 0px 10px 0px' + // I need to extract from that string the corresponding one to that property. + customValue: function(property, mIndex){ + return that.valueOnIndex(mIndex, property); + }, + }; + + // If detached let follow its standard flow + if(this.model.get('detached')) + delete result.onChange; + + return result; + }, + + /** + * Get default value of the property + * @return {string} + * */ + getDefaultValue: function(){ + var str = ''; + this.props.each(function(prop, index){ + str += prop.get('defaults') + prop.get('unit') + ' '; + }); + return str.replace(/ +$/,''); + }, + + /** + * Extract string from composite value + * @param {number} index Index + * @param {Object} view Property view + * @return {string} + * */ + valueOnIndex: function(index, view){ + var result = null; + var a = this.getComponentValue().split(' '); + if(a.length && a[index]){ + result = a[index]; + if(view && view.model && view.model.get('functionName')){ + var v = this.fetchFromFunction(result); + if(v) + result = v; + } + } + return result; + }, + + /** + * Build composite value + * @param {Object} selectedEl Selected element + * @param {Object} propertyView Property view + * @param {Object} opts Options + * @return {string} + * */ + build: function(selectedEl, propertyView, opts){ + var result = ''; + this.model.get('properties').each(function(prop){ + var v = prop.getValue(); + func = prop.get('functionName'); + + if(func) + v = func + '(' + v + ')'; + + result += v + ' '; + }); + return result.replace(/ +$/,''); + }, + + }); }); diff --git a/src/style_manager/view/PropertyFileView.js b/src/style_manager/view/PropertyFileView.js index ab7224f70..22a35d493 100644 --- a/src/style_manager/view/PropertyFileView.js +++ b/src/style_manager/view/PropertyFileView.js @@ -1,134 +1,133 @@ define(['backbone','./PropertyView', 'text!./../templates/propertyFile.html'], - function (Backbone, PropertyView, propertyTemplate) { - /** - * @class PropertyColorView - * */ - return PropertyView.extend({ - - template: _.template(propertyTemplate), - - initialize: function(options) { - PropertyView.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(); - }, - - /** @inheritdoc */ - renderInput: function() { - - if(!this.$input){ - this.$input = $('', {placeholder: this.defaultValue, type: 'text' }); - } - - if(!this.$preview){ - this.$preview = this.$el.find('#' + this.pfx + 'preview-file'); - } - - if(!this.$previewBox){ - this.$previewBox = this.$el.find('#' + this.pfx + 'preview-box'); - } - - if(!this.componentValue || this.componentValue == this.defaultValue) - this.setPreviewView(0); - else - this.setPreviewView(1); - - this.setValue(this.componentValue,0); - }, - - /** - * Change visibility of the preview box - * @param bool Visibility - * - * @return void - * */ - setPreviewView: function(v){ - if(!this.$previewBox) - return; - if(v) - this.$previewBox.addClass(this.pfx + 'show'); - else - this.$previewBox.removeClass(this.pfx + 'show'); - }, - - /** - * Spread url - * @param string Url - * - * @return void - * */ - spreadUrl: function(url){ - this.setValue('url("'+url+'")'); - this.setPreviewView(1); - }, - - /** - * Shows file preview - * @param string Value - * */ - setPreview: function(v){ - if(this.$preview) - this.$preview.css('background-image',v); - }, - - /** @inheritdoc */ - setValue: function(value, f){ - PropertyView.prototype.setValue.apply(this, arguments); - this.setPreview(value); - }, - - /** @inheritdoc */ - renderTemplate: function(){ - this.$el.append( this.template({ - upload : 'Upload', - assets : 'Images', - pfx : this.pfx - })); - }, - - /** @inheritdoc */ - cleanValue: function(){ - this.setPreviewView(0); - this.model.set({value: ''},{silent: true}); - }, - - /** - * Remove file from input - * - * @return void - * */ - removeFile:function(){ - this.model.set('value',this.defaultValue); - PropertyView.prototype.cleanValue.apply(this, arguments); - this.setPreviewView(0); - }, - - /** - * Open dialog for image selecting - * @param {Object} e Event - * - * @return void - * */ - openAssetManager: function(e){ - var that = this; - if(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(model){ - that.modal.close(); - that.spreadUrl(model.get('src')); - that.valueChanged(e); - }); - } - }, - - - }); + function (Backbone, PropertyView, propertyTemplate) { + /** + * @class PropertyColorView + * */ + return PropertyView.extend({ + + template: _.template(propertyTemplate), + + initialize: function(options) { + PropertyView.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(); + }, + + /** @inheritdoc */ + renderInput: function() { + if (!this.$input) { + this.$input = $('', {placeholder: this.defaultValue, type: 'text' }); + } + + if (!this.$preview) { + this.$preview = this.$el.find('#' + this.pfx + 'preview-file'); + } + + if (!this.$previewBox) { + this.$previewBox = this.$el.find('#' + this.pfx + 'preview-box'); + } + + if(!this.componentValue || this.componentValue == this.defaultValue) + this.setPreviewView(0); + else + this.setPreviewView(1); + + this.setValue(this.componentValue, 0); + }, + + /** + * Change visibility of the preview box + * @param bool Visibility + * + * @return void + * */ + setPreviewView: function(v){ + if(!this.$previewBox) + return; + if(v) + this.$previewBox.addClass(this.pfx + 'show'); + else + this.$previewBox.removeClass(this.pfx + 'show'); + }, + + /** + * Spread url + * @param string Url + * + * @return void + * */ + spreadUrl: function(url) { + this.setValue(url); + this.setPreviewView(1); + }, + + /** + * Shows file preview + * @param string Value + * */ + setPreview: function(url) { + if(this.$preview) + this.$preview.css('background-image', "url(" + url + ")"); + }, + + /** @inheritdoc */ + setValue: function(value, f){ + PropertyView.prototype.setValue.apply(this, arguments); + this.setPreview(value); + }, + + /** @inheritdoc */ + renderTemplate: function(){ + this.$el.append( this.template({ + upload : 'Upload', + assets : 'Images', + pfx : this.pfx + })); + }, + + /** @inheritdoc */ + cleanValue: function(){ + this.setPreviewView(0); + this.model.set({value: ''},{silent: true}); + }, + + /** + * Remove file from input + * + * @return void + * */ + removeFile:function(){ + this.model.set('value',this.defaultValue); + PropertyView.prototype.cleanValue.apply(this, arguments); + this.setPreviewView(0); + }, + + /** + * Open dialog for image selecting + * @param {Object} e Event + * + * @return void + * */ + openAssetManager: function(e){ + var that = this; + if(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(model){ + that.modal.close(); + that.spreadUrl(model.get('src')); + that.valueChanged(e); + }); + } + }, + + + }); }); diff --git a/src/style_manager/view/PropertyIntegerView.js b/src/style_manager/view/PropertyIntegerView.js index 51a7826e4..1a4e43a64 100644 --- a/src/style_manager/view/PropertyIntegerView.js +++ b/src/style_manager/view/PropertyIntegerView.js @@ -1,40 +1,41 @@ define(['backbone','./PropertyView', 'Abstract/ui/InputNumber'], - function (Backbone, PropertyView, InputNumber) { + function (Backbone, PropertyView, InputNumber) { - return PropertyView.extend({ + return PropertyView.extend({ - initialize: function(options) { - PropertyView.prototype.initialize.apply(this, arguments); - this.listenTo( this.model ,'change:unit', this.valueChanged); - }, + initialize: function(options) { + PropertyView.prototype.initialize.apply(this, arguments); + this.listenTo( this.model ,'change:unit', this.valueChanged); + }, - /** - * Returns value from inputs - * @return {string} - */ - getValueForTarget: function(){ - return this.model.get('value') + this.model.get('unit'); - }, + /** + * Returns value from inputs + * @return {string} + */ + getValueForTarget: function() { + var model = this.model; + return model.get('value') + model.get('unit'); + }, - renderInput: function() { - if (!this.input) { - var inputNumber = new InputNumber({ - model: this.model, - ppfx: this.ppfx - }); - this.input = inputNumber.render(); - this.$el.append(this.input.$el); - this.$input = this.input.inputEl; - this.$unit = this.input.unitEl; - } - this.setValue(this.componentValue); - }, + renderInput: function() { + if (!this.input) { + var inputNumber = new InputNumber({ + model: this.model, + ppfx: this.ppfx + }); + this.input = inputNumber.render(); + this.$el.append(this.input.$el); + this.$input = this.input.inputEl; + this.$unit = this.input.unitEl; + } + this.setValue(this.componentValue); + }, - renderTemplate: function(){}, + renderTemplate: function(){}, - setValue: function(value) { - this.input.setValue(value, {silent: 1}); - }, + setValue: function(value) { + this.input.setValue(value, {silent: 1}); + }, - }); + }); }); diff --git a/src/style_manager/view/PropertyStackView.js b/src/style_manager/view/PropertyStackView.js index b33723085..a2b53eb33 100644 --- a/src/style_manager/view/PropertyStackView.js +++ b/src/style_manager/view/PropertyStackView.js @@ -28,6 +28,12 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack else { this.checkVisibility(); this.refreshLayers(); + + /* + this.model.get('properties').each(function(prop) { + console.log(prop.get('property'), ' - ', prop.get('value')); + }); + */ } }, @@ -47,10 +53,11 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack * * @return {Object} * */ - indexChanged: function(e){ - var layer = this.getLayers().at(this.model.get('stackIndex')); + indexChanged: function(e) { + var model = this.model; + var layer = this.getLayers().at(model.get('stackIndex')); layer.set('props', this.$props); - this.model.get('properties').each(function(prop){ + model.get('properties').each(function (prop) { prop.trigger('targetUpdated'); }); }, @@ -68,7 +75,7 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack var that = this; var result = PropertyCompositeView.prototype.getPropsConfig.apply(this, arguments); - result.onChange = function(el, view, opt){ + result.onChange = function(el, view, opt) { var model = view.model; var result = that.build(); @@ -91,21 +98,25 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack }, /** - * Extract string from composite value - * @param integer Index - * @param View propView Property view + * Extract string from the composite value of the target + * @param {integer} index Property index + * @param {View} propView Property view * @return string + * @private * */ - valueOnIndex: function(index, propView){ - var result = null; + valueOnIndex: function(index, propView) { + var result = null; + var layerIndex = this.model.get('stackIndex'); + // If detached the value in this case is stacked, eg. substack-prop: 1px, 2px, 3px... - if(this.model.get('detached')){ - var valist = propView.componentValue.split(','); - result = valist[this.model.get('stackIndex')]; - result = result ? result.trim() : result; - }else{ - var aStack = this.getStackValues(); - var strVar = aStack[this.model.get('stackIndex')]; + if (this.model.get('detached')) { + var valist = propView.getTargetValue().split(','); + result = valist[layerIndex]; + result = result ? result.trim() : propView.getDefaultValue(); + result = propView.tryFetchFromFunction(result); + } else { + var aStack = this.getStackValues(); + var strVar = aStack[layerIndex]; if(!strVar) return; var a = strVar.split(' '); @@ -113,11 +124,15 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack result = a[index]; } } + return result; }, - /** @inheritdoc */ - build: function(){ + /** + * Build composite value + * @private + * */ + build: function() { var stackIndex = this.model.get('stackIndex'); if(stackIndex === null) return; @@ -148,15 +163,17 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack * * @return Object * */ - addLayer: function(e){ + addLayer: function(e) { if(this.getTarget()){ var layers = this.getLayers(); var layer = layers.add({ name : 'test' }); var index = layers.indexOf(layer); layer.set('value', this.getDefaultValue()); + // In detached mode valueUpdated will add new 'layer value' // to all subprops this.valueUpdated(); + // This will set subprops with a new default values this.model.set('stackIndex', index); return layer; @@ -166,11 +183,13 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack /** * Fired when the input value is updated */ - valueUpdated: function(){ - if(!this.model.get('detached')) - this.model.set('value', this.createValue()); - else{ - this.model.get('properties').each(function(prop){ + valueUpdated: function() { + var model = this.model; + + if (!model.get('detached')) { + model.set('value', this.createValue()); + } else { + model.get('properties').each(function(prop){ prop.trigger('change:value'); }); } @@ -216,15 +235,17 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack * Only for detached stacks * @return {Array} */ - getLayersFromTarget: function(){ + getLayersFromTarget: function() { var arr = []; var target = this.getTarget(); if(!target) return arr; var trgStyle = target.get('style'); - this.model.get('properties').each(function(prop){ + + this.model.get('properties').each(function(prop) { var style = trgStyle[prop.get('property')]; - if(style){ + + if (style) { var list = style.split(','); for(var i = 0, len = list.length; i < len; i++){ var val = list[i].trim(); @@ -239,22 +260,25 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack } } }); + return arr; }, /** * Refresh layers * */ - refreshLayers: function(){ + refreshLayers: function() { var n = []; var a = []; var fieldName = 'value'; - if(this.model.get('detached')){ + var detached = this.model.get('detached'); + + if (detached) { fieldName = 'values'; a = this.getLayersFromTarget(); - }else{ + } else { var v = this.getComponentValue(); - if(v){ + if (v) { // Remove spaces inside functions: // eg: // From: 1px 1px rgba(2px, 2px, 2px), 2px 2px rgba(3px, 3px, 3px) @@ -266,17 +290,23 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack a = v.split(', '); } } + _.each(a, function(e){ var o = {}; o[fieldName] = e; n.push(o); },this); + this.$props.detach(); var layers = this.getLayers(); layers.reset(); layers.add(n); - if(!this.model.get('detached')) + + // Avoid updating with detached as it will cause issues on next change + if (!detached) { this.valueUpdated(); + } + this.model.set({stackIndex: null}, {silent: true}); }, diff --git a/src/style_manager/view/PropertyView.js b/src/style_manager/view/PropertyView.js index 3d40b2761..e82a07747 100644 --- a/src/style_manager/view/PropertyView.js +++ b/src/style_manager/view/PropertyView.js @@ -91,8 +91,8 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat * * @return {Boolean} * */ - sameValue: function(){ - return this.getComponentValue() == (this.model.get('value') + this.model.get('unit')); + sameValue: function() { + return this.getComponentValue() == this.getValueForTarget(); }, @@ -102,6 +102,7 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat * @return {String} * */ getComponentValue: function() { + var propModel = this.model; var target = this.getTarget(); if(!target) @@ -114,7 +115,7 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat this.componentValue = this.defaultValue + (this.unit || ''); // todo model // Check if wrap inside function is required - if(this.model.get('functionName')){ + if (propModel.get('functionName')) { var v = this.fetchFromFunction(this.componentValue); if(v) this.componentValue = v; @@ -123,7 +124,7 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat // This allow to ovveride the normal flow of selecting component value, // useful in composite properties if(this.customValue && typeof this.customValue === "function"){ - var index = this.model.collection.indexOf(this.model); + var index = propModel.collection.indexOf(propModel); var t = this.customValue(this, index); if(t) this.componentValue = t; @@ -132,22 +133,68 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat return this.componentValue; }, + /** + * Refactor of getComponentValue + * @param {Object} [opts] Options + * @param {Boolean} [options.fetchFromFunction] + * @param {Boolean} [options.ignoreDefault] + * @return string + * @private + */ + getTargetValue: function (opts) { + var result; + var opt = opts || {}; + var model = this.model; + var target = this.getTarget(); + + if (!target) { + return result; + } + + result = target.get('style')[model.get('property')]; + + if (!result && !opt.ignoreDefault) { + result = this.getDefaultValue(); + } + + return result; + }, + + /** + * Returns default value + * @return {String} + * @private + */ + getDefaultValue: function () { + return this.model.get('defaults'); + }, + /** * Fetch the string from function type value * @param {String} v Function type value * * @return {String} * */ - fetchFromFunction: function(v){ + fetchFromFunction: function(v) { return v.substring(v.indexOf("(") + 1, v.lastIndexOf(")")); }, + tryFetchFromFunction: function(value) { + if (!this.model.get('functionName')) { + return value; + } + + var start = value.indexOf("(") + 1; + var end = value.lastIndexOf(")"); + return value.substring(start, end); + }, + /** * Returns value from inputs * @return {string} */ - getValueForTarget: function(){ - return this.model.getValue(); + getValueForTarget: function() { + return this.model.get('value'); }, /** diff --git a/src/utils/Sorter.js b/src/utils/Sorter.js index 96e787483..6cf9feea2 100644 --- a/src/utils/Sorter.js +++ b/src/utils/Sorter.js @@ -431,7 +431,7 @@ define(function(require) { // Get children based on getChildrenContainer var $elem = $(elem); var elemData = $elem.data('model'); - if (elemData) { + if (elemData && elemData.view) { elem = elemData.view.getChildrenContainer(); } diff --git a/test/specs/dom_components/view/ComponentTextView.js b/test/specs/dom_components/view/ComponentTextView.js index bedd6276f..02b1fbb7c 100644 --- a/test/specs/dom_components/view/ComponentTextView.js +++ b/test/specs/dom_components/view/ComponentTextView.js @@ -35,7 +35,7 @@ define([path + 'ComponentTextView', 'DomComponents/model/Component'], }); it('Component empty', function() { - $fixture.html().should.equal('
'); + $fixture.html().should.equal('
'); }); it('Input content is stored in model', function() { diff --git a/test/specs/dom_components/view/ComponentV.js b/test/specs/dom_components/view/ComponentV.js index d6a4d9bef..a7aa6a3a3 100644 --- a/test/specs/dom_components/view/ComponentV.js +++ b/test/specs/dom_components/view/ComponentV.js @@ -42,23 +42,23 @@ define([path + 'ComponentView', 'DomComponents/model/Component', 'DomComponents' }); it('Component empty', function() { - $fixture.html().should.equal('
'); + $fixture.html().should.equal('
'); }); it('Add helper class on update of state', function() { model.set('state', 'test'); - $fixture.html().should.equal('
'); + $fixture.html().should.equal('
'); }); it('Clean form helper state', function() { model.set('state', 'test'); model.set('state', ''); - $fixture.html().should.equal('
'); + $fixture.html().should.equal('
'); }); it('Add helper class on status update', function() { model.set('status', 'selected'); - $fixture.html().should.equal('
'); + $fixture.html().should.equal('
'); }); it('Get string of classes', function() { @@ -131,7 +131,7 @@ define([path + 'ComponentView', 'DomComponents/model/Component', 'DomComponents' model: model, defaultTypes: dcomp.componentTypes, }); - view.render().$el.html().should.equal('
'); + view.render().$el.html().should.equal('
'); }); });