@osimatic/helpers-js 1.1.14 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/form_helper.js +17 -0
- package/package.json +1 -1
- package/string.js +4 -0
package/form_helper.js
CHANGED
|
@@ -100,6 +100,23 @@ class FormHelper {
|
|
|
100
100
|
return textarea.val().replace(/(\r\n|\n|\r)/g, "\n").split("\n").filter(word => word.length > 0);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
static setOnInputChange(input, callback, doneTypingInterval) {
|
|
104
|
+
//setup before functions
|
|
105
|
+
let typingTimer; //timer identifier
|
|
106
|
+
doneTypingInterval = typeof doneTypingInterval != 'undefined' && null !== doneTypingInterval ? doneTypingInterval : 700; // time in ms
|
|
107
|
+
|
|
108
|
+
//on keyup, start the countdown
|
|
109
|
+
input.on('keyup', function () {
|
|
110
|
+
clearTimeout(typingTimer);
|
|
111
|
+
typingTimer = setTimeout(callback, doneTypingInterval);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
//on keydown, clear the countdown
|
|
115
|
+
input.on('keydown', function () {
|
|
116
|
+
clearTimeout(typingTimer);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
103
120
|
// ------------------------------------------------------------
|
|
104
121
|
// Select
|
|
105
122
|
// ------------------------------------------------------------
|
package/package.json
CHANGED
package/string.js
CHANGED
|
@@ -115,6 +115,10 @@ String.prototype.ucwords = String.prototype.ucwords || function() {
|
|
|
115
115
|
String.prototype.capitalize = String.prototype.capitalize || function() {
|
|
116
116
|
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
117
117
|
}
|
|
118
|
+
String.prototype.acronym = String.prototype.acronym || function() {
|
|
119
|
+
return this.split(' ').map(word => word.charAt(0)).join('');
|
|
120
|
+
//return this.match(/\b(\w)/g).join('');
|
|
121
|
+
}
|
|
118
122
|
|
|
119
123
|
String.prototype.encodeForHtmlDataAttribute = String.prototype.encodeForHtmlDataAttribute || function() {
|
|
120
124
|
return this.replace(/\"/g, "'");
|