{"version":3,"sources":["ucws_blocks/ucws_table/templates/js/ucws_table_custom.js"],"names":["Drupal","$","once","drupalSettings","behaviors","ucwsTableDataTable","attach","context","settings","fn","dataTable","dataTablesSettings","ucws_table","each","id","style","blockId","DataTable","isDataTable","$blockTable","this","index","$table","headers","tableId","attr","addClass","striped","length","push","text","find","wrapInner","displayChunkSizes","tableSize","pager","displayChunkSize","i","ordering","sorting","order","searching","search","info","paging","pagingType","lengthChange","lengthMenu","language","searchPlaceholder","paginate","previous","next","drawCallback","initComplete","json","selectpicker","wrap","err","console","log","message","jQuery"],"mappings":"CAAA,SAAWA,EAAQC,EAAGC,EAAMC,GAC1B,aAEAH,EAAOI,UAAUC,mBAAqB,CACpCC,OAAQ,SAAUC,EAASC,GAuBzB,GAA8B,mBAAnBP,EAAEQ,GAAGC,UAA0B,CAExC,IACIC,EAAqBR,EAAeS,WAAWP,mBAAmB,GAGtEJ,EAAEY,KAAKF,GAAoB,SAAUG,EAAIN,GACvC,GAAIM,GAAMN,EAASO,MAAO,CACxB,IAAIC,EANc,QAMcF,EAG3Bb,EAAEQ,GAAGQ,UAAUC,YAAYjB,EAAE,QAAS,IAAMe,KAC/Cf,EAAE,IAAMe,GAASH,MAAK,WAEpB,IAAIM,EAAclB,EAAE,QAASA,EAAEmB,OAC/BnB,EAAEC,EAAK,aAAciB,IAAcN,MAAK,SAAUQ,GAGhD,IApCYC,EAClBC,EAmCUC,GAAYH,EAAQ,EAAI,GAAM,IAAM,KAAOA,EAAQ,GASvD,GARApB,EAAEmB,MAAMK,KAAK,KAAMT,EAAAA,SAAkCQ,GAErDvB,EAAEmB,MAAMM,SAAS,wBAEjBzB,EAAEmB,MAAMM,SAASlB,EAASmB,SAAW,iBAIjC1B,EAAE,QAASA,EAAEmB,OAAOQ,OAAQ,CAI9B3B,EAAEmB,MAAMM,SAASlB,EAASO,OAAS,gBACZ,gBAAnBP,EAASO,QAlDHO,EAmDOrB,EAAEmB,MAlD3BG,EAAU,GACdtB,EAAE,WA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CtD,EAAE,6BAA6BuD,eAE/BvD,EAAEmB,MAAMqC,KAAK,mCAKnB,MAAOC,GAELC,QAAQC,IAAI,4BAA8BF,EAAIG,SAE9C5D,EAAEmB,MAAMqC,KAAK,sCAKfxD,EAAEmB,MAAMqC,KAAK,6CApIjC,CA8IGzD,OAAQ8D,OAAQ5D,KAAMC","file":"ucws_table_custom.js","sourcesContent":["(function (Drupal, $, once, drupalSettings) {\n 'use strict';\n\n Drupal.behaviors.ucwsTableDataTable = {\n attach: function (context, settings) {\n\n //\n // Provides content support for mobile 'card' style.\n //\n function setMobileTable($table) {\n var headers = [];\n $('thead th', $table).each(function () {\n headers.push($(this).text());\n });\n // Copy header value as label into each corresponding cell.\n $(':not(thead) tr', $table).each(function () {\n $(this).find('th, td').each(function (index) {\n $(this).attr('label', headers[index]);\n // Due to necessary CSS, we need to wrap cell contents.\n $(this).wrapInner('
');\n });\n });\n }\n\n //\n // Initialize all of the DataTable tables on the page.\n //\n if (typeof $.fn.dataTable === \"function\") {\n\n var containerPrefix = 'table';\n var dataTablesSettings = drupalSettings.ucws_table.ucwsTableDataTable[0];\n\n // Iterate over table containers!\n $.each(dataTablesSettings, function (id, settings) {\n if (id && settings.style) {\n var blockId = containerPrefix + id;\n\n // First we should check if DataTable() has already been run on the table.\n if (!$.fn.DataTable.isDataTable($('table', '#' + blockId))) {\n $('#' + blockId).each(function () {\n // Iterate over each table in the block.\n var $blockTable = $('table', $(this));\n $(once('initialize', $blockTable)).each(function (index) {\n\n // Add sequential unique IDs to each table.\n var tableId = ((index + 1 < 10) ? '0' : '') + (index + 1);\n $(this).attr('id', blockId + '_' + containerPrefix + tableId);\n // Main Bootstrap table classes.\n $(this).addClass('table table-bordered');\n // Determine if striped display or not.\n $(this).addClass(settings.striped && 'table-striped');\n\n // Initialize some variables to control DataTable display.\n // Needs to be defined for everything to work though!\n if ($('thead', $(this)).length) {\n\n // Determine if mobile display is table or card.\n // If card, we must adjust the table for proper display.\n $(this).addClass(settings.style || 'mobile-table');\n if (settings.style === 'mobile-card') {\n setMobileTable($(this));\n }\n\n // Determine display format of the pagination dropdown.\n var displayPagerStyle = 'simple_numbers';\n var displayChunkSizes = [[], []]; // DataTables format.\n var tableSize = $(':not(thead) tr', $(this)).length; // Disregard 'thead'.\n\n // More than 10 items? Create chunked table display dropdown.\n if (settings.pager && tableSize > 10) {\n var displayChunkSize = [10, 20, 50, 100];\n for (var i = 0; i < displayChunkSize.length - 1; i++) {\n if (tableSize > displayChunkSize[i]) {\n displayChunkSizes[0].push(displayChunkSize[i]);\n displayChunkSizes[1].push('Show ' + displayChunkSize[i] + ' of ' + tableSize + ' entries');\n }\n }\n // Ensure there is the ability to display all items.\n displayChunkSizes[0].push(-1);\n displayChunkSizes[1].push('Show all ' + tableSize + ' entries');\n }\n\n // Fire up the configured DataTable display!\n try {\n $(this).DataTable({\n ordering: settings.sorting,\n order: [], // No pre-sorting by default.\n searching: settings.search,\n info: (settings.pager && tableSize > 10),\n paging: (settings.pager && tableSize > 10),\n pagingType: displayPagerStyle,\n lengthChange: (settings.pager && tableSize > 10),\n lengthMenu: displayChunkSizes,\n language: {\n lengthMenu: '_MENU_',\n searchPlaceholder: 'Search this table',\n search: '_INPUT_',\n paginate: {\n previous: ' ',\n next: ' ',\n }\n },\n drawCallback: function(settings) {\n $('.dataTables_wrapper .paginate_button.next > a').each(function () {\n $(this).addClass('ucws-icon ucws-icon-chevron');\n });\n $('.dataTables_wrapper .paginate_button.previous > a').each(function () {\n $(this).addClass('ucws-icon ucws-icon-chevron');\n });\n // Add the button role to the pager buttons so they don't get animated.\n $('.dataTables_wrapper .paginate_button > a').each(function () {\n $(this).attr('role', 'button');\n });\n },\n initComplete: function (settings, json) {\n // Rock and roll - initialize Bootstrap Select!\n $('.dataTables_length select').selectpicker();\n // Now we can safely wrap the table too!\n $(this).wrap('');\n },\n });\n }\n // Lots of reasons this can fail (i.e. malformed table).\n catch (err) {\n // Error message may not be useful due to minimization...\n console.log('DataTable loading error: ' + err.message);\n // Still wrap the table.\n $(this).wrap('');\n }\n }\n else {\n // Still wrap the table.\n $(this).wrap('');\n }\n });\n });\n }\n }\n });\n }\n }\n };\n})(Drupal, jQuery, once, drupalSettings);\n"]}