[web/js] Deprecate baseuri() and replace with BASE_URL (closes #3955372)
authorRémi Cardona <remi.cardona@logilab.fr>
Fri, 23 May 2014 18:35:13 +0200
changeset 9819 95902c0b991b
parent 9818 e3d2012adcd0
child 9821 2077c8da1893
[web/js] Deprecate baseuri() and replace with BASE_URL (closes #3955372) Added by commit 8bf2337a6f3b and publicly available since 3.11.2 released more than 3 years ago.
web/data/cubicweb.ajax.js
web/data/cubicweb.edition.js
web/data/cubicweb.facets.js
web/data/cubicweb.htmlhelpers.js
web/data/cubicweb.timeline-bundle.js
--- a/web/data/cubicweb.ajax.js	Fri May 23 18:17:44 2014 +0200
+++ b/web/data/cubicweb.ajax.js	Fri May 23 18:35:13 2014 +0200
@@ -88,8 +88,8 @@
 });
 
 var AJAX_PREFIX_URL = 'ajax';
-var JSON_BASE_URL = baseuri() + 'json?';
-var AJAX_BASE_URL = baseuri() + AJAX_PREFIX_URL + '?';
+var JSON_BASE_URL = BASE_URL + 'json?';
+var AJAX_BASE_URL = BASE_URL + AJAX_PREFIX_URL + '?';
 
 
 jQuery.extend(cw.ajax, {
@@ -122,9 +122,7 @@
      * (e.g. http://..../data??resource1.js,resource2.js)
      */
     _modconcatLikeUrl: function(url) {
-        var base = baseuri();
-        if (!base.endswith('/')) { base += '/'; }
-        var modconcat_rgx = new RegExp('(' + base + 'data/([a-z0-9]+/)?)\\?\\?(.+)');
+        var modconcat_rgx = new RegExp('(' + BASE_URL + 'data/([a-z0-9]+/)?)\\?\\?(.+)');
         return modconcat_rgx.exec(url);
     },
 
@@ -379,8 +377,8 @@
  * dictionary, `reqtype` the HTTP request type (get 'GET' or 'POST').
  */
 function loadRemote(url, form, reqtype, sync) {
-    if (!url.toLowerCase().startswith(baseuri().toLowerCase())) {
-        url = baseuri() + url;
+    if (!url.toLowerCase().startswith(BASE_URL.toLowerCase())) {
+        url = BASE_URL + url;
     }
     if (!sync) {
         var deferred = new Deferred();
@@ -592,7 +590,7 @@
                 var fck = new FCKeditor(this.id);
                 fck.Config['CustomConfigurationsPath'] = fckconfigpath;
                 fck.Config['DefaultLanguage'] = fcklang;
-                fck.BasePath = baseuri() + "fckeditor/";
+                fck.BasePath = BASE_URL + "fckeditor/";
                 fck.ReplaceTextarea();
             } else {
                 cw.log('fckeditor could not be found.');
--- a/web/data/cubicweb.edition.js	Fri May 23 18:17:44 2014 +0200
+++ b/web/data/cubicweb.edition.js	Fri May 23 18:35:13 2014 +0200
@@ -67,7 +67,7 @@
                 rql: rql_for_eid(eid),
                 '__notemplate': 1
             };
-            var d = jQuery('#unrelatedDivs_' + eid).loadxhtml(baseuri() + 'view', args, 'post', 'append');
+            var d = jQuery('#unrelatedDivs_' + eid).loadxhtml(BASE_URL + 'view', args, 'post', 'append');
             d.addCallback(function() {
                 _showMatchingSelect(eid, jQuery('#' + divId));
             });
--- a/web/data/cubicweb.facets.js	Fri May 23 18:17:44 2014 +0200
+++ b/web/data/cubicweb.facets.js	Fri May 23 18:35:13 2014 +0200
@@ -69,7 +69,7 @@
         }
         var $focusLink = $('#focusLink');
         if ($focusLink.length) {
-            var url = baseuri()+ 'view?rql=' + encodeURIComponent(rql);
+            var url = BASE_URL + 'view?rql=' + encodeURIComponent(rql);
             if (vid) {
                 url += '&vid=' + encodeURIComponent(vid);
             }
--- a/web/data/cubicweb.htmlhelpers.js	Fri May 23 18:17:44 2014 +0200
+++ b/web/data/cubicweb.htmlhelpers.js	Fri May 23 18:35:13 2014 +0200
@@ -12,20 +12,13 @@
 /**
  * .. function:: baseuri()
  *
- * returns the document's baseURI. (baseuri() uses document.baseURI if
- * available and inspects the <base> tag manually otherwise.)
+ * returns the document's baseURI.
  */
-function baseuri() {
-    if (typeof BASE_URL === 'undefined') {
-        // backward compatibility, BASE_URL might be undefined
-        var uri = document.baseURI;
-        if (uri) { // some browsers don't define baseURI
-            return uri.toLowerCase();
-        }
-        return jQuery('base').attr('href').toLowerCase();
-    }
-    return BASE_URL;
-}
+baseuri = cw.utils.deprecatedFunction(
+    "[3.20] baseuri() is deprecated, use BASE_URL instead",
+    function () {
+        return BASE_URL;
+    });
 
 /**
  * .. function:: setProgressCursor()
--- a/web/data/cubicweb.timeline-bundle.js	Fri May 23 18:17:44 2014 +0200
+++ b/web/data/cubicweb.timeline-bundle.js	Fri May 23 18:35:13 2014 +0200
@@ -3,8 +3,8 @@
  *  :organization: Logilab
  */
 
-var SimileAjax_urlPrefix = baseuri() + 'data/';
-var Timeline_urlPrefix = baseuri() + 'data/';
+var SimileAjax_urlPrefix = BASE_URL + 'data/';
+var Timeline_urlPrefix = BASE_URL + 'data/';
 
 /*
  *  Simile Ajax API