Author: jmorliaguet
Date: Sun May 14 12:59:45 2006
New Revision: 3130

Modified:
   cpsskins/branches/paris-sprint-2006/standard/filters/style/style_editor.js
   cpsskins/branches/paris-sprint-2006/standard/filters/style/style_editor.pt
   cpsskins/branches/paris-sprint-2006/standard/filters/style/views.py
   cpsskins/branches/paris-sprint-2006/ui/editing/views.py
   cpsskins/branches/paris-sprint-2006/ui/panels/element_editor.pt

Log:

- added a 'display' tab.

- simplifications



Modified: 
cpsskins/branches/paris-sprint-2006/standard/filters/style/style_editor.js
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/filters/style/style_editor.js  
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/filters/style/style_editor.js  
Sun May 14 12:59:45 2006
@@ -2,12 +2,10 @@
 CPSSkins.addActions({
   'selectTag': function(info) {
     var target = info.target;
-    var saved_bg = target.saved_bg;
-    if (saved_bg) target.style.backgroundColor = saved_bg;
     var style_id = 
CPSSkins.getModelById('element-editor').getData().form.format;
     var selector = getSelectorInContext(target, $('previewArea'), style_id);
 
-    CPSSkins.getModelById('style-editor').updateData({'selector': selector, 
'style_id': style_id});
+    CPSSkins.getModelById('style-editor').updateData({selector: selector, 
style_id: style_id});
   },
 
   'updateLabel': function(info) {
@@ -30,8 +28,12 @@
       tag = node.tagName;
       if (!tag) break;
       tag = tag.toLowerCase();
-      classnames = node.className.replace(' style' + style_id, '').split(' ');
-      name = classnames.join('.');
+      classnames = node.className;
+      name = '';
+      if (classnames) {
+        classnames = classnames.replace(' style' + style_id, '').split(' ');
+        name = classnames.join('.');
+      }
       selector = name ? tag + '.' + name : tag;
 
       // ignore tags that have the "ignore" attribute set

Modified: 
cpsskins/branches/paris-sprint-2006/standard/filters/style/style_editor.pt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/filters/style/style_editor.pt  
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/filters/style/style_editor.pt  
Sun May 14 12:59:45 2006
@@ -1,10 +1,4 @@
-<tal:block define="displays context/findDisplays"
-           condition="displays">
-
-<div tal:define="display python: displays[0];
-                 id context/identifier;
-                 widget display/formattable:widget;
-                 widget_types widget/types">
+<div tal:define="widget_types view/getWidgetTypes">
 
   <ins class="model" tal:content="view/getModelDef" />
 
@@ -41,5 +35,3 @@
     </tr>
   </table>
 </div>
-
-</tal:block>

Modified: cpsskins/branches/paris-sprint-2006/standard/filters/style/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/filters/style/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/filters/style/views.py Sun May 
14 12:59:45 2006
@@ -25,6 +25,7 @@
 from cpsskins import configuration
 from cpsskins import minjson as json
 from cpsskins import utils
+from cpsskins.elements.interfaces import IFormattable
 from cpsskins.standard.formats.style import IStyle
 from cpsskins.utils import getThemeManager
 
@@ -40,6 +41,12 @@
         self.session = ISession(request)['cpsskins']
         self.tmutil = getThemeManager(context)
 
+    def getWidgetTypes(self):
+        display_id = self.request.form.get('display')
+        display = self.tmutil.getElementById(display_id)
+        widget = IFormattable(display).getFormat(u'widget')
+        return widget.types
+
     def renderWidgetPreview(self):
         """Render a style preview based on the specified widget.
         """
@@ -51,7 +58,7 @@
         widget = getUtility(configuration.IWidget, widget_type)
         markup = widget.view(None, None).renderPreview()
         markup = utils.insertCSSClass(markup, utils.camelize(widget_type))
-        markup = utils.insertCSSClass(markup, u'style' + style_id)
+        markup = utils.insertCSSClass(markup, u'style' + str(style_id))
         return markup
 
     def getModelDef(self):

Modified: cpsskins/branches/paris-sprint-2006/ui/editing/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/editing/views.py     (original)
+++ cpsskins/branches/paris-sprint-2006/ui/editing/views.py     Sun May 14 
12:59:45 2006
@@ -130,8 +130,8 @@
         tmutil = getThemeManager(context)
 
         form = request.form
-        format_name = form.get('format')
         element_id = form.get('id')
+        tab = form.get('tab')
 
         negotiation = getMultiAdapter((context, request),
                                       INegotiation, 'negotiation')
@@ -140,8 +140,13 @@
         display = displayable.getEffectiveDisplay(perspective)
         formattable = IFormattable(display)
 
-        # Edited element
         edited = context
+
+        display_name = IType(display).getTypeName()
+        if tab == display_name:
+            edited = display
+
+        # Element
         element_info = {
             'name': IType(context).getTypeName(),
             'id': context.identifier,
@@ -155,12 +160,11 @@
             if is_setting:
                 f = IResource(f).getResource()
 
-            name = IType(f).getTypeName()
-            selected = name == format_name
-            if selected:
+            format_name = IType(f).getTypeName()
+            if tab == format_name:
                 edited = f
 
-            formats_info.append({'name': name})
+            formats_info.append({'name': format_name, 'id': f.identifier})
 
         viewer = getMultiAdapter((context, request), IViewer)
         preview = viewer()

Modified: cpsskins/branches/paris-sprint-2006/ui/panels/element_editor.pt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/panels/element_editor.pt     
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/panels/element_editor.pt     Sun May 
14 12:59:45 2006
@@ -6,6 +6,7 @@
             element python: tmutil.getElementById(id);
             info element/@@editpanel/getInfo;
             display nocall:info/display;
+            display_id display/identifier;
             edited nocall:info/edited">
 
   <a class="back"
@@ -24,18 +25,23 @@
   <div class="tabs">
     <a i18n:translate=""
        tal:attributes="
-         href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({'form': 
{'id': '$id', 'format': '', 'mode': 'edit'}})"
+         href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({form: 
{id: '$id', mode: 'edit'}})"
        tal:content="info/element/name" />
 
     <a i18n:translate=""
+       tal:attributes="
+         href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({form: 
{id: $id, tab: '${display/type:name}'}})"
+       tal:content="display/type:name" />
+
+    <a i18n:translate=""
        tal:repeat="format info/formats"
        tal:attributes="
-         href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({'script': 
'/++skin++cpsskins/++resource++style_editor.js', 'form': {'id': $id, 'format': 
'${format/name}'}})"
+         href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({script: 
'/++skin++cpsskins/++resource++style_editor.js', form: {id: $id, display: 
$display_id, format: ${format/id}, tab: '${format/name}'}})"
        tal:content="format/name" />
 
     <a i18n:translate=""
        tal:attributes="
-         href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({'form': 
{'id': '$id', 'format': '', 'mode': 'preview'}})">Preview</a>
+         href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({form: 
{id: '$id', mode: 'preview'}})">Preview</a>
 
   </div>
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to