Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / widget / UpgradeBar.js

History | View | Annotate | Download (3.61 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.widget.UpgradeBar"]){
9
dojo._hasResource["dojox.widget.UpgradeBar"]=true;
10
dojo.provide("dojox.widget.UpgradeBar");
11
dojo.require("dojo.window");
12
dojo.require("dojo.fx");
13
dojo.require("dojo.cookie");
14
dojo.require("dijit._Widget");
15
dojo.require("dijit._Templated");
16
dojo.experimental("dojox.widget.UpgradeBar");
17
dojo.declare("dojox.widget.UpgradeBar",[dijit._Widget,dijit._Templated],{notifications:[],buttonCancel:"Close for now",noRemindButton:"Don't Remind Me Again",templateString:dojo.cache("dojox.widget","UpgradeBar/UpgradeBar.html","<div class=\"dojoxUpgradeBar\">\n\t<div class=\"dojoxUpgradeBarMessage\" dojoAttachPoint=\"messageNode\">message</div>\n\t<div class=\"dojoxUpgradeBarReminderButton\" dojoAttachPoint=\"dontRemindButtonNode\" dojoAttachEvent=\"onclick:_onDontRemindClick\">${noRemindButton}</div>\n\t<span dojoAttachPoint=\"closeButtonNode\" class=\"dojoxUpgradeBarCloseIcon\" dojoAttachEvent=\"onclick: hide, onmouseenter: _onCloseEnter, onmouseleave: _onCloseLeave\" title=\"${buttonCancel}\"></span>\n</div>\n"),constructor:function(_1,_2){
18
if(!_1.notifications&&_2){
19
dojo.forEach(_2.childNodes,function(n){
20
if(n.nodeType==1){
21
var _3=dojo.attr(n,"validate");
22
this.notifications.push({message:n.innerHTML,validate:function(){
23
var _4=true;
24
try{
25
_4=dojo.eval(_3);
26
}
27
catch(e){
28
}
29
return _4;
30
}});
31
}
32
},this);
33
}
34
},checkNotifications:function(){
35
if(!this.notifications.length){
36
return;
37
}
38
for(var i=0;i<this.notifications.length;i++){
39
var _5=this.notifications[i].validate();
40
if(_5){
41
this.notify(this.notifications[i].message);
42
break;
43
}
44
}
45
},postCreate:function(){
46
this.inherited(arguments);
47
if(this.domNode.parentNode){
48
dojo.style(this.domNode,"display","none");
49
}
50
dojo.mixin(this.attributeMap,{message:{node:"messageNode",type:"innerHTML"}});
51
if(!this.noRemindButton){
52
dojo.destroy(this.dontRemindButtonNode);
53
}
54
if(dojo.isIE==6){
55
var _6=this;
56
var _7=function(){
57
var v=dojo.window.getBox();
58
dojo.style(_6.domNode,"width",v.w+"px");
59
};
60
this.connect(window,"resize",function(){
61
_7();
62
});
63
_7();
64
}
65
dojo.addOnLoad(this,"checkNotifications");
66
},notify:function(_8){
67
if(dojo.cookie("disableUpgradeReminders")){
68
return;
69
}
70
if(!this.domNode.parentNode||!this.domNode.parentNode.innerHTML){
71
document.body.appendChild(this.domNode);
72
}
73
dojo.style(this.domNode,"display","");
74
if(_8){
75
this.set("message",_8);
76
}
77
},show:function(){
78
this._bodyMarginTop=dojo.style(dojo.body(),"marginTop");
79
this._size=dojo.contentBox(this.domNode).h;
80
dojo.style(this.domNode,{display:"block",height:0,opacity:0});
81
if(!this._showAnim){
82
this._showAnim=dojo.fx.combine([dojo.animateProperty({node:dojo.body(),duration:500,properties:{marginTop:this._bodyMarginTop+this._size}}),dojo.animateProperty({node:this.domNode,duration:500,properties:{height:this._size,opacity:1}})]);
83
}
84
this._showAnim.play();
85
},hide:function(){
86
if(!this._hideAnim){
87
this._hideAnim=dojo.fx.combine([dojo.animateProperty({node:dojo.body(),duration:500,properties:{marginTop:this._bodyMarginTop}}),dojo.animateProperty({node:this.domNode,duration:500,properties:{height:0,opacity:0}})]);
88
dojo.connect(this._hideAnim,"onEnd",this,function(){
89
dojo.style(this.domNode,"display","none");
90
});
91
}
92
this._hideAnim.play();
93
},_onDontRemindClick:function(){
94
dojo.cookie("disableUpgradeReminders",true,{expires:3650});
95
this.hide();
96
},_onCloseEnter:function(){
97
dojo.addClass(this.closeButtonNode,"dojoxUpgradeBarCloseIcon-hover");
98
},_onCloseLeave:function(){
99
dojo.removeClass(this.closeButtonNode,"dojoxUpgradeBarCloseIcon-hover");
100
}});
101
}