1function getItemNamespace (elId) { 2 return jQuery('#' + elId).attr('namespace'); 3} 4 5function getItemIndex (elId) { 6 return jQuery('#' + elId).attr('index'); 7} 8 9function initMassActionsOnDatatables(elId){ 10 $('#' + elId + ' [data-check-container]').luCheckAll({ 11 onCheck: function(container, counter) { 12 var massActions = container.find('.lu-t-c__mass-actions'); 13 massActions.find('.lu-value').html(counter); 14 if (counter > 0) { 15 massActions.addClass('is-open'); 16 } else { 17 massActions.removeClass('is-open'); 18 } 19 } 20 }); 21} 22 23function collectTableMassActionsData(elId){ 24 var colectedData = {}; 25 $('#' + elId + ' [data-check-container] tbody input:checkbox.table-mass-action-check:enabled:checked') 26 .each(function(index, value){ 27 colectedData[index] = $(this).val(); 28 }); 29 30 return colectedData; 31} 32 33function uncheckSelectAllCheck(elId){ 34 closeAllSelectMassActions(); 35} 36 37function closeAllSelectMassActions(){ 38 $('.lu-t-c__mass-actions').removeClass('is-open'); 39 $('.table-mass-action-check').prop('checked', false); 40 $('thead input:checkbox:enabled').prop('checked', false); 41} 42 43function initTooltipsForDatatables(elId) { 44 $('#' + elId + ' [data-toggle="lu-tooltip"], [data-tooltip]').luTooltip({}); 45} 46 47function initModalSelects(){ 48 initContainerSelects('mgModalContainer'); 49} 50function initContainerSelects(id) { 51 $('#' + id + ' select:not(.ajax)').each(function(){ 52 if ($(this).attr('bi-event-change')) { 53 var biEventAction = $(this).attr('bi-event-change'); 54 $(this).selectize({ 55 plugins: ['remove_button'], 56 onItemAdd : function(value){ 57 if (biEventAction === 'initReloadModal') { 58 mgPageControler.modalInstance.initReloadModal(); 59 } 60 else if (biEventAction && typeof mgPageControler[biEventAction] === "function") { 61 setTimeout(function(){ 62 mgPageControler[biEventAction](); 63 }, 500); 64 } 65 else if (biEventAction && typeof mgPageControler.vueLoader[biEventAction] === "function") { 66 setTimeout(function(){ 67 mgPageControler.vueLoader[biEventAction](); 68 }, 500); 69 } else if (biEventAction && typeof window[biEventAction] === "function") { 70 setTimeout(function(){ 71 window[biEventAction](); 72 }, 500); 73 } 74 } 75 }); 76 } else { 77 $(this).luSelect({}); 78 } 79 }); 80} 81 82function initModalSwitchEvents(){ 83 $('#mgModalContainer :checkbox').each(function(){ 84 if ($(this).attr('bi-event-change')) { 85 var biEventAction = $(this).attr('bi-event-change'); 86 $(this).change(function() { 87 if (biEventAction && typeof mgPageControler[biEventAction] === "function") { 88 setTimeout(function(){ 89 mgPageControler[biEventAction](); 90 }, 500); 91 } 92 else if (biEventAction && typeof mgPageControler.vueLoader[biEventAction] === "function") { 93 setTimeout(function(){ 94 mgPageControler.vueLoader[biEventAction](); 95 }, 500); 96 } else if (biEventAction && typeof window[biEventAction] === "function") { 97 setTimeout(function(){ 98 window[biEventAction](); 99 }, 500); 100 } 101 }); 102 } 103 }); 104} 105 106function initModalTooltips(){ 107 initContainerTooltips('mgModalContainer'); 108} 109 110function initContainerTooltips(id) { 111 $('#' + id + ' [data-toggle="lu-tooltip"], [data-tooltip]').luTooltip({}); 112} 113 114function mgFormControler(targetFormId) { 115 this.fields = null; 116 this.data = {}; 117 this.formId = targetFormId; 118 119 this.formElement = null; 120 this.formDataObj = null; 121 122 this.loadFormFields = function(){ 123 var that = this; 124 125 jQuery('#'+this.formId).find('input,select,textarea').each(function () { 126 if (!jQuery(this).is(':disabled')) { 127 var name = jQuery(this).attr('name'); 128 129 var value = null; 130 131 if (name !== undefined) { 132 var type = jQuery(this).attr('type'); 133 var regExp = /([a-zA-Z_0-9]+)\[([a-zA-Z_0-9]+)\]/g; 134 var regExpLg = /([a-zA-Z_0-9]+)\[([a-zA-Z_0-9]+)\]\[([a-zA-Z_0-9]+)\]/g; 135 136 if (type === 'checkbox') { 137 var value = 'off'; 138 jQuery('#'+that.formId).find('input[name="'+name+'"]').each(function () { 139 if (jQuery(this).is(':checked')) { 140 value = jQuery(this).val(); 141 } 142 }); 143 } else if (type === 'radio') { 144 if (jQuery(this).is(':checked')) { 145 var value = jQuery(this).val(); 146 } 147 } else if (type === 'file') { 148 var value ={ 149 type: 'file', 150 value: jQuery(this).val() 151 }; 152 } else { 153 var value = jQuery(this).val(); 154 } 155 if (value !== null) { 156 if (result = regExpLg.exec(name)) { 157 if (that.data[result[1]] === undefined) { 158 that.data[result[1]] = {}; 159 } 160 if (that.data[result[1]][result[2]] === undefined) { 161 that.data[result[1]][result[2]] = {}; 162 } 163 that.data[result[1]][result[2]][result[3]] = value; 164 }else if (result = regExp.exec(name)) { 165 if (that.data[result[1]] === undefined) { 166 that.data[result[1]] = {}; 167 } 168 that.data[result[1]][result[2]] = value; 169 } else { 170 that.data[name] = value; 171 } 172 } 173 } 174 } 175 }); 176 }; 177 178 this.getFieldsData = function() { 179 this.formElement = null; 180 this.formDataObj = null; 181 182 this.loadFormFields(); 183 184 var formatedData = new FormData(); 185 for (var key in this.data) { 186 if (!this.data.hasOwnProperty(key)) { 187 continue; 188 } 189 var KeyValue = this.data[key]; 190 if (key.indexOf('[') > 0){ 191 var formatedKey = 'formData[' + key.substring(0, key.indexOf('[')) + ']' + key.substring(key.indexOf('[')); 192 } else { 193 var formatedKey = 'formData[' + key + ']' 194 } 195 196 if(typeof KeyValue === 'object') { 197 if (KeyValue.type === 'file'){ 198 this.addFieldData(formatedData, key, formatedKey, KeyValue); 199 } else{ 200 this.addIteratedData(formatedData, formatedKey, KeyValue); 201 } 202 } else { 203 formatedData.set(formatedKey, KeyValue); 204 } 205 } 206 207 return formatedData; 208 }; 209 210 this.addFieldData = function(formatedData, key, formatedKey, KeyValue){ 211 if (!this.formElement) { 212 this.formElement = document.querySelector("#" + this.formId); 213 this.formDataObj = new FormData(this.formElement); 214 } 215 216 KeyValue = this.formDataObj.get(key); 217 if (typeof KeyValue !== 'object') { 218 formatedData.set(formatedKey, KeyValue); 219 } else { 220 formatedData.set(formatedKey, KeyValue, KeyValue.name); 221 } 222 }; 223 224 this.addIteratedData = function(formatedData, formatedKey, KeyValue){ 225 for (var key in KeyValue) { 226 if (!KeyValue.hasOwnProperty(key)) { 227 continue; 228 } 229 if (typeof KeyValue[key] === 'object') { 230 this.addIteratedData(formatedData, formatedKey + '[' + key + ']', KeyValue[key]); 231 } else { 232 formatedData.set(formatedKey + '[' + key + ']', KeyValue[key]); 233 } 234 } 235 }; 236 237 this.updateFieldsValidationMessages = function(errorsList) { 238 jQuery('#'+this.formId).find('input,select,textarea').each(function () { 239 if (!jQuery(this).is(':disabled')) { 240 var name = jQuery(this).attr('name'); 241 if(name !== undefined && errorsList[name] !== undefined) 242 { 243 if(!jQuery(this).parents('.lu-form-group').first().hasClass('lu-is-error')) { 244 jQuery(this).parents('.lu-form-group').first().addClass('lu-is-error'); 245 } 246 247 var messagePlaceholder = jQuery(this).parents('.lu-form-group').first().children('.lu-form-feedback'); 248 if(jQuery(messagePlaceholder).length > 0) 249 { 250 jQuery(messagePlaceholder).html(errorsList[name].slice(-1)[0]); 251 if(jQuery(messagePlaceholder).attr('hidden')){ 252 jQuery(messagePlaceholder).removeAttr('hidden'); 253 } 254 } 255 }else if(name !== undefined) { 256 if(jQuery(this).parents('.lu-form-group').first().hasClass('lu-is-error')) { 257 jQuery(this).parents('.lu-form-group').first().removeClass('lu-is-error'); 258 } 259 var messagePlaceholder = jQuery(this).parents('.lu-form-group').first().children('.lu-form-feedback'); 260 if(jQuery(messagePlaceholder).length > 0){ 261 jQuery(messagePlaceholder).html(''); 262 if(!jQuery(messagePlaceholder).attr('hidden')){ 263 jQuery(messagePlaceholder).attr('hidden', 'hidden'); 264 } 265 } 266 } 267 } 268 }); 269 }; 270}; 271 272//Sortable 273function tldCategoriesSortableController() 274{
275 var helperHeight = 0; 276 277 //Add sortable for parent categories 278 if (! $('#groupList.vSortable').hasClass('ui-sortable')) 279 { 280 $("#groupList.vSortable").sortable( 281 { 282 items: "li:not(.lu-nav--sub li, .sortable-disabled)", 283 start: function(event, ui) 284 { 285 $(ui.item).find("ul").hide(); 286 $("#groupList").attr("isBeingSorted", "true"); 287 }, 288 stop: function(event, ui) 289 { 290 var order = []; 291 $("#groupList .nav__item").each(function(index, element) 292 { 293 if($(element).hasClass("ui-sortable-placeholder")) 294 { 295 return; 296 } 297 298 var catId = $(element).attr("actionid"); 299 order.push(catId); 300 }); 301 302 mgPageControler.vueLoader.updateSorting(order, 'addCategoryForm', 'ModulesGarden_DNSManager3_App_UI_Widget_DoeTldConfigComponents_CategoryForms_AddCategoryForm'); 303 $(ui.item).css("height", helperHeight); 304 $(ui.item).find("a").css("height", 32); 305 $(ui.item).find("ul").show(); 306 }, 307 sort: function(event, ui) 308 { 309 $( "#groupList" ).sortable( "refreshPositions" ); 310 }, 311 helper: function(event, li) 312 { 313 helperHeight = $(li).css("height"); 314 $(li).css("height", 32); 315 return li; 316 }, 317 }); 318 } 319 320 //Add sortable for children - this has to be refreshed per catego content load 321 $("#groupList.vSortable .nav--sub").sortable( 322 { 323 stop: function(event, ui) 324 { 325 var order = []; 326 $(this).find(".nav__item").each(function(index, element) 327 { 328 if($(element).hasClass("ui-sortable-placeholder")) 329 { 330 return; 331 } 332 333 var catId = $(element).attr("actionid"); 334 order.push(catId); 335 }); 336 337 mgPageControler.vueLoader.updateSorting(order, 'addCategoryForm', 'ModulesGarden_DNSManager3_App_UI_Widget_DoeTldConfigComponents_CategoryForms_AddCategoryForm'); 338 }, 339 }); 340 341 //Add Sortable on table 342 $('#itemContentContainer tbody.vSortable').sortable( 343 { 344 stop: function(event, ui) 345 { 346 var order = []; 347 $("#itemContentContainer tbody").find("tr").each(function(index, element) 348 { 349 if($(element).hasClass("ui-sortable-placeholder")) 350 { 351 return; 352 } 353 354 var catId = $(element).attr("actionid"); 355 order.push(catId); 356 }); 357 mgPageControler.vueLoader.updateSorting(order, 'assignTldForm', 'ModulesGarden_DNSManager3_App_UI_Widget_DoeTldConfigComponents_CategoryForms_AssignTldForm'); 358 }, 359 helper: function(e, tr) 360 { 361 var $originals = tr.children(); 362 var $helper = tr.clone(); 363 $helper.children().each(function(index) 364 { 365 $(this).width($originals.eq(index).width()+100); 366 }); 367 368 return $helper; 369 }, 370 }); 371 372} 373 374 375// CUSTOM FUNCTIONS 376 377//this is example custom action, use it for non-ajax actions 378function custAction1(vueControler, params, event){ 379 console.log('custAction1', vueControler, params, event); 380} 381 382//this is example custom action, use it for ajax actions 383function custAction2(vueControler, params, event){ 384 console.log('custAction2', vueControler, params, event); 385} 386 387function mgEmptyToPause(name, row) { 388 if (!row[name] || row[name] === '') { 389 return '-'; 390 } 391 else { 392 return row[name]; 393 } 394} 395 396function newCall(data) { 397 console.log(data); 398} 399 400function buildOptionTag(text, value, selected, disabled) { 401 var option = document.createElement("option"); 402 option.text = text; 403 option.value = value; 404 if (selected) { 405 option.setAttribute('selected', 'selected'); 406 } 407 if (disabled) { 408 option.setAttribute('disabled', 'disabled'); 409 } 410 411 return option; 412} 413 414function initTaggersForContainer(containerId){ 415 jQuery('#' + containerId + ' .lu-tagger').each(function() 416 { 417 if(!jQuery(this).hasClass('selectize-input')) 418 { 419 $(this).selectize({ 420 plugins: ['restore_on_backspace'], 421 delimiter: ',', 422 persist: false, 423 create: function(input) { 424 return { 425 value: input, 426 text: input 427 } 428 } 429 }); 430 } 431 }); 432} 433 434function initModalTaggers() { 435 initTaggersForContainer('mgModalContainer'); 436} 437 438function initAppTaggers() { 439 initTaggersForContainer('layers'); 440} 441 442mgEventHandler.on('AppCreated', null, function(id, params){ 443 setTimeout(function() { 444 initAppTaggers(); 445 }, 100); 446}, 900); 447 448function copyUrl(vueController, params, event) { 449 let element = $("[name='" + params.fieldname + "']"); 450 let temp = $("<input>"); 451 $("body").append(temp); 452 temp.val(element.val()).select(); 453 document.execCommand("copy"); 454 temp.remove(); 455 vueController.addAlert('success', params.copyTextMessage); 456}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.