changeset 4512:72747179701a

javascript: ypjax cleanup Set 'Loading ...' while waiting for response.
author Mads Kiilerich <madski@unity3d.com>
date Mon, 08 Sep 2014 13:38:56 +0200
parents 8b394bbd551c
children 0253b8e7d76c
files kallithea/public/js/base.js kallithea/templates/pullrequests/pullrequest.html
diffstat 2 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Mon Sep 08 13:38:56 2014 +0200
+++ b/kallithea/public/js/base.js	Mon Sep 08 13:38:56 2014 +0200
@@ -368,12 +368,13 @@
  *  o.argument
  * @param args arguments
  */
-function ypjax(url,container,s_call,args){
+function ypjax(url, container, s_call, args){
     var method='GET';
     if(args===undefined){
         args=null;
     }
-    $container = $('#' + container);
+    var $target = $('#' + container);
+    $target.html(_TM['Loading ...']).css('opacity','0.3');
 
     // Set special header for partial ajax == HTTP_X_PARTIAL_XHR
     YUC.initHeader('X-PARTIAL-XHR',true);
@@ -381,21 +382,18 @@
     // wrapper of passed callback
     var s_wrapper = (function(o){
         return function(o){
-            $container.html(o.responseText);
-            $container.css('opacity','1.0');
+            $target.html(o.responseText).css('opacity','1.0');
             //execute the given original callback
             if (s_call !== undefined && s_call){
                 s_call();
             }
         }
     })()
-    $container.css('opacity','0.3');
-    YUC.asyncRequest(method,url,{
-        success:s_wrapper,
-        failure:function(o){
+    YUC.asyncRequest(method, url, {
+        success: s_wrapper,
+        failure: function(o){
             console.log('ypjax failure: '+o);
-            $container.html('<span class="error_red">ERROR: {0}</span>'.format(o.status));
-            $container.css('opacity','1.0');
+            $target.html('<span class="error_red">ERROR: {0}</span>'.format(o.status)).css('opacity','1.0');
         },
         cache:false
     },args);
--- a/kallithea/templates/pullrequests/pullrequest.html	Mon Sep 08 13:38:56 2014 +0200
+++ b/kallithea/templates/pullrequests/pullrequest.html	Mon Sep 08 13:38:56 2014 +0200
@@ -217,7 +217,6 @@
           url = url.replace(k,rev_data[k]);
       }
 
-      YUD.get('pull_request_overview').innerHTML = "${_('Loading ...')}";
       ypjax(url,'pull_request_overview', function(o){
           var jsdata = eval('('+YUD.get('jsdata').innerHTML+')');
           var r = new BranchRenderer('graph_canvas', 'graph_content_pr');