MTrackWeb/templates/images/js/mtrack2.js
authorAlan Knowles <alan@akbkhome.com>
Sat, 21 May 2011 15:21:58 +0000 (23:21 +0800)
committerAlan Knowles <alan@akbkhome.com>
Sat, 21 May 2011 15:21:58 +0000 (23:21 +0800)
MTrackWeb/templates/images/js/mtrack2.js

index fc1a1d1..aca81ab 100644 (file)
@@ -9,7 +9,8 @@
  * then whenever html is loaded via AJAX, we can run run through the handlers and add them.
  * 
  */
+
+
  
 MTrack = {
     
@@ -57,7 +58,87 @@ MTrack = {
         //    sortable: false
         //});
       
-    }
+    },
+    
+    currentURL : false,
+    missingHashRequest : false,
+    
+    
+    // This is the main body load tool...
+    // it still needs to handle anchors...
+    
+    
+    ajaxLoad : function(url,slideleft)
+    { 
+        this.currentURL = url;
+        var target = Roo.get("ajaxbody");
+        var content = Roo.get("content");
+        target.setStyle('position', 'relative');
+        
+        Roo.select('.mask').show(); // must show first?
+        Roo.select('.mask-loading').show();
+        // content has a border...
+        var t = content.getBox().top - Roo.get(document).getScroll().top - 13;
+        var l = content.getBox().left - Roo.get(document).getScroll().top - 13;
+        var w = content.getBox().width+ 26;
+        var h = content.getBox().height + 26;
+     
+        Roo.select('.mask').first().setLocation(l,t);
+        Roo.select('.mask').first().setSize( w , h, false  );
+        
+        Roo.select('.mask-loading').first().setLocation(
+                l + ( w / 2) - 16, t +   16 
+        );
+        
+        if (MTrack.missingHashRequest) {
+            MTrack.missingHashRequest.abort();
+            MTrack.missingHashRequest = false;
+        }
+        Roo.get('loader').hide();
+        Roo.Ajax.request({
+            url : baseURL + url,
+            params : { ajax_body : 1 },
+            success : function(data) {
+                
+                Roo.select('.mask').hide();
+                Roo.get('loader').update(data);
+                Roo.get('loader').show();
+                Roo.get('loader').setWidth( w );
+                Roo.get('loader').setPosition( slideleft?  l+w : l-w , t  );
+                
+                target.animate(
+                    {
+                        left: slideleft ? -1 * w  : w
+                    },
+                    500,
+                    function() {
+                        target.setPosition(  0, 0 ); // reset it at end of animation - as it ends up with the new content.
+                    }
+                );
+                
+                Roo.get('loader').animate(
+                    {
+                            left: l+13
+                    },
+                    500,
+                    function () {
+                        target.update( Roo.get('loader').dom.innerHTML);
+                        Roo.get('loader').hide();
+                        Roo.get('loader').update("");
+                        target.show();// make sure!!
+                    
+                        MTrack.missingHashes(target,  url);
+                        MTrack.addHandlers(target);
+                    }
+                );
+            }
+            //console.log('loaded dif');
+            
+               
+        });
+      
+        return false;  
+
     
 }
 
@@ -86,7 +167,7 @@ Roo.onReady(function() {
 // any date picers.. - on milestones?
 MTrack.register('.dateinput', 'each', function(e) {
     var ee = new Roo.form.DateField({
-        dateFormat: 'yy-mm-dd' // nice and compatible..
+        dateFormat: 'Y-m-d' // nice and compatible..
     });
     ee.applyTo(e);
     // minDate: 0,