// Generated by CoffeeScript 1.9.2 (function() { var $, MAX_ZINDEX, util, hasProp = {}.hasOwnProperty, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 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; }; window.Xray = {}; if (!($ = window.jQuery)) { return; } MAX_ZINDEX = 2147483647; Xray.init = (function() { var is_mac; if (Xray.initialized) { return; } Xray.initialized = true; is_mac = navigator.platform.toUpperCase().indexOf('MAC') !== -1; $(document).keydown(function(e) { if ((is_mac && e.metaKey || !is_mac && e.ctrlKey) && e.shiftKey && e.keyCode === 88) { if (Xray.isShowing) { Xray.hide(); } else { Xray.show(); } } if (Xray.isShowing && e.keyCode === 27) { return Xray.hide(); } }); return $(function() { new Xray.Overlay; Xray.findTemplates(); return typeof console !== "undefined" && console !== null ? console.log("Ready to Xray. Press " + (is_mac ? 'cmd+shift+x' : 'ctrl+shift+x') + " to scan your UI.") : void 0; }); })(); Xray.specimens = function() { return Xray.ViewSpecimen.all.concat(Xray.TemplateSpecimen.all); }; Xray.constructorInfo = function(constructor) { var func, info, ref; if (window.XrayPaths) { ref = window.XrayPaths; for (info in ref) { if (!hasProp.call(ref, info)) continue; func = ref[info]; if (func === constructor) { return JSON.parse(info); } } } return null; }; Xray.findTemplates = function() { return util.bm('findTemplates', function() { var $templateContents, _, comment, comments, el, i, id, len, path, ref, results; comments = $('*:not(iframe,script)').contents().filter(function() { return this.nodeType === 8 && this.data.slice(0, 10) === "XRAY START"; }); results = []; for (i = 0, len = comments.length; i < len; i++) { comment = comments[i]; ref = comment.data.match(/^XRAY START (\d+) (.*)$/), _ = ref[0], id = ref[1], path = ref[2]; $templateContents = new jQuery; el = comment.nextSibling; while (!(!el || (el.nodeType === 8 && el.data === ("XRAY END " + id)))) { if (el.nodeType === 1 && el.tagName !== 'SCRIPT') { $templateContents.push(el); } el = el.nextSibling; } if ((el != null ? el.nodeType : void 0) === 8) { el.parentNode.removeChild(el); } comment.parentNode.removeChild(comment); results.push(Xray.TemplateSpecimen.add($templateContents, { name: path.split('/').slice(-1)[0], path: path })); } return results; }); }; Xray.open = function(path) { return $.ajax({ url: "/_xray/open?path=" + path }); }; Xray.show = function(type) { if (type == null) { type = null; } return Xray.Overlay.instance().show(type); }; Xray.hide = function() { return Xray.Overlay.instance().hide(); }; Xray.toggleSettings = function() { return Xray.Overlay.instance().settings.toggle(); }; Xray.Specimen = (function() { Specimen.add = function(el, info) { if (info == null) { info = {}; } return this.all.push(new this(el, info)); }; Specimen.remove = function(el) { var ref; return (ref = this.find(el)) != null ? ref.remove() : void 0; }; Specimen.find = function(el) { var i, len, ref, specimen; if (el instanceof jQuery) { el = el[0]; } ref = this.all; for (i = 0, len = ref.length; i < len; i++) { specimen = ref[i]; if (specimen.el === el) { return specimen; } } return null; }; Specimen.reset = function() { return this.all = []; }; function Specimen(contents, info) { if (info == null) { info = {}; } this.makeLabel = bind(this.makeLabel, this); this.el = contents instanceof jQuery ? contents[0] : contents; this.$contents = $(contents); this.name = info.name; this.path = info.path; } Specimen.prototype.remove = function() { var idx; idx = this.constructor.all.indexOf(this); if (idx !== -1) { return this.constructor.all.splice(idx, 1); } }; Specimen.prototype.isVisible = function() { return this.$contents.length && this.$contents.is(':visible'); }; Specimen.prototype.makeBox = function() { this.bounds = util.computeBoundingBox(this.$contents); this.$box = $("