git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@72 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
/**
|
|
* * This script depends on jquery.format.js
|
|
*/
|
|
|
|
$(document).ready(function() {
|
|
profind_template.init();
|
|
});
|
|
|
|
profind_template = {
|
|
init: function() {
|
|
profind_template.hideHeaderIfEmpty();
|
|
profind_template.onAppend();
|
|
$(".add").click(function(){
|
|
var template = jQuery.format(jQuery.trim($(this).siblings(".template").val()));
|
|
var place = $(this).parents(".templateFrame:first").children(".templateTarget");
|
|
var i = place.find(".rowIndex").length>0 ? place.find(".rowIndex").max()+1 : 0;
|
|
$(template(i)).appendTo(place);
|
|
profind_template.showHeader(this);
|
|
profind_template.onAppend();
|
|
|
|
return false;
|
|
});
|
|
|
|
$(".remove").live("click", function() {
|
|
if ($(this).siblings(".pk").val() === '') {
|
|
$(this).parents(".templateContent:first").remove();
|
|
} else {
|
|
$(this).siblings(".to_remove").val(1);
|
|
$(this).parents(".templateContent:first").hide();
|
|
}
|
|
profind_template.hideHeaderIfEmpty();
|
|
return false;
|
|
});
|
|
},
|
|
|
|
hideHeaderIfEmpty: function() {
|
|
var place = $('.templateTarget').filter(function(){return $.trim($(this).text())===''});
|
|
$(place).siblings('.templateHead').hide();
|
|
$(place).parents(".templateFrame:first").removeClass('table');
|
|
},
|
|
|
|
showHeader: function(element) {
|
|
var place = $(element).parents(".templateFrame:first");
|
|
$(place).children('.templateHead').show();
|
|
$(place).addClass('table');
|
|
},
|
|
|
|
onAppend: function() {
|
|
|
|
}
|
|
};
|