jquery-keypad-rails 1.4.2.1 → 1.5.0
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.
- checksums.yaml +8 -8
- data/build.me +3 -6
- data/lib/jquery/keypad/rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.keypad-ca.js +21 -0
- data/vendor/assets/javascripts/jquery.keypad-cs.js +21 -0
- data/vendor/assets/javascripts/jquery.keypad-de.js +1 -0
- data/vendor/assets/javascripts/jquery.keypad-es.js +1 -0
- data/vendor/assets/javascripts/jquery.keypad-fr.js +1 -0
- data/vendor/assets/javascripts/jquery.keypad-it.js +1 -0
- data/vendor/assets/javascripts/jquery.keypad-nl.js +1 -0
- data/vendor/assets/javascripts/jquery.keypad-pt-BR.js +1 -0
- data/vendor/assets/javascripts/jquery.keypad-tr.js +1 -0
- data/vendor/assets/javascripts/jquery.keypad.js +273 -265
- data/vendor/assets/javascripts/jquery.keypad.min.js +2 -2
- data/vendor/assets/stylesheets/jquery.keypad.alt.css +1 -1
- data/vendor/assets/stylesheets/jquery.keypad.css +1 -1
- metadata +5 -4
- data/vendor/assets/javascripts/jquery.keypad.pack.js +0 -7
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjhiZDFlNGJlY2M3YzRmZDhkY2VlN2M5MTJmN2U0OWM0NDNjODM4Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzI2OTlmNDhkNTk5ODkzMzZlNGJkMzVmM2QyMTU4Y2YyMTg1YzBhNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODkzNGZlNTE1MjAzYTc5NDU2YTFhZmI4ZWNlMzMyNmUzMTczOGQ2OGMxNjUy
|
10
|
+
NDljNDE0NTkxMGNlMDNjYWI4MDRjN2U5M2FlYmMxNGIwNmJjMzc5ODU5NjU2
|
11
|
+
Zjc5ZmRlZjRmNzQxODJjY2U5YWZmYTNmN2U2MDQ4YjdmMzFkM2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmQ2MzEwM2MzYzJjNjNhNjdlNzcxZjFkYmZlYjBmNzUwNmNkMjcxNjcwYWQ0
|
14
|
+
ODU5MzE2NWU0NzVmMDBiOTc2ZjJlZjEwODk1MTYzYjE5Y2EzMTU2YzgyNTI3
|
15
|
+
OTkzM2YxMTFjNTZmNDViMWQ5MWVjMDVlNGUxNGQ1MTExYTkyZDk=
|
data/build.me
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
VER=1.
|
4
|
-
REV=.1
|
3
|
+
VER=1.5.0
|
5
4
|
|
6
5
|
rm build/*
|
7
6
|
pushd build
|
@@ -20,15 +19,13 @@ cat >lib/jquery/keypad/rails/version.rb <<EOF
|
|
20
19
|
module Jquery
|
21
20
|
module Keypad
|
22
21
|
module Rails
|
23
|
-
VERSION = "${VER}
|
22
|
+
VERSION = "${VER}"
|
24
23
|
end
|
25
24
|
end
|
26
25
|
end
|
27
26
|
EOF
|
28
27
|
|
29
|
-
git commit -a
|
30
|
-
|
31
28
|
gem update --system
|
32
29
|
gem build jquery-keypad-rails.gemspec
|
33
|
-
|
30
|
+
gem push jquery-keypad-rails-${VER}.gem
|
34
31
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* http://keith-wood.name/keypad.html
|
2
|
+
Catalan initialisation for the jQuery keypad extension
|
3
|
+
Written by Ignasi Nogues (inogues@clickartedu.com). */
|
4
|
+
(function($) { // hide the namespace
|
5
|
+
$.keypad.regional['ca'] = {
|
6
|
+
buttonText: '...', buttonStatus: 'Obrir el teclat',
|
7
|
+
closeText: 'Tancar', closeStatus: 'Tancar el teclat',
|
8
|
+
clearText: 'Netejar', clearStatus: 'Eliminar tot el text',
|
9
|
+
backText: 'Tornar', backStatus: 'Borrar el caràcter anterior',
|
10
|
+
shiftText: 'Shift', shiftStatus: 'Canviar majúscules/minúscules',
|
11
|
+
spacebarText: ' ', spacebarStatus: '',
|
12
|
+
enterText: 'Entrar', enterStatus: '',
|
13
|
+
tabText: '→', tabStatus: '',
|
14
|
+
alphabeticLayout: $.keypad.qwertyAlphabetic,
|
15
|
+
fullLayout: $.keypad.qwertyLayout,
|
16
|
+
isAlphabetic: $.keypad.isAlphabetic,
|
17
|
+
isNumeric: $.keypad.isNumeric,
|
18
|
+
toUpper: $.keypad.toUpper,
|
19
|
+
isRTL: false};
|
20
|
+
$.keypad.setDefaults($.keypad.regional['ca']);
|
21
|
+
})(jQuery);
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* http://keith-wood.name/keypad.html
|
2
|
+
Czech initialisation for the jQuery keypad extension
|
3
|
+
Written by Amadeo Mareš. */
|
4
|
+
(function($) { // hide the namespace
|
5
|
+
$.keypad.regional['cs'] = {
|
6
|
+
buttonText: '...', buttonStatus: 'Otevřít',
|
7
|
+
closeText: 'Zavřít', closeStatus: 'Zavře klávesnici',
|
8
|
+
clearText: 'Vymazat', clearStatus: 'Smaže text',
|
9
|
+
backText: 'Smazat', backStatus: 'Smaže poslední písmeno',
|
10
|
+
shiftText: 'Velikost', shiftStatus: 'Nastaví velká/malá písmena',
|
11
|
+
spacebarText: ' ', spacebarStatus: '',
|
12
|
+
enterText: 'Enter', enterStatus: '',
|
13
|
+
tabText: '→', tabStatus: '',
|
14
|
+
alphabeticLayout: $.keypad.qwertyAlphabetic,
|
15
|
+
fullLayout: $.keypad.qwertyLayout,
|
16
|
+
isAlphabetic: $.keypad.isAlphabetic,
|
17
|
+
isNumeric: $.keypad.isNumeric,
|
18
|
+
toUpper: $.keypad.toUpper,
|
19
|
+
isRTL: false};
|
20
|
+
$.keypad.setDefaults($.keypad.regional['cs']);
|
21
|
+
})(jQuery);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* http://keith-wood.name/keypad.html
|
2
|
-
Keypad field entry extension for jQuery v1.
|
2
|
+
Keypad field entry extension for jQuery v1.5.0.
|
3
3
|
Written by Keith Wood (kbwood{at}iinet.com.au) August 2008.
|
4
4
|
Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
|
5
5
|
MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
|
@@ -7,8 +7,6 @@
|
|
7
7
|
|
8
8
|
(function($) { // hide the namespace
|
9
9
|
|
10
|
-
var PROP_NAME = 'keypad';
|
11
|
-
|
12
10
|
/* Keypad manager.
|
13
11
|
Use the singleton instance of this class, $.keypad, to interact with the plugin.
|
14
12
|
Settings for keypad fields are maintained in instance objects,
|
@@ -20,17 +18,17 @@ function Keypad() {
|
|
20
18
|
this._keyCode = 0;
|
21
19
|
this._specialKeys = [];
|
22
20
|
this.addKeyDef('CLOSE', 'close', function(inst) {
|
23
|
-
|
24
|
-
|
21
|
+
plugin._curInst = (inst._inline ? inst : plugin._curInst);
|
22
|
+
plugin._hidePlugin();
|
25
23
|
});
|
26
|
-
this.addKeyDef('CLEAR', 'clear', function(inst) {
|
27
|
-
this.addKeyDef('BACK', 'back', function(inst) {
|
28
|
-
this.addKeyDef('SHIFT', 'shift', function(inst) {
|
29
|
-
this.addKeyDef('SPACE_BAR', 'spacebar', function(inst) {
|
24
|
+
this.addKeyDef('CLEAR', 'clear', function(inst) { plugin._clearValue(inst); });
|
25
|
+
this.addKeyDef('BACK', 'back', function(inst) { plugin._backValue(inst); });
|
26
|
+
this.addKeyDef('SHIFT', 'shift', function(inst) { plugin._shiftKeypad(inst); });
|
27
|
+
this.addKeyDef('SPACE_BAR', 'spacebar', function(inst) { plugin._selectValue(inst, ' '); }, true);
|
30
28
|
this.addKeyDef('SPACE', 'space');
|
31
29
|
this.addKeyDef('HALF_SPACE', 'half-space');
|
32
|
-
this.addKeyDef('ENTER', 'enter', function(inst) {
|
33
|
-
this.addKeyDef('TAB', 'tab', function(inst) {
|
30
|
+
this.addKeyDef('ENTER', 'enter', function(inst) { plugin._selectValue(inst, '\x0D'); }, true);
|
31
|
+
this.addKeyDef('TAB', 'tab', function(inst) { plugin._selectValue(inst, '\x09'); }, true);
|
34
32
|
// Standard US keyboard alphabetic layout
|
35
33
|
this.qwertyAlphabetic = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'];
|
36
34
|
// Standard US keyboard layout
|
@@ -63,6 +61,7 @@ function Keypad() {
|
|
63
61
|
fullLayout: this.qwertyLayout, // Default layout for full keyboard
|
64
62
|
isAlphabetic: this.isAlphabetic, // Function to determine if character is alphabetic
|
65
63
|
isNumeric: this.isNumeric, // Function to determine if character is numeric
|
64
|
+
toUpper: this.toUpper, // Function to convert characters to upper case
|
66
65
|
isRTL: false // True if right-to-left language, false if left-to-right
|
67
66
|
};
|
68
67
|
this._defaults = { // Global defaults for all the keypad instances
|
@@ -96,20 +95,29 @@ function Keypad() {
|
|
96
95
|
$.extend(Keypad.prototype, {
|
97
96
|
/* Class name added to elements to indicate already configured with keypad. */
|
98
97
|
markerClassName: 'hasKeypad',
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
98
|
+
/* Name of the data property for instance settings. */
|
99
|
+
propertyName: 'keypad',
|
100
|
+
|
101
|
+
_mainDivClass: 'keypad-popup', // The main keypad division class
|
102
|
+
_inlineClass: 'keypad-inline', // The inline marker class
|
103
|
+
_appendClass: 'keypad-append', // The append marker class
|
104
|
+
_triggerClass: 'keypad-trigger', // The trigger marker class
|
105
|
+
_disableClass: 'keypad-disabled', // The disabled covering marker class
|
106
|
+
_inlineEntryClass: 'keypad-keyentry', // The inline entry marker class
|
107
|
+
_coverClass: 'keypad-cover', // The IE select cover marker class
|
108
|
+
_rtlClass: 'keypad-rtl', // The right-to-left marker class
|
109
|
+
_rowClass: 'keypad-row', // The keypad row marker class
|
110
|
+
_promptClass: 'keypad-prompt', // The prompt marker class
|
111
|
+
_specialClass: 'keypad-special', // The special key marker class
|
112
|
+
_namePrefixClass: 'keypad-', // The key name marker class prefix
|
113
|
+
_keyClass: 'keypad-key', // The key marker class
|
114
|
+
_keyDownClass: 'keypad-key-down', // The key down marker class
|
115
|
+
|
116
|
+
/* Override the default settings for all keypad instances.
|
109
117
|
@param settings (object) the new settings to use as defaults
|
110
|
-
@return (
|
118
|
+
@return (Keypad) this object */
|
111
119
|
setDefaults: function(settings) {
|
112
|
-
|
120
|
+
$.extend(this._defaults, settings || {});
|
113
121
|
return this;
|
114
122
|
},
|
115
123
|
|
@@ -120,7 +128,7 @@ $.extend(Keypad.prototype, {
|
|
120
128
|
@param action (function) the action performed for this key -
|
121
129
|
receives inst as a parameter
|
122
130
|
@param noHighlight (boolean) true to suppress highlight when using ThemeRoller
|
123
|
-
@return (
|
131
|
+
@return (Keypad) this object */
|
124
132
|
addKeyDef: function(id, name, action, noHighlight) {
|
125
133
|
if (this._keyCode == 32) {
|
126
134
|
throw 'Only 32 special keys allowed';
|
@@ -132,24 +140,26 @@ $.extend(Keypad.prototype, {
|
|
132
140
|
},
|
133
141
|
|
134
142
|
/* Attach the keypad to a jQuery selection.
|
135
|
-
@param target
|
136
|
-
@param
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
inst
|
143
|
+
@param target (element) the control to affect
|
144
|
+
@param options (object) the custom options for this instance */
|
145
|
+
_attachPlugin: function(target, options) {
|
146
|
+
target = $(target);
|
147
|
+
if (target.hasClass(this.markerClassName)) {
|
148
|
+
return;
|
149
|
+
}
|
150
|
+
var inline = !target[0].nodeName.toLowerCase().match(/input|textarea/);
|
151
|
+
var inst = {options: $.extend({}, this._defaults, options), _inline: inline,
|
152
|
+
_mainDiv: (inline ? $('<div class="' + this._inlineClass + '"></div>') : plugin.mainDiv),
|
153
|
+
ucase: false};
|
144
154
|
this._setInput(target, inst);
|
145
155
|
this._connectKeypad(target, inst);
|
146
156
|
if (inline) {
|
147
|
-
|
148
|
-
bind('click.
|
157
|
+
target.append(inst._mainDiv).
|
158
|
+
bind('click.' + this.propertyName, function() { inst._input.focus(); });
|
149
159
|
this._updateKeypad(inst);
|
150
160
|
}
|
151
|
-
else if (
|
152
|
-
this.
|
161
|
+
else if (target.is(':disabled')) {
|
162
|
+
this._disablePlugin(target);
|
153
163
|
}
|
154
164
|
},
|
155
165
|
|
@@ -157,132 +167,161 @@ $.extend(Keypad.prototype, {
|
|
157
167
|
@param target (jQuery) the target control
|
158
168
|
@param inst (object) the instance settings */
|
159
169
|
_setInput: function(target, inst) {
|
160
|
-
inst._input = $(!inst._inline ? target :
|
170
|
+
inst._input = $(!inst._inline ? target : inst.options.target ||
|
161
171
|
'<input type="text" class="' + this._inlineEntryClass + '" disabled="disabled"/>');
|
162
172
|
if (inst._inline) {
|
163
|
-
target = $(target);
|
164
173
|
target.find('input').remove();
|
165
|
-
if (!
|
174
|
+
if (!inst.options.target) {
|
166
175
|
target.append(inst._input);
|
167
176
|
}
|
168
177
|
}
|
169
178
|
},
|
170
179
|
|
171
180
|
/* Attach the keypad to a text field.
|
172
|
-
@param target (
|
181
|
+
@param target (jQuery) the target text field
|
173
182
|
@param inst (object) the instance settings */
|
174
183
|
_connectKeypad: function(target, inst) {
|
175
|
-
|
176
|
-
|
177
|
-
return;
|
178
|
-
}
|
179
|
-
var appendText = this._get(inst, 'appendText');
|
180
|
-
var isRTL = this._get(inst, 'isRTL');
|
184
|
+
target = $(target);
|
185
|
+
var appendText = inst.options.appendText;
|
181
186
|
if (appendText) {
|
182
|
-
|
187
|
+
target[inst.options.isRTL ? 'before' : 'after'](
|
183
188
|
'<span class="' + this._appendClass + '">' + appendText + '</span>');
|
184
189
|
}
|
185
190
|
if (!inst._inline) {
|
186
|
-
|
187
|
-
|
188
|
-
|
191
|
+
if (inst.options.showOn == 'focus' || inst.options.showOn == 'both') {
|
192
|
+
// pop-up keypad when in the marked field
|
193
|
+
target.bind('focus.' + this.propertyName, this._showPlugin).
|
194
|
+
bind('keydown.' + this.propertyName, this._doKeyDown);
|
189
195
|
}
|
190
|
-
if (showOn == 'button' || showOn == 'both') {
|
191
|
-
|
192
|
-
var buttonStatus =
|
193
|
-
var buttonImage =
|
194
|
-
var trigger = $(
|
196
|
+
if (inst.options.showOn == 'button' || inst.options.showOn == 'both') {
|
197
|
+
// pop-up keypad when button clicked
|
198
|
+
var buttonStatus = inst.options.buttonStatus;
|
199
|
+
var buttonImage = inst.options.buttonImage;
|
200
|
+
var trigger = $(inst.options.buttonImageOnly ?
|
195
201
|
$('<img src="' + buttonImage + '" alt="' +
|
196
202
|
buttonStatus + '" title="' + buttonStatus + '"/>') :
|
197
203
|
$('<button type="button" title="' + buttonStatus + '"></button>').
|
198
|
-
html(buttonImage == '' ? buttonText :
|
204
|
+
html(buttonImage == '' ? inst.options.buttonText :
|
199
205
|
$('<img src="' + buttonImage + '" alt="' +
|
200
206
|
buttonStatus + '" title="' + buttonStatus + '"/>')));
|
201
|
-
|
207
|
+
target[inst.options.isRTL ? 'before' : 'after'](trigger);
|
202
208
|
trigger.addClass(this._triggerClass).click(function() {
|
203
|
-
if (
|
204
|
-
|
209
|
+
if (plugin._keypadShowing && plugin._lastField == target[0]) {
|
210
|
+
plugin._hidePlugin();
|
205
211
|
}
|
206
212
|
else {
|
207
|
-
|
213
|
+
plugin._showPlugin(target[0]);
|
208
214
|
}
|
209
215
|
return false;
|
210
216
|
});
|
211
217
|
}
|
212
218
|
}
|
213
|
-
inst.saveReadonly =
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
219
|
+
inst.saveReadonly = target.attr('readonly');
|
220
|
+
target.addClass(this.markerClassName).
|
221
|
+
data(this.propertyName, inst)
|
222
|
+
[inst.options.keypadOnly ? 'attr' : 'removeAttr']('readonly', true).
|
223
|
+
bind('setData.' + this.propertyName, function(event, key, value) {
|
224
|
+
inst.options[key] = value;
|
225
|
+
}).bind('getData.' + this.propertyName, function(event, key) {
|
226
|
+
return inst.options[key];
|
220
227
|
});
|
221
|
-
|
228
|
+
},
|
229
|
+
|
230
|
+
/* Retrieve or reconfigure the settings for a control.
|
231
|
+
@param target (element) the control to affect
|
232
|
+
@param options (object) the new options for this instance or
|
233
|
+
(string) an individual property name
|
234
|
+
@param value (any) the individual property value (omit if options
|
235
|
+
is an object or to retrieve the value of a setting)
|
236
|
+
@return (any) if retrieving a value */
|
237
|
+
_optionPlugin: function(target, options, value) {
|
238
|
+
target = $(target);
|
239
|
+
var inst = target.data(this.propertyName);
|
240
|
+
if (!options || (typeof options == 'string' && value == null)) { // Get option
|
241
|
+
var name = options;
|
242
|
+
options = (inst || {}).options;
|
243
|
+
return (options && name ? options[name] : options);
|
244
|
+
}
|
245
|
+
|
246
|
+
if (!target.hasClass(this.markerClassName)) {
|
247
|
+
return;
|
248
|
+
}
|
249
|
+
options = options || {};
|
250
|
+
if (typeof options == 'string') {
|
251
|
+
var name = options;
|
252
|
+
options = {};
|
253
|
+
options[name] = value;
|
254
|
+
}
|
255
|
+
if (this._curInst == inst) {
|
256
|
+
this._hidePlugin();
|
257
|
+
}
|
258
|
+
$.extend(inst.options, options);
|
259
|
+
this._setInput(target, inst);
|
260
|
+
this._updateKeypad(inst);
|
222
261
|
},
|
223
262
|
|
224
263
|
/* Detach keypad from its control.
|
225
264
|
@param target (element) the target text field */
|
226
|
-
|
227
|
-
|
228
|
-
if (
|
265
|
+
_destroyPlugin: function(target) {
|
266
|
+
target = $(target);
|
267
|
+
if (!target.hasClass(this.markerClassName)) {
|
229
268
|
return;
|
230
269
|
}
|
231
|
-
var inst =
|
270
|
+
var inst = target.data(this.propertyName);
|
232
271
|
if (this._curInst == inst) {
|
233
|
-
this.
|
272
|
+
this._hidePlugin();
|
234
273
|
}
|
235
|
-
|
274
|
+
target.siblings('.' + this._appendClass).remove().end().
|
236
275
|
siblings('.' + this._triggerClass).remove().end().
|
237
276
|
prev('.' + this._inlineEntryClass).remove();
|
238
|
-
|
239
|
-
|
277
|
+
target.removeClass(this.markerClassName).empty().
|
278
|
+
unbind('.' + this.propertyName).
|
279
|
+
removeData(this.propertyName)
|
240
280
|
[inst.saveReadonly ? 'attr' : 'removeAttr']('readonly', true);
|
241
|
-
|
242
|
-
$.removeData(target, PROP_NAME);
|
281
|
+
inst._input.removeData(this.propertyName);
|
243
282
|
},
|
244
283
|
|
245
284
|
/* Enable the keypad for a jQuery selection.
|
246
285
|
@param target (element) the target text field */
|
247
|
-
|
248
|
-
|
249
|
-
if (!
|
286
|
+
_enablePlugin: function(target) {
|
287
|
+
target = $(target);
|
288
|
+
if (!target.hasClass(this.markerClassName)) {
|
250
289
|
return;
|
251
290
|
}
|
252
|
-
var nodeName = target.nodeName.toLowerCase();
|
253
|
-
if (nodeName
|
254
|
-
target.disabled = false;
|
255
|
-
|
291
|
+
var nodeName = target[0].nodeName.toLowerCase();
|
292
|
+
if (nodeName.match(/input|textarea/)) {
|
293
|
+
target[0].disabled = false;
|
294
|
+
target.siblings('button.' + this._triggerClass).
|
256
295
|
each(function() { this.disabled = false; }).end().
|
257
296
|
siblings('img.' + this._triggerClass).
|
258
297
|
css({opacity: '1.0', cursor: ''});
|
259
298
|
}
|
260
|
-
else if (nodeName
|
261
|
-
|
262
|
-
var inst =
|
263
|
-
inst._mainDiv.find('button').
|
299
|
+
else if (nodeName.match(/div|span/)) {
|
300
|
+
target.children('.' + this._disableClass).remove();
|
301
|
+
var inst = target.data(this.propertyName);
|
302
|
+
inst._mainDiv.find('button').removeAttr('disabled');
|
264
303
|
}
|
265
304
|
this._disabledFields = $.map(this._disabledFields,
|
266
|
-
function(value) { return (value == target ? null : value); }); // delete entry
|
305
|
+
function(value) { return (value == target[0] ? null : value); }); // delete entry
|
267
306
|
},
|
268
307
|
|
269
308
|
/* Disable the keypad for a jQuery selection.
|
270
309
|
@param target (element) the target text field */
|
271
|
-
|
272
|
-
|
273
|
-
if (!
|
310
|
+
_disablePlugin: function(target) {
|
311
|
+
target = $(target);
|
312
|
+
if (!target.hasClass(this.markerClassName)) {
|
274
313
|
return;
|
275
314
|
}
|
276
|
-
var nodeName = target.nodeName.toLowerCase();
|
277
|
-
if (nodeName
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
315
|
+
var nodeName = target[0].nodeName.toLowerCase();
|
316
|
+
if (nodeName.match(/input|textarea/)) {
|
317
|
+
target[0].disabled = true;
|
318
|
+
target.siblings('button.' + this._triggerClass).
|
319
|
+
each(function() { this.disabled = true; }).end().
|
320
|
+
siblings('img.' + this._triggerClass).
|
321
|
+
css({opacity: '0.5', cursor: 'default'});
|
283
322
|
}
|
284
|
-
else if (nodeName
|
285
|
-
var inline =
|
323
|
+
else if (nodeName.match(/div|span/)) {
|
324
|
+
var inline = target.children('.' + this._inlineClass);
|
286
325
|
var offset = inline.offset();
|
287
326
|
var relOffset = {left: 0, top: 0};
|
288
327
|
inline.parents().each(function() {
|
@@ -291,91 +330,69 @@ $.extend(Keypad.prototype, {
|
|
291
330
|
return false;
|
292
331
|
}
|
293
332
|
});
|
294
|
-
|
333
|
+
target.prepend('<div class="' + this._disableClass + '" style="width: ' +
|
295
334
|
inline.outerWidth() + 'px; height: ' + inline.outerHeight() +
|
296
335
|
'px; left: ' + (offset.left - relOffset.left) +
|
297
336
|
'px; top: ' + (offset.top - relOffset.top) + 'px;"></div>');
|
298
|
-
var inst =
|
337
|
+
var inst = target.data(this.propertyName);
|
299
338
|
inst._mainDiv.find('button').attr('disabled', 'disabled');
|
300
339
|
}
|
301
340
|
this._disabledFields = $.map(this._disabledFields,
|
302
|
-
function(value) { return (value == target ? null : value); }); // delete entry
|
303
|
-
this._disabledFields[this._disabledFields.length] = target;
|
341
|
+
function(value) { return (value == target[0] ? null : value); }); // delete entry
|
342
|
+
this._disabledFields[this._disabledFields.length] = target[0];
|
304
343
|
},
|
305
344
|
|
306
345
|
/* Is the text field disabled as a keypad?
|
307
346
|
@param target (element) the target text field
|
308
347
|
@return (boolean) true if disabled, false if enabled */
|
309
|
-
|
348
|
+
_isDisabledPlugin: function(target) {
|
310
349
|
return (target && $.inArray(target, this._disabledFields) > -1);
|
311
350
|
},
|
312
351
|
|
313
|
-
/* Update the settings for keypad attached to a text field
|
314
|
-
@param target (element) the target text field
|
315
|
-
@param name (object) the new settings to update or
|
316
|
-
(string) the name of the setting to change
|
317
|
-
@param value (any) the new value for the setting (omit if above is an object) */
|
318
|
-
_changeKeypad: function(target, name, value) {
|
319
|
-
var settings = name || {};
|
320
|
-
if (typeof name == 'string') {
|
321
|
-
settings = {};
|
322
|
-
settings[name] = value;
|
323
|
-
}
|
324
|
-
var inst = $.data(target, PROP_NAME);
|
325
|
-
if (inst) {
|
326
|
-
if (this._curInst == inst) {
|
327
|
-
this._hideKeypad();
|
328
|
-
}
|
329
|
-
extendRemove(inst.settings, settings);
|
330
|
-
this._setInput($(target), inst);
|
331
|
-
this._updateKeypad(inst);
|
332
|
-
}
|
333
|
-
},
|
334
|
-
|
335
352
|
/* Pop-up the keypad for a given text field.
|
336
353
|
@param field (element) the text field attached to the keypad or
|
337
354
|
(event) if triggered by focus */
|
338
|
-
|
355
|
+
_showPlugin: function(field) {
|
339
356
|
field = field.target || field;
|
340
|
-
if (
|
341
|
-
|
357
|
+
if (plugin._isDisabledPlugin(field) ||
|
358
|
+
plugin._lastField == field) { // already here
|
342
359
|
return;
|
343
360
|
}
|
344
|
-
var inst = $.data(field,
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
361
|
+
var inst = $.data(field, plugin.propertyName);
|
362
|
+
plugin._hidePlugin(null, '');
|
363
|
+
plugin._lastField = field;
|
364
|
+
plugin._pos = plugin._findPos(field);
|
365
|
+
plugin._pos[1] += field.offsetHeight; // add the height
|
349
366
|
var isFixed = false;
|
350
367
|
$(field).parents().each(function() {
|
351
368
|
isFixed |= $(this).css('position') == 'fixed';
|
352
369
|
return !isFixed;
|
353
370
|
});
|
354
371
|
if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
|
355
|
-
|
356
|
-
|
372
|
+
plugin._pos[0] -= document.documentElement.scrollLeft;
|
373
|
+
plugin._pos[1] -= document.documentElement.scrollTop;
|
357
374
|
}
|
358
|
-
var offset = {left:
|
359
|
-
|
375
|
+
var offset = {left: plugin._pos[0], top: plugin._pos[1]};
|
376
|
+
plugin._pos = null;
|
360
377
|
// determine sizing offscreen
|
361
378
|
inst._mainDiv.css({position: 'absolute', display: 'block', top: '-1000px',
|
362
379
|
width: ($.browser.opera ? '1000px' : 'auto')});
|
363
|
-
|
380
|
+
plugin._updateKeypad(inst);
|
364
381
|
// and adjust position before showing
|
365
|
-
offset =
|
382
|
+
offset = plugin._checkOffset(inst, offset, isFixed);
|
366
383
|
inst._mainDiv.css({position: (isFixed ? 'fixed' : 'absolute'), display: 'none',
|
367
384
|
left: offset.left + 'px', top: offset.top + 'px'});
|
368
|
-
var
|
369
|
-
var duration = $.keypad._get(inst, 'duration');
|
385
|
+
var duration = inst.options.duration;
|
370
386
|
duration = (duration == 'normal' && $.ui && $.ui.version >= '1.8' ? '_default' : duration);
|
387
|
+
var showAnim = inst.options.showAnim;
|
371
388
|
var postProcess = function() {
|
372
|
-
|
373
|
-
var borders =
|
374
|
-
inst._mainDiv.find('iframe.' +
|
389
|
+
plugin._keypadShowing = true;
|
390
|
+
var borders = plugin._getBorders(inst._mainDiv);
|
391
|
+
inst._mainDiv.find('iframe.' + plugin._coverClass). // IE6- only
|
375
392
|
css({left: -borders[0], top: -borders[1],
|
376
393
|
width: inst._mainDiv.outerWidth(), height: inst._mainDiv.outerHeight()});
|
377
394
|
};
|
378
|
-
if ($.effects && $.effects[showAnim]) {
|
395
|
+
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
|
379
396
|
var data = inst._mainDiv.data(); // Update old effects data
|
380
397
|
for (var key in data) {
|
381
398
|
if (key.match(/^ec\.storage\./)) {
|
@@ -383,7 +400,7 @@ $.extend(Keypad.prototype, {
|
|
383
400
|
}
|
384
401
|
}
|
385
402
|
inst._mainDiv.data(data).show(showAnim,
|
386
|
-
|
403
|
+
inst.options.showOptions, duration, postProcess);
|
387
404
|
}
|
388
405
|
else {
|
389
406
|
inst._mainDiv[showAnim || 'show']((showAnim ? duration : ''), postProcess);
|
@@ -394,7 +411,7 @@ $.extend(Keypad.prototype, {
|
|
394
411
|
if (inst._input[0].type != 'hidden') {
|
395
412
|
inst._input[0].focus();
|
396
413
|
}
|
397
|
-
|
414
|
+
plugin._curInst = inst;
|
398
415
|
},
|
399
416
|
|
400
417
|
/* Generate the keypad content.
|
@@ -405,13 +422,12 @@ $.extend(Keypad.prototype, {
|
|
405
422
|
find('iframe.' + this._coverClass). // IE6- only
|
406
423
|
css({left: -borders[0], top: -borders[1],
|
407
424
|
width: inst._mainDiv.outerWidth(), height: inst._mainDiv.outerHeight()});
|
408
|
-
inst._mainDiv.removeClass().addClass(
|
409
|
-
(
|
410
|
-
(
|
425
|
+
inst._mainDiv.removeClass().addClass(inst.options.keypadClass +
|
426
|
+
(inst.options.useThemeRoller ? ' ui-widget ui-widget-content' : '') +
|
427
|
+
(inst.options.isRTL ? ' ' + this._rtlClass : '') + ' ' +
|
411
428
|
(inst._inline ? this._inlineClass : this._mainDivClass));
|
412
|
-
|
413
|
-
|
414
|
-
beforeShow.apply((inst._input ? inst._input[0] : null),
|
429
|
+
if ($.isFunction(inst.options.beforeShow)) {
|
430
|
+
inst.options.beforeShow.apply((inst._input ? inst._input[0] : null),
|
415
431
|
[inst._mainDiv, inst]);
|
416
432
|
}
|
417
433
|
},
|
@@ -449,7 +465,7 @@ $.extend(Keypad.prototype, {
|
|
449
465
|
inst._mainDiv.css('width', width);
|
450
466
|
}
|
451
467
|
// reposition keypad panel horizontally if outside the browser window
|
452
|
-
if (
|
468
|
+
if (inst.options.isRTL ||
|
453
469
|
(offset.left + inst._mainDiv.outerWidth() - scrollX) > browserWidth) {
|
454
470
|
offset.left = Math.max((isFixed ? 0 : scrollX),
|
455
471
|
pos[0] + (inst._input ? inst._input.outerWidth() : 0) -
|
@@ -485,36 +501,34 @@ $.extend(Keypad.prototype, {
|
|
485
501
|
/* Hide the keypad from view.
|
486
502
|
@param field (element) the text field attached to the keypad
|
487
503
|
@param duration (string) the duration over which to close the keypad */
|
488
|
-
|
504
|
+
_hidePlugin: function(field, duration) {
|
489
505
|
var inst = this._curInst;
|
490
|
-
if (!inst || (field && inst != $.data(field,
|
506
|
+
if (!inst || (field && inst != $.data(field, this.propertyName))) {
|
491
507
|
return;
|
492
508
|
}
|
493
509
|
if (this._keypadShowing) {
|
494
|
-
duration = (duration != null ? duration :
|
510
|
+
duration = (duration != null ? duration : inst.options.duration);
|
495
511
|
duration = (duration == 'normal' && $.ui && $.ui.version >= '1.8' ? '_default' : duration);
|
496
|
-
var showAnim =
|
497
|
-
if ($.effects && $.effects[showAnim]) {
|
498
|
-
inst._mainDiv.hide(showAnim,
|
512
|
+
var showAnim = inst.options.showAnim;
|
513
|
+
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
|
514
|
+
inst._mainDiv.hide(showAnim, inst.options.showOptions, duration);
|
499
515
|
}
|
500
516
|
else {
|
501
517
|
inst._mainDiv[(showAnim == 'slideDown' ? 'slideUp' :
|
502
518
|
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))](showAnim ? duration : '');
|
503
519
|
}
|
504
520
|
}
|
505
|
-
|
506
|
-
|
507
|
-
onClose.apply((inst._input ? inst._input[0] : null), // trigger custom callback
|
521
|
+
if ($.isFunction(inst.options.onClose)) {
|
522
|
+
inst.options.onClose.apply((inst._input ? inst._input[0] : null), // trigger custom callback
|
508
523
|
[inst._input.val(), inst]);
|
509
524
|
}
|
510
525
|
if (this._keypadShowing) {
|
511
526
|
this._keypadShowing = false;
|
512
527
|
this._lastField = null;
|
513
528
|
}
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
// }
|
529
|
+
if (inst._inline) {
|
530
|
+
inst._input.val('');
|
531
|
+
}
|
518
532
|
this._curInst = null;
|
519
533
|
},
|
520
534
|
|
@@ -522,23 +536,23 @@ $.extend(Keypad.prototype, {
|
|
522
536
|
@param e (event) the key event */
|
523
537
|
_doKeyDown: function(e) {
|
524
538
|
if (e.keyCode == 9) { // Tab out
|
525
|
-
|
526
|
-
|
539
|
+
plugin.mainDiv.stop(true, true);
|
540
|
+
plugin._hidePlugin();
|
527
541
|
}
|
528
542
|
},
|
529
543
|
|
530
544
|
/* Close keypad if clicked elsewhere.
|
531
545
|
@param event (event) the mouseclick details */
|
532
546
|
_checkExternalClick: function(event) {
|
533
|
-
if (
|
547
|
+
if (!plugin._curInst) {
|
534
548
|
return;
|
535
549
|
}
|
536
550
|
var target = $(event.target);
|
537
|
-
if (!target.parents().andSelf().
|
538
|
-
!target.hasClass(
|
539
|
-
!target.parents().andSelf().hasClass(
|
540
|
-
|
541
|
-
|
551
|
+
if (!target.parents().andSelf().hasClass(plugin._mainDivClass) &&
|
552
|
+
!target.hasClass(plugin.markerClassName) &&
|
553
|
+
!target.parents().andSelf().hasClass(plugin._triggerClass) &&
|
554
|
+
plugin._keypadShowing) {
|
555
|
+
plugin._hidePlugin();
|
542
556
|
}
|
543
557
|
},
|
544
558
|
|
@@ -554,7 +568,7 @@ $.extend(Keypad.prototype, {
|
|
554
568
|
@param inst (object) the instance settings */
|
555
569
|
_clearValue: function(inst) {
|
556
570
|
this._setValue(inst, '', 0);
|
557
|
-
this._notifyKeypress(inst,
|
571
|
+
this._notifyKeypress(inst, plugin.DEL);
|
558
572
|
},
|
559
573
|
|
560
574
|
/* Erase the last character.
|
@@ -573,7 +587,7 @@ $.extend(Keypad.prototype, {
|
|
573
587
|
}
|
574
588
|
this._setValue(inst, (value.length == 0 ? '' :
|
575
589
|
value.substr(0, range[0] - 1) + value.substr(range[1])), range[0] - 1);
|
576
|
-
this._notifyKeypress(inst,
|
590
|
+
this._notifyKeypress(inst, plugin.BS);
|
577
591
|
},
|
578
592
|
|
579
593
|
/* Update the text field with the selected value.
|
@@ -678,58 +692,46 @@ $.extend(Keypad.prototype, {
|
|
678
692
|
value = value.substr(0, maxlen);
|
679
693
|
}
|
680
694
|
inst._input.val(value);
|
681
|
-
if (
|
695
|
+
if (!$.isFunction(inst.options.onKeypress)) {
|
682
696
|
inst._input.trigger('change'); // fire the change event
|
683
697
|
}
|
684
698
|
},
|
685
699
|
|
686
700
|
_notifyKeypress: function(inst, key) {
|
687
|
-
|
688
|
-
|
689
|
-
onKeypress.apply((inst._input ? inst._input[0] : null),
|
701
|
+
if ($.isFunction(inst.options.onKeypress)) { // trigger custom callback
|
702
|
+
inst.options.onKeypress.apply((inst._input ? inst._input[0] : null),
|
690
703
|
[key, inst._input.val(), inst]);
|
691
704
|
}
|
692
705
|
},
|
693
706
|
|
694
|
-
/* Get a setting value, defaulting if necessary.
|
695
|
-
@param inst (object) the instance settings
|
696
|
-
@param name (string) the name of the setting
|
697
|
-
@return (any) the value of the setting, or its default if not set explicitly */
|
698
|
-
_get: function(inst, name) {
|
699
|
-
return inst.settings[name] !== undefined ?
|
700
|
-
inst.settings[name] : this._defaults[name];
|
701
|
-
},
|
702
|
-
|
703
707
|
/* Generate the HTML for the current state of the keypad.
|
704
708
|
@param inst (object) the instance settings
|
705
709
|
@return (jQuery) the HTML for this keypad */
|
706
710
|
_generateHTML: function(inst) {
|
707
|
-
var
|
708
|
-
|
709
|
-
|
710
|
-
var separator = this._get(inst, 'separator');
|
711
|
-
var html = (!prompt ? '' : '<div class="keypad-prompt' +
|
712
|
-
(useTR ? ' ui-widget-header ui-corner-all' : '') + '">' + prompt + '</div>');
|
711
|
+
var html = (!inst.options.prompt ? '' : '<div class="' + this._promptClass +
|
712
|
+
(inst.options.useThemeRoller ? ' ui-widget-header ui-corner-all' : '') + '">' +
|
713
|
+
inst.options.prompt + '</div>');
|
713
714
|
var layout = this._randomiseLayout(inst);
|
714
715
|
for (var i = 0; i < layout.length; i++) {
|
715
|
-
html += '<div class="
|
716
|
-
var keys = layout[i].split(separator);
|
716
|
+
html += '<div class="' + this._rowClass + '">';
|
717
|
+
var keys = layout[i].split(inst.options.separator);
|
717
718
|
for (var j = 0; j < keys.length; j++) {
|
718
719
|
if (inst.ucase) {
|
719
|
-
keys[j] = keys[j]
|
720
|
+
keys[j] = inst.options.toUpper(keys[j]);
|
720
721
|
}
|
721
722
|
var keyDef = this._specialKeys[keys[j].charCodeAt(0)];
|
722
723
|
if (keyDef) {
|
723
|
-
html += (keyDef.action ? '<button type="button" class="
|
724
|
-
|
724
|
+
html += (keyDef.action ? '<button type="button" class="' + this._specialClass +
|
725
|
+
' ' + this._namePrefixClass + keyDef.name +
|
726
|
+
(inst.options.useThemeRoller ? ' ui-corner-all ui-state-default' +
|
725
727
|
(keyDef.noHighlight ? '' : ' ui-state-highlight') : '') +
|
726
|
-
'" title="' +
|
727
|
-
(
|
728
|
-
'<div class="
|
728
|
+
'" title="' + inst.options[keyDef.name + 'Status'] + '">' +
|
729
|
+
(inst.options[keyDef.name + 'Text'] || ' ') + '</button>' :
|
730
|
+
'<div class="' + this._namePrefixClass + keyDef.name + '"></div>');
|
729
731
|
}
|
730
732
|
else {
|
731
|
-
html += '<button type="button" ' +
|
732
|
-
|
733
|
+
html += '<button type="button" class="' + this._keyClass +
|
734
|
+
(inst.options.useThemeRoller ? ' ui-corner-all ui-state-default' : '') + '">' +
|
733
735
|
(keys[j] == ' ' ? ' ' : keys[j]) + '</button>';
|
734
736
|
}
|
735
737
|
}
|
@@ -737,16 +739,16 @@ $.extend(Keypad.prototype, {
|
|
737
739
|
}
|
738
740
|
html += '<div style="clear: both;"></div>' +
|
739
741
|
(!inst._inline && $.browser.msie && parseInt($.browser.version, 10) < 7 ?
|
740
|
-
'<iframe src="javascript:false;" class="' +
|
742
|
+
'<iframe src="javascript:false;" class="' + plugin._coverClass + '"></iframe>' : '');
|
741
743
|
html = $(html);
|
742
744
|
var thisInst = inst;
|
743
|
-
var activeClasses =
|
745
|
+
var activeClasses = this._keyDownClass + (inst.options.useThemeRoller ? ' ui-state-active' : '');
|
744
746
|
html.find('button').mousedown(function() { $(this).addClass(activeClasses); }).
|
745
747
|
mouseup(function() { $(this).removeClass(activeClasses); }).
|
746
748
|
mouseout(function() { $(this).removeClass(activeClasses); }).
|
747
|
-
filter('.
|
749
|
+
filter('.' + this._keyClass).click(function() { plugin._selectValue(thisInst, $(this).text()); });
|
748
750
|
$.each(this._specialKeys, function(i, keyDef) {
|
749
|
-
html.find('.
|
751
|
+
html.find('.' + plugin._namePrefixClass + keyDef.name).click(function() {
|
750
752
|
keyDef.action.apply(thisInst._input, [thisInst]);
|
751
753
|
});
|
752
754
|
});
|
@@ -758,36 +760,29 @@ $.extend(Keypad.prototype, {
|
|
758
760
|
@param inst (object) the instance settings
|
759
761
|
@return (string[]) the layout with any requested randomisations applied */
|
760
762
|
_randomiseLayout: function(inst) {
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
var layout = this._get(inst, 'layout');
|
766
|
-
if (!randomiseNumeric && !randomiseAlpha && !randomiseOther && !randomiseAll) {
|
767
|
-
return layout;
|
768
|
-
}
|
769
|
-
var isNumeric = this._get(inst, 'isNumeric');
|
770
|
-
var isAlphabetic = this._get(inst, 'isAlphabetic');
|
771
|
-
var separator = this._get(inst, 'separator');
|
763
|
+
if (!inst.options.randomiseNumeric && !inst.options.randomiseAlphabetic &&
|
764
|
+
!inst.options.randomiseOther && !inst.options.randomiseAll) {
|
765
|
+
return inst.options.layout;
|
766
|
+
}
|
772
767
|
var numerics = [];
|
773
768
|
var alphas = [];
|
774
769
|
var others = [];
|
775
770
|
var newLayout = [];
|
776
771
|
// Find characters of different types
|
777
|
-
for (var i = 0; i < layout.length; i++) {
|
772
|
+
for (var i = 0; i < inst.options.layout.length; i++) {
|
778
773
|
newLayout[i] = '';
|
779
|
-
var keys = layout[i].split(separator);
|
774
|
+
var keys = inst.options.layout[i].split(inst.options.separator);
|
780
775
|
for (var j = 0; j < keys.length; j++) {
|
781
776
|
if (this._isControl(keys[j])) {
|
782
777
|
continue;
|
783
778
|
}
|
784
|
-
if (randomiseAll) {
|
779
|
+
if (inst.options.randomiseAll) {
|
785
780
|
others.push(keys[j]);
|
786
781
|
}
|
787
|
-
else if (isNumeric(keys[j])) {
|
782
|
+
else if (inst.options.isNumeric(keys[j])) {
|
788
783
|
numerics.push(keys[j]);
|
789
784
|
}
|
790
|
-
else if (isAlphabetic(keys[j])) {
|
785
|
+
else if (inst.options.isAlphabetic(keys[j])) {
|
791
786
|
alphas.push(keys[j]);
|
792
787
|
}
|
793
788
|
else {
|
@@ -796,27 +791,27 @@ $.extend(Keypad.prototype, {
|
|
796
791
|
}
|
797
792
|
}
|
798
793
|
// Shuffle them
|
799
|
-
if (randomiseNumeric) {
|
794
|
+
if (inst.options.randomiseNumeric) {
|
800
795
|
this._shuffle(numerics);
|
801
796
|
}
|
802
|
-
if (
|
797
|
+
if (inst.options.randomiseAlphabetic) {
|
803
798
|
this._shuffle(alphas);
|
804
799
|
}
|
805
|
-
if (randomiseOther || randomiseAll) {
|
800
|
+
if (inst.options.randomiseOther || inst.options.randomiseAll) {
|
806
801
|
this._shuffle(others);
|
807
802
|
}
|
808
803
|
var n = 0;
|
809
804
|
var a = 0;
|
810
805
|
var o = 0;
|
811
806
|
// And replace them in the layout
|
812
|
-
for (var i = 0; i < layout.length; i++) {
|
813
|
-
var keys = layout[i].split(separator);
|
807
|
+
for (var i = 0; i < inst.options.layout.length; i++) {
|
808
|
+
var keys = inst.options.layout[i].split(inst.options.separator);
|
814
809
|
for (var j = 0; j < keys.length; j++) {
|
815
810
|
newLayout[i] += (this._isControl(keys[j]) ? keys[j] :
|
816
|
-
(randomiseAll ? others[o++] :
|
817
|
-
(isNumeric(keys[j]) ? numerics[n++] :
|
818
|
-
(isAlphabetic(keys[j]) ? alphas[a++] :
|
819
|
-
others[o++])))) + separator;
|
811
|
+
(inst.options.randomiseAll ? others[o++] :
|
812
|
+
(inst.options.isNumeric(keys[j]) ? numerics[n++] :
|
813
|
+
(inst.options.isAlphabetic(keys[j]) ? alphas[a++] :
|
814
|
+
others[o++])))) + inst.options.separator;
|
820
815
|
}
|
821
816
|
}
|
822
817
|
return newLayout;
|
@@ -843,6 +838,12 @@ $.extend(Keypad.prototype, {
|
|
843
838
|
return (ch >= '0' && ch <= '9');
|
844
839
|
},
|
845
840
|
|
841
|
+
/* Convert a character to upper case.
|
842
|
+
@param ch (char) the character to convert
|
843
|
+
@return (char) its uppercase version */
|
844
|
+
toUpper: function(ch) {
|
845
|
+
return ch.toUpperCase();
|
846
|
+
},
|
846
847
|
/* Randomise the contents of an array.
|
847
848
|
@param values (string[]) the array to rearrange */
|
848
849
|
_shuffle: function(values) {
|
@@ -855,44 +856,51 @@ $.extend(Keypad.prototype, {
|
|
855
856
|
}
|
856
857
|
});
|
857
858
|
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
859
|
+
// The list of commands that return values and don't permit chaining
|
860
|
+
var getters = ['isDisabled'];
|
861
|
+
|
862
|
+
/* Determine whether a command is a getter and doesn't permit chaining.
|
863
|
+
@param command (string, optional) the command to run
|
864
|
+
@param otherArgs ([], optional) any other arguments for the command
|
865
|
+
@return true if the command is a getter, false if not */
|
866
|
+
function isNotChained(command, otherArgs) {
|
867
|
+
if (command == 'option' && (otherArgs.length == 0 ||
|
868
|
+
(otherArgs.length == 1 && typeof otherArgs[0] == 'string'))) {
|
869
|
+
return true;
|
868
870
|
}
|
869
|
-
return
|
870
|
-
}
|
871
|
+
return $.inArray(command, getters) > -1;
|
872
|
+
}
|
871
873
|
|
872
874
|
/* Invoke the keypad functionality.
|
873
|
-
@param options (
|
874
|
-
(
|
875
|
-
@return (
|
875
|
+
@param options (object) the new settings to use for these instances (optional) or
|
876
|
+
(string) the command to run (optional)
|
877
|
+
@return (jQuery) for chaining further calls or
|
878
|
+
(any) getter value */
|
876
879
|
$.fn.keypad = function(options) {
|
877
880
|
var otherArgs = Array.prototype.slice.call(arguments, 1);
|
878
|
-
if (options
|
879
|
-
return
|
880
|
-
apply($.keypad, [this[0]].concat(otherArgs));
|
881
|
+
if (isNotChained(options, otherArgs)) {
|
882
|
+
return plugin['_' + options + 'Plugin'].apply(plugin, [this[0]].concat(otherArgs));
|
881
883
|
}
|
882
884
|
return this.each(function() {
|
883
|
-
typeof options == 'string'
|
884
|
-
|
885
|
-
|
886
|
-
|
885
|
+
if (typeof options == 'string') {
|
886
|
+
if (!plugin['_' + options + 'Plugin']) {
|
887
|
+
throw 'Unknown command: ' + options;
|
888
|
+
}
|
889
|
+
plugin['_' + options + 'Plugin'].apply(plugin, [this].concat(otherArgs));
|
890
|
+
}
|
891
|
+
else {
|
892
|
+
plugin._attachPlugin(this, options || {});
|
893
|
+
}
|
887
894
|
});
|
888
895
|
};
|
889
896
|
|
890
|
-
|
897
|
+
/* Initialise the keypad functionality. */
|
898
|
+
var plugin = $.keypad = new Keypad(); // Singleton instance
|
891
899
|
|
892
900
|
// Add the keypad division and external click check
|
893
901
|
$(function() {
|
894
|
-
$(document.body).append(
|
895
|
-
mousedown(
|
902
|
+
$(document.body).append(plugin.mainDiv).
|
903
|
+
mousedown(plugin._checkExternalClick);
|
896
904
|
});
|
897
905
|
|
898
906
|
})(jQuery);
|