+1
-1
| { | ||
| "name": "kb", | ||
| "description": "A Dom Attributes Binding and Event Listener Library", | ||
| "version": "0.7.3", | ||
| "version": "0.7.4", | ||
| "main": "index", | ||
@@ -6,0 +6,0 @@ "authors": [ |
+0
-0
| module.exports = require( './KB/Min/KB.min' ); |
+1
-1
@@ -1,1 +0,1 @@ | ||
| var KB = (function() { var CreateKB = (function() { function CreateKB() { /* This holds global attribute listeners when tied to kb */ var _attrListeners = {}, /* This holds global attribute update listeners when tied to kb */ _attrUpdateListeners = {}, /* This holds global style listeners when tied to kb */ _styleListeners = {}, /* This holds global style update listeners when tied to kb */ _styleUpdateListeners = {}, /* This holds all injected objects, so You can see what is injected */ _injected = {}, /* The symbol to dignify what the master global listener is */ _all = '*', _texts = ['textContent', 'innerHTML', 'innerText', 'outerHTML', 'outerText', 'appendChild', 'removeChild', 'replaceChild', 'insertAdjacentHTML', 'insertBefore'], /* A master list of all style prop names */ _allStyles = Object.getOwnPropertyNames(document.body.style), _allEvents = Object.keys(HTMLElement.prototype).filter(function(v) { return (v.indexOf('on') === 0); }).concat(['addEventListener', 'removeEventListener']), /* global iterators */ x, i, /* Default set method for all listeners, loops through and runs all attached listeners */ _set = function(el, prop, val, ret, args, stopChange) { var e = new _changeEvent(el, prop, val, ret, args, undefined, 'set', stopChange); if (el.__kb !== undefined) { var localAttrListeners = el.__kb._attrListeners, localStyleListeners = el.__kb._styleListeners, localParentAttrListeners = el.__kb._parentAttrListeners, localParentStyleListeners = el.__kb._parentStyleListeners; if (localAttrListeners[prop] !== undefined) { loopListener(localAttrListeners[prop], e); } if (e._stopPropogation === undefined && localStyleListeners[prop] !== undefined) { loopListener(localStyleListeners[prop], e); } if (e._stopPropogation === undefined && localAttrListeners[_all] !== undefined) { loopListener(localAttrListeners[_all], e); if (e._stopPropogation === undefined) { loopListener(localStyleListeners[_all], e); } } if (e._stopPropogation === undefined && localParentAttrListeners[prop] !== undefined) { loopParentListener(localParentAttrListeners[prop], e); } if (e._stopPropogation === undefined && localParentStyleListeners[prop] !== undefined) { loopParentListener(localParentStyleListeners[prop], e); } if (e._stopPropogation === undefined && localParentAttrListeners[_all] !== undefined) { loopParentListener(localParentAttrListeners[_all], e); if (e._stopPropogation === undefined) { loopParentListener(localParentStyleListeners[_all], e); } } } if (e._stopPropogation === undefined && _attrListeners[prop] !== undefined) { loopListener(_attrListeners[prop], e); } if (e._stopPropogation === undefined && _styleListeners[prop] !== undefined) { loopListener(_styleListeners[prop], e); } if (e._stopPropogation === undefined && _attrListeners[_all] !== undefined) { loopListener(_attrListeners[_all], e); if (e._stopPropogation === undefined) { loopListener(_styleListeners[_all], e); } } if (e._preventDefault !== undefined) return false; return true; }, /* Default update method for all listeners, loops through and runs all attached update listeners */ _update = function(el, prop, val, ret, args, action) { var e = new _changeEvent(el, prop, val, ret, args, action, 'update'); if (el.__kb !== undefined) { var localAttrListeners = el.__kb._attrUpdateListeners, localStyleListeners = el.__kb._styleUpdateListeners, localParentAttrListeners = el.__kb._parentAttrUpdateListeners, localParentStyleListeners = el.__kb._parentStyleUpdateListeners; if (localAttrListeners[prop] !== undefined) { loopListener(localAttrListeners[prop], e); } if (e._stopPropogation === undefined && localStyleListeners[prop] !== undefined) { loopListener(localStyleListeners[prop], e); } if (e._stopPropogation === undefined && localAttrListeners[_all] !== undefined) { loopListener(localAttrListeners[_all], e); if (e._stopPropogation === undefined) { loopListener(localStyleListeners[_all], e); } } if (e._stopPropogation === undefined && localParentAttrListeners[prop] !== undefined) { loopParentListener(localParentAttrListeners[prop], e); } if (e._stopPropogation === undefined && localParentStyleListeners[prop] !== undefined) { loopParentListener(localParentStyleListeners[prop], e); } if (e._stopPropogation === undefined && localParentAttrListeners[_all] !== undefined) { loopParentListener(localParentAttrListeners[_all], e); if (e._stopPropogation === undefined) { loopParentListener(localParentStyleListeners[_all], e); } } } if (e._stopPropogation === undefined && _attrUpdateListeners[prop] !== undefined) { loopListener(_attrUpdateListeners[prop], e); } if (e._stopPropogation === undefined && _styleUpdateListeners[prop] !== undefined) { loopListener(_styleUpdateListeners[prop], e); } if (e._stopPropogation === undefined && _attrUpdateListeners[_all] !== undefined) { loopListener(_attrUpdateListeners[_all], e); if (e._stopPropogation === undefined) { loopListener(_styleUpdateListeners[_all], e); } } if (e._preventDefault !== undefined) return false; return true; } /* Helper method to loop through listeners and run them */ function loopListener(looper, e) { var _looper = looper, _len = looper.length, _e = e, _x; for (_x = 0; _x < _len; _x++) { looper[_x](_e); if (_e._stopPropogation !== undefined) break; } } /* Helper method to loop through all parent listeners and run them */ function loopParentListener(looper, e) { var _looper = looper, _len = looper.length, _e = e, _x; for (_x = 0; _x < _len; _x++) { _e.child = _e.target; _e.target = looper[_x].parent; looper[_x].func(_e); if (_e._stopPropogation !== undefined) break; } } /* Helper method to loop through all listeners and return if a method exists */ function loopListenerCheck(looper, func) { var _looper = looper, _len = looper.length, _func = func, _x; for (_x = 0; _x < _len; x++) { if (_looper[x].toString() === _func.toString()) return true; } return false; } /* The event object that gets passed to each listener */ function _changeEvent(el, attr, value, oldValue, args, action, type, stopChange) { this.stopPropagation = function() { this._stopPropogation = true; }; this.preventDefault = function() { this._preventDefault = true; }; this.value = value; this.oldValue = oldValue; this.target = el; this.attr = attr; this.arguments = args; this.action = action; this.child = undefined; this.type = type; this.stopChange = stopChange; } /* This holds all listeners associated with a particular element */ function _localBinders() { this._attrListeners = {}; this._attrUpdateListeners = {}; this._styleListeners = {}; this._styleUpdateListeners = {}; this._parentStyleListeners = {}; this._parentStyleUpdateListeners = {}; this._parentAttrListeners = {}; this._parentAttrUpdateListeners = {}; this._injectedStyle = {}; } /* This is a standard property set overwrite */ function setStandard(descriptor, key, set, update) { var _descriptor = descriptor, _descGet = _descriptor.get, _descSet = _descriptor.set, _key = key, _set = set, _update = update, _oldValue; return function standardSet(v) { _oldValue = _descGet.call(this); if (_set(this, _key, v, _oldValue, undefined, this._stopChange)) { _descSet.call(this, v); } if (!this._stopChange) { _update(this, _key, v, _oldValue); } this._stopChange = undefined; } } /* This is a standard value set overwrite */ function setValue(descriptor, key, set, update) { var _descriptor = descriptor, _key = key, _set = set, _update = update, _oldValue; return function valueSet(v) { _oldValue = _descriptor.value; if (_set(this, _key, v, _oldValue, arguments, this._stopChange)) { _descriptor.value = v; } if (!this._stopChange) { _update(this, _key, v, _oldValue, arguments); } this._stopChange = undefined; } } /* This is a standard function overwrite */ function setFunction(descriptor, key, set, update) { var _descriptor = descriptor, _descVal = _descriptor.value, _key = key, _set = set, _update = update, _action; return function functionSet() { if (_set(this, _key, null, null, arguments, this._stopChange)) { _action = _descVal.apply(this, arguments); } if (!this._stopChange) { _update(this, _key, null, null, arguments, _action); } this._stopChange = undefined; return _action; } } /* This overwites a style property */ function setStyle(descriptor, key, set, update, el) { var _proto = el.style, _descriptor = descriptor, _key = key, _keyCP = key.replace(/([A-Z])/g, "-$1").replace('webkit', '-webkit'), _set = set, _update = update, _el = el, _oldValue, _value; return { get: function() { return _value; }, set: function styleSet(v) { _oldValue = _value; if (_set(_el, _key, v, _oldValue, undefined, this._stopChange)) { _value = v; _proto.setProperty(_keyCP, v); } if (!this._stopChange) { _update(_el, _key, v, _oldValue); } this._stopChange = undefined; }, enumerable: true, configurable: true } } /* A helper method that is run for all addListener methods */ function addListener(attr, func, child, update) { if (typeof func !== 'function') return bind; var isInput = (['value', 'checked'].indexOf(attr) !== -1), isStyle = (_allStyles.indexOf(attr) !== -1), listeners; if (this.toString() !== bind.toString()) { if (child) { var children = this.querySelectorAll('*'), len = children.length, listenerObj; for (var x = 0; x < len; x++) { listenerObj = children[x].attrListeners(); if (isInput || (attr === _all)) { if (children[x].addInputBinding !== undefined) children[x].addInputBinding(); if (children[x].addInputBoxBinding !== undefined) children[x].addInputBoxBinding(); } if (isStyle) { bind.injectStyleProperty(children[x], attr); listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners'); if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push({ parent: this, func: func }); } else { if (attr === _all) { listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners'); var len = _allStyles.length; for (var i = 0; i < len; i++) { bind.injectStyleProperty(children[x], _allStyles[i]); } if (listenerObj[listeners][_all] === undefined) listenerObj[listeners][_all] = []; listenerObj[listeners][_all].push({ parent: this, func: func }); } listeners = (update ? '_parentAttrUpdateListeners' : '_parentAttrListeners'); if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push({ parent: this, func: func }); } } } else { listenerObj = this.attrListeners(); if (isStyle) { listeners = (update ? '_styleUpdateListeners' : '_styleListeners'); bind.injectStyleProperty(this, attr); if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push(func); } else { if (isInput || (attr === _all)) { if (this.addInputBinding !== undefined) this.addInputBinding(); if (this.addInputBoxBinding !== undefined) this.addInputBoxBinding(); } if (attr === _all) { listeners = (update ? '_styleUpdateListeners' : '_styleListeners'); var len = _allStyles.length; for (var x = 0; x < len; x++) { bind.injectStyleProperty(this, _allStyles[x]); } if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push(func); } listeners = (update ? '_attrUpdateListeners' : '_attrListeners'); if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push(func); } } } else { if (isInput || (attr === _all)) { var inputs = document.querySelectorAll('input, textarea'), len = inputs.length; for (var x = 0; x < len; x++) { if (inputs[x].addInputBinding !== undefined) inputs[x].addInputBinding(); if (inputs[x].addInputBoxBinding !== undefined) inputs[x].addInputBoxBinding(); } } if (isStyle) { var els = Array.prototype.slice.call(document.body.querySelectorAll('*')), len = (els.length + 1); els.unshift(document.body); for (var x = 0; x < len; x++) { bind.injectStyleProperty(els[x], attr); } listeners = (update ? _styleUpdateListeners : _styleListeners); if (listeners[attr] === undefined) listeners[attr] = []; listeners[attr].push(func); } else { if (attr === _all) { var els = Array.prototype.slice.call(document.body.querySelectorAll('*')), len = (els.length + 1), lenStyles = _allStyles.length; els.unshift(document.body); for (var x = 0; x < len; x++) { for (var i = 0; i < lenStyles; i++) { bind.injectStyleProperty(els[x], _allStyles[i]); } } listeners = (update ? _styleUpdateListeners : _styleListeners); if (listeners[attr] === undefined) listeners[attr] = []; listeners[attr].push(func); } listeners = (update ? _attrUpdateListeners : _attrListeners); if (listeners[attr] === undefined) listeners[attr] = []; listeners[attr].push(func); } } } /* A helper method that is ran for all removeListener methods */ function removeListener(attr, func, child, update) { if (typeof func !== 'function') return bind; var isInput = (['value', 'checked'].indexOf(attr) !== -1), isStyle = (_allStyles.indexOf(attr) !== -1), listeners, x; function cut(attr, list) { var listenerFuncs = list[attr], len = listenerFuncs.length; for (x = 0; x < len; x++) { if (listenerFuncs[x].toString() === func.toString()) { listenerFuncs.splice(x, 1); } } } if (this.toString() !== bind.toString()) { if (child) { var children = this.querySelectorAll('*'), len = children.length; if (isStyle) { listeners = (update ? '_childStyleUpdateListeners' : '_childStyleListeners'); cut(attr, this.attrListeners()[listeners]); listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners'); } else { if (attr === _all) { listeners = (update ? '_childStyleUpdateListeners' : '_childStyleListeners'); cut(attr, this.attrListeners()[listeners]); } listeners = (update ? '_childAttrUpdateListeners' : '_childAttrListeners'); cut(attr, this.attrListeners()[listeners]); listeners = (update ? '_parentAttrUpdateListeners' : '_parentAttrListeners'); } for (x = 0; x < len; x++) { var parents = children[x].attrListeners()[listeners][attr], parentLen = parents.length; for (var i = 0; i < parentLen; i++) { if (parents[i].isEqualNode(this)) { parents.slice(i, 1); } } if (attr === _all) { listenersStyle = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners'); var parents = children[x].attrListeners()[listeners][attr], parentLen = parents.length; for (var i = 0; i < parentLen; i++) { if (parents[i].isEqualNode(this)) { parents.slice(i, 1); } } } } } else { if (isStyle) { listeners = (update ? '_styleUpdateListeners' : '_styleListeners'); cut(attr, this.attrListeners()[listeners]); } else { if (attr === _all) { listeners = (update ? '_styleUpdateListeners' : '_styleListeners'); cut(attr, this.attrListeners()[listeners]); } listeners = (update ? '_attrUpdateListeners' : '_attrListeners'); cut(attr, this.attrListeners()[listeners]); } } } else { if (isStyle) { listeners = (update ? _styleUpdateListeners : _styleListeners); cut(attr, listeners); } else { if (attr === _all) { listeners = (update ? _styleUpdateListeners : _styleListeners); cut(attr, listeners); } listeners = (update ? _attrUpdateListeners : _attrListeners); cut(attr, listeners); } } } /* this method gets attached to all elements for easy listener adding of child events */ function addChildAttrListener(attr, func) { bind.addAttrListener.call(this, attr, func, true); return this; } /* this method gets attached to all elements for easy listener adding of child update events */ function addChildAttrUpdateListener(attr, func) { bind.addAttrUpdateListener.call(this, attr, func, true); return this; } /* this method gets attached to all elements for easy listener removal of child events */ function removeChildAttrListener(attr, func) { bind.removeAttrListener.call(this, attr, func, true); return this; } /* this method gets attached to all elements for easy listener removal of child update events */ function removeChildAttrUpdateListener(attr, func) { bind.removeAttrUpdateListener.call(this, attr, func, true); return this; } /* This method checks if a listener of this function already exists on a desired attribute */ function hasListener(listener, attr, func) { var _listeners = this.attrListeners(); if (attr === 'html') attr = 'innerHTML'; if (attr === 'events') attr = 'onclick'; switch (listener) { case 'attr': if (typeof _listeners._attrListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._attrListeners[attr], func)) return true; } else if (typeof _listeners._styleListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._styleListeners[attr], func)) return true; } else if (typeof _listeners._parentAttrListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._parentAttrListeners[attr], func)) return true; } else if (typeof _listeners._parentStyleListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._parentStyleListeners[attr], func)) return true; } break; case 'attrupdate': if (typeof _listeners._attrUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._attrUpdateListeners[attr], func)) return true; } else if (typeof _listeners._styleUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._styleUpdateListeners[attr], func)) return true; } else if (typeof _listeners._parentAttrUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._parentAttrUpdateListeners[attr], func)) return true; } else if (typeof _listeners._parentStyleUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._parentStyleUpdateListeners[attr], func)) return true; } break; } return false; } /* sets stopChange Property for stopping update listeners to fire */ function stopChange() { this._stopChange = true; return this; } /* This is the master constructor, to be ran only once. */ function bind() { bind.injectPrototypes(Node, 'Node'); bind.injectPrototypes(Element, 'Element'); bind.injectPrototypes(HTMLElement, 'HTMLElement'); bind.injectPrototypes(HTMLInputElement, 'HTMLInputElement'); bind.injectPrototypes(HTMLTextAreaElement, 'HTMLTextAreaElement'); bind.injectPrototypes(Document, 'Document'); var __set = _set, __update = _update; function hasInput(attrListeners) { var attrs = ['value', 'checked'], _localListeners = attrListeners, _localAttr = _localListeners._attrListeners, _localUpdateAttr = _localListeners._attrUpdateListeners, _localParentAttr = _localListeners._parentAttrListeners, _localParentUpdateAttr = _localListeners._parentAttrUpdateListeners, has = false; if (_attrListeners[_all] !== undefined || _attrUpdateListeners[_all] !== undefined) { has = true; } if (has !== true && _localAttr[_all] !== undefined || _localUpdateAttr[_all] !== undefined || _localParentAttr[_all] !== undefined || _localParentUpdateAttr[_all] !== undefined) { has = true; } if (has !== true) { for (var x = 0; x < attrs.length; x++) { if (_attrListeners[attrs[x]] !== undefined || _attrUpdateListeners[attrs[x]] !== undefined || _localAttr[attrs[x]] !== undefined || _localUpdateAttr[attrs[x]] !== undefined || _localParentAttr[attrs[x]] !== undefined || _localParentUpdateAttr[attrs[x]] !== undefined) { has = true; break; } } } return has; } function getStyles(arr, styles) { var x, _arr = arr, _styles = styles, len = styles.length; for (x = 0; x < len; x++) { if (_arr.indexOf(_styles[x]) === -1) { _arr.push(_styles[x]); } } return _arr; } function hasStyle(attrListeners) { var _globalStyle = Object.keys(_styleListeners), _globalStyleUpdate = Object.keys(_styleUpdateListeners), _localListeners = attrListeners, _localStyle = Object.keys(_localListeners._styleListeners), _localUpdateStyle = Object.keys(_localListeners._styleUpdateListeners), _localParentStyle = Object.keys(_localListeners._parentStyleListeners), _localParentUpdateStyle = Object.keys(_localListeners._parentStyleUpdateListeners), has = []; if (_globalStyle.length !== 0 || _globalStyleUpdate.length !== 0) { has = getStyles(has, _globalStyle); has = getStyles(has, _globalStyleUpdate); } if (has.length !== 0 && _localParentStyle.length !== 0 || _localParentUpdateStyle.length !== 0) { has = getStyles(has, _localParentStyle); has = getStyles(has, _localParentUpdateStyle); } if (has.indexOf(_all) !== -1) has = _allStyles; return has; } function copyListeners(listeners, copyTo) { var listenerProps = Object.keys(listeners), _currProp, _currListener; for (var x = 0, len = listenerProps.length; x < len; x++) { _currProp = listenerProps[x]; if (copyTo[_currProp] === undefined) { copyTo[_currProp] = listeners[_currProp].slice(); } else { for (var i = 0, lenI = listeners[_currProp].length; i < lenI; i++) { _currListener = listeners[_currProp][i]; copyTo[_currProp].push(_currListener); } } } } function reSync(e) { if (e.target.nodeType !== 3 && e.target.nodeType !== 8) { var attrListeners = e.target.attrListeners(), _hasInput = hasInput(attrListeners), _hasStyle = hasStyle(attrListeners), _hasStyleLen = _hasStyle.length, _parentAttr, _parentAttrUpdate, _parentStyle, _parentStyleUpdate, _listeners, nodes = [], len, outer = ((e.attr === 'outerHTML' || e.attr === 'outerText') ? e.attr : undefined), target = e.target if (outer !== undefined) { e.attr = 'appendChild', e.arguments = [e.target]; e.target = e.target.parentElement; } if (_hasInput) { if (e.attr === 'appendChild' && e.arguments[0].nodeType !== 3 && e.arguments[0].nodeType !== 8) { nodes = Array.prototype.slice.call(e.arguments[0].querySelectorAll('input,textarea')); if (e.arguments[0].tagName === 'INPUT' || e.arguments[0].tagName === 'TEXTAREA') { nodes.unshift(e.arguments[0]) } } else { nodes = Array.prototype.slice.call(e.target.querySelectorAll('input,textarea')); } len = nodes.length; for (var x = 0; x < len; x++) { if (nodes[x].addInputBinding !== undefined) nodes[x].addInputBinding(); if (nodes[x].addInputBoxBinding !== undefined) nodes[x].addInputBoxBinding(); } } if (e.attr === 'appendChild' && e.arguments[0].nodeName !== '#text' && e.arguments[0].nodeName !== '#comment') { nodes = Array.prototype.slice.call(e.arguments[0].querySelectorAll('*')); nodes.unshift(e.arguments[0]); _parentAttr = e.target.__kb._parentAttrListeners; _parentAttrUpdate = e.target.__kb._parentAttrUpdateListeners; _parentStyle = e.target.__kb._parentStyleListeners; _parentStyleUpdate = e.target.__kb._parentStyleUpdateListeners; } else { nodes = Array.prototype.slice.call(e.target.querySelectorAll('*')); _parentAttr = e.target.__kb._parentAttrListeners; _parentAttrUpdate = e.target.__kb._parentAttrUpdateListeners; _parentStyle = e.target.__kb._parentStyleListeners; _parentStyleUpdate = e.target.__kb._parentStyleUpdateListeners; } len = nodes.length; for (var x = 0; x < len; x++) { if (_hasStyleLen !== 0) { for (var i = 0; i < _hasStyleLen; i++) { bind.injectStyleProperty(nodes[x], _hasStyle[i]); } } _listeners = nodes[x].attrListeners(); copyListeners(_parentAttr, _listeners._parentAttrListeners); copyListeners(_parentAttrUpdate, _listeners._parentAttrUpdateListeners); copyListeners(_parentStyle, _listeners._parentStyleListeners); copyListeners(_parentStyleUpdate, _listeners._parentStyleUpdateListeners); } if (outer !== undefined) { e.attr = outer; e.target = target; e.arguments = []; } } } function checkAttr(e) { var oldAttr = e.target.attributes[e.arguments[0]], old = (oldAttr !== undefined ? oldAttr.value : ""), val = (e.attr === 'setAttribute' ? e.arguments[1] : ""); if (!__set(e.target, e.arguments[0], val, old, [val])) { e.preventDefault(); } } function checkAttrUpdate(e) { var oldAttr = e.target.attributes[e.arguments[0]], old = (oldAttr !== undefined ? oldAttr.value : ""), val = (e.attr === 'setAttribute' ? e.arguments[1] : ""); __update(e.target, e.arguments[0], val, old, [val]); } //for keeping binds with inputs bind.addAttrUpdateListener('appendChild', reSync); bind.addAttrUpdateListener('removeChild', reSync); bind.addAttrUpdateListener('innerHTML', reSync); bind.addAttrUpdateListener('outerHTML', reSync); bind.addAttrUpdateListener('innerText', reSync); bind.addAttrUpdateListener('outerText', reSync); bind.addAttrUpdateListener('textContent', reSync); //allows for html attribute changes to be listened to just like properties bind.addAttrListener('setAttribute', checkAttr); bind.addAttrListener('removeAttribute', checkAttr); bind.addAttrUpdateListener('setAttribute', checkAttrUpdate); bind.addAttrUpdateListener('removeAttribute', checkAttrUpdate); return bind; } bind.injectPrototypeProperty = function(obj, key, injectName, set, update) { var _proto = obj.prototype, _descriptor = Object.getOwnPropertyDescriptor(_proto, key), _injectName = (injectName || obj.toString().split(/\s+/)[1].split('{')[0].replace('()', '')), _injectedObj = _injected[_injectName], __set = (set || _set), __update = (update || _update); if (_proto.attrListeners === undefined) { _proto = {}; _proto.attrListeners = (function() { if (this.__kb === undefined) { this.__kb = new _localBinders(); } return this.__kb; }).bind(_proto); _proto.addAttrListener = bind.addAttrListener; _proto.addAttrUpdateListener = bind.addAttrUpdateListener; _proto.addChildAttrListener = addChildAttrListener; _proto.addChildAttrUpdateListener = addChildAttrUpdateListener; _proto.hasListener = hasListener; _proto.removeAttrListener = bind.removeAttrListener; _proto.removeAttrUpdateListener = bind.removeAttrUpdateListener; _proto.removeChildAttrListener = removeChildAttrListener; _proto.removeChildAttrUpdateListener = removeChildAttrUpdateListener; _proto.stopChange = stopChange; } if (_injectedObj === undefined) { _injected[_injectName] = { obj: obj, proto: _proto, descriptors: {}, set: undefined, update: undefined }; _injectedObj = _injected[_injectName]; _injectedObj.set = __set; _injectedObj.update = __update; } if (_injectedObj.descriptors[key] === undefined) _injectedObj.descriptors[key] = _descriptor; if (_descriptor.configurable) { if (_descriptor.set !== undefined) { Object.defineProperty(_proto, key, { get: _descriptor.get, set: setStandard(_descriptor, key, __set, __update), enumerable: true, configurable: true }); } else if (typeof _descriptor.value === 'function') { Object.defineProperty(_proto, key, { value: setFunction(_descriptor, key, __set, __update), writable: true, enumerable: true, configurable: true }); } else if (_descriptor.value !== undefined) { Object.defineProperty(_proto, key, { get: function() { return _descriptor.value; }, set: setValue(_descriptor, key, __set, __update), enumerable: true, configurable: true }); } } return bind; } bind.injectStyleProperty = function(el, key, set, update) { var _proto = el.style, _descriptor = Object.getOwnPropertyDescriptor(_proto, key), _injectedObj = el.attrListeners().injectedStyle, __set = (set || _set), __update = (update || _update); if (_injectedObj === undefined) { el.attrListeners().injectedStyle = { obj: el, proto: _proto, descriptors: {}, set: undefined, update: undefined }; el.attrListeners().injectedStyle.set = __set; el.attrListeners().injectedStyle.update = __update; _injectedObj = el.attrListeners().injectedStyle; } if (_injectedObj.descriptors[key] === undefined) _injectedObj.descriptors[key] = _descriptor; if (_descriptor.configurable) { Object.defineProperty(_proto, key, setStyle(_descriptor, key, __set, __update, el)); } return bind; } bind.injectPrototypes = function(obj, injectName, set, update) { var _proto = obj.prototype, _injectName = (injectName || obj.toString().split(/\s+/)[1].split('{')[0].replace('()', '')), _injectedObj = _injected[_injectName], _keys = Object.getOwnPropertyNames(_proto), __set = (set || _set), __update = (update || _update), _descriptors, x; if (_proto.attrListeners === undefined) { _proto.attrListeners = function() { if (this.__kb === undefined) { this.__kb = new _localBinders(); } return this.__kb; } _proto.addAttrListener = bind.addAttrListener; _proto.addAttrUpdateListener = bind.addAttrUpdateListener; _proto.addChildAttrListener = addChildAttrListener; _proto.addChildAttrUpdateListener = addChildAttrUpdateListener; _proto.hasListener = hasListener; _proto.stopChange = stopChange; } if (_injectedObj === undefined) { _injected[_injectName] = { obj: obj, proto: _proto, descriptors: {}, set: undefined, update: undefined }; _injectedObj = _injected[_injectName]; _injectedObj.set = __set; _injectedObj.update = __update; } _descriptors = _injected[_injectName].descriptors; for (x = 0; x < _keys.length; x += 1) { if (_descriptors[_keys[x]] === undefined) { bind.injectPrototypeProperty(obj, _keys[x], _injectName, __set, _update); } } if (_keys.indexOf('value') !== -1) { function keyDown(e) { var isCheck, oldCheck, oldValue, value; if (this.type === 'checkbox' || this.type === 'radio') { oldCheck = this.checked; isCheck = true; } oldValue = (isCheck ? (typeof this.checked === 'string' ? this.checked : (this.checked ? "true" : "false")) : this.value); setTimeout((function() { value = (isCheck ? (typeof this.checked === 'string' ? this.checked : (this.checked ? "true" : "false")) : this.value); if (isCheck) { if (!_injectedObj.set(this, 'checked', this.checked, oldValue)) { _descriptors['checked'].set.call(this, oldValue); } else { _injectedObj.update(this, 'checked', this.checked, oldValue); } } this.value = value; if (!_injectedObj.set(this, 'value', this.value, oldValue)) { _descriptors['value'].set.call(this, oldValue); } else { _injectedObj.update(this, 'value', this.checked, oldValue); } }).bind(this), 0); } _proto.removeInputBinding = function() { this.attrListeners()._onkeydown = undefined; this.removeEventListener('keydown', keyDown); } _proto.addInputBinding = function() { this.attrListeners()._onkeydown = true; this.addEventListener('keydown', keyDown); } _proto.removeInputBoxBinding = function() { this.attrListeners()._onmousedown = undefined; this.removeEventListener('mouseup', keyDown); } _proto.addInputBoxBinding = function() { this.attrListeners()._onmousedown = true; this.addEventListener('mouseup', keyDown); } } return bind; } bind.addAttrListener = function(attr, func, child) { if (attr === 'html') { for (var x = 0, len = _texts.length; x < len; x++) { addListener.call(this, _texts[x], func, child, false); } } else if (attr === 'events') { for (var x = 0, len = _allEvents.length; x < len; x++) { addListener.call(this, _allEvents[x], func, child, false); } } else { addListener.call(this, attr, func, child, false); } return this; } bind.addAttrUpdateListener = function(attr, func, child) { if (attr === 'html') { for (var x = 0, len = _texts.length; x < len; x++) { addListener.call(this, _texts[x], func, child, true); } } else if (attr === 'events') { for (var x = 0, len = _allEvents.length; x < len; x++) { addListener.call(this, _allEvents[x], func, child, true); } } else { addListener.call(this, attr, func, child, true); } return this; } bind.removeAttrListener = function(attr, func, child) { if (attr === 'html') { for (var x = 0, len = _texts.length; x < len; x++) { removeListener.call(this, _texts[x], func, child, false); } } else if (attr === 'events') { for (var x = 0, len = _allEvents.length; x < len; x++) { removeListener.call(this, _allEvents[x], func, child, false); } } else { removeListener.call(this, attr, func, child, false); } return this; } bind.removeAttrUpdateListener = function(attr, func, child) { if (attr === 'html') { for (var x = 0, len = _texts.length; x < len; x++) { removeListener.call(this, _texts[x], func, child, true); } } else if (attr === 'events') { for (var x = 0, len = _allEvents.length; x < len; x++) { removeListener.call(this, _allEvents[x], func, child, true); } } else { removeListener.call(this, attr, func, child, true); } return this; } bind.hasListener = function(listener, attr, func) { if (attr === 'html') attr = 'innerHTML'; if (attr === 'events') attr = 'onclick'; switch (listener) { case 'attr': if (typeof _attrListeners[attr] !== undefined) { if (loopListenerCheck(_attrListeners[attr], func)) return true; } else if (typeof _styleListeners[attr] !== undefined) { if (loopListenerCheck(_styleListeners[attr], func)) return true; } break; case 'attrupdate': if (typeof _attrUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_attrUpdateListeners[attr], func)) return true; } else if (typeof _styleUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_styleUpdateListeners[attr], func)) return true; } break; } return false; } bind.injectedPrototypes = function() { return _injected; } return bind; } if (typeof define === "function" && define.amd) { define('KB', CreateKB); //global KM define in browser } return CreateKB; }()) if (window.define && window.require) { define([], function() { return CreateKB; }); } else if (window.module) { module.exports = CreateKB; } return CreateKB; }()) | ||
| var KB = (function() { var CreateKB = (function() { function CreateKB() { /* This holds global attribute listeners when tied to kb */ var _attrListeners = {}, /* This holds global attribute update listeners when tied to kb */ _attrUpdateListeners = {}, /* This holds global style listeners when tied to kb */ _styleListeners = {}, /* This holds global style update listeners when tied to kb */ _styleUpdateListeners = {}, /* This holds all injected objects, so You can see what is injected */ _injected = {}, /* The symbol to dignify what the master global listener is */ _all = '*', _texts = ['textContent', 'innerHTML', 'innerText', 'outerHTML', 'outerText', 'appendChild', 'removeChild', 'replaceChild', 'insertAdjacentHTML', 'insertBefore'], /* A master list of all style prop names */ _allStyles = Object.getOwnPropertyNames(document.body.style), _allEvents = Object.keys(HTMLElement.prototype).filter(function(v) { return (v.indexOf('on') === 0); }).concat(['addEventListener', 'removeEventListener']), /* global iterators */ x, i, /* Default set method for all listeners, loops through and runs all attached listeners */ _set = function(el, prop, val, ret, args, stopChange) { var e = new _changeEvent(el, prop, val, ret, args, undefined, 'set', stopChange); if (el.__kb !== undefined) { var localAttrListeners = el.__kb._attrListeners, localStyleListeners = el.__kb._styleListeners, localParentAttrListeners = el.__kb._parentAttrListeners, localParentStyleListeners = el.__kb._parentStyleListeners; if (localAttrListeners[prop] !== undefined) { loopListener(localAttrListeners[prop], e); } if (e._stopPropogation === undefined && localStyleListeners[prop] !== undefined) { loopListener(localStyleListeners[prop], e); } if (e._stopPropogation === undefined && localAttrListeners[_all] !== undefined) { loopListener(localAttrListeners[_all], e); if (e._stopPropogation === undefined) { loopListener(localStyleListeners[_all], e); } } if (e._stopPropogation === undefined && localParentAttrListeners[prop] !== undefined) { loopParentListener(localParentAttrListeners[prop], e); } if (e._stopPropogation === undefined && localParentStyleListeners[prop] !== undefined) { loopParentListener(localParentStyleListeners[prop], e); } if (e._stopPropogation === undefined && localParentAttrListeners[_all] !== undefined) { loopParentListener(localParentAttrListeners[_all], e); if (e._stopPropogation === undefined) { loopParentListener(localParentStyleListeners[_all], e); } } } if (e._stopPropogation === undefined && _attrListeners[prop] !== undefined) { loopListener(_attrListeners[prop], e); } if (e._stopPropogation === undefined && _styleListeners[prop] !== undefined) { loopListener(_styleListeners[prop], e); } if (e._stopPropogation === undefined && _attrListeners[_all] !== undefined) { loopListener(_attrListeners[_all], e); if (e._stopPropogation === undefined) { loopListener(_styleListeners[_all], e); } } if (e._preventDefault !== undefined) return false; return true; }, /* Default update method for all listeners, loops through and runs all attached update listeners */ _update = function(el, prop, val, ret, args, action) { var e = new _changeEvent(el, prop, val, ret, args, action, 'update'); if (el.__kb !== undefined) { var localAttrListeners = el.__kb._attrUpdateListeners, localStyleListeners = el.__kb._styleUpdateListeners, localParentAttrListeners = el.__kb._parentAttrUpdateListeners, localParentStyleListeners = el.__kb._parentStyleUpdateListeners; if (localAttrListeners[prop] !== undefined) { loopListener(localAttrListeners[prop], e); } if (e._stopPropogation === undefined && localStyleListeners[prop] !== undefined) { loopListener(localStyleListeners[prop], e); } if (e._stopPropogation === undefined && localAttrListeners[_all] !== undefined) { loopListener(localAttrListeners[_all], e); if (e._stopPropogation === undefined) { loopListener(localStyleListeners[_all], e); } } if (e._stopPropogation === undefined && localParentAttrListeners[prop] !== undefined) { loopParentListener(localParentAttrListeners[prop], e); } if (e._stopPropogation === undefined && localParentStyleListeners[prop] !== undefined) { loopParentListener(localParentStyleListeners[prop], e); } if (e._stopPropogation === undefined && localParentAttrListeners[_all] !== undefined) { loopParentListener(localParentAttrListeners[_all], e); if (e._stopPropogation === undefined) { loopParentListener(localParentStyleListeners[_all], e); } } } if (e._stopPropogation === undefined && _attrUpdateListeners[prop] !== undefined) { loopListener(_attrUpdateListeners[prop], e); } if (e._stopPropogation === undefined && _styleUpdateListeners[prop] !== undefined) { loopListener(_styleUpdateListeners[prop], e); } if (e._stopPropogation === undefined && _attrUpdateListeners[_all] !== undefined) { loopListener(_attrUpdateListeners[_all], e); if (e._stopPropogation === undefined) { loopListener(_styleUpdateListeners[_all], e); } } if (e._preventDefault !== undefined) return false; return true; } /* Helper method to loop through listeners and run them */ function loopListener(looper, e) { var _looper = looper, _len = looper.length, _e = e, _x; for (_x = 0; _x < _len; _x++) { looper[_x](_e); if (_e._stopPropogation !== undefined) break; } } /* Helper method to loop through all parent listeners and run them */ function loopParentListener(looper, e) { var _looper = looper, _len = looper.length, _e = e, _x; for (_x = 0; _x < _len; _x++) { _e.child = _e.target; _e.target = looper[_x].parent; looper[_x].func(_e); if (_e._stopPropogation !== undefined) break; } } /* Helper method to loop through all listeners and return if a method exists */ function loopListenerCheck(looper, func) { var _looper = looper, _len = looper.length, _func = func, _x; for (_x = 0; _x < _len; x++) { if (_looper[x].toString() === _func.toString()) return true; } return false; } /* The event object that gets passed to each listener */ function _changeEvent(el, attr, value, oldValue, args, action, type, stopChange) { this.stopPropagation = function() { this._stopPropogation = true; }; this.preventDefault = function() { this._preventDefault = true; }; this.value = value; this.oldValue = oldValue; this.target = el; this.attr = attr; this.arguments = args; this.action = action; this.child = undefined; this.type = type; this.stopChange = stopChange; } /* This holds all listeners associated with a particular element */ function _localBinders() { this._attrListeners = {}; this._attrUpdateListeners = {}; this._styleListeners = {}; this._styleUpdateListeners = {}; this._parentStyleListeners = {}; this._parentStyleUpdateListeners = {}; this._parentAttrListeners = {}; this._parentAttrUpdateListeners = {}; this._injectedStyle = {}; } /* This is a standard property set overwrite */ function setStandard(descriptor, key, set, update) { var _descriptor = descriptor, _descGet = _descriptor.get, _descSet = _descriptor.set, _key = key, _set = set, _update = update, _oldValue; return function standardSet(v) { _oldValue = _descGet.call(this); if (_set(this, _key, v, _oldValue, undefined, this._stopChange)) { _descSet.call(this, v); } if (!this._stopChange) { _update(this, _key, v, _oldValue); } this._stopChange = undefined; } } /* This is a standard value set overwrite */ function setValue(descriptor, key, set, update) { var _descriptor = descriptor, _key = key, _set = set, _update = update, _oldValue; return function valueSet(v) { _oldValue = _descriptor.value; if (_set(this, _key, v, _oldValue, arguments, this._stopChange)) { _descriptor.value = v; } if (!this._stopChange) { _update(this, _key, v, _oldValue, arguments); } this._stopChange = undefined; } } /* This is a standard function overwrite */ function setFunction(descriptor, key, set, update) { var _descriptor = descriptor, _descVal = _descriptor.value, _key = key, _set = set, _update = update, _action; return function functionSet() { if (_set(this, _key, null, null, arguments, this._stopChange)) { _action = _descVal.apply(this, arguments); } if (!this._stopChange) { _update(this, _key, null, null, arguments, _action); } this._stopChange = undefined; return _action; } } /* This overwites a style property */ function setStyle(descriptor, key, set, update, el) { var _proto = el.style, _descriptor = descriptor, _key = key, _keyCP = key.replace(/([A-Z])/g, "-$1").replace('webkit', '-webkit'), _set = set, _update = update, _el = el, _oldValue, _value; return { get: function() { return _value; }, set: function styleSet(v) { _oldValue = _value; if (_set(_el, _key, v, _oldValue, undefined, this._stopChange)) { _value = v; _proto.setProperty(_keyCP, v); } if (!this._stopChange) { _update(_el, _key, v, _oldValue); } this._stopChange = undefined; }, enumerable: true, configurable: true } } /* A helper method that is run for all addListener methods */ function addListener(attr, func, child, update) { if (typeof func !== 'function') return bind; var isInput = (['value', 'checked'].indexOf(attr) !== -1), isStyle = (_allStyles.indexOf(attr) !== -1), listeners; if (this.toString() !== bind.toString()) { if (child) { var children = this.querySelectorAll('*'), len = children.length, listenerObj; for (var x = 0; x < len; x++) { listenerObj = children[x].attrListeners(); if (isInput || (attr === _all)) { if (children[x].addInputBinding !== undefined) children[x].addInputBinding(); if (children[x].addInputBoxBinding !== undefined) children[x].addInputBoxBinding(); } if (isStyle) { bind.injectStyleProperty(children[x], attr); listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners'); if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push({ parent: this, func: func }); } else { if (attr === _all) { listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners'); var len = _allStyles.length; for (var i = 0; i < len; i++) { bind.injectStyleProperty(children[x], _allStyles[i]); } if (listenerObj[listeners][_all] === undefined) listenerObj[listeners][_all] = []; listenerObj[listeners][_all].push({ parent: this, func: func }); } listeners = (update ? '_parentAttrUpdateListeners' : '_parentAttrListeners'); if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push({ parent: this, func: func }); } } } else { listenerObj = this.attrListeners(); if (isStyle) { listeners = (update ? '_styleUpdateListeners' : '_styleListeners'); bind.injectStyleProperty(this, attr); if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push(func); } else { if (isInput || (attr === _all)) { if (this.addInputBinding !== undefined) this.addInputBinding(); if (this.addInputBoxBinding !== undefined) this.addInputBoxBinding(); } if (attr === _all) { listeners = (update ? '_styleUpdateListeners' : '_styleListeners'); var len = _allStyles.length; for (var x = 0; x < len; x++) { bind.injectStyleProperty(this, _allStyles[x]); } if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push(func); } listeners = (update ? '_attrUpdateListeners' : '_attrListeners'); if (listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = []; listenerObj[listeners][attr].push(func); } } } else { if (isInput || (attr === _all)) { var inputs = document.querySelectorAll('input, textarea'), len = inputs.length; for (var x = 0; x < len; x++) { if (inputs[x].addInputBinding !== undefined) inputs[x].addInputBinding(); if (inputs[x].addInputBoxBinding !== undefined) inputs[x].addInputBoxBinding(); } } if (isStyle) { var els = Array.prototype.slice.call(document.body.querySelectorAll('*')), len = (els.length + 1); els.unshift(document.body); for (var x = 0; x < len; x++) { bind.injectStyleProperty(els[x], attr); } listeners = (update ? _styleUpdateListeners : _styleListeners); if (listeners[attr] === undefined) listeners[attr] = []; listeners[attr].push(func); } else { if (attr === _all) { var els = Array.prototype.slice.call(document.body.querySelectorAll('*')), len = (els.length + 1), lenStyles = _allStyles.length; els.unshift(document.body); for (var x = 0; x < len; x++) { for (var i = 0; i < lenStyles; i++) { bind.injectStyleProperty(els[x], _allStyles[i]); } } listeners = (update ? _styleUpdateListeners : _styleListeners); if (listeners[attr] === undefined) listeners[attr] = []; listeners[attr].push(func); } listeners = (update ? _attrUpdateListeners : _attrListeners); if (listeners[attr] === undefined) listeners[attr] = []; listeners[attr].push(func); } } } /* A helper method that is ran for all removeListener methods */ function removeListener(attr, func, child, update) { if (typeof func !== 'function') return bind; var isInput = (['value', 'checked'].indexOf(attr) !== -1), isStyle = (_allStyles.indexOf(attr) !== -1), listeners, x; function cut(attr, list) { var listenerFuncs = list[attr], len = listenerFuncs.length; for (x = 0; x < len; x++) { if (listenerFuncs[x].toString() === func.toString()) { listenerFuncs.splice(x, 1); } } } if (this.toString() !== bind.toString()) { if (child) { var children = this.querySelectorAll('*'), len = children.length; if (isStyle) { listeners = (update ? '_childStyleUpdateListeners' : '_childStyleListeners'); cut(attr, this.attrListeners()[listeners]); listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners'); } else { if (attr === _all) { listeners = (update ? '_childStyleUpdateListeners' : '_childStyleListeners'); cut(attr, this.attrListeners()[listeners]); } listeners = (update ? '_childAttrUpdateListeners' : '_childAttrListeners'); cut(attr, this.attrListeners()[listeners]); listeners = (update ? '_parentAttrUpdateListeners' : '_parentAttrListeners'); } for (x = 0; x < len; x++) { var parents = children[x].attrListeners()[listeners][attr], parentLen = parents.length; for (var i = 0; i < parentLen; i++) { if (parents[i].isEqualNode(this)) { parents.slice(i, 1); } } if (attr === _all) { listenersStyle = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners'); var parents = children[x].attrListeners()[listeners][attr], parentLen = parents.length; for (var i = 0; i < parentLen; i++) { if (parents[i].isEqualNode(this)) { parents.slice(i, 1); } } } } } else { if (isStyle) { listeners = (update ? '_styleUpdateListeners' : '_styleListeners'); cut(attr, this.attrListeners()[listeners]); } else { if (attr === _all) { listeners = (update ? '_styleUpdateListeners' : '_styleListeners'); cut(attr, this.attrListeners()[listeners]); } listeners = (update ? '_attrUpdateListeners' : '_attrListeners'); cut(attr, this.attrListeners()[listeners]); } } } else { if (isStyle) { listeners = (update ? _styleUpdateListeners : _styleListeners); cut(attr, listeners); } else { if (attr === _all) { listeners = (update ? _styleUpdateListeners : _styleListeners); cut(attr, listeners); } listeners = (update ? _attrUpdateListeners : _attrListeners); cut(attr, listeners); } } } /* this method gets attached to all elements for easy listener adding of child events */ function addChildAttrListener(attr, func) { bind.addAttrListener.call(this, attr, func, true); return this; } /* this method gets attached to all elements for easy listener adding of child update events */ function addChildAttrUpdateListener(attr, func) { bind.addAttrUpdateListener.call(this, attr, func, true); return this; } /* this method gets attached to all elements for easy listener removal of child events */ function removeChildAttrListener(attr, func) { bind.removeAttrListener.call(this, attr, func, true); return this; } /* this method gets attached to all elements for easy listener removal of child update events */ function removeChildAttrUpdateListener(attr, func) { bind.removeAttrUpdateListener.call(this, attr, func, true); return this; } /* This method checks if a listener of this function already exists on a desired attribute */ function hasListener(listener, attr, func) { var _listeners = this.attrListeners(); if (attr === 'html') attr = 'innerHTML'; if (attr === 'events') attr = 'onclick'; switch (listener) { case 'attr': if (typeof _listeners._attrListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._attrListeners[attr], func)) return true; } else if (typeof _listeners._styleListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._styleListeners[attr], func)) return true; } else if (typeof _listeners._parentAttrListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._parentAttrListeners[attr], func)) return true; } else if (typeof _listeners._parentStyleListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._parentStyleListeners[attr], func)) return true; } break; case 'attrupdate': if (typeof _listeners._attrUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._attrUpdateListeners[attr], func)) return true; } else if (typeof _listeners._styleUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._styleUpdateListeners[attr], func)) return true; } else if (typeof _listeners._parentAttrUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._parentAttrUpdateListeners[attr], func)) return true; } else if (typeof _listeners._parentStyleUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_listeners._parentStyleUpdateListeners[attr], func)) return true; } break; } return false; } /* sets stopChange Property for stopping update listeners to fire */ function stopChange() { this._stopChange = true; return this; } /* This is the master constructor, to be ran only once. */ function bind() { bind.injectPrototypes(Node, 'Node'); bind.injectPrototypes(Element, 'Element'); bind.injectPrototypes(HTMLElement, 'HTMLElement'); bind.injectPrototypes(HTMLInputElement, 'HTMLInputElement'); bind.injectPrototypes(HTMLTextAreaElement, 'HTMLTextAreaElement'); bind.injectPrototypes(Document, 'Document'); var __set = _set, __update = _update; function hasInput(attrListeners) { var attrs = ['value', 'checked'], _localListeners = attrListeners, _localAttr = _localListeners._attrListeners, _localUpdateAttr = _localListeners._attrUpdateListeners, _localParentAttr = _localListeners._parentAttrListeners, _localParentUpdateAttr = _localListeners._parentAttrUpdateListeners, has = false; if (_attrListeners[_all] !== undefined || _attrUpdateListeners[_all] !== undefined) { has = true; } if (has !== true && _localAttr[_all] !== undefined || _localUpdateAttr[_all] !== undefined || _localParentAttr[_all] !== undefined || _localParentUpdateAttr[_all] !== undefined) { has = true; } if (has !== true) { for (var x = 0; x < attrs.length; x++) { if (_attrListeners[attrs[x]] !== undefined || _attrUpdateListeners[attrs[x]] !== undefined || _localAttr[attrs[x]] !== undefined || _localUpdateAttr[attrs[x]] !== undefined || _localParentAttr[attrs[x]] !== undefined || _localParentUpdateAttr[attrs[x]] !== undefined) { has = true; break; } } } return has; } function getStyles(arr, styles) { var x, _arr = arr, _styles = styles, len = styles.length; for (x = 0; x < len; x++) { if (_arr.indexOf(_styles[x]) === -1) { _arr.push(_styles[x]); } } return _arr; } function hasStyle(attrListeners) { var _globalStyle = Object.keys(_styleListeners), _globalStyleUpdate = Object.keys(_styleUpdateListeners), _localListeners = attrListeners, _localStyle = Object.keys(_localListeners._styleListeners), _localUpdateStyle = Object.keys(_localListeners._styleUpdateListeners), _localParentStyle = Object.keys(_localListeners._parentStyleListeners), _localParentUpdateStyle = Object.keys(_localListeners._parentStyleUpdateListeners), has = []; if (_globalStyle.length !== 0 || _globalStyleUpdate.length !== 0) { has = getStyles(has, _globalStyle); has = getStyles(has, _globalStyleUpdate); } if (has.length !== 0 && _localParentStyle.length !== 0 || _localParentUpdateStyle.length !== 0) { has = getStyles(has, _localParentStyle); has = getStyles(has, _localParentUpdateStyle); } if (has.indexOf(_all) !== -1) has = _allStyles; return has; } function copyListeners(listeners, copyTo) { var listenerProps = Object.keys(listeners), _currProp, _currListener; for (var x = 0, len = listenerProps.length; x < len; x++) { _currProp = listenerProps[x]; if (copyTo[_currProp] === undefined) { copyTo[_currProp] = listeners[_currProp].slice(); } else { for (var i = 0, lenI = listeners[_currProp].length; i < lenI; i++) { _currListener = listeners[_currProp][i]; copyTo[_currProp].push(_currListener); } } } } function reSync(e) { if (e.target.nodeType !== 3 && e.target.nodeType !== 8) { var attrListeners = e.target.attrListeners(), _hasInput = hasInput(attrListeners), _hasStyle = hasStyle(attrListeners), _hasStyleLen = _hasStyle.length, _parentAttr, _parentAttrUpdate, _parentStyle, _parentStyleUpdate, _listeners, nodes = [], len, outer = ((e.attr === 'outerHTML' || e.attr === 'outerText') ? e.attr : undefined), target = e.target if (outer !== undefined) { e.attr = 'appendChild', e.arguments = [e.target]; e.target = e.target.parentElement; } if (_hasInput) { if (e.attr === 'appendChild' && e.arguments[0].nodeType !== 3 && e.arguments[0].nodeType !== 8) { nodes = Array.prototype.slice.call(e.arguments[0].querySelectorAll('input,textarea')); if (e.arguments[0].tagName === 'INPUT' || e.arguments[0].tagName === 'TEXTAREA') { nodes.unshift(e.arguments[0]) } } else { nodes = Array.prototype.slice.call(e.target.querySelectorAll('input,textarea')); } len = nodes.length; for (var x = 0; x < len; x++) { if (nodes[x].addInputBinding !== undefined) nodes[x].addInputBinding(); if (nodes[x].addInputBoxBinding !== undefined) nodes[x].addInputBoxBinding(); } } if (e.attr === 'appendChild' && e.arguments[0].nodeName !== '#text' && e.arguments[0].nodeName !== '#comment') { nodes = Array.prototype.slice.call(e.arguments[0].querySelectorAll('*')); nodes.unshift(e.arguments[0]); _parentAttr = e.target.__kb._parentAttrListeners; _parentAttrUpdate = e.target.__kb._parentAttrUpdateListeners; _parentStyle = e.target.__kb._parentStyleListeners; _parentStyleUpdate = e.target.__kb._parentStyleUpdateListeners; } else { nodes = Array.prototype.slice.call(e.target.querySelectorAll('*')); _parentAttr = e.target.__kb._parentAttrListeners; _parentAttrUpdate = e.target.__kb._parentAttrUpdateListeners; _parentStyle = e.target.__kb._parentStyleListeners; _parentStyleUpdate = e.target.__kb._parentStyleUpdateListeners; } len = nodes.length; for (var x = 0; x < len; x++) { if (_hasStyleLen !== 0) { for (var i = 0; i < _hasStyleLen; i++) { bind.injectStyleProperty(nodes[x], _hasStyle[i]); } } _listeners = nodes[x].attrListeners(); copyListeners(_parentAttr, _listeners._parentAttrListeners); copyListeners(_parentAttrUpdate, _listeners._parentAttrUpdateListeners); copyListeners(_parentStyle, _listeners._parentStyleListeners); copyListeners(_parentStyleUpdate, _listeners._parentStyleUpdateListeners); } if (outer !== undefined) { e.attr = outer; e.target = target; e.arguments = []; } } } function checkAttr(e) { var oldAttr = e.target.attributes[e.arguments[0]], old = (oldAttr !== undefined ? oldAttr.value : ""), val = (e.attr === 'setAttribute' ? e.arguments[1] : ""); if (!__set(e.target, e.arguments[0], val, old, [val])) { e.preventDefault(); } } function checkAttrUpdate(e) { var oldAttr = e.target.attributes[e.arguments[0]], old = (oldAttr !== undefined ? oldAttr.value : ""), val = (e.attr === 'setAttribute' ? e.arguments[1] : ""); __update(e.target, e.arguments[0], val, old, [val]); } //for keeping binds with inputs bind.addAttrUpdateListener('appendChild', reSync); bind.addAttrUpdateListener('removeChild', reSync); bind.addAttrUpdateListener('innerHTML', reSync); bind.addAttrUpdateListener('outerHTML', reSync); bind.addAttrUpdateListener('innerText', reSync); bind.addAttrUpdateListener('outerText', reSync); bind.addAttrUpdateListener('textContent', reSync); //allows for html attribute changes to be listened to just like properties bind.addAttrListener('setAttribute', checkAttr); bind.addAttrListener('removeAttribute', checkAttr); bind.addAttrUpdateListener('setAttribute', checkAttrUpdate); bind.addAttrUpdateListener('removeAttribute', checkAttrUpdate); return bind; } bind.injectPrototypeProperty = function(obj, key, injectName, set, update) { var _proto = obj.prototype, _descriptor = Object.getOwnPropertyDescriptor(_proto, key), _injectName = (injectName || obj.toString().split(/\s+/)[1].split('{')[0].replace('()', '')), _injectedObj = _injected[_injectName], __set = (set || _set), __update = (update || _update); if (_proto.attrListeners === undefined) { _proto = {}; _proto.attrListeners = (function() { if (this.__kb === undefined) { this.__kb = new _localBinders(); } return this.__kb; }).bind(_proto); _proto.addAttrListener = bind.addAttrListener; _proto.addAttrUpdateListener = bind.addAttrUpdateListener; _proto.addChildAttrListener = addChildAttrListener; _proto.addChildAttrUpdateListener = addChildAttrUpdateListener; _proto.hasListener = hasListener; _proto.removeAttrListener = bind.removeAttrListener; _proto.removeAttrUpdateListener = bind.removeAttrUpdateListener; _proto.removeChildAttrListener = removeChildAttrListener; _proto.removeChildAttrUpdateListener = removeChildAttrUpdateListener; _proto.stopChange = stopChange; } if (_injectedObj === undefined) { _injected[_injectName] = { obj: obj, proto: _proto, descriptors: {}, set: undefined, update: undefined }; _injectedObj = _injected[_injectName]; _injectedObj.set = __set; _injectedObj.update = __update; } if (_injectedObj.descriptors[key] === undefined) _injectedObj.descriptors[key] = _descriptor; if (_descriptor.configurable) { if (_descriptor.set !== undefined) { Object.defineProperty(_proto, key, { get: _descriptor.get, set: setStandard(_descriptor, key, __set, __update), enumerable: true, configurable: true }); } else if (typeof _descriptor.value === 'function') { Object.defineProperty(_proto, key, { value: setFunction(_descriptor, key, __set, __update), writable: true, enumerable: true, configurable: true }); } else if (_descriptor.value !== undefined) { Object.defineProperty(_proto, key, { get: function() { return _descriptor.value; }, set: setValue(_descriptor, key, __set, __update), enumerable: true, configurable: true }); } } return bind; } bind.injectStyleProperty = function(el, key, set, update) { var _proto = el.style, _descriptor = Object.getOwnPropertyDescriptor(_proto, key), _injectedObj = el.attrListeners().injectedStyle, __set = (set || _set), __update = (update || _update); if (_injectedObj === undefined) { el.attrListeners().injectedStyle = { obj: el, proto: _proto, descriptors: {}, set: undefined, update: undefined }; el.attrListeners().injectedStyle.set = __set; el.attrListeners().injectedStyle.update = __update; _injectedObj = el.attrListeners().injectedStyle; } if (_injectedObj.descriptors[key] === undefined) _injectedObj.descriptors[key] = _descriptor; if (_descriptor.configurable) { Object.defineProperty(_proto, key, setStyle(_descriptor, key, __set, __update, el)); } return bind; } bind.injectPrototypes = function(obj, injectName, set, update) { var _proto = obj.prototype, _injectName = (injectName || obj.toString().split(/\s+/)[1].split('{')[0].replace('()', '')), _injectedObj = _injected[_injectName], _keys = Object.getOwnPropertyNames(_proto), __set = (set || _set), __update = (update || _update), _descriptors, x; if (_proto.attrListeners === undefined) { _proto.attrListeners = function() { if (this.__kb === undefined) { this.__kb = new _localBinders(); } return this.__kb; } _proto.addAttrListener = bind.addAttrListener; _proto.addAttrUpdateListener = bind.addAttrUpdateListener; _proto.addChildAttrListener = addChildAttrListener; _proto.addChildAttrUpdateListener = addChildAttrUpdateListener; _proto.removeAttrListener = bind.removeAttrListener; _proto.removeAttrUpdateListener = bind.removeAttrUpdateListener; _proto.removeChildAttrListener = removeChildAttrListener; _proto.removeChildAttrUpdateListener = removeChildAttrUpdateListener; _proto.hasListener = hasListener; _proto.stopChange = stopChange; } if (_injectedObj === undefined) { _injected[_injectName] = { obj: obj, proto: _proto, descriptors: {}, set: undefined, update: undefined }; _injectedObj = _injected[_injectName]; _injectedObj.set = __set; _injectedObj.update = __update; } _descriptors = _injected[_injectName].descriptors; for (x = 0; x < _keys.length; x += 1) { if (_descriptors[_keys[x]] === undefined) { bind.injectPrototypeProperty(obj, _keys[x], _injectName, __set, _update); } } if (_keys.indexOf('value') !== -1) { function keyDown(e) { var isCheck, oldCheck, oldValue, value; if (this.type === 'checkbox' || this.type === 'radio') { oldCheck = this.checked; isCheck = true; } oldValue = (isCheck ? (typeof this.checked === 'string' ? this.checked : (this.checked ? "true" : "false")) : this.value); setTimeout((function() { value = (isCheck ? (typeof this.checked === 'string' ? this.checked : (this.checked ? "true" : "false")) : this.value); if (isCheck) { if (!_injectedObj.set(this, 'checked', this.checked, oldValue)) { _descriptors['checked'].set.call(this, oldValue); } else { _injectedObj.update(this, 'checked', this.checked, oldValue); } } this.value = value; if (!_injectedObj.set(this, 'value', this.value, oldValue)) { _descriptors['value'].set.call(this, oldValue); } else { _injectedObj.update(this, 'value', this.checked, oldValue); } }).bind(this), 0); } _proto.removeInputBinding = function() { this.attrListeners()._onkeydown = undefined; this.removeEventListener('keydown', keyDown); } _proto.addInputBinding = function() { this.attrListeners()._onkeydown = true; this.addEventListener('keydown', keyDown); } _proto.removeInputBoxBinding = function() { this.attrListeners()._onmousedown = undefined; this.removeEventListener('mouseup', keyDown); } _proto.addInputBoxBinding = function() { this.attrListeners()._onmousedown = true; this.addEventListener('mouseup', keyDown); } } return bind; } bind.addAttrListener = function(attr, func, child) { if (attr === 'html') { for (var x = 0, len = _texts.length; x < len; x++) { addListener.call(this, _texts[x], func, child, false); } } else if (attr === 'events') { for (var x = 0, len = _allEvents.length; x < len; x++) { addListener.call(this, _allEvents[x], func, child, false); } } else { addListener.call(this, attr, func, child, false); } return this; } bind.addAttrUpdateListener = function(attr, func, child) { if (attr === 'html') { for (var x = 0, len = _texts.length; x < len; x++) { addListener.call(this, _texts[x], func, child, true); } } else if (attr === 'events') { for (var x = 0, len = _allEvents.length; x < len; x++) { addListener.call(this, _allEvents[x], func, child, true); } } else { addListener.call(this, attr, func, child, true); } return this; } bind.removeAttrListener = function(attr, func, child) { if (attr === 'html') { for (var x = 0, len = _texts.length; x < len; x++) { removeListener.call(this, _texts[x], func, child, false); } } else if (attr === 'events') { for (var x = 0, len = _allEvents.length; x < len; x++) { removeListener.call(this, _allEvents[x], func, child, false); } } else { removeListener.call(this, attr, func, child, false); } return this; } bind.removeAttrUpdateListener = function(attr, func, child) { if (attr === 'html') { for (var x = 0, len = _texts.length; x < len; x++) { removeListener.call(this, _texts[x], func, child, true); } } else if (attr === 'events') { for (var x = 0, len = _allEvents.length; x < len; x++) { removeListener.call(this, _allEvents[x], func, child, true); } } else { removeListener.call(this, attr, func, child, true); } return this; } bind.hasListener = function(listener, attr, func) { if (attr === 'html') attr = 'innerHTML'; if (attr === 'events') attr = 'onclick'; switch (listener) { case 'attr': if (typeof _attrListeners[attr] !== undefined) { if (loopListenerCheck(_attrListeners[attr], func)) return true; } else if (typeof _styleListeners[attr] !== undefined) { if (loopListenerCheck(_styleListeners[attr], func)) return true; } break; case 'attrupdate': if (typeof _attrUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_attrUpdateListeners[attr], func)) return true; } else if (typeof _styleUpdateListeners[attr] !== undefined) { if (loopListenerCheck(_styleUpdateListeners[attr], func)) return true; } break; } return false; } bind.injectedPrototypes = function() { return _injected; } return bind; } if (typeof define === "function" && define.amd) { define('KB', CreateKB); //global KM define in browser } return CreateKB; }()) if ((typeof window !== 'undefined') && (typeof window.define !== 'undefined') && (typeof window.require !== 'undefined')) { define([], function() { return CreateKB; }); } else if ((typeof module !== 'undefined')) { module.exports = CreateKB; } return CreateKB; }()) |
+4
-0
@@ -1072,2 +1072,6 @@ define([],function(){ | ||
| _proto.addChildAttrUpdateListener = addChildAttrUpdateListener; | ||
| _proto.removeAttrListener = bind.removeAttrListener; | ||
| _proto.removeAttrUpdateListener = bind.removeAttrUpdateListener; | ||
| _proto.removeChildAttrListener = removeChildAttrListener; | ||
| _proto.removeChildAttrUpdateListener = removeChildAttrUpdateListener; | ||
| _proto.hasListener = hasListener; | ||
@@ -1074,0 +1078,0 @@ _proto.stopChange = stopChange; |
+27
-26
@@ -1,12 +0,12 @@ | ||
| var KB=function(){var G=function(){function G(){function k(a,c){var b=a.length,d;for(d=0;d<b&&(a[d](c),void 0===c._stopPropogation);d++);}function p(a,c){var b=a.length,d;for(d=0;d<b&&(c.child=c.target,c.target=a[d].parent,a[d].func(c),void 0===c._stopPropogation);d++);}function I(a,c){for(var b=a.length;0<b;K++)if(a[K].toString()===c.toString())return!0;return!1}function L(a,c,b,d,f,e,g,r){this.stopPropagation=function(){this._stopPropogation=!0};this.preventDefault=function(){this._preventDefault= | ||
| !0};this.value=b;this.oldValue=d;this.target=a;this.attr=c;this.arguments=f;this.action=e;this.child=void 0;this.type=g;this.stopChange=r}function M(){this._attrListeners={};this._attrUpdateListeners={};this._styleListeners={};this._styleUpdateListeners={};this._parentStyleListeners={};this._parentStyleUpdateListeners={};this._parentAttrListeners={};this._parentAttrUpdateListeners={};this._injectedStyle={}}function R(a,c,b,d){var f=a.get,e=a.set,g;return function(a){g=f.call(this);b(this,c,a,g,void 0, | ||
| this._stopChange)&&e.call(this,a);this._stopChange||d(this,c,a,g);this._stopChange=void 0}}function S(a,c,b,d){var f;return function(e){f=a.value;b(this,c,e,f,arguments,this._stopChange)&&(a.value=e);this._stopChange||d(this,c,e,f,arguments);this._stopChange=void 0}}function T(a,c,b,d){var f=a.value,e;return function(){b(this,c,null,null,arguments,this._stopChange)&&(e=f.apply(this,arguments));this._stopChange||d(this,c,null,null,arguments,e);this._stopChange=void 0;return e}}function U(a,c,b,d,f){var e= | ||
| f.style,g=c.replace(/([A-Z])/g,"-$1").replace("webkit","-webkit"),r,m;return{get:function(){return m},set:function(a){r=m;b(f,c,a,r,void 0,this._stopChange)&&(m=a,e.setProperty(g,a));this._stopChange||d(f,c,a,r);this._stopChange=void 0},enumerable:!0,configurable:!0}}function E(a,c,b,d){if("function"!==typeof c)return h;var f=-1!==["value","checked"].indexOf(a),e=-1!==x.indexOf(a),g;if(this.toString()!==h.toString())if(b){var r=this.querySelectorAll("*");b=r.length;for(var m,l=0;l<b;l++){m=r[l].attrListeners(); | ||
| if(f||"*"===a)void 0!==r[l].addInputBinding&&r[l].addInputBinding(),void 0!==r[l].addInputBoxBinding&&r[l].addInputBoxBinding();if(e)h.injectStyleProperty(r[l],a),g=d?"_parentStyleUpdateListeners":"_parentStyleListeners";else{if("*"===a){g=d?"_parentStyleUpdateListeners":"_parentStyleListeners";b=x.length;for(var n=0;n<b;n++)h.injectStyleProperty(r[l],x[n]);void 0===m[g]["*"]&&(m[g]["*"]=[]);m[g]["*"].push({parent:this,func:c})}g=d?"_parentAttrUpdateListeners":"_parentAttrListeners"}void 0===m[g][a]&& | ||
| (m[g][a]=[]);m[g][a].push({parent:this,func:c})}}else{m=this.attrListeners();if(e)g=d?"_styleUpdateListeners":"_styleListeners",h.injectStyleProperty(this,a);else{if(f||"*"===a)void 0!==this.addInputBinding&&this.addInputBinding(),void 0!==this.addInputBoxBinding&&this.addInputBoxBinding();if("*"===a){g=d?"_styleUpdateListeners":"_styleListeners";b=x.length;for(l=0;l<b;l++)h.injectStyleProperty(this,x[l]);void 0===m[g][a]&&(m[g][a]=[]);m[g][a].push(c)}g=d?"_attrUpdateListeners":"_attrListeners"}void 0=== | ||
| m[g][a]&&(m[g][a]=[]);m[g][a].push(c)}else{if(f||"*"===a)for(n=document.querySelectorAll("input, textarea"),b=n.length,l=0;l<b;l++)void 0!==n[l].addInputBinding&&n[l].addInputBinding(),void 0!==n[l].addInputBoxBinding&&n[l].addInputBoxBinding();if(e){e=Array.prototype.slice.call(document.body.querySelectorAll("*"));b=e.length+1;e.unshift(document.body);for(l=0;l<b;l++)h.injectStyleProperty(e[l],a);g=d?B:C}else{if("*"===a){e=Array.prototype.slice.call(document.body.querySelectorAll("*"));b=e.length+ | ||
| 1;f=x.length;e.unshift(document.body);for(l=0;l<b;l++)for(n=0;n<f;n++)h.injectStyleProperty(e[l],x[n]);g=d?B:C;void 0===g[a]&&(g[a]=[]);g[a].push(c)}g=d?y:z}void 0===g[a]&&(g[a]=[]);g[a].push(c)}}function F(a,c,b,d){function f(a,b){var d=b[a],e=d.length;for(g=0;g<e;g++)d[g].toString()===c.toString()&&d.splice(g,1)}if("function"!==typeof c)return h;["value","checked"].indexOf(a);var e=-1!==x.indexOf(a),g;if(this.toString()!==h.toString())if(b){b=this.querySelectorAll("*");var r=b.length;e?(e=d?"_childStyleUpdateListeners": | ||
| "_childStyleListeners",f(a,this.attrListeners()[e]),e=d?"_parentStyleUpdateListeners":"_parentStyleListeners"):("*"===a&&(e=d?"_childStyleUpdateListeners":"_childStyleListeners",f(a,this.attrListeners()[e])),e=d?"_childAttrUpdateListeners":"_childAttrListeners",f(a,this.attrListeners()[e]),e=d?"_parentAttrUpdateListeners":"_parentAttrListeners");for(g=0;g<r;g++){for(var m=b[g].attrListeners()[e][a],l=m.length,n=0;n<l;n++)m[n].isEqualNode(this)&&m.slice(n,1);if("*"===a)for(listenersStyle=d?"_parentStyleUpdateListeners": | ||
| "_parentStyleListeners",m=b[g].attrListeners()[e][a],l=m.length,n=0;n<l;n++)m[n].isEqualNode(this)&&m.slice(n,1)}}else e?e=d?"_styleUpdateListeners":"_styleListeners":("*"===a&&(e=d?"_styleUpdateListeners":"_styleListeners",f(a,this.attrListeners()[e])),e=d?"_attrUpdateListeners":"_attrListeners"),f(a,this.attrListeners()[e]);else e?e=d?B:C:("*"===a&&(e=d?B:C,f(a,e)),e=d?y:z),f(a,e)}function N(a,c){h.addAttrListener.call(this,a,c,!0);return this}function O(a,c){h.addAttrUpdateListener.call(this,a, | ||
| c,!0);return this}function V(a,c){h.removeAttrListener.call(this,a,c,!0);return this}function W(a,c){h.removeAttrUpdateListener.call(this,a,c,!0);return this}function P(a,c,b){var d=this.attrListeners();"html"===c&&(c="innerHTML");"events"===c&&(c="onclick");switch(a){case "attr":if(I(d._attrListeners[c],b))return!0;break;case "attrupdate":if(I(d._attrUpdateListeners[c],b))return!0}return!1}function Q(){this._stopChange=!0;return this}function h(){function a(a,b){var c,d=b.length;for(c=0;c<d;c++)-1=== | ||
| var KB=function(){var G=function(){function G(){function k(a,c){var b=a.length,d;for(d=0;d<b&&(a[d](c),void 0===c._stopPropogation);d++);}function p(a,c){var b=a.length,d;for(d=0;d<b&&(c.child=c.target,c.target=a[d].parent,a[d].func(c),void 0===c._stopPropogation);d++);}function I(a,c){for(var b=a.length;0<b;K++)if(a[K].toString()===c.toString())return!0;return!1}function L(a,c,b,d,g,e,f,r){this.stopPropagation=function(){this._stopPropogation=!0};this.preventDefault=function(){this._preventDefault= | ||
| !0};this.value=b;this.oldValue=d;this.target=a;this.attr=c;this.arguments=g;this.action=e;this.child=void 0;this.type=f;this.stopChange=r}function M(){this._attrListeners={};this._attrUpdateListeners={};this._styleListeners={};this._styleUpdateListeners={};this._parentStyleListeners={};this._parentStyleUpdateListeners={};this._parentAttrListeners={};this._parentAttrUpdateListeners={};this._injectedStyle={}}function T(a,c,b,d){var g=a.get,e=a.set,f;return function(a){f=g.call(this);b(this,c,a,f,void 0, | ||
| this._stopChange)&&e.call(this,a);this._stopChange||d(this,c,a,f);this._stopChange=void 0}}function U(a,c,b,d){var g;return function(e){g=a.value;b(this,c,e,g,arguments,this._stopChange)&&(a.value=e);this._stopChange||d(this,c,e,g,arguments);this._stopChange=void 0}}function V(a,c,b,d){var g=a.value,e;return function(){b(this,c,null,null,arguments,this._stopChange)&&(e=g.apply(this,arguments));this._stopChange||d(this,c,null,null,arguments,e);this._stopChange=void 0;return e}}function W(a,c,b,d,g){var e= | ||
| g.style,f=c.replace(/([A-Z])/g,"-$1").replace("webkit","-webkit"),r,m;return{get:function(){return m},set:function(a){r=m;b(g,c,a,r,void 0,this._stopChange)&&(m=a,e.setProperty(f,a));this._stopChange||d(g,c,a,r);this._stopChange=void 0},enumerable:!0,configurable:!0}}function E(a,c,b,d){if("function"!==typeof c)return h;var g=-1!==["value","checked"].indexOf(a),e=-1!==x.indexOf(a),f;if(this.toString()!==h.toString())if(b){var r=this.querySelectorAll("*");b=r.length;for(var m,l=0;l<b;l++){m=r[l].attrListeners(); | ||
| if(g||"*"===a)void 0!==r[l].addInputBinding&&r[l].addInputBinding(),void 0!==r[l].addInputBoxBinding&&r[l].addInputBoxBinding();if(e)h.injectStyleProperty(r[l],a),f=d?"_parentStyleUpdateListeners":"_parentStyleListeners";else{if("*"===a){f=d?"_parentStyleUpdateListeners":"_parentStyleListeners";b=x.length;for(var n=0;n<b;n++)h.injectStyleProperty(r[l],x[n]);void 0===m[f]["*"]&&(m[f]["*"]=[]);m[f]["*"].push({parent:this,func:c})}f=d?"_parentAttrUpdateListeners":"_parentAttrListeners"}void 0===m[f][a]&& | ||
| (m[f][a]=[]);m[f][a].push({parent:this,func:c})}}else{m=this.attrListeners();if(e)f=d?"_styleUpdateListeners":"_styleListeners",h.injectStyleProperty(this,a);else{if(g||"*"===a)void 0!==this.addInputBinding&&this.addInputBinding(),void 0!==this.addInputBoxBinding&&this.addInputBoxBinding();if("*"===a){f=d?"_styleUpdateListeners":"_styleListeners";b=x.length;for(l=0;l<b;l++)h.injectStyleProperty(this,x[l]);void 0===m[f][a]&&(m[f][a]=[]);m[f][a].push(c)}f=d?"_attrUpdateListeners":"_attrListeners"}void 0=== | ||
| m[f][a]&&(m[f][a]=[]);m[f][a].push(c)}else{if(g||"*"===a)for(n=document.querySelectorAll("input, textarea"),b=n.length,l=0;l<b;l++)void 0!==n[l].addInputBinding&&n[l].addInputBinding(),void 0!==n[l].addInputBoxBinding&&n[l].addInputBoxBinding();if(e){e=Array.prototype.slice.call(document.body.querySelectorAll("*"));b=e.length+1;e.unshift(document.body);for(l=0;l<b;l++)h.injectStyleProperty(e[l],a);f=d?B:C}else{if("*"===a){e=Array.prototype.slice.call(document.body.querySelectorAll("*"));b=e.length+ | ||
| 1;g=x.length;e.unshift(document.body);for(l=0;l<b;l++)for(n=0;n<g;n++)h.injectStyleProperty(e[l],x[n]);f=d?B:C;void 0===f[a]&&(f[a]=[]);f[a].push(c)}f=d?y:z}void 0===f[a]&&(f[a]=[]);f[a].push(c)}}function F(a,c,b,d){function g(a,b){var d=b[a],e=d.length;for(f=0;f<e;f++)d[f].toString()===c.toString()&&d.splice(f,1)}if("function"!==typeof c)return h;["value","checked"].indexOf(a);var e=-1!==x.indexOf(a),f;if(this.toString()!==h.toString())if(b){b=this.querySelectorAll("*");var r=b.length;e?(e=d?"_childStyleUpdateListeners": | ||
| "_childStyleListeners",g(a,this.attrListeners()[e]),e=d?"_parentStyleUpdateListeners":"_parentStyleListeners"):("*"===a&&(e=d?"_childStyleUpdateListeners":"_childStyleListeners",g(a,this.attrListeners()[e])),e=d?"_childAttrUpdateListeners":"_childAttrListeners",g(a,this.attrListeners()[e]),e=d?"_parentAttrUpdateListeners":"_parentAttrListeners");for(f=0;f<r;f++){for(var m=b[f].attrListeners()[e][a],l=m.length,n=0;n<l;n++)m[n].isEqualNode(this)&&m.slice(n,1);if("*"===a)for(listenersStyle=d?"_parentStyleUpdateListeners": | ||
| "_parentStyleListeners",m=b[f].attrListeners()[e][a],l=m.length,n=0;n<l;n++)m[n].isEqualNode(this)&&m.slice(n,1)}}else e?e=d?"_styleUpdateListeners":"_styleListeners":("*"===a&&(e=d?"_styleUpdateListeners":"_styleListeners",g(a,this.attrListeners()[e])),e=d?"_attrUpdateListeners":"_attrListeners"),g(a,this.attrListeners()[e]);else e?e=d?B:C:("*"===a&&(e=d?B:C,g(a,e)),e=d?y:z),g(a,e)}function N(a,c){h.addAttrListener.call(this,a,c,!0);return this}function O(a,c){h.addAttrUpdateListener.call(this,a, | ||
| c,!0);return this}function P(a,c){h.removeAttrListener.call(this,a,c,!0);return this}function Q(a,c){h.removeAttrUpdateListener.call(this,a,c,!0);return this}function R(a,c,b){var d=this.attrListeners();"html"===c&&(c="innerHTML");"events"===c&&(c="onclick");switch(a){case "attr":if(I(d._attrListeners[c],b))return!0;break;case "attrupdate":if(I(d._attrUpdateListeners[c],b))return!0}return!1}function S(){this._stopChange=!0;return this}function h(){function a(a,b){var c,d=b.length;for(c=0;c<d;c++)-1=== | ||
| a.indexOf(b[c])&&a.push(b[c]);return a}function c(a,b){for(var c=Object.keys(a),d,e,g=0,f=c.length;g<f;g++)if(d=c[g],void 0===b[d])b[d]=a[d].slice();else for(var h=0,k=a[d].length;h<k;h++)e=a[d][h],b[d].push(e)}function b(b){if(3!==b.target.nodeType&&8!==b.target.nodeType){var d=b.target.attrListeners(),e,g=["value","checked"],f=d._attrListeners,k=d._attrUpdateListeners,q=d._parentAttrListeners;e=d._parentAttrUpdateListeners;var p=!1;if(void 0!==z["*"]||void 0!==y["*"])p=!0;if(!0!==p&&void 0!==f["*"]|| | ||
@@ -17,16 +17,17 @@ void 0!==k["*"]||void 0!==q["*"]||void 0!==e["*"])p=!0;if(!0!==p)for(var w=0;w<g.length;w++)if(void 0!==z[g[w]]||void 0!==y[g[w]]||void 0!==f[g[w]]||void 0!==k[g[w]]||void 0!==q[g[w]]||void 0!==e[g[w]]){p=!0;break}e=p;g=Object.keys(C);f=Object.keys(B);Object.keys(d._styleListeners);Object.keys(d._styleUpdateListeners);k=Object.keys(d._parentStyleListeners);d=Object.keys(d._parentStyleUpdateListeners);q=[];if(0!==g.length||0!==f.length)q=a(q,g),q=a(q,f);if(0!==q.length&&0!==k.length||0!==d.length)q= | ||
| p=b.target.__kb._parentAttrUpdateListeners;w=b.target.__kb._parentStyleListeners;v=b.target.__kb._parentStyleUpdateListeners;t=f.length;for(u=0;u<t;u++){if(0!==g)for(A=0;A<g;A++)h.injectStyleProperty(f[u],d[A]);A=f[u].attrListeners();c(e,A._parentAttrListeners);c(p,A._parentAttrUpdateListeners);c(w,A._parentStyleListeners);c(v,A._parentStyleUpdateListeners)}void 0!==k&&(b.attr=k,b.target=q,b.arguments=[])}}function d(a){var b=a.target.attributes[a.arguments[0]],c="setAttribute"===a.attr?a.arguments[1]: | ||
| "";e(a.target,a.arguments[0],c,void 0!==b?b.value:"",[c])||a.preventDefault()}function f(a){var b=a.target.attributes[a.arguments[0]],c="setAttribute"===a.attr?a.arguments[1]:"";g(a.target,a.arguments[0],c,void 0!==b?b.value:"",[c])}h.injectPrototypes(Node,"Node");h.injectPrototypes(Element,"Element");h.injectPrototypes(HTMLElement,"HTMLElement");h.injectPrototypes(HTMLInputElement,"HTMLInputElement");h.injectPrototypes(HTMLTextAreaElement,"HTMLTextAreaElement");h.injectPrototypes(Document,"Document"); | ||
| var e=J,g=H;h.addAttrUpdateListener("appendChild",b);h.addAttrUpdateListener("removeChild",b);h.addAttrUpdateListener("innerHTML",b);h.addAttrUpdateListener("outerHTML",b);h.addAttrUpdateListener("innerText",b);h.addAttrUpdateListener("outerText",b);h.addAttrUpdateListener("textContent",b);h.addAttrListener("setAttribute",d);h.addAttrListener("removeAttribute",d);h.addAttrUpdateListener("setAttribute",f);h.addAttrUpdateListener("removeAttribute",f);return h}var z={},y={},C={},B={},v={},t="textContent innerHTML innerText outerHTML outerText appendChild removeChild replaceChild insertAdjacentHTML insertBefore".split(" "), | ||
| x=Object.getOwnPropertyNames(document.body.style),D=Object.keys(HTMLElement.prototype).filter(function(a){return 0===a.indexOf("on")}).concat(["addEventListener","removeEventListener"]),K,J=function(a,c,b,d,f,e){b=new L(a,c,b,d,f,void 0,"set",e);void 0!==a.__kb&&(d=a.__kb._attrListeners,f=a.__kb._styleListeners,e=a.__kb._parentAttrListeners,a=a.__kb._parentStyleListeners,void 0!==d[c]&&k(d[c],b),void 0===b._stopPropogation&&void 0!==f[c]&&k(f[c],b),void 0===b._stopPropogation&&void 0!==d["*"]&&(k(d["*"], | ||
| b),void 0===b._stopPropogation&&k(f["*"],b)),void 0===b._stopPropogation&&void 0!==e[c]&&p(e[c],b),void 0===b._stopPropogation&&void 0!==a[c]&&p(a[c],b),void 0===b._stopPropogation&&void 0!==e["*"]&&(p(e["*"],b),void 0===b._stopPropogation&&p(a["*"],b)));void 0===b._stopPropogation&&void 0!==z[c]&&k(z[c],b);void 0===b._stopPropogation&&void 0!==C[c]&&k(C[c],b);void 0===b._stopPropogation&&void 0!==z["*"]&&(k(z["*"],b),void 0===b._stopPropogation&&k(C["*"],b));return void 0!==b._preventDefault?!1: | ||
| !0},H=function(a,c,b,d,f,e){b=new L(a,c,b,d,f,e,"update");void 0!==a.__kb&&(d=a.__kb._attrUpdateListeners,f=a.__kb._styleUpdateListeners,e=a.__kb._parentAttrUpdateListeners,a=a.__kb._parentStyleUpdateListeners,void 0!==d[c]&&k(d[c],b),void 0===b._stopPropogation&&void 0!==f[c]&&k(f[c],b),void 0===b._stopPropogation&&void 0!==d["*"]&&(k(d["*"],b),void 0===b._stopPropogation&&k(f["*"],b)),void 0===b._stopPropogation&&void 0!==e[c]&&p(e[c],b),void 0===b._stopPropogation&&void 0!==a[c]&&p(a[c],b),void 0=== | ||
| b._stopPropogation&&void 0!==e["*"]&&(p(e["*"],b),void 0===b._stopPropogation&&p(a["*"],b)));void 0===b._stopPropogation&&void 0!==y[c]&&k(y[c],b);void 0===b._stopPropogation&&void 0!==B[c]&&k(B[c],b);void 0===b._stopPropogation&&void 0!==y["*"]&&(k(y["*"],b),void 0===b._stopPropogation&&k(B["*"],b));return void 0!==b._preventDefault?!1:!0};h.injectPrototypeProperty=function(a,c,b,d,f){var e=a.prototype,g=Object.getOwnPropertyDescriptor(e,c);b=b||a.toString().split(/\s+/)[1].split("{")[0].replace("()", | ||
| "");var k=v[b];d=d||J;f=f||H;void 0===e.attrListeners&&(e={},e.attrListeners=function(){void 0===this.__kb&&(this.__kb=new M);return this.__kb}.bind(e),e.addAttrListener=h.addAttrListener,e.addAttrUpdateListener=h.addAttrUpdateListener,e.addChildAttrListener=N,e.addChildAttrUpdateListener=O,e.hasListener=P,e.removeAttrListener=h.removeAttrListener,e.removeAttrUpdateListener=h.removeAttrUpdateListener,e.removeChildAttrListener=V,e.removeChildAttrUpdateListener=W,e.stopChange=Q);void 0===k&&(v[b]={obj:a, | ||
| proto:e,descriptors:{},set:void 0,update:void 0},k=v[b],k.set=d,k.update=f);void 0===k.descriptors[c]&&(k.descriptors[c]=g);g.configurable&&(void 0!==g.set?Object.defineProperty(e,c,{get:g.get,set:R(g,c,d,f),enumerable:!0,configurable:!0}):"function"===typeof g.value?Object.defineProperty(e,c,{value:T(g,c,d,f),writable:!0,enumerable:!0,configurable:!0}):void 0!==g.value&&Object.defineProperty(e,c,{get:function(){return g.value},set:S(g,c,d,f),enumerable:!0,configurable:!0}));return h};h.injectStyleProperty= | ||
| function(a,c,b,d){var f=a.style,e=Object.getOwnPropertyDescriptor(f,c),g=a.attrListeners().injectedStyle;b=b||J;d=d||H;void 0===g&&(a.attrListeners().injectedStyle={obj:a,proto:f,descriptors:{},set:void 0,update:void 0},a.attrListeners().injectedStyle.set=b,a.attrListeners().injectedStyle.update=d,g=a.attrListeners().injectedStyle);void 0===g.descriptors[c]&&(g.descriptors[c]=e);e.configurable&&Object.defineProperty(f,c,U(e,c,b,d,a));return h};h.injectPrototypes=function(a,c,b,d){var f=a.prototype; | ||
| c=c||a.toString().split(/\s+/)[1].split("{")[0].replace("()","");var e=v[c],g=Object.getOwnPropertyNames(f);b=b||J;d=d||H;var k;void 0===f.attrListeners&&(f.attrListeners=function(){void 0===this.__kb&&(this.__kb=new M);return this.__kb},f.addAttrListener=h.addAttrListener,f.addAttrUpdateListener=h.addAttrUpdateListener,f.addChildAttrListener=N,f.addChildAttrUpdateListener=O,f.hasListener=P,f.stopChange=Q);void 0===e&&(v[c]={obj:a,proto:f,descriptors:{},set:void 0,update:void 0},e=v[c],e.set=b,e.update= | ||
| d);k=v[c].descriptors;for(d=0;d<g.length;d+=1)void 0===k[g[d]]&&h.injectPrototypeProperty(a,g[d],c,b,H);if(-1!==g.indexOf("value")){var m=function(a){var b,c,d;if("checkbox"===this.type||"radio"===this.type)b=!0;c=b?"string"===typeof this.checked?this.checked:this.checked?"true":"false":this.value;setTimeout(function(){d=b?"string"===typeof this.checked?this.checked:this.checked?"true":"false":this.value;b&&(e.set(this,"checked",this.checked,c)?e.update(this,"checked",this.checked,c):k.checked.set.call(this, | ||
| c));this.value=d;e.set(this,"value",this.value,c)?e.update(this,"value",this.checked,c):k.value.set.call(this,c)}.bind(this),0)};f.removeInputBinding=function(){this.attrListeners()._onkeydown=void 0;this.removeEventListener("keydown",m)};f.addInputBinding=function(){this.attrListeners()._onkeydown=!0;this.addEventListener("keydown",m)};f.removeInputBoxBinding=function(){this.attrListeners()._onmousedown=void 0;this.removeEventListener("mouseup",m)};f.addInputBoxBinding=function(){this.attrListeners()._onmousedown= | ||
| !0;this.addEventListener("mouseup",m)}}return h};h.addAttrListener=function(a,c,b){if("html"===a){a=0;for(var d=t.length;a<d;a++)E.call(this,t[a],c,b,!1)}else if("events"===a)for(a=0,d=D.length;a<d;a++)E.call(this,D[a],c,b,!1);else E.call(this,a,c,b,!1);return this};h.addAttrUpdateListener=function(a,c,b){if("html"===a){a=0;for(var d=t.length;a<d;a++)E.call(this,t[a],c,b,!0)}else if("events"===a)for(a=0,d=D.length;a<d;a++)E.call(this,D[a],c,b,!0);else E.call(this,a,c,b,!0);return this};h.removeAttrListener= | ||
| function(a,c,b){if("html"===a){a=0;for(var d=t.length;a<d;a++)F.call(this,t[a],c,b,!1)}else if("events"===a)for(a=0,d=D.length;a<d;a++)F.call(this,D[a],c,b,!1);else F.call(this,a,c,b,!1);return this};h.removeAttrUpdateListener=function(a,c,b){if("html"===a){a=0;for(var d=t.length;a<d;a++)F.call(this,t[a],c,b,!0)}else if("events"===a)for(a=0,d=D.length;a<d;a++)F.call(this,D[a],c,b,!0);else F.call(this,a,c,b,!0);return this};h.hasListener=function(a,c,b){"html"===c&&(c="innerHTML");"events"===c&&(c= | ||
| "onclick");switch(a){case "attr":if(I(z[c],b))return!0;break;case "attrupdate":if(I(y[c],b))return!0}return!1};h.injectedPrototypes=function(){return v};return h}"function"===typeof define&&define.amd&&define("KB",G);return G}();window.define&&window.require?define([],function(){return G}):window.module&&(module.exports=G);return G}(); | ||
| "";e(a.target,a.arguments[0],c,void 0!==b?b.value:"",[c])||a.preventDefault()}function g(a){var b=a.target.attributes[a.arguments[0]],c="setAttribute"===a.attr?a.arguments[1]:"";f(a.target,a.arguments[0],c,void 0!==b?b.value:"",[c])}h.injectPrototypes(Node,"Node");h.injectPrototypes(Element,"Element");h.injectPrototypes(HTMLElement,"HTMLElement");h.injectPrototypes(HTMLInputElement,"HTMLInputElement");h.injectPrototypes(HTMLTextAreaElement,"HTMLTextAreaElement");h.injectPrototypes(Document,"Document"); | ||
| var e=J,f=H;h.addAttrUpdateListener("appendChild",b);h.addAttrUpdateListener("removeChild",b);h.addAttrUpdateListener("innerHTML",b);h.addAttrUpdateListener("outerHTML",b);h.addAttrUpdateListener("innerText",b);h.addAttrUpdateListener("outerText",b);h.addAttrUpdateListener("textContent",b);h.addAttrListener("setAttribute",d);h.addAttrListener("removeAttribute",d);h.addAttrUpdateListener("setAttribute",g);h.addAttrUpdateListener("removeAttribute",g);return h}var z={},y={},C={},B={},v={},t="textContent innerHTML innerText outerHTML outerText appendChild removeChild replaceChild insertAdjacentHTML insertBefore".split(" "), | ||
| x=Object.getOwnPropertyNames(document.body.style),D=Object.keys(HTMLElement.prototype).filter(function(a){return 0===a.indexOf("on")}).concat(["addEventListener","removeEventListener"]),K,J=function(a,c,b,d,g,e){b=new L(a,c,b,d,g,void 0,"set",e);void 0!==a.__kb&&(d=a.__kb._attrListeners,g=a.__kb._styleListeners,e=a.__kb._parentAttrListeners,a=a.__kb._parentStyleListeners,void 0!==d[c]&&k(d[c],b),void 0===b._stopPropogation&&void 0!==g[c]&&k(g[c],b),void 0===b._stopPropogation&&void 0!==d["*"]&&(k(d["*"], | ||
| b),void 0===b._stopPropogation&&k(g["*"],b)),void 0===b._stopPropogation&&void 0!==e[c]&&p(e[c],b),void 0===b._stopPropogation&&void 0!==a[c]&&p(a[c],b),void 0===b._stopPropogation&&void 0!==e["*"]&&(p(e["*"],b),void 0===b._stopPropogation&&p(a["*"],b)));void 0===b._stopPropogation&&void 0!==z[c]&&k(z[c],b);void 0===b._stopPropogation&&void 0!==C[c]&&k(C[c],b);void 0===b._stopPropogation&&void 0!==z["*"]&&(k(z["*"],b),void 0===b._stopPropogation&&k(C["*"],b));return void 0!==b._preventDefault?!1: | ||
| !0},H=function(a,c,b,d,g,e){b=new L(a,c,b,d,g,e,"update");void 0!==a.__kb&&(d=a.__kb._attrUpdateListeners,g=a.__kb._styleUpdateListeners,e=a.__kb._parentAttrUpdateListeners,a=a.__kb._parentStyleUpdateListeners,void 0!==d[c]&&k(d[c],b),void 0===b._stopPropogation&&void 0!==g[c]&&k(g[c],b),void 0===b._stopPropogation&&void 0!==d["*"]&&(k(d["*"],b),void 0===b._stopPropogation&&k(g["*"],b)),void 0===b._stopPropogation&&void 0!==e[c]&&p(e[c],b),void 0===b._stopPropogation&&void 0!==a[c]&&p(a[c],b),void 0=== | ||
| b._stopPropogation&&void 0!==e["*"]&&(p(e["*"],b),void 0===b._stopPropogation&&p(a["*"],b)));void 0===b._stopPropogation&&void 0!==y[c]&&k(y[c],b);void 0===b._stopPropogation&&void 0!==B[c]&&k(B[c],b);void 0===b._stopPropogation&&void 0!==y["*"]&&(k(y["*"],b),void 0===b._stopPropogation&&k(B["*"],b));return void 0!==b._preventDefault?!1:!0};h.injectPrototypeProperty=function(a,c,b,d,g){var e=a.prototype,f=Object.getOwnPropertyDescriptor(e,c);b=b||a.toString().split(/\s+/)[1].split("{")[0].replace("()", | ||
| "");var k=v[b];d=d||J;g=g||H;void 0===e.attrListeners&&(e={},e.attrListeners=function(){void 0===this.__kb&&(this.__kb=new M);return this.__kb}.bind(e),e.addAttrListener=h.addAttrListener,e.addAttrUpdateListener=h.addAttrUpdateListener,e.addChildAttrListener=N,e.addChildAttrUpdateListener=O,e.hasListener=R,e.removeAttrListener=h.removeAttrListener,e.removeAttrUpdateListener=h.removeAttrUpdateListener,e.removeChildAttrListener=P,e.removeChildAttrUpdateListener=Q,e.stopChange=S);void 0===k&&(v[b]={obj:a, | ||
| proto:e,descriptors:{},set:void 0,update:void 0},k=v[b],k.set=d,k.update=g);void 0===k.descriptors[c]&&(k.descriptors[c]=f);f.configurable&&(void 0!==f.set?Object.defineProperty(e,c,{get:f.get,set:T(f,c,d,g),enumerable:!0,configurable:!0}):"function"===typeof f.value?Object.defineProperty(e,c,{value:V(f,c,d,g),writable:!0,enumerable:!0,configurable:!0}):void 0!==f.value&&Object.defineProperty(e,c,{get:function(){return f.value},set:U(f,c,d,g),enumerable:!0,configurable:!0}));return h};h.injectStyleProperty= | ||
| function(a,c,b,d){var g=a.style,e=Object.getOwnPropertyDescriptor(g,c),f=a.attrListeners().injectedStyle;b=b||J;d=d||H;void 0===f&&(a.attrListeners().injectedStyle={obj:a,proto:g,descriptors:{},set:void 0,update:void 0},a.attrListeners().injectedStyle.set=b,a.attrListeners().injectedStyle.update=d,f=a.attrListeners().injectedStyle);void 0===f.descriptors[c]&&(f.descriptors[c]=e);e.configurable&&Object.defineProperty(g,c,W(e,c,b,d,a));return h};h.injectPrototypes=function(a,c,b,d){var g=a.prototype; | ||
| c=c||a.toString().split(/\s+/)[1].split("{")[0].replace("()","");var e=v[c],f=Object.getOwnPropertyNames(g);b=b||J;d=d||H;var k;void 0===g.attrListeners&&(g.attrListeners=function(){void 0===this.__kb&&(this.__kb=new M);return this.__kb},g.addAttrListener=h.addAttrListener,g.addAttrUpdateListener=h.addAttrUpdateListener,g.addChildAttrListener=N,g.addChildAttrUpdateListener=O,g.removeAttrListener=h.removeAttrListener,g.removeAttrUpdateListener=h.removeAttrUpdateListener,g.removeChildAttrListener=P, | ||
| g.removeChildAttrUpdateListener=Q,g.hasListener=R,g.stopChange=S);void 0===e&&(v[c]={obj:a,proto:g,descriptors:{},set:void 0,update:void 0},e=v[c],e.set=b,e.update=d);k=v[c].descriptors;for(d=0;d<f.length;d+=1)void 0===k[f[d]]&&h.injectPrototypeProperty(a,f[d],c,b,H);if(-1!==f.indexOf("value")){var m=function(a){var b,c,d;if("checkbox"===this.type||"radio"===this.type)b=!0;c=b?"string"===typeof this.checked?this.checked:this.checked?"true":"false":this.value;setTimeout(function(){d=b?"string"===typeof this.checked? | ||
| this.checked:this.checked?"true":"false":this.value;b&&(e.set(this,"checked",this.checked,c)?e.update(this,"checked",this.checked,c):k.checked.set.call(this,c));this.value=d;e.set(this,"value",this.value,c)?e.update(this,"value",this.checked,c):k.value.set.call(this,c)}.bind(this),0)};g.removeInputBinding=function(){this.attrListeners()._onkeydown=void 0;this.removeEventListener("keydown",m)};g.addInputBinding=function(){this.attrListeners()._onkeydown=!0;this.addEventListener("keydown",m)};g.removeInputBoxBinding= | ||
| function(){this.attrListeners()._onmousedown=void 0;this.removeEventListener("mouseup",m)};g.addInputBoxBinding=function(){this.attrListeners()._onmousedown=!0;this.addEventListener("mouseup",m)}}return h};h.addAttrListener=function(a,c,b){if("html"===a){a=0;for(var d=t.length;a<d;a++)E.call(this,t[a],c,b,!1)}else if("events"===a)for(a=0,d=D.length;a<d;a++)E.call(this,D[a],c,b,!1);else E.call(this,a,c,b,!1);return this};h.addAttrUpdateListener=function(a,c,b){if("html"===a){a=0;for(var d=t.length;a< | ||
| d;a++)E.call(this,t[a],c,b,!0)}else if("events"===a)for(a=0,d=D.length;a<d;a++)E.call(this,D[a],c,b,!0);else E.call(this,a,c,b,!0);return this};h.removeAttrListener=function(a,c,b){if("html"===a){a=0;for(var d=t.length;a<d;a++)F.call(this,t[a],c,b,!1)}else if("events"===a)for(a=0,d=D.length;a<d;a++)F.call(this,D[a],c,b,!1);else F.call(this,a,c,b,!1);return this};h.removeAttrUpdateListener=function(a,c,b){if("html"===a){a=0;for(var d=t.length;a<d;a++)F.call(this,t[a],c,b,!0)}else if("events"===a)for(a= | ||
| 0,d=D.length;a<d;a++)F.call(this,D[a],c,b,!0);else F.call(this,a,c,b,!0);return this};h.hasListener=function(a,c,b){"html"===c&&(c="innerHTML");"events"===c&&(c="onclick");switch(a){case "attr":if(I(z[c],b))return!0;break;case "attrupdate":if(I(y[c],b))return!0}return!1};h.injectedPrototypes=function(){return v};return h}"function"===typeof define&&define.amd&&define("KB",G);return G}();"undefined"!==typeof window&&"undefined"!==typeof window.define&&"undefined"!==typeof window.require?define([], | ||
| function(){return G}):"undefined"!==typeof module&&(module.exports=G);return G}(); |
+2
-2
| { | ||
| "name": "KB", | ||
| "version": "0.7.3", | ||
| "version": "0.7.4", | ||
| "description": "A Dom Attributes Binding and Event Listener Library", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
| "devDependencies": { | ||
| "K_Tasks": "^0.5.0" | ||
| "K_Tasks": "^0.6.4" | ||
| }, | ||
@@ -38,0 +38,0 @@ "scripts": { |
6708763
0.01%1284
0.39%