From c7f1e1d8ad564090c21136d13b122cf7f8a4a270 Mon Sep 17 00:00:00 2001 From: rvelices Date: Tue, 30 Nov 2010 20:42:35 +0000 Subject: bug 2043: merge from trunk to branch 2.1 some Javascript errors in default theme (also makes the rating.js script async) git-svn-id: http://piwigo.org/svn/branches/2.1@7958 68402e56-0260-453c-a942-63ccdbb3a9ee --- themes/default/js/rating.js | 15 +++++- themes/default/js/scripts.js | 103 ++++++++++++++++++++---------------- themes/default/template/picture.tpl | 12 +++-- 3 files changed, 79 insertions(+), 51 deletions(-) (limited to 'themes/default') diff --git a/themes/default/js/rating.js b/themes/default/js/rating.js index 0e3006ec2..93c0da22b 100644 --- a/themes/default/js/rating.js +++ b/themes/default/js/rating.js @@ -90,4 +90,17 @@ function updateRating(e) } ); return false; -} \ No newline at end of file +} + +(function() { +if (typeof _pwgRatingAutoQueue!="undefined" && _pwgRatingAutoQueue.length) +{ + for (var i=0; i<_pwgRatingAutoQueue.length; i++) + makeNiceRatingForm(_pwgRatingAutoQueue[i]); +} +_pwgRatingAutoQueue = { + push: function(opts) { + makeNiceRatingForm(opts); + } +} +})(); \ No newline at end of file diff --git a/themes/default/js/scripts.js b/themes/default/js/scripts.js index 638fccbcf..eae0c2a3b 100644 --- a/themes/default/js/scripts.js +++ b/themes/default/js/scripts.js @@ -51,124 +51,135 @@ function popuphelp(url) ); } -Function.prototype.pwgBind = function() { - var __method = this, object = arguments[0], args = Array.prototype.slice.call(arguments,1); - return function() { - return __method.apply(object, args.concat(arguments) ); - } +function pwgBind(object, method) { + var args = Array.prototype.slice.call(arguments,2); + return function() { + return method.apply(object, args.concat(Array.prototype.slice.call(arguments,0)) ); + } } + function PwgWS(urlRoot) { this.urlRoot = urlRoot; this.options = { method: "GET", - async: true, + async: true, onFailure: null, onSuccess: null }; }; PwgWS.prototype = { - callService : function(method, parameters, options) { if (options) { - for (var property in options) - this.options[property] = options[property]; + for (var prop in options) + this.options[prop] = options[prop]; } - try { this.transport = new XMLHttpRequest();} + try { this.xhr = new XMLHttpRequest();} catch(e) { - try { this.transport = new ActiveXObject('Msxml2.XMLHTTP'); } + try { this.xhr = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { - try { this.transport = new ActiveXObject('Microsoft.XMLHTTP'); } + try { this.xhr = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e){ - dispatchError(0, "Cannot create request object"); + this.error(0, "Cannot create request object"); + return; } } } - this.transport.onreadystatechange = this.onStateChange.pwgBind(this); + this.xhr.onreadystatechange = pwgBind(this, this.onStateChange); var url = this.urlRoot+"ws.php?format=json"; var body = "method="+method; if (parameters) { - for (var property in parameters) + for (var prop in parameters) { - if ( typeof parameters[property] == 'object' && parameters[property]) + if ( typeof parameters[prop] == 'object' && parameters[prop]) { - for (var i=0; i {/if} {/foreach} - -- cgit v1.2.3