diff --git a/public/assets/demo/default/base/scripts.bundle.js b/public/assets/demo/default/base/scripts.bundle.js index 9f8c1962..577261cb 100644 --- a/public/assets/demo/default/base/scripts.bundle.js +++ b/public/assets/demo/default/base/scripts.bundle.js @@ -527,7 +527,7 @@ var mApp = function() { //== Initialize mApp class on document ready $(document).ready(function() { mApp.init(); -}); +}); /** * @class mUtil Metronic base utilize class that privides helper functions */ @@ -875,8 +875,3471 @@ var mUtil = function() { //== Initialize mUtil class on document ready $(document).ready(function() { mUtil.init(); -}); -(function($) { if (typeof mUtil === 'undefined') throw new Error('mUtil is required and must be included before mDatatable.'); // plugin setup $.fn.mDatatable = function(options) { if ($(this).length === 0) throw new Error('No mDatatable element exist.'); // global variables var datatable = this; // debug enabled? // 1) state will be cleared on each refresh // 2) enable some logs // 3) etc. datatable.debug = false; datatable.API = { record: null, value: null, params: null, }; var Plugin = { /******************** ** PRIVATE METHODS ********************/ isInit: false, offset: 110, stateId: 'meta', ajaxParams: {}, init: function(options) { Plugin.setupBaseDOM.call(); Plugin.setupDOM(datatable.table); Plugin.spinnerCallback(true); // set custom query from options Plugin.setDataSourceQuery(Plugin.getOption('data.source.read.params.query')); // on event after layout had done setup, show datatable $(datatable).on('m-datatable--on-layout-updated', Plugin.afterRender); if (datatable.debug) Plugin.stateRemove(Plugin.stateId); // initialize extensions $.each(Plugin.getOption('extensions'), function(extName, extOptions) { if (typeof $.fn.mDatatable[extName] === 'function') new $.fn.mDatatable[extName](datatable, extOptions); }); // get data if (options.data.type === 'remote' || options.data.type === 'local') { if (options.data.saveState === false || options.data.saveState.cookie === false && options.data.saveState.webstorage === false) { Plugin.stateRemove(Plugin.stateId); } // get data for local if (options.data.type === 'local' && typeof options.data.source === 'object') { if (options.data.source === null) { // this is html table Plugin.extractTable(); } datatable.dataSet = datatable.originalDataSet = Plugin.dataMapCallback(options.data.source); } Plugin.dataRender(); } Plugin.setHeadTitle.call(); Plugin.setHeadTitle.call(this, datatable.tableFoot); // for normal table, setup layout right away if (options.data.type === null) { Plugin.setupCellField.call(); Plugin.setupTemplateCell.call(); // setup extra system column properties Plugin.setupSystemColumn.call(); } // hide header if (typeof options.layout.header !== 'undefined' && options.layout.header === false) { $(datatable.table).find('thead').remove(); } // hide footer if (typeof options.layout.footer !== 'undefined' && options.layout.footer === false) { $(datatable.table).find('tfoot').remove(); } // for normal and local data type, run layoutUpdate if (options.data.type === null || options.data.type === 'local') { // setup nested datatable, if option enabled Plugin.setupSubDatatable.call(); // setup extra system column properties Plugin.setupSystemColumn.call(); Plugin.redraw(); } $(window).resize(Plugin.fullRender); $(datatable).height(''); $(Plugin.getOption('search.input')).on('keyup', function(e) { if (Plugin.getOption('search.onEnter') && e.which !== 13) return; Plugin.search($(this).val().toLowerCase()); }); return datatable; }, /** * Extract static HTML table content into datasource */ extractTable: function() { var columns = []; var headers = $(datatable). find('tr:first-child th'). get(). map(function(cell, i) { var field = $(cell).data('field'); if (typeof field === 'undefined') { field = $(cell).text().trim(); } var column = {field: field, title: field}; for (var ii in options.columns) { if (options.columns[ii].field === field) { column = $.extend(true, {}, options.columns[ii], column); } } columns.push(column); return field; }); // auto create columns config options.columns = columns; var data = $(datatable).find('tr').get().map(function(row) { return $(row).find('td').get().map(function(cell, i) { return $(cell).html(); }); }); var source = []; $.each(data, function(i, row) { if (row.length === 0) return; var td = {}; $.each(row, function(index, value) { td[headers[index]] = value; }); source.push(td); }); options.data.source = source; }, /** * One time layout update on init */ layoutUpdate: function() { // setup nested datatable, if option enabled Plugin.setupSubDatatable.call(); // setup extra system column properties Plugin.setupSystemColumn.call(); Plugin.columnHide.call(); Plugin.sorting.call(); // setup cell hover event Plugin.setupHover.call(); if (typeof options.detail === 'undefined' // temporary disable lock column in subtable && Plugin.getDepth() === 1) { // lock columns handler Plugin.lockTable.call(); } if (!Plugin.isInit) { $(datatable).trigger('m-datatable--on-init', {table: $(datatable.wrap).attr('id'), options: options}); Plugin.isInit = true; } $(datatable).trigger('m-datatable--on-layout-updated', {table: $(datatable.wrap).attr('id')}); }, lockTable: function() { // todo; revise lock table responsive var lock = { lockEnabled: false, init: function() { // check if table should be locked columns lock.lockEnabled = Plugin.lockEnabledColumns(); if (lock.lockEnabled.left.length === 0 && lock.lockEnabled.right.length === 0) { return; } lock.enable(); }, enable: function() { var enableLock = function(tablePart) { // check if already has lock column if ($(tablePart).find('.m-datatable__lock').length > 0) { Plugin.log('Locked container already exist in: ', tablePart); return; } // check if no rows exists if ($(tablePart).find('.m-datatable__row').length === 0) { Plugin.log('No row exist in: ', tablePart); return; } // locked div container var lockLeft = $('
'). addClass('m-datatable__lock m-datatable__lock--left'); var lockScroll = $(''). addClass('m-datatable__lock m-datatable__lock--scroll'); var lockRight = $(''). addClass('m-datatable__lock m-datatable__lock--right'); $(tablePart).find('.m-datatable__row').each(function() { var rowLeft = $('