Index: trunk/extensions/WikiLove/WikiLove.php |
— | — | @@ -77,7 +77,15 @@ |
78 | 78 | 'remoteExtPath' => 'WikiLove/modules/ext.wikiLove', |
79 | 79 | ); |
80 | 80 | |
| 81 | +// messages for default options, because we want to use them in the default |
| 82 | +// options module, but also for the user in the user options module |
| 83 | +$wgWikiLoveOptionMessages = array( |
| 84 | + 'wikilove-type-makeyourown', |
| 85 | +); |
| 86 | + |
81 | 87 | // resources |
| 88 | +// it is much better to have a chain like: startup -> default -> local -> init, |
| 89 | +// but because of this bug that isn't possible right now: https://bugzilla.wikimedia.org/29608 |
82 | 90 | $wgResourceModules += array( |
83 | 91 | 'ext.wikiLove.icon' => $extWikiLoveTpl + array( |
84 | 92 | 'styles' => 'ext.wikiLove.icon.css', |
— | — | @@ -86,7 +94,6 @@ |
87 | 95 | 'ext.wikiLove.startup' => $extWikiLoveTpl + array( |
88 | 96 | 'scripts' => array( |
89 | 97 | 'ext.wikiLove.core.js', |
90 | | - 'ext.wikiLove.defaultOptions.js', |
91 | 98 | ), |
92 | 99 | 'styles' => 'ext.wikiLove.css', |
93 | 100 | 'messages' => array( |
— | — | @@ -107,7 +114,6 @@ |
108 | 115 | 'wikilove-preview', |
109 | 116 | 'wikilove-notify', |
110 | 117 | 'wikilove-button-send', |
111 | | - 'wikilove-type-makeyourown', |
112 | 118 | 'wikilove-err-header', |
113 | 119 | 'wikilove-err-title', |
114 | 120 | 'wikilove-err-msg', |
— | — | @@ -125,15 +131,15 @@ |
126 | 132 | 'ext.wikiLove.local' => array( |
127 | 133 | 'class' => 'WikiLoveLocal', |
128 | 134 | /* for information only, this is actually in the class! |
129 | | - 'dependencies' => array( |
130 | | - 'ext.wikiLove.startup', |
131 | | - ), |
| 135 | + 'messages' => $wgWikiLoveOptionMessages, |
| 136 | + 'dependencies' => 'ext.wikiLove.startup' |
132 | 137 | */ |
133 | 138 | ), |
134 | | - 'ext.wikiLove.init' => $extWikiLoveTpl + array( |
135 | | - 'scripts' => 'ext.wikiLove.init.js', |
136 | | - 'dependencies' => array( |
137 | | - 'ext.wikiLove.local', |
| 139 | + 'ext.wikiLove.defaultOptions' => $extWikiLoveTpl + array( |
| 140 | + 'scripts' => array( |
| 141 | + 'ext.wikiLove.defaultOptions.js', |
138 | 142 | ), |
| 143 | + 'messages' => $wgWikiLoveOptionMessages, |
| 144 | + 'dependencies' => 'ext.wikiLove.startup' |
139 | 145 | ), |
140 | 146 | ); |
Index: trunk/extensions/WikiLove/WikiLove.hooks.php |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | * @param $skin Skin |
51 | 51 | */ |
52 | 52 | public static function beforePageDisplay( $out, $skin ) { |
53 | | - global $wgWikiLoveGlobal, $wgUser; |
| 53 | + global $wgWikiLoveGlobal, $wgWikiLoveEnableLocalConfig, $wgUser; |
54 | 54 | if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) { |
55 | 55 | return true; |
56 | 56 | } |
— | — | @@ -57,7 +57,17 @@ |
58 | 58 | $title = self::getUserTalkPage( $skin->getTitle() ); |
59 | 59 | if ( !is_null( $title ) ) { |
60 | 60 | $out->addModules( 'ext.wikiLove.icon' ); |
61 | | - $out->addModules( 'ext.wikiLove.init' ); |
| 61 | + |
| 62 | + // it is much better to have a chain like: startup -> default -> local -> init, |
| 63 | + // but because of this bug that isn't possible right now: https://bugzilla.wikimedia.org/29608 |
| 64 | + $optionsTitle = Title::newFromText( "MediaWiki:WikiLove.js" ); |
| 65 | + if( $optionsTitle->exists() && $optionsTitle->isCssOrJsPage() ) { |
| 66 | + $out->addModules( 'ext.wikiLove.local' ); |
| 67 | + } |
| 68 | + else { |
| 69 | + $out->addModules( 'ext.wikiLove.defaultOptions' ); |
| 70 | + } |
| 71 | + |
62 | 72 | self::$recipient = $title->getText(); |
63 | 73 | } |
64 | 74 | return true; |
Index: trunk/extensions/WikiLove/WikiLove.local.php |
— | — | @@ -14,4 +14,9 @@ |
15 | 15 | 'ext.wikiLove.startup', |
16 | 16 | ); |
17 | 17 | } |
| 18 | + |
| 19 | + public function getMessages() { |
| 20 | + global $wgWikiLoveOptionMessages; |
| 21 | + return $wgWikiLoveOptionMessages; |
| 22 | + } |
18 | 23 | } |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.init.js |
— | — | @@ -1,3 +0,0 @@ |
2 | | -( function( $ ) { |
3 | | -$( document ).ready( $.wikiLove.init ); |
4 | | -} )( jQuery ); |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | ( function( $ ) { |
3 | | -$.wikiLove.optionsHook = function() { return { |
| 3 | +$.wikiLoveOptions = function() { return { |
4 | 4 | defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\ |
5 | 5 | |rowspan="2" style="vertical-align: middle; padding: 5px;" | [[$3|$4]]\n\ |
6 | 6 | |style="font-size: x-large; padding: 3px; height: 1.5em;" | \'\'\'$2\'\'\'\n\ |
— | — | @@ -356,4 +356,9 @@ |
357 | 357 | } |
358 | 358 | } |
359 | 359 | }; }; |
| 360 | + |
| 361 | +if( typeof $.wikiLove != 'undefined' ) $.wikiLove.init(); // this is required when copying this file to MediaWiki:WikiLove.js |
| 362 | +// because of https://bugzilla.wikimedia.org/29608 ; please leave it here as it does no harm being executed in defaultOptions.js |
| 363 | +// and it may be confusing if it is required to uncomment it when copying this to MediaWiki:WikiLove.js |
| 364 | + |
360 | 365 | } )( jQuery ); |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -11,8 +11,6 @@ |
12 | 12 | gallery = {}; |
13 | 13 | |
14 | 14 | return { |
15 | | - optionsHook: function() { return {}; }, // hook that can be overridden by the user to modify options |
16 | | - |
17 | 15 | /* |
18 | 16 | * Opens the dialog and builds it if necessary. |
19 | 17 | */ |
— | — | @@ -532,9 +530,12 @@ |
533 | 531 | /* |
534 | 532 | * Init function which is called upon page load. Binds the WikiLove icon to opening the dialog. |
535 | 533 | */ |
536 | | - init: function() { |
537 | | - options = $.wikiLove.optionsHook(); |
538 | | - $( '#ca-wikilove' ).find( 'a' ).click( function( e ) { |
| 534 | + init: function( ) { |
| 535 | + if( typeof $.wikiLoveOptions == 'function' ) options = $.wikiLoveOptions(); |
| 536 | + |
| 537 | + var $wikiLoveLink = $( '#ca-wikilove' ).find( 'a' ); |
| 538 | + $wikiLoveLink.unbind( 'click' ); |
| 539 | + $wikiLoveLink.click( function( e ) { |
539 | 540 | $.wikiLove.openDialog(); |
540 | 541 | e.preventDefault(); |
541 | 542 | }); |
— | — | @@ -636,4 +637,6 @@ |
637 | 638 | }; |
638 | 639 | |
639 | 640 | }()); |
| 641 | + |
| 642 | +$( document ).ready( $.wikiLove.init ); |
640 | 643 | } ) ( jQuery ); |