PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.10.0
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.10.0
3.3.9 3.3.8 trunk 1.0 1.1.0 1.10.0 1.11.0 1.11.1 1.12.0 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.2.0 1.20.0 1.20.1 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 All 67 releases
logtivity / assets / app.js

app.js in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity 1.10.0, at assets/app.js

158 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var LogtivityLogIndex = {
2
3 init: function() {
4 this.container = jQuery('#logtivity-log-index');
5
6 this.form = jQuery('#logtivity-log-index-search-form');
7
8 this.listenForPagination();
9
10 this.listenForChange();
11
12 this.filter();
13
14 this.listenForViewLog()
15
16 this.listenForCloseModal();
17 },
18
19 listenForCloseModal: function() {
20
21 var $this = this;
22
23 jQuery("body").on( "click", ".js-logtivity-notice-dismiss", function(e) {
24 e.preventDefault();
25
26 $this.hideModal();
27
28 });
29
30 jQuery(document).on('keyup', function(e) {
31
32 if (e.key == "Escape") {
33 $this.hideModal();
34 }
35
36 });
37
38 jQuery(document).mouseup(function(e) {
39
40 if (!$this.modalOpen) {
41 return;
42 }
43
44 var container = jQuery('.logtivity-modal-dialog');
45
46 // if the target of the click isn't the container nor a descendant of the container
47 if (!container.is(e.target) && container.has(e.target).length === 0) {
48 $this.hideModal();
49 }
50
51 });
52
53 },
54
55 listenForViewLog: function() {
56
57 var $this = this;
58
59 jQuery("body").on( "click", ".js-logtivity-view-log", function(e) {
60 e.preventDefault();
61
62 $this.showLogModal(jQuery(this).next().html());
63 });
64
65 },
66
67 showLogModal: function(modalContent) {
68
69 jQuery('.logtivity-modal').addClass('active');
70
71 this.modalOpen = true;
72
73 jQuery('.logtivity-modal-content').html(modalContent);
74
75 },
76
77 hideModal: function() {
78
79 jQuery('.logtivity-modal').removeClass('active');
80
81 this.modalOpen = false;
82
83 },
84
85 listenForChange: function() {
86
87 var $this = this;
88
89 var timeout = null;
90
91 jQuery("body").on( "input", "#logtivity-log-index-search-form input", function(e) {
92 e.preventDefault();
93
94 jQuery('#logtivity_page').val('');
95
96 // Clear the timeout if it has already been set.
97 // This will prevent the previous task from executing
98 // if it has been less than <MILLISECONDS>
99 clearTimeout(timeout);
100
101 // Make a new timeout set to go off in 1000ms
102 timeout = setTimeout(function () {
103
104 $this.filter();
105
106 }, 1000);
107
108 });
109
110 },
111
112 loading: function() {
113
114 this.container.html(
115 '<div style="text-align: center; padding-bottom: 20px"><div class="spinner is-active" style="float:none;width:auto;height:auto;padding:10px 0 10px 50px;background-position:20px 0;"></div></div>'
116 );
117
118 },
119
120 listenForPagination: function() {
121
122 var $this = this;
123
124 jQuery("body").on( "click", ".js-logtivity-pagination", function(e) {
125 e.preventDefault();
126
127 jQuery('#logtivity_page').val(jQuery(this).attr('data-page'));
128
129 $this.filter();
130 });
131
132 },
133
134 filter: function() {
135
136 this.loading();
137
138 var $this = this;
139
140 jQuery.ajax({
141 url: $this.form.attr('action'),
142 type: 'GET',
143 data: $this.form.serialize(),
144 success: function(result) {
145 $this.container.html(result.view);
146 },
147 error: function(error) {
148 console.log(error);
149 }
150 });
151
152 }
153
154 };
155
156 jQuery(function() {
157 LogtivityLogIndex.init();
158 });