Bugzilla – Attachment 115328 Details for
Bug 27467
Provide a static URL for tables
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27467: [SOLUTION 2] Add deepLink.js
Bug-27467-SOLUTION-2-Add-deepLinkjs.patch (text/plain), 3.84 KB, created by
Jonathan Druart
on 2021-01-19 14:12:38 UTC
(
hide
)
Description:
Bug 27467: [SOLUTION 2] Add deepLink.js
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-01-19 14:12:38 UTC
Size:
3.84 KB
patch
obsolete
>From 33b392154e6fd81fe5d070b016f1dfc2d2f48074 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 19 Jan 2021 14:03:05 +0100 >Subject: [PATCH] Bug 27467: [SOLUTION 2] Add deepLink.js > >--- > .../lib/jquery/plugins/dataTables.deepLink.js | 87 +++++++++++++++++++ > 1 file changed, 87 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.deepLink.js > >diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.deepLink.js b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.deepLink.js >new file mode 100644 >index 0000000000..11f004e09c >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.deepLink.js >@@ -0,0 +1,87 @@ >+/*! Deep linking options parsing support for DataTables >+ * 2017 SpryMedia Ltd - datatables.net/license >+ */ >+ >+/** >+ * @summary LengthLinks >+ * @description Deep linking options parsing support for DataTables >+ * @version 1.0.0 >+ * @file dataTables.deepLink.js >+ * @author SpryMedia Ltd (www.sprymedia.co.uk) >+ * @copyright Copyright 2017 SpryMedia Ltd. >+ * >+ * License MIT - http://datatables.net/license/mit >+ * >+ * This feature plug-in for DataTables provides a function which will >+ * take DataTables options from the browser's URL search string and >+ * return an object that can be used to construct a DataTable. This >+ * allows deep linking to be easily implemented with DataTables - for >+ * example a URL might be `myTable?displayStart=10` which will >+ * automatically cause the second page of the DataTable to be displayed. >+ * >+ * This plug-in works on a whitelist basis - you must specify which >+ * [initialisation parameters](//datatables.net/reference/option) you >+ * want the URL search string to specify. Any parameter given in the >+ * URL which is not listed will be ignored (e.g. you are unlikely to >+ * want to let the URL search string specify the `ajax` option). >+ * >+ * This specification is done by passing an array of property names >+ * to the `$.fn.dataTable.ext.deepLink` function. If you do which to >+ * allow _every_ parameter (I wouldn't recommend it) you can use `all` >+ * instead of an array. >+ * >+ * @example >+ * // Allow a display start point and search string to be specified >+ * $('#myTable').DataTable( >+ * $.fn.dataTable.ext.deepLink( [ 'displayStart', 'search.search' ] ) >+ * ); >+ * >+ * @example >+ * // As above, but with a default search >+ * var options = $.fn.dataTable.ext.deepLink(['displayStart', 'search.search']); >+ * >+ * $('#myTable').DataTable( >+ * $.extend( true, { >+ * search: { search: 'Initial search value' } >+ * }, options ) >+ * ); >+ */ >+(function(window, document, $, undefined) { >+ // Use DataTables' object builder so strings can be used to represent >+ // nested objects >+ var setBuilder = $.fn.dataTable.ext.internal._fnSetObjectDataFn; >+ >+ $.fn.dataTable.ext.deepLink = function(whitelist) { >+ var search = location.search.replace(/^\?/, '').split('&'); >+ var out = {}; >+ >+ for (var i = 0, ien = search.length; i < ien; i++) { >+ var pair = search[i].split('='); >+ var key = decodeURIComponent(pair[0]); >+ var value = decodeURIComponent(pair[1]); >+ >+ // "Casting" >+ if (value === 'true') { >+ value = true; >+ } else if (value === 'false') { >+ value = false; >+ } else if (!value.match(/[^\d]/) && key !== 'search.search') { >+ // don't convert if searching or it'll break the search >+ value = value * 1; >+ } else if (value.indexOf('{') === 0 || value.indexOf('[') === 0) { >+ // Try to JSON parse for arrays and obejcts >+ try { >+ value = $.parseJSON(value); >+ } catch (e) {console.log("ERR");console.log(e);} >+ } >+ >+ if (whitelist === 'all' || $.inArray(key, whitelist) !== -1) { >+ var setter = setBuilder(key); >+ setter(out, value); >+ } >+ } >+ >+ console.log(out); >+ return out; >+ }; >+})(window, document, jQuery); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27467
:
115325
|
115326
|
115327
|
115328
|
115329
|
115330
|
115331
|
117962