PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.17.0
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.17.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.17.0, at assets/app.js

188 lines 3.4 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 if (!this.container.length) {
7 return;
8 }
9
10 this.form = jQuery('#logtivity-log-index-search-form');
11
12 this.listenForPagination();
13
14 this.listenForChange();
15
16 this.filter();
17
18 this.listenForViewLog()
19
20 this.listenForCloseModal();
21 },
22
23 listenForCloseModal: function() {
24
25 var $this = this;
26
27 jQuery("body").on( "click", ".js-logtivity-notice-dismiss", function(e) {
28 e.preventDefault();
29
30 $this.hideModal();
31
32 });
33
34 jQuery(document).on('keyup', function(e) {
35
36 if (e.key == "Escape") {
37 $this.hideModal();
38 }
39
40 });
41
42 jQuery(document).mouseup(function(e) {
43
44 if (!$this.modalOpen) {
45 return;
46 }
47
48 var container = jQuery('.logtivity-modal-dialog');
49
50 // if the target of the click isn't the container nor a descendant of the container
51 if (!container.is(e.target) && container.has(e.target).length === 0) {
52 $this.hideModal();
53 }
54
55 });
56
57 },
58
59 listenForViewLog: function() {
60
61 var $this = this;
62
63 jQuery("body").on( "click", ".js-logtivity-view-log", function(e) {
64 e.preventDefault();
65
66 $this.showLogModal(jQuery(this).next().html());
67 });
68
69 },
70
71 showLogModal: function(modalContent) {
72
73 jQuery('.logtivity-modal').addClass('active');
74
75 this.modalOpen = true;
76
77 jQuery('.logtivity-modal-content').html(modalContent);
78
79 },
80
81 hideModal: function() {
82
83 jQuery('.logtivity-modal').removeClass('active');
84
85 this.modalOpen = false;
86
87 },
88
89 listenForChange: function() {
90
91 var $this = this;
92
93 var timeout = null;
94
95 jQuery("body").on( "input", "#logtivity-log-index-search-form input", function(e) {
96 e.preventDefault();
97
98 jQuery('#logtivity_page').val('');
99
100 // Clear the timeout if it has already been set.
101 // This will prevent the previous task from executing
102 // if it has been less than <MILLISECONDS>
103 clearTimeout(timeout);
104
105 // Make a new timeout set to go off in 1000ms
106 timeout = setTimeout(function () {
107
108 $this.filter();
109
110 }, 1000);
111
112 });
113
114 },
115
116 loading: function() {
117
118 this.container.html(
119 '<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>'
120 );
121
122 },
123
124 listenForPagination: function() {
125
126 var $this = this;
127
128 jQuery("body").on( "click", ".js-logtivity-pagination", function(e) {
129 e.preventDefault();
130
131 jQuery('#logtivity_page').val(jQuery(this).attr('data-page'));
132
133 $this.filter();
134 });
135
136 },
137
138 filter: function() {
139
140 this.loading();
141
142 var $this = this;
143
144 jQuery.ajax({
145 url: $this.form.attr('action'),
146 type: 'GET',
147 data: $this.form.serialize(),
148 success: function(result) {
149 $this.container.html(result.view);
150 },
151 error: function(error) {
152 console.log(error);
153 }
154 });
155
156 }
157
158 };
159
160 var DismissUrlHasChanged = {
161
162 init: function() {
163
164 jQuery( document ).on( 'click', '.notice-dismiss', function () {
165 var type = jQuery(this).closest('.is-dismissible').attr('notice');
166 var dismissUntil = jQuery(this).closest('.is-dismissible').attr('dismiss-until');
167
168 if (type) {
169 jQuery.ajax( ajaxurl, {
170 type: 'POST',
171 data: {
172 action: 'logtivity_dismiss_notice',
173 type: type,
174 dismiss_until: dismissUntil,
175 }
176 });
177 }
178
179 });
180
181 }
182
183 };
184
185 jQuery(function() {
186 LogtivityLogIndex.init();
187 DismissUrlHasChanged.init();
188 });