Author: jmorliaguet
Date: Sun Mar 19 18:11:33 2006
New Revision: 2664

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/panels/views.py
   cpsskins/branches/jmo-perspectives/ui/screens/sitedesigner/views.py
Log:

- simplifications



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 
18:11:33 2006
@@ -603,36 +603,11 @@
   clickEvent: function(e) {
     var target = Event.element(e);
     if (target.tagName.toLowerCase() == 'a') {
-      var href = target.href;
-      var views = this.views;
 
-      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);
+      this.views.entries().each(function(v) {
+        var view = CPSSkins.getViewById(v);
+        view.model.setData({'url': target.href});
+      })
 
       Event.stop(e);
     }
@@ -1620,8 +1595,11 @@
         "data": JSON.stringify(data)
         }).toQueryString(),
       onComplete: function(req) {
-        var data = JSON.parse(req.responseText);
-        storage.write(data);
+        var content_type = req.getResponseHeader('content-type');
+        if (content_type.match(/^text\/x-json/)) {
+          var data = JSON.parse(req.responseText);
+          storage.write(data);
+        }
       }
     });
   }
@@ -1967,18 +1945,25 @@
     if (url) {
       var widget = this.widget;
       var options = {
-        onComplete: function() {
-          CPSSkins._parse(widget);
-          view.attachControllers();
+        onComplete: function(req) {
+          var disp = req.getResponseHeader('content-disposition');
+          if (disp && disp.match(/^attachment/)) {
+            window.location = url;
+          } else {
+            widget.innerHTML = req.responseText;
+            CPSSkins._parse(widget);
+            view.attachControllers();
+          }
         }
       };
 
       var parts = url.split('?');
+      var method = url;
       if (parts.length == 2) {
-        url = parts[0];
+        method = parts[0];
         options.parameters = parts[1];
       }
-      new Ajax.Updater(widget, url, options);
+      new Ajax.Request(method, options);
     }
   },
 

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/panels/views.py
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/panels/views.py
      (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/panels/views.py
      Sun Mar 19 18:11:33 2006
@@ -6,4 +6,5 @@
 class FormAction(BrowserView):
 
     def doSomething(self):
+        self.request.response.setHeader('content-type', 'text/x-json')
         return json.write({'url': '@@panels-form.html?updated=1'})

Modified: cpsskins/branches/jmo-perspectives/ui/screens/sitedesigner/views.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/screens/sitedesigner/views.py 
(original)
+++ cpsskins/branches/jmo-perspectives/ui/screens/sitedesigner/views.py Sun Mar 
19 18:11:33 2006
@@ -22,6 +22,7 @@
 from zope.component import getUtilitiesFor, getUtility, getMultiAdapter
 from zope.component import queryUtility, getAllUtilitiesRegisteredFor
 
+from cpsskins import minjson as json
 from cpsskins.elements.interfaces import IType
 from cpsskins.setup.interfaces import ISetting, IGlobalSetting
 from cpsskins.setup.interfaces import IResourceType, IResourceManager, 
IResource
@@ -58,6 +59,7 @@
 
         resources = getUtility(IResourceManager)
         resources.customize(name=name, context=self.context)
+        self.request.response.redirect('@@settings-section.html')
 
     def decustomizeSetting(self, name=u''):
         if not name:
@@ -65,6 +67,7 @@
 
         resources = getUtility(IResourceManager)
         resources.decustomize(name=name, context=self.context)
+        self.request.response.redirect('@@settings-section.html')
 
     def removeSetting(self, name=u''):
         if not name:
@@ -72,6 +75,7 @@
 
         resources = getUtility(IResourceManager)
         resources.unregister(name=name, context=self.context)
+        self.request.response.redirect('@@settings-section.html')
 
     def exportSetting(self, name=u''):
         """Export the setting as an XML file.
@@ -98,6 +102,8 @@
         # remove the xml header used in the resource
         resource_xml = exporter().replace('<?xml version="1.0"?>', '')
 
+        response.setHeader('Location', 'settings-section.html')
+
         return setting_xml % {
             'name': name,
             'title': setting.title,
@@ -108,4 +114,4 @@
         """Reload the setting from the file-system
         """
         reloadSetting(name)
-
+        self.request.response.redirect('@@settings-section.html')
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to