[Checkins] SVN: z3c.formjsdemo/trunk/src/z3c/formjsdemo/c The calculator also works again.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Jul 6 18:07:06 EDT 2007


Log message for revision 77545:
  The calculator also works again.
  

Changed:
  U   z3c.formjsdemo/trunk/src/z3c/formjsdemo/calculator/browser.py
  U   z3c.formjsdemo/trunk/src/z3c/formjsdemo/calculator/calculator.pt
  U   z3c.formjsdemo/trunk/src/z3c/formjsdemo/configure.zcml

-=-
Modified: z3c.formjsdemo/trunk/src/z3c/formjsdemo/calculator/browser.py
===================================================================
--- z3c.formjsdemo/trunk/src/z3c/formjsdemo/calculator/browser.py	2007-07-06 22:00:53 UTC (rev 77544)
+++ z3c.formjsdemo/trunk/src/z3c/formjsdemo/calculator/browser.py	2007-07-06 22:07:06 UTC (rev 77545)
@@ -1,3 +1,21 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Browser code for JS calculator demo.
+
+$Id: layer.py 75942 2007-05-24 14:53:46Z srichter $
+"""
+__docformat__="restructuredtext"
 import os.path
 import zope.interface
 from zope.viewlet.viewlet import CSSViewlet
@@ -3,5 +21,5 @@
 from z3c.form import form, button, field
 from z3c.formui import layout
-from z3c.formjs import jsbutton, jsevent, interfaces
+from z3c.formjs import jsaction, jsevent, interfaces
 
 CalculatorCSSViewlet = CSSViewlet('calculator.css')
@@ -10,10 +28,10 @@
 class IGridButton(interfaces.IJSButton):
     """A button within the grid."""
 
-class Literal(jsbutton.JSButton):
+class Literal(jsaction.JSButton):
     zope.interface.implements(IGridButton)
 
-class Operator(jsbutton.JSButton):
+class Operator(jsaction.JSButton):
     zope.interface.implements(IGridButton)
 
 class IButtons(zope.interface.Interface):
@@ -37,7 +55,7 @@
     equal = Operator(title=u'=')
     divide = Operator(title=u'/')
 
-    clear = jsbutton.JSButton(title=u"C")
+    clear = jsaction.JSButton(title=u"C")
 
 
 class GridButtonActions(button.ButtonActions):
@@ -68,8 +86,9 @@
         self.actions = GridButtonActions(self, self.request, self.context)
         self.actions.update()
 
-    @jsevent.handler(Operator)
-    def handleOperator(self, id):
+    @jsaction.handler(Operator)
+    def handleOperator(self, selector):
+        id = selector.widget.id
         return '''var operator = $("#operator .value").html();
                   var newOperator = $("#%s").val();
                   var current = $("#current .value").html();
@@ -85,14 +104,15 @@
                       current = eval(stack+operator+current);
                       stack = current;
                   }
-                  
+
                   $("#operator .value").html(operator);
                   $("#stack .value").html(stack);
                   $("#recentOperator .value").html("True");
                   $("#current .value").html(current);''' % id
 
-    @jsevent.handler(Literal)
-    def handleLiteral(self, id):
+    @jsaction.handler(Literal)
+    def handleLiteral(self, selector):
+        id = selector.widget.id
         return '''var recentOperator = $("#recentOperator .value").html();
                   var current = $("#current .value").html();
                   var number = $("#%s").val();
@@ -104,8 +124,8 @@
                   $("#recentOperator .value").html("");
                   ''' % id
 
-    @jsevent.handler(buttons['clear'])
-    def handlerClear(self, id):
+    @jsaction.handler(buttons['clear'])
+    def handlerClear(self, selector):
         return '''$("#stack .value").html("");
                   $("#current .value").html("");
                   $("#operator .value").html("");

Modified: z3c.formjsdemo/trunk/src/z3c/formjsdemo/calculator/calculator.pt
===================================================================
--- z3c.formjsdemo/trunk/src/z3c/formjsdemo/calculator/calculator.pt	2007-07-06 22:00:53 UTC (rev 77544)
+++ z3c.formjsdemo/trunk/src/z3c/formjsdemo/calculator/calculator.pt	2007-07-06 22:07:06 UTC (rev 77545)
@@ -22,6 +22,8 @@
     </div>
   </div>
   <div metal:use-macro="macro:form">
+    <div metal:fill-slot="info"
+         tal:replace="nothing" />
     <div id="buttons" metal:fill-slot="buttons">
       <table>
         <tr tal:repeat="row view/actions/grid">
@@ -41,6 +43,3 @@
     >Digital Readout</a> font installed.
   <p>
 </div>
-<script type="text/javascript"
-	tal:content="view/jsevents:renderer/render">
-</script>
\ No newline at end of file

Modified: z3c.formjsdemo/trunk/src/z3c/formjsdemo/configure.zcml
===================================================================
--- z3c.formjsdemo/trunk/src/z3c/formjsdemo/configure.zcml	2007-07-06 22:00:53 UTC (rev 77544)
+++ z3c.formjsdemo/trunk/src/z3c/formjsdemo/configure.zcml	2007-07-06 22:07:06 UTC (rev 77545)
@@ -14,7 +14,7 @@
   <!-- Examples -->
 
   <include package=".button" />
-  <!--include package=".calculator" /-->
+  <include package=".calculator" />
   <!--include package=".validator" /-->
 
 </configure>



More information about the Checkins mailing list