PluginProbe
Redirection / 2.2.14
Redirection v2.2.14
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / js / redirection.js

redirection.js in Redirection 2.2.14, at js/redirection.js

301 lines 8.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var Redirection;
2
3 (function($) {
4 Redirection = function( args ) {
5 var opts = $.extend({
6 ajaxurl: '',
7 nonce: '',
8 are_you_sure: 'Are you sure?',
9 none_selected: 'No items were selected',
10 page: 0
11 }, args);
12
13 function do_items( type, command ) {
14 var checked = $( '.item :checked' );
15 if ( checked.length > 0 ) {
16 if ( confirm( opts.are_you_sure ) ) {
17 $( '#loading' ).show ();
18
19 $.post( opts.ajaxurl, {
20 _ajax_nonce: opts.nonce,
21 action: 'red_' + type + '_' + command,
22 checked: checked.serialize()
23 },
24 function() {
25 window.location.reload();
26 });
27 }
28 }
29 else
30 alert( opts.none_selected );
31
32 return false;
33 }
34
35 function sort_order_save( type ) {
36 if ( confirm( opts.are_you_sure ) ) {
37 $( '#loading' ).show();
38
39 $.post( opts.ajaxurl, {
40 action: 'red_' + type + '_saveorder',
41 page: opts.page,
42 _ajax_nonce: opts.nonce,
43 items: $( '#items' ).sortable( 'serialize' )
44 },
45 function() {
46 $( '#loading' ).hide ();
47 $( '#toggle_sort_off' ).hide ();
48 $( '#toggle_sort_on' ).show ();
49 $( '#items' ).sortable( 'disable' );
50 $( '#items li' ).removeClass( 'sortable' );
51 });
52 }
53
54 return false;
55 }
56
57 function sort_order() {
58 $( '#items' ).sortable();
59 $( '#toggle_sort_on' ).hide();
60 $( '#toggle_sort_off' ).show();
61 $( '#items li' ).addClass( 'sortable' );
62 return false;
63 }
64
65 function move_all( type ) {
66 var checked = $( '.item :checked' );
67 if ( checked.length > 0 ) {
68 if ( confirm( opts.are_you_sure ) ) {
69 $( '#loading' ).show ();
70
71 $.post( opts.ajaxurl, {
72 _ajax_nonce: opts.nonce,
73 action: 'red_' + type + '_move',
74 target: $( '#move' ).val(),
75 checked: checked.serialize()
76 },
77 function() {
78 window.location.reload();
79 });
80 }
81 }
82 else
83 alert( opts.none_selected );
84
85 return false;
86 }
87
88 function select_all() {
89 $( '.item :checkbox' ).each(function () {
90 this.checked = (this.checked ? '' : 'checked');
91 });
92
93 return false;
94 }
95
96 function delete_all( type ) {
97 var checked = $( '.item :checked' );
98
99 if ( checked.length > 0 ) {
100 if ( confirm( opts.are_you_sure ) ) {
101 var urltype = 'red_redirect_delete';
102
103 if ( type == 'group' )
104 urltype = 'red_group_delete';
105 else if ( type == 'log' )
106 urltype = 'red_log_delete';
107
108 $( '#loading' ).show();
109
110 $.post( opts.ajaxurl, {
111 checked: checked.serialize(),
112 action: urltype,
113 _ajax_nonce: opts.nonce
114 },
115 function() {
116 $( '#loading' ).hide();
117 checked.each( function(pos, item) {
118 $( '#item_' + $( item ).val() ).fadeOut();
119 });
120 });
121 }
122 }
123 else
124 alert( opts.none_selected );
125
126 return false;
127 }
128
129 function form_loader( element, type, reset_func ) {
130 var item = $( element ).parents( type )
131 var href = element.href;
132
133 if ( href.indexOf( 'admin-ajax.php' ) == -1 )
134 href = opts.ajaxurl + '?action=red_redirect_edit&id=' + item.attr( 'id' ).substr( 5 ) + '&_ajax_nonce=' + opts.nonce;
135
136 $( item ).find( '.operations div' ).hide();
137 $( item ).find( '.loader' ).show();
138 $( item ).load( href, function() {
139 // Setup cancel handler
140 $( item ).find( 'input[name=cancel]').click( function() {
141 $( item ).find( '.loader' ).show();
142
143 $( item ).load( href.replace( '_edit', '_load' ), function () {
144 reset_func( type );
145 });
146
147 return false;
148 });
149
150 var changestatus = null;
151
152 // Form handler
153 $( item ).find( 'form' ).ajaxForm( {
154 beforeSubmit: function( data, form ) {
155 $( item ).find( '.loader' ).show();
156
157 if ( form.find( 'input[name=status]' ).length > 0 )
158 changestatus = form.find( 'input[name=status]' ).attr( 'checked' );
159 },
160 success: function( response ) {
161 $( item ).html( response );
162
163 if ( changestatus !== null ) {
164 if ( changestatus === true )
165 $( item ).removeClass( 'disabled' );
166 else
167 $( item ).addClass( 'disabled' );
168 }
169
170 reset_func( type );
171 }
172 });
173 });
174
175 return false;
176 }
177
178 function modules() {
179 // Edit module
180 $( 'a.edit' ).unbind( 'click' ).click( function() {
181 return form_loader( this, 'tr', modules );
182 } );
183
184 // Reset links
185 $( 'a.reset' ).unbind( 'click' ).click( function() {
186 var item = $( this ).parents( 'tr' )
187 var href = this.href;
188
189 $( item ).find( '.operations div' ).hide();
190 $( item ).find( '.loader' ).show();
191 $( item ).load( this.href, function() {
192 modules();
193 });
194
195 return false;
196 });
197
198 // Delete links
199 $( 'a.rdelete' ).unbind( 'click' ).click( function() {
200 var item = $( this ).parents( 'tr' )
201
202 $( item ).find( '.operations a' ).hide();
203 $( item ).find( '.loader' ).show();
204 $.get( this.href, function() {
205 $( item ).fadeOut();
206 });
207
208 return false;
209 });
210 }
211
212 function edit_items( type ) {
213 $( 'a.redirection-edit' ).unbind( 'click' ).click(function() { return form_loader( this, 'li', edit_items ) } );
214
215 $( 'a.select-all' ).unbind( 'click' ).click(function() { return select_all(); } );
216 $( 'a.toggle-all' ).unbind( 'click' ).click(function() { return do_items( type, 'toggle' ); });
217 $( 'a.reset-all' ).unbind( 'click' ).click(function() { return do_items( type, 'reset' ); });
218 $( 'a.delete-all' ).unbind( 'click' ).click(function() { return delete_all( type ); });
219 $( 'input.move-all' ).unbind( 'click' ).click(function() { return move_all( type ); });
220
221 $( 'a.sort-on' ).unbind( 'click' ).click(function() { return sort_order(); });
222 $( 'a.sort-save' ).unbind( 'click' ).click(function() { return sort_order_save( type ); });
223 }
224
225 function logs() {
226 $( '.show-log' ).unbind( 'click' ).click( function() {
227 var item = $( this ).parents( 'tr' )
228 var href = this.href;
229
230 // Set loading icon
231 $( item ).find( '.info' ).html( opts.progress );
232
233 // Load info
234 $( item ).find( '.info' ).load( this.href, function() {
235 // Setup cancel handler
236 $( item ).find( '.info input[name=cancel]').click( function() {
237 $( item ).find( '.info' ).load( href.replace( 'red_log_show', 'red_log_hide' ), function () {
238 logs();
239 });
240
241 return false;
242 });
243 } );
244
245 return false;
246 });
247
248 $( '#actionator' ).unbind( 'click' ).click( function() {
249 if ( $( '#action2_select' ).val() == 'delete' )
250 delete_all( 'log' );
251 return false;
252 });
253
254 $( '.add-log' ).unbind( 'click' ).click( function( item ) {
255 var item = $( this ).parents( 'tr' )
256
257 $( '#added' ).hide ();
258 $( '#add' ).show ();
259
260 // Copy details
261 $( '#old' ).val( $( item ).find( '.details' ).attr( 'href' ).replace( /\w*:\/\/(.*?)\//, '/' ) );
262 return true;
263 });
264
265 $( '#cb input' ).unbind( 'click' ).click( function() {
266 var checked = $( this ).attr( 'checked' );
267
268 $( 'input.check' ).each( function( pos, item ) {
269 $( item ).attr( 'checked', checked );
270 });
271 });
272 }
273
274 var api = {
275 logs: logs,
276 edit_items: edit_items,
277 modules: modules
278 };
279
280 return api;
281 }
282
283 $( document ).ready( function() {
284 $( '#support-annoy' ).animate( { opacity: 0.2, backgroundColor: 'red' } ).animate( { opacity: 1, backgroundColor: 'yellow' } );
285 } );
286
287 })(jQuery);
288
289 function update_user_agent (item,box)
290 {
291 jQuery('#user_agent_' + box).attr ('value', jQuery(item).attr ('value'));
292 }
293
294 function change_add_redirect (item)
295 {
296 if (item.value == 'url' || item.value == 'pass')
297 jQuery('#target').show ();
298 else
299 jQuery('#target').hide ();
300 }
301