@convergence/input-element-bindings
Advanced tools
Comparing version 0.1.0 to 0.1.1
/**! | ||
© 2017 Convergence Labs, Inc. | ||
@version 0.1.0 | ||
@version 0.1.1 | ||
@license MIT | ||
@@ -146,2 +146,22 @@ */ | ||
}, { | ||
key: "insertText", | ||
value: function insertText(index, value) { | ||
var oldVal = this._input.value; | ||
var newVal = oldVal.substring(0, index) + value + oldVal.substring(index, oldVal.length); | ||
this.setValue(newVal); | ||
} | ||
}, { | ||
key: "removeText", | ||
value: function removeText(index, length) { | ||
var oldVal = this._input.value; | ||
var newVal = oldVal.substring(0, index) + oldVal.substring(index + length, oldVal.length); | ||
this.setValue(newVal); | ||
} | ||
}, { | ||
key: "setValue", | ||
value: function setValue(value) { | ||
this._input.value = value; | ||
this._oldValue = value; | ||
} | ||
}, { | ||
key: "_onEvent", | ||
@@ -265,4 +285,3 @@ value: function _onEvent() { | ||
if (!event.local) { | ||
var oldVal = textInput.value; | ||
textInput.value = oldVal.substring(0, event.index) + event.value + oldVal.substring(event.index, oldVal.length); | ||
processor.insertText(event.index, event.value); | ||
} | ||
@@ -275,4 +294,3 @@ }; | ||
if (!event.local) { | ||
var oldVal = textInput.value; | ||
textInput.value = oldVal.substring(0, event.index) + oldVal.substring(event.index + event.value.length, oldVal.length); | ||
processor.removeText(event.index, event.value.length); | ||
} | ||
@@ -284,3 +302,3 @@ }; | ||
var onRemoteValue = function onRemoteValue(event) { | ||
if (!event.local) textInput.value = event.value; | ||
if (!event.local) processor.setValue(event.value); | ||
}; | ||
@@ -287,0 +305,0 @@ |
/**! | ||
© 2017 Convergence Labs, Inc. | ||
@version 0.1.0 | ||
@version 0.1.1 | ||
@license MIT | ||
*/ | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("Convergence")):"function"==typeof define&&define.amd?define("ConvergenceInputElementBinder",["Convergence"],n):"object"==typeof exports?exports.ConvergenceInputElementBinder=n(require("Convergence")):e.ConvergenceInputElementBinder=n(e.Convergence)}(this,function(e){return function(e){function n(r){if(t[r])return t[r].exports;var u=t[r]={exports:{},id:r,loaded:!1};return e[r].call(u.exports,u,u.exports,n),u.loaded=!0,u.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(1);Object.keys(r).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var u=t(3);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,n,t){"use strict";function r(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0}),n.TextInputProcessor=void 0;var u=function(){function e(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(n,t,r){return t&&e(n.prototype,t),r&&e(n,r),n}}(),o=t(2);n.TextInputProcessor=function(){function e(n){r(this,e);var t=(0,o.resolveElement)(n.element);if(t instanceof HTMLInputElement){if("text"!==t.type&&"url"!==t.type&&"tel"!==t.type&&"search"!==t.type&&"password"!==t.type)throw new Error("HTMLInputElement must of of type 'text', 'url', 'tel', or 'search': "+t.type)}else if(!(t instanceof HTMLTextAreaElement))throw new Error("Input element must either an HTMLTextInput or a HTMLTextArea.");this._input=t,this._onInsert=n.onInsert,this._onRemove=n.onRemove,this._event=n.event||"input",this._oldValue=this._input.value,this._listener=this._onEvent.bind(this),this.bind()}return u(e,[{key:"bind",value:function(){this._input.addEventListener(this._event,this._listener)}},{key:"unbind",value:function(){this._input.removeEventListener(this._event,this._listener)}},{key:"_onEvent",value:function(){var e=this._input.value,n=0,t=0;if(this._oldValue!==e){for(;this._oldValue.charAt(t)===e.charAt(t);)t++;for(;this._oldValue.charAt(this._oldValue.length-1-n)===e.charAt(e.length-1-n)&&n+t<this._oldValue.length&&n+t<e.length;)n++;this._oldValue.length!==t+n&&this._onRemove&&this._onRemove(t,this._oldValue.length-t-n),e.length!==t+n&&this._onInsert&&this._onInsert(t,e.slice(t,e.length-n)),this._oldValue=e}}}]),e}()},function(e,n){"use strict";function t(e){if(e instanceof HTMLElement)return e;if("string"==typeof e){var n=document.getElementById(e);if(void 0===n)throw new ReferenceError("An element with id '"+e+"' could not be found.");return n}throw new Error("The supplied argument must be an HTMLElement or a string representing an element id.")}Object.defineProperty(n,"__esModule",{value:!0}),n.resolveElement=t},function(e,n,t){"use strict";function r(e,n){var t=(0,c.resolveElement)(e);t.value=n.value();var r=new f.TextInputProcessor({element:t,event:"input",onInsert:function(e,t){return n.insert(e,t)},onRemove:function(e,t){return n.remove(e,t)}}),u=function(n){if(!n.local){var t=e.value;e.value=t.substring(0,n.index)+n.value+t.substring(n.index,t.length)}};n.on(E.RealTimeString.Events.INSERT,u);var o=function(n){if(!n.local){var t=e.value;e.value=t.substring(0,n.index)+t.substring(n.index+n.value.length,t.length)}};n.on(E.RealTimeString.Events.REMOVE,o);var i=function(n){n.local||(e.value=n.value)};n.on(E.RealTimeString.Events.VALUE,i);var l=function(){r.unbind(),n.off(E.RealTimeString.Events.INSERT,u),n.off(E.RealTimeString.Events.REMOVE,o),n.off(E.RealTimeString.Events.VALUE,i)};return n.on(E.RealTimeString.Events.DETACHED,l),{unbind:l}}function u(e,n){var t=(0,c.resolveElement)(e);t.value=n.value();var r=function(t){return n.value(Number(e.value))};t.addEventListener("input",r,!1);var u=function(n){n.local||(e.value=n.element.value())};n.on(E.RealTimeNumber.Events.VALUE,u);var o=function(n){n.local||(e.value=Number(e.value)+n.value)};n.on(E.RealTimeNumber.Events.DELTA,o);var i=function(){t.removeEventListener("input",r),n.off(E.RealTimeNumber.Events.VALUE,u),n.off(E.RealTimeNumber.Events.DELTA,o)};return n.on(E.RealTimeNumber.Events.DETACHED,i),{unbind:i}}function o(e,n){var t=(0,c.resolveElement)(e);t.checked=n.value();var r=function(e){return n.value(t.checked)};e.addEventListener("change",r,!1);var u=function(n){n.local||(e.checked=n.element.value())};n.on(E.RealTimeBoolean.Events.VALUE,u);var o=function(){e.removeEventListener("change",r),n.off(E.RealTimeBoolean.Events.VALUE,u)};return n.on(E.RealTimeNumber.Events.DETACHED,o),{unbind:o}}function i(e,n){return u(e,n)}function l(e,n){var t=(0,c.resolveElement)(e);t.value=n.value();var r=function(t){return n.value(e.value)};t.addEventListener("input",r,!1);var u=function(n){n.local||(e.value=n.element.value())};n.on(E.RealTimeNumber.Events.VALUE,u);var o=function(){t.removeEventListener("input",r),n.off(E.RealTimeNumber.Events.VALUE,u)};return n.on(E.RealTimeNumber.Events.DETACHED,o),{unbind:o}}function a(e,n){var t=(0,c.resolveElement)(e);t.value=n.value();var r=function(t){return n.value(e.value)};t.addEventListener("input",r,!1);var u=function(n){n.local||(e.value=n.element.value())};n.on(E.RealTimeNumber.Events.VALUE,u);var o=function(){t.removeEventListener("input",r),n.off(E.RealTimeNumber.Events.VALUE,u)};return n.on(E.RealTimeNumber.Events.DETACHED,o),{unbind:o}}function v(e,n){var t=(0,c.resolveElement)(e),r=function(){for(var t=n.value(),r=0;r<e.options.length;r++){var u=e.options[r];u.selected=t.indexOf(u.value)>=0}};r();var u=function(t){for(var r=[],u=0;u<e.options.length;u++){var o=e.options[u];o.selected&&r.push(o.value)}n.value(r)};t.addEventListener("input",u,!1);var o=function(e){e.local||r()};n.on(E.RealTimeNumber.Events.VALUE,o);var i=function(){t.removeEventListener("input",u),n.off(E.RealTimeNumber.Events.VALUE,o)};return n.on(E.RealTimeNumber.Events.DETACHED,i),{unbind:i}}function s(e,n){var t=e.map(function(e){return(0,c.resolveElement)(e)}),r=function(){var t=n.value();e.forEach(function(e){return e.checked=e.value===t})};r();var u=function(t){var r=!1;e.forEach(function(e){e.checked&&(n.value(e.value),r=!0)}),r||n.value("")};t.forEach(function(e){return e.addEventListener("change",u,!1)});var o=function(e){e.local||r()};n.on(E.RealTimeNumber.Events.VALUE,o);var i=function(){t.forEach(function(e){return e.removeEventListener("change",u,!1)}),n.off(E.RealTimeNumber.Events.VALUE,o)};return n.on(E.RealTimeNumber.Events.DETACHED,i),{unbind:i}}Object.defineProperty(n,"__esModule",{value:!0}),n.bindTextInput=r,n.bindNumberInput=u,n.bindCheckboxInput=o,n.bindRangeInput=i,n.bindColorInput=l,n.bindSingleSelect=a,n.bindMultiSelect=v,n.bindRadioInputs=s;var c=t(2),f=t(1),E=t(4)},function(n,t){n.exports=e}])}); | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("Convergence")):"function"==typeof define&&define.amd?define("ConvergenceInputElementBinder",["Convergence"],n):"object"==typeof exports?exports.ConvergenceInputElementBinder=n(require("Convergence")):e.ConvergenceInputElementBinder=n(e.Convergence)}(this,function(e){return function(e){function n(r){if(t[r])return t[r].exports;var u=t[r]={exports:{},id:r,loaded:!1};return e[r].call(u.exports,u,u.exports,n),u.loaded=!0,u.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(1);Object.keys(r).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var u=t(3);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,n,t){"use strict";function r(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0}),n.TextInputProcessor=void 0;var u=function(){function e(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(n,t,r){return t&&e(n.prototype,t),r&&e(n,r),n}}(),i=t(2);n.TextInputProcessor=function(){function e(n){r(this,e);var t=(0,i.resolveElement)(n.element);if(t instanceof HTMLInputElement){if("text"!==t.type&&"url"!==t.type&&"tel"!==t.type&&"search"!==t.type&&"password"!==t.type)throw new Error("HTMLInputElement must of of type 'text', 'url', 'tel', or 'search': "+t.type)}else if(!(t instanceof HTMLTextAreaElement))throw new Error("Input element must either an HTMLTextInput or a HTMLTextArea.");this._input=t,this._onInsert=n.onInsert,this._onRemove=n.onRemove,this._event=n.event||"input",this._oldValue=this._input.value,this._listener=this._onEvent.bind(this),this.bind()}return u(e,[{key:"bind",value:function(){this._input.addEventListener(this._event,this._listener)}},{key:"unbind",value:function(){this._input.removeEventListener(this._event,this._listener)}},{key:"insertText",value:function(e,n){var t=this._input.value,r=t.substring(0,e)+n+t.substring(e,t.length);this.setValue(r)}},{key:"removeText",value:function(e,n){var t=this._input.value,r=t.substring(0,e)+t.substring(e+n,t.length);this.setValue(r)}},{key:"setValue",value:function(e){this._input.value=e,this._oldValue=e}},{key:"_onEvent",value:function(){var e=this._input.value,n=0,t=0;if(this._oldValue!==e){for(;this._oldValue.charAt(t)===e.charAt(t);)t++;for(;this._oldValue.charAt(this._oldValue.length-1-n)===e.charAt(e.length-1-n)&&n+t<this._oldValue.length&&n+t<e.length;)n++;this._oldValue.length!==t+n&&this._onRemove&&this._onRemove(t,this._oldValue.length-t-n),e.length!==t+n&&this._onInsert&&this._onInsert(t,e.slice(t,e.length-n)),this._oldValue=e}}}]),e}()},function(e,n){"use strict";function t(e){if(e instanceof HTMLElement)return e;if("string"==typeof e){var n=document.getElementById(e);if(void 0===n)throw new ReferenceError("An element with id '"+e+"' could not be found.");return n}throw new Error("The supplied argument must be an HTMLElement or a string representing an element id.")}Object.defineProperty(n,"__esModule",{value:!0}),n.resolveElement=t},function(e,n,t){"use strict";function r(e,n){var t=(0,c.resolveElement)(e);t.value=n.value();var r=new f.TextInputProcessor({element:t,event:"input",onInsert:function(e,t){return n.insert(e,t)},onRemove:function(e,t){return n.remove(e,t)}}),u=function(e){e.local||r.insertText(e.index,e.value)};n.on(E.RealTimeString.Events.INSERT,u);var i=function(e){e.local||r.removeText(e.index,e.value.length)};n.on(E.RealTimeString.Events.REMOVE,i);var o=function(e){e.local||r.setValue(e.value)};n.on(E.RealTimeString.Events.VALUE,o);var l=function(){r.unbind(),n.off(E.RealTimeString.Events.INSERT,u),n.off(E.RealTimeString.Events.REMOVE,i),n.off(E.RealTimeString.Events.VALUE,o)};return n.on(E.RealTimeString.Events.DETACHED,l),{unbind:l}}function u(e,n){var t=(0,c.resolveElement)(e);t.value=n.value();var r=function(t){return n.value(Number(e.value))};t.addEventListener("input",r,!1);var u=function(n){n.local||(e.value=n.element.value())};n.on(E.RealTimeNumber.Events.VALUE,u);var i=function(n){n.local||(e.value=Number(e.value)+n.value)};n.on(E.RealTimeNumber.Events.DELTA,i);var o=function(){t.removeEventListener("input",r),n.off(E.RealTimeNumber.Events.VALUE,u),n.off(E.RealTimeNumber.Events.DELTA,i)};return n.on(E.RealTimeNumber.Events.DETACHED,o),{unbind:o}}function i(e,n){var t=(0,c.resolveElement)(e);t.checked=n.value();var r=function(e){return n.value(t.checked)};e.addEventListener("change",r,!1);var u=function(n){n.local||(e.checked=n.element.value())};n.on(E.RealTimeBoolean.Events.VALUE,u);var i=function(){e.removeEventListener("change",r),n.off(E.RealTimeBoolean.Events.VALUE,u)};return n.on(E.RealTimeNumber.Events.DETACHED,i),{unbind:i}}function o(e,n){return u(e,n)}function l(e,n){var t=(0,c.resolveElement)(e);t.value=n.value();var r=function(t){return n.value(e.value)};t.addEventListener("input",r,!1);var u=function(n){n.local||(e.value=n.element.value())};n.on(E.RealTimeNumber.Events.VALUE,u);var i=function(){t.removeEventListener("input",r),n.off(E.RealTimeNumber.Events.VALUE,u)};return n.on(E.RealTimeNumber.Events.DETACHED,i),{unbind:i}}function a(e,n){var t=(0,c.resolveElement)(e);t.value=n.value();var r=function(t){return n.value(e.value)};t.addEventListener("input",r,!1);var u=function(n){n.local||(e.value=n.element.value())};n.on(E.RealTimeNumber.Events.VALUE,u);var i=function(){t.removeEventListener("input",r),n.off(E.RealTimeNumber.Events.VALUE,u)};return n.on(E.RealTimeNumber.Events.DETACHED,i),{unbind:i}}function v(e,n){var t=(0,c.resolveElement)(e),r=function(){for(var t=n.value(),r=0;r<e.options.length;r++){var u=e.options[r];u.selected=t.indexOf(u.value)>=0}};r();var u=function(t){for(var r=[],u=0;u<e.options.length;u++){var i=e.options[u];i.selected&&r.push(i.value)}n.value(r)};t.addEventListener("input",u,!1);var i=function(e){e.local||r()};n.on(E.RealTimeNumber.Events.VALUE,i);var o=function(){t.removeEventListener("input",u),n.off(E.RealTimeNumber.Events.VALUE,i)};return n.on(E.RealTimeNumber.Events.DETACHED,o),{unbind:o}}function s(e,n){var t=e.map(function(e){return(0,c.resolveElement)(e)}),r=function(){var t=n.value();e.forEach(function(e){return e.checked=e.value===t})};r();var u=function(t){var r=!1;e.forEach(function(e){e.checked&&(n.value(e.value),r=!0)}),r||n.value("")};t.forEach(function(e){return e.addEventListener("change",u,!1)});var i=function(e){e.local||r()};n.on(E.RealTimeNumber.Events.VALUE,i);var o=function(){t.forEach(function(e){return e.removeEventListener("change",u,!1)}),n.off(E.RealTimeNumber.Events.VALUE,i)};return n.on(E.RealTimeNumber.Events.DETACHED,o),{unbind:o}}Object.defineProperty(n,"__esModule",{value:!0}),n.bindTextInput=r,n.bindNumberInput=u,n.bindCheckboxInput=i,n.bindRangeInput=o,n.bindColorInput=l,n.bindSingleSelect=a,n.bindMultiSelect=v,n.bindRadioInputs=s;var c=t(2),f=t(1),E=t(4)},function(n,t){n.exports=e}])}); | ||
//# sourceMappingURL=convergence-input-element-bindings.min.js.map |
/**! | ||
© 2017 Convergence Labs, Inc. | ||
@version 0.1.0 | ||
@version 0.1.1 | ||
@license MIT | ||
@@ -49,4 +49,3 @@ */ | ||
if (!event.local) { | ||
var oldVal = textInput.value; | ||
textInput.value = oldVal.substring(0, event.index) + event.value + oldVal.substring(event.index, oldVal.length); | ||
processor.insertText(event.index, event.value); | ||
} | ||
@@ -59,4 +58,3 @@ }; | ||
if (!event.local) { | ||
var oldVal = textInput.value; | ||
textInput.value = oldVal.substring(0, event.index) + oldVal.substring(event.index + event.value.length, oldVal.length); | ||
processor.removeText(event.index, event.value.length); | ||
} | ||
@@ -68,3 +66,3 @@ }; | ||
var onRemoteValue = function onRemoteValue(event) { | ||
if (!event.local) textInput.value = event.value; | ||
if (!event.local) processor.setValue(event.value); | ||
}; | ||
@@ -71,0 +69,0 @@ |
/**! | ||
© 2017 Convergence Labs, Inc. | ||
@version 0.1.0 | ||
@version 0.1.1 | ||
@license MIT | ||
@@ -5,0 +5,0 @@ */ |
/**! | ||
© 2017 Convergence Labs, Inc. | ||
@version 0.1.0 | ||
@version 0.1.1 | ||
@license MIT | ||
@@ -5,0 +5,0 @@ */ |
/**! | ||
© 2017 Convergence Labs, Inc. | ||
@version 0.1.0 | ||
@version 0.1.1 | ||
@license MIT | ||
@@ -56,2 +56,22 @@ */ | ||
}, { | ||
key: "insertText", | ||
value: function insertText(index, value) { | ||
var oldVal = this._input.value; | ||
var newVal = oldVal.substring(0, index) + value + oldVal.substring(index, oldVal.length); | ||
this.setValue(newVal); | ||
} | ||
}, { | ||
key: "removeText", | ||
value: function removeText(index, length) { | ||
var oldVal = this._input.value; | ||
var newVal = oldVal.substring(0, index) + oldVal.substring(index + length, oldVal.length); | ||
this.setValue(newVal); | ||
} | ||
}, { | ||
key: "setValue", | ||
value: function setValue(value) { | ||
this._input.value = value; | ||
this._oldValue = value; | ||
} | ||
}, { | ||
key: "_onEvent", | ||
@@ -58,0 +78,0 @@ value: function _onEvent() { |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "http://convergencelabs.com", | ||
@@ -14,0 +14,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93806
863