Index: trunk/tools/wp-photocommons/readme.txt |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | |
43 | 43 | == Changelog == |
44 | 44 | |
45 | | -= 1.0 = |
| 45 | += 0.1 = |
46 | 46 | * Initial version |
47 | 47 | |
48 | 48 | == Upgrade Notice == |
Index: trunk/tools/wp-photocommons/js/search.js |
— | — | @@ -133,6 +133,6 @@ |
134 | 134 | |
135 | 135 | // Init |
136 | 136 | // FIXME |
137 | | - $( document ).ready( PhotoCommons.init ); |
| 137 | + //$( document ).ready( PhotoCommons.init ); |
138 | 138 | |
139 | 139 | })(jQuery); |
\ No newline at end of file |
Index: trunk/tools/wp-photocommons/js/admin.js |
— | — | @@ -1,56 +1,58 @@ |
2 | 2 | (function($) { |
3 | | - var PATH = '../wp-content/plugins/wp-photocommons'; |
4 | 3 | |
5 | | - function _(msg) { |
6 | | - return window.PhotoCommons.translations[msg]; |
7 | | - } |
| 4 | + var PATH = '../wp-content/plugins/wp-photocommons'; |
8 | 5 | |
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 | + } |
15 | 9 | |
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 | + )); |
18 | 16 | |
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(){ |
22 | 19 | |
23 | | - var $self = $('#photocommons-dialog'); |
| 20 | + PhotoCommons.init(); |
24 | 21 | |
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 | + }); |
30 | 28 | |
31 | | - $('#wp-photocommons-images .image').live('click', function() { |
32 | | - var file = $(this).attr('data-filename'), |
33 | | - shortcode = '[photocommons file="' + file + '" width="300"] '; |
| 29 | + }); |
34 | 30 | |
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(); |
46 | 33 | |
47 | | - $self.dialog('close'); |
48 | | - }); |
49 | | - }); |
50 | | - }); |
51 | | - } |
| 34 | + searchDialog.dialog('open'); |
52 | 35 | |
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"] '; |
56 | 39 | |
| 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 | + |
57 | 59 | })(jQuery); |
\ No newline at end of file |