https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114201
Revision: 114201
Author: awjrichards
Date: 2012-03-19 22:18:07 +0000 (Mon, 19 Mar 2012)
Log Message:
-----------
MFT r113486, r113488, r113512, r113553, r113640, r113642, r113644, r113645,
r113685, r113693, r113695, r113714, r113720, r113721, r113726, r113730,
r113769, r113770, r113771, r113778
Modified Paths:
--------------
branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile
branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
branches/wmf/1.19wmf1/extensions/MobileFrontend/api/ApiQueryExcerpts.php
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.min.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.min.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/fixtures.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js
Added Paths:
-----------
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.min.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js
Removed Paths:
-------------
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_application.js
Property Changed:
----------------
branches/wmf/1.19wmf1/extensions/MobileFrontend/
Property changes on: branches/wmf/1.19wmf1/extensions/MobileFrontend
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/extensions/MobileFrontend:99727,113463,113465-113466,113469-113472
+
/trunk/extensions/MobileFrontend:99727,113463,113465-113466,113469-113472,113486,113488,113512,113553,113640,113642,113644-113645,113685,113693,113695,113714,113720-113721,113726,113730,113769-113771,113778
Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile 2012-03-19
22:16:13 UTC (rev 114200)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/Makefile 2012-03-19
22:18:07 UTC (rev 114201)
@@ -2,5 +2,5 @@
java -jar yuicompressor-2.4.6.jar javascripts/application.js -o
javascripts/application.min.js
java -jar yuicompressor-2.4.6.jar javascripts/banner.js -o
javascripts/banner.min.js
java -jar yuicompressor-2.4.6.jar javascripts/opensearch.js -o
javascripts/opensearch.min.js
- java -jar yuicompressor-2.4.6.jar javascripts/beta_application.js -o
javascripts/beta_application.min.js
+ java -jar yuicompressor-2.4.6.jar javascripts/toggle.js -o
javascripts/toggle.min.js
java -jar yuicompressor-2.4.6.jar javascripts/beta_opensearch.js -o
javascripts/beta_opensearch.min.js
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
2012-03-19 22:16:13 UTC (rev 114200)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
2012-03-19 22:18:07 UTC (rev 114201)
@@ -1276,6 +1276,7 @@
$testModules['qunit']['ext.mobilefrontend.tests'] = array(
'scripts' => array( 'tests/js/fixtures.js',
'javascripts/application.js',
'javascripts/opensearch.js',
'javascripts/banner.js',
+ 'javascripts/toggle.js',
'tests/js/test_toggle.js',
'tests/js/test_application.js',
'tests/js/test_opensearch.js', 'tests/js/test_banner.js' ),
'dependencies' => array( ),
'localBasePath' => dirname( __FILE__ ),
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/api/ApiQueryExcerpts.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/api/ApiQueryExcerpts.php
2012-03-19 22:16:13 UTC (rev 114200)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/api/ApiQueryExcerpts.php
2012-03-19 22:18:07 UTC (rev 114201)
@@ -197,7 +197,7 @@
public function getExamples() {
return array(
-
'api.php?action=query&prop=excerpt&length=175&titles=Therion' => 'Get a
175-character excerpt',
+
'api.php?action=query&prop=excerpts&exlength=175&titles=Therion' => 'Get a
175-character excerpt',
);
}
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
2012-03-19 22:16:13 UTC (rev 114200)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -4,45 +4,9 @@
var utilities;
function init() {
- var i, results, languageSelection, a, heading, btns,
- sectionHeadings = utilities( '.section_heading' );
+ var languageSelection;
utilities( document.body ).addClass( 'jsEnabled' );
- // TODO: remove in future - currently enables toggling in
Wikipedia Mobile App v < 1.1
- window.wm_toggle_section = wm_toggle_section;
- var btns = utilities( '.section_heading button' );
- for( i = 0; i < btns.length; i++ ) {
- utilities( btns[i] ).remove();
- }
-
- function openSectionHandler() {
- var sectionNumber = this.id ? this.id.split( '_' )[1] :
-1;
- if( sectionNumber > -1 ) {
- wm_toggle_section( sectionNumber );
- }
- }
- function createButton( visible ) {
- var btn, label;
- btn = document.createElement( 'button' );
- label = document.createTextNode( visible ? showText :
hideText );
- btn.className = visible ? 'show' : 'hide';
- btn.appendChild( label );
- btn.style.display = visible ? 'inline-block' : 'none';
- return btn;
- }
- if(!sectionHeadings) {
- sectionHeadings = [];
- } else {
- utilities( document.body ).addClass( 'togglingEnabled'
);
- }
- for( i = 0; i < sectionHeadings.length; i++ ) {
- heading = sectionHeadings[i];
- heading.removeAttribute( 'onclick' ); // TODO: remove
any legacy onclick handlers
- heading.insertBefore( createButton( true ),
heading.firstChild );
- heading.insertBefore( createButton( false ),
heading.firstChild );
- utilities( heading ).bind( 'click', openSectionHandler
);
- }
- results = document.getElementById( 'results' );
languageSelection = document.getElementById(
'languageselection' );
function navigateToLanguageSelection() {
@@ -62,58 +26,24 @@
}
utilities( document.getElementById( 'logo' ) ).bind( 'click',
logoClick );
- function checkHash() {
- var hash = this.hash || document.location.hash;
- if ( hash.indexOf( '#' ) === 0 ) {
- wm_reveal_for_hash( hash );
- }
- }
- checkHash();
- for ( a = document.getElementsByTagName( 'a' ), i = 0; i <
a.length; i++ ) {
- utilities( a[i] ).bind( 'click', checkHash );
- }
-
// Try to scroll and hide URL bar
window.scrollTo( 0, 1 );
}
- function wm_reveal_for_hash( hash ) {
- var targetel = document.getElementById( hash.substr(1) ),
- p, section_idx;
- if ( targetel ) {
- p = targetel;
- while ( p && p.className !== 'content_block' &&
- p.className !== 'section_heading' ) {
- p = p.parentNode;
- }
- if ( p && p.style.display !== 'block' ) {
- section_idx = parseInt( p.id.split( '_' )[1],
10 );
- wm_toggle_section( section_idx );
- }
- }
- }
-
- function wm_toggle_section( section_id ) {
- var b = document.getElementById( 'section_' + section_id ),
- bb = b.getElementsByTagName( 'button' ), i, s, e;
- for ( i = 0; i <= 1; i++ ) {
- s = bb[i].style;
- s.display = s.display === 'none' || ( i && !s.display )
? 'inline-block' : 'none';
- }
- for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) {
- e = document.getElementById( d[i] + section_id );
- if ( e ) {
- e.style.display = e.style.display === 'block' ?
'none' : 'block';
- }
- }
- }
-
utilities = typeof jQuery !== 'undefined' ? jQuery : function( el ) {
if( typeof(el) === 'string' ) {
if( document.querySelectorAll ) {
return [].slice.call(
document.querySelectorAll( el ) );
}
+ } else if( !el ) {
+ el = document.createElement( 'div' );
}
+
+ function hasClass( name ) {
+ var classNames = el.className.split( ' ' );
+ return classNames.indexOf( name ) > -1;
+ }
+
function addClass( name ) {
var className = el.className,
classNames = className.split( ' ' );
@@ -144,6 +74,7 @@
return {
addClass: addClass,
bind: bind,
+ hasClass: hasClass,
remove: remove,
removeClass: removeClass
};
@@ -169,9 +100,13 @@
init();
return {
- wm_reveal_for_hash: wm_reveal_for_hash,
- wm_toggle_section: wm_toggle_section,
init: init,
+ message: function( name ) {
+ return mwMobileFrontendConfig.messages[name] || '';
+ },
+ setting: function( name ) {
+ return mwMobileFrontendConfig.settings[name] || '';
+ },
utils: utilities
};
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js
===================================================================
---
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js
2012-03-19 22:16:13 UTC (rev 114200)
+++
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.min.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -1 +1 @@
-MobileFrontend=(function(){var a;function c(){var
j,k,f,o,r,h,n=a(".section_heading");a(document.body).addClass("jsEnabled");window.wm_toggle_section=b;var
h=a(".section_heading
button");for(j=0;j<h.length;j++){a(h[j]).remove()}function m(){var
i=this.id?this.id.split("_")[1]:-1;if(i>-1){b(i)}}function p(t){var
s,i;s=document.createElement("button");i=document.createTextNode(t?showText:hideText);s.className=t?"show":"hide";s.appendChild(i);s.style.display=t?"inline-block":"none";return
s}if(!n){n=[]}else{a(document.body).addClass("togglingEnabled")}for(j=0;j<n.length;j++){r=n[j];r.removeAttribute("onclick");r.insertBefore(p(true),r.firstChild);r.insertBefore(p(false),r.firstChild);a(r).bind("click",m)}k=document.getElementById("results");f=document.getElementById("languageselection");function
g(){var
i;if(f){i=f.options[f.selectedIndex].value;if(i){location.href=i}}}a(f).bind("change",g);function
l(){var
i=document.getElementById("nav").style;i.display=i.display==="block"?"none":"block"}a(document.getElementById("logo")).bind("click",l);function
q(){var
i=this.hash||document.location.hash;if(i.indexOf("#")===0){e(i)}}q();for(o=document.getElementsByTagName("a"),j=0;j<o.length;j++){a(o[j]).bind("click",q)}window.scrollTo(0,1)}function
e(i){var
g=document.getElementById(i.substr(1)),h,f;if(g){h=g;while(h&&h.className!=="content_block"&&h.className!=="section_heading"){h=h.parentNode}if(h&&h.style.display!=="block"){f=parseInt(h.id.split("_")[1],10);b(f)}}}function
b(g){var
f=document.getElementById("section_"+g),l=f.getElementsByTagName("button"),h,j,k;for(h=0;h<=1;h++){j=l[h].style;j.display=j.display==="none"||(h&&!j.display)?"inline-block":"none"}for(h=0,d=["content_","anchor_"];h<=1;h++){k=document.getElementById(d[h]+g);if(k){k.style.display=k.style.display==="block"?"none":"block"}}}a=typeof
jQuery!=="undefined"?jQuery:function(g){if(typeof(g)==="string"){if(document.querySelectorAll){return[].slice.call(document.querySelectorAll(g))}}function
h(k){var l=g.className,m=l.split(" ");m.push(k);g.className=m.join("
")}function i(k){var m=g.className,n=m.split("
"),o=[],l;for(l=0;l<n.length;l++){if(n[l]!==k){o.push(n[l])}}g.className=o.join("
")}function j(l,k){g.addEventListener(l,k,false)}function
f(){g.parentNode.removeChild(g)}return{addClass:h,bind:j,remove:f,removeClass:i}};a.ajax=a.ajax||function(h){var
f,g;if(window.XMLHttpRequest){f=new XMLHttpRequest()}else{f=new
ActiveXObject("Microsoft.XMLHTTP")}if(f.overrideMimeType){f.overrideMimeType("text/xml")}f.onreadystatechange=function(){if(f.readyState===4&&f.status===200){h.success(f.responseXML)}};f.open("GET",h.url,true);f.send()};c();return{wm_reveal_for_hash:e,wm_toggle_section:b,init:c,utils:a}}());
\ No newline at end of file
+MobileFrontend=(function(){var a;function b(){var
e;a(document.body).addClass("jsEnabled");e=document.getElementById("languageselection");function
c(){var
f;if(e){f=e.options[e.selectedIndex].value;if(f){location.href=f}}}a(e).bind("change",c);function
d(){var
f=document.getElementById("nav").style;f.display=f.display==="block"?"none":"block"}a(document.getElementById("logo")).bind("click",d);window.scrollTo(0,1)}a=typeof
jQuery!=="undefined"?jQuery:function(e){if(typeof(e)==="string"){if(document.querySelectorAll){return[].slice.call(document.querySelectorAll(e))}}function
d(i){var j=e.className.split("");return j.indexOf(i)>-1}function f(i){var
j=e.className,k=j.split(" ");k.push(i);e.className=k.join(" ")}function
g(j){var l=e.className,m=l.split("
"),n=[],k;for(k=0;k<m.length;k++){if(m[k]!==j){n.push(m[k])}}e.className=n.join("
")}function h(j,i){e.addEventListener(j,i,false)}function
c(){e.parentNode.removeChild(e)}return{addClass:f,bind:h,hasClass:d,remove:c,removeClass:g}};a.ajax=a.ajax||function(e){var
c,d;if(window.XMLHttpRequest){c=new XMLHttpRequest()}else{c=new
ActiveXObject("Microsoft.XMLHTTP")}if(c.overrideMimeType){c.overrideMimeType("text/xml")}c.onreadystatechange=function(){if(c.readyState===4&&c.status===200){e.success(c.responseXML)}};c.open("GET",e.url,true);c.send()};b();return{init:b,message:function(c){return
mwMobileFrontendConfig.messages[c]||""},setting:function(c){return
mwMobileFrontendConfig.settings[c]||""},utils:a}}());
\ No newline at end of file
Deleted:
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_application.js
===================================================================
---
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_application.js
2012-03-19 22:16:13 UTC (rev 114200)
+++
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_application.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -1,183 +0,0 @@
-/*global document, window */
-/*jslint sloppy: true, white:true, maxerr: 50, indent: 4, plusplus: true*/
-/*
-TODO: getElementsByClassName not supported by IE < 9
-TODO: addEventListener not supported by IE < 9
-*/
-MobileFrontend = (function() {
- var utilities;
-
- function init() {
- var i, search, clearSearch, results, languageSelection, a,
heading, btns,
- sectionHeadings = utilities( '.section_heading' );
- utilities( document.body ).addClass( 'jsEnabled' );
-
- // TODO: remove in future - currently enables toggling in
Wikipedia Mobile App v < 1.1
- window.wm_toggle_section = wm_toggle_section;
- var btns = utilities( '.section_heading button' );
- for( i = 0; i < btns.length; i++ ) {
- utilities( btns[i] ).remove();
- }
-
- function openSectionHandler() {
- var sectionNumber = this.id ? this.id.split( '_' )[1] :
-1;
- if( sectionNumber > -1 ) {
- wm_toggle_section( sectionNumber );
- }
- }
- function createButton( visible ) {
- var btn, label;
- btn = document.createElement( 'button' );
- label = document.createTextNode( visible ? showText :
hideText );
- btn.className = visible ? 'show' : 'hide';
- btn.appendChild( label );
- btn.style.display = visible ? 'inline-block' : 'none';
- return btn;
- }
- if(!sectionHeadings) {
- sectionHeadings = [];
- } else {
- utilities( document.body ).addClass( 'togglingEnabled'
);
- }
- for( i = 0; i < sectionHeadings.length; i++ ) {
- heading = sectionHeadings[i];
- heading.removeAttribute( 'onclick' ); // TODO: remove
any legacy onclick handlers
- heading.insertBefore( createButton( true ),
heading.firstChild );
- heading.insertBefore( createButton( false ),
heading.firstChild );
- utilities( heading ).bind( 'click', openSectionHandler
);
- }
- results = document.getElementById( 'results' );
- languageSelection = document.getElementById(
'languageselection' );
-
- function navigateToLanguageSelection() {
- var url;
- if ( languageSelection ) {
- url =
languageSelection.options[languageSelection.selectedIndex].value;
- if ( url ) {
- location.href = url;
- }
- }
- }
- utilities( languageSelection ).bind( 'change',
navigateToLanguageSelection );
-
- function logoClick() {
- var n = document.getElementById( 'nav' ).style;
- n.display = n.display === 'block' ? 'none' : 'block';
- }
- utilities( document.getElementById( 'logo' ) ).bind( 'click',
logoClick );
-
- function checkHash() {
- var hash = this.hash || document.location.hash;
- if ( hash.indexOf( '#' ) === 0 ) {
- wm_reveal_for_hash( hash );
- }
- }
- checkHash();
- for ( a = document.getElementsByTagName( 'a' ), i = 0; i <
a.length; i++ ) {
- utilities( a[i] ).bind( 'click', checkHash );
- }
-
- // Try to scroll and hide URL bar
- window.scrollTo( 0, 1 );
- }
-
- function wm_reveal_for_hash( hash ) {
- var targetel = document.getElementById( hash.substr(1) ),
- p, section_idx;
- if ( targetel ) {
- p = targetel;
- while ( p && p.className !== 'content_block' &&
- p.className !== 'section_heading' ) {
- p = p.parentNode;
- }
- if ( p && p.style.display !== 'block' ) {
- section_idx = parseInt( p.id.split( '_' )[1],
10 );
- wm_toggle_section( section_idx );
- }
- }
- }
-
- function wm_toggle_section( section_id ) {
- var b = document.getElementById( 'section_' + section_id ),
- bb = b.getElementsByTagName( 'button' ), i, s, e;
- for ( i = 0; i <= 1; i++ ) {
- s = bb[i].style;
- s.display = s.display === 'none' || ( i && !s.display )
? 'inline-block' : 'none';
- }
- for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) {
- e = document.getElementById( d[i] + section_id );
- if ( e ) {
- e.style.display = e.style.display === 'block' ?
'none' : 'block';
- }
- }
- }
-
- utilities = typeof jQuery !== 'undefined' ? jQuery : function( el ) {
- if( typeof(el) === 'string' ) {
- if( document.querySelectorAll ) {
- return [].slice.call(
document.querySelectorAll( el ) );
- }
- }
-
- function addClass( name ) {
- var className = el.className,
- classNames = className.split( ' ' );
- classNames.push(name); // TODO: only push if unique
- el.className = classNames.join( ' ' );
- }
-
- function removeClass( name ) {
- var className = el.className,
- classNames = className.split( ' ' ),
- newClasses = [], i;
- for( i = 0; i < classNames.length; i++ ) {
- if( classNames[i] !== name ) {
- newClasses.push( classNames[i] );
- }
- }
- el.className = newClasses.join( ' ' );
- }
-
- function bind( type, handler ) {
- el.addEventListener( type, handler, false );
- }
-
- function remove() {
- el.parentNode.removeChild(el);
- }
-
- return {
- addClass: addClass,
- bind: bind,
- remove: remove,
- removeClass: removeClass
- };
- }
- utilities.ajax = utilities.ajax || function( options ) {
- var xmlHttp, url;
- if ( window.XMLHttpRequest ) {
- xmlHttp = new XMLHttpRequest();
- } else {
- xmlHttp = new ActiveXObject( 'Microsoft.XMLHTTP' );
- }
- if( xmlHttp.overrideMimeType ) { // non standard
- xmlHttp.overrideMimeType( 'text/xml' );
- }
- xmlHttp.onreadystatechange = function() {
- if ( xmlHttp.readyState === 4 && xmlHttp.status === 200
) {
- options.success( xmlHttp.responseXML );
- }
- };
- xmlHttp.open( 'GET', options.url, true );
- xmlHttp.send();
- };
-
- init();
- return {
- wm_reveal_for_hash: wm_reveal_for_hash,
- wm_toggle_section: wm_toggle_section,
- init: init,
- utils: utilities
- };
-
-}());
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js
===================================================================
---
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js
2012-03-19 22:16:13 UTC (rev 114200)
+++
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -12,9 +12,7 @@
focused = false,
u = MobileFrontend.utils;
- if ( scriptPath ) {
- apiUrl = scriptPath + apiUrl;
- }
+ apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl;
function hideResults() {
results.style.display = 'none';
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.min.js
===================================================================
---
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.min.js
2012-03-19 22:16:13 UTC (rev 114200)
+++
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/beta_opensearch.min.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -1 +1 @@
-MobileFrontend.opensearch=(function(){var
c="/api.php",p=-1,f=500,E=15,v,w=document.getElementById("results"),o=document.getElementById("search"),z=document.getElementById("sq"),a=document.getElementById("searchbox"),e=document.getElementById("logo"),g=document.getElementById("goButton"),y=document.getElementById("content"),s=document.getElementById("footer"),F=document.getElementById("zero-rated-banner")||document.getElementById("zero-rated-banner-red"),C=document.getElementById("clearsearch"),n=false,q={},r=MobileFrontend.utils;if(scriptPath){c=scriptPath+c}function
x(){w.style.display="none"}function
k(){if(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)){var
u=r('meta[name="viewport"]');if(u){u=u[0];u.content="width=device-width,
minimum-scale=1.0, maximum-scale=1.0,
initial-scale=1.0";r(document.body).bind("gesturestart",function(){u.content="width=device-width,
initial-scale=1.0"})}}}k();o.onfocus=function(){var
u,J,K,G,H,I;a=document.getElementById("searchbox");z=document.getElementById("sq");y=document.getElementById("content");s=document.getElementById("footer");k();if(!n){MobileFrontend.utils(document.body).addClass("full-screen-search");u=document.getElementById("placeholder");if(!u){J=document.createElement("span");K=document.createTextNode(placeholder);J.setAttribute("id","placeholder");J.appendChild(K);a.insertBefore(J,a.firstChild)}u=document.getElementById("placeholder");if(u){u.style.display="block"}if(u&&o.value!==""){u.style.display="none"}I=document.getElementById("remove-results");if(!I){G=document.createElement("a");G.setAttribute("href","#");G.setAttribute("id","remove-results");r(G).bind("click",D);H=document.createElement("div");H.setAttribute("id","left-arrow");G.appendChild(H);z.insertBefore(G,z.firstChild)}n=true}};function
D(){MobileFrontend.utils(document.body).removeClass("full-screen-search");var
G,u=document.getElementById("placeholder");if(u){u.style.display="none"}if(n){n=false}if(C){C.style.display="none"}}function
b(G){var
u;if(!G){G=window.event}if(G.target){u=G.target}else{if(G.srcElement){u=G.srcElement}}if(u.nodeType===3){u=u.parentNode}G.cancelBubble=true;G.stopPropagation();if(u.className==="suggestion-result"||u.className==="search-result-item"||u.className==="suggestions-result"||u.className==="sq-val-update"||u.id==="results"||u.id==="search"||u.id==="searchbox"||u.id==="sq"||u.id==="placeholder"||u.id==="clearsearch"||u.tagName==="BODY"){if(u.id==="clearsearch"&&w){w.innerHTML=""}}else{x()}}window.onload=function(){r(o).bind("keyup",function(){clearTimeout(p);v=this.value;if(v.length<1){w.innerHTML=""}else{v=encodeURIComponent(v);p=setTimeout(function(){m(v)},f)}})};function
m(u){url=c+"?action=opensearch&limit="+E+"&namespace=0&format=xml&search="+u;r.ajax({url:url,success:function(G){t(j(G))}})}function
j(J){var
K=[],G,H,I,u=J.getElementsByTagName("Item");for(G=0;G<u.length;G++){H=u[G];I={label:H.getElementsByTagName("Text")[0].textContent,value:H.getElementsByTagName("Url")[0].textContent};K.push(I)}return
K}function l(G){var u=document.getElementById("search");if(u){u.value=G+"
";u.focus();m(u.value)}}function h(H){var G=document.createTextNode(H);var
u=document.createElement("div");u.appendChild(G);return u.innerHTML}function
B(u){return u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function t(P){var
J=document.getElementById("results"),L,K,I=h(document.getElementById("search").value),H,O,G,u,M,N;J.style.display="block";if(o){o.focus()}if(!P||P.length<1){J.innerHTML='<div
class="suggestions-results" title="No Results">No
Results</div>'}else{if(J.firstChild){J.removeChild(J.firstChild)}L=document.createElement("div");L.className="suggestions-results";J.appendChild(L);H=function(){var
Q=this.parentNode.getAttribute("title");l(Q)};for(K=0;K<P.length;K++){O=P[K];u=document.createElement("div");M=document.createElement("a");u.setAttribute("title",O.label);u.className="suggestions-result";N=document.createTextNode("+");M.appendChild(N);M.className="sq-val-update";r(M).bind("click",H);u.appendChild(M);M=document.createElement("a");M.setAttribute("href",O.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));M.className="search-result-item";N=document.createTextNode(O.label);M.appendChild(N);u.appendChild(M);L.appendChild(u);G=B(I);M.innerHTML=M.innerHTML.replace(new
RegExp("("+G+")","ig"),"<strong>$1</strong>")}}}function d(){var
u=document.getElementById("placeholder");if(u){u.style.display="none"}}function
i(){var
K=document.getElementById("clearsearch"),G=document.getElementById("search"),u=document.getElementById("results");function
I(){if(K){if(G.value.length>0){K.style.display="block"}else{K.style.display="none"}}}function
H(L){G.value="";K.style.display="none";if(L){L.preventDefault()}}function
J(){G.select()}r(K).bind("mousedown",H);r(G).bind("keyup",I);r(G).bind("keydown",d);r(G).bind("click",J)}function
A(){var
u=document.getElementById("results");u.onmousedown=b;document.body.onmousedown=b;document.body.ontouchstart=b;u.ontouchstart=b;o.onpaste=d}A();i();return{init:A,initClearSearch:i,writeResults:t,createObjectArray:j,removeResults:D}}());
\ No newline at end of file
+MobileFrontend.opensearch=(function(){var
c="/api.php",m=-1,d=500,z=15,q,l=document.getElementById("search"),t=document.getElementById("sq"),a=document.getElementById("searchbox"),r=document.getElementById("content"),o=document.getElementById("footer"),x=document.getElementById("clearsearch"),k=false,n=MobileFrontend.utils;c=MobileFrontend.setting("scriptPath")+c;function
s(){results.style.display="none"}function
h(){if(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)){var
u=n('meta[name="viewport"]');if(u){u=u[0];u.content="width=device-width,
minimum-scale=1.0, maximum-scale=1.0,
initial-scale=1.0";n(document.body).bind("gesturestart",function(){u.content="width=device-width,
initial-scale=1.0"})}}}h();l.onfocus=function(){var
u,A;a=document.getElementById("searchbox");t=document.getElementById("sq");r=document.getElementById("content");o=document.getElementById("footer");h();if(!k){MobileFrontend.utils(document.body).addClass("full-screen-search");u=document.getElementById("remove-results");if(!u){u=document.createElement("a");u.setAttribute("href","#");u.setAttribute("id","remove-results");n(u).bind("click",y);A=document.createElement("div");A.setAttribute("id","left-arrow");u.appendChild(A);t.insertBefore(u,t.firstChild)}k=true}};function
y(){MobileFrontend.utils(document.body).removeClass("full-screen-search");if(k){k=false}if(x){x.style.display="none"}}function
b(A){var
u;if(!A){A=window.event}if(A.target){u=A.target}else{if(A.srcElement){u=A.srcElement}}if(u.nodeType===3){u=u.parentNode}A.cancelBubble=true;A.stopPropagation();if(u.className==="suggestion-result"||u.className==="search-result-item"||u.className==="suggestions-result"||u.className==="sq-val-update"||u.id==="results"||u.id==="search"||u.id==="searchbox"||u.id==="sq"||u.id==="placeholder"||u.id==="clearsearch"||u.tagName==="BODY"){if(u.id==="clearsearch"&&results){results.innerHTML=""}}else{s()}}window.onload=function(){n(l).bind("keyup",function(){clearTimeout(m);q=this.value;if(q.length<1){results.innerHTML=""}else{q=encodeURIComponent(q);m=setTimeout(function(){j(q)},d)}})};function
j(u){url=c+"?action=opensearch&limit="+z+"&namespace=0&format=xml&search="+u;n.ajax({url:url,success:function(A){p(g(A))}})}function
g(D){var
E=[],A,B,C,u=D.getElementsByTagName("Item");for(A=0;A<u.length;A++){B=u[A];C={label:B.getElementsByTagName("Text")[0].textContent,value:B.getElementsByTagName("Url")[0].textContent};E.push(C)}return
E}function i(A){var u=document.getElementById("search");if(u){u.value=A+"
";u.focus();j(u.value)}}function e(B){var
A=document.createTextNode(B),u=document.createElement("div");u.appendChild(A);return
u.innerHTML}function w(u){return
u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function p(J){var
D=document.getElementById("results"),F,E,C=e(document.getElementById("search").value),B,I,A,u,G,H;D.style.display="block";if(l){l.focus()}if(!J||J.length<1){D.innerHTML='<ul
class="suggestions-results" title="No Results"><li
class="suggestions-result">No
Results</li></div>'}else{if(D.firstChild){D.removeChild(D.firstChild)}F=document.createElement("ul");F.className="suggestions-results";D.appendChild(F);B=function(){var
K=this.parentNode.getAttribute("title");i(K)};for(E=0;E<J.length;E++){I=J[E];u=document.createElement("li");G=document.createElement("a");u.setAttribute("title",I.label);u.className="suggestions-result";H=document.createTextNode("+");G.appendChild(H);G.className="sq-val-update";n(G).bind("click",B);u.appendChild(G);G=document.createElement("a");G.setAttribute("href",I.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));G.className="search-result-item";H=document.createTextNode(I.label);G.appendChild(H);u.appendChild(G);F.appendChild(u);A=w(C);G.innerHTML=G.innerHTML.replace(new
RegExp("("+A+")","ig"),"<strong>$1</strong>")}}}function f(){var
D=document.getElementById("clearsearch"),u=document.getElementById("search");function
B(){if(D){if(u.value.length>0){D.style.display="block"}else{D.style.display="none"}}}function
A(E){u.value="";D.style.display="none";if(E){E.preventDefault()}}function
C(){u.select()}n(D).bind("mousedown",A);n(u).bind("keyup",B);n(u).bind("click",C)}function
v(){var
u=document.getElementById("results");u.onmousedown=b;document.body.onmousedown=b;document.body.ontouchstart=b;u.ontouchstart=b}v();f();return{init:v,initClearSearch:f,writeResults:p,createObjectArray:g,removeResults:y}}());
\ No newline at end of file
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.js
2012-03-19 22:16:13 UTC (rev 114200)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -8,9 +8,7 @@
sb = document.getElementById( 'searchbox' ),
u = MobileFrontend.utils;
- if ( scriptPath ) {
- apiUrl = scriptPath + apiUrl;
- }
+ apiUrl = MobileFrontend.setting( 'scriptPath' ) + apiUrl;
function hideResults() {
var results = document.getElementById( 'results' );
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.min.js
===================================================================
---
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.min.js
2012-03-19 22:16:13 UTC (rev 114200)
+++
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/opensearch.min.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -1 +1 @@
-MobileFrontend.opensearch=(function(){var
l="/api.php",c=-1,f=500,g=5,h=document.getElementById("results"),p=document.getElementById("search"),k=document.getElementById("searchbox"),m=MobileFrontend.utils;if(scriptPath){l=scriptPath+l}function
b(){var q=document.getElementById("results");q.style.display="none"}function
e(r){var
q;if(!r){r=window.event}if(r.target){q=r.target}else{if(r.srcElement){q=r.srcElement}}if(q.nodeType===3){q=q.parentNode}r.cancelBubble=true;r.stopPropagation();if(!(q.className==="suggestion-result"||q.className==="search-result-item"||q.className==="suggestions-result"||q.className==="sq-val-update")){b()}}window.onload=function(){m(p).bind("keyup",function(){clearTimeout(c);var
q=this.value;if(q.length<1){h.innerHTML=""}else{c=setTimeout(function(){o(q)},f)}})};function
o(q){q=encodeURIComponent(q);url=l+"?action=opensearch&limit="+g+"&namespace=0&format=xml&search="+q;m.ajax({url:url,success:function(r){j(i(r))}})}function
i(u){var
v=[],r,s,t,q=u.getElementsByTagName("Item");for(r=0;r<q.length;r++){s=q[r];t={label:s.getElementsByTagName("Text")[0].textContent,value:s.getElementsByTagName("Url")[0].textContent};v.push(t)}return
v}function d(r){var q=document.getElementById("search");if(q){q.value=r+"
";q.focus();o(q.value)}}function j(B){var
t=document.getElementById("results"),w,u,s,A,q,y,z,r=document.getElementById("sq"),v=document.getElementById("header");t.style.display="block";var
x=r.offsetParent.offsetTop+r.offsetHeight+r.offsetTop-1+v.offsetTop;t.style.top=x+"px";if(!B||B.length<1){t.innerHTML='<div
class="suggestions-results"><div class="suggestions-result">No
results</div></div>'}else{if(t.firstChild){t.removeChild(t.firstChild)}w=document.createElement("div");w.className="suggestions-results";t.appendChild(w);s=function(){var
C=this.parentNode.getAttribute("title");d(C)};for(u=0;u<B.length;u++){A=B[u];q=document.createElement("div");y=document.createElement("a");q.setAttribute("title",A.label);q.className="suggestions-result";z=document.createTextNode("+");y.appendChild(z);y.className="sq-val-update";m(y).bind("click",s);q.appendChild(y);y=document.createElement("a");y.setAttribute("href",A.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));y.className="search-result-item";z=document.createTextNode(A.label);y.appendChild(z);q.appendChild(y);w.appendChild(q)}}}function
a(){var
v=document.getElementById("clearsearch"),r=document.getElementById("search"),q=document.getElementById("results");function
t(){if(v){if(r.value.length>0){v.style.display="block"}else{v.style.display="none";if(q){q.style.display="none"}}}}function
s(w){r.value="";v.style.display="none";if(q){q.style.display="none"}if(w){w.preventDefault()}}function
u(){r.select()}m(v).bind("mousedown",s);m(r).bind("keyup",t);m(r).bind("click",u)}function
n(){var
q=document.getElementById("results");q.onmousedown=e;document.body.onmousedown=e;document.body.ontouchstart=e;q.ontouchstart=e}n();a();return{init:n,initClearSearch:a,writeResults:j,createObjectArray:i}}());
\ No newline at end of file
+MobileFrontend.opensearch=(function(){var
l="/api.php",c=-1,f=500,g=5,h=document.getElementById("results"),p=document.getElementById("search"),k=document.getElementById("searchbox"),m=MobileFrontend.utils;l=MobileFrontend.setting("scriptPath")+l;function
b(){var q=document.getElementById("results");q.style.display="none"}function
e(r){var
q;if(!r){r=window.event}if(r.target){q=r.target}else{if(r.srcElement){q=r.srcElement}}if(q.nodeType===3){q=q.parentNode}r.cancelBubble=true;r.stopPropagation();if(!(q.className==="suggestion-result"||q.className==="search-result-item"||q.className==="suggestions-result"||q.className==="sq-val-update")){b()}}window.onload=function(){m(p).bind("keyup",function(){clearTimeout(c);var
q=this.value;if(q.length<1){h.innerHTML=""}else{c=setTimeout(function(){o(q)},f)}})};function
o(q){q=encodeURIComponent(q);url=l+"?action=opensearch&limit="+g+"&namespace=0&format=xml&search="+q;m.ajax({url:url,success:function(r){j(i(r))}})}function
i(u){var
v=[],r,s,t,q=u.getElementsByTagName("Item");for(r=0;r<q.length;r++){s=q[r];t={label:s.getElementsByTagName("Text")[0].textContent,value:s.getElementsByTagName("Url")[0].textContent};v.push(t)}return
v}function d(r){var q=document.getElementById("search");if(q){q.value=r+"
";q.focus();o(q.value)}}function j(B){var
t=document.getElementById("results"),w,u,s,A,q,y,z,r=document.getElementById("sq"),v=document.getElementById("header");t.style.display="block";var
x=r.offsetParent.offsetTop+r.offsetHeight+r.offsetTop-1+v.offsetTop;t.style.top=x+"px";if(!B||B.length<1){t.innerHTML='<div
class="suggestions-results"><div class="suggestions-result">No
results</div></div>'}else{if(t.firstChild){t.removeChild(t.firstChild)}w=document.createElement("div");w.className="suggestions-results";t.appendChild(w);s=function(){var
C=this.parentNode.getAttribute("title");d(C)};for(u=0;u<B.length;u++){A=B[u];q=document.createElement("div");y=document.createElement("a");q.setAttribute("title",A.label);q.className="suggestions-result";z=document.createTextNode("+");y.appendChild(z);y.className="sq-val-update";m(y).bind("click",s);q.appendChild(y);y=document.createElement("a");y.setAttribute("href",A.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));y.className="search-result-item";z=document.createTextNode(A.label);y.appendChild(z);q.appendChild(y);w.appendChild(q)}}}function
a(){var
v=document.getElementById("clearsearch"),r=document.getElementById("search"),q=document.getElementById("results");function
t(){if(v){if(r.value.length>0){v.style.display="block"}else{v.style.display="none";if(q){q.style.display="none"}}}}function
s(w){r.value="";v.style.display="none";if(q){q.style.display="none"}if(w){w.preventDefault()}}function
u(){r.select()}m(v).bind("mousedown",s);m(r).bind("keyup",t);m(r).bind("click",u)}function
n(){var
q=document.getElementById("results");q.onmousedown=e;document.body.onmousedown=e;document.body.ontouchstart=e;q.ontouchstart=e}n();a();return{init:n,initClearSearch:a,writeResults:j,createObjectArray:i}}());
\ No newline at end of file
Copied: branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js
(from rev 113640, trunk/extensions/MobileFrontend/javascripts/toggle.js)
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js
(rev 0)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -0,0 +1,95 @@
+/*global document, window */
+/*jslint sloppy: true, white:true, maxerr: 50, indent: 4, plusplus: true*/
+MobileFrontend.toggle = (function() {
+ var u = MobileFrontend.utils;
+
+ function init() {
+ var i, a, heading, btns,
+ sectionHeadings = u( '.section_heading' );
+
+ // TODO: remove in future - currently enables toggling in
Wikipedia Mobile App v < 1.1
+ window.wm_toggle_section = wm_toggle_section;
+ btns = u( '.section_heading button' );
+ for( i = 0; i < btns.length; i++ ) {
+ u( btns[i] ).remove();
+ }
+
+ function openSectionHandler() {
+ var sectionNumber = this.id ? this.id.split( '_' )[1] :
-1;
+ if( sectionNumber > -1 ) {
+ wm_toggle_section( sectionNumber );
+ }
+ }
+ function createButton( visible ) {
+ var btn, label;
+ btn = document.createElement( 'button' );
+ label = document.createTextNode(
MobileFrontend.message( visible ? 'expand-section' : 'collapse-section' ) );
+ btn.className = visible ? 'show' : 'hide';
+ btn.appendChild( label );
+ return btn;
+ }
+ if(!sectionHeadings) {
+ sectionHeadings = [];
+ } else {
+ u( document.body ).addClass( 'togglingEnabled' );
+ }
+ for( i = 0; i < sectionHeadings.length; i++ ) {
+ heading = sectionHeadings[i];
+ heading.removeAttribute( 'onclick' ); // TODO: remove
any legacy onclick handlers
+ heading.insertBefore( createButton( true ),
heading.firstChild );
+ heading.insertBefore( createButton( false ),
heading.firstChild );
+ u( heading ).bind( 'click', openSectionHandler );
+ }
+
+ function checkHash() {
+ var hash = this.hash || document.location.hash;
+ if ( hash.indexOf( '#' ) === 0 ) {
+ wm_reveal_for_hash( hash );
+ }
+ }
+ checkHash();
+ for ( a = document.getElementsByTagName( 'a' ), i = 0; i <
a.length; i++ ) {
+ u( a[i] ).bind( 'click', checkHash );
+ }
+ }
+
+ function wm_reveal_for_hash( hash ) {
+ var targetel = document.getElementById( hash.substr(1) ),
+ p, section_idx;
+ if ( targetel ) {
+ p = targetel;
+ while ( p && !u(p).hasClass( 'content_block' ) &&
+ !u(p).hasClass( 'section_heading' ) ) {
+ p = p.parentNode;
+ }
+ if ( p && p.style.display !== 'block' ) {
+ section_idx = parseInt( p.id.split( '_' )[1],
10 );
+ wm_toggle_section( section_idx );
+ }
+ }
+ }
+
+ function wm_toggle_section( section_id ) {
+ var b = document.getElementById( 'section_' + section_id ),
+ bb = b.getElementsByTagName( 'button' ), i, s, e;
+ if( u(b).hasClass( 'openSection' ) ) {
+ u(b).removeClass( 'openSection' );
+ } else {
+ u(b).addClass( 'openSection' );
+ }
+ for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) {
+ e = document.getElementById( d[i] + section_id );
+ if ( e ) {
+ e.style.display = e.style.display === 'block' ?
'none' : 'block';
+ }
+ }
+ }
+
+ init();
+ return {
+ wm_reveal_for_hash: wm_reveal_for_hash,
+ wm_toggle_section: wm_toggle_section,
+ init: init
+ };
+
+})();
Copied:
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.min.js (from
rev 113714, trunk/extensions/MobileFrontend/javascripts/toggle.min.js)
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.min.js
(rev 0)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/toggle.min.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -0,0 +1 @@
+MobileFrontend.toggle=(function(){var a=MobileFrontend.utils;function c(){var
l,f,n,m,h=a(".section_heading");window.wm_toggle_section=b;m=a(".section_heading
button");for(l=0;l<m.length;l++){a(m[l]).remove()}function k(){var
i=this.id?this.id.split("_")[1]:-1;if(i>-1){b(i)}}function g(p){var
o,i;o=document.createElement("button");i=document.createTextNode(MobileFrontend.message(p?"expand-section":"collapse-section"));o.className=p?"show":"hide";o.appendChild(i);return
o}if(!h){h=[]}else{a(document.body).addClass("togglingEnabled")}for(l=0;l<h.length;l++){n=h[l];n.removeAttribute("onclick");n.insertBefore(g(true),n.firstChild);n.insertBefore(g(false),n.firstChild);a(n).bind("click",k)}function
j(){var
i=this.hash||document.location.hash;if(i.indexOf("#")===0){e(i)}}j();for(f=document.getElementsByTagName("a"),l=0;l<f.length;l++){a(f[l]).bind("click",j)}}function
e(i){var
g=document.getElementById(i.substr(1)),h,f;if(g){h=g;while(h&&!a(h).hasClass("content_block")&&!a(h).hasClass("section_heading")){h=h.parentNode}if(h&&h.style.display!=="block"){f=parseInt(h.id.split("_")[1],10);b(f)}}}function
b(g){var
f=document.getElementById("section_"+g),l=f.getElementsByTagName("button"),h,j,k;if(a(f).hasClass("openSection")){a(f).removeClass("openSection")}else{a(f).addClass("openSection")}for(h=0,d=["content_","anchor_"];h<=1;h++){k=document.getElementById(d[h]+g);if(k){k.style.display=k.style.display==="block"?"none":"block"}}}c();return{wm_reveal_for_hash:e,wm_toggle_section:b,init:c}})();
\ No newline at end of file
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
2012-03-19 22:16:13 UTC (rev 114200)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/beta_common.css
2012-03-19 22:18:07 UTC (rev 114201)
@@ -318,17 +318,23 @@
margin: 0px;
}
-button.show {
+button.show,
+button.hide { /* for non-js browsers */
display: none;
}
+.togglingEnabled button.hide,
+.togglingEnabled .openSection button.show {
+ display: none;
+}
+
+.togglingEnabled .openSection button.hide,
.togglingEnabled button.show {
display: inline-block;
}
.togglingEnabled .content_block,
-.togglingEnabled .section_anchors,
-button.section_heading.hide {
+.togglingEnabled .section_anchors {
display: none;
}
@@ -498,6 +504,7 @@
-moz-border-radius: 5px;
background: #f9f9f9;
margin-bottom: 10px;
+ text-align: center;
}
.thumb .thumbinner[style] {
@@ -590,7 +597,7 @@
height: 25px;
width: 27px;
padding-bottom: 0;
- text-indent: 999px;
+ text-indent: -999px;
}
html[dir="rtl"] .goButton {
Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css
2012-03-19 22:16:13 UTC (rev 114200)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/stylesheets/common.css
2012-03-19 22:18:07 UTC (rev 114201)
@@ -332,17 +332,23 @@
margin: 0px;
}
-button.show {
+button.show,
+button.hide { /* for non-js browsers */
display: none;
}
+.togglingEnabled button.hide,
+.togglingEnabled .openSection button.show {
+ display: none;
+}
+
+.togglingEnabled .openSection button.hide,
.togglingEnabled button.show {
display: inline-block;
}
.togglingEnabled .content_block,
-.togglingEnabled .section_anchors,
-button.section_heading.hide {
+.togglingEnabled .section_anchors {
display: none;
}
@@ -526,6 +532,7 @@
-moz-border-radius: 5px;
background: #f9f9f9;
margin-bottom: 10px;
+ text-align: center;
}
.thumb .thumbinner[style] {
@@ -625,7 +632,7 @@
height: 25px;
width: 27px;
padding-bottom: 0;
- text-indent: 999px;
+ text-indent: -999px;
}
html[dir="rtl"] .goButton {
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
===================================================================
---
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
2012-03-19 22:16:13 UTC (rev 114200)
+++
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
2012-03-19 22:18:07 UTC (rev 114201)
@@ -40,9 +40,19 @@
$startLinkTag = "<link
href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/";
$endLinkTag = "' media='all' rel='Stylesheet' type='text/css'
/>";
$filePageStyle = ( $this->data['isFilePage'] ) ? $startLinkTag
. 'filepage.css' . $endLinkTag : '';
- $buttonHideText = htmlentities( $this->data['hideText'],
ENT_QUOTES );
- $buttonShowText = htmlentities( $this->data['showText'],
ENT_QUOTES );
+ $buttonHideText = Xml::escapeJsString( $this->data['hideText']
);
+ $buttonShowText = Xml::escapeJsString( $this->data['showText']
);
+ $jsconfig = array(
+ 'messages' => array(
+ 'expand-section' => $buttonShowText,
+ 'collapse-section' => $buttonHideText
+ ),
+ 'settings' => array(
+ 'scriptPath' => ( $this->data['wgScriptPath'] ),
+ ),
+ );
+ $configuration = FormatJSON::encode( $jsconfig );
$applicationHtml = <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -51,19 +61,14 @@
<head>
<title>{$this->data['htmlTitle']}</title>
<meta http-equiv="content-type"
content="application/xhtml+xml; charset=utf-8" />
- <link
href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$betaPrefix}common.css?version=1331257310'
media='all' rel='Stylesheet' type='text/css' />
- <link
href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$cssFileName}.css?version=1331257310'
media='all' rel='Stylesheet' type='text/css' />
+ <link
href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$betaPrefix}common.css?version=1331678715'
media='all' rel='Stylesheet' type='text/css' />
+ <link
href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/{$cssFileName}.css?version=1331678715'
media='all' rel='Stylesheet' type='text/css' />
{$filePageStyle}
- <meta name="viewport" content="max-width=device-width,
initial-scale=1.0">
+ <meta name="viewport" content="initial-scale=1.0">
{$appleTouchIconTag}
{$jQueryScript}
- <script type='text/javascript'>
- //<![CDATA[
- var title = "{$this->data['htmlTitle']}";
- var scriptPath =
"{$this->data['wgScriptPath']}";
- var showText = "{$buttonShowText}";
- var hideText = "{$buttonHideText}";
- //]]>
+ <script type="text/javascript">
+ var mwMobileFrontendConfig = {$configuration};
</script>
</head>
<body>
@@ -75,7 +80,8 @@
</div>
{$this->data['footerHtml']}
<!--[if gt IE 9]><!-->
-
{$startScriptTag}{$javaScriptPath}{$betaPrefix}application.{$resourceSuffix}js?version=1331257310{$endScriptTag}
+
{$startScriptTag}{$javaScriptPath}application.{$resourceSuffix}js?version=1331257310{$endScriptTag}
+
{$startScriptTag}{$javaScriptPath}toggle.{$resourceSuffix}js?version=1331257310{$endScriptTag}
{$startScriptTag}{$javaScriptPath}banner.{$resourceSuffix}js?version=1331257310{$endScriptTag}
{$startScriptTag}{$javaScriptPath}{$betaPrefix}opensearch.{$resourceSuffix}js?version=1331250599{$endScriptTag}
{$filePageScript}
Modified: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/fixtures.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/fixtures.js
2012-03-19 22:16:13 UTC (rev 114200)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/fixtures.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -1,4 +1,12 @@
-var showText = "show", hideText = "hide";
+var mwMobileFrontendConfig = {
+ messages: {
+ showText: "show",
+ hideText: "hide"
+ },
+ settings: {
+ scriptPath: "/"
+ }
+};
window.MobileFrontendTests = {
cleanFixtures: function() {
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js
===================================================================
---
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js
2012-03-19 22:16:13 UTC (rev 114200)
+++
branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_application.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -57,61 +57,3 @@
strictEqual(visible3, false, "toggle");
});
-module("MobileFrontend application.js: wm_toggle_section", {
- setup: function() {
- MFET.createFixtures();
- MFE.init();
- $("#content_1,#anchor_1,#section_1 .hide").hide();
- $("#section_1 .show").show();
- },
- teardown: function() {
- MFET.cleanFixtures();
- window.location.hash = "#";
- }
-});
-
-test("wm_toggle_section", function() {
- MFE.wm_toggle_section("1");
- strictEqual($("#content_1").is(":visible"), true, "check content is
visible on a toggle");
- strictEqual($("#anchor_1").is(":visible"), true, "check anchor is
visible on toggle");
- strictEqual($("#section_1 .hide").is(":visible"), true, "check hide
button now visible");
- strictEqual($("#section_1 .show").is(":visible"), false, "check show
button now hidden");
-
- // perform second toggle
- MFE.wm_toggle_section("1");
- strictEqual($("#content_1").is(":visible"), false, "check content is
hidden on a toggle");
- strictEqual($("#anchor_1").is(":visible"), false, "check anchor is
hidden on toggle");
- strictEqual($("#section_1 .hide").is(":visible"), false, "check hide
button now hidden");
- strictEqual($("#section_1 .show").is(":visible"), true, "check show
button now visible");
-});
-
-test("wm_reveal_for_hash", function() {
- MFE.wm_reveal_for_hash("#First_Section");
- strictEqual($("#content_1").is(":visible"), true, "check content is
visible on a toggle");
- strictEqual($("#anchor_1").is(":visible"), true, "check anchor is
visible on toggle");
- strictEqual($("#section_1 .hide").is(":visible"), true, "check hide
button now visible");
- strictEqual($("#section_1 .show").is(":visible"), false, "check show
button now hidden");
-});
-
-test("wm_reveal_for_hash", function() {
- MFE.wm_reveal_for_hash("#First_Section_2");
- strictEqual($("#content_1").is(":visible"), true, "check content is
visible on a toggle");
- strictEqual($("#anchor_1").is(":visible"), true, "check anchor is
visible on toggle");
- strictEqual($("#section_1 .hide").is(":visible"), true, "check hide
button now visible");
- strictEqual($("#section_1 .show").is(":visible"), false, "check show
button now hidden");
-});
-
-test("clicking hash links", function() {
- MFET.triggerEvent($("[href=#First_Section_2]")[0], "click");
- strictEqual($("#content_1").is(":visible"), true, "check content is
visible on a toggle");
- strictEqual($("#anchor_1").is(":visible"), true, "check anchor is
visible on toggle");
- strictEqual($("#section_1 .hide").is(":visible"), true, "check hide
button now visible");
- strictEqual($("#section_1 .show").is(":visible"), false, "check show
button now hidden");
-});
-
-test("clicking a heading toggles it", function() {
- var visibilityStart = $("#content_1").is(":visible");
- MFET.triggerEvent($("#section_1")[0], "click");
- strictEqual(visibilityStart, false, "check content is hidden at start");
- strictEqual($("#content_1").is(":visible"), true, "check content is
hidden on a toggle");
-});
Copied: branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js
(from rev 113640, trunk/extensions/MobileFrontend/tests/js/test_toggle.js)
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js
(rev 0)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/tests/js/test_toggle.js
2012-03-19 22:18:07 UTC (rev 114201)
@@ -0,0 +1,73 @@
+function applyCss() {
+ $(".hide").show();
+ $(".show").hide();
+ $(".openSection .hide").hide();
+ $(".openSection .show").show();
+}
+
+module("MobileFrontend toggle.js: wm_toggle_section", {
+ setup: function() {
+ MFET.createFixtures();
+ MFE.toggle.init();
+ $("#section_1").addClass("openSection");
+ $("#content_1,#anchor_1,#section_1 .hide").hide();
+ },
+ teardown: function() {
+ MFET.cleanFixtures();
+ window.location.hash = "#";
+ }
+});
+
+test("wm_toggle_section", function() {
+ strictEqual($("#section_1").hasClass("openSection"), true, "openSection
class present");
+ MFE.toggle.wm_toggle_section("1");
+ applyCss();
+ strictEqual($("#content_1").is(":visible"), true, "check content is
visible on a toggle");
+ strictEqual($("#anchor_1").is(":visible"), true, "check anchor is
visible on toggle");
+ strictEqual($("#section_1").hasClass("openSection"), false,
"openSection class removed");
+ strictEqual($("#section_1 .hide").is(":visible"), true, "check hide
button now visible");
+ strictEqual($("#section_1 .show").is(":visible"), false, "check show
button now hidden");
+
+ // perform second toggle
+ MFE.toggle.wm_toggle_section("1");
+ applyCss();
+ strictEqual($("#content_1").is(":visible"), false, "check content is
hidden on a toggle");
+ strictEqual($("#anchor_1").is(":visible"), false, "check anchor is
hidden on toggle");
+ strictEqual($("#section_1 .hide").is(":visible"), false, "check hide
button now hidden");
+ strictEqual($("#section_1 .show").is(":visible"), true, "check show
button now visible");
+});
+
+test("wm_reveal_for_hash", function() {
+ MFE.toggle.wm_reveal_for_hash("#First_Section");
+ applyCss();
+ strictEqual($("#content_1").is(":visible"), true, "check content is
visible on a toggle");
+ strictEqual($("#anchor_1").is(":visible"), true, "check anchor is
visible on toggle");
+ strictEqual($("#section_1 .hide").is(":visible"), true, "check hide
button now visible");
+ strictEqual($("#section_1 .show").is(":visible"), false, "check show
button now hidden");
+});
+
+test("wm_reveal_for_hash", function() {
+ MFE.toggle.wm_reveal_for_hash("#First_Section_2");
+ applyCss();
+ strictEqual($("#content_1").is(":visible"), true, "check content is
visible on a toggle");
+ strictEqual($("#anchor_1").is(":visible"), true, "check anchor is
visible on toggle");
+ strictEqual($("#section_1 .hide").is(":visible"), true, "check hide
button now visible");
+ strictEqual($("#section_1 .show").is(":visible"), false, "check show
button now hidden");
+});
+
+test("clicking hash links", function() {
+ MFET.triggerEvent($("[href=#First_Section_2]")[0], "click");
+ applyCss();
+ strictEqual($("#content_1").is(":visible"), true, "check content is
visible on a toggle");
+ strictEqual($("#anchor_1").is(":visible"), true, "check anchor is
visible on toggle");
+ strictEqual($("#section_1 .hide").is(":visible"), true, "check hide
button now visible");
+ strictEqual($("#section_1 .show").is(":visible"), false, "check show
button now hidden");
+});
+
+test("clicking a heading toggles it", function() {
+ var visibilityStart = $("#content_1").is(":visible");
+ MFET.triggerEvent($("#section_1")[0], "click");
+ applyCss();
+ strictEqual(visibilityStart, false, "check content is hidden at start");
+ strictEqual($("#content_1").is(":visible"), true, "check content is
hidden on a toggle");
+});
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs