Debian Codegraph @

dojox/calendar/_ScrollBarBase.js

raw symbols SCIP
1 define([
2 "dojo/_base/declare",
3 "dojo/_base/event",
4 "dojo/_base/lang",
5 "dojo/on",
6 "dojo/dom-style",
7 "dojo/sniff",
8 "dijit/_WidgetBase",
9 "dojox/html/metrics"],
10
11 function(
12 declare,
13 event,
14 lang,
15 on,
16 domStyle,
17 has,
18 _WidgetBase,
19 metrics){
20
21 return declare('dojox.calendar._ScrollBarBase', _WidgetBase, {
22
23 // value: Number
24 // The value of the scroll bar in pixel offset.
25 value: 0,
26
27 // minimum: Number
28 // The minimum value of the scroll bar.
29 minimum: 0,
30
31 // maximum: Number
32 // The maximum value of the scroll bar.
33 maximum: 100,
34
35 // direction: String
36 // Direction of the scroll bar. Valid values are "vertical" or "horizontal".
37 direction: "vertical",
38
39 _vertical: true,
40
41 _scrollHandle: null,
42
43 containerSize: 0,
44
45 buildRendering: function(){
46 this.inherited(arguments);
47 this.own(on(this.domNode, "scroll", lang.hitch(this, function(param) {
48 this.value = this._getDomScrollerValue();
49 this.onChange(this.value);
50 this.onScroll(this.value);
51 })));
52 },
53
54 _getDomScrollerValue : function() {
55 if(this._vertical){
56 return this.domNode.scrollTop;
57 }
58
59 var rtl = !this.isLeftToRight();
60 if(rtl){
61 if(has("webkit") || has("ie") == 7){
62 if(this._scW == undefined){
63 this._scW = metrics.getScrollbar().w;
64 }
65 return this.maximum - this.domNode.scrollLeft - this.containerSize + this._scW;
66 }
67 if(has("mozilla")){
68 return -this.domNode.scrollLeft;
69 }
70 // ie>7 and others...
71 }
72 return this.domNode.scrollLeft;
73 },
74
75 _setDomScrollerValue : function(value) {
76 this.domNode[this._vertical?"scrollTop":"scrollLeft"] = value;
77 },
78
79 _setValueAttr: function(value){
80 value = Math.min(this.maximum, value);
81 value = Math.max(this.minimum, value);
82 if (this.value != value) {
83 this.value = value;
84 this.onChange(value);
85 this._setDomScrollerValue(value);
86 }
87 },
88
89 onChange: function(value){
90 // summary:
91 // An extension point invoked when the value has changed.
92 // value: Integer
93 // The position of the scroll bar in pixels.
94 // tags:
95 // callback
96 },
97
98 onScroll: function(value){
99 // summary:
100 // An extension point invoked when the user scrolls with the mouse.
101 // value: Integer
102 // The position of the scroll bar in pixels.
103 // tags:
104 // callback
105 },
106
107 _setMinimumAttr: function(value){
108 value = Math.min(value, this.maximum);
109 this.minimum = value;
110 },
111
112 _setMaximumAttr: function(value){
113 value = Math.max(value, this.minimum);
114 this.maximum = value;
115 domStyle.set(this.content, this._vertical?"height":"width", value + "px");
116 },
117
118 _setDirectionAttr: function(value){
119 if(value == "vertical"){
120 value = "vertical";
121 this._vertical = true;
122 }else{
123 value = "horizontal";
124 this._vertical = false;
125 }
126 this._set("direction", value);
127 }
128
129 });
130
131 });