Revize d149244c
Přidáno uživatelem Jan Čarnogurský před asi 4 roky(ů)
src/main/webapp/js/assemblyScripts.js | ||
---|---|---|
1 | 1 |
$(document).ready(function() { |
2 | 2 |
|
3 |
// reaction for add/delete parameters from selected fields (row, column, value) |
|
3 | 4 |
$('.select-action-button').on('click', function () { |
5 |
// if input has headlight class (parameter is already added -> remove) |
|
4 | 6 |
if ($(this).hasClass('select-action-headlight')) |
5 | 7 |
{ |
8 |
// remove headlight class from type |
|
6 | 9 |
$(this).removeClass('select-action-headlight'); |
10 |
|
|
11 |
// remove parameter from selected inputs |
|
7 | 12 |
removeParameter(getParameterTitle($(this)), getParameterType($(this))); |
8 | 13 |
} |
9 | 14 |
else |
10 | 15 |
{ |
16 |
// remove headlight from other types for parameter if exists |
|
11 | 17 |
$(this).closest('.select-action-buttons').find('.select-action-button').removeClass('select-action-headlight'); |
12 | 18 |
|
19 |
// remove element from selected inputs if exists |
|
13 | 20 |
removeFromAll(getParameterTitle($(this))); |
14 | 21 |
|
22 |
// headlight selected input |
|
15 | 23 |
$(this).addClass('select-action-headlight'); |
16 | 24 |
|
25 |
// add selected parameter to selected parameters by type |
|
17 | 26 |
addParameter(getParameterIndex($(this)), |
18 | 27 |
getParameterTitle($(this)), |
19 | 28 |
getParameterType($(this)), |
20 | 29 |
getParameterHiddenValue($(this))); |
21 | 30 |
|
31 |
// reinitialize actions for new parameter |
|
22 | 32 |
initParameters(); |
23 | 33 |
} |
24 | 34 |
}); |
25 | 35 |
|
36 |
// init actions |
|
26 | 37 |
initParameters(); |
27 | 38 |
|
28 | 39 |
}); |
29 | 40 |
|
41 |
/** |
|
42 |
* Remove value from all selected fields |
|
43 |
* @param title |
|
44 |
*/ |
|
30 | 45 |
function removeFromAll(title) { |
31 | 46 |
$rows = $('.selected-input-container'); |
32 | 47 |
|
... | ... | |
40 | 55 |
}); |
41 | 56 |
} |
42 | 57 |
|
58 |
/** |
|
59 |
* Returns parameter index |
|
60 |
* @param button |
|
61 |
* @returns {*|jQuery|string|undefined} |
|
62 |
*/ |
|
43 | 63 |
function getParameterIndex(button) { |
44 | 64 |
return $(button).closest('.parameter-row').find('.parameterIndex').val(); |
45 | 65 |
} |
46 | 66 |
|
67 |
/** |
|
68 |
* Adds new parameter to selected fields |
|
69 |
* @param index |
|
70 |
* @param parameterName |
|
71 |
* @param type |
|
72 |
* @param hiddenValue |
|
73 |
*/ |
|
47 | 74 |
function addParameter(index, parameterName, type, hiddenValue) { |
48 | 75 |
var row = document.createElement('tr'); |
49 | 76 |
row.classList.add(type + '-parameter', 'parameter'); |
... | ... | |
102 | 129 |
|
103 | 130 |
} |
104 | 131 |
|
132 |
/** |
|
133 |
* Remove specific parameter from fields by name and container |
|
134 |
* @param title |
|
135 |
* @param parameterClass |
|
136 |
*/ |
|
105 | 137 |
function removeParameter(title, parameterClass) { |
106 | 138 |
$rows = $('.' + parameterClass + '-parameter'); |
107 | 139 |
|
... | ... | |
115 | 147 |
}); |
116 | 148 |
} |
117 | 149 |
|
150 |
/** |
|
151 |
* Base on class returns type |
|
152 |
* @param context |
|
153 |
* @returns {string} |
|
154 |
*/ |
|
118 | 155 |
function getParameterType(context) { |
119 | 156 |
if ($(context).hasClass('column-button')) |
120 | 157 |
{ |
... | ... | |
130 | 167 |
} |
131 | 168 |
} |
132 | 169 |
|
170 |
/** |
|
171 |
* Base on type return integer value |
|
172 |
* @param context |
|
173 |
* @returns {number} |
|
174 |
*/ |
|
133 | 175 |
function getParameterHiddenValue(context) { |
134 | 176 |
if ($(context).hasClass('column-button')) |
135 | 177 |
{ |
... | ... | |
145 | 187 |
} |
146 | 188 |
} |
147 | 189 |
|
190 |
/** |
|
191 |
* Returns parameter name |
|
192 |
* @param context |
|
193 |
* @returns {*|jQuery} |
|
194 |
*/ |
|
148 | 195 |
function getParameterTitle(context) { |
149 | 196 |
return $(context).closest('.parameter-row').find('.parameter-name').text(); |
150 | 197 |
} |
151 | 198 |
|
152 |
|
|
199 |
/** |
|
200 |
* Init base actions |
|
201 |
*/ |
|
153 | 202 |
function initParameters() |
154 | 203 |
{ |
155 | 204 |
$('.sortable').sortable(); |
Také k dispozici: Unified diff
re #7972 - Allow assembly order only for role Administrator, javascript comments