diff --git a/jquery.dynatable.js b/jquery.dynatable.js index 9285e1e..0aae57f 100644 --- a/jquery.dynatable.js +++ b/jquery.dynatable.js @@ -53,56 +53,46 @@ perPageSelect: true }, table: { - defaultColumnIdStyle: 'camelCase', + defaultColumnIdStyle: "camelCase", columns: null, - headRowSelector: 'thead tr', // or e.g. tr:first-child - bodyRowSelector: 'tbody tr', - headRowClass: null, - copyHeaderAlignment: true, - copyHeaderClass: false + headRowSelector: "thead tr", // or e.g. tr:first-child + bodyRowSelector: "tbody tr", + headRowClass: null }, inputs: { queries: null, sorts: null, - multisort: ['ctrlKey', 'shiftKey', 'metaKey'], + multisort: ["ctrlKey", "shiftKey", "metaKey"], page: null, - queryEvent: 'blur change', + queryEvent: "blur change", recordCountTarget: null, - recordCountPlacement: 'after', + recordCountPlacement: "after", paginationLinkTarget: null, - paginationLinkPlacement: 'after', - paginationClass: 'dynatable-pagination-links', - paginationLinkClass: 'dynatable-page-link', - paginationPrevClass: 'dynatable-page-prev', - paginationNextClass: 'dynatable-page-next', - paginationActiveClass: 'dynatable-active-page', - paginationDisabledClass: 'dynatable-disabled-page', - paginationPrev: 'Previous', - paginationNext: 'Next', + paginationLinkPlacement: "after", + paginationClass: "dynatable-pagination-links", + paginationLinkClass: "dynatable-page-link", + paginationPrevClass: "dynatable-page-prev", + paginationNextClass: "dynatable-page-next", + paginationActiveClass: "dynatable-active-page", + paginationDisabledClass: "dynatable-disabled-page", + paginationPrev: "Previous", + paginationNext: "Next", paginationGap: [1,2,2,1], searchTarget: null, - searchPlacement: 'before', - searchText: 'Search: ', + searchPlacement: "before", perPageTarget: null, - perPagePlacement: 'before', - perPageText: 'Show: ', - pageText: 'Pages: ', - recordCountPageBoundTemplate: '{pageLowerBound} to {pageUpperBound} of', - recordCountPageUnboundedTemplate: '{recordsShown} of', - recordCountTotalTemplate: '{recordsQueryCount} {collectionName}', - recordCountFilteredTemplate: ' (filtered from {recordsTotal} total records)', - recordCountText: 'Showing', - recordCountTextTemplate: '{text} {pageTemplate} {totalTemplate} {filteredTemplate}', - recordCountTemplate: '{textTemplate}', - processingText: 'Processing...' + perPagePlacement: "before", + perPageText: "Show: ", + recordCountText: "Showing ", + processingText: "Processing..." }, dataset: { ajax: false, ajaxUrl: null, ajaxCache: null, ajaxOnLoad: false, - ajaxMethod: 'GET', - ajaxDataType: 'json', + ajaxMethod: "GET", + ajaxDataType: "json", totalRecordCount: null, queries: {}, queryRecordCount: null, @@ -110,7 +100,7 @@ perPageDefault: 10, perPageOptions: [10,20,50,100], sorts: {}, - sortsKeys: [], + sortsKeys: null, sortTypes: {}, records: null }, @@ -124,16 +114,16 @@ _attributeReader: defaultAttributeReader }, params: { - dynatable: 'dynatable', - queries: 'queries', - sorts: 'sorts', - page: 'page', - perPage: 'perPage', - offset: 'offset', - records: 'records', + dynatable: "dynatable", + queries: "queries", + sorts: "sorts", + page: "page", + perPage: "perPage", + offset: "offset", + records: "records", record: null, - queryRecordCount: 'queryRecordCount', - totalRecordCount: 'totalRecordCount' + queryRecordCount: "queryRecordCount", + totalRecordCount: "totalRecordCount" } }; @@ -187,7 +177,7 @@ }; build = function() { - this.$element.trigger('dynatable:preinit', this); + this.$element.trigger("dynatable:preinit", this); for (model in modelPrototypes) { if (modelPrototypes.hasOwnProperty(model)) { @@ -198,9 +188,9 @@ } } - this.$element.trigger('dynatable:init', this); + this.$element.trigger("dynatable:init", this); - if (!this.settings.dataset.ajax || (this.settings.dataset.ajax && this.settings.dataset.ajaxOnLoad) || this.settings.features.paginate || (this.settings.features.sort && !$.isEmptyObject(this.settings.dataset.sorts))) { + if (!this.settings.dataset.ajax || (this.settings.dataset.ajax && this.settings.dataset.ajaxOnLoad) || this.settings.features.paginate) { this.process(); } }; @@ -208,7 +198,7 @@ processAll = function(skipPushState) { var data = {}; - this.$element.trigger('dynatable:beforeProcess', data); + this.$element.trigger("dynatable:beforeProcess", data); if (!$.isEmptyObject(this.settings.dataset.queries)) { data[this.settings.params.queries] = this.settings.dataset.queries; } // TODO: Wrap this in a try/rescue block to hide the processing indicator and indicate something went wrong if error @@ -233,10 +223,9 @@ dataType: _this.settings.dataset.ajaxDataType, data: data, error: function(xhr, error) { - _this.$element.trigger('dynatable:ajax:error', {xhr: xhr, error : error}); }, success: function(response) { - _this.$element.trigger('dynatable:ajax:success', response); + _this.$element.trigger("dynatable:ajax:success", response); // Merge ajax results and meta-data into dynatables cached data _this.records.updateFromJson(response); // update table with new records @@ -280,47 +269,41 @@ this.state.push(data); } } - - this.$element.addClass('dynatable-loaded'); - this.$element.trigger('dynatable:afterProcess', data); + this.$element.trigger("dynatable:afterProcess", data); }; function defaultRowWriter(rowIndex, record, columns, cellWriter) { - var tr = ''; + var tr = ""; // grab the record's attribute for each column for (var i = 0, len = columns.length; i < len; i++) { tr += cellWriter(columns[i], record); } - return '' + tr + ''; + return "" + tr + ""; }; function defaultCellWriter(column, record) { var html = column.attributeWriter(record), - td = '