Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jquery.repeater

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery.repeater - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

12

jquery.repeater.js

@@ -1,4 +0,4 @@

// jquery.repeater version 0.1.6
// jquery.repeater version 0.1.7
// https://github.com/DubFriend/jquery.repeater
// (MIT) 09-11-2014
// (MIT) 16-03-2015
// Brian Detering <BDeterin@gmail.com> (http://www.briandetering.net/)

@@ -720,2 +720,10 @@ (function ($) {

var $firstDeleteButton = $(this).find('[data-repeater-item]')
.first()
.find('[data-repeater-delete]');
if(fig.isFirstItemUndeletable && $firstDeleteButton) {
$firstDeleteButton.remove();
}
var groupName = $list.data('repeater-list');

@@ -722,0 +730,0 @@

6

jquery.repeater.min.js

@@ -1,5 +0,5 @@

// jquery.repeater version 0.1.6
// jquery.repeater version 0.1.7
// https://github.com/DubFriend/jquery.repeater
// (MIT) 09-11-2014
// (MIT) 16-03-2015
// Brian Detering <BDeterin@gmail.com> (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-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,b){var c=[];return g(a,function(a,d,e){c.push(b(a,d,e))}),c},j=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},k=function(a,b,d){return c(a)?i(a,b):j(a,b,d)},l=function(a,b,c){return k(a,function(a){return a[b].apply(a,c||[])})},m=function(a,b){var c=null;return function(){var d=this,e=arguments;null===c&&(c=setTimeout(function(){c=null},a),b.apply(d,e))}},n=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=n(),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},m=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},o=function(a){var b={},c=x(a,b);return c.getType=function(){return"email"},c},p=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("<form>").closest("form").get(0).reset(),a(this).unwrap()})},e.$().change(function(a){d.publishChange(a,this)}),e},q=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("<form>").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:o,password:t,range:v,textarea:y,select:w,"select[multiple]":s,radio:u,checkbox:m,file:p,"file[multiple]":r,hidden:q},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(){-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+'"]')})}))};if(f.is("input, select, textarea"))if(f.is('input[type="button"], button, input[type="submit"]'))i("button",f);else if(f.is("textarea"))i("textarea",f);else if(f.is('input[type="text"]')||f.is("input")&&!f.attr("type"))i("text",f);else if(f.is('input[type="password"]'))i("password",f);else if(f.is('input[type="email"]'))i("email",f);else if(f.is('input[type="url"]'))i("url",f);else if(f.is('input[type="range"]'))i("range",f);else if(f.is("select"))f.is("[multiple]")?i("select[multiple]",f):i("select",f);else if(f.is('input[type="file"]'))f.is("[multiple]")?i("file[multiple]",f):i("file",f);else if(f.is('input[type="hidden"]'))i("hidden",f);else if(f.is('input[type="radio"]'))j("radio",f);else{if(!f.is('input[type="checkbox"]'))throw"invalid input type";j("checkbox",f)}else 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"]');return 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?l(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 l(A({$:b}),"disable"),b},a.fn.inputEnable=function(){var b=a(this);return l(A({$:b}),"enable"),b},a.fn.inputClear=function(){var b=a(this);return l(A({$:b}),"clear"),b}}(jQuery),a.fn.repeater=function(c){return c=c||{},a(this).each(function(){var d=a(this),e=c.show||function(){a(this).show()},f=c.hide||function(a){a()},g=d.find("[data-repeater-list]"),i=g.find("[data-repeater-item]").first().clone().hide(),j=g.data("repeater-list"),l=function(){g.find("[data-repeater-item]").each(function(b){a(this).find("[name]").each(function(){var c=a(this).attr("name").match(/\[[^\]]+\]/g),d=c?h(c).replace(/\[|\]/g,""):a(this).attr("name"),e=j+"["+b+"]["+d+"]"+(a(this).is(":checkbox")?"[]":"");a(this).attr("name",e)})}),g.find("input[name][checked]").removeAttr("checked").prop("checked",!0)};l();var n=function(a,c){var d;d=a.find("[name]").first().attr("name").match(/\[([0-9]*)\]/)[1],a.inputVal(k(c,b,function(b){var c=j+"["+d+"]["+b+"]";return a.find('[name="'+c+'"]').length?c:c+"[]"}))},o=function(){var b=function(b){var d=c.defaultValues;b.find("[name]").each(function(){a(this).inputClear()}),d&&n(b,d)};return function(a){g.append(a),l(),b(a)}}();d.find("[data-repeater-create]").click(m(50,function(){var a=i.clone();o(a),e.call(a.get(0))})),g.on("click","[data-repeater-delete]",m(50,function(){var b=a(this).closest("[data-repeater-item]").get(0);f.call(b,function(){a(b).remove(),l()})}))}),this}}(jQuery);
!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,b){var c=[];return g(a,function(a,d,e){c.push(b(a,d,e))}),c},j=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},k=function(a,b,d){return c(a)?i(a,b):j(a,b,d)},l=function(a,b,c){return k(a,function(a){return a[b].apply(a,c||[])})},m=function(a,b){var c=null;return function(){var d=this,e=arguments;null===c&&(c=setTimeout(function(){c=null},a),b.apply(d,e))}},n=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=n(),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},m=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},o=function(a){var b={},c=x(a,b);return c.getType=function(){return"email"},c},p=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("<form>").closest("form").get(0).reset(),a(this).unwrap()})},e.$().change(function(a){d.publishChange(a,this)}),e},q=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("<form>").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:o,password:t,range:v,textarea:y,select:w,"select[multiple]":s,radio:u,checkbox:m,file:p,"file[multiple]":r,hidden:q},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(){-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+'"]')})}))};if(f.is("input, select, textarea"))if(f.is('input[type="button"], button, input[type="submit"]'))i("button",f);else if(f.is("textarea"))i("textarea",f);else if(f.is('input[type="text"]')||f.is("input")&&!f.attr("type"))i("text",f);else if(f.is('input[type="password"]'))i("password",f);else if(f.is('input[type="email"]'))i("email",f);else if(f.is('input[type="url"]'))i("url",f);else if(f.is('input[type="range"]'))i("range",f);else if(f.is("select"))f.is("[multiple]")?i("select[multiple]",f):i("select",f);else if(f.is('input[type="file"]'))f.is("[multiple]")?i("file[multiple]",f):i("file",f);else if(f.is('input[type="hidden"]'))i("hidden",f);else if(f.is('input[type="radio"]'))j("radio",f);else{if(!f.is('input[type="checkbox"]'))throw"invalid input type";j("checkbox",f)}else 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"]');return 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?l(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 l(A({$:b}),"disable"),b},a.fn.inputEnable=function(){var b=a(this);return l(A({$:b}),"enable"),b},a.fn.inputClear=function(){var b=a(this);return l(A({$:b}),"clear"),b}}(jQuery),a.fn.repeater=function(c){return c=c||{},a(this).each(function(){var d=a(this),e=c.show||function(){a(this).show()},f=c.hide||function(a){a()},g=d.find("[data-repeater-list]"),i=g.find("[data-repeater-item]").first().clone().hide(),j=a(this).find("[data-repeater-item]").first().find("[data-repeater-delete]");c.isFirstItemUndeletable&&j&&j.remove();var l=g.data("repeater-list"),n=function(){g.find("[data-repeater-item]").each(function(b){a(this).find("[name]").each(function(){var c=a(this).attr("name").match(/\[[^\]]+\]/g),d=c?h(c).replace(/\[|\]/g,""):a(this).attr("name"),e=l+"["+b+"]["+d+"]"+(a(this).is(":checkbox")?"[]":"");a(this).attr("name",e)})}),g.find("input[name][checked]").removeAttr("checked").prop("checked",!0)};n();var o=function(a,c){var d;d=a.find("[name]").first().attr("name").match(/\[([0-9]*)\]/)[1],a.inputVal(k(c,b,function(b){var c=l+"["+d+"]["+b+"]";return a.find('[name="'+c+'"]').length?c:c+"[]"}))},p=function(){var b=function(b){var d=c.defaultValues;b.find("[name]").each(function(){a(this).inputClear()}),d&&o(b,d)};return function(a){g.append(a),n(),b(a)}}();d.find("[data-repeater-create]").click(m(50,function(){var a=i.clone();p(a),e.call(a.get(0))})),g.on("click","[data-repeater-delete]",m(50,function(){var b=a(this).closest("[data-repeater-item]").get(0);f.call(b,function(){a(b).remove(),n()})}))}),this}}(jQuery);
{
"name": "jquery.repeater",
"version": "0.1.6",
"version": "0.1.7",
"description": "repeatable form input interface",

@@ -5,0 +5,0 @@ "main": "index.html",

@@ -76,3 +76,7 @@ #Repeater

}
}
},
// (Optional)
// Removes the delete button from the first list item,
// defaults to false.
isFirstItemUndeletable: true
})

@@ -79,0 +83,0 @@ });

{
"name": "repeater",
"version": "0.1.6",
"version": "0.1.7",
"title": "Repeater",

@@ -5,0 +5,0 @@ "author": {

@@ -22,2 +22,10 @@ $.fn.repeater = function(fig) {

var $firstDeleteButton = $(this).find('[data-repeater-item]')
.first()
.find('[data-repeater-delete]');
if(fig.isFirstItemUndeletable && $firstDeleteButton) {
$firstDeleteButton.remove();
}
var groupName = $list.data('repeater-list');

@@ -24,0 +32,0 @@

@@ -221,2 +221,11 @@ QUnit.module('repeater', {

.find('[data-repeater-delete]').click();
});
QUnit.test('isFirstItemUndeletable configuration option', function (assert) {
this.$repeater.repeater({ isFirstItemUndeletable: true });
var $firstDeleteButton = this.$repeater.find('[data-repeater-item]')
.first().find('[data-repeater-delete]');
assert.strictEqual($firstDeleteButton.length, 0, 'first delete button is removed');
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc