Author: jvloothuis
Date: Thu Oct 11 10:22:31 2007
New Revision: 47387
Modified:
kukit/kss.base/trunk/kss/base/corecommands.py
kukit/kss.base/trunk/kss/base/corecommands.txt
Log:
Started with the implementation of the core command set
Modified: kukit/kss.base/trunk/kss/base/corecommands.py
==============================================================================
--- kukit/kss.base/trunk/kss/base/corecommands.py (original)
+++ kukit/kss.base/trunk/kss/base/corecommands.py Thu Oct 11 10:22:31 2007
@@ -1,13 +1,6 @@
from kss.base.commands import KSSCommandSet
class KSSCoreCommands(KSSCommandSet):
-
- def replaceInnerHTML(self, selector, value):
- self.commands.add('replaceInnerHTML', selector, html=value)
-
- def replaceHTML(self, selector, value):
- self.commands.add('replaceHTML', selector, html=value)
-
def setAttribute(self, selector, name, value):
self.commands.add('setAttribute', selector, name=name, value=value)
@@ -17,6 +10,30 @@
raise ValueError('Style properites cannot contain spaces')
self.commands.add('setStyle', selector, name=name, value=value)
+ def addClass(self, selector, value):
+ self.commands.add('addClass', selector, value=value)
+
+ def removeClass(self, selector, value):
+ self.commands.add('removeClass', selector, value=value)
+
+ def toggleClass(self, selector, value):
+ self.commands.add('toggleClass', selector, value=value)
+
+ def focus(self, selector):
+ self.commands.add('focus', selector)
+
+
+
+ def replaceInnerHTML(self, selector, value):
+ """Replace the contents of a node (selector) with the new `value`"""
+ self.commands.add('replaceInnerHTML', selector, html=value)
+
+ def replaceHTML(self, selector, value):
+ self.commands.add('replaceHTML', selector, html=value)
+
+
+ def insertHTMLBefore(self, selector, value):
+ self.commands.add('insertHTMLBefore', selector, html=value)
def insertHTMLAfter(self, selector, value):
self.commands.add('insertHTMLAfter', selector, html=value)
@@ -27,73 +44,45 @@
def insertHTMLAsLastChild(self, selector, value):
self.commands.add('insertHTMLAsLastChild', selector, html=value)
- def insertHTMLBefore(self, selector, value):
- self.commands.add('insertHTMLBefore', selector, html=value)
-
- def clearChildNodes(self, selector):
- self.commands.add('clearChildNodes', selector)
-
def deleteNode(self, selector):
self.commands.add('deleteNode', selector)
- def deleteNodeAfter(self, selector):
- self.commands.add('deleteNodeAfter', selector)
-
def deleteNodeBefore(self, selector):
self.commands.add('deleteNodeBefore', selector)
+ def deleteNodeAfter(self, selector):
+ self.commands.add('deleteNodeAfter', selector)
+ def clearChildNodes(self, selector):
+ self.commands.add('clearChildNodes', selector)
+
+
def copyChildNodesFrom(self, selector, id):
self.commands.add('copyChildNodesFrom', selector, html_id=id)
- def moveNodeAfter(self, selector, id):
- self.commands.add('moveNodeAfter', selector, html_id=id)
+ def copyChildNodesTo(self, selector, id):
+ self.commands.add('copyChildNodesTo', selector, html_id=id)
+
+
def moveNodeBefore(self, selector, id):
self.commands.add('moveNodeBefore', selector, html_id=id)
- def copyChildNodesTo(self, selector, id):
- self.commands.add('copyChildNodesTo', selector, html_id=id)
+ def moveNodeAfter(self, selector, id):
+ self.commands.add('moveNodeAfter', selector, html_id=id)
+ # TODO: Selector less actions
def setStateVar(self, varname, value):
selector = None
self.commands.add('setStateVar', selector, varname=varname,
value=value)
- def triggerEvent(self, name, **kw):
+ def triggerEvent(self, name, **kwargs):
self.commands.add('triggerEvent', name=name, **kwargs)
- def toggleClass(self, selector, *arg, **kw):
- ##def toggleClass(self, selector, value):
- """ see interfaces.py """
- # BBB 4 months, until 2007-10-18
- value = BBB_classParms('toggleClass', *arg, **kw)
-
- command = self.commands.addCommand('toggleClass', selector)
- data = command.addParam('value', value)
-
- def addClass(self, selector, *arg, **kw):
- ##def addClass(self, selector, name):
- """ see interfaces.py """
- # BBB 4 months, until 2007-10-18
- value = BBB_classParms('addClass', *arg, **kw)
-
- command = self.commands.addCommand('addClass', selector)
- data = command.addParam('value', value)
-
- def removeClass(self, selector, *arg, **kw):
- ##def removeClass(self, selector, name):
- """ see interfaces.py """
- # BBB 4 months, until 2007-10-18
- value = BBB_classParms('removeClass', *arg, **kw)
- command = self.commands.addCommand('removeClass', selector)
- data = command.addParam('value', value)
- def focus(self, selector):
- """ see interfaces.py """
- command = self.commands.addCommand('focus', selector)
Modified: kukit/kss.base/trunk/kss/base/corecommands.txt
==============================================================================
--- kukit/kss.base/trunk/kss/base/corecommands.txt (original)
+++ kukit/kss.base/trunk/kss/base/corecommands.txt Thu Oct 11 10:22:31 2007
@@ -20,6 +20,9 @@
>>> commands.render()
'...replaceInnerHTML...some <h1>html</h1>...'
+-----------------
+Node modification
+-----------------
Set attribute
-------------
@@ -37,4 +40,176 @@
>>> print commands
setStyle(css('div'), name='somename', value='some value')
+Add class
+---------
+
+ >>> commands.clear()
+ >>> core.addClass(CSS('div'), 'somename')
+ >>> print commands
+ addClass(css('div'), value='somename')
+
+
+Remove class
+------------
+
+ >>> commands.clear()
+ >>> core.removeClass(CSS('div'), 'somename')
+ >>> print commands
+ removeClass(css('div'), value='somename')
+
+Toggle class
+------------
+
+ >>> commands.clear()
+ >>> core.toggleClass(CSS('div'), 'somename')
+ >>> print commands
+ toggleClass(css('div'), value='somename')
+
+
+Focus
+-----
+
+ >>> commands.clear()
+ >>> core.focus(CSS('div'))
+ >>> print commands
+ focus(css('div'))
+
+----------------
+HTML replacement
+----------------
+
+Replace inner HTML
+------------------
+
+ >>> commands.clear()
+ >>> core.replaceInnerHTML(CSS('div'), 'some html')
+ >>> print commands
+ replaceInnerHTML(css('div'), html='some html')
+
+Replace HTML
+------------
+
+ >>> commands.clear()
+ >>> core.replaceHTML(CSS('div'), 'some html')
+ >>> print commands
+ replaceHTML(css('div'), html='some html')
+
+
+--------------
+HTML insertion
+--------------
+
+Insert HTML before
+------------------
+
+ >>> commands.clear()
+ >>> core.insertHTMLBefore(CSS('div'), 'some html')
+ >>> print commands
+ insertHTMLBefore(css('div'), html='some html')
+
+Insert HTML after
+-----------------
+
+ >>> commands.clear()
+ >>> core.insertHTMLAfter(CSS('div'), 'some html')
+ >>> print commands
+ insertHTMLAfter(css('div'), html='some html')
+
+Insert HTML as first child
+--------------------------
+
+ >>> commands.clear()
+ >>> core.insertHTMLAsFirstChild(CSS('div'), 'some html')
+ >>> print commands
+ insertHTMLAsFirstChild(css('div'), html='some html')
+
+Insert HTML as last child
+--------------------------
+
+ >>> commands.clear()
+ >>> core.insertHTMLAsLastChild(CSS('div'), 'some html')
+ >>> print commands
+ insertHTMLAsLastChild(css('div'), html='some html')
+
+
+------------
+Node removal
+------------
+
+Delete node
+-----------
+
+ >>> commands.clear()
+ >>> core.deleteNode(CSS('div'))
+ >>> print commands
+ deleteNode(css('div'))
+
+Delete node before
+------------------
+
+ >>> commands.clear()
+ >>> core.deleteNodeBefore(CSS('div'))
+ >>> print commands
+ deleteNodeBefore(css('div'))
+
+Delete node after
+-----------------
+
+ >>> commands.clear()
+ >>> core.deleteNodeAfter(CSS('div'))
+ >>> print commands
+ deleteNodeAfter(css('div'))
+
+Clear child nodes
+-----------------
+
+ >>> commands.clear()
+ >>> core.focus(CSS('div'))
+ >>> print commands
+ focus(css('div'))
+
+
+-------------
+Copying nodes
+-------------
+
+Copy child nodes from
+----------------------
+
+ >>> commands.clear()
+ >>> core.copyChildNodesFrom(CSS('div'), 'nodeid')
+ >>> print commands
+ copyChildNodesFrom(css('div'), html_id='nodeid')
+
+
+Copy child nodes to
+-------------------
+
+ >>> commands.clear()
+ >>> core.copyChildNodesTo(CSS('div'), 'nodeid')
+ >>> print commands
+ copyChildNodesTo(css('div'), html_id='nodeid')
+
+
+------------
+Moving nodes
+------------
+
+Move node before
+----------------
+
+ >>> commands.clear()
+ >>> core.moveNodeBefore(CSS('div'), 'nodeid')
+ >>> print commands
+ moveNodeBefore(css('div'), html_id='nodeid')
+
+Move node after
+---------------
+
+ >>> commands.clear()
+ >>> core.moveNodeAfter(CSS('div'), 'nodeid')
+ >>> print commands
+ moveNodeAfter(css('div'), html_id='nodeid')
+
+
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins