Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function () {
- var emptyFunc = function () { return null; };
- window.pager = { get: emptyFunc, set: emptyFunc, params: { toggle: emptyFunc } };
- //window.modules = { all: {} };
- function addElToBody(tagName, props) {
- var propName, el = document.createElement(tagName);
- for (propName in props) {
- el[propName] = props[propName];
- }
- document.body.appendChild(el);
- }
- var libName, libs = {
- _: "//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js",
- jQuery: "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js",
- // sugar: "//cdnjs.cloudflare.com/ajax/libs/sugar/1.4.1/sugar.min.js"
- };
- for (libName in libs) {
- if (!window[libName]) {
- addElToBody('script', {
- src: libs[libName]
- });
- }
- }
- document.body.style.margin = 0;
- if (!document.querySelector('#layers')) {
- addElToBody('div', {
- 'id': 'layers',
- 'style': "width:100%; height:100%;"
- });
- }
- function initAllModules(){
- window['require'] = {};
- require.str = (function str (require) {Object.defineProperty(this, 'module_name', {value:'str'});
- var ifs;
- this["if"] = ifs = function(arg, true_str, false_str) {
- if (true_str == null) {
- true_str = arg;
- }
- if (arg) {
- return true_str;
- } else {
- if (false_str != null) {
- return false_str;
- } else {
- return '';
- }
- }
- };
- this.capitalize = function(str) {
- return str[0].toUpperCase() + str.slice(1);
- };
- this.dasherize = function(str) {
- return str.replace(/([A-Z])/g, function(full, match) {
- return '-' + match.toLowerCase();
- }).replace(/ /g, '-');
- };
- this.parsesToNumber = this.isNumber = function(str) {
- return !Number.isNaN(parseInt(str));
- };
- this.truncate = function(str, limit, truncStr) {
- if (truncStr == null) {
- truncStr = '...';
- }
- if (str.length > limit) {
- return str.slice(0, limit) + truncStr;
- } else {
- return str;
- }
- };
- this.titleize = this.titelize = function(str) {
- return str.replace(/[-_]/g, ' ').replace(/(^| )(\w)/g, function(full, s, firstChar) {
- return s + firstChar.toUpperCase();
- }).replace(/(\w)([A-Z])/g, function(f, s, c) {
- return s + ' ' + c;
- });
- };
- this.random = function(limit) {
- if (limit == null) {
- limit = 20;
- }
- return (Math.random() + '').slice(2, +(limit + 1) + 1 || 9e9);
- };
- this.remove = function(full, remove) {
- return full.replace(remove, '');
- };
- this.reverse = function(str) {
- return str.split("").reverse().join('');
- };
- return this;
- }).call({}, require);
- //# sourceURL=str-143
- require.html = (function html (require) {Object.defineProperty(this, 'module_name', {value:'html'});
- 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'];
- 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"];
- 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'];
- this.condenseTags = function(htmlStr) {
- return htmlStr.replace(/>( |\n)+<(\w)/g, function(full, content, char) {
- return '><' + char;
- });
- };
- this.prettify = function(htmlStr) {
- var indent;
- if (htmlStr instanceof Element) {
- htmlStr = htmlStr.outerHTML;
- }
- indent = '';
- return htmlStr.replace(/<(\/)?[^>]+>/g, function(full, closing, pos) {
- var followingIsClosing, indentBeg, res;
- indentBeg = indent;
- if (closing) {
- followingIsClosing = htmlStr.slice(pos + full.length, +(pos + full.length + 1) + 1 || 9e9) === '</';
- indent = indent.substr(2);
- res = full + require.str["if"](followingIsClosing, "\n" + indent);
- } else {
- indent += ' ';
- res = "\n" + indent + full;
- }
- return res;
- });
- };
- return this;
- }).call({}, require);
- //# sourceURL=html-144
- require.typeof = (function (require) {Object.defineProperty(this, 'module_name', {value:'typeof'});
- 123;
- return function(arg) {
- var type;
- type = typeof arg;
- if (type === 'object') {
- if (arg instanceof Array || ArrayBuffer.isView(arg)) {
- return 'array';
- }
- if (arg === null) {
- return 'null';
- }
- }
- return type;
- };
- return this;
- }).call({}, require);
- //# sourceURL=typeof-145
- require.argumentTypes = (function argumentTypes (require) {Object.defineProperty(this, 'module_name', {value:'argumentTypes'});
- var defaultMapping;
- defaultMapping = {
- string: 'str',
- number: 'num',
- object: 'obj',
- array: 'arr',
- boolean: 'boo',
- "function": 'fun',
- undefined: 'nil',
- "null": 'nil'
- };
- return function(args, typeMapping, defaultValues) {
- var arg, argTypes, current, i, key, len, ref, ref1, typeName, val;
- if (typeMapping == null) {
- typeMapping = defaultMapping;
- }
- argTypes = {};
- for (i = 0, len = args.length; i < len; i++) {
- arg = args[i];
- typeName = (ref = (ref1 = typeMapping[require["typeof"](arg)]) != null ? ref1 : typeMapping["default"]) != null ? ref : 'default';
- if (current = argTypes[typeName]) {
- if (Array.isArray(current)) {
- current.push(arg);
- } else {
- argTypes[typeName] = [argTypes[typeName], arg];
- }
- } else {
- argTypes[typeName] = arg;
- }
- }
- for (key in defaultValues) {
- val = defaultValues[key];
- if (argTypes[key] == null) {
- argTypes[key] = val;
- }
- }
- return argTypes;
- };
- return this;
- }).call({}, require);
- //# sourceURL=argumentTypes-146
- require.assert = (function assert (require) {Object.defineProperty(this, 'module_name', {value:'assert'});
- var argMapping, assert;
- argMapping = {
- "function": 'testFunc',
- string: 'errorMessage',
- "default": 'result'
- };
- return assert = function() {
- var errorMessage, ref, result, testFunc;
- if (arguments.length > 2) {
- throw 'depracated assert call';
- }
- ref = require.argumentTypes(arguments, argMapping), result = ref.result, testFunc = ref.testFunc, errorMessage = ref.errorMessage;
- if (testFunc) {
- result = testFunc();
- }
- if (!result) {
- throw Error("assert failed: '" + errorMessage + "'");
- }
- };
- return this;
- }).call({}, require);
- //# sourceURL=assert-147
- require.object = (function object (require) {Object.defineProperty(this, 'module_name', {value:'object'});
- var identity,
- slice = [].slice;
- identity = function(el) {
- return el;
- };
- this.clone = typeof _ !== "undefined" && _ !== null ? _.clone : void 0;
- this.isEqual = typeof _ !== "undefined" && _ !== null ? _.isEqual : void 0;
- this.dellAll = function(obj) {
- var key;
- for (key in obj) {
- delete obj[key];
- }
- };
- this.filter = function(obj, filterer) {
- var filtered, key, val;
- filtered = {};
- for (key in obj) {
- val = obj[key];
- if (filterer(key, val)) {
- filtered[key] = val;
- }
- }
- return filtered;
- };
- this.forEach = function(obj, func) {
- var key, val;
- for (key in obj) {
- val = obj[key];
- func(val, key);
- }
- };
- this.fromArray = function(array, valFromEl, keyFromEl) {
- var el, i, ind, len, obj;
- if (valFromEl == null) {
- valFromEl = identity;
- }
- if (keyFromEl == null) {
- keyFromEl = identity;
- }
- obj = {};
- for (ind = i = 0, len = array.length; i < len; ind = ++i) {
- el = array[ind];
- obj[keyFromEl(el, ind)] = valFromEl(el, ind);
- }
- return obj;
- };
- this.isObject = function(o) {
- return typeof o === 'object' && !Array.isArray(o) && o !== null;
- };
- this.map = function(obj, mapFuncs) {
- var key, newObj, val;
- require.assert("'mapFuncs' argument should include 'key' and/or 'val' transform functions", (mapFuncs.key != null) || (mapFuncs.val != null));
- if (mapFuncs.key == null) {
- mapFuncs.key = identity;
- }
- if (mapFuncs.val == null) {
- mapFuncs.val = identity;
- }
- newObj = {};
- for (key in obj) {
- val = obj[key];
- newObj[mapFuncs.key(key, val)] = mapFuncs.val(val, key);
- }
- return newObj;
- };
- this.merge = function() {
- var first, i, key, len, obj, rest, val;
- first = arguments[0], rest = 2 <= arguments.length ? slice.call(arguments, 1) : [];
- for (i = 0, len = rest.length; i < len; i++) {
- obj = rest[i];
- for (key in obj) {
- val = obj[key];
- first[key] = val;
- }
- }
- return first;
- };
- this.mergeWary = function() {
- var first, i, key, len, obj, rest, val;
- first = arguments[0], rest = 2 <= arguments.length ? slice.call(arguments, 1) : [];
- for (i = 0, len = rest.length; i < len; i++) {
- obj = rest[i];
- for (key in obj) {
- val = obj[key];
- if (first[key] == null) {
- first[key] = val;
- }
- }
- }
- return first;
- };
- this.mergeDeep = function(target, source) {
- var key, targetProp, val;
- for (key in source) {
- val = source[key];
- targetProp = target[key];
- if (this.isObject(targetProp) && this.isObject(val)) {
- this.mergeDeep(targetProp, val);
- } else {
- target[key] = val;
- }
- }
- return target;
- };
- this.eachDeep = function(rootObj, func, filter) {
- var depth, hasBeenExecuted, iterator;
- if (filter == null) {
- filter = function() {
- return true;
- };
- }
- depth = 1;
- hasBeenExecuted = new Map;
- iterator = function(obj, parent) {
- var key, val;
- if (hasBeenExecuted.get(obj)) {
- return;
- }
- hasBeenExecuted.set(obj, true);
- for (key in obj) {
- val = obj[key];
- if (!(filter(key, val, depth))) {
- continue;
- }
- if (typeof val === 'object') {
- depth++;
- iterator(val, obj);
- depth--;
- }
- func(key, val, parent);
- }
- };
- iterator(rootObj);
- };
- this.select = function(obj, keysArr) {
- var i, key, len, newObj;
- newObj = {};
- for (i = 0, len = keysArr.length; i < len; i++) {
- key = keysArr[i];
- newObj[key] = obj[key];
- }
- return newObj;
- };
- this.values = function(obj) {
- var k, results, value;
- results = [];
- for (k in obj) {
- value = obj[k];
- results.push(value);
- }
- return results;
- };
- return this;
- }).call({}, require);
- //# sourceURL=object-148
- require.create_html_node = (function create_html_node (require) {Object.defineProperty(this, 'module_name', {value:'create_html_node'});
- var create_html_node;
- return create_html_node = function(sKey) {
- var classes, domElName, el, idName, ref, ref1, ref2;
- if (sKey == null) {
- sKey = 'div';
- }
- domElName = ((ref = sKey.match(/^(h[1-6]|[^ #._0123456789]+)\d?/)) != null ? ref[1] : void 0) || 'div';
- idName = (ref1 = sKey.match(/#[^ ]+/)) != null ? ref1[0].slice(1) : void 0;
- classes = (ref2 = sKey.match(/\.[^ #.]+/g)) != null ? ref2.map(function(cStr) {
- return cStr.slice(1);
- }) : void 0;
- el = document.createElement(domElName);
- if (idName != null) {
- el.id = idName;
- }
- if (classes != null ? classes.length : void 0) {
- el.setAttribute('class', classes.join(' '));
- }
- return el;
- };
- return this;
- }).call({}, require);
- //# sourceURL=create_html_node-149
- require.node_from_obj = (function node_from_obj (require) {Object.defineProperty(this, 'module_name', {value:'node_from_obj'});
- var allAttrActions, defaultAction, defaultAttrsMap, eventAction, eventAttrsMap, iterate, node_from_obj, specialAttrsMap, stackDepth;
- eventAction = function(attrName, attrVal, node) {
- var eventName;
- eventName = attrName.toLowerCase().slice(2);
- node.addEventListener(eventName, attrVal, false);
- if (node.listeners == null) {
- node.listeners = {};
- }
- if (node.listeners[attrName] != null) {
- throw "Event system don't allow binding two events of same type to same node";
- }
- return node.listeners[eventName] = attrVal;
- };
- defaultAction = function(attrName, attrVal, node) {
- if (attrVal != null) {
- return node.setAttribute(attrName, attrVal);
- }
- };
- defaultAttrsMap = require.object.fromArray(require.html.standardAttrs, function() {
- return defaultAction;
- });
- eventAttrsMap = require.object.fromArray(require.html.eventAttrs, function() {
- return eventAction;
- });
- specialAttrsMap = {
- raw: function(attrName, attrVal, node) {
- return node.innerHTML = attrVal;
- },
- text: function(attrName, attrVal, node) {
- return node.textContent = attrVal;
- }
- };
- allAttrActions = require.object.merge(defaultAttrsMap, eventAttrsMap);
- require.object.merge(allAttrActions, specialAttrsMap);
- stackDepth = 0;
- iterate = function(node, val) {
- var attrName, i, key, len, nonStandard, subVal, tag;
- if (val == null) {
- return node;
- }
- if (stackDepth > 100) {
- stackDepth = 0;
- throw "node_from_obj stack depth > 100; endless loop?";
- }
- stackDepth++;
- if (typeof val === 'function') {
- val = val(node);
- if (val === node) {
- return;
- }
- }
- if (val instanceof Array) {
- for (i = 0, len = val.length; i < len; i++) {
- subVal = val[i];
- iterate(node, subVal);
- }
- } else if (val instanceof Node) {
- node.appendChild(val);
- } else if (typeof val === 'object') {
- for (key in val) {
- subVal = val[key];
- if (allAttrActions[key] || (nonStandard = /^\w*[A-Z]/.test(key))) {
- if (node.setAttribute == null) {
- throw new Error("Can't set attributes ('" + key + "') for root list (" + key + ")");
- }
- if (nonStandard) {
- attrName = key.replace(/[A-Z]/g, function(match, ind) {
- return (require.str["if"](ind !== 0, '-')) + match.toLowerCase();
- });
- defaultAction(attrName, subVal, node);
- nonStandard = null;
- } else {
- allAttrActions[key](key, subVal, node);
- }
- } else if (key.match(/^me[0-9]?$/)) {
- iterate(node, subVal);
- } else {
- tag = require.create_html_node(key);
- iterate(tag, subVal);
- node.appendChild(tag);
- }
- }
- } else {
- node.textContent = val;
- }
- stackDepth--;
- return node;
- };
- return node_from_obj = function(tmplObj) {
- var fragment;
- fragment = iterate(document.createDocumentFragment(), tmplObj);
- return fragment;
- };
- return this;
- }).call({}, require);
- //# sourceURL=node_from_obj-150
- require.dom = (function dom (require) {Object.defineProperty(this, 'module_name', {value:'dom'});
- this.addChilds = function(node, children) {
- var child, i, len, results;
- results = [];
- for (i = 0, len = children.length; i < len; i++) {
- child = children[i];
- results.push(node.appendChild(child));
- }
- return results;
- };
- this.getAttr = function(node, attrName) {
- var val;
- val = node.attributes.getNamedItem(attrName).value;
- if (require.str.parsesToNumber(val)) {
- return parseFloat(val);
- } else {
- return val;
- }
- };
- this.get = function(selector, parentEl) {
- if (parentEl == null) {
- parentEl = document;
- }
- return parentEl.querySelector(selector);
- };
- this.getAll = function(selector, parentEl) {
- if (parentEl == null) {
- parentEl = document;
- }
- return parentEl.querySelectorAll(selector);
- };
- this.fragment = document.createDocumentFragment.bind(document);
- this["new"] = function(type_id_class, props) {
- var el;
- if (typeof type_id_class === 'object') {
- return (require.node_from_obj(type_id_class)).childNodes[0];
- }
- el = require.create_html_node(type_id_class);
- switch (typeof props) {
- case 'string':
- el.innerHTML = props;
- break;
- case 'object':
- if (props) {
- require.object.merge(el, props);
- }
- }
- return el;
- };
- this.append = this.addTo = function(parent_element, content) {
- if (typeof content === 'object') {
- content = require.node_from_obj(content);
- }
- parent_element.appendChild(content);
- return content;
- };
- this.prepend = function(parentEl, content) {
- if (typeof content === 'object') {
- content = require.node_from_obj(content);
- }
- return parentEl.insertBefore(content, parentEl.firstChild);
- };
- this.remove = function(element) {
- var parentEl;
- if (typeof element === 'string') {
- element = this.get(element);
- }
- if ((parentEl = element != null ? element.parentElement : void 0) != null) {
- return parentEl.removeChild(element);
- } else {
- return console.info("failed to remove node", element);
- }
- };
- this.removeChildren = function(node) {
- var results;
- results = [];
- while (node.firstChild) {
- results.push(node.removeChild(node.firstChild));
- }
- return results;
- };
- this.render = function(node, htmlObj) {
- console.warn(":dom.render will deprecate");
- this.removeChildren(node);
- return node.appendChild(require.node_from_obj(htmlObj));
- };
- this.replaceChildren = this.replaceChilds = function(node, newContent) {
- this.removeChildren(node);
- return this.append(node, newContent);
- };
- this.replace = function(oldEl, newEl) {
- var parentEl;
- if (typeof newEl === 'object') {
- newEl = require.node_from_obj(newEl);
- }
- if ((parentEl = oldEl.parentElement) != null) {
- parentEl.replaceChild(newEl, oldEl);
- } else {
- console.info("failed to replace node", newEl, oldEl);
- }
- return newEl;
- };
- return this;
- }).call({}, require);
- //# sourceURL=dom-151
- require.array = (function array (require) {Object.defineProperty(this, 'module_name', {value:'array'});
- var flatten;
- this.includes = this.contains = this.has = function(arr, el) {
- return arr.indexOf(el) !== -1;
- };
- this.toObject = function(array, val_from_el, key_from_el) {
- var el, i, ind, len, obj;
- console.warn(":array.toObject will deprecate, use \:object.fromArray");
- obj = {};
- if (key_from_el == null) {
- key_from_el = function(el) {
- return el;
- };
- }
- for (ind = i = 0, len = array.length; i < len; ind = ++i) {
- el = array[ind];
- obj[key_from_el(el, ind)] = val_from_el(el, ind);
- }
- return obj;
- };
- this.toArray = function(arrayish) {
- return Array.prototype.slice.call(arrayish);
- };
- this.diff = function(arrA, arrB) {
- var diff, el, i, len, unchecked;
- unchecked = arrB.slice(0);
- diff = [];
- for (i = 0, len = arrA.length; i < len; i++) {
- el = arrA[i];
- if (arrB.indexOf(el) !== -1) {
- this.remove(unchecked, el);
- } else {
- diff.push(el);
- }
- }
- return diff.concat(unchecked);
- };
- this.flatten = flatten = function(arr) {
- return arr.reduce((function(a, b) {
- return a.concat(Array.isArray(b) ? flatten(b) : b);
- }), []);
- };
- this.last = this.lastOf = function(arr) {
- return arr[arr.length - 1];
- };
- this.setLastOf = function(arr, newVal) {
- return arr[arr.length - 1] = newVal;
- };
- this.pushArray = function(arr, arr2) {
- return arr.push.apply(arr, arr2);
- };
- this.remove = function(arr, el) {
- var ind;
- if ((ind = arr.indexOf(el)) !== -1) {
- arr.splice(ind, 1);
- }
- return arr;
- };
- this.count = function(arr, filterFunc) {
- var count, e, filterEl, i, len;
- if (typeof filterFunc !== 'function') {
- filterEl = filterFunc;
- filterFunc = function(e) {
- return e === filterEl;
- };
- }
- count = 0;
- for (i = 0, len = arr.length; i < len; i++) {
- e = arr[i];
- if (filterFunc(e)) {
- count++;
- }
- }
- return count;
- };
- return this;
- }).call({}, require);
- //# sourceURL=array-152
- require.events = (function events (require) {Object.defineProperty(this, 'module_name', {value:'events'});
- var slice = [].slice;
- this.initChild = function(childObj, logEvents) {
- if (childObj !== this) {
- Object.setPrototypeOf(childObj, this);
- }
- if (childObj.listeners == null) {
- childObj.listeners = {};
- }
- if (childObj.listenersFired == null) {
- childObj.listenersFired = {};
- }
- if (logEvents) {
- return childObj.logs = [];
- }
- };
- this.on = function() {
- var base, callback, eventNames, i, j, len, name;
- eventNames = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), callback = arguments[i++];
- for (j = 0, len = eventNames.length; j < len; j++) {
- name = eventNames[j];
- if ((base = this.listeners)[name] == null) {
- base[name] = [];
- }
- if (this.listeners[name].indexOf(callback) === -1) {
- this.listeners[name].push(callback);
- }
- }
- };
- this.onFirst = function(name, cb) {
- if (this.listenersFired[name]) {
- return cb.apply(null, this.listenersFired[name]);
- } else {
- return this.on(name, function() {
- cb.apply(null, arguments);
- return false;
- });
- }
- };
- this.bindUnloading = function() {};
- this.emit = function() {
- var args, callback, i, len, name, ref, remove;
- name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
- if (this.logs) {
- this.logs.push([name, Date.now(), args, this.listeners[name] != null]);
- }
- this.listenersFired[name] = args;
- if (this.listeners[name] == null) {
- return console.log("Event '" + name + "' emitted, but no one is listening!");
- }
- remove = [];
- ref = this.listeners[name];
- for (i = 0, len = ref.length; i < len; i++) {
- callback = ref[i];
- if ((callback.apply(null, args)) === false) {
- remove.push(callback);
- }
- }
- if (remove.length) {
- this.listeners[name] = this.listeners[name].filter(function(cb) {
- return remove.indexOf(cb) === -1;
- });
- }
- };
- this.removeListener = function(name, func) {
- return require.array.remove(this.listeners[name], func);
- };
- this.stats = function() {
- var hits, i, len, log, misses, name1, ref, target;
- if (this.logs == null) {
- return console.warn(":events @logs need to be on, to show stats");
- }
- hits = {};
- misses = {};
- ref = this.logs;
- for (i = 0, len = ref.length; i < len; i++) {
- log = ref[i];
- target = log[3] ? hits : misses;
- if (target[name1 = log[0]] == null) {
- target[name1] = 0;
- }
- target[log[0]] += 1;
- }
- return {
- hits: hits,
- misses: misses
- };
- };
- return this;
- }).call({}, require);
- //# sourceURL=events-153
- require.editor_events = (function editor_events (require) {Object.defineProperty(this, 'module_name', {value:'editor_events'});
- require.events.initChild(this, true);
- window.addEventListener('unload', (this.unloadEditor != null ? this.unloadEditor : this.unloadEditor = (function(_this) {
- return function(ev) {
- return _this.emit('editor_removed', ev);
- };
- })(this)));
- this.safe = function() {};
- return this;
- }).call({}, require);
- //# sourceURL=editor_events-154
- require.pager = (function pager (require) {Object.defineProperty(this, 'module_name', {value:'pager'});
- var slice = [].slice;
- require.events.initChild(this, true);
- this.defaultPage = 'edit';
- this.defaultParams = {
- '0': 'front_page',
- '1': 'fullscreen'
- };
- this.useHashUrl = true;
- if (this.page == null) {
- this.page = null;
- }
- if (this.params == null) {
- this.params = {};
- }
- if (this.skipEvent == null) {
- this.skipEvent = false;
- }
- if (this.initialized == null) {
- this.initialized = false;
- }
- this.parseRootAndParams = function(str) {
- var aParams, i, k, keyInd, len, oParams, ref, ref1, rootName, sParam, v;
- ref = str.split('/'), rootName = ref[0], aParams = 2 <= ref.length ? slice.call(ref, 1) : [];
- oParams = {};
- keyInd = 0;
- for (i = 0, len = aParams.length; i < len; i++) {
- sParam = aParams[i];
- ref1 = sParam.split('='), k = ref1[0], v = ref1[1];
- if (v != null) {
- oParams[k] = v;
- } else {
- oParams[keyInd++] = k;
- }
- }
- return [rootName, oParams];
- };
- if (this.urlChecker == null) {
- this.urlChecker = (function(_this) {
- return function() {
- var i, isDiff, key, len, oldPage, oldParams, paramKeys, ref, ref1, urlPath, valueName;
- if (_this.skipEvent) {
- _this.skipEvent = false;
- return;
- }
- urlPath = window.location.hash.replace(/#\/?/, '').replace(/\/$/, '');
- ref = [_this.page, require.object.clone(_this.params)], oldPage = ref[0], oldParams = ref[1];
- ref1 = _this.parseRootAndParams(urlPath), _this.page = ref1[0], _this.params = ref1[1];
- if (!_this.page.length) {
- _this.page = _this.defaultPage;
- }
- if (_this.params[0] == null) {
- _this.params = _this.defaultParams;
- }
- if (_this.page !== oldPage) {
- _this.emit('pageChanged', _this.page, oldPage);
- }
- paramKeys = _.uniq(Object.keys(oldParams).concat(Object.keys(_this.params)));
- for (i = 0, len = paramKeys.length; i < len; i++) {
- key = paramKeys[i];
- if (_this.params[key] !== oldParams[key]) {
- _this.emit('changed:' + key, _this.params[key], oldParams[key]);
- if (require.str.parsesToNumber(key)) {
- valueName = _this.params[key] || oldParams[key];
- _this.emit('changed:' + valueName, !!_this.params[key]);
- }
- isDiff = true;
- }
- }
- };
- })(this);
- }
- if (this.useHashUrl) {
- window.addEventListener('hashchange', this.urlChecker);
- require.editor_events.onFirst('codemirror_initialized', this.urlChecker);
- }
- this.unload = function(parentName, final) {
- if (final) {
- return window.removeEventListener('hashchange', this.urlChecker);
- }
- };
- this.setPath = function(pathStr) {
- if (this.useHashUrl) {
- window.location.hash = '/' + pathStr;
- }
- };
- this.updateUrl = function(newParams, newPage) {
- if (newParams == null) {
- newParams = this.params;
- }
- if (newPage == null) {
- newPage = this.page;
- }
- this.setPath(newPage + '/' + this.paramsAsStrArr(newParams).join('/'));
- };
- this.paramsAsStrArr = function(params) {
- var pName, pVal, results;
- results = [];
- for (pName in params) {
- pVal = params[pName];
- if (isNaN(pName - 0)) {
- results.push(pName + "=" + pVal);
- } else {
- results.push(pVal);
- }
- }
- return results;
- };
- this.get = this.getParam = function(name) {
- var key, ref, val;
- if (this.params[name] != null) {
- return decodeURIComponent(this.params[name]);
- } else {
- ref = this.params;
- for (key in ref) {
- val = ref[key];
- if (!isNaN(key - 0)) {
- if (val === name) {
- return true;
- }
- }
- }
- }
- };
- this.set = this.setParam = function(name, value, skipEvent) {
- var newParams;
- this.skipEvent = skipEvent;
- newParams = require.object.clone(this.params);
- if (value == null) {
- if (this.getParam(name)) {
- return;
- }
- value = name;
- name = Object.keys(newParams).length;
- }
- newParams[name] = value;
- this.updateUrl(newParams);
- return value;
- };
- this.remove = this.removeParam = function(name, skipEvent) {
- var key, newParams, val;
- this.skipEvent = skipEvent;
- newParams = require.object.clone(this.params);
- if (newParams[name] != null) {
- delete newParams[name];
- } else {
- for (key in newParams) {
- val = newParams[key];
- if (!isNaN(key - 0)) {
- if (name === val) {
- delete newParams[key];
- }
- }
- }
- }
- this.updateUrl(newParams);
- };
- this.toggle = this.toggleParam = function(name) {
- if (this.getParam(name)) {
- return this.removeParam(name);
- } else {
- return this.setParam(name);
- }
- };
- return this;
- }).call({}, require);
- //# sourceURL=pager-155
- require.module = (function module (require) {Object.defineProperty(this, 'module_name', {value:'module'});
- this.getBase = this.getId = this.getName = function(nameOrMod) {
- if (typeof nameOrMod === 'string') {
- return nameOrMod;
- } else {
- return nameOrMod.module_name;
- }
- };
- this.reset = function(moduleName) {
- var module;
- if ((module = modules.all[moduleName]) != null) {
- this.deleteProps(module);
- } else {
- modules.all[moduleName] = {};
- }
- };
- this.deleteProps = function(module) {
- var i, key, len, ref;
- ref = Object.getOwnPropertyNames(module);
- for (i = 0, len = ref.length; i < len; i++) {
- key = ref[i];
- delete module[key];
- }
- };
- this.run = function() {
- return canvas_wars.recompile_editor();
- };
- this.rerun_parent_modules = function(moduleName) {
- var i, len, parentModule, ref;
- if (typeof moduleName === 'object') {
- moduleName = moduleName.module_name;
- }
- ref = Object.keys(modules.required_from[moduleName]);
- for (i = 0, len = ref.length; i < len; i++) {
- parentModule = ref[i];
- this.execute(parentModule);
- }
- };
- this.execute = function(module) {
- return canvas_wars.execute_module(this.getName(module));
- };
- this.executeAll = function(module, depth) {
- var executed, filter;
- module = this.getName(module);
- filter = depth != null ? function(k, v, d) {
- return d <= depth;
- } : function() {
- return true;
- };
- executed = {};
- require.object.eachDeep(modules.deps_tree[module], (function(_this) {
- return function(subModName) {
- if (executed[subModName]) {
- return;
- }
- _this.execute(subModName);
- return executed[subModName] = true;
- };
- })(this), filter);
- return this.execute(module);
- };
- this.fromName = function(name) {
- return modules.all[name];
- };
- this.getCurrentName = function() {
- return require.pager.get(0);
- };
- this.getCurrent = function() {
- return this.fromName(this.getCurrentName());
- };
- this.listAllChildren = function(moduleName) {
- var childs, key, results;
- childs = {};
- require.object.eachDeep(modules.deps_tree[moduleName], function(key) {
- return childs[key] = true;
- });
- results = [];
- for (key in childs) {
- results.push(key);
- }
- return results;
- };
- this.isBeingEdited = function(module) {
- return module.module_name === this.getCurrentName();
- };
- return this;
- }).call({}, require);
- //# sourceURL=module-156
- require.aspectRatio = (function aspectRatio (require) {Object.defineProperty(this, 'module_name', {value:'aspectRatio'});
- this.setContainer = function(containerWidth, containerHeight) {
- this.containerWidth = containerWidth;
- this.containerHeight = containerHeight;
- if (this.containerWidth instanceof Node) {
- this.containerHeight = this.containerWidth.clientHeight;
- this.containerWidth = this.containerWidth.clientWidth;
- }
- return this;
- };
- this.fitInCointainer = function(widthToHeight) {
- if (this.containerHeight > this.containerWidth / widthToHeight) {
- this.width = this.containerWidth;
- this.height = this.containerWidth / widthToHeight;
- } else {
- this.height = this.containerHeight;
- this.width = this.containerHeight * widthToHeight;
- }
- return [this.width, this.height];
- };
- return this;
- }).call({}, require);
- //# sourceURL=aspectRatio-157
- require.editor_sizes = (function editor_sizes (require) {Object.defineProperty(this, 'module_name', {value:'editor_sizes'});
- this.editorFont = 10;
- this.uiFont = 12;
- this.topRowHeight = 26;
- this.modulesInfoHeight = 18;
- return this;
- }).call({}, require);
- //# sourceURL=editor_sizes-158
- require.coffee_styles = (function coffee_styles (require) {Object.defineProperty(this, 'module_name', {value:'coffee_styles'});
- this.addStyles = function(el_id, rules) {
- var cssStr, styleEl;
- if (typeof window === "undefined" || window === null) {
- return console.error("Trying to create StyleSheet rules on server side!");
- }
- if (arguments.length === 1) {
- rules = el_id;
- el_id = 'main';
- }
- el_id = el_id + '_styles';
- rules = typeof rules === 'function' ? rules.call(this.helpers) : rules;
- this.stack = [];
- cssStr = typeof rules === 'object' ? this.compile(rules) : rules;
- styleEl = document.getElementById(el_id);
- if (styleEl == null) {
- styleEl = document.createElement('style');
- styleEl.id = el_id;
- document.head.appendChild(styleEl);
- }
- if (el_id === 'main_styles') {
- styleEl.innerHTML += cssStr;
- } else {
- styleEl.innerHTML = cssStr;
- }
- };
- this.non_pixel_vars = ['font-weight', 'opacity', 'z-index', 'zoom'];
- this.vendors = function(property_name, val) {
- var i, len, obj, ref, vendor;
- obj = {};
- ref = ['webkit', 'moz', 'ms'];
- for (i = 0, len = ref.length; i < len; i++) {
- vendor = ref[i];
- obj["-" + vendor + "-" + property_name] = val;
- }
- obj[property_name] = val;
- return obj;
- };
- this.create_property_string = function(key, value) {
- var val;
- key = key.replace(/_/g, '-');
- key = key.replace(/[A-Z]/g, function(s) {
- return '-' + s.toLowerCase();
- });
- if (typeof value === 'number' && this.non_pixel_vars.indexOf(key) === -1) {
- value = value + "px";
- }
- if (key.match(' -v')) {
- key = key.split(' ')[0];
- return ((function() {
- var ref, results;
- ref = this.vendors(key, val);
- results = [];
- for (key in ref) {
- val = ref[key];
- results.push(" " + key + ": " + value + ";\n");
- }
- return results;
- }).call(this)).join('');
- } else {
- return " " + key + ": " + value + ";\n";
- }
- };
- this.compile = function(rulesObj) {
- var childRules, childSelector, children, combineStr, cssStr, declarations, firstChar, i, j, key, len, len1, mixin, nested, newCSS, parentSelector, ref, ref1, selector, val, value;
- if (this.stack.indexOf(rulesObj) !== -1 || this.stack.length === 100) {
- console.warn('@stack', this.stack);
- throw "Endless stack ccss.compile_to_str!";
- }
- this.stack.push(rulesObj);
- cssStr = '';
- for (selector in rulesObj) {
- childRules = rulesObj[selector];
- declarations = '';
- nested = {};
- if (selector.slice(0, 1) === '@') {
- cssStr += selector + ' { \n';
- cssStr += this.compile(childRules);
- return cssStr + '}\n';
- }
- while (childRules != null ? childRules.mixin : void 0) {
- mixin = childRules.mixin;
- childRules.mixin = null;
- for (key in mixin) {
- val = mixin[key];
- if (childRules[key] == null) {
- childRules[key] = val;
- }
- }
- }
- for (key in childRules) {
- value = childRules[key];
- if (typeof value === 'object') {
- children = [];
- ref = key.split(/\s*,\s*/);
- for (i = 0, len = ref.length; i < len; i++) {
- childSelector = ref[i];
- ref1 = selector.split(/\s*,\s*/);
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- parentSelector = ref1[j];
- firstChar = childSelector.slice(0, 1);
- combineStr = (function() {
- switch (firstChar) {
- case ':':
- return '';
- case '&':
- childSelector = childSelector.slice(1);
- return '';
- default:
- return ' ';
- }
- })();
- children.push(parentSelector + combineStr + childSelector);
- }
- }
- nested[children.join(',')] = value;
- } else {
- declarations += this.create_property_string(key, value);
- }
- }
- if (declarations.length) {
- newCSS = selector + " {\n" + declarations + "}\n";
- try {
- cssStr += newCSS;
- } catch (_error) {
- console.log("failed with ", newCSS);
- return;
- }
- }
- cssStr += this.compile(nested);
- }
- return cssStr;
- };
- return this;
- }).call({}, require);
- //# sourceURL=coffee_styles-159
- require.styles = (function styles (require) {Object.defineProperty(this, 'module_name', {value:'styles'});
- if (this.addedStyles == null) {
- this.addedStyles = {};
- }
- this.addScoped = function(module, styleObj) {
- var obj;
- styleObj = (
- obj = {},
- obj["#" + module.module_name] = styleObj,
- obj
- );
- return this.add(module, styleObj);
- };
- this.add = function(id_or_obj, objOrCssStr) {
- if (arguments.length !== 2) {
- return;
- }
- if (typeof id_or_obj === 'object') {
- id_or_obj = id_or_obj.module_name;
- }
- if (typeof id_or_obj !== 'string') {
- throw Error("\:styles.add require id string");
- }
- this.addedStyles[id_or_obj] = true;
- return require.coffee_styles.addStyles(id_or_obj, objOrCssStr);
- };
- this.parseNode = function(dom_element_style_definitions) {};
- this.clear = function() {
- var idStr, results;
- results = [];
- for (idStr in this.addedStyles) {
- results.push(this.unload(idStr));
- }
- return results;
- };
- this.unload = function(idStr) {
- var i, len, ref, styleEl;
- if (!idStr) {
- return;
- }
- ref = document.querySelectorAll("head #" + idStr + "_styles");
- for (i = 0, len = ref.length; i < len; i++) {
- styleEl = ref[i];
- require.dom.remove(styleEl);
- }
- return delete this.addedStyles[idStr];
- };
- return this;
- }).call({}, require);
- //# sourceURL=styles-160
- require.unload = (function unload (require) {Object.defineProperty(this, 'module_name', {value:'unload'});
- var unload;
- return unload = function(mod, cb) {
- switch (require["typeof"](mod.unload)) {
- case 'array':
- if (mod.unload.includes(cb)) {
- return;
- }
- return mod.unload.push(cb);
- case 'function':
- if (mod.unload === cb) {
- return;
- }
- return mod.unload = [mod.unload, cb];
- default:
- return mod.unload = cb;
- }
- };
- return this;
- }).call({}, require);
- //# sourceURL=unload-161
- require.layers_styles = (function layers_styles (require) {Object.defineProperty(this, 'module_name', {value:'layers_styles'});
- var availableHeight, id;
- id = 'layer';
- availableHeight = "calc(100% - " + require.editor_sizes.modulesInfoHeight + "px)";
- if (this.normal == null) {
- this.normal = (function(_this) {
- return function() {
- var state;
- state = 'normal';
- return require.styles.add(id, {
- '#layers': {
- width: '100%',
- height: "calc(100% - " + require.editor_sizes.modulesInfoHeight + "px)",
- overflow: 'hidden',
- pointerEvents: 'none',
- '& > *': {
- pointerEvents: 'all',
- position: 'absolute',
- top: '0',
- left: '0',
- overflowY: 'auto',
- '&:not(canvas)': {
- height: '100%',
- width: '100%'
- }
- },
- '& > canvas': {
- overflowY: 'hidden',
- top: '50%',
- left: '50%',
- transform: 'translate(-50%, -50%)'
- }
- }
- });
- };
- })(this);
- }
- this.normal();
- this.none = function(mod) {
- if (!mod) {
- throw Error("add caller module");
- }
- require.styles.unload(id);
- return require.unload(mod, this.normal);
- };
- return this;
- }).call({}, require);
- //# sourceURL=layers_styles-162
- require.layers = (function layers (require) {Object.defineProperty(this, 'module_name', {value:'layers'});
- var ref;
- if (this.container == null) {
- this.container = (ref = document.getElementById('layers')) != null ? ref : require.dom["new"]('#layers');
- }
- if (this.addedLayers == null) {
- this.addedLayers = {};
- }
- if (this.canvases == null) {
- this.canvases = {};
- }
- this.add = function(node, name) {
- var ref1;
- name = (ref1 = name.module_name) != null ? ref1 : name;
- if (!node.id) {
- node.id = name;
- }
- if (this.addedLayers[name]) {
- this.unload(name);
- }
- return this.addedLayers[name] = this.container.appendChild(node);
- };
- this.get = function(layerName, elementType) {
- var node;
- if (elementType == null) {
- elementType = 'div';
- }
- layerName = require.module.getId(layerName);
- if (!(node = this.addedLayers[layerName])) {
- if (!(node = this.container.querySelector('#' + layerName))) {
- node = document.createElement(elementType);
- node.id = layerName;
- node.className = 'layer';
- this.container.appendChild(node);
- }
- this.addedLayers[layerName] = node;
- }
- return node;
- };
- this.getCanvas = function(nameOrMod, widthToHeight, ctxType) {
- var el, name, ref1;
- if (ctxType == null) {
- ctxType = '2d';
- }
- if (typeof nameOrMod === 'object') {
- if (nameOrMod.viewChangeRecompile == null) {
- nameOrMod.viewChangeRecompile = true;
- }
- }
- name = require.module.getId(nameOrMod);
- el = this.get(name, 'canvas');
- if (widthToHeight != null) {
- require.aspectRatio.setContainer(this.container);
- ref1 = require.aspectRatio.fitInCointainer(widthToHeight), el.width = ref1[0], el.height = ref1[1];
- } else {
- el.width = this.container.clientWidth;
- el.height = this.container.clientHeight;
- }
- return this.canvases[name] = {
- node: el,
- ctx: el.getContext(ctxType),
- width: el.width,
- height: el.height,
- widthToHeight: widthToHeight
- };
- };
- this.has = function(layer) {
- return this.addedLayers[require.module.getId(layer)] != null;
- };
- this.clear = function() {
- var id, layerEl, ref1, results;
- ref1 = this.addedLayers;
- results = [];
- for (id in ref1) {
- layerEl = ref1[id];
- results.push(this.unload(layerEl));
- }
- return results;
- };
- this.unload = function(layer, final) {
- var i, len, obj, ref1;
- if (final) {
- ref1 = [this.addedLayers, this.canvases];
- for (i = 0, len = ref1.length; i < len; i++) {
- obj = ref1[i];
- require.object.dellAll(obj);
- }
- require.dom.removeChildren(this.container);
- return;
- }
- if (!(layer instanceof Element)) {
- layer = require.module.getId(layer);
- }
- if (typeof layer === 'string') {
- layer = this.addedLayers[layer];
- }
- if (layer instanceof Element) {
- delete this.addedLayers[layer.id];
- delete this.canvases[layer.id];
- require.dom.remove(layer);
- } else if (layer) {
- console.warn('unknown layer.unload type', layer);
- }
- };
- if (this.refresh == null) {
- this.refresh = (function(_this) {
- return function(runModule) {
- var name, node, ref1, ref2, results;
- require.aspectRatio.setContainer(_this.container);
- ref1 = _this.addedLayers;
- results = [];
- for (name in ref1) {
- node = ref1[name];
- if (node.tagName === 'CANVAS') {
- if (_this.canvases[name].widthToHeight != null) {
- results.push((ref2 = require.aspectRatio.fitInCointainer(_this.canvases[name].widthToHeight), node.width = ref2[0], node.height = ref2[1], ref2));
- } else {
- node.width = _this.container.clientWidth;
- results.push(node.height = _this.container.clientHeight);
- }
- } else {
- results.push(void 0);
- }
- }
- return results;
- };
- })(this);
- }
- if (this.fullRefresh == null) {
- this.fullRefresh = (function(_this) {
- return function() {
- var ref1;
- _this.refresh();
- if (((ref1 = require.module.getCurrent()) != null ? ref1.viewChangeRecompile : void 0) && !window.canvas_wars.loading) {
- return canvas_wars.recompile_editor();
- }
- };
- })(this);
- }
- this.styles = require.layers_styles;
- return this;
- }).call({}, require);
- //# sourceURL=layers-163
- require.render = (function render (require) {Object.defineProperty(this, 'module_name', {value:'render'});
- this.toNode = function(node, htmlObjOrNode) {
- require.dom.removeChildren(node);
- if (!(htmlObjOrNode instanceof Node)) {
- htmlObjOrNode = require.node_from_obj(htmlObjOrNode);
- }
- node.appendChild(htmlObjOrNode);
- return node;
- };
- this.toLayer = function(module, htmlObjOrNode) {
- return this.toNode(require.layers.get(module), htmlObjOrNode);
- };
- this.unload = function(from, final) {
- return require.layers.unload(from);
- };
- this.late = function(moduleOrNode, htmlObjFunc) {
- var func;
- func = moduleOrNode instanceof Node ? this.toNode : this.toLayer.bind(this);
- return setTimeout(function() {
- return func(moduleOrNode, htmlObjFunc());
- });
- };
- return this;
- }).call({}, require);
- //# sourceURL=render-164
- require.common_style_classes = (function common_style_classes (require) {Object.defineProperty(this, 'module_name', {value:'common_style_classes'});
- require.object.merge(this, {
- '.align_center': {
- display: 'block',
- top: '50%',
- left: '50%',
- 'transform -v': 'translate(-50%,-50%)'
- },
- '.vertical_align_center': {
- display: 'block',
- top: '50%',
- 'transform -v': 'translateY(-50%)'
- },
- '.clickable, .pointer': {
- cursor: 'pointer'
- },
- '.one-line': {
- display: 'block',
- whiteSpace: 'nowrap',
- overflow: 'hidden',
- textOverflow: 'ellipsis'
- },
- '.inline-block': {
- display: 'inline-block',
- verticalAlign: 'top'
- }
- });
- require.styles.add(this, this);
- return this;
- }).call({}, require);
- //# sourceURL=common_style_classes-165
- require.color = (function color (require) {Object.defineProperty(this, 'module_name', {value:'color'});
- this.l = this.lightness = function(lightness) {
- return "hsl(0,0%," + lightness + "%)";
- };
- this.la = this.lightnessAlpha = function(lightness, alpha) {
- return "hsla(0,0%," + lightness + "%," + alpha + ")";
- };
- this.h = this.hue = function(hue) {
- return "hsl(" + hue + ",100%,50%)";
- };
- this.hl = function(hue, l) {
- return "hsl(" + hue + ",100%," + l + "%)";
- };
- this.hsl = function(h, s, l) {
- return "hsl(" + h + "," + s + "%," + l + "%)";
- };
- this.hsla = function(h, s, l, a) {
- return "hsla(" + h + "," + s + "%," + l + "%," + a + ")";
- };
- return this;
- }).call({}, require);
- //# sourceURL=color-166
- require.editor_colors = (function editor_colors (require) {Object.defineProperty(this, 'module_name', {value:'editor_colors'});
- this.purple = 'hsl(261, 90%, 75%)';
- this.blue = 'hsl(203, 90%, 63%)';
- this.turcose = "hsl(170, 90%, 50%)";
- this.green = "hsl(90, 75%, 50%)";
- this.green_hover = "hsl(90, 100%, 70%)";
- this.yellow = 'hsl(57, 72%, 65%)';
- this.orange = 'hsl(37, 100%, 56%)';
- this.red = 'hsl(19, 100%, 56%)';
- this.unhued_red = 'hsl(337, 100%, 56%)';
- this.gray = 'hsl(50, 11%, 55%)';
- this.white = 'hsl(0,0%,90%)';
- this.black = 'hsl(70, 8%, 12%)';
- this.uiGreen = require.color.hsl(130, 70, 43);
- this.uiRed = require.color.hsl(0, 80, 43);
- this.uiRedDim = require.color.hsl(0, 50, 43);
- return this;
- }).call({}, require);
- //# sourceURL=editor_colors-167
- require.syntax_styles = (function syntax_styles (require) {Object.defineProperty(this, 'module_name', {value:'syntax_styles'});
- var b;
- this.link_color = require.editor_colors.green;
- this.typeMapping = {
- 'string': 'yellow',
- 'null': 'purple',
- 'undefined': 'purple',
- boolean: 'blue',
- number: 'blue',
- array: 'turcose',
- object: 'green',
- 'function': 'orange'
- };
- this.operatorColor = require.editor_colors.red;
- this.types = require.object.map(this.typeMapping, {
- key: function(typeName) {
- return '.cm-' + typeName;
- },
- val: function(colorName) {
- return {
- color: require.editor_colors[colorName]
- };
- }
- });
- this.main = {
- '#editor, #editor pre': {
- fontSize: this.fontSize = require.editor_sizes.editorFont,
- lineHeight: this.lineHeight = '1.5em',
- letterSpacing: 1
- },
- 'a, a#login-name-link': {
- textDecoration: 'none',
- color: this.link_color,
- '&:hover': {
- color: require.editor_colors.green_hover
- }
- },
- '.cm-error.cm-require-link': {
- background: "hsl(0, 100%, 13%)",
- borderRadius: 3
- },
- '.cm-highlighted': {
- background: require.color.la(100, 0.19),
- textDecoration: 'none',
- "&:not(.cm-single)\:not(.cm-punctuation)": {
- borderBottom: b = '1px solid ' + require.color.l(80),
- borderTop: b
- },
- '&.cm-number:not(.cm-property)\:not(.cm-variable)\:not(.cm-string)': {
- background: require.editor_colors[this.typeMapping.number],
- color: require.editor_colors.black,
- fontWeight: 'bold',
- borderRadius: 2
- }
- },
- '.cm-require-link': {
- '&.cm-highlighted:not(.cm-punctuation)': {
- textDecoration: 'underline'
- },
- '&.cm-highlighted': {
- cursor: 'pointer'
- }
- },
- '.cm-editor-error': {
- backgroundColor: 'hsla(0, 100%, 40%, 0.55)',
- color: 'white !important',
- '&:first-child': {
- borderTopLeftRadius: 3,
- borderBottomLeftRadius: 3
- },
- '&:last-child': {
- borderTopRightRadius: 3,
- borderBottomRightRadius: 3
- }
- },
- '.cm-variable': {
- color: require.editor_colors.white
- },
- '.cm-keyword': {
- color: this.operatorColor
- },
- '.cm-atom': {
- color: require.editor_colors[this.typeMapping["null"]]
- },
- '.cm-punctuation': {
- color: require.editor_colors.orange
- },
- '.cm-operator': {
- color: this.operatorColor
- },
- '.CodeMirror-matchingbracket': {
- color: this.operatorColor
- }
- };
- this.rest = {
- '.cm-string-2': {
- color: this.operatorColor
- },
- '.cm-comment': {
- color: require.editor_colors.gray
- },
- '.CodeMirror-matchingbracket, .CodeMirror-nonmatchingbracket': {
- textDecoration: 'underline'
- },
- '.CodeMirror-nonmatchingbracket': {
- color: 'red'
- }
- };
- this.add = (function(_this) {
- return function() {
- require.styles.add('syntax_styles_before_types', _this.main);
- require.styles.add('syntax_type', _this.types);
- return require.styles.add('syntax_styles_after_types', _this.rest);
- };
- })(this);
- return this;
- }).call({}, require);
- //# sourceURL=syntax_styles-168
- require.inspect_object = (function inspect_object (require) {Object.defineProperty(this, 'module_name', {value:'inspect_object'});
- var defaultOptions, inspect_obj, propertiesByProto,
- 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; };
- defaultOptions = {
- create_key_node: function(sKey, val, parent) {
- var obj1;
- return require.node_from_obj([
- (
- obj1 = {},
- obj1["span.key.cm-" + (require["typeof"](val))] = {
- raw: sKey
- },
- obj1["span.key"] = ': ',
- obj1
- )
- ]);
- },
- transform_value: function(valueNode, val) {
- var props, str;
- props = Object.keys(val);
- str = (function() {
- var ref;
- switch (val.constructor.name) {
- case 'Object':
- return " {" + props.length + "}";
- case 'Array':
- return " [" + props.length + "]";
- default:
- return val.constructor.name + ' ' + ((ref = val.length) != null ? ref : props.length);
- }
- })();
- valueNode.textContent = str;
- return valueNode;
- },
- sort: function(a, b) {
- var res;
- if (isNaN(res = a - b)) {
- return a.localeCompare(b);
- } else {
- return res;
- }
- },
- showPropsMax: 500
- };
- propertiesByProto = function(obj, sort) {
- var curr, i, inheritanceInd, len, propName, props, propsByHeritance, ref;
- propsByHeritance = [];
- inheritanceInd = 0;
- curr = obj;
- while (true) {
- props = propsByHeritance[inheritanceInd] = [];
- ref = Object.getOwnPropertyNames(curr);
- for (i = 0, len = ref.length; i < len; i++) {
- propName = ref[i];
- props.push(propName);
- }
- inheritanceInd++;
- if (sort) {
- props.sort(sort);
- }
- if (!(curr = Object.getPrototypeOf(curr)) || curr === Object.prototype || curr === Array.prototype) {
- if (indexOf.call(curr, '__proto__') >= 0) {
- debugger;
- }
- break;
- }
- }
- return propsByHeritance;
- };
- inspect_obj = function(obj, targetNode, state, options) {
- 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;
- if (state == null) {
- state = [];
- }
- ind = -1;
- if (options == null) {
- options = {};
- }
- for (optName in defaultOptions) {
- action = defaultOptions[optName];
- if (options[optName] == null) {
- options[optName] = action;
- }
- }
- create_key_node = options.create_key_node, transform_value = options.transform_value;
- wrapper = require.dom["new"]('.inspect_object .rows');
- numberKeys = 0;
- ref = propertiesByProto(obj, options.sort);
- for (heritInd = i = 0, len = ref.length; i < len; heritInd = ++i) {
- propsByHeritance = ref[heritInd];
- for (j = 0, len1 = propsByHeritance.length; j < len1; j++) {
- key = propsByHeritance[j];
- val = obj[key];
- ind++;
- if (require.str.parsesToNumber(key)) {
- if (numberKeys === options.showPropsMax) {
- wrapper.appendChild(require.node_from_obj({
- div: '... (TODO: add link to open more values)'
- }));
- }
- numberKeys++;
- if (numberKeys > options.showPropsMax) {
- continue;
- }
- }
- row_node = require.dom["new"]('.inspect-row' + require.str["if"](!state[ind], '.one-line'));
- valueNode = require.dom["new"]('span.value');
- valueNode.classList.add('cm-' + require["typeof"](val));
- if (heritInd) {
- key = '⋏'.repeat(heritInd) + ' ' + key;
- }
- require.dom.addChilds(row_node, [keyNode = create_key_node(key, val, obj), valueNode]);
- if (typeof val === 'object' && val !== null) {
- if (state[ind]) {
- inspect_obj(val, valueNode, state[ind], options);
- }
- transform_value(valueNode, val);
- toggle_open = (function(state, ind, wrapper, ev) {
- state[ind] = state[ind] ? null : [];
- inspect_obj(obj, wrapper, state, options);
- return ev.stopPropagation();
- }).bind(null, state, ind, wrapper);
- row_node.classList.add('pointer');
- row_node.addEventListener('click', toggle_open, false);
- } else {
- if (typeof val === 'string') {
- val = "\"" + val + "\"";
- }
- if (val !== void 0) {
- val = val + '';
- }
- valueNode.textContent = typeof val === 'function' ? val.replace(/{[\s\S]*/, '') + ' ' + val.length : val != null ? require.str.truncate(val, 60) : void 0;
- }
- wrapper.appendChild(row_node);
- }
- }
- if (targetNode) {
- return require.dom.replace(targetNode, wrapper);
- } else {
- return wrapper;
- }
- };
- require.common_style_classes;
- require.styles.add('inspect_object', {
- '.inspect_object.rows': {
- '.pointer': {
- cursor: 'pointer',
- '&:hover': {
- background: require.color.la(0, 0.2)
- }
- },
- '.rows': {
- paddingLeft: 12
- },
- '.inspect-row': {
- paddingLeft: 3,
- transition: '250ms'
- },
- mixin: require.syntax_styles.types
- }
- });
- return inspect_obj;
- return this;
- }).call({}, require);
- //# sourceURL=inspect_object-169
- require.angularDomStructure = (function angularDomStructure (require) {Object.defineProperty(this, 'module_name', {value:'angularDomStructure'});
- var getCSSPath, standardHtmlTags, toArray, toggleClass, topMargin;
- 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'];
- toArray = function(arrayish) {
- return Array.prototype.slice.call(arrayish);
- };
- getCSSPath = function(node) {
- var ind, parts, siblingsArr, str;
- parts = [];
- while (node.parentElement) {
- str = node.tagName;
- if (node.id) {
- str += "#" + node.id;
- parts.unshift(str);
- break;
- }
- siblingsArr = toArray(node.parentElement.childNodes);
- ind = siblingsArr.filter(function(n) {
- return n.attributes != null;
- }).indexOf(node);
- parts.unshift(str + (":nth-child(" + (ind + 1) + ")"));
- node = node.parentElement;
- }
- return parts.join(' > ');
- };
- toggleClass = function(node, className) {
- if (node.classList.contains(className)) {
- return node.classList.remove(className);
- } else {
- return node.classList.add(className);
- }
- };
- this.filterSpecial = function(node, parentSpecial) {
- var attrFilterFunc, child, i, len, nodeClassesStr, ref, results, specialAttrs, specialTag, thisCurrent;
- if (parentSpecial == null) {
- parentSpecial = {
- children: []
- };
- }
- if (!standardHtmlTags.includes(node.tagName)) {
- specialTag = node.tagName;
- }
- if (!(specialTag || this.filteredRoot)) {
- specialTag = 'root';
- }
- attrFilterFunc = this.specialAttrsToMatch.length || this.classAttrsToMatch.length ? (function(_this) {
- return function(attr) {
- if (attr.name === 'class' && _this.classAttrsToMatch.length) {
- return (_.intersection(_this.classAttrsToMatch, attr.value.split(' '))).length > 0;
- } else {
- return _this.specialAttrsToMatch.includes(attr.name);
- }
- };
- })(this) : function(attr) {
- return !require.html.standardAttrs.includes(attr.name);
- };
- specialAttrs = toArray(node.attributes).filter(attrFilterFunc);
- if (specialTag || specialAttrs.length) {
- nodeClassesStr = require.str["if"](node.classList.length, ' .' + toArray(node.classList).join('.'));
- parentSpecial.children.push(this.current = {
- tag: '<' + node.tagName + (require.str["if"](node.id, ' #' + node.id)) + nodeClassesStr + '>',
- attrs: specialAttrs,
- children: [],
- path: getCSSPath(node)
- });
- if (this.filteredRoot == null) {
- this.filteredRoot = this.current;
- }
- }
- ref = node.childNodes;
- results = [];
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- if (!(child.attributes != null)) {
- continue;
- }
- thisCurrent = this.current;
- this.filterSpecial(child, this.current);
- results.push(this.current = thisCurrent);
- }
- return results;
- };
- this.renderableFromNode = function(tagAttrsChildren, parent) {
- var attr, child, i, j, len, len1, origTagName, ref, ref1, sub, tagName;
- if (parent == null) {
- parent = {};
- }
- tagName = origTagName = tagAttrsChildren.tag.toLowerCase() + '::' + tagAttrsChildren.path;
- parent[tagName] = sub = {};
- ref = tagAttrsChildren.attrs;
- for (i = 0, len = ref.length; i < len; i++) {
- attr = ref[i];
- sub[attr.nodeName] = attr.nodeValue;
- }
- ref1 = tagAttrsChildren.children;
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- child = ref1[j];
- this.renderableFromNode(child, sub);
- }
- return parent;
- };
- this.attrInputValue = localStorage.angularInspectAttrNames || "ng-app ui-view ng-controller";
- this.openInspector = (function(_this) {
- return function() {
- var attrName, htmlStr, i, len, options, ref, testNode;
- htmlStr = document.body.innerHTML;
- _this.filteredRoot = _this.current = null;
- _this.classAttrsToMatch = [];
- _this.specialAttrsToMatch = [];
- ref = _this.attrInputValue.split(/[ ,]/);
- for (i = 0, len = ref.length; i < len; i++) {
- attrName = ref[i];
- if (attrName[0] === '.') {
- _this.classAttrsToMatch.push(attrName.slice(1));
- } else {
- _this.specialAttrsToMatch.push(attrName);
- }
- }
- require.render.toLayer(_this, {
- pre: [
- {
- 'a.toggleSide': {
- onClick: function(ev) {
- return toggleClass(ev.target.parentElement.parentElement, 'rightSide');
- },
- me: 'side'
- },
- '.attributes': [
- 'Show only attributes:', _this.attrsInput = require.dom["new"]({
- 'input': {
- value: _this.attrInputValue,
- onKeyUp: _.debounce((function(ev) {
- _this.attrInputValue = localStorage.angularInspectAttrNames = ev.target.value;
- _this.openInspector();
- return ev.preventDefault();
- }), 1000)
- }
- })
- ],
- '.final': ['Structure:', _this.finalEl = require.dom["new"]()],
- '.scope': [
- _this.scopeEl = require.dom["new"]({
- div: {
- div: '',
- div2: ''
- }
- })
- ]
- }
- ]
- });
- _this.attrsInput.focus();
- _this.attrsInput.value = _this.attrsInput.value;
- testNode = document.createElement('root');
- testNode.innerHTML = htmlStr;
- _this.filterSpecial(testNode);
- require.inspect_object(_this.filteredRoot, _this.filteredEl);
- options = {
- create_key_node: function(key) {
- var domEl, inspectScope, keyTxt, path, ref1;
- ref1 = key.split('::'), key = ref1[0], path = ref1[1];
- keyTxt = key.replace(/\d$/, '') + ' ';
- path += ' > *\:first-child';
- if (path) {
- return domEl = require.dom["new"]({
- 'a.key': {
- onClick: inspectScope = function(ev, storedPath) {
- var scope, targetNode;
- if (storedPath != null) {
- path = storedPath;
- }
- console.log('window.inspectedElement =', window.inspectedElement = document.querySelector(path));
- if (targetNode = typeof angular !== "undefined" && angular !== null ? angular.element(document.querySelector(path)) : void 0) {
- require.render.toNode(_this.scopeEl.children[0], {
- span: "Scope in ",
- a: {
- me: key,
- onClick: function() {
- return inspectScope.call(this, null, path);
- }
- },
- span2: ':'
- });
- if (scope = targetNode != null ? targetNode.scope() : void 0) {
- scope['(unfiltered)'] = scope;
- scope = require.object.filter(scope, function(key, val) {
- return key[0] !== '$';
- });
- require.inspect_object(scope, _this.scopeEl.children[1]);
- }
- } else {
- console.warn("node not found from DOM (or not inside angular app)");
- }
- return ev != null ? ev.preventDefault() : void 0;
- },
- me: keyTxt
- }
- });
- } else {
- return require.dom["new"]({
- 'span.key': keyTxt
- });
- }
- }
- };
- return require.inspect_object(_this.renderableFromNode(_this.filteredRoot), _this.finalEl, [[]], options);
- };
- })(this);
- if (!document.querySelector('#inspectorButton')) {
- document.body.appendChild(require.node_from_obj({
- '#inspectorButton': {
- onClick: (function(_this) {
- return function() {
- if (require.layers.has(_this)) {
- return require.layers.unload(_this);
- } else {
- return _this.openInspector();
- }
- };
- })(this),
- me: 'i'
- }
- }));
- }
- this.unload = function() {
- return require.dom.remove('#inspectorButton');
- };
- require.styles.add(this, {
- '#inspectorButton': {
- position: 'fixed',
- top: 0,
- left: 0,
- width: 15,
- height: 15,
- lineHeight: 15,
- textAlign: 'center',
- zIndex: 1051,
- color: 'gray',
- cursor: 'pointer',
- opacity: 0,
- '&:hover': {
- opacity: 1
- }
- },
- 'body > #layers': {
- position: 'fixed',
- top: topMargin = 0,
- height: "calc(100% - " + topMargin + "px)",
- zIndex: 1051
- },
- '#layers #angularDomStructure': {
- position: 'relative',
- background: "hsla(0, 0%, 0%, 0.8)",
- width: '50%',
- padding: '2px 4px',
- pre: {
- color: 'white',
- textShadow: "0px 1px 2px black",
- background: 'none',
- border: 'none'
- },
- '.final,.filtered,.scope': {
- marginTop: 10
- },
- '.final': {
- maxHeight: 350,
- overflowY: 'scroll'
- },
- '&.rightSide': {
- float: 'right'
- },
- '.toggleSide': {
- float: 'right',
- cursor: 'pointer',
- zIndex: 2
- },
- 'input': {
- color: 'black',
- width: "calc(100% - 140px)"
- }
- },
- '#right_side #angularDomStructure': {
- width: '100%'
- }
- });
- return this;
- }).call({}, require);
- //# sourceURL=angularDomStructure-170
- }
- if (document.readyState === "complete") {
- initAllModules();
- } else {
- window.addEventListener('load', initAllModules, false);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement