{I" class:ETI"ProcessedAsset;FI"logical_path;TI"chaskiq/manage/iframe.js;FI" pathname;TI"c/Users/michelson/Documents/ruby/chaskiq/app/assets/javascripts/chaskiq/manage/iframe.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+>ÖÊUI" length;TiÕ$I" digest;TI"%032c59ea95a3d6807db0310fb090fdd2;FI" source;TI"Õ$(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.Iframe = (function(superClass) { extend(Iframe, superClass); function Iframe() { return Iframe.__super__.constructor.apply(this, arguments); } Iframe.prototype.el = '#chaskiq-mail-editor'; Iframe.prototype.events = function() { return { 'drag .blocks li a': 'drag', 'drag .tpl-block-controls a': 'drag', 'dragstart .tpl-block-controls a': 'setDraggedEl', 'dragend .tpl-block-controls a': 'removeDraggedEl', "dragleave #bodyTable": "hideSections", "drop #bodyTable": "hideSections", "dragover .tpl-block": "displayItemOver", "dragover .chaskiqContainerEmptyMessage": "displayItemOver", 'drop #templateBody': "drop", 'drop #templatePreheader': "drop", 'drop #templateHeader': "drop", 'drop #templateBody': "drop", "drop #templateFooter": "drop", "click .tpl-block": "setFocus", "click .imagePlaceholder .button-small": "displayUploaderList", "click .tpl-block-delete": "deleteBloc", "click input.submit": "submitEditor" }; }; Iframe.prototype.initialize = function() { this.editor = top.editor; this.textarea = $(this.editor.el).find('#campaign_html_content'); return this.css = $(this.editor.el).find('#campaign_css'); }; Iframe.prototype.copyToTextArea = function() { var $this; $this = $("#mail-editor"); return window.setTimeout((function(_this) { return function() { return $(_this.editor.el).find('#campaign_html_content').val($this.html()); }; })(this), 0); }; Iframe.prototype.copyCssRulesToTextArea = function() { var rules; rules = _.map(this.style().cssRules, function(rule) { return rule.cssText; }); return $("#campaign_css").val(rules.join(" ")); }; Iframe.prototype.template = function() { return '

dsfsd

'; }; Iframe.prototype.render = function() { $(this.el).find('#mail-editor').html(this.textarea.val()); this.removeTplBlockControls(); return this.addTplBlockControls(); }; Iframe.prototype.removeTplBlockControls = function() { return $(".tpl-block-controls").remove(); }; Iframe.prototype.addTplBlockControls = function() { return _.each($(".chaskiqBlock.tpl-block"), (function(_this) { return function(n) { return $(n).append(_this.templateBlockControls()); }; })(this)); }; Iframe.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(); }; Iframe.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); }; Iframe.prototype.removeDraggedEl = function() { return $(this.crt).remove(); }; Iframe.prototype.displayItemOver = function(ev) { this.displaySections(ev); $('.tpl-block').removeClass("chaskiqDndItemBefore"); if ($(ev.currentTarget).hasClass("tpl-block")) { $(ev.currentTarget).addClass("chaskiqDndItemBefore"); } return ev.preventDefault(); }; Iframe.prototype.hideSections = function() { $('.tpl-container').removeClass("default").removeClass("over"); return _.each($('.tpl-container'), function(n) { return $(n).find(".legend").remove(); }); }; Iframe.prototype.drag = function(ev) { return this.dragged = $(ev.currentTarget); }; Iframe.prototype.allowDrop = function(ev) { return ev.preventDefault(); }; Iframe.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(); } }); }; Iframe.prototype.drop = function(ev) { var container, tmpl, to_drop; ev.preventDefault(); console.log(ev.target.id); container = $(ev.currentTarget); if (this.editor.dragged && this.editor.dragged.attr('data-block')) { tmpl = this.editor.handleBlock(this.editor.dragged.data('block')); this.dropBlock(container, tmpl); } else { to_drop = this.dragged.parents(".tpl-block"); this.dropBlock(container, to_drop); } this.copyToTextArea(); this.releaseBeforeItem(); this.displayEmptyBlocks(); this.editor.dragged = null; return this.dragged = null; }; Iframe.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); } }; Iframe.prototype.releaseBeforeItem = function() { return $(".tpl-block").removeClass("chaskiqDndItemBefore"); }; Iframe.prototype.currentFocused = function() { return $(".tpl-block.focus"); }; Iframe.prototype.setFocus = function(ev) { $(".tpl-block").removeClass("focus"); $(ev.currentTarget).addClass("focus"); this.editor.displayWysiwyg(); this.editor.renderBlockDesignSettings(); return false; }; Iframe.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; }; Iframe.prototype.emptyContainerMessage = function() { return "
Drop Content Blocks Here
"; }; Iframe.prototype.wrapBlock = function(content) { return "
" + content + "
" + (this.templateBlockControls()) + "
"; }; Iframe.prototype.templateBlockControls = function() { return "
"; }; Iframe.prototype.displayUploaderList = function(ev) { var placeholder; placeholder = $(ev.currentTarget).parents('.imagePlaceholder'); this.editor.checkExistentImages(placeholder); return false; }; /* Style Handling */ Iframe.prototype.findStyleSheet = function() { return _.find(document.styleSheets, function(n) { return n.ownerNode.id === "custom_style"; }); }; Iframe.prototype.findRule = function(name, sheet) { if (sheet == null) { sheet = this.defaultStyleSheet(); } return _.find(sheet.cssRules, function(n) { return n.selectorText === name; }); }; Iframe.prototype.findRuleIndex = function(sheet, name) { var indexes; indexes = _.map(sheet.cssRules, function(n, i) { if (n.selectorText === name) { return i; } }); return indexes[0]; }; Iframe.prototype.defaultStyleSheet = function() { return this.findStyleSheet(); }; Iframe.prototype.style = function() { return this.defaultStyleSheet(); }; Iframe.prototype.modifyRule = function(selector, property, value) { var rule, s; rule = this.findRule(selector); s = this.style(); if (_.isUndefined(rule)) { return s.insertRule(selector + " { property: " + value + ";}", s.cssRules.length); } else { return this.findRule(selector).style[property] = value; } }; return Iframe; })(Backbone.View); }).call(this); ;TI"dependency_digest;TI"%c58ed955a9119c2fd0de528f0cfe6187;FI"required_paths;T[I"c/Users/michelson/Documents/ruby/chaskiq/app/assets/javascripts/chaskiq/manage/iframe.js.coffee;FI"dependency_paths;T[{I" path;TI"c/Users/michelson/Documents/ruby/chaskiq/app/assets/javascripts/chaskiq/manage/iframe.js.coffee;FI" mtime;TI"2015-08-12T02:14:38-03:00;TI" digest;TI"%52886469e067af5c1f083462606963d7;FI" _version;TI"%64e62ddc273c2f5847f30d698ca14b67;F