r51445 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51444‎ | r51445 | r51446 >
Date:01:54, 4 June 2009
Author:dale
Status:deferred
Tags:
Comment:
some ie6 fixes
Modified paths:
  • /branches/new-upload/phase3/js2/mwEmbed/jquery/plugins/jquery.pngFix.js (added) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_baseEmbed.js (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/mv_embed.js (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/skins/mvpcf/styles.css (modified) (history)

Diff [purge]

Index: branches/new-upload/phase3/js2/mwEmbed/jquery/plugins/jquery.pngFix.js
@@ -0,0 +1,113 @@
 2+/**
 3+ * --------------------------------------------------------------------
 4+ * jQuery-Plugin "pngFix"
 5+ * Version: 1.2, 09.03.2009
 6+ * by Andreas Eberhard, andreas.eberhard@gmail.com
 7+ * http://jquery.andreaseberhard.de/
 8+ *
 9+ * Copyright (c) 2007 Andreas Eberhard
 10+ * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 11+ *
 12+ * Changelog:
 13+ * 09.03.2009 Version 1.2
 14+ * - Update for jQuery 1.3.x, removed @ from selectors
 15+ * 11.09.2007 Version 1.1
 16+ * - removed noConflict
 17+ * - added png-support for input type=image
 18+ * - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 19+ * 31.05.2007 initial Version 1.0
 20+ * --------------------------------------------------------------------
 21+ * @example $(function(){$(document).pngFix();});
 22+ * @desc Fixes all PNG's in the document on document.ready
 23+ *
 24+ * jQuery(function(){jQuery(document).pngFix();});
 25+ * @desc Fixes all PNG's in the document on document.ready when using noConflict
 26+ *
 27+ * @example $(function(){$('div.examples').pngFix();});
 28+ * @desc Fixes all PNG's within div with class examples
 29+ *
 30+ * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 31+ * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 32+ * --------------------------------------------------------------------
 33+ */
 34+
 35+(function($) {
 36+
 37+jQuery.fn.pngFix = function(settings) {
 38+
 39+ // Settings
 40+ settings = jQuery.extend({
 41+ blankgif: 'blank.gif'
 42+ }, settings);
 43+
 44+ var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
 45+ var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
 46+
 47+ if (jQuery.browser.msie && (ie55 || ie6)) {
 48+
 49+ //fix images with png-source
 50+ jQuery(this).find("img[src$=.png]").each(function() {
 51+
 52+ jQuery(this).attr('width',jQuery(this).width());
 53+ jQuery(this).attr('height',jQuery(this).height());
 54+
 55+ var prevStyle = '';
 56+ var strNewHTML = '';
 57+ var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
 58+ var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
 59+ var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
 60+ var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
 61+ var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
 62+ var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
 63+ if (this.style.border) {
 64+ prevStyle += 'border:'+this.style.border+';';
 65+ this.style.border = '';
 66+ }
 67+ if (this.style.padding) {
 68+ prevStyle += 'padding:'+this.style.padding+';';
 69+ this.style.padding = '';
 70+ }
 71+ if (this.style.margin) {
 72+ prevStyle += 'margin:'+this.style.margin+';';
 73+ this.style.margin = '';
 74+ }
 75+ var imgStyle = (this.style.cssText);
 76+
 77+ strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
 78+ strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
 79+ strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
 80+ strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
 81+ strNewHTML += imgStyle+'"></span>';
 82+ if (prevStyle != ''){
 83+ strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
 84+ }
 85+
 86+ jQuery(this).hide();
 87+ jQuery(this).after(strNewHTML);
 88+
 89+ });
 90+
 91+ // fix css background pngs
 92+ jQuery(this).find("*").each(function(){
 93+ var bgIMG = jQuery(this).css('background-image');
 94+ if(bgIMG.indexOf(".png")!=-1){
 95+ var iebg = bgIMG.split('url("')[1].split('")')[0];
 96+ jQuery(this).css('background-image', 'none');
 97+ jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
 98+ }
 99+ });
 100+
 101+ //fix input with png-source
 102+ jQuery(this).find("input[src$=.png]").each(function() {
 103+ var bgIMG = jQuery(this).attr('src');
 104+ jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
 105+ jQuery(this).attr('src', settings.blankgif)
 106+ });
 107+
 108+ }
 109+
 110+ return jQuery;
 111+
 112+};
 113+
 114+})(jQuery);
Index: branches/new-upload/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php
@@ -14,12 +14,14 @@
1515 $wgJSAutoloadLocalClasses['j.cookie'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/external/cookie/jquery.cookie.js';
1616
1717 $wgJSAutoloadLocalClasses['j.contextMenu'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.contextMenu.js';
 18+ $wgJSAutoloadLocalClasses['j.fn.pngFix'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.pngFix.js';
 19+
1820 $wgJSAutoloadLocalClasses['j.fn.autocomplete'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.autocomplete.js';
1921 $wgJSAutoloadLocalClasses['j.fn.hoverIntent'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.hoverIntent.js';
2022 $wgJSAutoloadLocalClasses['j.Jcrop'] = $wgMwEmbedDirectory . 'jquery/plugins/Jcrop/js/jquery.Jcrop.js';
2123 $wgJSAutoloadLocalClasses['Date.fromString'] = $wgMwEmbedDirectory . 'jquery/plugins/date.js';
2224 $wgJSAutoloadLocalClasses['j.fn.datePicker'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.datePicker.js';
23 -
 25+
2426 //jquery.ui
2527 $wgJSAutoloadLocalClasses['j.ui'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.core.js';
2628
Index: branches/new-upload/phase3/js2/mwEmbed/skins/mvpcf/styles.css
@@ -297,8 +297,7 @@
298298 .mvttseek{
299299 cursor:pointer;
300300 }
301 -.large_play_button {
302 - background: url(images/player_big_play_button.png) 0 0 no-repeat;
 301+.large_play_button {
303302 display:block;
304303 width: 130px;
305304 height: 96px;
Index: branches/new-upload/phase3/js2/mwEmbed/mv_embed.js
@@ -59,6 +59,7 @@
6060 /*parseUri class parses URIs:*/
6161 var parseUri=function(d){var o=parseUri.options,value=o.parser[o.strictMode?"strict":"loose"].exec(d);for(var i=0,uri={};i<14;i++){uri[o.key[i]]=value[i]||""}uri[o.q.name]={};uri[o.key[12]].replace(o.q.parser,function(a,b,c){if(b)uri[o.q.name][b]=c});return uri};parseUri.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};
6262
 63+
6364 //get mv_embed location if it has not been set
6465 if( !mv_embed_path ){
6566 var mv_embed_path = getMvEmbedPath();
@@ -112,7 +113,7 @@
113114 "mv_ogg-player-flowplayer" : "Flowplayer",
114115 "mv_ogg-player-selected" : " (selected)",
115116 "mv_ogg-player-omtkplayer" : "OMTK Flash Vorbis",
116 - "mv_generic_missing_plugin" : "You browser does not appear to support playback type: <b>$1</b><br> visit the <a href=\"http://metavid.org/wiki/Client_Playback\">Playback Methods</a> page to download a player<br>",
 117+ "mv_generic_missing_plugin" : "You browser does not appear to support playback type: <b>$1</b><br> visit the <a href=\"http://commons.wikimedia.org/wiki/Commons:Media_help\">Playback Methods</a> page to download a player<br>",
117118
118119 "add_to_end_of_sequence" : "Add to End of Sequence",
119120
@@ -404,9 +405,13 @@
405406 var secReq = {};
406407 //IE loads things out of order running j.slider before j.ui is ready
407408 //load ui depenent scripts in a second request:
408 - if($j.browser.msie){
 409+ if($j.browser.msie){
409410 secReq = {
410411 '$j.ui.slider' : 'jquery/' + jQueryUiVN + '/ui/ui.slider.js'
 412+ }
 413+ //ie6 yay!
 414+ if($j.browser.version <= 6){
 415+ secReq[ '$j.fn.pngFix' ] = 'jquery/plugins/jquery.pngFix.js';
411416 }
412417 }else{
413418 baseReq['$j.ui.slider'] = 'jquery/' + jQueryUiVN + '/ui/ui.slider.js';
Index: branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/mv_baseEmbed.js
@@ -107,7 +107,7 @@
108108 }
109109 //process selected elements:
110110 //ie8 does not play well with the jQuery video,audio,playlist selector use native:
111 - if($j.browser.msie = true && $j.browser.version >= 8){
 111+ if($j.browser.msie && $j.browser.version >= 8){
112112 jtags = j_selector.split(',');
113113 for(var i=0;i<jtags.length;i++){
114114 $j( document.getElementsByTagName( jtags[i] )).each(function(){
@@ -288,8 +288,13 @@
289289 //big_play_link_ play binding:
290290 $j('#big_play_link_' + embedObj.id).unbind().click(function(){
291291 $j('#' + embedObj.id).get(0).play();
292 - });
 292+ });
293293
 294+ if( $j.browser.msie && $j.browser.version <= 6){
 295+ $j('#big_play_link_' + embedObj.id).pngFix();
 296+ }
 297+
 298+
294299 //captions binding:
295300 $j('#timed_text_' + embedObj.id).unbind().btnBind().click(function(){
296301 $j('#' + embedObj.id).get(0).showTextInterface();
@@ -1073,7 +1078,7 @@
10741079 if( this.pc )
10751080 var missing_type = this.pc.type;
10761081 js_log('no player found for given source type ' + missing_type);
1077 - this.load_error= gM('mv_generic_missing_plugin', missing_type );
 1082+ this.load_error= this.getPluginMissingHTML(missing_type);
10781083 }
10791084 },
10801085 inheritEmbedObj:function(){
@@ -1505,13 +1510,15 @@
15061511 /*
15071512 * get missing plugin html (check for user included code)
15081513 */
1509 - getPluginMissingHTML : function(){
 1514+ getPluginMissingHTML : function(missing_type){
15101515 //keep the box width hight:
15111516 var out = '<div style="width:'+this.width+'px;height:'+this.height+'px">';
15121517 if(this.user_missing_plugin_html){
15131518 out+= this.user_missing_plugin_html;
15141519 }else{
1515 - out+= gM('generic_missing_plugin') + ' or <a title="'+gM('download_clip')+'" href="'+this.src +'">'+gM('download_clip')+'</a>';
 1520+ if(!missing_type)
 1521+ missing_type='';
 1522+ out+= gM('mv_generic_missing_plugin', missing_type) + ' or <a title="'+gM('download_clip')+'" href="'+this.src +'">'+gM('download_clip')+'</a>';
15161523 }
15171524 return out + '</div>';
15181525 },
@@ -1685,7 +1692,9 @@
16861693 if(!id)id=this.id;
16871694 return '<div id="big_play_link_'+id+'" class="large_play_button" '+
16881695 'style="left:'+((this.playerPixelWidth()-130)/2)+'px;'+
1689 - 'top:'+((this.playerPixelHeight()-96)/2)+'px;"></div>';
 1696+ 'top:' + ((this.playerPixelHeight()-96)/2) + 'px;">'+
 1697+ '<img src="' + mv_skin_img_path + 'player_big_play_button.png">'+
 1698+ '</div>';
16901699 },
16911700 doLinkBack:function(){
16921701 if(this.roe && this.media_element.addedROEData==false){
@@ -2557,27 +2566,21 @@
25582567 js_log("running detect");
25592568 this.players = new mediaPlayers();
25602569 //every browser supports html rendering:
2561 - this.players.addPlayer( htmlPlayer );
2562 - // First some browser detection
2563 - this.msie = ( navigator.appName == "Microsoft Internet Explorer" );
2564 - this.msie6 = ( navigator.userAgent.indexOf("MSIE 6")===false);
2565 - this.opera = ( navigator.appName == 'Opera' );
2566 - this.safari = ( navigator.vendor && navigator.vendor.substr( 0, 5 ) == 'Apple' );
2567 -
 2570+ this.players.addPlayer( htmlPlayer );
25682571 // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to
25692572 // search navigator.mimeTypes to see if it's installed
25702573 var javaEnabled = navigator.javaEnabled();
25712574 // In Opera, navigator.javaEnabled() is all there is
2572 - var invisibleJava = this.opera;
 2575+ var invisibleJava = $j.browser.opera;
25732576 // Some browsers filter out duplicate mime types, hiding some plugins
2574 - var uniqueMimesOnly = this.opera || this.safari;
 2577+ var uniqueMimesOnly = $j.browser.opera || $j.browser.safari;
25752578 // Opera will switch off javaEnabled in preferences if java can't be found.
25762579 // And it doesn't register an application/x-java-applet mime type like Mozilla does.
25772580 if ( invisibleJava && javaEnabled )
25782581 this.players.addPlayer( cortadoPlayer );
25792582
25802583 // ActiveX plugins
2581 - if(this.msie){
 2584+ if($j.browser.msie){
25822585 // check for flash
25832586 if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash')){
25842587 //try to get the flash version for omtk include:

Status & tagging log