├── .gitignore ├── Gruntfile.js ├── README.md ├── contenttools-build ├── content-tools.js ├── content-tools.min.css ├── content-tools.min.js ├── icons.woff └── images │ ├── ce-drop-above.png │ ├── ce-drop-below.png │ ├── ce-drop-left.png │ ├── ce-drop-right.png │ └── video.png ├── image.png ├── index.html ├── package.json └── sandbox.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* global module:false */ 2 | module.exports = function(grunt) { 3 | var port = grunt.option('port') || 8000; 4 | var base = grunt.option('base') || '.'; 5 | 6 | // Project configuration 7 | grunt.initConfig({ 8 | 9 | connect: { 10 | server: { 11 | options: { 12 | port: port, 13 | base: base, 14 | open: true, 15 | keepalive: true 16 | } 17 | } 18 | }, 19 | 20 | }); 21 | 22 | // Dependencies 23 | grunt.loadNpmTasks( 'grunt-contrib-connect' ); 24 | 25 | // Serve presentation locally 26 | grunt.registerTask( 'serve', [ 'connect' ] ); 27 | 28 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Content Tools & Angular JS 2 | ========================== 3 | 4 | The source code is a demo integration between Content Tools JS and Angular JS. 5 | 6 | [Content Tools JS](https://github.com/GetmeUK/ContentTools) is an inline page 7 | editor which can turn any standard HTML page into a WSYIWYG editor. 8 | 9 | ## Installation 10 | 11 | Install the Node.js dependencies: 12 | 13 | $ npm install 14 | 15 | ## Start the demo site 16 | 17 | $ grunt serve 18 | 19 | ## Usage 20 | 21 | Using an Angular directive called "ng-editor", it will bind the DOM element to 22 | Content Tools and render its content editable: 23 | 24 |
Some content...
26 |Another content....
30 | (https://bitbucket.org/getmeuk/contenttools) */
2 | .ce--dragging,.ce--resizing{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ce--dragging{cursor:move !important}.ce--resizing{cursor:nwse-resize !important}.ce-element--type-image,.ce-element--type-video{background-repeat:no-repeat;position:relative;cursor:pointer;z-index:1}.ce-element--type-image:after,.ce-element--type-image:before,.ce-element--type-video:after,.ce-element--type-video:before{background:rgba(0,0,0,0.5);border-radius:2px;color:white;display:none;font-family:arial, sans-serif;font-size:10px;line-height:10px;padding:4px 4px 3px;position:absolute}.ce-element--type-image:before,.ce-element--type-video:before{content:attr(data-ce-size);right:10px;top:10px}.ce-element--type-image.ce-element--over:before,.ce-element--type-image.ce-element--resizing:before,.ce-element--type-video.ce-element--over:before,.ce-element--type-video.ce-element--resizing:before{display:block}.ce-element--type-image{background-position:0 0;background-size:cover}.ce-element--type-video{background:#333 url("images/video.png") center center no-repeat}.ce-element--type-video:after{bottom:10px;content:attr(data-ce-title);display:block;left:10px}.ce-element--empty:after{display:inline-block;content:'\00a0'}.ce-element--dragging{background-color:rgba(51,51,51,0.1) !important;opacity:0.5;z-index:-1}.ce-element--dragging.ce-element--type-image,.ce-element--dragging.ce-element--type-video{background-color:#333 !important;opacity:1.0;outline-color:rgba(51,51,51,0.1) !important}.ce-element--drop{background:rgba(243,156,18,0.5) none 0 0 repeat !important}.ce-element--drop .ce-element--type-list-item-text,.ce-element--drop .ce-element--type-table-cell-text{background:transparent !important}.ce-element--drop-above{background-image:url("images/ce-drop-above.png") !important}.ce-element--drop-below{background-image:url("images/ce-drop-below.png") !important}.ce-element--drop-left{background-image:url("images/ce-drop-left.png") !important}.ce-element--drop-right{background-image:url("images/ce-drop-right.png") !important}.ce-element--focused,.ce-element--over{background-color:rgba(243,156,18,0.1);outline:none}.ce-element--focused.ce-element--type-image,.ce-element--focused.ce-element--type-video,.ce-element--over.ce-element--type-image,.ce-element--over.ce-element--type-video{background-color:#333;outline:4px solid rgba(243,156,18,0.35)}.ce-element--resize-top-left{cursor:nw-resize}.ce-element--resize-top-right{cursor:ne-resize}.ce-element--resize-bottom-right{cursor:se-resize}.ce-element--resize-bottom-left{cursor:sw-resize}.ce-drag-helper{background:#fff;border-radius:2px;box-shadow:0 3px 3px rgba(0,0,0,0.25);color:#4e4e4e;font:arial, sans-serif;font-size:12px;height:120px;left:0;line-height:135%;margin:5px 0px 0px 5px;overflow:hidden;padding:15px;position:absolute;top:0;width:120px;word-wrap:break-word;z-index:9}.ce-drag-helper:before{background:#2980b9;color:white;content:attr(data-ce-type);display:block;font-family:arial, sans-serif;font-size:10px;line-height:10px;padding:4px 4px 3px;position:absolute;right:0;top:0}.ce-drag-helper--type-list:after,.ce-drag-helper--type-list-item-text:after,.ce-drag-helper--type-pre-text:after,.ce-drag-helper--type-table:after,.ce-drag-helper--type-table-row:after,.ce-drag-helper--type-text:after{background-image:linear-gradient(rgba(255,255,255,0), #fff 66%);bottom:0;content:'';display:block;height:40px;left:0;position:absolute;width:100%}.ce-drag-helper--type-image{background-repeat:no-repeat;background-size:cover}img,iframe,video,.ce-element--type-image,.ce-element--type-video{display:block;margin-left:auto;margin-right:auto}img.align-left,iframe.align-left,video.align-left,.ce-element--type-image.align-left,.ce-element--type-video.align-left{clear:initial;float:left}img.align-right,iframe.align-right,video.align-right,.ce-element--type-image.align-right,.ce-element--type-video.align-right{clear:initial;float:right}.ce-element--type-table-cell-text:empty:before{content:'...';font-style:italic;opacity:0.5}.ce-measure{display:block !important}@font-face{font-family:'icon';src:url("icons.woff");font-weight:normal;font-style:normal}.ct-widget,.ct-widget *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.ct-widget div,.ct-widget span,.ct-widget iframe,.ct-widget a,.ct-widget b,.ct-widget i fieldset,.ct-widget form,.ct-widget label,.ct-widget legend,.ct-widget table,.ct-widget caption,.ct-widget tbody,.ct-widget tfoot,.ct-widget thead,.ct-widget tr,.ct-widget th,.ct-widget td,.ct-widget * div,.ct-widget * span,.ct-widget * iframe,.ct-widget * a,.ct-widget * b,.ct-widget * i fieldset,.ct-widget * form,.ct-widget * label,.ct-widget * legend,.ct-widget * table,.ct-widget * caption,.ct-widget * tbody,.ct-widget * tfoot,.ct-widget * thead,.ct-widget * tr,.ct-widget * th,.ct-widget * td{border:0;font-size:100%;font:inherit;margin:0;padding:0;vertical-align:baseline}.ct-widget ol,.ct-widget ul,.ct-widget * ol,.ct-widget * ul{list-style:none}.ct-widget table,.ct-widget * table{border-collapse:collapse;border-spacing:0}.ct-widget{opacity:0;font-family:arial, sans-serif;font-size:14px;line-height:18px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;z-index:9999;-webkit-transition-property:opacity;-moz-transition-property:opacity;transition-property:opacity;-webkit-transition-duration:0.25s;-moz-transition-duration:0.25s;transition-duration:0.25s;-webkit-transition-timing-function:ease-in;-moz-transition-timing-function:ease-in;transition-timing-function:ease-in}.ct-widget--active{opacity:1;-webkit-transition-property:opacity;-moz-transition-property:opacity;transition-property:opacity;-webkit-transition-duration:0.25s;-moz-transition-duration:0.25s;transition-duration:0.25s;-webkit-transition-timing-function:ease-in;-moz-transition-timing-function:ease-in;transition-timing-function:ease-in}.ct-widget .ct-attribute{border-bottom:1px solid #eee;height:48px;vertical-align:top}.ct-widget .ct-attribute::after{clear:both;content:"";display:table}.ct-widget .ct-attribute__name{background:#f6f6f6;border:none;color:#646464;float:left;height:47px;outline:none;padding:0 16px;font-family:arial, sans-serif;font-size:14px;line-height:48px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:25%}.ct-widget .ct-attribute__name--invalid{color:#e74c3c}.ct-widget .ct-attribute__value{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:white;border:none;color:#646464;float:right;height:47px;outline:none;padding:0 16px;font-family:arial, sans-serif;font-size:14px;line-height:48px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:75%}.ct-widget .ct-cropmarks{height:320px;left:73px;position:absolute;top:0;width:427px}.ct-widget .ct-cropmarks__clipper{height:100%;overflow:hidden;position:relative;width:100%}.ct-widget .ct-cropmarks__ruler--top-left{position:absolute}.ct-widget .ct-cropmarks__ruler--top-left:after{border:1px solid rgba(255,255,255,0.5);border-bottom:none;border-right:none;box-shadow:-1px -1px 1px rgba(0,0,0,0.25),inset 1px 1px 1px rgba(0,0,0,0.25);content:'';height:999px;left:0;position:absolute;top:0;width:999px}.ct-widget .ct-cropmarks__ruler--bottom-right{position:absolute}.ct-widget .ct-cropmarks__ruler--bottom-right:after{border:1px solid rgba(255,255,255,0.5);border-top:none;border-left:none;bottom:0;box-shadow:1px 1px 1px rgba(0,0,0,0.25),inset -1px -1px 1px rgba(0,0,0,0.25);content:'';height:999px;position:absolute;right:0;width:999px}.ct-widget .ct-cropmarks__handle{background:#2980b9;border:1px solid #409ad5;border-radius:7px;cursor:pointer;height:15px;margin-left:-7px;margin-top:-7px;position:absolute;width:15px}.ct-widget .ct-cropmarks__handle--bottom-right{margin-left:-8px;margin-top:-8px}.ct-widget .ct-cropmarks__handle:hover{background:#2e8ece}@-webkit-keyframes busy-dialog{0%{transform:translate(-50%, -50%) rotate(0deg);-webkit-transform:transform}100%{transform:translate(-50%, -50%) rotate(359deg);-webkit-transform:transform}}@-moz-keyframes busy-dialog{0%{transform:translate(-50%, -50%) rotate(0deg);-moz-transform:transform}100%{transform:translate(-50%, -50%) rotate(359deg);-moz-transform:transform}}@keyframes busy-dialog{0%{transform:translate(-50%, -50%) rotate(0deg);-webkit-transform:transform;-moz-transform:transform;-ms-transform:transform;-o-transform:transform;transform:transform}100%{transform:translate(-50%, -50%) rotate(359deg);-webkit-transform:transform;-moz-transform:transform;-ms-transform:transform;-o-transform:transform;transform:transform}}.ct-widget.ct-dialog{background:white;box-shadow:0 8px 8px rgba(0,0,0,0.35);border-radius:2px;height:480px;left:50%;margin-left:-350px;margin-top:-240px;position:fixed;top:50%;width:700px;z-index:10099}.ct-widget.ct-dialog--busy .ct-dialog__busy{display:block}.ct-widget.ct-dialog--busy .ct-dialog__body{opacity:0.1}.ct-widget .ct-dialog__header{color:#a4a4a4;border-bottom:1px solid #eee;height:48px;padding:0 16px;position:relative}.ct-widget .ct-dialog__caption{font-family:arial, sans-serif;font-size:18px;line-height:48px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ct-widget .ct-dialog__close{border-left:1px solid #eee;cursor:pointer;height:48px;line-height:48px;position:absolute;right:0;text-align:center;top:0;font-family:'icon';font-size:16px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:48px}.ct-widget .ct-dialog__close:before{content:'\ea0f'}.ct-widget .ct-dialog__close:hover:before{color:#646464}.ct-widget .ct-dialog__body{margin:auto;width:572px}.ct-widget .ct-dialog__view{height:320px;margin-top:32px}.ct-widget .ct-dialog__controls{margin-top:16px}.ct-widget .ct-dialog__controls::after{clear:both;content:"";display:table}.ct-widget .ct-dialog__busy{display:none;position:absolute}.ct-widget .ct-dialog__busy:before{-webkit-animation:busy-dialog 5s linear;-moz-animation:busy-dialog 5s linear;animation:busy-dialog 5s linear;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-fill-mode:forwards;-moz-animation-fill-mode:forwards;animation-fill-mode:forwards;color:#a4a4a4;content:"\e994";left:50%;position:fixed;top:50%;font-family:'icon';font-size:80px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ct-widget .ct-control-group{font-size:0}.ct-widget .ct-control-group--center{text-align:center}.ct-widget .ct-control-group--left{float:left}.ct-widget .ct-control-group--right{float:right}.ct-widget .ct-control{margin-left:16px;position:relative}.ct-widget .ct-control:first-child{margin-left:0}.ct-widget .ct-control--icon{border-radius:2px;color:#a4a4a4;cursor:pointer;display:inline-block;height:32px;line-height:32px;text-align:center;font-family:'icon';font-size:16px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:32px}.ct-widget .ct-control--icon:after{background:black;border-radius:2px;color:white;content:attr(data-tooltip);display:block;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;hyphens:auto;left:-26.5px;line-height:20px;opacity:0.0;padding:0 8px;position:absolute;bottom:37px;font-family:arial, sans-serif;font-size:12px;line-height:20px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;visibility:hidden;width:85px;word-break:break-word}.ct-widget .ct-control--icon:hover:after{opacity:0.8;visibility:visible;-webkit-transition-property:opacity;-moz-transition-property:opacity;transition-property:opacity;-webkit-transition-duration:0s;-moz-transition-duration:0s;transition-duration:0s;-webkit-transition-timing-function:ease-in;-moz-transition-timing-function:ease-in;transition-timing-function:ease-in;-webkit-transition-delay:2s;-moz-transition-delay:2s;transition-delay:2s}.ct-widget .ct-control--icon:before{content:''}.ct-widget .ct-control--icon:hover{background:#eee;color:#646464}.ct-widget .ct-control--active,.ct-widget .ct-control--on{background:#a4a4a4;color:white}.ct-widget .ct-control--active:hover,.ct-widget .ct-control--on:hover{background:#646464;color:white}.ct-widget .ct-control--rotate-ccw:before{content:'\e965'}.ct-widget .ct-control--rotate-cw:before{content:'\e966'}.ct-widget .ct-control--crop:before{content:'\ea57'}.ct-widget .ct-control--remove:before{content:'\e9ac'}.ct-widget .ct-control--styles:before{content:'\e90b'}.ct-widget .ct-control--attributes:before{content:'\e994'}.ct-widget .ct-control--code:before{content:'\ea80'}.ct-widget .ct-control--icon.ct-control--muted{cursor:default}.ct-widget .ct-control--icon.ct-control--muted:before{opacity:0.5}.ct-widget .ct-control--icon.ct-control--muted:hover{color:#a4a4a4;background:transparent}.ct-widget .ct-control--text{background:#2980b9;border-radius:2px;color:white;cursor:pointer;display:inline-block;font-weight:bold;height:32px;overflow:hidden;padding:0 8px;text-align:center;text-overflow:ellipsis;font-family:arial, sans-serif;font-size:14px;line-height:32px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top;width:100px}.ct-widget .ct-control--text:hover{background:#2e8ece}.ct-widget .ct-control--apply,.ct-widget .ct-control--insert,.ct-widget .ct-control--ok{background:#27ae60}.ct-widget .ct-control--apply:hover,.ct-widget .ct-control--insert:hover,.ct-widget .ct-control--ok:hover{background:#2cc36b}.ct-widget .ct-control--cancel,.ct-widget .ct-control--clear{background:#e74c3c}.ct-widget .ct-control--cancel:hover,.ct-widget .ct-control--clear:hover{background:#ea6153}.ct-widget .ct-control--text.ct-control--muted{background:#ccc;cursor:default}.ct-widget .ct-control--text.ct-control--muted:hover{background:#ccc}.ct-widget .ct-control--upload{overflow:hidden}.ct-widget.ct-image-dialog--empty .ct-progress-bar,.ct-widget.ct-image-dialog--empty .ct-control--rotate-ccw,.ct-widget.ct-image-dialog--empty .ct-control--rotate-cw,.ct-widget.ct-image-dialog--empty .ct-control--crop,.ct-widget.ct-image-dialog--empty .ct-control--insert,.ct-widget.ct-image-dialog--empty .ct-control--cancel,.ct-widget.ct-image-dialog--empty .ct-control--clear{display:none}.ct-widget.ct-image-dialog--uploading .ct-control--rotate-ccw,.ct-widget.ct-image-dialog--uploading .ct-control--rotate-cw,.ct-widget.ct-image-dialog--uploading .ct-control--crop,.ct-widget.ct-image-dialog--uploading .ct-control--upload,.ct-widget.ct-image-dialog--uploading .ct-control--insert,.ct-widget.ct-image-dialog--uploading .ct-control--clear{display:none}.ct-widget.ct-image-dialog--populated .ct-progress-bar,.ct-widget.ct-image-dialog--populated .ct-control--upload,.ct-widget.ct-image-dialog--populated .ct-control--cancel{display:none}.ct-widget .ct-image-dialog__view{background:#eee;position:relative}.ct-widget .ct-image-dialog__view:empty{font-family:'icon';font-size:80px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:320px;text-align:center}.ct-widget .ct-image-dialog__view:empty:before{color:white;content:'\e90d'}.ct-widget .ct-image-dialog__image{background-color:transparent;background-position:center center;background-repeat:no-repeat;background-size:contain;height:100%;width:100%}.ct-widget .ct-image-dialog__file-upload{cursor:pointer;font-size:400px;left:0;opacity:0;position:absolute;top:0}.ct-widget.ct-properties-dialog--attributes .ct-properties-dialog__attributes{display:block}.ct-widget.ct-properties-dialog--styles .ct-properties-dialog__styles{display:block}.ct-widget.ct-properties-dialog--styles .ct-properties-dialog__styles:empty:before{color:#a4a4a4;content:attr(data-ct-empty);display:block;font-style:italic;margin-top:20px;text-align:center}.ct-widget.ct-properties-dialog--code .ct-properties-dialog__code{display:block}.ct-widget .ct-properties-dialog__view{border:1px solid #ddd;overflow:auto}.ct-widget .ct-properties-dialog__attributes,.ct-widget .ct-properties-dialog__code,.ct-widget .ct-properties-dialog__styles{display:none}.ct-widget .ct-properties-dialog__inner-html{border:none;display:block;font-family:courier,"Bitstream Vera Sans Mono",Consolas,Courier,monospace;height:318px;padding:16px;outline:none;resize:none;width:100%}.ct-widget .ct-properties-dialog__inner-html--invalid{color:#e74c3c}.ct-widget .ct-table-dialog__view{border:1px solid #ddd;overflow:auto}.ct-widget .ct-video-dialog__preview:empty{background:#eee;font-family:'icon';font-size:80px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:320px;text-align:center}.ct-widget .ct-video-dialog__preview:empty:before{color:white;content:'\ea98'}.ct-widget .ct-video-dialog__input{border:none;border-bottom:1px solid #eee;height:32px;line-height:32px;outline:none;padding:0 4px;font-family:arial, sans-serif;font-size:14px;line-height:18px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top;width:456px}.ct-widget .ct-video-dialog__input:focus{border-bottom:1px solid #e1e1e1}.ct-widget.ct-anchored-dialog{border-bottom:2px solid #27ae60;box-shadow:0 3px 3px rgba(0,0,0,0.35);font-size:0;height:34px;left:0;margin-left:-144px;margin-top:-48px;position:absolute;top:0;z-index:10099}.ct-widget.ct-anchored-dialog:after{border:16px solid rgba(255,255,255,0);border-top-color:#27ae60;content:'';left:128px;position:absolute;top:34px}.ct-widget .ct-anchored-dialog__input{border:none;color:#646464;height:32px;outline:none;font-family:arial, sans-serif;font-size:14px;line-height:32px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;padding:0 16px;vertical-align:top;width:256px}.ct-widget .ct-anchored-dialog__button{background:#27ae60;cursor:pointer;display:inline-block;height:32px;line-height:32px;text-align:center;font-family:'icon';font-size:16px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:32px}.ct-widget .ct-anchored-dialog__button:before{color:white;content:'\ea10'}.ct-widget .ct-anchored-dialog__button:hover{background:#2cc36b}@-webkit-keyframes flash{0%{opacity:0;font-size:32px;-webkit-transform:font-size}25%{font-size:320px;opacity:1;-webkit-transform:all}50%{font-size:320px;opacity:1;-webkit-transform:all}75%{font-size:320px;opacity:1;-webkit-transform:all}100%{opacity:0;-webkit-transform:all}}@-moz-keyframes flash{0%{opacity:0;font-size:32px;-moz-transform:font-size}25%{font-size:320px;opacity:1;-moz-transform:all}50%{font-size:320px;opacity:1;-moz-transform:all}75%{font-size:320px;opacity:1;-moz-transform:all}100%{opacity:0;-moz-transform:all}}@keyframes flash{0%{opacity:0;font-size:32px;-webkit-transform:font-size;-moz-transform:font-size;-ms-transform:font-size;-o-transform:font-size;transform:font-size}25%{font-size:320px;opacity:1;-webkit-transform:all;-moz-transform:all;-ms-transform:all;-o-transform:all;transform:all}50%{font-size:320px;opacity:1;-webkit-transform:all;-moz-transform:all;-ms-transform:all;-o-transform:all;transform:all}75%{font-size:320px;opacity:1;-webkit-transform:all;-moz-transform:all;-ms-transform:all;-o-transform:all;transform:all}100%{opacity:0;-webkit-transform:all;-moz-transform:all;-ms-transform:all;-o-transform:all;transform:all}}@-webkit-keyframes flash-timer{0%{opacity:1;-webkit-transform:opacity}99%{opacity:1;-webkit-transform:opacity}100%{opacity:0;-webkit-transform:opacity}}@-moz-keyframes flash-timer{0%{opacity:1;-moz-transform:opacity}99%{opacity:1;-moz-transform:opacity}100%{opacity:0;-moz-transform:opacity}}@keyframes flash-timer{0%{opacity:1;-webkit-transform:opacity;-moz-transform:opacity;-ms-transform:opacity;-o-transform:opacity;transform:opacity}99%{opacity:1;-webkit-transform:opacity;-moz-transform:opacity;-ms-transform:opacity;-o-transform:opacity;transform:opacity}100%{opacity:0;-webkit-transform:opacity;-moz-transform:opacity;-ms-transform:opacity;-o-transform:opacity;transform:opacity}}.ct-widget.ct-flash{color:rgba(255,255,255,0.9);height:0;left:0;position:fixed;font-family:'icon';font-size:16px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;top:0;width:0;z-index:10999}.ct-widget.ct-flash:before{left:50%;opacity:0;position:fixed;text-shadow:0 0 20px rgba(0,0,0,0.5);top:50%;transform:translate(-50%, -50%)}.ct-widget.ct-flash--active{-webkit-animation:flash-timer 2s ease-in;-moz-animation:flash-timer 2s ease-in;animation:flash-timer 2s ease-in;-webkit-animation-iteration-count:1;-moz-animation-iteration-count:1;animation-iteration-count:1;-webkit-animation-fill-mode:forwards;-moz-animation-fill-mode:forwards;animation-fill-mode:forwards}.ct-widget.ct-flash--active:before{-webkit-animation:flash 2s ease-in;-moz-animation:flash 2s ease-in;animation:flash 2s ease-in;-webkit-animation-iteration-count:1;-moz-animation-iteration-count:1;animation-iteration-count:1;-webkit-animation-fill-mode:forwards;-moz-animation-fill-mode:forwards;animation-fill-mode:forwards;font-size:320px;opacity:1}.ct-widget.ct-flash--ok:before{content:'\ea10'}.ct-widget.ct-flash--no:before{content:'\ea0f'}.ct-widget .ct-grip{cursor:move;font-size:0;text-align:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ct-widget .ct-grip__bump{background:rgba(70,70,70,0.15);border-radius:12px;display:inline-block;height:12px;margin-left:12px;width:12px}.ct-widget .ct-grip__bump:first-child{margin-left:0}@-webkit-keyframes busy-ignition{0%{transform:rotate(0deg);-webkit-transform:transform}100%{transform:rotate(359deg);-webkit-transform:transform}}@-moz-keyframes busy-ignition{0%{transform:rotate(0deg);-moz-transform:transform}100%{transform:rotate(359deg);-moz-transform:transform}}@keyframes busy-ignition{0%{transform:rotate(0deg);-webkit-transform:transform;-moz-transform:transform;-ms-transform:transform;-o-transform:transform;transform:transform}100%{transform:rotate(359deg);-webkit-transform:transform;-moz-transform:transform;-ms-transform:transform;-o-transform:transform;transform:transform}}.ct-widget.ct-ignition{left:16px;position:fixed;top:16px}.ct-widget.ct-ignition .ct-ignition__button{display:none}.ct-widget.ct-ignition--editing .ct-ignition__button--confirm,.ct-widget.ct-ignition--editing .ct-ignition__button--cancel{display:block}.ct-widget.ct-ignition--ready .ct-ignition__button--edit{display:block}.ct-widget.ct-ignition--busy .ct-ignition__button{display:none}.ct-widget.ct-ignition--busy .ct-ignition__button--busy{display:block}.ct-widget .ct-ignition__button{border-radius:24px;content:'';cursor:pointer;display:block;height:48px;line-height:48px;opacity:0.9;position:absolute;text-align:center;font-family:'icon';font-size:24px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:48px}.ct-widget .ct-ignition__button:before{color:white}.ct-widget .ct-ignition__button--busy{-webkit-animation:busy-ignition 5s linear;-moz-animation:busy-ignition 5s linear;animation:busy-ignition 5s linear;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-fill-mode:forwards;-moz-animation-fill-mode:forwards;animation-fill-mode:forwards;background:#646464;cursor:default}.ct-widget .ct-ignition__button--busy:before{content:'\e994'}.ct-widget .ct-ignition__button--busy:hover{background:#646464}.ct-widget .ct-ignition__button--confirm{background:#27ae60}.ct-widget .ct-ignition__button--confirm:before{content:'\ea10'}.ct-widget .ct-ignition__button--confirm:hover{background:#2cc36b}.ct-widget .ct-ignition__button--cancel{background:#e74c3c;left:64px}.ct-widget .ct-ignition__button--cancel:before{content:'\ea0f'}.ct-widget .ct-ignition__button--cancel:hover{background:#ea6153}.ct-widget .ct-ignition__button--edit{background:#2980b9}.ct-widget .ct-ignition__button--edit:before{content:'\e905';-webkit-transition-property:-webkit-transform;-moz-transition-property:-moz-transform;transition-property:transform;-webkit-transition-duration:0.1s;-moz-transition-duration:0.1s;transition-duration:0.1s;-webkit-transition-timing-function:ease-in;-moz-transition-timing-function:ease-in;transition-timing-function:ease-in}.ct-widget .ct-ignition__button--edit:hover{background:#2e8ece}.ct-widget .ct-ignition__button--edit:hover:before{display:inline-block;-webkit-transform:rotate(-15deg);-moz-transform:rotate(-15deg);-ms-transform:rotate(-15deg);-o-transform:rotate(-15deg);transform:rotate(-15deg)}.ct-widget.ct-inspector{background:rgba(233,233,233,0.2);border-top:1px solid rgba(255,255,255,0.1);bottom:0;height:32px;left:0;overflow:hidden;padding:3px 16px 0;position:fixed;width:100%}.ct-widget .ct-inspector__tags::after{clear:both;content:"";display:table}.ct-widget .ct-inspector__tags:before{color:#464646;content:'\ea80';display:block;float:left;height:24px;line-height:24px;margin-right:16px;text-align:center;font-family:'icon';font-size:16px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:24px}.ct-widget .ct-tag{background-color:#2980b9;border-radius:2px 0 0 2px;color:white;cursor:pointer;float:left;font-weight:bold;height:24px;line-height:24px;margin-left:24px;padding:0 8px;position:relative;text-shadow:0 1px 0 rgba(0,0,0,0.35)}.ct-widget .ct-tag:after{border-style:solid;border-bottom:12px solid rgba(255,0,0,0);border-left:12px solid #2980b9;border-right:none;border-top:12px solid rgba(255,0,0,0);content:'';display:block;height:24px;bottom:0;right:-24px;position:absolute;width:24px;-moz-transform:scale(0.9999)}.ct-widget .ct-tag:first-child{margin-left:0}.ct-widget .ct-tag:hover{background-color:#4aa3df}.ct-widget .ct-tag:hover:after{border-left-color:#4aa3df}.ct-widget .ct-tag:nth-child(1){background-color:#8e44ad}.ct-widget .ct-tag:nth-child(1):after{border-left-color:#8e44ad}.ct-widget .ct-tag:nth-child(1):hover{background-color:#9b50ba}.ct-widget .ct-tag:nth-child(1):hover:after{border-left-color:#9b50ba}.ct-widget .ct-tag:nth-child(2){background-color:#2980b9}.ct-widget .ct-tag:nth-child(2):after{border-left-color:#2980b9}.ct-widget .ct-tag:nth-child(2):hover{background-color:#2e8ece}.ct-widget .ct-tag:nth-child(2):hover:after{border-left-color:#2e8ece}.ct-widget .ct-tag:nth-child(3){background-color:#27ae60}.ct-widget .ct-tag:nth-child(3):after{border-left-color:#27ae60}.ct-widget .ct-tag:nth-child(3):hover{background-color:#2cc36b}.ct-widget .ct-tag:nth-child(3):hover:after{border-left-color:#2cc36b}.ct-widget .ct-tag:nth-child(4){background-color:#d35400}.ct-widget .ct-tag:nth-child(4):after{border-left-color:#d35400}.ct-widget .ct-tag:nth-child(4):hover{background-color:#ec5e00}.ct-widget .ct-tag:nth-child(4):hover:after{border-left-color:#ec5e00}.ct-widget .ct-tag:nth-child(5){background-color:#f39c12}.ct-widget .ct-tag:nth-child(5):after{border-left-color:#f39c12}.ct-widget .ct-tag:nth-child(5):hover{background-color:#f4a62a}.ct-widget .ct-tag:nth-child(5):hover:after{border-left-color:#f4a62a}.ct-widget .ct-tag:nth-child(6){background-color:#16a085}.ct-widget .ct-tag:nth-child(6):after{border-left-color:#16a085}.ct-widget .ct-tag:nth-child(6):hover{background-color:#19b698}.ct-widget .ct-tag:nth-child(6):hover:after{border-left-color:#19b698}.ct-widget.ct-modal{background:rgba(0,0,0,0.7);height:0;left:0;position:fixed;top:0;width:0;z-index:10009}.ct-widget.ct-modal--transparent{background:transparent}.ct-widget--active.ct-modal{height:100%;width:100%}.ct-widget .ct-progress-bar{border:1px solid #eee;height:32px;line-height:32px;padding:1px;width:456px}.ct-widget .ct-progress-bar__progress{background:#2980b9;height:28px}.ct-widget .ct-section{border-bottom:1px solid #eee;color:#bdbdbd;cursor:pointer;font-style:italic;height:48px;padding:0 16px;font-family:arial, sans-serif;font-size:16px;line-height:48px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ct-widget .ct-section::after{clear:both;content:"";display:table}.ct-widget .ct-section:hover{background:#f6f6f6}.ct-widget .ct-section--applied{color:#646464;font-style:normal}.ct-widget .ct-section--applied .ct-section__switch{background-color:#27ae60;border:1px solid #1e8449}.ct-widget .ct-section--applied .ct-section__switch:before{left:25px;-webkit-transition-property:left;-moz-transition-property:left;transition-property:left;-webkit-transition-duration:0.1s;-moz-transition-duration:0.1s;transition-duration:0.1s;-webkit-transition-timing-function:ease-in;-moz-transition-timing-function:ease-in;transition-timing-function:ease-in}.ct-widget .ct-section--contains-input .ct-section__label{width:75%}.ct-widget .ct-section__label{float:left;overflow:hidden;text-overflow:ellipsis;width:472px;white-space:nowrap}.ct-widget .ct-section__switch{background-color:#ccc;border:1px solid #b3b3b3;border-radius:12px;box-shadow:inset 0px 0 2px rgba(0,0,0,0.1);float:right;height:24px;margin-top:12px;position:relative;width:48px}.ct-widget .ct-section__switch:before{background:white;border-radius:10px;content:'';height:20px;left:1px;position:absolute;top:1px;-webkit-transition-property:left;-moz-transition-property:left;transition-property:left;-webkit-transition-duration:0.1s;-moz-transition-duration:0.1s;transition-duration:0.1s;-webkit-transition-timing-function:ease-in;-moz-transition-timing-function:ease-in;transition-timing-function:ease-in;width:20px}.ct-widget .ct-section__input{background:white;border:none;color:#646464;float:right;height:47px;outline:none;padding:0 16px;text-align:right;font-family:arial, sans-serif;font-size:14px;line-height:48px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:25%}.ct-widget .ct-section__input--invalid{color:#e74c3c}.ct-widget.ct-toolbox{background:rgba(233,233,233,0.9);border:1px solid rgba(255,255,255,0.5);box-shadow:0 3px 3px rgba(0,0,0,0.35);left:128px;padding:8px;position:fixed;top:128px;width:138px}.ct-widget.ct-toolbox--dragging{opacity:0.5}.ct-widget .ct-toolbox__grip{padding:8px 0}.ct-widget .ct-tool-group{padding:4px 0}.ct-widget .ct-tool-group::after{clear:both;content:"";display:table}.ct-widget .ct-tool-group:first-child{padding-top:0}.ct-widget .ct-tool{border-radius:2px;color:#464646;cursor:pointer;float:left;height:32px;margin:4px;margin-right:4px;position:relative;text-align:center;font-family:'icon';font-size:16px;font-style:normal;font-weight:normal;font-variant:normal;speak:none;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:32px}.ct-widget .ct-tool:after{background:black;border-radius:2px;color:white;content:attr(data-tooltip);display:block;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;hyphens:auto;left:-26.5px;line-height:20px;opacity:0.0;padding:0 8px;position:absolute;bottom:37px;font-family:arial, sans-serif;font-size:12px;line-height:20px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;visibility:hidden;width:85px;word-break:break-word}.ct-widget .ct-tool:hover:after{opacity:0.8;visibility:visible;-webkit-transition-property:opacity;-moz-transition-property:opacity;transition-property:opacity;-webkit-transition-duration:0s;-moz-transition-duration:0s;transition-duration:0s;-webkit-transition-timing-function:ease-in;-moz-transition-timing-function:ease-in;transition-timing-function:ease-in;-webkit-transition-delay:2s;-moz-transition-delay:2s;transition-delay:2s}.ct-widget .ct-tool:before{line-height:32px}.ct-widget .ct-tool:nth-child(3n){margin-right:0}.ct-widget .ct-tool:hover{background:rgba(255,255,255,0.5)}.ct-widget .ct-tool--disabled{color:rgba(70,70,70,0.33)}.ct-widget .ct-tool--disabled:hover{background:transparent}.ct-widget .ct-tool--down{background:rgba(0,0,0,0.025);box-shadow:inset 0 1px 3px rgba(0,0,0,0.25);line-height:34px}.ct-widget .ct-tool--down:hover{background:rgba(0,0,0,0.025)}.ct-widget .ct-tool--applied{background:rgba(0,0,0,0.1);box-shadow:inset 0 1px 3px rgba(0,0,0,0.25)}.ct-widget .ct-tool--applied:hover{background:rgba(0,0,0,0.15)}.ct-widget .ct-tool--bold:before{content:"\ea62"}.ct-widget .ct-tool--heading:before{content:"H";font-weight:bold}.ct-widget .ct-tool--subheading:before{content:"H"}.ct-widget .ct-tool--paragraph:before{content:"P"}.ct-widget .ct-tool--preformatted:before{content:"\ea80"}.ct-widget .ct-tool--italic:before{content:"\ea64"}.ct-widget .ct-tool--link:before{content:"\e9cb"}.ct-widget .ct-tool--align-left:before{content:"\ea77"}.ct-widget .ct-tool--align-center:before{content:"\ea78"}.ct-widget .ct-tool--align-right:before{content:"\ea79"}.ct-widget .ct-tool--unordered-list:before{content:"\e9ba"}.ct-widget .ct-tool--ordered-list:before{content:"\e9b9"}.ct-widget .ct-tool--table:before{content:"\ea71"}.ct-widget .ct-tool--indent:before{content:"\ea7b"}.ct-widget .ct-tool--unindent:before{content:"\ea7c"}.ct-widget .ct-tool--line-break:before{content:"\ea6e"}.ct-widget .ct-tool--image:before{content:"\e90d"}.ct-widget .ct-tool--video:before{content:"\ea98"}.ct-widget .ct-tool--undo:before{content:"\e965"}.ct-widget .ct-tool--redo:before{content:"\e966"}.ct-widget .ct-tool--remove:before{content:"\e9ac"}@-webkit-keyframes highlight{0%{outline-color:rgba(255,255,255,0);-webkit-transform:background-color}25%{outline-color:rgba(243,156,18,0.25);-webkit-transform:background-color}50%{outline-color:rgba(243,156,18,0.25);-webkit-transform:background-color}100%{outline-color:rgba(255,255,255,0);-webkit-transform:background-color}}@-moz-keyframes highlight{0%{outline-color:rgba(255,255,255,0);-moz-transform:background-color}25%{outline-color:rgba(243,156,18,0.25);-moz-transform:background-color}50%{outline-color:rgba(243,156,18,0.25);-moz-transform:background-color}100%{outline-color:rgba(255,255,255,0);-moz-transform:background-color}}@keyframes highlight{0%{outline-color:rgba(255,255,255,0);-webkit-transform:background-color;-moz-transform:background-color;-ms-transform:background-color;-o-transform:background-color;transform:background-color}25%{outline-color:rgba(243,156,18,0.25);-webkit-transform:background-color;-moz-transform:background-color;-ms-transform:background-color;-o-transform:background-color;transform:background-color}50%{outline-color:rgba(243,156,18,0.25);-webkit-transform:background-color;-moz-transform:background-color;-ms-transform:background-color;-o-transform:background-color;transform:background-color}100%{outline-color:rgba(255,255,255,0);-webkit-transform:background-color;-moz-transform:background-color;-ms-transform:background-color;-o-transform:background-color;transform:background-color}}.ct-app{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.ct-app *,.ct-app *:before,.ct-app *:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.ct--highlight{outline:4px solid rgba(243,156,18,0.25);-webkit-animation:highlight 0.5s ease-in;-moz-animation:highlight 0.5s ease-in;animation:highlight 0.5s ease-in;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-fill-mode:forwards;-moz-animation-fill-mode:forwards;animation-fill-mode:forwards}.ct--no-scroll{overflow:hidden}.ct--puesdo-select{background:rgba(0,0,0,0.1)}
3 |
--------------------------------------------------------------------------------
/contenttools-build/content-tools.min.js:
--------------------------------------------------------------------------------
1 | /*! ContentTools v0.1.0 by Getme Limited (https://bitbucket.org/getmeuk/contenttools) */
2 | (function(){window.FSM={},FSM.Machine=function(){function Machine(context){this.context=context,this._stateTransitions={},this._stateTransitionsAny={},this._defaultTransition=null,this._initialState=null,this._currentState=null}return Machine.prototype.addTransition=function(action,state,nextState,callback){return nextState||(nextState=state),this._stateTransitions[[action,state]]=[nextState,callback]},Machine.prototype.addTransitions=function(actions,state,nextState,callback){var action,_i,_len,_results;for(nextState||(nextState=state),_results=[],_i=0,_len=actions.length;_len>_i;_i++)action=actions[_i],_results.push(this.addTransition(action,state,nextState,callback));return _results},Machine.prototype.addTransitionAny=function(state,nextState,callback){return nextState||(nextState=state),this._stateTransitionsAny[state]=[nextState,callback]},Machine.prototype.setDefaultTransition=function(state,callback){return this._defaultTransition=[state,callback]},Machine.prototype.getTransition=function(action,state){if(this._stateTransitions[[action,state]])return this._stateTransitions[[action,state]];if(this._stateTransitionsAny[state])return this._stateTransitionsAny[state];if(this._defaultTransition)return this._defaultTransition;throw new Error("Transition is undefined: ("+action+", "+state+")")},Machine.prototype.getCurrentState=function(){return this._currentState},Machine.prototype.setInitialState=function(state){return this._initialState=state,this._currentState?void 0:this.reset()},Machine.prototype.reset=function(){return this._currentState=this._initialState},Machine.prototype.process=function(action){var result;return result=this.getTransition(action,this._currentState),result[1]&&result[1].call(this.context||(this.context=this),action),this._currentState=result[0]},Machine}()}).call(this),function(){var ALPHA_CHARS,ALPHA_NUMERIC_CHARS,ATTR_DELIM,ATTR_ENTITY_DOUBLE_DELIM,ATTR_ENTITY_NO_DELIM,ATTR_ENTITY_SINGLE_DELIM,ATTR_NAME,ATTR_NAME_FIND_VALUE,ATTR_OR_TAG_END,ATTR_VALUE_DOUBLE_DELIM,ATTR_VALUE_NO_DELIM,ATTR_VALUE_SINGLE_DELIM,CHAR_OR_ENTITY_OR_TAG,CLOSING_TAG,ENTITY,ENTITY_CHARS,OPENING_TAG,OPENNING_OR_CLOSING_TAG,TAG_NAME_CLOSING,TAG_NAME_MUST_CLOSE,TAG_NAME_OPENING,TAG_OPENING_SELF_CLOSING,_Parser,__slice=[].slice,__indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};window.HTMLString={},HTMLString.String=function(){function String(html,preserveWhitespace){null==preserveWhitespace&&(preserveWhitespace=!1),this._preserveWhitespace=preserveWhitespace,html?(null===HTMLString.String._parser&&(HTMLString.String._parser=new _Parser),this.characters=HTMLString.String._parser.parse(html,this._preserveWhitespace).characters):this.characters=[]}return String._parser=null,String.prototype.isWhitespace=function(){var c,_i,_len,_ref;for(_ref=this.characters,_i=0,_len=_ref.length;_len>_i;_i++)if(c=_ref[_i],!c.isWhitespace())return!1;return!0},String.prototype.length=function(){return this.characters.length},String.prototype.preserveWhitespace=function(){return this._preserveWhitespace},String.prototype.capitalize=function(){var c,newString;return newString=this.copy(),newString.length()&&(c=newString.characters[0]._c.toUpperCase(),newString.characters[0]._c=c),newString},String.prototype.charAt=function(index){return this.characters[index].copy()},String.prototype.concat=function(){var c,indexChar,inheritFormat,inheritedTags,newString,string,strings,tail,_i,_j,_k,_l,_len,_len1,_len2,_ref,_ref1;for(strings=2<=arguments.length?__slice.call(arguments,0,_i=arguments.length-1):(_i=0,[]),inheritFormat=arguments[_i++],"undefined"!=typeof inheritFormat&&"boolean"!=typeof inheritFormat&&(strings.push(inheritFormat),inheritFormat=!0),newString=this.copy(),_j=0,_len=strings.length;_len>_j;_j++)if(string=strings[_j],0!==string.length){if(tail=string,"string"==typeof string&&(tail=new HTMLString.String(string,this._preserveWhitespace)),inheritFormat&&newString.length())for(indexChar=newString.charAt(newString.length()-1),inheritedTags=indexChar.tags(),indexChar.isTag()&&inheritedTags.shift(),"string"!=typeof string&&(tail=tail.copy()),_ref=tail.characters,_k=0,_len1=_ref.length;_len1>_k;_k++)c=_ref[_k],c.addTags.apply(c,inheritedTags);for(_ref1=tail.characters,_l=0,_len2=_ref1.length;_len2>_l;_l++)c=_ref1[_l],newString.characters.push(c)}return newString},String.prototype.contains=function(substring){var c,found,from,i,_i,_len,_ref;if("string"==typeof substring)return this.text().indexOf(substring)>-1;for(from=0;from<=this.length()-substring.length();){for(found=!0,_ref=substring.characters,i=_i=0,_len=_ref.length;_len>_i;i=++_i)if(c=_ref[i],!c.eq(this.characters[i+from])){found=!1;break}if(found)return!0;from++}return!1},String.prototype.endsWith=function(substring){var c,characters,i,_i,_len,_ref;if("string"==typeof substring)return""===substring||this.text().slice(-substring.length)===substring;for(characters=this.characters.slice().reverse(),_ref=substring.characters.slice().reverse(),i=_i=0,_len=_ref.length;_len>_i;i=++_i)if(c=_ref[i],!c.eq(characters[i]))return!1;return!0},String.prototype.format=function(){var c,from,i,newString,tags,to,_i;for(from=arguments[0],to=arguments[1],tags=3<=arguments.length?__slice.call(arguments,2):[],0>to&&(to=this.length()+to+1),0>from&&(from=this.length()+from),newString=this.copy(),i=_i=from;to>=from?to>_i:_i>to;i=to>=from?++_i:--_i)c=newString.characters[i],c.addTags.apply(c,tags);return newString},String.prototype.hasTags=function(){var c,found,strict,tags,_i,_j,_len,_ref;for(tags=2<=arguments.length?__slice.call(arguments,0,_i=arguments.length-1):(_i=0,[]),strict=arguments[_i++],"undefined"!=typeof strict&&"boolean"!=typeof strict&&(tags.push(strict),strict=!1),found=!1,_ref=this.characters,_j=0,_len=_ref.length;_len>_j;_j++)if(c=_ref[_j],c.hasTags.apply(c,tags))found=!0;else if(strict)return!1;return found},String.prototype.html=function(){var c,closingTag,closingTags,head,html,openHeads,openTag,openTags,tag,_i,_j,_k,_l,_len,_len1,_len2,_len3,_len4,_m,_ref,_ref1,_ref2,_ref3;for(html="",openTags=[],openHeads=[],closingTags=[],_ref=this.characters,_i=0,_len=_ref.length;_len>_i;_i++){for(c=_ref[_i],closingTags=[],_ref1=openTags.slice().reverse(),_j=0,_len1=_ref1.length;_len1>_j;_j++)if(openTag=_ref1[_j],closingTags.push(openTag),!c.hasTags(openTag)){for(_k=0,_len2=closingTags.length;_len2>_k;_k++)closingTag=closingTags[_k],html+=closingTag.tail(),openTags.pop(),openHeads.pop();closingTags=[]}for(_ref2=c._tags,_l=0,_len3=_ref2.length;_len3>_l;_l++)tag=_ref2[_l],-1===openHeads.indexOf(tag.head())&&(head=tag.head(),html+=head,tag.selfClosing()||(openTags.push(tag),openHeads.push(head)));html+=c.c()}for(_ref3=openTags.reverse(),_m=0,_len4=_ref3.length;_len4>_m;_m++)tag=_ref3[_m],html+=tag.tail();return html},String.prototype.indexOf=function(substring,from){var c,found,i,skip,_i,_j,_len,_len1,_ref;if(null==from&&(from=0),0>from&&(from=0),"string"==typeof substring){if(!this.contains(substring))return-1;for(substring=substring.split("");from<=this.length()-substring.length;){for(found=!0,skip=0,i=_i=0,_len=substring.length;_len>_i;i=++_i)if(c=substring[i],this.characters[i+from].isTag()&&(skip+=1),c!==this.characters[skip+i+from].c()){found=!1;break}if(found)return from;from++}return-1}for(;from<=this.length()-substring.length();){for(found=!0,_ref=substring.characters,i=_j=0,_len1=_ref.length;_len1>_j;i=++_j)if(c=_ref[i],!c.eq(this.characters[i+from])){found=!1;break}if(found)return from;from++}return-1},String.prototype.insert=function(index,substring,inheritFormat){var c,head,indexChar,inheritedTags,middle,newString,tail,_i,_j,_k,_len,_len1,_len2,_ref,_ref1,_ref2;if(null==inheritFormat&&(inheritFormat=!0),head=this.slice(0,index),tail=this.slice(index),0>index&&(index=this.length()+index),middle=substring,"string"==typeof substring&&(middle=new HTMLString.String(substring,this._preserveWhitespace)),inheritFormat&&index>0)for(indexChar=this.charAt(index-1),inheritedTags=indexChar.tags(),indexChar.isTag()&&inheritedTags.shift(),"string"!=typeof substring&&(middle=middle.copy()),_ref=middle.characters,_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],c.addTags.apply(c,inheritedTags);for(newString=head,_ref1=middle.characters,_j=0,_len1=_ref1.length;_len1>_j;_j++)c=_ref1[_j],newString.characters.push(c);for(_ref2=tail.characters,_k=0,_len2=_ref2.length;_len2>_k;_k++)c=_ref2[_k],newString.characters.push(c);return newString},String.prototype.lastIndexOf=function(substring,from){var c,characters,found,i,skip,_i,_j,_len,_len1;if(null==from&&(from=0),0>from&&(from=0),characters=this.characters.slice(from).reverse(),from=0,"string"==typeof substring){if(!this.contains(substring))return-1;for(substring=substring.split("").reverse();from<=characters.length-substring.length;){for(found=!0,skip=0,i=_i=0,_len=substring.length;_len>_i;i=++_i)if(c=substring[i],characters[i+from].isTag()&&(skip+=1),c!==characters[skip+i+from].c()){found=!1;break}if(found)return from;from++}return-1}for(substring=substring.characters.slice().reverse();from<=characters.length-substring.length;){for(found=!0,i=_j=0,_len1=substring.length;_len1>_j;i=++_j)if(c=substring[i],!c.eq(characters[i+from])){found=!1;break}if(found)return from;from++}return-1},String.prototype.optimize=function(){var c,closingTag,closingTags,head,lastC,len,openHeads,openTag,openTags,runLength,runLengthSort,runLengths,run_length,t,tag,_i,_j,_k,_l,_len,_len1,_len2,_len3,_len4,_len5,_len6,_m,_n,_o,_ref,_ref1,_ref2,_ref3,_ref4,_ref5,_results;for(openTags=[],openHeads=[],lastC=null,_ref=this.characters.slice().reverse(),_i=0,_len=_ref.length;_len>_i;_i++){for(c=_ref[_i],c._runLengthMap={},c._runLengthMapSize=0,closingTags=[],_ref1=openTags.slice().reverse(),_j=0,_len1=_ref1.length;_len1>_j;_j++)if(openTag=_ref1[_j],closingTags.push(openTag),!c.hasTags(openTag)){for(_k=0,_len2=closingTags.length;_len2>_k;_k++)closingTag=closingTags[_k],openTags.pop(),openHeads.pop();closingTags=[]}for(_ref2=c._tags,_l=0,_len3=_ref2.length;_len3>_l;_l++)tag=_ref2[_l],-1===openHeads.indexOf(tag.head())&&(tag.selfClosing()||(openTags.push(tag),openHeads.push(tag.head())));for(_m=0,_len4=openTags.length;_len4>_m;_m++)tag=openTags[_m],head=tag.head(),lastC?(c._runLengthMap[head]||(c._runLengthMap[head]=[tag,0]),run_length=0,lastC._runLengthMap[head]&&(run_length=lastC._runLengthMap[head][1]),c._runLengthMap[head][1]=run_length+1):c._runLengthMap[head]=[tag,1];lastC=c}for(runLengthSort=function(a,b){return b[1]-a[1]},_ref3=this.characters,_results=[],_n=0,_len5=_ref3.length;_len5>_n;_n++)if(c=_ref3[_n],len=c._tags.length,!(len>0&&c._tags[0].selfClosing()&&3>len||2>len)){runLengths=[],_ref4=c._runLengthMap;for(tag in _ref4)runLength=_ref4[tag],runLengths.push(runLength);for(runLengths.sort(runLengthSort),_ref5=c._tags.slice(),_o=0,_len6=_ref5.length;_len6>_o;_o++)tag=_ref5[_o],tag.selfClosing()||c.removeTags(tag);_results.push(c.addTags.apply(c,function(){var _len7,_p,_results1;for(_results1=[],_p=0,_len7=runLengths.length;_len7>_p;_p++)t=runLengths[_p],_results1.push(t[0]);return _results1}()))}return _results},String.prototype.slice=function(from,to){var c,newString;return newString=new HTMLString.String("",this._preserveWhitespace),newString.characters=function(){var _i,_len,_ref,_results;for(_ref=this.characters.slice(from,to),_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c.copy());return _results}.call(this),newString},String.prototype.split=function(separator,limit){var count,i,index,indexes,lastIndex,substrings,_i,_ref;for(null==separator&&(separator=""),null==limit&&(limit=0),lastIndex=0,count=0,indexes=[0];;){if(limit>0&&count>limit)break;if(index=this.indexOf(separator,lastIndex),-1===index||index===this.length()-1)break;indexes.push(index),lastIndex=index+1}for(indexes.push(this.length()),substrings=[],i=_i=0,_ref=indexes.length-2;_ref>=0?_ref>=_i:_i>=_ref;i=_ref>=0?++_i:--_i)substrings.push(this.slice(indexes[i],indexes[i+1]));return substrings},String.prototype.startsWith=function(substring){var c,i,_i,_len,_ref;if("string"==typeof substring)return this.text().slice(0,substring.length)===substring;for(_ref=substring.characters,i=_i=0,_len=_ref.length;_len>_i;i=++_i)if(c=_ref[i],!c.eq(this.characters[i]))return!1;return!0},String.prototype.substr=function(from,length){return 0>=length?new HTMLString.String("",this._preserveWhitespace):(0>from&&(from=this.length()+from),void 0===length&&(length=this.length()-from),this.slice(from,from+length))},String.prototype.substring=function(from,to){return void 0===to&&(to=this.length()),this.slice(from,to)},String.prototype.text=function(){var c,text,_i,_len,_ref;for(text="",_ref=this.characters,_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],c.isTag()?c.isTag("br")&&(text+="\n"):text+=(" "!==c.c(),c.c());return this.constructor.decode(text)},String.prototype.toLowerCase=function(){var c,newString,_i,_len,_ref;for(newString=this.copy(),_ref=newString.characters,_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],1===c._c.length&&(c._c=c._c.toLowerCase());return newString},String.prototype.toUpperCase=function(){var c,newString,_i,_len,_ref;for(newString=this.copy(),_ref=newString.characters,_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],1===c._c.length&&(c._c=c._c.toUpperCase());return newString},String.prototype.trim=function(){var c,from,newString,to,_i,_j,_len,_len1,_ref,_ref1;for(_ref=this.characters,from=_i=0,_len=_ref.length;_len>_i&&(c=_ref[from],c.isWhitespace());from=++_i);for(_ref1=this.characters.slice().reverse(),to=_j=0,_len1=_ref1.length;_len1>_j&&(c=_ref1[to],c.isWhitespace());to=++_j);return to=this.length()-to-1,newString=new HTMLString.String("",this._preserveWhitespace),newString.characters=function(){var _k,_len2,_ref2,_results;for(_ref2=this.characters.slice(from,+to+1||9e9),_results=[],_k=0,_len2=_ref2.length;_len2>_k;_k++)c=_ref2[_k],_results.push(c.copy());return _results}.call(this),newString},String.prototype.trimLeft=function(){var c,from,newString,to,_i,_len,_ref;for(to=this.length()-1,_ref=this.characters,from=_i=0,_len=_ref.length;_len>_i&&(c=_ref[from],c.isWhitespace());from=++_i);return newString=new HTMLString.String("",this._preserveWhitespace),newString.characters=function(){var _j,_len1,_ref1,_results;for(_ref1=this.characters.slice(from,+to+1||9e9),_results=[],_j=0,_len1=_ref1.length;_len1>_j;_j++)c=_ref1[_j],_results.push(c.copy());return _results}.call(this),newString},String.prototype.trimRight=function(){var c,from,newString,to,_i,_len,_ref;for(from=0,_ref=this.characters.slice().reverse(),to=_i=0,_len=_ref.length;_len>_i&&(c=_ref[to],c.isWhitespace());to=++_i);return to=this.length()-to-1,newString=new HTMLString.String("",this._preserveWhitespace),newString.characters=function(){var _j,_len1,_ref1,_results;for(_ref1=this.characters.slice(from,+to+1||9e9),_results=[],_j=0,_len1=_ref1.length;_len1>_j;_j++)c=_ref1[_j],_results.push(c.copy());return _results}.call(this),newString},String.prototype.unformat=function(){var c,from,i,newString,tags,to,_i;for(from=arguments[0],to=arguments[1],tags=3<=arguments.length?__slice.call(arguments,2):[],0>to&&(to=this.length()+to+1),0>from&&(from=this.length()+from),newString=this.copy(),i=_i=from;to>=from?to>_i:_i>to;i=to>=from?++_i:--_i)c=newString.characters[i],c.removeTags.apply(c,tags);return newString},String.prototype.copy=function(){var c,stringCopy;return stringCopy=new HTMLString.String("",this._preserveWhitespace),stringCopy.characters=function(){var _i,_len,_ref,_results;for(_ref=this.characters,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c.copy());return _results}.call(this),stringCopy},String.encode=function(string){var textarea;return textarea=document.createElement("textarea"),textarea.textContent=string,textarea.innerHTML},String.decode=function(string){var textarea;return textarea=document.createElement("textarea"),textarea.innerHTML=string,textarea.textContent},String}(),ALPHA_CHARS="AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-_$".split(""),ALPHA_NUMERIC_CHARS=ALPHA_CHARS.concat("1234567890".split("")),ENTITY_CHARS=ALPHA_NUMERIC_CHARS.concat(["#"]),CHAR_OR_ENTITY_OR_TAG=1,ENTITY=2,OPENNING_OR_CLOSING_TAG=3,OPENING_TAG=4,CLOSING_TAG=5,TAG_NAME_OPENING=6,TAG_NAME_CLOSING=7,TAG_OPENING_SELF_CLOSING=8,TAG_NAME_MUST_CLOSE=9,ATTR_OR_TAG_END=10,ATTR_NAME=11,ATTR_NAME_FIND_VALUE=12,ATTR_DELIM=13,ATTR_VALUE_SINGLE_DELIM=14,ATTR_VALUE_DOUBLE_DELIM=15,ATTR_VALUE_NO_DELIM=16,ATTR_ENTITY_NO_DELIM=17,ATTR_ENTITY_SINGLE_DELIM=18,ATTR_ENTITY_DOUBLE_DELIM=19,_Parser=function(){function _Parser(){this.fsm=new FSM.Machine(this),this.fsm.setInitialState(CHAR_OR_ENTITY_OR_TAG),this.fsm.addTransitionAny(CHAR_OR_ENTITY_OR_TAG,null,function(c){return this._pushChar(c)}),this.fsm.addTransition("<",CHAR_OR_ENTITY_OR_TAG,OPENNING_OR_CLOSING_TAG),this.fsm.addTransition("&",CHAR_OR_ENTITY_OR_TAG,ENTITY),this.fsm.addTransitions(ENTITY_CHARS,ENTITY,null,function(c){return this.entity+=c}),this.fsm.addTransition(";",ENTITY,CHAR_OR_ENTITY_OR_TAG,function(){return this._pushChar("&"+this.entity+";"),this.entity=""}),this.fsm.addTransitions([" ","\n"],OPENNING_OR_CLOSING_TAG),this.fsm.addTransitions(ALPHA_CHARS,OPENNING_OR_CLOSING_TAG,OPENING_TAG,function(){return this._back()}),this.fsm.addTransition("/",OPENNING_OR_CLOSING_TAG,CLOSING_TAG),this.fsm.addTransitions([" ","\n"],OPENING_TAG),this.fsm.addTransitions(ALPHA_CHARS,OPENING_TAG,TAG_NAME_OPENING,function(){return this._back()}),this.fsm.addTransitions([" ","\n"],CLOSING_TAG),this.fsm.addTransitions(ALPHA_CHARS,CLOSING_TAG,TAG_NAME_CLOSING,function(){return this._back()}),this.fsm.addTransitions(ALPHA_NUMERIC_CHARS,TAG_NAME_OPENING,null,function(c){return this.tagName+=c}),this.fsm.addTransitions([" ","\n"],TAG_NAME_OPENING,ATTR_OR_TAG_END),this.fsm.addTransition("/",TAG_NAME_OPENING,TAG_OPENING_SELF_CLOSING,function(){return this.selfClosing=!0}),this.fsm.addTransition(">",TAG_NAME_OPENING,CHAR_OR_ENTITY_OR_TAG,function(){return this._pushTag()}),this.fsm.addTransitions([" ","\n"],TAG_OPENING_SELF_CLOSING),this.fsm.addTransition(">",TAG_OPENING_SELF_CLOSING,CHAR_OR_ENTITY_OR_TAG,function(){return this._pushTag()}),this.fsm.addTransitions([" ","\n"],ATTR_OR_TAG_END),this.fsm.addTransition("/",ATTR_OR_TAG_END,TAG_OPENING_SELF_CLOSING,function(){return this.selfClosing=!0}),this.fsm.addTransition(">",ATTR_OR_TAG_END,CHAR_OR_ENTITY_OR_TAG,function(){return this._pushTag()}),this.fsm.addTransitions(ALPHA_CHARS,ATTR_OR_TAG_END,ATTR_NAME,function(){return this._back()}),this.fsm.addTransitions(ALPHA_NUMERIC_CHARS,TAG_NAME_CLOSING,null,function(c){return this.tagName+=c}),this.fsm.addTransitions([" ","\n"],TAG_NAME_CLOSING,TAG_NAME_MUST_CLOSE),this.fsm.addTransition(">",TAG_NAME_CLOSING,CHAR_OR_ENTITY_OR_TAG,function(){return this._popTag()}),this.fsm.addTransitions([" ","\n"],TAG_NAME_MUST_CLOSE),this.fsm.addTransition(">",TAG_NAME_MUST_CLOSE,CHAR_OR_ENTITY_OR_TAG,function(){return this._popTag()}),this.fsm.addTransitions(ALPHA_NUMERIC_CHARS,ATTR_NAME,null,function(c){return this.attributeName+=c}),this.fsm.addTransitions([" ","\n"],ATTR_NAME,ATTR_NAME_FIND_VALUE),this.fsm.addTransition("=",ATTR_NAME,ATTR_DELIM),this.fsm.addTransitions([" ","\n"],ATTR_NAME_FIND_VALUE),this.fsm.addTransition("=",ATTR_NAME_FIND_VALUE,ATTR_DELIM),this.fsm.addTransitions(">",ATTR_NAME,ATTR_OR_TAG_END,function(){return this._pushAttribute(),this._back()}),this.fsm.addTransitionAny(ATTR_NAME_FIND_VALUE,ATTR_OR_TAG_END,function(){return this._pushAttribute(),this._back()}),this.fsm.addTransitions([" ","\n"],ATTR_DELIM),this.fsm.addTransition("'",ATTR_DELIM,ATTR_VALUE_SINGLE_DELIM),this.fsm.addTransition('"',ATTR_DELIM,ATTR_VALUE_DOUBLE_DELIM),this.fsm.addTransitions(ALPHA_NUMERIC_CHARS.concat(["&"],ATTR_DELIM,ATTR_VALUE_NO_DELIM,function(){return this._back()})),this.fsm.addTransition(" ",ATTR_VALUE_NO_DELIM,ATTR_OR_TAG_END,function(){return this._pushAttribute()}),this.fsm.addTransitions(["/",">"],ATTR_VALUE_NO_DELIM,ATTR_OR_TAG_END,function(){return this._back(),this._pushAttribute()}),this.fsm.addTransition("&",ATTR_VALUE_NO_DELIM,ATTR_ENTITY_NO_DELIM),this.fsm.addTransitionAny(ATTR_VALUE_NO_DELIM,null,function(c){return this.attributeValue+=c}),this.fsm.addTransition("'",ATTR_VALUE_SINGLE_DELIM,ATTR_OR_TAG_END,function(){return this._pushAttribute()}),this.fsm.addTransition("&",ATTR_VALUE_SINGLE_DELIM,ATTR_ENTITY_SINGLE_DELIM),this.fsm.addTransitionAny(ATTR_VALUE_SINGLE_DELIM,null,function(c){return this.attributeValue+=c}),this.fsm.addTransition('"',ATTR_VALUE_DOUBLE_DELIM,ATTR_OR_TAG_END,function(){return this._pushAttribute()}),this.fsm.addTransition("&",ATTR_VALUE_DOUBLE_DELIM,ATTR_ENTITY_DOUBLE_DELIM),this.fsm.addTransitionAny(ATTR_VALUE_DOUBLE_DELIM,null,function(c){return this.attributeValue+=c}),this.fsm.addTransitions(ENTITY_CHARS,ATTR_ENTITY_NO_DELIM,null,function(c){return this.entity+=c}),this.fsm.addTransitions(ENTITY_CHARS,ATTR_ENTITY_SINGLE_DELIM,function(c){return this.entity+=c}),this.fsm.addTransitions(ENTITY_CHARS,ATTR_ENTITY_DOUBLE_DELIM,null,function(c){return this.entity+=c}),this.fsm.addTransition(";",ATTR_ENTITY_NO_DELIM,ATTR_VALUE_NO_DELIM,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""}),this.fsm.addTransition(";",ATTR_ENTITY_SINGLE_DELIM,ATTR_VALUE_SINGLE_DELIM,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""}),this.fsm.addTransition(";",ATTR_ENTITY_DOUBLE_DELIM,ATTR_VALUE_DOUBLE_DELIM,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""})}return _Parser.prototype._back=function(){return this.head--},_Parser.prototype._pushAttribute=function(){return this.attributes[this.attributeName]=this.attributeValue,this.attributeName="",this.attributeValue=""},_Parser.prototype._pushChar=function(c){var character,lastCharacter;return character=new HTMLString.Character(c,this.tags),this._preserveWhitespace?void this.string.characters.push(character):!this.string.length()||character.isTag()||character.isEntity()||!character.isWhitespace()||(lastCharacter=this.string.characters[this.string.length()-1],!lastCharacter.isWhitespace()||lastCharacter.isTag()||lastCharacter.isEntity())?this.string.characters.push(character):void 0},_Parser.prototype._pushTag=function(){var tag,_ref;return tag=new HTMLString.Tag(this.tagName,this.attributes),this.tags.push(tag),tag.selfClosing()&&(this._pushChar(""),this.tags.pop(),!this.selfClosed&&(_ref=this.tagName,__indexOf.call(HTMLString.Tag.SELF_CLOSING,_ref)>=0)&&this.fsm.reset()),this.tagName="",this.selfClosed=!1,this.attributes=[]},_Parser.prototype._popTag=function(){for(var character,tag;;)if(tag=this.tags.pop(),this.string.length()&&(character=this.string.characters[this.string.length()-1],!character.isTag()&&character.isWhitespace()&&character.removeTags(tag)),tag.name()===this.tagName.toLowerCase())break;return this.tagName=""},_Parser.prototype.parse=function(html,preserveWhitespace){var character,error;for(this._preserveWhitespace=preserveWhitespace,this.reset(),html=this.preprocess(html),this.fsm.parser=this;this.head> "+error)}this.head++}return this.string},_Parser.prototype.preprocess=function(html){return html=html.replace(/\r\n/g,"\n").replace(/\r/g,"\n"),html=html.replace(//g,""),this._preserveWhitespace||(html=html.replace(/\s+/g," ")),html},_Parser.prototype.reset=function(){return this.fsm.reset(),this.head=0,this.string=new HTMLString.String,this.entity="",this.tags=[],this.tagName="",this.selfClosing=!1,this.attributes={},this.attributeName="",this.attributeValue=""},_Parser}(),HTMLString.Tag=function(){function Tag(name,attributes){var k,v;this._name=name.toLowerCase(),this._selfClosing=HTMLString.Tag.SELF_CLOSING[this._name]===!0,this._head=null,this._attributes={};for(k in attributes)v=attributes[k],this._attributes[k]=v}return Tag.SELF_CLOSING={area:!0,base:!0,br:!0,hr:!0,img:!0,input:!0,"link meta":!0,wbr:!0},Tag.prototype.head=function(){var components,k,v,_ref;if(!this._head){components=[],_ref=this._attributes;for(k in _ref)v=_ref[k],components.push(v?""+k+'="'+v+'"':""+k);components.sort(),components.unshift(this._name),this._head="<"+components.join(" ")+">"}return this._head},Tag.prototype.name=function(){return this._name},Tag.prototype.selfClosing=function(){return this._selfClosing},Tag.prototype.tail=function(){return this._selfClosing?"":""+this._name+">"},Tag.prototype.attr=function(name,value){return void 0===value?this._attributes[name]:(this._attributes[name]=value,this._head=null)},Tag.prototype.removeAttr=function(name){return void 0!==this._attributes[name]?delete this._attributes[name]:void 0},Tag.prototype.copy=function(){return new HTMLString.Tag(this._name,this._attributes)},Tag}(),HTMLString.Character=function(){function Character(c,tags){this._c=c,c.length>1&&(this._c=c.toLowerCase()),this._tags=[],this.addTags.apply(this,tags)}return Character.prototype.c=function(){return this._c},Character.prototype.isEntity=function(){return this._c.length>1},Character.prototype.isTag=function(tagName){return 0!==this._tags.length&&this._tags[0].selfClosing()?tagName&&this._tags[0].name()!==tagName?!1:!0:!1},Character.prototype.isWhitespace=function(){var _ref;return" "===(_ref=this._c)||"\n"===_ref||" "===_ref||this.isTag("br")},Character.prototype.tags=function(){var t;return function(){var _i,_len,_ref,_results;for(_ref=this._tags,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)t=_ref[_i],_results.push(t.copy());return _results}.call(this)},Character.prototype.addTags=function(){var tag,tags,_i,_len,_results;for(tags=1<=arguments.length?__slice.call(arguments,0):[],_results=[],_i=0,_len=tags.length;_len>_i;_i++)tag=tags[_i],tag.selfClosing()?this.isTag()||this._tags.unshift(tag.copy()):_results.push(this._tags.push(tag.copy()));return _results},Character.prototype.eq=function(c){var tag,tags,_i,_j,_len,_len1,_ref,_ref1;if(this.c()!==c.c())return!1;if(this._tags.length!==c._tags.length)return!1;for(tags={},_ref=this._tags,_i=0,_len=_ref.length;_len>_i;_i++)tag=_ref[_i],tags[tag.head()]=!0;for(_ref1=c._tags,_j=0,_len1=_ref1.length;_len1>_j;_j++)if(tag=_ref1[_j],!tags[tag.head()])return!1;return!0},Character.prototype.hasTags=function(){var tag,tagHeads,tagNames,tags,_i,_j,_len,_len1,_ref;for(tags=1<=arguments.length?__slice.call(arguments,0):[],tagNames={},tagHeads={},_ref=this._tags,_i=0,_len=_ref.length;_len>_i;_i++)tag=_ref[_i],tagNames[tag.name()]=!0,tagHeads[tag.head()]=!0;for(_j=0,_len1=tags.length;_len1>_j;_j++)if(tag=tags[_j],"string"==typeof tag){if(void 0===tagNames[tag])return!1}else if(void 0===tagHeads[tag.head()])return!1;return!0},Character.prototype.removeTags=function(){var heads,names,newTags,tag,tags,_i,_len;if(tags=1<=arguments.length?__slice.call(arguments,0):[],0===tags.length)return void(this._tags=[]);for(names={},heads={},_i=0,_len=tags.length;_len>_i;_i++)tag=tags[_i],"string"==typeof tag?names[tag]=tag:heads[tag.head()]=tag;return newTags=[],this._tags=this._tags.filter(function(tag){return heads[tag.head()]||names[tag.name()]?void 0:tag})},Character.prototype.copy=function(){var t;return new HTMLString.Character(this._c,function(){var _i,_len,_ref,_results;for(_ref=this._tags,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)t=_ref[_i],_results.push(t.copy());return _results}.call(this))},Character}()}.call(this),function(){var SELF_CLOSING_NODE_NAMES,_containedBy,_getChildNodeAndOffset,_getNodeRange,_getOffsetOfChildNode,__indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};window.ContentSelect={},ContentSelect.Range=function(){function Range(from,to){this.set(from,to)}return Range.prototype.isCollapsed=function(){return this._from===this._to},Range.prototype.span=function(){return this._to-this._from},Range.prototype.collapse=function(){return this._to=this._from},Range.prototype.eq=function(range){return this.get()[0]===range.get()[0]&&this.get()[1]===range.get()[1]},Range.prototype.get=function(){return[this._from,this._to]},Range.prototype.select=function(element){var docRange,endNode,endOffset,startNode,startOffset,_ref,_ref1;return ContentSelect.Range.unselectAll(),docRange=document.createRange(),_ref=_getChildNodeAndOffset(element,this._from),startNode=_ref[0],startOffset=_ref[1],_ref1=_getChildNodeAndOffset(element,this._to),endNode=_ref1[0],endOffset=_ref1[1],docRange.setStart(startNode,startOffset),docRange.setEnd(endNode,endOffset),window.getSelection().addRange(docRange)},Range.prototype.set=function(from,to){return from=Math.max(0,from),to=Math.max(0,to),this._from=Math.min(from,to),this._to=Math.max(from,to)},Range.prepareElement=function(element){var i,node,selfClosingNodes,_i,_len,_results;for(selfClosingNodes=element.querySelectorAll(SELF_CLOSING_NODE_NAMES.join(", ")),_results=[],i=_i=0,_len=selfClosingNodes.length;_len>_i;i=++_i)node=selfClosingNodes[i],node.parentNode.insertBefore(document.createTextNode(""),node),_results.push(i_i;_i++)n=_ref[_i],_results.push(n);return _results}();childStack.length>0;)switch(childNode=childStack.shift(),childNode.nodeType){case Node.TEXT_NODE:if(childNode.textContent.length>=childOffset)return[childNode,childOffset];childOffset-=childNode.textContent.length;break;case Node.ELEMENT_NODE:if(_ref=childNode.nodeName.toLowerCase(),__indexOf.call(SELF_CLOSING_NODE_NAMES,_ref)>=0){if(0===childOffset)return[childNode,0];childOffset=Math.max(0,childOffset-1)}else childNode.childNodes&&Array.prototype.unshift.apply(childStack,function(){var _i,_len,_ref1,_results;for(_ref1=childNode.childNodes,_results=[],_i=0,_len=_ref1.length;_len>_i;_i++)n=_ref1[_i],_results.push(n);return _results}())}return[childNode,childOffset]},_getOffsetOfChildNode=function(parentNode,childNode){var childStack,n,offset,otherChildNode,_ref,_ref1;if(0===parentNode.childNodes.length)return 0;for(offset=0,childStack=function(){var _i,_len,_ref,_results;for(_ref=parentNode.childNodes,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)n=_ref[_i],_results.push(n);return _results}();childStack.length>0;){if(otherChildNode=childStack.shift(),otherChildNode===childNode)return _ref=otherChildNode.nodeName.toLowerCase(),__indexOf.call(SELF_CLOSING_NODE_NAMES,_ref)>=0?offset+1:offset;
3 | switch(otherChildNode.nodeType){case Node.TEXT_NODE:offset+=otherChildNode.textContent.length;break;case Node.ELEMENT_NODE:_ref1=otherChildNode.nodeName.toLowerCase(),__indexOf.call(SELF_CLOSING_NODE_NAMES,_ref1)>=0?offset+=1:otherChildNode.childNodes&&Array.prototype.unshift.apply(childStack,function(){var _i,_len,_ref2,_results;for(_ref2=otherChildNode.childNodes,_results=[],_i=0,_len=_ref2.length;_len>_i;_i++)n=_ref2[_i],_results.push(n);return _results}())}}return offset},_getNodeRange=function(element,docRange){var childNode,childNodes,endNode,endOffset,endRange,i,startNode,startOffset,startRange,_i,_j,_len,_len1,_ref;if(childNodes=element.childNodes,startRange=docRange.cloneRange(),startRange.collapse(!0),endRange=docRange.cloneRange(),endRange.collapse(!1),startNode=startRange.startContainer,startOffset=startRange.startOffset,endNode=endRange.endContainer,endOffset=endRange.endOffset,!startRange.comparePoint)return[startNode,startOffset,endNode,endOffset];if(startNode===element)for(startNode=childNodes[childNodes.length-1],startOffset=startNode.textContent.length,i=_i=0,_len=childNodes.length;_len>_i;i=++_i)if(childNode=childNodes[i],1===startRange.comparePoint(childNode,0)){0===i?(startNode=childNode,startOffset=0):(startNode=childNodes[i-1],startOffset=childNode.textContent.length),_ref=startNode.nodeName.toLowerCase,__indexOf.call(SELF_CLOSING_NODE_NAMES,_ref)>=0&&(startOffset=1);break}if(docRange.collapsed)return[startNode,startOffset,startNode,startOffset];if(endNode===element)for(endNode=childNodes[childNodes.length-1],endOffset=endNode.textContent.length,i=_j=0,_len1=childNodes.length;_len1>_j;i=++_j)childNode=childNodes[i],1===endRange.comparePoint(childNode,0)&&(endNode=0===i?childNode:childNodes[i-1],endOffset=childNode.textContent.length+1);return[startNode,startOffset,endNode,endOffset]}}.call(this),function(){var C,_Root,_TagNames,_mergers,__slice=[].slice,__indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1},__hasProp={}.hasOwnProperty,__extends=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)__hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};window.ContentEdit={DEFAULT_MAX_ELEMENT_WIDTH:800,DEFAULT_MIN_ELEMENT_WIDTH:80,DRAG_HOLD_DURATION:500,DROP_EDGE_SIZE:50,HELPER_CHAR_LIMIT:250,INDENT:" ",LANGUAGE:"en",RESIZE_CORNER_SIZE:15,_translations:{},_:function(s){var lang;return lang=ContentEdit.LANGUAGE,ContentEdit._translations[lang]&&ContentEdit._translations[lang][s]?ContentEdit._translations[lang][s]:s},addTranslations:function(language,translations){return ContentEdit._translations[language]=translations},addCSSClass:function(domElement,className){var c,classAttr,classNames;return domElement.classList?void domElement.classList.add(className):(classAttr=domElement.getAttribute("class"),classAttr?(classNames=function(){var _i,_len,_ref,_results;for(_ref=classAttr.split(" "),_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}(),-1===classNames.indexOf(className)?domElement.setAttribute("class",""+classAttr+" "+className):void 0):domElement.setAttribute("class",className))},attributesToString:function(attributes){var attributeStrings,name,names,value,_i,_len;if(!attributes)return"";for(names=function(){var _results;_results=[];for(name in attributes)_results.push(name);return _results}(),names.sort(),attributeStrings=[],_i=0,_len=names.length;_len>_i;_i++)name=names[_i],value=attributes[name],attributeStrings.push(""===value?name:""+name+'="'+value+'"');return attributeStrings.join(" ")},removeCSSClass:function(domElement,className){var c,classAttr,classNameIndex,classNames;return domElement.classList?(domElement.classList.remove(className),void(0===domElement.classList.length&&domElement.removeAttribute("class"))):(classAttr=domElement.getAttribute("class"),classAttr?(classNames=function(){var _i,_len,_ref,_results;for(_ref=classAttr.split(" "),_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}(),classNameIndex=classNames.indexOf(className),classNameIndex>-1?(classNames.splice(classNameIndex,1),classNames.length?domElement.setAttribute("class",classNames.join(" ")):domElement.removeAttribute("class")):void 0):domElement.setAttribute("class",className))}},(C=function(){function C(){}return C}()).name||Object.defineProperty(Function.prototype,"name",{get:function(){var name;return name=this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1],Object.defineProperty(this,"name",{value:name}),name}}),_TagNames=function(){function _TagNames(){this._tagNames={}}return _TagNames.prototype.register=function(){var cls,tagName,tagNames,_i,_len,_results;for(cls=arguments[0],tagNames=2<=arguments.length?__slice.call(arguments,1):[],_results=[],_i=0,_len=tagNames.length;_len>_i;_i++)tagName=tagNames[_i],_results.push(this._tagNames[tagName.toLowerCase()]=cls);return _results},_TagNames.prototype.match=function(tagName){return this._tagNames[tagName.toLowerCase()]?this._tagNames[tagName.toLowerCase()]:ContentEdit.Static},_TagNames}(),ContentEdit.TagNames=function(){function TagNames(){}var instance;return instance=null,TagNames.get=function(){return null!=instance?instance:instance=new _TagNames},TagNames}(),ContentEdit.Node=function(){function Node(){this._bindings={},this._parent=null,this._modified=null}return Node.prototype.lastModified=function(){return this._modified},Node.prototype.parent=function(){return this._parent},Node.prototype.parents=function(){var parent,parents;for(parents=[],parent=this._parent;parent;)parents.push(parent),parent=parent._parent;return parents},Node.prototype.html=function(indent){throw null==indent&&(indent=""),new Error("`html` not implemented")},Node.prototype.bind=function(eventName,callback){return void 0===this._bindings[eventName]&&(this._bindings[eventName]=[]),this._bindings[eventName].push(callback),callback},Node.prototype.trigger=function(){var args,callback,eventName,_i,_len,_ref,_results;if(eventName=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[],this._bindings[eventName]){for(_ref=this._bindings[eventName],_results=[],_i=0,_len=_ref.length;_len>_i;_i++)callback=_ref[_i],callback&&_results.push(callback.call.apply(callback,[this].concat(__slice.call(args))));return _results}},Node.prototype.unbind=function(eventName,callback){var i,suspect,_i,_len,_ref,_results;if(!eventName)return void(this._bindings={});if(!callback)return void(this._bindings[eventName]=void 0);if(this._bindings[eventName]){for(_ref=this._bindings[eventName],_results=[],i=_i=0,_len=_ref.length;_len>_i;i=++_i)suspect=_ref[i],_results.push(suspect===callback?this._bindings[eventName].splice(i,1):void 0);return _results}},Node.prototype.commit=function(){return this._modified=null,ContentEdit.Root.get().trigger("commit",this)},Node.prototype.taint=function(){var now,parent,root,_i,_len,_ref;for(now=Date.now(),this._modified=now,_ref=this.parents(),_i=0,_len=_ref.length;_len>_i;_i++)parent=_ref[_i],parent._modified=now;return root=ContentEdit.Root.get(),root._modified=now,root.trigger("taint",this)},Node.prototype.closest=function(testFunc){var parent;for(parent=this.parent();parent&&!testFunc(parent);)parent=parent.parent?parent.parent():null;return parent},Node.prototype.next=function(){var children,index,node,_i,_len,_ref;if(this.children&&this.children.length>0)return this.children[0];for(_ref=[this].concat(this.parents()),_i=0,_len=_ref.length;_len>_i;_i++){if(node=_ref[_i],!node.parent())return null;if(children=node.parent().children,index=children.indexOf(node),index=0||(this.prototype[key]=value);return this},Node.fromDOMElement=function(){throw new Error("`fromDOMElement` not implemented")},Node}(),ContentEdit.NodeCollection=function(_super){function NodeCollection(){NodeCollection.__super__.constructor.call(this),this.children=[]}return __extends(NodeCollection,_super),NodeCollection.prototype.descendants=function(){var descendants,node,nodeStack;for(descendants=[],nodeStack=this.children.slice();nodeStack.length>0;)node=nodeStack.shift(),descendants.push(node),node.children&&node.children.length>0&&(nodeStack=node.children.slice().concat(nodeStack));return descendants},NodeCollection.prototype.isMounted=function(){return!1},NodeCollection.prototype.attach=function(node,index){return node.parent()&&node.parent().detach(node),node._parent=this,void 0!==index?this.children.splice(index,0,node):this.children.push(node),node.mount&&this.isMounted()&&node.mount(),this.taint(),ContentEdit.Root.get().trigger("attach",this,node)},NodeCollection.prototype.commit=function(){var descendant,_i,_len,_ref;for(_ref=this.descendants(),_i=0,_len=_ref.length;_len>_i;_i++)descendant=_ref[_i],descendant._modified=null;return this._modified=null,ContentEdit.Root.get().trigger("commit",this)},NodeCollection.prototype.detach=function(node){var nodeIndex;return nodeIndex=this.children.indexOf(node),-1!==nodeIndex?(node.unmount&&this.isMounted()&&node.isMounted()&&node.unmount(),this.children.splice(nodeIndex,1),node._parent=null,this.taint(),ContentEdit.Root.get().trigger("detach",this,node)):void 0},NodeCollection}(ContentEdit.Node),ContentEdit.Element=function(_super){function Element(tagName,attributes){Element.__super__.constructor.call(this),this._tagName=tagName.toLowerCase(),this._attributes=attributes?attributes:{},this._domElement=null}return __extends(Element,_super),Element.prototype.attributes=function(){var attributes,name,value,_ref;attributes={},_ref=this._attributes;for(name in _ref)value=_ref[name],attributes[name]=value;return attributes},Element.prototype.cssTypeName=function(){return"element"},Element.prototype.domElement=function(){return this._domElement},Element.prototype.isFocused=function(){return ContentEdit.Root.get().focused()===this},Element.prototype.isMounted=function(){return null!==this._domElement},Element.prototype.typeName=function(){return"Element"},Element.prototype.addCSSClass=function(className){var modified;return modified=!1,this.hasCSSClass(className)||(modified=!0,this.attr("class")?this.attr("class",""+this.attr("class")+" "+className):this.attr("class",className)),this._addCSSClass(className),modified?this.taint():void 0},Element.prototype.attr=function(name,value){return name=name.toLowerCase(),void 0===value?this._attributes[name]:(this._attributes[name]=value,this.isMounted()&&"class"!==name.toLowerCase()&&this._domElement.setAttribute(name,value),this.taint())},Element.prototype.blur=function(){var root;return root=ContentEdit.Root.get(),this.isFocused()?(this._removeCSSClass("ce-element--focused"),root._focused=null,root.trigger("blur",this)):void 0},Element.prototype.createDraggingDOMElement=function(){var helper;if(this.isMounted())return helper=document.createElement("div"),helper.setAttribute("class","ce-drag-helper ce-drag-helper--type-"+this.cssTypeName()),console.log(this.typeName(),ContentEdit._(this.typeName())),helper.setAttribute("data-ce-type",ContentEdit._(this.typeName())),helper},Element.prototype.drag=function(x,y){return this.isMounted()?ContentEdit.Root.get().startDragging(this,x,y):void 0},Element.prototype.drop=function(element,placement){if(element){if(element._removeCSSClass("ce-element--drop"),element._removeCSSClass("ce-element--drop-"+placement[0]),element._removeCSSClass("ce-element--drop-"+placement[1]),this.constructor.droppers[element.constructor.name])return this.constructor.droppers[element.constructor.name](this,element,placement);if(element.constructor.droppers[this.constructor.name])return element.constructor.droppers[this.constructor.name](this,element,placement)}},Element.prototype.focus=function(supressDOMFocus){var root;return root=ContentEdit.Root.get(),this.isFocused()?void 0:(root.focused()&&root.focused().blur(),this._addCSSClass("ce-element--focused"),root._focused=this,this.isMounted()&&!supressDOMFocus&&this.domElement().focus(),root.trigger("focus",this))},Element.prototype.hasCSSClass=function(className){var c,classNames;return this.attr("class")&&(classNames=function(){var _i,_len,_ref,_results;for(_ref=this.attr("class").split(" "),_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}.call(this),classNames.indexOf(className)>-1)?!0:!1},Element.prototype.merge=function(element){return this.constructor.mergers[element.constructor.name]?this.constructor.mergers[element.constructor.name](element,this):element.constructor.mergers[this.constructor.name]?element.constructor.mergers[this.constructor.name](element,this):void 0},Element.prototype.mount=function(){var sibling;return this._domElement||(this._domElement=document.createElement(this.tagName())),sibling=this.nextSibling(),sibling?this.parent().domElement().insertBefore(this._domElement,sibling.domElement()):this.parent().domElement().appendChild(this._domElement),this._addDOMEventListeners(),this._addCSSClass("ce-element"),this._addCSSClass("ce-element--type-"+this.cssTypeName()),this.isFocused()&&this._addCSSClass("ce-element--focused"),ContentEdit.Root.get().trigger("mount",this)},Element.prototype.removeAttr=function(name){return name=name.toLowerCase(),this._attributes[name]?(delete this._attributes[name],this.isMounted()&&"class"!==name.toLowerCase()&&this._domElement.removeAttribute(name),this.taint()):void 0},Element.prototype.removeCSSClass=function(className){var c,classNameIndex,classNames;if(this.hasCSSClass(className))return classNames=function(){var _i,_len,_ref,_results;for(_ref=this.attr("class").split(" "),_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}.call(this),classNameIndex=classNames.indexOf(className),classNameIndex>-1&&classNames.splice(classNameIndex,1),classNames.length?this.attr("class",classNames.join(" ")):this.removeAttr("class"),this._removeCSSClass(className),this.taint()},Element.prototype.tagName=function(name){return void 0===name?this._tagName:(this._tagName=name.toLowerCase(),this.isMounted()&&(this.unmount(),this.mount()),this.taint())},Element.prototype.unmount=function(){return this._removeDOMEventListeners(),this._domElement.parentNode&&this._domElement.parentNode.removeChild(this._domElement),this._domElement=null,ContentEdit.Root.get().trigger("unmount",this)},Element.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("focus",function(){return function(ev){return ev.preventDefault()}}(this)),this._domElement.addEventListener("dragstart",function(){return function(ev){return ev.preventDefault()}}(this)),this._domElement.addEventListener("keydown",function(_this){return function(ev){return _this._onKeyDown(ev)}}(this)),this._domElement.addEventListener("keyup",function(_this){return function(ev){return _this._onKeyUp(ev)}}(this)),this._domElement.addEventListener("mousedown",function(_this){return function(ev){return 0===ev.button?_this._onMouseDown(ev):void 0}}(this)),this._domElement.addEventListener("mousemove",function(_this){return function(ev){return _this._onMouseMove(ev)}}(this)),this._domElement.addEventListener("mouseover",function(_this){return function(ev){return _this._onMouseOver(ev)}}(this)),this._domElement.addEventListener("mouseout",function(_this){return function(ev){return _this._onMouseOut(ev)}}(this)),this._domElement.addEventListener("mouseup",function(_this){return function(ev){return 0===ev.button?_this._onMouseUp(ev):void 0}}(this)),this._domElement.addEventListener("paste",function(_this){return function(ev){return _this._onPaste(ev)}}(this))},Element.prototype._onKeyDown=function(){},Element.prototype._onKeyUp=function(){},Element.prototype._onMouseDown=function(){return this.focus?this.focus(!0):void 0},Element.prototype._onMouseMove=function(){},Element.prototype._onMouseOver=function(){var dragging,root;return this._addCSSClass("ce-element--over"),root=ContentEdit.Root.get(),dragging=root.dragging(),dragging&&dragging!==this&&!root._dropTarget&&(this.constructor.droppers[dragging.constructor.name]||dragging.constructor.droppers[this.constructor.name])?(this._addCSSClass("ce-element--drop"),root._dropTarget=this):void 0},Element.prototype._onMouseOut=function(){var dragging,root;return this._removeCSSClass("ce-element--over"),root=ContentEdit.Root.get(),dragging=root.dragging(),dragging?(this._removeCSSClass("ce-element--drop"),this._removeCSSClass("ce-element--drop-above"),this._removeCSSClass("ce-element--drop-below"),this._removeCSSClass("ce-element--drop-center"),this._removeCSSClass("ce-element--drop-left"),this._removeCSSClass("ce-element--drop-right"),root._dropTarget=null):void 0},Element.prototype._onMouseUp=function(){},Element.prototype._onPaste=function(ev){return ev.preventDefault(),ev.stopPropagation(),ContentEdit.Root.get().trigger("paste",this,ev)},Element.prototype._removeDOMEventListeners=function(){},Element.prototype._addCSSClass=function(className){return this.isMounted()?ContentEdit.addCSSClass(this._domElement,className):void 0},Element.prototype._attributesToString=function(){return Object.getOwnPropertyNames(this._attributes).length>0?" "+ContentEdit.attributesToString(this._attributes):""},Element.prototype._removeCSSClass=function(className){return this.isMounted()?ContentEdit.removeCSSClass(this._domElement,className):void 0},Element.droppers={},Element.mergers={},Element.placements=["above","below"],Element.getDOMElementAttributes=function(domElement){var attribute,attributes,_i,_len,_ref;if(!domElement.hasAttributes())return{};for(attributes={},_ref=domElement.attributes,_i=0,_len=_ref.length;_len>_i;_i++)attribute=_ref[_i],attributes[attribute.name.toLowerCase()]=attribute.value;return attributes},Element._dropVert=function(element,target,placement){var insertIndex;return element.parent().detach(element),insertIndex=target.parent().children.indexOf(target),"below"===placement[0]&&(insertIndex+=1),target.parent().attach(element,insertIndex)},Element._dropBoth=function(element,target,placement){var aClassNames,className,insertIndex,_i,_len,_ref;if(element.parent().detach(element),insertIndex=target.parent().children.indexOf(target),"below"===placement[0]&&"center"===placement[1]&&(insertIndex+=1),element.a){if(element._removeCSSClass("align-left"),element._removeCSSClass("align-right"),element.a["class"]){for(aClassNames=[],_ref=element.a["class"].split(" "),_i=0,_len=_ref.length;_len>_i;_i++)className=_ref[_i],"align-left"!==className&&"align-right"!==className&&aClassNames.push(className);aClassNames.length?element.a["class"]=aClassNames.join(" "):delete element.a["class"]}}else element.removeCSSClass("align-left"),element.removeCSSClass("align-right");return"left"===placement[1]&&(element.a?(element.a["class"]?element.a["class"]+=" align-left":element.a["class"]="align-left",element._addCSSClass("align-left")):element.addCSSClass("align-left")),"right"===placement[1]&&(element.a?(element.a["class"]?element.a["class"]+=" align-right":element.a["class"]="align-right",element._addCSSClass("align-right")):element.addCSSClass("align-right")),target.parent().attach(element,insertIndex)},Element}(ContentEdit.Node),ContentEdit.ElementCollection=function(_super){function ElementCollection(tagName,attributes){ElementCollection.__super__.constructor.call(this,tagName,attributes),ContentEdit.NodeCollection.prototype.constructor.call(this)}return __extends(ElementCollection,_super),ElementCollection.extend(ContentEdit.NodeCollection),ElementCollection.prototype.cssTypeName=function(){return"element-collection"},ElementCollection.prototype.isMounted=function(){return null!==this._domElement},ElementCollection.prototype.createDraggingDOMElement=function(){var helper,text;if(this.isMounted())return helper=ElementCollection.__super__.createDraggingDOMElement.call(this),text=this._domElement.textContent,text.length>ContentEdit.HELPER_CHAR_LIMIT&&(text=text.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),helper.innerHTML=text,helper},ElementCollection.prototype.detach=function(element){return ContentEdit.NodeCollection.prototype.detach.call(this,element),0===this.children.length&&this.parent()?this.parent().detach(this):void 0},ElementCollection.prototype.html=function(indent){var c,children;return null==indent&&(indent=""),children=function(){var _i,_len,_ref,_results;for(_ref=this.children,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c.html(indent+ContentEdit.INDENT));return _results}.call(this),""+indent+"<"+this.tagName()+this._attributesToString()+">\n"+(""+children.join("\n")+"\n")+(""+indent+""+this.tagName()+">")},ElementCollection.prototype.mount=function(){var child,name,value,_i,_len,_ref,_ref1,_results;this._domElement=document.createElement(this._tagName),_ref=this._attributes;for(name in _ref)value=_ref[name],this._domElement.setAttribute(name,value);for(ElementCollection.__super__.mount.call(this),_ref1=this.children,_results=[],_i=0,_len=_ref1.length;_len>_i;_i++)child=_ref1[_i],_results.push(child.mount());return _results},ElementCollection.prototype.unmount=function(){var child,_i,_len,_ref;for(_ref=this.children,_i=0,_len=_ref.length;_len>_i;_i++)child=_ref[_i],child.unmount();return ElementCollection.__super__.unmount.call(this)},ElementCollection.prototype.blur=void 0,ElementCollection.prototype.focus=void 0,ElementCollection}(ContentEdit.Element),ContentEdit.ResizableElement=function(_super){function ResizableElement(tagName,attributes){ResizableElement.__super__.constructor.call(this,tagName,attributes),this._domSizeInfoElement=null,this._aspectRatio=1}return __extends(ResizableElement,_super),ResizableElement.prototype.aspectRatio=function(){return this._aspectRatio},ResizableElement.prototype.maxSize=function(){var maxWidth;return maxWidth=parseInt(this.attr("data-ce-max-width")||0),maxWidth||(maxWidth=ContentEdit.DEFAULT_MAX_ELEMENT_WIDTH),maxWidth=Math.max(maxWidth,this.size()[0]),[maxWidth,maxWidth*this.aspectRatio()]},ResizableElement.prototype.minSize=function(){var minWidth;return minWidth=parseInt(this.attr("data-ce-min-width")||0),minWidth||(minWidth=ContentEdit.DEFAULT_MIN_ELEMENT_WIDTH),minWidth=Math.min(minWidth,this.size()[0]),[minWidth,minWidth*this.aspectRatio()]},ResizableElement.prototype.mount=function(){return ResizableElement.__super__.mount.call(this),this._domElement.setAttribute("data-ce-size",this._getSizeInfo())},ResizableElement.prototype.resize=function(corner,x,y){return this.isMounted()?ContentEdit.Root.get().startResizing(this,corner,x,y,!0):void 0},ResizableElement.prototype.size=function(newSize){var height,maxSize,minSize,width;return newSize?(newSize[0]=parseInt(newSize[0]),newSize[1]=parseInt(newSize[1]),minSize=this.minSize(),newSize[0]=Math.max(newSize[0],minSize[0]),newSize[1]=Math.max(newSize[1],minSize[1]),maxSize=this.maxSize(),newSize[0]=Math.min(newSize[0],maxSize[0]),newSize[1]=Math.min(newSize[1],maxSize[1]),this.attr("width",parseInt(newSize[0])),this.attr("height",parseInt(newSize[1])),this.isMounted()?(this._domElement.style.width=""+newSize[0]+"px",this._domElement.style.height=""+newSize[1]+"px",this._domElement.setAttribute("data-ce-size",this._getSizeInfo())):void 0):(width=parseInt(this.attr("width")||1),height=parseInt(this.attr("height")||1),[width,height])},ResizableElement.prototype._onMouseDown=function(ev){var corner;return ResizableElement.__super__._onMouseDown.call(this),corner=this._getResizeCorner(ev.clientX,ev.clientY),corner?this.resize(corner,ev.clientX,ev.clientY):(clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(_this){return function(){return _this.drag(ev.pageX,ev.pageY)}}(this),150))},ResizableElement.prototype._onMouseMove=function(ev){var corner;return ResizableElement.__super__._onMouseMove.call(this),this._removeCSSClass("ce-element--resize-top-left"),this._removeCSSClass("ce-element--resize-top-right"),this._removeCSSClass("ce-element--resize-bottom-left"),this._removeCSSClass("ce-element--resize-bottom-right"),corner=this._getResizeCorner(ev.clientX,ev.clientY),corner?this._addCSSClass("ce-element--resize-"+corner[0]+"-"+corner[1]):void 0},ResizableElement.prototype._onMouseOut=function(){return ResizableElement.__super__._onMouseOut.call(this),this._removeCSSClass("ce-element--resize-top-left"),this._removeCSSClass("ce-element--resize-top-right"),this._removeCSSClass("ce-element--resize-bottom-left"),this._removeCSSClass("ce-element--resize-bottom-right")},ResizableElement.prototype._onMouseUp=function(){return ResizableElement.__super__._onMouseUp.call(this),this._dragTimeout?clearTimeout(this._dragTimeout):void 0},ResizableElement.prototype._getResizeCorner=function(x,y){var corner,cornerSize,rect,size,_ref;return rect=this._domElement.getBoundingClientRect(),_ref=[x-rect.left,y-rect.top],x=_ref[0],y=_ref[1],size=this.size(),cornerSize=ContentEdit.RESIZE_CORNER_SIZE,cornerSize=Math.min(cornerSize,Math.max(parseInt(size[0]/4),1)),cornerSize=Math.min(cornerSize,Math.max(parseInt(size[1]/4),1)),corner=null,cornerSize>x?cornerSize>y?corner=["top","left"]:y>rect.height-cornerSize&&(corner=["bottom","left"]):x>rect.width-cornerSize&&(cornerSize>y?corner=["top","right"]:y>rect.height-cornerSize&&(corner=["bottom","right"])),corner},ResizableElement.prototype._getSizeInfo=function(){var size;return size=this.size(),"w "+size[0]+" × h "+size[1]},ResizableElement}(ContentEdit.Element),ContentEdit.Region=function(_super){function Region(domElement){var c,childNode,childNodes,cls,element,tagNames,_i,_len;for(Region.__super__.constructor.call(this),this._domElement=domElement,tagNames=ContentEdit.TagNames.get(),childNodes=function(){var _i,_len,_ref,_results;for(_ref=this._domElement.childNodes,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}.call(this),_i=0,_len=childNodes.length;_len>_i;_i++)childNode=childNodes[_i],1===childNode.nodeType&&(cls=tagNames.match(childNode.getAttribute("data-ce-tag")?childNode.getAttribute("data-ce-tag"):childNode.tagName),element=cls.fromDOMElement(childNode),this._domElement.removeChild(childNode),element&&this.attach(element))}return __extends(Region,_super),Region.prototype.domElement=function(){return this._domElement},Region.prototype.isMounted=function(){return!0},Region.prototype.html=function(indent){var c;return null==indent&&(indent=""),function(){var _i,_len,_ref,_results;for(_ref=this.children,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c.html(indent));return _results}.call(this).join("\n").trim()},Region}(ContentEdit.NodeCollection),_Root=function(_super){function _Root(){this._onStopResizing=__bind(this._onStopResizing,this),this._onResize=__bind(this._onResize,this),this._onStopDragging=__bind(this._onStopDragging,this),this._onDrag=__bind(this._onDrag,this),_Root.__super__.constructor.call(this),this._focused=null,this._dragging=null,this._dropTarget=null,this._draggingDOMElement=null,this._resizing=null,this._resizingInit=null}return __extends(_Root,_super),_Root.prototype.dragging=function(){return this._dragging},_Root.prototype.dropTarget=function(){return this._dropTarget},_Root.prototype.focused=function(){return this._focused},_Root.prototype.resizing=function(){return this._resizing},_Root.prototype.cancelDragging=function(){return this._dragging?(document.body.removeChild(this._draggingDOMElement),document.removeEventListener("mousemove",this._onDrag),document.removeEventListener("mouseup",this._onStopDragging),this._dragging._removeCSSClass("ce-element--dragging"),this._dragging=null,this._dropTarget=null,ContentEdit.removeCSSClass(document.body,"ce--dragging")):void 0},_Root.prototype.startDragging=function(element,x,y){return this._dragging?void 0:(this._dragging=element,this._dragging._addCSSClass("ce-element--dragging"),this._draggingDOMElement=this._dragging.createDraggingDOMElement(),document.body.appendChild(this._draggingDOMElement),this._draggingDOMElement.style.left=""+x+"px",this._draggingDOMElement.style.top=""+y+"px",document.addEventListener("mousemove",this._onDrag),document.addEventListener("mouseup",this._onStopDragging),ContentEdit.addCSSClass(document.body,"ce--dragging"))},_Root.prototype._getDropPlacement=function(x,y){var horz,rect,vert,_ref;return this._dropTarget?(rect=this._dropTarget.domElement().getBoundingClientRect(),_ref=[x-rect.left,y-rect.top],x=_ref[0],y=_ref[1],horz="center",xrect.width-ContentEdit.DROP_EDGE_SIZE&&(horz="right"),vert="above",y>rect.height/2&&(vert="below"),[vert,horz]):null},_Root.prototype._onDrag=function(ev){var placement,_ref,_ref1;return ContentSelect.Range.unselectAll(),this._draggingDOMElement.style.left=""+ev.pageX+"px",this._draggingDOMElement.style.top=""+ev.pageY+"px",this._dropTarget&&(placement=this._getDropPlacement(ev.clientX,ev.clientY),this._dropTarget._removeCSSClass("ce-element--drop-above"),this._dropTarget._removeCSSClass("ce-element--drop-below"),this._dropTarget._removeCSSClass("ce-element--drop-center"),this._dropTarget._removeCSSClass("ce-element--drop-left"),this._dropTarget._removeCSSClass("ce-element--drop-right"),_ref=placement[0],__indexOf.call(this._dragging.constructor.placements,_ref)>=0&&this._dropTarget._addCSSClass("ce-element--drop-"+placement[0]),_ref1=placement[1],__indexOf.call(this._dragging.constructor.placements,_ref1)>=0)?this._dropTarget._addCSSClass("ce-element--drop-"+placement[1]):void 0},_Root.prototype._onStopDragging=function(ev){var placement;return placement=this._getDropPlacement(ev.clientX,ev.clientY),this._dragging.drop(this._dropTarget,placement),this.cancelDragging()},_Root.prototype.startResizing=function(element,corner,x,y,fixed){var measureDom,parentDom;if(!this._resizing)return this._resizing=element,this._resizingInit={corner:corner,fixed:fixed,origin:[x,y],size:element.size()},this._resizing._addCSSClass("ce-element--resizing"),parentDom=this._resizing.parent().domElement(),measureDom=document.createElement("div"),measureDom.setAttribute("class","ce-measure"),parentDom.appendChild(measureDom),this._resizingParentWidth=measureDom.getBoundingClientRect().width,parentDom.removeChild(measureDom),document.addEventListener("mousemove",this._onResize),document.addEventListener("mouseup",this._onStopResizing),ContentEdit.addCSSClass(document.body,"ce--resizing")},_Root.prototype._onResize=function(ev){var height,width,x,y;return ContentSelect.Range.unselectAll(),x=this._resizingInit.origin[0]-ev.clientX,"right"===this._resizingInit.corner[1]&&(x=-x),width=this._resizingInit.size[0]+x,width=Math.min(width,this._resizingParentWidth),this._resizingInit.fixed?height=width*this._resizing.aspectRatio():(y=this._resizingInit.origin[1]-ev.clientY,"bottom"===this._resizingInit.corner[0]&&(y=-y),height=this._resizingInit.size[1]+y),this._resizing.size([width,height])
4 | },_Root.prototype._onStopResizing=function(){return document.removeEventListener("mousemove",this._onResize),document.removeEventListener("mouseup",this._onStopResizing),this._resizing._removeCSSClass("ce-element--resizing"),this._resizing=null,this._resizingInit=null,this._resizingParentWidth=null,ContentEdit.removeCSSClass(document.body,"ce--resizing")},_Root}(ContentEdit.Node),ContentEdit.Root=function(){function Root(){}var instance;return instance=null,Root.get=function(){return null!=instance?instance:instance=new _Root},Root}(),ContentEdit.Static=function(_super){function Static(tagName,attributes,content){Static.__super__.constructor.call(this,tagName,attributes),this._content=content}return __extends(Static,_super),Static.prototype.cssTypeName=function(){return"static"},Static.prototype.typeName=function(){return"Static"},Static.prototype.html=function(indent){return null==indent&&(indent=""),""+indent+"<"+this._tagName+this._attributesToString()+">"+this._content+(""+indent+""+this._tagName+">")},Static.prototype.mount=function(){var name,value,_ref;this._domElement=document.createElement(this._tagName),_ref=this._attributes;for(name in _ref)value=_ref[name],this._domElement.setAttribute(name,value);return this._domElement.innerHTML=this._content,Static.__super__.mount.call(this)},Static.prototype.blur=void 0,Static.prototype.focus=void 0,Static.prototype._onMouseOver=function(ev){return Static.__super__._onMouseOver.call(this,ev),this._removeCSSClass("ce-element--over")},Static.fromDOMElement=function(domElement){return new this(domElement.tagName,this.getDOMElementAttributes(domElement),domElement.innerHTML)},Static}(ContentEdit.Element),ContentEdit.TagNames.get().register(ContentEdit.Static,"static"),ContentEdit.Text=function(_super){function Text(tagName,attributes,content){Text.__super__.constructor.call(this,tagName,attributes),this.content=content instanceof HTMLString.String?content:new HTMLString.String(content).trim()}return __extends(Text,_super),Text.prototype.cssTypeName=function(){return"text"},Text.prototype.typeName=function(){return"Text"},Text.prototype.blur=function(){return this.content.isWhitespace()?this.parent()&&this.parent().detach(this):this.isMounted()&&(this._domElement.blur(),this._domElement.removeAttribute("contenteditable")),Text.__super__.blur.call(this)},Text.prototype.createDraggingDOMElement=function(){var helper,text;if(this.isMounted())return helper=Text.__super__.createDraggingDOMElement.call(this),text=this._domElement.textContent,text.length>ContentEdit.HELPER_CHAR_LIMIT&&(text=text.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),helper.innerHTML=text,helper},Text.prototype.drag=function(x,y){return this.storeState(),this._domElement.removeAttribute("contenteditable"),Text.__super__.drag.call(this,x,y)},Text.prototype.drop=function(element,placement){return Text.__super__.drop.call(this,element,placement),this.restoreState()},Text.prototype.focus=function(supressDOMFocus){return this.isMounted()&&this._domElement.setAttribute("contenteditable",""),Text.__super__.focus.call(this,supressDOMFocus)},Text.prototype.html=function(indent){var content;return null==indent&&(indent=""),(!this._lastCached||this._lastCached\n"+(""+indent+ContentEdit.INDENT+this._cached+"\n")+(""+indent+""+this._tagName+">")},Text.prototype.mount=function(){var name,value,_ref;this._domElement=document.createElement(this._tagName),_ref=this._attributes;for(name in _ref)value=_ref[name],this._domElement.setAttribute(name,value);return this.updateInnerHTML(),Text.__super__.mount.call(this)},Text.prototype.restoreState=function(){return this._savedSelection?this.isMounted()&&this.isFocused()?(this._domElement.setAttribute("contenteditable",""),this._addCSSClass("ce-element--focused"),this._savedSelection.select(this._domElement),this._savedSelection=void 0):void(this._savedSelection=void 0):void 0},Text.prototype.selection=function(selection){return void 0===selection?this.isMounted()?ContentSelect.Range.query(this._domElement):new ContentSelect.Range(0,0):selection.select(this._domElement)},Text.prototype.storeState=function(){return this.isMounted()&&this.isFocused()?this._savedSelection=ContentSelect.Range.query(this._domElement):void 0},Text.prototype.updateInnerHTML=function(){return this._domElement.innerHTML=this.content.html(),ContentSelect.Range.prepareElement(this._domElement),this._flagIfEmpty()},Text.prototype._onKeyDown=function(ev){switch(ev.keyCode){case 40:return this._keyDown(ev);case 37:return this._keyLeft(ev);case 39:return this._keyRight(ev);case 38:return this._keyUp(ev);case 9:return this._keyTab(ev);case 8:return this._keyBack(ev);case 46:return this._keyDelete(ev);case 13:return this._keyReturn(ev)}},Text.prototype._onKeyUp=function(){var newSnaphot,snapshot;return snapshot=this.content.html(),this.content=new HTMLString.String(this._domElement.innerHTML,this.content.preserveWhitespace()),newSnaphot=this.content.html(),snapshot!==newSnaphot&&this.taint(),this._flagIfEmpty()},Text.prototype._onMouseDown=function(ev){return Text.__super__._onMouseDown.call(this),clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(_this){return function(){return _this.drag(ev.pageX,ev.pageY)}}(this),ContentEdit.DRAG_HOLD_DURATION)},Text.prototype._onMouseMove=function(){return this._dragTimeout&&clearTimeout(this._dragTimeout),Text.__super__._onMouseMove.call(this)},Text.prototype._onMouseOut=function(){return this._dragTimeout&&clearTimeout(this._dragTimeout),Text.__super__._onMouseOut.call(this)},Text.prototype._onMouseUp=function(){return this._dragTimeout&&clearTimeout(this._dragTimeout),Text.__super__._onMouseUp.call(this)},Text.prototype._keyBack=function(ev){var previous,selection;return selection=ContentSelect.Range.query(this._domElement),0===selection.get()[0]&&selection.isCollapsed()?(ev.preventDefault(),previous=this.previousContent(),previous?previous.merge(this):void 0):void 0},Text.prototype._keyDelete=function(ev){var next,selection;return selection=ContentSelect.Range.query(this._domElement),this._atEnd(selection)&&selection.isCollapsed()?(ev.preventDefault(),next=this.nextContent(),next?this.merge(next):void 0):void 0},Text.prototype._keyDown=function(ev){return this._keyRight(ev)},Text.prototype._keyLeft=function(ev){var previous,selection;return selection=ContentSelect.Range.query(this._domElement),0===selection.get()[0]&&selection.isCollapsed()?(ev.preventDefault(),previous=this.previousContent(),previous?(previous.focus(),selection=new ContentSelect.Range(previous.content.length(),previous.content.length()),selection.select(previous.domElement())):ContentEdit.Root.get().trigger("previous-region",this.closest(function(node){return"Region"===node.constructor.name}))):void 0},Text.prototype._keyReturn=function(ev){var element,selection,tail,tip;return ev.preventDefault(),this.content.isWhitespace()?void 0:(ContentSelect.Range.query(this._domElement),selection=ContentSelect.Range.query(this._domElement),tip=this.content.substring(0,selection.get()[0]),tail=this.content.substring(selection.get()[1]),this.content=tip.trim(),this.updateInnerHTML(),element=new this.constructor("p",{},tail.trim()),this.parent().attach(element,this.parent().children.indexOf(this)+1),tip.length()?(element.focus(),selection=new ContentSelect.Range(0,0),selection.select(element.domElement())):(selection=new ContentSelect.Range(0,tip.length()),selection.select(this._domElement)),this.taint())},Text.prototype._keyRight=function(ev){var next,selection;return selection=ContentSelect.Range.query(this._domElement),this._atEnd(selection)&&selection.isCollapsed()?(ev.preventDefault(),next=this.nextContent(),next?(next.focus(),selection=new ContentSelect.Range(0,0),selection.select(next.domElement())):ContentEdit.Root.get().trigger("next-region",this.closest(function(node){return"Region"===node.constructor.name}))):void 0},Text.prototype._keyTab=function(ev){return ev.preventDefault()},Text.prototype._keyUp=function(ev){return this._keyLeft(ev)},Text.prototype._atEnd=function(selection){var atEnd;return atEnd=selection.get()[0]===this.content.length(),selection.get()[0]===this.content.length()-1&&this.content.characters[this.content.characters.length-1].isTag("br")&&(atEnd=!0),atEnd},Text.prototype._flagIfEmpty=function(){return 0===this.content.length()?this._addCSSClass("ce-element--empty"):this._removeCSSClass("ce-element--empty")},Text.droppers={Static:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert},Text.mergers={Text:function(element,target){var offset;return offset=target.content.length(),element.content.length()&&(target.content=target.content.concat(element.content)),target.isMounted()&&(target._domElement.innerHTML=target.content.html()),target.focus(),new ContentSelect.Range(offset,offset).select(target._domElement),element.parent()&&element.parent().detach(element),target.taint()}},Text.fromDOMElement=function(domElement){return new this(domElement.tagName,this.getDOMElementAttributes(domElement),domElement.innerHTML.replace(/^\s+|\s+$/g,""))},Text}(ContentEdit.Element),ContentEdit.TagNames.get().register(ContentEdit.Text,"address","blockquote","h1","h2","h3","h4","h5","h6","p"),ContentEdit.PreText=function(_super){function PreText(tagName,attributes,content){this.content=content instanceof HTMLString.String?content:new HTMLString.String(content,!0),ContentEdit.Element.call(this,tagName,attributes)}return __extends(PreText,_super),PreText.prototype.cssTypeName=function(){return"pre-text"},PreText.prototype.typeName=function(){return"Preformatted"},PreText.prototype.html=function(indent){var content;return null==indent&&(indent=""),(!this._lastCached||this._lastCached"+(""+this._cached+""+this._tagName+">")},PreText.prototype._keyReturn=function(ev){var cursor,selection,tail,tip;return ev.preventDefault(),selection=ContentSelect.Range.query(this._domElement),cursor=selection.get()[0]+1,0===selection.get()[0]&&selection.isCollapsed()?this.content=new HTMLString.String("\n",!0).concat(this.content):this._atEnd(selection)&&selection.isCollapsed()?this.content=this.content.concat(new HTMLString.String("\n",!0)):0===selection.get()[0]&&selection.get()[1]===this.content.length()?(this.content=new HTMLString.String("\n",!0),cursor=0):(tip=this.content.substring(0,selection.get()[0]),tail=this.content.substring(selection.get()[1]),this.content=tip.concat(new HTMLString.String("\n",!0),tail)),this.updateInnerHTML(),selection.set(cursor,cursor),selection.select(this._domElement),this.taint()},PreText.droppers={PreText:ContentEdit.Element._dropVert,Static:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert},PreText.mergers={},PreText.fromDOMElement=function(domElement){return new this(domElement.tagName,this.getDOMElementAttributes(domElement),domElement.innerHTML)},PreText}(ContentEdit.Text),ContentEdit.TagNames.get().register(ContentEdit.PreText,"pre"),ContentEdit.Image=function(_super){function Image(attributes,a){var size;Image.__super__.constructor.call(this,"img",attributes),this.a=a?a:null,size=this.size(),this._aspectRatio=size[1]/size[0]}return __extends(Image,_super),Image.prototype.cssTypeName=function(){return"image"},Image.prototype.typeName=function(){return"Image"},Image.prototype.createDraggingDOMElement=function(){var helper;if(this.isMounted())return helper=Image.__super__.createDraggingDOMElement.call(this),helper.style.backgroundImage="url("+this._attributes.src+")",helper},Image.prototype.html=function(indent){var attributes,img;return null==indent&&(indent=""),img=""+indent+"
",this.a?(attributes=ContentEdit.attributesToString(this.a),attributes=""+attributes+' data-ce-tag="img"',""+indent+"\n"+(""+ContentEdit.INDENT+img+"\n")+(""+indent+"")):img},Image.prototype.mount=function(){var style;return this._domElement=document.createElement("div"),this.a&&this.a["class"]?this._domElement.setAttribute("class",this.a["class"]):this._attributes["class"]&&this._domElement.setAttribute("class",this._attributes["class"]),style=this._attributes.style?this._attributes.style:"",style+="background-image:url("+this._attributes.src+");",this._attributes.width&&(style+="width:"+this._attributes.width+"px;"),this._attributes.height&&(style+="height:"+this._attributes.height+"px;"),this._domElement.setAttribute("style",style),Image.__super__.mount.call(this)},Image.droppers={Image:ContentEdit.Element._dropBoth,PreText:ContentEdit.Element._dropBoth,Static:ContentEdit.Element._dropBoth,Text:ContentEdit.Element._dropBoth},Image.placements=["above","below","left","right","center"],Image.fromDOMElement=function(domElement){var a,attributes,c,childNode,childNodes,_i,_len;if(a=null,"a"===domElement.tagName.toLowerCase()){for(a=this.getDOMElementAttributes(domElement),childNodes=function(){var _i,_len,_ref,_results;for(_ref=domElement.childNodes,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}(),_i=0,_len=childNodes.length;_len>_i;_i++)if(childNode=childNodes[_i],1===childNode.nodeType&&"img"===childNode.tagName.toLowerCase()){domElement=childNode;break}"a"===domElement.tagName.toLowerCase()&&(domElement=document.createElement("img"))}return attributes=this.getDOMElementAttributes(domElement),void 0===attributes.width&&(attributes.width=void 0===attributes.height?domElement.naturalWidth:domElement.clientWidth),void 0===attributes.height&&(attributes.height=void 0===attributes.width?domElement.naturalHeight:domElement.clientHeight),new this(attributes,a)},Image}(ContentEdit.ResizableElement),ContentEdit.TagNames.get().register(ContentEdit.Image,"img"),ContentEdit.Video=function(_super){function Video(tagName,attributes,sources){var size;null==sources&&(sources=[]),Video.__super__.constructor.call(this,tagName,attributes),this.sources=sources,size=this.size(),this._aspectRatio=size[1]/size[0]}return __extends(Video,_super),Video.prototype.cssTypeName=function(){return"video"},Video.prototype.typeName=function(){return"Video"},Video.prototype._title=function(){var src;return src="",this.attr("src")?src=this.attr("src"):this.sources.length&&(src=this.sources[0].src),src||(src="No video source set"),src.length>ContentEdit.HELPER_CHAR_LIMIT&&(src=text.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),src},Video.prototype.createDraggingDOMElement=function(){var helper;if(this.isMounted())return helper=Video.__super__.createDraggingDOMElement.call(this),helper.innerHTML=this._title(),helper},Video.prototype.html=function(indent){var attributes,source,sourceStrings,_i,_len,_ref;if(null==indent&&(indent=""),"video"===this.tagName()){for(sourceStrings=[],_ref=this.sources,_i=0,_len=_ref.length;_len>_i;_i++)source=_ref[_i],attributes=ContentEdit.attributesToString(source),sourceStrings.push(""+indent+ContentEdit.INDENT+"");return""+indent+"")}return""+indent+"<"+this._tagName+this._attributesToString()+">"+(""+this._tagName+">")},Video.prototype.mount=function(){var style;return this._domElement=document.createElement("div"),this.a&&this.a["class"]?this._domElement.setAttribute("class",this.a["class"]):this._attributes["class"]&&this._domElement.setAttribute("class",this._attributes["class"]),style=this._attributes.style?this._attributes.style:"",this._attributes.width&&(style+="width:"+this._attributes.width+"px;"),this._attributes.height&&(style+="height:"+this._attributes.height+"px;"),this._domElement.setAttribute("style",style),this._domElement.setAttribute("data-ce-title",this._title()),Video.__super__.mount.call(this)},Video.droppers={Image:ContentEdit.Element._dropBoth,PreText:ContentEdit.Element._dropBoth,Static:ContentEdit.Element._dropBoth,Text:ContentEdit.Element._dropBoth,Video:ContentEdit.Element._dropBoth},Video.placements=["above","below","left","right","center"],Video.fromDOMElement=function(domElement){var c,childNode,childNodes,sources,_i,_len;for(childNodes=function(){var _i,_len,_ref,_results;for(_ref=domElement.childNodes,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}(),sources=[],_i=0,_len=childNodes.length;_len>_i;_i++)childNode=childNodes[_i],1===childNode.nodeType&&"source"===childNode.tagName.toLowerCase()&&sources.push(this.getDOMElementAttributes(childNode));return new this(domElement.tagName,this.getDOMElementAttributes(domElement),sources)},Video}(ContentEdit.ResizableElement),ContentEdit.TagNames.get().register(ContentEdit.Video,"iframe","video"),ContentEdit.List=function(_super){function List(tagName,attributes){List.__super__.constructor.call(this,tagName,attributes)}return __extends(List,_super),List.prototype.cssTypeName=function(){return"list"},List.prototype.typeName=function(){return"List"},List.prototype._onMouseOver=function(ev){return"ListItem"!==this.parent().constructor.name?(List.__super__._onMouseOver.call(this,ev),this._removeCSSClass("ce-element--over")):void 0},List.droppers={Image:ContentEdit.Element._dropBoth,List:ContentEdit.Element._dropVert,PreText:ContentEdit.Element._dropVert,Static:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert,Video:ContentEdit.Element._dropBoth},List.fromDOMElement=function(domElement){var c,childNode,childNodes,list,_i,_len;for(list=new this(domElement.tagName,this.getDOMElementAttributes(domElement)),childNodes=function(){var _i,_len,_ref,_results;for(_ref=domElement.childNodes,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}(),_i=0,_len=childNodes.length;_len>_i;_i++)childNode=childNodes[_i],1===childNode.nodeType&&"li"===childNode.tagName.toLowerCase()&&list.attach(ContentEdit.ListItem.fromDOMElement(childNode));return 0===list.children.length?null:list},List}(ContentEdit.ElementCollection),ContentEdit.TagNames.get().register(ContentEdit.List,"ol","ul"),ContentEdit.ListItem=function(_super){function ListItem(attributes){ListItem.__super__.constructor.call(this,"li",attributes)}return __extends(ListItem,_super),ListItem.prototype.cssTypeName=function(){return"list-item"},ListItem.prototype.list=function(){return 2===this.children.length?this.children[1]:null},ListItem.prototype.listItemText=function(){return this.children.length>0?this.children[0]:null},ListItem.prototype.html=function(indent){var lines;return null==indent&&(indent=""),lines=[""+indent+""],this.listItemText()&&lines.push(this.listItemText().html(indent+ContentEdit.INDENT)),this.list()&&lines.push(this.list().html(indent+ContentEdit.INDENT)),lines.push(""+indent+" "),lines.join("\n")},ListItem.prototype.indent=function(){var sibling;if(0!==this.parent().children.indexOf(this))return sibling=this.previousSibling(),sibling.list()||sibling.attach(new ContentEdit.List(sibling.parent().tagName())),this.listItemText().storeState(),this.parent().detach(this),sibling.list().attach(this),this.listItemText().restoreState()},ListItem.prototype.remove=function(){var child,i,index,_i,_len,_ref;if(this.parent()){if(index=this.parent().children.indexOf(this),this.list())for(_ref=this.list().children.slice(),i=_i=0,_len=_ref.length;_len>_i;i=++_i)child=_ref[i],child.parent().detach(child),this.parent().attach(child,i+index);return this.parent().detach(this)}},ListItem.prototype.unindent=function(){var child,grandParent,i,itemIndex,list,parent,parentIndex,selection,sibling,siblings,text,_i,_j,_k,_l,_len,_len1,_len2,_len3,_ref,_ref1;if(parent=this.parent(),grandParent=parent.parent(),siblings=parent.children.slice(parent.children.indexOf(this)+1,parent.children.length),"ListItem"===grandParent.constructor.name){for(this.listItemText().storeState(),parent.detach(this),grandParent.parent().attach(this,grandParent.parent().children.indexOf(grandParent)+1),siblings.length&&!this.list()&&this.attach(new ContentEdit.List(parent.tagName())),_i=0,_len=siblings.length;_len>_i;_i++)sibling=siblings[_i],sibling.parent().detach(sibling),this.list().attach(sibling);return this.listItemText().restoreState()}if(text=new ContentEdit.Text("p",this.attr("class")?{"class":this.attr("class")}:{},this.listItemText().content),selection=null,this.listItemText().isFocused()&&(selection=ContentSelect.Range.query(this.listItemText().domElement())),parentIndex=grandParent.children.indexOf(parent),itemIndex=parent.children.indexOf(this),0===itemIndex){if(list=null,1===parent.children.length?(this.list()&&(list=new ContentEdit.List(parent.tagName())),grandParent.detach(parent)):parent.detach(this),grandParent.attach(text,parentIndex),list&&grandParent.attach(list,parentIndex+1),this.list())for(_ref=this.list().children.slice(),i=_j=0,_len1=_ref.length;_len1>_j;i=++_j)child=_ref[i],child.parent().detach(child),list?list.attach(child):parent.attach(child,i)}else if(itemIndex===parent.children.length-1)parent.detach(this),grandParent.attach(text,parentIndex+1),this.list()&&grandParent.attach(this.list(),parentIndex+2);else{if(parent.detach(this),grandParent.attach(text,parentIndex+1),list=new ContentEdit.List(parent.tagName()),grandParent.attach(list,parentIndex+2),this.list())for(_ref1=this.list().children.slice(),_k=0,_len2=_ref1.length;_len2>_k;_k++)child=_ref1[_k],child.parent().detach(child),list.attach(child);for(_l=0,_len3=siblings.length;_len3>_l;_l++)sibling=siblings[_l],sibling.parent().detach(sibling),list.attach(sibling)}return selection?(text.focus(),selection.select(text.domElement())):void 0},ListItem.prototype._onMouseOver=function(ev){return ListItem.__super__._onMouseOver.call(this,ev),this._removeCSSClass("ce-element--over")},ListItem.prototype._addDOMEventListeners=function(){},ListItem.prototype._removeDOMEventListners=function(){},ListItem.fromDOMElement=function(domElement){var childNode,content,listDOMElement,listElement,listItem,listItemText,_i,_len,_ref,_ref1;for(listItem=new this(this.getDOMElementAttributes(domElement)),content="",listDOMElement=null,_ref=domElement.childNodes,_i=0,_len=_ref.length;_len>_i;_i++)childNode=_ref[_i],1===childNode.nodeType?"ul"===(_ref1=childNode.tagName.toLowerCase())||"li"===_ref1?listDOMElement||(listDOMElement=childNode):content+=childNode.outerHTML:content+=HTMLString.String.encode(childNode.textContent);return content=content.replace(/^\s+|\s+$/g,""),listItemText=new ContentEdit.ListItemText(content),listItem.attach(listItemText),listDOMElement&&(listElement=ContentEdit.List.fromDOMElement(listDOMElement),listItem.attach(listElement)),listItem},ListItem}(ContentEdit.ElementCollection),ContentEdit.ListItemText=function(_super){function ListItemText(content){ListItemText.__super__.constructor.call(this,"div",{},content)}return __extends(ListItemText,_super),ListItemText.prototype.cssTypeName=function(){return"list-item-text"},ListItemText.prototype.typeName=function(){return"List item"},ListItemText.prototype.blur=function(){return this.content.isWhitespace()?this.parent().remove():this.isMounted()&&(this._domElement.blur(),this._domElement.removeAttribute("contenteditable")),ContentEdit.Element.prototype.blur.call(this)},ListItemText.prototype.html=function(indent){var content;return null==indent&&(indent=""),(!this._lastCached||this._lastCached_i;_i++)if(child=_ref[_i],child.tagName()===tagName)return child;return null},Table.droppers={Image:ContentEdit.Element._dropBoth,List:ContentEdit.Element._dropVert,PreText:ContentEdit.Element._dropVert,Static:ContentEdit.Element._dropVert,Table:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert,Video:ContentEdit.Element._dropBoth},Table.fromDOMElement=function(domElement){var c,childNode,childNodes,orphanRows,row,section,table,tagName,_i,_j,_len,_len1;for(table=new this(this.getDOMElementAttributes(domElement)),childNodes=function(){var _i,_len,_ref,_results;for(_ref=domElement.childNodes,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}(),orphanRows=[],_i=0,_len=childNodes.length;_len>_i;_i++)if(childNode=childNodes[_i],1===childNode.nodeType&&(tagName=childNode.tagName.toLowerCase(),!table._getChild(tagName)))switch(tagName){case"tbody":case"tfoot":case"thead":section=ContentEdit.TableSection.fromDOMElement(childNode),table.attach(section);break;case"tr":orphanRows.push(ContentEdit.TableRow.fromDOMElement(childNode))}if(orphanRows.length>0)for(table._getChild("tbody")||table.attach(new ContentEdit.TableSection("tbody")),_j=0,_len1=orphanRows.length;_len1>_j;_j++)row=orphanRows[_j],table.tbody().attach(row);return 0===table.children.length?null:table},Table}(ContentEdit.ElementCollection),ContentEdit.TagNames.get().register(ContentEdit.Table,"table"),ContentEdit.TableSection=function(_super){function TableSection(tagName,attributes){TableSection.__super__.constructor.call(this,tagName,attributes)}return __extends(TableSection,_super),TableSection.prototype.cssTypeName=function(){return"table-section"},TableSection.prototype._onMouseOver=function(ev){return TableSection.__super__._onMouseOver.call(this,ev),this._removeCSSClass("ce-element--over")},TableSection.fromDOMElement=function(domElement){var c,childNode,childNodes,section,_i,_len;for(section=new this(domElement.tagName,this.getDOMElementAttributes(domElement)),childNodes=function(){var _i,_len,_ref,_results;for(_ref=domElement.childNodes,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}(),_i=0,_len=childNodes.length;_len>_i;_i++)childNode=childNodes[_i],1===childNode.nodeType&&"tr"===childNode.tagName.toLowerCase()&§ion.attach(ContentEdit.TableRow.fromDOMElement(childNode));return section},TableSection}(ContentEdit.ElementCollection),ContentEdit.TableRow=function(_super){function TableRow(attributes){TableRow.__super__.constructor.call(this,"tr",attributes)}return __extends(TableRow,_super),TableRow.prototype.cssTypeName=function(){return"table-row"},TableRow.prototype.typeName=function(){return"Table row"},TableRow.prototype._onMouseOver=function(ev){return TableRow.__super__._onMouseOver.call(this,ev),this._removeCSSClass("ce-element--over")},TableRow.droppers={TableRow:ContentEdit.Element._dropVert},TableRow.fromDOMElement=function(domElement){var c,childNode,childNodes,row,tagName,_i,_len;
5 | for(row=new this(this.getDOMElementAttributes(domElement)),childNodes=function(){var _i,_len,_ref,_results;for(_ref=domElement.childNodes,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)c=_ref[_i],_results.push(c);return _results}(),_i=0,_len=childNodes.length;_len>_i;_i++)childNode=childNodes[_i],1===childNode.nodeType&&(tagName=childNode.tagName.toLowerCase(),("td"===tagName||"th"===tagName)&&row.attach(ContentEdit.TableCell.fromDOMElement(childNode)));return row},TableRow}(ContentEdit.ElementCollection),ContentEdit.TableCell=function(_super){function TableCell(tagName,attributes){TableCell.__super__.constructor.call(this,tagName,attributes)}return __extends(TableCell,_super),TableCell.prototype.cssTypeName=function(){return"table-cell"},TableCell.prototype.tableCellText=function(){return this.children.length>0?this.children[0]:null},TableCell.prototype.html=function(indent){var lines;return null==indent&&(indent=""),lines=[""+indent+"<"+this.tagName()+this._attributesToString()+">"],this.tableCellText()&&lines.push(this.tableCellText().html(indent+ContentEdit.INDENT)),lines.push(""+indent+""+this.tagName()+">"),lines.join("\n")},TableCell.prototype._onMouseOver=function(ev){return TableCell.__super__._onMouseOver.call(this,ev),this._removeCSSClass("ce-element--over")},TableCell.prototype._addDOMEventListeners=function(){},TableCell.prototype._removeDOMEventListners=function(){},TableCell.fromDOMElement=function(domElement){var tableCell,tableCellText;return tableCell=new this(domElement.tagName,this.getDOMElementAttributes(domElement)),tableCellText=new ContentEdit.TableCellText(domElement.innerHTML.replace(/^\s+|\s+$/g,"")),tableCell.attach(tableCellText),tableCell},TableCell}(ContentEdit.ElementCollection),ContentEdit.TableCellText=function(_super){function TableCellText(content){TableCellText.__super__.constructor.call(this,"div",{},content)}return __extends(TableCellText,_super),TableCellText.prototype.cssTypeName=function(){return"table-cell-text"},TableCellText.prototype._isInFirstRow=function(){var cell,row,section,table;return cell=this.parent(),row=cell.parent(),section=row.parent(),table=section.parent(),section!==table.firstSection()?!1:row===section.children[0]},TableCellText.prototype._isInLastRow=function(){var cell,row,section,table;return cell=this.parent(),row=cell.parent(),section=row.parent(),table=section.parent(),section!==table.lastSection()?!1:row===section.children[section.children.length-1]},TableCellText.prototype._isLastInSection=function(){var cell,row,section;return cell=this.parent(),row=cell.parent(),section=row.parent(),row!==section.children[section.children.length-1]?!1:cell===row.children[row.children.length-1]},TableCellText.prototype.blur=function(){return this.isMounted()&&(this._domElement.blur(),this._domElement.removeAttribute("contenteditable")),ContentEdit.Element.prototype.blur.call(this)},TableCellText.prototype.html=function(indent){var content;return null==indent&&(indent=""),(!this._lastCached||this._lastCached_i;_i++)child=_ref[_i],newCell=new ContentEdit.TableCell(child.tagName(),child._attributes),newCellText=new ContentEdit.TableCellText(""),newCell.attach(newCellText),row.attach(newCell);return section=this.closest(function(node){return"TableSection"===node.constructor.name}),section.attach(row),row.children[0].tableCellText().focus()}return this.nextContent().focus()},TableCellText.prototype._keyUp=function(ev){var cell,cellIndex,previousRow,row;return ev.preventDefault(),cell=this.parent(),this._isInFirstRow()?(row=cell.parent(),row.children[0].previousContent().focus()):(previousRow=cell.parent().previousWithTest(function(node){return"TableRow"===node.constructor.name}),cellIndex=cell.parent().children.indexOf(cell),cellIndex=Math.min(cellIndex,previousRow.children.length),previousRow.children[cellIndex].tableCellText().focus())},TableCellText.droppers={},TableCellText.mergers={},TableCellText}(ContentEdit.Text)}.call(this),function(){var AttributeUI,CropmarksUI,StyleUI,_EditorApp,__slice=[].slice,__hasProp={}.hasOwnProperty,__extends=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)__hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};window.ContentTools={Tools:{},DEFAULT_TOOLS:[["bold","italic","link","align-left","align-center","align-right"],["heading","subheading","paragraph","unordered-list","ordered-list","table","indent","unindent","line-break"],["image","video","preformatted"],["undo","redo","remove"]],DEFAULT_VIDEO_HEIGHT:300,DEFAULT_VIDEO_WIDTH:400,HIGHLIGHT_HOLD_DURATION:2e3,INSPECTOR_IGNORED_ELEMENTS:["ListItemText","Region","TableCellText"],IMAGE_UPLOADER:null,MIN_CROP:10,RESTRICTED_ATTRIBUTES:{img:["height","src","width","data-ce-max-width","data-ce-min-width"],iframe:["height","width"]},getEmbedVideoURL:function(url){var domains,id,kv,m,netloc,params,paramsStr,parser,path,_i,_len,_ref;for(domains={"www.youtube.com":"youtube","youtu.be":"youtube","vimeo.com":"vimeo"},parser=document.createElement("a"),parser.href=url,netloc=parser.hostname.toLowerCase(),path=parser.pathname,null!==path&&"/"!==path.substr(0,1)&&(path="/"+path),params={},paramsStr=parser.search.slice(1),_ref=paramsStr.split("&"),_i=0,_len=_ref.length;_len>_i;_i++)kv=_ref[_i],kv=kv.split("="),params[kv[0]]=kv[1];switch(domains[netloc]){case"youtube":if("/watch"===path.toLowerCase()){if(!params.v)return null;id=params.v}else{if(m=path.match(/\/([A-Za-z0-9_-]+)$/i),!m)return null;id=m[1]}return"https://www.youtube.com/embed/"+id;case"vimeo":return m=path.match(/\/(\w+\/\w+\/){0,1}(\d+)/i),m?"https://player.vimeo.com/video/"+m[2]:null}return null}},ContentTools.ComponentUI=function(){function ComponentUI(){this._bindings={},this._parent=null,this._children=[],this._domElement=null}return ComponentUI.prototype.children=function(){return this._children.slice()},ComponentUI.prototype.domElement=function(){return this._domElement},ComponentUI.prototype.parent=function(){return this._parent},ComponentUI.prototype.isMounted=function(){return null!==this._domElement},ComponentUI.prototype.attach=function(component,index){return component.parent()&&component.parent().detach(component),component._parent=this,void 0!==index?this._children.splice(index,0,component):this._children.push(component)},ComponentUI.prototype.addCSSClass=function(className){return this.isMounted()?ContentEdit.addCSSClass(this._domElement,className):void 0},ComponentUI.prototype.detatch=function(){},ComponentUI.prototype.mount=function(){},ComponentUI.prototype.removeCSSClass=function(className){return this.isMounted()?ContentEdit.removeCSSClass(this._domElement,className):void 0},ComponentUI.prototype.unmount=function(){return this.isMounted()?(this._removeDOMEventListeners(),this._domElement.parentNode.removeChild(this._domElement),this._domElement=null):void 0},ComponentUI.prototype.bind=function(eventName,callback){return void 0===this._bindings[eventName]&&(this._bindings[eventName]=[]),this._bindings[eventName].push(callback),callback},ComponentUI.prototype.trigger=function(){var args,callback,eventName,_i,_len,_ref,_results;if(eventName=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[],this._bindings[eventName]){for(_ref=this._bindings[eventName],_results=[],_i=0,_len=_ref.length;_len>_i;_i++)callback=_ref[_i],callback&&_results.push(callback.call.apply(callback,[this].concat(__slice.call(args))));return _results}},ComponentUI.prototype.unbind=function(eventName,callback){var i,suspect,_i,_len,_ref,_results;if(!eventName)return void(this._bindings={});if(!callback)return void(this._bindings[eventName]=void 0);if(this._bindings[eventName]){for(_ref=this._bindings[eventName],_results=[],i=_i=0,_len=_ref.length;_len>_i;i=++_i)suspect=_ref[i],_results.push(suspect===callback?this._bindings[eventName].splice(i,1):void 0);return _results}},ComponentUI.prototype._addDOMEventListeners=function(){},ComponentUI.prototype._removeDOMEventListeners=function(){},ComponentUI.prototype.createDiv=function(classNames,attributes,content){var domElement,name,value;if(domElement=document.createElement("div"),classNames&&classNames.length>0&&domElement.setAttribute("class",classNames.join(" ")),attributes)for(name in attributes)value=attributes[name],domElement.setAttribute(name,value);return content&&(domElement.innerHTML=content),domElement},ComponentUI}(),ContentTools.WidgetUI=function(_super){function WidgetUI(){return WidgetUI.__super__.constructor.apply(this,arguments)}return __extends(WidgetUI,_super),WidgetUI.prototype.attach=function(component,index){return WidgetUI.__super__.attach.call(this,component,index),this.isMounted()?component.mount():void 0},WidgetUI.prototype.show=function(){var fadeIn;return this.isMounted()||this.mount(),fadeIn=function(_this){return function(){return _this.addCSSClass("ct-widget--active")}}(this),setTimeout(fadeIn,100)},WidgetUI.prototype.hide=function(){var monitorForHidden;return this.removeCSSClass("ct-widget--active"),monitorForHidden=function(_this){return function(){return window.getComputedStyle?parseFloat(window.getComputedStyle(_this._domElement).opacity)<.01?_this.unmount():setTimeout(monitorForHidden,250):void _this.unmount()}}(this),setTimeout(monitorForHidden,250)},WidgetUI}(ContentTools.ComponentUI),ContentTools.AnchoredComponentUI=function(_super){function AnchoredComponentUI(){return AnchoredComponentUI.__super__.constructor.apply(this,arguments)}return __extends(AnchoredComponentUI,_super),AnchoredComponentUI.prototype.mount=function(domParent,before){return null==before&&(before=null),domParent.insertBefore(this._domElement,before),this._addDOMEventListeners()},AnchoredComponentUI}(ContentTools.ComponentUI),ContentTools.FlashUI=function(_super){function FlashUI(modifier){FlashUI.__super__.constructor.call(this),this.mount(modifier)}return __extends(FlashUI,_super),FlashUI.prototype.mount=function(modifier){var monitorForHidden;return this._domElement=this.createDiv(["ct-flash","ct-flash--active","ct-flash--"+modifier,"ct-widget","ct-widget--active"]),FlashUI.__super__.mount.call(this,ContentTools.EditorApp.get().domElement()),monitorForHidden=function(_this){return function(){return window.getComputedStyle?parseFloat(window.getComputedStyle(_this._domElement).opacity)<.01?_this.unmount():setTimeout(monitorForHidden,250):void _this.unmount()}}(this),setTimeout(monitorForHidden,250)},FlashUI}(ContentTools.AnchoredComponentUI),ContentTools.IgnitionUI=function(_super){function IgnitionUI(){IgnitionUI.__super__.constructor.call(this),this._busy=!1}return __extends(IgnitionUI,_super),IgnitionUI.prototype.busy=function(busy){if(void 0===busy)return"busy"===this._state;if(this._busy!==busy)return this._busy=busy,busy?this.addCSSClass("ct-ignition--busy"):this.removeCSSClass("ct-ignition--busy")},IgnitionUI.prototype.changeState=function(state){return"editing"===state?(this.addCSSClass("ct-ignition--editing"),this.removeCSSClass("ct-ignition--ready")):"ready"===state?(this.removeCSSClass("ct-ignition--editing"),this.addCSSClass("ct-ignition--ready")):void 0},IgnitionUI.prototype.mount=function(){return IgnitionUI.__super__.mount.call(this),this._domElement=this.createDiv(["ct-widget","ct-ignition","ct-ignition--ready"]),this.parent().domElement().appendChild(this._domElement),this._domEdit=this.createDiv(["ct-ignition__button","ct-ignition__button--edit"]),this._domElement.appendChild(this._domEdit),this._domConfirm=this.createDiv(["ct-ignition__button","ct-ignition__button--confirm"]),this._domElement.appendChild(this._domConfirm),this._domCancel=this.createDiv(["ct-ignition__button","ct-ignition__button--cancel"]),this._domElement.appendChild(this._domCancel),this._domBusy=this.createDiv(["ct-ignition__button","ct-ignition__button--busy"]),this._domElement.appendChild(this._domBusy),this._addDOMEventListeners()},IgnitionUI.prototype.unmount=function(){return IgnitionUI.__super__.unmount.call(this),this._domEdit=null,this._domConfirm=null,this._domCancel=null},IgnitionUI.prototype._addDOMEventListeners=function(){return this._domEdit.addEventListener("click",function(_this){return function(ev){return ev.preventDefault(),_this.addCSSClass("ct-ignition--editing"),_this.removeCSSClass("ct-ignition--ready"),_this.trigger("start")}}(this)),this._domConfirm.addEventListener("click",function(_this){return function(ev){return ev.preventDefault(),_this.removeCSSClass("ct-ignition--editing"),_this.addCSSClass("ct-ignition--ready"),_this.trigger("stop",!0)}}(this)),this._domCancel.addEventListener("click",function(_this){return function(ev){return ev.preventDefault(),_this.removeCSSClass("ct-ignition--editing"),_this.addCSSClass("ct-ignition--ready"),_this.trigger("stop",!1)}}(this))},IgnitionUI}(ContentTools.WidgetUI),ContentTools.InspectorUI=function(_super){function InspectorUI(){InspectorUI.__super__.constructor.call(this),this._tagUIs=[]}return __extends(InspectorUI,_super),InspectorUI.prototype.mount=function(){return this._domElement=this.createDiv(["ct-widget","ct-inspector"]),this.parent().domElement().appendChild(this._domElement),this._domTags=this.createDiv(["ct-inspector__tags","ct-tags"]),this._domElement.appendChild(this._domTags),this._addDOMEventListeners(),this._handleFocusChange=function(_this){return function(){return _this.updateTags()}}(this),ContentEdit.Root.get().bind("blur",this._handleFocusChange),ContentEdit.Root.get().bind("focus",this._handleFocusChange),ContentEdit.Root.get().bind("mount",this._handleFocusChange)},InspectorUI.prototype.unmount=function(){return InspectorUI.__super__.unmount.call(this),this._domTags=null,ContentEdit.Root.get().unbind("blur",this._handleFocusChange),ContentEdit.Root.get().unbind("focus",this._handleFocusChange),ContentEdit.Root.get().unbind("mount",this._handleFocusChange)},InspectorUI.prototype.updateTags=function(){var element,elements,tag,_i,_j,_len,_len1,_ref,_results;for(element=ContentEdit.Root.get().focused(),_ref=this._tagUIs,_i=0,_len=_ref.length;_len>_i;_i++)tag=_ref[_i],tag.unmount();if(element){for(elements=element.parents(),elements.reverse(),elements.push(element),_results=[],_j=0,_len1=elements.length;_len1>_j;_j++)element=elements[_j],-1===ContentTools.INSPECTOR_IGNORED_ELEMENTS.indexOf(element.constructor.name)&&(tag=new ContentTools.TagUI(element),this._tagUIs.push(tag),_results.push(tag.mount(this._domTags)));return _results}},InspectorUI}(ContentTools.WidgetUI),ContentTools.TagUI=function(_super){function TagUI(element){this.element=element,this._onMouseDown=__bind(this._onMouseDown,this),TagUI.__super__.constructor.call(this)}return __extends(TagUI,_super),TagUI.prototype.mount=function(domParent,before){return null==before&&(before=null),this._domElement=this.createDiv(["ct-tag"]),this._domElement.textContent=this.element.tagName(),TagUI.__super__.mount.call(this,domParent,before)},TagUI.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("mousedown",this._onMouseDown)},TagUI.prototype._onMouseDown=function(ev){var app,dialog,modal;return ev.preventDefault(),this.element.storeState&&this.element.storeState(),app=ContentTools.EditorApp.get(),modal=new ContentTools.ModalUI,dialog=new ContentTools.PropertiesDialog(this.element),dialog.bind("cancel",function(_this){return function(){return dialog.unbind("cancel"),modal.hide(),dialog.hide(),_this.element.restoreState?_this.element.restoreState():void 0}}(this)),dialog.bind("save",function(_this){return function(attributes,styles,innerHTML){var applied,className,classNames,cssClass,element,name,value,_i,_j,_len,_len1,_ref,_ref1;dialog.unbind("save");for(name in attributes)if(value=attributes[name],"class"===name){for(null===value&&(value=""),classNames={},_ref=value.split(" "),_i=0,_len=_ref.length;_len>_i;_i++)className=_ref[_i],className=className.trim(),className&&(classNames[className]=!0,_this.element.hasCSSClass(className)||_this.element.addCSSClass(className));for(_ref1=_this.element.attr("class").split(" "),_j=0,_len1=_ref1.length;_len1>_j;_j++)className=_ref1[_j],className=className.trim(),void 0===classNames[className]&&_this.element.removeCSSClass(className)}else null===value?_this.element.removeAttr(name):_this.element.attr(name,value);for(cssClass in styles)applied=styles[cssClass],applied?_this.element.addCSSClass(cssClass):_this.element.removeCSSClass(cssClass);return null!==innerHTML&&innerHTML!==dialog.getElementInnerHTML()&&(element=_this.element,element.content||(element=element.children[0]),element.content=new HTMLString.String(innerHTML,element.content.preserveWhitespace()),element.updateInnerHTML(),element.taint(),element.selection(new ContentSelect.Range(0,0)),element.storeState()),modal.hide(),dialog.hide(),_this.element.restoreState?_this.element.restoreState():void 0}}(this)),app.attach(modal),app.attach(dialog),modal.show(),dialog.show()},TagUI}(ContentTools.AnchoredComponentUI),ContentTools.ModalUI=function(_super){function ModalUI(transparent,allowScrolling){ModalUI.__super__.constructor.call(this),this._transparent=transparent,this._allowScrolling=allowScrolling}return __extends(ModalUI,_super),ModalUI.prototype.mount=function(){return this._domElement=this.createDiv(["ct-widget","ct-modal"]),this.parent().domElement().appendChild(this._domElement),this._transparent&&this.addCSSClass("ct-modal--transparent"),this._allowScrolling||ContentEdit.addCSSClass(document.body,"ct--no-scroll"),this._addDOMEventListeners()},ModalUI.prototype.unmount=function(){return this._allowScrolling||ContentEdit.removeCSSClass(document.body,"ct--no-scroll"),ModalUI.__super__.unmount.call(this)},ModalUI.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("click",function(_this){return function(){return _this.trigger("click")}}(this))},ModalUI}(ContentTools.WidgetUI),ContentTools.ToolboxUI=function(_super){function ToolboxUI(tools){this._onStopDragging=__bind(this._onStopDragging,this),this._onStartDragging=__bind(this._onStartDragging,this),this._onDrag=__bind(this._onDrag,this),ToolboxUI.__super__.constructor.call(this),this._tools=tools,this._dragging=!1,this._draggingOffset=null,this._domGrip=null,this._toolUIs={}}return __extends(ToolboxUI,_super),ToolboxUI.prototype.isDragging=function(){return this._dragging},ToolboxUI.prototype.hide=function(){return this._removeDOMEventListeners(),ToolboxUI.__super__.hide.call(this)},ToolboxUI.prototype.tools=function(tools){return void 0===tools?this._tools:(this._tools=tools,this.unmount(),this.mount())},ToolboxUI.prototype.mount=function(){var coord,domToolGroup,i,position,restore,tool,toolGroup,toolName,_i,_j,_len,_len1,_ref;for(this._domElement=this.createDiv(["ct-widget","ct-toolbox"]),this.parent().domElement().appendChild(this._domElement),this._domGrip=this.createDiv(["ct-toolbox__grip","ct-grip"]),this._domElement.appendChild(this._domGrip),this._domGrip.appendChild(this.createDiv(["ct-grip__bump"])),this._domGrip.appendChild(this.createDiv(["ct-grip__bump"])),this._domGrip.appendChild(this.createDiv(["ct-grip__bump"])),_ref=this._tools,i=_i=0,_len=_ref.length;_len>_i;i=++_i)for(toolGroup=_ref[i],domToolGroup=this.createDiv(["ct-tool-group"]),this._domElement.appendChild(domToolGroup),_j=0,_len1=toolGroup.length;_len1>_j;_j++)toolName=toolGroup[_j],tool=ContentTools.ToolShelf.fetch(toolName),this._toolUIs[toolName]=new ContentTools.ToolUI(tool),this._toolUIs[toolName].mount(domToolGroup),this._toolUIs[toolName].disable(),this._toolUIs[toolName].bind("apply",function(_this){return function(){return _this.updateTools()}}(this));return restore=window.localStorage.getItem("ct-toolbox-position"),restore&&/^\d+,\d+$/.test(restore)&&(position=function(){var _k,_len2,_ref1,_results;for(_ref1=restore.split(","),_results=[],_k=0,_len2=_ref1.length;_len2>_k;_k++)coord=_ref1[_k],_results.push(parseInt(coord));return _results}(),this._domElement.style.left=""+position[0]+"px",this._domElement.style.top=""+position[1]+"px",this._contain()),this._addDOMEventListeners()},ToolboxUI.prototype.updateTools=function(){var element,name,selection,toolUI,_ref,_results;element=ContentEdit.Root.get().focused(),selection=null,element&&element.selection&&(selection=element.selection()),_ref=this._toolUIs,_results=[];for(name in _ref)toolUI=_ref[name],_results.push(toolUI.update(element,selection));return _results},ToolboxUI.prototype.unmount=function(){return ToolboxUI.__super__.unmount.call(this),this._domGrip=null},ToolboxUI.prototype._addDOMEventListeners=function(){return this._domGrip.addEventListener("mousedown",this._onStartDragging),this._handleResize=function(_this){return function(){var containResize;return _this._resizeTimeout&&clearTimeout(_this._resizeTimeout),containResize=function(){return _this._contain()},_this._resizeTimeout=setTimeout(containResize,250)}}(this),window.addEventListener("resize",this._handleResize),this._updateTools=function(_this){return function(){var app,element,name,selection,toolUI,update,_ref,_results;app=ContentTools.EditorApp.get(),update=!1,element=ContentEdit.Root.get().focused(),selection=null,element===_this._lastUpdateElement?element&&element.selection&&(selection=element.selection(),_this._lastUpdateSelection&&selection.eq(_this._lastUpdateSelection)&&(update=!0)):update=!0,app.history&&(_this._lastUpdateHistoryLength!==app.history.length()&&(update=!0),_this._lastUpdateHistoryLength=app.history.length()),_this._lastUpdateElement=element,_this._lastUpdateSelection=selection,_ref=_this._toolUIs,_results=[];for(name in _ref)toolUI=_ref[name],_results.push(toolUI.update(element,selection));return _results}}(this),this._updateToolsTimeout=setInterval(this._updateTools,100),this._handleKeyDown=function(){return function(ev){var element,os,redo,undo,version;switch(46===ev.keyCode&&(element=ContentEdit.Root.get().focused(),element&&!element.content&&ContentTools.Tools.Remove.apply(element,null,function(){})),version=navigator.appVersion,os="linux",-1!==version.indexOf("Mac")?os="mac":-1!==version.indexOf("Win")&&(os="windows"),redo=!1,undo=!1,os){case"linux":90===ev.keyCode&&ev.ctrlKey&&(redo=ev.shiftKey,undo=!redo);break;case"mac":90===ev.keyCode&&ev.metaKey&&(redo=ev.shiftKey,undo=!redo);break;case"windows":89===ev.keyCode&&ev.ctrlKey&&(redo=!0),90===ev.keyCode&&ev.ctrlKey&&(undo=!0)}return undo&&ContentTools.Tools.Undo.canApply(null,null)&&ContentTools.Tools.Undo.apply(null,null,function(){}),redo&&ContentTools.Tools.Redo.canApply(null,null)?ContentTools.Tools.Redo.apply(null,null,function(){}):void 0}}(this),window.addEventListener("keydown",this._handleKeyDown)},ToolboxUI.prototype._contain=function(){var rect;if(this.isMounted())return rect=this._domElement.getBoundingClientRect(),rect.left+rect.width>window.innerWidth&&(this._domElement.style.left=""+(window.innerWidth-rect.width)+"px"),rect.top+rect.height>window.innerHeight&&(this._domElement.style.top=""+(window.innerHeight-rect.height)+"px"),rect.left<0&&(this._domElement.style.left="0px"),rect.top<0&&(this._domElement.style.top="0px"),rect=this._domElement.getBoundingClientRect(),window.localStorage.setItem("ct-toolbox-position",""+rect.left+","+rect.top)},ToolboxUI.prototype._removeDOMEventListeners=function(){return this.isMounted()&&this._domGrip.removeEventListener("mousedown",this._onStartDragging),window.removeEventListener("keydown",this._handleKeyDown),window.removeEventListener("resize",this._handleResize),window.removeEventListener("resize",this._handleResize),clearInterval(this._updateToolsTimeout)},ToolboxUI.prototype._onDrag=function(ev){return ContentSelect.Range.unselectAll(),this._domElement.style.left=""+(ev.clientX-this._draggingOffset.x)+"px",this._domElement.style.top=""+(ev.clientY-this._draggingOffset.y)+"px"},ToolboxUI.prototype._onStartDragging=function(ev){var rect;return ev.preventDefault(),this.isDragging()?void 0:(this._dragging=!0,this.addCSSClass("ct-toolbox--dragging"),rect=this._domElement.getBoundingClientRect(),this._draggingOffset={x:ev.clientX-rect.left,y:ev.clientY-rect.top},document.addEventListener("mousemove",this._onDrag),document.addEventListener("mouseup",this._onStopDragging),ContentEdit.addCSSClass(document.body,"ce--dragging"))},ToolboxUI.prototype._onStopDragging=function(){return this.isDragging()?(this._contain(),document.removeEventListener("mousemove",this._onDrag),document.removeEventListener("mouseup",this._onStopDragging),this._draggingOffset=null,this._dragging=!1,this.removeCSSClass("ct-toolbox--dragging"),ContentEdit.removeCSSClass(document.body,"ce--dragging")):void 0},ToolboxUI}(ContentTools.WidgetUI),ContentTools.ToolUI=function(_super){function ToolUI(tool){this._onMouseUp=__bind(this._onMouseUp,this),this._onMouseLeave=__bind(this._onMouseLeave,this),this._onMouseDown=__bind(this._onMouseDown,this),this._addDOMEventListeners=__bind(this._addDOMEventListeners,this),ToolUI.__super__.constructor.call(this),this.tool=tool,this._mouseDown=!1,this._disabled=!1}return __extends(ToolUI,_super),ToolUI.prototype.disabled=function(){return this._disabled},ToolUI.prototype.apply=function(){var callback,element,selection;return element=ContentEdit.Root.get().focused(),element&&element.isMounted()&&(selection=null,element.selection&&(selection=element.selection()),this.tool.canApply(element,selection))?(callback=function(_this){return function(applied){return applied?_this.trigger("apply"):void 0}}(this),this.tool.apply(element,selection,callback)):void 0},ToolUI.prototype.disable=function(){return this._disabled?void 0:(this._disabled=!0,this._mouseDown=!1,this.addCSSClass("ct-tool--disabled"),this.removeCSSClass("ct-tool--applied"))},ToolUI.prototype.enable=function(){return this._disabled?(this._disabled=!1,this.removeCSSClass("ct-tool--disabled")):void 0},ToolUI.prototype.mount=function(domParent,before){return null==before&&(before=null),this._domElement=this.createDiv(["ct-tool","ct-tool--"+this.tool.icon]),this._domElement.setAttribute("data-tooltip",ContentEdit._(this.tool.label)),ToolUI.__super__.mount.call(this,domParent,before)},ToolUI.prototype.update=function(element,selection){return element&&element.isMounted()&&this.tool.canApply(element,selection)?(this.enable(),this.tool.isApplied(element,selection)?this.addCSSClass("ct-tool--applied"):this.removeCSSClass("ct-tool--applied")):void this.disable()},ToolUI.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("mousedown",this._onMouseDown),this._domElement.addEventListener("mouseleave",this._onMouseLeave),this._domElement.addEventListener("mouseup",this._onMouseUp)},ToolUI.prototype._onMouseDown=function(ev){return ev.preventDefault(),this.disabled()?void 0:(this._mouseDown=!0,this.addCSSClass("ct-tool--down"))},ToolUI.prototype._onMouseLeave=function(){return this._mouseDown=!1,this.removeCSSClass("ct-tool--down")},ToolUI.prototype._onMouseUp=function(){return this._mouseDown&&this.apply(),this._mouseDown=!1,this.removeCSSClass("ct-tool--down")},ToolUI}(ContentTools.AnchoredComponentUI),ContentTools.AnchoredDialogUI=function(_super){function AnchoredDialogUI(){AnchoredDialogUI.__super__.constructor.call(this),this._position=[0,0]}return __extends(AnchoredDialogUI,_super),AnchoredDialogUI.prototype.mount=function(){return this._domElement=this.createDiv(["ct-widget","ct-anchored-dialog"]),this.parent().domElement().appendChild(this._domElement),this._domElement.style.top=""+this._position[1]+"px",this._domElement.style.left=""+this._position[0]+"px"},AnchoredDialogUI.prototype.position=function(newPosition){return void 0===newPosition?this._position.slice():(this._position=newPosition.slice(),this.isMounted()?(this._domElement.style.top=""+this._position[1]+"px",this._domElement.style.left=""+this._position[10]+"px"):void 0)},AnchoredDialogUI}(ContentTools.WidgetUI),ContentTools.DialogUI=function(_super){function DialogUI(caption){null==caption&&(caption=""),DialogUI.__super__.constructor.call(this),this._busy=!1,this._caption=caption}return __extends(DialogUI,_super),DialogUI.prototype.busy=function(busy){if(void 0===busy)return this._busy;if(this._busy!==busy&&(this._busy=busy,this.isMounted()))return this._busy?ContentEdit.addCSSClass(this._domElement,"ct-dialog--busy"):ContentEdit.removeCSSClass(this._domElement,"ct-dialog--busy")},DialogUI.prototype.caption=function(caption){return void 0===caption?this._caption:(this._caption=caption,this._domCaption.textContent=ContentEdit._(caption))},DialogUI.prototype.mount=function(){var dialogCSSClasses,domBody,domHeader;return dialogCSSClasses=["ct-widget","ct-dialog"],this._busy&&dialogCSSClasses.push("ct-dialog--busy"),this._domElement=this.createDiv(dialogCSSClasses),this.parent().domElement().appendChild(this._domElement),domHeader=this.createDiv(["ct-dialog__header"]),this._domElement.appendChild(domHeader),this._domCaption=this.createDiv(["ct-dialog__caption"]),domHeader.appendChild(this._domCaption),this.caption(this._caption),this._domClose=this.createDiv(["ct-dialog__close"]),domHeader.appendChild(this._domClose),domBody=this.createDiv(["ct-dialog__body"]),this._domElement.appendChild(domBody),this._domView=this.createDiv(["ct-dialog__view"]),domBody.appendChild(this._domView),this._domControls=this.createDiv(["ct-dialog__controls"]),domBody.appendChild(this._domControls),this._domBusy=this.createDiv(["ct-dialog__busy"]),this._domElement.appendChild(this._domBusy)},DialogUI.prototype.unmount=function(){return DialogUI.__super__.unmount.call(this),this._domBusy=null,this._domCaption=null,this._domClose=null,this._domControls=null,this._domView=null},DialogUI.prototype._addDOMEventListeners=function(){return this._handleEscape=function(_this){return function(ev){return _this._busy?void 0:27===ev.keyCode?_this.trigger("cancel"):void 0}}(this),document.addEventListener("keyup",this._handleEscape),this._domClose.addEventListener("click",function(_this){return function(ev){return ev.preventDefault(),_this._busy?void 0:_this.trigger("cancel")}}(this))},DialogUI.prototype._removeDOMEventListeners=function(){return document.removeEventListener("keyup",this._handleEscape)
6 | },DialogUI}(ContentTools.WidgetUI),ContentTools.ImageDialog=function(_super){function ImageDialog(){ImageDialog.__super__.constructor.call(this,"Insert image"),this._cropmarks=null,this._imageURL=null,this._imageSize=null,this._progress=0,this._state="empty",ContentTools.IMAGE_UPLOADER&&ContentTools.IMAGE_UPLOADER(this)}return __extends(ImageDialog,_super),ImageDialog.prototype.cropRegion=function(){return this._cropmarks?this._cropmarks.region():[0,0,1,1]},ImageDialog.prototype.addCropmarks=function(){return this._cropmarks?void 0:(this._cropmarks=new CropmarksUI(this._imageSize),this._cropmarks.mount(this._domView),ContentEdit.addCSSClass(this._domCrop,"ct-control--active"))},ImageDialog.prototype.clear=function(){return this._domImage&&(this._domImage.parentNode.removeChild(this._domImage),this._domImage=null),this._imageURL=null,this._imageSize=null,this.state("empty")},ImageDialog.prototype.mount=function(){var domActions,domProgressBar,domTools;return ImageDialog.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-image-dialog"),ContentEdit.addCSSClass(this._domElement,"ct-image-dialog--empty"),ContentEdit.addCSSClass(this._domView,"ct-image-dialog__view"),domTools=this.createDiv(["ct-control-group","ct-control-group--left"]),this._domControls.appendChild(domTools),this._domRotateCCW=this.createDiv(["ct-control","ct-control--icon","ct-control--rotate-ccw"]),this._domRotateCCW.setAttribute("data-tooltip",ContentEdit._("Rotate")+" -90°"),domTools.appendChild(this._domRotateCCW),this._domRotateCW=this.createDiv(["ct-control","ct-control--icon","ct-control--rotate-cw"]),this._domRotateCW.setAttribute("data-tooltip",ContentEdit._("Rotate")+" 90°"),domTools.appendChild(this._domRotateCW),this._domCrop=this.createDiv(["ct-control","ct-control--icon","ct-control--crop"]),this._domCrop.setAttribute("data-tooltip",ContentEdit._("Cropmarks")),domTools.appendChild(this._domCrop),domProgressBar=this.createDiv(["ct-progress-bar"]),domTools.appendChild(domProgressBar),this._domProgress=this.createDiv(["ct-progress-bar__progress"]),domProgressBar.appendChild(this._domProgress),domActions=this.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(domActions),this._domUpload=this.createDiv(["ct-control","ct-control--text","ct-control--upload"]),this._domUpload.textContent=ContentEdit._("Upload"),domActions.appendChild(this._domUpload),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-image-dialog__file-upload"),this._domInput.setAttribute("name","file"),this._domInput.setAttribute("type","file"),this._domInput.setAttribute("accept","image/*"),this._domUpload.appendChild(this._domInput),this._domInsert=this.createDiv(["ct-control","ct-control--text","ct-control--insert"]),this._domInsert.textContent=ContentEdit._("Insert"),domActions.appendChild(this._domInsert),this._domCancelUpload=this.createDiv(["ct-control","ct-control--text","ct-control--cancel"]),this._domCancelUpload.textContent=ContentEdit._("Cancel"),domActions.appendChild(this._domCancelUpload),this._domClear=this.createDiv(["ct-control","ct-control--text","ct-control--clear"]),this._domClear.textContent=ContentEdit._("Clear"),domActions.appendChild(this._domClear),this._addDOMEventListeners(),this.trigger("imageUploader.mount")},ImageDialog.prototype.populate=function(imageURL,imageSize){return this._imageURL=imageURL,this._imageSize=imageSize,this._domImage||(this._domImage=this.createDiv(["ct-image-dialog__image"]),this._domView.appendChild(this._domImage)),this._domImage.style["background-image"]="url("+imageURL+")",this.state("populated")},ImageDialog.prototype.progress=function(progress){return void 0===progress?this._progress:(this._progress=progress,this.isMounted()?this._domProgress.style.width=""+this._progress+"%":void 0)},ImageDialog.prototype.removeCropmarks=function(){return this._cropmarks?(this._cropmarks.unmount(),this._cropmarks=null,ContentEdit.removeCSSClass(this._domCrop,"ct-control--active")):void 0},ImageDialog.prototype.save=function(imageURL,imageSize,imageAttrs){return this.trigger("save",imageURL,imageSize,imageAttrs)},ImageDialog.prototype.state=function(state){var prevState;if(void 0===state)return this._state;if(this._state!==state&&(prevState=this._state,this._state=state,this.isMounted()))return ContentEdit.addCSSClass(this._domElement,"ct-image-dialog--"+this._state),ContentEdit.removeCSSClass(this._domElement,"ct-image-dialog--"+prevState)},ImageDialog.prototype.unmount=function(){return ImageDialog.__super__.unmount.call(this),this._domCancelUpload=null,this._domClear=null,this._domCrop=null,this._domInput=null,this._domInsert=null,this._domProgress=null,this._domRotateCCW=null,this._domRotateCW=null,this._domUpload=null,this.trigger("imageUploader.unmount")},ImageDialog.prototype._addDOMEventListeners=function(){return ImageDialog.__super__._addDOMEventListeners.call(this),this._domInput.addEventListener("change",function(_this){return function(ev){var file;return file=ev.target.files[0],ev.target.value="",ev.target.value&&(ev.target.type="text",ev.target.type="file"),_this.trigger("imageUploader.fileReady",file)}}(this)),this._domCancelUpload.addEventListener("click",function(_this){return function(){return _this.trigger("imageUploader.cancelUpload")}}(this)),this._domClear.addEventListener("click",function(_this){return function(){return _this.removeCropmarks(),_this.trigger("imageUploader.clear")}}(this)),this._domRotateCCW.addEventListener("click",function(_this){return function(){return _this.removeCropmarks(),_this.trigger("imageUploader.rotateCCW")}}(this)),this._domRotateCW.addEventListener("click",function(_this){return function(){return _this.removeCropmarks(),_this.trigger("imageUploader.rotateCW")}}(this)),this._domCrop.addEventListener("click",function(_this){return function(){return _this._cropmarks?_this.removeCropmarks():_this.addCropmarks()}}(this)),this._domInsert.addEventListener("click",function(_this){return function(){return _this.trigger("imageUploader.save")}}(this))},ImageDialog}(ContentTools.DialogUI),CropmarksUI=function(_super){function CropmarksUI(imageSize){CropmarksUI.__super__.constructor.call(this),this._bounds=null,this._dragging=null,this._draggingOrigin=null,this._imageSize=imageSize}return __extends(CropmarksUI,_super),CropmarksUI.prototype.mount=function(domParent,before){return null==before&&(before=null),this._domElement=this.createDiv(["ct-cropmarks"]),this._domClipper=this.createDiv(["ct-cropmarks__clipper"]),this._domElement.appendChild(this._domClipper),this._domRulers=[this.createDiv(["ct-cropmarks__ruler","ct-cropmarks__ruler--top-left"]),this.createDiv(["ct-cropmarks__ruler","ct-cropmarks__ruler--bottom-right"])],this._domClipper.appendChild(this._domRulers[0]),this._domClipper.appendChild(this._domRulers[1]),this._domHandles=[this.createDiv(["ct-cropmarks__handle","ct-cropmarks__handle--top-left"]),this.createDiv(["ct-cropmarks__handle","ct-cropmarks__handle--bottom-right"])],this._domElement.appendChild(this._domHandles[0]),this._domElement.appendChild(this._domHandles[1]),CropmarksUI.__super__.mount.call(this,domParent,before),this._fit(domParent)},CropmarksUI.prototype.region=function(){return[parseFloat(this._domHandles[0].style.top)/this._bounds[1],parseFloat(this._domHandles[0].style.left)/this._bounds[0],parseFloat(this._domHandles[1].style.top)/this._bounds[1],parseFloat(this._domHandles[1].style.left)/this._bounds[0]]},CropmarksUI.prototype.unmount=function(){return CropmarksUI.__super__.unmount.call(this),this._domClipper=null,this._domHandles=null,this._domRulers=null},CropmarksUI.prototype._addDOMEventListeners=function(){return CropmarksUI.__super__._addDOMEventListeners.call(this),this._domHandles[0].addEventListener("mousedown",function(_this){return function(ev){return 0===ev.button?_this._startDrag(0,ev.clientY,ev.clientX):void 0}}(this)),this._domHandles[1].addEventListener("mousedown",function(_this){return function(ev){return 0===ev.button?_this._startDrag(1,ev.clientY,ev.clientX):void 0}}(this))},CropmarksUI.prototype._drag=function(top,left){var height,minCrop,offsetLeft,offsetTop,width;if(null!==this._dragging)return ContentSelect.Range.unselectAll(),offsetTop=top-this._draggingOrigin[1],offsetLeft=left-this._draggingOrigin[0],height=this._bounds[1],left=0,top=0,width=this._bounds[0],minCrop=Math.min(Math.min(ContentTools.MIN_CROP,height),width),0===this._dragging?(height=parseInt(this._domHandles[1].style.top)-minCrop,width=parseInt(this._domHandles[1].style.left)-minCrop):(left=parseInt(this._domHandles[0].style.left)+minCrop,top=parseInt(this._domHandles[0].style.top)+minCrop),offsetTop=Math.min(Math.max(top,offsetTop),height),offsetLeft=Math.min(Math.max(left,offsetLeft),width),this._domHandles[this._dragging].style.top=""+offsetTop+"px",this._domHandles[this._dragging].style.left=""+offsetLeft+"px",this._domRulers[this._dragging].style.top=""+offsetTop+"px",this._domRulers[this._dragging].style.left=""+offsetLeft+"px"},CropmarksUI.prototype._fit=function(domParent){var height,heightScale,left,ratio,rect,top,width,widthScale;return rect=domParent.getBoundingClientRect(),widthScale=rect.width/this._imageSize[0],heightScale=rect.height/this._imageSize[1],ratio=Math.min(widthScale,heightScale),width=ratio*this._imageSize[0],height=ratio*this._imageSize[1],left=(rect.width-width)/2,top=(rect.height-height)/2,this._domElement.style.width=""+width+"px",this._domElement.style.height=""+height+"px",this._domElement.style.top=""+top+"px",this._domElement.style.left=""+left+"px",this._domHandles[0].style.top="0px",this._domHandles[0].style.left="0px",this._domHandles[1].style.top=""+height+"px",this._domHandles[1].style.left=""+width+"px",this._domRulers[0].style.top="0px",this._domRulers[0].style.left="0px",this._domRulers[1].style.top=""+height+"px",this._domRulers[1].style.left=""+width+"px",this._bounds=[width,height]},CropmarksUI.prototype._startDrag=function(handleIndex,top,left){var domHandle;return domHandle=this._domHandles[handleIndex],this._dragging=handleIndex,this._draggingOrigin=[left-parseInt(domHandle.style.left),top-parseInt(domHandle.style.top)],this._onMouseMove=function(_this){return function(ev){return _this._drag(ev.clientY,ev.clientX)}}(this),document.addEventListener("mousemove",this._onMouseMove),this._onMouseUp=function(_this){return function(){return _this._stopDrag()}}(this),document.addEventListener("mouseup",this._onMouseUp)},CropmarksUI.prototype._stopDrag=function(){return document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._dragging=null,this._draggingOrigin=null},CropmarksUI}(ContentTools.AnchoredComponentUI),ContentTools.LinkDialog=function(_super){function LinkDialog(initialValue){null==initialValue&&(initialValue=""),LinkDialog.__super__.constructor.call(this),this._initialValue=initialValue}return __extends(LinkDialog,_super),LinkDialog.prototype.mount=function(){return LinkDialog.__super__.mount.call(this),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-anchored-dialog__input"),this._domInput.setAttribute("name","href"),this._domInput.setAttribute("placeholder",ContentEdit._("Enter a link")+"..."),this._domInput.setAttribute("type","text"),this._domInput.setAttribute("value",this._initialValue),this._domElement.appendChild(this._domInput),this._domButton=this.createDiv(["ct-anchored-dialog__button"]),this._domElement.appendChild(this._domButton),this._addDOMEventListeners()},LinkDialog.prototype.save=function(){return this.isMounted?this.trigger("save",this._domInput.value.trim()):this.trigger("save","")},LinkDialog.prototype.show=function(){return LinkDialog.__super__.show.call(this),this._domInput.focus(),this._initialValue?this._domInput.select():void 0},LinkDialog.prototype.unmount=function(){return this.isMounted()&&this._domInput.blur(),LinkDialog.__super__.unmount.call(this),this._domButton=null,this._domInput=null},LinkDialog.prototype._addDOMEventListeners=function(){return this._domInput.addEventListener("keypress",function(_this){return function(ev){return 13===ev.keyCode?_this.save():void 0}}(this)),this._domButton.addEventListener("click",function(_this){return function(ev){return ev.preventDefault(),_this.save()}}(this))},LinkDialog}(ContentTools.AnchoredDialogUI),ContentTools.PropertiesDialog=function(_super){function PropertiesDialog(element){var _ref;this.element=element,PropertiesDialog.__super__.constructor.call(this,"Properties"),this._attributeUIs=[],this._focusedAttributeUI=null,this._styleUIs=[],this._supportsCoding=element.content,("ListItem"===(_ref=element.constructor.name)||"TableCell"===_ref)&&(this._supportsCoding=!0)}return __extends(PropertiesDialog,_super),PropertiesDialog.prototype.caption=function(caption){return void 0===caption?this._caption:(this._caption=caption,this._domCaption.textContent=ContentEdit._(caption)+(": "+this.element.tagName()))},PropertiesDialog.prototype.changedAttributes=function(){var attributeUI,attributes,changedAttributes,name,restricted,value,_i,_len,_ref,_ref1;for(attributes={},changedAttributes={},_ref=this._attributeUIs,_i=0,_len=_ref.length;_len>_i;_i++)attributeUI=_ref[_i],name=attributeUI.name(),value=attributeUI.value(),""!==name&&(attributes[name.toLowerCase()]=!0,this.element.attr(name)!==value&&(changedAttributes[name]=value));restricted=ContentTools.RESTRICTED_ATTRIBUTES[this.element.tagName()],_ref1=this.element.attributes();for(name in _ref1)value=_ref1[name],restricted&&-1!==restricted.indexOf(name.toLowerCase())||void 0===attributes[name]&&(changedAttributes[name]=null);return changedAttributes},PropertiesDialog.prototype.changedStyles=function(){var cssClass,styleUI,styles,_i,_len,_ref;for(styles={},_ref=this._styleUIs,_i=0,_len=_ref.length;_len>_i;_i++)styleUI=_ref[_i],cssClass=styleUI.style.cssClass(),this.element.hasCSSClass(cssClass)!==styleUI.applied()&&(styles[cssClass]=styleUI.applied());return styles},PropertiesDialog.prototype.getElementInnerHTML=function(){return this._supportsCoding?this.element.content?this.element.content.html():this.element.children[0].content.html():null},PropertiesDialog.prototype.mount=function(){var attributeNames,attributes,domActions,domTabs,lastTab,name,restricted,style,styleUI,value,_i,_j,_len,_len1,_ref;for(PropertiesDialog.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog"),ContentEdit.addCSSClass(this._domView,"ct-properties-dialog__view"),this._domStyles=this.createDiv(["ct-properties-dialog__styles"]),this._domStyles.setAttribute("data-ct-empty",ContentEdit._("No styles available for this tag")),this._domView.appendChild(this._domStyles),_ref=ContentTools.StylePalette.styles(this.element.tagName()),_i=0,_len=_ref.length;_len>_i;_i++)style=_ref[_i],styleUI=new StyleUI(style,this.element.hasCSSClass(style.cssClass())),this._styleUIs.push(styleUI),styleUI.mount(this._domStyles);this._domAttributes=this.createDiv(["ct-properties-dialog__attributes"]),this._domView.appendChild(this._domAttributes),restricted=ContentTools.RESTRICTED_ATTRIBUTES[this.element.tagName()],attributes=this.element.attributes(),attributeNames=[];for(name in attributes)value=attributes[name],restricted&&-1!==restricted.indexOf(name.toLowerCase())||attributeNames.push(name);for(attributeNames.sort(),_j=0,_len1=attributeNames.length;_len1>_j;_j++)name=attributeNames[_j],value=attributes[name],this._addAttributeUI(name,value);return this._addAttributeUI("",""),this._domCode=this.createDiv(["ct-properties-dialog__code"]),this._domView.appendChild(this._domCode),this._domInnerHTML=document.createElement("textarea"),this._domInnerHTML.setAttribute("class","ct-properties-dialog__inner-html"),this._domInnerHTML.setAttribute("name","code"),this._domInnerHTML.value=this.getElementInnerHTML(),this._domCode.appendChild(this._domInnerHTML),domTabs=this.createDiv(["ct-control-group","ct-control-group--left"]),this._domControls.appendChild(domTabs),this._domStylesTab=this.createDiv(["ct-control","ct-control--icon","ct-control--styles"]),this._domStylesTab.setAttribute("data-tooltip",ContentEdit._("Styles")),domTabs.appendChild(this._domStylesTab),this._domAttributesTab=this.createDiv(["ct-control","ct-control--icon","ct-control--attributes"]),this._domAttributesTab.setAttribute("data-tooltip",ContentEdit._("Attributes")),domTabs.appendChild(this._domAttributesTab),this._domCodeTab=this.createDiv(["ct-control","ct-control--icon","ct-control--code"]),this._domCodeTab.setAttribute("data-tooltip",ContentEdit._("Code")),domTabs.appendChild(this._domCodeTab),this._supportsCoding||ContentEdit.addCSSClass(this._domCodeTab,"ct-control--muted"),this._domRemoveAttribute=this.createDiv(["ct-control","ct-control--icon","ct-control--remove","ct-control--muted"]),this._domRemoveAttribute.setAttribute("data-tooltip",ContentEdit._("Remove")),domTabs.appendChild(this._domRemoveAttribute),domActions=this.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(domActions),this._domApply=this.createDiv(["ct-control","ct-control--text","ct-control--apply"]),this._domApply.textContent=ContentEdit._("Apply"),domActions.appendChild(this._domApply),lastTab=window.localStorage.getItem("ct-properties-dialog-tab"),"attributes"===lastTab?(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--attributes"),ContentEdit.addCSSClass(this._domAttributesTab,"ct-control--active")):"code"===lastTab&&this._supportsCoding?(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--code"),ContentEdit.addCSSClass(this._domCodeTab,"ct-control--active")):(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--styles"),ContentEdit.addCSSClass(this._domStylesTab,"ct-control--active")),this._addDOMEventListeners()},PropertiesDialog.prototype.save=function(){var innerHTML;return innerHTML=null,this._supportsCoding&&(innerHTML=this._domInnerHTML.value),this.trigger("save",this.changedAttributes(),this.changedStyles(),innerHTML)},PropertiesDialog.prototype._addAttributeUI=function(name,value){var attributeUI,dialog;return dialog=this,attributeUI=new AttributeUI(name,value),this._attributeUIs.push(attributeUI),attributeUI.bind("blur",function(){var index,lastAttributeUI,length;return dialog._focusedAttributeUI=null,ContentEdit.addCSSClass(dialog._domRemoveAttribute,"ct-control--muted"),index=dialog._attributeUIs.indexOf(this),length=dialog._attributeUIs.length,""===this.name()&&length-1>index&&(this.unmount(),dialog._attributeUIs.splice(index,1)),lastAttributeUI=dialog._attributeUIs[length-1],lastAttributeUI&&lastAttributeUI.name()&&lastAttributeUI.value()?dialog._addAttributeUI("",""):void 0}),attributeUI.bind("focus",function(){return dialog._focusedAttributeUI=this,ContentEdit.removeCSSClass(dialog._domRemoveAttribute,"ct-control--muted")}),attributeUI.bind("namechange",function(){var element,otherAttributeUI,restricted,valid,_i,_len,_ref;for(element=dialog.element,name=this.name().toLowerCase(),restricted=ContentTools.RESTRICTED_ATTRIBUTES[element.tagName()],valid=!0,restricted&&-1!==restricted.indexOf(name)&&(valid=!1),_ref=dialog._attributeUIs,_i=0,_len=_ref.length;_len>_i;_i++)otherAttributeUI=_ref[_i],""!==name&&otherAttributeUI!==this&&otherAttributeUI.name().toLowerCase()===name&&(valid=!1);return this.valid(valid),valid?ContentEdit.removeCSSClass(dialog._domApply,"ct-control--muted"):ContentEdit.addCSSClass(dialog._domApply,"ct-control--muted")}),attributeUI.mount(this._domAttributes),attributeUI},PropertiesDialog.prototype._addDOMEventListeners=function(){var selectTab,validateCode;return PropertiesDialog.__super__._addDOMEventListeners.call(this),selectTab=function(_this){return function(selected){var selectedCap,tab,tabCap,tabs,_i,_len;for(tabs=["attributes","code","styles"],_i=0,_len=tabs.length;_len>_i;_i++)tab=tabs[_i],tab!==selected&&(tabCap=tab.charAt(0).toUpperCase()+tab.slice(1),ContentEdit.removeCSSClass(_this._domElement,"ct-properties-dialog--"+tab),ContentEdit.removeCSSClass(_this["_dom"+tabCap+"Tab"],"ct-control--active"));return selectedCap=selected.charAt(0).toUpperCase()+selected.slice(1),ContentEdit.addCSSClass(_this._domElement,"ct-properties-dialog--"+selected),ContentEdit.addCSSClass(_this["_dom"+selectedCap+"Tab"],"ct-control--active"),window.localStorage.setItem("ct-properties-dialog-tab",selected)}}(this),this._domStylesTab.addEventListener("mousedown",function(){return function(){return selectTab("styles")}}(this)),this._domAttributesTab.addEventListener("mousedown",function(){return function(){return selectTab("attributes")}}(this)),this._domCodeTab.addEventListener("mousedown",function(){return function(){return selectTab("code")}}(this)),this._domRemoveAttribute.addEventListener("mousedown",function(_this){return function(ev){var index,last;return ev.preventDefault(),_this._focusedAttributeUI&&(index=_this._attributeUIs.indexOf(_this._focusedAttributeUI),last=index===_this._attributeUIs.length-1,_this._focusedAttributeUI.unmount(),_this._attributeUIs.splice(index,1),last)?_this._addAttributeUI("",""):void 0}}(this)),validateCode=function(_this){return function(){var content;try{return content=new HTMLString.String(_this._domInnerHTML.value),ContentEdit.removeCSSClass(_this._domInnerHTML,"ct-properties-dialog__inner-html--invalid"),ContentEdit.removeCSSClass(_this._domApply,"ct-control--muted")}catch(_error){return ContentEdit.addCSSClass(_this._domInnerHTML,"ct-properties-dialog__inner-html--invalid"),ContentEdit.addCSSClass(_this._domApply,"ct-control--muted")}}}(this),this._domInnerHTML.addEventListener("input",validateCode),this._domInnerHTML.addEventListener("propertychange",validateCode),this._domApply.addEventListener("click",function(_this){return function(ev){var cssClass;return ev.preventDefault(),cssClass=_this._domApply.getAttribute("class"),-1===cssClass.indexOf("ct-control--muted")?_this.save():void 0}}(this))},PropertiesDialog}(ContentTools.DialogUI),StyleUI=function(_super){function StyleUI(style,applied){this.style=style,StyleUI.__super__.constructor.call(this),this._applied=applied}return __extends(StyleUI,_super),StyleUI.prototype.applied=function(applied){if(void 0===applied)return this._applied;if(this._applied!==applied)return this._applied=applied,this._applied?ContentEdit.addCSSClass(this._domElement,"ct-section--applied"):ContentEdit.removeCSSClass(this._domElement,"ct-section--applied")},StyleUI.prototype.mount=function(domParent,before){var label;return null==before&&(before=null),this._domElement=this.createDiv(["ct-section"]),this._applied&&ContentEdit.addCSSClass(this._domElement,"ct-section--applied"),label=this.createDiv(["ct-section__label"]),label.textContent=this.style.name(),this._domElement.appendChild(label),this._domElement.appendChild(this.createDiv(["ct-section__switch"])),StyleUI.__super__.mount.call(this,domParent,before)},StyleUI.prototype._addDOMEventListeners=function(){var toggleSection;return toggleSection=function(_this){return function(ev){return ev.preventDefault(),_this.applied(_this.applied()?!1:!0)}}(this),this._domElement.addEventListener("click",toggleSection)},StyleUI}(ContentTools.AnchoredComponentUI),AttributeUI=function(_super){function AttributeUI(name,value){AttributeUI.__super__.constructor.call(this),this._initialName=name,this._initialValue=value}return __extends(AttributeUI,_super),AttributeUI.prototype.name=function(){return this._domName.value.trim()},AttributeUI.prototype.value=function(){return this._domValue.value.trim()},AttributeUI.prototype.mount=function(domParent,before){return null==before&&(before=null),this._domElement=this.createDiv(["ct-attribute"]),this._domName=document.createElement("input"),this._domName.setAttribute("class","ct-attribute__name"),this._domName.setAttribute("name","name"),this._domName.setAttribute("placeholder",ContentEdit._("Name")),this._domName.setAttribute("type","text"),this._domName.setAttribute("value",this._initialName),this._domElement.appendChild(this._domName),this._domValue=document.createElement("input"),this._domValue.setAttribute("class","ct-attribute__value"),this._domValue.setAttribute("name","value"),this._domValue.setAttribute("placeholder",ContentEdit._("Value")),this._domValue.setAttribute("type","text"),this._domValue.setAttribute("value",this._initialValue),this._domElement.appendChild(this._domValue),AttributeUI.__super__.mount.call(this,domParent,before)},AttributeUI.prototype.valid=function(valid){return valid?ContentEdit.removeCSSClass(this._domName,"ct-attribute__name--invalid"):ContentEdit.addCSSClass(this._domName,"ct-attribute__name--invalid")},AttributeUI.prototype._addDOMEventListeners=function(){return this._domName.addEventListener("blur",function(_this){return function(){var name,nextDomAttribute,nextNameDom;return name=_this.name(),nextDomAttribute=_this._domElement.nextSibling,_this.trigger("blur"),""===name&&nextDomAttribute?(nextNameDom=nextDomAttribute.querySelector(".ct-attribute__name"),nextNameDom.focus()):void 0}}(this)),this._domName.addEventListener("focus",function(_this){return function(){return _this.trigger("focus")}}(this)),this._domName.addEventListener("input",function(_this){return function(){return _this.trigger("namechange")}}(this)),this._domName.addEventListener("keydown",function(_this){return function(ev){return 13===ev.keyCode?_this._domValue.focus():void 0}}(this)),this._domValue.addEventListener("blur",function(_this){return function(){return _this.trigger("blur")}}(this)),this._domValue.addEventListener("focus",function(_this){return function(){return _this.trigger("focus")}}(this)),this._domValue.addEventListener("keydown",function(_this){return function(ev){var nextDomAttribute,nextNameDom;if(13===ev.keyCode||9===ev.keyCode&&!ev.shiftKey)return ev.preventDefault(),nextDomAttribute=_this._domElement.nextSibling,nextDomAttribute||(_this._domValue.blur(),nextDomAttribute=_this._domElement.nextSibling),nextDomAttribute?(nextNameDom=nextDomAttribute.querySelector(".ct-attribute__name"),nextNameDom.focus()):void 0}}(this))},AttributeUI}(ContentTools.AnchoredComponentUI),ContentTools.TableDialog=function(_super){function TableDialog(table){this.table=table,this.table?TableDialog.__super__.constructor.call(this,"Update table"):TableDialog.__super__.constructor.call(this,"Insert table")}return __extends(TableDialog,_super),TableDialog.prototype.mount=function(){var cfg,domBodyLabel,domControlGroup,domFootLabel,domHeadLabel,footCSSClasses,headCSSClasses;return TableDialog.__super__.mount.call(this),cfg={columns:3,foot:!1,head:!0},this.table&&(cfg={columns:this.table.firstSection().children[0].children.length,foot:this.table.tfoot(),head:this.table.thead()}),ContentEdit.addCSSClass(this._domElement,"ct-table-dialog"),ContentEdit.addCSSClass(this._domView,"ct-table-dialog__view"),headCSSClasses=["ct-section"],cfg.head&&headCSSClasses.push("ct-section--applied"),this._domHeadSection=this.createDiv(headCSSClasses),this._domView.appendChild(this._domHeadSection),domHeadLabel=this.createDiv(["ct-section__label"]),domHeadLabel.textContent=ContentEdit._("Table head"),this._domHeadSection.appendChild(domHeadLabel),this._domHeadSwitch=this.createDiv(["ct-section__switch"]),this._domHeadSection.appendChild(this._domHeadSwitch),this._domBodySection=this.createDiv(["ct-section","ct-section--applied","ct-section--contains-input"]),this._domView.appendChild(this._domBodySection),domBodyLabel=this.createDiv(["ct-section__label"]),domBodyLabel.textContent=ContentEdit._("Table body (columns)"),this._domBodySection.appendChild(domBodyLabel),this._domBodyInput=document.createElement("input"),this._domBodyInput.setAttribute("class","ct-section__input"),this._domBodyInput.setAttribute("maxlength","2"),this._domBodyInput.setAttribute("name","columns"),this._domBodyInput.setAttribute("type","text"),this._domBodyInput.setAttribute("value",cfg.columns),this._domBodySection.appendChild(this._domBodyInput),footCSSClasses=["ct-section"],cfg.foot&&footCSSClasses.push("ct-section--applied"),this._domFootSection=this.createDiv(footCSSClasses),this._domView.appendChild(this._domFootSection),domFootLabel=this.createDiv(["ct-section__label"]),domFootLabel.textContent=ContentEdit._("Table foot"),this._domFootSection.appendChild(domFootLabel),this._domFootSwitch=this.createDiv(["ct-section__switch"]),this._domFootSection.appendChild(this._domFootSwitch),domControlGroup=this.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(domControlGroup),this._domApply=this.createDiv(["ct-control","ct-control--text","ct-control--apply"]),this._domApply.textContent="Apply",domControlGroup.appendChild(this._domApply),this._addDOMEventListeners()},TableDialog.prototype.save=function(){var footCSSClass,headCSSClass,tableCfg;return footCSSClass=this._domFootSection.getAttribute("class"),headCSSClass=this._domHeadSection.getAttribute("class"),tableCfg={columns:parseInt(this._domBodyInput.value),foot:footCSSClass.indexOf("ct-section--applied")>-1,head:headCSSClass.indexOf("ct-section--applied")>-1},this.trigger("save",tableCfg)},TableDialog.prototype.unmount=function(){return TableDialog.__super__.unmount.call(this),this._domBodyInput=null,this._domBodySection=null,this._domApply=null,this._domHeadSection=null,this._domHeadSwitch=null,this._domFootSection=null,this._domFootSwitch=null},TableDialog.prototype._addDOMEventListeners=function(){var toggleSection;return TableDialog.__super__._addDOMEventListeners.call(this),toggleSection=function(ev){return ev.preventDefault(),this.getAttribute("class").indexOf("ct-section--applied")>-1?ContentEdit.removeCSSClass(this,"ct-section--applied"):ContentEdit.addCSSClass(this,"ct-section--applied")},this._domHeadSection.addEventListener("click",toggleSection),this._domFootSection.addEventListener("click",toggleSection),this._domBodySection.addEventListener("click",function(_this){return function(){return _this._domBodyInput.focus()}}(this)),this._domBodyInput.addEventListener("input",function(_this){return function(ev){var valid;return valid=/^[1-9]\d{0,1}$/.test(ev.target.value),valid?(ContentEdit.removeCSSClass(_this._domBodyInput,"ct-section__input--invalid"),ContentEdit.removeCSSClass(_this._domApply,"ct-control--muted")):(ContentEdit.addCSSClass(_this._domBodyInput,"ct-section__input--invalid"),ContentEdit.addCSSClass(_this._domApply,"ct-control--muted"))}}(this)),this._domApply.addEventListener("click",function(_this){return function(ev){var cssClass;return ev.preventDefault(),cssClass=_this._domApply.getAttribute("class"),-1===cssClass.indexOf("ct-control--muted")?_this.save():void 0}}(this))},TableDialog}(ContentTools.DialogUI),ContentTools.VideoDialog=function(_super){function VideoDialog(){VideoDialog.__super__.constructor.call(this,"Insert video")}return __extends(VideoDialog,_super),VideoDialog.prototype.clearPreview=function(){return this._domPreview?(this._domPreview.parentNode.removeChild(this._domPreview),this._domPreview=void 0):void 0},VideoDialog.prototype.mount=function(){var domControlGroup;return VideoDialog.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-video-dialog"),ContentEdit.addCSSClass(this._domView,"ct-video-dialog__preview"),domControlGroup=this.createDiv(["ct-control-group"]),this._domControls.appendChild(domControlGroup),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-video-dialog__input"),this._domInput.setAttribute("name","url"),this._domInput.setAttribute("placeholder",ContentEdit._("Paste YouTube or Vimeo URL")+"..."),this._domInput.setAttribute("type","text"),domControlGroup.appendChild(this._domInput),this._domButton=this.createDiv(["ct-control","ct-control--text","ct-control--insert","ct-control--muted"]),this._domButton.textContent=ContentEdit._("Insert"),domControlGroup.appendChild(this._domButton),this._addDOMEventListeners()},VideoDialog.prototype.preview=function(url){return this.clearPreview(),this._domPreview=document.createElement("iframe"),this._domPreview.setAttribute("frameborder","0"),this._domPreview.setAttribute("height","100%"),this._domPreview.setAttribute("src",url),this._domPreview.setAttribute("width","100%"),this._domView.appendChild(this._domPreview)
7 | },VideoDialog.prototype.save=function(){var embedURL,videoURL;return videoURL=this._domInput.value.trim(),embedURL=ContentTools.getEmbedVideoURL(videoURL),embedURL?this.trigger("save",embedURL):this.trigger("save",videoURL)},VideoDialog.prototype.show=function(){return VideoDialog.__super__.show.call(this),this._domInput.focus()},VideoDialog.prototype.unmount=function(){return this.isMounted()&&this._domInput.blur(),VideoDialog.__super__.unmount.call(this),this._domButton=null,this._domInput=null,this._domPreview=null},VideoDialog.prototype._addDOMEventListeners=function(){return VideoDialog.__super__._addDOMEventListeners.call(this),this._domInput.addEventListener("input",function(_this){return function(ev){var updatePreview;return ev.target.value?ContentEdit.removeCSSClass(_this._domButton,"ct-control--muted"):ContentEdit.addCSSClass(_this._domButton,"ct-control--muted"),_this._updatePreviewTimeout&&clearTimeout(_this._updatePreviewTimeout),updatePreview=function(){var embedURL,videoURL;return videoURL=_this._domInput.value.trim(),embedURL=ContentTools.getEmbedVideoURL(videoURL),embedURL?_this.preview(embedURL):_this.clearPreview()},_this._updatePreviewTimeout=setTimeout(updatePreview,500)}}(this)),this._domInput.addEventListener("keypress",function(_this){return function(ev){return 13===ev.keyCode?_this.save():void 0}}(this)),this._domButton.addEventListener("click",function(_this){return function(ev){var cssClass;return ev.preventDefault(),cssClass=_this._domButton.getAttribute("class"),-1===cssClass.indexOf("ct-control--muted")?_this.save():void 0}}(this))},VideoDialog}(ContentTools.DialogUI),_EditorApp=function(_super){function _EditorApp(){_EditorApp.__super__.constructor.call(this),this.history=null,this._state=ContentTools.EditorApp.DORMANT,this._regions=null,this._orderedRegions=null,this._ignition=null,this._inspector=null,this._toolbox=null}return __extends(_EditorApp,_super),_EditorApp.prototype.ctrlDown=function(){return this._ctrlDown},_EditorApp.prototype.domRegions=function(){return this._domRegions},_EditorApp.prototype.orderedRegions=function(){var name;return function(){var _i,_len,_ref,_results;for(_ref=this._orderedRegions,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)name=_ref[_i],_results.push(this._regions[name]);return _results}.call(this)},_EditorApp.prototype.regions=function(){return this._regions},_EditorApp.prototype.shiftDown=function(){return this._shiftDown},_EditorApp.prototype.busy=function(busy){return this._ignition.busy(busy)},_EditorApp.prototype.init=function(query,namingProp){return null==namingProp&&(namingProp="id"),this._namingProp=namingProp,this._domRegions=document.querySelectorAll(query),0!==this._domRegions.length?(this.mount(),this._ignition=new ContentTools.IgnitionUI,this.attach(this._ignition),this._ignition.bind("start",function(_this){return function(){return _this.start()}}(this)),this._ignition.bind("stop",function(_this){return function(save){if(save)_this.save();else if(!_this.revert())return void _this._ignition.changeState("editing");return _this.stop()}}(this)),this._domRegions.length&&this._ignition.show(),this._toolbox=new ContentTools.ToolboxUI(ContentTools.DEFAULT_TOOLS),this.attach(this._toolbox),this._inspector=new ContentTools.InspectorUI,this.attach(this._inspector),this._state=ContentTools.EditorApp.READY,ContentEdit.Root.get().bind("detach",function(_this){return function(){return _this._preventEmptyRegions()}}(this)),ContentEdit.Root.get().bind("paste",function(_this){return function(element,ev){return _this.paste(element,ev.clipboardData)}}(this)),ContentEdit.Root.get().bind("next-region",function(_this){return function(region){var child,element,index,regions,_i,_len,_ref;if(regions=_this.orderedRegions(),index=regions.indexOf(region),!(index>=regions.length-1)){for(region=regions[index+1],element=null,_ref=region.descendants(),_i=0,_len=_ref.length;_len>_i;_i++)if(child=_ref[_i],void 0!==child.content){element=child;break}return element?(element.focus(),void element.selection(new ContentSelect.Range(0,0))):ContentEdit.Root.get().trigger("next-region",region)}}}(this)),ContentEdit.Root.get().bind("previous-region",function(_this){return function(region){var child,descendants,element,index,length,regions,_i,_len;if(regions=_this.orderedRegions(),index=regions.indexOf(region),!(0>=index)){for(region=regions[index-1],element=null,descendants=region.descendants(),descendants.reverse(),_i=0,_len=descendants.length;_len>_i;_i++)if(child=descendants[_i],void 0!==child.content){element=child;break}return element?(length=element.content.length(),element.focus(),void element.selection(new ContentSelect.Range(length,length))):ContentEdit.Root.get().trigger("previous-region",region)}}}(this))):void 0},_EditorApp.prototype.destroy=function(){return this.unmount()},_EditorApp.prototype.highlightRegions=function(highlight){var domRegion,_i,_len,_ref,_results;for(_ref=this._domRegions,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)domRegion=_ref[_i],_results.push(highlight?ContentEdit.addCSSClass(domRegion,"ct--highlight"):ContentEdit.removeCSSClass(domRegion,"ct--highlight"));return _results},_EditorApp.prototype.mount=function(){return this._domElement=this.createDiv(["ct-app"]),document.body.insertBefore(this._domElement,null),this._addDOMEventListeners()},_EditorApp.prototype.paste=function(element,clipboardData){var className,content,cursor,encodeHTML,i,insertAt,insertIn,insertNode,item,itemText,lastItem,line,lineLength,lines,selection,tail,tip,_i,_len;if(content=clipboardData.getData("text/plain"),lines=content.split("\n"),lines=lines.filter(function(line){return""!==line.trim()})){if(encodeHTML=HTMLString.String.encode,className=element.constructor.name,(lines.length>1||!element.content)&&"PreText"!==className){for("ListItemText"===className?(insertNode=element.parent(),insertIn=element.parent().parent(),insertAt=insertIn.children.indexOf(insertNode)+1):(insertNode=element,"Region"!==insertNode.parent().constructor.name&&(insertNode=element.closest(function(node){return"Region"===node.parent().constructor.name})),insertIn=insertNode.parent(),insertAt=insertIn.children.indexOf(insertNode)+1),i=_i=0,_len=lines.length;_len>_i;i=++_i)line=lines[i],line=encodeHTML(line),"ListItemText"===className?(item=new ContentEdit.ListItem,itemText=new ContentEdit.ListItemText(line),item.attach(itemText),lastItem=itemText):(item=new ContentEdit.Text("p",{},line),lastItem=item),insertIn.attach(item,insertAt+i);return lineLength=lastItem.content.length(),lastItem.focus(),lastItem.selection(new ContentSelect.Range(lineLength,lineLength))}return content=encodeHTML(content),content=new HTMLString.String(content,"PreText"===className),selection=element.selection(),cursor=selection.get()[0]+content.length(),tip=element.content.substring(0,selection.get()[0]),tail=element.content.substring(selection.get()[1]),element.content=tip.concat(content),element.content=element.content.concat(tail,!1),element.updateInnerHTML(),element.taint(),selection.set(cursor,cursor),element.selection(selection)}},_EditorApp.prototype.unmount=function(){return this._domElement.parentNode.removeChild(this._domElement),this._domElement=null,this._removeDOMEventListeners(),this._ignition=null,this._inspector=null,this._toolbox=null},_EditorApp.prototype.revert=function(){return ContentEdit.Root.get().lastModified()&&!window.confirm(ContentEdit._("Your changes have not been saved, do you really want to lose them?"))?!1:(this.revertToSnapshot(this.history.goTo(0),!1),!0)},_EditorApp.prototype.revertToSnapshot=function(snapshot,restoreEditable){var domRegion,i,name,region,_i,_len,_ref,_ref1;null==restoreEditable&&(restoreEditable=!0),_ref=this._regions;for(name in _ref)region=_ref[name],region.domElement().innerHTML=snapshot.regions[name];if(restoreEditable){for(this._regions={},_ref1=this._domRegions,i=_i=0,_len=_ref1.length;_len>_i;i=++_i)domRegion=_ref1[i],name=domRegion.getAttribute(this._namingProp),name||(name=i),this._regions[name]=new ContentEdit.Region(domRegion);return this.history.replaceRegions(this._regions),this.history.restoreSelection(snapshot)}},_EditorApp.prototype.save=function(){var args,child,html,modifiedRegions,name,passive,region,_ref;if(passive=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[],ContentEdit.Root.get().lastModified()||!passive){modifiedRegions={},_ref=this._regions;for(name in _ref)region=_ref[name],html=region.html(),1===region.children.length&&(child=region.children[0],child.content&&!child.content.html()&&(html="")),modifiedRegions[name]=html,passive||(region.domElement().innerHTML=modifiedRegions[name]);return this.trigger.apply(this,["save",modifiedRegions].concat(__slice.call(args)))}},_EditorApp.prototype.setRegionOrder=function(regionNames){return this._orderedRegions=regionNames.slice()},_EditorApp.prototype.start=function(){var domRegion,i,name,_i,_len,_ref;for(this.busy(!0),this._regions={},this._orderedRegions=[],_ref=this._domRegions,i=_i=0,_len=_ref.length;_len>_i;i=++_i)domRegion=_ref[i],name=domRegion.getAttribute(this._namingProp),name||(name=i),this._regions[name]=new ContentEdit.Region(domRegion),this._orderedRegions.push(name);return this._preventEmptyRegions(),this.history=new ContentTools.History(this._regions),this.history.watch(),this._state=ContentTools.EditorApp.EDITING,ContentEdit.Root.get().commit(),this._toolbox.show(),this._inspector.show(),this.busy(!1)},_EditorApp.prototype.stop=function(){return ContentEdit.Root.get().focused()&&ContentEdit.Root.get().focused().blur(),this.history.stopWatching(),this.history=null,this._toolbox.hide(),this._inspector.hide(),this._regions={},this._state=ContentTools.EditorApp.READY},_EditorApp.prototype._addDOMEventListeners=function(){return this._handleHighlightOn=function(_this){return function(ev){var _ref;return clearTimeout(_this._highlightTimeout),17===(_ref=ev.keyCode)||224===_ref?void(_this._ctrlDown=!0):16===ev.keyCode?(_this._shiftDown=!0,_this._highlightTimeout=setTimeout(function(){return _this.highlightRegions(!0)},ContentTools.HIGHLIGHT_HOLD_DURATION)):void 0}}(this),this._handleHighlightOff=function(_this){return function(ev){var _ref;return 17===(_ref=ev.keyCode)||224===_ref?void(_this._ctrlDown=!1):16===ev.keyCode?(_this._shiftDown=!1,_this._highlightTimeout&&clearTimeout(_this._highlightTimeout),_this.highlightRegions(!1)):void 0}}(this),document.addEventListener("keydown",this._handleHighlightOn),document.addEventListener("keyup",this._handleHighlightOff),window.onbeforeunload=function(_this){return function(){return _this._state===ContentTools.EditorApp.EDITING?ContentEdit._("Your changes have not been saved, do you really want to lose them?"):void 0}}(this),window.addEventListener("unload",function(_this){return function(){return _this.destroy()}}(this))},_EditorApp.prototype._preventEmptyRegions=function(){var name,placeholder,region,_ref,_results;_ref=this._regions,_results=[];for(name in _ref)region=_ref[name],region.children.length>0||(placeholder=new ContentEdit.Text("p",{},""),_results.push(region.attach(placeholder)));return _results},_EditorApp.prototype._removeDOMEventListeners=function(){return document.removeEventListener("keydown",this._handleHighlightOn),document.removeEventListener("keyup",this._handleHighlightOff)},_EditorApp}(ContentTools.ComponentUI),ContentTools.EditorApp=function(){function EditorApp(){}var instance;return EditorApp.DORMANT="dormant",EditorApp.READY="ready",EditorApp.EDITING="editing",instance=null,EditorApp.get=function(){var cls;return cls=ContentTools.EditorApp.getCls(),null!=instance?instance:instance=new cls},EditorApp.getCls=function(){return _EditorApp},EditorApp}(),ContentTools.History=function(){function History(regions){this._lastSnapshotTaken=null,this._regions={},this.replaceRegions(regions),this._snapshotIndex=-1,this._snapshots=[],this._store()}return History.prototype.canRedo=function(){return this._snapshotIndex0},History.prototype.length=function(){return this._snapshots.length},History.prototype.snapshot=function(){return this._snapshots[this._snapshotIndex]},History.prototype.goTo=function(index){return this._snapshotIndex=Math.min(this._snapshots.length-1,Math.max(0,index)),this.snapshot()},History.prototype.redo=function(){return this.goTo(this._snapshotIndex+1)},History.prototype.replaceRegions=function(regions){var k,v,_results;this._regions={},_results=[];for(k in regions)v=regions[k],_results.push(this._regions[k]=v);return _results},History.prototype.restoreSelection=function(snapshot){var element,region;if(snapshot.selected)return region=this._regions[snapshot.selected.region],element=region.descendants()[snapshot.selected.element],element.focus(),element.selection&&snapshot.selected.selection?element.selection(snapshot.selected.selection):void 0},History.prototype.stopWatching=function(){return this._watchInterval&&clearInterval(this._watchInterval),this._delayedStoreTimeout?clearTimeout(this._delayedStoreTimeout):void 0},History.prototype.undo=function(){return this.goTo(this._snapshotIndex-1)},History.prototype.watch=function(){var watch;return this._lastSnapshotTaken=Date.now(),watch=function(_this){return function(){var delayedStore,lastModified;if(lastModified=ContentEdit.Root.get().lastModified(),null!==lastModified&&lastModified>_this._lastSnapshotTaken){if(_this._delayedStoreRequested===lastModified)return;return _this._delayedStoreTimeout&&clearTimeout(_this._delayedStoreTimeout),delayedStore=function(){return _this._lastSnapshotTaken=lastModified,_this._store()},_this._delayedStoreRequested=lastModified,_this._delayedStoreTimeout=setTimeout(delayedStore,500)}}}(this),this._watchInterval=setInterval(watch,50)},History.prototype._store=function(){var element,name,other_region,region,snapshot,_ref,_ref1;snapshot={regions:{},selected:null},_ref=this._regions;for(name in _ref)region=_ref[name],snapshot.regions[name]=region.html();if(element=ContentEdit.Root.get().focused()){snapshot.selected={},region=element.closest(function(node){return"Region"===node.constructor.name}),_ref1=this._regions;for(name in _ref1)if(other_region=_ref1[name],region===other_region){snapshot.selected.region=name;break}snapshot.selected.element=region.descendants().indexOf(element),element.selection&&(snapshot.selected.selection=element.selection())}return this._snapshotIndex_i;_i++)if(c=_ref1[_i],c.hasTags("a"))for(_ref2=c.tags(),_j=0,_len1=_ref2.length;_len1>_j;_j++)if(tag=_ref2[_j],"a"===tag.name())return tag.attr("href");return""},Link.canApply=function(element,selection){return"Image"===element.constructor.name?!0:Link.__super__.constructor.canApply.call(this,element,selection)},Link.isApplied=function(element,selection){return"Image"===element.constructor.name?element.a:Link.__super__.constructor.isApplied.call(this,element,selection)},Link.apply=function(element,selection,callback){var allowScrolling,app,applied,dialog,domElement,from,measureSpan,modal,rect,selectTag,to,transparent,_ref;return applied=!1,"Image"===element.constructor.name?rect=element.domElement().getBoundingClientRect():(element.storeState(),selectTag=new HTMLString.Tag("span",{"class":"ct--puesdo-select"}),_ref=selection.get(),from=_ref[0],to=_ref[1],element.content=element.content.format(from,to,selectTag),element.updateInnerHTML(),domElement=element.domElement(),measureSpan=domElement.getElementsByClassName("ct--puesdo-select"),rect=measureSpan[0].getBoundingClientRect()),app=ContentTools.EditorApp.get(),modal=new ContentTools.ModalUI(transparent=!0,allowScrolling=!0),modal.bind("click",function(){return this.unmount(),dialog.hide(),element.content&&(element.content=element.content.unformat(from,to,selectTag),element.updateInnerHTML(),element.restoreState()),callback(applied)}),dialog=new ContentTools.LinkDialog(this.getHref(element,selection)),dialog.position([rect.left+rect.width/2+window.scrollX,rect.top+rect.height/2+window.scrollY]),dialog.bind("save",function(href){var a;return dialog.unbind("save"),applied=!0,"Image"===element.constructor.name?element.a=href?{href:href}:null:(element.content=element.content.unformat(from,to,"a"),href&&(a=new HTMLString.Tag("a",{href:href}),element.content=element.content.format(from,to,a)),element.updateInnerHTML(),element.taint()),modal.trigger("click")}),app.attach(modal),app.attach(dialog),modal.show(),dialog.show()},Link}(ContentTools.Tools.Bold),ContentTools.Tools.Heading=function(_super){function Heading(){return Heading.__super__.constructor.apply(this,arguments)}return __extends(Heading,_super),ContentTools.ToolShelf.stow(Heading,"heading"),Heading.label="Heading",Heading.icon="heading",Heading.tagName="h1",Heading.canApply=function(element){return void 0!==element.content&&"Region"===element.parent().constructor.name},Heading.apply=function(element,selection,callback){var content,insertAt,parent,textElement;return element.storeState(),"PreText"===element.constructor.name?(content=element.content.html().replace(/ /g," "),textElement=new ContentEdit.Text(this.tagName,{},content),parent=element.parent(),insertAt=parent.children.indexOf(element),parent.detach(element),parent.attach(textElement,insertAt),element.blur(),textElement.focus(),textElement.selection(selection)):(element.tagName(this.tagName),element.restoreState()),callback(!0)},Heading}(ContentTools.Tool),ContentTools.Tools.Subheading=function(_super){function Subheading(){return Subheading.__super__.constructor.apply(this,arguments)}return __extends(Subheading,_super),ContentTools.ToolShelf.stow(Subheading,"subheading"),Subheading.label="Subeading",Subheading.icon="subheading",Subheading.tagName="h2",Subheading}(ContentTools.Tools.Heading),ContentTools.Tools.Paragraph=function(_super){function Paragraph(){return Paragraph.__super__.constructor.apply(this,arguments)}return __extends(Paragraph,_super),ContentTools.ToolShelf.stow(Paragraph,"paragraph"),Paragraph.label="Paragraph",Paragraph.icon="paragraph",Paragraph.tagName="p",Paragraph.canApply=function(element){return void 0!==element},Paragraph.apply=function(element,selection,callback){var app,forceAdd,paragraph,region;return app=ContentTools.EditorApp.get(),forceAdd=app.ctrlDown(),ContentTools.Tools.Heading.canApply(element)&&!forceAdd?Paragraph.__super__.constructor.apply.call(this,element,selection,callback):("Region"!==element.parent().constructor.name&&(element=element.closest(function(node){return"Region"===node.parent().constructor.name})),region=element.parent(),paragraph=new ContentEdit.Text("p"),region.attach(paragraph,region.children.indexOf(element)+1),paragraph.focus(),callback(!0))},Paragraph}(ContentTools.Tools.Heading),ContentTools.Tools.Preformatted=function(_super){function Preformatted(){return Preformatted.__super__.constructor.apply(this,arguments)}return __extends(Preformatted,_super),ContentTools.ToolShelf.stow(Preformatted,"preformatted"),Preformatted.label="Preformatted",Preformatted.icon="preformatted",Preformatted.tagName="pre",Preformatted.apply=function(element,selection,callback){var insertAt,parent,preText,text;return text=element.content.text(),preText=new ContentEdit.PreText("pre",{},HTMLString.String.encode(text)),parent=element.parent(),insertAt=parent.children.indexOf(element),parent.detach(element),parent.attach(preText,insertAt),element.blur(),preText.focus(),preText.selection(selection),callback(!0)},Preformatted}(ContentTools.Tools.Heading),ContentTools.Tools.AlignLeft=function(_super){function AlignLeft(){return AlignLeft.__super__.constructor.apply(this,arguments)}return __extends(AlignLeft,_super),ContentTools.ToolShelf.stow(AlignLeft,"align-left"),AlignLeft.label="Align left",AlignLeft.icon="align-left",AlignLeft.className="text-left",AlignLeft.canApply=function(element){return void 0!==element.content},AlignLeft.isApplied=function(element){var _ref;return this.canApply(element)?(("ListItemText"===(_ref=element.constructor.name)||"TableCellText"===_ref)&&(element=element.parent()),element.hasCSSClass(this.className)):!1},AlignLeft.apply=function(element,selection,callback){var className,_i,_len,_ref,_ref1;for(("ListItemText"===(_ref=element.constructor.name)||"TableCellText"===_ref)&&(element=element.parent()),_ref1=["text-center","text-left","text-right"],_i=0,_len=_ref1.length;_len>_i;_i++)if(className=_ref1[_i],element.hasCSSClass(className)&&(element.removeCSSClass(className),className===this.className))return callback(!0);return element.addCSSClass(this.className),callback(!0)},AlignLeft}(ContentTools.Tool),ContentTools.Tools.AlignCenter=function(_super){function AlignCenter(){return AlignCenter.__super__.constructor.apply(this,arguments)}return __extends(AlignCenter,_super),ContentTools.ToolShelf.stow(AlignCenter,"align-center"),AlignCenter.label="Align center",AlignCenter.icon="align-center",AlignCenter.className="text-center",AlignCenter}(ContentTools.Tools.AlignLeft),ContentTools.Tools.AlignRight=function(_super){function AlignRight(){return AlignRight.__super__.constructor.apply(this,arguments)}return __extends(AlignRight,_super),ContentTools.ToolShelf.stow(AlignRight,"align-right"),AlignRight.label="Align right",AlignRight.icon="align-right",AlignRight.className="text-right",AlignRight}(ContentTools.Tools.AlignLeft),ContentTools.Tools.UnorderedList=function(_super){function UnorderedList(){return UnorderedList.__super__.constructor.apply(this,arguments)}return __extends(UnorderedList,_super),ContentTools.ToolShelf.stow(UnorderedList,"unordered-list"),UnorderedList.label="Bullet list",UnorderedList.icon="unordered-list",UnorderedList.listTag="ul",UnorderedList.canApply=function(element){var _ref;return void 0!==element.content&&("Region"===(_ref=element.parent().constructor.name)||"ListItem"===_ref)},UnorderedList.apply=function(element,selection,callback){var insertAt,list,listItem,listItemText,parent;return"ListItem"===element.parent().constructor.name?(element.storeState(),list=element.closest(function(node){return"List"===node.constructor.name}),list.tagName(this.listTag),element.restoreState()):(listItemText=new ContentEdit.ListItemText(element.content.copy()),listItem=new ContentEdit.ListItem,listItem.attach(listItemText),list=new ContentEdit.List(this.listTag,{}),list.attach(listItem),parent=element.parent(),insertAt=parent.children.indexOf(element),parent.detach(element),parent.attach(list,insertAt),listItemText.focus(),listItemText.selection(selection)),callback(!0)},UnorderedList}(ContentTools.Tool),ContentTools.Tools.OrderedList=function(_super){function OrderedList(){return OrderedList.__super__.constructor.apply(this,arguments)}return __extends(OrderedList,_super),ContentTools.ToolShelf.stow(OrderedList,"ordered-list"),OrderedList.label="Numbers list",OrderedList.icon="ordered-list",OrderedList.listTag="ol",OrderedList}(ContentTools.Tools.UnorderedList),ContentTools.Tools.Table=function(_super){function Table(){return Table.__super__.constructor.apply(this,arguments)}return __extends(Table,_super),ContentTools.ToolShelf.stow(Table,"table"),Table.label="Table",Table.icon="table",Table.canApply=function(element){return void 0!==element},Table.apply=function(element,selection,callback){var app,dialog,modal,table;return element.storeState&&element.storeState(),app=ContentTools.EditorApp.get(),modal=new ContentTools.ModalUI,table=element.closest(function(node){return node&&"Table"===node.constructor.name}),dialog=new ContentTools.TableDialog(table),dialog.bind("cancel",function(){return function(){return dialog.unbind("cancel"),modal.hide(),dialog.hide(),element.restoreState&&element.restoreState(),callback(!1)}}(this)),dialog.bind("save",function(_this){return function(tableCfg){var index,keepFocus,node,_ref;return dialog.unbind("save"),keepFocus=!0,table?(_this._updateTable(tableCfg,table),keepFocus=element.closest(function(node){return node&&"Table"===node.constructor.name})):(table=_this._createTable(tableCfg),_ref=_this._insertAt(element),node=_ref[0],index=_ref[1],node.parent().attach(table,index),keepFocus=!1),keepFocus?element.restoreState():table.firstSection().children[0].children[0].children[0].focus(),modal.hide(),dialog.hide(),callback(!0)}}(this)),app.attach(modal),app.attach(dialog),modal.show(),dialog.show()},Table._adjustColumns=function(section,columns){var cell,cellTag,cellText,currentColumns,diff,i,row,_i,_len,_ref,_results;for(_ref=section.children,_results=[],_i=0,_len=_ref.length;_len>_i;_i++)row=_ref[_i],cellTag=row.children[0].tagName(),currentColumns=row.children.length,diff=columns-currentColumns,_results.push(0>diff?function(){var _j,_results1;for(_results1=[],i=_j=diff;0>=diff?0>_j:_j>0;i=0>=diff?++_j:--_j)cell=row.children[row.children.length-1],_results1.push(row.detach(cell));return _results1}():diff>0?function(){var _j,_results1;for(_results1=[],i=_j=0;diff>=0?diff>_j:_j>diff;i=diff>=0?++_j:--_j)cell=new ContentEdit.TableCell(cellTag),row.attach(cell),cellText=new ContentEdit.TableCellText(""),_results1.push(cell.attach(cellText));return _results1}():void 0);return _results},Table._createTable=function(tableCfg){var body,foot,head,table;return table=new ContentEdit.Table,tableCfg.head&&(head=this._createTableSection("thead","th",tableCfg.columns),table.attach(head)),body=this._createTableSection("tbody","td",tableCfg.columns),table.attach(body),tableCfg.foot&&(foot=this._createTableSection("tfoot","td",tableCfg.columns),table.attach(foot)),table},Table._createTableSection=function(sectionTag,cellTag,columns){var cell,cellText,i,row,section,_i;for(section=new ContentEdit.TableSection(sectionTag),row=new ContentEdit.TableRow,section.attach(row),i=_i=0;columns>=0?columns>_i:_i>columns;i=columns>=0?++_i:--_i)cell=new ContentEdit.TableCell(cellTag),row.attach(cell),cellText=new ContentEdit.TableCellText(""),cell.attach(cellText);return section},Table._updateTable=function(tableCfg,table){var columns,foot,head,section,_i,_len,_ref;if(!tableCfg.head&&table.thead()&&table.detach(table.thead()),!tableCfg.foot&&table.tfoot()&&table.detach(table.tfoot()),columns=table.firstSection().children[0].children.length,tableCfg.columns!==columns)for(_ref=table.children,_i=0,_len=_ref.length;_len>_i;_i++)section=_ref[_i],this._adjustColumns(section,tableCfg.columns);return tableCfg.head&&!table.thead()&&(head=this._createTableSection("thead","th",tableCfg.columns),table.attach(head)),tableCfg.foot&&!table.tfoot()?(foot=this._createTableSection("tfoot","td",tableCfg.columns),table.attach(foot)):void 0},Table}(ContentTools.Tool),ContentTools.Tools.Indent=function(_super){function Indent(){return Indent.__super__.constructor.apply(this,arguments)}return __extends(Indent,_super),ContentTools.ToolShelf.stow(Indent,"indent"),Indent.label="Indent",Indent.icon="indent",Indent.canApply=function(element){return"ListItem"===element.parent().constructor.name&&element.parent().parent().children.indexOf(element.parent())>0},Indent.apply=function(element,selection,callback){return element.parent().indent(),callback(!0)},Indent}(ContentTools.Tool),ContentTools.Tools.Unindent=function(_super){function Unindent(){return Unindent.__super__.constructor.apply(this,arguments)}return __extends(Unindent,_super),ContentTools.ToolShelf.stow(Unindent,"unindent"),Unindent.label="Unindent",Unindent.icon="unindent",Unindent.canApply=function(element){return"ListItem"===element.parent().constructor.name},Unindent.apply=function(element,selection,callback){return element.parent().unindent(),callback(!0)},Unindent}(ContentTools.Tool),ContentTools.Tools.LineBreak=function(_super){function LineBreak(){return LineBreak.__super__.constructor.apply(this,arguments)}return __extends(LineBreak,_super),ContentTools.ToolShelf.stow(LineBreak,"line-break"),LineBreak.label="Line break",LineBreak.icon="line-break",LineBreak.canApply=function(element){return element.content},LineBreak.apply=function(element,selection,callback){var br,cursor,tail,tip;return cursor=selection.get()[0]+1,tip=element.content.substring(0,selection.get()[0]),tail=element.content.substring(selection.get()[1]),br=new HTMLString.String("
",element.content.preserveWhitespace()),element.content=tip.concat(br,tail),element.updateInnerHTML(),element.taint(),selection.set(cursor,cursor),element.selection(selection),callback(!0)},LineBreak}(ContentTools.Tool),ContentTools.Tools.Image=function(_super){function Image(){return Image.__super__.constructor.apply(this,arguments)
8 | }return __extends(Image,_super),ContentTools.ToolShelf.stow(Image,"image"),Image.label="Image",Image.icon="image",Image.canApply=function(){return!0},Image.apply=function(element,selection,callback){var app,dialog,modal;return element.storeState&&element.storeState(),app=ContentTools.EditorApp.get(),modal=new ContentTools.ModalUI,dialog=new ContentTools.ImageDialog,dialog.bind("cancel",function(){return function(){return dialog.unbind("cancel"),modal.hide(),dialog.hide(),element.restoreState&&element.restoreState(),callback(!1)}}(this)),dialog.bind("save",function(_this){return function(imageURL,imageSize,imageAttrs){var image,index,node,_ref;return dialog.unbind("save"),imageAttrs||(imageAttrs={}),imageAttrs.height=imageSize[1],imageAttrs.src=imageURL,imageAttrs.width=imageSize[0],image=new ContentEdit.Image(imageAttrs),_ref=_this._insertAt(element),node=_ref[0],index=_ref[1],node.parent().attach(image,index),image.focus(),modal.hide(),dialog.hide(),callback(!0)}}(this)),app.attach(modal),app.attach(dialog),modal.show(),dialog.show()},Image}(ContentTools.Tool),ContentTools.Tools.Video=function(_super){function Video(){return Video.__super__.constructor.apply(this,arguments)}return __extends(Video,_super),ContentTools.ToolShelf.stow(Video,"video"),Video.label="Video",Video.icon="video",Video.canApply=function(){return!0},Video.apply=function(element,selection,callback){var app,dialog,modal;return element.storeState&&element.storeState(),app=ContentTools.EditorApp.get(),modal=new ContentTools.ModalUI,dialog=new ContentTools.VideoDialog,dialog.bind("cancel",function(){return function(){return dialog.unbind("cancel"),modal.hide(),dialog.hide(),element.restoreState&&element.restoreState(),callback(!1)}}(this)),dialog.bind("save",function(_this){return function(videoURL){var index,node,video,_ref;return dialog.unbind("save"),videoURL?(video=new ContentEdit.Video("iframe",{frameborder:0,height:ContentTools.DEFAULT_VIDEO_HEIGHT,src:videoURL,width:ContentTools.DEFAULT_VIDEO_WIDTH}),_ref=_this._insertAt(element),node=_ref[0],index=_ref[1],node.parent().attach(video,index),video.focus()):element.restoreState&&element.restoreState(),modal.hide(),dialog.hide(),callback(""!==videoURL)}}(this)),app.attach(modal),app.attach(dialog),modal.show(),dialog.show()},Video}(ContentTools.Tool),ContentTools.Tools.Undo=function(_super){function Undo(){return Undo.__super__.constructor.apply(this,arguments)}return __extends(Undo,_super),ContentTools.ToolShelf.stow(Undo,"undo"),Undo.label="Undo",Undo.icon="undo",Undo.canApply=function(){var app;return app=ContentTools.EditorApp.get(),app.history&&app.history.canUndo()},Undo.apply=function(){var app,snapshot;return app=ContentTools.EditorApp.get(),app.history.stopWatching(),snapshot=app.history.undo(),app.revertToSnapshot(snapshot),app.history.watch()},Undo}(ContentTools.Tool),ContentTools.Tools.Redo=function(_super){function Redo(){return Redo.__super__.constructor.apply(this,arguments)}return __extends(Redo,_super),ContentTools.ToolShelf.stow(Redo,"redo"),Redo.label="Redo",Redo.icon="redo",Redo.canApply=function(){var app;return app=ContentTools.EditorApp.get(),app.history&&app.history.canRedo()},Redo.apply=function(){var app,snapshot;return app=ContentTools.EditorApp.get(),app.history.stopWatching(),snapshot=app.history.redo(),app.revertToSnapshot(snapshot),app.history.watch()},Redo}(ContentTools.Tool),ContentTools.Tools.Remove=function(_super){function Remove(){return Remove.__super__.constructor.apply(this,arguments)}return __extends(Remove,_super),ContentTools.ToolShelf.stow(Remove,"remove"),Remove.label="Remove",Remove.icon="remove",Remove.canApply=function(){return!0},Remove.apply=function(element,selection,callback){var app,list,row,table;switch(app=ContentTools.EditorApp.get(),element.blur(),element.constructor.name){case"ListItemText":app.ctrlDown()?(list=element.closest(function(node){return"Region"===node.parent().constructor.name}),list.parent().detach(list)):element.parent().parent().detach(element.parent());break;case"TableCellText":app.ctrlDown()?(table=element.closest(function(node){return"Table"===node.constructor.name}),table.parent().detach(table)):(row=element.parent().parent(),row.parent().detach(row));break;default:element.parent().detach(element)}return callback(!0)},Remove}(ContentTools.Tool)}.call(this);
--------------------------------------------------------------------------------
/contenttools-build/icons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guillaumepiot/contenttools-angularjs/396fea4dec621d6a03bb467f20b3e09790fd2120/contenttools-build/icons.woff
--------------------------------------------------------------------------------
/contenttools-build/images/ce-drop-above.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guillaumepiot/contenttools-angularjs/396fea4dec621d6a03bb467f20b3e09790fd2120/contenttools-build/images/ce-drop-above.png
--------------------------------------------------------------------------------
/contenttools-build/images/ce-drop-below.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guillaumepiot/contenttools-angularjs/396fea4dec621d6a03bb467f20b3e09790fd2120/contenttools-build/images/ce-drop-below.png
--------------------------------------------------------------------------------
/contenttools-build/images/ce-drop-left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guillaumepiot/contenttools-angularjs/396fea4dec621d6a03bb467f20b3e09790fd2120/contenttools-build/images/ce-drop-left.png
--------------------------------------------------------------------------------
/contenttools-build/images/ce-drop-right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guillaumepiot/contenttools-angularjs/396fea4dec621d6a03bb467f20b3e09790fd2120/contenttools-build/images/ce-drop-right.png
--------------------------------------------------------------------------------
/contenttools-build/images/video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guillaumepiot/contenttools-angularjs/396fea4dec621d6a03bb467f20b3e09790fd2120/contenttools-build/images/video.png
--------------------------------------------------------------------------------
/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guillaumepiot/contenttools-angularjs/396fea4dec621d6a03bb467f20b3e09790fd2120/image.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Content Tools & Angular JS
5 |
6 |
7 |
8 |
14 |
15 |
16 |
17 | Content Tools & Angular JS
18 |
19 |
20 |
21 | 5 rules for naming variables
22 |
23 |
24 | by Anthony Blackshaw · 18th January 2015
25 |
26 |
27 |
28 | Writing poor quality code will dramatically reduce the time
29 | you get to spend doing things you love, if you’re lucky
30 | enough to leave a project shortly after such a contribution
31 | everyone who subsequently has to work with your code will
32 | think you an arsehole.
33 |
34 |
35 |
36 |
37 |
38 | Above: This example is code found in
39 | a live and commercial project. Clearly the developer thought
40 | user.n5 would still clearly point to the 5th
41 | character of a the user's name when used elsewhere.
42 |
43 |
44 |
45 |
46 | The names we devise for folders, files, variables,
47 | functions, classes and any other user definable construct
48 | will (for the most part) determine how easily someone else
49 | can read and understand what we have written.
50 |
51 |
52 |
53 | To avoid repetition in the remainder of this section we use
54 | the term variable to cover folders, files, variables,
55 | functions, and classes.
56 |
57 |
58 |
59 |
60 |
61 | #
62 | First Name
63 | Last Name
64 | Username
65 |
66 |
67 |
68 |
69 | 1
70 | Mark
71 | Otto
72 | @mdo
73 |
74 |
75 | 2
76 | Jacob
77 | Thornton
78 | @fat
79 |
80 |
81 | 3
82 | Larry
83 | the Bird
84 | @twitter
85 |
86 |
87 |
88 |
89 |
90 |
91 | You can have another editable area on the same page
92 | Another content....
93 |
94 |
95 | JSON Output from Content Tools
96 |
97 | {{regions}}
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "contenttools-angularjs",
3 | "version": "1.0.0",
4 | "description": "A demo integration for Content Tools JS & Angular JS",
5 | "main": "Gruntfile.js",
6 | "dependencies": {
7 | "serve": "^1.4.0"
8 | },
9 | "devDependencies": {
10 | "grunt": "^0.4.5",
11 | "grunt-contrib-connect": "^0.11.2"
12 | },
13 | "scripts": {
14 | "test": "echo \"Error: no test specified\" && exit 1"
15 | },
16 | "repository": {
17 | "type": "git",
18 | "url": "https://github.com/Cotidia/contenttools-angularjs.git"
19 | },
20 | "keywords": [
21 | "content",
22 | "tools",
23 | "angular",
24 | "js"
25 | ],
26 | "author": "Guillaume Piot",
27 | "license": "ISC",
28 | "bugs": {
29 | "url": "https://github.com/Cotidia/contenttools-angularjs/issues"
30 | },
31 | "homepage": "https://github.com/Cotidia/contenttools-angularjs"
32 | }
33 |
--------------------------------------------------------------------------------
/sandbox.js:
--------------------------------------------------------------------------------
1 | angular.module('editorApp', [])
2 | .directive('ngEditor',['$compile', function($compile){
3 |
4 | function link(scope, element, attrs){
5 |
6 | // Initialise the editor
7 | editor = new ContentTools.EditorApp.get()
8 | editor.init('[ng-editor]', 'ng-editor')
9 |
10 | // Bind a function on editor save
11 | editor.bind('save', function(regions, autoSave){
12 |
13 | scope.$apply(function(){
14 | scope.regions = regions;
15 | });
16 |
17 | // "regions" contains all the html for each editable regions
18 | // Now, "regions" can be saved and used as needed.
19 |
20 | })
21 |
22 |
23 |
24 | // Capture element changes
25 | ContentEdit.Root.get().bind('taint', function (elm) {
26 |
27 | // If it has a parent, it is not a Region and will have "attr"
28 | if (elm.parent()) {
29 | if (elm.attr('ng-test')){
30 | console.log("Reload directive");
31 |
32 | elm.selection(new ContentSelect.Range(0, 0));
33 | $compile(element.contents())(scope);
34 | }
35 | }
36 |
37 | });
38 |
39 |
40 | }
41 |
42 | return {
43 | link: link
44 | }
45 |
46 | }])
47 | .directive('ngTest', function(){
48 |
49 | return {
50 | compile: function(element, attrs){
51 | var htmlText = 'test';
52 | console.log(element.child)
53 | element.html(htmlText);
54 | },
55 | link: function (scope, element) {
56 | console.log("Scope loaded")
57 | }
58 | }
59 |
60 | })
--------------------------------------------------------------------------------