| Server IP : 68.178.202.69 / Your IP : 216.73.216.122 Web Server : Apache System : Linux 69.202.178.68.host.secureserver.net 3.10.0-1160.139.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Nov 3 13:30:41 UTC 2025 x86_64 User : ikioworld ( 1005) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/ikioworld/www/assets/admin/plugins/ |
Upload File : |
/*
Title: Cozeit More plugin by Yasir Atabani
Documentation: na
Author: Yasir O. Atabani
Website: http://www.cozeit.com
Twitter: @yatabani
MIT License, https://github.com/cozeit/czMore/blob/master/LICENSE.md
*/
(function ($, undefined) {
$.fn.czMore = function (options) {
//Set defauls for the control
var defaults = {
max: 5,
min: 0,
onLoad: null,
onAdd: null,
onDelete: null
};
//Update unset options with defaults if needed
var options = $.extend(defaults, options);
$(this).bind("onAdd", function (event, data) {
options.onAdd.call(event, data);
});
$(this).bind("onLoad", function (event, data) {
options.onLoad.call(event, data);
});
$(this).bind("onDelete", function (event, data) {
options.onDelete.call(event, data);
});
//Executing functionality on all selected elements
return this.each(function () {
var obj = $(this);
var i = obj.children(".recordset").size();
var divPlus = '<div id="btnPlus" />';
var count = '<input id="' + this.id + '_czMore_txtCount" name="' + this.id + '_czMore_txtCount" type="hidden" value="0" size="5" />';
obj.before(count);
var recordset = obj.children("#first");
obj.after(divPlus);
var set = recordset.children(".recordset").children().first();
var btnPlus = obj.siblings("#btnPlus");
btnPlus.css({
'float': 'right',
'border': '0px',
'background-image': 'url("img/add.png")',
'background-position': 'center center',
'background-repeat': 'no-repeat',
'height': '25px',
'width': '25px',
'cursor': 'pointer'
});
if (recordset.length) {
obj.siblings("#btnPlus").click(function () {
var i = obj.children(".recordset").size();
var item = recordset.clone().html();
i++;
item = item.replace(/\[([0-9]\d{0})\]/g, "[" + i + "]");
item = item.replace(/\_([0-9]\d{0})\_/g, "_" + i + "_");
//$(element).html(item);
//item = $(item).children().first();
//item = $(item).parent();
obj.append(item);
loadMinus(obj.children().last());
minusClick(obj.children().last());
if (options.onAdd != null) {
obj.trigger("onAdd", i);
}
obj.siblings("input[name$='czMore_txtCount']").val(i);
return false;
});
recordset.remove();
for (var j = 0; j <= i; j++) {
loadMinus(obj.children()[j]);
minusClick(obj.children()[j]);
if (options.onAdd != null) {
obj.trigger("onAdd", j);
}
}
if (options.onLoad != null) {
obj.trigger("onLoad", i);
}
//obj.bind("onAdd", function (event, data) {
//If you had passed anything in your trigger function, you can grab it using the second parameter in the callback function.
//});
}
function resetNumbering() {
$(obj).children(".recordset").each(function (index, element) {
$(element).find('input:text, input:password, input:file, select, textarea').each(function(){
old_name = this.name;
new_name = old_name.replace(/\_([0-9]\d{0})\_/g, "_" + (index + 1) + "_");
this.id = this.name = new_name;
//alert(this.name);
});
index++
minusClick(element);
});
}
function loadMinus(recordset) {
var divMinus = '<div id="btnMinus" />';
$(recordset).children().first().before(divMinus);
var btnMinus = $(recordset).children("#btnMinus");
btnMinus.css({
'float': 'right',
'border': '0px',
'background-image': 'url("img/remove.png")',
'background-position': 'center center',
'background-repeat': 'no-repeat',
'height': '25px',
'width': '25px',
'cursor': 'poitnter'
});
}
function minusClick(recordset) {
$(recordset).children("#btnMinus").click(function () {
var i = obj.children(".recordset").size();
var id = $(recordset).attr("data-id")
$(recordset).remove();
resetNumbering();
obj.siblings("input[name$='czMore_txtCount']").val(obj.children(".recordset").size());
i--;
if (options.onDelete != null) {
if (id != null)
obj.trigger("onDelete", id);
}
});
}
});
};
})(jQuery);