r113695 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113694‎ | r113695 | r113696 >
Date:00:22, 13 March 2012
Author:jdlrobson
Status:ok
Tags:
Comment:
follow up to r113644#c32093

package up configuration into a single global config variable
Modified paths:
  • /trunk/extensions/MobileFrontend/javascripts/application.js (modified) (history)
  • /trunk/extensions/MobileFrontend/javascripts/beta_opensearch.js (modified) (history)
  • /trunk/extensions/MobileFrontend/javascripts/opensearch.js (modified) (history)
  • /trunk/extensions/MobileFrontend/templates/ApplicationTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/javascripts/beta_opensearch.js
@@ -12,9 +12,7 @@
1313 focused = false,
1414 u = MobileFrontend.utils;
1515
16 - if ( scriptPath ) {
17 - apiUrl = scriptPath + apiUrl;
18 - }
 16+ apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl;
1917
2018 function hideResults() {
2119 results.style.display = 'none';
Index: trunk/extensions/MobileFrontend/javascripts/application.js
@@ -99,9 +99,12 @@
100100 init();
101101 return {
102102 init: init,
103 - message: function(name) {
104 - return locale[ name ];
 103+ message: function( name ) {
 104+ return mwMobileFrontendConfig.messages[name] || '';
105105 },
 106+ setting: function( name ) {
 107+ return mwMobileFrontendConfig.settings[name] || '';
 108+ },
106109 utils: utilities
107110 };
108111
Index: trunk/extensions/MobileFrontend/javascripts/opensearch.js
@@ -8,9 +8,7 @@
99 sb = document.getElementById( 'searchbox' ),
1010 u = MobileFrontend.utils;
1111
12 - if ( scriptPath ) {
13 - apiUrl = scriptPath + apiUrl;
14 - }
 12+ apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl;
1513
1614 function hideResults() {
1715 var results = document.getElementById( 'results' );
Index: trunk/extensions/MobileFrontend/templates/ApplicationTemplate.php
@@ -43,6 +43,16 @@
4444 $buttonHideText = Xml::escapeJsString( $this->data['hideText'] );
4545 $buttonShowText = Xml::escapeJsString( $this->data['showText'] );
4646
 47+ $jsconfig = array(
 48+ 'messages' => array(
 49+ 'expand-section' => $buttonShowText,
 50+ 'collapse-section' => $buttonHideText
 51+ ),
 52+ 'settings' => array(
 53+ 'scriptPath' => ( $this->data['wgScriptPath'] ),
 54+ ),
 55+ );
 56+ $configuration = FormatJSON::encode( $jsconfig );
4757
4858 $applicationHtml = <<<HTML
4959 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -57,15 +67,8 @@
5868 <meta name="viewport" content="initial-scale=1.0">
5969 {$appleTouchIconTag}
6070 {$jQueryScript}
61 - <script type='text/javascript'>
62 - //<![CDATA[
63 - var title = "{$this->data['htmlTitle']}";
64 - var scriptPath = "{$this->data['wgScriptPath']}";
65 - var locale = {
66 - "expand-section": "{$buttonShowText}",
67 - "collapse-section": "{$buttonHideText}"
68 - };
69 - //]]>
 71+ <script type="text/javascript">
 72+ var mwMobileFrontendConfig = {$configuration};
7073 </script>
7174 </head>
7275 <body>

Follow-up revisions

RevisionCommit summaryAuthorDate
r114201MFT r113486, r113488, r113512, r113553, r113640, r113642, r113644, r113645, r...awjrichards22:18, 19 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r113644add locale global for handling languages and message function...jdlrobson18:17, 12 March 2012

Status & tagging log