Index: trunk/extensions/EducationProgram/resources/ep.pager.js |
— | — | @@ -6,36 +6,38 @@ |
7 | 7 | * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
8 | 8 | */ |
9 | 9 | |
10 | | -(function( $, mw, ep ) { |
11 | | - |
12 | | - $( document ).ready( function() { |
13 | | - |
14 | | - $( '.ep-pager-clear' ).click( function() { |
| 10 | +(function ( $, mw, ep ) { |
| 11 | + |
| 12 | + $( document ).ready( function () { |
| 13 | + |
| 14 | + $( '.ep-pager-clear' ).click( function () { |
15 | 15 | var $form = $( this ).closest( 'form' ); |
16 | 16 | $form.find( 'select' ).val( '' ); |
17 | 17 | $form.submit(); |
18 | 18 | return false; |
19 | 19 | } ); |
20 | | - |
21 | | - $( '.ep-pager-delete' ).click( function() { |
| 20 | + |
| 21 | + $( '.ep-pager-delete' ).click( function () { |
22 | 22 | if ( confirm( mw.msg( 'ep-pager-confirm-delete' ) ) ) { |
23 | | - $this = $( this ); |
24 | | - |
| 23 | + var $this = $( this ); |
| 24 | + |
25 | 25 | ep.api.remove( |
26 | 26 | { |
27 | 27 | 'type': $this.attr( 'data-type' ), |
28 | 28 | 'ids': [ $this.attr( 'data-id' ) ] |
29 | 29 | }, |
30 | | - function( result ) { |
| 30 | + function ( result ) { |
31 | 31 | if ( result.success ) { |
32 | | - $tr = $this.closest( 'tr' ); |
33 | | - $table = $tr.closest( 'table' ); |
34 | | - |
| 32 | + var $tr = $this.closest( 'tr' ); |
| 33 | + var $table = $tr.closest( 'table' ); |
| 34 | + |
35 | 35 | if ( $table.find( 'tr' ).length > 2 ) { |
36 | | - $tr.slideUp( 'slow', function() { $tr.remove(); } ); |
| 36 | + $tr.slideUp( 'slow', function () { |
| 37 | + $tr.remove(); |
| 38 | + } ); |
37 | 39 | } |
38 | 40 | else { |
39 | | - $table.slideUp( 'slow', function() { |
| 41 | + $table.slideUp( 'slow', function () { |
40 | 42 | $table.remove(); |
41 | 43 | } ); |
42 | 44 | } |
— | — | @@ -47,19 +49,19 @@ |
48 | 50 | ); |
49 | 51 | } |
50 | 52 | } ); |
51 | | - |
52 | | - $( '.ep-pager-select-all' ).change( function() { |
53 | | - var a = $( this ).closest( 'table' ).find( 'input:checkbox' ).prop( 'checked', $( this ).is( ':checked' ) ); |
| 53 | + |
| 54 | + $( '.ep-pager-select-all' ).change( function () { |
| 55 | + $( this ).closest( 'table' ).find( 'input:checkbox' ).prop( 'checked', $( this ).is( ':checked' ) ); |
54 | 56 | } ); |
55 | 57 | |
56 | | - $( '.ep-pager-delete-selected' ).click( function() { |
57 | | - var $deleteButton = $( this ); |
| 58 | + $( '.ep-pager-delete-selected' ).click( function () { |
| 59 | + var $deleteButton = $( this ); |
58 | 60 | var $selectAllCheckbox = $( '#ep-pager-select-all-' + $( this ).attr( 'data-pager-id' ) ); |
59 | | - var $table = $selectAllCheckbox.closest( 'table' ); |
| 61 | + var $table = $selectAllCheckbox.closest( 'table' ); |
60 | 62 | |
61 | 63 | var ids = []; |
62 | 64 | |
63 | | - $table.find( 'input[type=checkbox]:checked' ).each( function( i, element ) { |
| 65 | + $table.find( 'input[type=checkbox]:checked' ).each( function ( i, element ) { |
64 | 66 | ids.push( $( element ).val() ); |
65 | 67 | } ); |
66 | 68 | |
— | — | @@ -74,21 +76,21 @@ |
75 | 77 | 'type': $( this ).attr( 'data-type' ), |
76 | 78 | 'ids': ids |
77 | 79 | }, |
78 | | - function( result ) { |
| 80 | + function ( result ) { |
79 | 81 | if ( result.success ) { |
80 | | - if ( ids.length > 0 && ( $table.find( 'tr' ).length - ids.length > 1 ) ) { |
81 | | - for ( i in ids ) { |
82 | | - if ( ids.hasOwnProperty( i ) ) { |
83 | | - $( '#select-' + pagerId + '-' + ids[i] ).closest( 'tr' ).remove(); |
84 | | - } |
85 | | - } |
86 | | - } |
87 | | - else { |
88 | | - $table.slideUp( 'slow', function() { |
89 | | - $table.remove(); |
90 | | - $deleteButton.closest( 'fieldset' ).remove(); |
91 | | - } ); |
92 | | - } |
| 82 | + if ( ids.length > 0 && ( $table.find( 'tr' ).length - ids.length > 1 ) ) { |
| 83 | + for ( i in ids ) { |
| 84 | + if ( ids.hasOwnProperty( i ) ) { |
| 85 | + $( '#select-' + pagerId + '-' + ids[i] ).closest( 'tr' ).remove(); |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + else { |
| 90 | + $table.slideUp( 'slow', function () { |
| 91 | + $table.remove(); |
| 92 | + $deleteButton.closest( 'fieldset' ).remove(); |
| 93 | + } ); |
| 94 | + } |
93 | 95 | } |
94 | 96 | else { |
95 | 97 | alert( mw.msg( 'ep-pager-delete-selected-fail' ) ); // TODO |
— | — | @@ -96,7 +98,7 @@ |
97 | 99 | } |
98 | 100 | ); |
99 | 101 | } ); |
100 | | - |
| 102 | + |
101 | 103 | } ); |
102 | | - |
103 | | -})( window.jQuery, window.mediaWiki, window.educationProgram ) |
\ No newline at end of file |
| 104 | + |
| 105 | +})( window.jQuery, window.mediaWiki, window.educationProgram ); |
\ No newline at end of file |