| 1 |
dojo.provide("dojox.widget.DynamicTooltip"); |
| 2 |
dojo.experimental("dojox.widget.DynamicTooltip"); |
| 3 |
|
| 4 |
dojo.require("dijit.Tooltip"); |
| 5 |
dojo.requireLocalization("dijit", "loading"); |
| 6 |
|
| 7 |
dojo.declare("dojox.widget.DynamicTooltip", dijit.Tooltip, |
| 8 |
{ |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
hasLoaded: false, |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
href: "", |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
label: "", |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
preventCache: false, |
| 28 |
|
| 29 |
postMixInProperties: function(){ |
| 30 |
this.inherited(arguments); |
| 31 |
this._setLoadingLabel(); |
| 32 |
}, |
| 33 |
|
| 34 |
_setLoadingLabel: function(){ |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
if(this.href){ |
| 40 |
this.label = dojo.i18n.getLocalization("dijit", "loading", this.lang).loadingState; |
| 41 |
} |
| 42 |
}, |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
_setHrefAttr: function( href){ |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
this.href = href; |
| 61 |
this.hasLoaded = false; |
| 62 |
}, |
| 63 |
|
| 64 |
loadContent: function(node){ |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
if(!this.hasLoaded && this.href){ |
| 71 |
this._setLoadingLabel(); |
| 72 |
this.hasLoaded = true; |
| 73 |
|
| 74 |
dojo.xhrGet({ |
| 75 |
url: this.href, |
| 76 |
handleAs: "text", |
| 77 |
tooltipWidget: this, |
| 78 |
load: function(response, ioArgs){ |
| 79 |
this.tooltipWidget.label = response; |
| 80 |
this.tooltipWidget.close(); |
| 81 |
this.tooltipWidget.open(node); |
| 82 |
}, |
| 83 |
preventCache: this.preventCache |
| 84 |
}); |
| 85 |
} |
| 86 |
}, |
| 87 |
|
| 88 |
refresh: function(){ |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
this.hasLoaded = false; |
| 94 |
}, |
| 95 |
|
| 96 |
open: function( target){ |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
target = target || (this._connectNodes && this._connectNodes[0]); |
| 101 |
if(!target){ return; } |
| 102 |
|
| 103 |
this.loadContent(target); |
| 104 |
this.inherited(arguments); |
| 105 |
} |
| 106 |
} |
| 107 |
); |