Lines 13-18
function addItem( node, unique_item_fields ) {
Link Here
|
13 |
cloneItemBlock(index, unique_item_fields); |
13 |
cloneItemBlock(index, unique_item_fields); |
14 |
addItemInList(index, unique_item_fields); |
14 |
addItemInList(index, unique_item_fields); |
15 |
$("#" + index).find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM || "Update item") ); |
15 |
$("#" + index).find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM || "Update item") ); |
|
|
16 |
$("#"+ index).find("input[name='buttonPlusMulti']").remove(); |
17 |
$("#" + index).find("input[name='multiValue").remove(); |
16 |
$("#quantity").val(current_qty + 1).change(); |
18 |
$("#quantity").val(current_qty + 1).change(); |
17 |
} else if ( current_qty >= max_qty ) { |
19 |
} else if ( current_qty >= max_qty ) { |
18 |
alert(window.MSG_ADDITEM_JS_CANT_RECEIVE_MORE_ITEMS |
20 |
alert(window.MSG_ADDITEM_JS_CANT_RECEIVE_MORE_ITEMS |
Lines 27-32
function addItem( node, unique_item_fields ) {
Link Here
|
27 |
$("#" + index).hide(); |
29 |
$("#" + index).hide(); |
28 |
} |
30 |
} |
29 |
|
31 |
|
|
|
32 |
function addMulti( count, node, unique_item_fields){ |
33 |
var index = $(node).closest("div").attr('id'); |
34 |
var countItemsBefore = $("#items_list tbody tr").length; |
35 |
var current_qty = parseInt( $('#quantity').val(), 10 ); |
36 |
$("#procModal").modal('show'); |
37 |
$("#" + index).hide(); |
38 |
for(var i=0;i<count;i++){ |
39 |
cloneItemBlock(index, unique_item_fields, function(cloneIndex){ |
40 |
addItemInList(cloneIndex,unique_item_fields, function(){ |
41 |
if( ($("#items_list tbody tr").length-countItemsBefore)==(count)){ |
42 |
$("#multiValue").val(''); |
43 |
$('#'+index).show(); |
44 |
$('#'+index + ' #add_multiple_copies' ).css("visibility","hidden"); |
45 |
$("#procModal").modal('hide'); |
46 |
} |
47 |
}); |
48 |
$("#" + cloneIndex).find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM || "Update item ") ); |
49 |
$("#" + cloneIndex).find("input[name='buttonPlusMulti']").remove(); |
50 |
$("#" + cloneIndex).find("input[name='multiValue").remove(); |
51 |
$("#" + cloneIndex).hide(); |
52 |
current_qty++; |
53 |
$('#quantity').val( current_qty ); |
54 |
}); |
55 |
} |
56 |
} |
57 |
|
58 |
|
59 |
function checkCount(node, unique_item_fields){ |
60 |
var count = parseInt( $("#multiValue").val(), 10 ); |
61 |
if ( isNaN( count ) || count <=0) { |
62 |
$("#multiCountModal").modal('show'); |
63 |
} |
64 |
else{ |
65 |
addMulti( count, node, unique_item_fields); |
66 |
} |
67 |
} |
68 |
|
30 |
function showItem(index) { |
69 |
function showItem(index) { |
31 |
$("#outeritemblock").children("div").each(function(){ |
70 |
$("#outeritemblock").children("div").each(function(){ |
32 |
if ( $(this).attr('id') == index ) { |
71 |
if ( $(this).attr('id') == index ) { |
Lines 75-84
function constructTrNode(index, unique_item_fields) {
Link Here
|
75 |
return result; |
114 |
return result; |
76 |
} |
115 |
} |
77 |
|
116 |
|
78 |
function addItemInList(index, unique_item_fields) { |
117 |
function addItemInList(index, unique_item_fields, callback) { |
79 |
$("#items_list").show(); |
118 |
$("#items_list").show(); |
80 |
var tr = constructTrNode(index, unique_item_fields); |
119 |
var tr = constructTrNode(index, unique_item_fields); |
81 |
$("#items_list table tbody").append(tr); |
120 |
$("#items_list table tbody").append(tr); |
|
|
121 |
if (typeof callback === "function"){ |
122 |
callback(); |
123 |
} |
82 |
} |
124 |
} |
83 |
|
125 |
|
84 |
function deleteItemBlock(node_a, index, unique_item_fields) { |
126 |
function deleteItemBlock(node_a, index, unique_item_fields) { |
Lines 105-111
function deleteItemBlock(node_a, index, unique_item_fields) {
Link Here
|
105 |
} |
147 |
} |
106 |
} |
148 |
} |
107 |
|
149 |
|
108 |
function cloneItemBlock(index, unique_item_fields) { |
150 |
function cloneItemBlock(index, unique_item_fields, callback) { |
109 |
var original; |
151 |
var original; |
110 |
if(index) { |
152 |
if(index) { |
111 |
original = $("#" + index); //original <div> |
153 |
original = $("#" + index); //original <div> |
Lines 136-142
function cloneItemBlock(index, unique_item_fields) {
Link Here
|
136 |
/* Add buttons + and Clear */ |
178 |
/* Add buttons + and Clear */ |
137 |
var buttonPlus = "<fieldset class=\"action\">"; |
179 |
var buttonPlus = "<fieldset class=\"action\">"; |
138 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlus" style="cursor:pointer; margin:0 1em;" onclick="addItem(this,\'' + unique_item_fields + '\')" value="' + (window.MSG_ADDITEM_JS_ADDITEM || 'Add item')+ '" />'; |
180 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlus" style="cursor:pointer; margin:0 1em;" onclick="addItem(this,\'' + unique_item_fields + '\')" value="' + (window.MSG_ADDITEM_JS_ADDITEM || 'Add item')+ '" />'; |
139 |
buttonPlus += '<a class="addItemControl cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)">' + (window.MSG_ADDITEM_JS_CLEAR || 'Clear') + '</a>'; |
181 |
buttonPlus += '<input type="button" class="addItemControl cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)" value="' + (window.MSG_ADDITEM_JS_CLEAR || 'Clear')+ '" />'; |
|
|
182 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlusMulti" data-toggle="modal" data-target="#uniqueFieldsModal" onclick="javascript:this.nextSibling.style.visibility=\'visible\';document.f.multiValue.focus(); return false;" style="cursor:pointer; margin:0 1em;" value="' + (window.MSG_ADDITEM_JS_ADDMULTI || 'Add multiple items')+ '" />'; |
183 |
buttonPlus +='<span id="add_multiple_copies" style="visibility:hidden"><input type="textbox" class="addItemControl" id="multiValue" name="multiValue" placeholder="'+window.MSG_ADDITEM_JS_MULTIVAL+'" /><input type="button" class="addItemControl" name=buttonAddMulti" style="cursor:pointer; margin:0 1em;" onclick="checkCount( this ,\'' + unique_item_fields + '\')" value="' + (window.MSG_ADDITEM_JS_SUBMITMULTI || 'Add') + '" /></span>'; |
140 |
buttonPlus += "</fieldset>"; |
184 |
buttonPlus += "</fieldset>"; |
141 |
$(clone).append(buttonPlus); |
185 |
$(clone).append(buttonPlus); |
142 |
/* Copy values from the original block (input) */ |
186 |
/* Copy values from the original block (input) */ |
Lines 161-166
function cloneItemBlock(index, unique_item_fields) {
Link Here
|
161 |
}); |
205 |
}); |
162 |
|
206 |
|
163 |
$("#outeritemblock").append(clone); |
207 |
$("#outeritemblock").append(clone); |
|
|
208 |
if (typeof callback === "function"){ |
209 |
var cloneIndex = "itemblock"+random; |
210 |
callback(cloneIndex); |
211 |
} |
164 |
BindPluginEvents(data); |
212 |
BindPluginEvents(data); |
165 |
} |
213 |
} |
166 |
}); |
214 |
}); |