From f767f6ca4722313bdff194de023db559156865d7 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 7 Feb 2014 15:34:37 +0100 Subject: [PATCH] [FIX] website tour test: import with ajax insead of jquery (and auto load jquery) bzr revid: chm@openerp.com-20140207143437-uptdehmpegzze61y --- .../static/src/js/website.tour.test.js | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/addons/website/static/src/js/website.tour.test.js b/addons/website/static/src/js/website.tour.test.js index 4fc9f1fe213..ce2cc721a82 100644 --- a/addons/website/static/src/js/website.tour.test.js +++ b/addons/website/static/src/js/website.tour.test.js @@ -1,27 +1,32 @@ (function () { -var scripts = []; + +function LoadScript(src) { + xmlHttp = new XMLHttpRequest(); + xmlHttp.onreadystatechange = function() { + if(xmlHttp.readyState == 4) { + if (xmlHttp.status == 200 || xmlHttp.status == 304) { + new Function(xmlHttp.responseText)(); + } else { + throw new Error("Can't load JavaScript.\nhref: " + window.location.href + "\nsrc: " + src); + } + } + }; + xmlHttp.open("GET", src, false); + xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + xmlHttp.send(null); +} + +if (typeof jQuery === "undefined") + LoadScript("/web/static/lib/jquery/jquery.js"); if (typeof openerp === "undefined") { - scripts.push("/web/static/lib/qweb/qweb2.js"); - scripts.push("/web/static/lib/qweb/openerpframework.js"); + LoadScript("/web/static/lib/qweb/qweb2.js"); + LoadScript("/web/static/lib/qweb/openerpframework.js"); } if (typeof openerp === "undefined" || !openerp.website || !openerp.website.add_template_file) - scripts.push("/website/static/src/js/website.js"); + LoadScript("/website/static/src/js/website.js"); if (typeof openerp === "undefined" || !openerp.website.Tour) - scripts.push("/website/static/src/js/website.tour.js"); -if (typeof Tour === "undefined") { - scripts.push("/website/static/lib/bootstrap-tour/bootstrap-tour.js"); -} -for (var i in scripts) { - if (typeof jQuery === "undefined") { - throw new Error("jQuery not found.\nhref: " + window.location.href + (document && document.body ? "\n\n" + document.body.innerHTML : "")); - } - jQuery.ajax({ - async: false, - type: 'GET', - data: null, - url: scripts[i], - dataType: "script", - error: function (a,b,e) {throw e;} - }); -} + LoadScript("/website/static/src/js/website.tour.js"); +if (typeof Tour === "undefined") + LoadScript("/website/static/lib/bootstrap-tour/bootstrap-tour.js"); + })(); \ No newline at end of file