{I" class:ETI"BundledAsset;FI"logical_path;TI"&rubber_ring/attachment_dragger.js;FI" pathname;TI"g/home/vagrant/development/rubber_ring/app/assets/javascripts/rubber_ring/attachment_dragger.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+™…QI" length;Ti7 I" digest;TI"%1daf2baf80165c7e18cd7a92700ac535;FI" source;TI"7 (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; this.AttachmentDragger = (function() { AttachmentDragger.prototype.attribute = null; AttachmentDragger.prototype.drag_items = null; function AttachmentDragger(drag_selector, drop_selector, attribute) { this.drag_selector = drag_selector; this.drop_selector = drop_selector; this.attribute = attribute; this.cancel = __bind(this.cancel, this); this.init = __bind(this.init, this); this.init(); } AttachmentDragger.prototype.init = function() { var drag_item, drop_attachment_element, _i, _len, _ref, _this = this; this.drag_items = document.querySelectorAll(this.drag_selector); _ref = this.drag_items; for (_i = 0, _len = _ref.length; _i < _len; _i++) { drag_item = _ref[_i]; addEvent(drag_item, "dragstart", function(e) { return event.dataTransfer.setData(_this.attribute, $(e.currentTarget).attr(_this.attribute)); }); } drop_attachment_element = document.querySelector(this.drop_selector); addEvent(drop_attachment_element, "dragover", this.cancel); addEvent(drop_attachment_element, "dragenter", this.cancel); return addEvent(drop_attachment_element, "drop", function(e) { var new_content, pm; if (e.preventDefault) { e.preventDefault(); } if ($(e.currentTarget).attr(_this.attribute) !== e.dataTransfer.getData(_this.attribute)) { new_content = e.dataTransfer.getData(_this.attribute); if (new_content.length > 0) { $(e.currentTarget).attr(_this.attribute, e.dataTransfer.getData(_this.attribute)); pm = new PersistenceManager(); if (_this.attribute === "src") { pm.save_image($(e.currentTarget)); } if (_this.attribute === "href") { pm.save_attachment($(e.currentTarget)); } } } return false; }); }; AttachmentDragger.prototype.cancel = function(e) { if (e.preventDefault && $(e.currentTarget).attr(this.attribute) !== e.dataTransfer.getData(this.attribute)) { e.preventDefault(); } return false; }; return AttachmentDragger; })(); }).call(this); ;TI"required_assets_digest;TI"%9f34676cfa47436360f1b865746e7fc4;FI" _version;TI"%1e2632a10b8c877576b37720d5bf8883;F