Index: trunk/extensions/Collection/js/bookcreator.js |
— | — | @@ -21,23 +21,31 @@ |
22 | 22 | |
23 | 23 | (function($) { |
24 | 24 | |
| 25 | +var script_url = wgServer + ((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript); |
| 26 | + |
25 | 27 | function refreshBookCreatorBox(hint, oldid) { |
26 | | - sajax_request_type = 'GET'; |
27 | | - sajax_do_call('wfAjaxCollectionGetBookCreatorBoxContent', [hint, oldid], function(xhr) { |
28 | | - $('#coll-book_creator_box').html(xhr.responseText); |
29 | | - }); |
| 28 | + $.get(script_url, { |
| 29 | + 'action': 'ajax', |
| 30 | + 'rs': 'wfAjaxCollectionGetBookCreatorBoxContent', |
| 31 | + 'rsargs[]': [hint, oldid] |
| 32 | + }, function(result) { |
| 33 | + $('#coll-book_creator_box').html(result); |
| 34 | + }); |
30 | 35 | } |
31 | 36 | |
32 | 37 | function collectionCall(func, args) { |
33 | 38 | var hint = args.shift(); |
34 | | - sajax_request_type = 'POST'; |
35 | | - sajax_do_call('wfAjaxCollection' + func, args, function() { |
| 39 | + $.post(script_url, { |
| 40 | + 'action': 'ajax', |
| 41 | + 'rs': 'wfAjaxCollection' + func, |
| 42 | + 'rsargs[]': args |
| 43 | + }, function(result) { |
36 | 44 | var oldid = null; |
37 | 45 | if (args.length == 3) { |
38 | 46 | oldid = args[2]; |
39 | 47 | } |
40 | 48 | refreshBookCreatorBox(hint, oldid); |
41 | | - }); |
| 49 | + }); |
42 | 50 | } |
43 | 51 | |
44 | 52 | window.collectionCall = collectionCall; // public |
— | — | @@ -49,7 +57,6 @@ |
50 | 58 | var visible = false; |
51 | 59 | var show_soon_timeout = null; |
52 | 60 | var get_data_xhr = null; |
53 | | -var script_url = wgServer + ((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript); |
54 | 61 | var current_link = null; |
55 | 62 | var title = null; |
56 | 63 | |
Index: trunk/extensions/Collection/js/collection.js |
— | — | @@ -19,10 +19,8 @@ |
20 | 20 | * http://www.gnu.org/copyleft/gpl.html |
21 | 21 | */ |
22 | 22 | |
23 | | -(function() { |
| 23 | +(function($) { |
24 | 24 | |
25 | | -var jQuery = collection_jQuery; |
26 | | - |
27 | 25 | /******************************************************************************/ |
28 | 26 | |
29 | 27 | var requiredVersion = '1.4'; |
— | — | @@ -45,20 +43,28 @@ |
46 | 44 | return txt; |
47 | 45 | } |
48 | 46 | |
| 47 | +function req(func, args, callback) { |
| 48 | + $.post(script_url, { |
| 49 | + 'action': 'ajax', |
| 50 | + 'rs': 'wfAjaxCollection' + func, |
| 51 | + 'rsargs[]': args |
| 52 | + }, callback); |
| 53 | +} |
| 54 | + |
49 | 55 | var script_url = wgServer + |
50 | 56 | ((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript); |
51 | 57 | |
52 | 58 | /******************************************************************************/ |
53 | 59 | |
54 | 60 | function getMWServeStatus() { |
55 | | - jQuery.getJSON(script_url, { |
| 61 | + $.getJSON(script_url, { |
56 | 62 | 'action': 'ajax', |
57 | 63 | 'rs': 'wfAjaxGetMWServeStatus', |
58 | 64 | 'rsargs[]': [collection_id, writer] |
59 | 65 | }, function(result) { |
60 | 66 | if (result.state == 'progress' ) { |
61 | 67 | if ( result.status.progress ) { |
62 | | - jQuery('#renderingProgress').html('' + result.status.progress); |
| 68 | + $('#renderingProgress').html('' + result.status.progress); |
63 | 69 | } |
64 | 70 | if (result.status.status) { |
65 | 71 | var status = result.status.status; |
— | — | @@ -67,7 +73,7 @@ |
68 | 74 | } else if (result.status.page) { |
69 | 75 | status += gettext('#renderingPage', result.status.page); |
70 | 76 | } |
71 | | - jQuery('#renderingStatus').html(gettext('#renderingStatusText', status)); |
| 77 | + $('#renderingStatus').html(gettext('#renderingStatusText', status)); |
72 | 78 | } |
73 | 79 | setTimeout(getMWServeStatus, 500); |
74 | 80 | } else { |
— | — | @@ -80,13 +86,12 @@ |
81 | 87 | |
82 | 88 | function clear_collection() { |
83 | 89 | if (confirm(gettext('#clearCollectionConfirmText'))) { |
84 | | - sajax_request_type = "POST"; |
85 | | - sajax_do_call('wfAjaxCollectionClear', |
| 90 | + req('Clear', |
86 | 91 | [], |
87 | | - function(xhr) { |
88 | | - refresh_list(xhr); |
89 | | - sajax_do_call('wfAjaxCollectionGetBookCreatorBoxContent', ['showbook', null], function(xhr2) { |
90 | | - jQuery('#coll-book_creator_box').html(xhr2.responseText); |
| 92 | + function(result) { |
| 93 | + refresh_list(result); |
| 94 | + req('GetBookCreatorBoxContent', ['showbook', null], function(result2) { |
| 95 | + $('#coll-book_creator_box').html(result2); |
91 | 96 | }); |
92 | 97 | }); |
93 | 98 | } |
— | — | @@ -96,10 +101,7 @@ |
97 | 102 | function create_chapter() { |
98 | 103 | var name = prompt(gettext('#newChapterText')); |
99 | 104 | if (name) { |
100 | | - sajax_request_type = "POST"; |
101 | | - sajax_do_call('wfAjaxCollectionAddChapter', |
102 | | - [name], |
103 | | - refresh_list); |
| 105 | + req('AddChapter', [name], refresh_list); |
104 | 106 | } |
105 | 107 | return false; |
106 | 108 | } |
— | — | @@ -107,109 +109,103 @@ |
108 | 110 | function rename_chapter(index, old_name) { |
109 | 111 | var new_name = prompt(gettext('#renameChapterText'), old_name); |
110 | 112 | if (new_name) { |
111 | | - sajax_request_type = "POST"; |
112 | | - sajax_do_call('wfAjaxCollectionRenameChapter', |
113 | | - [index, new_name], |
114 | | - refresh_list); |
| 113 | + req('RenameChapter', [index, new_name], refresh_list); |
115 | 114 | } |
116 | 115 | return false; |
117 | 116 | } |
118 | 117 | |
119 | 118 | function remove_item(index) { |
120 | | - sajax_request_type = "POST"; |
121 | | - sajax_do_call('wfAjaxCollectionRemoveItem', |
| 119 | + req('RemoveItem', |
122 | 120 | [index], |
123 | | - function(xhr) { |
124 | | - refresh_list(xhr); |
125 | | - sajax_do_call('wfAjaxCollectionGetBookCreatorBoxContent', ['showbook', null], function(xhr2) { |
126 | | - jQuery('#coll-book_creator_box').html(xhr2.responseText); |
| 121 | + function(result) { |
| 122 | + refresh_list(result); |
| 123 | + req('GetBookCreatorBoxContent', ['showbook', null], function(result2) { |
| 124 | + $('#coll-book_creator_box').html(result2); |
127 | 125 | }); |
128 | 126 | }); |
129 | 127 | return false; |
130 | 128 | } |
131 | 129 | |
132 | 130 | function set_titles() { |
133 | | - sajax_request_type = "POST"; |
134 | | - sajax_do_call('wfAjaxCollectionSetTitles', |
135 | | - [jQuery('#titleInput').val(), jQuery('#subtitleInput').val()], function() {}); |
| 131 | + req('SetTitles', |
| 132 | + [$('#titleInput').val(), $('#subtitleInput').val()], function() {}); |
136 | 133 | return false; |
137 | 134 | } |
138 | 135 | |
139 | 136 | function set_sorting(items_string) { |
140 | | - sajax_request_type = "POST"; |
141 | | - sajax_do_call('wfAjaxCollectionSetSorting', [items_string], refresh_list); |
| 137 | + req('SetSorting', [items_string], refresh_list); |
142 | 138 | return false; |
143 | 139 | } |
144 | 140 | |
145 | 141 | function update_save_button() { |
146 | | - if (!jQuery('#saveButton').length) { |
| 142 | + if (!$('#saveButton').length) { |
147 | 143 | return; |
148 | 144 | } |
149 | | - if (jQuery('#collectionList .article').length == 0) { |
150 | | - jQuery('#saveButton').attr('disabled', 'disabled'); |
| 145 | + if ($('#collectionList .article').length == 0) { |
| 146 | + $('#saveButton').attr('disabled', 'disabled'); |
151 | 147 | return; |
152 | 148 | } |
153 | | - if (!jQuery('#communityCollTitle').length || jQuery('#personalCollType:checked').val()) { |
154 | | - jQuery('#personalCollTitle').attr('disabled', ''); |
155 | | - jQuery('#communityCollTitle').attr('disabled', 'disabled'); |
156 | | - if (!jQuery.trim(jQuery('#personalCollTitle').val())) { |
157 | | - jQuery('#saveButton').attr('disabled', 'disabled'); |
| 149 | + if (!$('#communityCollTitle').length || $('#personalCollType:checked').val()) { |
| 150 | + $('#personalCollTitle').attr('disabled', ''); |
| 151 | + $('#communityCollTitle').attr('disabled', 'disabled'); |
| 152 | + if (!$.trim($('#personalCollTitle').val())) { |
| 153 | + $('#saveButton').attr('disabled', 'disabled'); |
158 | 154 | return; |
159 | 155 | } |
160 | | - } else if (!jQuery('#personalCollTitle').length || jQuery('#communityCollType:checked').val()) { |
161 | | - jQuery('#communityCollTitle').attr('disabled', ''); |
162 | | - jQuery('#personalCollTitle').attr('disabled', 'disabled'); |
163 | | - if (!jQuery.trim(jQuery('#communityCollTitle').val())) { |
164 | | - jQuery('#saveButton').attr('disabled', 'disabled'); |
| 156 | + } else if (!$('#personalCollTitle').length || $('#communityCollType:checked').val()) { |
| 157 | + $('#communityCollTitle').attr('disabled', ''); |
| 158 | + $('#personalCollTitle').attr('disabled', 'disabled'); |
| 159 | + if (!$.trim($('#communityCollTitle').val())) { |
| 160 | + $('#saveButton').attr('disabled', 'disabled'); |
165 | 161 | return; |
166 | 162 | } |
167 | 163 | } |
168 | | - jQuery('#saveButton').attr('disabled', ''); |
| 164 | + $('#saveButton').attr('disabled', ''); |
169 | 165 | } |
170 | 166 | |
171 | 167 | function make_sortable() { |
172 | | - jQuery('#collectionList').sortable({ |
| 168 | + $('#collectionList').sortable({ |
173 | 169 | axis: 'y', |
174 | 170 | update: function(evt, ui) { |
175 | | - set_sorting(jQuery('#collectionList').sortable('serialize')); |
| 171 | + set_sorting($('#collectionList').sortable('serialize')); |
176 | 172 | } |
177 | 173 | }); |
178 | | - jQuery('#collectionList .sortableitem').css('cursor', 'move'); |
| 174 | + $('#collectionList .sortableitem').css('cursor', 'move'); |
179 | 175 | } |
180 | 176 | |
181 | | -function refresh_list(xhr) { |
182 | | - jQuery('#collectionListContainer').html(xhr.responseText); |
183 | | - jQuery('.makeVisible').css('display', 'inline'); |
| 177 | +function refresh_list(html) { |
| 178 | + $('#collectionListContainer').html(html); |
| 179 | + $('.makeVisible').css('display', 'inline'); |
184 | 180 | make_sortable(); |
185 | | - if (jQuery('#collectionList .article').length == 0) { |
186 | | - jQuery('#downloadButton').attr('disabled', 'disabled'); |
187 | | - jQuery('input.order').attr('disabled', 'disabled'); |
| 181 | + if ($('#collectionList .article').length == 0) { |
| 182 | + $('#downloadButton').attr('disabled', 'disabled'); |
| 183 | + $('input.order').attr('disabled', 'disabled'); |
188 | 184 | } else { |
189 | | - jQuery('#downloadButton').attr('disabled', ''); |
190 | | - jQuery('input.order').attr('disabled', ''); |
| 185 | + $('#downloadButton').attr('disabled', ''); |
| 186 | + $('input.order').attr('disabled', ''); |
191 | 187 | } |
192 | 188 | update_save_button(); |
193 | 189 | } |
194 | 190 | |
195 | 191 | function toggle_order_info(flag) { |
196 | 192 | if (flag) { |
197 | | - jQuery('#coll-more_info').css('display', 'none'); |
198 | | - jQuery('#coll-order_info').css('display', 'block'); |
199 | | - jQuery('#coll-hide_info').css('display', 'block'); |
| 193 | + $('#coll-more_info').css('display', 'none'); |
| 194 | + $('#coll-order_info').css('display', 'block'); |
| 195 | + $('#coll-hide_info').css('display', 'block'); |
200 | 196 | } else { |
201 | | - jQuery('#coll-more_info').css('display', 'block'); |
202 | | - jQuery('#coll-order_info').css('display', 'none'); |
203 | | - jQuery('#coll-hide_info').css('display', 'none'); |
| 197 | + $('#coll-more_info').css('display', 'block'); |
| 198 | + $('#coll-order_info').css('display', 'none'); |
| 199 | + $('#coll-hide_info').css('display', 'none'); |
204 | 200 | } |
205 | 201 | } |
206 | 202 | |
207 | | -jQuery(function() { |
| 203 | +$(function() { |
208 | 204 | if (requiredVersion != wgCollectionVersion) { |
209 | 205 | alert('ERROR: Version mismatch between Javascript and PHP code. Contact admin to fix the installation of Collection extension for MediaWiki.'); |
210 | 206 | return; |
211 | 207 | } |
212 | | - if (jQuery('#collectionList').length) { |
213 | | - jQuery('.makeVisible').css('display', 'inline'); |
| 208 | + if ($('#collectionList').length) { |
| 209 | + $('.makeVisible').css('display', 'inline'); |
214 | 210 | window.coll_create_chapter = create_chapter; |
215 | 211 | window.coll_remove_item = remove_item; |
216 | 212 | window.coll_rename_chapter = rename_chapter; |
— | — | @@ -218,18 +214,18 @@ |
219 | 215 | toggle_order_info(false); |
220 | 216 | update_save_button(); |
221 | 217 | make_sortable(); |
222 | | - jQuery('#personalCollTitle').keyup(update_save_button); |
223 | | - jQuery('#personalCollTitle').change(update_save_button); |
224 | | - jQuery('#communityCollTitle').keyup(update_save_button); |
225 | | - jQuery('#communityCollTitle').change(update_save_button); |
226 | | - jQuery('#personalCollType').change(update_save_button); |
227 | | - jQuery('#communityCollType').change(update_save_button); |
228 | | - jQuery('#titleInput').change(set_titles); |
229 | | - jQuery('#subtitleInput').change(set_titles); |
| 218 | + $('#personalCollTitle').keyup(update_save_button); |
| 219 | + $('#personalCollTitle').change(update_save_button); |
| 220 | + $('#communityCollTitle').keyup(update_save_button); |
| 221 | + $('#communityCollTitle').change(update_save_button); |
| 222 | + $('#personalCollType').change(update_save_button); |
| 223 | + $('#communityCollType').change(update_save_button); |
| 224 | + $('#titleInput').change(set_titles); |
| 225 | + $('#subtitleInput').change(set_titles); |
230 | 226 | } |
231 | 227 | if (typeof collection_rendering != 'undefined') { |
232 | 228 | getMWServeStatus(); |
233 | 229 | } |
234 | 230 | }); |
235 | 231 | |
236 | | -})(); |
| 232 | +})(collection_jQuery); |
Index: trunk/extensions/Collection/js/suggest.js |
— | — | @@ -1,21 +1,19 @@ |
2 | | -(function() { |
| 2 | +(function($) { |
3 | 3 | |
4 | | -var jQuery = collection_jQuery; |
5 | | - |
6 | 4 | var script_url = wgServer + |
7 | 5 | ((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript); |
8 | 6 | |
9 | 7 | function set_status(html) { |
10 | 8 | if (html) { |
11 | | - jQuery('#collectionSuggestStatus').css('visibility', 'visible').html(html); |
| 9 | + $('#collectionSuggestStatus').css('visibility', 'visible').html(html); |
12 | 10 | } else { |
13 | | - jQuery('#collectionSuggestStatus').css('visibility', 'hidden').html(' '); |
| 11 | + $('#collectionSuggestStatus').css('visibility', 'hidden').html(' '); |
14 | 12 | } |
15 | 13 | } |
16 | 14 | |
17 | 15 | function collectionSuggestCall(func, args) { |
18 | 16 | set_status('...'); |
19 | | - jQuery.post(script_url, { |
| 17 | + $.post(script_url, { |
20 | 18 | 'action': 'ajax', |
21 | 19 | 'rs': 'wfAjaxCollectionSuggest' + func, |
22 | 20 | 'rsargs[]': args |
— | — | @@ -25,16 +23,20 @@ |
26 | 24 | } else { |
27 | 25 | set_status(result.last_action); |
28 | 26 | } |
29 | | - jQuery('#collectionSuggestions').html(result.suggestions_html); |
30 | | - jQuery('#collectionMembers').html(result.members_html); |
31 | | - jQuery('#coll-num_pages').text(result.num_pages); |
32 | | - sajax_do_call('wfAjaxCollectionGetBookCreatorBoxContent', ['suggest', null], function(xhr) { |
33 | | - jQuery('#coll-book_creator_box').html(xhr.responseText); |
| 27 | + $('#collectionSuggestions').html(result.suggestions_html); |
| 28 | + $('#collectionMembers').html(result.members_html); |
| 29 | + $('#coll-num_pages').text(result.num_pages); |
| 30 | + $.get(script_url, { |
| 31 | + 'action': 'ajax', |
| 32 | + 'rs': 'wfAjaxCollectionGetBookCreatorBoxContent', |
| 33 | + 'rsargs[]': ['suggest', null] |
| 34 | + }, function(result) { |
| 35 | + $('#coll-book_creator_box').html(result); |
34 | 36 | }); |
35 | 37 | }, 'json'); |
36 | 38 | } |
37 | 39 | |
38 | 40 | window.collectionSuggestCall = collectionSuggestCall; |
39 | 41 | |
40 | | -})(); |
| 42 | +})(collection_jQuery); |
41 | 43 | |