Fixed layout

This commit is contained in:
Djamil Legato
2014-09-15 12:19:20 -07:00
parent 3f0db002a8
commit 037e0c0fdd
2 changed files with 3 additions and 2 deletions

View File

@@ -31,7 +31,8 @@
key: this.container.data('grav-dynfields-key') || 'Key', key: this.container.data('grav-dynfields-key') || 'Key',
val: this.container.data('grav-dynfields-value') || 'Value' val: this.container.data('grav-dynfields-value') || 'Value'
}; };
return '' + ' <input type="text" value="" placeholder="' + placeholder.key + '" />' + ' <input type="text" name="' + name + '[]" value="" placeholder="' + placeholder.val + '" />' + ' <span data-grav-remfield class="button fa fa-minus"></span> <span data-grav-addfield class="button fa fa-plus"></span>' + '';
return '' + ' <input type="text" value="" placeholder="' + placeholder.key + '" />' + ' <input type="text" name="' + name + '[]" value="" placeholder="' + placeholder.val + '" />' + ' <span data-grav-remfield class="fa fa-minus"></span> <span data-grav-addfield class="fa fa-plus"></span>' + '';
} }
}; };

View File

@@ -1 +1 @@
!function(a){var b={init:function(){var c=a("[data-grav-dynfields]");b.container=c,c.on("click","[data-grav-addfield]",b.addField.bind(b)),c.on("click","[data-grav-remfield]",b.remField.bind(b)),c.on("keyup","input:not([name])",b.updateFields.bind(b))},addField:function(b,c){c=a(b.target);var d=a('<div class="form-row" />').html(this.layout()),d=a("<div />").html(this.layout());d.insertAfter(c.parent("div"))},remField:function(b,c){c=a(b.target),c.parent("div").remove()},updateFields:function(b,c){c=a(b.target);var d=c.next();d.attr("name",this.getName()+"["+c.val()+"]")},getName:function(){return this.container.data("grav-dynfields")||"generic"},layout:function(){var a=this.getName(),b={key:this.container.data("grav-dynfields-key")||"Key",val:this.container.data("grav-dynfields-value")||"Value"};return' <input type="text" value="" placeholder="'+b.key+'" />'+' <input type="text" name="'+a+'[]" value="" placeholder="'+b.val+'" />'+' <span data-grav-remfield class="button fa fa-minus"></span> <span data-grav-addfield class="button fa fa-plus"></span>'}};a(b.init)}(jQuery); !function(a){var b={init:function(){var c=a("[data-grav-dynfields]");b.container=c,c.on("click","[data-grav-addfield]",b.addField.bind(b)),c.on("click","[data-grav-remfield]",b.remField.bind(b)),c.on("keyup","input:not([name])",b.updateFields.bind(b))},addField:function(b,c){c=a(b.target);var d=a('<div class="form-row" />').html(this.layout());d.insertAfter(c.parent("div"))},remField:function(b,c){c=a(b.target),c.parent("div").remove()},updateFields:function(b,c){c=a(b.target);var d=c.next();d.attr("name",this.getName()+"["+c.val()+"]")},getName:function(){return this.container.data("grav-dynfields")||"generic"},layout:function(){var a=this.getName(),b={key:this.container.data("grav-dynfields-key")||"Key",val:this.container.data("grav-dynfields-value")||"Value"};return' <input type="text" value="" placeholder="'+b.key+'" />'+' <input type="text" name="'+a+'[]" value="" placeholder="'+b.val+'" />'+' <span data-grav-remfield class="fa fa-minus"></span> <span data-grav-addfield class="fa fa-plus"></span>'}};a(b.init)}(jQuery);