corrade-nucleus-nucleons – Blame information for rev 24
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | /** |
2 | * @author: Dennis Hernández |
||
3 | * @webSite: http://djhvscf.github.io/Blog |
||
4 | * @version: v1.0.0 |
||
5 | * |
||
6 | * @update zhixin wen <wenzhixin2010@gmail.com> |
||
7 | */ |
||
8 | |||
9 | !function ($) { |
||
10 | |||
11 | 'use strict'; |
||
12 | |||
13 | $.extend($.fn.bootstrapTable.defaults, { |
||
14 | keyEvents: false |
||
15 | }); |
||
16 | |||
17 | var BootstrapTable = $.fn.bootstrapTable.Constructor, |
||
18 | _init = BootstrapTable.prototype.init; |
||
19 | |||
20 | BootstrapTable.prototype.init = function () { |
||
21 | _init.apply(this, Array.prototype.slice.apply(arguments)); |
||
22 | this.initKeyEvents(); |
||
23 | }; |
||
24 | |||
25 | BootstrapTable.prototype.initKeyEvents = function () { |
||
26 | if (this.options.keyEvents) { |
||
27 | var that = this; |
||
28 | |||
29 | $(document).off('keydown').on('keydown', function (e) { |
||
30 | var $search = that.$toolbar.find('.search input'), |
||
31 | $refresh = that.$toolbar.find('button[name="refresh"]'), |
||
32 | $toggle = that.$toolbar.find('button[name="toggle"]'), |
||
33 | $paginationSwitch = that.$toolbar.find('button[name="paginationSwitch"]'); |
||
34 | |||
35 | if (document.activeElement === $search.get(0) || !$.contains(document.activeElement ,that.$toolbar.get(0))) { |
||
36 | return true; |
||
37 | } |
||
38 | |||
39 | switch (e.keyCode) { |
||
40 | case 83: //s |
||
41 | if (!that.options.search) { |
||
42 | return; |
||
43 | } |
||
44 | $search.focus(); |
||
45 | return false; |
||
46 | case 82: //r |
||
47 | if (!that.options.showRefresh) { |
||
48 | return; |
||
49 | } |
||
50 | $refresh.click(); |
||
51 | return false; |
||
52 | case 84: //t |
||
53 | if (!that.options.showToggle) { |
||
54 | return; |
||
55 | } |
||
56 | $toggle.click(); |
||
57 | return false; |
||
58 | case 80: //p |
||
59 | if (!that.options.showPaginationSwitch) { |
||
60 | return; |
||
61 | } |
||
62 | $paginationSwitch.click(); |
||
63 | return false; |
||
64 | case 37: // left |
||
65 | if (!that.options.pagination) { |
||
66 | return; |
||
67 | } |
||
68 | that.prevPage(); |
||
69 | return false; |
||
70 | case 39: // right |
||
71 | if (!that.options.pagination) { |
||
72 | return; |
||
73 | } |
||
74 | that.nextPage(); |
||
75 | return; |
||
76 | } |
||
77 | }); |
||
78 | } |
||
79 | }; |
||
80 | }(jQuery); |