1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 from pyjamas import DOM
16 from pyjamas import Factory
17 from pyjamas import History
18
19 from pyjamas.ui.Widget import Widget
20 from pyjamas.ui import Event
21 from pyjamas.ui.ClickListener import ClickHandler
22
24
25 - def __init__(self, text="", asHTML=False, Element=None, **kwargs):
26
27 if Element is None:
28 Element = DOM.createDiv()
29 self.anchorElem = DOM.createAnchor()
30 self.setElement(Element)
31 DOM.appendChild(self.getElement(), self.anchorElem)
32
33 if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-Hyperlink"
34 if text:
35 if asHTML:
36 kwargs['HTML'] = text
37 else:
38 kwargs['Text'] = text
39 if not kwargs.has_key('TargetHistoryToken'):
40 kwargs['TargetHistoryToken'] = None
41
42 Widget.__init__(self, **kwargs)
43 ClickHandler.__init__(self)
44
52
55
58
60 return DOM.getInnerText(self.anchorElem)
61
62 - def setText(self, text):
63 DOM.setInnerText(self.anchorElem, text)
64
66 return self.targetHistoryToken
67
68 - def setTargetHistoryToken(self, targetHistoryToken):
69 self.targetHistoryToken = targetHistoryToken
70 if targetHistoryToken is None:
71 targetHistoryToken = ''
72 DOM.setAttribute(self.anchorElem, "href", "#" + targetHistoryToken)
73
74 Factory.registerClass('pyjamas.ui.Hyperlink', 'Hyperlink', Hyperlink)
75