From c057e9fd8c261b1aaac8d9890aec8736c2c9d0b9 Mon Sep 17 00:00:00 2001 From: peppertom Date: Wed, 4 Oct 2017 00:04:02 +0200 Subject: [PATCH] add html5 input type `number` support refs: #43 --- index.html | 183 ++++----- index.pre.html | 31 +- jquery.repeater.js | 860 ++++++++++++++++++++-------------------- jquery.repeater.min.js | 5 +- repeater.html | 4 + src/jquery.input.js | 878 +++++++++++++++++++++-------------------- test/index.html | 4 + test/test-lib.js | 1 + test/test.js | 22 +- 9 files changed, 1022 insertions(+), 966 deletions(-) diff --git a/index.html b/index.html index 4b0ed04..ad31e10 100644 --- a/index.html +++ b/index.html @@ -5,97 +5,101 @@ Repeater jquery.repeater -

Repeater

-
-
-
- - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - -
-
- -
- -

Nested

-
-
-
- - -
-
-
- - -
-
- +

Repeater

+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+
+ + + +

Nested

+
+
+
+ + +
+
+
+ +
+
- - - - - - + + + diff --git a/index.pre.html b/index.pre.html index bf11421..51dbdd0 100644 --- a/index.pre.html +++ b/index.pre.html @@ -5,20 +5,20 @@ Repeater jquery.repeater -

Repeater

- -

Nested

- - - - + + + diff --git a/jquery.repeater.js b/jquery.repeater.js index 1678b1f..ba38d7d 100644 --- a/jquery.repeater.js +++ b/jquery.repeater.js @@ -1,6 +1,6 @@ // jquery.repeater version 1.2.1 // https://github.com/DubFriend/jquery.repeater -// (MIT) 09-10-2016 +// (MIT) 03-10-2017 // Brian Detering (http://www.briandetering.net/) (function ($) { 'use strict'; @@ -166,560 +166,576 @@ var mixinPubSub = function (object) { // (MIT) 09-04-2014 // Brian Detering (http://www.briandetering.net/) (function ($) { -'use strict'; - -var createBaseInput = function (fig, my) { - var self = mixinPubSub(), - $self = fig.$; - - self.getType = function () { - throw 'implement me (return type. "text", "radio", etc.)'; - }; + 'use strict'; - self.$ = function (selector) { - return selector ? $self.find(selector) : $self; - }; - - self.disable = function () { - self.$().prop('disabled', true); - self.publish('isEnabled', false); - }; + var createBaseInput = function (fig, my) { + var self = mixinPubSub(), + $self = fig.$; - self.enable = function () { - self.$().prop('disabled', false); - self.publish('isEnabled', true); - }; + self.getType = function () { + throw 'implement me (return type. "text", "radio", etc.)'; + }; - my.equalTo = function (a, b) { - return a === b; - }; + self.$ = function (selector) { + return selector ? $self.find(selector) : $self; + }; - my.publishChange = (function () { - var oldValue; - return function (e, domElement) { - var newValue = self.get(); - if(!my.equalTo(newValue, oldValue)) { - self.publish('change', { e: e, domElement: domElement }); - } - oldValue = newValue; + self.disable = function () { + self.$().prop('disabled', true); + self.publish('isEnabled', false); }; - }()); - return self; -}; + self.enable = function () { + self.$().prop('disabled', false); + self.publish('isEnabled', true); + }; + my.equalTo = function (a, b) { + return a === b; + }; -var createInput = function (fig, my) { - var self = createBaseInput(fig, my); + my.publishChange = (function () { + var oldValue; + return function (e, domElement) { + var newValue = self.get(); + if (!my.equalTo(newValue, oldValue)) { + self.publish('change', {e: e, domElement: domElement}); + } + oldValue = newValue; + }; + }()); - self.get = function () { - return self.$().val(); + return self; }; - self.set = function (newValue) { - self.$().val(newValue); - }; - self.clear = function () { - self.set(''); - }; + var createInput = function (fig, my) { + var self = createBaseInput(fig, my); - my.buildSetter = function (callback) { - return function (newValue) { - callback.call(self, newValue); + self.get = function () { + return self.$().val(); }; - }; - return self; -}; + self.set = function (newValue) { + self.$().val(newValue); + }; -var inputEqualToArray = function (a, b) { - a = isArray(a) ? a : [a]; - b = isArray(b) ? b : [b]; + self.clear = function () { + self.set(''); + }; - var isEqual = true; - if(a.length !== b.length) { - isEqual = false; - } - else { - foreach(a, function (value) { - if(!inArray(b, value)) { - isEqual = false; - } - }); - } + my.buildSetter = function (callback) { + return function (newValue) { + callback.call(self, newValue); + }; + }; - return isEqual; -}; + return self; + }; -var createInputButton = function (fig) { - var my = {}, - self = createInput(fig, my); + var inputEqualToArray = function (a, b) { + a = isArray(a) ? a : [a]; + b = isArray(b) ? b : [b]; + + var isEqual = true; + if (a.length !== b.length) { + isEqual = false; + } + else { + foreach(a, function (value) { + if (!inArray(b, value)) { + isEqual = false; + } + }); + } - self.getType = function () { - return 'button'; + return isEqual; }; - self.$().on('change', function (e) { - my.publishChange(e, this); - }); + var createInputButton = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; + self.getType = function () { + return 'button'; + }; -var createInputCheckbox = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().on('change', function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'checkbox'; + return self; }; - self.get = function () { - var values = []; - self.$().filter(':checked').each(function () { - values.push($(this).val()); - }); - return values; - }; + var createInputCheckbox = function (fig) { + var my = {}, + self = createInput(fig, my); - self.set = function (newValues) { - newValues = isArray(newValues) ? newValues : [newValues]; + self.getType = function () { + return 'checkbox'; + }; - self.$().each(function () { - $(this).prop('checked', false); - }); + self.get = function () { + var values = []; + self.$().filter(':checked').each(function () { + values.push($(this).val()); + }); + return values; + }; - foreach(newValues, function (value) { - self.$().filter('[value="' + value + '"]') - .prop('checked', true); - }); - }; + self.set = function (newValues) { + newValues = isArray(newValues) ? newValues : [newValues]; - my.equalTo = inputEqualToArray; + self.$().each(function () { + $(this).prop('checked', false); + }); - self.$().change(function (e) { - my.publishChange(e, this); - }); + foreach(newValues, function (value) { + self.$().filter('[value="' + value + '"]') + .prop('checked', true); + }); + }; - return self; -}; + my.equalTo = inputEqualToArray; -var createInputEmail = function (fig) { - var my = {}, - self = createInputText(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'email'; + return self; }; - return self; -}; + var createInputEmail = function (fig) { + var my = {}, + self = createInputText(fig, my); -var createInputFile = function (fig) { - var my = {}, - self = createBaseInput(fig, my); + self.getType = function () { + return 'email'; + }; - self.getType = function () { - return 'file'; + return self; }; - self.get = function () { - return last(self.$().val().split('\\')); - }; + var createInputFile = function (fig) { + var my = {}, + self = createBaseInput(fig, my); - self.clear = function () { - // http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery - this.$().each(function () { - $(this).wrap('
').closest('form').get(0).reset(); - $(this).unwrap(); - }); - }; + self.getType = function () { + return 'file'; + }; - self.$().change(function (e) { - my.publishChange(e, this); - // self.publish('change', self); - }); + self.get = function () { + return last(self.$().val().split('\\')); + }; - return self; -}; + self.clear = function () { + // http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery + this.$().each(function () { + $(this).wrap('').closest('form').get(0).reset(); + $(this).unwrap(); + }); + }; -var createInputHidden = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + // self.publish('change', self); + }); - self.getType = function () { - return 'hidden'; + return self; }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + var createInputHidden = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; -var createInputMultipleFile = function (fig) { - var my = {}, - self = createBaseInput(fig, my); + self.getType = function () { + return 'hidden'; + }; - self.getType = function () { - return 'file[multiple]'; - }; + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.get = function () { - // http://stackoverflow.com/questions/14035530/how-to-get-value-of-html-5-multiple-file-upload-variable-using-jquery - var fileListObject = self.$().get(0).files || [], - names = [], i; + return self; + }; + var createInputMultipleFile = function (fig) { + var my = {}, + self = createBaseInput(fig, my); - for(i = 0; i < (fileListObject.length || 0); i += 1) { - names.push(fileListObject[i].name); - } + self.getType = function () { + return 'file[multiple]'; + }; - return names; - }; + self.get = function () { + // http://stackoverflow.com/questions/14035530/how-to-get-value-of-html-5-multiple-file-upload-variable-using-jquery + var fileListObject = self.$().get(0).files || [], + names = [], i; - self.clear = function () { - // http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery - this.$().each(function () { - $(this).wrap('').closest('form').get(0).reset(); - $(this).unwrap(); - }); - }; + for (i = 0; i < (fileListObject.length || 0); i += 1) { + names.push(fileListObject[i].name); + } - self.$().change(function (e) { - my.publishChange(e, this); - }); + return names; + }; - return self; -}; + self.clear = function () { + // http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery + this.$().each(function () { + $(this).wrap('').closest('form').get(0).reset(); + $(this).unwrap(); + }); + }; -var createInputMultipleSelect = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'select[multiple]'; + return self; }; - self.get = function () { - return self.$().val() || []; - }; + var createInputMultipleSelect = function (fig) { + var my = {}, + self = createInput(fig, my); - self.set = function (newValues) { - self.$().val( - newValues === '' ? [] : isArray(newValues) ? newValues : [newValues] - ); - }; + self.getType = function () { + return 'select[multiple]'; + }; - my.equalTo = inputEqualToArray; + self.get = function () { + return self.$().val() || []; + }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + self.set = function (newValues) { + self.$().val( + newValues === '' ? [] : isArray(newValues) ? newValues : [newValues] + ); + }; - return self; -}; + my.equalTo = inputEqualToArray; -var createInputPassword = function (fig) { - var my = {}, - self = createInputText(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'password'; + return self; }; - return self; -}; + var createInputPassword = function (fig) { + var my = {}, + self = createInputText(fig, my); -var createInputRadio = function (fig) { - var my = {}, - self = createInput(fig, my); + self.getType = function () { + return 'password'; + }; - self.getType = function () { - return 'radio'; + return self; }; - self.get = function () { - return self.$().filter(':checked').val() || null; - }; + var createInputRadio = function (fig) { + var my = {}, + self = createInput(fig, my); - self.set = function (newValue) { - if(!newValue) { - self.$().each(function () { - $(this).prop('checked', false); - }); - } - else { - self.$().filter('[value="' + newValue + '"]').prop('checked', true); - } - }; + self.getType = function () { + return 'radio'; + }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + self.get = function () { + return self.$().filter(':checked').val() || null; + }; - return self; -}; + self.set = function (newValue) { + if (!newValue) { + self.$().each(function () { + $(this).prop('checked', false); + }); + } + else { + self.$().filter('[value="' + newValue + '"]').prop('checked', true); + } + }; -var createInputRange = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'range'; + return self; }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + var createInputRange = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; + self.getType = function () { + return 'range'; + }; -var createInputSelect = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'select'; + return self; }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + var createInputSelect = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; + self.getType = function () { + return 'select'; + }; -var createInputText = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'text'; + return self; }; - self.$().on('change keyup keydown', function (e) { - my.publishChange(e, this); - }); + var createInputText = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; + self.getType = function () { + return 'text'; + }; -var createInputTextarea = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().on('change keyup keydown', function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'textarea'; + return self; }; - self.$().on('change keyup keydown', function (e) { - my.publishChange(e, this); - }); + var createInputTextarea = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; + self.getType = function () { + return 'textarea'; + }; -var createInputURL = function (fig) { - var my = {}, - self = createInputText(fig, my); + self.$().on('change keyup keydown', function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'url'; + return self; }; - return self; -}; + var createInputURL = function (fig) { + var my = {}, + self = createInputText(fig, my); + + self.getType = function () { + return 'url'; + }; -var buildFormInputs = function (fig) { - var inputs = {}, - $self = fig.$; - - var constructor = fig.constructorOverride || { - button: createInputButton, - text: createInputText, - url: createInputURL, - email: createInputEmail, - password: createInputPassword, - range: createInputRange, - textarea: createInputTextarea, - select: createInputSelect, - 'select[multiple]': createInputMultipleSelect, - radio: createInputRadio, - checkbox: createInputCheckbox, - file: createInputFile, - 'file[multiple]': createInputMultipleFile, - hidden: createInputHidden + return self; }; - var addInputsBasic = function (type, selector) { - var $input = isObject(selector) ? selector : $self.find(selector); + var createInputNumber = function (fig) { + var my = {}, + self = createInput(fig, my); - $input.each(function () { - var name = $(this).attr('name'); - inputs[name] = constructor[type]({ - $: $(this) - }); - }); + self.getType = function () { + return 'number'; + }; + + return self; }; - var addInputsGroup = function (type, selector) { - var names = [], - $input = isObject(selector) ? selector : $self.find(selector); + var buildFormInputs = function (fig) { + var inputs = {}, + $self = fig.$; + + var constructor = fig.constructorOverride || { + button: createInputButton, + text: createInputText, + url: createInputURL, + email: createInputEmail, + password: createInputPassword, + range: createInputRange, + textarea: createInputTextarea, + select: createInputSelect, + 'select[multiple]': createInputMultipleSelect, + radio: createInputRadio, + checkbox: createInputCheckbox, + file: createInputFile, + 'file[multiple]': createInputMultipleFile, + hidden: createInputHidden, + number: createInputNumber + }; - if(isObject(selector)) { - inputs[$input.attr('name')] = constructor[type]({ - $: $input - }); - } - else { - // group by name attribute - $input.each(function () { - if(indexOf(names, $(this).attr('name')) === -1) { - names.push($(this).attr('name')); - } - }); + var addInputsBasic = function (type, selector) { + var $input = isObject(selector) ? selector : $self.find(selector); - foreach(names, function (name) { + $input.each(function () { + var name = $(this).attr('name'); inputs[name] = constructor[type]({ - $: $self.find('input[name="' + name + '"]') + $: $(this) }); }); - } - }; + }; + var addInputsGroup = function (type, selector) { + var names = [], + $input = isObject(selector) ? selector : $self.find(selector); - if($self.is('input, select, textarea')) { - if($self.is('input[type="button"], button, input[type="submit"]')) { - addInputsBasic('button', $self); - } - else if($self.is('textarea')) { - addInputsBasic('textarea', $self); - } - else if( - $self.is('input[type="text"]') || - $self.is('input') && !$self.attr('type') - ) { - addInputsBasic('text', $self); - } - else if($self.is('input[type="password"]')) { - addInputsBasic('password', $self); - } - else if($self.is('input[type="email"]')) { - addInputsBasic('email', $self); - } - else if($self.is('input[type="url"]')) { - addInputsBasic('url', $self); - } - else if($self.is('input[type="range"]')) { - addInputsBasic('range', $self); - } - else if($self.is('select')) { - if($self.is('[multiple]')) { - addInputsBasic('select[multiple]', $self); + if (isObject(selector)) { + inputs[$input.attr('name')] = constructor[type]({ + $: $input + }); } else { - addInputsBasic('select', $self); + // group by name attribute + $input.each(function () { + if (indexOf(names, $(this).attr('name')) === -1) { + names.push($(this).attr('name')); + } + }); + + foreach(names, function (name) { + inputs[name] = constructor[type]({ + $: $self.find('input[name="' + name + '"]') + }); + }); } - } - else if($self.is('input[type="file"]')) { - if($self.is('[multiple]')) { - addInputsBasic('file[multiple]', $self); + }; + + + if ($self.is('input, select, textarea')) { + if ($self.is('input[type="button"], button, input[type="submit"]')) { + addInputsBasic('button', $self); + } + else if ($self.is('textarea')) { + addInputsBasic('textarea', $self); + } + else if ( + $self.is('input[type="text"]') || + $self.is('input') && !$self.attr('type') + ) { + addInputsBasic('text', $self); + } + else if ($self.is('input[type="password"]')) { + addInputsBasic('password', $self); + } + else if ($self.is('input[type="email"]')) { + addInputsBasic('email', $self); + } + else if ($self.is('input[type="url"]')) { + addInputsBasic('url', $self); + } + else if ($self.is('input[type="range"]')) { + addInputsBasic('range', $self); + } + else if ($self.is('select')) { + if ($self.is('[multiple]')) { + addInputsBasic('select[multiple]', $self); + } + else { + addInputsBasic('select', $self); + } + } + else if ($self.is('input[type="file"]')) { + if ($self.is('[multiple]')) { + addInputsBasic('file[multiple]', $self); + } + else { + addInputsBasic('file', $self); + } + } + else if ($self.is('input[type="hidden"]')) { + addInputsBasic('hidden', $self); + } + else if ($self.is('input[type="radio"]')) { + addInputsGroup('radio', $self); + } + else if ($self.is('input[type="checkbox"]')) { + addInputsGroup('checkbox', $self); + } + else if($self.is('input[type="number"]')) { + addInputsGroup('number', $self); } else { - addInputsBasic('file', $self); + //in all other cases default to a "text" input interface. + addInputsBasic('text', $self); } } - else if($self.is('input[type="hidden"]')) { - addInputsBasic('hidden', $self); - } - else if($self.is('input[type="radio"]')) { - addInputsGroup('radio', $self); - } - else if($self.is('input[type="checkbox"]')) { - addInputsGroup('checkbox', $self); - } else { - //in all other cases default to a "text" input interface. - addInputsBasic('text', $self); + addInputsBasic('button', 'input[type="button"], button, input[type="submit"]'); + addInputsBasic('text', 'input[type="text"]'); + addInputsBasic('password', 'input[type="password"]'); + addInputsBasic('email', 'input[type="email"]'); + addInputsBasic('url', 'input[type="url"]'); + addInputsBasic('range', 'input[type="range"]'); + addInputsBasic('textarea', 'textarea'); + addInputsBasic('select', 'select:not([multiple])'); + addInputsBasic('select[multiple]', 'select[multiple]'); + addInputsBasic('file', 'input[type="file"]:not([multiple])'); + addInputsBasic('file[multiple]', 'input[type="file"][multiple]'); + addInputsBasic('hidden', 'input[type="hidden"]'); + addInputsGroup('radio', 'input[type="radio"]'); + addInputsGroup('checkbox', 'input[type="checkbox"]'); + addInputsBasic('number', 'input[type="number"]'); } - } - else { - addInputsBasic('button', 'input[type="button"], button, input[type="submit"]'); - addInputsBasic('text', 'input[type="text"]'); - addInputsBasic('password', 'input[type="password"]'); - addInputsBasic('email', 'input[type="email"]'); - addInputsBasic('url', 'input[type="url"]'); - addInputsBasic('range', 'input[type="range"]'); - addInputsBasic('textarea', 'textarea'); - addInputsBasic('select', 'select:not([multiple])'); - addInputsBasic('select[multiple]', 'select[multiple]'); - addInputsBasic('file', 'input[type="file"]:not([multiple])'); - addInputsBasic('file[multiple]', 'input[type="file"][multiple]'); - addInputsBasic('hidden', 'input[type="hidden"]'); - addInputsGroup('radio', 'input[type="radio"]'); - addInputsGroup('checkbox', 'input[type="checkbox"]'); - } - return inputs; -}; + return inputs; + }; -$.fn.inputVal = function (newValue) { - var $self = $(this); + $.fn.inputVal = function (newValue) { + var $self = $(this); - var inputs = buildFormInputs({ $: $self }); + var inputs = buildFormInputs({$: $self}); - if($self.is('input, textarea, select')) { - if(typeof newValue === 'undefined') { - return inputs[$self.attr('name')].get(); - } - else { - inputs[$self.attr('name')].set(newValue); - return $self; - } - } - else { - if(typeof newValue === 'undefined') { - return call(inputs, 'get'); + if ($self.is('input, textarea, select')) { + if (typeof newValue === 'undefined') { + return inputs[$self.attr('name')].get(); + } + else { + inputs[$self.attr('name')].set(newValue); + return $self; + } } else { - foreach(newValue, function (value, inputName) { - inputs[inputName].set(value); - }); - return $self; + if (typeof newValue === 'undefined') { + return call(inputs, 'get'); + } + else { + foreach(newValue, function (value, inputName) { + inputs[inputName].set(value); + }); + return $self; + } } - } -}; + }; -$.fn.inputOnChange = function (callback) { - var $self = $(this); - var inputs = buildFormInputs({ $: $self }); - foreach(inputs, function (input) { - input.subscribe('change', function (data) { - callback.call(data.domElement, data.e); + $.fn.inputOnChange = function (callback) { + var $self = $(this); + var inputs = buildFormInputs({$: $self}); + foreach(inputs, function (input) { + input.subscribe('change', function (data) { + callback.call(data.domElement, data.e); + }); }); - }); - return $self; -}; + return $self; + }; -$.fn.inputDisable = function () { - var $self = $(this); - call(buildFormInputs({ $: $self }), 'disable'); - return $self; -}; + $.fn.inputDisable = function () { + var $self = $(this); + call(buildFormInputs({$: $self}), 'disable'); + return $self; + }; -$.fn.inputEnable = function () { - var $self = $(this); - call(buildFormInputs({ $: $self }), 'enable'); - return $self; -}; + $.fn.inputEnable = function () { + var $self = $(this); + call(buildFormInputs({$: $self}), 'enable'); + return $self; + }; -$.fn.inputClear = function () { - var $self = $(this); - call(buildFormInputs({ $: $self }), 'clear'); - return $self; -}; + $.fn.inputClear = function () { + var $self = $(this); + call(buildFormInputs({$: $self}), 'clear'); + return $self; + }; }(jQuery)); diff --git a/jquery.repeater.min.js b/jquery.repeater.min.js index ade677f..8571c3e 100644 --- a/jquery.repeater.min.js +++ b/jquery.repeater.min.js @@ -1,5 +1,6 @@ // jquery.repeater version 1.2.1 // https://github.com/DubFriend/jquery.repeater -// (MIT) 09-10-2016 +// (MIT) 03-10-2017 // Brian Detering (http://www.briandetering.net/) -!function(a){"use strict";var b=function(a){return a},c=function(b){return a.isArray(b)},d=function(a){return!c(a)&&a instanceof Object},e=function(b,c){return a.inArray(c,b)},f=function(a,b){return e(a,b)!==-1},g=function(a,b){for(var c in a)a.hasOwnProperty(c)&&b(a[c],c,a)},h=function(a){return a[a.length-1]},i=function(a){return Array.prototype.slice.call(a)},j=function(){var a={};return g(i(arguments),function(b){g(b,function(b,c){a[c]=b})}),a},k=function(a,b){var c=[];return g(a,function(a,d,e){c.push(b(a,d,e))}),c},l=function(a,b,c){var d={};return g(a,function(a,e,f){e=c?c(e,a):e,d[e]=b(a,e,f)}),d},m=function(a,b,d){return c(a)?k(a,b):l(a,b,d)},n=function(a,b){return m(a,function(a){return a[b]})},o=function(a,b){var d;return c(a)?(d=[],g(a,function(a,c,e){b(a,c,e)&&d.push(a)})):(d={},g(a,function(a,c,e){b(a,c,e)&&(d[c]=a)})),d},p=function(a,b,c){return m(a,function(a,d){return a[b].apply(a,c||[])})},q=function(a){a=a||{};var b={};return a.publish=function(a,c){g(b[a],function(a){a(c)})},a.subscribe=function(a,c){b[a]=b[a]||[],b[a].push(c)},a.unsubscribe=function(a){g(b,function(b){var c=e(b,a);c!==-1&&b.splice(c,1)})},a};!function(a){var b=function(a,b){var c=q(),d=a.$;return c.getType=function(){throw'implement me (return type. "text", "radio", etc.)'},c.$=function(a){return a?d.find(a):d},c.disable=function(){c.$().prop("disabled",!0),c.publish("isEnabled",!1)},c.enable=function(){c.$().prop("disabled",!1),c.publish("isEnabled",!0)},b.equalTo=function(a,b){return a===b},b.publishChange=function(){var a;return function(d,e){var f=c.get();b.equalTo(f,a)||c.publish("change",{e:d,domElement:e}),a=f}}(),c},i=function(a,c){var d=b(a,c);return d.get=function(){return d.$().val()},d.set=function(a){d.$().val(a)},d.clear=function(){d.set("")},c.buildSetter=function(a){return function(b){a.call(d,b)}},d},j=function(a,b){a=c(a)?a:[a],b=c(b)?b:[b];var d=!0;return a.length!==b.length?d=!1:g(a,function(a){f(b,a)||(d=!1)}),d},k=function(a){var b={},c=i(a,b);return c.getType=function(){return"button"},c.$().on("change",function(a){b.publishChange(a,this)}),c},l=function(b){var d={},e=i(b,d);return e.getType=function(){return"checkbox"},e.get=function(){var b=[];return e.$().filter(":checked").each(function(){b.push(a(this).val())}),b},e.set=function(b){b=c(b)?b:[b],e.$().each(function(){a(this).prop("checked",!1)}),g(b,function(a){e.$().filter('[value="'+a+'"]').prop("checked",!0)})},d.equalTo=j,e.$().change(function(a){d.publishChange(a,this)}),e},m=function(a){var b={},c=x(a,b);return c.getType=function(){return"email"},c},n=function(c){var d={},e=b(c,d);return e.getType=function(){return"file"},e.get=function(){return h(e.$().val().split("\\"))},e.clear=function(){this.$().each(function(){a(this).wrap("").closest("form").get(0).reset(),a(this).unwrap()})},e.$().change(function(a){d.publishChange(a,this)}),e},o=function(a){var b={},c=i(a,b);return c.getType=function(){return"hidden"},c.$().change(function(a){b.publishChange(a,this)}),c},r=function(c){var d={},e=b(c,d);return e.getType=function(){return"file[multiple]"},e.get=function(){var a,b=e.$().get(0).files||[],c=[];for(a=0;a<(b.length||0);a+=1)c.push(b[a].name);return c},e.clear=function(){this.$().each(function(){a(this).wrap("").closest("form").get(0).reset(),a(this).unwrap()})},e.$().change(function(a){d.publishChange(a,this)}),e},s=function(a){var b={},d=i(a,b);return d.getType=function(){return"select[multiple]"},d.get=function(){return d.$().val()||[]},d.set=function(a){d.$().val(""===a?[]:c(a)?a:[a])},b.equalTo=j,d.$().change(function(a){b.publishChange(a,this)}),d},t=function(a){var b={},c=x(a,b);return c.getType=function(){return"password"},c},u=function(b){var c={},d=i(b,c);return d.getType=function(){return"radio"},d.get=function(){return d.$().filter(":checked").val()||null},d.set=function(b){b?d.$().filter('[value="'+b+'"]').prop("checked",!0):d.$().each(function(){a(this).prop("checked",!1)})},d.$().change(function(a){c.publishChange(a,this)}),d},v=function(a){var b={},c=i(a,b);return c.getType=function(){return"range"},c.$().change(function(a){b.publishChange(a,this)}),c},w=function(a){var b={},c=i(a,b);return c.getType=function(){return"select"},c.$().change(function(a){b.publishChange(a,this)}),c},x=function(a){var b={},c=i(a,b);return c.getType=function(){return"text"},c.$().on("change keyup keydown",function(a){b.publishChange(a,this)}),c},y=function(a){var b={},c=i(a,b);return c.getType=function(){return"textarea"},c.$().on("change keyup keydown",function(a){b.publishChange(a,this)}),c},z=function(a){var b={},c=x(a,b);return c.getType=function(){return"url"},c},A=function(b){var c={},f=b.$,h=b.constructorOverride||{button:k,text:x,url:z,email:m,password:t,range:v,textarea:y,select:w,"select[multiple]":s,radio:u,checkbox:l,file:n,"file[multiple]":r,hidden:o},i=function(b,e){var g=d(e)?e:f.find(e);g.each(function(){var d=a(this).attr("name");c[d]=h[b]({$:a(this)})})},j=function(b,i){var j=[],k=d(i)?i:f.find(i);d(i)?c[k.attr("name")]=h[b]({$:k}):(k.each(function(){e(j,a(this).attr("name"))===-1&&j.push(a(this).attr("name"))}),g(j,function(a){c[a]=h[b]({$:f.find('input[name="'+a+'"]')})}))};return f.is("input, select, textarea")?f.is('input[type="button"], button, input[type="submit"]')?i("button",f):f.is("textarea")?i("textarea",f):f.is('input[type="text"]')||f.is("input")&&!f.attr("type")?i("text",f):f.is('input[type="password"]')?i("password",f):f.is('input[type="email"]')?i("email",f):f.is('input[type="url"]')?i("url",f):f.is('input[type="range"]')?i("range",f):f.is("select")?f.is("[multiple]")?i("select[multiple]",f):i("select",f):f.is('input[type="file"]')?f.is("[multiple]")?i("file[multiple]",f):i("file",f):f.is('input[type="hidden"]')?i("hidden",f):f.is('input[type="radio"]')?j("radio",f):f.is('input[type="checkbox"]')?j("checkbox",f):i("text",f):(i("button",'input[type="button"], button, input[type="submit"]'),i("text",'input[type="text"]'),i("password",'input[type="password"]'),i("email",'input[type="email"]'),i("url",'input[type="url"]'),i("range",'input[type="range"]'),i("textarea","textarea"),i("select","select:not([multiple])"),i("select[multiple]","select[multiple]"),i("file",'input[type="file"]:not([multiple])'),i("file[multiple]",'input[type="file"][multiple]'),i("hidden",'input[type="hidden"]'),j("radio",'input[type="radio"]'),j("checkbox",'input[type="checkbox"]')),c};a.fn.inputVal=function(b){var c=a(this),d=A({$:c});return c.is("input, textarea, select")?"undefined"==typeof b?d[c.attr("name")].get():(d[c.attr("name")].set(b),c):"undefined"==typeof b?p(d,"get"):(g(b,function(a,b){d[b].set(a)}),c)},a.fn.inputOnChange=function(b){var c=a(this),d=A({$:c});return g(d,function(a){a.subscribe("change",function(a){b.call(a.domElement,a.e)})}),c},a.fn.inputDisable=function(){var b=a(this);return p(A({$:b}),"disable"),b},a.fn.inputEnable=function(){var b=a(this);return p(A({$:b}),"enable"),b},a.fn.inputClear=function(){var b=a(this);return p(A({$:b}),"clear"),b}}(jQuery),a.fn.repeaterVal=function(){var b=function(a){var b=[];return g(a,function(a,c){var d=[];"undefined"!==c&&(d.push(c.match(/^[^\[]*/)[0]),d=d.concat(m(c.match(/\[[^\]]*\]/g),function(a){return a.replace(/[\[\]]/g,"")})),b.push({val:a,key:d}))}),b},c=function(a){if(1===a.length&&(0===a[0].key.length||1===a[0].key.length&&!a[0].key[0]))return a[0].val;g(a,function(a){a.head=a.key.shift()});var b,d=function(){var b={};return g(a,function(a){b[a.head]||(b[a.head]=[]),b[a.head].push(a)}),b}();return/^[0-9]+$/.test(a[0].head)?(b=[],g(d,function(a){b.push(c(a))})):(b={},g(d,function(a,d){b[d]=c(a)})),b};return c(b(a(this).inputVal()))},a.fn.repeater=function(c){c=c||{};var d;return a(this).each(function(){var e=a(this),f=c.show||function(){a(this).show()},i=c.hide||function(a){a()},k=e.find("[data-repeater-list]").first(),l=function(b,c){return b.filter(function(){return!c||0===a(this).closest(n(c,"selector").join(",")).length})},p=function(){return l(k.find("[data-repeater-item]"),c.repeaters)},q=k.find("[data-repeater-item]").first().clone().hide(),r=l(l(a(this).find("[data-repeater-item]"),c.repeaters).first().find("[data-repeater-delete]"),c.repeaters);c.isFirstItemUndeletable&&r&&r.remove();var s=function(){var a=k.data("repeater-list");return c.$parent?c.$parent.data("item-name")+"["+a+"]":a},t=function(b){c.repeaters&&b.each(function(){var b=a(this);g(c.repeaters,function(a){b.find(a.selector).repeater(j(a,{$parent:b}))})})},u=function(a,b,c){a&&g(a,function(a){c.call(b.find(a.selector)[0],a)})},v=function(b,c,d){b.each(function(b){var e=a(this);e.data("item-name",c+"["+b+"]"),l(e.find("[name]"),d).each(function(){var f=a(this),g=f.attr("name").match(/\[[^\]]+\]/g),i=g?h(g).replace(/\[|\]/g,""):f.attr("name"),j=c+"["+b+"]["+i+"]"+(f.is(":checkbox")||f.attr("multiple")?"[]":"");f.attr("name",j),u(d,e,function(d){var e=a(this);v(l(e.find("[data-repeater-item]"),d.repeaters||[]),c+"["+b+"]["+e.find("[data-repeater-list]").first().data("repeater-list")+"]",d.repeaters)})})}),k.find("input[name][checked]").removeAttr("checked").prop("checked",!0)};v(p(),s(),c.repeaters),t(p()),c.initEmpty&&p().remove(),c.ready&&c.ready(function(){v(p(),s(),c.repeaters)});var w=function(){var d=function(e,f,h){if(f||c.defaultValues){var i={};l(e.find("[name]"),h).each(function(){var b=a(this).attr("name").match(/\[([^\]]*)(\]|\]\[\])$/)[1];i[b]=a(this).attr("name")}),e.inputVal(m(o(f||c.defaultValues,function(a,b){return i[b]}),b,function(a){return i[a]}))}u(h,e,function(b){var c=a(this);l(c.find("[data-repeater-item]"),b.repeaters).each(function(){var e=c.find("[data-repeater-list]").data("repeater-list");if(f&&f[e]){var h=a(this).clone();c.find("[data-repeater-item]").remove(),g(f[e],function(a){var e=h.clone();d(e,a,b.repeaters||[]),c.find("[data-repeater-list]").append(e)})}else d(a(this),b.defaultValues,b.repeaters||[])})})};return function(b,e){k.append(b),v(p(),s(),c.repeaters),b.find("[name]").each(function(){a(this).inputClear()}),d(b,e||c.defaultValues,c.repeaters)}}(),x=function(a){var b=q.clone();w(b,a),c.repeaters&&t(b),f.call(b.get(0))};d=function(a){p().remove(),g(a,x)},l(e.find("[data-repeater-create]"),c.repeaters).click(function(){x()}),k.on("click","[data-repeater-delete]",function(){var b=a(this).closest("[data-repeater-item]").get(0);i.call(b,function(){a(b).remove(),v(p(),s(),c.repeaters)})})}),this.setList=d,this}}(jQuery); \ No newline at end of file + +!function(a){"use strict";var b=function(a){return a},c=function(b){return a.isArray(b)},d=function(a){return!c(a)&&a instanceof Object},e=function(b,c){return a.inArray(c,b)},f=function(a,b){return-1!==e(a,b)},g=function(a,b){for(var c in a)a.hasOwnProperty(c)&&b(a[c],c,a)},h=function(a){return a[a.length-1]},i=function(a){return Array.prototype.slice.call(a)},j=function(){var a={};return g(i(arguments),function(b){g(b,function(b,c){a[c]=b})}),a},k=function(a,b){var c=[];return g(a,function(a,d,e){c.push(b(a,d,e))}),c},l=function(a,b,c){var d={};return g(a,function(a,e,f){e=c?c(e,a):e,d[e]=b(a,e,f)}),d},m=function(a,b,d){return c(a)?k(a,b):l(a,b,d)},n=function(a,b){return m(a,function(a){return a[b]})},o=function(a,b){var d;return c(a)?(d=[],g(a,function(a,c,e){b(a,c,e)&&d.push(a)})):(d={},g(a,function(a,c,e){b(a,c,e)&&(d[c]=a)})),d},p=function(a,b,c){return m(a,function(a,d){return a[b].apply(a,c||[])})},q=function(a){a=a||{};var b={};return a.publish=function(a,c){g(b[a],function(a){a(c)})},a.subscribe=function(a,c){b[a]=b[a]||[],b[a].push(c)},a.unsubscribe=function(a){g(b,function(b){var c=e(b,a);-1!==c&&b.splice(c,1)})},a};!function(a){var b=function(a,b){var c=q(),d=a.$;return c.getType=function(){throw'implement me (return type. "text", "radio", etc.)'},c.$=function(a){return a?d.find(a):d},c.disable=function(){c.$().prop("disabled",!0),c.publish("isEnabled",!1)},c.enable=function(){c.$().prop("disabled",!1),c.publish("isEnabled",!0)},b.equalTo=function(a,b){return a===b},b.publishChange=function(){var a;return function(d,e){var f=c.get();b.equalTo(f,a)||c.publish("change",{e:d,domElement:e}),a=f}}(),c},i=function(a,c){var d=b(a,c);return d.get=function(){return d.$().val()},d.set=function(a){d.$().val(a)},d.clear=function(){d.set("")},c.buildSetter=function(a){return function(b){a.call(d,b)}},d},j=function(a,b){a=c(a)?a:[a],b=c(b)?b:[b];var d=!0;return a.length!==b.length?d=!1:g(a,function(a){f(b,a)||(d=!1)}),d},k=function(a){var b={},c=i(a,b);return c.getType=function(){return"button"},c.$().on("change",function(a){b.publishChange(a,this)}),c},l=function(b){var d={},e=i(b,d);return e.getType=function(){return"checkbox"},e.get=function(){var b=[];return e.$().filter(":checked").each(function(){b.push(a(this).val())}),b},e.set=function(b){b=c(b)?b:[b],e.$().each(function(){a(this).prop("checked",!1)}),g(b,function(a){e.$().filter('[value="'+a+'"]').prop("checked",!0)})},d.equalTo=j,e.$().change(function(a){d.publishChange(a,this)}),e},m=function(a){var b={},c=x(a,b);return c.getType=function(){return"email"},c},n=function(c){var d={},e=b(c,d);return e.getType=function(){return"file"},e.get=function(){return h(e.$().val().split("\\"))},e.clear=function(){this.$().each(function(){a(this).wrap("").closest("form").get(0).reset(),a(this).unwrap()})},e.$().change(function(a){d.publishChange(a,this)}),e},o=function(a){var b={},c=i(a,b);return c.getType=function(){return"hidden"},c.$().change(function(a){b.publishChange(a,this)}),c},r=function(c){var d={},e=b(c,d);return e.getType=function(){return"file[multiple]"},e.get=function(){var a,b=e.$().get(0).files||[],c=[];for(a=0;a<(b.length||0);a+=1)c.push(b[a].name);return c},e.clear=function(){this.$().each(function(){a(this).wrap("").closest("form").get(0).reset(),a(this).unwrap()})},e.$().change(function(a){d.publishChange(a,this)}),e},s=function(a){var b={},d=i(a,b);return d.getType=function(){return"select[multiple]"},d.get=function(){return d.$().val()||[]},d.set=function(a){d.$().val(""===a?[]:c(a)?a:[a])},b.equalTo=j,d.$().change(function(a){b.publishChange(a,this)}),d},t=function(a){var b={},c=x(a,b);return c.getType=function(){return"password"},c},u=function(b){var c={},d=i(b,c);return d.getType=function(){return"radio"},d.get=function(){return d.$().filter(":checked").val()||null},d.set=function(b){b?d.$().filter('[value="'+b+'"]').prop("checked",!0):d.$().each(function(){a(this).prop("checked",!1)})},d.$().change(function(a){c.publishChange(a,this)}),d},v=function(a){var b={},c=i(a,b);return c.getType=function(){return"range"},c.$().change(function(a){b.publishChange(a,this)}),c},w=function(a){var b={},c=i(a,b);return c.getType=function(){return"select"},c.$().change(function(a){b.publishChange(a,this)}),c},x=function(a){var b={},c=i(a,b);return c.getType=function(){return"text"},c.$().on("change keyup keydown",function(a){b.publishChange(a,this)}),c},y=function(a){var b={},c=i(a,b);return c.getType=function(){return"textarea"},c.$().on("change keyup keydown",function(a){b.publishChange(a,this)}),c},z=function(a){var b={},c=x(a,b);return c.getType=function(){return"url"},c},A=function(a){var b={},c=i(a,b);return c.getType=function(){return"number"},c},B=function(b){var c={},f=b.$,h=b.constructorOverride||{button:k,text:x,url:z,email:m,password:t,range:v,textarea:y,select:w,"select[multiple]":s,radio:u,checkbox:l,file:n,"file[multiple]":r,hidden:o,number:A},i=function(b,e){(d(e)?e:f.find(e)).each(function(){var d=a(this).attr("name");c[d]=h[b]({$:a(this)})})},j=function(b,i){var j=[],k=d(i)?i:f.find(i);d(i)?c[k.attr("name")]=h[b]({$:k}):(k.each(function(){-1===e(j,a(this).attr("name"))&&j.push(a(this).attr("name"))}),g(j,function(a){c[a]=h[b]({$:f.find('input[name="'+a+'"]')})}))};return f.is("input, select, textarea")?f.is('input[type="button"], button, input[type="submit"]')?i("button",f):f.is("textarea")?i("textarea",f):f.is('input[type="text"]')||f.is("input")&&!f.attr("type")?i("text",f):f.is('input[type="password"]')?i("password",f):f.is('input[type="email"]')?i("email",f):f.is('input[type="url"]')?i("url",f):f.is('input[type="range"]')?i("range",f):f.is("select")?f.is("[multiple]")?i("select[multiple]",f):i("select",f):f.is('input[type="file"]')?f.is("[multiple]")?i("file[multiple]",f):i("file",f):f.is('input[type="hidden"]')?i("hidden",f):f.is('input[type="radio"]')?j("radio",f):f.is('input[type="checkbox"]')?j("checkbox",f):f.is('input[type="number"]')?j("number",f):i("text",f):(i("button",'input[type="button"], button, input[type="submit"]'),i("text",'input[type="text"]'),i("password",'input[type="password"]'),i("email",'input[type="email"]'),i("url",'input[type="url"]'),i("range",'input[type="range"]'),i("textarea","textarea"),i("select","select:not([multiple])"),i("select[multiple]","select[multiple]"),i("file",'input[type="file"]:not([multiple])'),i("file[multiple]",'input[type="file"][multiple]'),i("hidden",'input[type="hidden"]'),j("radio",'input[type="radio"]'),j("checkbox",'input[type="checkbox"]'),i("number",'input[type="number"]')),c};a.fn.inputVal=function(b){var c=a(this),d=B({$:c});return c.is("input, textarea, select")?void 0===b?d[c.attr("name")].get():(d[c.attr("name")].set(b),c):void 0===b?p(d,"get"):(g(b,function(a,b){d[b].set(a)}),c)},a.fn.inputOnChange=function(b){var c=a(this),d=B({$:c});return g(d,function(a){a.subscribe("change",function(a){b.call(a.domElement,a.e)})}),c},a.fn.inputDisable=function(){var b=a(this);return p(B({$:b}),"disable"),b},a.fn.inputEnable=function(){var b=a(this);return p(B({$:b}),"enable"),b},a.fn.inputClear=function(){var b=a(this);return p(B({$:b}),"clear"),b}}(jQuery),a.fn.repeaterVal=function(){var b=function(a){if(1===a.length&&(0===a[0].key.length||1===a[0].key.length&&!a[0].key[0]))return a[0].val;g(a,function(a){a.head=a.key.shift()});var c,d=function(){var b={};return g(a,function(a){b[a.head]||(b[a.head]=[]),b[a.head].push(a)}),b}();return/^[0-9]+$/.test(a[0].head)?(c=[],g(d,function(a){c.push(b(a))})):(c={},g(d,function(a,d){c[d]=b(a)})),c};return b(function(a){var b=[];return g(a,function(a,c){var d=[];"undefined"!==c&&(d.push(c.match(/^[^\[]*/)[0]),d=d.concat(m(c.match(/\[[^\]]*\]/g),function(a){return a.replace(/[\[\]]/g,"")})),b.push({val:a,key:d}))}),b}(a(this).inputVal()))},a.fn.repeater=function(c){c=c||{};var d;return a(this).each(function(){var e=a(this),f=c.show||function(){a(this).show()},i=c.hide||function(a){a()},k=e.find("[data-repeater-list]").first(),l=function(b,c){return b.filter(function(){return!c||0===a(this).closest(n(c,"selector").join(",")).length})},p=function(){return l(k.find("[data-repeater-item]"),c.repeaters)},q=k.find("[data-repeater-item]").first().clone().hide(),r=l(l(a(this).find("[data-repeater-item]"),c.repeaters).first().find("[data-repeater-delete]"),c.repeaters);c.isFirstItemUndeletable&&r&&r.remove();var s=function(){var a=k.data("repeater-list");return c.$parent?c.$parent.data("item-name")+"["+a+"]":a},t=function(b){c.repeaters&&b.each(function(){var b=a(this);g(c.repeaters,function(a){b.find(a.selector).repeater(j(a,{$parent:b}))})})},u=function(a,b,c){a&&g(a,function(a){c.call(b.find(a.selector)[0],a)})},v=function(b,c,d){b.each(function(b){var e=a(this);e.data("item-name",c+"["+b+"]"),l(e.find("[name]"),d).each(function(){var f=a(this),g=f.attr("name").match(/\[[^\]]+\]/g),i=g?h(g).replace(/\[|\]/g,""):f.attr("name"),j=c+"["+b+"]["+i+"]"+(f.is(":checkbox")||f.attr("multiple")?"[]":"");f.attr("name",j),u(d,e,function(d){var e=a(this);v(l(e.find("[data-repeater-item]"),d.repeaters||[]),c+"["+b+"]["+e.find("[data-repeater-list]").first().data("repeater-list")+"]",d.repeaters)})})}),k.find("input[name][checked]").removeAttr("checked").prop("checked",!0)};v(p(),s(),c.repeaters),t(p()),c.initEmpty&&p().remove(),c.ready&&c.ready(function(){v(p(),s(),c.repeaters)});var w=function(){var d=function(e,f,h){if(f||c.defaultValues){var i={};l(e.find("[name]"),h).each(function(){var b=a(this).attr("name").match(/\[([^\]]*)(\]|\]\[\])$/)[1];i[b]=a(this).attr("name")}),e.inputVal(m(o(f||c.defaultValues,function(a,b){return i[b]}),b,function(a){return i[a]}))}u(h,e,function(b){var c=a(this);l(c.find("[data-repeater-item]"),b.repeaters).each(function(){var e=c.find("[data-repeater-list]").data("repeater-list");if(f&&f[e]){var h=a(this).clone();c.find("[data-repeater-item]").remove(),g(f[e],function(a){var e=h.clone();d(e,a,b.repeaters||[]),c.find("[data-repeater-list]").append(e)})}else d(a(this),b.defaultValues,b.repeaters||[])})})};return function(b,e){k.append(b),v(p(),s(),c.repeaters),b.find("[name]").each(function(){a(this).inputClear()}),d(b,e||c.defaultValues,c.repeaters)}}(),x=function(a){var b=q.clone();w(b,a),c.repeaters&&t(b),f.call(b.get(0))};d=function(a){p().remove(),g(a,x)},l(e.find("[data-repeater-create]"),c.repeaters).click(function(){x()}),k.on("click","[data-repeater-delete]",function(){var b=a(this).closest("[data-repeater-item]").get(0);i.call(b,function(){a(b).remove(),v(p(),s(),c.repeaters)})})}),this.setList=d,this}}(jQuery); \ No newline at end of file diff --git a/repeater.html b/repeater.html index e6001cb..9ba6516 100644 --- a/repeater.html +++ b/repeater.html @@ -5,6 +5,8 @@ + + @@ -32,6 +34,8 @@ + + diff --git a/src/jquery.input.js b/src/jquery.input.js index c9730cc..f8dbc29 100644 --- a/src/jquery.input.js +++ b/src/jquery.input.js @@ -3,559 +3,575 @@ // (MIT) 09-04-2014 // Brian Detering (http://www.briandetering.net/) (function ($) { -'use strict'; + 'use strict'; -var createBaseInput = function (fig, my) { - var self = mixinPubSub(), - $self = fig.$; + var createBaseInput = function (fig, my) { + var self = mixinPubSub(), + $self = fig.$; - self.getType = function () { - throw 'implement me (return type. "text", "radio", etc.)'; - }; - - self.$ = function (selector) { - return selector ? $self.find(selector) : $self; - }; - - self.disable = function () { - self.$().prop('disabled', true); - self.publish('isEnabled', false); - }; - - self.enable = function () { - self.$().prop('disabled', false); - self.publish('isEnabled', true); - }; + self.getType = function () { + throw 'implement me (return type. "text", "radio", etc.)'; + }; - my.equalTo = function (a, b) { - return a === b; - }; + self.$ = function (selector) { + return selector ? $self.find(selector) : $self; + }; - my.publishChange = (function () { - var oldValue; - return function (e, domElement) { - var newValue = self.get(); - if(!my.equalTo(newValue, oldValue)) { - self.publish('change', { e: e, domElement: domElement }); - } - oldValue = newValue; + self.disable = function () { + self.$().prop('disabled', true); + self.publish('isEnabled', false); }; - }()); - return self; -}; + self.enable = function () { + self.$().prop('disabled', false); + self.publish('isEnabled', true); + }; + my.equalTo = function (a, b) { + return a === b; + }; -var createInput = function (fig, my) { - var self = createBaseInput(fig, my); + my.publishChange = (function () { + var oldValue; + return function (e, domElement) { + var newValue = self.get(); + if (!my.equalTo(newValue, oldValue)) { + self.publish('change', {e: e, domElement: domElement}); + } + oldValue = newValue; + }; + }()); - self.get = function () { - return self.$().val(); + return self; }; - self.set = function (newValue) { - self.$().val(newValue); - }; - self.clear = function () { - self.set(''); - }; + var createInput = function (fig, my) { + var self = createBaseInput(fig, my); - my.buildSetter = function (callback) { - return function (newValue) { - callback.call(self, newValue); + self.get = function () { + return self.$().val(); }; - }; - return self; -}; - -var inputEqualToArray = function (a, b) { - a = isArray(a) ? a : [a]; - b = isArray(b) ? b : [b]; - - var isEqual = true; - if(a.length !== b.length) { - isEqual = false; - } - else { - foreach(a, function (value) { - if(!inArray(b, value)) { - isEqual = false; - } - }); - } + self.set = function (newValue) { + self.$().val(newValue); + }; - return isEqual; -}; + self.clear = function () { + self.set(''); + }; -var createInputButton = function (fig) { - var my = {}, - self = createInput(fig, my); + my.buildSetter = function (callback) { + return function (newValue) { + callback.call(self, newValue); + }; + }; - self.getType = function () { - return 'button'; + return self; }; - self.$().on('change', function (e) { - my.publishChange(e, this); - }); + var inputEqualToArray = function (a, b) { + a = isArray(a) ? a : [a]; + b = isArray(b) ? b : [b]; - return self; -}; - -var createInputCheckbox = function (fig) { - var my = {}, - self = createInput(fig, my); + var isEqual = true; + if (a.length !== b.length) { + isEqual = false; + } + else { + foreach(a, function (value) { + if (!inArray(b, value)) { + isEqual = false; + } + }); + } - self.getType = function () { - return 'checkbox'; + return isEqual; }; - self.get = function () { - var values = []; - self.$().filter(':checked').each(function () { - values.push($(this).val()); - }); - return values; - }; + var createInputButton = function (fig) { + var my = {}, + self = createInput(fig, my); - self.set = function (newValues) { - newValues = isArray(newValues) ? newValues : [newValues]; + self.getType = function () { + return 'button'; + }; - self.$().each(function () { - $(this).prop('checked', false); + self.$().on('change', function (e) { + my.publishChange(e, this); }); - foreach(newValues, function (value) { - self.$().filter('[value="' + value + '"]') - .prop('checked', true); - }); + return self; }; - my.equalTo = inputEqualToArray; - - self.$().change(function (e) { - my.publishChange(e, this); - }); + var createInputCheckbox = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; - -var createInputEmail = function (fig) { - var my = {}, - self = createInputText(fig, my); + self.getType = function () { + return 'checkbox'; + }; - self.getType = function () { - return 'email'; - }; + self.get = function () { + var values = []; + self.$().filter(':checked').each(function () { + values.push($(this).val()); + }); + return values; + }; - return self; -}; + self.set = function (newValues) { + newValues = isArray(newValues) ? newValues : [newValues]; -var createInputFile = function (fig) { - var my = {}, - self = createBaseInput(fig, my); + self.$().each(function () { + $(this).prop('checked', false); + }); - self.getType = function () { - return 'file'; - }; + foreach(newValues, function (value) { + self.$().filter('[value="' + value + '"]') + .prop('checked', true); + }); + }; - self.get = function () { - return last(self.$().val().split('\\')); - }; + my.equalTo = inputEqualToArray; - self.clear = function () { - // http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery - this.$().each(function () { - $(this).wrap('').closest('form').get(0).reset(); - $(this).unwrap(); + self.$().change(function (e) { + my.publishChange(e, this); }); - }; - self.$().change(function (e) { - my.publishChange(e, this); - // self.publish('change', self); - }); + return self; + }; - return self; -}; + var createInputEmail = function (fig) { + var my = {}, + self = createInputText(fig, my); -var createInputHidden = function (fig) { - var my = {}, - self = createInput(fig, my); + self.getType = function () { + return 'email'; + }; - self.getType = function () { - return 'hidden'; + return self; }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + var createInputFile = function (fig) { + var my = {}, + self = createBaseInput(fig, my); - return self; -}; -var createInputMultipleFile = function (fig) { - var my = {}, - self = createBaseInput(fig, my); + self.getType = function () { + return 'file'; + }; - self.getType = function () { - return 'file[multiple]'; - }; + self.get = function () { + return last(self.$().val().split('\\')); + }; - self.get = function () { - // http://stackoverflow.com/questions/14035530/how-to-get-value-of-html-5-multiple-file-upload-variable-using-jquery - var fileListObject = self.$().get(0).files || [], - names = [], i; + self.clear = function () { + // http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery + this.$().each(function () { + $(this).wrap('').closest('form').get(0).reset(); + $(this).unwrap(); + }); + }; - for(i = 0; i < (fileListObject.length || 0); i += 1) { - names.push(fileListObject[i].name); - } + self.$().change(function (e) { + my.publishChange(e, this); + // self.publish('change', self); + }); - return names; + return self; }; - self.clear = function () { - // http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery - this.$().each(function () { - $(this).wrap('').closest('form').get(0).reset(); - $(this).unwrap(); + var createInputHidden = function (fig) { + var my = {}, + self = createInput(fig, my); + + self.getType = function () { + return 'hidden'; + }; + + self.$().change(function (e) { + my.publishChange(e, this); }); + + return self; }; + var createInputMultipleFile = function (fig) { + var my = {}, + self = createBaseInput(fig, my); - self.$().change(function (e) { - my.publishChange(e, this); - }); + self.getType = function () { + return 'file[multiple]'; + }; - return self; -}; + self.get = function () { + // http://stackoverflow.com/questions/14035530/how-to-get-value-of-html-5-multiple-file-upload-variable-using-jquery + var fileListObject = self.$().get(0).files || [], + names = [], i; -var createInputMultipleSelect = function (fig) { - var my = {}, - self = createInput(fig, my); + for (i = 0; i < (fileListObject.length || 0); i += 1) { + names.push(fileListObject[i].name); + } - self.getType = function () { - return 'select[multiple]'; - }; + return names; + }; - self.get = function () { - return self.$().val() || []; - }; + self.clear = function () { + // http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery + this.$().each(function () { + $(this).wrap('').closest('form').get(0).reset(); + $(this).unwrap(); + }); + }; - self.set = function (newValues) { - self.$().val( - newValues === '' ? [] : isArray(newValues) ? newValues : [newValues] - ); + self.$().change(function (e) { + my.publishChange(e, this); + }); + + return self; }; - my.equalTo = inputEqualToArray; + var createInputMultipleSelect = function (fig) { + var my = {}, + self = createInput(fig, my); + + self.getType = function () { + return 'select[multiple]'; + }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + self.get = function () { + return self.$().val() || []; + }; - return self; -}; + self.set = function (newValues) { + self.$().val( + newValues === '' ? [] : isArray(newValues) ? newValues : [newValues] + ); + }; -var createInputPassword = function (fig) { - var my = {}, - self = createInputText(fig, my); + my.equalTo = inputEqualToArray; - self.getType = function () { - return 'password'; + self.$().change(function (e) { + my.publishChange(e, this); + }); + + return self; }; - return self; -}; + var createInputPassword = function (fig) { + var my = {}, + self = createInputText(fig, my); -var createInputRadio = function (fig) { - var my = {}, - self = createInput(fig, my); + self.getType = function () { + return 'password'; + }; - self.getType = function () { - return 'radio'; + return self; }; - self.get = function () { - return self.$().filter(':checked').val() || null; - }; + var createInputRadio = function (fig) { + var my = {}, + self = createInput(fig, my); - self.set = function (newValue) { - if(!newValue) { - self.$().each(function () { - $(this).prop('checked', false); - }); - } - else { - self.$().filter('[value="' + newValue + '"]').prop('checked', true); - } - }; + self.getType = function () { + return 'radio'; + }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + self.get = function () { + return self.$().filter(':checked').val() || null; + }; - return self; -}; + self.set = function (newValue) { + if (!newValue) { + self.$().each(function () { + $(this).prop('checked', false); + }); + } + else { + self.$().filter('[value="' + newValue + '"]').prop('checked', true); + } + }; -var createInputRange = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'range'; + return self; }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + var createInputRange = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; + self.getType = function () { + return 'range'; + }; -var createInputSelect = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'select'; + return self; }; - self.$().change(function (e) { - my.publishChange(e, this); - }); + var createInputSelect = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; + self.getType = function () { + return 'select'; + }; -var createInputText = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().change(function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'text'; + return self; }; - self.$().on('change keyup keydown', function (e) { - my.publishChange(e, this); - }); + var createInputText = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; + self.getType = function () { + return 'text'; + }; -var createInputTextarea = function (fig) { - var my = {}, - self = createInput(fig, my); + self.$().on('change keyup keydown', function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'textarea'; + return self; }; - self.$().on('change keyup keydown', function (e) { - my.publishChange(e, this); - }); + var createInputTextarea = function (fig) { + var my = {}, + self = createInput(fig, my); - return self; -}; + self.getType = function () { + return 'textarea'; + }; -var createInputURL = function (fig) { - var my = {}, - self = createInputText(fig, my); + self.$().on('change keyup keydown', function (e) { + my.publishChange(e, this); + }); - self.getType = function () { - return 'url'; + return self; }; - return self; -}; - -var buildFormInputs = function (fig) { - var inputs = {}, - $self = fig.$; - - var constructor = fig.constructorOverride || { - button: createInputButton, - text: createInputText, - url: createInputURL, - email: createInputEmail, - password: createInputPassword, - range: createInputRange, - textarea: createInputTextarea, - select: createInputSelect, - 'select[multiple]': createInputMultipleSelect, - radio: createInputRadio, - checkbox: createInputCheckbox, - file: createInputFile, - 'file[multiple]': createInputMultipleFile, - hidden: createInputHidden - }; + var createInputURL = function (fig) { + var my = {}, + self = createInputText(fig, my); - var addInputsBasic = function (type, selector) { - var $input = isObject(selector) ? selector : $self.find(selector); + self.getType = function () { + return 'url'; + }; - $input.each(function () { - var name = $(this).attr('name'); - inputs[name] = constructor[type]({ - $: $(this) - }); - }); + return self; }; - var addInputsGroup = function (type, selector) { - var names = [], - $input = isObject(selector) ? selector : $self.find(selector); + var createInputNumber = function (fig) { + var my = {}, + self = createInput(fig, my); - if(isObject(selector)) { - inputs[$input.attr('name')] = constructor[type]({ - $: $input - }); - } - else { - // group by name attribute - $input.each(function () { - if(indexOf(names, $(this).attr('name')) === -1) { - names.push($(this).attr('name')); - } - }); + self.getType = function () { + return 'number'; + }; - foreach(names, function (name) { + return self; + }; + + var buildFormInputs = function (fig) { + var inputs = {}, + $self = fig.$; + + var constructor = fig.constructorOverride || { + button: createInputButton, + text: createInputText, + url: createInputURL, + email: createInputEmail, + password: createInputPassword, + range: createInputRange, + textarea: createInputTextarea, + select: createInputSelect, + 'select[multiple]': createInputMultipleSelect, + radio: createInputRadio, + checkbox: createInputCheckbox, + file: createInputFile, + 'file[multiple]': createInputMultipleFile, + hidden: createInputHidden, + number: createInputNumber + }; + + var addInputsBasic = function (type, selector) { + var $input = isObject(selector) ? selector : $self.find(selector); + + $input.each(function () { + var name = $(this).attr('name'); inputs[name] = constructor[type]({ - $: $self.find('input[name="' + name + '"]') + $: $(this) }); }); - } - }; + }; + var addInputsGroup = function (type, selector) { + var names = [], + $input = isObject(selector) ? selector : $self.find(selector); - if($self.is('input, select, textarea')) { - if($self.is('input[type="button"], button, input[type="submit"]')) { - addInputsBasic('button', $self); - } - else if($self.is('textarea')) { - addInputsBasic('textarea', $self); - } - else if( - $self.is('input[type="text"]') || - $self.is('input') && !$self.attr('type') - ) { - addInputsBasic('text', $self); - } - else if($self.is('input[type="password"]')) { - addInputsBasic('password', $self); - } - else if($self.is('input[type="email"]')) { - addInputsBasic('email', $self); - } - else if($self.is('input[type="url"]')) { - addInputsBasic('url', $self); - } - else if($self.is('input[type="range"]')) { - addInputsBasic('range', $self); - } - else if($self.is('select')) { - if($self.is('[multiple]')) { - addInputsBasic('select[multiple]', $self); + if (isObject(selector)) { + inputs[$input.attr('name')] = constructor[type]({ + $: $input + }); } else { - addInputsBasic('select', $self); + // group by name attribute + $input.each(function () { + if (indexOf(names, $(this).attr('name')) === -1) { + names.push($(this).attr('name')); + } + }); + + foreach(names, function (name) { + inputs[name] = constructor[type]({ + $: $self.find('input[name="' + name + '"]') + }); + }); } - } - else if($self.is('input[type="file"]')) { - if($self.is('[multiple]')) { - addInputsBasic('file[multiple]', $self); + }; + + + if ($self.is('input, select, textarea')) { + if ($self.is('input[type="button"], button, input[type="submit"]')) { + addInputsBasic('button', $self); + } + else if ($self.is('textarea')) { + addInputsBasic('textarea', $self); + } + else if ( + $self.is('input[type="text"]') || + $self.is('input') && !$self.attr('type') + ) { + addInputsBasic('text', $self); + } + else if ($self.is('input[type="password"]')) { + addInputsBasic('password', $self); + } + else if ($self.is('input[type="email"]')) { + addInputsBasic('email', $self); + } + else if ($self.is('input[type="url"]')) { + addInputsBasic('url', $self); + } + else if ($self.is('input[type="range"]')) { + addInputsBasic('range', $self); + } + else if ($self.is('select')) { + if ($self.is('[multiple]')) { + addInputsBasic('select[multiple]', $self); + } + else { + addInputsBasic('select', $self); + } + } + else if ($self.is('input[type="file"]')) { + if ($self.is('[multiple]')) { + addInputsBasic('file[multiple]', $self); + } + else { + addInputsBasic('file', $self); + } + } + else if ($self.is('input[type="hidden"]')) { + addInputsBasic('hidden', $self); + } + else if ($self.is('input[type="radio"]')) { + addInputsGroup('radio', $self); + } + else if ($self.is('input[type="checkbox"]')) { + addInputsGroup('checkbox', $self); + } + else if($self.is('input[type="number"]')) { + addInputsGroup('number', $self); } else { - addInputsBasic('file', $self); + //in all other cases default to a "text" input interface. + addInputsBasic('text', $self); } } - else if($self.is('input[type="hidden"]')) { - addInputsBasic('hidden', $self); - } - else if($self.is('input[type="radio"]')) { - addInputsGroup('radio', $self); - } - else if($self.is('input[type="checkbox"]')) { - addInputsGroup('checkbox', $self); - } else { - //in all other cases default to a "text" input interface. - addInputsBasic('text', $self); + addInputsBasic('button', 'input[type="button"], button, input[type="submit"]'); + addInputsBasic('text', 'input[type="text"]'); + addInputsBasic('password', 'input[type="password"]'); + addInputsBasic('email', 'input[type="email"]'); + addInputsBasic('url', 'input[type="url"]'); + addInputsBasic('range', 'input[type="range"]'); + addInputsBasic('textarea', 'textarea'); + addInputsBasic('select', 'select:not([multiple])'); + addInputsBasic('select[multiple]', 'select[multiple]'); + addInputsBasic('file', 'input[type="file"]:not([multiple])'); + addInputsBasic('file[multiple]', 'input[type="file"][multiple]'); + addInputsBasic('hidden', 'input[type="hidden"]'); + addInputsGroup('radio', 'input[type="radio"]'); + addInputsGroup('checkbox', 'input[type="checkbox"]'); + addInputsBasic('number', 'input[type="number"]'); } - } - else { - addInputsBasic('button', 'input[type="button"], button, input[type="submit"]'); - addInputsBasic('text', 'input[type="text"]'); - addInputsBasic('password', 'input[type="password"]'); - addInputsBasic('email', 'input[type="email"]'); - addInputsBasic('url', 'input[type="url"]'); - addInputsBasic('range', 'input[type="range"]'); - addInputsBasic('textarea', 'textarea'); - addInputsBasic('select', 'select:not([multiple])'); - addInputsBasic('select[multiple]', 'select[multiple]'); - addInputsBasic('file', 'input[type="file"]:not([multiple])'); - addInputsBasic('file[multiple]', 'input[type="file"][multiple]'); - addInputsBasic('hidden', 'input[type="hidden"]'); - addInputsGroup('radio', 'input[type="radio"]'); - addInputsGroup('checkbox', 'input[type="checkbox"]'); - } - - return inputs; -}; - -$.fn.inputVal = function (newValue) { - var $self = $(this); - - var inputs = buildFormInputs({ $: $self }); - - if($self.is('input, textarea, select')) { - if(typeof newValue === 'undefined') { - return inputs[$self.attr('name')].get(); + + return inputs; + }; + + $.fn.inputVal = function (newValue) { + var $self = $(this); + + var inputs = buildFormInputs({$: $self}); + + if ($self.is('input, textarea, select')) { + if (typeof newValue === 'undefined') { + return inputs[$self.attr('name')].get(); + } + else { + inputs[$self.attr('name')].set(newValue); + return $self; + } } else { - inputs[$self.attr('name')].set(newValue); - return $self; - } - } - else { - if(typeof newValue === 'undefined') { - return call(inputs, 'get'); + if (typeof newValue === 'undefined') { + return call(inputs, 'get'); + } + else { + foreach(newValue, function (value, inputName) { + inputs[inputName].set(value); + }); + return $self; + } } - else { - foreach(newValue, function (value, inputName) { - inputs[inputName].set(value); + }; + + $.fn.inputOnChange = function (callback) { + var $self = $(this); + var inputs = buildFormInputs({$: $self}); + foreach(inputs, function (input) { + input.subscribe('change', function (data) { + callback.call(data.domElement, data.e); }); - return $self; - } - } -}; - -$.fn.inputOnChange = function (callback) { - var $self = $(this); - var inputs = buildFormInputs({ $: $self }); - foreach(inputs, function (input) { - input.subscribe('change', function (data) { - callback.call(data.domElement, data.e); }); - }); - return $self; -}; - -$.fn.inputDisable = function () { - var $self = $(this); - call(buildFormInputs({ $: $self }), 'disable'); - return $self; -}; - -$.fn.inputEnable = function () { - var $self = $(this); - call(buildFormInputs({ $: $self }), 'enable'); - return $self; -}; - -$.fn.inputClear = function () { - var $self = $(this); - call(buildFormInputs({ $: $self }), 'clear'); - return $self; -}; + return $self; + }; + + $.fn.inputDisable = function () { + var $self = $(this); + call(buildFormInputs({$: $self}), 'disable'); + return $self; + }; + + $.fn.inputEnable = function () { + var $self = $(this); + call(buildFormInputs({$: $self}), 'enable'); + return $self; + }; + + $.fn.inputClear = function () { + var $self = $(this); + call(buildFormInputs({$: $self}), 'clear'); + return $self; + }; }(jQuery)); diff --git a/test/index.html b/test/index.html index 3f97eda..e9b8cc6 100644 --- a/test/index.html +++ b/test/index.html @@ -17,6 +17,8 @@ + + @@ -44,6 +46,8 @@ + + diff --git a/test/test-lib.js b/test/test-lib.js index 9886ef6..489881a 100644 --- a/test/test-lib.js +++ b/test/test-lib.js @@ -8,6 +8,7 @@ var generateNameMappedInputValues = function (group, index, defaultValue, overri var defaultObject = {}; defaultObject['group-' + group + '[' + index + '][text-input]'] = defaultValue; defaultObject['group-' + group + '[' + index + '][textarea-input]'] = defaultValue; + defaultObject['group-' + group + '[' + index + '][number-input]'] = defaultValue; defaultObject['group-' + group + '[' + index + '][select-input]'] = defaultValue || null; defaultObject['group-' + group + '[' + index + '][radio-input]'] = defaultValue || null; defaultObject['group-' + group + '[' + index + '][checkbox-input][]'] = defaultValue ? [defaultValue] : []; diff --git a/test/test.js b/test/test.js index c98de9f..54560f3 100644 --- a/test/test.js +++ b/test/test.js @@ -30,7 +30,8 @@ QUnit.test('add item', function (assert) { assert.deepEqual( getNamedInputValues($items.first()), generateNameMappedInputValues('a', 0, 'A', { - "group-a[0][multiple-select-input][]": ['A', 'B'] + "group-a[0][multiple-select-input][]": ['A', 'B'], + "group-a[0][number-input]": '5' }), 'does not clear other inputs' ); @@ -99,7 +100,8 @@ QUnit.test('second repeater add item', function (assert) { assert.deepEqual( getNamedInputValues($items.first()), generateNameMappedInputValues('b', 0, 'A', { - "group-b[0][multiple-select-input][]": ['A', 'B'] + "group-b[0][multiple-select-input][]": ['A', 'B'], + "group-b[0][number-input]": '5' }), 'does not clear other inputs' ); @@ -130,7 +132,8 @@ QUnit.test('multiple add buttons', function (assert) { assert.deepEqual( getNamedInputValues($items.first()), generateNameMappedInputValues('a', 0, 'A', { - "group-a[0][multiple-select-input][]": ['A', 'B'] + "group-a[0][multiple-select-input][]": ['A', 'B'], + "group-a[0][number-input]": '5' }), 'does not clear other inputs' ); @@ -165,7 +168,8 @@ QUnit.test('delete item', function (assert) { assert.deepEqual( getNamedInputValues(this.$repeater), generateNameMappedInputValues('a', 0, 'B', { - "group-a[0][multiple-select-input][]": ['A', 'B'] + "group-a[0][multiple-select-input][]": ['A', 'B'], + "group-a[0][number-input]": '5' }), 'second input remains and reindexed as first element' ); @@ -186,7 +190,8 @@ QUnit.test('delete item that has been added', function (assert) { assert.deepEqual( getNamedInputValues(this.$repeater.find('[data-repeater-item]').last()), generateNameMappedInputValues('a', 1, 'B', { - "group-a[1][multiple-select-input][]": ['A', 'B'] + "group-a[1][multiple-select-input][]": ['A', 'B'], + "group-a[1][number-input]": '5' }), 'second input remains' ); @@ -217,7 +222,8 @@ QUnit.asyncTest('custom hide callback', function (assert) { assert.deepEqual( getNamedInputValues($(this)), generateNameMappedInputValues('a', 0, 'A',{ - "group-a[0][multiple-select-input][]": ['A', 'B'] + "group-a[0][multiple-select-input][]": ['A', 'B'], + "group-a[0][number-input]": '5' }), '"this" is set to first element' ); @@ -260,7 +266,7 @@ QUnit.asyncTest('has ready callback option and setIndexes', function (assert) { }).get(); assert.strictEqual(indeces[0], '0'); - assert.strictEqual(indeces[10], '1'); + assert.strictEqual(indeces[11], '1'); QUnit.start(); } @@ -274,6 +280,7 @@ QUnit.test('repeaterVal', function (assert) { { "text-input": "A", "textarea-input": "A", + "number-input": "5", "select-input": "A", "multiple-select-input": ["A", "B"], "radio-input": "A", @@ -282,6 +289,7 @@ QUnit.test('repeaterVal', function (assert) { { "text-input": "B", "textarea-input": "B", + "number-input": "5", "select-input": "B", "multiple-select-input": ["A", "B"], "radio-input": "B",