Advertisement
Guest User

Angular inspector

a guest
Aug 24th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function () {
  2.   var emptyFunc = function () { return null; };
  3.   window.pager = { get: emptyFunc, set: emptyFunc, params: { toggle: emptyFunc } };
  4.   //window.modules = { all: {} };
  5.   function addElToBody(tagName, props) {
  6.     var propName, el = document.createElement(tagName);
  7.     for (propName in props) {
  8.       el[propName] = props[propName];
  9.     }
  10.     document.body.appendChild(el);
  11.   }
  12.   var libName, libs = {
  13.     _: "//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js",
  14.     jQuery: "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js",
  15.     // sugar: "//cdnjs.cloudflare.com/ajax/libs/sugar/1.4.1/sugar.min.js"
  16.   };
  17.   for (libName in libs) {
  18.     if (!window[libName]) {
  19.       addElToBody('script', {
  20.         src: libs[libName]
  21.       });
  22.     }
  23.   }
  24.   document.body.style.margin = 0;
  25.   if (!document.querySelector('#layers')) {
  26.     addElToBody('div', {
  27.       'id': 'layers',
  28.       'style': "width:100%; height:100%;"
  29.     });
  30.   }
  31.   function initAllModules(){
  32.     window['require'] = {};
  33.  
  34.  
  35.   require.str = (function str (require) {Object.defineProperty(this, 'module_name', {value:'str'});
  36.     var ifs;
  37.  
  38.     this["if"] = ifs = function(arg, true_str, false_str) {
  39.       if (true_str == null) {
  40.         true_str = arg;
  41.       }
  42.       if (arg) {
  43.         return true_str;
  44.       } else {
  45.         if (false_str != null) {
  46.           return false_str;
  47.         } else {
  48.           return '';
  49.         }
  50.       }
  51.     };
  52.  
  53.     this.capitalize = function(str) {
  54.       return str[0].toUpperCase() + str.slice(1);
  55.     };
  56.  
  57.     this.dasherize = function(str) {
  58.       return str.replace(/([A-Z])/g, function(full, match) {
  59.         return '-' + match.toLowerCase();
  60.       }).replace(/ /g, '-');
  61.     };
  62.  
  63.     this.parsesToNumber = this.isNumber = function(str) {
  64.       return !Number.isNaN(parseInt(str));
  65.     };
  66.  
  67.     this.truncate = function(str, limit, truncStr) {
  68.       if (truncStr == null) {
  69.         truncStr = '...';
  70.       }
  71.       if (str.length > limit) {
  72.         return str.slice(0, limit) + truncStr;
  73.       } else {
  74.         return str;
  75.       }
  76.     };
  77.  
  78.     this.titleize = this.titelize = function(str) {
  79.       return str.replace(/[-_]/g, ' ').replace(/(^| )(\w)/g, function(full, s, firstChar) {
  80.         return s + firstChar.toUpperCase();
  81.       }).replace(/(\w)([A-Z])/g, function(f, s, c) {
  82.         return s + ' ' + c;
  83.       });
  84.     };
  85.  
  86.     this.random = function(limit) {
  87.       if (limit == null) {
  88.         limit = 20;
  89.       }
  90.       return (Math.random() + '').slice(2, +(limit + 1) + 1 || 9e9);
  91.     };
  92.  
  93.     this.remove = function(full, remove) {
  94.       return full.replace(remove, '');
  95.     };
  96.  
  97.     this.reverse = function(str) {
  98.       return str.split("").reverse().join('');
  99.     };
  100.  
  101.     return this;
  102.     }).call({}, require);
  103.     //# sourceURL=str-143
  104.  
  105.   require.html = (function html (require) {Object.defineProperty(this, 'module_name', {value:'html'});
  106.     this.eventAttrs = ['onKeyDown', 'onKeyUp', 'onKeyPress', 'onClick', 'onDoubleClick', 'onBlur', 'onFocus', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseDown', 'onMouseUp', 'onChange', 'onInput', 'onSubmit', 'onDragEnter', 'onDragExit', 'onDragLeave', 'onDragOver', 'onDrag', 'onDragEnd', 'onDragStart', 'onDrop', 'onResize'];
  107.  
  108.     this.standardAttrs = ["accept", "action", "alt", "async", "checked", "class", "cols", "content", "controls", "coords", "data", "defer", "dir", "disabled", "download", "draggable", "form", "height", "hidden", "href", "icon", "id", "lang", "list", "loop", "manifest", "max", "media", "method", "min", "multiple", "muted", "name", "open", "pattern", "placeholder", "poster", "preload", "rel", "required", "role", "rows", "sandbox", "scope", "scrolling", "seamless", "selected", "shape", "size", "sizes", "spellcheck", "src", "start", "step", "style", "target", "title", "type", "value", "width", "wmode"];
  109.  
  110.     this.standardTags = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr'];
  111.  
  112.     this.condenseTags = function(htmlStr) {
  113.       return htmlStr.replace(/>( |\n)+<(\w)/g, function(full, content, char) {
  114.         return '><' + char;
  115.       });
  116.     };
  117.  
  118.     this.prettify = function(htmlStr) {
  119.       var indent;
  120.       if (htmlStr instanceof Element) {
  121.         htmlStr = htmlStr.outerHTML;
  122.       }
  123.       indent = '';
  124.       return htmlStr.replace(/<(\/)?[^>]+>/g, function(full, closing, pos) {
  125.         var followingIsClosing, indentBeg, res;
  126.         indentBeg = indent;
  127.         if (closing) {
  128.           followingIsClosing = htmlStr.slice(pos + full.length, +(pos + full.length + 1) + 1 || 9e9) === '</';
  129.           indent = indent.substr(2);
  130.           res = full + require.str["if"](followingIsClosing, "\n" + indent);
  131.         } else {
  132.           indent += '  ';
  133.           res = "\n" + indent + full;
  134.         }
  135.         return res;
  136.       });
  137.     };
  138.  
  139.     return this;
  140.     }).call({}, require);
  141.     //# sourceURL=html-144
  142.  
  143.   require.typeof = (function  (require) {Object.defineProperty(this, 'module_name', {value:'typeof'});
  144.     123;
  145.     return function(arg) {
  146.       var type;
  147.       type = typeof arg;
  148.       if (type === 'object') {
  149.         if (arg instanceof Array || ArrayBuffer.isView(arg)) {
  150.           return 'array';
  151.         }
  152.         if (arg === null) {
  153.           return 'null';
  154.         }
  155.       }
  156.       return type;
  157.     };
  158.  
  159.     return this;
  160.     }).call({}, require);
  161.     //# sourceURL=typeof-145
  162.  
  163.   require.argumentTypes = (function argumentTypes (require) {Object.defineProperty(this, 'module_name', {value:'argumentTypes'});
  164.     var defaultMapping;
  165.  
  166.     defaultMapping = {
  167.       string: 'str',
  168.       number: 'num',
  169.       object: 'obj',
  170.       array: 'arr',
  171.       boolean: 'boo',
  172.       "function": 'fun',
  173.       undefined: 'nil',
  174.       "null": 'nil'
  175.     };
  176.  
  177.     return function(args, typeMapping, defaultValues) {
  178.       var arg, argTypes, current, i, key, len, ref, ref1, typeName, val;
  179.       if (typeMapping == null) {
  180.         typeMapping = defaultMapping;
  181.       }
  182.       argTypes = {};
  183.       for (i = 0, len = args.length; i < len; i++) {
  184.         arg = args[i];
  185.         typeName = (ref = (ref1 = typeMapping[require["typeof"](arg)]) != null ? ref1 : typeMapping["default"]) != null ? ref : 'default';
  186.         if (current = argTypes[typeName]) {
  187.           if (Array.isArray(current)) {
  188.             current.push(arg);
  189.           } else {
  190.             argTypes[typeName] = [argTypes[typeName], arg];
  191.           }
  192.         } else {
  193.           argTypes[typeName] = arg;
  194.         }
  195.       }
  196.       for (key in defaultValues) {
  197.         val = defaultValues[key];
  198.         if (argTypes[key] == null) {
  199.           argTypes[key] = val;
  200.         }
  201.       }
  202.       return argTypes;
  203.     };
  204.  
  205.     return this;
  206.     }).call({}, require);
  207.     //# sourceURL=argumentTypes-146
  208.  
  209.   require.assert = (function assert (require) {Object.defineProperty(this, 'module_name', {value:'assert'});
  210.     var argMapping, assert;
  211.  
  212.     argMapping = {
  213.       "function": 'testFunc',
  214.       string: 'errorMessage',
  215.       "default": 'result'
  216.     };
  217.  
  218.     return assert = function() {
  219.       var errorMessage, ref, result, testFunc;
  220.       if (arguments.length > 2) {
  221.         throw 'depracated assert call';
  222.       }
  223.       ref = require.argumentTypes(arguments, argMapping), result = ref.result, testFunc = ref.testFunc, errorMessage = ref.errorMessage;
  224.       if (testFunc) {
  225.         result = testFunc();
  226.       }
  227.       if (!result) {
  228.         throw Error("assert failed: '" + errorMessage + "'");
  229.       }
  230.     };
  231.  
  232.     return this;
  233.     }).call({}, require);
  234.     //# sourceURL=assert-147
  235.  
  236.   require.object = (function object (require) {Object.defineProperty(this, 'module_name', {value:'object'});
  237.     var identity,
  238.       slice = [].slice;
  239.  
  240.     identity = function(el) {
  241.       return el;
  242.     };
  243.  
  244.     this.clone = typeof _ !== "undefined" && _ !== null ? _.clone : void 0;
  245.  
  246.     this.isEqual = typeof _ !== "undefined" && _ !== null ? _.isEqual : void 0;
  247.  
  248.     this.dellAll = function(obj) {
  249.       var key;
  250.       for (key in obj) {
  251.         delete obj[key];
  252.       }
  253.     };
  254.  
  255.     this.filter = function(obj, filterer) {
  256.       var filtered, key, val;
  257.       filtered = {};
  258.       for (key in obj) {
  259.         val = obj[key];
  260.         if (filterer(key, val)) {
  261.           filtered[key] = val;
  262.         }
  263.       }
  264.       return filtered;
  265.     };
  266.  
  267.     this.forEach = function(obj, func) {
  268.       var key, val;
  269.       for (key in obj) {
  270.         val = obj[key];
  271.         func(val, key);
  272.       }
  273.     };
  274.  
  275.     this.fromArray = function(array, valFromEl, keyFromEl) {
  276.       var el, i, ind, len, obj;
  277.       if (valFromEl == null) {
  278.         valFromEl = identity;
  279.       }
  280.       if (keyFromEl == null) {
  281.         keyFromEl = identity;
  282.       }
  283.       obj = {};
  284.       for (ind = i = 0, len = array.length; i < len; ind = ++i) {
  285.         el = array[ind];
  286.         obj[keyFromEl(el, ind)] = valFromEl(el, ind);
  287.       }
  288.       return obj;
  289.     };
  290.  
  291.     this.isObject = function(o) {
  292.       return typeof o === 'object' && !Array.isArray(o) && o !== null;
  293.     };
  294.  
  295.     this.map = function(obj, mapFuncs) {
  296.       var key, newObj, val;
  297.       require.assert("'mapFuncs' argument should include 'key' and/or 'val' transform functions", (mapFuncs.key != null) || (mapFuncs.val != null));
  298.       if (mapFuncs.key == null) {
  299.         mapFuncs.key = identity;
  300.       }
  301.       if (mapFuncs.val == null) {
  302.         mapFuncs.val = identity;
  303.       }
  304.       newObj = {};
  305.       for (key in obj) {
  306.         val = obj[key];
  307.         newObj[mapFuncs.key(key, val)] = mapFuncs.val(val, key);
  308.       }
  309.       return newObj;
  310.     };
  311.  
  312.     this.merge = function() {
  313.       var first, i, key, len, obj, rest, val;
  314.       first = arguments[0], rest = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  315.       for (i = 0, len = rest.length; i < len; i++) {
  316.         obj = rest[i];
  317.         for (key in obj) {
  318.           val = obj[key];
  319.           first[key] = val;
  320.         }
  321.       }
  322.       return first;
  323.     };
  324.  
  325.     this.mergeWary = function() {
  326.       var first, i, key, len, obj, rest, val;
  327.       first = arguments[0], rest = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  328.       for (i = 0, len = rest.length; i < len; i++) {
  329.         obj = rest[i];
  330.         for (key in obj) {
  331.           val = obj[key];
  332.           if (first[key] == null) {
  333.             first[key] = val;
  334.           }
  335.         }
  336.       }
  337.       return first;
  338.     };
  339.  
  340.     this.mergeDeep = function(target, source) {
  341.       var key, targetProp, val;
  342.       for (key in source) {
  343.         val = source[key];
  344.         targetProp = target[key];
  345.         if (this.isObject(targetProp) && this.isObject(val)) {
  346.           this.mergeDeep(targetProp, val);
  347.         } else {
  348.           target[key] = val;
  349.         }
  350.       }
  351.       return target;
  352.     };
  353.  
  354.     this.eachDeep = function(rootObj, func, filter) {
  355.       var depth, hasBeenExecuted, iterator;
  356.       if (filter == null) {
  357.         filter = function() {
  358.           return true;
  359.         };
  360.       }
  361.       depth = 1;
  362.       hasBeenExecuted = new Map;
  363.       iterator = function(obj, parent) {
  364.         var key, val;
  365.         if (hasBeenExecuted.get(obj)) {
  366.           return;
  367.         }
  368.         hasBeenExecuted.set(obj, true);
  369.         for (key in obj) {
  370.           val = obj[key];
  371.           if (!(filter(key, val, depth))) {
  372.             continue;
  373.           }
  374.           if (typeof val === 'object') {
  375.             depth++;
  376.             iterator(val, obj);
  377.             depth--;
  378.           }
  379.           func(key, val, parent);
  380.         }
  381.       };
  382.       iterator(rootObj);
  383.     };
  384.  
  385.     this.select = function(obj, keysArr) {
  386.       var i, key, len, newObj;
  387.       newObj = {};
  388.       for (i = 0, len = keysArr.length; i < len; i++) {
  389.         key = keysArr[i];
  390.         newObj[key] = obj[key];
  391.       }
  392.       return newObj;
  393.     };
  394.  
  395.     this.values = function(obj) {
  396.       var k, results, value;
  397.       results = [];
  398.       for (k in obj) {
  399.         value = obj[k];
  400.         results.push(value);
  401.       }
  402.       return results;
  403.     };
  404.  
  405.     return this;
  406.     }).call({}, require);
  407.     //# sourceURL=object-148
  408.  
  409.   require.create_html_node = (function create_html_node (require) {Object.defineProperty(this, 'module_name', {value:'create_html_node'});
  410.     var create_html_node;
  411.  
  412.     return create_html_node = function(sKey) {
  413.       var classes, domElName, el, idName, ref, ref1, ref2;
  414.       if (sKey == null) {
  415.         sKey = 'div';
  416.       }
  417.       domElName = ((ref = sKey.match(/^(h[1-6]|[^ #._0123456789]+)\d?/)) != null ? ref[1] : void 0) || 'div';
  418.       idName = (ref1 = sKey.match(/#[^ ]+/)) != null ? ref1[0].slice(1) : void 0;
  419.       classes = (ref2 = sKey.match(/\.[^ #.]+/g)) != null ? ref2.map(function(cStr) {
  420.         return cStr.slice(1);
  421.       }) : void 0;
  422.       el = document.createElement(domElName);
  423.       if (idName != null) {
  424.         el.id = idName;
  425.       }
  426.       if (classes != null ? classes.length : void 0) {
  427.         el.setAttribute('class', classes.join(' '));
  428.       }
  429.       return el;
  430.     };
  431.  
  432.     return this;
  433.     }).call({}, require);
  434.     //# sourceURL=create_html_node-149
  435.  
  436.   require.node_from_obj = (function node_from_obj (require) {Object.defineProperty(this, 'module_name', {value:'node_from_obj'});
  437.     var allAttrActions, defaultAction, defaultAttrsMap, eventAction, eventAttrsMap, iterate, node_from_obj, specialAttrsMap, stackDepth;
  438.  
  439.     eventAction = function(attrName, attrVal, node) {
  440.       var eventName;
  441.       eventName = attrName.toLowerCase().slice(2);
  442.       node.addEventListener(eventName, attrVal, false);
  443.       if (node.listeners == null) {
  444.         node.listeners = {};
  445.       }
  446.       if (node.listeners[attrName] != null) {
  447.         throw "Event system don't allow binding two events of same type to same node";
  448.       }
  449.       return node.listeners[eventName] = attrVal;
  450.     };
  451.  
  452.     defaultAction = function(attrName, attrVal, node) {
  453.       if (attrVal != null) {
  454.         return node.setAttribute(attrName, attrVal);
  455.       }
  456.     };
  457.  
  458.     defaultAttrsMap = require.object.fromArray(require.html.standardAttrs, function() {
  459.       return defaultAction;
  460.     });
  461.  
  462.     eventAttrsMap = require.object.fromArray(require.html.eventAttrs, function() {
  463.       return eventAction;
  464.     });
  465.  
  466.     specialAttrsMap = {
  467.       raw: function(attrName, attrVal, node) {
  468.         return node.innerHTML = attrVal;
  469.       },
  470.       text: function(attrName, attrVal, node) {
  471.         return node.textContent = attrVal;
  472.       }
  473.     };
  474.  
  475.     allAttrActions = require.object.merge(defaultAttrsMap, eventAttrsMap);
  476.  
  477.     require.object.merge(allAttrActions, specialAttrsMap);
  478.  
  479.     stackDepth = 0;
  480.  
  481.     iterate = function(node, val) {
  482.       var attrName, i, key, len, nonStandard, subVal, tag;
  483.       if (val == null) {
  484.         return node;
  485.       }
  486.       if (stackDepth > 100) {
  487.         stackDepth = 0;
  488.         throw "node_from_obj stack depth > 100; endless loop?";
  489.       }
  490.       stackDepth++;
  491.       if (typeof val === 'function') {
  492.         val = val(node);
  493.         if (val === node) {
  494.           return;
  495.         }
  496.       }
  497.       if (val instanceof Array) {
  498.         for (i = 0, len = val.length; i < len; i++) {
  499.           subVal = val[i];
  500.           iterate(node, subVal);
  501.         }
  502.       } else if (val instanceof Node) {
  503.         node.appendChild(val);
  504.       } else if (typeof val === 'object') {
  505.         for (key in val) {
  506.           subVal = val[key];
  507.           if (allAttrActions[key] || (nonStandard = /^\w*[A-Z]/.test(key))) {
  508.             if (node.setAttribute == null) {
  509.               throw new Error("Can't set attributes ('" + key + "') for root list (" + key + ")");
  510.             }
  511.             if (nonStandard) {
  512.               attrName = key.replace(/[A-Z]/g, function(match, ind) {
  513.                 return (require.str["if"](ind !== 0, '-')) + match.toLowerCase();
  514.               });
  515.               defaultAction(attrName, subVal, node);
  516.               nonStandard = null;
  517.             } else {
  518.               allAttrActions[key](key, subVal, node);
  519.             }
  520.           } else if (key.match(/^me[0-9]?$/)) {
  521.             iterate(node, subVal);
  522.           } else {
  523.             tag = require.create_html_node(key);
  524.             iterate(tag, subVal);
  525.             node.appendChild(tag);
  526.           }
  527.         }
  528.       } else {
  529.         node.textContent = val;
  530.       }
  531.       stackDepth--;
  532.       return node;
  533.     };
  534.  
  535.     return node_from_obj = function(tmplObj) {
  536.       var fragment;
  537.       fragment = iterate(document.createDocumentFragment(), tmplObj);
  538.       return fragment;
  539.     };
  540.  
  541.     return this;
  542.     }).call({}, require);
  543.     //# sourceURL=node_from_obj-150
  544.  
  545.   require.dom = (function dom (require) {Object.defineProperty(this, 'module_name', {value:'dom'});
  546.     this.addChilds = function(node, children) {
  547.       var child, i, len, results;
  548.       results = [];
  549.       for (i = 0, len = children.length; i < len; i++) {
  550.         child = children[i];
  551.         results.push(node.appendChild(child));
  552.       }
  553.       return results;
  554.     };
  555.  
  556.     this.getAttr = function(node, attrName) {
  557.       var val;
  558.       val = node.attributes.getNamedItem(attrName).value;
  559.       if (require.str.parsesToNumber(val)) {
  560.         return parseFloat(val);
  561.       } else {
  562.         return val;
  563.       }
  564.     };
  565.  
  566.     this.get = function(selector, parentEl) {
  567.       if (parentEl == null) {
  568.         parentEl = document;
  569.       }
  570.       return parentEl.querySelector(selector);
  571.     };
  572.  
  573.     this.getAll = function(selector, parentEl) {
  574.       if (parentEl == null) {
  575.         parentEl = document;
  576.       }
  577.       return parentEl.querySelectorAll(selector);
  578.     };
  579.  
  580.     this.fragment = document.createDocumentFragment.bind(document);
  581.  
  582.     this["new"] = function(type_id_class, props) {
  583.       var el;
  584.       if (typeof type_id_class === 'object') {
  585.         return (require.node_from_obj(type_id_class)).childNodes[0];
  586.       }
  587.       el = require.create_html_node(type_id_class);
  588.       switch (typeof props) {
  589.         case 'string':
  590.           el.innerHTML = props;
  591.           break;
  592.         case 'object':
  593.           if (props) {
  594.             require.object.merge(el, props);
  595.           }
  596.       }
  597.       return el;
  598.     };
  599.  
  600.     this.append = this.addTo = function(parent_element, content) {
  601.       if (typeof content === 'object') {
  602.         content = require.node_from_obj(content);
  603.       }
  604.       parent_element.appendChild(content);
  605.       return content;
  606.     };
  607.  
  608.     this.prepend = function(parentEl, content) {
  609.       if (typeof content === 'object') {
  610.         content = require.node_from_obj(content);
  611.       }
  612.       return parentEl.insertBefore(content, parentEl.firstChild);
  613.     };
  614.  
  615.     this.remove = function(element) {
  616.       var parentEl;
  617.       if (typeof element === 'string') {
  618.         element = this.get(element);
  619.       }
  620.       if ((parentEl = element != null ? element.parentElement : void 0) != null) {
  621.         return parentEl.removeChild(element);
  622.       } else {
  623.         return console.info("failed to remove node", element);
  624.       }
  625.     };
  626.  
  627.     this.removeChildren = function(node) {
  628.       var results;
  629.       results = [];
  630.       while (node.firstChild) {
  631.         results.push(node.removeChild(node.firstChild));
  632.       }
  633.       return results;
  634.     };
  635.  
  636.     this.render = function(node, htmlObj) {
  637.       console.warn(":dom.render will deprecate");
  638.       this.removeChildren(node);
  639.       return node.appendChild(require.node_from_obj(htmlObj));
  640.     };
  641.  
  642.     this.replaceChildren = this.replaceChilds = function(node, newContent) {
  643.       this.removeChildren(node);
  644.       return this.append(node, newContent);
  645.     };
  646.  
  647.     this.replace = function(oldEl, newEl) {
  648.       var parentEl;
  649.       if (typeof newEl === 'object') {
  650.         newEl = require.node_from_obj(newEl);
  651.       }
  652.       if ((parentEl = oldEl.parentElement) != null) {
  653.         parentEl.replaceChild(newEl, oldEl);
  654.       } else {
  655.         console.info("failed to replace node", newEl, oldEl);
  656.       }
  657.       return newEl;
  658.     };
  659.  
  660.     return this;
  661.     }).call({}, require);
  662.     //# sourceURL=dom-151
  663.  
  664.   require.array = (function array (require) {Object.defineProperty(this, 'module_name', {value:'array'});
  665.     var flatten;
  666.  
  667.     this.includes = this.contains = this.has = function(arr, el) {
  668.       return arr.indexOf(el) !== -1;
  669.     };
  670.  
  671.     this.toObject = function(array, val_from_el, key_from_el) {
  672.       var el, i, ind, len, obj;
  673.       console.warn(":array.toObject will deprecate, use \:object.fromArray");
  674.       obj = {};
  675.       if (key_from_el == null) {
  676.         key_from_el = function(el) {
  677.           return el;
  678.         };
  679.       }
  680.       for (ind = i = 0, len = array.length; i < len; ind = ++i) {
  681.         el = array[ind];
  682.         obj[key_from_el(el, ind)] = val_from_el(el, ind);
  683.       }
  684.       return obj;
  685.     };
  686.  
  687.     this.toArray = function(arrayish) {
  688.       return Array.prototype.slice.call(arrayish);
  689.     };
  690.  
  691.     this.diff = function(arrA, arrB) {
  692.       var diff, el, i, len, unchecked;
  693.       unchecked = arrB.slice(0);
  694.       diff = [];
  695.       for (i = 0, len = arrA.length; i < len; i++) {
  696.         el = arrA[i];
  697.         if (arrB.indexOf(el) !== -1) {
  698.           this.remove(unchecked, el);
  699.         } else {
  700.           diff.push(el);
  701.         }
  702.       }
  703.       return diff.concat(unchecked);
  704.     };
  705.  
  706.     this.flatten = flatten = function(arr) {
  707.       return arr.reduce((function(a, b) {
  708.         return a.concat(Array.isArray(b) ? flatten(b) : b);
  709.       }), []);
  710.     };
  711.  
  712.     this.last = this.lastOf = function(arr) {
  713.       return arr[arr.length - 1];
  714.     };
  715.  
  716.     this.setLastOf = function(arr, newVal) {
  717.       return arr[arr.length - 1] = newVal;
  718.     };
  719.  
  720.     this.pushArray = function(arr, arr2) {
  721.       return arr.push.apply(arr, arr2);
  722.     };
  723.  
  724.     this.remove = function(arr, el) {
  725.       var ind;
  726.       if ((ind = arr.indexOf(el)) !== -1) {
  727.         arr.splice(ind, 1);
  728.       }
  729.       return arr;
  730.     };
  731.  
  732.     this.count = function(arr, filterFunc) {
  733.       var count, e, filterEl, i, len;
  734.       if (typeof filterFunc !== 'function') {
  735.         filterEl = filterFunc;
  736.         filterFunc = function(e) {
  737.           return e === filterEl;
  738.         };
  739.       }
  740.       count = 0;
  741.       for (i = 0, len = arr.length; i < len; i++) {
  742.         e = arr[i];
  743.         if (filterFunc(e)) {
  744.           count++;
  745.         }
  746.       }
  747.       return count;
  748.     };
  749.  
  750.     return this;
  751.     }).call({}, require);
  752.     //# sourceURL=array-152
  753.  
  754.   require.events = (function events (require) {Object.defineProperty(this, 'module_name', {value:'events'});
  755.     var slice = [].slice;
  756.  
  757.     this.initChild = function(childObj, logEvents) {
  758.       if (childObj !== this) {
  759.         Object.setPrototypeOf(childObj, this);
  760.       }
  761.       if (childObj.listeners == null) {
  762.         childObj.listeners = {};
  763.       }
  764.       if (childObj.listenersFired == null) {
  765.         childObj.listenersFired = {};
  766.       }
  767.       if (logEvents) {
  768.         return childObj.logs = [];
  769.       }
  770.     };
  771.  
  772.     this.on = function() {
  773.       var base, callback, eventNames, i, j, len, name;
  774.       eventNames = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), callback = arguments[i++];
  775.       for (j = 0, len = eventNames.length; j < len; j++) {
  776.         name = eventNames[j];
  777.         if ((base = this.listeners)[name] == null) {
  778.           base[name] = [];
  779.         }
  780.         if (this.listeners[name].indexOf(callback) === -1) {
  781.           this.listeners[name].push(callback);
  782.         }
  783.       }
  784.     };
  785.  
  786.     this.onFirst = function(name, cb) {
  787.       if (this.listenersFired[name]) {
  788.         return cb.apply(null, this.listenersFired[name]);
  789.       } else {
  790.         return this.on(name, function() {
  791.           cb.apply(null, arguments);
  792.           return false;
  793.         });
  794.       }
  795.     };
  796.  
  797.     this.bindUnloading = function() {};
  798.  
  799.     this.emit = function() {
  800.       var args, callback, i, len, name, ref, remove;
  801.       name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  802.       if (this.logs) {
  803.         this.logs.push([name, Date.now(), args, this.listeners[name] != null]);
  804.       }
  805.       this.listenersFired[name] = args;
  806.       if (this.listeners[name] == null) {
  807.         return console.log("Event '" + name + "' emitted, but no one is listening!");
  808.       }
  809.       remove = [];
  810.       ref = this.listeners[name];
  811.       for (i = 0, len = ref.length; i < len; i++) {
  812.         callback = ref[i];
  813.         if ((callback.apply(null, args)) === false) {
  814.           remove.push(callback);
  815.         }
  816.       }
  817.       if (remove.length) {
  818.         this.listeners[name] = this.listeners[name].filter(function(cb) {
  819.           return remove.indexOf(cb) === -1;
  820.         });
  821.       }
  822.     };
  823.  
  824.     this.removeListener = function(name, func) {
  825.       return require.array.remove(this.listeners[name], func);
  826.     };
  827.  
  828.     this.stats = function() {
  829.       var hits, i, len, log, misses, name1, ref, target;
  830.       if (this.logs == null) {
  831.         return console.warn(":events @logs need to be on, to show stats");
  832.       }
  833.       hits = {};
  834.       misses = {};
  835.       ref = this.logs;
  836.       for (i = 0, len = ref.length; i < len; i++) {
  837.         log = ref[i];
  838.         target = log[3] ? hits : misses;
  839.         if (target[name1 = log[0]] == null) {
  840.           target[name1] = 0;
  841.         }
  842.         target[log[0]] += 1;
  843.       }
  844.       return {
  845.         hits: hits,
  846.         misses: misses
  847.       };
  848.     };
  849.  
  850.     return this;
  851.     }).call({}, require);
  852.     //# sourceURL=events-153
  853.  
  854.   require.editor_events = (function editor_events (require) {Object.defineProperty(this, 'module_name', {value:'editor_events'});
  855.     require.events.initChild(this, true);
  856.  
  857.     window.addEventListener('unload', (this.unloadEditor != null ? this.unloadEditor : this.unloadEditor = (function(_this) {
  858.       return function(ev) {
  859.         return _this.emit('editor_removed', ev);
  860.       };
  861.     })(this)));
  862.  
  863.     this.safe = function() {};
  864.  
  865.     return this;
  866.     }).call({}, require);
  867.     //# sourceURL=editor_events-154
  868.  
  869.   require.pager = (function pager (require) {Object.defineProperty(this, 'module_name', {value:'pager'});
  870.     var slice = [].slice;
  871.  
  872.     require.events.initChild(this, true);
  873.  
  874.     this.defaultPage = 'edit';
  875.  
  876.     this.defaultParams = {
  877.       '0': 'front_page',
  878.       '1': 'fullscreen'
  879.     };
  880.  
  881.     this.useHashUrl = true;
  882.  
  883.     if (this.page == null) {
  884.       this.page = null;
  885.     }
  886.  
  887.     if (this.params == null) {
  888.       this.params = {};
  889.     }
  890.  
  891.     if (this.skipEvent == null) {
  892.       this.skipEvent = false;
  893.     }
  894.  
  895.     if (this.initialized == null) {
  896.       this.initialized = false;
  897.     }
  898.  
  899.     this.parseRootAndParams = function(str) {
  900.       var aParams, i, k, keyInd, len, oParams, ref, ref1, rootName, sParam, v;
  901.       ref = str.split('/'), rootName = ref[0], aParams = 2 <= ref.length ? slice.call(ref, 1) : [];
  902.       oParams = {};
  903.       keyInd = 0;
  904.       for (i = 0, len = aParams.length; i < len; i++) {
  905.         sParam = aParams[i];
  906.         ref1 = sParam.split('='), k = ref1[0], v = ref1[1];
  907.         if (v != null) {
  908.           oParams[k] = v;
  909.         } else {
  910.           oParams[keyInd++] = k;
  911.         }
  912.       }
  913.       return [rootName, oParams];
  914.     };
  915.  
  916.     if (this.urlChecker == null) {
  917.       this.urlChecker = (function(_this) {
  918.         return function() {
  919.           var i, isDiff, key, len, oldPage, oldParams, paramKeys, ref, ref1, urlPath, valueName;
  920.           if (_this.skipEvent) {
  921.             _this.skipEvent = false;
  922.             return;
  923.           }
  924.           urlPath = window.location.hash.replace(/#\/?/, '').replace(/\/$/, '');
  925.           ref = [_this.page, require.object.clone(_this.params)], oldPage = ref[0], oldParams = ref[1];
  926.           ref1 = _this.parseRootAndParams(urlPath), _this.page = ref1[0], _this.params = ref1[1];
  927.           if (!_this.page.length) {
  928.             _this.page = _this.defaultPage;
  929.           }
  930.           if (_this.params[0] == null) {
  931.             _this.params = _this.defaultParams;
  932.           }
  933.           if (_this.page !== oldPage) {
  934.             _this.emit('pageChanged', _this.page, oldPage);
  935.           }
  936.           paramKeys = _.uniq(Object.keys(oldParams).concat(Object.keys(_this.params)));
  937.           for (i = 0, len = paramKeys.length; i < len; i++) {
  938.             key = paramKeys[i];
  939.             if (_this.params[key] !== oldParams[key]) {
  940.               _this.emit('changed:' + key, _this.params[key], oldParams[key]);
  941.               if (require.str.parsesToNumber(key)) {
  942.                 valueName = _this.params[key] || oldParams[key];
  943.                 _this.emit('changed:' + valueName, !!_this.params[key]);
  944.               }
  945.               isDiff = true;
  946.             }
  947.           }
  948.         };
  949.       })(this);
  950.     }
  951.  
  952.     if (this.useHashUrl) {
  953.       window.addEventListener('hashchange', this.urlChecker);
  954.       require.editor_events.onFirst('codemirror_initialized', this.urlChecker);
  955.     }
  956.  
  957.     this.unload = function(parentName, final) {
  958.       if (final) {
  959.         return window.removeEventListener('hashchange', this.urlChecker);
  960.       }
  961.     };
  962.  
  963.     this.setPath = function(pathStr) {
  964.       if (this.useHashUrl) {
  965.         window.location.hash = '/' + pathStr;
  966.       }
  967.     };
  968.  
  969.     this.updateUrl = function(newParams, newPage) {
  970.       if (newParams == null) {
  971.         newParams = this.params;
  972.       }
  973.       if (newPage == null) {
  974.         newPage = this.page;
  975.       }
  976.       this.setPath(newPage + '/' + this.paramsAsStrArr(newParams).join('/'));
  977.     };
  978.  
  979.     this.paramsAsStrArr = function(params) {
  980.       var pName, pVal, results;
  981.       results = [];
  982.       for (pName in params) {
  983.         pVal = params[pName];
  984.         if (isNaN(pName - 0)) {
  985.           results.push(pName + "=" + pVal);
  986.         } else {
  987.           results.push(pVal);
  988.         }
  989.       }
  990.       return results;
  991.     };
  992.  
  993.     this.get = this.getParam = function(name) {
  994.       var key, ref, val;
  995.       if (this.params[name] != null) {
  996.         return decodeURIComponent(this.params[name]);
  997.       } else {
  998.         ref = this.params;
  999.         for (key in ref) {
  1000.           val = ref[key];
  1001.           if (!isNaN(key - 0)) {
  1002.             if (val === name) {
  1003.               return true;
  1004.             }
  1005.           }
  1006.         }
  1007.       }
  1008.     };
  1009.  
  1010.     this.set = this.setParam = function(name, value, skipEvent) {
  1011.       var newParams;
  1012.       this.skipEvent = skipEvent;
  1013.       newParams = require.object.clone(this.params);
  1014.       if (value == null) {
  1015.         if (this.getParam(name)) {
  1016.           return;
  1017.         }
  1018.         value = name;
  1019.         name = Object.keys(newParams).length;
  1020.       }
  1021.       newParams[name] = value;
  1022.       this.updateUrl(newParams);
  1023.       return value;
  1024.     };
  1025.  
  1026.     this.remove = this.removeParam = function(name, skipEvent) {
  1027.       var key, newParams, val;
  1028.       this.skipEvent = skipEvent;
  1029.       newParams = require.object.clone(this.params);
  1030.       if (newParams[name] != null) {
  1031.         delete newParams[name];
  1032.       } else {
  1033.         for (key in newParams) {
  1034.           val = newParams[key];
  1035.           if (!isNaN(key - 0)) {
  1036.             if (name === val) {
  1037.               delete newParams[key];
  1038.             }
  1039.           }
  1040.         }
  1041.       }
  1042.       this.updateUrl(newParams);
  1043.     };
  1044.  
  1045.     this.toggle = this.toggleParam = function(name) {
  1046.       if (this.getParam(name)) {
  1047.         return this.removeParam(name);
  1048.       } else {
  1049.         return this.setParam(name);
  1050.       }
  1051.     };
  1052.  
  1053.     return this;
  1054.     }).call({}, require);
  1055.     //# sourceURL=pager-155
  1056.  
  1057.   require.module = (function module (require) {Object.defineProperty(this, 'module_name', {value:'module'});
  1058.     this.getBase = this.getId = this.getName = function(nameOrMod) {
  1059.       if (typeof nameOrMod === 'string') {
  1060.         return nameOrMod;
  1061.       } else {
  1062.         return nameOrMod.module_name;
  1063.       }
  1064.     };
  1065.  
  1066.     this.reset = function(moduleName) {
  1067.       var module;
  1068.       if ((module = modules.all[moduleName]) != null) {
  1069.         this.deleteProps(module);
  1070.       } else {
  1071.         modules.all[moduleName] = {};
  1072.       }
  1073.     };
  1074.  
  1075.     this.deleteProps = function(module) {
  1076.       var i, key, len, ref;
  1077.       ref = Object.getOwnPropertyNames(module);
  1078.       for (i = 0, len = ref.length; i < len; i++) {
  1079.         key = ref[i];
  1080.         delete module[key];
  1081.       }
  1082.     };
  1083.  
  1084.     this.run = function() {
  1085.       return canvas_wars.recompile_editor();
  1086.     };
  1087.  
  1088.     this.rerun_parent_modules = function(moduleName) {
  1089.       var i, len, parentModule, ref;
  1090.       if (typeof moduleName === 'object') {
  1091.         moduleName = moduleName.module_name;
  1092.       }
  1093.       ref = Object.keys(modules.required_from[moduleName]);
  1094.       for (i = 0, len = ref.length; i < len; i++) {
  1095.         parentModule = ref[i];
  1096.         this.execute(parentModule);
  1097.       }
  1098.     };
  1099.  
  1100.     this.execute = function(module) {
  1101.       return canvas_wars.execute_module(this.getName(module));
  1102.     };
  1103.  
  1104.     this.executeAll = function(module, depth) {
  1105.       var executed, filter;
  1106.       module = this.getName(module);
  1107.       filter = depth != null ? function(k, v, d) {
  1108.         return d <= depth;
  1109.       } : function() {
  1110.         return true;
  1111.       };
  1112.       executed = {};
  1113.       require.object.eachDeep(modules.deps_tree[module], (function(_this) {
  1114.         return function(subModName) {
  1115.           if (executed[subModName]) {
  1116.             return;
  1117.           }
  1118.           _this.execute(subModName);
  1119.           return executed[subModName] = true;
  1120.         };
  1121.       })(this), filter);
  1122.       return this.execute(module);
  1123.     };
  1124.  
  1125.     this.fromName = function(name) {
  1126.       return modules.all[name];
  1127.     };
  1128.  
  1129.     this.getCurrentName = function() {
  1130.       return require.pager.get(0);
  1131.     };
  1132.  
  1133.     this.getCurrent = function() {
  1134.       return this.fromName(this.getCurrentName());
  1135.     };
  1136.  
  1137.     this.listAllChildren = function(moduleName) {
  1138.       var childs, key, results;
  1139.       childs = {};
  1140.       require.object.eachDeep(modules.deps_tree[moduleName], function(key) {
  1141.         return childs[key] = true;
  1142.       });
  1143.       results = [];
  1144.       for (key in childs) {
  1145.         results.push(key);
  1146.       }
  1147.       return results;
  1148.     };
  1149.  
  1150.     this.isBeingEdited = function(module) {
  1151.       return module.module_name === this.getCurrentName();
  1152.     };
  1153.  
  1154.     return this;
  1155.     }).call({}, require);
  1156.     //# sourceURL=module-156
  1157.  
  1158.   require.aspectRatio = (function aspectRatio (require) {Object.defineProperty(this, 'module_name', {value:'aspectRatio'});
  1159.     this.setContainer = function(containerWidth, containerHeight) {
  1160.       this.containerWidth = containerWidth;
  1161.       this.containerHeight = containerHeight;
  1162.       if (this.containerWidth instanceof Node) {
  1163.         this.containerHeight = this.containerWidth.clientHeight;
  1164.         this.containerWidth = this.containerWidth.clientWidth;
  1165.       }
  1166.       return this;
  1167.     };
  1168.  
  1169.     this.fitInCointainer = function(widthToHeight) {
  1170.       if (this.containerHeight > this.containerWidth / widthToHeight) {
  1171.         this.width = this.containerWidth;
  1172.         this.height = this.containerWidth / widthToHeight;
  1173.       } else {
  1174.         this.height = this.containerHeight;
  1175.         this.width = this.containerHeight * widthToHeight;
  1176.       }
  1177.       return [this.width, this.height];
  1178.     };
  1179.  
  1180.     return this;
  1181.     }).call({}, require);
  1182.     //# sourceURL=aspectRatio-157
  1183.  
  1184.   require.editor_sizes = (function editor_sizes (require) {Object.defineProperty(this, 'module_name', {value:'editor_sizes'});
  1185.     this.editorFont = 10;
  1186.  
  1187.     this.uiFont = 12;
  1188.  
  1189.     this.topRowHeight = 26;
  1190.  
  1191.     this.modulesInfoHeight = 18;
  1192.  
  1193.     return this;
  1194.     }).call({}, require);
  1195.     //# sourceURL=editor_sizes-158
  1196.  
  1197.   require.coffee_styles = (function coffee_styles (require) {Object.defineProperty(this, 'module_name', {value:'coffee_styles'});
  1198.     this.addStyles = function(el_id, rules) {
  1199.       var cssStr, styleEl;
  1200.       if (typeof window === "undefined" || window === null) {
  1201.         return console.error("Trying to create StyleSheet rules on server side!");
  1202.       }
  1203.       if (arguments.length === 1) {
  1204.         rules = el_id;
  1205.         el_id = 'main';
  1206.       }
  1207.       el_id = el_id + '_styles';
  1208.       rules = typeof rules === 'function' ? rules.call(this.helpers) : rules;
  1209.       this.stack = [];
  1210.       cssStr = typeof rules === 'object' ? this.compile(rules) : rules;
  1211.       styleEl = document.getElementById(el_id);
  1212.       if (styleEl == null) {
  1213.         styleEl = document.createElement('style');
  1214.         styleEl.id = el_id;
  1215.         document.head.appendChild(styleEl);
  1216.       }
  1217.       if (el_id === 'main_styles') {
  1218.         styleEl.innerHTML += cssStr;
  1219.       } else {
  1220.         styleEl.innerHTML = cssStr;
  1221.       }
  1222.     };
  1223.  
  1224.     this.non_pixel_vars = ['font-weight', 'opacity', 'z-index', 'zoom'];
  1225.  
  1226.     this.vendors = function(property_name, val) {
  1227.       var i, len, obj, ref, vendor;
  1228.       obj = {};
  1229.       ref = ['webkit', 'moz', 'ms'];
  1230.       for (i = 0, len = ref.length; i < len; i++) {
  1231.         vendor = ref[i];
  1232.         obj["-" + vendor + "-" + property_name] = val;
  1233.       }
  1234.       obj[property_name] = val;
  1235.       return obj;
  1236.     };
  1237.  
  1238.     this.create_property_string = function(key, value) {
  1239.       var val;
  1240.       key = key.replace(/_/g, '-');
  1241.       key = key.replace(/[A-Z]/g, function(s) {
  1242.         return '-' + s.toLowerCase();
  1243.       });
  1244.       if (typeof value === 'number' && this.non_pixel_vars.indexOf(key) === -1) {
  1245.         value = value + "px";
  1246.       }
  1247.       if (key.match(' -v')) {
  1248.         key = key.split(' ')[0];
  1249.         return ((function() {
  1250.           var ref, results;
  1251.           ref = this.vendors(key, val);
  1252.           results = [];
  1253.           for (key in ref) {
  1254.             val = ref[key];
  1255.             results.push("  " + key + ": " + value + ";\n");
  1256.           }
  1257.           return results;
  1258.         }).call(this)).join('');
  1259.       } else {
  1260.         return "  " + key + ": " + value + ";\n";
  1261.       }
  1262.     };
  1263.  
  1264.     this.compile = function(rulesObj) {
  1265.       var childRules, childSelector, children, combineStr, cssStr, declarations, firstChar, i, j, key, len, len1, mixin, nested, newCSS, parentSelector, ref, ref1, selector, val, value;
  1266.       if (this.stack.indexOf(rulesObj) !== -1 || this.stack.length === 100) {
  1267.         console.warn('@stack', this.stack);
  1268.         throw "Endless stack ccss.compile_to_str!";
  1269.       }
  1270.       this.stack.push(rulesObj);
  1271.       cssStr = '';
  1272.       for (selector in rulesObj) {
  1273.         childRules = rulesObj[selector];
  1274.         declarations = '';
  1275.         nested = {};
  1276.         if (selector.slice(0, 1) === '@') {
  1277.           cssStr += selector + ' { \n';
  1278.           cssStr += this.compile(childRules);
  1279.           return cssStr + '}\n';
  1280.         }
  1281.         while (childRules != null ? childRules.mixin : void 0) {
  1282.           mixin = childRules.mixin;
  1283.           childRules.mixin = null;
  1284.           for (key in mixin) {
  1285.             val = mixin[key];
  1286.             if (childRules[key] == null) {
  1287.               childRules[key] = val;
  1288.             }
  1289.           }
  1290.         }
  1291.         for (key in childRules) {
  1292.           value = childRules[key];
  1293.           if (typeof value === 'object') {
  1294.             children = [];
  1295.             ref = key.split(/\s*,\s*/);
  1296.             for (i = 0, len = ref.length; i < len; i++) {
  1297.               childSelector = ref[i];
  1298.               ref1 = selector.split(/\s*,\s*/);
  1299.               for (j = 0, len1 = ref1.length; j < len1; j++) {
  1300.                 parentSelector = ref1[j];
  1301.                 firstChar = childSelector.slice(0, 1);
  1302.                 combineStr = (function() {
  1303.                   switch (firstChar) {
  1304.                     case ':':
  1305.                       return '';
  1306.                     case '&':
  1307.                       childSelector = childSelector.slice(1);
  1308.                       return '';
  1309.                     default:
  1310.                       return ' ';
  1311.                   }
  1312.                 })();
  1313.                 children.push(parentSelector + combineStr + childSelector);
  1314.               }
  1315.             }
  1316.             nested[children.join(',')] = value;
  1317.           } else {
  1318.             declarations += this.create_property_string(key, value);
  1319.           }
  1320.         }
  1321.         if (declarations.length) {
  1322.           newCSS = selector + " {\n" + declarations + "}\n";
  1323.           try {
  1324.             cssStr += newCSS;
  1325.           } catch (_error) {
  1326.             console.log("failed with ", newCSS);
  1327.             return;
  1328.           }
  1329.         }
  1330.         cssStr += this.compile(nested);
  1331.       }
  1332.       return cssStr;
  1333.     };
  1334.  
  1335.     return this;
  1336.     }).call({}, require);
  1337.     //# sourceURL=coffee_styles-159
  1338.  
  1339.   require.styles = (function styles (require) {Object.defineProperty(this, 'module_name', {value:'styles'});
  1340.     if (this.addedStyles == null) {
  1341.       this.addedStyles = {};
  1342.     }
  1343.  
  1344.     this.addScoped = function(module, styleObj) {
  1345.       var obj;
  1346.       styleObj = (
  1347.         obj = {},
  1348.         obj["#" + module.module_name] = styleObj,
  1349.         obj
  1350.       );
  1351.       return this.add(module, styleObj);
  1352.     };
  1353.  
  1354.     this.add = function(id_or_obj, objOrCssStr) {
  1355.       if (arguments.length !== 2) {
  1356.         return;
  1357.       }
  1358.       if (typeof id_or_obj === 'object') {
  1359.         id_or_obj = id_or_obj.module_name;
  1360.       }
  1361.       if (typeof id_or_obj !== 'string') {
  1362.         throw Error("\:styles.add require id string");
  1363.       }
  1364.       this.addedStyles[id_or_obj] = true;
  1365.       return require.coffee_styles.addStyles(id_or_obj, objOrCssStr);
  1366.     };
  1367.  
  1368.     this.parseNode = function(dom_element_style_definitions) {};
  1369.  
  1370.     this.clear = function() {
  1371.       var idStr, results;
  1372.       results = [];
  1373.       for (idStr in this.addedStyles) {
  1374.         results.push(this.unload(idStr));
  1375.       }
  1376.       return results;
  1377.     };
  1378.  
  1379.     this.unload = function(idStr) {
  1380.       var i, len, ref, styleEl;
  1381.       if (!idStr) {
  1382.         return;
  1383.       }
  1384.       ref = document.querySelectorAll("head #" + idStr + "_styles");
  1385.       for (i = 0, len = ref.length; i < len; i++) {
  1386.         styleEl = ref[i];
  1387.         require.dom.remove(styleEl);
  1388.       }
  1389.       return delete this.addedStyles[idStr];
  1390.     };
  1391.  
  1392.     return this;
  1393.     }).call({}, require);
  1394.     //# sourceURL=styles-160
  1395.  
  1396.   require.unload = (function unload (require) {Object.defineProperty(this, 'module_name', {value:'unload'});
  1397.     var unload;
  1398.  
  1399.     return unload = function(mod, cb) {
  1400.       switch (require["typeof"](mod.unload)) {
  1401.         case 'array':
  1402.           if (mod.unload.includes(cb)) {
  1403.             return;
  1404.           }
  1405.           return mod.unload.push(cb);
  1406.         case 'function':
  1407.           if (mod.unload === cb) {
  1408.             return;
  1409.           }
  1410.           return mod.unload = [mod.unload, cb];
  1411.         default:
  1412.           return mod.unload = cb;
  1413.       }
  1414.     };
  1415.  
  1416.     return this;
  1417.     }).call({}, require);
  1418.     //# sourceURL=unload-161
  1419.  
  1420.   require.layers_styles = (function layers_styles (require) {Object.defineProperty(this, 'module_name', {value:'layers_styles'});
  1421.     var availableHeight, id;
  1422.  
  1423.     id = 'layer';
  1424.  
  1425.     availableHeight = "calc(100% - " + require.editor_sizes.modulesInfoHeight + "px)";
  1426.  
  1427.     if (this.normal == null) {
  1428.       this.normal = (function(_this) {
  1429.         return function() {
  1430.           var state;
  1431.           state = 'normal';
  1432.           return require.styles.add(id, {
  1433.             '#layers': {
  1434.               width: '100%',
  1435.               height: "calc(100% - " + require.editor_sizes.modulesInfoHeight + "px)",
  1436.               overflow: 'hidden',
  1437.               pointerEvents: 'none',
  1438.               '& > *': {
  1439.                 pointerEvents: 'all',
  1440.                 position: 'absolute',
  1441.                 top: '0',
  1442.                 left: '0',
  1443.                 overflowY: 'auto',
  1444.                 '&:not(canvas)': {
  1445.                   height: '100%',
  1446.                   width: '100%'
  1447.                 }
  1448.               },
  1449.               '& > canvas': {
  1450.                 overflowY: 'hidden',
  1451.                 top: '50%',
  1452.                 left: '50%',
  1453.                 transform: 'translate(-50%, -50%)'
  1454.               }
  1455.             }
  1456.           });
  1457.         };
  1458.       })(this);
  1459.     }
  1460.  
  1461.     this.normal();
  1462.  
  1463.     this.none = function(mod) {
  1464.       if (!mod) {
  1465.         throw Error("add caller module");
  1466.       }
  1467.       require.styles.unload(id);
  1468.       return require.unload(mod, this.normal);
  1469.     };
  1470.  
  1471.     return this;
  1472.     }).call({}, require);
  1473.     //# sourceURL=layers_styles-162
  1474.  
  1475.   require.layers = (function layers (require) {Object.defineProperty(this, 'module_name', {value:'layers'});
  1476.     var ref;
  1477.  
  1478.     if (this.container == null) {
  1479.       this.container = (ref = document.getElementById('layers')) != null ? ref : require.dom["new"]('#layers');
  1480.     }
  1481.  
  1482.     if (this.addedLayers == null) {
  1483.       this.addedLayers = {};
  1484.     }
  1485.  
  1486.     if (this.canvases == null) {
  1487.       this.canvases = {};
  1488.     }
  1489.  
  1490.     this.add = function(node, name) {
  1491.       var ref1;
  1492.       name = (ref1 = name.module_name) != null ? ref1 : name;
  1493.       if (!node.id) {
  1494.         node.id = name;
  1495.       }
  1496.       if (this.addedLayers[name]) {
  1497.         this.unload(name);
  1498.       }
  1499.       return this.addedLayers[name] = this.container.appendChild(node);
  1500.     };
  1501.  
  1502.     this.get = function(layerName, elementType) {
  1503.       var node;
  1504.       if (elementType == null) {
  1505.         elementType = 'div';
  1506.       }
  1507.       layerName = require.module.getId(layerName);
  1508.       if (!(node = this.addedLayers[layerName])) {
  1509.         if (!(node = this.container.querySelector('#' + layerName))) {
  1510.           node = document.createElement(elementType);
  1511.           node.id = layerName;
  1512.           node.className = 'layer';
  1513.           this.container.appendChild(node);
  1514.         }
  1515.         this.addedLayers[layerName] = node;
  1516.       }
  1517.       return node;
  1518.     };
  1519.  
  1520.     this.getCanvas = function(nameOrMod, widthToHeight, ctxType) {
  1521.       var el, name, ref1;
  1522.       if (ctxType == null) {
  1523.         ctxType = '2d';
  1524.       }
  1525.       if (typeof nameOrMod === 'object') {
  1526.         if (nameOrMod.viewChangeRecompile == null) {
  1527.           nameOrMod.viewChangeRecompile = true;
  1528.         }
  1529.       }
  1530.       name = require.module.getId(nameOrMod);
  1531.       el = this.get(name, 'canvas');
  1532.       if (widthToHeight != null) {
  1533.         require.aspectRatio.setContainer(this.container);
  1534.         ref1 = require.aspectRatio.fitInCointainer(widthToHeight), el.width = ref1[0], el.height = ref1[1];
  1535.       } else {
  1536.         el.width = this.container.clientWidth;
  1537.         el.height = this.container.clientHeight;
  1538.       }
  1539.       return this.canvases[name] = {
  1540.         node: el,
  1541.         ctx: el.getContext(ctxType),
  1542.         width: el.width,
  1543.         height: el.height,
  1544.         widthToHeight: widthToHeight
  1545.       };
  1546.     };
  1547.  
  1548.     this.has = function(layer) {
  1549.       return this.addedLayers[require.module.getId(layer)] != null;
  1550.     };
  1551.  
  1552.     this.clear = function() {
  1553.       var id, layerEl, ref1, results;
  1554.       ref1 = this.addedLayers;
  1555.       results = [];
  1556.       for (id in ref1) {
  1557.         layerEl = ref1[id];
  1558.         results.push(this.unload(layerEl));
  1559.       }
  1560.       return results;
  1561.     };
  1562.  
  1563.     this.unload = function(layer, final) {
  1564.       var i, len, obj, ref1;
  1565.       if (final) {
  1566.         ref1 = [this.addedLayers, this.canvases];
  1567.         for (i = 0, len = ref1.length; i < len; i++) {
  1568.           obj = ref1[i];
  1569.           require.object.dellAll(obj);
  1570.         }
  1571.         require.dom.removeChildren(this.container);
  1572.         return;
  1573.       }
  1574.       if (!(layer instanceof Element)) {
  1575.         layer = require.module.getId(layer);
  1576.       }
  1577.       if (typeof layer === 'string') {
  1578.         layer = this.addedLayers[layer];
  1579.       }
  1580.       if (layer instanceof Element) {
  1581.         delete this.addedLayers[layer.id];
  1582.         delete this.canvases[layer.id];
  1583.         require.dom.remove(layer);
  1584.       } else if (layer) {
  1585.         console.warn('unknown layer.unload type', layer);
  1586.       }
  1587.     };
  1588.  
  1589.     if (this.refresh == null) {
  1590.       this.refresh = (function(_this) {
  1591.         return function(runModule) {
  1592.           var name, node, ref1, ref2, results;
  1593.           require.aspectRatio.setContainer(_this.container);
  1594.           ref1 = _this.addedLayers;
  1595.           results = [];
  1596.           for (name in ref1) {
  1597.             node = ref1[name];
  1598.             if (node.tagName === 'CANVAS') {
  1599.               if (_this.canvases[name].widthToHeight != null) {
  1600.                 results.push((ref2 = require.aspectRatio.fitInCointainer(_this.canvases[name].widthToHeight), node.width = ref2[0], node.height = ref2[1], ref2));
  1601.               } else {
  1602.                 node.width = _this.container.clientWidth;
  1603.                 results.push(node.height = _this.container.clientHeight);
  1604.               }
  1605.             } else {
  1606.               results.push(void 0);
  1607.             }
  1608.           }
  1609.           return results;
  1610.         };
  1611.       })(this);
  1612.     }
  1613.  
  1614.     if (this.fullRefresh == null) {
  1615.       this.fullRefresh = (function(_this) {
  1616.         return function() {
  1617.           var ref1;
  1618.           _this.refresh();
  1619.           if (((ref1 = require.module.getCurrent()) != null ? ref1.viewChangeRecompile : void 0) && !window.canvas_wars.loading) {
  1620.             return canvas_wars.recompile_editor();
  1621.           }
  1622.         };
  1623.       })(this);
  1624.     }
  1625.  
  1626.     this.styles = require.layers_styles;
  1627.  
  1628.     return this;
  1629.     }).call({}, require);
  1630.     //# sourceURL=layers-163
  1631.  
  1632.   require.render = (function render (require) {Object.defineProperty(this, 'module_name', {value:'render'});
  1633.     this.toNode = function(node, htmlObjOrNode) {
  1634.       require.dom.removeChildren(node);
  1635.       if (!(htmlObjOrNode instanceof Node)) {
  1636.         htmlObjOrNode = require.node_from_obj(htmlObjOrNode);
  1637.       }
  1638.       node.appendChild(htmlObjOrNode);
  1639.       return node;
  1640.     };
  1641.  
  1642.     this.toLayer = function(module, htmlObjOrNode) {
  1643.       return this.toNode(require.layers.get(module), htmlObjOrNode);
  1644.     };
  1645.  
  1646.     this.unload = function(from, final) {
  1647.       return require.layers.unload(from);
  1648.     };
  1649.  
  1650.     this.late = function(moduleOrNode, htmlObjFunc) {
  1651.       var func;
  1652.       func = moduleOrNode instanceof Node ? this.toNode : this.toLayer.bind(this);
  1653.       return setTimeout(function() {
  1654.         return func(moduleOrNode, htmlObjFunc());
  1655.       });
  1656.     };
  1657.  
  1658.     return this;
  1659.     }).call({}, require);
  1660.     //# sourceURL=render-164
  1661.  
  1662.   require.common_style_classes = (function common_style_classes (require) {Object.defineProperty(this, 'module_name', {value:'common_style_classes'});
  1663.     require.object.merge(this, {
  1664.       '.align_center': {
  1665.         display: 'block',
  1666.         top: '50%',
  1667.         left: '50%',
  1668.         'transform -v': 'translate(-50%,-50%)'
  1669.       },
  1670.       '.vertical_align_center': {
  1671.         display: 'block',
  1672.         top: '50%',
  1673.         'transform -v': 'translateY(-50%)'
  1674.       },
  1675.       '.clickable, .pointer': {
  1676.         cursor: 'pointer'
  1677.       },
  1678.       '.one-line': {
  1679.         display: 'block',
  1680.         whiteSpace: 'nowrap',
  1681.         overflow: 'hidden',
  1682.         textOverflow: 'ellipsis'
  1683.       },
  1684.       '.inline-block': {
  1685.         display: 'inline-block',
  1686.         verticalAlign: 'top'
  1687.       }
  1688.     });
  1689.  
  1690.     require.styles.add(this, this);
  1691.  
  1692.     return this;
  1693.     }).call({}, require);
  1694.     //# sourceURL=common_style_classes-165
  1695.  
  1696.   require.color = (function color (require) {Object.defineProperty(this, 'module_name', {value:'color'});
  1697.     this.l = this.lightness = function(lightness) {
  1698.       return "hsl(0,0%," + lightness + "%)";
  1699.     };
  1700.  
  1701.     this.la = this.lightnessAlpha = function(lightness, alpha) {
  1702.       return "hsla(0,0%," + lightness + "%," + alpha + ")";
  1703.     };
  1704.  
  1705.     this.h = this.hue = function(hue) {
  1706.       return "hsl(" + hue + ",100%,50%)";
  1707.     };
  1708.  
  1709.     this.hl = function(hue, l) {
  1710.       return "hsl(" + hue + ",100%," + l + "%)";
  1711.     };
  1712.  
  1713.     this.hsl = function(h, s, l) {
  1714.       return "hsl(" + h + "," + s + "%," + l + "%)";
  1715.     };
  1716.  
  1717.     this.hsla = function(h, s, l, a) {
  1718.       return "hsla(" + h + "," + s + "%," + l + "%," + a + ")";
  1719.     };
  1720.  
  1721.     return this;
  1722.     }).call({}, require);
  1723.     //# sourceURL=color-166
  1724.  
  1725.   require.editor_colors = (function editor_colors (require) {Object.defineProperty(this, 'module_name', {value:'editor_colors'});
  1726.     this.purple = 'hsl(261, 90%, 75%)';
  1727.  
  1728.     this.blue = 'hsl(203, 90%, 63%)';
  1729.  
  1730.     this.turcose = "hsl(170, 90%, 50%)";
  1731.  
  1732.     this.green = "hsl(90, 75%, 50%)";
  1733.  
  1734.     this.green_hover = "hsl(90, 100%, 70%)";
  1735.  
  1736.     this.yellow = 'hsl(57, 72%, 65%)';
  1737.  
  1738.     this.orange = 'hsl(37, 100%, 56%)';
  1739.  
  1740.     this.red = 'hsl(19, 100%, 56%)';
  1741.  
  1742.     this.unhued_red = 'hsl(337, 100%, 56%)';
  1743.  
  1744.     this.gray = 'hsl(50, 11%, 55%)';
  1745.  
  1746.     this.white = 'hsl(0,0%,90%)';
  1747.  
  1748.     this.black = 'hsl(70, 8%, 12%)';
  1749.  
  1750.     this.uiGreen = require.color.hsl(130, 70, 43);
  1751.  
  1752.     this.uiRed = require.color.hsl(0, 80, 43);
  1753.  
  1754.     this.uiRedDim = require.color.hsl(0, 50, 43);
  1755.  
  1756.     return this;
  1757.     }).call({}, require);
  1758.     //# sourceURL=editor_colors-167
  1759.  
  1760.   require.syntax_styles = (function syntax_styles (require) {Object.defineProperty(this, 'module_name', {value:'syntax_styles'});
  1761.     var b;
  1762.  
  1763.     this.link_color = require.editor_colors.green;
  1764.  
  1765.     this.typeMapping = {
  1766.       'string': 'yellow',
  1767.       'null': 'purple',
  1768.       'undefined': 'purple',
  1769.       boolean: 'blue',
  1770.       number: 'blue',
  1771.       array: 'turcose',
  1772.       object: 'green',
  1773.       'function': 'orange'
  1774.     };
  1775.  
  1776.     this.operatorColor = require.editor_colors.red;
  1777.  
  1778.     this.types = require.object.map(this.typeMapping, {
  1779.       key: function(typeName) {
  1780.         return '.cm-' + typeName;
  1781.       },
  1782.       val: function(colorName) {
  1783.         return {
  1784.           color: require.editor_colors[colorName]
  1785.         };
  1786.       }
  1787.     });
  1788.  
  1789.     this.main = {
  1790.       '#editor, #editor pre': {
  1791.         fontSize: this.fontSize = require.editor_sizes.editorFont,
  1792.         lineHeight: this.lineHeight = '1.5em',
  1793.         letterSpacing: 1
  1794.       },
  1795.       'a, a#login-name-link': {
  1796.         textDecoration: 'none',
  1797.         color: this.link_color,
  1798.         '&:hover': {
  1799.           color: require.editor_colors.green_hover
  1800.         }
  1801.       },
  1802.       '.cm-error.cm-require-link': {
  1803.         background: "hsl(0, 100%, 13%)",
  1804.         borderRadius: 3
  1805.       },
  1806.       '.cm-highlighted': {
  1807.         background: require.color.la(100, 0.19),
  1808.         textDecoration: 'none',
  1809.         "&:not(.cm-single)\:not(.cm-punctuation)": {
  1810.           borderBottom: b = '1px solid ' + require.color.l(80),
  1811.           borderTop: b
  1812.         },
  1813.         '&.cm-number:not(.cm-property)\:not(.cm-variable)\:not(.cm-string)': {
  1814.           background: require.editor_colors[this.typeMapping.number],
  1815.           color: require.editor_colors.black,
  1816.           fontWeight: 'bold',
  1817.           borderRadius: 2
  1818.         }
  1819.       },
  1820.       '.cm-require-link': {
  1821.         '&.cm-highlighted:not(.cm-punctuation)': {
  1822.           textDecoration: 'underline'
  1823.         },
  1824.         '&.cm-highlighted': {
  1825.           cursor: 'pointer'
  1826.         }
  1827.       },
  1828.       '.cm-editor-error': {
  1829.         backgroundColor: 'hsla(0, 100%, 40%, 0.55)',
  1830.         color: 'white !important',
  1831.         '&:first-child': {
  1832.           borderTopLeftRadius: 3,
  1833.           borderBottomLeftRadius: 3
  1834.         },
  1835.         '&:last-child': {
  1836.           borderTopRightRadius: 3,
  1837.           borderBottomRightRadius: 3
  1838.         }
  1839.       },
  1840.       '.cm-variable': {
  1841.         color: require.editor_colors.white
  1842.       },
  1843.       '.cm-keyword': {
  1844.         color: this.operatorColor
  1845.       },
  1846.       '.cm-atom': {
  1847.         color: require.editor_colors[this.typeMapping["null"]]
  1848.       },
  1849.       '.cm-punctuation': {
  1850.         color: require.editor_colors.orange
  1851.       },
  1852.       '.cm-operator': {
  1853.         color: this.operatorColor
  1854.       },
  1855.       '.CodeMirror-matchingbracket': {
  1856.         color: this.operatorColor
  1857.       }
  1858.     };
  1859.  
  1860.     this.rest = {
  1861.       '.cm-string-2': {
  1862.         color: this.operatorColor
  1863.       },
  1864.       '.cm-comment': {
  1865.         color: require.editor_colors.gray
  1866.       },
  1867.       '.CodeMirror-matchingbracket, .CodeMirror-nonmatchingbracket': {
  1868.         textDecoration: 'underline'
  1869.       },
  1870.       '.CodeMirror-nonmatchingbracket': {
  1871.         color: 'red'
  1872.       }
  1873.     };
  1874.  
  1875.     this.add = (function(_this) {
  1876.       return function() {
  1877.         require.styles.add('syntax_styles_before_types', _this.main);
  1878.         require.styles.add('syntax_type', _this.types);
  1879.         return require.styles.add('syntax_styles_after_types', _this.rest);
  1880.       };
  1881.     })(this);
  1882.  
  1883.     return this;
  1884.     }).call({}, require);
  1885.     //# sourceURL=syntax_styles-168
  1886.  
  1887.   require.inspect_object = (function inspect_object (require) {Object.defineProperty(this, 'module_name', {value:'inspect_object'});
  1888.     var defaultOptions, inspect_obj, propertiesByProto,
  1889.       indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
  1890.  
  1891.     defaultOptions = {
  1892.       create_key_node: function(sKey, val, parent) {
  1893.         var obj1;
  1894.         return require.node_from_obj([
  1895.           (
  1896.             obj1 = {},
  1897.             obj1["span.key.cm-" + (require["typeof"](val))] = {
  1898.               raw: sKey
  1899.             },
  1900.             obj1["span.key"] = ': ',
  1901.             obj1
  1902.           )
  1903.         ]);
  1904.       },
  1905.       transform_value: function(valueNode, val) {
  1906.         var props, str;
  1907.         props = Object.keys(val);
  1908.         str = (function() {
  1909.           var ref;
  1910.           switch (val.constructor.name) {
  1911.             case 'Object':
  1912.               return " {" + props.length + "}";
  1913.             case 'Array':
  1914.               return " [" + props.length + "]";
  1915.             default:
  1916.               return val.constructor.name + ' ' + ((ref = val.length) != null ? ref : props.length);
  1917.           }
  1918.         })();
  1919.         valueNode.textContent = str;
  1920.         return valueNode;
  1921.       },
  1922.       sort: function(a, b) {
  1923.         var res;
  1924.         if (isNaN(res = a - b)) {
  1925.           return a.localeCompare(b);
  1926.         } else {
  1927.           return res;
  1928.         }
  1929.       },
  1930.       showPropsMax: 500
  1931.     };
  1932.  
  1933.     propertiesByProto = function(obj, sort) {
  1934.       var curr, i, inheritanceInd, len, propName, props, propsByHeritance, ref;
  1935.       propsByHeritance = [];
  1936.       inheritanceInd = 0;
  1937.       curr = obj;
  1938.       while (true) {
  1939.         props = propsByHeritance[inheritanceInd] = [];
  1940.         ref = Object.getOwnPropertyNames(curr);
  1941.         for (i = 0, len = ref.length; i < len; i++) {
  1942.           propName = ref[i];
  1943.           props.push(propName);
  1944.         }
  1945.         inheritanceInd++;
  1946.         if (sort) {
  1947.           props.sort(sort);
  1948.         }
  1949.         if (!(curr = Object.getPrototypeOf(curr)) || curr === Object.prototype || curr === Array.prototype) {
  1950.           if (indexOf.call(curr, '__proto__') >= 0) {
  1951.             debugger;
  1952.           }
  1953.           break;
  1954.         }
  1955.       }
  1956.       return propsByHeritance;
  1957.     };
  1958.  
  1959.     inspect_obj = function(obj, targetNode, state, options) {
  1960.       var action, create_key_node, heritInd, i, ind, j, key, keyNode, len, len1, numberKeys, optName, propsByHeritance, ref, row_node, toggle_open, transform_value, val, valueNode, wrapper;
  1961.       if (state == null) {
  1962.         state = [];
  1963.       }
  1964.       ind = -1;
  1965.       if (options == null) {
  1966.         options = {};
  1967.       }
  1968.       for (optName in defaultOptions) {
  1969.         action = defaultOptions[optName];
  1970.         if (options[optName] == null) {
  1971.           options[optName] = action;
  1972.         }
  1973.       }
  1974.       create_key_node = options.create_key_node, transform_value = options.transform_value;
  1975.       wrapper = require.dom["new"]('.inspect_object .rows');
  1976.       numberKeys = 0;
  1977.       ref = propertiesByProto(obj, options.sort);
  1978.       for (heritInd = i = 0, len = ref.length; i < len; heritInd = ++i) {
  1979.         propsByHeritance = ref[heritInd];
  1980.         for (j = 0, len1 = propsByHeritance.length; j < len1; j++) {
  1981.           key = propsByHeritance[j];
  1982.           val = obj[key];
  1983.           ind++;
  1984.           if (require.str.parsesToNumber(key)) {
  1985.             if (numberKeys === options.showPropsMax) {
  1986.               wrapper.appendChild(require.node_from_obj({
  1987.                 div: '... (TODO: add link to open more values)'
  1988.               }));
  1989.             }
  1990.             numberKeys++;
  1991.             if (numberKeys > options.showPropsMax) {
  1992.               continue;
  1993.             }
  1994.           }
  1995.           row_node = require.dom["new"]('.inspect-row' + require.str["if"](!state[ind], '.one-line'));
  1996.           valueNode = require.dom["new"]('span.value');
  1997.           valueNode.classList.add('cm-' + require["typeof"](val));
  1998.           if (heritInd) {
  1999.             key = '⋏'.repeat(heritInd) + ' ' + key;
  2000.           }
  2001.           require.dom.addChilds(row_node, [keyNode = create_key_node(key, val, obj), valueNode]);
  2002.           if (typeof val === 'object' && val !== null) {
  2003.             if (state[ind]) {
  2004.               inspect_obj(val, valueNode, state[ind], options);
  2005.             }
  2006.             transform_value(valueNode, val);
  2007.             toggle_open = (function(state, ind, wrapper, ev) {
  2008.               state[ind] = state[ind] ? null : [];
  2009.               inspect_obj(obj, wrapper, state, options);
  2010.               return ev.stopPropagation();
  2011.             }).bind(null, state, ind, wrapper);
  2012.             row_node.classList.add('pointer');
  2013.             row_node.addEventListener('click', toggle_open, false);
  2014.           } else {
  2015.             if (typeof val === 'string') {
  2016.               val = "\"" + val + "\"";
  2017.             }
  2018.             if (val !== void 0) {
  2019.               val = val + '';
  2020.             }
  2021.             valueNode.textContent = typeof val === 'function' ? val.replace(/{[\s\S]*/, '') + ' ' + val.length : val != null ? require.str.truncate(val, 60) : void 0;
  2022.           }
  2023.           wrapper.appendChild(row_node);
  2024.         }
  2025.       }
  2026.       if (targetNode) {
  2027.         return require.dom.replace(targetNode, wrapper);
  2028.       } else {
  2029.         return wrapper;
  2030.       }
  2031.     };
  2032.  
  2033.     require.common_style_classes;
  2034.  
  2035.     require.styles.add('inspect_object', {
  2036.       '.inspect_object.rows': {
  2037.         '.pointer': {
  2038.           cursor: 'pointer',
  2039.           '&:hover': {
  2040.             background: require.color.la(0, 0.2)
  2041.           }
  2042.         },
  2043.         '.rows': {
  2044.           paddingLeft: 12
  2045.         },
  2046.         '.inspect-row': {
  2047.           paddingLeft: 3,
  2048.           transition: '250ms'
  2049.         },
  2050.         mixin: require.syntax_styles.types
  2051.       }
  2052.     });
  2053.  
  2054.     return inspect_obj;
  2055.  
  2056.     return this;
  2057.     }).call({}, require);
  2058.     //# sourceURL=inspect_object-169
  2059.  
  2060.   require.angularDomStructure = (function angularDomStructure (require) {Object.defineProperty(this, 'module_name', {value:'angularDomStructure'});
  2061.     var getCSSPath, standardHtmlTags, toArray, toggleClass, topMargin;
  2062.  
  2063.     standardHtmlTags = ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr'];
  2064.  
  2065.     toArray = function(arrayish) {
  2066.       return Array.prototype.slice.call(arrayish);
  2067.     };
  2068.  
  2069.     getCSSPath = function(node) {
  2070.       var ind, parts, siblingsArr, str;
  2071.       parts = [];
  2072.       while (node.parentElement) {
  2073.         str = node.tagName;
  2074.         if (node.id) {
  2075.           str += "#" + node.id;
  2076.           parts.unshift(str);
  2077.           break;
  2078.         }
  2079.         siblingsArr = toArray(node.parentElement.childNodes);
  2080.         ind = siblingsArr.filter(function(n) {
  2081.           return n.attributes != null;
  2082.         }).indexOf(node);
  2083.         parts.unshift(str + (":nth-child(" + (ind + 1) + ")"));
  2084.         node = node.parentElement;
  2085.       }
  2086.       return parts.join(' > ');
  2087.     };
  2088.  
  2089.     toggleClass = function(node, className) {
  2090.       if (node.classList.contains(className)) {
  2091.         return node.classList.remove(className);
  2092.       } else {
  2093.         return node.classList.add(className);
  2094.       }
  2095.     };
  2096.  
  2097.     this.filterSpecial = function(node, parentSpecial) {
  2098.       var attrFilterFunc, child, i, len, nodeClassesStr, ref, results, specialAttrs, specialTag, thisCurrent;
  2099.       if (parentSpecial == null) {
  2100.         parentSpecial = {
  2101.           children: []
  2102.         };
  2103.       }
  2104.       if (!standardHtmlTags.includes(node.tagName)) {
  2105.         specialTag = node.tagName;
  2106.       }
  2107.       if (!(specialTag || this.filteredRoot)) {
  2108.         specialTag = 'root';
  2109.       }
  2110.       attrFilterFunc = this.specialAttrsToMatch.length || this.classAttrsToMatch.length ? (function(_this) {
  2111.         return function(attr) {
  2112.           if (attr.name === 'class' && _this.classAttrsToMatch.length) {
  2113.             return (_.intersection(_this.classAttrsToMatch, attr.value.split(' '))).length > 0;
  2114.           } else {
  2115.             return _this.specialAttrsToMatch.includes(attr.name);
  2116.           }
  2117.         };
  2118.       })(this) : function(attr) {
  2119.         return !require.html.standardAttrs.includes(attr.name);
  2120.       };
  2121.       specialAttrs = toArray(node.attributes).filter(attrFilterFunc);
  2122.       if (specialTag || specialAttrs.length) {
  2123.         nodeClassesStr = require.str["if"](node.classList.length, ' .' + toArray(node.classList).join('.'));
  2124.         parentSpecial.children.push(this.current = {
  2125.           tag: '<' + node.tagName + (require.str["if"](node.id, ' #' + node.id)) + nodeClassesStr + '>',
  2126.           attrs: specialAttrs,
  2127.           children: [],
  2128.           path: getCSSPath(node)
  2129.         });
  2130.         if (this.filteredRoot == null) {
  2131.           this.filteredRoot = this.current;
  2132.         }
  2133.       }
  2134.       ref = node.childNodes;
  2135.       results = [];
  2136.       for (i = 0, len = ref.length; i < len; i++) {
  2137.         child = ref[i];
  2138.         if (!(child.attributes != null)) {
  2139.           continue;
  2140.         }
  2141.         thisCurrent = this.current;
  2142.         this.filterSpecial(child, this.current);
  2143.         results.push(this.current = thisCurrent);
  2144.       }
  2145.       return results;
  2146.     };
  2147.  
  2148.     this.renderableFromNode = function(tagAttrsChildren, parent) {
  2149.       var attr, child, i, j, len, len1, origTagName, ref, ref1, sub, tagName;
  2150.       if (parent == null) {
  2151.         parent = {};
  2152.       }
  2153.       tagName = origTagName = tagAttrsChildren.tag.toLowerCase() + '::' + tagAttrsChildren.path;
  2154.       parent[tagName] = sub = {};
  2155.       ref = tagAttrsChildren.attrs;
  2156.       for (i = 0, len = ref.length; i < len; i++) {
  2157.         attr = ref[i];
  2158.         sub[attr.nodeName] = attr.nodeValue;
  2159.       }
  2160.       ref1 = tagAttrsChildren.children;
  2161.       for (j = 0, len1 = ref1.length; j < len1; j++) {
  2162.         child = ref1[j];
  2163.         this.renderableFromNode(child, sub);
  2164.       }
  2165.       return parent;
  2166.     };
  2167.  
  2168.     this.attrInputValue = localStorage.angularInspectAttrNames || "ng-app ui-view ng-controller";
  2169.  
  2170.     this.openInspector = (function(_this) {
  2171.       return function() {
  2172.         var attrName, htmlStr, i, len, options, ref, testNode;
  2173.         htmlStr = document.body.innerHTML;
  2174.         _this.filteredRoot = _this.current = null;
  2175.         _this.classAttrsToMatch = [];
  2176.         _this.specialAttrsToMatch = [];
  2177.         ref = _this.attrInputValue.split(/[ ,]/);
  2178.         for (i = 0, len = ref.length; i < len; i++) {
  2179.           attrName = ref[i];
  2180.           if (attrName[0] === '.') {
  2181.             _this.classAttrsToMatch.push(attrName.slice(1));
  2182.           } else {
  2183.             _this.specialAttrsToMatch.push(attrName);
  2184.           }
  2185.         }
  2186.         require.render.toLayer(_this, {
  2187.           pre: [
  2188.             {
  2189.               'a.toggleSide': {
  2190.                 onClick: function(ev) {
  2191.                   return toggleClass(ev.target.parentElement.parentElement, 'rightSide');
  2192.                 },
  2193.                 me: 'side'
  2194.               },
  2195.               '.attributes': [
  2196.                 'Show only attributes:', _this.attrsInput = require.dom["new"]({
  2197.                   'input': {
  2198.                     value: _this.attrInputValue,
  2199.                     onKeyUp: _.debounce((function(ev) {
  2200.                       _this.attrInputValue = localStorage.angularInspectAttrNames = ev.target.value;
  2201.                       _this.openInspector();
  2202.                       return ev.preventDefault();
  2203.                     }), 1000)
  2204.                   }
  2205.                 })
  2206.               ],
  2207.               '.final': ['Structure:', _this.finalEl = require.dom["new"]()],
  2208.               '.scope': [
  2209.                 _this.scopeEl = require.dom["new"]({
  2210.                   div: {
  2211.                     div: '',
  2212.                     div2: ''
  2213.                   }
  2214.                 })
  2215.               ]
  2216.             }
  2217.           ]
  2218.         });
  2219.         _this.attrsInput.focus();
  2220.         _this.attrsInput.value = _this.attrsInput.value;
  2221.         testNode = document.createElement('root');
  2222.         testNode.innerHTML = htmlStr;
  2223.         _this.filterSpecial(testNode);
  2224.         require.inspect_object(_this.filteredRoot, _this.filteredEl);
  2225.         options = {
  2226.           create_key_node: function(key) {
  2227.             var domEl, inspectScope, keyTxt, path, ref1;
  2228.             ref1 = key.split('::'), key = ref1[0], path = ref1[1];
  2229.             keyTxt = key.replace(/\d$/, '') + ' ';
  2230.             path += ' > *\:first-child';
  2231.             if (path) {
  2232.               return domEl = require.dom["new"]({
  2233.                 'a.key': {
  2234.                   onClick: inspectScope = function(ev, storedPath) {
  2235.                     var scope, targetNode;
  2236.                     if (storedPath != null) {
  2237.                       path = storedPath;
  2238.                     }
  2239.                     console.log('window.inspectedElement =', window.inspectedElement = document.querySelector(path));
  2240.                     if (targetNode = typeof angular !== "undefined" && angular !== null ? angular.element(document.querySelector(path)) : void 0) {
  2241.                       require.render.toNode(_this.scopeEl.children[0], {
  2242.                         span: "Scope in ",
  2243.                         a: {
  2244.                           me: key,
  2245.                           onClick: function() {
  2246.                             return inspectScope.call(this, null, path);
  2247.                           }
  2248.                         },
  2249.                         span2: ':'
  2250.                       });
  2251.                       if (scope = targetNode != null ? targetNode.scope() : void 0) {
  2252.                         scope['(unfiltered)'] = scope;
  2253.                         scope = require.object.filter(scope, function(key, val) {
  2254.                           return key[0] !== '$';
  2255.                         });
  2256.                         require.inspect_object(scope, _this.scopeEl.children[1]);
  2257.                       }
  2258.                     } else {
  2259.                       console.warn("node not found from DOM (or not inside angular app)");
  2260.                     }
  2261.                     return ev != null ? ev.preventDefault() : void 0;
  2262.                   },
  2263.                   me: keyTxt
  2264.                 }
  2265.               });
  2266.             } else {
  2267.               return require.dom["new"]({
  2268.                 'span.key': keyTxt
  2269.               });
  2270.             }
  2271.           }
  2272.         };
  2273.         return require.inspect_object(_this.renderableFromNode(_this.filteredRoot), _this.finalEl, [[]], options);
  2274.       };
  2275.     })(this);
  2276.  
  2277.     if (!document.querySelector('#inspectorButton')) {
  2278.       document.body.appendChild(require.node_from_obj({
  2279.         '#inspectorButton': {
  2280.           onClick: (function(_this) {
  2281.             return function() {
  2282.               if (require.layers.has(_this)) {
  2283.                 return require.layers.unload(_this);
  2284.               } else {
  2285.                 return _this.openInspector();
  2286.               }
  2287.             };
  2288.           })(this),
  2289.           me: 'i'
  2290.         }
  2291.       }));
  2292.     }
  2293.  
  2294.     this.unload = function() {
  2295.       return require.dom.remove('#inspectorButton');
  2296.     };
  2297.  
  2298.     require.styles.add(this, {
  2299.       '#inspectorButton': {
  2300.         position: 'fixed',
  2301.         top: 0,
  2302.         left: 0,
  2303.         width: 15,
  2304.         height: 15,
  2305.         lineHeight: 15,
  2306.         textAlign: 'center',
  2307.         zIndex: 1051,
  2308.         color: 'gray',
  2309.         cursor: 'pointer',
  2310.         opacity: 0,
  2311.         '&:hover': {
  2312.           opacity: 1
  2313.         }
  2314.       },
  2315.       'body > #layers': {
  2316.         position: 'fixed',
  2317.         top: topMargin = 0,
  2318.         height: "calc(100% - " + topMargin + "px)",
  2319.         zIndex: 1051
  2320.       },
  2321.       '#layers #angularDomStructure': {
  2322.         position: 'relative',
  2323.         background: "hsla(0, 0%, 0%, 0.8)",
  2324.         width: '50%',
  2325.         padding: '2px 4px',
  2326.         pre: {
  2327.           color: 'white',
  2328.           textShadow: "0px 1px 2px black",
  2329.           background: 'none',
  2330.           border: 'none'
  2331.         },
  2332.         '.final,.filtered,.scope': {
  2333.           marginTop: 10
  2334.         },
  2335.         '.final': {
  2336.           maxHeight: 350,
  2337.           overflowY: 'scroll'
  2338.         },
  2339.         '&.rightSide': {
  2340.           float: 'right'
  2341.         },
  2342.         '.toggleSide': {
  2343.           float: 'right',
  2344.           cursor: 'pointer',
  2345.           zIndex: 2
  2346.         },
  2347.         'input': {
  2348.           color: 'black',
  2349.           width: "calc(100% - 140px)"
  2350.         }
  2351.       },
  2352.       '#right_side #angularDomStructure': {
  2353.         width: '100%'
  2354.       }
  2355.     });
  2356.  
  2357.     return this;
  2358.     }).call({}, require);
  2359.     //# sourceURL=angularDomStructure-170
  2360.   }
  2361.   if (document.readyState === "complete") {
  2362.     initAllModules();
  2363.   } else {
  2364.     window.addEventListener('load', initAllModules, false);
  2365.   }
  2366. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement