Index: trunk/extensions/Contest/specials/SpecialEditContest.php |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | |
125 | 125 | $this->contest = $contest; |
126 | 126 | $this->showForm(); |
127 | | - $this->getOutput()->addModules( 'contest.special.contest' ); |
| 127 | + $this->getOutput()->addModules( 'contest.special.editcontest' ); |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
Index: trunk/extensions/Contest/Contest.php |
— | — | @@ -146,9 +146,9 @@ |
147 | 147 | ) |
148 | 148 | ); |
149 | 149 | |
150 | | -$wgResourceModules['contest.special.contest'] = $moduleTemplate + array( |
| 150 | +$wgResourceModules['contest.special.editcontest'] = $moduleTemplate + array( |
151 | 151 | 'scripts' => array( |
152 | | - 'contest.special.contest.js' |
| 152 | + 'contest.special.editcontest.js' |
153 | 153 | ), |
154 | 154 | 'messages' => array( |
155 | 155 | 'contest-edit-delete', |
Index: trunk/extensions/Contest/resources/contest.special.contest.js |
— | — | @@ -1,165 +0,0 @@ |
2 | | -/** |
3 | | - * JavasSript for the Contest MediaWiki extension. |
4 | | - * @see https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Extension:Contest |
5 | | - * |
6 | | - * @licence GNU GPL v3 or later |
7 | | - * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
8 | | - */ |
9 | | - |
10 | | -// TODO: put all stuff in HTMLForm form so the submission stuff doesn't fail |
11 | | - |
12 | | -(function( $, mw ) { |
13 | | - |
14 | | - function addChallengeToRemove( id ) { |
15 | | - if ( !isNaN( id ) ) { |
16 | | - var currentVal = $( '#delete-challenges' ).val(); |
17 | | - |
18 | | - var currentIds = currentVal !== '' ? currentVal.split( '|' ) : []; |
19 | | - currentIds.push( id ); |
20 | | - |
21 | | - $( '#delete-challenges' ).val( currentIds.join( '|' ) ); |
22 | | - } |
23 | | - } |
24 | | - |
25 | | - $.fn.mwChallenge = function( options ) { |
26 | | - |
27 | | - var _this = this; |
28 | | - var $this = $( this ); |
29 | | - this.options = options; |
30 | | - |
31 | | - this.titleInput = null; |
32 | | - this.textInput = null; |
33 | | - this.deleteButton = null; |
34 | | - |
35 | | - this.remove = function() { |
36 | | - addChallengeToRemove( $this.attr( 'data-challenge-id' ) ); |
37 | | - |
38 | | - $tr = $this.closest( 'tr' ); |
39 | | - $tr.slideUp( 'fast', function() { $tr.remove(); } ); |
40 | | - }; |
41 | | - |
42 | | - this.init = function() { |
43 | | - $this.html( '' ); |
44 | | - |
45 | | - this.titleInput = $( '<input />' ).attr( { |
46 | | - 'type': 'text', |
47 | | - 'name': 'contest-challenge-' + $this.attr( 'data-challenge-id' ), |
48 | | - 'size': 45 |
49 | | - } ).val( $this.attr( 'data-challenge-title' ) ); |
50 | | - |
51 | | - $this.append( |
52 | | - $( '<div />' ).html( |
53 | | - $( '<label />' ) |
54 | | - .text( mw.msg( 'contest-edit-challenge-title' ) ) |
55 | | - .attr( 'for', 'contest-challenge-' + $this.attr( 'data-challenge-id' ) ) |
56 | | - ).append( ' ' ).append( this.titleInput ) |
57 | | - ); |
58 | | - |
59 | | - this.onelineInput = $( '<input />' ).attr( { |
60 | | - 'type': 'text', |
61 | | - 'name': 'challenge-oneline-' + $this.attr( 'data-challenge-id' ), |
62 | | - 'size': 45 |
63 | | - } ).val( $this.attr( 'data-challenge-oneline' ) ); |
64 | | - |
65 | | - $this.append( |
66 | | - $( '<div />' ).html( |
67 | | - $( '<label />' ) |
68 | | - .text( mw.msg( 'contest-edit-challenge-oneline' ) ) |
69 | | - .attr( 'for', 'contest-oneline-' + $this.attr( 'data-challenge-id' ) ) |
70 | | - ).append( ' ' ).append( this.onelineInput ) |
71 | | - ); |
72 | | - |
73 | | - this.textInput = $( '<textarea />' ).attr( { |
74 | | - 'name': 'challenge-text-' + $this.attr( 'data-challenge-id' ) |
75 | | - } ).val( $this.attr( 'data-challenge-text' ) ); |
76 | | - |
77 | | - $this.append( |
78 | | - $( '<div />' ).html( |
79 | | - $( '<label />' ) |
80 | | - .text( mw.msg( 'contest-edit-challenge-text' ) ) |
81 | | - .attr( 'for', 'challenge-text-' + $this.attr( 'data-challenge-id' ) ) |
82 | | - ).append( '<br />' ).append( this.textInput ) |
83 | | - ); |
84 | | - |
85 | | - this.deleteButton = $( '<button />' ) |
86 | | - .button( { 'label': mw.msg( 'contest-edit-delete' ) } ) |
87 | | - .click( function() { |
88 | | - if ( confirm( mw.msg( 'contest-edit-confirm-delete' ) ) ) { |
89 | | - _this.remove(); |
90 | | - return false; |
91 | | - } |
92 | | - } ); |
93 | | - |
94 | | - $this.append( this.deleteButton ); |
95 | | - }; |
96 | | - |
97 | | - this.init(); |
98 | | - |
99 | | - return this; |
100 | | - |
101 | | - }; |
102 | | - |
103 | | - var newNr = 0; |
104 | | - var $table = null; |
105 | | - |
106 | | - function getNewChallengeMessage() { |
107 | | - return mw.msg( 'contest-edit-add-' + ( $( '.contest-challenge-input' ).size() === 0 ? 'first' : 'another' ) ); |
108 | | - } |
109 | | - |
110 | | - function addChallenge( challenge ) { |
111 | | - $challenge = $( '<div />' ).attr( { |
112 | | - 'class': 'contest-challenge-input', |
113 | | - 'data-challenge-id': challenge.id, |
114 | | - 'data-challenge-title': challenge.title, |
115 | | - 'data-challenge-text': challenge.text, |
116 | | - 'data-challenge-oneline': challenge.oneline |
117 | | - } ); |
118 | | - |
119 | | - $tr = $( '<tr />' ); |
120 | | - |
121 | | - $tr.append( $( '<td />' ) ); |
122 | | - |
123 | | - $tr.append( $( '<td />' ).html( $challenge ).append( '<hr />' ) ); |
124 | | - |
125 | | - $( '.add-new-challenge' ).before( $tr ); |
126 | | - |
127 | | - $challenge.mwChallenge(); |
128 | | - } |
129 | | - |
130 | | - $( document ).ready( function() { |
131 | | - |
132 | | - $table = $( '#contest-name-field' ).closest( 'tbody' ); |
133 | | - |
134 | | - $( '#bodyContent' ).find( '[type="submit"]' ).button(); |
135 | | - |
136 | | - $table.append( '<tr><td colspan="2"><hr /></td></tr>' ); |
137 | | - |
138 | | - $addNew = $( '<button />' ).button( { 'label': getNewChallengeMessage() } ).click( function() { |
139 | | - addChallenge( { |
140 | | - 'id': 'new-' + newNr++ , |
141 | | - 'title': '', |
142 | | - 'text': '' |
143 | | - } ); |
144 | | - |
145 | | - $( this ).button( { 'label': getNewChallengeMessage() } ); |
146 | | - |
147 | | - return false; |
148 | | - } ); |
149 | | - |
150 | | - $table.append( $( '<tr />' ).attr( 'class', 'add-new-challenge' ).html( $( '<td />' ) ).append( $( '<td />' ).html( $addNew ) ) ); |
151 | | - |
152 | | - $table.append( '<tr><td colspan="2"><hr /></td></tr>' ); |
153 | | - |
154 | | - $( '.contest-challenge' ).each( function( index, domElement ) { |
155 | | - $this = $( domElement ); |
156 | | - addChallenge( { |
157 | | - 'id': $this.attr( 'data-challenge-id' ), |
158 | | - 'title': $this.attr( 'data-challenge-title' ), |
159 | | - 'text': $this.attr( 'data-challenge-text' ), |
160 | | - 'oneline': $this.attr( 'data-challenge-oneline' ), |
161 | | - } ); |
162 | | - } ); |
163 | | - |
164 | | - } ); |
165 | | - |
166 | | -})( window.jQuery, window.mediaWiki ); |
Index: trunk/extensions/Contest/resources/contest.special.editcontest.js |
— | — | @@ -0,0 +1,164 @@ |
| 2 | +/** |
| 3 | + * JavasSript for the Contest MediaWiki extension. |
| 4 | + * @see https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Extension:Contest |
| 5 | + * |
| 6 | + * @licence GNU GPL v3 or later |
| 7 | + * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
| 8 | + */ |
| 9 | + |
| 10 | +(function( $, mw ) { |
| 11 | + |
| 12 | + function addChallengeToRemove( id ) { |
| 13 | + if ( !isNaN( id ) ) { |
| 14 | + var currentVal = $( '#delete-challenges' ).val(); |
| 15 | + |
| 16 | + var currentIds = currentVal !== '' ? currentVal.split( '|' ) : []; |
| 17 | + currentIds.push( id ); |
| 18 | + |
| 19 | + $( '#delete-challenges' ).val( currentIds.join( '|' ) ); |
| 20 | + } |
| 21 | + } |
| 22 | + |
| 23 | + $.fn.mwChallenge = function( options ) { |
| 24 | + |
| 25 | + var _this = this; |
| 26 | + var $this = $( this ); |
| 27 | + this.options = options; |
| 28 | + |
| 29 | + this.titleInput = null; |
| 30 | + this.textInput = null; |
| 31 | + this.deleteButton = null; |
| 32 | + |
| 33 | + this.remove = function() { |
| 34 | + addChallengeToRemove( $this.attr( 'data-challenge-id' ) ); |
| 35 | + |
| 36 | + $tr = $this.closest( 'tr' ); |
| 37 | + $tr.slideUp( 'fast', function() { $tr.remove(); } ); |
| 38 | + }; |
| 39 | + |
| 40 | + this.init = function() { |
| 41 | + $this.html( '' ); |
| 42 | + |
| 43 | + this.titleInput = $( '<input />' ).attr( { |
| 44 | + 'type': 'text', |
| 45 | + 'name': 'contest-challenge-' + $this.attr( 'data-challenge-id' ), |
| 46 | + 'size': 45 |
| 47 | + } ).val( $this.attr( 'data-challenge-title' ) ); |
| 48 | + |
| 49 | + $this.append( |
| 50 | + $( '<div />' ).html( |
| 51 | + $( '<label />' ) |
| 52 | + .text( mw.msg( 'contest-edit-challenge-title' ) ) |
| 53 | + .attr( 'for', 'contest-challenge-' + $this.attr( 'data-challenge-id' ) ) |
| 54 | + ).append( ' ' ).append( this.titleInput ) |
| 55 | + ); |
| 56 | + |
| 57 | + this.onelineInput = $( '<input />' ).attr( { |
| 58 | + 'type': 'text', |
| 59 | + 'name': 'challenge-oneline-' + $this.attr( 'data-challenge-id' ), |
| 60 | + 'size': 45, |
| 61 | + 'style': 'margin-top: 3px' |
| 62 | + } ).val( $this.attr( 'data-challenge-oneline' ) ); |
| 63 | + |
| 64 | + $this.append( |
| 65 | + $( '<div />' ).html( |
| 66 | + $( '<label />' ) |
| 67 | + .text( mw.msg( 'contest-edit-challenge-oneline' ) ) |
| 68 | + .attr( { 'for': 'contest-oneline-' + $this.attr( 'data-challenge-id' ) } ) |
| 69 | + ).append( ' ' ).append( this.onelineInput ) |
| 70 | + ); |
| 71 | + |
| 72 | + this.textInput = $( '<textarea />' ).attr( { |
| 73 | + 'name': 'challenge-text-' + $this.attr( 'data-challenge-id' ) |
| 74 | + } ).val( $this.attr( 'data-challenge-text' ) ); |
| 75 | + |
| 76 | + $this.append( |
| 77 | + $( '<div />' ).html( |
| 78 | + $( '<label />' ) |
| 79 | + .text( mw.msg( 'contest-edit-challenge-text' ) ) |
| 80 | + .attr( 'for', 'challenge-text-' + $this.attr( 'data-challenge-id' ) ) |
| 81 | + ).append( '<br />' ).append( this.textInput ) |
| 82 | + ); |
| 83 | + |
| 84 | + this.deleteButton = $( '<button />' ) |
| 85 | + .button( { 'label': mw.msg( 'contest-edit-delete' ) } ) |
| 86 | + .click( function() { |
| 87 | + if ( confirm( mw.msg( 'contest-edit-confirm-delete' ) ) ) { |
| 88 | + _this.remove(); |
| 89 | + return false; |
| 90 | + } |
| 91 | + } ); |
| 92 | + |
| 93 | + $this.append( this.deleteButton ); |
| 94 | + }; |
| 95 | + |
| 96 | + this.init(); |
| 97 | + |
| 98 | + return this; |
| 99 | + |
| 100 | + }; |
| 101 | + |
| 102 | + var newNr = 0; |
| 103 | + var $table = null; |
| 104 | + |
| 105 | + function getNewChallengeMessage() { |
| 106 | + return mw.msg( 'contest-edit-add-' + ( $( '.contest-challenge-input' ).size() === 0 ? 'first' : 'another' ) ); |
| 107 | + } |
| 108 | + |
| 109 | + function addChallenge( challenge ) { |
| 110 | + $challenge = $( '<div />' ).attr( { |
| 111 | + 'class': 'contest-challenge-input', |
| 112 | + 'data-challenge-id': challenge.id, |
| 113 | + 'data-challenge-title': challenge.title, |
| 114 | + 'data-challenge-text': challenge.text, |
| 115 | + 'data-challenge-oneline': challenge.oneline |
| 116 | + } ); |
| 117 | + |
| 118 | + $tr = $( '<tr />' ); |
| 119 | + |
| 120 | + $tr.append( $( '<td />' ) ); |
| 121 | + |
| 122 | + $tr.append( $( '<td />' ).html( $challenge ).append( '<hr />' ) ); |
| 123 | + |
| 124 | + $( '.add-new-challenge' ).before( $tr ); |
| 125 | + |
| 126 | + $challenge.mwChallenge(); |
| 127 | + } |
| 128 | + |
| 129 | + $( document ).ready( function() { |
| 130 | + |
| 131 | + $table = $( '#contest-name-field' ).closest( 'tbody' ); |
| 132 | + |
| 133 | + $( '#bodyContent' ).find( '[type="submit"]' ).button(); |
| 134 | + |
| 135 | + $table.append( '<tr><td colspan="2"><hr /></td></tr>' ); |
| 136 | + |
| 137 | + $addNew = $( '<button />' ).button( { 'label': getNewChallengeMessage() } ).click( function() { |
| 138 | + addChallenge( { |
| 139 | + 'id': 'new-' + newNr++ , |
| 140 | + 'title': '', |
| 141 | + 'text': '' |
| 142 | + } ); |
| 143 | + |
| 144 | + $( this ).button( { 'label': getNewChallengeMessage() } ); |
| 145 | + |
| 146 | + return false; |
| 147 | + } ); |
| 148 | + |
| 149 | + $table.append( $( '<tr />' ).attr( 'class', 'add-new-challenge' ).html( $( '<td />' ) ).append( $( '<td />' ).html( $addNew ) ) ); |
| 150 | + |
| 151 | + $table.append( '<tr><td colspan="2"><hr /></td></tr>' ); |
| 152 | + |
| 153 | + $( '.contest-challenge' ).each( function( index, domElement ) { |
| 154 | + $this = $( domElement ); |
| 155 | + addChallenge( { |
| 156 | + 'id': $this.attr( 'data-challenge-id' ), |
| 157 | + 'title': $this.attr( 'data-challenge-title' ), |
| 158 | + 'text': $this.attr( 'data-challenge-text' ), |
| 159 | + 'oneline': $this.attr( 'data-challenge-oneline' ), |
| 160 | + } ); |
| 161 | + } ); |
| 162 | + |
| 163 | + } ); |
| 164 | + |
| 165 | +})( window.jQuery, window.mediaWiki ); |
Property changes on: trunk/extensions/Contest/resources/contest.special.editcontest.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 166 | + native |