awesome_nested_fields 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- awesome_nested_fields (0.6.1)
4
+ awesome_nested_fields (0.6.2)
5
5
  rails (>= 3.0.0)
6
6
 
7
7
  GEM
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2012 Lailson Bandeira
1
+ Copyright (c) 2011-2013 Lailson Bandeira
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Awesome Nested Fields
1
+ Awesome Nested Fields [![Gem Version](https://badge.fury.io/rb/awesome_nested_fields.png)](http://badge.fury.io/rb/awesome_nested_fields)
2
2
  =====================
3
3
 
4
4
  In Rails, you can create forms that have fields from nested models. For example, if a person has many phone numbers, you can easily create a form that receives data from the person and from a fixed number of phones. However, when you want to allow the person to insert multiple, indefinite phones, you're in trouble: it's [much harder](http://railscasts.com/episodes/196-nested-model-form-part-1) [than it](http://railscasts.com/episodes/197-nested-model-form-part-2) [should be](http://stackoverflow.com/questions/1704142/unobtrusive-dynamic-form-fields-in-rails-with-jquery). Well, not anymore.
@@ -1,3 +1,3 @@
1
1
  module AwesomeNestedFields
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -230,7 +230,7 @@
230
230
  function unescape_html_tags(html) {
231
231
  var e = document.createElement('div');
232
232
  e.innerHTML = html;
233
- return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
233
+ return e.childNodes.length === 0 ? "" : jQuery.trim(e.childNodes[0].nodeValue);
234
234
  }
235
235
 
236
236
  function log(msg) {
@@ -4,4 +4,4 @@
4
4
  * Requires jquery-ujs adapter.
5
5
  * https://github.com/lailsonbm/awesome_nested_fields
6
6
  */
7
- (function(h){var i={beforeInsert:function(q,r){r()},afterInsert:function(q){},beforeRemove:function(q,r){r()},afterRemove:function(q){},itemTemplateSelector:".item.template",emptyTemplateSelector:".empty.template",containerSelector:".items, .container",itemSelector:".item",emptySelector:".empty",addSelector:".add",removeSelector:".remove",newItemIndex:"new_nested_item",unescapeTemplate:true};var d={init:function(q){return this.each(function(){var r=h(this);if(r.data("nested-fields.options")){g("Nested fields already defined for this element. If you want to redefine options, destroy it and init again.");return r}q=h.extend({},i,q);q.itemTemplate=h(q.itemTemplateSelector,r);q.emptyTemplate=h(q.emptyTemplateSelector,r);q.container=h(q.containerSelector,r);q.add=h(q.addSelector,r);r.data("nested-fields.options",q);l(q);b(q,r)})},insert:function(r,q){q=h.extend({},j(this),q);return f(r,q)},remove:function(r,q){q=h.extend({},j(this),q);return e(r,q)},removeAll:function(q){q=h.extend({},j(this),q);h(d.items.apply(this)).each(function(r,s){d.remove(s,q)})},items:function(){return c(j(this))},destroy:function(){h(this).removeData("nested-fields.options");h("*",this).unbind(".nested-fields")}};h.fn.nestedFields=function(q){if(d[q]){return d[q].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof q==="object"||!q){return d.init.apply(this,arguments)}else{h.error("Method "+q+" does not exist on jQuery.nestedFields")}}};function j(r){var q=h(r);while(q.length>0){var s=q.data("nested-fields.options");if(s){return s}else{q=q.parent()}}return null}function l(q){q.add.bind("click.nested-fields",function(r){r.preventDefault();f(null,q)})}function b(q,r){h(q.itemSelector,r).each(function(s,t){k(t,q)})}function m(r){var u=new RegExp(r.newItemIndex,"g");var q=new Date().getTime();var t=r.itemTemplate.html();if(r.unescapeTemplate){t=o(t)}var s=h(t.replace(u,q));s.attr("data-new-record",true);s.attr("data-record-id",q);k(s,r);return s}function f(q,r){var s=m(r);function t(){if(q){q(s)}a(r);r.container.append(s)}if(!r.skipBefore){r.beforeInsert(s,t);if(r.beforeInsert.length<=1){t()}}else{t()}if(!r.skipAfter){r.afterInsert(s)}return s}function a(q){p(q).remove()}function e(t,s){function q(){if(r.attr("data-new-record")){r.remove()}else{r.find("INPUT[name$='[_destroy]']").val("true");r.hide()}n(s)}var r=h(t);if(!s.skipBefore){s.beforeRemove(r,q);if(s.beforeRemove.length<=1){q()}}else{q()}if(!s.skipAfter){s.afterRemove(r)}return r}function n(q){if(c(q).length===0){var r=q.emptyTemplate.html();if(q.unescapeTemplate){r=o(r)}q.container.append(r)}}function k(t,r){var q=h(t).find(r.removeSelector);var u=q.attr("data-confirm");var s=u?"confirm:complete":"click";q.bind(s+".nested-fields",function(v,w){v.preventDefault();if(w===undefined||w===true){e(t,r)}})}function c(q){return q.container.find(q.itemSelector+":visible")}function p(q){return q.container.find(q.emptySelector)}function o(q){var r=document.createElement("div");r.innerHTML=q;return r.childNodes.length===0?"":r.childNodes[0].nodeValue}function g(q){if(console&&console.log){console.log(q)}}})(jQuery);
7
+ (function(h){var i={beforeInsert:function(q,r){r()},afterInsert:function(q){},beforeRemove:function(q,r){r()},afterRemove:function(q){},itemTemplateSelector:".item.template",emptyTemplateSelector:".empty.template",containerSelector:".items, .container",itemSelector:".item",emptySelector:".empty",addSelector:".add",removeSelector:".remove",newItemIndex:"new_nested_item",unescapeTemplate:true};var d={init:function(q){return this.each(function(){var r=h(this);if(r.data("nested-fields.options")){g("Nested fields already defined for this element. If you want to redefine options, destroy it and init again.");return r}q=h.extend({},i,q);q.itemTemplate=h(q.itemTemplateSelector,r);q.emptyTemplate=h(q.emptyTemplateSelector,r);q.container=h(q.containerSelector,r);q.add=h(q.addSelector,r);r.data("nested-fields.options",q);l(q);b(q,r)})},insert:function(r,q){q=h.extend({},j(this),q);return f(r,q)},remove:function(r,q){q=h.extend({},j(this),q);return e(r,q)},removeAll:function(q){q=h.extend({},j(this),q);h(d.items.apply(this)).each(function(r,s){d.remove(s,q)})},items:function(){return c(j(this))},destroy:function(){h(this).removeData("nested-fields.options");h("*",this).unbind(".nested-fields")}};h.fn.nestedFields=function(q){if(d[q]){return d[q].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof q==="object"||!q){return d.init.apply(this,arguments)}else{h.error("Method "+q+" does not exist on jQuery.nestedFields")}}};function j(r){var q=h(r);while(q.length>0){var s=q.data("nested-fields.options");if(s){return s}else{q=q.parent()}}return null}function l(q){q.add.bind("click.nested-fields",function(r){r.preventDefault();f(null,q)})}function b(q,r){h(q.itemSelector,r).each(function(s,t){k(t,q)})}function m(r){var u=new RegExp(r.newItemIndex,"g");var q=new Date().getTime();var t=r.itemTemplate.html();if(r.unescapeTemplate){t=o(t)}var s=h(t.replace(u,q));s.attr("data-new-record",true);s.attr("data-record-id",q);k(s,r);return s}function f(q,r){var s=m(r);function t(){if(q){q(s)}a(r);r.container.append(s)}if(!r.skipBefore){r.beforeInsert(s,t);if(r.beforeInsert.length<=1){t()}}else{t()}if(!r.skipAfter){r.afterInsert(s)}return s}function a(q){p(q).remove()}function e(t,s){function q(){if(r.attr("data-new-record")){r.remove()}else{r.find("INPUT[name$='[_destroy]']").val("true");r.hide()}n(s)}var r=h(t);if(!s.skipBefore){s.beforeRemove(r,q);if(s.beforeRemove.length<=1){q()}}else{q()}if(!s.skipAfter){s.afterRemove(r)}return r}function n(q){if(c(q).length===0){var r=q.emptyTemplate.html();if(q.unescapeTemplate){r=o(r)}q.container.append(r)}}function k(t,r){var q=h(t).find(r.removeSelector);var u=q.attr("data-confirm");var s=u?"confirm:complete":"click";q.bind(s+".nested-fields",function(v,w){v.preventDefault();if(w===undefined||w===true){e(t,r)}})}function c(q){return q.container.find(q.itemSelector+":visible")}function p(q){return q.container.find(q.emptySelector)}function o(q){var r=document.createElement("div");r.innerHTML=q;return r.childNodes.length===0?"":jQuery.trim(r.childNodes[0].nodeValue)}function g(q){if(console&&console.log){console.log(q)}}})(jQuery);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_nested_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-09 00:00:00.000000000 Z
12
+ date: 2013-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  segments:
115
115
  - 0
116
- hash: -40724994690773291
116
+ hash: -2541328998417105626
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements: