{I" class:ETI"BundledAsset;FI"logical_path;TI"mercury/regions/image.js;FI" pathname;TI"/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/regions/image.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+9RI" length;TiI" digest;TI"%4455a448491f2bc5b2df1785768269ef;FI" source;TI"(function() { var __hasProp = {}.hasOwnProperty, __extends = 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; }; this.Mercury.Regions.Image = (function(_super) { var type; __extends(Image, _super); Image.supported = document.getElementById; Image.supportedText = "Chrome 10+, Firefox 4+, IE 7+, Safari 5+, Opera 8+"; type = 'image'; Image.prototype.type = function() { return type; }; function Image(element, window, options) { this.element = element; this.window = window; this.options = options != null ? options : {}; Image.__super__.constructor.apply(this, arguments); } Image.prototype.bindEvents = function() { var _this = this; Mercury.on('mode', function(event, options) { if (options.mode === 'preview') { return _this.togglePreview(); } }); Mercury.on('focus:frame', function() { if (_this.previewing || Mercury.region !== _this) { return; } return _this.focus(); }); Mercury.on('action', function(event, options) { if (_this.previewing || Mercury.region !== _this) { return; } if (options.action) { return _this.execCommand(options.action, options); } }); this.element.on('dragenter', function(event) { if (_this.previewing) { return; } event.preventDefault(); return event.originalEvent.dataTransfer.dropEffect = 'copy'; }); this.element.on('dragover', function(event) { if (_this.previewing) { return; } event.preventDefault(); return event.originalEvent.dataTransfer.dropEffect = 'copy'; }); this.element.on('drop', function(event) { if (_this.previewing) { return; } if (event.originalEvent.dataTransfer.files.length) { event.preventDefault(); _this.focus(); return Mercury.uploader(event.originalEvent.dataTransfer.files[0]); } }); return this.element.on('focus', function() { return _this.focus(); }); }; Image.prototype.togglePreview = function() { if (this.previewing) { this.previewing = false; this.element.attr(Mercury.config.regions.attribute, type); return this.build(); } else { this.previewing = true; this.element.removeAttr(Mercury.config.regions.attribute); return Mercury.trigger('region:blurred', { region: this }); } }; Image.prototype.focus = function() { if (this.previewing) { return; } Mercury.region = this; Mercury.trigger('region:focused', { region: this }); return Mercury.trigger('region:update', { region: this }); }; Image.prototype.execCommand = function(action, options) { var handler; if (options == null) { options = {}; } Image.__super__.execCommand.apply(this, arguments); if (handler = Mercury.Regions.Image.actions[action]) { return handler.call(this, options); } }; Image.prototype.pushHistory = function() { return this.history.push({ src: this.element.attr('src') }); }; Image.prototype.updateSrc = function(src) { return this.element.attr('src', src); }; Image.prototype.serialize = function() { return { type: type, data: this.dataAttributes(), attributes: { src: this.element.attr('src') } }; }; Image.actions = { undo: function() { var prev; if (prev = this.history.undo()) { return this.updateSrc(prev.src); } }, redo: function() { var next; if (next = this.history.redo()) { return this.updateSrc(next.src); } }, insertImage: function(options) { return this.updateSrc(options.value.src); } }; return Image; })(Mercury.Region); }).call(this); ;TI"required_assets_digest;TI"%ab74930a46387a1f3f33895e77875bda;FI" _version;TI"%2cf3622cbba861b85d33ffabfa420c13;F