Add JS files
This commit is contained in:
143
modules/Tasks/javascript/EditView.js
Normal file
143
modules/Tasks/javascript/EditView.js
Normal file
@@ -0,0 +1,143 @@
|
||||
$.event.special.inputchange = {
|
||||
setup: function () {
|
||||
var self = this, val;
|
||||
$.data(this, 'timer', window.setInterval(function () {
|
||||
val = self.value;
|
||||
if ($.data(self, 'cache') != val) {
|
||||
$.data(self, 'cache', val);
|
||||
$(self).trigger('inputchange');
|
||||
}
|
||||
}, 20));
|
||||
},
|
||||
teardown: function () {
|
||||
window.clearInterval($.data(this, 'timer'));
|
||||
},
|
||||
add: function () {
|
||||
$.data(this, 'cache', this.value);
|
||||
}
|
||||
};
|
||||
function getDataForAccount(){
|
||||
var ajax_url = "index.php?module=EcmInvoiceOuts&action=javahelper&to_pdf=1";
|
||||
var params = {
|
||||
job : 'getDataForAccount',
|
||||
id : $('#parent_id').val(),
|
||||
|
||||
};
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : ajax_url,
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
console.log(data);
|
||||
if(data[0].tele!=''){
|
||||
console.log(data.tele);
|
||||
$('#InputsWrapper').append('<tr><td><input type="hidden" value="" name="telephones_id[]"><input type="text" size="30" name="telephones[]" id="field_6" value="'+data[0].tele+'"/></td><td><a href="#" class="removeclass"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&themeName=Sugar5&imageName=id-ff-remove.png"></a></td></tr>');
|
||||
}
|
||||
if(data[0].email!=''){
|
||||
$('#InputsWrapperMail').append('<tr><td><input type="hidden" value="" name="emails_id[]"><input type="text" size="30" name="emails[]" id="field_6" value="'+data[0].email+'"/></td><td><a href="#" class="removeclass1"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&themeName=Sugar5&imageName=id-ff-remove.png"></a></td></tr>');
|
||||
}
|
||||
},
|
||||
data : params
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
$('#parent_id').on('inputchange',
|
||||
function () {
|
||||
$(".loading_panel").css("display", "block");
|
||||
setTimeout(function () {
|
||||
getDataForAccount();
|
||||
}, 1000);
|
||||
});
|
||||
var MaxInputs = 10; //maximum input boxes allowed
|
||||
var InputsWrapper = $("#InputsWrapper"); //Input boxes wrapper ID
|
||||
var AddButton = $("#AddMoreWWWBox"); //Add button ID
|
||||
|
||||
var x = InputsWrapper.length; //initlal text box count
|
||||
var FieldCount=1; //to keep track of text box added
|
||||
|
||||
var weblists = $.parseJSON($("input[name='telephones_list']").val()); // get and decode json object
|
||||
|
||||
|
||||
$.each(weblists, function(idx, obj) { // add existing elements
|
||||
FieldCount++; //text box added increment
|
||||
//add input box
|
||||
if(idx == 0 ){ // to first element
|
||||
$( "div input[name='telephones[]']" ).first().val(obj);
|
||||
$( "div input[name='telephones_id[]']" ).first().val(obj.id);
|
||||
} else { // rest
|
||||
$(InputsWrapper).append('<tr><td><input type="hidden" value="'+obj.id+'" name="telephones_id[]"><input type="text" size="30" name="telephones[]" id="field_'+ FieldCount +'" value="'+obj +'"/></td><td><a href="#" class="removeclass"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&themeName=Sugar5&imageName=id-ff-remove.png"></a></td></tr>');
|
||||
}
|
||||
x++; //text box increment
|
||||
|
||||
});
|
||||
|
||||
$(AddButton).click(function (e) //on add input button click
|
||||
{
|
||||
if(x <= MaxInputs) //max input box allowed
|
||||
{
|
||||
FieldCount++; //text box added increment
|
||||
//add input box
|
||||
$(InputsWrapper).append('<tr><td><input type="hidden" value="" name="telephones_id[]"><input type="text" size="30" name="telephones[]" id="field_'+ FieldCount +'" value=""/></td><td><a href="#" class="removeclass"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&themeName=Sugar5&imageName=id-ff-remove.png"></a></td></tr>');
|
||||
x++; //text box increment
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$("body").on("click",".removeclass", function(e){ //user click on remove text
|
||||
console.log("x1: " +x);
|
||||
if( x > 1 ) {
|
||||
$(this).closest('tr').remove();//remove text box
|
||||
x--; //decrement textbox
|
||||
}
|
||||
return false;
|
||||
})
|
||||
|
||||
var MaxInputs1 = 10; //maximum input boxes allowed
|
||||
var InputsWrapper1 = $("#InputsWrapperMail"); //Input boxes wrapper ID
|
||||
var AddButton1 = $("#AddMoreMailBox"); //Add button ID
|
||||
|
||||
var x1 = InputsWrapper1.length; //initlal text box count
|
||||
var FieldCount1=1; //to keep track of text box added
|
||||
|
||||
var emaillists = $.parseJSON($("input[name='emails_list']").val()); // get and decode json object
|
||||
|
||||
|
||||
$.each(emaillists, function(idx, obj) { // add existing elements
|
||||
FieldCount1++; //text box added increment
|
||||
//add input box
|
||||
if(idx == 0 ){ // to first element
|
||||
$( "div input[name='emails[]']" ).first().val(obj);
|
||||
$( "div input[name='emails_id[]']" ).first().val(obj.id);
|
||||
} else { // rest
|
||||
$(InputsWrapper1).append('<tr><td><input type="hidden" value="'+obj.id+'" name="emails_id[]"><input type="text" size="30" name="emails[]" id="field_'+ FieldCount1 +'" value="'+obj +'"/></td><td><a href="#" class="removeclass1"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&themeName=Sugar5&imageName=id-ff-remove.png"></a></td></tr>');
|
||||
}
|
||||
x1++; //text box increment
|
||||
|
||||
});
|
||||
|
||||
$(AddButton1).click(function (e) //on add input button click
|
||||
{
|
||||
if(x1 <= MaxInputs1) //max input box allowed
|
||||
{
|
||||
FieldCount1++; //text box added increment
|
||||
//add input box
|
||||
$(InputsWrapper1).append('<tr><td><input type="hidden" value="" name="emails_id[]"><input type="text" size="30" name="emails[]" id="field_'+ FieldCount1 +'" value=""/></td><td><a href="#" class="removeclass1"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&themeName=Sugar5&imageName=id-ff-remove.png"></a></td></tr>');
|
||||
x1++; //text box increment
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$("body").on("click",".removeclass1", function(e){ //user click on remove text
|
||||
console.log("x1: " +x1);
|
||||
if( x1 > 1 ) {
|
||||
$(this).closest('tr').remove();//remove text box
|
||||
x1--; //decrement textbox
|
||||
}
|
||||
return false;
|
||||
})
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user