r89315 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89314‎ | r89315 | r89316 >
Date:01:47, 2 June 2011
Author:dale
Status:deferred (Comments)
Tags:
Comment:
fixes bug 29185 Adds a separate module "jquery.loadingSpinner" that has a sprite based png alpha loading animation ( that looks good in on any background )
*Needs help* on the spinner graphic "loadingDots.png" that does not look like crap and not made in gimp in a min.
Modified paths:
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/MwEmbedSupport.php (modified) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner (added) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/jquery.loadingSpinner.js (added) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingDots.png (added) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpinner.css (added) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpokes.gif (added) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery/jquery.mwEmbedUtil.js (modified) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/skins/common/MwEmbedCommonStyle.css (modified) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedSupport.hooks.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/EmbedPlayer.loader.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/tests/Player_Sources.html (modified) (history)

Diff [purge]

Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/tests/Player_Sources.html
@@ -2,8 +2,7 @@
33 <html xmlns="http://www.w3.org/1999/xhtml">
44 <head>
55 <title>Player sources</title>
6 -
7 -<script type="text/javascript" src="../../../mwEmbedLoader.php"></script>
 6+ <script type="text/javascript" src="../../../mwEmbedLoader.php"></script>
87 </head>
98 <body>
109
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/EmbedPlayer.loader.js
@@ -76,8 +76,7 @@
7777 $( playerElement )
7878 .getAbsoluteOverlaySpinner()
7979 .attr('id', 'loadingSpinner_' + $( playerElement ).attr('id') )
80 - .addClass( 'playerLoadingSpinner' );
81 -
 80+
8281 // Add core "skin/interface" loader
8382 var skinString = $( playerElement ).attr( 'class' );
8483 if( ! skinString
Index: trunk/extensions/MwEmbedSupport/MwEmbedSupport.hooks.php
@@ -43,7 +43,7 @@
4444
4545 // Add MwEmbedSupport modules to Startup:
4646 static function addStartupModules( &$modules ){
47 - array_push($modules, 'jquery.triggerQueueCallback', 'jquery.mwEmbedUtil', 'mw.MwEmbedSupport' );
 47+ array_push($modules, 'jquery.triggerQueueCallback', 'jquery.loadingSpinner', 'jquery.mwEmbedUtil', 'mw.MwEmbedSupport' );
4848 return true;
4949 }
5050 }
\ No newline at end of file
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery/jquery.mwEmbedUtil.js
@@ -19,46 +19,7 @@
2020 });
2121 }
2222 };
23 -
24 - /**
25 - * Set a given selector html to the loading spinner:
26 - */
27 - $.fn.loadingSpinner = function( ) {
28 - if ( this ) {
29 - $( this ).html(
30 - $( '<div />' )
31 - .addClass( "loadingSpinner" )
32 - );
33 - }
34 - return this;
35 - };
36 - /**
37 - * Add an absolute overlay spinner useful for cases where the
38 - * element does not display child elements, ( images, video )
39 - */
40 - $.fn.getAbsoluteOverlaySpinner = function(){
41 - var pos = $( this ).offset();
42 - var posLeft = ( $( this ).width() ) ?
43 - parseInt( pos.left + ( .5 * $( this ).width() ) -16 ) :
44 - pos.left + 30;
4523
46 - var posTop = ( $( this ).height() ) ?
47 - parseInt( pos.top + ( .5 * $( this ).height() ) -16 ) :
48 - pos.top + 30;
49 -
50 - var $spinner = $('<div />')
51 - .loadingSpinner()
52 - .css({
53 - 'width' : 32,
54 - 'height' : 32,
55 - 'position': 'absolute',
56 - 'top' : posTop + 'px',
57 - 'left' : posLeft + 'px'
58 - });
59 - $('body').append( $spinner );
60 - return $spinner;
61 - };
62 -
6324
6425 /**
6526 * Shortcut to a themed button Should be depreciated for $.button
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/MwEmbedSupport.php
@@ -9,12 +9,21 @@
1010 'dependencies' => array(
1111 // jQuery dependencies:
1212 'jquery.triggerQueueCallback',
 13+ 'jquery.loadingSpinner',
1314 'jquery.mwEmbedUtil',
1415 ),
1516 'messageFile' => 'MwEmbedSupport.i18n.php',
1617 ),
 18+ "jquery.loadingSpinner" => array(
 19+ 'scripts' => 'jquery.loadingSpinner/jquery.loadingSpinner.js',
 20+ 'styles' => 'jquery.loadingSpinner/loadingSpinner.css'
 21+ ),
1722 'mw.MwEmbedSupport.style' => array(
18 - 'styles'=>'skins/common/MwEmbedCommonStyle.css',
 23+ // NOTE we add the loadingSpinner.css as a work around to the resource loader register
 24+ // of modules as "ready" even though only the "script" part of the module was included.
 25+ 'styles'=> array( 'skins/common/MwEmbedCommonStyle.css',
 26+ 'jquery.loadingSpinner/loadingSpinner.css'
 27+ ),
1928 'skinStyles' => array(
2029 /* shared jQuery ui skin styles */
2130 'darkness' => 'skins/jquery.ui.themes/darkness/jquery-ui-1.7.2.css',
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/skins/common/MwEmbedCommonStyle.css
@@ -14,49 +14,6 @@
1515 color:white;
1616 }
1717
18 -.loadingSpinner {
19 - width:32px;
20 - height:32px;
21 - display:block;
22 - padding:0px;
23 - /* @embed */
24 - background-image: url(images/loading_ani.gif);
25 - margin: auto;
26 -}
27 -.cssLoadingSpinner {
28 - position:relative;
29 - width:100px;
30 - height:100px;
31 - //margin:25px;
32 - -moz-border-radius:100px;
33 - float:left;
34 - -moz-transform:scale(0.3);
35 - -webkit-transform:scale(0.3);
36 -
37 - /* not used right now: */
38 - -webkit-animation-name: rotateThis;
39 - -webkit-animation-duration:2s;
40 - -webkit-animation-iteration-count:infinite;
41 - -webkit-animation-timing-function:linear;
42 -}
43 -.cssLoadingSpinner div {
44 - width:15px;
45 - height:30px;
46 - position:absolute;
47 - top:35px;
48 - left:45px;
49 -}
50 -.cssLoadingSpinner div {
51 - -moz-border-radius:30px;
52 - -webkit-border-radius:30px;
53 - border-radius:30px;
54 -}
55 -/* uncomment this to use css animation in webkit browsers */
56 - @-webkit-keyframes rotateThis {
57 - from {-webkit-transform:scale(0.7) rotate(0deg);}
58 - to {-webkit-transform:scale(0.7) rotate(360deg);}
59 -}
60 -
6118 /* jquery.ui overrides */
6219
6320 .ui-icon_link {
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpinner.css
@@ -0,0 +1,9 @@
 2+.loadingSpinner {
 3+ background-image: url('loadingDots.png');
 4+ width: 32px;
 5+ height: 32px;
 6+}
 7+.absoluteOverlaySpinner {
 8+ position : absolute;
 9+ z-index: 3;
 10+}
\ No newline at end of file
Property changes on: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpinner.css
___________________________________________________________________
Added: svn:mime-type
111 + text/plain
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/jquery.loadingSpinner.js
@@ -0,0 +1,51 @@
 2+( function( $ ) {
 3+ /**
 4+ * Set a given selector html to the loading spinner:
 5+ */
 6+ $.fn.loadingSpinner = function( ) {
 7+ var _this = this;
 8+ if ( _this ) {
 9+ $( _this ).html(
 10+ $( '<div />' )
 11+ .addClass( "loadingSpinner" )
 12+ );
 13+ var i =0;
 14+ var interval = setInterval( function(){
 15+ if( _this && $( _this ).find('.loadingSpinner').length ){
 16+ var offset = i*32;
 17+ $( _this ).find('.loadingSpinner').css('background-position','0 ' + offset + 'px');
 18+ if(i >= 7) i = 0;
 19+ i++;
 20+ } else {
 21+ clearInterval( interval );
 22+ }
 23+ }, 70 );
 24+ }
 25+ return _this;
 26+ };
 27+ /**
 28+ * Add an absolute overlay spinner useful for cases where the
 29+ * element does not display child elements, ( images, video )
 30+ */
 31+ $.fn.getAbsoluteOverlaySpinner = function(){
 32+ var pos = $( this ).offset();
 33+ var posLeft = ( $( this ).width() ) ?
 34+ parseInt( pos.left + ( .5 * $( this ).width() ) -16 ) :
 35+ pos.left + 30;
 36+
 37+ var posTop = ( $( this ).height() ) ?
 38+ parseInt( pos.top + ( .5 * $( this ).height() ) -16 ) :
 39+ pos.top + 30;
 40+
 41+ var $spinner = $('<div />')
 42+ .addClass('absoluteOverlaySpinner')
 43+ .loadingSpinner()
 44+ .css({
 45+ 'top' : posTop + 'px',
 46+ 'left' : posLeft + 'px'
 47+ });
 48+ $('body').append( $spinner );
 49+ return $spinner;
 50+ };
 51+
 52+} )( jQuery );
\ No newline at end of file
Property changes on: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/jquery.loadingSpinner.js
___________________________________________________________________
Added: svn:mime-type
153 + text/plain
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpokes.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpokes.gif
___________________________________________________________________
Added: svn:mime-type
254 + application/octet-stream
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingDots.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingDots.png
___________________________________________________________________
Added: svn:mime-type
355 + application/octet-stream

Follow-up revisions

RevisionCommit summaryAuthorDate
r90081bug 29185 follow up to r89315#c17554 don't display the loader for firefox vi...dale20:36, 14 June 2011

Comments

#Comment by Bawolff (talk | contribs)   01:50, 2 June 2011

I nominate Throbber allbackgrounds stroopwafel.gif as a "spinner graphic "loadingDots.png" that does not look like crap and not made in gimp in a min"

On a serious note, I once stumbled upon commons:User:Splarka/Throbber which might be able to help you.

#Comment by Mdale (talk | contribs)   01:54, 2 June 2011

thanks, keep in mind it needs to be a png with alpha layers ( not an animated gif ) so that it looks good on many backgrounds.

#Comment by Brion VIBBER (talk | contribs)   19:21, 3 June 2011

I like the animated sprite trick!

I do however see two spinners overlapping on Firefox 4... it may be that one is a native spinner for loading up the video thumb, and the other is ours? On Chrome I only see one.

Brief screencast showing loading in FF 4:

#Comment by Mdale (talk | contribs)   20:36, 14 June 2011

so I have turned off the loader for firefox since it has its own native loader ( in r90081 )

Status & tagging log