symfony-collection-js
Advanced tools
Comparing version 3.0.1 to 3.0.2
{ | ||
"name": "symfony-collection-js", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "A jquery plugin to dynamically create elements of a symfony form collection.", | ||
@@ -5,0 +5,0 @@ "main": "symfonyCollectionJs.js", |
@@ -30,3 +30,2 @@ // Uses CommonJS, AMD or browser globals to create a jQuery plugin. | ||
var settings; | ||
var selector = this.selector; | ||
var eventPrototypeModified = 'prototypeModified'; | ||
@@ -115,3 +114,3 @@ var eventAddMethodCalled = 'addMethodCalled'; | ||
$collection_root.on(eventDeleteMethodCalled, function(e, param){ | ||
$elem = $collection_root.children().eq(param); | ||
var $elem = $collection_root.children().eq(param); | ||
delete_elem($elem); | ||
@@ -136,3 +135,3 @@ settings.post_delete($elem, $.fn.formCollection.POST_DELETE_CONTEXT.DELETE_METHOD); | ||
return obj; | ||
} | ||
}; | ||
@@ -172,3 +171,3 @@ /* | ||
inspect_model_tree($modelNodeChilds.eq(i), currentPath.concat([i]));//concat creates a new array | ||
}; | ||
} | ||
}; | ||
@@ -192,3 +191,3 @@ | ||
$elem.find(settings.btn_up_selector).click(function() { | ||
$switched_elem = move_elem_up($elem); | ||
var $switched_elem = move_elem_up($elem); | ||
if ($switched_elem) { | ||
@@ -199,3 +198,3 @@ settings.post_up($elem, $switched_elem); | ||
$elem.find(settings.btn_down_selector).click(function() { | ||
$switched_elem = move_elem_down($elem); | ||
var $switched_elem = move_elem_down($elem); | ||
if ($switched_elem) { | ||
@@ -249,3 +248,3 @@ settings.post_down($elem, $switched_elem); | ||
newFormHtml = newFormHtml.replace(prototypeNameRegexp, index); | ||
$newForm = $(newFormHtml); | ||
var $newForm = $(newFormHtml); | ||
init_elem_listeners($newForm); | ||
@@ -282,6 +281,6 @@ return $newForm; | ||
var move_elem_up = function($elem) { | ||
$prev = $elem.prev(); | ||
var $prev = $elem.prev(); | ||
if (!$prev) | ||
return false; | ||
newIndex = $prev.index(); | ||
var newIndex = $prev.index(); | ||
$prev.before($elem); | ||
@@ -295,6 +294,6 @@ update_index($elem, newIndex); | ||
var move_elem_down = function($elem) { | ||
$next = $elem.next(); | ||
var $next = $elem.next(); | ||
if (!$next) | ||
return false; | ||
newIndex = $next.index(); | ||
var newIndex = $next.index(); | ||
$next.after($elem); | ||
@@ -308,7 +307,2 @@ update_index($elem, newIndex); | ||
var init_existing = function() { | ||
/* | ||
* the existing nodes have no placeholders. but we need it to update it. | ||
* we need a model to save the attributes formats with placeholdes in the target element | ||
*/ | ||
var $modelElement = $(prototype); | ||
$collection_root.children().each(function() { | ||
@@ -326,7 +320,7 @@ init_elem_listeners($(this)); | ||
if (typeof settings.other_btn_add === 'string') | ||
$otherBtnAdd = $(settings.other_btn_add) | ||
$otherBtnAdd = $(settings.other_btn_add); | ||
else if (settings.other_btn_add instanceof jQuery) | ||
$otherBtnAdd = settings.other_btn_add; | ||
else { | ||
console.log('other_btn_add: bad value, can be a selector or a jQuery object.') | ||
console.log('other_btn_add: bad value, can be a selector or a jQuery object.'); | ||
} | ||
@@ -333,0 +327,0 @@ if ($otherBtnAdd) { |
100035
1136