{I" class:ETI"ProcessedAsset;FI"logical_path;TI"&chaskiq/manage/campaign_wizard.js;FI" pathname;TI"l/Users/michelson/Documents/ruby/chaskiq/app/assets/javascripts/chaskiq/manage/campaign_wizard.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+ÎñUI" length;TiB‹I" digest;TI"%3481aa5ef66dca826464806c636cc5dc;FI" source;TI"B‹(function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; window.Editor = (function(superClass) { extend(Editor, superClass); function Editor() { return Editor.__super__.constructor.apply(this, arguments); } Editor.prototype.el = '#chaskiq-mail-editor'; Editor.prototype.events = function() { return { 'keyup .note-editable': 'copyToFocusedElement', 'drag .blocks li a': 'drag', "click #editor-controls #save": "saveAndClose", "changeColor.colorpicker .colorpicker": "changeColor", "change .text-size-picker": "changeProperty", "change .font-picker": "changeProperty", "change .font-weight": "changeProperty", "change .font-spacing": "changeProperty", "change .font-align": "changeProperty", "click input.submit": "submitEditor" }; }; Editor.prototype.initialize = function() { this.textarea = $(this.el).find('#campaign_html_content'); this.css = $(this.el).find('#campaign_css'); window.current_editor = this; this.placeholder = null; return this.files = []; }; Editor.prototype.setIframe = function(iframe) { return this.iframe = iframe; }; Editor.prototype.copyToEditor = function(ev) { var $this; $this = $(ev.currentTarget); return window.setTimeout((function(_this) { return function() { return $(_this.iframe.el).find('#mail-editor').html($this.val()); }; })(this), 0); }; Editor.prototype.buildOptionsFromStyles = function() { return this.renderBlockDesignSettings(); }; Editor.prototype.copyToTextArea = function() { var $this; $this = $(this.iframe.el).find("#mail-editor"); return window.setTimeout((function(_this) { return function() { return $(_this.el).find('#campaign_html_content').val($this.html()); }; })(this), 0); }; Editor.prototype.copyToFocusedElement = function(ev) { this.currentFocused().find('.mcnTextContent').html($(ev.currentTarget).html()); return this.copyToTextArea(); }; Editor.prototype.copyCssRulesToTextArea = function() { var rules; rules = _.map(this.style().cssRules, function(rule) { return rule.cssText; }); return $("#campaign_css").val(rules.join(" ")); }; Editor.prototype.submitEditor = function(ev) { this.removeTplBlockControls(); this.copyToTextArea(); this.copyCssRulesToTextArea(); return setTimeout(function() { return $(ev.currentTarget).submit(); }, 600); }; Editor.prototype.template = function() { return '

dsfsd

'; }; Editor.prototype.render = function() { return document.getElementById("editor-frame").onload = (function(_this) { return function() { _this.iframe = $("#editor-frame")[0].contentWindow.iframe; $("#tab-2").html(_this.baseStylesTemplate("accordeon", _this.definitionsForEditor())); $('.colorpicker').colorpicker(); if (_.isEmpty(_this.textarea.val())) { return $(_this.iframe.el).find('#mail-editor').html(_this.baseTemplate()); } else { return $(_this.iframe.el).find('#mail-editor').html(_this.textarea.val()); } }; })(this); }; Editor.prototype.removeTplBlockControls = function() { return $(".tpl-block-controls").remove(); }; Editor.prototype.addTplBlockControls = function() { return _.each($(".chaskiqBlock.tpl-block"), (function(_this) { return function(n) { return $(n).append(_this.templateBlockControls()); }; })(this)); }; Editor.prototype.displaySections = function(ev) { var container; container = $(ev.currentTarget).parent(".tpl-container"); container.append("
" + ($(container).attr("mc:container")) + "
"); container.addClass("default"); if (container.hasClass("tpl-container")) { container.addClass("over").removeClass("default"); container.find(".legend").addClass("over").removeClass("default"); } return ev.preventDefault(); }; Editor.prototype.setDraggedEl = function(e) { this.crt = $(e.currentTarget).parents(".tpl-block")[0].cloneNode(true); this.crt.style.backgroundColor = "white"; this.crt.style.position = "absolute"; this.crt.style.border = "1px solid #666"; this.crt.style.boxShadow = "1px 2px 2px #adadad"; this.crt.style.top = "0px"; this.crt.style.right = "0px"; this.crt.style.opacity = 0.9; this.crt.style.zIndex = -9999; document.body.appendChild(this.crt); e.dataTransfer = e.originalEvent.dataTransfer; return e.dataTransfer.setDragImage(this.crt, 0, 0); }; Editor.prototype.removeDraggedEl = function() { return $(this.crt).remove(); }; Editor.prototype.displayItemOver = function(ev) { this.displaySections(ev); $('.tpl-block').removeClass("chaskiqDndItemBefore"); if ($(ev.currentTarget).hasClass("tpl-block")) { $(ev.currentTarget).addClass("chaskiqDndItemBefore"); } return ev.preventDefault(); }; Editor.prototype.hideSections = function() { $('.tpl-container').removeClass("default").removeClass("over"); return _.each($('.tpl-container'), function(n) { return $(n).find(".legend").remove(); }); }; Editor.prototype.drag = function(ev) { return this.dragged = $(ev.currentTarget); }; Editor.prototype.allowDrop = function(ev) { return ev.preventDefault(); }; Editor.prototype.displayEmptyBlocks = function() { return _.each($('.tpl-container'), function(container) { var empty_message; empty_message = $(container).find('.chaskiqContainerEmptyMessage'); if ($(container).find(".tpl-block").length > 0) { return empty_message.hide(); } else { return empty_message.show(); } }); }; Editor.prototype.dropBlock = function(container, tmpl) { if ($(".tpl-block.chaskiqDndItemBefore").length > 0) { container.find(".tpl-block.chaskiqDndItemBefore").before(tmpl); return container.find('.chaskiqContainerEmptyMessage').hide(); } else { return container.find(".tpl-container").append(tmpl); } }; Editor.prototype.releaseBeforeItem = function() { return $(".tpl-block").removeClass("chaskiqDndItemBefore"); }; Editor.prototype.displayWysiwyg = function() { $('.block-settings').show(); $('.main-settings').hide(); this.initWysiwyg(); return false; }; Editor.prototype.displayBlockButtons = function() { $('.block-settings').hide(); $('.main-settings').show(); return false; }; Editor.prototype.saveAndClose = function() { this.copyToTextArea(); this.displayBlockButtons(); return false; }; Editor.prototype.currentFocused = function() { return $(this.iframe.el).find(".tpl-block.focus"); }; Editor.prototype.initWysiwyg = function() { $('.summernote').destroy(); InitSummernote(); return $('.summernote').code(this.currentFocused().find('.mcnTextContent').html()); }; Editor.prototype.handleBlock = function(block_type) { var html; html = ""; switch (block_type) { case "boxed": html = this.boxedBlock(); break; case "text": html = this.textBlock(); break; case "separator": html = this.separatorBlock(); break; case "image": html = this.imageBlock(); break; case "image_group": html = this.imageGroupBlock(); break; case "image_card": html = this.imageCardBlock(); break; default: console.log("Nada"); } return this.wrapBlock(html); }; Editor.prototype.deleteBloc = function(ev) { var container, target; target = $(ev.currentTarget); container = target.parents(".tpl-container"); target.parents(".tpl-block").remove(); if (container.find(".tpl-block").length === 0) { container.find(".chaskiqContainerEmptyMessage").show(); } return false; }; Editor.prototype.emptyContainerMessage = function() { return "
Drop Content Blocks Here
"; }; Editor.prototype.wrapBlock = function(content) { return "
" + content + "
" + (this.templateBlockControls()) + "
"; }; Editor.prototype.templateBlockControls = function() { return "
"; }; Editor.prototype.baseTemplate = function() { return "
" + (this.emptyContainerMessage()) + "
" + (this.emptyContainerMessage()) + "
" + (this.emptyContainerMessage()) + "
" + (this.emptyContainerMessage()) + " " + (this.wrapBlock(this.subscriptionBlock())) + "
"; }; Editor.prototype.boxedBlock = function() { return "
This is a Text Block. Use this to provide text...
"; }; Editor.prototype.textBlock = function() { return "
This is a Text Block. Use this to provide text...
"; }; Editor.prototype.separatorBlock = function() { return "
"; }; Editor.prototype.imageBlock = function() { return "
Drop an image here
or
"; }; Editor.prototype.imageGroupBlock = function() { return "
Drop an image here
or
Drop an image here
or
"; }; Editor.prototype.imageCardBlock = function() { return "
Drop an image here
or
Your text caption goes here
"; }; Editor.prototype.subscriptionBlock = function() { return "
© {{campaign_description}}

Our mailing address is:
{{campaign_url}}

unsubscribe from this list    update subscription preferences 

"; }; Editor.prototype.listenerForImagesReplace = function() { return $('.image-selector').on("click", function() { var html, url; html = current_editor.placeholder.parents(".mcpreview-image-uploader"); url = $(this).data('image-url'); current_editor.replaceImagePreview(html, url); return false; }); }; Editor.prototype.checkExistentImages = function(placeholder) { return $.ajax({ url: $("#editor-container").data("attachments-path"), dataType: "json", success: (function(_this) { return function(data) { Chaskiq.Helpers.showModal(_this.templateForAttachments(data), "dsdsda"); _this.placeholder = placeholder; _this.listenerForImagesReplace(); $('#myModal input[type=file]').on('change', _this.prepareUpload); return $('#myModal #upload-form').on('submit', _this.uploadFiles); }; })(this), error: function(err) { return alert("error retrieving files"); } }); }; Editor.prototype.replaceImagePreview = function(html_to_replace, url) { html_to_replace.replaceWith(""); Chaskiq.Helpers.hideModal(); return this.copyToTextArea(); }; Editor.prototype.templateforUploader = function() { return "
"; }; Editor.prototype.templateForAttachments = function(data) { var html; html = this.templateforUploader(); html += ""; }; Editor.prototype.appendImageToAttachmentList = function(data) { $("#myModal .attachments-modal-list").prepend("
  • Select
  • "); return this.listenerForImagesReplace(); }; Editor.prototype.fileUploader = function() {}; Editor.prototype.prepareUpload = function(event) { window.current_editor.files = event.target.files; }; Editor.prototype.uploadFiles = function(event) { var data; console.log("upload upload!"); event.stopPropagation(); event.preventDefault(); data = new FormData; $.each(window.current_editor.files, function(key, value) { data.append("attachment[image]", value); }); $.ajax({ url: $("#editor-container").data("attachments-path"), type: 'POST', data: data, cache: false, dataType: 'json', processData: false, contentType: false, success: function(data, textStatus, jqXHR) { if (typeof data.error === 'undefined') { current_editor.appendImageToAttachmentList(data); } else { console.log('ERRORS: ' + data.error); } }, error: function(jqXHR, textStatus, errorThrown) { console.log('ERRORS: ' + textStatus); } }); }; Editor.prototype.defaultStyleSheet = function() { return this.iframe.findStyleSheet(); }; Editor.prototype.style = function() { return this.defaultStyleSheet(); }; Editor.prototype.definitionsForEditor = function() { return [ { name: "Page", targets: [ { name: "Background", selector: "#bodyTable", template: "background", namespace: "Content" }, { name: "Text", selector: "#bodyTable", template: "typography", namespace: "Content" } ] }, { name: "Preheader", targets: [ { name: "background", selector: "#templatePreheader", template: "background", namespace: "Content" }, { name: "Text", selector: "#templatePreHeader", template: "typography", namespace: "Content" }, { name: "h1", selector: "#templatePreHeader h1", template: "typography", namespace: "Content" }, { name: "h2", selector: "#templatePreHeader h2", template: "typography", namespace: "Content" } ] }, { name: "Header", targets: [ { name: "Header background", selector: "#templateHeader", template: "background" } ] }, { name: "Body", targets: [ { name: "body background", selector: "#templateBody", template: "background", namespace: "Content" }, { name: "font", selector: ".bodyContainer .mcnTextContent", template: "typography", namespace: "Content" }, { name: "links", selector: ".bodyContainer .mcnTextContent a", template: "typography", namespace: "Content" } ] }, { name: "Footer", targets: [ { name: "background", selector: "#templateFooter", template: "background", namespace: "Content" }, { name: "font", selector: ".footerContainer .mcnTextContent, .footerContainer .mcnTextContent p", template: "typography", namespace: "Content" } ] }, { name: "Columns", targets: [] } ]; }; Editor.prototype.definitionsForBlocks = function() { return [ { name: "mcnBaseTemplate", targets: [] }, { name: "mcnBoxedText", targets: [ { name: "background", selector: ".mcnTextContentContainer", template: "background", namespace: "Content" }, { name: "font", selector: ".mcnTextContentContainer", template: "typography", namespace: "Content" } ] }, { name: "mcnText", targets: [ { name: "background", selector: "", template: "background", namespace: "Content" }, { name: "font", selector: "", template: "typography", namespace: "Content" }, { name: "heading 1", selector: "h1", template: "typography", namespace: "Content" }, { name: "heading 2", selector: "h2", template: "typography", namespace: "Content" }, { name: "page links", selector: "a", template: "typography", namespace: "Content" } ] }, { name: "mcnDivider", targets: [] }, { name: "mcnImage", targets: [] }, { name: "mcnImageGroup", targets: [ { name: "background", selector: "", template: "background", namespace: "BlockInner" } ] }, { name: "mcnImageCard", targets: [ { name: "background", selector: "", template: "background", namespace: "BottomContent" }, { name: "font", selector: "", template: "typography", namespace: "BottomContent" } ] }, { name: "mcnSubscription", targets: [] } ]; }; Editor.prototype.renderBlockDesignSettings = function() { var e, focused, html, section; try { $('.colorpicker').colorpicker('destroy'); } catch (_error) { e = _error; console.log(e); } focused = this.currentFocused().find("table:first").attr("class"); section = _.find(editor.definitionsForBlocks(), (function(_this) { return function(n) { return (n.name + "Block") === focused; }; })(this)); console.log("section " + focused); if (section) { console.log("display for " + focused); this.current_section = section; html = this.buildDesignToolForTarget(section); $("#tab-4").html(html); return $('.colorpicker').colorpicker(); } }; Editor.prototype.baseStylesTemplate = function(id, definitions) { return "
    " + (this.colapsiblePanelsFor(id, definitions)) + "
    "; }; Editor.prototype.colapsiblePanelsFor = function(id, style_types) { var tpl; tpl = _.map(style_types, (function(_this) { return function(n) { return "

    " + n.name + "

    " + (_this.buildDesignToolForTarget(n)) + "

    "; }; })(this)); return tpl.join(" "); }; Editor.prototype.buildDesignToolForTarget = function(section) { var tpl; tpl = _.map(section.targets, (function(_this) { return function(n) { return _this.templateToolsFor(n, section.name); }; })(this)); return "
    " + (tpl.join(" ")) + "
    "; }; Editor.prototype.templateToolsFor = function(n, parent_name) { var title, tools; title = "

    " + n.name + "

    "; tools = ""; switch (n.template) { case "background": tools = this.backgroundFieldsFor(n, parent_name); break; case "typography": tools = this.typoFieldsFor(n, parent_name); } return [title, tools].join(" "); }; Editor.prototype.rgb2hex = function(rgb) { if (_.isUndefined(rgb)) { return; } rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i); if (rgb && rgb.length === 4) { return "#" + ("0" + parseInt(rgb[1], 10).toString(16)).slice(-2) + ("0" + parseInt(rgb[2], 10).toString(16)).slice(-2) + ("0" + parseInt(rgb[3], 10).toString(16)).slice(-2); } else { return ''; } }; Editor.prototype.changeColor = function(ev) { var css, property, target, value; target = $(ev.currentTarget); css = target.data('css'); property = target.data('css-property'); value = this.rgb2hex(ev.color.toString()); console.log("changing from " + css + ", " + property + " " + value); if (css.length > 0) { return this.iframe.modifyRule(css, property, value); } else { return this.currentFocused().find("table:first").find("." + this.current_section.name + (target.data('namespace'))).css(property, value); } }; Editor.prototype.changeProperty = function(ev) { var css, property, target, value; target = $(ev.currentTarget); css = target.data('css'); property = target.data('css-property'); value = target.val(); console.log("changing from " + css + ", " + property + " " + value); if (css.length > 0) { return this.iframe.modifyRule(css, property, value); } else { return editor.currentFocused().find("table:first").find("." + this.current_section.name + (target.data('namespace'))).css(property, value); } }; Editor.prototype.arrayGen = function(n) { return Array.apply(null, { length: n }).map(Number.call, Number); }; Editor.prototype.styleforSelector = function(target, style_selector, parent_name) { var o, val; val = !target.selector ? this.currentFocused().find("." + parent_name + target.namespace) : this.iframe.$el.find(target.selector); o = val.css(style_selector); return o; }; Editor.prototype.backgroundFieldsFor = function(target, parent_name) { var style_selector, val; style_selector = "background-color"; val = this.styleforSelector(target, style_selector, parent_name); val = this.rgb2hex(val); return [""].join(" "); }; Editor.prototype.typoFieldsFor = function(target, parent_name) { var align, c, color, familyFont, ff, sf, sizeFont, spacingtext, weight; c = this.styleforSelector(target, 'color', parent_name); color = "
    "; sizeFont = "
    "; ff = this.styleforSelector(target, 'font-family', parent_name); familyFont = "
    "; weight = "
    "; spacingtext = "
    "; align = "
    "; return [color, sizeFont, familyFont, weight, spacingtext, align].join(" "); }; return Editor; })(Backbone.View); }).call(this); ;TI"dependency_digest;TI"%36a1f9203cc91b17bfc9e6923f3a12a1;FI"required_paths;T[I"l/Users/michelson/Documents/ruby/chaskiq/app/assets/javascripts/chaskiq/manage/campaign_wizard.js.coffee;FI"dependency_paths;T[{I" path;TI"l/Users/michelson/Documents/ruby/chaskiq/app/assets/javascripts/chaskiq/manage/campaign_wizard.js.coffee;FI" mtime;TI"2015-09-10T02:36:14-03:00;TI" digest;TI"%de6879c246be2c7e1c3843828cb73b82;FI" _version;TI"%64e62ddc273c2f5847f30d698ca14b67;F