MediaWiki: Common.js

From ShareRice Wiki (AFN)
Jump to: navigation, search
Line 22: Line 22:
  
 
if ( dir == 'max') {
 
if ( dir == 'max') {
_asianfuse.video_panels.add(key, $(key).parent().height());
+
_asianfuse.video_panels.add(key, jQuery(key).parent().height());
  
$('.af-video-embed_' + rand).width(_asianfuse.maxWidth + 'px');
+
jQuery('.af-video-embed_' + rand).width(_asianfuse.maxWidth + 'px');
$('.af-video-embed_' + rand).height(_asianfuse.maxHeight + 'px');
+
jQuery('.af-video-embed_' + rand).height(_asianfuse.maxHeight + 'px');
  
 
// Reset the width relative to the width of the embedded video,  
 
// Reset the width relative to the width of the embedded video,  
 
// because we cannot count on it's parent element's calculated width to cause this to display as expected
 
// because we cannot count on it's parent element's calculated width to cause this to display as expected
$('#af-video-restore_' + rand).width(_asianfuse.maxWidth * 0.98 + 'px');
+
jQuery('#af-video-restore_' + rand).width(_asianfuse.maxWidth * 0.98 + 'px');
$('#af-video-restore_' + rand).show();
+
jQuery('#af-video-restore_' + rand).show();
  
 
} else if ( dir == 'min' ) {
 
} else if ( dir == 'min' ) {
$('#af-video-restore_' + rand).hide();
+
jQuery('#af-video-restore_' + rand).hide();
$('.af-video-embed_' + rand).width(_asianfuse.minWidth + 'px')
+
jQuery('.af-video-embed_' + rand).width(_asianfuse.minWidth + 'px')
$('.af-video-embed_' + rand).height(_asianfuse.minHeight + 'px');
+
jQuery('.af-video-embed_' + rand).height(_asianfuse.minHeight + 'px');
  
$(key).parent().width('150px')
+
jQuery(key).parent().width('150px')
  
 
if( _asianfuse.video_panels.has_key(key) ) {
 
if( _asianfuse.video_panels.has_key(key) ) {
$(key).parent().height(_asianfuse.video_panels[key] + 'px');
+
jQuery(key).parent().height(_asianfuse.video_panels[key] + 'px');
 
}
 
}
 
}
 
}

Revision as of 04:30, 5 July 2011

/* Any JavaScript here will be loaded for all users on every page load. */

// Provide easy access to default values, neatly hidden in a "namespace" that SHOULDN'T conflict with any other environmental variables.
var _asianfuse = {
	video_panels: {
	add: function(key, val) { 
		if ( this.has_key(key) || val == undefined ) { return; }
		this[key] = val; 
	},
	has_key: function(key) { return(this[key] != undefined); }
	},

	maxWidth: 425,
	minWidth: 150,

	maxHeight: 350,
	minHeight: 124
}

function do_resize (rand, dir) {
	key = '#af-video-restore_' + rand

	if ( dir == 'max') {
		_asianfuse.video_panels.add(key, jQuery(key).parent().height());

		jQuery('.af-video-embed_' + rand).width(_asianfuse.maxWidth + 'px');
		jQuery('.af-video-embed_' + rand).height(_asianfuse.maxHeight + 'px');

		// Reset the width relative to the width of the embedded video, 
		// because we cannot count on it's parent element's calculated width to cause this to display as expected
		jQuery('#af-video-restore_' + rand).width(_asianfuse.maxWidth * 0.98 + 'px');
		jQuery('#af-video-restore_' + rand).show();

	} else if ( dir == 'min' ) {
		jQuery('#af-video-restore_' + rand).hide();
		jQuery('.af-video-embed_' + rand).width(_asianfuse.minWidth + 'px')
		jQuery('.af-video-embed_' + rand).height(_asianfuse.minHeight + 'px');

		jQuery(key).parent().width('150px')

		if( _asianfuse.video_panels.has_key(key) ) {
			jQuery(key).parent().height(_asianfuse.video_panels[key] + 'px');
		}
	}
}

addOnloadHook( do_resize );