*
* Copyright (c) 2011-2012 Aidan Feldman
* MIT Licensed (LICENSE)
- *//*global Backbone, _, $ */(function(){"use strict",Backbone.NestedModel=Backbone.Model.extend({get:function(a,b){b=b||{};var c=Backbone.NestedModel.attrPath(a),d=c[0],e=Backbone.NestedModel.__super__.get.call(this,d);for(var f=1;f<c.length;f++){if(!e)break;d=c[f],e=e[d]}return!b.silent&&_.isObject(e)&&window.console&&window.console.log("Backbone-Nested syntax is preferred for accesing values of attribute '"+a+"'."),e},has:function(a){var b=this.get(a,{silent:!0});return b!==null&&!_.isUndefined(b)},set:function(a,b,c){var d;_.isObject(a)||a==null?(d=a,c=b):(d={},d[a]=b),c=c||{};var e=Backbone.NestedModel.deepClone(this.attributes),f,g,h;for(var i in d)g=Backbone.NestedModel.attrPath(i),h=Backbone.NestedModel.createAttrObj(g,d[i]),this._mergeAttrs(e,h,c);return Backbone.NestedModel.__super__.set.call(this,e,c)},unset:function(a,b){return b=_.extend({},b,{unset:!0}),this.set(a,null,b),this},add:function(a,b,c){var d=this.get(a,{silent:!0});this.set(a+"["+d.length+"]",b,c)},remove:function(a,b){b=b||{};var c=Backbone.NestedModel.attrPath(a),d=_.initial(c),e=this.get(d,{silent:!0}),f=_.last(c);if(!_.isArray(e))throw new Error("remove() must be called on a nested array");var g=!b.silent&&e.length>f+1,h=e[f];return e.splice(f,1),this.set(a,e,b),g&&this.trigger("remove:"+Backbone.NestedModel.createAttrStr(d),this,h),this},toJSON:function(){var a=Backbone.NestedModel.__super__.toJSON.apply(this);return Backbone.NestedModel.deepClone(a)},_mergeAttrs:function(a,b,c,d){return d=d||[],_.each(b,function(b,e){e==="-1"&&(e=a.length);var f=a[e],g=d.concat([e]),h,i=_.isObject(b)&&_.any(b,function(a,b){return b==="-1"||_.isNumber(b)});i&&!_.isArray(f)&&(f=a[e]=[]);if(e in a&&_.isObject(b)&&_.isObject(f))f=a[e]=this._mergeAttrs(f,b,c,g);else{var j=f;f=a[e]=b,_.isArray(a)&&!c.silent&&(h=Backbone.NestedModel.createAttrStr(d),!j&&f?this.trigger("add:"+h,this,f):j&&!f&&this.trigger("remove:"+h,this,j))}!c.silent&&g.length>1&&(h=Backbone.NestedModel.createAttrStr(g),this.trigger("change:"+h,this,f))},this),a}},{attrPath:function(a){var b;return _.isString(a)?(a=a.replace(/\[\]/g,"[-1]"),b=a===""?[""]:a.match(/[^\.\[\]]+/g),b=_.map(b,function(a){return a.match(/^\d+$/)?parseInt(a,10):a})):b=a,b},createAttrObj:function(a,b){var c=this.attrPath(a),d;switch(c.length){case 0:throw"no valid attributes: '"+a+"'";case 1:d=b;break;default:var e=_.rest(c);d=this.createAttrObj(e,b)}var f=c[0],g=_.isNumber(f)?[]:{};return g[f]=d,g},createAttrStr:function(a){var b=a[0];return _.each(_.rest(a),function(a){b+=_.isNumber(a)?"["+a+"]":"."+a}),b},deepClone:function(a){return $.extend(!0,{},a)}})})();
\ No newline at end of file
+ *//*global Backbone, _, $ */(function(){"use strict",Backbone.NestedModel=Backbone.Model.extend({get:function(a,b){b=b||{};var c=Backbone.NestedModel.attrPath(a),d=c[0],e=Backbone.NestedModel.__super__.get.call(this,d);for(var f=1;f<c.length;f++){if(!e)break;d=c[f],e=e[d]}return e},has:function(a){var b=this.get(a,{silent:!0});return b!==null&&!_.isUndefined(b)},set:function(a,b,c){var d;_.isObject(a)||a==null?(d=a,c=b):(d={},d[a]=b),c=c||{};var e=Backbone.NestedModel.deepClone(this.attributes),f,g,h;for(var i in d)g=Backbone.NestedModel.attrPath(i),h=Backbone.NestedModel.createAttrObj(g,d[i]),this._mergeAttrs(e,h,c);return Backbone.NestedModel.__super__.set.call(this,e,c)},unset:function(a,b){return b=_.extend({},b,{unset:!0}),this.set(a,null,b),this},add:function(a,b,c){var d=this.get(a,{silent:!0});this.set(a+"["+d.length+"]",b,c)},remove:function(a,b){b=b||{};var c=Backbone.NestedModel.attrPath(a),d=_.initial(c),e=this.get(d,{silent:!0}),f=_.last(c);if(!_.isArray(e))throw new Error("remove() must be called on a nested array");var g=!b.silent&&e.length>f+1,h=e[f];return e.splice(f,1),this.set(a,e,b),g&&this.trigger("remove:"+Backbone.NestedModel.createAttrStr(d),this,h),this},toJSON:function(){var a=Backbone.NestedModel.__super__.toJSON.apply(this);return Backbone.NestedModel.deepClone(a)},_mergeAttrs:function(a,b,c,d){return d=d||[],_.each(b,function(b,e){e==="-1"&&(e=a.length);var f=a[e],g=d.concat([e]),h,i=_.isObject(b)&&_.any(b,function(a,b){return b==="-1"||_.isNumber(b)});i&&!_.isArray(f)&&(f=a[e]=[]);if(e in a&&_.isObject(b)&&_.isObject(f))f=a[e]=this._mergeAttrs(f,b,c,g);else{var j=f;f=a[e]=b,_.isArray(a)&&!c.silent&&(h=Backbone.NestedModel.createAttrStr(d),!j&&f?this.trigger("add:"+h,this,f):j&&!f&&this.trigger("remove:"+h,this,j))}!c.silent&&g.length>1&&(h=Backbone.NestedModel.createAttrStr(g),this.trigger("change:"+h,this,f))},this),a}},{attrPath:function(a){var b;return _.isString(a)?(a=a.replace(/\[\]/g,"[-1]"),b=a===""?[""]:a.match(/[^\.\[\]]+/g),b=_.map(b,function(a){return a.match(/^\d+$/)?parseInt(a,10):a})):b=a,b},createAttrObj:function(a,b){var c=this.attrPath(a),d;switch(c.length){case 0:throw"no valid attributes: '"+a+"'";case 1:d=b;break;default:var e=_.rest(c);d=this.createAttrObj(e,b)}var f=c[0],g=_.isNumber(f)?[]:{};return g[f]=d,g},createAttrStr:function(a){var b=a[0];return _.each(_.rest(a),function(a){b+=_.isNumber(a)?"["+a+"]":"."+a}),b},deepClone:function(a){return $.extend(!0,{},a)}})})();
\ No newline at end of file
--- /dev/null
+
+
+(function(root, factory) {
+ if (typeof exports !== 'undefined') {
+ return factory(root, exports);
+ } else if (typeof define === 'function' && define.amd) {
+ return define('synapse/core', ['exports'], function(exports) {
+ return factory(root, exports);
+ });
+ } else {
+ return root.SynapseCore = factory(root, {});
+ }
+})(this, function(root, core) {
+ var channels;
+ channels = {};
+ return {
+ toString: Object.prototype.toString,
+ getType: function(object) {
+ return this.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
+ },
+ isObject: function(object) {
+ return this.getType(object) === 'Object';
+ },
+ isArray: function(object) {
+ return this.getType(object) === 'Array';
+ },
+ isFunction: function(object) {
+ return this.getType(object) === 'Function';
+ },
+ isString: function(object) {
+ return this.getType(object) === 'String';
+ },
+ isBoolean: function(object) {
+ return this.getType(object) === 'Boolean';
+ }
+ };
+});
+
+var __slice = Array.prototype.slice;
+
+(function(root, factory) {
+ if (typeof exports !== 'undefined') {
+ return factory(root, exports, require('synapse/core'));
+ } else if (typeof define === 'function' && define.amd) {
+ return define('synapse', ['synapse/core', 'exports'], function(core, exports) {
+ return factory(root, exports, core);
+ });
+ } else {
+ return root.Synapse = factory(root, {}, root.SynapseCore);
+ }
+})(this, function(root, Synapse, core) {
+ var connect, connectOne, defaultConnectOptions, detectEvent, detectInterface, detectOtherInterface, limitedApi, objectGuid, offEvent, onEvent, synapseHooks, synapseObjects, triggerEvent;
+ objectGuid = 1;
+ synapseObjects = {};
+ synapseHooks = [];
+ limitedApi = ['observe', 'notify', 'syncWith', 'stopObserving', 'pauseObserving', 'resumeObserving', 'stopNotifying', 'pauseNotifying', 'resumeNotifying'];
+ Synapse = (function() {
+
+ Synapse.prototype.version = '0.4.2';
+
+ function Synapse(object) {
+ var hook, method, raw, wrapped, _fn, _i, _j, _len, _len2,
+ _this = this;
+ if (object instanceof Synapse) return object;
+ if (this.constructor !== Synapse) {
+ wrapped = new Synapse(object);
+ raw = wrapped.raw;
+ _fn = function(method) {
+ return raw[method] = function() {
+ wrapped[method].apply(wrapped, arguments);
+ return this;
+ };
+ };
+ for (_i = 0, _len = limitedApi.length; _i < _len; _i++) {
+ method = limitedApi[_i];
+ _fn(method);
+ }
+ return raw;
+ }
+ for (_j = 0, _len2 = synapseHooks.length; _j < _len2; _j++) {
+ hook = synapseHooks[_j];
+ if (hook.checkObjectType(object)) break;
+ hook = null;
+ }
+ if (!hook) {
+ throw new Error("No hook exists for " + (core.getType(object)) + " types");
+ }
+ this.raw = (typeof hook.coerceObject === "function" ? hook.coerceObject(object) : void 0) || object;
+ this.hook = hook;
+ this.guid = objectGuid++;
+ this._observing = {};
+ this._notifying = {};
+ synapseObjects[this.guid] = this;
+ }
+
+ Synapse.prototype.get = function() {
+ var _ref;
+ return (_ref = this.hook).getHandler.apply(_ref, [this.raw].concat(__slice.call(arguments)));
+ };
+
+ Synapse.prototype.set = function() {
+ var _ref;
+ (_ref = this.hook).setHandler.apply(_ref, [this.raw].concat(__slice.call(arguments)));
+ return this;
+ };
+
+ Synapse.prototype.observe = function() {
+ var args, other;
+ other = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ other = new Synapse(other);
+ connect.apply(null, [other, this].concat(__slice.call(args)));
+ return this;
+ };
+
+ Synapse.prototype.notify = function() {
+ var args, other;
+ other = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ other = new Synapse(other);
+ connect.apply(null, [this, other].concat(__slice.call(args)));
+ return this;
+ };
+
+ Synapse.prototype.syncWith = function(other) {
+ other = new Synapse(other);
+ this.observe(other).notify(other);
+ return this;
+ };
+
+ Synapse.prototype.stopObserving = function(other) {
+ var channels, observerInterface, subject, subjectGuid, thread;
+ if (!other) {
+ for (subjectGuid in this._observing) {
+ channels = this._observing[subjectGuid];
+ subject = synapseObjects[subjectGuid];
+ for (observerInterface in channels) {
+ thread = channels[observerInterface];
+ offEvent(subject, thread.event, thread.handler);
+ }
+ this._observing = {
+ _open: true
+ };
+ }
+ } else {
+ channels = this._observing[other.guid];
+ for (observerInterface in channels) {
+ thread = channels[observerInterface];
+ offEvent(other, thread.event, thread.handler);
+ }
+ this._observing[other.guid] = {
+ _open: true
+ };
+ }
+ return this;
+ };
+
+ Synapse.prototype.pauseObserving = function(other) {
+ var channels, subjectGuid;
+ if (!other) {
+ for (subjectGuid in this._observing) {
+ channels = this._observing[subjectGuid];
+ channels._open = false;
+ }
+ } else {
+ channels = this._observing[other.guid];
+ channels._open = false;
+ }
+ return this;
+ };
+
+ Synapse.prototype.resumeObserving = function(other) {
+ var channels, subjectGuid;
+ if (other) {
+ if ((channels = this._observing[other.guid])) channels._open = true;
+ } else {
+ for (subjectGuid in this._observing) {
+ this._observing[subjectGuid]._open = true;
+ }
+ }
+ return this;
+ };
+
+ Synapse.prototype.stopNotifying = function(other) {
+ var channels, observer, observerGuid, observerInterface, thread;
+ if (!other) {
+ for (observerGuid in this._notifying) {
+ channels = this._notifying[observerGuid];
+ observer = synapseObjects[observerGuid];
+ for (observerInterface in channels) {
+ thread = channels[observerInterface];
+ offEvent(this, thread.event, thread.handler);
+ }
+ this._notifying = {
+ _open: true
+ };
+ }
+ } else {
+ channels = this._notifying[other.guid];
+ for (observerInterface in channels) {
+ thread = channels[observerInterface];
+ offEvent(this, thread.event, thread.handler);
+ }
+ this._notifying[other.guid] = {
+ _open: true
+ };
+ }
+ return this;
+ };
+
+ Synapse.prototype.pauseNotifying = function(other) {
+ var channels, observerGuid;
+ if (!other) {
+ for (observerGuid in this._notifying) {
+ channels = this._notifying[observerGuid];
+ channels._open = false;
+ }
+ } else {
+ channels = this._notifying[other.guid];
+ channels._open = false;
+ }
+ return this;
+ };
+
+ Synapse.prototype.resumeNotifying = function(other) {
+ var channels, observerGuid;
+ if (other) {
+ if ((channels = this._notifying[other.guid])) channels._open = true;
+ } else {
+ for (observerGuid in this._notifying) {
+ this._notifying[observerGuid]._open = true;
+ }
+ }
+ return this;
+ };
+
+ return Synapse;
+
+ })();
+ Synapse.addHooks = function() {
+ return synapseHooks.push.apply(synapseHooks, arguments);
+ };
+ Synapse.clearHooks = function() {
+ return synapseHooks = [];
+ };
+ detectEvent = function() {
+ var args, object, value, _ref;
+ object = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ if ((value = (_ref = object.hook).detectEvent.apply(_ref, [object.raw].concat(__slice.call(args))))) {
+ return value;
+ }
+ throw new Error("" + object.hook.typeName + " types do not support events");
+ };
+ onEvent = function() {
+ var args, object, value, _base;
+ object = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ if ((value = typeof (_base = object.hook).onEventHandler === "function" ? _base.onEventHandler.apply(_base, [object.raw].concat(__slice.call(args))) : void 0)) {
+ return object;
+ }
+ throw new Error("" + object.hook.typeName + " types do not support events");
+ };
+ offEvent = function() {
+ var args, object, value, _base;
+ object = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ if ((value = typeof (_base = object.hook).offEventHandler === "function" ? _base.offEventHandler.apply(_base, [object.raw].concat(__slice.call(args))) : void 0)) {
+ return object;
+ }
+ throw new Error("" + object.hook.typeName + " types do not support events");
+ };
+ triggerEvent = function() {
+ var args, object, value, _base;
+ object = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ if ((value = typeof (_base = object.hook).triggerEventHandler === "function" ? _base.triggerEventHandler.apply(_base, [object.raw].concat(__slice.call(args))) : void 0)) {
+ return object;
+ }
+ throw new Error("" + object.hook.typeName + " types do not support events");
+ };
+ detectInterface = function(object) {
+ var _base;
+ return typeof (_base = object.hook).detectInterface === "function" ? _base.detectInterface(object.raw) : void 0;
+ };
+ detectOtherInterface = function(object) {
+ var _base;
+ return typeof (_base = object.hook).detectOtherInterface === "function" ? _base.detectOtherInterface(object.raw) : void 0;
+ };
+ defaultConnectOptions = {
+ event: null,
+ subjectInterface: null,
+ observerInterface: null,
+ converter: null,
+ triggerOnBind: true
+ };
+ connectOne = function(subject, observer, options) {
+ var channel, converter, event, events, handler, key, observerChannels, observerInterface, subjectChannels, subjectInterface, triggerOnBind, value, _i, _len;
+ for (key in defaultConnectOptions) {
+ value = defaultConnectOptions[key];
+ if (!(options[key] != null)) options[key] = value;
+ }
+ if ((converter = options.converter) && !core.isFunction(converter)) {
+ converter = observer.object[converter];
+ }
+ if (!(subjectInterface = options.subjectInterface)) {
+ if (!(subjectInterface = detectInterface(subject) || detectOtherInterface(observer)) && !converter) {
+ throw new Error("An interface for " + subject.hook.typeName + " objects could not be detected");
+ }
+ }
+ if (!(observerInterface = options.observerInterface)) {
+ if (!(observerInterface = detectInterface(observer) || detectOtherInterface(subject))) {
+ throw new Error("An interface for " + observer.hook.typeName + " objects could not be detected");
+ }
+ }
+ if (!(events = options.event)) events = detectEvent(subject, subjectInterface);
+ if (!core.isArray(events)) events = [events];
+ triggerOnBind = options.triggerOnBind;
+ for (_i = 0, _len = events.length; _i < _len; _i++) {
+ event = events[_i];
+ handler = function() {
+ if (observer._observing[subject.guid]._open === true && subject._notifying[observer.guid]._open === true) {
+ value = subject.get(subjectInterface);
+ if (converter) value = converter(value);
+ return observer.set(observerInterface, value);
+ }
+ };
+ if (!(observerChannels = observer._observing[subject.guid])) {
+ observerChannels = observer._observing[subject.guid] = {
+ _open: true
+ };
+ }
+ if (!(subjectChannels = subject._notifying[observer.guid])) {
+ subjectChannels = subject._notifying[observer.guid] = {
+ _open: true
+ };
+ }
+ channel = {
+ event: event,
+ handler: handler
+ };
+ observerChannels[observerInterface] = channel;
+ subjectChannels[observerInterface] = channel;
+ onEvent(subject, event, handler);
+ if (triggerOnBind) triggerEvent(subject, event);
+ }
+ };
+ connect = function() {
+ var arg0, arg1, args, observer, opt, options, subject, _i, _len;
+ subject = arguments[0], observer = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
+ options = args;
+ arg0 = args[0];
+ arg1 = args[1];
+ if (core.isFunction(arg0)) {
+ options = {
+ converter: arg0
+ };
+ } else if (core.isArray(arg0) || !core.isObject(arg0)) {
+ options = {
+ subjectInterface: arg0,
+ observerInterface: arg1
+ };
+ }
+ if (!core.isArray(options)) options = [options];
+ for (_i = 0, _len = options.length; _i < _len; _i++) {
+ opt = options[_i];
+ connectOne(subject, observer, opt);
+ }
+ };
+ return Synapse;
+});
+
+
+(function(root, factory) {
+ if (typeof exports !== 'undefined') {
+ return factory(root, exports, require('synapse/core'));
+ } else if (typeof define === 'function' && define.amd) {
+ return define('synapse/hooks/object', ['synapse/core', 'exports'], function(core, exports) {
+ return factory(root, exports, core);
+ });
+ } else {
+ return root.ObjectHook = factory(root, {}, root.SynapseCore);
+ }
+})(this, function(root, ObjectHook, core) {
+ return {
+ typeName: 'Plain Object',
+ checkObjectType: function(object) {
+ return core.isObject(object);
+ },
+ getHandler: function(object, key) {
+ if (core.isFunction(object[key])) {
+ return object[key]();
+ } else {
+ return object[key];
+ }
+ },
+ setHandler: function(object, key, value) {
+ if (core.isFunction(object[key])) {
+ return object[key](value);
+ } else {
+ return object[key] = value;
+ }
+ }
+ };
+});
+
+var __slice = Array.prototype.slice;
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ return define('synapse/hooks/jquery', ['synapse/core', 'jquery', 'exports'], function(core, $, exports) {
+ return factory(root, exports, core, $);
+ });
+ } else if (typeof exports === 'undefined') {
+ return root.jQueryHook = factory(root, {}, root.SynapseCore, root.jQuery);
+ }
+})(this, function(root, jQueryHook, core, $) {
+ var domEvents, elementBindAttributes, elementInterfaces, interfaces;
+ interfaces = (function() {
+ return {
+ registry: {},
+ register: function(config) {
+ return this.registry[config.name] = config;
+ },
+ unregister: function(name) {
+ return delete this.registry[name];
+ },
+ get: function() {
+ var args, iface, key, name, object, _ref;
+ object = arguments[0], name = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
+ _ref = name.split('.'), name = _ref[0], key = _ref[1];
+ if (key != null) args = [key].concat(args);
+ if ((iface = this.registry[name])) return iface.get.apply(object, args);
+ },
+ set: function() {
+ var args, iface, key, name, object, _ref;
+ object = arguments[0], name = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
+ _ref = name.split('.'), name = _ref[0], key = _ref[1];
+ if (key != null) args = [key].concat(args);
+ if ((iface = this.registry[name])) return iface.set.apply(object, args);
+ }
+ };
+ })();
+ (function() {
+ var getAttribute, getCss, getProperty, setAttribute, setCss, setProperty;
+ getProperty = function(key) {
+ if (this.prop != null) return this.prop(key);
+ return getAttribute.call(this, key);
+ };
+ setProperty = function(key, value) {
+ if (this.prop != null) {
+ if (typeof key === 'object') return this.prop(key);
+ return this.prop(key, value);
+ }
+ return setAttribute.call(this, key, value);
+ };
+ getAttribute = function(key) {
+ return this.attr(key);
+ };
+ setAttribute = function(key, value) {
+ if (core.isObject(key)) {
+ return this.attr(key);
+ } else {
+ return this.attr(key, value);
+ }
+ };
+ getCss = function(key) {
+ return this.css(key);
+ };
+ setCss = function(key, value) {
+ if (core.isObject(key)) {
+ return this.css(key);
+ } else {
+ return this.css(key, value);
+ }
+ };
+ interfaces.register({
+ name: 'text',
+ get: function() {
+ return this.text();
+ },
+ set: function(value) {
+ return this.text((value != null ? value : '').toString());
+ }
+ });
+ interfaces.register({
+ name: 'html',
+ get: function() {
+ return this.html();
+ },
+ set: function(value) {
+ return this.html((value != null ? value : '').toString());
+ }
+ });
+ interfaces.register({
+ name: 'value',
+ get: function() {
+ return this.val();
+ },
+ set: function(value) {
+ return this.val(value != null ? value : '');
+ }
+ });
+ interfaces.register({
+ name: 'enabled',
+ get: function() {
+ return !getProperty.call(this, 'disabled');
+ },
+ set: function(value) {
+ if (core.isArray(value) && value.length === 0) value = false;
+ return setProperty.call(this, 'disabled', !Boolean(value));
+ }
+ });
+ interfaces.register({
+ name: 'disabled',
+ get: function() {
+ return getProperty.call(this, 'disabled');
+ },
+ set: function(value) {
+ if (core.isArray(value) && value.length === 0) value = false;
+ return setProperty.call(this, 'disabled', Boolean(value));
+ }
+ });
+ interfaces.register({
+ name: 'checked',
+ get: function() {
+ return getProperty.call(this, 'checked');
+ },
+ set: function(value) {
+ if (core.isArray(value) && value.length === 0) value = false;
+ return setProperty.call(this, 'checked', Boolean(value));
+ }
+ });
+ interfaces.register({
+ name: 'visible',
+ get: function() {
+ return getCss.call(this, 'display') === !'none';
+ },
+ set: function(value) {
+ if (core.isArray(value) && value.length === 0) value = false;
+ if (Boolean(value)) {
+ return this.show();
+ } else {
+ return this.hide();
+ }
+ }
+ });
+ interfaces.register({
+ name: 'hidden',
+ get: function() {
+ return getCss.call(this, 'display') === 'none';
+ },
+ set: function(value) {
+ if (core.isArray(value) && value.length === 0) value = false;
+ if (Boolean(value)) {
+ return this.hide();
+ } else {
+ return this.show();
+ }
+ }
+ });
+ interfaces.register({
+ name: 'prop',
+ get: function(key) {
+ return getProperty.call(this, key);
+ },
+ set: function(key, value) {
+ return setProperty.call(this, key, value);
+ }
+ });
+ interfaces.register({
+ name: 'attr',
+ get: function(key) {
+ return getAttribute.call(this, key);
+ },
+ set: function(key, value) {
+ return setAttribute.call(this, key, value);
+ }
+ });
+ interfaces.register({
+ name: 'css',
+ get: function(key) {
+ return getCss.call(this, key);
+ },
+ set: function(key, value) {
+ return setCss.call(this, key, value);
+ }
+ });
+ interfaces.register({
+ name: 'data',
+ get: function(key) {
+ return this.data(key);
+ },
+ set: function(key, value) {
+ return this.data(key, value);
+ }
+ });
+ return interfaces.register({
+ name: 'class',
+ get: function(key) {
+ return this.hasClass(key);
+ },
+ set: function(key, value) {
+ return this.toggleClass(key, Boolean(value));
+ }
+ });
+ })();
+ domEvents = [['a,button,[type=button],[type=reset]', 'click'], ['select,[type=checkbox],[type=radio],textarea', 'change'], ['[type=submit]', 'submit'], ['input', 'keyup']];
+ elementInterfaces = [['[type=checkbox],[type=radio]', 'checked'], ['input,textarea,select', 'value']];
+ elementBindAttributes = ['name', 'role', 'data-bind'];
+ return {
+ typeName: 'jQuery',
+ domEvents: domEvents,
+ elementBindAttributes: elementBindAttributes,
+ elementInterfaces: elementInterfaces,
+ interfaces: interfaces,
+ checkObjectType: function(object) {
+ return object instanceof $ || object.nodeType === 1 || core.isString(object);
+ },
+ coerceObject: function(object) {
+ return $(object);
+ },
+ getHandler: function(object, key) {
+ var value;
+ value = interfaces.get(object, key);
+ if (value && object.is('[type=number]')) {
+ if (value.indexOf('.') > -1) {
+ return parseFloat(value);
+ } else {
+ return parseInt(value);
+ }
+ }
+ return value;
+ },
+ setHandler: function(object, key, value) {
+ return interfaces.set(object, key, value);
+ },
+ onEventHandler: function(object, event, handler) {
+ return object.bind(event, handler);
+ },
+ offEventHandler: function(object, event, handler) {
+ return object.unbind(event, handler);
+ },
+ triggerEventHandler: function(object, event) {