forked from viur-framework/html5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.py
2993 lines (2072 loc) · 66.5 KB
/
core.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import logging, string
########################################################################################################################
# DOM-access functions and variables
########################################################################################################################
try:
# Pyodide
from js import window, eval as jseval
document = window.document
except:
print("Emulation mode")
from xml.dom.minidom import parseString
jseval = None
window = None
document = parseString("<html><head /><body /></html>")
def domCreateAttribute(tag, ns=None):
"""
Creates a new HTML/SVG/... attribute
:param ns: the namespace. Default: HTML. Possible values: HTML, SVG, XBL, XUL
"""
uri = None
if ns == "SVG":
uri = "http://www.w3.org/2000/svg"
elif ns == "XBL":
uri = "http://www.mozilla.org/xbl"
elif ns == "XUL":
uri = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
if uri:
return document.createAttribute(uri, tag)
return document.createAttribute(tag)
def domCreateElement(tag, ns=None):
"""
Creates a new HTML/SVG/... tag
:param ns: the namespace. Default: HTML. Possible values: HTML, SVG, XBL, XUL
"""
uri = None
if ns == "SVG":
uri = "http://www.w3.org/2000/svg"
elif ns == "XBL":
uri = "http://www.mozilla.org/xbl"
elif ns == "XUL":
uri = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
if uri:
return document.createElementNS(uri, tag)
return document.createElement(tag)
def domCreateTextNode(txt=""):
return document.createTextNode(txt)
def domGetElementById(idTag):
return document.getElementById(idTag)
def domElementFromPoint(x, y):
return document.elementFromPoint(x, y)
def domGetElementsByTagName(tag):
items = document.getElementsByTagName(tag)
return [items.item(i) for i in range(0, int(items.length))] #pyodide interprets items.length as float, so convert to int
########################################################################################################################
# HTML Widgets
########################################################################################################################
# TextNode -------------------------------------------------------------------------------------------------------------
class TextNode(object):
"""
Represents a piece of text inside the DOM.
This is the *only* object not deriving from "Widget", as it does
not support any of its properties.
"""
def __init__(self, txt=None, *args, **kwargs):
super().__init__()
self._parent = None
self._children = []
self.element = domCreateTextNode(txt or "")
self._isAttached = False
def _setText(self, txt):
self.element.data = txt
def _getText(self):
return self.element.data
def __str__(self):
return self.element.data
def onAttach(self):
self._isAttached = True
def onDetach(self):
self._isAttached = False
def _setDisabled(self, disabled):
return
def _getDisabled(self):
return False
def children(self):
return []
# _WidgetClassWrapper -------------------------------------------------------------------------------------------------
class _WidgetClassWrapper(list):
def __init__(self, targetWidget):
super().__init__()
self.targetWidget = targetWidget
# Initially read content of element into current wrappper
value = targetWidget.element.getAttribute("class")
if value:
for c in value.split(" "):
list.append(self, c)
def set(self, value):
if value is None:
value = []
elif isinstance(value, str):
value = value.split(" ")
elif not isinstance(value, list):
raise ValueError("Value must be a str, a List or None")
list.clear(self)
list.extend(self, value)
self._updateElem()
def _updateElem(self):
if len(self) == 0:
self.targetWidget.element.removeAttribute("class")
else:
self.targetWidget.element.setAttribute("class", " ".join(self))
def append(self, p_object):
list.append(self, p_object)
self._updateElem()
def clear(self):
list.clear(self)
self._updateElem()
def remove(self, value):
try:
list.remove(self, value)
except:
pass
self._updateElem()
def extend(self, iterable):
list.extend(self, iterable)
self._updateElem()
def insert(self, index, p_object):
list.insert(self, index, p_object)
self._updateElem()
def pop(self, index=None):
list.pop(self, index)
self._updateElem()
# _WidgetDataWrapper ---------------------------------------------------------------------------------------------------
class _WidgetDataWrapper(dict):
def __init__(self, targetWidget):
super().__init__()
self.targetWidget = targetWidget
alldata = targetWidget.element
for data in dir(alldata.dataset):
dict.__setitem__(self, data, getattr(alldata.dataset, data))
def __setitem__(self, key, value):
dict.__setitem__(self, key, value)
self.targetWidget.element.setAttribute(str("data-" + key), value)
def update(self, E=None, **F):
dict.update(self, E, **F)
if E is not None and "keys" in dir(E):
for key in E:
self.targetWidget.element.setAttribute(str("data-" + key), E["data-" + key])
elif E:
for (key, val) in E:
self.targetWidget.element.setAttribute(str("data-" + key), "data-" + val)
for key in F:
self.targetWidget.element.setAttribute(str("data-" + key), F["data-" + key])
# _WidgetStyleWrapper --------------------------------------------------------------------------------------------------
class _WidgetStyleWrapper(dict):
def __init__(self, targetWidget):
super().__init__()
self.targetWidget = targetWidget
style = targetWidget.element.style
for key in dir(style):
# Convert JS-Style-Syntax to CSS Syntax (ie borderTop -> border-top)
realKey = ""
for currChar in key:
if currChar.isupper():
realKey += "-"
realKey += currChar.lower()
val = style.getPropertyValue(realKey)
if val:
dict.__setitem__(self, realKey, val)
def __setitem__(self, key, value):
dict.__setitem__(self, key, value)
self.targetWidget.element.style.setProperty(key, value)
def update(self, E=None, **F):
dict.update(self, E, **F)
if E is not None and "keys" in dir(E):
for key in E:
self.targetWidget.element.style.setProperty(key, E[key])
elif E:
for (key, val) in E:
self.targetWidget.element.style.setProperty(key, val)
for key in F:
self.targetWidget.element.style.setProperty(key, F[key])
# Widget ---------------------------------------------------------------------------------------------------------------
class Widget(object):
_tagName = None # Defines the tag-name that is used for DOM-Element construction
_leafTag = False # Defines whether ths Widget may contain other Widgets (default) or is a leaf
_namespace = None # Namespace
_parserTagName = None # Alternative tag name under which this Widget is registered in HTML parser
style = [] # CSS-classes to directly assign to this Widget at construction.
def __init__(self, *args, appendTo=None, style=None, **kwargs):
if "_wrapElem" in kwargs.keys():
self.element = kwargs["_wrapElem"]
del kwargs["_wrapElem"]
else:
assert self._tagName is not None
self.element = domCreateElement(self._tagName, ns=self._namespace)
self._widgetClassWrapper = None
super().__init__()
self.addClass(self.style)
if style:
self.addClass(style)
self._children = []
self._catchedEvents = {}
self._disabledState = 0
self._isAttached = False
self._parent = None
if args:
self.appendChild(*args, **kwargs)
if appendTo:
appendTo.appendChild(self)
def sinkEvent(self, *args):
for event_attrName in args:
event = event_attrName.lower()
if event_attrName in self._catchedEvents or event in ["onattach", "ondetach"]:
continue
eventFn = getattr(self, event_attrName, None)
assert eventFn and callable(eventFn), "{} must provide a {} method".format(str(self), event_attrName)
self._catchedEvents[event_attrName] = eventFn
if event.startswith("on"):
event = event[2:]
self.element.addEventListener(event, eventFn)
def unsinkEvent(self, *args):
for event_attrName in args:
event = event_attrName.lower()
if event_attrName not in self._catchedEvents:
continue
eventFn = self._catchedEvents[event_attrName]
del self._catchedEvents[event_attrName]
if event.startswith("on"):
event = event[2:]
self.element.removeEventListener(event, eventFn)
def disable(self):
"""
Disables an element, in case it is not already disabled.
On disabled elements, events are not triggered anymore.
"""
if not self["disabled"]:
self["disabled"] = True
def enable(self):
"""
Enables an element, in case it is not already enabled.
"""
if self["disabled"]:
self["disabled"] = False
def _getTargetfuncName(self, key, type):
assert type in ["get", "set"]
return "_{}{}{}".format(type, key[0].upper(), key[1:])
def __getitem__(self, key):
funcName = self._getTargetfuncName(key, "get")
if funcName in dir(self):
return getattr(self, funcName)()
return None
def __setitem__(self, key, value):
funcName = self._getTargetfuncName(key, "set")
if funcName in dir(self):
return getattr(self, funcName)(value)
raise ValueError("{} is no valid attribute for {}".format(key, (self._tagName or str(self))))
def __str__(self):
return str(self.__class__.__name__)
def __iter__(self):
return self._children.__iter__()
def _getData(self):
"""
Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.
:param name:
:returns:
"""
return _WidgetDataWrapper(self)
def _getTranslate(self):
"""
Specifies whether an elements attribute values and contents of its children are to be translated when the page is localized, or whether to leave them unchanged.
:returns: True | False
"""
return True if self.element.translate == "yes" else False
def _setTranslate(self, val):
"""
Specifies whether an elements attribute values and contents of its children are to be translated when the page is localized, or whether to leave them unchanged.
:param val: True | False
"""
self.element.translate = "yes" if val == True else "no"
def _getTitle(self):
"""
Advisory information associated with the element.
:returns: str
"""
return self.element.title
def _setTitle(self, val):
"""
Advisory information associated with the element.
:param val: str
"""
self.element.title = val
def _getTabindex(self):
"""
Specifies whether the element represents an element that is is focusable (that is, an element which is part of the sequence of focusable elements in the document), and the relative order of the element in the sequence of focusable elements in the document.
:returns: number
"""
return self.element.getAttribute("tabindex")
def _setTabindex(self, val):
"""
Specifies whether the element represents an element that is is focusable (that is, an element which is part of the sequence of focusable elements in the document), and the relative order of the element in the sequence of focusable elements in the document.
:param val: number
"""
self.element.setAttribute("tabindex", val)
def _getSpellcheck(self):
"""
Specifies whether the element represents an element whose contents are subject to spell checking and grammar checking.
:returns: True | False
"""
return True if self.element.spellcheck == "true" else False
def _setSpellcheck(self, val):
"""
Specifies whether the element represents an element whose contents are subject to spell checking and grammar checking.
:param val: True | False
"""
self.element.spellcheck = str(val).lower()
def _getLang(self):
"""
Specifies the primary language for the contents of the element and for any of the elements attributes that contain text.
:returns: language tag e.g. de|en|fr|es|it|ru|
"""
return self.element.lang
def _setLang(self, val):
"""
Specifies the primary language for the contents of the element and for any of the elements attributes that contain text.
:param val: language tag
"""
self.element.lang = val
def _getHidden(self):
"""
Specifies that the element represents an element that is not yet, or is no longer, relevant.
:returns: True | False
"""
return True if self.element.hasAttribute("hidden") else False
def _setHidden(self, val):
"""
Specifies that the element represents an element that is not yet, or is no longer, relevant.
:param val: True | False
"""
if val:
self.element.setAttribute("hidden", "")
self.addClass("is-hidden")
else:
self.element.removeAttribute("hidden")
self.removeClass("is-hidden")
def _getDisabled(self):
return bool(self._disabledState)
def _setDisabled(self, disable):
for child in self._children:
child._setDisabled(disable)
if disable:
self._disabledState += 1
if isinstance(self, _attrDisabled) and self._disabledState == 1:
self.element.disabled = True
elif self._disabledState > 0:
if isinstance(self, _attrDisabled) and self._disabledState == 1:
self.element.disabled = False
self._disabledState -= 1
def _getDropzone(self):
"""
Specifies what types of content can be dropped on the element, and instructs the UA about which actions to take with content when it is dropped on the element.
:returns: "copy" | "move" | "link"
"""
return self.element.dropzone
def _setDropzone(self, val):
"""
Specifies what types of content can be dropped on the element, and instructs the UA about which actions to take with content when it is dropped on the element.
:param val: "copy" | "move" | "link"
"""
self.element.dropzone = val
def _getDraggable(self):
"""
Specifies whether the element is draggable.
:returns: True | False | "auto"
"""
return (self.element.draggable if str(self.element.draggable) == "auto" else (
True if str(self.element.draggable).lower() == "true" else False))
def _setDraggable(self, val):
"""
Specifies whether the element is draggable.
:param val: True | False | "auto"
"""
self.element.draggable = str(val).lower()
def _getDir(self):
"""
Specifies the elements text directionality.
:returns: ltr | rtl | auto
"""
return self.element.dir
def _setDir(self, val):
"""
Specifies the elements text directionality.
:param val: ltr | rtl | auto
"""
self.element.dir = val
def _getContextmenu(self):
"""
The value of the id attribute on the menu with which to associate the element as a context menu.
:returns:
"""
return self.element.contextmenu
def _setContextmenu(self, val):
"""
The value of the id attribute on the menu with which to associate the element as a context menu.
:param val:
"""
self.element.contextmenu = val
def _getContenteditable(self):
"""
Specifies whether the contents of the element are editable.
:returns: True | False
"""
v = self.element.getAttribute("contenteditable")
return str(v).lower() == "true"
def _setContenteditable(self, val):
"""
Specifies whether the contents of the element are editable.
:param val: True | False
"""
self.element.setAttribute("contenteditable", str(val).lower())
def _getAccesskey(self):
"""
A key label or list of key labels with which to associate the element; each key label represents a keyboard shortcut which UAs can use to activate the element or give focus to the element.
:param self:
:returns:
"""
return self.element.accesskey
def _setAccesskey(self, val):
"""
A key label or list of key labels with which to associate the element; each key label represents a keyboard shortcut which UAs can use to activate the element or give focus to the element.
:param self:
:param val:
"""
self.element.accesskey = val
def _getId(self):
"""
Specifies a unique id for an element
:param self:
:returns:
"""
return self.element.id
def _setId(self, val):
"""
Specifies a unique id for an element
:param self:
:param val:
"""
self.element.id = val
def _getClass(self):
"""
The class attribute specifies one or more classnames for an element.
:returns:
"""
if self._widgetClassWrapper is None:
self._widgetClassWrapper = _WidgetClassWrapper(self)
return self._widgetClassWrapper
def _setClass(self, value):
"""
The class attribute specifies one or more classnames for an element.
:param self:
:param value:
@raise ValueError:
"""
self._getClass().set(value)
def _getStyle(self):
"""
The style attribute specifies an inline style for an element.
:param self:
:returns:
"""
return _WidgetStyleWrapper(self)
def _getRole(self):
"""
Specifies a role for an element
@param self:
@return:
"""
return self.element.getAttribute("role")
def _setRole(self, val):
"""
Specifies a role for an element
@param self:
@param val:
"""
self.element.setAttribute("role", val)
def hide(self):
"""
Hide element, if shown.
:return:
"""
if not self["hidden"]:
self["hidden"] = True
def show(self):
"""
Show element, if hidden.
:return:
"""
if self["hidden"]:
self["hidden"] = False
def isHidden(self):
"""
Checks if a widget is hidden.
:return: True if hidden, False otherwise.
"""
return self["hidden"]
def isVisible(self):
"""
Checks if a widget is visible.
:return: True if visible, False otherwise.
"""
return not self.isHidden()
def onBind(self, widget, name):
"""
Event function that is called on the widget when it is bound to another widget with a name.
This is only done by the HTML parser, a manual binding by the user is not triggered.
"""
return
def onAttach(self):
self._isAttached = True
for c in self._children:
c.onAttach()
def onDetach(self):
self._isAttached = False
for c in self._children:
c.onDetach()
def __collectChildren(self, *args, **kwargs):
if kwargs.get("bindTo") is None:
kwargs["bindTo"] = self
widgets = []
for arg in args:
if isinstance(arg, (str, HtmlAst)):
widgets.extend(fromHTML(arg, **kwargs))
elif isinstance(arg, (list, tuple)):
for subarg in arg:
widgets.extend(self.__collectChildren(subarg, **kwargs))
elif not isinstance(arg, (Widget, TextNode)):
widgets.append(TextNode(str(arg)))
else:
widgets.append(arg)
return widgets
def insertBefore(self, insert, child, **kwargs):
if not child:
return self.appendChild(insert)
assert child in self._children, "{} is not a child of {}".format(child, self)
toInsert = self.__collectChildren(insert, **kwargs)
for insert in toInsert:
if insert._parent:
insert._parent.removeChild(insert)
self.element.insertBefore(insert.element, child.element)
self._children.insert(self._children.index(child), insert)
insert._parent = self
if self._isAttached:
insert.onAttach()
return toInsert
def prependChild(self, *args, **kwargs):
if kwargs.get("replace", False):
self.removeAllChildren()
del kwargs["replace"]
toPrepend = self.__collectChildren(*args, **kwargs)
for child in toPrepend:
if child._parent:
child._parent._children.remove(child)
child._parent = None
if not self._children:
self.appendChild(child)
else:
self.insertBefore(child, self.children(0))
return toPrepend
def appendChild(self, *args, **kwargs):
if kwargs.get("replace", False):
self.removeAllChildren()
del kwargs["replace"]
toAppend = self.__collectChildren(*args, **kwargs)
for child in toAppend:
if isinstance(child, Template):
return self.appendChild(child._children)
if child._parent:
child._parent._children.remove(child)
self._children.append(child)
self.element.appendChild(child.element)
child._parent = self
if self._isAttached:
child.onAttach()
return toAppend
def removeChild(self, child):
assert child in self._children, "{} is not a child of {}".format(child, self)
if child._isAttached:
child.onDetach()
self.element.removeChild(child.element)
self._children.remove(child)
child._parent = None
def removeAllChildren(self):
"""
Removes all child widgets of the current widget.
"""
for child in self._children[:]:
self.removeChild(child)
def isParentOf(self, widget):
"""
Checks if an object is the parent of widget.
:type widget: Widget
:param widget: The widget to check for.
:return: True, if widget is a child of the object, else False.
"""
# You cannot be your own child!
if self == widget:
return False
for child in self._children:
if child == widget:
return True
if child.isParentOf(widget):
return True
return False
def isChildOf(self, widget):
"""
Checks if an object is the child of widget.
:type widget: Widget
:param widget: The widget to check for.
:return: True, if object is a child of widget, else False.
"""
# You cannot be your own parent!
if self == widget:
return False
parent = self.parent()
while parent:
if parent == widget:
return True
parent = widget.parent()
return False
def hasClass(self, className):
"""
Determine whether the current widget is assigned the given class
:param className: The class name to search for.
:type className: str
"""
if isinstance(className, str) or isinstance(className, unicode):
return className in self["class"]
else:
raise TypeError()
def addClass(self, *args):
"""
Adds a class or a list of classes to the current widget.
If the widget already has the class, it is ignored.
:param args: A list of class names. This can also be a list.
:type args: list of str | list of list of str
"""
for item in args:
if isinstance(item, list):
self.addClass(*item)
elif isinstance(item, str):
for sitem in item.split(" "):
if not self.hasClass(sitem):
self["class"].append(sitem)
else:
raise TypeError()
def hasClass(self, name):
"""
Checks whether the widget has class name set or unset.
:param name: The class-name to be checked.
:type args: str
"""
return name in self["class"]
def removeClass(self, *args):
"""
Removes a class or a list of classes from the current widget.
:param args: A list of class names. This can also be a list.
:type args: list of str | list of list of str
"""
for item in args:
if isinstance(item, list):
self.removeClass(item)
elif isinstance(item, str):
for sitem in item.split(" "):
if self.hasClass(sitem):
self["class"].remove(sitem)
else:
raise TypeError()
def toggleClass(self, on, off=None):
"""
Toggles the class ``on``.
If the widget contains a class ``on``, it is toggled by ``off``.
``off`` can either be a class name that is substituted, or nothing.
:param on: Classname to test for. If ``on`` does not exist, but ``off``, ``off`` is replaced by ``on``.
:type on: str
:param off: Classname to replace if ``on`` existed.
:type off: str
:return: Returns True, if ``on`` was switched, else False.
:rtype: bool
"""
if self.hasClass(on):
self.removeClass(on)
if off and not self.hasClass(off):
self.addClass(off)
return False
if off and self.hasClass(off):
self.removeClass(off)
self.addClass(on)
return True
def onBlur(self, event):
pass
def onChange(self, event):
pass
def onContextMenu(self, event):
pass
def onFocus(self, event):
pass
def onFocusIn(self, event):
pass
def onFocusOut(self, event):
pass
def onFormChange(self, event):
pass
def onFormInput(self, event):
pass
def onInput(self, event):
pass
def onInvalid(self, event):
pass
def onReset(self, event):
pass
def onSelect(self, event):
pass
def onSubmit(self, event):
pass
def onKeyDown(self, event):
pass
def onKeyPress(self, event):
pass
def onKeyUp(self, event):
pass
def onClick(self, event):
pass
def onDblClick(self, event):
pass
def onDrag(self, event):
pass
def onDragEnd(self, event):
pass
def onDragEnter(self, event):
pass
def onDragLeave(self, event):
pass
def onDragOver(self, event):
pass
def onDragStart(self, event):
pass
def onDrop(self, event):
pass
def onMouseDown(self, event):
pass
def onMouseMove(self, event):
pass
def onMouseOut(self, event):
pass
def onMouseOver(self, event):
pass
def onMouseUp(self, event):
pass
def onMouseWheel(self, event):
pass