way2web-clone
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -8,9 +8,10 @@ /** | ||
* @param {object} customEvents | ||
* @param {boolean} customCountOnRemove | ||
* | ||
* @return {object} | ||
*/ | ||
window.Clone = function($scope, customElements, customClasses, customEvents) { | ||
window.Clone = function($scope, customElements, customClasses, customEvents, customCountOnRemove) { | ||
'use strict'; | ||
var version = '0.1.1'; | ||
var version = '0.1.2'; | ||
@@ -32,2 +33,4 @@ var elements = { | ||
var countOnRemove = customCountOnRemove; | ||
/** | ||
@@ -89,2 +92,15 @@ * Get all parameters, and merge it with the default values. | ||
/** | ||
* Set the count on remove. | ||
* | ||
* @param {boolean} customCountOnRemove | ||
* | ||
* @return {object} | ||
*/ | ||
function setCountOnRemove(customCountOnRemove) { | ||
countOnRemove = customCountOnRemove; | ||
return this; | ||
} | ||
/** | ||
@@ -130,4 +146,13 @@ * Clone the element. | ||
function removeElement() { | ||
var $counter = $scope.find(elements.counter); | ||
var $count = $counter.val(); | ||
$(this).closest(elements.removeClone).remove(); | ||
if($(elements.removeClone + ':not(.' + classes.hidden + ')') && countOnRemove) { | ||
$count = $($scope).find(elements.removeClone + ':not(.' + classes.hidden + ')').length; | ||
} | ||
$counter.val($count); | ||
triggerEvent('remove', [$(this)]); | ||
@@ -177,11 +202,12 @@ } | ||
return { | ||
init: init, | ||
scope: $scope, | ||
clone: cloneElement, | ||
remove: removeElement, | ||
setElements: setElements, | ||
setClasses: setClasses, | ||
setEvents: setEvents, | ||
version: version | ||
init: init, | ||
scope: $scope, | ||
clone: cloneElement, | ||
remove: removeElement, | ||
setElements: setElements, | ||
setClasses: setClasses, | ||
setEvents: setEvents, | ||
setCountOnRemove: setCountOnRemove, | ||
version: version | ||
}; | ||
}; |
{ | ||
"name": "way2web-clone", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Clone an element.", | ||
@@ -5,0 +5,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9353
173