Author: jmorliaguet
Date: Sun Mar 19 15:38:31 2006
New Revision: 2661

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
Log:

- Location Controller: simpler usage, added support for response headers
  (attachments),



Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Sun Mar 19 
15:38:31 2006
@@ -603,15 +603,36 @@
   clickEvent: function(e) {
     var target = Event.element(e);
     if (target.tagName.toLowerCase() == 'a') {
-      var url = target.href;
-
+      var href = target.href;
       var views = this.views;
-      var location_field = this.def.location_field || 'url';
-      views.each(function(v) {
-        var view = CPSSkins.getViewById(v);
-        var model = view.model;
-        if (model) model.setData({location_field: url});
-      });
+
+      var options = {
+        onComplete: function(req) {
+          var resp = req.responseText;
+          var disp = req.getResponseHeader('content-disposition');
+          if (disp && disp.match(/^attachment/)) {
+            window.location = href;
+          }
+          if (resp) {
+            var data = JSON.parse(resp);
+          }
+          views.entries().each(function(v) {
+            var view = CPSSkins.getViewById(v);
+            if (data) {
+              view.model.setData(data);
+            } else {
+              view.refresh();
+            }
+          });
+        }
+      }
+
+      var parts = href.split('?');
+      if (parts.length == 2) {
+        url = parts[0];
+        options.parameters = parts[1];
+      }
+      new Ajax.Request(url, options);
 
       Event.stop(e);
     }
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to