o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1388436950.112035: @value"{I" class:EFI"BundledAsset;FI"logical_path;FI"mercury/snippet.js;FI" pathname;FI"‘/Users/jrissler/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/mercury-6daffeeb487e/app/assets/javascripts/mercury/snippet.js.coffee;FI"content_type;FI"application/javascript;FI" mtime;FI"2013-11-20T08:09:45-05:00;FI" length;FiýI" digest;F"%4ee23f465d73745012bdaa73eb5f2764I" source;FI"ý(function() { var __hasProp = {}.hasOwnProperty; this.Mercury.Snippet = (function() { Snippet.all = []; Snippet.displayOptionsFor = function(name, options, displayOptions) { var snippet; if (options == null) { options = {}; } if (displayOptions == null) { displayOptions = true; } if (displayOptions) { Mercury.modal(this.optionsUrl(name), jQuery.extend({ title: 'Snippet Options', handler: 'insertSnippet', snippetName: name, loadType: Mercury.config.snippets.method }, options)); } else { snippet = Mercury.Snippet.create(name); Mercury.trigger('action', { action: 'insertSnippet', value: snippet }); } return Mercury.snippet = null; }; Snippet.optionsUrl = function(name) { var url; url = Mercury.config.snippets.optionsUrl; if (typeof url === 'function') { url = url(); } return url.replace(':name', name); }; Snippet.previewUrl = function(name) { var url; url = Mercury.config.snippets.previewUrl; if (typeof url === 'function') { url = url(); } return url.replace(':name', name); }; Snippet.create = function(name, options) { var instance; instance = new Mercury.Snippet(name, this.uniqueId(), options); this.all.push(instance); return instance; }; Snippet.uniqueId = function() { var i, identities, identity, snippet, _ref; _ref = [0, "snippet_0"], i = _ref[0], identity = _ref[1]; identities = (function() { var _i, _len, _ref1, _results; _ref1 = this.all; _results = []; for (_i = 0, _len = _ref1.length; _i < _len; _i++) { snippet = _ref1[_i]; _results.push(snippet.identity); } return _results; }).call(this); while (identities.indexOf(identity) !== -1) { i += 1; identity = "snippet_" + i; } return identity; }; Snippet.find = function(identity) { var snippet, _i, _len, _ref; _ref = this.all; for (_i = 0, _len = _ref.length; _i < _len; _i++) { snippet = _ref[_i]; if (snippet.identity === identity) { return snippet; } } return null; }; Snippet.load = function(snippets) { var details, identity, instance, _results; _results = []; for (identity in snippets) { if (!__hasProp.call(snippets, identity)) continue; details = snippets[identity]; instance = new Mercury.Snippet(details.name, identity, details); _results.push(this.all.push(instance)); } return _results; }; Snippet.clearAll = function() { delete this.all; return this.all = []; }; function Snippet(name, identity, options) { this.name = name; this.identity = identity; if (options == null) { options = {}; } this.version = 0; this.data = ''; this.wrapperTag = 'div'; this.history = new Mercury.HistoryBuffer(); this.setOptions(options); } Snippet.prototype.getHTML = function(context, callback) { var element; if (callback == null) { callback = null; } element = jQuery("<" + this.wrapperTag + ">", { "class": "" + this.name + "-snippet", contenteditable: "false", 'data-snippet': this.identity, 'data-version': this.version }, context); element.html("[" + this.identity + "]"); this.loadPreview(element, callback); return element; }; Snippet.prototype.getText = function(callback) { return "[--" + this.identity + "--]"; }; Snippet.prototype.loadPreview = function(element, callback) { var _this = this; if (callback == null) { callback = null; } return jQuery.ajax(Snippet.previewUrl(this.name), { headers: Mercury.ajaxHeaders(), type: Mercury.config.snippets.method, data: this.options, success: function(data) { _this.data = data; element.html(data); if (callback) { return callback(); } }, error: function() { return Mercury.notify('Error loading the preview for the \"%s\" snippet.', _this.name); } }); }; Snippet.prototype.displayOptions = function() { Mercury.snippet = this; return Mercury.modal(Snippet.optionsUrl(this.name), { title: 'Snippet Options', handler: 'insertSnippet', loadType: Mercury.config.snippets.method, loadData: this.options }); }; Snippet.prototype.setOptions = function(options) { this.options = options; delete this.options['authenticity_token']; delete this.options['utf8']; if (this.options.wrapperTag) { this.wrapperTag = this.options.wrapperTag; } this.version += 1; return this.history.push(this.options); }; Snippet.prototype.setVersion = function(version) { if (version == null) { version = null; } version = parseInt(version); if (version && this.history.stack[version - 1]) { this.version = version; this.options = this.history.stack[version - 1]; return true; } return false; }; Snippet.prototype.serialize = function() { return $.extend({ name: this.name }, this.options); }; return Snippet; })(); }).call(this); ;FI"required_assets_digest;F"%f780d6987a528a5e294e63fb8431fbbaI" _version;F"%6776f581a4329e299531e1d52aa59832