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
|
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
dojo._xdResourceLoaded(function(dojo, dijit, dojox){
return {depends: [["provide", "dojox.widget.DynamicTooltip"],
["require", "dijit.Tooltip"],
["requireLocalization", "dijit", "loading", null, "ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw", "ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"]],
defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.widget.DynamicTooltip"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.widget.DynamicTooltip"] = true;
dojo.provide("dojox.widget.DynamicTooltip");
dojo.experimental("dojox.widget.DynamicTooltip");
dojo.require("dijit.Tooltip");
;
dojo.declare("dojox.widget.DynamicTooltip", dijit.Tooltip,
{
// summary:
// Extention of dijit.Tooltip providing content set via XHR
// request via href param
// hasLoaded: Boolean
// false if the contents are yet to be loaded from the HTTP request
hasLoaded: false,
// href: String
// location from where to fetch the contents
href: "",
// label: String
// contents to diplay in the tooltip. Initialized to a loading icon.
label: "",
// preventCache: Boolean
// Cache content retreived externally
preventCache: false,
postMixInProperties: function(){
this.inherited(arguments);
this._setLoadingLabel();
},
_setLoadingLabel: function(){
// summary:
// Changes the tooltip label / contents to loading message, only if
// there's an href param, otherwise acts as normal tooltip
if(this.href){
this.label = dojo.i18n.getLocalization("dijit", "loading", this.lang).loadingState;
}
},
// MOW: this is a new widget, do we really need a deprecated stub?
// setHref: function(/*String|Uri*/ href){
// // summary:
// // Deprecated. Use set('href', ...) instead.
// dojo.deprecated("dojox.widget.DynamicTooltip.setHref() is deprecated. Use set('href', ...) instead.", "", "2.0");
// return this.set("href", href);
// },
_setHrefAttr: function(/*String|Uri*/ href){
// summary:
// Hook so attr("href", ...) works.
// description:
// resets so next show loads new href
// href:
// url to the content you want to show, must be within the same domain as your mainpage
this.href = href;
this.hasLoaded = false;
},
loadContent: function(node){
// summary:
// Download contents of href via XHR and display
// description:
// 1. checks if content already loaded
// 2. if not, sends XHR to download new data
if(!this.hasLoaded && this.href){
this._setLoadingLabel();
this.hasLoaded = true;
dojo.xhrGet({
url: this.href,
handleAs: "text",
tooltipWidget: this,
load: function(response, ioArgs){
this.tooltipWidget.label = response;
this.tooltipWidget.close();
this.tooltipWidget.open(node);
},
preventCache: this.preventCache
});
}
},
refresh: function(){
// summary:
// Allows re-download of contents of href and display
// Useful with preventCache = true
this.hasLoaded = false;
},
open: function(/*DomNode*/ target){
// summary:
// Display the tooltip; usually not called directly.
target = target || (this._connectNodes && this._connectNodes[0]);
if(!target){ return; }
this.loadContent(target);
this.inherited(arguments);
}
}
);
}
}};});
|