forked from oria/gridx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGotoPagePane.js
61 lines (50 loc) · 1.47 KB
/
GotoPagePane.js
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
define([
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/_base/event",
"dojo/keys",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin",
"dojo/text!../templates/GotoPagePane.html",
"dojo/i18n",
"dojo/i18n!../nls/PaginationBar"
], function(declare, lang, event, keys, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, goToTemplate, i18n){
/*=====
return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
});
=====*/
return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
templateString: goToTemplate,
pager: null,
pagination: null,
dialog: null,
postMixInProperties: function(){
var t = this;
lang.mixin(t, i18n.getLocalization('gridx', 'PaginationBar', t.pagination.grid.lang));
t.numberTextBoxClass = t.pager.numberTextBoxClass.prototype.declaredClass;
t.buttonClass = t.pager.buttonClass.prototype.declaredClass;
t.connect(t.domNode, 'onkeydown', '_onKeyDown');
},
postCreate: function(){
this._updateStatus();
},
_updateStatus: function(){
var b = this.pageInputBox;
this.okBtn.set('disabled', !b.isValid() || b.get('displayedValue') === "");
},
_onOK: function(){
this.pagination.gotoPage(this.pageInputBox.get('value') - 1);
this.dialog.hide();
},
_onCancel: function(){
this.dialog.hide();
},
_onKeyDown: function(evt){
if(!this.okBtn.get('disabled') && keys.ENTER == evt.keyCode){
this._onOK();
event.stop(evt);
}
}
});
});