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 Widget import Widget
20 from pyjamas.ui import Event
21 from ClickListener import ClickHandler
22
24
25 - def __init__(self, text="", asHTML=False, targetHistoryToken="",
26 Element=None, **kwargs):
27
28 self.targetHistoryToken = ""
29
30 if not Element:
31 Element = DOM.createDiv()
32 self.anchorElem = DOM.createAnchor()
33 self.setElement(Element)
34 DOM.appendChild(self.getElement(), self.anchorElem)
35
36 if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-Hyperlink"
37 if text:
38 if asHTML:
39 kwargs['HTML'] = text
40 else:
41 kwargs['Text'] = text
42 if targetHistoryToken:
43 kwargs['TargetHistoryToken'] = targetHistoryToken
44
45 Widget.__init__(self, **kwargs)
46 ClickHandler.__init__(self)
47
50
52 return self.targetHistoryToken
53
55 return DOM.getInnerText(self.anchorElem)
56
62
65
66 - def setTargetHistoryToken(self, targetHistoryToken):
67 self.targetHistoryToken = targetHistoryToken
68 DOM.setAttribute(self.anchorElem, "href", "#" + targetHistoryToken)
69
70 - def setText(self, text):
71 DOM.setInnerText(self.anchorElem, text)
72
73 Factory.registerClass('pyjamas.ui.Hyperlink', Hyperlink)
74