|
35 | 35 | */ |
36 | 36 | static checkAndDisplay(components) { |
37 | 37 | return function(condition) { |
38 | | - var elemArray = components instanceof Array ? components : [components]; |
| 38 | + let elemArray = components instanceof Array ? components : [components]; |
39 | 39 | elemArray.forEach(function(elem) { |
40 | 40 | if (condition()) { |
41 | 41 | elem.show() |
42 | 42 | } else { |
43 | 43 | elem.hide() |
| 44 | + elem.hide() |
44 | 45 | } |
45 | 46 | }); |
46 | 47 | } |
|
88 | 89 | * @returns {String} Value of the selected radio option |
89 | 90 | */ |
90 | 91 | static getSelectedRadioGroupOption(component) { |
91 | | - var radioComp = component.find('[type="radio"]'); |
92 | | - for (var i = 0; i < radioComp.length; i++) { |
| 92 | + let radioComp = component.find('[type="radio"]'); |
| 93 | + for (let i = 0; i < radioComp.length; i++) { |
93 | 94 | if ($(radioComp[i]).prop("checked")) { |
94 | 95 | return $(radioComp[i]).val(); |
95 | 96 | } |
|
103 | 104 | */ |
104 | 105 | static initializeEditDialog(editDialogClass) { |
105 | 106 | return function() { |
106 | | - var args = Array.prototype.slice.call(arguments); |
| 107 | + let args = Array.prototype.slice.call(arguments); |
107 | 108 | /** |
108 | 109 | * Initialise the conditional display of the various elements of the dialog. |
109 | 110 | * |
|
130 | 131 | */ |
131 | 132 | static renderSubDialog(container) { |
132 | 133 | return function(dialogPath, callback) { |
133 | | - var args = Array.prototype.slice.call(arguments); |
134 | | - var $container = $(container); |
135 | | - var componentPath = $container.data("componentpath"); |
136 | | - var isDialogRendered = false; |
| 134 | + let args = Array.prototype.slice.call(arguments); |
| 135 | + let $container = $(container); |
| 136 | + let componentPath = $container.data("componentpath"); |
| 137 | + let isDialogRendered = false; |
137 | 138 | if (componentPath && dialogPath) { |
138 | 139 | $container.empty(); |
139 | | - var currentDialogPath = dialogPath + "/cq:dialog.html"; |
| 140 | + let currentDialogPath = dialogPath + "/cq:dialog.html"; |
140 | 141 | if (currentDialogPath.indexOf("/") !== 0) { |
141 | 142 | currentDialogPath = "/mnt/overlay/" + currentDialogPath; |
142 | 143 | } |
143 | | - var actionPath = currentDialogPath + componentPath; |
144 | | - var subDialogResponse = CQ.shared.HTTP.get(actionPath); |
| 144 | + let actionPath = currentDialogPath + componentPath; |
| 145 | + let subDialogResponse = CQ.shared.HTTP.get(actionPath); |
145 | 146 | if (CQ.shared.HTTP.isOk(subDialogResponse)) { |
146 | | - var parser = $(window).adaptTo("foundation-util-htmlparser"), |
| 147 | + let parser = $(window).adaptTo("foundation-util-htmlparser"), |
147 | 148 | html = subDialogResponse.body; |
148 | 149 | parser.parse(html, true).then(function (dialogHtml) { |
149 | | - var $subDialogContent = $(dialogHtml).find('.cq-dialog-content'); |
| 150 | + let $subDialogContent = $(dialogHtml).find('.cq-dialog-content'); |
150 | 151 | $subDialogContent.addClass("guide-dialog"); |
151 | 152 | if ($subDialogContent.length > 0) { |
152 | 153 | isDialogRendered = true; |
|
162 | 163 | } |
163 | 164 |
|
164 | 165 | static handlePatternDropDown(dialog, patternClass, formatClass) { |
165 | | - var patternComponent = dialog.find(patternClass)[0]; |
166 | | - var formatComponent = dialog.find(formatClass)[0]; |
| 166 | + let patternComponent = dialog.find(patternClass)[0]; |
| 167 | + let formatComponent = dialog.find(formatClass)[0]; |
167 | 168 | _managePatternDynamicBehaviour(); |
168 | 169 | patternComponent.addEventListener("change", _managePatternDynamicBehaviour ); |
169 | 170 | function _managePatternDynamicBehaviour() { |
170 | | - var displayPatternSelectedValue = patternComponent.selectedItem.innerHTML; |
171 | | - var patternComponentOptionsNodeList=patternComponent.querySelectorAll('coral-select-item'); |
| 171 | + // below the pattern was compared based on the name rather than the value ("No Pattern" instead of ####.####) which was creating issue in other languages therefore now it has changed to value. |
| 172 | + let displayPatternSelectedValue = patternComponent.selectedItem.value; |
| 173 | + let patternComponentOptionsNodeList=patternComponent.querySelectorAll('coral-select-item'); |
172 | 174 | if(patternComponentOptionsNodeList.length<=2 ){ |
173 | | - //there are 2 default options, "Select" and "custom". |
| 175 | + //there are 2 default options, "Select" and "custom". |
174 | 176 | // For this dropdown to be visible it should have atleast one other option |
175 | | - var patternComponentParentDiv=patternComponent.closest("div"); |
| 177 | + let patternComponentParentDiv=patternComponent.closest("div"); |
176 | 178 | patternComponentParentDiv.setAttribute("hidden", true); |
177 | 179 | }else { |
178 | | - var displayFormatParentDiv=formatComponent.closest("div"); |
| 180 | + let displayFormatParentDiv=formatComponent.closest("div"); |
179 | 181 | switch (displayPatternSelectedValue) { |
180 | | - case "Select" : |
181 | | - case "No Pattern" : |
| 182 | + case "" : |
| 183 | + case "#####################.###############" : |
182 | 184 | displayFormatParentDiv.setAttribute("hidden", true); |
183 | 185 | break; |
184 | 186 | default : |
185 | 187 | displayFormatParentDiv.removeAttribute("hidden"); |
186 | 188 | } |
187 | 189 | } |
188 | | - if(displayPatternSelectedValue!="Custom") { |
| 190 | + if(displayPatternSelectedValue!="custom") { |
189 | 191 | formatComponent.value = patternComponent.value; |
190 | 192 | } |
191 | 193 | } |
192 | 194 | } |
193 | 195 |
|
194 | 196 | static handlePatternFormat(dialog, patternClass, formatClass){ |
195 | 197 |
|
196 | | - var patternComponent = dialog.find(patternClass)[0]; |
197 | | - var formatComponent = dialog.find(formatClass)[0]; |
| 198 | + let patternComponent = dialog.find(patternClass)[0]; |
| 199 | + let formatComponent = dialog.find(formatClass)[0]; |
198 | 200 | _manageFormatChange() |
199 | 201 | formatComponent.addEventListener("change", _manageFormatChange ); |
200 | 202 | function _manageFormatChange(){ |
201 | | - var itemFound=false; |
| 203 | + let itemFound=false; |
202 | 204 | if(formatComponent.value!=patternComponent.value){ |
203 | 205 | patternComponent.items.getAll().forEach(function (item) { |
204 | 206 | if (item.value == formatComponent.value) { |
|
223 | 225 | */ |
224 | 226 | static registerDialogDataTypeValidators(defaultTypeSelector, enumSelector, getSelectedDataType) { |
225 | 227 | return function (dialog) { |
226 | | - var isBoolean = function(value) { |
227 | | - var isBoolean = false; |
| 228 | + let isBoolean = function(value) { |
| 229 | + let isBoolean = false; |
228 | 230 | if (value) { |
229 | | - var lowerCaseValue = value.toLowerCase(); |
| 231 | + let lowerCaseValue = value.toLowerCase(); |
230 | 232 | isBoolean = lowerCaseValue === 'true' || lowerCaseValue === 'false'; |
231 | 233 | } |
232 | 234 | return isBoolean |
|
239 | 241 | }); |
240 | 242 | } |
241 | 243 |
|
242 | | - var dataTypeValidator = function(el) { |
243 | | - var isValid = true; |
244 | | - var value = el.value; |
| 244 | + let dataTypeValidator = function(el) { |
| 245 | + let isValid = true; |
| 246 | + let value = el.value; |
245 | 247 | if (value) { |
246 | | - var dataType = getSelectedDataType(dialog); |
| 248 | + let dataType = getSelectedDataType(dialog); |
247 | 249 | switch (dataType) { |
248 | 250 | case 'number': |
249 | 251 | isValid = !isNaN(value); |
|
264 | 266 | } |
265 | 267 |
|
266 | 268 | static selectElement(tag, selectorValue, bStartsWith, bWithoutTypeHint) { |
267 | | - var $element = null; |
| 269 | + let $element = null; |
268 | 270 | if (bStartsWith) { |
269 | 271 | $element = $(tag + "[name^='" + selectorValue + "']"); |
270 | 272 | } else { |
|
277 | 279 | } |
278 | 280 |
|
279 | 281 | static showComponent(elem, parentWrapper) { |
280 | | - var parentTag = $(elem).closest(parentWrapper); |
| 282 | + let parentTag = $(elem).closest(parentWrapper); |
281 | 283 | if ($(parentTag).is("[hidden]")) { |
282 | 284 | $(parentTag).removeAttr("hidden"); |
283 | 285 | } else { |
|
286 | 288 | } |
287 | 289 |
|
288 | 290 | static hideComponent(elem, parentWrapper) { |
289 | | - var parentTag = $(elem).closest(parentWrapper); |
| 291 | + let parentTag = $(elem).closest(parentWrapper); |
290 | 292 | $(parentTag).attr("hidden", ""); |
291 | 293 | } |
292 | 294 |
|
|
0 commit comments