Lines 12-18
function addItem( node, unique_item_fields ) {
Link Here
|
12 |
if ( current_qty < max_qty - 1 ) |
12 |
if ( current_qty < max_qty - 1 ) |
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 ) ); |
|
|
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).appendTo('#outeritemblock'); |
44 |
$('#'+index).show(); |
45 |
$('#'+index + ' #add_multiple_copies' ).css("visibility","hidden"); |
46 |
$("#procModal").modal('hide'); |
47 |
} |
48 |
}); |
49 |
$("#" + cloneIndex).find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) ); |
50 |
$("#" + cloneIndex).find("input[name='buttonPlusMulti']").remove(); |
51 |
$("#" + cloneIndex).find("input[name='multiValue']").remove(); |
52 |
$("#" + cloneIndex).hide(); |
53 |
current_qty++; |
54 |
$('#quantity').val( current_qty ); |
55 |
}); |
56 |
} |
57 |
} |
58 |
|
59 |
|
60 |
function checkCount(node, unique_item_fields){ |
61 |
var count = parseInt( $("#multiValue").val(), 10 ); |
62 |
if ( isNaN( count ) || count <=0) { |
63 |
$("#multiCountModal").modal('show'); |
64 |
} |
65 |
else{ |
66 |
addMulti( count, node, unique_item_fields); |
67 |
} |
68 |
} |
69 |
|
30 |
function showItem(index) { |
70 |
function showItem(index) { |
31 |
$("#outeritemblock").children("div").each(function(){ |
71 |
$("#outeritemblock").children("div").each(function(){ |
32 |
if ( $(this).attr('id') == index ) { |
72 |
if ( $(this).attr('id') == index ) { |
Lines 75-84
function constructTrNode(index, unique_item_fields) {
Link Here
|
75 |
return result; |
115 |
return result; |
76 |
} |
116 |
} |
77 |
|
117 |
|
78 |
function addItemInList(index, unique_item_fields) { |
118 |
function addItemInList(index, unique_item_fields, callback) { |
79 |
$("#items_list").show(); |
119 |
$("#items_list").show(); |
80 |
var tr = constructTrNode(index, unique_item_fields); |
120 |
var tr = constructTrNode(index, unique_item_fields); |
81 |
$("#items_list table tbody").append(tr); |
121 |
$("#items_list table tbody").append(tr); |
|
|
122 |
if (typeof callback === "function"){ |
123 |
callback(); |
124 |
} |
82 |
} |
125 |
} |
83 |
|
126 |
|
84 |
function deleteItemBlock(node_a, index, unique_item_fields) { |
127 |
function deleteItemBlock(node_a, index, unique_item_fields) { |
Lines 105-111
function deleteItemBlock(node_a, index, unique_item_fields) {
Link Here
|
105 |
} |
148 |
} |
106 |
} |
149 |
} |
107 |
|
150 |
|
108 |
function cloneItemBlock(index, unique_item_fields) { |
151 |
function cloneItemBlock(index, unique_item_fields, callback) { |
109 |
var original; |
152 |
var original; |
110 |
if(index) { |
153 |
if(index) { |
111 |
original = $("#" + index); //original <div> |
154 |
original = $("#" + index); //original <div> |
Lines 136-142
function cloneItemBlock(index, unique_item_fields) {
Link Here
|
136 |
/* Add buttons + and Clear */ |
179 |
/* Add buttons + and Clear */ |
137 |
var buttonPlus = "<fieldset class=\"action\">"; |
180 |
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')+ '" />'; |
181 |
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>'; |
182 |
buttonPlus += '<input type="button" class="addItemControl cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)" value="' + (window.MSG_ADDITEM_JS_CLEAR || 'Clear')+ '" />'; |
|
|
183 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlusMulti" data-toggle="modal" data-target="#uniqueFieldsModal" onclick="javascript:this.nextSibling.style.visibility=\'visible\'; return false;" style="cursor:pointer; margin:0 1em;" value="' + (window.MSG_ADDITEM_JS_ADDMULTI || 'Add multiple items')+ '" />'; |
184 |
buttonPlus +='<span id="add_multiple_copies" style="visibility:hidden"><input type="number" 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>"; |
185 |
buttonPlus += "</fieldset>"; |
141 |
$(clone).append(buttonPlus); |
186 |
$(clone).append(buttonPlus); |
142 |
/* Copy values from the original block (input) */ |
187 |
/* Copy values from the original block (input) */ |
Lines 161-166
function cloneItemBlock(index, unique_item_fields) {
Link Here
|
161 |
}); |
206 |
}); |
162 |
|
207 |
|
163 |
$("#outeritemblock").append(clone); |
208 |
$("#outeritemblock").append(clone); |
|
|
209 |
if (typeof callback === "function"){ |
210 |
var cloneIndex = "itemblock"+random; |
211 |
callback(cloneIndex); |
212 |
} |
164 |
BindPluginEvents(data); |
213 |
BindPluginEvents(data); |
165 |
} |
214 |
} |
166 |
}); |
215 |
}); |
167 |
- |
|
|