Tarea #1054 -> Mejorar el rendimiento de la web

git-svn-id: https://192.168.0.254/svn/Proyectos.ASong2U_Web/trunk@163 cd1a4ea2-8c7f-e448-aada-19d1fee9e1d6
This commit is contained in:
David Arranz 2012-08-31 15:58:19 +00:00
parent 3d8bc4db7f
commit e6bf89d5ce
11 changed files with 328 additions and 35 deletions

View File

@ -73,6 +73,6 @@
<?php endif; ?>
<?php wp_footer(); ?>
<?php require(ghostpool_scripts . 'custom.php'); ?>
</body>
</html>

View File

@ -232,11 +232,13 @@ function gp_enqueue_scripts() {
//wp_enqueue_script('prettyphoto', get_template_directory_uri() . '/lib/scripts/prettyPhoto/js/jquery.prettyPhoto.js', array('jquery'));
//wp_enqueue_script('jqtransform', get_template_directory_uri() . '/lib/scripts/jquery.jqtransform.js', array('jquery'));
wp_enqueue_script('jqtransform', get_template_directory_uri() . '/lib/scripts/jquery.jqtransform.js', array('jquery'));
//wp_enqueue_script('jqueryeasing', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.easing.1.3.js', array('jquery'));
wp_enqueue_script('jqueryeasing', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.easing.1.3.js', array('jquery'));
//wp_enqueue_script('froogaloop', get_template_directory_uri() . '/lib/scripts/videoslider/js/froogaloop.min.js', array('jquery'));
// Para Vimeo;
wp_enqueue_script('froogaloop', get_template_directory_uri() . '/lib/scripts/videoslider/js/froogaloop.min.js', array('jquery'));
//wp_enqueue_script('froogaloop', get_template_directory_uri() . '/lib/scripts/videoslider/js/froogaloop.js', array('jquery'));
wp_enqueue_script('apPlaylistManager', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apPlaylistManager.min.js', array('jquery'));
//wp_enqueue_script('apPlaylistManager', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apPlaylistManager.js', array('jquery'));

View File

@ -11,7 +11,7 @@
<!--[if IE 7]><link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/lib/css/style-ie7.css" media="screen" /><![endif]-->
<!--[if lte IE 8 ]><link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/lib/scripts/videoslider/css/ie.css" /><![endif]-->
<?php require(ghostpool_scripts . 'custom.php'); ?>
<?php require(ghostpool_inc . 'page-styling.php'); ?>
<?php if (is_home() OR is_front_page()) : ?>

View File

@ -210,21 +210,23 @@ function shrinkTitle()
textH1.style.fontSize -= 10+"px";
}
jQuery(window).ready(function() {
jQuery('#content-wrapper .post-loop .post-thumbnail a').live('click', function(e) {
e.preventDefault();
var nParent = (jQuery(this).parent().parent());
var classList = jQuery(nParent).attr('class').split(' ');
jQuery(classList).each(function(index, item) {
var id = item.replace('post-','');
if (jQuery.isNumeric(id)) {
loadVideo(id);
jQuery('html, body').animate({ scrollTop: 0 }, 600);
return false;
}
jQuery(window).ready(function() {
if (jQuery('#slider-wrapper').length > 0 ) {
jQuery('#content-wrapper .post-loop .post-thumbnail a').live('click', function(e) {
e.preventDefault();
var nParent = (jQuery(this).parent().parent());
var classList = jQuery(nParent).attr('class').split(' ');
jQuery(classList).each(function(index, item) {
var id = item.replace('post-','');
if (jQuery.isNumeric(id)) {
loadVideo(id);
jQuery('html, body').animate({ scrollTop: 0 }, 600);
return false;
}
});
return false;
});
return false;
});
}
});
jQuery(document).ready(function(){
@ -242,7 +244,6 @@ jQuery(document).ready(function(){
});
});
jQuery(document).ready(function(){
setTimeout(function() {
jQuery("#content-wrapper #message.updated").toggle('slow');

View File

@ -11,6 +11,6 @@ b=oUrl+"id/"+b;jQuery("#dedicate_this_song_button").attr("href",b);jQuery("#fsbb
jQuery("#dedication-data-panel").hide("fast");jQuery("#dedication-data-panel").slideUp("fast",function(){jQuery("#dedication-data-panel").html(c);jQuery("#dedicationTitle-data-panel").html(c)});jQuery("#dedication-data-panel").slideDown();jQuery("#dedicationFooter_container").slideUp("fast",function(){jQuery("#dedicationArtits").html(f);jQuery("#dedicationSong").html(g)});jQuery("#dedicationFooter_container").slideDown("fast",function(){});jQuery("#dedicationTitle").html(e);shrinkTitle();jQuery("#dedicationTitle a").jTypeWriter();
jQuery("#dedicationComments_container").slideUp("fast",function(){jQuery("#dedicationComments_container").load(h+" #comments","",function(){init_comments();jQuery("#dedicationComments_container").on("submit","#commentform",function(){prepare_new_comment_home();return!1})})});jQuery("#dedicationComments_container").slideDown();0<jQuery("#postdata-mark-read-"+a).length&&(jQuery("#postdata-mark-read-"+a+" .mar_mark_as_read").click(),jQuery("#postdata-mark-read-"+a).remove())}}
function shrinkTitle(){var a=document.getElementById("dedicationTitle"),b=document.getElementById("dedicationTitle_container");for(a.style.fontSize="42px";a.offsetWidth>b.offsetWidth;)size=parseInt(a.style.fontSize.replace("px","")),size-=1,a.style.fontSize=size+"px";a.style.fontSize-=NaN}
jQuery(window).ready(function(){jQuery("#content-wrapper .post-loop .post-thumbnail a").live("click",function(a){a.preventDefault();a=jQuery(this).parent().parent();a=jQuery(a).attr("class").split(" ");jQuery(a).each(function(a,e){var c=e.replace("post-","");if(jQuery.isNumeric(c))return loadVideo(c),jQuery("html, body").animate({scrollTop:0},600),!1});return!1})});
jQuery(window).ready(function(){0<jQuery("#slider-wrapper").length&&jQuery("#content-wrapper .post-loop .post-thumbnail a").live("click",function(a){a.preventDefault();a=jQuery(this).parent().parent();a=jQuery(a).attr("class").split(" ");jQuery(a).each(function(a,e){var c=e.replace("post-","");if(jQuery.isNumeric(c))return loadVideo(c),jQuery("html, body").animate({scrollTop:0},600),!1});return!1})});
jQuery(document).ready(function(){jQuery("#sidebar .sidebarposts .top_10 .posts").hide();jQuery("#sidebar .sidebarposts .top_10 h3").click(function(){jQuery("#sidebar .sidebarposts .top_10 .posts").toggle("slow",function(){})})});jQuery(document).ready(function(){jQuery("#my-friends-big-avatars div.see_more").hide();jQuery("#my-friends-big-avatars span.see_more").click(function(){jQuery("#my-friends-big-avatars span.see_more").hide();jQuery("#my-friends-big-avatars div.see_more").toggle("fast",function(){})})});
jQuery(document).ready(function(){setTimeout(function(){jQuery("#content-wrapper #message.updated").toggle("slow")},3E3)});

View File

@ -20,5 +20,3 @@ function activePlaylist(playlist) {
jQuery.fn.videoGallery.inputPlaylist(playlist);
return false;
}

View File

@ -9,7 +9,7 @@ function createVideoGallery() {
jQuery('#componentWrapper').videoGallery({
componentFixedSize: true,
animateVideoSizeOnPlaylistClose: true,
thumbOrientation: 'vertical',
thumbOrientation:'vertical',
activePlaylist:'playlist',
activeVideo:99999,
autoPlay:true,
@ -43,8 +43,13 @@ function createVideoGallery() {
iconThumbBackwardOn: '<?php echo get_template_directory_uri(); ?>/lib/scripts/videoslider/data/icons/thumb_backward_on.png',
iconThumbBackwardVOn: '<?php echo get_template_directory_uri(); ?>/lib/scripts/videoslider/data/icons/thumb_backward_v_on.png',
videoGalleryPlayMedia: function(){ updateInfo(); },
videoGallerySetupDone: function(){ },
videoGalleryPlaylistEnd: function(){
loadVideo(0);
<?php if (!is_singular()) { ?>
loadVideo(0);
<?php } else { ?>
redirect();
<?php } ?>
}
});
};

View File

@ -0,0 +1,288 @@
// Init style shamelessly stolen from jQuery http://jquery.com
var Froogaloop = (function(){
// Define a local copy of Froogaloop
function Froogaloop(iframe) {
// The Froogaloop object is actually just the init constructor
return new Froogaloop.fn.init(iframe);
}
var eventCallbacks = {},
hasWindowEvent = false,
isReady = false,
slice = Array.prototype.slice,
playerDomain = '';
Froogaloop.fn = Froogaloop.prototype = {
element: null,
init: function(iframe) {
if (typeof iframe === "string") {
iframe = document.getElementById(iframe);
}
this.element = iframe;
// Register message event listeners
playerDomain = getDomainFromUrl(this.element.getAttribute('src'));
return this;
},
/*
* Calls a function to act upon the player.
*
* @param {string} method The name of the Javascript API method to call. Eg: 'play'.
* @param {Array|Function} valueOrCallback params Array of parameters to pass when calling an API method
* or callback function when the method returns a value.
*/
api: function(method, valueOrCallback) {
if (!this.element || !method) {
return false;
}
var self = this,
element = self.element,
target_id = element.id !== '' ? element.id : null,
params = !isFunction(valueOrCallback) ? valueOrCallback : null,
callback = isFunction(valueOrCallback) ? valueOrCallback : null;
// Store the callback for get functions
if (callback) {
storeCallback(method, callback, target_id);
}
postMessage(method, params, element);
return self;
},
/*
* Registers an event listener and a callback function that gets called when the event fires.
*
* @param eventName (String): Name of the event to listen for.
* @param callback (Function): Function that should be called when the event fires.
*/
addEvent: function(eventName, callback) {
if (!this.element) {
return false;
}
var self = this,
element = self.element,
target_id = element.id !== '' ? element.id : null;
storeCallback(eventName, callback, target_id);
// The ready event is not registered via postMessage. It fires regardless.
if (eventName != 'ready') {
postMessage('addEventListener', eventName, element);
}
else if (eventName == 'ready' && isReady) {
callback.call(null, target_id);
}
return self;
},
/*
* Unregisters an event listener that gets called when the event fires.
*
* @param eventName (String): Name of the event to stop listening for.
*/
removeEvent: function(eventName) {
if (!this.element) {
return false;
}
var self = this,
element = self.element,
target_id = element.id !== '' ? element.id : null,
removed = removeCallback(eventName, target_id);
// The ready event is not registered
if (eventName != 'ready' && removed) {
postMessage('removeEventListener', eventName, element);
}
}
};
/**
* Handles posting a message to the parent window.
*
* @param method (String): name of the method to call inside the player. For api calls
* this is the name of the api method (api_play or api_pause) while for events this method
* is api_addEventListener.
* @param params (Object or Array): List of parameters to submit to the method. Can be either
* a single param or an array list of parameters.
* @param target (HTMLElement): Target iframe to post the message to.
*/
function postMessage(method, params, target) {
if (!target.contentWindow.postMessage) {
return false;
}
var url = target.getAttribute('src').split('?')[0],
data = JSON.stringify({
method: method,
value: params
});
if (url.substr(0, 2) === '//') {
url = window.location.protocol + url;
}
target.contentWindow.postMessage(data, url);
}
/**
* Event that fires whenever the window receives a message from its parent
* via window.postMessage.
*/
function onMessageReceived(event) {
var data, method;
try {
data = JSON.parse(event.data);
method = data.event || data.method;
}
catch(e) {
//fail silently... like a ninja!
}
if (method == 'ready' && !isReady) {
isReady = true;
}
// Handles messages from moogaloop only
if (event.origin != playerDomain) {
return false;
}
var value = data.value,
eventData = data.data,
target_id = target_id === '' ? null : data.player_id,
callback = getCallback(method, target_id),
params = [];
if (!callback) {
return false;
}
if (value !== undefined) {
params.push(value);
}
if (eventData) {
params.push(eventData);
}
if (target_id) {
params.push(target_id);
}
return params.length > 0 ? callback.apply(null, params) : callback.call();
}
/**
* Stores submitted callbacks for each iframe being tracked and each
* event for that iframe.
*
* @param eventName (String): Name of the event. Eg. api_onPlay
* @param callback (Function): Function that should get executed when the
* event is fired.
* @param target_id (String) [Optional]: If handling more than one iframe then
* it stores the different callbacks for different iframes based on the iframe's
* id.
*/
function storeCallback(eventName, callback, target_id) {
if (target_id) {
if (!eventCallbacks[target_id]) {
eventCallbacks[target_id] = {};
}
eventCallbacks[target_id][eventName] = callback;
}
else {
eventCallbacks[eventName] = callback;
}
}
/**
* Retrieves stored callbacks.
*/
function getCallback(eventName, target_id) {
if (target_id) {
return eventCallbacks[target_id][eventName];
}
else {
return eventCallbacks[eventName];
}
}
function removeCallback(eventName, target_id) {
if (target_id && eventCallbacks[target_id]) {
if (!eventCallbacks[target_id][eventName]) {
return false;
}
eventCallbacks[target_id][eventName] = null;
}
else {
if (!eventCallbacks[eventName]) {
return false;
}
eventCallbacks[eventName] = null;
}
return true;
}
/**
* Returns a domain's root domain.
* Eg. returns http://vimeo.com when http://vimeo.com/channels is sbumitted
*
* @param url (String): Url to test against.
* @return url (String): Root domain of submitted url
*/
function getDomainFromUrl(url) {
if (url.substr(0, 2) === '//') {
url = window.location.protocol + url;
}
var url_pieces = url.split('/'),
domain_str = '';
for(var i = 0, length = url_pieces.length; i < length; i++) {
if(i<3) {domain_str += url_pieces[i];}
else {break;}
if(i<2) {domain_str += '/';}
}
return domain_str;
}
function isFunction(obj) {
return !!(obj && obj.constructor && obj.call && obj.apply);
}
function isArray(obj) {
return toString.call(obj) === '[object Array]';
}
// Give the init function the Froogaloop prototype for later instantiation
Froogaloop.fn.init.prototype = Froogaloop.fn;
// Listens for the message event.
// W3C
if (window.addEventListener) {
window.addEventListener('message', onMessageReceived, false);
}
// IE
else {
window.attachEvent('onmessage', onMessageReceived);
}
// Expose froogaloop to the global object
return (window.Froogaloop = window.$f = Froogaloop);
})();

View File

@ -1,4 +1,4 @@
var Froogaloop=function(){function g(a){return new g.fn.init(a)}function h(a,b,c){if(!c.contentWindow.postMessage)return!1;var f=c.getAttribute("src").split("?")[0];a=JSON.stringify({method:a,value:b});c.contentWindow.postMessage(a,f)}function i(a){if(a.origin!=playerDomain)return!1;var b=JSON.parse(a.data);a=b.value;var c=b.data,f=f==""?null:b.player_id;b=f?d[f][b.event||b.method]:d[b.event||b.method];var e=[];if(!b)return!1;a!==void 0&&e.push(a);c&&e.push(c);f&&e.push(f);return e.length>0?b.apply(null,
e):b.call()}function j(a,b,c){c?(d[c]||(d[c]={}),d[c][a]=b):d[a]=b}var d={},k=!1;g.fn=g.prototype={playerDomain:"",element:null,init:function(a){typeof a==="string"&&(a=document.getElementById(a));this.element=a;return this},api:function(a,b){if(!this.element||!a)return!1;var c=this.element,f=c.id!=""?c.id:null,e=!b||!b.constructor||!b.call||!b.apply?b:null,d=b&&b.constructor&&b.call&&b.apply?b:null;d&&j(a,d,f);h(a,e,c);return this},addEvent:function(a,b){if(!this.element)return!1;var c=this.element;
j(a,b,c.id!=""?c.id:null);a!="ready"&&h("addEventListener",a,c);if(k)return this;c=c.getAttribute("src").split("/");for(var d="",e=0,g=c.length;e<g;e++){if(e<3)d+=c[e];else break;e<2&&(d+="/")}playerDomain=d;window.addEventListener?window.addEventListener("message",i,!1):window.attachEvent("onmessage",i,!1);k=!0;return this},removeEvent:function(a){if(!this.element)return!1;var b=this.element,c;a:{if((c=b.id!=""?b.id:null)&&d[c]){if(!d[c][a]){c=!1;break a}d[c][a]=null}else{if(!d[a]){c=!1;break a}d[a]=
null}c=!0}a!="ready"&&c&&h("removeEventListener",a,b)}};g.fn.init.prototype=g.fn;return window.Froogaloop=window.$f=g}();
var Froogaloop=function(){function e(a){return new e.fn.init(a)}function h(a,c,b){if(!b.contentWindow.postMessage)return!1;var f=b.getAttribute("src").split("?")[0],a=JSON.stringify({method:a,value:c});"//"===f.substr(0,2)&&(f=window.location.protocol+f);b.contentWindow.postMessage(a,f)}function j(a){var c,b;try{c=JSON.parse(a.data),b=c.event||c.method}catch(f){}"ready"==b&&!i&&(i=!0);if(a.origin!=k)return!1;var a=c.value,e=c.data,g=""===g?null:c.player_id;c=g?d[g][b]:d[b];b=[];if(!c)return!1;void 0!==
a&&b.push(a);e&&b.push(e);g&&b.push(g);return 0<b.length?c.apply(null,b):c.call()}function l(a,c,b){b?(d[b]||(d[b]={}),d[b][a]=c):d[a]=c}var d={},i=!1,k="";e.fn=e.prototype={element:null,init:function(a){"string"===typeof a&&(a=document.getElementById(a));this.element=a;a=this.element.getAttribute("src");"//"===a.substr(0,2)&&(a=window.location.protocol+a);for(var a=a.split("/"),c="",b=0,f=a.length;b<f;b++){if(3>b)c+=a[b];else break;2>b&&(c+="/")}k=c;return this},api:function(a,c){if(!this.element||
!a)return!1;var b=this.element,f=""!==b.id?b.id:null,d=!c||!c.constructor||!c.call||!c.apply?c:null,e=c&&c.constructor&&c.call&&c.apply?c:null;e&&l(a,e,f);h(a,d,b);return this},addEvent:function(a,c){if(!this.element)return!1;var b=this.element,d=""!==b.id?b.id:null;l(a,c,d);"ready"!=a?h("addEventListener",a,b):"ready"==a&&i&&c.call(null,d);return this},removeEvent:function(a){if(!this.element)return!1;var c=this.element,b;a:{if((b=""!==c.id?c.id:null)&&d[b]){if(!d[b][a]){b=!1;break a}d[b][a]=null}else{if(!d[a]){b=
!1;break a}d[a]=null}b=!0}"ready"!=a&&b&&h("removeEventListener",a,c)}};e.fn.init.prototype=e.fn;window.addEventListener?window.addEventListener("message",j,!1):window.attachEvent("onmessage",j);return window.Froogaloop=window.$f=e}();

View File

@ -41,10 +41,8 @@
_vimeoHolder.css('display', 'block');
_vimeoHolder.append(_vimeoVideoIframe);
_player = Froogaloop(_vimeoVideoIframe[0]);
_player.addEvent('ready', onVimeoReady);
};
ap_VimeoPlayer.prototype = {
@ -84,14 +82,13 @@
}
function onVimeoReady(playerID) {
//console.log('this._onVimeoReady');
_player.api('setVolume', _defaultVolume);
_player.addEvent('finish', onVimeoFinish);
if(!_inited){
_inited=true;
}
if(_autoPlay) _player.api('play');
if(_autoPlay) { _player.api('play'); }
}
function onVimeoFinish() {

View File

@ -89,9 +89,11 @@ if (have_posts()) {
</ul>
</div> <!-- componentPlaylist -->
<div class="slideshow_controls">
<div class="controls_prev"><img src='<?php echo get_template_directory_uri(); ?>/lib/scripts/videoslider/data/icons/backward.png' width='11' height='16' alt='controls_prev'/></div>
<div class="player_share"><img src='<?php echo get_template_directory_uri(); ?>/lib/scripts/videoslider/data/icons/share.png' width='40' height='40' alt=''/></div>
<?php if (!is_singular()) { ?>
<div class="controls_prev"><img src='<?php echo get_template_directory_uri(); ?>/lib/scripts/videoslider/data/icons/backward.png' width='11' height='16' alt='controls_prev'/></div>
<div class="controls_next"><img src='<?php echo get_template_directory_uri(); ?>/lib/scripts/videoslider/data/icons/forward.png' width='11' height='16' alt='controls_next'/></div>
<?php } ?>
<div class="player_share"><img src='<?php echo get_template_directory_uri(); ?>/lib/scripts/videoslider/data/icons/share.png' width='40' height='40' alt=''/></div>
<div id="shareHolder">
<div id="shareHolderInner">