{I" class:ETI"ProcessedAsset;FI"logical_path;TI"cocoon.js;FI" pathname;TI"^/Users/paulomoura/.rvm/gems/ruby-2.2.0/gems/cocoon-1.2.6/app/assets/javascripts/cocoon.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+¡4ïTI" length;Ti\I" digest;TI"%50668a911ac69114e0706ea5dc068e8c;FI" source;TI"\(function($) { var cocoon_element_counter = 0; var create_new_id = function() { return (new Date().getTime() + cocoon_element_counter++); } var newcontent_braced = function(id) { return '[' + id + ']$1'; } var newcontent_underscord = function(id) { return '_' + id + '_$1'; } $(document).on('click', '.add_fields', function(e) { e.preventDefault(); var $this = $(this), assoc = $this.data('association'), assocs = $this.data('associations'), content = $this.data('association-insertion-template'), insertionMethod = $this.data('association-insertion-method') || $this.data('association-insertion-position') || 'before', insertionNode = $this.data('association-insertion-node'), insertionTraversal = $this.data('association-insertion-traversal'), count = parseInt($this.data('count'), 10), regexp_braced = new RegExp('\\[new_' + assoc + '\\](.*?\\s)', 'g'), regexp_underscord = new RegExp('_new_' + assoc + '_(\\w*)', 'g'), new_id = create_new_id(), new_content = content.replace(regexp_braced, newcontent_braced(new_id)), new_contents = []; if (new_content == content) { regexp_braced = new RegExp('\\[new_' + assocs + '\\](.*?\\s)', 'g'); regexp_underscord = new RegExp('_new_' + assocs + '_(\\w*)', 'g'); new_content = content.replace(regexp_braced, newcontent_braced(new_id)); } new_content = new_content.replace(regexp_underscord, newcontent_underscord(new_id)); new_contents = [new_content]; count = (isNaN(count) ? 1 : Math.max(count, 1)); count -= 1; while (count) { new_id = create_new_id(); new_content = content.replace(regexp_braced, newcontent_braced(new_id)); new_content = new_content.replace(regexp_underscord, newcontent_underscord(new_id)); new_contents.push(new_content); count -= 1; } if (insertionNode){ if (insertionTraversal){ insertionNode = $this[insertionTraversal](insertionNode); } else { insertionNode = insertionNode == "this" ? $this : $(insertionNode); } } else { insertionNode = $this.parent(); } $.each(new_contents, function(i, node) { var contentNode = $(node); insertionNode.trigger('cocoon:before-insert', [contentNode]); // allow any of the jquery dom manipulation methods (after, before, append, prepend, etc) // to be called on the node. allows the insertion node to be the parent of the inserted // code and doesn't force it to be a sibling like after/before does. default: 'before' var addedContent = insertionNode[insertionMethod](contentNode); insertionNode.trigger('cocoon:after-insert', [contentNode]); }); }); $(document).on('click', '.remove_fields.dynamic, .remove_fields.existing', function(e) { var $this = $(this), wrapper_class = $this.data('wrapper-class') || 'nested-fields', node_to_delete = $this.closest('.' + wrapper_class), trigger_node = node_to_delete.parent(); e.preventDefault(); trigger_node.trigger('cocoon:before-remove', [node_to_delete]); var timeout = trigger_node.data('remove-timeout') || 0; setTimeout(function() { if ($this.hasClass('dynamic')) { node_to_delete.remove(); } else { $this.prev("input[type=hidden]").val("1"); node_to_delete.hide(); } trigger_node.trigger('cocoon:after-remove', [node_to_delete]); }, timeout); }); $('.remove_fields.existing.destroyed').each(function(i, obj) { var $this = $(this), wrapper_class = $this.data('wrapper-class') || 'nested-fields'; $this.closest('.' + wrapper_class).hide(); }); })(jQuery); ;TI"dependency_digest;TI"%7c3bc503feb7f4f4604d06bee21bf280;FI"required_paths;T[I"^/Users/paulomoura/.rvm/gems/ruby-2.2.0/gems/cocoon-1.2.6/app/assets/javascripts/cocoon.js;FI"dependency_paths;T[{I" path;TI"^/Users/paulomoura/.rvm/gems/ruby-2.2.0/gems/cocoon-1.2.6/app/assets/javascripts/cocoon.js;F@I"2015-02-26T11:58:41-03:00;T@I"%50668a911ac69114e0706ea5dc068e8c;FI" _version;TI"%64e62ddc273c2f5847f30d698ca14b67;F