https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113942
Revision: 113942 Author: jdlrobson Date: 2012-03-15 18:05:40 +0000 (Thu, 15 Mar 2012) Log Message: ----------- first version of references reveal see design: http://www.mediawiki.org/wiki/Mobile_design/Reference_reveal this is only made available for the beta Modified Paths: -------------- trunk/extensions/MobileFrontend/Makefile trunk/extensions/MobileFrontend/stylesheets/beta_common.css trunk/extensions/MobileFrontend/templates/ApplicationTemplate.php Added Paths: ----------- trunk/extensions/MobileFrontend/javascripts/references.js Modified: trunk/extensions/MobileFrontend/Makefile =================================================================== --- trunk/extensions/MobileFrontend/Makefile 2012-03-15 17:52:32 UTC (rev 113941) +++ trunk/extensions/MobileFrontend/Makefile 2012-03-15 18:05:40 UTC (rev 113942) @@ -3,4 +3,5 @@ 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/toggle.js -o javascripts/toggle.min.js + java -jar yuicompressor-2.4.6.jar javascripts/references.js -o javascripts/references.min.js java -jar yuicompressor-2.4.6.jar javascripts/beta_opensearch.js -o javascripts/beta_opensearch.min.js Added: trunk/extensions/MobileFrontend/javascripts/references.js =================================================================== --- trunk/extensions/MobileFrontend/javascripts/references.js (rev 0) +++ trunk/extensions/MobileFrontend/javascripts/references.js 2012-03-15 18:05:40 UTC (rev 113942) @@ -0,0 +1,51 @@ +if( typeof jQuery !== 'undefined' ) { + MobileFrontend.references = (function($) { + function collect() { + var references = {}; + $( 'ol.references li' ).each(function(i, el) { + references[ $(el).attr( 'id' ) ] = { + html: $(el).html(), + label: i + 1 + }; + }); + return references; + } + + // TODO: only apply to places that need it + // http://www.quirksmode.org/blog/archives/2010/12/the_fifth_posit.html + // https://github.com/Modernizr/Modernizr/issues/167 + $( document ).scroll( function(ev) { + $( '#mf-references' ).css( { + bottom: -window.pageYOffset, + position: 'absolute' + } ); + } ); + + function init() { + $( '<div id="mf-references"><div></div></div>' ).hide().appendTo( document.body ); + var close = function( ev ) { + $( '#mf-references' ).slideUp(); + }; + $( '<button>close</button>' ).click( close ).appendTo( '#mf-references' ); + $( '.mw-cite-backlink a' ).click( close ); + + var data, html, href, references = collect(); + $( 'sup a' ).click( function(ev) { + href = $(this).attr( 'href' ); + data = href && href.charAt(0) === '#' ? + references[ href.substr( 1, href.length ) ] : null; + + if( data ) { + html = '<h3>[' + data.label + ']</h3>' + data.html; + } else { + html = $( '<a />' ).text( $(this).text() ). + attr( 'href', href ).appendTo('<div />').parent().html(); + } + $( '#mf-references div' ).html( html ); + $( '#mf-references' ).slideDown( 1000 ); + ev.preventDefault(); + }); + } + init(); + })(jQuery); +} \ No newline at end of file Modified: trunk/extensions/MobileFrontend/stylesheets/beta_common.css =================================================================== --- trunk/extensions/MobileFrontend/stylesheets/beta_common.css 2012-03-15 17:52:32 UTC (rev 113941) +++ trunk/extensions/MobileFrontend/stylesheets/beta_common.css 2012-03-15 18:05:40 UTC (rev 113942) @@ -843,3 +843,50 @@ .full-screen-search #nav { display: none !important; } + +#mf-references { + -webkit-transition: bottom 0.1s ease-in-out; + -moz-transition: bottom 0.1s ease-in-out; + -o-transition: bottom 0.1s ease-in-out; + transition: bottom 0.1s ease-in-out; + position: fixed; + bottom: 0; + left: 0; + right: 0; + background-color: #E4E4E4; + padding: 22px 34px; + -webkit-box-shadow: 0px -20px 10px -16px #aaa; + -moz-box-shadow: 0px -20px 10px -16px #aaa; + -o-box-shadow: 0px -20px 10px -16px #aaa; + box-shadow: 0px -20px 10px -16px #aaa; + word-break: break-word; + line-height: 1.4em; + font-size: 0.8em; +} + +#mf-references button { + top: 22px; + right: 16px; /* padding of mf-references - width 18 */ + width: 18px; + height: 12px; + background: url(images/close-button-beta.png) no-repeat scroll 0 0 transparent; + margin: 0; + background-position: right center; + background-size: auto 12px; + cursor: pointer; + position: absolute; + text-indent: -999px; + border: none; +} + +#mf-references h3 { + margin: 0; + padding-right: 4px; + line-height: 1em; + display: inline; +} + +#mf-references a:visited, +#mf-references a { + color: #3354C0; +} Modified: trunk/extensions/MobileFrontend/templates/ApplicationTemplate.php =================================================================== --- trunk/extensions/MobileFrontend/templates/ApplicationTemplate.php 2012-03-15 17:52:32 UTC (rev 113941) +++ trunk/extensions/MobileFrontend/templates/ApplicationTemplate.php 2012-03-15 18:05:40 UTC (rev 113942) @@ -34,7 +34,8 @@ $endScriptTag = '"></script>'; $javaScriptPath = $this->data['wgExtensionAssetsPath'] . '/MobileFrontend/javascripts/'; - $jQueryScript = ( $this->data['device']['supports_jquery'] ) ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : ''; + $jQuerySupport = $this->data['device']['supports_jquery']; + $jQueryScript = $jQuerySupport ? $startScriptTag . $javaScriptPath . 'jquery-1.7.1.min.js' . $endScriptTag : ''; $filePageScript = ( $this->data['isFilePage'] ) ? $startScriptTag . $javaScriptPath . 'filepage.js?version=122920111241' . $endScriptTag : ''; $startLinkTag = "<link href='{$this->data['wgExtensionAssetsPath']}/MobileFrontend/stylesheets/"; @@ -54,6 +55,13 @@ ); $configuration = FormatJSON::encode( $jsconfig ); + if( $this->data['isBetaGroupMember'] && $jQuerySupport ) { + $betajs = <<<HTML + {$startScriptTag}{$javaScriptPath}references.{$resourceSuffix}js?version=1331257310{$endScriptTag} +HTML; + } else { + $betajs = ""; + } $applicationHtml = <<<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> @@ -84,6 +92,7 @@ {$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} + {$betajs} {$filePageScript} <!--[endif]--> </body> _______________________________________________ MediaWiki-CVS mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
