From 254234b0dc2437868e3cff84d0c1efc1b89f3167 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 06:33:59 -0800 Subject: [PATCH 01/12] =?UTF-8?q?Fixed=20#4787=20-=20don=E2=80=99t=20try?= =?UTF-8?q?=20to=20display=20category=20if=20it=20is=20invalid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This shouldn’t be needed, but in case data got weird (manual editing, etc) --- resources/views/accessories/checkout.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/accessories/checkout.blade.php b/resources/views/accessories/checkout.blade.php index e9230c73e..09b13221e 100755 --- a/resources/views/accessories/checkout.blade.php +++ b/resources/views/accessories/checkout.blade.php @@ -39,7 +39,7 @@ @endif - @if ($accessory->category->name) + @if ($accessory->category)
From 7f1a535b3030686102f3258ce7590a90c156c88d Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 18:47:27 -0800 Subject: [PATCH 02/12] Added new seats API route --- routes/api.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routes/api.php b/routes/api.php index 70a20d871..c70014265 100644 --- a/routes/api.php +++ b/routes/api.php @@ -351,6 +351,13 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { /*--- Licenses API ---*/ + Route::group(['prefix' => 'licenses'], function () { + Route::get('{licenseId}/seats', [ + 'as' => 'api.license.seats', + 'uses' => 'LicensesController@seats' + ]); + }); // Licenses group + Route::resource('licenses', 'LicensesController', [ 'names' => @@ -367,6 +374,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { ); // Licenses resource + /*--- Locations API ---*/ Route::group(['prefix' => 'locations'], function () { From 3d5545494ece1a94915d9308853a8e9a505c8aad Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 18:47:40 -0800 Subject: [PATCH 03/12] Added new seats transformer --- .../Transformers/LicenseSeatsTransformer.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 app/Http/Transformers/LicenseSeatsTransformer.php diff --git a/app/Http/Transformers/LicenseSeatsTransformer.php b/app/Http/Transformers/LicenseSeatsTransformer.php new file mode 100644 index 000000000..56bdf0a87 --- /dev/null +++ b/app/Http/Transformers/LicenseSeatsTransformer.php @@ -0,0 +1,57 @@ +transformDatatables($array, $total); + } + + public function transformLicenseSeat (LicenseSeat $seat, $seat_count) + { + $array = [ + 'id' => (int) $seat->license->id, + 'name' => 'Seat '.$seat_count, + 'assigned_user' => ($seat->user) ? [ + 'id' => (int) $seat->user->id, + 'name'=> e($seat->user->present()->fullName) + ] : null, + 'assigned_asset' => ($seat->asset) ? [ + 'id' => (int) $seat->asset->id, + 'name'=> e($seat->asset->present()->fullName) + ] : null, + 'reassignable' => (bool) $seat->license->reassignable, + 'user_can_checkout' => (($seat->assigned_to=='') && ($seat->asset_id=='')) ? true : false, + ]; + + $permissions_array['available_actions'] = [ + 'checkout' => Gate::allows('checkout', License::class) ? true : false, + 'checkin' => Gate::allows('checkin', License::class) ? true : false, + 'clone' => Gate::allows('create', License::class) ? true : false, + 'update' => Gate::allows('update', License::class) ? true : false, + 'delete' => Gate::allows('delete', License::class) ? true : false, + ]; + + $array += $permissions_array; + + return $array; + } + + + + + +} From e3d7be23cb03e741f52304a31d86f25cbeae1f9b Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 18:47:57 -0800 Subject: [PATCH 04/12] Added new seats controller method --- .../Controllers/Api/LicensesController.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/Http/Controllers/Api/LicensesController.php b/app/Http/Controllers/Api/LicensesController.php index 83915905b..59ef32e61 100644 --- a/app/Http/Controllers/Api/LicensesController.php +++ b/app/Http/Controllers/Api/LicensesController.php @@ -5,7 +5,9 @@ namespace App\Http\Controllers\Api; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Http\Transformers\LicensesTransformer; +use App\Http\Transformers\LicenseSeatsTransformer; use App\Models\License; +use App\Models\LicenseSeat; use App\Models\Company; class LicensesController extends Controller @@ -162,4 +164,38 @@ class LicensesController extends Controller { // } + + /** + * Get license seat listing + * + * @author [A. Gianotto] [] + * @since [v1.0] + * @param int $licenseId + * @return \Illuminate\Contracts\View\View + */ + public function seats(Request $request, $licenseId) + { + + if ($license = License::find($licenseId)) { + + $seats = LicenseSeat::where('license_id', $licenseId)->with('license', 'user', 'asset'); + + $offset = request('offset', 0); + $limit = request('limit', 50); + $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; + + $total = $seats->count(); + $seats = $seats->skip($offset)->take($limit)->get(); + + if ($seats) { + return (new LicenseSeatsTransformer)->transformLicenseSeats($seats, $total); + } + + } + + return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/licenses/message.does_not_exist')), 200); + + } + + } From bb52a8417c62e713b4afe0a67980e5c41ca8942f Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 18:58:41 -0800 Subject: [PATCH 05/12] Switch view code to AJAX table --- resources/views/licenses/view.blade.php | 104 ++++++------------------ 1 file changed, 25 insertions(+), 79 deletions(-) diff --git a/resources/views/licenses/view.blade.php b/resources/views/licenses/view.blade.php index dc1bee4c8..198729e47 100755 --- a/resources/views/licenses/view.blade.php +++ b/resources/views/licenses/view.blade.php @@ -38,90 +38,36 @@
-
- +
+ +
+
- - - - - - + + + + + + + - - @if ($license->licenseseats) - @foreach ($license->licenseseats as $licensedto) - - - - - - - - @endforeach - @endif -
{{ trans('admin/licenses/general.seat') }}{{ trans('admin/licenses/general.user') }}{{ trans('admin/licenses/form.asset') }}
{{ trans('admin/licenses/general.seat') }}{{ trans('admin/licenses/general.user') }}{{ trans('admin/licenses/form.asset') }}{{ trans('general.location') }}Checkin/Checkout
Seat {{ $count }} - @if (($licensedto->user) && ($licensedto->deleted_at == NULL)) - @can('users.view') - - - {{ $licensedto->user->present()->fullName() }} - - @else - - {{ $licensedto->user->present()->fullName() }} - @endcan - - @elseif (($licensedto->user) && ($licensedto->deleted_at != NULL)) - - {{ $licensedto->user->present()->fullName() }} - - @endif - - @if ($licensedto->asset) - - @can('view', $licensedto->asset) - - - {{ $licensedto->asset->name }} {{ $licensedto->asset->asset_tag }} - - @else - - {{ $licensedto->asset->name }} {{ $licensedto->asset->asset_tag }} - @endcan - - @if ($licensedto->asset->location) - @can('locations.view') - ({!! $licensedto->asset->location->present()->nameUrl() !!}) - @else - ({{ $licensedto->asset->location->present()->name() }}) - @endcan - @endif - - @endif - - @can('checkout', $license) - @if (($licensedto->assigned_to) || ($licensedto->asset_id)) - @if ($license->reassignable) - - {{ trans('general.checkin') }} - - @else - Assigned - @endif - @else - - {{ trans('general.checkout') }} - - @endif - @endcan -
+
+
-
+
@@ -318,7 +264,7 @@ - + @@ -423,7 +369,7 @@ @section('moar_scripts') - @include ('partials.bootstrap-table', ['simple_view' => true]) + @include ('partials.bootstrap-table') @stop From bab0bda17440fe274ff46bd35b2c05ead7172dc8 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 18:58:55 -0800 Subject: [PATCH 06/12] Added custom formatter for license seats (WIP) --- .../views/partials/bootstrap-table.blade.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index d049a5c23..59db8447c 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -285,18 +285,23 @@ } + // We need a special formatter for license seats, since they don't work exactly the same + // + function licenseSeatInOutFormatter (value, row) { + + if ((row.available_actions.checkout == true) && (row.user_can_checkout == true) && (!row.assigned_to)) { + return '{{ trans('general.checkout') }}'; + } else { + + } + } + function genericCheckinCheckoutFormatter(destination) { return function (value,row) { // The user is allowed to check items out, AND the item is deployable - if ((row.available_actions.checkout == true) && (row.user_can_checkout == true) && (!row.assigned_to)) { - // case for licenses - if (row.next_seat) { - return '{{ trans('general.checkout') }}'; - } else { - return '{{ trans('general.checkout') }}'; - } - + if ((row.available_actions.checkout == true) && (row.user_can_checkout == true) && ((!row.asset_id) && (!row.assigned_to))) { + return '{{ trans('general.checkout') }}'; // The user is allowed to check items out, but the item is not deployable } else if (((row.user_can_checkout == false)) && (row.available_actions.checkout == true) && (!row.assigned_to)) { From c6a956382fa956299998dc9ccfff8dfbe605ded6 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 20:04:41 -0800 Subject: [PATCH 07/12] Fixed #4784 - cookie not always being set correctly for ajax tables --- .../cookie/bootstrap-table-cookie.js | 205 +++++++++++++----- .../cookie/bootstrap-table-cookie.min.js | 6 +- .../views/partials/bootstrap-table.blade.php | 26 +-- 3 files changed, 166 insertions(+), 71 deletions(-) diff --git a/public/js/extensions/cookie/bootstrap-table-cookie.js b/public/js/extensions/cookie/bootstrap-table-cookie.js index 3192bde38..c3a746a4b 100755 --- a/public/js/extensions/cookie/bootstrap-table-cookie.js +++ b/public/js/extensions/cookie/bootstrap-table-cookie.js @@ -1,7 +1,7 @@ /** * @author: Dennis Hernández * @webSite: http://djhvscf.github.io/Blog - * @version: v1.2.0 + * @version: v1.2.2 * * @update zhixin wen */ @@ -64,11 +64,27 @@ } cookieName = that.options.cookieIdTable + '.' + cookieName; - if (!cookieName || /^(?:expires|max\-age|path|domain|secure)$/i.test(cookieName)) { - return false; + + switch(that.options.cookieStorage) { + case 'cookieStorage': + document.cookie = [ + cookieName, '=', cookieValue, + '; expires=' + that.options.cookieExpire, + that.options.cookiePath ? '; path=' + that.options.cookiePath : '', + that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '', + that.options.cookieSecure ? '; secure' : '' + ].join(''); + break; + case 'localStorage': + localStorage.setItem(cookieName, cookieValue); + break; + case 'sessionStorage': + sessionStorage.setItem(cookieName, cookieValue); + break; + default: + return false; } - document.cookie = encodeURIComponent(cookieName) + '=' + encodeURIComponent(cookieValue) + calculateExpiration(that.options.cookieExpire) + (that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '') + (that.options.cookiePath ? '; path=' + that.options.cookiePath : '') + (that.cookieSecure ? '; secure' : ''); return true; }; @@ -83,28 +99,44 @@ cookieName = tableName + '.' + cookieName; - return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(cookieName).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null; - }; - - var hasCookie = function (cookieName) { - if (!cookieName) { - return false; + switch(that.options.cookieStorage) { + case 'cookieStorage': + return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(cookieName).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null; + case 'localStorage': + return localStorage.getItem(cookieName); + case 'sessionStorage': + return sessionStorage.getItem(cookieName); + default: + return null; } - return (new RegExp('(?:^|;\\s*)' + encodeURIComponent(cookieName).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=')).test(document.cookie); }; - var deleteCookie = function (tableName, cookieName, sPath, sDomain) { + var deleteCookie = function (that, tableName, cookieName) { cookieName = tableName + '.' + cookieName; - if (!hasCookie(cookieName)) { - return false; + + switch(that.options.cookieStorage) { + case 'cookieStorage': + document.cookie = [ + encodeURIComponent(cookieName), '=', + '; expires=Thu, 01 Jan 1970 00:00:00 GMT', + that.options.cookiePath ? '; path=' + that.options.cookiePath : '', + that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '', + ].join(''); + break; + case 'localStorage': + localStorage.removeItem(cookieName); + break; + case 'sessionStorage': + sessionStorage.removeItem(cookieName); + break; + } - document.cookie = encodeURIComponent(cookieName) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT' + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : ''); return true; }; var calculateExpiration = function(cookieExpire) { var time = cookieExpire.replace(/[0-9]*/, ''); //s,mi,h,d,m,y - cookieExpire = cookieExpire.replace(/[A-Za-z]/, ''); //number + cookieExpire = cookieExpire.replace(/[A-Za-z]{1,2}}/, ''); //number switch (time.toLowerCase()) { case 's': @@ -123,7 +155,7 @@ cookieExpire = cookieExpire * 30 * 24 * 60 * 60; break; case 'y': - cookieExpire = cookieExpire * 365 * 30 * 24 * 60 * 60; + cookieExpire = cookieExpire * 365 * 24 * 60 * 60; break; default: cookieExpire = undefined; @@ -133,6 +165,38 @@ return cookieExpire === undefined ? '' : '; max-age=' + cookieExpire; }; + var initCookieFilters = function (bootstrapTable) { + setTimeout(function () { + var parsedCookieFilters = JSON.parse(getCookie(bootstrapTable, bootstrapTable.options.cookieIdTable, cookieIds.filterControl)); + + if (!bootstrapTable.options.filterControlValuesLoaded && parsedCookieFilters) { + bootstrapTable.options.filterControlValuesLoaded = true; + + var cachedFilters = {}, + header = getCurrentHeader(bootstrapTable), + searchControls = getCurrentSearchControls(bootstrapTable), + + applyCookieFilters = function (element, filteredCookies) { + $(filteredCookies).each(function (i, cookie) { + $(element).val(cookie.text); + cachedFilters[cookie.field] = cookie.text; + }); + }; + + header.find(searchControls).each(function () { + var field = $(this).closest('[data-field]').data('field'), + filteredCookies = $.grep(parsedCookieFilters, function (cookie) { + return cookie.field === field; + }); + + applyCookieFilters(this, filteredCookies); + }); + + bootstrapTable.initColumnSearch(cachedFilters); + } + }, 250); + }; + $.extend($.fn.bootstrapTable.defaults, { cookie: false, cookieExpire: '2h', @@ -140,17 +204,30 @@ cookieDomain: null, cookieSecure: null, cookieIdTable: '', - cookiesEnabled: ['bs.table.sortOrder', 'bs.table.sortName', 'bs.table.pageNumber', 'bs.table.pageList', 'bs.table.columns', 'bs.table.searchText', 'bs.table.filterControl'], + cookiesEnabled: [ + 'bs.table.sortOrder', 'bs.table.sortName', + 'bs.table.pageNumber', 'bs.table.pageList', + 'bs.table.columns', 'bs.table.searchText', + 'bs.table.filterControl' + ], + cookieStorage: 'cookieStorage', //localStorage, sessionStorage //internal variable filterControls: [], filterControlValuesLoaded: false }); + $.fn.bootstrapTable.methods.push('getCookies'); $.fn.bootstrapTable.methods.push('deleteCookie'); + $.extend($.fn.bootstrapTable.utils, { + setCookie: setCookie, + getCookie: getCookie + }); + var BootstrapTable = $.fn.bootstrapTable.Constructor, _init = BootstrapTable.prototype.init, _initTable = BootstrapTable.prototype.initTable, + _initServer = BootstrapTable.prototype.initServer, _onSort = BootstrapTable.prototype.onSort, _onPageNumber = BootstrapTable.prototype.onPageNumber, _onPageListChange = BootstrapTable.prototype.onPageListChange, @@ -167,9 +244,10 @@ this.options.filterControls = []; this.options.filterControlValuesLoaded = false; - this.options.cookiesEnabled = typeof this.options.cookiesEnabled === 'string' ? - this.options.cookiesEnabled.replace('[', '').replace(']', '').replace(/ /g, '').toLowerCase().split(',') : this.options.cookiesEnabled; + this.options.cookiesEnabled.replace('[', '').replace(']', '') + .replace(/ /g, '').toLowerCase().split(',') : + this.options.cookiesEnabled; if (this.options.filterControl) { var that = this; @@ -191,36 +269,46 @@ } setCookie(that, cookieIds.filterControl, JSON.stringify(that.options.filterControls)); - }).on('post-body.bs.table', function () { - setTimeout(function () { - if (!that.options.filterControlValuesLoaded) { - that.options.filterControlValuesLoaded = true; - var filterControl = JSON.parse(getCookie(that, that.options.cookieIdTable, cookieIds.filterControl)); - if (filterControl) { - var field = null, - result = [], - header = getCurrentHeader(that), - searchControls = getCurrentSearchControls(that); - - header.find(searchControls).each(function (index, ele) { - field = $(this).parent().parent().parent().data('field'); - result = $.grep(filterControl, function (valueObj) { - return valueObj.field === field; - }); - - if (result.length > 0) { - $(this).val(result[0].text); - that.onColumnSearch({currentTarget: $(this)}); - } - }); - } - } - }, 250); - }); + }).on('post-body.bs.table', initCookieFilters(that)); } _init.apply(this, Array.prototype.slice.apply(arguments)); }; + BootstrapTable.prototype.initServer = function () { + var bootstrapTable = this, + selectsWithoutDefaults = [], + + columnHasSelectControl = function (column) { + return column.filterControl && column.filterControl === 'select'; + }, + + columnHasDefaultSelectValues = function (column) { + return column.filterData && column.filterData !== 'column'; + }, + + cookiesPresent = function() { + var cookie = JSON.parse(getCookie(bootstrapTable, bootstrapTable.options.cookieIdTable, cookieIds.filterControl)); + return bootstrapTable.options.cookie && cookie; + }; + + selectsWithoutDefaults = $.grep(bootstrapTable.columns, function(column) { + return columnHasSelectControl(column) && !columnHasDefaultSelectValues(column); + }); + + // reset variable to original initServer function, so that future calls to initServer + // use the original function from this point on. + BootstrapTable.prototype.initServer = _initServer; + + // early return if we don't need to populate any select values with cookie values + if (this.options.filterControl && cookiesPresent() && selectsWithoutDefaults.length === 0) { + return; + } + + // call BootstrapTable.prototype.initServer + _initServer.apply(this, Array.prototype.slice.apply(arguments)); + }; + + BootstrapTable.prototype.initTable = function () { _initTable.apply(this, Array.prototype.slice.apply(arguments)); this.initCookie(); @@ -233,7 +321,6 @@ if ((this.options.cookieIdTable === '') || (this.options.cookieExpire === '') || (!cookieEnabled())) { throw new Error("Configuration error. Please review the cookieIdTable, cookieExpire properties, if those properties are ok, then this browser does not support the cookies"); - return; } var sortOrderCookie = getCookie(this, this.options.cookieIdTable, cookieIds.sortOrder), @@ -310,15 +397,31 @@ setCookie(this, cookieIds.columns, JSON.stringify(visibleColumns)); }; - + BootstrapTable.prototype.selectPage = function (page) { _selectPage.apply(this, Array.prototype.slice.apply(arguments)); setCookie(this, cookieIds.pageNumber, page); }; BootstrapTable.prototype.onSearch = function () { - _onSearch.apply(this, Array.prototype.slice.apply(arguments)); - setCookie(this, cookieIds.searchText, this.searchText); + var target = Array.prototype.slice.apply(arguments); + _onSearch.apply(this, target); + + if ($(target[0].currentTarget).parent().hasClass('search')) { + setCookie(this, cookieIds.searchText, this.searchText); + } + }; + + BootstrapTable.prototype.getCookies = function () { + var bootstrapTable = this; + var cookies = {}; + $.each(cookieIds, function(key, value) { + cookies[key] = getCookie(bootstrapTable, bootstrapTable.options.cookieIdTable, value); + if (key === 'columns') { + cookies[key] = JSON.parse(cookies[key]); + } + }); + return cookies; }; BootstrapTable.prototype.deleteCookie = function (cookieName) { @@ -326,6 +429,6 @@ return; } - deleteCookie(this.options.cookieIdTable, cookieIds[cookieName], this.options.cookiePath, this.options.cookieDomain); + deleteCookie(this, this.options.cookieIdTable, cookieIds[cookieName]); }; })(jQuery); diff --git a/public/js/extensions/cookie/bootstrap-table-cookie.min.js b/public/js/extensions/cookie/bootstrap-table-cookie.min.js index 0a3c25717..425ef8b6f 100755 --- a/public/js/extensions/cookie/bootstrap-table-cookie.min.js +++ b/public/js/extensions/cookie/bootstrap-table-cookie.min.js @@ -1,7 +1,7 @@ /* -* bootstrap-table - v1.9.1 - 2015-10-25 +* bootstrap-table - v1.11.1 - 2017-02-22 * https://github.com/wenzhixin/bootstrap-table -* Copyright (c) 2015 zhixin wen +* Copyright (c) 2017 zhixin wen * Licensed MIT License */ -!function(a){"use strict";var b={sortOrder:"bs.table.sortOrder",sortName:"bs.table.sortName",pageNumber:"bs.table.pageNumber",pageList:"bs.table.pageList",columns:"bs.table.columns",searchText:"bs.table.searchText",filterControl:"bs.table.filterControl"},c=function(a){var b=a.$header;return a.options.height&&(b=a.$tableHeader),b},d=function(a){var b="select, input";return a.options.height&&(b="table select, table input"),b},e=function(){return!!navigator.cookieEnabled},f=function(a,b){for(var c=-1,d=0;d0&&(a(this).val(i[0].text),e.onColumnSearch({currentTarget:a(this)}))})}}},250)})}m.apply(this,Array.prototype.slice.apply(arguments))},l.prototype.initTable=function(){n.apply(this,Array.prototype.slice.apply(arguments)),this.initCookie()},l.prototype.initCookie=function(){if(this.options.cookie){if(""===this.options.cookieIdTable||""===this.options.cookieExpire||!e())throw new Error("Configuration error. Please review the cookieIdTable, cookieExpire properties, if those properties are ok, then this browser does not support the cookies");var c=h(this,this.options.cookieIdTable,b.sortOrder),d=h(this,this.options.cookieIdTable,b.sortName),f=h(this,this.options.cookieIdTable,b.pageNumber),g=h(this,this.options.cookieIdTable,b.pageList),i=JSON.parse(h(this,this.options.cookieIdTable,b.columns)),j=h(this,this.options.cookieIdTable,b.searchText);this.options.sortOrder=c?c:this.options.sortOrder,this.options.sortName=d?d:this.options.sortName,this.options.pageNumber=f?+f:this.options.pageNumber,this.options.pageSize=g?g===this.options.formatAllRows()?g:+g:this.options.pageSize,this.options.searchText=j?j:"",i&&a.each(this.columns,function(b,c){c.visible=-1!==a.inArray(c.field,i)})}},l.prototype.onSort=function(){o.apply(this,Array.prototype.slice.apply(arguments)),g(this,b.sortOrder,this.options.sortOrder),g(this,b.sortName,this.options.sortName)},l.prototype.onPageNumber=function(){p.apply(this,Array.prototype.slice.apply(arguments)),g(this,b.pageNumber,this.options.pageNumber)},l.prototype.onPageListChange=function(){q.apply(this,Array.prototype.slice.apply(arguments)),g(this,b.pageList,this.options.pageSize)},l.prototype.onPageFirst=function(){r.apply(this,Array.prototype.slice.apply(arguments)),g(this,b.pageNumber,this.options.pageNumber)},l.prototype.onPagePre=function(){s.apply(this,Array.prototype.slice.apply(arguments)),g(this,b.pageNumber,this.options.pageNumber)},l.prototype.onPageNext=function(){t.apply(this,Array.prototype.slice.apply(arguments)),g(this,b.pageNumber,this.options.pageNumber)},l.prototype.onPageLast=function(){u.apply(this,Array.prototype.slice.apply(arguments)),g(this,b.pageNumber,this.options.pageNumber)},l.prototype.toggleColumn=function(){v.apply(this,Array.prototype.slice.apply(arguments));var c=[];a.each(this.columns,function(a,b){b.visible&&c.push(b.field)}),g(this,b.columns,JSON.stringify(c))},l.prototype.selectPage=function(a){w.apply(this,Array.prototype.slice.apply(arguments)),g(this,b.pageNumber,a)},l.prototype.onSearch=function(){x.apply(this,Array.prototype.slice.apply(arguments)),g(this,b.searchText,this.searchText)},l.prototype.deleteCookie=function(a){""!==a&&e()&&j(this.options.cookieIdTable,b[a],this.options.cookiePath,this.options.cookieDomain)}}(jQuery); \ No newline at end of file +!function(a){"use strict";var b={sortOrder:"bs.table.sortOrder",sortName:"bs.table.sortName",pageNumber:"bs.table.pageNumber",pageList:"bs.table.pageList",columns:"bs.table.columns",searchText:"bs.table.searchText",filterControl:"bs.table.filterControl"},c=function(a){var b=a.$header;return a.options.height&&(b=a.$tableHeader),b},d=function(a){var b="select, input";return a.options.height&&(b="table select, table input"),b},e=function(){return!!navigator.cookieEnabled},f=function(a,b){for(var c=-1,d=0;d + @if (!isset($simple_view)) - @@ -36,31 +36,27 @@ classes: 'table table-responsive table-no-bordered', undefinedText: '', iconsPrefix: 'fa', - - @if (isset($search)) - search: true, - @endif - - + search: {{ (isset($search)) ? 'true' : 'false' }}, paginationVAlign: 'both', sidePagination: '{{ (isset($clientSearch)) ? 'client' : 'server' }}', sortable: true, + pageSize: 20, + pagination: true, + cookie: true, + cookieExpire: '2y', + cookieIdTable: '{{ Route::currentRouteName() }}', @if (!isset($simple_view)) showRefresh: true, - pagination: true, - pageSize: 20, - cookie: true, - cookieExpire: '2y', showExport: true, stickyHeader: true, stickyHeaderOffsetY: stickyHeaderOffsetY + 'px', - @if (isset($showFooter)) showFooter: true, @endif + showColumns: true, trimOnSearch: false, @@ -287,13 +283,9 @@ // We need a special formatter for license seats, since they don't work exactly the same // - function licenseSeatInOutFormatter (value, row) { + function licenseSeatInOutFormatter(value, row) { - if ((row.available_actions.checkout == true) && (row.user_can_checkout == true) && (!row.assigned_to)) { - return '{{ trans('general.checkout') }}'; - } else { - } } function genericCheckinCheckoutFormatter(destination) { From c31362655c410e8740a5b23f254287cab42b9269 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 20:34:36 -0800 Subject: [PATCH 08/12] Refactored BS tables include for clearer separation of simple v not simple --- .../views/partials/bootstrap-table.blade.php | 168 +++++++++--------- 1 file changed, 85 insertions(+), 83 deletions(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index db3d8cff1..8c5ece9be 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -33,90 +33,86 @@ $('.snipe-table').bootstrapTable('destroy').bootstrapTable({ - classes: 'table table-responsive table-no-bordered', - undefinedText: '', - iconsPrefix: 'fa', - search: {{ (isset($search)) ? 'true' : 'false' }}, - paginationVAlign: 'both', - sidePagination: '{{ (isset($clientSearch)) ? 'client' : 'server' }}', - sortable: true, - pageSize: 20, - pagination: true, - cookie: true, - cookieExpire: '2y', - cookieIdTable: '{{ Route::currentRouteName() }}', - - @if (!isset($simple_view)) - - showRefresh: true, - showExport: true, - stickyHeader: true, - stickyHeaderOffsetY: stickyHeaderOffsetY + 'px', - - @if (isset($showFooter)) - showFooter: true, - @endif - - showColumns: true, - trimOnSearch: false, - - @if (isset($multiSort)) - showMultiSort: true, - @endif - - @if (isset($exportFile)) - exportDataType: 'all', - exportTypes: ['csv', 'excel', 'doc', 'txt','json', 'xml', 'pdf'], - exportOptions: { - - fileName: '{{ $exportFile . "-" }}' + (new Date()).toISOString().slice(0,10), - ignoreColumn: ['actions','change','checkbox','checkincheckout','icon'], - worksheetName: "Snipe-IT Export", - jspdf: { - orientation: 'l', - autotable: { - styles: { - rowHeight: 20, - fontSize: 10, - overflow: 'linebreak', - }, - headerStyles: {fillColor: 255, textColor: 0}, - //alternateRowStyles: {fillColor: [60, 69, 79], textColor: 255} - } - } + classes: 'table table-responsive table-no-bordered', + undefinedText: '', + iconsPrefix: 'fa', + search: {{ (isset($search)) ? 'true' : 'false' }}, + paginationVAlign: 'both', + sidePagination: '{{ (isset($clientSearch)) ? 'client' : 'server' }}', + sortable: true, + pageSize: 20, + pagination: true, + cookie: true, + cookieExpire: '2y', + cookieIdTable: '{{ Route::currentRouteName() }}', + @if (isset($columns)) + columns: {!! $columns !!}, + @endif + mobileResponsive: true, + maintainSelected: true, + paginationFirstText: "{{ trans('general.first') }}", + paginationLastText: "{{ trans('general.last') }}", + paginationPreText: "{{ trans('general.previous') }}", + paginationNextText: "{{ trans('general.next') }}", + formatLoadingMessage: function () { + return '

Loading... please wait....

'; }, - @endif + icons: { + advancedSearchIcon: 'fa fa-search-plus', + paginationSwitchDown: 'fa-caret-square-o-down', + paginationSwitchUp: 'fa-caret-square-o-up', + columns: 'fa-columns', + @if( isset($multiSort)) + sort: 'fa fa-sort-amount-desc', + plus: 'fa fa-plus', + minus: 'fa fa-minus', + @endif + refresh: 'fa-refresh' + }, + @if (!isset($simple_view)) - @endif + showRefresh: true, + showExport: true, + stickyHeader: true, + stickyHeaderOffsetY: stickyHeaderOffsetY + 'px', - @if (isset($columns)) - columns: {!! $columns !!}, - @endif + @if (isset($showFooter)) + showFooter: true, + @endif - mobileResponsive: true, - maintainSelected: true, - paginationFirstText: "{{ trans('general.first') }}", - paginationLastText: "{{ trans('general.last') }}", - paginationPreText: "{{ trans('general.previous') }}", - paginationNextText: "{{ trans('general.next') }}", - formatLoadingMessage: function () { - return '

Loading... please wait....

'; - }, - pageList: ['20', '30','50','100','150','200'], - icons: { - advancedSearchIcon: 'fa fa-search-plus', - paginationSwitchDown: 'fa-caret-square-o-down', - paginationSwitchUp: 'fa-caret-square-o-up', - columns: 'fa-columns', - @if( isset($multiSort)) - sort: 'fa fa-sort-amount-desc', - plus: 'fa fa-plus', - minus: 'fa fa-minus', - @endif - refresh: 'fa-refresh' - } + showColumns: true, + trimOnSearch: false, - }); + @if (isset($multiSort)) + showMultiSort: true, + @endif + + @if (isset($exportFile)) + exportDataType: 'all', + exportTypes: ['csv', 'excel', 'doc', 'txt','json', 'xml', 'pdf'], + exportOptions: { + + fileName: '{{ $exportFile . "-" }}' + (new Date()).toISOString().slice(0,10), + ignoreColumn: ['actions','change','checkbox','checkincheckout','icon'], + worksheetName: "Snipe-IT Export", + jspdf: { + orientation: 'l', + autotable: { + styles: { + rowHeight: 20, + fontSize: 10, + overflow: 'linebreak', + }, + headerStyles: {fillColor: 255, textColor: 0}, + //alternateRowStyles: {fillColor: [60, 69, 79], textColor: 255} + } + } + }, + @endif + @endif + pageList: ['20', '30','50','100','150','200'] + + }); } @@ -282,9 +278,15 @@ // We need a special formatter for license seats, since they don't work exactly the same - // - function licenseSeatInOutFormatter(value, row) { + // Checkouts need the license ID, checkins need the specific seat ID + function licenseSeatInOutFormatter(value, row) { + // The user is allowed to check the license seat out and it's available + if ((row.available_actions.checkout == true) && (row.user_can_checkout == true) && ((!row.asset_id) && (!row.assigned_to))) { + return '{{ trans('general.checkout') }}'; + } else { + return '{{ trans('general.checkin') }}'; + } } @@ -302,9 +304,9 @@ // The user is allowed to check items in } else if (row.available_actions.checkin == true) { if (row.assigned_to) { - return '{{ trans('general.checkin') }}'; + return '{{ trans('general.checkin') }}'; } else if (row.assigned_pivot_id) { - return '{{ trans('general.checkin') }}'; + return '{{ trans('general.checkin') }}'; } } From af7b7664c5eb3008bbdefbcbe5998ee696a1f849 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 20:34:44 -0800 Subject: [PATCH 09/12] Added license seat location method --- app/Models/LicenseSeat.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Models/LicenseSeat.php b/app/Models/LicenseSeat.php index b1c9a5c3a..1f1660f90 100755 --- a/app/Models/LicenseSeat.php +++ b/app/Models/LicenseSeat.php @@ -34,4 +34,17 @@ class LicenseSeat extends Model implements ICompanyableChild { return $this->belongsTo('\App\Models\Asset', 'asset_id')->withTrashed(); } + + public function location() + { + if (($this->user) && ($this->user->location)) { + return $this->user->location; + + } elseif (($this->asset) && ($this->asset->location)) { + return $this->asset->location; + } + + return false; + + } } From 2bbb6001a81abbfeeb1788ab1d6fdd0ceb417c33 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 20:36:27 -0800 Subject: [PATCH 10/12] Added location to seats transformer --- app/Http/Transformers/LicenseSeatsTransformer.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Transformers/LicenseSeatsTransformer.php b/app/Http/Transformers/LicenseSeatsTransformer.php index 56bdf0a87..783c75c58 100644 --- a/app/Http/Transformers/LicenseSeatsTransformer.php +++ b/app/Http/Transformers/LicenseSeatsTransformer.php @@ -23,7 +23,8 @@ class LicenseSeatsTransformer public function transformLicenseSeat (LicenseSeat $seat, $seat_count) { $array = [ - 'id' => (int) $seat->license->id, + 'id' => (int) $seat->id, + 'license_id' => (int) $seat->license->id, 'name' => 'Seat '.$seat_count, 'assigned_user' => ($seat->user) ? [ 'id' => (int) $seat->user->id, @@ -33,6 +34,10 @@ class LicenseSeatsTransformer 'id' => (int) $seat->asset->id, 'name'=> e($seat->asset->present()->fullName) ] : null, + 'location' => ($seat->location()) ? [ + 'id' => (int) $seat->location()->id, + 'name'=> e($seat->location()->name) + ] : null, 'reassignable' => (bool) $seat->license->reassignable, 'user_can_checkout' => (($seat->assigned_to=='') && ($seat->asset_id=='')) ? true : false, ]; From 55b9f1207df5b08ad077233e8e0c39d51ed8a179 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 10 Jan 2018 22:53:54 -0800 Subject: [PATCH 11/12] Updated bootstrap tables --- public/js/FileSaver.min.js | 7 +- public/js/bootstrap-table.js | 1150 +- public/js/bootstrap-table.min.js | 8 +- public/js/extensions/export/tableExport.js | 3472 ++-- .../js/extensions/export/tableExport.min.js | 77 + .../toolbar/bootstrap-table-toolbar.js | 12 +- .../toolbar/bootstrap-table-toolbar.min.js | 6 +- public/js/jspdf.min.js | 17167 +--------------- public/js/jspdf.plugin.autotable.js | 4 +- public/js/xlsx.core.min.js | 15 + resources/views/accessories/index.blade.php | 4 +- resources/views/licenses/view.blade.php | 23 +- .../views/partials/bootstrap-table.blade.php | 70 +- 13 files changed, 3292 insertions(+), 18723 deletions(-) create mode 100644 public/js/extensions/export/tableExport.min.js create mode 100644 public/js/xlsx.core.min.js diff --git a/public/js/FileSaver.min.js b/public/js/FileSaver.min.js index b1cb31dae..9a1e397f2 100644 --- a/public/js/FileSaver.min.js +++ b/public/js/FileSaver.min.js @@ -1,7 +1,2 @@ /*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ -var saveAs=saveAs||"undefined"!==typeof navigator&&navigator.msSaveOrOpenBlob&&navigator.msSaveOrOpenBlob.bind(navigator)||function(a){"use strict";if("undefined"===typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var k=a.document,n=k.createElementNS("http://www.w3.org/1999/xhtml","a"),w="download"in n,x=function(c){var e=k.createEvent("MouseEvents");e.initMouseEvent("click",!0,!1,a,0,0,0,0,0,!1,!1,!1,!1,0,null);c.dispatchEvent(e)},q=a.webkitRequestFileSystem,u=a.requestFileSystem||q||a.mozRequestFileSystem, -y=function(c){(a.setImmediate||a.setTimeout)(function(){throw c;},0)},r=0,s=function(c){var e=function(){"string"===typeof c?(a.URL||a.webkitURL||a).revokeObjectURL(c):c.remove()};a.chrome?e():setTimeout(e,500)},t=function(c,a,d){a=[].concat(a);for(var b=a.length;b--;){var l=c["on"+a[b]];if("function"===typeof l)try{l.call(c,d||c)}catch(f){y(f)}}},m=function(c,e){var d=this,b=c.type,l=!1,f,p,k=function(){t(d,["writestart","progress","write","writeend"])},g=function(){if(l||!f)f=(a.URL||a.webkitURL|| -a).createObjectURL(c);p?p.location.href=f:void 0==a.open(f,"_blank")&&"undefined"!==typeof safari&&(a.location.href=f);d.readyState=d.DONE;k();s(f)},h=function(a){return function(){if(d.readyState!==d.DONE)return a.apply(this,arguments)}},m={create:!0,exclusive:!1},v;d.readyState=d.INIT;e||(e="download");if(w)f=(a.URL||a.webkitURL||a).createObjectURL(c),n.href=f,n.download=e,x(n),d.readyState=d.DONE,k(),s(f);else{a.chrome&&b&&"application/octet-stream"!==b&&(v=c.slice||c.webkitSlice,c=v.call(c,0, -c.size,"application/octet-stream"),l=!0);q&&"download"!==e&&(e+=".download");if("application/octet-stream"===b||q)p=a;u?(r+=c.size,u(a.TEMPORARY,r,h(function(a){a.root.getDirectory("saved",m,h(function(a){var b=function(){a.getFile(e,m,h(function(a){a.createWriter(h(function(b){b.onwriteend=function(b){p.location.href=a.toURL();d.readyState=d.DONE;t(d,"writeend",b);s(a)};b.onerror=function(){var a=b.error;a.code!==a.ABORT_ERR&&g()};["writestart","progress","write","abort"].forEach(function(a){b["on"+ -a]=d["on"+a]});b.write(c);d.abort=function(){b.abort();d.readyState=d.DONE};d.readyState=d.WRITING}),g)}),g)};a.getFile(e,{create:!1},h(function(a){a.remove();b()}),h(function(a){a.code===a.NOT_FOUND_ERR?b():g()}))}),g)}),g)):g()}},b=m.prototype;b.abort=function(){this.readyState=this.DONE;t(this,"abort")};b.readyState=b.INIT=0;b.WRITING=1;b.DONE=2;b.error=b.onwritestart=b.onprogress=b.onwrite=b.onabort=b.onerror=b.onwriteend=null;return function(a,b){return new m(a,b)}}}("undefined"!==typeof self&& -self||"undefined"!==typeof window&&window||this.content);"undefined"!==typeof module&&null!==module?module.exports=saveAs:"undefined"!==typeof define&&null!==define&&null!=define.amd&&define([],function(){return saveAs}); \ No newline at end of file +var saveAs=saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,a=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},i=/constructor/i.test(e.HTMLElement)||e.safari,f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},s="application/octet-stream",d=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,d)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(a){u(a)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},v=function(t,u,d){if(!d){t=p(t)}var v=this,w=t.type,m=w===s,y,h=function(){l(v,"writestart progress write writeend".split(" "))},S=function(){if((f||m&&i)&&e.FileReader){var r=new FileReader;r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");var n=e.open(t,"_blank");if(!n)e.location.href=t;t=undefined;v.readyState=v.DONE;h()};r.readAsDataURL(t);v.readyState=v.INIT;return}if(!y){y=n().createObjectURL(t)}if(m){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}v.readyState=v.DONE;h();c(y)};v.readyState=v.INIT;if(o){y=n().createObjectURL(t);setTimeout(function(){r.href=y;r.download=u;a(r);h();c(y);v.readyState=v.DONE});return}S()},w=v.prototype,m=function(e,t,n){return new v(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){t=t||e.name||"download";if(!n){e=p(e)}return navigator.msSaveOrOpenBlob(e,t)}}w.abort=function(){};w.readyState=w.INIT=0;w.WRITING=1;w.DONE=2;w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null;return m}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!==null){define("FileSaver.js",function(){return saveAs})} diff --git a/public/js/bootstrap-table.js b/public/js/bootstrap-table.js index 1c891bbc5..9813921f5 100755 --- a/public/js/bootstrap-table.js +++ b/public/js/bootstrap-table.js @@ -1,10 +1,10 @@ /** * @author zhixin wen - * version: 1.9.1 + * version: 1.11.1 * https://github.com/wenzhixin/bootstrap-table/ */ -!function ($) { +(function ($) { 'use strict'; // TOOLS DEFINITION @@ -140,7 +140,7 @@ return func; } if (typeof func === 'function') { - return func.apply(self, args); + return func.apply(self, args || []); } if (!func && typeof name === 'string' && sprintf.apply(this, [name].concat(args))) { return sprintf.apply(this, [name].concat(args)); @@ -180,25 +180,16 @@ var escapeHTML = function (text) { if (typeof text === 'string') { return text - .replace(/&/g, "&") - .replace(//g, ">") - .replace(/"/g, """) - .replace(/'/g, "'"); + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/`/g, '`'); } return text; }; - var getRealHeight = function ($el) { - var height = 0; - $el.children().each(function () { - if (height < $(this).outerHeight(true)) { - height = $(this).outerHeight(true); - } - }); - return height; - }; - var getRealDataAttr = function (dataAttr) { for (var attr in dataAttr) { var auxAttr = attr.split(/(?=[A-Z])/).join('-').toLowerCase(); @@ -211,17 +202,66 @@ return dataAttr; }; - var getItemField = function (item, field) { + var getItemField = function (item, field, escape) { var value = item; if (typeof field !== 'string' || item.hasOwnProperty(field)) { - return item[field]; + return escape ? escapeHTML(item[field]) : item[field]; } var props = field.split('.'); for (var p in props) { - value = value[props[p]]; + if (props.hasOwnProperty(p)) { + value = value && value[props[p]]; + } + } + return escape ? escapeHTML(value) : value; + }; + + var isIEBrowser = function () { + return !!(navigator.userAgent.indexOf("MSIE ") > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)); + }; + + var objectKeys = function () { + // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys + if (!Object.keys) { + Object.keys = (function() { + var hasOwnProperty = Object.prototype.hasOwnProperty, + hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'), + dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ], + dontEnumsLength = dontEnums.length; + + return function(obj) { + if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) { + throw new TypeError('Object.keys called on non-object'); + } + + var result = [], prop, i; + + for (prop in obj) { + if (hasOwnProperty.call(obj, prop)) { + result.push(prop); + } + } + + if (hasDontEnumBug) { + for (i = 0; i < dontEnumsLength; i++) { + if (hasOwnProperty.call(obj, dontEnums[i])) { + result.push(dontEnums[i]); + } + } + } + return result; + }; + }()); } - return value; }; // BOOTSTRAP TABLE CLASS DEFINITION @@ -239,14 +279,17 @@ BootstrapTable.DEFAULTS = { classes: 'table table-hover', + sortClass: undefined, locale: undefined, height: undefined, undefinedText: '-', sortName: undefined, sortOrder: 'asc', + sortStable: false, striped: false, columns: [[]], data: [], + totalField: 'total', dataField: 'rows', method: 'get', url: undefined, @@ -254,11 +297,7 @@ cache: true, contentType: 'application/json', dataType: 'json', - ajaxOptions: { - headers: { - 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') - } - }, + ajaxOptions: {}, queryParams: function (params) { return params; }, @@ -268,6 +307,7 @@ }, pagination: false, onlyInfoPagination: false, + paginationLoop: true, sidePagination: 'client', // client or server totalRows: 0, // server side need to set pageNumber: 1, @@ -276,11 +316,10 @@ paginationHAlign: 'right', //right, left paginationVAlign: 'bottom', //bottom, top, both paginationDetailHAlign: 'left', //right, left - paginationFirstText: '«', paginationPreText: '‹', paginationNextText: '›', - paginationLastText: '»', search: false, + searchOnEnterKey: false, strictSearch: false, searchAlign: 'right', selectItemName: 'btSelectItem', @@ -292,6 +331,7 @@ showToggle: false, buttonsAlign: 'right', smartDisplay: true, + escape: false, minimumCountColumns: 1, idField: undefined, uniqueId: undefined, @@ -312,6 +352,7 @@ searchTimeOut: 500, searchText: '', iconSize: undefined, + buttonsClass: 'default', iconsPrefix: 'glyphicon', // glyphicon of fa (font awesome) icons: { paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down', @@ -323,6 +364,10 @@ detailClose: 'glyphicon-minus icon-minus' }, + customSearch: $.noop, + + customSort: $.noop, + rowStyle: function (row, index) { return {}; }, @@ -331,6 +376,10 @@ return {}; }, + footerStyle: function (row, index) { + return {}; + }, + onAll: function (name, args) { return false; }, @@ -403,19 +452,22 @@ onRefreshOptions: function (options) { return false; }, + onRefresh: function (params) { + return false; + }, onResetView: function () { return false; } }; - BootstrapTable.LOCALES = []; + BootstrapTable.LOCALES = {}; - BootstrapTable.LOCALES['en-US'] = BootstrapTable.LOCALES['en'] = { + BootstrapTable.LOCALES['en-US'] = BootstrapTable.LOCALES.en = { formatLoadingMessage: function () { return 'Loading, please wait...'; }, formatRecordsPerPage: function (pageNumber) { - return sprintf('%s records per page', pageNumber); + return sprintf('%s rows per page', pageNumber); }, formatShowingRows: function (pageFrom, pageTo, totalRows) { return sprintf('Showing %s to %s of %s rows', pageFrom, pageTo, totalRows); @@ -474,7 +526,8 @@ cellStyle: undefined, searchable: true, searchFormatter: true, - cardVisible: true + cardVisible: true, + escape : false }; BootstrapTable.EVENTS = { @@ -502,7 +555,8 @@ 'expand-row.bs.table': 'onExpandRow', 'collapse-row.bs.table': 'onCollapseRow', 'refresh-options.bs.table': 'onRefreshOptions', - 'reset-view.bs.table': 'onResetView' + 'reset-view.bs.table': 'onResetView', + 'refresh.bs.table': 'onRefresh' }; BootstrapTable.prototype.init = function () { @@ -511,6 +565,7 @@ this.initTable(); this.initHeader(); this.initData(); + this.initHiddenRows(); this.initFooter(); this.initToolbar(); this.initPagination(); @@ -523,7 +578,7 @@ if (this.options.locale) { var parts = this.options.locale.split(/-|_/); parts[0].toLowerCase(); - parts[1] && parts[1].toUpperCase(); + if (parts[1]) parts[1].toUpperCase(); if ($.fn.bootstrapTable.locales[this.options.locale]) { // locale as requested $.extend(this.options, $.fn.bootstrapTable.locales[this.options.locale]); @@ -593,6 +648,10 @@ var column = []; $(this).find('th').each(function () { + // Fix #2014 - getFieldIndex and elsewhere assume this is string, causes issues if not + if (typeof $(this).data('field') !== 'undefined') { + $(this).data('field', $(this).data('field') + ''); + } column.push($.extend({}, { title: $(this).html(), 'class': $(this).attr('class'), @@ -627,7 +686,8 @@ return; } - this.$el.find('>tbody>tr').each(function () { + var m = []; + this.$el.find('>tbody>tr').each(function (y) { var row = {}; // save tr's id, class and data-* attributes @@ -635,20 +695,38 @@ row._class = $(this).attr('class'); row._data = getRealDataAttr($(this).data()); - $(this).find('td').each(function (i) { - var field = that.columns[i].field; + $(this).find('>td').each(function (x) { + var $this = $(this), + cspan = +$this.attr('colspan') || 1, + rspan = +$this.attr('rowspan') || 1, + tx, ty; + + for (; m[y] && m[y][x]; x++); //skip already occupied cells in current row + + for (tx = x; tx < x + cspan; tx++) { //mark matrix elements occupied by current cell with true + for (ty = y; ty < y + rspan; ty++) { + if (!m[ty]) { //fill missing rows + m[ty] = []; + } + m[ty][tx] = true; + } + } + + var field = that.columns[x].field; row[field] = $(this).html(); // save td's id, class and data-* attributes row['_' + field + '_id'] = $(this).attr('id'); row['_' + field + '_class'] = $(this).attr('class'); row['_' + field + '_rowspan'] = $(this).attr('rowspan'); + row['_' + field + '_colspan'] = $(this).attr('colspan'); row['_' + field + '_title'] = $(this).attr('title'); row['_' + field + '_data'] = getRealDataAttr($(this).data()); }); data.push(row); }); this.options.data = data; + if (data.length) this.fromHtml = true; }; BootstrapTable.prototype.initHeader = function () { @@ -671,7 +749,7 @@ $.each(this.options.columns, function (i, columns) { html.push('
'); - if (i == 0 && !that.options.cardView && that.options.detailView) { + if (i === 0 && !that.options.cardView && that.options.detailView) { html.push(sprintf('', that.options.columns.length)); } @@ -733,13 +811,12 @@ sprintf(' rowspan="%s"', column.rowspan), sprintf(' colspan="%s"', column.colspan), sprintf(' data-field="%s"', column.field), - "tabindex='0'", '>'); html.push(sprintf('
', that.options.sortable && column.sortable ? 'sortable both' : '')); - text = column.title; + text = that.options.escape ? escapeHTML(column.title) : column.title; if (column.checkbox) { if (!that.options.singleSelect && that.options.checkboxHeader) { @@ -767,7 +844,14 @@ $(this).data(visibleColumns[$(this).data('field')]); }); this.$container.off('click', '.th-inner').on('click', '.th-inner', function (event) { - if (that.options.sortable && $(this).parent().data().sortable) { + var target = $(this); + + if (that.options.detailView) { + if (target.closest('.bootstrap-table')[0] !== that.$container[0]) + return false; + } + + if (that.options.sortable && target.parent().data().sortable) { that.onSort(event); } }); @@ -781,6 +865,7 @@ } }); + $(window).off('resize.bootstrap-table'); if (!this.options.showHeader || this.options.cardView) { this.$header.hide(); this.$tableHeader.hide(); @@ -791,15 +876,15 @@ this.$tableLoading.css('top', this.$header.outerHeight() + 1); // Assign the correct sortable arrow this.getCaret(); + $(window).on('resize.bootstrap-table', $.proxy(this.resetWidth, this)); } this.$selectAll = this.$header.find('[name="btSelectAll"]'); - this.$container.off('click', '[name="btSelectAll"]') - .on('click', '[name="btSelectAll"]', function () { - var checked = $(this).prop('checked'); - that[checked ? 'checkAll' : 'uncheckAll'](); - that.updateSelected(); - }); + this.$selectAll.off('click').on('click', function () { + var checked = $(this).prop('checked'); + that[checked ? 'checkAll' : 'uncheckAll'](); + that.updateSelected(); + }); }; BootstrapTable.prototype.initFooter = function () { @@ -842,15 +927,27 @@ var that = this, name = this.options.sortName, order = this.options.sortOrder === 'desc' ? -1 : 1, - index = $.inArray(this.options.sortName, this.header.fields); + index = $.inArray(this.options.sortName, this.header.fields), + timeoutId = 0; + + if (this.options.customSort !== $.noop) { + this.options.customSort.apply(this, [this.options.sortName, this.options.sortOrder]); + return; + } if (index !== -1) { + if (this.options.sortStable) { + $.each(this.data, function (i, row) { + if (!row.hasOwnProperty('_position')) row._position = i; + }); + } + this.data.sort(function (a, b) { if (that.header.sortNames[index]) { name = that.header.sortNames[index]; } - var aa = getItemField(a, name), - bb = getItemField(b, name), + var aa = getItemField(a, name, that.options.escape), + bb = getItemField(b, name, that.options.escape), value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]); if (value !== undefined) { @@ -865,6 +962,11 @@ bb = ''; } + if (that.options.sortStable && aa === bb) { + aa = a._position; + bb = b._position; + } + // IF both values are numeric, do a numeric comparison if ($.isNumeric(aa) && $.isNumeric(bb)) { // Convert numerical values form string to float. @@ -891,6 +993,17 @@ return order; }); + + if (this.options.sortClass !== undefined) { + clearTimeout(timeoutId); + timeoutId = setTimeout(function () { + that.$el.removeClass(that.options.sortClass); + var index = that.$header.find(sprintf('[data-field="%s"]', + that.options.sortName).index() + 1); + that.$el.find(sprintf('tr td:nth-child(%s)', index)) + .addClass(that.options.sortClass); + }, 250); + } } }; @@ -930,10 +1043,13 @@ $search, switchableCount = 0; + if (this.$toolbar.find('.bs-bars').children().length) { + $('body').append($(this.options.toolbar)); + } this.$toolbar.html(''); if (typeof this.options.toolbar === 'string' || typeof this.options.toolbar === 'object') { - $(sprintf('
', this.options.toolbarAlign)) + $(sprintf('
', this.options.toolbarAlign)) .appendTo(this.$toolbar) .append($(this.options.toolbar)); } @@ -947,34 +1063,40 @@ } if (this.options.showPaginationSwitch) { - html.push(sprintf(''); } if (this.options.showRefresh) { - html.push(sprintf(''); } if (this.options.showToggle) { - html.push(sprintf(''); } if (this.options.showColumns) { html.push(sprintf('
', - this.options.formatColumns()), - '
'); - // Fix #188: this.showToolbar is for extentions + // Fix #188: this.showToolbar is for extensions if (this.showToolbar || html.length > 2) { this.$toolbar.append(html.join('')); } @@ -1024,8 +1146,8 @@ if (this.options.showToggle) { this.$toolbar.find('button[name="toggle"]') .off('click').on('click', function () { - that.toggleView(); - }); + that.toggleView(); + }); } if (this.options.showColumns) { @@ -1041,8 +1163,7 @@ $keepOpen.find('input').off('click').on('click', function () { var $this = $(this); - that.toggleColumn(getFieldIndex(that.columns, - $(this).data('field')), $this.prop('checked'), false); + that.toggleColumn($(this).val(), $this.prop('checked'), false); that.trigger('column-switch', $(this).data('field'), $this.prop('checked')); }); } @@ -1059,12 +1180,29 @@ this.$toolbar.append(html.join('')); $search = this.$toolbar.find('.search input'); - $search.off('keyup drop').on('keyup drop', function (event) { + $search.off('keyup drop blur').on('keyup drop blur', function (event) { + if (that.options.searchOnEnterKey && event.keyCode !== 13) { + return; + } + + if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) { + return; + } + clearTimeout(timeoutId); // doesn't matter if it's 0 timeoutId = setTimeout(function () { that.onSearch(event); }, that.options.searchTimeOut); }); + + if (isIEBrowser()) { + $search.off('mouseup').on('mouseup', function (event) { + clearTimeout(timeoutId); // doesn't matter if it's 0 + timeoutId = setTimeout(function () { + that.onSearch(event); + }, that.options.searchTimeOut); + }); + } } }; @@ -1080,6 +1218,7 @@ return; } this.searchText = text; + this.options.searchText = text; this.options.pageNumber = 1; this.initSearch(); @@ -1091,17 +1230,20 @@ var that = this; if (this.options.sidePagination !== 'server') { - var s = this.searchText && this.searchText.toLowerCase(); + if (this.options.customSearch !== $.noop) { + this.options.customSearch.apply(this, [this.searchText]); + return; + } + + var s = this.searchText && (this.options.escape ? + escapeHTML(this.searchText) : this.searchText).toLowerCase(); var f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns; // Check filter this.data = f ? $.grep(this.options.data, function (item, i) { for (var key in f) { - if ($.isArray(f[key])) { - if ($.inArray(item[key], f[key]) === -1) { - return false; - } - } else if (item[key] !== f[key]) { + if ($.isArray(f[key]) && $.inArray(item[key], f[key]) === -1 || + !$.isArray(f[key]) && item[key] !== f[key]) { return false; } } @@ -1109,20 +1251,33 @@ }) : this.options.data; this.data = s ? $.grep(this.data, function (item, i) { - for (var key in item) { - key = $.isNumeric(key) ? parseInt(key, 10) : key; - var value = item[key], - column = that.columns[getFieldIndex(that.columns, key)], - j = $.inArray(key, that.header.fields); + for (var j = 0; j < that.header.fields.length; j++) { - // Fix #142: search use formated data - if (column && column.searchFormatter) { - value = calculateObjectValue(column, - that.header.formatters[j], [value, item, i], value); + if (!that.header.searchables[j]) { + continue; } - var index = $.inArray(key, that.header.fields); - if (index !== -1 && that.header.searchables[index] && (typeof value === 'string' || typeof value === 'number')) { + var key = $.isNumeric(that.header.fields[j]) ? parseInt(that.header.fields[j], 10) : that.header.fields[j]; + var column = that.columns[getFieldIndex(that.columns, key)]; + var value; + + if (typeof key === 'string') { + value = item; + var props = key.split('.'); + for (var prop_index = 0; prop_index < props.length; prop_index++) { + value = value[props[prop_index]]; + } + + // Fix #142: respect searchForamtter boolean + if (column && column.searchFormatter) { + value = calculateObjectValue(column, + that.header.formatters[j], [value, item, i], value); + } + } else { + value = item[key]; + } + + if (typeof value === 'string' || typeof value === 'number') { if (that.options.strictSearch) { if ((value + '').toLowerCase() === s) { return true; @@ -1155,7 +1310,8 @@ $first, $pre, $next, $last, $number, - data = this.getData(); + data = this.getData(), + pageList = this.options.pageList; if (this.options.sidePagination !== 'server') { this.options.totalRows = data.length; @@ -1195,27 +1351,27 @@ '
', '', this.options.onlyInfoPagination ? this.options.formatDetailPagination(this.options.totalRows) : - this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows), + this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows), ''); if (!this.options.onlyInfoPagination) { html.push(''); var pageNumber = [ - sprintf('', - this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ? - 'dropdown' : 'dropup'), - '', - '
', ''); - } this.$pagination.html(html.join('')); @@ -1288,14 +1496,6 @@ $last = this.$pagination.find('.page-last'); $number = this.$pagination.find('.page-number'); - if (this.options.pageNumber <= 1) { - $first.addClass('disabled'); - $pre.addClass('disabled'); - } - if (this.options.pageNumber >= this.totalPages) { - $next.addClass('disabled'); - $last.addClass('disabled'); - } if (this.options.smartDisplay) { if (this.totalPages <= 1) { this.$pagination.find('div.pagination').hide(); @@ -1307,6 +1507,16 @@ // when data is empty, hide the pagination this.$pagination[this.getData().length ? 'show' : 'hide'](); } + + if (!this.options.paginationLoop) { + if (this.options.pageNumber === 1) { + $pre.addClass('disabled'); + } + if (this.options.pageNumber === this.totalPages) { + $next.addClass('disabled'); + } + } + if ($allSelected) { this.options.pageSize = this.options.formatAllRows(); } @@ -1348,26 +1558,39 @@ this.$toolbar.find('.page-size').text(this.options.pageSize); this.updatePagination(event); + return false; }; BootstrapTable.prototype.onPageFirst = function (event) { this.options.pageNumber = 1; this.updatePagination(event); + return false; }; BootstrapTable.prototype.onPagePre = function (event) { - this.options.pageNumber--; + if ((this.options.pageNumber - 1) === 0) { + this.options.pageNumber = this.options.totalPages; + } else { + this.options.pageNumber--; + } this.updatePagination(event); + return false; }; BootstrapTable.prototype.onPageNext = function (event) { - this.options.pageNumber++; + if ((this.options.pageNumber + 1) > this.options.totalPages) { + this.options.pageNumber = 1; + } else { + this.options.pageNumber++; + } this.updatePagination(event); + return false; }; BootstrapTable.prototype.onPageLast = function (event) { this.options.pageNumber = this.totalPages; this.updatePagination(event); + return false; }; BootstrapTable.prototype.onPageNumber = function (event) { @@ -1376,6 +1599,198 @@ } this.options.pageNumber = +$(event.currentTarget).text(); this.updatePagination(event); + return false; + }; + + BootstrapTable.prototype.initRow = function(item, i, data, parentDom) { + var that=this, + key, + html = [], + style = {}, + csses = [], + data_ = '', + attributes = {}, + htmlAttributes = []; + + if ($.inArray(item, this.hiddenRows) > -1) { + return; + } + + style = calculateObjectValue(this.options, this.options.rowStyle, [item, i], style); + + if (style && style.css) { + for (key in style.css) { + csses.push(key + ': ' + style.css[key]); + } + } + + attributes = calculateObjectValue(this.options, + this.options.rowAttributes, [item, i], attributes); + + if (attributes) { + for (key in attributes) { + htmlAttributes.push(sprintf('%s="%s"', key, escapeHTML(attributes[key]))); + } + } + + if (item._data && !$.isEmptyObject(item._data)) { + $.each(item._data, function(k, v) { + // ignore data-index + if (k === 'index') { + return; + } + data_ += sprintf(' data-%s="%s"', k, v); + }); + } + + html.push('' + ); + + if (this.options.cardView) { + html.push(sprintf('
'); + } + + $.each(this.header.fields, function(j, field) { + var text = '', + value_ = getItemField(item, field, that.options.escape), + value = '', + type = '', + cellStyle = {}, + id_ = '', + class_ = that.header.classes[j], + data_ = '', + rowspan_ = '', + colspan_ = '', + title_ = '', + column = that.columns[j]; + + if (that.fromHtml && typeof value_ === 'undefined') { + return; + } + + if (!column.visible) { + return; + } + + if (that.options.cardView && (!column.cardVisible)) { + return; + } + + if (column.escape) { + value_ = escapeHTML(value_); + } + + style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; ')); + + // handle td's id and class + if (item['_' + field + '_id']) { + id_ = sprintf(' id="%s"', item['_' + field + '_id']); + } + if (item['_' + field + '_class']) { + class_ = sprintf(' class="%s"', item['_' + field + '_class']); + } + if (item['_' + field + '_rowspan']) { + rowspan_ = sprintf(' rowspan="%s"', item['_' + field + '_rowspan']); + } + if (item['_' + field + '_colspan']) { + colspan_ = sprintf(' colspan="%s"', item['_' + field + '_colspan']); + } + if (item['_' + field + '_title']) { + title_ = sprintf(' title="%s"', item['_' + field + '_title']); + } + cellStyle = calculateObjectValue(that.header, + that.header.cellStyles[j], [value_, item, i, field], cellStyle); + if (cellStyle.classes) { + class_ = sprintf(' class="%s"', cellStyle.classes); + } + if (cellStyle.css) { + var csses_ = []; + for (var key in cellStyle.css) { + csses_.push(key + ': ' + cellStyle.css[key]); + } + style = sprintf('style="%s"', csses_.concat(that.header.styles[j]).join('; ')); + } + + value = calculateObjectValue(column, + that.header.formatters[j], [value_, item, i], value_); + + if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) { + $.each(item['_' + field + '_data'], function(k, v) { + // ignore data-index + if (k === 'index') { + return; + } + data_ += sprintf(' data-%s="%s"', k, v); + }); + } + + if (column.checkbox || column.radio) { + type = column.checkbox ? 'checkbox' : type; + type = column.radio ? 'radio' : type; + + text = [sprintf(that.options.cardView ? + '
' : '
' + ].join(''); + + item[that.header.stateField] = value === true || (value && value.checked); + } else { + value = typeof value === 'undefined' || value === null ? + that.options.undefinedText : value; + + text = that.options.cardView ? ['
', + that.options.showHeader ? sprintf('%s', style, + getPropertyFromOther(that.columns, 'field', 'title', field)) : '', + sprintf('%s', value), + '
' + ].join('') : [sprintf('', + id_, class_, style, data_, rowspan_, colspan_, title_), + value, + '' + ].join(''); + + // Hide empty data on Card view when smartDisplay is set to true. + if (that.options.cardView && that.options.smartDisplay && value === '') { + // Should set a placeholder for event binding correct fieldIndex + text = '
'; + } + } + + html.push(text); + }); + + if (this.options.cardView) { + html.push(''); + } + html.push('
'); + + return html.join(' '); }; BootstrapTable.prototype.initBody = function (fixedScroll) { @@ -1397,182 +1812,28 @@ this.pageTo = data.length; } + var trFragments = $(document.createDocumentFragment()); + var hasTr; + for (var i = this.pageFrom - 1; i < this.pageTo; i++) { - var key, - item = data[i], - style = {}, - csses = [], - data_ = '', - attributes = {}, - htmlAttributes = []; - - style = calculateObjectValue(this.options, this.options.rowStyle, [item, i], style); - - if (style && style.css) { - for (key in style.css) { - csses.push(key + ': ' + style.css[key]); - } + var item = data[i]; + var tr = this.initRow(item, i, data, trFragments); + hasTr = hasTr || !!tr; + if (tr&&tr!==true) { + trFragments.append(tr); } - - attributes = calculateObjectValue(this.options, - this.options.rowAttributes, [item, i], attributes); - - if (attributes) { - for (key in attributes) { - htmlAttributes.push(sprintf('%s="%s"', key, escapeHTML(attributes[key]))); - } - } - - if (item._data && !$.isEmptyObject(item._data)) { - $.each(item._data, function (k, v) { - // ignore data-index - if (k === 'index') { - return; - } - data_ += sprintf(' data-%s="%s"', k, v); - }); - } - - html.push('' - ); - - if (this.options.cardView) { - html.push(sprintf(''); - } - - $.each(this.header.fields, function (j, field) { - var text = '', - value = getItemField(item, field), - type = '', - cellStyle = {}, - id_ = '', - class_ = that.header.classes[j], - data_ = '', - rowspan_ = '', - title_ = '', - column = that.columns[getFieldIndex(that.columns, field)]; - - if (!column.visible) { - return; - } - - style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; ')); - - value = calculateObjectValue(column, - that.header.formatters[j], [value, item, i], value); - - // handle td's id and class - if (item['_' + field + '_id']) { - id_ = sprintf(' id="%s"', item['_' + field + '_id']); - } - if (item['_' + field + '_class']) { - class_ = sprintf(' class="%s"', item['_' + field + '_class']); - } - if (item['_' + field + '_rowspan']) { - rowspan_ = sprintf(' rowspan="%s"', item['_' + field + '_rowspan']); - } - if (item['_' + field + '_title']) { - title_ = sprintf(' title="%s"', item['_' + field + '_title']); - } - cellStyle = calculateObjectValue(that.header, - that.header.cellStyles[j], [value, item, i], cellStyle); - if (cellStyle.classes) { - class_ = sprintf(' class="%s"', cellStyle.classes); - } - if (cellStyle.css) { - var csses_ = []; - for (var key in cellStyle.css) { - csses_.push(key + ': ' + cellStyle.css[key]); - } - style = sprintf('style="%s"', csses_.concat(that.header.styles[j]).join('; ')); - } - - if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) { - $.each(item['_' + field + '_data'], function (k, v) { - // ignore data-index - if (k === 'index') { - return; - } - data_ += sprintf(' data-%s="%s"', k, v); - }); - } - - if (column.checkbox || column.radio) { - type = column.checkbox ? 'checkbox' : type; - type = column.radio ? 'radio' : type; - - text = [that.options.cardView ? - '
' : '
' - ].join(''); - - item[that.header.stateField] = value === true || (value && value.checked); - } else { - value = typeof value === 'undefined' || value === null ? - that.options.undefinedText : value; - - text = that.options.cardView ? ['
', - that.options.showHeader ? sprintf('%s', style, - getPropertyFromOther(that.columns, 'field', 'title', field)) : '', - sprintf('%s', value), - '
' - ].join('') : [sprintf('', id_, class_, style, data_, rowspan_, title_), - value, - '' - ].join(''); - - // Hide empty data on Card view when smartDisplay is set to true. - if (that.options.cardView && that.options.smartDisplay && value === '') { - // Should set a placeholder for event binding correct fieldIndex - text = '
'; - } - } - - html.push(text); - }); - - if (this.options.cardView) { - html.push(''); - } - - html.push('
'); } // show no records - if (!html.length) { - html.push('', + if (!hasTr) { + trFragments.append('' + sprintf('', - this.$header.find('th').length, this.options.formatNoMatches()), + this.$header.find('th').length, + this.options.formatNoMatches()) + ''); } - this.$body.html(html.join('')); + this.$body.html(trFragments); if (!fixedScroll) { this.scrollTo(0); @@ -1584,16 +1845,17 @@ $tr = $td.parent(), item = that.data[$tr.data('index')], index = $td[0].cellIndex, - field = that.header.fields[that.options.detailView && !that.options.cardView ? index - 1 : index], + fields = that.getVisibleFields(), + field = fields[that.options.detailView && !that.options.cardView ? index - 1 : index], column = that.columns[getFieldIndex(that.columns, field)], - value = getItemField(item, field); + value = getItemField(item, field, that.options.escape); if ($td.find('.detail-icon').length) { return; } that.trigger(e.type === 'click' ? 'click-cell' : 'dbl-click-cell', field, value, item, $td); - that.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr); + that.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr, field); // if click to select - then trigger the checkbox/radio click if (e.type === 'click' && that.options.clickToSelect && column.clickToSelect) { @@ -1613,16 +1875,20 @@ // remove and update if ($tr.next().is('tr.detail-view')) { $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailOpen)); - $tr.next().remove(); that.trigger('collapse-row', index, row); + $tr.next().remove(); } else { $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailClose)); - $tr.after(sprintf('', - $tr.find('td').length, calculateObjectValue(that.options, - that.options.detailFormatter, [index, row], ''))); - that.trigger('expand-row', index, row, $tr.next().find('td')); + $tr.after(sprintf('', $tr.find('td').length)); + var $element = $tr.next().find('td'); + var content = calculateObjectValue(that.options, that.options.detailFormatter, [index, row, $element], ''); + if($element.length === 1) { + $element.append(content); + } + that.trigger('expand-row', index, row, $element); } that.resetView(); + return false; }); this.$selectItem = this.$body.find(sprintf('[name="%s"]', this.options.selectItemName)); @@ -1691,23 +1957,26 @@ this.updateSelected(); this.resetView(); - this.trigger('post-body'); + this.trigger('post-body', data); }; - BootstrapTable.prototype.initServer = function (silent, query) { + BootstrapTable.prototype.initServer = function (silent, query, url) { var that = this, data = {}, params = { - pageSize: this.options.pageSize === this.options.formatAllRows() ? - this.options.totalRows : this.options.pageSize, - pageNumber: this.options.pageNumber, searchText: this.searchText, sortName: this.options.sortName, sortOrder: this.options.sortOrder }, request; - if (!this.options.url && !this.options.ajax) { + if (this.options.pagination) { + params.pageSize = this.options.pageSize === this.options.formatAllRows() ? + this.options.totalRows : this.options.pageSize; + params.pageNumber = this.options.pageNumber; + } + + if (!(url || this.options.url) && !this.options.ajax) { return; } @@ -1717,16 +1986,17 @@ sort: params.sortName, order: params.sortOrder }; + if (this.options.pagination) { - params.limit = this.options.pageSize === this.options.formatAllRows() ? - this.options.totalRows : this.options.pageSize; params.offset = this.options.pageSize === this.options.formatAllRows() ? 0 : this.options.pageSize * (this.options.pageNumber - 1); + params.limit = this.options.pageSize === this.options.formatAllRows() ? + this.options.totalRows : this.options.pageSize; } } if (!($.isEmptyObject(this.filterColumnsPartial))) { - params['filter'] = JSON.stringify(this.filterColumnsPartial, null); + params.filter = JSON.stringify(this.filterColumnsPartial, null); } data = calculateObjectValue(this.options, this.options.queryParams, [params], data); @@ -1743,7 +2013,7 @@ } request = $.extend({}, calculateObjectValue(null, this.options.ajaxOptions), { type: this.options.method, - url: this.options.url, + url: url || this.options.url, data: this.options.contentType === 'application/json' && this.options.method === 'post' ? JSON.stringify(data) : data, cache: this.options.cache, @@ -1754,21 +2024,21 @@ that.load(res); that.trigger('load-success', res); + if (!silent) that.$tableLoading.hide(); }, error: function (res) { that.trigger('load-error', res.status, res); - }, - complete: function () { - if (!silent) { - that.$tableLoading.hide(); - } + if (!silent) that.$tableLoading.hide(); } }); if (this.options.ajax) { calculateObjectValue(this, this.options.ajax, [request], null); } else { - $.ajax(request); + if (this._xhr && this._xhr.readyState !== 4) { + this._xhr.abort(); + } + this._xhr = $.ajax(request); } }; @@ -1820,6 +2090,7 @@ row[that.header.stateField] = false; } }); + this.initHiddenRows(); }; BootstrapTable.prototype.trigger = function (name) { @@ -1893,7 +2164,8 @@ that.$header_.find(sprintf('th[data-field="%s"]', $(this).data('field'))).data($(this).data()); }); - var visibleFields = this.getVisibleFields(); + var visibleFields = this.getVisibleFields(), + $ths = this.$header_.find('th'); this.$body.find('>tr:first-child:not(.no-records-found) > *').each(function (i) { var $this = $(this), @@ -1906,8 +2178,12 @@ index = i - 1; } - that.$header_.find(sprintf('th[data-field="%s"]', visibleFields[index])) - .find('.fht-cell').width($this.innerWidth()); + var $th = that.$header_.find(sprintf('th[data-field="%s"]', visibleFields[index])); + if ($th.length > 1) { + $th = $($ths[$this[0].cellIndex]); + } + + $th.find('.fht-cell').width($this.innerWidth()); }); // horizontal scroll event // TODO: it's probably better improving the layout than binding to scroll event @@ -1935,8 +2211,11 @@ } $.each(this.columns, function (i, column) { - var falign = '', // footer align style - style = '', + var key, + falign = '', // footer align style + valign = '', + csses = [], + style = {}, class_ = sprintf(' class="%s"', column['class']); if (!column.visible) { @@ -1948,9 +2227,17 @@ } falign = sprintf('text-align: %s; ', column.falign ? column.falign : column.align); - style = sprintf('vertical-align: %s; ', column.valign); + valign = sprintf('vertical-align: %s; ', column.valign); - html.push(''); + style = calculateObjectValue(null, that.options.footerStyle); + + if (style && style.css) { + for (key in style.css) { + csses.push(key + ': ' + style.css[key]); + } + } + + html.push(''); html.push('
'); html.push(calculateObjectValue(column, column.footerFormatter, [data], ' ') || ' '); @@ -1962,6 +2249,7 @@ }); this.$tableFooter.find('tr').html(html.join('')); + this.$tableFooter.show(); clearTimeout(this.timeoutFooter_); this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this), this.$el.is(':hidden') ? 100 : 0); @@ -2019,17 +2307,6 @@ } }; - BootstrapTable.prototype.toggleRow = function (index, uniqueId, visible) { - if (index === -1) { - return; - } - - this.$body.find(typeof index !== 'undefined' ? - sprintf('tr[data-index="%s"]', index) : - sprintf('tr[data-uniqueid="%s"]', uniqueId)) - [visible ? 'show' : 'hide'](); - }; - BootstrapTable.prototype.getVisibleFields = function () { var that = this, visibleFields = []; @@ -2059,8 +2336,8 @@ this.$selectItem.length === this.$selectItem.filter(':checked').length); if (this.options.height) { - var toolbarHeight = getRealHeight(this.$toolbar), - paginationHeight = getRealHeight(this.$pagination), + var toolbarHeight = this.$toolbar.outerHeight(true), + paginationHeight = this.$pagination.outerHeight(true), height = this.options.height - toolbarHeight - paginationHeight; this.$tableContainer.css('height', height + 'px'); @@ -2070,6 +2347,7 @@ // remove the element css this.$el.css('margin-top', '0'); this.$tableContainer.css('padding-bottom', '0'); + this.$tableFooter.hide(); return; } @@ -2106,7 +2384,7 @@ // #431: support pagination if (this.options.sidePagination === 'server') { - this.options.totalRows = data.total; + this.options.totalRows = data[this.options.totalField]; fixedScroll = data.fixedScroll; data = data[this.options.dataField]; } else if (!$.isArray(data)) { // support fixedScroll @@ -2124,6 +2402,7 @@ this.initData(data, 'append'); this.initSearch(); this.initPagination(); + this.initSort(); this.initBody(true); }; @@ -2131,6 +2410,7 @@ this.initData(data, 'prepend'); this.initSearch(); this.initPagination(); + this.initSort(); this.initBody(true); }; @@ -2150,6 +2430,9 @@ } if ($.inArray(row[params.field], params.values) !== -1) { this.options.data.splice(i, 1); + if (this.options.sidePagination === 'server') { + this.options.totalRows -= 1; + } } } @@ -2159,6 +2442,7 @@ this.initSearch(); this.initPagination(); + this.initSort(); this.initBody(true); }; @@ -2225,19 +2509,26 @@ }; BootstrapTable.prototype.updateByUniqueId = function (params) { - var rowId; + var that = this; + var allParams = $.isArray(params) ? params : [ params ]; - if (!params.hasOwnProperty('id') || !params.hasOwnProperty('row')) { - return; - } + $.each(allParams, function(i, params) { + var rowId; - rowId = $.inArray(this.getRowByUniqueId(params.id), this.options.data); + if (!params.hasOwnProperty('id') || !params.hasOwnProperty('row')) { + return; + } - if (rowId === -1) { - return; - } + rowId = $.inArray(that.getRowByUniqueId(params.id), that.options.data); - $.extend(this.data[rowId], params.row); + if (rowId === -1) { + return; + } + $.extend(that.options.data[rowId], params.row); + }); + + this.initSearch(); + this.initPagination(); this.initSort(); this.initBody(true); }; @@ -2254,36 +2545,68 @@ }; BootstrapTable.prototype.updateRow = function (params) { - if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) { - return; - } - $.extend(this.data[params.index], params.row); + var that = this; + var allParams = $.isArray(params) ? params : [ params ]; + + $.each(allParams, function(i, params) { + if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) { + return; + } + $.extend(that.options.data[params.index], params.row); + }); + + this.initSearch(); + this.initPagination(); this.initSort(); this.initBody(true); }; + BootstrapTable.prototype.initHiddenRows = function () { + this.hiddenRows = []; + }; + BootstrapTable.prototype.showRow = function (params) { - if (!params.hasOwnProperty('index') || !params.hasOwnProperty('uniqueId')) { - return; - } - this.toggleRow(params.index, params.uniqueId, true); + this.toggleRow(params, true); }; BootstrapTable.prototype.hideRow = function (params) { - if (!params.hasOwnProperty('index') || !params.hasOwnProperty('uniqueId')) { - return; - } - this.toggleRow(params.index, params.uniqueId, false); + this.toggleRow(params, false); }; - BootstrapTable.prototype.getRowsHidden = function (show) { - var rows = $(this.$body[0]).children().filter(':hidden'), - i = 0; - if (show) { - for (; i < rows.length; i++) { - $(rows[i]).show(); - } + BootstrapTable.prototype.toggleRow = function (params, visible) { + var row, index; + + if (params.hasOwnProperty('index')) { + row = this.getData()[params.index]; + } else if (params.hasOwnProperty('uniqueId')) { + row = this.getRowByUniqueId(params.uniqueId); } + + if (!row) { + return; + } + + index = $.inArray(row, this.hiddenRows); + + if (!visible && index === -1) { + this.hiddenRows.push(row); + } else if (visible && index > -1) { + this.hiddenRows.splice(index, 1); + } + this.initBody(true); + }; + + BootstrapTable.prototype.getHiddenRows = function (show) { + var that = this, + data = this.getData(), + rows = []; + + $.each(data, function (i, row) { + if ($.inArray(row, that.hiddenRows) > -1) { + rows.push(row); + } + }); + this.hiddenRows = rows; return rows; }; @@ -2322,6 +2645,10 @@ return; } this.data[params.index][params.field] = params.value; + + if (params.reinit === false) { + return; + } this.initSort(); this.initBody(true); }; @@ -2333,8 +2660,9 @@ BootstrapTable.prototype.getSelections = function () { var that = this; - return $.grep(this.data, function (row) { - return row[that.header.stateField]; + return $.grep(this.options.data, function (row) { + // fix #2424: from html with checkbox + return row[that.header.stateField] === true; }); }; @@ -2354,6 +2682,20 @@ this.checkAll_(false); }; + BootstrapTable.prototype.checkInvert = function () { + var that = this; + var rows = that.$selectItem.filter(':enabled'); + var checked = rows.filter(':checked'); + rows.each(function() { + $(this).prop('checked', !$(this).prop('checked')); + }); + that.updateRows(); + that.updateSelected(); + that.trigger('uncheck-some', checked); + checked = that.getSelections(); + that.trigger('check-some', checked); + }; + BootstrapTable.prototype.checkAll_ = function (checked) { var rows; if (!checked) { @@ -2446,9 +2788,16 @@ BootstrapTable.prototype.refresh = function (params) { if (params && params.url) { this.options.url = params.url; - this.options.pageNumber = 1; } - this.initServer(params && params.silent, params && params.query); + if (params && params.pageNumber) { + this.options.pageNumber = params.pageNumber; + } + if (params && params.pageSize) { + this.options.pageSize = params.pageSize; + } + this.initServer(params && params.silent, + params && params.query, params && params.url); + this.trigger('refresh', params); }; BootstrapTable.prototype.resetWidth = function () { @@ -2474,6 +2823,38 @@ }); }; + BootstrapTable.prototype.getVisibleColumns = function () { + return $.grep(this.columns, function (column) { + return column.visible; + }); + }; + + BootstrapTable.prototype.toggleAllColumns = function (visible) { + $.each(this.columns, function (i, column) { + this.columns[i].visible = visible; + }); + + this.initHeader(); + this.initSearch(); + this.initPagination(); + this.initBody(); + if (this.options.showColumns) { + var $items = this.$toolbar.find('.keep-open input').prop('disabled', false); + + if ($items.filter(':checked').length <= this.options.minimumCountColumns) { + $items.filter(':checked').prop('disabled', true); + } + } + }; + + BootstrapTable.prototype.showAllColumns = function () { + this.toggleAllColumns(true); + }; + + BootstrapTable.prototype.hideAllColumns = function () { + this.toggleAllColumns(false); + }; + BootstrapTable.prototype.filterBy = function (columns) { this.filterColumns = $.isEmptyObject(columns) ? {} : columns; this.options.pageNumber = 1; @@ -2529,7 +2910,7 @@ BootstrapTable.prototype.refreshOptions = function (options) { //If the objects are equivalent then avoid the call of destroy / init methods - if (compareObjects(this.options, options, false)) { + if (compareObjects(this.options, options, true)) { return; } this.options = $.extend(this.options, options); @@ -2608,6 +2989,21 @@ } }; + BootstrapTable.prototype.updateFormatText = function (name, text) { + if (this.options[sprintf('format%s', name)]) { + if (typeof text === 'string') { + this.options[sprintf('format%s', name)] = function () { + return text; + }; + } else if (typeof text === 'function') { + this.options[sprintf('format%s', name)] = text; + } + } + this.initToolbar(); + this.initPagination(); + this.initBody(); + }; + // BOOTSTRAP TABLE PLUGIN DEFINITION // ======================= @@ -2616,9 +3012,9 @@ 'getSelections', 'getAllSelections', 'getData', 'load', 'append', 'prepend', 'remove', 'removeAll', 'insertRow', 'updateRow', 'updateCell', 'updateByUniqueId', 'removeByUniqueId', - 'getRowByUniqueId', 'showRow', 'hideRow', 'getRowsHidden', + 'getRowByUniqueId', 'showRow', 'hideRow', 'getHiddenRows', 'mergeCells', - 'checkAll', 'uncheckAll', + 'checkAll', 'uncheckAll', 'checkInvert', 'check', 'uncheck', 'checkBy', 'uncheckBy', 'refresh', @@ -2626,7 +3022,8 @@ 'resetWidth', 'destroy', 'showLoading', 'hideLoading', - 'showColumn', 'hideColumn', 'getHiddenColumns', + 'showColumn', 'hideColumn', 'getHiddenColumns', 'getVisibleColumns', + 'showAllColumns', 'hideAllColumns', 'filterBy', 'scrollTo', 'getScrollPosition', @@ -2635,7 +3032,8 @@ 'toggleView', 'refreshOptions', 'resetSearch', - 'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows' + 'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows', + 'updateFormatText' ]; $.fn.bootstrapTable = function (option) { @@ -2681,7 +3079,10 @@ sprintf: sprintf, getFieldIndex: getFieldIndex, compareObjects: compareObjects, - calculateObjectValue: calculateObjectValue + calculateObjectValue: calculateObjectValue, + getItemField: getItemField, + objectKeys: objectKeys, + isIEBrowser: isIEBrowser }; // BOOTSTRAP TABLE INIT @@ -2690,5 +3091,4 @@ $(function () { $('[data-toggle="table"]').bootstrapTable(); }); - -}(jQuery); +})(jQuery); diff --git a/public/js/bootstrap-table.min.js b/public/js/bootstrap-table.min.js index 3fe39fc78..9723e1a67 100755 --- a/public/js/bootstrap-table.min.js +++ b/public/js/bootstrap-table.min.js @@ -1,8 +1,8 @@ /* -* bootstrap-table - v1.10.1 - 2016-02-17 +* bootstrap-table - v1.11.1 - 2017-02-22 * https://github.com/wenzhixin/bootstrap-table -* Copyright (c) 2016 zhixin wen +* Copyright (c) 2017 zhixin wen * Licensed MIT License */ -!function(a){"use strict";var b=null,c=function(a){var b=arguments,c=!0,d=1;return a=a.replace(/%s/g,function(){var a=b[d++];return"undefined"==typeof a?(c=!1,""):a}),c?a:""},d=function(b,c,d,e){var f="";return a.each(b,function(a,b){return b[c]===e?(f=b[d],!1):!0}),f},e=function(b,c){var d=-1;return a.each(b,function(a,b){return b.field===c?(d=a,!1):!0}),d},f=function(b){var c,d,e,f=0,g=[];for(c=0;cd;d++)g[c][d]=!1;for(c=0;ce;e++)g[c+e][k]=!0;for(e=0;j>e;e++)g[c][k+e]=!0}},g=function(){if(null===b){var c,d,e=a("

").addClass("fixed-table-scroll-inner"),f=a("

").addClass("fixed-table-scroll-outer");f.append(e),a("body").append(f),c=e[0].offsetWidth,f.css("overflow","scroll"),d=e[0].offsetWidth,c===d&&(d=f[0].clientWidth),f.remove(),b=c-d}return b},h=function(b,d,e,f){var g=d;if("string"==typeof d){var h=d.split(".");h.length>1?(g=window,a.each(h,function(a,b){g=g[b]})):g=window[d]}return"object"==typeof g?g:"function"==typeof g?g.apply(b,e):!g&&"string"==typeof d&&c.apply(this,[d].concat(e))?c.apply(this,[d].concat(e)):f},i=function(b,c,d){var e=Object.getOwnPropertyNames(b),f=Object.getOwnPropertyNames(c),g="";if(d&&e.length!==f.length)return!1;for(var h=0;h-1&&b[g]!==c[g])return!1;return!0},j=function(a){return"string"==typeof a?a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`"):a},k=function(b){var c=0;return b.children().each(function(){c0||navigator.userAgent.match(/Trident.*rv\:11\./))},o=function(b,c){this.options=c,this.$el=a(b),this.$el_=this.$el.clone(),this.timeoutId_=0,this.timeoutFooter_=0,this.init()};o.DEFAULTS={classes:"table table-hover",locale:void 0,height:void 0,undefinedText:"-",sortName:void 0,sortOrder:"asc",striped:!1,columns:[[]],data:[],dataField:"rows",method:"get",url:void 0,ajax:void 0,cache:!0,contentType:"application/json",dataType:"json",ajaxOptions:{},queryParams:function(a){return a},queryParamsType:"limit",responseHandler:function(a){return a},pagination:!1,onlyInfoPagination:!1,sidePagination:"client",totalRows:0,pageNumber:1,pageSize:10,pageList:[10,25,50,100],paginationHAlign:"right",paginationVAlign:"bottom",paginationDetailHAlign:"left",paginationPreText:"‹",paginationNextText:"›",search:!1,searchOnEnterKey:!1,strictSearch:!1,searchAlign:"right",selectItemName:"btSelectItem",showHeader:!0,showFooter:!1,showColumns:!1,showPaginationSwitch:!1,showRefresh:!1,showToggle:!1,buttonsAlign:"right",smartDisplay:!0,escape:!1,minimumCountColumns:1,idField:void 0,uniqueId:void 0,cardView:!1,detailView:!1,detailFormatter:function(){return""},trimOnSearch:!0,clickToSelect:!1,singleSelect:!1,toolbar:void 0,toolbarAlign:"left",checkboxHeader:!0,sortable:!0,silentSort:!0,maintainSelected:!1,searchTimeOut:500,searchText:"",iconSize:void 0,iconsPrefix:"glyphicon",icons:{paginationSwitchDown:"glyphicon-collapse-down icon-chevron-down",paginationSwitchUp:"glyphicon-collapse-up icon-chevron-up",refresh:"glyphicon-refresh icon-refresh",toggle:"glyphicon-list-alt icon-list-alt",columns:"glyphicon-th icon-th",detailOpen:"glyphicon-plus icon-plus",detailClose:"glyphicon-minus icon-minus"},rowStyle:function(){return{}},rowAttributes:function(){return{}},onAll:function(){return!1},onClickCell:function(){return!1},onDblClickCell:function(){return!1},onClickRow:function(){return!1},onDblClickRow:function(){return!1},onSort:function(){return!1},onCheck:function(){return!1},onUncheck:function(){return!1},onCheckAll:function(){return!1},onUncheckAll:function(){return!1},onCheckSome:function(){return!1},onUncheckSome:function(){return!1},onLoadSuccess:function(){return!1},onLoadError:function(){return!1},onColumnSwitch:function(){return!1},onPageChange:function(){return!1},onSearch:function(){return!1},onToggle:function(){return!1},onPreBody:function(){return!1},onPostBody:function(){return!1},onPostHeader:function(){return!1},onExpandRow:function(){return!1},onCollapseRow:function(){return!1},onRefreshOptions:function(){return!1},onResetView:function(){return!1}},o.LOCALES=[],o.LOCALES["en-US"]=o.LOCALES.en={formatLoadingMessage:function(){return"Loading, please wait..."},formatRecordsPerPage:function(a){return c("%s records per page",a)},formatShowingRows:function(a,b,d){return c("Showing %s to %s of %s rows",a,b,d)},formatDetailPagination:function(a){return c("Showing %s rows",a)},formatSearch:function(){return"Search"},formatNoMatches:function(){return"No matching records found"},formatPaginationSwitch:function(){return"Hide/Show pagination"},formatRefresh:function(){return"Refresh"},formatToggle:function(){return"Toggle"},formatColumns:function(){return"Columns"},formatAllRows:function(){return"All"}},a.extend(o.DEFAULTS,o.LOCALES["en-US"]),o.COLUMN_DEFAULTS={radio:!1,checkbox:!1,checkboxEnabled:!0,field:void 0,title:void 0,titleTooltip:void 0,"class":void 0,align:void 0,halign:void 0,falign:void 0,valign:void 0,width:void 0,sortable:!1,order:"asc",visible:!0,switchable:!0,clickToSelect:!0,formatter:void 0,footerFormatter:void 0,events:void 0,sorter:void 0,sortName:void 0,cellStyle:void 0,searchable:!0,searchFormatter:!0,cardVisible:!0},o.EVENTS={"all.bs.table":"onAll","click-cell.bs.table":"onClickCell","dbl-click-cell.bs.table":"onDblClickCell","click-row.bs.table":"onClickRow","dbl-click-row.bs.table":"onDblClickRow","sort.bs.table":"onSort","check.bs.table":"onCheck","uncheck.bs.table":"onUncheck","check-all.bs.table":"onCheckAll","uncheck-all.bs.table":"onUncheckAll","check-some.bs.table":"onCheckSome","uncheck-some.bs.table":"onUncheckSome","load-success.bs.table":"onLoadSuccess","load-error.bs.table":"onLoadError","column-switch.bs.table":"onColumnSwitch","page-change.bs.table":"onPageChange","search.bs.table":"onSearch","toggle.bs.table":"onToggle","pre-body.bs.table":"onPreBody","post-body.bs.table":"onPostBody","post-header.bs.table":"onPostHeader","expand-row.bs.table":"onExpandRow","collapse-row.bs.table":"onCollapseRow","refresh-options.bs.table":"onRefreshOptions","reset-view.bs.table":"onResetView"},o.prototype.init=function(){this.initLocale(),this.initContainer(),this.initTable(),this.initHeader(),this.initData(),this.initFooter(),this.initToolbar(),this.initPagination(),this.initBody(),this.initSearchText(),this.initServer()},o.prototype.initLocale=function(){if(this.options.locale){var b=this.options.locale.split(/-|_/);b[0].toLowerCase(),b[1]&&b[1].toUpperCase(),a.fn.bootstrapTable.locales[this.options.locale]?a.extend(this.options,a.fn.bootstrapTable.locales[this.options.locale]):a.fn.bootstrapTable.locales[b.join("-")]?a.extend(this.options,a.fn.bootstrapTable.locales[b.join("-")]):a.fn.bootstrapTable.locales[b[0]]&&a.extend(this.options,a.fn.bootstrapTable.locales[b[0]])}},o.prototype.initContainer=function(){this.$container=a(['
','
',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'
':"",'
','
{{ trans('general.notes') }}{{ trans('general.file_name') }}{{ trans('general.file_name') }}
', this.header.fields.length)); + } + + if (!this.options.cardView && this.options.detailView) { + html.push('
', + '', + sprintf('', this.options.iconsPrefix, this.options.icons.detailOpen), + '', + '', column['class'] || ''), + '', + that.header.formatters[j] && typeof value === 'string' ? value : '', + that.options.cardView ? '' : '
', this.header.fields.length)); - } - - if (!this.options.cardView && this.options.detailView) { - html.push('', - '', - sprintf('', this.options.iconsPrefix, this.options.icons.detailOpen), - '', - '', - '', - that.header.formatters[j] && typeof value === 'string' ? value : '', - that.options.cardView ? '' : '
%s
%s
','
','
',this.options.formatLoadingMessage(),"
","
",'',"bottom"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'
':"","
","
"].join("")),this.$container.insertAfter(this.$el),this.$tableContainer=this.$container.find(".fixed-table-container"),this.$tableHeader=this.$container.find(".fixed-table-header"),this.$tableBody=this.$container.find(".fixed-table-body"),this.$tableLoading=this.$container.find(".fixed-table-loading"),this.$tableFooter=this.$container.find(".fixed-table-footer"),this.$toolbar=this.$container.find(".fixed-table-toolbar"),this.$pagination=this.$container.find(".fixed-table-pagination"),this.$tableBody.append(this.$el),this.$container.after('
'),this.$el.addClass(this.options.classes),this.options.striped&&this.$el.addClass("table-striped"),-1!==a.inArray("table-no-bordered",this.options.classes.split(" "))&&this.$tableContainer.addClass("table-no-bordered")},o.prototype.initTable=function(){var b=this,c=[],d=[];this.$header=this.$el.find(">thead"),this.$header.length||(this.$header=a("").appendTo(this.$el)),this.$header.find("tr").each(function(){var b=[];a(this).find("th").each(function(){b.push(a.extend({},{title:a(this).html(),"class":a(this).attr("class"),titleTooltip:a(this).attr("title"),rowspan:a(this).attr("rowspan")?+a(this).attr("rowspan"):void 0,colspan:a(this).attr("colspan")?+a(this).attr("colspan"):void 0},a(this).data()))}),c.push(b)}),a.isArray(this.options.columns[0])||(this.options.columns=[this.options.columns]),this.options.columns=a.extend(!0,[],c,this.options.columns),this.columns=[],f(this.options.columns),a.each(this.options.columns,function(c,d){a.each(d,function(d,e){e=a.extend({},o.COLUMN_DEFAULTS,e),"undefined"!=typeof e.fieldIndex&&(b.columns[e.fieldIndex]=e),b.options.columns[c][d]=e})}),this.options.data.length||(this.$el.find(">tbody>tr").each(function(){var c={};c._id=a(this).attr("id"),c._class=a(this).attr("class"),c._data=l(a(this).data()),a(this).find("td").each(function(d){var e=b.columns[d].field;c[e]=a(this).html(),c["_"+e+"_id"]=a(this).attr("id"),c["_"+e+"_class"]=a(this).attr("class"),c["_"+e+"_rowspan"]=a(this).attr("rowspan"),c["_"+e+"_title"]=a(this).attr("title"),c["_"+e+"_data"]=l(a(this).data())}),d.push(c)}),this.options.data=d)},o.prototype.initHeader=function(){var b=this,d={},e=[];this.header={fields:[],styles:[],classes:[],formatters:[],events:[],sorters:[],sortNames:[],cellStyles:[],searchables:[]},a.each(this.options.columns,function(f,g){e.push(""),0==f&&!b.options.cardView&&b.options.detailView&&e.push(c('
',b.options.columns.length)),a.each(g,function(a,f){var g="",h="",i="",j="",k=c(' class="%s"',f["class"]),l=(b.options.sortOrder||f.order,"px"),m=f.width;if(void 0===f.width||b.options.cardView||"string"==typeof f.width&&-1!==f.width.indexOf("%")&&(l="%"),f.width&&"string"==typeof f.width&&(m=f.width.replace("%","").replace("px","")),h=c("text-align: %s; ",f.halign?f.halign:f.align),i=c("text-align: %s; ",f.align),j=c("vertical-align: %s; ",f.valign),j+=c("width: %s; ",!f.checkbox&&!f.radio||m?m?m+l:void 0:"36px"),"undefined"!=typeof f.fieldIndex){if(b.header.fields[f.fieldIndex]=f.field,b.header.styles[f.fieldIndex]=i+j,b.header.classes[f.fieldIndex]=k,b.header.formatters[f.fieldIndex]=f.formatter,b.header.events[f.fieldIndex]=f.events,b.header.sorters[f.fieldIndex]=f.sorter,b.header.sortNames[f.fieldIndex]=f.sortName,b.header.cellStyles[f.fieldIndex]=f.cellStyle,b.header.searchables[f.fieldIndex]=f.searchable,!f.visible)return;if(b.options.cardView&&!f.cardVisible)return;d[f.field]=f}e.push(""),e.push(c('
',b.options.sortable&&f.sortable?"sortable both":"")),g=f.title,f.checkbox&&(!b.options.singleSelect&&b.options.checkboxHeader&&(g=''),b.header.stateField=f.field),f.radio&&(g="",b.header.stateField=f.field,b.options.singleSelect=!0),e.push(g),e.push("
"),e.push('
'),e.push("
"),e.push("")}),e.push("")}),this.$header.html(e.join("")),this.$header.find("th[data-field]").each(function(){a(this).data(d[a(this).data("field")])}),this.$container.off("click",".th-inner").on("click",".th-inner",function(c){var d=a(this);return d.closest(".bootstrap-table")[0]!==b.$container[0]?!1:void(b.options.sortable&&d.parent().data().sortable&&b.onSort(c))}),this.$header.children().children().off("keypress").on("keypress",function(c){if(b.options.sortable&&a(this).data().sortable){var d=c.keyCode||c.which;13==d&&b.onSort(c)}}),!this.options.showHeader||this.options.cardView?(this.$header.hide(),this.$tableHeader.hide(),this.$tableLoading.css("top",0)):(this.$header.show(),this.$tableHeader.show(),this.$tableLoading.css("top",this.$header.outerHeight()+1),this.getCaret()),this.$selectAll=this.$header.find('[name="btSelectAll"]'),this.$selectAll.off("click").on("click",function(){var c=a(this).prop("checked");b[c?"checkAll":"uncheckAll"](),b.updateSelected()})},o.prototype.initFooter=function(){!this.options.showFooter||this.options.cardView?this.$tableFooter.hide():this.$tableFooter.show()},o.prototype.initData=function(a,b){this.data="append"===b?this.data.concat(a):"prepend"===b?[].concat(a).concat(this.data):a||this.options.data,this.options.data="append"===b?this.options.data.concat(a):"prepend"===b?[].concat(a).concat(this.options.data):this.data,"server"!==this.options.sidePagination&&this.initSort()},o.prototype.initSort=function(){var b=this,c=this.options.sortName,d="desc"===this.options.sortOrder?-1:1,e=a.inArray(this.options.sortName,this.header.fields);-1!==e&&this.data.sort(function(f,g){b.header.sortNames[e]&&(c=b.header.sortNames[e]);var i=m(f,c,b.options.escape),j=m(g,c,b.options.escape),k=h(b.header,b.header.sorters[e],[i,j]);return void 0!==k?d*k:((void 0===i||null===i)&&(i=""),(void 0===j||null===j)&&(j=""),a.isNumeric(i)&&a.isNumeric(j)?(i=parseFloat(i),j=parseFloat(j),j>i?-1*d:d):i===j?0:("string"!=typeof i&&(i=i.toString()),-1===i.localeCompare(j)?-1*d:d))})},o.prototype.onSort=function(b){var c="keypress"===b.type?a(b.currentTarget):a(b.currentTarget).parent(),d=this.$header.find("th").eq(c.index());return this.$header.add(this.$header_).find("span.order").remove(),this.options.sortName===c.data("field")?this.options.sortOrder="asc"===this.options.sortOrder?"desc":"asc":(this.options.sortName=c.data("field"),this.options.sortOrder="asc"===c.data("order")?"desc":"asc"),this.trigger("sort",this.options.sortName,this.options.sortOrder),c.add(d).data("order",this.options.sortOrder),this.getCaret(),"server"===this.options.sidePagination?void this.initServer(this.options.silentSort):(this.initSort(),void this.initBody())},o.prototype.initToolbar=function(){var b,d,f=this,g=[],i=0,j=0;this.$toolbar.find(".bars").children().length&&a("body").append(a(this.options.toolbar)),this.$toolbar.html(""),("string"==typeof this.options.toolbar||"object"==typeof this.options.toolbar)&&a(c('
',this.options.toolbarAlign)).appendTo(this.$toolbar).append(a(this.options.toolbar)),g=[c('
',this.options.buttonsAlign,this.options.buttonsAlign)],"string"==typeof this.options.icons&&(this.options.icons=h(null,this.options.icons)),this.options.showPaginationSwitch&&g.push(c('"),this.options.showRefresh&&g.push(c('"),this.options.showToggle&&g.push(c('"),this.options.showColumns&&(g.push(c('
',this.options.formatColumns()),'",'","
")),g.push("
"),(this.showToolbar||g.length>2)&&this.$toolbar.append(g.join("")),this.options.showPaginationSwitch&&this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",a.proxy(this.togglePagination,this)),this.options.showRefresh&&this.$toolbar.find('button[name="refresh"]').off("click").on("click",a.proxy(this.refresh,this)),this.options.showToggle&&this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){f.toggleView()}),this.options.showColumns&&(b=this.$toolbar.find(".keep-open"),j<=this.options.minimumCountColumns&&b.find("input").prop("disabled",!0),b.find("li").off("click").on("click",function(a){a.stopImmediatePropagation()}),b.find("input").off("click").on("click",function(){var b=a(this);f.toggleColumn(e(f.columns,a(this).data("field")),b.prop("checked"),!1),f.trigger("column-switch",a(this).data("field"),b.prop("checked"))})),this.options.search&&(g=[],g.push('"),this.$toolbar.append(g.join("")),d=this.$toolbar.find(".search input"),d.off("keyup drop").on("keyup drop",function(a){f.options.searchOnEnterKey&&13!==a.keyCode||(clearTimeout(i),i=setTimeout(function(){f.onSearch(a)},f.options.searchTimeOut))}),n()&&d.off("mouseup").on("mouseup",function(a){clearTimeout(i),i=setTimeout(function(){f.onSearch(a)},f.options.searchTimeOut)}))},o.prototype.onSearch=function(b){var c=a.trim(a(b.currentTarget).val());this.options.trimOnSearch&&a(b.currentTarget).val()!==c&&a(b.currentTarget).val(c),c!==this.searchText&&(this.searchText=c,this.options.searchText=c,this.options.pageNumber=1,this.initSearch(),this.updatePagination(),this.trigger("search",c))},o.prototype.initSearch=function(){var b=this;if("server"!==this.options.sidePagination){var c=this.searchText&&this.searchText.toLowerCase(),d=a.isEmptyObject(this.filterColumns)?null:this.filterColumns;this.data=d?a.grep(this.options.data,function(b){for(var c in d)if(a.isArray(d[c])){if(-1===a.inArray(b[c],d[c]))return!1}else if(b[c]!==d[c])return!1;return!0}):this.options.data,this.data=c?a.grep(this.data,function(d,f){for(var g in d){g=a.isNumeric(g)?parseInt(g,10):g;var i=d[g],j=b.columns[e(b.columns,g)],k=a.inArray(g,b.header.fields);j&&j.searchFormatter&&(i=h(j,b.header.formatters[k],[i,d,f],i));var l=a.inArray(g,b.header.fields);if(-1!==l&&b.header.searchables[l]&&("string"==typeof i||"number"==typeof i))if(b.options.strictSearch){if((i+"").toLowerCase()===c)return!0}else if(-1!==(i+"").toLowerCase().indexOf(c))return!0}return!1}):this.data}},o.prototype.initPagination=function(){if(!this.options.pagination)return void this.$pagination.hide();this.$pagination.show();var b,d,e,f,g,h,i,j,k,l=this,m=[],n=!1,o=this.getData();if("server"!==this.options.sidePagination&&(this.options.totalRows=o.length),this.totalPages=0,this.options.totalRows){if(this.options.pageSize===this.options.formatAllRows())this.options.pageSize=this.options.totalRows,n=!0;else if(this.options.pageSize===this.options.totalRows){var p="string"==typeof this.options.pageList?this.options.pageList.replace("[","").replace("]","").replace(/ /g,"").toLowerCase().split(","):this.options.pageList;a.inArray(this.options.formatAllRows().toLowerCase(),p)>-1&&(n=!0)}this.totalPages=~~((this.options.totalRows-1)/this.options.pageSize)+1,this.options.totalPages=this.totalPages}if(this.totalPages>0&&this.options.pageNumber>this.totalPages&&(this.options.pageNumber=this.totalPages),this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1,this.pageTo=this.options.pageNumber*this.options.pageSize,this.pageTo>this.options.totalRows&&(this.pageTo=this.options.totalRows),m.push('
','',this.options.onlyInfoPagination?this.options.formatDetailPagination(this.options.totalRows):this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),""),!this.options.onlyInfoPagination){m.push('');var q=[c('',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?"dropdown":"dropup"),'",'"),m.push(this.options.formatRecordsPerPage(q.join(""))),m.push(""),m.push("
",'")}this.$pagination.html(m.join("")),this.options.onlyInfoPagination||(f=this.$pagination.find(".page-list a"),g=this.$pagination.find(".page-first"),h=this.$pagination.find(".page-pre"),i=this.$pagination.find(".page-next"),j=this.$pagination.find(".page-last"),k=this.$pagination.find(".page-number"),this.options.smartDisplay&&(this.totalPages<=1&&this.$pagination.find("div.pagination").hide(),(r.length<2||this.options.totalRows<=r[0])&&this.$pagination.find("span.page-list").hide(),this.$pagination[this.getData().length?"show":"hide"]()),n&&(this.options.pageSize=this.options.formatAllRows()),f.off("click").on("click",a.proxy(this.onPageListChange,this)),g.off("click").on("click",a.proxy(this.onPageFirst,this)),h.off("click").on("click",a.proxy(this.onPagePre,this)),i.off("click").on("click",a.proxy(this.onPageNext,this)),j.off("click").on("click",a.proxy(this.onPageLast,this)),k.off("click").on("click",a.proxy(this.onPageNumber,this)))},o.prototype.updatePagination=function(b){b&&a(b.currentTarget).hasClass("disabled")||(this.options.maintainSelected||this.resetRows(),this.initPagination(),"server"===this.options.sidePagination?this.initServer():this.initBody(),this.trigger("page-change",this.options.pageNumber,this.options.pageSize))},o.prototype.onPageListChange=function(b){var c=a(b.currentTarget);c.parent().addClass("active").siblings().removeClass("active"),this.options.pageSize=c.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+c.text(),this.$toolbar.find(".page-size").text(this.options.pageSize),this.updatePagination(b)},o.prototype.onPageFirst=function(a){this.options.pageNumber=1,this.updatePagination(a)},o.prototype.onPagePre=function(a){this.options.pageNumber-1==0?this.options.pageNumber=this.options.totalPages:this.options.pageNumber--,this.updatePagination(a)},o.prototype.onPageNext=function(a){this.options.pageNumber+1>this.options.totalPages?this.options.pageNumber=1:this.options.pageNumber++,this.updatePagination(a)},o.prototype.onPageLast=function(a){this.options.pageNumber=this.totalPages,this.updatePagination(a)},o.prototype.onPageNumber=function(b){this.options.pageNumber!==+a(b.currentTarget).text()&&(this.options.pageNumber=+a(b.currentTarget).text(),this.updatePagination(b))},o.prototype.initBody=function(b){var f=this,g=[],i=this.getData();this.trigger("pre-body",i),this.$body=this.$el.find(">tbody"),this.$body.length||(this.$body=a("").appendTo(this.$el)),this.options.pagination&&"server"!==this.options.sidePagination||(this.pageFrom=1,this.pageTo=i.length);for(var k=this.pageFrom-1;k"),this.options.cardView&&g.push(c('',this.header.fields.length)),!this.options.cardView&&this.options.detailView&&g.push("",'',c('',this.options.iconsPrefix,this.options.icons.detailOpen),"",""),a.each(this.header.fields,function(b,i){var j="",l=m(n,i,f.options.escape),q="",r={},s="",t=f.header.classes[b],u="",v="",w="",x=f.columns[e(f.columns,i)];if(x.visible){if(o=c('style="%s"',p.concat(f.header.styles[b]).join("; ")),l=h(x,f.header.formatters[b],[l,n,k],l),n["_"+i+"_id"]&&(s=c(' id="%s"',n["_"+i+"_id"])),n["_"+i+"_class"]&&(t=c(' class="%s"',n["_"+i+"_class"])),n["_"+i+"_rowspan"]&&(v=c(' rowspan="%s"',n["_"+i+"_rowspan"])),n["_"+i+"_title"]&&(w=c(' title="%s"',n["_"+i+"_title"])),r=h(f.header,f.header.cellStyles[b],[l,n,k],r),r.classes&&(t=c(' class="%s"',r.classes)),r.css){var y=[];for(var z in r.css)y.push(z+": "+r.css[z]);o=c('style="%s"',y.concat(f.header.styles[b]).join("; "))}n["_"+i+"_data"]&&!a.isEmptyObject(n["_"+i+"_data"])&&a.each(n["_"+i+"_data"],function(a,b){"index"!==a&&(u+=c(' data-%s="%s"',a,b))}),x.checkbox||x.radio?(q=x.checkbox?"checkbox":q,q=x.radio?"radio":q,j=[c(f.options.cardView?'
':'',x["class"]||""),"",f.header.formatters[b]&&"string"==typeof l?l:"",f.options.cardView?"
":""].join(""),n[f.header.stateField]=l===!0||l&&l.checked):(l="undefined"==typeof l||null===l?f.options.undefinedText:l,j=f.options.cardView?['
',f.options.showHeader?c('%s',o,d(f.columns,"field","title",i)):"",c('%s',l),"
"].join(""):[c("",s,t,o,u,v,w),l,""].join(""),f.options.cardView&&f.options.smartDisplay&&""===l&&(j='
')),g.push(j)}}),this.options.cardView&&g.push(""),g.push("")}g.length||g.push('',c('%s',this.$header.find("th").length,this.options.formatNoMatches()),""),this.$body.html(g.join("")),b||this.scrollTo(0),this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick",function(b){var d=a(this),g=d.parent(),h=f.data[g.data("index")],i=d[0].cellIndex,j=f.header.fields[f.options.detailView&&!f.options.cardView?i-1:i],k=f.columns[e(f.columns,j)],l=m(h,j,f.options.escape);if(!d.find(".detail-icon").length&&(f.trigger("click"===b.type?"click-cell":"dbl-click-cell",j,l,h,d),f.trigger("click"===b.type?"click-row":"dbl-click-row",h,g),"click"===b.type&&f.options.clickToSelect&&k.clickToSelect)){var n=g.find(c('[name="%s"]',f.options.selectItemName));n.length&&n[0].click()}}),this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click",function(){var b=a(this),d=b.parent().parent(),e=d.data("index"),g=i[e];if(d.next().is("tr.detail-view"))b.find("i").attr("class",c("%s %s",f.options.iconsPrefix,f.options.icons.detailOpen)),d.next().remove(),f.trigger("collapse-row",e,g);else{b.find("i").attr("class",c("%s %s",f.options.iconsPrefix,f.options.icons.detailClose)),d.after(c('',d.find("td").length));var j=d.next().find("td"),k=h(f.options,f.options.detailFormatter,[e,g,j],"");1===j.length&&j.append(k),f.trigger("expand-row",e,g,j)}f.resetView()}),this.$selectItem=this.$body.find(c('[name="%s"]',this.options.selectItemName)),this.$selectItem.off("click").on("click",function(b){b.stopImmediatePropagation();var c=a(this),d=c.prop("checked"),e=f.data[c.data("index")];f.options.maintainSelected&&a(this).is(":radio")&&a.each(f.options.data,function(a,b){b[f.header.stateField]=!1}),e[f.header.stateField]=d,f.options.singleSelect&&(f.$selectItem.not(this).each(function(){f.data[a(this).data("index")][f.header.stateField]=!1}),f.$selectItem.filter(":checked").not(this).prop("checked",!1)),f.updateSelected(),f.trigger(d?"check":"uncheck",e,c)}),a.each(this.header.events,function(b,c){if(c){"string"==typeof c&&(c=h(null,c));var d=f.header.fields[b],e=a.inArray(d,f.getVisibleFields());f.options.detailView&&!f.options.cardView&&(e+=1);for(var g in c)f.$body.find(">tr:not(.no-records-found)").each(function(){var b=a(this),h=b.find(f.options.cardView?".card-view":"td").eq(e),i=g.indexOf(" "),j=g.substring(0,i),k=g.substring(i+1),l=c[g];h.find(k).off(j).on(j,function(a){var c=b.data("index"),e=f.data[c],g=e[d];l.apply(this,[a,g,e,c])})})}}),this.updateSelected(),this.resetView(),this.trigger("post-body")},o.prototype.initServer=function(b,c){var d,e=this,f={},g={ -searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder};this.options.pagination&&(g.pageSize=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,g.pageNumber=this.options.pageNumber),(this.options.url||this.options.ajax)&&("limit"===this.options.queryParamsType&&(g={search:g.searchText,sort:g.sortName,order:g.sortOrder},this.options.pagination&&(g.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,g.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1))),a.isEmptyObject(this.filterColumnsPartial)||(g.filter=JSON.stringify(this.filterColumnsPartial,null)),f=h(this.options,this.options.queryParams,[g],f),a.extend(f,c||{}),f!==!1&&(b||this.$tableLoading.show(),d=a.extend({},h(null,this.options.ajaxOptions),{type:this.options.method,url:this.options.url,data:"application/json"===this.options.contentType&&"post"===this.options.method?JSON.stringify(f):f,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(a){a=h(e.options,e.options.responseHandler,[a],a),e.load(a),e.trigger("load-success",a),b||e.$tableLoading.hide()},error:function(a){e.trigger("load-error",a.status,a),b||e.$tableLoading.hide()}}),this.options.ajax?h(this,this.options.ajax,[d],null):a.ajax(d)))},o.prototype.initSearchText=function(){if(this.options.search&&""!==this.options.searchText){var a=this.$toolbar.find(".search input");a.val(this.options.searchText),this.onSearch({currentTarget:a})}},o.prototype.getCaret=function(){var b=this;a.each(this.$header.find("th"),function(c,d){a(d).find(".sortable").removeClass("desc asc").addClass(a(d).data("field")===b.options.sortName?b.options.sortOrder:"both")})},o.prototype.updateSelected=function(){var b=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;this.$selectAll.add(this.$selectAll_).prop("checked",b),this.$selectItem.each(function(){a(this).closest("tr")[a(this).prop("checked")?"addClass":"removeClass"]("selected")})},o.prototype.updateRows=function(){var b=this;this.$selectItem.each(function(){b.data[a(this).data("index")][b.header.stateField]=a(this).prop("checked")})},o.prototype.resetRows=function(){var b=this;a.each(this.data,function(a,c){b.$selectAll.prop("checked",!1),b.$selectItem.prop("checked",!1),b.header.stateField&&(c[b.header.stateField]=!1)})},o.prototype.trigger=function(b){var c=Array.prototype.slice.call(arguments,1);b+=".bs.table",this.options[o.EVENTS[b]].apply(this.options,c),this.$el.trigger(a.Event(b),c),this.options.onAll(b,c),this.$el.trigger(a.Event("all.bs.table"),[b,c])},o.prototype.resetHeader=function(){clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(a.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)},o.prototype.fitHeader=function(){var b,d,e,f,h=this;if(h.$el.is(":hidden"))return void(h.timeoutId_=setTimeout(a.proxy(h.fitHeader,h),100));if(b=this.$tableBody.get(0),d=b.scrollWidth>b.clientWidth&&b.scrollHeight>b.clientHeight+this.$header.outerHeight()?g():0,this.$el.css("margin-top",-this.$header.outerHeight()),e=a(":focus"),e.length>0){var i=e.parents("th");if(i.length>0){var j=i.attr("data-field");if(void 0!==j){var k=this.$header.find("[data-field='"+j+"']");k.length>0&&k.find(":input").addClass("focus-temp")}}}this.$header_=this.$header.clone(!0,!0),this.$selectAll_=this.$header_.find('[name="btSelectAll"]'),this.$tableHeader.css({"margin-right":d}).find("table").css("width",this.$el.outerWidth()).html("").attr("class",this.$el.attr("class")).append(this.$header_),f=a(".focus-temp:visible:eq(0)"),f.length>0&&(f.focus(),this.$header.find(".focus-temp").removeClass("focus-temp")),this.$header.find("th[data-field]").each(function(){h.$header_.find(c('th[data-field="%s"]',a(this).data("field"))).data(a(this).data())});var l=this.getVisibleFields();this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(b){var d=a(this),e=b;h.options.detailView&&!h.options.cardView&&(0===b&&h.$header_.find("th.detail").find(".fht-cell").width(d.innerWidth()),e=b-1),h.$header_.find(c('th[data-field="%s"]',l[e])).find(".fht-cell").width(d.innerWidth())}),this.$tableBody.off("scroll").on("scroll",function(){h.$tableHeader.scrollLeft(a(this).scrollLeft()),h.options.showFooter&&!h.options.cardView&&h.$tableFooter.scrollLeft(a(this).scrollLeft())}),h.trigger("post-header")},o.prototype.resetFooter=function(){var b=this,d=b.getData(),e=[];this.options.showFooter&&!this.options.cardView&&(!this.options.cardView&&this.options.detailView&&e.push('
 
'),a.each(this.columns,function(a,f){var g="",i="",j=c(' class="%s"',f["class"]);f.visible&&(!b.options.cardView||f.cardVisible)&&(g=c("text-align: %s; ",f.falign?f.falign:f.align),i=c("vertical-align: %s; ",f.valign),e.push(""),e.push('
'),e.push(h(f,f.footerFormatter,[d]," ")||" "),e.push("
"),e.push('
'),e.push("
"),e.push(""))}),this.$tableFooter.find("tr").html(e.join("")),clearTimeout(this.timeoutFooter_),this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0))},o.prototype.fitFooter=function(){var b,c,d;return clearTimeout(this.timeoutFooter_),this.$el.is(":hidden")?void(this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),100)):(c=this.$el.css("width"),d=c>this.$tableBody.width()?g():0,this.$tableFooter.css({"margin-right":d}).find("table").css("width",c).attr("class",this.$el.attr("class")),b=this.$tableFooter.find("td"),void this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(c){var d=a(this);b.eq(c).find(".fht-cell").width(d.innerWidth())}))},o.prototype.toggleColumn=function(a,b,d){if(-1!==a&&(this.columns[a].visible=b,this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns)){var e=this.$toolbar.find(".keep-open input").prop("disabled",!1);d&&e.filter(c('[value="%s"]',a)).prop("checked",b),e.filter(":checked").length<=this.options.minimumCountColumns&&e.filter(":checked").prop("disabled",!0)}},o.prototype.toggleRow=function(a,b,d){-1!==a&&this.$body.find("undefined"!=typeof a?c('tr[data-index="%s"]',a):c('tr[data-uniqueid="%s"]',b))[d?"show":"hide"]()},o.prototype.getVisibleFields=function(){var b=this,c=[];return a.each(this.header.fields,function(a,d){var f=b.columns[e(b.columns,d)];f.visible&&c.push(d)}),c},o.prototype.resetView=function(a){var b=0;if(a&&a.height&&(this.options.height=a.height),this.$selectAll.prop("checked",this.$selectItem.length>0&&this.$selectItem.length===this.$selectItem.filter(":checked").length),this.options.height){var c=k(this.$toolbar),d=k(this.$pagination),e=this.options.height-c-d;this.$tableContainer.css("height",e+"px")}return this.options.cardView?(this.$el.css("margin-top","0"),void this.$tableContainer.css("padding-bottom","0")):(this.options.showHeader&&this.options.height?(this.$tableHeader.show(),this.resetHeader(),b+=this.$header.outerHeight()):(this.$tableHeader.hide(),this.trigger("post-header")),this.options.showFooter&&(this.resetFooter(),this.options.height&&(b+=this.$tableFooter.outerHeight()+1)),this.getCaret(),this.$tableContainer.css("padding-bottom",b+"px"),void this.trigger("reset-view"))},o.prototype.getData=function(b){return!this.searchText&&a.isEmptyObject(this.filterColumns)&&a.isEmptyObject(this.filterColumnsPartial)?b?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data:b?this.data.slice(this.pageFrom-1,this.pageTo):this.data},o.prototype.load=function(b){var c=!1;"server"===this.options.sidePagination?(this.options.totalRows=b.total,c=b.fixedScroll,b=b[this.options.dataField]):a.isArray(b)||(c=b.fixedScroll,b=b.data),this.initData(b),this.initSearch(),this.initPagination(),this.initBody(c)},o.prototype.append=function(a){this.initData(a,"append"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},o.prototype.prepend=function(a){this.initData(a,"prepend"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},o.prototype.remove=function(b){var c,d,e=this.options.data.length;if(b.hasOwnProperty("field")&&b.hasOwnProperty("values")){for(c=e-1;c>=0;c--)d=this.options.data[c],d.hasOwnProperty(b.field)&&-1!==a.inArray(d[b.field],b.values)&&this.options.data.splice(c,1);e!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))}},o.prototype.removeAll=function(){this.options.data.length>0&&(this.options.data.splice(0,this.options.data.length),this.initSearch(),this.initPagination(),this.initBody(!0))},o.prototype.getRowByUniqueId=function(a){var b,c,d,e=this.options.uniqueId,f=this.options.data.length,g=null;for(b=f-1;b>=0;b--){if(c=this.options.data[b],c.hasOwnProperty(e))d=c[e];else{if(!c._data.hasOwnProperty(e))continue;d=c._data[e]}if("string"==typeof d?a=a.toString():"number"==typeof d&&(Number(d)===d&&d%1===0?a=parseInt(a):d===Number(d)&&0!==d&&(a=parseFloat(a))),d===a){g=c;break}}return g},o.prototype.removeByUniqueId=function(a){var b=this.options.data.length,c=this.getRowByUniqueId(a);c&&this.options.data.splice(this.options.data.indexOf(c),1),b!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initBody(!0))},o.prototype.updateByUniqueId=function(b){var c;b.hasOwnProperty("id")&&b.hasOwnProperty("row")&&(c=a.inArray(this.getRowByUniqueId(b.id),this.options.data),-1!==c&&(a.extend(this.data[c],b.row),this.initSort(),this.initBody(!0)))},o.prototype.insertRow=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("row")&&(this.data.splice(a.index,0,a.row),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))},o.prototype.updateRow=function(b){b.hasOwnProperty("index")&&b.hasOwnProperty("row")&&(a.extend(this.data[b.index],b.row),this.initSort(),this.initBody(!0))},o.prototype.showRow=function(a){(a.hasOwnProperty("index")||a.hasOwnProperty("uniqueId"))&&this.toggleRow(a.index,a.uniqueId,!0)},o.prototype.hideRow=function(a){(a.hasOwnProperty("index")||a.hasOwnProperty("uniqueId"))&&this.toggleRow(a.index,a.uniqueId,!1)},o.prototype.getRowsHidden=function(b){var c=a(this.$body[0]).children().filter(":hidden"),d=0;if(b)for(;dtr");if(this.options.detailView&&!this.options.cardView&&(g+=1),e=j.eq(f).find(">td").eq(g),!(0>f||0>g||f>=this.data.length)){for(c=f;f+h>c;c++)for(d=g;g+i>d;d++)j.eq(c).find(">td").eq(d).hide();e.attr("rowspan",h).attr("colspan",i).show()}},o.prototype.updateCell=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("field")&&a.hasOwnProperty("value")&&(this.data[a.index][a.field]=a.value,a.reinit!==!1&&(this.initSort(),this.initBody(!0)))},o.prototype.getOptions=function(){return this.options},o.prototype.getSelections=function(){var b=this;return a.grep(this.data,function(a){return a[b.header.stateField]})},o.prototype.getAllSelections=function(){var b=this;return a.grep(this.options.data,function(a){return a[b.header.stateField]})},o.prototype.checkAll=function(){this.checkAll_(!0)},o.prototype.uncheckAll=function(){this.checkAll_(!1)},o.prototype.checkInvert=function(){var b=this,c=b.$selectItem.filter(":enabled"),d=c.filter(":checked");c.each(function(){a(this).prop("checked",!a(this).prop("checked"))}),b.updateRows(),b.updateSelected(),b.trigger("uncheck-some",d),d=b.getSelections(),b.trigger("check-some",d)},o.prototype.checkAll_=function(a){var b;a||(b=this.getSelections()),this.$selectAll.add(this.$selectAll_).prop("checked",a),this.$selectItem.filter(":enabled").prop("checked",a),this.updateRows(),a&&(b=this.getSelections()),this.trigger(a?"check-all":"uncheck-all",b)},o.prototype.check=function(a){this.check_(!0,a)},o.prototype.uncheck=function(a){this.check_(!1,a)},o.prototype.check_=function(a,b){var d=this.$selectItem.filter(c('[data-index="%s"]',b)).prop("checked",a);this.data[b][this.header.stateField]=a,this.updateSelected(),this.trigger(a?"check":"uncheck",this.data[b],d)},o.prototype.checkBy=function(a){this.checkBy_(!0,a)},o.prototype.uncheckBy=function(a){this.checkBy_(!1,a)},o.prototype.checkBy_=function(b,d){if(d.hasOwnProperty("field")&&d.hasOwnProperty("values")){var e=this,f=[];a.each(this.options.data,function(g,h){if(!h.hasOwnProperty(d.field))return!1;if(-1!==a.inArray(h[d.field],d.values)){var i=e.$selectItem.filter(":enabled").filter(c('[data-index="%s"]',g)).prop("checked",b);h[e.header.stateField]=b,f.push(h),e.trigger(b?"check":"uncheck",h,i)}}),this.updateSelected(),this.trigger(b?"check-some":"uncheck-some",f)}},o.prototype.destroy=function(){this.$el.insertBefore(this.$container),a(this.options.toolbar).insertBefore(this.$el),this.$container.next().remove(),this.$container.remove(),this.$el.html(this.$el_.html()).css("margin-top","0").attr("class",this.$el_.attr("class")||"")},o.prototype.showLoading=function(){this.$tableLoading.show()},o.prototype.hideLoading=function(){this.$tableLoading.hide()},o.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var a=this.$toolbar.find('button[name="paginationSwitch"] i');this.options.pagination?a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown):a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp),this.updatePagination()},o.prototype.refresh=function(a){a&&a.url&&(this.options.url=a.url,this.options.pageNumber=1),this.initServer(a&&a.silent,a&&a.query)},o.prototype.resetWidth=function(){this.options.showHeader&&this.options.height&&this.fitHeader(),this.options.showFooter&&this.fitFooter()},o.prototype.showColumn=function(a){this.toggleColumn(e(this.columns,a),!0,!0)},o.prototype.hideColumn=function(a){this.toggleColumn(e(this.columns,a),!1,!0)},o.prototype.getHiddenColumns=function(){return a.grep(this.columns,function(a){return!a.visible})},o.prototype.filterBy=function(b){this.filterColumns=a.isEmptyObject(b)?{}:b,this.options.pageNumber=1,this.initSearch(),this.updatePagination()},o.prototype.scrollTo=function(a){return"string"==typeof a&&(a="bottom"===a?this.$tableBody[0].scrollHeight:0),"number"==typeof a&&this.$tableBody.scrollTop(a),"undefined"==typeof a?this.$tableBody.scrollTop():void 0},o.prototype.getScrollPosition=function(){return this.scrollTo()},o.prototype.selectPage=function(a){a>0&&a<=this.options.totalPages&&(this.options.pageNumber=a,this.updatePagination())},o.prototype.prevPage=function(){this.options.pageNumber>1&&(this.options.pageNumber--,this.updatePagination())},o.prototype.nextPage=function(){this.options.pageNumber tr[data-index="%s"]',b));d.next().is("tr.detail-view")===(a?!1:!0)&&d.find("> td > .detail-icon").click()},o.prototype.expandRow=function(a){this.expandRow_(!0,a)},o.prototype.collapseRow=function(a){this.expandRow_(!1,a)},o.prototype.expandAllRows=function(b){if(b){var d=this.$body.find(c('> tr[data-index="%s"]',0)),e=this,f=null,g=!1,h=-1;if(d.next().is("tr.detail-view")?d.next().next().is("tr.detail-view")||(d.next().find(".detail-icon").click(),g=!0):(d.find("> td > .detail-icon").click(),g=!0),g)try{h=setInterval(function(){f=e.$body.find("tr.detail-view").last().find(".detail-icon"),f.length>0?f.click():clearInterval(h)},1)}catch(i){clearInterval(h)}}else for(var j=this.$body.children(),k=0;kd;d++)g[c][d]=!1;for(c=0;ce;e++)g[c+e][k]=!0;for(e=0;j>e;e++)g[c][k+e]=!0}},g=function(){if(null===b){var c,d,e=a("

").addClass("fixed-table-scroll-inner"),f=a("

").addClass("fixed-table-scroll-outer");f.append(e),a("body").append(f),c=e[0].offsetWidth,f.css("overflow","scroll"),d=e[0].offsetWidth,c===d&&(d=f[0].clientWidth),f.remove(),b=c-d}return b},h=function(b,d,e,f){var g=d;if("string"==typeof d){var h=d.split(".");h.length>1?(g=window,a.each(h,function(a,b){g=g[b]})):g=window[d]}return"object"==typeof g?g:"function"==typeof g?g.apply(b,e||[]):!g&&"string"==typeof d&&c.apply(this,[d].concat(e))?c.apply(this,[d].concat(e)):f},i=function(b,c,d){var e=Object.getOwnPropertyNames(b),f=Object.getOwnPropertyNames(c),g="";if(d&&e.length!==f.length)return!1;for(var h=0;h-1&&b[g]!==c[g])return!1;return!0},j=function(a){return"string"==typeof a?a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`"):a},k=function(a){for(var b in a){var c=b.split(/(?=[A-Z])/).join("-").toLowerCase();c!==b&&(a[c]=a[b],delete a[b])}return a},l=function(a,b,c){var d=a;if("string"!=typeof b||a.hasOwnProperty(b))return c?j(a[b]):a[b];var e=b.split(".");for(var f in e)e.hasOwnProperty(f)&&(d=d&&d[e[f]]);return c?j(d):d},m=function(){return!!(navigator.userAgent.indexOf("MSIE ")>0||navigator.userAgent.match(/Trident.*rv\:11\./))},n=function(){Object.keys||(Object.keys=function(){var a=Object.prototype.hasOwnProperty,b=!{toString:null}.propertyIsEnumerable("toString"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=c.length;return function(e){if("object"!=typeof e&&("function"!=typeof e||null===e))throw new TypeError("Object.keys called on non-object");var f,g,h=[];for(f in e)a.call(e,f)&&h.push(f);if(b)for(g=0;d>g;g++)a.call(e,c[g])&&h.push(c[g]);return h}}())},o=function(b,c){this.options=c,this.$el=a(b),this.$el_=this.$el.clone(),this.timeoutId_=0,this.timeoutFooter_=0,this.init()};o.DEFAULTS={classes:"table table-hover",sortClass:void 0,locale:void 0,height:void 0,undefinedText:"-",sortName:void 0,sortOrder:"asc",sortStable:!1,striped:!1,columns:[[]],data:[],totalField:"total",dataField:"rows",method:"get",url:void 0,ajax:void 0,cache:!0,contentType:"application/json",dataType:"json",ajaxOptions:{},queryParams:function(a){return a},queryParamsType:"limit",responseHandler:function(a){return a},pagination:!1,onlyInfoPagination:!1,paginationLoop:!0,sidePagination:"client",totalRows:0,pageNumber:1,pageSize:10,pageList:[10,25,50,100],paginationHAlign:"right",paginationVAlign:"bottom",paginationDetailHAlign:"left",paginationPreText:"‹",paginationNextText:"›",search:!1,searchOnEnterKey:!1,strictSearch:!1,searchAlign:"right",selectItemName:"btSelectItem",showHeader:!0,showFooter:!1,showColumns:!1,showPaginationSwitch:!1,showRefresh:!1,showToggle:!1,buttonsAlign:"right",smartDisplay:!0,escape:!1,minimumCountColumns:1,idField:void 0,uniqueId:void 0,cardView:!1,detailView:!1,detailFormatter:function(){return""},trimOnSearch:!0,clickToSelect:!1,singleSelect:!1,toolbar:void 0,toolbarAlign:"left",checkboxHeader:!0,sortable:!0,silentSort:!0,maintainSelected:!1,searchTimeOut:500,searchText:"",iconSize:void 0,buttonsClass:"default",iconsPrefix:"glyphicon",icons:{paginationSwitchDown:"glyphicon-collapse-down icon-chevron-down",paginationSwitchUp:"glyphicon-collapse-up icon-chevron-up",refresh:"glyphicon-refresh icon-refresh",toggle:"glyphicon-list-alt icon-list-alt",columns:"glyphicon-th icon-th",detailOpen:"glyphicon-plus icon-plus",detailClose:"glyphicon-minus icon-minus"},customSearch:a.noop,customSort:a.noop,rowStyle:function(){return{}},rowAttributes:function(){return{}},footerStyle:function(){return{}},onAll:function(){return!1},onClickCell:function(){return!1},onDblClickCell:function(){return!1},onClickRow:function(){return!1},onDblClickRow:function(){return!1},onSort:function(){return!1},onCheck:function(){return!1},onUncheck:function(){return!1},onCheckAll:function(){return!1},onUncheckAll:function(){return!1},onCheckSome:function(){return!1},onUncheckSome:function(){return!1},onLoadSuccess:function(){return!1},onLoadError:function(){return!1},onColumnSwitch:function(){return!1},onPageChange:function(){return!1},onSearch:function(){return!1},onToggle:function(){return!1},onPreBody:function(){return!1},onPostBody:function(){return!1},onPostHeader:function(){return!1},onExpandRow:function(){return!1},onCollapseRow:function(){return!1},onRefreshOptions:function(){return!1},onRefresh:function(){return!1},onResetView:function(){return!1}},o.LOCALES={},o.LOCALES["en-US"]=o.LOCALES.en={formatLoadingMessage:function(){return"Loading, please wait..."},formatRecordsPerPage:function(a){return c("%s rows per page",a)},formatShowingRows:function(a,b,d){return c("Showing %s to %s of %s rows",a,b,d)},formatDetailPagination:function(a){return c("Showing %s rows",a)},formatSearch:function(){return"Search"},formatNoMatches:function(){return"No matching records found"},formatPaginationSwitch:function(){return"Hide/Show pagination"},formatRefresh:function(){return"Refresh"},formatToggle:function(){return"Toggle"},formatColumns:function(){return"Columns"},formatAllRows:function(){return"All"}},a.extend(o.DEFAULTS,o.LOCALES["en-US"]),o.COLUMN_DEFAULTS={radio:!1,checkbox:!1,checkboxEnabled:!0,field:void 0,title:void 0,titleTooltip:void 0,"class":void 0,align:void 0,halign:void 0,falign:void 0,valign:void 0,width:void 0,sortable:!1,order:"asc",visible:!0,switchable:!0,clickToSelect:!0,formatter:void 0,footerFormatter:void 0,events:void 0,sorter:void 0,sortName:void 0,cellStyle:void 0,searchable:!0,searchFormatter:!0,cardVisible:!0,escape:!1},o.EVENTS={"all.bs.table":"onAll","click-cell.bs.table":"onClickCell","dbl-click-cell.bs.table":"onDblClickCell","click-row.bs.table":"onClickRow","dbl-click-row.bs.table":"onDblClickRow","sort.bs.table":"onSort","check.bs.table":"onCheck","uncheck.bs.table":"onUncheck","check-all.bs.table":"onCheckAll","uncheck-all.bs.table":"onUncheckAll","check-some.bs.table":"onCheckSome","uncheck-some.bs.table":"onUncheckSome","load-success.bs.table":"onLoadSuccess","load-error.bs.table":"onLoadError","column-switch.bs.table":"onColumnSwitch","page-change.bs.table":"onPageChange","search.bs.table":"onSearch","toggle.bs.table":"onToggle","pre-body.bs.table":"onPreBody","post-body.bs.table":"onPostBody","post-header.bs.table":"onPostHeader","expand-row.bs.table":"onExpandRow","collapse-row.bs.table":"onCollapseRow","refresh-options.bs.table":"onRefreshOptions","reset-view.bs.table":"onResetView","refresh.bs.table":"onRefresh"},o.prototype.init=function(){this.initLocale(),this.initContainer(),this.initTable(),this.initHeader(),this.initData(),this.initHiddenRows(),this.initFooter(),this.initToolbar(),this.initPagination(),this.initBody(),this.initSearchText(),this.initServer()},o.prototype.initLocale=function(){if(this.options.locale){var b=this.options.locale.split(/-|_/);b[0].toLowerCase(),b[1]&&b[1].toUpperCase(),a.fn.bootstrapTable.locales[this.options.locale]?a.extend(this.options,a.fn.bootstrapTable.locales[this.options.locale]):a.fn.bootstrapTable.locales[b.join("-")]?a.extend(this.options,a.fn.bootstrapTable.locales[b.join("-")]):a.fn.bootstrapTable.locales[b[0]]&&a.extend(this.options,a.fn.bootstrapTable.locales[b[0]])}},o.prototype.initContainer=function(){this.$container=a(['
','
',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'
':"",'
','
','
','
',this.options.formatLoadingMessage(),"
","
",'',"bottom"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'
':"","
","
"].join("")),this.$container.insertAfter(this.$el),this.$tableContainer=this.$container.find(".fixed-table-container"),this.$tableHeader=this.$container.find(".fixed-table-header"),this.$tableBody=this.$container.find(".fixed-table-body"),this.$tableLoading=this.$container.find(".fixed-table-loading"),this.$tableFooter=this.$container.find(".fixed-table-footer"),this.$toolbar=this.$container.find(".fixed-table-toolbar"),this.$pagination=this.$container.find(".fixed-table-pagination"),this.$tableBody.append(this.$el),this.$container.after('
'),this.$el.addClass(this.options.classes),this.options.striped&&this.$el.addClass("table-striped"),-1!==a.inArray("table-no-bordered",this.options.classes.split(" "))&&this.$tableContainer.addClass("table-no-bordered")},o.prototype.initTable=function(){var b=this,c=[],d=[];if(this.$header=this.$el.find(">thead"),this.$header.length||(this.$header=a("").appendTo(this.$el)),this.$header.find("tr").each(function(){var b=[];a(this).find("th").each(function(){"undefined"!=typeof a(this).data("field")&&a(this).data("field",a(this).data("field")+""),b.push(a.extend({},{title:a(this).html(),"class":a(this).attr("class"),titleTooltip:a(this).attr("title"),rowspan:a(this).attr("rowspan")?+a(this).attr("rowspan"):void 0,colspan:a(this).attr("colspan")?+a(this).attr("colspan"):void 0},a(this).data()))}),c.push(b)}),a.isArray(this.options.columns[0])||(this.options.columns=[this.options.columns]),this.options.columns=a.extend(!0,[],c,this.options.columns),this.columns=[],f(this.options.columns),a.each(this.options.columns,function(c,d){a.each(d,function(d,e){e=a.extend({},o.COLUMN_DEFAULTS,e),"undefined"!=typeof e.fieldIndex&&(b.columns[e.fieldIndex]=e),b.options.columns[c][d]=e})}),!this.options.data.length){var e=[];this.$el.find(">tbody>tr").each(function(c){var f={};f._id=a(this).attr("id"),f._class=a(this).attr("class"),f._data=k(a(this).data()),a(this).find(">td").each(function(d){for(var g,h,i=a(this),j=+i.attr("colspan")||1,l=+i.attr("rowspan")||1;e[c]&&e[c][d];d++);for(g=d;d+j>g;g++)for(h=c;c+l>h;h++)e[h]||(e[h]=[]),e[h][g]=!0;var m=b.columns[d].field;f[m]=a(this).html(),f["_"+m+"_id"]=a(this).attr("id"),f["_"+m+"_class"]=a(this).attr("class"),f["_"+m+"_rowspan"]=a(this).attr("rowspan"),f["_"+m+"_colspan"]=a(this).attr("colspan"),f["_"+m+"_title"]=a(this).attr("title"),f["_"+m+"_data"]=k(a(this).data())}),d.push(f)}),this.options.data=d,d.length&&(this.fromHtml=!0)}},o.prototype.initHeader=function(){var b=this,d={},e=[];this.header={fields:[],styles:[],classes:[],formatters:[],events:[],sorters:[],sortNames:[],cellStyles:[],searchables:[]},a.each(this.options.columns,function(f,g){e.push(""),0===f&&!b.options.cardView&&b.options.detailView&&e.push(c('
',b.options.columns.length)),a.each(g,function(a,f){var g="",h="",i="",k="",l=c(' class="%s"',f["class"]),m=(b.options.sortOrder||f.order,"px"),n=f.width;if(void 0===f.width||b.options.cardView||"string"==typeof f.width&&-1!==f.width.indexOf("%")&&(m="%"),f.width&&"string"==typeof f.width&&(n=f.width.replace("%","").replace("px","")),h=c("text-align: %s; ",f.halign?f.halign:f.align),i=c("text-align: %s; ",f.align),k=c("vertical-align: %s; ",f.valign),k+=c("width: %s; ",!f.checkbox&&!f.radio||n?n?n+m:void 0:"36px"),"undefined"!=typeof f.fieldIndex){if(b.header.fields[f.fieldIndex]=f.field,b.header.styles[f.fieldIndex]=i+k,b.header.classes[f.fieldIndex]=l,b.header.formatters[f.fieldIndex]=f.formatter,b.header.events[f.fieldIndex]=f.events,b.header.sorters[f.fieldIndex]=f.sorter,b.header.sortNames[f.fieldIndex]=f.sortName,b.header.cellStyles[f.fieldIndex]=f.cellStyle,b.header.searchables[f.fieldIndex]=f.searchable,!f.visible)return;if(b.options.cardView&&!f.cardVisible)return;d[f.field]=f}e.push(""),e.push(c('
',b.options.sortable&&f.sortable?"sortable both":"")),g=b.options.escape?j(f.title):f.title,f.checkbox&&(!b.options.singleSelect&&b.options.checkboxHeader&&(g=''),b.header.stateField=f.field),f.radio&&(g="",b.header.stateField=f.field,b.options.singleSelect=!0),e.push(g),e.push("
"),e.push('
'),e.push("
"),e.push("")}),e.push("")}),this.$header.html(e.join("")),this.$header.find("th[data-field]").each(function(){a(this).data(d[a(this).data("field")])}),this.$container.off("click",".th-inner").on("click",".th-inner",function(c){var d=a(this);return b.options.detailView&&d.closest(".bootstrap-table")[0]!==b.$container[0]?!1:void(b.options.sortable&&d.parent().data().sortable&&b.onSort(c))}),this.$header.children().children().off("keypress").on("keypress",function(c){if(b.options.sortable&&a(this).data().sortable){var d=c.keyCode||c.which;13==d&&b.onSort(c)}}),a(window).off("resize.bootstrap-table"),!this.options.showHeader||this.options.cardView?(this.$header.hide(),this.$tableHeader.hide(),this.$tableLoading.css("top",0)):(this.$header.show(),this.$tableHeader.show(),this.$tableLoading.css("top",this.$header.outerHeight()+1),this.getCaret(),a(window).on("resize.bootstrap-table",a.proxy(this.resetWidth,this))),this.$selectAll=this.$header.find('[name="btSelectAll"]'),this.$selectAll.off("click").on("click",function(){var c=a(this).prop("checked");b[c?"checkAll":"uncheckAll"](),b.updateSelected()})},o.prototype.initFooter=function(){!this.options.showFooter||this.options.cardView?this.$tableFooter.hide():this.$tableFooter.show()},o.prototype.initData=function(a,b){this.data="append"===b?this.data.concat(a):"prepend"===b?[].concat(a).concat(this.data):a||this.options.data,this.options.data="append"===b?this.options.data.concat(a):"prepend"===b?[].concat(a).concat(this.options.data):this.data,"server"!==this.options.sidePagination&&this.initSort()},o.prototype.initSort=function(){var b=this,d=this.options.sortName,e="desc"===this.options.sortOrder?-1:1,f=a.inArray(this.options.sortName,this.header.fields),g=0;return this.options.customSort!==a.noop?void this.options.customSort.apply(this,[this.options.sortName,this.options.sortOrder]):void(-1!==f&&(this.options.sortStable&&a.each(this.data,function(a,b){b.hasOwnProperty("_position")||(b._position=a)}),this.data.sort(function(c,g){b.header.sortNames[f]&&(d=b.header.sortNames[f]);var i=l(c,d,b.options.escape),j=l(g,d,b.options.escape),k=h(b.header,b.header.sorters[f],[i,j]);return void 0!==k?e*k:((void 0===i||null===i)&&(i=""),(void 0===j||null===j)&&(j=""),b.options.sortStable&&i===j&&(i=c._position,j=g._position),a.isNumeric(i)&&a.isNumeric(j)?(i=parseFloat(i),j=parseFloat(j),j>i?-1*e:e):i===j?0:("string"!=typeof i&&(i=i.toString()),-1===i.localeCompare(j)?-1*e:e))}),void 0!==this.options.sortClass&&(clearTimeout(g),g=setTimeout(function(){b.$el.removeClass(b.options.sortClass);var a=b.$header.find(c('[data-field="%s"]',b.options.sortName).index()+1);b.$el.find(c("tr td:nth-child(%s)",a)).addClass(b.options.sortClass)},250))))},o.prototype.onSort=function(b){var c="keypress"===b.type?a(b.currentTarget):a(b.currentTarget).parent(),d=this.$header.find("th").eq(c.index());return this.$header.add(this.$header_).find("span.order").remove(),this.options.sortName===c.data("field")?this.options.sortOrder="asc"===this.options.sortOrder?"desc":"asc":(this.options.sortName=c.data("field"),this.options.sortOrder="asc"===c.data("order")?"desc":"asc"),this.trigger("sort",this.options.sortName,this.options.sortOrder),c.add(d).data("order",this.options.sortOrder),this.getCaret(),"server"===this.options.sidePagination?void this.initServer(this.options.silentSort):(this.initSort(),void this.initBody())},o.prototype.initToolbar=function(){var b,d,e=this,f=[],g=0,i=0;this.$toolbar.find(".bs-bars").children().length&&a("body").append(a(this.options.toolbar)),this.$toolbar.html(""),("string"==typeof this.options.toolbar||"object"==typeof this.options.toolbar)&&a(c('
',this.options.toolbarAlign)).appendTo(this.$toolbar).append(a(this.options.toolbar)),f=[c('
',this.options.buttonsAlign,this.options.buttonsAlign)],"string"==typeof this.options.icons&&(this.options.icons=h(null,this.options.icons)),this.options.showPaginationSwitch&&f.push(c('"),this.options.showRefresh&&f.push(c('"),this.options.showToggle&&f.push(c('"),this.options.showColumns&&(f.push(c('
',this.options.formatColumns()),'",'","
")),f.push("
"),(this.showToolbar||f.length>2)&&this.$toolbar.append(f.join("")),this.options.showPaginationSwitch&&this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",a.proxy(this.togglePagination,this)),this.options.showRefresh&&this.$toolbar.find('button[name="refresh"]').off("click").on("click",a.proxy(this.refresh,this)),this.options.showToggle&&this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){e.toggleView()}),this.options.showColumns&&(b=this.$toolbar.find(".keep-open"),i<=this.options.minimumCountColumns&&b.find("input").prop("disabled",!0),b.find("li").off("click").on("click",function(a){a.stopImmediatePropagation()}),b.find("input").off("click").on("click",function(){var b=a(this);e.toggleColumn(a(this).val(),b.prop("checked"),!1),e.trigger("column-switch",a(this).data("field"),b.prop("checked"))})),this.options.search&&(f=[],f.push('"),this.$toolbar.append(f.join("")),d=this.$toolbar.find(".search input"),d.off("keyup drop blur").on("keyup drop blur",function(b){e.options.searchOnEnterKey&&13!==b.keyCode||a.inArray(b.keyCode,[37,38,39,40])>-1||(clearTimeout(g),g=setTimeout(function(){e.onSearch(b)},e.options.searchTimeOut))}),m()&&d.off("mouseup").on("mouseup",function(a){clearTimeout(g),g=setTimeout(function(){e.onSearch(a)},e.options.searchTimeOut)}))},o.prototype.onSearch=function(b){var c=a.trim(a(b.currentTarget).val());this.options.trimOnSearch&&a(b.currentTarget).val()!==c&&a(b.currentTarget).val(c),c!==this.searchText&&(this.searchText=c,this.options.searchText=c,this.options.pageNumber=1,this.initSearch(),this.updatePagination(),this.trigger("search",c))},o.prototype.initSearch=function(){var b=this;if("server"!==this.options.sidePagination){if(this.options.customSearch!==a.noop)return void this.options.customSearch.apply(this,[this.searchText]);var c=this.searchText&&(this.options.escape?j(this.searchText):this.searchText).toLowerCase(),d=a.isEmptyObject(this.filterColumns)?null:this.filterColumns;this.data=d?a.grep(this.options.data,function(b){for(var c in d)if(a.isArray(d[c])&&-1===a.inArray(b[c],d[c])||!a.isArray(d[c])&&b[c]!==d[c])return!1;return!0}):this.options.data,this.data=c?a.grep(this.data,function(d,f){for(var g=0;g-1&&(n=!0)}this.totalPages=~~((this.options.totalRows-1)/this.options.pageSize)+1,this.options.totalPages=this.totalPages}if(this.totalPages>0&&this.options.pageNumber>this.totalPages&&(this.options.pageNumber=this.totalPages),this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1,this.pageTo=this.options.pageNumber*this.options.pageSize,this.pageTo>this.options.totalRows&&(this.pageTo=this.options.totalRows),m.push('
','',this.options.onlyInfoPagination?this.options.formatDetailPagination(this.options.totalRows):this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),""),!this.options.onlyInfoPagination){m.push('');var r=[c('',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?"dropdown":"dropup"),'",'"),m.push(this.options.formatRecordsPerPage(r.join(""))),m.push(""),m.push("
",'")}this.$pagination.html(m.join("")),this.options.onlyInfoPagination||(f=this.$pagination.find(".page-list a"),g=this.$pagination.find(".page-first"),h=this.$pagination.find(".page-pre"),i=this.$pagination.find(".page-next"),j=this.$pagination.find(".page-last"),k=this.$pagination.find(".page-number"),this.options.smartDisplay&&(this.totalPages<=1&&this.$pagination.find("div.pagination").hide(),(p.length<2||this.options.totalRows<=p[0])&&this.$pagination.find("span.page-list").hide(),this.$pagination[this.getData().length?"show":"hide"]()),this.options.paginationLoop||(1===this.options.pageNumber&&h.addClass("disabled"),this.options.pageNumber===this.totalPages&&i.addClass("disabled")),n&&(this.options.pageSize=this.options.formatAllRows()),f.off("click").on("click",a.proxy(this.onPageListChange,this)),g.off("click").on("click",a.proxy(this.onPageFirst,this)),h.off("click").on("click",a.proxy(this.onPagePre,this)),i.off("click").on("click",a.proxy(this.onPageNext,this)),j.off("click").on("click",a.proxy(this.onPageLast,this)),k.off("click").on("click",a.proxy(this.onPageNumber,this)))},o.prototype.updatePagination=function(b){b&&a(b.currentTarget).hasClass("disabled")||(this.options.maintainSelected||this.resetRows(),this.initPagination(),"server"===this.options.sidePagination?this.initServer():this.initBody(),this.trigger("page-change",this.options.pageNumber,this.options.pageSize))},o.prototype.onPageListChange=function(b){var c=a(b.currentTarget);return c.parent().addClass("active").siblings().removeClass("active"),this.options.pageSize=c.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+c.text(),this.$toolbar.find(".page-size").text(this.options.pageSize),this.updatePagination(b),!1},o.prototype.onPageFirst=function(a){return this.options.pageNumber=1,this.updatePagination(a),!1},o.prototype.onPagePre=function(a){return this.options.pageNumber-1===0?this.options.pageNumber=this.options.totalPages:this.options.pageNumber--,this.updatePagination(a),!1},o.prototype.onPageNext=function(a){return this.options.pageNumber+1>this.options.totalPages?this.options.pageNumber=1:this.options.pageNumber++,this.updatePagination(a),!1},o.prototype.onPageLast=function(a){return this.options.pageNumber=this.totalPages,this.updatePagination(a),!1},o.prototype.onPageNumber=function(b){return this.options.pageNumber!==+a(b.currentTarget).text()?(this.options.pageNumber=+a(b.currentTarget).text(),this.updatePagination(b),!1):void 0},o.prototype.initRow=function(b,e){var f,g=this,i=[],k={},m=[],n="",o={},p=[];if(!(a.inArray(b,this.hiddenRows)>-1)){if(k=h(this.options,this.options.rowStyle,[b,e],k),k&&k.css)for(f in k.css)m.push(f+": "+k.css[f]);if(o=h(this.options,this.options.rowAttributes,[b,e],o))for(f in o)p.push(c('%s="%s"',f,j(o[f])));return b._data&&!a.isEmptyObject(b._data)&&a.each(b._data,function(a,b){"index"!==a&&(n+=c(' data-%s="%s"',a,b))}),i.push(""),this.options.cardView&&i.push(c('
',this.header.fields.length)),!this.options.cardView&&this.options.detailView&&i.push("",'',c('',this.options.iconsPrefix,this.options.icons.detailOpen),"",""),a.each(this.header.fields,function(f,n){var o="",p=l(b,n,g.options.escape),q="",r="",s={},t="",u=g.header.classes[f],v="",w="",x="",y="",z=g.columns[f];if(!(g.fromHtml&&"undefined"==typeof p||!z.visible||g.options.cardView&&!z.cardVisible)){if(z.escape&&(p=j(p)),k=c('style="%s"',m.concat(g.header.styles[f]).join("; ")),b["_"+n+"_id"]&&(t=c(' id="%s"',b["_"+n+"_id"])),b["_"+n+"_class"]&&(u=c(' class="%s"',b["_"+n+"_class"])),b["_"+n+"_rowspan"]&&(w=c(' rowspan="%s"',b["_"+n+"_rowspan"])),b["_"+n+"_colspan"]&&(x=c(' colspan="%s"',b["_"+n+"_colspan"])),b["_"+n+"_title"]&&(y=c(' title="%s"',b["_"+n+"_title"])),s=h(g.header,g.header.cellStyles[f],[p,b,e,n],s),s.classes&&(u=c(' class="%s"',s.classes)),s.css){var A=[];for(var B in s.css)A.push(B+": "+s.css[B]);k=c('style="%s"',A.concat(g.header.styles[f]).join("; "))}q=h(z,g.header.formatters[f],[p,b,e],p),b["_"+n+"_data"]&&!a.isEmptyObject(b["_"+n+"_data"])&&a.each(b["_"+n+"_data"],function(a,b){"index"!==a&&(v+=c(' data-%s="%s"',a,b))}),z.checkbox||z.radio?(r=z.checkbox?"checkbox":r,r=z.radio?"radio":r,o=[c(g.options.cardView?'
':'',z["class"]||""),"",g.header.formatters[f]&&"string"==typeof q?q:"",g.options.cardView?"
":""].join(""),b[g.header.stateField]=q===!0||q&&q.checked):(q="undefined"==typeof q||null===q?g.options.undefinedText:q,o=g.options.cardView?['
',g.options.showHeader?c('%s',k,d(g.columns,"field","title",n)):"",c('%s',q),"
"].join(""):[c("",t,u,k,v,w,x,y),q,""].join(""),g.options.cardView&&g.options.smartDisplay&&""===q&&(o='
')),i.push(o)}}),this.options.cardView&&i.push("
"),i.push(""),i.join(" ")}},o.prototype.initBody=function(b){var d=this,f=this.getData();this.trigger("pre-body",f),this.$body=this.$el.find(">tbody"),this.$body.length||(this.$body=a("").appendTo(this.$el)),this.options.pagination&&"server"!==this.options.sidePagination||(this.pageFrom=1,this.pageTo=f.length);for(var g,i=a(document.createDocumentFragment()),j=this.pageFrom-1;j'+c('%s',this.$header.find("th").length,this.options.formatNoMatches())+""),this.$body.html(i),b||this.scrollTo(0),this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick",function(b){var f=a(this),g=f.parent(),h=d.data[g.data("index")],i=f[0].cellIndex,j=d.getVisibleFields(),k=j[d.options.detailView&&!d.options.cardView?i-1:i],m=d.columns[e(d.columns,k)],n=l(h,k,d.options.escape);if(!f.find(".detail-icon").length&&(d.trigger("click"===b.type?"click-cell":"dbl-click-cell",k,n,h,f),d.trigger("click"===b.type?"click-row":"dbl-click-row",h,g,k),"click"===b.type&&d.options.clickToSelect&&m.clickToSelect)){var o=g.find(c('[name="%s"]',d.options.selectItemName));o.length&&o[0].click()}}),this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click",function(){var b=a(this),e=b.parent().parent(),g=e.data("index"),i=f[g];if(e.next().is("tr.detail-view"))b.find("i").attr("class",c("%s %s",d.options.iconsPrefix,d.options.icons.detailOpen)),d.trigger("collapse-row",g,i),e.next().remove();else{b.find("i").attr("class",c("%s %s",d.options.iconsPrefix,d.options.icons.detailClose)),e.after(c('',e.find("td").length));var j=e.next().find("td"),k=h(d.options,d.options.detailFormatter,[g,i,j],"");1===j.length&&j.append(k),d.trigger("expand-row",g,i,j)}return d.resetView(),!1}),this.$selectItem=this.$body.find(c('[name="%s"]',this.options.selectItemName)),this.$selectItem.off("click").on("click",function(b){b.stopImmediatePropagation();var c=a(this),e=c.prop("checked"),f=d.data[c.data("index")];d.options.maintainSelected&&a(this).is(":radio")&&a.each(d.options.data,function(a,b){b[d.header.stateField]=!1}),f[d.header.stateField]=e,d.options.singleSelect&&(d.$selectItem.not(this).each(function(){d.data[a(this).data("index")][d.header.stateField]=!1}),d.$selectItem.filter(":checked").not(this).prop("checked",!1)),d.updateSelected(),d.trigger(e?"check":"uncheck",f,c)}),a.each(this.header.events,function(b,c){if(c){"string"==typeof c&&(c=h(null,c));var e=d.header.fields[b],f=a.inArray(e,d.getVisibleFields());d.options.detailView&&!d.options.cardView&&(f+=1);for(var g in c)d.$body.find(">tr:not(.no-records-found)").each(function(){var b=a(this),h=b.find(d.options.cardView?".card-view":"td").eq(f),i=g.indexOf(" "),j=g.substring(0,i),k=g.substring(i+1),l=c[g];h.find(k).off(j).on(j,function(a){var c=b.data("index"),f=d.data[c],g=f[e];l.apply(this,[a,g,f,c])})})}}),this.updateSelected(),this.resetView(),this.trigger("post-body",f)},o.prototype.initServer=function(b,c,d){var e,f=this,g={},i={searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder};this.options.pagination&&(i.pageSize=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,i.pageNumber=this.options.pageNumber),(d||this.options.url||this.options.ajax)&&("limit"===this.options.queryParamsType&&(i={search:i.searchText,sort:i.sortName,order:i.sortOrder},this.options.pagination&&(i.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1),i.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize)),a.isEmptyObject(this.filterColumnsPartial)||(i.filter=JSON.stringify(this.filterColumnsPartial,null)),g=h(this.options,this.options.queryParams,[i],g),a.extend(g,c||{}),g!==!1&&(b||this.$tableLoading.show(),e=a.extend({},h(null,this.options.ajaxOptions),{type:this.options.method,url:d||this.options.url,data:"application/json"===this.options.contentType&&"post"===this.options.method?JSON.stringify(g):g,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(a){a=h(f.options,f.options.responseHandler,[a],a),f.load(a),f.trigger("load-success",a),b||f.$tableLoading.hide()},error:function(a){f.trigger("load-error",a.status,a),b||f.$tableLoading.hide()}}),this.options.ajax?h(this,this.options.ajax,[e],null):(this._xhr&&4!==this._xhr.readyState&&this._xhr.abort(),this._xhr=a.ajax(e))))},o.prototype.initSearchText=function(){if(this.options.search&&""!==this.options.searchText){var a=this.$toolbar.find(".search input");a.val(this.options.searchText),this.onSearch({currentTarget:a})}},o.prototype.getCaret=function(){var b=this;a.each(this.$header.find("th"),function(c,d){a(d).find(".sortable").removeClass("desc asc").addClass(a(d).data("field")===b.options.sortName?b.options.sortOrder:"both")})},o.prototype.updateSelected=function(){var b=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;this.$selectAll.add(this.$selectAll_).prop("checked",b),this.$selectItem.each(function(){a(this).closest("tr")[a(this).prop("checked")?"addClass":"removeClass"]("selected")})},o.prototype.updateRows=function(){var b=this;this.$selectItem.each(function(){b.data[a(this).data("index")][b.header.stateField]=a(this).prop("checked")})},o.prototype.resetRows=function(){var b=this;a.each(this.data,function(a,c){b.$selectAll.prop("checked",!1),b.$selectItem.prop("checked",!1),b.header.stateField&&(c[b.header.stateField]=!1)}),this.initHiddenRows()},o.prototype.trigger=function(b){var c=Array.prototype.slice.call(arguments,1);b+=".bs.table",this.options[o.EVENTS[b]].apply(this.options,c),this.$el.trigger(a.Event(b),c),this.options.onAll(b,c),this.$el.trigger(a.Event("all.bs.table"),[b,c])},o.prototype.resetHeader=function(){clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(a.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)},o.prototype.fitHeader=function(){var b,d,e,f,h=this;if(h.$el.is(":hidden"))return void(h.timeoutId_=setTimeout(a.proxy(h.fitHeader,h),100));if(b=this.$tableBody.get(0),d=b.scrollWidth>b.clientWidth&&b.scrollHeight>b.clientHeight+this.$header.outerHeight()?g():0,this.$el.css("margin-top",-this.$header.outerHeight()),e=a(":focus"),e.length>0){var i=e.parents("th");if(i.length>0){var j=i.attr("data-field");if(void 0!==j){var k=this.$header.find("[data-field='"+j+"']");k.length>0&&k.find(":input").addClass("focus-temp")}}}this.$header_=this.$header.clone(!0,!0),this.$selectAll_=this.$header_.find('[name="btSelectAll"]'),this.$tableHeader.css({"margin-right":d}).find("table").css("width",this.$el.outerWidth()).html("").attr("class",this.$el.attr("class")).append(this.$header_),f=a(".focus-temp:visible:eq(0)"),f.length>0&&(f.focus(),this.$header.find(".focus-temp").removeClass("focus-temp")),this.$header.find("th[data-field]").each(function(){h.$header_.find(c('th[data-field="%s"]',a(this).data("field"))).data(a(this).data())});var l=this.getVisibleFields(),m=this.$header_.find("th");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(b){var d=a(this),e=b;h.options.detailView&&!h.options.cardView&&(0===b&&h.$header_.find("th.detail").find(".fht-cell").width(d.innerWidth()),e=b-1);var f=h.$header_.find(c('th[data-field="%s"]',l[e]));f.length>1&&(f=a(m[d[0].cellIndex])),f.find(".fht-cell").width(d.innerWidth())}),this.$tableBody.off("scroll").on("scroll",function(){h.$tableHeader.scrollLeft(a(this).scrollLeft()),h.options.showFooter&&!h.options.cardView&&h.$tableFooter.scrollLeft(a(this).scrollLeft())}),h.trigger("post-header")},o.prototype.resetFooter=function(){var b=this,d=b.getData(),e=[];this.options.showFooter&&!this.options.cardView&&(!this.options.cardView&&this.options.detailView&&e.push('
 
'),a.each(this.columns,function(a,f){var g,i="",j="",k=[],l={},m=c(' class="%s"',f["class"]);if(f.visible&&(!b.options.cardView||f.cardVisible)){if(i=c("text-align: %s; ",f.falign?f.falign:f.align),j=c("vertical-align: %s; ",f.valign),l=h(null,b.options.footerStyle),l&&l.css)for(g in l.css)k.push(g+": "+l.css[g]);e.push(""),e.push('
'),e.push(h(f,f.footerFormatter,[d]," ")||" "),e.push("
"),e.push('
'),e.push("
"),e.push("")}}),this.$tableFooter.find("tr").html(e.join("")),this.$tableFooter.show(),clearTimeout(this.timeoutFooter_),this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0))},o.prototype.fitFooter=function(){var b,c,d;return clearTimeout(this.timeoutFooter_),this.$el.is(":hidden")?void(this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),100)):(c=this.$el.css("width"),d=c>this.$tableBody.width()?g():0,this.$tableFooter.css({"margin-right":d}).find("table").css("width",c).attr("class",this.$el.attr("class")),b=this.$tableFooter.find("td"),void this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(c){var d=a(this);b.eq(c).find(".fht-cell").width(d.innerWidth())}))},o.prototype.toggleColumn=function(a,b,d){if(-1!==a&&(this.columns[a].visible=b,this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns)){var e=this.$toolbar.find(".keep-open input").prop("disabled",!1);d&&e.filter(c('[value="%s"]',a)).prop("checked",b),e.filter(":checked").length<=this.options.minimumCountColumns&&e.filter(":checked").prop("disabled",!0)}},o.prototype.getVisibleFields=function(){var b=this,c=[];return a.each(this.header.fields,function(a,d){var f=b.columns[e(b.columns,d)];f.visible&&c.push(d)}),c},o.prototype.resetView=function(a){var b=0;if(a&&a.height&&(this.options.height=a.height),this.$selectAll.prop("checked",this.$selectItem.length>0&&this.$selectItem.length===this.$selectItem.filter(":checked").length),this.options.height){var c=this.$toolbar.outerHeight(!0),d=this.$pagination.outerHeight(!0),e=this.options.height-c-d;this.$tableContainer.css("height",e+"px")}return this.options.cardView?(this.$el.css("margin-top","0"),this.$tableContainer.css("padding-bottom","0"),void this.$tableFooter.hide()):(this.options.showHeader&&this.options.height?(this.$tableHeader.show(),this.resetHeader(),b+=this.$header.outerHeight()):(this.$tableHeader.hide(),this.trigger("post-header")),this.options.showFooter&&(this.resetFooter(),this.options.height&&(b+=this.$tableFooter.outerHeight()+1)),this.getCaret(),this.$tableContainer.css("padding-bottom",b+"px"),void this.trigger("reset-view"))},o.prototype.getData=function(b){return!this.searchText&&a.isEmptyObject(this.filterColumns)&&a.isEmptyObject(this.filterColumnsPartial)?b?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data:b?this.data.slice(this.pageFrom-1,this.pageTo):this.data},o.prototype.load=function(b){var c=!1;"server"===this.options.sidePagination?(this.options.totalRows=b[this.options.totalField],c=b.fixedScroll,b=b[this.options.dataField]):a.isArray(b)||(c=b.fixedScroll,b=b.data),this.initData(b),this.initSearch(),this.initPagination(),this.initBody(c)},o.prototype.append=function(a){this.initData(a,"append"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},o.prototype.prepend=function(a){this.initData(a,"prepend"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},o.prototype.remove=function(b){var c,d,e=this.options.data.length;if(b.hasOwnProperty("field")&&b.hasOwnProperty("values")){for(c=e-1;c>=0;c--)d=this.options.data[c],d.hasOwnProperty(b.field)&&-1!==a.inArray(d[b.field],b.values)&&(this.options.data.splice(c,1),"server"===this.options.sidePagination&&(this.options.totalRows-=1));e!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))}},o.prototype.removeAll=function(){this.options.data.length>0&&(this.options.data.splice(0,this.options.data.length),this.initSearch(),this.initPagination(),this.initBody(!0))},o.prototype.getRowByUniqueId=function(a){var b,c,d,e=this.options.uniqueId,f=this.options.data.length,g=null;for(b=f-1;b>=0;b--){if(c=this.options.data[b],c.hasOwnProperty(e))d=c[e];else{if(!c._data.hasOwnProperty(e))continue;d=c._data[e]}if("string"==typeof d?a=a.toString():"number"==typeof d&&(Number(d)===d&&d%1===0?a=parseInt(a):d===Number(d)&&0!==d&&(a=parseFloat(a))),d===a){g=c;break}}return g},o.prototype.removeByUniqueId=function(a){var b=this.options.data.length,c=this.getRowByUniqueId(a);c&&this.options.data.splice(this.options.data.indexOf(c),1),b!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initBody(!0))},o.prototype.updateByUniqueId=function(b){var c=this,d=a.isArray(b)?b:[b];a.each(d,function(b,d){var e;d.hasOwnProperty("id")&&d.hasOwnProperty("row")&&(e=a.inArray(c.getRowByUniqueId(d.id),c.options.data),-1!==e&&a.extend(c.options.data[e],d.row))}),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},o.prototype.insertRow=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("row")&&(this.data.splice(a.index,0,a.row),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))},o.prototype.updateRow=function(b){var c=this,d=a.isArray(b)?b:[b];a.each(d,function(b,d){d.hasOwnProperty("index")&&d.hasOwnProperty("row")&&a.extend(c.options.data[d.index],d.row)}),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},o.prototype.initHiddenRows=function(){this.hiddenRows=[]},o.prototype.showRow=function(a){this.toggleRow(a,!0)},o.prototype.hideRow=function(a){this.toggleRow(a,!1)},o.prototype.toggleRow=function(b,c){var d,e;b.hasOwnProperty("index")?d=this.getData()[b.index]:b.hasOwnProperty("uniqueId")&&(d=this.getRowByUniqueId(b.uniqueId)),d&&(e=a.inArray(d,this.hiddenRows),c||-1!==e?c&&e>-1&&this.hiddenRows.splice(e,1):this.hiddenRows.push(d),this.initBody(!0))},o.prototype.getHiddenRows=function(){var b=this,c=this.getData(),d=[];return a.each(c,function(c,e){a.inArray(e,b.hiddenRows)>-1&&d.push(e)}),this.hiddenRows=d,d},o.prototype.mergeCells=function(b){var c,d,e,f=b.index,g=a.inArray(b.field,this.getVisibleFields()),h=b.rowspan||1,i=b.colspan||1,j=this.$body.find(">tr");if(this.options.detailView&&!this.options.cardView&&(g+=1),e=j.eq(f).find(">td").eq(g),!(0>f||0>g||f>=this.data.length)){for(c=f;f+h>c;c++)for(d=g;g+i>d;d++)j.eq(c).find(">td").eq(d).hide();e.attr("rowspan",h).attr("colspan",i).show()}},o.prototype.updateCell=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("field")&&a.hasOwnProperty("value")&&(this.data[a.index][a.field]=a.value,a.reinit!==!1&&(this.initSort(),this.initBody(!0)))},o.prototype.getOptions=function(){return this.options},o.prototype.getSelections=function(){var b=this;return a.grep(this.options.data,function(a){return a[b.header.stateField]===!0})},o.prototype.getAllSelections=function(){var b=this;return a.grep(this.options.data,function(a){return a[b.header.stateField]})},o.prototype.checkAll=function(){this.checkAll_(!0)},o.prototype.uncheckAll=function(){this.checkAll_(!1)},o.prototype.checkInvert=function(){var b=this,c=b.$selectItem.filter(":enabled"),d=c.filter(":checked");c.each(function(){a(this).prop("checked",!a(this).prop("checked"))}),b.updateRows(),b.updateSelected(),b.trigger("uncheck-some",d),d=b.getSelections(),b.trigger("check-some",d)},o.prototype.checkAll_=function(a){var b;a||(b=this.getSelections()),this.$selectAll.add(this.$selectAll_).prop("checked",a),this.$selectItem.filter(":enabled").prop("checked",a),this.updateRows(),a&&(b=this.getSelections()),this.trigger(a?"check-all":"uncheck-all",b)},o.prototype.check=function(a){this.check_(!0,a)},o.prototype.uncheck=function(a){this.check_(!1,a)},o.prototype.check_=function(a,b){var d=this.$selectItem.filter(c('[data-index="%s"]',b)).prop("checked",a);this.data[b][this.header.stateField]=a,this.updateSelected(),this.trigger(a?"check":"uncheck",this.data[b],d)},o.prototype.checkBy=function(a){this.checkBy_(!0,a)},o.prototype.uncheckBy=function(a){this.checkBy_(!1,a)},o.prototype.checkBy_=function(b,d){if(d.hasOwnProperty("field")&&d.hasOwnProperty("values")){var e=this,f=[];a.each(this.options.data,function(g,h){if(!h.hasOwnProperty(d.field))return!1;if(-1!==a.inArray(h[d.field],d.values)){var i=e.$selectItem.filter(":enabled").filter(c('[data-index="%s"]',g)).prop("checked",b);h[e.header.stateField]=b,f.push(h),e.trigger(b?"check":"uncheck",h,i)}}),this.updateSelected(),this.trigger(b?"check-some":"uncheck-some",f)}},o.prototype.destroy=function(){this.$el.insertBefore(this.$container),a(this.options.toolbar).insertBefore(this.$el),this.$container.next().remove(),this.$container.remove(),this.$el.html(this.$el_.html()).css("margin-top","0").attr("class",this.$el_.attr("class")||"")},o.prototype.showLoading=function(){this.$tableLoading.show()},o.prototype.hideLoading=function(){this.$tableLoading.hide()},o.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var a=this.$toolbar.find('button[name="paginationSwitch"] i');this.options.pagination?a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown):a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp),this.updatePagination()},o.prototype.refresh=function(a){a&&a.url&&(this.options.url=a.url),a&&a.pageNumber&&(this.options.pageNumber=a.pageNumber),a&&a.pageSize&&(this.options.pageSize=a.pageSize),this.initServer(a&&a.silent,a&&a.query,a&&a.url),this.trigger("refresh",a)},o.prototype.resetWidth=function(){this.options.showHeader&&this.options.height&&this.fitHeader(),this.options.showFooter&&this.fitFooter()},o.prototype.showColumn=function(a){this.toggleColumn(e(this.columns,a),!0,!0)},o.prototype.hideColumn=function(a){this.toggleColumn(e(this.columns,a),!1,!0)},o.prototype.getHiddenColumns=function(){return a.grep(this.columns,function(a){return!a.visible})},o.prototype.getVisibleColumns=function(){return a.grep(this.columns,function(a){return a.visible})},o.prototype.toggleAllColumns=function(b){if(a.each(this.columns,function(a){this.columns[a].visible=b}),this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns){var c=this.$toolbar.find(".keep-open input").prop("disabled",!1);c.filter(":checked").length<=this.options.minimumCountColumns&&c.filter(":checked").prop("disabled",!0)}},o.prototype.showAllColumns=function(){this.toggleAllColumns(!0)},o.prototype.hideAllColumns=function(){this.toggleAllColumns(!1)},o.prototype.filterBy=function(b){this.filterColumns=a.isEmptyObject(b)?{}:b,this.options.pageNumber=1,this.initSearch(),this.updatePagination()},o.prototype.scrollTo=function(a){return"string"==typeof a&&(a="bottom"===a?this.$tableBody[0].scrollHeight:0),"number"==typeof a&&this.$tableBody.scrollTop(a),"undefined"==typeof a?this.$tableBody.scrollTop():void 0},o.prototype.getScrollPosition=function(){return this.scrollTo()},o.prototype.selectPage=function(a){a>0&&a<=this.options.totalPages&&(this.options.pageNumber=a,this.updatePagination())},o.prototype.prevPage=function(){this.options.pageNumber>1&&(this.options.pageNumber--,this.updatePagination())},o.prototype.nextPage=function(){this.options.pageNumber tr[data-index="%s"]',b));d.next().is("tr.detail-view")===(a?!1:!0)&&d.find("> td > .detail-icon").click()},o.prototype.expandRow=function(a){this.expandRow_(!0,a)},o.prototype.collapseRow=function(a){this.expandRow_(!1,a)},o.prototype.expandAllRows=function(b){if(b){var d=this.$body.find(c('> tr[data-index="%s"]',0)),e=this,f=null,g=!1,h=-1;if(d.next().is("tr.detail-view")?d.next().next().is("tr.detail-view")||(d.next().find(".detail-icon").click(),g=!0):(d.find("> td > .detail-icon").click(),g=!0),g)try{h=setInterval(function(){f=e.$body.find("tr.detail-view").last().find(".detail-icon"),f.length>0?f.click():clearInterval(h)},1)}catch(i){clearInterval(h)}}else for(var j=this.$body.children(),k=0;k