1if (typeof(SDT_DATA) == 'undefined') { 2 var SDT_DATA = {}; 3} 4var g_stbServerSideProcessing = false; 5var g_stbServerSideProcessingIsActive = false; 6 7(function(vendor, $, window) { 8 9 var appName = 'Tables'; 10 var dataTableInstances = []; 11 var ruleJSInstances = []; 12 var extraConfig = {}; 13 14 if (!(appName in vendor)) { 15 vendor[appName] = {}; 16 17 vendor[appName].getAppName = (function() { 18 return appName; 19 }); 20 21 vendor[appName].setExtraConfig = (function(param, value) { 22 extraConfig[param] = value; 23 }); 24 25 vendor[appName].getParameterByName = (function(name) { 26 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); 27 28 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 29 results = regex.exec(location.search); 30 31 return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 32 }); 33 34 vendor[appName].replaceParameterByName = (function(url, paramName, paramValue) { 35 var pattern = new RegExp('\\b(' + paramName + '=).*?(&|$)'); 36 if (url.search(pattern) >= 0) { 37 return url.replace(pattern, '$1' + paramValue + '$2'); 38 } 39 return url + (url.indexOf('?') > 0 ? '&' : '?') + paramName + '=' + paramValue; 40 }); 41 42 vendor[appName].getAllTableInstances = (function() { 43 return dataTableInstances; 44 }); 45 46 vendor[appName].removeAllTableInstances = (function() { 47 dataTableInstances = []; 48 }); 49 50 vendor[appName].setTableInstance = (function(instance) { 51 dataTableInstances.push(instance); 52 }); 53 54 vendor[appName].getTableInstanceById = (function(id) { 55 var allTables = this.getAllTableInstances(); 56 57 for (var i = 0; i < allTables.length; i++) { 58 if (allTables[i].table_id == id) { 59 return allTables[i]; 60 } 61 } 62 return false; 63 }); 64 65 vendor[appName].getTableInstanceByViewId = (function(viewId) { 66 var allTables = this.getAllTableInstances(); 67 68 for (var i = 0; i < allTables.length; i++) { 69 if (allTables[i].table_view_id == viewId) { 70 return allTables[i]; 71 } 72 } 73 return false; 74 }); 75 76 vendor[appName].removeTableInstanceByViewId = (function(viewId) { 77 var allTables = this.getAllTableInstances(); 78 79 for (var i = 0; i < allTables.length; i++) { 80 if (allTables[i].table_view_id == viewId) { 81 allTables.splice(i, 1); 82 return true; 83 } 84 } 85 return false; 86 }); 87 88 vendor[appName].getAllRuleJSInstances = (function() { 89 return ruleJSInstances; 90 }); 91 92 vendor[appName].setRuleJSInstance = (function(table) { 93 var rootElem = table.closest('.supsystic-tables-wrap'), 94 viewId = table.data('view-id'); 95 96 ruleJSInstances[viewId] = new ruleJS(rootElem.attr('id')); 97 ruleJSInstances[viewId].instanceTable = table; 98 return ruleJSInstances[viewId]; 99 }); 100 101 vendor[appName].getRuleJSInstance = (function(table) { 102 var allRuleJS = this.getAllRuleJSInstances(), 103 viewId = table.data('view-id'); 104 105 if (!allRuleJS[viewId]) { 106 this.setRuleJSInstance(table); 107 } 108 return allRuleJS[viewId]; 109 }); 110 111 vendor[appName].request = (function(route, data) { 112 if (!$.isPlainObject(route) || !('module' in route) || !('action' in route)) { 113 throw new Error('Request route is not specified.'); 114 } 115 if (!$.isPlainObject(data)) { 116 data = {}; 117 } 118 if ('action' in data) { 119 throw new Error('Reserved field "action" used.'); 120 } 121 data.action = 'supsystic-tables'; 122 123 var url = window.ajaxurl ? window.ajaxurl : ajax_obj.ajaxurl, 124 deferred = $.Deferred(); 125 126 $.post(url, $.extend({}, { 127 route: route 128 }, data)) 129 .done(function(response, textStatus, jqXHR) { 130 if (response.success) { 131 deferred.resolve(response, textStatus, jqXHR); 132 } else { 133 if (data._maxIter) { 134 retryAjax(deferred, url, route, data, 1, data._maxIter); 135 } else { 136 var message = typeof response.message !== 'undefined' ? response.message : 'There are errors during the request.'; 137 138 deferred.reject(message, textStatus, jqXHR); 139 } 140 } 141 }).fail(function(jqXHR, textStatus, errorThrown) { 142 if (data._maxIter) { 143 retryAjax(deferred, url, route, data, 1, data._maxIter); 144 } else { 145 deferred.reject(errorThrown, textStatus, jqXHR); 146 } 147 }); 148 149 function retryAjax(def, url, route, data, curIter, maxIter) { 150 $.post(url, $.extend({}, { 151 route: route 152 }, data)) 153 .done(function(response, textStatus, jqXHR) { 154 if (response.success) { 155 def.resolve(response, textStatus, jqXHR); 156 } else { 157 var message = typeof response.message !== 'undefined' ? response.message : 'There are errors during the request.'; 158 159 retryErrorHandler(def, url, route, data, curIter, maxIter, message, textStatus, jqXHR); 160 } 161 }).fail(function(jqXHR, textStatus, errorThrown) { 162 retryErrorHandler(def, url, route, data, curIter, maxIter, errorThrown, textStatus, jqXHR); 163 }); 164 } 165 166 function retryErrorHandler(def, url, route, data, curIter, maxIter, errorThrown, textStatus, jqXHR) { 167 curIter++;
168 if (curIter < maxIter) { 169 retryAjax(def, url, route, data, curIter, maxIter); 170 } else { 171 def.reject(errorThrown, textStatus, jqXHR); 172 } 173 } 174 175 return deferred.promise(); 176 }); 177 178 vendor[appName].setTableMobileWidth = (function(isMobile) { 179 $('div .supsystic-tables-wrap').each(function() { 180 isMobile = (typeof(isMobile) == 'undefined' ? true : isMobile); 181 var ssDiv = $(this), 182 widthAttr = ssDiv.data('table-width-' + (isMobile ? 'mobile' : 'fixed')); 183 if (typeof(widthAttr) != 'undefined') { 184 ssDiv.css('display', (widthAttr == 'auto' ? 'inline-block' : '')).css('width', widthAttr); 185 } 186 }); 187 }); 188 189 vendor[appName].initTablesOnPage = (function(id) { 190 this._initTablesOnPage(id); 191 }); 192 193 vendor[appName]._initTablesOnPage = (function(id) { 194 var tables = $(typeof id != 'undefined' ? '#supsystic-table-' + id + ':not(.dataTable)' : '.supsystic-table'); 195 if (tables.length == 0) return; 196 if (typeof this._initTablesOnPageWoo === 'function') this._initTablesOnPageWoo(id); 197 198 var self = this, 199 firstTableId = '', 200 firstTableViewId = '', 201 firstTable = '', 202 firstTableWrapper = '', 203 firstTableFirstRow = ''; 204 205 if ($(window).width() <= 991) { 206 self.setTableMobileWidth(); 207 } 208 209 tables.each(function() { 210 self.initializeTable(this, self.showTable, function(table) { 211 // This is used when table is hidden in tabs and can't calculate itself width to adjust on small screens 212 if (table.is(':visible')) { 213 // Fix bug in FF and IE which not supporting max-width 100% for images in td 214 self._calculateImages(table); 215 } else { 216 table.data('isVisible', setInterval(function() { 217 if (table.is(':visible')) { 218 clearInterval(table.data('isVisible')); 219 self._calculateImages(table); 220 } 221 }, 250)); 222 } 223 // Align all tables on page by the columns width depending on the columns width of first table on page 224 if (table.data('align-by-first-table')) { 225 firstTableId = firstTableId || $('.supsystic-table:first').data('id'); 226 firstTable = firstTable || $('#supsystic-table-' + firstTableId); 227 firstTableViewId = firstTable.data('view-id'); 228 firstTableWrapper = firstTableWrapper || firstTable.parents('#supsystic-table-' + firstTableViewId); 229 firstTableFirstRow = firstTable.data('head') ? firstTable.find('thead tr:first-child th') : firstTable.find('tbody tr:first-child td'); 230 231 if (firstTableViewId != table.data('view-id')) { 232 var currentTableWrapper = table.parents('#supsystic-table-' + table.data('view-id')); 233 234 currentTableWrapper.css({ 235 width: firstTableWrapper.get(0).style.width 236 }); 237 table.css({ 238 width: firstTable.get(0).style.width 239 }); 240 currentTableWrapper.find('.supsystic-table').each(function() { 241 var curTable = $(this), 242 curTableFirstRow = curTable.data('head') ? curTable.find('thead tr:first-child th') : curTable.find('tbody tr:first-child td'); 243 244 $.each(curTableFirstRow, function(index, element) { 245 if (firstTableFirstRow[index]) { 246 $(this).width($(firstTableFirstRow[index]).get(0).style.width); 247 } 248 }); 249 }); 250 } 251 } 252 //if row has merged cells no need place header there 253 if (table.data('merged') && table.hasClass('ColWithMergeCellsAlign')) { 254 var mergedData = table.data('merged'); 255 $.each(mergedData, function(index, value) { 256 var rowNumWithMergeCell = value.row; 257 var numForEq = Number(rowNumWithMergeCell) - 1; 258 table.find('tbody tr:eq(' + numForEq + ')').closest('tr').addClass('haveMergedCell'); 259 }); 260 self.setCellAttributes(table.parents('.supsystic-tables-wrap:first').find('.DTFC_LeftWrapper, DTFC_RightWrapper, .dataTables_scrollHead, .dataTables_scrollFoot').find('th, td')); 261 } 262 if (typeof self.getTableInstanceById(table.data('id')).fnAdjustColumnSizing == 'function') { 263 table.trigger('responsive-resize.dt'); 264 setTimeout(function() { 265 table.trigger('responsive-resize.dt'); 266 self.getTableInstanceById(table.data('id')).fnAdjustColumnSizing(false); 267 }, 500); 268 } 269 self.initShortcodesInTable(table); 270 }); 271 //self.initShortcodesInTable($(this)); 272 }); 273 }); 274 275 vendor[appName].initShortcodesInTable = (function(table) { 276 var tableViewId = table.data('view-id'); 277 //google-maps-easy 278 if (typeof(gmpAllMapsInfo) !== 'undefined' && gmpAllMapsInfo && gmpAllMapsInfo.length) { 279 for (var i = 0; i < gmpAllMapsInfo.length; i++) { 280 var mapData = gmpAllMapsInfo[i],
281 map = $('#' + mapData.view_html_id); 282 if (map.length && map.closest('#supsystic-table-' + tableViewId).length) { 283 var mapViewId = mapData.view_id; 284 setTimeout(function(mapData, mapViewId) { 285 g_gmpAllMaps = $.grep(g_gmpAllMaps, function(value) { 286 if (value.getViewId() == mapViewId) { 287 if (mapData.heatmap && mapData.heatmap.coords) { 288 var coord = [], 289 oldCoord = mapData.heatmap.coords; 290 for (var c = 0; c < oldCoord.length; c++) { 291 var data = oldCoord[c]; 292 coord.push(typeof data == 'object' ? data.join(',') : data); 293 } 294 mapData.heatmap.coords = coord; 295 } 296 if (value._mapParams.simple_slider_id) { 297 $('#' + value._mapParams.simple_slider_id).html(value._mapParams.original_slider_html); 298 } 299 } 300 return value.getViewId() != mapViewId; 301 }); 302 gmpInitMapOnPage(mapData); 303 }, 50, mapData, mapViewId); 304 } 305 } 306 $(document).trigger('gmpAmiVarInited'); 307 } 308 //ultimate-maps 309 if (typeof(umsAllMapsInfo) !== 'undefined' && umsAllMapsInfo && umsAllMapsInfo.length) { 310 for (var i = 0; i < umsAllMapsInfo.length; i++) { 311 var mapData = umsAllMapsInfo[i], 312 map = $('#' + mapData.view_html_id); 313 if (map.length && map.closest('#supsystic-table-' + tableViewId).length) { 314 var mapViewId = mapData.view_id; 315 setTimeout(function(mapData, mapViewId) { 316 g_umsAllMaps = $.grep(g_umsAllMaps, function(value) { 317 if (value.getViewId() == mapViewId) { 318 value._mapObj.remove(); 319 } 320 return value.getViewId() != mapViewId; 321 }); 322 umsInitMapOnPage(mapData); 323 }, 600, mapData, mapViewId); 324 } 325 } 326 $(document).trigger('umsAmiVarInited'); 327 } 328 }); 329 330 vendor[appName]._getOriginalImageSizes = (function(img) { 331 var tempImage = new Image(), 332 width, 333 height; 334 if ('naturalWidth' in tempImage && 'naturalHeight' in tempImage) { 335 width = img.naturalWidth; 336 height = img.naturalHeight; 337 } else { 338 tempImage.src = img.src; 339 width = tempImage.width; 340 height = tempImage.height; 341 } 342 return { 343 width: width, 344 height: height 345 }; 346 }); 347 348 vendor[appName]._calculateImages = (function($table) { 349 var self = this, 350 $images = $table.find('img'); 351 if ($images.length > 0 && /firefox|trident|msie/i.test(navigator.userAgent)) { 352 $images.hide(); 353 $.each($images, function(index, el) { 354 var $img = $(this), 355 originalSizes = self._getOriginalImageSizes(this); 356 if ($img.closest('td, th').width() < originalSizes.width) { 357 $img.css('width', '100%'); 358 } 359 }); 360 $images.show(); 361 362 } 363 }); 364 365 vendor[appName].createSpinner = (function(elem) { 366 elem = typeof(elem) != 'undefined' ? elem : false;
367 368 if (elem) { 369 var icon = elem.attr('disabled', true).find('.fa'); 370 371 if (icon) { 372 icon.data('icon', icon.attr('class')); 373 icon.attr('class', 'fa fa-spinner fa-spin'); 374 } 375 } else { 376 return $('<i/>', { 377 class: 'fa fa-spinner fa-spin' 378 }); 379 } 380 }); 381 382 vendor[appName].deleteSpinner = (function(elem) { 383 var icon = elem.attr('disabled', false).find('.fa'); 384 385 if (icon) { 386 icon.attr('class', icon.data('icon')); 387 icon.data('icon', ''); 388 } 389 }); 390 391 vendor[appName].initializeTable = (function(table, callback, finalCallback, reinit, addInstance) { 392 reinit = typeof reinit != 'undefined' ? reinit : {}; 393 addInstance = typeof addInstance != 'undefined' ? addInstance : true; 394 395 var self = this, 396 $table = (table instanceof $ ? table : $(table)), 397 features = $table.data('features'), 398 config = {}, 399 responsiveMode = $table.data('responsive-mode'), 400 searchingSettings = $table.data('searching-settings'), 401 tableInstance = {}, 402 defaultFeatures = { 403 autoWidth: false, 404 info: false, 405 ordering: false, 406 paging: false, 407 responsive: false, 408 searching: false, 409 stateSave: false, 410 bJQueryUI: true, 411 api: true, 412 retrieve: true, 413 processing: true, 414 initComplete: callback, 415 headerCallback: function(thead, data, start, end, display) { 416 $(thead).closest('thead').find('th').each(function() { 417 self.setStylesToCell(this); 418 }); 419 }, 420 footerCallback: function(tfoot, data, start, end, display) { 421 $(tfoot).closest('tfoot').find('th').each(function() { 422 self.setStylesToCell(this); 423 }); 424 }, 425 // order param disable the default table sorting. 426 // it should be here because of Woocommerce addon: 427 // it has no hidden header for tables without header 428 // and in triggers an error during initializing. 429 // order param should be disabled later during sorting activation 430 order: [] 431 }; 432 433 g_stbServerSideProcessing = $table.data('server-side-processing') && $table.data('server-side-processing') == 'on'; 434 435 // Fix for searching by merged cells 436 $table.find('tbody td[data-colspan], tbody td[data-rowspan]').each(function(index, item) { 437 var cell = $(item), 438 cellData = cell.html(); 439 440 // prevent of copy cell data if it contains tags with id attribute - it must be unique on page 441 if (!cellData.toString().match(/<.*?id=['|"].*?['|"].*?>/g)) { 442 var cellOrValue = cell.data('original-value'), 443 cellFormula = cell.data('formula'), 444 cellOrder = cell.data('order'), 445 table = cell.parents('table:first'), 446 colIndex = cell.index(), 447 rowIndex = cell.parents('tr:first').index(), 448 colspan = cell.data('colspan'), 449 rowspan = cell.data('rowspan'); 450 451 for (var i = rowIndex + 1; i <= rowIndex + rowspan; i++) { 452 for (var j = colIndex + 1; j <= colIndex + colspan; j++) { 453 var hiddenCell = table.find('tbody tr:nth-child(' + i + ') td:nth-child(' + j + ')'); 454 455 if (hiddenCell.data('hide') && !$table.data('merged')) { 456 hiddenCell.html(cellData); 457 hiddenCell.data('original-value', cellOrValue); 458 hiddenCell.attr('data-original-value', cellOrValue); 459 hiddenCell.data('order', cellOrder); 460 hiddenCell.attr('data-order', cellOrder); 461 if (cellFormula) { 462 hiddenCell.data('formula', cellFormula); 463 hiddenCell.attr('data-formula', cellFormula); 464 } 465 } 466 } 467 } 468 } 469 }); 470 471 // Set features 472 $.each(features, function() { 473 var featureName = this.replace(/[-_]([a-z])/g, function(g) { 474 return g[1].toUpperCase(); 475 }); 476 config[featureName] = true; 477 }); 478 if ($table.data('search-value') && !config['searching']) { 479 config['searching'] = true; 480 } 481 if (!config['searching'] && (typeof this.setTableAddSearching === 'function')) { 482 config['searching'] = this.setTableAddSearching($table); 483 } 484 if (toeInArray('searching', features) != -1 && searchingSettings) { 485 if (searchingSettings.minChars > 0 || 486 searchingSettings.resultOnly || 487 searchingSettings.strictMatching 488 ) { 489 $.fn.dataTable.ext.search.push(function(settings, data) { 490 var $searchInput = $(settings.nTableWrapper).find('.dataTables_filter input'), 491 searchValue = $searchInput.val(); 492 493 if (searchingSettings.resultOnly && searchValue.length === 0) { 494 if (searchingSettings.showTable) { 495 return false;
496 } 497 return false; 498 } 499 if (searchingSettings.strictMatching) { 500 searchValue = $.fn.dataTable.util.escapeRegex(searchValue); 501 var regExp = new RegExp('^' + searchValue, 'i'); 502 503 for (var i = 0; i < data.length; i++) { 504 var words = data[i].replace(/\s\s+/g, ' ').split(' '); 505 506 for (var j = 0; j < words.length; j++) { 507 if (words[j].match(regExp)) { 508 return true; 509 } 510 } 511 } 512 return false; 513 } else { 514 return data.join(' ').toLowerCase().indexOf(searchValue.toLowerCase()) !== -1 515 } 516 }); 517 $table.on('init.dt', function(event, settings) { 518 if (!settings) { 519 return; 520 } 521 522 var $tableWrapper = $(settings.nTableWrapper), 523 $tableSearchInput = $tableWrapper.find('.dataTables_filter input'), 524 $customInput = $tableSearchInput.clone(); 525 526 $tableSearchInput.replaceWith($customInput); 527 528 $customInput.on('input change', function() { 529 if (!searchingSettings.showTable) { 530 if (searchingSettings.resultOnly && searchingSettings.minChars && (this.value.length < searchingSettings.minChars || !this.value.length)) { 531 $table.hide(); 532 $table.parent().find('.dataTables_paginate').hide(); 533 } else { 534 $table.show(); 535 $table.parent().find('.dataTables_paginate').show(); 536 } 537 } 538 if (searchingSettings.minChars && (this.value.length < searchingSettings.minChars && this.value.length !== 0)) { 539 event.preventDefault(); 540 return false; 541 } 542 $table.api().draw(); 543 }); 544 545 if (searchingSettings.resultOnly && !searchingSettings.showTable) { 546 $table.hide(); 547 $table.parent().find('.dataTables_paginate').hide(); 548 } 549 }); 550 } 551 if (searchingSettings.columnSearch) { 552 var inputTop = (searchingSettings.columnSearchPosition && searchingSettings.columnSearchPosition == 'top'), 553 tPosition = inputTop ? 'thead' : 'tfoot';
554 if (!$table.find('.stbColumnsSearchWrapper').length) { 555 var headerRow = $table.find('thead tr:first').find('th'); 556 if (headerRow.length) { 557 var searchRow = '<tr class="stbColumnsSearchWrapper">', 558 func = inputTop ? 'prepend' : 'append'; 559 for (var i = 0; i < headerRow.length; i++) { 560 var cellItem = $(headerRow[i]), 561 cellClass = '', 562 cellStyle = ''; 563 if (!g_stbServerSideProcessing) { 564 cellStyle = cellItem.is(':visible') ? '' : 'style="display: none;"'; 565 } 566 if (cellItem.hasClass('invisibleCell')) { 567 cellClass = ' class="invisibleCell"' 568 } 569 searchRow += '<th ' + cellClass + cellStyle + '><input class="search-column" type="text" data-column-num="' + i + '"/></th>'; 570 } 571 searchRow += '</tr>'; 572 if ($table.find(tPosition).length == 0) { 573 $table.append($('<' + tPosition + '>')); 574 } 575 $table.find(tPosition)[func](searchRow); 576 } 577 } 578 if ($table.data('auto-index') !== 'off') {
579 $('.stbColumnsSearchWrapper th:first-child input').css({ 580 'visibility': 'hidden' 581 }); 582 } 583 } 584 } 585 if (toeInArray('ordering', features) != -1) { 586 var sortingEnable = ['_all'], 587 sortingDisable = [], 588 aaSorting = [], 589 multipleSorting = $table.data('multiple-sorting'), 590 disableSorting = $table.data('disable-sorting'); 591 592 if (!$table.data('head')) { 593 sortingDisable = ['_all']; 594 } 595 if (disableSorting && disableSorting.length) { 596 sortingDisable = disableSorting; 597 } 598 if (multipleSorting && multipleSorting.length) { 599 aaSorting = multipleSorting; 600 } else { 601 var columnsCount = $table.find('tr:first th').length, 602 sortColumn = $table.data('sort-column') || 0, 603 sortOrder = $table.data('sort-order') || 'asc', 604 columnNumber = sortColumn - 1; 605 606 if (columnNumber >= 0 && columnNumber < columnsCount) { 607 aaSorting.push([columnNumber, sortOrder]); 608 } 609 } 610 // config.aoColumnDefs = [ 611 // { type: 'natural-nohtml-ci', targets: '_all' }, 612 // { "sortable": false, "targets": sortingDisable }, 613 // { "sortable": true, "targets": sortingEnable } 614 // ]; 615 config.aoColumnDefs = {}; 616 config.aaSorting = aaSorting; 617 delete defaultFeatures.order; 618 } 619 if ($table.data('pagination-length')) { 620 var paginationLength = String($table.data('pagination-length')); 621 622 config.aLengthMenu = []; 623 config.aLengthMenu.push(paginationLength.replace('All', -1).split(',').map(Number)); 624 config.aLengthMenu.push(paginationLength.split(',')); 625 } 626 if ($table.data('auto-index') && $table.data('auto-index') !== 'off') { 627 $table.on('draw.dt', function() { 628 var isFirst = true, 629 index = 1; 630 $table.api().column(0).nodes().each(function(cell, i) { 631 var style = window.getComputedStyle(cell); 632 if (isFirst) { 633 index = i + 1; 634 isFirst = false; 635 } 636 if (style.display !== 'none' && !cell.classList.contains('invisibleCell')) { 637 cell.innerHTML = index; 638 index++; 639 } 640 }); 641 }); 642 } 643 644 // Set responsive mode 645 if (responsiveMode == 0) { 646 // Responsive Mode: Standart Responsive Mode 647 var labelStyles = '<style>', 648 id = '#' + $table.attr('id'); 649 650 // Add header data to each response row 651 $table.find('thead th').each(function(index, el) { 652 labelStyles += id + '.oneColumnWithLabels td:nth-of-type(' + (index + 1) + '):before { content: "' + $(this).text() + '"; }'; 653 }); 654 labelStyles += '</style>'; 655 $table.append(labelStyles); 656 657 $(window).on('load resize orientationchange', $table, function(event) { 658 event.preventDefault(); 659 clearTimeout($table.data('resizeTimer')); 660 661 $table.data('resizeTimer', setTimeout(function() { 662 $table.removeClass('oneColumn oneColumnWithLabels'); 663 $table.css('width', '100%'); 664 var tableWidth = $table.width(), 665 wrapperWidth = $table.closest('.supsystic-tables-wrap').width(); 666 if (tableWidth >
666 wrapperWidth || $(window).width() <= 475) { 667 $table.addClass('oneColumn'); 668 669 if ($table.data('head') == 'on') { 670 $table.addClass('oneColumnWithLabels'); 671 } 672 } 673 }, 150)); 674 if (g_stbServerSideProcessing) { 675 $table.find('td').each(function() { 676 $(this).css({ 677 'width': '', 678 'min-width': '' 679 }); 680 }); 681 } 682 }); 683 } else if (responsiveMode === 1) { 684 // Responsive Mode: Automatic Column Hiding 685 config.responsive = { 686 details: { 687 renderer: function(api, rowIdx, columns) { 688 var $table = $(api.table().node()), 689 $subTable = $('<table/>'); 690 691 $.each(columns, function(i, col) { 692 if (col.hidden) { 693 var $cell = $(api.cell(col.rowIndex, col.columnIndex).node()).clone(), 694 markup = '<tr data-dt-row="' + col.rowIndex + '" data-dt-column="' + col.columnIndex + '">'; 695 if ($table.data('head') == 'on') { 696 var tableHeadTr = $(api.table().header()).find('tr:not(.stbColumnsSearchWra
696pper)').eq(0); 697 var $headerContent = tableHeadTr.find('th').eq(col.columnIndex).html(); 698 markup += '<td>'; 699 if ($headerContent) { 700 markup += $headerContent; 701 } 702 markup += '</td>'; 703 } 704 markup += '</tr>'; 705 $cell.after( 706 $('<td>') 707 .addClass('collapsed-cell-holder') 708 .attr('data-cell-row', col.rowIndex) 709 .attr('data-cell-column', col.columnIndex) 710 .hide() 711 ); 712 $subTable.append($(markup).append($cell.addClass('collapsed').show())); 713 } 714 }); 715 return $subTable.is(':empty') ? false : $subTable; 716 } 717 } 718 }; 719 $table.on('responsive-resize.dt', function(event, api, columns) { 720 if (typeof api == 'undefined' || typeof columns == 'undefined') { 721 var tbl = $(this), 722 instance = vendor[appName].getTableInstanceById(tbl.data('id')); 723 724 if (instance) { 725 api = typeof api != 'undefined' ? api : instance.api(); 726 columns = typeof columns != 'undefined' ? columns : instance.api().columns(); 727 } 728 } 729 var autoHiding = [], 730 searchColumn = $table.find('.stbColumnsSearchWra
730pper input.search-column'); 731 for (var i = 0, len = columns.length; i < len; i++) { 732 autoHiding[i] = columns[i] ? 1 : 0; 733 } 734 $table.find('th input.search-column').each(function() { 735 var th = $(this).parents('th:first'), 736 i = th.index(); 737 if (columns.length > i) { 738 th.css('display', columns[i] ? '' : 'none'); 739 } 740 }); 741 if (typeof columns[0] == 'boolean') { 742 $table.attr('data-auto-hiding', autoHiding.join()); 743 } 744 if ($table.width() > $table.parent().width()) { 745 $table.css('width', '100%'); 746 $table.css('max-width', '100%'); 747 api.responsive.recalc(); 748 return; 749 } 750 for (var i = 0, len = columns.length; i < len; i++) { 751 if (columns[i]) { 752 $table.find('tr > td.collapsed-cell-holder[data-cell-column="' + i + '"]').each(function(index, el) { 753 var $this = $(this); 754 var $cell = $(api.cell( 755 $this.data('cell-row'), 756 $this.data('cell-column') 757 ).node()); 758 759 if ($cell.hasClass('collapsed')) { 760 $cell.removeClass('collapsed'); 761 $this.replaceWith($cell); 762 } 763 }); 764 } 765 } 766 if ($table.data('merged')) { 767 // if has merged cells remove them, with autohidding they not working 768 $table.find('td[data-hide]').show(); 769 $table.find('td[data-rowspan]').attr({ 770 'data-rowspan': 1, 771 rowspan: 1, 772 'data-colspan': 1, 773 colspan: 1 774 }); 775 } 776 }); 777 } else if (responsiveMode === 2) { 778 // Responsive Mode: Horizontal Scroll 779 config.scrollX = true; 780 config.bAutoWidth = false; 781 var firstRow = $table.find('tbody tr:first-child td'); 782 if (firstRow.length) { 783 var cntCols = firstRow.length; 784 $table.find('thead tr:first-child th').each(function(i, th) { 785 if (cntCols > i && $(th).css('width')) { 786 firstRow.eq(i).css('width', $(th).css('width')); 787 } 788 }); 789 } 790 } 791 if (responsiveMode === 2 || responsiveMode === 3) { 792 // Responsive Mode: 2 - Horizontal Scroll, 3 - Disable Responsivity 793 var fixedHead = $table.data('head') && $table.data('fixed-head'), 794 fixedFoot = $table.data('foot') && $table.data('fixed-foot'), 795 fixedLeft = $table.data('fixed-left'), 796 fixedRight = $table.data('fixed-right'); 797 798 // TODO: correct the code to set fixed header and fixed footer in the standard way 799 // TODO: https://datatables.net/extensions/fixedheader/#Features 800 //config.fixedHeader = { 801 // header: false, 802 // footer: false 803 //}; 804 //if (fixedHead) { 805 // config.fixedHeader.header = true; 806 //} 807 //if (fixedFoot) { 808 // config.fixedHeader.footer = true; 809 //} 810 if (fixedHead || fixedFoot) { 811 config.scrollY = $table.data('fixed-height'); 812 config.scrollCollapse = true; 813 } 814 if ($table.data('fixed-cols')) { 815 config.fixedColumns = { 816 leftColumns: fixedLeft ? parseInt(fixedLeft) : 0, 817 rightColumns: fixedRight ? parseInt(fixedRight) : 0 818 }; 819 config.scrollX = true; 820 } 821 } 822 823 //$table.find('.invisibleCell').siblings('td').addClass('invisibleCell'); 824 825 // Add translation 826 var langData = typeof g_stbTblLangData != 'undefined' ? JSON.parse(g_stbTblLangData) : $table.data('translation'), 827 translation = langData || {}, 828 override = $table.data('override'); 829 830 if (typeof translation != 'object') { 831 translation = {}; // for just to be sure that it is object 832 } 833 $.each(override, function(key, value) { 834 if (value.length) { 835 translation[key] = value; 836 // We need to support old DT format, cuz some languages use it 837 translation['s' + key.charAt(0).toUpperCase() + key.substr(1)] = value; 838 } 839 }); 840 config.language = translation; 841 842 var ajaxSource = {}; 843 844 if (g_stbServerSideProcessing) { 845 var nonce = (typeof DTGS_NONCE !== "undefined") ? DTGS_NONCE : DTGS_NONCE_FRONTEND; 846 var route = { 847 "action": "getPageRows", 848 "module": "tables", 849 "nonce": nonce 850 }, 851 loadedRows = [], 852 loadedCells = [], 853 headerRowsCount = ($table.data('head') == 'on' ? $table.data('head-rows-count') : 0), 854 footerRowsCount = ($table.data('foot') == 'on' ? $table.data('foot-custom-rows-count') : 0); 855 ajaxSource = { 856 processing: true, 857 serverSide: true, 858 ajax: { 859 url: window.ajaxurl ? window.ajaxurl : ajax_obj.ajaxurl, 860 type: 'POST', 861 data: { 862 action: "supsystic-tables", 863 route: route, 864 id: $table.data('id'), 865 searchParams: searchingSettings, 866 searchValue: function() { 867 var input = $('#' + $table.attr('id') + '_filter.dataTables_filter').find('input'); 868 return (input.length ? input.val() : ''); 869 }, 870 header: headerRowsCount, 871 footer: footerRowsCount, 872 beforeSend: function() { 873 g_stbServerSideProcessingIsActive = true; 874 } 875 }, 876 dataFilter: function(data) { 877 var json = jQuery.parseJSON(data), 878 rows = $(json.rows).find('tr'), 879 aData = []; 880 881 loadedRows = []; 882 loadedCells = []; 883 for (var i = 0; i < rows.length; i++) { 884 var row = rows[i]; 885 loadedRows.push(row.attributes); 886 var cells = $(row).find('td'), 887 attrs = [], 888 vals = []; 889 for (var j = 0; j < cells.length; j++) { 890 var cell = cells[j]; 891 attrs.push(cell.attributes); 892 vals.push(cell.innerHTML); 893 } 894 loadedCells.push(attrs); 895 aData.push(vals); 896 } 897 json.rows = ''; 898 json.data = aData; 899 g_stbServerSideProcessingIsActive = false;
900 return JSON.stringify(json); 901 } 902 }, 903 createdRow: function(row, data, dataIndex) { 904 if (typeof(loadedRows[dataIndex]) != 'undefined') { 905 $(loadedRows[dataIndex]).each(function() { 906 $(row).attr(this.name, this.value); 907 }); 908 } 909 } 910 }; 911 if (typeof(config.aoColumnDefs) == 'undefined' || jQuery.isEmptyObject(config.aoColumnDefs)) { 912 config.aoColumnDefs = []; 913 } 914 config.aoColumnDefs.push({ 915 targets: '_all', 916 cellType: 'td', 917 createdCell: function(td, cellData, rowData, row, col) { 918 if (typeof(loadedCells[row][col]) != 'undefined') { 919 var rowspan = 1, 920 colspan = 1; 921 $(loadedCells[row][col]).each(function() { 922 if (this.name == 'data-rowspan' && this.value > 1) { 923 rowspan = this.value; 924 } 925 if (this.name == 'data-colspan' && this.value > 1) { 926 colspan = this.value; 927 } 928 }); 929 if (rowspan > 1 || colspan > 1) { 930 var stopRow = row + parseInt(rowspan), 931 stopCol = col + parseInt(colspan), 932 startRow = colspan > 1 ? row : row + 1, 933 hide; 934 if (stopRow >= loadedCells.length) { 935 stopRow = loadedCells.length; 936 } 937 if (stopCol >= loadedCells[row].length) { 938 stopCol = loadedCells[row].length; 939 } 940 941 for (i = startRow; i < stopRow; i++) { 942 if (i > row) { 943 hide = document.createAttribute('data-hide'); 944 hide.value = 'true'; 945 loadedCells[i][col].setNamedItem(hide); 946 } 947 for (j = col + 1; j < stopCol; j++) { 948 hide = document.createAttribute('data-hide'); 949 hide.value = 'true'; 950 loadedCells[i][j].setNamedItem(hide); 951 } 952 } 953 } 954 $(loadedCells[row][col]).each(function() { 955 //if(this.name != 'data-formula') { 956 $(td).attr(this.name, this.value); 957 //} 958 }); 959 } 960 } 961 }); 962 } 963 $table.trigger('beforeInitializeTable', $table); 964 var dateFormat = $table.data('date-format'); 965 $table.dataTable.moment(dateFormat); 966 jQuery.fn.dataTable.ext.order.intl(); 967 tableInstance = $table.dataTable($.extend({}
967, defaultFeatures, config, extraConfig, ajaxSource, reinit));; 968 tableInstance.table_id = $table.data('id'); 969 tableInstance.table_view_id = $table.data('view-id'); 970 tableInstance.fnFakeRowspan(); 971 self._checkOnClickPopups($table); 972 window.table = $table; 973 if ($table.data('remove-rows')) { 974 975 $(function() { 976 977 $.contextMenu({ 978 selector: '.dataTable td', 979 animation: { 980 duration: 250, 981 show: 'fadeIn', 982 hide: 'fadeOut' 983 }, 984 callback: function(key, options) { 985 var m = "clicked: " + key; 986 }, 987 items: { 988 "remove_row": { 989 name: "Remove row", 990 callback: function(itemKey, opt, e) { 991 contextMenuAction(this, 'remove_row'); 992 } 993 }, 994 "add_row_before": { 995 name: "Add row before", 996 callback: function(itemKey, opt, e) { 997 contextMenuAction(this, 'add_row', 'before'); 998 } 999 }, 1000 "add_row_after": { 1001 name: "Add row after", 1002 callback: function(itemKey, opt, e) { 1003 contextMenuAction(this, 'add_row', 'after'); 1004 } 1005 }, 1006 "sep1": "---------", 1007 "quit": { 1008 name: "Quit" 1009 } 1010 } 1011 }); 1012 1013 function contextMenuAction(e, action, second) { 1014 var coltext = e.text(); 1015 var colvindex = e.parent().children().index(e); 1016 var colindex = $('table.dataTable thead tr th:eq(' + colvindex + ')').data('column-index'); 1017 1018 /* Global var for counter */ 1019 var giCount = 1; 1020 switch (action) { 1021 case "remove_row": 1022 $table.fnDeleteRow(e.parent('tr')); 1023 $table.fnUpdate(); 1024 break; 1025 case "add_row": 1026 var tr = e.parent('tr').clone(true, true); 1027 tr.find('td').html('').addClass('menu-injected').addClass('editable').addClass('justCloned'); 1028 tr.find('td').data('original-value', '').attr('data-original-value', ''); 1029 var order = tr.find('td').data('order'); 1030 if (second == 'before') { 1031 order = order - 1; 1032 tr.find('td').data('order', order).attr('data-order', order); 1033 } else { 1034 order = order + 1; 1035 tr.find('td').data('order', order).attr('data-order', order); 1036 } 1037 tr.find('td').data('cell-type', 'text').attr('data-cell-type', 'text'); 1038 tr.find('td').data('cell-format-type', '').attr('data-cell-format-type', ''); 1039 $table.append(tr); 1040 $table.fnAddData(tr, true); 1041 tr.find('td.justCloned').data('y', '9999').attr('data-y', '9999').removeClass('justCloned'); 1042 // $table.fnUpdate(); 1043 // $table.trigger('draw.dt'); 1044 break; 1045 } 1046 } 1047 1048 }); 1049 1050 } 1051 1052 if (g_stbServerSideProcessing) { 1053 jQuery('.dataTables_processing').css('z-index', '10'); 1054 } else { 1055 self.setColumnSearch($table); 1056 } 1057 $table.on('draw.dt', function() { 1058 var searching = $table.data('searching-settings'); 1059 if (searching && ('columnSearch' in searching) && searching.columnSearch == 'on') { 1060 self.setColumnSearch($table); 1061 } 1062 if (!g_stbServerSideProcessing && $table.data('merged')) { 1063 tableInstance.fnResetFakeRowspan(); 1064 } 1065 self.initShortcodesInTable($table); 1066 }); 1067 if (responsiveMode === 1) { 1068 $table.on('responsive-resize.dt', function(event, api, columns) { 1069 if (!g_stbServerSideProcessing && $table.data('merged')) { 1070 tableInstance.fnResetFakeRowspan(); 1071 } 1072 }); 1073 } 1074 if (typeof $table.data('fixed-cols') !== 'undefined') { 1075 tableInstance.api().fixedColumns().update(); 1076 } 1077 if (addInstance) { 1078 this.setTableInstance(tableInstance); 1079 } 1080 return typeof finalCallback == "function" ? finalCallback(tableInstance) : tableInstance; 1081 }); 1082 1083 /** Callback for displaying table after initializing 1084 * @param {object} settings - DataTables settings object 1085 * @param {object} json - JSON data retrieved from the server if the ajax option was set. Otherwise undefined. 1086 */ 1087 vendor[appName].showTable = (function(settings, json) { 1088 var self = vendor[appName], // it is callback so "this" does not equal vendor[appName] object 1089 $table = this instanceof $ ? this : settings, // for compatibility with old pro versions 1090 $tableWrap = $table.closest('.supsystic-tables-wrap'), 1091 tableSelector = '#supsystic-table-' + $table.data('view-id') + ' #supsystic-table-' + $table.data('id'), 1092 afterTableLoadedScriptString = $table.attr('data-after-table-loaded-script'), 1093 _ruleJS = self.setRuleJSInstance($table), 1094 responsiveMode = $table.data('responsive-mode'), 1095 fixedHeader = $table.data('fixed-head') == 'on', 1096 fixedFooter = $table.data('fixed-foot') == 'on', 1097 fixedColumns = $table.data('fixed-right') > 0 || $table.data('fixed-left') > 0, 1098 viewId = $table.data('view-id'); 1099 1100 // Apply custom CSS styles, which have been set through the table editor 1101 $table.find('th, td').each(function() { 1102 self.setStylesToCell(this); 1103 }); 1104 $table.bind('column-visibility.dt draw.dt', function(e) { 1105 $(this).find('th, td').each(function() { 1106 self.setStylesToCell(this); 1107 }); 1108 }); 1109 1110 // Remove sorting visual elements from the tags if there is no header on table 1111 if (!$table.data('head')) { 1112 $table.find('th').removeClass('sorting sorting_asc sorting_desc sorting_disabled'); 1113 } 1114 1115 // Calculate formulas 1116 _ruleJS.init(); 1117 1118 // Set formats 1119 self.formatDataAtTable($table, true); 1120 1121 1122 // Apply shortcode param "search" 1123 if ($table.data('search-value')) { 1124 $table.api().search($table.data('search-value')).draw(); 1125 } 1126
1127 // Show comments on tap 1128 if ('ontouchstart' in window || navigator.msMaxTouchPoints) { 1129 $table.parents('.supsystic-tables-wrap:first').find('td, th').on('click', self.applyMobileTableComments); 1130 } 1131 1132 // Prepare Contact Form by Supsystic buttons 1133 $table.parents('.supsystic-tables-wrap:first').find('th, td').each(self._contactFormBtnCellClb); 1134 1135 // Page change callback 1136 $table.on('page.dt', function() { 1137 if (g_stbServerSideProcessing) { 1138 g_stbServerSideProcessingIsActive = true; 1139 } 1140 var table = $(this), 1141 tableSelector = '#supsystic-table-' + table.data('view-id') + ' #supsystic-table-' + table.data('id'); 1142 self.applyTableEventClb(self.pageEvent, 50, tableSelector); 1143 if ($table.data('pagination-scroll') == 'on') { 1144 $('html, body').animate({ 1145 scrollTop: table.closest('.dataTables_wrapper').offset().top 1146 }, 100); 1147 } 1148 if (typeof(self.setImgLightbox) == 'function') { 1149 self.setImgLightbox($table); 1150 } 1151 }); 1152 1153 // Frontend fields 1154 if (typeof(self.createEditableFields) == 'function') { // for compatibility with old pro versions 1155 var $editableFields = $tableWrap.find('.editable'), 1156 $editfileFields = $tableWrap.find('.editfile'), 1157 $selectableFields = $tableWrap.find('.selectable'), 1158 $tableId = $table.data('id'), 1159 useEditableFields = typeof(useEdit) != 'undefined' && typeof(useEdit[$tableId]) != 'undefined' ? 1160 useEdit[$tableId] : 1161 false; 1162 1163 if (useEditableFields || (SDT_DATA.isAdmin && SDT_DATA.isPro)) { 1164 if (typeof(self.setFrontendFields) == 'function') { 1165 self.setFrontendFields($table); 1166 } else if (typeof(self.setAllFields) == 'function') { 1167 self.setAllFields($table, $editableFields, $selectableFields); 1168 } else { 1169 self.createEditableFields($table, $editableFields); 1170 self.createEditableFileFields($table, $editfileFields); 1171 } 1172 $table.on('init.dt', function() { 1173 $table.on('responsive-resize.dt responsive-display.dt draw.dt', function() { 1174 $editableFields.off('click.sup'); // for compatibility with old pro versions 1175 $editfileFields.off('click.sup'); 1176 self.updateAfterRedraw($table); 1177 }); 1178 }); 1179 } 1180 } 1181 if (typeof(self.setImgLightbox) == 'function') { 1182 self.setImgLightbox($table); 1183 } 1184 1185 // apply page.dt event by change table pagination via select 1186 var paginationSelect = $tableWrap.find('.dataTables_length select'); 1187 if (paginationSelect.length) { 1188 paginationSelect.on('change', function() { 1189 $table.trigger('page.dt'); 1190 }); 1191 } 1192 1193 self.applyTableEventClb(self.fixHeaderOfHiddenColumns, 50, tableSelector); 1194 1195 $table.trigger('beforeShowTable', $table); 1196 1197 // Show table 1198 $tableWrap.prev('.supsystic-table-loader').hide(); 1199 $tableWrap.css('visibility', 'visible'); 1200 1201 self.fixSortingForMultipleHeader($table); 1202 1203 if (responsiveMode === 2 || fixedHeader || fixedFooter) { 1204 // Responsive Mode: Horizontal Scroll 1205 $(window).on('load resize orientationchange', $table, function(event) { 1206 var tBody = $tableWrap.find('.dataTables_scrollBody'), 1207 tBodyTable = tBody.find('.supsystic-table'); 1208 1209 if (tBody.width() > tBodyTable.width() || $tableWrap.width() > tBodyTable.width()) { 1210 tBody.width(tBodyTable.width()); 1211 $tableWrap.find('.dataTables_scrollHead, .dataTables_scrollFoot, .dataTables_scrollBody').width(tBodyTable.width() + 1); 1212 /* 1213 var scrollTables = $tableWrap.find('.dataTables_scrollHead, .dataTables_scrollFoot'); 1214 scrollTables.width(tBodyTable.width() + 1); 1215 scrollTables.find('table').width(tBodyTable.width() + 1);*/ 1216 } 1217 if (tBody.isHorizontallyScrollable()) { 1218 tBody.css({ 1219 'border-bottom': 'none' 1220 }); 1221 } else { 1222 tBody.removeStyle('border-bottom'); 1223 } 1224 var table = self.getTableInstanceById($table.data('id')); 1225 if (typeof table.fnAdjustColumnSizing == 'function') { 1226 setTimeout(function() { 1227 table.fnAdjustColumnSizing(false); 1228 }, 350); 1229 } 1230 }); 1231 1232 // need resize twice to get better frontend view 1233 var tBody = $tableWrap.find('.dataTables_scrollBody'), 1234 tBodyTable = tBody.find('.supsystic-table'); 1235 1236 if (tBodyTable.is(":visible")) { 1237 setTimeout(function() { 1238 $(window).trigger('load'); 1239 }, 200); 1240 } 1241 var $tHeadTable = $tableWrap.find('.dataTables_scrollHead .supsystic-table'); 1242 if ($tHeadTable.length) { 1243 self.formatDataAtTable($tHeadTable, true); 1244 } 1245 var $tFootTable = $tableWrap.find('.dataTables_scrollFoot .supsystic-table'); 1246 if ($tFootTable.length) { 1247 self.formatDataAtTable($tFootTable, true); 1248 } 1249 } 1250 // Correct width of fixed header / footer 1251 if (fixedHeader || fixedFooter) { 1252 $table.api().fixedHeader.adjust(); 1253 1254 var i = 1; 1255 setTimeout(function() { 1256 var flag = fixedHeader, 1257 el = fixedHeader ? 1258 $tableWrap.find('.dataTables_scrollHead table thead tr:first-child th') : 1259 $tableWrap.find('.dataTables_scrollFoot table tfoot tr:first-child th'); 1260 1261 el.each(function() { 1262 var thWidth = $tableWrap.find('.dataTables_scrollBody table tbody tr:first-child td:nth-child(' + i + ')'); 1263 1264 $(this).css({ 1265 'width': thWidth.outerWidth(), 1266 'min-width': thWidth.outerWidth(), 1267 'box-sizing': 'border-box' 1268 }); 1269 if (fixedFooter && flag) { 1270 var footerEl = $tableWrap.find('.dataTables_scrollFoot table tfoot tr:first-child th:nth-child(' + i + ')'); 1271 footerEl.css({ 1272 'width': thWidth.outerWidth(), 1273 'min-width': thWidth.outerWidth(), 1274 'box-sizing': 'border-box' 1275 }); 1276 } 1277 i++; 1278 }); 1279 }, 200); 1280 } 1281 1282 // Correct width of fixed columns 1283 if (fixedColumns) { 1284 $table.api().fixedColumns().relayout(); 1285 1286 //var tableCaption = $('.dataTables_scrollHead caption'); 1287 // 1288 //if(tableCaption.length) { 1289 //self._fixTableCaption(tableCaption.height(), viewId, 10); 1290 //} 1291 } 1292 /* Fix for Horizontal scroll responsive mode if table has different width for one column in header and body */ 1293 if (!fixedHeader && !fixedFooter && responsiveMode === 2 && toeInArray('auto_width', $table.data('features')) == -1) { 1294 $tableWrap.find('.dataTables_scrollBody table thead tr:first-child th').each(function() {
1295 var tableWidth = $table.width(), 1296 tableWrapWidth = $tableWrap.width(); 1297 1298 if (tableWrapWidth > tableWidth) { 1299 $tableWrap 1300 .find('.dataTables_scrollHeadInner, .dataTables_scrollBody, .dataTables_scrollFootInner') 1301 .addClass('fit-content'); 1302 } 1303 }); 1304 } 1305 1306 // Load user custom scripts 1307 if (afterTableLoadedScriptString !== undefined) { 1308 afterTableLoadedScriptString = afterTableLoadedScriptString.substring(1, afterTableLoadedScriptString.length - 1); 1309 1310 var afterTableLoadedScript = b64DecodeUnicode(afterTableLoadedScriptString).replace(/"/g, "'"), 1311 executeScript = new Function(afterTableLoadedScript); 1312 1313 if (typeof executeScript === "function") { 1314 setTimeout(function() { 1315 executeScript(); 1316 }, 1000); 1317 } 1318 } 1319 1320 if (g_stbServerSideProcessing) { 1321 $table.on('draw.dt', function(e) { 1322 var searching = $table.data('searching-settings'); 1323 if (searching && ('columnSearch' in searching) && searching.columnSearch == 'on') { 1324 self.setColumnSearch($table); 1325 } 1326 self.getTableInstanceByViewId(viewId).fnFakeRowspan(); 1327 if (responsiveMode === 0 || responsiveMode === 2) { 1328 $(window).trigger('load'); 1329 } 1330 }).trigger('draw.dt'); 1331 } 1332 1333 var tblEditLink = 'g_stbTblEditLink_' + $table.data('id'), 1334 showTblEditLink = eval("typeof " + tblEditLink) !== 'undefined' ? jQuery(window.atob(eval(tblEditLink))) : false; 1335 1336 if (showTblEditLink && jQuery(tableSelector).closest('.supsystic-tables-wrap').find('.tblEditLink').length === 0) { 1337 jQuery(tableSelector).closest('.supsystic-tables-wrap').append(showTblEditLink); 1338 } 1339 1340 function b64DecodeUnicode(str) { 1341 return decodeURIComponent(Array.prototype.map.call(atob(str), function(c) { 1342 return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); 1343 }).join('')); 1344 } 1345 }); 1346 1347 vendor[appName].applyTableEventClb = (function(clb, timeout) { 1348 // Callback for applying events' actions and other functions to tables with server side processing (SSP) 1349 timeout = timeout ? timeout : 0; 1350 var self = this, 1351 args = Array.from(arguments); 1352 1353 if (g_stbServerSideProcessing && g_stbServerSideProcessingIsActive) { 1354 setTimeout(function() { 1355 self.applyTableEventClb.apply(self, args); 1356 }, 50); 1357 } else { 1358 if (typeof clb == 'function') { 1359 args = args.slice(2); 1360 setTimeout(function() { 1361 clb.apply(self, args); 1362 }, timeout); 1363 } 1364 } 1365 }); 1366 1367 vendor[appName].pageEvent = (function(tableSelector) { 1368 var table = $(tableSelector), 1369 tableWrapper = table.parents('.supsystic-tables-wrap:first'); 1370 1371 this.getRuleJSInstance(table).init(); 1372 this.formatDataAtTable(table, true); 1373 this.fixHeaderOfHiddenColumns(table); 1374 if ('ontouchstart' in window || navigator.msMaxTouchPoints) { 1375 tableWrapper.find('td, th').on('click', this.applyMobileTableComments); 1376 } 1377 tableWrapper.find('td, th').each(this._contactFormBtnCellClb); 1378 this.initShortcodesInTable(table); 1379 }); 1380 1381 vendor[appName].fixHeaderOfHiddenColumns = (function($table) { 1382 $table = $table instanceof $ ? $table : $($table); 1383 1384 var tableWrapper = $table.parents('.supsystic-tables-wrap:first'); 1385 1386 if (!$table.data('head')) { 1387 tableWrapper.find('thead').each(function() { 1388 var thead = $(this); 1389 thead.find('th').each(function(iter, item) { 1390 var th = $(this), 1391 itemIndex = iter + 1, 1392 columnAllTd = thead.parents('table:first').find('tbody td:nth-child(' + itemIndex + ')'), 1393 columnInvTd = columnAllTd.filter('.invisibleCell'), 1394 hidden = columnAllTd.length > 0 && columnAllTd.length == columnInvTd.length; 1395 if (hidden) { 1396 // Fix of correct displaying of tables with hidden rows / columns for tables without headers 1397 th.addClass('invisibleCell'); 1398 } 1399 }); 1400 }); 1401 } 1402 }); 1403 1404 vendor[appName].applyMobileTableComments = (function(e) { 1405 var $elem = $(this), 1406 title = $elem.attr('title'); 1407 1408 if (title) { 1409 var tableViewId = $elem.parents('table.supsystic-table:first').data('view-id'), 1410 cellId = $elem.data('cell-id'), 1411 comment = $('.stbMobileComment[data-table="' + tableViewId + '"][data-cell="' + cellId + '"]'); 1412 1413 if (!comment.length) { 1414 comment = $('<div class="stbMobileComment" style="display:none;"/>'); 1415 comment.text(title) 1416 .data('table', tableViewId) 1417 .attr('data-table', tableViewId) 1418 .data('cell', cellId) 1419 .attr('data-cell', cellId) 1420 .appendTo('body'); 1421 } 1422 comment.css({ 1423 top: (e.pageY - 70) + 'px', 1424 left: (e.pageX + 20) + 'px' 1425 }).fadeIn('slow'); 1426 1427 setTimeout(function() { 1428 comment.fadeOut('slow'); 1429 }, 2500); 1430 } 1431 }); 1432 1433 vendor[appName]._contactFormBtnCellClb = (function(e) { 1434 var cell = $(this), 1435 y = cell.data('y'), 1436 pair, 1437 valueCell; 1438 if (cell.html().indexOf('cfsPreFill') != -1) { 1439 var cellHtml = cell.html().replace(/href=["|']([^"]*?)["|']/g, function(a, b) { 1440 if (b.indexOf('cfsPreFill') != -1) { 1441 var newB = b.split('&'); 1442 if (newB.length) { 1443 for (var i = 0; i < newB.length; i++) { 1444 pair = newB[i].split('='); 1445 if (pair.length && pair[1].match(/[A-Za-z]/)) { 1446 valueCell = cell.parents('tr:first').find('[data-cell-id="' + pair[1] + y + '"]');
1447 if (valueCell.length) { 1448 pair[1] = $.trim(valueCell.html()); 1449 } 1450 } 1451 newB[i] = pair.join('='); 1452 } 1453 newB = newB.join('&'); 1454 a = a.replace(b, newB); 1455 } 1456 return a; 1457 } 1458 }); 1459 cell.html(cellHtml); 1460 } 1461 }); 1462 1463 vendor[appName].setColumnSearch = (function(table) { 1464 if (typeof this.setTableAddFilters === 'function') this.setTableAddFilters(table); 1465 1466 var self = this, 1467 searchingSettings = table.data('searching-settings'), 1468 inputs = table.parents('.dataTables_wrapper:first').find('.stbColumnsSearchWrapper .search-column'); 1469 if (inputs.length == 0) { 1470 return; 1471 } 1472 //$(document).off('keyup change', ".dataTables_wrapper:first .stbColumnsSearchWra
1472pper .search-column") 1473 // .on('keyup change', ".dataTables_wrapper:first .stbColumnsSearchWrapper .search-column",function () { 1474 inputs.off('keyup.dtg change.dtg').on('keyup.dtg change.dtg', function() { 1475 var input = $(this), 1476 position = input.parents('th:first').index(), 1477 value = this.value, 1478 column = table.api().column(position); 1479 if (typeof self.resetTableAddFilters === 'function') self.resetTableAddFilters(table); 1480 if (column.search() !== value) { 1481 column.search(value.replace(/;/g, "|"), true, false).draw(); 1482 setTimeout(function() { 1483 column.draw(); 1484 }, 50); 1485 } 1486 }); 1487 }); 1488 1489 vendor[appName].setCopyEvents = (function(obj, events) { 1490 $.each(events, function(event, handlers) { 1491 $.each(handlers, function(j, handler) { 1492 $(obj).unbind(event).bind(event, handler); 1493 }); 1494 }); 1495 }); 1496 1497 // Callback for executing script after table is initialized 1498 vendor[appName].executeScript = (function(table) { 1499 var $table = (table instanceof $ ? table : $(table)), 1500 $tableWrap = $table.closest('.supsystic-tables-wrap'); 1501 1502 this.getRuleJSInstance($table).init(); 1503 $tableWrap.prev('.supsystic-table-loader').hide(); 1504 $tableWrap.css('visibility', 'visible'); 1505 }); 1506 1507 vendor[appName].fixSortingForMultipleHeader = (function(table) { 1508 if (table.data('head-rows-count') > 1 && table.data('sort-order')) { 1509 var thead = table.find('thead tr').get().reverse(); 1510 1511 // Fix of sorting for table with multiple header (when header has more than 1 row) 1512 if (table.data('head')) { 1513 $.each(table.find('thead tr:last-child th'), function(index, element) { 1514 var th = $(element), 1515 nthChild = index + 1; 1516 1517 if (th.data('hide')) { 1518 $(thead).each(function() { 1519 var item = $(this).find('th:nth-child(' + nthChild + ')'); 1520 1521 if (!item.data('hide')) { 1522 item.addClass('sorting'); 1523 item.click(function() { 1524 th.trigger('click'); 1525 if (th.hasClass('sorting')) { 1526 item.removeClass('sorting_asc'); 1527 item.removeClass('sorting_desc'); 1528 item.addClass('sorting'); 1529 } else if (th.hasClass('sorting_asc')) { 1530 item.removeClass('sorting'); 1531 item.removeClass('sorting_desc'); 1532 item.addClass('sorting_asc'); 1533 } else if (th.hasClass('sorting_desc')) { 1534 item.removeClass('sorting'); 1535 item.removeClass('sorting_asc'); 1536 item.addClass('sorting_desc'); 1537 } 1538 }); 1539 return false; // stop .each() function 1540 } 1541 }); 1542 } 1543 }); 1544 } 1545 } 1546 }); 1547 1548 vendor[appName].formatDataAtTable = (function(table, correctSorting) { 1549 correctSorting = correctSorting ? correctSorting : false; 1550 1551 var self = this, 1552 numberFormat = table.data('number-format'), 1553 generalCurrencyFormat = table.data('currency-format'), 1554 generalPercentFormat = table.data('percent-format'), 1555 generalDateFormat = table.data('date-format'), 1556 generalTimeFormat = table.data('time-format'); 1557 1558 table.find('th, td').each(function(index, el) { 1559 var $this = $(this); 1560 1561 if ((table.data('auto-index') != 'off' && $this.is(':first-child')) || 1562 (table.data('responsive-mode') == 1 && table.hasClass('collapsed') && $this.hasClass('child')) || 1563 $this.find('.search-column').length || 1564 $this.hasClass('tooltipCell') || 1565 $this.data('hide') 1566 ) { 1567 // Break current .each iteration 1568 return; 1569 } 1570 1571 var languageData = numeral.languageData(), 1572 format = $this.data('cell-format'), 1573 formatType = $this.data('cell-format-type'), 1574 preparedFormat, 1575 delimiters, 1576 value = $.trim($this.html()), 1577 noFormat = false;
1578 1579 // function checkIfDate(parts) { 1580 // var newDate = new Date(parts[0], parts[1]-1, parts[2]); 1581 // if (newDate.getTime() === newDate.getTime()) { 1582 // $this.attr('data-cell-format-type', 'date'); 1583 // $this.data('cell-format-type', 'date'); 1584 // formatType = $this.data('cell-format-type'); 1585 // console.log(parts); 1586 // } 1587 // } 1588 // var parts = value.split('.'); 1589 // if (parts.length > 0) { 1590 // checkIfDate(parts); 1591 // } 1592 // var parts = value.split('-'); 1593 // if (parts.length > 0) { 1594 // checkIfDate(parts); 1595 // } 1596 // var parts = value.split('/'); 1597 // if (parts.length > 0) { 1598 // checkIfDate(parts); 1599 // } 1600 1601 1602 // Fix data params for cells which use formulas, which depended on cells with shortcodes inside 1603 if (correctSorting && toeInArray(formatType, ['date', 'time_duration']) == -1) { 1604 var dataTableInstance = typeof table.api == 'function' ? table : self.getTableInstanceById(table.data('id')); 1605 1606 if ($this.data('original-value') != value) { 1607 $this.data('original-value', value); 1608 $this.attr('data-original-value', value); 1609 } 1610 if ($this.data('data-order') != value) { 1611 $this.data('order'); 1612 $this.attr('data-order', value); 1613 if (dataTableInstance) { 1614 dataTableInstance.api().cell($this).invalidate(); 1615 } 1616 } 1617 } 1618 if (value) { 1619 if ($this.data('cell-reformat')) { 1620 switch (formatType) { 1621 case 'date': 1622 var newDate = moment(value, format); 1623 if (newDate.isValid()) { 1624 value = newDate.format(generalDateFormat); 1625 1626 $this.data('cell-format', generalDateFormat); 1627 $this.attr('data-cell-format', generalDateFormat); 1628 1629 $this.data('original-value', value); 1630 $this.attr('data-original-value', value); 1631 1632 $this.data('order', value); 1633 $this.attr('data-order', value); 1634 1635 if (!g_stbServerSideProcessing) { 1636 $this.data('cell-reformat', false); 1637 $this.attr('data-cell-reformat', 0); 1638 } 1639 } 1640 break; 1641 case 'time_duration': 1642 var newTime = moment(value, format), 1643 isValid = false; 1644 // console.log(newTime); 1645 1646 if (newTime.isValid()) { 1647 value = newTime.format(generalTimeFormat); 1648 isValid = true; 1649 } else { 1650 newTime = moment.duration(value); 1651 if (newTime._milliseconds || value == 0) { 1652 value = newTime.format(generalTimeFormat); 1653 isValid = true; 1654 } 1655 } 1656 if (isValid) { 1657 $this.data('cell-format', generalTimeFormat); 1658 $this.attr('data-cell-format', generalTimeFormat); 1659 1660 $this.data('original-value', value); 1661 $this.attr('data-original-value', value); 1662 1663 $this.data('order', value); 1664 $this.attr('data-order', value); 1665 1666 if (!g_stbServerSideProcessing) { 1667 $this.data('cell-reformat', false); 1668 $this.attr('data-cell-reformat', 0); 1669 } 1670 } 1671 break; 1672 default: 1673 break; 1674 } 1675 } else if (self.isNumber(value) && !isNaN(value)) { 1676 numberFormat = numberFormat ? numberFormat.toString() : ''; 1677 1678 switch (formatType) { 1679 case 'percent': 1680 format = format ? format : generalPercentFormat; 1681 1682 if (format) { 1683 format = format.toString(); 1684 1685 var clearFormat = format.indexOf('%') >
1685 -1 ? format.replace('%', '') : format; 1686 1687 value = value.indexOf('%') > -1 ? $this.data('original-value') : value; 1688 delimiters = (clearFormat.match(/[^\d]/g) || [',', '.']).reverse(); 1689 languageData.delimiters = { 1690 decimal: delimiters[0], 1691 thousands: delimiters[1] 1692 }; 1693 1694 // We need to use dafault delimiters for format string 1695 preparedFormat = format.replace(clearFormat, clearFormat.replace(delimiters[0], '.').replace(delimiters[1], ',')); 1696 } else { 1697 noFormat = true; 1698 } 1699 break; 1700 case 'currency': 1701 format = format ? format : generalCurrencyFormat; 1702 1703 if (format) { 1704 format = format.toString(); 1705 1706 var formatWithoutCurrency = format.match(/\d.?\d*.?\d*/)[0], 1707 currencySymbol = format.replace(formatWithoutCurrency, '') || '$'; // We need to set currency symbol in any case for normal work of numeraljs 1708 1709 delimiters = (formatWithoutCurrency.match(/[^\d]/g) || [',', '.']).reverse(); 1710 1711 languageData.delimiters = { 1712 decimal: delimiters[0], 1713 thousands: delimiters[1] 1714 }; 1715 languageData.currency.symbol = currencySymbol; 1716 // We need to use dafault delimiters for format string 1717 preparedFormat = format 1718 .replace(formatWithoutCurrency, formatWithoutCurrency 1719 .replace(delimiters[0], '.') 1720 .replace(delimiters[1], ',')) 1721 .replace(currencySymbol, '$'); 1722 } else { 1723 noFormat = true; 1724 } 1725 break; 1726 case 'date': 1727 case 'time_duration': 1728 noFormat = true; 1729 break; 1730 default: 1731 if (numberFormat) { 1732 format = numberFormat; 1733 delimiters = (format.match(/[^\d]/g) || [',', '.']).reverse(); 1734 languageData.delimiters = { 1735 decimal: delimiters[0], 1736 thousands: delimiters[1] 1737 }; 1738 1739 // We need to use dafault delimiters for format string 1740 preparedFormat = format.replace(format, format.replace(delimiters[0], '.').replace(delimiters[1], ',')); 1741 break; 1742 } else { 1743 noFormat = true; 1744 } 1745 break; 1746 } 1747 if (noFormat) { 1748 noFormat = false; 1749 } else { 1750 numeral.language('en', languageData); 1751 value = numeral(value).format(preparedFormat); 1752 } 1753 } 1754 } 1755 $this.html(value); 1756 }); 1757 }); 1758 1759 vendor[appName].isNumber = (function(value) { 1760 if (value) { 1761 if (value.toString().match(/^-{0,1}\d+\.{0,1}\d*$/)) { 1762 return true; 1763 } 1764 } 1765 return false;
1766 }); 1767 1768 vendor[appName].prepareFormulaToParse = (function(value) { 1769 var stringsInFormula = value.match(/".+?"|'.+?'/g); 1770 1771 if (stringsInFormula && stringsInFormula.length) { 1772 var clearValue = value.replace(/".+?"|'.+?'/g, '%STR%'), 1773 index = 0; 1774 1775 clearValue = clearValue.toUpperCase(); 1776 value = clearValue.replace(/%STR%/g, function(match) { 1777 var val = match; 1778 1779 if (index < stringsInFormula.length) { 1780 val = stringsInFormula[index]; 1781 index++; 1782 } 1783 return val; 1784 }); 1785 } else { 1786 value = value.toUpperCase(); 1787 } 1788 return value; 1789 }); 1790 1791 vendor[appName].Base64 = { 1792 _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", 1793 encode: function(input) { 1794 var self = vendor[appName].Base64, 1795 output = "", 1796 i = 0, 1797 chr1, chr2, chr3, enc1, enc2, enc3, enc4; 1798 1799 input = self._utf8_encode(input); 1800 1801 while (i < input.length) { 1802 chr1 = input.charCodeAt(i++); 1803 chr2 = input.charCodeAt(i++); 1804 chr3 = input.charCodeAt(i++); 1805 1806 enc1 = chr1 >> 2; 1807 enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 1808 enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 1809 enc4 = chr3 & 63; 1810 1811 if (isNaN(chr2)) { 1812 enc3 = enc4 = 64; 1813 } else if (isNaN(chr3)) { 1814 enc4 = 64; 1815 } 1816 output = output + 1817 self._keyStr.charAt(enc1) + self._keyStr.charAt(enc2) + 1818 self._keyStr.charAt(enc3) + self._keyStr.charAt(enc4); 1819 } 1820 1821 return output; 1822 }, 1823 // private method for UTF-8 encoding 1824 _utf8_encode: function(string) { 1825 string = string.replace(/\r\n/g, "\n"); 1826 var utftext = ""; 1827 1828 for (var n = 0; n < string.length; n++) { 1829 1830 var c = string.charCodeAt(n); 1831 1832 if (c < 128) { 1833 utftext += String.fromCharCode(c); 1834 } else if ((c > 127) && (c < 2048)) { 1835 utftext += String.fromCharCode((c >> 6) | 192); 1836 utftext += String.fromCharCode((c & 63) | 128); 1837 } else { 1838 utftext += String.fromCharCode((c >> 12) | 224); 1839 utftext += String.fromCharCode(((c >> 6) & 63) | 128); 1840 utftext += String.fromCharCode((c & 63) | 128); 1841 } 1842 1843 } 1844 1845 return utftext; 1846 } 1847 }; 1848 1849 vendor[appName].getClassesRegexp = (function() { 1850 return { 1851 color: /color\-([0-9a-f]{6})/, 1852 background: /bg\-([0-9a-f]{6})/, 1853 fontFamily: /ffamily\-([a-z_]+)/i, 1854 fontSize: /fsize\-([0-9]+)/ 1855 } 1856 }); 1857 1858 vendor[appName].setStylesToCell = (function(cell) { 1859 var $cell = cell instanceof jQuery ? cell : $(cell), 1860 viewId = $cell.parents('.supsystic-table:first').data('view-id'), 1861 classes = this.getClassesRegexp(), 1862 cellClassNames = $cell.get(0).className, 1863 color = classes.color.exec(cellClassNames), 1864 background = classes.background.exec(cellClassNames), 1865 fontFamily = classes.fontFamily.exec(cellClassNames), 1866 fontSize = classes.fontSize.exec(cellClassNames); 1867 1868 if (null !== color) { 1869 $cell.css({ 1870 color: '#' + color[1] 1871 }); 1872 } 1873 if (null !== background) { 1874 $cell.css({ 1875 backgroundColor: '#' + background[1] 1876 }); 1877 } 1878 if (null !== fontFamily) { 1879 var family = fontFamily[1].replace(/_/g, ' '), 1880 familyName = fontFamily[1].replace(/_/g, '+'), 1881 familyString = '@import url("//fonts.googleapis.com/css?family='
1881+ familyName + '");'; 1882 1883 if (g_stbStandartFontsList && 1884 toeInArray(family, g_stbStandartFontsList) == -1 && 1885 g_stbAllFontsList && 1886 toeInArray(family, g_stbAllFontsList) != -1 1887 ) { 1888 var style = this.getFrontendCellStylesElem(viewId); 1889 1890 if (style.text().indexOf(familyString) == -1) { 1891 style.text(familyString + '\n' + style.text()); 1892 } 1893 } 1894 $cell.css({ 1895 fontFamily: family 1896 }); 1897 } 1898 if (null !== fontSize) { 1899 var lineHeight = +fontSize[1] + 6; 1900 $cell.css({ 1901 fontSize: fontSize[1] + 'px', 1902 lineHeight: lineHeight + 'px' 1903 }); 1904 } 1905 }); 1906 1907 vendor[appName].getAdminCellStylesElem = (function() { 1908 var $style = $('#supsystic-tables-style'); 1909 1910 if (!$style.length) { 1911 $style = $('<style/>', { 1912 id: 'supsystic-tables-style' 1913 }); 1914 $('head').append($style); 1915 } 1916 return $style; 1917 }); 1918 1919 vendor[appName].getFrontendCellStylesElem = (function(viewId) { 1920 var $style = $('#supsystic-table-' + viewId + '-css'); 1921 1922 if (!$style.length) { 1923 $style = $('<style/>', { 1924 id: 'supsystic-table-' + viewId + '-css' 1925 }); 1926 $('head').append($style); 1927 } 1928 return $style; 1929 }); 1930 1931 vendor[appName]._fixTableCaption = (function(captionHeight, viewId, counter) { 1932 if (counter < 0) return false; 1933 1934 // Fix for displaying of caption for tables with fixed columns 1935 var self = this, 1936 tableViewHtmlId = '#supsystic-table-' + viewId, 1937 fixedColumnsWrapper = $(tableViewHtmlId + ' .DTFC_LeftWrapper, ' + tableViewHtmlId + ' .DTFC_RightWrapper'); 1938 1939 if (fixedColumnsWrapper.length) { 1940 fixedColumnsWrapper.find('caption').css({ 1941 display: 'none' 1942 }); 1943 fixedColumnsWrapper.css({ 1944 top: captionHeight + 'px' 1945 }); 1946 } else { 1947 counter--; 1948 setTimeout(function() { 1949 self._fixTableCaption(captionHeight, viewId, counter); 1950 }, 50); 1951 } 1952 }); 1953 1954 vendor[appName]._getChunksArray = (function(arr, len) { 1955 var chunks = [], 1956 i = 0, 1957 n = arr.length; 1958 1959 while (i < n) { 1960 chunks.push(arr.slice(i, i += len)); 1961 } 1962 1963 return chunks; 1964 }); 1965 1966 vendor[appName]._checkOnClickPopups = (function($table) { 1967 // Integration with our PopUp plugin 1968 // Only after table was inited - we can do this, and only in that way it will work 1969 if (typeof(_ppsBindOnElementClickPopups) !== 'undefined' && $table && $table.size()) { 1970 var $bindedLinks = $table.find('[href*="#ppsShowPopUp_"].ppsClickBinded'); 1971 if ($bindedLinks && $bindedLinks.size()) { 1972 $bindedLinks.removeClass('ppsClickBinded').unbind('click'); 1973 } 1974 _ppsBindOnElementClickPopups(); 1975 } 1976 }); 1977 1978 vendor[appName].setCellAttributes = function(cells) { 1979 var colspan, rowspan; 1980 for (var i = 0; i < cells.length; i++) { 1981 if (cells[i].getAttribute('data-hide')) { 1982 cells[i].style.display = 'none'; 1983 } 1984 if (colspan = cells[i].getAttribute('data-colspan')) { 1985 if (colspan > 1) { 1986 cells[i].setAttribute('colspan', colspan); 1987 $(cells[i]).attr('colspan', colspan); 1988 } 1989 } 1990 if (rowspan = cells[i].getAttribute('data-rowspan')) { 1991 if (rowspan > 1) { 1992 cells[i].setAttribute('rowspan', rowspan); 1993 } 1994 } 1995 } 1996 }; 1997 } 1998 1999}(window.supsystic = window.supsystic || {}, window.jQuery, window)); 2000 2001// For compatibility to old PRO versions 2002function classesRegexp() { 2003 return window.supsystic.Tables.getClassesRegexp(); 2004} 2005 2006function getAdminCellStylesElem() { 2007 return window.supsystic.Tables.getAdminCellStylesElem(); 2008} 2009 2010/** 2011 * We will not use just jQUery.inArray because it is work incorrect for objects 2012 * @return mixed - key that was found element or -1 if not 2013 */ 2014function toeInArray(needle, haystack) { 2015 if (typeof(haystack) == 'object') { 2016 for (var k in haystack) { 2017 if (haystack[k] == needle) 2018 return k; 2019 } 2020 } else if (typeof(haystack) == 'array') { 2021 return jQuery.inArray(needle, haystack); 2022 } 2023 return -1; 2024} 2025 2026(function($) { 2027 /** 2028 * Detects whether element can be scrolled vertically. 2029 * @this jQuery 2030 * @return {boolean} 2031 */ 2032 $.fn.isVerticallyScrollable = function() { 2033 if (this.scrollTop()) { 2034 // Element is already scrolled, so it is scrollable 2035 return true; 2036 } else { 2037 // Test by actually scrolling 2038 this.scrollTop(1); 2039 2040 if (this.scrollTop()) { 2041 // Scroll back 2042 this.scrollTop(0); 2043 return true; 2044 } 2045 } 2046 return false;
2047 }; 2048 2049 /** 2050 * Detects whether element can be scrolled horizontally. 2051 * @this jQuery 2052 * @return {boolean} 2053 */ 2054 $.fn.isHorizontallyScrollable = function() { 2055 if (this.scrollLeft()) { 2056 // Element is already scrolled, so it is scrollable 2057 return true; 2058 } else { 2059 // Test by actually scrolling 2060 this.scrollLeft(1); 2061 2062 if (this.scrollLeft()) { 2063 // Scroll back 2064 this.scrollLeft(0); 2065 return true; 2066 } 2067 } 2068 return false; 2069 }; 2070 2071 $.extend($.expr.pseudos || $.expr[":"], { 2072 "vertically-scrollable": function(a, i, m) { 2073 return $(a).isVerticallyScrollable(); 2074 }, 2075 "horizontally-scrollable": function(a, i, m) { 2076 return $(a).isHorizontallyScrollable(); 2077 } 2078 }); 2079 2080 $.fn.removeStyle = function(style) { 2081 var search = new RegExp(style + '[^;]+;?', 'g'); 2082 2083 return this.each(function() { 2084 $(this).attr('style', function(i, style) { 2085 return style && style.replace(search, ''); 2086 }); 2087 }); 2088 }; 2089 2090 if (!Array.from) { 2091 // Fix of compatibility with IE browser to use ES6 feature 2092 Array.from = (function() { 2093 var toStr = Object.prototype.toString; 2094 var isCallable = function(fn) { 2095 return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; 2096 }; 2097 var toInteger = function(value) { 2098 var number = Number(value); 2099 if (isNaN(number)) { 2100 return 0; 2101 } 2102 if (number === 0 || !isFinite(number)) { 2103 return number; 2104 } 2105 return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); 2106 }; 2107 var maxSafeInteger = Math.pow(2, 53) - 1; 2108 var toLength = function(value) { 2109 var len = toInteger(value); 2110 return Math.min(Math.max(len, 0), maxSafeInteger); 2111 }; 2112 2113 // The length property of the from method is 1. 2114 return function from(arrayLike /*, mapFn, thisArg */ ) { 2115 // 1. Let C be the this value. 2116 var C = this; 2117 2118 // 2. Let items be ToObject(arrayLike). 2119 var items = Object(arrayLike); 2120 2121 // 3. ReturnIfAbrupt(items). 2122 if (arrayLike == null) { 2123 throw new TypeError('Array.from requires an array-like object - not null or undefined'); 2124 } 2125 2126 // 4. If mapfn is undefined, then let mapping be false. 2127 var mapFn = arguments.length > 1 ? arguments[1] : void undefined; 2128 var T; 2129 if (typeof mapFn !== 'undefined') { 2130 // 5. else 2131 // 5. a If IsCallable(mapfn) is false, throw a TypeError exception. 2132 if (!isCallable(mapFn)) { 2133 throw new TypeError('Array.from: when provided, the second argument must be a function'); 2134 } 2135 2136 // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined. 2137 if (arguments.length > 2) { 2138 T = arguments[2]; 2139 } 2140 } 2141 2142 // 10. Let lenValue be Get(items, "length"). 2143 // 11. Let len be ToLength(lenValue). 2144 var len = toLength(items.length); 2145 2146 // 13. If IsConstructor(C) is true, then 2147 // 13. a. Let A be the result of calling the [[Construct]] internal method 2148 // of C with an argument list containing the single item len. 2149 // 14. a. Else, Let A be ArrayCreate(len). 2150 var A = isCallable(C) ? Object(new C(len)) : new Array(len); 2151 2152 // 16. Let k be 0. 2153 var k = 0; 2154 // 17. Repeat, while k < len⦠(also steps a - h) 2155 var kValue; 2156 while (k < len) { 2157 kValue = items[k]; 2158 if (mapFn) { 2159 A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); 2160 } else { 2161 A[k] = kValue; 2162 } 2163 k += 1; 2164 } 2165 // 18. Let putStatus be Put(A, "length", len, true). 2166 A.length = len; 2167 // 20. Return A. 2168 return A; 2169 }; 2170 }()); 2171 } 2172}(jQuery));
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.