diff --git a/README.md b/README.md index 99a35a6bb..5e06fa9c8 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Newsletter Demo - http://grapesjs.com/demo-newsletter-editor.html * [Testing](#testing) * [Plugins](#plugins) * [Support](#support) +* [Changelog](https://github.com/artf/grapesjs/releases) * [License](#license) @@ -188,6 +189,7 @@ $ npm test * [grapesjs-component-countdown](https://github.com/artf/grapesjs-component-countdown) - Simple countdown component * [grapesjs-style-gradient](https://github.com/artf/grapesjs-style-gradient) - Add a gradient type input * [grapesjs-blocks-flexbox](https://github.com/artf/grapesjs-blocks-flexbox) - Add the flexbox block +* [grapesjs-lory-slider](https://github.com/artf/grapesjs-lory-slider) - Slider component by using [lory](https://github.com/meandmax/lory) ### Presets * [grapesjs-preset-webpage](https://github.com/artf/grapesjs-preset-webpage) - Webpage Builder diff --git a/dist/css/grapes.min.css b/dist/css/grapes.min.css index 23b048f93..26cc99b9d 100644 --- a/dist/css/grapes.min.css +++ b/dist/css/grapes.min.css @@ -1,4 +1,4 @@ .sp-container{position:absolute;top:0;left:0;display:inline-block;*display:inline;*zoom:1;z-index:9999994;overflow:hidden}.sp-container.sp-flat{position:relative}.sp-container,.sp-container *{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.sp-top{position:relative;width:100%;display:inline-block}.sp-top-inner{position:absolute;top:0;left:0;bottom:0;right:0}.sp-color{position:absolute;top:0;left:0;bottom:0;right:20%}.sp-hue{position:absolute;top:0;right:0;bottom:0;left:84%;height:100%}.sp-clear-enabled .sp-hue{top:33px;height:77.5%}.sp-fill{padding-top:80%}.sp-sat,.sp-val{position:absolute;top:0;left:0;right:0;bottom:0}.sp-alpha-enabled .sp-top{margin-bottom:18px}.sp-alpha-enabled .sp-alpha{display:block}.sp-alpha-handle{position:absolute;top:-4px;bottom:-4px;width:6px;left:50%;cursor:pointer;border:1px solid black;background:white;opacity:.8}.sp-alpha{display:none;position:absolute;bottom:-14px;right:0;left:0;height:8px}.sp-alpha-inner{border:solid 1px #333}.sp-clear{display:none}.sp-clear.sp-clear-display{background-position:center}.sp-clear-enabled .sp-clear{display:block;position:absolute;top:0px;right:0;bottom:0;left:84%;height:28px}.sp-container,.sp-replacer,.sp-preview,.sp-dragger,.sp-slider,.sp-alpha,.sp-clear,.sp-alpha-handle,.sp-container.sp-dragging .sp-input,.sp-container button{-webkit-user-select:none;-moz-user-select:-moz-none;-o-user-select:none;user-select:none}.sp-container.sp-input-disabled .sp-input-container{display:none}.sp-container.sp-buttons-disabled .sp-button-container{display:none}.sp-container.sp-palette-buttons-disabled .sp-palette-button-container{display:none}.sp-palette-only .sp-picker-container{display:none}.sp-palette-disabled .sp-palette-container{display:none}.sp-initial-disabled .sp-initial{display:none}.sp-sat{background-image:-webkit-gradient(linear, 0 0, 100% 0, from(#fff), to(rgba(204,154,129,0)));background-image:-webkit-linear-gradient(left, #fff, rgba(204,154,129,0));background-image:-moz-linear-gradient(left, #fff, rgba(204,154,129,0));background-image:-o-linear-gradient(left, #fff, rgba(204,154,129,0));background-image:-ms-linear-gradient(left, #fff, rgba(204,154,129,0));background-image:linear-gradient(to right, #fff, rgba(204,154,129,0));-ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr=#FFFFFFFF, endColorstr=#00CC9A81)";filter:progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr='#FFFFFFFF', endColorstr='#00CC9A81')}.sp-val{background-image:-webkit-gradient(linear, 0 100%, 0 0, from(#000), to(rgba(204,154,129,0)));background-image:-webkit-linear-gradient(bottom, #000, rgba(204,154,129,0));background-image:-moz-linear-gradient(bottom, #000, rgba(204,154,129,0));background-image:-o-linear-gradient(bottom, #000, rgba(204,154,129,0));background-image:-ms-linear-gradient(bottom, #000, rgba(204,154,129,0));background-image:linear-gradient(to top, #000, rgba(204,154,129,0));-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#00CC9A81, endColorstr=#FF000000)";filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00CC9A81', endColorstr='#FF000000')}.sp-hue{background:-moz-linear-gradient(top, red 0%, #ff0 17%, lime 33%, cyan 50%, blue 67%, #f0f 83%, red 100%);background:-ms-linear-gradient(top, red 0%, #ff0 17%, lime 33%, cyan 50%, blue 67%, #f0f 83%, red 100%);background:-o-linear-gradient(top, red 0%, #ff0 17%, lime 33%, cyan 50%, blue 67%, #f0f 83%, red 100%);background:-webkit-gradient(linear, left top, left bottom, from(red), color-stop(0.17, #ff0), color-stop(0.33, lime), color-stop(0.5, cyan), color-stop(0.67, blue), color-stop(0.83, #f0f), to(red));background:-webkit-linear-gradient(top, red 0%, #ff0 17%, lime 33%, cyan 50%, blue 67%, #f0f 83%, red 100%);background:linear-gradient(to bottom, red 0%, #ff0 17%, lime 33%, cyan 50%, blue 67%, #f0f 83%, red 100%)}.sp-1{height:17%;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0000', endColorstr='#ffff00')}.sp-2{height:16%;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff00', endColorstr='#00ff00')}.sp-3{height:17%;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ff00', endColorstr='#00ffff')}.sp-4{height:17%;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ffff', endColorstr='#0000ff')}.sp-5{height:16%;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0000ff', endColorstr='#ff00ff')}.sp-6{height:17%;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff00ff', endColorstr='#ff0000')}.sp-hidden{display:none !important}.sp-cf:before,.sp-cf:after{content:"";display:table}.sp-cf:after{clear:both}.sp-cf{*zoom:1}@media (max-device-width: 480px){.sp-color{right:40%}.sp-hue{left:63%}.sp-fill{padding-top:60%}}.sp-dragger{border-radius:5px;height:5px;width:5px;border:1px solid #fff;background:#000;cursor:pointer;position:absolute;top:0;left:0}.sp-slider{position:absolute;top:0;cursor:pointer;height:3px;left:-1px;right:-1px;border:1px solid #000;background:white;opacity:.8}.sp-container{border-radius:0;background-color:#ECECEC;border:solid 1px #f0c49B;padding:0}.sp-container,.sp-container button,.sp-container input,.sp-color,.sp-hue,.sp-clear{font:normal 12px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.sp-top{margin-bottom:3px}.sp-color,.sp-hue,.sp-clear{border:solid 1px #666}.sp-input-container{float:right;width:100px;margin-bottom:4px}.sp-initial-disabled .sp-input-container{width:100%}.sp-input{font-size:12px !important;border:1px inset;padding:4px 5px;margin:0;width:100%;background:transparent;border-radius:3px;color:#222}.sp-input:focus{border:1px solid orange}.sp-input.sp-validation-error{border:1px solid red;background:#fdd}.sp-picker-container,.sp-palette-container{float:left;position:relative;padding:10px;padding-bottom:300px;margin-bottom:-290px}.sp-picker-container{width:172px;border-left:solid 1px #fff}.sp-palette-container{border-right:solid 1px #ccc}.sp-palette-only .sp-palette-container{border:0}.sp-palette .sp-thumb-el{display:block;position:relative;float:left;width:24px;height:15px;margin:3px;cursor:pointer;border:solid 2px transparent}.sp-palette .sp-thumb-el:hover,.sp-palette .sp-thumb-el.sp-thumb-active{border-color:orange}.sp-thumb-el{position:relative}.sp-initial{float:left;border:solid 1px #333}.sp-initial span{width:30px;height:25px;border:none;display:block;float:left;margin:0}.sp-initial .sp-clear-display{background-position:center}.sp-palette-button-container,.sp-button-container{float:right}.sp-replacer{margin:0;overflow:hidden;cursor:pointer;padding:4px;display:inline-block;*zoom:1;*display:inline;border:solid 1px #91765d;background:#eee;color:#333;vertical-align:middle}.sp-replacer:hover,.sp-replacer.sp-active{border-color:#F0C49B;color:#111}.sp-replacer.sp-disabled{cursor:default;border-color:silver;color:silver}.sp-dd{padding:2px 0;height:16px;line-height:16px;float:left;font-size:10px}.sp-preview{position:relative;width:25px;height:20px;border:solid 1px #222;margin-right:5px;float:left;z-index:0}.sp-palette{*width:220px;max-width:220px}.sp-palette .sp-thumb-el{width:16px;height:16px;margin:2px 1px;border:solid 1px #d0d0d0}.sp-container{padding-bottom:0}.sp-container button{background-color:#eeeeee;background-image:-webkit-linear-gradient(top, #eee, #ccc);background-image:-moz-linear-gradient(top, #eee, #ccc);background-image:-ms-linear-gradient(top, #eee, #ccc);background-image:-o-linear-gradient(top, #eee, #ccc);background-image:linear-gradient(to bottom, #eee, #ccc);border:1px solid #ccc;border-bottom:1px solid #bbb;border-radius:3px;color:#333;font-size:14px;line-height:1;padding:5px 4px;text-align:center;text-shadow:0 1px 0 #eee;vertical-align:middle}.sp-container button:hover{background-color:#dddddd;background-image:-webkit-linear-gradient(top, #ddd, #bbb);background-image:-moz-linear-gradient(top, #ddd, #bbb);background-image:-ms-linear-gradient(top, #ddd, #bbb);background-image:-o-linear-gradient(top, #ddd, #bbb);background-image:linear-gradient(to bottom, #ddd, #bbb);border:1px solid #bbb;border-bottom:1px solid #999;cursor:pointer;text-shadow:0 1px 0 #ddd}.sp-container button:active{border:1px solid #aaa;border-bottom:1px solid #888;-webkit-box-shadow:inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;-moz-box-shadow:inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;-ms-box-shadow:inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;-o-box-shadow:inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;box-shadow:inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee}.sp-cancel{font-size:11px;color:#d93f3f !important;margin:0;padding:2px;margin-right:5px;vertical-align:middle;text-decoration:none}.sp-cancel:hover{color:#d93f3f !important;text-decoration:underline}.sp-palette span:hover,.sp-palette span.sp-thumb-active{border-color:#000}.sp-preview,.sp-alpha,.sp-thumb-el{position:relative;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==)}.sp-preview-inner,.sp-alpha-inner,.sp-thumb-inner{display:block;position:absolute;top:0;left:0;bottom:0;right:0}.sp-palette .sp-thumb-inner{background-position:50% 50%;background-repeat:no-repeat}.sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIVJREFUeNpiYBhsgJFMffxAXABlN5JruT4Q3wfi/0DsT64h8UD8HmpIPCWG/KemIfOJCUB+Aoacx6EGBZyHBqI+WsDCwuQ9mhxeg2A210Ntfo8klk9sOMijaURm7yc1UP2RNCMbKE9ODK1HM6iegYLkfx8pligC9lCD7KmRof0ZhjQACDAAceovrtpVBRkAAAAASUVORK5CYII=)}.sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAMdJREFUOE+tkgsNwzAMRMugEAahEAahEAZhEAqlEAZhEAohEAYh81X2dIm8fKpEspLGvudPOsUYpxE2BIJCroJmEW9qJ+MKaBFhEMNabSy9oIcIPwrB+afvAUFoK4H0tMaQ3XtlrggDhOVVMuT4E5MMG0FBbCEYzjYT7OxLEvIHQLY2zWwQ3D+9luyOQTfKDiFD3iUIfPk8VqrKjgAiSfGFPecrg6HN6m/iBcwiDAo7WiBeawa+Kwh7tZoSCGLMqwlSAzVDhoK+6vH4G0P5wdkAAAAASUVORK5CYII=)}.sp-clear-display{background-repeat:no-repeat;background-position:center;background-image:url(data:image/gif;base64,R0lGODlhFAAUAPcAAAAAAJmZmZ2dnZ6enqKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq/Hx8fLy8vT09PX19ff39/j4+Pn5+fr6+vv7+wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAP8ALAAAAAAUABQAAAihAP9FoPCvoMGDBy08+EdhQAIJCCMybCDAAYUEARBAlFiQQoMABQhKUJBxY0SPICEYHBnggEmDKAuoPMjS5cGYMxHW3IiT478JJA8M/CjTZ0GgLRekNGpwAsYABHIypcAgQMsITDtWJYBR6NSqMico9cqR6tKfY7GeBCuVwlipDNmefAtTrkSzB1RaIAoXodsABiZAEFB06gIBWC1mLVgBa0AAOw==)}/*! * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url("../fonts/fontawesome-webfont.eot?v=4.7.0");src:url("../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0") format("embedded-opentype"),url("../fonts/fontawesome-webfont.woff2?v=4.7.0") format("woff2"),url("../fonts/fontawesome-webfont.woff?v=4.7.0") format("woff"),url("../fonts/fontawesome-webfont.ttf?v=4.7.0") format("truetype"),url("../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular") format("svg");font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14286em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14286em;width:2.14286em;top:.14286em;text-align:center}.fa-li.fa-lg{left:-1.85714em}.fa-border{padding:.2em .25em .15em;border:solid 0.08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:""}.fa-music:before{content:""}.fa-search:before{content:""}.fa-envelope-o:before{content:""}.fa-heart:before{content:""}.fa-star:before{content:""}.fa-star-o:before{content:""}.fa-user:before{content:""}.fa-film:before{content:""}.fa-th-large:before{content:""}.fa-th:before{content:""}.fa-th-list:before{content:""}.fa-check:before{content:""}.fa-remove:before,.fa-close:before,.fa-times:before{content:""}.fa-search-plus:before{content:""}.fa-search-minus:before{content:""}.fa-power-off:before{content:""}.fa-signal:before{content:""}.fa-gear:before,.fa-cog:before{content:""}.fa-trash-o:before{content:""}.fa-home:before{content:""}.fa-file-o:before{content:""}.fa-clock-o:before{content:""}.fa-road:before{content:""}.fa-download:before{content:""}.fa-arrow-circle-o-down:before{content:""}.fa-arrow-circle-o-up:before{content:""}.fa-inbox:before{content:""}.fa-play-circle-o:before{content:""}.fa-rotate-right:before,.fa-repeat:before{content:""}.fa-refresh:before{content:""}.fa-list-alt:before{content:""}.fa-lock:before{content:""}.fa-flag:before{content:""}.fa-headphones:before{content:""}.fa-volume-off:before{content:""}.fa-volume-down:before{content:""}.fa-volume-up:before{content:""}.fa-qrcode:before{content:""}.fa-barcode:before{content:""}.fa-tag:before{content:""}.fa-tags:before{content:""}.fa-book:before{content:""}.fa-bookmark:before{content:""}.fa-print:before{content:""}.fa-camera:before{content:""}.fa-font:before{content:""}.fa-bold:before{content:""}.fa-italic:before{content:""}.fa-text-height:before{content:""}.fa-text-width:before{content:""}.fa-align-left:before{content:""}.fa-align-center:before{content:""}.fa-align-right:before{content:""}.fa-align-justify:before{content:""}.fa-list:before{content:""}.fa-dedent:before,.fa-outdent:before{content:""}.fa-indent:before{content:""}.fa-video-camera:before{content:""}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:""}.fa-pencil:before{content:""}.fa-map-marker:before{content:""}.fa-adjust:before{content:""}.fa-tint:before{content:""}.fa-edit:before,.fa-pencil-square-o:before{content:""}.fa-share-square-o:before{content:""}.fa-check-square-o:before{content:""}.fa-arrows:before{content:""}.fa-step-backward:before{content:""}.fa-fast-backward:before{content:""}.fa-backward:before{content:""}.fa-play:before{content:""}.fa-pause:before{content:""}.fa-stop:before{content:""}.fa-forward:before{content:""}.fa-fast-forward:before{content:""}.fa-step-forward:before{content:""}.fa-eject:before{content:""}.fa-chevron-left:before{content:""}.fa-chevron-right:before{content:""}.fa-plus-circle:before{content:""}.fa-minus-circle:before{content:""}.fa-times-circle:before{content:""}.fa-check-circle:before{content:""}.fa-question-circle:before{content:""}.fa-info-circle:before{content:""}.fa-crosshairs:before{content:""}.fa-times-circle-o:before{content:""}.fa-check-circle-o:before{content:""}.fa-ban:before{content:""}.fa-arrow-left:before{content:""}.fa-arrow-right:before{content:""}.fa-arrow-up:before{content:""}.fa-arrow-down:before{content:""}.fa-mail-forward:before,.fa-share:before{content:""}.fa-expand:before{content:""}.fa-compress:before{content:""}.fa-plus:before{content:""}.fa-minus:before{content:""}.fa-asterisk:before{content:""}.fa-exclamation-circle:before{content:""}.fa-gift:before{content:""}.fa-leaf:before{content:""}.fa-fire:before{content:""}.fa-eye:before{content:""}.fa-eye-slash:before{content:""}.fa-warning:before,.fa-exclamation-triangle:before{content:""}.fa-plane:before{content:""}.fa-calendar:before{content:""}.fa-random:before{content:""}.fa-comment:before{content:""}.fa-magnet:before{content:""}.fa-chevron-up:before{content:""}.fa-chevron-down:before{content:""}.fa-retweet:before{content:""}.fa-shopping-cart:before{content:""}.fa-folder:before{content:""}.fa-folder-open:before{content:""}.fa-arrows-v:before{content:""}.fa-arrows-h:before{content:""}.fa-bar-chart-o:before,.fa-bar-chart:before{content:""}.fa-twitter-square:before{content:""}.fa-facebook-square:before{content:""}.fa-camera-retro:before{content:""}.fa-key:before{content:""}.fa-gears:before,.fa-cogs:before{content:""}.fa-comments:before{content:""}.fa-thumbs-o-up:before{content:""}.fa-thumbs-o-down:before{content:""}.fa-star-half:before{content:""}.fa-heart-o:before{content:""}.fa-sign-out:before{content:""}.fa-linkedin-square:before{content:""}.fa-thumb-tack:before{content:""}.fa-external-link:before{content:""}.fa-sign-in:before{content:""}.fa-trophy:before{content:""}.fa-github-square:before{content:""}.fa-upload:before{content:""}.fa-lemon-o:before{content:""}.fa-phone:before{content:""}.fa-square-o:before{content:""}.fa-bookmark-o:before{content:""}.fa-phone-square:before{content:""}.fa-twitter:before{content:""}.fa-facebook-f:before,.fa-facebook:before{content:""}.fa-github:before{content:""}.fa-unlock:before{content:""}.fa-credit-card:before{content:""}.fa-feed:before,.fa-rss:before{content:""}.fa-hdd-o:before{content:""}.fa-bullhorn:before{content:""}.fa-bell:before{content:""}.fa-certificate:before{content:""}.fa-hand-o-right:before{content:""}.fa-hand-o-left:before{content:""}.fa-hand-o-up:before{content:""}.fa-hand-o-down:before{content:""}.fa-arrow-circle-left:before{content:""}.fa-arrow-circle-right:before{content:""}.fa-arrow-circle-up:before{content:""}.fa-arrow-circle-down:before{content:""}.fa-globe:before{content:""}.fa-wrench:before{content:""}.fa-tasks:before{content:""}.fa-filter:before{content:""}.fa-briefcase:before{content:""}.fa-arrows-alt:before{content:""}.fa-group:before,.fa-users:before{content:""}.fa-chain:before,.fa-link:before{content:""}.fa-cloud:before{content:""}.fa-flask:before{content:""}.fa-cut:before,.fa-scissors:before{content:""}.fa-copy:before,.fa-files-o:before{content:""}.fa-paperclip:before{content:""}.fa-save:before,.fa-floppy-o:before{content:""}.fa-square:before{content:""}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:""}.fa-list-ul:before{content:""}.fa-list-ol:before{content:""}.fa-strikethrough:before{content:""}.fa-underline:before{content:""}.fa-table:before{content:""}.fa-magic:before{content:""}.fa-truck:before{content:""}.fa-pinterest:before{content:""}.fa-pinterest-square:before{content:""}.fa-google-plus-square:before{content:""}.fa-google-plus:before{content:""}.fa-money:before{content:""}.fa-caret-down:before{content:""}.fa-caret-up:before{content:""}.fa-caret-left:before{content:""}.fa-caret-right:before{content:""}.fa-columns:before{content:""}.fa-unsorted:before,.fa-sort:before{content:""}.fa-sort-down:before,.fa-sort-desc:before{content:""}.fa-sort-up:before,.fa-sort-asc:before{content:""}.fa-envelope:before{content:""}.fa-linkedin:before{content:""}.fa-rotate-left:before,.fa-undo:before{content:""}.fa-legal:before,.fa-gavel:before{content:""}.fa-dashboard:before,.fa-tachometer:before{content:""}.fa-comment-o:before{content:""}.fa-comments-o:before{content:""}.fa-flash:before,.fa-bolt:before{content:""}.fa-sitemap:before{content:""}.fa-umbrella:before{content:""}.fa-paste:before,.fa-clipboard:before{content:""}.fa-lightbulb-o:before{content:""}.fa-exchange:before{content:""}.fa-cloud-download:before{content:""}.fa-cloud-upload:before{content:""}.fa-user-md:before{content:""}.fa-stethoscope:before{content:""}.fa-suitcase:before{content:""}.fa-bell-o:before{content:""}.fa-coffee:before{content:""}.fa-cutlery:before{content:""}.fa-file-text-o:before{content:""}.fa-building-o:before{content:""}.fa-hospital-o:before{content:""}.fa-ambulance:before{content:""}.fa-medkit:before{content:""}.fa-fighter-jet:before{content:""}.fa-beer:before{content:""}.fa-h-square:before{content:""}.fa-plus-square:before{content:""}.fa-angle-double-left:before{content:""}.fa-angle-double-right:before{content:""}.fa-angle-double-up:before{content:""}.fa-angle-double-down:before{content:""}.fa-angle-left:before{content:""}.fa-angle-right:before{content:""}.fa-angle-up:before{content:""}.fa-angle-down:before{content:""}.fa-desktop:before{content:""}.fa-laptop:before{content:""}.fa-tablet:before{content:""}.fa-mobile-phone:before,.fa-mobile:before{content:""}.fa-circle-o:before{content:""}.fa-quote-left:before{content:""}.fa-quote-right:before{content:""}.fa-spinner:before{content:""}.fa-circle:before{content:""}.fa-mail-reply:before,.fa-reply:before{content:""}.fa-github-alt:before{content:""}.fa-folder-o:before{content:""}.fa-folder-open-o:before{content:""}.fa-smile-o:before{content:""}.fa-frown-o:before{content:""}.fa-meh-o:before{content:""}.fa-gamepad:before{content:""}.fa-keyboard-o:before{content:""}.fa-flag-o:before{content:""}.fa-flag-checkered:before{content:""}.fa-terminal:before{content:""}.fa-code:before{content:""}.fa-mail-reply-all:before,.fa-reply-all:before{content:""}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:""}.fa-location-arrow:before{content:""}.fa-crop:before{content:""}.fa-code-fork:before{content:""}.fa-unlink:before,.fa-chain-broken:before{content:""}.fa-question:before{content:""}.fa-info:before{content:""}.fa-exclamation:before{content:""}.fa-superscript:before{content:""}.fa-subscript:before{content:""}.fa-eraser:before{content:""}.fa-puzzle-piece:before{content:""}.fa-microphone:before{content:""}.fa-microphone-slash:before{content:""}.fa-shield:before{content:""}.fa-calendar-o:before{content:""}.fa-fire-extinguisher:before{content:""}.fa-rocket:before{content:""}.fa-maxcdn:before{content:""}.fa-chevron-circle-left:before{content:""}.fa-chevron-circle-right:before{content:""}.fa-chevron-circle-up:before{content:""}.fa-chevron-circle-down:before{content:""}.fa-html5:before{content:""}.fa-css3:before{content:""}.fa-anchor:before{content:""}.fa-unlock-alt:before{content:""}.fa-bullseye:before{content:""}.fa-ellipsis-h:before{content:""}.fa-ellipsis-v:before{content:""}.fa-rss-square:before{content:""}.fa-play-circle:before{content:""}.fa-ticket:before{content:""}.fa-minus-square:before{content:""}.fa-minus-square-o:before{content:""}.fa-level-up:before{content:""}.fa-level-down:before{content:""}.fa-check-square:before{content:""}.fa-pencil-square:before{content:""}.fa-external-link-square:before{content:""}.fa-share-square:before{content:""}.fa-compass:before{content:""}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:""}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:""}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:""}.fa-euro:before,.fa-eur:before{content:""}.fa-gbp:before{content:""}.fa-dollar:before,.fa-usd:before{content:""}.fa-rupee:before,.fa-inr:before{content:""}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:""}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:""}.fa-won:before,.fa-krw:before{content:""}.fa-bitcoin:before,.fa-btc:before{content:""}.fa-file:before{content:""}.fa-file-text:before{content:""}.fa-sort-alpha-asc:before{content:""}.fa-sort-alpha-desc:before{content:""}.fa-sort-amount-asc:before{content:""}.fa-sort-amount-desc:before{content:""}.fa-sort-numeric-asc:before{content:""}.fa-sort-numeric-desc:before{content:""}.fa-thumbs-up:before{content:""}.fa-thumbs-down:before{content:""}.fa-youtube-square:before{content:""}.fa-youtube:before{content:""}.fa-xing:before{content:""}.fa-xing-square:before{content:""}.fa-youtube-play:before{content:""}.fa-dropbox:before{content:""}.fa-stack-overflow:before{content:""}.fa-instagram:before{content:""}.fa-flickr:before{content:""}.fa-adn:before{content:""}.fa-bitbucket:before{content:""}.fa-bitbucket-square:before{content:""}.fa-tumblr:before{content:""}.fa-tumblr-square:before{content:""}.fa-long-arrow-down:before{content:""}.fa-long-arrow-up:before{content:""}.fa-long-arrow-left:before{content:""}.fa-long-arrow-right:before{content:""}.fa-apple:before{content:""}.fa-windows:before{content:""}.fa-android:before{content:""}.fa-linux:before{content:""}.fa-dribbble:before{content:""}.fa-skype:before{content:""}.fa-foursquare:before{content:""}.fa-trello:before{content:""}.fa-female:before{content:""}.fa-male:before{content:""}.fa-gittip:before,.fa-gratipay:before{content:""}.fa-sun-o:before{content:""}.fa-moon-o:before{content:""}.fa-archive:before{content:""}.fa-bug:before{content:""}.fa-vk:before{content:""}.fa-weibo:before{content:""}.fa-renren:before{content:""}.fa-pagelines:before{content:""}.fa-stack-exchange:before{content:""}.fa-arrow-circle-o-right:before{content:""}.fa-arrow-circle-o-left:before{content:""}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:""}.fa-dot-circle-o:before{content:""}.fa-wheelchair:before{content:""}.fa-vimeo-square:before{content:""}.fa-turkish-lira:before,.fa-try:before{content:""}.fa-plus-square-o:before{content:""}.fa-space-shuttle:before{content:""}.fa-slack:before{content:""}.fa-envelope-square:before{content:""}.fa-wordpress:before{content:""}.fa-openid:before{content:""}.fa-institution:before,.fa-bank:before,.fa-university:before{content:""}.fa-mortar-board:before,.fa-graduation-cap:before{content:""}.fa-yahoo:before{content:""}.fa-google:before{content:""}.fa-reddit:before{content:""}.fa-reddit-square:before{content:""}.fa-stumbleupon-circle:before{content:""}.fa-stumbleupon:before{content:""}.fa-delicious:before{content:""}.fa-digg:before{content:""}.fa-pied-piper-pp:before{content:""}.fa-pied-piper-alt:before{content:""}.fa-drupal:before{content:""}.fa-joomla:before{content:""}.fa-language:before{content:""}.fa-fax:before{content:""}.fa-building:before{content:""}.fa-child:before{content:""}.fa-paw:before{content:""}.fa-spoon:before{content:""}.fa-cube:before{content:""}.fa-cubes:before{content:""}.fa-behance:before{content:""}.fa-behance-square:before{content:""}.fa-steam:before{content:""}.fa-steam-square:before{content:""}.fa-recycle:before{content:""}.fa-automobile:before,.fa-car:before{content:""}.fa-cab:before,.fa-taxi:before{content:""}.fa-tree:before{content:""}.fa-spotify:before{content:""}.fa-deviantart:before{content:""}.fa-soundcloud:before{content:""}.fa-database:before{content:""}.fa-file-pdf-o:before{content:""}.fa-file-word-o:before{content:""}.fa-file-excel-o:before{content:""}.fa-file-powerpoint-o:before{content:""}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:""}.fa-file-zip-o:before,.fa-file-archive-o:before{content:""}.fa-file-sound-o:before,.fa-file-audio-o:before{content:""}.fa-file-movie-o:before,.fa-file-video-o:before{content:""}.fa-file-code-o:before{content:""}.fa-vine:before{content:""}.fa-codepen:before{content:""}.fa-jsfiddle:before{content:""}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:""}.fa-circle-o-notch:before{content:""}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:""}.fa-ge:before,.fa-empire:before{content:""}.fa-git-square:before{content:""}.fa-git:before{content:""}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:""}.fa-tencent-weibo:before{content:""}.fa-qq:before{content:""}.fa-wechat:before,.fa-weixin:before{content:""}.fa-send:before,.fa-paper-plane:before{content:""}.fa-send-o:before,.fa-paper-plane-o:before{content:""}.fa-history:before{content:""}.fa-circle-thin:before{content:""}.fa-header:before{content:""}.fa-paragraph:before{content:""}.fa-sliders:before{content:""}.fa-share-alt:before{content:""}.fa-share-alt-square:before{content:""}.fa-bomb:before{content:""}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:""}.fa-tty:before{content:""}.fa-binoculars:before{content:""}.fa-plug:before{content:""}.fa-slideshare:before{content:""}.fa-twitch:before{content:""}.fa-yelp:before{content:""}.fa-newspaper-o:before{content:""}.fa-wifi:before{content:""}.fa-calculator:before{content:""}.fa-paypal:before{content:""}.fa-google-wallet:before{content:""}.fa-cc-visa:before{content:""}.fa-cc-mastercard:before{content:""}.fa-cc-discover:before{content:""}.fa-cc-amex:before{content:""}.fa-cc-paypal:before{content:""}.fa-cc-stripe:before{content:""}.fa-bell-slash:before{content:""}.fa-bell-slash-o:before{content:""}.fa-trash:before{content:""}.fa-copyright:before{content:""}.fa-at:before{content:""}.fa-eyedropper:before{content:""}.fa-paint-brush:before{content:""}.fa-birthday-cake:before{content:""}.fa-area-chart:before{content:""}.fa-pie-chart:before{content:""}.fa-line-chart:before{content:""}.fa-lastfm:before{content:""}.fa-lastfm-square:before{content:""}.fa-toggle-off:before{content:""}.fa-toggle-on:before{content:""}.fa-bicycle:before{content:""}.fa-bus:before{content:""}.fa-ioxhost:before{content:""}.fa-angellist:before{content:""}.fa-cc:before{content:""}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:""}.fa-meanpath:before{content:""}.fa-buysellads:before{content:""}.fa-connectdevelop:before{content:""}.fa-dashcube:before{content:""}.fa-forumbee:before{content:""}.fa-leanpub:before{content:""}.fa-sellsy:before{content:""}.fa-shirtsinbulk:before{content:""}.fa-simplybuilt:before{content:""}.fa-skyatlas:before{content:""}.fa-cart-plus:before{content:""}.fa-cart-arrow-down:before{content:""}.fa-diamond:before{content:""}.fa-ship:before{content:""}.fa-user-secret:before{content:""}.fa-motorcycle:before{content:""}.fa-street-view:before{content:""}.fa-heartbeat:before{content:""}.fa-venus:before{content:""}.fa-mars:before{content:""}.fa-mercury:before{content:""}.fa-intersex:before,.fa-transgender:before{content:""}.fa-transgender-alt:before{content:""}.fa-venus-double:before{content:""}.fa-mars-double:before{content:""}.fa-venus-mars:before{content:""}.fa-mars-stroke:before{content:""}.fa-mars-stroke-v:before{content:""}.fa-mars-stroke-h:before{content:""}.fa-neuter:before{content:""}.fa-genderless:before{content:""}.fa-facebook-official:before{content:""}.fa-pinterest-p:before{content:""}.fa-whatsapp:before{content:""}.fa-server:before{content:""}.fa-user-plus:before{content:""}.fa-user-times:before{content:""}.fa-hotel:before,.fa-bed:before{content:""}.fa-viacoin:before{content:""}.fa-train:before{content:""}.fa-subway:before{content:""}.fa-medium:before{content:""}.fa-yc:before,.fa-y-combinator:before{content:""}.fa-optin-monster:before{content:""}.fa-opencart:before{content:""}.fa-expeditedssl:before{content:""}.fa-battery-4:before,.fa-battery:before,.fa-battery-full:before{content:""}.fa-battery-3:before,.fa-battery-three-quarters:before{content:""}.fa-battery-2:before,.fa-battery-half:before{content:""}.fa-battery-1:before,.fa-battery-quarter:before{content:""}.fa-battery-0:before,.fa-battery-empty:before{content:""}.fa-mouse-pointer:before{content:""}.fa-i-cursor:before{content:""}.fa-object-group:before{content:""}.fa-object-ungroup:before{content:""}.fa-sticky-note:before{content:""}.fa-sticky-note-o:before{content:""}.fa-cc-jcb:before{content:""}.fa-cc-diners-club:before{content:""}.fa-clone:before{content:""}.fa-balance-scale:before{content:""}.fa-hourglass-o:before{content:""}.fa-hourglass-1:before,.fa-hourglass-start:before{content:""}.fa-hourglass-2:before,.fa-hourglass-half:before{content:""}.fa-hourglass-3:before,.fa-hourglass-end:before{content:""}.fa-hourglass:before{content:""}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:""}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:""}.fa-hand-scissors-o:before{content:""}.fa-hand-lizard-o:before{content:""}.fa-hand-spock-o:before{content:""}.fa-hand-pointer-o:before{content:""}.fa-hand-peace-o:before{content:""}.fa-trademark:before{content:""}.fa-registered:before{content:""}.fa-creative-commons:before{content:""}.fa-gg:before{content:""}.fa-gg-circle:before{content:""}.fa-tripadvisor:before{content:""}.fa-odnoklassniki:before{content:""}.fa-odnoklassniki-square:before{content:""}.fa-get-pocket:before{content:""}.fa-wikipedia-w:before{content:""}.fa-safari:before{content:""}.fa-chrome:before{content:""}.fa-firefox:before{content:""}.fa-opera:before{content:""}.fa-internet-explorer:before{content:""}.fa-tv:before,.fa-television:before{content:""}.fa-contao:before{content:""}.fa-500px:before{content:""}.fa-amazon:before{content:""}.fa-calendar-plus-o:before{content:""}.fa-calendar-minus-o:before{content:""}.fa-calendar-times-o:before{content:""}.fa-calendar-check-o:before{content:""}.fa-industry:before{content:""}.fa-map-pin:before{content:""}.fa-map-signs:before{content:""}.fa-map-o:before{content:""}.fa-map:before{content:""}.fa-commenting:before{content:""}.fa-commenting-o:before{content:""}.fa-houzz:before{content:""}.fa-vimeo:before{content:""}.fa-black-tie:before{content:""}.fa-fonticons:before{content:""}.fa-reddit-alien:before{content:""}.fa-edge:before{content:""}.fa-credit-card-alt:before{content:""}.fa-codiepie:before{content:""}.fa-modx:before{content:""}.fa-fort-awesome:before{content:""}.fa-usb:before{content:""}.fa-product-hunt:before{content:""}.fa-mixcloud:before{content:""}.fa-scribd:before{content:""}.fa-pause-circle:before{content:""}.fa-pause-circle-o:before{content:""}.fa-stop-circle:before{content:""}.fa-stop-circle-o:before{content:""}.fa-shopping-bag:before{content:""}.fa-shopping-basket:before{content:""}.fa-hashtag:before{content:""}.fa-bluetooth:before{content:""}.fa-bluetooth-b:before{content:""}.fa-percent:before{content:""}.fa-gitlab:before{content:""}.fa-wpbeginner:before{content:""}.fa-wpforms:before{content:""}.fa-envira:before{content:""}.fa-universal-access:before{content:""}.fa-wheelchair-alt:before{content:""}.fa-question-circle-o:before{content:""}.fa-blind:before{content:""}.fa-audio-description:before{content:""}.fa-volume-control-phone:before{content:""}.fa-braille:before{content:""}.fa-assistive-listening-systems:before{content:""}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:""}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:""}.fa-glide:before{content:""}.fa-glide-g:before{content:""}.fa-signing:before,.fa-sign-language:before{content:""}.fa-low-vision:before{content:""}.fa-viadeo:before{content:""}.fa-viadeo-square:before{content:""}.fa-snapchat:before{content:""}.fa-snapchat-ghost:before{content:""}.fa-snapchat-square:before{content:""}.fa-pied-piper:before{content:""}.fa-first-order:before{content:""}.fa-yoast:before{content:""}.fa-themeisle:before{content:""}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:""}.fa-fa:before,.fa-font-awesome:before{content:""}.fa-handshake-o:before{content:""}.fa-envelope-open:before{content:""}.fa-envelope-open-o:before{content:""}.fa-linode:before{content:""}.fa-address-book:before{content:""}.fa-address-book-o:before{content:""}.fa-vcard:before,.fa-address-card:before{content:""}.fa-vcard-o:before,.fa-address-card-o:before{content:""}.fa-user-circle:before{content:""}.fa-user-circle-o:before{content:""}.fa-user-o:before{content:""}.fa-id-badge:before{content:""}.fa-drivers-license:before,.fa-id-card:before{content:""}.fa-drivers-license-o:before,.fa-id-card-o:before{content:""}.fa-quora:before{content:""}.fa-free-code-camp:before{content:""}.fa-telegram:before{content:""}.fa-thermometer-4:before,.fa-thermometer:before,.fa-thermometer-full:before{content:""}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:""}.fa-thermometer-2:before,.fa-thermometer-half:before{content:""}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:""}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:""}.fa-shower:before{content:""}.fa-bathtub:before,.fa-s15:before,.fa-bath:before{content:""}.fa-podcast:before{content:""}.fa-window-maximize:before{content:""}.fa-window-minimize:before{content:""}.fa-window-restore:before{content:""}.fa-times-rectangle:before,.fa-window-close:before{content:""}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:""}.fa-bandcamp:before{content:""}.fa-grav:before{content:""}.fa-etsy:before{content:""}.fa-imdb:before{content:""}.fa-ravelry:before{content:""}.fa-eercast:before{content:""}.fa-microchip:before{content:""}.fa-snowflake-o:before{content:""}.fa-superpowers:before{content:""}.fa-wpexplorer:before{content:""}.fa-meetup:before{content:""}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.CodeMirror{font-family:monospace;height:300px;color:black;direction:ltr}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:white}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:black}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid black;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0 !important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor-mark{background-color:rgba(20,255,20,0.5);-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{0%{}50%{background-color:transparent}100%{}}@-webkit-keyframes blink{0%{}50%{background-color:transparent}100%{}}@keyframes blink{0%{}50%{background-color:transparent}100%{}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:-20px;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:blue}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:bold}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3,.cm-s-default .cm-type{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-s-default .cm-error{color:#f00}.cm-invalidchar{color:#f00}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,0.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:white}.CodeMirror-scroll{overflow:scroll !important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:none;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-vscrollbar,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:none !important;border:none !important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper ::selection{background-color:transparent}.CodeMirror-gutter-wrapper ::-moz-selection{background-color:transparent}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:contextual;font-variant-ligatures:contextual}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-rtl pre{direction:rtl}.CodeMirror-code{outline:none}.CodeMirror-scroll,.CodeMirror-sizer,.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute;pointer-events:none}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background-color:#ffa;background-color:rgba(255,255,0,0.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:none}.cm-s-hopscotch.CodeMirror{background:#322931;color:#d5d3d5}.cm-s-hopscotch div.CodeMirror-selected{background:#433b42 !important}.cm-s-hopscotch .CodeMirror-gutters{background:#322931;border-right:0px}.cm-s-hopscotch .CodeMirror-linenumber{color:#797379}.cm-s-hopscotch .CodeMirror-cursor{border-left:1px solid #989498 !important}.cm-s-hopscotch span.cm-comment{color:#b33508}.cm-s-hopscotch span.cm-atom{color:#c85e7c}.cm-s-hopscotch span.cm-number{color:#c85e7c}.cm-s-hopscotch span.cm-property,.cm-s-hopscotch span.cm-attribute{color:#8fc13e}.cm-s-hopscotch span.cm-keyword{color:#dd464c}.cm-s-hopscotch span.cm-string{color:#fdcc59}.cm-s-hopscotch span.cm-variable{color:#8fc13e}.cm-s-hopscotch span.cm-variable-2{color:#1290bf}.cm-s-hopscotch span.cm-def{color:#fd8b19}.cm-s-hopscotch span.cm-error{background:#dd464c;color:#989498}.cm-s-hopscotch span.cm-bracket{color:#d5d3d5}.cm-s-hopscotch span.cm-tag{color:#dd464c}.cm-s-hopscotch span.cm-link{color:#c85e7c}.cm-s-hopscotch .CodeMirror-matchingbracket{text-decoration:underline;color:white !important}.cm-s-hopscotch .CodeMirror-activeline-background{background:#302020}@font-face{font-family:'font3336';src:url("../fonts/main-fonts.eot?v=20");src:url("../fonts/main-fonts.woff?v=20") format("woff"),url("../fonts/main-fonts.ttf?v=20") format("truetype"),url("../fonts/main-fonts.svg?v=20") format("svg"),url("../fonts/main-fonts.eot?v=20") format("embedded-opentype");font-weight:normal;font-style:normal}.gjs-one-bg{background-color:#444}.gjs-one-color{color:#444}.gjs-one-color-h:hover{color:#444}.gjs-two-bg{background-color:#ddd}.gjs-two-color{color:#ddd}.gjs-two-color-h:hover{color:#ddd}.gjs-three-bg{background-color:#804f7b}.gjs-three-color{color:#804f7b}.gjs-three-color-h:hover{color:#804f7b}.gjs-four-bg{background-color:#d278c9}.gjs-four-color{color:#d278c9}.gjs-four-color-h:hover{color:#d278c9}.gjs-bg-main,.gjs-off-prv,.gjs-sm-sector .gjs-sm-colorp-c,.gjs-clm-tags .gjs-sm-colorp-c{background-color:#444}.gjs-color-main,.gjs-off-prv,.gjs-sm-sector .gjs-sm-stack #gjs-sm-add,.gjs-clm-tags .gjs-sm-stack #gjs-sm-add{color:#ddd;fill:#ddd}.gjs-color-active{color:#f8f8f8;fill:#f8f8f8}.gjs-color-warn{color:#ffca6f;fill:#ffca6f}.gjs-color-hl{color:#71b7f1;fill:#71b7f1}.gjs-fonts::before{display:block;font:normal normal normal 14px font3336;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:5em}.gjs-f-b1::before{content:'Q'}.gjs-f-b2::before{content:'W'}.gjs-f-b3::before{content:'E'}.gjs-f-b37::before{content:'R'}.gjs-f-hero::before{content:'T'}.gjs-f-h1p::before{content:'y'}.gjs-f-3ba::before{content:'u'}.gjs-f-image::before{content:'I'}.gjs-f-text::before{content:'o'}.gjs-f-quo::before{content:'p'}.gjs-f-button::before{content:'B'}.gjs-f-divider::before{content:'D'}.gjs-invis-invis,.gjs-clm-tags #gjs-clm-new,.gjs-no-app{background-color:transparent;border:none;color:inherit}.gjs-no-app{height:10px}.gjs-test::btn{color:'#fff'}.opac50,.gjs-clm-tags #gjs-clm-close{opacity:.5;filter:alpha(opacity=50)}.gjs-checker-bg,.gjs-field-colorp-c,.checker-bg,.gjs-sm-sector .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==")}.gjs-no-user-select,.gjs-grabbing,.gjs-grabbing *,.gjs-nav-comp-name,.gjs-rte-toolbar{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.gjs-no-pointer-events,.gjs-resizer-c,.gjs-margin-v-el,.gjs-padding-v-el,.gjs-fixedmargin-v-el,.gjs-fixedpadding-v-el{pointer-events:none}.gjs-bdrag{pointer-events:none !important;position:absolute !important;z-index:10 !important;width:auto}.gjs-drag-helper{background-color:#3b97e3 !important;pointer-events:none !important;position:absolute !important;z-index:10 !important;transform:scale(0.3) !important;transform-origin:top left !important;-webkit-transform-origin:top left !important;margin:15px !important;transition:none !important;outline:none !important}.gjs-grabbing,.gjs-grabbing *{cursor:grabbing !important;cursor:-webkit-grabbing !important}.gjs-grabbing{overflow:hidden}.gjs-off-prv{position:relative;z-index:10;padding:5px;cursor:pointer}.gjs-editor-cont ::-webkit-scrollbar-track{background:rgba(0,0,0,0.1)}.gjs-editor-cont ::-webkit-scrollbar-thumb{background-color:rgba(255,255,255,0.2)}.gjs-editor-cont ::-webkit-scrollbar{width:8px}.clear{clear:both}.no-select,.gjs-com-no-select,.gjs-com-no-select img,.gjs-category-title,.gjs-sm-sector .gjs-sm-title,.gjs-clm-tags .gjs-sm-title,.gjs-block-category .gjs-title,.gjs-nv-title,.gjs-clm-tags #gjs-clm-close{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.gjs-editor{font-family:Helvetica,sans-serif;font-size:.7rem;position:relative;box-sizing:border-box;height:100%}.gjs-freezed,.gjs-nv-freezed{opacity:.5;filter:alpha(opacity=50);pointer-events:none}.gjs-traits-label{border-bottom:1px solid rgba(0,0,0,0.2);font-size:13px;font-weight:lighter;margin-bottom:5px;padding:10px;text-align:left}.gjs-trt-trait{display:flex;justify-content:start;padding:5px 10px;font-weight:lighter}.gjs-trt-trait .gjs-label{width:30%;text-align:left}.gjs-trt-trait .gjs-field{width:70%}.gjs-cv-canvas{background-color:rgba(0,0,0,0.15);box-sizing:border-box;width:85%;height:calc(100% - $canvasTop);bottom:0;overflow:hidden;z-index:1;position:absolute;left:0;top:40px}.gjs-cv-canvas .gjs-ghost{display:none;pointer-events:none;background-color:#5b5b5b;border:2px dashed #ccc;position:absolute;z-index:10;opacity:.55;filter:alpha(opacity=55)}.gjs-cv-canvas .gjs-highlighter,.gjs-cv-canvas .gjs-highlighter-sel{position:absolute;outline:1px solid #3b97e3;outline-offset:-1px;pointer-events:none}.gjs-cv-canvas .gjs-highlighter-warning{outline:3px solid #ffca6f}.gjs-cv-canvas .gjs-highlighter-sel{outline:3px solid #3b97e3}.gjs-cv-canvas #gjs-tools{width:100%;position:absolute;top:0;left:0;outline:none}.gjs-cv-canvas>div:first-child{background-color:#fff;position:relative;height:100%;overflow:auto;width:100%}.gjs-cv-canvas *{box-sizing:border-box}.gjs-frame{outline:medium none;height:100%;width:100%;border:none;margin:auto;display:block;transition:width 0.35s ease,height 0.35s ease;position:absolute;top:0;bottom:0;left:0;right:0}.gjs-toolbar{position:absolute;background-color:#3b97e3;color:white;z-index:10}.gjs-toolbar-item{padding:5px 7px;font-size:0.8rem;cursor:pointer}.gjs-resizer-c{position:absolute;z-index:9}.gjs-margin-v-el,.gjs-padding-v-el,.gjs-fixedmargin-v-el,.gjs-fixedpadding-v-el{opacity:.1;filter:alpha(opacity=10);position:absolute;background-color:yellow}.gjs-fixedmargin-v-el,.gjs-fixedpadding-v-el{opacity:.2;filter:alpha(opacity=20)}.gjs-padding-v-el,.gjs-fixedpadding-v-el{background-color:navy}.gjs-resizer-h{pointer-events:all;position:absolute;border:3px solid #3b97e3;width:10px;height:10px;background-color:#fff;margin:-5px}.gjs-resizer-h-tl{top:0;left:0;cursor:nwse-resize}.gjs-resizer-h-tr{top:0;right:0;cursor:nesw-resize}.gjs-resizer-h-tc{top:0;margin:-5px auto;left:0;right:0;cursor:ns-resize}.gjs-resizer-h-cl{left:0;margin:auto -5px;top:0;bottom:0;cursor:ew-resize}.gjs-resizer-h-cr{margin:auto -5px;top:0;bottom:0;right:0;cursor:ew-resize}.gjs-resizer-h-bl{bottom:0;left:0;cursor:nesw-resize}.gjs-resizer-h-bc{bottom:0;margin:-5px auto;left:0;right:0;cursor:ns-resize}.gjs-resizer-h-br{bottom:0;right:0;cursor:nwse-resize}.gjs-pn-panel .gjs-resizer-h{background-color:rgba(0,0,0,0.2);border:none;opacity:0;transition:opacity 0.25s}.gjs-pn-panel .gjs-resizer-h:hover{opacity:1}.gjs-pn-panel .gjs-resizer-h-tc,.gjs-pn-panel .gjs-resizer-h-bc{margin:0 auto;width:100%}.gjs-pn-panel .gjs-resizer-h-cr,.gjs-pn-panel .gjs-resizer-h-cl{margin:auto 0;height:100%}.gjs-resizing .gjs-highlighter,.gjs-resizing .gjs-badge{display:none !important}.gjs-resizing-tl *{cursor:nwse-resize !important}.gjs-resizing-tr *{cursor:nesw-resize !important}.gjs-resizing-tc *{cursor:ns-resize !important}.gjs-resizing-cl *{cursor:ew-resize !important}.gjs-resizing-cr *{cursor:ew-resize !important}.gjs-resizing-bl *{cursor:nesw-resize !important}.gjs-resizing-bc *{cursor:ns-resize !important}.gjs-resizing-br *{cursor:nwse-resize !important}.btn-cl,.gjs-mdl-btn-close,.gjs-am-close{opacity:.3;filter:alpha(opacity=30);font-size:25px;cursor:pointer}.btn-cl:hover,.gjs-mdl-btn-close:hover,.gjs-am-close:hover{opacity:.7;filter:alpha(opacity=70)}.no-dots,.ui-resizable-handle{border:none !important;margin:0 !important;outline:none !important}.gjs-com-dashed *{outline:1px dashed #888;outline-offset:-2px;box-sizing:border-box}.gjs-cv-canvas .gjs-comp-selected{outline:3px solid #3b97e3 !important}*.gjs-com-hover,div.gjs-com-hover{outline:1px solid #3b97e3}*.gjs-com-hover-delete,div.gjs-com-hover-delete{outline:2px solid #dd3636;opacity:.5;filter:alpha(opacity=50)}*.gjs-com-hover-move,div.gjs-com-hover-move{outline:3px solid #ffca6f}.gjs-com-badge,.gjs-com-badge-red,.gjs-badge{pointer-events:none;background-color:#3b97e3;color:#fff;padding:2px 5px;position:absolute;z-index:1;font-size:12px;outline:none;display:none}.gjs-com-badge-red{background-color:#dd3636}.gjs-badge-warning{background-color:#ffca6f}.gjs-placeholder,.gjs-com-placeholder,.gjs-nv-placeholder{position:absolute;z-index:10;pointer-events:none;display:none}.gjs-placeholder,.gjs-nv-placeholder{border-style:solid !important;border-color:#62c462;outline:none;box-sizing:border-box;transition:top .2s,left .2s,width .2s,height .2s}.gjs-placeholder-int,.gjs-com-placeholder-int,.gjs-nv-placeholder-int{background-color:#62c462;box-shadow:0 0 3px rgba(0,0,0,0.2);height:100%;width:100%;pointer-events:none;padding:1.5px;outline:none}.gjs-pn-panel{display:inline-block;padding:5px;position:absolute;box-sizing:border-box;text-align:center;z-index:3}.gjs-pn-panel#gjs-pn-commands,.gjs-pn-panel#gjs-pn-options2{width:85%;left:0;top:0;box-shadow:0 0 5px rgba(0,0,0,0.2)}.gjs-pn-panel#gjs-pn-options{right:15%;top:0}.gjs-pn-panel#gjs-pn-options2{bottom:150px;height:auto}.gjs-pn-panel .icon-undo,.gjs-pn-panel .icon-redo{font-size:20px;height:30px;width:25px}.gjs-pn-panel#gjs-pn-views{border-bottom:2px solid rgba(0,0,0,0.2);right:0;width:15%;z-index:4}.gjs-pn-panel#gjs-pn-views-container{height:100%;padding:42px 0 0;right:0;width:15%;overflow:auto;box-shadow:0 0 5px rgba(0,0,0,0.2)}.gjs-pn-buttons{align-items:center;display:flex;justify-content:space-between}.gjs-pn-btn,.gjs-btnt{box-sizing:border-box;height:30px;width:30px;line-height:21px;background-color:transparent;border:none;font-size:18px;margin-right:5px;border-radius:2px;cursor:pointer;padding:5px;position:relative}.gjs-pn-btn.gjs-pn-active,.gjs-btnt.gjs-pn-active{background-color:rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.25) inset}.gjs-pn-btn>.gjs-pn-arrow-rd,.gjs-btnt>.gjs-pn-arrow-rd{border-bottom:5px solid rgba(255,255,255,0.7);border-left:5px solid transparent;bottom:2px;right:2px;position:absolute}.gjs-pn-btn>.gjs-pn-buttons,.gjs-btnt>.gjs-pn-buttons{background-color:#444;border-radius:2px;position:absolute;display:none;left:50px;top:0;padding:5px}.gjs-pn-btn>.gjs-pn-buttons.gjs-pn-visible,.gjs-btnt>.gjs-pn-buttons.gjs-pn-visible{display:block}.gjs-pn-btn>.gjs-pn-buttons>.gjs-pn-arrow-l,.gjs-btnt>.gjs-pn-buttons>.gjs-pn-arrow-l{border-bottom:5px solid transparent;border-right:5px solid #444;border-top:5px solid transparent;left:-5px;top:15px;position:absolute}.btn.expand,.gjs-layers .gjs-nv-item .expand#gjs-nv-btn-eye{background-image:none}.gjs-comp-image-placeholder{display:block;background-color:#f5f5f5;color:#777;height:50px;width:50px;line-height:50px;outline:3px solid #ffca6f;outline-offset:-3px;text-align:center;font-size:16.66667px;cursor:pointer}.gjs-comp-image-placeholder.fa-picture-o::after{content:"\f03e"}.gjs-label{line-height:18px}.gjs-fields{display:flex}.gjs-select{padding:0;width:100%}.gjs-select select{padding-right:10px}.gjs-select:-moz-focusring,.gjs-select select:-moz-focusring{color:transparent;text-shadow:0 0 0 rgba(255,255,255,0.7)}.gjs-input:focus,.gjs-button:focus,.gjs-btn-prim:focus,.gjs-select:focus,.gjs-select select:focus{outline:none}.gjs-field input,.gjs-field select,.gjs-field textarea{-webkit-appearance:none;-moz-appearance:none;appearance:none;color:inherit;border:none;background-color:transparent;box-sizing:border-box;width:100%;position:relative;padding:5px;z-index:1}.gjs-field input:focus,.gjs-field select:focus,.gjs-field textarea:focus{outline:none}.gjs-field-range{flex:9 1 auto}.gjs-field-integer input{padding-right:30px}.gjs-select option,.gjs-clm-select option,.gjs-sm-select option,.gjs-fields option,.gjs-sm-unit option{background-color:#444;color:#ddd}.gjs-field{background-color:rgba(0,0,0,0.2);border:none;box-shadow:none;border-radius:2px;box-sizing:border-box;padding:0;position:relative}.gjs-field textarea{resize:vertical}.gjs-field .gjs-sel-arrow{height:100%;width:9px;position:absolute;right:0;top:0;z-index:0}.gjs-field .gjs-d-s-arrow{bottom:0;top:0;margin:auto;right:5px;border-top:4px solid rgba(255,255,255,0.7);position:absolute;height:0;width:0;border-left:3px solid transparent;border-right:4px solid transparent;cursor:pointer}.gjs-field-arrows{position:absolute;cursor:ns-resize;margin:auto;height:20px;width:9px;z-index:10;bottom:0;right:3px;top:0}.gjs-field-color,.gjs-field-radio{width:100%}.gjs-field-color input{padding-right:22px;box-sizing:border-box}.gjs-field-colorp{border-left:1px solid rgba(0,0,0,0.2);box-sizing:border-box;height:100%;padding:2px;position:absolute;right:0;top:0;width:22px;z-index:10}.gjs-field-colorp .gjs-checker-bg,.gjs-field-colorp .gjs-field-colorp-c{height:100%;width:100%;border-radius:1px}.gjs-field-colorp-c{height:100%;position:relative;width:100%}.gjs-field-color-picker{background-color:#ddd;cursor:pointer;height:100%;width:100%;box-shadow:0 0 1px rgba(0,0,0,0.2);border-radius:1px;position:absolute;top:0}.gjs-field-checkbox{padding:0;width:auto !important}.gjs-field-checkbox input{display:none}.gjs-field-checkbox input:checked+.gjs-chk-icon{border-color:rgba(255,255,255,0.5);border-width:0 2px 2px 0;border-style:solid}.gjs-radio-item{flex:1 1 auto;text-align:center;border-left:1px solid rgba(0,0,0,0.2)}.gjs-radio-item:first-child{border:none}.gjs-radio-item:hover{background:rgba(0,0,0,0.2)}.gjs-radio-item input{display:none}.gjs-radio-item input:checked+.gjs-radio-item-label{background-color:rgba(255,255,255,0.2)}.gjs-radio-items{display:flex}.gjs-radio-item-label{cursor:pointer;display:block;padding:5px}.gjs-field-units{position:absolute;margin:auto;right:10px;bottom:0;top:0}.gjs-field-unit{position:absolute;right:10px;top:3px;font-size:10px;color:rgba(255,255,255,0.7);cursor:pointer}.gjs-field-arrow-u,.gjs-field-arrow-d{position:absolute;height:0;width:0;border-left:3px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(255,255,255,0.7);bottom:4px;cursor:pointer}.gjs-field-arrow-u{border-bottom:4px solid rgba(255,255,255,0.7);border-top:none;top:4px}.gjs-field-select{padding:0}.gjs-field-range{background-color:transparent;border:none;box-shadow:none;padding:0}.gjs-field-range input{margin:0;height:100%}.gjs-field-range input:focus{outline:none}.gjs-field-range input::-webkit-slider-thumb{-webkit-appearance:none;margin-top:-4px;height:10px;width:10px;border:1px solid rgba(0,0,0,0.2);border-radius:100%;background-color:#ddd;cursor:pointer}.gjs-field-range input::-moz-range-thumb{height:10px;width:10px;border:1px solid rgba(0,0,0,0.2);border-radius:100%;background-color:#ddd;cursor:pointer}.gjs-field-range input::-ms-thumb{height:10px;width:10px;border:1px solid rgba(0,0,0,0.2);border-radius:100%;background-color:#ddd;cursor:pointer}.gjs-field-range input::-moz-range-track{background-color:rgba(0,0,0,0.2);border-radius:1px;margin-top:3px;height:3px}.gjs-field-range input::-webkit-slider-runnable-track{background-color:rgba(0,0,0,0.2);border-radius:1px;margin-top:3px;height:3px}.gjs-field-range input::-ms-track{background-color:rgba(0,0,0,0.2);border-radius:1px;margin-top:3px;height:3px}.gjs-btn-prim{color:inherit;background-color:rgba(255,255,255,0.1);border-radius:2px;padding:3px 6px;padding:5px;cursor:pointer;border:none}.gjs-btn-prim:active{background-color:rgba(255,255,255,0.1)}.gjs-chk-icon{-ms-transform:rotate(45deg);-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);transform:rotate(45deg);box-sizing:border-box;display:block;height:14px;margin:0 5px;width:6px;cursor:pointer}.gjs-add-trasp{background:none;border:none;color:#ddd;cursor:pointer;font-size:1em;border-radius:2px;opacity:.75;filter:alpha(opacity=75)}.gjs-add-trasp:hover{opacity:1;filter:alpha(opacity=100)}.gjs-add-trasp:active{background-color:rgba(0,0,0,0.2)}.gjs-devices-c{display:flex;align-items:center;padding:3px}.gjs-devices-c .gjs-device-label{flex-grow:2;text-align:left;margin-right:10px}.gjs-devices-c .gjs-select{flex-grow:20}.gjs-devices-c .gjs-add-trasp{flex-grow:1;margin-left:5px}.gjs-category-open,.gjs-sm-sector.gjs-sm-open,.gjs-sm-open.gjs-clm-tags,.gjs-block-category.gjs-open{border-bottom:1px solid rgba(0,0,0,0.25)}.gjs-category-title,.gjs-sm-sector .gjs-sm-title,.gjs-clm-tags .gjs-sm-title,.gjs-block-category .gjs-title,.gjs-nv-title{font-weight:lighter;background-color:rgba(0,0,0,0.1);font-size:13px;letter-spacing:1px;padding:9px 10px 9px 20px;border-bottom:1px solid rgba(0,0,0,0.25);text-align:left;position:relative;cursor:pointer}.gjs-sm-clear{font-size:1rem;line-height:0;cursor:pointer}.gjs-sm-header{font-size:11px;font-weight:lighter;padding:10px}.gjs-sm-properties{font-size:11px;padding:10px 5px;display:flex;flex-wrap:wrap;align-items:flex-end;box-sizing:border-box;width:100%}.gjs-sm-label{margin:5px 5px 3px 0}.gjs-sm-close-btn,.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close{display:block;font-size:23px;position:absolute;cursor:pointer;right:5px;top:0;opacity:.2;filter:alpha(opacity=20)}.gjs-sm-close-btn:hover,.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close:hover,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close:hover{opacity:.7;filter:alpha(opacity=70)}.gjs-sm-sector,.gjs-clm-tags{clear:both;font-weight:lighter;text-align:left}.gjs-sm-sector #gjs-sm-caret,.gjs-clm-tags #gjs-sm-caret{padding-right:5px;font-size:11px}.gjs-sm-sector .gjs-sm-field,.gjs-clm-tags .gjs-sm-field,.gjs-sm-sector .gjs-clm-field,.gjs-clm-tags .gjs-clm-field{width:100%;position:relative}.gjs-sm-sector .gjs-sm-field input,.gjs-clm-tags .gjs-sm-field input,.gjs-sm-sector .gjs-clm-field input,.gjs-clm-tags .gjs-clm-field input,.gjs-sm-sector .gjs-sm-field select,.gjs-clm-tags .gjs-sm-field select,.gjs-sm-sector .gjs-clm-field select,.gjs-clm-tags .gjs-clm-field select{background-color:transparent;color:rgba(255,255,255,0.7);border:none;width:100%}.gjs-sm-sector .gjs-sm-field input,.gjs-clm-tags .gjs-sm-field input,.gjs-sm-sector .gjs-clm-field input,.gjs-clm-tags .gjs-clm-field input{box-sizing:border-box}.gjs-sm-sector .gjs-sm-field select,.gjs-clm-tags .gjs-sm-field select,.gjs-sm-sector .gjs-clm-field select,.gjs-clm-tags .gjs-clm-field select{position:relative;z-index:1;-webkit-appearance:none;-moz-appearance:none;appearance:none}.gjs-sm-sector .gjs-sm-field select::-ms-expand,.gjs-clm-tags .gjs-sm-field select::-ms-expand,.gjs-sm-sector .gjs-clm-field select::-ms-expand,.gjs-clm-tags .gjs-clm-field select::-ms-expand{display:none}.gjs-sm-sector .gjs-sm-field select:-moz-focusring,.gjs-clm-tags .gjs-sm-field select:-moz-focusring,.gjs-sm-sector .gjs-clm-field select:-moz-focusring,.gjs-clm-tags .gjs-clm-field select:-moz-focusring{color:transparent;text-shadow:0 0 0 rgba(255,255,255,0.7)}.gjs-sm-sector .gjs-sm-field input:focus,.gjs-clm-tags .gjs-sm-field input:focus,.gjs-sm-sector .gjs-clm-field input:focus,.gjs-clm-tags .gjs-clm-field input:focus,.gjs-sm-sector .gjs-sm-field select:focus,.gjs-clm-tags .gjs-sm-field select:focus,.gjs-sm-sector .gjs-clm-field select:focus,.gjs-clm-tags .gjs-clm-field select:focus{outline:none}.gjs-sm-sector .gjs-sm-field .gjs-sm-unit,.gjs-clm-tags .gjs-sm-field .gjs-sm-unit,.gjs-sm-sector .gjs-clm-field .gjs-sm-unit,.gjs-clm-tags .gjs-clm-field .gjs-sm-unit{position:absolute;right:10px;top:3px;font-size:10px;color:rgba(255,255,255,0.7);cursor:pointer}.gjs-sm-sector .gjs-sm-field .gjs-clm-sel-arrow,.gjs-clm-tags .gjs-sm-field .gjs-clm-sel-arrow,.gjs-sm-sector .gjs-clm-field .gjs-clm-sel-arrow,.gjs-clm-tags .gjs-clm-field .gjs-clm-sel-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-int-arrows,.gjs-clm-tags .gjs-sm-field .gjs-sm-int-arrows,.gjs-sm-sector .gjs-clm-field .gjs-sm-int-arrows,.gjs-clm-tags .gjs-clm-field .gjs-sm-int-arrows,.gjs-sm-sector .gjs-sm-field .gjs-sm-sel-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-sel-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-sel-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-sel-arrow{height:100%;width:9px;position:absolute;right:0;top:0;cursor:ns-resize}.gjs-sm-sector .gjs-sm-field .gjs-sm-sel-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-sel-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-sel-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-sel-arrow{cursor:pointer}.gjs-sm-sector .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-s-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-u-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-u-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-u-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-u-arrow{position:absolute;height:0;width:0;border-left:3px solid transparent;border-right:4px solid transparent;cursor:pointer}.gjs-sm-sector .gjs-sm-field .gjs-sm-u-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-u-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-u-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-u-arrow{border-bottom:4px solid rgba(255,255,255,0.7);top:4px}.gjs-sm-sector .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-s-arrow{border-top:4px solid rgba(255,255,255,0.7);bottom:4px}.gjs-sm-sector .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-s-arrow{bottom:7px}.gjs-sm-sector .gjs-sm-field.gjs-sm-color,.gjs-clm-tags .gjs-sm-field.gjs-sm-color,.gjs-sm-sector .gjs-sm-color.gjs-clm-field,.gjs-clm-tags .gjs-sm-color.gjs-clm-field,.gjs-sm-sector .gjs-sm-field.gjs-sm-input,.gjs-clm-tags .gjs-sm-field.gjs-sm-input,.gjs-sm-sector .gjs-sm-input.gjs-clm-field,.gjs-clm-tags .gjs-sm-input.gjs-clm-field,.gjs-sm-sector .gjs-sm-field.gjs-sm-integer,.gjs-clm-tags .gjs-sm-field.gjs-sm-integer,.gjs-sm-sector .gjs-sm-integer.gjs-clm-field,.gjs-clm-tags .gjs-sm-integer.gjs-clm-field,.gjs-sm-sector .gjs-sm-field.gjs-sm-list,.gjs-clm-tags .gjs-sm-field.gjs-sm-list,.gjs-sm-sector .gjs-sm-list.gjs-clm-field,.gjs-clm-tags .gjs-sm-list.gjs-clm-field,.gjs-sm-sector .gjs-sm-field.gjs-sm-select,.gjs-clm-tags .gjs-sm-field.gjs-sm-select,.gjs-sm-sector .gjs-sm-select.gjs-clm-field,.gjs-clm-tags .gjs-sm-select.gjs-clm-field,.gjs-sm-sector .gjs-clm-select,.gjs-clm-tags .gjs-clm-select{background-color:rgba(0,0,0,0.2);border:1px solid rgba(0,0,0,0.1);box-shadow:1px 1px 0 rgba(255,255,255,0.1);color:rgba(255,255,255,0.7);border-radius:2px;box-sizing:border-box;padding:0 5px}.gjs-sm-sector .gjs-sm-field.gjs-sm-composite,.gjs-clm-tags .gjs-sm-field.gjs-sm-composite,.gjs-sm-sector .gjs-sm-composite.gjs-clm-field,.gjs-clm-tags .gjs-sm-composite.gjs-clm-field{border-radius:2px}.gjs-sm-sector .gjs-sm-field.gjs-sm-select,.gjs-clm-tags .gjs-sm-field.gjs-sm-select,.gjs-sm-sector .gjs-sm-select.gjs-clm-field,.gjs-clm-tags .gjs-sm-select.gjs-clm-field,.gjs-sm-sector .gjs-clm-select,.gjs-clm-tags .gjs-clm-select{padding:0}.gjs-sm-sector .gjs-sm-field.gjs-sm-select select,.gjs-clm-tags .gjs-sm-field.gjs-sm-select select,.gjs-sm-sector .gjs-sm-select.gjs-clm-field select,.gjs-clm-tags .gjs-sm-select.gjs-clm-field select,.gjs-sm-sector .gjs-clm-select select,.gjs-clm-tags .gjs-clm-select select{height:20px}.gjs-sm-sector .gjs-sm-field.gjs-sm-select option,.gjs-clm-tags .gjs-sm-field.gjs-sm-select option,.gjs-sm-sector .gjs-sm-select.gjs-clm-field option,.gjs-clm-tags .gjs-sm-select.gjs-clm-field option,.gjs-sm-sector .gjs-clm-select option,.gjs-clm-tags .gjs-clm-select option{padding:3px 0}.gjs-sm-sector .gjs-sm-field.gjs-sm-composite,.gjs-clm-tags .gjs-sm-field.gjs-sm-composite,.gjs-sm-sector .gjs-sm-composite.gjs-clm-field,.gjs-clm-tags .gjs-sm-composite.gjs-clm-field{background-color:rgba(0,0,0,0.1);border:1px solid rgba(0,0,0,0.25)}.gjs-sm-sector .gjs-sm-field.gjs-sm-list,.gjs-clm-tags .gjs-sm-field.gjs-sm-list,.gjs-sm-sector .gjs-sm-list.gjs-clm-field,.gjs-clm-tags .gjs-sm-list.gjs-clm-field{width:auto;padding:0;overflow:hidden;float:left}.gjs-sm-sector .gjs-sm-field.gjs-sm-list input,.gjs-clm-tags .gjs-sm-field.gjs-sm-list input,.gjs-sm-sector .gjs-sm-list.gjs-clm-field input,.gjs-clm-tags .gjs-sm-list.gjs-clm-field input{display:none}.gjs-sm-sector .gjs-sm-field.gjs-sm-list label,.gjs-clm-tags .gjs-sm-field.gjs-sm-list label,.gjs-sm-sector .gjs-sm-list.gjs-clm-field label,.gjs-clm-tags .gjs-sm-list.gjs-clm-field label{cursor:pointer;padding:5px;display:block}.gjs-sm-sector .gjs-sm-field.gjs-sm-list .gjs-sm-radio:checked+label,.gjs-clm-tags .gjs-sm-field.gjs-sm-list .gjs-sm-radio:checked+label,.gjs-sm-sector .gjs-sm-list.gjs-clm-field .gjs-sm-radio:checked+label,.gjs-clm-tags .gjs-sm-list.gjs-clm-field .gjs-sm-radio:checked+label{background-color:rgba(255,255,255,0.2)}.gjs-sm-sector .gjs-sm-field.gjs-sm-list .gjs-sm-icon,.gjs-clm-tags .gjs-sm-field.gjs-sm-list .gjs-sm-icon,.gjs-sm-sector .gjs-sm-list.gjs-clm-field .gjs-sm-icon,.gjs-clm-tags .gjs-sm-list.gjs-clm-field .gjs-sm-icon{background-repeat:no-repeat;background-position:center;text-shadow:none;line-height:normal}.gjs-sm-sector .gjs-sm-field.gjs-sm-integer select,.gjs-clm-tags .gjs-sm-field.gjs-sm-integer select,.gjs-sm-sector .gjs-sm-integer.gjs-clm-field select,.gjs-clm-tags .gjs-sm-integer.gjs-clm-field select{width:auto;padding:0}.gjs-sm-sector .gjs-sm-list .gjs-sm-el,.gjs-clm-tags .gjs-sm-list .gjs-sm-el{float:left;border-left:1px solid rgba(0,0,0,0.2)}.gjs-sm-sector .gjs-sm-list .gjs-sm-el:first-child,.gjs-clm-tags .gjs-sm-list .gjs-sm-el:first-child{border:none}.gjs-sm-sector .gjs-sm-list .gjs-sm-el:hover,.gjs-clm-tags .gjs-sm-list .gjs-sm-el:hover{background:rgba(0,0,0,0.2)}.gjs-sm-sector .gjs-sm-slider .gjs-field-integer,.gjs-clm-tags .gjs-sm-slider .gjs-field-integer{flex:1 1 65px}.gjs-sm-sector .gjs-sm-property,.gjs-clm-tags .gjs-sm-property{box-sizing:border-box;float:left;width:50%;margin-bottom:5px;padding:0 5px}.gjs-sm-sector .gjs-sm-property.gjs-sm-composite,.gjs-clm-tags .gjs-sm-property.gjs-sm-composite,.gjs-sm-sector .gjs-sm-property.gjs-sm-file,.gjs-clm-tags .gjs-sm-property.gjs-sm-file,.gjs-sm-sector .gjs-sm-property.gjs-sm-list,.gjs-clm-tags .gjs-sm-property.gjs-sm-list,.gjs-sm-sector .gjs-sm-property.gjs-sm-radio,.gjs-clm-tags .gjs-sm-property.gjs-sm-radio,.gjs-sm-sector .gjs-sm-property.gjs-sm-stack,.gjs-clm-tags .gjs-sm-property.gjs-sm-stack,.gjs-sm-sector .gjs-sm-property.gjs-sm-slider,.gjs-clm-tags .gjs-sm-property.gjs-sm-slider,.gjs-sm-sector .gjs-sm-property.gjs-sm-color,.gjs-clm-tags .gjs-sm-property.gjs-sm-color{width:100%}.gjs-sm-sector .gjs-sm-property .gjs-sm-btn,.gjs-clm-tags .gjs-sm-property .gjs-sm-btn{background-color:rgba(33,33,33,0.2);border-radius:2px;box-shadow:1px 1px 0 rgba(5,5,5,0.2),1px 1px 0 rgba(43,43,43,0.2) inset;padding:5px;position:relative;text-align:center;height:auto;width:100%;cursor:pointer;color:#ddd;box-sizing:border-box;text-shadow:-1px -1px 0 rgba(0,0,0,0.2);border:none;opacity:.85;filter:alpha(opacity=85)}.gjs-sm-sector .gjs-sm-property .gjs-sm-btn-c,.gjs-clm-tags .gjs-sm-property .gjs-sm-btn-c{box-sizing:border-box;float:left;width:100%}.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box{background-color:rgba(255,255,255,0.05);border-radius:2px;margin-top:5px;position:relative;overflow:hidden}.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box.gjs-sm-show,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box.gjs-sm-show{border:1px solid rgba(252,252,252,0.05);padding:3px 20px}.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close{top:-5px;display:block}.gjs-sm-sector .gjs-sm-property.gjs-sm-file .gjs-sm-show #gjs-sm-preview-file,.gjs-clm-tags .gjs-sm-property.gjs-sm-file .gjs-sm-show #gjs-sm-preview-file{height:50px}.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-file,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-file{background-size:auto 100%;background-repeat:no-repeat;background-position:center center}.gjs-sm-sector .gjs-sm-property .gjs-sm-layers,.gjs-clm-tags .gjs-sm-property .gjs-sm-layers{margin-top:5px;padding:1px 3px;min-height:30px}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer{background-color:rgba(255,255,255,0.055);border-radius:2px;margin:2px 0;padding:7px;position:relative;cursor:pointer}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box{height:15px;position:absolute;right:27px;top:6px;width:15px}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer #gjs-sm-preview,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer #gjs-sm-preview,.gjs-sm-sector .gjs-sm-property .gjs-sm-layer #gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer #gjs-sm-preview-box{border-radius:2px}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer #gjs-sm-close-layer,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer #gjs-sm-close-layer{display:block;font-size:23px;position:absolute;cursor:pointer;right:5px;top:0;opacity:.5;filter:alpha(opacity=50)}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer #gjs-sm-close-layer:hover,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer #gjs-sm-close-layer:hover{opacity:.8;filter:alpha(opacity=80)}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box #gjs-sm-preview,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box #gjs-sm-preview{background-color:white;height:100%;width:100%;background-size:cover !important}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer.gjs-sm-active,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer.gjs-sm-active{background-color:rgba(255,255,255,0.12)}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer.gjs-sm-no-preview #gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer.gjs-sm-no-preview #gjs-sm-preview-box{display:none}.gjs-sm-sector #gjs-sm-text-shadow #gjs-sm-preview::after,.gjs-clm-tags #gjs-sm-text-shadow #gjs-sm-preview::after{color:#000;content:"T";font-weight:900;line-height:17px;padding:0 4px}.gjs-sm-sector .gjs-sm-stack .gjs-sm-properties,.gjs-clm-tags .gjs-sm-stack .gjs-sm-properties{padding:5px 0 0}.gjs-sm-sector .gjs-sm-stack #gjs-sm-add,.gjs-clm-tags .gjs-sm-stack #gjs-sm-add{background:none;border:none;cursor:pointer;outline:none;font-size:22px;line-height:10px;position:absolute;right:0;top:-17px;opacity:0.75}.gjs-sm-sector .gjs-sm-stack #gjs-sm-add:hover,.gjs-clm-tags .gjs-sm-stack #gjs-sm-add:hover{opacity:1;filter:alpha(opacity=100)}.gjs-sm-sector .gjs-sm-colorp-c,.gjs-clm-tags .gjs-sm-colorp-c{height:100%;width:20px;position:absolute;right:0;top:0;box-sizing:border-box;border-radius:2px;padding:2px}.gjs-sm-sector .gjs-sm-colorp-c .gjs-checker-bg,.gjs-clm-tags .gjs-sm-colorp-c .gjs-checker-bg,.gjs-sm-sector .gjs-sm-colorp-c .gjs-field-colorp-c,.gjs-clm-tags .gjs-sm-colorp-c .gjs-field-colorp-c{height:100%;width:100%;border-radius:1px}.gjs-sm-sector .gjs-sm-color-picker,.gjs-clm-tags .gjs-sm-color-picker{background-color:#ddd;cursor:pointer;height:16px;width:100%;margin-top:-16px;box-shadow:0 0 1px rgba(0,0,0,0.2);border-radius:1px}.gjs-sm-sector .gjs-sm-btn-upload #gjs-sm-upload,.gjs-clm-tags .gjs-sm-btn-upload #gjs-sm-upload{left:0;top:0;position:absolute;width:100%;opacity:0;cursor:pointer}.gjs-sm-sector .gjs-sm-btn-upload #gjs-sm-label,.gjs-clm-tags .gjs-sm-btn-upload #gjs-sm-label{padding:2px 0}.gjs-sm-layer>#gjs-sm-move{opacity:.7;filter:alpha(opacity=70);cursor:move;font-size:12px;float:left;margin:0 5px 0 0}.gjs-sm-layer>#gjs-sm-move:hover{opacity:.9;filter:alpha(opacity=90)}.gjs-blocks-c{display:flex;flex-wrap:wrap;justify-content:flex-start}.gjs-block-category{width:100%}.gjs-block-category .gjs-caret-icon{margin-right:5px}.gjs-block{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;width:45%;padding:1em;box-sizing:border-box;height:90px;cursor:all-scroll;font-size:11px;font-weight:lighter;display:flex;flex-direction:column;justify-content:flex-end;border:1px solid rgba(0,0,0,0.2);border-radius:3px;margin:10px 2.5% 5px;box-shadow:0 1px 0 0 rgba(0,0,0,0.15);transition:all 0.2s ease 0s;transition-property:box-shadow, color}.gjs-block:hover{box-shadow:0 3px 4px 0 rgba(0,0,0,0.15)}.gjs-block-svg{width:61%}.gjs-block-svg-path{fill:currentColor}.gjs-block.fa{font-size:2em;line-height:2em;padding:11px}.gjs-block-label{line-height:normal;font-size:0.65rem;font-weight:normal;font-family:Helvetica, sans-serif}.gjs-block.gjs-bdrag{width:auto;padding:0}.gjs-nv-selected-parent{border:1px solid #ffca6f}.gjs-nv-opac50{opacity:.5;filter:alpha(opacity=50)}.gjs-layers{position:relative;height:100%}.gjs-layers #gjs-nv-placeholder{width:100%;position:absolute}.gjs-layers #gjs-nv-placeholder #gjs-nv-plh-int{height:100%;padding:1px}.gjs-layers #gjs-nv-placeholder #gjs-nv-plh-int.gjs-nv-insert{background-color:#62c462}.gjs-layers .gjs-nv-item{font-weight:lighter;text-align:left;position:relative;background-color:rgba(0,0,0,0.1)}.gjs-layers .gjs-nv-item.gjs-nv-hide{opacity:.55;filter:alpha(opacity=55)}.gjs-layers .gjs-nv-item #gjs-nv-counter{font-size:10px;position:absolute;right:27px;top:9px}.gjs-layers .gjs-nv-item #gjs-nv-btn-eye{height:auto !important;width:auto !important;font-size:13px;left:0;top:0;padding:7px 5px 7px 10px;position:absolute;cursor:pointer;z-index:1}.gjs-nv-item #gjs-nv-caret{font-size:7px;width:8px;padding:2px;cursor:pointer;position:absolute;left:-9px;top:6px;opacity:.7;filter:alpha(opacity=70)}.gjs-nv-item #gjs-nv-caret:hover{opacity:1;filter:alpha(opacity=100)}.gjs-nv-title{padding:3px 10px 5px 30px;display:flex;align-items:center}.gjs-nv-title-inn{position:relative}.gjs-nv-item .gjs-nv-children .gjs-nv-title{border-left:1px solid rgba(5,5,5,0.2)}.gjs-nv-item>.gjs-nv-children{display:none}.gjs-nv-item.open>.gjs-nv-children{display:block}.gjs-nv-item>.gjs-nv-no-chld>#gjs-nv-caret::before{content:''}.gjs-nv-no-chld>.gjs-nv-title-inn>#gjs-nv-caret{display:none}.gjs-nv-item>#gjs-nv-move{position:absolute;cursor:move;font-size:12px;right:0;top:0;padding:7px 10px 7px 5px}.gjs-nv-selected .gjs-nv-title{background-color:rgba(255,255,255,0.1)}.gjs-nv-nav-item-edit{visibility:hidden;padding:5px;font-size:9px;position:absolute;left:-27px;top:1px;opacity:.7;filter:alpha(opacity=70)}.gjs-nv-nav-item-edit:hover{opacity:1;filter:alpha(opacity=100)}.gjs-nv-title-c:hover .gjs-nv-nav-item-edit{visibility:visible;cursor:pointer}.gjs-nav-comp-name{padding:5px;box-sizing:content-box}.gjs-clm-tags{font-size:11px;padding:10px 5px}.gjs-clm-tags #gjs-clm-label,.gjs-clm-tags #gjs-clm-sel{padding:7px 0;float:left}.gjs-clm-tags #gjs-clm-sel{font-style:italic;margin-left:5px}.gjs-clm-tags #gjs-clm-status-c{float:right}.gjs-clm-tags #gjs-clm-tags-field{clear:both;padding:5px;margin-bottom:5px}.gjs-clm-tags #gjs-clm-tags-c{display:inline-block;vertical-align:top}.gjs-clm-tags #gjs-clm-add-tag{background-color:rgba(255,255,255,0.15);border-radius:2px;padding:5px 6px;box-shadow:1px 1px 0 rgba(255,255,255,0.2) inset;border:1px solid rgba(0,0,0,0.15);cursor:pointer}.gjs-clm-tags #gjs-clm-new{color:#ddd;padding:5px 6px;display:none}.gjs-clm-tags .gjs-clm-tag{display:inline-block;border-radius:3px;margin:0 3px 3px 0;padding:5px;cursor:default}.gjs-clm-tags #gjs-clm-close{font-size:20px;line-height:0;cursor:pointer;color:rgba(255,255,255,0.9)}.gjs-clm-tags #gjs-clm-close:hover{opacity:.7;filter:alpha(opacity=70)}.gjs-clm-tags #gjs-clm-checkbox{color:rgba(255,255,255,0.9);vertical-align:middle;cursor:pointer;font-size:9px}.gjs-clm-tags #gjs-clm-tag-label{padding:0 3px;cursor:text}.gjs-mdl-backlayer{opacity:.5;filter:alpha(opacity=50);background-color:#000;position:absolute;top:0;left:0;z-index:1;width:100%;height:100%}.gjs-mdl-container{font-family:Helvetica,sans-serif;position:absolute;top:0;left:0;z-index:10;width:100%;height:100%}.gjs-mdl-dialog{text-shadow:-1px -1px 0 rgba(0,0,0,0.05);animation:gjs-slide-down 0.215s;margin:30px auto 0;max-width:850px;width:90%;border-radius:3px;font-weight:lighter;position:relative;z-index:2}.gjs-mdl-title{font-size:1rem}.gjs-mdl-btn-close{position:absolute;right:15px;top:5px}.gjs-mdl-active .gjs-mdl-dialog{animation:gjs-mdl-slide-down 0.216s}.gjs-mdl-header,.gjs-mdl-content{padding:10px 15px;clear:both}.gjs-mdl-header{position:relative;border-bottom:1px solid rgba(0,0,0,0.2);padding:15px 15px 7px}.gjs-export-dl::after{content:"";clear:both;display:block;margin-bottom:10px}.gjs-dropzone{display:none;opacity:0;position:absolute;top:0;left:0;z-index:11;width:100%;height:100%;transition:opacity 0.25s;pointer-events:none}.gjs-dropzone-active .gjs-dropzone{display:block;opacity:1}.gjs-am-assets{height:290px;overflow:auto;clear:both;display:flex;flex-wrap:wrap;align-items:flex-start;align-content:flex-start}.gjs-am-assets-header{padding:5px}.gjs-am-add-asset .gjs-am-add-field{width:70%;float:left}.gjs-am-add-asset button{width:25%;float:right}.gjs-am-preview-cont{position:relative;height:70px;width:30%;background-color:#444;border-radius:2px;float:left;overflow:hidden}.gjs-am-preview{position:absolute;background-position:center center;background-size:cover;background-repeat:no-repeat;height:100%;width:100%;z-index:1}.gjs-am-preview-bg{opacity:.5;filter:alpha(opacity=50);position:absolute;height:100%;width:100%;z-index:0}.gjs-am-dimensions{opacity:.5;filter:alpha(opacity=50);font-size:10px}.gjs-am-meta{width:70%;float:left;font-size:12px;padding:5px 0 0 5px;box-sizing:border-box}.gjs-am-meta>div{margin-bottom:5px}.gjs-am-close{cursor:pointer;position:absolute;right:5px;top:0;display:none}.gjs-am-asset{border-bottom:1px solid rgba(0,0,0,0.2);padding:5px;cursor:pointer;position:relative;box-sizing:border-box;width:100%}.gjs-am-asset:hover .gjs-am-close{display:block}.gjs-am-highlight{background-color:rgba(255,255,255,0.1)}.gjs-am-assets-cont{background-color:rgba(0,0,0,0.1);border-radius:3px;box-sizing:border-box;padding:10px;width:45%;float:right;height:325px;overflow:hidden}.gjs-am-file-uploader{width:55%;float:left}.gjs-am-file-uploader>form{background-color:rgba(0,0,0,0.1);border:2px dashed;border-radius:3px;position:relative;text-align:center;margin-bottom:15px}.gjs-am-file-uploader>form.gjs-am-hover{border:2px solid #62c462;color:#75cb75}.gjs-am-file-uploader>form.gjs-am-disabled{border-color:red}.gjs-am-file-uploader>form #gjs-am-uploadFile{opacity:0;filter:alpha(opacity=0);padding:150px 10px;width:100%;box-sizing:border-box}.gjs-am-file-uploader #gjs-am-title{position:absolute;padding:150px 10px;width:100%}.gjs-cm-editor-c{float:left;box-sizing:border-box;width:50%}.gjs-cm-editor-c .CodeMirror{height:450px}.gjs-cm-editor{font-size:12px}.gjs-cm-editor#gjs-cm-htmlmixed{padding-right:10px;border-right:1px solid rgba(0,0,0,0.2)}.gjs-cm-editor#gjs-cm-htmlmixed #gjs-cm-title{color:#a97d44}.gjs-cm-editor#gjs-cm-css{padding-left:10px}.gjs-cm-editor#gjs-cm-css #gjs-cm-title{color:#ddca7e}.gjs-cm-editor #gjs-cm-title{background-color:rgba(0,0,0,0.2);font-size:12px;padding:5px 10px 3px;text-align:right}.gjs-rte-toolbar{border:1px solid rgba(0,0,0,0.2);position:absolute;border-radius:3px;z-index:10}.gjs-rte-actionbar{display:flex}.gjs-rte-action{display:flex;align-items:center;justify-content:center;padding:5px;min-width:25px;border-right:1px solid rgba(0,0,0,0.2);text-align:center;cursor:pointer;outline:none}.gjs-rte-action:last-child{border-right:none}.gjs-rte-action:hover{background-color:rgba(255,255,255,0.1)}.gjs-rte-active{background-color:rgba(0,0,0,0.2)}.gjs-editor-cont .sp-hue,.gjs-editor-cont .sp-slider{cursor:row-resize}.gjs-editor-cont .sp-color,.gjs-editor-cont .sp-dragger{cursor:crosshair}.gjs-editor-cont .sp-alpha-inner,.gjs-editor-cont .sp-alpha-handle{cursor:col-resize}.gjs-editor-cont .sp-hue{left:90%}.gjs-editor-cont .sp-color{right:15%}.gjs-editor-cont .sp-container{border:1px solid rgba(0,0,0,0.2);box-shadow:0 0 7px rgba(0,0,0,0.2);border-radius:3px}.gjs-editor-cont .sp-picker-container{border:none}.gjs-editor-cont .colpick_dark .colpick_color{outline:1px solid rgba(0,0,0,0.2)}.gjs-editor-cont .sp-cancel,.gjs-editor-cont .sp-cancel:hover{bottom:-8px;color:#777 !important;font-size:25px;left:0;position:absolute;text-decoration:none}.gjs-editor-cont .sp-alpha-handle{background-color:#ccc;border:1px solid #555;width:4px}.gjs-editor-cont .sp-color,.gjs-editor-cont .sp-hue{border:1px solid #333333}.gjs-editor-cont .sp-slider{background-color:#ccc;border:1px solid #555;height:3px;left:-4px;width:22px}.gjs-editor-cont .sp-dragger{background:transparent;box-shadow:0 0 0 1px #111}.gjs-editor-cont .sp-button-container{float:none;width:100%;position:relative;text-align:right}.gjs-editor-cont .sp-container button,.gjs-editor-cont .sp-container button:hover,.gjs-editor-cont .sp-container button:active{background:rgba(0,0,0,0.2);border-color:rgba(0,0,0,0.2);color:#ddd;text-shadow:none;box-shadow:none;padding:3px 5px}.gjs-editor-cont .sp-palette-container{border:none;float:none;margin:0;padding:5px 10px 0}.gjs-editor-cont .sp-palette .sp-thumb-el,.gjs-editor-cont .sp-palette .sp-thumb-el:hover{border:1px solid rgba(0,0,0,0.9)}.gjs-editor-cont .sp-palette .sp-thumb-el:hover,.gjs-editor-cont .sp-palette .sp-thumb-el.sp-thumb-active{border-color:rgba(0,0,0,0.9)}.gjs-hidden{display:none}@keyframes gjs-slide-down{0%{transform:translate(0, -3rem);opacity:0}100%{transform:translate(0, 0);opacity:1}}@keyframes gjs-slide-up{0%{transform:translate(0, 0);opacity:1}100%{transform:translate(0, -3rem);opacity:0}} + */@font-face{font-family:'FontAwesome';src:url("../fonts/fontawesome-webfont.eot?v=4.7.0");src:url("../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0") format("embedded-opentype"),url("../fonts/fontawesome-webfont.woff2?v=4.7.0") format("woff2"),url("../fonts/fontawesome-webfont.woff?v=4.7.0") format("woff"),url("../fonts/fontawesome-webfont.ttf?v=4.7.0") format("truetype"),url("../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular") format("svg");font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14286em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14286em;width:2.14286em;top:.14286em;text-align:center}.fa-li.fa-lg{left:-1.85714em}.fa-border{padding:.2em .25em .15em;border:solid 0.08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:""}.fa-music:before{content:""}.fa-search:before{content:""}.fa-envelope-o:before{content:""}.fa-heart:before{content:""}.fa-star:before{content:""}.fa-star-o:before{content:""}.fa-user:before{content:""}.fa-film:before{content:""}.fa-th-large:before{content:""}.fa-th:before{content:""}.fa-th-list:before{content:""}.fa-check:before{content:""}.fa-remove:before,.fa-close:before,.fa-times:before{content:""}.fa-search-plus:before{content:""}.fa-search-minus:before{content:""}.fa-power-off:before{content:""}.fa-signal:before{content:""}.fa-gear:before,.fa-cog:before{content:""}.fa-trash-o:before{content:""}.fa-home:before{content:""}.fa-file-o:before{content:""}.fa-clock-o:before{content:""}.fa-road:before{content:""}.fa-download:before{content:""}.fa-arrow-circle-o-down:before{content:""}.fa-arrow-circle-o-up:before{content:""}.fa-inbox:before{content:""}.fa-play-circle-o:before{content:""}.fa-rotate-right:before,.fa-repeat:before{content:""}.fa-refresh:before{content:""}.fa-list-alt:before{content:""}.fa-lock:before{content:""}.fa-flag:before{content:""}.fa-headphones:before{content:""}.fa-volume-off:before{content:""}.fa-volume-down:before{content:""}.fa-volume-up:before{content:""}.fa-qrcode:before{content:""}.fa-barcode:before{content:""}.fa-tag:before{content:""}.fa-tags:before{content:""}.fa-book:before{content:""}.fa-bookmark:before{content:""}.fa-print:before{content:""}.fa-camera:before{content:""}.fa-font:before{content:""}.fa-bold:before{content:""}.fa-italic:before{content:""}.fa-text-height:before{content:""}.fa-text-width:before{content:""}.fa-align-left:before{content:""}.fa-align-center:before{content:""}.fa-align-right:before{content:""}.fa-align-justify:before{content:""}.fa-list:before{content:""}.fa-dedent:before,.fa-outdent:before{content:""}.fa-indent:before{content:""}.fa-video-camera:before{content:""}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:""}.fa-pencil:before{content:""}.fa-map-marker:before{content:""}.fa-adjust:before{content:""}.fa-tint:before{content:""}.fa-edit:before,.fa-pencil-square-o:before{content:""}.fa-share-square-o:before{content:""}.fa-check-square-o:before{content:""}.fa-arrows:before{content:""}.fa-step-backward:before{content:""}.fa-fast-backward:before{content:""}.fa-backward:before{content:""}.fa-play:before{content:""}.fa-pause:before{content:""}.fa-stop:before{content:""}.fa-forward:before{content:""}.fa-fast-forward:before{content:""}.fa-step-forward:before{content:""}.fa-eject:before{content:""}.fa-chevron-left:before{content:""}.fa-chevron-right:before{content:""}.fa-plus-circle:before{content:""}.fa-minus-circle:before{content:""}.fa-times-circle:before{content:""}.fa-check-circle:before{content:""}.fa-question-circle:before{content:""}.fa-info-circle:before{content:""}.fa-crosshairs:before{content:""}.fa-times-circle-o:before{content:""}.fa-check-circle-o:before{content:""}.fa-ban:before{content:""}.fa-arrow-left:before{content:""}.fa-arrow-right:before{content:""}.fa-arrow-up:before{content:""}.fa-arrow-down:before{content:""}.fa-mail-forward:before,.fa-share:before{content:""}.fa-expand:before{content:""}.fa-compress:before{content:""}.fa-plus:before{content:""}.fa-minus:before{content:""}.fa-asterisk:before{content:""}.fa-exclamation-circle:before{content:""}.fa-gift:before{content:""}.fa-leaf:before{content:""}.fa-fire:before{content:""}.fa-eye:before{content:""}.fa-eye-slash:before{content:""}.fa-warning:before,.fa-exclamation-triangle:before{content:""}.fa-plane:before{content:""}.fa-calendar:before{content:""}.fa-random:before{content:""}.fa-comment:before{content:""}.fa-magnet:before{content:""}.fa-chevron-up:before{content:""}.fa-chevron-down:before{content:""}.fa-retweet:before{content:""}.fa-shopping-cart:before{content:""}.fa-folder:before{content:""}.fa-folder-open:before{content:""}.fa-arrows-v:before{content:""}.fa-arrows-h:before{content:""}.fa-bar-chart-o:before,.fa-bar-chart:before{content:""}.fa-twitter-square:before{content:""}.fa-facebook-square:before{content:""}.fa-camera-retro:before{content:""}.fa-key:before{content:""}.fa-gears:before,.fa-cogs:before{content:""}.fa-comments:before{content:""}.fa-thumbs-o-up:before{content:""}.fa-thumbs-o-down:before{content:""}.fa-star-half:before{content:""}.fa-heart-o:before{content:""}.fa-sign-out:before{content:""}.fa-linkedin-square:before{content:""}.fa-thumb-tack:before{content:""}.fa-external-link:before{content:""}.fa-sign-in:before{content:""}.fa-trophy:before{content:""}.fa-github-square:before{content:""}.fa-upload:before{content:""}.fa-lemon-o:before{content:""}.fa-phone:before{content:""}.fa-square-o:before{content:""}.fa-bookmark-o:before{content:""}.fa-phone-square:before{content:""}.fa-twitter:before{content:""}.fa-facebook-f:before,.fa-facebook:before{content:""}.fa-github:before{content:""}.fa-unlock:before{content:""}.fa-credit-card:before{content:""}.fa-feed:before,.fa-rss:before{content:""}.fa-hdd-o:before{content:""}.fa-bullhorn:before{content:""}.fa-bell:before{content:""}.fa-certificate:before{content:""}.fa-hand-o-right:before{content:""}.fa-hand-o-left:before{content:""}.fa-hand-o-up:before{content:""}.fa-hand-o-down:before{content:""}.fa-arrow-circle-left:before{content:""}.fa-arrow-circle-right:before{content:""}.fa-arrow-circle-up:before{content:""}.fa-arrow-circle-down:before{content:""}.fa-globe:before{content:""}.fa-wrench:before{content:""}.fa-tasks:before{content:""}.fa-filter:before{content:""}.fa-briefcase:before{content:""}.fa-arrows-alt:before{content:""}.fa-group:before,.fa-users:before{content:""}.fa-chain:before,.fa-link:before{content:""}.fa-cloud:before{content:""}.fa-flask:before{content:""}.fa-cut:before,.fa-scissors:before{content:""}.fa-copy:before,.fa-files-o:before{content:""}.fa-paperclip:before{content:""}.fa-save:before,.fa-floppy-o:before{content:""}.fa-square:before{content:""}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:""}.fa-list-ul:before{content:""}.fa-list-ol:before{content:""}.fa-strikethrough:before{content:""}.fa-underline:before{content:""}.fa-table:before{content:""}.fa-magic:before{content:""}.fa-truck:before{content:""}.fa-pinterest:before{content:""}.fa-pinterest-square:before{content:""}.fa-google-plus-square:before{content:""}.fa-google-plus:before{content:""}.fa-money:before{content:""}.fa-caret-down:before{content:""}.fa-caret-up:before{content:""}.fa-caret-left:before{content:""}.fa-caret-right:before{content:""}.fa-columns:before{content:""}.fa-unsorted:before,.fa-sort:before{content:""}.fa-sort-down:before,.fa-sort-desc:before{content:""}.fa-sort-up:before,.fa-sort-asc:before{content:""}.fa-envelope:before{content:""}.fa-linkedin:before{content:""}.fa-rotate-left:before,.fa-undo:before{content:""}.fa-legal:before,.fa-gavel:before{content:""}.fa-dashboard:before,.fa-tachometer:before{content:""}.fa-comment-o:before{content:""}.fa-comments-o:before{content:""}.fa-flash:before,.fa-bolt:before{content:""}.fa-sitemap:before{content:""}.fa-umbrella:before{content:""}.fa-paste:before,.fa-clipboard:before{content:""}.fa-lightbulb-o:before{content:""}.fa-exchange:before{content:""}.fa-cloud-download:before{content:""}.fa-cloud-upload:before{content:""}.fa-user-md:before{content:""}.fa-stethoscope:before{content:""}.fa-suitcase:before{content:""}.fa-bell-o:before{content:""}.fa-coffee:before{content:""}.fa-cutlery:before{content:""}.fa-file-text-o:before{content:""}.fa-building-o:before{content:""}.fa-hospital-o:before{content:""}.fa-ambulance:before{content:""}.fa-medkit:before{content:""}.fa-fighter-jet:before{content:""}.fa-beer:before{content:""}.fa-h-square:before{content:""}.fa-plus-square:before{content:""}.fa-angle-double-left:before{content:""}.fa-angle-double-right:before{content:""}.fa-angle-double-up:before{content:""}.fa-angle-double-down:before{content:""}.fa-angle-left:before{content:""}.fa-angle-right:before{content:""}.fa-angle-up:before{content:""}.fa-angle-down:before{content:""}.fa-desktop:before{content:""}.fa-laptop:before{content:""}.fa-tablet:before{content:""}.fa-mobile-phone:before,.fa-mobile:before{content:""}.fa-circle-o:before{content:""}.fa-quote-left:before{content:""}.fa-quote-right:before{content:""}.fa-spinner:before{content:""}.fa-circle:before{content:""}.fa-mail-reply:before,.fa-reply:before{content:""}.fa-github-alt:before{content:""}.fa-folder-o:before{content:""}.fa-folder-open-o:before{content:""}.fa-smile-o:before{content:""}.fa-frown-o:before{content:""}.fa-meh-o:before{content:""}.fa-gamepad:before{content:""}.fa-keyboard-o:before{content:""}.fa-flag-o:before{content:""}.fa-flag-checkered:before{content:""}.fa-terminal:before{content:""}.fa-code:before{content:""}.fa-mail-reply-all:before,.fa-reply-all:before{content:""}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:""}.fa-location-arrow:before{content:""}.fa-crop:before{content:""}.fa-code-fork:before{content:""}.fa-unlink:before,.fa-chain-broken:before{content:""}.fa-question:before{content:""}.fa-info:before{content:""}.fa-exclamation:before{content:""}.fa-superscript:before{content:""}.fa-subscript:before{content:""}.fa-eraser:before{content:""}.fa-puzzle-piece:before{content:""}.fa-microphone:before{content:""}.fa-microphone-slash:before{content:""}.fa-shield:before{content:""}.fa-calendar-o:before{content:""}.fa-fire-extinguisher:before{content:""}.fa-rocket:before{content:""}.fa-maxcdn:before{content:""}.fa-chevron-circle-left:before{content:""}.fa-chevron-circle-right:before{content:""}.fa-chevron-circle-up:before{content:""}.fa-chevron-circle-down:before{content:""}.fa-html5:before{content:""}.fa-css3:before{content:""}.fa-anchor:before{content:""}.fa-unlock-alt:before{content:""}.fa-bullseye:before{content:""}.fa-ellipsis-h:before{content:""}.fa-ellipsis-v:before{content:""}.fa-rss-square:before{content:""}.fa-play-circle:before{content:""}.fa-ticket:before{content:""}.fa-minus-square:before{content:""}.fa-minus-square-o:before{content:""}.fa-level-up:before{content:""}.fa-level-down:before{content:""}.fa-check-square:before{content:""}.fa-pencil-square:before{content:""}.fa-external-link-square:before{content:""}.fa-share-square:before{content:""}.fa-compass:before{content:""}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:""}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:""}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:""}.fa-euro:before,.fa-eur:before{content:""}.fa-gbp:before{content:""}.fa-dollar:before,.fa-usd:before{content:""}.fa-rupee:before,.fa-inr:before{content:""}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:""}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:""}.fa-won:before,.fa-krw:before{content:""}.fa-bitcoin:before,.fa-btc:before{content:""}.fa-file:before{content:""}.fa-file-text:before{content:""}.fa-sort-alpha-asc:before{content:""}.fa-sort-alpha-desc:before{content:""}.fa-sort-amount-asc:before{content:""}.fa-sort-amount-desc:before{content:""}.fa-sort-numeric-asc:before{content:""}.fa-sort-numeric-desc:before{content:""}.fa-thumbs-up:before{content:""}.fa-thumbs-down:before{content:""}.fa-youtube-square:before{content:""}.fa-youtube:before{content:""}.fa-xing:before{content:""}.fa-xing-square:before{content:""}.fa-youtube-play:before{content:""}.fa-dropbox:before{content:""}.fa-stack-overflow:before{content:""}.fa-instagram:before{content:""}.fa-flickr:before{content:""}.fa-adn:before{content:""}.fa-bitbucket:before{content:""}.fa-bitbucket-square:before{content:""}.fa-tumblr:before{content:""}.fa-tumblr-square:before{content:""}.fa-long-arrow-down:before{content:""}.fa-long-arrow-up:before{content:""}.fa-long-arrow-left:before{content:""}.fa-long-arrow-right:before{content:""}.fa-apple:before{content:""}.fa-windows:before{content:""}.fa-android:before{content:""}.fa-linux:before{content:""}.fa-dribbble:before{content:""}.fa-skype:before{content:""}.fa-foursquare:before{content:""}.fa-trello:before{content:""}.fa-female:before{content:""}.fa-male:before{content:""}.fa-gittip:before,.fa-gratipay:before{content:""}.fa-sun-o:before{content:""}.fa-moon-o:before{content:""}.fa-archive:before{content:""}.fa-bug:before{content:""}.fa-vk:before{content:""}.fa-weibo:before{content:""}.fa-renren:before{content:""}.fa-pagelines:before{content:""}.fa-stack-exchange:before{content:""}.fa-arrow-circle-o-right:before{content:""}.fa-arrow-circle-o-left:before{content:""}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:""}.fa-dot-circle-o:before{content:""}.fa-wheelchair:before{content:""}.fa-vimeo-square:before{content:""}.fa-turkish-lira:before,.fa-try:before{content:""}.fa-plus-square-o:before{content:""}.fa-space-shuttle:before{content:""}.fa-slack:before{content:""}.fa-envelope-square:before{content:""}.fa-wordpress:before{content:""}.fa-openid:before{content:""}.fa-institution:before,.fa-bank:before,.fa-university:before{content:""}.fa-mortar-board:before,.fa-graduation-cap:before{content:""}.fa-yahoo:before{content:""}.fa-google:before{content:""}.fa-reddit:before{content:""}.fa-reddit-square:before{content:""}.fa-stumbleupon-circle:before{content:""}.fa-stumbleupon:before{content:""}.fa-delicious:before{content:""}.fa-digg:before{content:""}.fa-pied-piper-pp:before{content:""}.fa-pied-piper-alt:before{content:""}.fa-drupal:before{content:""}.fa-joomla:before{content:""}.fa-language:before{content:""}.fa-fax:before{content:""}.fa-building:before{content:""}.fa-child:before{content:""}.fa-paw:before{content:""}.fa-spoon:before{content:""}.fa-cube:before{content:""}.fa-cubes:before{content:""}.fa-behance:before{content:""}.fa-behance-square:before{content:""}.fa-steam:before{content:""}.fa-steam-square:before{content:""}.fa-recycle:before{content:""}.fa-automobile:before,.fa-car:before{content:""}.fa-cab:before,.fa-taxi:before{content:""}.fa-tree:before{content:""}.fa-spotify:before{content:""}.fa-deviantart:before{content:""}.fa-soundcloud:before{content:""}.fa-database:before{content:""}.fa-file-pdf-o:before{content:""}.fa-file-word-o:before{content:""}.fa-file-excel-o:before{content:""}.fa-file-powerpoint-o:before{content:""}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:""}.fa-file-zip-o:before,.fa-file-archive-o:before{content:""}.fa-file-sound-o:before,.fa-file-audio-o:before{content:""}.fa-file-movie-o:before,.fa-file-video-o:before{content:""}.fa-file-code-o:before{content:""}.fa-vine:before{content:""}.fa-codepen:before{content:""}.fa-jsfiddle:before{content:""}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:""}.fa-circle-o-notch:before{content:""}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:""}.fa-ge:before,.fa-empire:before{content:""}.fa-git-square:before{content:""}.fa-git:before{content:""}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:""}.fa-tencent-weibo:before{content:""}.fa-qq:before{content:""}.fa-wechat:before,.fa-weixin:before{content:""}.fa-send:before,.fa-paper-plane:before{content:""}.fa-send-o:before,.fa-paper-plane-o:before{content:""}.fa-history:before{content:""}.fa-circle-thin:before{content:""}.fa-header:before{content:""}.fa-paragraph:before{content:""}.fa-sliders:before{content:""}.fa-share-alt:before{content:""}.fa-share-alt-square:before{content:""}.fa-bomb:before{content:""}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:""}.fa-tty:before{content:""}.fa-binoculars:before{content:""}.fa-plug:before{content:""}.fa-slideshare:before{content:""}.fa-twitch:before{content:""}.fa-yelp:before{content:""}.fa-newspaper-o:before{content:""}.fa-wifi:before{content:""}.fa-calculator:before{content:""}.fa-paypal:before{content:""}.fa-google-wallet:before{content:""}.fa-cc-visa:before{content:""}.fa-cc-mastercard:before{content:""}.fa-cc-discover:before{content:""}.fa-cc-amex:before{content:""}.fa-cc-paypal:before{content:""}.fa-cc-stripe:before{content:""}.fa-bell-slash:before{content:""}.fa-bell-slash-o:before{content:""}.fa-trash:before{content:""}.fa-copyright:before{content:""}.fa-at:before{content:""}.fa-eyedropper:before{content:""}.fa-paint-brush:before{content:""}.fa-birthday-cake:before{content:""}.fa-area-chart:before{content:""}.fa-pie-chart:before{content:""}.fa-line-chart:before{content:""}.fa-lastfm:before{content:""}.fa-lastfm-square:before{content:""}.fa-toggle-off:before{content:""}.fa-toggle-on:before{content:""}.fa-bicycle:before{content:""}.fa-bus:before{content:""}.fa-ioxhost:before{content:""}.fa-angellist:before{content:""}.fa-cc:before{content:""}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:""}.fa-meanpath:before{content:""}.fa-buysellads:before{content:""}.fa-connectdevelop:before{content:""}.fa-dashcube:before{content:""}.fa-forumbee:before{content:""}.fa-leanpub:before{content:""}.fa-sellsy:before{content:""}.fa-shirtsinbulk:before{content:""}.fa-simplybuilt:before{content:""}.fa-skyatlas:before{content:""}.fa-cart-plus:before{content:""}.fa-cart-arrow-down:before{content:""}.fa-diamond:before{content:""}.fa-ship:before{content:""}.fa-user-secret:before{content:""}.fa-motorcycle:before{content:""}.fa-street-view:before{content:""}.fa-heartbeat:before{content:""}.fa-venus:before{content:""}.fa-mars:before{content:""}.fa-mercury:before{content:""}.fa-intersex:before,.fa-transgender:before{content:""}.fa-transgender-alt:before{content:""}.fa-venus-double:before{content:""}.fa-mars-double:before{content:""}.fa-venus-mars:before{content:""}.fa-mars-stroke:before{content:""}.fa-mars-stroke-v:before{content:""}.fa-mars-stroke-h:before{content:""}.fa-neuter:before{content:""}.fa-genderless:before{content:""}.fa-facebook-official:before{content:""}.fa-pinterest-p:before{content:""}.fa-whatsapp:before{content:""}.fa-server:before{content:""}.fa-user-plus:before{content:""}.fa-user-times:before{content:""}.fa-hotel:before,.fa-bed:before{content:""}.fa-viacoin:before{content:""}.fa-train:before{content:""}.fa-subway:before{content:""}.fa-medium:before{content:""}.fa-yc:before,.fa-y-combinator:before{content:""}.fa-optin-monster:before{content:""}.fa-opencart:before{content:""}.fa-expeditedssl:before{content:""}.fa-battery-4:before,.fa-battery:before,.fa-battery-full:before{content:""}.fa-battery-3:before,.fa-battery-three-quarters:before{content:""}.fa-battery-2:before,.fa-battery-half:before{content:""}.fa-battery-1:before,.fa-battery-quarter:before{content:""}.fa-battery-0:before,.fa-battery-empty:before{content:""}.fa-mouse-pointer:before{content:""}.fa-i-cursor:before{content:""}.fa-object-group:before{content:""}.fa-object-ungroup:before{content:""}.fa-sticky-note:before{content:""}.fa-sticky-note-o:before{content:""}.fa-cc-jcb:before{content:""}.fa-cc-diners-club:before{content:""}.fa-clone:before{content:""}.fa-balance-scale:before{content:""}.fa-hourglass-o:before{content:""}.fa-hourglass-1:before,.fa-hourglass-start:before{content:""}.fa-hourglass-2:before,.fa-hourglass-half:before{content:""}.fa-hourglass-3:before,.fa-hourglass-end:before{content:""}.fa-hourglass:before{content:""}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:""}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:""}.fa-hand-scissors-o:before{content:""}.fa-hand-lizard-o:before{content:""}.fa-hand-spock-o:before{content:""}.fa-hand-pointer-o:before{content:""}.fa-hand-peace-o:before{content:""}.fa-trademark:before{content:""}.fa-registered:before{content:""}.fa-creative-commons:before{content:""}.fa-gg:before{content:""}.fa-gg-circle:before{content:""}.fa-tripadvisor:before{content:""}.fa-odnoklassniki:before{content:""}.fa-odnoklassniki-square:before{content:""}.fa-get-pocket:before{content:""}.fa-wikipedia-w:before{content:""}.fa-safari:before{content:""}.fa-chrome:before{content:""}.fa-firefox:before{content:""}.fa-opera:before{content:""}.fa-internet-explorer:before{content:""}.fa-tv:before,.fa-television:before{content:""}.fa-contao:before{content:""}.fa-500px:before{content:""}.fa-amazon:before{content:""}.fa-calendar-plus-o:before{content:""}.fa-calendar-minus-o:before{content:""}.fa-calendar-times-o:before{content:""}.fa-calendar-check-o:before{content:""}.fa-industry:before{content:""}.fa-map-pin:before{content:""}.fa-map-signs:before{content:""}.fa-map-o:before{content:""}.fa-map:before{content:""}.fa-commenting:before{content:""}.fa-commenting-o:before{content:""}.fa-houzz:before{content:""}.fa-vimeo:before{content:""}.fa-black-tie:before{content:""}.fa-fonticons:before{content:""}.fa-reddit-alien:before{content:""}.fa-edge:before{content:""}.fa-credit-card-alt:before{content:""}.fa-codiepie:before{content:""}.fa-modx:before{content:""}.fa-fort-awesome:before{content:""}.fa-usb:before{content:""}.fa-product-hunt:before{content:""}.fa-mixcloud:before{content:""}.fa-scribd:before{content:""}.fa-pause-circle:before{content:""}.fa-pause-circle-o:before{content:""}.fa-stop-circle:before{content:""}.fa-stop-circle-o:before{content:""}.fa-shopping-bag:before{content:""}.fa-shopping-basket:before{content:""}.fa-hashtag:before{content:""}.fa-bluetooth:before{content:""}.fa-bluetooth-b:before{content:""}.fa-percent:before{content:""}.fa-gitlab:before{content:""}.fa-wpbeginner:before{content:""}.fa-wpforms:before{content:""}.fa-envira:before{content:""}.fa-universal-access:before{content:""}.fa-wheelchair-alt:before{content:""}.fa-question-circle-o:before{content:""}.fa-blind:before{content:""}.fa-audio-description:before{content:""}.fa-volume-control-phone:before{content:""}.fa-braille:before{content:""}.fa-assistive-listening-systems:before{content:""}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:""}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:""}.fa-glide:before{content:""}.fa-glide-g:before{content:""}.fa-signing:before,.fa-sign-language:before{content:""}.fa-low-vision:before{content:""}.fa-viadeo:before{content:""}.fa-viadeo-square:before{content:""}.fa-snapchat:before{content:""}.fa-snapchat-ghost:before{content:""}.fa-snapchat-square:before{content:""}.fa-pied-piper:before{content:""}.fa-first-order:before{content:""}.fa-yoast:before{content:""}.fa-themeisle:before{content:""}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:""}.fa-fa:before,.fa-font-awesome:before{content:""}.fa-handshake-o:before{content:""}.fa-envelope-open:before{content:""}.fa-envelope-open-o:before{content:""}.fa-linode:before{content:""}.fa-address-book:before{content:""}.fa-address-book-o:before{content:""}.fa-vcard:before,.fa-address-card:before{content:""}.fa-vcard-o:before,.fa-address-card-o:before{content:""}.fa-user-circle:before{content:""}.fa-user-circle-o:before{content:""}.fa-user-o:before{content:""}.fa-id-badge:before{content:""}.fa-drivers-license:before,.fa-id-card:before{content:""}.fa-drivers-license-o:before,.fa-id-card-o:before{content:""}.fa-quora:before{content:""}.fa-free-code-camp:before{content:""}.fa-telegram:before{content:""}.fa-thermometer-4:before,.fa-thermometer:before,.fa-thermometer-full:before{content:""}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:""}.fa-thermometer-2:before,.fa-thermometer-half:before{content:""}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:""}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:""}.fa-shower:before{content:""}.fa-bathtub:before,.fa-s15:before,.fa-bath:before{content:""}.fa-podcast:before{content:""}.fa-window-maximize:before{content:""}.fa-window-minimize:before{content:""}.fa-window-restore:before{content:""}.fa-times-rectangle:before,.fa-window-close:before{content:""}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:""}.fa-bandcamp:before{content:""}.fa-grav:before{content:""}.fa-etsy:before{content:""}.fa-imdb:before{content:""}.fa-ravelry:before{content:""}.fa-eercast:before{content:""}.fa-microchip:before{content:""}.fa-snowflake-o:before{content:""}.fa-superpowers:before{content:""}.fa-wpexplorer:before{content:""}.fa-meetup:before{content:""}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.CodeMirror{font-family:monospace;height:300px;color:black;direction:ltr}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:white}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:black}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid black;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0 !important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor-mark{background-color:rgba(20,255,20,0.5);-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{0%{}50%{background-color:transparent}100%{}}@-webkit-keyframes blink{0%{}50%{background-color:transparent}100%{}}@keyframes blink{0%{}50%{background-color:transparent}100%{}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:-20px;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:blue}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:bold}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3,.cm-s-default .cm-type{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-s-default .cm-error{color:#f00}.cm-invalidchar{color:#f00}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,0.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:white}.CodeMirror-scroll{overflow:scroll !important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:none;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-vscrollbar,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:none !important;border:none !important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper ::selection{background-color:transparent}.CodeMirror-gutter-wrapper ::-moz-selection{background-color:transparent}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:contextual;font-variant-ligatures:contextual}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-rtl pre{direction:rtl}.CodeMirror-code{outline:none}.CodeMirror-scroll,.CodeMirror-sizer,.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute;pointer-events:none}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background-color:#ffa;background-color:rgba(255,255,0,0.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:none}.cm-s-hopscotch.CodeMirror{background:#322931;color:#d5d3d5}.cm-s-hopscotch div.CodeMirror-selected{background:#433b42 !important}.cm-s-hopscotch .CodeMirror-gutters{background:#322931;border-right:0px}.cm-s-hopscotch .CodeMirror-linenumber{color:#797379}.cm-s-hopscotch .CodeMirror-cursor{border-left:1px solid #989498 !important}.cm-s-hopscotch span.cm-comment{color:#b33508}.cm-s-hopscotch span.cm-atom{color:#c85e7c}.cm-s-hopscotch span.cm-number{color:#c85e7c}.cm-s-hopscotch span.cm-property,.cm-s-hopscotch span.cm-attribute{color:#8fc13e}.cm-s-hopscotch span.cm-keyword{color:#dd464c}.cm-s-hopscotch span.cm-string{color:#fdcc59}.cm-s-hopscotch span.cm-variable{color:#8fc13e}.cm-s-hopscotch span.cm-variable-2{color:#1290bf}.cm-s-hopscotch span.cm-def{color:#fd8b19}.cm-s-hopscotch span.cm-error{background:#dd464c;color:#989498}.cm-s-hopscotch span.cm-bracket{color:#d5d3d5}.cm-s-hopscotch span.cm-tag{color:#dd464c}.cm-s-hopscotch span.cm-link{color:#c85e7c}.cm-s-hopscotch .CodeMirror-matchingbracket{text-decoration:underline;color:white !important}.cm-s-hopscotch .CodeMirror-activeline-background{background:#302020}@font-face{font-family:'font3336';src:url("../fonts/main-fonts.eot?v=20");src:url("../fonts/main-fonts.woff?v=20") format("woff"),url("../fonts/main-fonts.ttf?v=20") format("truetype"),url("../fonts/main-fonts.svg?v=20") format("svg"),url("../fonts/main-fonts.eot?v=20") format("embedded-opentype");font-weight:normal;font-style:normal}.gjs-one-bg{background-color:#444}.gjs-one-color{color:#444}.gjs-one-color-h:hover{color:#444}.gjs-two-bg{background-color:#ddd}.gjs-two-color{color:#ddd}.gjs-two-color-h:hover{color:#ddd}.gjs-three-bg{background-color:#804f7b}.gjs-three-color{color:#804f7b}.gjs-three-color-h:hover{color:#804f7b}.gjs-four-bg{background-color:#d278c9}.gjs-four-color{color:#d278c9}.gjs-four-color-h:hover{color:#d278c9}.gjs-bg-main,.gjs-off-prv,.gjs-sm-sector .gjs-sm-colorp-c,.gjs-clm-tags .gjs-sm-colorp-c{background-color:#444}.gjs-color-main,.gjs-off-prv,.gjs-sm-sector .gjs-sm-stack #gjs-sm-add,.gjs-clm-tags .gjs-sm-stack #gjs-sm-add{color:#ddd;fill:#ddd}.gjs-color-active{color:#f8f8f8;fill:#f8f8f8}.gjs-color-warn{color:#ffca6f;fill:#ffca6f}.gjs-color-hl{color:#71b7f1;fill:#71b7f1}.gjs-fonts::before{display:block;font:normal normal normal 14px font3336;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:5em}.gjs-f-b1::before{content:'Q'}.gjs-f-b2::before{content:'W'}.gjs-f-b3::before{content:'E'}.gjs-f-b37::before{content:'R'}.gjs-f-hero::before{content:'T'}.gjs-f-h1p::before{content:'y'}.gjs-f-3ba::before{content:'u'}.gjs-f-image::before{content:'I'}.gjs-f-text::before{content:'o'}.gjs-f-quo::before{content:'p'}.gjs-f-button::before{content:'B'}.gjs-f-divider::before{content:'D'}.gjs-invis-invis,.gjs-clm-tags #gjs-clm-new,.gjs-no-app{background-color:transparent;border:none;color:inherit}.gjs-no-app{height:10px}.gjs-test::btn{color:'#fff'}.opac50,.gjs-clm-tags #gjs-clm-close{opacity:.5;filter:alpha(opacity=50)}.gjs-checker-bg,.gjs-field-colorp-c,.checker-bg,.gjs-sm-sector .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==")}.gjs-no-user-select,.gjs-grabbing,.gjs-grabbing *,.gjs-nav-comp-name,.gjs-rte-toolbar{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.gjs-no-pointer-events,.gjs-resizer-c,.gjs-margin-v-el,.gjs-padding-v-el,.gjs-fixedmargin-v-el,.gjs-fixedpadding-v-el{pointer-events:none}.gjs-bdrag{pointer-events:none !important;position:absolute !important;z-index:10 !important;width:auto}.gjs-drag-helper{background-color:#3b97e3 !important;pointer-events:none !important;position:absolute !important;z-index:10 !important;transform:scale(0.3) !important;transform-origin:top left !important;-webkit-transform-origin:top left !important;margin:15px !important;transition:none !important;outline:none !important}.gjs-grabbing,.gjs-grabbing *{cursor:grabbing !important;cursor:-webkit-grabbing !important}.gjs-grabbing{overflow:hidden}.gjs-off-prv{position:relative;z-index:10;padding:5px;cursor:pointer}.gjs-editor-cont ::-webkit-scrollbar-track{background:rgba(0,0,0,0.1)}.gjs-editor-cont ::-webkit-scrollbar-thumb{background-color:rgba(255,255,255,0.2)}.gjs-editor-cont ::-webkit-scrollbar{width:8px}.clear{clear:both}.no-select,.gjs-com-no-select,.gjs-com-no-select img,.gjs-category-title,.gjs-sm-sector .gjs-sm-title,.gjs-clm-tags .gjs-sm-title,.gjs-block-category .gjs-title,.gjs-nv-title,.gjs-clm-tags #gjs-clm-close{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.gjs-editor{font-family:Helvetica,sans-serif;font-size:.7rem;position:relative;box-sizing:border-box;height:100%}.gjs-freezed,.gjs-nv-freezed{opacity:.5;filter:alpha(opacity=50);pointer-events:none}.gjs-traits-label{border-bottom:1px solid rgba(0,0,0,0.2);font-size:13px;font-weight:lighter;margin-bottom:5px;padding:10px;text-align:left}.gjs-trt-trait{display:flex;justify-content:start;padding:5px 10px;font-weight:lighter}.gjs-trt-trait .gjs-label{width:30%;text-align:left}.gjs-trt-trait .gjs-field{width:70%}.gjs-cv-canvas{background-color:rgba(0,0,0,0.15);box-sizing:border-box;width:85%;height:calc(100% - $canvasTop);bottom:0;overflow:hidden;z-index:1;position:absolute;left:0;top:40px}.gjs-cv-canvas .gjs-ghost{display:none;pointer-events:none;background-color:#5b5b5b;border:2px dashed #ccc;position:absolute;z-index:10;opacity:.55;filter:alpha(opacity=55)}.gjs-cv-canvas .gjs-highlighter,.gjs-cv-canvas .gjs-highlighter-sel{position:absolute;outline:1px solid #3b97e3;outline-offset:-1px;pointer-events:none}.gjs-cv-canvas .gjs-highlighter-warning{outline:3px solid #ffca6f}.gjs-cv-canvas .gjs-highlighter-sel{outline:3px solid #3b97e3}.gjs-cv-canvas #gjs-tools{width:100%;position:absolute;top:0;left:0;outline:none}.gjs-cv-canvas>div:first-child{background-color:#fff;position:relative;height:100%;overflow:auto;width:100%}.gjs-cv-canvas *{box-sizing:border-box}.gjs-frame{outline:medium none;height:100%;width:100%;border:none;margin:auto;display:block;transition:width 0.35s ease,height 0.35s ease;position:absolute;top:0;bottom:0;left:0;right:0}.gjs-toolbar{position:absolute;background-color:#3b97e3;color:white;z-index:10}.gjs-toolbar-item{padding:5px 7px;font-size:0.8rem;cursor:pointer}.gjs-resizer-c{position:absolute;z-index:9}.gjs-margin-v-el,.gjs-padding-v-el,.gjs-fixedmargin-v-el,.gjs-fixedpadding-v-el{opacity:.1;filter:alpha(opacity=10);position:absolute;background-color:yellow}.gjs-fixedmargin-v-el,.gjs-fixedpadding-v-el{opacity:.2;filter:alpha(opacity=20)}.gjs-padding-v-el,.gjs-fixedpadding-v-el{background-color:navy}.gjs-resizer-h{pointer-events:all;position:absolute;border:3px solid #3b97e3;width:10px;height:10px;background-color:#fff;margin:-5px}.gjs-resizer-h-tl{top:0;left:0;cursor:nwse-resize}.gjs-resizer-h-tr{top:0;right:0;cursor:nesw-resize}.gjs-resizer-h-tc{top:0;margin:-5px auto;left:0;right:0;cursor:ns-resize}.gjs-resizer-h-cl{left:0;margin:auto -5px;top:0;bottom:0;cursor:ew-resize}.gjs-resizer-h-cr{margin:auto -5px;top:0;bottom:0;right:0;cursor:ew-resize}.gjs-resizer-h-bl{bottom:0;left:0;cursor:nesw-resize}.gjs-resizer-h-bc{bottom:0;margin:-5px auto;left:0;right:0;cursor:ns-resize}.gjs-resizer-h-br{bottom:0;right:0;cursor:nwse-resize}.gjs-pn-panel .gjs-resizer-h{background-color:rgba(0,0,0,0.2);border:none;opacity:0;transition:opacity 0.25s}.gjs-pn-panel .gjs-resizer-h:hover{opacity:1}.gjs-pn-panel .gjs-resizer-h-tc,.gjs-pn-panel .gjs-resizer-h-bc{margin:0 auto;width:100%}.gjs-pn-panel .gjs-resizer-h-cr,.gjs-pn-panel .gjs-resizer-h-cl{margin:auto 0;height:100%}.gjs-resizing .gjs-highlighter,.gjs-resizing .gjs-badge{display:none !important}.gjs-resizing-tl *{cursor:nwse-resize !important}.gjs-resizing-tr *{cursor:nesw-resize !important}.gjs-resizing-tc *{cursor:ns-resize !important}.gjs-resizing-cl *{cursor:ew-resize !important}.gjs-resizing-cr *{cursor:ew-resize !important}.gjs-resizing-bl *{cursor:nesw-resize !important}.gjs-resizing-bc *{cursor:ns-resize !important}.gjs-resizing-br *{cursor:nwse-resize !important}.btn-cl,.gjs-mdl-btn-close,.gjs-am-close{opacity:.3;filter:alpha(opacity=30);font-size:25px;cursor:pointer}.btn-cl:hover,.gjs-mdl-btn-close:hover,.gjs-am-close:hover{opacity:.7;filter:alpha(opacity=70)}.no-dots,.ui-resizable-handle{border:none !important;margin:0 !important;outline:none !important}.gjs-com-dashed *{outline:1px dashed #888;outline-offset:-2px;box-sizing:border-box}.gjs-cv-canvas .gjs-comp-selected{outline:3px solid #3b97e3 !important}*.gjs-com-hover,div.gjs-com-hover{outline:1px solid #3b97e3}*.gjs-com-hover-delete,div.gjs-com-hover-delete{outline:2px solid #dd3636;opacity:.5;filter:alpha(opacity=50)}*.gjs-com-hover-move,div.gjs-com-hover-move{outline:3px solid #ffca6f}.gjs-com-badge,.gjs-com-badge-red,.gjs-badge{pointer-events:none;background-color:#3b97e3;color:#fff;padding:2px 5px;position:absolute;z-index:1;font-size:12px;outline:none;display:none}.gjs-com-badge-red{background-color:#dd3636}.gjs-badge-warning{background-color:#ffca6f}.gjs-placeholder,.gjs-com-placeholder,.gjs-nv-placeholder{position:absolute;z-index:10;pointer-events:none;display:none}.gjs-placeholder,.gjs-nv-placeholder{border-style:solid !important;border-color:#62c462;outline:none;box-sizing:border-box;transition:top .2s,left .2s,width .2s,height .2s}.gjs-placeholder-int,.gjs-com-placeholder-int,.gjs-nv-placeholder-int{background-color:#62c462;box-shadow:0 0 3px rgba(0,0,0,0.2);height:100%;width:100%;pointer-events:none;padding:1.5px;outline:none}.gjs-pn-panel{display:inline-block;padding:5px;position:absolute;box-sizing:border-box;text-align:center;z-index:3}.gjs-pn-panel#gjs-pn-commands,.gjs-pn-panel#gjs-pn-options2{width:85%;left:0;top:0;box-shadow:0 0 5px rgba(0,0,0,0.2)}.gjs-pn-panel#gjs-pn-options{right:15%;top:0}.gjs-pn-panel#gjs-pn-options2{bottom:150px;height:auto}.gjs-pn-panel .icon-undo,.gjs-pn-panel .icon-redo{font-size:20px;height:30px;width:25px}.gjs-pn-panel#gjs-pn-views{border-bottom:2px solid rgba(0,0,0,0.2);right:0;width:15%;z-index:4}.gjs-pn-panel#gjs-pn-views-container{height:100%;padding:42px 0 0;right:0;width:15%;overflow:auto;box-shadow:0 0 5px rgba(0,0,0,0.2)}.gjs-pn-buttons{align-items:center;display:flex;justify-content:space-between}.gjs-pn-btn,.gjs-btnt{box-sizing:border-box;height:30px;width:30px;line-height:21px;background-color:transparent;border:none;font-size:18px;margin-right:5px;border-radius:2px;cursor:pointer;padding:5px;position:relative}.gjs-pn-btn.gjs-pn-active,.gjs-btnt.gjs-pn-active{background-color:rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.25) inset}.gjs-pn-btn>.gjs-pn-arrow-rd,.gjs-btnt>.gjs-pn-arrow-rd{border-bottom:5px solid rgba(255,255,255,0.7);border-left:5px solid transparent;bottom:2px;right:2px;position:absolute}.gjs-pn-btn>.gjs-pn-buttons,.gjs-btnt>.gjs-pn-buttons{background-color:#444;border-radius:2px;position:absolute;display:none;left:50px;top:0;padding:5px}.gjs-pn-btn>.gjs-pn-buttons.gjs-pn-visible,.gjs-btnt>.gjs-pn-buttons.gjs-pn-visible{display:block}.gjs-pn-btn>.gjs-pn-buttons>.gjs-pn-arrow-l,.gjs-btnt>.gjs-pn-buttons>.gjs-pn-arrow-l{border-bottom:5px solid transparent;border-right:5px solid #444;border-top:5px solid transparent;left:-5px;top:15px;position:absolute}.btn.expand,.gjs-layers .gjs-nv-item .expand#gjs-nv-btn-eye{background-image:none}.gjs-comp-image-placeholder{display:block;background-color:#f5f5f5;color:#777;height:50px;width:50px;line-height:50px;outline:3px solid #ffca6f;outline-offset:-3px;text-align:center;font-size:16.66667px;cursor:pointer}.gjs-comp-image-placeholder.fa-picture-o::after{content:"\f03e"}.gjs-label{line-height:18px}.gjs-fields{display:flex}.gjs-select{padding:0;width:100%}.gjs-select select{padding-right:10px}.gjs-select:-moz-focusring,.gjs-select select:-moz-focusring{color:transparent;text-shadow:0 0 0 rgba(255,255,255,0.7)}.gjs-input:focus,.gjs-button:focus,.gjs-btn-prim:focus,.gjs-select:focus,.gjs-select select:focus{outline:none}.gjs-field input,.gjs-field select,.gjs-field textarea{-webkit-appearance:none;-moz-appearance:none;appearance:none;color:inherit;border:none;background-color:transparent;box-sizing:border-box;width:100%;position:relative;padding:5px;z-index:1}.gjs-field input:focus,.gjs-field select:focus,.gjs-field textarea:focus{outline:none}.gjs-field-range{flex:9 1 auto}.gjs-field-integer input{padding-right:30px}.gjs-select option,.gjs-clm-select option,.gjs-sm-select option,.gjs-fields option,.gjs-sm-unit option{background-color:#444;color:#ddd}.gjs-field{background-color:rgba(0,0,0,0.2);border:none;box-shadow:none;border-radius:2px;box-sizing:border-box;padding:0;position:relative}.gjs-field textarea{resize:vertical}.gjs-field .gjs-sel-arrow{height:100%;width:9px;position:absolute;right:0;top:0;z-index:0}.gjs-field .gjs-d-s-arrow{bottom:0;top:0;margin:auto;right:5px;border-top:4px solid rgba(255,255,255,0.7);position:absolute;height:0;width:0;border-left:3px solid transparent;border-right:4px solid transparent;cursor:pointer}.gjs-field-arrows{position:absolute;cursor:ns-resize;margin:auto;height:20px;width:9px;z-index:10;bottom:0;right:3px;top:0}.gjs-field-color,.gjs-field-radio{width:100%}.gjs-field-color input{padding-right:22px;box-sizing:border-box}.gjs-field-colorp{border-left:1px solid rgba(0,0,0,0.2);box-sizing:border-box;height:100%;padding:2px;position:absolute;right:0;top:0;width:22px;z-index:10}.gjs-field-colorp .gjs-checker-bg,.gjs-field-colorp .gjs-field-colorp-c{height:100%;width:100%;border-radius:1px}.gjs-field-colorp-c{height:100%;position:relative;width:100%}.gjs-field-color-picker{background-color:#ddd;cursor:pointer;height:100%;width:100%;box-shadow:0 0 1px rgba(0,0,0,0.2);border-radius:1px;position:absolute;top:0}.gjs-field-checkbox{padding:0;width:auto !important}.gjs-field-checkbox input{display:none}.gjs-field-checkbox input:checked+.gjs-chk-icon{border-color:rgba(255,255,255,0.5);border-width:0 2px 2px 0;border-style:solid}.gjs-radio-item{flex:1 1 auto;text-align:center;border-left:1px solid rgba(0,0,0,0.2)}.gjs-radio-item:first-child{border:none}.gjs-radio-item:hover{background:rgba(0,0,0,0.2)}.gjs-radio-item input{display:none}.gjs-radio-item input:checked+.gjs-radio-item-label{background-color:rgba(255,255,255,0.2)}.gjs-radio-items{display:flex}.gjs-radio-item-label{cursor:pointer;display:block;padding:5px}.gjs-field-units{position:absolute;margin:auto;right:10px;bottom:0;top:0}.gjs-field-unit{position:absolute;right:10px;top:3px;font-size:10px;color:rgba(255,255,255,0.7);cursor:pointer}.gjs-field-arrow-u,.gjs-field-arrow-d{position:absolute;height:0;width:0;border-left:3px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(255,255,255,0.7);bottom:4px;cursor:pointer}.gjs-field-arrow-u{border-bottom:4px solid rgba(255,255,255,0.7);border-top:none;top:4px}.gjs-field-select{padding:0}.gjs-field-range{background-color:transparent;border:none;box-shadow:none;padding:0}.gjs-field-range input{margin:0;height:100%}.gjs-field-range input:focus{outline:none}.gjs-field-range input::-webkit-slider-thumb{-webkit-appearance:none;margin-top:-4px;height:10px;width:10px;border:1px solid rgba(0,0,0,0.2);border-radius:100%;background-color:#ddd;cursor:pointer}.gjs-field-range input::-moz-range-thumb{height:10px;width:10px;border:1px solid rgba(0,0,0,0.2);border-radius:100%;background-color:#ddd;cursor:pointer}.gjs-field-range input::-ms-thumb{height:10px;width:10px;border:1px solid rgba(0,0,0,0.2);border-radius:100%;background-color:#ddd;cursor:pointer}.gjs-field-range input::-moz-range-track{background-color:rgba(0,0,0,0.2);border-radius:1px;margin-top:3px;height:3px}.gjs-field-range input::-webkit-slider-runnable-track{background-color:rgba(0,0,0,0.2);border-radius:1px;margin-top:3px;height:3px}.gjs-field-range input::-ms-track{background-color:rgba(0,0,0,0.2);border-radius:1px;margin-top:3px;height:3px}.gjs-btn-prim{color:inherit;background-color:rgba(255,255,255,0.1);border-radius:2px;padding:3px 6px;padding:5px;cursor:pointer;border:none}.gjs-btn-prim:active{background-color:rgba(255,255,255,0.1)}.gjs-chk-icon{-ms-transform:rotate(45deg);-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);transform:rotate(45deg);box-sizing:border-box;display:block;height:14px;margin:0 5px;width:6px;cursor:pointer}.gjs-add-trasp{background:none;border:none;color:#ddd;cursor:pointer;font-size:1em;border-radius:2px;opacity:.75;filter:alpha(opacity=75)}.gjs-add-trasp:hover{opacity:1;filter:alpha(opacity=100)}.gjs-add-trasp:active{background-color:rgba(0,0,0,0.2)}.gjs-devices-c{display:flex;align-items:center;padding:3px}.gjs-devices-c .gjs-device-label{flex-grow:2;text-align:left;margin-right:10px}.gjs-devices-c .gjs-select{flex-grow:20}.gjs-devices-c .gjs-add-trasp{flex-grow:1;margin-left:5px}.gjs-category-open,.gjs-sm-sector.gjs-sm-open,.gjs-sm-open.gjs-clm-tags,.gjs-block-category.gjs-open{border-bottom:1px solid rgba(0,0,0,0.25)}.gjs-category-title,.gjs-sm-sector .gjs-sm-title,.gjs-clm-tags .gjs-sm-title,.gjs-block-category .gjs-title,.gjs-nv-title{font-weight:lighter;background-color:rgba(0,0,0,0.1);font-size:13px;letter-spacing:1px;padding:9px 10px 9px 20px;border-bottom:1px solid rgba(0,0,0,0.25);text-align:left;position:relative;cursor:pointer}.gjs-sm-clear{font-size:1rem;line-height:0;cursor:pointer}.gjs-sm-header{font-size:11px;font-weight:lighter;padding:10px}.gjs-sm-properties{font-size:11px;padding:10px 5px;display:flex;flex-wrap:wrap;align-items:flex-end;box-sizing:border-box;width:100%}.gjs-sm-label{margin:5px 5px 3px 0}.gjs-sm-close-btn,.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close{display:block;font-size:23px;position:absolute;cursor:pointer;right:5px;top:0;opacity:.2;filter:alpha(opacity=20)}.gjs-sm-close-btn:hover,.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close:hover,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close:hover{opacity:.7;filter:alpha(opacity=70)}.gjs-sm-sector,.gjs-clm-tags{clear:both;font-weight:lighter;text-align:left}.gjs-sm-sector #gjs-sm-caret,.gjs-clm-tags #gjs-sm-caret{padding-right:5px;font-size:11px}.gjs-sm-sector .gjs-sm-field,.gjs-clm-tags .gjs-sm-field,.gjs-sm-sector .gjs-clm-field,.gjs-clm-tags .gjs-clm-field{width:100%;position:relative}.gjs-sm-sector .gjs-sm-field input,.gjs-clm-tags .gjs-sm-field input,.gjs-sm-sector .gjs-clm-field input,.gjs-clm-tags .gjs-clm-field input,.gjs-sm-sector .gjs-sm-field select,.gjs-clm-tags .gjs-sm-field select,.gjs-sm-sector .gjs-clm-field select,.gjs-clm-tags .gjs-clm-field select{background-color:transparent;color:rgba(255,255,255,0.7);border:none;width:100%}.gjs-sm-sector .gjs-sm-field input,.gjs-clm-tags .gjs-sm-field input,.gjs-sm-sector .gjs-clm-field input,.gjs-clm-tags .gjs-clm-field input{box-sizing:border-box}.gjs-sm-sector .gjs-sm-field select,.gjs-clm-tags .gjs-sm-field select,.gjs-sm-sector .gjs-clm-field select,.gjs-clm-tags .gjs-clm-field select{position:relative;z-index:1;-webkit-appearance:none;-moz-appearance:none;appearance:none}.gjs-sm-sector .gjs-sm-field select::-ms-expand,.gjs-clm-tags .gjs-sm-field select::-ms-expand,.gjs-sm-sector .gjs-clm-field select::-ms-expand,.gjs-clm-tags .gjs-clm-field select::-ms-expand{display:none}.gjs-sm-sector .gjs-sm-field select:-moz-focusring,.gjs-clm-tags .gjs-sm-field select:-moz-focusring,.gjs-sm-sector .gjs-clm-field select:-moz-focusring,.gjs-clm-tags .gjs-clm-field select:-moz-focusring{color:transparent;text-shadow:0 0 0 rgba(255,255,255,0.7)}.gjs-sm-sector .gjs-sm-field input:focus,.gjs-clm-tags .gjs-sm-field input:focus,.gjs-sm-sector .gjs-clm-field input:focus,.gjs-clm-tags .gjs-clm-field input:focus,.gjs-sm-sector .gjs-sm-field select:focus,.gjs-clm-tags .gjs-sm-field select:focus,.gjs-sm-sector .gjs-clm-field select:focus,.gjs-clm-tags .gjs-clm-field select:focus{outline:none}.gjs-sm-sector .gjs-sm-field .gjs-sm-unit,.gjs-clm-tags .gjs-sm-field .gjs-sm-unit,.gjs-sm-sector .gjs-clm-field .gjs-sm-unit,.gjs-clm-tags .gjs-clm-field .gjs-sm-unit{position:absolute;right:10px;top:3px;font-size:10px;color:rgba(255,255,255,0.7);cursor:pointer}.gjs-sm-sector .gjs-sm-field .gjs-clm-sel-arrow,.gjs-clm-tags .gjs-sm-field .gjs-clm-sel-arrow,.gjs-sm-sector .gjs-clm-field .gjs-clm-sel-arrow,.gjs-clm-tags .gjs-clm-field .gjs-clm-sel-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-int-arrows,.gjs-clm-tags .gjs-sm-field .gjs-sm-int-arrows,.gjs-sm-sector .gjs-clm-field .gjs-sm-int-arrows,.gjs-clm-tags .gjs-clm-field .gjs-sm-int-arrows,.gjs-sm-sector .gjs-sm-field .gjs-sm-sel-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-sel-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-sel-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-sel-arrow{height:100%;width:9px;position:absolute;right:0;top:0;cursor:ns-resize}.gjs-sm-sector .gjs-sm-field .gjs-sm-sel-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-sel-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-sel-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-sel-arrow{cursor:pointer}.gjs-sm-sector .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-s-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-u-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-u-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-u-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-u-arrow{position:absolute;height:0;width:0;border-left:3px solid transparent;border-right:4px solid transparent;cursor:pointer}.gjs-sm-sector .gjs-sm-field .gjs-sm-u-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-u-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-u-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-u-arrow{border-bottom:4px solid rgba(255,255,255,0.7);top:4px}.gjs-sm-sector .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-s-arrow{border-top:4px solid rgba(255,255,255,0.7);bottom:4px}.gjs-sm-sector .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-clm-d-s-arrow,.gjs-sm-sector .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-sm-field .gjs-sm-d-s-arrow,.gjs-sm-sector .gjs-clm-field .gjs-sm-d-s-arrow,.gjs-clm-tags .gjs-clm-field .gjs-sm-d-s-arrow{bottom:7px}.gjs-sm-sector .gjs-sm-field.gjs-sm-color,.gjs-clm-tags .gjs-sm-field.gjs-sm-color,.gjs-sm-sector .gjs-sm-color.gjs-clm-field,.gjs-clm-tags .gjs-sm-color.gjs-clm-field,.gjs-sm-sector .gjs-sm-field.gjs-sm-input,.gjs-clm-tags .gjs-sm-field.gjs-sm-input,.gjs-sm-sector .gjs-sm-input.gjs-clm-field,.gjs-clm-tags .gjs-sm-input.gjs-clm-field,.gjs-sm-sector .gjs-sm-field.gjs-sm-integer,.gjs-clm-tags .gjs-sm-field.gjs-sm-integer,.gjs-sm-sector .gjs-sm-integer.gjs-clm-field,.gjs-clm-tags .gjs-sm-integer.gjs-clm-field,.gjs-sm-sector .gjs-sm-field.gjs-sm-list,.gjs-clm-tags .gjs-sm-field.gjs-sm-list,.gjs-sm-sector .gjs-sm-list.gjs-clm-field,.gjs-clm-tags .gjs-sm-list.gjs-clm-field,.gjs-sm-sector .gjs-sm-field.gjs-sm-select,.gjs-clm-tags .gjs-sm-field.gjs-sm-select,.gjs-sm-sector .gjs-sm-select.gjs-clm-field,.gjs-clm-tags .gjs-sm-select.gjs-clm-field,.gjs-sm-sector .gjs-clm-select,.gjs-clm-tags .gjs-clm-select{background-color:rgba(0,0,0,0.2);border:1px solid rgba(0,0,0,0.1);box-shadow:1px 1px 0 rgba(255,255,255,0.1);color:rgba(255,255,255,0.7);border-radius:2px;box-sizing:border-box;padding:0 5px}.gjs-sm-sector .gjs-sm-field.gjs-sm-composite,.gjs-clm-tags .gjs-sm-field.gjs-sm-composite,.gjs-sm-sector .gjs-sm-composite.gjs-clm-field,.gjs-clm-tags .gjs-sm-composite.gjs-clm-field{border-radius:2px}.gjs-sm-sector .gjs-sm-field.gjs-sm-select,.gjs-clm-tags .gjs-sm-field.gjs-sm-select,.gjs-sm-sector .gjs-sm-select.gjs-clm-field,.gjs-clm-tags .gjs-sm-select.gjs-clm-field,.gjs-sm-sector .gjs-clm-select,.gjs-clm-tags .gjs-clm-select{padding:0}.gjs-sm-sector .gjs-sm-field.gjs-sm-select select,.gjs-clm-tags .gjs-sm-field.gjs-sm-select select,.gjs-sm-sector .gjs-sm-select.gjs-clm-field select,.gjs-clm-tags .gjs-sm-select.gjs-clm-field select,.gjs-sm-sector .gjs-clm-select select,.gjs-clm-tags .gjs-clm-select select{height:20px}.gjs-sm-sector .gjs-sm-field.gjs-sm-select option,.gjs-clm-tags .gjs-sm-field.gjs-sm-select option,.gjs-sm-sector .gjs-sm-select.gjs-clm-field option,.gjs-clm-tags .gjs-sm-select.gjs-clm-field option,.gjs-sm-sector .gjs-clm-select option,.gjs-clm-tags .gjs-clm-select option{padding:3px 0}.gjs-sm-sector .gjs-sm-field.gjs-sm-composite,.gjs-clm-tags .gjs-sm-field.gjs-sm-composite,.gjs-sm-sector .gjs-sm-composite.gjs-clm-field,.gjs-clm-tags .gjs-sm-composite.gjs-clm-field{background-color:rgba(0,0,0,0.1);border:1px solid rgba(0,0,0,0.25)}.gjs-sm-sector .gjs-sm-field.gjs-sm-list,.gjs-clm-tags .gjs-sm-field.gjs-sm-list,.gjs-sm-sector .gjs-sm-list.gjs-clm-field,.gjs-clm-tags .gjs-sm-list.gjs-clm-field{width:auto;padding:0;overflow:hidden;float:left}.gjs-sm-sector .gjs-sm-field.gjs-sm-list input,.gjs-clm-tags .gjs-sm-field.gjs-sm-list input,.gjs-sm-sector .gjs-sm-list.gjs-clm-field input,.gjs-clm-tags .gjs-sm-list.gjs-clm-field input{display:none}.gjs-sm-sector .gjs-sm-field.gjs-sm-list label,.gjs-clm-tags .gjs-sm-field.gjs-sm-list label,.gjs-sm-sector .gjs-sm-list.gjs-clm-field label,.gjs-clm-tags .gjs-sm-list.gjs-clm-field label{cursor:pointer;padding:5px;display:block}.gjs-sm-sector .gjs-sm-field.gjs-sm-list .gjs-sm-radio:checked+label,.gjs-clm-tags .gjs-sm-field.gjs-sm-list .gjs-sm-radio:checked+label,.gjs-sm-sector .gjs-sm-list.gjs-clm-field .gjs-sm-radio:checked+label,.gjs-clm-tags .gjs-sm-list.gjs-clm-field .gjs-sm-radio:checked+label{background-color:rgba(255,255,255,0.2)}.gjs-sm-sector .gjs-sm-field.gjs-sm-list .gjs-sm-icon,.gjs-clm-tags .gjs-sm-field.gjs-sm-list .gjs-sm-icon,.gjs-sm-sector .gjs-sm-list.gjs-clm-field .gjs-sm-icon,.gjs-clm-tags .gjs-sm-list.gjs-clm-field .gjs-sm-icon{background-repeat:no-repeat;background-position:center;text-shadow:none;line-height:normal}.gjs-sm-sector .gjs-sm-field.gjs-sm-integer select,.gjs-clm-tags .gjs-sm-field.gjs-sm-integer select,.gjs-sm-sector .gjs-sm-integer.gjs-clm-field select,.gjs-clm-tags .gjs-sm-integer.gjs-clm-field select{width:auto;padding:0}.gjs-sm-sector .gjs-sm-list .gjs-sm-el,.gjs-clm-tags .gjs-sm-list .gjs-sm-el{float:left;border-left:1px solid rgba(0,0,0,0.2)}.gjs-sm-sector .gjs-sm-list .gjs-sm-el:first-child,.gjs-clm-tags .gjs-sm-list .gjs-sm-el:first-child{border:none}.gjs-sm-sector .gjs-sm-list .gjs-sm-el:hover,.gjs-clm-tags .gjs-sm-list .gjs-sm-el:hover{background:rgba(0,0,0,0.2)}.gjs-sm-sector .gjs-sm-slider .gjs-field-integer,.gjs-clm-tags .gjs-sm-slider .gjs-field-integer{flex:1 1 65px}.gjs-sm-sector .gjs-sm-property,.gjs-clm-tags .gjs-sm-property{box-sizing:border-box;float:left;width:50%;margin-bottom:5px;padding:0 5px}.gjs-sm-sector .gjs-sm-property.gjs-sm-composite,.gjs-clm-tags .gjs-sm-property.gjs-sm-composite,.gjs-sm-sector .gjs-sm-property.gjs-sm-file,.gjs-clm-tags .gjs-sm-property.gjs-sm-file,.gjs-sm-sector .gjs-sm-property.gjs-sm-list,.gjs-clm-tags .gjs-sm-property.gjs-sm-list,.gjs-sm-sector .gjs-sm-property.gjs-sm-radio,.gjs-clm-tags .gjs-sm-property.gjs-sm-radio,.gjs-sm-sector .gjs-sm-property.gjs-sm-stack,.gjs-clm-tags .gjs-sm-property.gjs-sm-stack,.gjs-sm-sector .gjs-sm-property.gjs-sm-slider,.gjs-clm-tags .gjs-sm-property.gjs-sm-slider,.gjs-sm-sector .gjs-sm-property.gjs-sm-color,.gjs-clm-tags .gjs-sm-property.gjs-sm-color{width:100%}.gjs-sm-sector .gjs-sm-property .gjs-sm-btn,.gjs-clm-tags .gjs-sm-property .gjs-sm-btn{background-color:rgba(33,33,33,0.2);border-radius:2px;box-shadow:1px 1px 0 rgba(5,5,5,0.2),1px 1px 0 rgba(43,43,43,0.2) inset;padding:5px;position:relative;text-align:center;height:auto;width:100%;cursor:pointer;color:#ddd;box-sizing:border-box;text-shadow:-1px -1px 0 rgba(0,0,0,0.2);border:none;opacity:.85;filter:alpha(opacity=85)}.gjs-sm-sector .gjs-sm-property .gjs-sm-btn-c,.gjs-clm-tags .gjs-sm-property .gjs-sm-btn-c{box-sizing:border-box;float:left;width:100%}.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box{background-color:rgba(255,255,255,0.05);border-radius:2px;margin-top:5px;position:relative;overflow:hidden}.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box.gjs-sm-show,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box.gjs-sm-show{border:1px solid rgba(252,252,252,0.05);padding:3px 20px}.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-box #gjs-sm-close{top:-5px;display:block}.gjs-sm-sector .gjs-sm-property.gjs-sm-file .gjs-sm-show #gjs-sm-preview-file,.gjs-clm-tags .gjs-sm-property.gjs-sm-file .gjs-sm-show #gjs-sm-preview-file{height:50px}.gjs-sm-sector .gjs-sm-property.gjs-sm-file #gjs-sm-preview-file,.gjs-clm-tags .gjs-sm-property.gjs-sm-file #gjs-sm-preview-file{background-size:auto 100%;background-repeat:no-repeat;background-position:center center}.gjs-sm-sector .gjs-sm-property .gjs-sm-layers,.gjs-clm-tags .gjs-sm-property .gjs-sm-layers{margin-top:5px;padding:1px 3px;min-height:30px}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer{background-color:rgba(255,255,255,0.055);border-radius:2px;margin:2px 0;padding:7px;position:relative;cursor:pointer}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box{height:15px;position:absolute;right:27px;top:6px;width:15px}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer #gjs-sm-preview,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer #gjs-sm-preview,.gjs-sm-sector .gjs-sm-property .gjs-sm-layer #gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer #gjs-sm-preview-box{border-radius:2px}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer #gjs-sm-close-layer,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer #gjs-sm-close-layer{display:block;font-size:23px;position:absolute;cursor:pointer;right:5px;top:0;opacity:.5;filter:alpha(opacity=50)}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer #gjs-sm-close-layer:hover,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer #gjs-sm-close-layer:hover{opacity:.8;filter:alpha(opacity=80)}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box #gjs-sm-preview,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer>#gjs-sm-preview-box #gjs-sm-preview{background-color:white;height:100%;width:100%;background-size:cover !important}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer.gjs-sm-active,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer.gjs-sm-active{background-color:rgba(255,255,255,0.12)}.gjs-sm-sector .gjs-sm-property .gjs-sm-layer.gjs-sm-no-preview #gjs-sm-preview-box,.gjs-clm-tags .gjs-sm-property .gjs-sm-layer.gjs-sm-no-preview #gjs-sm-preview-box{display:none}.gjs-sm-sector #gjs-sm-text-shadow #gjs-sm-preview::after,.gjs-clm-tags #gjs-sm-text-shadow #gjs-sm-preview::after{color:#000;content:"T";font-weight:900;line-height:17px;padding:0 4px}.gjs-sm-sector .gjs-sm-stack .gjs-sm-properties,.gjs-clm-tags .gjs-sm-stack .gjs-sm-properties{padding:5px 0 0}.gjs-sm-sector .gjs-sm-stack #gjs-sm-add,.gjs-clm-tags .gjs-sm-stack #gjs-sm-add{background:none;border:none;cursor:pointer;outline:none;font-size:22px;line-height:10px;position:absolute;right:0;top:-17px;opacity:0.75}.gjs-sm-sector .gjs-sm-stack #gjs-sm-add:hover,.gjs-clm-tags .gjs-sm-stack #gjs-sm-add:hover{opacity:1;filter:alpha(opacity=100)}.gjs-sm-sector .gjs-sm-colorp-c,.gjs-clm-tags .gjs-sm-colorp-c{height:100%;width:20px;position:absolute;right:0;top:0;box-sizing:border-box;border-radius:2px;padding:2px}.gjs-sm-sector .gjs-sm-colorp-c .gjs-checker-bg,.gjs-clm-tags .gjs-sm-colorp-c .gjs-checker-bg,.gjs-sm-sector .gjs-sm-colorp-c .gjs-field-colorp-c,.gjs-clm-tags .gjs-sm-colorp-c .gjs-field-colorp-c{height:100%;width:100%;border-radius:1px}.gjs-sm-sector .gjs-sm-color-picker,.gjs-clm-tags .gjs-sm-color-picker{background-color:#ddd;cursor:pointer;height:16px;width:100%;margin-top:-16px;box-shadow:0 0 1px rgba(0,0,0,0.2);border-radius:1px}.gjs-sm-sector .gjs-sm-btn-upload #gjs-sm-upload,.gjs-clm-tags .gjs-sm-btn-upload #gjs-sm-upload{left:0;top:0;position:absolute;width:100%;opacity:0;cursor:pointer}.gjs-sm-sector .gjs-sm-btn-upload #gjs-sm-label,.gjs-clm-tags .gjs-sm-btn-upload #gjs-sm-label{padding:2px 0}.gjs-sm-layer>#gjs-sm-move{opacity:.7;filter:alpha(opacity=70);cursor:move;font-size:12px;float:left;margin:0 5px 0 0}.gjs-sm-layer>#gjs-sm-move:hover{opacity:.9;filter:alpha(opacity=90)}.gjs-blocks-c{display:flex;flex-wrap:wrap;justify-content:flex-start}.gjs-block-categories{display:flex;flex-direction:column}.gjs-block-category{width:100%}.gjs-block-category .gjs-caret-icon{margin-right:5px}.gjs-block{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;width:45%;padding:1em;box-sizing:border-box;height:90px;cursor:all-scroll;font-size:11px;font-weight:lighter;display:flex;flex-direction:column;justify-content:flex-end;border:1px solid rgba(0,0,0,0.2);border-radius:3px;margin:10px 2.5% 5px;box-shadow:0 1px 0 0 rgba(0,0,0,0.15);transition:all 0.2s ease 0s;transition-property:box-shadow, color}.gjs-block:hover{box-shadow:0 3px 4px 0 rgba(0,0,0,0.15)}.gjs-block-svg{width:61%;fill:currentColor}.gjs-block-svg-path{fill:currentColor}.gjs-block.fa{font-size:2em;line-height:2em;padding:11px}.gjs-block-label{line-height:normal;font-size:0.65rem;font-weight:normal;font-family:Helvetica, sans-serif}.gjs-block.gjs-bdrag{width:auto;padding:0}.gjs-nv-selected-parent{border:1px solid #ffca6f}.gjs-nv-opac50{opacity:.5;filter:alpha(opacity=50)}.gjs-layers{position:relative;height:100%}.gjs-layers #gjs-nv-placeholder{width:100%;position:absolute}.gjs-layers #gjs-nv-placeholder #gjs-nv-plh-int{height:100%;padding:1px}.gjs-layers #gjs-nv-placeholder #gjs-nv-plh-int.gjs-nv-insert{background-color:#62c462}.gjs-layers .gjs-nv-item{font-weight:lighter;text-align:left;position:relative;background-color:rgba(0,0,0,0.1)}.gjs-layers .gjs-nv-item.gjs-nv-hide{opacity:.55;filter:alpha(opacity=55)}.gjs-layers .gjs-nv-item #gjs-nv-counter{font-size:10px;position:absolute;right:27px;top:9px}.gjs-layers .gjs-nv-item #gjs-nv-btn-eye{height:auto !important;width:auto !important;font-size:13px;left:0;top:0;padding:7px 5px 7px 10px;position:absolute;cursor:pointer;z-index:1}.gjs-nv-item #gjs-nv-caret{font-size:7px;width:8px;padding:2px;cursor:pointer;position:absolute;left:-9px;top:6px;opacity:.7;filter:alpha(opacity=70)}.gjs-nv-item #gjs-nv-caret:hover{opacity:1;filter:alpha(opacity=100)}.gjs-nv-title{padding:3px 10px 5px 30px;display:flex;align-items:center}.gjs-nv-title-inn{position:relative}.gjs-nv-item .gjs-nv-children .gjs-nv-title{border-left:1px solid rgba(5,5,5,0.2)}.gjs-nv-item>.gjs-nv-children{display:none}.gjs-nv-item.open>.gjs-nv-children{display:block}.gjs-nv-item>.gjs-nv-no-chld>#gjs-nv-caret::before{content:''}.gjs-nv-no-chld>.gjs-nv-title-inn>#gjs-nv-caret{display:none}.gjs-nv-item>#gjs-nv-move{position:absolute;cursor:move;font-size:12px;right:0;top:0;padding:7px 10px 7px 5px}.gjs-nv-selected .gjs-nv-title{background-color:rgba(255,255,255,0.1)}.gjs-nv-nav-item-edit{visibility:hidden;padding:5px;font-size:9px;position:absolute;left:-27px;top:1px;opacity:.7;filter:alpha(opacity=70)}.gjs-nv-nav-item-edit:hover{opacity:1;filter:alpha(opacity=100)}.gjs-nv-title-c:hover .gjs-nv-nav-item-edit{visibility:visible;cursor:pointer}.gjs-nav-comp-name{padding:5px;box-sizing:content-box}.gjs-clm-tags{font-size:11px;padding:10px 5px}.gjs-clm-tags #gjs-clm-label,.gjs-clm-tags #gjs-clm-sel{padding:7px 0;float:left}.gjs-clm-tags #gjs-clm-sel{font-style:italic;margin-left:5px}.gjs-clm-tags #gjs-clm-status-c{float:right}.gjs-clm-tags #gjs-clm-tags-field{clear:both;padding:5px;margin-bottom:5px}.gjs-clm-tags #gjs-clm-tags-c{display:inline-block;vertical-align:top}.gjs-clm-tags #gjs-clm-add-tag{background-color:rgba(255,255,255,0.15);border-radius:2px;padding:5px 6px;box-shadow:1px 1px 0 rgba(255,255,255,0.2) inset;border:1px solid rgba(0,0,0,0.15);cursor:pointer}.gjs-clm-tags #gjs-clm-new{color:#ddd;padding:5px 6px;display:none}.gjs-clm-tags .gjs-clm-tag{display:inline-block;border-radius:3px;margin:0 3px 3px 0;padding:5px;cursor:default}.gjs-clm-tags #gjs-clm-close{font-size:20px;line-height:0;cursor:pointer;color:rgba(255,255,255,0.9)}.gjs-clm-tags #gjs-clm-close:hover{opacity:.7;filter:alpha(opacity=70)}.gjs-clm-tags #gjs-clm-checkbox{color:rgba(255,255,255,0.9);vertical-align:middle;cursor:pointer;font-size:9px}.gjs-clm-tags #gjs-clm-tag-label{padding:0 3px;cursor:text}.gjs-mdl-backlayer{opacity:.5;filter:alpha(opacity=50);background-color:#000;position:absolute;top:0;left:0;z-index:1;width:100%;height:100%}.gjs-mdl-container{font-family:Helvetica,sans-serif;position:absolute;top:0;left:0;z-index:10;width:100%;height:100%}.gjs-mdl-dialog{text-shadow:-1px -1px 0 rgba(0,0,0,0.05);animation:gjs-slide-down 0.215s;margin:30px auto 0;max-width:850px;width:90%;border-radius:3px;font-weight:lighter;position:relative;z-index:2}.gjs-mdl-title{font-size:1rem}.gjs-mdl-btn-close{position:absolute;right:15px;top:5px}.gjs-mdl-active .gjs-mdl-dialog{animation:gjs-mdl-slide-down 0.216s}.gjs-mdl-header,.gjs-mdl-content{padding:10px 15px;clear:both}.gjs-mdl-header{position:relative;border-bottom:1px solid rgba(0,0,0,0.2);padding:15px 15px 7px}.gjs-export-dl::after{content:"";clear:both;display:block;margin-bottom:10px}.gjs-dropzone{display:none;opacity:0;position:absolute;top:0;left:0;z-index:11;width:100%;height:100%;transition:opacity 0.25s;pointer-events:none}.gjs-dropzone-active .gjs-dropzone{display:block;opacity:1}.gjs-am-assets{height:290px;overflow:auto;clear:both;display:flex;flex-wrap:wrap;align-items:flex-start;align-content:flex-start}.gjs-am-assets-header{padding:5px}.gjs-am-add-asset .gjs-am-add-field{width:70%;float:left}.gjs-am-add-asset button{width:25%;float:right}.gjs-am-preview-cont{position:relative;height:70px;width:30%;background-color:#444;border-radius:2px;float:left;overflow:hidden}.gjs-am-preview{position:absolute;background-position:center center;background-size:cover;background-repeat:no-repeat;height:100%;width:100%;z-index:1}.gjs-am-preview-bg{opacity:.5;filter:alpha(opacity=50);position:absolute;height:100%;width:100%;z-index:0}.gjs-am-dimensions{opacity:.5;filter:alpha(opacity=50);font-size:10px}.gjs-am-meta{width:70%;float:left;font-size:12px;padding:5px 0 0 5px;box-sizing:border-box}.gjs-am-meta>div{margin-bottom:5px}.gjs-am-close{cursor:pointer;position:absolute;right:5px;top:0;display:none}.gjs-am-asset{border-bottom:1px solid rgba(0,0,0,0.2);padding:5px;cursor:pointer;position:relative;box-sizing:border-box;width:100%}.gjs-am-asset:hover .gjs-am-close{display:block}.gjs-am-highlight{background-color:rgba(255,255,255,0.1)}.gjs-am-assets-cont{background-color:rgba(0,0,0,0.1);border-radius:3px;box-sizing:border-box;padding:10px;width:45%;float:right;height:325px;overflow:hidden}.gjs-am-file-uploader{width:55%;float:left}.gjs-am-file-uploader>form{background-color:rgba(0,0,0,0.1);border:2px dashed;border-radius:3px;position:relative;text-align:center;margin-bottom:15px}.gjs-am-file-uploader>form.gjs-am-hover{border:2px solid #62c462;color:#75cb75}.gjs-am-file-uploader>form.gjs-am-disabled{border-color:red}.gjs-am-file-uploader>form #gjs-am-uploadFile{opacity:0;filter:alpha(opacity=0);padding:150px 10px;width:100%;box-sizing:border-box}.gjs-am-file-uploader #gjs-am-title{position:absolute;padding:150px 10px;width:100%}.gjs-cm-editor-c{float:left;box-sizing:border-box;width:50%}.gjs-cm-editor-c .CodeMirror{height:450px}.gjs-cm-editor{font-size:12px}.gjs-cm-editor#gjs-cm-htmlmixed{padding-right:10px;border-right:1px solid rgba(0,0,0,0.2)}.gjs-cm-editor#gjs-cm-htmlmixed #gjs-cm-title{color:#a97d44}.gjs-cm-editor#gjs-cm-css{padding-left:10px}.gjs-cm-editor#gjs-cm-css #gjs-cm-title{color:#ddca7e}.gjs-cm-editor #gjs-cm-title{background-color:rgba(0,0,0,0.2);font-size:12px;padding:5px 10px 3px;text-align:right}.gjs-rte-toolbar{border:1px solid rgba(0,0,0,0.2);position:absolute;border-radius:3px;z-index:10}.gjs-rte-actionbar{display:flex}.gjs-rte-action{display:flex;align-items:center;justify-content:center;padding:5px;min-width:25px;border-right:1px solid rgba(0,0,0,0.2);text-align:center;cursor:pointer;outline:none}.gjs-rte-action:last-child{border-right:none}.gjs-rte-action:hover{background-color:rgba(255,255,255,0.1)}.gjs-rte-active{background-color:rgba(0,0,0,0.2)}.gjs-editor-cont .sp-hue,.gjs-editor-cont .sp-slider{cursor:row-resize}.gjs-editor-cont .sp-color,.gjs-editor-cont .sp-dragger{cursor:crosshair}.gjs-editor-cont .sp-alpha-inner,.gjs-editor-cont .sp-alpha-handle{cursor:col-resize}.gjs-editor-cont .sp-hue{left:90%}.gjs-editor-cont .sp-color{right:15%}.gjs-editor-cont .sp-container{border:1px solid rgba(0,0,0,0.2);box-shadow:0 0 7px rgba(0,0,0,0.2);border-radius:3px}.gjs-editor-cont .sp-picker-container{border:none}.gjs-editor-cont .colpick_dark .colpick_color{outline:1px solid rgba(0,0,0,0.2)}.gjs-editor-cont .sp-cancel,.gjs-editor-cont .sp-cancel:hover{bottom:-8px;color:#777 !important;font-size:25px;left:0;position:absolute;text-decoration:none}.gjs-editor-cont .sp-alpha-handle{background-color:#ccc;border:1px solid #555;width:4px}.gjs-editor-cont .sp-color,.gjs-editor-cont .sp-hue{border:1px solid #333333}.gjs-editor-cont .sp-slider{background-color:#ccc;border:1px solid #555;height:3px;left:-4px;width:22px}.gjs-editor-cont .sp-dragger{background:transparent;box-shadow:0 0 0 1px #111}.gjs-editor-cont .sp-button-container{float:none;width:100%;position:relative;text-align:right}.gjs-editor-cont .sp-container button,.gjs-editor-cont .sp-container button:hover,.gjs-editor-cont .sp-container button:active{background:rgba(0,0,0,0.2);border-color:rgba(0,0,0,0.2);color:#ddd;text-shadow:none;box-shadow:none;padding:3px 5px}.gjs-editor-cont .sp-palette-container{border:none;float:none;margin:0;padding:5px 10px 0}.gjs-editor-cont .sp-palette .sp-thumb-el,.gjs-editor-cont .sp-palette .sp-thumb-el:hover{border:1px solid rgba(0,0,0,0.9)}.gjs-editor-cont .sp-palette .sp-thumb-el:hover,.gjs-editor-cont .sp-palette .sp-thumb-el.sp-thumb-active{border-color:rgba(0,0,0,0.9)}.gjs-hidden{display:none}@keyframes gjs-slide-down{0%{transform:translate(0, -3rem);opacity:0}100%{transform:translate(0, 0);opacity:1}}@keyframes gjs-slide-up{0%{transform:translate(0, 0);opacity:1}100%{transform:translate(0, -3rem);opacity:0}} diff --git a/dist/grapes.js b/dist/grapes.js index 53ad10e3b..8cb6af7ba 100644 --- a/dist/grapes.js +++ b/dist/grapes.js @@ -3566,7 +3566,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor Object.defineProperty(exports, "__esModule", { value: true }); -exports.getUnitFromValue = exports.normalizeFloat = exports.shallowDiff = exports.camelCase = exports.matches = exports.upFirst = exports.off = exports.on = undefined; +exports.getUnitFromValue = exports.normalizeFloat = exports.shallowDiff = exports.camelCase = exports.matches = exports.upFirst = exports.hasDnd = exports.off = exports.on = undefined; var _underscore = __webpack_require__(1); @@ -3673,8 +3673,13 @@ var normalizeFloat = function normalizeFloat(value) { return stepDecimals ? parseFloat(value.toFixed(stepDecimals)) : value; }; +var hasDnd = function hasDnd(em) { + return 'draggable' in document.createElement('i') && (em ? em.get('Config').nativeDnD : 1); +}; + exports.on = on; exports.off = off; +exports.hasDnd = hasDnd; exports.upFirst = upFirst; exports.matches = matches; exports.camelCase = camelCase; @@ -3885,7 +3890,7 @@ module.exports = Backbone.View.extend({ * @private * */ getClasses: function getClasses() { - var attr = this.model.get("attributes"), + var attr = this.model.get('attributes'), classes = attr['class'] || []; classes = (0, _underscore.isArray)(classes) ? classes : [classes]; @@ -4065,14 +4070,15 @@ var Backbone = __webpack_require__(0); var Components = __webpack_require__(49); var Selector = __webpack_require__(7); var Selectors = __webpack_require__(10); -var Traits = __webpack_require__(152); +var Traits = __webpack_require__(150); +var componentList = {}; +var componentIndex = 0; var escapeRegExp = function escapeRegExp(str) { return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'); }; -module.exports = Backbone.Model.extend(_Styleable2.default).extend({ - +var Component = Backbone.Model.extend(_Styleable2.default).extend({ defaults: { // HTML tag of the component tagName: 'div', @@ -4080,6 +4086,9 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ // Component type, eg. 'text', 'image', 'video', etc. type: '', + // Name of the component. Will be used, for example, in layers and badges + name: '', + // True if the component is removable from the canvas removable: true, @@ -4173,16 +4182,16 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ propagate: '', /** - * Set an array of items to show up inside the toolbar (eg. move, clone, delete) - * when the component is selected - * toolbar: [{ - * attributes: {class: 'fa fa-arrows'}, - * command: 'tlb-move', - * },{ - * attributes: {class: 'fa fa-clone'}, - * command: 'tlb-clone', - * }] - */ + * Set an array of items to show up inside the toolbar (eg. move, clone, delete) + * when the component is selected + * toolbar: [{ + * attributes: {class: 'fa fa-arrows'}, + * command: 'tlb-move', + * },{ + * attributes: {class: 'fa fa-clone'}, + * command: 'tlb-clone', + * }] + */ toolbar: null }, @@ -4222,13 +4231,15 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ this.sm = em; this.em = em; this.config = opt.config || {}; + this.ccid = Component.createId(this); this.set('attributes', this.get('attributes') || {}); + this.on('destroy', this.handleRemove); this.listenTo(this, 'change:script', this.scriptUpdated); this.listenTo(this, 'change:traits', this.traitsUpdated); this.listenTo(this, 'change:tagName', this.tagUpdated); this.listenTo(this, 'change:attributes', this.attrUpdated); - this.loadTraits(); this.initClasses(); + this.loadTraits(); this.initComponents(); this.initToolbar(); this.set('status', ''); @@ -4239,6 +4250,17 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ }, + /** + * Triggered on model remove + * @param {Model} removed Removed model + * @private + */ + handleRemove: function handleRemove(removed) { + var em = this.em; + em && em.trigger('component:remove', removed); + }, + + /** * Check component's type * @param {string} type Component type @@ -4264,7 +4286,8 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ find: function find(query) { var result = []; - this.view.$el.find(query).each(function (el, i, $el) { + this.view.$el.find(query).each(function (el, i, $els) { + var $el = $els.eq(i); var model = $el.data('model'); model && result.push(model); }); @@ -4453,7 +4476,7 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ // is not visible var comps = new Components(null, this.opt); comps.parent = this; - comps.reset(this.get('components')); + !this.opt.avoidChildren && comps.reset(this.get('components')); this.set('components', comps); return this; }, @@ -4570,7 +4593,8 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ } if (model.get('draggable')) { tb.push({ - attributes: { class: 'fa fa-arrows' }, + attributes: { class: 'fa fa-arrows', draggable: true }, + //events: hasDnd(this.em) ? { dragstart: 'execCommand' } : '', command: 'tlb-move' }); } @@ -4682,7 +4706,7 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ * @return {string} * */ getName: function getName() { - var customName = this.get('custom-name'); + var customName = this.get('name') || this.get('custom-name'); var tag = this.get('tagName'); tag = tag == 'div' ? 'box' : tag; var name = this.get('type') || tag; @@ -4759,11 +4783,10 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ var obj = Backbone.Model.prototype.toJSON.apply(this, args); var scriptStr = this.getScriptString(); + obj.attributes = this.getAttributes(); + delete obj.attributes.class; delete obj.toolbar; - - if (scriptStr) { - obj.script = scriptStr; - } + scriptStr && (obj.script = scriptStr); return obj; }, @@ -4775,7 +4798,17 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ */ getId: function getId() { var attrs = this.get('attributes') || {}; - return attrs.id || this.cid; + return attrs.id || this.ccid || this.cid; + }, + + + /** + * Get the DOM element of the model. This works only of the + * model is alredy rendered + * @return {HTMLElement} + */ + getEl: function getEl() { + return this.view && this.view.el; }, @@ -4805,12 +4838,12 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ var config = this.sm.config || {}; var tagVarStart = escapeRegExp(config.tagVarStart || '{[ '); var tagVarEnd = escapeRegExp(config.tagVarEnd || ' ]}'); - var reg = new RegExp(tagVarStart + '(\\w+)' + tagVarEnd, 'g'); + var reg = new RegExp(tagVarStart + '([\\w\\d-]*)' + tagVarEnd, 'g'); scr = scr.replace(reg, function (match, v) { // If at least one match is found I have to track this change for a // better optimization inside JS generator _this4.scriptUpdated(); - return _this4.attributes[v]; + return _this4.attributes[v] || ''; }); return scr; @@ -4821,7 +4854,6 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ em && em.trigger(event, this.model); } }, { - /** * Detect if the passed element is a valid component. * In case the element is valid an object abstracted @@ -4832,9 +4864,31 @@ module.exports = Backbone.Model.extend(_Styleable2.default).extend({ */ isComponent: function isComponent(el) { return { tagName: el.tagName ? el.tagName.toLowerCase() : '' }; + }, + + + /** + * Relying simply on the number of components becomes a problem when you + * store and load them back, you might hit collisions with new components + * @param {Model} model + * @return {string} + */ + createId: function createId(model) { + componentIndex++; + // Testing 1000000 components with `+ 2` returns 0 collisions + var ilen = componentIndex.toString().length + 2; + var uid = (Math.random() + 1.1).toString(36).slice(-ilen); + var nextId = 'i' + uid; + componentList[nextId] = model; + return nextId; + }, + getList: function getList() { + return componentList; } }); +module.exports = Component; + /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { @@ -4867,7 +4921,7 @@ module.exports = Backbone.View.extend({ events: _defineProperty({ - 'change': 'inputValueChanged' + change: 'inputValueChanged' }, 'click [' + clearProp + ']', 'clear'), initialize: function initialize() { @@ -15009,7 +15063,6 @@ var TYPE_CLASS = 1; var TYPE_ID = 2; var Selector = Backbone.Model.extend({ - idAttribute: 'name', defaults: { @@ -15096,9 +15149,8 @@ var Backbone = __webpack_require__(0); var $ = Backbone.$; module.exports = Backbone.View.extend({ - events: { - 'change': 'onChange' + change: 'onChange' }, attributes: function attributes() { @@ -16274,7 +16326,7 @@ var Property = __webpack_require__(12); module.exports = __webpack_require__(0).Collection.extend(_TypeableCollection2.default).extend({ types: [{ id: 'stack', - model: __webpack_require__(121), + model: __webpack_require__(119), view: __webpack_require__(34), isType: function isType(value) { if (value && value.type == 'stack') { @@ -16328,8 +16380,8 @@ module.exports = __webpack_require__(0).Collection.extend(_TypeableCollection2.d } }, { id: 'slider', - model: __webpack_require__(127), - view: __webpack_require__(128), + model: __webpack_require__(125), + view: __webpack_require__(126), isType: function isType(value) { if (value && value.type == 'slider') { return value; @@ -16401,7 +16453,6 @@ module.exports = __webpack_require__(0).Collection.extend(_TypeableCollection2.d var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; module.exports = __webpack_require__(0).Model.extend({ - defaults: { name: '', property: '', @@ -16660,12 +16711,11 @@ var Backbone = __webpack_require__(0); var ComponentView = __webpack_require__(3); module.exports = ComponentView.extend({ - tagName: 'img', events: { - 'dblclick': 'openModal', - 'click': 'initResize' + dblclick: 'openModal', + click: 'initResize' }, initialize: function initialize(o) { @@ -16677,6 +16727,28 @@ module.exports = ComponentView.extend({ var config = this.config; config.modal && (this.modal = config.modal); config.am && (this.am = config.am); + this.fetchFile(); + }, + + + /** + * Fetch file if exists + */ + fetchFile: function fetchFile() { + var model = this.model; + var file = model.get('file'); + + if (file) { + var fu = this.em.get('AssetManager').FileUploader(); + fu.uploadFile({ + dataTransfer: { files: [file] } + }, function (res) { + var obj = res && res.data && res.data[0]; + var src = obj && obj.src; + src && model.set({ src: src }); + }); + model.set('file', ''); + } }, @@ -16685,7 +16757,7 @@ module.exports = ComponentView.extend({ * @private * */ updateSrc: function updateSrc() { - var src = this.model.get("src"); + var src = this.model.get('src'); var el = this.$el; el.attr('src', src); el[src ? 'removeClass' : 'addClass'](this.classEmpty); @@ -16896,7 +16968,6 @@ var Backbone = __webpack_require__(0); var $ = Backbone.$; module.exports = Input.extend({ - events: { 'change input': 'handleChange', 'change select': 'handleUnitChange', @@ -16984,7 +17055,7 @@ module.exports = Input.extend({ var model = this.model; this.getInputEl().value = model.get('value'); var unitEl = this.getUnitEl(); - unitEl && (unitEl.value = model.get('unit')); + unitEl && (unitEl.value = model.get('unit') || ''); }, @@ -17021,7 +17092,7 @@ module.exports = Input.extend({ upArrowClick: function upArrowClick() { var model = this.model; var step = model.get('step'); - var value = model.get('value'); + var value = parseInt(model.get('value'), 10); value = this.normalizeValue(value + step); var valid = this.validateInputValue(value); model.set('value', valid.value); @@ -17035,7 +17106,7 @@ module.exports = Input.extend({ downArrowClick: function downArrowClick() { var model = this.model; var step = model.get('step'); - var value = model.get('value'); + var value = parseInt(model.get('value'), 10); var val = this.normalizeValue(value - step); var valid = this.validateInputValue(val); model.set('value', valid.value); @@ -17183,7 +17254,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Component = __webpack_require__(4); module.exports = Component.extend({ - defaults: _extends({}, Component.prototype.defaults, { type: 'tbody', tagName: 'tbody', @@ -17248,7 +17318,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Component = __webpack_require__(4); module.exports = Component.extend({ - defaults: _extends({}, Component.prototype.defaults, { type: 'image', tagName: 'img', @@ -17258,7 +17327,10 @@ module.exports = Component.extend({ editable: 1, highlightable: 0, resizable: 1, - traits: ['alt'] + traits: ['alt'], + + // File to load asynchronously once the model is rendered + file: '' }), initialize: function initialize(o, opt) { @@ -17335,7 +17407,6 @@ module.exports = Component.extend({ }; } }, { - /** * Detect if the passed element is a valid component. * In case the element is valid an object abstracted @@ -17368,8 +17439,8 @@ var _underscore = __webpack_require__(1); var _mixins = __webpack_require__(2); -var ToolbarView = __webpack_require__(188); -var Toolbar = __webpack_require__(190); +var ToolbarView = __webpack_require__(187); +var Toolbar = __webpack_require__(189); var key = __webpack_require__(23); var $ = __webpack_require__(0).$; var showOffsets = void 0; @@ -17593,7 +17664,7 @@ module.exports = { var config = canvas.getConfig(); var customeLabel = config.customBadgeLabel; this.cacheEl = el; - var model = $el.data("model"); + var model = $el.data('model'); if (!model || !model.get('badgable')) return; var badge = this.getBadge(); var badgeLabel = model.getIcon() + model.getName(); @@ -17622,7 +17693,7 @@ module.exports = { var $el = $(el); var model = $el.data('model'); - if (!model || !model.get("hoverable") || model.get('status') == 'selected') { + if (!model || !model.get('hoverable') || model.get('status') == 'selected') { return; } @@ -17832,7 +17903,7 @@ module.exports = { }); var leftPos = pos.left + pos.elementWidth - pos.targetWidth; toolbarStyle.top = pos.top + unit; - toolbarStyle.left = leftPos + unit; + toolbarStyle.left = (leftPos < 0 ? 0 : leftPos) + unit; toolbarStyle.display = origDisp; }, @@ -18080,7 +18151,7 @@ module.exports = _.extend({}, SelectPosition, { var trgCollection = $trg.data('collection'); var droppable = trgModel ? trgModel.get('droppable') : 1; opt.at = index; - if (trgCollection && droppable) return trgCollection.add(component, opt);else console.warn("Invalid target position"); + if (trgCollection && droppable) return trgCollection.add(component, opt);else console.warn('Invalid target position'); }, @@ -18514,7 +18585,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _promisePolyfill = __webpack_require__(77); +var _promisePolyfill = __webpack_require__(75); var _promisePolyfill2 = _interopRequireDefault(_promisePolyfill); @@ -18561,13 +18632,11 @@ exports.default = typeof fetch == 'function' ? fetch.bind() : function (url, opt module.exports = function (config) { - var TEXT_NODE = 'span'; var c = config; var modelAttrStart = 'data-gjs-'; return { - compTypes: '', /** @@ -19650,12 +19719,12 @@ var Backbone = __webpack_require__(0); var Buttons = __webpack_require__(28); module.exports = Backbone.Model.extend({ - defaults: { id: '', content: '', visible: true, - buttons: [] + buttons: [], + attributes: {} }, initialize: function initialize(options) { @@ -19673,10 +19742,9 @@ module.exports = Backbone.Model.extend({ var Backbone = __webpack_require__(0); -var Button = __webpack_require__(111); +var Button = __webpack_require__(109); module.exports = Backbone.Collection.extend({ - model: Button, /** @@ -19785,6 +19853,9 @@ module.exports = Backbone.View.extend({ updateContent: function updateContent() { this.$el.html(this.model.get('content')); }, + attributes: function attributes() { + return this.model.get('attributes'); + }, initResize: function initResize() { var em = this.config.em; var editor = em ? em.get('Editor') : ''; @@ -19825,7 +19896,8 @@ module.exports = Backbone.View.extend({ posFetcher: function posFetcher(el) { var rect = el.getBoundingClientRect(); return { - left: 0, top: 0, + left: 0, + top: 0, width: rect.width, height: rect.height }; @@ -19862,7 +19934,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */(function(_) { var Backbone = __webpack_require__(0); -var ButtonView = __webpack_require__(113); +var ButtonView = __webpack_require__(111); module.exports = Backbone.View.extend({ initialize: function initialize(o) { @@ -19979,15 +20051,14 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument */ module.exports = function () { var c = {}, - defaults = __webpack_require__(118), - Sectors = __webpack_require__(119), + defaults = __webpack_require__(116), + Sectors = __webpack_require__(117), Properties = __webpack_require__(11), - SectorsView = __webpack_require__(130); + SectorsView = __webpack_require__(128); var properties = void 0; var sectors, SectView; return { - /** * Name of the module * @type {String} @@ -20475,7 +20546,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Property = __webpack_require__(12); module.exports = Property.extend({ - defaults: _extends({}, Property.prototype.defaults, { // 'background' is a good example where to make a difference // between detached and not @@ -20556,7 +20626,7 @@ module.exports = Property.extend({ var PropertyCompositeView = __webpack_require__(17); -var LayersView = __webpack_require__(125); +var LayersView = __webpack_require__(123); module.exports = PropertyCompositeView.extend({ templateInput: function templateInput() { @@ -20745,9 +20815,8 @@ module.exports = PropertyCompositeView.extend({ var $ = Backbone.$; module.exports = Backbone.View.extend({ - events: { - 'change': 'handleChange' + change: 'handleChange' }, template: function template() { @@ -20976,7 +21045,7 @@ module.exports = __webpack_require__(14).extend({ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -__webpack_require__(124); +__webpack_require__(122); var Input = __webpack_require__(35); var $ = Backbone.$; @@ -21031,7 +21100,7 @@ module.exports = Input.extend({ var colorEl = $('
'); var cpStyle = colorEl.get(0).style; var elToAppend = this.em && this.em.config ? this.em.config.el : ''; - var colorPickerConfig = this.em && this.em.getConfig && this.em.getConfig("colorPicker") || {}; + var colorPickerConfig = this.em && this.em.getConfig && this.em.getConfig('colorPicker') || {}; var getColor = function getColor(color) { var cl = color.getAlpha() == 1 ? color.toHexString() : color.toRgbString(); return cl.replace(/ /g, ''); @@ -21238,12 +21307,10 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Property = __webpack_require__(12); module.exports = Property.extend({ - defaults: _extends({}, Property.prototype.defaults, { // Array of options, eg. [{name: 'Label ', value: '100'}] options: [] }) - }); /***/ }), @@ -21259,7 +21326,6 @@ var Property = __webpack_require__(12); var InputNumber = __webpack_require__(18); module.exports = Property.extend({ - defaults: _extends({}, Property.prototype.defaults, { // Array of units, eg. ['px', '%'] units: [], @@ -21289,7 +21355,9 @@ module.exports = Property.extend({ parseValue: function parseValue(val) { var parsed = Property.prototype.parseValue.apply(this, arguments); - var _input$validateInputV = this.input.validateInputValue(parsed.value, { deepCheck: 1 }), + var _input$validateInputV = this.input.validateInputValue(parsed.value, { + deepCheck: 1 + }), value = _input$validateInputV.value, unit = _input$validateInputV.unit; @@ -21311,7 +21379,6 @@ module.exports = Property.extend({ module.exports = __webpack_require__(44).extend({ - events: { 'click [data-toggle=asset-remove]': 'onRemove', click: 'onClick', @@ -21461,7 +21528,6 @@ var _fetch2 = _interopRequireDefault(_fetch); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } module.exports = Backbone.View.extend({ - template: _.template('\n
\n
<%= title %>
\n multiple/>\n
\n
\n '), events: {}, @@ -21529,7 +21595,7 @@ module.exports = Backbone.View.extend({ * @param {string} text Response text * @private */ - onUploadResponse: function onUploadResponse(text) { + onUploadResponse: function onUploadResponse(text, clb) { var em = this.config.em; var config = this.config; var target = this.target; @@ -21541,6 +21607,7 @@ module.exports = Backbone.View.extend({ } this.onUploadEnd(text); + clb && clb(json); }, @@ -21550,7 +21617,7 @@ module.exports = Backbone.View.extend({ * @return {Promise} * @private * */ - uploadFile: function uploadFile(e) { + uploadFile: function uploadFile(e, clb) { var _this = this; var files = e.dataTransfer ? e.dataTransfer.files : e.target.files; @@ -21587,7 +21654,7 @@ module.exports = Backbone.View.extend({ return Promise.reject(text); }); }).then(function (text) { - return _this.onUploadResponse(text); + return _this.onUploadResponse(text, clb); }).catch(function (err) { return _this.onUploadError(err); }); @@ -21693,7 +21760,7 @@ module.exports = Backbone.View.extend({ return this; } }, { - embedAsBase64: function embedAsBase64(e) { + embedAsBase64: function embedAsBase64(e, clb) { var _this3 = this; // List files dropped @@ -21726,6 +21793,42 @@ module.exports = Backbone.View.extend({ type = file.type; } + /* + // Show local video files, http://jsfiddle.net/dsbonev/cCCZ2/embedded/result,js,html,css/ + var URL = window.URL || window.webkitURL + var file = this.files[0] + var type = file.type + var videoNode = document.createElement('video'); + var canPlay = videoNode.canPlayType(type) // can use also for 'audio' types + if (canPlay === '') canPlay = 'no' + var message = 'Can play type "' + type + '": ' + canPlay + var isError = canPlay === 'no' + displayMessage(message, isError) + if (isError) { + return + } + var fileURL = URL.createObjectURL(file) + videoNode.src = fileURL + */ + + /* + // Show local video files, http://jsfiddle.net/dsbonev/cCCZ2/embedded/result,js,html,css/ + var URL = window.URL || window.webkitURL + var file = this.files[0] + var type = file.type + var videoNode = document.createElement('video'); + var canPlay = videoNode.canPlayType(type) // can use also for 'audio' types + if (canPlay === '') canPlay = 'no' + var message = 'Can play type "' + type + '": ' + canPlay + var isError = canPlay === 'no' + displayMessage(message, isError) + if (isError) { + return + } + var fileURL = URL.createObjectURL(file) + videoNode.src = fileURL + */ + // If it's an image, try to find its size if (type === 'image') { var data = { @@ -21798,7 +21901,7 @@ module.exports = Backbone.View.extend({ Promise.all(promises).then(function (data) { response.data = data; - _this3.onUploadResponse(response); + _this3.onUploadResponse(response, clb); }, function (error) { _this3.onUploadError(error); }); @@ -21823,7 +21926,6 @@ var Backbone = __webpack_require__(0); var Selectors = __webpack_require__(10); module.exports = Backbone.Model.extend(_Styleable2.default).extend({ - defaults: { // Css selectors selectors: {}, @@ -21985,7 +22087,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de var parseStyle = (0, _ParserHtml2.default)().parseStyle; exports.default = { - parseStyle: parseStyle, /** @@ -22104,7 +22205,6 @@ exports.default = { var Backbone = __webpack_require__(0); module.exports = Backbone.View.extend({ - // Default view itemView: '', @@ -22175,7 +22275,6 @@ var Backbone = __webpack_require__(0); module.exports = Backbone.Collection.extend({ initialize: function initialize(models, opt) { - this.on('add', this.onAdd); this.config = opt && opt.config ? opt.config : null; @@ -22386,13 +22485,11 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Component = __webpack_require__(4); module.exports = Component.extend({ - defaults: _extends({}, Component.prototype.defaults, { type: 'text', droppable: false, editable: true }) - }); /***/ }), @@ -22407,9 +22504,8 @@ var _mixins = __webpack_require__(2); var ComponentView = __webpack_require__(3); module.exports = ComponentView.extend({ - events: { - 'dblclick': 'enableEditing' + dblclick: 'enableEditing' }, initialize: function initialize(o) { @@ -22543,7 +22639,6 @@ module.exports = ComponentView.extend({ var $ = Backbone.$; module.exports = { - /** * Start select position event * @param {HTMLElement} trg @@ -22597,8 +22692,8 @@ module.exports = { if (this.cDim) { this.posIsLastEl = this.cDim.length !== 0 && this.posMethod == 'after' && this.posIndex == this.cDim.length; this.posTargetEl = this.cDim.length === 0 ? $(this.outsideElem) : !this.posIsLastEl && this.cDim[this.posIndex] ? $(this.cDim[this.posIndex][5]).parent() : $(this.outsideElem); - this.posTargetModel = this.posTargetEl.data("model"); - this.posTargetCollection = this.posTargetEl.data("model-comp"); + this.posTargetModel = this.posTargetEl.data('model'); + this.posTargetCollection = this.posTargetEl.data('model-comp'); } }, @@ -22693,7 +22788,9 @@ module.exports = _.extend({}, CreateComponent, { this.beforeInsert(object); var index = this.sorter.lastPos.index; // By default, collections do not trigger add event, so silent is used - var model = this.create(this.sorter.target, object, index, null, { silent: false }); + var model = this.create(this.sorter.target, object, index, null, { + silent: false + }); if (this.opt.terminateAfterInsert && this.sender) this.sender.set('active', false);else this.enable(); @@ -22744,7 +22841,6 @@ var ComponentView = __webpack_require__(3); var ItemsView = void 0; module.exports = __webpack_require__(0).View.extend({ - events: { 'mousedown [data-toggle-move]': 'startSort', 'click [data-toggle-visible]': 'toggleVisibility', @@ -22881,7 +22977,7 @@ module.exports = __webpack_require__(0).View.extend({ this.getCaret().addClass(chvDown); opened[model.cid] = model; } else { - this.$el.removeClass("open"); + this.$el.removeClass('open'); this.getCaret().removeClass(chvDown); delete opened[model.cid]; } @@ -23206,14 +23302,12 @@ module.exports = Backbone.View.extend({ var Backbone = __webpack_require__(0); module.exports = Backbone.Model.extend({ - defaults: { id: '', label: '', open: true, attributes: {} } - }); /***/ }), @@ -23223,22 +23317,13 @@ module.exports = Backbone.Model.extend({ "use strict"; -module.exports = __webpack_require__(59); - -/***/ }), -/* 59 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - var _cashDom = __webpack_require__(9); var _cashDom2 = _interopRequireDefault(_cashDom); var _underscore = __webpack_require__(1); -var _polyfills = __webpack_require__(60); +var _polyfills = __webpack_require__(59); var _polyfills2 = _interopRequireDefault(_polyfills); @@ -23247,14 +23332,37 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de (0, _polyfills2.default)(); module.exports = function () { - var defaultConfig = __webpack_require__(61); - var Editor = __webpack_require__(62); - var PluginManager = __webpack_require__(220); + var Editor = __webpack_require__(60); + var PluginManager = __webpack_require__(219); var plugins = new PluginManager(); var editors = []; + var defaultConfig = { + // If true renders editor on init + autorender: 1, - return { + // Where init the editor + container: '', + + // HTML string or object of components + components: '', + + // CSS string or object of rules + style: '', + + // If true, will fetch HTML and CSS from selected container + fromElement: 0, + + // Storage Manager + storageManager: {}, + + // Array of plugins to init + plugins: [], + + // Custom options for plugins + pluginsOpts: {} + }; + return { $: _cashDom2.default, editors: editors, @@ -23262,7 +23370,7 @@ module.exports = function () { plugins: plugins, // Will be replaced on build - version: '0.12.58', + version: '0.13.5', /** * Initializes an editor based on passed options @@ -23319,7 +23427,7 @@ module.exports = function () { }(); /***/ }), -/* 60 */ +/* 59 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -23335,7 +23443,6 @@ Object.defineProperty(exports, "__esModule", { */ exports.default = function () { - /** * Check if IE/Edge * @return {Boolean} @@ -23364,42 +23471,7 @@ exports.default = function () { }; /***/ }), -/* 61 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = { - // If true renders editor on init - autorender: 1, - - // Where init the editor - container: '', - - // HTML string or object of components - components: '', - - // CSS string or object of rules - style: '', - - // If true, will fetch HTML and CSS from selected container - fromElement: 0, - - // --- - - // Storage Manager - storageManager: {}, - - // Array of plugins to init - plugins: [], - - // Custom options for plugins - pluginsOpts: {} -}; - -/***/ }), -/* 62 */ +/* 60 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -23413,9 +23485,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de module.exports = function (config) { var c = config || {}, - defaults = __webpack_require__(63), - EditorModel = __webpack_require__(64), - EditorView = __webpack_require__(219); + defaults = __webpack_require__(61), + EditorModel = __webpack_require__(62), + EditorView = __webpack_require__(218); for (var name in defaults) { if (!(name in c)) c[name] = defaults[name]; @@ -23429,7 +23501,6 @@ module.exports = function (config) { }); return { - $: _cashDom2.default, /** @@ -23950,6 +24021,8 @@ module.exports = function (config) { * * ## Components * * `component:add` - Triggered when a new component is added to the editor, the model is passed as an argument to the callback + * * `component:remove` - Triggered when a component is removed, the model is passed as an argument to the callback + * * `component:clone` - Triggered when a new component is added by a clone command, the model is passed as an argument to the callback * * `component:update` - Triggered when a component is updated (moved, styled, etc.), the model is passed as an argument to the callback * * `component:update:{propertyName}` - Listen any property change, the model is passed as an argument to the callback * * `component:styleUpdate` - Triggered when the style of the component is updated, the model is passed as an argument to the callback @@ -23981,6 +24054,13 @@ module.exports = function (config) { * * `storage:store` - Triggered when something is stored to the storage, stored object passed as an argumnet * * `storage:end` - After the storage request is ended * * `storage:error` - On any error on storage request, passes the error as an argument + * ## Canvas + * * `canvas:dragenter` - When something is dragged inside the canvas, `DataTransfer` instance passed as an argument + * * `canvas:dragover` - When something is dragging on canvas, `DataTransfer` instance passed as an argument + * * `canvas:drop` - Something is dropped in canvas, `DataTransfer` instance and the dropped model are passed as arguments + * * `canvas:dragend` - When a drag operation is ended, `DataTransfer` instance passed as an argument + * * `canvas:dragdata` - On any dataTransfer parse, `DataTransfer` instance and the `result` are passed as arguments. + * By changing `result.content` you're able to customize what is dropped * ## Selectors * * `selector:add` - Triggers when a new selector/class is created * ## RTE @@ -24023,7 +24103,7 @@ module.exports = function (config) { */ /***/ }), -/* 63 */ +/* 61 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -24090,6 +24170,9 @@ module.exports = { // Return JS of components inside HTML from 'editor.getHtml()' jsInHtml: true, + // Enable native HTML5 drag and drop + nativeDnD: 1, + // Show the wrapper component in the final code, eg. in editor.getHtml() exportWrapper: 0, @@ -24166,7 +24249,6 @@ module.exports = { //Configurations for Style Manager styleManager: { - sectors: [{ name: 'General', open: false, @@ -24192,7 +24274,6 @@ module.exports = { open: false, buildProps: ['transition', 'perspective', 'transform'] }] - }, //Configurations for Block Manager @@ -24204,7 +24285,7 @@ module.exports = { }; /***/ }), -/* 64 */ +/* 62 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -24214,12 +24295,12 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var _underscore = __webpack_require__(1); -var deps = [__webpack_require__(65), __webpack_require__(69), __webpack_require__(70), __webpack_require__(73), __webpack_require__(81), __webpack_require__(86), __webpack_require__(89), __webpack_require__(93), __webpack_require__(97), __webpack_require__(109), __webpack_require__(115), __webpack_require__(31), __webpack_require__(132), __webpack_require__(138), __webpack_require__(143), __webpack_require__(150), __webpack_require__(178), __webpack_require__(184), __webpack_require__(210)]; +var deps = [__webpack_require__(63), __webpack_require__(67), __webpack_require__(68), __webpack_require__(71), __webpack_require__(79), __webpack_require__(84), __webpack_require__(87), __webpack_require__(91), __webpack_require__(95), __webpack_require__(107), __webpack_require__(113), __webpack_require__(31), __webpack_require__(130), __webpack_require__(136), __webpack_require__(141), __webpack_require__(148), __webpack_require__(176), __webpack_require__(183), __webpack_require__(209)]; var Backbone = __webpack_require__(0); var timedInterval = void 0; -__webpack_require__(218)({ +__webpack_require__(217)({ Backbone: Backbone, $: Backbone.$ }); @@ -24227,7 +24308,6 @@ __webpack_require__(218)({ var $ = Backbone.$; module.exports = Backbone.Model.extend({ - defaults: { clipboard: null, designerMode: false, @@ -24448,7 +24528,7 @@ module.exports = Backbone.Model.extend({ model = $(el).data('model'); } - if (model && !model.get("selectable")) { + if (model && !model.get('selectable')) { return; } @@ -24520,7 +24600,8 @@ module.exports = Backbone.Model.extend({ var js = config.jsInHtml ? this.getJs() : ''; var wrp = this.get('DomComponents').getComponent(); var html = this.get('CodeManager').getCode(wrp, 'html', { - exportWrapper: exportWrapper, wrappesIsBody: wrappesIsBody + exportWrapper: exportWrapper, + wrappesIsBody: wrappesIsBody }); html += js ? '' : ''; return html; @@ -24544,7 +24625,8 @@ module.exports = Backbone.Model.extend({ var protCss = !avoidProt ? config.protectedCss : ''; return protCss + this.get('CodeManager').getCode(wrp, 'css', { - cssc: cssc, wrappesIsBody: wrappesIsBody + cssc: cssc, + wrappesIsBody: wrappesIsBody }); }, @@ -24745,17 +24827,16 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 65 */ +/* 63 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = function () { - - var Sorter = __webpack_require__(66); - var Resizer = __webpack_require__(67); - var Dragger = __webpack_require__(68); + var Sorter = __webpack_require__(64); + var Resizer = __webpack_require__(65); + var Dragger = __webpack_require__(66); return { /** @@ -24780,7 +24861,7 @@ module.exports = function () { }; /***/ }), -/* 66 */ +/* 64 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -25021,7 +25102,7 @@ module.exports = Backbone.View.extend({ el.className = pfx + 'placeholder'; el.style.display = 'none'; el.style['pointer-events'] = 'none'; - ins.className = pfx + "placeholder-int"; + ins.className = pfx + 'placeholder-int'; el.appendChild(ins); return el; }, @@ -25063,8 +25144,8 @@ module.exports = Backbone.View.extend({ srcModel && srcModel.set && srcModel.set('status', 'freezed'); } - (0, _mixins.on)(container, 'mousemove', this.onMove); - (0, _mixins.on)(docs, 'mouseup', this.endMove); + (0, _mixins.on)(container, 'mousemove dragover', this.onMove); + (0, _mixins.on)(docs, 'mouseup dragend', this.endMove); (0, _mixins.on)(docs, 'keydown', this.rollback); onStart && onStart(); @@ -25099,7 +25180,11 @@ module.exports = Backbone.View.extend({ if (dropContent && em) { if (!dropModel) { var comps = em.get('DomComponents').getComponents(); - var tempModel = comps.add(dropContent, { avoidUpdateStyle: 1, temporary: 1 }); + var tempModel = comps.add(dropContent, { + avoidChildren: 1, + avoidUpdateStyle: 1, + temporary: 1 + }); dropModel = comps.remove(tempModel, { temporary: 1 }); this.dropModel = dropModel instanceof Array ? dropModel[0] : dropModel; } @@ -25233,13 +25318,18 @@ module.exports = Backbone.View.extend({ if ($el.css('float') !== 'none') return; if (parent && $(parent).css('display') == 'flex') return; switch (style.position) { - case 'static':case 'relative':case '': + case 'static': + case 'relative': + case '': break; default: return; } switch (el.tagName) { - case 'TR':case 'TBODY':case 'THEAD':case 'TFOOT': + case 'TR': + case 'TBODY': + case 'THEAD': + case 'TFOOT': return true; } switch ($el.css('display')) { @@ -25599,17 +25689,17 @@ module.exports = Backbone.View.extend({ //If x lefter than center if (posX < xCenter) { xLimit = xCenter; - result.method = "before"; + result.method = 'before'; } else { leftLimit = xCenter; - result.method = "after"; + result.method = 'after'; } } else { // If y upper than center if (posY < yCenter) { - result.method = "before"; + result.method = 'before'; break; - } else result.method = "after"; // After last element + } else result.method = 'after'; // After last element } } return result; @@ -25683,8 +25773,8 @@ module.exports = Backbone.View.extend({ var created; var docs = this.getDocuments(); var container = this.getContainerEl(); - (0, _mixins.off)(container, 'mousemove', this.onMove); - (0, _mixins.off)(docs, 'mouseup', this.endMove); + (0, _mixins.off)(container, 'mousemove dragover', this.onMove); + (0, _mixins.off)(docs, 'mouseup dragend', this.endMove); (0, _mixins.off)(docs, 'keydown', this.rollback); //this.$document.off('mouseup', this.endMove); //this.$document.off('keydown', this.rollback); @@ -25810,7 +25900,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1))) /***/ }), -/* 67 */ +/* 65 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -25892,7 +25982,6 @@ var getBoundingRect = function getBoundingRect(el, win) { }; var Resizer = function () { - /** * Init the Resizer with options * @param {Object} options @@ -26351,7 +26440,7 @@ module.exports = { }; /***/ }), -/* 68 */ +/* 66 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26371,7 +26460,6 @@ var getBoundingRect = function getBoundingRect(el, win) { }; module.exports = { - // TODO move to opts setKey: function setKey(keys, command) { //key(keys, command); @@ -26698,7 +26786,7 @@ module.exports = { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 69 */ +/* 67 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26747,7 +26835,6 @@ module.exports = function () { }; return { - keymaster: keymaster, name: 'Keymaps', @@ -26873,7 +26960,7 @@ module.exports = function () { }; /***/ }), -/* 70 */ +/* 68 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26890,7 +26977,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument */ -var _backboneUndo = __webpack_require__(71); +var _backboneUndo = __webpack_require__(69); var _backboneUndo2 = _interopRequireDefault(_backboneUndo); @@ -26904,7 +26991,6 @@ module.exports = function () { var configDef = {}; return { - name: 'UndoManager', /** @@ -27137,7 +27223,7 @@ module.exports = function () { }; /***/ }), -/* 71 */ +/* 69 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @@ -27154,7 +27240,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ (function (factory) { if (true) { // AMD support - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1), __webpack_require__(72)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1), __webpack_require__(70)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); @@ -27979,7 +28065,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /***/ }), -/* 72 */ +/* 70 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Backbone.js 1.2.1 @@ -29860,7 +29946,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16))) /***/ }), -/* 73 */ +/* 71 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29875,15 +29961,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ */ module.exports = function () { var c = {}, - defaults = __webpack_require__(74), - LocalStorage = __webpack_require__(75), - RemoteStorage = __webpack_require__(76); + defaults = __webpack_require__(72), + LocalStorage = __webpack_require__(73), + RemoteStorage = __webpack_require__(74); var storages = {}; var defaultStorages = {}; return { - /** * Name of the module * @type {String} @@ -30109,7 +30194,7 @@ module.exports = function () { }; /***/ }), -/* 74 */ +/* 72 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30173,11 +30258,10 @@ module.exports = { // true: application/json; charset=utf-8' // false: 'x-www-form-urlencoded' contentTypeJson: false - }; /***/ }), -/* 75 */ +/* 73 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30186,14 +30270,13 @@ module.exports = { var Backbone = __webpack_require__(0); module.exports = Backbone.Model.extend({ - defaults: { checkLocal: true }, /** - * @private - */ + * @private + */ store: function store(data, clb) { this.checkStorageEnvironment(); @@ -30247,7 +30330,7 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 76 */ +/* 74 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30262,7 +30345,6 @@ var _underscore = __webpack_require__(1); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } module.exports = __webpack_require__(0).Model.extend({ - fetch: _fetch2.default, defaults: { @@ -30411,7 +30493,7 @@ module.exports = __webpack_require__(0).Model.extend({ }); /***/ }), -/* 77 */ +/* 75 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(setImmediate) {(function (root) { @@ -30648,10 +30730,10 @@ module.exports = __webpack_require__(0).Model.extend({ })(this); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(78).setImmediate)) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76).setImmediate)) /***/ }), -/* 78 */ +/* 76 */ /***/ (function(module, exports, __webpack_require__) { var apply = Function.prototype.apply; @@ -30704,13 +30786,13 @@ exports._unrefActive = exports.active = function(item) { }; // setimmediate attaches itself to the global object -__webpack_require__(79); +__webpack_require__(77); exports.setImmediate = setImmediate; exports.clearImmediate = clearImmediate; /***/ }), -/* 79 */ +/* 77 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { @@ -30900,10 +30982,10 @@ exports.clearImmediate = clearImmediate; attachTo.clearImmediate = clearImmediate; }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self)); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16), __webpack_require__(80))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16), __webpack_require__(78))) /***/ }), -/* 80 */ +/* 78 */ /***/ (function(module, exports) { // shim for using process in browser @@ -31093,7 +31175,7 @@ process.umask = function() { return 0; }; /***/ }), -/* 81 */ +/* 79 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31110,13 +31192,12 @@ process.umask = function() { return 0; }; */ module.exports = function () { var c = {}, - defaults = __webpack_require__(82), - Devices = __webpack_require__(83), - DevicesView = __webpack_require__(85); + defaults = __webpack_require__(80), + Devices = __webpack_require__(81), + DevicesView = __webpack_require__(83); var devices, view; return { - /** * Name of the module * @type {String} @@ -31214,36 +31295,34 @@ module.exports = function () { }; /***/ }), -/* 82 */ +/* 80 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { - devices: [], deviceLabel: 'Device' - }; /***/ }), -/* 83 */ +/* 81 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var Backbone = __webpack_require__(0); -var Device = __webpack_require__(84); +var Device = __webpack_require__(82); module.exports = Backbone.Collection.extend({ model: Device }); /***/ }), -/* 84 */ +/* 82 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31252,7 +31331,6 @@ module.exports = Backbone.Collection.extend({ var Backbone = __webpack_require__(0); module.exports = Backbone.Model.extend({ - idAttribute: 'name', defaults: { @@ -31277,7 +31355,7 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 85 */ +/* 83 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31286,11 +31364,10 @@ module.exports = Backbone.Model.extend({ var Backbone = __webpack_require__(0); module.exports = Backbone.View.extend({ - template: _.template('\n
<%= deviceLabel %>
\n
\n \n \n \n
\n
\n
\n
\n '), events: { - 'change': 'updateDevice' + change: 'updateDevice' }, initialize: function initialize(o) { @@ -31368,7 +31445,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 86 */ +/* 84 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31376,13 +31453,12 @@ module.exports = Backbone.View.extend({ module.exports = function () { var c = {}, - defaults = __webpack_require__(87), - parserCss = __webpack_require__(88), + defaults = __webpack_require__(85), + parserCss = __webpack_require__(86), parserHtml = __webpack_require__(25); var pHtml, pCss; return { - compTypes: '', /** @@ -31434,20 +31510,18 @@ module.exports = function () { }; /***/ }), -/* 87 */ +/* 85 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { - textTags: ['br', 'b', 'i', 'u', 'a', 'ul', 'ol'] - }; /***/ }), -/* 88 */ +/* 86 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31478,7 +31552,7 @@ module.exports = function (config) { var sel = sels[i].trim(); // Will accept only concatenated classes and last // class might be with state (eg. :hover), nothing else. - if (/^(\.{1}[\w\-]+)+(:{1,2}[\w\-()]+)?$/ig.test(sel)) { + if (/^(\.{1}[\w\-]+)+(:{1,2}[\w\-()]+)?$/gi.test(sel)) { var cls = sel.split('.').filter(Boolean); result.push(cls); } else { @@ -31604,7 +31678,7 @@ module.exports = function (config) { }; /***/ }), -/* 89 */ +/* 87 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31665,14 +31739,13 @@ var _underscore = __webpack_require__(1); module.exports = function (config) { var c = config || {}, - defaults = __webpack_require__(90), + defaults = __webpack_require__(88), Selector = __webpack_require__(7), Selectors = __webpack_require__(10), - ClassTagsView = __webpack_require__(91); + ClassTagsView = __webpack_require__(89); var selectors, selectorTags; return { - Selector: Selector, Selectors: Selectors, @@ -31825,14 +31898,13 @@ module.exports = function (config) { }; /***/ }), -/* 90 */ +/* 88 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { - // Style prefix stylePrefix: 'clm-', @@ -31852,14 +31924,14 @@ module.exports = { }; /***/ }), -/* 91 */ +/* 89 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(_) { var Backbone = __webpack_require__(0); -var ClassTagView = __webpack_require__(92); +var ClassTagView = __webpack_require__(90); module.exports = Backbone.View.extend({ template: _.template('\n
\n
<%= label %>
\n
\n \n
\n \n \n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n \n
\n
\n
<%= selectedLabel %>
\n
\n
\n
'), @@ -32158,7 +32230,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 92 */ +/* 90 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32300,7 +32372,7 @@ module.exports = __webpack_require__(0).View.extend({ }); /***/ }), -/* 93 */ +/* 91 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32324,18 +32396,17 @@ module.exports = __webpack_require__(0).View.extend({ */ module.exports = function () { var c = {}, - defaults = __webpack_require__(94), - ModalM = __webpack_require__(95), - ModalView = __webpack_require__(96); + defaults = __webpack_require__(92), + ModalM = __webpack_require__(93), + ModalView = __webpack_require__(94); var model, modal; return { - /** - * Name of the module - * @type {String} - * @private - */ + * Name of the module + * @type {String} + * @private + */ name: 'Modal', /** @@ -32472,14 +32543,13 @@ module.exports = function () { }; /***/ }), -/* 94 */ +/* 92 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { - stylePrefix: 'mdl-', title: '', @@ -32487,11 +32557,10 @@ module.exports = { content: '', backdrop: true - -};; +}; /***/ }), -/* 95 */ +/* 93 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32508,7 +32577,7 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 96 */ +/* 94 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32646,7 +32715,7 @@ module.exports = __webpack_require__(0).View.extend({ }); /***/ }), -/* 97 */ +/* 95 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32672,15 +32741,14 @@ module.exports = __webpack_require__(0).View.extend({ * @module CodeManager */ module.exports = function () { - var c = {}, - defaults = __webpack_require__(98), - gHtml = __webpack_require__(99), - gCss = __webpack_require__(100), - gJson = __webpack_require__(101), - gJs = __webpack_require__(102), - eCM = __webpack_require__(103), - editorView = __webpack_require__(108); + defaults = __webpack_require__(96), + gHtml = __webpack_require__(97), + gCss = __webpack_require__(98), + gJson = __webpack_require__(99), + gJs = __webpack_require__(100), + eCM = __webpack_require__(101), + editorView = __webpack_require__(106); var generators = {}, defGenerators = {}, @@ -32876,7 +32944,7 @@ module.exports = function () { }; /***/ }), -/* 98 */ +/* 96 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32890,7 +32958,7 @@ module.exports = { }; /***/ }), -/* 99 */ +/* 97 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32920,7 +32988,7 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 100 */ +/* 98 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33053,7 +33121,7 @@ module.exports = __webpack_require__(0).Model.extend({ }); /***/ }), -/* 101 */ +/* 99 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33062,7 +33130,6 @@ module.exports = __webpack_require__(0).Model.extend({ var Backbone = __webpack_require__(0); module.exports = Backbone.Model.extend({ - /** @inheritdoc */ build: function build(model) { var json = model.toJSON(); @@ -33098,7 +33165,7 @@ module.exports = Backbone.Model.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 102 */ +/* 100 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33159,7 +33226,7 @@ module.exports = Backbone.Model.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 103 */ +/* 101 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33169,12 +33236,11 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Backbone = __webpack_require__(0); var CodeMirror = __webpack_require__(6); -var htmlMode = __webpack_require__(104); +var htmlMode = __webpack_require__(102); var cssMode = __webpack_require__(26); -var formatting = __webpack_require__(107); +var formatting = __webpack_require__(105); module.exports = Backbone.Model.extend({ - defaults: { input: '', label: '', @@ -33209,7 +33275,7 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 104 */ +/* 102 */ /***/ (function(module, exports, __webpack_require__) { // CodeMirror, copyright (c) by Marijn Haverbeke and others @@ -33217,7 +33283,7 @@ module.exports = Backbone.Model.extend({ (function(mod) { if (true) // CommonJS - mod(__webpack_require__(6), __webpack_require__(105), __webpack_require__(106), __webpack_require__(26)); + mod(__webpack_require__(6), __webpack_require__(103), __webpack_require__(104), __webpack_require__(26)); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod); else // Plain browser env @@ -33367,7 +33433,7 @@ module.exports = Backbone.Model.extend({ /***/ }), -/* 105 */ +/* 103 */ /***/ (function(module, exports, __webpack_require__) { // CodeMirror, copyright (c) by Marijn Haverbeke and others @@ -33767,7 +33833,7 @@ if (!CodeMirror.mimeModes.hasOwnProperty("text/html")) /***/ }), -/* 106 */ +/* 104 */ /***/ (function(module, exports, __webpack_require__) { // CodeMirror, copyright (c) by Marijn Haverbeke and others @@ -34628,7 +34694,7 @@ CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript /***/ }), -/* 107 */ +/* 105 */ /***/ (function(module, exports, __webpack_require__) { (function(mod) { @@ -34755,7 +34821,7 @@ CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript /***/ }), -/* 108 */ +/* 106 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34764,7 +34830,6 @@ CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript var Backbone = __webpack_require__(0); module.exports = Backbone.View.extend({ - template: _.template('\n
\n \t
<%= label %>
\n \t
\n
'), initialize: function initialize(o) { @@ -34783,7 +34848,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 109 */ +/* 107 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34838,15 +34903,14 @@ module.exports = Backbone.View.extend({ */ module.exports = function () { var c = {}, - defaults = __webpack_require__(110), + defaults = __webpack_require__(108), Panel = __webpack_require__(27), - Panels = __webpack_require__(112), + Panels = __webpack_require__(110), PanelView = __webpack_require__(29), - PanelsView = __webpack_require__(114); + PanelsView = __webpack_require__(112); var panels, PanelsViewObj; return { - /** * Name of the module * @type {String} @@ -34920,9 +34984,9 @@ module.exports = function () { * visible : true, * buttons : [...], * }); - * + * * const newPanel = panelManager.removePanel('myNewPanel'); - * + * */ removePanel: function removePanel(panel) { return panels.remove(panel); @@ -34982,7 +35046,7 @@ module.exports = function () { * Remove button from the panel * @param {string} panelId Panel's ID * @param {Object|Button|String} button Button object or instance of Button or button id - * @return {Button|null} Removed button. + * @return {Button|null} Removed button. * @example * const removedButton = panelManager.removeButton('myNewPanel',{ * id: 'myNewButton', @@ -34991,10 +35055,10 @@ module.exports = function () { * attributes: { title: 'Some title'}, * active: false, * }); - * + * * // It's also possible to use the button id * const removedButton = panelManager.removeButton('myNewPanel','myNewButton'); - * + * */ removeButton: function removeButton(panelId, button) { var pn = this.getPanel(panelId); @@ -35056,12 +35120,11 @@ module.exports = function () { Panel: Panel - }; }; /***/ }), -/* 110 */ +/* 108 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -35146,7 +35209,7 @@ module.exports = { }; /***/ }), -/* 111 */ +/* 109 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -35155,7 +35218,6 @@ module.exports = { var Backbone = __webpack_require__(0); module.exports = Backbone.Model.extend({ - defaults: { id: '', className: '', @@ -35180,7 +35242,7 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 112 */ +/* 110 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -35194,7 +35256,7 @@ module.exports = Backbone.Collection.extend({ }); /***/ }), -/* 113 */ +/* 111 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -35205,7 +35267,6 @@ var _underscore = __webpack_require__(1); var $ = Backbone.$; module.exports = Backbone.View.extend({ - tagName: 'span', initialize: function initialize(o) { @@ -35325,7 +35386,7 @@ module.exports = Backbone.View.extend({ * @return void * */ updateAttributes: function updateAttributes() { - this.$el.attr(this.model.get("attributes")); + this.$el.attr(this.model.get('attributes')); }, @@ -35480,7 +35541,6 @@ module.exports = Backbone.View.extend({ this.toogleActive(); }, toogleActive: function toogleActive() { - if (this.parentM) this.swapParent(); var active = this.model.get('active'); @@ -35532,7 +35592,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1))) /***/ }), -/* 114 */ +/* 112 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -35611,13 +35671,13 @@ module.exports = Backbone.View.extend({ }); /***/ }), -/* 115 */ +/* 113 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var _RichTextEditor = __webpack_require__(116); +var _RichTextEditor = __webpack_require__(114); var _RichTextEditor2 = _interopRequireDefault(_RichTextEditor); @@ -35642,7 +35702,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de */ module.exports = function () { var config = {}; - var defaults = __webpack_require__(117); + var defaults = __webpack_require__(115); var toolbar = void 0, actions = void 0, lastEl = void 0, @@ -35657,7 +35717,6 @@ module.exports = function () { }; return { - customRte: null, /** @@ -35931,7 +35990,7 @@ module.exports = function () { }; /***/ }), -/* 116 */ +/* 114 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36249,14 +36308,13 @@ var RichTextEditor = function () { exports.default = RichTextEditor; /***/ }), -/* 117 */ +/* 115 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { - stylePrefix: 'rte-', // If true, moves the toolbar below the element when the top canvas @@ -36268,7 +36326,7 @@ module.exports = { }; /***/ }), -/* 118 */ +/* 116 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36304,20 +36362,20 @@ module.exports = { }; /***/ }), -/* 119 */ +/* 117 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var Sector = __webpack_require__(120); +var Sector = __webpack_require__(118); module.exports = __webpack_require__(0).Collection.extend({ - model: Sector + model: Sector }); /***/ }), -/* 120 */ +/* 118 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36327,10 +36385,9 @@ var _underscore = __webpack_require__(1); var Backbone = __webpack_require__(0); var Properties = __webpack_require__(11); -var PropertyFactory = __webpack_require__(129); +var PropertyFactory = __webpack_require__(127); module.exports = Backbone.Model.extend({ - defaults: { id: '', name: '', @@ -36418,7 +36475,7 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 121 */ +/* 119 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36427,10 +36484,9 @@ module.exports = Backbone.Model.extend({ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var Property = __webpack_require__(33); -var Layers = __webpack_require__(122); +var Layers = __webpack_require__(120); module.exports = Property.extend({ - defaults: _extends({}, Property.prototype.defaults, { // Array of layers (which contain properties) layers: [], @@ -36452,7 +36508,7 @@ module.exports = Property.extend({ }); /***/ }), -/* 122 */ +/* 120 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36460,10 +36516,9 @@ module.exports = Property.extend({ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var Layer = __webpack_require__(123); +var Layer = __webpack_require__(121); module.exports = Backbone.Collection.extend({ - model: Layer, initialize: function initialize() { @@ -36583,14 +36638,13 @@ module.exports = Backbone.Collection.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 123 */ +/* 121 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(Backbone) { module.exports = Backbone.Model.extend({ - defaults: { index: '', value: '', @@ -36639,7 +36693,7 @@ module.exports = Backbone.Model.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 124 */ +/* 122 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36655,2233 +36709,2224 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol // License: MIT (function (factory) { - factory(Backbone.$); + factory(Backbone.$); })(function ($, undefined) { - "use strict"; + 'use strict'; + + var defaultOpts = { + // Callbacks + beforeShow: noop, + move: noop, + change: noop, + show: noop, + hide: noop, + + // Options + color: false, + flat: false, + showInput: false, + allowEmpty: false, + showButtons: true, + clickoutFiresChange: true, + showInitial: false, + showPalette: false, + showPaletteOnly: false, + hideAfterPaletteSelect: false, + togglePaletteOnly: false, + showSelectionPalette: true, + localStorageKey: false, + appendTo: 'body', + maxSelectionSize: 7, + cancelText: 'cancel', + chooseText: 'choose', + togglePaletteMoreText: 'more', + togglePaletteLessText: 'less', + clearText: 'Clear Color Selection', + noColorSelectedText: 'No Color Selected', + preferredFormat: false, + className: '', // Deprecated - use containerClassName and replacerClassName instead. + containerClassName: '', + replacerClassName: '', + showAlpha: false, + theme: 'sp-light', + palette: [['#ffffff', '#000000', '#ff0000', '#ff8000', '#ffff00', '#008000', '#0000ff', '#4b0082', '#9400d3']], + selectionPalette: [], + disabled: false, + offset: null + }, + spectrums = [], + IE = !!/msie/i.exec(window.navigator.userAgent), + rgbaSupport = function () { + function contains(str, substr) { + return !!~('' + str).indexOf(substr); + } + + var elem = document.createElement('div'); + var style = elem.style; + style.cssText = 'background-color:rgba(0,0,0,.5)'; + return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla'); + }(), + replaceInput = ["
", "
", "
▼
", '
'].join(''), + markup = function () { + // IE does not support gradients with multiple stops, so we need to simulate + // that for the rainbow slider with 8 divs that each have a single gradient + var gradientFix = ''; + if (IE) { + for (var i = 1; i <= 6; i++) { + gradientFix += "
"; + } + } + + return ["
", "
", "
", "
", "", '
', '
', "
", "
", "
", "
", "
", "
", "
", "
", '
', '
', '
', "
", '
', "
", "
", gradientFix, '
', '
', "
", '
', "
", "", '
', "
", "
", "", "", '
', '
', '
'].join(''); + }(); - var defaultOpts = { + function paletteTemplate(p, color, className, opts) { + var html = []; + for (var i = 0; i < p.length; i++) { + var current = p[i]; + if (current) { + var tiny = tinycolor(current); + var c = tiny.toHsl().l < 0.5 ? 'sp-thumb-el sp-thumb-dark' : 'sp-thumb-el sp-thumb-light'; + c += tinycolor.equals(color, current) ? ' sp-thumb-active' : ''; + var formattedString = tiny.toString(opts.preferredFormat || 'rgb'); + var swatchStyle = rgbaSupport ? 'background-color:' + tiny.toRgbString() : 'filter:' + tiny.toFilter(); + html.push(''); + } else { + var cls = 'sp-clear-display'; + html.push($('
').append($('').attr('title', opts.noColorSelectedText)).html()); + } + } + return "
" + html.join('') + '
'; + } - // Callbacks - beforeShow: noop, - move: noop, - change: noop, - show: noop, - hide: noop, + function hideAll() { + for (var i = 0; i < spectrums.length; i++) { + if (spectrums[i]) { + spectrums[i].hide(); + } + } + } - // Options - color: false, - flat: false, - showInput: false, - allowEmpty: false, - showButtons: true, - clickoutFiresChange: true, - showInitial: false, - showPalette: false, - showPaletteOnly: false, - hideAfterPaletteSelect: false, - togglePaletteOnly: false, - showSelectionPalette: true, - localStorageKey: false, - appendTo: "body", - maxSelectionSize: 7, - cancelText: "cancel", - chooseText: "choose", - togglePaletteMoreText: "more", - togglePaletteLessText: "less", - clearText: "Clear Color Selection", - noColorSelectedText: "No Color Selected", - preferredFormat: false, - className: "", // Deprecated - use containerClassName and replacerClassName instead. - containerClassName: "", - replacerClassName: "", - showAlpha: false, - theme: "sp-light", - palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]], - selectionPalette: [], - disabled: false, - offset: null - }, - spectrums = [], - IE = !!/msie/i.exec(window.navigator.userAgent), - rgbaSupport = function () { - function contains(str, substr) { - return !!~('' + str).indexOf(substr); + function instanceOptions(o, callbackContext) { + var opts = $.extend({}, defaultOpts, o); + opts.callbacks = { + move: bind(opts.move, callbackContext), + change: bind(opts.change, callbackContext), + show: bind(opts.show, callbackContext), + hide: bind(opts.hide, callbackContext), + beforeShow: bind(opts.beforeShow, callbackContext) + }; + return opts; + } + + function spectrum(element, o) { + var opts = instanceOptions(o, element), + flat = opts.flat, + showSelectionPalette = opts.showSelectionPalette, + localStorageKey = opts.localStorageKey, + theme = opts.theme, + callbacks = opts.callbacks, + resize = throttle(reflow, 10), + visible = false, + isDragging = false, + dragWidth = 0, + dragHeight = 0, + dragHelperHeight = 0, + slideHeight = 0, + slideWidth = 0, + alphaWidth = 0, + alphaSlideHelperWidth = 0, + slideHelperHeight = 0, + currentHue = 0, + currentSaturation = 0, + currentValue = 0, + currentAlpha = 1, + palette = [], + paletteArray = [], + paletteLookup = {}, + selectionPalette = opts.selectionPalette.slice(0), + maxSelectionSize = opts.maxSelectionSize, + draggingClass = 'sp-dragging', + shiftMovementDirection = null; + + var doc = element.ownerDocument, + body = doc.body, + boundElement = $(element), + disabled = false, + container = $(markup, doc).addClass(theme), + pickerContainer = container.find('.sp-picker-container'), + dragger = container.find('.sp-color'), + dragHelper = container.find('.sp-dragger'), + slider = container.find('.sp-hue'), + slideHelper = container.find('.sp-slider'), + alphaSliderInner = container.find('.sp-alpha-inner'), + alphaSlider = container.find('.sp-alpha'), + alphaSlideHelper = container.find('.sp-alpha-handle'), + textInput = container.find('.sp-input'), + paletteContainer = container.find('.sp-palette'), + initialColorContainer = container.find('.sp-initial'), + cancelButton = container.find('.sp-cancel'), + clearButton = container.find('.sp-clear'), + chooseButton = container.find('.sp-choose'), + toggleButton = container.find('.sp-palette-toggle'), + isInput = boundElement.is('input'), + isInputTypeColor = isInput && boundElement.attr('type') === 'color' && inputTypeColorSupport(), + shouldReplace = isInput && !flat, + replacer = shouldReplace ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]), + offsetElement = shouldReplace ? replacer : boundElement, + previewElement = replacer.find('.sp-preview-inner'), + initialColor = opts.color || isInput && boundElement.val(), + colorOnShow = false, + currentPreferredFormat = opts.preferredFormat, + clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange, + isEmpty = !initialColor, + allowEmpty = opts.allowEmpty && !isInputTypeColor; + + function applyOptions() { + if (opts.showPaletteOnly) { + opts.showPalette = true; + } + + toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText); + + if (opts.palette) { + palette = opts.palette.slice(0); + paletteArray = $.isArray(palette[0]) ? palette : [palette]; + paletteLookup = {}; + for (var i = 0; i < paletteArray.length; i++) { + for (var j = 0; j < paletteArray[i].length; j++) { + var rgb = tinycolor(paletteArray[i][j]).toRgbString(); + paletteLookup[rgb] = true; + } } + } - var elem = document.createElement('div'); - var style = elem.style; - style.cssText = 'background-color:rgba(0,0,0,.5)'; - return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla'); - }(), - replaceInput = ["
", "
", "
▼
", "
"].join(''), - markup = function () { - - // IE does not support gradients with multiple stops, so we need to simulate - // that for the rainbow slider with 8 divs that each have a single gradient - var gradientFix = ""; - if (IE) { - for (var i = 1; i <= 6; i++) { - gradientFix += "
"; - } - } + container.toggleClass('sp-flat', flat); + container.toggleClass('sp-input-disabled', !opts.showInput); + container.toggleClass('sp-alpha-enabled', opts.showAlpha); + container.toggleClass('sp-clear-enabled', allowEmpty); + container.toggleClass('sp-buttons-disabled', !opts.showButtons); + container.toggleClass('sp-palette-buttons-disabled', !opts.togglePaletteOnly); + container.toggleClass('sp-palette-disabled', !opts.showPalette); + container.toggleClass('sp-palette-only', opts.showPaletteOnly); + container.toggleClass('sp-initial-disabled', !opts.showInitial); + container.addClass(opts.className).addClass(opts.containerClassName); - return ["
", "
", "
", "
", "", "
", "
", "
", "
", "
", "
", "
", "
", "
", "
", "
", "
", "
", "
", "
", "
", "
", gradientFix, "
", "
", "
", "
", "
", "", "
", "
", "
", "", "", "
", "
", "
"].join(""); - }(); - - function paletteTemplate(p, color, className, opts) { - var html = []; - for (var i = 0; i < p.length; i++) { - var current = p[i]; - if (current) { - var tiny = tinycolor(current); - var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light"; - c += tinycolor.equals(color, current) ? " sp-thumb-active" : ""; - var formattedString = tiny.toString(opts.preferredFormat || "rgb"); - var swatchStyle = rgbaSupport ? "background-color:" + tiny.toRgbString() : "filter:" + tiny.toFilter(); - html.push(''); - } else { - var cls = 'sp-clear-display'; - html.push($('
').append($('').attr('title', opts.noColorSelectedText)).html()); - } - } - return "
" + html.join('') + "
"; + reflow(); } - function hideAll() { - for (var i = 0; i < spectrums.length; i++) { - if (spectrums[i]) { - spectrums[i].hide(); - } - } - } + function initialize() { + if (IE) { + container.find('*:not(input)').attr('unselectable', 'on'); + } - function instanceOptions(o, callbackContext) { - var opts = $.extend({}, defaultOpts, o); - opts.callbacks = { - 'move': bind(opts.move, callbackContext), - 'change': bind(opts.change, callbackContext), - 'show': bind(opts.show, callbackContext), - 'hide': bind(opts.hide, callbackContext), - 'beforeShow': bind(opts.beforeShow, callbackContext) - }; - return opts; - } - - function spectrum(element, o) { - - var opts = instanceOptions(o, element), - flat = opts.flat, - showSelectionPalette = opts.showSelectionPalette, - localStorageKey = opts.localStorageKey, - theme = opts.theme, - callbacks = opts.callbacks, - resize = throttle(reflow, 10), - visible = false, - isDragging = false, - dragWidth = 0, - dragHeight = 0, - dragHelperHeight = 0, - slideHeight = 0, - slideWidth = 0, - alphaWidth = 0, - alphaSlideHelperWidth = 0, - slideHelperHeight = 0, - currentHue = 0, - currentSaturation = 0, - currentValue = 0, - currentAlpha = 1, - palette = [], - paletteArray = [], - paletteLookup = {}, - selectionPalette = opts.selectionPalette.slice(0), - maxSelectionSize = opts.maxSelectionSize, - draggingClass = "sp-dragging", - shiftMovementDirection = null; - - var doc = element.ownerDocument, - body = doc.body, - boundElement = $(element), - disabled = false, - container = $(markup, doc).addClass(theme), - pickerContainer = container.find(".sp-picker-container"), - dragger = container.find(".sp-color"), - dragHelper = container.find(".sp-dragger"), - slider = container.find(".sp-hue"), - slideHelper = container.find(".sp-slider"), - alphaSliderInner = container.find(".sp-alpha-inner"), - alphaSlider = container.find(".sp-alpha"), - alphaSlideHelper = container.find(".sp-alpha-handle"), - textInput = container.find(".sp-input"), - paletteContainer = container.find(".sp-palette"), - initialColorContainer = container.find(".sp-initial"), - cancelButton = container.find(".sp-cancel"), - clearButton = container.find(".sp-clear"), - chooseButton = container.find(".sp-choose"), - toggleButton = container.find(".sp-palette-toggle"), - isInput = boundElement.is("input"), - isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(), - shouldReplace = isInput && !flat, - replacer = shouldReplace ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]), - offsetElement = shouldReplace ? replacer : boundElement, - previewElement = replacer.find(".sp-preview-inner"), - initialColor = opts.color || isInput && boundElement.val(), - colorOnShow = false, - currentPreferredFormat = opts.preferredFormat, - clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange, - isEmpty = !initialColor, - allowEmpty = opts.allowEmpty && !isInputTypeColor; - - function applyOptions() { - - if (opts.showPaletteOnly) { - opts.showPalette = true; - } + applyOptions(); - toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText); - - if (opts.palette) { - palette = opts.palette.slice(0); - paletteArray = $.isArray(palette[0]) ? palette : [palette]; - paletteLookup = {}; - for (var i = 0; i < paletteArray.length; i++) { - for (var j = 0; j < paletteArray[i].length; j++) { - var rgb = tinycolor(paletteArray[i][j]).toRgbString(); - paletteLookup[rgb] = true; - } - } - } + if (shouldReplace) { + boundElement.after(replacer).hide(); + } - container.toggleClass("sp-flat", flat); - container.toggleClass("sp-input-disabled", !opts.showInput); - container.toggleClass("sp-alpha-enabled", opts.showAlpha); - container.toggleClass("sp-clear-enabled", allowEmpty); - container.toggleClass("sp-buttons-disabled", !opts.showButtons); - container.toggleClass("sp-palette-buttons-disabled", !opts.togglePaletteOnly); - container.toggleClass("sp-palette-disabled", !opts.showPalette); - container.toggleClass("sp-palette-only", opts.showPaletteOnly); - container.toggleClass("sp-initial-disabled", !opts.showInitial); - container.addClass(opts.className).addClass(opts.containerClassName); - - reflow(); - } + if (!allowEmpty) { + clearButton.hide(); + } - function initialize() { + if (flat) { + boundElement.after(container).hide(); + } else { + var appendTo = opts.appendTo === 'parent' ? boundElement.parent() : $(opts.appendTo); + if (appendTo.length !== 1) { + appendTo = $('body'); + } - if (IE) { - container.find("*:not(input)").attr("unselectable", "on"); - } + appendTo.append(container); + } - applyOptions(); + updateSelectionPaletteFromStorage(); - if (shouldReplace) { - boundElement.after(replacer).hide(); - } + offsetElement.bind('click.spectrum touchstart.spectrum', function (e) { + if (!disabled) { + toggle(); + } - if (!allowEmpty) { - clearButton.hide(); - } + e.stopPropagation(); - if (flat) { - boundElement.after(container).hide(); - } else { + if (!$(e.target).is('input')) { + e.preventDefault(); + } + }); - var appendTo = opts.appendTo === "parent" ? boundElement.parent() : $(opts.appendTo); - if (appendTo.length !== 1) { - appendTo = $("body"); - } + if (boundElement.is(':disabled') || opts.disabled === true) { + disable(); + } - appendTo.append(container); - } + // Prevent clicks from bubbling up to document. This would cause it to be hidden. + container.click(stopPropagation); - updateSelectionPaletteFromStorage(); + // Handle user typed input + textInput.change(setFromTextInput); + textInput.bind('paste', function () { + setTimeout(setFromTextInput, 1); + }); + textInput.keydown(function (e) { + if (e.keyCode == 13) { + setFromTextInput(); + } + }); - offsetElement.bind("click.spectrum touchstart.spectrum", function (e) { + cancelButton.text(opts.cancelText); + cancelButton.bind('click.spectrum', function (e) { + e.stopPropagation(); + e.preventDefault(); + revert(); + hide(); + }); - if (!disabled) { - toggle(); - } + clearButton.attr('title', opts.clearText); + clearButton.bind('click.spectrum', function (e) { + e.stopPropagation(); + e.preventDefault(); + isEmpty = true; + move(); - e.stopPropagation(); + if (flat) { + //for the flat style, this is a change event + updateOriginalInput(true); + } + }); - if (!$(e.target).is("input")) { - e.preventDefault(); - } - }); + chooseButton.text(opts.chooseText); + chooseButton.bind('click.spectrum', function (e) { + e.stopPropagation(); + e.preventDefault(); - if (boundElement.is(":disabled") || opts.disabled === true) { - disable(); - } + if (IE && textInput.is(':focus')) { + textInput.trigger('change'); + } - // Prevent clicks from bubbling up to document. This would cause it to be hidden. - container.click(stopPropagation); + if (isValid()) { + updateOriginalInput(true); + hide(); + } + }); - // Handle user typed input - textInput.change(setFromTextInput); - textInput.bind("paste", function () { - setTimeout(setFromTextInput, 1); - }); - textInput.keydown(function (e) { - if (e.keyCode == 13) { - setFromTextInput(); - } - }); + toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText); + toggleButton.bind('click.spectrum', function (e) { + e.stopPropagation(); + e.preventDefault(); - cancelButton.text(opts.cancelText); - cancelButton.bind("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); - revert(); - hide(); - }); + opts.showPaletteOnly = !opts.showPaletteOnly; - clearButton.attr("title", opts.clearText); - clearButton.bind("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); - isEmpty = true; - move(); + // To make sure the Picker area is drawn on the right, next to the + // Palette area (and not below the palette), first move the Palette + // to the left to make space for the picker, plus 5px extra. + // The 'applyOptions' function puts the whole container back into place + // and takes care of the button-text and the sp-palette-only CSS class. + if (!opts.showPaletteOnly && !flat) { + container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5)); + } + applyOptions(); + }); - if (flat) { - //for the flat style, this is a change event - updateOriginalInput(true); - } - }); + draggable(alphaSlider, function (dragX, dragY, e) { + currentAlpha = dragX / alphaWidth; + isEmpty = false; + if (e.shiftKey) { + currentAlpha = Math.round(currentAlpha * 10) / 10; + } - chooseButton.text(opts.chooseText); - chooseButton.bind("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); + move(); + }, dragStart, dragStop); - if (IE && textInput.is(":focus")) { - textInput.trigger('change'); - } + draggable(slider, function (dragX, dragY) { + currentHue = parseFloat(dragY / slideHeight); + isEmpty = false; + if (!opts.showAlpha) { + currentAlpha = 1; + } + move(); + }, dragStart, dragStop); - if (isValid()) { - updateOriginalInput(true); - hide(); - } - }); + draggable(dragger, function (dragX, dragY, e) { + // shift+drag should snap the movement to either the x or y axis. + if (!e.shiftKey) { + shiftMovementDirection = null; + } else if (!shiftMovementDirection) { + var oldDragX = currentSaturation * dragWidth; + var oldDragY = dragHeight - currentValue * dragHeight; + var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY); - toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText); - toggleButton.bind("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); + shiftMovementDirection = furtherFromX ? 'x' : 'y'; + } - opts.showPaletteOnly = !opts.showPaletteOnly; + var setSaturation = !shiftMovementDirection || shiftMovementDirection === 'x'; + var setValue = !shiftMovementDirection || shiftMovementDirection === 'y'; - // To make sure the Picker area is drawn on the right, next to the - // Palette area (and not below the palette), first move the Palette - // to the left to make space for the picker, plus 5px extra. - // The 'applyOptions' function puts the whole container back into place - // and takes care of the button-text and the sp-palette-only CSS class. - if (!opts.showPaletteOnly && !flat) { - container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5)); - } - applyOptions(); - }); + if (setSaturation) { + currentSaturation = parseFloat(dragX / dragWidth); + } + if (setValue) { + currentValue = parseFloat((dragHeight - dragY) / dragHeight); + } - draggable(alphaSlider, function (dragX, dragY, e) { - currentAlpha = dragX / alphaWidth; - isEmpty = false; - if (e.shiftKey) { - currentAlpha = Math.round(currentAlpha * 10) / 10; - } + isEmpty = false; + if (!opts.showAlpha) { + currentAlpha = 1; + } - move(); - }, dragStart, dragStop); + move(); + }, dragStart, dragStop); - draggable(slider, function (dragX, dragY) { - currentHue = parseFloat(dragY / slideHeight); - isEmpty = false; - if (!opts.showAlpha) { - currentAlpha = 1; - } - move(); - }, dragStart, dragStop); + if (!!initialColor) { + _set(initialColor); - draggable(dragger, function (dragX, dragY, e) { + // In case color was black - update the preview UI and set the format + // since the set function will not run (default color is black). + updateUI(); + currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format; - // shift+drag should snap the movement to either the x or y axis. - if (!e.shiftKey) { - shiftMovementDirection = null; - } else if (!shiftMovementDirection) { - var oldDragX = currentSaturation * dragWidth; - var oldDragY = dragHeight - currentValue * dragHeight; - var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY); + addColorToSelectionPalette(initialColor); + } else { + updateUI(); + } - shiftMovementDirection = furtherFromX ? "x" : "y"; - } + if (flat) { + show(); + } - var setSaturation = !shiftMovementDirection || shiftMovementDirection === "x"; - var setValue = !shiftMovementDirection || shiftMovementDirection === "y"; + function paletteElementClick(e) { + if (e.data && e.data.ignore) { + _set($(e.target).closest('.sp-thumb-el').data('color')); + move(); + } else { + _set($(e.target).closest('.sp-thumb-el').data('color')); + move(); + updateOriginalInput(true); + if (opts.hideAfterPaletteSelect) { + hide(); + } + } - if (setSaturation) { - currentSaturation = parseFloat(dragX / dragWidth); - } - if (setValue) { - currentValue = parseFloat((dragHeight - dragY) / dragHeight); - } + return false; + } - isEmpty = false; - if (!opts.showAlpha) { - currentAlpha = 1; - } + var paletteEvent = IE ? 'mousedown.spectrum' : 'click.spectrum touchstart.spectrum'; + paletteContainer.delegate('.sp-thumb-el', paletteEvent, paletteElementClick); + initialColorContainer.delegate('.sp-thumb-el:nth-child(1)', paletteEvent, { ignore: true }, paletteElementClick); + } - move(); - }, dragStart, dragStop); + function updateSelectionPaletteFromStorage() { + if (localStorageKey && window.localStorage) { + // Migrate old palettes over to new format. May want to remove this eventually. + try { + var oldPalette = window.localStorage[localStorageKey].split(',#'); + if (oldPalette.length > 1) { + delete window.localStorage[localStorageKey]; + $.each(oldPalette, function (i, c) { + addColorToSelectionPalette(c); + }); + } + } catch (e) {} - if (!!initialColor) { - _set(initialColor); + try { + selectionPalette = window.localStorage[localStorageKey].split(';'); + } catch (e) {} + } + } - // In case color was black - update the preview UI and set the format - // since the set function will not run (default color is black). - updateUI(); - currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format; + function addColorToSelectionPalette(color) { + if (showSelectionPalette) { + var rgb = tinycolor(color).toRgbString(); + if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) { + selectionPalette.push(rgb); + while (selectionPalette.length > maxSelectionSize) { + selectionPalette.shift(); + } + } - addColorToSelectionPalette(initialColor); - } else { - updateUI(); - } + if (localStorageKey && window.localStorage) { + try { + window.localStorage[localStorageKey] = selectionPalette.join(';'); + } catch (e) {} + } + } + } - if (flat) { - show(); - } + function getUniqueSelectionPalette() { + var unique = []; + if (opts.showPalette) { + for (var i = 0; i < selectionPalette.length; i++) { + var rgb = tinycolor(selectionPalette[i]).toRgbString(); - function paletteElementClick(e) { - if (e.data && e.data.ignore) { - _set($(e.target).closest(".sp-thumb-el").data("color")); - move(); - } else { - _set($(e.target).closest(".sp-thumb-el").data("color")); - move(); - updateOriginalInput(true); - if (opts.hideAfterPaletteSelect) { - hide(); - } - } + if (!paletteLookup[rgb]) { + unique.push(selectionPalette[i]); + } + } + } - return false; - } + return unique.reverse().slice(0, opts.maxSelectionSize); + } - var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum"; - paletteContainer.delegate(".sp-thumb-el", paletteEvent, paletteElementClick); - initialColorContainer.delegate(".sp-thumb-el:nth-child(1)", paletteEvent, { ignore: true }, paletteElementClick); - } + function drawPalette() { + var currentColor = get(); - function updateSelectionPaletteFromStorage() { + var html = $.map(paletteArray, function (palette, i) { + return paletteTemplate(palette, currentColor, 'sp-palette-row sp-palette-row-' + i, opts); + }); - if (localStorageKey && window.localStorage) { + updateSelectionPaletteFromStorage(); - // Migrate old palettes over to new format. May want to remove this eventually. - try { - var oldPalette = window.localStorage[localStorageKey].split(",#"); - if (oldPalette.length > 1) { - delete window.localStorage[localStorageKey]; - $.each(oldPalette, function (i, c) { - addColorToSelectionPalette(c); - }); - } - } catch (e) {} + if (selectionPalette) { + html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, 'sp-palette-row sp-palette-row-selection', opts)); + } - try { - selectionPalette = window.localStorage[localStorageKey].split(";"); - } catch (e) {} - } - } + paletteContainer.html(html.join('')); + } - function addColorToSelectionPalette(color) { - if (showSelectionPalette) { - var rgb = tinycolor(color).toRgbString(); - if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) { - selectionPalette.push(rgb); - while (selectionPalette.length > maxSelectionSize) { - selectionPalette.shift(); - } - } + function drawInitial() { + if (opts.showInitial) { + var initial = colorOnShow; + var current = get(); + initialColorContainer.html(paletteTemplate([initial, current], current, 'sp-palette-row-initial', opts)); + } + } - if (localStorageKey && window.localStorage) { - try { - window.localStorage[localStorageKey] = selectionPalette.join(";"); - } catch (e) {} - } - } - } + function dragStart() { + if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) { + reflow(); + } + isDragging = true; + container.addClass(draggingClass); + shiftMovementDirection = null; + boundElement.trigger('dragstart.spectrum', [get()]); + } - function getUniqueSelectionPalette() { - var unique = []; - if (opts.showPalette) { - for (var i = 0; i < selectionPalette.length; i++) { - var rgb = tinycolor(selectionPalette[i]).toRgbString(); + function dragStop() { + isDragging = false; + container.removeClass(draggingClass); + boundElement.trigger('dragstop.spectrum', [get()]); + } - if (!paletteLookup[rgb]) { - unique.push(selectionPalette[i]); - } - } - } + function setFromTextInput() { + var value = textInput.val(); - return unique.reverse().slice(0, opts.maxSelectionSize); + if ((value === null || value === '') && allowEmpty) { + _set(null); + updateOriginalInput(true); + } else { + var tiny = tinycolor(value); + if (tiny.isValid()) { + _set(tiny); + updateOriginalInput(true); + } else { + textInput.addClass('sp-validation-error'); } + } + } - function drawPalette() { - - var currentColor = get(); + function toggle() { + if (visible) { + hide(); + } else { + show(); + } + } - var html = $.map(paletteArray, function (palette, i) { - return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i, opts); - }); + function show() { + var event = $.Event('beforeShow.spectrum'); - updateSelectionPaletteFromStorage(); + if (visible) { + reflow(); + return; + } - if (selectionPalette) { - html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection", opts)); - } + boundElement.trigger(event, [get()]); - paletteContainer.html(html.join("")); - } + if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) { + return; + } - function drawInitial() { - if (opts.showInitial) { - var initial = colorOnShow; - var current = get(); - initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial", opts)); - } - } + hideAll(); + visible = true; - function dragStart() { - if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) { - reflow(); - } - isDragging = true; - container.addClass(draggingClass); - shiftMovementDirection = null; - boundElement.trigger('dragstart.spectrum', [get()]); - } + var $doc = $(doc); + $doc.bind('keydown.spectrum', onkeydown); + $doc.bind('click.spectrum', clickout); + $(window).bind('resize.spectrum', resize); + replacer.addClass('sp-active'); + container.removeClass('sp-hidden'); - function dragStop() { - isDragging = false; - container.removeClass(draggingClass); - boundElement.trigger('dragstop.spectrum', [get()]); - } + reflow(); + updateUI(); - function setFromTextInput() { + colorOnShow = get(); - var value = textInput.val(); + drawInitial(); + callbacks.show(colorOnShow); + boundElement.trigger('show.spectrum', [colorOnShow]); + } - if ((value === null || value === "") && allowEmpty) { - _set(null); - updateOriginalInput(true); - } else { - var tiny = tinycolor(value); - if (tiny.isValid()) { - _set(tiny); - updateOriginalInput(true); - } else { - textInput.addClass("sp-validation-error"); - } - } - } + function onkeydown(e) { + // Close on ESC + if (e.keyCode === 27) { + hide(); + } + } - function toggle() { - if (visible) { - hide(); - } else { - show(); - } - } + function clickout(e) { + // Return on right click. + if (e.button == 2) { + return; + } - function show() { - var event = $.Event('beforeShow.spectrum'); + // If a drag event was happening during the mouseup, don't hide + // on click. + if (isDragging) { + return; + } - if (visible) { - reflow(); - return; - } + if (clickoutFiresChange) { + updateOriginalInput(true); + } else { + revert(); + } + hide(); + } - boundElement.trigger(event, [get()]); + function hide() { + // Return if hiding is unnecessary + if (!visible || flat) { + return; + } + visible = false; - if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) { - return; - } + $(doc).unbind('keydown.spectrum', onkeydown); + $(doc).unbind('click.spectrum', clickout); + $(window).unbind('resize.spectrum', resize); - hideAll(); - visible = true; + replacer.removeClass('sp-active'); + container.addClass('sp-hidden'); - var $doc = $(doc); - $doc.bind("keydown.spectrum", onkeydown); - $doc.bind("click.spectrum", clickout); - $(window).bind("resize.spectrum", resize); - replacer.addClass("sp-active"); - container.removeClass("sp-hidden"); + callbacks.hide(get()); + boundElement.trigger('hide.spectrum', [get()]); + } - reflow(); - updateUI(); + function revert() { + _set(colorOnShow, true); + } - colorOnShow = get(); + function _set(color, ignoreFormatChange) { + if (tinycolor.equals(color, get())) { + // Update UI just in case a validation error needs + // to be cleared. + updateUI(); + return; + } - drawInitial(); - callbacks.show(colorOnShow); - boundElement.trigger('show.spectrum', [colorOnShow]); - } + var newColor, newHsv; + if (!color && allowEmpty) { + isEmpty = true; + } else { + isEmpty = false; + newColor = tinycolor(color); + newHsv = newColor.toHsv(); - function onkeydown(e) { - // Close on ESC - if (e.keyCode === 27) { - hide(); - } - } + currentHue = newHsv.h % 360 / 360; + currentSaturation = newHsv.s; + currentValue = newHsv.v; + currentAlpha = newHsv.a; + } + updateUI(); - function clickout(e) { - // Return on right click. - if (e.button == 2) { - return; - } + if (newColor && newColor.isValid() && !ignoreFormatChange) { + currentPreferredFormat = opts.preferredFormat || newColor.getFormat(); + } + } - // If a drag event was happening during the mouseup, don't hide - // on click. - if (isDragging) { - return; - } + function get(opts) { + opts = opts || {}; - if (clickoutFiresChange) { - updateOriginalInput(true); - } else { - revert(); - } - hide(); - } + if (allowEmpty && isEmpty) { + return null; + } - function hide() { - // Return if hiding is unnecessary - if (!visible || flat) { - return; - } - visible = false; + return tinycolor.fromRatio({ + h: currentHue, + s: currentSaturation, + v: currentValue, + a: Math.round(currentAlpha * 100) / 100 + }, { format: opts.format || currentPreferredFormat }); + } - $(doc).unbind("keydown.spectrum", onkeydown); - $(doc).unbind("click.spectrum", clickout); - $(window).unbind("resize.spectrum", resize); + function isValid() { + return !textInput.hasClass('sp-validation-error'); + } - replacer.removeClass("sp-active"); - container.addClass("sp-hidden"); + function move() { + updateUI(); - callbacks.hide(get()); - boundElement.trigger('hide.spectrum', [get()]); - } + callbacks.move(get()); + boundElement.trigger('move.spectrum', [get()]); + } - function revert() { - _set(colorOnShow, true); - } + function updateUI() { + textInput.removeClass('sp-validation-error'); - function _set(color, ignoreFormatChange) { - if (tinycolor.equals(color, get())) { - // Update UI just in case a validation error needs - // to be cleared. - updateUI(); - return; - } + updateHelperLocations(); - var newColor, newHsv; - if (!color && allowEmpty) { - isEmpty = true; - } else { - isEmpty = false; - newColor = tinycolor(color); - newHsv = newColor.toHsv(); - - currentHue = newHsv.h % 360 / 360; - currentSaturation = newHsv.s; - currentValue = newHsv.v; - currentAlpha = newHsv.a; - } - updateUI(); + // Update dragger background color (gradients take care of saturation and value). + var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 }); + dragger.css('background-color', flatColor.toHexString()); - if (newColor && newColor.isValid() && !ignoreFormatChange) { - currentPreferredFormat = opts.preferredFormat || newColor.getFormat(); - } + // Get a format that alpha will be included in (hex and names ignore alpha) + var format = currentPreferredFormat; + if (currentAlpha < 1 && !(currentAlpha === 0 && format === 'name')) { + if (format === 'hex' || format === 'hex3' || format === 'hex6' || format === 'name') { + format = 'rgb'; } + } - function get(opts) { - opts = opts || {}; + var realColor = get({ format: format }), + displayColor = ''; - if (allowEmpty && isEmpty) { - return null; - } + //reset background info for preview element + previewElement.removeClass('sp-clear-display'); + previewElement.css('background-color', 'transparent'); - return tinycolor.fromRatio({ - h: currentHue, - s: currentSaturation, - v: currentValue, - a: Math.round(currentAlpha * 100) / 100 - }, { format: opts.format || currentPreferredFormat }); - } + if (!realColor && allowEmpty) { + // Update the replaced elements background with icon indicating no color selection + previewElement.addClass('sp-clear-display'); + } else { + var realHex = realColor.toHexString(), + realRgb = realColor.toRgbString(); - function isValid() { - return !textInput.hasClass("sp-validation-error"); + // Update the replaced elements background color (with actual selected color) + if (rgbaSupport || realColor.alpha === 1) { + previewElement.css('background-color', realRgb); + } else { + previewElement.css('background-color', 'transparent'); + previewElement.css('filter', realColor.toFilter()); } - function move() { - updateUI(); + if (opts.showAlpha) { + var rgb = realColor.toRgb(); + rgb.a = 0; + var realAlpha = tinycolor(rgb).toRgbString(); + var gradient = 'linear-gradient(left, ' + realAlpha + ', ' + realHex + ')'; - callbacks.move(get()); - boundElement.trigger('move.spectrum', [get()]); + if (IE) { + alphaSliderInner.css('filter', tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex)); + } else { + alphaSliderInner.css('background', '-webkit-' + gradient); + alphaSliderInner.css('background', '-moz-' + gradient); + alphaSliderInner.css('background', '-ms-' + gradient); + // Use current syntax gradient on unprefixed property. + alphaSliderInner.css('background', 'linear-gradient(to right, ' + realAlpha + ', ' + realHex + ')'); + } } - function updateUI() { + displayColor = realColor.toString(format); + } - textInput.removeClass("sp-validation-error"); + // Update the text entry input as it changes happen + if (opts.showInput) { + textInput.val(displayColor); + } - updateHelperLocations(); + if (opts.showPalette) { + drawPalette(); + } - // Update dragger background color (gradients take care of saturation and value). - var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 }); - dragger.css("background-color", flatColor.toHexString()); + drawInitial(); + } - // Get a format that alpha will be included in (hex and names ignore alpha) - var format = currentPreferredFormat; - if (currentAlpha < 1 && !(currentAlpha === 0 && format === "name")) { - if (format === "hex" || format === "hex3" || format === "hex6" || format === "name") { - format = "rgb"; - } - } + function updateHelperLocations() { + var s = currentSaturation; + var v = currentValue; - var realColor = get({ format: format }), - displayColor = ''; - - //reset background info for preview element - previewElement.removeClass("sp-clear-display"); - previewElement.css('background-color', 'transparent'); - - if (!realColor && allowEmpty) { - // Update the replaced elements background with icon indicating no color selection - previewElement.addClass("sp-clear-display"); - } else { - var realHex = realColor.toHexString(), - realRgb = realColor.toRgbString(); - - // Update the replaced elements background color (with actual selected color) - if (rgbaSupport || realColor.alpha === 1) { - previewElement.css("background-color", realRgb); - } else { - previewElement.css("background-color", "transparent"); - previewElement.css("filter", realColor.toFilter()); - } + if (allowEmpty && isEmpty) { + //if selected color is empty, hide the helpers + alphaSlideHelper.hide(); + slideHelper.hide(); + dragHelper.hide(); + } else { + //make sure helpers are visible + alphaSlideHelper.show(); + slideHelper.show(); + dragHelper.show(); + + // Where to show the little circle in that displays your current selected color + var dragX = s * dragWidth; + var dragY = dragHeight - v * dragHeight; + dragX = Math.max(-dragHelperHeight, Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)); + dragY = Math.max(-dragHelperHeight, Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)); + dragHelper.css({ + top: dragY + 'px', + left: dragX + 'px' + }); - if (opts.showAlpha) { - var rgb = realColor.toRgb(); - rgb.a = 0; - var realAlpha = tinycolor(rgb).toRgbString(); - var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")"; - - if (IE) { - alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex)); - } else { - alphaSliderInner.css("background", "-webkit-" + gradient); - alphaSliderInner.css("background", "-moz-" + gradient); - alphaSliderInner.css("background", "-ms-" + gradient); - // Use current syntax gradient on unprefixed property. - alphaSliderInner.css("background", "linear-gradient(to right, " + realAlpha + ", " + realHex + ")"); - } - } + var alphaX = currentAlpha * alphaWidth; + alphaSlideHelper.css({ + left: alphaX - alphaSlideHelperWidth / 2 + 'px' + }); - displayColor = realColor.toString(format); - } + // Where to show the bar that displays your current selected hue + var slideY = currentHue * slideHeight; + slideHelper.css({ + top: slideY - slideHelperHeight + 'px' + }); + } + } - // Update the text entry input as it changes happen - if (opts.showInput) { - textInput.val(displayColor); - } + function updateOriginalInput(fireCallback) { + var color = get(), + displayColor = '', + hasChanged = !tinycolor.equals(color, colorOnShow); - if (opts.showPalette) { - drawPalette(); - } + if (color) { + displayColor = color.toString(currentPreferredFormat); + // Update the selection palette with the current color + addColorToSelectionPalette(color); + } - drawInitial(); - } + if (isInput) { + boundElement.val(displayColor); + } - function updateHelperLocations() { - var s = currentSaturation; - var v = currentValue; - - if (allowEmpty && isEmpty) { - //if selected color is empty, hide the helpers - alphaSlideHelper.hide(); - slideHelper.hide(); - dragHelper.hide(); - } else { - //make sure helpers are visible - alphaSlideHelper.show(); - slideHelper.show(); - dragHelper.show(); - - // Where to show the little circle in that displays your current selected color - var dragX = s * dragWidth; - var dragY = dragHeight - v * dragHeight; - dragX = Math.max(-dragHelperHeight, Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)); - dragY = Math.max(-dragHelperHeight, Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)); - dragHelper.css({ - "top": dragY + "px", - "left": dragX + "px" - }); - - var alphaX = currentAlpha * alphaWidth; - alphaSlideHelper.css({ - "left": alphaX - alphaSlideHelperWidth / 2 + "px" - }); - - // Where to show the bar that displays your current selected hue - var slideY = currentHue * slideHeight; - slideHelper.css({ - "top": slideY - slideHelperHeight + "px" - }); - } + if (fireCallback && hasChanged) { + callbacks.change(color); + boundElement.trigger('change', [color]); + } + } + + function reflow() { + if (!visible) { + return; // Calculations would be useless and wouldn't be reliable anyways + } + dragWidth = dragger.width(); + dragHeight = dragger.height(); + dragHelperHeight = dragHelper.height(); + slideWidth = slider.width(); + slideHeight = slider.height(); + slideHelperHeight = slideHelper.height(); + alphaWidth = alphaSlider.width(); + alphaSlideHelperWidth = alphaSlideHelper.width(); + + if (!flat) { + container.css('position', 'absolute'); + if (opts.offset) { + container.offset(opts.offset); + } else { + container.offset(getOffset(container, offsetElement)); } + } - function updateOriginalInput(fireCallback) { - var color = get(), - displayColor = '', - hasChanged = !tinycolor.equals(color, colorOnShow); + updateHelperLocations(); - if (color) { - displayColor = color.toString(currentPreferredFormat); - // Update the selection palette with the current color - addColorToSelectionPalette(color); - } + if (opts.showPalette) { + drawPalette(); + } - if (isInput) { - boundElement.val(displayColor); - } + boundElement.trigger('reflow.spectrum'); + } - if (fireCallback && hasChanged) { - callbacks.change(color); - boundElement.trigger('change', [color]); - } - } + function destroy() { + boundElement.show(); + offsetElement.unbind('click.spectrum touchstart.spectrum'); + container.remove(); + replacer.remove(); + spectrums[spect.id] = null; + } - function reflow() { - if (!visible) { - return; // Calculations would be useless and wouldn't be reliable anyways - } - dragWidth = dragger.width(); - dragHeight = dragger.height(); - dragHelperHeight = dragHelper.height(); - slideWidth = slider.width(); - slideHeight = slider.height(); - slideHelperHeight = slideHelper.height(); - alphaWidth = alphaSlider.width(); - alphaSlideHelperWidth = alphaSlideHelper.width(); - - if (!flat) { - container.css("position", "absolute"); - if (opts.offset) { - container.offset(opts.offset); - } else { - container.offset(getOffset(container, offsetElement)); - } - } + function option(optionName, optionValue) { + if (optionName === undefined) { + return $.extend({}, opts); + } + if (optionValue === undefined) { + return opts[optionName]; + } - updateHelperLocations(); + opts[optionName] = optionValue; - if (opts.showPalette) { - drawPalette(); - } + if (optionName === 'preferredFormat') { + currentPreferredFormat = opts.preferredFormat; + } + applyOptions(); + } - boundElement.trigger('reflow.spectrum'); - } + function enable() { + disabled = false; + boundElement.attr('disabled', false); + offsetElement.removeClass('sp-disabled'); + } - function destroy() { - boundElement.show(); - offsetElement.unbind("click.spectrum touchstart.spectrum"); - container.remove(); - replacer.remove(); - spectrums[spect.id] = null; - } + function disable() { + hide(); + disabled = true; + boundElement.attr('disabled', true); + offsetElement.addClass('sp-disabled'); + } - function option(optionName, optionValue) { - if (optionName === undefined) { - return $.extend({}, opts); - } - if (optionValue === undefined) { - return opts[optionName]; - } + function setOffset(coord) { + opts.offset = coord; + reflow(); + } - opts[optionName] = optionValue; + initialize(); - if (optionName === "preferredFormat") { - currentPreferredFormat = opts.preferredFormat; - } - applyOptions(); - } + var spect = { + show: show, + hide: hide, + toggle: toggle, + reflow: reflow, + option: option, + enable: enable, + disable: disable, + offset: setOffset, + set: function set(c) { + _set(c); + updateOriginalInput(); + }, + get: get, + destroy: destroy, + container: container + }; - function enable() { - disabled = false; - boundElement.attr("disabled", false); - offsetElement.removeClass("sp-disabled"); - } + spect.id = spectrums.push(spect) - 1; - function disable() { - hide(); - disabled = true; - boundElement.attr("disabled", true); - offsetElement.addClass("sp-disabled"); - } + return spect; + } - function setOffset(coord) { - opts.offset = coord; - reflow(); - } + /** + * checkOffset - get the offset below/above and left/right element depending on screen position + * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js + */ + function getOffset(picker, input) { + var extraY = 0; + var dpWidth = picker.outerWidth(); + var dpHeight = picker.outerHeight(); + var inputHeight = input.outerHeight(); + var doc = picker[0].ownerDocument; + var docElem = doc.documentElement; + var cW = docElem.clientWidth; + var cH = docElem.clientHeight; + var scL = $(doc).scrollLeft(); + var scT = $(doc).scrollTop(); + var viewWidth = cW + scL; + var viewHeight = cH + scT; + var offset = input.offset(); - initialize(); - - var spect = { - show: show, - hide: hide, - toggle: toggle, - reflow: reflow, - option: option, - enable: enable, - disable: disable, - offset: setOffset, - set: function set(c) { - _set(c); - updateOriginalInput(); - }, - get: get, - destroy: destroy, - container: container - }; + offset.top += inputHeight; - spect.id = spectrums.push(spect) - 1; + offset.left -= Math.min(offset.left, offset.left + dpWidth > viewWidth && viewWidth > dpWidth ? Math.abs(offset.left + dpWidth - viewWidth) : 0); - return spect; - } + offset.top -= Math.min(offset.top, offset.top + dpHeight > viewHeight && viewHeight > dpHeight ? Math.abs(dpHeight + inputHeight - extraY) : extraY); - /** - * checkOffset - get the offset below/above and left/right element depending on screen position - * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js - */ - function getOffset(picker, input) { - var extraY = 0; - var dpWidth = picker.outerWidth(); - var dpHeight = picker.outerHeight(); - var inputHeight = input.outerHeight(); - var doc = picker[0].ownerDocument; - var docElem = doc.documentElement; - var cW = docElem.clientWidth; - var cH = docElem.clientHeight; - var scL = $(doc).scrollLeft(); - var scT = $(doc).scrollTop(); - var viewWidth = cW + scL; - var viewHeight = cH + scT; - var offset = input.offset(); + return offset; + } - offset.top += inputHeight; + /** + * noop - do nothing + */ + function noop() {} - offset.left -= Math.min(offset.left, offset.left + dpWidth > viewWidth && viewWidth > dpWidth ? Math.abs(offset.left + dpWidth - viewWidth) : 0); + /** + * stopPropagation - makes the code only doing this a little easier to read in line + */ + function stopPropagation(e) { + e.stopPropagation(); + } - offset.top -= Math.min(offset.top, offset.top + dpHeight > viewHeight && viewHeight > dpHeight ? Math.abs(dpHeight + inputHeight - extraY) : extraY); + /** + * Create a function bound to a given object + * Thanks to underscore.js + */ + function bind(func, obj) { + var slice = Array.prototype.slice; + var args = slice.call(arguments, 2); + return function () { + return func.apply(obj, args.concat(slice.call(arguments))); + }; + } - return offset; - } + /** + * Lightweight drag helper. Handles containment within the element, so that + * when dragging, the x is within [0,element.width] and y is within [0,element.height] + */ + function draggable(element, onmove, onstart, onstop) { + onmove = onmove || function () {}; + onstart = onstart || function () {}; + onstop = onstop || function () {}; + var doc = document; + var dragging = false; + var offset = {}; + var maxHeight = 0; + var maxWidth = 0; + var hasTouch = 'ontouchstart' in window; - /** - * noop - do nothing - */ - function noop() {} + var duringDragEvents = {}; + duringDragEvents['selectstart'] = prevent; + duringDragEvents['dragstart'] = prevent; + duringDragEvents['touchmove mousemove'] = move; + duringDragEvents['touchend mouseup'] = stop; - /** - * stopPropagation - makes the code only doing this a little easier to read in line - */ - function stopPropagation(e) { + function prevent(e) { + if (e.stopPropagation) { e.stopPropagation(); + } + if (e.preventDefault) { + e.preventDefault(); + } + e.returnValue = false; } - /** - * Create a function bound to a given object - * Thanks to underscore.js - */ - function bind(func, obj) { - var slice = Array.prototype.slice; - var args = slice.call(arguments, 2); - return function () { - return func.apply(obj, args.concat(slice.call(arguments))); - }; - } - - /** - * Lightweight drag helper. Handles containment within the element, so that - * when dragging, the x is within [0,element.width] and y is within [0,element.height] - */ - function draggable(element, onmove, onstart, onstop) { - onmove = onmove || function () {}; - onstart = onstart || function () {}; - onstop = onstop || function () {}; - var doc = document; - var dragging = false; - var offset = {}; - var maxHeight = 0; - var maxWidth = 0; - var hasTouch = 'ontouchstart' in window; - - var duringDragEvents = {}; - duringDragEvents["selectstart"] = prevent; - duringDragEvents["dragstart"] = prevent; - duringDragEvents["touchmove mousemove"] = move; - duringDragEvents["touchend mouseup"] = stop; - - function prevent(e) { - if (e.stopPropagation) { - e.stopPropagation(); - } - if (e.preventDefault) { - e.preventDefault(); - } - e.returnValue = false; + function move(e) { + if (dragging) { + // Mouseup happened outside of window + if (IE && doc.documentMode < 9 && !e.button) { + return stop(); } - function move(e) { - if (dragging) { - // Mouseup happened outside of window - if (IE && doc.documentMode < 9 && !e.button) { - return stop(); - } - - var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0]; - var pageX = t0 && t0.pageX || e.pageX; - var pageY = t0 && t0.pageY || e.pageY; - - var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth)); - var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight)); + var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0]; + var pageX = t0 && t0.pageX || e.pageX; + var pageY = t0 && t0.pageY || e.pageY; - if (hasTouch) { - // Stop scrolling in iOS - prevent(e); - } + var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth)); + var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight)); - onmove.apply(element, [dragX, dragY, e]); - } + if (hasTouch) { + // Stop scrolling in iOS + prevent(e); } - function start(e) { - var rightclick = e.which ? e.which == 3 : e.button == 2; - - if (!rightclick && !dragging) { - if (onstart.apply(element, arguments) !== false) { - dragging = true; - maxHeight = $(element).height(); - maxWidth = $(element).width(); - offset = $(element).offset(); + onmove.apply(element, [dragX, dragY, e]); + } + } - $(doc).bind(duringDragEvents); - $(doc.body).addClass("sp-dragging"); + function start(e) { + var rightclick = e.which ? e.which == 3 : e.button == 2; - move(e); + if (!rightclick && !dragging) { + if (onstart.apply(element, arguments) !== false) { + dragging = true; + maxHeight = $(element).height(); + maxWidth = $(element).width(); + offset = $(element).offset(); - prevent(e); - } - } - } + $(doc).bind(duringDragEvents); + $(doc.body).addClass('sp-dragging'); - function stop() { - if (dragging) { - $(doc).unbind(duringDragEvents); - $(doc.body).removeClass("sp-dragging"); + move(e); - // Wait a tick before notifying observers to allow the click event - // to fire in Chrome. - setTimeout(function () { - onstop.apply(element, arguments); - }, 0); - } - dragging = false; + prevent(e); } - - $(element).bind("touchstart mousedown", start); + } } - function throttle(func, wait, debounce) { - var timeout; - return function () { - var context = this, - args = arguments; - var throttler = function throttler() { - timeout = null; - func.apply(context, args); - }; - if (debounce) clearTimeout(timeout); - if (debounce || !timeout) timeout = setTimeout(throttler, wait); - }; - } + function stop() { + if (dragging) { + $(doc).unbind(duringDragEvents); + $(doc.body).removeClass('sp-dragging'); - function inputTypeColorSupport() { - return $.fn.spectrum.inputTypeColorSupport(); + // Wait a tick before notifying observers to allow the click event + // to fire in Chrome. + setTimeout(function () { + onstop.apply(element, arguments); + }, 0); + } + dragging = false; } - /** - * Define a jQuery plugin - */ - var dataID = "spectrum.id"; - $.fn.spectrum = function (opts, extra) { - - if (typeof opts == "string") { - - var returnValue = this; - var args = Array.prototype.slice.call(arguments, 1); - - this.each(function () { - var spect = spectrums[$(this).data(dataID)]; - if (spect) { - var method = spect[opts]; - if (!method) { - throw new Error("Spectrum: no such method: '" + opts + "'"); - } - - if (opts == "get") { - returnValue = spect.get(); - } else if (opts == "container") { - returnValue = spect.container; - } else if (opts == "option") { - returnValue = spect.option.apply(spect, args); - } else if (opts == "destroy") { - spect.destroy(); - $(this).removeData(dataID); - } else { - method.apply(spect, args); - } - } - }); - - return returnValue; - } + $(element).bind('touchstart mousedown', start); + } - // Initializing a new instance of spectrum - return this.spectrum("destroy").each(function () { - var options = $.extend({}, opts, $(this).data()); - var spect = spectrum(this, options); - $(this).data(dataID, spect.id); - }); + function throttle(func, wait, debounce) { + var timeout; + return function () { + var context = this, + args = arguments; + var throttler = function throttler() { + timeout = null; + func.apply(context, args); + }; + if (debounce) clearTimeout(timeout); + if (debounce || !timeout) timeout = setTimeout(throttler, wait); }; + } - $.fn.spectrum.load = true; - $.fn.spectrum.loadOpts = {}; - $.fn.spectrum.draggable = draggable; - $.fn.spectrum.defaults = defaultOpts; - $.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() { - if (typeof inputTypeColorSupport._cachedResult === "undefined") { - var colorInput = $("")[0]; // if color element is supported, value will default to not null - inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== ""; - } - return inputTypeColorSupport._cachedResult; - }; + function inputTypeColorSupport() { + return $.fn.spectrum.inputTypeColorSupport(); + } - $.spectrum = {}; - $.spectrum.localization = {}; - $.spectrum.palettes = {}; + /** + * Define a jQuery plugin + */ + var dataID = 'spectrum.id'; + $.fn.spectrum = function (opts, extra) { + if (typeof opts == 'string') { + var returnValue = this; + var args = Array.prototype.slice.call(arguments, 1); - $.fn.spectrum.processNativeColorInputs = function () { - var colorInputs = $("input[type=color]"); - if (colorInputs.length && !inputTypeColorSupport()) { - colorInputs.spectrum({ - preferredFormat: "hex6" - }); - } - }; + this.each(function () { + var spect = spectrums[$(this).data(dataID)]; + if (spect) { + var method = spect[opts]; + if (!method) { + throw new Error("Spectrum: no such method: '" + opts + "'"); + } - // TinyColor v1.1.2 - // https://github.com/bgrins/TinyColor - // Brian Grinstead, MIT License + if (opts == 'get') { + returnValue = spect.get(); + } else if (opts == 'container') { + returnValue = spect.container; + } else if (opts == 'option') { + returnValue = spect.option.apply(spect, args); + } else if (opts == 'destroy') { + spect.destroy(); + $(this).removeData(dataID); + } else { + method.apply(spect, args); + } + } + }); - //(function() { + return returnValue; + } - var trimLeft = /^[\s,#]+/, - trimRight = /\s+$/, - tinyCounter = 0, - math = Math, - mathRound = math.round, - mathMin = math.min, - mathMax = math.max, - mathRandom = math.random; + // Initializing a new instance of spectrum + return this.spectrum('destroy').each(function () { + var options = $.extend({}, opts, $(this).data()); + var spect = spectrum(this, options); + $(this).data(dataID, spect.id); + }); + }; - var tinycolor = function tinycolor(color, opts) { + $.fn.spectrum.load = true; + $.fn.spectrum.loadOpts = {}; + $.fn.spectrum.draggable = draggable; + $.fn.spectrum.defaults = defaultOpts; + $.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() { + if (typeof inputTypeColorSupport._cachedResult === 'undefined') { + var colorInput = $("")[0]; // if color element is supported, value will default to not null + inputTypeColorSupport._cachedResult = colorInput.type === 'color' && colorInput.value !== ''; + } + return inputTypeColorSupport._cachedResult; + }; - color = color ? color : ''; - opts = opts || {}; + $.spectrum = {}; + $.spectrum.localization = {}; + $.spectrum.palettes = {}; - // If input is already a tinycolor, return itself - if (color instanceof tinycolor) { - return color; - } - // If we are called as a function, call using new instead - if (!(this instanceof tinycolor)) { - return new tinycolor(color, opts); - } + $.fn.spectrum.processNativeColorInputs = function () { + var colorInputs = $('input[type=color]'); + if (colorInputs.length && !inputTypeColorSupport()) { + colorInputs.spectrum({ + preferredFormat: 'hex6' + }); + } + }; - var rgb = inputToRGB(color); - this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = mathRound(100 * this._a) / 100, this._format = opts.format || rgb.format; - this._gradientType = opts.gradientType; + // TinyColor v1.1.2 + // https://github.com/bgrins/TinyColor + // Brian Grinstead, MIT License - // Don't let the range of [0,255] come back in [0,1]. - // Potentially lose a little bit of precision here, but will fix issues where - // .5 gets interpreted as half of the total, instead of half of 1 - // If it was supposed to be 128, this was already taken care of by `inputToRgb` - if (this._r < 1) { - this._r = mathRound(this._r); - } - if (this._g < 1) { - this._g = mathRound(this._g); - } - if (this._b < 1) { - this._b = mathRound(this._b); - } + //(function() { - this._ok = rgb.ok; - this._tc_id = tinyCounter++; - }; + var trimLeft = /^[\s,#]+/, + trimRight = /\s+$/, + tinyCounter = 0, + math = Math, + mathRound = math.round, + mathMin = math.min, + mathMax = math.max, + mathRandom = math.random; - tinycolor.prototype = { - isDark: function isDark() { - return this.getBrightness() < 128; - }, - isLight: function isLight() { - return !this.isDark(); - }, - isValid: function isValid() { - return this._ok; - }, - getOriginalInput: function getOriginalInput() { - return this._originalInput; - }, - getFormat: function getFormat() { - return this._format; - }, - getAlpha: function getAlpha() { - return this._a; - }, - getBrightness: function getBrightness() { - var rgb = this.toRgb(); - return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; - }, - setAlpha: function setAlpha(value) { - this._a = boundAlpha(value); - this._roundA = mathRound(100 * this._a) / 100; - return this; - }, - toHsv: function toHsv() { - var hsv = rgbToHsv(this._r, this._g, this._b); - return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; - }, - toHsvString: function toHsvString() { - var hsv = rgbToHsv(this._r, this._g, this._b); - var h = mathRound(hsv.h * 360), - s = mathRound(hsv.s * 100), - v = mathRound(hsv.v * 100); - return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")"; - }, - toHsl: function toHsl() { - var hsl = rgbToHsl(this._r, this._g, this._b); - return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; - }, - toHslString: function toHslString() { - var hsl = rgbToHsl(this._r, this._g, this._b); - var h = mathRound(hsl.h * 360), - s = mathRound(hsl.s * 100), - l = mathRound(hsl.l * 100); - return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")"; - }, - toHex: function toHex(allow3Char) { - return rgbToHex(this._r, this._g, this._b, allow3Char); - }, - toHexString: function toHexString(allow3Char) { - return '#' + this.toHex(allow3Char); - }, - toHex8: function toHex8() { - return rgbaToHex(this._r, this._g, this._b, this._a); - }, - toHex8String: function toHex8String() { - return '#' + this.toHex8(); - }, - toRgb: function toRgb() { - return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; - }, - toRgbString: function toRgbString() { - return this._a == 1 ? "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; - }, - toPercentageRgb: function toPercentageRgb() { - return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a }; - }, - toPercentageRgbString: function toPercentageRgbString() { - return this._a == 1 ? "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; - }, - toName: function toName() { - if (this._a === 0) { - return "transparent"; - } + var tinycolor = function tinycolor(color, opts) { + color = color ? color : ''; + opts = opts || {}; - if (this._a < 1) { - return false; - } + // If input is already a tinycolor, return itself + if (color instanceof tinycolor) { + return color; + } + // If we are called as a function, call using new instead + if (!(this instanceof tinycolor)) { + return new tinycolor(color, opts); + } - return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; - }, - toFilter: function toFilter(secondColor) { - var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a); - var secondHex8String = hex8String; - var gradientType = this._gradientType ? "GradientType = 1, " : ""; - - if (secondColor) { - var s = tinycolor(secondColor); - secondHex8String = s.toHex8String(); - } + var rgb = inputToRGB(color); + this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = mathRound(100 * this._a) / 100, this._format = opts.format || rgb.format; + this._gradientType = opts.gradientType; - return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")"; - }, - toString: function toString(format) { - var formatSet = !!format; - format = format || this._format; - - var formattedString = false; - var hasAlpha = this._a < 1 && this._a >= 0; - var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name"); - - if (needsAlphaFormat) { - // Special case for "transparent", all other non-alpha formats - // will return rgba when there is transparency. - if (format === "name" && this._a === 0) { - return this.toName(); - } - return this.toRgbString(); - } - if (format === "rgb") { - formattedString = this.toRgbString(); - } - if (format === "prgb") { - formattedString = this.toPercentageRgbString(); - } - if (format === "hex" || format === "hex6") { - formattedString = this.toHexString(); - } - if (format === "hex3") { - formattedString = this.toHexString(true); - } - if (format === "hex8") { - formattedString = this.toHex8String(); - } - if (format === "name") { - formattedString = this.toName(); - } - if (format === "hsl") { - formattedString = this.toHslString(); - } - if (format === "hsv") { - formattedString = this.toHsvString(); - } + // Don't let the range of [0,255] come back in [0,1]. + // Potentially lose a little bit of precision here, but will fix issues where + // .5 gets interpreted as half of the total, instead of half of 1 + // If it was supposed to be 128, this was already taken care of by `inputToRgb` + if (this._r < 1) { + this._r = mathRound(this._r); + } + if (this._g < 1) { + this._g = mathRound(this._g); + } + if (this._b < 1) { + this._b = mathRound(this._b); + } - return formattedString || this.toHexString(); - }, + this._ok = rgb.ok; + this._tc_id = tinyCounter++; + }; - _applyModification: function _applyModification(fn, args) { - var color = fn.apply(null, [this].concat([].slice.call(args))); - this._r = color._r; - this._g = color._g; - this._b = color._b; - this.setAlpha(color._a); - return this; - }, - lighten: function lighten() { - return this._applyModification(_lighten, arguments); - }, - brighten: function brighten() { - return this._applyModification(_brighten, arguments); - }, - darken: function darken() { - return this._applyModification(_darken, arguments); - }, - desaturate: function desaturate() { - return this._applyModification(_desaturate, arguments); - }, - saturate: function saturate() { - return this._applyModification(_saturate, arguments); - }, - greyscale: function greyscale() { - return this._applyModification(_greyscale, arguments); - }, - spin: function spin() { - return this._applyModification(_spin, arguments); - }, + tinycolor.prototype = { + isDark: function isDark() { + return this.getBrightness() < 128; + }, + isLight: function isLight() { + return !this.isDark(); + }, + isValid: function isValid() { + return this._ok; + }, + getOriginalInput: function getOriginalInput() { + return this._originalInput; + }, + getFormat: function getFormat() { + return this._format; + }, + getAlpha: function getAlpha() { + return this._a; + }, + getBrightness: function getBrightness() { + var rgb = this.toRgb(); + return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; + }, + setAlpha: function setAlpha(value) { + this._a = boundAlpha(value); + this._roundA = mathRound(100 * this._a) / 100; + return this; + }, + toHsv: function toHsv() { + var hsv = rgbToHsv(this._r, this._g, this._b); + return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; + }, + toHsvString: function toHsvString() { + var hsv = rgbToHsv(this._r, this._g, this._b); + var h = mathRound(hsv.h * 360), + s = mathRound(hsv.s * 100), + v = mathRound(hsv.v * 100); + return this._a == 1 ? 'hsv(' + h + ', ' + s + '%, ' + v + '%)' : 'hsva(' + h + ', ' + s + '%, ' + v + '%, ' + this._roundA + ')'; + }, + toHsl: function toHsl() { + var hsl = rgbToHsl(this._r, this._g, this._b); + return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; + }, + toHslString: function toHslString() { + var hsl = rgbToHsl(this._r, this._g, this._b); + var h = mathRound(hsl.h * 360), + s = mathRound(hsl.s * 100), + l = mathRound(hsl.l * 100); + return this._a == 1 ? 'hsl(' + h + ', ' + s + '%, ' + l + '%)' : 'hsla(' + h + ', ' + s + '%, ' + l + '%, ' + this._roundA + ')'; + }, + toHex: function toHex(allow3Char) { + return rgbToHex(this._r, this._g, this._b, allow3Char); + }, + toHexString: function toHexString(allow3Char) { + return '#' + this.toHex(allow3Char); + }, + toHex8: function toHex8() { + return rgbaToHex(this._r, this._g, this._b, this._a); + }, + toHex8String: function toHex8String() { + return '#' + this.toHex8(); + }, + toRgb: function toRgb() { + return { + r: mathRound(this._r), + g: mathRound(this._g), + b: mathRound(this._b), + a: this._a + }; + }, + toRgbString: function toRgbString() { + return this._a == 1 ? 'rgb(' + mathRound(this._r) + ', ' + mathRound(this._g) + ', ' + mathRound(this._b) + ')' : 'rgba(' + mathRound(this._r) + ', ' + mathRound(this._g) + ', ' + mathRound(this._b) + ', ' + this._roundA + ')'; + }, + toPercentageRgb: function toPercentageRgb() { + return { + r: mathRound(bound01(this._r, 255) * 100) + '%', + g: mathRound(bound01(this._g, 255) * 100) + '%', + b: mathRound(bound01(this._b, 255) * 100) + '%', + a: this._a + }; + }, + toPercentageRgbString: function toPercentageRgbString() { + return this._a == 1 ? 'rgb(' + mathRound(bound01(this._r, 255) * 100) + '%, ' + mathRound(bound01(this._g, 255) * 100) + '%, ' + mathRound(bound01(this._b, 255) * 100) + '%)' : 'rgba(' + mathRound(bound01(this._r, 255) * 100) + '%, ' + mathRound(bound01(this._g, 255) * 100) + '%, ' + mathRound(bound01(this._b, 255) * 100) + '%, ' + this._roundA + ')'; + }, + toName: function toName() { + if (this._a === 0) { + return 'transparent'; + } - _applyCombination: function _applyCombination(fn, args) { - return fn.apply(null, [this].concat([].slice.call(args))); - }, - analogous: function analogous() { - return this._applyCombination(_analogous, arguments); - }, - complement: function complement() { - return this._applyCombination(_complement, arguments); - }, - monochromatic: function monochromatic() { - return this._applyCombination(_monochromatic, arguments); - }, - splitcomplement: function splitcomplement() { - return this._applyCombination(_splitcomplement, arguments); - }, - triad: function triad() { - return this._applyCombination(_triad, arguments); - }, - tetrad: function tetrad() { - return this._applyCombination(_tetrad, arguments); - } - }; + if (this._a < 1) { + return false; + } - // If input is an object, force 1 into "1.0" to handle ratios properly - // String input requires "1.0" as input, so 1 will be treated as 1 - tinycolor.fromRatio = function (color, opts) { - if ((typeof color === "undefined" ? "undefined" : _typeof(color)) == "object") { - var newColor = {}; - for (var i in color) { - if (color.hasOwnProperty(i)) { - if (i === "a") { - newColor[i] = color[i]; - } else { - newColor[i] = convertToPercentage(color[i]); - } - } - } - color = newColor; - } + return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; + }, + toFilter: function toFilter(secondColor) { + var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a); + var secondHex8String = hex8String; + var gradientType = this._gradientType ? 'GradientType = 1, ' : ''; - return tinycolor(color, opts); - }; + if (secondColor) { + var s = tinycolor(secondColor); + secondHex8String = s.toHex8String(); + } - // Given a string or object, convert that input to RGB - // Possible string inputs: - // - // "red" - // "#f00" or "f00" - // "#ff0000" or "ff0000" - // "#ff000000" or "ff000000" - // "rgb 255 0 0" or "rgb (255, 0, 0)" - // "rgb 1.0 0 0" or "rgb (1, 0, 0)" - // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" - // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" - // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" - // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" - // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" - // - function inputToRGB(color) { + return 'progid:DXImageTransform.Microsoft.gradient(' + gradientType + 'startColorstr=' + hex8String + ',endColorstr=' + secondHex8String + ')'; + }, + toString: function toString(format) { + var formatSet = !!format; + format = format || this._format; - var rgb = { r: 0, g: 0, b: 0 }; - var a = 1; - var ok = false; - var format = false; + var formattedString = false; + var hasAlpha = this._a < 1 && this._a >= 0; + var needsAlphaFormat = !formatSet && hasAlpha && (format === 'hex' || format === 'hex6' || format === 'hex3' || format === 'name'); - if (typeof color == "string") { - color = stringInputToObject(color); + if (needsAlphaFormat) { + // Special case for "transparent", all other non-alpha formats + // will return rgba when there is transparency. + if (format === 'name' && this._a === 0) { + return this.toName(); } + return this.toRgbString(); + } + if (format === 'rgb') { + formattedString = this.toRgbString(); + } + if (format === 'prgb') { + formattedString = this.toPercentageRgbString(); + } + if (format === 'hex' || format === 'hex6') { + formattedString = this.toHexString(); + } + if (format === 'hex3') { + formattedString = this.toHexString(true); + } + if (format === 'hex8') { + formattedString = this.toHex8String(); + } + if (format === 'name') { + formattedString = this.toName(); + } + if (format === 'hsl') { + formattedString = this.toHslString(); + } + if (format === 'hsv') { + formattedString = this.toHsvString(); + } - if ((typeof color === "undefined" ? "undefined" : _typeof(color)) == "object") { - if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) { - rgb = rgbToRgb(color.r, color.g, color.b); - ok = true; - format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; - } else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) { - color.s = convertToPercentage(color.s); - color.v = convertToPercentage(color.v); - rgb = hsvToRgb(color.h, color.s, color.v); - ok = true; - format = "hsv"; - } else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) { - color.s = convertToPercentage(color.s); - color.l = convertToPercentage(color.l); - rgb = hslToRgb(color.h, color.s, color.l); - ok = true; - format = "hsl"; - } + return formattedString || this.toHexString(); + }, - if (color.hasOwnProperty("a")) { - a = color.a; - } - } + _applyModification: function _applyModification(fn, args) { + var color = fn.apply(null, [this].concat([].slice.call(args))); + this._r = color._r; + this._g = color._g; + this._b = color._b; + this.setAlpha(color._a); + return this; + }, + lighten: function lighten() { + return this._applyModification(_lighten, arguments); + }, + brighten: function brighten() { + return this._applyModification(_brighten, arguments); + }, + darken: function darken() { + return this._applyModification(_darken, arguments); + }, + desaturate: function desaturate() { + return this._applyModification(_desaturate, arguments); + }, + saturate: function saturate() { + return this._applyModification(_saturate, arguments); + }, + greyscale: function greyscale() { + return this._applyModification(_greyscale, arguments); + }, + spin: function spin() { + return this._applyModification(_spin, arguments); + }, - a = boundAlpha(a); + _applyCombination: function _applyCombination(fn, args) { + return fn.apply(null, [this].concat([].slice.call(args))); + }, + analogous: function analogous() { + return this._applyCombination(_analogous, arguments); + }, + complement: function complement() { + return this._applyCombination(_complement, arguments); + }, + monochromatic: function monochromatic() { + return this._applyCombination(_monochromatic, arguments); + }, + splitcomplement: function splitcomplement() { + return this._applyCombination(_splitcomplement, arguments); + }, + triad: function triad() { + return this._applyCombination(_triad, arguments); + }, + tetrad: function tetrad() { + return this._applyCombination(_tetrad, arguments); + } + }; - return { - ok: ok, - format: color.format || format, - r: mathMin(255, mathMax(rgb.r, 0)), - g: mathMin(255, mathMax(rgb.g, 0)), - b: mathMin(255, mathMax(rgb.b, 0)), - a: a - }; + // If input is an object, force 1 into "1.0" to handle ratios properly + // String input requires "1.0" as input, so 1 will be treated as 1 + tinycolor.fromRatio = function (color, opts) { + if ((typeof color === 'undefined' ? 'undefined' : _typeof(color)) == 'object') { + var newColor = {}; + for (var i in color) { + if (color.hasOwnProperty(i)) { + if (i === 'a') { + newColor[i] = color[i]; + } else { + newColor[i] = convertToPercentage(color[i]); + } + } + } + color = newColor; } - // Conversion Functions - // -------------------- + return tinycolor(color, opts); + }; - // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: - // + // Given a string or object, convert that input to RGB + // Possible string inputs: + // + // "red" + // "#f00" or "f00" + // "#ff0000" or "ff0000" + // "#ff000000" or "ff000000" + // "rgb 255 0 0" or "rgb (255, 0, 0)" + // "rgb 1.0 0 0" or "rgb (1, 0, 0)" + // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" + // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" + // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" + // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" + // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" + // + function inputToRGB(color) { + var rgb = { r: 0, g: 0, b: 0 }; + var a = 1; + var ok = false; + var format = false; - // `rgbToRgb` - // Handle bounds / percentage checking to conform to CSS color spec - // - // *Assumes:* r, g, b in [0, 255] or [0, 1] - // *Returns:* { r, g, b } in [0, 255] - function rgbToRgb(r, g, b) { - return { - r: bound01(r, 255) * 255, - g: bound01(g, 255) * 255, - b: bound01(b, 255) * 255 - }; + if (typeof color == 'string') { + color = stringInputToObject(color); } - // `rgbToHsl` - // Converts an RGB color value to HSL. - // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] - // *Returns:* { h, s, l } in [0,1] - function rgbToHsl(r, g, b) { + if ((typeof color === 'undefined' ? 'undefined' : _typeof(color)) == 'object') { + if (color.hasOwnProperty('r') && color.hasOwnProperty('g') && color.hasOwnProperty('b')) { + rgb = rgbToRgb(color.r, color.g, color.b); + ok = true; + format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb'; + } else if (color.hasOwnProperty('h') && color.hasOwnProperty('s') && color.hasOwnProperty('v')) { + color.s = convertToPercentage(color.s); + color.v = convertToPercentage(color.v); + rgb = hsvToRgb(color.h, color.s, color.v); + ok = true; + format = 'hsv'; + } else if (color.hasOwnProperty('h') && color.hasOwnProperty('s') && color.hasOwnProperty('l')) { + color.s = convertToPercentage(color.s); + color.l = convertToPercentage(color.l); + rgb = hslToRgb(color.h, color.s, color.l); + ok = true; + format = 'hsl'; + } - r = bound01(r, 255); - g = bound01(g, 255); - b = bound01(b, 255); + if (color.hasOwnProperty('a')) { + a = color.a; + } + } - var max = mathMax(r, g, b), - min = mathMin(r, g, b); - var h, - s, - l = (max + min) / 2; + a = boundAlpha(a); - if (max == min) { - h = s = 0; // achromatic - } else { - var d = max - min; - s = l > 0.5 ? d / (2 - max - min) : d / (max + min); - switch (max) { - case r: - h = (g - b) / d + (g < b ? 6 : 0);break; - case g: - h = (b - r) / d + 2;break; - case b: - h = (r - g) / d + 4;break; - } + return { + ok: ok, + format: color.format || format, + r: mathMin(255, mathMax(rgb.r, 0)), + g: mathMin(255, mathMax(rgb.g, 0)), + b: mathMin(255, mathMax(rgb.b, 0)), + a: a + }; + } - h /= 6; - } + // Conversion Functions + // -------------------- - return { h: h, s: s, l: l }; - } + // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: + // - // `hslToRgb` - // Converts an HSL color value to RGB. - // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] - // *Returns:* { r, g, b } in the set [0, 255] - function hslToRgb(h, s, l) { - var r, g, b; + // `rgbToRgb` + // Handle bounds / percentage checking to conform to CSS color spec + // + // *Assumes:* r, g, b in [0, 255] or [0, 1] + // *Returns:* { r, g, b } in [0, 255] + function rgbToRgb(r, g, b) { + return { + r: bound01(r, 255) * 255, + g: bound01(g, 255) * 255, + b: bound01(b, 255) * 255 + }; + } - h = bound01(h, 360); - s = bound01(s, 100); - l = bound01(l, 100); + // `rgbToHsl` + // Converts an RGB color value to HSL. + // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] + // *Returns:* { h, s, l } in [0,1] + function rgbToHsl(r, g, b) { + r = bound01(r, 255); + g = bound01(g, 255); + b = bound01(b, 255); - function hue2rgb(p, q, t) { - if (t < 0) t += 1; - if (t > 1) t -= 1; - if (t < 1 / 6) return p + (q - p) * 6 * t; - if (t < 1 / 2) return q; - if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; - return p; - } + var max = mathMax(r, g, b), + min = mathMin(r, g, b); + var h, + s, + l = (max + min) / 2; - if (s === 0) { - r = g = b = l; // achromatic - } else { - var q = l < 0.5 ? l * (1 + s) : l + s - l * s; - var p = 2 * l - q; - r = hue2rgb(p, q, h + 1 / 3); - g = hue2rgb(p, q, h); - b = hue2rgb(p, q, h - 1 / 3); - } + if (max == min) { + h = s = 0; // achromatic + } else { + var d = max - min; + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + switch (max) { + case r: + h = (g - b) / d + (g < b ? 6 : 0); + break; + case g: + h = (b - r) / d + 2; + break; + case b: + h = (r - g) / d + 4; + break; + } - return { r: r * 255, g: g * 255, b: b * 255 }; + h /= 6; } - // `rgbToHsv` - // Converts an RGB color value to HSV - // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] - // *Returns:* { h, s, v } in [0,1] - function rgbToHsv(r, g, b) { + return { h: h, s: s, l: l }; + } - r = bound01(r, 255); - g = bound01(g, 255); - b = bound01(b, 255); + // `hslToRgb` + // Converts an HSL color value to RGB. + // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] + // *Returns:* { r, g, b } in the set [0, 255] + function hslToRgb(h, s, l) { + var r, g, b; - var max = mathMax(r, g, b), - min = mathMin(r, g, b); - var h, - s, - v = max; + h = bound01(h, 360); + s = bound01(s, 100); + l = bound01(l, 100); - var d = max - min; - s = max === 0 ? 0 : d / max; + function hue2rgb(p, q, t) { + if (t < 0) t += 1; + if (t > 1) t -= 1; + if (t < 1 / 6) return p + (q - p) * 6 * t; + if (t < 1 / 2) return q; + if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; + return p; + } - if (max == min) { - h = 0; // achromatic - } else { - switch (max) { - case r: - h = (g - b) / d + (g < b ? 6 : 0);break; - case g: - h = (b - r) / d + 2;break; - case b: - h = (r - g) / d + 4;break; - } - h /= 6; - } - return { h: h, s: s, v: v }; + if (s === 0) { + r = g = b = l; // achromatic + } else { + var q = l < 0.5 ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + r = hue2rgb(p, q, h + 1 / 3); + g = hue2rgb(p, q, h); + b = hue2rgb(p, q, h - 1 / 3); } - // `hsvToRgb` - // Converts an HSV color value to RGB. - // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] - // *Returns:* { r, g, b } in the set [0, 255] - function hsvToRgb(h, s, v) { + return { r: r * 255, g: g * 255, b: b * 255 }; + } - h = bound01(h, 360) * 6; - s = bound01(s, 100); - v = bound01(v, 100); + // `rgbToHsv` + // Converts an RGB color value to HSV + // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] + // *Returns:* { h, s, v } in [0,1] + function rgbToHsv(r, g, b) { + r = bound01(r, 255); + g = bound01(g, 255); + b = bound01(b, 255); - var i = math.floor(h), - f = h - i, - p = v * (1 - s), - q = v * (1 - f * s), - t = v * (1 - (1 - f) * s), - mod = i % 6, - r = [v, q, p, p, t, v][mod], - g = [t, v, v, q, p, p][mod], - b = [p, p, t, v, v, q][mod]; + var max = mathMax(r, g, b), + min = mathMin(r, g, b); + var h, + s, + v = max; - return { r: r * 255, g: g * 255, b: b * 255 }; - } + var d = max - min; + s = max === 0 ? 0 : d / max; - // `rgbToHex` - // Converts an RGB color to hex - // Assumes r, g, and b are contained in the set [0, 255] - // Returns a 3 or 6 character hex - function rgbToHex(r, g, b, allow3Char) { + if (max == min) { + h = 0; // achromatic + } else { + switch (max) { + case r: + h = (g - b) / d + (g < b ? 6 : 0); + break; + case g: + h = (b - r) / d + 2; + break; + case b: + h = (r - g) / d + 4; + break; + } + h /= 6; + } + return { h: h, s: s, v: v }; + } - var hex = [pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16))]; + // `hsvToRgb` + // Converts an HSV color value to RGB. + // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] + // *Returns:* { r, g, b } in the set [0, 255] + function hsvToRgb(h, s, v) { + h = bound01(h, 360) * 6; + s = bound01(s, 100); + v = bound01(v, 100); - // Return a 3 character hex if possible - if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { - return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); - } + var i = math.floor(h), + f = h - i, + p = v * (1 - s), + q = v * (1 - f * s), + t = v * (1 - (1 - f) * s), + mod = i % 6, + r = [v, q, p, p, t, v][mod], + g = [t, v, v, q, p, p][mod], + b = [p, p, t, v, v, q][mod]; - return hex.join(""); - } - // `rgbaToHex` - // Converts an RGBA color plus alpha transparency to hex - // Assumes r, g, b and a are contained in the set [0, 255] - // Returns an 8 character hex - function rgbaToHex(r, g, b, a) { + return { r: r * 255, g: g * 255, b: b * 255 }; + } - var hex = [pad2(convertDecimalToHex(a)), pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16))]; + // `rgbToHex` + // Converts an RGB color to hex + // Assumes r, g, and b are contained in the set [0, 255] + // Returns a 3 or 6 character hex + function rgbToHex(r, g, b, allow3Char) { + var hex = [pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16))]; - return hex.join(""); + // Return a 3 character hex if possible + if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { + return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); } - // `equals` - // Can be called with any tinycolor input - tinycolor.equals = function (color1, color2) { - if (!color1 || !color2) { - return false; - } - return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); - }; - tinycolor.random = function () { - return tinycolor.fromRatio({ - r: mathRandom(), - g: mathRandom(), - b: mathRandom() - }); - }; + return hex.join(''); + } + // `rgbaToHex` + // Converts an RGBA color plus alpha transparency to hex + // Assumes r, g, b and a are contained in the set [0, 255] + // Returns an 8 character hex + function rgbaToHex(r, g, b, a) { + var hex = [pad2(convertDecimalToHex(a)), pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16))]; - // Modification Functions - // ---------------------- - // Thanks to less.js for some of the basics here - // + return hex.join(''); + } - function _desaturate(color, amount) { - amount = amount === 0 ? 0 : amount || 10; - var hsl = tinycolor(color).toHsl(); - hsl.s -= amount / 100; - hsl.s = clamp01(hsl.s); - return tinycolor(hsl); + // `equals` + // Can be called with any tinycolor input + tinycolor.equals = function (color1, color2) { + if (!color1 || !color2) { + return false; } + return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); + }; + tinycolor.random = function () { + return tinycolor.fromRatio({ + r: mathRandom(), + g: mathRandom(), + b: mathRandom() + }); + }; - function _saturate(color, amount) { - amount = amount === 0 ? 0 : amount || 10; - var hsl = tinycolor(color).toHsl(); - hsl.s += amount / 100; - hsl.s = clamp01(hsl.s); - return tinycolor(hsl); - } + // Modification Functions + // ---------------------- + // Thanks to less.js for some of the basics here + // - function _greyscale(color) { - return tinycolor(color).desaturate(100); - } + function _desaturate(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var hsl = tinycolor(color).toHsl(); + hsl.s -= amount / 100; + hsl.s = clamp01(hsl.s); + return tinycolor(hsl); + } - function _lighten(color, amount) { - amount = amount === 0 ? 0 : amount || 10; - var hsl = tinycolor(color).toHsl(); - hsl.l += amount / 100; - hsl.l = clamp01(hsl.l); - return tinycolor(hsl); - } + function _saturate(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var hsl = tinycolor(color).toHsl(); + hsl.s += amount / 100; + hsl.s = clamp01(hsl.s); + return tinycolor(hsl); + } - function _brighten(color, amount) { - amount = amount === 0 ? 0 : amount || 10; - var rgb = tinycolor(color).toRgb(); - rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * -(amount / 100)))); - rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * -(amount / 100)))); - rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * -(amount / 100)))); - return tinycolor(rgb); - } + function _greyscale(color) { + return tinycolor(color).desaturate(100); + } - function _darken(color, amount) { - amount = amount === 0 ? 0 : amount || 10; - var hsl = tinycolor(color).toHsl(); - hsl.l -= amount / 100; - hsl.l = clamp01(hsl.l); - return tinycolor(hsl); - } + function _lighten(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var hsl = tinycolor(color).toHsl(); + hsl.l += amount / 100; + hsl.l = clamp01(hsl.l); + return tinycolor(hsl); + } - // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. - // Values outside of this range will be wrapped into this range. - function _spin(color, amount) { - var hsl = tinycolor(color).toHsl(); - var hue = (mathRound(hsl.h) + amount) % 360; - hsl.h = hue < 0 ? 360 + hue : hue; - return tinycolor(hsl); - } + function _brighten(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var rgb = tinycolor(color).toRgb(); + rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * -(amount / 100)))); + rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * -(amount / 100)))); + rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * -(amount / 100)))); + return tinycolor(rgb); + } - // Combination Functions - // --------------------- - // Thanks to jQuery xColor for some of the ideas behind these - // + function _darken(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var hsl = tinycolor(color).toHsl(); + hsl.l -= amount / 100; + hsl.l = clamp01(hsl.l); + return tinycolor(hsl); + } - function _complement(color) { - var hsl = tinycolor(color).toHsl(); - hsl.h = (hsl.h + 180) % 360; - return tinycolor(hsl); - } + // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. + // Values outside of this range will be wrapped into this range. + function _spin(color, amount) { + var hsl = tinycolor(color).toHsl(); + var hue = (mathRound(hsl.h) + amount) % 360; + hsl.h = hue < 0 ? 360 + hue : hue; + return tinycolor(hsl); + } - function _triad(color) { - var hsl = tinycolor(color).toHsl(); - var h = hsl.h; - return [tinycolor(color), tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })]; - } + // Combination Functions + // --------------------- + // Thanks to jQuery xColor for some of the ideas behind these + // - function _tetrad(color) { - var hsl = tinycolor(color).toHsl(); - var h = hsl.h; - return [tinycolor(color), tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })]; - } + function _complement(color) { + var hsl = tinycolor(color).toHsl(); + hsl.h = (hsl.h + 180) % 360; + return tinycolor(hsl); + } - function _splitcomplement(color) { - var hsl = tinycolor(color).toHsl(); - var h = hsl.h; - return [tinycolor(color), tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l })]; - } + function _triad(color) { + var hsl = tinycolor(color).toHsl(); + var h = hsl.h; + return [tinycolor(color), tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })]; + } - function _analogous(color, results, slices) { - results = results || 6; - slices = slices || 30; + function _tetrad(color) { + var hsl = tinycolor(color).toHsl(); + var h = hsl.h; + return [tinycolor(color), tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })]; + } - var hsl = tinycolor(color).toHsl(); - var part = 360 / slices; - var ret = [tinycolor(color)]; + function _splitcomplement(color) { + var hsl = tinycolor(color).toHsl(); + var h = hsl.h; + return [tinycolor(color), tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l })]; + } - for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) { - hsl.h = (hsl.h + part) % 360; - ret.push(tinycolor(hsl)); - } - return ret; - } + function _analogous(color, results, slices) { + results = results || 6; + slices = slices || 30; - function _monochromatic(color, results) { - results = results || 6; - var hsv = tinycolor(color).toHsv(); - var h = hsv.h, - s = hsv.s, - v = hsv.v; - var ret = []; - var modification = 1 / results; + var hsl = tinycolor(color).toHsl(); + var part = 360 / slices; + var ret = [tinycolor(color)]; - while (results--) { - ret.push(tinycolor({ h: h, s: s, v: v })); - v = (v + modification) % 1; - } + for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) { + hsl.h = (hsl.h + part) % 360; + ret.push(tinycolor(hsl)); + } + return ret; + } - return ret; + function _monochromatic(color, results) { + results = results || 6; + var hsv = tinycolor(color).toHsv(); + var h = hsv.h, + s = hsv.s, + v = hsv.v; + var ret = []; + var modification = 1 / results; + + while (results--) { + ret.push(tinycolor({ h: h, s: s, v: v })); + v = (v + modification) % 1; } - // Utility Functions - // --------------------- + return ret; + } - tinycolor.mix = function (color1, color2, amount) { - amount = amount === 0 ? 0 : amount || 50; + // Utility Functions + // --------------------- - var rgb1 = tinycolor(color1).toRgb(); - var rgb2 = tinycolor(color2).toRgb(); + tinycolor.mix = function (color1, color2, amount) { + amount = amount === 0 ? 0 : amount || 50; - var p = amount / 100; - var w = p * 2 - 1; - var a = rgb2.a - rgb1.a; + var rgb1 = tinycolor(color1).toRgb(); + var rgb2 = tinycolor(color2).toRgb(); - var w1; + var p = amount / 100; + var w = p * 2 - 1; + var a = rgb2.a - rgb1.a; - if (w * a == -1) { - w1 = w; - } else { - w1 = (w + a) / (1 + w * a); - } + var w1; - w1 = (w1 + 1) / 2; + if (w * a == -1) { + w1 = w; + } else { + w1 = (w + a) / (1 + w * a); + } - var w2 = 1 - w1; + w1 = (w1 + 1) / 2; - var rgba = { - r: rgb2.r * w1 + rgb1.r * w2, - g: rgb2.g * w1 + rgb1.g * w2, - b: rgb2.b * w1 + rgb1.b * w2, - a: rgb2.a * p + rgb1.a * (1 - p) - }; + var w2 = 1 - w1; - return tinycolor(rgba); + var rgba = { + r: rgb2.r * w1 + rgb1.r * w2, + g: rgb2.g * w1 + rgb1.g * w2, + b: rgb2.b * w1 + rgb1.b * w2, + a: rgb2.a * p + rgb1.a * (1 - p) }; - // Readability Functions - // --------------------- - // - - // `readability` - // Analyze the 2 colors and returns an object with the following properties: - // `brightness`: difference in brightness between the two colors - // `color`: difference in color/hue between the two colors - tinycolor.readability = function (color1, color2) { - var c1 = tinycolor(color1); - var c2 = tinycolor(color2); - var rgb1 = c1.toRgb(); - var rgb2 = c2.toRgb(); - var brightnessA = c1.getBrightness(); - var brightnessB = c2.getBrightness(); - var colorDiff = Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) + Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) + Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b); + return tinycolor(rgba); + }; - return { - brightness: Math.abs(brightnessA - brightnessB), - color: colorDiff - }; - }; + // Readability Functions + // --------------------- + // - // `readable` - // http://www.w3.org/TR/AERT#color-contrast - // Ensure that foreground and background color combinations provide sufficient contrast. - // *Example* - // tinycolor.isReadable("#000", "#111") => false - tinycolor.isReadable = function (color1, color2) { - var readability = tinycolor.readability(color1, color2); - return readability.brightness > 125 && readability.color > 500; - }; + // `readability` + // Analyze the 2 colors and returns an object with the following properties: + // `brightness`: difference in brightness between the two colors + // `color`: difference in color/hue between the two colors + tinycolor.readability = function (color1, color2) { + var c1 = tinycolor(color1); + var c2 = tinycolor(color2); + var rgb1 = c1.toRgb(); + var rgb2 = c2.toRgb(); + var brightnessA = c1.getBrightness(); + var brightnessB = c2.getBrightness(); + var colorDiff = Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) + Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) + Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b); - // `mostReadable` - // Given a base color and a list of possible foreground or background - // colors for that base, returns the most readable color. - // *Example* - // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000" - tinycolor.mostReadable = function (baseColor, colorList) { - var bestColor = null; - var bestScore = 0; - var bestIsReadable = false; - for (var i = 0; i < colorList.length; i++) { - - // We normalize both around the "acceptable" breaking point, - // but rank brightness constrast higher than hue. - - var readability = tinycolor.readability(baseColor, colorList[i]); - var readable = readability.brightness > 125 && readability.color > 500; - var score = 3 * (readability.brightness / 125) + readability.color / 500; - - if (readable && !bestIsReadable || readable && bestIsReadable && score > bestScore || !readable && !bestIsReadable && score > bestScore) { - bestIsReadable = readable; - bestScore = score; - bestColor = tinycolor(colorList[i]); - } - } - return bestColor; + return { + brightness: Math.abs(brightnessA - brightnessB), + color: colorDiff }; + }; - // Big List of Colors - // ------------------ - // - var names = tinycolor.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" - }; + // `readable` + // http://www.w3.org/TR/AERT#color-contrast + // Ensure that foreground and background color combinations provide sufficient contrast. + // *Example* + // tinycolor.isReadable("#000", "#111") => false + tinycolor.isReadable = function (color1, color2) { + var readability = tinycolor.readability(color1, color2); + return readability.brightness > 125 && readability.color > 500; + }; - // Make it easy to access colors via `hexNames[hex]` - var hexNames = tinycolor.hexNames = flip(names); + // `mostReadable` + // Given a base color and a list of possible foreground or background + // colors for that base, returns the most readable color. + // *Example* + // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000" + tinycolor.mostReadable = function (baseColor, colorList) { + var bestColor = null; + var bestScore = 0; + var bestIsReadable = false; + for (var i = 0; i < colorList.length; i++) { + // We normalize both around the "acceptable" breaking point, + // but rank brightness constrast higher than hue. - // Utilities - // --------- + var readability = tinycolor.readability(baseColor, colorList[i]); + var readable = readability.brightness > 125 && readability.color > 500; + var score = 3 * (readability.brightness / 125) + readability.color / 500; - // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` - function flip(o) { - var flipped = {}; - for (var i in o) { - if (o.hasOwnProperty(i)) { - flipped[o[i]] = i; - } - } - return flipped; + if (readable && !bestIsReadable || readable && bestIsReadable && score > bestScore || !readable && !bestIsReadable && score > bestScore) { + bestIsReadable = readable; + bestScore = score; + bestColor = tinycolor(colorList[i]); + } } + return bestColor; + }; - // Return a valid alpha value [0,1] with all invalid values being set to 1 - function boundAlpha(a) { - a = parseFloat(a); - - if (isNaN(a) || a < 0 || a > 1) { - a = 1; - } + // Big List of Colors + // ------------------ + // + var names = tinycolor.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' + }; + + // Make it easy to access colors via `hexNames[hex]` + var hexNames = tinycolor.hexNames = flip(names); + + // Utilities + // --------- + + // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` + function flip(o) { + var flipped = {}; + for (var i in o) { + if (o.hasOwnProperty(i)) { + flipped[o[i]] = i; + } + } + return flipped; + } + + // Return a valid alpha value [0,1] with all invalid values being set to 1 + function boundAlpha(a) { + a = parseFloat(a); + + if (isNaN(a) || a < 0 || a > 1) { + a = 1; + } + + return a; + } + + // Take input from [0, n] and return it as [0, 1] + function bound01(n, max) { + if (isOnePointZero(n)) { + n = '100%'; + } + + var processPercent = isPercentage(n); + n = mathMin(max, mathMax(0, parseFloat(n))); - return a; + // Automatically convert percentage into number + if (processPercent) { + n = parseInt(n * max, 10) / 100; } - // Take input from [0, n] and return it as [0, 1] - function bound01(n, max) { - if (isOnePointZero(n)) { - n = "100%"; - } - - var processPercent = isPercentage(n); - n = mathMin(max, mathMax(0, parseFloat(n))); - - // Automatically convert percentage into number - if (processPercent) { - n = parseInt(n * max, 10) / 100; - } - - // Handle floating point rounding errors - if (math.abs(n - max) < 0.000001) { - return 1; - } - - // Convert into [0, 1] range if it isn't already - return n % max / parseFloat(max); + // Handle floating point rounding errors + if (math.abs(n - max) < 0.000001) { + return 1; } - // Force a number between 0 and 1 - function clamp01(val) { - return mathMin(1, mathMax(0, val)); - } + // Convert into [0, 1] range if it isn't already + return n % max / parseFloat(max); + } - // Parse a base-16 hex value into a base-10 integer - function parseIntFromHex(val) { - return parseInt(val, 16); - } + // Force a number between 0 and 1 + function clamp01(val) { + return mathMin(1, mathMax(0, val)); + } - // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 - // - function isOnePointZero(n) { - return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; - } + // Parse a base-16 hex value into a base-10 integer + function parseIntFromHex(val) { + return parseInt(val, 16); + } - // Check to see if string passed in is a percentage - function isPercentage(n) { - return typeof n === "string" && n.indexOf('%') != -1; - } + // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 + // + function isOnePointZero(n) { + return typeof n == 'string' && n.indexOf('.') != -1 && parseFloat(n) === 1; + } - // Force a hex value to have 2 characters - function pad2(c) { - return c.length == 1 ? '0' + c : '' + c; - } + // Check to see if string passed in is a percentage + function isPercentage(n) { + return typeof n === 'string' && n.indexOf('%') != -1; + } - // Replace a decimal with it's percentage value - function convertToPercentage(n) { - if (n <= 1) { - n = n * 100 + "%"; - } + // Force a hex value to have 2 characters + function pad2(c) { + return c.length == 1 ? '0' + c : '' + c; + } - return n; + // Replace a decimal with it's percentage value + function convertToPercentage(n) { + if (n <= 1) { + n = n * 100 + '%'; } - // Converts a decimal to a hex value - function convertDecimalToHex(d) { - return Math.round(parseFloat(d) * 255).toString(16); - } - // Converts a hex value to a decimal - function convertHexToDecimal(h) { - return parseIntFromHex(h) / 255; - } + return n; + } - var matchers = function () { + // Converts a decimal to a hex value + function convertDecimalToHex(d) { + return Math.round(parseFloat(d) * 255).toString(16); + } + // Converts a hex value to a decimal + function convertHexToDecimal(h) { + return parseIntFromHex(h) / 255; + } - // - var CSS_INTEGER = "[-\\+]?\\d+%?"; + var matchers = function () { + // + var CSS_INTEGER = '[-\\+]?\\d+%?'; - // - var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; + // + var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?'; - // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. - var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; + // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. + var CSS_UNIT = '(?:' + CSS_NUMBER + ')|(?:' + CSS_INTEGER + ')'; - // Actual matching. - // Parentheses and commas are optional, but not required. - // Whitespace can take the place of commas or opening paren - var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; - var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; + // Actual matching. + // Parentheses and commas are optional, but not required. + // Whitespace can take the place of commas or opening paren + var PERMISSIVE_MATCH3 = '[\\s|\\(]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')\\s*\\)?'; + var PERMISSIVE_MATCH4 = '[\\s|\\(]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')\\s*\\)?'; - return { - rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), - rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), - hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), - hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), - hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), - hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), - 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})$/ - }; - }(); - - // `stringInputToObject` - // Permissive string parsing. Take in a number of formats, and output an object - // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` - function stringInputToObject(color) { - - color = color.replace(trimLeft, '').replace(trimRight, '').toLowerCase(); - var named = false; - if (names[color]) { - color = names[color]; - named = true; - } else if (color == 'transparent') { - return { r: 0, g: 0, b: 0, a: 0, format: "name" }; - } + return { + rgb: new RegExp('rgb' + PERMISSIVE_MATCH3), + rgba: new RegExp('rgba' + PERMISSIVE_MATCH4), + hsl: new RegExp('hsl' + PERMISSIVE_MATCH3), + hsla: new RegExp('hsla' + PERMISSIVE_MATCH4), + hsv: new RegExp('hsv' + PERMISSIVE_MATCH3), + hsva: new RegExp('hsva' + PERMISSIVE_MATCH4), + 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})$/ + }; + }(); - // Try to match string input using regular expressions. - // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] - // Just return an object and let the conversion functions handle that. - // This way the result will be the same whether the tinycolor is initialized with string or object. - var match; - if (match = matchers.rgb.exec(color)) { - return { r: match[1], g: match[2], b: match[3] }; - } - if (match = matchers.rgba.exec(color)) { - return { r: match[1], g: match[2], b: match[3], a: match[4] }; - } - if (match = matchers.hsl.exec(color)) { - return { h: match[1], s: match[2], l: match[3] }; - } - if (match = matchers.hsla.exec(color)) { - return { h: match[1], s: match[2], l: match[3], a: match[4] }; - } - if (match = matchers.hsv.exec(color)) { - return { h: match[1], s: match[2], v: match[3] }; - } - if (match = matchers.hsva.exec(color)) { - return { h: match[1], s: match[2], v: match[3], a: match[4] }; - } - if (match = matchers.hex8.exec(color)) { - return { - a: convertHexToDecimal(match[1]), - r: parseIntFromHex(match[2]), - g: parseIntFromHex(match[3]), - b: parseIntFromHex(match[4]), - format: named ? "name" : "hex8" - }; - } - if (match = matchers.hex6.exec(color)) { - return { - r: parseIntFromHex(match[1]), - g: parseIntFromHex(match[2]), - b: parseIntFromHex(match[3]), - format: named ? "name" : "hex" - }; - } - if (match = matchers.hex3.exec(color)) { - return { - r: parseIntFromHex(match[1] + '' + match[1]), - g: parseIntFromHex(match[2] + '' + match[2]), - b: parseIntFromHex(match[3] + '' + match[3]), - format: named ? "name" : "hex" - }; - } + // `stringInputToObject` + // Permissive string parsing. Take in a number of formats, and output an object + // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` + function stringInputToObject(color) { + color = color.replace(trimLeft, '').replace(trimRight, '').toLowerCase(); + var named = false; + if (names[color]) { + color = names[color]; + named = true; + } else if (color == 'transparent') { + return { r: 0, g: 0, b: 0, a: 0, format: 'name' }; + } - return false; + // Try to match string input using regular expressions. + // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] + // Just return an object and let the conversion functions handle that. + // This way the result will be the same whether the tinycolor is initialized with string or object. + var match; + if (match = matchers.rgb.exec(color)) { + return { r: match[1], g: match[2], b: match[3] }; + } + if (match = matchers.rgba.exec(color)) { + return { r: match[1], g: match[2], b: match[3], a: match[4] }; + } + if (match = matchers.hsl.exec(color)) { + return { h: match[1], s: match[2], l: match[3] }; + } + if (match = matchers.hsla.exec(color)) { + return { h: match[1], s: match[2], l: match[3], a: match[4] }; + } + if (match = matchers.hsv.exec(color)) { + return { h: match[1], s: match[2], v: match[3] }; + } + if (match = matchers.hsva.exec(color)) { + return { h: match[1], s: match[2], v: match[3], a: match[4] }; + } + if (match = matchers.hex8.exec(color)) { + return { + a: convertHexToDecimal(match[1]), + r: parseIntFromHex(match[2]), + g: parseIntFromHex(match[3]), + b: parseIntFromHex(match[4]), + format: named ? 'name' : 'hex8' + }; + } + if (match = matchers.hex6.exec(color)) { + return { + r: parseIntFromHex(match[1]), + g: parseIntFromHex(match[2]), + b: parseIntFromHex(match[3]), + format: named ? 'name' : 'hex' + }; + } + if (match = matchers.hex3.exec(color)) { + return { + r: parseIntFromHex(match[1] + '' + match[1]), + g: parseIntFromHex(match[2] + '' + match[2]), + b: parseIntFromHex(match[3] + '' + match[3]), + format: named ? 'name' : 'hex' + }; } - window.tinycolor = tinycolor; - //})(); + return false; + } - $(function () { - if ($.fn.spectrum.load) { - $.fn.spectrum.processNativeColorInputs(); - } - }); + window.tinycolor = tinycolor; + //})(); + + $(function () { + if ($.fn.spectrum.load) { + $.fn.spectrum.processNativeColorInputs(); + } + }); }); /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 125 */ +/* 123 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var Backbone = __webpack_require__(0); -var LayerView = __webpack_require__(126); +var LayerView = __webpack_require__(124); module.exports = Backbone.View.extend({ initialize: function initialize(o) { @@ -39005,14 +39050,13 @@ module.exports = Backbone.View.extend({ }); /***/ }), -/* 126 */ +/* 124 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(Backbone) { module.exports = Backbone.View.extend({ - events: { click: 'active', 'click [data-close-layer]': 'remove', @@ -39165,7 +39209,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 127 */ +/* 125 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -39176,15 +39220,13 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Property = __webpack_require__(42); module.exports = Property.extend({ - defaults: _extends({}, Property.prototype.defaults, { showInput: 1 }) - }); /***/ }), -/* 128 */ +/* 126 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -39193,7 +39235,6 @@ module.exports = Property.extend({ var Property = __webpack_require__(14); module.exports = Property.extend({ - events: { 'change [type=range]': 'inputValueChanged', 'input [type=range]': 'inputValueChangedSoft' @@ -39237,7 +39278,7 @@ module.exports = Property.extend({ }); /***/ }), -/* 129 */ +/* 127 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -39272,64 +39313,114 @@ module.exports = function () { // Fixed values switch (prop) { - case 'margin-top':case 'margin-right':case 'margin-bottom':case 'margin-left': - case 'padding-top':case 'padding-right':case 'padding-bottom':case 'padding-left': - case 'width':case 'max-width':case 'min-width': - case 'height':case 'max-height':case 'min-height': + case 'margin-top': + case 'margin-right': + case 'margin-bottom': + case 'margin-left': + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'width': + case 'max-width': + case 'min-width': + case 'height': + case 'max-height': + case 'min-height': obj.fixedValues = ['initial', 'inherit', 'auto']; break; case 'font-size': obj.fixedValues = ['medium', 'xx-small', 'x-small', 'small', 'large', 'x-large', 'xx-large', 'smaller', 'larger', 'length', 'initial', 'inherit']; break; - case 'letter-spacing':case 'line-height': + case 'letter-spacing': + case 'line-height': obj.fixedValues = ['normal', 'initial', 'inherit']; break; } // Type switch (prop) { - case 'float':case 'position': + case 'float': + case 'position': case 'text-align': obj.type = 'radio'; break; - case 'display':case 'font-family': + case 'display': + case 'font-family': case 'font-weight': case 'border-style': case 'box-shadow-type': - case 'background-repeat':case 'background-position':case 'background-attachment':case 'background-size': - case 'transition-property':case 'transition-timing-function': + case 'background-repeat': + case 'background-position': + case 'background-attachment': + case 'background-size': + case 'transition-property': + case 'transition-timing-function': case 'cursor': case 'overflow': obj.type = 'select'; break; - case 'top':case 'right':case 'bottom':case 'left': - case 'margin-top':case 'margin-right':case 'margin-bottom':case 'margin-left': - case 'padding-top':case 'padding-right':case 'padding-bottom':case 'padding-left': - case 'min-height':case 'min-width':case 'max-height':case 'max-width': - case 'width':case 'height': - case 'font-size':case 'letter-spacing':case 'line-height': - case 'text-shadow-h':case 'text-shadow-v':case 'text-shadow-blur': + case 'top': + case 'right': + case 'bottom': + case 'left': + case 'margin-top': + case 'margin-right': + case 'margin-bottom': + case 'margin-left': + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'min-height': + case 'min-width': + case 'max-height': + case 'max-width': + case 'width': + case 'height': + case 'font-size': + case 'letter-spacing': + case 'line-height': + case 'text-shadow-h': + case 'text-shadow-v': + case 'text-shadow-blur': case 'border-radius-c': - case 'border-top-left-radius':case 'border-top-right-radius':case 'border-bottom-left-radius':case 'border-bottom-right-radius': + case 'border-top-left-radius': + case 'border-top-right-radius': + case 'border-bottom-left-radius': + case 'border-bottom-right-radius': case 'border-width': - case 'box-shadow-h':case 'box-shadow-v':case 'box-shadow-blur':case 'box-shadow-spread': + case 'box-shadow-h': + case 'box-shadow-v': + case 'box-shadow-blur': + case 'box-shadow-spread': case 'transition-duration': case 'perspective': - case 'transform-rotate-x':case 'transform-rotate-y':case 'transform-rotate-z': - case 'transform-scale-x':case 'transform-scale-y':case 'transform-scale-z': + case 'transform-rotate-x': + case 'transform-rotate-y': + case 'transform-rotate-z': + case 'transform-scale-x': + case 'transform-scale-y': + case 'transform-scale-z': obj.type = 'integer'; break; - case 'margin':case 'padding': + case 'margin': + case 'padding': case 'border-radius': case 'border': case 'transform': obj.type = 'composite'; break; - case 'color':case 'text-shadow-color': - case 'background-color':case 'border-color':case 'box-shadow-color': + case 'color': + case 'text-shadow-color': + case 'background-color': + case 'border-color': + case 'box-shadow-color': obj.type = 'color'; break; - case 'text-shadow':case 'box-shadow':case 'background': + case 'text-shadow': + case 'box-shadow': + case 'background': case 'transition': obj.type = 'stack'; break; @@ -39340,8 +39431,10 @@ module.exports = function () { // Defaults switch (prop) { - case 'float':case 'background-color': - case 'background-image':case 'text-shadow': + case 'float': + case 'background-color': + case 'background-image': + case 'text-shadow': obj.defaults = 'none'; break; case 'display': @@ -39350,25 +39443,49 @@ module.exports = function () { case 'position': obj.defaults = 'static'; break; - case 'top':case 'right':case 'bottom':case 'left': - case 'margin-top':case 'margin-right':case 'margin-bottom':case 'margin-left': - case 'padding-top':case 'padding-right':case 'padding-bottom':case 'padding-left': - case 'text-shadow-h':case 'text-shadow-v':case 'text-shadow-blur': + case 'top': + case 'right': + case 'bottom': + case 'left': + case 'margin-top': + case 'margin-right': + case 'margin-bottom': + case 'margin-left': + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'text-shadow-h': + case 'text-shadow-v': + case 'text-shadow-blur': case 'border-radius-c': - case 'border-top-left-radius':case 'border-top-right-radius':case 'border-bottom-left-radius':case 'border-bottom-right-radius': - case 'box-shadow-h':case 'box-shadow-v':case 'box-shadow-spread': + case 'border-top-left-radius': + case 'border-top-right-radius': + case 'border-bottom-left-radius': + case 'border-bottom-right-radius': + case 'box-shadow-h': + case 'box-shadow-v': + case 'box-shadow-spread': case 'perspective': - case 'transform-rotate-x':case 'transform-rotate-y':case 'transform-rotate-z': + case 'transform-rotate-x': + case 'transform-rotate-y': + case 'transform-rotate-z': obj.defaults = 0; break; - case 'transform-scale-x':case 'transform-scale-y':case 'transform-scale-z': + case 'transform-scale-x': + case 'transform-scale-y': + case 'transform-scale-z': obj.defaults = 1; break; case 'box-shadow-blur': obj.defaults = '5px'; break; - case 'min-height':case 'min-width':case 'max-height':case 'max-width': - case 'width':case 'height': + case 'min-height': + case 'min-width': + case 'max-height': + case 'max-width': + case 'width': + case 'height': case 'background-size': case 'cursor': obj.defaults = 'auto'; @@ -39376,17 +39493,21 @@ module.exports = function () { case 'font-family': obj.defaults = 'Arial, Helvetica, sans-serif'; break; - case 'font-size':case 'border-width': + case 'font-size': + case 'border-width': obj.defaults = 'medium'; break; case 'font-weight': obj.defaults = '400'; break; - case 'letter-spacing':case 'line-height': + case 'letter-spacing': + case 'line-height': obj.defaults = 'normal'; break; - case 'color':case 'text-shadow-color': - case 'border-color':case 'box-shadow-color': + case 'color': + case 'text-shadow-color': + case 'border-color': + case 'box-shadow-color': obj.defaults = 'black'; break; case 'text-align': @@ -39423,44 +39544,78 @@ module.exports = function () { // Units switch (prop) { - case 'top':case 'right':case 'bottom':case 'left': - case 'margin-top':case 'margin-right':case 'margin-bottom':case 'margin-left': - case 'padding-top':case 'padding-right':case 'padding-bottom':case 'padding-left': - case 'min-height':case 'min-width':case 'max-height':case 'max-width': - case 'width':case 'height': - case 'text-shadow-h':case 'text-shadow-v':case 'text-shadow-blur': + case 'top': + case 'right': + case 'bottom': + case 'left': + case 'margin-top': + case 'margin-right': + case 'margin-bottom': + case 'margin-left': + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'min-height': + case 'min-width': + case 'max-height': + case 'max-width': + case 'width': + case 'height': + case 'text-shadow-h': + case 'text-shadow-v': + case 'text-shadow-blur': case 'border-radius-c': - case 'border-top-left-radius':case 'border-top-right-radius':case 'border-bottom-left-radius':case 'border-bottom-right-radius': - case 'box-shadow-h':case 'box-shadow-v': + case 'border-top-left-radius': + case 'border-top-right-radius': + case 'border-bottom-left-radius': + case 'border-bottom-right-radius': + case 'box-shadow-h': + case 'box-shadow-v': obj.units = ['px', '%']; break; - case 'font-size':case 'letter-spacing':case 'line-height': + case 'font-size': + case 'letter-spacing': + case 'line-height': obj.units = ['px', 'em', 'rem', '%']; break; case 'border-width': obj.units = ['px', 'em']; break; - case 'box-shadow-blur':case 'box-shadow-spread': + case 'box-shadow-blur': + case 'box-shadow-spread': case 'perspective': obj.units = ['px']; break; case 'transition-duration': obj.units = ['s']; break; - case 'transform-rotate-x':case 'transform-rotate-y':case 'transform-rotate-z': + case 'transform-rotate-x': + case 'transform-rotate-y': + case 'transform-rotate-z': obj.units = ['deg']; break; } // Min/Max switch (prop) { - case 'padding-top':case 'padding-right':case 'padding-bottom':case 'padding-left': - case 'min-height':case 'min-width':case 'max-height':case 'max-width': - case 'width':case 'height': + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'min-height': + case 'min-width': + case 'max-height': + case 'max-width': + case 'width': + case 'height': case 'font-size': case 'text-shadow-blur': case 'border-radius-c': - case 'border-top-left-radius':case 'border-top-right-radius':case 'border-bottom-left-radius':case 'border-bottom-right-radius': + case 'border-top-left-radius': + case 'border-top-right-radius': + case 'border-bottom-left-radius': + case 'border-bottom-right-radius': case 'border-width': case 'box-shadow-blur': case 'transition-duration': @@ -39471,7 +39626,9 @@ module.exports = function () { // Preview switch (prop) { - case 'text-shadow':case 'box-shadow':case 'background': + case 'text-shadow': + case 'box-shadow': + case 'background': obj.preview = true; break; } @@ -39608,7 +39765,7 @@ module.exports = function () { }; /***/ }), -/* 130 */ +/* 128 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -39618,7 +39775,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var _underscore = __webpack_require__(1); -var SectorView = __webpack_require__(131); +var SectorView = __webpack_require__(129); module.exports = Backbone.View.extend({ initialize: function initialize(o) { @@ -39802,7 +39959,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 131 */ +/* 129 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -39812,7 +39969,6 @@ var Backbone = __webpack_require__(0); var PropertiesView = __webpack_require__(13); module.exports = Backbone.View.extend({ - template: _.template('\n
\n \n <%= label %>\n
'), events: { @@ -39859,7 +40015,7 @@ module.exports = Backbone.View.extend({ * Show the content of the sector * */ show: function show() { - this.$el.addClass(this.pfx + "open"); + this.$el.addClass(this.pfx + 'open'); this.getPropertiesEl().style.display = ''; this.$caret.removeClass(this.caretR).addClass(this.caretD); }, @@ -39869,7 +40025,7 @@ module.exports = Backbone.View.extend({ * Hide the content of the sector * */ hide: function hide() { - this.$el.removeClass(this.pfx + "open"); + this.$el.removeClass(this.pfx + 'open'); this.getPropertiesEl().style.display = 'none'; this.$caret.removeClass(this.caretD).addClass(this.caretR); }, @@ -39913,7 +40069,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 132 */ +/* 130 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -39961,16 +40117,15 @@ module.exports = Backbone.View.extend({ module.exports = function () { var c = {}; - var defaults = __webpack_require__(133); - var Assets = __webpack_require__(134); - var AssetsView = __webpack_require__(137); + var defaults = __webpack_require__(131); + var Assets = __webpack_require__(132); + var AssetsView = __webpack_require__(135); var FileUpload = __webpack_require__(45); var assets = void 0, am = void 0, fu = void 0; return { - /** * Name of the module * @type {String} @@ -40064,7 +40219,6 @@ module.exports = function () { add: function add(asset) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - // Put the model at the beginning if (typeof opts.at == 'undefined') { opts.at = 0; @@ -40305,7 +40459,7 @@ module.exports = function () { }; /***/ }), -/* 133 */ +/* 131 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40397,7 +40551,7 @@ module.exports = { }; /***/ }), -/* 134 */ +/* 132 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40412,7 +40566,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de module.exports = __webpack_require__(0).Collection.extend(_TypeableCollection2.default).extend({ types: [{ id: 'image', - model: __webpack_require__(135), + model: __webpack_require__(133), view: __webpack_require__(43), isType: function isType(value) { if (typeof value == 'string') { @@ -40427,7 +40581,7 @@ module.exports = __webpack_require__(0).Collection.extend(_TypeableCollection2.d }); /***/ }), -/* 135 */ +/* 133 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40435,28 +40589,25 @@ module.exports = __webpack_require__(0).Collection.extend(_TypeableCollection2.d var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var Asset = __webpack_require__(136); +var Asset = __webpack_require__(134); module.exports = Asset.extend({ - defaults: _extends({}, Asset.prototype.defaults, { type: 'image', unitDim: 'px', height: 0, width: 0 }) - }); /***/ }), -/* 136 */ +/* 134 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = __webpack_require__(0).Model.extend({ - idAttribute: 'src', defaults: { @@ -40485,7 +40636,7 @@ module.exports = __webpack_require__(0).Model.extend({ }); /***/ }), -/* 137 */ +/* 135 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40496,7 +40647,6 @@ var AssetImageView = __webpack_require__(43); var FileUploader = __webpack_require__(45); module.exports = Backbone.View.extend({ - events: { submit: 'handleSubmit' }, @@ -40674,7 +40824,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 138 */ +/* 136 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40703,17 +40853,16 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument module.exports = function () { var em = void 0; var c = {}, - defaults = __webpack_require__(139), + defaults = __webpack_require__(137), CssRule = __webpack_require__(46), - CssRules = __webpack_require__(140), - CssRulesView = __webpack_require__(141); + CssRules = __webpack_require__(138), + CssRulesView = __webpack_require__(139); var Selectors = __webpack_require__(10); var Selector = __webpack_require__(7); var rules, rulesView; return { - Selectors: Selectors, /** @@ -41084,27 +41233,25 @@ module.exports = function () { }; /***/ }), -/* 139 */ +/* 137 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { - // Style prefix stylePrefix: 'css-', // Custom CSS string to render on top - 'staticRules': '', + staticRules: '', // Default CSS style rules: [] - }; /***/ }), -/* 140 */ +/* 138 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41144,14 +41291,14 @@ module.exports = Backbone.Collection.extend({ }); /***/ }), -/* 141 */ +/* 139 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var Backbone = __webpack_require__(0); -var CssRuleView = __webpack_require__(142); +var CssRuleView = __webpack_require__(140); module.exports = Backbone.View.extend({ initialize: function initialize(o) { @@ -41213,7 +41360,7 @@ module.exports = Backbone.View.extend({ }); /***/ }), -/* 142 */ +/* 140 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41241,7 +41388,7 @@ module.exports = __webpack_require__(0).View.extend({ }); /***/ }), -/* 143 */ +/* 141 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41251,19 +41398,18 @@ var _underscore = __webpack_require__(1); module.exports = function () { var c = {}; - var defaultOpts = __webpack_require__(144); - var TraitsView = __webpack_require__(145); + var defaultOpts = __webpack_require__(142); + var TraitsView = __webpack_require__(143); var TraitsViewer = void 0; return { - TraitsView: TraitsView, /** * Name of the module * @type {String} * @private - */ + */ name: 'TraitManager', /** @@ -41329,14 +41475,13 @@ module.exports = function () { }; /***/ }), -/* 144 */ +/* 142 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { - stylePrefix: 'trt-', labelContainer: 'Component settings', @@ -41349,11 +41494,10 @@ module.exports = { // Default options for the target input optionsTarget: [{ value: '', name: 'This window' }, { value: '_blank', name: 'New window' }] - }; /***/ }), -/* 145 */ +/* 143 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41361,21 +41505,20 @@ module.exports = { var DomainViews = __webpack_require__(48); var TraitView = __webpack_require__(8); -var TraitSelectView = __webpack_require__(146); -var TraitCheckboxView = __webpack_require__(147); -var TraitNumberView = __webpack_require__(148); -var TraitColorView = __webpack_require__(149); +var TraitSelectView = __webpack_require__(144); +var TraitCheckboxView = __webpack_require__(145); +var TraitNumberView = __webpack_require__(146); +var TraitColorView = __webpack_require__(147); module.exports = DomainViews.extend({ - itemView: TraitView, itemsView: { - 'text': TraitView, - 'number': TraitNumberView, - 'select': TraitSelectView, - 'checkbox': TraitCheckboxView, - 'color': TraitColorView + text: TraitView, + number: TraitNumberView, + select: TraitSelectView, + checkbox: TraitCheckboxView, + color: TraitColorView }, initialize: function initialize(o) { @@ -41403,7 +41546,7 @@ module.exports = DomainViews.extend({ }); /***/ }), -/* 146 */ +/* 144 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41472,7 +41615,7 @@ module.exports = TraitView.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1))) /***/ }), -/* 147 */ +/* 145 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41527,7 +41670,7 @@ module.exports = TraitView.extend({ }); /***/ }), -/* 148 */ +/* 146 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41582,7 +41725,7 @@ module.exports = TraitView.extend({ }); /***/ }), -/* 149 */ +/* 147 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41600,16 +41743,17 @@ module.exports = TraitView.extend({ getInputEl: function getInputEl() { if (!this.$input) { var value = this.getModelValue(); - var inputNumber = new InputColor({ + var inputColor = new InputColor({ target: this.config.em, contClass: this.ppfx + 'field-color', model: this.model, ppfx: this.ppfx }); - this.input = inputNumber.render(); + this.input = inputColor.render(); this.$input = this.input.colorEl; value = value || ''; this.model.set('value', value).trigger('change:value'); + this.input.setValue(value); } return this.$input.get(0); }, @@ -41628,7 +41772,7 @@ module.exports = TraitView.extend({ }); /***/ }), -/* 150 */ +/* 148 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41673,7 +41817,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument module.exports = function () { var c = {}; var em = void 0; - var defaults = __webpack_require__(151); + var defaults = __webpack_require__(149); var Component = __webpack_require__(4); var ComponentView = __webpack_require__(3); var Components = __webpack_require__(49); @@ -41682,56 +41826,56 @@ module.exports = function () { var component, componentView; var componentTypes = [{ id: 'cell', + model: __webpack_require__(153), + view: __webpack_require__(154) + }, { + id: 'row', model: __webpack_require__(155), view: __webpack_require__(156) }, { - id: 'row', + id: 'table', model: __webpack_require__(157), view: __webpack_require__(158) }, { - id: 'table', + id: 'thead', model: __webpack_require__(159), view: __webpack_require__(160) - }, { - id: 'thead', - model: __webpack_require__(161), - view: __webpack_require__(162) }, { id: 'tbody', model: __webpack_require__(19), - view: __webpack_require__(163) + view: __webpack_require__(161) }, { id: 'tfoot', + model: __webpack_require__(162), + view: __webpack_require__(163) + }, { + id: 'map', model: __webpack_require__(164), view: __webpack_require__(165) }, { - id: 'map', + id: 'link', model: __webpack_require__(166), view: __webpack_require__(167) }, { - id: 'link', + id: 'video', model: __webpack_require__(168), view: __webpack_require__(169) - }, { - id: 'video', - model: __webpack_require__(170), - view: __webpack_require__(171) }, { id: 'image', model: __webpack_require__(20), view: __webpack_require__(15) }, { id: 'script', + model: __webpack_require__(170), + view: __webpack_require__(171) + }, { + id: 'svg', model: __webpack_require__(172), view: __webpack_require__(173) }, { - id: 'svg', + id: 'textnode', model: __webpack_require__(174), view: __webpack_require__(175) - }, { - id: 'textnode', - model: __webpack_require__(176), - view: __webpack_require__(177) }, { id: 'text', model: __webpack_require__(51), @@ -41743,6 +41887,7 @@ module.exports = function () { }]; return { + Component: Component, Components: Components, @@ -42161,7 +42306,7 @@ module.exports = function () { }; /***/ }), -/* 151 */ +/* 149 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42203,7 +42348,7 @@ module.exports = { }; /***/ }), -/* 152 */ +/* 150 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42212,11 +42357,10 @@ module.exports = { var _underscore = __webpack_require__(1); var Backbone = __webpack_require__(0); -var Trait = __webpack_require__(153); -var TraitFactory = __webpack_require__(154); +var Trait = __webpack_require__(151); +var TraitFactory = __webpack_require__(152); module.exports = Backbone.Collection.extend({ - model: Trait, initialize: function initialize(coll) { @@ -42253,7 +42397,7 @@ module.exports = Backbone.Collection.extend({ }); /***/ }), -/* 153 */ +/* 151 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42264,13 +42408,14 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var _underscore = __webpack_require__(1); module.exports = __webpack_require__(0).Model.extend({ - defaults: { type: 'text', // text, number, range, select label: '', name: '', min: '', max: '', + unit: '', + step: 1, value: '', target: '', default: '', @@ -42314,6 +42459,19 @@ module.exports = __webpack_require__(0).Model.extend({ target.set('attributes', attrs); } }, + setValueFromInput: function setValueFromInput(value) { + var final = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; + var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + var toSet = { value: value }; + this.set(toSet, _extends({}, opts, { avoidStore: 1 })); + + // Have to trigger the change + if (final) { + this.set('value', '', opts); + this.set(toSet, opts); + } + }, /** @@ -42335,7 +42493,7 @@ module.exports = __webpack_require__(0).Model.extend({ }); /***/ }), -/* 154 */ +/* 152 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42368,7 +42526,9 @@ module.exports = function () { // Define placeholder switch (prop) { - case 'title':case 'alt':case 'id': + case 'title': + case 'alt': + case 'id': obj.placeholder = config.labelPlhText; break; case 'href': @@ -42392,7 +42552,7 @@ module.exports = function () { }; /***/ }), -/* 155 */ +/* 153 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42403,13 +42563,11 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Component = __webpack_require__(4); module.exports = Component.extend({ - defaults: _extends({}, Component.prototype.defaults, { type: 'cell', tagName: 'td', draggable: ['tr'] }) - }, { isComponent: function isComponent(el) { var result = ''; @@ -42427,7 +42585,7 @@ module.exports = Component.extend({ }); /***/ }), -/* 156 */ +/* 154 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42439,7 +42597,7 @@ var ComponentView = __webpack_require__(3); module.exports = ComponentView.extend({}); /***/ }), -/* 157 */ +/* 155 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42450,7 +42608,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Component = __webpack_require__(4); module.exports = Component.extend({ - defaults: _extends({}, Component.prototype.defaults, { type: 'row', tagName: 'tr', @@ -42482,7 +42639,7 @@ module.exports = Component.extend({ }); /***/ }), -/* 158 */ +/* 156 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42494,7 +42651,7 @@ var ComponentView = __webpack_require__(3); module.exports = ComponentView.extend({}); /***/ }), -/* 159 */ +/* 157 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42505,7 +42662,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Component = __webpack_require__(4); module.exports = Component.extend({ - defaults: _extends({}, Component.prototype.defaults, { type: 'table', tagName: 'table', @@ -42530,7 +42686,7 @@ module.exports = Component.extend({ }); /***/ }), -/* 160 */ +/* 158 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42544,7 +42700,7 @@ module.exports = ComponentView.extend({ }); /***/ }), -/* 161 */ +/* 159 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42555,12 +42711,10 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var ComponentTableBody = __webpack_require__(19); module.exports = ComponentTableBody.extend({ - defaults: _extends({}, ComponentTableBody.prototype.defaults, { type: 'thead', tagName: 'thead' }) - }, { isComponent: function isComponent(el) { var result = ''; @@ -42574,7 +42728,7 @@ module.exports = ComponentTableBody.extend({ }); /***/ }), -/* 162 */ +/* 160 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42586,7 +42740,7 @@ var ComponentView = __webpack_require__(3); module.exports = ComponentView.extend({}); /***/ }), -/* 163 */ +/* 161 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42598,7 +42752,7 @@ var ComponentView = __webpack_require__(3); module.exports = ComponentView.extend({}); /***/ }), -/* 164 */ +/* 162 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42609,12 +42763,10 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var ComponentTableBody = __webpack_require__(19); module.exports = ComponentTableBody.extend({ - defaults: _extends({}, ComponentTableBody.prototype.defaults, { type: 'tfoot', tagName: 'tfoot' }) - }, { isComponent: function isComponent(el) { var result = ''; @@ -42628,7 +42780,7 @@ module.exports = ComponentTableBody.extend({ }); /***/ }), -/* 165 */ +/* 163 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42640,7 +42792,7 @@ var ComponentView = __webpack_require__(3); module.exports = ComponentView.extend({}); /***/ }), -/* 166 */ +/* 164 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42650,7 +42802,6 @@ var Component = __webpack_require__(20); var OComponent = __webpack_require__(4); module.exports = Component.extend({ - defaults: _.extend({}, Component.prototype.defaults, { type: 'map', void: 0, @@ -42724,7 +42875,6 @@ module.exports = Component.extend({ if (qr.t) this.set('mapType', qr.t); } }, { - /** * Detect if the passed element is a valid component. * In case the element is valid an object abstracted @@ -42744,7 +42894,7 @@ module.exports = Component.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 167 */ +/* 165 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42754,7 +42904,6 @@ var Backbone = __webpack_require__(0); var ComponentView = __webpack_require__(15); module.exports = ComponentView.extend({ - tagName: 'div', events: {}, @@ -42774,7 +42923,7 @@ module.exports = ComponentView.extend({ }, getIframe: function getIframe() { if (!this.iframe) { - var ifrm = document.createElement("iframe"); + var ifrm = document.createElement('iframe'); ifrm.src = this.model.get('src'); ifrm.frameBorder = 0; ifrm.style.height = '100%'; @@ -42797,7 +42946,7 @@ module.exports = ComponentView.extend({ }); /***/ }), -/* 168 */ +/* 166 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42808,7 +42957,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Component = __webpack_require__(51); module.exports = Component.extend({ - defaults: _extends({}, Component.prototype.defaults, { type: 'link', tagName: 'a', @@ -42861,7 +43009,7 @@ module.exports = Component.extend({ }); /***/ }), -/* 169 */ +/* 167 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42887,21 +43035,21 @@ module.exports = ComponentView.extend({ }); /***/ }), -/* 170 */ +/* 168 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -/* WEBPACK VAR INJECTION */(function(_) { + + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var Component = __webpack_require__(20); var OComponent = __webpack_require__(4); - var yt = 'yt'; var vi = 'vi'; module.exports = Component.extend({ - - defaults: _.extend({}, Component.prototype.defaults, { + defaults: _extends({}, Component.prototype.defaults, { type: 'video', tagName: 'video', videoId: '', @@ -42938,6 +43086,13 @@ module.exports = Component.extend({ this.listenTo(this, 'change:provider', this.updateTraits); this.listenTo(this, 'change:videoId', this.updateSrc); }, + initToolbar: function initToolbar() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + OComponent.prototype.initToolbar.apply(this, args); + }, /** @@ -42948,7 +43103,8 @@ module.exports = Component.extend({ var uri = this.parseUri(this.get('src')); var qr = uri.query; switch (prov) { - case yt:case vi: + case yt: + case vi: var videoId = uri.pathname.split('/').pop(); this.set('videoId', videoId); if (qr.autoplay) this.set('autoplay', 1); @@ -42984,14 +43140,15 @@ module.exports = Component.extend({ * @private */ getAttrToHTML: function getAttrToHTML() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } var attr = Component.prototype.getAttrToHTML.apply(this, args); var prov = this.get('provider'); switch (prov) { - case yt:case vi: + case yt: + case vi: break; default: if (this.get('loop')) attr.loop = 'loop'; @@ -43169,7 +43326,6 @@ module.exports = Component.extend({ return url; } }, { - /** * Detect if the passed element is a valid component. * In case the element is valid an object abstracted @@ -43193,10 +43349,9 @@ module.exports = Component.extend({ return result; } }); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 171 */ +/* 169 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -43207,7 +43362,6 @@ var ComponentView = __webpack_require__(15); var OComponentView = __webpack_require__(3); module.exports = ComponentView.extend({ - tagName: 'div', events: {}, @@ -43259,7 +43413,8 @@ module.exports = ComponentView.extend({ var videoEl = this.videoEl; var md = this.model; switch (prov) { - case 'yt':case 'vi': + case 'yt': + case 'vi': this.model.trigger('change:videoId'); break; default: @@ -43324,7 +43479,7 @@ module.exports = ComponentView.extend({ }); /***/ }), -/* 172 */ +/* 170 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -43333,14 +43488,12 @@ module.exports = ComponentView.extend({ var Component = __webpack_require__(4); module.exports = Component.extend({ - defaults: _.extend({}, Component.prototype.defaults, { type: 'script', droppable: false, draggable: false, layerable: false }) - }, { isComponent: function isComponent(el) { if (el.tagName == 'SCRIPT') { @@ -43358,7 +43511,7 @@ module.exports = Component.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 173 */ +/* 171 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -43368,7 +43521,6 @@ var Backbone = __webpack_require__(0); var ComponentView = __webpack_require__(15); module.exports = ComponentView.extend({ - tagName: 'script', events: {}, @@ -43385,7 +43537,7 @@ module.exports = ComponentView.extend({ var onload = model.get('onload'); var svar = 'script' + scriptCount; var svarNext = 'script' + (scriptCount + 1); - content = "var " + svar + " = document.createElement('script');\n" + svar + ".onload = function(){\n" + (onload ? onload + "();\n" : '') + "typeof " + svarNext + "Start == 'function' && " + svarNext + "Start();\n" + "};\n" + svar + ".src = '" + src + "';\n" + "function " + svar + "Start() { document.body.appendChild(" + svar + "); };\n" + (!scriptCount ? svar + "Start();" : ''); + content = 'var ' + svar + " = document.createElement('script');\n" + svar + '.onload = function(){\n' + (onload ? onload + '();\n' : '') + 'typeof ' + svarNext + "Start == 'function' && " + svarNext + 'Start();\n' + '};\n' + svar + ".src = '" + src + "';\n" + 'function ' + svar + 'Start() { document.body.appendChild(' + svar + '); };\n' + (!scriptCount ? svar + 'Start();' : ''); if (em) { em.set('scriptCount', scriptCount + 1); } @@ -43399,7 +43551,7 @@ module.exports = ComponentView.extend({ }); /***/ }), -/* 174 */ +/* 172 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -43410,7 +43562,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var Component = __webpack_require__(4); module.exports = Component.extend({ - defaults: _extends({}, Component.prototype.defaults, { highlightable: 0 }), @@ -43439,7 +43590,7 @@ module.exports = Component.extend({ }); /***/ }), -/* 175 */ +/* 173 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -43448,15 +43599,13 @@ module.exports = Component.extend({ var ComponentView = __webpack_require__(3); module.exports = ComponentView.extend({ - _createElement: function _createElement(tagName) { return document.createElementNS('http://www.w3.org/2000/svg', tagName); } - }); /***/ }), -/* 176 */ +/* 174 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -43465,7 +43614,6 @@ module.exports = ComponentView.extend({ var Component = __webpack_require__(4); module.exports = Component.extend({ - defaults: _.extend({}, Component.prototype.defaults, { droppable: false, editable: true @@ -43489,7 +43637,7 @@ module.exports = Component.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 177 */ +/* 175 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -43500,7 +43648,7 @@ var Backbone = __webpack_require__(0); module.exports = Backbone.View.extend({}); /***/ }), -/* 178 */ +/* 176 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -43508,16 +43656,21 @@ module.exports = Backbone.View.extend({}); var _mixins = __webpack_require__(2); +var _Droppable = __webpack_require__(177); + +var _Droppable2 = _interopRequireDefault(_Droppable); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + module.exports = function () { var c = {}, - defaults = __webpack_require__(179), - Canvas = __webpack_require__(180), - CanvasView = __webpack_require__(182); + defaults = __webpack_require__(178), + Canvas = __webpack_require__(179), + CanvasView = __webpack_require__(181); var canvas; var frameRect; return { - /** * Used inside RTE * @private @@ -43724,11 +43877,11 @@ module.exports = function () { /** - * Get the offset of the element - * @param {HTMLElement} el - * @return {Object} - * @private - */ + * Get the offset of the element + * @param {HTMLElement} el + * @return {Object} + * @private + */ offset: function offset(el) { return CanvasView.offset(el); }, @@ -43928,6 +44081,9 @@ module.exports = function () { getScrollListeners: function getScrollListeners() { return [this.getFrameEl().contentWindow, this.getElement()]; }, + postRender: function postRender() { + if ((0, _mixins.hasDnd)(c.em)) this.droppable = new _Droppable2.default(c.em); + }, /** @@ -43942,14 +44098,194 @@ module.exports = function () { }; /***/ }), -/* 179 */ +/* 177 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -module.exports = { +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* + This class makes the canvas droppable + */ + +var _mixins = __webpack_require__(2); + +var _underscore = __webpack_require__(1); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Droppable = function () { + function Droppable(em) { + _classCallCheck(this, Droppable); + + this.em = em; + var el = em.get('DomComponents').getWrapper().getEl(); + this.el = el; + this.counter = 0; + (0, _underscore.bindAll)(this, 'handleDragEnter', 'handleDragOver', 'handleDrop', 'handleDragLeave'); + (0, _mixins.on)(el, 'dragenter', this.handleDragEnter); + (0, _mixins.on)(el, 'dragover', this.handleDragOver); + (0, _mixins.on)(el, 'drop', this.handleDrop); + (0, _mixins.on)(el, 'dragleave', this.handleDragLeave); + return this; + } + + _createClass(Droppable, [{ + key: 'endDrop', + value: function endDrop(cancel, ev) { + var em = this.em; + this.counter = 0; + this.over = 0; + // force out like in BlockView + var sorter = this.sorter; + cancel && (sorter.moved = 0); + sorter.endMove(); + em.trigger('canvas:dragend', ev); + } + }, { + key: 'handleDragLeave', + value: function handleDragLeave(ev) { + this.updateCounter(-1, ev); + } + }, { + key: 'updateCounter', + value: function updateCounter(value, ev) { + this.counter += value; + this.counter === 0 && this.endDrop(1, ev); + } + }, { + key: 'handleDragEnter', + value: function handleDragEnter(ev) { + var em = this.em; + var dt = ev.dataTransfer; + this.updateCounter(1, ev); + if (this.over) return; + this.over = 1; + var utils = em.get('Utils'); + var canvas = em.get('Canvas'); + this.sorter = new utils.Sorter({ + em: em, + wmargin: 1, + nested: 1, + canvasRelative: 1, + direction: 'a', + container: canvas.getBody(), + placer: canvas.getPlacerEl(), + eventMoving: 'mousemove dragover', + containerSel: '*', + itemSel: '*', + pfx: 'gjs-', + onStart: function onStart() { + return em.stopDefault(); + }, + onEndMove: function onEndMove(model) { + em.runDefault(); + + if (model && model.get && model.get('activeOnRender')) { + model.trigger('active'); + model.set('activeOnRender', 0); + } + + model && em.trigger('canvas:drop', dt, model); + }, + document: canvas.getFrameEl().contentDocument + }); + // For security reason I can't read the drag data on dragenter, but + // as I need it for the Sorter context I will use `dragContent` or just + // any not empty element + var content = em.get('dragContent') || '
'; + this.sorter.setDropContent(content); + this.sorter.startSort(); + em.trigger('canvas:dragenter', dt, content); + } + + /** + * Always need to have this handler active for enabling the drop + * @param {Event} ev + */ + + }, { + key: 'handleDragOver', + value: function handleDragOver(ev) { + ev.preventDefault(); + this.em.trigger('canvas:dragover', ev); + } + }, { + key: 'handleDrop', + value: function handleDrop(ev) { + ev.preventDefault(); + var dt = ev.dataTransfer; + var content = this.getContentByData(dt).content; + ev.target.style.border = ''; + + if (content) { + this.sorter.setDropContent(content); + } else { + this.sorter.moved = 0; + } + + this.endDrop(0, ev); + } + }, { + key: 'getContentByData', + value: function getContentByData(dataTransfer) { + var em = this.em; + var types = dataTransfer.types; + var files = dataTransfer.files; + var content = dataTransfer.getData('text'); + + if (files.length) { + content = []; + for (var i = 0; i < files.length; i++) { + var file = files[i]; + var type = file.type.split('/')[0]; + + if (type == 'image') { + content.push({ + type: type, + file: file, + attributes: { alt: file.name } + }); + } + } + } else if (types.indexOf('text/html') >= 0) { + content = dataTransfer.getData('text/html').replace(/<\/?meta[^>]*>/g, ''); + } else if (types.indexOf('text/uri-list') >= 0) { + content = { + type: 'link', + attributes: { href: content }, + content: content + }; + } else if (types.indexOf('text/json') >= 0) { + var json = dataTransfer.getData('text/json'); + json && (content = JSON.parse(json)); + } + + var result = { content: content }; + em.trigger('canvas:dragdata', dataTransfer, result); + + return result; + } + }]); + + return Droppable; +}(); + +exports.default = Droppable; + +/***/ }), +/* 178 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +module.exports = { stylePrefix: 'cv-', // Coming soon @@ -43982,21 +44318,19 @@ module.exports = { * } */ customBadgeLabel: '' - }; /***/ }), -/* 180 */ +/* 179 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var Backbone = __webpack_require__(0); -var Frame = __webpack_require__(181); +var Frame = __webpack_require__(180); module.exports = Backbone.Model.extend({ - defaults: { frame: '', wrapper: '', @@ -44010,7 +44344,7 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 181 */ +/* 180 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -44019,24 +44353,22 @@ module.exports = Backbone.Model.extend({ var Backbone = __webpack_require__(0); module.exports = Backbone.Model.extend({ - defaults: { wrapper: '', width: '', height: '', attributes: {} } - }); /***/ }), -/* 182 */ +/* 181 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(Backbone, _) { -var FrameView = __webpack_require__(183); +var FrameView = __webpack_require__(182); var $ = Backbone.$; module.exports = Backbone.View.extend({ @@ -44134,7 +44466,7 @@ module.exports = Backbone.View.extend({ var colorWarn = '#ffca6f'; - var baseCss = '\n * {\n box-sizing: border-box;\n }\n html, body, #wrapper {\n min-height: 100%;\n }\n body {\n margin: 0;\n height: 100%;\n background-color: #fff\n }\n #wrapper {\n overflow: auto\n }\n '; + var baseCss = '\n * {\n box-sizing: border-box;\n }\n html, body, #wrapper {\n min-height: 100%;\n }\n body {\n margin: 0;\n height: 100%;\n background-color: #fff\n }\n #wrapper {\n overflow: auto;\n overflow-x: hidden;\n }\n '; // Remove `html { height: 100%;}` from the baseCss as it gives jumpings // effects (on ENTER) with RTE like CKEditor (maybe some bug there?!?) // With `body {height: auto;}` jumps in CKEditor are removed but in @@ -44298,7 +44630,7 @@ module.exports = Backbone.View.extend({ // In editor, I make use of setTimeout as during the append process of elements // those will not be available immediatly, therefore 'item' variable var script = document.createElement('script'); - script.innerText = '\n setTimeout(function() {\n var item = document.getElementById(\'' + id + '\');\n if (!item) return;\n (function(){' + model.getScriptString() + '}.bind(item))()\n }, 1);'; + script.innerText = '\n setTimeout(function() {\n var item = document.getElementById(\'' + id + '\');\n if (!item) return;\n (function(){\n ' + model.getScriptString() + ';\n }.bind(item))()\n }, 1);'; view.scriptContainer.get(0).appendChild(script); }, @@ -44346,7 +44678,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1))) /***/ }), -/* 183 */ +/* 182 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -44357,11 +44689,9 @@ var _underscore = __webpack_require__(1); var motionsEv = 'transitionend oTransitionEnd transitionend webkitTransitionEnd'; module.exports = __webpack_require__(0).View.extend({ - tagName: 'iframe', attributes: { - src: 'about:blank', allowfullscreen: 'allowfullscreen' }, @@ -44382,11 +44712,18 @@ module.exports = __webpack_require__(0).View.extend({ var em = this.em; var device = em.getDeviceModel(); var style = this.el.style; - style.width = device ? device.get('width') : ''; - style.height = device ? device.get('height') : ''; + var currW = style.width || ''; + var currH = style.height || ''; + var newW = device ? device.get('width') : ''; + var newH = device ? device.get('height') : ''; + var noChanges = currW == newW && currH == newH; + style.width = newW; + style.height = newH; this.udpateOffset(); + // Prevent fixed highlighting box which appears when on + // component hover during the animation em.stopDefault({ preserveSelected: 1 }); - this.$el.on(motionsEv, this.udpateOffset); + noChanges ? this.udpateOffset() : this.$el.on(motionsEv, this.udpateOffset); }, udpateOffset: function udpateOffset() { var em = this.em; @@ -44408,7 +44745,7 @@ module.exports = __webpack_require__(0).View.extend({ }); /***/ }), -/* 184 */ +/* 183 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -44421,8 +44758,8 @@ module.exports = function () { var c = {}, commands = {}, defaultCommands = {}, - defaults = __webpack_require__(185), - AbsCommands = __webpack_require__(186); + defaults = __webpack_require__(184), + AbsCommands = __webpack_require__(185); // Need it here as it would be used below var add = function add(id, obj) { @@ -44436,7 +44773,6 @@ module.exports = function () { }; return { - /** * Name of the module * @type {String} @@ -44464,27 +44800,27 @@ module.exports = function () { if (obj.id) this.add(obj.id, obj); } - var ViewCode = __webpack_require__(187); + var ViewCode = __webpack_require__(186); defaultCommands['select-comp'] = __webpack_require__(21); defaultCommands['create-comp'] = __webpack_require__(22); - defaultCommands['delete-comp'] = __webpack_require__(192); - defaultCommands['image-comp'] = __webpack_require__(193); - defaultCommands['move-comp'] = __webpack_require__(194); - defaultCommands['text-comp'] = __webpack_require__(195); + defaultCommands['delete-comp'] = __webpack_require__(191); + defaultCommands['image-comp'] = __webpack_require__(192); + defaultCommands['move-comp'] = __webpack_require__(193); + defaultCommands['text-comp'] = __webpack_require__(194); defaultCommands['insert-custom'] = __webpack_require__(54); defaultCommands['export-template'] = ViewCode; - defaultCommands['sw-visibility'] = __webpack_require__(196); - defaultCommands['open-layers'] = __webpack_require__(197); - defaultCommands['open-sm'] = __webpack_require__(200); - defaultCommands['open-tm'] = __webpack_require__(201); - defaultCommands['open-blocks'] = __webpack_require__(202); - defaultCommands['open-assets'] = __webpack_require__(203); - defaultCommands['show-offset'] = __webpack_require__(204); - defaultCommands['select-parent'] = __webpack_require__(205); - defaultCommands.fullscreen = __webpack_require__(206); - defaultCommands.preview = __webpack_require__(207); - defaultCommands.resize = __webpack_require__(208); - defaultCommands.drag = __webpack_require__(209); + defaultCommands['sw-visibility'] = __webpack_require__(195); + defaultCommands['open-layers'] = __webpack_require__(196); + defaultCommands['open-sm'] = __webpack_require__(199); + defaultCommands['open-tm'] = __webpack_require__(200); + defaultCommands['open-blocks'] = __webpack_require__(201); + defaultCommands['open-assets'] = __webpack_require__(202); + defaultCommands['show-offset'] = __webpack_require__(203); + defaultCommands['select-parent'] = __webpack_require__(204); + defaultCommands.fullscreen = __webpack_require__(205); + defaultCommands.preview = __webpack_require__(206); + defaultCommands.resize = __webpack_require__(207); + defaultCommands.drag = __webpack_require__(208); defaultCommands['tlb-delete'] = { run: function run(ed) { @@ -44511,21 +44847,36 @@ module.exports = function () { var collection = sel.collection; var index = collection.indexOf(sel); - collection.add(sel.clone(), { at: index + 1 }); + var added = collection.add(sel.clone(), { at: index + 1 }); sel.emitUpdate(); + ed.trigger('component:clone', added); } }; defaultCommands['tlb-move'] = { run: function run(ed, sender, opts) { + var dragger = void 0; + var em = ed.getModel(); + var event = opts && opts.event; var sel = ed.getSelected(); - var dragger; + var toolbarStyle = ed.Canvas.getToolbarEl().style; + var nativeDrag = event.type == 'dragstart'; + + var hideTlb = function hideTlb() { + toolbarStyle.display = 'none'; + em.stopDefault(); + }; if (!sel || !sel.get('draggable')) { console.warn('The element is not draggable'); return; } + // Without setTimeout the ghost image disappears + nativeDrag ? setTimeout(function () { + return hideTlb; + }, 0) : hideTlb(); + var onStart = function onStart(e, opts) { console.log('start mouse pos ', opts.start); console.log('el rect ', opts.elRect); @@ -44536,7 +44887,7 @@ module.exports = function () { var onEnd = function onEnd(e, opts) { em.runDefault(); - em.set('selectedComponent', sel); + em.setSelected(sel); sel.emitUpdate(); dragger && dragger.blur(); }; @@ -44546,23 +44897,23 @@ module.exports = function () { console.log('Current ', opts.current); }; - var toolbarEl = ed.Canvas.getToolbarEl(); - toolbarEl.style.display = 'none'; - var em = ed.getModel(); - em.stopDefault(); - if (em.get('designerMode')) { // TODO move grabbing func in editor/canvas from the Sorter dragger = editor.runCommand('drag', { el: sel.view.el, options: { - event: opts && opts.event, + event: event, onStart: onStart, onDrag: onDrag, onEnd: onEnd } }); } else { + if (nativeDrag) { + event.dataTransfer.setDragImage(sel.view.el, 0, 0); + //sel.set('status', 'freezed'); + } + var cmdMove = ed.Commands.get('move-comp'); cmdMove.onEndMoveFromModel = onEnd; cmdMove.initSorterFromModel(sel); @@ -44716,14 +45067,13 @@ module.exports = function () { */ /***/ }), -/* 185 */ +/* 184 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { - ESCAPE_KEY: 27, stylePrefix: 'com-', @@ -44747,7 +45097,7 @@ module.exports = { }; /***/ }), -/* 186 */ +/* 185 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -44756,7 +45106,6 @@ module.exports = { var $ = Backbone.$; module.exports = Backbone.View.extend({ - /** * Initialize method that can't be removed * @param {Object} o Options @@ -44874,7 +45223,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 187 */ +/* 186 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -44936,7 +45285,7 @@ module.exports = { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 188 */ +/* 187 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -44944,10 +45293,9 @@ module.exports = { var Backbone = __webpack_require__(0); var DomainViews = __webpack_require__(48); -var ToolbarButtonView = __webpack_require__(189); +var ToolbarButtonView = __webpack_require__(188); module.exports = DomainViews.extend({ - itemView: ToolbarButtonView, initialize: function initialize(opts) { @@ -44957,7 +45305,7 @@ module.exports = DomainViews.extend({ }); /***/ }), -/* 189 */ +/* 188 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -44966,10 +45314,11 @@ module.exports = DomainViews.extend({ var Backbone = __webpack_require__(0); module.exports = Backbone.View.extend({ - events: { - 'mousedown': 'handleClick' + events: function events() { + return this.model.get('events') || { + mousedown: 'handleClick' + }; }, - attributes: function attributes() { return this.model.get('attributes'); }, @@ -44979,6 +45328,9 @@ module.exports = Backbone.View.extend({ handleClick: function handleClick(event) { event.preventDefault(); event.stopPropagation(); + this.execCommand(event); + }, + execCommand: function execCommand(event) { var opts = { event: event }; var command = this.model.get('command'); var editor = this.editor; @@ -44999,19 +45351,19 @@ module.exports = Backbone.View.extend({ }); /***/ }), -/* 190 */ +/* 189 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var Backbone = __webpack_require__(0); -var ToolbarButton = __webpack_require__(191); +var ToolbarButton = __webpack_require__(190); module.exports = Backbone.Collection.extend({ model: ToolbarButton }); /***/ }), -/* 191 */ +/* 190 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45020,16 +45372,14 @@ module.exports = Backbone.Collection.extend({ model: ToolbarButton }); var Backbone = __webpack_require__(0); module.exports = Backbone.Model.extend({ - - defaults: { - command: '', - attributes: {} - } - + defaults: { + command: '', + attributes: {} + } }); /***/ }), -/* 192 */ +/* 191 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45112,7 +45462,7 @@ module.exports = _.extend({}, SelectComponent, { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1))) /***/ }), -/* 193 */ +/* 192 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45122,7 +45472,6 @@ var Backbone = __webpack_require__(0); var InsertCustom = __webpack_require__(54); module.exports = _.extend({}, InsertCustom, { - /** * Trigger before insert * @param {Object} object @@ -45153,7 +45502,7 @@ module.exports = _.extend({}, InsertCustom, { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 194 */ +/* 193 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45320,7 +45669,7 @@ module.exports = _.extend({}, SelectPosition, SelectComponent, { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1))) /***/ }), -/* 195 */ +/* 194 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45330,7 +45679,6 @@ var Backbone = __webpack_require__(0); var CreateComponent = __webpack_require__(22); module.exports = _.extend({}, CreateComponent, { - /** * This event is triggered at the beginning of a draw operation * @param {Object} component Object component before creation @@ -45357,7 +45705,7 @@ module.exports = _.extend({}, CreateComponent, { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 196 */ +/* 195 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45368,18 +45716,18 @@ module.exports = { ed.Canvas.getBody().className = this.ppfx + 'dashed'; }, stop: function stop(ed) { - ed.Canvas.getBody().className = ""; + ed.Canvas.getBody().className = ''; } }; /***/ }), -/* 197 */ +/* 196 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(Backbone) { -var Layers = __webpack_require__(198); +var Layers = __webpack_require__(197); var $ = Backbone.$; module.exports = { @@ -45416,7 +45764,7 @@ module.exports = { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 198 */ +/* 197 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45425,7 +45773,7 @@ module.exports = { module.exports = function () { var itemsView = void 0; var config = {}; - var defaults = __webpack_require__(199); + var defaults = __webpack_require__(198); var ItemView = __webpack_require__(55); var ItemsView = __webpack_require__(56); @@ -45446,9 +45794,10 @@ module.exports = function () { level: level, config: config, opened: opened + }; - // Show wrapper if requested - };if (config.showWrapper && collection.parent) { + // Show wrapper if requested + if (config.showWrapper && collection.parent) { View = ItemView; options.model = collection.parent; } else { @@ -45496,7 +45845,7 @@ module.exports = function () { }; /***/ }), -/* 199 */ +/* 198 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45519,7 +45868,7 @@ module.exports = { }; /***/ }), -/* 200 */ +/* 199 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45577,7 +45926,9 @@ module.exports = { * @private */ toggleSm: function toggleSm() { - if (!this.sender.get('active')) return; + var sender = this.sender; + if (sender && sender.get && !sender.get('active')) return; + if (this.target.get('selectedComponent')) { this.$cn2.show(); this.$header.hide(); @@ -45596,7 +45947,7 @@ module.exports = { }; /***/ }), -/* 201 */ +/* 200 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45629,7 +45980,7 @@ module.exports = { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 202 */ +/* 201 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45659,7 +46010,7 @@ module.exports = { }; /***/ }), -/* 203 */ +/* 202 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45693,7 +46044,7 @@ module.exports = { }; /***/ }), -/* 204 */ +/* 203 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45848,7 +46199,7 @@ module.exports = { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 205 */ +/* 204 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45860,7 +46211,7 @@ module.exports = { var comp = sel && sel.parent(); // Recurse through the parent() chain until a selectable parent is found - while (comp && !comp.get("selectable")) { + while (comp && !comp.get('selectable')) { comp = comp.parent(); } @@ -45869,7 +46220,7 @@ module.exports = { }; /***/ }), -/* 206 */ +/* 205 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -45918,7 +46269,7 @@ module.exports = { * it's enabled * @param {strinf} pfx Browser prefix * @param {Event} e - */ + */ fsChanged: function fsChanged(pfx, e) { var d = document; var ev = (pfx || '') + 'fullscreenchange'; @@ -45942,7 +46293,7 @@ module.exports = { }; /***/ }), -/* 207 */ +/* 206 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -46011,7 +46362,7 @@ module.exports = { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 208 */ +/* 207 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -46048,7 +46399,7 @@ module.exports = { }; /***/ }), -/* 209 */ +/* 208 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -46086,7 +46437,7 @@ module.exports = { }; /***/ }), -/* 210 */ +/* 209 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -46124,15 +46475,14 @@ module.exports = { */ module.exports = function () { var c = {}, - defaults = __webpack_require__(211), - Blocks = __webpack_require__(212), - BlockCategories = __webpack_require__(214), - BlocksView = __webpack_require__(215); + defaults = __webpack_require__(210), + Blocks = __webpack_require__(211), + BlockCategories = __webpack_require__(213), + BlocksView = __webpack_require__(214); var blocks, blocksVisible, blocksView; var categories = []; return { - /** * Name of the module * @type {String} @@ -46331,36 +46681,34 @@ module.exports = function () { }; /***/ }), -/* 211 */ +/* 210 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { - blocks: [], appendTo: '' - }; /***/ }), -/* 212 */ +/* 211 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var Backbone = __webpack_require__(0); -var Block = __webpack_require__(213); +var Block = __webpack_require__(212); module.exports = Backbone.Collection.extend({ model: Block }); /***/ }), -/* 213 */ +/* 212 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -46370,7 +46718,6 @@ var Backbone = __webpack_require__(0); var Category = __webpack_require__(57); module.exports = Backbone.Model.extend({ - defaults: { label: '', content: '', @@ -46395,7 +46742,7 @@ module.exports = Backbone.Model.extend({ }); /***/ }), -/* 214 */ +/* 213 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -46408,17 +46755,18 @@ module.exports = Backbone.Collection.extend({ }); /***/ }), -/* 215 */ +/* 214 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(_) { -var Backbone = __webpack_require__(0); -var BlockView = __webpack_require__(216); -var CategoryView = __webpack_require__(217); +var _underscore = __webpack_require__(1); -module.exports = Backbone.View.extend({ +var BlockView = __webpack_require__(215); +var CategoryView = __webpack_require__(216); + +module.exports = __webpack_require__(0).View.extend({ initialize: function initialize(opts, config) { _.bindAll(this, 'getSorter', 'onDrag', 'onDrop'); this.config = config || {}; @@ -46532,11 +46880,13 @@ module.exports = Backbone.View.extend({ // Check for categories if (category && this.categories) { - if (typeof category == 'string') { + if ((0, _underscore.isString)(category)) { category = { id: category, label: category }; + } else if ((0, _underscore.isObject)(category) && !category.id) { + category.id = category.label; } var catModel = this.categories.add(category); @@ -46597,23 +46947,27 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 216 */ +/* 215 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(Backbone) { +var _underscore = __webpack_require__(1); + var _mixins = __webpack_require__(2); module.exports = Backbone.View.extend({ - events: { - mousedown: 'startDrag' + mousedown: 'startDrag', + dragstart: 'handleDragStart', + dragend: 'handleDragEnd' }, initialize: function initialize(o) { var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + this.em = config.em; this.config = config; this.endDrag = this.endDrag.bind(this); this.ppfx = config.pStylePrefix || ''; @@ -46626,22 +46980,30 @@ module.exports = Backbone.View.extend({ * @private */ startDrag: function startDrag(e) { + var config = this.config; //Right or middel click - if (e.button !== 0) { - return; - } - - if (!this.config.getSorter) { - return; - } - - this.config.em.refreshCanvas(); - var sorter = this.config.getSorter(); + if (e.button !== 0 || !config.getSorter || this.el.draggable) return; + config.em.refreshCanvas(); + var sorter = config.getSorter(); sorter.setDragHelper(this.el, e); sorter.setDropContent(this.model.get('content')); sorter.startSort(this.el); (0, _mixins.on)(document, 'mouseup', this.endDrag); }, + handleDragStart: function handleDragStart(ev) { + var content = this.model.get('content'); + var isObj = (0, _underscore.isObject)(content); + var type = isObj ? 'text/json' : 'text'; + var data = isObj ? JSON.stringify(content) : content; + + // Note: data are not available on dragenter for security reason, + // but will use dragContent as I need it for the Sorter context + ev.dataTransfer.setData(type, data); + this.em.set('dragContent', content); + }, + handleDragEnd: function handleDragEnd() { + this.em.set('dragContent', ''); + }, /** @@ -46663,15 +47025,17 @@ module.exports = Backbone.View.extend({ var el = this.el; var pfx = this.ppfx; var className = pfx + 'block'; + var label = this.model.get('label'); el.className += ' ' + className + ' ' + pfx + 'one-bg ' + pfx + 'four-color-h'; - el.innerHTML = '
' + this.model.get('label') + '
'; + el.innerHTML = '
' + label + '
'; + (0, _mixins.hasDnd)(this.em) && el.setAttribute('draggable', true); return this; } }); /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 217 */ +/* 216 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -46680,7 +47044,6 @@ module.exports = Backbone.View.extend({ var Backbone = __webpack_require__(0); module.exports = Backbone.View.extend({ - template: _.template('\n
\n \n <%= label %>\n
\n
\n '), events: {}, @@ -46741,6 +47104,7 @@ module.exports = Backbone.View.extend({ label: this.model.get('label') }); this.el.className = this.className; + this.$el.css({ order: this.model.get('order') }); this.updateVisibility(); return this; } @@ -46748,7 +47112,7 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 218 */ +/* 217 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -46995,7 +47359,6 @@ module.exports = function (_ref) { return node.parentNode && node.parentNode.removeChild(node); }); }, - // For spectrum compatibility fn.bind = function (ev, h) { return this.on(ev, h); @@ -47091,7 +47454,7 @@ module.exports = function (_ref) { }; /***/ }), -/* 219 */ +/* 218 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -47139,16 +47502,15 @@ module.exports = Backbone.View.extend({ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 220 */ +/* 219 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = function (config) { - var c = config || {}, - defaults = __webpack_require__(221); + defaults = __webpack_require__(220); // Set default options for (var name in defaults) { @@ -47158,7 +47520,6 @@ module.exports = function (config) { var plugins = {}; return { - /** * Add new plugin. Plugins could not be overwritten * @param {string} id Plugin ID @@ -47207,7 +47568,7 @@ module.exports = function (config) { }; /***/ }), -/* 221 */ +/* 220 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; diff --git a/dist/grapes.min.js b/dist/grapes.min.js index 11bea23d1..b3375c07b 100644 --- a/dist/grapes.min.js +++ b/dist/grapes.min.js @@ -1,5 +1,5 @@ -/*! grapesjs - 0.12.58 */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.grapesjs=e():t.grapesjs=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=58)}([function(t,e,n){(function(i){var r,o;!function(s){var a="object"==typeof self&&self.self===self&&self||"object"==typeof i&&i.global===i&&i;r=[n(1),n(9),e],void 0!==(o=function(t,e,n){a.Backbone=s(a,n,t,e)}.apply(e,r))&&(t.exports=o)}(function(t,e,n,i){var r=t.Backbone,o=Array.prototype.slice;e.VERSION="1.3.3",e.$=i,e.noConflict=function(){return t.Backbone=r,this},e.emulateHTTP=!1,e.emulateJSON=!1;var s=function(t,e,i){switch(t){case 1:return function(){return n[e](this[i])};case 2:return function(t){return n[e](this[i],t)};case 3:return function(t,r){return n[e](this[i],l(t,this),r)};case 4:return function(t,r,o){return n[e](this[i],l(t,this),r,o)};default:return function(){var t=o.call(arguments);return t.unshift(this[i]),n[e].apply(n,t)}}},a=function(t,e,i){n.each(e,function(e,r){n[r]&&(t.prototype[r]=s(e,r,i))})},l=function(t,e){return n.isFunction(t)?t:n.isObject(t)&&!e._isModel(t)?c(t):n.isString(t)?function(e){return e.get(t)}:t},c=function(t){var e=n.matches(t);return function(t){return e(t.attributes)}},u=e.Events={},h=/\s+/,d=function(t,e,i,r,o){var s,a=0;if(i&&"object"==typeof i){void 0!==r&&"context"in o&&void 0===o.context&&(o.context=r);for(s=n.keys(i);athis.length&&(r=this.length),r<0&&(r+=this.length+1);var o,s,a=[],l=[],c=[],u=[],h={},d=e.add,f=e.merge,p=e.remove,g=!1,v=this.comparator&&null==r&&!1!==e.sort,m=n.isString(this.comparator)?this.comparator:null;for(s=0;s7),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(_,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var e=this.root.slice(0,-1)||"/";return this.location.replace(e+"#"+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 i=document.body,r=i.insertBefore(this.iframe,i.firstChild).contentWindow;r.document.open(),r.document.close(),r.location.hash="#"+this.fragment}var o=window.addEventListener||function(t,e){return attachEvent("on"+t,e)};if(this._usePushState?o("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?o("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var t=window.removeEventListener||function(t,e){return detachEvent("on"+t,e)};this._usePushState?t("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&t("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),I.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe&&(e=this.getHash(this.iframe.contentWindow)),e===this.fragment)return!1;this.iframe&&this.navigate(e),this.loadUrl()},loadUrl:function(t){return!!this.matchRoot()&&(t=this.fragment=this.getFragment(t),n.some(this.handlers,function(e){if(e.route.test(t))return e.callback(t),!0}))},navigate:function(t,e){if(!I.started)return!1;e&&!0!==e||(e={trigger:!!e}),t=this.getFragment(t||"");var n=this.root;""!==t&&"?"!==t.charAt(0)||(n=n.slice(0,-1)||"/");var i=n+t;if(t=this.decodeFragment(t.replace(F,"")),this.fragment!==t){if(this.fragment=t,this._usePushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,i);else{if(!this._wantsHashChange)return this.location.assign(i);if(this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getHash(this.iframe.contentWindow)){var r=this.iframe.contentWindow;e.replace||(r.document.open(),r.document.close()),this._updateHash(r.location,t,e.replace)}}return e.trigger?this.loadUrl(t):void 0}},_updateHash:function(t,e,n){if(n){var i=t.href.replace(/(javascript:|#).*$/,"");t.replace(i+"#"+e)}else t.hash="#"+e}}),e.history=new I;var z=function(t,e){var i,r=this;return i=t&&n.has(t,"constructor")?t.constructor:function(){return r.apply(this,arguments)},n.extend(i,r,e),i.prototype=n.create(r.prototype,t),i.prototype.constructor=i,i.__super__=r.prototype,i};b.extend=x.extend=P.extend=S.extend=I.extend=z;var $=function(){throw new Error('A "url" property or function must be specified')},R=function(t,e){var n=e.error;e.error=function(i){n&&n.call(e.context,t,i,e),t.trigger("error",t,i,e)}};return e})}).call(e,n(16))},function(t,e,n){var i,r;(function(){function n(t){function e(e,n,i,r,o,s){for(;o>=0&&o0?0:a-1;return arguments.length<3&&(r=n[s?s[l]:l],l+=t),e(n,i,r,s,l,a)}}function o(t){return function(e,n,i){n=S(n,i);for(var r=A(e),o=t>0?0:r-1;o>=0&&o0?s=o>=0?o:Math.max(o+a,s):a=o>=0?Math.min(o+1,a):o+a+1;else if(n&&o&&a)return o=n(i,r),i[o]===r?o:-1;if(r!==r)return o=e(p.call(i,s,a),C.isNaN),o>=0?o+s:-1;for(o=t>0?s:a-1;o>=0&&o=0&&e<=P};C.each=C.forEach=function(t,e,n){e=k(e,n);var i,r;if(O(t))for(i=0,r=t.length;i=0},C.invoke=function(t,e){var n=p.call(arguments,2),i=C.isFunction(e);return C.map(t,function(t){var r=i?e:t[e];return null==r?r:r.apply(t,n)})},C.pluck=function(t,e){return C.map(t,C.property(e))},C.where=function(t,e){return C.filter(t,C.matcher(e))},C.findWhere=function(t,e){return C.find(t,C.matcher(e))},C.max=function(t,e,n){var i,r,o=-1/0,s=-1/0;if(null==e&&null!=t){t=O(t)?t:C.values(t);for(var a=0,l=t.length;ao&&(o=i)}else e=S(e,n),C.each(t,function(t,n,i){((r=e(t,n,i))>s||r===-1/0&&o===-1/0)&&(o=t,s=r)});return o},C.min=function(t,e,n){var i,r,o=1/0,s=1/0;if(null==e&&null!=t){t=O(t)?t:C.values(t);for(var a=0,l=t.length;ai||void 0===n)return 1;if(ne?(s&&(clearTimeout(s),s=null),a=c,o=t.apply(i,r),s||(i=r=null)):s||!1===n.trailing||(s=setTimeout(l,u)),o}},C.debounce=function(t,e,n){var i,r,o,s,a,l=function(){var c=C.now()-s;c=0?i=setTimeout(l,e-c):(i=null,n||(a=t.apply(o,r),i||(o=r=null)))};return function(){o=this,r=arguments,s=C.now();var c=n&&!i;return i||(i=setTimeout(l,e)),c&&(a=t.apply(o,r),o=r=null),a}},C.wrap=function(t,e){return C.partial(e,t)},C.negate=function(t){return function(){return!t.apply(this,arguments)}},C.compose=function(){var t=arguments,e=t.length-1;return function(){for(var n=e,i=t[e].apply(this,arguments);n--;)i=t[n].call(this,i);return i}},C.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},C.before=function(t,e){var n;return function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}},C.once=C.partial(C.before,2);var D=!{toString:null}.propertyIsEnumerable("toString"),_=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];C.keys=function(t){if(!C.isObject(t))return[];if(y)return y(t);var e=[];for(var n in t)C.has(t,n)&&e.push(n);return D&&a(t,e),e},C.allKeys=function(t){if(!C.isObject(t))return[];var e=[];for(var n in t)e.push(n);return D&&a(t,e),e},C.values=function(t){for(var e=C.keys(t),n=e.length,i=Array(n),r=0;r":">",'"':""","'":"'","`":"`"},$=C.invert(z),R=function(t){var e=function(e){return t[e]},n="(?:"+C.keys(t).join("|")+")",i=RegExp(n),r=RegExp(n,"g");return function(t){return t=null==t?"":""+t,i.test(t)?t.replace(r,e):t}};C.escape=R(z),C.unescape=R($),C.result=function(t,e,n){var i=null==t?void 0:t[e];return void 0===i&&(i=n),C.isFunction(i)?i.call(t):i};var V=0;C.uniqueId=function(t){var e=++V+"";return t?t+e:e},C.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,j={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\u2028|\u2029/g,W=function(t){return"\\"+j[t]};C.template=function(t,e,n){!e&&n&&(e=n),e=C.defaults({},e,C.templateSettings);var i=RegExp([(e.escape||H).source,(e.interpolate||H).source,(e.evaluate||H).source].join("|")+"|$","g"),r=0,o="__p+='";t.replace(i,function(e,n,i,s,a){return o+=t.slice(r,a).replace(B,W),r=a+e.length,n?o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":i?o+="'+\n((__t=("+i+"))==null?'':__t)+\n'":s&&(o+="';\n"+s+"\n__p+='"),e}),o+="';\n",e.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var s=new Function(e.variable||"obj","_",o)}catch(t){throw t.source=o,t}var a=function(t){return s.call(this,t,C)};return a.source="function("+(e.variable||"obj")+"){\n"+o+"}",a},C.chain=function(t){var e=C(t);return e._chain=!0,e};var U=function(t,e){return t._chain?C(e).chain():e};C.mixin=function(t){C.each(C.functions(t),function(e){var n=C[e]=t[e];C.prototype[e]=function(){var t=[this._wrapped];return f.apply(t,arguments),U(this,n.apply(C,t))}})},C.mixin(C),C.each(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=u[t];C.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0],U(this,n)}}),C.each(["concat","join","slice"],function(t){var e=u[t];C.prototype[t]=function(){return U(this,e.apply(this._wrapped,arguments))}}),C.prototype.value=function(){return this._wrapped},C.prototype.valueOf=C.prototype.toJSON=C.prototype.value,C.prototype.toString=function(){return""+this._wrapped},i=[],void 0!==(r=function(){return C}.apply(e,i))&&(t.exports=r)}).call(this)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getUnitFromValue=e.normalizeFloat=e.shallowDiff=e.camelCase=e.matches=e.upFirst=e.off=e.on=void 0;var i=n(1),r=window.Element.prototype,o=r.matches||r.webkitMatchesSelector||r.mozMatchesSelector||r.msMatchesSelector,s=function(t,e){var n={},r=(0,i.keys)(e);for(var o in t)if(t.hasOwnProperty(o)){var s=t[o],a=e[o];r.indexOf(o)>=0?s!==a&&(n[o]=a):n[o]=null}for(var l in e)e.hasOwnProperty(l)&&(0,i.isUndefined)(t[l])&&(n[l]=e[l]);return n},a=function(t,e,n){e=e.split(/\s+/),t=t instanceof Array?t:[t];for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=0;if(isNaN(t))return n;if(t=parseFloat(t),Math.floor(t)!==t){var r=e.toString().split(".")[1];i=r?r.length:0}return i?parseFloat(t.toFixed(i)):t};e.on=a,e.off=l,e.upFirst=u,e.matches=o,e.camelCase=h,e.shallowDiff=s,e.normalizeFloat=d,e.getUnitFromValue=c},function(t,e,n){"use strict";(function(e){var i=n(1),r=n(50);t.exports=e.View.extend({className:function(){return this.getClasses()},tagName:function(){return this.model.get("tagName")},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.model,n=t.config||{};this.opts=t,this.config=n,this.em=n.em||"",this.pfx=n.stylePrefix||"",this.ppfx=n.pStylePrefix||"",this.attr=e.get("attributes"),this.classe=this.attr.class||[];var i=this.$el,r=e.get("classes");this.listenTo(e,"destroy remove",this.remove),this.listenTo(e,"change:style",this.updateStyle),this.listenTo(e,"change:attributes",this.updateAttributes),this.listenTo(e,"change:highlightable",this.updateHighlight),this.listenTo(e,"change:status",this.updateStatus),this.listenTo(e,"change:state",this.updateState),this.listenTo(e,"change:script",this.render),this.listenTo(e,"change",this.handleChange),this.listenTo(r,"add remove change",this.updateClasses),i.data("model",e),i.data("collection",e.get("components")),e.view=this,r.length&&this.importClasses(),this.init()},remove:function(){e.View.prototype.remove.apply(this);var t=this.childrenView;t&&t.stopListening()},init:function(){},handleChange:function(){var t=this.model;t.emitUpdate();for(var e in t.changed)t.emitUpdate(e)},importClasses:function(){var t=this.config.em.get("SelectorManager");t&&this.model.get("classes").each(function(e){t.add(e.get("name"))})},updateState:function(t){var e="hc-state";this.model.get("state")?this.$el.addClass(e):this.$el.removeClass(e)},updateStatus:function(t){var e=this.el,n=this.model.get("status"),i=this.pfx,r=this.ppfx,o=i+"selected",s=o+"-parent",a=r+"freezed",l=e.getAttribute("class")||"",c="";switch(n){case"selected":c=l+" "+o;break;case"selected-parent":c=l+" "+s;break;case"freezed":c=l+" "+a;break;default:this.$el.removeClass(o+" "+s+" "+a)}(c=c.trim())&&e.setAttribute("class",c)},updateHighlight:function(){var t=this.model.get("highlightable");this.setAttribute("data-highlightable",t?1:"")},updateStyle:function(){var t=this.em,e=this.model;t&&t.get("avoidInlineStyle")?(this.el.id=e.getId(),e.setStyle(e.getStyle())):this.setAttribute("style",e.styleToString())},updateClasses:function(){var t=this.model.get("classes").pluck("name").join(" ");this.setAttribute("class",t),this.updateStatus()},setAttribute:function(t,e){var n=this.$el;e?n.attr(t,e):n.removeAttr(t)},getClasses:function(){var t=this.model.get("attributes"),e=t.class||[];return e=(0,i.isArray)(e)?e:[e],e.length?e.join(" "):null},updateAttributes:function(){var t=this.model,e={},n=t.get("attributes"),i=t.get("src");for(var r in n)e[r]=n[r];i&&(e.src=i),this.$el.attr(e),this.updateHighlight(),this.updateStyle()},updateContent:function(){this.getChildrenContainer().innerHTML=this.model.get("content")},prevDef:function(t){t.preventDefault()},updateScript:function(){if(this.model.get("script")){var t=this.em;if(t){t.get("Canvas").getCanvasView().updateScript(this)}}},getChildrenContainer:function(){var t=this.el;return"function"==typeof this.getChildrenSelector?t=this.el.querySelector(this.getChildrenSelector()):this.getTemplate,t},renderChildren:function(){var t=this.getChildrenContainer(),e=new r({collection:this.model.get("components"),config:this.config,componentTypes:this.opts.componentTypes});e.render(t),this.childrenView=e;for(var n=Array.prototype.slice.call(e.el.childNodes),i=0,o=n.length;i0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.sm||n.em||"",s=this.parent(),a=s&&s.attributes;if(a&&a.propagate){var l={},c=a.propagate;c.forEach(function(t){return l[t]=s.get(t)}),l.propagate=c,l=i({},l,e),this.set(l)}var u=this.get("propagate");u&&this.set("propagate",(0,r.isArray)(u)?u:[u]),n&&n.config&&n.config.voidElements.indexOf(this.get("tagName"))>=0&&this.set("void",!0),n.em=o,this.opt=n,this.sm=o,this.em=o,this.config=n.config||{},this.set("attributes",this.get("attributes")||{}),this.listenTo(this,"change:script",this.scriptUpdated),this.listenTo(this,"change:traits",this.traitsUpdated),this.listenTo(this,"change:tagName",this.tagUpdated),this.listenTo(this,"change:attributes",this.attrUpdated),this.loadTraits(),this.initClasses(),this.initComponents(),this.initToolbar(),this.set("status",""),this.listenTo(this.get("classes"),"add remove change",function(){return t.emitUpdate("classes")}),this.init()},is:function(t){return!(this.get("type")!=t)},find:function(t){var e=[];return this.view.$el.find(t).each(function(t,n,i){var r=i.data("model");r&&e.push(r)}),e},tagUpdated:function(){var t=this.collection,e=t.indexOf(this);t.remove(this),t.add(this,{at:e})},attrUpdated:function(){var t=this,e=i({},this.previous("attributes")),n=i({},this.get("attributes")),s=(0,o.shallowDiff)(e,n);(0,r.keys)(s).forEach(function(e){return t.trigger("change:attributes:"+e)})},setAttributes:function(t){t=i({},t);var e=t.class;e&&this.setClass(e),delete t.class;var n=t.style;n&&this.setStyle(n),delete t.style,this.set("attributes",t)},getStyle:function(){var t=this.em;if(t&&t.getConfig("avoidInlineStyle")){var e=this.get("state"),n=t.get("CssComposer"),i=n.getIdRule(this.getId(),{state:e});if(this.rule=i,i)return i.getStyle()}return a.default.getStyle.call(this)},setStyle:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=this.em;if(s&&s.getConfig("avoidInlineStyle")){e=(0,r.isString)(e)?this.parseStyle(e):e;var l=this.get("state"),c=s.get("CssComposer"),u=this.getStyle();this.rule=c.setIdRule(this.getId(),e,i({},n,{state:l}));var h=(0,o.shallowDiff)(u,e);(0,r.keys)(h).forEach(function(e){return t.trigger("change:style:"+e)})}else e=a.default.setStyle.apply(this,arguments);return e},getAttributes:function(){var t=[],e=i({},this.get("attributes"));return this.get("classes").each(function(e){return t.push(e.get("name"))}),t.length&&(e.class=t.join(" ")),(0,r.isEmpty)(this.getStyle())||(0,r.has)(e,"id")||(e.id=this.getId()),e},addClass:function(t){var e=this.em.get("SelectorManager").addClass(t);return this.get("classes").add(e)},setClass:function(t){return this.get("classes").reset(),this.addClass(t)},removeClass:function(t){var e=[];t=(0,r.isArray)(t)?t:[t];var n=this.get("classes"),i=u.TYPE_CLASS;return t.forEach(function(t){t.split(" ").forEach(function(t){var r=n.where({name:t,type:i})[0];r&&e.push(n.remove(r))})}),e},initClasses:function(){var t=this.normalizeClasses(this.get("classes")||[]);return this.set("classes",new h(t)),this},initComponents:function(){var t=new c(null,this.opt);return t.parent=this,t.reset(this.get("components")),this.set("components",t),this},init:function(){},append:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.components().add(t,e);return(0,r.isArray)(n)?n:[n]},components:function(t){var e=this.get("components");if((0,r.isUndefined)(t))return e;e.reset(),t&&this.append(t)},parent:function(){var t=this.collection;return t&&t.parent},scriptUpdated:function(){this.set("scriptUpdated",1)},traitsUpdated:function(){var t=0,e=i({},this.get("attributes")),n=this.get("traits");if(!(n instanceof d))return void this.loadTraits();n.each(function(n){if(t=1,!n.get("changeProp")){var i=n.getInitValue();i&&(e[n.get("name")]=i)}}),t&&this.set("attributes",e)},initToolbar:function(){var t=this;if(!t.get("toolbar")){var e=[];t.collection&&e.push({attributes:{class:"fa fa-arrow-up"},command:"select-parent"}),t.get("draggable")&&e.push({attributes:{class:"fa fa-arrows"},command:"tlb-move"}),t.get("copyable")&&e.push({attributes:{class:"fa fa-clone"},command:"tlb-clone"}),t.get("removable")&&e.push({attributes:{class:"fa fa-trash-o"},command:"tlb-delete"}),t.set("toolbar",e)}},loadTraits:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new d([],this.opt);return n.setTarget(this),t=t||this.get("traits"),t.length&&n.add(t),this.set("traits",n,e),this},normalizeClasses:function(t){var e=[];if(this.sm.get){var n=this.sm.get("SelectorManager");if(n)return t.forEach(function(t){var i="";i="string"==typeof t?t:t.name;var r=n.add(i);e.push(r)}),e}},clone:function(t){var e=this.em,n=this.getStyle(),o=i({},this.attributes);return o.attributes=i({},o.attributes),delete o.attributes.id,o.components=[],o.classes=[],o.traits=[],this.get("components").each(function(t,e){o.components[e]=t.clone(1)}),this.get("traits").each(function(t,e){o.traits[e]=t.clone()}),this.get("classes").each(function(t,e){o.classes[e]=t.get("name")}),o.status="",o.view="",t&&(this.opt.collection=null),e&&e.getConfig("avoidInlineStyle")&&!(0,r.isEmpty)(n)&&(o.style=n),new this.constructor(o,this.opt)},getName:function(){var t=this.get("custom-name"),e=this.get("tagName");e="div"==e?"box":e;var n=this.get("type")||e;return n=n.charAt(0).toUpperCase()+n.slice(1),t||n},getIcon:function(){var t=this.get("icon");return t?t+" ":""},toHTML:function(t){var e=this,n=[],i=e.get("tagName"),o=e.get("void"),s=this.getAttrToHTML();for(var a in s){var l=s[a];(0,r.isUndefined)(l)||n.push(a+'="'+l+'"')}var c=n.length?" "+n.join(" "):"",u="<"+i+c+(o?"/":"")+">"+e.get("content");return e.get("components").each(function(t){return u+=t.toHTML()}),!o&&(u+=""),u},getAttrToHTML:function(){var t=this.getAttributes();return delete t.style,t},toJSON:function(){for(var t=arguments.length,e=Array(t),n=0;n\n '+this.templateLabel(t)+'\n
\n
\n '+this.templateInput(t)+"\n
\n "},templateLabel:function(t){var e=this.pfx;return'\n \n '+t.get("name")+'\n \n ⨯\n '},templateInput:function(t){return'\n
\n \n
\n '},events:function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}({change:"inputValueChanged"},"click [data-clear-style]","clear"),initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,i.bindAll)(this,"targetUpdated"),this.config=t.config||{};var e=this.config.em;this.em=e,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.target=t.target||{},this.propTarget=t.propTarget||{},this.onChange=t.onChange,this.onInputRender=t.onInputRender||{},this.customValue=t.customValue||{};var n=this.model;this.property=n.get("property"),this.input=null;var r=this.pfx;this.inputHolderId="#"+r+"input-holder",this.sector=n.collection&&n.collection.sector,n.view=this,n.get("value")||n.set("value",n.getDefaultValue()),e&&e.on("update:component:style:"+this.property,this.targetUpdated),this.listenTo(this.propTarget,"update",this.targetUpdated),this.listenTo(n,"destroy remove",this.remove),this.listenTo(n,"change:value",this.modelValueChanged),this.listenTo(n,"targetUpdated",this.targetUpdated),this.listenTo(n,"change:visible",this.updateVisibility),this.listenTo(n,"change:status",this.updateStatus);var o=this.init&&this.init.bind(this);o&&o()},updateStatus:function(){var t=this.model.get("status"),e=this.pfx,n=this.ppfx,i=this.config,r=n+"four-color",o=n+"color-warn",s=this.$el.children("."+e+"label"),a=this.getClearEl().style;switch(s.removeClass(r+" "+o),a.display="none",t){case"updated":s.addClass(r),i.clearProperties&&(a.display="inline");break;case"computed":s.addClass(o)}},clear:function(){this.getTargetModel().removeStyle(this.model.get("property")),this.targetUpdated()},getClearEl:function(){return this.el.querySelector("[data-clear-style]")},getTarget:function(){return this.getTargetModel()},getTargetModel:function(){return this.propTarget&&this.propTarget.model},getHelperModel:function(){return this.propTarget&&this.propTarget.helper},inputValueChanged:function(t){t&&t.stopPropagation(),this.model.setValue(this.getInputValue(),1,{fromInput:1}),this.elementUpdated()},elementUpdated:function(){this.setStatus("updated")},setStatus:function(t){this.model.set("status",t);var e=this.model.parent;e&&e.set("status",t)},targetUpdated:function(){if(this.checkVisibility()){var t=this.config,e=t.em,n=this.model,i="",r="",o=this.getTargetValue({ignoreDefault:1}),s=n.getDefaultValue(),a=this.getComputedValue();o?(i=o,t.highlightChanged&&(r="updated")):a&&t.showComputed&&a!=s?(i=a,t.highlightComputed&&(r="computed")):(i=s,r=""),n.setValue(i,0,{fromTarget:1}),this.setStatus(r),e&&(e.trigger("styleManager:change",this),e.trigger("styleManager:change:"+n.get("property"),this))}},checkVisibility:function(){var t=1;return this.config.hideNotStylable&&(this.isTargetStylable()&&this.isComponentStylable()?this.show():(this.hide(),t=0),this.sector&&this.sector.trigger("updateVisibility")),t},getTargetValue:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.model,i=this.getTargetModel(),r=this.customValue;if(!i)return t;if(t=i.getStyle()[n.get("property")],t||e.ignoreDefault||(t=n.getDefaultValue()),"function"==typeof r&&!e.ignoreCustomValue){var o=n.collection.indexOf(n),s=r(this,o);s&&(t=s)}return t},getComputedValue:function(){var t=this.propTarget,e=t.computed||{},n=t.computedDefault||{},i=this.config.avoidComputed||[],o=this.model.get("property"),s=i.indexOf(o)<0,a=e[o],l=n[(0,r.camelCase)(o)];return e&&s&&l!==a&&a},getInputValue:function(){var t=this.getInputEl();return t?t.value:""},modelValueChanged:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.config.em,r=this.model,o=r.getFullValue(),s=this.getTarget(),a=this.onChange;n.fromInput||this.setValue(o),s&&this.isTargetStylable()&&this.isComponentStylable()&&(n.fromTarget||(a&&!n.fromParent?a(s,this,n):this.updateTargetStyle(o,null,n)),i&&(i.trigger("component:update",s),i.trigger("component:styleUpdate",s),i.trigger("component:styleUpdate:"+r.get("property"),s)))},updateTargetStyle:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=e||this.model.get("property"),r=this.getTarget(),o=r.getStyle();t?o[i]=t:delete o[i],r.setStyle(o,n);var s=this.getHelperModel();s&&s.setStyle(o,n)},isTargetStylable:function(t){this.model.get("id");var e=t||this.getTarget(),n=this.model,r=n.get("property"),o=n.get("toRequire"),s=e.get("unstylable"),a=e.get("stylable-require"),l=e.get("stylable");return(0,i.isArray)(l)&&(l=l.indexOf(r)>=0),(0,i.isArray)(s)&&(l=s.indexOf(r)<0),o&&(l=a&&a.indexOf(r)>=0||!t),l},isComponentStylable:function(){var t=this.em,e=t&&t.get("selectedComponent");return!e||this.isTargetStylable(e)},setRawValue:function(t){this.setValue(this.model.parseValue(t))},setValue:function(t){var e=this.model,n=t||e.getDefaultValue(),i=this.getInputEl();i&&(i.value=n)},getInputEl:function(){return this.input||(this.input=this.el.querySelector("input")),this.input},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)},cleanValue:function(){this.setValue("")},render:function(){var t=this.pfx,e=this.model,n=this.el;n.innerHTML=this.template(e),n.className=t+"property "+t+e.get("type"),this.updateStatus();var i=this.onRender&&this.onRender.bind(this);i&&i(),this.setValue(e.get("value"),{targetUpdate:1})}})}).call(e,n(0))},function(t,e,n){!function(e,n){t.exports=n()}(0,function(){"use strict";function t(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}function e(t){for(var e=t.childNodes.length;e>0;--e)t.removeChild(t.firstChild);return t}function n(t,n){return e(t).appendChild(n)}function i(t,e,n,i){var r=document.createElement(t);if(n&&(r.className=n),i&&(r.style.cssText=i),"string"==typeof e)r.appendChild(document.createTextNode(e));else if(e)for(var o=0;o=e)return s+(e-o);s+=a-o,s+=n-s%n,o=a+1}}function d(t,e){for(var n=0;n=e)return i+Math.min(s,e-r);if(r+=o-i,r+=n-r%n,i=o+1,r>=e)return i}}function p(t){for(;qs.length<=t;)qs.push(g(qs)+" ");return qs[t]}function g(t){return t[t.length-1]}function v(t,e){for(var n=[],i=0;i"€"&&(t.toUpperCase()!=t.toLowerCase()||Ks.test(t))}function w(t,e){return e?!!(e.source.indexOf("\\w")>-1&&x(t))||e.test(t):x(t)}function C(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e])return!1;return!0}function k(t){return t.charCodeAt(0)>=768&&Gs.test(t)}function S(t,e,n){for(;(n<0?e>0:en?-1:1;;){if(e==n)return e;var r=(e+n)/2,o=i<0?Math.ceil(r):Math.floor(r);if(o==e)return t(o)?e:n;t(o)?n=o:e=o+i}}function E(t,e,n){var o=this;this.input=n,o.scrollbarFiller=i("div",null,"CodeMirror-scrollbar-filler"),o.scrollbarFiller.setAttribute("cm-not-content","true"),o.gutterFiller=i("div",null,"CodeMirror-gutter-filler"),o.gutterFiller.setAttribute("cm-not-content","true"),o.lineDiv=r("div",null,"CodeMirror-code"),o.selectionDiv=i("div",null,null,"position: relative; z-index: 1"),o.cursorDiv=i("div",null,"CodeMirror-cursors"),o.measure=i("div",null,"CodeMirror-measure"),o.lineMeasure=i("div",null,"CodeMirror-measure"),o.lineSpace=r("div",[o.measure,o.lineMeasure,o.selectionDiv,o.cursorDiv,o.lineDiv],null,"position: relative; outline: none");var s=r("div",[o.lineSpace],"CodeMirror-lines");o.mover=i("div",[s],null,"position: relative"),o.sizer=i("div",[o.mover],"CodeMirror-sizer"),o.sizerWidth=null,o.heightForcer=i("div",null,null,"position: absolute; height: "+Hs+"px; width: 1px;"),o.gutters=i("div",null,"CodeMirror-gutters"),o.lineGutter=null,o.scroller=i("div",[o.sizer,o.heightForcer,o.gutters],"CodeMirror-scroll"),o.scroller.setAttribute("tabIndex","-1"),o.wrapper=i("div",[o.scrollbarFiller,o.gutterFiller,o.scroller],"CodeMirror"),ms&&ys<8&&(o.gutters.style.zIndex=-1,o.scroller.style.paddingRight=0),bs||fs&&Ps||(o.scroller.draggable=!0),t&&(t.appendChild?t.appendChild(o.wrapper):t(o.wrapper)),o.viewFrom=o.viewTo=e.first,o.reportedViewFrom=o.reportedViewTo=e.first,o.view=[],o.renderedView=null,o.externalMeasured=null,o.viewOffset=0,o.lastWrapHeight=o.lastWrapWidth=0,o.updateLineNumbers=null,o.nativeBarWidth=o.barHeight=o.barWidth=0,o.scrollbarsClipped=!1,o.lineNumWidth=o.lineNumInnerWidth=o.lineNumChars=null,o.alignWidgets=!1,o.cachedCharWidth=o.cachedTextHeight=o.cachedPaddingH=null,o.maxLine=null,o.maxLineLength=0,o.maxLineChanged=!1,o.wheelDX=o.wheelDY=o.wheelStartX=o.wheelStartY=null,o.shift=!1,o.selForContextMenu=null,o.activeTouch=null,n.init(o)}function M(t,e){if((e-=t.first)<0||e>=t.size)throw new Error("There is no line "+(e+t.first)+" in the document.");for(var n=t;!n.lines;)for(var i=0;;++i){var r=n.children[i],o=r.chunkSize();if(e=t.first&&en?_(n,M(t,n).text.length):B(e,M(t,e.line).text.length)}function B(t,e){var n=t.ch;return null==n||n>e?_(t.line,e):n<0?_(t.line,0):t}function W(t,e){for(var n=[],i=0;i=e:o.to>e);(i||(i=[])).push(new K(s,o.from,l?null:o.to))}}return i}function Z(t,e,n){var i;if(t)for(var r=0;r=e:o.to>e);if(a||o.from==e&&"bookmark"==s.type&&(!n||o.marker.insertLeft)){var l=null==o.from||(s.inclusiveLeft?o.from<=e:o.from0&&a)for(var w=0;w0)){var u=[l,1],h=F(c.from,a.from),f=F(c.to,a.to);(h<0||!s.inclusiveLeft&&!h)&&u.push({from:c.from,to:a.from}),(f>0||!s.inclusiveRight&&!f)&&u.push({from:a.to,to:c.to}),r.splice.apply(r,u),l+=u.length-3}}return r}function nt(t){var e=t.markedSpans;if(e){for(var n=0;n=0&&h<=0||u<=0&&h>=0)&&(u<=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?F(c.to,n)>=0:F(c.to,n)>0)||u>=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?F(c.from,i)<=0:F(c.from,i)<0)))return!0}}}function ht(t){for(var e;e=lt(t);)t=e.find(-1,!0).line;return t}function dt(t){for(var e;e=ct(t);)t=e.find(1,!0).line;return t}function ft(t){for(var e,n;e=ct(t);)t=e.find(1,!0).line,(n||(n=[])).push(t);return n}function pt(t,e){var n=M(t,e),i=ht(n);return n==i?e:L(i)}function gt(t,e){if(e>t.lastLine())return e;var n,i=M(t,e);if(!vt(t,i))return e;for(;n=ct(i);)i=n.find(1,!0).line;return L(i)+1}function vt(t,e){var n=Xs&&e.markedSpans;if(n)for(var i=void 0,r=0;re.maxLineLength&&(e.maxLineLength=n,e.maxLine=t)})}function wt(t,e,n,i){if(!t)return i(e,n,"ltr",0);for(var r=!1,o=0;oe||e==n&&s.to==e)&&(i(Math.max(s.from,e),Math.min(s.to,n),1==s.level?"rtl":"ltr",o),r=!0)}r||i(e,n,"ltr")}function Ct(t,e,n){var i;Js=null;for(var r=0;re)return r;o.to==e&&(o.from!=o.to&&"before"==n?i=r:Js=r),o.from==e&&(o.from!=o.to&&"before"!=n?i=r:Js=r)}return null!=i?i:Js}function kt(t,e){var n=t.order;return null==n&&(n=t.order=Zs(t.text,e)),n}function St(t,e){return t._handlers&&t._handlers[e]||Qs}function Tt(t,e,n){if(t.removeEventListener)t.removeEventListener(e,n,!1);else if(t.detachEvent)t.detachEvent("on"+e,n);else{var i=t._handlers,r=i&&i[e];if(r){var o=d(r,n);o>-1&&(i[e]=r.slice(0,o).concat(r.slice(o+1)))}}}function Et(t,e){var n=St(t,e);if(n.length)for(var i=Array.prototype.slice.call(arguments,2),r=0;r0}function Ot(t){t.prototype.on=function(t,e){ta(this,t,e)},t.prototype.off=function(t,e){Tt(this,t,e)}}function Lt(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function Nt(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}function It(t){return null!=t.defaultPrevented?t.defaultPrevented:0==t.returnValue}function Dt(t){Lt(t),Nt(t)}function _t(t){return t.target||t.srcElement}function Ft(t){var e=t.which;return null==e&&(1&t.button?e=1:2&t.button?e=3:4&t.button&&(e=2)),As&&t.ctrlKey&&1==e&&(e=3),e}function zt(t){if(null==Rs){var e=i("span","​");n(t,i("span",[e,document.createTextNode("x")])),0!=t.firstChild.offsetHeight&&(Rs=e.offsetWidth<=1&&e.offsetHeight>2&&!(ms&&ys<8))}var r=Rs?i("span","​"):i("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function $t(t){if(null!=Vs)return Vs;var i=n(t,document.createTextNode("AخA")),r=Is(i,0,1).getBoundingClientRect(),o=Is(i,1,2).getBoundingClientRect();return e(t),!(!r||r.left==r.right)&&(Vs=o.right-r.right<3)}function Rt(t){if(null!=oa)return oa;var e=n(t,i("span","x")),r=e.getBoundingClientRect(),o=Is(e,0,1).getBoundingClientRect();return oa=Math.abs(r.left-o.left)>1}function Vt(t,e){arguments.length>2&&(e.dependencies=Array.prototype.slice.call(arguments,2)),sa[t]=e}function Ht(t,e){aa[t]=e}function jt(t){if("string"==typeof t&&aa.hasOwnProperty(t))t=aa[t];else if(t&&"string"==typeof t.name&&aa.hasOwnProperty(t.name)){var e=aa[t.name];"string"==typeof e&&(e={name:e}),t=b(e,t),t.name=e.name}else{if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return jt("application/xml");if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+json$/.test(t))return jt("application/json")}return"string"==typeof t?{name:t}:t||{name:"null"}}function Bt(t,e){e=jt(e);var n=sa[e.name];if(!n)return Bt(t,"text/plain");var i=n(t,e);if(la.hasOwnProperty(e.name)){var r=la[e.name];for(var o in r)r.hasOwnProperty(o)&&(i.hasOwnProperty(o)&&(i["_"+o]=i[o]),i[o]=r[o])}if(i.name=e.name,e.helperType&&(i.helperType=e.helperType),e.modeProps)for(var s in e.modeProps)i[s]=e.modeProps[s];return i}function Wt(t,e){u(e,la.hasOwnProperty(t)?la[t]:la[t]={})}function Ut(t,e){if(!0===e)return e;if(t.copyState)return t.copyState(e);var n={};for(var i in e){var r=e[i];r instanceof Array&&(r=r.concat([])),n[i]=r}return n}function qt(t,e){for(var n;t.innerMode&&(n=t.innerMode(e))&&n.mode!=t;)e=n.state,t=n.mode;return n||{mode:t,state:e}}function Kt(t,e,n){return!t.startState||t.startState(e,n)}function Gt(t,e,n,i){var r=[t.state.modeGen],o={};ne(t,e.text,t.doc.mode,n,function(t,e){return r.push(t,e)},o,i);for(var s=n.state,a=0;at&&r.splice(l,1,t,r[l+1],i),l+=2,c=Math.min(t,i)}if(e)if(a.opaque)r.splice(n,l-n,t,"overlay "+e),l=n+2;else for(;nt.options.maxHighlightLength&&Ut(t.doc.mode,i.state),o=Gt(t,e,i);r&&(i.state=r),e.stateAfter=i.save(!r),e.styles=o.styles,o.classes?e.styleClasses=o.classes:e.styleClasses&&(e.styleClasses=null),n===t.doc.highlightFrontier&&(t.doc.modeFrontier=Math.max(t.doc.modeFrontier,++t.doc.highlightFrontier))}return e.styles}function Xt(t,e,n){var i=t.doc,r=t.display;if(!i.mode.startState)return new ha(i,!0,e);var o=ie(t,e,n),s=o>i.first&&M(i,o-1).stateAfter,a=s?ha.fromSaved(i,s,o):new ha(i,Kt(i.mode),o);return i.iter(o,e,function(n){Jt(t,n.text,a);var i=a.line;n.stateAfter=i==e-1||i%5==0||i>=r.viewFrom&&ie.start)return o}throw new Error("Mode "+t.name+" failed to advance stream.")}function te(t,e,n,i){var r,o=t.doc,s=o.mode;e=j(o,e);var a,l=M(o,e.line),c=Xt(t,e.line,n),u=new ca(l.text,t.options.tabSize,c);for(i&&(a=[]);(i||u.post.options.maxHighlightLength?(a=!1,s&&Jt(t,e,i,h.pos),h.pos=e.length,l=null):l=ee(Qt(n,h,i.state,d),o),d){var f=d[0].name;f&&(l="m-"+(l?f+" "+l:f))}if(!a||u!=l){for(;cs;--a){if(a<=o.first)return o.first;var l=M(o,a-1),c=l.stateAfter;if(c&&(!n||a+(c instanceof ua?c.lookAhead:0)<=o.modeFrontier))return a;var u=h(l.text,null,t.options.tabSize);(null==r||i>u)&&(r=a-1,i=u)}return r}function re(t,e){if(t.modeFrontier=Math.min(t.modeFrontier,e),!(t.highlightFrontiern;i--){var r=M(t,i).stateAfter;if(r&&(!(r instanceof ua)||i+r.lookAhead1&&!/ /.test(t))return t;for(var n=e,i="",r=0;rc&&h.from<=c));d++);if(h.to>=u)return t(n,i,r,o,s,a,l);t(n,i.slice(0,h.to-c),r,o,null,a,l),o=null,i=i.slice(h.to-c),c=h.to}}}function fe(t,e,n,i){var r=!i&&n.widgetNode;r&&t.map.push(t.pos,t.pos+e,r),!i&&t.cm.display.input.needsContentAttribute&&(r||(r=t.content.appendChild(document.createElement("span"))),r.setAttribute("cm-marker",n.id)),r&&(t.cm.display.input.setUneditable(r),t.content.appendChild(r)),t.pos+=e,t.trailingSpace=!1}function pe(t,e,n){var i=t.markedSpans,r=t.text,o=0;if(i)for(var s,a,l,c,u,h,d,f=r.length,p=0,g=1,v="",m=0;;){if(m==p){l=c=u=h=a="",d=null,m=1/0;for(var y=[],b=void 0,x=0;xp||C.collapsed&&w.to==p&&w.from==p)?(null!=w.to&&w.to!=p&&m>w.to&&(m=w.to,c=""),C.className&&(l+=" "+C.className),C.css&&(a=(a?a+";":"")+C.css),C.startStyle&&w.from==p&&(u+=" "+C.startStyle),C.endStyle&&w.to==m&&(b||(b=[])).push(C.endStyle,w.to),C.title&&!h&&(h=C.title),C.collapsed&&(!d||st(d.marker,C)<0)&&(d=w)):w.from>p&&m>w.from&&(m=w.from)}if(b)for(var k=0;k=f)break;for(var T=Math.min(f,m);;){if(v){var E=p+v.length;if(!d){var M=E>T?v.slice(0,T-p):v;e.addToken(e,M,s?s+l:l,u,p+M.length==m?c:"",h,a)}if(E>=T){v=v.slice(T-p),p=T;break}p=E,u=""}v=r.slice(o,o=n[g++]),s=ae(n[g++],e.cm.options)}}else for(var P=1;P2&&o.push((l.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Be(t,e,n){if(t.line==e)return{map:t.measure.map,cache:t.measure.cache};for(var i=0;in)return{map:t.measure.maps[r],cache:t.measure.caches[r],before:!0}}function We(t,e){e=ht(e);var i=L(e),r=t.display.externalMeasured=new ge(t.doc,e,i);r.lineN=i;var o=r.built=le(t,r);return r.text=o.pre,n(t.display.lineMeasure,o.pre),r}function Ue(t,e,n,i){return Ge(t,Ke(t,e),n,i)}function qe(t,e){if(e>=t.display.viewFrom&&e=n.lineN&&ee)&&(o=l-a,r=o-1,e>=l&&(s="right")),null!=r){if(i=t[c+2],a==l&&n==(i.insertLeft?"left":"right")&&(s=n),"left"==n&&0==r)for(;c&&t[c-2]==t[c-3]&&t[c-1].insertLeft;)i=t[2+(c-=3)],s="left";if("right"==n&&r==l-a)for(;c=0&&(n=t[r]).left==n.right;r--);return n}function Je(t,e,n,i){var r,o=Ye(e.map,n,i),s=o.node,a=o.start,l=o.end,c=o.collapse;if(3==s.nodeType){for(var u=0;u<4;u++){for(;a&&k(e.line.text.charAt(o.coverStart+a));)--a;for(;o.coverStart+l0&&(c=i="right");var h;r=t.options.lineWrapping&&(h=s.getClientRects()).length>1?h["right"==i?h.length-1:0]:s.getBoundingClientRect()}if(ms&&ys<9&&!a&&(!r||!r.left&&!r.right)){var d=s.parentNode.getClientRects()[0];r=d?{left:d.left,right:d.left+xn(t.display),top:d.top,bottom:d.bottom}:ba}for(var f=r.top-e.rect.top,p=r.bottom-e.rect.top,g=(f+p)/2,v=e.view.measure.heights,m=0;m=i.text.length?(c=i.text.length,u="before"):c<=0&&(c=0,u="after"),!l)return s("before"==u?c-1:c,"before"==u);var h=Ct(l,c,u),d=Js,f=a(c,h,"before"==u);return null!=d&&(f.other=a(c,d,"before"!=u)),f}function un(t,e){var n=0;e=j(t.doc,e),t.options.lineWrapping||(n=xn(t.display)*e.ch);var i=M(t.doc,e.line),r=yt(i)+Fe(t.display);return{left:n,right:n,top:r,bottom:r+i.height}}function hn(t,e,n,i,r){var o=_(t,e,n);return o.xRel=r,i&&(o.outside=!0),o}function dn(t,e,n){var i=t.doc;if((n+=t.display.viewOffset)<0)return hn(i.first,0,null,!0,-1);var r=N(i,n),o=i.first+i.size-1;if(r>o)return hn(i.first+i.size-1,M(i,o).text.length,null,!0,1);e<0&&(e=0);for(var s=M(i,r);;){var a=vn(t,s,r,e,n),l=ct(s),c=l&&l.find(0,!0);if(!l||!(a.ch>c.from.ch||a.ch==c.from.ch&&a.xRel>0))return a;r=L(s=c.to.line)}}function fn(t,e,n,i){i-=on(e);var r=e.text.length,o=T(function(e){return Ge(t,n,e-1).bottom<=i},r,0);return r=T(function(e){return Ge(t,n,e).top>i},o,r),{begin:o,end:r}}function pn(t,e,n,i){return n||(n=Ke(t,e)),fn(t,e,n,sn(t,e,Ge(t,n,i),"line").top)}function gn(t,e,n,i){return!(t.bottom<=n)&&(t.top>n||(i?t.left:t.right)>e)}function vn(t,e,n,i,r){r-=yt(e);var o=Ke(t,e),s=on(e),a=0,l=e.text.length,c=!0,u=kt(e,t.doc.direction);if(u){var h=(t.options.lineWrapping?yn:mn)(t,e,n,o,u,i,r);c=1!=h.level,a=c?h.from:h.to-1,l=c?h.to:h.from-1}var d,f,p=null,g=null,v=T(function(e){var n=Ge(t,o,e);return n.top+=s,n.bottom+=s,!!gn(n,i,r,!1)&&(n.top<=r&&n.left<=i&&(p=e,g=n),!0)},a,l),m=!1;if(g){var y=i-g.left=x.bottom}return v=S(e.text,v,1),hn(n,v,f,m,i-d)}function mn(t,e,n,i,r,o,s){var a=T(function(a){var l=r[a],c=1!=l.level;return gn(cn(t,_(n,c?l.to:l.from,c?"before":"after"),"line",e,i),o,s,!0)},0,r.length-1),l=r[a];if(a>0){var c=1!=l.level,u=cn(t,_(n,c?l.from:l.to,c?"after":"before"),"line",e,i);gn(u,o,s,!0)&&u.top>s&&(l=r[a-1])}return l}function yn(t,e,n,i,r,o,s){var a=fn(t,e,i,s),l=a.begin,c=a.end;/\s/.test(e.text.charAt(c-1))&&c--;for(var u=null,h=null,d=0;d=c||f.to<=l)){var p=1!=f.level,g=Ge(t,i,p?Math.min(c,f.to)-1:Math.max(l,f.from)).right,v=gv)&&(u=f,h=v)}}return u||(u=r[r.length-1]),u.fromc&&(u={from:u.from,to:c,level:u.level}),u}function bn(t){if(null!=t.cachedTextHeight)return t.cachedTextHeight;if(null==pa){pa=i("pre");for(var r=0;r<49;++r)pa.appendChild(document.createTextNode("x")),pa.appendChild(i("br"));pa.appendChild(document.createTextNode("x"))}n(t.measure,pa);var o=pa.offsetHeight/50;return o>3&&(t.cachedTextHeight=o),e(t.measure),o||1}function xn(t){if(null!=t.cachedCharWidth)return t.cachedCharWidth;var e=i("span","xxxxxxxxxx"),r=i("pre",[e]);n(t.measure,r);var o=e.getBoundingClientRect(),s=(o.right-o.left)/10;return s>2&&(t.cachedCharWidth=s),s||10}function wn(t){for(var e=t.display,n={},i={},r=e.gutters.clientLeft,o=e.gutters.firstChild,s=0;o;o=o.nextSibling,++s)n[t.options.gutters[s]]=o.offsetLeft+o.clientLeft+r,i[t.options.gutters[s]]=o.clientWidth;return{fixedPos:Cn(e),gutterTotalWidth:e.gutters.offsetWidth,gutterLeft:n,gutterWidth:i,wrapperWidth:e.wrapper.clientWidth}}function Cn(t){return t.scroller.getBoundingClientRect().left-t.sizer.getBoundingClientRect().left}function kn(t){var e=bn(t.display),n=t.options.lineWrapping,i=n&&Math.max(5,t.display.scroller.clientWidth/xn(t.display)-3);return function(r){if(vt(t.doc,r))return 0;var o=0;if(r.widgets)for(var s=0;s=t.display.viewTo)return null;if((e-=t.display.viewFrom)<0)return null;for(var n=t.display.view,i=0;i=t.display.viewTo||a.to().line0?e.blinker=setInterval(function(){return e.cursorDiv.style.visibility=(n=!n)?"":"hidden"},t.options.cursorBlinkRate):t.options.cursorBlinkRate<0&&(e.cursorDiv.style.visibility="hidden")}}function In(t){t.state.focused||(t.display.input.focus(),_n(t))}function Dn(t){t.state.delayingBlurEvent=!0,setTimeout(function(){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1,Fn(t))},100)}function _n(t,e){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1),"nocursor"!=t.options.readOnly&&(t.state.focused||(Et(t,"focus",t,e),t.state.focused=!0,a(t.display.wrapper,"CodeMirror-focused"),t.curOp||t.display.selForContextMenu==t.doc.sel||(t.display.input.reset(),bs&&setTimeout(function(){return t.display.input.reset(!0)},20)),t.display.input.receivedFocus()),Nn(t))}function Fn(t,e){t.state.delayingBlurEvent||(t.state.focused&&(Et(t,"blur",t,e),t.state.focused=!1,Fs(t.display.wrapper,"CodeMirror-focused")),clearInterval(t.display.blinker),setTimeout(function(){t.state.focused||(t.display.shift=!1)},150))}function zn(t){for(var e=t.display,n=e.lineDiv.offsetTop,i=0;i.005||l<-.005)&&(O(r.line,o),$n(r.line),r.rest))for(var c=0;c=s&&(o=N(e,yt(M(e,l))-t.wrapper.clientHeight),s=l)}return{from:o,to:Math.max(s,o+1)}}function Vn(t){var e=t.display,n=e.view;if(e.alignWidgets||e.gutters.firstChild&&t.options.fixedGutter){for(var i=Cn(e)-e.scroller.scrollLeft+t.doc.scrollLeft,r=e.gutters.offsetWidth,o=i+"px",s=0;s(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!Ts){var s=i("div","​",null,"position: absolute;\n top: "+(e.top-n.viewOffset-Fe(t.display))+"px;\n height: "+(e.bottom-e.top+Re(t)+n.barHeight)+"px;\n left: "+e.left+"px; width: "+Math.max(2,e.right-e.left)+"px;");t.display.lineSpace.appendChild(s),s.scrollIntoView(o),t.display.lineSpace.removeChild(s)}}}function Bn(t,e,n,i){null==i&&(i=0);var r;t.options.lineWrapping||e!=n||(e=e.ch?_(e.line,"before"==e.sticky?e.ch-1:e.ch,"after"):e,n="before"==e.sticky?_(e.line,e.ch+1,"before"):e);for(var o=0;o<5;o++){var s=!1,a=cn(t,e),l=n&&n!=e?cn(t,n):a;r={left:Math.min(a.left,l.left),top:Math.min(a.top,l.top)-i,right:Math.max(a.left,l.left),bottom:Math.max(a.bottom,l.bottom)+i};var c=Un(t,r),u=t.doc.scrollTop,h=t.doc.scrollLeft;if(null!=c.scrollTop&&(Zn(t,c.scrollTop),Math.abs(t.doc.scrollTop-u)>1&&(s=!0)),null!=c.scrollLeft&&(ti(t,c.scrollLeft),Math.abs(t.doc.scrollLeft-h)>1&&(s=!0)),!s)break}return r}function Wn(t,e){var n=Un(t,e);null!=n.scrollTop&&Zn(t,n.scrollTop),null!=n.scrollLeft&&ti(t,n.scrollLeft)}function Un(t,e){var n=t.display,i=bn(t.display);e.top<0&&(e.top=0);var r=t.curOp&&null!=t.curOp.scrollTop?t.curOp.scrollTop:n.scroller.scrollTop,o=He(t),s={};e.bottom-e.top>o&&(e.bottom=e.top+o);var a=t.doc.height+ze(n),l=e.topa-i;if(e.topr+o){var u=Math.min(e.top,(c?a:e.bottom)-o);u!=r&&(s.scrollTop=u)}var h=t.curOp&&null!=t.curOp.scrollLeft?t.curOp.scrollLeft:n.scroller.scrollLeft,d=Ve(t)-(t.options.fixedGutter?n.gutters.offsetWidth:0),f=e.right-e.left>d;return f&&(e.right=e.left+d),e.left<10?s.scrollLeft=0:e.leftd+h-3&&(s.scrollLeft=e.right+(f?0:10)-d),s}function qn(t,e){null!=e&&(Xn(t),t.curOp.scrollTop=(null==t.curOp.scrollTop?t.doc.scrollTop:t.curOp.scrollTop)+e)}function Kn(t){Xn(t);var e=t.getCursor();t.curOp.scrollToPos={from:e,to:e,margin:t.options.cursorScrollMargin}}function Gn(t,e,n){null==e&&null==n||Xn(t),null!=e&&(t.curOp.scrollLeft=e),null!=n&&(t.curOp.scrollTop=n)}function Yn(t,e){Xn(t),t.curOp.scrollToPos=e}function Xn(t){var e=t.curOp.scrollToPos;if(e){t.curOp.scrollToPos=null;Jn(t,un(t,e.from),un(t,e.to),e.margin)}}function Jn(t,e,n,i){var r=Un(t,{left:Math.min(e.left,n.left),top:Math.min(e.top,n.top)-i,right:Math.max(e.right,n.right),bottom:Math.max(e.bottom,n.bottom)+i});Gn(t,r.scrollLeft,r.scrollTop)}function Zn(t,e){Math.abs(t.doc.scrollTop-e)<2||(fs||Oi(t,{top:e}),Qn(t,e,!0),fs&&Oi(t),ki(t,100))}function Qn(t,e,n){e=Math.min(t.display.scroller.scrollHeight-t.display.scroller.clientHeight,e),(t.display.scroller.scrollTop!=e||n)&&(t.doc.scrollTop=e,t.display.scrollbars.setScrollTop(e),t.display.scroller.scrollTop!=e&&(t.display.scroller.scrollTop=e))}function ti(t,e,n,i){e=Math.min(e,t.display.scroller.scrollWidth-t.display.scroller.clientWidth),(n?e==t.doc.scrollLeft:Math.abs(t.doc.scrollLeft-e)<2)&&!i||(t.doc.scrollLeft=e,Vn(t),t.display.scroller.scrollLeft!=e&&(t.display.scroller.scrollLeft=e),t.display.scrollbars.setScrollLeft(e))}function ei(t){var e=t.display,n=e.gutters.offsetWidth,i=Math.round(t.doc.height+ze(t.display));return{clientHeight:e.scroller.clientHeight,viewHeight:e.wrapper.clientHeight,scrollWidth:e.scroller.scrollWidth,clientWidth:e.scroller.clientWidth,viewWidth:e.wrapper.clientWidth,barLeft:t.options.fixedGutter?n:0,docHeight:i,scrollHeight:i+Re(t)+e.barHeight,nativeBarWidth:e.nativeBarWidth,gutterWidth:n}}function ni(t,e){e||(e=ei(t));var n=t.display.barWidth,i=t.display.barHeight;ii(t,e);for(var r=0;r<4&&n!=t.display.barWidth||i!=t.display.barHeight;r++)n!=t.display.barWidth&&t.options.lineWrapping&&zn(t),ii(t,ei(t)),n=t.display.barWidth,i=t.display.barHeight}function ii(t,e){var n=t.display,i=n.scrollbars.update(e);n.sizer.style.paddingRight=(n.barWidth=i.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=i.bottom)+"px",n.heightForcer.style.borderBottom=i.bottom+"px solid transparent",i.right&&i.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=i.bottom+"px",n.scrollbarFiller.style.width=i.right+"px"):n.scrollbarFiller.style.display="",i.bottom&&t.options.coverGutterNextToScrollbar&&t.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=i.bottom+"px",n.gutterFiller.style.width=e.gutterWidth+"px"):n.gutterFiller.style.display=""}function ri(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Fs(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new Ca[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),ta(e,"mousedown",function(){t.state.focused&&setTimeout(function(){return t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,n){"horizontal"==n?ti(t,e):Zn(t,e)},t),t.display.scrollbars.addClass&&a(t.display.wrapper,t.display.scrollbars.addClass)}function oi(t){t.curOp={cm:t,viewChanged:!1,startHeight:t.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++ka},me(t.curOp)}function si(t){be(t.curOp,function(t){for(var e=0;e=n.viewTo)||n.maxLineChanged&&e.options.lineWrapping,t.update=t.mustUpdate&&new Sa(e,t.mustUpdate&&{top:t.scrollTop,ensure:t.scrollToPos},t.forceUpdate)}function ci(t){t.updatedDisplay=t.mustUpdate&&Pi(t.cm,t.update)}function ui(t){var e=t.cm,n=e.display;t.updatedDisplay&&zn(e),t.barMeasure=ei(e),n.maxLineChanged&&!e.options.lineWrapping&&(t.adjustWidthTo=Ue(e,n.maxLine,n.maxLine.text.length).left+3,e.display.sizerWidth=t.adjustWidthTo,t.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+t.adjustWidthTo+Re(e)+e.display.barWidth),t.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+t.adjustWidthTo-Ve(e))),(t.updatedDisplay||t.selectionChanged)&&(t.preparedSelection=n.input.prepareSelection())}function hi(t){var e=t.cm;null!=t.adjustWidthTo&&(e.display.sizer.style.minWidth=t.adjustWidthTo+"px",t.maxScrollLefte)&&(r.updateLineNumbers=e),t.curOp.viewChanged=!0,e>=r.viewTo)Xs&&pt(t.doc,e)r.viewFrom?bi(t):(r.viewFrom+=i,r.viewTo+=i);else if(e<=r.viewFrom&&n>=r.viewTo)bi(t);else if(e<=r.viewFrom){var o=xi(t,n,n+i,1);o?(r.view=r.view.slice(o.index),r.viewFrom=o.lineN,r.viewTo+=i):bi(t)}else if(n>=r.viewTo){var s=xi(t,e,e,-1);s?(r.view=r.view.slice(0,s.index),r.viewTo=s.lineN):bi(t)}else{var a=xi(t,e,e,-1),l=xi(t,n,n+i,1);a&&l?(r.view=r.view.slice(0,a.index).concat(ve(t,a.lineN,l.lineN)).concat(r.view.slice(l.index)),r.viewTo+=i):bi(t)}var c=r.externalMeasured;c&&(n=r.lineN&&e=i.viewTo)){var o=i.view[En(t,e)];if(null!=o.node){var s=o.changes||(o.changes=[]);-1==d(s,n)&&s.push(n)}}}function bi(t){t.display.viewFrom=t.display.viewTo=t.doc.first,t.display.view=[],t.display.viewOffset=0}function xi(t,e,n,i){var r,o=En(t,e),s=t.display.view;if(!Xs||n==t.doc.first+t.doc.size)return{index:o,lineN:n};for(var a=t.display.viewFrom,l=0;l0){if(o==s.length-1)return null;r=a+s[o].size-e,o++}else r=a-e;e+=r,n+=r}for(;pt(t.doc,n)!=n;){if(o==(i<0?0:s.length-1))return null;n+=i*s[o-(i<0?1:0)].size,o+=i}return{index:o,lineN:n}}function wi(t,e,n){var i=t.display;0==i.view.length||e>=i.viewTo||n<=i.viewFrom?(i.view=ve(t,e,n),i.viewFrom=e):(i.viewFrom>e?i.view=ve(t,e,i.viewFrom).concat(i.view):i.viewFromn&&(i.view=i.view.slice(0,En(t,n)))),i.viewTo=n}function Ci(t){for(var e=t.display.view,n=0,i=0;i=t.display.viewTo)){var n=+new Date+t.options.workTime,i=Xt(t,e.highlightFrontier),r=[];e.iter(i.line,Math.min(e.first+e.size,t.display.viewTo+500),function(o){if(i.line>=t.display.viewFrom){var s=o.styles,a=o.text.length>t.options.maxHighlightLength?Ut(e.mode,i.state):null,l=Gt(t,o,i,!0);a&&(i.state=a),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var h=!s||s.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),d=0;!h&&dn)return ki(t,t.options.workDelay),!0}),e.highlightFrontier=i.line,e.modeFrontier=Math.max(e.modeFrontier,i.line),r.length&&fi(t,function(){for(var e=0;e=i.viewFrom&&n.visible.to<=i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&0==Ci(t))return!1;Hn(t)&&(bi(t),n.dims=wn(t));var o=r.first+r.size,s=Math.max(n.visible.from-t.options.viewportMargin,r.first),a=Math.min(o,n.visible.to+t.options.viewportMargin);i.viewFroma&&i.viewTo-a<20&&(a=Math.min(o,i.viewTo)),Xs&&(s=pt(t.doc,s),a=gt(t.doc,a));var l=s!=i.viewFrom||a!=i.viewTo||i.lastWrapHeight!=n.wrapperHeight||i.lastWrapWidth!=n.wrapperWidth;wi(t,s,a),i.viewOffset=yt(M(t.doc,i.viewFrom)),t.display.mover.style.top=i.viewOffset+"px";var c=Ci(t);if(!l&&0==c&&!n.force&&i.renderedView==i.view&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo))return!1;var u=Ei(t);return c>4&&(i.lineDiv.style.display="none"),Li(t,i.updateLineNumbers,n.dims),c>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,Mi(u),e(i.cursorDiv),e(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,l&&(i.lastWrapHeight=n.wrapperHeight,i.lastWrapWidth=n.wrapperWidth,ki(t,400)),i.updateLineNumbers=null,!0}function Ai(t,e){for(var n=e.viewport,i=!0;(i&&t.options.lineWrapping&&e.oldDisplayWidth!=Ve(t)||(n&&null!=n.top&&(n={top:Math.min(t.doc.height+ze(t.display)-He(t),n.top)}),e.visible=Rn(t.display,t.doc,n),!(e.visible.from>=t.display.viewFrom&&e.visible.to<=t.display.viewTo)))&&Pi(t,e);i=!1){zn(t);var r=ei(t);Mn(t),ni(t,r),Ii(t,r),e.force=!1}e.signal(t,"update",t),t.display.viewFrom==t.display.reportedViewFrom&&t.display.viewTo==t.display.reportedViewTo||(e.signal(t,"viewportChange",t,t.display.viewFrom,t.display.viewTo),t.display.reportedViewFrom=t.display.viewFrom,t.display.reportedViewTo=t.display.viewTo)}function Oi(t,e){var n=new Sa(t,e);if(Pi(t,n)){zn(t),Ai(t,n);var i=ei(t);Mn(t),ni(t,i),Ii(t,i),n.finish()}}function Li(t,n,i){function r(e){var n=e.nextSibling;return bs&&As&&t.display.currentWheelTarget==e?e.style.display="none":e.parentNode.removeChild(e),n}for(var o=t.display,s=t.options.lineNumbers,a=o.lineDiv,l=a.firstChild,c=o.view,u=o.viewFrom,h=0;h-1&&(p=!1),Ce(t,f,u,i)),p&&(e(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(D(t.options,u)))),l=f.node.nextSibling}else{var g=Oe(t,f,u,i);a.insertBefore(g,l)}u+=f.size}for(;l;)l=r(l)}function Ni(t){var e=t.display.gutters.offsetWidth;t.display.sizer.style.marginLeft=e+"px"}function Ii(t,e){t.display.sizer.style.minHeight=e.docHeight+"px",t.display.heightForcer.style.top=e.docHeight+"px",t.display.gutters.style.height=e.docHeight+t.display.barHeight+Re(t)+"px"}function Di(t){var n=t.display.gutters,r=t.options.gutters;e(n);for(var o=0;o-1&&!t.lineNumbers&&(t.gutters=t.gutters.slice(0),t.gutters.splice(e,1))}function Fi(t){var e=t.wheelDeltaX,n=t.wheelDeltaY;return null==e&&t.detail&&t.axis==t.HORIZONTAL_AXIS&&(e=t.detail),null==n&&t.detail&&t.axis==t.VERTICAL_AXIS?n=t.detail:null==n&&(n=t.wheelDelta),{x:e,y:n}}function zi(t){var e=Fi(t);return e.x*=Ea,e.y*=Ea,e}function $i(t,e){var n=Fi(e),i=n.x,r=n.y,o=t.display,s=o.scroller,a=s.scrollWidth>s.clientWidth,l=s.scrollHeight>s.clientHeight;if(i&&a||r&&l){if(r&&As&&bs)t:for(var c=e.target,u=o.view;c!=s;c=c.parentNode)for(var h=0;h=0){var s=V(o.from(),r.from()),a=R(o.to(),r.to()),l=o.empty()?r.from()==r.head:o.from()==o.head;i<=e&&--e,t.splice(--i,2,new Pa(l?a:s,l?s:a))}}return new Ma(t,e)}function Vi(t,e){return new Ma([new Pa(t,e||t)],0)}function Hi(t){return t.text?_(t.from.line+t.text.length-1,g(t.text).length+(1==t.text.length?t.from.ch:0)):t.to}function ji(t,e){if(F(t,e.from)<0)return t;if(F(t,e.to)<=0)return Hi(e);var n=t.line+e.text.length-(e.to.line-e.from.line)-1,i=t.ch;return t.line==e.to.line&&(i+=Hi(e).ch-e.to.ch),_(n,i)}function Bi(t,e){for(var n=[],i=0;i1&&t.remove(a.line+1,p-1),t.insert(a.line+1,y)}xe(t,"change",t,e)}function Xi(t,e,n){function i(t,r,o){if(t.linked)for(var s=0;s1&&!t.done[t.done.length-2].ranges?(t.done.pop(),g(t.done)):void 0}function rr(t,e,n,i){var r=t.history;r.undone.length=0;var o,s,a=+new Date;if((r.lastOp==i||r.lastOrigin==e.origin&&e.origin&&("+"==e.origin.charAt(0)&&t.cm&&r.lastModTime>a-t.cm.options.historyEventDelay||"*"==e.origin.charAt(0)))&&(o=ir(r,r.lastOp==i)))s=g(o.changes),0==F(e.from,e.to)&&0==F(e.from,s.to)?s.to=Hi(e):o.changes.push(er(t,e));else{var l=g(r.done);for(l&&l.ranges||ar(t.sel,r.done),o={changes:[er(t,e)],generation:r.generation},r.done.push(o);r.done.length>r.undoDepth;)r.done.shift(),r.done[0].ranges||r.done.shift()}r.done.push(n),r.generation=++r.maxGeneration,r.lastModTime=r.lastSelTime=a,r.lastOp=r.lastSelOp=i,r.lastOrigin=r.lastSelOrigin=e.origin,s||Et(t,"historyAdded")}function or(t,e,n,i){var r=e.charAt(0);return"*"==r||"+"==r&&n.ranges.length==i.ranges.length&&n.somethingSelected()==i.somethingSelected()&&new Date-t.history.lastSelTime<=(t.cm?t.cm.options.historyEventDelay:500)}function sr(t,e,n,i){var r=t.history,o=i&&i.origin;n==r.lastSelOp||o&&r.lastSelOrigin==o&&(r.lastModTime==r.lastSelTime&&r.lastOrigin==o||or(t,o,g(r.done),e))?r.done[r.done.length-1]=e:ar(e,r.done),r.lastSelTime=+new Date,r.lastSelOrigin=o,r.lastSelOp=n,i&&!1!==i.clearRedo&&nr(r.undone)}function ar(t,e){var n=g(e);n&&n.ranges&&n.equals(t)||e.push(t)}function lr(t,e,n,i){var r=e["spans_"+t.id],o=0;t.iter(Math.max(t.first,n),Math.min(t.first+t.size,i),function(n){n.markedSpans&&((r||(r=e["spans_"+t.id]={}))[o]=n.markedSpans),++o})}function cr(t){if(!t)return null;for(var e,n=0;n-1&&(g(a)[h]=c[h],delete c[h])}}}return i}function fr(t,e,n,i){if(i){var r=t.anchor;if(n){var o=F(e,r)<0;o!=F(n,r)<0?(r=e,e=n):o!=F(e,n)<0&&(e=n)}return new Pa(r,e)}return new Pa(n||e,e)}function pr(t,e,n,i,r){null==r&&(r=t.cm&&(t.cm.display.shift||t.extend)),xr(t,new Ma([fr(t.sel.primary(),e,n,r)],0),i)}function gr(t,e,n){for(var i=[],r=t.cm&&(t.cm.display.shift||t.extend),o=0;o=e.ch:a.to>e.ch))){if(r&&(Et(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--s;continue}break}if(!l.atomic)continue;if(n){var c=l.find(i<0?1:-1),u=void 0;if((i<0?l.inclusiveRight:l.inclusiveLeft)&&(c=Mr(t,c,-i,c&&c.line==e.line?o:null)),c&&c.line==e.line&&(u=F(c,n))&&(i<0?u<0:u>0))return Tr(t,c,e,i,r)}var h=l.find(i<0?-1:1);return(i<0?l.inclusiveLeft:l.inclusiveRight)&&(h=Mr(t,h,i,h.line==e.line?o:null)),h?Tr(t,h,e,i,r):null}}return e}function Er(t,e,n,i,r){var o=i||1,s=Tr(t,e,n,o,r)||!r&&Tr(t,e,n,o,!0)||Tr(t,e,n,-o,r)||!r&&Tr(t,e,n,-o,!0);return s||(t.cantEdit=!0,_(t.first,0))}function Mr(t,e,n,i){return n<0&&0==e.ch?e.line>t.first?j(t,_(e.line-1)):null:n>0&&e.ch==(i||M(t,e.line)).text.length?e.line=0;--r)Lr(t,{from:i[r].from,to:i[r].to,text:r?[""]:e.text,origin:e.origin});else Lr(t,e)}}function Lr(t,e){if(1!=e.text.length||""!=e.text[0]||0!=F(e.from,e.to)){var n=Bi(t,e);rr(t,e,n,t.cm?t.cm.curOp.id:NaN),Dr(t,e,n,Q(t,e));var i=[];Xi(t,function(t,n){n||-1!=d(i,t.history)||(Rr(t.history,e),i.push(t.history)),Dr(t,e,null,Q(t,e))})}}function Nr(t,e,n){if(!t.cm||!t.cm.state.suppressEdits||n){for(var i,r=t.history,o=t.sel,s="undo"==e?r.done:r.undone,a="undo"==e?r.undone:r.done,l=0;l=0;--h){var f=function(n){var r=i.changes[n];if(r.origin=e,u&&!Ar(t,r,!1))return s.length=0,{};c.push(er(t,r));var o=n?Bi(t,r):g(s);Dr(t,r,o,hr(t,r)),!n&&t.cm&&t.cm.scrollIntoView({from:r.from,to:Hi(r)});var a=[];Xi(t,function(t,e){e||-1!=d(a,t.history)||(Rr(t.history,r),a.push(t.history)),Dr(t,r,null,hr(t,r))})}(h);if(f)return f.v}}}}function Ir(t,e){if(0!=e&&(t.first+=e,t.sel=new Ma(v(t.sel.ranges,function(t){return new Pa(_(t.anchor.line+e,t.anchor.ch),_(t.head.line+e,t.head.ch))}),t.sel.primIndex),t.cm)){mi(t.cm,t.first,t.first-e,e);for(var n=t.cm.display,i=n.viewFrom;it.lastLine())){if(e.from.lineo&&(e={from:e.from,to:_(o,M(t,o).text.length),text:[e.text[0]],origin:e.origin}),e.removed=P(t,e.from,e.to),n||(n=Bi(t,e)),t.cm?_r(t.cm,e,i):Yi(t,e,i),wr(t,n,Bs)}}function _r(t,e,n){var i=t.doc,r=t.display,o=e.from,s=e.to,a=!1,l=o.line;t.options.lineWrapping||(l=L(ht(M(i,o.line))),i.iter(l,s.line+1,function(t){if(t==r.maxLine)return a=!0,!0})),i.sel.contains(e.from,e.to)>-1&&Pt(t),Yi(i,e,n,kn(t)),t.options.lineWrapping||(i.iter(l,o.line+e.text.length,function(t){var e=bt(t);e>r.maxLineLength&&(r.maxLine=t,r.maxLineLength=e,r.maxLineChanged=!0,a=!1)}),a&&(t.curOp.updateMaxLine=!0)),re(i,o.line),ki(t,400);var c=e.text.length-(s.line-o.line)-1;e.full?mi(t):o.line!=s.line||1!=e.text.length||Gi(t.doc,e)?mi(t,o.line,s.line+1,c):yi(t,o.line,"text");var u=At(t,"changes"),h=At(t,"change");if(h||u){var d={from:o,to:s,text:e.text,removed:e.removed,origin:e.origin};h&&xe(t,"change",t,d),u&&(t.curOp.changeObjs||(t.curOp.changeObjs=[])).push(d)}t.display.selForContextMenu=null}function Fr(t,e,n,i,r){if(i||(i=n),F(i,n)<0){var o;o=[i,n],n=o[0],i=o[1]}"string"==typeof e&&(e=t.splitLines(e)),Or(t,{from:n,to:i,text:e,origin:r})}function zr(t,e,n,i){n0||0==a&&!1!==s.clearWhenEmpty)return s;if(s.replacedWith&&(s.collapsed=!0,s.widgetNode=r("span",[s.replacedWith],"CodeMirror-widget"),i.handleMouseEvents||s.widgetNode.setAttribute("cm-ignore-events","true"),i.insertLeft&&(s.widgetNode.insertLeft=!0)),s.collapsed){if(ut(t,e.line,e,n,s)||e.line!=n.line&&ut(t,n.line,e,n,s))throw new Error("Inserting collapsed marker partially overlapping an existing one");q()}s.addToHistory&&rr(t,{from:e,to:n,origin:"markText"},t.sel,NaN);var l,c=e.line,h=t.cm;if(t.iter(c,n.line+1,function(t){h&&s.collapsed&&!h.options.lineWrapping&&ht(t)==h.display.maxLine&&(l=!0),s.collapsed&&c!=e.line&&O(t,0),X(t,new K(s,c==e.line?e.ch:null,c==n.line?n.ch:null)),++c}),s.collapsed&&t.iter(e.line,n.line+1,function(e){vt(t,e)&&O(e,0)}),s.clearOnEnter&&ta(s,"beforeCursorEnter",function(){return s.clear()}),s.readOnly&&(U(),(t.history.done.length||t.history.undone.length)&&t.clearHistory()),s.collapsed&&(s.id=++Oa,s.atomic=!0),h){if(l&&(h.curOp.updateMaxLine=!0),s.collapsed)mi(h,e.line,n.line+1);else if(s.className||s.title||s.startStyle||s.endStyle||s.css)for(var d=e.line;d<=n.line;d++)yi(h,d,"text");s.atomic&&kr(h.doc),xe(h,"markerAdded",h,s)}return s}function qr(t,e,n,i,r){i=u(i),i.shared=!1;var o=[Ur(t,e,n,i,r)],s=o[0],a=i.widgetNode;return Xi(t,function(t){a&&(i.widgetNode=a.cloneNode(!0)),o.push(Ur(t,j(t,e),j(t,n),i,r));for(var l=0;l-1)return e.state.draggingText(t),void setTimeout(function(){return e.display.input.focus()},20);try{var l=t.dataTransfer.getData("Text");if(l){var c;if(e.state.draggingText&&!e.state.draggingText.copy&&(c=e.listSelections()),wr(e.doc,Vi(n,n)),c)for(var u=0;u=0;e--)Fr(t.doc,"",i[e].from,i[e].to,"+delete");Kn(t)})}function fo(t,e,n){var i=S(t.text,e+n,n);return i<0||i>t.text.length?null:i}function po(t,e,n){var i=fo(t,e.ch,n);return null==i?null:new _(e.line,i,n<0?"after":"before")}function go(t,e,n,i,r){if(t){var o=kt(n,e.doc.direction);if(o){var s,a=r<0?g(o):o[0],l=r<0==(1==a.level),c=l?"after":"before";if(a.level>0||"rtl"==e.doc.direction){var u=Ke(e,n);s=r<0?n.text.length-1:0;var h=Ge(e,u,s).top;s=T(function(t){return Ge(e,u,t).top==h},r<0==(1==a.level)?a.from:a.to-1,s),"before"==c&&(s=fo(n,s,1))}else s=r<0?a.to:a.from;return new _(i,s,c)}}return new _(i,r<0?n.text.length:0,r<0?"before":"after")}function vo(t,e,n,i){var r=kt(e,t.doc.direction);if(!r)return po(e,n,i);n.ch>=e.text.length?(n.ch=e.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=Ct(r,n.ch,n.sticky),s=r[o];if("ltr"==t.doc.direction&&s.level%2==0&&(i>0?s.to>n.ch:s.from=s.from&&d>=u.begin)){var f=h?"before":"after";return new _(n.line,d,f)}}var p=function(t,e,i){for(var o=function(t,e){return e?new _(n.line,l(t,1),"before"):new _(n.line,t,"after")};t>=0&&t0==(1!=s.level),c=a?i.begin:l(i.end,-1);if(s.from<=c&&c0?u.end:l(u.begin,-1);return null==v||i>0&&v==e.text.length||!(g=p(i>0?0:r.length-1,i,c(v)))?null:g}function mo(t,e){var n=M(t.doc,e),i=ht(n);return i!=n&&(e=L(i)),go(!0,t,i,e,1)}function yo(t,e){var n=M(t.doc,e),i=dt(n);return i!=n&&(e=L(i)),go(!0,t,n,e,-1)}function bo(t,e){var n=mo(t,e.line),i=M(t.doc,n.line),r=kt(i,t.doc.direction);if(!r||0==r[0].level){var o=Math.max(0,i.text.search(/\S/)),s=e.line==n.line&&e.ch<=o&&e.ch;return _(n.line,s?0:o,n.sticky)}return n}function xo(t,e,n){if("string"==typeof e&&!(e=ja[e]))return!1;t.display.input.ensurePolled();var i=t.display.shift,r=!1;try{t.isReadOnly()&&(t.state.suppressEdits=!0),n&&(t.display.shift=!1),r=e(t)!=js}finally{t.display.shift=i,t.state.suppressEdits=!1}return r}function wo(t,e,n){for(var i=0;i-1&&(F((r=a.ranges[r]).from(),e)<0||e.xRel>0)&&(F(r.to(),e)>0||e.xRel<0)?Do(t,i,e,o):Fo(t,i,e,o)}function Do(t,e,n,i){var r=t.display,o=!1,s=pi(t,function(e){bs&&(r.scroller.draggable=!1),t.state.draggingText=!1,Tt(document,"mouseup",s),Tt(document,"mousemove",a),Tt(r.scroller,"dragstart",l),Tt(r.scroller,"drop",s),o||(Lt(e),i.addNew||pr(t.doc,n,null,null,i.extend),bs||ms&&9==ys?setTimeout(function(){document.body.focus(),r.input.focus()},20):r.input.focus())}),a=function(t){o=o||Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)>=10},l=function(){return o=!0};bs&&(r.scroller.draggable=!0),t.state.draggingText=s,s.copy=!i.moveOnDrag,r.scroller.dragDrop&&r.scroller.dragDrop(),ta(document,"mouseup",s),ta(document,"mousemove",a),ta(r.scroller,"dragstart",l),ta(r.scroller,"drop",s),Dn(t),setTimeout(function(){return r.input.focus()},20)}function _o(t,e,n){if("char"==n)return new Pa(e,e);if("word"==n)return t.findWordAt(e);if("line"==n)return new Pa(_(e.line,0),j(t.doc,_(e.line+1,0)));var i=n(t,e);return new Pa(i.from,i.to)}function Fo(t,e,n,i){function r(e){if(0!=F(m,e))if(m=e,"rectangle"==i.unit){for(var r=[],o=t.options.tabSize,s=h(M(c,n.line).text,n.ch,o),a=h(M(c,e.line).text,e.ch,o),l=Math.min(s,a),g=Math.max(s,a),v=Math.min(n.line,e.line),y=Math.min(t.lastLine(),Math.max(n.line,e.line));v<=y;v++){var b=M(c,v).text,x=f(b,l,o);l==g?r.push(new Pa(_(v,x),_(v,x))):b.length>x&&r.push(new Pa(_(v,x),_(v,f(b,g,o))))}r.length||r.push(new Pa(n,n)),xr(c,Ri(p.ranges.slice(0,d).concat(r),d),{origin:"*mouse",scroll:!1}),t.scrollIntoView(e)}else{var w,C=u,k=_o(t,e,i.unit),S=C.anchor;F(k.anchor,S)>0?(w=k.head,S=V(C.from(),k.anchor)):(w=k.anchor,S=R(C.to(),k.head));var T=p.ranges.slice(0);T[d]=zo(t,new Pa(j(c,S),w)),xr(c,Ri(T,d),Ws)}}function o(e){var n=++b,a=Tn(t,e,!0,"rectangle"==i.unit);if(a)if(0!=F(a,m)){t.curOp.focus=s(),r(a);var u=Rn(l,c);(a.line>=u.to||a.liney.bottom?20:0;h&&setTimeout(pi(t,function(){b==n&&(l.scroller.scrollTop+=h,o(e))}),50)}}function a(e){t.state.selectingText=!1,b=1/0,Lt(e),l.input.focus(),Tt(document,"mousemove",x),Tt(document,"mouseup",w),c.history.lastSelOrigin=null}var l=t.display,c=t.doc;Lt(e);var u,d,p=c.sel,g=p.ranges;if(i.addNew&&!i.extend?(d=c.sel.contains(n),u=d>-1?g[d]:new Pa(n,n)):(u=c.sel.primary(),d=c.sel.primIndex),"rectangle"==i.unit)i.addNew||(u=new Pa(n,n)),n=Tn(t,e,!0,!0),d=-1;else{var v=_o(t,n,i.unit);u=i.extend?fr(u,v.anchor,v.head,i.extend):v}i.addNew?-1==d?(d=g.length,xr(c,Ri(g.concat([u]),d),{scroll:!1,origin:"*mouse"})):g.length>1&&g[d].empty()&&"char"==i.unit&&!i.extend?(xr(c,Ri(g.slice(0,d).concat(g.slice(d+1)),0),{scroll:!1,origin:"*mouse"}),p=c.sel):vr(c,d,u,Ws):(d=0,xr(c,new Ma([u],0),Ws),p=c.sel);var m=n,y=l.wrapper.getBoundingClientRect(),b=0,x=pi(t,function(t){Ft(t)?o(t):a(t)}),w=pi(t,a);t.state.selectingText=w,ta(document,"mousemove",x),ta(document,"mouseup",w)}function zo(t,e){var n=e.anchor,i=e.head,r=M(t.doc,n.line);if(0==F(n,i)&&n.sticky==i.sticky)return e;var o=kt(r);if(!o)return e;var s=Ct(o,n.ch,n.sticky),a=o[s];if(a.from!=n.ch&&a.to!=n.ch)return e;var l=s+(a.from==n.ch==(1!=a.level)?0:1);if(0==l||l==o.length)return e;var c;if(i.line!=n.line)c=(i.line-n.line)*("ltr"==t.doc.direction?1:-1)>0;else{var u=Ct(o,i.ch,i.sticky),h=u-s||(i.ch-n.ch)*(1==a.level?-1:1);c=u==l-1||u==l?h<0:h>0}var d=o[l+(c?-1:0)],f=c==(1==d.level),p=f?d.from:d.to,g=f?"after":"before";return n.ch==p&&n.sticky==g?e:new Pa(new _(n.line,p,g),i)}function $o(t,e,n,i){var r,o;if(e.touches)r=e.touches[0].clientX,o=e.touches[0].clientY;else try{r=e.clientX,o=e.clientY}catch(e){return!1}if(r>=Math.floor(t.display.gutters.getBoundingClientRect().right))return!1;i&&Lt(e);var s=t.display,a=s.lineDiv.getBoundingClientRect();if(o>a.bottom||!At(t,n))return It(e);o-=a.top-s.viewOffset;for(var l=0;l=r){return Et(t,n,t,N(t.doc,o),t.options.gutters[l],e),It(e)}}}function Ro(t,e){return $o(t,e,"gutterClick",!0)}function Vo(t,e){_e(t.display,e)||Ho(t,e)||Mt(t,e,"contextmenu")||t.display.input.onContextMenu(e)}function Ho(t,e){return!!At(t,"gutterContextMenu")&&$o(t,e,"gutterContextMenu",!1)}function jo(t){t.display.wrapper.className=t.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+t.options.theme.replace(/(^|\s)\s*/g," cm-s-"),en(t)}function Bo(t){Di(t),mi(t),Vn(t)}function Wo(t,e,n){if(!e!=!(n&&n!=Ga)){var i=t.display.dragFunctions,r=e?ta:Tt;r(t.display.scroller,"dragstart",i.start),r(t.display.scroller,"dragenter",i.enter),r(t.display.scroller,"dragover",i.over),r(t.display.scroller,"dragleave",i.leave),r(t.display.scroller,"drop",i.drop)}}function Uo(t){t.options.lineWrapping?(a(t.display.wrapper,"CodeMirror-wrap"),t.display.sizer.style.minWidth="",t.display.sizerWidth=null):(Fs(t.display.wrapper,"CodeMirror-wrap"),xt(t)),Sn(t),mi(t),en(t),setTimeout(function(){return ni(t)},100)}function qo(t,e){var n=this;if(!(this instanceof qo))return new qo(t,e);this.options=e=e?u(e):{},u(Ya,e,!1),_i(e);var i=e.value;"string"==typeof i&&(i=new Da(i,e.mode,null,e.lineSeparator,e.direction)),this.doc=i;var r=new qo.inputStyles[e.inputStyle](this),o=this.display=new E(t,i,r);o.wrapper.CodeMirror=this,Di(this),jo(this),e.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),ri(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new $s,keySeq:null,specialChars:null},e.autofocus&&!Ps&&o.input.focus(),ms&&ys<11&&setTimeout(function(){return n.display.input.reset(!0)},20),Ko(this),eo(),oi(this),this.curOp.forceUpdate=!0,Ji(this,i),e.autofocus&&!Ps||this.hasFocus()?setTimeout(c(_n,this),20):Fn(this);for(var s in Xa)Xa.hasOwnProperty(s)&&Xa[s](n,e[s],Ga);Hn(this),e.finishInit&&e.finishInit(this);for(var a=0;a400}var r=t.display;ta(r.scroller,"mousedown",pi(t,Oo)),ms&&ys<11?ta(r.scroller,"dblclick",pi(t,function(e){if(!Mt(t,e)){var n=Tn(t,e);if(n&&!Ro(t,e)&&!_e(t.display,e)){Lt(e);var i=t.findWordAt(n);pr(t.doc,i.anchor,i.head)}}})):ta(r.scroller,"dblclick",function(e){return Mt(t,e)||Lt(e)}),_s||ta(r.scroller,"contextmenu",function(e){return Vo(t,e)});var o,s={end:0};ta(r.scroller,"touchstart",function(e){if(!Mt(t,e)&&!n(e)&&!Ro(t,e)){r.input.ensurePolled(),clearTimeout(o);var i=+new Date;r.activeTouch={start:i,moved:!1,prev:i-s.end<=300?s:null},1==e.touches.length&&(r.activeTouch.left=e.touches[0].pageX,r.activeTouch.top=e.touches[0].pageY)}}),ta(r.scroller,"touchmove",function(){r.activeTouch&&(r.activeTouch.moved=!0)}),ta(r.scroller,"touchend",function(n){var o=r.activeTouch;if(o&&!_e(r,n)&&null!=o.left&&!o.moved&&new Date-o.start<300){var s,a=t.coordsChar(r.activeTouch,"page");s=!o.prev||i(o,o.prev)?new Pa(a,a):!o.prev.prev||i(o,o.prev.prev)?t.findWordAt(a):new Pa(_(a.line,0),j(t.doc,_(a.line+1,0))),t.setSelection(s.anchor,s.head),t.focus(),Lt(n)}e()}),ta(r.scroller,"touchcancel",e),ta(r.scroller,"scroll",function(){r.scroller.clientHeight&&(Zn(t,r.scroller.scrollTop),ti(t,r.scroller.scrollLeft,!0),Et(t,"scroll",t))}),ta(r.scroller,"mousewheel",function(e){return $i(t,e)}),ta(r.scroller,"DOMMouseScroll",function(e){return $i(t,e)}),ta(r.wrapper,"scroll",function(){return r.wrapper.scrollTop=r.wrapper.scrollLeft=0}),r.dragFunctions={enter:function(e){Mt(t,e)||Dt(e)},over:function(e){Mt(t,e)||(Zr(t,e),Dt(e))},start:function(e){return Jr(t,e)},drop:pi(t,Xr),leave:function(e){Mt(t,e)||Qr(t)}};var a=r.input.getField();ta(a,"keyup",function(e){return Mo.call(t,e)}),ta(a,"keydown",pi(t,To)),ta(a,"keypress",pi(t,Po)),ta(a,"focus",function(e){return _n(t,e)}),ta(a,"blur",function(e){return Fn(t,e)})}function Go(t,e,n,i){var r,o=t.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?r=Xt(t,e).state:n="prev");var s=t.options.tabSize,a=M(o,e),l=h(a.text,null,s);a.stateAfter&&(a.stateAfter=null);var c,u=a.text.match(/^\s*/)[0];if(i||/\S/.test(a.text)){if("smart"==n&&((c=o.mode.indent(r,a.text.slice(u.length),a.text))==js||c>150)){if(!i)return;n="prev"}}else c=0,n="not";"prev"==n?c=e>o.first?h(M(o,e-1).text,null,s):0:"add"==n?c=l+t.options.indentUnit:"subtract"==n?c=l-t.options.indentUnit:"number"==typeof n&&(c=l+n),c=Math.max(0,c);var d="",f=0;if(t.options.indentWithTabs)for(var g=Math.floor(c/s);g;--g)f+=s,d+="\t";if(f1)if(Za&&Za.text.join("\n")==e){if(i.ranges.length%Za.text.length==0){l=[];for(var c=0;c=0;h--){var d=i.ranges[h],f=d.from(),p=d.to();d.empty()&&(n&&n>0?f=_(f.line,f.ch-n):t.state.overwrite&&!s?p=_(p.line,Math.min(M(o,p.line).text.length,p.ch+g(a).length)):Za&&Za.lineWise&&Za.text.join("\n")==e&&(f=p=_(f.line,0))),u=t.curOp.updateInput;var m={from:f,to:p,text:l?l[h%l.length]:a,origin:r||(s?"paste":t.state.cutIncoming?"cut":"+input")};Or(t.doc,m),xe(t,"inputRead",t,m)}e&&!s&&Zo(t,e),Kn(t),t.curOp.updateInput=u,t.curOp.typing=!0,t.state.pasteIncoming=t.state.cutIncoming=!1}function Jo(t,e){var n=t.clipboardData&&t.clipboardData.getData("Text");if(n)return t.preventDefault(),e.isReadOnly()||e.options.disableInput||fi(e,function(){return Xo(e,n,0,null,"paste")}),!0}function Zo(t,e){if(t.options.electricChars&&t.options.smartIndent)for(var n=t.doc.sel,i=n.ranges.length-1;i>=0;i--){var r=n.ranges[i];if(!(r.head.ch>100||i&&n.ranges[i-1].head.line==r.head.line)){var o=t.getModeAt(r.head),s=!1;if(o.electricChars){for(var a=0;a-1){s=Go(t,r.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(M(t.doc,r.head.line).text.slice(0,r.head.ch))&&(s=Go(t,r.head.line,"smart"));s&&xe(t,"electricInput",t,r.head.line)}}}function Qo(t){for(var e=[],n=[],i=0;i=t.first+t.size)&&(e=new _(i,e.ch,e.sticky),c=M(t,i))}function s(i){var s;if(null==(s=r?vo(t.cm,c,e,n):po(c,e,n))){if(i||!o())return!1;e=go(r,t.cm,c,e.line,n)}else e=s;return!0}var a=e,l=n,c=M(t,e.line);if("char"==i)s();else if("column"==i)s(!0);else if("word"==i||"group"==i)for(var u=null,h="group"==i,d=t.cm&&t.cm.getHelper(e,"wordChars"),f=!0;!(n<0)||s(!f);f=!1){var p=c.text.charAt(e.ch)||"\n",g=w(p,d)?"w":h&&"\n"==p?"n":!h||/\s/.test(p)?null:"p";if(!h||f||g||(g="s"),u&&u!=g){n<0&&(n=1,s(),e.sticky="after");break}if(g&&(u=g),n>0&&!s(!f))break}var v=Er(t,e,a,l,!0);return z(a,v)&&(v.hitSide=!0),v}function is(t,e,n,i){var r,o=t.doc,s=e.left;if("page"==i){var a=Math.min(t.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),l=Math.max(a-.5*bn(t.display),3);r=(n>0?e.bottom:e.top)+n*l}else"line"==i&&(r=n>0?e.bottom+3:e.top-3);for(var c;c=dn(t,s,r),c.outside;){if(n<0?r<=0:r>=o.height){c.hitSide=!0;break}r+=5*n}return c}function rs(t,e){var n=qe(t,e.line);if(!n||n.hidden)return null;var i=M(t.doc,e.line),r=Be(n,i,e.line),o=kt(i,t.doc.direction),s="left";if(o){s=Ct(o,e.ch)%2?"right":"left"}var a=Ye(r.map,e.ch,s);return a.offset="right"==a.collapse?a.end:a.start,a}function os(t){for(var e=t;e;e=e.parentNode)if(/CodeMirror-gutter-wrapper/.test(e.className))return!0;return!1}function ss(t,e){return e&&(t.bad=!0),t}function as(t,e,n,i,r){function o(t){return function(e){return e.id==t}}function s(){u&&(c+=h,u=!1)}function a(t){t&&(s(),c+=t)}function l(e){if(1==e.nodeType){var n=e.getAttribute("cm-text");if(null!=n)return void a(n||e.textContent.replace(/\u200b/g,""));var c,d=e.getAttribute("cm-marker");if(d){var f=t.findMarks(_(i,0),_(r+1,0),o(+d));return void(f.length&&(c=f[0].find(0))&&a(P(t.doc,c.from,c.to).join(h)))}if("false"==e.getAttribute("contenteditable"))return;var p=/^(pre|div|p)$/i.test(e.nodeName);p&&s();for(var g=0;g=15&&(Cs=!1,bs=!0);var Is,Ds=As&&(xs||Cs&&(null==Ns||Ns<12.11)),_s=fs||ms&&ys>=9,Fs=function(e,n){var i=e.className,r=t(n).exec(i);if(r){var o=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(o?r[1]+o:"")}};Is=document.createRange?function(t,e,n,i){var r=document.createRange();return r.setEnd(i||t,n),r.setStart(t,e),r}:function(t,e,n){var i=document.body.createTextRange();try{i.moveToElementText(t.parentNode)}catch(t){return i}return i.collapse(!0),i.moveEnd("character",n),i.moveStart("character",e),i};var zs=function(t){t.select()};Es?zs=function(t){t.selectionStart=0,t.selectionEnd=t.value.length}:ms&&(zs=function(t){try{t.select()}catch(t){}});var $s=function(){this.id=null};$s.prototype.set=function(t,e){clearTimeout(this.id),this.id=setTimeout(e,t)};var Rs,Vs,Hs=30,js={toString:function(){return"CodeMirror.Pass"}},Bs={scroll:!1},Ws={origin:"*mouse"},Us={origin:"+move"},qs=[""],Ks=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Gs=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Ys=!1,Xs=!1,Js=null,Zs=function(){function t(t){return t<=247?n.charAt(t):1424<=t&&t<=1524?"R":1536<=t&&t<=1785?i.charAt(t-1536):1774<=t&&t<=2220?"r":8192<=t&&t<=8203?"w":8204==t?"b":"L"}function e(t,e,n){this.level=t,this.from=e,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",i="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,s=/[LRr]/,a=/[Lb1n]/,l=/[1n]/;return function(n,i){var c="ltr"==i?"L":"R";if(0==n.length||"ltr"==i&&!r.test(n))return!1;for(var u=n.length,h=[],d=0;d=this.string.length},ca.prototype.sol=function(){return this.pos==this.lineStart},ca.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},ca.prototype.next=function(){if(this.pose},ca.prototype.eatSpace=function(){for(var t=this,e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++t.pos;return this.pos>e},ca.prototype.skipToEnd=function(){this.pos=this.string.length},ca.prototype.skipTo=function(t){var e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0},ca.prototype.backUp=function(t){this.pos-=t},ca.prototype.column=function(){return this.lastColumnPos0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}var r=function(t){return n?t.toLowerCase():t};if(r(this.string.substr(this.pos,t.length))==r(t))return!1!==e&&(this.pos+=t.length),!0},ca.prototype.current=function(){return this.string.slice(this.start,this.pos)},ca.prototype.hideFirstChars=function(t,e){this.lineStart+=t;try{return e()}finally{this.lineStart-=t}},ca.prototype.lookAhead=function(t){var e=this.lineOracle;return e&&e.lookAhead(t)},ca.prototype.baseToken=function(){var t=this.lineOracle;return t&&t.baseToken(this.pos)};var ua=function(t,e){this.state=t,this.lookAhead=e},ha=function(t,e,n,i){this.state=e,this.doc=t,this.line=n,this.maxLookAhead=i||0,this.baseTokens=null,this.baseTokenPos=1};ha.prototype.lookAhead=function(t){var e=this.doc.getLine(this.line+t);return null!=e&&t>this.maxLookAhead&&(this.maxLookAhead=t),e},ha.prototype.baseToken=function(t){var e=this;if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=t;)e.baseTokenPos+=2;var n=this.baseTokens[this.baseTokenPos+1];return{type:n&&n.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-t}},ha.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ha.fromSaved=function(t,e,n){return e instanceof ua?new ha(t,Ut(t.mode,e.state),n,e.lookAhead):new ha(t,Ut(t.mode,e),n)},ha.prototype.save=function(t){var e=!1!==t?Ut(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new ua(e,this.maxLookAhead):e};var da=function(t,e,n){this.start=t.start,this.end=t.pos,this.string=t.current(),this.type=e||null,this.state=n},fa=function(t,e,n){this.text=t,it(this,e),this.height=n?n(this):1};fa.prototype.lineNo=function(){return L(this)},Ot(fa);var pa,ga={},va={},ma=null,ya=null,ba={left:0,right:0,top:0,bottom:0},xa=function(t,e,n){this.cm=n;var r=this.vert=i("div",[i("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=i("div",[i("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");t(r),t(o),ta(r,"scroll",function(){r.clientHeight&&e(r.scrollTop,"vertical")}),ta(o,"scroll",function(){o.clientWidth&&e(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,ms&&ys<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};xa.prototype.update=function(t){var e=t.scrollWidth>t.clientWidth+1,n=t.scrollHeight>t.clientHeight+1,i=t.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=e?i+"px":"0";var r=t.viewHeight-(e?i:0);this.vert.firstChild.style.height=Math.max(0,t.scrollHeight-t.clientHeight+r)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(e){this.horiz.style.display="block",this.horiz.style.right=n?i+"px":"0",this.horiz.style.left=t.barLeft+"px";var o=t.viewWidth-t.barLeft-(n?i:0);this.horiz.firstChild.style.width=Math.max(0,t.scrollWidth-t.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&t.clientHeight>0&&(0==i&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?i:0,bottom:e?i:0}},xa.prototype.setScrollLeft=function(t){this.horiz.scrollLeft!=t&&(this.horiz.scrollLeft=t),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},xa.prototype.setScrollTop=function(t){this.vert.scrollTop!=t&&(this.vert.scrollTop=t),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},xa.prototype.zeroWidthHack=function(){var t=As&&!Ss?"12px":"18px";this.horiz.style.height=this.vert.style.width=t,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new $s,this.disableVert=new $s},xa.prototype.enableZeroWidthBar=function(t,e,n){function i(){var r=t.getBoundingClientRect();("vert"==n?document.elementFromPoint(r.right-1,(r.top+r.bottom)/2):document.elementFromPoint((r.right+r.left)/2,r.bottom-1))!=t?t.style.pointerEvents="none":e.set(1e3,i)}t.style.pointerEvents="auto",e.set(1e3,i)},xa.prototype.clear=function(){var t=this.horiz.parentNode;t.removeChild(this.horiz),t.removeChild(this.vert)};var wa=function(){};wa.prototype.update=function(){return{bottom:0,right:0}},wa.prototype.setScrollLeft=function(){},wa.prototype.setScrollTop=function(){},wa.prototype.clear=function(){};var Ca={native:xa,null:wa},ka=0,Sa=function(t,e,n){var i=t.display;this.viewport=e,this.visible=Rn(i,t.doc,e),this.editorIsHidden=!i.wrapper.offsetWidth,this.wrapperHeight=i.wrapper.clientHeight,this.wrapperWidth=i.wrapper.clientWidth,this.oldDisplayWidth=Ve(t),this.force=n,this.dims=wn(t),this.events=[]};Sa.prototype.signal=function(t,e){At(t,e)&&this.events.push(arguments)},Sa.prototype.finish=function(){for(var t=this,e=0;e=0&&F(t,r.to())<=0)return i}return-1};var Pa=function(t,e){this.anchor=t,this.head=e};Pa.prototype.from=function(){return V(this.anchor,this.head)},Pa.prototype.to=function(){return R(this.anchor,this.head)},Pa.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},Hr.prototype={chunkSize:function(){return this.lines.length},removeInner:function(t,e){for(var n=this,i=t,r=t+e;i1||!(this.children[0]instanceof Hr))){var l=[];this.collapse(l),this.children=[new Hr(l)],this.children[0].parent=this}},collapse:function(t){for(var e=this,n=0;n50){for(var a=o.lines.length%25+25,l=a;l10);t.parent.maybeSpill()}},iterN:function(t,e,n){for(var i=this,r=0;re.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=h,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&mi(e,r,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&kr(e.doc)),e&&xe(e,"markerCleared",e,this,r,o),n&&si(e),this.parent&&this.parent.clear()}},La.prototype.find=function(t,e){var n=this;null==t&&"bookmark"==this.type&&(t=1);for(var i,r,o=0;o=0;c--)Or(i,r[c]);l?br(this,l):this.cm&&Kn(this.cm)}),undo:vi(function(){Nr(this,"undo")}),redo:vi(function(){Nr(this,"redo")}),undoSelection:vi(function(){Nr(this,"undo",!0)}),redoSelection:vi(function(){Nr(this,"redo",!0)}),setExtending:function(t){this.extend=t},getExtending:function(){return this.extend},historySize:function(){for(var t=this.history,e=0,n=0,i=0;i=t.ch)&&e.push(r.marker.parent||r.marker)}return e},findMarks:function(t,e,n){t=j(this,t),e=j(this,e);var i=[],r=t.line;return this.iter(t.line,e.line+1,function(o){var s=o.markedSpans;if(s)for(var a=0;a=l.to||null==l.from&&r!=t.line||null!=l.from&&r==e.line&&l.from>=e.ch||n&&!n(l.marker)||i.push(l.marker.parent||l.marker)}++r}),i},getAllMarks:function(){var t=[];return this.iter(function(e){var n=e.markedSpans;if(n)for(var i=0;it)return e=t,!0;t-=o,++n}),j(this,_(n,e))},indexFromPos:function(t){t=j(this,t);var e=t.ch;if(t.linee&&(e=t.from),null!=t.to&&t.to0)r=new _(r.line,r.ch+1),t.replaceRange(o.charAt(r.ch-1)+o.charAt(r.ch-2),_(r.line,r.ch-2),r,"+transpose");else if(r.line>t.doc.first){var s=M(t.doc,r.line-1).text;s&&(r=new _(r.line,1),t.replaceRange(o.charAt(0)+t.doc.lineSeparator()+s.charAt(s.length-1),_(r.line-1,s.length-1),r,"+transpose"))}n.push(new Pa(r,r))}t.setSelections(n)})},newlineAndIndent:function(t){return fi(t,function(){for(var e=t.listSelections(),n=e.length-1;n>=0;n--)t.replaceRange(t.doc.lineSeparator(),e[n].anchor,e[n].head,"+input");e=t.listSelections();for(var i=0;it&&0==F(e,this.pos)&&n==this.button};var qa,Ka,Ga={toString:function(){return"CodeMirror.Init"}},Ya={},Xa={};qo.defaults=Ya,qo.optionHandlers=Xa;var Ja=[];qo.defineInitHook=function(t){return Ja.push(t)};var Za=null,Qa=function(t){this.cm=t,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new $s,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Qa.prototype.init=function(t){function e(t){if(!Mt(r,t)){if(r.somethingSelected())Yo({lineWise:!1,text:r.getSelections()}),"cut"==t.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var e=Qo(r);Yo({lineWise:!0,text:e.text}),"cut"==t.type&&r.operation(function(){r.setSelections(e.ranges,0,Bs),r.replaceSelection("",null,"cut")})}if(t.clipboardData){t.clipboardData.clearData();var n=Za.text.join("\n");if(t.clipboardData.setData("Text",n),t.clipboardData.getData("Text")==n)return void t.preventDefault()}var s=es(),a=s.firstChild;r.display.lineSpace.insertBefore(s,r.display.lineSpace.firstChild),a.value=Za.text.join("\n");var l=document.activeElement;zs(a),setTimeout(function(){r.display.lineSpace.removeChild(s),l.focus(),l==o&&i.showPrimarySelection()},50)}}var n=this,i=this,r=i.cm,o=i.div=t.lineDiv;ts(o,r.options.spellcheck),ta(o,"paste",function(t){Mt(r,t)||Jo(t,r)||ys<=11&&setTimeout(pi(r,function(){return n.updateFromDOM()}),20)}),ta(o,"compositionstart",function(t){n.composing={data:t.data,done:!1}}),ta(o,"compositionupdate",function(t){n.composing||(n.composing={data:t.data,done:!1})}),ta(o,"compositionend",function(t){n.composing&&(t.data!=n.composing.data&&n.readFromDOMSoon(),n.composing.done=!0)}),ta(o,"touchstart",function(){return i.forceCompositionEnd()}),ta(o,"input",function(){n.composing||n.readFromDOMSoon()}),ta(o,"copy",e),ta(o,"cut",e)},Qa.prototype.prepareSelection=function(){var t=Pn(this.cm,!1);return t.focus=this.cm.state.focused,t},Qa.prototype.showSelection=function(t,e){t&&this.cm.display.view.length&&((t.focus||e)&&this.showPrimarySelection(),this.showMultipleSelections(t))},Qa.prototype.showPrimarySelection=function(){var t=window.getSelection(),e=this.cm,n=e.doc.sel.primary(),i=n.from(),r=n.to();if(e.display.viewTo==e.display.viewFrom||i.line>=e.display.viewTo||r.line=e.display.viewFrom&&rs(e,i)||{node:a[0].measure.map[2],offset:0},c=r.linet.firstLine()&&(i=_(i.line-1,M(t.doc,i.line-1).length)),r.ch==M(t.doc,r.line).text.length&&r.linee.viewTo-1)return!1;var o,s,a;i.line==e.viewFrom||0==(o=En(t,i.line))?(s=L(e.view[0].line),a=e.view[0].node):(s=L(e.view[o].line),a=e.view[o-1].node.nextSibling);var l,c,u=En(t,r.line);if(u==e.view.length-1?(l=e.viewTo-1,c=e.lineDiv.lastChild):(l=L(e.view[u+1].line)-1,c=e.view[u+1].node.previousSibling),!a)return!1;for(var h=t.doc.splitLines(as(t,a,c,s,l)),d=P(t.doc,_(s,0),_(l,M(t.doc,l).text.length));h.length>1&&d.length>1;)if(g(h)==g(d))h.pop(),d.pop(),l--;else{if(h[0]!=d[0])break;h.shift(),d.shift(),s++}for(var f=0,p=0,v=h[0],m=d[0],y=Math.min(v.length,m.length);fi.ch&&b.charCodeAt(b.length-p-1)==x.charCodeAt(x.length-p-1);)f--,p++;h[h.length-1]=b.slice(0,b.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(f).replace(/\u200b+$/,"");var C=_(s,f),k=_(l,d.length?g(d).length-p:0);return h.length>1||h[0]||F(C,k)?(Fr(t.doc,h,C,k,"+input"),!0):void 0},Qa.prototype.ensurePolled=function(){this.forceCompositionEnd()},Qa.prototype.reset=function(){this.forceCompositionEnd()},Qa.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Qa.prototype.readFromDOMSoon=function(){var t=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(t.readDOMTimeout=null,t.composing){if(!t.composing.done)return;t.composing=null}t.updateFromDOM()},80))},Qa.prototype.updateFromDOM=function(){var t=this;!this.cm.isReadOnly()&&this.pollContent()||fi(this.cm,function(){return mi(t.cm)})},Qa.prototype.setUneditable=function(t){t.contentEditable="false"},Qa.prototype.onKeyPress=function(t){0!=t.charCode&&(t.preventDefault(),this.cm.isReadOnly()||pi(this.cm,Xo)(this.cm,String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),0))},Qa.prototype.readOnlyChanged=function(t){this.div.contentEditable=String("nocursor"!=t)},Qa.prototype.onContextMenu=function(){},Qa.prototype.resetPosition=function(){},Qa.prototype.needsContentAttribute=!0;var tl=function(t){this.cm=t,this.prevInput="",this.pollingFast=!1,this.polling=new $s,this.hasSelection=!1,this.composing=null};tl.prototype.init=function(t){function e(t){if(!Mt(r,t)){if(r.somethingSelected())Yo({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var e=Qo(r);Yo({lineWise:!0,text:e.text}),"cut"==t.type?r.setSelections(e.ranges,null,Bs):(i.prevInput="",s.value=e.text.join("\n"),zs(s))}"cut"==t.type&&(r.state.cutIncoming=!0)}}var n=this,i=this,r=this.cm,o=this.wrapper=es(),s=this.textarea=o.firstChild;t.wrapper.insertBefore(o,t.wrapper.firstChild),Es&&(s.style.width="0px"),ta(s,"input",function(){ms&&ys>=9&&n.hasSelection&&(n.hasSelection=null),i.poll()}),ta(s,"paste",function(t){Mt(r,t)||Jo(t,r)||(r.state.pasteIncoming=!0,i.fastPoll())}),ta(s,"cut",e),ta(s,"copy",e),ta(t.scroller,"paste",function(e){_e(t,e)||Mt(r,e)||(r.state.pasteIncoming=!0,i.focus())}),ta(t.lineSpace,"selectstart",function(e){_e(t,e)||Lt(e)}),ta(s,"compositionstart",function(){var t=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:t,range:r.markText(t,r.getCursor("to"),{className:"CodeMirror-composing"})}}),ta(s,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},tl.prototype.prepareSelection=function(){var t=this.cm,e=t.display,n=t.doc,i=Pn(t);if(t.options.moveInputWithCursor){var r=cn(t,n.sel.primary().head,"div"),o=e.wrapper.getBoundingClientRect(),s=e.lineDiv.getBoundingClientRect();i.teTop=Math.max(0,Math.min(e.wrapper.clientHeight-10,r.top+s.top-o.top)),i.teLeft=Math.max(0,Math.min(e.wrapper.clientWidth-10,r.left+s.left-o.left))}return i},tl.prototype.showSelection=function(t){var e=this.cm,i=e.display;n(i.cursorDiv,t.cursors),n(i.selectionDiv,t.selection),null!=t.teTop&&(this.wrapper.style.top=t.teTop+"px",this.wrapper.style.left=t.teLeft+"px")},tl.prototype.reset=function(t){if(!this.contextMenuPending&&!this.composing){var e=this.cm;if(e.somethingSelected()){this.prevInput="";var n=e.getSelection();this.textarea.value=n,e.state.focused&&zs(this.textarea),ms&&ys>=9&&(this.hasSelection=n)}else t||(this.prevInput=this.textarea.value="",ms&&ys>=9&&(this.hasSelection=null))}},tl.prototype.getField=function(){return this.textarea},tl.prototype.supportsTouch=function(){return!1},tl.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!Ps||s()!=this.textarea))try{this.textarea.focus()}catch(t){}},tl.prototype.blur=function(){this.textarea.blur()},tl.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},tl.prototype.receivedFocus=function(){this.slowPoll()},tl.prototype.slowPoll=function(){var t=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){t.poll(),t.cm.state.focused&&t.slowPoll()})},tl.prototype.fastPoll=function(){function t(){n.poll()||e?(n.pollingFast=!1,n.slowPoll()):(e=!0,n.polling.set(60,t))}var e=!1,n=this;n.pollingFast=!0,n.polling.set(20,t)},tl.prototype.poll=function(){var t=this,e=this.cm,n=this.textarea,i=this.prevInput;if(this.contextMenuPending||!e.state.focused||ia(n)&&!i&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var r=n.value;if(r==i&&!e.somethingSelected())return!1;if(ms&&ys>=9&&this.hasSelection===r||As&&/[\uf700-\uf7ff]/.test(r))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var o=r.charCodeAt(0);if(8203!=o||i||(i="​"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var s=0,a=Math.min(i.length,r.length);s1e3||r.indexOf("\n")>-1?n.value=t.prevInput="":t.prevInput=r,t.composing&&(t.composing.range.clear(),t.composing.range=e.markText(t.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},tl.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},tl.prototype.onKeyPress=function(){ms&&ys>=9&&(this.hasSelection=null),this.fastPoll()},tl.prototype.onContextMenu=function(t){function e(){if(null!=s.selectionStart){var t=r.somethingSelected(),e="​"+(t?s.value:"");s.value="⇚",s.value=e,i.prevInput=t?"":"​",s.selectionStart=1,s.selectionEnd=e.length,o.selForContextMenu=r.doc.sel}}function n(){if(i.contextMenuPending=!1,i.wrapper.style.cssText=u,s.style.cssText=c,ms&&ys<9&&o.scrollbars.setScrollTop(o.scroller.scrollTop=l),null!=s.selectionStart){(!ms||ms&&ys<9)&&e();var t=0,n=function(){o.selForContextMenu==r.doc.sel&&0==s.selectionStart&&s.selectionEnd>0&&"​"==i.prevInput?pi(r,Pr)(r):t++<10?o.detectingSelectAll=setTimeout(n,500):(o.selForContextMenu=null,o.input.reset())};o.detectingSelectAll=setTimeout(n,200)}}var i=this,r=i.cm,o=r.display,s=i.textarea,a=Tn(r,t),l=o.scroller.scrollTop;if(a&&!Cs){r.options.resetSelectionOnContextMenu&&-1==r.doc.sel.contains(a)&&pi(r,xr)(r.doc,Vi(a),Bs);var c=s.style.cssText,u=i.wrapper.style.cssText;i.wrapper.style.cssText="position: absolute";var h=i.wrapper.getBoundingClientRect();s.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(t.clientY-h.top-5)+"px; left: "+(t.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(ms?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var d;if(bs&&(d=window.scrollY),o.input.focus(),bs&&window.scrollTo(null,d),o.input.reset(),r.somethingSelected()||(s.value=i.prevInput=" "),i.contextMenuPending=!0,o.selForContextMenu=r.doc.sel,clearTimeout(o.detectingSelectAll),ms&&ys>=9&&e(),_s){Dt(t);var f=function(){Tt(window,"mouseup",f),setTimeout(n,20)};ta(window,"mouseup",f)}else setTimeout(n,50)}},tl.prototype.readOnlyChanged=function(t){t||this.reset(),this.textarea.disabled="nocursor"==t},tl.prototype.setUneditable=function(){},tl.prototype.needsContentAttribute=!1,function(t){function e(e,i,r,o){t.defaults[e]=i,r&&(n[e]=o?function(t,e,n){n!=Ga&&r(t,e,n)}:r)}var n=t.optionHandlers;t.defineOption=e,t.Init=Ga,e("value","",function(t,e){return t.setValue(e)},!0),e("mode",null,function(t,e){t.doc.modeOption=e,qi(t)},!0),e("indentUnit",2,qi,!0),e("indentWithTabs",!1),e("smartIndent",!0),e("tabSize",4,function(t){Ki(t),en(t),mi(t)},!0),e("lineSeparator",null,function(t,e){if(t.doc.lineSep=e,e){var n=[],i=t.doc.first;t.doc.iter(function(t){for(var r=0;;){var o=t.text.indexOf(e,r);if(-1==o)break;r=o+e.length,n.push(_(i,o))}i++});for(var r=n.length-1;r>=0;r--)Fr(t.doc,e,n[r],_(n[r].line,n[r].ch+e.length))}}),e("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,e,n){t.state.specialChars=new RegExp(e.source+(e.test("\t")?"":"|\t"),"g"),n!=Ga&&t.refresh()}),e("specialCharPlaceholder",ce,function(t){return t.refresh()},!0),e("electricChars",!0),e("inputStyle",Ps?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),e("spellcheck",!1,function(t,e){return t.getInputField().spellcheck=e},!0),e("rtlMoveVisually",!Ls),e("wholeLineUpdateBefore",!0),e("theme","default",function(t){jo(t),Bo(t)},!0),e("keyMap","default",function(t,e,n){var i=uo(e),r=n!=Ga&&uo(n);r&&r.detach&&r.detach(t,i),i.attach&&i.attach(t,r||null)}),e("extraKeys",null),e("configureMouse",null),e("lineWrapping",!1,Uo,!0),e("gutters",[],function(t){_i(t.options),Bo(t)},!0),e("fixedGutter",!0,function(t,e){t.display.gutters.style.left=e?Cn(t.display)+"px":"0",t.refresh()},!0),e("coverGutterNextToScrollbar",!1,function(t){return ni(t)},!0),e("scrollbarStyle","native",function(t){ri(t),ni(t),t.display.scrollbars.setScrollTop(t.doc.scrollTop),t.display.scrollbars.setScrollLeft(t.doc.scrollLeft)},!0),e("lineNumbers",!1,function(t){_i(t.options),Bo(t)},!0),e("firstLineNumber",1,Bo,!0),e("lineNumberFormatter",function(t){return t},Bo,!0),e("showCursorWhenSelecting",!1,Mn,!0),e("resetSelectionOnContextMenu",!0),e("lineWiseCopyCut",!0),e("pasteLinesPerSelection",!0),e("readOnly",!1,function(t,e){"nocursor"==e&&(Fn(t),t.display.input.blur()),t.display.input.readOnlyChanged(e)}),e("disableInput",!1,function(t,e){e||t.display.input.reset()},!0),e("dragDrop",!0,Wo),e("allowDropFileTypes",null),e("cursorBlinkRate",530),e("cursorScrollMargin",0),e("cursorHeight",1,Mn,!0),e("singleCursorHeightPerLine",!0,Mn,!0),e("workTime",100),e("workDelay",100),e("flattenSpans",!0,Ki,!0),e("addModeClass",!1,Ki,!0),e("pollInterval",100),e("undoDepth",200,function(t,e){return t.doc.history.undoDepth=e}),e("historyEventDelay",1250),e("viewportMargin",10,function(t){return t.refresh()},!0),e("maxHighlightLength",1e4,Ki,!0),e("moveInputWithCursor",!0,function(t,e){e||t.display.input.resetPosition()}),e("tabindex",null,function(t,e){return t.display.input.getField().tabIndex=e||""}),e("autofocus",null),e("direction","ltr",function(t,e){return t.doc.setDirection(e)},!0)}(qo),function(t){var e=t.optionHandlers,n=t.helpers={};t.prototype={constructor:t,focus:function(){window.focus(),this.display.input.focus()},setOption:function(t,n){var i=this.options,r=i[t];i[t]==n&&"mode"!=t||(i[t]=n,e.hasOwnProperty(t)&&pi(this,e[t])(this,n,r),Et(this,"optionChange",this,t))},getOption:function(t){return this.options[t]},getDoc:function(){return this.doc},addKeyMap:function(t,e){this.state.keyMaps[e?"push":"unshift"](uo(t))},removeKeyMap:function(t){for(var e=this.state.keyMaps,n=0;ni&&(Go(e,o.head.line,t,!0),i=o.head.line,r==e.doc.sel.primIndex&&Kn(e));else{var s=o.from(),a=o.to(),l=Math.max(i,s.line);i=Math.min(e.lastLine(),a.line-(a.ch?0:1))+1;for(var c=l;c0&&vr(e.doc,r,new Pa(s,u[r].to()),Bs)}}}),getTokenAt:function(t,e){return te(this,t,e)},getLineTokens:function(t,e){return te(this,_(t),e,!0)},getTokenTypeAt:function(t){t=j(this.doc,t);var e,n=Yt(this,M(this.doc,t.line)),i=0,r=(n.length-1)/2,o=t.ch;if(0==o)e=n[2];else for(;;){var s=i+r>>1;if((s?n[2*s-1]:0)>=o)r=s;else{if(!(n[2*s+1]o&&(t=o,r=!0),i=M(this.doc,t)}else i=t;return sn(this,i,{top:0,left:0},e||"page",n||r).top+(r?this.doc.height-yt(i):0)},defaultTextHeight:function(){return bn(this.display)},defaultCharWidth:function(){return xn(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(t,e,n,i,r){var o=this.display;t=cn(this,j(this.doc,t));var s=t.bottom,a=t.left;if(e.style.position="absolute",e.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(e),o.sizer.appendChild(e),"over"==i)s=t.top;else if("above"==i||"near"==i){var l=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==i||t.bottom+e.offsetHeight>l)&&t.top>e.offsetHeight?s=t.top-e.offsetHeight:t.bottom+e.offsetHeight<=l&&(s=t.bottom),a+e.offsetWidth>c&&(a=c-e.offsetWidth)}e.style.top=s+"px",e.style.left=e.style.right="","right"==r?(a=o.sizer.clientWidth-e.offsetWidth,e.style.right="0px"):("left"==r?a=0:"middle"==r&&(a=(o.sizer.clientWidth-e.offsetWidth)/2),e.style.left=a+"px"),n&&Wn(this,{left:a,top:s,right:a+e.offsetWidth,bottom:s+e.offsetHeight})},triggerOnKeyDown:gi(To),triggerOnKeyPress:gi(Po),triggerOnKeyUp:Mo,triggerOnMouseDown:gi(Oo),execCommand:function(t){if(ja.hasOwnProperty(t))return ja[t].call(null,this)},triggerElectric:gi(function(t){Zo(this,t)}),findPosH:function(t,e,n,i){var r=this,o=1;e<0&&(o=-1,e=-e);for(var s=j(this.doc,t),a=0;a0&&a(n.charAt(i-1));)--i;for(;r.5)&&Sn(this),Et(this,"refresh",this)}),swapDoc:gi(function(t){var e=this.doc;return e.cm=null,Ji(this,t),en(this),this.display.input.reset(),Gn(this,t.scrollLeft,t.scrollTop),this.curOp.forceScroll=!0,xe(this,"swapDoc",this,e),e}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Ot(t),t.registerHelper=function(e,i,r){n.hasOwnProperty(e)||(n[e]=t[e]={_global:[]}),n[e][i]=r},t.registerGlobalHelper=function(e,i,r,o){t.registerHelper(e,i,o),n[e]._global.push({pred:r,val:o})}}(qo);var el="iter insert remove copy getEditor constructor".split(" ");for(var nl in Da.prototype)Da.prototype.hasOwnProperty(nl)&&d(el,nl)<0&&(qo.prototype[nl]=function(t){return function(){return t.apply(this.doc,arguments)}}(Da.prototype[nl]));return Ot(Da),qo.inputStyles={textarea:tl,contenteditable:Qa},qo.defineMode=function(t){qo.defaults.mode||"null"==t||(qo.defaults.mode=t),Vt.apply(this,arguments)},qo.defineMIME=Ht,qo.defineMode("null",function(){return{token:function(t){return t.skipToEnd()}}}),qo.defineMIME("text/plain","null"),qo.defineExtension=function(t,e){qo.prototype[t]=e},qo.defineDocExtension=function(t,e){Da.prototype[t]=e},qo.fromTextArea=us,function(t){t.off=Tt,t.on=ta,t.wheelEventPixels=zi,t.Doc=Da,t.splitLines=na,t.countColumn=h,t.findColumn=f,t.isWordChar=x,t.Pass=js,t.signal=Et,t.Line=fa,t.changeEnd=Hi,t.scrollbarModel=Ca,t.Pos=_,t.cmpPos=F,t.modes=sa,t.mimeModes=aa,t.resolveMode=jt,t.getMode=Bt,t.modeExtensions=la,t.extendMode=Wt,t.copyState=Ut,t.startState=Kt,t.innerMode=qt,t.commands=ja,t.keyMap=Ha,t.keyName=co,t.isModifierKey=ao,t.lookupKey=so,t.normalizeKeyMap=oo,t.StringStream=ca,t.SharedTextMarker=Na,t.TextMarker=La,t.LineWidget=Aa,t.e_preventDefault=Lt,t.e_stopPropagation=Nt,t.e_stop=Dt,t.addClass=a,t.contains=o,t.rmClass=Fs,t.keyNames=za}(qo),qo.version="5.31.0",qo})},function(t,e,n){"use strict";var i=n(0),r=i.Model.extend({idAttribute:"name",defaults:{name:"",label:"",type:1,active:!0,private:!1,protected:!1},initialize:function(){var t=this.get("name"),e=this.get("label");t?e||this.set("label",t):this.set("name",e),this.set("name",r.escapeName(this.get("name")))},getFullName:function(){var t="";switch(this.get("type")){case 1:t=".";break;case 2:t="#"}return t+this.get("name")}},{TYPE_CLASS:1,TYPE_ID:2,escapeName:function(t){return(""+t).trim().replace(/([^a-z0-9\w-]+)/gi,"-")}});t.exports=r},function(t,e,n){"use strict";var i=(n(1),n(0)),r=i.$;t.exports=i.View.extend({events:{change:"onChange"},attributes:function(){return this.model.get("attributes")},initialize:function(t){var e=this.model,n=(e.get("name"),e.target);this.config=t.config||{},this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.target=n,this.className=this.pfx+"trait",this.labelClass=this.ppfx+"label",this.fieldClass=this.ppfx+"field "+this.ppfx+"field-"+e.get("type"),this.inputhClass=this.ppfx+"input-holder",e.off("change:value",this.onValueChange),this.listenTo(e,"change:value",this.onValueChange),this.tmpl='
'},onChange:function(){this.model.set("value",this.getInputEl().value)},getValueForTarget:function(){return this.model.get("value")},setInputValue:function(t){this.getInputEl().value=t},onValueChange:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.model;this.target,i.get("name");if(n.fromTarget)this.setInputValue(i.get("value"));else{var r=this.getValueForTarget();i.setTargetValue(r)}},renderLabel:function(){this.$el.html('
'+this.getLabel()+"
")},getLabel:function(){var t=this.model,e=t.get("label")||t.get("name");return e.charAt(0).toUpperCase()+e.slice(1).replace(/-/g," ")},getInputEl:function(){if(!this.$input){var t=this.model,e=this.target,n=t.get("name"),i=t.get("placeholder")||t.get("default")||"",o=t.get("type")||"text",s=e.get("attributes"),a=t.get("min"),l=t.get("max"),c=t.get("changeProp")?e.get(n):t.get("value")||s[n],u=r('');c&&u.prop("value",c),a&&u.prop("min",a),l&&u.prop("max",l),this.$input=u}return this.$input.get(0)},getModelValue:function(){var t,e=this.model,n=this.target,i=e.get("name");if(e.get("changeProp"))t=n.get(i);else{var r=n.get("attributes");t=e.get("value")||r[i]}return t},renderField:function(){if(!this.$input){this.$el.append(this.tmpl);var t=this.getInputEl(),e=this.el.querySelector("."+this.inputhClass);e.insertBefore(t,e.childNodes[0])}},render:function(){return this.renderLabel(),this.renderField(),this.el.className=this.className,this}})},function(t,e,n){"use strict";var i,r;!function(o,s){i=s,void 0!==(r="function"==typeof i?i.call(e,n,e,t):i)&&(t.exports=r)}(0,function(){function t(t,e){return e=e||M,z.test(t)?e.getElementsByClassName(t.slice(1)):R.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t)}function e(t){if(!E){E=M.implementation.createHTMLDocument();var e=E.createElement("base");e.href=M.location.href,E.head.appendChild(e)}return E.body.innerHTML=t,E.body.childNodes}function n(t){"loading"!==M.readyState?t():M.addEventListener("DOMContentLoaded",t)}function i(i,r){if(!i)return this;if(i.cash&&i!==P)return i;var o,s=i,a=0;if(_(i))s=F.test(i)?M.getElementById(i.slice(1)):$.test(i)?e(i):t(i,r);else if(D(i))return n(i),this;if(!s)return this;if(s.nodeType||s===P)this[0]=s,this.length=1;else for(o=this.length=s.length;a=0&&s.splice(i,1)):(o(s,function(n){t.removeEventListener(e,n)}),s=[]))}function x(t,e){return"&"+encodeURIComponent(t)+"="+encodeURIComponent(e).replace(/%20/g,"+")}function w(t){var e=[];return o(t.options,function(t){t.selected&&e.push(t.value)}),e.length?e:null}function C(t){var e=t.selectedIndex;return e>=0?t.options[e].value:null}function k(t){var e=t.type;if(!e)return null;switch(e.toLowerCase()){case"select-one":return C(t);case"select-multiple":return w(t);case"radio":case"checkbox":return t.checked?t.value:null;default:return t.value?t.value:null}}function S(t,e,n){if(n){var i=t.childNodes[0];t.insertBefore(e,i)}else t.appendChild(e)}function T(t,e,n){var i=_(e);if(!i&&e.length)return void o(e,function(e){return T(t,e,n)});o(t,i?function(t){return t.insertAdjacentHTML(n?"afterbegin":"beforeend",e)}:function(t,i){return S(t,0===i?e:e.cloneNode(!0),n)})}var E,M=document,P=window,A=Array.prototype,O=A.slice,L=A.filter,N=A.push,I=function(){},D=function(t){return typeof t==typeof I&&t.call},_=function(t){return"string"==typeof t},F=/^#[\w-]*$/,z=/^\.[\w-]*$/,$=/<.+>/,R=/^\w+$/,V=r.fn=r.prototype=i.prototype={cash:!0,length:0,push:N,splice:A.splice,map:A.map,init:i};Object.defineProperty(V,"constructor",{value:r}),r.parseHTML=e,r.noop=I,r.isFunction=D,r.isString=_,r.extend=V.extend=function(t){t=t||{};var e=O.call(arguments),n=e.length,i=1;for(1===e.length&&(t=this,i=0);i1?this.each(function(n){return n.style[t]=e}):P.getComputedStyle(this[0])[t];for(var n in t)this.css(n,t[n]);return this}}),o(["Width","Height"],function(t){var e=t.toLowerCase();V[e]=function(){return this[0].getBoundingClientRect()[e]},V["inner"+t]=function(){return this[0]["client"+t]},V["outer"+t]=function(e){return this[0]["offset"+t]+(e?m(this,"margin"+("Width"===t?"Left":"Top"))+m(this,"margin"+("Width"===t?"Right":"Bottom")):0)}}),V.extend({off:function(t,e){return this.each(function(n){return b(n,t,e)})},on:function(t,e,i,r){var o;if(!_(t)){for(var a in t)this.on(a,e,t[a]);return this}return D(e)&&(i=e,e=null),"ready"===t?(n(i),this):(e&&(o=i,i=function(t){for(var n=t.target;!s(n,e);){if(n===this)return n=!1;n=n.parentNode}n&&o.call(n,t)}),this.each(function(e){var n=i;r&&(n=function(){i.apply(this,arguments),b(e,t,n)}),y(e,t,n)}))},one:function(t,e,n){return this.on(t,e,n,!0)},ready:n,trigger:function(t,e){var n=M.createEvent("HTMLEvents");return n.data=e,n.initEvent(t,!0,!1),this.each(function(t){return t.dispatchEvent(n)})}}),V.extend({serialize:function(){var t="";return o(this[0].elements||this,function(e){if(!e.disabled&&"FIELDSET"!==e.tagName){var n=e.name;switch(e.type.toLowerCase()){case"file":case"reset":case"submit":case"button":break;case"select-multiple":var i=k(e);null!==i&&o(i,function(e){t+=x(n,e)});break;default:var r=k(e);null!==r&&(t+=x(n,r))}}}),t.substr(1)},val:function(t){return void 0===t?k(this[0]):this.each(function(e){return e.value=t})}}),V.extend({after:function(t){return r(t).insertAfter(this),this},append:function(t){return T(this,t),this},appendTo:function(t){return T(r(t),this),this},before:function(t){return r(t).insertBefore(this),this},clone:function(){return r(this.map(function(t){return t.cloneNode(!0)}))},empty:function(){return this.html(""),this},html:function(t){if(void 0===t)return this[0].innerHTML;var e=t.nodeType?t[0].outerHTML:t;return this.each(function(t){return t.innerHTML=e})},insertAfter:function(t){var e=this;return r(t).each(function(t,n){var i=t.parentNode,r=t.nextSibling;e.each(function(t){i.insertBefore(0===n?t:t.cloneNode(!0),r)})}),this},insertBefore:function(t){var e=this;return r(t).each(function(t,n){var i=t.parentNode;e.each(function(e){i.insertBefore(0===n?e:e.cloneNode(!0),t)})}),this},prepend:function(t){return T(this,t,!0),this},prependTo:function(t){return T(r(t),this,!0),this},remove:function(){return this.each(function(t){return t.parentNode.removeChild(t)})},text:function(t){return void 0===t?this[0].textContent:this.each(function(e){return e.textContent=t})}});var U=M.documentElement;return V.extend({position:function(){var t=this[0];return{left:t.offsetLeft,top:t.offsetTop}},offset:function(){var t=this[0].getBoundingClientRect();return{top:t.top+P.pageYOffset-U.clientTop,left:t.left+P.pageXOffset-U.clientLeft}},offsetParent:function(){return r(this[0].offsetParent)}}),V.extend({children:function(t){var e=[];return this.each(function(t){N.apply(e,t.children)}),e=l(e),t?e.filter(function(e){return s(e,t)}):e},closest:function(t){return!t||this.length<1?r():this.is(t)?this.filter(t):this.parent().closest(t)},is:function(t){if(!t)return!1;var e=!1,n=a(t);return this.each(function(i){return!(e=n(i,t))}),e},find:function(e){if(!e||e.nodeType)return r(e&&this.has(e).length?e:null);var n=[];return this.each(function(i){N.apply(n,t(e,i))}),l(n)},has:function(e){var n=_(e)?function(n){return 0!==t(e,n).length}:function(t){return t.contains(e)};return this.filter(n)},next:function(){return r(this[0].nextElementSibling)},not:function(t){if(!t)return this;var e=a(t);return this.filter(function(n){return!e(n,t)})},parent:function(){var t=[];return this.each(function(e){e&&e.parentNode&&t.push(e.parentNode)}),l(t)},parents:function(t){var e,n=[];return this.each(function(i){for(e=i;e&&e.parentNode&&e!==M.body.parentNode;)e=e.parentNode,(!t||t&&s(e,t))&&n.push(e)}),l(n)},prev:function(){return r(this[0].previousElementSibling)},siblings:function(){var t=this.parent().children(),e=this[0];return t.filter(function(t){return t!==e})}}),r})},function(t,e,n){"use strict";var i=n(1),r=n(7);t.exports=n(0).Collection.extend({model:r,getStyleable:function(){return(0,i.filter)(this.models,function(t){return t.get("active")&&!t.get("private")})},getValid:function(){return(0,i.filter)(this.models,function(t){return!t.get("private")})},getFullString:function(t){var e=[];return(t||this).forEach(function(t){return e.push(t.getFullName())}),e.join("").trim()}})},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.parseValue(t);this.set(r,i({},n,{avoidStore:1})),e&&(this.set("value","",n),this.set(r,n))},setValueFromInput:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.setValue(t,e,i({},n,{fromInput:1}))},parseValue:function(t){var e={value:t};if(!this.get("functionName"))return e;var n=[],i=""+t,r=i.indexOf("(")+1,o=i.lastIndexOf(")");return n.push(r),o>=0&&n.push(o),e.value=String.prototype.substring.apply(i,n),e},getDefaultValue:function(){return this.get("defaults")},getFullValue:function(t){var e=this.get("functionName"),n=t||this.get("value");return e&&(n=e+"("+n+")"),n}})},function(t,e,n){"use strict";(function(e){n(5),n(14),n(36),n(37),n(38),n(40),n(17),n(34);t.exports=e.View.extend({initialize:function(t){this.config=t.config||{},this.pfx=this.config.stylePrefix||"",this.target=t.target||{},this.propTarget=t.propTarget||{},this.onChange=t.onChange,this.onInputRender=t.onInputRender||{},this.customValue=t.customValue||{};var e=this.collection;this.listenTo(e,"add",this.addTo),this.listenTo(e,"reset",this.render)},addTo:function(t){this.add(t)},add:function(t,e){var n=new t.typeView({model:t,name:t.get("name"),id:this.pfx+t.get("property"),target:this.target,propTarget:this.propTarget,onChange:this.onChange,onInputRender:this.onInputRender,config:this.config});"composite"!=t.get("type")&&(n.customValue=this.customValue),n.render();var i=n.el;e?e.appendChild(i):this.el.appendChild(i)},render:function(){var t=this,e=document.createDocumentFragment();return this.collection.each(function(n){return t.add(n,e)}),this.$el.append(e),this.$el.attr("class",this.pfx+"properties"),this}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=(n(18),e.$);t.exports=n(5).extend({templateInput:function(){return""},init:function(){var t=this.model;this.listenTo(t,"change:unit",this.modelValueChanged),this.listenTo(t,"el:change",this.elementUpdated)},setValue:function(t){this.inputInst.setValue(t,{silent:1})},onRender:function(){var t=this.ppfx;if(!this.input){var e=this.model.input;e.ppfx=t,e.render();this.el.querySelector("."+t+"fields").appendChild(e.el),this.$input=e.inputEl,this.unit=e.unitEl,this.$unit=i(this.unit),this.input=this.$input.get(0),this.inputInst=e}}})}).call(e,n(0))},function(t,e,n){"use strict";var i=(n(0),n(3));t.exports=i.extend({tagName:"img",events:{dblclick:"openModal",click:"initResize"},initialize:function(t){var e=this.model;i.prototype.initialize.apply(this,arguments),this.listenTo(e,"change:src",this.updateSrc),this.listenTo(e,"dblclick active",this.openModal),this.classEmpty=this.ppfx+"plh-image";var n=this.config;n.modal&&(this.modal=n.modal),n.am&&(this.am=n.am)},updateSrc:function(){var t=this.model.get("src"),e=this.$el;e.attr("src",t),e[t?"removeClass":"addClass"](this.classEmpty)},openModal:function(t){var e=this.opts.config.em,n=e?e.get("Editor"):"";n&&this.model.get("editable")&&n.runCommand("open-assets",{target:this.model,onSelect:function(){n.Modal.close(),n.AssetManager.setTarget(null)}})},render:function(){this.updateAttributes(),this.updateClasses();var t=this.$el.attr("class")||"";return this.model.get("src")||this.$el.attr("class",(t+" "+this.classEmpty).trim()),this.$el.attr("onmousedown","return false"),this}})},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";(function(e){var i=n(5),r=e.$;t.exports=i.extend({templateInput:function(){var t=this.pfx;return'\n
\n \n
\n '},inputValueChanged:function(){if(!this.model.get("detached")){for(var t=arguments.length,e=Array(t),n=0;n'),this.input=this.$input.get(0)),this.props||(this.props=t.get("properties")),!this.$props)){this.props.each(function(e,n){e&&"composite"==e.get("type")&&(this.props.remove(e),console.warn("Nested composite types not yet allowed.")),e.parent=t},this);var i=n(13),o=new i(this.getPropsConfig());this.$props=o.render().$el,this.$el.find("#"+this.pfx+"input-holder").append(this.$props)}},getPropsConfig:function(t){var e=this,n=this.model,i={config:this.config,collection:this.props,target:this.target,propTarget:this.propTarget,onChange:function(t,e,i){n.set("value",n.getFullValue(),i)},customValue:function(t,n){return e.valueOnIndex(n,t)}};return n.get("detached")&&delete i.onChange,i},valueOnIndex:function(t,e){var n=void 0,i=this.getTargetValue({ignoreDefault:1});if(i){n=i.split(" ")[t]}else n=e&&e.getTargetValue({ignoreCustomValue:1,ignoreDefault:1});return e&&(n=e.model.parseValue(n).value),n}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=n(1),r=n(2),o=n(35),s=n(0);s.$;t.exports=o.extend({events:{"change input":"handleChange","change select":"handleUnitChange","click [data-arrow-up]":"upArrowClick","click [data-arrow-down]":"downArrowClick","mousedown [data-arrows]":"downIncrement"},template:function(){var t=this.ppfx;return'\n \n \n
\n
\n
\n
\n '},inputClass:function(){var t=this.ppfx;return this.opts.contClass||t+"field "+t+"field-integer"},initialize:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];o.prototype.initialize.apply(this,arguments),(0,i.bindAll)(this,"moveIncrement","upIncrement"),this.doc=document,this.listenTo(this.model,"change:unit",this.handleModelChange)},setValue:function(t,e){var n=e||{},i=this.validateInputValue(t,{deepCheck:1}),r={value:i.value};(i.unit||i.force)&&(r.unit=i.unit),this.model.set(r,n),n.silent&&this.handleModelChange()},handleChange:function(t){t.stopPropagation(),this.setValue(this.getInputEl().value),this.elementUpdated()},handleUnitChange:function(t){t.stopPropagation();var e=this.getUnitEl().value;this.model.set("unit",e),this.elementUpdated()},elementUpdated:function(){this.model.trigger("el:change")},handleModelChange:function(){var t=this.model;this.getInputEl().value=t.get("value");var e=this.getUnitEl();e&&(e.value=t.get("unit"))},getUnitEl:function(){if(!this.unitEl){var t=this.model,e=t.get("units")||[];if(e.length){var n=[];e.forEach(function(e){var i=e==t.get("unit")?"selected":"";n.push("")});var i=document.createElement("div");i.innerHTML='",this.unitEl=i.firstChild}}return this.unitEl},upArrowClick:function(){var t=this.model,e=t.get("step"),n=t.get("value");n=this.normalizeValue(n+e);var i=this.validateInputValue(n);t.set("value",i.value),this.elementUpdated()},downArrowClick:function(){var t=this.model,e=t.get("step"),n=t.get("value"),i=this.normalizeValue(n-e),r=this.validateInputValue(i);t.set("value",r.value),this.elementUpdated()},downIncrement:function(t){t.preventDefault(),this.moved=0;var e=this.model.get("value");e=this.normalizeValue(e),this.current={y:t.pageY,val:e},(0,r.on)(this.doc,"mousemove",this.moveIncrement),(0,r.on)(this.doc,"mouseup",this.upIncrement)},moveIncrement:function(t){this.moved=1;var e=this.model,n=e.get("step"),i=this.current,r=this.normalizeValue(i.val+(i.y-t.pageY)*n);return this.prValue=this.validateInputValue(r).value,e.set("value",this.prValue,{avoidStore:1}),!1},upIncrement:function(){var t=this.model,e=t.get("step");if((0,r.off)(this.doc,"mouseup",this.upIncrement),(0,r.off)(this.doc,"mousemove",this.moveIncrement),this.prValue&&this.moved){var n=this.prValue-e;t.set("value",n,{avoidStore:1}).set("value",n+e),this.elementUpdated()}},normalizeValue:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.model,i=n.get("step"),r=0;if(isNaN(t))return e;if(t=parseFloat(t),Math.floor(t)!==t){var o=i.toString().split(".")[1];r=o?o.length:0}return r?parseFloat(t.toFixed(r)):t},validateInputValue:function(t,n){var i=0,r=n||{},o=this.model,s=""!==t?t:o.get("defaults"),a=o.get("units")||[],l=o.get("unit")||a.length&&a[0]||"",c=o.get("max"),u=o.get("min");if(r.deepCheck){var h=o.get("fixedValues")||[];if(s){var d=new RegExp("^"+h.join("|"),"g");if(h.length&&d.test(s))s=s.match(d)[0],l="",i=1;else{var f=s+"";s+="",s=parseFloat(s.replace(",",".")),s=isNaN(s)?o.get("defaults"):s;var p=f.replace(s,"");e.indexOf(a,p)>=0&&(l=p)}}}return void 0!==c&&""!==c&&(s=s>c?c:s),void 0!==u&&""!==u&&(s=s1&&void 0!==arguments[1]?arguments[1]:{},r=i.el,o=i.config,a=i.resizer,l=o.keyHeight,c=o.keyWidth,d=o.currentUnit;p("add",0,i),e=n.get("StyleManager").getModelToStyle(h);var f=getComputedStyle(r),g=e.getStyle(),v=g[c]||f[c],m=g[l]||f[l];a.startDim.w=parseFloat(v),a.startDim.h=parseFloat(m),u=0,d&&(o.unitHeight=(0,s.getUnitFromValue)(m),o.unitWidth=(0,s.getUnitFromValue)(v))},onMove:function(){o.trigger("change:canvasOffset")},onEnd:function(t,e){p("remove",0,e),o.trigger("change:canvasOffset"),u=1},updateTarget:function(t,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e){var o=r.store,s=r.selectedHandler,a=r.config,l=a.keyHeight,c=a.keyWidth,u=["tc","bc"].indexOf(s)>=0,h=["cl","cr"].indexOf(s)>=0,d=e.getStyle();u||(d[c]=i.w+a.unitWidth),h||(d[l]=i.h+a.unitHeight),e.setStyle(d,{avoidStore:1});n&&n.trigger("update:component:style:"+l+" update:component:style:"+c),o&&e.trigger("change:style",e,d,{})}}},"object"==(void 0===d?"undefined":r(d))&&(f=i({},f,d)),o.runCommand("resize",{el:t,options:f}))},updateToolbar:function(t){var e=this.config.em,n=t==e?e.get("selectedComponent"):t,i=this.canvas.getToolbarEl(),r=i.style;if(!n)return void(r.opacity=0);var o=n.get("toolbar");this.ppfx;if(e.get("Config").showToolbar&&o&&o.length){if(r.opacity="",r.display="",!this.toolbar){i.innerHTML="",this.toolbar=new l(o);var s=new a({collection:this.toolbar,editor:this.editor});i.appendChild(s.render().el)}this.toolbar.reset(o);var c=n.view;c&&this.updateToolbarPos(c.el)}else r.display="none"},updateToolbarPos:function(t,e){var n=this.canvas.getToolbarEl(),i=n.style,r=i.display;i.display="block";var o=this.canvas.getTargetToElementDim(n,t,{elPos:e,event:"toolbarPosUpdate"}),s=o.left+o.elementWidth-o.targetWidth;i.top=o.top+"px",i.left=s+"px",i.display=r},getCanvasPosition:function(){return this.canvas.getCanvasView().getPosition()},clean:function(){this.selEl&&this.selEl.removeClass(this.hoverClass)},getBadge:function(){return this.canvas.getBadgeEl()},onFrameScroll:function(t){var e=this.cacheEl;if(e){var n=this.getElementPos(e);this.updateBadge(e,n);var i=this.em.get("selectedComponent");i&&this.updateToolbarPos(i.view.el)}},updateAttached:function(t){var e=this.em.getSelected();if(e){var n=e.view;this.updateToolbarPos(n.el),this.showFixedElementOffset(n.el)}},getElementPos:function(t,e){return this.canvas.getCanvasView().getElementPos(t)},hideBadge:function(){this.getBadge().style.display="none"},cleanPrevious:function(t){t&&t.set({status:"",state:""})},getContentWindow:function(){return this.frameEl.contentWindow},run:function(t){this.editor=t&&t.get("Editor"),this.enable(),this.onSelect()},stop:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.em;this.stopSelectComponent(),!n.preserveSelected&&i.setSelected(null),this.clean(),this.hideBadge(),this.hideFixedElementOffset(),this.canvas.getToolbarEl().style.display="none",i.off("component:update",this.updateAttached,this),i.off("change:canvasOffset",this.updateAttached,this),i.off("change:selectedComponent",this.updateToolbar,this)}}},function(t,e,n){"use strict";(function(e,i){var r=n(53),o=e.$;t.exports=i.extend({},r,{init:function(t){i.bindAll(this,"startDraw","draw","endDraw","rollback"),this.config=t||{},this.hType=this.config.newFixedH?"height":"min-height",this.allowDraw=1},enable:function(){for(var t=arguments.length,e=Array(t),n=0;n0;for(o in C)(!C[o]&&n(i.mods,+o)>-1||C[o]&&-1==n(i.mods,+o))&&(a=!1);(0!=i.mods.length||C[16]||C[18]||C[17]||C[91])&&!a||!1===i.method(t,i)&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0))}}function s(t){var e,i=t.keyCode,r=n(M,i);if(r>=0&&M.splice(r,1),93!=i&&224!=i||(i=91),i in C){C[i]=!1;for(e in S)S[e]==i&&(l[e]=!1)}}function a(){for(x in C)C[x]=!1;for(x in S)l[x]=!1}function l(t,e,n){var i,r;i=v(t),void 0===n&&(n=e,e="all");for(var o=0;o1&&(r=m(t),t=[t[t.length-1]]),t=t[0],t=E(t),t in w||(w[t]=[]),w[t].push({shortcut:i[o],scope:e,method:n,key:i[o],mods:r})}function c(t,e){var n,r,o,s,a,l=[];for(n=v(t),s=0;s1&&(l=m(r),t=r[r.length-1]),t=E(t),void 0===e&&(e=p()),!w[t])return;for(o=0;o*\/]/.test(n)?i(null,"select-op"):"."==n&&t.match(/^-?[_a-z][_a-z0-9-]*/i)?i("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(n)?i(null,n):"u"==n&&t.match(/rl(-prefix)?\(/)||"d"==n&&t.match("omain(")||"r"==n&&t.match("egexp(")?(t.backUp(1),e.tokenize=s,i("property","word")):/[\w\\\-]/.test(n)?(t.eatWhile(/[\w\\\-]/),i("property","word")):i(null,null):/[\d.]/.test(t.peek())?(t.eatWhile(/[\w.%]/),i("number","unit")):t.match(/^-[\w\\\-]+/)?(t.eatWhile(/[\w\\\-]/),t.match(/^\s*:/,!1)?i("variable-2","variable-definition"):i("variable-2","variable")):t.match(/^\w+-/)?i("meta","meta"):void 0}function o(t){return function(e,n){for(var r,o=!1;null!=(r=e.next());){if(r==t&&!o){")"==t&&e.backUp(1);break}o=!o&&"\\"==r}return(r==t||!o&&")"!=t)&&(n.tokenize=null),i("string","string")}}function s(t,e){return t.next(),t.match(/\s*[\"\')]/,!1)?e.tokenize=null:e.tokenize=o(")"),i(null,"(")}function a(t,e,n){this.type=t,this.indent=e,this.prev=n}function l(t,e,n,i){return t.context=new a(n,e.indentation()+(!1===i?0:v),t.context),n}function c(t){return t.context.prev&&(t.context=t.context.prev),t.context.type}function u(t,e,n){return L[n.context.type](t,e,n)}function h(t,e,n,i){for(var r=i||1;r>0;r--)n.context=n.context.prev;return u(t,e,n)}function d(t){var e=t.current().toLowerCase();g=M.hasOwnProperty(e)?"atom":E.hasOwnProperty(e)?"keyword":"variable"}var f=n.inline;n.propertyKeywords||(n=t.resolveMode("text/css"));var p,g,v=e.indentUnit,m=n.tokenHooks,y=n.documentTypes||{},b=n.mediaTypes||{},x=n.mediaFeatures||{},w=n.mediaValueKeywords||{},C=n.propertyKeywords||{},k=n.nonStandardPropertyKeywords||{},S=n.fontProperties||{},T=n.counterDescriptors||{},E=n.colorKeywords||{},M=n.valueKeywords||{},P=n.allowNested,A=n.lineComment,O=!0===n.supportsAtComponent,L={};return L.top=function(t,e,n){if("{"==t)return l(n,e,"block");if("}"==t&&n.context.prev)return c(n);if(O&&/@component/.test(t))return l(n,e,"atComponentBlock");if(/^@(-moz-)?document$/.test(t))return l(n,e,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/.test(t))return l(n,e,"atBlock");if(/^@(font-face|counter-style)/.test(t))return n.stateArg=t,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(t))return"keyframes";if(t&&"@"==t.charAt(0))return l(n,e,"at");if("hash"==t)g="builtin";else if("word"==t)g="tag";else{if("variable-definition"==t)return"maybeprop";if("interpolation"==t)return l(n,e,"interpolation");if(":"==t)return"pseudo";if(P&&"("==t)return l(n,e,"parens")}return n.context.type},L.block=function(t,e,n){if("word"==t){var i=e.current().toLowerCase();return C.hasOwnProperty(i)?(g="property","maybeprop"):k.hasOwnProperty(i)?(g="string-2","maybeprop"):P?(g=e.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(g+=" error","maybeprop")}return"meta"==t?"block":P||"hash"!=t&&"qualifier"!=t?L.top(t,e,n):(g="error","block")},L.maybeprop=function(t,e,n){return":"==t?l(n,e,"prop"):u(t,e,n)},L.prop=function(t,e,n){if(";"==t)return c(n);if("{"==t&&P)return l(n,e,"propBlock");if("}"==t||"{"==t)return h(t,e,n);if("("==t)return l(n,e,"parens");if("hash"!=t||/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(e.current())){if("word"==t)d(e);else if("interpolation"==t)return l(n,e,"interpolation")}else g+=" error";return"prop"},L.propBlock=function(t,e,n){return"}"==t?c(n):"word"==t?(g="property","maybeprop"):n.context.type},L.parens=function(t,e,n){return"{"==t||"}"==t?h(t,e,n):")"==t?c(n):"("==t?l(n,e,"parens"):"interpolation"==t?l(n,e,"interpolation"):("word"==t&&d(e),"parens")},L.pseudo=function(t,e,n){return"meta"==t?"pseudo":"word"==t?(g="variable-3",n.context.type):u(t,e,n)},L.documentTypes=function(t,e,n){return"word"==t&&y.hasOwnProperty(e.current())?(g="tag",n.context.type):L.atBlock(t,e,n)},L.atBlock=function(t,e,n){if("("==t)return l(n,e,"atBlock_parens");if("}"==t||";"==t)return h(t,e,n);if("{"==t)return c(n)&&l(n,e,P?"block":"top");if("interpolation"==t)return l(n,e,"interpolation");if("word"==t){var i=e.current().toLowerCase();g="only"==i||"not"==i||"and"==i||"or"==i?"keyword":b.hasOwnProperty(i)?"attribute":x.hasOwnProperty(i)?"property":w.hasOwnProperty(i)?"keyword":C.hasOwnProperty(i)?"property":k.hasOwnProperty(i)?"string-2":M.hasOwnProperty(i)?"atom":E.hasOwnProperty(i)?"keyword":"error"}return n.context.type},L.atComponentBlock=function(t,e,n){return"}"==t?h(t,e,n):"{"==t?c(n)&&l(n,e,P?"block":"top",!1):("word"==t&&(g="error"),n.context.type)},L.atBlock_parens=function(t,e,n){return")"==t?c(n):"{"==t||"}"==t?h(t,e,n,2):L.atBlock(t,e,n)},L.restricted_atBlock_before=function(t,e,n){return"{"==t?l(n,e,"restricted_atBlock"):"word"==t&&"@counter-style"==n.stateArg?(g="variable","restricted_atBlock_before"):u(t,e,n)},L.restricted_atBlock=function(t,e,n){return"}"==t?(n.stateArg=null,c(n)):"word"==t?(g="@font-face"==n.stateArg&&!S.hasOwnProperty(e.current().toLowerCase())||"@counter-style"==n.stateArg&&!T.hasOwnProperty(e.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},L.keyframes=function(t,e,n){return"word"==t?(g="variable","keyframes"):"{"==t?l(n,e,"top"):u(t,e,n)},L.at=function(t,e,n){return";"==t?c(n):"{"==t||"}"==t?h(t,e,n):("word"==t?g="tag":"hash"==t&&(g="builtin"),"at")},L.interpolation=function(t,e,n){return"}"==t?c(n):"{"==t||";"==t?h(t,e,n):("word"==t?g="variable":"variable"!=t&&"("!=t&&")"!=t&&(g="error"),"interpolation")},{startState:function(t){return{tokenize:null,state:f?"block":"top",stateArg:null,context:new a(f?"block":"top",t||0,null)}},token:function(t,e){if(!e.tokenize&&t.eatSpace())return null;var n=(e.tokenize||r)(t,e);return n&&"object"==typeof n&&(p=n[1],n=n[0]),g=n,"comment"!=p&&(e.state=L[e.state](p,t,e)),g},indent:function(t,e){var n=t.context,i=e&&e.charAt(0),r=n.indent;return"prop"!=n.type||"}"!=i&&")"!=i||(n=n.prev),n.prev&&("}"!=i||"block"!=n.type&&"top"!=n.type&&"interpolation"!=n.type&&"restricted_atBlock"!=n.type?(")"!=i||"parens"!=n.type&&"atBlock_parens"!=n.type)&&("{"!=i||"at"!=n.type&&"atBlock"!=n.type)||(r=Math.max(0,n.indent-v)):(n=n.prev,r=n.indent)),r},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * ",lineComment:A,fold:"brace"}});var i=["domain","regexp","url","url-prefix"],r=e(i),o=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],s=e(o),a=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover"],l=e(a),c=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive"],u=e(c),h=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],d=e(h),f=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],p=e(f),g=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],v=e(g),m=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],y=e(m),b=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],x=e(b),w=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],C=e(w),k=i.concat(o).concat(a).concat(c).concat(h).concat(f).concat(b).concat(w);t.registerHelper("hintWords","css",k),t.defineMIME("text/css",{documentTypes:r,mediaTypes:s,mediaFeatures:l,mediaValueKeywords:u,propertyKeywords:d,nonStandardPropertyKeywords:p,fontProperties:v,counterDescriptors:y,colorKeywords:x,valueKeywords:C,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=n,n(t,e))}},name:"css"}),t.defineMIME("text/x-scss",{mediaTypes:s,mediaFeatures:l,mediaValueKeywords:u,propertyKeywords:d,nonStandardPropertyKeywords:p,colorKeywords:x,valueKeywords:C,fontProperties:v,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=n,n(t,e)):["operator","operator"]},":":function(t){return!!t.match(/\s*\{/,!1)&&[null,null]},$:function(t){return t.match(/^[\w-]+/),t.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(t){return!!t.eat("{")&&[null,"interpolation"]}},name:"css",helperType:"scss"}),t.defineMIME("text/x-less",{mediaTypes:s,mediaFeatures:l,mediaValueKeywords:u,propertyKeywords:d,nonStandardPropertyKeywords:p,colorKeywords:x,valueKeywords:C,fontProperties:v,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=n,n(t,e)):["operator","operator"]},"@":function(t){return t.eat("{")?[null,"interpolation"]:!t.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)&&(t.eatWhile(/[\w\\\-]/),t.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"}),t.defineMIME("text/x-gss",{documentTypes:r,mediaTypes:s,mediaFeatures:l,propertyKeywords:d,nonStandardPropertyKeywords:p,fontProperties:v,counterDescriptors:y,colorKeywords:x,valueKeywords:C,supportsAtComponent:!0,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=n,n(t,e))}},name:"css",helperType:"gss"})})},function(t,e,n){"use strict";var i=n(0),r=n(28);t.exports=i.Model.extend({defaults:{id:"",content:"",visible:!0,buttons:[]},initialize:function(t){this.btn=this.get("buttons")||[],this.buttons=new r(this.btn),this.set("buttons",this.buttons)}})},function(t,e,n){"use strict";var i=n(0),r=n(111);t.exports=i.Collection.extend({model:r,deactivateAllExceptOne:function(t,e){this.forEach(function(n,i){n!==t&&(n.set("active",!1),e&&n.get("buttons").length&&n.get("buttons").deactivateAllExceptOne(t,e))})},deactivateAll:function(t){var e=t||"";this.forEach(function(t,n){t.get("context")==e&&(t.set("active",!1),t.get("buttons").length&&t.get("buttons").deactivateAll(e))})},disableAllButtons:function(t){var e=t||"";this.forEach(function(t,n){t.get("context")==e&&(t.set("disable",!0),t.get("buttons").length&&t.get("buttons").disableAllButtons(e))})},disableAllButtonsExceptOne:function(t,e){this.forEach(function(n,i){n!==t&&(n.set("disable",!0),e&&n.get("buttons").length&&n.get("buttons").disableAllButtonsExceptOne(t,e))})}})},function(t,e,n){"use strict";var i=n(0),r=n(30);t.exports=i.View.extend({initialize:function(t){var e=t.config||{};this.config=e,this.pfx=e.stylePrefix||"",this.ppfx=e.pStylePrefix||"",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"))},initResize:function(){var t=this.config.em,e=t?t.get("Editor"):"",n=this.model.get("resizable");if(e&&n){var i,r,o,s=!0===n?[1,1,1,1]:n,a=s.length,l=0;2==a?(i=s[0],o=s[0],r=s[1],l=s[1]):4==a&&(i=s[0],r=s[1],o=s[2],l=s[3]);var c=e.Utils.Resizer.init({tc:i,cr:r,bc:o,cl:l,tl:0,tr:0,bl:0,br:0,appendTo:this.el,prefix:e.getConfig().stylePrefix,posFetcher:function(t){var e=t.getBoundingClientRect();return{left:0,top:0,width:e.width,height:e.height}}});c.blur=function(){},c.focus(this.el)}},render:function(){var t=this.$el,e=this.ppfx;if(t.attr("class",this.className+" "+e+"one-bg"),this.id&&t.attr("id",this.id),this.buttons.length){var n=new r({collection:this.buttons,config:this.config});t.append(n.render().el)}return t.append(this.model.get("content")),this}})},function(t,e,n){"use strict";(function(e){var i=n(0),r=n(113);t.exports=i.View.extend({initialize:function(t){this.opt=t||{},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(t){this.addToCollection(t)},addToCollection:function(t,e){var n=e||null,i=r,o=new i({model:t,config:this.config,parentM:this.parentM}),s=o.render().el;return n?n.appendChild(s):this.$el.append(s),s},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(e){this.addToCollection(e,t)},this),this.$el.append(t),this.$el.attr("class",e.result(this,"className")),this}})}).call(e,n(1))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{},n=e.model,o=void 0===n?{}:n,s=e.view,a=void 0===s?{}:s,l=this.getType(t);if(l)return new l.view(i({model:new l.model(o),config:r},a))},render:function(){return e.render().el}}}},function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0});var n=t.Model,i=t.View;e.default={types:[],initialize:function(t,e){var n=this;this.model=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=void 0,r=void 0,o=void 0;if(t&&t.type){var s=n.getBaseType();o=n.getType(t.type),i=o?o.model:s.model,r=o?o.view:s.view}else{var a=n.recognizeType(t);o=a.type,i=o.model,r=o.view,t=a.attributes}var l=new i(t,e);return l.typeView=r,l};var i=this.init&&this.init.bind(this);i&&i()},recognizeType:function(t){for(var e=this.getTypes(),n=0;n\n \n
\n
\n '},init:function(){var t=this.model;this.pfx;t.set("stackIndex",null),this.events["click [data-add-layer]"]="addLayer",this.listenTo(t,"change:stackIndex",this.indexChanged),this.listenTo(t,"updateValue",this.inputValueChanged),this.delegateEvents()},targetUpdated:function(){if(this.model.get("detached"))this.checkVisibility();else{for(var t=arguments.length,e=Array(t),n=0;n'},inputClass:function(){return this.ppfx+"field"},holderClass:function(){return this.ppfx+"input-holder"},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.ppfx||"";this.opts=t,this.ppfx=e,this.em=t.target||{},this.listenTo(this.model,"change:value",this.handleModelChange)},elementUpdated:function(){this.model.trigger("el:change")},setValue:function(t){var e=this.model,n=t||e.get("defaults"),i=this.getInputEl();i&&(i.value=n)},handleModelChange:function(t,e,n){this.setValue(e,n)},handleChange:function(t){t.stopPropagation(),this.model.set("value",this.getInputEl().value),this.elementUpdated()},getInputEl:function(){if(!this.inputEl){var t=this.model.get("defaults");this.inputEl=n('')}return this.inputEl.get(0)},render:function(){var t=this.$el;return t.addClass(this.inputClass()),t.html(this.template()),t.find("."+this.holderClass()).append(this.getInputEl()),this}})}).call(e,n(0))},function(t,e,n){"use strict";t.exports=n(5).extend({templateInput:function(){var t=(this.pfx,this.ppfx);return'\n
\n
\n '},onRender:function(){var t=this.pfx,e=this.ppfx,n=e+"radio-item-label",i=this.model,r=i.get("property"),o=i.get("list")||i.get("options")||[];if(!this.input&&o&&o.length){var s="";o.forEach(function(i){var o=i.className?i.className+" "+t+"icon "+n:"",a=r+"-"+i.value,l=i.name||i.value,c=i.title?'title="'+i.title+'"':"";s+='\n
\n \n \n
\n "});var a=this.el.querySelector("."+e+"field");a.innerHTML='
'+s+"
",this.input=a.firstChild}},getInputValue:function(){var t=this.getCheckedEl();return t?t.value:""},getCheckedEl:function(){var t=this.getInputEl();return t?t.querySelector("input:checked"):""},setValue:function(t){var e=this.model,n=t||e.get("value")||e.getDefaultValue(),i=this.getInputEl(),r=i?i.querySelector('[value="'+n+'"]'):"";if(r)r.checked=!0;else{var o=this.getCheckedEl();o&&(o.checked=!1)}}})},function(t,e,n){"use strict";(function(e){e.$;t.exports=n(5).extend({templateInput:function(){var t=this.pfx,e=this.ppfx;return'\n
\n \n
\n
\n
\n
\n '},onRender:function(){var t=this.pfx,e=this.model,n=e.get("list")||e.get("options")||[];if(!this.input){var i="";n.forEach(function(t){var e=t.name||t.value,n=t.style?t.style.replace(/"/g,"""):"",r=n?'style="'+n+'"':"",o=t.value.replace(/"/g,""");i+='"});var r=this.el.querySelector("#"+t+"input-holder");r.innerHTML="",this.input=r.firstChild}}})}).call(e,n(0))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{};e=i({},e,{silent:1}),this.inputInst.setValue(t,e)},onRender:function(){if(!this.input){var t=this.ppfx,e=new r({target:this.target,model:this.model,ppfx:t}),n=e.render();this.el.querySelector("."+t+"fields").appendChild(n.el),this.$input=n.inputEl,this.$color=n.colorEl,this.input=this.$input.get(0),this.inputInst=n}}})},function(t,e,n){"use strict";(function(e){var i=Object.assign||function(t){for(var e=1;e\n
\n
\n
\n
\n
\n '},inputClass:function(){var t=this.ppfx;return t+"field "+t+"field-color"},holderClass:function(){return this.ppfx+"input-holder"},setValue:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.model,i=t||n.get("defaults"),r=this.getInputEl(),o=this.getColorEl(),s="none"!=i?i:"";r.value=i,o.get(0).style.backgroundColor=s,e.fromTarget&&(o.spectrum("set",s),this.noneColor="none"==i)},getColorEl:function(){if(!this.colorEl){var t=this,e=this.ppfx,n=this.model,r=o('
'),s=r.get(0).style,a=this.em&&this.em.config?this.em.config.el:"",l=this.em&&this.em.getConfig&&this.em.getConfig("colorPicker")||{},c=function(t){return(1==t.getAlpha()?t.toHexString():t.toRgbString()).replace(/ /g,"")},u=0,h=void 0;this.$el.find("[data-colorp-c]").append(r),r.spectrum(i({containerClassName:e+"one-bg "+e+"two-color",appendTo:a||"body",maxSelectionSize:8,showPalette:!0,showAlpha:!0,chooseText:"Ok",cancelText:"⨯",palette:[]},l,{move:function(t){var e=c(t);s.backgroundColor=e,n.setValueFromInput(e,0)},change:function(e){u=1;var i=c(e);s.backgroundColor=i,n.setValueFromInput(i),t.noneColor=0},show:function(t){u=0,h=c(t)},hide:function(e){!u&&h&&(t.noneColor&&(h=""),s.backgroundColor=h,r.spectrum("set",h),n.setValueFromInput(h,0))}})),this.colorEl=r}return this.colorEl},render:function(){return r.prototype.render.call(this),this.getColorEl(),this}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=n(5),r=e.$;t.exports=i.extend({templateInput:function(){var t=this.pfx;this.ppfx;return'\n
\n
\n
\n \n
\n
\n
\n
\n
\n
⨯
\n
\n
\n '},init:function(){var t=this.em;this.modal=t.get("Modal"),this.am=t.get("AssetManager"),this.events["click #"+this.pfx+"close"]="removeFile",this.events["click #"+this.pfx+"images"]="openAssetManager",this.delegateEvents()},onRender:function(){if(!this.$input){var t=this.model.getDefaultValue();this.$input=r('')}this.$preview||(this.$preview=this.$el.find("#"+this.pfx+"preview-file")),this.$previewBox||(this.$previewBox=this.$el.find("#"+this.pfx+"preview-box")),this.setValue(this.componentValue,0)},setValue:function(t,e){i.prototype.setValue.apply(this,arguments),this.setPreviewView(t&&t!=this.model.getDefaultValue()),this.setPreview(t)},setPreviewView:function(t){var e=this.$previewBox;e&&e[t?"addClass":"removeClass"](this.pfx+"show")},spreadUrl:function(t){this.model.set("value",t),this.setPreviewView(1)},setPreview:function(t){var e=this.$preview;t=t&&t.indexOf("url(")<0?"url("+t+")":t,e&&e.css("background-image",t)},cleanValue:function(){this.setPreviewView(0),this.model.set({value:""},{silent:!0})},removeFile:function(){this.model.set("value",this.model.getDefaultValue());for(var t=arguments.length,e=Array(t),n=0;n\n
\n '},getInfo:function(){var t=this.pfx,e=this.model,n=e.get("name"),i=e.get("width"),r=e.get("height"),o=e.get("unitDim"),s=i&&r?i+"x"+r+o:"";return n=n||e.getFilename(),'\n
'+n+'
\n
'+s+"
\n "},init:function(t){var e=this.pfx;this.className+=" "+e+"asset-image"},onClick:function(){var t=this.config.onClick,e=this.model;this.collection.trigger("deselectAll"),this.$el.addClass(this.pfx+"highlight"),"function"==typeof t?t(e):this.updateTarget(this.collection.target)},onDblClick:function(){var t=this.em,e=this.config.onDblClick,n=this.model;"function"==typeof e?e(n):(this.updateTarget(this.collection.target),t&&t.get("Modal").close());var i=this.collection.onSelect;"function"==typeof i&&i(this.model)},onRemove:function(t){t.stopImmediatePropagation(),this.model.collection.remove(this.model)}})},function(t,e,n){"use strict";(function(e,n){t.exports=e.View.extend({initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=t,this.collection=t.collection;var e=t.config||{};this.config=e,this.pfx=e.stylePrefix||"",this.ppfx=e.pStylePrefix||"",this.em=e.em,this.className=this.pfx+"asset",this.listenTo(this.model,"destroy remove",this.remove),this.model.view=this;var n=this.init&&this.init.bind(this);n&&n(t)},template:function(){var t=this.pfx;return'\n
\n '+this.getPreview()+'\n
\n
\n '+this.getInfo()+'\n
\n
\n ⨯\n
\n '},updateTarget:function(t){t&&t.set&&(t.set("attributes",n.clone(t.get("attributes"))),t.set("src",this.model.get("src")))},getPreview:function(){return""},getInfo:function(){return""},render:function(){var t=this.el;return t.innerHTML=this.template(this,this.model),t.className=this.className,this}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";(function(e,i){var r=n(24),o=function(t){return t&&t.__esModule?t:{default:t}}(r);t.exports=e.View.extend({template:i.template('\n
\n
<%= title %>
\n multiple/>\n
\n
\n '),events:{},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=t;var e=t.config||{};this.config=e,this.pfx=e.stylePrefix||"",this.ppfx=e.pStylePrefix||"",this.target=this.options.globalCollection||{},this.uploadId=this.pfx+"uploadFile",this.disabled=void 0!==e.disableUpload?e.disableUpload:!e.upload&&!e.embedAsBase64,this.events["change #"+this.uploadId]="uploadFile";var n=e.uploadFile;n?this.uploadFile=n.bind(this):e.embedAsBase64&&(this.uploadFile=this.constructor.embedAsBase64),this.delegateEvents()},onUploadStart:function(){var t=this.config.em;t&&t.trigger("asset:upload:start")},onUploadEnd:function(t){var e=this.config.em;e&&e.trigger("asset:upload:end",t)},onUploadError:function(t){var e=this.config.em;console.error(t),this.onUploadEnd(t),e&&e.trigger("asset:upload:error",t)},onUploadResponse:function(t){var e=this.config.em,n=this.config,i=this.target,r="string"==typeof t?JSON.parse(t):t;e&&e.trigger("asset:upload:response",r),n.autoAdd&&i&&i.add(r.data,{at:0}),this.onUploadEnd(t)},uploadFile:function(t){for(var e=this,n=t.dataTransfer?t.dataTransfer.files:t.target.files,i=new FormData,r=this.config,s=r.params,a=0;a'+i.dropzoneContent+""),h(),"draggable"in o&&[o,a].forEach(function(t){t.ondragover=d,t.ondragleave=f,t.ondrop=p})},render:function(){return this.$el.html(this.template({title:this.config.uploadText,uploadId:this.uploadId,disabled:this.disabled,pfx:this.pfx})),this.initDrop(),this.$el.attr("class",this.pfx+"file-uploader"),this}},{embedAsBase64:function(t){var e=this,n=t.dataTransfer?t.dataTransfer.files:t.target.files,i={data:[]};if(!FileReader)return void this.onUploadError(new Error("Unsupported platform, FileReader is not defined"));var r=[],o=/^(.+)\/(.+)$/,s=!0,a=!1,l=void 0;try{for(var c,u=n[Symbol.iterator]();!(s=(c=u.next()).done);s=!0){var h=c.value;!function(t){var e=new Promise(function(e,n){var i=new FileReader;i.addEventListener("load",function(r){var s=void 0,a=t.name,l=o.exec(t.type);if("image"===(s=l?l[1]:t.type)){var c={src:i.result,name:a,type:s,height:0,width:0},u=new Image;u.addEventListener("error",function(t){n(t)}),u.addEventListener("load",function(){c.height=u.height,c.width=u.width,e(c)}),u.src=c.src}else e(s?{src:i.result,name:a,type:s}:i.result)}),i.addEventListener("error",function(t){n(t)}),i.addEventListener("abort",function(t){n("Aborted")}),i.readAsDataURL(t)});r.push(e)}(h)}}catch(t){a=!0,l=t}finally{try{!s&&u.return&&u.return()}finally{if(a)throw l}}Promise.all(r).then(function(t){i.data=t,e.onUploadResponse(i)},function(t){e.onUploadError(t)})}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";(function(e){var i=n(47),r=function(t){return t&&t.__esModule?t:{default:t}}(i),o=n(0),s=n(10);t.exports=o.Model.extend(r.default).extend({defaults:{selectors:{},selectorsAdd:"",style:{},mediaText:"",state:"",stylable:!0,important:0},initialize:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.config=t||{};var n=e.em,i=this.config.selectors||[];if(this.em=n,n){var r=n.get("SelectorManager"),o=[];i.forEach(function(t){o.push(r.add(t))}),i=o}this.set("selectors",new s(i))},selectorsToString:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=[],n=this.get("state"),i=this.get("selectorsAdd"),r=this.get("selectors").getFullString(),o=n?":"+n:"";return r&&e.push(""+r+o),i&&!t.skipAdd&&e.push(i),e.join(", ")},toCSS:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="",n=this.get("mediaText"),i=this.styleToString(t),r=this.selectorsToString();return r&&i&&(e=r+"{"+i+"}"),n&&e&&(e="@media "+n+"{"+e+"}"),e},compare:function(t,n,i,r){var o=r||{},s=n||"",a=i||"",l=o.selectorsAdd||"";t instanceof Array||t.models||(t=[t]);var c=e.map(t.models||t,function(t){return t.get("name")}),u=e.map(this.get("selectors").models,function(t){return t.get("name")});if(c.length!==u.length)return!1;for(var h=0;h0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,r.isString)(e)&&(e=l(e));var s=this.getStyle(),a=i({},e);this.set("style",a,n);var c=(0,o.shallowDiff)(s,a);return(0,r.keys)(c).forEach(function(e){return t.trigger("change:style:"+e)}),a},addStyle:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};"string"==typeof t?t={prop:e}:n=e||{},t=this.extendStyle(t),this.setStyle(t,n)},removeStyle:function(t){var e=this.getStyle();delete e[t],this.setStyle(e)},styleToString:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=[],n=this.getStyle();for(var i in n){var o=t.important,s=(0,r.isArray)(o)?o.indexOf(i)>=0:o,a=n[i]+(s?" !important":"");e.push(i+":"+a+";")}return e.join("")}}},function(t,e,n){"use strict";var i=n(0);t.exports=i.View.extend({itemView:"",itemsView:"",itemType:"type",initialize:function(t,e){this.config=e||{}},addTo:function(t){this.add(t)},add:function(t,e){var n=e||null,i=this.itemView,r=t.get(this.itemType);this.itemsView&&this.itemsView[r]&&(i=this.itemsView[r]);var o=new i({model:t,config:this.config},this.config),s=o.render().el;n?n.appendChild(s):this.$el.append(s)},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.length&&this.collection.each(function(e){this.add(e,t)},this),this.$el.append(t),this}})},function(t,e,n){"use strict";var i=n(1),r=n(0);t.exports=r.Collection.extend({initialize:function(t,e){this.on("add",this.onAdd),this.config=e&&e.config?e.config:null,e&&(e.sm||e.em)&&(this.editor=e.sm||e.em),this.model=function(t,n){var i;!n.sm&&e&&e.sm&&(n.sm=e.sm),!n.em&&e&&e.em&&(n.em=e.em),e&&e.config&&(n.config=e.config),e&&e.componentTypes&&(n.componentTypes=e.componentTypes);for(var r=e.componentTypes,o=0;o1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof t){var n=this.editor.get("Parser").parseHtml(t);t=n.html;var i=this.editor.get("CssComposer");if(n.css&&i){var o=e.avoidUpdateStyle;i.addCollection(n.css,{extend:1,avoidUpdateStyle:o})}}return r.Collection.prototype.add.apply(this,[t,e])},onAdd:function(t,e,n){var r=this.editor,o=t.get("style"),s=r&&r.getConfig("avoidInlineStyle");if(!(0,i.isEmpty)(o)&&!s&&r&&r.get&&r.get("Config").forceClass){var a=this.editor.get("CssComposer"),l=this.editor.get("SelectorManager").add(t.cid);t.set({style:{}}),t.get("classes").add(l);a.add(l).set("style",o)}}})},function(t,e,n){"use strict";(function(e){var i=n(1);t.exports=e.View.extend({initialize:function(t){this.opts=t||{},this.config=t.config||{};var e=this.collection;this.listenTo(e,"add",this.addTo),this.listenTo(e,"reset",this.resetChildren)},addTo:function(t){var e=this.config.em,n=this.collection.indexOf(t);this.addToCollection(t,null,n),e&&!t.opt.temporary&&(e.trigger("add:component",t),e.trigger("component:add",t))},addToCollection:function(t,e,r){this.compView||(this.compView=n(3));for(var o=e||null,s=this.compView,a=this.opts.componentTypes,l=t.get("type"),c=0;c':"")+'\n\n
\n
\n
\n \n '+t.getIcon()+'\n \n
\n
\n
\n
'+(r||"")+'
\n
\n \n
\n
\n '},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.opt=t,this.level=t.level,this.config=t.config,this.em=t.config.em,this.ppfx=this.em.get("Config").stylePrefix,this.sorter=t.sorter||"",this.pfx=this.config.stylePrefix;var e=this.pfx,n=this.ppfx,i=this.model,r=i.get("components");i.set("open",!1),this.listenTo(r,"remove add change reset",this.checkChildren),this.listenTo(i,"destroy remove",this.remove),this.listenTo(i,"change:status",this.updateStatus),this.listenTo(i,"change:open",this.updateOpening),this.listenTo(i,"change:style:display",this.updateVisibility),this.className=e+"item no-select",this.editBtnCls=e+"nav-item-edit",this.inputNameCls=n+"nav-comp-name",this.caretCls=n+"nav-item-caret",this.titleCls=e+"title",this.$el.data("model",i),this.$el.data("collection",r)},getVisibilityEl:function(){return this.eyeEl||(this.eyeEl=this.$el.children("#"+this.pfx+"btn-eye")),this.eyeEl},updateVisibility:function(){var t=this.pfx,e=this.model,n=t+"hide",i="none"==e.getStyle().display,r=i?"addClass":"removeClass";this.$el[r](n),this.getVisibilityEl()[r]("fa-eye-slash")},toggleVisibility:function(t){t&&t.stopPropagation();var e=this.model,n=e.getStyle();"none"==n.display?delete n.display:n.display="none",e.setStyle(n)},handleEdit:function(t){t.stopPropagation();var e=this.getInputName();e.readOnly=!1,e.focus()},handleEditEnd:function(t){t.stopPropagation();var e=this.getInputName();e.readOnly=!0,this.model.set("custom-name",e.value)},getInputName:function(){return this.inputName||(this.inputName=this.el.querySelector("."+this.inputNameCls)),this.inputName},updateOpening:function(){var t=this.opt.opened||{},e=this.model;e.get("open")?(this.$el.addClass("open"),this.getCaret().addClass("fa-chevron-down"),t[e.cid]=e):(this.$el.removeClass("open"),this.getCaret().removeClass("fa-chevron-down"),delete t[e.cid])},toggleOpening:function(t){t.stopPropagation(),this.model.get("components").length&&this.model.set("open",!this.model.get("open"))},handleSelect:function(t){t.stopPropagation(),this.em&&this.em.setSelected(this.model,{fromLayers:1})},startSort:function(t){t.stopPropagation(),0===t.button&&this.sorter&&this.sorter.startSort(t.target)},freeze:function(){this.$el.addClass(this.pfx+"opac50"),this.model.set("open",0)},unfreeze:function(){this.$el.removeClass(this.pfx+"opac50")},updateStatus:function(t){r.prototype.updateStatus.apply(this,arguments)},isVisible:function(){var t=this.model.get("style"),e=t.display;if(!e||"none"!=e)return 1},checkChildren:function(){var t=this.model,e=this.countChildren(t),n=this.pfx,i=n+"no-chld",r=this.$el.children("."+n+"title-c").children("."+n+"title");this.$counter||(this.$counter=this.$el.children("#"+n+"counter")),e?(r.removeClass(i),this.$counter.html(e)):(r.addClass(i),this.$counter.empty(),t.set("open",0))},countChildren:function(t){var e=0;return t.get("components").each(function(t){var n=this.opt.isCountable,i=this.config.hideTextnode;n&&!n(t,i)||e++},this),e},getCaret:function(){if(!this.caret){var t=this.pfx;this.caret=this.$el.children("."+t+"title-c").find("#"+t+"caret")}return this.caret},render:function(){var t=this.model,e=this.pfx,r=this.isVisible(),s=this.$el,a=this.level+1;s.html(this.template(t)),(0,i.isUndefined)(o)&&(o=n(56));var l=new o({collection:t.get("components"),config:this.config,sorter:this.sorter,opened:this.opt.opened,parent:t,level:a}).render().$el;return s.find("."+e+"children").append(l),t.get("draggable")&&this.config.sortable||s.children("#"+e+"move").remove(),!r&&(this.className+=" "+e+"hide"),s.attr("class",this.className),this.updateOpening(),this.updateStatus(),this.updateVisibility(),this}})},function(t,e,n){"use strict";var i=n(0),r=n(55);t.exports=i.View.extend({initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.opt=t;var e=t.config||{};if(this.level=t.level,this.config=e,this.preview=t.preview,this.ppfx=e.pStylePrefix||"",this.pfx=e.stylePrefix||"",this.parent=t.parent,this.listenTo(this.collection,"add",this.addTo),this.listenTo(this.collection,"reset resetNavigator",this.render),this.className=this.pfx+"items",e.sortable&&!this.opt.sorter){var n=this.pfx,i=e.em.get("Utils");this.opt.sorter=new i.Sorter({container:e.sortContainer||this.el,containerSel:"."+n+"items",itemSel:"."+n+"item",ppfx:this.ppfx,ignoreViewChildren:1,avoidSelectOnEnd:1,pfx:n,nested:1})}this.sorter=this.opt.sorter||"",this.$el.data("collection",this.collection),this.parent&&this.$el.data("model",this.parent)},addTo:function(t){var e=this.collection.indexOf(t);this.addToCollection(t,null,e)},addToCollection:function(t,e,n){var i=this.level,o=e||null,s=r;if(this.isCountable(t,this.config.hideTextnode)){var a=new s({level:i,model:t,config:this.config,sorter:this.sorter,isCountable:this.isCountable,opened:this.opt.opened}),l=a.render().el;if(o)o.appendChild(l);else if(void 0!==n){var c="before";this.$el.children().length==n&&(n--,c="after"),n<0?this.$el.append(l):this.$el.children().eq(n)[c](l)}else this.$el.append(l);return l}},isCountable:function(t,e){var n=t.get("type"),i=t.get("tagName");return!(("textnode"==n||"br"==i)&&e||!t.get("layerable"))},render:function(){var t=this,e=document.createDocumentFragment();return this.el.innerHTML="",this.collection.each(function(n){return t.addToCollection(n,e)}),this.el.appendChild(e),this.$el.attr("class",this.className),this}})},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{id:"",label:"",open:!0,attributes:{}}})},function(t,e,n){"use strict";t.exports=n(59)},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}var r=n(9),o=i(r),s=n(1);(0,i(n(60)).default)(),t.exports=function(){var t=n(61),e=n(62),i=n(220),r=new i,a=[];return{$:o.default,editors:a,plugins:r,version:"0.12.58",init:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=n.container;if(!i)throw new Error("'container' is required");(0,s.defaults)(n,t),n.el=i instanceof window.HTMLElement?i:document.querySelector(i);var o=new e(n).init();return n.plugins.forEach(function(t){var e=r.get(t);e?e(o,n.pluginsOpts[t]||{}):console.warn("Plugin "+t+" not found")}),o.getModel().loadOnStart(),n.autorender&&o.render(),a.push(o),o}}}()},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){if(function(){for(var t=void 0,e=window.navigator.userAgent,n=[["edge",/Edge\/([0-9\._]+)/],["ie",/MSIE\s(7\.0)/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/]],i=0;i0&&void 0!==arguments[0]?arguments[0]:{};this.config=e,this.set("Config",e),this.set("modules",[]),e.el&&e.fromElement&&(this.config.components=e.el.innerHTML),o.forEach(function(e){return t.loadModule(e)}),this.on("change:selectedComponent",this.componentSelected,this),this.on("change:changesCount",this.updateChanges,this)},getConfig:function(t){var e=this.config;return(0,r.isUndefined)(t)?e:e[t]},loadOnStart:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=this.get("StorageManager");this.get("toLoad").forEach(function(t){t.onLoad()});var i=function(){t.get("modules").forEach(function(e){return e.postLoad&&e.postLoad(t)}),e&&e()};n&&n.getConfig().autoload?this.load(i):i()},updateChanges:function(){var t=this.get("StorageManager"),e=this.get("changesCount");this.config.noticeOnUnload&&e?window.onbeforeunload=function(t){return 1}:window.onbeforeunload=null,t.isAutosave()&&e>=t.getStepsBeforeSave()&&this.store()},loadModule:function(t){var e=this.config,n=new t,r=n.name.charAt(0).toLowerCase()+n.name.slice(1),o=e[r]||e[n.name]||{};o.pStylePrefix=e.pStylePrefix||"";var s=this.get("StorageManager");if(n.storageKey&&n.store&&n.load&&s){o.stm=s;var a=this.get("storables");a.push(n),this.set("storables",a)}return o.em=this,n.init(i({},o)),!n.private&&this.set(n.name,n),n.onLoad&&this.get("toLoad").push(n),this.get("modules").push(n),this},init:function(t){this.set("Editor",t)},getEditor:function(){return this.get("Editor")},handleUpdates:function(t,e){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i.temporary||(a&&clearInterval(a),a=setTimeout(function(){i.avoidStore||n.set("changesCount",n.get("changesCount")+1,i)},0))},componentSelected:function(t,e,n){this.get("selectedComponent")?(this.trigger("select-comp",[t,e,n]),this.trigger("component:selected",arguments)):this.trigger("deselect-comp")},getSelected:function(){return this.get("selectedComponent")},setSelected:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t;t instanceof window.HTMLElement&&(n=l(t).data("model")),n&&!n.get("selectable")||this.set("selectedComponent",n,e)},setComponents:function(t){return this.get("DomComponents").setComponents(t)},getComponents:function(){var t=this.get("DomComponents"),e=this.get("CodeManager");if(t&&e){var n=t.getComponents();return e.getCode(n,"json")}},setStyle:function(t){for(var e=this.get("CssComposer").getAll(),n=0,i=e.length;n"+i+"<\/script>":""},getCss:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.config,n=e.wrappesIsBody,i=t.avoidProtected,r=this.get("CssComposer"),o=this.get("DomComponents").getComponent();return(i?"":e.protectedCss)+this.get("CodeManager").getCode(o,"css",{cssc:r,wrappesIsBody:n})},getJs:function(){var t=this.get("DomComponents").getWrapper();return this.get("CodeManager").getCode(t,"js").trim()},store:function(t){var e=this,n=this.get("StorageManager"),i={};if(n)return this.get("storables").forEach(function(t){var e=t.store(1);for(var n in e)i[n]=e[n]}),n.store(i,function(){t&&t(),e.set("changesCount",0),e.trigger("storage:store",i)}),i},load:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.getCacheLoad(1,function(n){t.get("storables").forEach(function(t){return t.load(n)}),e&&e(n)})},getCacheLoad:function(t,e){var n=this,i=t?1:0;if(this.cacheLoad&&!i)return this.cacheLoad;var r=this.get("StorageManager"),o=[];if(!r)return{};this.get("storables").forEach(function(t){var e=t.storageKey;e="function"==typeof e?e():e,(e instanceof Array?e:[e]).forEach(function(t){o.push(t)})}),r.load(o,function(t){n.cacheLoad=t,e&&e(t),n.trigger("storage:load",t)})},getDeviceModel:function(){var t=this.get("device");return this.get("DeviceManager").get(t)},runDefault:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.get("Commands").get(this.config.defaultCommand);e&&!this.defaultRunning&&(e.stop(this,this,t),e.run(this,this,t),this.defaultRunning=1)},stopDefault:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.get("Commands").get(this.config.defaultCommand);e&&(e.stop(this,this,t),this.defaultRunning=0)},refreshCanvas:function(){this.set("canvasOffset",this.get("Canvas").getOffset())},clearSelection:function(t){(t||window).getSelection().removeAllRanges()},getCurrentMedia:function(){var t=this.config,e=this.getDeviceModel(),n=t.mediaCondition,i=t.devicePreviewMode,r=e&&e.get("widthMedia");return e&&r&&!i?"("+n+": "+r+")":""},data:function(t,e,n){if(t["_gjs-data"]||(t["_gjs-data"]={}),(0,r.isUndefined)(n))return t["_gjs-data"][e];t["_gjs-data"][e]=n}})},function(t,e,n){"use strict";t.exports=function(){var t=n(66),e=n(67),i=n(68);return{name:"Utils",init:function(){return this},Sorter:t,Resizer:e,Dragger:i}}},function(t,e,n){"use strict";(function(e,i){var r=n(1),o=n(2),s=e.$;t.exports=e.View.extend({initialize:function(t){this.opt=t||{},i.bindAll(this,"startSort","onMove","endMove","rollback","udpateOffset","moveDragHelper");var e=t||{};this.elT=0,this.elL=0,this.borderOffset=e.borderOffset||10;var n=e.container;this.el="string"==typeof n?document.querySelector(n):n,this.$el=s(this.el),this.containerSel=e.containerSel||"div",this.itemSel=e.itemSel||"div",this.draggable=e.draggable||!0,this.nested=e.nested||0,this.pfx=e.pfx||"",this.ppfx=e.ppfx||"",this.freezeClass=e.freezeClass||this.pfx+"freezed",this.onStart=e.onStart||"",this.onEndMove=e.onEndMove||"",this.direction=e.direction||"v",this.onMoveClb=e.onMove||"",this.relative=e.relative||0,this.ignoreViewChildren=e.ignoreViewChildren||0,this.ignoreModels=e.ignoreModels||0,this.plh=e.placer||"",this.wmargin=e.wmargin||0,this.offTop=e.offsetTop||0,this.offLeft=e.offsetLeft||0,this.document=e.document||document,this.$document=s(this.document),this.dropContent=null,this.em=e.em||"",this.dragHelper=null,this.canvasRelative=e.canvasRelative||0,this.selectOnEnd=!e.avoidSelectOnEnd,this.em&&this.em.on&&(this.em.on("change:canvasOffset",this.udpateOffset),this.udpateOffset())},getContainerEl:function(){if(!this.el){var t=this.opt.container;this.el="string"==typeof t?document.querySelector(t):t,this.$el=s(this.el)}return this.el},getDocuments:function(){var t=this.em,e=t&&t.get("Canvas").getBody().ownerDocument,n=[document];return e&&n.push(e),n},udpateOffset:function(){var t=this.em.get("canvasOffset");this.offTop=t.top,this.offLeft=t.left},setDropContent:function(t){this.dropContent=t},toggleSortCursor:function(t){var e=this.em;document.body,this.ppfx||this.pfx,e&&e.get("Canvas").getBody();t?e&&e.get("Canvas").startAutoscroll():e&&e.get("Canvas").stopAutoscroll()},setDragHelper:function(t,e){for(var n=e||"",i=t.cloneNode(1),r=t.getBoundingClientRect(),o=getComputedStyle(t),a="",l=0;ls+c-10||ra+l-10)return 1},getCurrentPos:function(){var t=this.eventMove;return{x:t.pageX||0,y:t.pageY||0}},getDim:function(t){var e,n,i,r;if(this.canvasRelative&&this.em){var o=this.em.get("Canvas").getElementPos(t),s=window.getComputedStyle(t),a=parseFloat(s.marginTop),l=parseFloat(s.marginBottom),c=parseFloat(s.marginRight),u=parseFloat(s.marginLeft);e=o.top-a,n=o.left-u,i=o.height+a+l,r=o.width+u+c}else{var h=this.offset(t);e=this.relative?t.offsetTop:h.top-(this.wmargin?-1:1)*this.elT,n=this.relative?t.offsetLeft:h.left-(this.wmargin?-1:1)*this.elL,i=t.offsetHeight,r=t.offsetWidth}return[e,n,i,r]},getChildrenDim:function(t){var e=[];if(!t)return e;var n=this.getTargetModel(t);n&&n.view&&!this.ignoreViewChildren&&(t=n.view.getChildrenContainer());for(var i=t.children,r=0,o=i.length;rs||s>a+c-r||l+r>o||o>l+u-r)&&(i=1),!!i},findPosition:function(t,e,n){for(var i={index:0,method:"before"},r=0,o=0,s=0,a=0,l=0,c=0,u=0,h=0,d=0,f=t.length;do||a&&c>=a||r&&s0&&void 0!==arguments[0]?arguments[0]:{};return i(this,t),this.setOptions(e),(0,o.bindAll)(this,"handleKeyDown","handleMouseDown","move","stop"),this}return r(t,[{key:"getConfig",value:function(){return this.opts}},{key:"setOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.opts=(0,o.defaults)(t,a),this.setup()}},{key:"setup",value:function(){var t=this.opts,e=t.prefix||"",n=t.appendTo||document.body,i=this.container;for(i||(i=document.createElement("div"),i.className=e+"resizer-c",n.appendChild(i),this.container=i);i.firstChild;)i.removeChild(i.firstChild);var r={};["tl","tc","tr","cl","cr","bl","bc","br"].forEach(function(e){return r[e]=t[e]?l(e,t):""});for(var o in r){var s=r[o];s&&i.appendChild(s)}this.handlers=r,this.mousePosFetcher=t.mousePosFetcher,this.updateTarget=t.updateTarget,this.posFetcher=t.posFetcher,this.onStart=t.onStart,this.onMove=t.onMove,this.onEnd=t.onEnd}},{key:"isHandler",value:function(t){var e=this.handlers;for(var n in e)if(e[n]===t)return!0;return!1}},{key:"getFocusedEl",value:function(){return this.el}},{key:"getDocumentEl",value:function(){return[this.el.ownerDocument,document]}},{key:"getElementPos",value:function(t){var e=this.posFetcher||"";return e?e(t):c(t)}},{key:"focus",value:function(t){if(!t||t!==this.el){this.el=t;var e=this.getElementPos(t),n=this.container,i=n.style;i.left=e.left+"px",i.top=e.top+"px",i.width=e.width+"px",i.height=e.height+"px",n.style.display="block",(0,s.on)(this.getDocumentEl(),"mousedown",this.handleMouseDown)}}},{key:"blur",value:function(){this.container.style.display="none",this.el&&((0,s.off)(this.getDocumentEl(),"mousedown",this.handleMouseDown),this.el=null)}},{key:"start",value:function(t){if(0===t.button){t.preventDefault(),t.stopPropagation();var e=this.el,n=this,i=this.opts||{},r="data-"+i.prefix+"handler",a=this.getElementPos(e);this.handlerAttr=t.target.getAttribute(r),this.clickedHandler=t.target,this.startDim={t:a.top,l:a.left,w:a.width,h:a.height},this.rectDim={t:a.top,l:a.left,w:a.width,h:a.height},this.startPos={x:t.clientX,y:t.clientY};var l=this.getDocumentEl();(0,s.on)(l,"mousemove",this.move),(0,s.on)(l,"keydown",this.handleKeyDown),(0,s.on)(l,"mouseup",this.stop),(0,o.isFunction)(this.onStart)&&this.onStart(t,{docs:l,config:i,el:e,resizer:n}),this.move(t)}}},{key:"move",value:function(t){var e=this.onMove,n=this.mousePosFetcher,i=n?n(t):{x:t.clientX,y:t.clientY};this.currentPos=i,this.delta={x:i.x-this.startPos.x,y:i.y-this.startPos.y},this.keys={shift:t.shiftKey,ctrl:t.ctrlKey,alt:t.altKey},this.rectDim=this.calc(this),this.updateRect(0),e&&e(t),0===t.which&&this.stop(t)}},{key:"stop",value:function(t){var e=this.opts,n=this.getDocumentEl();(0,s.off)(n,"mousemove",this.move),(0,s.off)(n,"keydown",this.handleKeyDown),(0,s.off)(n,"mouseup",this.stop),this.updateRect(1),(0,o.isFunction)(this.onEnd)&&this.onEnd(t,{docs:n,config:e})}},{key:"updateRect",value:function(t){var e=this.el,n=this,i=this.opts,r=this.rectDim,s=this.container.style,a=this.updateTarget,l=this.getSelectedHandler(),c=i.unitHeight,u=i.unitWidth;if((0,o.isFunction)(a))a(e,r,{store:t,selectedHandler:l,resizer:n,config:i});else{var h=e.style;h.width=r.w+u,h.height=r.h+c}var d=this.getElementPos(e);s.left=d.left+"px",s.top=d.top+"px",s.width=d.width+"px",s.height=d.height+"px"}},{key:"getSelectedHandler",value:function(){var t=this.handlers;if(this.selectedHandler)for(var e in t)if(t[e]===this.selectedHandler)return e}},{key:"handleKeyDown",value:function(t){27===t.keyCode&&(this.rectDim=this.startDim,this.stop(t))}},{key:"handleMouseDown",value:function(t){var e=t.target;this.isHandler(e)?(this.selectedHandler=e,this.start(t)):e!==this.el&&(this.selectedHandler="",this.blur())}},{key:"calc",value:function(t){var e=void 0,n=this.opts||{},i=n.step,r=this.startDim,o=n.minDim,a=n.maxDim,l=t.delta.x,c=t.delta.y,u=r.w,h=r.h,d={t:0,l:0,w:u,h:h};if(t){var f=t.handlerAttr;~f.indexOf("r")&&(e=(0,s.normalizeFloat)(u+l*i,i),e=Math.max(o,e),a&&(e=Math.min(a,e)),d.w=e),~f.indexOf("b")&&(e=(0,s.normalizeFloat)(h+c*i,i),e=Math.max(o,e),a&&(e=Math.min(a,e)),d.h=e),~f.indexOf("l")&&(e=(0,s.normalizeFloat)(u-l*i,i),e=Math.max(o,e),a&&(e=Math.min(a,e)),d.w=e),~f.indexOf("t")&&(e=(0,s.normalizeFloat)(h-c*i,i),e=Math.max(o,e),a&&(e=Math.min(a,e)),d.h=e);var p=n.ratioDefault?!t.keys.shift:t.keys.shift;if(f.indexOf("c")<0&&p){var g=r.w/r.h;d.w/d.h>g?d.h=Math.round(d.w/g):d.w=Math.round(d.h*g)}return~f.indexOf("l")&&(d.l=r.w-d.w),~f.indexOf("t")&&(d.t=r.h-d.h),d}}}]),t}();t.exports={init:function(t){return new u(t)}}},function(t,e,n){"use strict";(function(e){var n=e.$,i=function(t,e){var n=e||window,i=t.getBoundingClientRect();return{left:i.left+n.pageXOffset,top:i.top+n.pageYOffset,width:i.width,height:i.height}};t.exports={setKey:function(t,e){},getElementRect:function(t){var e=this.opts.posFetcher||"";return e?e(t,{avoidFrameOffset:1}):i(t)},init:function(t){return this.setOptions(t),this.handleMouseDown=this.handleMouseDown.bind(this),this.drag=this.drag.bind(this),this.move=this.move.bind(this),this.stop=this.stop.bind(this),this.setKey("up, right, down, left",this.handleKey),this},setOptions:function(t){this.opts=t||{}},focus:function(t){if(!t||t!==this.el){this.getDocumentEl(t),this.blur(),this.el=t,this.handlers=this.opts.dragHandlers||[t];var e=this.getElementRect(t);this.elRect=e,this.startTop=e.top,this.startLeft=e.left,this.getDocumentEl().on("mousedown",this.handleMouseDown)}},blur:function(){this.getDocumentEl().off("mousedown",this.handleMouseDown),this.el=null},start:function(t){this.startPos=this.getMousePos(t);var e=this.getDocumentEl();e.on("mousemove",this.drag),e.on("mouseup",this.stop);var n=this.opts.onStart;"function"==typeof n&&n(t,{docs:e,el:this.el,start:this.startPos,elRect:this.elRect}),this.drag(t)},stop:function(t){var e=this.getDocumentEl();e.off("mousemove",this.drag),e.off("mouseup",this.stop),this.lockedAxis=null;var n=this.opts.onEnd;"function"==typeof n&&n(t,{docs:e,delta:this.delta,end:{x:this.startLeft+this.delta.x,y:this.startTop+this.delta.y}})},handleMouseDown:function(t){var e=t.target;this.isHandler(e)&&this.start(t)},isHandler:function(t){var e=this.handlers;for(var n in e)if(e[n]===t)return!0;return!1},handleKey:function(t,e){switch(e.shortcut){case"up":this.move(0,-1);break;case"right":this.move(1,0);break;case"down":this.move(0,1);break;case"left":this.move(-1,0)}},getDocumentEl:function(t){var t=t||this.el;if(!this.$doc){var e=[document];t&&e.push(t.ownerDocument),this.$doc=n(e)}return this.$doc},getMousePos:function(t){var e=this.opts.mousePosFetcher;return e?e(t):{x:t.clientX,y:t.clientY}},drag:function(t){var e=this.lockedAxis,n=this.getMousePos(t),i={x:n.x-this.startPos.x,y:n.y-this.startPos.y};if(t.shiftKey){if(!e){var r=i.x,o=i.y,s=Math.abs(r),a=Math.abs(o);o>=s||o<=-s?e="x":(r>a||r<-a)&&(e="y")}}else e=null;"x"===e&&(i.x=this.startPos.x),"y"===e&&(i.y=this.startPos.y),this.lockedAxis=e,this.delta=i,this.move(i.x,i.y);var l=this.opts.onDrag;"function"==typeof l&&l(t,{delta:i,current:{x:this.startLeft+i.x,y:this.startTop+i.y},lockedAxis:e}),0===t.which&&this.stop(t)},move:function(t,e){this.moveX(t),this.moveY(e)},moveX:function(t){var e=this.el,n=(this.opts,this.startLeft+t),i=this.opts.setX;"function"==typeof i?i(n,{el:e,start:this.startLeft,delta:t}):e.style.left=n+"px"},moveY:function(t){var e=this.el,n=(this.opts,this.startTop+t),i=this.opts.setY;"function"==typeof i?i(n,{el:e,start:this.startTop,delta:t}):e.style.top=n+"px"}}}).call(e,n(0))},function(t,e,n){"use strict";var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=Object.assign||function(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{};return e=r({},a,n),t=e.em,this.em=t,this},onLoad:function(){var t=e.defaults;for(var n in t){var i=t[n];this.add(n,i.keys,i.handler)}},add:function(t,e,r){var a=this.em,l=a.get("Commands"),c=a.getEditor(),u={id:t,keys:e,handler:r};return n[t]&&this.remove(t),n[t]=u,s(e,function(e,n){r=(0,o.isString)(r)?l.get(r):r,"object"==(void 0===r?"undefined":i(r))?r.run(c):r(c);var s=[t,n.shortcut,e];a.trigger.apply(a,["keymap:emit"].concat(s)),a.trigger.apply(a,["keymap:emit:"+t].concat(s))}),a.trigger("keymap:add",u),u},get:function(t){return n[t]},getAll:function(){return n},remove:function(t){var e=this.em,i=this.get(t);if(i)return delete n[t],s.unbind(i.keys),e&&e.trigger("keymap:remove",i),i}}}},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{};n=i({},a,s),t=n.em,this.em=t,e=new o.default({track:!0,register:[]}),e.changeUndoType("change",{condition:!1});var l={on:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!r&&(r=t.previousAttributes()),!n.avoidStore){var i={object:t,before:r,after:t.toJSON()};return r=null,i}},undo:function(t,e,n,i){t.set(e)},redo:function(t,e,n,i){t.set(n)}};return["style","attributes","content","src"].forEach(function(t){return e.addUndoType("change:"+t,l)}),e.on("undo redo",function(){return t.trigger("change:selectedComponent change:canvasOffset")}),["undo","redo"].forEach(function(n){return e.on(n,function(){return t.trigger(n)})}),this},getConfig:function(){return n},add:function(t){return e.register(t),this},remove:function(t){return e.unregister(t),this},removeAll:function(){return e.unregisterAll(),this},start:function(){return e.startTracking(),this},stop:function(){return e.stopTracking(),this},undo:function(){return t.get("Canvas").isInputFocused()||e.undo(1),this},undoAll:function(){return e.undoAll(),this},redo:function(){return t.get("Canvas").isInputFocused()||e.redo(1),this},redoAll:function(){return e.redoAll(),this},hasUndo:function(){return e.isAvailable("undo")},hasRedo:function(){return e.isAvailable("redo")},getStack:function(){return e.stack},clear:function(){return e.clear(),this},getInstance:function(){return e}}}},function(t,e,n){var i,r,o;/*! +/*! grapesjs - 0.13.5 */ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.grapesjs=e():t.grapesjs=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=58)}([function(t,e,n){(function(i){var r,o;!function(s){var a="object"==typeof self&&self.self===self&&self||"object"==typeof i&&i.global===i&&i;r=[n(1),n(9),e],void 0!==(o=function(t,e,n){a.Backbone=s(a,n,t,e)}.apply(e,r))&&(t.exports=o)}(function(t,e,n,i){var r=t.Backbone,o=Array.prototype.slice;e.VERSION="1.3.3",e.$=i,e.noConflict=function(){return t.Backbone=r,this},e.emulateHTTP=!1,e.emulateJSON=!1;var s=function(t,e,i){switch(t){case 1:return function(){return n[e](this[i])};case 2:return function(t){return n[e](this[i],t)};case 3:return function(t,r){return n[e](this[i],l(t,this),r)};case 4:return function(t,r,o){return n[e](this[i],l(t,this),r,o)};default:return function(){var t=o.call(arguments);return t.unshift(this[i]),n[e].apply(n,t)}}},a=function(t,e,i){n.each(e,function(e,r){n[r]&&(t.prototype[r]=s(e,r,i))})},l=function(t,e){return n.isFunction(t)?t:n.isObject(t)&&!e._isModel(t)?c(t):n.isString(t)?function(e){return e.get(t)}:t},c=function(t){var e=n.matches(t);return function(t){return e(t.attributes)}},u=e.Events={},h=/\s+/,d=function(t,e,i,r,o){var s,a=0;if(i&&"object"==typeof i){void 0!==r&&"context"in o&&void 0===o.context&&(o.context=r);for(s=n.keys(i);athis.length&&(r=this.length),r<0&&(r+=this.length+1);var o,s,a=[],l=[],c=[],u=[],h={},d=e.add,f=e.merge,p=e.remove,g=!1,v=this.comparator&&null==r&&!1!==e.sort,m=n.isString(this.comparator)?this.comparator:null;for(s=0;s7),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(_,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var e=this.root.slice(0,-1)||"/";return this.location.replace(e+"#"+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 i=document.body,r=i.insertBefore(this.iframe,i.firstChild).contentWindow;r.document.open(),r.document.close(),r.location.hash="#"+this.fragment}var o=window.addEventListener||function(t,e){return attachEvent("on"+t,e)};if(this._usePushState?o("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?o("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var t=window.removeEventListener||function(t,e){return detachEvent("on"+t,e)};this._usePushState?t("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&t("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),D.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe&&(e=this.getHash(this.iframe.contentWindow)),e===this.fragment)return!1;this.iframe&&this.navigate(e),this.loadUrl()},loadUrl:function(t){return!!this.matchRoot()&&(t=this.fragment=this.getFragment(t),n.some(this.handlers,function(e){if(e.route.test(t))return e.callback(t),!0}))},navigate:function(t,e){if(!D.started)return!1;e&&!0!==e||(e={trigger:!!e}),t=this.getFragment(t||"");var n=this.root;""!==t&&"?"!==t.charAt(0)||(n=n.slice(0,-1)||"/");var i=n+t;if(t=this.decodeFragment(t.replace(F,"")),this.fragment!==t){if(this.fragment=t,this._usePushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,i);else{if(!this._wantsHashChange)return this.location.assign(i);if(this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getHash(this.iframe.contentWindow)){var r=this.iframe.contentWindow;e.replace||(r.document.open(),r.document.close()),this._updateHash(r.location,t,e.replace)}}return e.trigger?this.loadUrl(t):void 0}},_updateHash:function(t,e,n){if(n){var i=t.href.replace(/(javascript:|#).*$/,"");t.replace(i+"#"+e)}else t.hash="#"+e}}),e.history=new D;var z=function(t,e){var i,r=this;return i=t&&n.has(t,"constructor")?t.constructor:function(){return r.apply(this,arguments)},n.extend(i,r,e),i.prototype=n.create(r.prototype,t),i.prototype.constructor=i,i.__super__=r.prototype,i};b.extend=x.extend=P.extend=S.extend=D.extend=z;var $=function(){throw new Error('A "url" property or function must be specified')},R=function(t,e){var n=e.error;e.error=function(i){n&&n.call(e.context,t,i,e),t.trigger("error",t,i,e)}};return e})}).call(e,n(16))},function(t,e,n){var i,r;(function(){function n(t){function e(e,n,i,r,o,s){for(;o>=0&&o0?0:a-1;return arguments.length<3&&(r=n[s?s[l]:l],l+=t),e(n,i,r,s,l,a)}}function o(t){return function(e,n,i){n=S(n,i);for(var r=A(e),o=t>0?0:r-1;o>=0&&o0?s=o>=0?o:Math.max(o+a,s):a=o>=0?Math.min(o+1,a):o+a+1;else if(n&&o&&a)return o=n(i,r),i[o]===r?o:-1;if(r!==r)return o=e(p.call(i,s,a),C.isNaN),o>=0?o+s:-1;for(o=t>0?s:a-1;o>=0&&o=0&&e<=P};C.each=C.forEach=function(t,e,n){e=k(e,n);var i,r;if(O(t))for(i=0,r=t.length;i=0},C.invoke=function(t,e){var n=p.call(arguments,2),i=C.isFunction(e);return C.map(t,function(t){var r=i?e:t[e];return null==r?r:r.apply(t,n)})},C.pluck=function(t,e){return C.map(t,C.property(e))},C.where=function(t,e){return C.filter(t,C.matcher(e))},C.findWhere=function(t,e){return C.find(t,C.matcher(e))},C.max=function(t,e,n){var i,r,o=-1/0,s=-1/0;if(null==e&&null!=t){t=O(t)?t:C.values(t);for(var a=0,l=t.length;ao&&(o=i)}else e=S(e,n),C.each(t,function(t,n,i){((r=e(t,n,i))>s||r===-1/0&&o===-1/0)&&(o=t,s=r)});return o},C.min=function(t,e,n){var i,r,o=1/0,s=1/0;if(null==e&&null!=t){t=O(t)?t:C.values(t);for(var a=0,l=t.length;ai||void 0===n)return 1;if(ne?(s&&(clearTimeout(s),s=null),a=c,o=t.apply(i,r),s||(i=r=null)):s||!1===n.trailing||(s=setTimeout(l,u)),o}},C.debounce=function(t,e,n){var i,r,o,s,a,l=function(){var c=C.now()-s;c=0?i=setTimeout(l,e-c):(i=null,n||(a=t.apply(o,r),i||(o=r=null)))};return function(){o=this,r=arguments,s=C.now();var c=n&&!i;return i||(i=setTimeout(l,e)),c&&(a=t.apply(o,r),o=r=null),a}},C.wrap=function(t,e){return C.partial(e,t)},C.negate=function(t){return function(){return!t.apply(this,arguments)}},C.compose=function(){var t=arguments,e=t.length-1;return function(){for(var n=e,i=t[e].apply(this,arguments);n--;)i=t[n].call(this,i);return i}},C.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},C.before=function(t,e){var n;return function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}},C.once=C.partial(C.before,2);var I=!{toString:null}.propertyIsEnumerable("toString"),_=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];C.keys=function(t){if(!C.isObject(t))return[];if(y)return y(t);var e=[];for(var n in t)C.has(t,n)&&e.push(n);return I&&a(t,e),e},C.allKeys=function(t){if(!C.isObject(t))return[];var e=[];for(var n in t)e.push(n);return I&&a(t,e),e},C.values=function(t){for(var e=C.keys(t),n=e.length,i=Array(n),r=0;r":">",'"':""","'":"'","`":"`"},$=C.invert(z),R=function(t){var e=function(e){return t[e]},n="(?:"+C.keys(t).join("|")+")",i=RegExp(n),r=RegExp(n,"g");return function(t){return t=null==t?"":""+t,i.test(t)?t.replace(r,e):t}};C.escape=R(z),C.unescape=R($),C.result=function(t,e,n){var i=null==t?void 0:t[e];return void 0===i&&(i=n),C.isFunction(i)?i.call(t):i};var V=0;C.uniqueId=function(t){var e=++V+"";return t?t+e:e},C.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,j={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\u2028|\u2029/g,W=function(t){return"\\"+j[t]};C.template=function(t,e,n){!e&&n&&(e=n),e=C.defaults({},e,C.templateSettings);var i=RegExp([(e.escape||H).source,(e.interpolate||H).source,(e.evaluate||H).source].join("|")+"|$","g"),r=0,o="__p+='";t.replace(i,function(e,n,i,s,a){return o+=t.slice(r,a).replace(B,W),r=a+e.length,n?o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":i?o+="'+\n((__t=("+i+"))==null?'':__t)+\n'":s&&(o+="';\n"+s+"\n__p+='"),e}),o+="';\n",e.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var s=new Function(e.variable||"obj","_",o)}catch(t){throw t.source=o,t}var a=function(t){return s.call(this,t,C)};return a.source="function("+(e.variable||"obj")+"){\n"+o+"}",a},C.chain=function(t){var e=C(t);return e._chain=!0,e};var U=function(t,e){return t._chain?C(e).chain():e};C.mixin=function(t){C.each(C.functions(t),function(e){var n=C[e]=t[e];C.prototype[e]=function(){var t=[this._wrapped];return f.apply(t,arguments),U(this,n.apply(C,t))}})},C.mixin(C),C.each(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=u[t];C.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0],U(this,n)}}),C.each(["concat","join","slice"],function(t){var e=u[t];C.prototype[t]=function(){return U(this,e.apply(this._wrapped,arguments))}}),C.prototype.value=function(){return this._wrapped},C.prototype.valueOf=C.prototype.toJSON=C.prototype.value,C.prototype.toString=function(){return""+this._wrapped},i=[],void 0!==(r=function(){return C}.apply(e,i))&&(t.exports=r)}).call(this)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getUnitFromValue=e.normalizeFloat=e.shallowDiff=e.camelCase=e.matches=e.upFirst=e.hasDnd=e.off=e.on=void 0;var i=n(1),r=window.Element.prototype,o=r.matches||r.webkitMatchesSelector||r.mozMatchesSelector||r.msMatchesSelector,s=function(t,e){var n={},r=(0,i.keys)(e);for(var o in t)if(t.hasOwnProperty(o)){var s=t[o],a=e[o];r.indexOf(o)>=0?s!==a&&(n[o]=a):n[o]=null}for(var l in e)e.hasOwnProperty(l)&&(0,i.isUndefined)(t[l])&&(n[l]=e[l]);return n},a=function(t,e,n){e=e.split(/\s+/),t=t instanceof Array?t:[t];for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=0;if(isNaN(t))return n;if(t=parseFloat(t),Math.floor(t)!==t){var r=e.toString().split(".")[1];i=r?r.length:0}return i?parseFloat(t.toFixed(i)):t},f=function(t){return"draggable"in document.createElement("i")&&(t?t.get("Config").nativeDnD:1)};e.on=a,e.off=l,e.hasDnd=f,e.upFirst=u,e.matches=o,e.camelCase=h,e.shallowDiff=s,e.normalizeFloat=d,e.getUnitFromValue=c},function(t,e,n){"use strict";(function(e){var i=n(1),r=n(50);t.exports=e.View.extend({className:function(){return this.getClasses()},tagName:function(){return this.model.get("tagName")},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.model,n=t.config||{};this.opts=t,this.config=n,this.em=n.em||"",this.pfx=n.stylePrefix||"",this.ppfx=n.pStylePrefix||"",this.attr=e.get("attributes"),this.classe=this.attr.class||[];var i=this.$el,r=e.get("classes");this.listenTo(e,"destroy remove",this.remove),this.listenTo(e,"change:style",this.updateStyle),this.listenTo(e,"change:attributes",this.updateAttributes),this.listenTo(e,"change:highlightable",this.updateHighlight),this.listenTo(e,"change:status",this.updateStatus),this.listenTo(e,"change:state",this.updateState),this.listenTo(e,"change:script",this.render),this.listenTo(e,"change",this.handleChange),this.listenTo(r,"add remove change",this.updateClasses),i.data("model",e),i.data("collection",e.get("components")),e.view=this,r.length&&this.importClasses(),this.init()},remove:function(){e.View.prototype.remove.apply(this);var t=this.childrenView;t&&t.stopListening()},init:function(){},handleChange:function(){var t=this.model;t.emitUpdate();for(var e in t.changed)t.emitUpdate(e)},importClasses:function(){var t=this.config.em.get("SelectorManager");t&&this.model.get("classes").each(function(e){t.add(e.get("name"))})},updateState:function(t){var e="hc-state";this.model.get("state")?this.$el.addClass(e):this.$el.removeClass(e)},updateStatus:function(t){var e=this.el,n=this.model.get("status"),i=this.pfx,r=this.ppfx,o=i+"selected",s=o+"-parent",a=r+"freezed",l=e.getAttribute("class")||"",c="";switch(n){case"selected":c=l+" "+o;break;case"selected-parent":c=l+" "+s;break;case"freezed":c=l+" "+a;break;default:this.$el.removeClass(o+" "+s+" "+a)}(c=c.trim())&&e.setAttribute("class",c)},updateHighlight:function(){var t=this.model.get("highlightable");this.setAttribute("data-highlightable",t?1:"")},updateStyle:function(){var t=this.em,e=this.model;t&&t.get("avoidInlineStyle")?(this.el.id=e.getId(),e.setStyle(e.getStyle())):this.setAttribute("style",e.styleToString())},updateClasses:function(){var t=this.model.get("classes").pluck("name").join(" ");this.setAttribute("class",t),this.updateStatus()},setAttribute:function(t,e){var n=this.$el;e?n.attr(t,e):n.removeAttr(t)},getClasses:function(){var t=this.model.get("attributes"),e=t.class||[];return e=(0,i.isArray)(e)?e:[e],e.length?e.join(" "):null},updateAttributes:function(){var t=this.model,e={},n=t.get("attributes"),i=t.get("src");for(var r in n)e[r]=n[r];i&&(e.src=i),this.$el.attr(e),this.updateHighlight(),this.updateStyle()},updateContent:function(){this.getChildrenContainer().innerHTML=this.model.get("content")},prevDef:function(t){t.preventDefault()},updateScript:function(){if(this.model.get("script")){var t=this.em;if(t){t.get("Canvas").getCanvasView().updateScript(this)}}},getChildrenContainer:function(){var t=this.el;return"function"==typeof this.getChildrenSelector?t=this.el.querySelector(this.getChildrenSelector()):this.getTemplate,t},renderChildren:function(){var t=this.getChildrenContainer(),e=new r({collection:this.model.get("components"),config:this.config,componentTypes:this.opts.componentTypes});e.render(t),this.childrenView=e;for(var n=Array.prototype.slice.call(e.el.childNodes),i=0,o=n.length;i0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.sm||n.em||"",s=this.parent(),a=s&&s.attributes;if(a&&a.propagate){var l={},c=a.propagate;c.forEach(function(t){return l[t]=s.get(t)}),l.propagate=c,l=i({},l,e),this.set(l)}var u=this.get("propagate");u&&this.set("propagate",(0,r.isArray)(u)?u:[u]),n&&n.config&&n.config.voidElements.indexOf(this.get("tagName"))>=0&&this.set("void",!0),n.em=o,this.opt=n,this.sm=o,this.em=o,this.config=n.config||{},this.ccid=v.createId(this),this.set("attributes",this.get("attributes")||{}),this.on("destroy",this.handleRemove),this.listenTo(this,"change:script",this.scriptUpdated),this.listenTo(this,"change:traits",this.traitsUpdated),this.listenTo(this,"change:tagName",this.tagUpdated),this.listenTo(this,"change:attributes",this.attrUpdated),this.initClasses(),this.loadTraits(),this.initComponents(),this.initToolbar(),this.set("status",""),this.listenTo(this.get("classes"),"add remove change",function(){return t.emitUpdate("classes")}),this.init()},handleRemove:function(t){var e=this.em;e&&e.trigger("component:remove",t)},is:function(t){return!(this.get("type")!=t)},find:function(t){var e=[];return this.view.$el.find(t).each(function(t,n,i){var r=i.eq(n),o=r.data("model");o&&e.push(o)}),e},tagUpdated:function(){var t=this.collection,e=t.indexOf(this);t.remove(this),t.add(this,{at:e})},attrUpdated:function(){var t=this,e=i({},this.previous("attributes")),n=i({},this.get("attributes")),s=(0,o.shallowDiff)(e,n);(0,r.keys)(s).forEach(function(e){return t.trigger("change:attributes:"+e)})},setAttributes:function(t){t=i({},t);var e=t.class;e&&this.setClass(e),delete t.class;var n=t.style;n&&this.setStyle(n),delete t.style,this.set("attributes",t)},getStyle:function(){var t=this.em;if(t&&t.getConfig("avoidInlineStyle")){var e=this.get("state"),n=t.get("CssComposer"),i=n.getIdRule(this.getId(),{state:e});if(this.rule=i,i)return i.getStyle()}return a.default.getStyle.call(this)},setStyle:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=this.em;if(s&&s.getConfig("avoidInlineStyle")){e=(0,r.isString)(e)?this.parseStyle(e):e;var l=this.get("state"),c=s.get("CssComposer"),u=this.getStyle();this.rule=c.setIdRule(this.getId(),e,i({},n,{state:l}));var h=(0,o.shallowDiff)(u,e);(0,r.keys)(h).forEach(function(e){return t.trigger("change:style:"+e)})}else e=a.default.setStyle.apply(this,arguments);return e},getAttributes:function(){var t=[],e=i({},this.get("attributes"));return this.get("classes").each(function(e){return t.push(e.get("name"))}),t.length&&(e.class=t.join(" ")),(0,r.isEmpty)(this.getStyle())||(0,r.has)(e,"id")||(e.id=this.getId()),e},addClass:function(t){var e=this.em.get("SelectorManager").addClass(t);return this.get("classes").add(e)},setClass:function(t){return this.get("classes").reset(),this.addClass(t)},removeClass:function(t){var e=[];t=(0,r.isArray)(t)?t:[t];var n=this.get("classes"),i=u.TYPE_CLASS;return t.forEach(function(t){t.split(" ").forEach(function(t){var r=n.where({name:t,type:i})[0];r&&e.push(n.remove(r))})}),e},initClasses:function(){var t=this.normalizeClasses(this.get("classes")||[]);return this.set("classes",new h(t)),this},initComponents:function(){var t=new c(null,this.opt);return t.parent=this,!this.opt.avoidChildren&&t.reset(this.get("components")),this.set("components",t),this},init:function(){},append:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.components().add(t,e);return(0,r.isArray)(n)?n:[n]},components:function(t){var e=this.get("components");if((0,r.isUndefined)(t))return e;e.reset(),t&&this.append(t)},parent:function(){var t=this.collection;return t&&t.parent},scriptUpdated:function(){this.set("scriptUpdated",1)},traitsUpdated:function(){var t=0,e=i({},this.get("attributes")),n=this.get("traits");if(!(n instanceof d))return void this.loadTraits();n.each(function(n){if(t=1,!n.get("changeProp")){var i=n.getInitValue();i&&(e[n.get("name")]=i)}}),t&&this.set("attributes",e)},initToolbar:function(){var t=this;if(!t.get("toolbar")){var e=[];t.collection&&e.push({attributes:{class:"fa fa-arrow-up"},command:"select-parent"}),t.get("draggable")&&e.push({attributes:{class:"fa fa-arrows",draggable:!0},command:"tlb-move"}),t.get("copyable")&&e.push({attributes:{class:"fa fa-clone"},command:"tlb-clone"}),t.get("removable")&&e.push({attributes:{class:"fa fa-trash-o"},command:"tlb-delete"}),t.set("toolbar",e)}},loadTraits:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new d([],this.opt);return n.setTarget(this),t=t||this.get("traits"),t.length&&n.add(t),this.set("traits",n,e),this},normalizeClasses:function(t){var e=[];if(this.sm.get){var n=this.sm.get("SelectorManager");if(n)return t.forEach(function(t){var i="";i="string"==typeof t?t:t.name;var r=n.add(i);e.push(r)}),e}},clone:function(t){var e=this.em,n=this.getStyle(),o=i({},this.attributes);return o.attributes=i({},o.attributes),delete o.attributes.id,o.components=[],o.classes=[],o.traits=[],this.get("components").each(function(t,e){o.components[e]=t.clone(1)}),this.get("traits").each(function(t,e){o.traits[e]=t.clone()}),this.get("classes").each(function(t,e){o.classes[e]=t.get("name")}),o.status="",o.view="",t&&(this.opt.collection=null),e&&e.getConfig("avoidInlineStyle")&&!(0,r.isEmpty)(n)&&(o.style=n),new this.constructor(o,this.opt)},getName:function(){var t=this.get("name")||this.get("custom-name"),e=this.get("tagName");e="div"==e?"box":e;var n=this.get("type")||e;return n=n.charAt(0).toUpperCase()+n.slice(1),t||n},getIcon:function(){var t=this.get("icon");return t?t+" ":""},toHTML:function(t){var e=this,n=[],i=e.get("tagName"),o=e.get("void"),s=this.getAttrToHTML();for(var a in s){var l=s[a];(0,r.isUndefined)(l)||n.push(a+'="'+l+'"')}var c=n.length?" "+n.join(" "):"",u="<"+i+c+(o?"/":"")+">"+e.get("content");return e.get("components").each(function(t){return u+=t.toHTML()}),!o&&(u+=""),u},getAttrToHTML:function(){var t=this.getAttributes();return delete t.style,t},toJSON:function(){for(var t=arguments.length,e=Array(t),n=0;n\n '+this.templateLabel(t)+'\n \n
\n '+this.templateInput(t)+"\n
\n "},templateLabel:function(t){var e=this.pfx;return'\n \n '+t.get("name")+'\n \n ⨯\n '},templateInput:function(t){return'\n
\n \n
\n '},events:function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}({change:"inputValueChanged"},"click [data-clear-style]","clear"),initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,i.bindAll)(this,"targetUpdated"),this.config=t.config||{};var e=this.config.em;this.em=e,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.target=t.target||{},this.propTarget=t.propTarget||{},this.onChange=t.onChange,this.onInputRender=t.onInputRender||{},this.customValue=t.customValue||{};var n=this.model;this.property=n.get("property"),this.input=null;var r=this.pfx;this.inputHolderId="#"+r+"input-holder",this.sector=n.collection&&n.collection.sector,n.view=this,n.get("value")||n.set("value",n.getDefaultValue()),e&&e.on("update:component:style:"+this.property,this.targetUpdated),this.listenTo(this.propTarget,"update",this.targetUpdated),this.listenTo(n,"destroy remove",this.remove),this.listenTo(n,"change:value",this.modelValueChanged),this.listenTo(n,"targetUpdated",this.targetUpdated),this.listenTo(n,"change:visible",this.updateVisibility),this.listenTo(n,"change:status",this.updateStatus);var o=this.init&&this.init.bind(this);o&&o()},updateStatus:function(){var t=this.model.get("status"),e=this.pfx,n=this.ppfx,i=this.config,r=n+"four-color",o=n+"color-warn",s=this.$el.children("."+e+"label"),a=this.getClearEl().style;switch(s.removeClass(r+" "+o),a.display="none",t){case"updated":s.addClass(r),i.clearProperties&&(a.display="inline");break;case"computed":s.addClass(o)}},clear:function(){this.getTargetModel().removeStyle(this.model.get("property")),this.targetUpdated()},getClearEl:function(){return this.el.querySelector("[data-clear-style]")},getTarget:function(){return this.getTargetModel()},getTargetModel:function(){return this.propTarget&&this.propTarget.model},getHelperModel:function(){return this.propTarget&&this.propTarget.helper},inputValueChanged:function(t){t&&t.stopPropagation(),this.model.setValue(this.getInputValue(),1,{fromInput:1}),this.elementUpdated()},elementUpdated:function(){this.setStatus("updated")},setStatus:function(t){this.model.set("status",t);var e=this.model.parent;e&&e.set("status",t)},targetUpdated:function(){if(this.checkVisibility()){var t=this.config,e=t.em,n=this.model,i="",r="",o=this.getTargetValue({ignoreDefault:1}),s=n.getDefaultValue(),a=this.getComputedValue();o?(i=o,t.highlightChanged&&(r="updated")):a&&t.showComputed&&a!=s?(i=a,t.highlightComputed&&(r="computed")):(i=s,r=""),n.setValue(i,0,{fromTarget:1}),this.setStatus(r),e&&(e.trigger("styleManager:change",this),e.trigger("styleManager:change:"+n.get("property"),this))}},checkVisibility:function(){var t=1;return this.config.hideNotStylable&&(this.isTargetStylable()&&this.isComponentStylable()?this.show():(this.hide(),t=0),this.sector&&this.sector.trigger("updateVisibility")),t},getTargetValue:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.model,i=this.getTargetModel(),r=this.customValue;if(!i)return t;if(t=i.getStyle()[n.get("property")],t||e.ignoreDefault||(t=n.getDefaultValue()),"function"==typeof r&&!e.ignoreCustomValue){var o=n.collection.indexOf(n),s=r(this,o);s&&(t=s)}return t},getComputedValue:function(){var t=this.propTarget,e=t.computed||{},n=t.computedDefault||{},i=this.config.avoidComputed||[],o=this.model.get("property"),s=i.indexOf(o)<0,a=e[o],l=n[(0,r.camelCase)(o)];return e&&s&&l!==a&&a},getInputValue:function(){var t=this.getInputEl();return t?t.value:""},modelValueChanged:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.config.em,r=this.model,o=r.getFullValue(),s=this.getTarget(),a=this.onChange;n.fromInput||this.setValue(o),s&&this.isTargetStylable()&&this.isComponentStylable()&&(n.fromTarget||(a&&!n.fromParent?a(s,this,n):this.updateTargetStyle(o,null,n)),i&&(i.trigger("component:update",s),i.trigger("component:styleUpdate",s),i.trigger("component:styleUpdate:"+r.get("property"),s)))},updateTargetStyle:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=e||this.model.get("property"),r=this.getTarget(),o=r.getStyle();t?o[i]=t:delete o[i],r.setStyle(o,n);var s=this.getHelperModel();s&&s.setStyle(o,n)},isTargetStylable:function(t){this.model.get("id");var e=t||this.getTarget(),n=this.model,r=n.get("property"),o=n.get("toRequire"),s=e.get("unstylable"),a=e.get("stylable-require"),l=e.get("stylable");return(0,i.isArray)(l)&&(l=l.indexOf(r)>=0),(0,i.isArray)(s)&&(l=s.indexOf(r)<0),o&&(l=a&&a.indexOf(r)>=0||!t),l},isComponentStylable:function(){var t=this.em,e=t&&t.get("selectedComponent");return!e||this.isTargetStylable(e)},setRawValue:function(t){this.setValue(this.model.parseValue(t))},setValue:function(t){var e=this.model,n=t||e.getDefaultValue(),i=this.getInputEl();i&&(i.value=n)},getInputEl:function(){return this.input||(this.input=this.el.querySelector("input")),this.input},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)},cleanValue:function(){this.setValue("")},render:function(){var t=this.pfx,e=this.model,n=this.el;n.innerHTML=this.template(e),n.className=t+"property "+t+e.get("type"),this.updateStatus();var i=this.onRender&&this.onRender.bind(this);i&&i(),this.setValue(e.get("value"),{targetUpdate:1})}})}).call(e,n(0))},function(t,e,n){!function(e,n){t.exports=n()}(0,function(){"use strict";function t(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}function e(t){for(var e=t.childNodes.length;e>0;--e)t.removeChild(t.firstChild);return t}function n(t,n){return e(t).appendChild(n)}function i(t,e,n,i){var r=document.createElement(t);if(n&&(r.className=n),i&&(r.style.cssText=i),"string"==typeof e)r.appendChild(document.createTextNode(e));else if(e)for(var o=0;o=e)return s+(e-o);s+=a-o,s+=n-s%n,o=a+1}}function d(t,e){for(var n=0;n=e)return i+Math.min(s,e-r);if(r+=o-i,r+=n-r%n,i=o+1,r>=e)return i}}function p(t){for(;qs.length<=t;)qs.push(g(qs)+" ");return qs[t]}function g(t){return t[t.length-1]}function v(t,e){for(var n=[],i=0;i"€"&&(t.toUpperCase()!=t.toLowerCase()||Ks.test(t))}function w(t,e){return e?!!(e.source.indexOf("\\w")>-1&&x(t))||e.test(t):x(t)}function C(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e])return!1;return!0}function k(t){return t.charCodeAt(0)>=768&&Gs.test(t)}function S(t,e,n){for(;(n<0?e>0:en?-1:1;;){if(e==n)return e;var r=(e+n)/2,o=i<0?Math.ceil(r):Math.floor(r);if(o==e)return t(o)?e:n;t(o)?n=o:e=o+i}}function E(t,e,n){var o=this;this.input=n,o.scrollbarFiller=i("div",null,"CodeMirror-scrollbar-filler"),o.scrollbarFiller.setAttribute("cm-not-content","true"),o.gutterFiller=i("div",null,"CodeMirror-gutter-filler"),o.gutterFiller.setAttribute("cm-not-content","true"),o.lineDiv=r("div",null,"CodeMirror-code"),o.selectionDiv=i("div",null,null,"position: relative; z-index: 1"),o.cursorDiv=i("div",null,"CodeMirror-cursors"),o.measure=i("div",null,"CodeMirror-measure"),o.lineMeasure=i("div",null,"CodeMirror-measure"),o.lineSpace=r("div",[o.measure,o.lineMeasure,o.selectionDiv,o.cursorDiv,o.lineDiv],null,"position: relative; outline: none");var s=r("div",[o.lineSpace],"CodeMirror-lines");o.mover=i("div",[s],null,"position: relative"),o.sizer=i("div",[o.mover],"CodeMirror-sizer"),o.sizerWidth=null,o.heightForcer=i("div",null,null,"position: absolute; height: "+Hs+"px; width: 1px;"),o.gutters=i("div",null,"CodeMirror-gutters"),o.lineGutter=null,o.scroller=i("div",[o.sizer,o.heightForcer,o.gutters],"CodeMirror-scroll"),o.scroller.setAttribute("tabIndex","-1"),o.wrapper=i("div",[o.scrollbarFiller,o.gutterFiller,o.scroller],"CodeMirror"),ms&&ys<8&&(o.gutters.style.zIndex=-1,o.scroller.style.paddingRight=0),bs||fs&&Ps||(o.scroller.draggable=!0),t&&(t.appendChild?t.appendChild(o.wrapper):t(o.wrapper)),o.viewFrom=o.viewTo=e.first,o.reportedViewFrom=o.reportedViewTo=e.first,o.view=[],o.renderedView=null,o.externalMeasured=null,o.viewOffset=0,o.lastWrapHeight=o.lastWrapWidth=0,o.updateLineNumbers=null,o.nativeBarWidth=o.barHeight=o.barWidth=0,o.scrollbarsClipped=!1,o.lineNumWidth=o.lineNumInnerWidth=o.lineNumChars=null,o.alignWidgets=!1,o.cachedCharWidth=o.cachedTextHeight=o.cachedPaddingH=null,o.maxLine=null,o.maxLineLength=0,o.maxLineChanged=!1,o.wheelDX=o.wheelDY=o.wheelStartX=o.wheelStartY=null,o.shift=!1,o.selForContextMenu=null,o.activeTouch=null,n.init(o)}function M(t,e){if((e-=t.first)<0||e>=t.size)throw new Error("There is no line "+(e+t.first)+" in the document.");for(var n=t;!n.lines;)for(var i=0;;++i){var r=n.children[i],o=r.chunkSize();if(e=t.first&&en?_(n,M(t,n).text.length):B(e,M(t,e.line).text.length)}function B(t,e){var n=t.ch;return null==n||n>e?_(t.line,e):n<0?_(t.line,0):t}function W(t,e){for(var n=[],i=0;i=e:o.to>e);(i||(i=[])).push(new K(s,o.from,l?null:o.to))}}return i}function Z(t,e,n){var i;if(t)for(var r=0;r=e:o.to>e);if(a||o.from==e&&"bookmark"==s.type&&(!n||o.marker.insertLeft)){var l=null==o.from||(s.inclusiveLeft?o.from<=e:o.from0&&a)for(var w=0;w0)){var u=[l,1],h=F(c.from,a.from),f=F(c.to,a.to);(h<0||!s.inclusiveLeft&&!h)&&u.push({from:c.from,to:a.from}),(f>0||!s.inclusiveRight&&!f)&&u.push({from:a.to,to:c.to}),r.splice.apply(r,u),l+=u.length-3}}return r}function nt(t){var e=t.markedSpans;if(e){for(var n=0;n=0&&h<=0||u<=0&&h>=0)&&(u<=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?F(c.to,n)>=0:F(c.to,n)>0)||u>=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?F(c.from,i)<=0:F(c.from,i)<0)))return!0}}}function ht(t){for(var e;e=lt(t);)t=e.find(-1,!0).line;return t}function dt(t){for(var e;e=ct(t);)t=e.find(1,!0).line;return t}function ft(t){for(var e,n;e=ct(t);)t=e.find(1,!0).line,(n||(n=[])).push(t);return n}function pt(t,e){var n=M(t,e),i=ht(n);return n==i?e:L(i)}function gt(t,e){if(e>t.lastLine())return e;var n,i=M(t,e);if(!vt(t,i))return e;for(;n=ct(i);)i=n.find(1,!0).line;return L(i)+1}function vt(t,e){var n=Xs&&e.markedSpans;if(n)for(var i=void 0,r=0;re.maxLineLength&&(e.maxLineLength=n,e.maxLine=t)})}function wt(t,e,n,i){if(!t)return i(e,n,"ltr",0);for(var r=!1,o=0;oe||e==n&&s.to==e)&&(i(Math.max(s.from,e),Math.min(s.to,n),1==s.level?"rtl":"ltr",o),r=!0)}r||i(e,n,"ltr")}function Ct(t,e,n){var i;Js=null;for(var r=0;re)return r;o.to==e&&(o.from!=o.to&&"before"==n?i=r:Js=r),o.from==e&&(o.from!=o.to&&"before"!=n?i=r:Js=r)}return null!=i?i:Js}function kt(t,e){var n=t.order;return null==n&&(n=t.order=Zs(t.text,e)),n}function St(t,e){return t._handlers&&t._handlers[e]||Qs}function Tt(t,e,n){if(t.removeEventListener)t.removeEventListener(e,n,!1);else if(t.detachEvent)t.detachEvent("on"+e,n);else{var i=t._handlers,r=i&&i[e];if(r){var o=d(r,n);o>-1&&(i[e]=r.slice(0,o).concat(r.slice(o+1)))}}}function Et(t,e){var n=St(t,e);if(n.length)for(var i=Array.prototype.slice.call(arguments,2),r=0;r0}function Ot(t){t.prototype.on=function(t,e){ta(this,t,e)},t.prototype.off=function(t,e){Tt(this,t,e)}}function Lt(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function Nt(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}function Dt(t){return null!=t.defaultPrevented?t.defaultPrevented:0==t.returnValue}function It(t){Lt(t),Nt(t)}function _t(t){return t.target||t.srcElement}function Ft(t){var e=t.which;return null==e&&(1&t.button?e=1:2&t.button?e=3:4&t.button&&(e=2)),As&&t.ctrlKey&&1==e&&(e=3),e}function zt(t){if(null==Rs){var e=i("span","​");n(t,i("span",[e,document.createTextNode("x")])),0!=t.firstChild.offsetHeight&&(Rs=e.offsetWidth<=1&&e.offsetHeight>2&&!(ms&&ys<8))}var r=Rs?i("span","​"):i("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function $t(t){if(null!=Vs)return Vs;var i=n(t,document.createTextNode("AخA")),r=Ds(i,0,1).getBoundingClientRect(),o=Ds(i,1,2).getBoundingClientRect();return e(t),!(!r||r.left==r.right)&&(Vs=o.right-r.right<3)}function Rt(t){if(null!=oa)return oa;var e=n(t,i("span","x")),r=e.getBoundingClientRect(),o=Ds(e,0,1).getBoundingClientRect();return oa=Math.abs(r.left-o.left)>1}function Vt(t,e){arguments.length>2&&(e.dependencies=Array.prototype.slice.call(arguments,2)),sa[t]=e}function Ht(t,e){aa[t]=e}function jt(t){if("string"==typeof t&&aa.hasOwnProperty(t))t=aa[t];else if(t&&"string"==typeof t.name&&aa.hasOwnProperty(t.name)){var e=aa[t.name];"string"==typeof e&&(e={name:e}),t=b(e,t),t.name=e.name}else{if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return jt("application/xml");if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+json$/.test(t))return jt("application/json")}return"string"==typeof t?{name:t}:t||{name:"null"}}function Bt(t,e){e=jt(e);var n=sa[e.name];if(!n)return Bt(t,"text/plain");var i=n(t,e);if(la.hasOwnProperty(e.name)){var r=la[e.name];for(var o in r)r.hasOwnProperty(o)&&(i.hasOwnProperty(o)&&(i["_"+o]=i[o]),i[o]=r[o])}if(i.name=e.name,e.helperType&&(i.helperType=e.helperType),e.modeProps)for(var s in e.modeProps)i[s]=e.modeProps[s];return i}function Wt(t,e){u(e,la.hasOwnProperty(t)?la[t]:la[t]={})}function Ut(t,e){if(!0===e)return e;if(t.copyState)return t.copyState(e);var n={};for(var i in e){var r=e[i];r instanceof Array&&(r=r.concat([])),n[i]=r}return n}function qt(t,e){for(var n;t.innerMode&&(n=t.innerMode(e))&&n.mode!=t;)e=n.state,t=n.mode;return n||{mode:t,state:e}}function Kt(t,e,n){return!t.startState||t.startState(e,n)}function Gt(t,e,n,i){var r=[t.state.modeGen],o={};ne(t,e.text,t.doc.mode,n,function(t,e){return r.push(t,e)},o,i);for(var s=n.state,a=0;at&&r.splice(l,1,t,r[l+1],i),l+=2,c=Math.min(t,i)}if(e)if(a.opaque)r.splice(n,l-n,t,"overlay "+e),l=n+2;else for(;nt.options.maxHighlightLength&&Ut(t.doc.mode,i.state),o=Gt(t,e,i);r&&(i.state=r),e.stateAfter=i.save(!r),e.styles=o.styles,o.classes?e.styleClasses=o.classes:e.styleClasses&&(e.styleClasses=null),n===t.doc.highlightFrontier&&(t.doc.modeFrontier=Math.max(t.doc.modeFrontier,++t.doc.highlightFrontier))}return e.styles}function Xt(t,e,n){var i=t.doc,r=t.display;if(!i.mode.startState)return new ha(i,!0,e);var o=ie(t,e,n),s=o>i.first&&M(i,o-1).stateAfter,a=s?ha.fromSaved(i,s,o):new ha(i,Kt(i.mode),o);return i.iter(o,e,function(n){Jt(t,n.text,a);var i=a.line;n.stateAfter=i==e-1||i%5==0||i>=r.viewFrom&&ie.start)return o}throw new Error("Mode "+t.name+" failed to advance stream.")}function te(t,e,n,i){var r,o=t.doc,s=o.mode;e=j(o,e);var a,l=M(o,e.line),c=Xt(t,e.line,n),u=new ca(l.text,t.options.tabSize,c);for(i&&(a=[]);(i||u.post.options.maxHighlightLength?(a=!1,s&&Jt(t,e,i,h.pos),h.pos=e.length,l=null):l=ee(Qt(n,h,i.state,d),o),d){var f=d[0].name;f&&(l="m-"+(l?f+" "+l:f))}if(!a||u!=l){for(;cs;--a){if(a<=o.first)return o.first;var l=M(o,a-1),c=l.stateAfter;if(c&&(!n||a+(c instanceof ua?c.lookAhead:0)<=o.modeFrontier))return a;var u=h(l.text,null,t.options.tabSize);(null==r||i>u)&&(r=a-1,i=u)}return r}function re(t,e){if(t.modeFrontier=Math.min(t.modeFrontier,e),!(t.highlightFrontiern;i--){var r=M(t,i).stateAfter;if(r&&(!(r instanceof ua)||i+r.lookAhead1&&!/ /.test(t))return t;for(var n=e,i="",r=0;rc&&h.from<=c));d++);if(h.to>=u)return t(n,i,r,o,s,a,l);t(n,i.slice(0,h.to-c),r,o,null,a,l),o=null,i=i.slice(h.to-c),c=h.to}}}function fe(t,e,n,i){var r=!i&&n.widgetNode;r&&t.map.push(t.pos,t.pos+e,r),!i&&t.cm.display.input.needsContentAttribute&&(r||(r=t.content.appendChild(document.createElement("span"))),r.setAttribute("cm-marker",n.id)),r&&(t.cm.display.input.setUneditable(r),t.content.appendChild(r)),t.pos+=e,t.trailingSpace=!1}function pe(t,e,n){var i=t.markedSpans,r=t.text,o=0;if(i)for(var s,a,l,c,u,h,d,f=r.length,p=0,g=1,v="",m=0;;){if(m==p){l=c=u=h=a="",d=null,m=1/0;for(var y=[],b=void 0,x=0;xp||C.collapsed&&w.to==p&&w.from==p)?(null!=w.to&&w.to!=p&&m>w.to&&(m=w.to,c=""),C.className&&(l+=" "+C.className),C.css&&(a=(a?a+";":"")+C.css),C.startStyle&&w.from==p&&(u+=" "+C.startStyle),C.endStyle&&w.to==m&&(b||(b=[])).push(C.endStyle,w.to),C.title&&!h&&(h=C.title),C.collapsed&&(!d||st(d.marker,C)<0)&&(d=w)):w.from>p&&m>w.from&&(m=w.from)}if(b)for(var k=0;k=f)break;for(var T=Math.min(f,m);;){if(v){var E=p+v.length;if(!d){var M=E>T?v.slice(0,T-p):v;e.addToken(e,M,s?s+l:l,u,p+M.length==m?c:"",h,a)}if(E>=T){v=v.slice(T-p),p=T;break}p=E,u=""}v=r.slice(o,o=n[g++]),s=ae(n[g++],e.cm.options)}}else for(var P=1;P2&&o.push((l.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Be(t,e,n){if(t.line==e)return{map:t.measure.map,cache:t.measure.cache};for(var i=0;in)return{map:t.measure.maps[r],cache:t.measure.caches[r],before:!0}}function We(t,e){e=ht(e);var i=L(e),r=t.display.externalMeasured=new ge(t.doc,e,i);r.lineN=i;var o=r.built=le(t,r);return r.text=o.pre,n(t.display.lineMeasure,o.pre),r}function Ue(t,e,n,i){return Ge(t,Ke(t,e),n,i)}function qe(t,e){if(e>=t.display.viewFrom&&e=n.lineN&&ee)&&(o=l-a,r=o-1,e>=l&&(s="right")),null!=r){if(i=t[c+2],a==l&&n==(i.insertLeft?"left":"right")&&(s=n),"left"==n&&0==r)for(;c&&t[c-2]==t[c-3]&&t[c-1].insertLeft;)i=t[2+(c-=3)],s="left";if("right"==n&&r==l-a)for(;c=0&&(n=t[r]).left==n.right;r--);return n}function Je(t,e,n,i){var r,o=Ye(e.map,n,i),s=o.node,a=o.start,l=o.end,c=o.collapse;if(3==s.nodeType){for(var u=0;u<4;u++){for(;a&&k(e.line.text.charAt(o.coverStart+a));)--a;for(;o.coverStart+l0&&(c=i="right");var h;r=t.options.lineWrapping&&(h=s.getClientRects()).length>1?h["right"==i?h.length-1:0]:s.getBoundingClientRect()}if(ms&&ys<9&&!a&&(!r||!r.left&&!r.right)){var d=s.parentNode.getClientRects()[0];r=d?{left:d.left,right:d.left+xn(t.display),top:d.top,bottom:d.bottom}:ba}for(var f=r.top-e.rect.top,p=r.bottom-e.rect.top,g=(f+p)/2,v=e.view.measure.heights,m=0;m=i.text.length?(c=i.text.length,u="before"):c<=0&&(c=0,u="after"),!l)return s("before"==u?c-1:c,"before"==u);var h=Ct(l,c,u),d=Js,f=a(c,h,"before"==u);return null!=d&&(f.other=a(c,d,"before"!=u)),f}function un(t,e){var n=0;e=j(t.doc,e),t.options.lineWrapping||(n=xn(t.display)*e.ch);var i=M(t.doc,e.line),r=yt(i)+Fe(t.display);return{left:n,right:n,top:r,bottom:r+i.height}}function hn(t,e,n,i,r){var o=_(t,e,n);return o.xRel=r,i&&(o.outside=!0),o}function dn(t,e,n){var i=t.doc;if((n+=t.display.viewOffset)<0)return hn(i.first,0,null,!0,-1);var r=N(i,n),o=i.first+i.size-1;if(r>o)return hn(i.first+i.size-1,M(i,o).text.length,null,!0,1);e<0&&(e=0);for(var s=M(i,r);;){var a=vn(t,s,r,e,n),l=ct(s),c=l&&l.find(0,!0);if(!l||!(a.ch>c.from.ch||a.ch==c.from.ch&&a.xRel>0))return a;r=L(s=c.to.line)}}function fn(t,e,n,i){i-=on(e);var r=e.text.length,o=T(function(e){return Ge(t,n,e-1).bottom<=i},r,0);return r=T(function(e){return Ge(t,n,e).top>i},o,r),{begin:o,end:r}}function pn(t,e,n,i){return n||(n=Ke(t,e)),fn(t,e,n,sn(t,e,Ge(t,n,i),"line").top)}function gn(t,e,n,i){return!(t.bottom<=n)&&(t.top>n||(i?t.left:t.right)>e)}function vn(t,e,n,i,r){r-=yt(e);var o=Ke(t,e),s=on(e),a=0,l=e.text.length,c=!0,u=kt(e,t.doc.direction);if(u){var h=(t.options.lineWrapping?yn:mn)(t,e,n,o,u,i,r);c=1!=h.level,a=c?h.from:h.to-1,l=c?h.to:h.from-1}var d,f,p=null,g=null,v=T(function(e){var n=Ge(t,o,e);return n.top+=s,n.bottom+=s,!!gn(n,i,r,!1)&&(n.top<=r&&n.left<=i&&(p=e,g=n),!0)},a,l),m=!1;if(g){var y=i-g.left=x.bottom}return v=S(e.text,v,1),hn(n,v,f,m,i-d)}function mn(t,e,n,i,r,o,s){var a=T(function(a){var l=r[a],c=1!=l.level;return gn(cn(t,_(n,c?l.to:l.from,c?"before":"after"),"line",e,i),o,s,!0)},0,r.length-1),l=r[a];if(a>0){var c=1!=l.level,u=cn(t,_(n,c?l.from:l.to,c?"after":"before"),"line",e,i);gn(u,o,s,!0)&&u.top>s&&(l=r[a-1])}return l}function yn(t,e,n,i,r,o,s){var a=fn(t,e,i,s),l=a.begin,c=a.end;/\s/.test(e.text.charAt(c-1))&&c--;for(var u=null,h=null,d=0;d=c||f.to<=l)){var p=1!=f.level,g=Ge(t,i,p?Math.min(c,f.to)-1:Math.max(l,f.from)).right,v=gv)&&(u=f,h=v)}}return u||(u=r[r.length-1]),u.fromc&&(u={from:u.from,to:c,level:u.level}),u}function bn(t){if(null!=t.cachedTextHeight)return t.cachedTextHeight;if(null==pa){pa=i("pre");for(var r=0;r<49;++r)pa.appendChild(document.createTextNode("x")),pa.appendChild(i("br"));pa.appendChild(document.createTextNode("x"))}n(t.measure,pa);var o=pa.offsetHeight/50;return o>3&&(t.cachedTextHeight=o),e(t.measure),o||1}function xn(t){if(null!=t.cachedCharWidth)return t.cachedCharWidth;var e=i("span","xxxxxxxxxx"),r=i("pre",[e]);n(t.measure,r);var o=e.getBoundingClientRect(),s=(o.right-o.left)/10;return s>2&&(t.cachedCharWidth=s),s||10}function wn(t){for(var e=t.display,n={},i={},r=e.gutters.clientLeft,o=e.gutters.firstChild,s=0;o;o=o.nextSibling,++s)n[t.options.gutters[s]]=o.offsetLeft+o.clientLeft+r,i[t.options.gutters[s]]=o.clientWidth;return{fixedPos:Cn(e),gutterTotalWidth:e.gutters.offsetWidth,gutterLeft:n,gutterWidth:i,wrapperWidth:e.wrapper.clientWidth}}function Cn(t){return t.scroller.getBoundingClientRect().left-t.sizer.getBoundingClientRect().left}function kn(t){var e=bn(t.display),n=t.options.lineWrapping,i=n&&Math.max(5,t.display.scroller.clientWidth/xn(t.display)-3);return function(r){if(vt(t.doc,r))return 0;var o=0;if(r.widgets)for(var s=0;s=t.display.viewTo)return null;if((e-=t.display.viewFrom)<0)return null;for(var n=t.display.view,i=0;i=t.display.viewTo||a.to().line0?e.blinker=setInterval(function(){return e.cursorDiv.style.visibility=(n=!n)?"":"hidden"},t.options.cursorBlinkRate):t.options.cursorBlinkRate<0&&(e.cursorDiv.style.visibility="hidden")}}function Dn(t){t.state.focused||(t.display.input.focus(),_n(t))}function In(t){t.state.delayingBlurEvent=!0,setTimeout(function(){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1,Fn(t))},100)}function _n(t,e){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1),"nocursor"!=t.options.readOnly&&(t.state.focused||(Et(t,"focus",t,e),t.state.focused=!0,a(t.display.wrapper,"CodeMirror-focused"),t.curOp||t.display.selForContextMenu==t.doc.sel||(t.display.input.reset(),bs&&setTimeout(function(){return t.display.input.reset(!0)},20)),t.display.input.receivedFocus()),Nn(t))}function Fn(t,e){t.state.delayingBlurEvent||(t.state.focused&&(Et(t,"blur",t,e),t.state.focused=!1,Fs(t.display.wrapper,"CodeMirror-focused")),clearInterval(t.display.blinker),setTimeout(function(){t.state.focused||(t.display.shift=!1)},150))}function zn(t){for(var e=t.display,n=e.lineDiv.offsetTop,i=0;i.005||l<-.005)&&(O(r.line,o),$n(r.line),r.rest))for(var c=0;c=s&&(o=N(e,yt(M(e,l))-t.wrapper.clientHeight),s=l)}return{from:o,to:Math.max(s,o+1)}}function Vn(t){var e=t.display,n=e.view;if(e.alignWidgets||e.gutters.firstChild&&t.options.fixedGutter){for(var i=Cn(e)-e.scroller.scrollLeft+t.doc.scrollLeft,r=e.gutters.offsetWidth,o=i+"px",s=0;s(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!Ts){var s=i("div","​",null,"position: absolute;\n top: "+(e.top-n.viewOffset-Fe(t.display))+"px;\n height: "+(e.bottom-e.top+Re(t)+n.barHeight)+"px;\n left: "+e.left+"px; width: "+Math.max(2,e.right-e.left)+"px;");t.display.lineSpace.appendChild(s),s.scrollIntoView(o),t.display.lineSpace.removeChild(s)}}}function Bn(t,e,n,i){null==i&&(i=0);var r;t.options.lineWrapping||e!=n||(e=e.ch?_(e.line,"before"==e.sticky?e.ch-1:e.ch,"after"):e,n="before"==e.sticky?_(e.line,e.ch+1,"before"):e);for(var o=0;o<5;o++){var s=!1,a=cn(t,e),l=n&&n!=e?cn(t,n):a;r={left:Math.min(a.left,l.left),top:Math.min(a.top,l.top)-i,right:Math.max(a.left,l.left),bottom:Math.max(a.bottom,l.bottom)+i};var c=Un(t,r),u=t.doc.scrollTop,h=t.doc.scrollLeft;if(null!=c.scrollTop&&(Zn(t,c.scrollTop),Math.abs(t.doc.scrollTop-u)>1&&(s=!0)),null!=c.scrollLeft&&(ti(t,c.scrollLeft),Math.abs(t.doc.scrollLeft-h)>1&&(s=!0)),!s)break}return r}function Wn(t,e){var n=Un(t,e);null!=n.scrollTop&&Zn(t,n.scrollTop),null!=n.scrollLeft&&ti(t,n.scrollLeft)}function Un(t,e){var n=t.display,i=bn(t.display);e.top<0&&(e.top=0);var r=t.curOp&&null!=t.curOp.scrollTop?t.curOp.scrollTop:n.scroller.scrollTop,o=He(t),s={};e.bottom-e.top>o&&(e.bottom=e.top+o);var a=t.doc.height+ze(n),l=e.topa-i;if(e.topr+o){var u=Math.min(e.top,(c?a:e.bottom)-o);u!=r&&(s.scrollTop=u)}var h=t.curOp&&null!=t.curOp.scrollLeft?t.curOp.scrollLeft:n.scroller.scrollLeft,d=Ve(t)-(t.options.fixedGutter?n.gutters.offsetWidth:0),f=e.right-e.left>d;return f&&(e.right=e.left+d),e.left<10?s.scrollLeft=0:e.leftd+h-3&&(s.scrollLeft=e.right+(f?0:10)-d),s}function qn(t,e){null!=e&&(Xn(t),t.curOp.scrollTop=(null==t.curOp.scrollTop?t.doc.scrollTop:t.curOp.scrollTop)+e)}function Kn(t){Xn(t);var e=t.getCursor();t.curOp.scrollToPos={from:e,to:e,margin:t.options.cursorScrollMargin}}function Gn(t,e,n){null==e&&null==n||Xn(t),null!=e&&(t.curOp.scrollLeft=e),null!=n&&(t.curOp.scrollTop=n)}function Yn(t,e){Xn(t),t.curOp.scrollToPos=e}function Xn(t){var e=t.curOp.scrollToPos;if(e){t.curOp.scrollToPos=null;Jn(t,un(t,e.from),un(t,e.to),e.margin)}}function Jn(t,e,n,i){var r=Un(t,{left:Math.min(e.left,n.left),top:Math.min(e.top,n.top)-i,right:Math.max(e.right,n.right),bottom:Math.max(e.bottom,n.bottom)+i});Gn(t,r.scrollLeft,r.scrollTop)}function Zn(t,e){Math.abs(t.doc.scrollTop-e)<2||(fs||Oi(t,{top:e}),Qn(t,e,!0),fs&&Oi(t),ki(t,100))}function Qn(t,e,n){e=Math.min(t.display.scroller.scrollHeight-t.display.scroller.clientHeight,e),(t.display.scroller.scrollTop!=e||n)&&(t.doc.scrollTop=e,t.display.scrollbars.setScrollTop(e),t.display.scroller.scrollTop!=e&&(t.display.scroller.scrollTop=e))}function ti(t,e,n,i){e=Math.min(e,t.display.scroller.scrollWidth-t.display.scroller.clientWidth),(n?e==t.doc.scrollLeft:Math.abs(t.doc.scrollLeft-e)<2)&&!i||(t.doc.scrollLeft=e,Vn(t),t.display.scroller.scrollLeft!=e&&(t.display.scroller.scrollLeft=e),t.display.scrollbars.setScrollLeft(e))}function ei(t){var e=t.display,n=e.gutters.offsetWidth,i=Math.round(t.doc.height+ze(t.display));return{clientHeight:e.scroller.clientHeight,viewHeight:e.wrapper.clientHeight,scrollWidth:e.scroller.scrollWidth,clientWidth:e.scroller.clientWidth,viewWidth:e.wrapper.clientWidth,barLeft:t.options.fixedGutter?n:0,docHeight:i,scrollHeight:i+Re(t)+e.barHeight,nativeBarWidth:e.nativeBarWidth,gutterWidth:n}}function ni(t,e){e||(e=ei(t));var n=t.display.barWidth,i=t.display.barHeight;ii(t,e);for(var r=0;r<4&&n!=t.display.barWidth||i!=t.display.barHeight;r++)n!=t.display.barWidth&&t.options.lineWrapping&&zn(t),ii(t,ei(t)),n=t.display.barWidth,i=t.display.barHeight}function ii(t,e){var n=t.display,i=n.scrollbars.update(e);n.sizer.style.paddingRight=(n.barWidth=i.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=i.bottom)+"px",n.heightForcer.style.borderBottom=i.bottom+"px solid transparent",i.right&&i.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=i.bottom+"px",n.scrollbarFiller.style.width=i.right+"px"):n.scrollbarFiller.style.display="",i.bottom&&t.options.coverGutterNextToScrollbar&&t.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=i.bottom+"px",n.gutterFiller.style.width=e.gutterWidth+"px"):n.gutterFiller.style.display=""}function ri(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Fs(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new Ca[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),ta(e,"mousedown",function(){t.state.focused&&setTimeout(function(){return t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,n){"horizontal"==n?ti(t,e):Zn(t,e)},t),t.display.scrollbars.addClass&&a(t.display.wrapper,t.display.scrollbars.addClass)}function oi(t){t.curOp={cm:t,viewChanged:!1,startHeight:t.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++ka},me(t.curOp)}function si(t){be(t.curOp,function(t){for(var e=0;e=n.viewTo)||n.maxLineChanged&&e.options.lineWrapping,t.update=t.mustUpdate&&new Sa(e,t.mustUpdate&&{top:t.scrollTop,ensure:t.scrollToPos},t.forceUpdate)}function ci(t){t.updatedDisplay=t.mustUpdate&&Pi(t.cm,t.update)}function ui(t){var e=t.cm,n=e.display;t.updatedDisplay&&zn(e),t.barMeasure=ei(e),n.maxLineChanged&&!e.options.lineWrapping&&(t.adjustWidthTo=Ue(e,n.maxLine,n.maxLine.text.length).left+3,e.display.sizerWidth=t.adjustWidthTo,t.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+t.adjustWidthTo+Re(e)+e.display.barWidth),t.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+t.adjustWidthTo-Ve(e))),(t.updatedDisplay||t.selectionChanged)&&(t.preparedSelection=n.input.prepareSelection())}function hi(t){var e=t.cm;null!=t.adjustWidthTo&&(e.display.sizer.style.minWidth=t.adjustWidthTo+"px",t.maxScrollLefte)&&(r.updateLineNumbers=e),t.curOp.viewChanged=!0,e>=r.viewTo)Xs&&pt(t.doc,e)r.viewFrom?bi(t):(r.viewFrom+=i,r.viewTo+=i);else if(e<=r.viewFrom&&n>=r.viewTo)bi(t);else if(e<=r.viewFrom){var o=xi(t,n,n+i,1);o?(r.view=r.view.slice(o.index),r.viewFrom=o.lineN,r.viewTo+=i):bi(t)}else if(n>=r.viewTo){var s=xi(t,e,e,-1);s?(r.view=r.view.slice(0,s.index),r.viewTo=s.lineN):bi(t)}else{var a=xi(t,e,e,-1),l=xi(t,n,n+i,1);a&&l?(r.view=r.view.slice(0,a.index).concat(ve(t,a.lineN,l.lineN)).concat(r.view.slice(l.index)),r.viewTo+=i):bi(t)}var c=r.externalMeasured;c&&(n=r.lineN&&e=i.viewTo)){var o=i.view[En(t,e)];if(null!=o.node){var s=o.changes||(o.changes=[]);-1==d(s,n)&&s.push(n)}}}function bi(t){t.display.viewFrom=t.display.viewTo=t.doc.first,t.display.view=[],t.display.viewOffset=0}function xi(t,e,n,i){var r,o=En(t,e),s=t.display.view;if(!Xs||n==t.doc.first+t.doc.size)return{index:o,lineN:n};for(var a=t.display.viewFrom,l=0;l0){if(o==s.length-1)return null;r=a+s[o].size-e,o++}else r=a-e;e+=r,n+=r}for(;pt(t.doc,n)!=n;){if(o==(i<0?0:s.length-1))return null;n+=i*s[o-(i<0?1:0)].size,o+=i}return{index:o,lineN:n}}function wi(t,e,n){var i=t.display;0==i.view.length||e>=i.viewTo||n<=i.viewFrom?(i.view=ve(t,e,n),i.viewFrom=e):(i.viewFrom>e?i.view=ve(t,e,i.viewFrom).concat(i.view):i.viewFromn&&(i.view=i.view.slice(0,En(t,n)))),i.viewTo=n}function Ci(t){for(var e=t.display.view,n=0,i=0;i=t.display.viewTo)){var n=+new Date+t.options.workTime,i=Xt(t,e.highlightFrontier),r=[];e.iter(i.line,Math.min(e.first+e.size,t.display.viewTo+500),function(o){if(i.line>=t.display.viewFrom){var s=o.styles,a=o.text.length>t.options.maxHighlightLength?Ut(e.mode,i.state):null,l=Gt(t,o,i,!0);a&&(i.state=a),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var h=!s||s.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),d=0;!h&&dn)return ki(t,t.options.workDelay),!0}),e.highlightFrontier=i.line,e.modeFrontier=Math.max(e.modeFrontier,i.line),r.length&&fi(t,function(){for(var e=0;e=i.viewFrom&&n.visible.to<=i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&0==Ci(t))return!1;Hn(t)&&(bi(t),n.dims=wn(t));var o=r.first+r.size,s=Math.max(n.visible.from-t.options.viewportMargin,r.first),a=Math.min(o,n.visible.to+t.options.viewportMargin);i.viewFroma&&i.viewTo-a<20&&(a=Math.min(o,i.viewTo)),Xs&&(s=pt(t.doc,s),a=gt(t.doc,a));var l=s!=i.viewFrom||a!=i.viewTo||i.lastWrapHeight!=n.wrapperHeight||i.lastWrapWidth!=n.wrapperWidth;wi(t,s,a),i.viewOffset=yt(M(t.doc,i.viewFrom)),t.display.mover.style.top=i.viewOffset+"px";var c=Ci(t);if(!l&&0==c&&!n.force&&i.renderedView==i.view&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo))return!1;var u=Ei(t);return c>4&&(i.lineDiv.style.display="none"),Li(t,i.updateLineNumbers,n.dims),c>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,Mi(u),e(i.cursorDiv),e(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,l&&(i.lastWrapHeight=n.wrapperHeight,i.lastWrapWidth=n.wrapperWidth,ki(t,400)),i.updateLineNumbers=null,!0}function Ai(t,e){for(var n=e.viewport,i=!0;(i&&t.options.lineWrapping&&e.oldDisplayWidth!=Ve(t)||(n&&null!=n.top&&(n={top:Math.min(t.doc.height+ze(t.display)-He(t),n.top)}),e.visible=Rn(t.display,t.doc,n),!(e.visible.from>=t.display.viewFrom&&e.visible.to<=t.display.viewTo)))&&Pi(t,e);i=!1){zn(t);var r=ei(t);Mn(t),ni(t,r),Di(t,r),e.force=!1}e.signal(t,"update",t),t.display.viewFrom==t.display.reportedViewFrom&&t.display.viewTo==t.display.reportedViewTo||(e.signal(t,"viewportChange",t,t.display.viewFrom,t.display.viewTo),t.display.reportedViewFrom=t.display.viewFrom,t.display.reportedViewTo=t.display.viewTo)}function Oi(t,e){var n=new Sa(t,e);if(Pi(t,n)){zn(t),Ai(t,n);var i=ei(t);Mn(t),ni(t,i),Di(t,i),n.finish()}}function Li(t,n,i){function r(e){var n=e.nextSibling;return bs&&As&&t.display.currentWheelTarget==e?e.style.display="none":e.parentNode.removeChild(e),n}for(var o=t.display,s=t.options.lineNumbers,a=o.lineDiv,l=a.firstChild,c=o.view,u=o.viewFrom,h=0;h-1&&(p=!1),Ce(t,f,u,i)),p&&(e(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(I(t.options,u)))),l=f.node.nextSibling}else{var g=Oe(t,f,u,i);a.insertBefore(g,l)}u+=f.size}for(;l;)l=r(l)}function Ni(t){var e=t.display.gutters.offsetWidth;t.display.sizer.style.marginLeft=e+"px"}function Di(t,e){t.display.sizer.style.minHeight=e.docHeight+"px",t.display.heightForcer.style.top=e.docHeight+"px",t.display.gutters.style.height=e.docHeight+t.display.barHeight+Re(t)+"px"}function Ii(t){var n=t.display.gutters,r=t.options.gutters;e(n);for(var o=0;o-1&&!t.lineNumbers&&(t.gutters=t.gutters.slice(0),t.gutters.splice(e,1))}function Fi(t){var e=t.wheelDeltaX,n=t.wheelDeltaY;return null==e&&t.detail&&t.axis==t.HORIZONTAL_AXIS&&(e=t.detail),null==n&&t.detail&&t.axis==t.VERTICAL_AXIS?n=t.detail:null==n&&(n=t.wheelDelta),{x:e,y:n}}function zi(t){var e=Fi(t);return e.x*=Ea,e.y*=Ea,e}function $i(t,e){var n=Fi(e),i=n.x,r=n.y,o=t.display,s=o.scroller,a=s.scrollWidth>s.clientWidth,l=s.scrollHeight>s.clientHeight;if(i&&a||r&&l){if(r&&As&&bs)t:for(var c=e.target,u=o.view;c!=s;c=c.parentNode)for(var h=0;h=0){var s=V(o.from(),r.from()),a=R(o.to(),r.to()),l=o.empty()?r.from()==r.head:o.from()==o.head;i<=e&&--e,t.splice(--i,2,new Pa(l?a:s,l?s:a))}}return new Ma(t,e)}function Vi(t,e){return new Ma([new Pa(t,e||t)],0)}function Hi(t){return t.text?_(t.from.line+t.text.length-1,g(t.text).length+(1==t.text.length?t.from.ch:0)):t.to}function ji(t,e){if(F(t,e.from)<0)return t;if(F(t,e.to)<=0)return Hi(e);var n=t.line+e.text.length-(e.to.line-e.from.line)-1,i=t.ch;return t.line==e.to.line&&(i+=Hi(e).ch-e.to.ch),_(n,i)}function Bi(t,e){for(var n=[],i=0;i1&&t.remove(a.line+1,p-1),t.insert(a.line+1,y)}xe(t,"change",t,e)}function Xi(t,e,n){function i(t,r,o){if(t.linked)for(var s=0;s1&&!t.done[t.done.length-2].ranges?(t.done.pop(),g(t.done)):void 0}function rr(t,e,n,i){var r=t.history;r.undone.length=0;var o,s,a=+new Date;if((r.lastOp==i||r.lastOrigin==e.origin&&e.origin&&("+"==e.origin.charAt(0)&&t.cm&&r.lastModTime>a-t.cm.options.historyEventDelay||"*"==e.origin.charAt(0)))&&(o=ir(r,r.lastOp==i)))s=g(o.changes),0==F(e.from,e.to)&&0==F(e.from,s.to)?s.to=Hi(e):o.changes.push(er(t,e));else{var l=g(r.done);for(l&&l.ranges||ar(t.sel,r.done),o={changes:[er(t,e)],generation:r.generation},r.done.push(o);r.done.length>r.undoDepth;)r.done.shift(),r.done[0].ranges||r.done.shift()}r.done.push(n),r.generation=++r.maxGeneration,r.lastModTime=r.lastSelTime=a,r.lastOp=r.lastSelOp=i,r.lastOrigin=r.lastSelOrigin=e.origin,s||Et(t,"historyAdded")}function or(t,e,n,i){var r=e.charAt(0);return"*"==r||"+"==r&&n.ranges.length==i.ranges.length&&n.somethingSelected()==i.somethingSelected()&&new Date-t.history.lastSelTime<=(t.cm?t.cm.options.historyEventDelay:500)}function sr(t,e,n,i){var r=t.history,o=i&&i.origin;n==r.lastSelOp||o&&r.lastSelOrigin==o&&(r.lastModTime==r.lastSelTime&&r.lastOrigin==o||or(t,o,g(r.done),e))?r.done[r.done.length-1]=e:ar(e,r.done),r.lastSelTime=+new Date,r.lastSelOrigin=o,r.lastSelOp=n,i&&!1!==i.clearRedo&&nr(r.undone)}function ar(t,e){var n=g(e);n&&n.ranges&&n.equals(t)||e.push(t)}function lr(t,e,n,i){var r=e["spans_"+t.id],o=0;t.iter(Math.max(t.first,n),Math.min(t.first+t.size,i),function(n){n.markedSpans&&((r||(r=e["spans_"+t.id]={}))[o]=n.markedSpans),++o})}function cr(t){if(!t)return null;for(var e,n=0;n-1&&(g(a)[h]=c[h],delete c[h])}}}return i}function fr(t,e,n,i){if(i){var r=t.anchor;if(n){var o=F(e,r)<0;o!=F(n,r)<0?(r=e,e=n):o!=F(e,n)<0&&(e=n)}return new Pa(r,e)}return new Pa(n||e,e)}function pr(t,e,n,i,r){null==r&&(r=t.cm&&(t.cm.display.shift||t.extend)),xr(t,new Ma([fr(t.sel.primary(),e,n,r)],0),i)}function gr(t,e,n){for(var i=[],r=t.cm&&(t.cm.display.shift||t.extend),o=0;o=e.ch:a.to>e.ch))){if(r&&(Et(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--s;continue}break}if(!l.atomic)continue;if(n){var c=l.find(i<0?1:-1),u=void 0;if((i<0?l.inclusiveRight:l.inclusiveLeft)&&(c=Mr(t,c,-i,c&&c.line==e.line?o:null)),c&&c.line==e.line&&(u=F(c,n))&&(i<0?u<0:u>0))return Tr(t,c,e,i,r)}var h=l.find(i<0?-1:1);return(i<0?l.inclusiveLeft:l.inclusiveRight)&&(h=Mr(t,h,i,h.line==e.line?o:null)),h?Tr(t,h,e,i,r):null}}return e}function Er(t,e,n,i,r){var o=i||1,s=Tr(t,e,n,o,r)||!r&&Tr(t,e,n,o,!0)||Tr(t,e,n,-o,r)||!r&&Tr(t,e,n,-o,!0);return s||(t.cantEdit=!0,_(t.first,0))}function Mr(t,e,n,i){return n<0&&0==e.ch?e.line>t.first?j(t,_(e.line-1)):null:n>0&&e.ch==(i||M(t,e.line)).text.length?e.line=0;--r)Lr(t,{from:i[r].from,to:i[r].to,text:r?[""]:e.text,origin:e.origin});else Lr(t,e)}}function Lr(t,e){if(1!=e.text.length||""!=e.text[0]||0!=F(e.from,e.to)){var n=Bi(t,e);rr(t,e,n,t.cm?t.cm.curOp.id:NaN),Ir(t,e,n,Q(t,e));var i=[];Xi(t,function(t,n){n||-1!=d(i,t.history)||(Rr(t.history,e),i.push(t.history)),Ir(t,e,null,Q(t,e))})}}function Nr(t,e,n){if(!t.cm||!t.cm.state.suppressEdits||n){for(var i,r=t.history,o=t.sel,s="undo"==e?r.done:r.undone,a="undo"==e?r.undone:r.done,l=0;l=0;--h){var f=function(n){var r=i.changes[n];if(r.origin=e,u&&!Ar(t,r,!1))return s.length=0,{};c.push(er(t,r));var o=n?Bi(t,r):g(s);Ir(t,r,o,hr(t,r)),!n&&t.cm&&t.cm.scrollIntoView({from:r.from,to:Hi(r)});var a=[];Xi(t,function(t,e){e||-1!=d(a,t.history)||(Rr(t.history,r),a.push(t.history)),Ir(t,r,null,hr(t,r))})}(h);if(f)return f.v}}}}function Dr(t,e){if(0!=e&&(t.first+=e,t.sel=new Ma(v(t.sel.ranges,function(t){return new Pa(_(t.anchor.line+e,t.anchor.ch),_(t.head.line+e,t.head.ch))}),t.sel.primIndex),t.cm)){mi(t.cm,t.first,t.first-e,e);for(var n=t.cm.display,i=n.viewFrom;it.lastLine())){if(e.from.lineo&&(e={from:e.from,to:_(o,M(t,o).text.length),text:[e.text[0]],origin:e.origin}),e.removed=P(t,e.from,e.to),n||(n=Bi(t,e)),t.cm?_r(t.cm,e,i):Yi(t,e,i),wr(t,n,Bs)}}function _r(t,e,n){var i=t.doc,r=t.display,o=e.from,s=e.to,a=!1,l=o.line;t.options.lineWrapping||(l=L(ht(M(i,o.line))),i.iter(l,s.line+1,function(t){if(t==r.maxLine)return a=!0,!0})),i.sel.contains(e.from,e.to)>-1&&Pt(t),Yi(i,e,n,kn(t)),t.options.lineWrapping||(i.iter(l,o.line+e.text.length,function(t){var e=bt(t);e>r.maxLineLength&&(r.maxLine=t,r.maxLineLength=e,r.maxLineChanged=!0,a=!1)}),a&&(t.curOp.updateMaxLine=!0)),re(i,o.line),ki(t,400);var c=e.text.length-(s.line-o.line)-1;e.full?mi(t):o.line!=s.line||1!=e.text.length||Gi(t.doc,e)?mi(t,o.line,s.line+1,c):yi(t,o.line,"text");var u=At(t,"changes"),h=At(t,"change");if(h||u){var d={from:o,to:s,text:e.text,removed:e.removed,origin:e.origin};h&&xe(t,"change",t,d),u&&(t.curOp.changeObjs||(t.curOp.changeObjs=[])).push(d)}t.display.selForContextMenu=null}function Fr(t,e,n,i,r){if(i||(i=n),F(i,n)<0){var o;o=[i,n],n=o[0],i=o[1]}"string"==typeof e&&(e=t.splitLines(e)),Or(t,{from:n,to:i,text:e,origin:r})}function zr(t,e,n,i){n0||0==a&&!1!==s.clearWhenEmpty)return s;if(s.replacedWith&&(s.collapsed=!0,s.widgetNode=r("span",[s.replacedWith],"CodeMirror-widget"),i.handleMouseEvents||s.widgetNode.setAttribute("cm-ignore-events","true"),i.insertLeft&&(s.widgetNode.insertLeft=!0)),s.collapsed){if(ut(t,e.line,e,n,s)||e.line!=n.line&&ut(t,n.line,e,n,s))throw new Error("Inserting collapsed marker partially overlapping an existing one");q()}s.addToHistory&&rr(t,{from:e,to:n,origin:"markText"},t.sel,NaN);var l,c=e.line,h=t.cm;if(t.iter(c,n.line+1,function(t){h&&s.collapsed&&!h.options.lineWrapping&&ht(t)==h.display.maxLine&&(l=!0),s.collapsed&&c!=e.line&&O(t,0),X(t,new K(s,c==e.line?e.ch:null,c==n.line?n.ch:null)),++c}),s.collapsed&&t.iter(e.line,n.line+1,function(e){vt(t,e)&&O(e,0)}),s.clearOnEnter&&ta(s,"beforeCursorEnter",function(){return s.clear()}),s.readOnly&&(U(),(t.history.done.length||t.history.undone.length)&&t.clearHistory()),s.collapsed&&(s.id=++Oa,s.atomic=!0),h){if(l&&(h.curOp.updateMaxLine=!0),s.collapsed)mi(h,e.line,n.line+1);else if(s.className||s.title||s.startStyle||s.endStyle||s.css)for(var d=e.line;d<=n.line;d++)yi(h,d,"text");s.atomic&&kr(h.doc),xe(h,"markerAdded",h,s)}return s}function qr(t,e,n,i,r){i=u(i),i.shared=!1;var o=[Ur(t,e,n,i,r)],s=o[0],a=i.widgetNode;return Xi(t,function(t){a&&(i.widgetNode=a.cloneNode(!0)),o.push(Ur(t,j(t,e),j(t,n),i,r));for(var l=0;l-1)return e.state.draggingText(t),void setTimeout(function(){return e.display.input.focus()},20);try{var l=t.dataTransfer.getData("Text");if(l){var c;if(e.state.draggingText&&!e.state.draggingText.copy&&(c=e.listSelections()),wr(e.doc,Vi(n,n)),c)for(var u=0;u=0;e--)Fr(t.doc,"",i[e].from,i[e].to,"+delete");Kn(t)})}function fo(t,e,n){var i=S(t.text,e+n,n);return i<0||i>t.text.length?null:i}function po(t,e,n){var i=fo(t,e.ch,n);return null==i?null:new _(e.line,i,n<0?"after":"before")}function go(t,e,n,i,r){if(t){var o=kt(n,e.doc.direction);if(o){var s,a=r<0?g(o):o[0],l=r<0==(1==a.level),c=l?"after":"before";if(a.level>0||"rtl"==e.doc.direction){var u=Ke(e,n);s=r<0?n.text.length-1:0;var h=Ge(e,u,s).top;s=T(function(t){return Ge(e,u,t).top==h},r<0==(1==a.level)?a.from:a.to-1,s),"before"==c&&(s=fo(n,s,1))}else s=r<0?a.to:a.from;return new _(i,s,c)}}return new _(i,r<0?n.text.length:0,r<0?"before":"after")}function vo(t,e,n,i){var r=kt(e,t.doc.direction);if(!r)return po(e,n,i);n.ch>=e.text.length?(n.ch=e.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=Ct(r,n.ch,n.sticky),s=r[o];if("ltr"==t.doc.direction&&s.level%2==0&&(i>0?s.to>n.ch:s.from=s.from&&d>=u.begin)){var f=h?"before":"after";return new _(n.line,d,f)}}var p=function(t,e,i){for(var o=function(t,e){return e?new _(n.line,l(t,1),"before"):new _(n.line,t,"after")};t>=0&&t0==(1!=s.level),c=a?i.begin:l(i.end,-1);if(s.from<=c&&c0?u.end:l(u.begin,-1);return null==v||i>0&&v==e.text.length||!(g=p(i>0?0:r.length-1,i,c(v)))?null:g}function mo(t,e){var n=M(t.doc,e),i=ht(n);return i!=n&&(e=L(i)),go(!0,t,i,e,1)}function yo(t,e){var n=M(t.doc,e),i=dt(n);return i!=n&&(e=L(i)),go(!0,t,n,e,-1)}function bo(t,e){var n=mo(t,e.line),i=M(t.doc,n.line),r=kt(i,t.doc.direction);if(!r||0==r[0].level){var o=Math.max(0,i.text.search(/\S/)),s=e.line==n.line&&e.ch<=o&&e.ch;return _(n.line,s?0:o,n.sticky)}return n}function xo(t,e,n){if("string"==typeof e&&!(e=ja[e]))return!1;t.display.input.ensurePolled();var i=t.display.shift,r=!1;try{t.isReadOnly()&&(t.state.suppressEdits=!0),n&&(t.display.shift=!1),r=e(t)!=js}finally{t.display.shift=i,t.state.suppressEdits=!1}return r}function wo(t,e,n){for(var i=0;i-1&&(F((r=a.ranges[r]).from(),e)<0||e.xRel>0)&&(F(r.to(),e)>0||e.xRel<0)?Io(t,i,e,o):Fo(t,i,e,o)}function Io(t,e,n,i){var r=t.display,o=!1,s=pi(t,function(e){bs&&(r.scroller.draggable=!1),t.state.draggingText=!1,Tt(document,"mouseup",s),Tt(document,"mousemove",a),Tt(r.scroller,"dragstart",l),Tt(r.scroller,"drop",s),o||(Lt(e),i.addNew||pr(t.doc,n,null,null,i.extend),bs||ms&&9==ys?setTimeout(function(){document.body.focus(),r.input.focus()},20):r.input.focus())}),a=function(t){o=o||Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)>=10},l=function(){return o=!0};bs&&(r.scroller.draggable=!0),t.state.draggingText=s,s.copy=!i.moveOnDrag,r.scroller.dragDrop&&r.scroller.dragDrop(),ta(document,"mouseup",s),ta(document,"mousemove",a),ta(r.scroller,"dragstart",l),ta(r.scroller,"drop",s),In(t),setTimeout(function(){return r.input.focus()},20)}function _o(t,e,n){if("char"==n)return new Pa(e,e);if("word"==n)return t.findWordAt(e);if("line"==n)return new Pa(_(e.line,0),j(t.doc,_(e.line+1,0)));var i=n(t,e);return new Pa(i.from,i.to)}function Fo(t,e,n,i){function r(e){if(0!=F(m,e))if(m=e,"rectangle"==i.unit){for(var r=[],o=t.options.tabSize,s=h(M(c,n.line).text,n.ch,o),a=h(M(c,e.line).text,e.ch,o),l=Math.min(s,a),g=Math.max(s,a),v=Math.min(n.line,e.line),y=Math.min(t.lastLine(),Math.max(n.line,e.line));v<=y;v++){var b=M(c,v).text,x=f(b,l,o);l==g?r.push(new Pa(_(v,x),_(v,x))):b.length>x&&r.push(new Pa(_(v,x),_(v,f(b,g,o))))}r.length||r.push(new Pa(n,n)),xr(c,Ri(p.ranges.slice(0,d).concat(r),d),{origin:"*mouse",scroll:!1}),t.scrollIntoView(e)}else{var w,C=u,k=_o(t,e,i.unit),S=C.anchor;F(k.anchor,S)>0?(w=k.head,S=V(C.from(),k.anchor)):(w=k.anchor,S=R(C.to(),k.head));var T=p.ranges.slice(0);T[d]=zo(t,new Pa(j(c,S),w)),xr(c,Ri(T,d),Ws)}}function o(e){var n=++b,a=Tn(t,e,!0,"rectangle"==i.unit);if(a)if(0!=F(a,m)){t.curOp.focus=s(),r(a);var u=Rn(l,c);(a.line>=u.to||a.liney.bottom?20:0;h&&setTimeout(pi(t,function(){b==n&&(l.scroller.scrollTop+=h,o(e))}),50)}}function a(e){t.state.selectingText=!1,b=1/0,Lt(e),l.input.focus(),Tt(document,"mousemove",x),Tt(document,"mouseup",w),c.history.lastSelOrigin=null}var l=t.display,c=t.doc;Lt(e);var u,d,p=c.sel,g=p.ranges;if(i.addNew&&!i.extend?(d=c.sel.contains(n),u=d>-1?g[d]:new Pa(n,n)):(u=c.sel.primary(),d=c.sel.primIndex),"rectangle"==i.unit)i.addNew||(u=new Pa(n,n)),n=Tn(t,e,!0,!0),d=-1;else{var v=_o(t,n,i.unit);u=i.extend?fr(u,v.anchor,v.head,i.extend):v}i.addNew?-1==d?(d=g.length,xr(c,Ri(g.concat([u]),d),{scroll:!1,origin:"*mouse"})):g.length>1&&g[d].empty()&&"char"==i.unit&&!i.extend?(xr(c,Ri(g.slice(0,d).concat(g.slice(d+1)),0),{scroll:!1,origin:"*mouse"}),p=c.sel):vr(c,d,u,Ws):(d=0,xr(c,new Ma([u],0),Ws),p=c.sel);var m=n,y=l.wrapper.getBoundingClientRect(),b=0,x=pi(t,function(t){Ft(t)?o(t):a(t)}),w=pi(t,a);t.state.selectingText=w,ta(document,"mousemove",x),ta(document,"mouseup",w)}function zo(t,e){var n=e.anchor,i=e.head,r=M(t.doc,n.line);if(0==F(n,i)&&n.sticky==i.sticky)return e;var o=kt(r);if(!o)return e;var s=Ct(o,n.ch,n.sticky),a=o[s];if(a.from!=n.ch&&a.to!=n.ch)return e;var l=s+(a.from==n.ch==(1!=a.level)?0:1);if(0==l||l==o.length)return e;var c;if(i.line!=n.line)c=(i.line-n.line)*("ltr"==t.doc.direction?1:-1)>0;else{var u=Ct(o,i.ch,i.sticky),h=u-s||(i.ch-n.ch)*(1==a.level?-1:1);c=u==l-1||u==l?h<0:h>0}var d=o[l+(c?-1:0)],f=c==(1==d.level),p=f?d.from:d.to,g=f?"after":"before";return n.ch==p&&n.sticky==g?e:new Pa(new _(n.line,p,g),i)}function $o(t,e,n,i){var r,o;if(e.touches)r=e.touches[0].clientX,o=e.touches[0].clientY;else try{r=e.clientX,o=e.clientY}catch(e){return!1}if(r>=Math.floor(t.display.gutters.getBoundingClientRect().right))return!1;i&&Lt(e);var s=t.display,a=s.lineDiv.getBoundingClientRect();if(o>a.bottom||!At(t,n))return Dt(e);o-=a.top-s.viewOffset;for(var l=0;l=r){return Et(t,n,t,N(t.doc,o),t.options.gutters[l],e),Dt(e)}}}function Ro(t,e){return $o(t,e,"gutterClick",!0)}function Vo(t,e){_e(t.display,e)||Ho(t,e)||Mt(t,e,"contextmenu")||t.display.input.onContextMenu(e)}function Ho(t,e){return!!At(t,"gutterContextMenu")&&$o(t,e,"gutterContextMenu",!1)}function jo(t){t.display.wrapper.className=t.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+t.options.theme.replace(/(^|\s)\s*/g," cm-s-"),en(t)}function Bo(t){Ii(t),mi(t),Vn(t)}function Wo(t,e,n){if(!e!=!(n&&n!=Ga)){var i=t.display.dragFunctions,r=e?ta:Tt;r(t.display.scroller,"dragstart",i.start),r(t.display.scroller,"dragenter",i.enter),r(t.display.scroller,"dragover",i.over),r(t.display.scroller,"dragleave",i.leave),r(t.display.scroller,"drop",i.drop)}}function Uo(t){t.options.lineWrapping?(a(t.display.wrapper,"CodeMirror-wrap"),t.display.sizer.style.minWidth="",t.display.sizerWidth=null):(Fs(t.display.wrapper,"CodeMirror-wrap"),xt(t)),Sn(t),mi(t),en(t),setTimeout(function(){return ni(t)},100)}function qo(t,e){var n=this;if(!(this instanceof qo))return new qo(t,e);this.options=e=e?u(e):{},u(Ya,e,!1),_i(e);var i=e.value;"string"==typeof i&&(i=new Ia(i,e.mode,null,e.lineSeparator,e.direction)),this.doc=i;var r=new qo.inputStyles[e.inputStyle](this),o=this.display=new E(t,i,r);o.wrapper.CodeMirror=this,Ii(this),jo(this),e.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),ri(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new $s,keySeq:null,specialChars:null},e.autofocus&&!Ps&&o.input.focus(),ms&&ys<11&&setTimeout(function(){return n.display.input.reset(!0)},20),Ko(this),eo(),oi(this),this.curOp.forceUpdate=!0,Ji(this,i),e.autofocus&&!Ps||this.hasFocus()?setTimeout(c(_n,this),20):Fn(this);for(var s in Xa)Xa.hasOwnProperty(s)&&Xa[s](n,e[s],Ga);Hn(this),e.finishInit&&e.finishInit(this);for(var a=0;a400}var r=t.display;ta(r.scroller,"mousedown",pi(t,Oo)),ms&&ys<11?ta(r.scroller,"dblclick",pi(t,function(e){if(!Mt(t,e)){var n=Tn(t,e);if(n&&!Ro(t,e)&&!_e(t.display,e)){Lt(e);var i=t.findWordAt(n);pr(t.doc,i.anchor,i.head)}}})):ta(r.scroller,"dblclick",function(e){return Mt(t,e)||Lt(e)}),_s||ta(r.scroller,"contextmenu",function(e){return Vo(t,e)});var o,s={end:0};ta(r.scroller,"touchstart",function(e){if(!Mt(t,e)&&!n(e)&&!Ro(t,e)){r.input.ensurePolled(),clearTimeout(o);var i=+new Date;r.activeTouch={start:i,moved:!1,prev:i-s.end<=300?s:null},1==e.touches.length&&(r.activeTouch.left=e.touches[0].pageX,r.activeTouch.top=e.touches[0].pageY)}}),ta(r.scroller,"touchmove",function(){r.activeTouch&&(r.activeTouch.moved=!0)}),ta(r.scroller,"touchend",function(n){var o=r.activeTouch;if(o&&!_e(r,n)&&null!=o.left&&!o.moved&&new Date-o.start<300){var s,a=t.coordsChar(r.activeTouch,"page");s=!o.prev||i(o,o.prev)?new Pa(a,a):!o.prev.prev||i(o,o.prev.prev)?t.findWordAt(a):new Pa(_(a.line,0),j(t.doc,_(a.line+1,0))),t.setSelection(s.anchor,s.head),t.focus(),Lt(n)}e()}),ta(r.scroller,"touchcancel",e),ta(r.scroller,"scroll",function(){r.scroller.clientHeight&&(Zn(t,r.scroller.scrollTop),ti(t,r.scroller.scrollLeft,!0),Et(t,"scroll",t))}),ta(r.scroller,"mousewheel",function(e){return $i(t,e)}),ta(r.scroller,"DOMMouseScroll",function(e){return $i(t,e)}),ta(r.wrapper,"scroll",function(){return r.wrapper.scrollTop=r.wrapper.scrollLeft=0}),r.dragFunctions={enter:function(e){Mt(t,e)||It(e)},over:function(e){Mt(t,e)||(Zr(t,e),It(e))},start:function(e){return Jr(t,e)},drop:pi(t,Xr),leave:function(e){Mt(t,e)||Qr(t)}};var a=r.input.getField();ta(a,"keyup",function(e){return Mo.call(t,e)}),ta(a,"keydown",pi(t,To)),ta(a,"keypress",pi(t,Po)),ta(a,"focus",function(e){return _n(t,e)}),ta(a,"blur",function(e){return Fn(t,e)})}function Go(t,e,n,i){var r,o=t.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?r=Xt(t,e).state:n="prev");var s=t.options.tabSize,a=M(o,e),l=h(a.text,null,s);a.stateAfter&&(a.stateAfter=null);var c,u=a.text.match(/^\s*/)[0];if(i||/\S/.test(a.text)){if("smart"==n&&((c=o.mode.indent(r,a.text.slice(u.length),a.text))==js||c>150)){if(!i)return;n="prev"}}else c=0,n="not";"prev"==n?c=e>o.first?h(M(o,e-1).text,null,s):0:"add"==n?c=l+t.options.indentUnit:"subtract"==n?c=l-t.options.indentUnit:"number"==typeof n&&(c=l+n),c=Math.max(0,c);var d="",f=0;if(t.options.indentWithTabs)for(var g=Math.floor(c/s);g;--g)f+=s,d+="\t";if(f1)if(Za&&Za.text.join("\n")==e){if(i.ranges.length%Za.text.length==0){l=[];for(var c=0;c=0;h--){var d=i.ranges[h],f=d.from(),p=d.to();d.empty()&&(n&&n>0?f=_(f.line,f.ch-n):t.state.overwrite&&!s?p=_(p.line,Math.min(M(o,p.line).text.length,p.ch+g(a).length)):Za&&Za.lineWise&&Za.text.join("\n")==e&&(f=p=_(f.line,0))),u=t.curOp.updateInput;var m={from:f,to:p,text:l?l[h%l.length]:a,origin:r||(s?"paste":t.state.cutIncoming?"cut":"+input")};Or(t.doc,m),xe(t,"inputRead",t,m)}e&&!s&&Zo(t,e),Kn(t),t.curOp.updateInput=u,t.curOp.typing=!0,t.state.pasteIncoming=t.state.cutIncoming=!1}function Jo(t,e){var n=t.clipboardData&&t.clipboardData.getData("Text");if(n)return t.preventDefault(),e.isReadOnly()||e.options.disableInput||fi(e,function(){return Xo(e,n,0,null,"paste")}),!0}function Zo(t,e){if(t.options.electricChars&&t.options.smartIndent)for(var n=t.doc.sel,i=n.ranges.length-1;i>=0;i--){var r=n.ranges[i];if(!(r.head.ch>100||i&&n.ranges[i-1].head.line==r.head.line)){var o=t.getModeAt(r.head),s=!1;if(o.electricChars){for(var a=0;a-1){s=Go(t,r.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(M(t.doc,r.head.line).text.slice(0,r.head.ch))&&(s=Go(t,r.head.line,"smart"));s&&xe(t,"electricInput",t,r.head.line)}}}function Qo(t){for(var e=[],n=[],i=0;i=t.first+t.size)&&(e=new _(i,e.ch,e.sticky),c=M(t,i))}function s(i){var s;if(null==(s=r?vo(t.cm,c,e,n):po(c,e,n))){if(i||!o())return!1;e=go(r,t.cm,c,e.line,n)}else e=s;return!0}var a=e,l=n,c=M(t,e.line);if("char"==i)s();else if("column"==i)s(!0);else if("word"==i||"group"==i)for(var u=null,h="group"==i,d=t.cm&&t.cm.getHelper(e,"wordChars"),f=!0;!(n<0)||s(!f);f=!1){var p=c.text.charAt(e.ch)||"\n",g=w(p,d)?"w":h&&"\n"==p?"n":!h||/\s/.test(p)?null:"p";if(!h||f||g||(g="s"),u&&u!=g){n<0&&(n=1,s(),e.sticky="after");break}if(g&&(u=g),n>0&&!s(!f))break}var v=Er(t,e,a,l,!0);return z(a,v)&&(v.hitSide=!0),v}function is(t,e,n,i){var r,o=t.doc,s=e.left;if("page"==i){var a=Math.min(t.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),l=Math.max(a-.5*bn(t.display),3);r=(n>0?e.bottom:e.top)+n*l}else"line"==i&&(r=n>0?e.bottom+3:e.top-3);for(var c;c=dn(t,s,r),c.outside;){if(n<0?r<=0:r>=o.height){c.hitSide=!0;break}r+=5*n}return c}function rs(t,e){var n=qe(t,e.line);if(!n||n.hidden)return null;var i=M(t.doc,e.line),r=Be(n,i,e.line),o=kt(i,t.doc.direction),s="left";if(o){s=Ct(o,e.ch)%2?"right":"left"}var a=Ye(r.map,e.ch,s);return a.offset="right"==a.collapse?a.end:a.start,a}function os(t){for(var e=t;e;e=e.parentNode)if(/CodeMirror-gutter-wrapper/.test(e.className))return!0;return!1}function ss(t,e){return e&&(t.bad=!0),t}function as(t,e,n,i,r){function o(t){return function(e){return e.id==t}}function s(){u&&(c+=h,u=!1)}function a(t){t&&(s(),c+=t)}function l(e){if(1==e.nodeType){var n=e.getAttribute("cm-text");if(null!=n)return void a(n||e.textContent.replace(/\u200b/g,""));var c,d=e.getAttribute("cm-marker");if(d){var f=t.findMarks(_(i,0),_(r+1,0),o(+d));return void(f.length&&(c=f[0].find(0))&&a(P(t.doc,c.from,c.to).join(h)))}if("false"==e.getAttribute("contenteditable"))return;var p=/^(pre|div|p)$/i.test(e.nodeName);p&&s();for(var g=0;g=15&&(Cs=!1,bs=!0);var Ds,Is=As&&(xs||Cs&&(null==Ns||Ns<12.11)),_s=fs||ms&&ys>=9,Fs=function(e,n){var i=e.className,r=t(n).exec(i);if(r){var o=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(o?r[1]+o:"")}};Ds=document.createRange?function(t,e,n,i){var r=document.createRange();return r.setEnd(i||t,n),r.setStart(t,e),r}:function(t,e,n){var i=document.body.createTextRange();try{i.moveToElementText(t.parentNode)}catch(t){return i}return i.collapse(!0),i.moveEnd("character",n),i.moveStart("character",e),i};var zs=function(t){t.select()};Es?zs=function(t){t.selectionStart=0,t.selectionEnd=t.value.length}:ms&&(zs=function(t){try{t.select()}catch(t){}});var $s=function(){this.id=null};$s.prototype.set=function(t,e){clearTimeout(this.id),this.id=setTimeout(e,t)};var Rs,Vs,Hs=30,js={toString:function(){return"CodeMirror.Pass"}},Bs={scroll:!1},Ws={origin:"*mouse"},Us={origin:"+move"},qs=[""],Ks=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Gs=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Ys=!1,Xs=!1,Js=null,Zs=function(){function t(t){return t<=247?n.charAt(t):1424<=t&&t<=1524?"R":1536<=t&&t<=1785?i.charAt(t-1536):1774<=t&&t<=2220?"r":8192<=t&&t<=8203?"w":8204==t?"b":"L"}function e(t,e,n){this.level=t,this.from=e,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",i="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,s=/[LRr]/,a=/[Lb1n]/,l=/[1n]/;return function(n,i){var c="ltr"==i?"L":"R";if(0==n.length||"ltr"==i&&!r.test(n))return!1;for(var u=n.length,h=[],d=0;d=this.string.length},ca.prototype.sol=function(){return this.pos==this.lineStart},ca.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},ca.prototype.next=function(){if(this.pose},ca.prototype.eatSpace=function(){for(var t=this,e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++t.pos;return this.pos>e},ca.prototype.skipToEnd=function(){this.pos=this.string.length},ca.prototype.skipTo=function(t){var e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0},ca.prototype.backUp=function(t){this.pos-=t},ca.prototype.column=function(){return this.lastColumnPos0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}var r=function(t){return n?t.toLowerCase():t};if(r(this.string.substr(this.pos,t.length))==r(t))return!1!==e&&(this.pos+=t.length),!0},ca.prototype.current=function(){return this.string.slice(this.start,this.pos)},ca.prototype.hideFirstChars=function(t,e){this.lineStart+=t;try{return e()}finally{this.lineStart-=t}},ca.prototype.lookAhead=function(t){var e=this.lineOracle;return e&&e.lookAhead(t)},ca.prototype.baseToken=function(){var t=this.lineOracle;return t&&t.baseToken(this.pos)};var ua=function(t,e){this.state=t,this.lookAhead=e},ha=function(t,e,n,i){this.state=e,this.doc=t,this.line=n,this.maxLookAhead=i||0,this.baseTokens=null,this.baseTokenPos=1};ha.prototype.lookAhead=function(t){var e=this.doc.getLine(this.line+t);return null!=e&&t>this.maxLookAhead&&(this.maxLookAhead=t),e},ha.prototype.baseToken=function(t){var e=this;if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=t;)e.baseTokenPos+=2;var n=this.baseTokens[this.baseTokenPos+1];return{type:n&&n.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-t}},ha.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ha.fromSaved=function(t,e,n){return e instanceof ua?new ha(t,Ut(t.mode,e.state),n,e.lookAhead):new ha(t,Ut(t.mode,e),n)},ha.prototype.save=function(t){var e=!1!==t?Ut(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new ua(e,this.maxLookAhead):e};var da=function(t,e,n){this.start=t.start,this.end=t.pos,this.string=t.current(),this.type=e||null,this.state=n},fa=function(t,e,n){this.text=t,it(this,e),this.height=n?n(this):1};fa.prototype.lineNo=function(){return L(this)},Ot(fa);var pa,ga={},va={},ma=null,ya=null,ba={left:0,right:0,top:0,bottom:0},xa=function(t,e,n){this.cm=n;var r=this.vert=i("div",[i("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=i("div",[i("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");t(r),t(o),ta(r,"scroll",function(){r.clientHeight&&e(r.scrollTop,"vertical")}),ta(o,"scroll",function(){o.clientWidth&&e(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,ms&&ys<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};xa.prototype.update=function(t){var e=t.scrollWidth>t.clientWidth+1,n=t.scrollHeight>t.clientHeight+1,i=t.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=e?i+"px":"0";var r=t.viewHeight-(e?i:0);this.vert.firstChild.style.height=Math.max(0,t.scrollHeight-t.clientHeight+r)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(e){this.horiz.style.display="block",this.horiz.style.right=n?i+"px":"0",this.horiz.style.left=t.barLeft+"px";var o=t.viewWidth-t.barLeft-(n?i:0);this.horiz.firstChild.style.width=Math.max(0,t.scrollWidth-t.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&t.clientHeight>0&&(0==i&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?i:0,bottom:e?i:0}},xa.prototype.setScrollLeft=function(t){this.horiz.scrollLeft!=t&&(this.horiz.scrollLeft=t),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},xa.prototype.setScrollTop=function(t){this.vert.scrollTop!=t&&(this.vert.scrollTop=t),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},xa.prototype.zeroWidthHack=function(){var t=As&&!Ss?"12px":"18px";this.horiz.style.height=this.vert.style.width=t,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new $s,this.disableVert=new $s},xa.prototype.enableZeroWidthBar=function(t,e,n){function i(){var r=t.getBoundingClientRect();("vert"==n?document.elementFromPoint(r.right-1,(r.top+r.bottom)/2):document.elementFromPoint((r.right+r.left)/2,r.bottom-1))!=t?t.style.pointerEvents="none":e.set(1e3,i)}t.style.pointerEvents="auto",e.set(1e3,i)},xa.prototype.clear=function(){var t=this.horiz.parentNode;t.removeChild(this.horiz),t.removeChild(this.vert)};var wa=function(){};wa.prototype.update=function(){return{bottom:0,right:0}},wa.prototype.setScrollLeft=function(){},wa.prototype.setScrollTop=function(){},wa.prototype.clear=function(){};var Ca={native:xa,null:wa},ka=0,Sa=function(t,e,n){var i=t.display;this.viewport=e,this.visible=Rn(i,t.doc,e),this.editorIsHidden=!i.wrapper.offsetWidth,this.wrapperHeight=i.wrapper.clientHeight,this.wrapperWidth=i.wrapper.clientWidth,this.oldDisplayWidth=Ve(t),this.force=n,this.dims=wn(t),this.events=[]};Sa.prototype.signal=function(t,e){At(t,e)&&this.events.push(arguments)},Sa.prototype.finish=function(){for(var t=this,e=0;e=0&&F(t,r.to())<=0)return i}return-1};var Pa=function(t,e){this.anchor=t,this.head=e};Pa.prototype.from=function(){return V(this.anchor,this.head)},Pa.prototype.to=function(){return R(this.anchor,this.head)},Pa.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},Hr.prototype={chunkSize:function(){return this.lines.length},removeInner:function(t,e){for(var n=this,i=t,r=t+e;i1||!(this.children[0]instanceof Hr))){var l=[];this.collapse(l),this.children=[new Hr(l)],this.children[0].parent=this}},collapse:function(t){for(var e=this,n=0;n50){for(var a=o.lines.length%25+25,l=a;l10);t.parent.maybeSpill()}},iterN:function(t,e,n){for(var i=this,r=0;re.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=h,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&mi(e,r,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&kr(e.doc)),e&&xe(e,"markerCleared",e,this,r,o),n&&si(e),this.parent&&this.parent.clear()}},La.prototype.find=function(t,e){var n=this;null==t&&"bookmark"==this.type&&(t=1);for(var i,r,o=0;o=0;c--)Or(i,r[c]);l?br(this,l):this.cm&&Kn(this.cm)}),undo:vi(function(){Nr(this,"undo")}),redo:vi(function(){Nr(this,"redo")}),undoSelection:vi(function(){Nr(this,"undo",!0)}),redoSelection:vi(function(){Nr(this,"redo",!0)}),setExtending:function(t){this.extend=t},getExtending:function(){return this.extend},historySize:function(){for(var t=this.history,e=0,n=0,i=0;i=t.ch)&&e.push(r.marker.parent||r.marker)}return e},findMarks:function(t,e,n){t=j(this,t),e=j(this,e);var i=[],r=t.line;return this.iter(t.line,e.line+1,function(o){var s=o.markedSpans;if(s)for(var a=0;a=l.to||null==l.from&&r!=t.line||null!=l.from&&r==e.line&&l.from>=e.ch||n&&!n(l.marker)||i.push(l.marker.parent||l.marker)}++r}),i},getAllMarks:function(){var t=[];return this.iter(function(e){var n=e.markedSpans;if(n)for(var i=0;it)return e=t,!0;t-=o,++n}),j(this,_(n,e))},indexFromPos:function(t){t=j(this,t);var e=t.ch;if(t.linee&&(e=t.from),null!=t.to&&t.to0)r=new _(r.line,r.ch+1),t.replaceRange(o.charAt(r.ch-1)+o.charAt(r.ch-2),_(r.line,r.ch-2),r,"+transpose");else if(r.line>t.doc.first){var s=M(t.doc,r.line-1).text;s&&(r=new _(r.line,1),t.replaceRange(o.charAt(0)+t.doc.lineSeparator()+s.charAt(s.length-1),_(r.line-1,s.length-1),r,"+transpose"))}n.push(new Pa(r,r))}t.setSelections(n)})},newlineAndIndent:function(t){return fi(t,function(){for(var e=t.listSelections(),n=e.length-1;n>=0;n--)t.replaceRange(t.doc.lineSeparator(),e[n].anchor,e[n].head,"+input");e=t.listSelections();for(var i=0;it&&0==F(e,this.pos)&&n==this.button};var qa,Ka,Ga={toString:function(){return"CodeMirror.Init"}},Ya={},Xa={};qo.defaults=Ya,qo.optionHandlers=Xa;var Ja=[];qo.defineInitHook=function(t){return Ja.push(t)};var Za=null,Qa=function(t){this.cm=t,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new $s,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Qa.prototype.init=function(t){function e(t){if(!Mt(r,t)){if(r.somethingSelected())Yo({lineWise:!1,text:r.getSelections()}),"cut"==t.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var e=Qo(r);Yo({lineWise:!0,text:e.text}),"cut"==t.type&&r.operation(function(){r.setSelections(e.ranges,0,Bs),r.replaceSelection("",null,"cut")})}if(t.clipboardData){t.clipboardData.clearData();var n=Za.text.join("\n");if(t.clipboardData.setData("Text",n),t.clipboardData.getData("Text")==n)return void t.preventDefault()}var s=es(),a=s.firstChild;r.display.lineSpace.insertBefore(s,r.display.lineSpace.firstChild),a.value=Za.text.join("\n");var l=document.activeElement;zs(a),setTimeout(function(){r.display.lineSpace.removeChild(s),l.focus(),l==o&&i.showPrimarySelection()},50)}}var n=this,i=this,r=i.cm,o=i.div=t.lineDiv;ts(o,r.options.spellcheck),ta(o,"paste",function(t){Mt(r,t)||Jo(t,r)||ys<=11&&setTimeout(pi(r,function(){return n.updateFromDOM()}),20)}),ta(o,"compositionstart",function(t){n.composing={data:t.data,done:!1}}),ta(o,"compositionupdate",function(t){n.composing||(n.composing={data:t.data,done:!1})}),ta(o,"compositionend",function(t){n.composing&&(t.data!=n.composing.data&&n.readFromDOMSoon(),n.composing.done=!0)}),ta(o,"touchstart",function(){return i.forceCompositionEnd()}),ta(o,"input",function(){n.composing||n.readFromDOMSoon()}),ta(o,"copy",e),ta(o,"cut",e)},Qa.prototype.prepareSelection=function(){var t=Pn(this.cm,!1);return t.focus=this.cm.state.focused,t},Qa.prototype.showSelection=function(t,e){t&&this.cm.display.view.length&&((t.focus||e)&&this.showPrimarySelection(),this.showMultipleSelections(t))},Qa.prototype.showPrimarySelection=function(){var t=window.getSelection(),e=this.cm,n=e.doc.sel.primary(),i=n.from(),r=n.to();if(e.display.viewTo==e.display.viewFrom||i.line>=e.display.viewTo||r.line=e.display.viewFrom&&rs(e,i)||{node:a[0].measure.map[2],offset:0},c=r.linet.firstLine()&&(i=_(i.line-1,M(t.doc,i.line-1).length)),r.ch==M(t.doc,r.line).text.length&&r.linee.viewTo-1)return!1;var o,s,a;i.line==e.viewFrom||0==(o=En(t,i.line))?(s=L(e.view[0].line),a=e.view[0].node):(s=L(e.view[o].line),a=e.view[o-1].node.nextSibling);var l,c,u=En(t,r.line);if(u==e.view.length-1?(l=e.viewTo-1,c=e.lineDiv.lastChild):(l=L(e.view[u+1].line)-1,c=e.view[u+1].node.previousSibling),!a)return!1;for(var h=t.doc.splitLines(as(t,a,c,s,l)),d=P(t.doc,_(s,0),_(l,M(t.doc,l).text.length));h.length>1&&d.length>1;)if(g(h)==g(d))h.pop(),d.pop(),l--;else{if(h[0]!=d[0])break;h.shift(),d.shift(),s++}for(var f=0,p=0,v=h[0],m=d[0],y=Math.min(v.length,m.length);fi.ch&&b.charCodeAt(b.length-p-1)==x.charCodeAt(x.length-p-1);)f--,p++;h[h.length-1]=b.slice(0,b.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(f).replace(/\u200b+$/,"");var C=_(s,f),k=_(l,d.length?g(d).length-p:0);return h.length>1||h[0]||F(C,k)?(Fr(t.doc,h,C,k,"+input"),!0):void 0},Qa.prototype.ensurePolled=function(){this.forceCompositionEnd()},Qa.prototype.reset=function(){this.forceCompositionEnd()},Qa.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Qa.prototype.readFromDOMSoon=function(){var t=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(t.readDOMTimeout=null,t.composing){if(!t.composing.done)return;t.composing=null}t.updateFromDOM()},80))},Qa.prototype.updateFromDOM=function(){var t=this;!this.cm.isReadOnly()&&this.pollContent()||fi(this.cm,function(){return mi(t.cm)})},Qa.prototype.setUneditable=function(t){t.contentEditable="false"},Qa.prototype.onKeyPress=function(t){0!=t.charCode&&(t.preventDefault(),this.cm.isReadOnly()||pi(this.cm,Xo)(this.cm,String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),0))},Qa.prototype.readOnlyChanged=function(t){this.div.contentEditable=String("nocursor"!=t)},Qa.prototype.onContextMenu=function(){},Qa.prototype.resetPosition=function(){},Qa.prototype.needsContentAttribute=!0;var tl=function(t){this.cm=t,this.prevInput="",this.pollingFast=!1,this.polling=new $s,this.hasSelection=!1,this.composing=null};tl.prototype.init=function(t){function e(t){if(!Mt(r,t)){if(r.somethingSelected())Yo({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var e=Qo(r);Yo({lineWise:!0,text:e.text}),"cut"==t.type?r.setSelections(e.ranges,null,Bs):(i.prevInput="",s.value=e.text.join("\n"),zs(s))}"cut"==t.type&&(r.state.cutIncoming=!0)}}var n=this,i=this,r=this.cm,o=this.wrapper=es(),s=this.textarea=o.firstChild;t.wrapper.insertBefore(o,t.wrapper.firstChild),Es&&(s.style.width="0px"),ta(s,"input",function(){ms&&ys>=9&&n.hasSelection&&(n.hasSelection=null),i.poll()}),ta(s,"paste",function(t){Mt(r,t)||Jo(t,r)||(r.state.pasteIncoming=!0,i.fastPoll())}),ta(s,"cut",e),ta(s,"copy",e),ta(t.scroller,"paste",function(e){_e(t,e)||Mt(r,e)||(r.state.pasteIncoming=!0,i.focus())}),ta(t.lineSpace,"selectstart",function(e){_e(t,e)||Lt(e)}),ta(s,"compositionstart",function(){var t=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:t,range:r.markText(t,r.getCursor("to"),{className:"CodeMirror-composing"})}}),ta(s,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},tl.prototype.prepareSelection=function(){var t=this.cm,e=t.display,n=t.doc,i=Pn(t);if(t.options.moveInputWithCursor){var r=cn(t,n.sel.primary().head,"div"),o=e.wrapper.getBoundingClientRect(),s=e.lineDiv.getBoundingClientRect();i.teTop=Math.max(0,Math.min(e.wrapper.clientHeight-10,r.top+s.top-o.top)),i.teLeft=Math.max(0,Math.min(e.wrapper.clientWidth-10,r.left+s.left-o.left))}return i},tl.prototype.showSelection=function(t){var e=this.cm,i=e.display;n(i.cursorDiv,t.cursors),n(i.selectionDiv,t.selection),null!=t.teTop&&(this.wrapper.style.top=t.teTop+"px",this.wrapper.style.left=t.teLeft+"px")},tl.prototype.reset=function(t){if(!this.contextMenuPending&&!this.composing){var e=this.cm;if(e.somethingSelected()){this.prevInput="";var n=e.getSelection();this.textarea.value=n,e.state.focused&&zs(this.textarea),ms&&ys>=9&&(this.hasSelection=n)}else t||(this.prevInput=this.textarea.value="",ms&&ys>=9&&(this.hasSelection=null))}},tl.prototype.getField=function(){return this.textarea},tl.prototype.supportsTouch=function(){return!1},tl.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!Ps||s()!=this.textarea))try{this.textarea.focus()}catch(t){}},tl.prototype.blur=function(){this.textarea.blur()},tl.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},tl.prototype.receivedFocus=function(){this.slowPoll()},tl.prototype.slowPoll=function(){var t=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){t.poll(),t.cm.state.focused&&t.slowPoll()})},tl.prototype.fastPoll=function(){function t(){n.poll()||e?(n.pollingFast=!1,n.slowPoll()):(e=!0,n.polling.set(60,t))}var e=!1,n=this;n.pollingFast=!0,n.polling.set(20,t)},tl.prototype.poll=function(){var t=this,e=this.cm,n=this.textarea,i=this.prevInput;if(this.contextMenuPending||!e.state.focused||ia(n)&&!i&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var r=n.value;if(r==i&&!e.somethingSelected())return!1;if(ms&&ys>=9&&this.hasSelection===r||As&&/[\uf700-\uf7ff]/.test(r))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var o=r.charCodeAt(0);if(8203!=o||i||(i="​"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var s=0,a=Math.min(i.length,r.length);s1e3||r.indexOf("\n")>-1?n.value=t.prevInput="":t.prevInput=r,t.composing&&(t.composing.range.clear(),t.composing.range=e.markText(t.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},tl.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},tl.prototype.onKeyPress=function(){ms&&ys>=9&&(this.hasSelection=null),this.fastPoll()},tl.prototype.onContextMenu=function(t){function e(){if(null!=s.selectionStart){var t=r.somethingSelected(),e="​"+(t?s.value:"");s.value="⇚",s.value=e,i.prevInput=t?"":"​",s.selectionStart=1,s.selectionEnd=e.length,o.selForContextMenu=r.doc.sel}}function n(){if(i.contextMenuPending=!1,i.wrapper.style.cssText=u,s.style.cssText=c,ms&&ys<9&&o.scrollbars.setScrollTop(o.scroller.scrollTop=l),null!=s.selectionStart){(!ms||ms&&ys<9)&&e();var t=0,n=function(){o.selForContextMenu==r.doc.sel&&0==s.selectionStart&&s.selectionEnd>0&&"​"==i.prevInput?pi(r,Pr)(r):t++<10?o.detectingSelectAll=setTimeout(n,500):(o.selForContextMenu=null,o.input.reset())};o.detectingSelectAll=setTimeout(n,200)}}var i=this,r=i.cm,o=r.display,s=i.textarea,a=Tn(r,t),l=o.scroller.scrollTop;if(a&&!Cs){r.options.resetSelectionOnContextMenu&&-1==r.doc.sel.contains(a)&&pi(r,xr)(r.doc,Vi(a),Bs);var c=s.style.cssText,u=i.wrapper.style.cssText;i.wrapper.style.cssText="position: absolute";var h=i.wrapper.getBoundingClientRect();s.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(t.clientY-h.top-5)+"px; left: "+(t.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(ms?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var d;if(bs&&(d=window.scrollY),o.input.focus(),bs&&window.scrollTo(null,d),o.input.reset(),r.somethingSelected()||(s.value=i.prevInput=" "),i.contextMenuPending=!0,o.selForContextMenu=r.doc.sel,clearTimeout(o.detectingSelectAll),ms&&ys>=9&&e(),_s){It(t);var f=function(){Tt(window,"mouseup",f),setTimeout(n,20)};ta(window,"mouseup",f)}else setTimeout(n,50)}},tl.prototype.readOnlyChanged=function(t){t||this.reset(),this.textarea.disabled="nocursor"==t},tl.prototype.setUneditable=function(){},tl.prototype.needsContentAttribute=!1,function(t){function e(e,i,r,o){t.defaults[e]=i,r&&(n[e]=o?function(t,e,n){n!=Ga&&r(t,e,n)}:r)}var n=t.optionHandlers;t.defineOption=e,t.Init=Ga,e("value","",function(t,e){return t.setValue(e)},!0),e("mode",null,function(t,e){t.doc.modeOption=e,qi(t)},!0),e("indentUnit",2,qi,!0),e("indentWithTabs",!1),e("smartIndent",!0),e("tabSize",4,function(t){Ki(t),en(t),mi(t)},!0),e("lineSeparator",null,function(t,e){if(t.doc.lineSep=e,e){var n=[],i=t.doc.first;t.doc.iter(function(t){for(var r=0;;){var o=t.text.indexOf(e,r);if(-1==o)break;r=o+e.length,n.push(_(i,o))}i++});for(var r=n.length-1;r>=0;r--)Fr(t.doc,e,n[r],_(n[r].line,n[r].ch+e.length))}}),e("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,e,n){t.state.specialChars=new RegExp(e.source+(e.test("\t")?"":"|\t"),"g"),n!=Ga&&t.refresh()}),e("specialCharPlaceholder",ce,function(t){return t.refresh()},!0),e("electricChars",!0),e("inputStyle",Ps?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),e("spellcheck",!1,function(t,e){return t.getInputField().spellcheck=e},!0),e("rtlMoveVisually",!Ls),e("wholeLineUpdateBefore",!0),e("theme","default",function(t){jo(t),Bo(t)},!0),e("keyMap","default",function(t,e,n){var i=uo(e),r=n!=Ga&&uo(n);r&&r.detach&&r.detach(t,i),i.attach&&i.attach(t,r||null)}),e("extraKeys",null),e("configureMouse",null),e("lineWrapping",!1,Uo,!0),e("gutters",[],function(t){_i(t.options),Bo(t)},!0),e("fixedGutter",!0,function(t,e){t.display.gutters.style.left=e?Cn(t.display)+"px":"0",t.refresh()},!0),e("coverGutterNextToScrollbar",!1,function(t){return ni(t)},!0),e("scrollbarStyle","native",function(t){ri(t),ni(t),t.display.scrollbars.setScrollTop(t.doc.scrollTop),t.display.scrollbars.setScrollLeft(t.doc.scrollLeft)},!0),e("lineNumbers",!1,function(t){_i(t.options),Bo(t)},!0),e("firstLineNumber",1,Bo,!0),e("lineNumberFormatter",function(t){return t},Bo,!0),e("showCursorWhenSelecting",!1,Mn,!0),e("resetSelectionOnContextMenu",!0),e("lineWiseCopyCut",!0),e("pasteLinesPerSelection",!0),e("readOnly",!1,function(t,e){"nocursor"==e&&(Fn(t),t.display.input.blur()),t.display.input.readOnlyChanged(e)}),e("disableInput",!1,function(t,e){e||t.display.input.reset()},!0),e("dragDrop",!0,Wo),e("allowDropFileTypes",null),e("cursorBlinkRate",530),e("cursorScrollMargin",0),e("cursorHeight",1,Mn,!0),e("singleCursorHeightPerLine",!0,Mn,!0),e("workTime",100),e("workDelay",100),e("flattenSpans",!0,Ki,!0),e("addModeClass",!1,Ki,!0),e("pollInterval",100),e("undoDepth",200,function(t,e){return t.doc.history.undoDepth=e}),e("historyEventDelay",1250),e("viewportMargin",10,function(t){return t.refresh()},!0),e("maxHighlightLength",1e4,Ki,!0),e("moveInputWithCursor",!0,function(t,e){e||t.display.input.resetPosition()}),e("tabindex",null,function(t,e){return t.display.input.getField().tabIndex=e||""}),e("autofocus",null),e("direction","ltr",function(t,e){return t.doc.setDirection(e)},!0)}(qo),function(t){var e=t.optionHandlers,n=t.helpers={};t.prototype={constructor:t,focus:function(){window.focus(),this.display.input.focus()},setOption:function(t,n){var i=this.options,r=i[t];i[t]==n&&"mode"!=t||(i[t]=n,e.hasOwnProperty(t)&&pi(this,e[t])(this,n,r),Et(this,"optionChange",this,t))},getOption:function(t){return this.options[t]},getDoc:function(){return this.doc},addKeyMap:function(t,e){this.state.keyMaps[e?"push":"unshift"](uo(t))},removeKeyMap:function(t){for(var e=this.state.keyMaps,n=0;ni&&(Go(e,o.head.line,t,!0),i=o.head.line,r==e.doc.sel.primIndex&&Kn(e));else{var s=o.from(),a=o.to(),l=Math.max(i,s.line);i=Math.min(e.lastLine(),a.line-(a.ch?0:1))+1;for(var c=l;c0&&vr(e.doc,r,new Pa(s,u[r].to()),Bs)}}}),getTokenAt:function(t,e){return te(this,t,e)},getLineTokens:function(t,e){return te(this,_(t),e,!0)},getTokenTypeAt:function(t){t=j(this.doc,t);var e,n=Yt(this,M(this.doc,t.line)),i=0,r=(n.length-1)/2,o=t.ch;if(0==o)e=n[2];else for(;;){var s=i+r>>1;if((s?n[2*s-1]:0)>=o)r=s;else{if(!(n[2*s+1]o&&(t=o,r=!0),i=M(this.doc,t)}else i=t;return sn(this,i,{top:0,left:0},e||"page",n||r).top+(r?this.doc.height-yt(i):0)},defaultTextHeight:function(){return bn(this.display)},defaultCharWidth:function(){return xn(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(t,e,n,i,r){var o=this.display;t=cn(this,j(this.doc,t));var s=t.bottom,a=t.left;if(e.style.position="absolute",e.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(e),o.sizer.appendChild(e),"over"==i)s=t.top;else if("above"==i||"near"==i){var l=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==i||t.bottom+e.offsetHeight>l)&&t.top>e.offsetHeight?s=t.top-e.offsetHeight:t.bottom+e.offsetHeight<=l&&(s=t.bottom),a+e.offsetWidth>c&&(a=c-e.offsetWidth)}e.style.top=s+"px",e.style.left=e.style.right="","right"==r?(a=o.sizer.clientWidth-e.offsetWidth,e.style.right="0px"):("left"==r?a=0:"middle"==r&&(a=(o.sizer.clientWidth-e.offsetWidth)/2),e.style.left=a+"px"),n&&Wn(this,{left:a,top:s,right:a+e.offsetWidth,bottom:s+e.offsetHeight})},triggerOnKeyDown:gi(To),triggerOnKeyPress:gi(Po),triggerOnKeyUp:Mo,triggerOnMouseDown:gi(Oo),execCommand:function(t){if(ja.hasOwnProperty(t))return ja[t].call(null,this)},triggerElectric:gi(function(t){Zo(this,t)}),findPosH:function(t,e,n,i){var r=this,o=1;e<0&&(o=-1,e=-e);for(var s=j(this.doc,t),a=0;a0&&a(n.charAt(i-1));)--i;for(;r.5)&&Sn(this),Et(this,"refresh",this)}),swapDoc:gi(function(t){var e=this.doc;return e.cm=null,Ji(this,t),en(this),this.display.input.reset(),Gn(this,t.scrollLeft,t.scrollTop),this.curOp.forceScroll=!0,xe(this,"swapDoc",this,e),e}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Ot(t),t.registerHelper=function(e,i,r){n.hasOwnProperty(e)||(n[e]=t[e]={_global:[]}),n[e][i]=r},t.registerGlobalHelper=function(e,i,r,o){t.registerHelper(e,i,o),n[e]._global.push({pred:r,val:o})}}(qo);var el="iter insert remove copy getEditor constructor".split(" ");for(var nl in Ia.prototype)Ia.prototype.hasOwnProperty(nl)&&d(el,nl)<0&&(qo.prototype[nl]=function(t){return function(){return t.apply(this.doc,arguments)}}(Ia.prototype[nl]));return Ot(Ia),qo.inputStyles={textarea:tl,contenteditable:Qa},qo.defineMode=function(t){qo.defaults.mode||"null"==t||(qo.defaults.mode=t),Vt.apply(this,arguments)},qo.defineMIME=Ht,qo.defineMode("null",function(){return{token:function(t){return t.skipToEnd()}}}),qo.defineMIME("text/plain","null"),qo.defineExtension=function(t,e){qo.prototype[t]=e},qo.defineDocExtension=function(t,e){Ia.prototype[t]=e},qo.fromTextArea=us,function(t){t.off=Tt,t.on=ta,t.wheelEventPixels=zi,t.Doc=Ia,t.splitLines=na,t.countColumn=h,t.findColumn=f,t.isWordChar=x,t.Pass=js,t.signal=Et,t.Line=fa,t.changeEnd=Hi,t.scrollbarModel=Ca,t.Pos=_,t.cmpPos=F,t.modes=sa,t.mimeModes=aa,t.resolveMode=jt,t.getMode=Bt,t.modeExtensions=la,t.extendMode=Wt,t.copyState=Ut,t.startState=Kt,t.innerMode=qt,t.commands=ja,t.keyMap=Ha,t.keyName=co,t.isModifierKey=ao,t.lookupKey=so,t.normalizeKeyMap=oo,t.StringStream=ca,t.SharedTextMarker=Na,t.TextMarker=La,t.LineWidget=Aa,t.e_preventDefault=Lt,t.e_stopPropagation=Nt,t.e_stop=It,t.addClass=a,t.contains=o,t.rmClass=Fs,t.keyNames=za}(qo),qo.version="5.31.0",qo})},function(t,e,n){"use strict";var i=n(0),r=i.Model.extend({idAttribute:"name",defaults:{name:"",label:"",type:1,active:!0,private:!1,protected:!1},initialize:function(){var t=this.get("name"),e=this.get("label");t?e||this.set("label",t):this.set("name",e),this.set("name",r.escapeName(this.get("name")))},getFullName:function(){var t="";switch(this.get("type")){case 1:t=".";break;case 2:t="#"}return t+this.get("name")}},{TYPE_CLASS:1,TYPE_ID:2,escapeName:function(t){return(""+t).trim().replace(/([^a-z0-9\w-]+)/gi,"-")}});t.exports=r},function(t,e,n){"use strict";var i=(n(1),n(0)),r=i.$;t.exports=i.View.extend({events:{change:"onChange"},attributes:function(){return this.model.get("attributes")},initialize:function(t){var e=this.model,n=(e.get("name"),e.target);this.config=t.config||{},this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.target=n,this.className=this.pfx+"trait",this.labelClass=this.ppfx+"label",this.fieldClass=this.ppfx+"field "+this.ppfx+"field-"+e.get("type"),this.inputhClass=this.ppfx+"input-holder",e.off("change:value",this.onValueChange),this.listenTo(e,"change:value",this.onValueChange),this.tmpl='
'},onChange:function(){this.model.set("value",this.getInputEl().value)},getValueForTarget:function(){return this.model.get("value")},setInputValue:function(t){this.getInputEl().value=t},onValueChange:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.model;this.target,i.get("name");if(n.fromTarget)this.setInputValue(i.get("value"));else{var r=this.getValueForTarget();i.setTargetValue(r)}},renderLabel:function(){this.$el.html('
'+this.getLabel()+"
")},getLabel:function(){var t=this.model,e=t.get("label")||t.get("name");return e.charAt(0).toUpperCase()+e.slice(1).replace(/-/g," ")},getInputEl:function(){if(!this.$input){var t=this.model,e=this.target,n=t.get("name"),i=t.get("placeholder")||t.get("default")||"",o=t.get("type")||"text",s=e.get("attributes"),a=t.get("min"),l=t.get("max"),c=t.get("changeProp")?e.get(n):t.get("value")||s[n],u=r('');c&&u.prop("value",c),a&&u.prop("min",a),l&&u.prop("max",l),this.$input=u}return this.$input.get(0)},getModelValue:function(){var t,e=this.model,n=this.target,i=e.get("name");if(e.get("changeProp"))t=n.get(i);else{var r=n.get("attributes");t=e.get("value")||r[i]}return t},renderField:function(){if(!this.$input){this.$el.append(this.tmpl);var t=this.getInputEl(),e=this.el.querySelector("."+this.inputhClass);e.insertBefore(t,e.childNodes[0])}},render:function(){return this.renderLabel(),this.renderField(),this.el.className=this.className,this}})},function(t,e,n){"use strict";var i,r;!function(o,s){i=s,void 0!==(r="function"==typeof i?i.call(e,n,e,t):i)&&(t.exports=r)}(0,function(){function t(t,e){return e=e||M,z.test(t)?e.getElementsByClassName(t.slice(1)):R.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t)}function e(t){if(!E){E=M.implementation.createHTMLDocument();var e=E.createElement("base");e.href=M.location.href,E.head.appendChild(e)}return E.body.innerHTML=t,E.body.childNodes}function n(t){"loading"!==M.readyState?t():M.addEventListener("DOMContentLoaded",t)}function i(i,r){if(!i)return this;if(i.cash&&i!==P)return i;var o,s=i,a=0;if(_(i))s=F.test(i)?M.getElementById(i.slice(1)):$.test(i)?e(i):t(i,r);else if(I(i))return n(i),this;if(!s)return this;if(s.nodeType||s===P)this[0]=s,this.length=1;else for(o=this.length=s.length;a=0&&s.splice(i,1)):(o(s,function(n){t.removeEventListener(e,n)}),s=[]))}function x(t,e){return"&"+encodeURIComponent(t)+"="+encodeURIComponent(e).replace(/%20/g,"+")}function w(t){var e=[];return o(t.options,function(t){t.selected&&e.push(t.value)}),e.length?e:null}function C(t){var e=t.selectedIndex;return e>=0?t.options[e].value:null}function k(t){var e=t.type;if(!e)return null;switch(e.toLowerCase()){case"select-one":return C(t);case"select-multiple":return w(t);case"radio":case"checkbox":return t.checked?t.value:null;default:return t.value?t.value:null}}function S(t,e,n){if(n){var i=t.childNodes[0];t.insertBefore(e,i)}else t.appendChild(e)}function T(t,e,n){var i=_(e);if(!i&&e.length)return void o(e,function(e){return T(t,e,n)});o(t,i?function(t){return t.insertAdjacentHTML(n?"afterbegin":"beforeend",e)}:function(t,i){return S(t,0===i?e:e.cloneNode(!0),n)})}var E,M=document,P=window,A=Array.prototype,O=A.slice,L=A.filter,N=A.push,D=function(){},I=function(t){return typeof t==typeof D&&t.call},_=function(t){return"string"==typeof t},F=/^#[\w-]*$/,z=/^\.[\w-]*$/,$=/<.+>/,R=/^\w+$/,V=r.fn=r.prototype=i.prototype={cash:!0,length:0,push:N,splice:A.splice,map:A.map,init:i};Object.defineProperty(V,"constructor",{value:r}),r.parseHTML=e,r.noop=D,r.isFunction=I,r.isString=_,r.extend=V.extend=function(t){t=t||{};var e=O.call(arguments),n=e.length,i=1;for(1===e.length&&(t=this,i=0);i1?this.each(function(n){return n.style[t]=e}):P.getComputedStyle(this[0])[t];for(var n in t)this.css(n,t[n]);return this}}),o(["Width","Height"],function(t){var e=t.toLowerCase();V[e]=function(){return this[0].getBoundingClientRect()[e]},V["inner"+t]=function(){return this[0]["client"+t]},V["outer"+t]=function(e){return this[0]["offset"+t]+(e?m(this,"margin"+("Width"===t?"Left":"Top"))+m(this,"margin"+("Width"===t?"Right":"Bottom")):0)}}),V.extend({off:function(t,e){return this.each(function(n){return b(n,t,e)})},on:function(t,e,i,r){var o;if(!_(t)){for(var a in t)this.on(a,e,t[a]);return this}return I(e)&&(i=e,e=null),"ready"===t?(n(i),this):(e&&(o=i,i=function(t){for(var n=t.target;!s(n,e);){if(n===this)return n=!1;n=n.parentNode}n&&o.call(n,t)}),this.each(function(e){var n=i;r&&(n=function(){i.apply(this,arguments),b(e,t,n)}),y(e,t,n)}))},one:function(t,e,n){return this.on(t,e,n,!0)},ready:n,trigger:function(t,e){var n=M.createEvent("HTMLEvents");return n.data=e,n.initEvent(t,!0,!1),this.each(function(t){return t.dispatchEvent(n)})}}),V.extend({serialize:function(){var t="";return o(this[0].elements||this,function(e){if(!e.disabled&&"FIELDSET"!==e.tagName){var n=e.name;switch(e.type.toLowerCase()){case"file":case"reset":case"submit":case"button":break;case"select-multiple":var i=k(e);null!==i&&o(i,function(e){t+=x(n,e)});break;default:var r=k(e);null!==r&&(t+=x(n,r))}}}),t.substr(1)},val:function(t){return void 0===t?k(this[0]):this.each(function(e){return e.value=t})}}),V.extend({after:function(t){return r(t).insertAfter(this),this},append:function(t){return T(this,t),this},appendTo:function(t){return T(r(t),this),this},before:function(t){return r(t).insertBefore(this),this},clone:function(){return r(this.map(function(t){return t.cloneNode(!0)}))},empty:function(){return this.html(""),this},html:function(t){if(void 0===t)return this[0].innerHTML;var e=t.nodeType?t[0].outerHTML:t;return this.each(function(t){return t.innerHTML=e})},insertAfter:function(t){var e=this;return r(t).each(function(t,n){var i=t.parentNode,r=t.nextSibling;e.each(function(t){i.insertBefore(0===n?t:t.cloneNode(!0),r)})}),this},insertBefore:function(t){var e=this;return r(t).each(function(t,n){var i=t.parentNode;e.each(function(e){i.insertBefore(0===n?e:e.cloneNode(!0),t)})}),this},prepend:function(t){return T(this,t,!0),this},prependTo:function(t){return T(r(t),this,!0),this},remove:function(){return this.each(function(t){return t.parentNode.removeChild(t)})},text:function(t){return void 0===t?this[0].textContent:this.each(function(e){return e.textContent=t})}});var U=M.documentElement;return V.extend({position:function(){var t=this[0];return{left:t.offsetLeft,top:t.offsetTop}},offset:function(){var t=this[0].getBoundingClientRect();return{top:t.top+P.pageYOffset-U.clientTop,left:t.left+P.pageXOffset-U.clientLeft}},offsetParent:function(){return r(this[0].offsetParent)}}),V.extend({children:function(t){var e=[];return this.each(function(t){N.apply(e,t.children)}),e=l(e),t?e.filter(function(e){return s(e,t)}):e},closest:function(t){return!t||this.length<1?r():this.is(t)?this.filter(t):this.parent().closest(t)},is:function(t){if(!t)return!1;var e=!1,n=a(t);return this.each(function(i){return!(e=n(i,t))}),e},find:function(e){if(!e||e.nodeType)return r(e&&this.has(e).length?e:null);var n=[];return this.each(function(i){N.apply(n,t(e,i))}),l(n)},has:function(e){var n=_(e)?function(n){return 0!==t(e,n).length}:function(t){return t.contains(e)};return this.filter(n)},next:function(){return r(this[0].nextElementSibling)},not:function(t){if(!t)return this;var e=a(t);return this.filter(function(n){return!e(n,t)})},parent:function(){var t=[];return this.each(function(e){e&&e.parentNode&&t.push(e.parentNode)}),l(t)},parents:function(t){var e,n=[];return this.each(function(i){for(e=i;e&&e.parentNode&&e!==M.body.parentNode;)e=e.parentNode,(!t||t&&s(e,t))&&n.push(e)}),l(n)},prev:function(){return r(this[0].previousElementSibling)},siblings:function(){var t=this.parent().children(),e=this[0];return t.filter(function(t){return t!==e})}}),r})},function(t,e,n){"use strict";var i=n(1),r=n(7);t.exports=n(0).Collection.extend({model:r,getStyleable:function(){return(0,i.filter)(this.models,function(t){return t.get("active")&&!t.get("private")})},getValid:function(){return(0,i.filter)(this.models,function(t){return!t.get("private")})},getFullString:function(t){var e=[];return(t||this).forEach(function(t){return e.push(t.getFullName())}),e.join("").trim()}})},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.parseValue(t);this.set(r,i({},n,{avoidStore:1})),e&&(this.set("value","",n),this.set(r,n))},setValueFromInput:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.setValue(t,e,i({},n,{fromInput:1}))},parseValue:function(t){var e={value:t};if(!this.get("functionName"))return e;var n=[],i=""+t,r=i.indexOf("(")+1,o=i.lastIndexOf(")");return n.push(r),o>=0&&n.push(o),e.value=String.prototype.substring.apply(i,n),e},getDefaultValue:function(){return this.get("defaults")},getFullValue:function(t){var e=this.get("functionName"),n=t||this.get("value");return e&&(n=e+"("+n+")"),n}})},function(t,e,n){"use strict";(function(e){n(5),n(14),n(36),n(37),n(38),n(40),n(17),n(34);t.exports=e.View.extend({initialize:function(t){this.config=t.config||{},this.pfx=this.config.stylePrefix||"",this.target=t.target||{},this.propTarget=t.propTarget||{},this.onChange=t.onChange,this.onInputRender=t.onInputRender||{},this.customValue=t.customValue||{};var e=this.collection;this.listenTo(e,"add",this.addTo),this.listenTo(e,"reset",this.render)},addTo:function(t){this.add(t)},add:function(t,e){var n=new t.typeView({model:t,name:t.get("name"),id:this.pfx+t.get("property"),target:this.target,propTarget:this.propTarget,onChange:this.onChange,onInputRender:this.onInputRender,config:this.config});"composite"!=t.get("type")&&(n.customValue=this.customValue),n.render();var i=n.el;e?e.appendChild(i):this.el.appendChild(i)},render:function(){var t=this,e=document.createDocumentFragment();return this.collection.each(function(n){return t.add(n,e)}),this.$el.append(e),this.$el.attr("class",this.pfx+"properties"),this}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=(n(18),e.$);t.exports=n(5).extend({templateInput:function(){return""},init:function(){var t=this.model;this.listenTo(t,"change:unit",this.modelValueChanged),this.listenTo(t,"el:change",this.elementUpdated)},setValue:function(t){this.inputInst.setValue(t,{silent:1})},onRender:function(){var t=this.ppfx;if(!this.input){var e=this.model.input;e.ppfx=t,e.render();this.el.querySelector("."+t+"fields").appendChild(e.el),this.$input=e.inputEl,this.unit=e.unitEl,this.$unit=i(this.unit),this.input=this.$input.get(0),this.inputInst=e}}})}).call(e,n(0))},function(t,e,n){"use strict";var i=(n(0),n(3));t.exports=i.extend({tagName:"img",events:{dblclick:"openModal",click:"initResize"},initialize:function(t){var e=this.model;i.prototype.initialize.apply(this,arguments),this.listenTo(e,"change:src",this.updateSrc),this.listenTo(e,"dblclick active",this.openModal),this.classEmpty=this.ppfx+"plh-image";var n=this.config;n.modal&&(this.modal=n.modal),n.am&&(this.am=n.am),this.fetchFile()},fetchFile:function(){var t=this.model,e=t.get("file");if(e){this.em.get("AssetManager").FileUploader().uploadFile({dataTransfer:{files:[e]}},function(e){var n=e&&e.data&&e.data[0],i=n&&n.src;i&&t.set({src:i})}),t.set("file","")}},updateSrc:function(){var t=this.model.get("src"),e=this.$el;e.attr("src",t),e[t?"removeClass":"addClass"](this.classEmpty)},openModal:function(t){var e=this.opts.config.em,n=e?e.get("Editor"):"";n&&this.model.get("editable")&&n.runCommand("open-assets",{target:this.model,onSelect:function(){n.Modal.close(),n.AssetManager.setTarget(null)}})},render:function(){this.updateAttributes(),this.updateClasses();var t=this.$el.attr("class")||"";return this.model.get("src")||this.$el.attr("class",(t+" "+this.classEmpty).trim()),this.$el.attr("onmousedown","return false"),this}})},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";(function(e){var i=n(5),r=e.$;t.exports=i.extend({templateInput:function(){var t=this.pfx;return'\n
\n \n
\n '},inputValueChanged:function(){if(!this.model.get("detached")){for(var t=arguments.length,e=Array(t),n=0;n'),this.input=this.$input.get(0)),this.props||(this.props=t.get("properties")),!this.$props)){this.props.each(function(e,n){e&&"composite"==e.get("type")&&(this.props.remove(e),console.warn("Nested composite types not yet allowed.")),e.parent=t},this);var i=n(13),o=new i(this.getPropsConfig());this.$props=o.render().$el,this.$el.find("#"+this.pfx+"input-holder").append(this.$props)}},getPropsConfig:function(t){var e=this,n=this.model,i={config:this.config,collection:this.props,target:this.target,propTarget:this.propTarget,onChange:function(t,e,i){n.set("value",n.getFullValue(),i)},customValue:function(t,n){return e.valueOnIndex(n,t)}};return n.get("detached")&&delete i.onChange,i},valueOnIndex:function(t,e){var n=void 0,i=this.getTargetValue({ignoreDefault:1});if(i){n=i.split(" ")[t]}else n=e&&e.getTargetValue({ignoreCustomValue:1,ignoreDefault:1});return e&&(n=e.model.parseValue(n).value),n}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=n(1),r=n(2),o=n(35),s=n(0);s.$;t.exports=o.extend({events:{"change input":"handleChange","change select":"handleUnitChange","click [data-arrow-up]":"upArrowClick","click [data-arrow-down]":"downArrowClick","mousedown [data-arrows]":"downIncrement"},template:function(){var t=this.ppfx;return'\n \n \n
\n
\n
\n
\n '},inputClass:function(){var t=this.ppfx;return this.opts.contClass||t+"field "+t+"field-integer"},initialize:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];o.prototype.initialize.apply(this,arguments),(0,i.bindAll)(this,"moveIncrement","upIncrement"),this.doc=document,this.listenTo(this.model,"change:unit",this.handleModelChange)},setValue:function(t,e){var n=e||{},i=this.validateInputValue(t,{deepCheck:1}),r={value:i.value};(i.unit||i.force)&&(r.unit=i.unit),this.model.set(r,n),n.silent&&this.handleModelChange()},handleChange:function(t){t.stopPropagation(),this.setValue(this.getInputEl().value),this.elementUpdated()},handleUnitChange:function(t){t.stopPropagation();var e=this.getUnitEl().value;this.model.set("unit",e),this.elementUpdated()},elementUpdated:function(){this.model.trigger("el:change")},handleModelChange:function(){var t=this.model;this.getInputEl().value=t.get("value");var e=this.getUnitEl();e&&(e.value=t.get("unit")||"")},getUnitEl:function(){if(!this.unitEl){var t=this.model,e=t.get("units")||[];if(e.length){var n=[];e.forEach(function(e){var i=e==t.get("unit")?"selected":"";n.push("")});var i=document.createElement("div");i.innerHTML='",this.unitEl=i.firstChild}}return this.unitEl},upArrowClick:function(){var t=this.model,e=t.get("step"),n=parseInt(t.get("value"),10);n=this.normalizeValue(n+e);var i=this.validateInputValue(n);t.set("value",i.value),this.elementUpdated()},downArrowClick:function(){var t=this.model,e=t.get("step"),n=parseInt(t.get("value"),10),i=this.normalizeValue(n-e),r=this.validateInputValue(i);t.set("value",r.value),this.elementUpdated()},downIncrement:function(t){t.preventDefault(),this.moved=0;var e=this.model.get("value");e=this.normalizeValue(e),this.current={y:t.pageY,val:e},(0,r.on)(this.doc,"mousemove",this.moveIncrement),(0,r.on)(this.doc,"mouseup",this.upIncrement)},moveIncrement:function(t){this.moved=1;var e=this.model,n=e.get("step"),i=this.current,r=this.normalizeValue(i.val+(i.y-t.pageY)*n);return this.prValue=this.validateInputValue(r).value,e.set("value",this.prValue,{avoidStore:1}),!1},upIncrement:function(){var t=this.model,e=t.get("step");if((0,r.off)(this.doc,"mouseup",this.upIncrement),(0,r.off)(this.doc,"mousemove",this.moveIncrement),this.prValue&&this.moved){var n=this.prValue-e;t.set("value",n,{avoidStore:1}).set("value",n+e),this.elementUpdated()}},normalizeValue:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.model,i=n.get("step"),r=0;if(isNaN(t))return e;if(t=parseFloat(t),Math.floor(t)!==t){var o=i.toString().split(".")[1];r=o?o.length:0}return r?parseFloat(t.toFixed(r)):t},validateInputValue:function(t,n){var i=0,r=n||{},o=this.model,s=""!==t?t:o.get("defaults"),a=o.get("units")||[],l=o.get("unit")||a.length&&a[0]||"",c=o.get("max"),u=o.get("min");if(r.deepCheck){var h=o.get("fixedValues")||[];if(s){var d=new RegExp("^"+h.join("|"),"g");if(h.length&&d.test(s))s=s.match(d)[0],l="",i=1;else{var f=s+"";s+="",s=parseFloat(s.replace(",",".")),s=isNaN(s)?o.get("defaults"):s;var p=f.replace(s,"");e.indexOf(a,p)>=0&&(l=p)}}}return void 0!==c&&""!==c&&(s=s>c?c:s),void 0!==u&&""!==u&&(s=s1&&void 0!==arguments[1]?arguments[1]:{},r=i.el,o=i.config,a=i.resizer,l=o.keyHeight,c=o.keyWidth,d=o.currentUnit;p("add",0,i),e=n.get("StyleManager").getModelToStyle(h);var f=getComputedStyle(r),g=e.getStyle(),v=g[c]||f[c],m=g[l]||f[l];a.startDim.w=parseFloat(v),a.startDim.h=parseFloat(m),u=0,d&&(o.unitHeight=(0,s.getUnitFromValue)(m),o.unitWidth=(0,s.getUnitFromValue)(v))},onMove:function(){o.trigger("change:canvasOffset")},onEnd:function(t,e){p("remove",0,e),o.trigger("change:canvasOffset"),u=1},updateTarget:function(t,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e){var o=r.store,s=r.selectedHandler,a=r.config,l=a.keyHeight,c=a.keyWidth,u=["tc","bc"].indexOf(s)>=0,h=["cl","cr"].indexOf(s)>=0,d=e.getStyle();u||(d[c]=i.w+a.unitWidth),h||(d[l]=i.h+a.unitHeight),e.setStyle(d,{avoidStore:1});n&&n.trigger("update:component:style:"+l+" update:component:style:"+c),o&&e.trigger("change:style",e,d,{})}}},"object"==(void 0===d?"undefined":r(d))&&(f=i({},f,d)),o.runCommand("resize",{el:t,options:f}))},updateToolbar:function(t){var e=this.config.em,n=t==e?e.get("selectedComponent"):t,i=this.canvas.getToolbarEl(),r=i.style;if(!n)return void(r.opacity=0);var o=n.get("toolbar");this.ppfx;if(e.get("Config").showToolbar&&o&&o.length){if(r.opacity="",r.display="",!this.toolbar){i.innerHTML="",this.toolbar=new l(o);var s=new a({collection:this.toolbar,editor:this.editor});i.appendChild(s.render().el)}this.toolbar.reset(o);var c=n.view;c&&this.updateToolbarPos(c.el)}else r.display="none"},updateToolbarPos:function(t,e){var n=this.canvas.getToolbarEl(),i=n.style,r=i.display;i.display="block";var o=this.canvas.getTargetToElementDim(n,t,{elPos:e,event:"toolbarPosUpdate"}),s=o.left+o.elementWidth-o.targetWidth;i.top=o.top+"px",i.left=(s<0?0:s)+"px",i.display=r},getCanvasPosition:function(){return this.canvas.getCanvasView().getPosition()},clean:function(){this.selEl&&this.selEl.removeClass(this.hoverClass)},getBadge:function(){return this.canvas.getBadgeEl()},onFrameScroll:function(t){var e=this.cacheEl;if(e){var n=this.getElementPos(e);this.updateBadge(e,n);var i=this.em.get("selectedComponent");i&&this.updateToolbarPos(i.view.el)}},updateAttached:function(t){var e=this.em.getSelected();if(e){var n=e.view;this.updateToolbarPos(n.el),this.showFixedElementOffset(n.el)}},getElementPos:function(t,e){return this.canvas.getCanvasView().getElementPos(t)},hideBadge:function(){this.getBadge().style.display="none"},cleanPrevious:function(t){t&&t.set({status:"",state:""})},getContentWindow:function(){return this.frameEl.contentWindow},run:function(t){this.editor=t&&t.get("Editor"),this.enable(),this.onSelect()},stop:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.em;this.stopSelectComponent(),!n.preserveSelected&&i.setSelected(null),this.clean(),this.hideBadge(),this.hideFixedElementOffset(),this.canvas.getToolbarEl().style.display="none",i.off("component:update",this.updateAttached,this),i.off("change:canvasOffset",this.updateAttached,this),i.off("change:selectedComponent",this.updateToolbar,this)}}},function(t,e,n){"use strict";(function(e,i){var r=n(53),o=e.$;t.exports=i.extend({},r,{init:function(t){i.bindAll(this,"startDraw","draw","endDraw","rollback"),this.config=t||{},this.hType=this.config.newFixedH?"height":"min-height",this.allowDraw=1},enable:function(){for(var t=arguments.length,e=Array(t),n=0;n0;for(o in C)(!C[o]&&n(i.mods,+o)>-1||C[o]&&-1==n(i.mods,+o))&&(a=!1);(0!=i.mods.length||C[16]||C[18]||C[17]||C[91])&&!a||!1===i.method(t,i)&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0))}}function s(t){var e,i=t.keyCode,r=n(M,i);if(r>=0&&M.splice(r,1),93!=i&&224!=i||(i=91),i in C){C[i]=!1;for(e in S)S[e]==i&&(l[e]=!1)}}function a(){for(x in C)C[x]=!1;for(x in S)l[x]=!1}function l(t,e,n){var i,r;i=v(t),void 0===n&&(n=e,e="all");for(var o=0;o1&&(r=m(t),t=[t[t.length-1]]),t=t[0],t=E(t),t in w||(w[t]=[]),w[t].push({shortcut:i[o],scope:e,method:n,key:i[o],mods:r})}function c(t,e){var n,r,o,s,a,l=[];for(n=v(t),s=0;s1&&(l=m(r),t=r[r.length-1]),t=E(t),void 0===e&&(e=p()),!w[t])return;for(o=0;o*\/]/.test(n)?i(null,"select-op"):"."==n&&t.match(/^-?[_a-z][_a-z0-9-]*/i)?i("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(n)?i(null,n):"u"==n&&t.match(/rl(-prefix)?\(/)||"d"==n&&t.match("omain(")||"r"==n&&t.match("egexp(")?(t.backUp(1),e.tokenize=s,i("property","word")):/[\w\\\-]/.test(n)?(t.eatWhile(/[\w\\\-]/),i("property","word")):i(null,null):/[\d.]/.test(t.peek())?(t.eatWhile(/[\w.%]/),i("number","unit")):t.match(/^-[\w\\\-]+/)?(t.eatWhile(/[\w\\\-]/),t.match(/^\s*:/,!1)?i("variable-2","variable-definition"):i("variable-2","variable")):t.match(/^\w+-/)?i("meta","meta"):void 0}function o(t){return function(e,n){for(var r,o=!1;null!=(r=e.next());){if(r==t&&!o){")"==t&&e.backUp(1);break}o=!o&&"\\"==r}return(r==t||!o&&")"!=t)&&(n.tokenize=null),i("string","string")}}function s(t,e){return t.next(),t.match(/\s*[\"\')]/,!1)?e.tokenize=null:e.tokenize=o(")"),i(null,"(")}function a(t,e,n){this.type=t,this.indent=e,this.prev=n}function l(t,e,n,i){return t.context=new a(n,e.indentation()+(!1===i?0:v),t.context),n}function c(t){return t.context.prev&&(t.context=t.context.prev),t.context.type}function u(t,e,n){return L[n.context.type](t,e,n)}function h(t,e,n,i){for(var r=i||1;r>0;r--)n.context=n.context.prev;return u(t,e,n)}function d(t){var e=t.current().toLowerCase();g=M.hasOwnProperty(e)?"atom":E.hasOwnProperty(e)?"keyword":"variable"}var f=n.inline;n.propertyKeywords||(n=t.resolveMode("text/css"));var p,g,v=e.indentUnit,m=n.tokenHooks,y=n.documentTypes||{},b=n.mediaTypes||{},x=n.mediaFeatures||{},w=n.mediaValueKeywords||{},C=n.propertyKeywords||{},k=n.nonStandardPropertyKeywords||{},S=n.fontProperties||{},T=n.counterDescriptors||{},E=n.colorKeywords||{},M=n.valueKeywords||{},P=n.allowNested,A=n.lineComment,O=!0===n.supportsAtComponent,L={};return L.top=function(t,e,n){if("{"==t)return l(n,e,"block");if("}"==t&&n.context.prev)return c(n);if(O&&/@component/.test(t))return l(n,e,"atComponentBlock");if(/^@(-moz-)?document$/.test(t))return l(n,e,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/.test(t))return l(n,e,"atBlock");if(/^@(font-face|counter-style)/.test(t))return n.stateArg=t,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(t))return"keyframes";if(t&&"@"==t.charAt(0))return l(n,e,"at");if("hash"==t)g="builtin";else if("word"==t)g="tag";else{if("variable-definition"==t)return"maybeprop";if("interpolation"==t)return l(n,e,"interpolation");if(":"==t)return"pseudo";if(P&&"("==t)return l(n,e,"parens")}return n.context.type},L.block=function(t,e,n){if("word"==t){var i=e.current().toLowerCase();return C.hasOwnProperty(i)?(g="property","maybeprop"):k.hasOwnProperty(i)?(g="string-2","maybeprop"):P?(g=e.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(g+=" error","maybeprop")}return"meta"==t?"block":P||"hash"!=t&&"qualifier"!=t?L.top(t,e,n):(g="error","block")},L.maybeprop=function(t,e,n){return":"==t?l(n,e,"prop"):u(t,e,n)},L.prop=function(t,e,n){if(";"==t)return c(n);if("{"==t&&P)return l(n,e,"propBlock");if("}"==t||"{"==t)return h(t,e,n);if("("==t)return l(n,e,"parens");if("hash"!=t||/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(e.current())){if("word"==t)d(e);else if("interpolation"==t)return l(n,e,"interpolation")}else g+=" error";return"prop"},L.propBlock=function(t,e,n){return"}"==t?c(n):"word"==t?(g="property","maybeprop"):n.context.type},L.parens=function(t,e,n){return"{"==t||"}"==t?h(t,e,n):")"==t?c(n):"("==t?l(n,e,"parens"):"interpolation"==t?l(n,e,"interpolation"):("word"==t&&d(e),"parens")},L.pseudo=function(t,e,n){return"meta"==t?"pseudo":"word"==t?(g="variable-3",n.context.type):u(t,e,n)},L.documentTypes=function(t,e,n){return"word"==t&&y.hasOwnProperty(e.current())?(g="tag",n.context.type):L.atBlock(t,e,n)},L.atBlock=function(t,e,n){if("("==t)return l(n,e,"atBlock_parens");if("}"==t||";"==t)return h(t,e,n);if("{"==t)return c(n)&&l(n,e,P?"block":"top");if("interpolation"==t)return l(n,e,"interpolation");if("word"==t){var i=e.current().toLowerCase();g="only"==i||"not"==i||"and"==i||"or"==i?"keyword":b.hasOwnProperty(i)?"attribute":x.hasOwnProperty(i)?"property":w.hasOwnProperty(i)?"keyword":C.hasOwnProperty(i)?"property":k.hasOwnProperty(i)?"string-2":M.hasOwnProperty(i)?"atom":E.hasOwnProperty(i)?"keyword":"error"}return n.context.type},L.atComponentBlock=function(t,e,n){return"}"==t?h(t,e,n):"{"==t?c(n)&&l(n,e,P?"block":"top",!1):("word"==t&&(g="error"),n.context.type)},L.atBlock_parens=function(t,e,n){return")"==t?c(n):"{"==t||"}"==t?h(t,e,n,2):L.atBlock(t,e,n)},L.restricted_atBlock_before=function(t,e,n){return"{"==t?l(n,e,"restricted_atBlock"):"word"==t&&"@counter-style"==n.stateArg?(g="variable","restricted_atBlock_before"):u(t,e,n)},L.restricted_atBlock=function(t,e,n){return"}"==t?(n.stateArg=null,c(n)):"word"==t?(g="@font-face"==n.stateArg&&!S.hasOwnProperty(e.current().toLowerCase())||"@counter-style"==n.stateArg&&!T.hasOwnProperty(e.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},L.keyframes=function(t,e,n){return"word"==t?(g="variable","keyframes"):"{"==t?l(n,e,"top"):u(t,e,n)},L.at=function(t,e,n){return";"==t?c(n):"{"==t||"}"==t?h(t,e,n):("word"==t?g="tag":"hash"==t&&(g="builtin"),"at")},L.interpolation=function(t,e,n){return"}"==t?c(n):"{"==t||";"==t?h(t,e,n):("word"==t?g="variable":"variable"!=t&&"("!=t&&")"!=t&&(g="error"),"interpolation")},{startState:function(t){return{tokenize:null,state:f?"block":"top",stateArg:null,context:new a(f?"block":"top",t||0,null)}},token:function(t,e){if(!e.tokenize&&t.eatSpace())return null;var n=(e.tokenize||r)(t,e);return n&&"object"==typeof n&&(p=n[1],n=n[0]),g=n,"comment"!=p&&(e.state=L[e.state](p,t,e)),g},indent:function(t,e){var n=t.context,i=e&&e.charAt(0),r=n.indent;return"prop"!=n.type||"}"!=i&&")"!=i||(n=n.prev),n.prev&&("}"!=i||"block"!=n.type&&"top"!=n.type&&"interpolation"!=n.type&&"restricted_atBlock"!=n.type?(")"!=i||"parens"!=n.type&&"atBlock_parens"!=n.type)&&("{"!=i||"at"!=n.type&&"atBlock"!=n.type)||(r=Math.max(0,n.indent-v)):(n=n.prev,r=n.indent)),r},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * ",lineComment:A,fold:"brace"}});var i=["domain","regexp","url","url-prefix"],r=e(i),o=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],s=e(o),a=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover"],l=e(a),c=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive"],u=e(c),h=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],d=e(h),f=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],p=e(f),g=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],v=e(g),m=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],y=e(m),b=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],x=e(b),w=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],C=e(w),k=i.concat(o).concat(a).concat(c).concat(h).concat(f).concat(b).concat(w);t.registerHelper("hintWords","css",k),t.defineMIME("text/css",{documentTypes:r,mediaTypes:s,mediaFeatures:l,mediaValueKeywords:u,propertyKeywords:d,nonStandardPropertyKeywords:p,fontProperties:v,counterDescriptors:y,colorKeywords:x,valueKeywords:C,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=n,n(t,e))}},name:"css"}),t.defineMIME("text/x-scss",{mediaTypes:s,mediaFeatures:l,mediaValueKeywords:u,propertyKeywords:d,nonStandardPropertyKeywords:p,colorKeywords:x,valueKeywords:C,fontProperties:v,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=n,n(t,e)):["operator","operator"]},":":function(t){return!!t.match(/\s*\{/,!1)&&[null,null]},$:function(t){return t.match(/^[\w-]+/),t.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(t){return!!t.eat("{")&&[null,"interpolation"]}},name:"css",helperType:"scss"}),t.defineMIME("text/x-less",{mediaTypes:s,mediaFeatures:l,mediaValueKeywords:u,propertyKeywords:d,nonStandardPropertyKeywords:p,colorKeywords:x,valueKeywords:C,fontProperties:v,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=n,n(t,e)):["operator","operator"]},"@":function(t){return t.eat("{")?[null,"interpolation"]:!t.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)&&(t.eatWhile(/[\w\\\-]/),t.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"}),t.defineMIME("text/x-gss",{documentTypes:r,mediaTypes:s,mediaFeatures:l,propertyKeywords:d,nonStandardPropertyKeywords:p,fontProperties:v,counterDescriptors:y,colorKeywords:x,valueKeywords:C,supportsAtComponent:!0,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=n,n(t,e))}},name:"css",helperType:"gss"})})},function(t,e,n){"use strict";var i=n(0),r=n(28);t.exports=i.Model.extend({defaults:{id:"",content:"",visible:!0,buttons:[],attributes:{}},initialize:function(t){this.btn=this.get("buttons")||[],this.buttons=new r(this.btn),this.set("buttons",this.buttons)}})},function(t,e,n){"use strict";var i=n(0),r=n(109);t.exports=i.Collection.extend({model:r,deactivateAllExceptOne:function(t,e){this.forEach(function(n,i){n!==t&&(n.set("active",!1),e&&n.get("buttons").length&&n.get("buttons").deactivateAllExceptOne(t,e))})},deactivateAll:function(t){var e=t||"";this.forEach(function(t,n){t.get("context")==e&&(t.set("active",!1),t.get("buttons").length&&t.get("buttons").deactivateAll(e))})},disableAllButtons:function(t){var e=t||"";this.forEach(function(t,n){t.get("context")==e&&(t.set("disable",!0),t.get("buttons").length&&t.get("buttons").disableAllButtons(e))})},disableAllButtonsExceptOne:function(t,e){this.forEach(function(n,i){n!==t&&(n.set("disable",!0),e&&n.get("buttons").length&&n.get("buttons").disableAllButtonsExceptOne(t,e))})}})},function(t,e,n){"use strict";var i=n(0),r=n(30);t.exports=i.View.extend({initialize:function(t){var e=t.config||{};this.config=e,this.pfx=e.stylePrefix||"",this.ppfx=e.pStylePrefix||"",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"))},attributes:function(){return this.model.get("attributes")},initResize:function(){var t=this.config.em,e=t?t.get("Editor"):"",n=this.model.get("resizable");if(e&&n){var i,r,o,s=!0===n?[1,1,1,1]:n,a=s.length,l=0;2==a?(i=s[0],o=s[0],r=s[1],l=s[1]):4==a&&(i=s[0],r=s[1],o=s[2],l=s[3]);var c=e.Utils.Resizer.init({tc:i,cr:r,bc:o,cl:l,tl:0,tr:0,bl:0,br:0,appendTo:this.el,prefix:e.getConfig().stylePrefix,posFetcher:function(t){var e=t.getBoundingClientRect();return{left:0,top:0,width:e.width,height:e.height}}});c.blur=function(){},c.focus(this.el)}},render:function(){var t=this.$el,e=this.ppfx;if(t.attr("class",this.className+" "+e+"one-bg"),this.id&&t.attr("id",this.id),this.buttons.length){var n=new r({collection:this.buttons,config:this.config});t.append(n.render().el)}return t.append(this.model.get("content")),this}})},function(t,e,n){"use strict";(function(e){var i=n(0),r=n(111);t.exports=i.View.extend({initialize:function(t){this.opt=t||{},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(t){this.addToCollection(t)},addToCollection:function(t,e){var n=e||null,i=r,o=new i({model:t,config:this.config,parentM:this.parentM}),s=o.render().el;return n?n.appendChild(s):this.$el.append(s),s},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(e){this.addToCollection(e,t)},this),this.$el.append(t),this.$el.attr("class",e.result(this,"className")),this}})}).call(e,n(1))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{},n=e.model,o=void 0===n?{}:n,s=e.view,a=void 0===s?{}:s,l=this.getType(t);if(l)return new l.view(i({model:new l.model(o),config:r},a))},render:function(){return e.render().el}}}},function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0});var n=t.Model,i=t.View;e.default={types:[],initialize:function(t,e){var n=this;this.model=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=void 0,r=void 0,o=void 0;if(t&&t.type){var s=n.getBaseType();o=n.getType(t.type),i=o?o.model:s.model,r=o?o.view:s.view}else{var a=n.recognizeType(t);o=a.type,i=o.model,r=o.view,t=a.attributes}var l=new i(t,e);return l.typeView=r,l};var i=this.init&&this.init.bind(this);i&&i()},recognizeType:function(t){for(var e=this.getTypes(),n=0;n\n \n
\n \n '},init:function(){var t=this.model;this.pfx;t.set("stackIndex",null),this.events["click [data-add-layer]"]="addLayer",this.listenTo(t,"change:stackIndex",this.indexChanged),this.listenTo(t,"updateValue",this.inputValueChanged),this.delegateEvents()},targetUpdated:function(){if(this.model.get("detached"))this.checkVisibility();else{for(var t=arguments.length,e=Array(t),n=0;n'},inputClass:function(){return this.ppfx+"field"},holderClass:function(){return this.ppfx+"input-holder"},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.ppfx||"";this.opts=t,this.ppfx=e,this.em=t.target||{},this.listenTo(this.model,"change:value",this.handleModelChange)},elementUpdated:function(){this.model.trigger("el:change")},setValue:function(t){var e=this.model,n=t||e.get("defaults"),i=this.getInputEl();i&&(i.value=n)},handleModelChange:function(t,e,n){this.setValue(e,n)},handleChange:function(t){t.stopPropagation(),this.model.set("value",this.getInputEl().value),this.elementUpdated()},getInputEl:function(){if(!this.inputEl){var t=this.model.get("defaults");this.inputEl=n('')}return this.inputEl.get(0)},render:function(){var t=this.$el;return t.addClass(this.inputClass()),t.html(this.template()),t.find("."+this.holderClass()).append(this.getInputEl()),this}})}).call(e,n(0))},function(t,e,n){"use strict";t.exports=n(5).extend({templateInput:function(){var t=(this.pfx,this.ppfx);return'\n
\n
\n '},onRender:function(){var t=this.pfx,e=this.ppfx,n=e+"radio-item-label",i=this.model,r=i.get("property"),o=i.get("list")||i.get("options")||[];if(!this.input&&o&&o.length){var s="";o.forEach(function(i){var o=i.className?i.className+" "+t+"icon "+n:"",a=r+"-"+i.value,l=i.name||i.value,c=i.title?'title="'+i.title+'"':"";s+='\n
\n \n \n
\n "});var a=this.el.querySelector("."+e+"field");a.innerHTML='
'+s+"
",this.input=a.firstChild}},getInputValue:function(){var t=this.getCheckedEl();return t?t.value:""},getCheckedEl:function(){var t=this.getInputEl();return t?t.querySelector("input:checked"):""},setValue:function(t){var e=this.model,n=t||e.get("value")||e.getDefaultValue(),i=this.getInputEl(),r=i?i.querySelector('[value="'+n+'"]'):"";if(r)r.checked=!0;else{var o=this.getCheckedEl();o&&(o.checked=!1)}}})},function(t,e,n){"use strict";(function(e){e.$;t.exports=n(5).extend({templateInput:function(){var t=this.pfx,e=this.ppfx;return'\n
\n \n
\n
\n
\n
\n '},onRender:function(){var t=this.pfx,e=this.model,n=e.get("list")||e.get("options")||[];if(!this.input){var i="";n.forEach(function(t){var e=t.name||t.value,n=t.style?t.style.replace(/"/g,"""):"",r=n?'style="'+n+'"':"",o=t.value.replace(/"/g,""");i+='"});var r=this.el.querySelector("#"+t+"input-holder");r.innerHTML="",this.input=r.firstChild}}})}).call(e,n(0))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{};e=i({},e,{silent:1}),this.inputInst.setValue(t,e)},onRender:function(){if(!this.input){var t=this.ppfx,e=new r({target:this.target,model:this.model,ppfx:t}),n=e.render();this.el.querySelector("."+t+"fields").appendChild(n.el),this.$input=n.inputEl,this.$color=n.colorEl,this.input=this.$input.get(0),this.inputInst=n}}})},function(t,e,n){"use strict";(function(e){var i=Object.assign||function(t){for(var e=1;e\n
\n
\n
\n
\n
\n '},inputClass:function(){var t=this.ppfx;return t+"field "+t+"field-color"},holderClass:function(){return this.ppfx+"input-holder"},setValue:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.model,i=t||n.get("defaults"),r=this.getInputEl(),o=this.getColorEl(),s="none"!=i?i:"";r.value=i,o.get(0).style.backgroundColor=s,e.fromTarget&&(o.spectrum("set",s),this.noneColor="none"==i)},getColorEl:function(){if(!this.colorEl){var t=this,e=this.ppfx,n=this.model,r=o('
'),s=r.get(0).style,a=this.em&&this.em.config?this.em.config.el:"",l=this.em&&this.em.getConfig&&this.em.getConfig("colorPicker")||{},c=function(t){return(1==t.getAlpha()?t.toHexString():t.toRgbString()).replace(/ /g,"")},u=0,h=void 0;this.$el.find("[data-colorp-c]").append(r),r.spectrum(i({containerClassName:e+"one-bg "+e+"two-color",appendTo:a||"body",maxSelectionSize:8,showPalette:!0,showAlpha:!0,chooseText:"Ok",cancelText:"⨯",palette:[]},l,{move:function(t){var e=c(t);s.backgroundColor=e,n.setValueFromInput(e,0)},change:function(e){u=1;var i=c(e);s.backgroundColor=i,n.setValueFromInput(i),t.noneColor=0},show:function(t){u=0,h=c(t)},hide:function(e){!u&&h&&(t.noneColor&&(h=""),s.backgroundColor=h,r.spectrum("set",h),n.setValueFromInput(h,0))}})),this.colorEl=r}return this.colorEl},render:function(){return r.prototype.render.call(this),this.getColorEl(),this}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=n(5),r=e.$;t.exports=i.extend({templateInput:function(){var t=this.pfx;this.ppfx;return'\n
\n
\n
\n \n
\n
\n
\n
\n
\n
⨯
\n
\n
\n '},init:function(){var t=this.em;this.modal=t.get("Modal"),this.am=t.get("AssetManager"),this.events["click #"+this.pfx+"close"]="removeFile",this.events["click #"+this.pfx+"images"]="openAssetManager",this.delegateEvents()},onRender:function(){if(!this.$input){var t=this.model.getDefaultValue();this.$input=r('')}this.$preview||(this.$preview=this.$el.find("#"+this.pfx+"preview-file")),this.$previewBox||(this.$previewBox=this.$el.find("#"+this.pfx+"preview-box")),this.setValue(this.componentValue,0)},setValue:function(t,e){i.prototype.setValue.apply(this,arguments),this.setPreviewView(t&&t!=this.model.getDefaultValue()),this.setPreview(t)},setPreviewView:function(t){var e=this.$previewBox;e&&e[t?"addClass":"removeClass"](this.pfx+"show")},spreadUrl:function(t){this.model.set("value",t),this.setPreviewView(1)},setPreview:function(t){var e=this.$preview;t=t&&t.indexOf("url(")<0?"url("+t+")":t,e&&e.css("background-image",t)},cleanValue:function(){this.setPreviewView(0),this.model.set({value:""},{silent:!0})},removeFile:function(){this.model.set("value",this.model.getDefaultValue());for(var t=arguments.length,e=Array(t),n=0;n\n
\n '},getInfo:function(){var t=this.pfx,e=this.model,n=e.get("name"),i=e.get("width"),r=e.get("height"),o=e.get("unitDim"),s=i&&r?i+"x"+r+o:"";return n=n||e.getFilename(),'\n
'+n+'
\n
'+s+"
\n "},init:function(t){var e=this.pfx;this.className+=" "+e+"asset-image"},onClick:function(){var t=this.config.onClick,e=this.model;this.collection.trigger("deselectAll"),this.$el.addClass(this.pfx+"highlight"),"function"==typeof t?t(e):this.updateTarget(this.collection.target)},onDblClick:function(){var t=this.em,e=this.config.onDblClick,n=this.model;"function"==typeof e?e(n):(this.updateTarget(this.collection.target),t&&t.get("Modal").close());var i=this.collection.onSelect;"function"==typeof i&&i(this.model)},onRemove:function(t){t.stopImmediatePropagation(),this.model.collection.remove(this.model)}})},function(t,e,n){"use strict";(function(e,n){t.exports=e.View.extend({initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=t,this.collection=t.collection;var e=t.config||{};this.config=e,this.pfx=e.stylePrefix||"",this.ppfx=e.pStylePrefix||"",this.em=e.em,this.className=this.pfx+"asset",this.listenTo(this.model,"destroy remove",this.remove),this.model.view=this;var n=this.init&&this.init.bind(this);n&&n(t)},template:function(){var t=this.pfx;return'\n
\n '+this.getPreview()+'\n
\n
\n '+this.getInfo()+'\n
\n
\n ⨯\n
\n '},updateTarget:function(t){t&&t.set&&(t.set("attributes",n.clone(t.get("attributes"))),t.set("src",this.model.get("src")))},getPreview:function(){return""},getInfo:function(){return""},render:function(){var t=this.el;return t.innerHTML=this.template(this,this.model),t.className=this.className,this}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";(function(e,i){var r=n(24),o=function(t){return t&&t.__esModule?t:{default:t}}(r);t.exports=e.View.extend({template:i.template('\n
\n
<%= title %>
\n multiple/>\n
\n
\n '),events:{},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=t;var e=t.config||{};this.config=e,this.pfx=e.stylePrefix||"",this.ppfx=e.pStylePrefix||"",this.target=this.options.globalCollection||{},this.uploadId=this.pfx+"uploadFile",this.disabled=void 0!==e.disableUpload?e.disableUpload:!e.upload&&!e.embedAsBase64,this.events["change #"+this.uploadId]="uploadFile";var n=e.uploadFile;n?this.uploadFile=n.bind(this):e.embedAsBase64&&(this.uploadFile=this.constructor.embedAsBase64),this.delegateEvents()},onUploadStart:function(){var t=this.config.em;t&&t.trigger("asset:upload:start")},onUploadEnd:function(t){var e=this.config.em;e&&e.trigger("asset:upload:end",t)},onUploadError:function(t){var e=this.config.em;console.error(t),this.onUploadEnd(t),e&&e.trigger("asset:upload:error",t)},onUploadResponse:function(t,e){var n=this.config.em,i=this.config,r=this.target,o="string"==typeof t?JSON.parse(t):t;n&&n.trigger("asset:upload:response",o),i.autoAdd&&r&&r.add(o.data,{at:0}),this.onUploadEnd(t),e&&e(o)},uploadFile:function(t,e){for(var n=this,i=t.dataTransfer?t.dataTransfer.files:t.target.files,r=new FormData,s=this.config,a=s.params,l=0;l'+i.dropzoneContent+""),h(),"draggable"in o&&[o,a].forEach(function(t){t.ondragover=d,t.ondragleave=f,t.ondrop=p})},render:function(){return this.$el.html(this.template({title:this.config.uploadText,uploadId:this.uploadId,disabled:this.disabled,pfx:this.pfx})),this.initDrop(),this.$el.attr("class",this.pfx+"file-uploader"),this}},{embedAsBase64:function(t,e){var n=this,i=t.dataTransfer?t.dataTransfer.files:t.target.files,r={data:[]};if(!FileReader)return void this.onUploadError(new Error("Unsupported platform, FileReader is not defined"));var o=[],s=/^(.+)\/(.+)$/,a=!0,l=!1,c=void 0;try{for(var u,h=i[Symbol.iterator]();!(a=(u=h.next()).done);a=!0){var d=u.value;!function(t){var e=new Promise(function(e,n){var i=new FileReader;i.addEventListener("load",function(r){var o=void 0,a=t.name,l=s.exec(t.type);if("image"===(o=l?l[1]:t.type)){var c={src:i.result,name:a,type:o,height:0,width:0},u=new Image;u.addEventListener("error",function(t){n(t)}),u.addEventListener("load",function(){c.height=u.height,c.width=u.width,e(c)}),u.src=c.src}else e(o?{src:i.result,name:a,type:o}:i.result)}),i.addEventListener("error",function(t){n(t)}),i.addEventListener("abort",function(t){n("Aborted")}),i.readAsDataURL(t)});o.push(e)}(d)}}catch(t){l=!0,c=t}finally{try{!a&&h.return&&h.return()}finally{if(l)throw c}}Promise.all(o).then(function(t){r.data=t,n.onUploadResponse(r,e)},function(t){n.onUploadError(t)})}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";(function(e){var i=n(47),r=function(t){return t&&t.__esModule?t:{default:t}}(i),o=n(0),s=n(10);t.exports=o.Model.extend(r.default).extend({defaults:{selectors:{},selectorsAdd:"",style:{},mediaText:"",state:"",stylable:!0,important:0},initialize:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.config=t||{};var n=e.em,i=this.config.selectors||[];if(this.em=n,n){var r=n.get("SelectorManager"),o=[];i.forEach(function(t){o.push(r.add(t))}),i=o}this.set("selectors",new s(i))},selectorsToString:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=[],n=this.get("state"),i=this.get("selectorsAdd"),r=this.get("selectors").getFullString(),o=n?":"+n:"";return r&&e.push(""+r+o),i&&!t.skipAdd&&e.push(i),e.join(", ")},toCSS:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="",n=this.get("mediaText"),i=this.styleToString(t),r=this.selectorsToString();return r&&i&&(e=r+"{"+i+"}"),n&&e&&(e="@media "+n+"{"+e+"}"),e},compare:function(t,n,i,r){var o=r||{},s=n||"",a=i||"",l=o.selectorsAdd||"";t instanceof Array||t.models||(t=[t]);var c=e.map(t.models||t,function(t){return t.get("name")}),u=e.map(this.get("selectors").models,function(t){return t.get("name")});if(c.length!==u.length)return!1;for(var h=0;h0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,r.isString)(e)&&(e=l(e));var s=this.getStyle(),a=i({},e);this.set("style",a,n);var c=(0,o.shallowDiff)(s,a);return(0,r.keys)(c).forEach(function(e){return t.trigger("change:style:"+e)}),a},addStyle:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};"string"==typeof t?t={prop:e}:n=e||{},t=this.extendStyle(t),this.setStyle(t,n)},removeStyle:function(t){var e=this.getStyle();delete e[t],this.setStyle(e)},styleToString:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=[],n=this.getStyle();for(var i in n){var o=t.important,s=(0,r.isArray)(o)?o.indexOf(i)>=0:o,a=n[i]+(s?" !important":"");e.push(i+":"+a+";")}return e.join("")}}},function(t,e,n){"use strict";var i=n(0);t.exports=i.View.extend({itemView:"",itemsView:"",itemType:"type",initialize:function(t,e){this.config=e||{}},addTo:function(t){this.add(t)},add:function(t,e){var n=e||null,i=this.itemView,r=t.get(this.itemType);this.itemsView&&this.itemsView[r]&&(i=this.itemsView[r]);var o=new i({model:t,config:this.config},this.config),s=o.render().el;n?n.appendChild(s):this.$el.append(s)},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.length&&this.collection.each(function(e){this.add(e,t)},this),this.$el.append(t),this}})},function(t,e,n){"use strict";var i=n(1),r=n(0);t.exports=r.Collection.extend({initialize:function(t,e){this.on("add",this.onAdd),this.config=e&&e.config?e.config:null,e&&(e.sm||e.em)&&(this.editor=e.sm||e.em),this.model=function(t,n){var i;!n.sm&&e&&e.sm&&(n.sm=e.sm),!n.em&&e&&e.em&&(n.em=e.em),e&&e.config&&(n.config=e.config),e&&e.componentTypes&&(n.componentTypes=e.componentTypes);for(var r=e.componentTypes,o=0;o1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof t){var n=this.editor.get("Parser").parseHtml(t);t=n.html;var i=this.editor.get("CssComposer");if(n.css&&i){var o=e.avoidUpdateStyle;i.addCollection(n.css,{extend:1,avoidUpdateStyle:o})}}return r.Collection.prototype.add.apply(this,[t,e])},onAdd:function(t,e,n){var r=this.editor,o=t.get("style"),s=r&&r.getConfig("avoidInlineStyle");if(!(0,i.isEmpty)(o)&&!s&&r&&r.get&&r.get("Config").forceClass){var a=this.editor.get("CssComposer"),l=this.editor.get("SelectorManager").add(t.cid);t.set({style:{}}),t.get("classes").add(l);a.add(l).set("style",o)}}})},function(t,e,n){"use strict";(function(e){var i=n(1);t.exports=e.View.extend({initialize:function(t){this.opts=t||{},this.config=t.config||{};var e=this.collection;this.listenTo(e,"add",this.addTo),this.listenTo(e,"reset",this.resetChildren)},addTo:function(t){var e=this.config.em,n=this.collection.indexOf(t);this.addToCollection(t,null,n),e&&!t.opt.temporary&&(e.trigger("add:component",t),e.trigger("component:add",t))},addToCollection:function(t,e,r){this.compView||(this.compView=n(3));for(var o=e||null,s=this.compView,a=this.opts.componentTypes,l=t.get("type"),c=0;c':"")+'\n\n
\n
\n
\n \n '+t.getIcon()+'\n \n
\n
\n
\n
'+(r||"")+'
\n
\n \n
\n
\n '},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.opt=t,this.level=t.level,this.config=t.config,this.em=t.config.em,this.ppfx=this.em.get("Config").stylePrefix,this.sorter=t.sorter||"",this.pfx=this.config.stylePrefix;var e=this.pfx,n=this.ppfx,i=this.model,r=i.get("components");i.set("open",!1),this.listenTo(r,"remove add change reset",this.checkChildren),this.listenTo(i,"destroy remove",this.remove),this.listenTo(i,"change:status",this.updateStatus),this.listenTo(i,"change:open",this.updateOpening),this.listenTo(i,"change:style:display",this.updateVisibility),this.className=e+"item no-select",this.editBtnCls=e+"nav-item-edit",this.inputNameCls=n+"nav-comp-name",this.caretCls=n+"nav-item-caret",this.titleCls=e+"title",this.$el.data("model",i),this.$el.data("collection",r)},getVisibilityEl:function(){return this.eyeEl||(this.eyeEl=this.$el.children("#"+this.pfx+"btn-eye")),this.eyeEl},updateVisibility:function(){var t=this.pfx,e=this.model,n=t+"hide",i="none"==e.getStyle().display,r=i?"addClass":"removeClass";this.$el[r](n),this.getVisibilityEl()[r]("fa-eye-slash")},toggleVisibility:function(t){t&&t.stopPropagation();var e=this.model,n=e.getStyle();"none"==n.display?delete n.display:n.display="none",e.setStyle(n)},handleEdit:function(t){t.stopPropagation();var e=this.getInputName();e.readOnly=!1,e.focus()},handleEditEnd:function(t){t.stopPropagation();var e=this.getInputName();e.readOnly=!0,this.model.set("custom-name",e.value)},getInputName:function(){return this.inputName||(this.inputName=this.el.querySelector("."+this.inputNameCls)),this.inputName},updateOpening:function(){var t=this.opt.opened||{},e=this.model;e.get("open")?(this.$el.addClass("open"),this.getCaret().addClass("fa-chevron-down"),t[e.cid]=e):(this.$el.removeClass("open"),this.getCaret().removeClass("fa-chevron-down"),delete t[e.cid])},toggleOpening:function(t){t.stopPropagation(),this.model.get("components").length&&this.model.set("open",!this.model.get("open"))},handleSelect:function(t){t.stopPropagation(),this.em&&this.em.setSelected(this.model,{fromLayers:1})},startSort:function(t){t.stopPropagation(),0===t.button&&this.sorter&&this.sorter.startSort(t.target)},freeze:function(){this.$el.addClass(this.pfx+"opac50"),this.model.set("open",0)},unfreeze:function(){this.$el.removeClass(this.pfx+"opac50")},updateStatus:function(t){r.prototype.updateStatus.apply(this,arguments)},isVisible:function(){var t=this.model.get("style"),e=t.display;if(!e||"none"!=e)return 1},checkChildren:function(){var t=this.model,e=this.countChildren(t),n=this.pfx,i=n+"no-chld",r=this.$el.children("."+n+"title-c").children("."+n+"title");this.$counter||(this.$counter=this.$el.children("#"+n+"counter")),e?(r.removeClass(i),this.$counter.html(e)):(r.addClass(i),this.$counter.empty(),t.set("open",0))},countChildren:function(t){var e=0;return t.get("components").each(function(t){var n=this.opt.isCountable,i=this.config.hideTextnode;n&&!n(t,i)||e++},this),e},getCaret:function(){if(!this.caret){var t=this.pfx;this.caret=this.$el.children("."+t+"title-c").find("#"+t+"caret")}return this.caret},render:function(){var t=this.model,e=this.pfx,r=this.isVisible(),s=this.$el,a=this.level+1;s.html(this.template(t)),(0,i.isUndefined)(o)&&(o=n(56));var l=new o({collection:t.get("components"),config:this.config,sorter:this.sorter,opened:this.opt.opened,parent:t,level:a}).render().$el;return s.find("."+e+"children").append(l),t.get("draggable")&&this.config.sortable||s.children("#"+e+"move").remove(),!r&&(this.className+=" "+e+"hide"),s.attr("class",this.className),this.updateOpening(),this.updateStatus(),this.updateVisibility(),this}})},function(t,e,n){"use strict";var i=n(0),r=n(55);t.exports=i.View.extend({initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.opt=t;var e=t.config||{};if(this.level=t.level,this.config=e,this.preview=t.preview,this.ppfx=e.pStylePrefix||"",this.pfx=e.stylePrefix||"",this.parent=t.parent,this.listenTo(this.collection,"add",this.addTo),this.listenTo(this.collection,"reset resetNavigator",this.render),this.className=this.pfx+"items",e.sortable&&!this.opt.sorter){var n=this.pfx,i=e.em.get("Utils");this.opt.sorter=new i.Sorter({container:e.sortContainer||this.el,containerSel:"."+n+"items",itemSel:"."+n+"item",ppfx:this.ppfx,ignoreViewChildren:1,avoidSelectOnEnd:1,pfx:n,nested:1})}this.sorter=this.opt.sorter||"",this.$el.data("collection",this.collection),this.parent&&this.$el.data("model",this.parent)},addTo:function(t){var e=this.collection.indexOf(t);this.addToCollection(t,null,e)},addToCollection:function(t,e,n){var i=this.level,o=e||null,s=r;if(this.isCountable(t,this.config.hideTextnode)){var a=new s({level:i,model:t,config:this.config,sorter:this.sorter,isCountable:this.isCountable,opened:this.opt.opened}),l=a.render().el;if(o)o.appendChild(l);else if(void 0!==n){var c="before";this.$el.children().length==n&&(n--,c="after"),n<0?this.$el.append(l):this.$el.children().eq(n)[c](l)}else this.$el.append(l);return l}},isCountable:function(t,e){var n=t.get("type"),i=t.get("tagName");return!(("textnode"==n||"br"==i)&&e||!t.get("layerable"))},render:function(){var t=this,e=document.createDocumentFragment();return this.el.innerHTML="",this.collection.each(function(n){return t.addToCollection(n,e)}),this.el.appendChild(e),this.$el.attr("class",this.className),this}})},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{id:"",label:"",open:!0,attributes:{}}})},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}var r=n(9),o=i(r),s=n(1);(0,i(n(59)).default)(),t.exports=function(){var t=n(60),e=n(219),i=new e,r=[],a={autorender:1,container:"",components:"",style:"",fromElement:0,storageManager:{},plugins:[],pluginsOpts:{}};return{$:o.default,editors:r,plugins:i,version:"0.13.5",init:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.container;if(!n)throw new Error("'container' is required");(0,s.defaults)(e,a),e.el=n instanceof window.HTMLElement?n:document.querySelector(n);var o=new t(e).init();return e.plugins.forEach(function(t){var n=i.get(t);n?n(o,e.pluginsOpts[t]||{}):console.warn("Plugin "+t+" not found")}),o.getModel().loadOnStart(),e.autorender&&o.render(),r.push(o),o}}}()},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){if(function(){for(var t=void 0,e=window.navigator.userAgent,n=[["edge",/Edge\/([0-9\._]+)/],["ie",/MSIE\s(7\.0)/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/]],i=0;i0&&void 0!==arguments[0]?arguments[0]:{};this.config=e,this.set("Config",e),this.set("modules",[]),e.el&&e.fromElement&&(this.config.components=e.el.innerHTML),o.forEach(function(e){return t.loadModule(e)}),this.on("change:selectedComponent",this.componentSelected,this),this.on("change:changesCount",this.updateChanges,this)},getConfig:function(t){var e=this.config;return(0,r.isUndefined)(t)?e:e[t]},loadOnStart:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=this.get("StorageManager");this.get("toLoad").forEach(function(t){t.onLoad()});var i=function(){t.get("modules").forEach(function(e){return e.postLoad&&e.postLoad(t)}),e&&e()};n&&n.getConfig().autoload?this.load(i):i()},updateChanges:function(){var t=this.get("StorageManager"),e=this.get("changesCount");this.config.noticeOnUnload&&e?window.onbeforeunload=function(t){return 1}:window.onbeforeunload=null,t.isAutosave()&&e>=t.getStepsBeforeSave()&&this.store()},loadModule:function(t){var e=this.config,n=new t,r=n.name.charAt(0).toLowerCase()+n.name.slice(1),o=e[r]||e[n.name]||{};o.pStylePrefix=e.pStylePrefix||"";var s=this.get("StorageManager");if(n.storageKey&&n.store&&n.load&&s){o.stm=s;var a=this.get("storables");a.push(n),this.set("storables",a)}return o.em=this,n.init(i({},o)),!n.private&&this.set(n.name,n),n.onLoad&&this.get("toLoad").push(n),this.get("modules").push(n),this},init:function(t){this.set("Editor",t)},getEditor:function(){return this.get("Editor")},handleUpdates:function(t,e){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i.temporary||(a&&clearInterval(a),a=setTimeout(function(){i.avoidStore||n.set("changesCount",n.get("changesCount")+1,i)},0))},componentSelected:function(t,e,n){this.get("selectedComponent")?(this.trigger("select-comp",[t,e,n]),this.trigger("component:selected",arguments)):this.trigger("deselect-comp")},getSelected:function(){return this.get("selectedComponent")},setSelected:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t;t instanceof window.HTMLElement&&(n=l(t).data("model")),n&&!n.get("selectable")||this.set("selectedComponent",n,e)},setComponents:function(t){return this.get("DomComponents").setComponents(t)},getComponents:function(){var t=this.get("DomComponents"),e=this.get("CodeManager");if(t&&e){var n=t.getComponents();return e.getCode(n,"json")}},setStyle:function(t){for(var e=this.get("CssComposer").getAll(),n=0,i=e.length;n"+i+"<\/script>":""},getCss:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.config,n=e.wrappesIsBody,i=t.avoidProtected,r=this.get("CssComposer"),o=this.get("DomComponents").getComponent();return(i?"":e.protectedCss)+this.get("CodeManager").getCode(o,"css",{cssc:r,wrappesIsBody:n})},getJs:function(){var t=this.get("DomComponents").getWrapper();return this.get("CodeManager").getCode(t,"js").trim()},store:function(t){var e=this,n=this.get("StorageManager"),i={};if(n)return this.get("storables").forEach(function(t){var e=t.store(1);for(var n in e)i[n]=e[n]}),n.store(i,function(){t&&t(),e.set("changesCount",0),e.trigger("storage:store",i)}),i},load:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.getCacheLoad(1,function(n){t.get("storables").forEach(function(t){return t.load(n)}),e&&e(n)})},getCacheLoad:function(t,e){var n=this,i=t?1:0;if(this.cacheLoad&&!i)return this.cacheLoad;var r=this.get("StorageManager"),o=[];if(!r)return{};this.get("storables").forEach(function(t){var e=t.storageKey;e="function"==typeof e?e():e,(e instanceof Array?e:[e]).forEach(function(t){o.push(t)})}),r.load(o,function(t){n.cacheLoad=t,e&&e(t),n.trigger("storage:load",t)})},getDeviceModel:function(){var t=this.get("device");return this.get("DeviceManager").get(t)},runDefault:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.get("Commands").get(this.config.defaultCommand);e&&!this.defaultRunning&&(e.stop(this,this,t),e.run(this,this,t),this.defaultRunning=1)},stopDefault:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.get("Commands").get(this.config.defaultCommand);e&&(e.stop(this,this,t),this.defaultRunning=0)},refreshCanvas:function(){this.set("canvasOffset",this.get("Canvas").getOffset())},clearSelection:function(t){(t||window).getSelection().removeAllRanges()},getCurrentMedia:function(){var t=this.config,e=this.getDeviceModel(),n=t.mediaCondition,i=t.devicePreviewMode,r=e&&e.get("widthMedia");return e&&r&&!i?"("+n+": "+r+")":""},data:function(t,e,n){if(t["_gjs-data"]||(t["_gjs-data"]={}),(0,r.isUndefined)(n))return t["_gjs-data"][e];t["_gjs-data"][e]=n}})},function(t,e,n){"use strict";t.exports=function(){var t=n(64),e=n(65),i=n(66);return{name:"Utils",init:function(){return this},Sorter:t,Resizer:e,Dragger:i}}},function(t,e,n){"use strict";(function(e,i){var r=n(1),o=n(2),s=e.$;t.exports=e.View.extend({initialize:function(t){this.opt=t||{},i.bindAll(this,"startSort","onMove","endMove","rollback","udpateOffset","moveDragHelper");var e=t||{};this.elT=0,this.elL=0,this.borderOffset=e.borderOffset||10;var n=e.container;this.el="string"==typeof n?document.querySelector(n):n,this.$el=s(this.el),this.containerSel=e.containerSel||"div",this.itemSel=e.itemSel||"div",this.draggable=e.draggable||!0,this.nested=e.nested||0,this.pfx=e.pfx||"",this.ppfx=e.ppfx||"",this.freezeClass=e.freezeClass||this.pfx+"freezed",this.onStart=e.onStart||"",this.onEndMove=e.onEndMove||"",this.direction=e.direction||"v",this.onMoveClb=e.onMove||"",this.relative=e.relative||0,this.ignoreViewChildren=e.ignoreViewChildren||0,this.ignoreModels=e.ignoreModels||0,this.plh=e.placer||"",this.wmargin=e.wmargin||0,this.offTop=e.offsetTop||0,this.offLeft=e.offsetLeft||0,this.document=e.document||document,this.$document=s(this.document),this.dropContent=null,this.em=e.em||"",this.dragHelper=null,this.canvasRelative=e.canvasRelative||0,this.selectOnEnd=!e.avoidSelectOnEnd,this.em&&this.em.on&&(this.em.on("change:canvasOffset",this.udpateOffset),this.udpateOffset())},getContainerEl:function(){if(!this.el){var t=this.opt.container;this.el="string"==typeof t?document.querySelector(t):t,this.$el=s(this.el)}return this.el},getDocuments:function(){var t=this.em,e=t&&t.get("Canvas").getBody().ownerDocument,n=[document];return e&&n.push(e),n},udpateOffset:function(){var t=this.em.get("canvasOffset");this.offTop=t.top,this.offLeft=t.left},setDropContent:function(t){this.dropContent=t},toggleSortCursor:function(t){var e=this.em;document.body,this.ppfx||this.pfx,e&&e.get("Canvas").getBody();t?e&&e.get("Canvas").startAutoscroll():e&&e.get("Canvas").stopAutoscroll()},setDragHelper:function(t,e){for(var n=e||"",i=t.cloneNode(1),r=t.getBoundingClientRect(),o=getComputedStyle(t),a="",l=0;ls+c-10||ra+l-10)return 1},getCurrentPos:function(){var t=this.eventMove;return{x:t.pageX||0,y:t.pageY||0}},getDim:function(t){var e,n,i,r;if(this.canvasRelative&&this.em){var o=this.em.get("Canvas").getElementPos(t),s=window.getComputedStyle(t),a=parseFloat(s.marginTop),l=parseFloat(s.marginBottom),c=parseFloat(s.marginRight),u=parseFloat(s.marginLeft);e=o.top-a,n=o.left-u,i=o.height+a+l,r=o.width+u+c}else{var h=this.offset(t);e=this.relative?t.offsetTop:h.top-(this.wmargin?-1:1)*this.elT,n=this.relative?t.offsetLeft:h.left-(this.wmargin?-1:1)*this.elL,i=t.offsetHeight,r=t.offsetWidth}return[e,n,i,r]},getChildrenDim:function(t){var e=[];if(!t)return e;var n=this.getTargetModel(t);n&&n.view&&!this.ignoreViewChildren&&(t=n.view.getChildrenContainer());for(var i=t.children,r=0,o=i.length;rs||s>a+c-r||l+r>o||o>l+u-r)&&(i=1),!!i},findPosition:function(t,e,n){for(var i={index:0,method:"before"},r=0,o=0,s=0,a=0,l=0,c=0,u=0,h=0,d=0,f=t.length;do||a&&c>=a||r&&s0&&void 0!==arguments[0]?arguments[0]:{};return i(this,t),this.setOptions(e),(0,o.bindAll)(this,"handleKeyDown","handleMouseDown","move","stop"),this}return r(t,[{key:"getConfig",value:function(){return this.opts}},{key:"setOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.opts=(0,o.defaults)(t,a),this.setup()}},{key:"setup",value:function(){var t=this.opts,e=t.prefix||"",n=t.appendTo||document.body,i=this.container;for(i||(i=document.createElement("div"),i.className=e+"resizer-c",n.appendChild(i),this.container=i);i.firstChild;)i.removeChild(i.firstChild);var r={};["tl","tc","tr","cl","cr","bl","bc","br"].forEach(function(e){return r[e]=t[e]?l(e,t):""});for(var o in r){var s=r[o];s&&i.appendChild(s)}this.handlers=r,this.mousePosFetcher=t.mousePosFetcher,this.updateTarget=t.updateTarget,this.posFetcher=t.posFetcher,this.onStart=t.onStart,this.onMove=t.onMove,this.onEnd=t.onEnd}},{key:"isHandler",value:function(t){var e=this.handlers;for(var n in e)if(e[n]===t)return!0;return!1}},{key:"getFocusedEl",value:function(){return this.el}},{key:"getDocumentEl",value:function(){return[this.el.ownerDocument,document]}},{key:"getElementPos",value:function(t){var e=this.posFetcher||"";return e?e(t):c(t)}},{key:"focus",value:function(t){if(!t||t!==this.el){this.el=t;var e=this.getElementPos(t),n=this.container,i=n.style;i.left=e.left+"px",i.top=e.top+"px",i.width=e.width+"px",i.height=e.height+"px",n.style.display="block",(0,s.on)(this.getDocumentEl(),"mousedown",this.handleMouseDown)}}},{key:"blur",value:function(){this.container.style.display="none",this.el&&((0,s.off)(this.getDocumentEl(),"mousedown",this.handleMouseDown),this.el=null)}},{key:"start",value:function(t){if(0===t.button){t.preventDefault(),t.stopPropagation();var e=this.el,n=this,i=this.opts||{},r="data-"+i.prefix+"handler",a=this.getElementPos(e);this.handlerAttr=t.target.getAttribute(r),this.clickedHandler=t.target,this.startDim={t:a.top,l:a.left,w:a.width,h:a.height},this.rectDim={t:a.top,l:a.left,w:a.width,h:a.height},this.startPos={x:t.clientX,y:t.clientY};var l=this.getDocumentEl();(0,s.on)(l,"mousemove",this.move),(0,s.on)(l,"keydown",this.handleKeyDown),(0,s.on)(l,"mouseup",this.stop),(0,o.isFunction)(this.onStart)&&this.onStart(t,{docs:l,config:i,el:e,resizer:n}),this.move(t)}}},{key:"move",value:function(t){var e=this.onMove,n=this.mousePosFetcher,i=n?n(t):{x:t.clientX,y:t.clientY};this.currentPos=i,this.delta={x:i.x-this.startPos.x,y:i.y-this.startPos.y},this.keys={shift:t.shiftKey,ctrl:t.ctrlKey,alt:t.altKey},this.rectDim=this.calc(this),this.updateRect(0),e&&e(t),0===t.which&&this.stop(t)}},{key:"stop",value:function(t){var e=this.opts,n=this.getDocumentEl();(0,s.off)(n,"mousemove",this.move),(0,s.off)(n,"keydown",this.handleKeyDown),(0,s.off)(n,"mouseup",this.stop),this.updateRect(1),(0,o.isFunction)(this.onEnd)&&this.onEnd(t,{docs:n,config:e})}},{key:"updateRect",value:function(t){var e=this.el,n=this,i=this.opts,r=this.rectDim,s=this.container.style,a=this.updateTarget,l=this.getSelectedHandler(),c=i.unitHeight,u=i.unitWidth;if((0,o.isFunction)(a))a(e,r,{store:t,selectedHandler:l,resizer:n,config:i});else{var h=e.style;h.width=r.w+u,h.height=r.h+c}var d=this.getElementPos(e);s.left=d.left+"px",s.top=d.top+"px",s.width=d.width+"px",s.height=d.height+"px"}},{key:"getSelectedHandler",value:function(){var t=this.handlers;if(this.selectedHandler)for(var e in t)if(t[e]===this.selectedHandler)return e}},{key:"handleKeyDown",value:function(t){27===t.keyCode&&(this.rectDim=this.startDim,this.stop(t))}},{key:"handleMouseDown",value:function(t){var e=t.target;this.isHandler(e)?(this.selectedHandler=e,this.start(t)):e!==this.el&&(this.selectedHandler="",this.blur())}},{key:"calc",value:function(t){var e=void 0,n=this.opts||{},i=n.step,r=this.startDim,o=n.minDim,a=n.maxDim,l=t.delta.x,c=t.delta.y,u=r.w,h=r.h,d={t:0,l:0,w:u,h:h};if(t){var f=t.handlerAttr;~f.indexOf("r")&&(e=(0,s.normalizeFloat)(u+l*i,i),e=Math.max(o,e),a&&(e=Math.min(a,e)),d.w=e),~f.indexOf("b")&&(e=(0,s.normalizeFloat)(h+c*i,i),e=Math.max(o,e),a&&(e=Math.min(a,e)),d.h=e),~f.indexOf("l")&&(e=(0,s.normalizeFloat)(u-l*i,i),e=Math.max(o,e),a&&(e=Math.min(a,e)),d.w=e),~f.indexOf("t")&&(e=(0,s.normalizeFloat)(h-c*i,i),e=Math.max(o,e),a&&(e=Math.min(a,e)),d.h=e);var p=n.ratioDefault?!t.keys.shift:t.keys.shift;if(f.indexOf("c")<0&&p){var g=r.w/r.h;d.w/d.h>g?d.h=Math.round(d.w/g):d.w=Math.round(d.h*g)}return~f.indexOf("l")&&(d.l=r.w-d.w),~f.indexOf("t")&&(d.t=r.h-d.h),d}}}]),t}();t.exports={init:function(t){return new u(t)}}},function(t,e,n){"use strict";(function(e){var n=e.$,i=function(t,e){var n=e||window,i=t.getBoundingClientRect();return{left:i.left+n.pageXOffset,top:i.top+n.pageYOffset,width:i.width,height:i.height}};t.exports={setKey:function(t,e){},getElementRect:function(t){var e=this.opts.posFetcher||"";return e?e(t,{avoidFrameOffset:1}):i(t)},init:function(t){return this.setOptions(t),this.handleMouseDown=this.handleMouseDown.bind(this),this.drag=this.drag.bind(this),this.move=this.move.bind(this),this.stop=this.stop.bind(this),this.setKey("up, right, down, left",this.handleKey),this},setOptions:function(t){this.opts=t||{}},focus:function(t){if(!t||t!==this.el){this.getDocumentEl(t),this.blur(),this.el=t,this.handlers=this.opts.dragHandlers||[t];var e=this.getElementRect(t);this.elRect=e,this.startTop=e.top,this.startLeft=e.left,this.getDocumentEl().on("mousedown",this.handleMouseDown)}},blur:function(){this.getDocumentEl().off("mousedown",this.handleMouseDown),this.el=null},start:function(t){this.startPos=this.getMousePos(t);var e=this.getDocumentEl();e.on("mousemove",this.drag),e.on("mouseup",this.stop);var n=this.opts.onStart;"function"==typeof n&&n(t,{docs:e,el:this.el,start:this.startPos,elRect:this.elRect}),this.drag(t)},stop:function(t){var e=this.getDocumentEl();e.off("mousemove",this.drag),e.off("mouseup",this.stop),this.lockedAxis=null;var n=this.opts.onEnd;"function"==typeof n&&n(t,{docs:e,delta:this.delta,end:{x:this.startLeft+this.delta.x,y:this.startTop+this.delta.y}})},handleMouseDown:function(t){var e=t.target;this.isHandler(e)&&this.start(t)},isHandler:function(t){var e=this.handlers;for(var n in e)if(e[n]===t)return!0;return!1},handleKey:function(t,e){switch(e.shortcut){case"up":this.move(0,-1);break;case"right":this.move(1,0);break;case"down":this.move(0,1);break;case"left":this.move(-1,0)}},getDocumentEl:function(t){var t=t||this.el;if(!this.$doc){var e=[document];t&&e.push(t.ownerDocument),this.$doc=n(e)}return this.$doc},getMousePos:function(t){var e=this.opts.mousePosFetcher;return e?e(t):{x:t.clientX,y:t.clientY}},drag:function(t){var e=this.lockedAxis,n=this.getMousePos(t),i={x:n.x-this.startPos.x,y:n.y-this.startPos.y};if(t.shiftKey){if(!e){var r=i.x,o=i.y,s=Math.abs(r),a=Math.abs(o);o>=s||o<=-s?e="x":(r>a||r<-a)&&(e="y")}}else e=null;"x"===e&&(i.x=this.startPos.x),"y"===e&&(i.y=this.startPos.y),this.lockedAxis=e,this.delta=i,this.move(i.x,i.y);var l=this.opts.onDrag;"function"==typeof l&&l(t,{delta:i,current:{x:this.startLeft+i.x,y:this.startTop+i.y},lockedAxis:e}),0===t.which&&this.stop(t)},move:function(t,e){this.moveX(t),this.moveY(e)},moveX:function(t){var e=this.el,n=(this.opts,this.startLeft+t),i=this.opts.setX;"function"==typeof i?i(n,{el:e,start:this.startLeft,delta:t}):e.style.left=n+"px"},moveY:function(t){var e=this.el,n=(this.opts,this.startTop+t),i=this.opts.setY;"function"==typeof i?i(n,{el:e,start:this.startTop,delta:t}):e.style.top=n+"px"}}}).call(e,n(0))},function(t,e,n){"use strict";var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=Object.assign||function(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{};return e=r({},a,n),t=e.em,this.em=t,this},onLoad:function(){var t=e.defaults;for(var n in t){var i=t[n];this.add(n,i.keys,i.handler)}},add:function(t,e,r){var a=this.em,l=a.get("Commands"),c=a.getEditor(),u={id:t,keys:e,handler:r};return n[t]&&this.remove(t),n[t]=u,s(e,function(e,n){r=(0,o.isString)(r)?l.get(r):r,"object"==(void 0===r?"undefined":i(r))?r.run(c):r(c);var s=[t,n.shortcut,e];a.trigger.apply(a,["keymap:emit"].concat(s)),a.trigger.apply(a,["keymap:emit:"+t].concat(s))}),a.trigger("keymap:add",u),u},get:function(t){return n[t]},getAll:function(){return n},remove:function(t){var e=this.em,i=this.get(t);if(i)return delete n[t],s.unbind(i.keys),e&&e.trigger("keymap:remove",i),i}}}},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{};n=i({},a,s),t=n.em,this.em=t,e=new o.default({track:!0,register:[]}),e.changeUndoType("change",{condition:!1});var l={on:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!r&&(r=t.previousAttributes()),!n.avoidStore){var i={object:t,before:r,after:t.toJSON()};return r=null,i}},undo:function(t,e,n,i){t.set(e)},redo:function(t,e,n,i){t.set(n)}};return["style","attributes","content","src"].forEach(function(t){return e.addUndoType("change:"+t,l)}),e.on("undo redo",function(){return t.trigger("change:selectedComponent change:canvasOffset")}),["undo","redo"].forEach(function(n){return e.on(n,function(){return t.trigger(n)})}),this},getConfig:function(){return n},add:function(t){return e.register(t),this},remove:function(t){return e.unregister(t),this},removeAll:function(){return e.unregisterAll(),this},start:function(){return e.startTracking(),this},stop:function(){return e.stopTracking(),this},undo:function(){return t.get("Canvas").isInputFocused()||e.undo(1),this},undoAll:function(){return e.undoAll(),this},redo:function(){return t.get("Canvas").isInputFocused()||e.redo(1),this},redoAll:function(){return e.redoAll(),this},hasUndo:function(){return e.isAvailable("undo")},hasRedo:function(){return e.isAvailable("redo")},getStack:function(){return e.stack},clear:function(){return e.clear(),this},getInstance:function(){return e}}}},function(t,e,n){var i,r,o;/*! * Backbone.Undo.js v0.2 * * Copyright (c)2013 Oliver Sartun @@ -8,4 +8,4 @@ * Documentation and full license available at * https://github.com/osartun/Backbone.Undo.js */ -!function(s){r=[n(1),n(72)],i=s,void 0!==(o="function"==typeof i?i.apply(e,r):i)&&(t.exports=o)}(function(t,e){function n(t,e,n){return n.length<=4?t.call(e,n[0],n[1],n[2],n[3]):t.apply(e,n)}function i(t,e){return f.call(t,e)}function r(e,n){return null!=e&&(t.isArray(n)||(n=i(arguments,1)),t.all(n,function(t){return t in e}))}function o(){this.registeredObjects=[],this.cidIndexes=[]}function s(e,n,i,r){for(var o,s=0,a=n.length;st.maximumStackLength&&(t.shift(),t.pointer--)}}}function h(){}function d(e,n,i,o){if("object"==typeof n)return t.each(n,function(t,n){2===e?d(e,t,i,o):d(e,n,t,i)});switch(e){case 0:r(i,"undo","redo","on")&&t.all(t.pick(i,"undo","redo","on"),t.isFunction)&&(o[n]=i);break;case 1:o[n]&&t.isObject(i)&&(o[n]=t.extend({},o[n],i));break;case 2:delete o[n]}return this}var f=Array.prototype.slice,p=function(){function e(){i++,n=!0,t.defer(function(){n=!1})}var n=!1,i=-1;return function(){return n||e(),i}}();o.prototype={isRegistered:function(e){return e&&e.cid?this.registeredObjects[e.cid]:t.contains(this.registeredObjects,e)},register:function(t){return!this.isRegistered(t)&&(t&&t.cid?(this.registeredObjects[t.cid]=t,this.cidIndexes.push(t.cid)):this.registeredObjects.push(t),!0)},unregister:function(e){if(this.isRegistered(e)){if(e&&e.cid)delete this.registeredObjects[e.cid],this.cidIndexes.splice(t.indexOf(this.cidIndexes,e.cid),1);else{var n=t.indexOf(this.registeredObjects,e);this.registeredObjects.splice(n,1)}return!0}return!1},get:function(){return t.map(this.cidIndexes,function(t){return this.registeredObjects[t]},this).concat(this.registeredObjects)}};var g={add:{undo:function(t,e,n,i){t.remove(n,i)},redo:function(t,e,n,i){i.index&&(i.at=i.index),t.add(n,i)},on:function(e,n,i){return{object:n,before:void 0,after:e,options:t.clone(i)}}},remove:{undo:function(t,e,n,i){"index"in i&&(i.at=i.index),t.add(e,i)},redo:function(t,e,n,i){t.remove(e,i)},on:function(e,n,i){return{object:n,before:e,after:void 0,options:t.clone(i)}}},change:{undo:function(e,n,i,r){t.isEmpty(n)?t.each(t.keys(i),e.unset,e):(e.set(n),r&&r.unsetData&&r.unsetData.before&&r.unsetData.before.length&&t.each(r.unsetData.before,e.unset,e))},redo:function(e,n,i,r){t.isEmpty(i)?t.each(t.keys(n),e.unset,e):(e.set(i),r&&r.unsetData&&r.unsetData.after&&r.unsetData.after.length&&t.each(r.unsetData.after,e.unset,e))},on:function(e,n){var i=e.changedAttributes(),r=t.keys(i),o=t.pick(e.previousAttributes(),r),s=t.keys(o),a=(n||(n={})).unsetData={after:[],before:[]};return r.length!=s.length&&(r.length>s.length?t.each(r,function(t){t in o||a.before.push(t)},this):t.each(s,function(t){t in i||a.after.push(t)})),{object:e,before:o,after:i,options:t.clone(n)}}},reset:{undo:function(t,e,n){t.reset(e)},redo:function(t,e,n){t.reset(n)},on:function(e,n){return{object:e,before:n.previousModels,after:t.clone(e.models)}}}};h.prototype=g;var v=e.Model.extend({defaults:{type:null,object:null,before:null,after:null,magicFusionIndex:null},undo:function(t){a("undo",this.attributes)},redo:function(t){a("redo",this.attributes)}}),m=e.Collection.extend({model:v,pointer:-1,track:!1,isCurrentlyUndoRedoing:!1,maximumStackLength:1/0,setMaxLength:function(t){this.maximumStackLength=t}}),y=e.Model.extend({defaults:{maximumStackLength:1/0,track:!1},initialize:function(e){this.stack=new m,this.objectRegistry=new o,this.undoTypes=new h,this.stack.setMaxLength(this.get("maximumStackLength")),this.on("change:maximumStackLength",function(t,e){this.stack.setMaxLength(e)},this),e&&e.track&&this.startTracking(),e&&e.register&&(t.isArray(e.register)||t.isArguments(e.register)?n(this.register,this,e.register):this.register(e.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(t){u(this.stack,t,i(arguments,1),this.undoTypes)},register:function(){s("on",arguments,this._addToStack,this)},unregister:function(){s("off",arguments,this._addToStack,this)},unregisterAll:function(){n(this.unregister,this,this.objectRegistry.get())},undo:function(t){l("undo",this,this.stack,t)},undoAll:function(){l("undo",this,this.stack,!1,!0)},redo:function(t){l("redo",this,this.stack,t)},redoAll:function(){l("redo",this,this.stack,!1,!0)},isAvailable:function(t){var e=this.stack,n=e.length;switch(t){case"undo":return n>0&&e.pointer>-1;case"redo":return n>0&&e.pointer1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=this.get("contentTypeJson"),s=this.get("headers")||{},a=this.get("params"),l=n.body||{},c=void 0,u=void 0;for(var h in a)l[h]=a[h];if((0,o.isUndefined)(s["X-Requested-With"])&&(s["X-Requested-With"]="XMLHttpRequest"),(0,o.isUndefined)(s["Content-Type"])&&r&&(s["Content-Type"]="application/json; charset=utf-8"),r)u=JSON.stringify(l);else{u=new FormData;for(var d in l)u.append(d,l[d])}c={method:n.method||"post",credentials:"include",headers:s},"post"===c.method&&(c.body=u),this.onStart(),this.fetch(t,c).then(function(t){return 1==(t.status/200|0)?t.text():t.text().then(function(t){return Promise.reject(t)})}).then(function(t){return e.onResponse(t,i)}).catch(function(t){return e.onError(t)})}})},function(t,e,n){(function(e){!function(n){function i(){}function r(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],h(t,this)}function s(t,e){for(;3===t._state;)t=t._value;if(0===t._state)return void t._deferreds.push(e);t._handled=!0,o._immediateFn(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?a:l)(e.promise,t._value);var i;try{i=n(t._value)}catch(t){return void l(e.promise,t)}a(e.promise,i)})}function a(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof o)return t._state=3,t._value=e,void c(t);if("function"==typeof n)return void h(r(n,e),t)}t._state=1,t._value=e,c(t)}catch(e){l(t,e)}}function l(t,e){t._state=2,t._value=e,c(t)}function c(t){2===t._state&&0===t._deferreds.length&&o._immediateFn(function(){t._handled||o._unhandledRejectionFn(t._value)});for(var e=0,n=t._deferreds.length;e=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(79),e.setImmediate=setImmediate,e.clearImmediate=clearImmediate},function(t,e,n){(function(t,e){!function(t,n){"use strict";function i(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n1)for(var n=1;n<%= deviceLabel %>\n
\n \n \n \n
\n
\n
\n
\n '),events:{change:"updateDevice"},initialize:function(t){this.config=t.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 t=this.em;if(t){var e=this.devicesEl,n=e?e.val():"";t.set("device",n)}},updateSelect:function(){var t=this.em,e=this.devicesEl;if(t&&t.getDeviceModel&&e){var n=t.getDeviceModel(),i=n?n.get("name"):"";e.val(i)}},getOptions:function(){var t="";return this.collection.each(function(e){var n=e.get("name");t+='"}),t},render:function(){var t=this.ppfx;return this.$el.html(this.template({ppfx:t,deviceLabel:this.config.deviceLabel})),this.devicesEl=this.$el.find("."+t+"devices"),this.devicesEl.append(this.getOptions()),this.el.className=t+"devices-c",this}})}).call(e,n(1))},function(t,e,n){"use strict";t.exports=function(){var t,e,i={},r=n(87),o=n(88),s=n(25);return{compTypes:"",name:"Parser",init:function(n){i=n||{};for(var a in r)a in i||(i[a]=r[a]);return t=new s(i),e=new o(i),this},parseHtml:function(n){return t.compTypes=this.compTypes,t.parse(n,e)},parseCss:function(t){return e.parse(t)}}}},function(t,e,n){"use strict";t.exports={textTags:["br","b","i","u","a","ul","ol"]}},function(t,e,n){"use strict";t.exports=function(t){return{parseSelector:function(t){for(var e=[],n=[],i=t.split(","),r=0,o=i.length;r1&&void 0!==arguments[1]?arguments[1]:{};"object"==(void 0===t?"undefined":i(t))?n=t:n.name=t,n.label&&!n.name&&(n.name=l.escapeName(n.label));var r=n.name,o=r?this.get(r,n.type):e.where(n)[0];return o||e.add(n)},addClass:function(t){var n=[];return(0,r.isString)(t)&&(t=t.trim().split(" ")),t.forEach(function(t){return n.push(e.add({name:t}))}),n},get:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l.TYPE_CLASS;return e.where({name:t,type:n})[0]},getAll:function(){return e},render:function(t){if(t){return new u({collection:new c(t),config:s}).render().el}return o.render().el}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"clm-",selectors:[],label:"Classes",statesLabel:"- State -",selectedLabel:"Selected",states:[{name:"hover",label:"Hover"},{name:"active",label:"Click"},{name:"nth-of-type(2n)",label:"Even/Odd"}]}},function(t,e,n){"use strict";(function(e){var i=n(0),r=n(92);t.exports=i.View.extend({template:e.template('\n
\n
<%= label %>
\n
\n \n
\n \n \n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n \n
\n
\n
<%= selectedLabel %>
\n
\n
\n
'),events:{},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config=t.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.em=this.target,this.listenTo(this.target,"change:selectedComponent",this.componentChanged),this.listenTo(this.target,"component:update:classes",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(t){this.updateStateVis()},getStateOptions:function(){for(var t="",e=0;e'+this.states[e].label+"";return t},addNew:function(t){this.addToClasses(t)},startNewTag:function(t){this.$addBtn.get(0).style.display="none",this.$input.show().focus()},endNewTag:function(t){this.$addBtn.get(0).style.display="",this.$input.hide().val("")},onInputKeyUp:function(t){13===t.keyCode?this.addNewTag(this.$input.val()):27===t.keyCode&&this.endNewTag()},componentChanged:function(t){this.compTarget=this.target.get("selectedComponent");var e=this.compTarget,n=[];e&&(this.getStates().val(e.get("state")),n=e.get("classes").getValid()),this.collection.reset(n),this.updateStateVis()},updateStateVis:function(){var t=this.em,e=t&&t.getConfig("avoidInlineStyle");this.collection.length||e?this.getStatesC().css("display","block"):this.getStatesC().css("display","none"),this.updateSelector()},updateSelector:function(){var t=this.target.getSelected();if(this.compTarget=t,t&&t.get){var e=t.get("state"),n=this.collection,i=n.getFullString(n.getStyleable());i=i||"#"+t.getId(),i+=e?":"+e:"";var r=this.el.querySelector("#"+this.pfx+"sel");r&&(r.innerHTML=i)}},stateChanged:function(t){this.compTarget&&(this.compTarget.set("state",this.$states.val()),this.updateSelector())},addNewTag:function(t){var e=this.target,n=this.compTarget;if(t.trim()){if(e){var i=e.get("SelectorManager"),r=i.add({label:t});if(n){var o=n.get("classes");o.length;o.add(r);o.length;this.collection.add(r),this.updateStateVis()}}this.endNewTag()}},addToClasses:function(t,e){var n=e||null,i=new r({model:t,config:this.config,coll:this.collection}),o=i.render().el;return n?n.appendChild(o):this.getClasses().append(o),o},renderClasses:function(){var t=document.createDocumentFragment();return this.collection.each(function(e){this.addToClasses(e,t)},this),this.getClasses()&&this.getClasses().empty().append(t),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(){var t=this.config;return this.$el.html(this.template({selectedLabel:t.selectedLabel,statesLabel:t.statesLabel,label:t.label,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}})}).call(e,n(1))},function(t,e,n){"use strict";var i=n(7);t.exports=n(0).View.extend({template:function(){var t=this.pfx;this.ppfx;return'\n \n '+(this.model.get("label")||"")+'\n \n ⨯\n \n '},events:{"click [data-tag-remove]":"removeTag","click [data-tag-status]":"changeStatus","dblclick [data-tag-name]":"startEditTag","focusout [data-tag-name]":"endEditTag"},initialize:function(t){this.config=t.config||{},this.coll=t.coll||null,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.target=this.config.em,this.listenTo(this.model,"change:active",this.updateStatus)},getInputEl:function(){return this.inputEl||(this.inputEl=this.el.querySelector("[data-tag-name]")),this.inputEl},startEditTag:function(){var t=this.getInputEl();t.contentEditable=!0,t.focus()},endEditTag:function(){var t=this.model,e=this.getInputEl(),n=e.textContent,r=i.escapeName(n),o=this.target,s=o&&o.get("SelectorManager");e.contentEditable=!1,s&&(s.get(r)?e.innerText=t.get("label"):t.set({name:r,label:n}))},changeStatus:function(){this.model.set("active",!this.model.get("active"))},removeTag:function(t){var e=this,n=this.target,i=this.model,r=this.coll,o=(this.el,n&&n.get("selectedComponent"));o&&(o.get,o.get("classes").remove(i)),r&&r.remove(i),setTimeout(function(){return e.remove()},0)},updateStatus:function(){var t="fa-check-square-o";this.$chk||(this.$chk=this.$el.find("#"+this.pfx+"checkbox")),this.model.get("active")?(this.$chk.removeClass("fa-square-o").addClass(t),this.$el.removeClass("opac50")):(this.$chk.removeClass(t).addClass("fa-square-o"),this.$el.addClass("opac50"))},render:function(){var t=this.pfx,e=this.ppfx;return this.$el.html(this.template()),this.$el.attr("class",t+"tag "+e+"three-bg"),this.updateStatus(),this}})},function(t,e,n){"use strict";t.exports=function(){var t,e,i={},r=n(94),o=n(95),s=n(96);return{name:"Modal",init:function(n){i=n||{};for(var a in r)a in i||(i[a]=r[a]);var l=i.pStylePrefix;return l&&(i.stylePrefix=l+i.stylePrefix),t=new o(i),e=new s({model:t,config:i}),this},postRender:function(t){this.render().appendTo(t.el)},open:function(){return e.show(),this},close:function(){return e.hide(),this},isOpen:function(){return!!t.get("open")},setTitle:function(e){return t.set("title",e),this},getTitle:function(){return t.get("title")},setContent:function(e){return t.set("content"," "),t.set("content",e),this},getContent:function(){return t.get("content")},getContentEl:function(){return e.getContent().get(0)},getModel:function(){return t},render:function(){return e.render().$el}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"mdl-",title:"",content:"",backdrop:!0}},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{title:"",content:"",open:!1}})},function(t,e,n){"use strict";t.exports=n(0).View.extend({template:function(t){var e=t.pfx,n=t.ppfx,i=t.content;return'
\n
\n
'+t.title+'
\n
⨯
\n
\n
\n
'+i+'
\n
\n
\n
\n
\n '},events:{},initialize:function(t){var e=this.model,n=t.config||{},i=n.stylePrefix||"",r=n.backdrop;this.config=n,this.pfx=i,this.ppfx=n.pStylePrefix||"",this.listenTo(e,"change:open",this.updateOpen),this.listenTo(e,"change:title",this.updateTitle),this.listenTo(e,"change:content",this.updateContent),this.events["click ."+i+"btn-close"]="hide",r&&(this.events["click ."+i+"backlayer"]="hide"),this.delegateEvents()},getCollector:function(){return this.$collector||(this.$collector=this.$el.find("."+this.pfx+"collector")),this.$collector},getContent:function(){var t=this.pfx;return this.$content||(this.$content=this.$el.find("."+t+"content #"+t+"c")),this.$content},getTitle:function(){return this.$title||(this.$title=this.$el.find("."+this.pfx+"title")),this.$title.get(0)},updateContent:function(){var t=this.getContent(),e=t.children(),n=this.getCollector(),i=this.model.get("content");e.length&&n.append(e),t.empty().append(i)},updateTitle:function(){var t=this.getTitle();t&&(t.innerHTML=this.model.get("title"))},updateOpen:function(){this.el.style.display=this.model.get("open")?"":"none"},hide:function(){this.model.set("open",0)},show:function(){this.model.set("open",1)},render:function(){var t=this.$el,e=this.pfx,n=(this.ppfx,this.model.toJSON());return n.pfx=this.pfx,n.ppfx=this.ppfx,t.html(this.template(n)),t.attr("class",e+"container"),this.updateOpen(),this}})},function(t,e,n){"use strict";t.exports=function(){var t={},e=n(98),i=n(99),r=n(100),o=n(101),s=n(102),a=n(103),l=n(108),c={},u={},h={},d={};return{getConfig:function(){return t},config:t,EditorView:l,name:"CodeManager",init:function(n){t=n||{};for(var l in e)l in t||(t[l]=e[l]);var c=t.pStylePrefix;return c&&(t.stylePrefix=c+t.stylePrefix),u.html=new i,u.css=new r,u.json=new o,u.js=new s,d.CodeMirror=new a,this.loadDefaultGenerators().loadDefaultViewers(),this},addGenerator:function(t,e){return c[t]=e,this},getGenerator:function(t){return c[t]||null},getGenerators:function(){return c},addViewer:function(t,e){return h[t]=e,this},getViewer:function(t){return h[t]||null},getViewers:function(){return h},updateViewer:function(t,e){t.setContent(e)},getCode:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i.em=t.em;var r=this.getGenerator(n);return r?r.build(e,i):""},loadDefaultGenerators:function(){for(var t in u)this.addGenerator(t,u[t]);return this},loadDefaultViewers:function(){for(var t in d)this.addViewer(t,d[t]);return this}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"cm-",inlineCss:!1}},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({build:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.get("components");return e.exportWrapper?e.wrappesIsBody?""+this.buildModels(n)+"":t.toHTML():this.buildModels(n)},buildModels:function(t){var e="";return t.each(function(t){e+=t.toHTML()}),e}})},function(t,e,n){"use strict";t.exports=n(0).Model.extend({initialize:function(){this.compCls=[],this.ids=[]},buildFromModel:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i="",r=this.em,o=r&&r.getConfig("avoidInlineStyle"),s=t.styleToString(),a=t.get("classes"),l=n.wrappesIsBody,c=t.get("wrapper");if(this.ids.push("#"+t.getId()),a.each(function(t){return e.compCls.push(t.getFullName())}),(!o||c)&&s){var u="#"+t.getId();u=l&&c?"body":u,i=u+"{"+s+"}"}return t.components().each(function(t){return i+=e.buildFromModel(t,n)}),i},build:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.cssc;this.em=n.em||"",this.compCls=[],this.ids=[];var r=this.buildFromModel(t,n);if(i){var o=i.getAll(),s={};o.each(function(t){var n=t.get("mediaText");if(n){var i=s[n];return void(i?i.push(t):s[n]=[t])}r+=e.buildFromRule(t)});for(var a in s){var l="";s[a].forEach(function(t){return l+=e.buildFromRule(t)}),l&&(r+="@media "+a+"{"+l+"}")}}return r},buildFromRule:function(t){var e=this,n="",i=t.selectorsToString(),r=t.selectorsToString({skipAdd:1}),o=void 0;if(t.get("selectors").each(function(t){var n=t.getFullName();(e.compCls.indexOf(n)>=0||e.ids.indexOf(n)>=0)&&(o=1)}),r&&o||t.get("selectorsAdd")){var s=t.styleToString();s&&(n+=i+"{"+s+"}")}return n}})},function(t,e,n){"use strict";(function(e){var i=n(0);t.exports=i.Model.extend({build:function(t){var n=t.toJSON();return this.beforeEach(n),e.each(n,function(t,e){var r=n[e];if(r instanceof i.Model)n[e]=this.build(r);else if(r instanceof i.Collection){var o=r;n[e]=[],o.length&&o.each(function(t,i){n[e][i]=this.build(t)},this)}},this),n},beforeEach:function(t){delete t.status}})}).call(e,n(1))},function(t,e,n){"use strict";(function(e){var i=n(0);t.exports=i.Model.extend({mapModel:function(t){var n="",i=t.get("script"),r=t.get("type"),o=t.get("components"),s=t.getId();if(i){var a=t.get("attributes");a=e.extend({},a,{id:s}),t.set("attributes",a);var l=t.getScriptString();if(t.get("scriptUpdated"))this.mapJs[r+"-"+s]={ids:[s],code:l};else{var c=this.mapJs[r];c?c.ids.push(s):this.mapJs[r]={ids:[s],code:l}}}return o.each(function(t){n+=this.mapModel(t)},this),n},build:function(t){this.mapJs={},this.mapModel(t);var e="";for(var n in this.mapJs){var i=this.mapJs[n];e+="\n var items = document.querySelectorAll('"+("#"+i.ids.join(", #"))+"');\n for (var i = 0, len = items.length; i < len; i++) {\n (function(){"+i.code+"}.bind(items[i]))();\n }"}return e}})}).call(e,n(1))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e-1?t.backUp(i.length-r):i.match(/<\/?$/)&&(t.backUp(i.length),t.match(e,!1)||t.match(i)),n}function n(t){var e=l[t];return e||(l[t]=new RegExp("\\s+"+t+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*"))}function i(t,e){var i=t.match(n(e));return i?/^\s*(.*?)\s*$/.exec(i[2])[1]:""}function r(t,e){return new RegExp((e?"^":"")+"","i")}function o(t,e){for(var n in t)for(var i=e[n]||(e[n]=[]),r=t[n],o=r.length-1;o>=0;o--)i.unshift(r[o])}function s(t,e){for(var n=0;n\s\/]/.test(i.current())&&(a=o.htmlState.tagName&&o.htmlState.tagName.toLowerCase())&&u.hasOwnProperty(a))o.inTag=a+" ";else if(o.inTag&&d&&/>$/.test(i.current())){var f=/^([\S]+) (.*)/.exec(o.inTag);o.inTag=null;var p=">"==i.current()&&s(u[f[1]],f[2]),g=t.getMode(n,p),v=r(f[1],!0),m=r(f[1],!1);o.token=function(t,n){return t.match(v,!1)?(n.token=l,n.localState=n.localMode=null,null):e(t,m,n.localMode.token(t,n.localState))},o.localMode=g,o.localState=t.startState(g,c.indent(o.htmlState,""))}else o.inTag&&(o.inTag+=i.current(),i.eol()&&(o.inTag+=" "));return h}var c=t.getMode(n,{name:"xml",htmlMode:!0,multilineTagIndentFactor:i.multilineTagIndentFactor,multilineTagIndentPastTag:i.multilineTagIndentPastTag}),u={},h=i&&i.tags,d=i&&i.scriptTypes;if(o(a,u),h&&o(h,u),d)for(var f=d.length-1;f>=0;f--)u.script.unshift(["type",d[f].matches,d[f].mode]);return{startState:function(){return{token:l,inTag:null,localMode:null,localState:null,htmlState:t.startState(c)}},copyState:function(e){var n;return e.localState&&(n=t.copyState(e.localMode,e.localState)),{token:e.token,inTag:e.inTag,localMode:e.localMode,localState:n,htmlState:t.copyState(c,e.htmlState)}},token:function(t,e){return e.token(t,e)},indent:function(e,n,i){return!e.localMode||/^\s*<\//.test(n)?c.indent(e.htmlState,n):e.localMode.indent?e.localMode.indent(e.localState,n,i):t.Pass},innerMode:function(t){return{state:t.localState||t.htmlState,mode:t.localMode||c}}}},"xml","javascript","css"),t.defineMIME("text/html","htmlmixed")})},function(t,e,n){!function(t){t(n(6))}(function(t){"use strict";var e={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},n={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1};t.defineMode("xml",function(i,r){function o(t,e){function n(n){return e.tokenize=n,n(t,e)}var i=t.next();if("<"==i)return t.eat("!")?t.eat("[")?t.match("CDATA[")?n(l("atom","]]>")):null:t.match("--")?n(l("comment","--\x3e")):t.match("DOCTYPE",!0,!0)?(t.eatWhile(/[\w\._\-]/),n(c(1))):null:t.eat("?")?(t.eatWhile(/[\w\._\-]/),e.tokenize=l("meta","?>"),"meta"):(E=t.eat("/")?"closeTag":"openTag",e.tokenize=s,"tag bracket");if("&"==i){var r;return r=t.eat("#")?t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";"):t.eatWhile(/[\w\.\-:]/)&&t.eat(";"),r?"atom":"error"}return t.eatWhile(/[^&<]/),null}function s(t,e){var n=t.next();if(">"==n||"/"==n&&t.eat(">"))return e.tokenize=o,E=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return E="equals",null;if("<"==n){e.tokenize=o,e.state=f,e.tagName=e.tagStart=null;var i=e.tokenize(t,e);return i?i+" tag error":"tag error"}return/[\'\"]/.test(n)?(e.tokenize=a(n),e.stringStartCol=t.column(),e.tokenize(t,e)):(t.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function a(t){var e=function(e,n){for(;!e.eol();)if(e.next()==t){n.tokenize=s;break}return"string"};return e.isInAttribute=!0,e}function l(t,e){return function(n,i){for(;!n.eol();){if(n.match(e)){i.tokenize=o;break}n.next()}return t}}function c(t){return function(e,n){for(var i;null!=(i=e.next());){if("<"==i)return n.tokenize=c(t+1),n.tokenize(e,n);if(">"==i){if(1==t){n.tokenize=o;break}return n.tokenize=c(t-1),n.tokenize(e,n)}}return"meta"}}function u(t,e,n){this.prev=t.context,this.tagName=e,this.indent=t.indented,this.startOfLine=n,(k.doNotIndent.hasOwnProperty(e)||t.context&&t.context.noIndent)&&(this.noIndent=!0)}function h(t){t.context&&(t.context=t.context.prev)}function d(t,e){for(var n;;){if(!t.context)return;if(n=t.context.tagName,!k.contextGrabbers.hasOwnProperty(n)||!k.contextGrabbers[n].hasOwnProperty(e))return;h(t)}}function f(t,e,n){return"openTag"==t?(n.tagStart=e.column(),p):"closeTag"==t?g:f}function p(t,e,n){return"word"==t?(n.tagName=e.current(),M="tag",y):(M="error",p)}function g(t,e,n){if("word"==t){var i=e.current();return n.context&&n.context.tagName!=i&&k.implicitlyClosed.hasOwnProperty(n.context.tagName)&&h(n),n.context&&n.context.tagName==i||!1===k.matchClosing?(M="tag",v):(M="tag error",m)}return M="error",m}function v(t,e,n){return"endTag"!=t?(M="error",v):(h(n),f)}function m(t,e,n){return M="error",v(t,e,n)}function y(t,e,n){if("word"==t)return M="attribute",b;if("endTag"==t||"selfcloseTag"==t){var i=n.tagName,r=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==t||k.autoSelfClosers.hasOwnProperty(i)?d(n,i):(d(n,i),n.context=new u(n,i,r==n.indented)),f}return M="error",y}function b(t,e,n){return"equals"==t?x:(k.allowMissing||(M="error"),y(t,e,n))}function x(t,e,n){return"string"==t?w:"word"==t&&k.allowUnquoted?(M="string",y):(M="error",y(t,e,n))}function w(t,e,n){return"string"==t?w:y(t,e,n)}var C=i.indentUnit,k={},S=r.htmlMode?e:n;for(var T in S)k[T]=S[T];for(var T in r)k[T]=r[T];var E,M;return o.isInText=!0,{startState:function(t){var e={tokenize:o,state:f,indented:t||0,tagName:null,tagStart:null,context:null};return null!=t&&(e.baseIndent=t),e},token:function(t,e){if(!e.tagName&&t.sol()&&(e.indented=t.indentation()),t.eatSpace())return null;E=null;var n=e.tokenize(t,e);return(n||E)&&"comment"!=n&&(M=null,e.state=e.state(E||n,t,e),M&&(n="error"==M?n+" error":M)),n},indent:function(e,n,i){var r=e.context;if(e.tokenize.isInAttribute)return e.tagStart==e.indented?e.stringStartCol+1:e.indented+C;if(r&&r.noIndent)return t.Pass;if(e.tokenize!=s&&e.tokenize!=o)return i?i.match(/^(\s*)/)[0].length:0;if(e.tagName)return!1!==k.multilineTagIndentPastTag?e.tagStart+e.tagName.length+2:e.tagStart+C*(k.multilineTagIndentFactor||1);if(k.alignCDATA&&/$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:k.htmlMode?"html":"xml",helperType:k.htmlMode?"html":"xml",skipAttribute:function(t){t.state==x&&(t.state=y)}}}),t.defineMIME("text/xml","xml"),t.defineMIME("application/xml","xml"),t.mimeModes.hasOwnProperty("text/html")||t.defineMIME("text/html",{name:"xml",htmlMode:!0})})},function(t,e,n){!function(t){t(n(6))}(function(t){"use strict";t.defineMode("javascript",function(e,n){function i(t){for(var e,n=!1,i=!1;null!=(e=t.next());){if(!n){if("/"==e&&!i)return;"["==e?i=!0:i&&"]"==e&&(i=!1)}n=!n&&"\\"==e}}function r(t,e,n){return Tt=t,Et=n,e}function o(t,e){var n=t.next();if('"'==n||"'"==n)return e.tokenize=s(n),e.tokenize(t,e);if("."==n&&t.match(/^\d+(?:[eE][+\-]?\d+)?/))return r("number","number");if("."==n&&t.match(".."))return r("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return r(n);if("="==n&&t.eat(">"))return r("=>","operator");if("0"==n&&t.eat(/x/i))return t.eatWhile(/[\da-f]/i),r("number","number");if("0"==n&&t.eat(/o/i))return t.eatWhile(/[0-7]/i),r("number","number");if("0"==n&&t.eat(/b/i))return t.eatWhile(/[01]/i),r("number","number");if(/\d/.test(n))return t.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),r("number","number");if("/"==n)return t.eat("*")?(e.tokenize=a,a(t,e)):t.eat("/")?(t.skipToEnd(),r("comment","comment")):St(t,e,1)?(i(t),t.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),r("regexp","string-2")):(t.eat("="),r("operator","operator",t.current()));if("`"==n)return e.tokenize=l,l(t,e);if("#"==n)return t.skipToEnd(),r("error","error");if(Dt.test(n))return">"==n&&e.lexical&&">"==e.lexical.type||(t.eat("=")?"!"!=n&&"="!=n||t.eat("="):/[<>*+\-]/.test(n)&&(t.eat(n),">"==n&&t.eat(n))),r("operator","operator",t.current());if(Nt.test(n)){t.eatWhile(Nt);var o=t.current();if("."!=e.lastType){if(It.propertyIsEnumerable(o)){var c=It[o];return r(c.type,c.style,o)}if("async"==o&&t.match(/^\s*[\(\w]/,!1))return r("async","keyword",o)}return r("variable","variable",o)}}function s(t){return function(e,n){var i,s=!1;if(At&&"@"==e.peek()&&e.match(_t))return n.tokenize=o,r("jsonld-keyword","meta");for(;null!=(i=e.next())&&(i!=t||s);)s=!s&&"\\"==i;return s||(n.tokenize=o),r("string","string")}}function a(t,e){for(var n,i=!1;n=t.next();){if("/"==n&&i){e.tokenize=o;break}i="*"==n}return r("comment","comment")}function l(t,e){for(var n,i=!1;null!=(n=t.next());){if(!i&&("`"==n||"$"==n&&t.eat("{"))){e.tokenize=o;break}i=!i&&"\\"==n}return r("quasi","string-2",t.current())}function c(t,e){e.fatArrowAt&&(e.fatArrowAt=null);var n=t.string.indexOf("=>",t.start);if(!(n<0)){if(Lt){var i=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(t.string.slice(t.start,n));i&&(n=i.index)}for(var r=0,o=!1,s=n-1;s>=0;--s){var a=t.string.charAt(s),l=Ft.indexOf(a);if(l>=0&&l<3){if(!r){++s;break}if(0==--r){"("==a&&(o=!0);break}}else if(l>=3&&l<6)++r;else if(Nt.test(a))o=!0;else{if(/["'\/]/.test(a))return;if(o&&!r){++s;break}}}o&&!r&&(e.fatArrowAt=s)}}function u(t,e,n,i,r,o){this.indented=t,this.column=e,this.type=n,this.prev=r,this.info=o,null!=i&&(this.align=i)}function h(t,e){for(var n=t.localVars;n;n=n.next)if(n.name==e)return!0;for(var i=t.context;i;i=i.prev)for(var n=i.vars;n;n=n.next)if(n.name==e)return!0}function d(t,e,n,i,r){var o=t.cc;for($t.state=t,$t.stream=r,$t.marked=null,$t.cc=o,$t.style=e,t.lexical.hasOwnProperty("align")||(t.lexical.align=!0);;){if((o.length?o.pop():Ot?C:w)(n,i)){for(;o.length&&o[o.length-1].lex;)o.pop()();return $t.marked?$t.marked:"variable"==n&&h(t,i)?"variable-2":e}}}function f(){for(var t=arguments.length-1;t>=0;t--)$t.cc.push(arguments[t])}function p(){return f.apply(null,arguments),!0}function g(t){function e(e){for(var n=e;n;n=n.next)if(n.name==t)return!0;return!1}var i=$t.state;if($t.marked="def",i.context){if(e(i.localVars))return;i.localVars={name:t,next:i.localVars}}else{if(e(i.globalVars))return;n.globalVars&&(i.globalVars={name:t,next:i.globalVars})}}function v(){$t.state.context={prev:$t.state.context,vars:$t.state.localVars},$t.state.localVars=Rt}function m(){$t.state.localVars=$t.state.context.vars,$t.state.context=$t.state.context.prev}function y(t,e){var n=function(){var n=$t.state,i=n.indented;if("stat"==n.lexical.type)i=n.lexical.indented;else for(var r=n.lexical;r&&")"==r.type&&r.align;r=r.prev)i=r.indented;n.lexical=new u(i,$t.stream.column(),t,null,n.lexical,e)};return n.lex=!0,n}function b(){var t=$t.state;t.lexical.prev&&(")"==t.lexical.type&&(t.indented=t.lexical.indented),t.lexical=t.lexical.prev)}function x(t){function e(n){return n==t?p():";"==t?f():p(e)}return e}function w(t,e){return"var"==t?p(y("vardef",e.length),J,x(";"),b):"keyword a"==t?p(y("form"),S,w,b):"keyword b"==t?p(y("form"),w,b):"keyword d"==t?$t.stream.match(/^\s*$/,!1)?p():p(y("stat"),E,x(";"),b):"debugger"==t?p(x(";")):"{"==t?p(y("}"),B,b):";"==t?p():"if"==t?("else"==$t.state.lexical.info&&$t.state.cc[$t.state.cc.length-1]==b&&$t.state.cc.pop()(),p(y("form"),S,w,b,nt)):"function"==t?p(lt):"for"==t?p(y("form"),it,w,b):"variable"==t?Lt&&"type"==e?($t.marked="keyword",p(U,x("operator"),U,x(";"))):Lt&&"declare"==e?($t.marked="keyword",p(w)):p(y("stat"),F):"switch"==t?p(y("form"),S,x("{"),y("}","switch"),B,b,b):"case"==t?p(C,x(":")):"default"==t?p(x(":")):"catch"==t?p(y("form"),v,x("("),ct,x(")"),w,b,m):"class"==t?p(y("form"),ht,b):"export"==t?p(y("stat"),gt,b):"import"==t?p(y("stat"),mt,b):"module"==t?p(y("form"),Z,x("{"),y("}"),B,b,b):"async"==t?p(w):"@"==e?p(C,w):f(y("stat"),C,x(";"),b)}function C(t){return T(t,!1)}function k(t){return T(t,!0)}function S(t){return"("!=t?f():p(y(")"),C,x(")"),b)}function T(t,e){if($t.state.fatArrowAt==$t.stream.start){var n=e?N:L;if("("==t)return p(v,y(")"),H(ct,")"),b,x("=>"),n,m);if("variable"==t)return f(v,Z,x("=>"),n,m)}var i=e?P:M;return zt.hasOwnProperty(t)?p(i):"function"==t?p(lt,i):"class"==t?p(y("form"),ut,b):"keyword c"==t||"async"==t?p(e?k:C):"("==t?p(y(")"),E,x(")"),b,i):"operator"==t||"spread"==t?p(e?k:C):"["==t?p(y("]"),Ct,b,i):"{"==t?j($,"}",null,i):"quasi"==t?f(A,i):"new"==t?p(I(e)):p()}function E(t){return t.match(/[;\}\)\],]/)?f():f(C)}function M(t,e){return","==t?p(C):P(t,e,!1)}function P(t,e,n){var i=0==n?M:P,r=0==n?C:k;return"=>"==t?p(v,n?N:L,m):"operator"==t?/\+\+|--/.test(e)||Lt&&"!"==e?p(i):"?"==e?p(C,x(":"),r):p(r):"quasi"==t?f(A,i):";"!=t?"("==t?j(k,")","call",i):"."==t?p(z,i):"["==t?p(y("]"),E,x("]"),b,i):Lt&&"as"==e?($t.marked="keyword",p(U,i)):"regexp"==t?($t.state.lastType=$t.marked="operator",$t.stream.backUp($t.stream.pos-$t.stream.start-1),p(r)):void 0:void 0}function A(t,e){return"quasi"!=t?f():"${"!=e.slice(e.length-2)?p(A):p(C,O)}function O(t){if("}"==t)return $t.marked="string-2",$t.state.tokenize=l,p(A)}function L(t){return c($t.stream,$t.state),f("{"==t?w:C)}function N(t){return c($t.stream,$t.state),f("{"==t?w:k)}function I(t){return function(e){return"."==e?p(t?_:D):"variable"==e&&Lt?p(X,t?P:M):f(t?k:C)}}function D(t,e){if("target"==e)return $t.marked="keyword",p(M)}function _(t,e){if("target"==e)return $t.marked="keyword",p(P)}function F(t){return":"==t?p(b,w):f(M,x(";"),b)}function z(t){if("variable"==t)return $t.marked="property",p()}function $(t,e){if("async"==t)return $t.marked="property",p($);if("variable"==t||"keyword"==$t.style){if($t.marked="property","get"==e||"set"==e)return p(R);var n;return Lt&&$t.state.fatArrowAt==$t.stream.start&&(n=$t.stream.match(/^\s*:\s*/,!1))&&($t.state.fatArrowAt=$t.stream.pos+n[0].length),p(V)}return"number"==t||"string"==t?($t.marked=At?"property":$t.style+" property",p(V)):"jsonld-keyword"==t?p(V):"modifier"==t?p($):"["==t?p(C,x("]"),V):"spread"==t?p(k,V):"*"==e?($t.marked="keyword",p($)):":"==t?f(V):void 0}function R(t){return"variable"!=t?f(V):($t.marked="property",p(lt))}function V(t){return":"==t?p(k):"("==t?f(lt):void 0}function H(t,e,n){function i(r,o){if(n?n.indexOf(r)>-1:","==r){var s=$t.state.lexical;return"call"==s.info&&(s.pos=(s.pos||0)+1),p(function(n,i){return n==e||i==e?f():f(t)},i)}return r==e||o==e?p():p(x(e))}return function(n,r){return n==e||r==e?p():f(t,i)}}function j(t,e,n){for(var i=3;i"==t)return p(U)}function K(t,e){return"variable"==t||"keyword"==$t.style?($t.marked="property",p(K)):"?"==e?p(K):":"==t?p(U):"["==t?p(C,W,x("]"),K):void 0}function G(t){return"variable"==t?p(G):":"==t?p(U):void 0}function Y(t,e){return"<"==e?p(y(">"),H(U,">"),b,Y):"|"==e||"."==t?p(U):"["==t?p(x("]"),Y):"extends"==e?p(U):void 0}function X(t,e){if("<"==e)return p(y(">"),H(U,">"),b,Y)}function J(){return f(Z,W,tt,et)}function Z(t,e){return"modifier"==t?p(Z):"variable"==t?(g(e),p()):"spread"==t?p(Z):"["==t?j(Z,"]"):"{"==t?j(Q,"}"):void 0}function Q(t,e){return"variable"!=t||$t.stream.match(/^\s*:/,!1)?("variable"==t&&($t.marked="property"),"spread"==t?p(Z):"}"==t?f():p(x(":"),Z,tt)):(g(e),p(tt))}function tt(t,e){if("="==e)return p(k)}function et(t){if(","==t)return p(J)}function nt(t,e){if("keyword b"==t&&"else"==e)return p(y("form","else"),w,b)}function it(t){if("("==t)return p(y(")"),rt,x(")"),b)}function rt(t){return"var"==t?p(J,x(";"),st):";"==t?p(st):"variable"==t?p(ot):f(C,x(";"),st)}function ot(t,e){return"in"==e||"of"==e?($t.marked="keyword",p(C)):p(M,st)}function st(t,e){return";"==t?p(at):"in"==e||"of"==e?($t.marked="keyword",p(C)):f(C,x(";"),at)}function at(t){")"!=t&&p(C)}function lt(t,e){return"*"==e?($t.marked="keyword",p(lt)):"variable"==t?(g(e),p(lt)):"("==t?p(v,y(")"),H(ct,")"),b,W,w,m):Lt&&"<"==e?p(y(">"),H(U,">"),b,lt):void 0}function ct(t,e){return"@"==e&&p(C,ct),"spread"==t||"modifier"==t?p(ct):f(Z,W,tt)}function ut(t,e){return"variable"==t?ht(t,e):dt(t,e)}function ht(t,e){if("variable"==t)return g(e),p(dt)}function dt(t,e){return"<"==e?p(y(">"),H(U,">"),b,dt):"extends"==e||"implements"==e||Lt&&","==t?p(Lt?U:C,dt):"{"==t?p(y("}"),ft,b):void 0}function ft(t,e){return"modifier"==t||"async"==t||"variable"==t&&("static"==e||"get"==e||"set"==e)&&$t.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?($t.marked="keyword",p(ft)):"variable"==t||"keyword"==$t.style?($t.marked="property",p(Lt?pt:lt,ft)):"["==t?p(C,x("]"),Lt?pt:lt,ft):"*"==e?($t.marked="keyword",p(ft)):";"==t?p(ft):"}"==t?p():"@"==e?p(C,ft):void 0}function pt(t,e){return"?"==e?p(pt):":"==t?p(U,tt):"="==e?p(k):f(lt)}function gt(t,e){return"*"==e?($t.marked="keyword",p(wt,x(";"))):"default"==e?($t.marked="keyword",p(C,x(";"))):"{"==t?p(H(vt,"}"),wt,x(";")):f(w)}function vt(t,e){return"as"==e?($t.marked="keyword",p(x("variable"))):"variable"==t?f(k,vt):void 0}function mt(t){return"string"==t?p():f(yt,bt,wt)}function yt(t,e){return"{"==t?j(yt,"}"):("variable"==t&&g(e),"*"==e&&($t.marked="keyword"),p(xt))}function bt(t){if(","==t)return p(yt,bt)}function xt(t,e){if("as"==e)return $t.marked="keyword",p(yt)}function wt(t,e){if("from"==e)return $t.marked="keyword",p(C)}function Ct(t){return"]"==t?p():f(H(k,"]"))}function kt(t,e){return"operator"==t.lastType||","==t.lastType||Dt.test(e.charAt(0))||/[,.]/.test(e.charAt(0))}function St(t,e,n){return e.tokenize==o&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(e.lastType)||"quasi"==e.lastType&&/\{\s*$/.test(t.string.slice(0,t.pos-(n||0)))}var Tt,Et,Mt=e.indentUnit,Pt=n.statementIndent,At=n.jsonld,Ot=n.json||At,Lt=n.typescript,Nt=n.wordCharacters||/[\w$\xa1-\uffff]/,It=function(){function t(t){return{type:t,style:"keyword"}}var e=t("keyword a"),n=t("keyword b"),i=t("keyword c"),r=t("keyword d"),o=t("operator"),s={type:"atom",style:"atom"},a={if:t("if"),while:e,with:e,else:n,do:n,try:n,finally:n,return:r,break:r,continue:r,new:t("new"),delete:i,void:i,throw:i,debugger:t("debugger"),var:t("var"),const:t("var"),let:t("var"),function:t("function"),catch:t("catch"),for:t("for"),switch:t("switch"),case:t("case"),default:t("default"),in:o,typeof:o,instanceof:o,true:s,false:s,null:s,undefined:s,NaN:s,Infinity:s,this:t("this"),class:t("class"),super:t("atom"),yield:i,export:t("export"),import:t("import"),extends:i,await:i};if(Lt){var l={type:"variable",style:"type"},c={interface:t("class"),implements:i,namespace:i,module:t("module"),enum:t("module"),public:t("modifier"),private:t("modifier"),protected:t("modifier"),abstract:t("modifier"),readonly:t("modifier"),string:l,number:l,boolean:l,any:l};for(var u in c)a[u]=c[u]}return a}(),Dt=/[+\-*&%=<>!?|~^@]/,_t=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,Ft="([{}])",zt={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,"jsonld-keyword":!0},$t={state:null,column:null,marked:null,cc:null},Rt={name:"this",next:{name:"arguments"}};return b.lex=!0,{startState:function(t){var e={tokenize:o,lastType:"sof",cc:[],lexical:new u((t||0)-Mt,0,"block",!1),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:t||0};return n.globalVars&&"object"==typeof n.globalVars&&(e.globalVars=n.globalVars),e},token:function(t,e){if(t.sol()&&(e.lexical.hasOwnProperty("align")||(e.lexical.align=!1),e.indented=t.indentation(),c(t,e)),e.tokenize!=a&&t.eatSpace())return null;var n=e.tokenize(t,e);return"comment"==Tt?n:(e.lastType="operator"!=Tt||"++"!=Et&&"--"!=Et?Tt:"incdec",d(e,n,Tt,Et,t))},indent:function(e,i){if(e.tokenize==a)return t.Pass;if(e.tokenize!=o)return 0;var r,s=i&&i.charAt(0),l=e.lexical;if(!/^\s*else\b/.test(i))for(var c=e.cc.length-1;c>=0;--c){var u=e.cc[c];if(u==b)l=l.prev;else if(u!=nt)break}for(;("stat"==l.type||"form"==l.type)&&("}"==s||(r=e.cc[e.cc.length-1])&&(r==M||r==P)&&!/^[,\.=+\-*:?[\(]/.test(i));)l=l.prev;Pt&&")"==l.type&&"stat"==l.prev.type&&(l=l.prev);var h=l.type,d=s==h;return"vardef"==h?l.indented+("operator"==e.lastType||","==e.lastType?l.info+1:0):"form"==h&&"{"==s?l.indented:"form"==h?l.indented+Mt:"stat"==h?l.indented+(kt(e,i)?Pt||Mt:0):"switch"!=l.info||d||0==n.doubleIndentSwitch?l.align?l.column+(d?0:1):l.indented+(d?0:Mt):l.indented+(/^(?:case|default)\b/.test(i)?Mt:2*Mt)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:Ot?null:"/*",blockCommentEnd:Ot?null:"*/",blockCommentContinue:Ot?null:" * ",lineComment:Ot?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:Ot?"json":"javascript",jsonldMode:At,jsonMode:Ot,expressionAllowed:St,skipExpression:function(t){var e=t.cc[t.cc.length-1];e!=C&&e!=k||t.cc.pop()}}}),t.registerHelper("wordChars","javascript",/[\w$]/),t.defineMIME("text/javascript","javascript"),t.defineMIME("text/ecmascript","javascript"),t.defineMIME("application/javascript","javascript"),t.defineMIME("application/x-javascript","javascript"),t.defineMIME("application/ecmascript","javascript"),t.defineMIME("application/json",{name:"javascript",json:!0}),t.defineMIME("application/x-json",{name:"javascript",json:!0}),t.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),t.defineMIME("text/typescript",{name:"javascript",typescript:!0}),t.defineMIME("application/typescript",{name:"javascript",typescript:!0})})},function(t,e,n){!function(t){t(n(6))}(function(t){t.extendMode("css",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(t,e){return/^[;{}]$/.test(e)}}),t.extendMode("javascript",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(t,e,n,i){return this.jsonMode?/^[\[,{]$/.test(e)||/^}/.test(n):(";"!=e||!i.lexical||")"!=i.lexical.type)&&(/^[;{}]$/.test(e)&&!/^;/.test(n))}});var e=/^(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)$/;t.extendMode("xml",{commentStart:"\x3c!--",commentEnd:"--\x3e",newlineAfterToken:function(t,n,i,r){var o=!1;return"html"==this.configuration&&(o=!!r.context&&e.test(r.context.tagName)),!o&&("tag"==t&&/>$/.test(n)&&r.context||/^-1&&a>-1&&a>s&&(t=t.substr(0,s)+t.substring(s+o.commentStart.length,a)+t.substr(a+o.commentEnd.length)),r.replaceRange(t,n,i)}})}),t.defineExtension("autoIndentRange",function(t,e){var n=this;this.operation(function(){for(var i=t.line;i<=e.line;i++)n.indentLine(i,"smart")})}),t.defineExtension("autoFormatRange",function(e,n){function i(){c+="\n",h=!0,++u}for(var r=this,o=r.getMode(),s=r.getRange(e,n).split("\n"),a=t.copyState(o,r.getTokenAt(e).state),l=r.getOption("tabSize"),c="",u=0,h=0===e.ch,d=0;d\n \t
<%= label %>
\n \t
\n '),initialize:function(t){this.config=t.config||{},this.pfx=this.config.stylePrefix},render:function(){var t=this.model.toJSON();return t.pfx=this.pfx,this.$el.html(this.template(t)),this.$el.attr("class",this.pfx+"editor-c"),this.$el.find("#"+this.pfx+"code").append(this.model.get("input")),this}})}).call(e,n(1))},function(t,e,n){"use strict";t.exports=function(){var t,e,i={},r=n(110),o=n(27),s=n(112),a=(n(29),n(114));return{name:"Panels",init:function(n){i=n||{};for(var o in r)o in i||(i[o]=r[o]);var l=i.pStylePrefix;return l&&(i.stylePrefix=l+i.stylePrefix),t=new s(i.defaults),e=new a({collection:t,config:i}),this},getPanels:function(){return t},getPanelsEl:function(){return e.el},addPanel:function(e){return t.add(e)},removePanel:function(e){return t.remove(e)},getPanel:function(e){var n=t.where({id:e});return n.length?n[0]:null},addButton:function(t,e){var n=this.getPanel(t);return n?n.get("buttons").add(e):null},removeButton:function(t,e){var n=this.getPanel(t);return n&&n.get("buttons").remove(e)},getButton:function(t,e){var n=this.getPanel(t);if(n){var i=n.get("buttons").where({id:e});return i.length?i[0]:null}return null},render:function(){return e.render().el},active:function(){this.getPanels().each(function(t){t.get("buttons").each(function(t){t.get("active")&&t.trigger("updateActive")})})},disableButtons:function(){this.getPanels().each(function(t){t.get("buttons").each(function(t){t.get("disable")&&t.trigger("change:disable")})})},Panel:o}}},function(t,e,n){"use strict";var i="sw-visibility",r="export-template",o="open-layers",s="open-blocks",a="fullscreen",l="preview";t.exports={stylePrefix:"pn-",defaults:[{id:"commands",buttons:[{}]},{id:"options",buttons:[{active:!0,id:i,className:"fa fa-square-o",command:i,context:i,attributes:{title:"View components"}},{id:l,className:"fa fa-eye",command:l,context:l,attributes:{title:"Preview"}},{id:a,className:"fa fa-arrows-alt",command:a,context:a,attributes:{title:"Fullscreen"}},{id:r,className:"fa fa-code",command:r,attributes:{title:"View code"}}]},{id:"views",buttons:[{id:"open-sm",className:"fa fa-paint-brush",command:"open-sm",active:!0,attributes:{title:"Open Style Manager"}},{id:"open-tm",className:"fa fa-cog",command:"open-tm",attributes:{title:"Settings"}},{id:o,className:"fa fa-bars",command:o,attributes:{title:"Open Layer Manager"}},{id:s,className:"fa fa-th-large",command:s,attributes:{title:"Open Blocks"}}]}],em:null,delayBtnsShow:300}},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{id:"",className:"",command:"",context:"",buttons:[],attributes:{},options:{},active:!1,dragDrop:!1,runDefaultCommand:!0,stopDefaultCommand:!1,disable:!1},initialize:function(t){if(this.get("buttons").length){var e=n(28);this.set("buttons",new e(this.get("buttons")))}}})},function(t,e,n){"use strict";var i=n(0),r=n(27);t.exports=i.Collection.extend({model:r})},function(t,e,n){"use strict";(function(e,i){var r=n(1),o=e.$;t.exports=e.View.extend({tagName:"span",initialize:function(t){i.bindAll(this,"startTimer","stopTimer","showButtons","hideButtons","closeOnKeyPress","onDrop","initSorter","stopDrag");var e=this.model.get("className");this.config=t.config||{},this.em=this.config.em||{};var n=this.config.stylePrefix||"",r=this.config.pStylePrefix||"";this.pfx=n,this.ppfx=this.config.pStylePrefix||"",this.id=n+this.model.get("id"),this.activeCls=n+"active "+r+"four-color",this.disableCls=n+"active",this.btnsVisCls=n+"visible",this.parentM=t.parentM||null,this.className=n+"btn"+(e?" "+e:""),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.listenTo(this.model,"change:disable",this.updateDisable),this.model.get("buttons").length&&(this.$el.on("mousedown",this.startTimer),this.$el.append(o("
",{class:n+"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 t=this.em.Canvas;this.canvasEl=t.getBody(),this.sorter=new this.em.Utils.Sorter({container:this.canvasEl,placer:t.getPlacerEl(),containerSel:"*",itemSel:"*",pfx:this.ppfx,onMove:this.onDrag,onEndMove:this.onDrop,document:t.getFrameEl().contentDocument,direction:"a",wmargin:1,nested:1});var e=t.getOffset();this.sorter.offTop=e.top,this.sorter.offLeft=e.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",o(document).on("mouseup",this.stopDrag)},stopDrag:function(){o(document).off("mouseup",this.stopDrag),this.sorter.endMove()},onDrag:function(t){},onDrop:function(t){this.canvasEl.style.cursor="default"},updateClassName:function(){var t=this.model.get("className");this.$el.attr("class",this.pfx+"btn"+(t?" "+t:""))},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),o(document).on("mouseup",this.stopTimer)},stopTimer:function(){o(document).off("mouseup",this.stopTimer),this.timeout&&clearTimeout(this.timeout)},showButtons:function(){clearTimeout(this.timeout),this.model.set("bntsVis",!0),o(document).on("mousedown",this.hideButtons),o(document).on("keypress",this.closeOnKeyPress)},hideButtons:function(t){t&&o(t.target).trigger("click"),this.model.set("bntsVis",!1),o(document).off("mousedown",this.hideButtons),o(document).off("keypress",this.closeOnKeyPress)},closeOnKeyPress:function(t){27==(t.which||t.keyCode)&&this.hideButtons()},updateActive:function(){var t=this.model,e=t.get("context"),n=this.parentM,i={},o=this.em&&this.em.get?this.em.get("Editor"):null,s=t.get("command");this.commands&&(0,r.isString)(s)?i=this.commands.get(s)||{}:(0,r.isFunction)(s)?i={run:s}:null!==s&&(0,r.isObject)(s)&&(i=s),t.get("active")?(t.collection.deactivateAll(e),t.set("active",!0,{silent:!0}).trigger("checkActive"),n&&n.set("active",!0,{silent:!0}).trigger("checkActive"),i.run&&(i.run(o,t,t.get("options")),o.trigger("run:"+s)),!i.stop&&t.set("active",!1)):(this.$el.removeClass(this.activeCls),t.collection.deactivateAll(e),n&&n.set("active",!1,{silent:!0}).trigger("checkActive"),i.stop&&(i.stop(o,t,t.get("options")),o.trigger("stop:"+s)))},updateDisable:function(){this.model.get("disable")?this.$el.addClass(this.disableCls):this.$el.removeClass(this.disableCls)},checkActive:function(){this.model.get("active")?this.$el.addClass(this.activeCls):this.$el.removeClass(this.activeCls)},clicked:function(t){this.model.get("bntsVis")||this.model.get("disable")||this.toogleActive()},toogleActive:function(){this.parentM&&this.swapParent();var t=this.model.get("active");this.model.set("active",!t);this.em.get("Commands").get("select-comp");t?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 t=n(30),e=new t({collection:this.model.get("buttons"),config:this.config,parentM:this.model});this.$buttons=e.render().$el,this.$buttons.append(o("
",{class:this.pfx+"arrow-l"})),this.$el.append(this.$buttons)}return this}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";var i=n(0),r=n(29);t.exports=i.View.extend({initialize:function(t){this.opt=t||{},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(t){this.addToCollection(t)},addToCollection:function(t,e){var n=e||null,i=new r({model:t,config:this.config}),o=i.render().el,s=t.get("appendTo");if(s){document.querySelector(s).appendChild(o)}else n?n.appendChild(o):this.$el.append(o);return i.initResize(),o},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(e){this.addToCollection(e,t)},this),this.$el.append(t),this.$el.attr("class",this.className),this}})},function(t,e,n){"use strict";var i=n(116),r=function(t){return t&&t.__esModule?t:{default:t}}(i),o=n(2);t.exports=function(){var t={},e=n(117),i=void 0,s=void 0,a=void 0,l=void 0,c=function(){var t=i.style;t.top="-100px",t.left="-100px",t.display="none"};return{customRte:null,name:"RichTextEditor",init:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=n;for(var r in e)r in t||(t[r]=e[r]);var a=t.pStylePrefix;return a&&(t.stylePrefix=a+t.stylePrefix),this.pfx=t.stylePrefix,s=t.actions||[],i=document.createElement("div"),i.className=a+"rte-toolbar "+a+"one-bg",l=this.initRte(document.createElement("div")),(0,o.on)(i,"mousedown",function(t){return t.stopPropagation()}),this},postRender:function(t){var e=t.model.get("Canvas");i.style.pointerEvents="all",c(),e.getToolsEl().appendChild(i)},initRte:function(e){var n=this.pfx,o=i,s=this.actionbar,a=this.actions||t.actions,c={actionbar:n+"actionbar",button:n+"action",active:n+"active"},u=new r.default({el:e,classes:c,actions:a,actionbar:s,actionbarContainer:o});return l&&l.setEl(e),u.actionbar&&(this.actionbar=u.actionbar),u.actions&&(this.actions=u.actions),u},add:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.name=t,l.addAction(e,{sync:1})},get:function(t){var e=void 0;return l.getActions().forEach(function(n){n.name==t&&(e=n)}),e},getAll:function(){return l.getActions()},remove:function(t){var e=this.getAll(),n=this.get(t);if(n){var i=n.btn,r=e.indexOf(n);i.parentNode.removeChild(i),e.splice(r,1)}return n},getToolbarEl:function(){return i},udpatePosition:function(){var e=t.em.get("Canvas"),n=e.getTargetToElementDim(i,a,{event:"rteToolbarPosUpdate"});t.adjustToolbar&&n.top<=n.canvasTop&&(n.top=n.elementTop+n.elementHeight);var r=i.style;r.top=n.top+"px",r.left=n.left+"px"},enable:function(e,n){a=e.el;var r=t.em,o=e.getChildrenContainer(),s=this.customRte;if(i.style.display="",n=s?s.enable(o,n):this.initRte(o).enable(),r){setTimeout(this.udpatePosition.bind(this),0);var l="change:canvasOffset canvasScroll";r.off(l,this.udpatePosition,this),r.on(l,this.udpatePosition,this),r.trigger("rte:enable",e,n)}return n},disable:function(e,n){var i=t.em,r=this.customRte,o=e.getChildrenContainer();r?r.disable(o,n):n&&n.disable(),c(),i&&i.trigger("rte:disable",e,n)}}}},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=Object.assign||function(t){for(var e=1;eB",attributes:{title:"Bold"},result:function(t){return t.exec("bold")}},italic:{name:"italic",icon:"I",attributes:{title:"Italic"},result:function(t){return t.exec("italic")}},underline:{name:"underline",icon:"U",attributes:{title:"Underline"},result:function(t){return t.exec("underline")}},strikethrough:{name:"strikethrough",icon:"S",attributes:{title:"Strike-through"},result:function(t){return t.exec("strikeThrough")}},link:{icon:'⫘',name:"link",attributes:{style:"font-size:1.4rem;padding:0 4px 2px;",title:"Link"},result:function(t){return t.insertHTML(''+t.selection()+"")}}},c=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t);var o=n.el;if(o[a])return o[a];o[a]=this,this.setEl(o),this.updateActiveActions=this.updateActiveActions.bind(this);var s=n.actions||[];s.forEach(function(t,e){"string"==typeof t?t=l[t]:l[t.name]&&(t=r({},l[t.name],t)),s[e]=t});var c=s.length?s:Object.keys(l).map(function(t){return l[t]});n.classes=r({actionbar:"actionbar",button:"action",active:"active"},n.classes);var u=n.classes,h=n.actionbar;if(this.actionbar=h,this.settings=n,this.classes=u,this.actions=c,!h){var d=n.actionbarContainer;h=document.createElement("div"),h.className=u.actionbar,d.appendChild(h),this.actionbar=h,c.forEach(function(t){return e.addAction(t)})}return n.styleWithCSS&&this.exec("styleWithCSS"),this.syncActions(),this}return o(t,[{key:"setEl",value:function(t){this.el=t,this.doc=t.ownerDocument}},{key:"updateActiveActions",value:function(){var t=this;this.getActions().forEach(function(e){var n=e.btn,i=e.update,r=t.classes.active,o=e.name,s=t.doc;n.className=n.className.replace(r,"").trim(),s.queryCommandState(o)&&(n.className+=" "+r),i&&i(t,e)})}},{key:"enable",value:function(){return this.enabled?this:(this.actionbarEl().style.display="",this.el.contentEditable=!0,(0,s.on)(this.el,"mouseup keyup",this.updateActiveActions),this.syncActions(),this.updateActiveActions(),this.el.focus(),this.enabled=1,this)}},{key:"disable",value:function(){return this.actionbarEl().style.display="none",this.el.contentEditable=!1,(0,s.off)(this.el,"mouseup keyup",this.updateActiveActions),this.enabled=0,this}},{key:"syncActions",value:function(){var t=this;this.getActions().forEach(function(e){var n=e.event||"click";e.btn["on"+n]=function(n){e.result(t,e),t.updateActiveActions()}})}},{key:"addAction",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.sync,i=document.createElement("span"),r=t.icon,o=t.attributes||{};i.className=this.classes.button,t.btn=i;for(var s in o)i.setAttribute(s,o[s]);"string"==typeof r?i.innerHTML=r:i.appendChild(r),this.actionbarEl().appendChild(i),n&&(this.actions.push(t),this.syncActions())}},{key:"getActions",value:function(){return this.actions}},{key:"selection",value:function(){return this.doc.getSelection()}},{key:"exec",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.doc.execCommand(t,!1,e)}},{key:"actionbarEl",value:function(){return this.actionbar}},{key:"insertHTML",value:function(t){var e=void 0,n=this.doc,i=n.getSelection();if(i&&i.rangeCount){var r=n.createElement("div"),o=i.getRangeAt(0);o.deleteContents(),r.innerHTML=t,Array.prototype.slice.call(r.childNodes).forEach(function(t){o.insertNode(t),e=t}),i.removeAllRanges(),i.addRange(o),this.el.focus()}}}]),t}();e.default=c},function(t,e,n){"use strict";t.exports={stylePrefix:"rte-",adjustToolbar:1,actions:["bold","italic","underline","strikethrough","link"]}},function(t,e,n){"use strict";t.exports={stylePrefix:"sm-",sectors:[],textNoElement:"Select an element before using Style Manager",hideNotStylable:!0,highlightChanged:!0,highlightComputed:!0,showComputed:!0,clearProperties:0,avoidComputed:["width","height"]}},function(t,e,n){"use strict";var i=n(120);t.exports=n(0).Collection.extend({model:i})},function(t,e,n){"use strict";var i=n(1),r=n(0),o=n(11),s=n(129);t.exports=r.Model.extend({defaults:{id:"",name:"",open:!0,buildProps:"",extendBuilded:1,properties:[]},initialize:function(t){var e=t||{},n=[],i=this.buildProperties(e.buildProps);!this.get("id")&&this.set("id",this.get("name")),n=i?this.extendProperties(i):this.get("properties");var r=new o(n);r.sector=this,this.set("properties",r)},extendProperties:function(t,e,n){for(var r=t.length,o=e||this.get("properties"),s=this.get("extendBuilded"),a=[],l=0,c=o.length;l')}else{o.push(t("
").append(t('').attr("title",r.noColorSelectedText)).html())}}return"
"+o.join("")+"
"}function r(){for(var t=0;t1&&(delete window.localStorage[B],t.each(e,function(t,e){p(e)}))}catch(t){}try{vt=window.localStorage[B].split(";")}catch(t){}}}function p(e){if(j){var n=st(e).toRgbString();if(!gt[n]&&-1===t.inArray(n,vt))for(vt.push(n);vt.length>mt;)vt.shift();if(B&&window.localStorage)try{window.localStorage[B]=vt.join(";")}catch(t){}}}function g(){var t=[];if(V.showPalette)for(var e=0;eMath.abs(e-r);bt=o?"x":"y"}}else bt=null;var s=!bt||"x"===bt,a=!bt||"y"===bt;s&&(ut=parseFloat(t/tt)),a&&(ht=parseFloat((et-e)/et)),Yt=!1,V.showAlpha||(dt=1),O()},y,b),Ut?(M(Ut),L(),Kt=V.preferredFormat||st(Ut).format,p(Ut)):L(),H&&C();var i=G?"mousedown.spectrum":"click.spectrum touchstart.spectrum";It.delegate(".sp-thumb-el",i,e),Dt.delegate(".sp-thumb-el:nth-child(1)",i,{ignore:!0},e)}();var Jt={show:C,hide:T,toggle:w,reflow:D,option:F,enable:z,disable:$,offset:R,set:function(t){M(t),I()},get:P,destroy:_,container:kt};return Jt.id=K.push(Jt)-1,Jt}function a(e,n){var i=e.outerWidth(),r=e.outerHeight(),o=n.outerHeight(),s=e[0].ownerDocument,a=s.documentElement,l=a.clientWidth,c=a.clientHeight,u=t(s).scrollLeft(),h=t(s).scrollTop(),d=l+u,f=c+h,p=n.offset();return p.top+=o,p.left-=Math.min(p.left,p.left+i>d&&d>i?Math.abs(p.left+i-d):0),p.top-=Math.min(p.top,p.top+r>f&&f>r?Math.abs(r+o-0):0),p}function l(){}function c(t){t.stopPropagation()}function u(t,e){var n=Array.prototype.slice,i=n.call(arguments,2);return function(){return t.apply(e,i.concat(n.call(arguments)))}}function h(e,n,i,r){function o(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}function s(t){if(u){if(G&&c.documentMode<9&&!t.button)return l();var i=t.originalEvent&&t.originalEvent.touches&&t.originalEvent.touches[0],r=i&&i.pageX||t.pageX,s=i&&i.pageY||t.pageY,a=Math.max(0,Math.min(r-h.left,f)),g=Math.max(0,Math.min(s-h.top,d));p&&o(t),n.apply(e,[a,g,t])}}function a(n){(n.which?3==n.which:2==n.button)||u||!1!==i.apply(e,arguments)&&(u=!0,d=t(e).height(),f=t(e).width(),h=t(e).offset(),t(c).bind(g),t(c.body).addClass("sp-dragging"),s(n),o(n))}function l(){u&&(t(c).unbind(g),t(c.body).removeClass("sp-dragging"),setTimeout(function(){r.apply(e,arguments)},0)),u=!1}n=n||function(){},i=i||function(){},r=r||function(){};var c=document,u=!1,h={},d=0,f=0,p="ontouchstart"in window,g={};g.selectstart=o,g.dragstart=o,g["touchmove mousemove"]=s,g["touchend mouseup"]=l,t(e).bind("touchstart mousedown",a)}function d(t,e,n){var i;return function(){var r=this,o=arguments,s=function(){i=null,t.apply(r,o)};n&&clearTimeout(i),!n&&i||(i=setTimeout(s,e))}}function f(){return t.fn.spectrum.inputTypeColorSupport()}function p(t){var n={r:0,g:0,b:0},i=1,r=!1,o=!1;return"string"==typeof t&&(t=U(t)),"object"==(void 0===t?"undefined":e(t))&&(t.hasOwnProperty("r")&&t.hasOwnProperty("g")&&t.hasOwnProperty("b")?(n=g(t.r,t.g,t.b),r=!0,o="%"===String(t.r).substr(-1)?"prgb":"rgb"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("v")?(t.s=j(t.s),t.v=j(t.v),n=b(t.h,t.s,t.v),r=!0,o="hsv"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("l")&&(t.s=j(t.s),t.l=j(t.l),n=m(t.h,t.s,t.l),r=!0,o="hsl"),t.hasOwnProperty("a")&&(i=t.a)),i=_(i),{ok:r,format:t.format||o,r:it(255,rt(n.r,0)),g:it(255,rt(n.g,0)),b:it(255,rt(n.b,0)),a:i}}function g(t,e,n){return{r:255*F(t,255),g:255*F(e,255),b:255*F(n,255)}}function v(t,e,n){t=F(t,255),e=F(e,255),n=F(n,255);var i,r,o=rt(t,e,n),s=it(t,e,n),a=(o+s)/2;if(o==s)i=r=0;else{var l=o-s;switch(r=a>.5?l/(2-o-s):l/(o+s),o){case t:i=(e-n)/l+(e1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}var r,o,s;if(t=F(t,360),e=F(e,100),n=F(n,100),0===e)r=o=s=n;else{var a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;r=i(l,a,t+1/3),o=i(l,a,t),s=i(l,a,t-1/3)}return{r:255*r,g:255*o,b:255*s}}function y(t,e,n){t=F(t,255),e=F(e,255),n=F(n,255);var i,r,o=rt(t,e,n),s=it(t,e,n),a=o,l=o-s;if(r=0===o?0:l/o,o==s)i=0;else{switch(o){case t:i=(e-n)/l+(e>1)+720)%360;--e;)i.h=(i.h+r)%360,o.push(st(i));return o}function D(t,e){e=e||6;for(var n=st(t).toHsv(),i=n.h,r=n.s,o=n.v,s=[],a=1/e;e--;)s.push(st({h:i,s:r,v:o})),o=(o+a)%1;return s}function _(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function F(t,e){R(t)&&(t="100%");var n=V(t);return t=it(e,rt(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),et.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function z(t){return it(1,rt(0,t))}function $(t){return parseInt(t,16)}function R(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function V(t){return"string"==typeof t&&-1!=t.indexOf("%")}function H(t){return 1==t.length?"0"+t:""+t}function j(t){return t<=1&&(t=100*t+"%"),t}function B(t){return Math.round(255*parseFloat(t)).toString(16)}function W(t){return $(t)/255}function U(t){t=t.replace(Z,"").replace(Q,"").toLowerCase();var e=!1;if(at[t])t=at[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=ct.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=ct.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=ct.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=ct.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=ct.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=ct.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=ct.hex8.exec(t))?{a:W(n[1]),r:$(n[2]),g:$(n[3]),b:$(n[4]),format:e?"name":"hex8"}:(n=ct.hex6.exec(t))?{r:$(n[1]),g:$(n[2]),b:$(n[3]),format:e?"name":"hex"}:!!(n=ct.hex3.exec(t))&&{r:$(n[1]+""+n[1]),g:$(n[2]+""+n[2]),b:$(n[3]+""+n[3]),format:e?"name":"hex"}}var q={beforeShow:l,move:l,change:l,show:l,hide:l,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},K=[],G=!!/msie/i.exec(window.navigator.userAgent),Y=function(){function t(t,e){return!!~(""+t).indexOf(e)}var e=document.createElement("div"),n=e.style;return n.cssText="background-color:rgba(0,0,0,.5)",t(n.backgroundColor,"rgba")||t(n.backgroundColor,"hsla")}(),X=["
","
","
▼
","
"].join(""),J=function(){var t="";if(G)for(var e=1;e<=6;e++)t+="
";return["
","
","
","
","","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
",t,"
","
","
","
","
","","
","
","
","","","
","
","
"].join("")}();t.fn.spectrum=function(e,n){if("string"==typeof e){var i=this,r=Array.prototype.slice.call(arguments,1);return this.each(function(){var n=K[t(this).data("spectrum.id")];if(n){var o=n[e];if(!o)throw new Error("Spectrum: no such method: '"+e+"'");"get"==e?i=n.get():"container"==e?i=n.container:"option"==e?i=n.option.apply(n,r):"destroy"==e?(n.destroy(),t(this).removeData("spectrum.id")):o.apply(n,r)}}),i}return this.spectrum("destroy").each(function(){var n=t.extend({},e,t(this).data()),i=s(this,n);t(this).data("spectrum.id",i.id)})},t.fn.spectrum.load=!0,t.fn.spectrum.loadOpts={},t.fn.spectrum.draggable=h,t.fn.spectrum.defaults=q,t.fn.spectrum.inputTypeColorSupport=function e(){if(void 0===e._cachedResult){var n=t("")[0];e._cachedResult="color"===n.type&&""!==n.value}return e._cachedResult},t.spectrum={},t.spectrum.localization={},t.spectrum.palettes={},t.fn.spectrum.processNativeColorInputs=function(){var e=t("input[type=color]");e.length&&!f()&&e.spectrum({preferredFormat:"hex6"})};var Z=/^[\s,#]+/,Q=/\s+$/,tt=0,et=Math,nt=et.round,it=et.min,rt=et.max,ot=et.random,st=function t(e,n){if(e=e||"",n=n||{},e instanceof t)return e;if(!(this instanceof t))return new t(e,n);var i=p(e);this._originalInput=e,this._r=i.r,this._g=i.g,this._b=i.b,this._a=i.a,this._roundA=nt(100*this._a)/100,this._format=n.format||i.format,this._gradientType=n.gradientType,this._r<1&&(this._r=nt(this._r)),this._g<1&&(this._g=nt(this._g)),this._b<1&&(this._b=nt(this._b)),this._ok=i.ok,this._tc_id=tt++};st.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 t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},setAlpha:function(t){return this._a=_(t),this._roundA=nt(100*this._a)/100,this},toHsv:function(){var t=y(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=y(this._r,this._g,this._b),e=nt(360*t.h),n=nt(100*t.s),i=nt(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+i+"%)":"hsva("+e+", "+n+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var t=v(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=v(this._r,this._g,this._b),e=nt(360*t.h),n=nt(100*t.s),i=nt(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+i+"%)":"hsla("+e+", "+n+"%, "+i+"%, "+this._roundA+")"},toHex:function(t){return x(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return w(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:nt(this._r),g:nt(this._g),b:nt(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+nt(this._r)+", "+nt(this._g)+", "+nt(this._b)+")":"rgba("+nt(this._r)+", "+nt(this._g)+", "+nt(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:nt(100*F(this._r,255))+"%",g:nt(100*F(this._g,255))+"%",b:nt(100*F(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+nt(100*F(this._r,255))+"%, "+nt(100*F(this._g,255))+"%, "+nt(100*F(this._b,255))+"%)":"rgba("+nt(100*F(this._r,255))+"%, "+nt(100*F(this._g,255))+"%, "+nt(100*F(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(lt[x(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+w(this._r,this._g,this._b,this._a),n=e,i=this._gradientType?"GradientType = 1, ":"";if(t){n=st(t).toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,i=this._a<1&&this._a>=0;return e||!i||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(T,arguments)},brighten:function(){return this._applyModification(E,arguments)},darken:function(){return this._applyModification(M,arguments)},desaturate:function(){return this._applyModification(C,arguments)},saturate:function(){return this._applyModification(k,arguments)},greyscale:function(){return this._applyModification(S,arguments)},spin:function(){return this._applyModification(P,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(I,arguments)},complement:function(){return this._applyCombination(A,arguments)},monochromatic:function(){return this._applyCombination(D,arguments)},splitcomplement:function(){return this._applyCombination(N,arguments)},triad:function(){return this._applyCombination(O,arguments)},tetrad:function(){return this._applyCombination(L,arguments)}},st.fromRatio=function(t,n){if("object"==(void 0===t?"undefined":e(t))){var i={};for(var r in t)t.hasOwnProperty(r)&&(i[r]="a"===r?t[r]:j(t[r]));t=i}return st(t,n)},st.equals=function(t,e){return!(!t||!e)&&st(t).toRgbString()==st(e).toRgbString()},st.random=function(){return st.fromRatio({r:ot(),g:ot(),b:ot()})},st.mix=function(t,e,n){n=0===n?0:n||50;var i,r=st(t).toRgb(),o=st(e).toRgb(),s=n/100,a=2*s-1,l=o.a-r.a;i=a*l==-1?a:(a+l)/(1+a*l),i=(i+1)/2;var c=1-i,u={r:o.r*i+r.r*c,g:o.g*i+r.g*c,b:o.b*i+r.b*c,a:o.a*s+r.a*(1-s)};return st(u)},st.readability=function(t,e){var n=st(t),i=st(e),r=n.toRgb(),o=i.toRgb(),s=n.getBrightness(),a=i.getBrightness(),l=Math.max(r.r,o.r)-Math.min(r.r,o.r)+Math.max(r.g,o.g)-Math.min(r.g,o.g)+Math.max(r.b,o.b)-Math.min(r.b,o.b);return{brightness:Math.abs(s-a),color:l}},st.isReadable=function(t,e){var n=st.readability(t,e);return n.brightness>125&&n.color>500},st.mostReadable=function(t,e){for(var n=null,i=0,r=!1,o=0;o125&&s.color>500,l=s.brightness/125*3+s.color/500;(a&&!r||a&&r&&l>i||!a&&!r&&l>i)&&(r=a,i=l,n=st(e[o]))}return n};var at=st.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"},lt=st.hexNames=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}(at),ct=function(){var t="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",e="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{rgb:new RegExp("rgb"+e),rgba:new RegExp("rgba"+n),hsl:new RegExp("hsl"+e),hsla:new RegExp("hsla"+n),hsv:new RegExp("hsv"+e),hsva:new RegExp("hsva"+n),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=st,t(function(){t.fn.spectrum.load&&t.fn.spectrum.processNativeColorInputs()})}(t.$)}()}).call(e,n(0))},function(t,e,n){"use strict";var i=n(0),r=n(126);t.exports=i.View.extend({initialize:function(t){this.config=t.config||{},this.stackModel=t.stackModel,this.preview=t.preview,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.propsConfig=t.propsConfig;var e=this.pfx,n=this.ppfx,i=this.collection;this.className=e+"layers "+n+"field",this.listenTo(i,"add",this.addTo),this.listenTo(i,"deselectAll",this.deselectAll),this.listenTo(i,"reset",this.render);var r=this.config.em||"",o=r?r.get("Utils"):"";this.sorter=o?new o.Sorter({container:this.el,ignoreViewChildren:1,containerSel:"."+e+"layers",itemSel:"."+e+"layer",pfx:this.config.pStylePrefix}):"",i.view=this,this.$el.data("model",i),this.$el.data("collection",i)},addTo:function(t){var e=this.collection.indexOf(t);this.addToCollection(t,null,e)},addToCollection:function(t,e,n){var i=e||null,o=this.stackModel,s=this.config,a=this.sorter,l=this.propsConfig;void 0!==this.preview&&t.set("preview",this.preview);var c=new r({model:t,config:s,sorter:a,stackModel:o,propsConfig:l}),u=c.render().el;if(i)i.appendChild(u);else if(void 0!==n){var h="before";this.$el.children().length==n&&(n--,h="after"),n<0?this.$el.append(u):this.$el.children().eq(n)[h](u)}else this.$el.append(u);return u},deselectAll:function(){this.$el.find("."+this.pfx+"layer").removeClass(this.pfx+"active")},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(e){this.addToCollection(e,t)},this),this.$el.append(t),this.$el.attr("class",this.className),this.sorter&&(this.sorter.plh=null),this}})},function(t,e,n){"use strict";(function(e){t.exports=e.View.extend({events:{click:"active","click [data-close-layer]":"remove","mousedown [data-move-layer]":"initSorter"},template:function(t){var e=this.pfx;return'\n
\n \n
\n
Layer '+t.get("index")+'
\n
\n \t
\n
\n
\n ⨯\n
\n
\n
\n '},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.model;this.stackModel=t.stackModel||{},this.config=t.config||{},this.pfx=this.config.stylePrefix||"",this.sorter=t.sorter||null,this.propsConfig=t.propsConfig||{},this.customPreview=t.onPreview,this.listenTo(e,"destroy remove",this.remove),this.listenTo(e,"change:active",this.updateVisibility),this.listenTo(e.get("properties"),"change",this.updatePreview),e.get("preview")||this.$el.addClass(this.pfx+"no-preview"),e.view=this,e.set({droppable:0,draggable:1}),this.$el.data("model",e)},initSorter:function(t){this.sorter&&this.sorter.startSort(this.el)},remove:function(t){t&&t.stopPropagation&&t.stopPropagation();var n=this.model,i=n.collection,r=this.stackModel;e.View.prototype.remove.apply(this,arguments),i.contains(n)&&i.remove(n),r&&r.set&&(r.set({stackIndex:null},{silent:!0}),r.trigger("updateValue"))},onPreview:function(t){var e=t.split(" "),n=[];return this.model.get("properties").each(function(t,i){var r=e[i]||"";if(r&&"integer"==t.get("type")){var o=parseInt(r,10),s=r.replace(o,"");o=isNaN(o)?0:o,o=o>3?3:o,o=o<-3?-3:o,r=o+s}n.push(r)}),n.join(" ")},updatePreview:function(){var t=this.stackModel,e=this.customPreview,n=this.getPreviewEl(),i=this.model.getFullValue(),r=e?e(i):this.onPreview(i);r&&t&&n&&(n.style[t.get("property")]=r)},getPropertiesWrapper:function(){return this.propsWrapEl||(this.propsWrapEl=this.el.querySelector("[data-properties]")),this.propsWrapEl},getPreviewEl:function(){return this.previewEl||(this.previewEl=this.el.querySelector("[data-preview]")),this.previewEl},active:function(){var t=this.model,e=t.collection;e.active(e.indexOf(t))},updateVisibility:function(){var t=this.pfx,e=this.getPropertiesWrapper(),n=this.model.get("active");e.style.display=n?"":"none",this.$el[n?"addClass":"removeClass"](t+"active")},render:function(){var t=n(13),e=this.propsConfig,i=this.pfx+"layer",r=this.model,o=this.el,s=new t({collection:r.get("properties"),config:this.config,target:e.target,customValue:e.customValue,propTarget:e.propTarget,onChange:e.onChange}).render().el;return o.innerHTML=this.template(r),o.className=i,this.getPropertiesWrapper().appendChild(s),this.updateVisibility(),this.updatePreview(),this}})}).call(e,n(0))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e\n \n
\n '},getSliderEl:function(){return this.slider||(this.slider=this.el.querySelector("input[type=range]")),this.slider},inputValueChanged:function(){var t=this.model,e=t.get("step");this.getInputEl().value=this.getSliderEl().value;var n=this.getInputValue()-e;t.set("value",n,{avoidStore:1}).set("value",n+e),this.elementUpdated()},inputValueChangedSoft:function(){this.getInputEl().value=this.getSliderEl().value,this.model.set("value",this.getInputValue(),{avoidStore:1}),this.elementUpdated()},setValue:function(t){this.getSliderEl().value=t,this.inputInst.setValue(t,{silent:1})},onRender:function(){i.prototype.onRender.apply(this,arguments),this.model.get("showInput")||(this.inputInst.el.style.display="none")}})},function(t,e,n){"use strict";n(0);t.exports=function(){return{build:function(t){var e=[];"string"==typeof t&&(t=[t]);for(var n=0,i=t.length;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.get("SelectorManager"),r=n.add("hc-state"),o=i.get([r]);if(o){var s=i.getAll();s.remove(o),s.add(o)}else o=i.add([r]);o.set("important",1),o.setStyle(e),l.helper=o};if(r){var p=i.getIdRule(o,u);e=p||i.setIdRule(o,{},u)}if(a.length){var g=a.getStyleable(),v=i.get(g,c,d);return!v&&g.length&&(n.stop(),v=i.add(g,c,d),v.setStyle(e.getStyle()),e.setStyle({}),n.start()),v?(c&&f(v.getStyle()),l.model=v,void l.trigger("update")):(l.model=e,void l.trigger("update"))}if(c){var m=i.getIdRule(o,u);c&&f(m&&m.getStyle())}l.model=e,l.trigger("update")}},addToCollection:function(t,e){var n=e||null,i=new o({model:t,id:this.pfx+t.get("name").replace(" ","_").toLowerCase(),name:t.get("name"),properties:t.get("properties"),target:this.target,propTarget:this.propTarget,config:this.config}),r=i.render().el;return n?n.appendChild(r):this.$el.append(r),r},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(e){this.addToCollection(e,t)},this),this.$el.attr("id",this.pfx+"sectors"),this.$el.append(t),this}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=n(0),r=n(13);t.exports=i.View.extend({template:e.template('\n
\n \n <%= label %>\n
'),events:{"click [data-sector-title]":"toggle"},initialize:function(t){this.config=t.config||{},this.pfx=this.config.stylePrefix||"",this.target=t.target||{},this.propTarget=t.propTarget||{},this.caretR="fa-caret-right",this.caretD="fa-caret-down";var e=this.model;this.listenTo(e,"change:open",this.updateOpen),this.listenTo(e,"updateVisibility",this.updateVisibility),this.listenTo(e,"destroy remove",this.remove)},updateVisibility:function(){var t;this.model.get("properties").each(function(e){e.get("visible")&&(t=1)}),this.el.style.display=t?"block":"none"},updateOpen:function(){this.model.get("open")?this.show():this.hide()},show:function(){this.$el.addClass(this.pfx+"open"),this.getPropertiesEl().style.display="",this.$caret.removeClass(this.caretR).addClass(this.caretD)},hide:function(){this.$el.removeClass(this.pfx+"open"),this.getPropertiesEl().style.display="none",this.$caret.removeClass(this.caretD).addClass(this.caretR)},getPropertiesEl:function(){return this.$el.find("."+this.pfx+"properties").get(0)},toggle:function(t){var e=this.model.get("open")?0:1;this.model.set("open",e)},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 t=this.model.get("properties");if(t){var e=new r({collection:t,target:this.target,propTarget:this.propTarget,config:this.config});this.$el.append(e.render().el)}}})}).call(e,n(1))},function(t,e,n){"use strict";t.exports=function(){var t={},e=n(133),i=n(134),r=n(137),o=n(45),s=void 0,a=void 0,l=void 0;return{name:"AssetManager",storageKey:"assets",getConfig:function(){return t},init:function(n){var c=this;t=n||{};for(var u in e)u in t||(t[u]=e[u]);var h=t.pStylePrefix,d=t.em;h&&(t.stylePrefix=h+t.stylePrefix),s=new i([]);var f={collection:new i([]),globalCollection:s,config:t};return l=new o(f),f.fu=l,a=new r(f),s.listenTo(s,"add",function(t){c.getAllVisible().add(t),d&&d.trigger("asset:add",t)}),s.listenTo(s,"remove",function(t){c.getAllVisible().remove(t),d&&d.trigger("asset:remove",t)}),this},add:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return void 0===e.at&&(e.at=0),s.add(t,e)},get:function(t){return s.where({src:t})[0]},getAll:function(){return s},getAllVisible:function(){return a.collection},remove:function(t){var e=this.get(t);return this.getAll().remove(e),this},store:function(e){var n={},i=JSON.stringify(this.getAll().toJSON());return n[this.storageKey]=i,!e&&t.stm&&t.stm.store(n),n},load:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.storageKey,n=t[e]||[];if("string"==typeof n)try{n=JSON.parse(t[e])}catch(t){}return n&&n.length&&this.getAll().reset(n),n},getContainer:function(){return a.el},getAssetsEl:function(){return a.el.querySelector("[data-el=assets]")},render:function(t){var e=t||this.getAll().models;return a.rendered||a.render(),a.collection.reset(e),this.getContainer()},addType:function(t,e){this.getAll().addType(t,e)},getType:function(t){return this.getAll().getType(t)},getTypes:function(){return this.getAll().getTypes()},AssetsView:function(){return a},FileUploader:function(){return l},onLoad:function(){this.getAll().reset(t.assets)},postRender:function(e){t.dropzone&&l.initDropzone(e)},setTarget:function(t){a.collection.target=t},onSelect:function(t){a.collection.onSelect=t},onClick:function(e){t.onClick=e},onDblClick:function(e){t.onDblClick=e}}}},function(t,e,n){"use strict";t.exports={assets:[],noAssets:"",stylePrefix:"am-",upload:0,uploadName:"files",headers:{},params:{},autoAdd:1,uploadText:"Drop files here or click to upload",addBtnText:"Add image",uploadFile:"",handleAdd:"",dropzone:0,openAssetsOnDrop:1,dropzoneContent:"",modalTitle:"Select Image",inputPlaceholder:"http://path/to/the/image.jpg"}},function(t,e,n){"use strict";var i=n(32),r=function(t){return t&&t.__esModule?t:{default:t}}(i);t.exports=n(0).Collection.extend(r.default).extend({types:[{id:"image",model:n(135),view:n(43),isType:function(t){return"string"==typeof t?{type:"image",src:t}:t}}]})},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e\n
\n
\n
\n \n
\n \n
\n
\n \n
\n
\n
\n
\n '},initialize:function(t){this.options=t,this.config=t.config,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"";var e=this.collection;this.listenTo(e,"reset",this.renderAssets),this.listenTo(e,"add",this.addToAsset),this.listenTo(e,"remove",this.removedAsset),this.listenTo(e,"deselectAll",this.deselectAll)},handleSubmit:function(t){t.preventDefault();var e=this.getAddInput(),n=e.value.trim(),i=this.config.handleAdd;n&&(e.value="",this.getAssetsEl().scrollTop=0,i?i(n):this.options.globalCollection.add(n,{at:0}))},getAssetsEl:function(){return this.el.querySelector("."+this.pfx+"assets")},getAddInput:function(){return this.inputUrl&&this.inputUrl.value||(this.inputUrl=this.el.querySelector("."+this.pfx+"add-asset input")),this.inputUrl},removedAsset:function(t){this.collection.length||this.toggleNoAssets()},addToAsset:function(t){1==this.collection.length&&this.toggleNoAssets(1),this.addAsset(t)},addAsset:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e,i=this.collection,r=this.config,o=new t.typeView({model:t,collection:i,config:r}).render().el;if(n)n.appendChild(o);else{var s=this.getAssetsEl();s&&s.insertBefore(o,s.firstChild)}return o},toggleNoAssets:function(t){var e=this.$el.find("."+this.pfx+"assets");if(t)e.empty();else{var n=this.config.noAssets;n&&e.append(n)}},deselectAll:function(){var t=this.pfx;this.$el.find("."+t+"highlight").removeClass(t+"highlight")},renderAssets:function(){var t=this,e=document.createDocumentFragment(),n=this.$el.find("."+this.pfx+"assets");n.empty(),this.toggleNoAssets(this.collection.length),this.collection.each(function(n){return t.addAsset(n,e)}),n.append(e)},render:function(){var t=this.options.fu.render().el;return this.$el.empty(),this.$el.append(t).append(this.template(this)),this.el.className=this.ppfx+"asset-manager",this.renderAssets(),this.rendered=1,this}})}).call(e,n(0))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e=0&&(n.css=o.em.getCss()),i.indexOf("styles")>=0&&(n.styles=JSON.stringify(t)),e||o.stm.store(n),n}},add:function(e,n,i,r){var s=n||"",l=i||"",c=r||{},u=this.get(e,s,l,c);return u||(c.state=s,c.mediaText=l,c.selectors="",u=new a(c,o),u.get("selectors").add(e),t.add(u),u)},get:function(e,n,i,r){var o=null;return t.each(function(t){o||t.compare(e,n,i,r)&&(o=t)}),o},getAll:function(){return t},clear:function(){return this.getAll().reset(),this},addCollection:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[],r=t instanceof Array?t:[t],s=0,a=r.length;s1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.state||"",o=n.mediaText||r.getCurrentMedia(),s=r.get("SelectorManager"),a=s.add({name:t,type:h.TYPE_ID}),l=this.add(a,i,o);return l.setStyle(e,n),l},getIdRule:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.state||"",i=e.mediaText||r.getCurrentMedia(),o=r.get("SelectorManager").get(t,h.TYPE_ID);return o&&this.get(o,n,i)},setClassRule:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.state||"",o=n.mediaText||r.getCurrentMedia(),s=r.get("SelectorManager"),a=s.add({name:t,type:h.TYPE_CLASS}),l=this.add(a,i,o);return l.setStyle(e,n),l},getClassRule:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.state||"",i=e.mediaText||r.getCurrentMedia(),o=r.get("SelectorManager").get(t,h.TYPE_CLASS);return o&&this.get(o,n,i)},render:function(){return e.render().el}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"css-",staticRules:"",rules:[]}},function(t,e,n){"use strict";var i=n(0),r=n(46);t.exports=i.Collection.extend({initialize:function(t,e){e&&e.sm&&(this.editor=e.sm),this.model=function(t,n){return!n.sm&&e&&e.sm&&(n.sm=e.sm),new r(t,n)}},add:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof t&&(t=this.editor.get("Parser").parseCss(t)),e.em=this.editor,i.Collection.prototype.add.apply(this,[t,e])}})},function(t,e,n){"use strict";var i=n(0),r=n(142);t.exports=i.View.extend({initialize:function(t){var e=t.config||{};this.config=e,this.em=e.em,this.pfx=e.stylePrefix||"",this.className=this.pfx+"rules";var n=this.collection;this.listenTo(n,"add",this.addTo),this.listenTo(n,"reset",this.render)},addTo:function(t){this.addToCollection(t)},addToCollection:function(t,e){var n=e||null,i=r,o=new i({model:t,config:this.config}),s=o.render().el;return n?n.appendChild(s):this.$el.append(s),s},render:function(){var t=this,e=this.$el,n=document.createDocumentFragment();return e.empty(),this.collection.each(function(e){return t.addToCollection(e,n)}),e.append(n),e.attr("class",this.className),this}})},function(t,e,n){"use strict";t.exports=n(0).View.extend({tagName:"style",initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config=t.config||{};var e=this.model;this.listenTo(e,"change:style change:state change:mediaText",this.render),this.listenTo(e,"destroy remove",this.remove),this.listenTo(e.get("selectors"),"change",this.render)},render:function(){var t=this.model,e=t.get("important");return this.el.innerHTML=this.model.toCSS({important:e}),this}})},function(t,e,n){"use strict";var i=n(1);t.exports=function(){var t={},e=n(144),r=n(145),o=void 0;return{TraitsView:r,name:"TraitManager",getConfig:function(){return t},init:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=n,(0,i.defaults)(t,e);var s=t.pStylePrefix;return s&&(t.stylePrefix=""+s+t.stylePrefix),o=new r({collection:[],editor:t.em,config:t}),this},getTraitsViewer:function(){return o},addType:function(t,e){var n=o.itemView;o.itemsView[t]=n.extend(e)},getType:function(t){return o.itemsView[t]}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"trt-",labelContainer:"Component settings",labelPlhText:"eg. Text here",labelPlhHref:"eg. https://google.com",optionsTarget:[{value:"",name:"This window"},{value:"_blank",name:"New window"}]}},function(t,e,n){"use strict";var i=n(48),r=n(8),o=n(146),s=n(147),a=n(148),l=n(149);t.exports=i.extend({itemView:r,itemsView:{text:r,number:a,select:o,checkbox:s,color:l},initialize:function(t){this.config=t.config||{},this.em=t.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 t=this.em.get("selectedComponent");t&&(this.collection=t.get("traits"),this.render())}})},function(t,e,n){"use strict";(function(e,i){var r=n(8),o=e.$;t.exports=r.extend({initialize:function(t){r.prototype.initialize.apply(this,arguments);var e=this.ppfx;this.tmpl='
'},getInputEl:function(){if(!this.$input){var t=this.model,e=t.get("options")||[],n="",this.input=n,this.$input=o(this.input);var r=this.target,s=t.get("name"),a=t.get("value");if(t.get("changeProp"))a=a||r.get(s);else{a=r.get("attributes")[s]}a&&this.$input.val(a)}return this.$input.get(0)}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";var i=n(8);t.exports=i.extend({initialize:function(t){i.prototype.initialize.apply(this,arguments);var e=this.ppfx+"chk-icon";this.tmpl='
'},onChange:function(){this.model.set("value",this.getInputEl().checked)},getInputEl:function(){var t;this.$input||(t=1);for(var e=arguments.length,n=Array(e),r=0;r2&&void 0!==arguments[2]?arguments[2]:{},r=t.components(),s=o.get("UndoManager"),a=o.handleUpdates.bind(o),l=this.handleChanges.bind(this),c=this.handleRemoves.bind(this);s&&s.add(t),s&&r&&s.add(r);[[t,"change:style change:content change:attributes change:src",a],[r,"add",l],[r,"remove",c],[t.get("classes"),"add remove",a]].forEach(function(t){o.stopListening(t[0],t[1],t[2]),o.listenTo(t[0],t[1],t[2])}),!i.avoidStore&&a("","",i),r.each(function(t){return n.handleChanges(t,e,i)})},handleRemoves:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!n.avoidStore&&o.handleUpdates(t,e,n)},load:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e="";if(!t&&r.stm&&(t=r.em.getCacheLoad()),t.components)try{e=JSON.parse(t.components)}catch(t){}else t.html&&(e=t.html);var n=e&&e.constructor===Object;return(e&&e.length||n)&&(this.clear(),this.getComponents().reset(),n?this.getWrapper().set(e).initComponents().initClasses().loadTraits():this.getComponents().add(e)),e},store:function(t){if(r.stm){var e={},n=this.storageKey();if(n.indexOf("html")>=0&&(e.html=r.em.getHtml()),n.indexOf("components")>=0){var i=r.storeWrapper?this.getWrapper():this.getComponents();e.components=JSON.stringify(i)}return t||r.stm.store(e),e}},getComponent:function(){return t},getWrapper:function(){return this.getComponent()},getComponents:function(){return this.getWrapper().get("components")},addComponent:function(t){return this.getComponents().add(t)},render:function(){return e.render().el},clear:function(){for(var t=this.getComponents(),e=0,n=t.length;e1&&void 0!==arguments[1]?arguments[1]:{};this.em=e.em||""},setTarget:function(t){this.target=t},add:function(t,e){var n=this.em;if((0,i.isString)(t)||(0,i.isArray)(t)){var o=n&&n.get&&n.get("TraitManager"),a=o&&o.getConfig(),l=s(a);(0,i.isString)(t)&&(t=[t]);for(var c=0,u=t.length;c0&&void 0!==arguments[0]?arguments[0]:{};return{build:function(e){var n=[];"string"==typeof e&&(e=[e]);for(var i=0;is.top+s.height?s.top+s.height:g;var v={top:g,left:p,elementTop:s.top,elementLeft:s.left,elementWidth:s.width,elementHeight:s.height,targetWidth:t.offsetWidth,targetHeight:t.offsetHeight,canvasTop:o.top,canvasLeft:o.left};return h&&r.em&&r.em.trigger(h,v),v},getMouseRelativePos:function(t,e){var n=e||{},i=0,r=0,o=n.subWinOffset,s=t.target.ownerDocument,a=s.defaultView||s.parentWindow,l=a.frameElement,c=o?a.pageYOffset:0,u=o?a.pageXOffset:0;if(l){var h=l.getBoundingClientRect();i=h.top||0,r=h.left||0}return{y:t.clientY+i-c,x:t.clientX+r-u}},getMouseRelativeCanvas:function(t,e){var n=this.getFrameEl(),i=this.getBody(),r=n.offsetTop||0,o=n.offsetLeft||0,s=i.scrollTop||0,a=i.scrollLeft||0;return{y:t.clientY+r+s,x:t.clientX+o+a}},isInputFocused:function(){return"BODY"!==this.getFrameEl().contentDocument.activeElement.tagName},startAutoscroll:function(){var t=this;this.dragging=1;var n=this.getScrollListeners();e=a.getFrameOffset(1),setTimeout(function(){(0,i.on)(n,"mousemove",t.autoscroll),(0,i.on)(n,"mouseup",t.stopAutoscroll)},0)},autoscroll:function(t){if(t.preventDefault(),this.dragging){var n=this.getFrameEl().contentWindow,i=n.document.body.scrollTop,r=i,o=t.clientY,s=e.height-50;o<50&&(r-=50-o),o>s&&(r+=o-s),n.scrollTo(0,r)}},stopAutoscroll:function(){this.dragging=0;var t=this.getScrollListeners();(0,i.off)(t,"mousemove",this.autoscroll),(0,i.off)(t,"mouseup",this.stopAutoscroll)},getScrollListeners:function(){return[this.getFrameEl().contentWindow,this.getElement()]},getFrameWrapperEl:function(){return a.frame.getWrapper()}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"cv-",rulers:!1,scripts:[],styles:[],customBadgeLabel:""}},function(t,e,n){"use strict";var i=n(0),r=n(181);t.exports=i.Model.extend({defaults:{frame:"",wrapper:"",rulers:!1},initialize:function(t){var e=this.conf||{};this.set("frame",new r(e.frame))}})},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{wrapper:"",width:"",height:"",attributes:{}}})},function(t,e,n){"use strict";(function(e,i){var r=n(183),o=e.$;t.exports=e.View.extend({initialize:function(t){i.bindAll(this,"renderBody","onFrameScroll","clearOff"),window.onscroll=this.clearOff,this.config=t.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 r({model:this.model.get("frame"),config:this.config})},isElInViewport:function(t){var e=t.getBoundingClientRect(),n=this.getFrameOffset(1),i=e.top,r=e.left;return i>=0&&r>=0&&i<=n.height&&r<=n.width},onFrameScroll:function(){var t=this.frame.el.contentDocument.body;this.toolsEl.style.top="-"+t.scrollTop+"px",this.toolsEl.style.left="-"+t.scrollLeft+"px",this.em.trigger("canvasScroll")},renderScripts:function(){var t=this.frame,e=this;t.el.onload=function(){function n(i){if(i.length>0){var r=document.createElement("script");r.type="text/javascript",r.src=i.shift(),r.onerror=r.onload=n.bind(null,i),t.el.contentDocument.head.appendChild(r)}else e.renderBody()}var i=e.config.scripts.slice(0);n(i)}},renderBody:function(){var t=this.model.get("frame").get("wrapper"),e=this.config.em;if(t){var n=this.ppfx,i=o(this.frame.el.contentWindow.document.body),r=e.get("CssComposer"),s=e.get("Config"),a=this.config,l=s.protectedCss,c="";a.styles.forEach(function(t){c+=''});var u="\n \n * {\n box-sizing: border-box;\n }\n html, body, #wrapper {\n min-height: 100%;\n }\n body {\n margin: 0;\n height: 100%;\n background-color: #fff\n }\n #wrapper {\n overflow: auto\n }\n \n\n ."+n+"dashed *[data-highlightable] {\n outline: 1px dashed rgba(170,170,170,0.7);\n outline-offset: -3px\n }\n\n ."+n+"comp-selected {\n outline: 3px solid #3b97e3 !important;\n }\n\n ."+n+"comp-selected-parent {\n outline: 2px solid #ffca6f !important\n }\n\n ."+n+"no-select {\n user-select: none;\n -webkit-user-select:none;\n -moz-user-select: none;\n }\n\n ."+n+"freezed {\n opacity: 0.5;\n pointer-events: none;\n }\n\n ."+n+"no-pointer {\n pointer-events: none;\n }\n\n ."+n+"plh-image {\n background: #f5f5f5;\n border: none;\n height: 50px;\n width: 50px;\n display: block;\n outline: 3px solid #ffca6f;\n cursor: pointer;\n outline-offset: -2px\n }\n\n ."+n+"grabbing {\n cursor: grabbing;\n cursor: -webkit-grabbing;\n }\n\n * ::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.1)\n }\n\n * ::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.2)\n }\n\n * ::-webkit-scrollbar {\n width: 10px\n }\n\n "+(s.canvasCss||"")+"\n "+(l||"")+"\n ";c&&i.append(c),i.append(""),i.append(t.render()).append(r.render()),i.append(this.getJsContainer()),e.trigger("loaded"),this.frame.el.contentWindow.onscroll=this.onFrameScroll,this.frame.udpateOffset();var h=document,d=this.frame.el.contentDocument,f=function(t){var e=new KeyboardEvent(t.type,t);return e.keyCodeVal=t.keyCode,["keyCode","which"].forEach(function(t){Object.defineProperty(e,t,{get:function(){return this.keyCodeVal}})}),e};d.addEventListener("keydown",function(t){h.dispatchEvent(f(t))}),d.addEventListener("keyup",function(t){h.dispatchEvent(f(t))})}},offset:function(t){var e=t.getBoundingClientRect(),n=t.ownerDocument.body;return{top:e.top+n.scrollTop,left:e.left+n.scrollLeft,width:e.width,height:e.height}},clearOff:function(){this.frmOff=null,this.cvsOff=null},getFrameOffset:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.frmOff&&!t||(this.frmOff=this.offset(this.frame.el)),this.frmOff},getCanvasOffset:function(){return this.cvsOff||(this.cvsOff=this.offset(this.el)),this.cvsOff},getElementPos:function(t,e){var n=e||{},i=this.getFrameOffset(),r=this.getCanvasOffset(),o=this.offset(t),s=n.avoidFrameOffset?0:i.top,a=n.avoidFrameOffset?0:i.left;return{top:o.top+s-r.top,left:o.left+a-r.left,height:t.offsetHeight||t.clientHeight,width:t.offsetWidth||t.clientWidth}},getPosition:function(){var t=this.frame.el.contentDocument.body,e=this.getFrameOffset(),n=this.getCanvasOffset();return{top:e.top+t.scrollTop-n.top,left:e.left+t.scrollLeft-n.left}},updateScript:function(t){t.scriptContainer||(t.scriptContainer=o("
"),this.getJsContainer().append(t.scriptContainer.get(0)));var e=t.model,n=e.getId();t.el.id=n,t.scriptContainer.html("");var i=document.createElement("script");i.innerText="\n setTimeout(function() {\n var item = document.getElementById('"+n+"');\n if (!item) return;\n (function(){"+e.getScriptString()+"}.bind(item))()\n }, 1);",t.scriptContainer.get(0).appendChild(i)},getJsContainer:function(){return this.jsContainer||(this.jsContainer=o('
').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 t=this.frame;0===this.config.scripts.length?t.el.onload=this.renderBody:this.renderScripts()}var e=this.ppfx;this.$el.append('\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n ');var n=this.el,i=n.querySelector("#"+e+"tools");return this.hlEl=n.querySelector("."+e+"highlighter"),this.badgeEl=n.querySelector("."+e+"badge"),this.placerEl=n.querySelector("."+e+"placeholder"),this.ghostEl=n.querySelector("."+e+"ghost"),this.toolbarEl=n.querySelector("."+e+"toolbar"),this.resizerEl=n.querySelector("."+e+"resizer"),this.offsetEl=n.querySelector("."+e+"offset-v"),this.fixedOffsetEl=n.querySelector("."+e+"offset-fixed-v"),this.toolsEl=i,this.el.className=this.className,this}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";var i=n(1),r="transitionend oTransitionEnd transitionend webkitTransitionEnd";t.exports=n(0).View.extend({tagName:"iframe",attributes:{src:"about:blank",allowfullscreen:"allowfullscreen"},initialize:function(t){(0,i.bindAll)(this,"udpateOffset"),this.config=t.config||{},this.ppfx=this.config.pStylePrefix||"",this.em=this.config.em,this.listenTo(this.em,"change:device",this.updateDim)},updateDim:function(t){var e=this.em,n=e.getDeviceModel(),i=this.el.style;i.width=n?n.get("width"):"",i.height=n?n.get("height"):"",this.udpateOffset(),e.stopDefault({preserveSelected:1}),this.$el.on(r,this.udpateOffset)},udpateOffset:function(){var t=this.em,e=t.get("Canvas").getOffset();t.set("canvasOffset",e),t.runDefault({preserveSelected:1}),this.$el.off(r,this.udpateOffset)},getBody:function(){this.$el.contents().find("body")},getWrapper:function(){return this.$el.contents().find("body > div")},render:function(){return this.$el.attr({class:this.ppfx+"frame"}),this}})},function(t,e,n){"use strict";var i=n(1);t.exports=function(){var t=void 0,e={},r={},o={},s=n(185),a=n(186),l=function(t,e){return(0,i.isFunction)(e)&&(e={run:e}),delete e.initialize,r[t]=a.extend(e),this};return{name:"Commands",init:function(i){e=i||{};for(var r in s)r in e||(e[r]=s[r]);t=e.em;var a=e.pStylePrefix;a&&(e.stylePrefix=a+e.stylePrefix);for(var l in e.defaults){var c=e.defaults[l];c.id&&this.add(c.id,c)}var u=n(187);return o["select-comp"]=n(21),o["create-comp"]=n(22),o["delete-comp"]=n(192),o["image-comp"]=n(193),o["move-comp"]=n(194),o["text-comp"]=n(195),o["insert-custom"]=n(54),o["export-template"]=u,o["sw-visibility"]=n(196),o["open-layers"]=n(197),o["open-sm"]=n(200),o["open-tm"]=n(201),o["open-blocks"]=n(202),o["open-assets"]=n(203),o["show-offset"]=n(204),o["select-parent"]=n(205),o.fullscreen=n(206),o.preview=n(207),o.resize=n(208),o.drag=n(209),o["tlb-delete"]={run:function(t){var e=t.getSelected();if(!e||!e.get("removable"))return void console.warn("The element is not removable");t.select(null),e.destroy()}},o["tlb-clone"]={run:function(t){var e=t.getSelected();if(!e||!e.get("copyable"))return void console.warn("The element is not clonable");var n=e.collection,i=n.indexOf(e);n.add(e.clone(),{at:i+1}),e.emitUpdate()}},o["tlb-move"]={run:function(t,e,n){var i,r=t.getSelected();if(!r||!r.get("draggable"))return void console.warn("The element is not draggable");var o=function(t,e){console.log("start mouse pos ",e.start),console.log("el rect ",e.elRect);var n=e.el;n.style.position="absolute",n.style.margin=0},s=function(t,e){l.runDefault(),l.set("selectedComponent",r),r.emitUpdate(),i&&i.blur()},a=function(t,e){console.log("Delta ",e.delta),console.log("Current ",e.current)};t.Canvas.getToolbarEl().style.display="none";var l=t.getModel();if(l.stopDefault(),l.get("designerMode"))i=editor.runCommand("drag",{el:r.view.el,options:{event:n&&n.event,onStart:o,onDrag:a,onEnd:s}});else{var c=t.Commands.get("move-comp");c.onEndMoveFromModel=s,c.initSorterFromModel(r)}r.set("status","selected")}},o["core:undo"]=function(t){return t.UndoManager.undo()},o["core:redo"]=function(t){return t.UndoManager.redo()},o["core:canvas-clear"]=function(t){t.DomComponents.clear(),t.CssComposer.clear()},o["core:copy"]=function(t){var e=t.getModel(),n=t.getSelected();n&&n.get("copyable")&&!t.Canvas.isInputFocused()&&e.set("clipboard",n)},o["core:paste"]=function(t){var e=t.getModel(),n=e.get("clipboard"),i=t.getSelected(),r=i&&i.collection;if(r&&n&&!t.Canvas.isInputFocused()){var o=r.indexOf(i)+1;r.add(n.clone(),{at:o})}},e.em&&(e.model=e.em.get("Canvas")),this.loadDefaultCommands(),this},add:l,get:function(t){var n=r[t];return"function"==typeof n&&(n=new n(e),r[t]=n),n},has:function(t){return!!r[t]},loadDefaultCommands:function(){for(var t in o)this.add(t,o[t]);return this}}}},function(t,e,n){"use strict";t.exports={ESCAPE_KEY:27,stylePrefix:"com-",defaults:[],em:null,firstCentered:!0,newFixedH:!1,minComponentH:50,minComponentW:50}},function(t,e,n){"use strict";(function(e){var n=e.$;t.exports=e.View.extend({initialize:function(t){this.config=t||{},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=n(this.getCanvasWrapper()),this.frameEl=this.canvas.getFrameEl(),this.canvasTool=this.getCanvasTools(),this.bodyEl=this.getCanvasBody()),this.init(this.config)},onFrameScroll:function(t){},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(t){var e=t.getBoundingClientRect();return{top:e.top+t.ownerDocument.body.scrollTop,left:e.left+t.ownerDocument.body.scrollLeft}},init:function(t){},run:function(t,e){},stop:function(t,e){}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var n=e.$;t.exports={run:function(t,e){arguments.length>2&&void 0!==arguments[2]&&arguments[2];e&&e.set&&e.set("active",0);var i=t.getConfig(),r=t.Modal,o=i.stylePrefix;if(this.cm=t.CodeManager||null,!this.$editors){var s=this.buildEditor("htmlmixed","hopscotch","HTML"),a=this.buildEditor("css","hopscotch","CSS");this.htmlEditor=s.el,this.cssEditor=a.el;var l=n('
');l.append(s.$el).append(a.$el),this.$editors=l}r.setTitle(i.textViewCode),r.setContent(this.$editors),r.open(),this.htmlEditor.setContent(t.getHtml()),this.cssEditor.setContent(t.getCss())},stop:function(t){var e=t.Modal;e&&e.close()},buildEditor:function(t,e,n){var i=document.createElement("textarea");!this.codeMirror&&(this.codeMirror=this.cm.getViewer("CodeMirror"));var r=this.codeMirror.clone().set({label:n,codeName:t,theme:e,input:i}),o=new this.cm.EditorView({model:r,config:this.cm.getConfig()}).render().$el;return r.init(i),{el:r,$el:o}}}}).call(e,n(0))},function(t,e,n){"use strict";var i=(n(0),n(48)),r=n(189);t.exports=i.extend({itemView:r,initialize:function(t){this.config={editor:t.editor||""},this.listenTo(this.collection,"reset",this.render)}})},function(t,e,n){"use strict";var i=n(0);t.exports=i.View.extend({events:{mousedown:"handleClick"},attributes:function(){return this.model.get("attributes")},initialize:function(t){this.editor=t.config.editor},handleClick:function(t){t.preventDefault(),t.stopPropagation();var e={event:t},n=this.model.get("command"),i=this.editor;"function"==typeof n&&n(i,null,e),"string"==typeof n&&i.runCommand(n,e)},render:function(){var t=this.editor.getConfig();return this.el.className+=" "+t.stylePrefix+"toolbar-item",this}})},function(t,e,n){"use strict";var i=n(0),r=n(191);t.exports=i.Collection.extend({model:r})},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{command:"",attributes:{}}})},function(t,e,n){"use strict";(function(e,i){var r=n(21),o=e.$;t.exports=i.extend({},r,{init:function(t){i.bindAll(this,"startDelete","stopDelete","onDelete"),this.hoverClass=this.pfx+"hover-delete",this.badgeClass=this.pfx+"badge-red"},enable:function(){this.$el.find("*").mouseover(this.startDelete).mouseout(this.stopDelete).click(this.onDelete)},startDelete:function(t){t.stopPropagation();var e=o(t.target);e.data("model").get("removable")&&(e.addClass(this.hoverClass),this.attachBadge(e.get(0)))},stopDelete:function(t){t.stopPropagation(),o(t.target).removeClass(this.hoverClass),this.badge&&this.badge.css({left:-1e3,top:-1e3})},onDelete:function(t){t.stopPropagation();var e=o(t.target);e.data("model").get("removable")&&(e.data("model").destroy(),this.removeBadge(),this.clean())},updateBadgeLabel:function(t){this.badge.html("Remove "+t.getName())}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";(function(e){var i=(n(0),n(54));t.exports=e.extend({},i,{beforeInsert:function(t){t.type="image",t.style={},t.attributes={},t.attributes.onmousedown="return false",this.config.firstCentered&&this.getCanvasWrapper()==this.sorter.target&&(t.style.margin="0 auto")},afterInsert:function(t){t.trigger("dblclick"),this.sender&&this.sender.set("active",!1)}})}).call(e,n(1))},function(t,e,n){"use strict";(function(e,i){var r=n(2),o=n(21),s=n(53),a=e.$;t.exports=i.extend({},s,o,{init:function(t){o.init.apply(this,arguments),i.bindAll(this,"initSorter","rollback","onEndMove"),this.opt=t,this.hoverClass=this.ppfx+"highlighter-warning",this.badgeClass=this.ppfx+"badge-warning",this.noSelClass=this.ppfx+"no-select"},enable:function(){for(var t=arguments.length,e=Array(t),n=0;n
');this.panel.set("appendContent",c).trigger("change:appendContent"),o.layers.sortContainer=c.get(0);var u=(new i).init(n,o.layers);this.$layers=u.render(),c.append(this.$layers),this.toAppend=c}this.toAppend.show()},stop:function(){this.toAppend&&this.toAppend.hide()}}}).call(e,n(0))},function(t,e,n){"use strict";t.exports=function(){var t=void 0,e={},i=n(199),r=n(55),o=n(56);return{init:function(n,s){e=s||e;var a=e.em;for(var l in i)l in e||(e[l]=i[l]);var c=o,u=s.opened||{},h={level:0,config:e,opened:u};return e.showWrapper&&n.parent?(c=r,h.model=n.parent):h.collection=n,t=new c(h),a&&a.on("change:selectedComponent",this.componentChanged),this.componentChanged(),this},componentChanged:function(t,n){if(!(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).fromLayers){var i=e.em,r=i.get("opened"),o=i.get("selectedComponent"),s=o&&o.collection?o.collection.parent:null;for(var a in r)r[a].set("open",0);for(;s;)s.set("open",1),r[s.cid]=s,s=s.collection?s.collection.parent:null}},render:function(){return t.render().$el}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"nv-",sortable:1,hidable:1,hideTextnode:1,showWrapper:1}},function(t,e,n){"use strict";var i=(n(31),n(0)),r=i.$;t.exports={run:function(t,e){if(this.sender=e,!this.$cn){var n=t.getConfig(),i=t.Panels;this.$cn=r("
"),this.$cn2=r("
"),this.$cn.append(this.$cn2);var o=t.DeviceManager;if(o&&n.showDevices){i.addPanel({id:"devices-c"}).set("appendContent",o.render()).trigger("change:appendContent")}var s=t.SelectorManager;s&&this.$cn2.append(s.render([])),this.$cn2.append(t.StyleManager.render());var a=t.StyleManager.getConfig(),l=a.stylePrefix;this.$header=r('
'+a.textNoElement+"
"),this.$cn.append(this.$header),i.getPanel("views-container")?this.panel=i.getPanel("views-container"):this.panel=i.addPanel({id:"views-container"}),this.panel.set("appendContent",this.$cn).trigger("change:appendContent"),this.target=t.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()}}},function(t,e,n){"use strict";(function(e){var n=e.$;t.exports={run:function(t,e){var i,r=t.Config,o=r.stylePrefix,s=t.TraitManager;if(!this.obj){var a=s.getTraitsViewer(),l=s.getConfig();this.obj=n("
").append('
'+l.labelContainer+"
").get(0),this.obj.appendChild(a.render().el);var c=t.Panels;i=c.getPanel("views-container")?c.getPanel("views-container"):c.addPanel({id:"views-container"}),i.set("appendContent",this.obj).trigger("change:appendContent")}this.obj.style.display="block"},stop:function(){this.obj&&(this.obj.style.display="none")}}}).call(e,n(0))},function(t,e,n){"use strict";t.exports={run:function(t,e){var n=t.BlockManager,i=t.Panels;if(!this.blocks){n.render();var r="views-container",o=document.createElement("div"),s=i.getPanel(r)||i.addPanel({id:r});o.appendChild(n.getContainer()),s.set("appendContent",o).trigger("change:appendContent"),this.blocks=o}this.blocks.style.display="block"},stop:function(){var t=this.blocks;t&&(t.style.display="none")}}},function(t,e,n){"use strict";t.exports={run:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.Modal,r=t.AssetManager,o=r.getConfig(),s=n.modalTitle||o.modalTitle||"";r.setTarget(n.target),r.onClick(n.onClick),r.onDblClick(n.onDblClick),r.onSelect(n.onSelect),this.rendered||(r.render(r.getAll().filter(function(t){return"image"==t.get("type")})),this.rendered=1),i.setTitle(s),i.setContent(r.getContainer()),i.open()}}},function(t,e,n){"use strict";(function(e){var n=e.$;t.exports={getOffsetMethod:function(t){return"get"+(t||"")+"OffsetViewerEl"},run:function(t,e,i){var r=i||{},o=r.state||"",s=t.getConfig();if(s.showOffsets&&(s.showOffsetsSelected||"Fixed"!=o)){var a=t.Canvas,l=r.el||"",c=r.elPos||a.getElementPos(l),u=window.getComputedStyle(l),h=this.ppfx,d=o+"State",f=this.getOffsetMethod(o),p=a[f]();p.style.display="block";var g=this["marginT"+o],v=this["marginB"+o],m=this["marginL"+o],y=this["marginR"+o],b=this["padT"+o],x=this["padB"+o],w=this["padL"+o],C=this["padR"+o];if(!this[d]){var k=o.toLowerCase(),S=k+"margin-v",T=k+"padding-v",E=n('
').get(0),M=n('
').get(0),P=h+S+"-el",A=h+T+"-el",O=P+" "+(h+S),L=A+" "+(h+T);g=n('
').get(0),v=n('
').get(0),m=n('
').get(0),y=n('
').get(0),b=n('
').get(0),x=n('
').get(0),w=n('
').get(0),C=n('
').get(0),this["marginT"+o]=g,this["marginB"+o]=v,this["marginL"+o]=m,this["marginR"+o]=y,this["padT"+o]=b,this["padB"+o]=x,this["padL"+o]=w,this["padR"+o]=C,E.appendChild(g),E.appendChild(v),E.appendChild(m),E.appendChild(y),M.appendChild(b),M.appendChild(x),M.appendChild(w),M.appendChild(C),p.appendChild(E),p.appendChild(M),this[d]="1"}var N=u.marginLeft.replace("px",""),I=parseInt(u.marginTop.replace("px","")),D=parseInt(u.marginBottom.replace("px","")),_=g.style,F=v.style,z=m.style,$=y.style,R=b.style,V=x.style,H=w.style,j=C.style,B=parseInt(c.left);_.height=u.marginTop,_.width=u.width,_.top=c.top-u.marginTop.replace("px","")+"px",_.left=B+"px",F.height=u.marginBottom,F.width=u.width,F.top=c.top+c.height+"px",F.left=B+"px";var W=c.height+I+D+"px",U=c.top-I+"px";z.height=W,z.width=u.marginLeft,z.top=U,z.left=B-N+"px",$.height=W,$.width=u.marginRight,$.top=U,$.left=B+c.width+"px";var q=parseInt(u.paddingTop.replace("px",""));R.height=u.paddingTop,R.width=u.width,R.top=c.top+"px",R.left=B+"px";var K=parseInt(u.paddingBottom.replace("px",""));V.height=u.paddingBottom,V.width=u.width,V.top=c.top+c.height-K+"px",V.left=B+"px";var G=c.height-K-q+"px",Y=c.top+q+"px";H.height=G,H.width=u.paddingLeft,H.top=Y,H.left=c.left+"px";var X=parseInt(u.paddingRight.replace("px",""));j.height=G,j.width=u.paddingRight,j.top=Y,j.left=c.left+c.width-X+"px"}},stop:function(t,e,n){var i=n||{},r=i.state||"",o=this.getOffsetMethod(r);t.Canvas[o]().style.display="none"}}}).call(e,n(0))},function(t,e,n){"use strict";t.exports={run:function(t){for(var e=t.getSelected(),n=e&&e.parent();n&&!n.get("selectable");)n=n.parent();n&&t.select(n)}}},function(t,e,n){"use strict";t.exports={isEnabled:function(){var t=document;return t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement?1:0},enable:function(t){var e="";return t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?(e="webkit",t.webkitRequestFullscreen()):t.mozRequestFullScreen?(e="moz",t.mozRequestFullScreen()):t.msRequestFullscreen?t.msRequestFullscreen():console.warn("Fullscreen not supported"),e},disable:function(){var t=document;t.exitFullscreen?t.exitFullscreen():t.webkitExitFullscreen?t.webkitExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.msExitFullscreen&&t.msExitFullscreen()},fsChanged:function(t,e){var n=(document,(t||"")+"fullscreenchange");this.isEnabled()||(this.stop(null,this.sender),document.removeEventListener(n,this.fsChanged))},run:function(t,e){this.sender=e;var n=this.enable(t.getContainer());this.fsChanged=this.fsChanged.bind(this,n),document.addEventListener(n+"fullscreenchange",this.fsChanged),t&&t.trigger("change:canvasOffset")},stop:function(t,e){e&&e.set&&e.set("active",!1),this.disable(),t&&t.trigger("change:canvasOffset")}}},function(t,e,n){"use strict";(function(e){t.exports={getPanels:function(t){return this.panels||(this.panels=t.Panels.getPanelsEl()),this.panels},tglPointers:function(t,n){var i=t.Canvas.getBody().querySelectorAll("."+this.ppfx+"no-pointer");e.each(i,function(t){t.style.pointerEvents=n?"":"all"})},run:function(t,e){e&&e.set&&e.set("active",!1),t.stopCommand("sw-visibility"),t.getModel().stopDefault();var n=this.getPanels(t),i=t.Canvas.getElement(),r=t.getEl(),o=t.Config.stylePrefix;this.helper||(this.helper=document.createElement("span"),this.helper.className=o+"off-prv fa fa-eye-slash",r.appendChild(this.helper),this.helper.onclick=function(){t.stopCommand("preview")}),this.helper.style.display="inline-block",this.tglPointers(t),n.style.display="none";var s=i.style;s.width="100%",s.height="100%",s.top="0",s.left="0",s.padding="0",s.margin="0",t.trigger("change:canvasOffset")},stop:function(t,e){var n=this.getPanels(t);t.runCommand("sw-visibility"),t.getModel().runDefault(),n.style.display="block",t.Canvas.getElement().setAttribute("style",""),this.helper&&(this.helper.style.display="none"),t.trigger("change:canvasOffset"),this.tglPointers(t,1)}}}).call(e,n(1))},function(t,e,n){"use strict";t.exports={run:function(t,e,n){var i=n||{},r=i.el||"",o=t.Canvas,s=this.canvasResizer,a=i.options||{},l=o.getCanvasView();return a.ratioDefault=1,a.appendTo=o.getResizerEl(),a.prefix=t.getConfig().stylePrefix,a.posFetcher=l.getElementPos.bind(l),a.mousePosFetcher=o.getMouseRelativePos,s&&!i.forceNew||(this.canvasResizer=t.Utils.Resizer.init(a),s=this.canvasResizer),s.setOptions(a),s.focus(r),s},stop:function(){var t=this.canvasResizer;t&&t.blur()}}},function(t,e,n){"use strict";t.exports={run:function(t,e,n){var i=n&&n.el||"",r=t.Canvas,o=this.dragger,s=n.options||{},a=r.getCanvasView();return s.prefix=t.getConfig().stylePrefix,s.mousePosFetcher=r.getMouseRelativePos,s.posFetcher=a.getElementPos.bind(a),o||(o=t.Utils.Dragger.init(s),this.dragger=o),o.setOptions(s),o.focus(i),s.event&&o.start(s.event),o},stop:function(){this.canvasResizer&&this.canvasResizer.blur()}}},function(t,e,n){"use strict";t.exports=function(){var t,e,i,r={},o=n(211),s=n(212),a=n(214),l=n(215),c=[];return{name:"BlockManager",init:function(n){r=n||{};var u=r.em;for(var h in o)h in r||(r[h]=o[h]);return t=new s([]),e=new s([]),c=new a,i=new l({collection:e,categories:c},r),t.listenTo(t,"add",function(t){e.add(t),u&&u.trigger("block:add",t)}),t.listenTo(t,"remove",function(t){e.remove(t),u&&u.trigger("block:remove",t)}),t.listenTo(t,"reset",function(t){e.reset(t.models)}),this},getConfig:function(){return r},onLoad:function(){var t=this.getAll();!t.length&&t.reset(r.blocks)},add:function(e,n){var i=n||{};return i.id=e,t.add(i)},get:function(e){return t.get(e)},getAll:function(){return t},getAllVisible:function(){return e},remove:function(e){return t.remove(e)},getCategories:function(){return c},getContainer:function(){return i.el},render:function(t){var e=t||this.getAll().models;i.rendered||(i.render(),i.rendered=1),i.collection.reset(e)}}}},function(t,e,n){"use strict";t.exports={blocks:[],appendTo:""}},function(t,e,n){"use strict";var i=n(0),r=n(213);t.exports=i.Collection.extend({model:r})},function(t,e,n){"use strict";var i=n(0),r=n(57);t.exports=i.Model.extend({defaults:{label:"",content:"",category:"",attributes:{}},initialize:function(){var t=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],this.get("category"));if(t&&"string"==typeof t){new r({id:t,label:t})}}})},function(t,e,n){"use strict";var i=n(0);t.exports=i.Collection.extend({model:n(57)})},function(t,e,n){"use strict";(function(e){var i=n(0),r=n(216),o=n(217);t.exports=i.View.extend({initialize:function(t,n){e.bindAll(this,"getSorter","onDrag","onDrop"),this.config=n||{},this.categories=t.categories||"",this.renderedCategories=[];var i=this.config.pStylePrefix||"";this.ppfx=i,this.noCatClass=i+"blocks-no-cat",this.blockContClass=i+"blocks-c",this.catsClass=i+"block-categories";var r=this.collection;this.listenTo(r,"add",this.addTo),this.listenTo(r,"reset",this.render),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 t=this.em.get("Utils"),e=this.canvas;this.sorter=new t.Sorter({container:e.getBody(),placer:e.getPlacerEl(),containerSel:"*",itemSel:"*",pfx:this.ppfx,onStart:this.onDrag,onEndMove:this.onDrop,onMove:this.onMove,document:e.getFrameEl().contentDocument,direction:"a",wmargin:1,nested:1,em:this.em,canvasRelative:1})}return this.sorter}},onDrag:function(t){this.em.stopDefault(),this.em.trigger("block:drag:start",t)},onMove:function(t){this.em.trigger("block:drag:move",t)},onDrop:function(t){var e=this.em;e.runDefault(),t&&t.get&&(t.get("activeOnRender")&&(t.trigger("active"),t.set("activeOnRender",0)),e.trigger("block:drag:stop",t))},addTo:function(t){this.add(t)},add:function(t,e){var n=e||null,i=new r({model:t,attributes:t.get("attributes")},this.config),s=i.render().el,a=t.get("category");if(a&&this.categories){"string"==typeof a&&(a={id:a,label:a});var l=this.categories.add(a),c=l.get("id"),u=this.renderedCategories[c],h=this.getCategoriesEl();return t.set("category",l),!u&&h&&(u=new o({model:l},this.config).render(),this.renderedCategories[c]=u,h.appendChild(u.el)),void(u&&u.append(s))}n?n.appendChild(s):this.append(s)},getCategoriesEl:function(){return this.catsEl||(this.catsEl=this.el.querySelector("."+this.catsClass)),this.catsEl},getBlocksEl:function(){return this.blocksEl||(this.blocksEl=this.el.querySelector("."+this.noCatClass+" ."+this.blockContClass)),this.blocksEl},append:function(t){var e=this.getBlocksEl();e&&e.appendChild(t)},render:function(){var t=this,e=document.createDocumentFragment();return this.catsEl=null,this.blocksEl=null,this.renderedCategories=[],this.el.innerHTML='\n
\n
\n
\n
\n ',this.collection.each(function(n){return t.add(n,e)}),this.append(e),this.$el.addClass(this.blockContClass+"s"),this}})}).call(e,n(1))},function(t,e,n){"use strict";(function(e){var i=n(2);t.exports=e.View.extend({events:{mousedown:"startDrag"},initialize:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.config=e,this.endDrag=this.endDrag.bind(this),this.ppfx=e.pStylePrefix||"",this.listenTo(this.model,"destroy remove",this.remove)},startDrag:function(t){if(0===t.button&&this.config.getSorter){this.config.em.refreshCanvas();var e=this.config.getSorter();e.setDragHelper(this.el,t),e.setDropContent(this.model.get("content")),e.startSort(this.el),(0,i.on)(document,"mouseup",this.endDrag)}},endDrag:function(t){(0,i.off)(document,"mouseup",this.endDrag);var e=this.config.getSorter();e.moved=0,e.endMove()},render:function(){var t=this.el,e=this.ppfx,n=e+"block";return t.className+=" "+n+" "+e+"one-bg "+e+"four-color-h",t.innerHTML='
'+this.model.get("label")+"
",this}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=n(0);t.exports=i.View.extend({template:e.template('\n
\n \n <%= label %>\n
\n
\n '),events:{},initialize:function(){var t=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});this.config=t;var e=this.config.pStylePrefix||"";this.pfx=e,this.caretR="fa fa-caret-right",this.caretD="fa fa-caret-down",this.iconClass=e+"caret-icon",this.activeClass=e+"open",this.className=e+"block-category",this.events["click ."+e+"title"]="toggle",this.listenTo(this.model,"change:open",this.updateVisibility),this.delegateEvents()},updateVisibility:function(){this.model.get("open")?this.open():this.close()},open:function(){this.el.className=this.className+" "+this.activeClass,this.getIconEl().className=this.iconClass+" "+this.caretD,this.getBlocksEl().style.display=""},close:function(){this.el.className=this.className,this.getIconEl().className=this.iconClass+" "+this.caretR,this.getBlocksEl().style.display="none"},toggle:function(){var t=this.model;t.set("open",!t.get("open"))},getIconEl:function(){return this.iconEl||(this.iconEl=this.el.querySelector("."+this.iconClass)),this.iconEl},getBlocksEl:function(){return this.blocksEl||(this.blocksEl=this.el.querySelector("."+this.pfx+"blocks-c")),this.blocksEl},append:function(t){this.getBlocksEl().appendChild(t)},render:function(){return this.el.innerHTML=this.template({pfx:this.pfx,label:this.model.get("label")}),this.el.className=this.className,this.updateVisibility(),this}})}).call(e,n(1))},function(t,e,n){"use strict";t.exports=function(t){var e=t.$,n=t.Backbone;if(n){var i=n.View.prototype,r={};i.eventNsMap=r,i.delegate=function(t,e,n){var i=".delegateEvents"+this.cid;this.$el.on(t,e,n);var o=r[i];return o||(o=[],r[i]=o),o.push({eventName:t,selector:e,listener:n}),this},i.undelegateEvents=function(){var t=this,e=".delegateEvents"+this.cid;if(this.$el){var n=r[e];n&&n.forEach(function(e){var n=e.eventName;e.selector,e.listener;t.$el.off(n)})}return this},i.undelegate=function(t,e,n){var i=this,o=".delegateEvents"+this.cid,s=r[o];return s&&s.forEach(function(n){var r=n.eventName,o=n.selector;n.listener;r==t&&o==e&&i.$el.off(r)}),this}}if(e&&"jQuery"!==e.prototype.constructor.name){var o=e.fn,s=e.prototype.on,a=e.prototype.off,l=e.prototype.trigger,c=e.prototype.offset,u=function(t){return t.split(/[,\s]+/g)},h=function(t){return t.split(".")};o.on=function(t,e,n,i){var r=this;if("string"==typeof t){var o=u(t);if(1==o.length){t=o[0];var a=h(t);if(0!==t.indexOf(".")&&(t=a[0]),a=a.slice(1),a.length){this.data("_cashNs");this.data("_cashNs",a)}return s.call(this,t,e,n,i)}return o.forEach(function(t){return r.on(t,e,n,i)}),this}return s.call(this,t,e,n,i)},o.off=function(t,e){var n=this;if("string"==typeof t){var i=u(t);if(1==i.length){t=i[0];var r=h(t);return 0!==t.indexOf(".")&&(t=r[0]),r=r.slice(1),r.length,a.call(this,t,e)}return i.forEach(function(t){return n.off(t,e)}),this}return a.call(this,t,e)},o.trigger=function(t,n){var i=this;if(t instanceof e.Event)return this.trigger(t.type,n);if("string"==typeof t){var r=u(t);if(1==r.length){t=r[0];var o=h(t);return 0!==t.indexOf(".")&&(t=o[0]),o=o.slice(1),o.length,l.call(this,t,n)}return r.forEach(function(t){return i.trigger(t,n)}),this}return l.call(this,t,n)},o.hide=function(){return this.css("display","none")},o.show=function(){return this.css("display","block")},o.focus=function(){var t=this.get(0);return t&&t.focus(),this},o.remove=function(){return this.each(function(t){return t.parentNode&&t.parentNode.removeChild(t)})},o.bind=function(t,e){return this.on(t,e)},o.unbind=function(t,e){return this.off(t,e)},o.click=function(t){return t?this.on("click",t):this.trigger("click")},o.change=function(t){return t?this.on("change",t):this.trigger("change")},o.keydown=function(t){return t?this.on("keydown",t):this.trigger("keydown")},o.delegate=function(t,e,n,i){return i||(i=n),this.on(e,t,function(t){t.data=n,i(t)})},o.scrollLeft=function(){var t=this.get(0);t=9==t.nodeType?t.defaultView:t;var e=t instanceof Window?t:null;return e?e.pageXOffset:t.scrollLeft||0},o.scrollTop=function(){var t=this.get(0);t=9==t.nodeType?t.defaultView:t;var e=t instanceof Window?t:null;return e?e.pageYOffset:t.scrollTop||0},o.offset=function(t){var e=void 0,n=void 0;return t&&(e=t.top,n=t.left),void 0!==e&&this.css("top",e+"px"),void 0!==n&&this.css("left",n+"px"),c.call(this)},e.map=function(t,e){for(var n=[],i=0;it.maximumStackLength&&(t.shift(),t.pointer--)}}}function h(){}function d(e,n,i,o){if("object"==typeof n)return t.each(n,function(t,n){2===e?d(e,t,i,o):d(e,n,t,i)});switch(e){case 0:r(i,"undo","redo","on")&&t.all(t.pick(i,"undo","redo","on"),t.isFunction)&&(o[n]=i);break;case 1:o[n]&&t.isObject(i)&&(o[n]=t.extend({},o[n],i));break;case 2:delete o[n]}return this}var f=Array.prototype.slice,p=function(){function e(){i++,n=!0,t.defer(function(){n=!1})}var n=!1,i=-1;return function(){return n||e(),i}}();o.prototype={isRegistered:function(e){return e&&e.cid?this.registeredObjects[e.cid]:t.contains(this.registeredObjects,e)},register:function(t){return!this.isRegistered(t)&&(t&&t.cid?(this.registeredObjects[t.cid]=t,this.cidIndexes.push(t.cid)):this.registeredObjects.push(t),!0)},unregister:function(e){if(this.isRegistered(e)){if(e&&e.cid)delete this.registeredObjects[e.cid],this.cidIndexes.splice(t.indexOf(this.cidIndexes,e.cid),1);else{var n=t.indexOf(this.registeredObjects,e);this.registeredObjects.splice(n,1)}return!0}return!1},get:function(){return t.map(this.cidIndexes,function(t){return this.registeredObjects[t]},this).concat(this.registeredObjects)}};var g={add:{undo:function(t,e,n,i){t.remove(n,i)},redo:function(t,e,n,i){i.index&&(i.at=i.index),t.add(n,i)},on:function(e,n,i){return{object:n,before:void 0,after:e,options:t.clone(i)}}},remove:{undo:function(t,e,n,i){"index"in i&&(i.at=i.index),t.add(e,i)},redo:function(t,e,n,i){t.remove(e,i)},on:function(e,n,i){return{object:n,before:e,after:void 0,options:t.clone(i)}}},change:{undo:function(e,n,i,r){t.isEmpty(n)?t.each(t.keys(i),e.unset,e):(e.set(n),r&&r.unsetData&&r.unsetData.before&&r.unsetData.before.length&&t.each(r.unsetData.before,e.unset,e))},redo:function(e,n,i,r){t.isEmpty(i)?t.each(t.keys(n),e.unset,e):(e.set(i),r&&r.unsetData&&r.unsetData.after&&r.unsetData.after.length&&t.each(r.unsetData.after,e.unset,e))},on:function(e,n){var i=e.changedAttributes(),r=t.keys(i),o=t.pick(e.previousAttributes(),r),s=t.keys(o),a=(n||(n={})).unsetData={after:[],before:[]};return r.length!=s.length&&(r.length>s.length?t.each(r,function(t){t in o||a.before.push(t)},this):t.each(s,function(t){t in i||a.after.push(t)})),{object:e,before:o,after:i,options:t.clone(n)}}},reset:{undo:function(t,e,n){t.reset(e)},redo:function(t,e,n){t.reset(n)},on:function(e,n){return{object:e,before:n.previousModels,after:t.clone(e.models)}}}};h.prototype=g;var v=e.Model.extend({defaults:{type:null,object:null,before:null,after:null,magicFusionIndex:null},undo:function(t){a("undo",this.attributes)},redo:function(t){a("redo",this.attributes)}}),m=e.Collection.extend({model:v,pointer:-1,track:!1,isCurrentlyUndoRedoing:!1,maximumStackLength:1/0,setMaxLength:function(t){this.maximumStackLength=t}}),y=e.Model.extend({defaults:{maximumStackLength:1/0,track:!1},initialize:function(e){this.stack=new m,this.objectRegistry=new o,this.undoTypes=new h,this.stack.setMaxLength(this.get("maximumStackLength")),this.on("change:maximumStackLength",function(t,e){this.stack.setMaxLength(e)},this),e&&e.track&&this.startTracking(),e&&e.register&&(t.isArray(e.register)||t.isArguments(e.register)?n(this.register,this,e.register):this.register(e.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(t){u(this.stack,t,i(arguments,1),this.undoTypes)},register:function(){s("on",arguments,this._addToStack,this)},unregister:function(){s("off",arguments,this._addToStack,this)},unregisterAll:function(){n(this.unregister,this,this.objectRegistry.get())},undo:function(t){l("undo",this,this.stack,t)},undoAll:function(){l("undo",this,this.stack,!1,!0)},redo:function(t){l("redo",this,this.stack,t)},redoAll:function(){l("redo",this,this.stack,!1,!0)},isAvailable:function(t){var e=this.stack,n=e.length;switch(t){case"undo":return n>0&&e.pointer>-1;case"redo":return n>0&&e.pointer1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=this.get("contentTypeJson"),s=this.get("headers")||{},a=this.get("params"),l=n.body||{},c=void 0,u=void 0;for(var h in a)l[h]=a[h];if((0,o.isUndefined)(s["X-Requested-With"])&&(s["X-Requested-With"]="XMLHttpRequest"),(0,o.isUndefined)(s["Content-Type"])&&r&&(s["Content-Type"]="application/json; charset=utf-8"),r)u=JSON.stringify(l);else{u=new FormData;for(var d in l)u.append(d,l[d])}c={method:n.method||"post",credentials:"include",headers:s},"post"===c.method&&(c.body=u),this.onStart(),this.fetch(t,c).then(function(t){return 1==(t.status/200|0)?t.text():t.text().then(function(t){return Promise.reject(t)})}).then(function(t){return e.onResponse(t,i)}).catch(function(t){return e.onError(t)})}})},function(t,e,n){(function(e){!function(n){function i(){}function r(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],h(t,this)}function s(t,e){for(;3===t._state;)t=t._value;if(0===t._state)return void t._deferreds.push(e);t._handled=!0,o._immediateFn(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?a:l)(e.promise,t._value);var i;try{i=n(t._value)}catch(t){return void l(e.promise,t)}a(e.promise,i)})}function a(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof o)return t._state=3,t._value=e,void c(t);if("function"==typeof n)return void h(r(n,e),t)}t._state=1,t._value=e,c(t)}catch(e){l(t,e)}}function l(t,e){t._state=2,t._value=e,c(t)}function c(t){2===t._state&&0===t._deferreds.length&&o._immediateFn(function(){t._handled||o._unhandledRejectionFn(t._value)});for(var e=0,n=t._deferreds.length;e=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(77),e.setImmediate=setImmediate,e.clearImmediate=clearImmediate},function(t,e,n){(function(t,e){!function(t,n){"use strict";function i(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n1)for(var n=1;n<%= deviceLabel %>
\n
\n \n \n \n
\n
\n
\n
\n '),events:{change:"updateDevice"},initialize:function(t){this.config=t.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 t=this.em;if(t){var e=this.devicesEl,n=e?e.val():"";t.set("device",n)}},updateSelect:function(){var t=this.em,e=this.devicesEl;if(t&&t.getDeviceModel&&e){var n=t.getDeviceModel(),i=n?n.get("name"):"";e.val(i)}},getOptions:function(){var t="";return this.collection.each(function(e){var n=e.get("name");t+='"}),t},render:function(){var t=this.ppfx;return this.$el.html(this.template({ppfx:t,deviceLabel:this.config.deviceLabel})),this.devicesEl=this.$el.find("."+t+"devices"),this.devicesEl.append(this.getOptions()),this.el.className=t+"devices-c",this}})}).call(e,n(1))},function(t,e,n){"use strict";t.exports=function(){var t,e,i={},r=n(85),o=n(86),s=n(25);return{compTypes:"",name:"Parser",init:function(n){i=n||{};for(var a in r)a in i||(i[a]=r[a]);return t=new s(i),e=new o(i),this},parseHtml:function(n){return t.compTypes=this.compTypes,t.parse(n,e)},parseCss:function(t){return e.parse(t)}}}},function(t,e,n){"use strict";t.exports={textTags:["br","b","i","u","a","ul","ol"]}},function(t,e,n){"use strict";t.exports=function(t){return{parseSelector:function(t){for(var e=[],n=[],i=t.split(","),r=0,o=i.length;r1&&void 0!==arguments[1]?arguments[1]:{};"object"==(void 0===t?"undefined":i(t))?n=t:n.name=t,n.label&&!n.name&&(n.name=l.escapeName(n.label));var r=n.name,o=r?this.get(r,n.type):e.where(n)[0];return o||e.add(n)},addClass:function(t){var n=[];return(0,r.isString)(t)&&(t=t.trim().split(" ")),t.forEach(function(t){return n.push(e.add({name:t}))}),n},get:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l.TYPE_CLASS;return e.where({name:t,type:n})[0]},getAll:function(){return e},render:function(t){if(t){return new u({collection:new c(t),config:s}).render().el}return o.render().el}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"clm-",selectors:[],label:"Classes",statesLabel:"- State -",selectedLabel:"Selected",states:[{name:"hover",label:"Hover"},{name:"active",label:"Click"},{name:"nth-of-type(2n)",label:"Even/Odd"}]}},function(t,e,n){"use strict";(function(e){var i=n(0),r=n(90);t.exports=i.View.extend({template:e.template('\n
\n
<%= label %>
\n
\n \n
\n \n \n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n \n
\n
\n
<%= selectedLabel %>
\n
\n
\n
'),events:{},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config=t.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.em=this.target,this.listenTo(this.target,"change:selectedComponent",this.componentChanged),this.listenTo(this.target,"component:update:classes",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(t){this.updateStateVis()},getStateOptions:function(){for(var t="",e=0;e'+this.states[e].label+"";return t},addNew:function(t){this.addToClasses(t)},startNewTag:function(t){this.$addBtn.get(0).style.display="none",this.$input.show().focus()},endNewTag:function(t){this.$addBtn.get(0).style.display="",this.$input.hide().val("")},onInputKeyUp:function(t){13===t.keyCode?this.addNewTag(this.$input.val()):27===t.keyCode&&this.endNewTag()},componentChanged:function(t){this.compTarget=this.target.get("selectedComponent");var e=this.compTarget,n=[];e&&(this.getStates().val(e.get("state")),n=e.get("classes").getValid()),this.collection.reset(n),this.updateStateVis()},updateStateVis:function(){var t=this.em,e=t&&t.getConfig("avoidInlineStyle");this.collection.length||e?this.getStatesC().css("display","block"):this.getStatesC().css("display","none"),this.updateSelector()},updateSelector:function(){var t=this.target.getSelected();if(this.compTarget=t,t&&t.get){var e=t.get("state"),n=this.collection,i=n.getFullString(n.getStyleable());i=i||"#"+t.getId(),i+=e?":"+e:"";var r=this.el.querySelector("#"+this.pfx+"sel");r&&(r.innerHTML=i)}},stateChanged:function(t){this.compTarget&&(this.compTarget.set("state",this.$states.val()),this.updateSelector())},addNewTag:function(t){var e=this.target,n=this.compTarget;if(t.trim()){if(e){var i=e.get("SelectorManager"),r=i.add({label:t});if(n){var o=n.get("classes");o.length;o.add(r);o.length;this.collection.add(r),this.updateStateVis()}}this.endNewTag()}},addToClasses:function(t,e){var n=e||null,i=new r({model:t,config:this.config,coll:this.collection}),o=i.render().el;return n?n.appendChild(o):this.getClasses().append(o),o},renderClasses:function(){var t=document.createDocumentFragment();return this.collection.each(function(e){this.addToClasses(e,t)},this),this.getClasses()&&this.getClasses().empty().append(t),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(){var t=this.config;return this.$el.html(this.template({selectedLabel:t.selectedLabel,statesLabel:t.statesLabel,label:t.label,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}})}).call(e,n(1))},function(t,e,n){"use strict";var i=n(7);t.exports=n(0).View.extend({template:function(){var t=this.pfx;this.ppfx;return'\n \n '+(this.model.get("label")||"")+'\n \n ⨯\n \n '},events:{"click [data-tag-remove]":"removeTag","click [data-tag-status]":"changeStatus","dblclick [data-tag-name]":"startEditTag","focusout [data-tag-name]":"endEditTag"},initialize:function(t){this.config=t.config||{},this.coll=t.coll||null,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.target=this.config.em,this.listenTo(this.model,"change:active",this.updateStatus)},getInputEl:function(){return this.inputEl||(this.inputEl=this.el.querySelector("[data-tag-name]")),this.inputEl},startEditTag:function(){var t=this.getInputEl();t.contentEditable=!0,t.focus()},endEditTag:function(){var t=this.model,e=this.getInputEl(),n=e.textContent,r=i.escapeName(n),o=this.target,s=o&&o.get("SelectorManager");e.contentEditable=!1,s&&(s.get(r)?e.innerText=t.get("label"):t.set({name:r,label:n}))},changeStatus:function(){this.model.set("active",!this.model.get("active"))},removeTag:function(t){var e=this,n=this.target,i=this.model,r=this.coll,o=(this.el,n&&n.get("selectedComponent"));o&&(o.get,o.get("classes").remove(i)),r&&r.remove(i),setTimeout(function(){return e.remove()},0)},updateStatus:function(){var t="fa-check-square-o";this.$chk||(this.$chk=this.$el.find("#"+this.pfx+"checkbox")),this.model.get("active")?(this.$chk.removeClass("fa-square-o").addClass(t),this.$el.removeClass("opac50")):(this.$chk.removeClass(t).addClass("fa-square-o"),this.$el.addClass("opac50"))},render:function(){var t=this.pfx,e=this.ppfx;return this.$el.html(this.template()),this.$el.attr("class",t+"tag "+e+"three-bg"),this.updateStatus(),this}})},function(t,e,n){"use strict";t.exports=function(){var t,e,i={},r=n(92),o=n(93),s=n(94);return{name:"Modal",init:function(n){i=n||{};for(var a in r)a in i||(i[a]=r[a]);var l=i.pStylePrefix;return l&&(i.stylePrefix=l+i.stylePrefix),t=new o(i),e=new s({model:t,config:i}),this},postRender:function(t){this.render().appendTo(t.el)},open:function(){return e.show(),this},close:function(){return e.hide(),this},isOpen:function(){return!!t.get("open")},setTitle:function(e){return t.set("title",e),this},getTitle:function(){return t.get("title")},setContent:function(e){return t.set("content"," "),t.set("content",e),this},getContent:function(){return t.get("content")},getContentEl:function(){return e.getContent().get(0)},getModel:function(){return t},render:function(){return e.render().$el}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"mdl-",title:"",content:"",backdrop:!0}},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{title:"",content:"",open:!1}})},function(t,e,n){"use strict";t.exports=n(0).View.extend({template:function(t){var e=t.pfx,n=t.ppfx,i=t.content;return'
\n
\n
'+t.title+'
\n
⨯
\n
\n
\n
'+i+'
\n
\n
\n
\n
\n '},events:{},initialize:function(t){var e=this.model,n=t.config||{},i=n.stylePrefix||"",r=n.backdrop;this.config=n,this.pfx=i,this.ppfx=n.pStylePrefix||"",this.listenTo(e,"change:open",this.updateOpen),this.listenTo(e,"change:title",this.updateTitle),this.listenTo(e,"change:content",this.updateContent),this.events["click ."+i+"btn-close"]="hide",r&&(this.events["click ."+i+"backlayer"]="hide"),this.delegateEvents()},getCollector:function(){return this.$collector||(this.$collector=this.$el.find("."+this.pfx+"collector")),this.$collector},getContent:function(){var t=this.pfx;return this.$content||(this.$content=this.$el.find("."+t+"content #"+t+"c")),this.$content},getTitle:function(){return this.$title||(this.$title=this.$el.find("."+this.pfx+"title")),this.$title.get(0)},updateContent:function(){var t=this.getContent(),e=t.children(),n=this.getCollector(),i=this.model.get("content");e.length&&n.append(e),t.empty().append(i)},updateTitle:function(){var t=this.getTitle();t&&(t.innerHTML=this.model.get("title"))},updateOpen:function(){this.el.style.display=this.model.get("open")?"":"none"},hide:function(){this.model.set("open",0)},show:function(){this.model.set("open",1)},render:function(){var t=this.$el,e=this.pfx,n=(this.ppfx,this.model.toJSON());return n.pfx=this.pfx,n.ppfx=this.ppfx,t.html(this.template(n)),t.attr("class",e+"container"),this.updateOpen(),this}})},function(t,e,n){"use strict";t.exports=function(){var t={},e=n(96),i=n(97),r=n(98),o=n(99),s=n(100),a=n(101),l=n(106),c={},u={},h={},d={};return{getConfig:function(){return t},config:t,EditorView:l,name:"CodeManager",init:function(n){t=n||{};for(var l in e)l in t||(t[l]=e[l]);var c=t.pStylePrefix;return c&&(t.stylePrefix=c+t.stylePrefix),u.html=new i,u.css=new r,u.json=new o,u.js=new s,d.CodeMirror=new a,this.loadDefaultGenerators().loadDefaultViewers(),this},addGenerator:function(t,e){return c[t]=e,this},getGenerator:function(t){return c[t]||null},getGenerators:function(){return c},addViewer:function(t,e){return h[t]=e,this},getViewer:function(t){return h[t]||null},getViewers:function(){return h},updateViewer:function(t,e){t.setContent(e)},getCode:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i.em=t.em;var r=this.getGenerator(n);return r?r.build(e,i):""},loadDefaultGenerators:function(){for(var t in u)this.addGenerator(t,u[t]);return this},loadDefaultViewers:function(){for(var t in d)this.addViewer(t,d[t]);return this}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"cm-",inlineCss:!1}},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({build:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.get("components");return e.exportWrapper?e.wrappesIsBody?""+this.buildModels(n)+"":t.toHTML():this.buildModels(n)},buildModels:function(t){var e="";return t.each(function(t){e+=t.toHTML()}),e}})},function(t,e,n){"use strict";t.exports=n(0).Model.extend({initialize:function(){this.compCls=[],this.ids=[]},buildFromModel:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i="",r=this.em,o=r&&r.getConfig("avoidInlineStyle"),s=t.styleToString(),a=t.get("classes"),l=n.wrappesIsBody,c=t.get("wrapper");if(this.ids.push("#"+t.getId()),a.each(function(t){return e.compCls.push(t.getFullName())}),(!o||c)&&s){var u="#"+t.getId();u=l&&c?"body":u,i=u+"{"+s+"}"}return t.components().each(function(t){return i+=e.buildFromModel(t,n)}),i},build:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.cssc;this.em=n.em||"",this.compCls=[],this.ids=[];var r=this.buildFromModel(t,n);if(i){var o=i.getAll(),s={};o.each(function(t){var n=t.get("mediaText");if(n){var i=s[n];return void(i?i.push(t):s[n]=[t])}r+=e.buildFromRule(t)});for(var a in s){var l="";s[a].forEach(function(t){return l+=e.buildFromRule(t)}),l&&(r+="@media "+a+"{"+l+"}")}}return r},buildFromRule:function(t){var e=this,n="",i=t.selectorsToString(),r=t.selectorsToString({skipAdd:1}),o=void 0;if(t.get("selectors").each(function(t){var n=t.getFullName();(e.compCls.indexOf(n)>=0||e.ids.indexOf(n)>=0)&&(o=1)}),r&&o||t.get("selectorsAdd")){var s=t.styleToString();s&&(n+=i+"{"+s+"}")}return n}})},function(t,e,n){"use strict";(function(e){var i=n(0);t.exports=i.Model.extend({build:function(t){var n=t.toJSON();return this.beforeEach(n),e.each(n,function(t,e){var r=n[e];if(r instanceof i.Model)n[e]=this.build(r);else if(r instanceof i.Collection){var o=r;n[e]=[],o.length&&o.each(function(t,i){n[e][i]=this.build(t)},this)}},this),n},beforeEach:function(t){delete t.status}})}).call(e,n(1))},function(t,e,n){"use strict";(function(e){var i=n(0);t.exports=i.Model.extend({mapModel:function(t){var n="",i=t.get("script"),r=t.get("type"),o=t.get("components"),s=t.getId();if(i){var a=t.get("attributes");a=e.extend({},a,{id:s}),t.set("attributes",a);var l=t.getScriptString();if(t.get("scriptUpdated"))this.mapJs[r+"-"+s]={ids:[s],code:l};else{var c=this.mapJs[r];c?c.ids.push(s):this.mapJs[r]={ids:[s],code:l}}}return o.each(function(t){n+=this.mapModel(t)},this),n},build:function(t){this.mapJs={},this.mapModel(t);var e="";for(var n in this.mapJs){var i=this.mapJs[n];e+="\n var items = document.querySelectorAll('"+("#"+i.ids.join(", #"))+"');\n for (var i = 0, len = items.length; i < len; i++) {\n (function(){"+i.code+"}.bind(items[i]))();\n }"}return e}})}).call(e,n(1))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e-1?t.backUp(i.length-r):i.match(/<\/?$/)&&(t.backUp(i.length),t.match(e,!1)||t.match(i)),n}function n(t){var e=l[t];return e||(l[t]=new RegExp("\\s+"+t+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*"))}function i(t,e){var i=t.match(n(e));return i?/^\s*(.*?)\s*$/.exec(i[2])[1]:""}function r(t,e){return new RegExp((e?"^":"")+"","i")}function o(t,e){for(var n in t)for(var i=e[n]||(e[n]=[]),r=t[n],o=r.length-1;o>=0;o--)i.unshift(r[o])}function s(t,e){for(var n=0;n\s\/]/.test(i.current())&&(a=o.htmlState.tagName&&o.htmlState.tagName.toLowerCase())&&u.hasOwnProperty(a))o.inTag=a+" ";else if(o.inTag&&d&&/>$/.test(i.current())){var f=/^([\S]+) (.*)/.exec(o.inTag);o.inTag=null;var p=">"==i.current()&&s(u[f[1]],f[2]),g=t.getMode(n,p),v=r(f[1],!0),m=r(f[1],!1);o.token=function(t,n){return t.match(v,!1)?(n.token=l,n.localState=n.localMode=null,null):e(t,m,n.localMode.token(t,n.localState))},o.localMode=g,o.localState=t.startState(g,c.indent(o.htmlState,""))}else o.inTag&&(o.inTag+=i.current(),i.eol()&&(o.inTag+=" "));return h}var c=t.getMode(n,{name:"xml",htmlMode:!0,multilineTagIndentFactor:i.multilineTagIndentFactor,multilineTagIndentPastTag:i.multilineTagIndentPastTag}),u={},h=i&&i.tags,d=i&&i.scriptTypes;if(o(a,u),h&&o(h,u),d)for(var f=d.length-1;f>=0;f--)u.script.unshift(["type",d[f].matches,d[f].mode]);return{startState:function(){return{token:l,inTag:null,localMode:null,localState:null,htmlState:t.startState(c)}},copyState:function(e){var n;return e.localState&&(n=t.copyState(e.localMode,e.localState)),{token:e.token,inTag:e.inTag,localMode:e.localMode,localState:n,htmlState:t.copyState(c,e.htmlState)}},token:function(t,e){return e.token(t,e)},indent:function(e,n,i){return!e.localMode||/^\s*<\//.test(n)?c.indent(e.htmlState,n):e.localMode.indent?e.localMode.indent(e.localState,n,i):t.Pass},innerMode:function(t){return{state:t.localState||t.htmlState,mode:t.localMode||c}}}},"xml","javascript","css"),t.defineMIME("text/html","htmlmixed")})},function(t,e,n){!function(t){t(n(6))}(function(t){"use strict";var e={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},n={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1};t.defineMode("xml",function(i,r){function o(t,e){function n(n){return e.tokenize=n,n(t,e)}var i=t.next();if("<"==i)return t.eat("!")?t.eat("[")?t.match("CDATA[")?n(l("atom","]]>")):null:t.match("--")?n(l("comment","--\x3e")):t.match("DOCTYPE",!0,!0)?(t.eatWhile(/[\w\._\-]/),n(c(1))):null:t.eat("?")?(t.eatWhile(/[\w\._\-]/),e.tokenize=l("meta","?>"),"meta"):(E=t.eat("/")?"closeTag":"openTag",e.tokenize=s,"tag bracket");if("&"==i){var r;return r=t.eat("#")?t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";"):t.eatWhile(/[\w\.\-:]/)&&t.eat(";"),r?"atom":"error"}return t.eatWhile(/[^&<]/),null}function s(t,e){var n=t.next();if(">"==n||"/"==n&&t.eat(">"))return e.tokenize=o,E=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return E="equals",null;if("<"==n){e.tokenize=o,e.state=f,e.tagName=e.tagStart=null;var i=e.tokenize(t,e);return i?i+" tag error":"tag error"}return/[\'\"]/.test(n)?(e.tokenize=a(n),e.stringStartCol=t.column(),e.tokenize(t,e)):(t.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function a(t){var e=function(e,n){for(;!e.eol();)if(e.next()==t){n.tokenize=s;break}return"string"};return e.isInAttribute=!0,e}function l(t,e){return function(n,i){for(;!n.eol();){if(n.match(e)){i.tokenize=o;break}n.next()}return t}}function c(t){return function(e,n){for(var i;null!=(i=e.next());){if("<"==i)return n.tokenize=c(t+1),n.tokenize(e,n);if(">"==i){if(1==t){n.tokenize=o;break}return n.tokenize=c(t-1),n.tokenize(e,n)}}return"meta"}}function u(t,e,n){this.prev=t.context,this.tagName=e,this.indent=t.indented,this.startOfLine=n,(k.doNotIndent.hasOwnProperty(e)||t.context&&t.context.noIndent)&&(this.noIndent=!0)}function h(t){t.context&&(t.context=t.context.prev)}function d(t,e){for(var n;;){if(!t.context)return;if(n=t.context.tagName,!k.contextGrabbers.hasOwnProperty(n)||!k.contextGrabbers[n].hasOwnProperty(e))return;h(t)}}function f(t,e,n){return"openTag"==t?(n.tagStart=e.column(),p):"closeTag"==t?g:f}function p(t,e,n){return"word"==t?(n.tagName=e.current(),M="tag",y):(M="error",p)}function g(t,e,n){if("word"==t){var i=e.current();return n.context&&n.context.tagName!=i&&k.implicitlyClosed.hasOwnProperty(n.context.tagName)&&h(n),n.context&&n.context.tagName==i||!1===k.matchClosing?(M="tag",v):(M="tag error",m)}return M="error",m}function v(t,e,n){return"endTag"!=t?(M="error",v):(h(n),f)}function m(t,e,n){return M="error",v(t,e,n)}function y(t,e,n){if("word"==t)return M="attribute",b;if("endTag"==t||"selfcloseTag"==t){var i=n.tagName,r=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==t||k.autoSelfClosers.hasOwnProperty(i)?d(n,i):(d(n,i),n.context=new u(n,i,r==n.indented)),f}return M="error",y}function b(t,e,n){return"equals"==t?x:(k.allowMissing||(M="error"),y(t,e,n))}function x(t,e,n){return"string"==t?w:"word"==t&&k.allowUnquoted?(M="string",y):(M="error",y(t,e,n))}function w(t,e,n){return"string"==t?w:y(t,e,n)}var C=i.indentUnit,k={},S=r.htmlMode?e:n;for(var T in S)k[T]=S[T];for(var T in r)k[T]=r[T];var E,M;return o.isInText=!0,{startState:function(t){var e={tokenize:o,state:f,indented:t||0,tagName:null,tagStart:null,context:null};return null!=t&&(e.baseIndent=t),e},token:function(t,e){if(!e.tagName&&t.sol()&&(e.indented=t.indentation()),t.eatSpace())return null;E=null;var n=e.tokenize(t,e);return(n||E)&&"comment"!=n&&(M=null,e.state=e.state(E||n,t,e),M&&(n="error"==M?n+" error":M)),n},indent:function(e,n,i){var r=e.context;if(e.tokenize.isInAttribute)return e.tagStart==e.indented?e.stringStartCol+1:e.indented+C;if(r&&r.noIndent)return t.Pass;if(e.tokenize!=s&&e.tokenize!=o)return i?i.match(/^(\s*)/)[0].length:0;if(e.tagName)return!1!==k.multilineTagIndentPastTag?e.tagStart+e.tagName.length+2:e.tagStart+C*(k.multilineTagIndentFactor||1);if(k.alignCDATA&&/$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:k.htmlMode?"html":"xml",helperType:k.htmlMode?"html":"xml",skipAttribute:function(t){t.state==x&&(t.state=y)}}}),t.defineMIME("text/xml","xml"),t.defineMIME("application/xml","xml"),t.mimeModes.hasOwnProperty("text/html")||t.defineMIME("text/html",{name:"xml",htmlMode:!0})})},function(t,e,n){!function(t){t(n(6))}(function(t){"use strict";t.defineMode("javascript",function(e,n){function i(t){for(var e,n=!1,i=!1;null!=(e=t.next());){if(!n){if("/"==e&&!i)return;"["==e?i=!0:i&&"]"==e&&(i=!1)}n=!n&&"\\"==e}}function r(t,e,n){return Tt=t,Et=n,e}function o(t,e){var n=t.next();if('"'==n||"'"==n)return e.tokenize=s(n),e.tokenize(t,e);if("."==n&&t.match(/^\d+(?:[eE][+\-]?\d+)?/))return r("number","number");if("."==n&&t.match(".."))return r("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return r(n);if("="==n&&t.eat(">"))return r("=>","operator");if("0"==n&&t.eat(/x/i))return t.eatWhile(/[\da-f]/i),r("number","number");if("0"==n&&t.eat(/o/i))return t.eatWhile(/[0-7]/i),r("number","number");if("0"==n&&t.eat(/b/i))return t.eatWhile(/[01]/i),r("number","number");if(/\d/.test(n))return t.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),r("number","number");if("/"==n)return t.eat("*")?(e.tokenize=a,a(t,e)):t.eat("/")?(t.skipToEnd(),r("comment","comment")):St(t,e,1)?(i(t),t.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),r("regexp","string-2")):(t.eat("="),r("operator","operator",t.current()));if("`"==n)return e.tokenize=l,l(t,e);if("#"==n)return t.skipToEnd(),r("error","error");if(It.test(n))return">"==n&&e.lexical&&">"==e.lexical.type||(t.eat("=")?"!"!=n&&"="!=n||t.eat("="):/[<>*+\-]/.test(n)&&(t.eat(n),">"==n&&t.eat(n))),r("operator","operator",t.current());if(Nt.test(n)){t.eatWhile(Nt);var o=t.current();if("."!=e.lastType){if(Dt.propertyIsEnumerable(o)){var c=Dt[o];return r(c.type,c.style,o)}if("async"==o&&t.match(/^\s*[\(\w]/,!1))return r("async","keyword",o)}return r("variable","variable",o)}}function s(t){return function(e,n){var i,s=!1;if(At&&"@"==e.peek()&&e.match(_t))return n.tokenize=o,r("jsonld-keyword","meta");for(;null!=(i=e.next())&&(i!=t||s);)s=!s&&"\\"==i;return s||(n.tokenize=o),r("string","string")}}function a(t,e){for(var n,i=!1;n=t.next();){if("/"==n&&i){e.tokenize=o;break}i="*"==n}return r("comment","comment")}function l(t,e){for(var n,i=!1;null!=(n=t.next());){if(!i&&("`"==n||"$"==n&&t.eat("{"))){e.tokenize=o;break}i=!i&&"\\"==n}return r("quasi","string-2",t.current())}function c(t,e){e.fatArrowAt&&(e.fatArrowAt=null);var n=t.string.indexOf("=>",t.start);if(!(n<0)){if(Lt){var i=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(t.string.slice(t.start,n));i&&(n=i.index)}for(var r=0,o=!1,s=n-1;s>=0;--s){var a=t.string.charAt(s),l=Ft.indexOf(a);if(l>=0&&l<3){if(!r){++s;break}if(0==--r){"("==a&&(o=!0);break}}else if(l>=3&&l<6)++r;else if(Nt.test(a))o=!0;else{if(/["'\/]/.test(a))return;if(o&&!r){++s;break}}}o&&!r&&(e.fatArrowAt=s)}}function u(t,e,n,i,r,o){this.indented=t,this.column=e,this.type=n,this.prev=r,this.info=o,null!=i&&(this.align=i)}function h(t,e){for(var n=t.localVars;n;n=n.next)if(n.name==e)return!0;for(var i=t.context;i;i=i.prev)for(var n=i.vars;n;n=n.next)if(n.name==e)return!0}function d(t,e,n,i,r){var o=t.cc;for($t.state=t,$t.stream=r,$t.marked=null,$t.cc=o,$t.style=e,t.lexical.hasOwnProperty("align")||(t.lexical.align=!0);;){if((o.length?o.pop():Ot?C:w)(n,i)){for(;o.length&&o[o.length-1].lex;)o.pop()();return $t.marked?$t.marked:"variable"==n&&h(t,i)?"variable-2":e}}}function f(){for(var t=arguments.length-1;t>=0;t--)$t.cc.push(arguments[t])}function p(){return f.apply(null,arguments),!0}function g(t){function e(e){for(var n=e;n;n=n.next)if(n.name==t)return!0;return!1}var i=$t.state;if($t.marked="def",i.context){if(e(i.localVars))return;i.localVars={name:t,next:i.localVars}}else{if(e(i.globalVars))return;n.globalVars&&(i.globalVars={name:t,next:i.globalVars})}}function v(){$t.state.context={prev:$t.state.context,vars:$t.state.localVars},$t.state.localVars=Rt}function m(){$t.state.localVars=$t.state.context.vars,$t.state.context=$t.state.context.prev}function y(t,e){var n=function(){var n=$t.state,i=n.indented;if("stat"==n.lexical.type)i=n.lexical.indented;else for(var r=n.lexical;r&&")"==r.type&&r.align;r=r.prev)i=r.indented;n.lexical=new u(i,$t.stream.column(),t,null,n.lexical,e)};return n.lex=!0,n}function b(){var t=$t.state;t.lexical.prev&&(")"==t.lexical.type&&(t.indented=t.lexical.indented),t.lexical=t.lexical.prev)}function x(t){function e(n){return n==t?p():";"==t?f():p(e)}return e}function w(t,e){return"var"==t?p(y("vardef",e.length),J,x(";"),b):"keyword a"==t?p(y("form"),S,w,b):"keyword b"==t?p(y("form"),w,b):"keyword d"==t?$t.stream.match(/^\s*$/,!1)?p():p(y("stat"),E,x(";"),b):"debugger"==t?p(x(";")):"{"==t?p(y("}"),B,b):";"==t?p():"if"==t?("else"==$t.state.lexical.info&&$t.state.cc[$t.state.cc.length-1]==b&&$t.state.cc.pop()(),p(y("form"),S,w,b,nt)):"function"==t?p(lt):"for"==t?p(y("form"),it,w,b):"variable"==t?Lt&&"type"==e?($t.marked="keyword",p(U,x("operator"),U,x(";"))):Lt&&"declare"==e?($t.marked="keyword",p(w)):p(y("stat"),F):"switch"==t?p(y("form"),S,x("{"),y("}","switch"),B,b,b):"case"==t?p(C,x(":")):"default"==t?p(x(":")):"catch"==t?p(y("form"),v,x("("),ct,x(")"),w,b,m):"class"==t?p(y("form"),ht,b):"export"==t?p(y("stat"),gt,b):"import"==t?p(y("stat"),mt,b):"module"==t?p(y("form"),Z,x("{"),y("}"),B,b,b):"async"==t?p(w):"@"==e?p(C,w):f(y("stat"),C,x(";"),b)}function C(t){return T(t,!1)}function k(t){return T(t,!0)}function S(t){return"("!=t?f():p(y(")"),C,x(")"),b)}function T(t,e){if($t.state.fatArrowAt==$t.stream.start){var n=e?N:L;if("("==t)return p(v,y(")"),H(ct,")"),b,x("=>"),n,m);if("variable"==t)return f(v,Z,x("=>"),n,m)}var i=e?P:M;return zt.hasOwnProperty(t)?p(i):"function"==t?p(lt,i):"class"==t?p(y("form"),ut,b):"keyword c"==t||"async"==t?p(e?k:C):"("==t?p(y(")"),E,x(")"),b,i):"operator"==t||"spread"==t?p(e?k:C):"["==t?p(y("]"),Ct,b,i):"{"==t?j($,"}",null,i):"quasi"==t?f(A,i):"new"==t?p(D(e)):p()}function E(t){return t.match(/[;\}\)\],]/)?f():f(C)}function M(t,e){return","==t?p(C):P(t,e,!1)}function P(t,e,n){var i=0==n?M:P,r=0==n?C:k;return"=>"==t?p(v,n?N:L,m):"operator"==t?/\+\+|--/.test(e)||Lt&&"!"==e?p(i):"?"==e?p(C,x(":"),r):p(r):"quasi"==t?f(A,i):";"!=t?"("==t?j(k,")","call",i):"."==t?p(z,i):"["==t?p(y("]"),E,x("]"),b,i):Lt&&"as"==e?($t.marked="keyword",p(U,i)):"regexp"==t?($t.state.lastType=$t.marked="operator",$t.stream.backUp($t.stream.pos-$t.stream.start-1),p(r)):void 0:void 0}function A(t,e){return"quasi"!=t?f():"${"!=e.slice(e.length-2)?p(A):p(C,O)}function O(t){if("}"==t)return $t.marked="string-2",$t.state.tokenize=l,p(A)}function L(t){return c($t.stream,$t.state),f("{"==t?w:C)}function N(t){return c($t.stream,$t.state),f("{"==t?w:k)}function D(t){return function(e){return"."==e?p(t?_:I):"variable"==e&&Lt?p(X,t?P:M):f(t?k:C)}}function I(t,e){if("target"==e)return $t.marked="keyword",p(M)}function _(t,e){if("target"==e)return $t.marked="keyword",p(P)}function F(t){return":"==t?p(b,w):f(M,x(";"),b)}function z(t){if("variable"==t)return $t.marked="property",p()}function $(t,e){if("async"==t)return $t.marked="property",p($);if("variable"==t||"keyword"==$t.style){if($t.marked="property","get"==e||"set"==e)return p(R);var n;return Lt&&$t.state.fatArrowAt==$t.stream.start&&(n=$t.stream.match(/^\s*:\s*/,!1))&&($t.state.fatArrowAt=$t.stream.pos+n[0].length),p(V)}return"number"==t||"string"==t?($t.marked=At?"property":$t.style+" property",p(V)):"jsonld-keyword"==t?p(V):"modifier"==t?p($):"["==t?p(C,x("]"),V):"spread"==t?p(k,V):"*"==e?($t.marked="keyword",p($)):":"==t?f(V):void 0}function R(t){return"variable"!=t?f(V):($t.marked="property",p(lt))}function V(t){return":"==t?p(k):"("==t?f(lt):void 0}function H(t,e,n){function i(r,o){if(n?n.indexOf(r)>-1:","==r){var s=$t.state.lexical;return"call"==s.info&&(s.pos=(s.pos||0)+1),p(function(n,i){return n==e||i==e?f():f(t)},i)}return r==e||o==e?p():p(x(e))}return function(n,r){return n==e||r==e?p():f(t,i)}}function j(t,e,n){for(var i=3;i"==t)return p(U)}function K(t,e){return"variable"==t||"keyword"==$t.style?($t.marked="property",p(K)):"?"==e?p(K):":"==t?p(U):"["==t?p(C,W,x("]"),K):void 0}function G(t){return"variable"==t?p(G):":"==t?p(U):void 0}function Y(t,e){return"<"==e?p(y(">"),H(U,">"),b,Y):"|"==e||"."==t?p(U):"["==t?p(x("]"),Y):"extends"==e?p(U):void 0}function X(t,e){if("<"==e)return p(y(">"),H(U,">"),b,Y)}function J(){return f(Z,W,tt,et)}function Z(t,e){return"modifier"==t?p(Z):"variable"==t?(g(e),p()):"spread"==t?p(Z):"["==t?j(Z,"]"):"{"==t?j(Q,"}"):void 0}function Q(t,e){return"variable"!=t||$t.stream.match(/^\s*:/,!1)?("variable"==t&&($t.marked="property"),"spread"==t?p(Z):"}"==t?f():p(x(":"),Z,tt)):(g(e),p(tt))}function tt(t,e){if("="==e)return p(k)}function et(t){if(","==t)return p(J)}function nt(t,e){if("keyword b"==t&&"else"==e)return p(y("form","else"),w,b)}function it(t){if("("==t)return p(y(")"),rt,x(")"),b)}function rt(t){return"var"==t?p(J,x(";"),st):";"==t?p(st):"variable"==t?p(ot):f(C,x(";"),st)}function ot(t,e){return"in"==e||"of"==e?($t.marked="keyword",p(C)):p(M,st)}function st(t,e){return";"==t?p(at):"in"==e||"of"==e?($t.marked="keyword",p(C)):f(C,x(";"),at)}function at(t){")"!=t&&p(C)}function lt(t,e){return"*"==e?($t.marked="keyword",p(lt)):"variable"==t?(g(e),p(lt)):"("==t?p(v,y(")"),H(ct,")"),b,W,w,m):Lt&&"<"==e?p(y(">"),H(U,">"),b,lt):void 0}function ct(t,e){return"@"==e&&p(C,ct),"spread"==t||"modifier"==t?p(ct):f(Z,W,tt)}function ut(t,e){return"variable"==t?ht(t,e):dt(t,e)}function ht(t,e){if("variable"==t)return g(e),p(dt)}function dt(t,e){return"<"==e?p(y(">"),H(U,">"),b,dt):"extends"==e||"implements"==e||Lt&&","==t?p(Lt?U:C,dt):"{"==t?p(y("}"),ft,b):void 0}function ft(t,e){return"modifier"==t||"async"==t||"variable"==t&&("static"==e||"get"==e||"set"==e)&&$t.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?($t.marked="keyword",p(ft)):"variable"==t||"keyword"==$t.style?($t.marked="property",p(Lt?pt:lt,ft)):"["==t?p(C,x("]"),Lt?pt:lt,ft):"*"==e?($t.marked="keyword",p(ft)):";"==t?p(ft):"}"==t?p():"@"==e?p(C,ft):void 0}function pt(t,e){return"?"==e?p(pt):":"==t?p(U,tt):"="==e?p(k):f(lt)}function gt(t,e){return"*"==e?($t.marked="keyword",p(wt,x(";"))):"default"==e?($t.marked="keyword",p(C,x(";"))):"{"==t?p(H(vt,"}"),wt,x(";")):f(w)}function vt(t,e){return"as"==e?($t.marked="keyword",p(x("variable"))):"variable"==t?f(k,vt):void 0}function mt(t){return"string"==t?p():f(yt,bt,wt)}function yt(t,e){return"{"==t?j(yt,"}"):("variable"==t&&g(e),"*"==e&&($t.marked="keyword"),p(xt))}function bt(t){if(","==t)return p(yt,bt)}function xt(t,e){if("as"==e)return $t.marked="keyword",p(yt)}function wt(t,e){if("from"==e)return $t.marked="keyword",p(C)}function Ct(t){return"]"==t?p():f(H(k,"]"))}function kt(t,e){return"operator"==t.lastType||","==t.lastType||It.test(e.charAt(0))||/[,.]/.test(e.charAt(0))}function St(t,e,n){return e.tokenize==o&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(e.lastType)||"quasi"==e.lastType&&/\{\s*$/.test(t.string.slice(0,t.pos-(n||0)))}var Tt,Et,Mt=e.indentUnit,Pt=n.statementIndent,At=n.jsonld,Ot=n.json||At,Lt=n.typescript,Nt=n.wordCharacters||/[\w$\xa1-\uffff]/,Dt=function(){function t(t){return{type:t,style:"keyword"}}var e=t("keyword a"),n=t("keyword b"),i=t("keyword c"),r=t("keyword d"),o=t("operator"),s={type:"atom",style:"atom"},a={if:t("if"),while:e,with:e,else:n,do:n,try:n,finally:n,return:r,break:r,continue:r,new:t("new"),delete:i,void:i,throw:i,debugger:t("debugger"),var:t("var"),const:t("var"),let:t("var"),function:t("function"),catch:t("catch"),for:t("for"),switch:t("switch"),case:t("case"),default:t("default"),in:o,typeof:o,instanceof:o,true:s,false:s,null:s,undefined:s,NaN:s,Infinity:s,this:t("this"),class:t("class"),super:t("atom"),yield:i,export:t("export"),import:t("import"),extends:i,await:i};if(Lt){var l={type:"variable",style:"type"},c={interface:t("class"),implements:i,namespace:i,module:t("module"),enum:t("module"),public:t("modifier"),private:t("modifier"),protected:t("modifier"),abstract:t("modifier"),readonly:t("modifier"),string:l,number:l,boolean:l,any:l};for(var u in c)a[u]=c[u]}return a}(),It=/[+\-*&%=<>!?|~^@]/,_t=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,Ft="([{}])",zt={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,"jsonld-keyword":!0},$t={state:null,column:null,marked:null,cc:null},Rt={name:"this",next:{name:"arguments"}};return b.lex=!0,{startState:function(t){var e={tokenize:o,lastType:"sof",cc:[],lexical:new u((t||0)-Mt,0,"block",!1),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:t||0};return n.globalVars&&"object"==typeof n.globalVars&&(e.globalVars=n.globalVars),e},token:function(t,e){if(t.sol()&&(e.lexical.hasOwnProperty("align")||(e.lexical.align=!1),e.indented=t.indentation(),c(t,e)),e.tokenize!=a&&t.eatSpace())return null;var n=e.tokenize(t,e);return"comment"==Tt?n:(e.lastType="operator"!=Tt||"++"!=Et&&"--"!=Et?Tt:"incdec",d(e,n,Tt,Et,t))},indent:function(e,i){if(e.tokenize==a)return t.Pass;if(e.tokenize!=o)return 0;var r,s=i&&i.charAt(0),l=e.lexical;if(!/^\s*else\b/.test(i))for(var c=e.cc.length-1;c>=0;--c){var u=e.cc[c];if(u==b)l=l.prev;else if(u!=nt)break}for(;("stat"==l.type||"form"==l.type)&&("}"==s||(r=e.cc[e.cc.length-1])&&(r==M||r==P)&&!/^[,\.=+\-*:?[\(]/.test(i));)l=l.prev;Pt&&")"==l.type&&"stat"==l.prev.type&&(l=l.prev);var h=l.type,d=s==h;return"vardef"==h?l.indented+("operator"==e.lastType||","==e.lastType?l.info+1:0):"form"==h&&"{"==s?l.indented:"form"==h?l.indented+Mt:"stat"==h?l.indented+(kt(e,i)?Pt||Mt:0):"switch"!=l.info||d||0==n.doubleIndentSwitch?l.align?l.column+(d?0:1):l.indented+(d?0:Mt):l.indented+(/^(?:case|default)\b/.test(i)?Mt:2*Mt)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:Ot?null:"/*",blockCommentEnd:Ot?null:"*/",blockCommentContinue:Ot?null:" * ",lineComment:Ot?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:Ot?"json":"javascript",jsonldMode:At,jsonMode:Ot,expressionAllowed:St,skipExpression:function(t){var e=t.cc[t.cc.length-1];e!=C&&e!=k||t.cc.pop()}}}),t.registerHelper("wordChars","javascript",/[\w$]/),t.defineMIME("text/javascript","javascript"),t.defineMIME("text/ecmascript","javascript"),t.defineMIME("application/javascript","javascript"),t.defineMIME("application/x-javascript","javascript"),t.defineMIME("application/ecmascript","javascript"),t.defineMIME("application/json",{name:"javascript",json:!0}),t.defineMIME("application/x-json",{name:"javascript",json:!0}),t.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),t.defineMIME("text/typescript",{name:"javascript",typescript:!0}),t.defineMIME("application/typescript",{name:"javascript",typescript:!0})})},function(t,e,n){!function(t){t(n(6))}(function(t){t.extendMode("css",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(t,e){return/^[;{}]$/.test(e)}}),t.extendMode("javascript",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(t,e,n,i){return this.jsonMode?/^[\[,{]$/.test(e)||/^}/.test(n):(";"!=e||!i.lexical||")"!=i.lexical.type)&&(/^[;{}]$/.test(e)&&!/^;/.test(n))}});var e=/^(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)$/;t.extendMode("xml",{commentStart:"\x3c!--",commentEnd:"--\x3e",newlineAfterToken:function(t,n,i,r){var o=!1;return"html"==this.configuration&&(o=!!r.context&&e.test(r.context.tagName)),!o&&("tag"==t&&/>$/.test(n)&&r.context||/^-1&&a>-1&&a>s&&(t=t.substr(0,s)+t.substring(s+o.commentStart.length,a)+t.substr(a+o.commentEnd.length)),r.replaceRange(t,n,i)}})}),t.defineExtension("autoIndentRange",function(t,e){var n=this;this.operation(function(){for(var i=t.line;i<=e.line;i++)n.indentLine(i,"smart")})}),t.defineExtension("autoFormatRange",function(e,n){function i(){c+="\n",h=!0,++u}for(var r=this,o=r.getMode(),s=r.getRange(e,n).split("\n"),a=t.copyState(o,r.getTokenAt(e).state),l=r.getOption("tabSize"),c="",u=0,h=0===e.ch,d=0;d\n \t
<%= label %>
\n \t
\n
'),initialize:function(t){this.config=t.config||{},this.pfx=this.config.stylePrefix},render:function(){var t=this.model.toJSON();return t.pfx=this.pfx,this.$el.html(this.template(t)),this.$el.attr("class",this.pfx+"editor-c"),this.$el.find("#"+this.pfx+"code").append(this.model.get("input")),this}})}).call(e,n(1))},function(t,e,n){"use strict";t.exports=function(){var t,e,i={},r=n(108),o=n(27),s=n(110),a=(n(29),n(112));return{name:"Panels",init:function(n){i=n||{};for(var o in r)o in i||(i[o]=r[o]);var l=i.pStylePrefix;return l&&(i.stylePrefix=l+i.stylePrefix),t=new s(i.defaults),e=new a({collection:t,config:i}),this},getPanels:function(){return t},getPanelsEl:function(){return e.el},addPanel:function(e){return t.add(e)},removePanel:function(e){return t.remove(e)},getPanel:function(e){var n=t.where({id:e});return n.length?n[0]:null},addButton:function(t,e){var n=this.getPanel(t);return n?n.get("buttons").add(e):null},removeButton:function(t,e){var n=this.getPanel(t);return n&&n.get("buttons").remove(e)},getButton:function(t,e){var n=this.getPanel(t);if(n){var i=n.get("buttons").where({id:e});return i.length?i[0]:null}return null},render:function(){return e.render().el},active:function(){this.getPanels().each(function(t){t.get("buttons").each(function(t){t.get("active")&&t.trigger("updateActive")})})},disableButtons:function(){this.getPanels().each(function(t){t.get("buttons").each(function(t){t.get("disable")&&t.trigger("change:disable")})})},Panel:o}}},function(t,e,n){"use strict";var i="sw-visibility",r="export-template",o="open-layers",s="open-blocks",a="fullscreen",l="preview";t.exports={stylePrefix:"pn-",defaults:[{id:"commands",buttons:[{}]},{id:"options",buttons:[{active:!0,id:i,className:"fa fa-square-o",command:i,context:i,attributes:{title:"View components"}},{id:l,className:"fa fa-eye",command:l,context:l,attributes:{title:"Preview"}},{id:a,className:"fa fa-arrows-alt",command:a,context:a,attributes:{title:"Fullscreen"}},{id:r,className:"fa fa-code",command:r,attributes:{title:"View code"}}]},{id:"views",buttons:[{id:"open-sm",className:"fa fa-paint-brush",command:"open-sm",active:!0,attributes:{title:"Open Style Manager"}},{id:"open-tm",className:"fa fa-cog",command:"open-tm",attributes:{title:"Settings"}},{id:o,className:"fa fa-bars",command:o,attributes:{title:"Open Layer Manager"}},{id:s,className:"fa fa-th-large",command:s,attributes:{title:"Open Blocks"}}]}],em:null,delayBtnsShow:300}},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{id:"",className:"",command:"",context:"",buttons:[],attributes:{},options:{},active:!1,dragDrop:!1,runDefaultCommand:!0,stopDefaultCommand:!1,disable:!1},initialize:function(t){if(this.get("buttons").length){var e=n(28);this.set("buttons",new e(this.get("buttons")))}}})},function(t,e,n){"use strict";var i=n(0),r=n(27);t.exports=i.Collection.extend({model:r})},function(t,e,n){"use strict";(function(e,i){var r=n(1),o=e.$;t.exports=e.View.extend({tagName:"span",initialize:function(t){i.bindAll(this,"startTimer","stopTimer","showButtons","hideButtons","closeOnKeyPress","onDrop","initSorter","stopDrag");var e=this.model.get("className");this.config=t.config||{},this.em=this.config.em||{};var n=this.config.stylePrefix||"",r=this.config.pStylePrefix||"";this.pfx=n,this.ppfx=this.config.pStylePrefix||"",this.id=n+this.model.get("id"),this.activeCls=n+"active "+r+"four-color",this.disableCls=n+"active",this.btnsVisCls=n+"visible",this.parentM=t.parentM||null,this.className=n+"btn"+(e?" "+e:""),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.listenTo(this.model,"change:disable",this.updateDisable),this.model.get("buttons").length&&(this.$el.on("mousedown",this.startTimer),this.$el.append(o("
",{class:n+"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 t=this.em.Canvas;this.canvasEl=t.getBody(),this.sorter=new this.em.Utils.Sorter({container:this.canvasEl,placer:t.getPlacerEl(),containerSel:"*",itemSel:"*",pfx:this.ppfx,onMove:this.onDrag,onEndMove:this.onDrop,document:t.getFrameEl().contentDocument,direction:"a",wmargin:1,nested:1});var e=t.getOffset();this.sorter.offTop=e.top,this.sorter.offLeft=e.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",o(document).on("mouseup",this.stopDrag)},stopDrag:function(){o(document).off("mouseup",this.stopDrag),this.sorter.endMove()},onDrag:function(t){},onDrop:function(t){this.canvasEl.style.cursor="default"},updateClassName:function(){var t=this.model.get("className");this.$el.attr("class",this.pfx+"btn"+(t?" "+t:""))},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),o(document).on("mouseup",this.stopTimer)},stopTimer:function(){o(document).off("mouseup",this.stopTimer),this.timeout&&clearTimeout(this.timeout)},showButtons:function(){clearTimeout(this.timeout),this.model.set("bntsVis",!0),o(document).on("mousedown",this.hideButtons),o(document).on("keypress",this.closeOnKeyPress)},hideButtons:function(t){t&&o(t.target).trigger("click"),this.model.set("bntsVis",!1),o(document).off("mousedown",this.hideButtons),o(document).off("keypress",this.closeOnKeyPress)},closeOnKeyPress:function(t){27==(t.which||t.keyCode)&&this.hideButtons()},updateActive:function(){var t=this.model,e=t.get("context"),n=this.parentM,i={},o=this.em&&this.em.get?this.em.get("Editor"):null,s=t.get("command");this.commands&&(0,r.isString)(s)?i=this.commands.get(s)||{}:(0,r.isFunction)(s)?i={run:s}:null!==s&&(0,r.isObject)(s)&&(i=s),t.get("active")?(t.collection.deactivateAll(e),t.set("active",!0,{silent:!0}).trigger("checkActive"),n&&n.set("active",!0,{silent:!0}).trigger("checkActive"),i.run&&(i.run(o,t,t.get("options")),o.trigger("run:"+s)),!i.stop&&t.set("active",!1)):(this.$el.removeClass(this.activeCls),t.collection.deactivateAll(e),n&&n.set("active",!1,{silent:!0}).trigger("checkActive"),i.stop&&(i.stop(o,t,t.get("options")),o.trigger("stop:"+s)))},updateDisable:function(){this.model.get("disable")?this.$el.addClass(this.disableCls):this.$el.removeClass(this.disableCls)},checkActive:function(){this.model.get("active")?this.$el.addClass(this.activeCls):this.$el.removeClass(this.activeCls)},clicked:function(t){this.model.get("bntsVis")||this.model.get("disable")||this.toogleActive()},toogleActive:function(){this.parentM&&this.swapParent();var t=this.model.get("active");this.model.set("active",!t);this.em.get("Commands").get("select-comp");t?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 t=n(30),e=new t({collection:this.model.get("buttons"),config:this.config,parentM:this.model});this.$buttons=e.render().$el,this.$buttons.append(o("
",{class:this.pfx+"arrow-l"})),this.$el.append(this.$buttons)}return this}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";var i=n(0),r=n(29);t.exports=i.View.extend({initialize:function(t){this.opt=t||{},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(t){this.addToCollection(t)},addToCollection:function(t,e){var n=e||null,i=new r({model:t,config:this.config}),o=i.render().el,s=t.get("appendTo");if(s){document.querySelector(s).appendChild(o)}else n?n.appendChild(o):this.$el.append(o);return i.initResize(),o},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(e){this.addToCollection(e,t)},this),this.$el.append(t),this.$el.attr("class",this.className),this}})},function(t,e,n){"use strict";var i=n(114),r=function(t){return t&&t.__esModule?t:{default:t}}(i),o=n(2);t.exports=function(){var t={},e=n(115),i=void 0,s=void 0,a=void 0,l=void 0,c=function(){var t=i.style;t.top="-100px",t.left="-100px",t.display="none"};return{customRte:null,name:"RichTextEditor",init:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=n;for(var r in e)r in t||(t[r]=e[r]);var a=t.pStylePrefix;return a&&(t.stylePrefix=a+t.stylePrefix),this.pfx=t.stylePrefix,s=t.actions||[],i=document.createElement("div"),i.className=a+"rte-toolbar "+a+"one-bg",l=this.initRte(document.createElement("div")),(0,o.on)(i,"mousedown",function(t){return t.stopPropagation()}),this},postRender:function(t){var e=t.model.get("Canvas");i.style.pointerEvents="all",c(),e.getToolsEl().appendChild(i)},initRte:function(e){var n=this.pfx,o=i,s=this.actionbar,a=this.actions||t.actions,c={actionbar:n+"actionbar",button:n+"action",active:n+"active"},u=new r.default({el:e,classes:c,actions:a,actionbar:s,actionbarContainer:o});return l&&l.setEl(e),u.actionbar&&(this.actionbar=u.actionbar),u.actions&&(this.actions=u.actions),u},add:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.name=t,l.addAction(e,{sync:1})},get:function(t){var e=void 0;return l.getActions().forEach(function(n){n.name==t&&(e=n)}),e},getAll:function(){return l.getActions()},remove:function(t){var e=this.getAll(),n=this.get(t);if(n){var i=n.btn,r=e.indexOf(n);i.parentNode.removeChild(i),e.splice(r,1)}return n},getToolbarEl:function(){return i},udpatePosition:function(){var e=t.em.get("Canvas"),n=e.getTargetToElementDim(i,a,{event:"rteToolbarPosUpdate"});t.adjustToolbar&&n.top<=n.canvasTop&&(n.top=n.elementTop+n.elementHeight);var r=i.style;r.top=n.top+"px",r.left=n.left+"px"},enable:function(e,n){a=e.el;var r=t.em,o=e.getChildrenContainer(),s=this.customRte;if(i.style.display="",n=s?s.enable(o,n):this.initRte(o).enable(),r){setTimeout(this.udpatePosition.bind(this),0);var l="change:canvasOffset canvasScroll";r.off(l,this.udpatePosition,this),r.on(l,this.udpatePosition,this),r.trigger("rte:enable",e,n)}return n},disable:function(e,n){var i=t.em,r=this.customRte,o=e.getChildrenContainer();r?r.disable(o,n):n&&n.disable(),c(),i&&i.trigger("rte:disable",e,n)}}}},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=Object.assign||function(t){for(var e=1;eB",attributes:{title:"Bold"},result:function(t){return t.exec("bold")}},italic:{name:"italic",icon:"I",attributes:{title:"Italic"},result:function(t){return t.exec("italic")}},underline:{name:"underline",icon:"U",attributes:{title:"Underline"},result:function(t){return t.exec("underline")}},strikethrough:{name:"strikethrough",icon:"S",attributes:{title:"Strike-through"},result:function(t){return t.exec("strikeThrough")}},link:{icon:'⫘',name:"link",attributes:{style:"font-size:1.4rem;padding:0 4px 2px;",title:"Link"},result:function(t){return t.insertHTML(''+t.selection()+"")}}},c=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t);var o=n.el;if(o[a])return o[a];o[a]=this,this.setEl(o),this.updateActiveActions=this.updateActiveActions.bind(this);var s=n.actions||[];s.forEach(function(t,e){"string"==typeof t?t=l[t]:l[t.name]&&(t=r({},l[t.name],t)),s[e]=t});var c=s.length?s:Object.keys(l).map(function(t){return l[t]});n.classes=r({actionbar:"actionbar",button:"action",active:"active"},n.classes);var u=n.classes,h=n.actionbar;if(this.actionbar=h,this.settings=n,this.classes=u,this.actions=c,!h){var d=n.actionbarContainer;h=document.createElement("div"),h.className=u.actionbar,d.appendChild(h),this.actionbar=h,c.forEach(function(t){return e.addAction(t)})}return n.styleWithCSS&&this.exec("styleWithCSS"),this.syncActions(),this}return o(t,[{key:"setEl",value:function(t){this.el=t,this.doc=t.ownerDocument}},{key:"updateActiveActions",value:function(){var t=this;this.getActions().forEach(function(e){var n=e.btn,i=e.update,r=t.classes.active,o=e.name,s=t.doc;n.className=n.className.replace(r,"").trim(),s.queryCommandState(o)&&(n.className+=" "+r),i&&i(t,e)})}},{key:"enable",value:function(){return this.enabled?this:(this.actionbarEl().style.display="",this.el.contentEditable=!0,(0,s.on)(this.el,"mouseup keyup",this.updateActiveActions),this.syncActions(),this.updateActiveActions(),this.el.focus(),this.enabled=1,this)}},{key:"disable",value:function(){return this.actionbarEl().style.display="none",this.el.contentEditable=!1,(0,s.off)(this.el,"mouseup keyup",this.updateActiveActions),this.enabled=0,this}},{key:"syncActions",value:function(){var t=this;this.getActions().forEach(function(e){var n=e.event||"click";e.btn["on"+n]=function(n){e.result(t,e),t.updateActiveActions()}})}},{key:"addAction",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.sync,i=document.createElement("span"),r=t.icon,o=t.attributes||{};i.className=this.classes.button,t.btn=i;for(var s in o)i.setAttribute(s,o[s]);"string"==typeof r?i.innerHTML=r:i.appendChild(r),this.actionbarEl().appendChild(i),n&&(this.actions.push(t),this.syncActions())}},{key:"getActions",value:function(){return this.actions}},{key:"selection",value:function(){return this.doc.getSelection()}},{key:"exec",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.doc.execCommand(t,!1,e)}},{key:"actionbarEl",value:function(){return this.actionbar}},{key:"insertHTML",value:function(t){var e=void 0,n=this.doc,i=n.getSelection();if(i&&i.rangeCount){var r=n.createElement("div"),o=i.getRangeAt(0);o.deleteContents(),r.innerHTML=t,Array.prototype.slice.call(r.childNodes).forEach(function(t){o.insertNode(t),e=t}),i.removeAllRanges(),i.addRange(o),this.el.focus()}}}]),t}();e.default=c},function(t,e,n){"use strict";t.exports={stylePrefix:"rte-",adjustToolbar:1,actions:["bold","italic","underline","strikethrough","link"]}},function(t,e,n){"use strict";t.exports={stylePrefix:"sm-",sectors:[],textNoElement:"Select an element before using Style Manager",hideNotStylable:!0,highlightChanged:!0,highlightComputed:!0,showComputed:!0,clearProperties:0,avoidComputed:["width","height"]}},function(t,e,n){"use strict";var i=n(118);t.exports=n(0).Collection.extend({model:i})},function(t,e,n){"use strict";var i=n(1),r=n(0),o=n(11),s=n(127);t.exports=r.Model.extend({defaults:{id:"",name:"",open:!0,buildProps:"",extendBuilded:1,properties:[]},initialize:function(t){var e=t||{},n=[],i=this.buildProperties(e.buildProps);!this.get("id")&&this.set("id",this.get("name")),n=i?this.extendProperties(i):this.get("properties");var r=new o(n);r.sector=this,this.set("properties",r)},extendProperties:function(t,e,n){for(var r=t.length,o=e||this.get("properties"),s=this.get("extendBuilded"),a=[],l=0,c=o.length;l')}else{o.push(t("
").append(t('').attr("title",r.noColorSelectedText)).html())}}return"
"+o.join("")+"
"}function r(){for(var t=0;t1&&(delete window.localStorage[B],t.each(e,function(t,e){p(e)}))}catch(t){}try{vt=window.localStorage[B].split(";")}catch(t){}}}function p(e){if(j){var n=st(e).toRgbString();if(!gt[n]&&-1===t.inArray(n,vt))for(vt.push(n);vt.length>mt;)vt.shift();if(B&&window.localStorage)try{window.localStorage[B]=vt.join(";")}catch(t){}}}function g(){var t=[];if(V.showPalette)for(var e=0;eMath.abs(e-r);bt=o?"x":"y"}}else bt=null;var s=!bt||"x"===bt,a=!bt||"y"===bt;s&&(ut=parseFloat(t/tt)),a&&(ht=parseFloat((et-e)/et)),Yt=!1,V.showAlpha||(dt=1),O()},y,b),Ut?(M(Ut),L(),Kt=V.preferredFormat||st(Ut).format,p(Ut)):L(),H&&C();var i=G?"mousedown.spectrum":"click.spectrum touchstart.spectrum";Dt.delegate(".sp-thumb-el",i,e),It.delegate(".sp-thumb-el:nth-child(1)",i,{ignore:!0},e)}();var Jt={show:C,hide:T,toggle:w,reflow:I,option:F,enable:z,disable:$,offset:R,set:function(t){M(t),D()},get:P,destroy:_,container:kt};return Jt.id=K.push(Jt)-1,Jt}function a(e,n){var i=e.outerWidth(),r=e.outerHeight(),o=n.outerHeight(),s=e[0].ownerDocument,a=s.documentElement,l=a.clientWidth,c=a.clientHeight,u=t(s).scrollLeft(),h=t(s).scrollTop(),d=l+u,f=c+h,p=n.offset();return p.top+=o,p.left-=Math.min(p.left,p.left+i>d&&d>i?Math.abs(p.left+i-d):0),p.top-=Math.min(p.top,p.top+r>f&&f>r?Math.abs(r+o-0):0),p}function l(){}function c(t){t.stopPropagation()}function u(t,e){var n=Array.prototype.slice,i=n.call(arguments,2);return function(){return t.apply(e,i.concat(n.call(arguments)))}}function h(e,n,i,r){function o(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}function s(t){if(u){if(G&&c.documentMode<9&&!t.button)return l();var i=t.originalEvent&&t.originalEvent.touches&&t.originalEvent.touches[0],r=i&&i.pageX||t.pageX,s=i&&i.pageY||t.pageY,a=Math.max(0,Math.min(r-h.left,f)),g=Math.max(0,Math.min(s-h.top,d));p&&o(t),n.apply(e,[a,g,t])}}function a(n){(n.which?3==n.which:2==n.button)||u||!1!==i.apply(e,arguments)&&(u=!0,d=t(e).height(),f=t(e).width(),h=t(e).offset(),t(c).bind(g),t(c.body).addClass("sp-dragging"),s(n),o(n))}function l(){u&&(t(c).unbind(g),t(c.body).removeClass("sp-dragging"),setTimeout(function(){r.apply(e,arguments)},0)),u=!1}n=n||function(){},i=i||function(){},r=r||function(){};var c=document,u=!1,h={},d=0,f=0,p="ontouchstart"in window,g={};g.selectstart=o,g.dragstart=o,g["touchmove mousemove"]=s,g["touchend mouseup"]=l,t(e).bind("touchstart mousedown",a)}function d(t,e,n){var i;return function(){var r=this,o=arguments,s=function(){i=null,t.apply(r,o)};n&&clearTimeout(i),!n&&i||(i=setTimeout(s,e))}}function f(){return t.fn.spectrum.inputTypeColorSupport()}function p(t){var n={r:0,g:0,b:0},i=1,r=!1,o=!1;return"string"==typeof t&&(t=U(t)),"object"==(void 0===t?"undefined":e(t))&&(t.hasOwnProperty("r")&&t.hasOwnProperty("g")&&t.hasOwnProperty("b")?(n=g(t.r,t.g,t.b),r=!0,o="%"===String(t.r).substr(-1)?"prgb":"rgb"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("v")?(t.s=j(t.s),t.v=j(t.v),n=b(t.h,t.s,t.v),r=!0,o="hsv"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("l")&&(t.s=j(t.s),t.l=j(t.l),n=m(t.h,t.s,t.l),r=!0,o="hsl"),t.hasOwnProperty("a")&&(i=t.a)),i=_(i),{ok:r,format:t.format||o,r:it(255,rt(n.r,0)),g:it(255,rt(n.g,0)),b:it(255,rt(n.b,0)),a:i}}function g(t,e,n){return{r:255*F(t,255),g:255*F(e,255),b:255*F(n,255)}}function v(t,e,n){t=F(t,255),e=F(e,255),n=F(n,255);var i,r,o=rt(t,e,n),s=it(t,e,n),a=(o+s)/2;if(o==s)i=r=0;else{var l=o-s;switch(r=a>.5?l/(2-o-s):l/(o+s),o){case t:i=(e-n)/l+(e1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}var r,o,s;if(t=F(t,360),e=F(e,100),n=F(n,100),0===e)r=o=s=n;else{var a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;r=i(l,a,t+1/3),o=i(l,a,t),s=i(l,a,t-1/3)}return{r:255*r,g:255*o,b:255*s}}function y(t,e,n){t=F(t,255),e=F(e,255),n=F(n,255);var i,r,o=rt(t,e,n),s=it(t,e,n),a=o,l=o-s;if(r=0===o?0:l/o,o==s)i=0;else{switch(o){case t:i=(e-n)/l+(e>1)+720)%360;--e;)i.h=(i.h+r)%360,o.push(st(i));return o}function I(t,e){e=e||6;for(var n=st(t).toHsv(),i=n.h,r=n.s,o=n.v,s=[],a=1/e;e--;)s.push(st({h:i,s:r,v:o})),o=(o+a)%1;return s}function _(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function F(t,e){R(t)&&(t="100%");var n=V(t);return t=it(e,rt(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),et.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function z(t){return it(1,rt(0,t))}function $(t){return parseInt(t,16)}function R(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function V(t){return"string"==typeof t&&-1!=t.indexOf("%")}function H(t){return 1==t.length?"0"+t:""+t}function j(t){return t<=1&&(t=100*t+"%"),t}function B(t){return Math.round(255*parseFloat(t)).toString(16)}function W(t){return $(t)/255}function U(t){t=t.replace(Z,"").replace(Q,"").toLowerCase();var e=!1;if(at[t])t=at[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=ct.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=ct.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=ct.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=ct.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=ct.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=ct.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=ct.hex8.exec(t))?{a:W(n[1]),r:$(n[2]),g:$(n[3]),b:$(n[4]),format:e?"name":"hex8"}:(n=ct.hex6.exec(t))?{r:$(n[1]),g:$(n[2]),b:$(n[3]),format:e?"name":"hex"}:!!(n=ct.hex3.exec(t))&&{r:$(n[1]+""+n[1]),g:$(n[2]+""+n[2]),b:$(n[3]+""+n[3]),format:e?"name":"hex"}}var q={beforeShow:l,move:l,change:l,show:l,hide:l,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},K=[],G=!!/msie/i.exec(window.navigator.userAgent),Y=function(){function t(t,e){return!!~(""+t).indexOf(e)}var e=document.createElement("div"),n=e.style;return n.cssText="background-color:rgba(0,0,0,.5)",t(n.backgroundColor,"rgba")||t(n.backgroundColor,"hsla")}(),X=["
","
","
▼
","
"].join(""),J=function(){var t="";if(G)for(var e=1;e<=6;e++)t+="
";return["
","
","
","
","","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
",t,"
","
","
","
","
","","
","
","
","","","
","
","
"].join("")}();t.fn.spectrum=function(e,n){if("string"==typeof e){var i=this,r=Array.prototype.slice.call(arguments,1);return this.each(function(){var n=K[t(this).data("spectrum.id")];if(n){var o=n[e];if(!o)throw new Error("Spectrum: no such method: '"+e+"'");"get"==e?i=n.get():"container"==e?i=n.container:"option"==e?i=n.option.apply(n,r):"destroy"==e?(n.destroy(),t(this).removeData("spectrum.id")):o.apply(n,r)}}),i}return this.spectrum("destroy").each(function(){var n=t.extend({},e,t(this).data()),i=s(this,n);t(this).data("spectrum.id",i.id)})},t.fn.spectrum.load=!0,t.fn.spectrum.loadOpts={},t.fn.spectrum.draggable=h,t.fn.spectrum.defaults=q,t.fn.spectrum.inputTypeColorSupport=function e(){if(void 0===e._cachedResult){var n=t("")[0];e._cachedResult="color"===n.type&&""!==n.value}return e._cachedResult},t.spectrum={},t.spectrum.localization={},t.spectrum.palettes={},t.fn.spectrum.processNativeColorInputs=function(){var e=t("input[type=color]");e.length&&!f()&&e.spectrum({preferredFormat:"hex6"})};var Z=/^[\s,#]+/,Q=/\s+$/,tt=0,et=Math,nt=et.round,it=et.min,rt=et.max,ot=et.random,st=function t(e,n){if(e=e||"",n=n||{},e instanceof t)return e;if(!(this instanceof t))return new t(e,n);var i=p(e);this._originalInput=e,this._r=i.r,this._g=i.g,this._b=i.b,this._a=i.a,this._roundA=nt(100*this._a)/100,this._format=n.format||i.format,this._gradientType=n.gradientType,this._r<1&&(this._r=nt(this._r)),this._g<1&&(this._g=nt(this._g)),this._b<1&&(this._b=nt(this._b)),this._ok=i.ok,this._tc_id=tt++};st.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 t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},setAlpha:function(t){return this._a=_(t),this._roundA=nt(100*this._a)/100,this},toHsv:function(){var t=y(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=y(this._r,this._g,this._b),e=nt(360*t.h),n=nt(100*t.s),i=nt(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+i+"%)":"hsva("+e+", "+n+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var t=v(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=v(this._r,this._g,this._b),e=nt(360*t.h),n=nt(100*t.s),i=nt(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+i+"%)":"hsla("+e+", "+n+"%, "+i+"%, "+this._roundA+")"},toHex:function(t){return x(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return w(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:nt(this._r),g:nt(this._g),b:nt(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+nt(this._r)+", "+nt(this._g)+", "+nt(this._b)+")":"rgba("+nt(this._r)+", "+nt(this._g)+", "+nt(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:nt(100*F(this._r,255))+"%",g:nt(100*F(this._g,255))+"%",b:nt(100*F(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+nt(100*F(this._r,255))+"%, "+nt(100*F(this._g,255))+"%, "+nt(100*F(this._b,255))+"%)":"rgba("+nt(100*F(this._r,255))+"%, "+nt(100*F(this._g,255))+"%, "+nt(100*F(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(lt[x(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+w(this._r,this._g,this._b,this._a),n=e,i=this._gradientType?"GradientType = 1, ":"";if(t){n=st(t).toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,i=this._a<1&&this._a>=0;return e||!i||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(T,arguments)},brighten:function(){return this._applyModification(E,arguments)},darken:function(){return this._applyModification(M,arguments)},desaturate:function(){return this._applyModification(C,arguments)},saturate:function(){return this._applyModification(k,arguments)},greyscale:function(){return this._applyModification(S,arguments)},spin:function(){return this._applyModification(P,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(D,arguments)},complement:function(){return this._applyCombination(A,arguments)},monochromatic:function(){return this._applyCombination(I,arguments)},splitcomplement:function(){return this._applyCombination(N,arguments)},triad:function(){return this._applyCombination(O,arguments)},tetrad:function(){return this._applyCombination(L,arguments)}},st.fromRatio=function(t,n){if("object"==(void 0===t?"undefined":e(t))){var i={};for(var r in t)t.hasOwnProperty(r)&&(i[r]="a"===r?t[r]:j(t[r]));t=i}return st(t,n)},st.equals=function(t,e){return!(!t||!e)&&st(t).toRgbString()==st(e).toRgbString()},st.random=function(){return st.fromRatio({r:ot(),g:ot(),b:ot()})},st.mix=function(t,e,n){n=0===n?0:n||50;var i,r=st(t).toRgb(),o=st(e).toRgb(),s=n/100,a=2*s-1,l=o.a-r.a;i=a*l==-1?a:(a+l)/(1+a*l),i=(i+1)/2;var c=1-i,u={r:o.r*i+r.r*c,g:o.g*i+r.g*c,b:o.b*i+r.b*c,a:o.a*s+r.a*(1-s)};return st(u)},st.readability=function(t,e){var n=st(t),i=st(e),r=n.toRgb(),o=i.toRgb(),s=n.getBrightness(),a=i.getBrightness(),l=Math.max(r.r,o.r)-Math.min(r.r,o.r)+Math.max(r.g,o.g)-Math.min(r.g,o.g)+Math.max(r.b,o.b)-Math.min(r.b,o.b);return{brightness:Math.abs(s-a),color:l}},st.isReadable=function(t,e){var n=st.readability(t,e);return n.brightness>125&&n.color>500},st.mostReadable=function(t,e){for(var n=null,i=0,r=!1,o=0;o125&&s.color>500,l=s.brightness/125*3+s.color/500;(a&&!r||a&&r&&l>i||!a&&!r&&l>i)&&(r=a,i=l,n=st(e[o]))}return n};var at=st.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"},lt=st.hexNames=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}(at),ct=function(){var t="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",e="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{rgb:new RegExp("rgb"+e),rgba:new RegExp("rgba"+n),hsl:new RegExp("hsl"+e),hsla:new RegExp("hsla"+n),hsv:new RegExp("hsv"+e),hsva:new RegExp("hsva"+n),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=st,t(function(){t.fn.spectrum.load&&t.fn.spectrum.processNativeColorInputs()})}(t.$)}()}).call(e,n(0))},function(t,e,n){"use strict";var i=n(0),r=n(124);t.exports=i.View.extend({initialize:function(t){this.config=t.config||{},this.stackModel=t.stackModel,this.preview=t.preview,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"",this.propsConfig=t.propsConfig;var e=this.pfx,n=this.ppfx,i=this.collection;this.className=e+"layers "+n+"field",this.listenTo(i,"add",this.addTo),this.listenTo(i,"deselectAll",this.deselectAll),this.listenTo(i,"reset",this.render);var r=this.config.em||"",o=r?r.get("Utils"):"";this.sorter=o?new o.Sorter({container:this.el,ignoreViewChildren:1,containerSel:"."+e+"layers",itemSel:"."+e+"layer",pfx:this.config.pStylePrefix}):"",i.view=this,this.$el.data("model",i),this.$el.data("collection",i)},addTo:function(t){var e=this.collection.indexOf(t);this.addToCollection(t,null,e)},addToCollection:function(t,e,n){var i=e||null,o=this.stackModel,s=this.config,a=this.sorter,l=this.propsConfig;void 0!==this.preview&&t.set("preview",this.preview);var c=new r({model:t,config:s,sorter:a,stackModel:o,propsConfig:l}),u=c.render().el;if(i)i.appendChild(u);else if(void 0!==n){var h="before";this.$el.children().length==n&&(n--,h="after"),n<0?this.$el.append(u):this.$el.children().eq(n)[h](u)}else this.$el.append(u);return u},deselectAll:function(){this.$el.find("."+this.pfx+"layer").removeClass(this.pfx+"active")},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(e){this.addToCollection(e,t)},this),this.$el.append(t),this.$el.attr("class",this.className),this.sorter&&(this.sorter.plh=null),this}})},function(t,e,n){"use strict";(function(e){t.exports=e.View.extend({events:{click:"active","click [data-close-layer]":"remove","mousedown [data-move-layer]":"initSorter"},template:function(t){var e=this.pfx;return'\n
\n \n
\n
Layer '+t.get("index")+'
\n
\n \t
\n
\n
\n ⨯\n
\n
\n
\n '},initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.model;this.stackModel=t.stackModel||{},this.config=t.config||{},this.pfx=this.config.stylePrefix||"",this.sorter=t.sorter||null,this.propsConfig=t.propsConfig||{},this.customPreview=t.onPreview,this.listenTo(e,"destroy remove",this.remove),this.listenTo(e,"change:active",this.updateVisibility),this.listenTo(e.get("properties"),"change",this.updatePreview),e.get("preview")||this.$el.addClass(this.pfx+"no-preview"),e.view=this,e.set({droppable:0,draggable:1}),this.$el.data("model",e)},initSorter:function(t){this.sorter&&this.sorter.startSort(this.el)},remove:function(t){t&&t.stopPropagation&&t.stopPropagation();var n=this.model,i=n.collection,r=this.stackModel;e.View.prototype.remove.apply(this,arguments),i.contains(n)&&i.remove(n),r&&r.set&&(r.set({stackIndex:null},{silent:!0}),r.trigger("updateValue"))},onPreview:function(t){var e=t.split(" "),n=[];return this.model.get("properties").each(function(t,i){var r=e[i]||"";if(r&&"integer"==t.get("type")){var o=parseInt(r,10),s=r.replace(o,"");o=isNaN(o)?0:o,o=o>3?3:o,o=o<-3?-3:o,r=o+s}n.push(r)}),n.join(" ")},updatePreview:function(){var t=this.stackModel,e=this.customPreview,n=this.getPreviewEl(),i=this.model.getFullValue(),r=e?e(i):this.onPreview(i);r&&t&&n&&(n.style[t.get("property")]=r)},getPropertiesWrapper:function(){return this.propsWrapEl||(this.propsWrapEl=this.el.querySelector("[data-properties]")),this.propsWrapEl},getPreviewEl:function(){return this.previewEl||(this.previewEl=this.el.querySelector("[data-preview]")),this.previewEl},active:function(){var t=this.model,e=t.collection;e.active(e.indexOf(t))},updateVisibility:function(){var t=this.pfx,e=this.getPropertiesWrapper(),n=this.model.get("active");e.style.display=n?"":"none",this.$el[n?"addClass":"removeClass"](t+"active")},render:function(){var t=n(13),e=this.propsConfig,i=this.pfx+"layer",r=this.model,o=this.el,s=new t({collection:r.get("properties"),config:this.config,target:e.target,customValue:e.customValue,propTarget:e.propTarget,onChange:e.onChange}).render().el;return o.innerHTML=this.template(r),o.className=i,this.getPropertiesWrapper().appendChild(s),this.updateVisibility(),this.updatePreview(),this}})}).call(e,n(0))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e\n \n
\n '},getSliderEl:function(){return this.slider||(this.slider=this.el.querySelector("input[type=range]")),this.slider},inputValueChanged:function(){var t=this.model,e=t.get("step");this.getInputEl().value=this.getSliderEl().value;var n=this.getInputValue()-e;t.set("value",n,{avoidStore:1}).set("value",n+e),this.elementUpdated()},inputValueChangedSoft:function(){this.getInputEl().value=this.getSliderEl().value,this.model.set("value",this.getInputValue(),{avoidStore:1}),this.elementUpdated()},setValue:function(t){this.getSliderEl().value=t,this.inputInst.setValue(t,{silent:1})},onRender:function(){i.prototype.onRender.apply(this,arguments),this.model.get("showInput")||(this.inputInst.el.style.display="none")}})},function(t,e,n){"use strict";n(0);t.exports=function(){return{build:function(t){var e=[];"string"==typeof t&&(t=[t]);for(var n=0,i=t.length;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.get("SelectorManager"),r=n.add("hc-state"),o=i.get([r]);if(o){var s=i.getAll();s.remove(o),s.add(o)}else o=i.add([r]);o.set("important",1),o.setStyle(e),l.helper=o};if(r){var p=i.getIdRule(o,u);e=p||i.setIdRule(o,{},u)}if(a.length){var g=a.getStyleable(),v=i.get(g,c,d);return!v&&g.length&&(n.stop(),v=i.add(g,c,d),v.setStyle(e.getStyle()),e.setStyle({}),n.start()),v?(c&&f(v.getStyle()),l.model=v,void l.trigger("update")):(l.model=e,void l.trigger("update"))}if(c){var m=i.getIdRule(o,u);c&&f(m&&m.getStyle())}l.model=e,l.trigger("update")}},addToCollection:function(t,e){var n=e||null,i=new o({model:t,id:this.pfx+t.get("name").replace(" ","_").toLowerCase(),name:t.get("name"),properties:t.get("properties"),target:this.target,propTarget:this.propTarget,config:this.config}),r=i.render().el;return n?n.appendChild(r):this.$el.append(r),r},render:function(){var t=document.createDocumentFragment();return this.$el.empty(),this.collection.each(function(e){this.addToCollection(e,t)},this),this.$el.attr("id",this.pfx+"sectors"),this.$el.append(t),this}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=n(0),r=n(13);t.exports=i.View.extend({template:e.template('\n
\n \n <%= label %>\n
'),events:{"click [data-sector-title]":"toggle"},initialize:function(t){this.config=t.config||{},this.pfx=this.config.stylePrefix||"",this.target=t.target||{},this.propTarget=t.propTarget||{},this.caretR="fa-caret-right",this.caretD="fa-caret-down";var e=this.model;this.listenTo(e,"change:open",this.updateOpen),this.listenTo(e,"updateVisibility",this.updateVisibility),this.listenTo(e,"destroy remove",this.remove)},updateVisibility:function(){var t;this.model.get("properties").each(function(e){e.get("visible")&&(t=1)}),this.el.style.display=t?"block":"none"},updateOpen:function(){this.model.get("open")?this.show():this.hide()},show:function(){this.$el.addClass(this.pfx+"open"),this.getPropertiesEl().style.display="",this.$caret.removeClass(this.caretR).addClass(this.caretD)},hide:function(){this.$el.removeClass(this.pfx+"open"),this.getPropertiesEl().style.display="none",this.$caret.removeClass(this.caretD).addClass(this.caretR)},getPropertiesEl:function(){return this.$el.find("."+this.pfx+"properties").get(0)},toggle:function(t){var e=this.model.get("open")?0:1;this.model.set("open",e)},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 t=this.model.get("properties");if(t){var e=new r({collection:t,target:this.target,propTarget:this.propTarget,config:this.config});this.$el.append(e.render().el)}}})}).call(e,n(1))},function(t,e,n){"use strict";t.exports=function(){var t={},e=n(131),i=n(132),r=n(135),o=n(45),s=void 0,a=void 0,l=void 0;return{name:"AssetManager",storageKey:"assets",getConfig:function(){return t},init:function(n){var c=this;t=n||{};for(var u in e)u in t||(t[u]=e[u]);var h=t.pStylePrefix,d=t.em;h&&(t.stylePrefix=h+t.stylePrefix),s=new i([]);var f={collection:new i([]),globalCollection:s,config:t};return l=new o(f),f.fu=l,a=new r(f),s.listenTo(s,"add",function(t){c.getAllVisible().add(t),d&&d.trigger("asset:add",t)}),s.listenTo(s,"remove",function(t){c.getAllVisible().remove(t),d&&d.trigger("asset:remove",t)}),this},add:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return void 0===e.at&&(e.at=0),s.add(t,e)},get:function(t){return s.where({src:t})[0]},getAll:function(){return s},getAllVisible:function(){return a.collection},remove:function(t){var e=this.get(t);return this.getAll().remove(e),this},store:function(e){var n={},i=JSON.stringify(this.getAll().toJSON());return n[this.storageKey]=i,!e&&t.stm&&t.stm.store(n),n},load:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.storageKey,n=t[e]||[];if("string"==typeof n)try{n=JSON.parse(t[e])}catch(t){}return n&&n.length&&this.getAll().reset(n),n},getContainer:function(){return a.el},getAssetsEl:function(){return a.el.querySelector("[data-el=assets]")},render:function(t){var e=t||this.getAll().models;return a.rendered||a.render(),a.collection.reset(e),this.getContainer()},addType:function(t,e){this.getAll().addType(t,e)},getType:function(t){return this.getAll().getType(t)},getTypes:function(){return this.getAll().getTypes()},AssetsView:function(){return a},FileUploader:function(){return l},onLoad:function(){this.getAll().reset(t.assets)},postRender:function(e){t.dropzone&&l.initDropzone(e)},setTarget:function(t){a.collection.target=t},onSelect:function(t){a.collection.onSelect=t},onClick:function(e){t.onClick=e},onDblClick:function(e){t.onDblClick=e}}}},function(t,e,n){"use strict";t.exports={assets:[],noAssets:"",stylePrefix:"am-",upload:0,uploadName:"files",headers:{},params:{},autoAdd:1,uploadText:"Drop files here or click to upload",addBtnText:"Add image",uploadFile:"",handleAdd:"",dropzone:0,openAssetsOnDrop:1,dropzoneContent:"",modalTitle:"Select Image",inputPlaceholder:"http://path/to/the/image.jpg"}},function(t,e,n){"use strict";var i=n(32),r=function(t){return t&&t.__esModule?t:{default:t}}(i);t.exports=n(0).Collection.extend(r.default).extend({types:[{id:"image",model:n(133),view:n(43),isType:function(t){return"string"==typeof t?{type:"image",src:t}:t}}]})},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e\n
\n
\n
\n \n
\n \n
\n
\n \n
\n
\n
\n
\n '},initialize:function(t){this.options=t,this.config=t.config,this.pfx=this.config.stylePrefix||"",this.ppfx=this.config.pStylePrefix||"";var e=this.collection;this.listenTo(e,"reset",this.renderAssets),this.listenTo(e,"add",this.addToAsset),this.listenTo(e,"remove",this.removedAsset),this.listenTo(e,"deselectAll",this.deselectAll)},handleSubmit:function(t){t.preventDefault();var e=this.getAddInput(),n=e.value.trim(),i=this.config.handleAdd;n&&(e.value="",this.getAssetsEl().scrollTop=0,i?i(n):this.options.globalCollection.add(n,{at:0}))},getAssetsEl:function(){return this.el.querySelector("."+this.pfx+"assets")},getAddInput:function(){return this.inputUrl&&this.inputUrl.value||(this.inputUrl=this.el.querySelector("."+this.pfx+"add-asset input")),this.inputUrl},removedAsset:function(t){this.collection.length||this.toggleNoAssets()},addToAsset:function(t){1==this.collection.length&&this.toggleNoAssets(1),this.addAsset(t)},addAsset:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e,i=this.collection,r=this.config,o=new t.typeView({model:t,collection:i,config:r}).render().el;if(n)n.appendChild(o);else{var s=this.getAssetsEl();s&&s.insertBefore(o,s.firstChild)}return o},toggleNoAssets:function(t){var e=this.$el.find("."+this.pfx+"assets");if(t)e.empty();else{var n=this.config.noAssets;n&&e.append(n)}},deselectAll:function(){var t=this.pfx;this.$el.find("."+t+"highlight").removeClass(t+"highlight")},renderAssets:function(){var t=this,e=document.createDocumentFragment(),n=this.$el.find("."+this.pfx+"assets");n.empty(),this.toggleNoAssets(this.collection.length),this.collection.each(function(n){return t.addAsset(n,e)}),n.append(e)},render:function(){var t=this.options.fu.render().el;return this.$el.empty(),this.$el.append(t).append(this.template(this)),this.el.className=this.ppfx+"asset-manager",this.renderAssets(),this.rendered=1,this}})}).call(e,n(0))},function(t,e,n){"use strict";var i=Object.assign||function(t){for(var e=1;e=0&&(n.css=o.em.getCss()),i.indexOf("styles")>=0&&(n.styles=JSON.stringify(t)),e||o.stm.store(n),n}},add:function(e,n,i,r){var s=n||"",l=i||"",c=r||{},u=this.get(e,s,l,c);return u||(c.state=s,c.mediaText=l,c.selectors="",u=new a(c,o),u.get("selectors").add(e),t.add(u),u)},get:function(e,n,i,r){var o=null;return t.each(function(t){o||t.compare(e,n,i,r)&&(o=t)}),o},getAll:function(){return t},clear:function(){return this.getAll().reset(),this},addCollection:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[],r=t instanceof Array?t:[t],s=0,a=r.length;s1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.state||"",o=n.mediaText||r.getCurrentMedia(),s=r.get("SelectorManager"),a=s.add({name:t,type:h.TYPE_ID}),l=this.add(a,i,o);return l.setStyle(e,n),l},getIdRule:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.state||"",i=e.mediaText||r.getCurrentMedia(),o=r.get("SelectorManager").get(t,h.TYPE_ID);return o&&this.get(o,n,i)},setClassRule:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.state||"",o=n.mediaText||r.getCurrentMedia(),s=r.get("SelectorManager"),a=s.add({name:t,type:h.TYPE_CLASS}),l=this.add(a,i,o);return l.setStyle(e,n),l},getClassRule:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.state||"",i=e.mediaText||r.getCurrentMedia(),o=r.get("SelectorManager").get(t,h.TYPE_CLASS);return o&&this.get(o,n,i)},render:function(){return e.render().el}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"css-",staticRules:"",rules:[]}},function(t,e,n){"use strict";var i=n(0),r=n(46);t.exports=i.Collection.extend({initialize:function(t,e){e&&e.sm&&(this.editor=e.sm),this.model=function(t,n){return!n.sm&&e&&e.sm&&(n.sm=e.sm),new r(t,n)}},add:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof t&&(t=this.editor.get("Parser").parseCss(t)),e.em=this.editor,i.Collection.prototype.add.apply(this,[t,e])}})},function(t,e,n){"use strict";var i=n(0),r=n(140);t.exports=i.View.extend({initialize:function(t){var e=t.config||{};this.config=e,this.em=e.em,this.pfx=e.stylePrefix||"",this.className=this.pfx+"rules";var n=this.collection;this.listenTo(n,"add",this.addTo),this.listenTo(n,"reset",this.render)},addTo:function(t){this.addToCollection(t)},addToCollection:function(t,e){var n=e||null,i=r,o=new i({model:t,config:this.config}),s=o.render().el;return n?n.appendChild(s):this.$el.append(s),s},render:function(){var t=this,e=this.$el,n=document.createDocumentFragment();return e.empty(),this.collection.each(function(e){return t.addToCollection(e,n)}),e.append(n),e.attr("class",this.className),this}})},function(t,e,n){"use strict";t.exports=n(0).View.extend({tagName:"style",initialize:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config=t.config||{};var e=this.model;this.listenTo(e,"change:style change:state change:mediaText",this.render),this.listenTo(e,"destroy remove",this.remove),this.listenTo(e.get("selectors"),"change",this.render)},render:function(){var t=this.model,e=t.get("important");return this.el.innerHTML=this.model.toCSS({important:e}),this}})},function(t,e,n){"use strict";var i=n(1);t.exports=function(){var t={},e=n(142),r=n(143),o=void 0;return{TraitsView:r,name:"TraitManager",getConfig:function(){return t},init:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=n,(0,i.defaults)(t,e);var s=t.pStylePrefix;return s&&(t.stylePrefix=""+s+t.stylePrefix),o=new r({collection:[],editor:t.em,config:t}),this},getTraitsViewer:function(){return o},addType:function(t,e){var n=o.itemView;o.itemsView[t]=n.extend(e)},getType:function(t){return o.itemsView[t]}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"trt-",labelContainer:"Component settings",labelPlhText:"eg. Text here",labelPlhHref:"eg. https://google.com",optionsTarget:[{value:"",name:"This window"},{value:"_blank",name:"New window"}]}},function(t,e,n){"use strict";var i=n(48),r=n(8),o=n(144),s=n(145),a=n(146),l=n(147);t.exports=i.extend({itemView:r,itemsView:{text:r,number:a,select:o,checkbox:s,color:l},initialize:function(t){this.config=t.config||{},this.em=t.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 t=this.em.get("selectedComponent");t&&(this.collection=t.get("traits"),this.render())}})},function(t,e,n){"use strict";(function(e,i){var r=n(8),o=e.$;t.exports=r.extend({initialize:function(t){r.prototype.initialize.apply(this,arguments);var e=this.ppfx;this.tmpl='
'},getInputEl:function(){if(!this.$input){var t=this.model,e=t.get("options")||[],n="",this.input=n,this.$input=o(this.input);var r=this.target,s=t.get("name"),a=t.get("value");if(t.get("changeProp"))a=a||r.get(s);else{a=r.get("attributes")[s]}a&&this.$input.val(a)}return this.$input.get(0)}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";var i=n(8);t.exports=i.extend({initialize:function(t){i.prototype.initialize.apply(this,arguments);var e=this.ppfx+"chk-icon";this.tmpl='
'},onChange:function(){this.model.set("value",this.getInputEl().checked)},getInputEl:function(){var t;this.$input||(t=1);for(var e=arguments.length,n=Array(e),r=0;r2&&void 0!==arguments[2]?arguments[2]:{},r=t.components(),s=o.get("UndoManager"),a=o.handleUpdates.bind(o),l=this.handleChanges.bind(this),c=this.handleRemoves.bind(this);s&&s.add(t),s&&r&&s.add(r);[[t,"change:style change:content change:attributes change:src",a],[r,"add",l],[r,"remove",c],[t.get("classes"),"add remove",a]].forEach(function(t){o.stopListening(t[0],t[1],t[2]),o.listenTo(t[0],t[1],t[2])}),!i.avoidStore&&a("","",i),r.each(function(t){return n.handleChanges(t,e,i)})},handleRemoves:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!n.avoidStore&&o.handleUpdates(t,e,n)},load:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e="";if(!t&&r.stm&&(t=r.em.getCacheLoad()),t.components)try{e=JSON.parse(t.components)}catch(t){}else t.html&&(e=t.html);var n=e&&e.constructor===Object;return(e&&e.length||n)&&(this.clear(),this.getComponents().reset(),n?this.getWrapper().set(e).initComponents().initClasses().loadTraits():this.getComponents().add(e)),e},store:function(t){if(r.stm){var e={},n=this.storageKey();if(n.indexOf("html")>=0&&(e.html=r.em.getHtml()),n.indexOf("components")>=0){var i=r.storeWrapper?this.getWrapper():this.getComponents();e.components=JSON.stringify(i)}return t||r.stm.store(e),e}},getComponent:function(){return t},getWrapper:function(){return this.getComponent()},getComponents:function(){return this.getWrapper().get("components")},addComponent:function(t){return this.getComponents().add(t)},render:function(){return e.render().el},clear:function(){for(var t=this.getComponents(),e=0,n=t.length;e1&&void 0!==arguments[1]?arguments[1]:{};this.em=e.em||""},setTarget:function(t){this.target=t},add:function(t,e){var n=this.em;if((0,i.isString)(t)||(0,i.isArray)(t)){var o=n&&n.get&&n.get("TraitManager"),a=o&&o.getConfig(),l=s(a);(0,i.isString)(t)&&(t=[t]);for(var c=0,u=t.length;c1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={value:t};this.set(r,i({},n,{avoidStore:1})),e&&(this.set("value","",n),this.set(r,n))},getInitValue:function(){var t=this.target,e=this.get("name"),n=void 0;if(t){var i=t.get("attributes");n=this.get("changeProp")?t.get(e):i[e]}return n||this.get("value")||this.get("default")}})},function(t,e,n){"use strict";t.exports=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{build:function(e){var n=[];"string"==typeof e&&(e=[e]);for(var i=0;is.top+s.height?s.top+s.height:g;var v={top:g,left:p,elementTop:s.top,elementLeft:s.left,elementWidth:s.width,elementHeight:s.height,targetWidth:t.offsetWidth,targetHeight:t.offsetHeight,canvasTop:o.top,canvasLeft:o.left};return h&&r.em&&r.em.trigger(h,v),v},getMouseRelativePos:function(t,e){var n=e||{},i=0,r=0,o=n.subWinOffset,s=t.target.ownerDocument,a=s.defaultView||s.parentWindow,l=a.frameElement,c=o?a.pageYOffset:0,u=o?a.pageXOffset:0;if(l){var h=l.getBoundingClientRect();i=h.top||0,r=h.left||0}return{y:t.clientY+i-c,x:t.clientX+r-u}},getMouseRelativeCanvas:function(t,e){var n=this.getFrameEl(),i=this.getBody(),r=n.offsetTop||0,o=n.offsetLeft||0,s=i.scrollTop||0,a=i.scrollLeft||0;return{y:t.clientY+r+s,x:t.clientX+o+a}},isInputFocused:function(){return"BODY"!==this.getFrameEl().contentDocument.activeElement.tagName},startAutoscroll:function(){var t=this;this.dragging=1;var n=this.getScrollListeners();e=l.getFrameOffset(1),setTimeout(function(){(0,i.on)(n,"mousemove",t.autoscroll),(0,i.on)(n,"mouseup",t.stopAutoscroll)},0)},autoscroll:function(t){if(t.preventDefault(),this.dragging){var n=this.getFrameEl().contentWindow,i=n.document.body.scrollTop,r=i,o=t.clientY,s=e.height-50;o<50&&(r-=50-o),o>s&&(r+=o-s),n.scrollTo(0,r)}},stopAutoscroll:function(){this.dragging=0;var t=this.getScrollListeners();(0,i.off)(t,"mousemove",this.autoscroll),(0,i.off)(t,"mouseup",this.stopAutoscroll)},getScrollListeners:function(){return[this.getFrameEl().contentWindow,this.getElement()]},postRender:function(){(0,i.hasDnd)(r.em)&&(this.droppable=new o.default(r.em))},getFrameWrapperEl:function(){return l.frame.getWrapper()}}}},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n";this.sorter.setDropContent(o),this.sorter.startSort(),e.trigger("canvas:dragenter",n,o)}}},{key:"handleDragOver",value:function(t){t.preventDefault(),this.em.trigger("canvas:dragover",t)}},{key:"handleDrop",value:function(t){t.preventDefault();var e=t.dataTransfer,n=this.getContentByData(e).content;t.target.style.border="",n?this.sorter.setDropContent(n):this.sorter.moved=0,this.endDrop(0,t)}},{key:"getContentByData",value:function(t){var e=this.em,n=t.types,i=t.files,r=t.getData("text");if(i.length){r=[];for(var o=0;o=0)r=t.getData("text/html").replace(/<\/?meta[^>]*>/g,"");else if(n.indexOf("text/uri-list")>=0)r={type:"link",attributes:{href:r},content:r};else if(n.indexOf("text/json")>=0){var l=t.getData("text/json");l&&(r=JSON.parse(l))}var c={content:r};return e.trigger("canvas:dragdata",t,c),c}}]),t}();e.default=a},function(t,e,n){"use strict";t.exports={stylePrefix:"cv-",rulers:!1,scripts:[],styles:[],customBadgeLabel:""}},function(t,e,n){"use strict";var i=n(0),r=n(180);t.exports=i.Model.extend({defaults:{frame:"",wrapper:"",rulers:!1},initialize:function(t){var e=this.conf||{};this.set("frame",new r(e.frame))}})},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{wrapper:"",width:"",height:"",attributes:{}}})},function(t,e,n){"use strict";(function(e,i){var r=n(182),o=e.$;t.exports=e.View.extend({initialize:function(t){i.bindAll(this,"renderBody","onFrameScroll","clearOff"),window.onscroll=this.clearOff,this.config=t.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 r({model:this.model.get("frame"),config:this.config})},isElInViewport:function(t){var e=t.getBoundingClientRect(),n=this.getFrameOffset(1),i=e.top,r=e.left;return i>=0&&r>=0&&i<=n.height&&r<=n.width},onFrameScroll:function(){var t=this.frame.el.contentDocument.body;this.toolsEl.style.top="-"+t.scrollTop+"px",this.toolsEl.style.left="-"+t.scrollLeft+"px",this.em.trigger("canvasScroll")},renderScripts:function(){var t=this.frame,e=this;t.el.onload=function(){function n(i){if(i.length>0){var r=document.createElement("script");r.type="text/javascript",r.src=i.shift(),r.onerror=r.onload=n.bind(null,i),t.el.contentDocument.head.appendChild(r)}else e.renderBody()}var i=e.config.scripts.slice(0);n(i)}},renderBody:function(){var t=this.model.get("frame").get("wrapper"),e=this.config.em;if(t){var n=this.ppfx,i=o(this.frame.el.contentWindow.document.body),r=e.get("CssComposer"),s=e.get("Config"),a=this.config,l=s.protectedCss,c="";a.styles.forEach(function(t){c+=''});var u="\n \n * {\n box-sizing: border-box;\n }\n html, body, #wrapper {\n min-height: 100%;\n }\n body {\n margin: 0;\n height: 100%;\n background-color: #fff\n }\n #wrapper {\n overflow: auto;\n overflow-x: hidden;\n }\n \n\n ."+n+"dashed *[data-highlightable] {\n outline: 1px dashed rgba(170,170,170,0.7);\n outline-offset: -3px\n }\n\n ."+n+"comp-selected {\n outline: 3px solid #3b97e3 !important;\n }\n\n ."+n+"comp-selected-parent {\n outline: 2px solid #ffca6f !important\n }\n\n ."+n+"no-select {\n user-select: none;\n -webkit-user-select:none;\n -moz-user-select: none;\n }\n\n ."+n+"freezed {\n opacity: 0.5;\n pointer-events: none;\n }\n\n ."+n+"no-pointer {\n pointer-events: none;\n }\n\n ."+n+"plh-image {\n background: #f5f5f5;\n border: none;\n height: 50px;\n width: 50px;\n display: block;\n outline: 3px solid #ffca6f;\n cursor: pointer;\n outline-offset: -2px\n }\n\n ."+n+"grabbing {\n cursor: grabbing;\n cursor: -webkit-grabbing;\n }\n\n * ::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.1)\n }\n\n * ::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.2)\n }\n\n * ::-webkit-scrollbar {\n width: 10px\n }\n\n "+(s.canvasCss||"")+"\n "+(l||"")+"\n ";c&&i.append(c),i.append(""),i.append(t.render()).append(r.render()),i.append(this.getJsContainer()),e.trigger("loaded"),this.frame.el.contentWindow.onscroll=this.onFrameScroll,this.frame.udpateOffset();var h=document,d=this.frame.el.contentDocument,f=function(t){var e=new KeyboardEvent(t.type,t);return e.keyCodeVal=t.keyCode,["keyCode","which"].forEach(function(t){Object.defineProperty(e,t,{get:function(){return this.keyCodeVal}})}),e};d.addEventListener("keydown",function(t){h.dispatchEvent(f(t))}),d.addEventListener("keyup",function(t){h.dispatchEvent(f(t))})}},offset:function(t){var e=t.getBoundingClientRect(),n=t.ownerDocument.body;return{top:e.top+n.scrollTop,left:e.left+n.scrollLeft,width:e.width,height:e.height}},clearOff:function(){this.frmOff=null,this.cvsOff=null},getFrameOffset:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.frmOff&&!t||(this.frmOff=this.offset(this.frame.el)),this.frmOff},getCanvasOffset:function(){return this.cvsOff||(this.cvsOff=this.offset(this.el)),this.cvsOff},getElementPos:function(t,e){var n=e||{},i=this.getFrameOffset(),r=this.getCanvasOffset(),o=this.offset(t),s=n.avoidFrameOffset?0:i.top,a=n.avoidFrameOffset?0:i.left;return{top:o.top+s-r.top,left:o.left+a-r.left,height:t.offsetHeight||t.clientHeight,width:t.offsetWidth||t.clientWidth}},getPosition:function(){var t=this.frame.el.contentDocument.body,e=this.getFrameOffset(),n=this.getCanvasOffset();return{top:e.top+t.scrollTop-n.top,left:e.left+t.scrollLeft-n.left}},updateScript:function(t){t.scriptContainer||(t.scriptContainer=o("
"),this.getJsContainer().append(t.scriptContainer.get(0)));var e=t.model,n=e.getId();t.el.id=n,t.scriptContainer.html("");var i=document.createElement("script");i.innerText="\n setTimeout(function() {\n var item = document.getElementById('"+n+"');\n if (!item) return;\n (function(){\n "+e.getScriptString()+";\n }.bind(item))()\n }, 1);",t.scriptContainer.get(0).appendChild(i)},getJsContainer:function(){return this.jsContainer||(this.jsContainer=o('
').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 t=this.frame;0===this.config.scripts.length?t.el.onload=this.renderBody:this.renderScripts()}var e=this.ppfx;this.$el.append('\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n ');var n=this.el,i=n.querySelector("#"+e+"tools");return this.hlEl=n.querySelector("."+e+"highlighter"),this.badgeEl=n.querySelector("."+e+"badge"),this.placerEl=n.querySelector("."+e+"placeholder"),this.ghostEl=n.querySelector("."+e+"ghost"),this.toolbarEl=n.querySelector("."+e+"toolbar"),this.resizerEl=n.querySelector("."+e+"resizer"),this.offsetEl=n.querySelector("."+e+"offset-v"),this.fixedOffsetEl=n.querySelector("."+e+"offset-fixed-v"),this.toolsEl=i,this.el.className=this.className,this}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";var i=n(1),r="transitionend oTransitionEnd transitionend webkitTransitionEnd";t.exports=n(0).View.extend({tagName:"iframe",attributes:{allowfullscreen:"allowfullscreen"},initialize:function(t){(0,i.bindAll)(this,"udpateOffset"),this.config=t.config||{},this.ppfx=this.config.pStylePrefix||"",this.em=this.config.em,this.listenTo(this.em,"change:device",this.updateDim)},updateDim:function(t){var e=this.em,n=e.getDeviceModel(),i=this.el.style,o=i.width||"",s=i.height||"",a=n?n.get("width"):"",l=n?n.get("height"):"",c=o==a&&s==l;i.width=a,i.height=l,this.udpateOffset(),e.stopDefault({preserveSelected:1}),c?this.udpateOffset():this.$el.on(r,this.udpateOffset)},udpateOffset:function(){var t=this.em,e=t.get("Canvas").getOffset();t.set("canvasOffset",e),t.runDefault({preserveSelected:1}),this.$el.off(r,this.udpateOffset)},getBody:function(){this.$el.contents().find("body")},getWrapper:function(){return this.$el.contents().find("body > div")},render:function(){return this.$el.attr({class:this.ppfx+"frame"}),this}})},function(t,e,n){"use strict";var i=n(1);t.exports=function(){var t=void 0,e={},r={},o={},s=n(184),a=n(185),l=function(t,e){return(0,i.isFunction)(e)&&(e={run:e}),delete e.initialize,r[t]=a.extend(e),this};return{name:"Commands",init:function(i){e=i||{};for(var r in s)r in e||(e[r]=s[r]);t=e.em;var a=e.pStylePrefix;a&&(e.stylePrefix=a+e.stylePrefix);for(var l in e.defaults){var c=e.defaults[l];c.id&&this.add(c.id,c)}var u=n(186);return o["select-comp"]=n(21),o["create-comp"]=n(22),o["delete-comp"]=n(191),o["image-comp"]=n(192),o["move-comp"]=n(193),o["text-comp"]=n(194),o["insert-custom"]=n(54),o["export-template"]=u,o["sw-visibility"]=n(195),o["open-layers"]=n(196),o["open-sm"]=n(199),o["open-tm"]=n(200),o["open-blocks"]=n(201),o["open-assets"]=n(202),o["show-offset"]=n(203),o["select-parent"]=n(204),o.fullscreen=n(205),o.preview=n(206),o.resize=n(207),o.drag=n(208),o["tlb-delete"]={run:function(t){var e=t.getSelected();if(!e||!e.get("removable"))return void console.warn("The element is not removable");t.select(null),e.destroy()}},o["tlb-clone"]={run:function(t){var e=t.getSelected();if(!e||!e.get("copyable"))return void console.warn("The element is not clonable");var n=e.collection,i=n.indexOf(e),r=n.add(e.clone(),{at:i+1});e.emitUpdate(),t.trigger("component:clone",r)}},o["tlb-move"]={run:function(t,e,n){var i=void 0,r=t.getModel(),o=n&&n.event,s=t.getSelected(),a=t.Canvas.getToolbarEl().style,l="dragstart"==o.type,c=function(){a.display="none",r.stopDefault()};if(!s||!s.get("draggable"))return void console.warn("The element is not draggable");l?setTimeout(function(){return c},0):c();var u=function(t,e){console.log("start mouse pos ",e.start),console.log("el rect ",e.elRect);var n=e.el;n.style.position="absolute",n.style.margin=0},h=function(t,e){r.runDefault(),r.setSelected(s),s.emitUpdate(),i&&i.blur()},d=function(t,e){console.log("Delta ",e.delta),console.log("Current ",e.current)};if(r.get("designerMode"))i=editor.runCommand("drag",{el:s.view.el,options:{event:o,onStart:u,onDrag:d,onEnd:h}});else{l&&o.dataTransfer.setDragImage(s.view.el,0,0);var f=t.Commands.get("move-comp");f.onEndMoveFromModel=h,f.initSorterFromModel(s)}s.set("status","selected")}},o["core:undo"]=function(t){return t.UndoManager.undo()},o["core:redo"]=function(t){return t.UndoManager.redo()},o["core:canvas-clear"]=function(t){t.DomComponents.clear(),t.CssComposer.clear()},o["core:copy"]=function(t){var e=t.getModel(),n=t.getSelected();n&&n.get("copyable")&&!t.Canvas.isInputFocused()&&e.set("clipboard",n)},o["core:paste"]=function(t){var e=t.getModel(),n=e.get("clipboard"),i=t.getSelected(),r=i&&i.collection;if(r&&n&&!t.Canvas.isInputFocused()){var o=r.indexOf(i)+1;r.add(n.clone(),{at:o})}},e.em&&(e.model=e.em.get("Canvas")),this.loadDefaultCommands(),this},add:l,get:function(t){var n=r[t];return"function"==typeof n&&(n=new n(e),r[t]=n),n},has:function(t){return!!r[t]},loadDefaultCommands:function(){for(var t in o)this.add(t,o[t]);return this}}}},function(t,e,n){"use strict";t.exports={ESCAPE_KEY:27,stylePrefix:"com-",defaults:[],em:null,firstCentered:!0,newFixedH:!1,minComponentH:50,minComponentW:50}},function(t,e,n){"use strict";(function(e){var n=e.$;t.exports=e.View.extend({initialize:function(t){this.config=t||{},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=n(this.getCanvasWrapper()),this.frameEl=this.canvas.getFrameEl(),this.canvasTool=this.getCanvasTools(),this.bodyEl=this.getCanvasBody()),this.init(this.config)},onFrameScroll:function(t){},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(t){var e=t.getBoundingClientRect();return{top:e.top+t.ownerDocument.body.scrollTop,left:e.left+t.ownerDocument.body.scrollLeft}},init:function(t){},run:function(t,e){},stop:function(t,e){}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var n=e.$;t.exports={run:function(t,e){arguments.length>2&&void 0!==arguments[2]&&arguments[2];e&&e.set&&e.set("active",0);var i=t.getConfig(),r=t.Modal,o=i.stylePrefix;if(this.cm=t.CodeManager||null,!this.$editors){var s=this.buildEditor("htmlmixed","hopscotch","HTML"),a=this.buildEditor("css","hopscotch","CSS");this.htmlEditor=s.el,this.cssEditor=a.el;var l=n('
');l.append(s.$el).append(a.$el),this.$editors=l}r.setTitle(i.textViewCode),r.setContent(this.$editors),r.open(),this.htmlEditor.setContent(t.getHtml()),this.cssEditor.setContent(t.getCss())},stop:function(t){var e=t.Modal;e&&e.close()},buildEditor:function(t,e,n){var i=document.createElement("textarea");!this.codeMirror&&(this.codeMirror=this.cm.getViewer("CodeMirror"));var r=this.codeMirror.clone().set({label:n,codeName:t,theme:e,input:i}),o=new this.cm.EditorView({model:r,config:this.cm.getConfig()}).render().$el;return r.init(i),{el:r,$el:o}}}}).call(e,n(0))},function(t,e,n){"use strict";var i=(n(0),n(48)),r=n(188);t.exports=i.extend({itemView:r,initialize:function(t){this.config={editor:t.editor||""},this.listenTo(this.collection,"reset",this.render)}})},function(t,e,n){"use strict";var i=n(0);t.exports=i.View.extend({events:function(){return this.model.get("events")||{mousedown:"handleClick"}},attributes:function(){return this.model.get("attributes")},initialize:function(t){this.editor=t.config.editor},handleClick:function(t){t.preventDefault(),t.stopPropagation(),this.execCommand(t)},execCommand:function(t){var e={event:t},n=this.model.get("command"),i=this.editor;"function"==typeof n&&n(i,null,e),"string"==typeof n&&i.runCommand(n,e)},render:function(){var t=this.editor.getConfig();return this.el.className+=" "+t.stylePrefix+"toolbar-item",this}})},function(t,e,n){"use strict";var i=n(0),r=n(190);t.exports=i.Collection.extend({model:r})},function(t,e,n){"use strict";var i=n(0);t.exports=i.Model.extend({defaults:{command:"",attributes:{}}})},function(t,e,n){"use strict";(function(e,i){var r=n(21),o=e.$;t.exports=i.extend({},r,{init:function(t){i.bindAll(this,"startDelete","stopDelete","onDelete"),this.hoverClass=this.pfx+"hover-delete",this.badgeClass=this.pfx+"badge-red"},enable:function(){this.$el.find("*").mouseover(this.startDelete).mouseout(this.stopDelete).click(this.onDelete)},startDelete:function(t){t.stopPropagation();var e=o(t.target);e.data("model").get("removable")&&(e.addClass(this.hoverClass),this.attachBadge(e.get(0)))},stopDelete:function(t){t.stopPropagation(),o(t.target).removeClass(this.hoverClass),this.badge&&this.badge.css({left:-1e3,top:-1e3})},onDelete:function(t){t.stopPropagation();var e=o(t.target);e.data("model").get("removable")&&(e.data("model").destroy(),this.removeBadge(),this.clean())},updateBadgeLabel:function(t){this.badge.html("Remove "+t.getName())}})}).call(e,n(0),n(1))},function(t,e,n){"use strict";(function(e){var i=(n(0),n(54));t.exports=e.extend({},i,{beforeInsert:function(t){t.type="image",t.style={},t.attributes={},t.attributes.onmousedown="return false",this.config.firstCentered&&this.getCanvasWrapper()==this.sorter.target&&(t.style.margin="0 auto")},afterInsert:function(t){t.trigger("dblclick"),this.sender&&this.sender.set("active",!1)}})}).call(e,n(1))},function(t,e,n){"use strict";(function(e,i){var r=n(2),o=n(21),s=n(53),a=e.$;t.exports=i.extend({},s,o,{init:function(t){o.init.apply(this,arguments),i.bindAll(this,"initSorter","rollback","onEndMove"),this.opt=t,this.hoverClass=this.ppfx+"highlighter-warning",this.badgeClass=this.ppfx+"badge-warning",this.noSelClass=this.ppfx+"no-select"},enable:function(){for(var t=arguments.length,e=Array(t),n=0;n
');this.panel.set("appendContent",c).trigger("change:appendContent"),o.layers.sortContainer=c.get(0);var u=(new i).init(n,o.layers);this.$layers=u.render(),c.append(this.$layers),this.toAppend=c}this.toAppend.show()},stop:function(){this.toAppend&&this.toAppend.hide()}}}).call(e,n(0))},function(t,e,n){"use strict";t.exports=function(){var t=void 0,e={},i=n(198),r=n(55),o=n(56);return{init:function(n,s){e=s||e;var a=e.em;for(var l in i)l in e||(e[l]=i[l]);var c=o,u=s.opened||{},h={level:0,config:e,opened:u};return e.showWrapper&&n.parent?(c=r,h.model=n.parent):h.collection=n,t=new c(h),a&&a.on("change:selectedComponent",this.componentChanged),this.componentChanged(),this},componentChanged:function(t,n){if(!(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).fromLayers){var i=e.em,r=i.get("opened"),o=i.get("selectedComponent"),s=o&&o.collection?o.collection.parent:null;for(var a in r)r[a].set("open",0);for(;s;)s.set("open",1),r[s.cid]=s,s=s.collection?s.collection.parent:null}},render:function(){return t.render().$el}}}},function(t,e,n){"use strict";t.exports={stylePrefix:"nv-",sortable:1,hidable:1,hideTextnode:1,showWrapper:1}},function(t,e,n){"use strict";var i=(n(31),n(0)),r=i.$;t.exports={run:function(t,e){if(this.sender=e,!this.$cn){var n=t.getConfig(),i=t.Panels;this.$cn=r("
"),this.$cn2=r("
"),this.$cn.append(this.$cn2);var o=t.DeviceManager;if(o&&n.showDevices){i.addPanel({id:"devices-c"}).set("appendContent",o.render()).trigger("change:appendContent")}var s=t.SelectorManager;s&&this.$cn2.append(s.render([])),this.$cn2.append(t.StyleManager.render());var a=t.StyleManager.getConfig(),l=a.stylePrefix;this.$header=r('
'+a.textNoElement+"
"),this.$cn.append(this.$header),i.getPanel("views-container")?this.panel=i.getPanel("views-container"):this.panel=i.addPanel({id:"views-container"}),this.panel.set("appendContent",this.$cn).trigger("change:appendContent"),this.target=t.editor,this.listenTo(this.target,"change:selectedComponent",this.toggleSm)}this.toggleSm()},toggleSm:function(){var t=this.sender;t&&t.get&&!t.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()}}},function(t,e,n){"use strict";(function(e){var n=e.$;t.exports={run:function(t,e){var i,r=t.Config,o=r.stylePrefix,s=t.TraitManager;if(!this.obj){var a=s.getTraitsViewer(),l=s.getConfig();this.obj=n("
").append('
'+l.labelContainer+"
").get(0),this.obj.appendChild(a.render().el);var c=t.Panels;i=c.getPanel("views-container")?c.getPanel("views-container"):c.addPanel({id:"views-container"}),i.set("appendContent",this.obj).trigger("change:appendContent")}this.obj.style.display="block"},stop:function(){this.obj&&(this.obj.style.display="none")}}}).call(e,n(0))},function(t,e,n){"use strict";t.exports={run:function(t,e){var n=t.BlockManager,i=t.Panels;if(!this.blocks){n.render();var r="views-container",o=document.createElement("div"),s=i.getPanel(r)||i.addPanel({id:r});o.appendChild(n.getContainer()),s.set("appendContent",o).trigger("change:appendContent"),this.blocks=o}this.blocks.style.display="block"},stop:function(){var t=this.blocks;t&&(t.style.display="none")}}},function(t,e,n){"use strict";t.exports={run:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.Modal,r=t.AssetManager,o=r.getConfig(),s=n.modalTitle||o.modalTitle||"";r.setTarget(n.target),r.onClick(n.onClick),r.onDblClick(n.onDblClick),r.onSelect(n.onSelect),this.rendered||(r.render(r.getAll().filter(function(t){return"image"==t.get("type")})),this.rendered=1),i.setTitle(s),i.setContent(r.getContainer()),i.open()}}},function(t,e,n){"use strict";(function(e){var n=e.$;t.exports={getOffsetMethod:function(t){return"get"+(t||"")+"OffsetViewerEl"},run:function(t,e,i){var r=i||{},o=r.state||"",s=t.getConfig();if(s.showOffsets&&(s.showOffsetsSelected||"Fixed"!=o)){var a=t.Canvas,l=r.el||"",c=r.elPos||a.getElementPos(l),u=window.getComputedStyle(l),h=this.ppfx,d=o+"State",f=this.getOffsetMethod(o),p=a[f]();p.style.display="block";var g=this["marginT"+o],v=this["marginB"+o],m=this["marginL"+o],y=this["marginR"+o],b=this["padT"+o],x=this["padB"+o],w=this["padL"+o],C=this["padR"+o];if(!this[d]){var k=o.toLowerCase(),S=k+"margin-v",T=k+"padding-v",E=n('
').get(0),M=n('
').get(0),P=h+S+"-el",A=h+T+"-el",O=P+" "+(h+S),L=A+" "+(h+T);g=n('
').get(0),v=n('
').get(0),m=n('
').get(0),y=n('
').get(0),b=n('
').get(0),x=n('
').get(0),w=n('
').get(0),C=n('
').get(0),this["marginT"+o]=g,this["marginB"+o]=v,this["marginL"+o]=m,this["marginR"+o]=y,this["padT"+o]=b,this["padB"+o]=x,this["padL"+o]=w,this["padR"+o]=C,E.appendChild(g),E.appendChild(v),E.appendChild(m),E.appendChild(y),M.appendChild(b),M.appendChild(x),M.appendChild(w),M.appendChild(C),p.appendChild(E),p.appendChild(M),this[d]="1"}var N=u.marginLeft.replace("px",""),D=parseInt(u.marginTop.replace("px","")),I=parseInt(u.marginBottom.replace("px","")),_=g.style,F=v.style,z=m.style,$=y.style,R=b.style,V=x.style,H=w.style,j=C.style,B=parseInt(c.left);_.height=u.marginTop,_.width=u.width,_.top=c.top-u.marginTop.replace("px","")+"px",_.left=B+"px",F.height=u.marginBottom,F.width=u.width,F.top=c.top+c.height+"px",F.left=B+"px";var W=c.height+D+I+"px",U=c.top-D+"px";z.height=W,z.width=u.marginLeft,z.top=U,z.left=B-N+"px",$.height=W,$.width=u.marginRight,$.top=U,$.left=B+c.width+"px";var q=parseInt(u.paddingTop.replace("px",""));R.height=u.paddingTop,R.width=u.width,R.top=c.top+"px",R.left=B+"px";var K=parseInt(u.paddingBottom.replace("px",""));V.height=u.paddingBottom,V.width=u.width,V.top=c.top+c.height-K+"px",V.left=B+"px";var G=c.height-K-q+"px",Y=c.top+q+"px";H.height=G,H.width=u.paddingLeft,H.top=Y,H.left=c.left+"px";var X=parseInt(u.paddingRight.replace("px",""));j.height=G,j.width=u.paddingRight,j.top=Y,j.left=c.left+c.width-X+"px"}},stop:function(t,e,n){var i=n||{},r=i.state||"",o=this.getOffsetMethod(r);t.Canvas[o]().style.display="none"}}}).call(e,n(0))},function(t,e,n){"use strict";t.exports={run:function(t){for(var e=t.getSelected(),n=e&&e.parent();n&&!n.get("selectable");)n=n.parent();n&&t.select(n)}}},function(t,e,n){"use strict";t.exports={isEnabled:function(){var t=document;return t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement?1:0},enable:function(t){var e="";return t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?(e="webkit",t.webkitRequestFullscreen()):t.mozRequestFullScreen?(e="moz",t.mozRequestFullScreen()):t.msRequestFullscreen?t.msRequestFullscreen():console.warn("Fullscreen not supported"),e},disable:function(){var t=document;t.exitFullscreen?t.exitFullscreen():t.webkitExitFullscreen?t.webkitExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.msExitFullscreen&&t.msExitFullscreen()},fsChanged:function(t,e){var n=(document,(t||"")+"fullscreenchange");this.isEnabled()||(this.stop(null,this.sender),document.removeEventListener(n,this.fsChanged))},run:function(t,e){this.sender=e;var n=this.enable(t.getContainer());this.fsChanged=this.fsChanged.bind(this,n),document.addEventListener(n+"fullscreenchange",this.fsChanged),t&&t.trigger("change:canvasOffset")},stop:function(t,e){e&&e.set&&e.set("active",!1),this.disable(),t&&t.trigger("change:canvasOffset")}}},function(t,e,n){"use strict";(function(e){t.exports={getPanels:function(t){return this.panels||(this.panels=t.Panels.getPanelsEl()),this.panels},tglPointers:function(t,n){var i=t.Canvas.getBody().querySelectorAll("."+this.ppfx+"no-pointer");e.each(i,function(t){t.style.pointerEvents=n?"":"all"})},run:function(t,e){e&&e.set&&e.set("active",!1),t.stopCommand("sw-visibility"),t.getModel().stopDefault();var n=this.getPanels(t),i=t.Canvas.getElement(),r=t.getEl(),o=t.Config.stylePrefix;this.helper||(this.helper=document.createElement("span"),this.helper.className=o+"off-prv fa fa-eye-slash",r.appendChild(this.helper),this.helper.onclick=function(){t.stopCommand("preview")}),this.helper.style.display="inline-block",this.tglPointers(t),n.style.display="none";var s=i.style;s.width="100%",s.height="100%",s.top="0",s.left="0",s.padding="0",s.margin="0",t.trigger("change:canvasOffset")},stop:function(t,e){var n=this.getPanels(t);t.runCommand("sw-visibility"),t.getModel().runDefault(),n.style.display="block",t.Canvas.getElement().setAttribute("style",""),this.helper&&(this.helper.style.display="none"),t.trigger("change:canvasOffset"),this.tglPointers(t,1)}}}).call(e,n(1))},function(t,e,n){"use strict";t.exports={run:function(t,e,n){var i=n||{},r=i.el||"",o=t.Canvas,s=this.canvasResizer,a=i.options||{},l=o.getCanvasView();return a.ratioDefault=1,a.appendTo=o.getResizerEl(),a.prefix=t.getConfig().stylePrefix,a.posFetcher=l.getElementPos.bind(l),a.mousePosFetcher=o.getMouseRelativePos,s&&!i.forceNew||(this.canvasResizer=t.Utils.Resizer.init(a),s=this.canvasResizer),s.setOptions(a),s.focus(r),s},stop:function(){var t=this.canvasResizer;t&&t.blur()}}},function(t,e,n){"use strict";t.exports={run:function(t,e,n){var i=n&&n.el||"",r=t.Canvas,o=this.dragger,s=n.options||{},a=r.getCanvasView();return s.prefix=t.getConfig().stylePrefix,s.mousePosFetcher=r.getMouseRelativePos,s.posFetcher=a.getElementPos.bind(a),o||(o=t.Utils.Dragger.init(s),this.dragger=o),o.setOptions(s),o.focus(i),s.event&&o.start(s.event),o},stop:function(){this.canvasResizer&&this.canvasResizer.blur()}}},function(t,e,n){"use strict";t.exports=function(){var t,e,i,r={},o=n(210),s=n(211),a=n(213),l=n(214),c=[];return{name:"BlockManager",init:function(n){r=n||{};var u=r.em;for(var h in o)h in r||(r[h]=o[h]);return t=new s([]),e=new s([]),c=new a,i=new l({collection:e,categories:c},r),t.listenTo(t,"add",function(t){e.add(t),u&&u.trigger("block:add",t)}),t.listenTo(t,"remove",function(t){e.remove(t),u&&u.trigger("block:remove",t)}),t.listenTo(t,"reset",function(t){e.reset(t.models)}),this},getConfig:function(){return r},onLoad:function(){var t=this.getAll();!t.length&&t.reset(r.blocks)},add:function(e,n){var i=n||{};return i.id=e,t.add(i)},get:function(e){return t.get(e)},getAll:function(){return t},getAllVisible:function(){return e},remove:function(e){return t.remove(e)},getCategories:function(){return c},getContainer:function(){return i.el},render:function(t){var e=t||this.getAll().models;i.rendered||(i.render(),i.rendered=1),i.collection.reset(e)}}}},function(t,e,n){"use strict";t.exports={blocks:[],appendTo:""}},function(t,e,n){"use strict";var i=n(0),r=n(212);t.exports=i.Collection.extend({model:r})},function(t,e,n){"use strict";var i=n(0),r=n(57);t.exports=i.Model.extend({defaults:{label:"",content:"",category:"",attributes:{}},initialize:function(){var t=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],this.get("category"));if(t&&"string"==typeof t){new r({id:t,label:t})}}})},function(t,e,n){"use strict";var i=n(0);t.exports=i.Collection.extend({model:n(57)})},function(t,e,n){"use strict";(function(e){var i=n(1),r=n(215),o=n(216);t.exports=n(0).View.extend({initialize:function(t,n){e.bindAll(this,"getSorter","onDrag","onDrop"),this.config=n||{},this.categories=t.categories||"",this.renderedCategories=[];var i=this.config.pStylePrefix||"";this.ppfx=i,this.noCatClass=i+"blocks-no-cat",this.blockContClass=i+"blocks-c",this.catsClass=i+"block-categories";var r=this.collection;this.listenTo(r,"add",this.addTo),this.listenTo(r,"reset",this.render),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 t=this.em.get("Utils"),e=this.canvas;this.sorter=new t.Sorter({container:e.getBody(),placer:e.getPlacerEl(),containerSel:"*",itemSel:"*",pfx:this.ppfx,onStart:this.onDrag,onEndMove:this.onDrop,onMove:this.onMove,document:e.getFrameEl().contentDocument,direction:"a",wmargin:1,nested:1,em:this.em,canvasRelative:1})}return this.sorter}},onDrag:function(t){this.em.stopDefault(),this.em.trigger("block:drag:start",t)},onMove:function(t){this.em.trigger("block:drag:move",t)},onDrop:function(t){var e=this.em;e.runDefault(),t&&t.get&&(t.get("activeOnRender")&&(t.trigger("active"),t.set("activeOnRender",0)),e.trigger("block:drag:stop",t))},addTo:function(t){this.add(t)},add:function(t,e){var n=e||null,s=new r({model:t,attributes:t.get("attributes")},this.config),a=s.render().el,l=t.get("category");if(l&&this.categories){(0,i.isString)(l)?l={id:l,label:l}:(0,i.isObject)(l)&&!l.id&&(l.id=l.label);var c=this.categories.add(l),u=c.get("id"),h=this.renderedCategories[u],d=this.getCategoriesEl();return t.set("category",c),!h&&d&&(h=new o({model:c},this.config).render(),this.renderedCategories[u]=h,d.appendChild(h.el)),void(h&&h.append(a))}n?n.appendChild(a):this.append(a)},getCategoriesEl:function(){return this.catsEl||(this.catsEl=this.el.querySelector("."+this.catsClass)),this.catsEl},getBlocksEl:function(){return this.blocksEl||(this.blocksEl=this.el.querySelector("."+this.noCatClass+" ."+this.blockContClass)),this.blocksEl},append:function(t){var e=this.getBlocksEl();e&&e.appendChild(t)},render:function(){var t=this,e=document.createDocumentFragment();return this.catsEl=null,this.blocksEl=null,this.renderedCategories=[],this.el.innerHTML='\n
\n
\n
\n
\n ',this.collection.each(function(n){return t.add(n,e)}),this.append(e),this.$el.addClass(this.blockContClass+"s"),this}})}).call(e,n(1))},function(t,e,n){"use strict";(function(e){var i=n(1),r=n(2);t.exports=e.View.extend({events:{mousedown:"startDrag",dragstart:"handleDragStart",dragend:"handleDragEnd"},initialize:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.em=e.em,this.config=e,this.endDrag=this.endDrag.bind(this),this.ppfx=e.pStylePrefix||"",this.listenTo(this.model,"destroy remove",this.remove)},startDrag:function(t){var e=this.config;if(0===t.button&&e.getSorter&&!this.el.draggable){e.em.refreshCanvas();var n=e.getSorter();n.setDragHelper(this.el,t),n.setDropContent(this.model.get("content")),n.startSort(this.el),(0,r.on)(document,"mouseup",this.endDrag)}},handleDragStart:function(t){var e=this.model.get("content"),n=(0,i.isObject)(e),r=n?"text/json":"text",o=n?JSON.stringify(e):e;t.dataTransfer.setData(r,o),this.em.set("dragContent",e)},handleDragEnd:function(){this.em.set("dragContent","")},endDrag:function(t){(0,r.off)(document,"mouseup",this.endDrag);var e=this.config.getSorter();e.moved=0,e.endMove()},render:function(){var t=this.el,e=this.ppfx,n=e+"block",i=this.model.get("label");return t.className+=" "+n+" "+e+"one-bg "+e+"four-color-h",t.innerHTML='
'+i+"
",(0,r.hasDnd)(this.em)&&t.setAttribute("draggable",!0),this}})}).call(e,n(0))},function(t,e,n){"use strict";(function(e){var i=n(0);t.exports=i.View.extend({template:e.template('\n
\n \n <%= label %>\n
\n
\n '),events:{},initialize:function(){var t=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});this.config=t;var e=this.config.pStylePrefix||"";this.pfx=e,this.caretR="fa fa-caret-right",this.caretD="fa fa-caret-down",this.iconClass=e+"caret-icon",this.activeClass=e+"open",this.className=e+"block-category",this.events["click ."+e+"title"]="toggle",this.listenTo(this.model,"change:open",this.updateVisibility),this.delegateEvents()},updateVisibility:function(){this.model.get("open")?this.open():this.close()},open:function(){this.el.className=this.className+" "+this.activeClass,this.getIconEl().className=this.iconClass+" "+this.caretD,this.getBlocksEl().style.display=""},close:function(){this.el.className=this.className,this.getIconEl().className=this.iconClass+" "+this.caretR,this.getBlocksEl().style.display="none"},toggle:function(){var t=this.model;t.set("open",!t.get("open"))},getIconEl:function(){return this.iconEl||(this.iconEl=this.el.querySelector("."+this.iconClass)),this.iconEl},getBlocksEl:function(){return this.blocksEl||(this.blocksEl=this.el.querySelector("."+this.pfx+"blocks-c")),this.blocksEl},append:function(t){this.getBlocksEl().appendChild(t)},render:function(){return this.el.innerHTML=this.template({pfx:this.pfx,label:this.model.get("label")}),this.el.className=this.className,this.$el.css({order:this.model.get("order")}),this.updateVisibility(),this}})}).call(e,n(1))},function(t,e,n){"use strict";t.exports=function(t){var e=t.$,n=t.Backbone;if(n){var i=n.View.prototype,r={};i.eventNsMap=r,i.delegate=function(t,e,n){var i=".delegateEvents"+this.cid;this.$el.on(t,e,n);var o=r[i];return o||(o=[],r[i]=o),o.push({eventName:t,selector:e,listener:n}),this},i.undelegateEvents=function(){var t=this,e=".delegateEvents"+this.cid;if(this.$el){var n=r[e];n&&n.forEach(function(e){var n=e.eventName;e.selector,e.listener;t.$el.off(n)})}return this},i.undelegate=function(t,e,n){var i=this,o=".delegateEvents"+this.cid,s=r[o];return s&&s.forEach(function(n){var r=n.eventName,o=n.selector;n.listener;r==t&&o==e&&i.$el.off(r)}),this}}if(e&&"jQuery"!==e.prototype.constructor.name){var o=e.fn,s=e.prototype.on,a=e.prototype.off,l=e.prototype.trigger,c=e.prototype.offset,u=function(t){return t.split(/[,\s]+/g)},h=function(t){return t.split(".")};o.on=function(t,e,n,i){var r=this;if("string"==typeof t){var o=u(t);if(1==o.length){t=o[0];var a=h(t);if(0!==t.indexOf(".")&&(t=a[0]),a=a.slice(1),a.length){this.data("_cashNs");this.data("_cashNs",a)}return s.call(this,t,e,n,i)}return o.forEach(function(t){return r.on(t,e,n,i)}),this}return s.call(this,t,e,n,i)},o.off=function(t,e){var n=this;if("string"==typeof t){var i=u(t);if(1==i.length){t=i[0];var r=h(t);return 0!==t.indexOf(".")&&(t=r[0]),r=r.slice(1),r.length,a.call(this,t,e)}return i.forEach(function(t){return n.off(t,e)}),this}return a.call(this,t,e)},o.trigger=function(t,n){var i=this;if(t instanceof e.Event)return this.trigger(t.type,n);if("string"==typeof t){var r=u(t);if(1==r.length){t=r[0];var o=h(t);return 0!==t.indexOf(".")&&(t=o[0]),o=o.slice(1),o.length,l.call(this,t,n)}return r.forEach(function(t){return i.trigger(t,n)}),this}return l.call(this,t,n)},o.hide=function(){return this.css("display","none")},o.show=function(){return this.css("display","block")},o.focus=function(){var t=this.get(0);return t&&t.focus(),this},o.remove=function(){return this.each(function(t){return t.parentNode&&t.parentNode.removeChild(t)})},o.bind=function(t,e){return this.on(t,e)},o.unbind=function(t,e){return this.off(t,e)},o.click=function(t){return t?this.on("click",t):this.trigger("click")},o.change=function(t){return t?this.on("change",t):this.trigger("change")},o.keydown=function(t){return t?this.on("keydown",t):this.trigger("keydown")},o.delegate=function(t,e,n,i){return i||(i=n),this.on(e,t,function(t){t.data=n,i(t)})},o.scrollLeft=function(){var t=this.get(0);t=9==t.nodeType?t.defaultView:t;var e=t instanceof Window?t:null;return e?e.pageXOffset:t.scrollLeft||0},o.scrollTop=function(){var t=this.get(0);t=9==t.nodeType?t.defaultView:t;var e=t instanceof Window?t:null;return e?e.pageYOffset:t.scrollTop||0},o.offset=function(t){var e=void 0,n=void 0;return t&&(e=t.top,n=t.left),void 0!==e&&this.css("top",e+"px"),void 0!==n&&this.css("left",n+"px"),c.call(this)},e.map=function(t,e){for(var n=[],i=0;i { let assets, am, fu; return { - /** * Name of the module * @type {String} @@ -75,8 +74,7 @@ module.exports = () => { c = config || {}; for (let name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } const ppfx = c.pStylePrefix; @@ -92,19 +90,19 @@ module.exports = () => { // Collection visible in asset manager collection: new Assets([]), globalCollection: assets, - config: c, + config: c }; fu = new FileUpload(obj); obj.fu = fu; am = new AssetsView(obj); // Setup the sync between the global and public collections - assets.listenTo(assets, 'add', (model) => { + assets.listenTo(assets, 'add', model => { this.getAllVisible().add(model); em && em.trigger('asset:add', model); }); - assets.listenTo(assets, 'remove', (model) => { + assets.listenTo(assets, 'remove', model => { this.getAllVisible().remove(model); em && em.trigger('asset:remove', model); }); @@ -136,7 +134,6 @@ module.exports = () => { * }]); */ add(asset, opts = {}) { - // Put the model at the beginning if (typeof opts.at == 'undefined') { opts.at = 0; @@ -153,7 +150,7 @@ module.exports = () => { * var asset = assetManager.get('http://img.jpg'); */ get(src) { - return assets.where({src})[0]; + return assets.where({ src })[0]; }, /** @@ -196,8 +193,7 @@ module.exports = () => { var obj = {}; var assets = JSON.stringify(this.getAll().toJSON()); obj[this.storageKey] = assets; - if(!noStore && c.stm) - c.stm.store(obj); + if (!noStore && c.stm) c.stm.store(obj); return obj; }, @@ -219,7 +215,7 @@ module.exports = () => { if (typeof assets == 'string') { try { assets = JSON.parse(data[name]); - } catch(err) {} + } catch (err) {} } if (assets && assets.length) { @@ -357,7 +353,6 @@ module.exports = () => { */ onDblClick(func) { c.onDblClick = func; - }, - + } }; }; diff --git a/src/asset_manager/model/Asset.js b/src/asset_manager/model/Asset.js index 8eaa01ec5..2a3a623d4 100644 --- a/src/asset_manager/model/Asset.js +++ b/src/asset_manager/model/Asset.js @@ -1,10 +1,9 @@ module.exports = require('backbone').Model.extend({ - idAttribute: 'src', defaults: { - type: '', - src: '', + type: '', + src: '' }, /** @@ -13,7 +12,9 @@ module.exports = require('backbone').Model.extend({ * @private * */ getFilename() { - return this.get('src').split('/').pop(); + return this.get('src') + .split('/') + .pop(); }, /** @@ -22,7 +23,8 @@ module.exports = require('backbone').Model.extend({ * @private * */ getExtension() { - return this.getFilename().split('.').pop(); - }, - + return this.getFilename() + .split('.') + .pop(); + } }); diff --git a/src/asset_manager/model/AssetImage.js b/src/asset_manager/model/AssetImage.js index f43bd092d..137112e8e 100644 --- a/src/asset_manager/model/AssetImage.js +++ b/src/asset_manager/model/AssetImage.js @@ -1,12 +1,11 @@ const Asset = require('./Asset'); module.exports = Asset.extend({ - - defaults: { ...Asset.prototype.defaults, + defaults: { + ...Asset.prototype.defaults, type: 'image', unitDim: 'px', height: 0, - width: 0, - }, - + width: 0 + } }); diff --git a/src/asset_manager/model/Assets.js b/src/asset_manager/model/Assets.js index e6343b255..204aa5c2f 100644 --- a/src/asset_manager/model/Assets.js +++ b/src/asset_manager/model/Assets.js @@ -1,18 +1,22 @@ import TypeableCollection from 'domain_abstract/model/TypeableCollection'; -module.exports = require('backbone').Collection.extend(TypeableCollection).extend({ - types: [{ - id: 'image', - model: require('./AssetImage'), - view: require('./../view/AssetImageView'), - isType(value) { - if (typeof value == 'string') { - return { - type: 'image', - src: value, +module.exports = require('backbone') + .Collection.extend(TypeableCollection) + .extend({ + types: [ + { + id: 'image', + model: require('./AssetImage'), + view: require('./../view/AssetImageView'), + isType(value) { + if (typeof value == 'string') { + return { + type: 'image', + src: value + }; } + return value; } - return value; } - }] -}); + ] + }); diff --git a/src/asset_manager/view/AssetImageView.js b/src/asset_manager/view/AssetImageView.js index 5adb5974c..9e1708ed1 100644 --- a/src/asset_manager/view/AssetImageView.js +++ b/src/asset_manager/view/AssetImageView.js @@ -1,9 +1,8 @@ module.exports = require('./AssetView').extend({ - events: { 'click [data-toggle=asset-remove]': 'onRemove', click: 'onClick', - dblclick: 'onDblClick', + dblclick: 'onDblClick' }, getPreview() { @@ -32,7 +31,7 @@ module.exports = require('./AssetView').extend({ init(o) { const pfx = this.pfx; - this.className += ` ${pfx}asset-image`; + this.className += ` ${pfx}asset-image`; }, /** diff --git a/src/asset_manager/view/AssetView.js b/src/asset_manager/view/AssetView.js index 3d82353b1..3297ee8e5 100644 --- a/src/asset_manager/view/AssetView.js +++ b/src/asset_manager/view/AssetView.js @@ -1,5 +1,4 @@ module.exports = Backbone.View.extend({ - initialize(o = {}) { this.options = o; this.collection = o.collection; @@ -55,5 +54,5 @@ module.exports = Backbone.View.extend({ el.innerHTML = this.template(this, this.model); el.className = this.className; return this; - }, + } }); diff --git a/src/asset_manager/view/AssetsView.js b/src/asset_manager/view/AssetsView.js index d125dc1b5..038130f22 100644 --- a/src/asset_manager/view/AssetsView.js +++ b/src/asset_manager/view/AssetsView.js @@ -3,9 +3,8 @@ var AssetImageView = require('./AssetImageView'); var FileUploader = require('./FileUploader'); module.exports = Backbone.View.extend({ - events: { - submit: 'handleSubmit', + submit: 'handleSubmit' }, template(view) { @@ -66,7 +65,7 @@ module.exports = Backbone.View.extend({ if (handleAdd) { handleAdd(url); } else { - this.options.globalCollection.add(url, {at: 0}); + this.options.globalCollection.add(url, { at: 0 }); } }, @@ -86,7 +85,7 @@ module.exports = Backbone.View.extend({ * @private */ getAddInput() { - if(!this.inputUrl || !this.inputUrl.value) + if (!this.inputUrl || !this.inputUrl.value) this.inputUrl = this.el.querySelector(`.${this.pfx}add-asset input`); return this.inputUrl; }, @@ -127,11 +126,11 @@ module.exports = Backbone.View.extend({ const rendered = new model.typeView({ model, collection, - config, + config }).render().el; if (fragment) { - fragment.appendChild( rendered ); + fragment.appendChild(rendered); } else { const assetsEl = this.getAssetsEl(); if (assetsEl) { @@ -172,7 +171,7 @@ module.exports = Backbone.View.extend({ const assets = this.$el.find(`.${this.pfx}assets`); assets.empty(); this.toggleNoAssets(this.collection.length); - this.collection.each((model) => this.addAsset(model, fragment)); + this.collection.each(model => this.addAsset(model, fragment)); assets.append(fragment); }, diff --git a/src/asset_manager/view/FileUploader.js b/src/asset_manager/view/FileUploader.js index c3c02feab..e58a0c3d3 100644 --- a/src/asset_manager/view/FileUploader.js +++ b/src/asset_manager/view/FileUploader.js @@ -1,8 +1,8 @@ import fetch from 'utils/fetch'; -module.exports = Backbone.View.extend({ - - template: _.template(` +module.exports = Backbone.View.extend( + { + template: _.template(`
<%= title %>
multiple/> @@ -10,307 +10,359 @@ module.exports = Backbone.View.extend({
`), - events: {}, - - initialize(opts = {}) { - this.options = opts; - const c = opts.config || {}; - this.config = c; - this.pfx = c.stylePrefix || ''; - this.ppfx = c.pStylePrefix || ''; - this.target = this.options.globalCollection || {}; - this.uploadId = this.pfx + 'uploadFile'; - this.disabled = c.disableUpload !== undefined ? c.disableUpload : !c.upload && !c.embedAsBase64; - this.events['change #' + this.uploadId] = 'uploadFile'; - let uploadFile = c.uploadFile; - - if (uploadFile) { - this.uploadFile = uploadFile.bind(this); - } else if (c.embedAsBase64) { - this.uploadFile = this.constructor.embedAsBase64; - } - - this.delegateEvents(); - }, - - /** - * Triggered before the upload is started - * @private - */ - onUploadStart() { - const em = this.config.em; - em && em.trigger('asset:upload:start'); - }, - - /** - * Triggered after the upload is ended - * @param {Object|string} res End result - * @private - */ - onUploadEnd(res) { - const em = this.config.em; - em && em.trigger('asset:upload:end', res); - }, - - /** - * Triggered on upload error - * @param {Object} err Error - * @private - */ - onUploadError(err) { - const em = this.config.em; - console.error(err); - this.onUploadEnd(err); - em && em.trigger('asset:upload:error', err); - }, - - /** - * Triggered on upload response - * @param {string} text Response text - * @private - */ - onUploadResponse(text) { - const em = this.config.em; - const config = this.config; - const target = this.target; - const json = typeof text === 'string' ? JSON.parse(text) : text; - em && em.trigger('asset:upload:response', json); - - if (config.autoAdd && target) { - target.add(json.data, {at: 0}); - } - - this.onUploadEnd(text); - }, + events: {}, + + initialize(opts = {}) { + this.options = opts; + const c = opts.config || {}; + this.config = c; + this.pfx = c.stylePrefix || ''; + this.ppfx = c.pStylePrefix || ''; + this.target = this.options.globalCollection || {}; + this.uploadId = this.pfx + 'uploadFile'; + this.disabled = + c.disableUpload !== undefined + ? c.disableUpload + : !c.upload && !c.embedAsBase64; + this.events['change #' + this.uploadId] = 'uploadFile'; + let uploadFile = c.uploadFile; + + if (uploadFile) { + this.uploadFile = uploadFile.bind(this); + } else if (c.embedAsBase64) { + this.uploadFile = this.constructor.embedAsBase64; + } - /** - * Upload files - * @param {Object} e Event - * @return {Promise} - * @private - * */ - uploadFile(e) { - const files = e.dataTransfer ? e.dataTransfer.files : e.target.files; - const body = new FormData(); - const config = this.config; - const params = config.params; - - for (let i = 0; i < files.length; i++) { - body.append(`${config.uploadName}[]`, files[i]); - } + this.delegateEvents(); + }, + + /** + * Triggered before the upload is started + * @private + */ + onUploadStart() { + const em = this.config.em; + em && em.trigger('asset:upload:start'); + }, + + /** + * Triggered after the upload is ended + * @param {Object|string} res End result + * @private + */ + onUploadEnd(res) { + const em = this.config.em; + em && em.trigger('asset:upload:end', res); + }, + + /** + * Triggered on upload error + * @param {Object} err Error + * @private + */ + onUploadError(err) { + const em = this.config.em; + console.error(err); + this.onUploadEnd(err); + em && em.trigger('asset:upload:error', err); + }, + + /** + * Triggered on upload response + * @param {string} text Response text + * @private + */ + onUploadResponse(text, clb) { + const em = this.config.em; + const config = this.config; + const target = this.target; + const json = typeof text === 'string' ? JSON.parse(text) : text; + em && em.trigger('asset:upload:response', json); + + if (config.autoAdd && target) { + target.add(json.data, { at: 0 }); + } - for (let param in params) { - body.append(param, params[param]); - } + this.onUploadEnd(text); + clb && clb(json); + }, + + /** + * Upload files + * @param {Object} e Event + * @return {Promise} + * @private + * */ + uploadFile(e, clb) { + const files = e.dataTransfer ? e.dataTransfer.files : e.target.files; + const body = new FormData(); + const config = this.config; + const params = config.params; + + for (let i = 0; i < files.length; i++) { + body.append(`${config.uploadName}[]`, files[i]); + } - var target = this.target; - const url = config.upload; - const headers = config.headers; - const reqHead = 'X-Requested-With'; + for (let param in params) { + body.append(param, params[param]); + } - if (typeof headers[reqHead] == 'undefined') { - headers[reqHead] = 'XMLHttpRequest'; - } + var target = this.target; + const url = config.upload; + const headers = config.headers; + const reqHead = 'X-Requested-With'; - if (url) { - this.onUploadStart(); - return fetch(url, { - method: 'post', - credentials: 'include', - headers, - body, - }).then(res => (res.status/200|0) == 1 ? - res.text() : res.text().then((text) => - Promise.reject(text) - )) - .then((text) => this.onUploadResponse(text)) - .catch(err => this.onUploadError(err)); - } - }, - - /** - * Make input file droppable - * @private - * */ - initDrop() { - var that = this; - if(!this.uploadForm){ - this.uploadForm = this.$el.find('form').get(0); - if( 'draggable' in this.uploadForm ){ - var uploadFile = this.uploadFile; - this.uploadForm.ondragover = function(){ - this.className = that.pfx + 'hover'; - return false; - }; - this.uploadForm.ondragleave = function(){ - this.className = ''; - return false; - }; - this.uploadForm.ondrop = function(e){ - this.className = ''; - e.preventDefault(); - that.uploadFile(e); - return; - }; + if (typeof headers[reqHead] == 'undefined') { + headers[reqHead] = 'XMLHttpRequest'; } - } - }, - initDropzone(ev) { - let addedCls = 0; - const c = this.config; - const em = ev.model; - const edEl = ev.el; - const editor = em.get('Editor'); - const container = em.get('Config').el; - const frameEl = em.get('Canvas').getBody(); - const ppfx = this.ppfx; - const updatedCls = `${ppfx}dropzone-active`; - const dropzoneCls = `${ppfx}dropzone`; - const cleanEditorElCls = () => { - edEl.className = edEl.className.replace(updatedCls, '').trim(); - addedCls = 0; - } - const onDragOver = () => { - if (!addedCls) { - edEl.className += ` ${updatedCls}`; - addedCls = 1; + if (url) { + this.onUploadStart(); + return fetch(url, { + method: 'post', + credentials: 'include', + headers, + body + }) + .then( + res => + ((res.status / 200) | 0) == 1 + ? res.text() + : res.text().then(text => Promise.reject(text)) + ) + .then(text => this.onUploadResponse(text, clb)) + .catch(err => this.onUploadError(err)); } - return false; - }; - const onDragLeave = () => { - cleanEditorElCls(); - return false; - }; - const onDrop = (e) => { + }, + + /** + * Make input file droppable + * @private + * */ + initDrop() { + var that = this; + if (!this.uploadForm) { + this.uploadForm = this.$el.find('form').get(0); + if ('draggable' in this.uploadForm) { + var uploadFile = this.uploadFile; + this.uploadForm.ondragover = function() { + this.className = that.pfx + 'hover'; + return false; + }; + this.uploadForm.ondragleave = function() { + this.className = ''; + return false; + }; + this.uploadForm.ondrop = function(e) { + this.className = ''; + e.preventDefault(); + that.uploadFile(e); + return; + }; + } + } + }, + + initDropzone(ev) { + let addedCls = 0; + const c = this.config; + const em = ev.model; + const edEl = ev.el; + const editor = em.get('Editor'); + const container = em.get('Config').el; + const frameEl = em.get('Canvas').getBody(); + const ppfx = this.ppfx; + const updatedCls = `${ppfx}dropzone-active`; + const dropzoneCls = `${ppfx}dropzone`; + const cleanEditorElCls = () => { + edEl.className = edEl.className.replace(updatedCls, '').trim(); + addedCls = 0; + }; + const onDragOver = () => { + if (!addedCls) { + edEl.className += ` ${updatedCls}`; + addedCls = 1; + } + return false; + }; + const onDragLeave = () => { + cleanEditorElCls(); + return false; + }; + const onDrop = e => { + cleanEditorElCls(); + e.preventDefault(); + e.stopPropagation(); + this.uploadFile(e); + + if (c.openAssetsOnDrop && editor) { + const target = editor.getSelected(); + editor.runCommand('open-assets', { + target, + onSelect() { + editor.Modal.close(); + editor.AssetManager.setTarget(null); + } + }); + } + + return false; + }; + + ev.$el.append(`
${c.dropzoneContent}
`); cleanEditorElCls(); - e.preventDefault(); - e.stopPropagation(); - this.uploadFile(e); - - if (c.openAssetsOnDrop && editor) { - const target = editor.getSelected(); - editor.runCommand('open-assets', { - target, - onSelect() { - editor.Modal.close(); - editor.AssetManager.setTarget(null); - } + + if ('draggable' in edEl) { + [edEl, frameEl].forEach(item => { + item.ondragover = onDragOver; + item.ondragleave = onDragLeave; + item.ondrop = onDrop; }); } - - return false; - }; - - ev.$el.append(`
${c.dropzoneContent}
`); - cleanEditorElCls(); - - if ('draggable' in edEl) { - [edEl, frameEl].forEach((item) => { - item.ondragover = onDragOver; - item.ondragleave = onDragLeave; - item.ondrop = onDrop; - }); + }, + + render() { + this.$el.html( + this.template({ + title: this.config.uploadText, + uploadId: this.uploadId, + disabled: this.disabled, + pfx: this.pfx + }) + ); + this.initDrop(); + this.$el.attr('class', this.pfx + 'file-uploader'); + return this; } }, + { + embedAsBase64: function(e, clb) { + // List files dropped + const files = e.dataTransfer ? e.dataTransfer.files : e.target.files; + const response = { data: [] }; + + // Unlikely, widely supported now + if (!FileReader) { + this.onUploadError( + new Error('Unsupported platform, FileReader is not defined') + ); + return; + } - render() { - this.$el.html( this.template({ - title: this.config.uploadText, - uploadId: this.uploadId, - disabled: this.disabled, - pfx: this.pfx - }) ); - this.initDrop(); - this.$el.attr('class', this.pfx + 'file-uploader'); - return this; - }, - -}, { - embedAsBase64: function (e) { - // List files dropped - const files = e.dataTransfer ? e.dataTransfer.files : e.target.files; - const response = { data: [] }; - - // Unlikely, widely supported now - if (!FileReader) { - this.onUploadError(new Error('Unsupported platform, FileReader is not defined')); - return; - } - - const promises = []; - const mimeTypeMatcher = /^(.+)\/(.+)$/; - - for (const file of files) { - // For each file a reader (to read the base64 URL) - // and a promise (to track and merge results and errors) - const promise = new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.addEventListener('load', (event) => { - let type; - const name = file.name; - - // Try to find the MIME type of the file. - const match = mimeTypeMatcher.exec(file.type); - if (match) { - type = match[1]; // The first part in the MIME, "image" in image/png - } else { - type = file.type; + const promises = []; + const mimeTypeMatcher = /^(.+)\/(.+)$/; + + for (const file of files) { + // For each file a reader (to read the base64 URL) + // and a promise (to track and merge results and errors) + const promise = new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.addEventListener('load', event => { + let type; + const name = file.name; + + // Try to find the MIME type of the file. + const match = mimeTypeMatcher.exec(file.type); + if (match) { + type = match[1]; // The first part in the MIME, "image" in image/png + } else { + type = file.type; + } + + /* + // Show local video files, http://jsfiddle.net/dsbonev/cCCZ2/embedded/result,js,html,css/ + var URL = window.URL || window.webkitURL + var file = this.files[0] + var type = file.type + var videoNode = document.createElement('video'); + var canPlay = videoNode.canPlayType(type) // can use also for 'audio' types + if (canPlay === '') canPlay = 'no' + var message = 'Can play type "' + type + '": ' + canPlay + var isError = canPlay === 'no' + displayMessage(message, isError) + + if (isError) { + return } - // If it's an image, try to find its size - if (type === 'image') { - const data = { - src: reader.result, - name, - type, - height: 0, - width: 0 - }; - - const image = new Image(); - image.addEventListener('error', (error) => { - reject(error); - }); - image.addEventListener('load', () => { - data.height = image.height; - data.width = image.width; - resolve(data); - }); - image.src = data.src; - - } else if (type) { - // Not an image, but has a type - resolve({ - src: reader.result, - name, - type - }); - } else { - // No type found, resolve with the URL only - resolve(reader.result); - } - }); - reader.addEventListener('error', (error) => { - reject(error); - }); - reader.addEventListener('abort', (error) => { - reject('Aborted'); + var fileURL = URL.createObjectURL(file) + videoNode.src = fileURL + */ + + /* + // Show local video files, http://jsfiddle.net/dsbonev/cCCZ2/embedded/result,js,html,css/ + var URL = window.URL || window.webkitURL + var file = this.files[0] + var type = file.type + var videoNode = document.createElement('video'); + var canPlay = videoNode.canPlayType(type) // can use also for 'audio' types + if (canPlay === '') canPlay = 'no' + var message = 'Can play type "' + type + '": ' + canPlay + var isError = canPlay === 'no' + displayMessage(message, isError) + + if (isError) { + return + } + + var fileURL = URL.createObjectURL(file) + videoNode.src = fileURL + */ + + // If it's an image, try to find its size + if (type === 'image') { + const data = { + src: reader.result, + name, + type, + height: 0, + width: 0 + }; + + const image = new Image(); + image.addEventListener('error', error => { + reject(error); + }); + image.addEventListener('load', () => { + data.height = image.height; + data.width = image.width; + resolve(data); + }); + image.src = data.src; + } else if (type) { + // Not an image, but has a type + resolve({ + src: reader.result, + name, + type + }); + } else { + // No type found, resolve with the URL only + resolve(reader.result); + } + }); + reader.addEventListener('error', error => { + reject(error); + }); + reader.addEventListener('abort', error => { + reject('Aborted'); + }); + + reader.readAsDataURL(file); }); - reader.readAsDataURL(file); - }); + promises.push(promise); + } - promises.push(promise); + Promise.all(promises).then( + data => { + response.data = data; + this.onUploadResponse(response, clb); + }, + error => { + this.onUploadError(error); + } + ); } - - Promise - .all(promises) - .then((data) => { - response.data = data; - this.onUploadResponse(response); - }, (error) => { - this.onUploadError(error); - }); } -}); +); diff --git a/src/block_manager/config/config.js b/src/block_manager/config/config.js index 3d8331e1e..9a66db002 100644 --- a/src/block_manager/config/config.js +++ b/src/block_manager/config/config.js @@ -1,7 +1,5 @@ module.exports = { - blocks: [], - appendTo: '', - + appendTo: '' }; diff --git a/src/block_manager/index.js b/src/block_manager/index.js index c7edca7b8..ea7e844f5 100644 --- a/src/block_manager/index.js +++ b/src/block_manager/index.js @@ -30,201 +30,201 @@ */ module.exports = () => { var c = {}, - defaults = require('./config/config'), - Blocks = require('./model/Blocks'), - BlockCategories = require('./model/Categories'), - BlocksView = require('./view/BlocksView'); + defaults = require('./config/config'), + Blocks = require('./model/Blocks'), + BlockCategories = require('./model/Categories'), + BlocksView = require('./view/BlocksView'); var blocks, blocksVisible, blocksView; var categories = []; return { - - /** - * Name of the module - * @type {String} - * @private - */ - name: 'BlockManager', - - /** - * Initialize module. Automatically called with a new instance of the editor - * @param {Object} config Configurations - * @return {this} - * @private - */ - init(config) { - c = config || {}; - const em = c.em; - - for (let name in defaults) { - if (!(name in c)) { - c[name] = defaults[name]; - } - } - - // Global blocks collection - blocks = new Blocks([]); - blocksVisible = new Blocks([]); - categories = new BlockCategories(), - blocksView = new BlocksView({ - // Visible collection - collection: blocksVisible, - categories, - }, c); - - // Setup the sync between the global and public collections - blocks.listenTo(blocks, 'add', model => { - blocksVisible.add(model); - em && em.trigger('block:add', model); - }); - - blocks.listenTo(blocks, 'remove', model => { - blocksVisible.remove(model); - em && em.trigger('block:remove', model); - }); - - blocks.listenTo(blocks, 'reset', coll => { - blocksVisible.reset(coll.models); - }); - - return this; - }, - - /** - * Get configuration object - * @return {Object} - */ - getConfig() { - return c; - }, - - /** - * Load default blocks if the collection is empty - */ - onLoad() { - const blocks = this.getAll(); - !blocks.length && blocks.reset(c.blocks); - }, - - /** - * Add new block to the collection. - * @param {string} id Block id - * @param {Object} opts Options - * @param {string} opts.label Name of the block - * @param {string} opts.content HTML content - * @param {string|Object} opts.category Group the block inside a catgegory. - * You should pass objects with id property, eg: - * {id: 'some-uid', label: 'My category'} - * The string will be converted in: - * 'someid' => {id: 'someid', label: 'someid'} - * @param {Object} [opts.attributes={}] Block attributes - * @return {Block} Added block - * @example - * blockManager.add('h1-block', { - * label: 'Heading', - * content: '

Put your title here

', - * category: 'Basic', - * attributes: { - * title: 'Insert h1 block' - * } - * }); - */ - add(id, opts) { - var obj = opts || {}; - obj.id = id; - return blocks.add(obj); - }, - - /** - * Return the block by id - * @param {string} id Block id - * @example - * const block = blockManager.get('h1-block'); - * console.log(JSON.stringify(block)); - * // {label: 'Heading', content: '

Put your ...', ...} - */ - get(id) { - return blocks.get(id); - }, - - /** - * Return all blocks - * @return {Collection} - * @example - * const blocks = blockManager.getAll(); - * console.log(JSON.stringify(blocks)); - * // [{label: 'Heading', content: '

Put your ...'}, ...] - */ - getAll() { - return blocks; - }, - - /** - * Return the visible collection, which containes blocks actually rendered - * @return {Collection} - */ - getAllVisible() { - return blocksVisible; - }, - - /** - * Remove a block by id - * @param {string} id Block id - * @return {Block} Removed block - */ - remove(id) { - return blocks.remove(id); - }, - - /** - * Get all available categories. - * It's possible to add categories only within blocks via 'add()' method - * @return {Array|Collection} - */ - getCategories() { - return categories; - }, - - /** - * Return the Blocks container element - * @return {HTMLElement} - */ - getContainer() { - return blocksView.el; - }, - - /** - * Render blocks - * @param {Array} blocks Blocks to render, without the argument will render - * all global blocks - * @example - * // Render all blocks (inside the global collection) - * blockManager.render(); - * - * // Render new set of blocks - * const blocks = blockManager.getAll(); - * blockManager.render(blocks.filter( - * block => block.get('category') == 'sections' - * )); - * // Or a new set from an array - * blockManager.render([ - * {label: 'Label text', content: '
Content
'} - * ]); - * - * // Back to blocks from the global collection - * blockManager.render(); - */ - render(blocks) { - const toRender = blocks || this.getAll().models; - - if (!blocksView.rendered) { - blocksView.render(); - blocksView.rendered = 1; + /** + * Name of the module + * @type {String} + * @private + */ + name: 'BlockManager', + + /** + * Initialize module. Automatically called with a new instance of the editor + * @param {Object} config Configurations + * @return {this} + * @private + */ + init(config) { + c = config || {}; + const em = c.em; + + for (let name in defaults) { + if (!(name in c)) { + c[name] = defaults[name]; } - - blocksView.collection.reset(toRender); - }, - + } + + // Global blocks collection + blocks = new Blocks([]); + blocksVisible = new Blocks([]); + (categories = new BlockCategories()), + (blocksView = new BlocksView( + { + // Visible collection + collection: blocksVisible, + categories + }, + c + )); + + // Setup the sync between the global and public collections + blocks.listenTo(blocks, 'add', model => { + blocksVisible.add(model); + em && em.trigger('block:add', model); + }); + + blocks.listenTo(blocks, 'remove', model => { + blocksVisible.remove(model); + em && em.trigger('block:remove', model); + }); + + blocks.listenTo(blocks, 'reset', coll => { + blocksVisible.reset(coll.models); + }); + + return this; + }, + + /** + * Get configuration object + * @return {Object} + */ + getConfig() { + return c; + }, + + /** + * Load default blocks if the collection is empty + */ + onLoad() { + const blocks = this.getAll(); + !blocks.length && blocks.reset(c.blocks); + }, + + /** + * Add new block to the collection. + * @param {string} id Block id + * @param {Object} opts Options + * @param {string} opts.label Name of the block + * @param {string} opts.content HTML content + * @param {string|Object} opts.category Group the block inside a catgegory. + * You should pass objects with id property, eg: + * {id: 'some-uid', label: 'My category'} + * The string will be converted in: + * 'someid' => {id: 'someid', label: 'someid'} + * @param {Object} [opts.attributes={}] Block attributes + * @return {Block} Added block + * @example + * blockManager.add('h1-block', { + * label: 'Heading', + * content: '

Put your title here

', + * category: 'Basic', + * attributes: { + * title: 'Insert h1 block' + * } + * }); + */ + add(id, opts) { + var obj = opts || {}; + obj.id = id; + return blocks.add(obj); + }, + + /** + * Return the block by id + * @param {string} id Block id + * @example + * const block = blockManager.get('h1-block'); + * console.log(JSON.stringify(block)); + * // {label: 'Heading', content: '

Put your ...', ...} + */ + get(id) { + return blocks.get(id); + }, + + /** + * Return all blocks + * @return {Collection} + * @example + * const blocks = blockManager.getAll(); + * console.log(JSON.stringify(blocks)); + * // [{label: 'Heading', content: '

Put your ...'}, ...] + */ + getAll() { + return blocks; + }, + + /** + * Return the visible collection, which containes blocks actually rendered + * @return {Collection} + */ + getAllVisible() { + return blocksVisible; + }, + + /** + * Remove a block by id + * @param {string} id Block id + * @return {Block} Removed block + */ + remove(id) { + return blocks.remove(id); + }, + + /** + * Get all available categories. + * It's possible to add categories only within blocks via 'add()' method + * @return {Array|Collection} + */ + getCategories() { + return categories; + }, + + /** + * Return the Blocks container element + * @return {HTMLElement} + */ + getContainer() { + return blocksView.el; + }, + + /** + * Render blocks + * @param {Array} blocks Blocks to render, without the argument will render + * all global blocks + * @example + * // Render all blocks (inside the global collection) + * blockManager.render(); + * + * // Render new set of blocks + * const blocks = blockManager.getAll(); + * blockManager.render(blocks.filter( + * block => block.get('category') == 'sections' + * )); + * // Or a new set from an array + * blockManager.render([ + * {label: 'Label text', content: '
Content
'} + * ]); + * + * // Back to blocks from the global collection + * blockManager.render(); + */ + render(blocks) { + const toRender = blocks || this.getAll().models; + + if (!blocksView.rendered) { + blocksView.render(); + blocksView.rendered = 1; + } + + blocksView.collection.reset(toRender); + } }; - }; diff --git a/src/block_manager/model/Block.js b/src/block_manager/model/Block.js index 3e8b7d7ed..356091ea1 100644 --- a/src/block_manager/model/Block.js +++ b/src/block_manager/model/Block.js @@ -2,12 +2,11 @@ var Backbone = require('backbone'); var Category = require('./Category'); module.exports = Backbone.Model.extend({ - defaults: { label: '', content: '', category: '', - attributes: {}, + attributes: {} }, initialize(opts = {}) { @@ -17,10 +16,9 @@ module.exports = Backbone.Model.extend({ if (typeof category == 'string') { var catObj = new Category({ id: category, - label: category, + label: category }); } } - }, - + } }); diff --git a/src/block_manager/model/Blocks.js b/src/block_manager/model/Blocks.js index 0522254e6..30b9a039a 100644 --- a/src/block_manager/model/Blocks.js +++ b/src/block_manager/model/Blocks.js @@ -2,5 +2,5 @@ var Backbone = require('backbone'); var Block = require('./Block'); module.exports = Backbone.Collection.extend({ - model: Block, + model: Block }); diff --git a/src/block_manager/model/Categories.js b/src/block_manager/model/Categories.js index cc0352ec1..849324aee 100644 --- a/src/block_manager/model/Categories.js +++ b/src/block_manager/model/Categories.js @@ -1,5 +1,5 @@ var Backbone = require('backbone'); module.exports = Backbone.Collection.extend({ - model: require('./Category'), + model: require('./Category') }); diff --git a/src/block_manager/model/Category.js b/src/block_manager/model/Category.js index e969636e0..379151c57 100644 --- a/src/block_manager/model/Category.js +++ b/src/block_manager/model/Category.js @@ -1,12 +1,10 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - defaults: { id: '', label: '', open: true, - attributes: {}, - }, - + attributes: {} + } }); diff --git a/src/block_manager/view/BlockView.js b/src/block_manager/view/BlockView.js index b7891b0fc..bbcbcab26 100644 --- a/src/block_manager/view/BlockView.js +++ b/src/block_manager/view/BlockView.js @@ -1,12 +1,15 @@ -import {on, off} from 'utils/mixins'; +import { isObject } from 'underscore'; +import { on, off, hasDnd } from 'utils/mixins'; module.exports = Backbone.View.extend({ - events: { - mousedown: 'startDrag' + mousedown: 'startDrag', + dragstart: 'handleDragStart', + dragend: 'handleDragEnd' }, initialize(o, config = {}) { + this.em = config.em; this.config = config; this.endDrag = this.endDrag.bind(this); this.ppfx = config.pStylePrefix || ''; @@ -18,23 +21,33 @@ module.exports = Backbone.View.extend({ * @private */ startDrag(e) { + const config = this.config; //Right or middel click - if (e.button !== 0) { - return; - } - - if(!this.config.getSorter) { - return; - } - - this.config.em.refreshCanvas(); - var sorter = this.config.getSorter(); + if (e.button !== 0 || !config.getSorter || this.el.draggable) return; + config.em.refreshCanvas(); + const sorter = config.getSorter(); sorter.setDragHelper(this.el, e); sorter.setDropContent(this.model.get('content')); sorter.startSort(this.el); on(document, 'mouseup', this.endDrag); }, + handleDragStart(ev) { + const content = this.model.get('content'); + const isObj = isObject(content); + const type = isObj ? 'text/json' : 'text'; + const data = isObj ? JSON.stringify(content) : content; + + // Note: data are not available on dragenter for security reason, + // but will use dragContent as I need it for the Sorter context + ev.dataTransfer.setData(type, data); + this.em.set('dragContent', content); + }, + + handleDragEnd() { + this.em.set('dragContent', ''); + }, + /** * Drop block * @private @@ -55,9 +68,10 @@ module.exports = Backbone.View.extend({ const el = this.el; const pfx = this.ppfx; const className = `${pfx}block`; + const label = this.model.get('label'); el.className += ` ${className} ${pfx}one-bg ${pfx}four-color-h`; - el.innerHTML = `
${this.model.get('label')}
`; + el.innerHTML = `
${label}
`; + hasDnd(this.em) && el.setAttribute('draggable', true); return this; - }, - + } }); diff --git a/src/block_manager/view/BlocksView.js b/src/block_manager/view/BlocksView.js index e14663450..b38b20c28 100644 --- a/src/block_manager/view/BlocksView.js +++ b/src/block_manager/view/BlocksView.js @@ -1,9 +1,9 @@ -var Backbone = require('backbone'); -var BlockView = require('./BlockView'); -var CategoryView = require('./CategoryView'); +import { isString, isObject } from 'underscore'; -module.exports = Backbone.View.extend({ +const BlockView = require('./BlockView'); +const CategoryView = require('./CategoryView'); +module.exports = require('backbone').View.extend({ initialize(opts, config) { _.bindAll(this, 'getSorter', 'onDrag', 'onDrop'); this.config = config || {}; @@ -21,7 +21,7 @@ module.exports = Backbone.View.extend({ this.tac = 'test-tac'; this.grabbingCls = this.ppfx + 'grabbing'; - if(this.em){ + if (this.em) { this.config.getSorter = this.getSorter; this.canvas = this.em.get('Canvas'); } @@ -32,9 +32,8 @@ module.exports = Backbone.View.extend({ * @private */ getSorter() { - if(!this.em) - return; - if(!this.sorter){ + if (!this.em) return; + if (!this.sorter) { var utils = this.em.get('Utils'); var canvas = this.canvas; this.sorter = new utils.Sorter({ @@ -51,7 +50,7 @@ module.exports = Backbone.View.extend({ wmargin: 1, nested: 1, em: this.em, - canvasRelative: 1, + canvasRelative: 1 }); } return this.sorter; @@ -79,7 +78,7 @@ module.exports = Backbone.View.extend({ em.runDefault(); if (model && model.get) { - if(model.get('activeOnRender')) { + if (model.get('activeOnRender')) { model.trigger('active'); model.set('activeOnRender', 0); } @@ -105,20 +104,25 @@ module.exports = Backbone.View.extend({ * */ add(model, fragment) { var frag = fragment || null; - var view = new BlockView({ - model, - attributes: model.get('attributes'), - }, this.config); + var view = new BlockView( + { + model, + attributes: model.get('attributes') + }, + this.config + ); var rendered = view.render().el; var category = model.get('category'); // Check for categories if (category && this.categories) { - if (typeof category == 'string') { + if (isString(category)) { category = { id: category, label: category }; + } else if (isObject(category) && !category.id) { + category.id = category.label; } var catModel = this.categories.add(category); @@ -128,9 +132,12 @@ module.exports = Backbone.View.extend({ model.set('category', catModel); if (!catView && categories) { - catView = new CategoryView({ - model: catModel - }, this.config).render(); + catView = new CategoryView( + { + model: catModel + }, + this.config + ).render(); this.renderedCategories[catId] = catView; categories.appendChild(catView.el); } @@ -139,10 +146,8 @@ module.exports = Backbone.View.extend({ return; } - if(frag) - frag.appendChild(rendered); - else - this.append(rendered); + if (frag) frag.appendChild(rendered); + else this.append(rendered); }, getCategoriesEl() { @@ -155,7 +160,9 @@ module.exports = Backbone.View.extend({ getBlocksEl() { if (!this.blocksEl) { - this.blocksEl = this.el.querySelector(`.${this.noCatClass} .${this.blockContClass}`); + this.blocksEl = this.el.querySelector( + `.${this.noCatClass} .${this.blockContClass}` + ); } return this.blocksEl; @@ -180,8 +187,7 @@ module.exports = Backbone.View.extend({ this.collection.each(model => this.add(model, frag)); this.append(frag); - this.$el.addClass(this.blockContClass + 's') + this.$el.addClass(this.blockContClass + 's'); return this; - }, - + } }); diff --git a/src/block_manager/view/CategoryView.js b/src/block_manager/view/CategoryView.js index fa6c811f0..dc42081c9 100644 --- a/src/block_manager/view/CategoryView.js +++ b/src/block_manager/view/CategoryView.js @@ -1,7 +1,6 @@ var Backbone = require('backbone'); module.exports = Backbone.View.extend({ - template: _.template(`
@@ -21,16 +20,14 @@ module.exports = Backbone.View.extend({ this.iconClass = `${pfx}caret-icon`; this.activeClass = `${pfx}open`; this.className = `${pfx}block-category`; - this.events[`click .${pfx}title`] = 'toggle'; + this.events[`click .${pfx}title`] = 'toggle'; this.listenTo(this.model, 'change:open', this.updateVisibility); this.delegateEvents(); }, updateVisibility() { - if(this.model.get('open')) - this.open(); - else - this.close(); + if (this.model.get('open')) this.open(); + else this.close(); }, open() { @@ -73,10 +70,11 @@ module.exports = Backbone.View.extend({ render() { this.el.innerHTML = this.template({ pfx: this.pfx, - label: this.model.get('label'), + label: this.model.get('label') }); this.el.className = this.className; + this.$el.css({ order: this.model.get('order') }); this.updateVisibility(); return this; - }, + } }); diff --git a/src/canvas/config/config.js b/src/canvas/config/config.js index 084ac18da..e69831d7a 100644 --- a/src/canvas/config/config.js +++ b/src/canvas/config/config.js @@ -1,5 +1,4 @@ module.exports = { - stylePrefix: 'cv-', // Coming soon @@ -31,6 +30,5 @@ module.exports = { * return ComponentModel.getName(); * } */ - customBadgeLabel: '', - + customBadgeLabel: '' }; diff --git a/src/canvas/index.js b/src/canvas/index.js index 0f3f80ded..9f28202d5 100644 --- a/src/canvas/index.js +++ b/src/canvas/index.js @@ -1,15 +1,15 @@ -import {on, off} from 'utils/mixins' +import { on, off, hasDnd } from 'utils/mixins'; +import Droppable from 'utils/Droppable'; module.exports = () => { var c = {}, - defaults = require('./config/config'), - Canvas = require('./model/Canvas'), - CanvasView = require('./view/CanvasView'); + defaults = require('./config/config'), + Canvas = require('./model/Canvas'), + CanvasView = require('./view/CanvasView'); var canvas; var frameRect; return { - /** * Used inside RTE * @private @@ -32,23 +32,20 @@ module.exports = () => { init(config) { c = config || {}; for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } var ppfx = c.pStylePrefix; - if(ppfx) - c.stylePrefix = ppfx + c.stylePrefix; + if (ppfx) c.stylePrefix = ppfx + c.stylePrefix; canvas = new Canvas(config); - CanvasView = new CanvasView({ + CanvasView = new CanvasView({ model: canvas, - config: c, + config: c }); var cm = c.em.get('DomComponents'); - if(cm) - this.setWrapper(cm); + if (cm) this.setWrapper(cm); this.startAutoscroll = this.startAutoscroll.bind(this); this.stopAutoscroll = this.stopAutoscroll.bind(this); @@ -200,11 +197,11 @@ module.exports = () => { }, /** - * Get the offset of the element - * @param {HTMLElement} el - * @return {Object} - * @private - */ + * Get the offset of the element + * @param {HTMLElement} el + * @return {Object} + * @private + */ offset(el) { return CanvasView.offset(el); }, @@ -257,11 +254,11 @@ module.exports = () => { var elTop = pos.top - targetHeight; var elLeft = pos.left; elLeft += toRight ? pos.width : 0; - elLeft = toRight ? (elLeft - targetWidth) : elLeft; + elLeft = toRight ? elLeft - targetWidth : elLeft; var leftPos = elLeft < canvasPos.left ? canvasPos.left : elLeft; var topPos = elTop < canvasPos.top ? canvasPos.top : elTop; - topPos = topPos > (pos.top + pos.height) ? (pos.top + pos.height) : topPos; + topPos = topPos > pos.top + pos.height ? pos.top + pos.height : topPos; var result = { top: topPos, @@ -273,11 +270,11 @@ module.exports = () => { targetWidth: target.offsetWidth, targetHeight: target.offsetHeight, canvasTop: canvasPos.top, - canvasLeft: canvasPos.left, + canvasLeft: canvasPos.left }; // In this way I can catch data and also change the position strategy - if(eventToTrigger && c.em) { + if (eventToTrigger && c.em) { c.em.trigger(eventToTrigger, result); } @@ -311,7 +308,7 @@ module.exports = () => { return { y: e.clientY + addTop - yOffset, - x: e.clientX + addLeft - xOffset, + x: e.clientX + addLeft - xOffset }; }, @@ -331,7 +328,7 @@ module.exports = () => { return { y: e.clientY + addTop + yOffset, - x: e.clientX + addLeft + xOffset, + x: e.clientX + addLeft + xOffset }; }, @@ -371,11 +368,11 @@ module.exports = () => { let limitBottom = frameRect.height - limitTop; if (clientY < limitTop) { - nextTop -= (limitTop - clientY); + nextTop -= limitTop - clientY; } if (clientY > limitBottom) { - nextTop += (clientY - limitBottom); + nextTop += clientY - limitBottom; } //console.log(`actualTop: ${actualTop} clientY: ${clientY} nextTop: ${nextTop} frameHeigh: ${frameRect.height}`); @@ -397,6 +394,10 @@ module.exports = () => { return [this.getFrameEl().contentWindow, this.getElement()]; }, + postRender() { + if (hasDnd(c.em)) this.droppable = new Droppable(c.em); + }, + /** * Returns wrapper element * @return {HTMLElement} @@ -404,6 +405,6 @@ module.exports = () => { */ getFrameWrapperEl() { return CanvasView.frame.getWrapper(); - }, + } }; }; diff --git a/src/canvas/model/Canvas.js b/src/canvas/model/Canvas.js index 6f4968364..ce168885f 100644 --- a/src/canvas/model/Canvas.js +++ b/src/canvas/model/Canvas.js @@ -2,16 +2,14 @@ var Backbone = require('backbone'); var Frame = require('./Frame'); module.exports = Backbone.Model.extend({ - - defaults :{ + defaults: { frame: '', wrapper: '', - rulers: false, + rulers: false }, initialize(config) { var conf = this.conf || {}; this.set('frame', new Frame(conf.frame)); - }, - + } }); diff --git a/src/canvas/model/Frame.js b/src/canvas/model/Frame.js index aa66331cd..9c859ac0d 100644 --- a/src/canvas/model/Frame.js +++ b/src/canvas/model/Frame.js @@ -1,12 +1,10 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - - defaults :{ + defaults: { wrapper: '', width: '', height: '', - attributes: {}, - }, - + attributes: {} + } }); diff --git a/src/canvas/view/CanvasView.js b/src/canvas/view/CanvasView.js index 7be33d503..a42b89d4d 100644 --- a/src/canvas/view/CanvasView.js +++ b/src/canvas/view/CanvasView.js @@ -2,14 +2,13 @@ const FrameView = require('./FrameView'); const $ = Backbone.$; module.exports = Backbone.View.extend({ - initialize(o) { _.bindAll(this, 'renderBody', 'onFrameScroll', 'clearOff'); - window.onscroll = this.clearOff + window.onscroll = this.clearOff; this.config = o.config || {}; this.em = this.config.em || {}; - this.ppfx = this.config.pStylePrefix || ''; - this.className = this.config.stylePrefix + 'canvas'; + this.ppfx = this.config.pStylePrefix || ''; + this.className = this.config.stylePrefix + 'canvas'; this.listenTo(this.em, 'change:canvasOffset', this.clearOff); this.frame = new FrameView({ model: this.model.get('frame'), @@ -17,7 +16,6 @@ module.exports = Backbone.View.extend({ }); }, - /** * Checks if the element is visible in the canvas's viewport * @param {HTMLElement} el @@ -28,8 +26,12 @@ module.exports = Backbone.View.extend({ const frameRect = this.getFrameOffset(1); const rTop = rect.top; const rLeft = rect.left; - return rTop >= 0 && rLeft >= 0 && - rTop <= frameRect.height && rLeft <= frameRect.width; + return ( + rTop >= 0 && + rLeft >= 0 && + rTop <= frameRect.height && + rLeft <= frameRect.width + ); }, /** @@ -49,26 +51,26 @@ module.exports = Backbone.View.extend({ * @private */ renderScripts() { - var frame = this.frame; - var that = this; - - frame.el.onload = () => { - var scripts = that.config.scripts.slice(0), // clone - counter = 0; - - function appendScript(scripts) { - if (scripts.length > 0) { - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = scripts.shift(); - script.onerror = script.onload = appendScript.bind(null, scripts); - frame.el.contentDocument.head.appendChild(script); - } else { - that.renderBody(); - } + var frame = this.frame; + var that = this; + + frame.el.onload = () => { + var scripts = that.config.scripts.slice(0), // clone + counter = 0; + + function appendScript(scripts) { + if (scripts.length > 0) { + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = scripts.shift(); + script.onerror = script.onload = appendScript.bind(null, scripts); + frame.el.contentDocument.head.appendChild(script); + } else { + that.renderBody(); } - appendScript(scripts); - }; + } + appendScript(scripts); + }; }, /** @@ -78,7 +80,7 @@ module.exports = Backbone.View.extend({ renderBody() { var wrap = this.model.get('frame').get('wrapper'); var em = this.config.em; - if(wrap) { + if (wrap) { var ppfx = this.ppfx; //var body = this.frame.$el.contents().find('body'); var body = $(this.frame.el.contentWindow.document.body); @@ -88,7 +90,7 @@ module.exports = Backbone.View.extend({ var protCss = conf.protectedCss; var externalStyles = ''; - confCanvas.styles.forEach((style) => { + confCanvas.styles.forEach(style => { externalStyles += ``; }); @@ -107,7 +109,8 @@ module.exports = Backbone.View.extend({ background-color: #fff } #wrapper { - overflow: auto + overflow: auto; + overflow-x: hidden; } `; // Remove `html { height: 100%;}` from the baseCss as it gives jumpings @@ -202,7 +205,7 @@ module.exports = Backbone.View.extend({ // the keyCode/which will be always `0`. Even if it's an old/deprecated // property keymaster (and many others) still use it... using `defineProperty` // hack seems the only way - const createCustomEvent = (e) => { + const createCustomEvent = e => { var oEvent = new KeyboardEvent(e.type, e); oEvent.keyCodeVal = e.keyCode; ['keyCode', 'which'].forEach(prop => { @@ -213,7 +216,7 @@ module.exports = Backbone.View.extend({ }); }); return oEvent; - } + }; fdoc.addEventListener('keydown', e => { doc.dispatchEvent(createCustomEvent(e)); }); @@ -235,7 +238,7 @@ module.exports = Backbone.View.extend({ top: rect.top + docBody.scrollTop, left: rect.left + docBody.scrollLeft, width: rect.width, - height: rect.height, + height: rect.height }; }, @@ -254,8 +257,7 @@ module.exports = Backbone.View.extend({ * @private */ getFrameOffset(force = 0) { - if(!this.frmOff || force) - this.frmOff = this.offset(this.frame.el); + if (!this.frmOff || force) this.frmOff = this.offset(this.frame.el); return this.frmOff; }, @@ -265,8 +267,7 @@ module.exports = Backbone.View.extend({ * @private */ getCanvasOffset() { - if(!this.cvsOff) - this.cvsOff = this.offset(this.el); + if (!this.cvsOff) this.cvsOff = this.offset(this.el); return this.cvsOff; }, @@ -315,7 +316,7 @@ module.exports = Backbone.View.extend({ * @private */ updateScript(view) { - if(!view.scriptContainer) { + if (!view.scriptContainer) { view.scriptContainer = $('
'); this.getJsContainer().append(view.scriptContainer.get(0)); } @@ -331,7 +332,9 @@ module.exports = Backbone.View.extend({ setTimeout(function() { var item = document.getElementById('${id}'); if (!item) return; - (function(){${model.getScriptString()}}.bind(item))() + (function(){ + ${model.getScriptString()}; + }.bind(item))() }, 1);`; view.scriptContainer.get(0).appendChild(script); }, @@ -347,11 +350,10 @@ module.exports = Backbone.View.extend({ return this.jsContainer; }, - render() { - this.wrapper = this.model.get('wrapper'); + this.wrapper = this.model.get('wrapper'); - if(this.wrapper && typeof this.wrapper.render == 'function'){ + if (this.wrapper && typeof this.wrapper.render == 'function') { this.model.get('frame').set('wrapper', this.wrapper); this.$el.append(this.frame.render().el); var frame = this.frame; @@ -389,6 +391,5 @@ module.exports = Backbone.View.extend({ this.toolsEl = toolsEl; this.el.className = this.className; return this; - }, - + } }); diff --git a/src/canvas/view/FrameView.js b/src/canvas/view/FrameView.js index 7a35a46cb..f1cb76af0 100644 --- a/src/canvas/view/FrameView.js +++ b/src/canvas/view/FrameView.js @@ -1,13 +1,12 @@ -import { bindAll } from 'underscore' +import { bindAll } from 'underscore'; -const motionsEv = 'transitionend oTransitionEnd transitionend webkitTransitionEnd'; +const motionsEv = + 'transitionend oTransitionEnd transitionend webkitTransitionEnd'; module.exports = require('backbone').View.extend({ - tagName: 'iframe', attributes: { - src: 'about:blank', allowfullscreen: 'allowfullscreen' }, @@ -27,11 +26,18 @@ module.exports = require('backbone').View.extend({ const em = this.em; const device = em.getDeviceModel(); const style = this.el.style; - style.width = device ? device.get('width') : ''; - style.height = device ? device.get('height') : ''; + const currW = style.width || ''; + const currH = style.height || ''; + const newW = device ? device.get('width') : ''; + const newH = device ? device.get('height') : ''; + const noChanges = currW == newW && currH == newH; + style.width = newW; + style.height = newH; this.udpateOffset(); + // Prevent fixed highlighting box which appears when on + // component hover during the animation em.stopDefault({ preserveSelected: 1 }); - this.$el.on(motionsEv, this.udpateOffset); + noChanges ? this.udpateOffset() : this.$el.on(motionsEv, this.udpateOffset); }, udpateOffset() { @@ -51,8 +57,7 @@ module.exports = require('backbone').View.extend({ }, render() { - this.$el.attr({class: this.ppfx + 'frame'}); + this.$el.attr({ class: this.ppfx + 'frame' }); return this; - }, - + } }); diff --git a/src/code_manager/config/config.js b/src/code_manager/config/config.js index 215b6c02e..c6b41a11d 100644 --- a/src/code_manager/config/config.js +++ b/src/code_manager/config/config.js @@ -2,5 +2,5 @@ module.exports = { // Style prefix stylePrefix: 'cm-', - inlineCss: false, + inlineCss: false }; diff --git a/src/code_manager/index.js b/src/code_manager/index.js index 32beeada4..05ed2c764 100644 --- a/src/code_manager/index.js +++ b/src/code_manager/index.js @@ -18,23 +18,21 @@ * @module CodeManager */ module.exports = () => { - var c = {}, - defaults = require('./config/config'), - gHtml = require('./model/HtmlGenerator'), - gCss = require('./model/CssGenerator'), - gJson = require('./model/JsonGenerator'), - gJs = require('./model/JsGenerator'), - eCM = require('./model/CodeMirrorEditor'), - editorView = require('./view/EditorView'); + defaults = require('./config/config'), + gHtml = require('./model/HtmlGenerator'), + gCss = require('./model/CssGenerator'), + gJson = require('./model/JsonGenerator'), + gJs = require('./model/JsGenerator'), + eCM = require('./model/CodeMirrorEditor'), + editorView = require('./view/EditorView'); var generators = {}, - defGenerators = {}, - viewers = {}, - defViewers = {}; + defGenerators = {}, + viewers = {}, + defViewers = {}; return { - getConfig() { return c; }, @@ -57,16 +55,14 @@ module.exports = () => { init(config) { c = config || {}; for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } var ppfx = c.pStylePrefix; - if(ppfx) - c.stylePrefix = ppfx + c.stylePrefix; + if (ppfx) c.stylePrefix = ppfx + c.stylePrefix; defGenerators.html = new gHtml(); - defGenerators.css = new gCss(); + defGenerators.css = new gCss(); defGenerators.json = new gJson(); defGenerators.js = new gJs(); defViewers.CodeMirror = new eCM(); @@ -183,7 +179,7 @@ module.exports = () => { * */ getCode(model, genId, opt = {}) { opt.em = c.em; - var generator = this.getGenerator(genId); + var generator = this.getGenerator(genId); return generator ? generator.build(model, opt) : ''; }, @@ -193,8 +189,7 @@ module.exports = () => { * @private * */ loadDefaultGenerators() { - for (var id in defGenerators) - this.addGenerator(id, defGenerators[id]); + for (var id in defGenerators) this.addGenerator(id, defGenerators[id]); return this; }, @@ -205,12 +200,9 @@ module.exports = () => { * @private * */ loadDefaultViewers() { - for (var id in defViewers) - this.addViewer(id, defViewers[id]); + for (var id in defViewers) this.addViewer(id, defViewers[id]); return this; - }, - + } }; - }; diff --git a/src/code_manager/model/CodeMirrorEditor.js b/src/code_manager/model/CodeMirrorEditor.js index eb5207612..045f65f2b 100644 --- a/src/code_manager/model/CodeMirrorEditor.js +++ b/src/code_manager/model/CodeMirrorEditor.js @@ -5,23 +5,22 @@ var cssMode = require('codemirror/mode/css/css'); var formatting = require('codemirror-formatting'); module.exports = Backbone.Model.extend({ - defaults: { - input : '', - label : '', - codeName : '', - theme : '', - readOnly : true, - lineNumbers : true, + input: '', + label: '', + codeName: '', + theme: '', + readOnly: true, + lineNumbers: true }, /** @inheritdoc */ init(el) { - this.editor = CodeMirror.fromTextArea(el, { + this.editor = CodeMirror.fromTextArea(el, { dragDrop: false, lineWrapping: true, mode: this.get('codeName'), - ...this.attributes, + ...this.attributes }); return this; @@ -29,14 +28,15 @@ module.exports = Backbone.Model.extend({ /** @inheritdoc */ setContent(v) { - if(!this.editor) - return; + if (!this.editor) return; this.editor.setValue(v); - if(this.editor.autoFormatRange){ + if (this.editor.autoFormatRange) { CodeMirror.commands.selectAll(this.editor); - this.editor.autoFormatRange(this.editor.getCursor(true), this.editor.getCursor(false) ); + this.editor.autoFormatRange( + this.editor.getCursor(true), + this.editor.getCursor(false) + ); CodeMirror.commands.goDocStart(this.editor); } - }, - + } }); diff --git a/src/code_manager/model/CssGenerator.js b/src/code_manager/model/CssGenerator.js index 1c0ddf6a8..37872a91e 100644 --- a/src/code_manager/model/CssGenerator.js +++ b/src/code_manager/model/CssGenerator.js @@ -1,5 +1,4 @@ module.exports = require('backbone').Model.extend({ - initialize() { this.compCls = []; this.ids = []; @@ -30,11 +29,10 @@ module.exports = require('backbone').Model.extend({ } const components = model.components(); - components.each(model => code += this.buildFromModel(model, opts)); + components.each(model => (code += this.buildFromModel(model, opts))); return code; }, - build(model, opts = {}) { const cssc = opts.cssc; this.em = opts.em || ''; @@ -67,13 +65,12 @@ module.exports = require('backbone').Model.extend({ for (let media in mediaRules) { let rulesStr = ''; const mRules = mediaRules[media]; - mRules.forEach(rule => rulesStr += this.buildFromRule(rule)); + mRules.forEach(rule => (rulesStr += this.buildFromRule(rule))); if (rulesStr) { code += `@media ${media}{${rulesStr}}`; } } - } return code; @@ -87,7 +84,7 @@ module.exports = require('backbone').Model.extend({ buildFromRule(rule) { let result = ''; const selectorStr = rule.selectorsToString(); - const selectorStrNoAdd = rule.selectorsToString({skipAdd: 1}); + const selectorStrNoAdd = rule.selectorsToString({ skipAdd: 1 }); let found; // This will not render a rule if there is no its component @@ -107,6 +104,5 @@ module.exports = require('backbone').Model.extend({ } return result; - }, - + } }); diff --git a/src/code_manager/model/HtmlGenerator.js b/src/code_manager/model/HtmlGenerator.js index d7087cbfa..84559412e 100644 --- a/src/code_manager/model/HtmlGenerator.js +++ b/src/code_manager/model/HtmlGenerator.js @@ -1,13 +1,13 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - build(model, opts = {}) { const models = model.get('components'); if (opts.exportWrapper) { - return opts.wrappesIsBody ? - `${this.buildModels(models)}` : model.toHTML(); + return opts.wrappesIsBody + ? `${this.buildModels(models)}` + : model.toHTML(); } return this.buildModels(models); @@ -20,5 +20,4 @@ module.exports = Backbone.Model.extend({ }); return code; } - }); diff --git a/src/code_manager/model/JsGenerator.js b/src/code_manager/model/JsGenerator.js index ac8a0d530..4c1116e7a 100644 --- a/src/code_manager/model/JsGenerator.js +++ b/src/code_manager/model/JsGenerator.js @@ -1,31 +1,30 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - mapModel(model) { var code = ''; - var script = model.get('script'); - var type = model.get('type'); - var comps = model.get('components'); + var script = model.get('script'); + var type = model.get('type'); + var comps = model.get('components'); var id = model.getId(); if (script) { // If the component has scripts we need to expose his ID var attr = model.get('attributes'); - attr = _.extend({}, attr, {id}); + attr = _.extend({}, attr, { id }); model.set('attributes', attr); var scrStr = model.getScriptString(); // If the script was updated, I'll put its code in a separate container if (model.get('scriptUpdated')) { - this.mapJs[type+'-'+id] = {ids: [id], code: scrStr}; + this.mapJs[type + '-' + id] = { ids: [id], code: scrStr }; } else { var mapType = this.mapJs[type]; - if(mapType) { + if (mapType) { mapType.ids.push(id); } else { - this.mapJs[type] = {ids: [id], code: scrStr}; + this.mapJs[type] = { ids: [id], code: scrStr }; } } } @@ -43,7 +42,7 @@ module.exports = Backbone.Model.extend({ var code = ''; - for(var type in this.mapJs) { + for (var type in this.mapJs) { var mapType = this.mapJs[type]; var ids = '#' + mapType.ids.join(', #'); code += ` @@ -53,8 +52,6 @@ module.exports = Backbone.Model.extend({ }`; } - return code; - }, - + } }); diff --git a/src/code_manager/model/JsonGenerator.js b/src/code_manager/model/JsonGenerator.js index 4085a3192..48dc5f737 100644 --- a/src/code_manager/model/JsonGenerator.js +++ b/src/code_manager/model/JsonGenerator.js @@ -1,26 +1,29 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - /** @inheritdoc */ build(model) { - var json = model.toJSON(); + var json = model.toJSON(); this.beforeEach(json); - _.each(json,function(v, attr){ - var obj = json[attr]; - if(obj instanceof Backbone.Model){ - json[attr] = this.build(obj); - }else if(obj instanceof Backbone.Collection){ - var coll = obj; - json[attr] = []; - if(coll.length){ - coll.each(function (el, index) { - json[attr][index] = this.build(el); - }, this); + _.each( + json, + function(v, attr) { + var obj = json[attr]; + if (obj instanceof Backbone.Model) { + json[attr] = this.build(obj); + } else if (obj instanceof Backbone.Collection) { + var coll = obj; + json[attr] = []; + if (coll.length) { + coll.each(function(el, index) { + json[attr][index] = this.build(el); + }, this); + } } - } - }, this); + }, + this + ); return json; }, @@ -32,5 +35,4 @@ module.exports = Backbone.Model.extend({ beforeEach(obj) { delete obj.status; } - }); diff --git a/src/code_manager/view/EditorView.js b/src/code_manager/view/EditorView.js index 679b8b564..e68fc2afa 100644 --- a/src/code_manager/view/EditorView.js +++ b/src/code_manager/view/EditorView.js @@ -1,7 +1,6 @@ var Backbone = require('backbone'); module.exports = Backbone.View.extend({ - template: _.template(`
<%= label %>
@@ -16,10 +15,9 @@ module.exports = Backbone.View.extend({ render() { var obj = this.model.toJSON(); obj.pfx = this.pfx; - this.$el.html( this.template(obj) ); + this.$el.html(this.template(obj)); this.$el.attr('class', this.pfx + 'editor-c'); - this.$el.find('#'+this.pfx+'code').append(this.model.get('input')); + this.$el.find('#' + this.pfx + 'code').append(this.model.get('input')); return this; - }, - + } }); diff --git a/src/commands/config/config.js b/src/commands/config/config.js index 23351446a..618ca5665 100644 --- a/src/commands/config/config.js +++ b/src/commands/config/config.js @@ -1,5 +1,4 @@ module.exports = { - ESCAPE_KEY: 27, stylePrefix: 'com-', @@ -19,5 +18,5 @@ module.exports = { minComponentH: 50, // Minimum width (in px) of component on creation - minComponentW: 50, + minComponentW: 50 }; diff --git a/src/commands/index.js b/src/commands/index.js index aa7ab7b5f..445a3f925 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -43,10 +43,10 @@ import { isFunction } from 'underscore'; module.exports = () => { let em; var c = {}, - commands = {}, - defaultCommands = {}, - defaults = require('./config/config'), - AbsCommands = require('./view/CommandAbstract'); + commands = {}, + defaultCommands = {}, + defaults = require('./config/config'), + AbsCommands = require('./view/CommandAbstract'); // Need it here as it would be used below var add = function(id, obj) { @@ -60,7 +60,6 @@ module.exports = () => { }; return { - /** * Name of the module * @type {String} @@ -76,19 +75,16 @@ module.exports = () => { init(config) { c = config || {}; for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } em = c.em; var ppfx = c.pStylePrefix; - if(ppfx) - c.stylePrefix = ppfx + c.stylePrefix; + if (ppfx) c.stylePrefix = ppfx + c.stylePrefix; // Load commands passed via configuration - for( var k in c.defaults) { + for (var k in c.defaults) { var obj = c.defaults[k]; - if(obj.id) - this.add(obj.id, obj); + if (obj.id) this.add(obj.id, obj); } const ViewCode = require('./view/ExportTemplate'); @@ -117,42 +113,55 @@ module.exports = () => { run(ed) { var sel = ed.getSelected(); - if(!sel || !sel.get('removable')) { + if (!sel || !sel.get('removable')) { console.warn('The element is not removable'); return; } ed.select(null); sel.destroy(); - }, + } }; defaultCommands['tlb-clone'] = { run(ed) { var sel = ed.getSelected(); - if(!sel || !sel.get('copyable')) { + if (!sel || !sel.get('copyable')) { console.warn('The element is not clonable'); return; } var collection = sel.collection; var index = collection.indexOf(sel); - collection.add(sel.clone(), {at: index + 1}); - sel.emitUpdate() - }, + const added = collection.add(sel.clone(), { at: index + 1 }); + sel.emitUpdate(); + ed.trigger('component:clone', added); + } }; defaultCommands['tlb-move'] = { run(ed, sender, opts) { - var sel = ed.getSelected(); - var dragger; + let dragger; + const em = ed.getModel(); + const event = opts && opts.event; + const sel = ed.getSelected(); + const toolbarStyle = ed.Canvas.getToolbarEl().style; + const nativeDrag = event.type == 'dragstart'; + + const hideTlb = () => { + toolbarStyle.display = 'none'; + em.stopDefault(); + }; - if(!sel || !sel.get('draggable')) { + if (!sel || !sel.get('draggable')) { console.warn('The element is not draggable'); return; } + // Without setTimeout the ghost image disappears + nativeDrag ? setTimeout(() => hideTlb, 0) : hideTlb(); + const onStart = (e, opts) => { console.log('start mouse pos ', opts.start); console.log('el rect ', opts.elRect); @@ -163,8 +172,8 @@ module.exports = () => { const onEnd = (e, opts) => { em.runDefault(); - em.set('selectedComponent', sel); - sel.emitUpdate() + em.setSelected(sel); + sel.emitUpdate(); dragger && dragger.blur(); }; @@ -173,31 +182,30 @@ module.exports = () => { console.log('Current ', opts.current); }; - var toolbarEl = ed.Canvas.getToolbarEl(); - toolbarEl.style.display = 'none'; - var em = ed.getModel(); - em.stopDefault(); - if (em.get('designerMode')) { // TODO move grabbing func in editor/canvas from the Sorter dragger = editor.runCommand('drag', { el: sel.view.el, options: { - event: opts && opts.event, + event, onStart, onDrag, onEnd } }); } else { - var cmdMove = ed.Commands.get('move-comp'); + if (nativeDrag) { + event.dataTransfer.setDragImage(sel.view.el, 0, 0); + //sel.set('status', 'freezed'); + } + + const cmdMove = ed.Commands.get('move-comp'); cmdMove.onEndMoveFromModel = onEnd; cmdMove.initSorterFromModel(sel); } - sel.set('status', 'selected'); - }, + } }; // Core commands @@ -227,10 +235,9 @@ module.exports = () => { } }; - if(c.em) - c.model = c.em.get('Canvas'); + if (c.em) c.model = c.em.get('Canvas'); - this.loadDefaultCommands() + this.loadDefaultCommands(); return this; }, @@ -266,9 +273,9 @@ module.exports = () => { get(id) { var el = commands[id]; - if(typeof el == 'function'){ + if (typeof el == 'function') { el = new el(c); - commands[id] = el; + commands[id] = el; } return el; @@ -290,11 +297,10 @@ module.exports = () => { * */ loadDefaultCommands() { for (var id in defaultCommands) { - this.add(id, defaultCommands[id]); + this.add(id, defaultCommands[id]); } return this; - }, + } }; - }; diff --git a/src/commands/model/Command.js b/src/commands/model/Command.js index 801af11b9..a6fcb3639 100644 --- a/src/commands/model/Command.js +++ b/src/commands/model/Command.js @@ -1,9 +1,7 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - - defaults :{ - id: '', + defaults: { + id: '' } - }); diff --git a/src/commands/model/Commands.js b/src/commands/model/Commands.js index 1313b3e5f..a2036bf9b 100644 --- a/src/commands/model/Commands.js +++ b/src/commands/model/Commands.js @@ -2,7 +2,5 @@ var Backbone = require('backbone'); var Command = require('./Command'); module.exports = Backbone.Collection.extend({ - - model: Command, - + model: Command }); diff --git a/src/commands/view/CommandAbstract.js b/src/commands/view/CommandAbstract.js index 8c615b8e8..b49a4cd4b 100644 --- a/src/commands/view/CommandAbstract.js +++ b/src/commands/view/CommandAbstract.js @@ -1,28 +1,26 @@ -const $ = Backbone.$ +const $ = Backbone.$; module.exports = Backbone.View.extend({ - /** * Initialize method that can't be removed * @param {Object} o Options * @private * */ initialize(o) { - this.config = o || {}; - 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.config = o || {}; + 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'); - if(this.em.get) - this.setElement(this.getCanvas()); + if (this.em.get) this.setElement(this.getCanvas()); - if(this.canvas){ + if (this.canvas) { this.$canvas = this.$el; this.$wrapper = $(this.getCanvasWrapper()); this.frameEl = this.canvas.getFrameEl(); @@ -106,6 +104,5 @@ module.exports = Backbone.View.extend({ * @param {Object} sender Button sender * @private * */ - stop(em, sender) {}, - + stop(em, sender) {} }); diff --git a/src/commands/view/CreateComponent.js b/src/commands/view/CreateComponent.js index bb6e6d5fb..99438a2a5 100644 --- a/src/commands/view/CreateComponent.js +++ b/src/commands/view/CreateComponent.js @@ -2,9 +2,8 @@ const SelectPosition = require('./SelectPosition'); const $ = Backbone.$; module.exports = _.extend({}, SelectPosition, { - init(opt) { - _.bindAll(this,'startDraw','draw','endDraw','rollback'); + _.bindAll(this, 'startDraw', 'draw', 'endDraw', 'rollback'); this.config = opt || {}; this.hType = this.config.newFixedH ? 'height' : 'min-height'; this.allowDraw = 1; @@ -16,9 +15,8 @@ module.exports = _.extend({}, SelectPosition, { * */ enable(...args) { SelectPosition.enable.apply(this, args); - this.$wr.css('cursor','crosshair'); - if(this.allowDraw) - this.$wr.on('mousedown', this.startDraw); + this.$wr.css('cursor', 'crosshair'); + if (this.allowDraw) this.$wr.on('mousedown', this.startDraw); this.ghost = this.canvas.getGhostEl(); }, @@ -33,11 +31,11 @@ module.exports = _.extend({}, SelectPosition, { this.ghost.style.display = 'block'; this.frameOff = this.getOffsetDim(); this.startPos = { - top : e.pageY + this.frameOff.top, + top: e.pageY + this.frameOff.top, left: e.pageX + this.frameOff.left }; this.isDragged = false; - this.tempComponent = {style: {}}; + this.tempComponent = { style: {} }; this.beforeDraw(this.tempComponent); this.updateSize(this.startPos.top, this.startPos.left, 0, 0); this.toggleEvents(1); @@ -75,11 +73,16 @@ module.exports = _.extend({}, SelectPosition, { this.toggleEvents(); var model = {}; // Only if the mouse was moved - if(this.isDragged){ + if (this.isDragged) { this.updateComponentSize(e); this.setRequirements(this.tempComponent); var lp = this.sorter.lastPos; - model = this.create(this.sorter.target, this.tempComponent, lp.index, lp.method); + model = this.create( + this.sorter.target, + this.tempComponent, + lp.index, + lp.method + ); this.sorter.prevTarget = null; } this.ghost.style.display = 'none'; @@ -103,10 +106,8 @@ module.exports = _.extend({}, SelectPosition, { var trgCollection = $trg.data('collection'); var droppable = trgModel ? trgModel.get('droppable') : 1; opt.at = index; - if(trgCollection && droppable) - return trgCollection.add(component, opt); - else - console.warn("Invalid target position"); + if (trgCollection && droppable) return trgCollection.add(component, opt); + else console.warn('Invalid target position'); }, /** @@ -116,29 +117,29 @@ module.exports = _.extend({}, SelectPosition, { * @private * */ setRequirements(component) { - var c = this.config; + var c = this.config; var compStl = component.style; // Check min width - if(compStl.width.replace(/\D/g,'') < c.minComponentW) - compStl.width = c.minComponentW +'px'; + if (compStl.width.replace(/\D/g, '') < c.minComponentW) + compStl.width = c.minComponentW + 'px'; // Check min height - if(compStl[this.hType].replace(/\D/g,'') < c.minComponentH) - compStl[this.hType] = c.minComponentH +'px'; + if (compStl[this.hType].replace(/\D/g, '') < c.minComponentH) + compStl[this.hType] = c.minComponentH + 'px'; // Set overflow in case of fixed height - if(c.newFixedH) - compStl.overflow = 'auto'; - if(!this.absoluteMode){ + if (c.newFixedH) compStl.overflow = 'auto'; + if (!this.absoluteMode) { delete compStl.left; delete compStl.top; - }else - compStl.position = 'absolute'; + } else compStl.position = 'absolute'; var lp = this.sorter.lastPos; - if(this.nearFloat(lp.index, lp.method, this.sorter.lastDims)) + if (this.nearFloat(lp.index, lp.method, this.sorter.lastDims)) compStl.float = 'left'; - if(this.config.firstCentered && - this.getCanvasWrapper() == this.sorter.target){ + if ( + this.config.firstCentered && + this.getCanvasWrapper() == this.sorter.target + ) { compStl.margin = '0 auto'; } @@ -152,12 +153,12 @@ module.exports = _.extend({}, SelectPosition, { * */ updateComponentSize(e) { var y = e.pageY + this.frameOff.top; - var x = e.pageX + this.frameOff.left; + var x = e.pageX + this.frameOff.left; var start = this.startPos; var top = start.top; var left = start.left; var height = y - top; - var width = x - left; + var width = x - left; if (x < left) { left = x; width = start.left - x; @@ -180,7 +181,7 @@ module.exports = _.extend({}, SelectPosition, { ghStl.top = compStl.top = top + u; ghStl.left = compStl.left = left + u; ghStl.width = compStl.width = width + u; - ghStl[this.hType] = compStl[this.hType] = height + u; + ghStl[this.hType] = compStl[this.hType] = height + u; }, /** @@ -191,7 +192,7 @@ module.exports = _.extend({}, SelectPosition, { * */ rollback(e, force) { var key = e.which || e.keyCode; - if(key == this.config.ESCAPE_KEY || force){ + if (key == this.config.ESCAPE_KEY || force) { this.isDragged = false; this.endDraw(); } @@ -204,7 +205,7 @@ module.exports = _.extend({}, SelectPosition, { * @private * */ beforeDraw(component) { - component.editable = false;//set this component editable + component.editable = false; //set this component editable }, /** @@ -214,17 +215,16 @@ module.exports = _.extend({}, SelectPosition, { * */ afterDraw(model) {}, - run(editor, sender, opts) { this.editor = editor; - this.sender = sender; + this.sender = sender; this.$wr = this.$wrapper; this.enable(); }, stop() { this.stopSelectPosition(); - this.$wrapper.css('cursor',''); + this.$wrapper.css('cursor', ''); this.$wrapper.unbind(); } }); diff --git a/src/commands/view/DeleteComponent.js b/src/commands/view/DeleteComponent.js index dcdd304b3..a023bbc62 100644 --- a/src/commands/view/DeleteComponent.js +++ b/src/commands/view/DeleteComponent.js @@ -1,17 +1,17 @@ const SelectComponent = require('./SelectComponent'); const $ = Backbone.$; -module.exports = _.extend({},SelectComponent,{ - +module.exports = _.extend({}, SelectComponent, { init(o) { _.bindAll(this, 'startDelete', 'stopDelete', 'onDelete'); - this.hoverClass = this.pfx + 'hover-delete'; - this.badgeClass = this.pfx + 'badge-red'; + this.hoverClass = this.pfx + 'hover-delete'; + this.badgeClass = this.pfx + 'badge-red'; }, enable() { var that = this; - this.$el.find('*') + this.$el + .find('*') .mouseover(this.startDelete) .mouseout(this.stopDelete) .click(this.onDelete); @@ -23,15 +23,14 @@ module.exports = _.extend({},SelectComponent,{ * @private */ startDelete(e) { - e.stopPropagation(); - var $this = $(e.target); - - // Show badge if possible - if($this.data('model').get('removable')){ - $this.addClass(this.hoverClass); - this.attachBadge($this.get(0)); - } + e.stopPropagation(); + var $this = $(e.target); + // Show badge if possible + if ($this.data('model').get('removable')) { + $this.addClass(this.hoverClass); + this.attachBadge($this.get(0)); + } }, /** @@ -40,13 +39,12 @@ module.exports = _.extend({},SelectComponent,{ * @private */ stopDelete(e) { - e.stopPropagation(); - var $this = $(e.target); - $this.removeClass(this.hoverClass); + e.stopPropagation(); + var $this = $(e.target); + $this.removeClass(this.hoverClass); - // Hide badge if possible - if(this.badge) - this.badge.css({ left: -1000, top:-1000 }); + // Hide badge if possible + if (this.badge) this.badge.css({ left: -1000, top: -1000 }); }, /** @@ -59,8 +57,7 @@ module.exports = _.extend({},SelectComponent,{ var $this = $(e.target); // Do nothing in case can't remove - if(!$this.data('model').get('removable')) - return; + if (!$this.data('model').get('removable')) return; $this.data('model').destroy(); this.removeBadge(); @@ -73,7 +70,6 @@ module.exports = _.extend({},SelectComponent,{ * @private * */ updateBadgeLabel(model) { - this.badge.html( 'Remove ' + model.getName() ); - }, - + this.badge.html('Remove ' + model.getName()); + } }); diff --git a/src/commands/view/Drag.js b/src/commands/view/Drag.js index 567d56754..9906593dc 100644 --- a/src/commands/view/Drag.js +++ b/src/commands/view/Drag.js @@ -1,5 +1,4 @@ module.exports = { - run(editor, sender, opts) { var el = (opts && opts.el) || ''; var canvas = editor.Canvas; @@ -11,7 +10,7 @@ module.exports = { options.posFetcher = canvasView.getElementPos.bind(canvasView); // Create the resizer for the canvas if not yet created - if(!dragger) { + if (!dragger) { dragger = editor.Utils.Dragger.init(options); this.dragger = dragger; } @@ -27,8 +26,6 @@ module.exports = { }, stop() { - if(this.canvasResizer) - this.canvasResizer.blur(); - }, - + if (this.canvasResizer) this.canvasResizer.blur(); + } }; diff --git a/src/commands/view/ExportTemplate.js b/src/commands/view/ExportTemplate.js index 0d651f457..a5fda7243 100644 --- a/src/commands/view/ExportTemplate.js +++ b/src/commands/view/ExportTemplate.js @@ -1,7 +1,6 @@ const $ = Backbone.$; module.exports = { - run(editor, sender, opts = {}) { sender && sender.set && sender.set('active', 0); const config = editor.getConfig(); @@ -9,7 +8,6 @@ module.exports = { const pfx = config.stylePrefix; this.cm = editor.CodeManager || null; - if (!this.$editors) { const oHtmlEd = this.buildEditor('htmlmixed', 'hopscotch', 'HTML'); const oCsslEd = this.buildEditor('css', 'hopscotch', 'CSS'); @@ -40,7 +38,7 @@ module.exports = { label, codeName, theme, - input, + input }); const $el = new this.cm.EditorView({ @@ -51,5 +49,5 @@ module.exports = { el.init(input); return { el, $el }; - }, + } }; diff --git a/src/commands/view/Fullscreen.js b/src/commands/view/Fullscreen.js index 9a2baf054..7b650b8e4 100644 --- a/src/commands/view/Fullscreen.js +++ b/src/commands/view/Fullscreen.js @@ -5,10 +5,13 @@ module.exports = { */ isEnabled() { var d = document; - if(d.fullscreenElement || d.webkitFullscreenElement || d.mozFullScreenElement) + if ( + d.fullscreenElement || + d.webkitFullscreenElement || + d.mozFullScreenElement + ) return 1; - else - return 0; + else return 0; }, /** @@ -18,18 +21,15 @@ module.exports = { */ enable(el) { var pfx = ''; - if (el.requestFullscreen) - el.requestFullscreen(); + if (el.requestFullscreen) el.requestFullscreen(); else if (el.webkitRequestFullscreen) { pfx = 'webkit'; el.webkitRequestFullscreen(); - }else if (el.mozRequestFullScreen) { + } else if (el.mozRequestFullScreen) { pfx = 'moz'; el.mozRequestFullScreen(); - }else if (el.msRequestFullscreen) - el.msRequestFullscreen(); - else - console.warn('Fullscreen not supported'); + } else if (el.msRequestFullscreen) el.msRequestFullscreen(); + else console.warn('Fullscreen not supported'); return pfx; }, @@ -38,14 +38,10 @@ module.exports = { */ disable() { var d = document; - if (d.exitFullscreen) - d.exitFullscreen(); - else if (d.webkitExitFullscreen) - d.webkitExitFullscreen(); - else if (d.mozCancelFullScreen) - d.mozCancelFullScreen(); - else if (d.msExitFullscreen) - d.msExitFullscreen(); + if (d.exitFullscreen) d.exitFullscreen(); + else if (d.webkitExitFullscreen) d.webkitExitFullscreen(); + else if (d.mozCancelFullScreen) d.mozCancelFullScreen(); + else if (d.msExitFullscreen) d.msExitFullscreen(); }, /** @@ -53,11 +49,11 @@ module.exports = { * it's enabled * @param {strinf} pfx Browser prefix * @param {Event} e - */ + */ fsChanged(pfx, e) { var d = document; var ev = (pfx || '') + 'fullscreenchange'; - if(!this.isEnabled()){ + if (!this.isEnabled()) { this.stop(null, this.sender); document.removeEventListener(ev, this.fsChanged); } @@ -68,16 +64,12 @@ module.exports = { var pfx = this.enable(editor.getContainer()); this.fsChanged = this.fsChanged.bind(this, pfx); document.addEventListener(pfx + 'fullscreenchange', this.fsChanged); - if(editor) - editor.trigger('change:canvasOffset'); + if (editor) editor.trigger('change:canvasOffset'); }, stop(editor, sender) { - if(sender && sender.set) - sender.set('active', false); + if (sender && sender.set) sender.set('active', false); this.disable(); - if(editor) - editor.trigger('change:canvasOffset'); + if (editor) editor.trigger('change:canvasOffset'); } - }; diff --git a/src/commands/view/ImageComponent.js b/src/commands/view/ImageComponent.js index b1f064f6a..f150195d5 100644 --- a/src/commands/view/ImageComponent.js +++ b/src/commands/view/ImageComponent.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var InsertCustom = require('./InsertCustom'); module.exports = _.extend({}, InsertCustom, { - /** * Trigger before insert * @param {Object} object @@ -14,8 +13,10 @@ module.exports = _.extend({}, InsertCustom, { object.style = {}; object.attributes = {}; object.attributes.onmousedown = 'return false'; - if (this.config.firstCentered && - this.getCanvasWrapper() == this.sorter.target ) { + if ( + this.config.firstCentered && + this.getCanvasWrapper() == this.sorter.target + ) { object.style.margin = '0 auto'; } }, @@ -27,9 +28,6 @@ module.exports = _.extend({}, InsertCustom, { * */ afterInsert(model) { model.trigger('dblclick'); - if(this.sender) - this.sender.set('active', false); - }, - - + if (this.sender) this.sender.set('active', false); + } }); diff --git a/src/commands/view/InsertCustom.js b/src/commands/view/InsertCustom.js index 02bd7fa06..9a3d61ef9 100644 --- a/src/commands/view/InsertCustom.js +++ b/src/commands/view/InsertCustom.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var CreateComponent = require('./CreateComponent'); module.exports = _.extend({}, CreateComponent, { - init(...args) { CreateComponent.init.apply(this, args); _.bindAll(this, 'insertComponent'); @@ -37,15 +36,15 @@ module.exports = _.extend({}, CreateComponent, { this.beforeInsert(object); var index = this.sorter.lastPos.index; // By default, collections do not trigger add event, so silent is used - var model = this.create(this.sorter.target, object, index, null, {silent: false}); + var model = this.create(this.sorter.target, object, index, null, { + silent: false + }); - if(this.opt.terminateAfterInsert && this.sender) + if (this.opt.terminateAfterInsert && this.sender) this.sender.set('active', false); - else - this.enable(); + else this.enable(); - if(!model) - return; + if (!model) return; this.afterInsert(model, this); }, @@ -72,5 +71,5 @@ module.exports = _.extend({}, CreateComponent, { * */ buildContent() { return this.opt.content || {}; - }, + } }); diff --git a/src/commands/view/MoveComponent.js b/src/commands/view/MoveComponent.js index 18872627b..219072acb 100644 --- a/src/commands/view/MoveComponent.js +++ b/src/commands/view/MoveComponent.js @@ -1,18 +1,17 @@ -import {on, off} from 'utils/mixins' +import { on, off } from 'utils/mixins'; const SelectComponent = require('./SelectComponent'); const SelectPosition = require('./SelectPosition'); const $ = Backbone.$; module.exports = _.extend({}, SelectPosition, SelectComponent, { - init(o) { SelectComponent.init.apply(this, arguments); - _.bindAll(this, 'initSorter','rollback', 'onEndMove'); + _.bindAll(this, 'initSorter', 'rollback', 'onEndMove'); this.opt = o; - this.hoverClass = this.ppfx + 'highlighter-warning'; - this.badgeClass = this.ppfx + 'badge-warning'; - this.noSelClass = this.ppfx + 'no-select'; + this.hoverClass = this.ppfx + 'highlighter-warning'; + this.badgeClass = this.ppfx + 'badge-warning'; + this.noSelClass = this.ppfx + 'no-select'; }, enable(...args) { @@ -20,7 +19,7 @@ module.exports = _.extend({}, SelectPosition, SelectComponent, { this.getBadgeEl().addClass(this.badgeClass); this.getHighlighterEl().addClass(this.hoverClass); var wp = this.$wrapper; - wp.css('cursor','move'); + wp.css('cursor', 'move'); wp.on('mousedown', this.initSorter); // Avoid strange moving behavior @@ -41,8 +40,7 @@ module.exports = _.extend({}, SelectPosition, SelectComponent, { initSorter(e) { var el = $(e.target).data('model'); var drag = el.get('draggable'); - if(!drag) - return; + if (!drag) return; // Avoid badge showing on move this.cacheEl = null; @@ -61,8 +59,7 @@ module.exports = _.extend({}, SelectPosition, SelectComponent, { */ initSorterFromModel(model) { var drag = model.get('draggable'); - if(!drag) - return; + if (!drag) return; // Avoid badge showing on move this.cacheEl = null; var el = model.view.el; @@ -111,7 +108,7 @@ module.exports = _.extend({}, SelectPosition, SelectComponent, { * */ rollback(e, force) { var key = e.which || e.keyCode; - if(key == this.opt.ESCAPE_KEY || force){ + if (key == this.opt.ESCAPE_KEY || force) { this.sorter.moved = false; this.sorter.endMove(); } @@ -124,8 +121,7 @@ module.exports = _.extend({}, SelectPosition, SelectComponent, { * @private */ getBadgeEl() { - if(!this.$badge) - this.$badge = $(this.getBadge()); + if (!this.$badge) this.$badge = $(this.getBadge()); return this.$badge; }, @@ -135,8 +131,7 @@ module.exports = _.extend({}, SelectPosition, SelectComponent, { * @private */ getHighlighterEl() { - if(!this.$hl) - this.$hl = $(this.canvas.getHighlighter()); + if (!this.$hl) this.$hl = $(this.canvas.getHighlighter()); return this.$hl; }, @@ -145,6 +140,9 @@ module.exports = _.extend({}, SelectPosition, SelectComponent, { this.getBadgeEl().removeClass(this.badgeClass); this.getHighlighterEl().removeClass(this.hoverClass); var wp = this.$wrapper; - wp.css('cursor', '').unbind().removeClass(this.noSelClass); + wp + .css('cursor', '') + .unbind() + .removeClass(this.noSelClass); } }); diff --git a/src/commands/view/OpenAssets.js b/src/commands/view/OpenAssets.js index 4f9984e11..179c08976 100644 --- a/src/commands/view/OpenAssets.js +++ b/src/commands/view/OpenAssets.js @@ -1,5 +1,4 @@ module.exports = { - run(editor, sender, opts = {}) { const modal = editor.Modal; const am = editor.AssetManager; @@ -12,15 +11,12 @@ module.exports = { am.onSelect(opts.onSelect); if (!this.rendered) { - am.render(am.getAll().filter( - asset => asset.get('type') == 'image' - )); + am.render(am.getAll().filter(asset => asset.get('type') == 'image')); this.rendered = 1; } modal.setTitle(title); modal.setContent(am.getContainer()); modal.open(); - }, - + } }; diff --git a/src/commands/view/OpenBlocks.js b/src/commands/view/OpenBlocks.js index 8abb5d871..a4ae5f721 100644 --- a/src/commands/view/OpenBlocks.js +++ b/src/commands/view/OpenBlocks.js @@ -1,5 +1,4 @@ module.exports = { - run(editor, sender) { const bm = editor.BlockManager; const pn = editor.Panels; @@ -8,7 +7,7 @@ module.exports = { bm.render(); const id = 'views-container'; const blocks = document.createElement('div'); - const panels = pn.getPanel(id) || pn.addPanel({id}); + const panels = pn.getPanel(id) || pn.addPanel({ id }); blocks.appendChild(bm.getContainer()); panels.set('appendContent', blocks).trigger('change:appendContent'); this.blocks = blocks; diff --git a/src/commands/view/OpenLayers.js b/src/commands/view/OpenLayers.js index e51185b5b..a47d2c55e 100644 --- a/src/commands/view/OpenLayers.js +++ b/src/commands/view/OpenLayers.js @@ -2,7 +2,6 @@ const Layers = require('navigator'); const $ = Backbone.$; module.exports = { - run(em, sender) { if (!this.toAppend) { var collection = em.DomComponents.getComponent().get('components'); @@ -13,14 +12,13 @@ module.exports = { config.layers.stylePrefix = config.stylePrefix + lyStylePfx; config.layers.pStylePrefix = config.stylePrefix; - config.layers.em = em.editor; + config.layers.em = em.editor; config.layers.opened = em.editor.get('opened'); // Check if panel exists otherwise crate it - if(!panels.getPanel('views-container')) - this.panel = panels.addPanel({id: 'views-container'}); - else - this.panel = panels.getPanel('views-container'); + if (!panels.getPanel('views-container')) + this.panel = panels.addPanel({ id: 'views-container' }); + else this.panel = panels.getPanel('views-container'); const toAppend = $(`
`); this.panel.set('appendContent', toAppend).trigger('change:appendContent'); diff --git a/src/commands/view/OpenStyleManager.js b/src/commands/view/OpenStyleManager.js index 2976e120f..87869a786 100644 --- a/src/commands/view/OpenStyleManager.js +++ b/src/commands/view/OpenStyleManager.js @@ -3,12 +3,11 @@ const Backbone = require('backbone'); const $ = Backbone.$; module.exports = { - run(em, sender) { - this.sender = sender; + this.sender = sender; if (!this.$cn) { - var config = em.getConfig(), - panels = em.Panels; + var config = em.getConfig(), + panels = em.Panels; // Main container this.$cn = $('
'); // Secondary container @@ -17,34 +16,36 @@ module.exports = { // Device Manager var dvm = em.DeviceManager; - if(dvm && config.showDevices){ - var devicePanel = panels.addPanel({ id: 'devices-c'}); - devicePanel.set('appendContent', dvm.render()).trigger('change:appendContent'); + if (dvm && config.showDevices) { + var devicePanel = panels.addPanel({ id: 'devices-c' }); + devicePanel + .set('appendContent', dvm.render()) + .trigger('change:appendContent'); } // Class Manager container var clm = em.SelectorManager; - if(clm) - this.$cn2.append(clm.render([])); + if (clm) this.$cn2.append(clm.render([])); this.$cn2.append(em.StyleManager.render()); var smConfig = em.StyleManager.getConfig(); const pfx = smConfig.stylePrefix; // Create header - this.$header = $(`
${smConfig.textNoElement}
`); + this.$header = $( + `
${smConfig.textNoElement}
` + ); this.$cn.append(this.$header); // Create panel if not exists - if(!panels.getPanel('views-container')) - this.panel = panels.addPanel({ id: 'views-container'}); - else - this.panel = panels.getPanel('views-container'); + if (!panels.getPanel('views-container')) + this.panel = panels.addPanel({ id: 'views-container' }); + else this.panel = panels.getPanel('views-container'); // Add all containers to the panel this.panel.set('appendContent', this.$cn).trigger('change:appendContent'); this.target = em.editor; - this.listenTo( this.target ,'change:selectedComponent', this.toggleSm); + this.listenTo(this.target, 'change:selectedComponent', this.toggleSm); } this.toggleSm(); }, @@ -54,24 +55,23 @@ module.exports = { * @private */ toggleSm() { - if(!this.sender.get('active')) - return; - if(this.target.get('selectedComponent')){ - this.$cn2.show(); - this.$header.hide(); - }else{ - this.$cn2.hide(); - this.$header.show(); - } + const sender = this.sender; + if (sender && sender.get && !sender.get('active')) return; + + if (this.target.get('selectedComponent')) { + this.$cn2.show(); + this.$header.hide(); + } else { + this.$cn2.hide(); + this.$header.show(); + } }, stop() { // Hide secondary container if exists - if(this.$cn2) - this.$cn2.hide(); + if (this.$cn2) this.$cn2.hide(); // Hide header container if exists - if(this.$header) - this.$header.hide(); + if (this.$header) this.$header.hide(); } }; diff --git a/src/commands/view/OpenTraitManager.js b/src/commands/view/OpenTraitManager.js index 3c9a92ab9..fe72334c3 100644 --- a/src/commands/view/OpenTraitManager.js +++ b/src/commands/view/OpenTraitManager.js @@ -1,24 +1,28 @@ const $ = Backbone.$; module.exports = { - run(editor, sender) { var config = editor.Config; var pfx = config.stylePrefix; var tm = editor.TraitManager; var panelC; - if(!this.obj){ + if (!this.obj) { var tmView = tm.getTraitsViewer(); var confTm = tm.getConfig(); this.obj = $('
') - .append('
' + confTm.labelContainer + '
') - .get(0); + .append( + '
' + + confTm.labelContainer + + '
' + ) + .get(0); this.obj.appendChild(tmView.render().el); var panels = editor.Panels; - if(!panels.getPanel('views-container')) - panelC = panels.addPanel({id: 'views-container'}); - else - panelC = panels.getPanel('views-container'); + if (!panels.getPanel('views-container')) + panelC = panels.addPanel({ id: 'views-container' }); + else panelC = panels.getPanel('views-container'); panelC.set('appendContent', this.obj).trigger('change:appendContent'); } @@ -26,7 +30,6 @@ module.exports = { }, stop() { - if(this.obj) - this.obj.style.display = 'none'; + if (this.obj) this.obj.style.display = 'none'; } }; diff --git a/src/commands/view/Preview.js b/src/commands/view/Preview.js index 008283a64..4a878dc22 100644 --- a/src/commands/view/Preview.js +++ b/src/commands/view/Preview.js @@ -1,21 +1,20 @@ module.exports = { - getPanels(editor) { - if(!this.panels) - this.panels = editor.Panels.getPanelsEl(); + if (!this.panels) this.panels = editor.Panels.getPanelsEl(); return this.panels; }, tglPointers(editor, v) { - var elP = editor.Canvas.getBody().querySelectorAll('.' + this.ppfx + 'no-pointer'); + var elP = editor.Canvas.getBody().querySelectorAll( + '.' + this.ppfx + 'no-pointer' + ); _.each(elP, item => { item.style.pointerEvents = v ? '' : 'all'; }); }, run(editor, sender) { - if(sender && sender.set) - sender.set('active', false); + if (sender && sender.set) sender.set('active', false); editor.stopCommand('sw-visibility'); editor.getModel().stopDefault(); var that = this; @@ -23,7 +22,7 @@ module.exports = { var canvas = editor.Canvas.getElement(); var editorEl = editor.getEl(); var pfx = editor.Config.stylePrefix; - if(!this.helper) { + if (!this.helper) { this.helper = document.createElement('span'); this.helper.className = pfx + 'off-prv fa fa-eye-slash'; editorEl.appendChild(this.helper); @@ -57,7 +56,7 @@ module.exports = { panels.style.display = 'block'; var canvas = editor.Canvas.getElement(); canvas.setAttribute('style', ''); - if(this.helper) { + if (this.helper) { this.helper.style.display = 'none'; } editor.trigger('change:canvasOffset'); diff --git a/src/commands/view/Resize.js b/src/commands/view/Resize.js index 99b49784a..a35becd63 100644 --- a/src/commands/view/Resize.js +++ b/src/commands/view/Resize.js @@ -1,5 +1,4 @@ module.exports = { - run(editor, sender, opts) { var opt = opts || {}; var el = opt.el || ''; @@ -14,7 +13,7 @@ module.exports = { options.mousePosFetcher = canvas.getMouseRelativePos; // Create the resizer for the canvas if not yet created - if(!canvasResizer || opt.forceNew) { + if (!canvasResizer || opt.forceNew) { this.canvasResizer = editor.Utils.Resizer.init(options); canvasResizer = this.canvasResizer; } @@ -27,6 +26,5 @@ module.exports = { stop() { const resizer = this.canvasResizer; resizer && resizer.blur(); - }, - + } }; diff --git a/src/commands/view/SelectComponent.js b/src/commands/view/SelectComponent.js index 996ca374a..90766c617 100644 --- a/src/commands/view/SelectComponent.js +++ b/src/commands/view/SelectComponent.js @@ -1,5 +1,5 @@ import { bindAll } from 'underscore'; -import { on, off, getUnitFromValue} from 'utils/mixins'; +import { on, off, getUnitFromValue } from 'utils/mixins'; const ToolbarView = require('dom_components/view/ToolbarView'); const Toolbar = require('dom_components/model/Toolbar'); @@ -8,15 +8,13 @@ const $ = require('backbone').$; let showOffsets; module.exports = { - init(o) { bindAll(this, 'onHover', 'onOut', 'onClick', 'onKeyPress', 'onFrameScroll'); }, - enable() { this.frameOff = this.canvasOff = this.adjScroll = null; - var config = this.config.em.get('Config'); + var config = this.config.em.get('Config'); this.startSelectComponent(); var em = this.config.em; showOffsets = 1; @@ -30,7 +28,7 @@ module.exports = { * @private * */ startSelectComponent() { - this.toggleSelectComponent(1); + this.toggleSelectComponent(1); }, /** @@ -38,7 +36,7 @@ module.exports = { * @private * */ stopSelectComponent() { - this.toggleSelectComponent(); + this.toggleSelectComponent(); }, /** @@ -48,7 +46,7 @@ module.exports = { toggleSelectComponent(enable) { const em = this.em; const method = enable ? 'on' : 'off'; - const methods = {on, off}; + const methods = { on, off }; const body = this.getCanvasBody(); const win = this.getContentWindow(); methods[method](body, 'mouseover', this.onHover); @@ -69,13 +67,11 @@ module.exports = { var focused = this.frameEl.contentDocument.activeElement.tagName !== 'BODY'; // On CANC (46) or Backspace (8) - if(key == 8 || key == 46) { - if(!focused) - e.preventDefault(); - if(comp && !focused) { - if(!comp.get('removable')) - return; - comp.set('status',''); + if (key == 8 || key == 46) { + if (!focused) e.preventDefault(); + if (comp && !focused) { + if (!comp.get('removable')) return; + comp.set('status', ''); comp.destroy(); this.hideBadge(); this.clean(); @@ -135,14 +131,13 @@ module.exports = { var $el = $(el); var model = $el.data('model'); - if ( (model && model.get('status') == 'selected') || - !showOffsets){ + if ((model && model.get('status') == 'selected') || !showOffsets) { return; } this.editor.runCommand('show-offset', { el, - elPos: pos, + elPos: pos }); }, @@ -164,7 +159,7 @@ module.exports = { this.editor.runCommand('show-offset', { el, elPos: pos, - state: 'Fixed', + state: 'Fixed' }); }, @@ -174,8 +169,7 @@ module.exports = { * @param {Object} pos */ hideFixedElementOffset(el, pos) { - if(this.editor) - this.editor.stopCommand('show-offset', {state: 'Fixed'}); + if (this.editor) this.editor.stopCommand('show-offset', { state: 'Fixed' }); }, /** @@ -199,7 +193,7 @@ module.exports = { if (model.get('selectable')) { editor.select(model); } else { - let parent = model.parent(); + let parent = model.parent(); while (parent && !parent.get('selectable')) parent = parent.parent(); parent && editor.select(parent); } @@ -218,9 +212,8 @@ module.exports = { var config = canvas.getConfig(); var customeLabel = config.customBadgeLabel; this.cacheEl = el; - var model = $el.data("model"); - if(!model || !model.get('badgable')) - return; + var model = $el.data('model'); + if (!model || !model.get('badgable')) return; var badge = this.getBadge(); var badgeLabel = model.getIcon() + model.getName(); badgeLabel = customeLabel ? customeLabel(model) : badgeLabel; @@ -231,7 +224,8 @@ module.exports = { var canvasPos = canvas.getCanvasView().getPosition(); var badgeH = badge ? badge.offsetHeight : 0; var badgeW = badge ? badge.offsetWidth : 0; - var top = pos.top - badgeH < canvasPos.top ? canvasPos.top : pos.top - badgeH; + var top = + pos.top - badgeH < canvasPos.top ? canvasPos.top : pos.top - badgeH; var left = pos.left + badgeW < canvasPos.left ? canvasPos.left : pos.left; bStyle.top = top + u; bStyle.left = left + u; @@ -247,7 +241,11 @@ module.exports = { var $el = $(el); var model = $el.data('model'); - if(!model || !model.get("hoverable") || model.get('status') == 'selected') { + if ( + !model || + !model.get('hoverable') || + model.get('status') == 'selected' + ) { return; } @@ -302,15 +300,17 @@ module.exports = { var toggleBodyClass = (method, e, opts) => { const docs = opts.docs; - docs && docs.forEach(doc => { - const body = doc.body; - const cls = body.className || ''; - body.className = (method == 'add' ? - `${cls} ${resizeClass}` : cls.replace(resizeClass, '')).trim(); - }); + docs && + docs.forEach(doc => { + const body = doc.body; + const cls = body.className || ''; + body.className = (method == 'add' + ? `${cls} ${resizeClass}` + : cls.replace(resizeClass, '') + ).trim(); + }); }; - if (editor && resizable) { options = { // Here the resizer is updated with the current element height and width @@ -322,7 +322,8 @@ module.exports = { const computedStyle = getComputedStyle(el); const modelStyle = modelToStyle.getStyle(); const currentWidth = modelStyle[keyWidth] || computedStyle[keyWidth]; - const currentHeight = modelStyle[keyHeight] || computedStyle[keyHeight]; + const currentHeight = + modelStyle[keyHeight] || computedStyle[keyHeight]; resizer.startDim.w = parseFloat(currentWidth); resizer.startDim.h = parseFloat(currentHeight); showOffsets = 0; @@ -349,7 +350,7 @@ module.exports = { return; } - const { store, selectedHandler, config} = options; + const { store, selectedHandler, config } = options; const { keyHeight, keyWidth } = config; const onlyHeight = ['tc', 'bc'].indexOf(selectedHandler) >= 0; const onlyWidth = ['cl', 'cr'].indexOf(selectedHandler) >= 0; @@ -363,9 +364,12 @@ module.exports = { style[keyHeight] = rect.h + config.unitHeight; } - modelToStyle.setStyle(style, {avoidStore: 1}); + modelToStyle.setStyle(style, { avoidStore: 1 }); const updateEvent = `update:component:style`; - em && em.trigger(`${updateEvent}:${keyHeight} ${updateEvent}:${keyWidth}`); + em && + em.trigger( + `${updateEvent}:${keyHeight} ${updateEvent}:${keyWidth}` + ); if (store) { modelToStyle.trigger('change:style', modelToStyle, style, {}); @@ -377,7 +381,7 @@ module.exports = { options = { ...options, ...resizable }; } - editor.runCommand('resize', {el, options}); + editor.runCommand('resize', { el, options }); // On undo/redo the resizer rect is not updating, need somehow to call // this.updateRect on undo/redo action @@ -409,7 +413,7 @@ module.exports = { if (showToolbar && toolbar && toolbar.length) { toolbarStyle.opacity = ''; toolbarStyle.display = ''; - if(!this.toolbar) { + if (!this.toolbar) { toolbarEl.innerHTML = ''; this.toolbar = new Toolbar(toolbar); var toolbarView = new ToolbarView({ @@ -440,11 +444,11 @@ module.exports = { toolbarStyle.display = 'block'; var pos = this.canvas.getTargetToElementDim(toolbarEl, el, { elPos, - event: 'toolbarPosUpdate', + event: 'toolbarPosUpdate' }); var leftPos = pos.left + pos.elementWidth - pos.targetWidth; toolbarStyle.top = pos.top + unit; - toolbarStyle.left = leftPos + unit; + toolbarStyle.left = (leftPos < 0 ? 0 : leftPos) + unit; toolbarStyle.display = origDisp; }, @@ -461,8 +465,7 @@ module.exports = { * @private * */ clean() { - if(this.selEl) - this.selEl.removeClass(this.hoverClass); + if (this.selEl) this.selEl.removeClass(this.hoverClass); }, /** @@ -529,10 +532,11 @@ module.exports = { * @private */ cleanPrevious(model) { - model && model.set({ - status: '', - state: '', - }); + model && + model.set({ + status: '', + state: '' + }); }, /** diff --git a/src/commands/view/SelectParent.js b/src/commands/view/SelectParent.js index a40c3ee8f..ad6a74249 100644 --- a/src/commands/view/SelectParent.js +++ b/src/commands/view/SelectParent.js @@ -1,15 +1,13 @@ module.exports = { - run(editor) { const sel = editor.getSelected(); let comp = sel && sel.parent(); // Recurse through the parent() chain until a selectable parent is found - while (comp && !comp.get("selectable")) { + while (comp && !comp.get('selectable')) { comp = comp.parent(); } comp && editor.select(comp); } - }; diff --git a/src/commands/view/SelectPosition.js b/src/commands/view/SelectPosition.js index 1c103fb1d..fc3241524 100644 --- a/src/commands/view/SelectPosition.js +++ b/src/commands/view/SelectPosition.js @@ -1,7 +1,6 @@ const $ = Backbone.$; module.exports = { - /** * Start select position event * @param {HTMLElement} trg @@ -10,7 +9,7 @@ module.exports = { startSelectPosition(trg, doc) { this.isPointed = false; var utils = this.editorModel.get('Utils'); - if(utils && !this.sorter) + if (utils && !this.sorter) this.sorter = new utils.Sorter({ container: this.getCanvasBody(), placer: this.canvas.getPlacerEl(), @@ -22,7 +21,7 @@ module.exports = { wmargin: 1, nested: 1, em: this.editorModel, - canvasRelative: 1, + canvasRelative: 1 }); this.sorter.startSort(trg); }, @@ -46,17 +45,27 @@ module.exports = { * */ stopSelectPosition() { this.posTargetCollection = null; - this.posIndex = this.posMethod=='after' && this.cDim.length!==0 ? this.posIndex + 1 : this.posIndex; //Normalize - if(this.sorter){ + this.posIndex = + this.posMethod == 'after' && this.cDim.length !== 0 + ? this.posIndex + 1 + : this.posIndex; //Normalize + if (this.sorter) { this.sorter.moved = 0; this.sorter.endMove(); } - if(this.cDim){ - this.posIsLastEl = this.cDim.length!==0 && this.posMethod=='after' && this.posIndex==this.cDim.length; - this.posTargetEl = (this.cDim.length===0 ? $(this.outsideElem) : - (!this.posIsLastEl && this.cDim[this.posIndex] ? $(this.cDim[this.posIndex][5]).parent() : $(this.outsideElem) )); - this.posTargetModel = this.posTargetEl.data("model"); - this.posTargetCollection = this.posTargetEl.data("model-comp"); + if (this.cDim) { + this.posIsLastEl = + this.cDim.length !== 0 && + this.posMethod == 'after' && + this.posIndex == this.cDim.length; + this.posTargetEl = + this.cDim.length === 0 + ? $(this.outsideElem) + : !this.posIsLastEl && this.cDim[this.posIndex] + ? $(this.cDim[this.posIndex][5]).parent() + : $(this.outsideElem); + this.posTargetModel = this.posTargetEl.data('model'); + this.posTargetCollection = this.posTargetEl.data('model-comp'); } }, @@ -80,23 +89,24 @@ module.exports = { var i = index || 0; var m = method || 'before'; var len = dims.length; - var isLast = len !== 0 && m == 'after' && i == len; - if(len !== 0 && ( - (!isLast && !dims[i][4]) || - (dims[i-1] && !dims[i-1][4]) || - (isLast && !dims[i-1][4]) ) ) + var isLast = len !== 0 && m == 'after' && i == len; + if ( + len !== 0 && + ((!isLast && !dims[i][4]) || + (dims[i - 1] && !dims[i - 1][4]) || + (isLast && !dims[i - 1][4])) + ) return 1; return 0; }, - run() { this.enable(); }, stop() { this.stopSelectPosition(); - this.$wrapper.css('cursor',''); + this.$wrapper.css('cursor', ''); this.$wrapper.unbind(); } }; diff --git a/src/commands/view/ShowOffset.js b/src/commands/view/ShowOffset.js index d1f5b9849..b407092c8 100644 --- a/src/commands/view/ShowOffset.js +++ b/src/commands/view/ShowOffset.js @@ -1,7 +1,6 @@ const $ = Backbone.$; module.exports = { - getOffsetMethod(state) { var method = state || ''; return 'get' + method + 'OffsetViewerEl'; @@ -12,8 +11,10 @@ module.exports = { var state = opt.state || ''; var config = editor.getConfig(); - if (!config.showOffsets || - (!config.showOffsetsSelected && state == 'Fixed') ) { + if ( + !config.showOffsets || + (!config.showOffsetsSelected && state == 'Fixed') + ) { return; } @@ -36,7 +37,7 @@ module.exports = { var padL = this['padL' + state]; var padR = this['padR' + state]; - if(!this[stateVar]) { + if (!this[stateVar]) { var stateLow = state.toLowerCase(); var marginName = stateLow + 'margin-v'; var paddingName = stateLow + 'padding-v'; @@ -125,7 +126,7 @@ module.exports = { pbStyle.top = pos.top + pos.height - padBot + unit; pbStyle.left = posLeft + unit; - var padSideH = (pos.height - padBot - padTop) + unit; + var padSideH = pos.height - padBot - padTop + unit; var padSideT = pos.top + padTop + unit; plStyle.height = padSideH; plStyle.width = style.paddingLeft; @@ -146,6 +147,5 @@ module.exports = { var canvas = editor.Canvas; var offsetViewer = canvas[method](); offsetViewer.style.display = 'none'; - }, - + } }; diff --git a/src/commands/view/SwitchVisibility.js b/src/commands/view/SwitchVisibility.js index f2a067f12..82a7e771a 100644 --- a/src/commands/view/SwitchVisibility.js +++ b/src/commands/view/SwitchVisibility.js @@ -1,11 +1,9 @@ module.exports = { - run(ed) { ed.Canvas.getBody().className = this.ppfx + 'dashed'; }, stop(ed) { - ed.Canvas.getBody().className = ""; + ed.Canvas.getBody().className = ''; } - }; diff --git a/src/commands/view/TextComponent.js b/src/commands/view/TextComponent.js index f24022aa5..aafc9589a 100644 --- a/src/commands/view/TextComponent.js +++ b/src/commands/view/TextComponent.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var CreateComponent = require('./CreateComponent'); module.exports = _.extend({}, CreateComponent, { - /** * This event is triggered at the beginning of a draw operation * @param {Object} component Object component before creation @@ -10,8 +9,7 @@ module.exports = _.extend({}, CreateComponent, { * */ beforeDraw(component) { component.type = 'text'; - if(!component.style) - component.style = {}; + if (!component.style) component.style = {}; component.style.padding = '10px'; }, @@ -21,11 +19,8 @@ module.exports = _.extend({}, CreateComponent, { * @private * */ afterDraw(model) { - if(!model || !model.set) - return; + if (!model || !model.set) return; model.trigger('focus'); - if(this.sender) - this.sender.set('active', false); - }, - + if (this.sender) this.sender.set('active', false); + } }); diff --git a/src/css_composer/config/config.js b/src/css_composer/config/config.js index 421594aac..0ae4f356f 100644 --- a/src/css_composer/config/config.js +++ b/src/css_composer/config/config.js @@ -1,12 +1,10 @@ module.exports = { - // Style prefix stylePrefix: 'css-', // Custom CSS string to render on top - 'staticRules': '', + staticRules: '', // Default CSS style - rules: [], - + rules: [] }; diff --git a/src/css_composer/index.js b/src/css_composer/index.js index 2e4e1d9f0..d56683cc7 100644 --- a/src/css_composer/index.js +++ b/src/css_composer/index.js @@ -19,375 +19,352 @@ module.exports = () => { let em; var c = {}, - defaults = require('./config/config'), - CssRule = require('./model/CssRule'), - CssRules = require('./model/CssRules'), - CssRulesView = require('./view/CssRulesView'); + defaults = require('./config/config'), + CssRule = require('./model/CssRule'), + CssRules = require('./model/CssRules'), + CssRulesView = require('./view/CssRulesView'); const Selectors = require('selector_manager/model/Selectors'); const Selector = require('selector_manager/model/Selector'); var rules, rulesView; return { - - Selectors, - - /** - * Name of the module - * @type {String} - * @private - */ - name: 'CssComposer', - - /** - * Mandatory for the storage manager - * @type {String} - * @private - */ - storageKey() { - var keys = []; - var smc = (c.stm && c.stm.getConfig()) || {}; - if(smc.storeCss) - keys.push('css'); - if(smc.storeStyles) - keys.push('styles'); - return keys; - }, - - /** - * Initializes module. Automatically called with a new instance of the editor - * @param {Object} config Configurations - * @private - */ - init(config) { - c = config || {}; - for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; - } - - var ppfx = c.pStylePrefix; - if(ppfx) - c.stylePrefix = ppfx + c.stylePrefix; - - var elStyle = (c.em && c.em.config.style) || ''; - c.rules = elStyle || c.rules; - - c.sm = c.em; - em = c.em; - rules = new CssRules([], c); - rulesView = new CssRulesView({ - collection: rules, - config: c, - }); - return this; - }, - - /** - * On load callback - * @private - */ - onLoad() { - rules.add(c.rules); - }, - - - /** - * Do stuff after load - * @param {Editor} em - * @private - */ - postLoad(em) { - const ev = 'add remove'; - const rules = this.getAll(); - em.stopListening(rules, ev, this.handleChange); - em.listenTo(rules, ev, this.handleChange); - rules.each(rule => this.handleChange(rule)); - }, - - - /** - * Handle rule changes - * @private - */ - handleChange(model) { - const ev = 'change:style'; - const um = em.get('UndoManager'); - um && um.add(model); - const handleUpdates = em.handleUpdates.bind(em); - em.stopListening(model, ev, handleUpdates); - em.listenTo(model, ev, handleUpdates); - }, - - - /** - * Load data from the passed object, if the object is empty will try to fetch them - * autonomously from the storage manager. - * The fetched data will be added to the collection - * @param {Object} data Object of data to load - * @return {Object} Loaded rules - */ - load(data) { - var d = data || ''; - - if (!d && c.stm) { - d = c.em.getCacheLoad(); - } - - var obj = d.styles || ''; - - if(d.styles) { - try { - obj = JSON.parse(d.styles); - } catch (err) {} - } else if (d.css) { - obj = c.em.get('Parser').parseCss(d.css); + Selectors, + + /** + * Name of the module + * @type {String} + * @private + */ + name: 'CssComposer', + + /** + * Mandatory for the storage manager + * @type {String} + * @private + */ + storageKey() { + var keys = []; + var smc = (c.stm && c.stm.getConfig()) || {}; + if (smc.storeCss) keys.push('css'); + if (smc.storeStyles) keys.push('styles'); + return keys; + }, + + /** + * Initializes module. Automatically called with a new instance of the editor + * @param {Object} config Configurations + * @private + */ + init(config) { + c = config || {}; + for (var name in defaults) { + if (!(name in c)) c[name] = defaults[name]; + } + + var ppfx = c.pStylePrefix; + if (ppfx) c.stylePrefix = ppfx + c.stylePrefix; + + var elStyle = (c.em && c.em.config.style) || ''; + c.rules = elStyle || c.rules; + + c.sm = c.em; + em = c.em; + rules = new CssRules([], c); + rulesView = new CssRulesView({ + collection: rules, + config: c + }); + return this; + }, + + /** + * On load callback + * @private + */ + onLoad() { + rules.add(c.rules); + }, + + /** + * Do stuff after load + * @param {Editor} em + * @private + */ + postLoad(em) { + const ev = 'add remove'; + const rules = this.getAll(); + em.stopListening(rules, ev, this.handleChange); + em.listenTo(rules, ev, this.handleChange); + rules.each(rule => this.handleChange(rule)); + }, + + /** + * Handle rule changes + * @private + */ + handleChange(model) { + const ev = 'change:style'; + const um = em.get('UndoManager'); + um && um.add(model); + const handleUpdates = em.handleUpdates.bind(em); + em.stopListening(model, ev, handleUpdates); + em.listenTo(model, ev, handleUpdates); + }, + + /** + * Load data from the passed object, if the object is empty will try to fetch them + * autonomously from the storage manager. + * The fetched data will be added to the collection + * @param {Object} data Object of data to load + * @return {Object} Loaded rules + */ + load(data) { + var d = data || ''; + + if (!d && c.stm) { + d = c.em.getCacheLoad(); + } + + var obj = d.styles || ''; + + if (d.styles) { + try { + obj = JSON.parse(d.styles); + } catch (err) {} + } else if (d.css) { + obj = c.em.get('Parser').parseCss(d.css); + } + + if (obj) { + rules.reset(obj); + } + + return obj; + }, + + /** + * Store data to the selected storage + * @param {Boolean} noStore If true, won't store + * @return {Object} Data to store + */ + store(noStore) { + if (!c.stm) return; + var obj = {}; + var keys = this.storageKey(); + if (keys.indexOf('css') >= 0) obj.css = c.em.getCss(); + if (keys.indexOf('styles') >= 0) obj.styles = JSON.stringify(rules); + if (!noStore) c.stm.store(obj); + return obj; + }, + + /** + * Add new rule to the collection, if not yet exists with the same selectors + * @param {Array} selectors Array of selectors + * @param {String} state Css rule state + * @param {String} width For which device this style is oriented + * @param {Object} opts Other options for the rule + * @return {Model} + * @example + * var sm = editor.SelectorManager; + * var sel1 = sm.add('myClass1'); + * var sel2 = sm.add('myClass2'); + * var rule = cssComposer.add([sel1, sel2], 'hover'); + * rule.set('style', { + * width: '100px', + * color: '#fff', + * }); + * */ + add(selectors, state, width, opts) { + var s = state || ''; + var w = width || ''; + var opt = opts || {}; + var rule = this.get(selectors, s, w, opt); + if (rule) return rule; + else { + opt.state = s; + opt.mediaText = w; + opt.selectors = ''; + rule = new CssRule(opt, c); + rule.get('selectors').add(selectors); + rules.add(rule); + return rule; + } + }, + + /** + * Get the rule + * @param {Array} selectors Array of selectors + * @param {String} state Css rule state + * @param {String} width For which device this style is oriented + * @param {Object} ruleProps Other rule props + * @return {Model|null} + * @example + * var sm = editor.SelectorManager; + * var sel1 = sm.add('myClass1'); + * var sel2 = sm.add('myClass2'); + * var rule = cssComposer.get([sel1, sel2], 'hover'); + * // Update the style + * rule.set('style', { + * width: '300px', + * color: '#000', + * }); + * */ + get(selectors, state, width, ruleProps) { + var rule = null; + rules.each(m => { + if (rule) return; + if (m.compare(selectors, state, width, ruleProps)) rule = m; + }); + return rule; + }, + + /** + * Get the collection of rules + * @return {Collection} + * */ + getAll() { + return rules; + }, + + /** + * Remove all rules + * @return {this} + */ + clear() { + this.getAll().reset(); + return this; + }, + + /** + * Add a raw collection of rule objects + * This method overrides styles, in case, of already defined rule + * @param {Array} data Array of rule objects, eg . [{selectors: ['class1'], style: {....}}, ..] + * @param {Object} opts Options + * @return {Array} + * @private + */ + addCollection(data, opts = {}) { + var result = []; + var d = data instanceof Array ? data : [data]; + + for (var i = 0, l = d.length; i < l; i++) { + var rule = d[i] || {}; + if (!rule.selectors) continue; + var sm = c.em && c.em.get('SelectorManager'); + if (!sm) console.warn('Selector Manager not found'); + var sl = rule.selectors; + var sels = sl instanceof Array ? sl : [sl]; + var newSels = []; + + for (var j = 0, le = sels.length; j < le; j++) { + var selec = sm.add(sels[j]); + newSels.push(selec); } - if (obj) { - rules.reset(obj); - } + var modelExists = this.get(newSels, rule.state, rule.mediaText, rule); + var model = this.add(newSels, rule.state, rule.mediaText, rule); + var updateStyle = !modelExists || !opts.avoidUpdateStyle; + const style = rule.style || {}; - return obj; - }, - - /** - * Store data to the selected storage - * @param {Boolean} noStore If true, won't store - * @return {Object} Data to store - */ - store(noStore) { - if(!c.stm) - return; - var obj = {}; - var keys = this.storageKey(); - if(keys.indexOf('css') >= 0) - obj.css = c.em.getCss(); - if(keys.indexOf('styles') >= 0) - obj.styles = JSON.stringify(rules); - if(!noStore) - c.stm.store(obj); - return obj; - }, - - /** - * Add new rule to the collection, if not yet exists with the same selectors - * @param {Array} selectors Array of selectors - * @param {String} state Css rule state - * @param {String} width For which device this style is oriented - * @param {Object} opts Other options for the rule - * @return {Model} - * @example - * var sm = editor.SelectorManager; - * var sel1 = sm.add('myClass1'); - * var sel2 = sm.add('myClass2'); - * var rule = cssComposer.add([sel1, sel2], 'hover'); - * rule.set('style', { - * width: '100px', - * color: '#fff', - * }); - * */ - add(selectors, state, width, opts) { - var s = state || ''; - var w = width || ''; - var opt = opts || {}; - var rule = this.get(selectors, s, w, opt); - if(rule) - return rule; - else { - opt.state = s; - opt.mediaText = w; - opt.selectors = ''; - rule = new CssRule(opt, c); - rule.get('selectors').add(selectors); - rules.add(rule); - return rule; - } - }, - - /** - * Get the rule - * @param {Array} selectors Array of selectors - * @param {String} state Css rule state - * @param {String} width For which device this style is oriented - * @param {Object} ruleProps Other rule props - * @return {Model|null} - * @example - * var sm = editor.SelectorManager; - * var sel1 = sm.add('myClass1'); - * var sel2 = sm.add('myClass2'); - * var rule = cssComposer.get([sel1, sel2], 'hover'); - * // Update the style - * rule.set('style', { - * width: '300px', - * color: '#000', - * }); - * */ - get(selectors, state, width, ruleProps) { - var rule = null; - rules.each(m => { - if(rule) - return; - if(m.compare(selectors, state, width, ruleProps)) - rule = m; - }); - return rule; - }, - - /** - * Get the collection of rules - * @return {Collection} - * */ - getAll() { - return rules; - }, - - - /** - * Remove all rules - * @return {this} - */ - clear() { - this.getAll().reset(); - return this; - }, - - - /** - * Add a raw collection of rule objects - * This method overrides styles, in case, of already defined rule - * @param {Array} data Array of rule objects, eg . [{selectors: ['class1'], style: {....}}, ..] - * @param {Object} opts Options - * @return {Array} - * @private - */ - addCollection(data, opts = {}) { - var result = []; - var d = data instanceof Array ? data : [data]; - - for (var i = 0, l = d.length; i < l; i++) { - var rule = d[i] || {}; - if(!rule.selectors) - continue; - var sm = c.em && c.em.get('SelectorManager'); - if(!sm) - console.warn('Selector Manager not found'); - var sl = rule.selectors; - var sels = sl instanceof Array ? sl : [sl]; - var newSels = []; - - for (var j = 0, le = sels.length; j < le; j++) { - var selec = sm.add(sels[j]); - newSels.push(selec); - } - - var modelExists = this.get(newSels, rule.state, rule.mediaText, rule); - var model = this.add(newSels, rule.state, rule.mediaText, rule); - var updateStyle = !modelExists || !opts.avoidUpdateStyle; - const style = rule.style || {}; - - if (updateStyle) { - let styleUpdate = opts.extend ? { ...model.get('style'), ...style } : style; - model.set('style', styleUpdate); - } - - result.push(model); + if (updateStyle) { + let styleUpdate = opts.extend + ? { ...model.get('style'), ...style } + : style; + model.set('style', styleUpdate); } - return result; - }, - - - /** - * Add/update the CSS rule with id selector - * @param {string} name Id selector name, eg. 'my-id' - * @param {Object} style Style properties and values - * @param {Object} [opts={}] Custom options, like `state` and `mediaText` - * @return {CssRule} The new/updated rule - * @example - * const rule = cc.setIdRule('myid', { color: 'red' }); - * const ruleHover = cc.setIdRule('myid', { color: 'blue' }, { state: 'hover' }); - * // This will add current CSS: - * // #myid { color: red } - * // #myid:hover { color: blue } - */ - setIdRule(name, style = {}, opts = {}) { - const state = opts.state || ''; - const media = opts.mediaText || em.getCurrentMedia(); - const sm = em.get('SelectorManager'); - const selector = sm.add({ name, type: Selector.TYPE_ID }); - const rule = this.add(selector, state, media); - rule.setStyle(style, opts); - return rule; - }, - - - /** - * Get the CSS rule by id selector - * @param {string} name Id selector name, eg. 'my-id' - * @param {Object} [opts={}] Custom options, like `state` and `mediaText` - * @return {CssRule} - * @example - * const rule = cc.getIdRule('myid'); - * const ruleHover = cc.setIdRule('myid', { state: 'hover' }); - */ - getIdRule(name, opts = {}) { - const state = opts.state || ''; - const media = opts.mediaText || em.getCurrentMedia(); - const selector = em.get('SelectorManager').get(name, Selector.TYPE_ID); - return selector && this.get(selector, state, media); - }, - - - /** - * Add/update the CSS rule with class selector - * @param {string} name Class selector name, eg. 'my-class' - * @param {Object} style Style properties and values - * @param {Object} [opts={}] Custom options, like `state` and `mediaText` - * @return {CssRule} The new/updated rule - * @example - * const rule = cc.setClassRule('myclass', { color: 'red' }); - * const ruleHover = cc.setClassRule('myclass', { color: 'blue' }, { state: 'hover' }); - * // This will add current CSS: - * // .myclass { color: red } - * // .myclass:hover { color: blue } - */ - setClassRule(name, style = {}, opts = {}) { - const state = opts.state || ''; - const media = opts.mediaText || em.getCurrentMedia(); - const sm = em.get('SelectorManager'); - const selector = sm.add({ name, type: Selector.TYPE_CLASS }); - const rule = this.add(selector, state, media); - rule.setStyle(style, opts); - return rule; - }, - - - /** - * Get the CSS rule by class selector - * @param {string} name Class selector name, eg. 'my-class' - * @param {Object} [opts={}] Custom options, like `state` and `mediaText` - * @return {CssRule} - * @example - * const rule = cc.getClassRule('myclass'); - * const ruleHover = cc.getClassRule('myclass', { state: 'hover' }); - */ - getClassRule(name, opts = {}) { - const state = opts.state || ''; - const media = opts.mediaText || em.getCurrentMedia(); - const selector = em.get('SelectorManager').get(name, Selector.TYPE_CLASS); - return selector && this.get(selector, state, media); - }, - - - /** - * Render the block of CSS rules - * @return {HTMLElement} - * @private - */ - render() { - return rulesView.render().el; - }, - - }; + result.push(model); + } + + return result; + }, + + /** + * Add/update the CSS rule with id selector + * @param {string} name Id selector name, eg. 'my-id' + * @param {Object} style Style properties and values + * @param {Object} [opts={}] Custom options, like `state` and `mediaText` + * @return {CssRule} The new/updated rule + * @example + * const rule = cc.setIdRule('myid', { color: 'red' }); + * const ruleHover = cc.setIdRule('myid', { color: 'blue' }, { state: 'hover' }); + * // This will add current CSS: + * // #myid { color: red } + * // #myid:hover { color: blue } + */ + setIdRule(name, style = {}, opts = {}) { + const state = opts.state || ''; + const media = opts.mediaText || em.getCurrentMedia(); + const sm = em.get('SelectorManager'); + const selector = sm.add({ name, type: Selector.TYPE_ID }); + const rule = this.add(selector, state, media); + rule.setStyle(style, opts); + return rule; + }, + + /** + * Get the CSS rule by id selector + * @param {string} name Id selector name, eg. 'my-id' + * @param {Object} [opts={}] Custom options, like `state` and `mediaText` + * @return {CssRule} + * @example + * const rule = cc.getIdRule('myid'); + * const ruleHover = cc.setIdRule('myid', { state: 'hover' }); + */ + getIdRule(name, opts = {}) { + const state = opts.state || ''; + const media = opts.mediaText || em.getCurrentMedia(); + const selector = em.get('SelectorManager').get(name, Selector.TYPE_ID); + return selector && this.get(selector, state, media); + }, + + /** + * Add/update the CSS rule with class selector + * @param {string} name Class selector name, eg. 'my-class' + * @param {Object} style Style properties and values + * @param {Object} [opts={}] Custom options, like `state` and `mediaText` + * @return {CssRule} The new/updated rule + * @example + * const rule = cc.setClassRule('myclass', { color: 'red' }); + * const ruleHover = cc.setClassRule('myclass', { color: 'blue' }, { state: 'hover' }); + * // This will add current CSS: + * // .myclass { color: red } + * // .myclass:hover { color: blue } + */ + setClassRule(name, style = {}, opts = {}) { + const state = opts.state || ''; + const media = opts.mediaText || em.getCurrentMedia(); + const sm = em.get('SelectorManager'); + const selector = sm.add({ name, type: Selector.TYPE_CLASS }); + const rule = this.add(selector, state, media); + rule.setStyle(style, opts); + return rule; + }, + + /** + * Get the CSS rule by class selector + * @param {string} name Class selector name, eg. 'my-class' + * @param {Object} [opts={}] Custom options, like `state` and `mediaText` + * @return {CssRule} + * @example + * const rule = cc.getClassRule('myclass'); + * const ruleHover = cc.getClassRule('myclass', { state: 'hover' }); + */ + getClassRule(name, opts = {}) { + const state = opts.state || ''; + const media = opts.mediaText || em.getCurrentMedia(); + const selector = em.get('SelectorManager').get(name, Selector.TYPE_CLASS); + return selector && this.get(selector, state, media); + }, + + /** + * Render the block of CSS rules + * @return {HTMLElement} + * @private + */ + render() { + return rulesView.render().el; + } + }; }; diff --git a/src/css_composer/model/CssRule.js b/src/css_composer/model/CssRule.js index bfadfbf43..1ea86c623 100644 --- a/src/css_composer/model/CssRule.js +++ b/src/css_composer/model/CssRule.js @@ -4,8 +4,7 @@ var Backbone = require('backbone'); var Selectors = require('selector_manager/model/Selectors'); module.exports = Backbone.Model.extend(Styleable).extend({ - - defaults: { + defaults: { // Css selectors selectors: {}, @@ -27,9 +26,8 @@ module.exports = Backbone.Model.extend(Styleable).extend({ // If true, sets '!important' on all properties // You can use an array to specify properties to set important // Used in view - important: 0, - }, - + important: 0 + }, initialize(c, opt = {}) { this.config = c || {}; @@ -40,7 +38,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({ if (em) { const sm = em.get('SelectorManager'); const slct = []; - selectors.forEach((selector) => { + selectors.forEach(selector => { slct.push(sm.add(selector)); }); selectors = slct; @@ -49,7 +47,6 @@ module.exports = Backbone.Model.extend(Styleable).extend({ this.set('selectors', new Selectors(selectors)); }, - /** * Return selectors fo the rule as a string * @return {string} @@ -65,7 +62,6 @@ module.exports = Backbone.Model.extend(Styleable).extend({ return result.join(', '); }, - /** * Returns CSS string of the rule * @param {Object} [opts={}] Options @@ -88,7 +84,6 @@ module.exports = Backbone.Model.extend(Styleable).extend({ return result; }, - /** * Compare the actual model with parameters * @param {Object} selectors Collection of selectors @@ -99,42 +94,35 @@ module.exports = Backbone.Model.extend(Styleable).extend({ * @private */ compare(selectors, state, width, ruleProps) { - var otherRule = ruleProps || {}; - var st = state || ''; - var wd = width || ''; - var selectorsAdd = otherRule.selectorsAdd || ''; - var cId = 'cid'; - //var a1 = _.pluck(selectors.models || selectors, cId); - //var a2 = _.pluck(this.get('selectors').models, cId); - if(!(selectors instanceof Array) && !selectors.models) - selectors = [selectors]; - var a1 = _.map((selectors.models || selectors), model => model.get('name')); - var a2 = _.map(this.get('selectors').models, model => model.get('name')); - var f = false; - - if(a1.length !== a2.length) - return f; - - for (var i = 0; i < a1.length; i++) { - var re = 0; - for (var j = 0; j < a2.length; j++) { - if (a1[i] === a2[j]) - re = 1; - } - if(re === 0) - return f; + var otherRule = ruleProps || {}; + var st = state || ''; + var wd = width || ''; + var selectorsAdd = otherRule.selectorsAdd || ''; + var cId = 'cid'; + //var a1 = _.pluck(selectors.models || selectors, cId); + //var a2 = _.pluck(this.get('selectors').models, cId); + if (!(selectors instanceof Array) && !selectors.models) + selectors = [selectors]; + var a1 = _.map(selectors.models || selectors, model => model.get('name')); + var a2 = _.map(this.get('selectors').models, model => model.get('name')); + var f = false; + + if (a1.length !== a2.length) return f; + + for (var i = 0; i < a1.length; i++) { + var re = 0; + for (var j = 0; j < a2.length; j++) { + if (a1[i] === a2[j]) re = 1; } + if (re === 0) return f; + } - if(this.get('state') !== st) - return f; - - if(this.get('mediaText') !== wd) - return f; + if (this.get('state') !== st) return f; - if(this.get('selectorsAdd') !== selectorsAdd) - return f; + if (this.get('mediaText') !== wd) return f; - return true; - }, + if (this.get('selectorsAdd') !== selectorsAdd) return f; + return true; + } }); diff --git a/src/css_composer/model/CssRules.js b/src/css_composer/model/CssRules.js index 19c23ced3..158761d94 100644 --- a/src/css_composer/model/CssRules.js +++ b/src/css_composer/model/CssRules.js @@ -2,27 +2,23 @@ var Backbone = require('backbone'); var CssRule = require('./CssRule'); module.exports = Backbone.Collection.extend({ - initialize(models, opt) { // Inject editor - if(opt && opt.sm) - this.editor = opt.sm; + if (opt && opt.sm) this.editor = opt.sm; // Not used this.model = (attrs, options) => { var model; - if(!options.sm && opt && opt.sm) - options.sm = opt.sm; + if (!options.sm && opt && opt.sm) options.sm = opt.sm; - switch(1){ + switch (1) { default: model = new CssRule(attrs, options); } - return model; + return model; }; - }, add(models, opt = {}) { @@ -31,6 +27,5 @@ module.exports = Backbone.Collection.extend({ } opt.em = this.editor; return Backbone.Collection.prototype.add.apply(this, [models, opt]); - }, - + } }); diff --git a/src/css_composer/view/CssRuleView.js b/src/css_composer/view/CssRuleView.js index 9bc9baf3d..4a7f29bf2 100644 --- a/src/css_composer/view/CssRuleView.js +++ b/src/css_composer/view/CssRuleView.js @@ -10,12 +10,10 @@ module.exports = require('backbone').View.extend({ this.listenTo(model.get('selectors'), 'change', this.render); }, - render() { const model = this.model; const important = model.get('important'); - this.el.innerHTML = this.model.toCSS({important}); + this.el.innerHTML = this.model.toCSS({ important }); return this; - }, - + } }); diff --git a/src/css_composer/view/CssRulesView.js b/src/css_composer/view/CssRulesView.js index 94ed5905b..0c2e132f7 100644 --- a/src/css_composer/view/CssRulesView.js +++ b/src/css_composer/view/CssRulesView.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var CssRuleView = require('./CssRuleView'); module.exports = Backbone.View.extend({ - initialize(o) { const config = o.config || {}; this.config = config; @@ -10,8 +9,8 @@ module.exports = Backbone.View.extend({ this.pfx = config.stylePrefix || ''; this.className = this.pfx + 'rules'; const coll = this.collection; - this.listenTo(coll, 'add', this.addTo ); - this.listenTo(coll, 'reset', this.render ); + this.listenTo(coll, 'add', this.addTo); + this.listenTo(coll, 'reset', this.render); }, /** @@ -31,19 +30,17 @@ module.exports = Backbone.View.extend({ * @private * */ addToCollection(model, fragmentEl) { - var fragment = fragmentEl || null; - var viewObject = CssRuleView; + var fragment = fragmentEl || null; + var viewObject = CssRuleView; var view = new viewObject({ - model, - config: this.config, + model, + config: this.config }); - var rendered = view.render().el; + var rendered = view.render().el; - if(fragment) - fragment.appendChild( rendered ); - else - this.$el.append(rendered); + if (fragment) fragment.appendChild(rendered); + else this.$el.append(rendered); return rendered; }, diff --git a/src/device_manager/config/config.js b/src/device_manager/config/config.js index e412a2050..b22a66721 100644 --- a/src/device_manager/config/config.js +++ b/src/device_manager/config/config.js @@ -1,7 +1,5 @@ module.exports = { - devices: [], - deviceLabel: 'Device', - + deviceLabel: 'Device' }; diff --git a/src/device_manager/index.js b/src/device_manager/index.js index 3a8f5451f..46190c2fa 100644 --- a/src/device_manager/index.js +++ b/src/device_manager/index.js @@ -9,104 +9,100 @@ */ module.exports = () => { var c = {}, - defaults = require('./config/config'), - Devices = require('./model/Devices'), - DevicesView = require('./view/DevicesView'); + defaults = require('./config/config'), + Devices = require('./model/Devices'), + DevicesView = require('./view/DevicesView'); var devices, view; return { + /** + * Name of the module + * @type {String} + * @private + */ + name: 'DeviceManager', - /** - * Name of the module - * @type {String} - * @private - */ - name: 'DeviceManager', + /** + * Initialize module. Automatically called with a new instance of the editor + * @param {Object} config Configurations + * @param {Array} [config.devices=[]] Default devices + * @example + * ... + * { + * devices: [ + * {name: 'Desktop', width: ''} + * {name: 'Tablet', width: '991px'} + * ], + * } + * ... + * @return {this} + * @private + */ + init(config) { + c = config || {}; + for (var name in defaults) { + if (!(name in c)) c[name] = defaults[name]; + } - /** - * Initialize module. Automatically called with a new instance of the editor - * @param {Object} config Configurations - * @param {Array} [config.devices=[]] Default devices - * @example - * ... - * { - * devices: [ - * {name: 'Desktop', width: ''} - * {name: 'Tablet', width: '991px'} - * ], - * } - * ... - * @return {this} - * @private - */ - init(config) { - c = config || {}; - for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; - } + devices = new Devices(c.devices); + view = new DevicesView({ + collection: devices, + config: c + }); + return this; + }, - devices = new Devices(c.devices); - view = new DevicesView({ - collection: devices, - config: c - }); - return this; - }, + /** + * Add new device to the collection. URLs are supposed to be unique + * @param {string} name Device name + * @param {string} width Width of the device + * @param {Object} opts Custom options + * @return {Device} Added device + * @example + * deviceManager.add('Tablet', '900px'); + * deviceManager.add('Tablet2', '900px', { + * height: '300px', + * widthMedia: '810px', // the width that will be used for the CSS media + * }); + */ + add(name, width, opts) { + var obj = opts || {}; + obj.name = name; + obj.width = width; + return devices.add(obj); + }, - /** - * Add new device to the collection. URLs are supposed to be unique - * @param {string} name Device name - * @param {string} width Width of the device - * @param {Object} opts Custom options - * @return {Device} Added device - * @example - * deviceManager.add('Tablet', '900px'); - * deviceManager.add('Tablet2', '900px', { - * height: '300px', - * widthMedia: '810px', // the width that will be used for the CSS media - * }); - */ - add(name, width, opts) { - var obj = opts || {}; - obj.name = name; - obj.width = width; - return devices.add(obj); - }, + /** + * Return device by name + * @param {string} name Name of the device + * @example + * var device = deviceManager.get('Tablet'); + * console.log(JSON.stringify(device)); + * // {name: 'Tablet', width: '900px'} + */ + get(name) { + return devices.get(name); + }, - /** - * Return device by name - * @param {string} name Name of the device - * @example - * var device = deviceManager.get('Tablet'); - * console.log(JSON.stringify(device)); - * // {name: 'Tablet', width: '900px'} - */ - get(name) { - return devices.get(name); - }, - - /** - * Return all devices - * @return {Collection} - * @example - * var devices = deviceManager.getAll(); - * console.log(JSON.stringify(devices)); - * // [{name: 'Desktop', width: ''}, ...] - */ - getAll() { - return devices; - }, - - /** - * Render devices - * @return {string} HTML string - * @private - */ - render() { - return view.render().el; - }, + /** + * Return all devices + * @return {Collection} + * @example + * var devices = deviceManager.getAll(); + * console.log(JSON.stringify(devices)); + * // [{name: 'Desktop', width: ''}, ...] + */ + getAll() { + return devices; + }, + /** + * Render devices + * @return {string} HTML string + * @private + */ + render() { + return view.render().el; + } }; - }; diff --git a/src/device_manager/model/Device.js b/src/device_manager/model/Device.js index 07e6d5a88..123906f03 100644 --- a/src/device_manager/model/Device.js +++ b/src/device_manager/model/Device.js @@ -1,10 +1,9 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - idAttribute: 'name', - defaults :{ + defaults: { name: '', // Width to set for the editor iframe @@ -15,7 +14,7 @@ module.exports = Backbone.Model.extend({ // The width which will be used in media queries, // If empty the width will be used - widthMedia: null, + widthMedia: null }, initialize() { @@ -23,5 +22,4 @@ module.exports = Backbone.Model.extend({ this.set('widthMedia', this.get('width')); } } - }); diff --git a/src/device_manager/model/Devices.js b/src/device_manager/model/Devices.js index 4ffcba36a..c6ced6ffb 100644 --- a/src/device_manager/model/Devices.js +++ b/src/device_manager/model/Devices.js @@ -2,5 +2,5 @@ var Backbone = require('backbone'); var Device = require('./Device'); module.exports = Backbone.Collection.extend({ - model: Device, + model: Device }); diff --git a/src/device_manager/view/DevicesView.js b/src/device_manager/view/DevicesView.js index a699568bc..9da83e16b 100644 --- a/src/device_manager/view/DevicesView.js +++ b/src/device_manager/view/DevicesView.js @@ -1,7 +1,6 @@ var Backbone = require('backbone'); module.exports = Backbone.View.extend({ - template: _.template(`
<%= deviceLabel %>
@@ -15,7 +14,7 @@ module.exports = Backbone.View.extend({ `), events: { - 'change': 'updateDevice' + change: 'updateDevice' }, initialize(o) { @@ -40,7 +39,7 @@ module.exports = Backbone.View.extend({ */ updateDevice() { var em = this.em; - if(em){ + if (em) { var devEl = this.devicesEl; var val = devEl ? devEl.val() : ''; em.set('device', val); @@ -54,7 +53,7 @@ module.exports = Backbone.View.extend({ updateSelect() { var em = this.em; var devEl = this.devicesEl; - if(em && em.getDeviceModel && devEl){ + if (em && em.getDeviceModel && devEl) { var device = em.getDeviceModel(); var name = device ? device.get('name') : ''; devEl.val(name); @@ -70,21 +69,22 @@ module.exports = Backbone.View.extend({ var result = ''; this.collection.each(device => { var name = device.get('name'); - result += ''; + result += ''; }); return result; }, render() { var pfx = this.ppfx; - this.$el.html(this.template({ - ppfx: pfx, - deviceLabel: this.config.deviceLabel - })); + this.$el.html( + this.template({ + ppfx: pfx, + deviceLabel: this.config.deviceLabel + }) + ); this.devicesEl = this.$el.find('.' + pfx + 'devices'); this.devicesEl.append(this.getOptions()); this.el.className = pfx + 'devices-c'; return this; - }, - + } }); diff --git a/src/dom_components/config/config.js b/src/dom_components/config/config.js index 5098e51d2..7b92d98b1 100644 --- a/src/dom_components/config/config.js +++ b/src/dom_components/config/config.js @@ -12,9 +12,15 @@ module.exports = { draggable: false, components: [], traits: [], - stylable: ['background','background-color','background-image', - 'background-repeat','background-attachment','background-position', - 'background-size'], + stylable: [ + 'background', + 'background-color', + 'background-image', + 'background-repeat', + 'background-attachment', + 'background-position', + 'background-size' + ] }, // Could be used for default components @@ -32,7 +38,22 @@ module.exports = { storeWrapper: 0, // List of void elements - voidElements: ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', - 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', - 'track', 'wbr'], + voidElements: [ + 'area', + 'base', + 'br', + 'col', + 'embed', + 'hr', + 'img', + 'input', + 'keygen', + 'link', + 'menuitem', + 'meta', + 'param', + 'source', + 'track', + 'wbr' + ] }; diff --git a/src/dom_components/index.js b/src/dom_components/index.js index 5f65f1a32..d8e5a5668 100644 --- a/src/dom_components/index.js +++ b/src/dom_components/index.js @@ -46,81 +46,82 @@ module.exports = () => { { id: 'cell', model: require('./model/ComponentTableCell'), - view: require('./view/ComponentTableCellView'), + view: require('./view/ComponentTableCellView') }, { id: 'row', model: require('./model/ComponentTableRow'), - view: require('./view/ComponentTableRowView'), + view: require('./view/ComponentTableRowView') }, { id: 'table', model: require('./model/ComponentTable'), - view: require('./view/ComponentTableView'), + view: require('./view/ComponentTableView') }, { id: 'thead', model: require('./model/ComponentTableHead'), - view: require('./view/ComponentTableHeadView'), + view: require('./view/ComponentTableHeadView') }, { id: 'tbody', model: require('./model/ComponentTableBody'), - view: require('./view/ComponentTableBodyView'), + view: require('./view/ComponentTableBodyView') }, { id: 'tfoot', model: require('./model/ComponentTableFoot'), - view: require('./view/ComponentTableFootView'), + view: require('./view/ComponentTableFootView') }, { id: 'map', model: require('./model/ComponentMap'), - view: require('./view/ComponentMapView'), + view: require('./view/ComponentMapView') }, { id: 'link', model: require('./model/ComponentLink'), - view: require('./view/ComponentLinkView'), + view: require('./view/ComponentLinkView') }, { id: 'video', model: require('./model/ComponentVideo'), - view: require('./view/ComponentVideoView'), + view: require('./view/ComponentVideoView') }, { id: 'image', model: require('./model/ComponentImage'), - view: require('./view/ComponentImageView'), + view: require('./view/ComponentImageView') }, { id: 'script', model: require('./model/ComponentScript'), - view: require('./view/ComponentScriptView'), + view: require('./view/ComponentScriptView') }, { id: 'svg', model: require('./model/ComponentSvg'), - view: require('./view/ComponentSvgView'), + view: require('./view/ComponentSvgView') }, { id: 'textnode', model: require('./model/ComponentTextNode'), - view: require('./view/ComponentTextNodeView'), + view: require('./view/ComponentTextNodeView') }, { id: 'text', model: require('./model/ComponentText'), - view: require('./view/ComponentTextView'), + view: require('./view/ComponentTextView') }, { id: 'default', model: Component, - view: ComponentView, - }, + view: ComponentView + } ]; return { + Component, Components, @@ -141,7 +142,7 @@ module.exports = () => { * @private */ getConfig() { - return c; + return c; }, /** @@ -152,10 +153,8 @@ module.exports = () => { storageKey() { var keys = []; var smc = (c.stm && c.stm.getConfig()) || {}; - if(smc.storeHtml) - keys.push('html'); - if(smc.storeComponents) - keys.push('components'); + if (smc.storeHtml) keys.push('html'); + if (smc.storeComponents) keys.push('components'); return keys; }, @@ -174,13 +173,11 @@ module.exports = () => { } for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } var ppfx = c.pStylePrefix; - if(ppfx) - c.stylePrefix = ppfx + c.stylePrefix; + if (ppfx) c.stylePrefix = ppfx + c.stylePrefix; // Load dependencies if (em) { @@ -197,7 +194,11 @@ module.exports = () => { wrapper.wrapper = 1; // Components might be a wrapper - if (components && components.constructor === Object && components.wrapper) { + if ( + components && + components.constructor === Object && + components.wrapper + ) { wrapper = { ...components }; components = components.components || []; wrapper.components = []; @@ -212,14 +213,14 @@ module.exports = () => { component = new Component(wrapper, { sm: em, config: c, - componentTypes, + componentTypes }); - component.set({ attributes: {id: 'wrapper'}}); + component.set({ attributes: { id: 'wrapper' } }); componentView = new ComponentView({ model: component, config: c, - componentTypes, + componentTypes }); return this; }, @@ -241,7 +242,6 @@ module.exports = () => { this.handleChanges(this.getWrapper(), null, { avoidStore: 1 }); }, - /** * Handle component changes * @private @@ -256,10 +256,11 @@ module.exports = () => { um && comps && um.add(comps); const evn = 'change:style change:content change:attributes change:src'; - [ [model, evn, handleUpdates], + [ + [model, evn, handleUpdates], [comps, 'add', handleChanges], [comps, 'remove', handleRemoves], - [model.get('classes'), 'add remove', handleUpdates], + [model.get('classes'), 'add remove', handleUpdates] ].forEach(els => { em.stopListening(els[0], els[1], els[2]); em.listenTo(els[0], els[1], els[2]); @@ -269,7 +270,6 @@ module.exports = () => { comps.each(model => this.handleChanges(model, value, opts)); }, - /** * Triggered when some component is removed * @private @@ -278,7 +278,6 @@ module.exports = () => { !opts.avoidStore && em.handleUpdates(model, value, opts); }, - /** * Load components from the passed object, if the object is empty will try to fetch them * autonomously from the selected storage @@ -309,8 +308,11 @@ module.exports = () => { // If the result is an object I consider it the wrapper if (isObj) { - this.getWrapper().set(result) - .initComponents().initClasses().loadTraits(); + this.getWrapper() + .set(result) + .initComponents() + .initClasses() + .loadTraits(); } else { this.getComponents().add(result); } @@ -325,7 +327,7 @@ module.exports = () => { * @return {Object} Data to store */ store(noStore) { - if(!c.stm) { + if (!c.stm) { return; } @@ -337,8 +339,9 @@ module.exports = () => { } if (keys.indexOf('components') >= 0) { - const toStore = c.storeWrapper ? - this.getWrapper() : this.getComponents(); + const toStore = c.storeWrapper + ? this.getWrapper() + : this.getComponents(); obj.components = JSON.stringify(toStore); } @@ -452,8 +455,7 @@ module.exports = () => { */ clear() { var c = this.getComponents(); - for(var i = 0, len = c.length; i < len; i++) - c.pop(); + for (var i = 0, len = c.length; i < len; i++) c.pop(); return this; }, @@ -475,7 +477,7 @@ module.exports = () => { */ addType(type, methods) { var compType = this.getType(type); - if(compType) { + if (compType) { compType.model = methods.model; compType.view = methods.view; } else { @@ -494,7 +496,7 @@ module.exports = () => { for (var it = 0; it < df.length; it++) { var dfId = df[it].id; - if(dfId == type) { + if (dfId == type) { return df[it]; } } @@ -514,12 +516,11 @@ module.exports = () => { if (previousModel) { previousModel.set({ status: '', - state: '', + state: '' }); } - model && model.set('status','selected'); + model && model.set('status', 'selected'); } - }; }; diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index a87061cf5..0c95340a4 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -1,5 +1,13 @@ -import { isUndefined, isArray, isEmpty, has, clone, isString, keys } from 'underscore'; -import { shallowDiff } from 'utils/mixins'; +import { + isUndefined, + isArray, + isEmpty, + has, + clone, + isString, + keys +} from 'underscore'; +import { shallowDiff, hasDnd } from 'utils/mixins'; import Styleable from 'domain_abstract/model/Styleable'; const Backbone = require('backbone'); @@ -7,757 +15,778 @@ const Components = require('./Components'); const Selector = require('selector_manager/model/Selector'); const Selectors = require('selector_manager/model/Selectors'); const Traits = require('trait_manager/model/Traits'); +const componentList = {}; +let componentIndex = 0; -const escapeRegExp = (str) => { +const escapeRegExp = str => { return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'); -} +}; -module.exports = Backbone.Model.extend(Styleable).extend({ +const Component = Backbone.Model.extend(Styleable).extend( + { + defaults: { + // HTML tag of the component + tagName: 'div', - defaults: { - // HTML tag of the component - tagName: 'div', + // Component type, eg. 'text', 'image', 'video', etc. + type: '', - // Component type, eg. 'text', 'image', 'video', etc. - type: '', + // Name of the component. Will be used, for example, in layers and badges + name: '', - // True if the component is removable from the canvas - removable: true, + // True if the component is removable from the canvas + removable: true, - // Indicates if it's possible to drag the component inside others - // Tip: Indicate an array of selectors where it could be dropped inside - draggable: true, + // Indicates if it's possible to drag the component inside others + // Tip: Indicate an array of selectors where it could be dropped inside + draggable: true, - // Indicates if it's possible to drop other components inside - // Tip: Indicate an array of selectors which could be dropped inside - droppable: true, + // Indicates if it's possible to drop other components inside + // Tip: Indicate an array of selectors which could be dropped inside + droppable: true, - // Set false if don't want to see the badge (with the name) over the component - badgable: true, + // Set false if don't want to see the badge (with the name) over the component + badgable: true, - // True if it's possible to style it - // Tip: - // Indicate an array of CSS properties which is possible to style, eg. ['color', 'width'] - // All other properties will be hidden from the style manager - stylable: true, - - // Indicate an array of style properties to show up which has been marked as `toRequire` - 'stylable-require': '', - - // Indicate an array of style properties which should be hidden from the style manager - unstylable: '', - - // Highlightable with 'dotted' style if true - highlightable: true, - - // True if it's possible to clone the component - copyable: true, - - // Indicates if it's possible to resize the component (at the moment implemented only on Image Components) - // It's also possible to pass an object as options for the Resizer - resizable: false, - - // Allow to edit the content of the component (used on Text components) - editable: false, - - // Hide the component inside Layers - layerable: true, - - // Allow component to be selected when clicked - selectable: true, - - // Shows a highlight outline when hovering on the element if true - hoverable: true, - - // This property is used by the HTML exporter as void elements do not - // have closing tag, eg.
,
, etc. - void: false, - - // Indicates if the component is in some CSS state like ':hover', ':active', etc. - state: '', - - // State, eg. 'selected' - status: '', - - // Content of the component (not escaped) which will be appended before children rendering - content: '', - - // Component icon, this string will be inserted before the name, eg. '' - icon: '', - - // Component related style - style: '', - - // Key-value object of the component's attributes - attributes: '', - - // Array of classes - classes: '', - - // Component's javascript - script: '', - - // Traits - traits: ['id', 'title'], - - // Indicates an array of properties which will be inhereted by - // all NEW appended children - // - // If you create a model likes this - // removable: false, - // draggable: false, - // propagate: ['removable', 'draggable'] - // When you append some new component inside, the new added model - // will get the exact same properties indicated in `propagate` array - // (as the `propagate` property itself) - // - propagate: '', - - /** - * Set an array of items to show up inside the toolbar (eg. move, clone, delete) - * when the component is selected - * toolbar: [{ - * attributes: {class: 'fa fa-arrows'}, - * command: 'tlb-move', - * },{ - * attributes: {class: 'fa fa-clone'}, - * command: 'tlb-clone', - * }] - */ - toolbar: null, - }, - - - initialize(props = {}, opt = {}) { - const em = opt.sm || opt.em || ''; - - // Propagate properties from parent if indicated - const parent = this.parent(); - const parentAttr = parent && parent.attributes; - - if (parentAttr && parentAttr.propagate) { - let newAttr = {}; - const toPropagate = parentAttr.propagate; - toPropagate.forEach(prop => newAttr[prop] = parent.get(prop)); - newAttr.propagate = toPropagate; - newAttr = {...newAttr, ...props}; - this.set(newAttr); - } - - const propagate = this.get('propagate'); - propagate && this.set('propagate', isArray(propagate) ? propagate : [propagate]); + // True if it's possible to style it + // Tip: + // Indicate an array of CSS properties which is possible to style, eg. ['color', 'width'] + // All other properties will be hidden from the style manager + stylable: true, + + // Indicate an array of style properties to show up which has been marked as `toRequire` + 'stylable-require': '', + + // Indicate an array of style properties which should be hidden from the style manager + unstylable: '', + + // Highlightable with 'dotted' style if true + highlightable: true, + + // True if it's possible to clone the component + copyable: true, + + // Indicates if it's possible to resize the component (at the moment implemented only on Image Components) + // It's also possible to pass an object as options for the Resizer + resizable: false, + + // Allow to edit the content of the component (used on Text components) + editable: false, + + // Hide the component inside Layers + layerable: true, + + // Allow component to be selected when clicked + selectable: true, + + // Shows a highlight outline when hovering on the element if true + hoverable: true, + + // This property is used by the HTML exporter as void elements do not + // have closing tag, eg.
,
, etc. + void: false, + + // Indicates if the component is in some CSS state like ':hover', ':active', etc. + state: '', + + // State, eg. 'selected' + status: '', + + // Content of the component (not escaped) which will be appended before children rendering + content: '', + + // Component icon, this string will be inserted before the name, eg. '' + icon: '', + + // Component related style + style: '', + + // Key-value object of the component's attributes + attributes: '', + + // Array of classes + classes: '', + + // Component's javascript + script: '', + + // Traits + traits: ['id', 'title'], + + // Indicates an array of properties which will be inhereted by + // all NEW appended children + // + // If you create a model likes this + // removable: false, + // draggable: false, + // propagate: ['removable', 'draggable'] + // When you append some new component inside, the new added model + // will get the exact same properties indicated in `propagate` array + // (as the `propagate` property itself) + // + propagate: '', + + /** + * Set an array of items to show up inside the toolbar (eg. move, clone, delete) + * when the component is selected + * toolbar: [{ + * attributes: {class: 'fa fa-arrows'}, + * command: 'tlb-move', + * },{ + * attributes: {class: 'fa fa-clone'}, + * command: 'tlb-clone', + * }] + */ + toolbar: null + }, + + initialize(props = {}, opt = {}) { + const em = opt.sm || opt.em || ''; + + // Propagate properties from parent if indicated + const parent = this.parent(); + const parentAttr = parent && parent.attributes; + + if (parentAttr && parentAttr.propagate) { + let newAttr = {}; + const toPropagate = parentAttr.propagate; + toPropagate.forEach(prop => (newAttr[prop] = parent.get(prop))); + newAttr.propagate = toPropagate; + newAttr = { ...newAttr, ...props }; + this.set(newAttr); + } + const propagate = this.get('propagate'); + propagate && + this.set('propagate', isArray(propagate) ? propagate : [propagate]); - // Check void elements - if(opt && opt.config && - opt.config.voidElements.indexOf(this.get('tagName')) >= 0) { + // Check void elements + if ( + opt && + opt.config && + opt.config.voidElements.indexOf(this.get('tagName')) >= 0 + ) { this.set('void', true); - } - - opt.em = em; - this.opt = opt; - this.sm = em; - this.em = em; - this.config = opt.config || {}; - this.set('attributes', this.get('attributes') || {}); - this.listenTo(this, 'change:script', this.scriptUpdated); - this.listenTo(this, 'change:traits', this.traitsUpdated); - this.listenTo(this, 'change:tagName', this.tagUpdated); - this.listenTo(this, 'change:attributes', this.attrUpdated); - this.loadTraits(); - this.initClasses(); - this.initComponents(); - this.initToolbar(); - this.set('status', ''); - this.listenTo(this.get('classes'), 'add remove change', - () => this.emitUpdate('classes')); - this.init(); - }, - - /** - * Check component's type - * @param {string} type Component type - * @return {Boolean} - * @example - * model.is('image') - * // -> false - */ - is(type) { - return !!(this.get('type') == type); - }, - - - /** - * Find inner models by query string - * ATTENTION: this method works only with alredy rendered component - * @param {string} query Query string - * @return {Array} Array of models - * @example - * model.find('div > .class'); - * // -> [Component, Component, ...] - */ - find(query) { - const result = []; - - this.view.$el.find(query).each((el, i, $el) => { - const model = $el.data('model'); - model && result.push(model); - }); - - return result; - }, - - - /** - * Once the tag is updated I have to remove the node and replace it - */ - tagUpdated() { - const coll = this.collection; - const at = coll.indexOf(this); - coll.remove(this); - coll.add(this, { at }); - }, - - - /** - * Emit changes for each updated attribute - */ - attrUpdated() { - const attrPrev = { ...this.previous('attributes') }; - const attrCurrent = { ...this.get('attributes') }; - const diff = shallowDiff(attrPrev, attrCurrent); - keys(diff).forEach(pr => this.trigger(`change:attributes:${pr}`)); - }, - - - /** - * Update attributes of the model - * @param {Object} attrs Key value attributes - * @example - * model.setAttributes({id: 'test', 'data-key': 'value'}); - */ - setAttributes(attrs) { - attrs = { ...attrs }; - - // Handle classes - const classes = attrs.class; - classes && this.setClass(classes); - delete attrs.class; - - // Handle style - const style = attrs.style; - style && this.setStyle(style); - delete attrs.style; - - this.set('attributes', attrs); - }, - - - getStyle() { - const em = this.em; - - if (em && em.getConfig('avoidInlineStyle')) { - const state = this.get('state'); - const cc = em.get('CssComposer'); - const rule = cc.getIdRule(this.getId(), { state }); - this.rule = rule; - - if (rule) { - return rule.getStyle(); } - } - - return Styleable.getStyle.call(this); - }, - - - setStyle(prop = {}, opts = {}) { - const em = this.em; - - if (em && em.getConfig('avoidInlineStyle')) { - prop = isString(prop) ? this.parseStyle(prop) : prop; - const state = this.get('state'); - const cc = em.get('CssComposer'); - const propOrig = this.getStyle(); - this.rule = cc.setIdRule(this.getId(), prop, { ...opts, state }); - const diff = shallowDiff(propOrig, prop); - keys(diff).forEach(pr => this.trigger(`change:style:${pr}`)); - } else { - prop = Styleable.setStyle.apply(this, arguments); - } - - return prop; - }, - - - /** - * Return attributes - * @return {Object} - */ - getAttributes() { - const classes = []; - const attributes = { ...this.get('attributes') }; - // Add classes - this.get('classes').each(cls => classes.push(cls.get('name'))); - classes.length && (attributes.class = classes.join(' ')); - - // If style is not empty I need an ID attached to the component - if (!isEmpty(this.getStyle()) && !has(attributes, 'id')) { - attributes.id = this.getId(); - } - - return attributes; - }, + opt.em = em; + this.opt = opt; + this.sm = em; + this.em = em; + this.config = opt.config || {}; + this.ccid = Component.createId(this); + this.set('attributes', this.get('attributes') || {}); + this.on('destroy', this.handleRemove); + this.listenTo(this, 'change:script', this.scriptUpdated); + this.listenTo(this, 'change:traits', this.traitsUpdated); + this.listenTo(this, 'change:tagName', this.tagUpdated); + this.listenTo(this, 'change:attributes', this.attrUpdated); + this.initClasses(); + this.loadTraits(); + this.initComponents(); + this.initToolbar(); + this.set('status', ''); + this.listenTo(this.get('classes'), 'add remove change', () => + this.emitUpdate('classes') + ); + this.init(); + }, + /** + * Triggered on model remove + * @param {Model} removed Removed model + * @private + */ + handleRemove(removed) { + const em = this.em; + em && em.trigger('component:remove', removed); + }, - /** - * Add classes - * @param {Array|string} classes Array or string of classes - * @return {Array} Array of added selectors - * @example - * model.addClass('class1'); - * model.addClass('class1 class2'); - * model.addClass(['class1', 'class2']); - * // -> [SelectorObject, ...] - */ - addClass(classes) { - const added = this.em.get('SelectorManager').addClass(classes); - return this.get('classes').add(added); - }, + /** + * Check component's type + * @param {string} type Component type + * @return {Boolean} + * @example + * model.is('image') + * // -> false + */ + is(type) { + return !!(this.get('type') == type); + }, + /** + * Find inner models by query string + * ATTENTION: this method works only with alredy rendered component + * @param {string} query Query string + * @return {Array} Array of models + * @example + * model.find('div > .class'); + * // -> [Component, Component, ...] + */ + find(query) { + const result = []; + + this.view.$el.find(query).each((el, i, $els) => { + const $el = $els.eq(i); + const model = $el.data('model'); + model && result.push(model); + }); + + return result; + }, - /** - * Set classes (resets current collection) - * @param {Array|string} classes Array or string of classes - * @return {Array} Array of added selectors - * @example - * model.setClass('class1'); - * model.setClass('class1 class2'); - * model.setClass(['class1', 'class2']); - * // -> [SelectorObject, ...] - */ - setClass(classes) { - this.get('classes').reset(); - return this.addClass(classes); - }, + /** + * Once the tag is updated I have to remove the node and replace it + */ + tagUpdated() { + const coll = this.collection; + const at = coll.indexOf(this); + coll.remove(this); + coll.add(this, { at }); + }, + /** + * Emit changes for each updated attribute + */ + attrUpdated() { + const attrPrev = { ...this.previous('attributes') }; + const attrCurrent = { ...this.get('attributes') }; + const diff = shallowDiff(attrPrev, attrCurrent); + keys(diff).forEach(pr => this.trigger(`change:attributes:${pr}`)); + }, - /** - * Remove classes - * @param {Array|string} classes Array or string of classes - * @return {Array} Array of removed selectors - * @example - * model.removeClass('class1'); - * model.removeClass('class1 class2'); - * model.removeClass(['class1', 'class2']); - * // -> [SelectorObject, ...] - */ - removeClass(classes) { - const removed = []; - classes = isArray(classes) ? classes : [classes]; - const selectors = this.get('classes'); - const type = Selector.TYPE_CLASS; - - classes.forEach(classe => { - const classes = classe.split(' '); - classes.forEach(name => { - const selector = selectors.where({ name, type })[0]; - selector && removed.push(selectors.remove(selector)); - }) - }); - - return removed; - }, + /** + * Update attributes of the model + * @param {Object} attrs Key value attributes + * @example + * model.setAttributes({id: 'test', 'data-key': 'value'}); + */ + setAttributes(attrs) { + attrs = { ...attrs }; + + // Handle classes + const classes = attrs.class; + classes && this.setClass(classes); + delete attrs.class; + + // Handle style + const style = attrs.style; + style && this.setStyle(style); + delete attrs.style; + + this.set('attributes', attrs); + }, + + getStyle() { + const em = this.em; + + if (em && em.getConfig('avoidInlineStyle')) { + const state = this.get('state'); + const cc = em.get('CssComposer'); + const rule = cc.getIdRule(this.getId(), { state }); + this.rule = rule; + + if (rule) { + return rule.getStyle(); + } + } + return Styleable.getStyle.call(this); + }, + + setStyle(prop = {}, opts = {}) { + const em = this.em; + + if (em && em.getConfig('avoidInlineStyle')) { + prop = isString(prop) ? this.parseStyle(prop) : prop; + const state = this.get('state'); + const cc = em.get('CssComposer'); + const propOrig = this.getStyle(); + this.rule = cc.setIdRule(this.getId(), prop, { ...opts, state }); + const diff = shallowDiff(propOrig, prop); + keys(diff).forEach(pr => this.trigger(`change:style:${pr}`)); + } else { + prop = Styleable.setStyle.apply(this, arguments); + } - initClasses() { - const classes = this.normalizeClasses(this.get('classes') || []); - this.set('classes', new Selectors(classes)); - return this; - }, + return prop; + }, + /** + * Return attributes + * @return {Object} + */ + getAttributes() { + const classes = []; + const attributes = { ...this.get('attributes') }; + + // Add classes + this.get('classes').each(cls => classes.push(cls.get('name'))); + classes.length && (attributes.class = classes.join(' ')); + + // If style is not empty I need an ID attached to the component + if (!isEmpty(this.getStyle()) && !has(attributes, 'id')) { + attributes.id = this.getId(); + } - initComponents() { - // Have to add components after the init, otherwise the parent - // is not visible - const comps = new Components(null, this.opt); - comps.parent = this; - comps.reset(this.get('components')); - this.set('components', comps); - return this; - }, + return attributes; + }, + /** + * Add classes + * @param {Array|string} classes Array or string of classes + * @return {Array} Array of added selectors + * @example + * model.addClass('class1'); + * model.addClass('class1 class2'); + * model.addClass(['class1', 'class2']); + * // -> [SelectorObject, ...] + */ + addClass(classes) { + const added = this.em.get('SelectorManager').addClass(classes); + return this.get('classes').add(added); + }, - /** - * Initialize callback - */ - init() {}, - - - /** - * Add new component children - * @param {Component|string} components Component to add - * @param {Object} [opts={}] Options, same as in `model.add()`(from backbone) - * @return {Array} Array of appended components - * @example - * someModel.get('components').lenght // -> 0 - * const videoComponent = someModel.append('
')[0]; - * // This will add 2 components (`video` and `div`) to your `someModel` - * someModel.get('components').lenght // -> 2 - * // You can pass components directly - * otherModel.append(otherModel2); - * otherModel.append([otherModel3, otherModel4]); - */ - append(components, opts = {}) { - const result = this.components().add(components, opts); - return isArray(result) ? result : [result]; - }, + /** + * Set classes (resets current collection) + * @param {Array|string} classes Array or string of classes + * @return {Array} Array of added selectors + * @example + * model.setClass('class1'); + * model.setClass('class1 class2'); + * model.setClass(['class1', 'class2']); + * // -> [SelectorObject, ...] + */ + setClass(classes) { + this.get('classes').reset(); + return this.addClass(classes); + }, + /** + * Remove classes + * @param {Array|string} classes Array or string of classes + * @return {Array} Array of removed selectors + * @example + * model.removeClass('class1'); + * model.removeClass('class1 class2'); + * model.removeClass(['class1', 'class2']); + * // -> [SelectorObject, ...] + */ + removeClass(classes) { + const removed = []; + classes = isArray(classes) ? classes : [classes]; + const selectors = this.get('classes'); + const type = Selector.TYPE_CLASS; + + classes.forEach(classe => { + const classes = classe.split(' '); + classes.forEach(name => { + const selector = selectors.where({ name, type })[0]; + selector && removed.push(selectors.remove(selector)); + }); + }); + + return removed; + }, + + initClasses() { + const classes = this.normalizeClasses(this.get('classes') || []); + this.set('classes', new Selectors(classes)); + return this; + }, + + initComponents() { + // Have to add components after the init, otherwise the parent + // is not visible + const comps = new Components(null, this.opt); + comps.parent = this; + !this.opt.avoidChildren && comps.reset(this.get('components')); + this.set('components', comps); + return this; + }, - /** - * Set new collection if `components` are provided, otherwise the - * current collection is returned - * @param {Component|string} [components] Components to set - * @return {Collection|undefined} - * @example - * // Get current collection - * const collection = model.components(); - * // Set new collection - * model.components('
'); - */ - components(components) { - const coll = this.get('components'); - - if (isUndefined(components)) { - return coll; - } else { - coll.reset(); - components && this.append(components); - } - }, + /** + * Initialize callback + */ + init() {}, + /** + * Add new component children + * @param {Component|string} components Component to add + * @param {Object} [opts={}] Options, same as in `model.add()`(from backbone) + * @return {Array} Array of appended components + * @example + * someModel.get('components').lenght // -> 0 + * const videoComponent = someModel.append('
')[0]; + * // This will add 2 components (`video` and `div`) to your `someModel` + * someModel.get('components').lenght // -> 2 + * // You can pass components directly + * otherModel.append(otherModel2); + * otherModel.append([otherModel3, otherModel4]); + */ + append(components, opts = {}) { + const result = this.components().add(components, opts); + return isArray(result) ? result : [result]; + }, - /** - * Get parent model - * @return {Component} - */ - parent() { - const coll = this.collection; - return coll && coll.parent; - }, + /** + * Set new collection if `components` are provided, otherwise the + * current collection is returned + * @param {Component|string} [components] Components to set + * @return {Collection|undefined} + * @example + * // Get current collection + * const collection = model.components(); + * // Set new collection + * model.components('
'); + */ + components(components) { + const coll = this.get('components'); + + if (isUndefined(components)) { + return coll; + } else { + coll.reset(); + components && this.append(components); + } + }, + /** + * Get parent model + * @return {Component} + */ + parent() { + const coll = this.collection; + return coll && coll.parent; + }, - /** - * Script updated - */ - scriptUpdated() { - this.set('scriptUpdated', 1); - }, + /** + * Script updated + */ + scriptUpdated() { + this.set('scriptUpdated', 1); + }, + /** + * Once traits are updated I have to populates model's attributes + */ + traitsUpdated() { + let found = 0; + const attrs = { ...this.get('attributes') }; + const traits = this.get('traits'); + + if (!(traits instanceof Traits)) { + this.loadTraits(); + return; + } - /** - * Once traits are updated I have to populates model's attributes - */ - traitsUpdated() { - let found = 0; - const attrs = { ...this.get('attributes') }; - const traits = this.get('traits'); + traits.each(trait => { + found = 1; + if (!trait.get('changeProp')) { + const value = trait.getInitValue(); + if (value) { + attrs[trait.get('name')] = value; + } + } + }); - if (!(traits instanceof Traits)) { - this.loadTraits(); - return; - } + found && this.set('attributes', attrs); + }, - traits.each((trait) => { - found = 1; - if (!trait.get('changeProp')) { - const value = trait.getInitValue(); - if (value) { - attrs[trait.get('name')] = value; + /** + * Init toolbar + */ + initToolbar() { + var model = this; + if (!model.get('toolbar')) { + var tb = []; + if (model.collection) { + tb.push({ + attributes: { class: 'fa fa-arrow-up' }, + command: 'select-parent' + }); + } + if (model.get('draggable')) { + tb.push({ + attributes: { class: 'fa fa-arrows', draggable: true }, + //events: hasDnd(this.em) ? { dragstart: 'execCommand' } : '', + command: 'tlb-move' + }); } + if (model.get('copyable')) { + tb.push({ + attributes: { class: 'fa fa-clone' }, + command: 'tlb-clone' + }); + } + if (model.get('removable')) { + tb.push({ + attributes: { class: 'fa fa-trash-o' }, + command: 'tlb-delete' + }); + } + model.set('toolbar', tb); } - }); - - found && this.set('attributes', attrs); - }, - + }, - /** - * Init toolbar - */ - initToolbar() { - var model = this; - if(!model.get('toolbar')) { - var tb = []; - if(model.collection) { - tb.push({ - attributes: {class: 'fa fa-arrow-up'}, - command: 'select-parent', - }); - } - if(model.get('draggable')) { - tb.push({ - attributes: {class: 'fa fa-arrows'}, - command: 'tlb-move', - }); - } - if(model.get('copyable')) { - tb.push({ - attributes: {class: 'fa fa-clone'}, - command: 'tlb-clone', - }); - } - if(model.get('removable')) { - tb.push({ - attributes: {class: 'fa fa-trash-o'}, - command: 'tlb-delete', - }); + /** + * Load traits + * @param {Array} traits + * @private + */ + loadTraits(traits, opts = {}) { + var trt = new Traits([], this.opt); + trt.setTarget(this); + traits = traits || this.get('traits'); + + if (traits.length) { + trt.add(traits); } - model.set('toolbar', tb); - } - }, - - - /** - * Load traits - * @param {Array} traits - * @private - */ - loadTraits(traits, opts = {}) { - var trt = new Traits([], this.opt); - trt.setTarget(this); - traits = traits || this.get('traits'); - - if (traits.length) { - trt.add(traits); - } - - this.set('traits', trt, opts); - return this; - }, + this.set('traits', trt, opts); + return this; + }, - /** - * Normalize input classes from array to array of objects - * @param {Array} arr - * @return {Array} - * @private - */ - normalizeClasses(arr) { - var res = []; - - if(!this.sm.get) - return; - - var clm = this.sm.get('SelectorManager'); - if(!clm) - return; + /** + * Normalize input classes from array to array of objects + * @param {Array} arr + * @return {Array} + * @private + */ + normalizeClasses(arr) { + var res = []; - arr.forEach(val => { - var name = ''; + if (!this.sm.get) return; - if(typeof val === 'string') - name = val; - else - name = val.name; + var clm = this.sm.get('SelectorManager'); + if (!clm) return; - var model = clm.add(name); - res.push(model); - }); - return res; - }, + arr.forEach(val => { + var name = ''; + if (typeof val === 'string') name = val; + else name = val.name; - /** - * Override original clone method - * @private - */ - clone(reset) { - const em = this.em; - const style = this.getStyle(); - const attr = { ...this.attributes }; - attr.attributes = { ...attr.attributes }; - delete attr.attributes.id; - attr.components = []; - attr.classes = []; - attr.traits = []; - - this.get('components').each((md, i) => { - attr.components[i] = md.clone(1); - }); - this.get('traits').each((md, i) => { - attr.traits[i] = md.clone(); - }); - this.get('classes').each((md, i) => { - attr.classes[i] = md.get('name'); - }); - - attr.status = ''; - attr.view = ''; - - if(reset){ - this.opt.collection = null; - } - - if (em && em.getConfig('avoidInlineStyle') && !isEmpty(style)) { - attr.style = style; - } - - return new this.constructor(attr, this.opt); - }, + var model = clm.add(name); + res.push(model); + }); + return res; + }, + /** + * Override original clone method + * @private + */ + clone(reset) { + const em = this.em; + const style = this.getStyle(); + const attr = { ...this.attributes }; + attr.attributes = { ...attr.attributes }; + delete attr.attributes.id; + attr.components = []; + attr.classes = []; + attr.traits = []; + + this.get('components').each((md, i) => { + attr.components[i] = md.clone(1); + }); + this.get('traits').each((md, i) => { + attr.traits[i] = md.clone(); + }); + this.get('classes').each((md, i) => { + attr.classes[i] = md.get('name'); + }); + + attr.status = ''; + attr.view = ''; + + if (reset) { + this.opt.collection = null; + } - /** - * Get the name of the component - * @return {string} - * */ - getName() { - let customName = this.get('custom-name'); - let tag = this.get('tagName'); - tag = tag == 'div' ? 'box' : tag; - let name = this.get('type') || tag; - name = name.charAt(0).toUpperCase() + name.slice(1); - return customName || name; - }, + if (em && em.getConfig('avoidInlineStyle') && !isEmpty(style)) { + attr.style = style; + } + return new this.constructor(attr, this.opt); + }, - /** - * Get the icon string - * @return {string} - */ - getIcon() { - let icon = this.get('icon'); - return icon ? icon + ' ' : ''; - }, + /** + * Get the name of the component + * @return {string} + * */ + getName() { + let customName = this.get('name') || this.get('custom-name'); + let tag = this.get('tagName'); + tag = tag == 'div' ? 'box' : tag; + let name = this.get('type') || tag; + name = name.charAt(0).toUpperCase() + name.slice(1); + return customName || name; + }, + /** + * Get the icon string + * @return {string} + */ + getIcon() { + let icon = this.get('icon'); + return icon ? icon + ' ' : ''; + }, - /** - * Return HTML string of the component - * @param {Object} opts Options - * @return {string} HTML string - * @private - */ - toHTML(opts) { - const model = this; - const attrs = []; - const classes = []; - const tag = model.get('tagName'); - const sTag = model.get('void'); - const attributes = this.getAttrToHTML(); - - for (let attr in attributes) { - const value = attributes[attr]; - - if (!isUndefined(value)) { + /** + * Return HTML string of the component + * @param {Object} opts Options + * @return {string} HTML string + * @private + */ + toHTML(opts) { + const model = this; + const attrs = []; + const classes = []; + const tag = model.get('tagName'); + const sTag = model.get('void'); + const attributes = this.getAttrToHTML(); + + for (let attr in attributes) { + const value = attributes[attr]; + + if (!isUndefined(value)) { attrs.push(`${attr}="${value}"`); + } } - } - let attrString = attrs.length ? ` ${attrs.join(' ')}` : ''; - let code = `<${tag}${attrString}${sTag ? '/' : ''}>${model.get('content')}`; - model.get('components').each(comp => code += comp.toHTML()); - !sTag && (code += ``); + let attrString = attrs.length ? ` ${attrs.join(' ')}` : ''; + let code = `<${tag}${attrString}${sTag ? '/' : ''}>${model.get( + 'content' + )}`; + model.get('components').each(comp => (code += comp.toHTML())); + !sTag && (code += ``); - return code; - }, + return code; + }, + /** + * Returns object of attributes for HTML + * @return {Object} + * @private + */ + getAttrToHTML() { + var attr = this.getAttributes(); + delete attr.style; + return attr; + }, - /** - * Returns object of attributes for HTML - * @return {Object} - * @private - */ - getAttrToHTML() { - var attr = this.getAttributes(); - delete attr.style; - return attr; - }, - - - /** - * Return a shallow copy of the model's attributes for JSON - * stringification. - * @return {Object} - * @private - */ - toJSON(...args) { - var obj = Backbone.Model.prototype.toJSON.apply(this, args); - var scriptStr = this.getScriptString(); - delete obj.toolbar; - - if (scriptStr) { - obj.script = scriptStr; - } + /** + * Return a shallow copy of the model's attributes for JSON + * stringification. + * @return {Object} + * @private + */ + toJSON(...args) { + const obj = Backbone.Model.prototype.toJSON.apply(this, args); + const scriptStr = this.getScriptString(); + obj.attributes = this.getAttributes(); + delete obj.attributes.class; + delete obj.toolbar; + scriptStr && (obj.script = scriptStr); + + return obj; + }, - return obj; - }, + /** + * Return model id + * @return {string} + */ + getId() { + let attrs = this.get('attributes') || {}; + return attrs.id || this.ccid || this.cid; + }, + /** + * Get the DOM element of the model. This works only of the + * model is alredy rendered + * @return {HTMLElement} + */ + getEl() { + return this.view && this.view.el; + }, - /** - * Return model id - * @return {string} - */ - getId() { - let attrs = this.get('attributes') || {}; - return attrs.id || this.cid; - }, + /** + * Return script in string format, cleans 'function() {..' from scripts + * if it's a function + * @param {string|Function} script + * @return {string} + * @private + */ + getScriptString(script) { + var scr = script || this.get('script'); + + if (!scr) { + return scr; + } + // Need to convert script functions to strings + if (typeof scr == 'function') { + var scrStr = scr.toString().trim(); + scrStr = scrStr + .replace(/^function[\s\w]*\(\)\s?\{/, '') + .replace(/\}$/, ''); + scr = scrStr.trim(); + } - /** - * Return script in string format, cleans 'function() {..' from scripts - * if it's a function - * @param {string|Function} script - * @return {string} - * @private - */ - getScriptString(script) { - var scr = script || this.get('script'); + var config = this.sm.config || {}; + var tagVarStart = escapeRegExp(config.tagVarStart || '{[ '); + var tagVarEnd = escapeRegExp(config.tagVarEnd || ' ]}'); + var reg = new RegExp(`${tagVarStart}([\\w\\d-]*)${tagVarEnd}`, 'g'); + scr = scr.replace(reg, (match, v) => { + // If at least one match is found I have to track this change for a + // better optimization inside JS generator + this.scriptUpdated(); + return this.attributes[v] || ''; + }); - if (!scr) { return scr; - } + }, - // Need to convert script functions to strings - if (typeof scr == 'function') { - var scrStr = scr.toString().trim(); - scrStr = scrStr.replace(/^function[\s\w]*\(\)\s?\{/, '').replace(/\}$/, ''); - scr = scrStr.trim(); + emitUpdate(property) { + const em = this.em; + const event = 'component:update' + (property ? `:${property}` : ''); + em && em.trigger(event, this.model); } - - var config = this.sm.config || {}; - var tagVarStart = escapeRegExp(config.tagVarStart || '{[ '); - var tagVarEnd = escapeRegExp(config.tagVarEnd || ' ]}'); - var reg = new RegExp(`${tagVarStart}(\\w+)${tagVarEnd}`, 'g'); - scr = scr.replace(reg, (match, v) => { - // If at least one match is found I have to track this change for a - // better optimization inside JS generator - this.scriptUpdated(); - return this.attributes[v]; - }) - - return scr; - }, - - - emitUpdate(property) { - const em = this.em; - const event = 'component:update' + (property ? `:${property}` : ''); - em && em.trigger(event, this.model); }, + { + /** + * Detect if the passed element is a valid component. + * In case the element is valid an object abstracted + * from the element will be returned + * @param {HTMLElement} + * @return {Object} + * @private + */ + isComponent(el) { + return { tagName: el.tagName ? el.tagName.toLowerCase() : '' }; + }, -},{ - - /** - * Detect if the passed element is a valid component. - * In case the element is valid an object abstracted - * from the element will be returned - * @param {HTMLElement} - * @return {Object} - * @private - */ - isComponent(el) { - return {tagName: el.tagName ? el.tagName.toLowerCase() : ''}; - }, + /** + * Relying simply on the number of components becomes a problem when you + * store and load them back, you might hit collisions with new components + * @param {Model} model + * @return {string} + */ + createId(model) { + componentIndex++; + // Testing 1000000 components with `+ 2` returns 0 collisions + const ilen = componentIndex.toString().length + 2; + const uid = (Math.random() + 1.1).toString(36).slice(-ilen); + const nextId = 'i' + uid; + componentList[nextId] = model; + return nextId; + }, + + getList() { + return componentList; + } + } +); -}); +module.exports = Component; diff --git a/src/dom_components/model/ComponentImage.js b/src/dom_components/model/ComponentImage.js index 2c6d28db1..21cf03600 100644 --- a/src/dom_components/model/ComponentImage.js +++ b/src/dom_components/model/ComponentImage.js @@ -1,103 +1,103 @@ var Component = require('./Component'); -module.exports = Component.extend({ +module.exports = Component.extend( + { + defaults: { + ...Component.prototype.defaults, + type: 'image', + tagName: 'img', + src: '', + void: 1, + droppable: 0, + editable: 1, + highlightable: 0, + resizable: 1, + traits: ['alt'], - defaults: { ...Component.prototype.defaults, - type: 'image', - tagName: 'img', - src: '', - void: 1, - droppable: 0, - editable: 1, - highlightable: 0, - resizable: 1, - traits: ['alt'] - }, + // File to load asynchronously once the model is rendered + file: '' + }, - initialize(o, opt) { - Component.prototype.initialize.apply(this, arguments); - var attr = this.get('attributes'); - if(attr.src) - this.set('src', attr.src); - }, + initialize(o, opt) { + Component.prototype.initialize.apply(this, arguments); + var attr = this.get('attributes'); + if (attr.src) this.set('src', attr.src); + }, - initToolbar(...args) { - Component.prototype.initToolbar.apply(this, args); + initToolbar(...args) { + Component.prototype.initToolbar.apply(this, args); - if (this.sm && this.sm.get) { - var cmd = this.sm.get('Commands'); - var cmdName = 'image-editor'; + if (this.sm && this.sm.get) { + var cmd = this.sm.get('Commands'); + var cmdName = 'image-editor'; - // Add Image Editor button only if the default command exists - if (cmd.has(cmdName)) { - var tb = this.get('toolbar'); - tb.push({ - attributes: {class: 'fa fa-pencil'}, - command: cmdName, - }); - this.set('toolbar', tb); + // Add Image Editor button only if the default command exists + if (cmd.has(cmdName)) { + var tb = this.get('toolbar'); + tb.push({ + attributes: { class: 'fa fa-pencil' }, + command: cmdName + }); + this.set('toolbar', tb); + } } - } - }, + }, - /** - * Returns object of attributes for HTML - * @return {Object} - * @private - */ - getAttrToHTML(...args) { - var attr = Component.prototype.getAttrToHTML.apply(this, args); - delete attr.onmousedown; - var src = this.get('src'); - if(src) - attr.src = src; - return attr; - }, + /** + * Returns object of attributes for HTML + * @return {Object} + * @private + */ + getAttrToHTML(...args) { + var attr = Component.prototype.getAttrToHTML.apply(this, args); + delete attr.onmousedown; + var src = this.get('src'); + if (src) attr.src = src; + return attr; + }, - /** - * Parse uri - * @param {string} uri - * @return {object} - * @private - */ - parseUri(uri) { - var el = document.createElement('a'); - el.href = uri; - var query = {}; - var qrs = el.search.substring(1).split('&'); - for (var i = 0; i < qrs.length; i++) { - var pair = qrs[i].split('='); - var name = decodeURIComponent(pair[0]); - if(name) - query[name] = decodeURIComponent(pair[1]); + /** + * Parse uri + * @param {string} uri + * @return {object} + * @private + */ + parseUri(uri) { + var el = document.createElement('a'); + el.href = uri; + var query = {}; + var qrs = el.search.substring(1).split('&'); + for (var i = 0; i < qrs.length; i++) { + var pair = qrs[i].split('='); + var name = decodeURIComponent(pair[0]); + if (name) query[name] = decodeURIComponent(pair[1]); + } + return { + hostname: el.hostname, + pathname: el.pathname, + protocol: el.protocol, + search: el.search, + hash: el.hash, + port: el.port, + query + }; } - return { - hostname: el.hostname, - pathname: el.pathname, - protocol: el.protocol, - search: el.search, - hash: el.hash, - port: el.port, - query, - }; }, - -},{ - - /** - * Detect if the passed element is a valid component. - * In case the element is valid an object abstracted - * from the element will be returned - * @param {HTMLElement} - * @return {Object} - * @private - */ - isComponent(el) { - var result = ''; - if(el.tagName == 'IMG'){ - result = {type: 'image'}; + { + /** + * Detect if the passed element is a valid component. + * In case the element is valid an object abstracted + * from the element will be returned + * @param {HTMLElement} + * @return {Object} + * @private + */ + isComponent(el) { + var result = ''; + if (el.tagName == 'IMG') { + result = { type: 'image' }; + } + return result; } - return result; - }, - -}); + } +); diff --git a/src/dom_components/model/ComponentLink.js b/src/dom_components/model/ComponentLink.js index 39f91d7ef..87140575d 100644 --- a/src/dom_components/model/ComponentLink.js +++ b/src/dom_components/model/ComponentLink.js @@ -1,53 +1,53 @@ const Component = require('./ComponentText'); -module.exports = Component.extend({ - - defaults: { ...Component.prototype.defaults, +module.exports = Component.extend( + { + defaults: { + ...Component.prototype.defaults, type: 'link', tagName: 'a', - traits: ['title', 'href', 'target'], - }, - - /** - * Returns object of attributes for HTML - * @return {Object} - * @private - */ - getAttrToHTML(...args) { - const attr = Component.prototype.getAttrToHTML.apply(this, args); - delete attr.onmousedown; - return attr; + traits: ['title', 'href', 'target'] + }, + + /** + * Returns object of attributes for HTML + * @return {Object} + * @private + */ + getAttrToHTML(...args) { + const attr = Component.prototype.getAttrToHTML.apply(this, args); + delete attr.onmousedown; + return attr; + } }, - -}, { - - isComponent(el) { - let result; - let avoidEdit; - - if (el.tagName == 'A') { - result = { - type: 'link', - editable: 0, - }; - - // The link is editable only if, at least, one of its - // children is a text node (not empty one) - const children = el.childNodes; - const len = children.length; - if (!len) delete result.editable; - - for (let i = 0; i < len; i++) { - const child = children[i]; - - if (child.nodeType == 3 && child.textContent.trim() != '') { - delete result.editable; - break; + { + isComponent(el) { + let result; + let avoidEdit; + + if (el.tagName == 'A') { + result = { + type: 'link', + editable: 0 + }; + + // The link is editable only if, at least, one of its + // children is a text node (not empty one) + const children = el.childNodes; + const len = children.length; + if (!len) delete result.editable; + + for (let i = 0; i < len; i++) { + const child = children[i]; + + if (child.nodeType == 3 && child.textContent.trim() != '') { + delete result.editable; + break; + } } } - } - return result; - }, - -}); + return result; + } + } +); diff --git a/src/dom_components/model/ComponentMap.js b/src/dom_components/model/ComponentMap.js index 0de3780bf..704ab6d20 100644 --- a/src/dom_components/model/ComponentMap.js +++ b/src/dom_components/model/ComponentMap.js @@ -1,9 +1,9 @@ var Component = require('./ComponentImage'); var OComponent = require('./Component'); -module.exports = Component.extend({ - - defaults: _.extend({}, Component.prototype.defaults, { +module.exports = Component.extend( + { + defaults: _.extend({}, Component.prototype.defaults, { type: 'map', void: 0, mapUrl: 'https://maps.google.com/maps', @@ -11,97 +11,97 @@ module.exports = Component.extend({ mapType: 'q', address: '', zoom: '1', - attributes: {frameborder: 0}, + attributes: { frameborder: 0 }, toolbar: OComponent.prototype.defaults.toolbar, - traits: [{ - label: 'Address', - name: 'address', - placeholder: 'eg. London, UK', - changeProp: 1, - },{ - type: 'select', - label: 'Map type', - name: 'mapType', - changeProp: 1, - options: [ - {value: 'q', name: 'Roadmap'}, - {value: 'w', name: 'Satellite'} - ] - },{ - label: 'Zoom', - name: 'zoom', - type: 'range', - min: '1', - max: '20', - changeProp: 1, - }], - }), - - - initialize(o, opt) { - if(this.get('src')) - this.parseFromSrc(); - else - this.updateSrc(); - Component.prototype.initialize.apply(this, arguments); - this.listenTo(this, 'change:address change:zoom change:mapType', this.updateSrc); - }, - - updateSrc() { - this.set('src', this.getMapUrl()); - }, + traits: [ + { + label: 'Address', + name: 'address', + placeholder: 'eg. London, UK', + changeProp: 1 + }, + { + type: 'select', + label: 'Map type', + name: 'mapType', + changeProp: 1, + options: [ + { value: 'q', name: 'Roadmap' }, + { value: 'w', name: 'Satellite' } + ] + }, + { + label: 'Zoom', + name: 'zoom', + type: 'range', + min: '1', + max: '20', + changeProp: 1 + } + ] + }), - /** - * Returns url of the map - * @return {string} - * @private - */ - getMapUrl() { - var md = this; - var addr = md.get('address'); - var zoom = md.get('zoom'); - var type = md.get('mapType'); - var size = ''; - addr = addr ? '&q=' + addr : ''; - zoom = zoom ? '&z=' + zoom : ''; - type = type ? '&t=' + type : ''; - var result = md.get('mapUrl')+'?' + addr + zoom + type; - result += '&output=embed'; - return result; - }, + initialize(o, opt) { + if (this.get('src')) this.parseFromSrc(); + else this.updateSrc(); + Component.prototype.initialize.apply(this, arguments); + this.listenTo( + this, + 'change:address change:zoom change:mapType', + this.updateSrc + ); + }, - /** - * Set attributes by src string - * @private - */ - parseFromSrc() { - var uri = this.parseUri(this.get('src')); - var qr = uri.query; - if(qr.q) - this.set('address', qr.q); - if(qr.z) - this.set('zoom', qr.z); - if(qr.t) - this.set('mapType', qr.t); - }, + updateSrc() { + this.set('src', this.getMapUrl()); + }, -},{ + /** + * Returns url of the map + * @return {string} + * @private + */ + getMapUrl() { + var md = this; + var addr = md.get('address'); + var zoom = md.get('zoom'); + var type = md.get('mapType'); + var size = ''; + addr = addr ? '&q=' + addr : ''; + zoom = zoom ? '&z=' + zoom : ''; + type = type ? '&t=' + type : ''; + var result = md.get('mapUrl') + '?' + addr + zoom + type; + result += '&output=embed'; + return result; + }, - /** - * Detect if the passed element is a valid component. - * In case the element is valid an object abstracted - * from the element will be returned - * @param {HTMLElement} - * @return {Object} - * @private - */ - isComponent(el) { - var result = ''; - if(el.tagName == 'IFRAME' && - /maps\.google\.com/.test(el.src) ){ - result = {type: 'map', src: el.src}; + /** + * Set attributes by src string + * @private + */ + parseFromSrc() { + var uri = this.parseUri(this.get('src')); + var qr = uri.query; + if (qr.q) this.set('address', qr.q); + if (qr.z) this.set('zoom', qr.z); + if (qr.t) this.set('mapType', qr.t); } - return result; }, - -}); + { + /** + * Detect if the passed element is a valid component. + * In case the element is valid an object abstracted + * from the element will be returned + * @param {HTMLElement} + * @return {Object} + * @private + */ + isComponent(el) { + var result = ''; + if (el.tagName == 'IFRAME' && /maps\.google\.com/.test(el.src)) { + result = { type: 'map', src: el.src }; + } + return result; + } + } +); diff --git a/src/dom_components/model/ComponentScript.js b/src/dom_components/model/ComponentScript.js index a18eae12d..b3b1bde4c 100644 --- a/src/dom_components/model/ComponentScript.js +++ b/src/dom_components/model/ComponentScript.js @@ -1,27 +1,26 @@ var Component = require('./Component'); -module.exports = Component.extend({ - - defaults: _.extend({}, Component.prototype.defaults, { - type: 'script', - droppable: false, - draggable: false, - layerable: false, - }), - -}, { +module.exports = Component.extend( + { + defaults: _.extend({}, Component.prototype.defaults, { + type: 'script', + droppable: false, + draggable: false, + layerable: false + }) + }, + { + isComponent(el) { + if (el.tagName == 'SCRIPT') { + var result = { type: 'script' }; - isComponent(el) { - if (el.tagName == 'SCRIPT') { - var result = {type: 'script'}; + if (el.src) { + result.src = el.src; + result.onload = el.onload; + } - if (el.src) { - result.src = el.src; - result.onload = el.onload; + return result; } - - return result; } - }, - -}); + } +); diff --git a/src/dom_components/model/ComponentSvg.js b/src/dom_components/model/ComponentSvg.js index cab7f6c36..db5b2c058 100644 --- a/src/dom_components/model/ComponentSvg.js +++ b/src/dom_components/model/ComponentSvg.js @@ -1,33 +1,33 @@ var Component = require('./Component'); -module.exports = Component.extend({ +module.exports = Component.extend( + { + defaults: { + ...Component.prototype.defaults, + highlightable: 0 + }, - defaults: { ...Component.prototype.defaults, - highlightable: 0, - }, - - getName() { - let name = this.get('tagName'); - let customName = this.get('custom-name'); - name = name.charAt(0).toUpperCase() + name.slice(1); - return customName || name; - }, - -}, { - - isComponent(el) { - if (SVGElement && el instanceof SVGElement) { - // Some SVG elements require uppercase letters (eg. ) - const tagName = el.tagName; - // Make the root resizable - const resizable = tagName == 'svg' ? true : false; - - return { - tagName, - type: 'svg', - resizable - }; + getName() { + let name = this.get('tagName'); + let customName = this.get('custom-name'); + name = name.charAt(0).toUpperCase() + name.slice(1); + return customName || name; } }, + { + isComponent(el) { + if (SVGElement && el instanceof SVGElement) { + // Some SVG elements require uppercase letters (eg. ) + const tagName = el.tagName; + // Make the root resizable + const resizable = tagName == 'svg' ? true : false; -}); + return { + tagName, + type: 'svg', + resizable + }; + } + } + } +); diff --git a/src/dom_components/model/ComponentTable.js b/src/dom_components/model/ComponentTable.js index 6f784425d..b50034222 100644 --- a/src/dom_components/model/ComponentTable.js +++ b/src/dom_components/model/ComponentTable.js @@ -1,29 +1,29 @@ const Component = require('./Component'); -module.exports = Component.extend({ - - defaults: { ...Component.prototype.defaults, +module.exports = Component.extend( + { + defaults: { + ...Component.prototype.defaults, type: 'table', tagName: 'table', - droppable: ['tbody', 'thead', 'tfoot'], - }, + droppable: ['tbody', 'thead', 'tfoot'] + }, - initialize(o, opt) { - Component.prototype.initialize.apply(this, arguments); - const components = this.get('components'); - !components.length && components.add({ type: 'tbody' }); + initialize(o, opt) { + Component.prototype.initialize.apply(this, arguments); + const components = this.get('components'); + !components.length && components.add({ type: 'tbody' }); + } }, + { + isComponent(el) { + let result = ''; -}, { - - isComponent(el) { - let result = ''; + if (el.tagName == 'TABLE') { + result = { type: 'table' }; + } - if (el.tagName == 'TABLE') { - result = { type: 'table' }; + return result; } - - return result; - }, - -}); + } +); diff --git a/src/dom_components/model/ComponentTableBody.js b/src/dom_components/model/ComponentTableBody.js index 943bdb33e..75754ede3 100644 --- a/src/dom_components/model/ComponentTableBody.js +++ b/src/dom_components/model/ComponentTableBody.js @@ -1,58 +1,58 @@ const Component = require('./Component'); -module.exports = Component.extend({ - - defaults: { ...Component.prototype.defaults, - type: 'tbody', - tagName: 'tbody', - draggable: ['table'], - droppable: ['tr'], - columns: 1, - rows: 1, - }, - - initialize(o, opt) { - Component.prototype.initialize.apply(this, arguments); - const components = this.get('components'); - let columns = this.get('columns'); - let rows = this.get('rows'); - - // Init components if empty - if (!components.length) { - const rowsToAdd = []; - - while (rows--) { - const columnsToAdd = []; - let clm = columns; - - while (clm--) { - columnsToAdd.push({ - type: 'cell', - classes: ['cell'] +module.exports = Component.extend( + { + defaults: { + ...Component.prototype.defaults, + type: 'tbody', + tagName: 'tbody', + draggable: ['table'], + droppable: ['tr'], + columns: 1, + rows: 1 + }, + + initialize(o, opt) { + Component.prototype.initialize.apply(this, arguments); + const components = this.get('components'); + let columns = this.get('columns'); + let rows = this.get('rows'); + + // Init components if empty + if (!components.length) { + const rowsToAdd = []; + + while (rows--) { + const columnsToAdd = []; + let clm = columns; + + while (clm--) { + columnsToAdd.push({ + type: 'cell', + classes: ['cell'] + }); + } + + rowsToAdd.push({ + type: 'row', + classes: ['row'], + components: columnsToAdd }); } - rowsToAdd.push({ - type: 'row', - classes: ['row'], - components: columnsToAdd - }); + components.add(rowsToAdd); } - - components.add(rowsToAdd); } }, + { + isComponent(el) { + let result = ''; -},{ - - isComponent(el) { - let result = ''; + if (el.tagName == 'TBODY') { + result = { type: 'tbody' }; + } - if (el.tagName == 'TBODY') { - result = { type: 'tbody' }; + return result; } - - return result; - }, - -}); + } +); diff --git a/src/dom_components/model/ComponentTableCell.js b/src/dom_components/model/ComponentTableCell.js index 852cd4353..28dace9c4 100644 --- a/src/dom_components/model/ComponentTableCell.js +++ b/src/dom_components/model/ComponentTableCell.js @@ -1,26 +1,27 @@ const Component = require('./Component'); -module.exports = Component.extend({ - - defaults: { ...Component.prototype.defaults, +module.exports = Component.extend( + { + defaults: { + ...Component.prototype.defaults, type: 'cell', tagName: 'td', - draggable: ['tr'], + draggable: ['tr'] + } }, + { + isComponent(el) { + let result = ''; + const tag = el.tagName; -}, { - isComponent(el) { - let result = ''; - const tag = el.tagName; + if (tag == 'TD' || tag == 'TH') { + result = { + type: 'cell', + tagName: tag.toLowerCase() + }; + } - if (tag == 'TD' || tag == 'TH') { - result = { - type: 'cell', - tagName: tag.toLowerCase() - }; + return result; } - - return result; - }, - -}); + } +); diff --git a/src/dom_components/model/ComponentTableFoot.js b/src/dom_components/model/ComponentTableFoot.js index c6723e899..67ba53b16 100644 --- a/src/dom_components/model/ComponentTableFoot.js +++ b/src/dom_components/model/ComponentTableFoot.js @@ -1,21 +1,22 @@ const ComponentTableBody = require('./ComponentTableBody'); -module.exports = ComponentTableBody.extend({ - - defaults: { ...ComponentTableBody.prototype.defaults, - type: 'tfoot', - tagName: 'tfoot', +module.exports = ComponentTableBody.extend( + { + defaults: { + ...ComponentTableBody.prototype.defaults, + type: 'tfoot', + tagName: 'tfoot' + } }, + { + isComponent(el) { + let result = ''; -},{ - isComponent(el) { - let result = ''; + if (el.tagName == 'TFOOT') { + result = { type: 'tfoot' }; + } - if (el.tagName == 'TFOOT') { - result = { type: 'tfoot' }; + return result; } - - return result; - }, - -}); + } +); diff --git a/src/dom_components/model/ComponentTableHead.js b/src/dom_components/model/ComponentTableHead.js index b7c383dc6..a64595745 100644 --- a/src/dom_components/model/ComponentTableHead.js +++ b/src/dom_components/model/ComponentTableHead.js @@ -1,21 +1,22 @@ const ComponentTableBody = require('./ComponentTableBody'); -module.exports = ComponentTableBody.extend({ - - defaults: { ...ComponentTableBody.prototype.defaults, - type: 'thead', - tagName: 'thead' +module.exports = ComponentTableBody.extend( + { + defaults: { + ...ComponentTableBody.prototype.defaults, + type: 'thead', + tagName: 'thead' + } }, + { + isComponent(el) { + let result = ''; -}, { - isComponent(el) { - let result = ''; + if (el.tagName == 'THEAD') { + result = { type: 'thead' }; + } - if (el.tagName == 'THEAD') { - result = { type: 'thead' }; + return result; } - - return result; - }, - -}); + } +); diff --git a/src/dom_components/model/ComponentTableRow.js b/src/dom_components/model/ComponentTableRow.js index 9558872f3..0981a044a 100644 --- a/src/dom_components/model/ComponentTableRow.js +++ b/src/dom_components/model/ComponentTableRow.js @@ -1,33 +1,34 @@ const Component = require('./Component'); -module.exports = Component.extend({ - - defaults: { ...Component.prototype.defaults, +module.exports = Component.extend( + { + defaults: { + ...Component.prototype.defaults, type: 'row', tagName: 'tr', draggable: ['thead', 'tbody', 'tfoot'], droppable: ['th', 'td'] - }, - - initialize(o, opt) { - Component.prototype.initialize.apply(this, arguments); - - // Clean the row from non cell components - const cells = []; - const components = this.get('components'); - components.each(model => model.is('cell') && cells.push(model)); - components.reset(cells); - } + }, -}, { - isComponent(el) { - let result = ''; + initialize(o, opt) { + Component.prototype.initialize.apply(this, arguments); - if (el.tagName == 'TR') { - result = { type: 'row' }; + // Clean the row from non cell components + const cells = []; + const components = this.get('components'); + components.each(model => model.is('cell') && cells.push(model)); + components.reset(cells); } - - return result; }, + { + isComponent(el) { + let result = ''; + + if (el.tagName == 'TR') { + result = { type: 'row' }; + } -}); + return result; + } + } +); diff --git a/src/dom_components/model/ComponentText.js b/src/dom_components/model/ComponentText.js index 58867f0fd..d91444084 100644 --- a/src/dom_components/model/ComponentText.js +++ b/src/dom_components/model/ComponentText.js @@ -1,11 +1,10 @@ const Component = require('./Component'); module.exports = Component.extend({ - - defaults: { ...Component.prototype.defaults, + defaults: { + ...Component.prototype.defaults, type: 'text', droppable: false, - editable: true, - }, - + editable: true + } }); diff --git a/src/dom_components/model/ComponentTextNode.js b/src/dom_components/model/ComponentTextNode.js index 1cc5d4c8b..3328c3365 100644 --- a/src/dom_components/model/ComponentTextNode.js +++ b/src/dom_components/model/ComponentTextNode.js @@ -1,27 +1,26 @@ var Component = require('./Component'); -module.exports = Component.extend({ +module.exports = Component.extend( + { + defaults: _.extend({}, Component.prototype.defaults, { + droppable: false, + editable: true + }), - defaults: _.extend({}, Component.prototype.defaults, { - droppable: false, - editable: true, - }), - - toHTML() { - return this.get('content'); - }, - -}, { - - isComponent(el) { - var result = ''; - if(el.nodeType === 3){ - result = { - type: 'textnode', - content: el.textContent - }; + toHTML() { + return this.get('content'); } - return result; }, - -}); + { + isComponent(el) { + var result = ''; + if (el.nodeType === 3) { + result = { + type: 'textnode', + content: el.textContent + }; + } + return result; + } + } +); diff --git a/src/dom_components/model/ComponentVideo.js b/src/dom_components/model/ComponentVideo.js index 45913b4d1..f7ef96f41 100644 --- a/src/dom_components/model/ComponentVideo.js +++ b/src/dom_components/model/ComponentVideo.js @@ -1,12 +1,12 @@ -var Component = require('./ComponentImage'); -var OComponent = require('./Component'); +const Component = require('./ComponentImage'); +const OComponent = require('./Component'); +const yt = 'yt'; +const vi = 'vi'; -var yt = 'yt'; -var vi = 'vi'; - -module.exports = Component.extend({ - - defaults: _.extend({}, Component.prototype.defaults, { +module.exports = Component.extend( + { + defaults: { + ...Component.prototype.defaults, type: 'video', tagName: 'video', videoId: '', @@ -20,297 +20,295 @@ module.exports = Component.extend({ controls: 1, color: '', sources: [], - attributes:{allowfullscreen:'allowfullscreen'}, - toolbar: OComponent.prototype.defaults.toolbar, - }), + attributes: { allowfullscreen: 'allowfullscreen' }, + toolbar: OComponent.prototype.defaults.toolbar + }, - initialize(o, opt) { - var traits = []; - var prov = this.get('provider'); - switch (prov) { - case yt: - traits = this.getYoutubeTraits(); - break; - case vi: - traits = this.getVimeoTraits(); - break; - default: - traits = this.getSourceTraits(); - } - if(this.get('src')) - this.parseFromSrc(); - this.set('traits', traits); - Component.prototype.initialize.apply(this, arguments); - this.listenTo(this, 'change:provider', this.updateTraits); - this.listenTo(this, 'change:videoId', this.updateSrc); - }, + initialize(o, opt) { + var traits = []; + var prov = this.get('provider'); + switch (prov) { + case yt: + traits = this.getYoutubeTraits(); + break; + case vi: + traits = this.getVimeoTraits(); + break; + default: + traits = this.getSourceTraits(); + } + if (this.get('src')) this.parseFromSrc(); + this.set('traits', traits); + Component.prototype.initialize.apply(this, arguments); + this.listenTo(this, 'change:provider', this.updateTraits); + this.listenTo(this, 'change:videoId', this.updateSrc); + }, - /** - * Set attributes by src string - */ - parseFromSrc() { - var prov = this.get('provider'); - var uri = this.parseUri(this.get('src')); - var qr = uri.query; - switch (prov) { - case yt: case vi: - var videoId = uri.pathname.split('/').pop(); - this.set('videoId', videoId); - if(qr.autoplay) - this.set('autoplay', 1); - if(qr.loop) - this.set('loop', 1); - if(parseInt(qr.controls) === 0) - this.set('controls', 0); - if(qr.color) - this.set('color', qr.color); - break; - default: - } - }, + initToolbar(...args) { + OComponent.prototype.initToolbar.apply(this, args); + }, - /** - * Update src on change of video ID - * @private - */ - updateSrc() { - var prov = this.get('provider'); - switch (prov) { - case yt: - this.set('src',this.getYoutubeSrc()); - break; - case vi: - this.set('src',this.getVimeoSrc()); - break; - } - }, + /** + * Set attributes by src string + */ + parseFromSrc() { + var prov = this.get('provider'); + var uri = this.parseUri(this.get('src')); + var qr = uri.query; + switch (prov) { + case yt: + case vi: + var videoId = uri.pathname.split('/').pop(); + this.set('videoId', videoId); + if (qr.autoplay) this.set('autoplay', 1); + if (qr.loop) this.set('loop', 1); + if (parseInt(qr.controls) === 0) this.set('controls', 0); + if (qr.color) this.set('color', qr.color); + break; + default: + } + }, - /** - * Returns object of attributes for HTML - * @return {Object} - * @private - */ - getAttrToHTML(...args) { - var attr = Component.prototype.getAttrToHTML.apply(this, args); - var prov = this.get('provider'); - switch (prov) { - case yt: case vi: - break; - default: - if(this.get('loop')) - attr.loop = 'loop'; - if(this.get('autoplay')) - attr.autoplay = 'autoplay'; - if(this.get('controls')) - attr.controls = 'controls'; - } - return attr; - }, + /** + * Update src on change of video ID + * @private + */ + updateSrc() { + var prov = this.get('provider'); + switch (prov) { + case yt: + this.set('src', this.getYoutubeSrc()); + break; + case vi: + this.set('src', this.getVimeoSrc()); + break; + } + }, - /** - * Update traits by provider - * @private - */ - updateTraits() { - var prov = this.get('provider'); - var traits = this.getSourceTraits(); - switch (prov) { - case yt: - this.set('tagName', 'iframe'); - traits = this.getYoutubeTraits(); - break; - case vi: - this.set('tagName', 'iframe'); - traits = this.getVimeoTraits(); - break; - default: - this.set('tagName', 'video'); - } - this.loadTraits(traits); - this.sm.trigger('change:selectedComponent'); - }, + /** + * Returns object of attributes for HTML + * @return {Object} + * @private + */ + getAttrToHTML(...args) { + var attr = Component.prototype.getAttrToHTML.apply(this, args); + var prov = this.get('provider'); + switch (prov) { + case yt: + case vi: + break; + default: + if (this.get('loop')) attr.loop = 'loop'; + if (this.get('autoplay')) attr.autoplay = 'autoplay'; + if (this.get('controls')) attr.controls = 'controls'; + } + return attr; + }, - // Listen provider change and switch traits, in TraitView listen traits change + /** + * Update traits by provider + * @private + */ + updateTraits() { + var prov = this.get('provider'); + var traits = this.getSourceTraits(); + switch (prov) { + case yt: + this.set('tagName', 'iframe'); + traits = this.getYoutubeTraits(); + break; + case vi: + this.set('tagName', 'iframe'); + traits = this.getVimeoTraits(); + break; + default: + this.set('tagName', 'video'); + } + this.loadTraits(traits); + this.sm.trigger('change:selectedComponent'); + }, - /** - * Return the provider trait - * @return {Object} - * @private - */ - getProviderTrait() { - return { - type: 'select', - label: 'Provider', - name: 'provider', - changeProp: 1, - value: this.get('provider'), - options: [ - {value: 'so', name: 'HTML5 Source'}, - {value: yt, name: 'Youtube'}, - {value: vi, name: 'Vimeo'} - ] - }; - }, + // Listen provider change and switch traits, in TraitView listen traits change - /** - * Return traits for the source provider - * @return {Array} - * @private - */ - getSourceTraits() { - return [ - this.getProviderTrait(), { - label: 'Source', - name: 'src', - placeholder: 'eg. ./media/video.mp4', - changeProp: 1, - }, - this.getAutoplayTrait(), - this.getLoopTrait(), - this.getControlsTrait()]; - }, - /** - * Return traits for the source provider - * @return {Array} - * @private - */ - getYoutubeTraits() { - return [ - this.getProviderTrait(), { - label: 'Video ID', - name: 'videoId', - placeholder: 'eg. jNQXAC9IVRw', + /** + * Return the provider trait + * @return {Object} + * @private + */ + getProviderTrait() { + return { + type: 'select', + label: 'Provider', + name: 'provider', changeProp: 1, - }, - this.getAutoplayTrait(), - this.getLoopTrait(), - this.getControlsTrait() - ]; - }, + value: this.get('provider'), + options: [ + { value: 'so', name: 'HTML5 Source' }, + { value: yt, name: 'Youtube' }, + { value: vi, name: 'Vimeo' } + ] + }; + }, - /** - * Return traits for the source provider - * @return {Array} - * @private - */ - getVimeoTraits() { - return [ - this.getProviderTrait(), { - label: 'Video ID', - name: 'videoId', - placeholder: 'eg. 123456789', - changeProp: 1, - },{ - label: 'Color', - name: 'color', - placeholder: 'eg. FF0000', - changeProp: 1, - }, - this.getAutoplayTrait(), - this.getLoopTrait(), - this.getControlsTrait()]; - }, + /** + * Return traits for the source provider + * @return {Array} + * @private + */ + getSourceTraits() { + return [ + this.getProviderTrait(), + { + label: 'Source', + name: 'src', + placeholder: 'eg. ./media/video.mp4', + changeProp: 1 + }, + this.getAutoplayTrait(), + this.getLoopTrait(), + this.getControlsTrait() + ]; + }, + /** + * Return traits for the source provider + * @return {Array} + * @private + */ + getYoutubeTraits() { + return [ + this.getProviderTrait(), + { + label: 'Video ID', + name: 'videoId', + placeholder: 'eg. jNQXAC9IVRw', + changeProp: 1 + }, + this.getAutoplayTrait(), + this.getLoopTrait(), + this.getControlsTrait() + ]; + }, - /** - * Return object trait - * @return {Object} - * @private - */ - getAutoplayTrait() { - return { - type: 'checkbox', - label: 'Autoplay', - name: 'autoplay', - changeProp: 1, - }; - }, + /** + * Return traits for the source provider + * @return {Array} + * @private + */ + getVimeoTraits() { + return [ + this.getProviderTrait(), + { + label: 'Video ID', + name: 'videoId', + placeholder: 'eg. 123456789', + changeProp: 1 + }, + { + label: 'Color', + name: 'color', + placeholder: 'eg. FF0000', + changeProp: 1 + }, + this.getAutoplayTrait(), + this.getLoopTrait(), + this.getControlsTrait() + ]; + }, - /** - * Return object trait - * @return {Object} - * @private - */ - getLoopTrait() { - return { - type: 'checkbox', - label: 'Loop', - name: 'loop', - changeProp: 1, - }; - }, + /** + * Return object trait + * @return {Object} + * @private + */ + getAutoplayTrait() { + return { + type: 'checkbox', + label: 'Autoplay', + name: 'autoplay', + changeProp: 1 + }; + }, - /** - * Return object trait - * @return {Object} - * @private - */ - getControlsTrait() { - return { - type: 'checkbox', - label: 'Controls', - name: 'controls', - changeProp: 1, - }; - }, + /** + * Return object trait + * @return {Object} + * @private + */ + getLoopTrait() { + return { + type: 'checkbox', + label: 'Loop', + name: 'loop', + changeProp: 1 + }; + }, + /** + * Return object trait + * @return {Object} + * @private + */ + getControlsTrait() { + return { + type: 'checkbox', + label: 'Controls', + name: 'controls', + changeProp: 1 + }; + }, - /** - * Returns url to youtube video - * @return {string} - * @private - */ - getYoutubeSrc() { - var url = this.get('ytUrl'); - url += this.get('videoId') + '?'; - url += this.get('autoplay') ? '&autoplay=1' : ''; - url += !this.get('controls') ? '&controls=0' : ''; - url += this.get('loop') ? '&loop=1' : ''; - return url; - }, + /** + * Returns url to youtube video + * @return {string} + * @private + */ + getYoutubeSrc() { + var url = this.get('ytUrl'); + url += this.get('videoId') + '?'; + url += this.get('autoplay') ? '&autoplay=1' : ''; + url += !this.get('controls') ? '&controls=0' : ''; + url += this.get('loop') ? '&loop=1' : ''; + return url; + }, - /** - * Returns url to vimeo video - * @return {string} - * @private - */ - getVimeoSrc() { - var url = this.get('viUrl'); - url += this.get('videoId') + '?'; - url += this.get('autoplay') ? '&autoplay=1' : ''; - url += this.get('loop') ? '&loop=1' : ''; - url += !this.get('controls') ? '&title=0&portrait=0&badge=0' : ''; - url += this.get('color') ? '&color=' + this.get('color') : ''; - return url; + /** + * Returns url to vimeo video + * @return {string} + * @private + */ + getVimeoSrc() { + var url = this.get('viUrl'); + url += this.get('videoId') + '?'; + url += this.get('autoplay') ? '&autoplay=1' : ''; + url += this.get('loop') ? '&loop=1' : ''; + url += !this.get('controls') ? '&title=0&portrait=0&badge=0' : ''; + url += this.get('color') ? '&color=' + this.get('color') : ''; + return url; + } }, - -},{ - - /** - * Detect if the passed element is a valid component. - * In case the element is valid an object abstracted - * from the element will be returned - * @param {HTMLElement} - * @return {Object} - * @private - */ - isComponent(el) { - var result = ''; - var isYtProv = /youtube\.com\/embed/.test(el.src); - var isViProv = /player\.vimeo\.com\/video/.test(el.src); - var isExtProv = isYtProv || isViProv; - if(el.tagName == 'VIDEO' || - (el.tagName == 'IFRAME' && isExtProv) ){ - result = {type: 'video'}; - if(el.src) - result.src = el.src; - if(isExtProv){ - if(isYtProv) - result.provider = yt; - else if(isViProv) - result.provider = vi; + { + /** + * Detect if the passed element is a valid component. + * In case the element is valid an object abstracted + * from the element will be returned + * @param {HTMLElement} + * @return {Object} + * @private + */ + isComponent(el) { + var result = ''; + var isYtProv = /youtube\.com\/embed/.test(el.src); + var isViProv = /player\.vimeo\.com\/video/.test(el.src); + var isExtProv = isYtProv || isViProv; + if (el.tagName == 'VIDEO' || (el.tagName == 'IFRAME' && isExtProv)) { + result = { type: 'video' }; + if (el.src) result.src = el.src; + if (isExtProv) { + if (isYtProv) result.provider = yt; + else if (isViProv) result.provider = vi; + } } + return result; } - return result; - }, - -}); + } +); diff --git a/src/dom_components/model/Components.js b/src/dom_components/model/Components.js index 71a511370..e3df908a0 100644 --- a/src/dom_components/model/Components.js +++ b/src/dom_components/model/Components.js @@ -3,50 +3,43 @@ import { isEmpty } from 'underscore'; const Backbone = require('backbone'); module.exports = Backbone.Collection.extend({ - initialize(models, opt) { - this.on('add', this.onAdd); this.config = opt && opt.config ? opt.config : null; // Inject editor - if(opt && (opt.sm || opt.em)) - this.editor = opt.sm || opt.em; + if (opt && (opt.sm || opt.em)) this.editor = opt.sm || opt.em; - this.model = (attrs, options) => { + this.model = (attrs, options) => { var model; - if(!options.sm && opt && opt.sm) - options.sm = opt.sm; + if (!options.sm && opt && opt.sm) options.sm = opt.sm; - if(!options.em && opt && opt.em) - options.em = opt.em; + if (!options.em && opt && opt.em) options.em = opt.em; - if(opt && opt.config) - options.config = opt.config; + if (opt && opt.config) options.config = opt.config; - if(opt && opt.componentTypes) - options.componentTypes = opt.componentTypes; + if (opt && opt.componentTypes) + options.componentTypes = opt.componentTypes; var df = opt.componentTypes; for (var it = 0; it < df.length; it++) { var dfId = df[it].id; - if(dfId == attrs.type) { + if (dfId == attrs.type) { model = df[it].model; break; } } - if(!model) { + if (!model) { // get the last one model = df[df.length - 1].model; } return new model(attrs, options); }; - }, add(models, opt = {}) { @@ -57,7 +50,7 @@ module.exports = Backbone.Collection.extend({ var cssc = this.editor.get('CssComposer'); if (parsed.css && cssc) { - var {avoidUpdateStyle} = opt; + var { avoidUpdateStyle } = opt; var added = cssc.addCollection(parsed.css, { extend: 1, avoidUpdateStyle @@ -73,15 +66,19 @@ module.exports = Backbone.Collection.extend({ const style = model.get('style'); const avoidInline = em && em.getConfig('avoidInlineStyle'); - if (!isEmpty(style) && !avoidInline && - em && em.get && em.get('Config').forceClass) { - var cssC = this.editor.get('CssComposer'); - var newClass = this.editor.get('SelectorManager').add(model.cid); - model.set({style:{}}); - model.get('classes').add(newClass); - var rule = cssC.add(newClass); - rule.set('style', style); + if ( + !isEmpty(style) && + !avoidInline && + em && + em.get && + em.get('Config').forceClass + ) { + var cssC = this.editor.get('CssComposer'); + var newClass = this.editor.get('SelectorManager').add(model.cid); + model.set({ style: {} }); + model.get('classes').add(newClass); + var rule = cssC.add(newClass); + rule.set('style', style); } - }, - + } }); diff --git a/src/dom_components/model/Toolbar.js b/src/dom_components/model/Toolbar.js index 499b70025..94367142f 100644 --- a/src/dom_components/model/Toolbar.js +++ b/src/dom_components/model/Toolbar.js @@ -1,4 +1,4 @@ var Backbone = require('backbone'); var ToolbarButton = require('./ToolbarButton'); -module.exports = Backbone.Collection.extend({model: ToolbarButton}); +module.exports = Backbone.Collection.extend({ model: ToolbarButton }); diff --git a/src/dom_components/model/ToolbarButton.js b/src/dom_components/model/ToolbarButton.js index 5caa20285..b4145ed05 100644 --- a/src/dom_components/model/ToolbarButton.js +++ b/src/dom_components/model/ToolbarButton.js @@ -1,10 +1,8 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - defaults: { - command: '', - attributes: {}, - }, - + command: '', + attributes: {} + } }); diff --git a/src/dom_components/view/ComponentImageView.js b/src/dom_components/view/ComponentImageView.js index d4f3f1707..4fc8927e8 100644 --- a/src/dom_components/view/ComponentImageView.js +++ b/src/dom_components/view/ComponentImageView.js @@ -2,12 +2,11 @@ var Backbone = require('backbone'); var ComponentView = require('./ComponentView'); module.exports = ComponentView.extend({ - tagName: 'img', events: { - 'dblclick': 'openModal', - 'click': 'initResize', + dblclick: 'openModal', + click: 'initResize' }, initialize(o) { @@ -19,21 +18,43 @@ module.exports = ComponentView.extend({ const config = this.config; config.modal && (this.modal = config.modal); config.am && (this.am = config.am); + this.fetchFile(); }, + /** + * Fetch file if exists + */ + fetchFile() { + const model = this.model; + const file = model.get('file'); + + if (file) { + const fu = this.em.get('AssetManager').FileUploader(); + fu.uploadFile( + { + dataTransfer: { files: [file] } + }, + res => { + const obj = res && res.data && res.data[0]; + const src = obj && obj.src; + src && model.set({ src }); + } + ); + model.set('file', ''); + } + }, /** * Update src attribute * @private * */ updateSrc() { - const src = this.model.get("src"); + const src = this.model.get('src'); const el = this.$el; el.attr('src', src); el[src ? 'removeClass' : 'addClass'](this.classEmpty); }, - /** * Open dialog for image changing * @param {Object} e Event @@ -43,7 +64,7 @@ module.exports = ComponentView.extend({ var em = this.opts.config.em; var editor = em ? em.get('Editor') : ''; - if(editor && this.model.get('editable')) { + if (editor && this.model.get('editable')) { editor.runCommand('open-assets', { target: this.model, onSelect() { @@ -54,17 +75,16 @@ module.exports = ComponentView.extend({ } }, - render() { this.updateAttributes(); this.updateClasses(); var actCls = this.$el.attr('class') || ''; - if(!this.model.get('src')) + if (!this.model.get('src')) this.$el.attr('class', (actCls + ' ' + this.classEmpty).trim()); // Avoid strange behaviours while try to drag this.$el.attr('onmousedown', 'return false'); return this; - }, + } }); diff --git a/src/dom_components/view/ComponentLinkView.js b/src/dom_components/view/ComponentLinkView.js index aabf8f3db..3c6dbcaec 100644 --- a/src/dom_components/view/ComponentLinkView.js +++ b/src/dom_components/view/ComponentLinkView.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var ComponentView = require('./ComponentTextView'); module.exports = ComponentView.extend({ - render(...args) { ComponentView.prototype.render.apply(this, args); @@ -11,6 +10,5 @@ module.exports = ComponentView.extend({ this.el.addEventListener('click', this.prevDef, true); return this; - }, - + } }); diff --git a/src/dom_components/view/ComponentMapView.js b/src/dom_components/view/ComponentMapView.js index 54b5e76e5..92f6d7c12 100644 --- a/src/dom_components/view/ComponentMapView.js +++ b/src/dom_components/view/ComponentMapView.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var ComponentView = require('./ComponentImageView'); module.exports = ComponentView.extend({ - tagName: 'div', events: {}, @@ -21,8 +20,8 @@ module.exports = ComponentView.extend({ }, getIframe() { - if(!this.iframe){ - var ifrm = document.createElement("iframe"); + if (!this.iframe) { + var ifrm = document.createElement('iframe'); ifrm.src = this.model.get('src'); ifrm.frameBorder = 0; ifrm.style.height = '100%'; @@ -38,6 +37,5 @@ module.exports = ComponentView.extend({ this.updateClasses(); this.el.appendChild(this.getIframe()); return this; - }, - + } }); diff --git a/src/dom_components/view/ComponentScriptView.js b/src/dom_components/view/ComponentScriptView.js index 9e2d7debd..5a546a159 100644 --- a/src/dom_components/view/ComponentScriptView.js +++ b/src/dom_components/view/ComponentScriptView.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var ComponentView = require('./ComponentImageView'); module.exports = ComponentView.extend({ - tagName: 'script', events: {}, @@ -15,20 +14,35 @@ module.exports = ComponentView.extend({ var content = ''; // If it's an external script - if(src) { + if (src) { var onload = model.get('onload'); var svar = 'script' + scriptCount; var svarNext = 'script' + (scriptCount + 1); - content = "var "+svar+" = document.createElement('script');\n" + - svar+".onload = function(){\n" + - (onload ? onload + "();\n" : '') + - "typeof "+svarNext+"Start == 'function' && "+svarNext+"Start();\n" + - "};\n" + - svar+".src = '" + src + "';\n"+ - "function "+svar+"Start() { document.body.appendChild("+svar+"); };\n" + - (!scriptCount ? svar+"Start();" : ''); - if(em){ - em.set('scriptCount', scriptCount + 1); + content = + 'var ' + + svar + + " = document.createElement('script');\n" + + svar + + '.onload = function(){\n' + + (onload ? onload + '();\n' : '') + + 'typeof ' + + svarNext + + "Start == 'function' && " + + svarNext + + 'Start();\n' + + '};\n' + + svar + + ".src = '" + + src + + "';\n" + + 'function ' + + svar + + 'Start() { document.body.appendChild(' + + svar + + '); };\n' + + (!scriptCount ? svar + 'Start();' : ''); + if (em) { + em.set('scriptCount', scriptCount + 1); } } else { content = model.get('content'); @@ -36,6 +50,5 @@ module.exports = ComponentView.extend({ this.el.innerHTML = content; return this; - }, - + } }); diff --git a/src/dom_components/view/ComponentSvgView.js b/src/dom_components/view/ComponentSvgView.js index 91a40a8af..4e54232ed 100644 --- a/src/dom_components/view/ComponentSvgView.js +++ b/src/dom_components/view/ComponentSvgView.js @@ -1,9 +1,7 @@ const ComponentView = require('./ComponentView'); module.exports = ComponentView.extend({ - _createElement: function(tagName) { return document.createElementNS('http://www.w3.org/2000/svg', tagName); } - }); diff --git a/src/dom_components/view/ComponentTableView.js b/src/dom_components/view/ComponentTableView.js index 55e290a24..56e4aa733 100644 --- a/src/dom_components/view/ComponentTableView.js +++ b/src/dom_components/view/ComponentTableView.js @@ -2,5 +2,5 @@ var Backbone = require('backbone'); var ComponentView = require('./ComponentView'); module.exports = ComponentView.extend({ - events: {}, + events: {} }); diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index 2471e5645..c9d34644c 100644 --- a/src/dom_components/view/ComponentTextView.js +++ b/src/dom_components/view/ComponentTextView.js @@ -1,11 +1,10 @@ -import {on, off} from 'utils/mixins' +import { on, off } from 'utils/mixins'; const ComponentView = require('./ComponentView'); module.exports = ComponentView.extend({ - events: { - 'dblclick': 'enableEditing', + dblclick: 'enableEditing' }, initialize(o) { @@ -76,10 +75,10 @@ module.exports = ComponentView.extend({ removable: 0, draggable: 0, copyable: 0, - toolbar: '', - }) + toolbar: '' + }); model.get('components').each(model => clean(model)); - } + }; // Avoid re-render on reset with silent option model.trigger('change:content', model); @@ -108,7 +107,7 @@ module.exports = ComponentView.extend({ */ toggleEvents(enable) { var method = enable ? 'on' : 'off'; - const mixins = {on, off}; + const mixins = { on, off }; // The ownerDocument is from the frame var elDocs = [this.el.ownerDocument, document]; @@ -118,6 +117,5 @@ module.exports = ComponentView.extend({ // Avoid closing edit mode on component click this.$el.off('mousedown', this.disablePropagation); this.$el[method]('mousedown', this.disablePropagation); - }, - + } }); diff --git a/src/dom_components/view/ComponentVideoView.js b/src/dom_components/view/ComponentVideoView.js index 9de803aa4..775c99441 100644 --- a/src/dom_components/view/ComponentVideoView.js +++ b/src/dom_components/view/ComponentVideoView.js @@ -3,7 +3,6 @@ var ComponentView = require('./ComponentImageView'); var OComponentView = require('./ComponentView'); module.exports = ComponentView.extend({ - tagName: 'div', events: {}, @@ -11,7 +10,11 @@ module.exports = ComponentView.extend({ initialize(o) { OComponentView.prototype.initialize.apply(this, arguments); this.listenTo(this.model, 'change:src', this.updateSrc); - this.listenTo(this.model, 'change:loop change:autoplay change:controls change:color', this.updateVideo); + this.listenTo( + this.model, + 'change:loop change:autoplay change:controls change:color', + this.updateVideo + ); this.listenTo(this.model, 'change:provider', this.updateProvider); }, @@ -52,7 +55,8 @@ module.exports = ComponentView.extend({ var videoEl = this.videoEl; var md = this.model; switch (prov) { - case 'yt': case 'vi': + case 'yt': + case 'vi': this.model.trigger('change:videoId'); break; default: @@ -115,6 +119,5 @@ module.exports = ComponentView.extend({ var prov = this.model.get('provider'); this.el.appendChild(this.renderByProvider(prov)); return this; - }, - + } }); diff --git a/src/dom_components/view/ComponentView.js b/src/dom_components/view/ComponentView.js index 550bf0ac6..3c6162e74 100644 --- a/src/dom_components/view/ComponentView.js +++ b/src/dom_components/view/ComponentView.js @@ -3,7 +3,6 @@ import { isArray } from 'underscore'; const ComponentsView = require('./ComponentsView'); module.exports = Backbone.View.extend({ - className() { return this.getClasses(); }, @@ -64,7 +63,6 @@ module.exports = Backbone.View.extend({ } }, - /** * Import, if possible, classes inside main container * @private @@ -72,14 +70,13 @@ module.exports = Backbone.View.extend({ importClasses() { var clm = this.config.em.get('SelectorManager'); - if(clm){ + if (clm) { this.model.get('classes').each(m => { - clm.add(m.get('name')); + clm.add(m.get('name')); }); } }, - /** * Fires on state update. If the state is not empty will add a helper class * @param {Event} e @@ -89,14 +86,13 @@ module.exports = Backbone.View.extend({ var cl = 'hc-state'; var state = this.model.get('state'); - if(state){ + if (state) { this.$el.addClass(cl); - }else{ + } else { this.$el.removeClass(cl); } }, - /** * Update item on status change * @param {Event} e @@ -114,17 +110,19 @@ module.exports = Backbone.View.extend({ var cls = ''; switch (status) { - case 'selected': - cls = `${actualCls} ${selectedCls}`; - break; - case 'selected-parent': - cls = `${actualCls} ${selectedParentCls}`; - break; - case 'freezed': - cls = `${actualCls} ${freezedCls}`; - break; - default: - this.$el.removeClass(`${selectedCls} ${selectedParentCls} ${freezedCls}`); + case 'selected': + cls = `${actualCls} ${selectedCls}`; + break; + case 'selected-parent': + cls = `${actualCls} ${selectedParentCls}`; + break; + case 'freezed': + cls = `${actualCls} ${freezedCls}`; + break; + default: + this.$el.removeClass( + `${selectedCls} ${selectedParentCls} ${freezedCls}` + ); } cls = cls.trim(); @@ -134,7 +132,6 @@ module.exports = Backbone.View.extend({ } }, - /** * Update highlight attribute * @private @@ -144,7 +141,6 @@ module.exports = Backbone.View.extend({ this.setAttribute('data-highlightable', hl ? 1 : ''); }, - /** * Update style attribute * @private @@ -161,13 +157,15 @@ module.exports = Backbone.View.extend({ } }, - /** * Update classe attribute * @private * */ updateClasses() { - const str = this.model.get('classes').pluck('name').join(' '); + const str = this.model + .get('classes') + .pluck('name') + .join(' '); this.setAttribute('class', str); // Regenerate status class @@ -192,8 +190,8 @@ module.exports = Backbone.View.extend({ * @private * */ getClasses() { - var attr = this.model.get("attributes"), - classes = attr['class'] || []; + var attr = this.model.get('attributes'), + classes = attr['class'] || []; classes = isArray(classes) ? classes : [classes]; if (classes.length) { @@ -209,7 +207,7 @@ module.exports = Backbone.View.extend({ * */ updateAttributes() { const model = this.model; - const attrs = {} + const attrs = {}; const attr = model.get('attributes'); const src = model.get('src'); @@ -250,7 +248,7 @@ module.exports = Backbone.View.extend({ } var em = this.em; - if(em) { + if (em) { var canvas = em.get('Canvas'); canvas.getCanvasView().updateScript(this); } @@ -301,14 +299,14 @@ module.exports = Backbone.View.extend({ const view = new ComponentsView({ collection: this.model.get('components'), config: this.config, - componentTypes: this.opts.componentTypes, + componentTypes: this.opts.componentTypes }); view.render(container); this.childrenView = view; const childNodes = Array.prototype.slice.call(view.el.childNodes); - for (var i = 0, len = childNodes.length ; i < len; i++) { + for (var i = 0, len = childNodes.length; i < len; i++) { container.appendChild(childNodes.shift()); } @@ -341,6 +339,5 @@ module.exports = Backbone.View.extend({ this.renderChildren(); this.updateScript(); return this; - }, - + } }); diff --git a/src/dom_components/view/ComponentsView.js b/src/dom_components/view/ComponentsView.js index 7408104fb..647952c03 100644 --- a/src/dom_components/view/ComponentsView.js +++ b/src/dom_components/view/ComponentsView.js @@ -1,7 +1,6 @@ -import { isUndefined } from 'underscore' +import { isUndefined } from 'underscore'; module.exports = Backbone.View.extend({ - initialize(o) { this.opts = o || {}; this.config = o.config || {}; @@ -38,10 +37,9 @@ module.exports = Backbone.View.extend({ * @private * */ addToCollection(model, fragmentEl, index) { - if(!this.compView) - this.compView = require('./ComponentView'); - var fragment = fragmentEl || null, - viewObject = this.compView; + if (!this.compView) this.compView = require('./ComponentView'); + var fragment = fragmentEl || null, + viewObject = this.compView; var dt = this.opts.componentTypes; @@ -49,7 +47,7 @@ module.exports = Backbone.View.extend({ for (var it = 0; it < dt.length; it++) { var dtId = dt[it].id; - if(dtId == type) { + if (dtId == type) { viewObject = dt[it].view; break; } @@ -59,16 +57,16 @@ module.exports = Backbone.View.extend({ var view = new viewObject({ model, config: this.config, - componentTypes: dt, + componentTypes: dt }); - var rendered = view.render().el; - if(view.model.get('type') == 'textnode') - rendered = document.createTextNode(view.model.get('content')); + var rendered = view.render().el; + if (view.model.get('type') == 'textnode') + rendered = document.createTextNode(view.model.get('content')); if (fragment) { fragment.appendChild(rendered); } else { - const parent = this.parentEl; + const parent = this.parentEl; const children = parent.childNodes; if (!isUndefined(index)) { @@ -102,11 +100,10 @@ module.exports = Backbone.View.extend({ render(parent) { const el = this.el; const frag = document.createDocumentFragment(); - this.parentEl = parent || this.el; + this.parentEl = parent || this.el; this.collection.each(model => this.addToCollection(model, frag)); el.innerHTML = ''; el.appendChild(frag); return this; } - }); diff --git a/src/dom_components/view/ToolbarButtonView.js b/src/dom_components/view/ToolbarButtonView.js index af9fc41b8..e49468176 100644 --- a/src/dom_components/view/ToolbarButtonView.js +++ b/src/dom_components/view/ToolbarButtonView.js @@ -1,8 +1,12 @@ var Backbone = require('backbone'); module.exports = Backbone.View.extend({ - events: { - 'mousedown': 'handleClick', + events() { + return ( + this.model.get('events') || { + mousedown: 'handleClick' + } + ); }, attributes() { @@ -11,12 +15,16 @@ module.exports = Backbone.View.extend({ initialize(opts) { this.editor = opts.config.editor; - }, + }, handleClick(event) { event.preventDefault(); event.stopPropagation(); - const opts = {event}; + this.execCommand(event); + }, + + execCommand(event) { + const opts = { event }; const command = this.model.get('command'); const editor = this.editor; @@ -33,6 +41,5 @@ module.exports = Backbone.View.extend({ var config = this.editor.getConfig(); this.el.className += ' ' + config.stylePrefix + 'toolbar-item'; return this; - }, - + } }); diff --git a/src/dom_components/view/ToolbarView.js b/src/dom_components/view/ToolbarView.js index b76cb4931..a984020d5 100644 --- a/src/dom_components/view/ToolbarView.js +++ b/src/dom_components/view/ToolbarView.js @@ -3,12 +3,10 @@ var DomainViews = require('domain_abstract/view/DomainViews'); var ToolbarButtonView = require('./ToolbarButtonView'); module.exports = DomainViews.extend({ - itemView: ToolbarButtonView, initialize(opts) { - this.config = {editor: opts.editor || ''}; + this.config = { editor: opts.editor || '' }; this.listenTo(this.collection, 'reset', this.render); - }, - + } }); diff --git a/src/domain_abstract/model/Styleable.js b/src/domain_abstract/model/Styleable.js index a0d379a8b..217b65642 100644 --- a/src/domain_abstract/model/Styleable.js +++ b/src/domain_abstract/model/Styleable.js @@ -4,7 +4,6 @@ import ParserHtml from 'parser/model/ParserHtml'; const parseStyle = ParserHtml().parseStyle; export default { - parseStyle, /** @@ -14,10 +13,9 @@ export default { * @return {Object} */ extendStyle(prop) { - return { ...this.getStyle(), ...prop}; + return { ...this.getStyle(), ...prop }; }, - /** * Get style object * @return {Object} @@ -26,7 +24,6 @@ export default { return { ...this.get('style') }; }, - /** * Set new style object * @param {Object|string} prop @@ -47,7 +44,6 @@ export default { return propNew; }, - /** * Add style property * @param {Object|string} prop @@ -69,7 +65,6 @@ export default { this.setStyle(prop, opts); }, - /** * Remove style property * @param {string} prop @@ -80,7 +75,6 @@ export default { this.setStyle(style); }, - /** * Returns string of style properties * @param {Object} [opts={}] Options @@ -98,5 +92,5 @@ export default { } return result.join(''); - }, -} + } +}; diff --git a/src/domain_abstract/model/TypeableCollection.js b/src/domain_abstract/model/TypeableCollection.js index 41394998c..6a207d993 100644 --- a/src/domain_abstract/model/TypeableCollection.js +++ b/src/domain_abstract/model/TypeableCollection.js @@ -40,13 +40,15 @@ export default { for (let i = 0; i < types.length; i++) { const type = types[i]; let typeFound = type.isType(value); - typeFound = typeof typeFound == 'boolean' && typeFound ? - {type: type.id} : typeFound; + typeFound = + typeof typeFound == 'boolean' && typeFound + ? { type: type.id } + : typeFound; if (typeFound) { return { type, - attributes: typeFound, + attributes: typeFound }; } } @@ -54,8 +56,8 @@ export default { // If, for any reason, the type is not found it'll return the base one return { type: this.getBaseType(), - attributes: value, - } + attributes: value + }; }, /** @@ -109,7 +111,7 @@ export default { const baseType = this.getBaseType(); const ModelInst = type ? type.model : baseType.model; const ViewInst = type ? type.view : baseType.view; - let {model, view, isType} = definition; + let { model, view, isType } = definition; model = model instanceof Model ? model : ModelInst.extend(model || {}); view = view instanceof View ? view : ViewInst.extend(view || {}); @@ -121,12 +123,14 @@ export default { definition.id = id; definition.model = model; definition.view = view; - definition.isType = isType || function(value) { - if (value && value.type == id) { - return true; - } - }; + definition.isType = + isType || + function(value) { + if (value && value.type == id) { + return true; + } + }; this.getTypes().unshift(definition); } } -} +}; diff --git a/src/domain_abstract/ui/Input.js b/src/domain_abstract/ui/Input.js index 4bb9ad3fc..4677f3881 100644 --- a/src/domain_abstract/ui/Input.js +++ b/src/domain_abstract/ui/Input.js @@ -1,17 +1,14 @@ const $ = Backbone.$; module.exports = Backbone.View.extend({ - events: { - 'change': 'handleChange', + change: 'handleChange' }, - template() { return ``; }, - inputClass() { return `${this.ppfx}field`; }, @@ -20,7 +17,6 @@ module.exports = Backbone.View.extend({ return `${this.ppfx}input-holder`; }, - initialize(opts = {}) { const ppfx = opts.ppfx || ''; this.opts = opts; @@ -29,7 +25,6 @@ module.exports = Backbone.View.extend({ this.listenTo(this.model, 'change:value', this.handleModelChange); }, - /** * Fired when the element of the property is updated */ @@ -37,7 +32,6 @@ module.exports = Backbone.View.extend({ this.model.trigger('el:change'); }, - /** * Set value to the input element * @param {string} value @@ -49,7 +43,6 @@ module.exports = Backbone.View.extend({ input && (input.value = val); }, - /** * Updates the view when the model is changed * */ @@ -57,7 +50,6 @@ module.exports = Backbone.View.extend({ this.setValue(value, opts); }, - /** * Handled when the view is changed */ @@ -67,7 +59,6 @@ module.exports = Backbone.View.extend({ this.elementUpdated(); }, - /** * Get the input element * @return {HTMLElement} @@ -81,7 +72,6 @@ module.exports = Backbone.View.extend({ return this.inputEl.get(0); }, - render() { const el = this.$el; el.addClass(this.inputClass()); @@ -89,5 +79,4 @@ module.exports = Backbone.View.extend({ el.find(`.${this.holderClass()}`).append(this.getInputEl()); return this; } - }); diff --git a/src/domain_abstract/ui/InputColor.js b/src/domain_abstract/ui/InputColor.js index b9284a893..c53674881 100644 --- a/src/domain_abstract/ui/InputColor.js +++ b/src/domain_abstract/ui/InputColor.js @@ -3,7 +3,6 @@ const Input = require('./Input'); const $ = Backbone.$; module.exports = Input.extend({ - template() { const ppfx = this.ppfx; return ` @@ -59,11 +58,14 @@ module.exports = Input.extend({ var colorEl = $(`
`); var cpStyle = colorEl.get(0).style; var elToAppend = this.em && this.em.config ? this.em.config.el : ''; - var colorPickerConfig = this.em && this.em.getConfig && this.em.getConfig("colorPicker") || {}; + var colorPickerConfig = + (this.em && this.em.getConfig && this.em.getConfig('colorPicker')) || + {}; const getColor = color => { - let cl = color.getAlpha() == 1 ? color.toHexString() : color.toRgbString(); + let cl = + color.getAlpha() == 1 ? color.toHexString() : color.toRgbString(); return cl.replace(/ /g, ''); - } + }; let changed = 0; let previousColor; @@ -73,7 +75,7 @@ module.exports = Input.extend({ appendTo: elToAppend || 'body', maxSelectionSize: 8, showPalette: true, - showAlpha: true, + showAlpha: true, chooseText: 'Ok', cancelText: '⨯', palette: [], @@ -98,14 +100,14 @@ module.exports = Input.extend({ previousColor = getColor(color); }, hide(color) { - if (!changed && previousColor) { - if (self.noneColor) { - previousColor = ''; - } - cpStyle.backgroundColor = previousColor; - colorEl.spectrum('set', previousColor); - model.setValueFromInput(previousColor, 0); - } + if (!changed && previousColor) { + if (self.noneColor) { + previousColor = ''; + } + cpStyle.backgroundColor = previousColor; + colorEl.spectrum('set', previousColor); + model.setValueFromInput(previousColor, 0); + } } }); @@ -120,5 +122,4 @@ module.exports = Input.extend({ this.getColorEl(); return this; } - }); diff --git a/src/domain_abstract/ui/InputNumber.js b/src/domain_abstract/ui/InputNumber.js index 587aebee9..c350720bb 100644 --- a/src/domain_abstract/ui/InputNumber.js +++ b/src/domain_abstract/ui/InputNumber.js @@ -1,20 +1,18 @@ import { bindAll } from 'underscore'; -import {on, off} from 'utils/mixins'; +import { on, off } from 'utils/mixins'; const Input = require('./Input'); const Backbone = require('backbone'); const $ = Backbone.$; module.exports = Input.extend({ - events: { 'change input': 'handleChange', 'change select': 'handleUnitChange', 'click [data-arrow-up]': 'upArrowClick', 'click [data-arrow-down]': 'downArrowClick', - 'mousedown [data-arrows]': 'downIncrement', + 'mousedown [data-arrows]': 'downIncrement' }, - template() { const ppfx = this.ppfx; return ` @@ -32,7 +30,6 @@ module.exports = Input.extend({ return this.opts.contClass || `${ppfx}field ${ppfx}field-integer`; }, - initialize(opts = {}) { Input.prototype.initialize.apply(this, arguments); bindAll(this, 'moveIncrement', 'upIncrement'); @@ -40,7 +37,6 @@ module.exports = Input.extend({ this.listenTo(this.model, 'change:unit', this.handleModelChange); }, - /** * Set value to the model * @param {string} value @@ -48,11 +44,11 @@ module.exports = Input.extend({ */ setValue(value, opts) { var opt = opts || {}; - var valid = this.validateInputValue(value, {deepCheck: 1}); - var validObj = {value: valid.value}; + var valid = this.validateInputValue(value, { deepCheck: 1 }); + var validObj = { value: valid.value }; // If found some unit value - if(valid.unit || valid.force) { + if (valid.unit || valid.force) { validObj.unit = valid.unit; } @@ -60,12 +56,11 @@ module.exports = Input.extend({ // Generally I get silent when I need to reflect data to view without // reupdating the target - if(opt.silent) { + if (opt.silent) { this.handleModelChange(); } }, - /** * Handled when the view is changed */ @@ -75,7 +70,6 @@ module.exports = Input.extend({ this.elementUpdated(); }, - /** * Handled when the view is changed */ @@ -86,7 +80,6 @@ module.exports = Input.extend({ this.elementUpdated(); }, - /** * Fired when the element of the property is updated */ @@ -94,7 +87,6 @@ module.exports = Input.extend({ this.model.trigger('el:change'); }, - /** * Updates the view when the model is changed * */ @@ -102,10 +94,9 @@ module.exports = Input.extend({ const model = this.model; this.getInputEl().value = model.get('value'); const unitEl = this.getUnitEl(); - unitEl && (unitEl.value = model.get('unit')); + unitEl && (unitEl.value = model.get('unit') || ''); }, - /** * Get the unit element * @return {HTMLElement} @@ -124,7 +115,9 @@ module.exports = Input.extend({ }); const temp = document.createElement('div'); - temp.innerHTML = ``; + temp.innerHTML = ``; this.unitEl = temp.firstChild; } } @@ -132,35 +125,32 @@ module.exports = Input.extend({ return this.unitEl; }, - /** * Invoked when the up arrow is clicked * */ upArrowClick() { const model = this.model; const step = model.get('step'); - let value = model.get('value'); + let value = parseInt(model.get('value'), 10); value = this.normalizeValue(value + step); var valid = this.validateInputValue(value); model.set('value', valid.value); this.elementUpdated(); }, - /** * Invoked when the down arrow is clicked * */ downArrowClick() { const model = this.model; const step = model.get('step'); - const value = model.get('value'); + const value = parseInt(model.get('value'), 10); const val = this.normalizeValue(value - step); var valid = this.validateInputValue(val); model.set('value', valid.value); this.elementUpdated(); }, - /** * Change easily integer input value with click&drag method * @param Event @@ -172,12 +162,11 @@ module.exports = Input.extend({ this.moved = 0; var value = this.model.get('value'); value = this.normalizeValue(value); - this.current = {y: e.pageY, val: value}; + this.current = { y: e.pageY, val: value }; on(this.doc, 'mousemove', this.moveIncrement); on(this.doc, 'mouseup', this.upIncrement); }, - /** While the increment is clicked, moving the mouse will update input value * @param Object * @@ -190,11 +179,10 @@ module.exports = Input.extend({ const data = this.current; var pos = this.normalizeValue(data.val + (data.y - ev.pageY) * step); this.prValue = this.validateInputValue(pos).value; - model.set('value', this.prValue, {avoidStore: 1}); + model.set('value', this.prValue, { avoidStore: 1 }); return false; }, - /** * Stop moveIncrement method * */ @@ -204,15 +192,13 @@ module.exports = Input.extend({ off(this.doc, 'mouseup', this.upIncrement); off(this.doc, 'mousemove', this.moveIncrement); - if(this.prValue && this.moved) { + if (this.prValue && this.moved) { var value = this.prValue - step; - model.set('value', value, {avoidStore: 1}) - .set('value', value + step); + model.set('value', value, { avoidStore: 1 }).set('value', value + step); this.elementUpdated(); } }, - normalizeValue(value, defValue = 0) { const model = this.model; const step = model.get('step'); @@ -232,7 +218,6 @@ module.exports = Input.extend({ return stepDecimals ? parseFloat(value.toFixed(stepDecimals)) : value; }, - /** * Validate input value * @param {String} value Raw value @@ -249,7 +234,7 @@ module.exports = Input.extend({ var max = model.get('max'); var min = model.get('min'); - if(opt.deepCheck) { + if (opt.deepCheck) { var fixed = model.get('fixedValues') || []; if (val) { @@ -266,17 +251,14 @@ module.exports = Input.extend({ val = !isNaN(val) ? val : model.get('defaults'); var uN = valCopy.replace(val, ''); // Check if exists as unit - if(_.indexOf(units, uN) >= 0) - unit = uN; + if (_.indexOf(units, uN) >= 0) unit = uN; } } } - if(typeof max !== 'undefined' && max !== '') - val = val > max ? max : val; + if (typeof max !== 'undefined' && max !== '') val = val > max ? max : val; - if(typeof min !== 'undefined' && min !== '') - val = val < min ? min : val; + if (typeof min !== 'undefined' && min !== '') val = val < min ? min : val; return { force, @@ -285,12 +267,14 @@ module.exports = Input.extend({ }; }, - render() { Input.prototype.render.call(this); const unit = this.getUnitEl(); - unit && this.$el.find(`.${this.ppfx}field-units`).get(0).appendChild(unit); + unit && + this.$el + .find(`.${this.ppfx}field-units`) + .get(0) + .appendChild(unit); return this; } - }); diff --git a/src/domain_abstract/view/DomainViews.js b/src/domain_abstract/view/DomainViews.js index 6b1d2e708..ac16b1d7c 100644 --- a/src/domain_abstract/view/DomainViews.js +++ b/src/domain_abstract/view/DomainViews.js @@ -1,7 +1,6 @@ var Backbone = require('backbone'); module.exports = Backbone.View.extend({ - // Default view itemView: '', @@ -14,7 +13,6 @@ module.exports = Backbone.View.extend({ this.config = config || {}; }, - /** * Add new model to the collection * @param {Model} model @@ -34,34 +32,32 @@ module.exports = Backbone.View.extend({ var frag = fragment || null; var itemView = this.itemView; var typeField = model.get(this.itemType); - if(this.itemsView && this.itemsView[typeField]){ + if (this.itemsView && this.itemsView[typeField]) { itemView = this.itemsView[typeField]; } - var view = new itemView({ - model, - config: this.config - }, this.config); + var view = new itemView( + { + model, + config: this.config + }, + this.config + ); var rendered = view.render().el; - if(frag) - frag.appendChild(rendered); - else - this.$el.append(rendered); + if (frag) frag.appendChild(rendered); + else this.$el.append(rendered); }, - - render() { var frag = document.createDocumentFragment(); this.$el.empty(); - if(this.collection.length) - this.collection.each(function(model){ + if (this.collection.length) + this.collection.each(function(model) { this.add(model, frag); }, this); this.$el.append(frag); return this; - }, - + } }); diff --git a/src/editor/config/config.js b/src/editor/config/config.js index 5e604949c..50392fbbe 100644 --- a/src/editor/config/config.js +++ b/src/editor/config/config.js @@ -59,6 +59,9 @@ module.exports = { // Return JS of components inside HTML from 'editor.getHtml()' jsInHtml: true, + // Enable native HTML5 drag and drop + nativeDnD: 1, + // Show the wrapper component in the final code, eg. in editor.getHtml() exportWrapper: 0, @@ -115,65 +118,106 @@ module.exports = { //Configurations for Device Manager deviceManager: { - devices: [{ + devices: [ + { name: 'Desktop', - width: '', - },{ + width: '' + }, + { name: 'Tablet', width: '768px', - widthMedia: '992px', - },{ + widthMedia: '992px' + }, + { name: 'Mobile landscape', width: '568px', - widthMedia: '768px', - },{ + widthMedia: '768px' + }, + { name: 'Mobile portrait', width: '320px', - widthMedia: '480px', - }], + widthMedia: '480px' + } + ] }, //Configurations for Style Manager styleManager: { - - sectors: [{ + sectors: [ + { name: 'General', open: false, - buildProps: ['float', 'display', 'position', 'top', 'right', 'left', 'bottom'], - },{ + buildProps: [ + 'float', + 'display', + 'position', + 'top', + 'right', + 'left', + 'bottom' + ] + }, + { name: 'Dimension', open: false, - buildProps: ['width', 'height', 'max-width', 'min-height', 'margin', 'padding'], - },{ + buildProps: [ + 'width', + 'height', + 'max-width', + 'min-height', + 'margin', + 'padding' + ] + }, + { name: 'Typography', open: false, - buildProps: ['font-family', 'font-size', 'font-weight', 'letter-spacing', 'color', 'line-height', 'text-align', 'text-shadow'], - properties: [{ + buildProps: [ + 'font-family', + 'font-size', + 'font-weight', + 'letter-spacing', + 'color', + 'line-height', + 'text-align', + 'text-shadow' + ], + properties: [ + { property: 'text-align', - list : [ - {value: 'left', className: 'fa fa-align-left'}, - {value: 'center', className: 'fa fa-align-center' }, - {value: 'right', className: 'fa fa-align-right'}, - {value: 'justify', className: 'fa fa-align-justify'} - ], - }] - },{ + list: [ + { value: 'left', className: 'fa fa-align-left' }, + { value: 'center', className: 'fa fa-align-center' }, + { value: 'right', className: 'fa fa-align-right' }, + { value: 'justify', className: 'fa fa-align-justify' } + ] + } + ] + }, + { name: 'Decorations', open: false, - buildProps: ['border-radius-c', 'background-color', 'border-radius', 'border', 'box-shadow', 'background'], - },{ + buildProps: [ + 'border-radius-c', + 'background-color', + 'border-radius', + 'border', + 'box-shadow', + 'background' + ] + }, + { name: 'Extra', open: false, - buildProps: ['transition', 'perspective', 'transform'], - }], - + buildProps: ['transition', 'perspective', 'transform'] + } + ] }, //Configurations for Block Manager blockManager: {}, - // Texts - textViewCode: 'Code', + textViewCode: 'Code' }; diff --git a/src/editor/index.js b/src/editor/index.js index fad4c33e7..13ee27408 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -10,6 +10,8 @@ * * ## Components * * `component:add` - Triggered when a new component is added to the editor, the model is passed as an argument to the callback + * * `component:remove` - Triggered when a component is removed, the model is passed as an argument to the callback + * * `component:clone` - Triggered when a new component is added by a clone command, the model is passed as an argument to the callback * * `component:update` - Triggered when a component is updated (moved, styled, etc.), the model is passed as an argument to the callback * * `component:update:{propertyName}` - Listen any property change, the model is passed as an argument to the callback * * `component:styleUpdate` - Triggered when the style of the component is updated, the model is passed as an argument to the callback @@ -41,6 +43,13 @@ * * `storage:store` - Triggered when something is stored to the storage, stored object passed as an argumnet * * `storage:end` - After the storage request is ended * * `storage:error` - On any error on storage request, passes the error as an argument + * ## Canvas + * * `canvas:dragenter` - When something is dragged inside the canvas, `DataTransfer` instance passed as an argument + * * `canvas:dragover` - When something is dragging on canvas, `DataTransfer` instance passed as an argument + * * `canvas:drop` - Something is dropped in canvas, `DataTransfer` instance and the dropped model are passed as arguments + * * `canvas:dragend` - When a drag operation is ended, `DataTransfer` instance passed as an argument + * * `canvas:dragdata` - On any dataTransfer parse, `DataTransfer` instance and the `result` are passed as arguments. + * By changing `result.content` you're able to customize what is dropped * ## Selectors * * `selector:add` - Triggers when a new selector/class is created * ## RTE @@ -85,24 +94,22 @@ import $ from 'cash-dom'; module.exports = config => { var c = config || {}, - defaults = require('./config/config'), - EditorModel = require('./model/Editor'), - EditorView = require('./view/EditorView'); + defaults = require('./config/config'), + EditorModel = require('./model/Editor'), + EditorView = require('./view/EditorView'); for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } c.pStylePrefix = c.stylePrefix; var em = new EditorModel(c); var editorView = new EditorView({ - model: em, - config: c, + model: em, + config: c }); return { - $, /** @@ -417,7 +424,7 @@ module.exports = config => { var result; var command = em.get('Commands').get(id); - if(command){ + if (command) { result = command.run(this, this, options); this.trigger('run:' + id); } @@ -436,7 +443,7 @@ module.exports = config => { var result; var command = em.get('Commands').get(id); - if(command){ + if (command) { result = command.stop(this, this, options); this.trigger('stop:' + id); } @@ -580,8 +587,6 @@ module.exports = config => { editorView.render(); return editorView.el; - }, - + } }; - }; diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 6cb880b9d..337652fe1 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -33,7 +33,6 @@ require('utils/extender')({ const $ = Backbone.$; module.exports = Backbone.Model.extend({ - defaults: { clipboard: null, designerMode: false, @@ -44,7 +43,7 @@ module.exports = Backbone.Model.extend({ modules: [], toLoad: [], opened: {}, - device: '', + device: '' }, initialize(c = {}) { @@ -52,8 +51,7 @@ module.exports = Backbone.Model.extend({ this.set('Config', c); this.set('modules', []); - if(c.el && c.fromElement) - this.config.components = c.el.innerHTML; + if (c.el && c.fromElement) this.config.components = c.el.innerHTML; // Load modules deps.forEach(name => this.loadModule(name)); @@ -61,7 +59,6 @@ module.exports = Backbone.Model.extend({ this.on('change:changesCount', this.updateChanges, this); }, - /** * Get configurations * @param {string} [prop] Property name @@ -73,7 +70,6 @@ module.exports = Backbone.Model.extend({ return isUndefined(prop) ? config : config[prop]; }, - /** * Should be called after all modules and plugins are loaded * @param {Function} clb @@ -102,7 +98,6 @@ module.exports = Backbone.Model.extend({ } }, - /** * Set the alert before unload in case it's requested * and there are unsaved changes @@ -123,7 +118,6 @@ module.exports = Backbone.Model.extend({ } }, - /** * Load generic module * @param {String} moduleName Module name @@ -167,12 +161,10 @@ module.exports = Backbone.Model.extend({ this.set('Editor', editor); }, - getEditor() { return this.get('Editor'); }, - /** * This method handles updates on the editor and tries to store them * if requested and if the changesCount is exceeded @@ -190,12 +182,11 @@ module.exports = Backbone.Model.extend({ timedInterval && clearInterval(timedInterval); timedInterval = setTimeout(() => { if (!opt.avoidStore) { - this.set('changesCount', this.get('changesCount') + 1, opt) + this.set('changesCount', this.get('changesCount') + 1, opt); } }, 0); }, - /** * Callback on component selection * @param {Object} Model @@ -207,12 +198,11 @@ module.exports = Backbone.Model.extend({ if (!this.get('selectedComponent')) { this.trigger('deselect-comp'); } else { - this.trigger('select-comp',[model,val,options]); + this.trigger('select-comp', [model, val, options]); this.trigger('component:selected', arguments); } }, - /** * Returns model of the selected component * @return {Component|null} @@ -235,7 +225,7 @@ module.exports = Backbone.Model.extend({ model = $(el).data('model'); } - if (model && !model.get("selectable")) { + if (model && !model.get('selectable')) { return; } @@ -261,10 +251,9 @@ module.exports = Backbone.Model.extend({ var cmp = this.get('DomComponents'); var cm = this.get('CodeManager'); - if(!cmp || !cm) - return; + if (!cmp || !cm) return; - var wrp = cmp.getComponents(); + var wrp = cmp.getComponents(); return cm.getCode(wrp, 'json'); }, @@ -276,8 +265,7 @@ module.exports = Backbone.Model.extend({ */ setStyle(style) { var rules = this.get('CssComposer').getAll(); - for(var i = 0, len = rules.length; i < len; i++) - rules.pop(); + for (var i = 0, len = rules.length; i < len; i++) rules.pop(); rules.add(style); return this; }, @@ -301,9 +289,10 @@ module.exports = Backbone.Model.extend({ const exportWrapper = config.exportWrapper; const wrappesIsBody = config.wrappesIsBody; const js = config.jsInHtml ? this.getJs() : ''; - var wrp = this.get('DomComponents').getComponent(); + var wrp = this.get('DomComponents').getComponent(); var html = this.get('CodeManager').getCode(wrp, 'html', { - exportWrapper, wrappesIsBody + exportWrapper, + wrappesIsBody }); html += js ? `` : ''; return html; @@ -323,9 +312,13 @@ module.exports = Backbone.Model.extend({ const wrp = this.get('DomComponents').getComponent(); const protCss = !avoidProt ? config.protectedCss : ''; - return protCss + this.get('CodeManager').getCode(wrp, 'css', { - cssc, wrappesIsBody - }); + return ( + protCss + + this.get('CodeManager').getCode(wrp, 'css', { + cssc, + wrappesIsBody + }) + ); }, /** @@ -335,7 +328,9 @@ module.exports = Backbone.Model.extend({ */ getJs() { var wrp = this.get('DomComponents').getWrapper(); - return this.get('CodeManager').getCode(wrp, 'js').trim(); + return this.get('CodeManager') + .getCode(wrp, 'js') + .trim(); }, /** @@ -347,14 +342,12 @@ module.exports = Backbone.Model.extend({ store(clb) { var sm = this.get('StorageManager'); var store = {}; - if(!sm) - return; + if (!sm) return; // Fetch what to store this.get('storables').forEach(m => { var obj = m.store(1); - for(var el in obj) - store[el] = obj[el]; + for (var el in obj) store[el] = obj[el]; }); sm.store(store, () => { @@ -372,7 +365,7 @@ module.exports = Backbone.Model.extend({ * @private */ load(clb = null) { - this.getCacheLoad(1, (res) => { + this.getCacheLoad(1, res => { this.get('storables').forEach(module => module.load(res)); clb && clb(res); }); @@ -387,13 +380,11 @@ module.exports = Backbone.Model.extend({ */ getCacheLoad(force, clb) { var f = force ? 1 : 0; - if(this.cacheLoad && !f) - return this.cacheLoad; + if (this.cacheLoad && !f) return this.cacheLoad; var sm = this.get('StorageManager'); var load = []; - if(!sm) - return {}; + if (!sm) return {}; this.get('storables').forEach(m => { var key = m.storageKey; @@ -428,8 +419,7 @@ module.exports = Backbone.Model.extend({ */ runDefault(opts = {}) { var command = this.get('Commands').get(this.config.defaultCommand); - if(!command || this.defaultRunning) - return; + if (!command || this.defaultRunning) return; command.stop(this, this, opts); command.run(this, this, opts); this.defaultRunning = 1; @@ -442,8 +432,7 @@ module.exports = Backbone.Model.extend({ */ stopDefault(opts = {}) { var command = this.get('Commands').get(this.config.defaultCommand); - if(!command) - return; + if (!command) return; command.stop(this, this, opts); this.defaultRunning = 0; }, @@ -467,7 +456,6 @@ module.exports = Backbone.Model.extend({ w.getSelection().removeAllRanges(); }, - /** * Get the current media text * @return {string} @@ -481,7 +469,6 @@ module.exports = Backbone.Model.extend({ return device && width && !preview ? `(${condition}: ${width})` : ''; }, - /** * Set/get data from the HTMLElement * @param {HTMLElement} el @@ -503,5 +490,4 @@ module.exports = Backbone.Model.extend({ el[varName][name] = value; } } - }); diff --git a/src/editor/view/EditorView.js b/src/editor/view/EditorView.js index ae2745c74..00a061169 100644 --- a/src/editor/view/EditorView.js +++ b/src/editor/view/EditorView.js @@ -1,7 +1,6 @@ const $ = Backbone.$; module.exports = Backbone.View.extend({ - initialize() { const model = this.model; model.view = this; @@ -23,16 +22,17 @@ module.exports = Backbone.View.extend({ const pfx = conf.stylePrefix; el.empty(); - if (conf.width) - contEl.css('width', conf.width); + if (conf.width) contEl.css('width', conf.width); - if (conf.height) - contEl.css('height', conf.height); + if (conf.height) contEl.css('height', conf.height); el.append(model.get('Canvas').render()); el.append(this.pn.render()); el.attr('class', `${pfx}editor ${pfx}one-bg ${pfx}two-color`); - contEl.addClass(`${pfx}editor-cont`).empty().append(el); + contEl + .addClass(`${pfx}editor-cont`) + .empty() + .append(el); return this; } diff --git a/src/grapesjs/config/config.js b/src/grapesjs/config/config.js deleted file mode 100644 index 8f3759c9b..000000000 --- a/src/grapesjs/config/config.js +++ /dev/null @@ -1,27 +0,0 @@ -module.exports = { - // If true renders editor on init - autorender: 1, - - // Where init the editor - container: '', - - // HTML string or object of components - components: '', - - // CSS string or object of rules - style: '', - - // If true, will fetch HTML and CSS from selected container - fromElement: 0, - - // --- - - // Storage Manager - storageManager: {}, - - // Array of plugins to init - plugins: [], - - // Custom options for plugins - pluginsOpts: {} -}; diff --git a/src/grapesjs/index.js b/src/grapesjs/index.js deleted file mode 100644 index 1a24b3235..000000000 --- a/src/grapesjs/index.js +++ /dev/null @@ -1,77 +0,0 @@ -import $ from 'cash-dom'; -import { defaults } from 'underscore'; -import polyfills from 'utils/polyfills'; - -polyfills(); - -module.exports = (() => { - const defaultConfig = require('./config/config'); - const Editor = require('editor'); - const PluginManager = require('plugin_manager'); - const plugins = new PluginManager(); - const editors = []; - - return { - - $, - - editors, - - plugins, - - // Will be replaced on build - version: '<# VERSION #>', - - /** - * Initializes an editor based on passed options - * @param {Object} config Configuration object - * @param {string|HTMLElement} config.container Selector which indicates where render the editor - * @param {Object|string} config.components='' HTML string or Component model in JSON format - * @param {Object|string} config.style='' CSS string or CSS model in JSON format - * @param {Boolean} [config.fromElement=false] If true, will fetch HTML and CSS from selected container - * @param {Boolean} [config.undoManager=true] Enable/Disable undo manager - * @param {Array} [config.plugins=[]] Array of plugins to execute on start - * @return {grapesjs.Editor} GrapesJS editor instance - * @example - * var editor = grapesjs.init({ - * container: '#myeditor', - * components: '
Hello world
', - * style: '.hello{color: red}', - * }) - */ - init(config = {}) { - const els = config.container; - - if (!els) { - throw new Error("'container' is required"); - } - - defaults(config, defaultConfig); - config.el = els instanceof window.HTMLElement ? els : document.querySelector(els); - const editor = new Editor(config).init(); - - // Load plugins - config.plugins.forEach(pluginId => { - const plugin = plugins.get(pluginId); - - if (plugin) { - plugin(editor, config.pluginsOpts[pluginId] || {}); - } else { - console.warn(`Plugin ${pluginId} not found`); - } - }); - - // Execute `onLoad` on modules once all plugins are initialized. - // A plugin might have extended/added some custom type so this - // is a good point to load stuff like components, css rules, etc. - editor.getModel().loadOnStart(); - - config.autorender && editor.render(); - - editors.push(editor); - return editor; - }, - - }; - -})(); diff --git a/src/index.js b/src/index.js index 03021ac74..4cb124347 100644 --- a/src/index.js +++ b/src/index.js @@ -1 +1,99 @@ -module.exports = require('./grapesjs'); +import $ from 'cash-dom'; +import { defaults } from 'underscore'; +import polyfills from 'utils/polyfills'; + +polyfills(); + +module.exports = (() => { + const Editor = require('editor'); + const PluginManager = require('plugin_manager'); + const plugins = new PluginManager(); + const editors = []; + const defaultConfig = { + // If true renders editor on init + autorender: 1, + + // Where init the editor + container: '', + + // HTML string or object of components + components: '', + + // CSS string or object of rules + style: '', + + // If true, will fetch HTML and CSS from selected container + fromElement: 0, + + // Storage Manager + storageManager: {}, + + // Array of plugins to init + plugins: [], + + // Custom options for plugins + pluginsOpts: {} + }; + + return { + $, + + editors, + + plugins, + + // Will be replaced on build + version: '<# VERSION #>', + + /** + * Initializes an editor based on passed options + * @param {Object} config Configuration object + * @param {string|HTMLElement} config.container Selector which indicates where render the editor + * @param {Object|string} config.components='' HTML string or Component model in JSON format + * @param {Object|string} config.style='' CSS string or CSS model in JSON format + * @param {Boolean} [config.fromElement=false] If true, will fetch HTML and CSS from selected container + * @param {Boolean} [config.undoManager=true] Enable/Disable undo manager + * @param {Array} [config.plugins=[]] Array of plugins to execute on start + * @return {grapesjs.Editor} GrapesJS editor instance + * @example + * var editor = grapesjs.init({ + * container: '#myeditor', + * components: '
Hello world
', + * style: '.hello{color: red}', + * }) + */ + init(config = {}) { + const els = config.container; + + if (!els) { + throw new Error("'container' is required"); + } + + defaults(config, defaultConfig); + config.el = + els instanceof window.HTMLElement ? els : document.querySelector(els); + const editor = new Editor(config).init(); + + // Load plugins + config.plugins.forEach(pluginId => { + const plugin = plugins.get(pluginId); + + if (plugin) { + plugin(editor, config.pluginsOpts[pluginId] || {}); + } else { + console.warn(`Plugin ${pluginId} not found`); + } + }); + + // Execute `onLoad` on modules once all plugins are initialized. + // A plugin might have extended/added some custom type so this + // is a good point to load stuff like components, css rules, etc. + editor.getModel().loadOnStart(); + + config.autorender && editor.render(); + + editors.push(editor); + return editor; + } + }; +})(); diff --git a/src/keymaps/index.js b/src/keymaps/index.js index f29ce6866..3d7b74b3c 100644 --- a/src/keymaps/index.js +++ b/src/keymaps/index.js @@ -19,31 +19,28 @@ module.exports = () => { defaults: { 'core:undo': { keys: '⌘+z, ctrl+z', - handler: 'core:undo', + handler: 'core:undo' }, 'core:redo': { keys: '⌘+shift+z, ctrl+shift+z', - handler: 'core:redo', + handler: 'core:redo' }, 'core:copy': { keys: '⌘+c, ctrl+c', - handler: 'core:copy', + handler: 'core:copy' }, 'core:paste': { keys: '⌘+v, ctrl+v', - handler: 'core:paste', + handler: 'core:paste' } } }; return { - keymaster, - name: 'Keymaps', - /** * Get module configurations * @return {Object} Configuration object @@ -52,7 +49,6 @@ module.exports = () => { return config; }, - /** * Initialize module * @param {Object} config Configurations @@ -65,7 +61,6 @@ module.exports = () => { return this; }, - onLoad() { const defKeys = config.defaults; @@ -75,7 +70,6 @@ module.exports = () => { } }, - /** * Add new keymap * @param {string} id Keymap id @@ -116,7 +110,6 @@ module.exports = () => { return keymap; }, - /** * Get the keymap by id * @param {string} id Keymap id @@ -129,7 +122,6 @@ module.exports = () => { return keymaps[id]; }, - /** * Get all keymaps * @return {Object} @@ -141,7 +133,6 @@ module.exports = () => { return keymaps; }, - /** * Remove the keymap by id * @param {string} id Keymap id @@ -160,8 +151,6 @@ module.exports = () => { em && em.trigger('keymap:remove', keymap); return keymap; } - }, - - + } }; }; diff --git a/src/modal_dialog/config/config.js b/src/modal_dialog/config/config.js index 0bf040bae..d33314819 100644 --- a/src/modal_dialog/config/config.js +++ b/src/modal_dialog/config/config.js @@ -1,11 +1,9 @@ module.exports = { - stylePrefix: 'mdl-', title: '', content: '', - backdrop: true, - -};; + backdrop: true +}; diff --git a/src/modal_dialog/index.js b/src/modal_dialog/index.js index e5f0e512f..9bbf4c4b0 100644 --- a/src/modal_dialog/index.js +++ b/src/modal_dialog/index.js @@ -16,14 +16,13 @@ */ module.exports = () => { var c = {}, - defaults = require('./config/config'), - ModalM = require('./model/Modal'), - ModalView = require('./view/ModalView'); + defaults = require('./config/config'), + ModalM = require('./model/Modal'), + ModalView = require('./view/ModalView'); var model, modal; return { - - /** + /** * Name of the module * @type {String} * @private @@ -38,18 +37,16 @@ module.exports = () => { init(config) { c = config || {}; for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } var ppfx = c.pStylePrefix; - if(ppfx) - c.stylePrefix = ppfx + c.stylePrefix; + if (ppfx) c.stylePrefix = ppfx + c.stylePrefix; model = new ModalM(c); modal = new ModalView({ model, - config: c, + config: c }); return this; diff --git a/src/modal_dialog/model/Modal.js b/src/modal_dialog/model/Modal.js index c50e9ed30..01d759ac6 100644 --- a/src/modal_dialog/model/Modal.js +++ b/src/modal_dialog/model/Modal.js @@ -4,6 +4,6 @@ module.exports = Backbone.Model.extend({ defaults: { title: '', content: '', - open: false, + open: false } }); diff --git a/src/modal_dialog/view/ModalView.js b/src/modal_dialog/view/ModalView.js index 70651c90c..bbc81dcd6 100644 --- a/src/modal_dialog/view/ModalView.js +++ b/src/modal_dialog/view/ModalView.js @@ -1,6 +1,5 @@ module.exports = require('backbone').View.extend({ - - template({pfx, ppfx, content, title}) { + template({ pfx, ppfx, content, title }) { return `
${title}
@@ -28,7 +27,7 @@ module.exports = require('backbone').View.extend({ this.listenTo(model, 'change:open', this.updateOpen); this.listenTo(model, 'change:title', this.updateTitle); this.listenTo(model, 'change:content', this.updateContent); - this.events[`click .${pfx}btn-close`] = 'hide'; + this.events[`click .${pfx}btn-close`] = 'hide'; bkd && (this.events[`click .${pfx}backlayer`] = 'hide'); this.delegateEvents(); }, @@ -39,8 +38,8 @@ module.exports = require('backbone').View.extend({ * @private */ getCollector() { - if(!this.$collector) - this.$collector = this.$el.find('.'+this.pfx+'collector'); + if (!this.$collector) + this.$collector = this.$el.find('.' + this.pfx + 'collector'); return this.$collector; }, @@ -65,8 +64,7 @@ module.exports = require('backbone').View.extend({ * @private */ getTitle() { - if(!this.$title) - this.$title = this.$el.find('.'+this.pfx+'title'); + if (!this.$title) this.$title = this.$el.find('.' + this.pfx + 'title'); return this.$title.get(0); }, @@ -89,8 +87,7 @@ module.exports = require('backbone').View.extend({ * */ updateTitle() { var title = this.getTitle(); - if(title) - title.innerHTML = this.model.get('title'); + if (title) title.innerHTML = this.model.get('title'); }, /** @@ -113,7 +110,7 @@ module.exports = require('backbone').View.extend({ * Show modal * @private * */ - show() { + show() { this.model.set('open', 1); }, @@ -128,6 +125,5 @@ module.exports = require('backbone').View.extend({ el.attr('class', `${pfx}container`); this.updateOpen(); return this; - }, - + } }); diff --git a/src/navigator/config/config.js b/src/navigator/config/config.js index 1ca049f51..aaca2c84f 100644 --- a/src/navigator/config/config.js +++ b/src/navigator/config/config.js @@ -11,5 +11,5 @@ module.exports = { hideTextnode: 1, // Indicates if the wrapper is visible in layers - showWrapper: 1, + showWrapper: 1 }; diff --git a/src/navigator/index.js b/src/navigator/index.js index 93267562b..437aefd97 100644 --- a/src/navigator/index.js +++ b/src/navigator/index.js @@ -12,8 +12,7 @@ module.exports = () => { // Set default options for (var name in defaults) { - if (!(name in config)) - config[name] = defaults[name]; + if (!(name in config)) config[name] = defaults[name]; } let View = ItemsView; @@ -23,14 +22,14 @@ module.exports = () => { level, config, opened - } + }; // Show wrapper if requested if (config.showWrapper && collection.parent) { View = ItemView; options.model = collection.parent; } else { - options.collection = collection + options.collection = collection; } itemsView = new View(options); @@ -67,6 +66,6 @@ module.exports = () => { render() { return itemsView.render().$el; - }, - } + } + }; }; diff --git a/src/navigator/view/ItemView.js b/src/navigator/view/ItemView.js index b641879f0..2bace9326 100644 --- a/src/navigator/view/ItemView.js +++ b/src/navigator/view/ItemView.js @@ -3,17 +3,15 @@ const ComponentView = require('dom_components/view/ComponentView'); let ItemsView; module.exports = require('backbone').View.extend({ - events: { 'mousedown [data-toggle-move]': 'startSort', 'click [data-toggle-visible]': 'toggleVisibility', 'click [data-toggle-select]': 'handleSelect', 'click [data-toggle-open]': 'toggleOpening', 'dblclick input': 'handleEdit', - 'focusout input': 'handleEditEnd', + 'focusout input': 'handleEditEnd' }, - template(model) { const pfx = this.pfx; const ppfx = this.ppfx; @@ -22,20 +20,29 @@ module.exports = require('backbone').View.extend({ const addClass = !count ? `${pfx}no-chld` : ''; const level = this.level + 1; return ` - ${ hidable ? - `` - : ''} + ${ + hidable + ? `` + : '' + }
-
+
- + ${model.getIcon()} - +
-
${ count ? count : '' }
+
${count ? count : ''}
@@ -43,7 +50,6 @@ module.exports = require('backbone').View.extend({ `; }, - initialize(o = {}) { this.opt = o; this.level = o.level; @@ -71,8 +77,7 @@ module.exports = require('backbone').View.extend({ this.$el.data('collection', components); }, - - getVisibilityEl () { + getVisibilityEl() { if (!this.eyeEl) { this.eyeEl = this.$el.children(`#${this.pfx}btn-eye`); } @@ -80,7 +85,6 @@ module.exports = require('backbone').View.extend({ return this.eyeEl; }, - updateVisibility() { const pfx = this.pfx; const model = this.model; @@ -92,7 +96,6 @@ module.exports = require('backbone').View.extend({ this.getVisibilityEl()[method](hideIcon); }, - /** * Toggle visibility * @param Event @@ -114,7 +117,6 @@ module.exports = require('backbone').View.extend({ model.setStyle(style); }, - /** * Handle the edit of the component name */ @@ -125,7 +127,6 @@ module.exports = require('backbone').View.extend({ inputName.focus(); }, - /** * Handle with the end of editing of the component name */ @@ -141,7 +142,7 @@ module.exports = require('backbone').View.extend({ * @return {HTMLElement} */ getInputName() { - if(!this.inputName) { + if (!this.inputName) { this.inputName = this.el.querySelector('.' + this.inputNameCls); } return this.inputName; @@ -162,7 +163,7 @@ module.exports = require('backbone').View.extend({ this.getCaret().addClass(chvDown); opened[model.cid] = model; } else { - this.$el.removeClass("open"); + this.$el.removeClass('open'); this.getCaret().removeClass(chvDown); delete opened[model.cid]; } @@ -177,10 +178,9 @@ module.exports = require('backbone').View.extend({ toggleOpening(e) { e.stopPropagation(); - if(!this.model.get('components').length) - return; + if (!this.model.get('components').length) return; - this.model.set('open', !this.model.get('open') ); + this.model.set('open', !this.model.get('open')); }, /** @@ -188,7 +188,7 @@ module.exports = require('backbone').View.extend({ */ handleSelect(e) { e.stopPropagation(); - this.em && this.em.setSelected(this.model, {fromLayers: 1}); + this.em && this.em.setSelected(this.model, { fromLayers: 1 }); }, /** @@ -212,7 +212,7 @@ module.exports = require('backbone').View.extend({ * */ freeze() { this.$el.addClass(this.pfx + 'opac50'); - this.model.set('open',0); + this.model.set('open', 0); }, /** @@ -231,7 +231,6 @@ module.exports = require('backbone').View.extend({ ComponentView.prototype.updateStatus.apply(this, arguments); }, - /** * Check if component is visible * @@ -240,8 +239,7 @@ module.exports = require('backbone').View.extend({ isVisible() { var css = this.model.get('style'), pr = css.display; - if(pr && pr == 'none' ) - return; + if (pr && pr == 'none') return; return 1; }, @@ -258,7 +256,7 @@ module.exports = require('backbone').View.extend({ const title = this.$el.children(`.${pfx}title-c`).children(`.${pfx}title`); //tC = `> .${pfx}title-c > .${pfx}title`; if (!this.$counter) { - this.$counter = this.$el.children(`#${pfx}counter`); + this.$counter = this.$el.children(`#${pfx}counter`); } if (c) { @@ -279,11 +277,10 @@ module.exports = require('backbone').View.extend({ */ countChildren(model) { var count = 0; - model.get('components').each(function(m){ + model.get('components').each(function(m) { var isCountable = this.opt.isCountable; var hide = this.config.hideTextnode; - if(isCountable && !isCountable(m, hide)) - return; + if (isCountable && !isCountable(m, hide)) return; count++; }, this); return count; @@ -320,8 +317,8 @@ module.exports = require('backbone').View.extend({ }).render().$el; el.find(`.${pfx}children`).append(children); - if(!model.get('draggable') || !this.config.sortable) { - el.children(`#${pfx}move`).remove(); + if (!model.get('draggable') || !this.config.sortable) { + el.children(`#${pfx}move`).remove(); } !vis && (this.className += ` ${pfx}hide`); @@ -330,6 +327,5 @@ module.exports = require('backbone').View.extend({ this.updateStatus(); this.updateVisibility(); return this; - }, - + } }); diff --git a/src/navigator/view/ItemsView.js b/src/navigator/view/ItemsView.js index 971338442..b14b54a66 100644 --- a/src/navigator/view/ItemsView.js +++ b/src/navigator/view/ItemsView.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var ItemView = require('./ItemView'); module.exports = Backbone.View.extend({ - initialize(o = {}) { this.opt = o; const config = o.config || {}; @@ -48,7 +47,7 @@ module.exports = Backbone.View.extend({ * @return Object * */ addTo(model) { - var i = this.collection.indexOf(model); + var i = this.collection.indexOf(model); this.addToCollection(model, null, i); }, @@ -62,10 +61,10 @@ module.exports = Backbone.View.extend({ * */ addToCollection(model, fragmentEl, index) { const level = this.level; - var fragment = fragmentEl || null; - var viewObject = ItemView; + var fragment = fragmentEl || null; + var viewObject = ItemView; - if(!this.isCountable(model, this.config.hideTextnode)) { + if (!this.isCountable(model, this.config.hideTextnode)) { return; } @@ -75,28 +74,30 @@ module.exports = Backbone.View.extend({ config: this.config, sorter: this.sorter, isCountable: this.isCountable, - opened: this.opt.opened, + opened: this.opt.opened }); - var rendered = view.render().el; + var rendered = view.render().el; - if(fragment){ + if (fragment) { fragment.appendChild(rendered); - }else{ - if(typeof index != 'undefined'){ - var method = 'before'; + } else { + if (typeof index != 'undefined') { + var method = 'before'; // If the added model is the last of collection // need to change the logic of append - if(this.$el.children().length == index){ + if (this.$el.children().length == index) { index--; - method = 'after'; + method = 'after'; } // In case the added is new in the collection index will be -1 - if(index < 0){ + if (index < 0) { this.$el.append(rendered); - }else - this.$el.children().eq(index)[method](rendered); - }else - this.$el.append(rendered); + } else + this.$el + .children() + .eq(index) + [method](rendered); + } else this.$el.append(rendered); } return rendered; @@ -111,8 +112,10 @@ module.exports = Backbone.View.extend({ isCountable(model, hide) { var type = model.get('type'); var tag = model.get('tagName'); - if( ((type == 'textnode' || tag == 'br') && hide) || - !model.get('layerable')) { + if ( + ((type == 'textnode' || tag == 'br') && hide) || + !model.get('layerable') + ) { return false; } return true; diff --git a/src/panels/config/config.js b/src/panels/config/config.js index 4acf56d96..75246a349 100644 --- a/src/panels/config/config.js +++ b/src/panels/config/config.js @@ -1,6 +1,6 @@ var crc = 'create-comp'; var mvc = 'move-comp'; -var swv = 'sw-visibility'; +var swv = 'sw-visibility'; var expt = 'export-template'; var osm = 'open-sm'; var otm = 'open-tm'; @@ -13,65 +13,79 @@ module.exports = { stylePrefix: 'pn-', // Default panels fa-sliders for features - defaults: [{ - id: 'commands', - buttons: [{}], - },{ - id: 'options', - buttons: [{ - active: true, - id: swv, - className: 'fa fa-square-o', - command: swv, - context: swv, - attributes: { title: 'View components' }, - },{ - id: prv, - className: 'fa fa-eye', - command: prv, - context: prv, - attributes: { title: 'Preview' }, - },{ - id: ful, - className: 'fa fa-arrows-alt', - command: ful, - context: ful, - attributes: { title: 'Fullscreen' }, - },{ - id: expt, - className: 'fa fa-code', - command: expt, - attributes: { title: 'View code' }, - }], - },{ - id: 'views', - buttons : [{ - id: osm, - className: 'fa fa-paint-brush', - command: osm, - active: true, - attributes: { title: 'Open Style Manager' }, - },{ - id: otm, - className: 'fa fa-cog', - command: otm, - attributes: { title: 'Settings' }, - },{ - id: ola, - className: 'fa fa-bars', - command: ola, - attributes : { title: 'Open Layer Manager' }, - },{ - id: obl, - className: 'fa fa-th-large', - command: obl, - attributes : { title: 'Open Blocks' }, - }], - }], + defaults: [ + { + id: 'commands', + buttons: [{}] + }, + { + id: 'options', + buttons: [ + { + active: true, + id: swv, + className: 'fa fa-square-o', + command: swv, + context: swv, + attributes: { title: 'View components' } + }, + { + id: prv, + className: 'fa fa-eye', + command: prv, + context: prv, + attributes: { title: 'Preview' } + }, + { + id: ful, + className: 'fa fa-arrows-alt', + command: ful, + context: ful, + attributes: { title: 'Fullscreen' } + }, + { + id: expt, + className: 'fa fa-code', + command: expt, + attributes: { title: 'View code' } + } + ] + }, + { + id: 'views', + buttons: [ + { + id: osm, + className: 'fa fa-paint-brush', + command: osm, + active: true, + attributes: { title: 'Open Style Manager' } + }, + { + id: otm, + className: 'fa fa-cog', + command: otm, + attributes: { title: 'Settings' } + }, + { + id: ola, + className: 'fa fa-bars', + command: ola, + attributes: { title: 'Open Layer Manager' } + }, + { + id: obl, + className: 'fa fa-th-large', + command: obl, + attributes: { title: 'Open Blocks' } + } + ] + } + ], // Editor model - em : null, + em: null, // Delay before show children buttons (in milliseconds) - delayBtnsShow : 300, + delayBtnsShow: 300 }; diff --git a/src/panels/index.js b/src/panels/index.js index 0ec6920a1..1cd05439b 100644 --- a/src/panels/index.js +++ b/src/panels/index.js @@ -47,15 +47,14 @@ */ module.exports = () => { var c = {}, - defaults = require('./config/config'), - Panel = require('./model/Panel'), - Panels = require('./model/Panels'), - PanelView = require('./view/PanelView'), - PanelsView = require('./view/PanelsView'); + defaults = require('./config/config'), + Panel = require('./model/Panel'), + Panels = require('./model/Panels'), + PanelView = require('./view/PanelView'), + PanelsView = require('./view/PanelsView'); var panels, PanelsViewObj; return { - /** * Name of the module * @type {String} @@ -70,18 +69,16 @@ module.exports = () => { init(config) { c = config || {}; for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } var ppfx = c.pStylePrefix; - if(ppfx) - c.stylePrefix = ppfx + c.stylePrefix; + if (ppfx) c.stylePrefix = ppfx + c.stylePrefix; panels = new Panels(c.defaults); PanelsViewObj = new PanelsView({ - collection : panels, - config : c, + collection: panels, + config: c }); return this; }, @@ -116,7 +113,7 @@ module.exports = () => { addPanel(panel) { return panels.add(panel); }, - + /** * Remove a panel from the collection * @param {Object|Panel|String} panel Object with right properties or an instance of Panel or Painel id @@ -127,9 +124,9 @@ module.exports = () => { * visible : true, * buttons : [...], * }); - * + * * const newPanel = panelManager.removePanel('myNewPanel'); - * + * */ removePanel(panel) { return panels.remove(panel); @@ -143,7 +140,7 @@ module.exports = () => { * var myPanel = panelManager.getPanel('myNewPanel'); */ getPanel(id) { - var res = panels.where({id}); + var res = panels.where({ id }); return res.length ? res[0] : null; }, @@ -178,15 +175,15 @@ module.exports = () => { * } */ addButton(panelId, button) { - var pn = this.getPanel(panelId); + var pn = this.getPanel(panelId); return pn ? pn.get('buttons').add(button) : null; }, - + /** * Remove button from the panel * @param {string} panelId Panel's ID * @param {Object|Button|String} button Button object or instance of Button or button id - * @return {Button|null} Removed button. + * @return {Button|null} Removed button. * @example * const removedButton = panelManager.removeButton('myNewPanel',{ * id: 'myNewButton', @@ -195,13 +192,13 @@ module.exports = () => { * attributes: { title: 'Some title'}, * active: false, * }); - * + * * // It's also possible to use the button id * const removedButton = panelManager.removeButton('myNewPanel','myNewButton'); - * + * */ removeButton(panelId, button) { - var pn = this.getPanel(panelId); + var pn = this.getPanel(panelId); return pn && pn.get('buttons').remove(button); }, @@ -214,9 +211,9 @@ module.exports = () => { * var button = panelManager.getButton('myPanel','myButton'); */ getButton(panelId, id) { - var pn = this.getPanel(panelId); - if(pn){ - var res = pn.get('buttons').where({id}); + var pn = this.getPanel(panelId); + if (pn) { + var res = pn.get('buttons').where({ id }); return res.length ? res[0] : null; } return null; @@ -236,27 +233,24 @@ module.exports = () => { */ active() { this.getPanels().each(p => { - p.get('buttons').each(btn => { - if(btn.get('active')) - btn.trigger('updateActive'); - }); + p.get('buttons').each(btn => { + if (btn.get('active')) btn.trigger('updateActive'); }); + }); }, - + /** * Disable buttons flagged as disabled * @private */ disableButtons() { this.getPanels().each(p => { - p.get('buttons').each(btn => { - if(btn.get('disable')) - btn.trigger('change:disable'); - }); + p.get('buttons').each(btn => { + if (btn.get('disable')) btn.trigger('change:disable'); }); + }); }, - Panel, - + Panel }; }; diff --git a/src/panels/model/Button.js b/src/panels/model/Button.js index 559fcd55d..5218e477e 100644 --- a/src/panels/model/Button.js +++ b/src/panels/model/Button.js @@ -1,8 +1,7 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - - defaults :{ + defaults: { id: '', className: '', command: '', @@ -14,14 +13,13 @@ module.exports = Backbone.Model.extend({ dragDrop: false, runDefaultCommand: true, stopDefaultCommand: false, - disable: false, + disable: false }, initialize(options) { - if(this.get('buttons').length){ - var Buttons = require('./Buttons'); - this.set('buttons', new Buttons(this.get('buttons')) ); + if (this.get('buttons').length) { + var Buttons = require('./Buttons'); + this.set('buttons', new Buttons(this.get('buttons'))); } - }, - + } }); diff --git a/src/panels/model/Buttons.js b/src/panels/model/Buttons.js index 74901156b..9d343e0b9 100644 --- a/src/panels/model/Buttons.js +++ b/src/panels/model/Buttons.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var Button = require('./Button'); module.exports = Backbone.Collection.extend({ - model: Button, /** @@ -14,10 +13,10 @@ module.exports = Backbone.Collection.extend({ * */ deactivateAllExceptOne(except, r) { this.forEach((model, index) => { - if(model !== except){ + if (model !== except) { model.set('active', false); - if(r && model.get('buttons').length) - model.get('buttons').deactivateAllExceptOne(except,r); + if (r && model.get('buttons').length) + model.get('buttons').deactivateAllExceptOne(except, r); } }); }, @@ -31,14 +30,14 @@ module.exports = Backbone.Collection.extend({ deactivateAll(ctx) { var context = ctx || ''; this.forEach((model, index) => { - if( model.get('context') == context ){ + if (model.get('context') == context) { model.set('active', false); - if(model.get('buttons').length) + if (model.get('buttons').length) model.get('buttons').deactivateAll(context); } }); }, - + /** * Disables all buttons * @param {String} ctx Context string @@ -48,9 +47,9 @@ module.exports = Backbone.Collection.extend({ disableAllButtons(ctx) { var context = ctx || ''; this.forEach((model, index) => { - if( model.get('context') == context ){ + if (model.get('context') == context) { model.set('disable', true); - if(model.get('buttons').length) + if (model.get('buttons').length) model.get('buttons').disableAllButtons(context); } }); @@ -65,12 +64,11 @@ module.exports = Backbone.Collection.extend({ * */ disableAllButtonsExceptOne(except, r) { this.forEach((model, index) => { - if(model !== except){ + if (model !== except) { model.set('disable', true); - if(r && model.get('buttons').length) - model.get('buttons').disableAllButtonsExceptOne(except,r); + if (r && model.get('buttons').length) + model.get('buttons').disableAllButtonsExceptOne(except, r); } }); - }, - + } }); diff --git a/src/panels/model/Panel.js b/src/panels/model/Panel.js index 1ac83c765..d0e545fd4 100644 --- a/src/panels/model/Panel.js +++ b/src/panels/model/Panel.js @@ -2,18 +2,17 @@ var Backbone = require('backbone'); var Buttons = require('./Buttons'); module.exports = Backbone.Model.extend({ - defaults: { id: '', content: '', visible: true, buttons: [], + attributes: {} }, initialize(options) { this.btn = this.get('buttons') || []; this.buttons = new Buttons(this.btn); this.set('buttons', this.buttons); - }, - + } }); diff --git a/src/panels/model/Panels.js b/src/panels/model/Panels.js index 01e040ca5..5f7db27bf 100644 --- a/src/panels/model/Panels.js +++ b/src/panels/model/Panels.js @@ -2,5 +2,5 @@ var Backbone = require('backbone'); var Panel = require('./Panel'); module.exports = Backbone.Collection.extend({ - model: Panel, + model: Panel }); diff --git a/src/panels/view/ButtonView.js b/src/panels/view/ButtonView.js index 8219d8968..e420016b0 100644 --- a/src/panels/view/ButtonView.js +++ b/src/panels/view/ButtonView.js @@ -2,11 +2,20 @@ import { isString, isObject, isFunction } from 'underscore'; const $ = Backbone.$; module.exports = Backbone.View.extend({ - tagName: 'span', initialize(o) { - _.bindAll(this, 'startTimer', 'stopTimer', 'showButtons', 'hideButtons','closeOnKeyPress','onDrop', 'initSorter', 'stopDrag'); + _.bindAll( + this, + 'startTimer', + 'stopTimer', + 'showButtons', + 'hideButtons', + 'closeOnKeyPress', + 'onDrop', + 'initSorter', + 'stopDrag' + ); var cls = this.model.get('className'); this.config = o.config || {}; this.em = this.config.em || {}; @@ -27,26 +36,24 @@ module.exports = Backbone.View.extend({ this.listenTo(this.model, 'change:className', this.updateClassName); this.listenTo(this.model, 'change:disable', this.updateDisable); - if(this.model.get('buttons').length){ + if (this.model.get('buttons').length) { this.$el.on('mousedown', this.startTimer); - this.$el.append($('
',{class: pfx + 'arrow-rd'})); + this.$el.append($('
', { class: pfx + 'arrow-rd' })); } - if(this.em && this.em.get) - this.commands = this.em.get('Commands'); + if (this.em && this.em.get) this.commands = this.em.get('Commands'); this.events = {}; - if(this.model.get('dragDrop')){ + if (this.model.get('dragDrop')) { this.events.mousedown = 'initDrag'; this.em.on('loaded', this.initSorter); - }else - this.events.click = 'clicked'; + } else this.events.click = 'clicked'; this.delegateEvents(); }, initSorter() { - if(this.em.Canvas){ + if (this.em.Canvas) { var canvas = this.em.Canvas; this.canvasEl = canvas.getBody(); this.sorter = new this.em.Utils.Sorter({ @@ -60,7 +67,7 @@ module.exports = Backbone.View.extend({ document: canvas.getFrameEl().contentDocument, direction: 'a', wmargin: 1, - nested: 1, + nested: 1 }); var offDim = canvas.getOffset(); this.sorter.offTop = offDim.top; @@ -119,7 +126,7 @@ module.exports = Backbone.View.extend({ * @return void * */ updateAttributes() { - this.$el.attr(this.model.get("attributes")); + this.$el.attr(this.model.get('attributes')); }, /** @@ -128,13 +135,10 @@ module.exports = Backbone.View.extend({ * @return void * */ updateBtnsVis() { - if(!this.$buttons) - return; + if (!this.$buttons) return; - if(this.model.get('bntsVis')) - this.$buttons.addClass(this.btnsVisCls); - else - this.$buttons.removeClass(this.btnsVisCls); + if (this.model.get('bntsVis')) this.$buttons.addClass(this.btnsVisCls); + else this.$buttons.removeClass(this.btnsVisCls); }, /** @@ -153,9 +157,8 @@ module.exports = Backbone.View.extend({ * @return void * */ stopTimer() { - $(document).off('mouseup', this.stopTimer); - if(this.timeout) - clearTimeout(this.timeout); + $(document).off('mouseup', this.stopTimer); + if (this.timeout) clearTimeout(this.timeout); }, /** @@ -166,8 +169,8 @@ module.exports = Backbone.View.extend({ showButtons() { clearTimeout(this.timeout); this.model.set('bntsVis', true); - $(document).on('mousedown', this.hideButtons); - $(document).on('keypress', this.closeOnKeyPress); + $(document).on('mousedown', this.hideButtons); + $(document).on('keypress', this.closeOnKeyPress); }, /** @@ -176,10 +179,12 @@ module.exports = Backbone.View.extend({ * @return void * */ hideButtons(e) { - if(e){ $(e.target).trigger('click'); } + if (e) { + $(e.target).trigger('click'); + } this.model.set('bntsVis', false); - $(document).off('mousedown', this.hideButtons); - $(document).off('keypress', this.closeOnKeyPress); + $(document).off('mousedown', this.hideButtons); + $(document).off('keypress', this.closeOnKeyPress); }, /** @@ -190,8 +195,7 @@ module.exports = Backbone.View.extend({ * */ closeOnKeyPress(e) { var key = e.which || e.keyCode; - if(key == 27) - this.hideButtons(); + if (key == 27) this.hideButtons(); }, /** @@ -208,7 +212,7 @@ module.exports = Backbone.View.extend({ var commandName = model.get('command'); if (this.commands && isString(commandName)) { - command = this.commands.get(commandName) || {}; + command = this.commands.get(commandName) || {}; } else if (isFunction(commandName)) { command = { run: commandName }; } else if (commandName !== null && isObject(commandName)) { @@ -218,7 +222,8 @@ module.exports = Backbone.View.extend({ if (model.get('active')) { model.collection.deactivateAll(context); model.set('active', true, { silent: true }).trigger('checkActive'); - parent && parent.set('active', true, { silent: true }).trigger('checkActive'); + parent && + parent.set('active', true, { silent: true }).trigger('checkActive'); if (command.run) { command.run(editor, model, model.get('options')); @@ -230,7 +235,8 @@ module.exports = Backbone.View.extend({ } else { this.$el.removeClass(this.activeCls); model.collection.deactivateAll(context); - parent && parent.set('active', false, { silent: true }).trigger('checkActive'); + parent && + parent.set('active', false, { silent: true }).trigger('checkActive'); if (command.stop) { command.stop(editor, model, model.get('options')); @@ -240,12 +246,11 @@ module.exports = Backbone.View.extend({ }, updateDisable() { - if(this.model.get('disable')) { + if (this.model.get('disable')) { this.$el.addClass(this.disableCls); } else { this.$el.removeClass(this.disableCls); } - }, /** @@ -254,10 +259,8 @@ module.exports = Backbone.View.extend({ * @return void * */ checkActive() { - if(this.model.get('active')) - this.$el.addClass(this.activeCls); - else - this.$el.removeClass(this.activeCls); + if (this.model.get('active')) this.$el.addClass(this.activeCls); + else this.$el.removeClass(this.activeCls); }, /** @@ -267,19 +270,15 @@ module.exports = Backbone.View.extend({ * @return void * */ clicked(e) { - if(this.model.get('bntsVis') ) - return; + if (this.model.get('bntsVis')) return; - if(this.model.get('disable') ) - return; + if (this.model.get('disable')) return; this.toogleActive(); }, toogleActive() { - - if(this.parentM) - this.swapParent(); + if (this.parentM) this.swapParent(); var active = this.model.get('active'); this.model.set('active', !active); @@ -287,12 +286,10 @@ module.exports = Backbone.View.extend({ // If the stop is requested var command = this.em.get('Commands').get('select-comp'); - if(active){ - if(this.model.get('runDefaultCommand')) - this.em.runDefault(); - }else{ - if(this.model.get('stopDefaultCommand')) - this.em.stopDefault(); + if (active) { + if (this.model.get('runDefaultCommand')) this.em.runDefault(); + } else { + if (this.model.get('stopDefaultCommand')) this.em.stopDefault(); } }, @@ -303,10 +300,10 @@ module.exports = Backbone.View.extend({ * */ swapParent() { 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('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', true, { silent: true }).trigger('checkActive'); }, @@ -314,19 +311,18 @@ module.exports = Backbone.View.extend({ this.updateAttributes(); this.$el.attr('class', this.className); - if(this.model.get('buttons').length){ - var btnsView = require('./ButtonsView'); //Avoid Circular Dependencies + if (this.model.get('buttons').length) { + var btnsView = require('./ButtonsView'); //Avoid Circular Dependencies var view = new btnsView({ - collection : this.model.get('buttons'), - config : this.config, - parentM : this.model + collection: this.model.get('buttons'), + config: this.config, + parentM: this.model }); - this.$buttons = view.render().$el; - this.$buttons.append($('
',{class: this.pfx + 'arrow-l'})); - this.$el.append(this.$buttons); //childNodes avoids wrapping 'div' + this.$buttons = view.render().$el; + this.$buttons.append($('
', { class: this.pfx + 'arrow-l' })); + this.$el.append(this.$buttons); //childNodes avoids wrapping 'div' } return this; - }, - + } }); diff --git a/src/panels/view/ButtonsView.js b/src/panels/view/ButtonsView.js index 8f48aca1c..6ca613fe6 100644 --- a/src/panels/view/ButtonsView.js +++ b/src/panels/view/ButtonsView.js @@ -2,14 +2,13 @@ var Backbone = require('backbone'); var ButtonView = require('./ButtonView'); module.exports = Backbone.View.extend({ - initialize(o) { this.opt = o || {}; 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.listenTo(this.collection, 'add', this.addTo); + this.listenTo(this.collection, 'reset', this.render); this.className = this.pfx + 'buttons'; }, @@ -31,19 +30,19 @@ module.exports = Backbone.View.extend({ * @return Object Object created * */ addToCollection(model, fragmentEl) { - var fragment = fragmentEl || null; - var viewObject = ButtonView; + var fragment = fragmentEl || null; + var viewObject = ButtonView; - var view = new viewObject({ + var view = new viewObject({ model, - config : this.config, - parentM : this.parentM + config: this.config, + parentM: this.parentM }); - var rendered = view.render().el; + var rendered = view.render().el; - if(fragment){ + if (fragment) { fragment.appendChild(rendered); - }else{ + } else { this.$el.append(rendered); } @@ -54,7 +53,7 @@ module.exports = Backbone.View.extend({ var fragment = document.createDocumentFragment(); this.$el.empty(); - this.collection.each(function(model){ + this.collection.each(function(model) { this.addToCollection(model, fragment); }, this); diff --git a/src/panels/view/PanelView.js b/src/panels/view/PanelView.js index dd6f689fa..d28ba457f 100644 --- a/src/panels/view/PanelView.js +++ b/src/panels/view/PanelView.js @@ -2,7 +2,6 @@ var Backbone = require('backbone'); var ButtonsView = require('./ButtonsView'); module.exports = Backbone.View.extend({ - initialize(o) { const config = o.config || {}; this.config = config; @@ -29,6 +28,10 @@ module.exports = Backbone.View.extend({ this.$el.html(this.model.get('content')); }, + attributes() { + return this.model.get('attributes'); + }, + initResize() { const em = this.config.em; const editor = em ? em.get('Editor') : ''; @@ -37,7 +40,10 @@ module.exports = Backbone.View.extend({ if (editor && resizable) { var resz = resizable === true ? [1, 1, 1, 1] : resizable; var resLen = resz.length; - var tc, cr, bc, cl = 0; + var tc, + cr, + bc, + cl = 0; // Choose which sides of the panel are resizable if (resLen == 2) { @@ -63,10 +69,11 @@ module.exports = Backbone.View.extend({ br: 0, appendTo: this.el, prefix: editor.getConfig().stylePrefix, - posFetcher: (el) => { + posFetcher: el => { var rect = el.getBoundingClientRect(); return { - left: 0, top: 0, + left: 0, + top: 0, width: rect.width, height: rect.height }; @@ -84,15 +91,14 @@ module.exports = Backbone.View.extend({ this.id && el.attr('id', this.id); if (this.buttons.length) { - var buttons = new ButtonsView({ + var buttons = new ButtonsView({ collection: this.buttons, - config: this.config, + config: this.config }); el.append(buttons.render().el); } el.append(this.model.get('content')); return this; - }, - + } }); diff --git a/src/panels/view/PanelsView.js b/src/panels/view/PanelsView.js index 34ac7682a..3ed5cf045 100644 --- a/src/panels/view/PanelsView.js +++ b/src/panels/view/PanelsView.js @@ -2,13 +2,12 @@ var Backbone = require('backbone'); var PanelView = require('./PanelView'); module.exports = Backbone.View.extend({ - initialize(o) { this.opt = o || {}; 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.listenTo(this.collection, 'add', this.addTo); + this.listenTo(this.collection, 'reset', this.render); this.className = this.pfx + 'panels'; }, @@ -36,7 +35,7 @@ module.exports = Backbone.View.extend({ var fragment = fragmentEl || null; var view = new PanelView({ model, - config: this.config, + config: this.config }); var rendered = view.render().el; var appendTo = model.get('appendTo'); @@ -60,7 +59,7 @@ module.exports = Backbone.View.extend({ var fragment = document.createDocumentFragment(); this.$el.empty(); - this.collection.each(function(model){ + this.collection.each(function(model) { this.addToCollection(model, fragment); }, this); diff --git a/src/parser/config/config.js b/src/parser/config/config.js index 0302532ac..31922f6db 100644 --- a/src/parser/config/config.js +++ b/src/parser/config/config.js @@ -1,5 +1,3 @@ module.exports = { - - textTags: ['br', 'b', 'i', 'u', 'a', 'ul', 'ol'], - + textTags: ['br', 'b', 'i', 'u', 'a', 'ul', 'ol'] }; diff --git a/src/parser/index.js b/src/parser/index.js index e0b9ededd..c9d6bb021 100644 --- a/src/parser/index.js +++ b/src/parser/index.js @@ -1,12 +1,11 @@ module.exports = () => { var c = {}, - defaults = require('./config/config'), - parserCss = require('./model/ParserCss'), - parserHtml = require('./model/ParserHtml'); + defaults = require('./config/config'), + parserCss = require('./model/ParserCss'), + parserHtml = require('./model/ParserHtml'); var pHtml, pCss; return { - compTypes: '', /** @@ -34,8 +33,7 @@ module.exports = () => { init(config) { c = config || {}; for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } pHtml = new parserHtml(c); pCss = new parserCss(c); @@ -54,7 +52,6 @@ module.exports = () => { parseCss(str) { return pCss.parse(str); - }, - + } }; }; diff --git a/src/parser/model/ParserCss.js b/src/parser/model/ParserCss.js index 9ddf2ad5b..7746a49eb 100644 --- a/src/parser/model/ParserCss.js +++ b/src/parser/model/ParserCss.js @@ -22,7 +22,7 @@ module.exports = config => ({ var sel = sels[i].trim(); // Will accept only concatenated classes and last // class might be with state (eg. :hover), nothing else. - if (/^(\.{1}[\w\-]+)+(:{1,2}[\w\-()]+)?$/ig.test(sel)) { + if (/^(\.{1}[\w\-]+)+(:{1,2}[\w\-()]+)?$/gi.test(sel)) { var cls = sel.split('.').filter(Boolean); result.push(cls); } else { @@ -31,7 +31,7 @@ module.exports = config => ({ } return { result, - add, + add }; }, @@ -50,11 +50,11 @@ module.exports = config => ({ var selsAdd = []; // It's a CSSMediaRule - if(node.cssRules) { + if (node.cssRules) { var subRules = this.parseNode(node); var mediaText = node.media.mediaText; - for( var s = 0, lens = subRules.length; s < lens; s++) { + for (var s = 0, lens = subRules.length; s < lens; s++) { var subRule = subRules[s]; subRule.mediaText = mediaText ? mediaText.trim() : ''; } @@ -62,8 +62,7 @@ module.exports = config => ({ result = result.concat(subRules); } - if(!sels) - continue; + if (!sels) continue; var selsParsed = this.parseSelector(sels); sels = selsParsed.result; @@ -77,7 +76,7 @@ module.exports = config => ({ const propName = stl[j]; const propValue = stl.getPropertyValue(propName); const important = stl.getPropertyPriority(propName); - style[propName] = `${propValue}${important ? ` !${important}` : ''}` + style[propName] = `${propValue}${important ? ` !${important}` : ''}`; } var lastRule = ''; @@ -88,7 +87,7 @@ module.exports = config => ({ //Isolate state from selector var stateArr = selArr[selArr.length - 1].split(/:(.+)/); - if(stateArr[1]){ + if (stateArr[1]) { selArr[selArr.length - 1] = stateArr[0]; model.state = stateArr[1]; stateArr.splice(stateArr.length - 1, 1); @@ -110,11 +109,10 @@ module.exports = config => ({ result.push({ selectors: [], selectorsAdd: selsAddStr, - style, + style }); } } - } return result; @@ -140,8 +138,7 @@ module.exports = config => ({ document.head.removeChild(el); var result = this.parseNode(sheet); - if(result.length == 1) - result = result[0]; + if (result.length == 1) result = result[0]; return result; } diff --git a/src/parser/model/ParserHtml.js b/src/parser/model/ParserHtml.js index da858228a..021c5dbf9 100644 --- a/src/parser/model/ParserHtml.js +++ b/src/parser/model/ParserHtml.js @@ -1,11 +1,9 @@ module.exports = config => { - var TEXT_NODE = 'span'; var c = config; var modelAttrStart = 'data-gjs-'; return { - compTypes: '', /** @@ -22,10 +20,12 @@ module.exports = config => { var decls = str.split(';'); for (var i = 0, len = decls.length; i < len; i++) { var decl = decls[i].trim(); - if(!decl) - continue; + if (!decl) continue; var prop = decl.split(':'); - result[prop[0].trim()] = prop.slice(1).join(':').trim(); + result[prop[0].trim()] = prop + .slice(1) + .join(':') + .trim(); } return result; }, @@ -45,8 +45,7 @@ module.exports = config => { for (var i = 0, len = cls.length; i < len; i++) { var cl = cls[i].trim(); var reg = new RegExp('^' + c.pStylePrefix); - if(!cl || reg.test(cl)) - continue; + if (!cl || reg.test(cl)) continue; result.push(cl); } return result; @@ -117,8 +116,11 @@ module.exports = config => { // I can get false positive here (eg. a selector '[data-attr]') // so put it under try/catch and let fail silently try { - nodeValue = (firstChar == '{' && lastChar == '}') || - (firstChar == '[' && lastChar == ']') ? JSON.parse(nodeValue) : nodeValue; + nodeValue = + (firstChar == '{' && lastChar == '}') || + (firstChar == '[' && lastChar == ']') + ? JSON.parse(nodeValue) + : nodeValue; } catch (e) {} model[modelAttr] = nodeValue; @@ -167,8 +169,10 @@ module.exports = config => { const comp = comps[ci]; const cType = comp.type; - if (['text', 'textnode'].indexOf(cType) < 0 && - c.textTags.indexOf(comp.tagName) < 0 ) { + if ( + ['text', 'textnode'].indexOf(cType) < 0 && + c.textTags.indexOf(comp.tagName) < 0 + ) { allTxt = 0; break; } @@ -202,44 +206,38 @@ module.exports = config => { */ parse(str, parserCss) { var config = (c.em && c.em.get('Config')) || {}; - var res = { html: '', css: ''}; + var res = { html: '', css: '' }; var el = document.createElement('div'); el.innerHTML = str; var scripts = el.querySelectorAll('script'); var i = scripts.length; // Remove all scripts - if(!config.allowScripts){ - while (i--) - scripts[i].parentNode.removeChild(scripts[i]); + if (!config.allowScripts) { + while (i--) scripts[i].parentNode.removeChild(scripts[i]); } // Detach style tags and parse them - if(parserCss){ + if (parserCss) { var styleStr = ''; var styles = el.querySelectorAll('style'); var j = styles.length; - while (j--){ + while (j--) { styleStr = styles[j].innerHTML + styleStr; styles[j].parentNode.removeChild(styles[j]); } - if(styleStr) - res.css = parserCss.parse(styleStr); + if (styleStr) res.css = parserCss.parse(styleStr); } var result = this.parseNode(el); - if(result.length == 1) - result = result[0]; + if (result.length == 1) result = result[0]; res.html = result; return res; - - }, - + } }; - }; diff --git a/src/plugin_manager/index.js b/src/plugin_manager/index.js index 9aafde072..225e9cf89 100644 --- a/src/plugin_manager/index.js +++ b/src/plugin_manager/index.js @@ -1,18 +1,15 @@ module.exports = config => { - var c = config || {}, - defaults = require('./config/config'); + defaults = require('./config/config'); // Set default options for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } var plugins = {}; return { - /** * Add new plugin. Plugins could not be overwritten * @param {string} id Plugin ID @@ -55,6 +52,5 @@ module.exports = config => { getAll() { return plugins; } - }; }; diff --git a/src/rich_text_editor/config/config.js b/src/rich_text_editor/config/config.js index f27a589f0..22b0e7351 100644 --- a/src/rich_text_editor/config/config.js +++ b/src/rich_text_editor/config/config.js @@ -1,11 +1,10 @@ module.exports = { - - stylePrefix : 'rte-', + stylePrefix: 'rte-', // If true, moves the toolbar below the element when the top canvas // edge is reached adjustToolbar: 1, // Default RTE actions - actions: ['bold', 'italic', 'underline', 'strikethrough', 'link'], + actions: ['bold', 'italic', 'underline', 'strikethrough', 'link'] }; diff --git a/src/rich_text_editor/index.js b/src/rich_text_editor/index.js index 2e9c5e453..d2bec1c8a 100644 --- a/src/rich_text_editor/index.js +++ b/src/rich_text_editor/index.js @@ -14,7 +14,7 @@ * @module RichTextEditor */ import RichTextEditor from './model/RichTextEditor'; -import {on, off} from 'utils/mixins' +import { on, off } from 'utils/mixins'; module.exports = () => { let config = {}; @@ -30,7 +30,6 @@ module.exports = () => { }; return { - customRte: null, /** @@ -71,7 +70,6 @@ module.exports = () => { return this; }, - /** * Post render callback * @param {View} ev @@ -84,7 +82,6 @@ module.exports = () => { canvas.getToolsEl().appendChild(toolbar); }, - /** * Init the built-in RTE * @param {HTMLElement} el @@ -99,14 +96,14 @@ module.exports = () => { const classes = { actionbar: `${pfx}actionbar`, button: `${pfx}action`, - active: `${pfx}active`, + active: `${pfx}active` }; const rte = new RichTextEditor({ el, classes, actions, actionbar, - actionbarContainer, + actionbarContainer }); globalRte && globalRte.setEl(el); @@ -158,7 +155,7 @@ module.exports = () => { */ add(name, action = {}) { action.name = name; - globalRte.addAction(action, {sync: 1}); + globalRte.addAction(action, { sync: 1 }); }, /** @@ -225,7 +222,7 @@ module.exports = () => { const un = 'px'; const canvas = config.em.get('Canvas'); const pos = canvas.getTargetToElementDim(toolbar, lastEl, { - event: 'rteToolbarPosUpdate', + event: 'rteToolbarPosUpdate' }); if (config.adjustToolbar) { @@ -285,6 +282,6 @@ module.exports = () => { hideToolbar(); em && em.trigger('rte:disable', view, rte); - }, + } }; }; diff --git a/src/rich_text_editor/model/RichTextEditor.js b/src/rich_text_editor/model/RichTextEditor.js index 11631fcc5..40cdad27f 100644 --- a/src/rich_text_editor/model/RichTextEditor.js +++ b/src/rich_text_editor/model/RichTextEditor.js @@ -1,7 +1,7 @@ // The initial version of this RTE was borrowed from https://github.com/jaredreich/pell // and adapted to the GrapesJS's need -import {on, off} from 'utils/mixins' +import { on, off } from 'utils/mixins'; const RTE_KEY = '_rte'; @@ -9,40 +9,40 @@ const defActions = { bold: { name: 'bold', icon: 'B', - attributes: {title: 'Bold'}, - result: (rte) => rte.exec('bold') + attributes: { title: 'Bold' }, + result: rte => rte.exec('bold') }, italic: { name: 'italic', icon: 'I', - attributes: {title: 'Italic'}, - result: (rte) => rte.exec('italic') + attributes: { title: 'Italic' }, + result: rte => rte.exec('italic') }, underline: { name: 'underline', icon: 'U', - attributes: {title: 'Underline'}, - result: (rte) => rte.exec('underline') + attributes: { title: 'Underline' }, + result: rte => rte.exec('underline') }, strikethrough: { name: 'strikethrough', icon: 'S', - attributes: {title: 'Strike-through'}, - result: (rte) => rte.exec('strikeThrough') + attributes: { title: 'Strike-through' }, + result: rte => rte.exec('strikeThrough') }, link: { icon: `⫘`, name: 'link', attributes: { style: 'font-size:1.4rem;padding:0 4px 2px;', - title: 'Link', + title: 'Link' }, - result: (rte) => rte.insertHTML(`${rte.selection()}`) + result: rte => + rte.insertHTML(`${rte.selection()}`) } -} +}; export default class RichTextEditor { - constructor(settings = {}) { const el = settings.el; @@ -56,21 +56,25 @@ export default class RichTextEditor { const settAct = settings.actions || []; settAct.forEach((action, i) => { - if (typeof action === 'string') { - action = defActions[action]; - } else if (defActions[action.name]) { - action = {...defActions[action.name], ...action}; - } - settAct[i] = action; + if (typeof action === 'string') { + action = defActions[action]; + } else if (defActions[action.name]) { + action = { ...defActions[action.name], ...action }; + } + settAct[i] = action; }); - const actions = settAct.length ? settAct : - Object.keys(defActions).map(action => defActions[action]) - - settings.classes = { ...{ - actionbar: 'actionbar', - button: 'action', - active: 'active', - }, ...settings.classes}; + const actions = settAct.length + ? settAct + : Object.keys(defActions).map(action => defActions[action]); + + settings.classes = { + ...{ + actionbar: 'actionbar', + button: 'action', + active: 'active' + }, + ...settings.classes + }; const classes = settings.classes; let actionbar = settings.actionbar; @@ -85,7 +89,7 @@ export default class RichTextEditor { actionbar.className = classes.actionbar; actionbarCont.appendChild(actionbar); this.actionbar = actionbar; - actions.forEach(action => this.addAction(action)) + actions.forEach(action => this.addAction(action)); } settings.styleWithCSS && this.exec('styleWithCSS'); @@ -114,7 +118,7 @@ export default class RichTextEditor { } update && update(this, action); - }) + }); } enable() { @@ -124,7 +128,7 @@ export default class RichTextEditor { this.actionbarEl().style.display = ''; this.el.contentEditable = true; - on(this.el, 'mouseup keyup', this.updateActiveActions) + on(this.el, 'mouseup keyup', this.updateActiveActions); this.syncActions(); this.updateActiveActions(); this.el.focus(); @@ -150,7 +154,7 @@ export default class RichTextEditor { action.result(this, action); this.updateActiveActions(); }; - }) + }); } /** @@ -197,7 +201,7 @@ export default class RichTextEditor { * @return {Selection} */ selection() { - return this.doc.getSelection() + return this.doc.getSelection(); } /** @@ -235,7 +239,7 @@ export default class RichTextEditor { Array.prototype.slice.call(node.childNodes).forEach(nd => { range.insertNode(nd); lastNode = nd; - }) + }); sel.removeAllRanges(); sel.addRange(range); diff --git a/src/selector_manager/config/config.js b/src/selector_manager/config/config.js index 4da150b4a..8bad09938 100644 --- a/src/selector_manager/config/config.js +++ b/src/selector_manager/config/config.js @@ -1,5 +1,4 @@ module.exports = { - // Style prefix stylePrefix: 'clm-', @@ -16,8 +15,8 @@ module.exports = { // States states: [ - { name: 'hover', label: 'Hover' }, - { name: 'active', label: 'Click' }, - { name: 'nth-of-type(2n)', label: 'Even/Odd' } - ], + { name: 'hover', label: 'Hover' }, + { name: 'active', label: 'Click' }, + { name: 'nth-of-type(2n)', label: 'Even/Odd' } + ] }; diff --git a/src/selector_manager/index.js b/src/selector_manager/index.js index 5a2eadf7a..09209e5be 100644 --- a/src/selector_manager/index.js +++ b/src/selector_manager/index.js @@ -49,18 +49,17 @@ * } */ -import { isString } from 'underscore' +import { isString } from 'underscore'; module.exports = config => { var c = config || {}, - defaults = require('./config/config'), - Selector = require('./model/Selector'), - Selectors = require('./model/Selectors'), - ClassTagsView = require('./view/ClassTagsView'); + defaults = require('./config/config'), + Selector = require('./model/Selector'), + Selectors = require('./model/Selectors'), + ClassTagsView = require('./view/ClassTagsView'); var selectors, selectorTags; return { - Selector, Selectors, @@ -91,8 +90,7 @@ module.exports = config => { c = conf || {}; for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } const em = c.em; @@ -103,14 +101,13 @@ module.exports = config => { } selectorTags = new ClassTagsView({ - collection: new Selectors([], {em,config: c}), - config: c, + collection: new Selectors([], { em, config: c }), + config: c }); // Global selectors container selectors = new Selectors(c.selectors); - selectors.on('add', (model) => - em.trigger('selector:add', model)); + selectors.on('add', model => em.trigger('selector:add', model)); return this; }, @@ -142,7 +139,9 @@ module.exports = config => { } const cname = opts.name; - const selector = cname ? this.get(cname, opts.type) : selectors.where(opts)[0]; + const selector = cname + ? this.get(cname, opts.type) + : selectors.where(opts)[0]; if (!selector) { return selectors.add(opts); @@ -168,11 +167,10 @@ module.exports = config => { classes = classes.trim().split(' '); } - classes.forEach(name => added.push(selectors.add({name}))) + classes.forEach(name => added.push(selectors.add({ name }))); return added; }, - /** * Get the selector by its name * @param {String} name Selector name @@ -182,7 +180,7 @@ module.exports = config => { * var selector = selectorManager.get('selectorName'); * */ get(name, type = Selector.TYPE_CLASS) { - return selectors.where({name, type})[0]; + return selectors.where({ name, type })[0]; }, /** @@ -200,15 +198,13 @@ module.exports = config => { * @private */ render(selectors) { - if(selectors){ + if (selectors) { var view = new ClassTagsView({ collection: new Selectors(selectors), - config: c, + config: c }); return view.render().el; - }else - return selectorTags.render().el; - }, - + } else return selectorTags.render().el; + } }; }; diff --git a/src/selector_manager/model/Selector.js b/src/selector_manager/model/Selector.js index 4f8c921bc..bfdd509e0 100644 --- a/src/selector_manager/model/Selector.js +++ b/src/selector_manager/model/Selector.js @@ -3,77 +3,78 @@ var Backbone = require('backbone'); const TYPE_CLASS = 1; const TYPE_ID = 2; -const Selector = Backbone.Model.extend({ - - idAttribute: 'name', - - defaults: { - name: '', - - label: '', - - // Type of the selector - type: TYPE_CLASS, - - // If not active it's not selectable by the style manager (uncheckboxed) - active: true, - - // Can't be seen by the style manager, therefore even by the user - // Will be rendered only in export code - private: false, - - // If true, can't be removed from the attacched element - protected: false, - }, - - initialize() { - const name = this.get('name'); - const label = this.get('label'); - - if (!name) { - this.set('name', label); - } else if (!label) { - this.set('label', name); +const Selector = Backbone.Model.extend( + { + idAttribute: 'name', + + defaults: { + name: '', + + label: '', + + // Type of the selector + type: TYPE_CLASS, + + // If not active it's not selectable by the style manager (uncheckboxed) + active: true, + + // Can't be seen by the style manager, therefore even by the user + // Will be rendered only in export code + private: false, + + // If true, can't be removed from the attacched element + protected: false + }, + + initialize() { + const name = this.get('name'); + const label = this.get('label'); + + if (!name) { + this.set('name', label); + } else if (!label) { + this.set('label', name); + } + + this.set('name', Selector.escapeName(this.get('name'))); + }, + + /** + * Get full selector name + * @return {string} + */ + getFullName() { + let init = ''; + + switch (this.get('type')) { + case TYPE_CLASS: + init = '.'; + break; + case TYPE_ID: + init = '#'; + break; + } + + return init + this.get('name'); } - - this.set('name', Selector.escapeName(this.get('name'))); }, - - /** - * Get full selector name - * @return {string} - */ - getFullName() { - let init = ''; - - switch (this.get('type')) { - case TYPE_CLASS: - init = '.'; - break; - case TYPE_ID: - init = '#'; - break; + { + // All type selectors: https://developer.mozilla.org/it/docs/Web/CSS/CSS_Selectors + // Here I define only what I need + TYPE_CLASS, + + TYPE_ID, + + /** + * Escape string + * @param {string} name + * @return {string} + * @private + */ + escapeName(name) { + return `${name}`.trim().replace(/([^a-z0-9\w-]+)/gi, '-'); } - - return init + this.get('name'); } - -}, { - // All type selectors: https://developer.mozilla.org/it/docs/Web/CSS/CSS_Selectors - // Here I define only what I need - TYPE_CLASS, - - TYPE_ID, - - /** - * Escape string - * @param {string} name - * @return {string} - * @private - */ - escapeName(name) { - return `${name}`.trim().replace(/([^a-z0-9\w-]+)/gi, '-'); - }, -}); +); module.exports = Selector; diff --git a/src/selector_manager/model/Selectors.js b/src/selector_manager/model/Selectors.js index 119e6f574..a3a800b7a 100644 --- a/src/selector_manager/model/Selectors.js +++ b/src/selector_manager/model/Selectors.js @@ -5,8 +5,10 @@ module.exports = require('backbone').Collection.extend({ model: Selector, getStyleable() { - return filter(this.models, item => - item.get('active') && !item.get('private')); + return filter( + this.models, + item => item.get('active') && !item.get('private') + ); }, getValid() { diff --git a/src/selector_manager/view/ClassTagView.js b/src/selector_manager/view/ClassTagView.js index 96bd42ef6..119c936de 100644 --- a/src/selector_manager/view/ClassTagView.js +++ b/src/selector_manager/view/ClassTagView.js @@ -2,7 +2,6 @@ const Selector = require('./../model/Selector'); const inputProp = 'contentEditable'; module.exports = require('backbone').View.extend({ - template() { const pfx = this.pfx; const ppfx = this.ppfx; @@ -16,15 +15,13 @@ module.exports = require('backbone').View.extend({ `; }, - events: { 'click [data-tag-remove]': 'removeTag', 'click [data-tag-status]': 'changeStatus', 'dblclick [data-tag-name]': 'startEditTag', - 'focusout [data-tag-name]': 'endEditTag', + 'focusout [data-tag-name]': 'endEditTag' }, - initialize(o) { this.config = o.config || {}; this.coll = o.coll || null; @@ -34,7 +31,6 @@ module.exports = require('backbone').View.extend({ this.listenTo(this.model, 'change:active', this.updateStatus); }, - /** * Returns the element which containes the anme of the tag * @return {HTMLElement} @@ -47,7 +43,6 @@ module.exports = require('backbone').View.extend({ return this.inputEl; }, - /** * Start editing tag * @private @@ -58,7 +53,6 @@ module.exports = require('backbone').View.extend({ inputEl.focus(); }, - /** * End editing tag. If the class typed already exists the * old one will be restored otherwise will be changed @@ -82,7 +76,6 @@ module.exports = require('backbone').View.extend({ } }, - /** * Update status of the tag * @private @@ -91,7 +84,6 @@ module.exports = require('backbone').View.extend({ this.model.set('active', !this.model.get('active')); }, - /** * Remove tag from the selected component * @param {Object} e @@ -108,7 +100,6 @@ module.exports = require('backbone').View.extend({ setTimeout(() => this.remove(), 0); }, - /** * Update status of the checkbox * @private @@ -117,19 +108,17 @@ module.exports = require('backbone').View.extend({ var chkOn = 'fa-check-square-o'; var chkOff = 'fa-square-o'; - if(!this.$chk) - this.$chk = this.$el.find('#' + this.pfx + 'checkbox'); + if (!this.$chk) this.$chk = this.$el.find('#' + this.pfx + 'checkbox'); - if(this.model.get('active')){ + if (this.model.get('active')) { this.$chk.removeClass(chkOff).addClass(chkOn); this.$el.removeClass('opac50'); - }else{ + } else { this.$chk.removeClass(chkOn).addClass(chkOff); this.$el.addClass('opac50'); } }, - render() { const pfx = this.pfx; const ppfx = this.ppfx; @@ -137,6 +126,5 @@ module.exports = require('backbone').View.extend({ this.$el.attr('class', `${pfx}tag ${ppfx}three-bg`); this.updateStatus(); return this; - }, - + } }); diff --git a/src/selector_manager/view/ClassTagsView.js b/src/selector_manager/view/ClassTagsView.js index 5eeeadefb..a00019e7f 100644 --- a/src/selector_manager/view/ClassTagsView.js +++ b/src/selector_manager/view/ClassTagsView.js @@ -51,7 +51,11 @@ module.exports = Backbone.View.extend({ this.target = this.config.em; this.em = this.target; - this.listenTo(this.target ,'change:selectedComponent',this.componentChanged); + this.listenTo( + this.target, + 'change:selectedComponent', + this.componentChanged + ); this.listenTo(this.target, 'component:update:classes', this.updateSelector); this.listenTo(this.collection, 'add', this.addNew); @@ -77,8 +81,13 @@ module.exports = Backbone.View.extend({ */ getStateOptions() { var strInput = ''; - for(var i = 0; i < this.states.length; i++){ - strInput += ''; + for (var i = 0; i < this.states.length; i++) { + strInput += + ''; } return strInput; }, @@ -118,10 +127,8 @@ module.exports = Backbone.View.extend({ * @private */ onInputKeyUp(e) { - if (e.keyCode === 13) - this.addNewTag(this.$input.val()); - else if(e.keyCode === 27) - this.endNewTag(); + if (e.keyCode === 13) this.addNewTag(this.$input.val()); + else if (e.keyCode === 27) this.endNewTag(); }, /** @@ -152,14 +159,12 @@ module.exports = Backbone.View.extend({ const em = this.em; const avoidInline = em && em.getConfig('avoidInlineStyle'); - if(this.collection.length || avoidInline) - this.getStatesC().css('display','block'); - else - this.getStatesC().css('display','none'); + if (this.collection.length || avoidInline) + this.getStatesC().css('display', 'block'); + else this.getStatesC().css('display', 'none'); this.updateSelector(); }, - /** * Udpate selector helper * @return {this} @@ -182,14 +187,13 @@ module.exports = Backbone.View.extend({ el && (el.innerHTML = result); }, - /** * Triggered when the select with states is changed * @param {Object} e * @private */ stateChanged(e) { - if(this.compTarget){ + if (this.compTarget) { this.compTarget.set('state', this.$states.val()); this.updateSelector(); } @@ -210,7 +214,7 @@ module.exports = Backbone.View.extend({ if (target) { const sm = target.get('SelectorManager'); - var model = sm.add({label}); + var model = sm.add({ label }); if (component) { var compCls = component.get('classes'); @@ -232,19 +236,17 @@ module.exports = Backbone.View.extend({ * @private * */ addToClasses(model, fragmentEl) { - var fragment = fragmentEl || null; + var fragment = fragmentEl || null; var view = new ClassTagView({ - model, - config: this.config, - coll: this.collection, + model, + config: this.config, + coll: this.collection }); - var rendered = view.render().el; + var rendered = view.render().el; - if(fragment) - fragment.appendChild(rendered); - else - this.getClasses().append(rendered); + if (fragment) fragment.appendChild(rendered); + else this.getClasses().append(rendered); return rendered; }, @@ -257,12 +259,14 @@ module.exports = Backbone.View.extend({ renderClasses() { var fragment = document.createDocumentFragment(); - this.collection.each(function(model){ + this.collection.each(function(model) { this.addToClasses(model, fragment); - },this); + }, this); - if(this.getClasses()) - this.getClasses().empty().append(fragment); + if (this.getClasses()) + this.getClasses() + .empty() + .append(fragment); return this; }, @@ -273,7 +277,7 @@ module.exports = Backbone.View.extend({ * @private */ getClasses() { - if(!this.$classes) + if (!this.$classes) this.$classes = this.$el.find('#' + this.pfx + 'tags-c'); return this.$classes; }, @@ -284,8 +288,7 @@ module.exports = Backbone.View.extend({ * @private */ getStates() { - if(!this.$states) - this.$states = this.$el.find('#' + this.stateInputId); + if (!this.$states) this.$states = this.$el.find('#' + this.stateInputId); return this.$states; }, @@ -295,20 +298,21 @@ module.exports = Backbone.View.extend({ * @private */ getStatesC() { - if(!this.$statesC) - this.$statesC = this.$el.find('#' + this.stateInputC); + if (!this.$statesC) this.$statesC = this.$el.find('#' + this.stateInputC); return this.$statesC; }, render() { const config = this.config; - this.$el.html(this.template({ - selectedLabel: config.selectedLabel, - statesLabel: config.statesLabel, - label: config.label, - pfx: this.pfx, - ppfx: this.ppfx, - })); + this.$el.html( + this.template({ + selectedLabel: config.selectedLabel, + statesLabel: config.statesLabel, + label: config.label, + 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'); @@ -318,6 +322,5 @@ module.exports = Backbone.View.extend({ this.renderClasses(); this.$el.attr('class', this.className); return this; - }, - + } }); diff --git a/src/storage_manager/config/config.js b/src/storage_manager/config/config.js index 77f074a2c..f77f889d0 100644 --- a/src/storage_manager/config/config.js +++ b/src/storage_manager/config/config.js @@ -54,5 +54,4 @@ module.exports = { // true: application/json; charset=utf-8' // false: 'x-www-form-urlencoded' contentTypeJson: false - }; diff --git a/src/storage_manager/index.js b/src/storage_manager/index.js index 20b0e0f28..ff8d8082e 100644 --- a/src/storage_manager/index.js +++ b/src/storage_manager/index.js @@ -7,15 +7,14 @@ */ module.exports = () => { var c = {}, - defaults = require('./config/config'), - LocalStorage = require('./model/LocalStorage'), - RemoteStorage = require('./model/RemoteStorage'); + defaults = require('./config/config'), + LocalStorage = require('./model/LocalStorage'), + RemoteStorage = require('./model/RemoteStorage'); var storages = {}; var defaultStorages = {}; return { - /** * Name of the module * @type {String} @@ -45,11 +44,10 @@ module.exports = () => { c = config || {}; for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } - defaultStorages.remote = new RemoteStorage(c); + defaultStorages.remote = new RemoteStorage(c); defaultStorages.local = new LocalStorage(c); c.currentStorage = c.type; this.loadDefaultProviders().setCurrent(c.type); @@ -88,7 +86,7 @@ module.exports = () => { * @return {this} * */ setStepsBeforeSave(v) { - c.stepsBeforeSave = v; + c.stepsBeforeSave = v; return this; }, @@ -168,8 +166,7 @@ module.exports = () => { var st = this.get(this.getCurrent()); var dataF = {}; - for(var key in data) - dataF[c.id + key] = data[key]; + for (var key in data) dataF[c.id + key] = data[key]; return st ? st.store(dataF, clb) : null; }, @@ -191,22 +188,22 @@ module.exports = () => { var keysF = []; var result = {}; - if(typeof keys === 'string') - keys = [keys]; + if (typeof keys === 'string') keys = [keys]; for (var i = 0, len = keys.length; i < len; i++) keysF.push(c.id + keys[i]); - st && st.load(keysF, res => { - // Restore keys name - var reg = new RegExp('^' + c.id + ''); - for (var itemKey in res) { - var itemKeyR = itemKey.replace(reg, ''); - result[itemKeyR] = res[itemKey]; - } - - clb && clb(result); - }); + st && + st.load(keysF, res => { + // Restore keys name + var reg = new RegExp('^' + c.id + ''); + for (var itemKey in res) { + var itemKeyR = itemKey.replace(reg, ''); + result[itemKeyR] = res[itemKey]; + } + + clb && clb(result); + }); }, /** @@ -215,8 +212,7 @@ module.exports = () => { * @private * */ loadDefaultProviders() { - for (var id in defaultStorages) - this.add(id, defaultStorages[id]); + for (var id in defaultStorages) this.add(id, defaultStorages[id]); return this; }, @@ -227,8 +223,6 @@ module.exports = () => { * */ getConfig() { return c; - }, - + } }; - }; diff --git a/src/storage_manager/model/LocalStorage.js b/src/storage_manager/model/LocalStorage.js index ec8c68875..1e0421dea 100644 --- a/src/storage_manager/model/LocalStorage.js +++ b/src/storage_manager/model/LocalStorage.js @@ -1,19 +1,17 @@ var Backbone = require('backbone'); module.exports = Backbone.Model.extend({ - defaults: { - checkLocal: true, + checkLocal: true }, /** - * @private - */ + * @private + */ store(data, clb) { this.checkStorageEnvironment(); - for(var key in data) - localStorage.setItem(key, data[key]); + for (var key in data) localStorage.setItem(key, data[key]); if (typeof clb == 'function') { clb(); @@ -27,10 +25,9 @@ module.exports = Backbone.Model.extend({ this.checkStorageEnvironment(); var result = {}; - for (var i = 0, len = keys.length; i < len; i++){ + for (var i = 0, len = keys.length; i < len; i++) { var value = localStorage.getItem(keys[i]); - if(value) - result[keys[i]] = value; + if (value) result[keys[i]] = value; } if (typeof clb == 'function') { @@ -55,8 +52,7 @@ module.exports = Backbone.Model.extend({ * @private * */ checkStorageEnvironment() { - if(this.get('checkLocal') && !localStorage) + if (this.get('checkLocal') && !localStorage) console.warn("Your browser doesn't support localStorage"); - }, - + } }); diff --git a/src/storage_manager/model/RemoteStorage.js b/src/storage_manager/model/RemoteStorage.js index df043b096..bb577803d 100644 --- a/src/storage_manager/model/RemoteStorage.js +++ b/src/storage_manager/model/RemoteStorage.js @@ -2,7 +2,6 @@ import fetch from 'utils/fetch'; import { isUndefined } from 'underscore'; module.exports = require('backbone').Model.extend({ - fetch, defaults: { @@ -56,7 +55,7 @@ module.exports = require('backbone').Model.extend({ const em = this.get('em'); const complete = this.get('onComplete'); const typeJson = this.get('contentTypeJson'); - const res = typeJson && typeof text === 'string' ? JSON.parse(text): text; + const res = typeJson && typeof text === 'string' ? JSON.parse(text) : text; complete && complete(res); clb && clb(res); em && em.trigger('storage:response', res); @@ -70,11 +69,11 @@ module.exports = require('backbone').Model.extend({ body[key] = data[key]; } - this.request(this.get('urlStore'), {body}, clb); + this.request(this.get('urlStore'), { body }, clb); }, load(keys, clb) { - this.request(this.get('urlLoad'), {method: 'get'}, clb); + this.request(this.get('urlLoad'), { method: 'get' }, clb); }, /** @@ -121,7 +120,7 @@ module.exports = require('backbone').Model.extend({ fetchOptions = { method: opts.method || 'post', credentials: 'include', - headers, + headers }; // Body should only be included on POST method @@ -131,11 +130,13 @@ module.exports = require('backbone').Model.extend({ this.onStart(); this.fetch(url, fetchOptions) - .then(res => (res.status/200|0) == 1 - ? res.text() - : res.text().then((text) => Promise.reject(text))) - .then((text) => this.onResponse(text, clb)) + .then( + res => + ((res.status / 200) | 0) == 1 + ? res.text() + : res.text().then(text => Promise.reject(text)) + ) + .then(text => this.onResponse(text, clb)) .catch(err => this.onError(err)); - }, - + } }); diff --git a/src/style_manager/config/config.js b/src/style_manager/config/config.js index b38722724..bbda994af 100644 --- a/src/style_manager/config/config.js +++ b/src/style_manager/config/config.js @@ -24,5 +24,5 @@ module.exports = { clearProperties: 0, // Properties not to take in account for computed styles - avoidComputed: ['width', 'height'], + avoidComputed: ['width', 'height'] }; diff --git a/src/style_manager/index.js b/src/style_manager/index.js index 135bd6c88..d6615c3af 100644 --- a/src/style_manager/index.js +++ b/src/style_manager/index.js @@ -40,15 +40,14 @@ */ module.exports = () => { var c = {}, - defaults = require('./config/config'), - Sectors = require('./model/Sectors'), - Properties = require('./model/Properties'), - SectorsView = require('./view/SectorsView'); + defaults = require('./config/config'), + Sectors = require('./model/Sectors'), + Properties = require('./model/Properties'), + SectorsView = require('./view/SectorsView'); let properties; var sectors, SectView; return { - /** * Name of the module * @type {String} @@ -56,7 +55,6 @@ module.exports = () => { */ name: 'StyleManager', - /** * Get configuration object * @return {Object} @@ -66,7 +64,6 @@ module.exports = () => { return c; }, - /** * Initialize module. Automatically called with a new instance of the editor * @param {Object} config Configurations @@ -74,25 +71,22 @@ module.exports = () => { init(config) { c = config || {}; for (var name in defaults) { - if (!(name in c)) - c[name] = defaults[name]; + if (!(name in c)) c[name] = defaults[name]; } var ppfx = c.pStylePrefix; - if(ppfx) - c.stylePrefix = ppfx + c.stylePrefix; + if (ppfx) c.stylePrefix = ppfx + c.stylePrefix; properties = new Properties(); sectors = new Sectors(c.sectors, c); - SectView = new SectorsView({ + SectView = new SectorsView({ collection: sectors, target: c.em, - config: c, + config: c }); return this; }, - /** * Add new sector to the collection. If the sector with the same id already exists, * that one will be returned @@ -111,14 +105,13 @@ module.exports = () => { * */ addSector(id, sector) { var result = this.getSector(id); - if(!result){ + if (!result) { sector.id = id; result = sectors.add(sector); } return result; }, - /** * Get sector by id * @param {string} id Sector id @@ -127,11 +120,10 @@ module.exports = () => { * var sector = styleManager.getSector('mySector'); * */ getSector(id) { - var res = sectors.where({id}); + var res = sectors.where({ id }); return res.length ? res[0] : null; }, - /** * Remove a sector by id * @param {string} id Sector id @@ -143,7 +135,6 @@ module.exports = () => { return this.getSectors().remove(this.getSector(id)); }, - /** * Get all sectors * @return {Sectors} Collection of sectors @@ -152,7 +143,6 @@ module.exports = () => { return sectors; }, - /** * Add property to the sector identified by id * @param {string} sectorId Sector id @@ -192,13 +182,11 @@ module.exports = () => { var prop = null; var sector = this.getSector(sectorId); - if(sector) - prop = sector.get('properties').add(property); + if (sector) prop = sector.get('properties').add(property); return prop; }, - /** * Get property by its CSS name and sector id * @param {string} sectorId Sector id @@ -211,15 +199,14 @@ module.exports = () => { var prop = null; var sector = this.getSector(sectorId); - if(sector){ - prop = sector.get('properties').where({property: name}); + if (sector) { + prop = sector.get('properties').where({ property: name }); prop = prop.length == 1 ? prop[0] : prop; } return prop; }, - /** * Remove a property from the sector * @param {string} sectorId Sector id @@ -233,7 +220,6 @@ module.exports = () => { return props && props.remove(this.getProperty(sectorId, name)); }, - /** * Get properties of the sector * @param {string} sectorId Sector id @@ -245,13 +231,11 @@ module.exports = () => { var props = null; var sector = this.getSector(sectorId); - if(sector) - props = sector.get('properties'); + if (sector) props = sector.get('properties'); return props; }, - /** * Get what to style inside Style Manager. If you select the component * without classes the entity is the Component itself and all changes will @@ -286,7 +270,6 @@ module.exports = () => { return model; }, - /** * Add new property type * @param {string} id Type ID @@ -308,7 +291,6 @@ module.exports = () => { properties.addType(id, definition); }, - /** * Get type * @param {string} id Type ID @@ -318,7 +300,6 @@ module.exports = () => { return properties.getType(id); }, - /** * Get all types * @return {Array} @@ -327,7 +308,6 @@ module.exports = () => { return properties.getTypes(); }, - /** * Create new property from type * @param {string} id Type ID @@ -343,7 +323,7 @@ module.exports = () => { * propView.model.on('change:value', ...); * someContainer.appendChild(propView.el); */ - createType(id, {model = {}, view = {}} = {}) { + createType(id, { model = {}, view = {} } = {}) { const type = this.getType(id); if (type) { @@ -355,14 +335,12 @@ module.exports = () => { } }, - /** * Render sectors and properties * @return {HTMLElement} * */ render() { return SectView.render().el; - }, - + } }; }; diff --git a/src/style_manager/model/Layer.js b/src/style_manager/model/Layer.js index a704c7267..2a99e9fff 100644 --- a/src/style_manager/model/Layer.js +++ b/src/style_manager/model/Layer.js @@ -1,24 +1,25 @@ module.exports = Backbone.Model.extend({ - defaults: { index: '', value: '', values: {}, active: false, preview: false, - properties: [], + properties: [] }, initialize() { const Properties = require('./Properties'); const properties = this.get('properties'); var value = this.get('value'); - this.set('properties', properties instanceof Properties ? - properties : new Properties(properties)); + this.set( + 'properties', + properties instanceof Properties ? properties : new Properties(properties) + ); // If there is no value I'll try to get it from values // I need value setted to make preview working - if(!value){ + if (!value) { var val = ''; var values = this.get('values'); @@ -45,5 +46,4 @@ module.exports = Backbone.Model.extend({ this.get('properties').each(prop => result.push(prop.getFullValue())); return result.join(' '); } - }); diff --git a/src/style_manager/model/Layers.js b/src/style_manager/model/Layers.js index c1fc0b9bd..3411d683c 100644 --- a/src/style_manager/model/Layers.js +++ b/src/style_manager/model/Layers.js @@ -1,7 +1,6 @@ const Layer = require('./Layer'); module.exports = Backbone.Collection.extend({ - model: Layer, initialize() { @@ -11,8 +10,7 @@ module.exports = Backbone.Collection.extend({ }, onAdd(model, c, opts) { - if(!opts.noIncrement) - model.set('index', this.idx++); + if (!opts.noIncrement) model.set('index', this.idx++); }, onReset() { @@ -38,7 +36,7 @@ module.exports = Backbone.Collection.extend({ }); const layerValues = value ? value.split(', ') : []; layerValues.forEach(layerValue => { - layers.push({properties: this.properties.parseValue(layerValue)}); + layers.push({ properties: this.properties.parseValue(layerValue) }); }); return layers; }, @@ -85,15 +83,14 @@ module.exports = Backbone.Collection.extend({ const propertyName = propModel.get('property'); if (layerProprs.indexOf(propertyName) < 0) { - layer.properties.push({ ...propModel.attributes }) + layer.properties.push({ ...propModel.attributes }); } - }) + }); }); return layers; }, - active(index) { this.each(layer => layer.set('active', 0)); const layer = this.at(index); @@ -114,5 +111,4 @@ module.exports = Backbone.Collection.extend({ }); return result.join(', '); } - }); diff --git a/src/style_manager/model/Properties.js b/src/style_manager/model/Properties.js index c2d4471ae..33253ad81 100644 --- a/src/style_manager/model/Properties.js +++ b/src/style_manager/model/Properties.js @@ -1,120 +1,132 @@ import TypeableCollection from 'domain_abstract/model/TypeableCollection'; const Property = require('./Property'); -module.exports = require('backbone').Collection.extend(TypeableCollection).extend({ - types: [ - { - id: 'stack', - model: require('./PropertyStack'), - view: require('./../view/PropertyStackView'), - isType(value) { - if (value && value.type == 'stack') { - return value; +module.exports = require('backbone') + .Collection.extend(TypeableCollection) + .extend({ + types: [ + { + id: 'stack', + model: require('./PropertyStack'), + view: require('./../view/PropertyStackView'), + isType(value) { + if (value && value.type == 'stack') { + return value; + } } - } - },{ - id: 'composite', - model: require('./PropertyComposite'), - view: require('./../view/PropertyCompositeView'), - isType(value) { - if (value && value.type == 'composite') { - return value; + }, + { + id: 'composite', + model: require('./PropertyComposite'), + view: require('./../view/PropertyCompositeView'), + isType(value) { + if (value && value.type == 'composite') { + return value; + } } - } - },{ - id: 'file', - model: Property, - view: require('./../view/PropertyFileView'), - isType(value) { - if (value && value.type == 'file') { - return value; + }, + { + id: 'file', + model: Property, + view: require('./../view/PropertyFileView'), + isType(value) { + if (value && value.type == 'file') { + return value; + } } - } - },{ - id: 'color', - model: Property, - view: require('./../view/PropertyColorView'), - isType(value) { - if (value && value.type == 'color') { - return value; + }, + { + id: 'color', + model: Property, + view: require('./../view/PropertyColorView'), + isType(value) { + if (value && value.type == 'color') { + return value; + } } - } - },{ - id: 'select', - model: require('./PropertyRadio'), - view: require('./../view/PropertySelectView'), - isType(value) { - if (value && value.type == 'select') { - return value; + }, + { + id: 'select', + model: require('./PropertyRadio'), + view: require('./../view/PropertySelectView'), + isType(value) { + if (value && value.type == 'select') { + return value; + } } - } - },{ - id: 'radio', - model: require('./PropertyRadio'), - view: require('./../view/PropertyRadioView'), - isType(value) { - if (value && value.type == 'radio') { - return value; + }, + { + id: 'radio', + model: require('./PropertyRadio'), + view: require('./../view/PropertyRadioView'), + isType(value) { + if (value && value.type == 'radio') { + return value; + } } - } - },{ - id: 'slider', - model: require('./PropertySlider'), - view: require('./../view/PropertySliderView'), - isType(value) { - if (value && value.type == 'slider') { - return value; + }, + { + id: 'slider', + model: require('./PropertySlider'), + view: require('./../view/PropertySliderView'), + isType(value) { + if (value && value.type == 'slider') { + return value; + } } - } - },{ - id: 'integer', - model: require('./PropertyInteger'), - view: require('./../view/PropertyIntegerView'), - isType(value) { - if (value && value.type == 'integer') { + }, + { + id: 'integer', + model: require('./PropertyInteger'), + view: require('./../view/PropertyIntegerView'), + isType(value) { + if (value && value.type == 'integer') { + return value; + } + } + }, + { + id: 'base', + model: Property, + view: require('./../view/PropertyView'), + isType(value) { + value.type = 'base'; return value; } } - },{ - id: 'base', - model: Property, - view: require('./../view/PropertyView'), - isType(value) { - value.type = 'base'; - return value; - } - } - ], + ], - deepClone() { - const collection = this.clone(); - collection.reset(collection.map(model => { - const cloned = model.clone(); - cloned.typeView = model.typeView; - return cloned; - })); - return collection; - }, + deepClone() { + const collection = this.clone(); + collection.reset( + collection.map(model => { + const cloned = model.clone(); + cloned.typeView = model.typeView; + return cloned; + }) + ); + return collection; + }, - /** - * Parse a value and return an array splitted by properties - * @param {string} value - * @return {Array} - * @return - */ - parseValue(value) { - const properties = []; - const values = value.split(' '); - values.forEach((value, i) => { - const property = this.at(i); - properties.push({ ...property.attributes, ...{ value } }); - }); - return properties; - }, + /** + * Parse a value and return an array splitted by properties + * @param {string} value + * @return {Array} + * @return + */ + parseValue(value) { + const properties = []; + const values = value.split(' '); + values.forEach((value, i) => { + const property = this.at(i); + properties.push({ ...property.attributes, ...{ value } }); + }); + return properties; + }, - getFullValue() { - let result = ''; - this.each(model => result += `${model.getFullValue()} `); - return result.trim(); - } -}); + getFullValue() { + let result = ''; + this.each(model => (result += `${model.getFullValue()} `)); + return result.trim(); + } + }); diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index c6f4d48f3..cf0d757cf 100644 --- a/src/style_manager/model/Property.js +++ b/src/style_manager/model/Property.js @@ -1,5 +1,4 @@ module.exports = require('backbone').Model.extend({ - defaults: { name: '', property: '', @@ -18,24 +17,25 @@ module.exports = require('backbone').Model.extend({ // Use case: // you can add all SVG CSS properties with toRequire as true // and then require them on SVG Components - toRequire: 0, + toRequire: 0 }, - initialize(opt) { var o = opt || {}; var name = this.get('name'); var prop = this.get('property'); if (!name) { - this.set('name', prop.charAt(0).toUpperCase() + prop.slice(1).replace(/-/g,' ')); + this.set( + 'name', + prop.charAt(0).toUpperCase() + prop.slice(1).replace(/-/g, ' ') + ); } const init = this.init && this.init.bind(this); init && init(); }, - /** * Update value * @param {any} value @@ -44,7 +44,7 @@ module.exports = require('backbone').Model.extend({ */ setValue(value, complete = 1, opts = {}) { const parsed = this.parseValue(value); - this.set(parsed, { ...opts, avoidStore: 1}); + this.set(parsed, { ...opts, avoidStore: 1 }); // It's important to set an empty value, otherwise the // UndoManager won't see the change @@ -54,7 +54,6 @@ module.exports = require('backbone').Model.extend({ } }, - /** * Like `setValue` but, in addition, prevents the update of the input element * as the changes should come from the input itself. @@ -64,10 +63,9 @@ module.exports = require('backbone').Model.extend({ * @param {Object} [opts={}] Options */ setValueFromInput(value, complete, opts = {}) { - this.setValue(value, complete, {...opts, fromInput: 1}); + this.setValue(value, complete, { ...opts, fromInput: 1 }); }, - /** * Parse a raw value, generally fetched from the target, for this property * @param {string} value Raw value string @@ -100,7 +98,6 @@ module.exports = require('backbone').Model.extend({ return result; }, - /** * Get the default value * @return {string} @@ -110,7 +107,6 @@ module.exports = require('backbone').Model.extend({ return this.get('defaults'); }, - /** * Get a complete value of the property. * This probably will replace the getValue when all @@ -128,6 +124,5 @@ module.exports = require('backbone').Model.extend({ } return value; - }, - + } }); diff --git a/src/style_manager/model/PropertyComposite.js b/src/style_manager/model/PropertyComposite.js index 069ecfb79..8234217c5 100644 --- a/src/style_manager/model/PropertyComposite.js +++ b/src/style_manager/model/PropertyComposite.js @@ -1,8 +1,8 @@ const Property = require('./Property'); module.exports = Property.extend({ - - defaults: { ...Property.prototype.defaults, + defaults: { + ...Property.prototype.defaults, // 'background' is a good example where to make a difference // between detached and not // @@ -18,18 +18,16 @@ module.exports = Property.extend({ properties: [], // Separator between properties - separator: ' ', + separator: ' ' }, - init() { const properties = this.get('properties') || []; const Properties = require('./Properties'); this.set('properties', new Properties(properties)); - this.listenTo(this, 'change:value', this.updateValues) + this.listenTo(this, 'change:value', this.updateValues); }, - /** * Update property values */ @@ -40,13 +38,13 @@ module.exports = Property.extend({ // Try to get value from a shorthand: // 11px -> 11px 11px 11px 11xp // 11px 22px -> 11px 22px 11px 22xp - const value = values[i] || values[(i % len) + (len != 1 && len % 2 ? 1 : 0)]; + const value = + values[i] || values[i % len + (len != 1 && len % 2 ? 1 : 0)]; // There some issue with UndoManager //property.setValue(value, 0, {fromParent: 1}); }); }, - /** * Returns default value * @param {Boolean} defaultProps Force to get defaults from properties @@ -61,17 +59,15 @@ module.exports = Property.extend({ value = ''; const properties = this.get('properties'); - properties.each((prop, index) => value += `${prop.getDefaultValue()} `); + properties.each((prop, index) => (value += `${prop.getDefaultValue()} `)); return value.trim(); }, - getFullValue() { if (this.get('detached')) { return ''; } return this.get('properties').getFullValue(); - }, - + } }); diff --git a/src/style_manager/model/PropertyFactory.js b/src/style_manager/model/PropertyFactory.js index 3851d9134..231b908e1 100644 --- a/src/style_manager/model/PropertyFactory.js +++ b/src/style_manager/model/PropertyFactory.js @@ -10,8 +10,7 @@ module.exports = () => ({ var objs = []; var dftFixedValues = ['initial', 'inherit']; - if(typeof props === 'string') - props = [props]; + if (typeof props === 'string') props = [props]; for (var i = 0, len = props.length; i < len; i++) { var obj = {}; @@ -19,73 +18,135 @@ module.exports = () => ({ obj.property = prop; // Property - switch(prop){ + switch (prop) { case 'border-radius-c': obj.property = 'border-radius'; break; } // Fixed values - switch(prop) { - case 'margin-top': case 'margin-right': case 'margin-bottom': case 'margin-left': - case 'padding-top': case 'padding-right': case 'padding-bottom': case 'padding-left': - case 'width': case 'max-width': case 'min-width': - case 'height': case 'max-height': case 'min-height': + switch (prop) { + case 'margin-top': + case 'margin-right': + case 'margin-bottom': + case 'margin-left': + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'width': + case 'max-width': + case 'min-width': + case 'height': + case 'max-height': + case 'min-height': obj.fixedValues = ['initial', 'inherit', 'auto']; break; case 'font-size': - obj.fixedValues = ['medium', 'xx-small', 'x-small', 'small', 'large', - 'x-large', 'xx-large', 'smaller', 'larger', 'length', 'initial', 'inherit']; + obj.fixedValues = [ + 'medium', + 'xx-small', + 'x-small', + 'small', + 'large', + 'x-large', + 'xx-large', + 'smaller', + 'larger', + 'length', + 'initial', + 'inherit' + ]; break; - case 'letter-spacing': case 'line-height': + case 'letter-spacing': + case 'line-height': obj.fixedValues = ['normal', 'initial', 'inherit']; break; } // Type - switch(prop){ - case 'float': case 'position': + switch (prop) { + case 'float': + case 'position': case 'text-align': obj.type = 'radio'; break; - case 'display': case 'font-family': + case 'display': + case 'font-family': case 'font-weight': case 'border-style': case 'box-shadow-type': - case 'background-repeat': case 'background-position': case 'background-attachment': case 'background-size': - case 'transition-property': case 'transition-timing-function': + case 'background-repeat': + case 'background-position': + case 'background-attachment': + case 'background-size': + case 'transition-property': + case 'transition-timing-function': case 'cursor': case 'overflow': obj.type = 'select'; break; - case 'top': case 'right': case 'bottom': case 'left': - case 'margin-top': case 'margin-right': case 'margin-bottom': case 'margin-left': - case 'padding-top': case 'padding-right': case 'padding-bottom': case 'padding-left': - case 'min-height': case 'min-width': case 'max-height': case 'max-width': - case 'width': case 'height': - case 'font-size': case 'letter-spacing': case 'line-height': - case 'text-shadow-h': case 'text-shadow-v': case 'text-shadow-blur': + case 'top': + case 'right': + case 'bottom': + case 'left': + case 'margin-top': + case 'margin-right': + case 'margin-bottom': + case 'margin-left': + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'min-height': + case 'min-width': + case 'max-height': + case 'max-width': + case 'width': + case 'height': + case 'font-size': + case 'letter-spacing': + case 'line-height': + case 'text-shadow-h': + case 'text-shadow-v': + case 'text-shadow-blur': case 'border-radius-c': - case 'border-top-left-radius': case 'border-top-right-radius': case 'border-bottom-left-radius':case 'border-bottom-right-radius': + case 'border-top-left-radius': + case 'border-top-right-radius': + case 'border-bottom-left-radius': + case 'border-bottom-right-radius': case 'border-width': - case 'box-shadow-h': case 'box-shadow-v': case 'box-shadow-blur': case 'box-shadow-spread': + case 'box-shadow-h': + case 'box-shadow-v': + case 'box-shadow-blur': + case 'box-shadow-spread': case 'transition-duration': case 'perspective': - case 'transform-rotate-x': case 'transform-rotate-y': case 'transform-rotate-z': - case 'transform-scale-x': case 'transform-scale-y': case 'transform-scale-z': + case 'transform-rotate-x': + case 'transform-rotate-y': + case 'transform-rotate-z': + case 'transform-scale-x': + case 'transform-scale-y': + case 'transform-scale-z': obj.type = 'integer'; break; - case 'margin': case 'padding': + case 'margin': + case 'padding': case 'border-radius': case 'border': case 'transform': obj.type = 'composite'; break; - case 'color': case 'text-shadow-color': - case 'background-color': case 'border-color': case 'box-shadow-color': + case 'color': + case 'text-shadow-color': + case 'background-color': + case 'border-color': + case 'box-shadow-color': obj.type = 'color'; break; - case 'text-shadow': case 'box-shadow': case 'background': + case 'text-shadow': + case 'box-shadow': + case 'background': case 'transition': obj.type = 'stack'; break; @@ -95,9 +156,11 @@ module.exports = () => ({ } // Defaults - switch(prop) { - case 'float': case 'background-color': - case 'background-image': case 'text-shadow': + switch (prop) { + case 'float': + case 'background-color': + case 'background-image': + case 'text-shadow': obj.defaults = 'none'; break; case 'display': @@ -106,25 +169,49 @@ module.exports = () => ({ case 'position': obj.defaults = 'static'; break; - case 'top': case 'right': case 'bottom': case 'left': - case 'margin-top': case 'margin-right': case 'margin-bottom': case 'margin-left': - case 'padding-top': case 'padding-right': case 'padding-bottom': case 'padding-left': - case 'text-shadow-h': case 'text-shadow-v': case 'text-shadow-blur': + case 'top': + case 'right': + case 'bottom': + case 'left': + case 'margin-top': + case 'margin-right': + case 'margin-bottom': + case 'margin-left': + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'text-shadow-h': + case 'text-shadow-v': + case 'text-shadow-blur': case 'border-radius-c': - case 'border-top-left-radius': case 'border-top-right-radius': case 'border-bottom-left-radius':case 'border-bottom-right-radius': - case 'box-shadow-h': case 'box-shadow-v': case 'box-shadow-spread': + case 'border-top-left-radius': + case 'border-top-right-radius': + case 'border-bottom-left-radius': + case 'border-bottom-right-radius': + case 'box-shadow-h': + case 'box-shadow-v': + case 'box-shadow-spread': case 'perspective': - case 'transform-rotate-x': case 'transform-rotate-y': case 'transform-rotate-z': + case 'transform-rotate-x': + case 'transform-rotate-y': + case 'transform-rotate-z': obj.defaults = 0; break; - case 'transform-scale-x': case 'transform-scale-y': case 'transform-scale-z': + case 'transform-scale-x': + case 'transform-scale-y': + case 'transform-scale-z': obj.defaults = 1; break; case 'box-shadow-blur': obj.defaults = '5px'; break; - case 'min-height': case 'min-width': case 'max-height': case 'max-width': - case 'width': case 'height': + case 'min-height': + case 'min-width': + case 'max-height': + case 'max-width': + case 'width': + case 'height': case 'background-size': case 'cursor': obj.defaults = 'auto'; @@ -132,17 +219,21 @@ module.exports = () => ({ case 'font-family': obj.defaults = 'Arial, Helvetica, sans-serif'; break; - case 'font-size': case 'border-width': + case 'font-size': + case 'border-width': obj.defaults = 'medium'; break; case 'font-weight': obj.defaults = '400'; break; - case 'letter-spacing': case 'line-height': + case 'letter-spacing': + case 'line-height': obj.defaults = 'normal'; break; - case 'color': case 'text-shadow-color': - case 'border-color': case 'box-shadow-color': + case 'color': + case 'text-shadow-color': + case 'border-color': + case 'box-shadow-color': obj.defaults = 'black'; break; case 'text-align': @@ -178,45 +269,79 @@ module.exports = () => ({ } // Units - switch(prop){ - case 'top': case 'right': case 'bottom': case 'left': - case 'margin-top': case 'margin-right': case 'margin-bottom': case 'margin-left': - case 'padding-top': case 'padding-right': case 'padding-bottom': case 'padding-left': - case 'min-height': case 'min-width': case 'max-height': case 'max-width': - case 'width': case 'height': - case 'text-shadow-h': case 'text-shadow-v': case 'text-shadow-blur': + switch (prop) { + case 'top': + case 'right': + case 'bottom': + case 'left': + case 'margin-top': + case 'margin-right': + case 'margin-bottom': + case 'margin-left': + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'min-height': + case 'min-width': + case 'max-height': + case 'max-width': + case 'width': + case 'height': + case 'text-shadow-h': + case 'text-shadow-v': + case 'text-shadow-blur': case 'border-radius-c': - case 'border-top-left-radius': case 'border-top-right-radius': case 'border-bottom-left-radius':case 'border-bottom-right-radius': - case 'box-shadow-h': case 'box-shadow-v': - obj.units = ['px','%']; + case 'border-top-left-radius': + case 'border-top-right-radius': + case 'border-bottom-left-radius': + case 'border-bottom-right-radius': + case 'box-shadow-h': + case 'box-shadow-v': + obj.units = ['px', '%']; break; - case 'font-size': case 'letter-spacing': case 'line-height': - obj.units = ['px','em', 'rem', '%']; + case 'font-size': + case 'letter-spacing': + case 'line-height': + obj.units = ['px', 'em', 'rem', '%']; break; case 'border-width': - obj.units = ['px','em']; + obj.units = ['px', 'em']; break; - case 'box-shadow-blur': case 'box-shadow-spread': + case 'box-shadow-blur': + case 'box-shadow-spread': case 'perspective': obj.units = ['px']; break; case 'transition-duration': obj.units = ['s']; break; - case 'transform-rotate-x': case 'transform-rotate-y': case 'transform-rotate-z': + case 'transform-rotate-x': + case 'transform-rotate-y': + case 'transform-rotate-z': obj.units = ['deg']; break; } // Min/Max - switch(prop) { - case 'padding-top': case 'padding-right': case 'padding-bottom': case 'padding-left': - case 'min-height': case 'min-width': case 'max-height': case 'max-width': - case 'width': case 'height': + switch (prop) { + case 'padding-top': + case 'padding-right': + case 'padding-bottom': + case 'padding-left': + case 'min-height': + case 'min-width': + case 'max-height': + case 'max-width': + case 'width': + case 'height': case 'font-size': case 'text-shadow-blur': case 'border-radius-c': - case 'border-top-left-radius': case 'border-top-right-radius': case 'border-bottom-left-radius':case 'border-bottom-right-radius': + case 'border-top-left-radius': + case 'border-top-right-radius': + case 'border-bottom-left-radius': + case 'border-bottom-right-radius': case 'border-width': case 'box-shadow-blur': case 'transition-duration': @@ -226,21 +351,23 @@ module.exports = () => ({ } // Preview - switch(prop){ - case 'text-shadow': case 'box-shadow': case 'background': + switch (prop) { + case 'text-shadow': + case 'box-shadow': + case 'background': obj.preview = true; break; } // Detached - switch(prop){ + switch (prop) { case 'background': obj.detached = true; break; } // Functions - switch(prop){ + switch (prop) { case 'transform-rotate-x': obj.functionName = 'rotateX'; break; @@ -265,28 +392,24 @@ module.exports = () => ({ } // Options - switch(prop){ + switch (prop) { case 'float': - obj.list = [ - {value: 'none'}, - {value: 'left'}, - {value: 'right'}, - ]; + obj.list = [{ value: 'none' }, { value: 'left' }, { value: 'right' }]; break; case 'display': obj.list = [ - {value: 'block'}, - {value: 'inline'}, - {value: 'inline-block'}, - {value: 'none'}, - ]; + { value: 'block' }, + { value: 'inline' }, + { value: 'inline-block' }, + { value: 'none' } + ]; break; case 'position': obj.list = [ - {value: 'static'}, - {value: 'relative'}, - {value: 'absolute'}, - {value: 'fixed'}, + { value: 'static' }, + { value: 'relative' }, + { value: 'absolute' }, + { value: 'fixed' } ]; break; case 'font-family': @@ -307,7 +430,7 @@ module.exports = () => ({ 'Verdana, Geneva' + ss ]; obj.list = []; - for(var j = 0, l = fonts.length; j < l; j++){ + for (var j = 0, l = fonts.length; j < l; j++) { var font = {}; font.value = fonts[j]; font.name = fonts[j].split(',')[0]; @@ -316,154 +439,198 @@ module.exports = () => ({ break; case 'font-weight': obj.list = [ - { value : '100', name : 'Thin', }, - { value : '200', name : 'Extra-Light', }, - { value : '300', name : 'Light', }, - { value : '400', name : 'Normal', }, - { value : '500', name : 'Medium',}, - { value : '600', name : 'Semi-Bold',}, - { value : '700', name : 'Bold', }, - { value : '800', name : 'Extra-Bold',}, - { value : '900', name : 'Ultra-Bold', } + { value: '100', name: 'Thin' }, + { value: '200', name: 'Extra-Light' }, + { value: '300', name: 'Light' }, + { value: '400', name: 'Normal' }, + { value: '500', name: 'Medium' }, + { value: '600', name: 'Semi-Bold' }, + { value: '700', name: 'Bold' }, + { value: '800', name: 'Extra-Bold' }, + { value: '900', name: 'Ultra-Bold' } ]; break; case 'text-align': obj.list = [ - { value : 'left'}, - { value : 'center'}, - { value : 'right'}, - { value : 'justify'} - ]; + { value: 'left' }, + { value: 'center' }, + { value: 'right' }, + { value: 'justify' } + ]; break; case 'border-style': obj.list = [ - { value : 'none'}, - { value : 'solid'}, - { value : 'dotted'}, - { value : 'dashed'}, - { value : 'double'}, - { value : 'groove'}, - { value : 'ridge'}, - { value : 'inset'}, - { value : 'outset'} - ]; + { value: 'none' }, + { value: 'solid' }, + { value: 'dotted' }, + { value: 'dashed' }, + { value: 'double' }, + { value: 'groove' }, + { value: 'ridge' }, + { value: 'inset' }, + { value: 'outset' } + ]; break; case 'box-shadow-type': obj.list = [ - {value : '', name: 'Outside'}, - {value : 'inset', name: 'Inside'} - ]; + { value: '', name: 'Outside' }, + { value: 'inset', name: 'Inside' } + ]; break; case 'background-repeat': obj.list = [ - { value : 'repeat'}, - { value : 'repeat-x'}, - { value : 'repeat-y'}, - { value : 'no-repeat'} - ]; + { value: 'repeat' }, + { value: 'repeat-x' }, + { value: 'repeat-y' }, + { value: 'no-repeat' } + ]; break; case 'background-position': obj.list = [ - { value : 'left top',}, - { value : 'left center',}, - { value : 'left bottom',}, - { value : 'right top',}, - { value : 'right center'}, - { value : 'right bottom'}, - { value : 'center top'}, - { value : 'center center'}, - { value : 'center bottom'} - ]; + { value: 'left top' }, + { value: 'left center' }, + { value: 'left bottom' }, + { value: 'right top' }, + { value: 'right center' }, + { value: 'right bottom' }, + { value: 'center top' }, + { value: 'center center' }, + { value: 'center bottom' } + ]; break; case 'background-attachment': obj.list = [ - { value : 'scroll'}, - { value : 'fixed'}, - { value : 'local'} - ]; + { value: 'scroll' }, + { value: 'fixed' }, + { value: 'local' } + ]; break; case 'background-size': obj.list = [ - { value : 'auto'}, - { value : 'cover'}, - { value : 'contain'} - ]; + { value: 'auto' }, + { value: 'cover' }, + { value: 'contain' } + ]; break; case 'transition-property': obj.list = [ - { value: 'all'}, - { value: 'width'}, - { value : 'height'}, - { value : 'background-color'}, - { value : 'transform'}, - { value : 'box-shadow'}, - { value : 'opacity'} - ]; + { value: 'all' }, + { value: 'width' }, + { value: 'height' }, + { value: 'background-color' }, + { value: 'transform' }, + { value: 'box-shadow' }, + { value: 'opacity' } + ]; break; case 'transition-timing-function': obj.list = [ - { value : 'linear'}, - { value : 'ease'}, - { value : 'ease-in'}, - { value : 'ease-out'}, - { value : 'ease-in-out'} - ]; + { value: 'linear' }, + { value: 'ease' }, + { value: 'ease-in' }, + { value: 'ease-out' }, + { value: 'ease-in-out' } + ]; break; case 'cursor': obj.list = [ - { value : 'auto'}, - { value : 'pointer'}, - { value : 'copy'}, - { value : 'crosshair'}, - { value : 'grab'}, - { value : 'grabbing'}, - { value : 'help'}, - { value : 'move'}, - { value : 'text'} - ]; + { value: 'auto' }, + { value: 'pointer' }, + { value: 'copy' }, + { value: 'crosshair' }, + { value: 'grab' }, + { value: 'grabbing' }, + { value: 'help' }, + { value: 'move' }, + { value: 'text' } + ]; break; case 'overflow': obj.list = [ - { value : 'visible'}, - { value : 'hidden'}, - { value : 'scroll'}, - { value : 'auto'} + { value: 'visible' }, + { value: 'hidden' }, + { value: 'scroll' }, + { value: 'auto' } ]; break; } // Properties - switch(prop){ + switch (prop) { case 'margin': - obj.properties = this.build(['margin-top', 'margin-right', 'margin-bottom', 'margin-left']); + obj.properties = this.build([ + 'margin-top', + 'margin-right', + 'margin-bottom', + 'margin-left' + ]); break; case 'padding': - obj.properties = this.build(['padding-top', 'padding-right', 'padding-bottom', 'padding-left']); + obj.properties = this.build([ + 'padding-top', + 'padding-right', + 'padding-bottom', + 'padding-left' + ]); break; case 'text-shadow': - obj.properties = this.build(['text-shadow-h', 'text-shadow-v', 'text-shadow-blur', 'text-shadow-color']); + obj.properties = this.build([ + 'text-shadow-h', + 'text-shadow-v', + 'text-shadow-blur', + 'text-shadow-color' + ]); break; case 'border': - obj.properties = this.build(['border-width', 'border-style', 'border-color']); + obj.properties = this.build([ + 'border-width', + 'border-style', + 'border-color' + ]); break; case 'border-radius': - obj.properties = this.build(['border-top-left-radius', 'border-top-right-radius', - 'border-bottom-left-radius', 'border-bottom-right-radius']); + obj.properties = this.build([ + 'border-top-left-radius', + 'border-top-right-radius', + 'border-bottom-left-radius', + 'border-bottom-right-radius' + ]); break; case 'box-shadow': - obj.properties = this.build(['box-shadow-h', 'box-shadow-v', 'box-shadow-blur','box-shadow-spread', - 'box-shadow-color', 'box-shadow-type']); + obj.properties = this.build([ + 'box-shadow-h', + 'box-shadow-v', + 'box-shadow-blur', + 'box-shadow-spread', + 'box-shadow-color', + 'box-shadow-type' + ]); break; case 'background': - obj.properties = this.build(['background-image', 'background-repeat', 'background-position','background-attachment', - 'background-size']); + obj.properties = this.build([ + 'background-image', + 'background-repeat', + 'background-position', + 'background-attachment', + 'background-size' + ]); break; case 'transition': - obj.properties = this.build(['transition-property', 'transition-duration', 'transition-timing-function']); + obj.properties = this.build([ + 'transition-property', + 'transition-duration', + 'transition-timing-function' + ]); break; case 'transform': - obj.properties = this.build(['transform-rotate-x', 'transform-rotate-y', 'transform-rotate-z', - 'transform-scale-x', 'transform-scale-y', 'transform-scale-z']); + obj.properties = this.build([ + 'transform-rotate-x', + 'transform-rotate-y', + 'transform-rotate-z', + 'transform-scale-x', + 'transform-scale-y', + 'transform-scale-z' + ]); break; } diff --git a/src/style_manager/model/PropertyInteger.js b/src/style_manager/model/PropertyInteger.js index 27dc4ddb1..5aea5c69b 100644 --- a/src/style_manager/model/PropertyInteger.js +++ b/src/style_manager/model/PropertyInteger.js @@ -2,8 +2,8 @@ const Property = require('./Property'); const InputNumber = require('domain_abstract/ui/InputNumber'); module.exports = Property.extend({ - - defaults: { ...Property.prototype.defaults, + defaults: { + ...Property.prototype.defaults, // Array of units, eg. ['px', '%'] units: [], @@ -17,10 +17,9 @@ module.exports = Property.extend({ min: '', // Maximum value - max: '', + max: '' }, - init() { const unit = this.get('unit'); const units = this.get('units'); @@ -31,19 +30,18 @@ module.exports = Property.extend({ } }, - parseValue(val) { const parsed = Property.prototype.parseValue.apply(this, arguments); - const { value, unit } = this.input.validateInputValue(parsed.value, {deepCheck: 1}); + const { value, unit } = this.input.validateInputValue(parsed.value, { + deepCheck: 1 + }); parsed.value = value; parsed.unit = unit; return parsed; }, - getFullValue() { let value = this.get('value') + this.get('unit'); return Property.prototype.getFullValue.apply(this, [value]); - }, - + } }); diff --git a/src/style_manager/model/PropertyRadio.js b/src/style_manager/model/PropertyRadio.js index 7c4631553..959711154 100644 --- a/src/style_manager/model/PropertyRadio.js +++ b/src/style_manager/model/PropertyRadio.js @@ -1,10 +1,9 @@ const Property = require('./Property'); module.exports = Property.extend({ - - defaults: { ...Property.prototype.defaults, + defaults: { + ...Property.prototype.defaults, // Array of options, eg. [{name: 'Label ', value: '100'}] - options: [], - }, - + options: [] + } }); diff --git a/src/style_manager/model/PropertySlider.js b/src/style_manager/model/PropertySlider.js index 51285c13a..403141b6c 100644 --- a/src/style_manager/model/PropertySlider.js +++ b/src/style_manager/model/PropertySlider.js @@ -1,9 +1,8 @@ const Property = require('./PropertyInteger'); module.exports = Property.extend({ - - defaults: { ...Property.prototype.defaults, - showInput: 1, - }, - + defaults: { + ...Property.prototype.defaults, + showInput: 1 + } }); diff --git a/src/style_manager/model/PropertyStack.js b/src/style_manager/model/PropertyStack.js index 86a4c7df8..b0ec21479 100644 --- a/src/style_manager/model/PropertyStack.js +++ b/src/style_manager/model/PropertyStack.js @@ -2,13 +2,13 @@ const Property = require('./PropertyComposite'); const Layers = require('./Layers'); module.exports = Property.extend({ - - defaults: { ...Property.prototype.defaults, + defaults: { + ...Property.prototype.defaults, // Array of layers (which contain properties) layers: [], // Layer preview - preview: 0, + preview: 0 }, init() { @@ -21,6 +21,5 @@ module.exports = Property.extend({ getFullValue() { return this.get('detached') ? '' : this.get('layers').getFullValue(); - }, - + } }); diff --git a/src/style_manager/model/Sector.js b/src/style_manager/model/Sector.js index 19b6d1950..b61487b13 100644 --- a/src/style_manager/model/Sector.js +++ b/src/style_manager/model/Sector.js @@ -5,14 +5,13 @@ const Properties = require('./Properties'); const PropertyFactory = require('./PropertyFactory'); module.exports = Backbone.Model.extend({ - defaults: { id: '', name: '', open: true, buildProps: '', extendBuilded: 1, - properties : [], + properties: [] }, initialize(opts) { @@ -21,10 +20,8 @@ module.exports = Backbone.Model.extend({ var builded = this.buildProperties(o.buildProps); !this.get('id') && this.set('id', this.get('name')); - if(!builded) - props = this.get('properties'); - else - props = this.extendProperties(builded); + if (!builded) props = this.get('properties'); + else props = this.extendProperties(builded); var propsModel = new Properties(props); propsModel.sector = this; @@ -51,12 +48,15 @@ module.exports = Backbone.Model.extend({ for (var j = 0; j < pLen; j++) { var prop = props[j]; - if (mProp.property == prop.property || - mProp.id == prop.property) { + if (mProp.property == prop.property || mProp.id == prop.property) { // Check for nested properties var mPProps = mProp.properties; if (mPProps && mPProps.length) { - mProp.properties = this.extendProperties(prop.properties, mPProps, 1); + mProp.properties = this.extendProperties( + prop.properties, + mPProps, + 1 + ); } props[j] = ext ? extend(prop, mProp) : mProp; isolated[j] = props[j]; @@ -65,7 +65,7 @@ module.exports = Backbone.Model.extend({ } } - if(!found){ + if (!found) { props.push(mProp); isolated.push(mProp); } @@ -84,15 +84,12 @@ module.exports = Backbone.Model.extend({ var r; var buildP = props || []; - if(!buildP.length) - return; + if (!buildP.length) return; - if(!this.propFactory) - this.propFactory = new PropertyFactory(); + if (!this.propFactory) this.propFactory = new PropertyFactory(); r = this.propFactory.build(buildP); return r; - }, - + } }); diff --git a/src/style_manager/model/Sectors.js b/src/style_manager/model/Sectors.js index f52fdc3cb..65439242b 100644 --- a/src/style_manager/model/Sectors.js +++ b/src/style_manager/model/Sectors.js @@ -1,5 +1,5 @@ const Sector = require('./Sector'); module.exports = require('backbone').Collection.extend({ - model: Sector + model: Sector }); diff --git a/src/style_manager/view/LayerView.js b/src/style_manager/view/LayerView.js index 8c780bf79..50810ca5f 100644 --- a/src/style_manager/view/LayerView.js +++ b/src/style_manager/view/LayerView.js @@ -1,5 +1,4 @@ module.exports = Backbone.View.extend({ - events: { click: 'active', 'click [data-close-layer]': 'remove', @@ -23,7 +22,7 @@ module.exports = Backbone.View.extend({
- ` + `; }, initialize(o = {}) { @@ -44,7 +43,7 @@ module.exports = Backbone.View.extend({ // For the sorter model.view = this; - model.set({droppable: 0, draggable: 1}); + model.set({ droppable: 0, draggable: 1 }); this.$el.data('model', model); }, @@ -53,14 +52,11 @@ module.exports = Backbone.View.extend({ * @param {Event} e * */ initSorter(e) { - if(this.sorter) - this.sorter.startSort(this.el); + if (this.sorter) this.sorter.startSort(this.el); }, - remove(e) { - if(e && e.stopPropagation) - e.stopPropagation(); + if (e && e.stopPropagation) e.stopPropagation(); const model = this.model; const collection = model.collection; @@ -73,7 +69,7 @@ module.exports = Backbone.View.extend({ } if (stackModel && stackModel.set) { - stackModel.set({stackIndex: null}, {silent: true}); + stackModel.set({ stackIndex: null }, { silent: true }); stackModel.trigger('updateValue'); } }, @@ -93,7 +89,7 @@ module.exports = Backbone.View.extend({ if (value) { if (prop.get('type') == 'integer') { let valueInt = parseInt(value, 10); - let unit = value.replace(valueInt,''); + let unit = value.replace(valueInt, ''); valueInt = !isNaN(valueInt) ? valueInt : 0; valueInt = valueInt > lim ? lim : valueInt; valueInt = valueInt < -lim ? -lim : valueInt; @@ -112,7 +108,9 @@ module.exports = Backbone.View.extend({ const customPreview = this.customPreview; const previewEl = this.getPreviewEl(); const value = this.model.getFullValue(); - const preview = customPreview ? customPreview(value) : this.onPreview(value); + const preview = customPreview + ? customPreview(value) + : this.onPreview(value); if (preview && stackModel && previewEl) { previewEl.style[stackModel.get('property')] = preview; @@ -159,7 +157,7 @@ module.exports = Backbone.View.extend({ target: propsConfig.target, customValue: propsConfig.customValue, propTarget: propsConfig.propTarget, - onChange: propsConfig.onChange, + onChange: propsConfig.onChange }).render().el; el.innerHTML = this.template(model); el.className = className; @@ -167,6 +165,5 @@ module.exports = Backbone.View.extend({ this.updateVisibility(); this.updatePreview(); return this; - }, - + } }); diff --git a/src/style_manager/view/LayersView.js b/src/style_manager/view/LayersView.js index 8289645a5..94fd1727f 100644 --- a/src/style_manager/view/LayersView.js +++ b/src/style_manager/view/LayersView.js @@ -2,10 +2,9 @@ var Backbone = require('backbone'); var LayerView = require('./LayerView'); module.exports = Backbone.View.extend({ - initialize(o) { this.config = o.config || {}; - this.stackModel = o.stackModel; + this.stackModel = o.stackModel; this.preview = o.preview; this.pfx = this.config.stylePrefix || ''; this.ppfx = this.config.pStylePrefix || ''; @@ -15,19 +14,21 @@ module.exports = Backbone.View.extend({ let collection = this.collection; this.className = `${pfx}layers ${ppfx}field`; this.listenTo(collection, 'add', this.addTo); - this.listenTo(collection, 'deselectAll', this.deselectAll ); + this.listenTo(collection, 'deselectAll', this.deselectAll); this.listenTo(collection, 'reset', this.render); var em = this.config.em || ''; var utils = em ? em.get('Utils') : ''; - this.sorter = utils ? new utils.Sorter({ - container: this.el, - ignoreViewChildren: 1, - containerSel: `.${pfx}layers`, - itemSel: `.${pfx}layer`, - pfx: this.config.pStylePrefix, - }) : ''; + this.sorter = utils + ? new utils.Sorter({ + container: this.el, + ignoreViewChildren: 1, + containerSel: `.${pfx}layers`, + itemSel: `.${pfx}layer`, + pfx: this.config.pStylePrefix + }) + : ''; // For the Sorter collection.view = this; @@ -42,7 +43,7 @@ module.exports = Backbone.View.extend({ * @return Object * */ addTo(model) { - var i = this.collection.indexOf(model); + var i = this.collection.indexOf(model); this.addToCollection(model, null, i); }, @@ -61,37 +62,39 @@ module.exports = Backbone.View.extend({ const sorter = this.sorter; const propsConfig = this.propsConfig; - if(typeof this.preview !== 'undefined'){ + if (typeof this.preview !== 'undefined') { model.set('preview', this.preview); } var view = new LayerView({ - model, - config, - sorter, - stackModel, - propsConfig + model, + config, + sorter, + stackModel, + propsConfig }); var rendered = view.render().el; if (fragment) { fragment.appendChild(rendered); } else { - if(typeof index != 'undefined'){ - var method = 'before'; + if (typeof index != 'undefined') { + var method = 'before'; // If the added model is the last of collection // need to change the logic of append - if(this.$el.children().length == index){ + if (this.$el.children().length == index) { index--; method = 'after'; } // In case the added is new in the collection index will be -1 - if(index < 0){ + if (index < 0) { this.$el.append(rendered); - }else - this.$el.children().eq(index)[method](rendered); - }else - this.$el.append(rendered); + } else + this.$el + .children() + .eq(index) + [method](rendered); + } else this.$el.append(rendered); } return rendered; @@ -103,22 +106,21 @@ module.exports = Backbone.View.extend({ * @return void * */ deselectAll() { - this.$el.find('.'+ this.pfx +'layer').removeClass(this.pfx + 'active'); + this.$el.find('.' + this.pfx + 'layer').removeClass(this.pfx + 'active'); }, render() { var fragment = document.createDocumentFragment(); this.$el.empty(); - this.collection.each(function(model){ + this.collection.each(function(model) { this.addToCollection(model, fragment); - },this); + }, this); this.$el.append(fragment); this.$el.attr('class', this.className); - if(this.sorter) - this.sorter.plh = null; + if (this.sorter) this.sorter.plh = null; return this; } diff --git a/src/style_manager/view/PropertiesView.js b/src/style_manager/view/PropertiesView.js index 1cbbd1417..07e2fb2dd 100644 --- a/src/style_manager/view/PropertiesView.js +++ b/src/style_manager/view/PropertiesView.js @@ -8,7 +8,6 @@ const PropertyCompositeView = require('./PropertyCompositeView'); const PropertyStackView = require('./PropertyStackView'); module.exports = Backbone.View.extend({ - initialize(o) { this.config = o.config || {}; this.pfx = this.config.stylePrefix || ''; @@ -22,12 +21,10 @@ module.exports = Backbone.View.extend({ this.listenTo(coll, 'reset', this.render); }, - addTo(model) { this.add(model); }, - add(model, frag) { var view = new model.typeView({ model, @@ -37,7 +34,7 @@ module.exports = Backbone.View.extend({ propTarget: this.propTarget, onChange: this.onChange, onInputRender: this.onInputRender, - config: this.config, + config: this.config }); if (model.get('type') != 'composite') { @@ -54,7 +51,6 @@ module.exports = Backbone.View.extend({ } }, - render() { const fragment = document.createDocumentFragment(); this.collection.each(model => this.add(model, fragment)); diff --git a/src/style_manager/view/PropertyColorView.js b/src/style_manager/view/PropertyColorView.js index 6e8a870a5..48c8518e0 100644 --- a/src/style_manager/view/PropertyColorView.js +++ b/src/style_manager/view/PropertyColorView.js @@ -1,7 +1,6 @@ const InputColor = require('domain_abstract/ui/InputColor'); module.exports = require('./PropertyIntegerView').extend({ - setValue(value, opts = {}) { opts = { ...opts, silent: 1 }; this.inputInst.setValue(value, opts); @@ -22,6 +21,5 @@ module.exports = require('./PropertyIntegerView').extend({ this.input = this.$input.get(0); this.inputInst = input; } - }, - + } }); diff --git a/src/style_manager/view/PropertyCompositeView.js b/src/style_manager/view/PropertyCompositeView.js index 618a1e9df..7d8fa6e08 100644 --- a/src/style_manager/view/PropertyCompositeView.js +++ b/src/style_manager/view/PropertyCompositeView.js @@ -2,7 +2,6 @@ const PropertyView = require('./PropertyView'); const $ = Backbone.$; module.exports = PropertyView.extend({ - templateInput() { const pfx = this.pfx; return ` @@ -41,7 +40,7 @@ module.exports = PropertyView.extend({ if (!this.$props) { //Not yet supported nested composite this.props.each(function(prop, index) { - if(prop && prop.get('type') == 'composite') { + if (prop && prop.get('type') == 'composite') { this.props.remove(prop); console.warn('Nested composite types not yet allowed.'); } @@ -78,7 +77,7 @@ module.exports = PropertyView.extend({ // I need to extract from that string the corresponding one to that property. customValue(property, mIndex) { return that.valueOnIndex(mIndex, property); - }, + } }; // If detached let follow its standard flow @@ -97,7 +96,7 @@ module.exports = PropertyView.extend({ * */ valueOnIndex(index, view) { let value; - const targetValue = this.getTargetValue({ignoreDefault: 1}); + const targetValue = this.getTargetValue({ ignoreDefault: 1 }); // If the target value of the composite is not empty I'll fetch // the corresponding value from the requested index, otherwise try @@ -106,7 +105,8 @@ module.exports = PropertyView.extend({ const values = targetValue.split(' '); value = values[index]; } else { - value = view && view.getTargetValue({ignoreCustomValue: 1, ignoreDefault: 1}); + value = + view && view.getTargetValue({ ignoreCustomValue: 1, ignoreDefault: 1 }); } if (view) { @@ -114,6 +114,5 @@ module.exports = PropertyView.extend({ } return value; - }, - + } }); diff --git a/src/style_manager/view/PropertyFileView.js b/src/style_manager/view/PropertyFileView.js index 4d5a9c87f..8114adb85 100644 --- a/src/style_manager/view/PropertyFileView.js +++ b/src/style_manager/view/PropertyFileView.js @@ -2,7 +2,6 @@ const PropertyView = require('./PropertyView'); const $ = Backbone.$; module.exports = PropertyView.extend({ - templateInput() { const pfx = this.pfx; const ppfx = this.ppfx; @@ -29,8 +28,8 @@ module.exports = PropertyView.extend({ const em = this.em; this.modal = em.get('Modal'); this.am = em.get('AssetManager'); - this.events['click #'+this.pfx+'close'] = 'removeFile'; - this.events['click #'+this.pfx+'images'] = 'openAssetManager'; + this.events['click #' + this.pfx + 'close'] = 'removeFile'; + this.events['click #' + this.pfx + 'images'] = 'openAssetManager'; this.delegateEvents(); }, @@ -92,7 +91,7 @@ module.exports = PropertyView.extend({ /** @inheritdoc */ cleanValue() { this.setPreviewView(0); - this.model.set({value: ''},{silent: true}); + this.model.set({ value: '' }, { silent: true }); }, /** @@ -113,11 +112,11 @@ module.exports = PropertyView.extend({ * @return void * */ openAssetManager(e) { - var that = this; + var that = this; var em = this.em; var editor = em ? em.get('Editor') : ''; - if(editor) { + if (editor) { this.modal.setTitle('Select image'); this.modal.setContent(this.am.getContainer()); this.am.setTarget(null); @@ -129,5 +128,5 @@ module.exports = PropertyView.extend({ } }); } - }, + } }); diff --git a/src/style_manager/view/PropertyIntegerView.js b/src/style_manager/view/PropertyIntegerView.js index 4a8c30115..91609c458 100644 --- a/src/style_manager/view/PropertyIntegerView.js +++ b/src/style_manager/view/PropertyIntegerView.js @@ -2,7 +2,6 @@ const InputNumber = require('domain_abstract/ui/InputNumber'); const $ = Backbone.$; module.exports = require('./PropertyView').extend({ - templateInput() { return ''; }, @@ -14,7 +13,7 @@ module.exports = require('./PropertyView').extend({ }, setValue(value) { - this.inputInst.setValue(value, {silent: 1}); + this.inputInst.setValue(value, { silent: 1 }); }, onRender() { @@ -32,6 +31,5 @@ module.exports = require('./PropertyView').extend({ this.input = this.$input.get(0); this.inputInst = input; } - }, - + } }); diff --git a/src/style_manager/view/PropertyRadioView.js b/src/style_manager/view/PropertyRadioView.js index 4ed37e7c6..cf99fc789 100644 --- a/src/style_manager/view/PropertyRadioView.js +++ b/src/style_manager/view/PropertyRadioView.js @@ -1,5 +1,4 @@ module.exports = require('./PropertyView').extend({ - templateInput() { const pfx = this.pfx; const ppfx = this.ppfx; @@ -18,18 +17,22 @@ module.exports = require('./PropertyView').extend({ const options = model.get('list') || model.get('options') || []; if (!this.input) { - if(options && options.length) { + if (options && options.length) { let inputStr = ''; options.forEach(el => { - let cl = el.className ? `${el.className} ${pfx}icon ${itemCls}` : ''; + let cl = el.className ? `${el.className} ${pfx}icon ${itemCls}` : ''; let id = `${prop}-${el.value}`; let labelTxt = el.name || el.value; let titleAttr = el.title ? `title="${el.title}"` : ''; inputStr += `
- - + +
`; }); @@ -63,6 +66,5 @@ module.exports = require('./PropertyView').extend({ const inputChk = this.getCheckedEl(); inputChk && (inputChk.checked = false); } - }, - + } }); diff --git a/src/style_manager/view/PropertySelectView.js b/src/style_manager/view/PropertySelectView.js index 61ff92d96..f235e081b 100644 --- a/src/style_manager/view/PropertySelectView.js +++ b/src/style_manager/view/PropertySelectView.js @@ -1,7 +1,6 @@ const $ = Backbone.$; module.exports = require('./PropertyView').extend({ - templateInput() { const pfx = this.pfx; const ppfx = this.ppfx; @@ -16,7 +15,7 @@ module.exports = require('./PropertyView').extend({ }, onRender() { - var pfx = this.pfx; + var pfx = this.pfx; const model = this.model; const options = model.get('list') || model.get('options') || []; @@ -25,9 +24,9 @@ module.exports = require('./PropertyView').extend({ options.forEach(option => { let name = option.name || option.value; - let style = option.style ? option.style.replace(/"/g,'"') : ''; + let style = option.style ? option.style.replace(/"/g, '"') : ''; let styleAttr = style ? `style="${style}"` : ''; - let value = option.value.replace(/"/g,'"'); + let value = option.value.replace(/"/g, '"'); optionsStr += ``; }); @@ -35,6 +34,5 @@ module.exports = require('./PropertyView').extend({ inputH.innerHTML = ``; this.input = inputH.firstChild; } - }, - + } }); diff --git a/src/style_manager/view/PropertySliderView.js b/src/style_manager/view/PropertySliderView.js index 4de4bac50..f6e1b362d 100644 --- a/src/style_manager/view/PropertySliderView.js +++ b/src/style_manager/view/PropertySliderView.js @@ -1,13 +1,11 @@ const Property = require('./PropertyIntegerView'); module.exports = Property.extend({ - events: { 'change [type=range]': 'inputValueChanged', - 'input [type=range]': 'inputValueChangedSoft', + 'input [type=range]': 'inputValueChangedSoft' }, - templateInput(model) { const ppfx = this.ppfx; return ` @@ -20,7 +18,6 @@ module.exports = Property.extend({ `; }, - getSliderEl() { if (!this.slider) { this.slider = this.el.querySelector('input[type=range]'); @@ -29,30 +26,26 @@ module.exports = Property.extend({ return this.slider; }, - inputValueChanged() { const model = this.model; const step = model.get('step'); this.getInputEl().value = this.getSliderEl().value; const value = this.getInputValue() - step; - model.set('value', value, {avoidStore: 1}).set('value', value + step); + model.set('value', value, { avoidStore: 1 }).set('value', value + step); this.elementUpdated(); }, - inputValueChangedSoft() { this.getInputEl().value = this.getSliderEl().value; - this.model.set('value', this.getInputValue(), {avoidStore: 1}); + this.model.set('value', this.getInputValue(), { avoidStore: 1 }); this.elementUpdated(); }, - setValue(value) { this.getSliderEl().value = value; - this.inputInst.setValue(value, {silent: 1}); + this.inputInst.setValue(value, { silent: 1 }); }, - onRender() { Property.prototype.onRender.apply(this, arguments); diff --git a/src/style_manager/view/PropertyStackView.js b/src/style_manager/view/PropertyStackView.js index 5a20e0662..b97780f12 100644 --- a/src/style_manager/view/PropertyStackView.js +++ b/src/style_manager/view/PropertyStackView.js @@ -2,7 +2,6 @@ const PropertyCompositeView = require('./PropertyCompositeView'); const LayersView = require('./LayersView'); module.exports = PropertyCompositeView.extend({ - templateInput() { const pfx = this.pfx; const ppfx = this.ppfx; @@ -65,7 +64,7 @@ module.exports = PropertyCompositeView.extend({ const layers = this.getLayers(); const properties = model.get('properties').deepClone(); properties.each(property => property.set('value', '')); - const layer = layers.add({properties}); + const layer = layers.add({ properties }); // In detached mode inputValueChanged will add new 'layer value' // to all subprops @@ -75,7 +74,6 @@ module.exports = PropertyCompositeView.extend({ model.set('stackIndex', layers.indexOf(layer)); }, - inputValueChanged() { const model = this.model; this.elementUpdated(); @@ -85,7 +83,7 @@ module.exports = PropertyCompositeView.extend({ if (!model.get('detached')) { model.set('value', this.getLayerValues()); } else { - model.get('properties').each(prop => prop.trigger('change:value')) + model.get('properties').each(prop => prop.trigger('change:value')); } }, @@ -126,7 +124,7 @@ module.exports = PropertyCompositeView.extend({ layers.reset(); layers.add(layersObj); - model.set({stackIndex: null}, {silent: true}); + model.set({ stackIndex: null }, { silent: true }); }, onRender() { @@ -149,14 +147,14 @@ module.exports = PropertyCompositeView.extend({ } else { model.set('value', model.getFullValue(), opt); } - }, + } }; const layers = new LayersView({ collection: this.getLayers(), stackModel: model, preview: model.get('preview'), config: this.config, - propsConfig, + propsConfig }).render().el; // Will use it to propogate changes @@ -167,11 +165,10 @@ module.exports = PropertyCompositeView.extend({ config: this.config, onChange: propsConfig.onChange, propTarget: propsConfig.propTarget, - customValue: propsConfig.customValue, + customValue: propsConfig.customValue }).render(); //model.get('properties') fieldEl.appendChild(layers); - }, - + } }); diff --git a/src/style_manager/view/PropertyView.js b/src/style_manager/view/PropertyView.js index 5f01672a8..bc601ea15 100644 --- a/src/style_manager/view/PropertyView.js +++ b/src/style_manager/view/PropertyView.js @@ -4,7 +4,6 @@ import { camelCase } from 'utils/mixins'; const clearProp = 'data-clear-style'; module.exports = Backbone.View.extend({ - template(model) { const pfx = this.pfx; return ` @@ -38,8 +37,8 @@ module.exports = Backbone.View.extend({ }, events: { - 'change': 'inputValueChanged', - [`click [${clearProp}]`]: 'clear', + change: 'inputValueChanged', + [`click [${clearProp}]`]: 'clear' }, initialize(o = {}) { @@ -52,8 +51,8 @@ module.exports = Backbone.View.extend({ this.target = o.target || {}; this.propTarget = o.propTarget || {}; this.onChange = o.onChange; - this.onInputRender = o.onInputRender || {}; - this.customValue = o.customValue || {}; + this.onInputRender = o.onInputRender || {}; + this.customValue = o.customValue || {}; const model = this.model; this.property = model.get('property'); this.input = null; @@ -160,7 +159,6 @@ module.exports = Backbone.View.extend({ this.elementUpdated(); }, - /** * Fired when the element of the property is updated */ @@ -168,14 +166,12 @@ module.exports = Backbone.View.extend({ this.setStatus('updated'); }, - setStatus(value) { this.model.set('status', value); const parent = this.model.parent; parent && parent.set('status', value); }, - /** * Fired when the target is changed * */ @@ -189,7 +185,7 @@ module.exports = Backbone.View.extend({ const model = this.model; let value = ''; let status = ''; - let targetValue = this.getTargetValue({ignoreDefault: 1}); + let targetValue = this.getTargetValue({ ignoreDefault: 1 }); let defaultValue = model.getDefaultValue(); let computedValue = this.getComputedValue(); @@ -199,8 +195,11 @@ module.exports = Backbone.View.extend({ if (config.highlightChanged) { status = 'updated'; } - } else if (computedValue && config.showComputed && - computedValue != defaultValue) { + } else if ( + computedValue && + config.showComputed && + computedValue != defaultValue + ) { value = computedValue; if (config.highlightComputed) { @@ -432,7 +431,6 @@ module.exports = Backbone.View.extend({ this.setValue(this.model.parseValue(value)); }, - /** * Update the element input. * Usually the value is a result of `model.getFullValue()` @@ -445,7 +443,6 @@ module.exports = Backbone.View.extend({ input && (input.value = val); }, - getInputEl() { if (!this.input) { this.input = this.el.querySelector('input'); @@ -455,8 +452,7 @@ module.exports = Backbone.View.extend({ }, updateVisibility() { - this.el.style.display = this.model.get('visible') ? - 'block' : 'none'; + this.el.style.display = this.model.get('visible') ? 'block' : 'none'; }, show() { @@ -484,7 +480,6 @@ module.exports = Backbone.View.extend({ const onRender = this.onRender && this.onRender.bind(this); onRender && onRender(); - this.setValue(model.get('value'), {targetUpdate: 1}); - }, - + this.setValue(model.get('value'), { targetUpdate: 1 }); + } }); diff --git a/src/style_manager/view/SectorView.js b/src/style_manager/view/SectorView.js index 336866a0e..807083f19 100644 --- a/src/style_manager/view/SectorView.js +++ b/src/style_manager/view/SectorView.js @@ -2,14 +2,13 @@ var Backbone = require('backbone'); var PropertiesView = require('./PropertiesView'); module.exports = Backbone.View.extend({ - template: _.template(`
<%= label %>
`), - events:{ + events: { 'click [data-sector-title]': 'toggle' }, @@ -43,17 +42,15 @@ module.exports = Backbone.View.extend({ * Update visibility */ updateOpen() { - if(this.model.get('open')) - this.show(); - else - this.hide(); + if (this.model.get('open')) this.show(); + else this.hide(); }, /** * Show the content of the sector * */ show() { - this.$el.addClass(this.pfx + "open"); + this.$el.addClass(this.pfx + 'open'); this.getPropertiesEl().style.display = ''; this.$caret.removeClass(this.caretR).addClass(this.caretD); }, @@ -62,7 +59,7 @@ module.exports = Backbone.View.extend({ * Hide the content of the sector * */ hide() { - this.$el.removeClass(this.pfx + "open"); + this.$el.removeClass(this.pfx + 'open'); this.getPropertiesEl().style.display = 'none'; this.$caret.removeClass(this.caretD).addClass(this.caretR); }, @@ -80,11 +77,13 @@ module.exports = Backbone.View.extend({ }, render() { - this.$el.html(this.template({ - pfx: this.pfx, - label: this.model.get('name'), - })); - this.$caret = this.$el.find('#' + this.pfx + 'caret'); + 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(); @@ -94,14 +93,14 @@ module.exports = Backbone.View.extend({ renderProperties() { var objs = this.model.get('properties'); - if(objs){ + if (objs) { var view = new PropertiesView({ collection: objs, target: this.target, propTarget: this.propTarget, - config: this.config, + config: this.config }); this.$el.append(view.render().el); } - }, + } }); diff --git a/src/style_manager/view/SectorsView.js b/src/style_manager/view/SectorsView.js index 339c9bde6..ce8c4c8d8 100644 --- a/src/style_manager/view/SectorsView.js +++ b/src/style_manager/view/SectorsView.js @@ -3,7 +3,6 @@ import { extend } from 'underscore'; const SectorView = require('./SectorView'); module.exports = Backbone.View.extend({ - initialize(o) { this.config = o.config || {}; this.pfx = this.config.stylePrefix || ''; @@ -19,11 +18,11 @@ module.exports = Backbone.View.extend({ body.removeChild(dummy); this.propTarget = target; const coll = this.collection; - const events = 'change:selectedComponent component:update:classes change:device'; + const events = + 'change:selectedComponent component:update:classes change:device'; this.listenTo(coll, 'add', this.addTo); this.listenTo(coll, 'reset', this.render); this.listenTo(this.target, events, this.targetUpdated); - }, /** @@ -63,7 +62,10 @@ module.exports = Backbone.View.extend({ pt.helper = null; if (view) { - pt.computed = window.getComputedStyle(view.el, state ? `:${state}` : null); + pt.computed = window.getComputedStyle( + view.el, + state ? `:${state}` : null + ); } const appendStateRule = (style = {}) => { @@ -137,7 +139,6 @@ module.exports = Backbone.View.extend({ pt.trigger('update'); }, - /** * Add new object to collection * @param {Object} model Model @@ -149,18 +150,23 @@ module.exports = Backbone.View.extend({ var fragment = fragmentEl || null; var view = new SectorView({ model, - id: this.pfx + model.get('name').replace(' ','_').toLowerCase(), + id: + this.pfx + + model + .get('name') + .replace(' ', '_') + .toLowerCase(), name: model.get('name'), properties: model.get('properties'), target: this.target, propTarget: this.propTarget, - config: this.config, + config: this.config }); var rendered = view.render().el; - if(fragment){ + if (fragment) { fragment.appendChild(rendered); - }else{ + } else { this.$el.append(rendered); } @@ -171,7 +177,7 @@ module.exports = Backbone.View.extend({ var fragment = document.createDocumentFragment(); this.$el.empty(); - this.collection.each(function(model){ + this.collection.each(function(model) { this.addToCollection(model, fragment); }, this); diff --git a/src/styles/scss/_gjs_blocks.scss b/src/styles/scss/_gjs_blocks.scss index 3af9bb622..e16d642f9 100644 --- a/src/styles/scss/_gjs_blocks.scss +++ b/src/styles/scss/_gjs_blocks.scss @@ -4,6 +4,11 @@ justify-content: flex-start; } +.#{$app-prefix}block-categories { + display: flex; + flex-direction: column; +} + .#{$app-prefix}block-category { width: 100%; @@ -47,6 +52,7 @@ .#{$app-prefix}block-svg { width: 61%; + fill: currentColor; } .#{$app-prefix}block-svg-path { diff --git a/src/trait_manager/config/config.js b/src/trait_manager/config/config.js index 0d45e5e9b..65cfd48e5 100644 --- a/src/trait_manager/config/config.js +++ b/src/trait_manager/config/config.js @@ -1,5 +1,4 @@ module.exports = { - stylePrefix: 'trt-', labelContainer: 'Component settings', @@ -15,5 +14,4 @@ module.exports = { { value: '', name: 'This window' }, { value: '_blank', name: 'New window' } ] - }; diff --git a/src/trait_manager/index.js b/src/trait_manager/index.js index 3f3350ff8..6dbc65f3f 100644 --- a/src/trait_manager/index.js +++ b/src/trait_manager/index.js @@ -7,14 +7,13 @@ module.exports = () => { let TraitsViewer; return { - TraitsView, /** * Name of the module * @type {String} * @private - */ + */ name: 'TraitManager', /** @@ -38,7 +37,7 @@ module.exports = () => { TraitsViewer = new TraitsView({ collection: [], editor: c.em, - config: c, + config: c }); return this; }, @@ -69,7 +68,6 @@ module.exports = () => { */ getType(name) { return TraitsViewer.itemsView[name]; - }, - + } }; }; diff --git a/src/trait_manager/model/Trait.js b/src/trait_manager/model/Trait.js index adec39da0..a36781a13 100644 --- a/src/trait_manager/model/Trait.js +++ b/src/trait_manager/model/Trait.js @@ -1,22 +1,22 @@ import { isUndefined } from 'underscore'; module.exports = require('backbone').Model.extend({ - defaults: { type: 'text', // text, number, range, select label: '', name: '', min: '', max: '', + unit: '', + step: 1, value: '', target: '', default: '', placeholder: '', changeProp: 0, - options: [], + options: [] }, - initialize() { const target = this.get('target'); const name = this.get('name'); @@ -25,18 +25,18 @@ module.exports = require('backbone').Model.extend({ if (target) { this.target = target; this.unset('target'); - const targetEvent = changeProp ? `change:${name}` : `change:attributes:${name}`; + const targetEvent = changeProp + ? `change:${name}` + : `change:attributes:${name}`; this.listenTo(target, targetEvent, this.targetUpdated); } }, - targetUpdated() { const value = this.getTargetValue(); !isUndefined(value) && this.set({ value }, { fromTarget: 1 }); }, - getTargetValue() { const name = this.get('name'); const target = this.target; @@ -44,7 +44,6 @@ module.exports = require('backbone').Model.extend({ if (target) return prop ? target.get(name) : target.getAttributes()[name]; }, - setTargetValue(value) { const target = this.target; const name = this.get('name'); @@ -59,6 +58,16 @@ module.exports = require('backbone').Model.extend({ } }, + setValueFromInput(value, final = 1, opts = {}) { + const toSet = { value }; + this.set(toSet, { ...opts, avoidStore: 1 }); + + // Have to trigger the change + if (final) { + this.set('value', '', opts); + this.set(toSet, opts); + } + }, /** * Get the initial value of the trait @@ -76,5 +85,4 @@ module.exports = require('backbone').Model.extend({ return value || this.get('value') || this.get('default'); } - }); diff --git a/src/trait_manager/model/TraitFactory.js b/src/trait_manager/model/TraitFactory.js index 1c3355d7a..5f47b7ab8 100644 --- a/src/trait_manager/model/TraitFactory.js +++ b/src/trait_manager/model/TraitFactory.js @@ -7,8 +7,7 @@ module.exports = (config = {}) => ({ build(props) { var objs = []; - if(typeof props === 'string') - props = [props]; + if (typeof props === 'string') props = [props]; for (var i = 0; i < props.length; i++) { var obj = {}; @@ -24,7 +23,9 @@ module.exports = (config = {}) => ({ // Define placeholder switch (prop) { - case 'title': case 'alt': case 'id': + case 'title': + case 'alt': + case 'id': obj.placeholder = config.labelPlhText; break; case 'href': @@ -32,7 +33,6 @@ module.exports = (config = {}) => ({ break; } - // Define options switch (prop) { case 'target': diff --git a/src/trait_manager/model/Traits.js b/src/trait_manager/model/Traits.js index bf9d9ba03..55a57aa64 100644 --- a/src/trait_manager/model/Traits.js +++ b/src/trait_manager/model/Traits.js @@ -4,7 +4,6 @@ const Trait = require('./Trait'); const TraitFactory = require('./TraitFactory'); module.exports = Backbone.Collection.extend({ - model: Trait, initialize(coll, options = {}) { @@ -25,7 +24,7 @@ module.exports = Backbone.Collection.extend({ const tf = TraitFactory(tmOpts); if (isString(models)) { - models = [models]; + models = [models]; } for (var i = 0, len = models.length; i < len; i++) { diff --git a/src/trait_manager/view/TraitCheckboxView.js b/src/trait_manager/view/TraitCheckboxView.js index c36bf1d23..79a3bbe0f 100644 --- a/src/trait_manager/view/TraitCheckboxView.js +++ b/src/trait_manager/view/TraitCheckboxView.js @@ -1,11 +1,17 @@ var TraitView = require('./TraitView'); module.exports = TraitView.extend({ - initialize(o) { TraitView.prototype.initialize.apply(this, arguments); var iconCls = this.ppfx + 'chk-icon'; - this.tmpl = '
'; + this.tmpl = + '
'; }, /** @@ -23,14 +29,13 @@ module.exports = TraitView.extend({ */ getInputEl(...args) { var first; - if(!this.$input) - first = 1; + if (!this.$input) first = 1; var el = TraitView.prototype.getInputEl.apply(this, args); - if(first){ + if (first) { var md = this.model; var name = md.get('name'); var target = this.target; - if(md.get('changeProp')){ + if (md.get('changeProp')) { el.checked = target.get(name); } else { var attrs = target.get('attributes'); @@ -38,6 +43,5 @@ module.exports = TraitView.extend({ } } return el; - }, - + } }); diff --git a/src/trait_manager/view/TraitColorView.js b/src/trait_manager/view/TraitColorView.js index 621ae3dcd..42c0616fa 100644 --- a/src/trait_manager/view/TraitColorView.js +++ b/src/trait_manager/view/TraitColorView.js @@ -10,16 +10,17 @@ module.exports = TraitView.extend({ getInputEl() { if (!this.$input) { var value = this.getModelValue(); - var inputNumber = new InputColor({ + var inputColor = new InputColor({ target: this.config.em, contClass: this.ppfx + 'field-color', model: this.model, ppfx: this.ppfx }); - this.input = inputNumber.render(); + this.input = inputColor.render(); this.$input = this.input.colorEl; value = value || ''; this.model.set('value', value).trigger('change:value'); + this.input.setValue(value); } return this.$input.get(0); }, @@ -29,10 +30,9 @@ module.exports = TraitView.extend({ * @private * */ renderField() { - if(!this.$input){ + if (!this.$input) { this.getInputEl(); this.$el.append(this.input.el); } - }, - + } }); diff --git a/src/trait_manager/view/TraitNumberView.js b/src/trait_manager/view/TraitNumberView.js index 3c66519f8..083872af5 100644 --- a/src/trait_manager/view/TraitNumberView.js +++ b/src/trait_manager/view/TraitNumberView.js @@ -2,12 +2,11 @@ var TraitView = require('./TraitView'); var InputNumber = require('domain_abstract/ui/InputNumber'); module.exports = TraitView.extend({ - getValueForTarget() { var model = this.model; var value = model.get('value'); var unit = model.get('unit'); - return value ? (value + unit) : ''; + return value ? value + unit : ''; }, /** @@ -37,11 +36,10 @@ module.exports = TraitView.extend({ * @private * */ renderField() { - if(!this.$input){ + if (!this.$input) { this.$el.append(this.tmpl); this.getInputEl(); this.$el.find('.' + this.inputhClass).prepend(this.input.el); } - }, - + } }); diff --git a/src/trait_manager/view/TraitSelectView.js b/src/trait_manager/view/TraitSelectView.js index 494f8238c..ca51ecdec 100644 --- a/src/trait_manager/view/TraitSelectView.js +++ b/src/trait_manager/view/TraitSelectView.js @@ -2,12 +2,20 @@ const TraitView = require('./TraitView'); const $ = Backbone.$; module.exports = TraitView.extend({ - initialize(o) { TraitView.prototype.initialize.apply(this, arguments); var ppfx = this.ppfx; - this.tmpl = '
'+ - '
'; + this.tmpl = + '
' + + '
'; }, /** @@ -16,7 +24,7 @@ module.exports = TraitView.extend({ * @private */ getInputEl() { - if(!this.$input) { + if (!this.$input) { var md = this.model; var opts = md.get('options') || []; var input = '`); if (value) { @@ -142,7 +147,7 @@ module.exports = Backbone.View.extend({ * @private * */ renderField() { - if(!this.$input){ + if (!this.$input) { this.$el.append(this.tmpl); const el = this.getInputEl(); // I use prepand expecially for checkbox traits @@ -156,6 +161,5 @@ module.exports = Backbone.View.extend({ this.renderField(); this.el.className = this.className; return this; - }, - + } }); diff --git a/src/trait_manager/view/TraitsView.js b/src/trait_manager/view/TraitsView.js index 1142b9232..c11a1a7ba 100644 --- a/src/trait_manager/view/TraitsView.js +++ b/src/trait_manager/view/TraitsView.js @@ -6,15 +6,14 @@ var TraitNumberView = require('./TraitNumberView'); var TraitColorView = require('./TraitColorView'); module.exports = DomainViews.extend({ - itemView: TraitView, itemsView: { - 'text': TraitView, - 'number': TraitNumberView, - 'select': TraitSelectView, - 'checkbox': TraitCheckboxView, - 'color': TraitColorView, + text: TraitView, + number: TraitNumberView, + select: TraitSelectView, + checkbox: TraitCheckboxView, + color: TraitColorView }, initialize(o) { @@ -33,10 +32,9 @@ module.exports = DomainViews.extend({ updatedCollection() { this.el.className = this.className; var comp = this.em.get('selectedComponent'); - if(comp){ + if (comp) { this.collection = comp.get('traits'); this.render(); } - }, - + } }); diff --git a/src/undo_manager/index.js b/src/undo_manager/index.js index 786fd4af6..ae38cb919 100644 --- a/src/undo_manager/index.js +++ b/src/undo_manager/index.js @@ -17,10 +17,8 @@ module.exports = () => { const configDef = {}; return { - name: 'UndoManager', - /** * Initialize module * @param {Object} config Configurations @@ -60,13 +58,14 @@ module.exports = () => { const events = ['style', 'attributes', 'content', 'src']; events.forEach(ev => um.addUndoType(`change:${ev}`, customUndoType)); - um.on('undo redo', () => em.trigger('change:selectedComponent change:canvasOffset')); + um.on('undo redo', () => + em.trigger('change:selectedComponent change:canvasOffset') + ); ['undo', 'redo'].forEach(ev => um.on(ev, () => em.trigger(ev))); return this; }, - /** * Get module configurations * @return {Object} Configuration object @@ -78,7 +77,6 @@ module.exports = () => { return config; }, - /** * Add an entity (Model/Collection) to track * Note: New Components and CSSRules will be added automatically @@ -92,7 +90,6 @@ module.exports = () => { return this; }, - /** * Remove and stop tracking the entity (Model/Collection) * @param {Model|Collection} entity Entity to remove @@ -105,7 +102,6 @@ module.exports = () => { return this; }, - /** * Remove all entities * @return {this} @@ -117,7 +113,6 @@ module.exports = () => { return this; }, - /** * Start/resume tracking changes * @return {this} @@ -129,7 +124,6 @@ module.exports = () => { return this; }, - /** * Stop tracking changes * @return {this} @@ -141,7 +135,6 @@ module.exports = () => { return this; }, - /** * Undo last change * @return {this} @@ -153,7 +146,6 @@ module.exports = () => { return this; }, - /** * Undo all changes * @return {this} @@ -165,7 +157,6 @@ module.exports = () => { return this; }, - /** * Redo last change * @return {this} @@ -177,7 +168,6 @@ module.exports = () => { return this; }, - /** * Redo all changes * @return {this} @@ -189,7 +179,6 @@ module.exports = () => { return this; }, - /** * Checks if exists an available undo * @return {Boolean} @@ -200,7 +189,6 @@ module.exports = () => { return um.isAvailable('undo'); }, - /** * Checks if exists an available redo * @return {Boolean} @@ -211,7 +199,6 @@ module.exports = () => { return um.isAvailable('redo'); }, - /** * Get stack of changes * @return {Collection} @@ -234,7 +221,6 @@ module.exports = () => { return this; }, - getInstance() { return um; } diff --git a/src/utils/ColorPicker.js b/src/utils/ColorPicker.js index 2018513c7..d3eacce10 100644 --- a/src/utils/ColorPicker.js +++ b/src/utils/ColorPicker.js @@ -5,2317 +5,2530 @@ // Author: Brian Grinstead // License: MIT -(function (factory) { - factory(Backbone.$) +(function(factory) { + factory(Backbone.$); })(function($, undefined) { - "use strict"; - - var defaultOpts = { - - // Callbacks - beforeShow: noop, - move: noop, - change: noop, - show: noop, - hide: noop, - - // Options - color: false, - flat: false, - showInput: false, - allowEmpty: false, - showButtons: true, - clickoutFiresChange: true, - showInitial: false, - showPalette: false, - showPaletteOnly: false, - hideAfterPaletteSelect: false, - togglePaletteOnly: false, - showSelectionPalette: true, - localStorageKey: false, - appendTo: "body", - maxSelectionSize: 7, - cancelText: "cancel", - chooseText: "choose", - togglePaletteMoreText: "more", - togglePaletteLessText: "less", - clearText: "Clear Color Selection", - noColorSelectedText: "No Color Selected", - preferredFormat: false, - className: "", // Deprecated - use containerClassName and replacerClassName instead. - containerClassName: "", - replacerClassName: "", - showAlpha: false, - theme: "sp-light", - palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]], - selectionPalette: [], - disabled: false, - offset: null + 'use strict'; + + var defaultOpts = { + // Callbacks + beforeShow: noop, + move: noop, + change: noop, + show: noop, + hide: noop, + + // Options + color: false, + flat: false, + showInput: false, + allowEmpty: false, + showButtons: true, + clickoutFiresChange: true, + showInitial: false, + showPalette: false, + showPaletteOnly: false, + hideAfterPaletteSelect: false, + togglePaletteOnly: false, + showSelectionPalette: true, + localStorageKey: false, + appendTo: 'body', + maxSelectionSize: 7, + cancelText: 'cancel', + chooseText: 'choose', + togglePaletteMoreText: 'more', + togglePaletteLessText: 'less', + clearText: 'Clear Color Selection', + noColorSelectedText: 'No Color Selected', + preferredFormat: false, + className: '', // Deprecated - use containerClassName and replacerClassName instead. + containerClassName: '', + replacerClassName: '', + showAlpha: false, + theme: 'sp-light', + palette: [ + [ + '#ffffff', + '#000000', + '#ff0000', + '#ff8000', + '#ffff00', + '#008000', + '#0000ff', + '#4b0082', + '#9400d3' + ] + ], + selectionPalette: [], + disabled: false, + offset: null }, spectrums = [], - IE = !!/msie/i.exec( window.navigator.userAgent ), + IE = !!/msie/i.exec(window.navigator.userAgent), rgbaSupport = (function() { - function contains( str, substr ) { - return !!~('' + str).indexOf(substr); - } - - var elem = document.createElement('div'); - var style = elem.style; - style.cssText = 'background-color:rgba(0,0,0,.5)'; - return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla'); + function contains(str, substr) { + return !!~('' + str).indexOf(substr); + } + + var elem = document.createElement('div'); + var style = elem.style; + style.cssText = 'background-color:rgba(0,0,0,.5)'; + return ( + contains(style.backgroundColor, 'rgba') || + contains(style.backgroundColor, 'hsla') + ); })(), replaceInput = [ - "
", - "
", - "
▼
", - "
" + "
", + "
", + "
▼
", + '
' ].join(''), - markup = (function () { - - // IE does not support gradients with multiple stops, so we need to simulate - // that for the rainbow slider with 8 divs that each have a single gradient - var gradientFix = ""; - if (IE) { - for (var i = 1; i <= 6; i++) { - gradientFix += "
"; - } - } - - return [ - "
", - "
", - "
", - "
", - "", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - "
", - gradientFix, - "
", - "
", - "
", - "
", - "
", - "", - "
", - "
", - "
", - "", - "", - "
", - "
", - "
" - ].join(""); + markup = (function() { + // IE does not support gradients with multiple stops, so we need to simulate + // that for the rainbow slider with 8 divs that each have a single gradient + var gradientFix = ''; + if (IE) { + for (var i = 1; i <= 6; i++) { + gradientFix += "
"; + } + } + + return [ + "
", + "
", + "
", + "
", + "", + '
', + '
', + "
", + "
", + "
", + "
", + "
", + "
", + "
", + "
", + '
', + '
', + '
', + "
", + '
', + "
", + "
", + gradientFix, + '
', + '
', + "
", + '
', + "
", + "", + '
', + "
", + "
", + "", + "", + '
', + '
', + '
' + ].join(''); })(); - function paletteTemplate (p, color, className, opts) { - var html = []; - for (var i = 0; i < p.length; i++) { - var current = p[i]; - if(current) { - var tiny = tinycolor(current); - var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light"; - c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : ""; - var formattedString = tiny.toString(opts.preferredFormat || "rgb"); - var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter(); - html.push(''); - } else { - var cls = 'sp-clear-display'; - html.push($('
') - .append($('') - .attr('title', opts.noColorSelectedText) - ) - .html() - ); - } - } - return "
" + html.join('') + "
"; + function paletteTemplate(p, color, className, opts) { + var html = []; + for (var i = 0; i < p.length; i++) { + var current = p[i]; + if (current) { + var tiny = tinycolor(current); + var c = + tiny.toHsl().l < 0.5 + ? 'sp-thumb-el sp-thumb-dark' + : 'sp-thumb-el sp-thumb-light'; + c += tinycolor.equals(color, current) ? ' sp-thumb-active' : ''; + var formattedString = tiny.toString(opts.preferredFormat || 'rgb'); + var swatchStyle = rgbaSupport + ? 'background-color:' + tiny.toRgbString() + : 'filter:' + tiny.toFilter(); + html.push( + '' + ); + } else { + var cls = 'sp-clear-display'; + html.push( + $('
') + .append( + $( + '' + ).attr('title', opts.noColorSelectedText) + ) + .html() + ); + } } - - function hideAll() { - for (var i = 0; i < spectrums.length; i++) { - if (spectrums[i]) { - spectrums[i].hide(); - } - } + return "
" + html.join('') + '
'; + } + + function hideAll() { + for (var i = 0; i < spectrums.length; i++) { + if (spectrums[i]) { + spectrums[i].hide(); + } + } + } + + function instanceOptions(o, callbackContext) { + var opts = $.extend({}, defaultOpts, o); + opts.callbacks = { + move: bind(opts.move, callbackContext), + change: bind(opts.change, callbackContext), + show: bind(opts.show, callbackContext), + hide: bind(opts.hide, callbackContext), + beforeShow: bind(opts.beforeShow, callbackContext) + }; + return opts; + } + + function spectrum(element, o) { + var opts = instanceOptions(o, element), + flat = opts.flat, + showSelectionPalette = opts.showSelectionPalette, + localStorageKey = opts.localStorageKey, + theme = opts.theme, + callbacks = opts.callbacks, + resize = throttle(reflow, 10), + visible = false, + isDragging = false, + dragWidth = 0, + dragHeight = 0, + dragHelperHeight = 0, + slideHeight = 0, + slideWidth = 0, + alphaWidth = 0, + alphaSlideHelperWidth = 0, + slideHelperHeight = 0, + currentHue = 0, + currentSaturation = 0, + currentValue = 0, + currentAlpha = 1, + palette = [], + paletteArray = [], + paletteLookup = {}, + selectionPalette = opts.selectionPalette.slice(0), + maxSelectionSize = opts.maxSelectionSize, + draggingClass = 'sp-dragging', + shiftMovementDirection = null; + + var doc = element.ownerDocument, + body = doc.body, + boundElement = $(element), + disabled = false, + container = $(markup, doc).addClass(theme), + pickerContainer = container.find('.sp-picker-container'), + dragger = container.find('.sp-color'), + dragHelper = container.find('.sp-dragger'), + slider = container.find('.sp-hue'), + slideHelper = container.find('.sp-slider'), + alphaSliderInner = container.find('.sp-alpha-inner'), + alphaSlider = container.find('.sp-alpha'), + alphaSlideHelper = container.find('.sp-alpha-handle'), + textInput = container.find('.sp-input'), + paletteContainer = container.find('.sp-palette'), + initialColorContainer = container.find('.sp-initial'), + cancelButton = container.find('.sp-cancel'), + clearButton = container.find('.sp-clear'), + chooseButton = container.find('.sp-choose'), + toggleButton = container.find('.sp-palette-toggle'), + isInput = boundElement.is('input'), + isInputTypeColor = + isInput && + boundElement.attr('type') === 'color' && + inputTypeColorSupport(), + shouldReplace = isInput && !flat, + replacer = shouldReplace + ? $(replaceInput) + .addClass(theme) + .addClass(opts.className) + .addClass(opts.replacerClassName) + : $([]), + offsetElement = shouldReplace ? replacer : boundElement, + previewElement = replacer.find('.sp-preview-inner'), + initialColor = opts.color || (isInput && boundElement.val()), + colorOnShow = false, + currentPreferredFormat = opts.preferredFormat, + clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange, + isEmpty = !initialColor, + allowEmpty = opts.allowEmpty && !isInputTypeColor; + + function applyOptions() { + if (opts.showPaletteOnly) { + opts.showPalette = true; + } + + toggleButton.text( + opts.showPaletteOnly + ? opts.togglePaletteMoreText + : opts.togglePaletteLessText + ); + + if (opts.palette) { + palette = opts.palette.slice(0); + paletteArray = $.isArray(palette[0]) ? palette : [palette]; + paletteLookup = {}; + for (var i = 0; i < paletteArray.length; i++) { + for (var j = 0; j < paletteArray[i].length; j++) { + var rgb = tinycolor(paletteArray[i][j]).toRgbString(); + paletteLookup[rgb] = true; + } + } + } + + container.toggleClass('sp-flat', flat); + container.toggleClass('sp-input-disabled', !opts.showInput); + container.toggleClass('sp-alpha-enabled', opts.showAlpha); + container.toggleClass('sp-clear-enabled', allowEmpty); + container.toggleClass('sp-buttons-disabled', !opts.showButtons); + container.toggleClass( + 'sp-palette-buttons-disabled', + !opts.togglePaletteOnly + ); + container.toggleClass('sp-palette-disabled', !opts.showPalette); + container.toggleClass('sp-palette-only', opts.showPaletteOnly); + container.toggleClass('sp-initial-disabled', !opts.showInitial); + container.addClass(opts.className).addClass(opts.containerClassName); + + reflow(); } - function instanceOptions(o, callbackContext) { - var opts = $.extend({}, defaultOpts, o); - opts.callbacks = { - 'move': bind(opts.move, callbackContext), - 'change': bind(opts.change, callbackContext), - 'show': bind(opts.show, callbackContext), - 'hide': bind(opts.hide, callbackContext), - 'beforeShow': bind(opts.beforeShow, callbackContext) - }; - return opts; - } - - function spectrum(element, o) { - - var opts = instanceOptions(o, element), - flat = opts.flat, - showSelectionPalette = opts.showSelectionPalette, - localStorageKey = opts.localStorageKey, - theme = opts.theme, - callbacks = opts.callbacks, - resize = throttle(reflow, 10), - visible = false, - isDragging = false, - dragWidth = 0, - dragHeight = 0, - dragHelperHeight = 0, - slideHeight = 0, - slideWidth = 0, - alphaWidth = 0, - alphaSlideHelperWidth = 0, - slideHelperHeight = 0, - currentHue = 0, - currentSaturation = 0, - currentValue = 0, - currentAlpha = 1, - palette = [], - paletteArray = [], - paletteLookup = {}, - selectionPalette = opts.selectionPalette.slice(0), - maxSelectionSize = opts.maxSelectionSize, - draggingClass = "sp-dragging", - shiftMovementDirection = null; - - var doc = element.ownerDocument, - body = doc.body, - boundElement = $(element), - disabled = false, - container = $(markup, doc).addClass(theme), - pickerContainer = container.find(".sp-picker-container"), - dragger = container.find(".sp-color"), - dragHelper = container.find(".sp-dragger"), - slider = container.find(".sp-hue"), - slideHelper = container.find(".sp-slider"), - alphaSliderInner = container.find(".sp-alpha-inner"), - alphaSlider = container.find(".sp-alpha"), - alphaSlideHelper = container.find(".sp-alpha-handle"), - textInput = container.find(".sp-input"), - paletteContainer = container.find(".sp-palette"), - initialColorContainer = container.find(".sp-initial"), - cancelButton = container.find(".sp-cancel"), - clearButton = container.find(".sp-clear"), - chooseButton = container.find(".sp-choose"), - toggleButton = container.find(".sp-palette-toggle"), - isInput = boundElement.is("input"), - isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(), - shouldReplace = isInput && !flat, - replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]), - offsetElement = (shouldReplace) ? replacer : boundElement, - previewElement = replacer.find(".sp-preview-inner"), - initialColor = opts.color || (isInput && boundElement.val()), - colorOnShow = false, - currentPreferredFormat = opts.preferredFormat, - clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange, - isEmpty = !initialColor, - allowEmpty = opts.allowEmpty && !isInputTypeColor; - - function applyOptions() { - - if (opts.showPaletteOnly) { - opts.showPalette = true; - } - - toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText); - - if (opts.palette) { - palette = opts.palette.slice(0); - paletteArray = $.isArray(palette[0]) ? palette : [palette]; - paletteLookup = {}; - for (var i = 0; i < paletteArray.length; i++) { - for (var j = 0; j < paletteArray[i].length; j++) { - var rgb = tinycolor(paletteArray[i][j]).toRgbString(); - paletteLookup[rgb] = true; - } - } - } - - container.toggleClass("sp-flat", flat); - container.toggleClass("sp-input-disabled", !opts.showInput); - container.toggleClass("sp-alpha-enabled", opts.showAlpha); - container.toggleClass("sp-clear-enabled", allowEmpty); - container.toggleClass("sp-buttons-disabled", !opts.showButtons); - container.toggleClass("sp-palette-buttons-disabled", !opts.togglePaletteOnly); - container.toggleClass("sp-palette-disabled", !opts.showPalette); - container.toggleClass("sp-palette-only", opts.showPaletteOnly); - container.toggleClass("sp-initial-disabled", !opts.showInitial); - container.addClass(opts.className).addClass(opts.containerClassName); - - reflow(); - } - - function initialize() { - - if (IE) { - container.find("*:not(input)").attr("unselectable", "on"); - } - - applyOptions(); - - if (shouldReplace) { - boundElement.after(replacer).hide(); - } - - if (!allowEmpty) { - clearButton.hide(); - } - - if (flat) { - boundElement.after(container).hide(); - } - else { - - var appendTo = opts.appendTo === "parent" ? boundElement.parent() : $(opts.appendTo); - if (appendTo.length !== 1) { - appendTo = $("body"); - } - - appendTo.append(container); - } - - updateSelectionPaletteFromStorage(); - - offsetElement.bind("click.spectrum touchstart.spectrum", function (e) { - - if (!disabled) { - toggle(); - } - - e.stopPropagation(); - - if (!$(e.target).is("input")) { - e.preventDefault(); - } - }); - - if(boundElement.is(":disabled") || (opts.disabled === true)) { - disable(); - } - - // Prevent clicks from bubbling up to document. This would cause it to be hidden. - container.click(stopPropagation); + function initialize() { + if (IE) { + container.find('*:not(input)').attr('unselectable', 'on'); + } - // Handle user typed input - textInput.change(setFromTextInput); - textInput.bind("paste", function () { - setTimeout(setFromTextInput, 1); - }); - textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } }); - - cancelButton.text(opts.cancelText); - cancelButton.bind("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); - revert(); - hide(); - }); + applyOptions(); - clearButton.attr("title", opts.clearText); - clearButton.bind("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); - isEmpty = true; - move(); - - if(flat) { - //for the flat style, this is a change event - updateOriginalInput(true); - } - }); + if (shouldReplace) { + boundElement.after(replacer).hide(); + } - chooseButton.text(opts.chooseText); - chooseButton.bind("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); + if (!allowEmpty) { + clearButton.hide(); + } - if (IE && textInput.is(":focus")) { - textInput.trigger('change'); - } + if (flat) { + boundElement.after(container).hide(); + } else { + var appendTo = + opts.appendTo === 'parent' ? boundElement.parent() : $(opts.appendTo); + if (appendTo.length !== 1) { + appendTo = $('body'); + } - if (isValid()) { - updateOriginalInput(true); - hide(); - } - }); + appendTo.append(container); + } - toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText); - toggleButton.bind("click.spectrum", function (e) { - e.stopPropagation(); - e.preventDefault(); - - opts.showPaletteOnly = !opts.showPaletteOnly; - - // To make sure the Picker area is drawn on the right, next to the - // Palette area (and not below the palette), first move the Palette - // to the left to make space for the picker, plus 5px extra. - // The 'applyOptions' function puts the whole container back into place - // and takes care of the button-text and the sp-palette-only CSS class. - if (!opts.showPaletteOnly && !flat) { - container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5)); - } - applyOptions(); - }); + updateSelectionPaletteFromStorage(); - draggable(alphaSlider, function (dragX, dragY, e) { - currentAlpha = (dragX / alphaWidth); - isEmpty = false; - if (e.shiftKey) { - currentAlpha = Math.round(currentAlpha * 10) / 10; - } - - move(); - }, dragStart, dragStop); - - draggable(slider, function (dragX, dragY) { - currentHue = parseFloat(dragY / slideHeight); - isEmpty = false; - if (!opts.showAlpha) { - currentAlpha = 1; - } - move(); - }, dragStart, dragStop); - - draggable(dragger, function (dragX, dragY, e) { - - // shift+drag should snap the movement to either the x or y axis. - if (!e.shiftKey) { - shiftMovementDirection = null; - } - else if (!shiftMovementDirection) { - var oldDragX = currentSaturation * dragWidth; - var oldDragY = dragHeight - (currentValue * dragHeight); - var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY); - - shiftMovementDirection = furtherFromX ? "x" : "y"; - } - - var setSaturation = !shiftMovementDirection || shiftMovementDirection === "x"; - var setValue = !shiftMovementDirection || shiftMovementDirection === "y"; - - if (setSaturation) { - currentSaturation = parseFloat(dragX / dragWidth); - } - if (setValue) { - currentValue = parseFloat((dragHeight - dragY) / dragHeight); - } - - isEmpty = false; - if (!opts.showAlpha) { - currentAlpha = 1; - } - - move(); - - }, dragStart, dragStop); - - if (!!initialColor) { - set(initialColor); - - // In case color was black - update the preview UI and set the format - // since the set function will not run (default color is black). - updateUI(); - currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format; - - addColorToSelectionPalette(initialColor); - } - else { - updateUI(); - } - - if (flat) { - show(); - } - - function paletteElementClick(e) { - if (e.data && e.data.ignore) { - set($(e.target).closest(".sp-thumb-el").data("color")); - move(); - } - else { - set($(e.target).closest(".sp-thumb-el").data("color")); - move(); - updateOriginalInput(true); - if (opts.hideAfterPaletteSelect) { - hide(); - } - } - - return false; - } - - var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum"; - paletteContainer.delegate(".sp-thumb-el", paletteEvent, paletteElementClick); - initialColorContainer.delegate(".sp-thumb-el:nth-child(1)", paletteEvent, { ignore: true }, paletteElementClick); + offsetElement.bind('click.spectrum touchstart.spectrum', function(e) { + if (!disabled) { + toggle(); } - function updateSelectionPaletteFromStorage() { - - if (localStorageKey && window.localStorage) { - - // Migrate old palettes over to new format. May want to remove this eventually. - try { - var oldPalette = window.localStorage[localStorageKey].split(",#"); - if (oldPalette.length > 1) { - delete window.localStorage[localStorageKey]; - $.each(oldPalette, function(i, c) { - addColorToSelectionPalette(c); - }); - } - } - catch(e) { } - - try { - selectionPalette = window.localStorage[localStorageKey].split(";"); - } - catch (e) { } - } - } + e.stopPropagation(); - function addColorToSelectionPalette(color) { - if (showSelectionPalette) { - var rgb = tinycolor(color).toRgbString(); - if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) { - selectionPalette.push(rgb); - while(selectionPalette.length > maxSelectionSize) { - selectionPalette.shift(); - } - } - - if (localStorageKey && window.localStorage) { - try { - window.localStorage[localStorageKey] = selectionPalette.join(";"); - } - catch(e) { } - } - } + if (!$(e.target).is('input')) { + e.preventDefault(); } + }); - function getUniqueSelectionPalette() { - var unique = []; - if (opts.showPalette) { - for (var i = 0; i < selectionPalette.length; i++) { - var rgb = tinycolor(selectionPalette[i]).toRgbString(); + if (boundElement.is(':disabled') || opts.disabled === true) { + disable(); + } - if (!paletteLookup[rgb]) { - unique.push(selectionPalette[i]); - } - } - } + // Prevent clicks from bubbling up to document. This would cause it to be hidden. + container.click(stopPropagation); - return unique.reverse().slice(0, opts.maxSelectionSize); + // Handle user typed input + textInput.change(setFromTextInput); + textInput.bind('paste', function() { + setTimeout(setFromTextInput, 1); + }); + textInput.keydown(function(e) { + if (e.keyCode == 13) { + setFromTextInput(); } + }); - function drawPalette() { - - var currentColor = get(); - - var html = $.map(paletteArray, function (palette, i) { - return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i, opts); - }); - - updateSelectionPaletteFromStorage(); - - if (selectionPalette) { - html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection", opts)); - } + cancelButton.text(opts.cancelText); + cancelButton.bind('click.spectrum', function(e) { + e.stopPropagation(); + e.preventDefault(); + revert(); + hide(); + }); - paletteContainer.html(html.join("")); - } + clearButton.attr('title', opts.clearText); + clearButton.bind('click.spectrum', function(e) { + e.stopPropagation(); + e.preventDefault(); + isEmpty = true; + move(); - function drawInitial() { - if (opts.showInitial) { - var initial = colorOnShow; - var current = get(); - initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial", opts)); - } + if (flat) { + //for the flat style, this is a change event + updateOriginalInput(true); } + }); - function dragStart() { - if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) { - reflow(); - } - isDragging = true; - container.addClass(draggingClass); - shiftMovementDirection = null; - boundElement.trigger('dragstart.spectrum', [ get() ]); - } + chooseButton.text(opts.chooseText); + chooseButton.bind('click.spectrum', function(e) { + e.stopPropagation(); + e.preventDefault(); - function dragStop() { - isDragging = false; - container.removeClass(draggingClass); - boundElement.trigger('dragstop.spectrum', [ get() ]); + if (IE && textInput.is(':focus')) { + textInput.trigger('change'); } - function setFromTextInput() { - - var value = textInput.val(); - - if ((value === null || value === "") && allowEmpty) { - set(null); - updateOriginalInput(true); - } - else { - var tiny = tinycolor(value); - if (tiny.isValid()) { - set(tiny); - updateOriginalInput(true); - } - else { - textInput.addClass("sp-validation-error"); - } - } + if (isValid()) { + updateOriginalInput(true); + hide(); } + }); - function toggle() { - if (visible) { - hide(); - } - else { - show(); - } + toggleButton.text( + opts.showPaletteOnly + ? opts.togglePaletteMoreText + : opts.togglePaletteLessText + ); + toggleButton.bind('click.spectrum', function(e) { + e.stopPropagation(); + e.preventDefault(); + + opts.showPaletteOnly = !opts.showPaletteOnly; + + // To make sure the Picker area is drawn on the right, next to the + // Palette area (and not below the palette), first move the Palette + // to the left to make space for the picker, plus 5px extra. + // The 'applyOptions' function puts the whole container back into place + // and takes care of the button-text and the sp-palette-only CSS class. + if (!opts.showPaletteOnly && !flat) { + container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5)); + } + applyOptions(); + }); + + draggable( + alphaSlider, + function(dragX, dragY, e) { + currentAlpha = dragX / alphaWidth; + isEmpty = false; + if (e.shiftKey) { + currentAlpha = Math.round(currentAlpha * 10) / 10; + } + + move(); + }, + dragStart, + dragStop + ); + + draggable( + slider, + function(dragX, dragY) { + currentHue = parseFloat(dragY / slideHeight); + isEmpty = false; + if (!opts.showAlpha) { + currentAlpha = 1; + } + move(); + }, + dragStart, + dragStop + ); + + draggable( + dragger, + function(dragX, dragY, e) { + // shift+drag should snap the movement to either the x or y axis. + if (!e.shiftKey) { + shiftMovementDirection = null; + } else if (!shiftMovementDirection) { + var oldDragX = currentSaturation * dragWidth; + var oldDragY = dragHeight - currentValue * dragHeight; + var furtherFromX = + Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY); + + shiftMovementDirection = furtherFromX ? 'x' : 'y'; + } + + var setSaturation = + !shiftMovementDirection || shiftMovementDirection === 'x'; + var setValue = + !shiftMovementDirection || shiftMovementDirection === 'y'; + + if (setSaturation) { + currentSaturation = parseFloat(dragX / dragWidth); + } + if (setValue) { + currentValue = parseFloat((dragHeight - dragY) / dragHeight); + } + + isEmpty = false; + if (!opts.showAlpha) { + currentAlpha = 1; + } + + move(); + }, + dragStart, + dragStop + ); + + if (!!initialColor) { + set(initialColor); + + // In case color was black - update the preview UI and set the format + // since the set function will not run (default color is black). + updateUI(); + currentPreferredFormat = + opts.preferredFormat || tinycolor(initialColor).format; + + addColorToSelectionPalette(initialColor); + } else { + updateUI(); + } + + if (flat) { + show(); + } + + function paletteElementClick(e) { + if (e.data && e.data.ignore) { + set( + $(e.target) + .closest('.sp-thumb-el') + .data('color') + ); + move(); + } else { + set( + $(e.target) + .closest('.sp-thumb-el') + .data('color') + ); + move(); + updateOriginalInput(true); + if (opts.hideAfterPaletteSelect) { + hide(); + } } - function show() { - var event = $.Event('beforeShow.spectrum'); - - if (visible) { - reflow(); - return; - } - - boundElement.trigger(event, [ get() ]); - - if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) { - return; - } - - hideAll(); - visible = true; - - var $doc = $(doc); - $doc.bind("keydown.spectrum", onkeydown); - $doc.bind("click.spectrum", clickout); - $(window).bind("resize.spectrum", resize); - replacer.addClass("sp-active"); - container.removeClass("sp-hidden"); - - reflow(); - updateUI(); + return false; + } + + var paletteEvent = IE + ? 'mousedown.spectrum' + : 'click.spectrum touchstart.spectrum'; + paletteContainer.delegate( + '.sp-thumb-el', + paletteEvent, + paletteElementClick + ); + initialColorContainer.delegate( + '.sp-thumb-el:nth-child(1)', + paletteEvent, + { ignore: true }, + paletteElementClick + ); + } - colorOnShow = get(); + function updateSelectionPaletteFromStorage() { + if (localStorageKey && window.localStorage) { + // Migrate old palettes over to new format. May want to remove this eventually. + try { + var oldPalette = window.localStorage[localStorageKey].split(',#'); + if (oldPalette.length > 1) { + delete window.localStorage[localStorageKey]; + $.each(oldPalette, function(i, c) { + addColorToSelectionPalette(c); + }); + } + } catch (e) {} - drawInitial(); - callbacks.show(colorOnShow); - boundElement.trigger('show.spectrum', [ colorOnShow ]); - } + try { + selectionPalette = window.localStorage[localStorageKey].split(';'); + } catch (e) {} + } + } - function onkeydown(e) { - // Close on ESC - if (e.keyCode === 27) { - hide(); - } + function addColorToSelectionPalette(color) { + if (showSelectionPalette) { + var rgb = tinycolor(color).toRgbString(); + if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) { + selectionPalette.push(rgb); + while (selectionPalette.length > maxSelectionSize) { + selectionPalette.shift(); + } } - function clickout(e) { - // Return on right click. - if (e.button == 2) { return; } - - // If a drag event was happening during the mouseup, don't hide - // on click. - if (isDragging) { return; } - - if (clickoutFiresChange) { - updateOriginalInput(true); - } - else { - revert(); - } - hide(); + if (localStorageKey && window.localStorage) { + try { + window.localStorage[localStorageKey] = selectionPalette.join(';'); + } catch (e) {} } + } + } - function hide() { - // Return if hiding is unnecessary - if (!visible || flat) { return; } - visible = false; - - $(doc).unbind("keydown.spectrum", onkeydown); - $(doc).unbind("click.spectrum", clickout); - $(window).unbind("resize.spectrum", resize); - - replacer.removeClass("sp-active"); - container.addClass("sp-hidden"); + function getUniqueSelectionPalette() { + var unique = []; + if (opts.showPalette) { + for (var i = 0; i < selectionPalette.length; i++) { + var rgb = tinycolor(selectionPalette[i]).toRgbString(); - callbacks.hide(get()); - boundElement.trigger('hide.spectrum', [ get() ]); + if (!paletteLookup[rgb]) { + unique.push(selectionPalette[i]); + } } + } - function revert() { - set(colorOnShow, true); - } + return unique.reverse().slice(0, opts.maxSelectionSize); + } - function set(color, ignoreFormatChange) { - if (tinycolor.equals(color, get())) { - // Update UI just in case a validation error needs - // to be cleared. - updateUI(); - return; - } - - var newColor, newHsv; - if (!color && allowEmpty) { - isEmpty = true; - } else { - isEmpty = false; - newColor = tinycolor(color); - newHsv = newColor.toHsv(); - - currentHue = (newHsv.h % 360) / 360; - currentSaturation = newHsv.s; - currentValue = newHsv.v; - currentAlpha = newHsv.a; - } - updateUI(); - - if (newColor && newColor.isValid() && !ignoreFormatChange) { - currentPreferredFormat = opts.preferredFormat || newColor.getFormat(); - } - } + function drawPalette() { + var currentColor = get(); - function get(opts) { - opts = opts || { }; + var html = $.map(paletteArray, function(palette, i) { + return paletteTemplate( + palette, + currentColor, + 'sp-palette-row sp-palette-row-' + i, + opts + ); + }); + + updateSelectionPaletteFromStorage(); + + if (selectionPalette) { + html.push( + paletteTemplate( + getUniqueSelectionPalette(), + currentColor, + 'sp-palette-row sp-palette-row-selection', + opts + ) + ); + } - if (allowEmpty && isEmpty) { - return null; - } + paletteContainer.html(html.join('')); + } - return tinycolor.fromRatio({ - h: currentHue, - s: currentSaturation, - v: currentValue, - a: Math.round(currentAlpha * 100) / 100 - }, { format: opts.format || currentPreferredFormat }); - } + function drawInitial() { + if (opts.showInitial) { + var initial = colorOnShow; + var current = get(); + initialColorContainer.html( + paletteTemplate( + [initial, current], + current, + 'sp-palette-row-initial', + opts + ) + ); + } + } - function isValid() { - return !textInput.hasClass("sp-validation-error"); - } + function dragStart() { + if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) { + reflow(); + } + isDragging = true; + container.addClass(draggingClass); + shiftMovementDirection = null; + boundElement.trigger('dragstart.spectrum', [get()]); + } - function move() { - updateUI(); + function dragStop() { + isDragging = false; + container.removeClass(draggingClass); + boundElement.trigger('dragstop.spectrum', [get()]); + } - callbacks.move(get()); - boundElement.trigger('move.spectrum', [ get() ]); + function setFromTextInput() { + var value = textInput.val(); + + if ((value === null || value === '') && allowEmpty) { + set(null); + updateOriginalInput(true); + } else { + var tiny = tinycolor(value); + if (tiny.isValid()) { + set(tiny); + updateOriginalInput(true); + } else { + textInput.addClass('sp-validation-error'); } + } + } - function updateUI() { - - textInput.removeClass("sp-validation-error"); - - updateHelperLocations(); - - // Update dragger background color (gradients take care of saturation and value). - var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 }); - dragger.css("background-color", flatColor.toHexString()); - - // Get a format that alpha will be included in (hex and names ignore alpha) - var format = currentPreferredFormat; - if (currentAlpha < 1 && !(currentAlpha === 0 && format === "name")) { - if (format === "hex" || format === "hex3" || format === "hex6" || format === "name") { - format = "rgb"; - } - } - - var realColor = get({ format: format }), - displayColor = ''; - - //reset background info for preview element - previewElement.removeClass("sp-clear-display"); - previewElement.css('background-color', 'transparent'); - - if (!realColor && allowEmpty) { - // Update the replaced elements background with icon indicating no color selection - previewElement.addClass("sp-clear-display"); - } - else { - var realHex = realColor.toHexString(), - realRgb = realColor.toRgbString(); - - // Update the replaced elements background color (with actual selected color) - if (rgbaSupport || realColor.alpha === 1) { - previewElement.css("background-color", realRgb); - } - else { - previewElement.css("background-color", "transparent"); - previewElement.css("filter", realColor.toFilter()); - } - - if (opts.showAlpha) { - var rgb = realColor.toRgb(); - rgb.a = 0; - var realAlpha = tinycolor(rgb).toRgbString(); - var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")"; - - if (IE) { - alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex)); - } - else { - alphaSliderInner.css("background", "-webkit-" + gradient); - alphaSliderInner.css("background", "-moz-" + gradient); - alphaSliderInner.css("background", "-ms-" + gradient); - // Use current syntax gradient on unprefixed property. - alphaSliderInner.css("background", - "linear-gradient(to right, " + realAlpha + ", " + realHex + ")"); - } - } - - displayColor = realColor.toString(format); - } - - // Update the text entry input as it changes happen - if (opts.showInput) { - textInput.val(displayColor); - } - - if (opts.showPalette) { - drawPalette(); - } - - drawInitial(); - } + function toggle() { + if (visible) { + hide(); + } else { + show(); + } + } - function updateHelperLocations() { - var s = currentSaturation; - var v = currentValue; - - if(allowEmpty && isEmpty) { - //if selected color is empty, hide the helpers - alphaSlideHelper.hide(); - slideHelper.hide(); - dragHelper.hide(); - } - else { - //make sure helpers are visible - alphaSlideHelper.show(); - slideHelper.show(); - dragHelper.show(); - - // Where to show the little circle in that displays your current selected color - var dragX = s * dragWidth; - var dragY = dragHeight - (v * dragHeight); - dragX = Math.max( - -dragHelperHeight, - Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight) - ); - dragY = Math.max( - -dragHelperHeight, - Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight) - ); - dragHelper.css({ - "top": dragY + "px", - "left": dragX + "px" - }); - - var alphaX = currentAlpha * alphaWidth; - alphaSlideHelper.css({ - "left": (alphaX - (alphaSlideHelperWidth / 2)) + "px" - }); - - // Where to show the bar that displays your current selected hue - var slideY = (currentHue) * slideHeight; - slideHelper.css({ - "top": (slideY - slideHelperHeight) + "px" - }); - } - } + function show() { + var event = $.Event('beforeShow.spectrum'); - function updateOriginalInput(fireCallback) { - var color = get(), - displayColor = '', - hasChanged = !tinycolor.equals(color, colorOnShow); - - if (color) { - displayColor = color.toString(currentPreferredFormat); - // Update the selection palette with the current color - addColorToSelectionPalette(color); - } - - if (isInput) { - boundElement.val(displayColor); - } - - if (fireCallback && hasChanged) { - callbacks.change(color); - boundElement.trigger('change', [ color ]); - } - } + if (visible) { + reflow(); + return; + } - function reflow() { - if (!visible) { - return; // Calculations would be useless and wouldn't be reliable anyways - } - dragWidth = dragger.width(); - dragHeight = dragger.height(); - dragHelperHeight = dragHelper.height(); - slideWidth = slider.width(); - slideHeight = slider.height(); - slideHelperHeight = slideHelper.height(); - alphaWidth = alphaSlider.width(); - alphaSlideHelperWidth = alphaSlideHelper.width(); - - if (!flat) { - container.css("position", "absolute"); - if (opts.offset) { - container.offset(opts.offset); - } else { - container.offset(getOffset(container, offsetElement)); - } - } - - updateHelperLocations(); - - if (opts.showPalette) { - drawPalette(); - } - - boundElement.trigger('reflow.spectrum'); - } + boundElement.trigger(event, [get()]); - function destroy() { - boundElement.show(); - offsetElement.unbind("click.spectrum touchstart.spectrum"); - container.remove(); - replacer.remove(); - spectrums[spect.id] = null; - } + if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) { + return; + } - function option(optionName, optionValue) { - if (optionName === undefined) { - return $.extend({}, opts); - } - if (optionValue === undefined) { - return opts[optionName]; - } + hideAll(); + visible = true; - opts[optionName] = optionValue; + var $doc = $(doc); + $doc.bind('keydown.spectrum', onkeydown); + $doc.bind('click.spectrum', clickout); + $(window).bind('resize.spectrum', resize); + replacer.addClass('sp-active'); + container.removeClass('sp-hidden'); - if (optionName === "preferredFormat") { - currentPreferredFormat = opts.preferredFormat; - } - applyOptions(); - } + reflow(); + updateUI(); - function enable() { - disabled = false; - boundElement.attr("disabled", false); - offsetElement.removeClass("sp-disabled"); - } + colorOnShow = get(); - function disable() { - hide(); - disabled = true; - boundElement.attr("disabled", true); - offsetElement.addClass("sp-disabled"); - } + drawInitial(); + callbacks.show(colorOnShow); + boundElement.trigger('show.spectrum', [colorOnShow]); + } - function setOffset(coord) { - opts.offset = coord; - reflow(); - } + function onkeydown(e) { + // Close on ESC + if (e.keyCode === 27) { + hide(); + } + } - initialize(); - - var spect = { - show: show, - hide: hide, - toggle: toggle, - reflow: reflow, - option: option, - enable: enable, - disable: disable, - offset: setOffset, - set: function (c) { - set(c); - updateOriginalInput(); - }, - get: get, - destroy: destroy, - container: container - }; - - spect.id = spectrums.push(spect) - 1; - - return spect; - } - - /** - * checkOffset - get the offset below/above and left/right element depending on screen position - * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js - */ - function getOffset(picker, input) { - var extraY = 0; - var dpWidth = picker.outerWidth(); - var dpHeight = picker.outerHeight(); - var inputHeight = input.outerHeight(); - var doc = picker[0].ownerDocument; - var docElem = doc.documentElement; - var cW = docElem.clientWidth; - var cH = docElem.clientHeight; - var scL = $(doc).scrollLeft(); - var scT = $(doc).scrollTop(); - var viewWidth = cW + scL; - var viewHeight = cH + scT; - var offset = input.offset(); - - offset.top += inputHeight; - - offset.left -= - Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? - Math.abs(offset.left + dpWidth - viewWidth) : 0); - - offset.top -= - Math.min(offset.top, ((offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? - Math.abs(dpHeight + inputHeight - extraY) : extraY)); - - return offset; - } - - /** - * noop - do nothing - */ - function noop() { - - } - - /** - * stopPropagation - makes the code only doing this a little easier to read in line - */ - function stopPropagation(e) { - e.stopPropagation(); + function clickout(e) { + // Return on right click. + if (e.button == 2) { + return; + } + + // If a drag event was happening during the mouseup, don't hide + // on click. + if (isDragging) { + return; + } + + if (clickoutFiresChange) { + updateOriginalInput(true); + } else { + revert(); + } + hide(); } - /** - * Create a function bound to a given object - * Thanks to underscore.js - */ - function bind(func, obj) { - var slice = Array.prototype.slice; - var args = slice.call(arguments, 2); - return function () { - return func.apply(obj, args.concat(slice.call(arguments))); - }; - } - - /** - * Lightweight drag helper. Handles containment within the element, so that - * when dragging, the x is within [0,element.width] and y is within [0,element.height] - */ - function draggable(element, onmove, onstart, onstop) { - onmove = onmove || function () { }; - onstart = onstart || function () { }; - onstop = onstop || function () { }; - var doc = document; - var dragging = false; - var offset = {}; - var maxHeight = 0; - var maxWidth = 0; - var hasTouch = ('ontouchstart' in window); - - var duringDragEvents = {}; - duringDragEvents["selectstart"] = prevent; - duringDragEvents["dragstart"] = prevent; - duringDragEvents["touchmove mousemove"] = move; - duringDragEvents["touchend mouseup"] = stop; - - function prevent(e) { - if (e.stopPropagation) { - e.stopPropagation(); - } - if (e.preventDefault) { - e.preventDefault(); - } - e.returnValue = false; - } + function hide() { + // Return if hiding is unnecessary + if (!visible || flat) { + return; + } + visible = false; - function move(e) { - if (dragging) { - // Mouseup happened outside of window - if (IE && doc.documentMode < 9 && !e.button) { - return stop(); - } + $(doc).unbind('keydown.spectrum', onkeydown); + $(doc).unbind('click.spectrum', clickout); + $(window).unbind('resize.spectrum', resize); - var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0]; - var pageX = t0 && t0.pageX || e.pageX; - var pageY = t0 && t0.pageY || e.pageY; + replacer.removeClass('sp-active'); + container.addClass('sp-hidden'); - var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth)); - var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight)); + callbacks.hide(get()); + boundElement.trigger('hide.spectrum', [get()]); + } - if (hasTouch) { - // Stop scrolling in iOS - prevent(e); - } + function revert() { + set(colorOnShow, true); + } - onmove.apply(element, [dragX, dragY, e]); - } - } + function set(color, ignoreFormatChange) { + if (tinycolor.equals(color, get())) { + // Update UI just in case a validation error needs + // to be cleared. + updateUI(); + return; + } + + var newColor, newHsv; + if (!color && allowEmpty) { + isEmpty = true; + } else { + isEmpty = false; + newColor = tinycolor(color); + newHsv = newColor.toHsv(); + + currentHue = (newHsv.h % 360) / 360; + currentSaturation = newHsv.s; + currentValue = newHsv.v; + currentAlpha = newHsv.a; + } + updateUI(); + + if (newColor && newColor.isValid() && !ignoreFormatChange) { + currentPreferredFormat = opts.preferredFormat || newColor.getFormat(); + } + } - function start(e) { - var rightclick = (e.which) ? (e.which == 3) : (e.button == 2); + function get(opts) { + opts = opts || {}; - if (!rightclick && !dragging) { - if (onstart.apply(element, arguments) !== false) { - dragging = true; - maxHeight = $(element).height(); - maxWidth = $(element).width(); - offset = $(element).offset(); + if (allowEmpty && isEmpty) { + return null; + } - $(doc).bind(duringDragEvents); - $(doc.body).addClass("sp-dragging"); + return tinycolor.fromRatio( + { + h: currentHue, + s: currentSaturation, + v: currentValue, + a: Math.round(currentAlpha * 100) / 100 + }, + { format: opts.format || currentPreferredFormat } + ); + } - move(e); + function isValid() { + return !textInput.hasClass('sp-validation-error'); + } - prevent(e); - } - } - } + function move() { + updateUI(); - function stop() { - if (dragging) { - $(doc).unbind(duringDragEvents); - $(doc.body).removeClass("sp-dragging"); - - // Wait a tick before notifying observers to allow the click event - // to fire in Chrome. - setTimeout(function() { - onstop.apply(element, arguments); - }, 0); - } - dragging = false; - } + callbacks.move(get()); + boundElement.trigger('move.spectrum', [get()]); + } - $(element).bind("touchstart mousedown", start); - } - - function throttle(func, wait, debounce) { - var timeout; - return function () { - var context = this, args = arguments; - var throttler = function () { - timeout = null; - func.apply(context, args); - }; - if (debounce) clearTimeout(timeout); - if (debounce || !timeout) timeout = setTimeout(throttler, wait); - }; - } - - function inputTypeColorSupport() { - return $.fn.spectrum.inputTypeColorSupport(); - } - - /** - * Define a jQuery plugin - */ - var dataID = "spectrum.id"; - $.fn.spectrum = function (opts, extra) { - - if (typeof opts == "string") { - - var returnValue = this; - var args = Array.prototype.slice.call( arguments, 1 ); - - this.each(function () { - var spect = spectrums[$(this).data(dataID)]; - if (spect) { - var method = spect[opts]; - if (!method) { - throw new Error( "Spectrum: no such method: '" + opts + "'" ); - } - - if (opts == "get") { - returnValue = spect.get(); - } - else if (opts == "container") { - returnValue = spect.container; - } - else if (opts == "option") { - returnValue = spect.option.apply(spect, args); - } - else if (opts == "destroy") { - spect.destroy(); - $(this).removeData(dataID); - } - else { - method.apply(spect, args); - } - } - }); + function updateUI() { + textInput.removeClass('sp-validation-error'); + + updateHelperLocations(); + + // Update dragger background color (gradients take care of saturation and value). + var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 }); + dragger.css('background-color', flatColor.toHexString()); + + // Get a format that alpha will be included in (hex and names ignore alpha) + var format = currentPreferredFormat; + if (currentAlpha < 1 && !(currentAlpha === 0 && format === 'name')) { + if ( + format === 'hex' || + format === 'hex3' || + format === 'hex6' || + format === 'name' + ) { + format = 'rgb'; + } + } + + var realColor = get({ format: format }), + displayColor = ''; + + //reset background info for preview element + previewElement.removeClass('sp-clear-display'); + previewElement.css('background-color', 'transparent'); + + if (!realColor && allowEmpty) { + // Update the replaced elements background with icon indicating no color selection + previewElement.addClass('sp-clear-display'); + } else { + var realHex = realColor.toHexString(), + realRgb = realColor.toRgbString(); + + // Update the replaced elements background color (with actual selected color) + if (rgbaSupport || realColor.alpha === 1) { + previewElement.css('background-color', realRgb); + } else { + previewElement.css('background-color', 'transparent'); + previewElement.css('filter', realColor.toFilter()); + } + + if (opts.showAlpha) { + var rgb = realColor.toRgb(); + rgb.a = 0; + var realAlpha = tinycolor(rgb).toRgbString(); + var gradient = + 'linear-gradient(left, ' + realAlpha + ', ' + realHex + ')'; + + if (IE) { + alphaSliderInner.css( + 'filter', + tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex) + ); + } else { + alphaSliderInner.css('background', '-webkit-' + gradient); + alphaSliderInner.css('background', '-moz-' + gradient); + alphaSliderInner.css('background', '-ms-' + gradient); + // Use current syntax gradient on unprefixed property. + alphaSliderInner.css( + 'background', + 'linear-gradient(to right, ' + realAlpha + ', ' + realHex + ')' + ); + } + } + + displayColor = realColor.toString(format); + } + + // Update the text entry input as it changes happen + if (opts.showInput) { + textInput.val(displayColor); + } + + if (opts.showPalette) { + drawPalette(); + } + + drawInitial(); + } - return returnValue; - } + function updateHelperLocations() { + var s = currentSaturation; + var v = currentValue; + + if (allowEmpty && isEmpty) { + //if selected color is empty, hide the helpers + alphaSlideHelper.hide(); + slideHelper.hide(); + dragHelper.hide(); + } else { + //make sure helpers are visible + alphaSlideHelper.show(); + slideHelper.show(); + dragHelper.show(); + + // Where to show the little circle in that displays your current selected color + var dragX = s * dragWidth; + var dragY = dragHeight - v * dragHeight; + dragX = Math.max( + -dragHelperHeight, + Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight) + ); + dragY = Math.max( + -dragHelperHeight, + Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight) + ); + dragHelper.css({ + top: dragY + 'px', + left: dragX + 'px' + }); - // Initializing a new instance of spectrum - return this.spectrum("destroy").each(function () { - var options = $.extend({}, opts, $(this).data()); - var spect = spectrum(this, options); - $(this).data(dataID, spect.id); + var alphaX = currentAlpha * alphaWidth; + alphaSlideHelper.css({ + left: alphaX - alphaSlideHelperWidth / 2 + 'px' }); - }; - $.fn.spectrum.load = true; - $.fn.spectrum.loadOpts = {}; - $.fn.spectrum.draggable = draggable; - $.fn.spectrum.defaults = defaultOpts; - $.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() { - if (typeof inputTypeColorSupport._cachedResult === "undefined") { - var colorInput = $("")[0]; // if color element is supported, value will default to not null - inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== ""; - } - return inputTypeColorSupport._cachedResult; - }; + // Where to show the bar that displays your current selected hue + var slideY = currentHue * slideHeight; + slideHelper.css({ + top: slideY - slideHelperHeight + 'px' + }); + } + } - $.spectrum = { }; - $.spectrum.localization = { }; - $.spectrum.palettes = { }; + function updateOriginalInput(fireCallback) { + var color = get(), + displayColor = '', + hasChanged = !tinycolor.equals(color, colorOnShow); + + if (color) { + displayColor = color.toString(currentPreferredFormat); + // Update the selection palette with the current color + addColorToSelectionPalette(color); + } + + if (isInput) { + boundElement.val(displayColor); + } + + if (fireCallback && hasChanged) { + callbacks.change(color); + boundElement.trigger('change', [color]); + } + } - $.fn.spectrum.processNativeColorInputs = function () { - var colorInputs = $("input[type=color]"); - if (colorInputs.length && !inputTypeColorSupport()) { - colorInputs.spectrum({ - preferredFormat: "hex6" - }); + function reflow() { + if (!visible) { + return; // Calculations would be useless and wouldn't be reliable anyways + } + dragWidth = dragger.width(); + dragHeight = dragger.height(); + dragHelperHeight = dragHelper.height(); + slideWidth = slider.width(); + slideHeight = slider.height(); + slideHelperHeight = slideHelper.height(); + alphaWidth = alphaSlider.width(); + alphaSlideHelperWidth = alphaSlideHelper.width(); + + if (!flat) { + container.css('position', 'absolute'); + if (opts.offset) { + container.offset(opts.offset); + } else { + container.offset(getOffset(container, offsetElement)); } - }; - - // TinyColor v1.1.2 - // https://github.com/bgrins/TinyColor - // Brian Grinstead, MIT License + } - //(function() { + updateHelperLocations(); - var trimLeft = /^[\s,#]+/, - trimRight = /\s+$/, - tinyCounter = 0, - math = Math, - mathRound = math.round, - mathMin = math.min, - mathMax = math.max, - mathRandom = math.random; + if (opts.showPalette) { + drawPalette(); + } - var tinycolor = function(color, opts) { + boundElement.trigger('reflow.spectrum'); + } - color = (color) ? color : ''; - opts = opts || { }; + function destroy() { + boundElement.show(); + offsetElement.unbind('click.spectrum touchstart.spectrum'); + container.remove(); + replacer.remove(); + spectrums[spect.id] = null; + } - // If input is already a tinycolor, return itself - if (color instanceof tinycolor) { - return color; - } - // If we are called as a function, call using new instead - if (!(this instanceof tinycolor)) { - return new tinycolor(color, opts); - } + function option(optionName, optionValue) { + if (optionName === undefined) { + return $.extend({}, opts); + } + if (optionValue === undefined) { + return opts[optionName]; + } - var rgb = inputToRGB(color); - this._originalInput = color, - this._r = rgb.r, - this._g = rgb.g, - this._b = rgb.b, - this._a = rgb.a, - this._roundA = mathRound(100*this._a) / 100, - this._format = opts.format || rgb.format; - this._gradientType = opts.gradientType; - - // Don't let the range of [0,255] come back in [0,1]. - // Potentially lose a little bit of precision here, but will fix issues where - // .5 gets interpreted as half of the total, instead of half of 1 - // If it was supposed to be 128, this was already taken care of by `inputToRgb` - if (this._r < 1) { this._r = mathRound(this._r); } - if (this._g < 1) { this._g = mathRound(this._g); } - if (this._b < 1) { this._b = mathRound(this._b); } - - this._ok = rgb.ok; - this._tc_id = tinyCounter++; - }; + opts[optionName] = optionValue; - tinycolor.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 rgb = this.toRgb(); - return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; - }, - setAlpha: function(value) { - this._a = boundAlpha(value); - this._roundA = mathRound(100*this._a) / 100; - return this; - }, - toHsv: function() { - var hsv = rgbToHsv(this._r, this._g, this._b); - return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; - }, - toHsvString: function() { - var hsv = rgbToHsv(this._r, this._g, this._b); - var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100); - return (this._a == 1) ? - "hsv(" + h + ", " + s + "%, " + v + "%)" : - "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")"; - }, - toHsl: function() { - var hsl = rgbToHsl(this._r, this._g, this._b); - return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; - }, - toHslString: function() { - var hsl = rgbToHsl(this._r, this._g, this._b); - var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100); - return (this._a == 1) ? - "hsl(" + h + ", " + s + "%, " + l + "%)" : - "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")"; - }, - toHex: function(allow3Char) { - return rgbToHex(this._r, this._g, this._b, allow3Char); - }, - toHexString: function(allow3Char) { - return '#' + this.toHex(allow3Char); - }, - toHex8: function() { - return rgbaToHex(this._r, this._g, this._b, this._a); - }, - toHex8String: function() { - return '#' + this.toHex8(); - }, - toRgb: function() { - return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; - }, - toRgbString: function() { - return (this._a == 1) ? - "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : - "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; - }, - toPercentageRgb: function() { - return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a }; - }, - toPercentageRgbString: function() { - return (this._a == 1) ? - "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : - "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; - }, - toName: function() { - if (this._a === 0) { - return "transparent"; - } - - if (this._a < 1) { - return false; - } + if (optionName === 'preferredFormat') { + currentPreferredFormat = opts.preferredFormat; + } + applyOptions(); + } - return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; - }, - toFilter: function(secondColor) { - var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a); - var secondHex8String = hex8String; - var gradientType = this._gradientType ? "GradientType = 1, " : ""; + function enable() { + disabled = false; + boundElement.attr('disabled', false); + offsetElement.removeClass('sp-disabled'); + } - if (secondColor) { - var s = tinycolor(secondColor); - secondHex8String = s.toHex8String(); - } + function disable() { + hide(); + disabled = true; + boundElement.attr('disabled', true); + offsetElement.addClass('sp-disabled'); + } - return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; - }, - toString: function(format) { - var formatSet = !!format; - format = format || this._format; - - var formattedString = false; - var hasAlpha = this._a < 1 && this._a >= 0; - var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name"); - - if (needsAlphaFormat) { - // Special case for "transparent", all other non-alpha formats - // will return rgba when there is transparency. - if (format === "name" && this._a === 0) { - return this.toName(); - } - return this.toRgbString(); - } - if (format === "rgb") { - formattedString = this.toRgbString(); - } - if (format === "prgb") { - formattedString = this.toPercentageRgbString(); - } - if (format === "hex" || format === "hex6") { - formattedString = this.toHexString(); - } - if (format === "hex3") { - formattedString = this.toHexString(true); - } - if (format === "hex8") { - formattedString = this.toHex8String(); - } - if (format === "name") { - formattedString = this.toName(); - } - if (format === "hsl") { - formattedString = this.toHslString(); - } - if (format === "hsv") { - formattedString = this.toHsvString(); - } - - return formattedString || this.toHexString(); - }, + function setOffset(coord) { + opts.offset = coord; + reflow(); + } - _applyModification: function(fn, args) { - var color = fn.apply(null, [this].concat([].slice.call(args))); - this._r = color._r; - this._g = color._g; - this._b = color._b; - this.setAlpha(color._a); - return this; - }, - lighten: function() { - return this._applyModification(lighten, arguments); - }, - brighten: function() { - return this._applyModification(brighten, arguments); - }, - darken: function() { - return this._applyModification(darken, arguments); - }, - desaturate: function() { - return this._applyModification(desaturate, arguments); - }, - saturate: function() { - return this._applyModification(saturate, arguments); - }, - greyscale: function() { - return this._applyModification(greyscale, arguments); - }, - spin: function() { - return this._applyModification(spin, arguments); - }, + initialize(); + + var spect = { + show: show, + hide: hide, + toggle: toggle, + reflow: reflow, + option: option, + enable: enable, + disable: disable, + offset: setOffset, + set: function(c) { + set(c); + updateOriginalInput(); + }, + get: get, + destroy: destroy, + container: container + }; - _applyCombination: function(fn, args) { - return fn.apply(null, [this].concat([].slice.call(args))); - }, - analogous: function() { - return this._applyCombination(analogous, arguments); - }, - complement: function() { - return this._applyCombination(complement, arguments); - }, - monochromatic: function() { - return this._applyCombination(monochromatic, arguments); - }, - splitcomplement: function() { - return this._applyCombination(splitcomplement, arguments); - }, - triad: function() { - return this._applyCombination(triad, arguments); - }, - tetrad: function() { - return this._applyCombination(tetrad, arguments); - } + spect.id = spectrums.push(spect) - 1; + + return spect; + } + + /** + * checkOffset - get the offset below/above and left/right element depending on screen position + * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js + */ + function getOffset(picker, input) { + var extraY = 0; + var dpWidth = picker.outerWidth(); + var dpHeight = picker.outerHeight(); + var inputHeight = input.outerHeight(); + var doc = picker[0].ownerDocument; + var docElem = doc.documentElement; + var cW = docElem.clientWidth; + var cH = docElem.clientHeight; + var scL = $(doc).scrollLeft(); + var scT = $(doc).scrollTop(); + var viewWidth = cW + scL; + var viewHeight = cH + scT; + var offset = input.offset(); + + offset.top += inputHeight; + + offset.left -= Math.min( + offset.left, + offset.left + dpWidth > viewWidth && viewWidth > dpWidth + ? Math.abs(offset.left + dpWidth - viewWidth) + : 0 + ); + + offset.top -= Math.min( + offset.top, + offset.top + dpHeight > viewHeight && viewHeight > dpHeight + ? Math.abs(dpHeight + inputHeight - extraY) + : extraY + ); + + return offset; + } + + /** + * noop - do nothing + */ + function noop() {} + + /** + * stopPropagation - makes the code only doing this a little easier to read in line + */ + function stopPropagation(e) { + e.stopPropagation(); + } + + /** + * Create a function bound to a given object + * Thanks to underscore.js + */ + function bind(func, obj) { + var slice = Array.prototype.slice; + var args = slice.call(arguments, 2); + return function() { + return func.apply(obj, args.concat(slice.call(arguments))); }; + } + + /** + * Lightweight drag helper. Handles containment within the element, so that + * when dragging, the x is within [0,element.width] and y is within [0,element.height] + */ + function draggable(element, onmove, onstart, onstop) { + onmove = onmove || function() {}; + onstart = onstart || function() {}; + onstop = onstop || function() {}; + var doc = document; + var dragging = false; + var offset = {}; + var maxHeight = 0; + var maxWidth = 0; + var hasTouch = 'ontouchstart' in window; + + var duringDragEvents = {}; + duringDragEvents['selectstart'] = prevent; + duringDragEvents['dragstart'] = prevent; + duringDragEvents['touchmove mousemove'] = move; + duringDragEvents['touchend mouseup'] = stop; + + function prevent(e) { + if (e.stopPropagation) { + e.stopPropagation(); + } + if (e.preventDefault) { + e.preventDefault(); + } + e.returnValue = false; + } - // If input is an object, force 1 into "1.0" to handle ratios properly - // String input requires "1.0" as input, so 1 will be treated as 1 - tinycolor.fromRatio = function(color, opts) { - if (typeof color == "object") { - var newColor = {}; - for (var i in color) { - if (color.hasOwnProperty(i)) { - if (i === "a") { - newColor[i] = color[i]; - } - else { - newColor[i] = convertToPercentage(color[i]); - } - } - } - color = newColor; + function move(e) { + if (dragging) { + // Mouseup happened outside of window + if (IE && doc.documentMode < 9 && !e.button) { + return stop(); } - return tinycolor(color, opts); - }; + var t0 = + e.originalEvent && + e.originalEvent.touches && + e.originalEvent.touches[0]; + var pageX = (t0 && t0.pageX) || e.pageX; + var pageY = (t0 && t0.pageY) || e.pageY; - // Given a string or object, convert that input to RGB - // Possible string inputs: - // - // "red" - // "#f00" or "f00" - // "#ff0000" or "ff0000" - // "#ff000000" or "ff000000" - // "rgb 255 0 0" or "rgb (255, 0, 0)" - // "rgb 1.0 0 0" or "rgb (1, 0, 0)" - // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" - // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" - // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" - // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" - // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" - // - function inputToRGB(color) { - - var rgb = { r: 0, g: 0, b: 0 }; - var a = 1; - var ok = false; - var format = false; - - if (typeof color == "string") { - color = stringInputToObject(color); - } + var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth)); + var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight)); - if (typeof color == "object") { - if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) { - rgb = rgbToRgb(color.r, color.g, color.b); - ok = true; - format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; - } - else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) { - color.s = convertToPercentage(color.s); - color.v = convertToPercentage(color.v); - rgb = hsvToRgb(color.h, color.s, color.v); - ok = true; - format = "hsv"; - } - else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) { - color.s = convertToPercentage(color.s); - color.l = convertToPercentage(color.l); - rgb = hslToRgb(color.h, color.s, color.l); - ok = true; - format = "hsl"; - } - - if (color.hasOwnProperty("a")) { - a = color.a; - } + if (hasTouch) { + // Stop scrolling in iOS + prevent(e); } - a = boundAlpha(a); - - return { - ok: ok, - format: color.format || format, - r: mathMin(255, mathMax(rgb.r, 0)), - g: mathMin(255, mathMax(rgb.g, 0)), - b: mathMin(255, mathMax(rgb.b, 0)), - a: a - }; + onmove.apply(element, [dragX, dragY, e]); + } } + function start(e) { + var rightclick = e.which ? e.which == 3 : e.button == 2; - // Conversion Functions - // -------------------- + if (!rightclick && !dragging) { + if (onstart.apply(element, arguments) !== false) { + dragging = true; + maxHeight = $(element).height(); + maxWidth = $(element).width(); + offset = $(element).offset(); - // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: - // - - // `rgbToRgb` - // Handle bounds / percentage checking to conform to CSS color spec - // - // *Assumes:* r, g, b in [0, 255] or [0, 1] - // *Returns:* { r, g, b } in [0, 255] - function rgbToRgb(r, g, b){ - return { - r: bound01(r, 255) * 255, - g: bound01(g, 255) * 255, - b: bound01(b, 255) * 255 - }; - } + $(doc).bind(duringDragEvents); + $(doc.body).addClass('sp-dragging'); - // `rgbToHsl` - // Converts an RGB color value to HSL. - // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] - // *Returns:* { h, s, l } in [0,1] - function rgbToHsl(r, g, b) { + move(e); - r = bound01(r, 255); - g = bound01(g, 255); - b = bound01(b, 255); - - var max = mathMax(r, g, b), min = mathMin(r, g, b); - var h, s, l = (max + min) / 2; - - if(max == min) { - h = s = 0; // achromatic - } - else { - var d = max - min; - s = l > 0.5 ? d / (2 - max - min) : d / (max + min); - switch(max) { - case r: h = (g - b) / d + (g < b ? 6 : 0); break; - case g: h = (b - r) / d + 2; break; - case b: h = (r - g) / d + 4; break; - } - - h /= 6; + prevent(e); } - - return { h: h, s: s, l: l }; + } } - // `hslToRgb` - // Converts an HSL color value to RGB. - // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] - // *Returns:* { r, g, b } in the set [0, 255] - function hslToRgb(h, s, l) { - var r, g, b; - - h = bound01(h, 360); - s = bound01(s, 100); - l = bound01(l, 100); - - function hue2rgb(p, q, t) { - if(t < 0) t += 1; - if(t > 1) t -= 1; - if(t < 1/6) return p + (q - p) * 6 * t; - if(t < 1/2) return q; - if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; - return p; - } - - if(s === 0) { - r = g = b = l; // achromatic - } - else { - var q = l < 0.5 ? l * (1 + s) : l + s - l * s; - var p = 2 * l - q; - r = hue2rgb(p, q, h + 1/3); - g = hue2rgb(p, q, h); - b = hue2rgb(p, q, h - 1/3); - } - - return { r: r * 255, g: g * 255, b: b * 255 }; + function stop() { + if (dragging) { + $(doc).unbind(duringDragEvents); + $(doc.body).removeClass('sp-dragging'); + + // Wait a tick before notifying observers to allow the click event + // to fire in Chrome. + setTimeout(function() { + onstop.apply(element, arguments); + }, 0); + } + dragging = false; } - // `rgbToHsv` - // Converts an RGB color value to HSV - // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] - // *Returns:* { h, s, v } in [0,1] - function rgbToHsv(r, g, b) { - - r = bound01(r, 255); - g = bound01(g, 255); - b = bound01(b, 255); - - var max = mathMax(r, g, b), min = mathMin(r, g, b); - var h, s, v = max; - - var d = max - min; - s = max === 0 ? 0 : d / max; + $(element).bind('touchstart mousedown', start); + } + + function throttle(func, wait, debounce) { + var timeout; + return function() { + var context = this, + args = arguments; + var throttler = function() { + timeout = null; + func.apply(context, args); + }; + if (debounce) clearTimeout(timeout); + if (debounce || !timeout) timeout = setTimeout(throttler, wait); + }; + } + + function inputTypeColorSupport() { + return $.fn.spectrum.inputTypeColorSupport(); + } + + /** + * Define a jQuery plugin + */ + var dataID = 'spectrum.id'; + $.fn.spectrum = function(opts, extra) { + if (typeof opts == 'string') { + var returnValue = this; + var args = Array.prototype.slice.call(arguments, 1); + + this.each(function() { + var spect = spectrums[$(this).data(dataID)]; + if (spect) { + var method = spect[opts]; + if (!method) { + throw new Error("Spectrum: no such method: '" + opts + "'"); + } + + if (opts == 'get') { + returnValue = spect.get(); + } else if (opts == 'container') { + returnValue = spect.container; + } else if (opts == 'option') { + returnValue = spect.option.apply(spect, args); + } else if (opts == 'destroy') { + spect.destroy(); + $(this).removeData(dataID); + } else { + method.apply(spect, args); + } + } + }); + + return returnValue; + } - if(max == min) { - h = 0; // achromatic - } - else { - switch(max) { - case r: h = (g - b) / d + (g < b ? 6 : 0); break; - case g: h = (b - r) / d + 2; break; - case b: h = (r - g) / d + 4; break; - } - h /= 6; - } - return { h: h, s: s, v: v }; - } - - // `hsvToRgb` - // Converts an HSV color value to RGB. - // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] - // *Returns:* { r, g, b } in the set [0, 255] - function hsvToRgb(h, s, v) { - - h = bound01(h, 360) * 6; - s = bound01(s, 100); - v = bound01(v, 100); - - var i = math.floor(h), - f = h - i, - p = v * (1 - s), - q = v * (1 - f * s), - t = v * (1 - (1 - f) * s), - mod = i % 6, - r = [v, q, p, p, t, v][mod], - g = [t, v, v, q, p, p][mod], - b = [p, p, t, v, v, q][mod]; - - return { r: r * 255, g: g * 255, b: b * 255 }; - } - - // `rgbToHex` - // Converts an RGB color to hex - // Assumes r, g, and b are contained in the set [0, 255] - // Returns a 3 or 6 character hex - function rgbToHex(r, g, b, allow3Char) { - - var hex = [ - pad2(mathRound(r).toString(16)), - pad2(mathRound(g).toString(16)), - pad2(mathRound(b).toString(16)) - ]; - - // Return a 3 character hex if possible - if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { - return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); - } + // Initializing a new instance of spectrum + return this.spectrum('destroy').each(function() { + var options = $.extend({}, opts, $(this).data()); + var spect = spectrum(this, options); + $(this).data(dataID, spect.id); + }); + }; + + $.fn.spectrum.load = true; + $.fn.spectrum.loadOpts = {}; + $.fn.spectrum.draggable = draggable; + $.fn.spectrum.defaults = defaultOpts; + $.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() { + if (typeof inputTypeColorSupport._cachedResult === 'undefined') { + var colorInput = $("")[0]; // if color element is supported, value will default to not null + inputTypeColorSupport._cachedResult = + colorInput.type === 'color' && colorInput.value !== ''; + } + return inputTypeColorSupport._cachedResult; + }; + + $.spectrum = {}; + $.spectrum.localization = {}; + $.spectrum.palettes = {}; + + $.fn.spectrum.processNativeColorInputs = function() { + var colorInputs = $('input[type=color]'); + if (colorInputs.length && !inputTypeColorSupport()) { + colorInputs.spectrum({ + preferredFormat: 'hex6' + }); + } + }; + + // TinyColor v1.1.2 + // https://github.com/bgrins/TinyColor + // Brian Grinstead, MIT License + + //(function() { + + var trimLeft = /^[\s,#]+/, + trimRight = /\s+$/, + tinyCounter = 0, + math = Math, + mathRound = math.round, + mathMin = math.min, + mathMax = math.max, + mathRandom = math.random; + + var tinycolor = function(color, opts) { + color = color ? color : ''; + opts = opts || {}; + + // If input is already a tinycolor, return itself + if (color instanceof tinycolor) { + return color; + } + // If we are called as a function, call using new instead + if (!(this instanceof tinycolor)) { + return new tinycolor(color, opts); + } - return hex.join(""); + var rgb = inputToRGB(color); + (this._originalInput = color), + (this._r = rgb.r), + (this._g = rgb.g), + (this._b = rgb.b), + (this._a = rgb.a), + (this._roundA = mathRound(100 * this._a) / 100), + (this._format = opts.format || rgb.format); + this._gradientType = opts.gradientType; + + // Don't let the range of [0,255] come back in [0,1]. + // Potentially lose a little bit of precision here, but will fix issues where + // .5 gets interpreted as half of the total, instead of half of 1 + // If it was supposed to be 128, this was already taken care of by `inputToRgb` + if (this._r < 1) { + this._r = mathRound(this._r); + } + if (this._g < 1) { + this._g = mathRound(this._g); + } + if (this._b < 1) { + this._b = mathRound(this._b); } - // `rgbaToHex` - // Converts an RGBA color plus alpha transparency to hex - // Assumes r, g, b and a are contained in the set [0, 255] - // Returns an 8 character hex - function rgbaToHex(r, g, b, a) { - var hex = [ - pad2(convertDecimalToHex(a)), - pad2(mathRound(r).toString(16)), - pad2(mathRound(g).toString(16)), - pad2(mathRound(b).toString(16)) - ]; + this._ok = rgb.ok; + this._tc_id = tinyCounter++; + }; - return hex.join(""); - } + tinycolor.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 rgb = this.toRgb(); + return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; + }, + setAlpha: function(value) { + this._a = boundAlpha(value); + this._roundA = mathRound(100 * this._a) / 100; + return this; + }, + toHsv: function() { + var hsv = rgbToHsv(this._r, this._g, this._b); + return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; + }, + toHsvString: function() { + var hsv = rgbToHsv(this._r, this._g, this._b); + var h = mathRound(hsv.h * 360), + s = mathRound(hsv.s * 100), + v = mathRound(hsv.v * 100); + return this._a == 1 + ? 'hsv(' + h + ', ' + s + '%, ' + v + '%)' + : 'hsva(' + h + ', ' + s + '%, ' + v + '%, ' + this._roundA + ')'; + }, + toHsl: function() { + var hsl = rgbToHsl(this._r, this._g, this._b); + return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; + }, + toHslString: function() { + var hsl = rgbToHsl(this._r, this._g, this._b); + var h = mathRound(hsl.h * 360), + s = mathRound(hsl.s * 100), + l = mathRound(hsl.l * 100); + return this._a == 1 + ? 'hsl(' + h + ', ' + s + '%, ' + l + '%)' + : 'hsla(' + h + ', ' + s + '%, ' + l + '%, ' + this._roundA + ')'; + }, + toHex: function(allow3Char) { + return rgbToHex(this._r, this._g, this._b, allow3Char); + }, + toHexString: function(allow3Char) { + return '#' + this.toHex(allow3Char); + }, + toHex8: function() { + return rgbaToHex(this._r, this._g, this._b, this._a); + }, + toHex8String: function() { + return '#' + this.toHex8(); + }, + toRgb: function() { + return { + r: mathRound(this._r), + g: mathRound(this._g), + b: mathRound(this._b), + a: this._a + }; + }, + toRgbString: function() { + return this._a == 1 + ? 'rgb(' + + mathRound(this._r) + + ', ' + + mathRound(this._g) + + ', ' + + mathRound(this._b) + + ')' + : 'rgba(' + + mathRound(this._r) + + ', ' + + mathRound(this._g) + + ', ' + + mathRound(this._b) + + ', ' + + this._roundA + + ')'; + }, + toPercentageRgb: function() { + return { + r: mathRound(bound01(this._r, 255) * 100) + '%', + g: mathRound(bound01(this._g, 255) * 100) + '%', + b: mathRound(bound01(this._b, 255) * 100) + '%', + a: this._a + }; + }, + toPercentageRgbString: function() { + return this._a == 1 + ? 'rgb(' + + mathRound(bound01(this._r, 255) * 100) + + '%, ' + + mathRound(bound01(this._g, 255) * 100) + + '%, ' + + mathRound(bound01(this._b, 255) * 100) + + '%)' + : 'rgba(' + + mathRound(bound01(this._r, 255) * 100) + + '%, ' + + mathRound(bound01(this._g, 255) * 100) + + '%, ' + + mathRound(bound01(this._b, 255) * 100) + + '%, ' + + this._roundA + + ')'; + }, + toName: function() { + if (this._a === 0) { + return 'transparent'; + } - // `equals` - // Can be called with any tinycolor input - tinycolor.equals = function (color1, color2) { - if (!color1 || !color2) { return false; } - return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); - }; - tinycolor.random = function() { - return tinycolor.fromRatio({ - r: mathRandom(), - g: mathRandom(), - b: mathRandom() - }); - }; + if (this._a < 1) { + return false; + } + return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; + }, + toFilter: function(secondColor) { + var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a); + var secondHex8String = hex8String; + var gradientType = this._gradientType ? 'GradientType = 1, ' : ''; + + if (secondColor) { + var s = tinycolor(secondColor); + secondHex8String = s.toHex8String(); + } + + return ( + 'progid:DXImageTransform.Microsoft.gradient(' + + gradientType + + 'startColorstr=' + + hex8String + + ',endColorstr=' + + secondHex8String + + ')' + ); + }, + toString: function(format) { + var formatSet = !!format; + format = format || this._format; + + var formattedString = false; + var hasAlpha = this._a < 1 && this._a >= 0; + var needsAlphaFormat = + !formatSet && + hasAlpha && + (format === 'hex' || + format === 'hex6' || + format === 'hex3' || + format === 'name'); + + if (needsAlphaFormat) { + // Special case for "transparent", all other non-alpha formats + // will return rgba when there is transparency. + if (format === 'name' && this._a === 0) { + return this.toName(); + } + return this.toRgbString(); + } + if (format === 'rgb') { + formattedString = this.toRgbString(); + } + if (format === 'prgb') { + formattedString = this.toPercentageRgbString(); + } + if (format === 'hex' || format === 'hex6') { + formattedString = this.toHexString(); + } + if (format === 'hex3') { + formattedString = this.toHexString(true); + } + if (format === 'hex8') { + formattedString = this.toHex8String(); + } + if (format === 'name') { + formattedString = this.toName(); + } + if (format === 'hsl') { + formattedString = this.toHslString(); + } + if (format === 'hsv') { + formattedString = this.toHsvString(); + } + + return formattedString || this.toHexString(); + }, - // Modification Functions - // ---------------------- - // Thanks to less.js for some of the basics here - // + _applyModification: function(fn, args) { + var color = fn.apply(null, [this].concat([].slice.call(args))); + this._r = color._r; + this._g = color._g; + this._b = color._b; + this.setAlpha(color._a); + return this; + }, + lighten: function() { + return this._applyModification(lighten, arguments); + }, + brighten: function() { + return this._applyModification(brighten, arguments); + }, + darken: function() { + return this._applyModification(darken, arguments); + }, + desaturate: function() { + return this._applyModification(desaturate, arguments); + }, + saturate: function() { + return this._applyModification(saturate, arguments); + }, + greyscale: function() { + return this._applyModification(greyscale, arguments); + }, + spin: function() { + return this._applyModification(spin, arguments); + }, - function desaturate(color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var hsl = tinycolor(color).toHsl(); - hsl.s -= amount / 100; - hsl.s = clamp01(hsl.s); - return tinycolor(hsl); + _applyCombination: function(fn, args) { + return fn.apply(null, [this].concat([].slice.call(args))); + }, + analogous: function() { + return this._applyCombination(analogous, arguments); + }, + complement: function() { + return this._applyCombination(complement, arguments); + }, + monochromatic: function() { + return this._applyCombination(monochromatic, arguments); + }, + splitcomplement: function() { + return this._applyCombination(splitcomplement, arguments); + }, + triad: function() { + return this._applyCombination(triad, arguments); + }, + tetrad: function() { + return this._applyCombination(tetrad, arguments); } - - function saturate(color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var hsl = tinycolor(color).toHsl(); - hsl.s += amount / 100; - hsl.s = clamp01(hsl.s); - return tinycolor(hsl); + }; + + // If input is an object, force 1 into "1.0" to handle ratios properly + // String input requires "1.0" as input, so 1 will be treated as 1 + tinycolor.fromRatio = function(color, opts) { + if (typeof color == 'object') { + var newColor = {}; + for (var i in color) { + if (color.hasOwnProperty(i)) { + if (i === 'a') { + newColor[i] = color[i]; + } else { + newColor[i] = convertToPercentage(color[i]); + } + } + } + color = newColor; } - function greyscale(color) { - return tinycolor(color).desaturate(100); + return tinycolor(color, opts); + }; + + // Given a string or object, convert that input to RGB + // Possible string inputs: + // + // "red" + // "#f00" or "f00" + // "#ff0000" or "ff0000" + // "#ff000000" or "ff000000" + // "rgb 255 0 0" or "rgb (255, 0, 0)" + // "rgb 1.0 0 0" or "rgb (1, 0, 0)" + // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" + // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" + // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" + // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" + // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" + // + function inputToRGB(color) { + var rgb = { r: 0, g: 0, b: 0 }; + var a = 1; + var ok = false; + var format = false; + + if (typeof color == 'string') { + color = stringInputToObject(color); } - function lighten (color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var hsl = tinycolor(color).toHsl(); - hsl.l += amount / 100; - hsl.l = clamp01(hsl.l); - return tinycolor(hsl); + if (typeof color == 'object') { + if ( + color.hasOwnProperty('r') && + color.hasOwnProperty('g') && + color.hasOwnProperty('b') + ) { + rgb = rgbToRgb(color.r, color.g, color.b); + ok = true; + format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb'; + } else if ( + color.hasOwnProperty('h') && + color.hasOwnProperty('s') && + color.hasOwnProperty('v') + ) { + color.s = convertToPercentage(color.s); + color.v = convertToPercentage(color.v); + rgb = hsvToRgb(color.h, color.s, color.v); + ok = true; + format = 'hsv'; + } else if ( + color.hasOwnProperty('h') && + color.hasOwnProperty('s') && + color.hasOwnProperty('l') + ) { + color.s = convertToPercentage(color.s); + color.l = convertToPercentage(color.l); + rgb = hslToRgb(color.h, color.s, color.l); + ok = true; + format = 'hsl'; + } + + if (color.hasOwnProperty('a')) { + a = color.a; + } } - function brighten(color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var rgb = tinycolor(color).toRgb(); - rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100)))); - rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100)))); - rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100)))); - return tinycolor(rgb); - } + a = boundAlpha(a); - function darken (color, amount) { - amount = (amount === 0) ? 0 : (amount || 10); - var hsl = tinycolor(color).toHsl(); - hsl.l -= amount / 100; - hsl.l = clamp01(hsl.l); - return tinycolor(hsl); + return { + ok: ok, + format: color.format || format, + r: mathMin(255, mathMax(rgb.r, 0)), + g: mathMin(255, mathMax(rgb.g, 0)), + b: mathMin(255, mathMax(rgb.b, 0)), + a: a + }; + } + + // Conversion Functions + // -------------------- + + // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: + // + + // `rgbToRgb` + // Handle bounds / percentage checking to conform to CSS color spec + // + // *Assumes:* r, g, b in [0, 255] or [0, 1] + // *Returns:* { r, g, b } in [0, 255] + function rgbToRgb(r, g, b) { + return { + r: bound01(r, 255) * 255, + g: bound01(g, 255) * 255, + b: bound01(b, 255) * 255 + }; + } + + // `rgbToHsl` + // Converts an RGB color value to HSL. + // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] + // *Returns:* { h, s, l } in [0,1] + function rgbToHsl(r, g, b) { + r = bound01(r, 255); + g = bound01(g, 255); + b = bound01(b, 255); + + var max = mathMax(r, g, b), + min = mathMin(r, g, b); + var h, + s, + l = (max + min) / 2; + + if (max == min) { + h = s = 0; // achromatic + } else { + var d = max - min; + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + switch (max) { + case r: + h = (g - b) / d + (g < b ? 6 : 0); + break; + case g: + h = (b - r) / d + 2; + break; + case b: + h = (r - g) / d + 4; + break; + } + + h /= 6; } - // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. - // Values outside of this range will be wrapped into this range. - function spin(color, amount) { - var hsl = tinycolor(color).toHsl(); - var hue = (mathRound(hsl.h) + amount) % 360; - hsl.h = hue < 0 ? 360 + hue : hue; - return tinycolor(hsl); + return { h: h, s: s, l: l }; + } + + // `hslToRgb` + // Converts an HSL color value to RGB. + // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] + // *Returns:* { r, g, b } in the set [0, 255] + function hslToRgb(h, s, l) { + var r, g, b; + + h = bound01(h, 360); + s = bound01(s, 100); + l = bound01(l, 100); + + function hue2rgb(p, q, t) { + if (t < 0) t += 1; + if (t > 1) t -= 1; + if (t < 1 / 6) return p + (q - p) * 6 * t; + if (t < 1 / 2) return q; + if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; + return p; } - // Combination Functions - // --------------------- - // Thanks to jQuery xColor for some of the ideas behind these - // - - function complement(color) { - var hsl = tinycolor(color).toHsl(); - hsl.h = (hsl.h + 180) % 360; - return tinycolor(hsl); + if (s === 0) { + r = g = b = l; // achromatic + } else { + var q = l < 0.5 ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + r = hue2rgb(p, q, h + 1 / 3); + g = hue2rgb(p, q, h); + b = hue2rgb(p, q, h - 1 / 3); } - function triad(color) { - var hsl = tinycolor(color).toHsl(); - var h = hsl.h; - return [ - tinycolor(color), - tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), - tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) - ]; + return { r: r * 255, g: g * 255, b: b * 255 }; + } + + // `rgbToHsv` + // Converts an RGB color value to HSV + // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] + // *Returns:* { h, s, v } in [0,1] + function rgbToHsv(r, g, b) { + r = bound01(r, 255); + g = bound01(g, 255); + b = bound01(b, 255); + + var max = mathMax(r, g, b), + min = mathMin(r, g, b); + var h, + s, + v = max; + + var d = max - min; + s = max === 0 ? 0 : d / max; + + if (max == min) { + h = 0; // achromatic + } else { + switch (max) { + case r: + h = (g - b) / d + (g < b ? 6 : 0); + break; + case g: + h = (b - r) / d + 2; + break; + case b: + h = (r - g) / d + 4; + break; + } + h /= 6; } - - function tetrad(color) { - var hsl = tinycolor(color).toHsl(); - var h = hsl.h; - return [ - tinycolor(color), - tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), - tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), - tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) - ]; + return { h: h, s: s, v: v }; + } + + // `hsvToRgb` + // Converts an HSV color value to RGB. + // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] + // *Returns:* { r, g, b } in the set [0, 255] + function hsvToRgb(h, s, v) { + h = bound01(h, 360) * 6; + s = bound01(s, 100); + v = bound01(v, 100); + + var i = math.floor(h), + f = h - i, + p = v * (1 - s), + q = v * (1 - f * s), + t = v * (1 - (1 - f) * s), + mod = i % 6, + r = [v, q, p, p, t, v][mod], + g = [t, v, v, q, p, p][mod], + b = [p, p, t, v, v, q][mod]; + + return { r: r * 255, g: g * 255, b: b * 255 }; + } + + // `rgbToHex` + // Converts an RGB color to hex + // Assumes r, g, and b are contained in the set [0, 255] + // Returns a 3 or 6 character hex + function rgbToHex(r, g, b, allow3Char) { + var hex = [ + pad2(mathRound(r).toString(16)), + pad2(mathRound(g).toString(16)), + pad2(mathRound(b).toString(16)) + ]; + + // Return a 3 character hex if possible + if ( + allow3Char && + hex[0].charAt(0) == hex[0].charAt(1) && + hex[1].charAt(0) == hex[1].charAt(1) && + hex[2].charAt(0) == hex[2].charAt(1) + ) { + return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); } - function splitcomplement(color) { - var hsl = tinycolor(color).toHsl(); - var h = hsl.h; - return [ - tinycolor(color), - tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}), - tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l}) - ]; - } - - function analogous(color, results, slices) { - results = results || 6; - slices = slices || 30; - - var hsl = tinycolor(color).toHsl(); - var part = 360 / slices; - var ret = [tinycolor(color)]; - - for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) { - hsl.h = (hsl.h + part) % 360; - ret.push(tinycolor(hsl)); - } - return ret; + return hex.join(''); + } + // `rgbaToHex` + // Converts an RGBA color plus alpha transparency to hex + // Assumes r, g, b and a are contained in the set [0, 255] + // Returns an 8 character hex + function rgbaToHex(r, g, b, a) { + var hex = [ + pad2(convertDecimalToHex(a)), + pad2(mathRound(r).toString(16)), + pad2(mathRound(g).toString(16)), + pad2(mathRound(b).toString(16)) + ]; + + return hex.join(''); + } + + // `equals` + // Can be called with any tinycolor input + tinycolor.equals = function(color1, color2) { + if (!color1 || !color2) { + return false; } - - function monochromatic(color, results) { - results = results || 6; - var hsv = tinycolor(color).toHsv(); - var h = hsv.h, s = hsv.s, v = hsv.v; - var ret = []; - var modification = 1 / results; - - while (results--) { - ret.push(tinycolor({ h: h, s: s, v: v})); - v = (v + modification) % 1; - } - - return ret; + return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); + }; + tinycolor.random = function() { + return tinycolor.fromRatio({ + r: mathRandom(), + g: mathRandom(), + b: mathRandom() + }); + }; + + // Modification Functions + // ---------------------- + // Thanks to less.js for some of the basics here + // + + function desaturate(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var hsl = tinycolor(color).toHsl(); + hsl.s -= amount / 100; + hsl.s = clamp01(hsl.s); + return tinycolor(hsl); + } + + function saturate(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var hsl = tinycolor(color).toHsl(); + hsl.s += amount / 100; + hsl.s = clamp01(hsl.s); + return tinycolor(hsl); + } + + function greyscale(color) { + return tinycolor(color).desaturate(100); + } + + function lighten(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var hsl = tinycolor(color).toHsl(); + hsl.l += amount / 100; + hsl.l = clamp01(hsl.l); + return tinycolor(hsl); + } + + function brighten(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var rgb = tinycolor(color).toRgb(); + rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * -(amount / 100)))); + rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * -(amount / 100)))); + rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * -(amount / 100)))); + return tinycolor(rgb); + } + + function darken(color, amount) { + amount = amount === 0 ? 0 : amount || 10; + var hsl = tinycolor(color).toHsl(); + hsl.l -= amount / 100; + hsl.l = clamp01(hsl.l); + return tinycolor(hsl); + } + + // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. + // Values outside of this range will be wrapped into this range. + function spin(color, amount) { + var hsl = tinycolor(color).toHsl(); + var hue = (mathRound(hsl.h) + amount) % 360; + hsl.h = hue < 0 ? 360 + hue : hue; + return tinycolor(hsl); + } + + // Combination Functions + // --------------------- + // Thanks to jQuery xColor for some of the ideas behind these + // + + function complement(color) { + var hsl = tinycolor(color).toHsl(); + hsl.h = (hsl.h + 180) % 360; + return tinycolor(hsl); + } + + function triad(color) { + var hsl = tinycolor(color).toHsl(); + var h = hsl.h; + return [ + tinycolor(color), + tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), + tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) + ]; + } + + function tetrad(color) { + var hsl = tinycolor(color).toHsl(); + var h = hsl.h; + return [ + tinycolor(color), + tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), + tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), + tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) + ]; + } + + function splitcomplement(color) { + var hsl = tinycolor(color).toHsl(); + var h = hsl.h; + return [ + tinycolor(color), + tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }), + tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l }) + ]; + } + + function analogous(color, results, slices) { + results = results || 6; + slices = slices || 30; + + var hsl = tinycolor(color).toHsl(); + var part = 360 / slices; + var ret = [tinycolor(color)]; + + for (hsl.h = (hsl.h - ((part * results) >> 1) + 720) % 360; --results; ) { + hsl.h = (hsl.h + part) % 360; + ret.push(tinycolor(hsl)); + } + return ret; + } + + function monochromatic(color, results) { + results = results || 6; + var hsv = tinycolor(color).toHsv(); + var h = hsv.h, + s = hsv.s, + v = hsv.v; + var ret = []; + var modification = 1 / results; + + while (results--) { + ret.push(tinycolor({ h: h, s: s, v: v })); + v = (v + modification) % 1; } - // Utility Functions - // --------------------- - - tinycolor.mix = function(color1, color2, amount) { - amount = (amount === 0) ? 0 : (amount || 50); - - var rgb1 = tinycolor(color1).toRgb(); - var rgb2 = tinycolor(color2).toRgb(); - - var p = amount / 100; - var w = p * 2 - 1; - var a = rgb2.a - rgb1.a; - - var w1; - - if (w * a == -1) { - w1 = w; - } else { - w1 = (w + a) / (1 + w * a); - } + return ret; + } - w1 = (w1 + 1) / 2; + // Utility Functions + // --------------------- - var w2 = 1 - w1; + tinycolor.mix = function(color1, color2, amount) { + amount = amount === 0 ? 0 : amount || 50; - var rgba = { - r: rgb2.r * w1 + rgb1.r * w2, - g: rgb2.g * w1 + rgb1.g * w2, - b: rgb2.b * w1 + rgb1.b * w2, - a: rgb2.a * p + rgb1.a * (1 - p) - }; + var rgb1 = tinycolor(color1).toRgb(); + var rgb2 = tinycolor(color2).toRgb(); - return tinycolor(rgba); - }; + var p = amount / 100; + var w = p * 2 - 1; + var a = rgb2.a - rgb1.a; + var w1; - // Readability Functions - // --------------------- - // - - // `readability` - // Analyze the 2 colors and returns an object with the following properties: - // `brightness`: difference in brightness between the two colors - // `color`: difference in color/hue between the two colors - tinycolor.readability = function(color1, color2) { - var c1 = tinycolor(color1); - var c2 = tinycolor(color2); - var rgb1 = c1.toRgb(); - var rgb2 = c2.toRgb(); - var brightnessA = c1.getBrightness(); - var brightnessB = c2.getBrightness(); - var colorDiff = ( - Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) + - Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) + - Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b) - ); + if (w * a == -1) { + w1 = w; + } else { + w1 = (w + a) / (1 + w * a); + } - return { - brightness: Math.abs(brightnessA - brightnessB), - color: colorDiff - }; - }; + w1 = (w1 + 1) / 2; - // `readable` - // http://www.w3.org/TR/AERT#color-contrast - // Ensure that foreground and background color combinations provide sufficient contrast. - // *Example* - // tinycolor.isReadable("#000", "#111") => false - tinycolor.isReadable = function(color1, color2) { - var readability = tinycolor.readability(color1, color2); - return readability.brightness > 125 && readability.color > 500; - }; + var w2 = 1 - w1; - // `mostReadable` - // Given a base color and a list of possible foreground or background - // colors for that base, returns the most readable color. - // *Example* - // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000" - tinycolor.mostReadable = function(baseColor, colorList) { - var bestColor = null; - var bestScore = 0; - var bestIsReadable = false; - for (var i=0; i < colorList.length; i++) { - - // We normalize both around the "acceptable" breaking point, - // but rank brightness constrast higher than hue. - - var readability = tinycolor.readability(baseColor, colorList[i]); - var readable = readability.brightness > 125 && readability.color > 500; - var score = 3 * (readability.brightness / 125) + (readability.color / 500); - - if ((readable && ! bestIsReadable) || - (readable && bestIsReadable && score > bestScore) || - ((! readable) && (! bestIsReadable) && score > bestScore)) { - bestIsReadable = readable; - bestScore = score; - bestColor = tinycolor(colorList[i]); - } - } - return bestColor; + var rgba = { + r: rgb2.r * w1 + rgb1.r * w2, + g: rgb2.g * w1 + rgb1.g * w2, + b: rgb2.b * w1 + rgb1.b * w2, + a: rgb2.a * p + rgb1.a * (1 - p) }; - - // Big List of Colors - // ------------------ - // - var names = tinycolor.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" + return tinycolor(rgba); + }; + + // Readability Functions + // --------------------- + // + + // `readability` + // Analyze the 2 colors and returns an object with the following properties: + // `brightness`: difference in brightness between the two colors + // `color`: difference in color/hue between the two colors + tinycolor.readability = function(color1, color2) { + var c1 = tinycolor(color1); + var c2 = tinycolor(color2); + var rgb1 = c1.toRgb(); + var rgb2 = c2.toRgb(); + var brightnessA = c1.getBrightness(); + var brightnessB = c2.getBrightness(); + var colorDiff = + Math.max(rgb1.r, rgb2.r) - + Math.min(rgb1.r, rgb2.r) + + Math.max(rgb1.g, rgb2.g) - + Math.min(rgb1.g, rgb2.g) + + Math.max(rgb1.b, rgb2.b) - + Math.min(rgb1.b, rgb2.b); + + return { + brightness: Math.abs(brightnessA - brightnessB), + color: colorDiff }; - - // Make it easy to access colors via `hexNames[hex]` - var hexNames = tinycolor.hexNames = flip(names); - - - // Utilities - // --------- - - // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` - function flip(o) { - var flipped = { }; - for (var i in o) { - if (o.hasOwnProperty(i)) { - flipped[o[i]] = i; - } - } - return flipped; + }; + + // `readable` + // http://www.w3.org/TR/AERT#color-contrast + // Ensure that foreground and background color combinations provide sufficient contrast. + // *Example* + // tinycolor.isReadable("#000", "#111") => false + tinycolor.isReadable = function(color1, color2) { + var readability = tinycolor.readability(color1, color2); + return readability.brightness > 125 && readability.color > 500; + }; + + // `mostReadable` + // Given a base color and a list of possible foreground or background + // colors for that base, returns the most readable color. + // *Example* + // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000" + tinycolor.mostReadable = function(baseColor, colorList) { + var bestColor = null; + var bestScore = 0; + var bestIsReadable = false; + for (var i = 0; i < colorList.length; i++) { + // We normalize both around the "acceptable" breaking point, + // but rank brightness constrast higher than hue. + + var readability = tinycolor.readability(baseColor, colorList[i]); + var readable = readability.brightness > 125 && readability.color > 500; + var score = 3 * (readability.brightness / 125) + readability.color / 500; + + if ( + (readable && !bestIsReadable) || + (readable && bestIsReadable && score > bestScore) || + (!readable && !bestIsReadable && score > bestScore) + ) { + bestIsReadable = readable; + bestScore = score; + bestColor = tinycolor(colorList[i]); + } } + return bestColor; + }; + + // Big List of Colors + // ------------------ + // + var names = (tinycolor.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' + }); + + // Make it easy to access colors via `hexNames[hex]` + var hexNames = (tinycolor.hexNames = flip(names)); + + // Utilities + // --------- + + // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` + function flip(o) { + var flipped = {}; + for (var i in o) { + if (o.hasOwnProperty(i)) { + flipped[o[i]] = i; + } + } + return flipped; + } - // Return a valid alpha value [0,1] with all invalid values being set to 1 - function boundAlpha(a) { - a = parseFloat(a); + // Return a valid alpha value [0,1] with all invalid values being set to 1 + function boundAlpha(a) { + a = parseFloat(a); - if (isNaN(a) || a < 0 || a > 1) { - a = 1; - } - - return a; + if (isNaN(a) || a < 0 || a > 1) { + a = 1; } - // Take input from [0, n] and return it as [0, 1] - function bound01(n, max) { - if (isOnePointZero(n)) { n = "100%"; } - - var processPercent = isPercentage(n); - n = mathMin(max, mathMax(0, parseFloat(n))); + return a; + } - // Automatically convert percentage into number - if (processPercent) { - n = parseInt(n * max, 10) / 100; - } + // Take input from [0, n] and return it as [0, 1] + function bound01(n, max) { + if (isOnePointZero(n)) { + n = '100%'; + } - // Handle floating point rounding errors - if ((math.abs(n - max) < 0.000001)) { - return 1; - } + var processPercent = isPercentage(n); + n = mathMin(max, mathMax(0, parseFloat(n))); - // Convert into [0, 1] range if it isn't already - return (n % max) / parseFloat(max); + // Automatically convert percentage into number + if (processPercent) { + n = parseInt(n * max, 10) / 100; } - // Force a number between 0 and 1 - function clamp01(val) { - return mathMin(1, mathMax(0, val)); + // Handle floating point rounding errors + if (math.abs(n - max) < 0.000001) { + return 1; } - // Parse a base-16 hex value into a base-10 integer - function parseIntFromHex(val) { - return parseInt(val, 16); + // Convert into [0, 1] range if it isn't already + return (n % max) / parseFloat(max); + } + + // Force a number between 0 and 1 + function clamp01(val) { + return mathMin(1, mathMax(0, val)); + } + + // Parse a base-16 hex value into a base-10 integer + function parseIntFromHex(val) { + return parseInt(val, 16); + } + + // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 + // + function isOnePointZero(n) { + return typeof n == 'string' && n.indexOf('.') != -1 && parseFloat(n) === 1; + } + + // Check to see if string passed in is a percentage + function isPercentage(n) { + return typeof n === 'string' && n.indexOf('%') != -1; + } + + // Force a hex value to have 2 characters + function pad2(c) { + return c.length == 1 ? '0' + c : '' + c; + } + + // Replace a decimal with it's percentage value + function convertToPercentage(n) { + if (n <= 1) { + n = n * 100 + '%'; } - // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 - // - function isOnePointZero(n) { - return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; + return n; + } + + // Converts a decimal to a hex value + function convertDecimalToHex(d) { + return Math.round(parseFloat(d) * 255).toString(16); + } + // Converts a hex value to a decimal + function convertHexToDecimal(h) { + return parseIntFromHex(h) / 255; + } + + var matchers = (function() { + // + var CSS_INTEGER = '[-\\+]?\\d+%?'; + + // + var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?'; + + // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. + var CSS_UNIT = '(?:' + CSS_NUMBER + ')|(?:' + CSS_INTEGER + ')'; + + // Actual matching. + // Parentheses and commas are optional, but not required. + // Whitespace can take the place of commas or opening paren + var PERMISSIVE_MATCH3 = + '[\\s|\\(]+(' + + CSS_UNIT + + ')[,|\\s]+(' + + CSS_UNIT + + ')[,|\\s]+(' + + CSS_UNIT + + ')\\s*\\)?'; + var PERMISSIVE_MATCH4 = + '[\\s|\\(]+(' + + CSS_UNIT + + ')[,|\\s]+(' + + CSS_UNIT + + ')[,|\\s]+(' + + CSS_UNIT + + ')[,|\\s]+(' + + CSS_UNIT + + ')\\s*\\)?'; + + return { + rgb: new RegExp('rgb' + PERMISSIVE_MATCH3), + rgba: new RegExp('rgba' + PERMISSIVE_MATCH4), + hsl: new RegExp('hsl' + PERMISSIVE_MATCH3), + hsla: new RegExp('hsla' + PERMISSIVE_MATCH4), + hsv: new RegExp('hsv' + PERMISSIVE_MATCH3), + hsva: new RegExp('hsva' + PERMISSIVE_MATCH4), + 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})$/ + }; + })(); + + // `stringInputToObject` + // Permissive string parsing. Take in a number of formats, and output an object + // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` + function stringInputToObject(color) { + color = color + .replace(trimLeft, '') + .replace(trimRight, '') + .toLowerCase(); + var named = false; + if (names[color]) { + color = names[color]; + named = true; + } else if (color == 'transparent') { + return { r: 0, g: 0, b: 0, a: 0, format: 'name' }; } - // Check to see if string passed in is a percentage - function isPercentage(n) { - return typeof n === "string" && n.indexOf('%') != -1; + // Try to match string input using regular expressions. + // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] + // Just return an object and let the conversion functions handle that. + // This way the result will be the same whether the tinycolor is initialized with string or object. + var match; + if ((match = matchers.rgb.exec(color))) { + return { r: match[1], g: match[2], b: match[3] }; } - - // Force a hex value to have 2 characters - function pad2(c) { - return c.length == 1 ? '0' + c : '' + c; + if ((match = matchers.rgba.exec(color))) { + return { r: match[1], g: match[2], b: match[3], a: match[4] }; } - - // Replace a decimal with it's percentage value - function convertToPercentage(n) { - if (n <= 1) { - n = (n * 100) + "%"; - } - - return n; + if ((match = matchers.hsl.exec(color))) { + return { h: match[1], s: match[2], l: match[3] }; } - - // Converts a decimal to a hex value - function convertDecimalToHex(d) { - return Math.round(parseFloat(d) * 255).toString(16); + if ((match = matchers.hsla.exec(color))) { + return { h: match[1], s: match[2], l: match[3], a: match[4] }; } - // Converts a hex value to a decimal - function convertHexToDecimal(h) { - return (parseIntFromHex(h) / 255); + if ((match = matchers.hsv.exec(color))) { + return { h: match[1], s: match[2], v: match[3] }; } - - var matchers = (function() { - - // - var CSS_INTEGER = "[-\\+]?\\d+%?"; - - // - var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; - - // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. - var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; - - // Actual matching. - // Parentheses and commas are optional, but not required. - // Whitespace can take the place of commas or opening paren - var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; - var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; - - return { - rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), - rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), - hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), - hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), - hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), - hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), - 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})$/ - }; - })(); - - // `stringInputToObject` - // Permissive string parsing. Take in a number of formats, and output an object - // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` - function stringInputToObject(color) { - - color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); - var named = false; - if (names[color]) { - color = names[color]; - named = true; - } - else if (color == 'transparent') { - return { r: 0, g: 0, b: 0, a: 0, format: "name" }; - } - - // Try to match string input using regular expressions. - // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] - // Just return an object and let the conversion functions handle that. - // This way the result will be the same whether the tinycolor is initialized with string or object. - var match; - if ((match = matchers.rgb.exec(color))) { - return { r: match[1], g: match[2], b: match[3] }; - } - if ((match = matchers.rgba.exec(color))) { - return { r: match[1], g: match[2], b: match[3], a: match[4] }; - } - if ((match = matchers.hsl.exec(color))) { - return { h: match[1], s: match[2], l: match[3] }; - } - if ((match = matchers.hsla.exec(color))) { - return { h: match[1], s: match[2], l: match[3], a: match[4] }; - } - if ((match = matchers.hsv.exec(color))) { - return { h: match[1], s: match[2], v: match[3] }; - } - if ((match = matchers.hsva.exec(color))) { - return { h: match[1], s: match[2], v: match[3], a: match[4] }; - } - if ((match = matchers.hex8.exec(color))) { - return { - a: convertHexToDecimal(match[1]), - r: parseIntFromHex(match[2]), - g: parseIntFromHex(match[3]), - b: parseIntFromHex(match[4]), - format: named ? "name" : "hex8" - }; - } - if ((match = matchers.hex6.exec(color))) { - return { - r: parseIntFromHex(match[1]), - g: parseIntFromHex(match[2]), - b: parseIntFromHex(match[3]), - format: named ? "name" : "hex" - }; - } - if ((match = matchers.hex3.exec(color))) { - return { - r: parseIntFromHex(match[1] + '' + match[1]), - g: parseIntFromHex(match[2] + '' + match[2]), - b: parseIntFromHex(match[3] + '' + match[3]), - format: named ? "name" : "hex" - }; - } - - return false; + if ((match = matchers.hsva.exec(color))) { + return { h: match[1], s: match[2], v: match[3], a: match[4] }; + } + if ((match = matchers.hex8.exec(color))) { + return { + a: convertHexToDecimal(match[1]), + r: parseIntFromHex(match[2]), + g: parseIntFromHex(match[3]), + b: parseIntFromHex(match[4]), + format: named ? 'name' : 'hex8' + }; + } + if ((match = matchers.hex6.exec(color))) { + return { + r: parseIntFromHex(match[1]), + g: parseIntFromHex(match[2]), + b: parseIntFromHex(match[3]), + format: named ? 'name' : 'hex' + }; + } + if ((match = matchers.hex3.exec(color))) { + return { + r: parseIntFromHex(match[1] + '' + match[1]), + g: parseIntFromHex(match[2] + '' + match[2]), + b: parseIntFromHex(match[3] + '' + match[3]), + format: named ? 'name' : 'hex' + }; } - window.tinycolor = tinycolor; - //})(); + return false; + } - $(function () { - if ($.fn.spectrum.load) { - $.fn.spectrum.processNativeColorInputs(); - } - }); + window.tinycolor = tinycolor; + //})(); + $(function() { + if ($.fn.spectrum.load) { + $.fn.spectrum.processNativeColorInputs(); + } + }); }); diff --git a/src/utils/Dragger.js b/src/utils/Dragger.js index 597af1523..9d28774d6 100644 --- a/src/utils/Dragger.js +++ b/src/utils/Dragger.js @@ -12,7 +12,6 @@ var getBoundingRect = (el, win) => { }; module.exports = { - // TODO move to opts setKey(keys, command) { //key(keys, command); @@ -25,9 +24,11 @@ module.exports = { */ getElementRect(el) { var posFetcher = this.opts.posFetcher || ''; - return posFetcher ? posFetcher(el, { - avoidFrameOffset: 1, - }) : getBoundingRect(el); + return posFetcher + ? posFetcher(el, { + avoidFrameOffset: 1 + }) + : getBoundingRect(el); }, /** @@ -67,7 +68,6 @@ module.exports = { this.el = el; this.handlers = this.opts.dragHandlers || [el]; - var elRect = this.getElementRect(el); //<-- TODO have wrong top:left this.elRect = elRect; this.startTop = elRect.top; @@ -75,7 +75,7 @@ module.exports = { // TODO init snapper - this.getDocumentEl().on('mousedown', this.handleMouseDown); + this.getDocumentEl().on('mousedown', this.handleMouseDown); }, /** @@ -98,12 +98,12 @@ module.exports = { // Start callback var onStart = this.opts.onStart; - if(typeof onStart === 'function') { + if (typeof onStart === 'function') { onStart(e, { docs, el: this.el, start: this.startPos, - elRect: this.elRect, + elRect: this.elRect }); } @@ -121,13 +121,13 @@ module.exports = { // Stop callback var onEnd = this.opts.onEnd; - if(typeof onEnd === 'function') { + if (typeof onEnd === 'function') { onEnd(e, { docs, delta: this.delta, end: { x: this.startLeft + this.delta.x, - y: this.startTop + this.delta.y, + y: this.startTop + this.delta.y } }); } @@ -203,10 +203,12 @@ module.exports = { */ getMousePos(e) { var mouseFetch = this.opts.mousePosFetcher; - return mouseFetch ? mouseFetch(e) : { - x: e.clientX, - y: e.clientY - }; + return mouseFetch + ? mouseFetch(e) + : { + x: e.clientX, + y: e.clientY + }; }, /** @@ -253,7 +255,7 @@ module.exports = { // Drag callback const onDrag = this.opts.onDrag; - if(typeof onDrag === 'function') { + if (typeof onDrag === 'function') { onDrag(e, { delta, current: { @@ -294,10 +296,10 @@ module.exports = { setX(xPos, { el, start: this.startLeft, - delta: x, + delta: x }); } else { - el.style.left = xPos + 'px'; + el.style.left = xPos + 'px'; } }, @@ -315,11 +317,10 @@ module.exports = { setY(yPos, { el, start: this.startTop, - delta: y, + delta: y }); } else { - el.style.top = yPos + 'px'; + el.style.top = yPos + 'px'; } - }, - + } }; diff --git a/src/utils/Droppable.js b/src/utils/Droppable.js new file mode 100644 index 000000000..7de1ca039 --- /dev/null +++ b/src/utils/Droppable.js @@ -0,0 +1,158 @@ +/* + This class makes the canvas droppable + */ + +import { on } from 'utils/mixins'; +import { bindAll } from 'underscore'; + +export default class Droppable { + constructor(em) { + this.em = em; + const el = em + .get('DomComponents') + .getWrapper() + .getEl(); + this.el = el; + this.counter = 0; + bindAll( + this, + 'handleDragEnter', + 'handleDragOver', + 'handleDrop', + 'handleDragLeave' + ); + on(el, 'dragenter', this.handleDragEnter); + on(el, 'dragover', this.handleDragOver); + on(el, 'drop', this.handleDrop); + on(el, 'dragleave', this.handleDragLeave); + + return this; + } + + endDrop(cancel, ev) { + const em = this.em; + this.counter = 0; + this.over = 0; + // force out like in BlockView + const sorter = this.sorter; + cancel && (sorter.moved = 0); + sorter.endMove(); + em.trigger('canvas:dragend', ev); + } + + handleDragLeave(ev) { + this.updateCounter(-1, ev); + } + + updateCounter(value, ev) { + this.counter += value; + this.counter === 0 && this.endDrop(1, ev); + } + + handleDragEnter(ev) { + const em = this.em; + const dt = ev.dataTransfer; + this.updateCounter(1, ev); + if (this.over) return; + this.over = 1; + const utils = em.get('Utils'); + const canvas = em.get('Canvas'); + this.sorter = new utils.Sorter({ + em, + wmargin: 1, + nested: 1, + canvasRelative: 1, + direction: 'a', + container: canvas.getBody(), + placer: canvas.getPlacerEl(), + eventMoving: 'mousemove dragover', + containerSel: '*', + itemSel: '*', + pfx: 'gjs-', + onStart: () => em.stopDefault(), + onEndMove: model => { + em.runDefault(); + + if (model && model.get && model.get('activeOnRender')) { + model.trigger('active'); + model.set('activeOnRender', 0); + } + + model && em.trigger('canvas:drop', dt, model); + }, + document: canvas.getFrameEl().contentDocument + }); + // For security reason I can't read the drag data on dragenter, but + // as I need it for the Sorter context I will use `dragContent` or just + // any not empty element + const content = em.get('dragContent') || '
'; + this.sorter.setDropContent(content); + this.sorter.startSort(); + em.trigger('canvas:dragenter', dt, content); + } + + /** + * Always need to have this handler active for enabling the drop + * @param {Event} ev + */ + handleDragOver(ev) { + ev.preventDefault(); + this.em.trigger('canvas:dragover', ev); + } + + handleDrop(ev) { + ev.preventDefault(); + const dt = ev.dataTransfer; + const content = this.getContentByData(dt).content; + ev.target.style.border = ''; + + if (content) { + this.sorter.setDropContent(content); + } else { + this.sorter.moved = 0; + } + + this.endDrop(0, ev); + } + + getContentByData(dataTransfer) { + const em = this.em; + const types = dataTransfer.types; + const files = dataTransfer.files; + let content = dataTransfer.getData('text'); + + if (files.length) { + content = []; + for (let i = 0; i < files.length; i++) { + const file = files[i]; + const type = file.type.split('/')[0]; + + if (type == 'image') { + content.push({ + type, + file, + attributes: { alt: file.name } + }); + } + } + } else if (types.indexOf('text/html') >= 0) { + content = dataTransfer + .getData('text/html') + .replace(/<\/?meta[^>]*>/g, ''); + } else if (types.indexOf('text/uri-list') >= 0) { + content = { + type: 'link', + attributes: { href: content }, + content: content + }; + } else if (types.indexOf('text/json') >= 0) { + const json = dataTransfer.getData('text/json'); + json && (content = JSON.parse(json)); + } + + const result = { content }; + em.trigger('canvas:dragdata', dataTransfer, result); + + return result; + } +} diff --git a/src/utils/Resizer.js b/src/utils/Resizer.js index f35c560ad..327d204ae 100644 --- a/src/utils/Resizer.js +++ b/src/utils/Resizer.js @@ -46,7 +46,7 @@ var defaultOpts = { cr: 1, // Center right bl: 1, // Bottom left bc: 1, // Bottom center - br: 1, // Bottom right + br: 1 // Bottom right }; var createHandler = (name, opts) => { @@ -69,18 +69,16 @@ var getBoundingRect = (el, win) => { }; class Resizer { - /** * Init the Resizer with options * @param {Object} options */ constructor(opts = {}) { this.setOptions(opts); - bindAll(this, 'handleKeyDown', 'handleMouseDown', 'move', 'stop') + bindAll(this, 'handleKeyDown', 'handleMouseDown', 'move', 'stop'); return this; } - /** * Get current connfiguration options * @return {Object} @@ -89,7 +87,6 @@ class Resizer { return this.opts; } - /** * Setup options * @param {Object} options @@ -122,8 +119,9 @@ class Resizer { // Create handlers const handlers = {}; - ['tl', 'tc', 'tr', 'cl', 'cr', 'bl', 'bc', 'br'].forEach(hdl => - handlers[hdl] = opts[hdl] ? createHandler(hdl, opts) : ''); + ['tl', 'tc', 'tr', 'cl', 'cr', 'bl', 'bc', 'br'].forEach( + hdl => (handlers[hdl] = opts[hdl] ? createHandler(hdl, opts) : '') + ); for (let n in handlers) { const handler = handlers[n]; @@ -238,13 +236,13 @@ class Resizer { t: rect.top, l: rect.left, w: rect.width, - h: rect.height, + h: rect.height }; this.rectDim = { t: rect.top, l: rect.left, w: rect.width, - h: rect.height, + h: rect.height }; this.startPos = { x: e.clientX, @@ -256,7 +254,8 @@ class Resizer { on(doc, 'mousemove', this.move); on(doc, 'keydown', this.handleKeyDown); on(doc, 'mouseup', this.stop); - isFunction(this.onStart) && this.onStart(e, {docs: doc, config, el, resizer}); + isFunction(this.onStart) && + this.onStart(e, { docs: doc, config, el, resizer }); this.move(e); } @@ -267,15 +266,17 @@ class Resizer { move(e) { const onMove = this.onMove; var mouseFetch = this.mousePosFetcher; - var currentPos = mouseFetch ? mouseFetch(e) : { - x: e.clientX, - y: e.clientY - }; + var currentPos = mouseFetch + ? mouseFetch(e) + : { + x: e.clientX, + y: e.clientY + }; this.currentPos = currentPos; this.delta = { x: currentPos.x - this.startPos.x, - y: currentPos.y - this.startPos.y, + y: currentPos.y - this.startPos.y }; this.keys = { shift: e.shiftKey, @@ -306,7 +307,7 @@ class Resizer { off(doc, 'keydown', this.handleKeyDown); off(doc, 'mouseup', this.stop); this.updateRect(1); - isFunction(this.onEnd) && this.onEnd(e, {docs: doc, config}); + isFunction(this.onEnd) && this.onEnd(e, { docs: doc, config }); } /** @@ -381,7 +382,7 @@ class Resizer { if (this.isHandler(el)) { this.selectedHandler = el; this.start(e); - }else if(el !== this.el){ + } else if (el !== this.el) { this.selectedHandler = ''; this.blur(); } @@ -409,8 +410,7 @@ class Resizer { h: startH }; - if (!data) - return; + if (!data) return; var attr = data.handlerAttr; if (~attr.indexOf('r')) { diff --git a/src/utils/Sorter.js b/src/utils/Sorter.js index 737a5e8a4..295d27b77 100644 --- a/src/utils/Sorter.js +++ b/src/utils/Sorter.js @@ -3,10 +3,17 @@ import { on, off, matches } from 'utils/mixins'; const $ = Backbone.$; module.exports = Backbone.View.extend({ - initialize(opt) { this.opt = opt || {}; - _.bindAll(this,'startSort','onMove','endMove','rollback', 'udpateOffset', 'moveDragHelper'); + _.bindAll( + this, + 'startSort', + 'onMove', + 'endMove', + 'rollback', + 'udpateOffset', + 'moveDragHelper' + ); var o = opt || {}; this.elT = 0; this.elL = 0; @@ -43,7 +50,7 @@ module.exports = Backbone.View.extend({ this.canvasRelative = o.canvasRelative || 0; this.selectOnEnd = !o.avoidSelectOnEnd; - if(this.em && this.em.on){ + if (this.em && this.em.on) { this.em.on('change:canvasOffset', this.udpateOffset); this.udpateOffset(); } @@ -58,7 +65,6 @@ module.exports = Backbone.View.extend({ return this.el; }, - getDocuments() { const em = this.em; const canvasDoc = em && em.get('Canvas').getBody().ownerDocument; @@ -134,12 +140,14 @@ module.exports = Backbone.View.extend({ ev && this.moveDragHelper(ev); // Listen mouse move events - if(this.em) { + if (this.em) { $(this.em.get('Canvas').getBody().ownerDocument) - .off('mousemove', this.moveDragHelper).on('mousemove', this.moveDragHelper); + .off('mousemove', this.moveDragHelper) + .on('mousemove', this.moveDragHelper); } $(document) - .off('mousemove', this.moveDragHelper).on('mousemove', this.moveDragHelper); + .off('mousemove', this.moveDragHelper) + .on('mousemove', this.moveDragHelper); }, /** @@ -149,7 +157,7 @@ module.exports = Backbone.View.extend({ moveDragHelper(e) { const doc = e.target.ownerDocument; - if(!this.dragHelper || !doc) { + if (!this.dragHelper || !doc) { return; } @@ -174,11 +182,10 @@ module.exports = Backbone.View.extend({ posX = e.clientX; } - dragHelperStyle.top = (posY + addTop) + 'px'; - dragHelperStyle.left = (posX + addLeft) + 'px'; + dragHelperStyle.top = posY + addTop + 'px'; + dragHelperStyle.left = posX + addLeft + 'px'; }, - /** * Returns true if the element matches with selector * @param {Element} el @@ -196,12 +203,10 @@ module.exports = Backbone.View.extend({ * @return {Element|null} */ closest(el, selector) { - if(!el) - return; + if (!el) return; var elem = el.parentNode; while (elem && elem.nodeType === 1) { - if (this.matches(elem, selector)) - return elem; + if (this.matches(elem, selector)) return elem; elem = elem.parentNode; } return null; @@ -231,7 +236,7 @@ module.exports = Backbone.View.extend({ el.className = pfx + 'placeholder'; el.style.display = 'none'; el.style['pointer-events'] = 'none'; - ins.className = pfx + "placeholder-int"; + ins.className = pfx + 'placeholder-int'; el.appendChild(ins); return el; }, @@ -272,8 +277,8 @@ module.exports = Backbone.View.extend({ srcModel && srcModel.set && srcModel.set('status', 'freezed'); } - on(container, 'mousemove', this.onMove); - on(docs, 'mouseup', this.endMove); + on(container, 'mousemove dragover', this.onMove); + on(docs, 'mouseup dragend', this.endMove); on(docs, 'keydown', this.rollback); onStart && onStart(); @@ -293,7 +298,6 @@ module.exports = Backbone.View.extend({ return $(elem).data('model'); }, - /** * Get the model of the current source element (element to drag) * @return {Model} @@ -307,8 +311,12 @@ module.exports = Backbone.View.extend({ if (dropContent && em) { if (!dropModel) { let comps = em.get('DomComponents').getComponents(); - let tempModel = comps.add(dropContent, {avoidUpdateStyle: 1, temporary: 1}); - dropModel = comps.remove(tempModel, {temporary: 1}); + let tempModel = comps.add(dropContent, { + avoidChildren: 1, + avoidUpdateStyle: 1, + temporary: 1 + }); + dropModel = comps.remove(tempModel, { temporary: 1 }); this.dropModel = dropModel instanceof Array ? dropModel[0] : dropModel; } return dropModel; @@ -319,7 +327,6 @@ module.exports = Backbone.View.extend({ } }, - /** * Highlight target * @param {Model|null} model @@ -351,15 +358,14 @@ module.exports = Backbone.View.extend({ // Turn placeholder visibile var plh = this.plh; var dsp = plh.style.display; - if (!dsp || dsp === 'none') - plh.style.display = 'block'; + if (!dsp || dsp === 'none') plh.style.display = 'block'; // Cache all necessary positions var eO = this.offset(this.el); this.elT = this.wmargin ? Math.abs(eO.top) : eO.top; - this.elL = this.wmargin ? Math.abs(eO.left): eO.left; - var rY = (e.pageY - this.elT) + this.el.scrollTop; - var rX = (e.pageX - this.elL) + this.el.scrollLeft; + this.elL = this.wmargin ? Math.abs(eO.left) : eO.left; + var rY = e.pageY - this.elT + this.el.scrollTop; + var rX = e.pageX - this.elL + this.el.scrollLeft; if (this.canvasRelative && em) { var mousePos = em.get('Canvas').getMouseRelativeCanvas(e); @@ -380,35 +386,34 @@ module.exports = Backbone.View.extend({ this.lastDims = dims; var pos = this.findPosition(dims, rX, rY); // If there is a significant changes with the pointer - if( !this.lastPos || - (this.lastPos.index != pos.index || this.lastPos.method != pos.method)){ + if ( + !this.lastPos || + (this.lastPos.index != pos.index || this.lastPos.method != pos.method) + ) { this.movePlaceholder(this.plh, dims, pos, this.prevTargetDim); - if(!this.$plh) - this.$plh = $(this.plh); + if (!this.$plh) this.$plh = $(this.plh); // With canvasRelative the offset is calculated automatically for // each element if (!this.canvasRelative) { - if(this.offTop) - this.$plh.css('top', '+=' + this.offTop + 'px'); - if(this.offLeft) - this.$plh.css('left', '+=' + this.offLeft + 'px'); + if (this.offTop) this.$plh.css('top', '+=' + this.offTop + 'px'); + if (this.offLeft) this.$plh.css('left', '+=' + this.offLeft + 'px'); } this.lastPos = pos; } - if(typeof this.onMoveClb === 'function') - this.onMoveClb(e); - - em && em.trigger('sorter:drag', { - target, - targetModel, - dims, - pos, - x: rX, - y: rY, - }); + if (typeof this.onMoveClb === 'function') this.onMoveClb(e); + + em && + em.trigger('sorter:drag', { + target, + targetModel, + dims, + pos, + x: rX, + y: rY + }); }, /** @@ -420,17 +425,15 @@ module.exports = Backbone.View.extend({ * @private * */ isInFlow(el, parent) { - if(!el) - return false; - - parent = parent || document.body; - var ch = -1, h; - var elem = el; - h = elem.offsetHeight; - if (/*h < ch || */!this.styleInFlow(elem, parent)) - return false; - else - return true; + if (!el) return false; + + parent = parent || document.body; + var ch = -1, + h; + var elem = el; + h = elem.offsetHeight; + if (/*h < ch || */ !this.styleInFlow(elem, parent)) return false; + else return true; }, /** @@ -443,28 +446,30 @@ module.exports = Backbone.View.extend({ styleInFlow(el, parent) { var style = el.style; var $el = $(el); - if (style.overflow && style.overflow !== 'visible') - return; - if ($el.css('float') !== 'none') - return; - if(parent && $(parent).css('display') == 'flex') - return; + if (style.overflow && style.overflow !== 'visible') return; + if ($el.css('float') !== 'none') return; + if (parent && $(parent).css('display') == 'flex') return; switch (style.position) { - case 'static': case 'relative': case '': - break; - default: - return; + case 'static': + case 'relative': + case '': + break; + default: + return; } switch (el.tagName) { - case 'TR': case 'TBODY': case 'THEAD': case 'TFOOT': - return true; + case 'TR': + case 'TBODY': + case 'THEAD': + case 'TFOOT': + return true; } switch ($el.css('display')) { - case 'block': - case 'list-item': - case 'table': - case 'flex': - return true; + case 'block': + case 'list-item': + case 'table': + case 'flex': + return true; } return; }, @@ -545,7 +550,7 @@ module.exports = Backbone.View.extend({ // Check if the target is different from the previous one if (this.prevTarget && this.prevTarget != target) { - this.prevTarget = null; + this.prevTarget = null; } // New target found @@ -567,29 +572,29 @@ module.exports = Backbone.View.extend({ } // If the target is the previous one will return the cached dims - if(this.prevTarget == target) - dims = this.cacheDims; + if (this.prevTarget == target) dims = this.cacheDims; // Target when I will drop element to sort this.target = this.prevTarget; // Generally, on any new target the poiner enters inside its area and // triggers nearBorders(), so have to take care of this - if(this.nearBorders(this.prevTargetDim, rX, rY) || - (!this.nested && !this.cacheDims.length)) { - const targetParent = this.targetP; + if ( + this.nearBorders(this.prevTargetDim, rX, rY) || + (!this.nested && !this.cacheDims.length) + ) { + const targetParent = this.targetP; - if (targetParent && this.validTarget(targetParent).valid) { - dims = this.cacheDimsP; - this.target = targetParent; - } + if (targetParent && this.validTarget(targetParent).valid) { + dims = this.cacheDimsP; + this.target = targetParent; + } } this.lastPos = null; return dims; }, - /** * Get valid target from element * This method should replace dimsFromTarget() @@ -617,7 +622,7 @@ module.exports = Backbone.View.extend({ // Check if the target is different from the previous one if (targetPrev && targetPrev != target) { - this.targetPrev = ''; + this.targetPrev = ''; } // New target found @@ -649,7 +654,6 @@ module.exports = Backbone.View.extend({ return target; }, - /** * Check if the current pointer is neare to element borders * @return {Boolen} @@ -658,28 +662,28 @@ module.exports = Backbone.View.extend({ const off = 10; const rect = el.getBoundingClientRect(); const body = el.ownerDocument.body; - const {x, y} = this.getCurrentPos(); + const { x, y } = this.getCurrentPos(); const top = rect.top + body.scrollTop; const left = rect.left + body.scrollLeft; const width = rect.width; const height = rect.height; //console.log(pos, {top, left}); - if ( y < (top + off) || // near top edge - y > (top + height - off) || // near bottom edge - x < (left + off) || // near left edge - x > (left + width - off) // near right edge - ) { - return 1; + if ( + y < top + off || // near top edge + y > top + height - off || // near bottom edge + x < left + off || // near left edge + x > left + width - off // near right edge + ) { + return 1; } }, - getCurrentPos() { const ev = this.eventMove; const x = ev.pageX || 0; const y = ev.pageY || 0; - return {x, y}; + return { x, y }; }, /** @@ -703,8 +707,12 @@ module.exports = Backbone.View.extend({ width = pos.width + marginLeft + marginRight; } else { var o = this.offset(el); - top = this.relative ? el.offsetTop : o.top - (this.wmargin ? -1 : 1) * this.elT; - left = this.relative ? el.offsetLeft : o.left - (this.wmargin ? -1 : 1) * this.elL; + top = this.relative + ? el.offsetTop + : o.top - (this.wmargin ? -1 : 1) * this.elT; + left = this.relative + ? el.offsetLeft + : o.left - (this.wmargin ? -1 : 1) * this.elL; height = el.offsetHeight; width = el.offsetWidth; } @@ -721,8 +729,7 @@ module.exports = Backbone.View.extend({ * */ getChildrenDim(trg) { var dims = []; - if(!trg) - return dims; + if (!trg) return dims; // Get children based on getChildrenContainer var trgModel = this.getTargetModel(trg); @@ -742,12 +749,9 @@ module.exports = Backbone.View.extend({ var dim = this.getDim(el); var dir = this.direction; - if(dir == 'v') - dir = true; - else if(dir == 'h') - dir = false; - else - dir = this.isInFlow(el, trg); + if (dir == 'v') dir = true; + else if (dir == 'h') dir = false; + else dir = this.isInFlow(el, trg); dim.push(dir); dim.push(el); @@ -773,8 +777,7 @@ module.exports = Backbone.View.extend({ var l = dim[1]; var h = dim[2]; var w = dim[3]; - if( ((t + off) > y) || (y > (t + h - off)) || - ((l + off) > x) || (x > (l + w - off)) ) + if (t + off > y || y > t + h - off || l + off > x || x > l + w - off) result = 1; return !!result; @@ -788,50 +791,56 @@ module.exports = Backbone.View.extend({ * @retun {Object} * */ findPosition(dims, posX, posY) { - var result = {index: 0, method: 'before'}; - var leftLimit = 0, xLimit = 0, dimRight = 0, yLimit = 0, xCenter = 0, yCenter = 0, dimDown = 0, dim = 0; + var result = { index: 0, method: 'before' }; + var leftLimit = 0, + xLimit = 0, + dimRight = 0, + yLimit = 0, + xCenter = 0, + yCenter = 0, + dimDown = 0, + dim = 0; // Each dim is: Top, Left, Height, Width - for(var i = 0, len = dims.length; i < len; i++){ + for (var i = 0, len = dims.length; i < len; i++) { dim = dims[i]; // Right position of the element. Left + Width dimRight = dim[1] + dim[3]; // Bottom position of the element. Top + Height dimDown = dim[0] + dim[2]; // X center position of the element. Left + (Width / 2) - xCenter = dim[1] + (dim[3] / 2); + xCenter = dim[1] + dim[3] / 2; // Y center position of the element. Top + (Height / 2) - yCenter = dim[0] + (dim[2] / 2); + yCenter = dim[0] + dim[2] / 2; // Skip if over the limits - if( (xLimit && dim[1] > xLimit) || - (yLimit && yCenter >= yLimit) || // >= avoid issue with clearfixes - (leftLimit && dimRight < leftLimit) ) - continue; + if ( + (xLimit && dim[1] > xLimit) || + (yLimit && yCenter >= yLimit) || // >= avoid issue with clearfixes + (leftLimit && dimRight < leftLimit) + ) + continue; result.index = i; // If it's not in flow (like 'float' element) - if(!dim[4]){ - if(posY < dimDown) - yLimit = dimDown; + if (!dim[4]) { + if (posY < dimDown) yLimit = dimDown; //If x lefter than center - if(posX < xCenter){ + if (posX < xCenter) { xLimit = xCenter; - result.method = "before"; - }else{ + result.method = 'before'; + } else { leftLimit = xCenter; - result.method = "after"; + result.method = 'after'; } - }else{ + } else { // If y upper than center - if(posY < yCenter){ - result.method = "before"; + if (posY < yCenter) { + result.method = 'before'; break; - }else - result.method = "after"; // After last element + } else result.method = 'after'; // After last element } } return result; }, - /** * Updates the position of the placeholder * @param {HTMLElement} phl @@ -840,47 +849,52 @@ module.exports = Backbone.View.extend({ * @param {Array} trgDim target dimensions * */ movePlaceholder(plh, dims, pos, trgDim) { - var marg = 0, t = 0, l = 0, w = 0, h = 0, - un = 'px', margI = 5, brdCol = '#62c462', brd = 3, - method = pos.method; + var marg = 0, + t = 0, + l = 0, + w = 0, + h = 0, + un = 'px', + margI = 5, + brdCol = '#62c462', + brd = 3, + method = pos.method; var elDim = dims[pos.index]; plh.style.borderColor = 'transparent ' + brdCol; plh.style.borderWidth = brd + un + ' ' + (brd + 2) + un; plh.style.margin = '-' + brd + 'px 0 0'; - if(elDim){ + if (elDim) { // If it's not in flow (like 'float' element) - if(!elDim[4]){ + if (!elDim[4]) { w = 'auto'; - h = elDim[2] - (marg * 2) + un; + h = elDim[2] - marg * 2 + un; t = elDim[0] + marg; - l = (method == 'before') ? (elDim[1] - marg) : (elDim[1] + elDim[3] - marg); + l = method == 'before' ? elDim[1] - marg : elDim[1] + elDim[3] - marg; plh.style.borderColor = brdCol + ' transparent'; - plh.style.borderWidth = (brd + 2) + un + ' ' + brd + un; + plh.style.borderWidth = brd + 2 + un + ' ' + brd + un; plh.style.margin = '0 0 0 -' + brd + 'px'; - }else{ + } else { w = elDim[3] + un; h = 'auto'; - t = (method == 'before') ? (elDim[0] - marg) : (elDim[0] + elDim[2] - marg); + t = method == 'before' ? elDim[0] - marg : elDim[0] + elDim[2] - marg; l = elDim[1]; } - }else{ - if(!this.nested){ + } else { + if (!this.nested) { plh.style.display = 'none'; return; } - if(trgDim){ + if (trgDim) { t = trgDim[0] + margI; l = trgDim[1] + margI; - w = (parseInt(trgDim[3]) - margI * 2) + un; + w = parseInt(trgDim[3]) - margI * 2 + un; h = 'auto'; } } plh.style.top = t + un; plh.style.left = l + un; - if(w) - plh.style.width = w; - if(h) - plh.style.height = h; + if (w) plh.style.width = w; + if (h) plh.style.height = h; }, /** @@ -893,13 +907,13 @@ module.exports = Backbone.View.extend({ var created; const docs = this.getDocuments(); const container = this.getContainerEl(); - off(container, 'mousemove', this.onMove); - off(docs, 'mouseup', this.endMove); + off(container, 'mousemove dragover', this.onMove); + off(docs, 'mouseup dragend', this.endMove); off(docs, 'keydown', this.rollback); //this.$document.off('mouseup', this.endMove); //this.$document.off('keydown', this.rollback); this.plh.style.display = 'none'; - var clsReg = new RegExp('(?:^|\\s)'+this.freezeClass+'(?!\\S)', 'gi'); + var clsReg = new RegExp('(?:^|\\s)' + this.freezeClass + '(?!\\S)', 'gi'); let src = this.eV; if (src) { @@ -915,15 +929,13 @@ module.exports = Backbone.View.extend({ created = this.move(this.target, src, this.lastPos); } - if(this.plh) - this.plh.style.display = 'none'; + if (this.plh) this.plh.style.display = 'none'; - if(typeof this.onEndMove === 'function') - this.onEndMove(created); + if (typeof this.onEndMove === 'function') this.onEndMove(created); var dragHelper = this.dragHelper; - if(dragHelper) { + if (dragHelper) { dragHelper.parentNode.removeChild(dragHelper); this.dragHelper = null; } @@ -952,11 +964,12 @@ module.exports = Backbone.View.extend({ var dropInfo = validResult.dropInfo; var dragInfo = validResult.dragInfo; var dropContent = this.dropContent; - droppable = validResult.trgModel instanceof Backbone.Collection ? 1 : droppable; + droppable = + validResult.trgModel instanceof Backbone.Collection ? 1 : droppable; if (targetCollection && droppable && draggable) { index = pos.method === 'after' ? index + 1 : index; - var opts = {at: index, noIncrement: 1}; + var opts = { at: index, noIncrement: 1 }; if (!dropContent) { modelTemp = targetCollection.add({}, opts); @@ -1015,6 +1028,5 @@ module.exports = Backbone.View.extend({ this.moved = 0; this.endMove(); } - }, - + } }); diff --git a/src/utils/extender.js b/src/utils/extender.js index f9d314619..baca168e2 100644 --- a/src/utils/extender.js +++ b/src/utils/extender.js @@ -1,4 +1,4 @@ -module.exports = ({$, Backbone}) => { +module.exports = ({ $, Backbone }) => { if (Backbone) { const ViewProt = Backbone.View.prototype; const eventNsMap = {}; @@ -15,7 +15,7 @@ module.exports = ({$, Backbone}) => { eventNsMap[vid] = eventMap; } - eventMap.push({eventName, selector, listener}); + eventMap.push({ eventName, selector, listener }); return this; }; @@ -26,7 +26,7 @@ module.exports = ({$, Backbone}) => { let eventMap = eventNsMap[vid]; if (eventMap) { - eventMap.forEach(({eventName, selector, listener}) => { + eventMap.forEach(({ eventName, selector, listener }) => { this.$el.off(eventName); }); } @@ -40,7 +40,7 @@ module.exports = ({$, Backbone}) => { let eventMap = eventNsMap[vid]; if (eventMap) { - eventMap.forEach(({eventName, selector, listener}) => { + eventMap.forEach(({ eventName, selector, listener }) => { if (eventName == ev && selector == sel) { this.$el.off(eventName); } @@ -55,9 +55,11 @@ module.exports = ({$, Backbone}) => { const fn = $.fn; const splitNamespace = function(name) { - const namespaceArray = name.split('.') - return ( name.indexOf('.') !== 0 ? [namespaceArray[0], namespaceArray.slice(1)] : [null, namespaceArray] ); - } + const namespaceArray = name.split('.'); + return name.indexOf('.') !== 0 + ? [namespaceArray[0], namespaceArray.slice(1)] + : [null, namespaceArray]; + }; /* const CashEvent = function(node, eventName, namespaces, delegate, originalCallback, runOnce) { @@ -103,11 +105,10 @@ module.exports = ({$, Backbone}) => { const off = $.prototype.off; const trigger = $.prototype.trigger; const offset = $.prototype.offset; - const getEvents = (eventName) => eventName.split(/[,\s]+/g); - const getNamespaces = (eventName) => eventName.split('.'); + const getEvents = eventName => eventName.split(/[,\s]+/g); + const getNamespaces = eventName => eventName.split('.'); fn.on = function(eventName, delegate, callback, runOnce) { - if (typeof eventName == 'string') { const events = getEvents(eventName); @@ -130,14 +131,15 @@ module.exports = ({$, Backbone}) => { return on.call(this, eventName, delegate, callback, runOnce); } else { - events.forEach((eventName) => - this.on(eventName, delegate, callback, runOnce)); + events.forEach(eventName => + this.on(eventName, delegate, callback, runOnce) + ); return this; } } else { - return on.call(this, eventName, delegate, callback, runOnce) + return on.call(this, eventName, delegate, callback, runOnce); } - } + }; fn.off = function(eventName, callback) { if (typeof eventName == 'string') { @@ -159,13 +161,13 @@ module.exports = ({$, Backbone}) => { return off.call(this, eventName, callback); } else { - events.forEach((eventName) => this.off(eventName, callback)); + events.forEach(eventName => this.off(eventName, callback)); return this; } } else { return off.call(this, eventName, callback); } - } + }; fn.trigger = function(eventName, data) { if (eventName instanceof $.Event) { @@ -191,54 +193,53 @@ module.exports = ({$, Backbone}) => { return trigger.call(this, eventName, data); } else { - events.forEach((eventName) => this.trigger(eventName, data)); + events.forEach(eventName => this.trigger(eventName, data)); return this; } } else { return trigger.call(this, eventName, data); } - } + }; fn.hide = function() { return this.css('display', 'none'); - } + }; fn.show = function() { return this.css('display', 'block'); - } + }; fn.focus = function() { const el = this.get(0); el && el.focus(); return this; - } + }; - fn.remove = function () { + (fn.remove = function() { return this.each(node => { return node.parentNode && node.parentNode.removeChild(node); }); - }, - - // For spectrum compatibility - fn.bind = function(ev, h) { - return this.on(ev, h); - } + }), + // For spectrum compatibility + (fn.bind = function(ev, h) { + return this.on(ev, h); + }); fn.unbind = function(ev, h) { return this.off(ev, h); - } + }; fn.click = function(h) { return h ? this.on('click', h) : this.trigger('click'); - } + }; fn.change = function(h) { return h ? this.on('change', h) : this.trigger('change'); - } + }; fn.keydown = function(h) { return h ? this.on('keydown', h) : this.trigger('keydown'); - } + }; fn.delegate = function(selector, events, data, handler) { if (!handler) { @@ -249,21 +250,21 @@ module.exports = ({$, Backbone}) => { e.data = data; handler(e); }); - } + }; fn.scrollLeft = function() { let el = this.get(0); el = el.nodeType == 9 ? el.defaultView : el; let win = el instanceof Window ? el : null; return win ? win.pageXOffset : el.scrollLeft || 0; - } + }; fn.scrollTop = function() { let el = this.get(0); el = el.nodeType == 9 ? el.defaultView : el; let win = el instanceof Window ? el : null; return win ? win.pageYOffset : el.scrollTop || 0; - } + }; fn.offset = function(coords) { let top, left; @@ -291,21 +292,21 @@ module.exports = ({$, Backbone}) => { } return ar; - } + }; const indexOf = Array.prototype.indexOf; $.inArray = function(val, arr, i) { - return arr == null ? -1 : indexOf.call( arr, val, i ); - } + return arr == null ? -1 : indexOf.call(arr, val, i); + }; $.Event = function(src, props) { - if (!(this instanceof $.Event) ) { + if (!(this instanceof $.Event)) { return new $.Event(src, props); } this.type = src; this.isDefaultPrevented = () => false; - } + }; } -} +}; diff --git a/src/utils/fetch.js b/src/utils/fetch.js index 33bdd5ebd..8db987abb 100644 --- a/src/utils/fetch.js +++ b/src/utils/fetch.js @@ -2,29 +2,32 @@ import Promise from 'promise-polyfill'; window.Promise = window.Promise || Promise; -export default typeof fetch == 'function' ? fetch.bind() : (url, options) => { - return new Promise((res, rej) => { - const req = new XMLHttpRequest(); - req.open(options.method || 'get', url); - req.withCredentials = options.credentials == 'include'; +export default (typeof fetch == 'function' + ? fetch.bind() + : (url, options) => { + return new Promise((res, rej) => { + const req = new XMLHttpRequest(); + req.open(options.method || 'get', url); + req.withCredentials = options.credentials == 'include'; - for (let k in options.headers || {}) { - req.setRequestHeader(k, options.headers[k]); - } + for (let k in options.headers || {}) { + req.setRequestHeader(k, options.headers[k]); + } - req.onload = e => res({ - status: req.status, - statusText: req.statusText, - text: () => Promise.resolve(req.responseText) - }); - req.onerror = rej; + req.onload = e => + res({ + status: req.status, + statusText: req.statusText, + text: () => Promise.resolve(req.responseText) + }); + req.onerror = rej; - // Actually, fetch doesn't support onProgress feature - if (req.upload && options.onProgress) { - req.upload.onprogress = options.onProgress; - } + // Actually, fetch doesn't support onProgress feature + if (req.upload && options.onProgress) { + req.upload.onprogress = options.onProgress; + } - // Include body only if present - options.body ? req.send(options.body) : req.send(); - }); -} + // Include body only if present + options.body ? req.send(options.body) : req.send(); + }); + }); diff --git a/src/utils/index.js b/src/utils/index.js index e4fcd5aa7..58c12d46a 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,5 +1,4 @@ module.exports = () => { - const Sorter = require('./Sorter'); const Resizer = require('./Resizer'); const Dragger = require('./Dragger'); @@ -21,6 +20,6 @@ module.exports = () => { Sorter, Resizer, - Dragger, + Dragger }; }; diff --git a/src/utils/mixins.js b/src/utils/mixins.js index 84d339e5f..9d56d78e6 100644 --- a/src/utils/mixins.js +++ b/src/utils/mixins.js @@ -1,7 +1,11 @@ import { omit, keys, isUndefined } from 'underscore'; const elProt = window.Element.prototype; -const matches = elProt.matches || elProt.webkitMatchesSelector || elProt.mozMatchesSelector || elProt.msMatchesSelector; +const matches = + elProt.matches || + elProt.webkitMatchesSelector || + elProt.mozMatchesSelector || + elProt.msMatchesSelector; /** * Returns shallow diff between 2 objects @@ -44,7 +48,6 @@ const shallowDiff = (objOrig, objNew) => { return result; }; - const on = (el, ev, fn) => { ev = ev.split(/\s+/); el = el instanceof Array ? el : [el]; @@ -52,8 +55,7 @@ const on = (el, ev, fn) => { for (let i = 0; i < ev.length; ++i) { el.forEach(elem => elem.addEventListener(ev[i], fn)); } -} - +}; const off = (el, ev, fn) => { ev = ev.split(/\s+/); @@ -62,21 +64,18 @@ const off = (el, ev, fn) => { for (let i = 0; i < ev.length; ++i) { el.forEach(elem => elem.removeEventListener(ev[i], fn)); } -} - +}; -const getUnitFromValue = (value) => { +const getUnitFromValue = value => { return value.replace(parseFloat(value), ''); -} - +}; const upFirst = value => value[0].toUpperCase() + value.toLowerCase().slice(1); - const camelCase = value => { const values = value.split('-'); return values[0].toLowerCase() + values.slice(1).map(upFirst); -} +}; const normalizeFloat = (value, step = 1, valueDef = 0) => { let stepDecimals = 0; @@ -89,16 +88,23 @@ const normalizeFloat = (value, step = 1, valueDef = 0) => { } return stepDecimals ? parseFloat(value.toFixed(stepDecimals)) : value; -} +}; +const hasDnd = em => { + return ( + 'draggable' in document.createElement('i') && + (em ? em.get('Config').nativeDnD : 1) + ); +}; export { on, off, + hasDnd, upFirst, matches, camelCase, shallowDiff, normalizeFloat, getUnitFromValue -} +}; diff --git a/src/utils/polyfills.js b/src/utils/polyfills.js index eb5449044..9b6a6e179 100644 --- a/src/utils/polyfills.js +++ b/src/utils/polyfills.js @@ -4,7 +4,6 @@ */ export default () => { - /** * Check if IE/Edge * @return {Boolean} @@ -13,10 +12,10 @@ export default () => { let match; const agent = window.navigator.userAgent; const rules = [ - [ 'edge', /Edge\/([0-9\._]+)/ ], - [ 'ie', /MSIE\s(7\.0)/ ], - [ 'ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/ ], - [ 'ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/ ], + ['edge', /Edge\/([0-9\._]+)/], + ['ie', /MSIE\s(7\.0)/], + ['ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ['ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/] ]; for (let i = 0; i < rules.length; i++) { @@ -26,13 +25,14 @@ export default () => { } return !!match; - } + }; if (isIE()) { - const originalCreateHTMLDocument = DOMImplementation.prototype.createHTMLDocument - DOMImplementation.prototype.createHTMLDocument = (title) => { + const originalCreateHTMLDocument = + DOMImplementation.prototype.createHTMLDocument; + DOMImplementation.prototype.createHTMLDocument = title => { if (!title) title = ''; return originalCreateHTMLDocument.apply(document.implementation, [title]); - } + }; } -} +}; diff --git a/test/helper.js b/test/helper.js index 7a590681b..1a7db08bc 100644 --- a/test/helper.js +++ b/test/helper.js @@ -39,9 +39,9 @@ global.Backbone = require('backbone'); global.localStorage = localStorage; global.SVGElement = global.Element; window.$ = Backbone.$; -global.navigator = {userAgent: 'node.js'}; +global.navigator = { userAgent: 'node.js' }; -Object.keys(window).forEach((key) => { +Object.keys(window).forEach(key => { if (!(key in global)) { global[key] = window[key]; } diff --git a/test/main.js b/test/main.js index d345e69b2..a5aa5ebc8 100644 --- a/test/main.js +++ b/test/main.js @@ -1,7 +1,6 @@ //import grapesjs from './../src'; describe('Main', () => { - describe('Startup', () => { it('Main object should be loaded', () => { expect(grapesjs).toExist(); diff --git a/test/specs/asset_manager/index.js b/test/specs/asset_manager/index.js index 5025642ad..2a043a4eb 100644 --- a/test/specs/asset_manager/index.js +++ b/test/specs/asset_manager/index.js @@ -3,9 +3,7 @@ var AssetManager = require('asset_manager'); var FileUploader = require('./view/FileUploader'); describe('Asset Manager', () => { - describe('Main', () => { - var obj; var imgObj; @@ -17,7 +15,7 @@ describe('Asset Manager', () => { }, load(keys) { return storage; - }, + } }; beforeEach(() => { @@ -26,7 +24,7 @@ describe('Asset Manager', () => { type: 'image', src: 'path/to/image', width: 101, - height: 102, + height: 102 }; obj = new AssetManager(); obj.init(); @@ -86,7 +84,6 @@ describe('Asset Manager', () => { }); describe('With storage', () => { - var storageManager; beforeEach(() => { @@ -94,9 +91,9 @@ describe('Asset Manager', () => { storageManager = new StorageManager().init({ autoload: 0, type: storageId - }) + }); obj = new AssetManager().init({ - stm: storageManager, + stm: storageManager }); storageManager.add(storageId, storageMock); document.body.querySelector('#asset-c').appendChild(obj.render()); @@ -110,15 +107,13 @@ describe('Asset Manager', () => { obj.add(imgObj); obj.store(); obj.remove(imgObj.src); - obj.load({assets: storage['gjs-assets']}); + obj.load({ assets: storage['gjs-assets'] }); var asset = obj.get(imgObj.src); expect(asset.get('width')).toEqual(imgObj.width); expect(asset.get('height')).toEqual(imgObj.height); expect(asset.get('type')).toEqual('image'); }); - }); - }); require('./model/Asset').run(); diff --git a/test/specs/asset_manager/model/Asset.js b/test/specs/asset_manager/model/Asset.js index 5f46eda21..091c887a8 100644 --- a/test/specs/asset_manager/model/Asset.js +++ b/test/specs/asset_manager/model/Asset.js @@ -2,14 +2,13 @@ var Asset = require('asset_manager/model/Asset'); module.exports = { run() { - describe('Asset', () => { it('Object exists', () => { expect(Asset).toExist(); }); it('Has default values', () => { - var obj = new Asset({}); + var obj = new Asset({}); expect(obj.get('type')).toNotExist(); expect(obj.get('src')).toNotExist(); expect(obj.getExtension()).toNotExist(); @@ -17,18 +16,18 @@ module.exports = { }); it('Test getFilename', () => { - var obj = new Asset({ type:'image', src: 'ch/eck/t.e.s.t'}); + var obj = new Asset({ type: 'image', src: 'ch/eck/t.e.s.t' }); expect(obj.getFilename()).toEqual('t.e.s.t'); - var obj = new Asset({ type:'image', src: 'ch/eck/1234abc'}); + var obj = new Asset({ type: 'image', src: 'ch/eck/1234abc' }); expect(obj.getFilename()).toEqual('1234abc'); }); it('Test getExtension', () => { - var obj = new Asset({ type:'image', src: 'ch/eck/t.e.s.t'}); + var obj = new Asset({ type: 'image', src: 'ch/eck/t.e.s.t' }); expect(obj.getExtension()).toEqual('t'); - var obj = new Asset({ type:'image', src: 'ch/eck/1234abc.'}); + var obj = new Asset({ type: 'image', src: 'ch/eck/1234abc.' }); expect(obj.getExtension()).toEqual(''); }); }); } -} +}; diff --git a/test/specs/asset_manager/model/AssetImage.js b/test/specs/asset_manager/model/AssetImage.js index 737e32080..25409a43f 100644 --- a/test/specs/asset_manager/model/AssetImage.js +++ b/test/specs/asset_manager/model/AssetImage.js @@ -2,7 +2,6 @@ var AssetImage = require('asset_manager/model/AssetImage'); module.exports = { run() { - describe('AssetImage', () => { it('Object exists', () => { expect(AssetImage).toExist(); @@ -18,8 +17,6 @@ module.exports = { expect(obj.getExtension()).toNotExist(); expect(obj.getFilename()).toNotExist(); }); - }); - } }; diff --git a/test/specs/asset_manager/model/Assets.js b/test/specs/asset_manager/model/Assets.js index 6252ff363..545ec3013 100644 --- a/test/specs/asset_manager/model/Assets.js +++ b/test/specs/asset_manager/model/Assets.js @@ -3,7 +3,6 @@ var Assets = require('asset_manager/model/Assets'); module.exports = { run() { describe('Assets', () => { - var obj; beforeEach(() => { diff --git a/test/specs/asset_manager/view/AssetImageView.js b/test/specs/asset_manager/view/AssetImageView.js index 3afbb4b9c..58acceda4 100644 --- a/test/specs/asset_manager/view/AssetImageView.js +++ b/test/specs/asset_manager/view/AssetImageView.js @@ -7,20 +7,19 @@ module.exports = { let obj; describe('AssetImageView', () => { - - beforeEach(function () { - var coll = new Assets(); - var model = coll.add({ type:'image', src: '/test' }); + beforeEach(function() { + var coll = new Assets(); + var model = coll.add({ type: 'image', src: '/test' }); obj = new AssetImageView({ collection: new Assets(), - config : {}, + config: {}, model }); document.body.innerHTML = '
'; document.body.querySelector('#fixtures').appendChild(obj.render().el); }); - afterEach(function () { + afterEach(function() { obj = null; document.body.innerHTML = ''; }); @@ -30,22 +29,20 @@ module.exports = { }); describe('Asset should be rendered correctly', () => { + it('Has preview box', function() { + var $asset = obj.$el; + expect($asset.find('.preview').length).toEqual(1); + }); - it('Has preview box', function() { - var $asset = obj.$el; - expect($asset.find('.preview').length).toEqual(1); - }); - - it('Has meta box', function() { - var $asset = obj.$el; - expect($asset.find('.meta').length).toEqual(1); - }); - - it('Has close button', function() { - var $asset = obj.$el; - expect($asset.find('[data-toggle=asset-remove]').length).toEqual(1); - }); + it('Has meta box', function() { + var $asset = obj.$el; + expect($asset.find('.meta').length).toEqual(1); + }); + it('Has close button', function() { + var $asset = obj.$el; + expect($asset.find('[data-toggle=asset-remove]').length).toEqual(1); + }); }); it('Could be selected', function() { @@ -65,12 +62,10 @@ module.exports = { it('Could be removed', function() { var spy = sinon.spy(); - obj.model.on("remove", spy); - obj.onRemove({stopImmediatePropagation() {}}); + obj.model.on('remove', spy); + obj.onRemove({ stopImmediatePropagation() {} }); expect(spy.called).toEqual(true); }); - }); - } }; diff --git a/test/specs/asset_manager/view/AssetView.js b/test/specs/asset_manager/view/AssetView.js index 4e866d3e2..677cdf388 100644 --- a/test/specs/asset_manager/view/AssetView.js +++ b/test/specs/asset_manager/view/AssetView.js @@ -4,21 +4,21 @@ var Assets = require('asset_manager/model/Assets'); module.exports = { run() { - describe('AssetView', () => { - - beforeEach(function () { - var coll = new Assets(); - var model = coll.add({src: 'test'}); + beforeEach(function() { + var coll = new Assets(); + var model = coll.add({ src: 'test' }); this.view = new AssetView({ - config : {}, + config: {}, model }); document.body.innerHTML = '
'; - document.body.querySelector('#fixtures').appendChild(this.view.render().el); + document.body + .querySelector('#fixtures') + .appendChild(this.view.render().el); }); - afterEach(function () { + afterEach(function() { this.view.remove(); }); @@ -29,8 +29,6 @@ module.exports = { it('Has correct prefix', function() { expect(this.view.pfx).toEqual(''); }); - }); - } -} +}; diff --git a/test/specs/asset_manager/view/AssetsView.js b/test/specs/asset_manager/view/AssetsView.js index 94d13d3e2..3a1bdb843 100644 --- a/test/specs/asset_manager/view/AssetsView.js +++ b/test/specs/asset_manager/view/AssetsView.js @@ -4,13 +4,11 @@ var Assets = require('asset_manager/model/Assets'); module.exports = { run() { - describe('AssetsView', () => { - var obj; var coll; - beforeEach(function () { + beforeEach(function() { coll = new Assets([]); obj = new AssetsView({ config: {}, @@ -24,7 +22,7 @@ module.exports = { document.body.querySelector('#fixtures').appendChild(obj.el); }); - afterEach(function () { + afterEach(function() { obj.collection.reset(); }); @@ -32,60 +30,58 @@ module.exports = { expect(AssetsView).toExist(); }); - it("Collection is empty", function (){ + it('Collection is empty', function() { expect(obj.getAssetsEl().innerHTML).toNotExist(); }); - it("Add new asset", function (){ - sinon.stub(obj, "addAsset"); - coll.add({src: 'test'}); + it('Add new asset', function() { + sinon.stub(obj, 'addAsset'); + coll.add({ src: 'test' }); expect(obj.addAsset.calledOnce).toEqual(true); }); - it("Render new asset", function (){ - coll.add({src: 'test'}); + it('Render new asset', function() { + coll.add({ src: 'test' }); expect(obj.getAssetsEl().innerHTML).toExist(); }); - it("Render correctly new image asset", function (){ - coll.add({ type: 'image', src: 'test'}); + it('Render correctly new image asset', function() { + coll.add({ type: 'image', src: 'test' }); var asset = obj.getAssetsEl().firstChild; expect(asset.tagName).toEqual('DIV'); expect(asset.innerHTML).toExist(); }); - it("Clean collection from asset", function (){ - var model = coll.add({src: 'test'}); + it('Clean collection from asset', function() { + var model = coll.add({ src: 'test' }); coll.remove(model); expect(obj.getAssetsEl().innerHTML).toNotExist(); }); - it("Deselect works", function (){ - coll.add([{},{}]); + it('Deselect works', function() { + coll.add([{}, {}]); var $asset = obj.$el.children().first(); $asset.attr('class', obj.pfx + 'highlight'); coll.trigger('deselectAll'); expect($asset.attr('class')).toNotExist(); }); - it("Returns not empty assets element", () => { + it('Returns not empty assets element', () => { expect(obj.getAssetsEl()).toExist(); }); - it("Returns not empty url input", () => { + it('Returns not empty url input', () => { expect(obj.getAddInput()).toExist(); }); - it("Add image asset from input string", () => { - obj.getAddInput().value = "test"; + it('Add image asset from input string', () => { + obj.getAddInput().value = 'test'; obj.handleSubmit({ preventDefault() {} }); var asset = obj.options.globalCollection.at(0); expect(asset.get('src')).toEqual('test'); }); - }); - } -} +}; diff --git a/test/specs/asset_manager/view/FileUploader.js b/test/specs/asset_manager/view/FileUploader.js index 27a89ae0d..b7a381b80 100644 --- a/test/specs/asset_manager/view/FileUploader.js +++ b/test/specs/asset_manager/view/FileUploader.js @@ -1,20 +1,17 @@ var FileUploader = require('asset_manager/view/FileUploader'); - module.exports = { run() { - describe('File Uploader', () => { - let obj; - beforeEach(function () { - obj = new FileUploader({ config : {} }); + beforeEach(function() { + obj = new FileUploader({ config: {} }); document.body.innerHTML = '
'; document.body.querySelector('#fixtures').appendChild(obj.render().el); }); - afterEach(function () { + afterEach(function() { obj.remove(); }); @@ -27,55 +24,62 @@ module.exports = { }); describe('Should be rendered correctly', () => { - - it('Has title', function() { - expect(obj.$el.find('#title').length).toEqual(1); - }); - - it('Title is empty', function() { - expect(obj.$el.find('#title').html()).toEqual(''); - }); - - it('Has file input', function() { - expect(obj.$el.find('input[type=file]').length).toEqual(1); - }); - - it('File input is enabled', function() { - expect(obj.$el.find('input[type=file]').prop('disabled')).toEqual(true); - }); - + it('Has title', function() { + expect(obj.$el.find('#title').length).toEqual(1); + }); + + it('Title is empty', function() { + expect(obj.$el.find('#title').html()).toEqual(''); + }); + + it('Has file input', function() { + expect(obj.$el.find('input[type=file]').length).toEqual(1); + }); + + it('File input is enabled', function() { + expect(obj.$el.find('input[type=file]').prop('disabled')).toEqual( + true + ); + }); }); describe('Interprets configurations correctly', () => { - - it('Has correct title', () => { - var view = new FileUploader({ config : { - uploadText : 'Test', - } }); - view.render(); - expect(view.$el.find('#title').html()).toEqual('Test'); + it('Has correct title', () => { + var view = new FileUploader({ + config: { + uploadText: 'Test' + } }); + view.render(); + expect(view.$el.find('#title').html()).toEqual('Test'); + }); - it('Could be disabled', () => { - var view = new FileUploader({ config : { + it('Could be disabled', () => { + var view = new FileUploader({ + config: { disableUpload: true, upload: 'something' - } }); - view.render(); - expect(view.$el.find('input[type=file]').prop('disabled')).toEqual(true); + } }); - - it('Handles embedAsBase64 parameter', () => { - var view = new FileUploader({ config : { + view.render(); + expect(view.$el.find('input[type=file]').prop('disabled')).toEqual( + true + ); + }); + + it('Handles embedAsBase64 parameter', () => { + var view = new FileUploader({ + config: { embedAsBase64: true - } }); - view.render(); - expect(view.$el.find('input[type=file]').prop('disabled')).toEqual(false); - expect(view.uploadFile).toEqual(FileUploader.embedAsBase64); + } }); - + view.render(); + expect(view.$el.find('input[type=file]').prop('disabled')).toEqual( + false + ); + expect(view.uploadFile).toEqual(FileUploader.embedAsBase64); + }); }); - }); } -} +}; diff --git a/test/specs/block_manager/index.js b/test/specs/block_manager/index.js index 877f083c8..3f242729a 100644 --- a/test/specs/block_manager/index.js +++ b/test/specs/block_manager/index.js @@ -2,9 +2,7 @@ var BlockManager = require('block_manager'); var BlocksView = require('./view/BlocksView'); describe('BlockManager', () => { - describe('Main', () => { - var obj; var idTest; var optsTest; @@ -47,14 +45,14 @@ describe('BlockManager', () => { }); it('Add block with attributes', () => { - optsTest.attributes = {'class':'test'}; + optsTest.attributes = { class: 'test' }; var model = obj.add(idTest, optsTest); expect(model.get('attributes').class).toEqual('test'); }); it('The id of the block is unique', () => { var model = obj.add(idTest, optsTest); - var model2 = obj.add(idTest, {other: 'test'}); + var model2 = obj.add(idTest, { other: 'test' }); expect(model).toEqual(model2); }); @@ -68,9 +66,7 @@ describe('BlockManager', () => { obj.render(); expect(obj.getContainer()).toExist(); }); - }); BlocksView.run(); - }); diff --git a/test/specs/block_manager/view/BlocksView.js b/test/specs/block_manager/view/BlocksView.js index e324cf6dc..b956a2c90 100644 --- a/test/specs/block_manager/view/BlocksView.js +++ b/test/specs/block_manager/view/BlocksView.js @@ -4,76 +4,76 @@ var Blocks = require('block_manager/model/Blocks'); module.exports = { run() { - describe('BlocksView', () => { + describe('BlocksView', () => { + var $fixtures; + var $fixture; + var model; + var view; + var editorModel; + var ppfx; - var $fixtures; - var $fixture; - var model; - var view; - var editorModel; - var ppfx; + beforeEach(() => { + model = new Blocks([]); + view = new BlocksView({ collection: model }); + document.body.innerHTML = '
'; + document.body.querySelector('#fixtures').appendChild(view.render().el); + }); - beforeEach(() => { - model = new Blocks([]); - view = new BlocksView({ collection: model }); - document.body.innerHTML = '
'; - document.body.querySelector('#fixtures').appendChild(view.render().el); - }); + afterEach(() => { + view.collection.reset(); + }); - afterEach(() => { - view.collection.reset(); - }); + it('The container is not empty', () => { + expect(view.el.outerHTML).toExist(); + }); - it("The container is not empty", () => { - expect(view.el.outerHTML).toExist(); - }); + it('No children inside', () => { + expect(view.getBlocksEl().children.length).toEqual(0); + }); - it("No children inside", () => { - expect(view.getBlocksEl().children.length).toEqual(0); - }); + it('Render children on add', () => { + model.add({}); + expect(view.getBlocksEl().children.length).toEqual(1); + model.add([{}, {}]); + expect(view.getBlocksEl().children.length).toEqual(3); + }); - it("Render children on add", () => { - model.add({}); - expect(view.getBlocksEl().children.length).toEqual(1); - model.add([{},{}]); - expect(view.getBlocksEl().children.length).toEqual(3); + it('Destroy children on remove', () => { + model.add([{}, {}]); + expect(view.getBlocksEl().children.length).toEqual(2); + model.at(0).destroy(); + expect(view.getBlocksEl().children.length).toEqual(1); + }); + + describe('With configs', () => { + beforeEach(() => { + ppfx = 'pfx-t-'; + editorModel = new Backbone.Model(); + model = new Blocks([{ name: 'test1' }, { name: 'test2' }]); + view = new BlocksView( + { + collection: model + }, + { + pStylePrefix: ppfx + } + ); + document.body.innerHTML = '
'; + document.body + .querySelector('#fixtures') + .appendChild(view.render().el); }); - it("Destroy children on remove", () => { - model.add([{},{}]); + it('Render children', () => { expect(view.getBlocksEl().children.length).toEqual(2); - model.at(0).destroy(); - expect(view.getBlocksEl().children.length).toEqual(1); }); - describe('With configs', () => { - - beforeEach(() => { - ppfx = 'pfx-t-'; - editorModel = new Backbone.Model(); - model = new Blocks([ - {name:'test1'}, - {name:'test2'} - ]); - view = new BlocksView({ - collection: model, - },{ - pStylePrefix: ppfx - }); - document.body.innerHTML = '
'; - document.body.querySelector('#fixtures').appendChild(view.render().el); - }); - - it("Render children", () => { - expect(view.getBlocksEl().children.length).toEqual(2); - }); - - it("Render container", () => { - expect(view.getBlocksEl().getAttribute('class')).toEqual(ppfx + 'blocks-c'); - }); - + it('Render container', () => { + expect(view.getBlocksEl().getAttribute('class')).toEqual( + ppfx + 'blocks-c' + ); }); - + }); }); } }; diff --git a/test/specs/code_manager/index.js b/test/specs/code_manager/index.js index 944bcc4e7..39f514268 100644 --- a/test/specs/code_manager/index.js +++ b/test/specs/code_manager/index.js @@ -2,9 +2,7 @@ var CodeManager = require('code_manager'); var Models = require('./model/CodeModels'); describe('Code Manager', () => { - describe('Main', () => { - let obj; beforeEach(() => { @@ -36,7 +34,6 @@ describe('Code Manager', () => { obj.addViewer('test', 'view'); expect(obj.getViewer('test')).toEqual('view'); }); - }); Models.run(); diff --git a/test/specs/code_manager/model/CodeModels.js b/test/specs/code_manager/model/CodeModels.js index 636a30bf2..d625a539d 100644 --- a/test/specs/code_manager/model/CodeModels.js +++ b/test/specs/code_manager/model/CodeModels.js @@ -7,263 +7,292 @@ const CssComposer = require('css_composer'); module.exports = { run() { - let comp; - let dcomp; - let obj; - let em; - let cc; - - describe('HtmlGenerator', () => { - beforeEach(() => { - em = new Editor(); - obj = new HtmlGenerator(); - dcomp = new DomComponents(); - comp = new Component({}, { + let comp; + let dcomp; + let obj; + let em; + let cc; + + describe('HtmlGenerator', () => { + beforeEach(() => { + em = new Editor(); + obj = new HtmlGenerator(); + dcomp = new DomComponents(); + comp = new Component( + {}, + { em, - componentTypes: dcomp.componentTypes, - }); + componentTypes: dcomp.componentTypes + } + ); + }); + + afterEach(() => { + obj = null; + }); + + it('Build correctly one component', () => { + expect(obj.build(comp)).toEqual(''); + }); + + it('Build correctly empty component inside', () => { + var m1 = comp.get('components').add({}); + expect(obj.build(comp)).toEqual('
'); + }); + + it('Build correctly not empty component inside', () => { + var m1 = comp.get('components').add({ + tagName: 'article', + attributes: { + 'data-test1': 'value1', + 'data-test2': 'value2' + } }); - - afterEach(() => { - obj = null; + expect(obj.build(comp)).toEqual( + '
' + ); + }); + + it('Build correctly component with classes', () => { + var m1 = comp.get('components').add({ + tagName: 'article', + attributes: { + 'data-test1': 'value1', + 'data-test2': 'value2' + } }); - - it('Build correctly one component', () => { - expect(obj.build(comp)).toEqual(''); - - }); - - it('Build correctly empty component inside', () => { - var m1 = comp.get('components').add({}); - expect(obj.build(comp)).toEqual('
'); - }); - - it('Build correctly not empty component inside', () => { - var m1 = comp.get('components').add({ - tagName: 'article', - attributes: { - 'data-test1': 'value1', - 'data-test2': 'value2' - } - }); - expect(obj.build(comp)).toEqual('
'); - }); - - it('Build correctly component with classes', () => { - var m1 = comp.get('components').add({ - tagName: 'article', - attributes: { - 'data-test1': 'value1', - 'data-test2': 'value2' - } - }); - ['class1', 'class2'].forEach(item => { - m1.get('classes').add({name: item}); - }); - expect(obj.build(comp)).toEqual('
'); + ['class1', 'class2'].forEach(item => { + m1.get('classes').add({ name: item }); }); + expect(obj.build(comp)).toEqual( + '
' + ); + }); }); describe('CssGenerator', () => { - var newCssComp = () => new CssComposer().init(); - beforeEach(() => { - em = new Editor({}); - cc = em.get('CssComposer'); - obj = new CssGenerator(); - dcomp = new DomComponents(); - comp = new Component({}, { + var newCssComp = () => new CssComposer().init(); + beforeEach(() => { + em = new Editor({}); + cc = em.get('CssComposer'); + obj = new CssGenerator(); + dcomp = new DomComponents(); + comp = new Component( + {}, + { em, - componentTypes: dcomp.componentTypes, - }); - }); - - afterEach(() => { - obj = null; - }); - - it('Build correctly one component', () => { - expect(obj.build(comp)).toEqual(''); - }); - - it('Build correctly empty component inside', () => { - var m1 = comp.get('components').add({tagName: 'article'}); - expect(obj.build(comp)).toEqual(''); - }); - - it('Build correctly component with style inside', () => { - var m1 = comp.get('components').add({ - tagName: 'article', - style: { - 'prop1': 'value1', - 'prop2': 'value2' - } - }); - expect(obj.build(comp)).toEqual('#' + m1.cid +'{prop1:value1;prop2:value2;}'); + componentTypes: dcomp.componentTypes + } + ); + }); + + afterEach(() => { + obj = null; + }); + + it('Build correctly one component', () => { + expect(obj.build(comp)).toEqual(''); + }); + + it('Build correctly empty component inside', () => { + var m1 = comp.get('components').add({ tagName: 'article' }); + expect(obj.build(comp)).toEqual(''); + }); + + it('Build correctly component with style inside', () => { + var m1 = comp.get('components').add({ + tagName: 'article', + style: { + prop1: 'value1', + prop2: 'value2' + } }); - - it('Build correctly component with class styled', () => { - var m1 = comp.get('components').add({tagName: 'article'}); - var cls1 = m1.get('classes').add({name: 'class1'}); - - var cssc = newCssComp(); - var rule = cssc.add(cls1); - rule.set('style',{'prop1':'value1', 'prop2':'value2'}); - - expect(obj.build(comp, {cssc})).toEqual('.class1{prop1:value1;prop2:value2;}'); - }); - - it('Build correctly component styled with class and state', () => { - var m1 = comp.get('components').add({tagName: 'article'}); - var cls1 = m1.get('classes').add({name: 'class1'}); - - var cssc = newCssComp(); - var rule = cssc.add(cls1); - rule.set('style',{'prop1':'value1', 'prop2':'value2'}); - rule.set('state', 'hover'); - - expect(obj.build(comp, {cssc})).toEqual('.class1:hover{prop1:value1;prop2:value2;}'); - }); - - - it('Build correctly with more classes', () => { - var m1 = comp.get('components').add({tagName: 'article'}); - var cls1 = m1.get('classes').add({name: 'class1'}); - var cls2 = m1.get('classes').add({name: 'class2'}); - - var cssc = newCssComp(); - var rule = cssc.add([cls1, cls2]); - rule.set('style',{'prop1':'value1', 'prop2':'value2'}); - - expect(obj.build(comp, {cssc})).toEqual('.class1.class2{prop1:value1;prop2:value2;}'); - }); - - it('Build rules with mixed classes', () => { - var m1 = comp.get('components').add({tagName: 'article'}); - var cls1 = m1.get('classes').add({name: 'class1'}); - var cls2 = m1.get('classes').add({name: 'class2'}); - - var cssc = newCssComp(); - var rule = cssc.add([cls1, cls2]); - rule.set('style',{'prop1':'value1', 'prop2':'value2'}); - rule.set('selectorsAdd', '.class1 .class2, div > .class4'); - - expect(obj.build(comp, {cssc})).toEqual('.class1.class2, .class1 .class2, div > .class4{prop1:value1;prop2:value2;}'); - }); - - it('Build rules with only not class based selectors', () => { - var cssc = newCssComp(); - var rule = cssc.add([]); - rule.set('style',{'prop1':'value1', 'prop2':'value2'}); - rule.set('selectorsAdd', '.class1 .class2, div > .class4'); - - expect(obj.build(comp, {cssc})).toEqual('.class1 .class2, div > .class4{prop1:value1;prop2:value2;}'); - }); - - it('Build correctly with class styled out', () => { - var m1 = comp.get('components').add({tagName: 'article'}); - var cls1 = m1.get('classes').add({name: 'class1'}); - var cls2 = m1.get('classes').add({name: 'class2'}); - - var cssc = newCssComp(); - var rule = cssc.add([cls1, cls2]); - rule.set('style',{'prop1':'value1'}); - var rule2 = cssc.add(cls2); - rule2.set('style',{'prop2':'value2'}); - - expect(obj.build(comp, {cssc})).toEqual('.class1.class2{prop1:value1;}.class2{prop2:value2;}'); - }); - - it('Rule with media query', () => { - var m1 = comp.get('components').add({tagName: 'article'}); - var cls1 = m1.get('classes').add({name: 'class1'}); - var cls2 = m1.get('classes').add({name: 'class2'}); - - var cssc = newCssComp(); - var rule = cssc.add([cls1, cls2]); - rule.set('style',{'prop1':'value1'}); - rule.set('mediaText', '(max-width: 999px)'); - - expect(obj.build(comp, {cssc})).toEqual('@media (max-width: 999px){.class1.class2{prop1:value1;}}'); - }); - - it('Rules mixed with media queries', () => { - var m1 = comp.get('components').add({tagName: 'article'}); - var cls1 = m1.get('classes').add({name: 'class1'}); - var cls2 = m1.get('classes').add({name: 'class2'}); - - var cssc = newCssComp(); - - var rule = cssc.add([cls1, cls2]); - rule.set('style',{'prop1':'value1'}); - var rule2 = cssc.add(cls2); - rule2.set('style',{'prop2':'value2'}); - - var rule3 = cssc.add(cls1, '', '(max-width: 999px)'); - rule3.set('style',{'prop3':'value3'}); - var rule4 = cssc.add(cls2, '', '(max-width: 999px)'); - rule4.set('style',{'prop4':'value4'}); - - var rule5 = cssc.add(cls1, '', '(max-width: 100px)'); - rule5.set('style',{'prop5':'value5'}); - - expect(obj.build(comp, {cssc})).toEqual('.class1.class2{prop1:value1;}.class2{prop2:value2;}'+ - '@media (max-width: 999px){.class1{prop3:value3;}.class2{prop4:value4;}}'+ - '@media (max-width: 100px){.class1{prop5:value5;}}'); - }); - - it('Avoid useless code', () => { - var m1 = comp.get('components').add({tagName: 'article'}); - var cls1 = m1.get('classes').add({name: 'class1'}); - - var cssc = newCssComp(); - var rule = cssc.add(cls1); - rule.set('style',{'prop1':'value1', 'prop2':'value2'}); - - comp.get('components').remove(m1); - expect(obj.build(comp, {cssc})).toEqual(''); - }); - - it('Render correctly a rule without avoidInlineStyle option', () => { - comp.setStyle({color: 'red'}); - const id = comp.getId(); - const result = `#${id}{color:red;}`; - expect(obj.build(comp, {cssc: cc})).toEqual(result); - }); - - it('Render correctly a rule with avoidInlineStyle option', () => { - em.getConfig().avoidInlineStyle = 1; - comp = new Component({}, { + expect(obj.build(comp)).toEqual( + '#' + m1.getId() + '{prop1:value1;prop2:value2;}' + ); + }); + + it('Build correctly component with class styled', () => { + var m1 = comp.get('components').add({ tagName: 'article' }); + var cls1 = m1.get('classes').add({ name: 'class1' }); + + var cssc = newCssComp(); + var rule = cssc.add(cls1); + rule.set('style', { prop1: 'value1', prop2: 'value2' }); + + expect(obj.build(comp, { cssc })).toEqual( + '.class1{prop1:value1;prop2:value2;}' + ); + }); + + it('Build correctly component styled with class and state', () => { + var m1 = comp.get('components').add({ tagName: 'article' }); + var cls1 = m1.get('classes').add({ name: 'class1' }); + + var cssc = newCssComp(); + var rule = cssc.add(cls1); + rule.set('style', { prop1: 'value1', prop2: 'value2' }); + rule.set('state', 'hover'); + + expect(obj.build(comp, { cssc })).toEqual( + '.class1:hover{prop1:value1;prop2:value2;}' + ); + }); + + it('Build correctly with more classes', () => { + var m1 = comp.get('components').add({ tagName: 'article' }); + var cls1 = m1.get('classes').add({ name: 'class1' }); + var cls2 = m1.get('classes').add({ name: 'class2' }); + + var cssc = newCssComp(); + var rule = cssc.add([cls1, cls2]); + rule.set('style', { prop1: 'value1', prop2: 'value2' }); + + expect(obj.build(comp, { cssc })).toEqual( + '.class1.class2{prop1:value1;prop2:value2;}' + ); + }); + + it('Build rules with mixed classes', () => { + var m1 = comp.get('components').add({ tagName: 'article' }); + var cls1 = m1.get('classes').add({ name: 'class1' }); + var cls2 = m1.get('classes').add({ name: 'class2' }); + + var cssc = newCssComp(); + var rule = cssc.add([cls1, cls2]); + rule.set('style', { prop1: 'value1', prop2: 'value2' }); + rule.set('selectorsAdd', '.class1 .class2, div > .class4'); + + expect(obj.build(comp, { cssc })).toEqual( + '.class1.class2, .class1 .class2, div > .class4{prop1:value1;prop2:value2;}' + ); + }); + + it('Build rules with only not class based selectors', () => { + var cssc = newCssComp(); + var rule = cssc.add([]); + rule.set('style', { prop1: 'value1', prop2: 'value2' }); + rule.set('selectorsAdd', '.class1 .class2, div > .class4'); + + expect(obj.build(comp, { cssc })).toEqual( + '.class1 .class2, div > .class4{prop1:value1;prop2:value2;}' + ); + }); + + it('Build correctly with class styled out', () => { + var m1 = comp.get('components').add({ tagName: 'article' }); + var cls1 = m1.get('classes').add({ name: 'class1' }); + var cls2 = m1.get('classes').add({ name: 'class2' }); + + var cssc = newCssComp(); + var rule = cssc.add([cls1, cls2]); + rule.set('style', { prop1: 'value1' }); + var rule2 = cssc.add(cls2); + rule2.set('style', { prop2: 'value2' }); + + expect(obj.build(comp, { cssc })).toEqual( + '.class1.class2{prop1:value1;}.class2{prop2:value2;}' + ); + }); + + it('Rule with media query', () => { + var m1 = comp.get('components').add({ tagName: 'article' }); + var cls1 = m1.get('classes').add({ name: 'class1' }); + var cls2 = m1.get('classes').add({ name: 'class2' }); + + var cssc = newCssComp(); + var rule = cssc.add([cls1, cls2]); + rule.set('style', { prop1: 'value1' }); + rule.set('mediaText', '(max-width: 999px)'); + + expect(obj.build(comp, { cssc })).toEqual( + '@media (max-width: 999px){.class1.class2{prop1:value1;}}' + ); + }); + + it('Rules mixed with media queries', () => { + var m1 = comp.get('components').add({ tagName: 'article' }); + var cls1 = m1.get('classes').add({ name: 'class1' }); + var cls2 = m1.get('classes').add({ name: 'class2' }); + + var cssc = newCssComp(); + + var rule = cssc.add([cls1, cls2]); + rule.set('style', { prop1: 'value1' }); + var rule2 = cssc.add(cls2); + rule2.set('style', { prop2: 'value2' }); + + var rule3 = cssc.add(cls1, '', '(max-width: 999px)'); + rule3.set('style', { prop3: 'value3' }); + var rule4 = cssc.add(cls2, '', '(max-width: 999px)'); + rule4.set('style', { prop4: 'value4' }); + + var rule5 = cssc.add(cls1, '', '(max-width: 100px)'); + rule5.set('style', { prop5: 'value5' }); + + expect(obj.build(comp, { cssc })).toEqual( + '.class1.class2{prop1:value1;}.class2{prop2:value2;}' + + '@media (max-width: 999px){.class1{prop3:value3;}.class2{prop4:value4;}}' + + '@media (max-width: 100px){.class1{prop5:value5;}}' + ); + }); + + it('Avoid useless code', () => { + var m1 = comp.get('components').add({ tagName: 'article' }); + var cls1 = m1.get('classes').add({ name: 'class1' }); + + var cssc = newCssComp(); + var rule = cssc.add(cls1); + rule.set('style', { prop1: 'value1', prop2: 'value2' }); + + comp.get('components').remove(m1); + expect(obj.build(comp, { cssc })).toEqual(''); + }); + + it('Render correctly a rule without avoidInlineStyle option', () => { + comp.setStyle({ color: 'red' }); + const id = comp.getId(); + const result = `#${id}{color:red;}`; + expect(obj.build(comp, { cssc: cc })).toEqual(result); + }); + + it('Render correctly a rule with avoidInlineStyle option', () => { + em.getConfig().avoidInlineStyle = 1; + comp = new Component( + {}, + { em, - componentTypes: dcomp.componentTypes, - }); - comp.setStyle({color: 'red'}); - const id = comp.getId(); - const result = `#${id}{color:red;}`; - expect(obj.build(comp, {cssc: cc, em})).toEqual(result); - }); - - it('Render correctly a rule with avoidInlineStyle and state', () => { - em.getConfig().avoidInlineStyle = 1; - const state = 'hover'; - comp.config.avoidInlineStyle = 1; - comp.set('state', state); - comp.setStyle({color: 'red'}); - const id = comp.getId(); - const result = `#${id}:${state}{color:red;}`; - expect(obj.build(comp, {cssc: cc, em})).toEqual(result); - }); - - it('Render correctly a rule with avoidInlineStyle and w/o state', () => { - em.getConfig().avoidInlineStyle = 1; - const state = 'hover'; - comp.config.avoidInlineStyle = 1; - comp.setStyle({color: 'blue'}); - comp.set('state', state); - comp.setStyle({color: 'red'}); - const id = comp.getId(); - const result = `#${id}{color:blue;}#${id}:${state}{color:red;}`; - expect(obj.build(comp, {cssc: cc, em})).toEqual(result); - }); - }) + componentTypes: dcomp.componentTypes + } + ); + comp.setStyle({ color: 'red' }); + const id = comp.getId(); + const result = `#${id}{color:red;}`; + expect(obj.build(comp, { cssc: cc, em })).toEqual(result); + }); + + it('Render correctly a rule with avoidInlineStyle and state', () => { + em.getConfig().avoidInlineStyle = 1; + const state = 'hover'; + comp.config.avoidInlineStyle = 1; + comp.set('state', state); + comp.setStyle({ color: 'red' }); + const id = comp.getId(); + const result = `#${id}:${state}{color:red;}`; + expect(obj.build(comp, { cssc: cc, em })).toEqual(result); + }); + + it('Render correctly a rule with avoidInlineStyle and w/o state', () => { + em.getConfig().avoidInlineStyle = 1; + const state = 'hover'; + comp.config.avoidInlineStyle = 1; + comp.setStyle({ color: 'blue' }); + comp.set('state', state); + comp.setStyle({ color: 'red' }); + const id = comp.getId(); + const result = `#${id}{color:blue;}#${id}:${state}{color:red;}`; + expect(obj.build(comp, { cssc: cc, em })).toEqual(result); + }); + }); } }; diff --git a/test/specs/commands/index.js b/test/specs/commands/index.js index 42316ad43..dc09a0b61 100644 --- a/test/specs/commands/index.js +++ b/test/specs/commands/index.js @@ -2,9 +2,7 @@ var Commands = require('commands'); var Models = require('./model/CommandModels'); describe('Commands', () => { - describe('Main', () => { - let obj; beforeEach(() => { @@ -20,7 +18,7 @@ describe('Commands', () => { }); it('Push new command', () => { - var comm = { test: 'test'}; + var comm = { test: 'test' }; obj.add('test', comm); expect(obj.get('test').test).toEqual('test'); }); @@ -59,9 +57,7 @@ describe('Commands', () => { it('Commands module should not have toLoad property', () => { expect(obj.toLoad).toEqual(null); }); - }); - }); Models.run(); diff --git a/test/specs/commands/model/CommandModels.js b/test/specs/commands/model/CommandModels.js index b31179dd6..fd94204e2 100644 --- a/test/specs/commands/model/CommandModels.js +++ b/test/specs/commands/model/CommandModels.js @@ -17,7 +17,6 @@ module.exports = { it('Has id property', () => { expect(obj.has('id')).toEqual(true); }); - }); describe('Commands', () => { @@ -34,8 +33,6 @@ module.exports = { it('Object is ok', () => { expect(obj).toExist(); }); - }); - } }; diff --git a/test/specs/css_composer/e2e/CssComposer.js b/test/specs/css_composer/e2e/CssComposer.js index fab1e33d8..ed7675446 100644 --- a/test/specs/css_composer/e2e/CssComposer.js +++ b/test/specs/css_composer/e2e/CssComposer.js @@ -2,208 +2,213 @@ const $ = Backbone.$; module.exports = { run() { - describe('E2E tests', () => { - var fixtures; - var fixture; - var gjs; - var cssc; - var clsm; - var domc; - var rulesSet; - var rulesSet2; - - before(() => { - fixtures = $("#fixtures"); - fixture = $('
'); - }); + describe('E2E tests', () => { + var fixtures; + var fixture; + var gjs; + var cssc; + var clsm; + var domc; + var rulesSet; + var rulesSet2; + + before(() => { + fixtures = $('#fixtures'); + fixture = $('
'); + }); - beforeEach(done => { - //this.timeout(5000); - gjs = grapesjs.init({ - stylePrefix: '', - storageManager: { autoload: 0, type:'none' }, - assetManager: { storageType: 'none', }, - container: 'csscomposer-fixture', - }); - cssc = gjs.CssComposer; - clsm = gjs.SelectorManager; - domc = gjs.DomComponents; - fixture.empty().appendTo(fixtures); - gjs.render(); - rulesSet = [ - { selectors: [{name: 'test1'}, {name: 'test2'}] }, - { selectors: [{name: 'test2'}, {name: 'test3'}] }, - { selectors: [{name: 'test3'}] } - ]; - rulesSet2 = [ - { selectors: [{name: 'test1'}, {name: 'test2'}], state:':active' }, - { selectors: [{name: 'test2'}, {name: 'test3'}] }, - { selectors: [{name: 'test3'}], mediaText:'(max-width: 900px)' } - ]; - done(); + beforeEach(done => { + //this.timeout(5000); + gjs = grapesjs.init({ + stylePrefix: '', + storageManager: { autoload: 0, type: 'none' }, + assetManager: { storageType: 'none' }, + container: 'csscomposer-fixture' }); + cssc = gjs.CssComposer; + clsm = gjs.SelectorManager; + domc = gjs.DomComponents; + fixture.empty().appendTo(fixtures); + gjs.render(); + rulesSet = [ + { selectors: [{ name: 'test1' }, { name: 'test2' }] }, + { selectors: [{ name: 'test2' }, { name: 'test3' }] }, + { selectors: [{ name: 'test3' }] } + ]; + rulesSet2 = [ + { + selectors: [{ name: 'test1' }, { name: 'test2' }], + state: ':active' + }, + { selectors: [{ name: 'test2' }, { name: 'test3' }] }, + { selectors: [{ name: 'test3' }], mediaText: '(max-width: 900px)' } + ]; + done(); + }); - afterEach(() => { - gjs = null; - cssc = null; - clsm = null; - }); + afterEach(() => { + gjs = null; + cssc = null; + clsm = null; + }); - after(() => { - fixture.remove(); - }); + after(() => { + fixture.remove(); + }); - it('Rules are correctly imported from default property', () => { - var gj = grapesjs.init({ - stylePrefix: '', - storageManager: {autoload: 0, type:'none'}, - cssComposer: {rules: rulesSet}, - container: 'csscomposer-fixture', - }); - var cssc = gj.editor.get('CssComposer'); - expect(cssc.getAll().length).toEqual(rulesSet.length); - var cls = gj.editor.get('SelectorManager').getAll(); - expect(cls.length).toEqual(3); + it('Rules are correctly imported from default property', () => { + var gj = grapesjs.init({ + stylePrefix: '', + storageManager: { autoload: 0, type: 'none' }, + cssComposer: { rules: rulesSet }, + container: 'csscomposer-fixture' }); + var cssc = gj.editor.get('CssComposer'); + expect(cssc.getAll().length).toEqual(rulesSet.length); + var cls = gj.editor.get('SelectorManager').getAll(); + expect(cls.length).toEqual(3); + }); + it('New rule adds correctly the class inside selector manager', () => { + var rules = cssc.getAll(); + rules.add({ selectors: [{ name: 'test1', private: true }] }); + var rule = clsm.getAll().at(0); + expect(rule.get('name')).toEqual('test1'); + expect(rule.get('private')).toEqual(true); + }); - it('New rule adds correctly the class inside selector manager', () => { - var rules = cssc.getAll(); - rules.add({ selectors: [{name: 'test1', private: true}] }); - var rule = clsm.getAll().at(0); - expect(rule.get('name')).toEqual('test1'); - expect(rule.get('private')).toEqual(true); - }); - - it('New rules are correctly imported inside selector manager', () => { - var rules = cssc.getAll(); - rulesSet.forEach(item => { - rules.add(item); - }); - var cls = clsm.getAll(); - expect(cls.length).toEqual(3); - expect(cls.at(0).get('name')).toEqual('test1'); - expect(cls.at(1).get('name')).toEqual('test2'); - expect(cls.at(2).get('name')).toEqual('test3'); + it('New rules are correctly imported inside selector manager', () => { + var rules = cssc.getAll(); + rulesSet.forEach(item => { + rules.add(item); }); + var cls = clsm.getAll(); + expect(cls.length).toEqual(3); + expect(cls.at(0).get('name')).toEqual('test1'); + expect(cls.at(1).get('name')).toEqual('test2'); + expect(cls.at(2).get('name')).toEqual('test3'); + }); - it('Add rules from the new component added as a string with style tag', () => { - var comps = domc.getComponents(); - var rules = cssc.getAll(); - comps.add("
Test
"); - expect(comps.length).toEqual(1); - expect(rules.length).toEqual(2); - }); + it('Add rules from the new component added as a string with style tag', () => { + var comps = domc.getComponents(); + var rules = cssc.getAll(); + comps.add( + '
Test
' + ); + expect(comps.length).toEqual(1); + expect(rules.length).toEqual(2); + }); - it('Add raw rule objects with addCollection', () => { - cssc.addCollection(rulesSet); - expect(cssc.getAll().length).toEqual(3); - expect(clsm.getAll().length).toEqual(3); - }); + it('Add raw rule objects with addCollection', () => { + cssc.addCollection(rulesSet); + expect(cssc.getAll().length).toEqual(3); + expect(clsm.getAll().length).toEqual(3); + }); - it('Add raw rule objects twice with addCollection do not duplucate rules', () => { - var rulesSet2Copy = JSON.parse(JSON.stringify(rulesSet2)); - var coll1 = cssc.addCollection(rulesSet2); - var coll2 = cssc.addCollection(rulesSet2Copy); - expect(cssc.getAll().length).toEqual(3); - expect(clsm.getAll().length).toEqual(3); - expect(coll1).toEqual(coll2); - }); + it('Add raw rule objects twice with addCollection do not duplucate rules', () => { + var rulesSet2Copy = JSON.parse(JSON.stringify(rulesSet2)); + var coll1 = cssc.addCollection(rulesSet2); + var coll2 = cssc.addCollection(rulesSet2Copy); + expect(cssc.getAll().length).toEqual(3); + expect(clsm.getAll().length).toEqual(3); + expect(coll1).toEqual(coll2); + }); - it("Extend css rule style, if requested", () => { - var style1 = {color: 'red', width: '10px'}; - var style2 = {height: '20px', width: '20px'}; - var rule1 = { - selectors: ['test1'], - style: style1, - }; - var rule2 = { - selectors: ['test1'], - style: style2, - }; - var ruleOut = cssc.addCollection(rule1)[0]; - // ruleOut is a Model - ruleOut = JSON.parse(JSON.stringify(ruleOut)); - var ruleResult = { - mediaText: '', - selectors: [{ - active: true, - label: 'test1', - name: 'test1', - type: clsm.Selector.TYPE_CLASS, - private: false, - protected: false, - }], - important: 0, - selectorsAdd: '', - state: '', - stylable: true, - style: { - color: 'red', - width: '10px' + it('Extend css rule style, if requested', () => { + var style1 = { color: 'red', width: '10px' }; + var style2 = { height: '20px', width: '20px' }; + var rule1 = { + selectors: ['test1'], + style: style1 + }; + var rule2 = { + selectors: ['test1'], + style: style2 + }; + var ruleOut = cssc.addCollection(rule1)[0]; + // ruleOut is a Model + ruleOut = JSON.parse(JSON.stringify(ruleOut)); + var ruleResult = { + mediaText: '', + selectors: [ + { + active: true, + label: 'test1', + name: 'test1', + type: clsm.Selector.TYPE_CLASS, + private: false, + protected: false } - }; - expect(ruleOut).toEqual(ruleResult); - var ruleOut = cssc.addCollection(rule2, {extend: 1})[0]; - ruleOut = JSON.parse(JSON.stringify(ruleOut)); - ruleResult.style = { + ], + important: 0, + selectorsAdd: '', + state: '', + stylable: true, + style: { color: 'red', - height: '20px', - width: '20px', + width: '10px' } - expect(ruleOut).toEqual(ruleResult); - - }); + }; + expect(ruleOut).toEqual(ruleResult); + var ruleOut = cssc.addCollection(rule2, { extend: 1 })[0]; + ruleOut = JSON.parse(JSON.stringify(ruleOut)); + ruleResult.style = { + color: 'red', + height: '20px', + width: '20px' + }; + expect(ruleOut).toEqual(ruleResult); + }); - it("Do not extend with different selectorsAdd", () => { - var style1 = {color: 'red', width: '10px'}; - var style2 = {height: '20px', width: '20px'}; - var rule1 = { - selectors: [], - selectorsAdd: '*', - style: style1, - }; - var rule2 = { - selectors: [], - selectorsAdd: 'p', - style: style2, - }; - var rule1Out = cssc.addCollection(rule1, {extend: 1})[0]; - var rule2Out = cssc.addCollection(rule2, {extend: 1})[0]; - rule1Out = JSON.parse(JSON.stringify(rule1Out)); - rule2Out = JSON.parse(JSON.stringify(rule2Out)); - var rule1Result = { - important: 0, - mediaText: '', - selectors: [], - selectorsAdd: '*', - state: '', - stylable: true, - style: { - color: 'red', - width: '10px' - } - }; - var rule2Result = { - important: 0, - mediaText: '', - selectors: [], - selectorsAdd: 'p', - state: '', - stylable: true, - style: { - height: '20px', - width: '20px', - } - }; - expect(rule1Out).toEqual(rule1Result); - expect(rule2Out).toEqual(rule2Result); - }); + it('Do not extend with different selectorsAdd', () => { + var style1 = { color: 'red', width: '10px' }; + var style2 = { height: '20px', width: '20px' }; + var rule1 = { + selectors: [], + selectorsAdd: '*', + style: style1 + }; + var rule2 = { + selectors: [], + selectorsAdd: 'p', + style: style2 + }; + var rule1Out = cssc.addCollection(rule1, { extend: 1 })[0]; + var rule2Out = cssc.addCollection(rule2, { extend: 1 })[0]; + rule1Out = JSON.parse(JSON.stringify(rule1Out)); + rule2Out = JSON.parse(JSON.stringify(rule2Out)); + var rule1Result = { + important: 0, + mediaText: '', + selectors: [], + selectorsAdd: '*', + state: '', + stylable: true, + style: { + color: 'red', + width: '10px' + } + }; + var rule2Result = { + important: 0, + mediaText: '', + selectors: [], + selectorsAdd: 'p', + state: '', + stylable: true, + style: { + height: '20px', + width: '20px' + } + }; + expect(rule1Out).toEqual(rule1Result); + expect(rule2Out).toEqual(rule2Result); + }); - it('Add raw rule objects with width via addCollection', () => { - var coll1 = cssc.addCollection(rulesSet2); - expect(coll1[2].get('mediaText')).toEqual(rulesSet2[2].mediaText); - }); + it('Add raw rule objects with width via addCollection', () => { + var coll1 = cssc.addCollection(rulesSet2); + expect(coll1[2].get('mediaText')).toEqual(rulesSet2[2].mediaText); }); + }); } }; diff --git a/test/specs/css_composer/index.js b/test/specs/css_composer/index.js index 80767c75e..79d416291 100644 --- a/test/specs/css_composer/index.js +++ b/test/specs/css_composer/index.js @@ -7,15 +7,15 @@ const utils = require('./../test_utils.js'); const Editor = require('editor/model/Editor'); describe('Css Composer', () => { - describe('Main', () => { - var obj; var em; var config; var storagMock = utils.storageMock(); var editorModel = { - getCss() {return 'testCss';}, + getCss() { + return 'testCss'; + }, getCacheLoad() { return storagMock.load(); } @@ -23,19 +23,18 @@ describe('Css Composer', () => { var setSmConfig = () => { config.stm = storagMock; - config.stm.getConfig = () => ({ + config.stm.getConfig = () => ({ storeCss: 1, storeStyles: 1 }); }; var setEm = () => { config.em = editorModel; - } - + }; beforeEach(() => { em = new Editor({}); - config = {em}; + config = { em }; obj = new CssComposer().init(config); }); @@ -59,68 +58,75 @@ describe('Css Composer', () => { it('Store data', () => { setSmConfig(); setEm(); - var expected = { css: 'testCss', styles: '[]',}; + var expected = { css: 'testCss', styles: '[]' }; expect(obj.store(1)).toEqual(expected); }); - it("Rules are empty", () => { + it('Rules are empty', () => { expect(obj.getAll().length).toEqual(0); }); it('Create new rule with correct selectors', () => { var sel = new obj.Selectors(); - var s1 = sel.add({name: 'test1'}); + var s1 = sel.add({ name: 'test1' }); var rule = obj.add(sel.models); expect(rule.get('selectors').at(0)).toEqual(s1); }); it('Create new rule correctly', () => { var sel = new obj.Selectors(); - var s1 = sel.add({name: 'test1'}); + var s1 = sel.add({ name: 'test1' }); var rule = obj.add(sel.models, 'state1', 'width1'); expect(rule.get('state')).toEqual('state1'); expect(rule.get('mediaText')).toEqual('width1'); }); - it("Add rule to collection", () => { - var sel = new obj.Selectors([{name: 'test1'}]); + it('Add rule to collection', () => { + var sel = new obj.Selectors([{ name: 'test1' }]); var rule = obj.add(sel.models); expect(obj.getAll().length).toEqual(1); - expect(obj.getAll().at(0).get('selectors').at(0).get('name')).toEqual('test1'); - }); - - it("Returns correct rule with the same selector", () => { - var sel = new obj.Selectors([{name: 'test1'}]); + expect( + obj + .getAll() + .at(0) + .get('selectors') + .at(0) + .get('name') + ).toEqual('test1'); + }); + + it('Returns correct rule with the same selector', () => { + var sel = new obj.Selectors([{ name: 'test1' }]); var rule1 = obj.add(sel.models); var rule2 = obj.get(sel.models); expect(rule1).toEqual(rule2); }); - it("Returns correct rule with the same selectors", () => { - var sel1 = new obj.Selectors([{name: 'test1'}]); + it('Returns correct rule with the same selectors', () => { + var sel1 = new obj.Selectors([{ name: 'test1' }]); var rule1 = obj.add(sel1.models); - var sel2 = new obj.Selectors([{name: 'test21'}, {name: 'test22'}]); + var sel2 = new obj.Selectors([{ name: 'test21' }, { name: 'test22' }]); var rule2 = obj.add(sel2.models); var rule3 = obj.get(sel2.models); expect(rule3).toEqual(rule2); }); - it("Do not create multiple rules with the same name selectors", () => { - var sel1 = new obj.Selectors([{name: 'test21'}, {name: 'test22'}]); + it('Do not create multiple rules with the same name selectors', () => { + var sel1 = new obj.Selectors([{ name: 'test21' }, { name: 'test22' }]); var rule1 = obj.add(sel1.models); - var sel2 = new obj.Selectors([{name: 'test22'}, {name: 'test21'}]); + var sel2 = new obj.Selectors([{ name: 'test22' }, { name: 'test21' }]); var rule2 = obj.add(sel2.models); expect(rule2).toEqual(rule1); }); it("Don't duplicate rules", () => { var sel = new obj.Selectors([]); - var s1 = sel.add({name: 'test1'}); - var s2 = sel.add({name: 'test2'}); - var s3 = sel.add({name: 'test3'}); + var s1 = sel.add({ name: 'test1' }); + var s2 = sel.add({ name: 'test2' }); + var s3 = sel.add({ name: 'test3' }); var rule1 = obj.add([s1, s3]); var rule2 = obj.add([s3, s1]); @@ -128,61 +134,65 @@ describe('Css Composer', () => { expect(rule2).toEqual(rule1); }); - it("Returns correct rule with the same mixed selectors", () => { + it('Returns correct rule with the same mixed selectors', () => { var sel = new obj.Selectors([]); - var s1 = sel.add({name: 'test1'}); - var s2 = sel.add({name: 'test2'}); - var s3 = sel.add({name: 'test3'}); + var s1 = sel.add({ name: 'test1' }); + var s2 = sel.add({ name: 'test2' }); + var s3 = sel.add({ name: 'test3' }); var rule1 = obj.add([s1, s3]); var rule2 = obj.get([s3, s1]); expect(rule2).toEqual(rule1); }); - it("Returns correct rule with the same selectors and state", () => { + it('Returns correct rule with the same selectors and state', () => { var sel = new obj.Selectors([]); - var s1 = sel.add({name: 'test1'}); - var s2 = sel.add({name: 'test2'}); - var s3 = sel.add({name: 'test3'}); + var s1 = sel.add({ name: 'test1' }); + var s2 = sel.add({ name: 'test2' }); + var s3 = sel.add({ name: 'test3' }); var rule1 = obj.add([s1, s3], 'hover'); var rule2 = obj.get([s3, s1], 'hover'); expect(rule2).toEqual(rule1); }); - it("Returns correct rule with the same selectors, state and width", () => { + it('Returns correct rule with the same selectors, state and width', () => { var sel = new obj.Selectors([]); - var s1 = sel.add({name: 'test1'}); - var rule1 = obj.add([s1], 'hover','1'); + var s1 = sel.add({ name: 'test1' }); + var rule1 = obj.add([s1], 'hover', '1'); var rule2 = obj.get([s1], 'hover', '1'); expect(rule2).toEqual(rule1); }); - it("Renders correctly", () => { + it('Renders correctly', () => { expect(obj.render()).toExist(); }); it('Create a rule with id selector by using setIdRule()', () => { const name = 'test'; - obj.setIdRule(name, {color: 'red'}); + obj.setIdRule(name, { color: 'red' }); expect(obj.getAll().length).toEqual(1); const rule = obj.getIdRule(name); expect(rule.selectorsToString()).toEqual(`#${name}`); expect(rule.styleToString()).toEqual(`color:red;`); - expect(rule.styleToString({important: 1})).toEqual(`color:red !important;`); - expect(rule.styleToString({important: ['color']})).toEqual(`color:red !important;`); + expect(rule.styleToString({ important: 1 })).toEqual( + `color:red !important;` + ); + expect(rule.styleToString({ important: ['color'] })).toEqual( + `color:red !important;` + ); }); it('Create a rule with id selector and state by using setIdRule()', () => { const name = 'test'; const state = 'hover'; - obj.setIdRule(name, {color: 'red'}, {state}); + obj.setIdRule(name, { color: 'red' }, { state }); expect(obj.getAll().length).toEqual(1); - const rule = obj.getIdRule(name, {state}); + const rule = obj.getIdRule(name, { state }); expect(rule.selectorsToString()).toEqual(`#${name}:${state}`); }); it('Create a rule with class selector by using setClassRule()', () => { const name = 'test'; - obj.setClassRule(name, {color: 'red'}); + obj.setClassRule(name, { color: 'red' }); expect(obj.getAll().length).toEqual(1); const rule = obj.getClassRule(name); expect(rule.selectorsToString()).toEqual(`.${name}`); @@ -192,12 +202,11 @@ describe('Css Composer', () => { it('Create a rule with class selector and state by using setClassRule()', () => { const name = 'test'; const state = 'hover'; - obj.setClassRule(name, {color: 'red'}, {state}); + obj.setClassRule(name, { color: 'red' }, { state }); expect(obj.getAll().length).toEqual(1); - const rule = obj.getClassRule(name, {state}); + const rule = obj.getClassRule(name, { state }); expect(rule.selectorsToString()).toEqual(`.${name}:${state}`); }); - }); Models.run(); diff --git a/test/specs/css_composer/model/CssModels.js b/test/specs/css_composer/model/CssModels.js index f9a6e63d5..44ea7753b 100644 --- a/test/specs/css_composer/model/CssModels.js +++ b/test/specs/css_composer/model/CssModels.js @@ -5,101 +5,96 @@ var Selector = require('selector_manager/model/Selector'); module.exports = { run() { - describe('CssRule', () => { - let obj; - - beforeEach(() => { - obj = new CssRule(); - }); - - afterEach(() => { - obj = null; - }); - - it('Has selectors property', () => { - expect(obj.has('selectors')).toEqual(true); - }); - - it('Has style property', () => { - expect(obj.has('style')).toEqual(true); - }); - - it('Has state property', () => { - expect(obj.has('state')).toEqual(true); - }); - - it('No default selectors', () => { - expect(obj.get('selectors').length).toEqual(0); - }); - - it('Compare returns true with the same selectors', () => { - var s1 = obj.get('selectors').add({ name: 'test1' }); - var s2 = obj.get('selectors').add({ name: 'test2' }); - expect(obj.compare([s1, s2])).toEqual(true); - }); - - it('Compare with different state', () => { - var s1 = obj.get('selectors').add({ name: 'test1' }); - var s2 = obj.get('selectors').add({ name: 'test2' }); - obj.set('state','hover'); - expect(obj.compare([s1, s2])).toEqual(false); - expect(obj.compare([s1, s2], 'hover')).toEqual(true); - }); - - it('Compare with different mediaText', () => { - var s1 = obj.get('selectors').add({ name: 'test1' }); - var s2 = obj.get('selectors').add({ name: 'test2' }); - obj.set('state','hover'); - obj.set('mediaText','1000'); - expect(obj.compare([s1, s2])).toEqual(false); - expect(obj.compare([s1, s2], 'hover')).toEqual(false); - expect(obj.compare([s2, s1], 'hover', '1000')).toEqual(true); - }); - - it('toCSS returns empty if there is no style', () => { - var s1 = obj.get('selectors').add({ name: 'test1' }); - expect(obj.toCSS()).toEqual(''); - }); - - it('toCSS returns empty if there is no selectors', () => { - obj.setStyle({color: 'red'}); - expect(obj.toCSS()).toEqual(''); - }); - - it('toCSS returns simple CSS', () => { - obj.get('selectors').add({ name: 'test1' }); - obj.setStyle({color: 'red'}); - expect(obj.toCSS()).toEqual(`.test1{color:red;}`); - }); - - it('toCSS wraps correctly inside media rule', () => { - const media = '(max-width: 768px)'; - obj.set('mediaText', media); - obj.get('selectors').add({ name: 'test1' }); - obj.setStyle({color: 'red'}); - expect(obj.toCSS()).toEqual(`@media ${media}{.test1{color:red;}}`); - }); - + describe('CssRule', () => { + let obj; + + beforeEach(() => { + obj = new CssRule(); + }); + + afterEach(() => { + obj = null; + }); + + it('Has selectors property', () => { + expect(obj.has('selectors')).toEqual(true); + }); + + it('Has style property', () => { + expect(obj.has('style')).toEqual(true); + }); + + it('Has state property', () => { + expect(obj.has('state')).toEqual(true); + }); + + it('No default selectors', () => { + expect(obj.get('selectors').length).toEqual(0); + }); + + it('Compare returns true with the same selectors', () => { + var s1 = obj.get('selectors').add({ name: 'test1' }); + var s2 = obj.get('selectors').add({ name: 'test2' }); + expect(obj.compare([s1, s2])).toEqual(true); + }); + + it('Compare with different state', () => { + var s1 = obj.get('selectors').add({ name: 'test1' }); + var s2 = obj.get('selectors').add({ name: 'test2' }); + obj.set('state', 'hover'); + expect(obj.compare([s1, s2])).toEqual(false); + expect(obj.compare([s1, s2], 'hover')).toEqual(true); + }); + + it('Compare with different mediaText', () => { + var s1 = obj.get('selectors').add({ name: 'test1' }); + var s2 = obj.get('selectors').add({ name: 'test2' }); + obj.set('state', 'hover'); + obj.set('mediaText', '1000'); + expect(obj.compare([s1, s2])).toEqual(false); + expect(obj.compare([s1, s2], 'hover')).toEqual(false); + expect(obj.compare([s2, s1], 'hover', '1000')).toEqual(true); + }); + + it('toCSS returns empty if there is no style', () => { + var s1 = obj.get('selectors').add({ name: 'test1' }); + expect(obj.toCSS()).toEqual(''); + }); + + it('toCSS returns empty if there is no selectors', () => { + obj.setStyle({ color: 'red' }); + expect(obj.toCSS()).toEqual(''); + }); + + it('toCSS returns simple CSS', () => { + obj.get('selectors').add({ name: 'test1' }); + obj.setStyle({ color: 'red' }); + expect(obj.toCSS()).toEqual(`.test1{color:red;}`); + }); + + it('toCSS wraps correctly inside media rule', () => { + const media = '(max-width: 768px)'; + obj.set('mediaText', media); + obj.get('selectors').add({ name: 'test1' }); + obj.setStyle({ color: 'red' }); + expect(obj.toCSS()).toEqual(`@media ${media}{.test1{color:red;}}`); + }); }); describe('CssRules', () => { - - it('Creates collection item correctly', () => { - var c = new CssRules(); - var m = c.add({}); - expect(m instanceof CssRule).toEqual(true); - }); - + it('Creates collection item correctly', () => { + var c = new CssRules(); + var m = c.add({}); + expect(m instanceof CssRule).toEqual(true); + }); }); - describe('Selectors', () => { - - it('Creates collection item correctly', () => { - var c = new Selectors(); - var m = c.add({}); - expect(m instanceof Selector).toEqual(true); - }); - + describe('Selectors', () => { + it('Creates collection item correctly', () => { + var c = new Selectors(); + var m = c.add({}); + expect(m instanceof Selector).toEqual(true); + }); }); } }; diff --git a/test/specs/css_composer/view/CssRuleView.js b/test/specs/css_composer/view/CssRuleView.js index 55dee4e1b..4827eab81 100644 --- a/test/specs/css_composer/view/CssRuleView.js +++ b/test/specs/css_composer/view/CssRuleView.js @@ -3,95 +3,93 @@ var CssRule = require('css_composer/model/CssRule'); module.exports = { run() { - describe('CssRuleView', () => { - - let obj; - let fixtures; - - beforeEach(function () { - var m = new CssRule(); - obj = new CssRuleView({ + describe('CssRuleView', () => { + let obj; + let fixtures; + + beforeEach(function() { + var m = new CssRule(); + obj = new CssRuleView({ + model: m + }); + document.body.innerHTML = '
'; + fixtures = document.body.querySelector('#fixtures'); + fixtures.appendChild(obj.render().el); + }); + + afterEach(() => { + obj.model.destroy(); + }); + + it('Object exists', () => { + expect(CssRuleView).toExist(); + }); + + it('Empty style inside', function() { + expect(fixtures.innerHTML).toEqual(''); + }); + + it('On update of style always empty as there is no selectors', function() { + obj.model.set('style', { prop: 'value' }); + expect(fixtures.innerHTML).toEqual(''); + }); + + describe('CssRuleView with selectors', () => { + let objReg; + + beforeEach(() => { + var m = new CssRule({ + selectors: [{ name: 'test1' }, { name: 'test2' }] + }); + objReg = new CssRuleView({ model: m }); + objReg.render(); document.body.innerHTML = '
'; fixtures = document.body.querySelector('#fixtures'); - fixtures.appendChild(obj.render().el); + fixtures.appendChild(objReg.el); }); afterEach(() => { - obj.model.destroy(); + objReg.model.destroy(); }); - it('Object exists', () => { - expect(CssRuleView).toExist(); + it('Empty with no style', () => { + expect(objReg.$el.html()).toEqual(''); }); - it('Empty style inside', function() { - expect(fixtures.innerHTML).toEqual(''); + it('Not empty on update of style', () => { + objReg.model.set('style', { prop: 'value' }); + expect(objReg.$el.html()).toEqual('.test1.test2{prop:value;}'); }); - it('On update of style always empty as there is no selectors', function() { - obj.model.set('style', {'prop':'value'}); - expect(fixtures.innerHTML).toEqual(''); + it('State correctly rendered', () => { + objReg.model.set('style', { prop: 'value' }); + objReg.model.set('state', 'hover'); + expect(objReg.$el.html()).toEqual('.test1.test2:hover{prop:value;}'); }); - describe('CssRuleView with selectors', () => { - - let objReg; - - beforeEach(() => { - var m = new CssRule({ - selectors: [{name:'test1'}, {name:'test2'}] - }); - objReg = new CssRuleView({ - model: m - }); - objReg.render(); - document.body.innerHTML = '
'; - fixtures = document.body.querySelector('#fixtures'); - fixtures.appendChild(objReg.el); - }); - - afterEach(() => { - objReg.model.destroy(); - }); - - it('Empty with no style', () => { - expect(objReg.$el.html()).toEqual(''); - }); - - it('Not empty on update of style', () => { - objReg.model.set('style', {'prop':'value'}); - expect(objReg.$el.html()).toEqual('.test1.test2{prop:value;}'); - }); - - it('State correctly rendered', () => { - objReg.model.set('style', {'prop':'value'}); - objReg.model.set('state', 'hover'); - expect(objReg.$el.html()).toEqual('.test1.test2:hover{prop:value;}'); - }); - - it('State render changes on update', () => { - objReg.model.set('style', {'prop':'value'}); - objReg.model.set('state', 'hover'); - objReg.model.set('state', ''); - expect(objReg.$el.html()).toEqual('.test1.test2{prop:value;}'); - }); - - it('Render media queries', () => { - objReg.model.set('style', {'prop':'value'}); - objReg.model.set('mediaText', '(max-width: 999px)'); - expect(objReg.$el.html()).toEqual('@media (max-width: 999px){.test1.test2{prop:value;}}'); - }); - - it('Empty on clear', () => { - objReg.model.set('style', {'prop':'value'}); - objReg.model.set('style', {}); - expect(objReg.$el.html()).toEqual(''); - }); + it('State render changes on update', () => { + objReg.model.set('style', { prop: 'value' }); + objReg.model.set('state', 'hover'); + objReg.model.set('state', ''); + expect(objReg.$el.html()).toEqual('.test1.test2{prop:value;}'); + }); + it('Render media queries', () => { + objReg.model.set('style', { prop: 'value' }); + objReg.model.set('mediaText', '(max-width: 999px)'); + expect(objReg.$el.html()).toEqual( + '@media (max-width: 999px){.test1.test2{prop:value;}}' + ); }); + it('Empty on clear', () => { + objReg.model.set('style', { prop: 'value' }); + objReg.model.set('style', {}); + expect(objReg.$el.html()).toEqual(''); + }); + }); }); } }; diff --git a/test/specs/css_composer/view/CssRulesView.js b/test/specs/css_composer/view/CssRulesView.js index d5a6ac777..d885fccdc 100644 --- a/test/specs/css_composer/view/CssRulesView.js +++ b/test/specs/css_composer/view/CssRulesView.js @@ -3,42 +3,40 @@ var CssRules = require('css_composer/model/CssRules'); module.exports = { run() { - describe('CssRulesView', () => { + describe('CssRulesView', () => { + let obj; - let obj; - - beforeEach(function () { - var col = new CssRules([]); - obj = new CssRulesView({ - collection: col - }); - document.body.innerHTML = '
'; - document.body.querySelector('#fixtures').appendChild(obj.render().el); - }); - - afterEach(() => { - obj.collection.reset(); - }); - - it('Object exists', () => { - expect(CssRulesView).toExist(); - }); - - it("Collection is empty", () => { - expect(obj.$el.html()).toNotExist(); - }); - - it("Add new rule", () => { - sinon.stub(obj, "addToCollection"); - obj.collection.add({}); - expect(obj.addToCollection.calledOnce).toExist(true); + beforeEach(function() { + var col = new CssRules([]); + obj = new CssRulesView({ + collection: col }); - - it("Render new rule", () => { - obj.collection.add({}); - expect(obj.$el.html()).toExist(); - }); - + document.body.innerHTML = '
'; + document.body.querySelector('#fixtures').appendChild(obj.render().el); + }); + + afterEach(() => { + obj.collection.reset(); + }); + + it('Object exists', () => { + expect(CssRulesView).toExist(); + }); + + it('Collection is empty', () => { + expect(obj.$el.html()).toNotExist(); + }); + + it('Add new rule', () => { + sinon.stub(obj, 'addToCollection'); + obj.collection.add({}); + expect(obj.addToCollection.calledOnce).toExist(true); + }); + + it('Render new rule', () => { + obj.collection.add({}); + expect(obj.$el.html()).toExist(); + }); }); } }; diff --git a/test/specs/device_manager/index.js b/test/specs/device_manager/index.js index 78d4d8bcd..304814daf 100644 --- a/test/specs/device_manager/index.js +++ b/test/specs/device_manager/index.js @@ -2,9 +2,7 @@ const DeviceManager = require('device_manager'); const DevicesView = require('./view/DevicesView'); describe('DeviceManager', () => { - describe('Main', () => { - var obj; var testNameDevice; var testWidthDevice; @@ -40,7 +38,7 @@ describe('DeviceManager', () => { }); it('Add device width options', () => { - var model = obj.add(testNameDevice, testWidthDevice, {opt: 'value'}); + var model = obj.add(testNameDevice, testWidthDevice, { opt: 'value' }); expect(model.get('opt')).toEqual('value'); }); @@ -59,9 +57,7 @@ describe('DeviceManager', () => { it('Render devices', () => { expect(obj.render()).toExist(); }); - }); DevicesView.run(); - }); diff --git a/test/specs/device_manager/view/DevicesView.js b/test/specs/device_manager/view/DevicesView.js index 262bd60e0..b1dbe6402 100644 --- a/test/specs/device_manager/view/DevicesView.js +++ b/test/specs/device_manager/view/DevicesView.js @@ -3,68 +3,65 @@ const Devices = require('device_manager/model/Devices'); module.exports = { run() { - describe('DevicesView', () => { + describe('DevicesView', () => { + var $fixtures; + var $fixture; + var model; + var view; + var editorModel; - var $fixtures; - var $fixture; - var model; - var view; - var editorModel; - - beforeEach(() => { - model = new Devices([]); - view = new DevicesView({ - collection: model - }); - document.body.innerHTML = '
'; - document.body.querySelector('#fixtures').appendChild(view.render().el); + beforeEach(() => { + model = new Devices([]); + view = new DevicesView({ + collection: model }); + document.body.innerHTML = '
'; + document.body.querySelector('#fixtures').appendChild(view.render().el); + }); - afterEach(() => { - view.collection.reset(); - }); + afterEach(() => { + view.collection.reset(); + }); - it("The content is not empty", () => { - expect(view.el.innerHTML).toExist(); - }); + it('The content is not empty', () => { + expect(view.el.innerHTML).toExist(); + }); - it("No options without devices", () => { - expect(view.getOptions()).toEqual(''); - }); - - it("Render new button", () => { - view.collection.add({}); - expect(view.$el.html()).toExist(); - }); + it('No options without devices', () => { + expect(view.getOptions()).toEqual(''); + }); - describe('With configs', () => { + it('Render new button', () => { + view.collection.add({}); + expect(view.$el.html()).toExist(); + }); - beforeEach(() => { - editorModel = new Backbone.Model(); - model = new Devices([ - {name:'test1'}, - {name:'test2'} - ]); - view = new DevicesView({ - collection: model, - config: { em: editorModel } - }); - document.body.innerHTML = '
'; - document.body.querySelector('#fixtures').appendChild(view.render().el); - }); - - it("Update device on select change", () => { - view.$el.find('select').val('test2'); - view.updateDevice(); - expect(view.config.em.get('device')).toEqual('test2'); - }); - - it("Render options", () => { - expect(view.getOptions()).toEqual(''); + describe('With configs', () => { + beforeEach(() => { + editorModel = new Backbone.Model(); + model = new Devices([{ name: 'test1' }, { name: 'test2' }]); + view = new DevicesView({ + collection: model, + config: { em: editorModel } }); + document.body.innerHTML = '
'; + document.body + .querySelector('#fixtures') + .appendChild(view.render().el); + }); + it('Update device on select change', () => { + view.$el.find('select').val('test2'); + view.updateDevice(); + expect(view.config.em.get('device')).toEqual('test2'); }); + it('Render options', () => { + expect(view.getOptions()).toEqual( + '' + ); + }); + }); }); } }; diff --git a/test/specs/dom_components/index.js b/test/specs/dom_components/index.js index 5cab2699b..19391c4d2 100644 --- a/test/specs/dom_components/index.js +++ b/test/specs/dom_components/index.js @@ -9,20 +9,24 @@ const Editor = require('editor/model/Editor'); const utils = require('./../test_utils.js'); describe('DOM Components', () => { - describe('Main', () => { - var em; var obj; var config; var storagMock = utils.storageMock(); var editorModel = { config: { - loadCompsOnRender: 0, + loadCompsOnRender: 0 + }, + get() { + return; + }, + getHtml() { + return 'testHtml'; + }, + getComponents() { + return { test: 1 }; }, - get() {return;}, - getHtml() {return 'testHtml';}, - getComponents() {return {test: 1};}, getCacheLoad() { return storagMock.load(); } @@ -30,21 +34,20 @@ describe('DOM Components', () => { // Methods var setSmConfig = () => { config.stm = storagMock; - config.stm.getConfig = () => ({ + config.stm.getConfig = () => ({ storeHtml: 1, storeComponents: 1 }); }; var setEm = () => { config.em = editorModel; - } - + }; beforeEach(() => { em = new Editor(); config = { em, - storeWrapper: 1, + storeWrapper: 1 }; obj = new DomComponents().init(config); }); @@ -66,8 +69,8 @@ describe('DOM Components', () => { getConfig() { return { storeHtml: 1, - storeComponents: 1, - } + storeComponents: 1 + }; } }; expect(obj.storageKey()).toEqual(['html', 'components']); @@ -79,7 +82,7 @@ describe('DOM Components', () => { //obj.getWrapper().get('components').add({}); var expected = { html: 'testHtml', - components: JSON.stringify(obj.getWrapper()), + components: JSON.stringify(obj.getWrapper()) }; expect(obj.store(1)).toEqual(expected); }); @@ -90,7 +93,7 @@ describe('DOM Components', () => { const comps = new Components({}, {}); obj.getWrapper().set('components', comps); obj.store(); - expect(obj.load()).toEqual([{test: 1}]); + expect(obj.load()).toEqual([{ test: 1 }]); }); it('Wrapper exists', () => { @@ -107,7 +110,7 @@ describe('DOM Components', () => { }); it('Add more components at once', () => { - var comp = obj.addComponent([{},{}]); + var comp = obj.addComponent([{}, {}]); expect(obj.getComponents().length).toEqual(2); }); @@ -124,5 +127,4 @@ describe('DOM Components', () => { ComponentTextView.run(); ComponentImageView.run(); }); - }); diff --git a/test/specs/dom_components/model/Component.js b/test/specs/dom_components/model/Component.js index fb32d393f..ccc051a26 100644 --- a/test/specs/dom_components/model/Component.js +++ b/test/specs/dom_components/model/Component.js @@ -12,277 +12,292 @@ const $ = Backbone.$; module.exports = { run() { - let obj; - let dcomp; - let compOpts; - let em; - - describe('Component', () => { - - beforeEach(() => { - em = new Editor({}); - dcomp = new DomComponents(); - compOpts = { - em, - componentTypes: dcomp.componentTypes, - }; - obj = new Component({}, compOpts); - }); + let obj; + let dcomp; + let compOpts; + let em; + + describe('Component', () => { + beforeEach(() => { + em = new Editor({}); + dcomp = new DomComponents(); + compOpts = { + em, + componentTypes: dcomp.componentTypes + }; + obj = new Component({}, compOpts); + }); - afterEach(() => { - obj = null; - }); + afterEach(() => { + obj = null; + }); - it('Has no children', () => { - expect(obj.get('components').length).toEqual(0); - }); + it('Has no children', () => { + expect(obj.get('components').length).toEqual(0); + }); - it('Clones correctly', () => { - var sAttr = obj.attributes; - var cloned = obj.clone(); - var eAttr = cloned.attributes; - eAttr.components = {}; - sAttr.components = {}; - eAttr.traits = {}; - sAttr.traits = {}; - expect(sAttr.length).toEqual(eAttr.length); - }); + it('Clones correctly', () => { + var sAttr = obj.attributes; + var cloned = obj.clone(); + var eAttr = cloned.attributes; + eAttr.components = {}; + sAttr.components = {}; + eAttr.traits = {}; + sAttr.traits = {}; + expect(sAttr.length).toEqual(eAttr.length); + }); - it('Clones correctly with traits', () => { - obj.get('traits').at(0).set('value', 'testTitle'); - var cloned = obj.clone(); - cloned.set('stylable', 0); - cloned.get('traits').at(0).set('value', 'testTitle2'); - expect(obj.get('traits').at(0).get('value')).toEqual('testTitle'); - expect(obj.get('stylable')).toEqual(true); - }); + it('Clones correctly with traits', () => { + obj + .get('traits') + .at(0) + .set('value', 'testTitle'); + var cloned = obj.clone(); + cloned.set('stylable', 0); + cloned + .get('traits') + .at(0) + .set('value', 'testTitle2'); + expect( + obj + .get('traits') + .at(0) + .get('value') + ).toEqual('testTitle'); + expect(obj.get('stylable')).toEqual(true); + }); - it('Has expected name', () => { - expect(obj.getName()).toEqual('Box'); - }); + it('Has expected name', () => { + expect(obj.getName()).toEqual('Box'); + }); - it('Has expected name 2', () => { - obj.cid = 'c999'; - obj.set('type','testType'); - expect(obj.getName()).toEqual('TestType'); - }); + it('Has expected name 2', () => { + obj.cid = 'c999'; + obj.set('type', 'testType'); + expect(obj.getName()).toEqual('TestType'); + }); - it('Component toHTML', () => { - expect(obj.toHTML()).toEqual('
'); - }); + it('Component toHTML', () => { + expect(obj.toHTML()).toEqual('
'); + }); - it('Component toHTML with attributes', () => { - obj = new Component({ - tagName: 'article', - attributes: { - 'data-test1': 'value1', - 'data-test2': 'value2' - } - }); - expect(obj.toHTML()).toEqual('
'); + it('Component toHTML with attributes', () => { + obj = new Component({ + tagName: 'article', + attributes: { + 'data-test1': 'value1', + 'data-test2': 'value2' + } }); + expect(obj.toHTML()).toEqual( + '
' + ); + }); - it('Component toHTML with value-less attribute', () => { - obj = new Component({ - tagName: 'div', - attributes: { - 'data-is-a-test': '' - } - }); - expect(obj.toHTML()).toEqual('
'); + it('Component toHTML with value-less attribute', () => { + obj = new Component({ + tagName: 'div', + attributes: { + 'data-is-a-test': '' + } }); + expect(obj.toHTML()).toEqual('
'); + }); - it('Component toHTML with classes', () => { - obj = new Component({ - tagName: 'article' - }); - ['class1', 'class2'].forEach(item => { - obj.get('classes').add({name: item}); - }); - expect(obj.toHTML()).toEqual('
'); + it('Component toHTML with classes', () => { + obj = new Component({ + tagName: 'article' }); - - it('Component toHTML with children', () => { - obj = new Component({tagName: 'article'}, compOpts); - obj.get('components').add({tagName: 'span'}); - expect(obj.toHTML()).toEqual('
'); + ['class1', 'class2'].forEach(item => { + obj.get('classes').add({ name: item }); }); + expect(obj.toHTML()).toEqual( + '
' + ); + }); - it('Component toHTML with more children', () => { - obj = new Component({tagName: 'article'}, compOpts); - obj.get('components').add([{tagName: 'span'}, {tagName: 'div'}]); - expect(obj.toHTML()).toEqual('
'); - }); + it('Component toHTML with children', () => { + obj = new Component({ tagName: 'article' }, compOpts); + obj.get('components').add({ tagName: 'span' }); + expect(obj.toHTML()).toEqual('
'); + }); - it('Component toHTML with no closing tag', () => { - obj = new Component({void: 1}); - expect(obj.toHTML()).toEqual('
'); - }); + it('Component toHTML with more children', () => { + obj = new Component({ tagName: 'article' }, compOpts); + obj.get('components').add([{ tagName: 'span' }, { tagName: 'div' }]); + expect(obj.toHTML()).toEqual( + '
' + ); + }); - it('Component parse empty div', () => { - var el = document.createElement('div'); - obj = Component.isComponent(el); - expect(obj).toEqual({tagName: 'div'}); - }); + it('Component toHTML with no closing tag', () => { + obj = new Component({ void: 1 }); + expect(obj.toHTML()).toEqual('
'); + }); - it('Component parse span', () => { - var el = document.createElement('span'); - obj = Component.isComponent(el); - expect(obj).toEqual({tagName: 'span'}); - }); + it('Component parse empty div', () => { + var el = document.createElement('div'); + obj = Component.isComponent(el); + expect(obj).toEqual({ tagName: 'div' }); + }); - it('setClass single class string', () => { - obj.setClass('class1'); - const result = obj.get('classes').models; - expect(result.length).toEqual(1); - expect(result[0] instanceof Selector).toEqual(true); - expect(result[0].get('name')).toEqual('class1'); - }); + it('Component parse span', () => { + var el = document.createElement('span'); + obj = Component.isComponent(el); + expect(obj).toEqual({ tagName: 'span' }); + }); - it('setClass multiple class string', () => { - obj.setClass('class1 class2'); - const result = obj.get('classes').models; - expect(result.length).toEqual(2); - }); + it('setClass single class string', () => { + obj.setClass('class1'); + const result = obj.get('classes').models; + expect(result.length).toEqual(1); + expect(result[0] instanceof Selector).toEqual(true); + expect(result[0].get('name')).toEqual('class1'); + }); - it('setClass single class array', () => { - obj.setClass(['class1']); - const result = obj.get('classes').models; - expect(result.length).toEqual(1); - }); + it('setClass multiple class string', () => { + obj.setClass('class1 class2'); + const result = obj.get('classes').models; + expect(result.length).toEqual(2); + }); - it('setClass multiple class array', () => { - obj.setClass(['class1', 'class2']); - const result = obj.get('classes').models; - expect(result.length).toEqual(2); - }); + it('setClass single class array', () => { + obj.setClass(['class1']); + const result = obj.get('classes').models; + expect(result.length).toEqual(1); + }); - it('addClass multiple array', () => { - obj.addClass(['class1', 'class2']); - const result = obj.get('classes').models; - expect(result.length).toEqual(2); - }); + it('setClass multiple class array', () => { + obj.setClass(['class1', 'class2']); + const result = obj.get('classes').models; + expect(result.length).toEqual(2); + }); - it('addClass avoid same name classes', () => { - obj.addClass(['class1', 'class2']); - obj.addClass(['class1', 'class3']); - const result = obj.get('classes').models; - expect(result.length).toEqual(3); - }); + it('addClass multiple array', () => { + obj.addClass(['class1', 'class2']); + const result = obj.get('classes').models; + expect(result.length).toEqual(2); + }); - it('removeClass by string', () => { - obj.addClass(['class1', 'class2']); - obj.removeClass('class2'); - const result = obj.get('classes').models; - expect(result.length).toEqual(1); - }); + it('addClass avoid same name classes', () => { + obj.addClass(['class1', 'class2']); + obj.addClass(['class1', 'class3']); + const result = obj.get('classes').models; + expect(result.length).toEqual(3); + }); - it('removeClass by string with multiple classes', () => { - obj.addClass(['class1', 'class2']); - obj.removeClass('class2 class1'); - const result = obj.get('classes').models; - expect(result.length).toEqual(0); - }); + it('removeClass by string', () => { + obj.addClass(['class1', 'class2']); + obj.removeClass('class2'); + const result = obj.get('classes').models; + expect(result.length).toEqual(1); + }); - it('removeClass by array', () => { - obj.addClass(['class1', 'class2']); - obj.removeClass(['class1', 'class2']); - const result = obj.get('classes').models; - expect(result.length).toEqual(0); - }); + it('removeClass by string with multiple classes', () => { + obj.addClass(['class1', 'class2']); + obj.removeClass('class2 class1'); + const result = obj.get('classes').models; + expect(result.length).toEqual(0); + }); - it('removeClass do nothing with undefined classes', () => { - obj.addClass(['class1', 'class2']); - obj.removeClass(['class3']); - const result = obj.get('classes').models; - expect(result.length).toEqual(2); - }); + it('removeClass by array', () => { + obj.addClass(['class1', 'class2']); + obj.removeClass(['class1', 'class2']); + const result = obj.get('classes').models; + expect(result.length).toEqual(0); + }); - it('removeClass actually removes classes from attributes', () => { - obj.addClass('class1'); - obj.removeClass('class1'); - const result = obj.getAttributes(); - expect(result.class).toEqual(undefined); - }); + it('removeClass do nothing with undefined classes', () => { + obj.addClass(['class1', 'class2']); + obj.removeClass(['class3']); + const result = obj.get('classes').models; + expect(result.length).toEqual(2); + }); - it('setAttributes', () => { - obj.setAttributes({ - id: 'test', - 'data-test': 'value', - class: 'class1 class2', - style: 'color: white; background: #fff' - }); - expect(obj.getAttributes()).toEqual({ - id: 'test', - class: 'class1 class2', - 'data-test': 'value', - }); - expect(obj.get('classes').length).toEqual(2); - expect(obj.getStyle()).toEqual({ - color: 'white', - background: '#fff', - }); - }); + it('removeClass actually removes classes from attributes', () => { + obj.addClass('class1'); + obj.removeClass('class1'); + const result = obj.getAttributes(); + expect(result.class).toEqual(undefined); + }); - it('setAttributes overwrites correctly', () => { - obj.setAttributes({id: 'test', 'data-test': 'value'}); - obj.setAttributes({'data-test': 'value2'}); - expect(obj.getAttributes()).toEqual({'data-test': 'value2'}); + it('setAttributes', () => { + obj.setAttributes({ + id: 'test', + 'data-test': 'value', + class: 'class1 class2', + style: 'color: white; background: #fff' }); - - it('append() returns always an array', () => { - let result = obj.append('text1'); - expect(result.length).toEqual(1); - result = obj.append('text1
text2
'); - expect(result.length).toEqual(2); + expect(obj.getAttributes()).toEqual({ + id: 'test', + class: 'class1 class2', + 'data-test': 'value' }); - - it('append() new components as string', () => { - obj.append('text1
text2
'); - const comps = obj.components(); - expect(comps.length).toEqual(2); - expect(comps.models[0].get('tagName')).toEqual('span'); - expect(comps.models[1].get('tagName')).toEqual('div'); + expect(obj.get('classes').length).toEqual(2); + expect(obj.getStyle()).toEqual({ + color: 'white', + background: '#fff' }); + }); - it('append() new components as Objects', () => { - obj.append([{}, {}]); - const comps = obj.components(); - expect(comps.length).toEqual(2); - obj.append({}); - expect(comps.length).toEqual(3); - }); + it('setAttributes overwrites correctly', () => { + obj.setAttributes({ id: 'test', 'data-test': 'value' }); + obj.setAttributes({ 'data-test': 'value2' }); + expect(obj.getAttributes()).toEqual({ 'data-test': 'value2' }); + }); - it('components() set new collection', () => { - obj.append([{}, {}]); - obj.components('test
'); - const result = obj.components(); - expect(result.length).toEqual(1); - expect(result.models[0].get('tagName')).toEqual('span'); - }); + it('append() returns always an array', () => { + let result = obj.append('text1'); + expect(result.length).toEqual(1); + result = obj.append('text1
text2
'); + expect(result.length).toEqual(2); + }); + it('append() new components as string', () => { + obj.append('text1
text2
'); + const comps = obj.components(); + expect(comps.length).toEqual(2); + expect(comps.models[0].get('tagName')).toEqual('span'); + expect(comps.models[1].get('tagName')).toEqual('div'); + }); - it('Propagate properties to children', () => { - obj.append({propagate: 'removable'}); - const result = obj.components(); - const newObj = result.models[0]; - expect(newObj.get('removable')).toEqual(true); - newObj.set('removable', false); - newObj.append({draggable: false}); - const child = newObj.components().models[0]; - expect(child.get('removable')).toEqual(false); - expect(child.get('propagate')).toEqual(['removable']); - }); + it('append() new components as Objects', () => { + obj.append([{}, {}]); + const comps = obj.components(); + expect(comps.length).toEqual(2); + obj.append({}); + expect(comps.length).toEqual(3); + }); + + it('components() set new collection', () => { + obj.append([{}, {}]); + obj.components('test
'); + const result = obj.components(); + expect(result.length).toEqual(1); + expect(result.models[0].get('tagName')).toEqual('span'); + }); + + it('Propagate properties to children', () => { + obj.append({ propagate: 'removable' }); + const result = obj.components(); + const newObj = result.models[0]; + expect(newObj.get('removable')).toEqual(true); + newObj.set('removable', false); + newObj.append({ draggable: false }); + const child = newObj.components().models[0]; + expect(child.get('removable')).toEqual(false); + expect(child.get('propagate')).toEqual(['removable']); + }); - it('Ability to stop/change propagation chain', () => { - obj.append({ - removable: false, - draggable: false, - propagate: ['removable', 'draggable'] - }); - const result = obj.components(); - const newObj = result.models[0]; - newObj.components(` + it('Ability to stop/change propagation chain', () => { + obj.append({ + removable: false, + draggable: false, + propagate: ['removable', 'draggable'] + }); + const result = obj.components(); + const newObj = result.models[0]; + newObj.components(`
comp1
@@ -295,126 +310,123 @@ module.exports = {
TEST
`); - const notInhereted = model => { - expect(model.get('stop')).toEqual(1); - expect(model.get('removable')).toEqual(true); - expect(model.get('draggable')).toEqual(true); - expect(model.get('propagate')).toEqual(['stop']); - model.components().each(model => inhereted(model)) - }; - const inhereted = model => { - if (model.get('stop')) { - notInhereted(model); - } else { - expect(model.get('removable')).toEqual(false); - expect(model.get('draggable')).toEqual(false); - expect(model.get('propagate')).toEqual(['removable', 'draggable']); - model.components().each(model => inhereted(model)) - } + const notInhereted = model => { + expect(model.get('stop')).toEqual(1); + expect(model.get('removable')).toEqual(true); + expect(model.get('draggable')).toEqual(true); + expect(model.get('propagate')).toEqual(['stop']); + model.components().each(model => inhereted(model)); + }; + const inhereted = model => { + if (model.get('stop')) { + notInhereted(model); + } else { + expect(model.get('removable')).toEqual(false); + expect(model.get('draggable')).toEqual(false); + expect(model.get('propagate')).toEqual(['removable', 'draggable']); + model.components().each(model => inhereted(model)); } - newObj.components().each(model => inhereted(model)) - }); + }; + newObj.components().each(model => inhereted(model)); + }); }); describe('Image Component', () => { + beforeEach(() => { + obj = new ComponentImage(); + }); - beforeEach(() => { - obj = new ComponentImage(); - }); - - afterEach(() => { - obj = null; - }); - - it('Has src property', () => { - expect(obj.has('src')).toEqual(true); - }); + afterEach(() => { + obj = null; + }); - it('Not droppable', () => { - expect(obj.get('droppable')).toEqual(false); - }); + it('Has src property', () => { + expect(obj.has('src')).toEqual(true); + }); - it('ComponentImage toHTML', () => { - obj = new ComponentImage(); - expect(obj.toHTML()).toEqual(''); - }); + it('Not droppable', () => { + expect(obj.get('droppable')).toEqual(false); + }); - it('Component toHTML with attributes', () => { - obj = new ComponentImage({ - attributes: {'alt': 'AltTest'}, - src: 'testPath' - }); - expect(obj.toHTML()).toEqual('AltTest'); - }); + it('ComponentImage toHTML', () => { + obj = new ComponentImage(); + expect(obj.toHTML()).toEqual(''); + }); - it('Refuse not img element', () => { - var el = document.createElement('div'); - obj = ComponentImage.isComponent(el); - expect(obj).toEqual(''); + it('Component toHTML with attributes', () => { + obj = new ComponentImage({ + attributes: { alt: 'AltTest' }, + src: 'testPath' }); + expect(obj.toHTML()).toEqual('AltTest'); + }); - it('Component parse img element', () => { - var el = document.createElement('img'); - obj = ComponentImage.isComponent(el); - expect(obj).toEqual({type: 'image'}); - }); + it('Refuse not img element', () => { + var el = document.createElement('div'); + obj = ComponentImage.isComponent(el); + expect(obj).toEqual(''); + }); - it('Component parse img element with src', () => { - var el = document.createElement('img'); - el.src = 'http://localhost/'; - obj = ComponentImage.isComponent(el); - expect(obj).toEqual({type: 'image'}); - }); + it('Component parse img element', () => { + var el = document.createElement('img'); + obj = ComponentImage.isComponent(el); + expect(obj).toEqual({ type: 'image' }); + }); + it('Component parse img element with src', () => { + var el = document.createElement('img'); + el.src = 'http://localhost/'; + obj = ComponentImage.isComponent(el); + expect(obj).toEqual({ type: 'image' }); + }); }); describe('Text Component', () => { + beforeEach(() => { + obj = new ComponentText(); + }); - beforeEach(() => { - obj = new ComponentText(); - }); - - afterEach(() => { - obj = null; - }); + afterEach(() => { + obj = null; + }); - it('Has content property', () => { - expect(obj.has('content')).toEqual(true); - }); + it('Has content property', () => { + expect(obj.has('content')).toEqual(true); + }); - it('Not droppable', () => { - expect(obj.get('droppable')).toEqual(false); - }); + it('Not droppable', () => { + expect(obj.get('droppable')).toEqual(false); + }); - it('Component toHTML with attributes', () => { - obj = new ComponentText({ - attributes: {'data-test': 'value'}, - content: 'test content' - }); - expect(obj.toHTML()).toEqual('
test content
'); + it('Component toHTML with attributes', () => { + obj = new ComponentText({ + attributes: { 'data-test': 'value' }, + content: 'test content' }); - + expect(obj.toHTML()).toEqual( + '
test content
' + ); + }); }); describe('Link Component', () => { - const aEl = document.createElement('a'); it('Component parse link element', () => { obj = ComponentLink.isComponent(aEl); - expect(obj).toEqual({type: 'link'}); + expect(obj).toEqual({ type: 'link' }); }); it('Component parse link element with text content', () => { aEl.innerHTML = 'some text here '; obj = ComponentLink.isComponent(aEl); - expect(obj).toEqual({type: 'link'}); + expect(obj).toEqual({ type: 'link' }); }); it('Component parse link element with not only text content', () => { aEl.innerHTML = '
Some
text
here
'; obj = ComponentLink.isComponent(aEl); - expect(obj).toEqual({type: 'link'}); + expect(obj).toEqual({ type: 'link' }); }); it('Component parse link element with only not text content', () => { @@ -422,86 +434,82 @@ module.exports = {
text
here
`; obj = ComponentLink.isComponent(aEl); - expect(obj).toEqual({type: 'link', editable: 0}); + expect(obj).toEqual({ type: 'link', editable: 0 }); }); it('Link element with only an image inside is not editable', () => { aEl.innerHTML = ''; obj = ComponentLink.isComponent(aEl); - expect(obj).toEqual({type: 'link', editable: 0}); + expect(obj).toEqual({ type: 'link', editable: 0 }); }); - }); describe('Map Component', () => { - it('Component parse map iframe', () => { - var src = 'https://maps.google.com/maps?&q=London,UK&z=11&t=q&output=embed'; + var src = + 'https://maps.google.com/maps?&q=London,UK&z=11&t=q&output=embed'; var el = $(''); obj = ComponentMap.isComponent(el.get(0)); - expect(obj).toEqual({type: 'map', src}); + expect(obj).toEqual({ type: 'map', src }); }); it('Component parse not map iframe', () => { - var el = $(''); + var el = $( + '' + ); obj = ComponentMap.isComponent(el.get(0)); expect(obj).toEqual(''); }); - }); describe('Video Component', () => { - it('Component parse video', () => { var src = 'http://localhost/'; var el = $(''); obj = ComponentVideo.isComponent(el.get(0)); - expect(obj).toEqual({type: 'video', src}); + expect(obj).toEqual({ type: 'video', src }); }); it('Component parse youtube video iframe', () => { var src = 'http://www.youtube.com/embed/jNQXAC9IVRw?'; var el = $('