o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1388437013.0224268: @value" {I" class:EFI"BundledAsset;FI"logical_path;FI"mercury/region.js;FI" pathname;FI"‡/Users/jrissler/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/mercury-rails-0.9.0/app/assets/javascripts/mercury/region.js.coffee;FI"content_type;FI"application/javascript;FI" mtime;FI"2013-12-30T11:31:51-05:00;FI" length;FiüI" digest;F"%aac4b048ad14a86ac386522159658ac1I" source;FI"ü(function() { this.Mercury.Region = (function() { function Region(element, window, options) { this.element = element; this.window = window; this.options = options != null ? options : {}; Mercury.log("building " + (this.type()), this.element, this.options); this.document = this.window.document; this.name = this.element.attr(Mercury.config.regions.identifier); this.history = new Mercury.HistoryBuffer(); this.build(); this.bindEvents(); this.pushHistory(); this.element.data('region', this); } Region.prototype.type = function() { return 'unknown'; }; Region.prototype.build = function() {}; Region.prototype.focus = function() {}; Region.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 || event.isDefaultPrevented()) { return; } if (options.action) { return _this.execCommand(options.action, options); } }); this.element.on('mousemove', function(event) { var snippet; if (_this.previewing || Mercury.region !== _this) { return; } snippet = jQuery(event.target).closest('[data-snippet]'); if (snippet.length) { _this.snippet = snippet; if (_this.snippet.data('snippet')) { return Mercury.trigger('show:toolbar', { type: 'snippet', snippet: _this.snippet }); } } }); return this.element.on('mouseout', function() { if (_this.previewing) { return; } return Mercury.trigger('hide:toolbar', { type: 'snippet', immediately: false }); }); }; Region.prototype.content = function(value, filterSnippets) { var container, snippet, _i, _len, _ref; if (value == null) { value = null; } if (filterSnippets == null) { filterSnippets = false; } if (value !== null) { return this.element.html(value); } else { container = jQuery('
').appendTo(this.document.createDocumentFragment()); container.html(this.element.html().replace(/^\s+|\s+$/g, '')); if (filterSnippets) { _ref = container.find('[data-snippet]'); for (_i = 0, _len = _ref.length; _i < _len; _i++) { snippet = _ref[_i]; snippet = jQuery(snippet); snippet.attr({ contenteditable: null, 'data-version': null }); snippet.html("[" + (snippet.data('snippet')) + "]"); } } return container.html(); } }; Region.prototype.togglePreview = function() { if (this.previewing) { this.previewing = false; this.element.attr(Mercury.config.regions.attribute, this.type()); if (Mercury.region === this) { return this.focus(); } } else { this.previewing = true; this.element.removeAttr(Mercury.config.regions.attribute); return Mercury.trigger('region:blurred', { region: this }); } }; Region.prototype.execCommand = function(action, options) { if (options == null) { options = {}; } this.focus(); if (action !== 'redo') { this.pushHistory(); } Mercury.log('execCommand', action, options.value); return Mercury.changes = true; }; Region.prototype.pushHistory = function() { return this.history.push(this.content()); }; Region.prototype.snippets = function() { var element, snippet, snippets, _i, _len, _ref; snippets = {}; _ref = this.element.find('[data-snippet]'); for (_i = 0, _len = _ref.length; _i < _len; _i++) { element = _ref[_i]; snippet = Mercury.Snippet.find(jQuery(element).data('snippet')); if (!snippet) { continue; } snippets[snippet.identity] = snippet.serialize(); } return snippets; }; Region.prototype.dataAttributes = function() { var attr, data, _i, _len, _ref; data = {}; _ref = Mercury.config.regions.dataAttributes; for (_i = 0, _len = _ref.length; _i < _len; _i++) { attr = _ref[_i]; data[attr] = (this.container || this.element).attr('data-' + attr); } return data; }; Region.prototype.serialize = function() { return { type: this.type(), data: this.dataAttributes(), value: this.content(null, true), snippets: this.snippets() }; }; return Region; })(); }).call(this); ;FI"required_assets_digest;F"%6cd7dc7eb6143d60afb45525fb23800eI" _version;F"%6776f581a4329e299531e1d52aa59832