r83054 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83053‎ | r83054 | r83055 >
Date:23:30, 1 March 2011
Author:krinkle
Status:deferred (Comments)
Tags:
Comment:
optimizing the way the dialog-div is added to the admin panel + fixing Bug 27817 - Search fails when used more than once
Modified paths:
  • /trunk/tools/wp-photocommons/js/admin.js (modified) (history)
  • /trunk/tools/wp-photocommons/js/search.js (modified) (history)
  • /trunk/tools/wp-photocommons/readme.txt (modified) (history)

Diff [purge]

Index: trunk/tools/wp-photocommons/readme.txt
@@ -41,7 +41,7 @@
4242
4343 == Changelog ==
4444
45 -= 1.0 =
 45+= 0.1 =
4646 * Initial version
4747
4848 == Upgrade Notice ==
Index: trunk/tools/wp-photocommons/js/search.js
@@ -133,6 +133,6 @@
134134
135135 // Init
136136 // FIXME
137 - $( document ).ready( PhotoCommons.init );
 137+ //$( document ).ready( PhotoCommons.init );
138138
139139 })(jQuery);
\ No newline at end of file
Index: trunk/tools/wp-photocommons/js/admin.js
@@ -1,56 +1,58 @@
22 (function($) {
3 - var PATH = '../wp-content/plugins/wp-photocommons';
43
5 - function _(msg) {
6 - return window.PhotoCommons.translations[msg];
7 - }
 4+ var PATH = '../wp-content/plugins/wp-photocommons';
85
9 - function addButtons() {
10 - $('#media-buttons').append(''.concat(
11 - '<a id="photocommons-add" title="' + _("Insert images from Wikimedia Commons") + '" style="padding-left:4px;">',
12 - '<img src="' + PATH + '/img/button.png"/>',
13 - '</a>'
14 - ));
 6+ function _(msg) {
 7+ return window.PhotoCommons.translations[msg];
 8+ }
159
16 - $('#photocommons-add').live('click', function(e) {
17 - e.preventDefault();
 10+ function addButtons() {
 11+ $('#media-buttons').append(''.concat(
 12+ '<a id="photocommons-add" title="' + _('Insert images from Wikimedia Commons') + '" style="padding-left:4px;">',
 13+ '<img src="' + PATH + '/img/button.png"/>',
 14+ '</a>'
 15+ ));
1816
19 - $('body').prepend('<div id="photocommons-dialog"></div>');
20 - $('#photocommons-dialog').load(PATH + '/search.php?standalone=1', function() {
21 - PhotoCommons.init();
 17+ var searchDialog = {};
 18+ $('<div id="photocommons-dialog"></div>').appendTo('body').load(PATH + '/search.php?standalone=1', function(){
2219
23 - var $self = $('#photocommons-dialog');
 20+ PhotoCommons.init();
2421
25 - $self.dialog({
26 - title : _('PhotoCommons') + ' - ' + _("Insert images from Wikimedia Commons"),
27 - width : 800,
28 - height : 500
29 - });
 22+ dialog = $('#photocommons-dialog').dialog({
 23+ title : _('PhotoCommons') + ' - ' + _('Insert images from Wikimedia Commons'),
 24+ width : 800,
 25+ height : 500,
 26+ autoOpen: false
 27+ });
3028
31 - $('#wp-photocommons-images .image').live('click', function() {
32 - var file = $(this).attr('data-filename'),
33 - shortcode = '[photocommons file="' + file + '" width="300"] ';
 29+ });
3430
35 - // Depending on whether we are in Wysiwyg or HTML mode we
36 - // do a different insert
37 - if ($('#edButtonHTML').hasClass('active')) {
38 - // HTML editor
39 - $('#content').val( function(i,val){
40 - return shortcode + val;
41 - });
42 - } else {
43 - // Wysiwyg
44 - tinyMCE.execCommand('mceInsertContent', false, shortcode);
45 - }
 31+ $('#photocommons-add').live('click', function(e) {
 32+ e.preventDefault();
4633
47 - $self.dialog('close');
48 - });
49 - });
50 - });
51 - }
 34+ searchDialog.dialog('open');
5235
53 - $(document).ready(function() {
54 - addButtons();
55 - });
 36+ $('#wp-photocommons-images .image').live('click', function() {
 37+ var file = $(this).attr('data-filename'),
 38+ shortcode = '[photocommons file="' + file + '" width="300"] ';
5639
 40+ // Depending on whether we are in Wysiwyg or HTML mode we
 41+ // do a different insert
 42+ if ($('#edButtonHTML').hasClass('active')) {
 43+ // HTML editor
 44+ $('#content').val( function(i,val){
 45+ return shortcode + val;
 46+ });
 47+ } else {
 48+ // Wysiwyg
 49+ tinyMCE.execCommand('mceInsertContent', false, shortcode);
 50+ }
 51+
 52+ searchDialog.dialog('close');
 53+ });
 54+ });
 55+ }
 56+
 57+ $(document).ready( addButtons );
 58+
5759 })(jQuery);
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r83055removed redundant call (see r83054 CR)krinkle23:37, 1 March 2011

Comments

#Comment by Krinkle (talk | contribs)   23:36, 1 March 2011

Ohyeah, I converted it to tabs like the other files and commented out the document-ready init call in search.js since that's no longer needed

#Comment by Krinkle (talk | contribs)   23:37, 1 March 2011

Removed entirely in r83055.

Status & tagging log