| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/imusiccircle/js/ |
Upload File : |
/** https://github.com/ReallyGood/jQuery.duplicate */
$.duplicate = function(){
var body = $('body');
body.off('duplicate');
var templates = {};
var settings = {};
var init = function(){
$('[data-duplicate]').each(function(){
var name = $(this).data('duplicate');
var template = $('<div>').html( $(this).clone(true) ).html();
var options = {};
var min = +$(this).data('duplicate-min');
options.minimum = isNaN(min) ? 1 : min;
options.maximum = +$(this).data('duplicate-max') || Infinity;
options.parent = $(this).parent();
settings[name] = options;
templates[name] = template;
});
body.on('click.duplicate', '[data-duplicate-add]', add);
body.on('click.duplicate', '[data-duplicate-remove]', remove);
};
function add(){
var targetName = $(this).data('duplicate-add');
//var selector = $('[data-duplicate=' + targetName + ']');
//var target = $(selector).last();
//if(!target.length) target = $(settings[targetName].parent);
if(targetName == 'MusicalCV'){
var html = $('#MusicalCVBox').html();
$(this).parent().append(html);
}else{
var html = $('#certBox').html();
if($('input[name="tutor_cert[file][]"]').size() <= 3){
$(this).parent().append(html);
}
}
}
function remove(){
var targetName = $(this).data('duplicate-remove');
var selector = '[data-duplicate=' + targetName + ']';
var target = $(this).parent();
//if(!target.length) target = $(this).siblings(selector).eq(0);
//if(!target.length) target = $(selector).eq($(selector).size()-1);
$('.InstrumentExpSection',target).eq($('.InstrumentExpSection',target).size()-1).remove();
/*
if($(selector).length <= settings[targetName].minimum) {
$(this).trigger('duplicate.error');
return;
}
target.remove();
$(this).trigger('duplicate.remove');*/
}
$(init);
};
$.duplicate();