1288 |
daniel |
1 |
|
|
|
2 |
(function(jQuery) {
|
|
|
3 |
|
|
|
4 |
jQuery.fn.wpsgInputStaffel = function(options) {
|
|
|
5 |
|
1292 |
daniel |
6 |
if (options == 'close')
|
|
|
7 |
{
|
|
|
8 |
|
|
|
9 |
jQuery("#wpsg_staffel_dialog").dialog('close');
|
|
|
10 |
return;
|
|
|
11 |
|
|
|
12 |
}
|
|
|
13 |
|
1288 |
daniel |
14 |
var settings = jQuery.extend({}, jQuery.fn.wpsgInputStaffel.defaults, options);
|
1292 |
daniel |
15 |
var field_id = this.attr("id");
|
1288 |
daniel |
16 |
|
|
|
17 |
var methods = {
|
|
|
18 |
renderTable: function() {
|
|
|
19 |
|
|
|
20 |
var strHTML = '<table style="width:100%;" borderspacing="0" cellpadding="0">';
|
|
|
21 |
|
|
|
22 |
arStaffelung = Array();
|
|
|
23 |
if (arStaffelung.length > 0)
|
|
|
24 |
{
|
|
|
25 |
|
|
|
26 |
for (var i = 0; i < arStaffelung.length; i ++)
|
|
|
27 |
{
|
|
|
28 |
|
|
|
29 |
var arData = arStaffelung[i];
|
|
|
30 |
|
|
|
31 |
strHTML += '<tr class="row' + i + '">';
|
|
|
32 |
strHTML += '<td style="width:50px;"></td>';
|
|
|
33 |
|
|
|
34 |
if (arData[0] == 0 || arStaffelung.length <= 1)
|
|
|
35 |
strHTML += '<td style="width:150px;">ab <input style="background:transparent; margin-right:5px; width:50px;" class="key" type="text" value="0" readonly="readonly" />' + settings.currency + '</td>';
|
|
|
36 |
else
|
|
|
37 |
strHTML += '<td style="width:150px;">ab <input onblur="arStaffelung[' + i + '][0] = jQuery(this).val(); wpsg_updateStaffelung();" style="margin-right:5px; width:50px;" class="key" type="text" value="' + arData[0] + '" />' + settings.currency + '</td>';
|
|
|
38 |
|
|
|
39 |
strHTML += '<td style="width:150px;"><input onblur="arStaffelung[' + i + '][1] = jQuery(this).val(); wpsg_updateStaffelung();" style="width:50px; margin-right:5px;" class="value" type="text" value="' + arData[1] + '" />' + settings.currency + '</td>';
|
|
|
40 |
|
|
|
41 |
strHTML += '<td style="text-align:right;"><input style="width:100px;" class="button" type="button" value="Entfernen" onclick="wpsg_delStaffelung(\'\', ' + i + ');" /></td>';
|
|
|
42 |
strHTML += '</tr>';
|
|
|
43 |
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
strHTML += '<tr><td colspan="4"> </td></tr>';
|
|
|
49 |
|
|
|
50 |
strHTML += '<tr class="row_neu">';
|
|
|
51 |
strHTML += '<td>Neu:</td>';
|
|
|
52 |
|
|
|
53 |
if (arStaffelung.length == 0)
|
|
|
54 |
strHTML += '<td>ab <input style="background:transparent; margin-right:5px; width:50px;" class="key" type="text" value="0" readonly="readonly" />' + settings.currency + '</td>';
|
|
|
55 |
else
|
|
|
56 |
strHTML += '<td>ab <input style="width:50px; margin-right:5px;" class="key" type="text" value="" />' + settings.currency + '</td>';
|
|
|
57 |
|
|
|
58 |
strHTML += '<td><input style="width:50px; margin-right:5px;" class="value" type="text" value="" />' + settings.currency + '</td>';
|
|
|
59 |
strHTML += '<td style="text-align:right;"><input style="width:100px;" class="button" type="button" value="Hinzufügen" onclick="return wpsg_addStaffelung(\'\');" /></td>';
|
|
|
60 |
strHTML += '</tr>';
|
|
|
61 |
|
|
|
62 |
strHTML += '<tr><td colspan="4"> </td></tr>';
|
|
|
63 |
strHTML += '<tr><td colspan="4" id="wpsg_staffelung_debug"> </td></tr>';
|
|
|
64 |
|
|
|
65 |
strHTML += '<tr>';
|
|
|
66 |
strHTML += '<td colspan="3"> </td>';
|
1292 |
daniel |
67 |
strHTML += '<td style="text-align:right;"><input style="width:100px;" class="button" type="button" onclick="return jQuery(\'#' + field_id + '\').wpsgInputStaffel(\'close\');" value="Schließen" /></td>';
|
1288 |
daniel |
68 |
strHTML += '</tr>';
|
|
|
69 |
|
|
|
70 |
strHTML += '</table>';
|
|
|
71 |
|
|
|
72 |
return strHTML;
|
|
|
73 |
|
|
|
74 |
},
|
|
|
75 |
showDialog: function() {
|
|
|
76 |
|
|
|
77 |
var strHTML = '<div id="wpsg_staffel_dialog" style="display:none;">';
|
|
|
78 |
|
|
|
79 |
strHTML += '<div style="padding:5px;" id="wpsg_staffel_table">' + methods.renderTable() + '</div>';
|
|
|
80 |
strHTML += '</div>';
|
|
|
81 |
|
|
|
82 |
jQuery('body').append(strHTML);
|
|
|
83 |
|
1292 |
daniel |
84 |
jQuery("#wpsg_staffel_dialog").dialog( {
|
|
|
85 |
'dialogClass': 'wp-dialog',
|
1288 |
daniel |
86 |
'modal': true,
|
|
|
87 |
'width': settings.width,
|
|
|
88 |
'height': settings.height,
|
|
|
89 |
'title': settings.title
|
|
|
90 |
} );
|
|
|
91 |
|
|
|
92 |
}
|
|
|
93 |
};
|
|
|
94 |
|
|
|
95 |
if (this.text().trim() == '')
|
|
|
96 |
{
|
|
|
97 |
this.text(wpsg_staffel.empty);
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
this.bind('click', function() {
|
|
|
101 |
|
1292 |
daniel |
102 |
var staffelKey = jQuery(this).text().trim();
|
|
|
103 |
if (staffelKey == wpsg_staffel.empty) staffelKey = '';
|
1288 |
daniel |
104 |
methods.showDialog.apply();
|
|
|
105 |
|
|
|
106 |
} );
|
|
|
107 |
|
|
|
108 |
};
|
|
|
109 |
|
|
|
110 |
jQuery.fn.wpsgInputStaffel.defaults = {
|
|
|
111 |
currency: '€',
|
|
|
112 |
title: wpsg_staffel.title,
|
|
|
113 |
width: 350,
|
|
|
114 |
height: 400
|
|
|
115 |
};
|
|
|
116 |
|
|
|
117 |
})(jQuery);
|