ruby-extjs 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,213 @@
1
+ shortcut = {
2
+ 'all_shortcuts' : {},
3
+ 'add' : function (shortcut_combination, callback, opt) {
4
+ var default_options = {
5
+ 'type' : 'keydown',
6
+ 'propagate' : false,
7
+ 'disable_in_input' : false,
8
+ 'target' : document,
9
+ 'keycode' : false
10
+ }
11
+ if (!opt)
12
+ opt = default_options;
13
+ else {
14
+ for (var dfo in default_options) {
15
+ if (typeof opt[dfo] == 'undefined')
16
+ opt[dfo] = default_options[dfo];
17
+ }
18
+ }
19
+ var ele = opt.target;
20
+ if (typeof opt.target == 'string')
21
+ ele = document.getElementById(opt.target);
22
+ var ths = this;
23
+ shortcut_combination = shortcut_combination.toLowerCase();
24
+ var func = function (e) {
25
+ e = e || window.event;
26
+ if (opt['disable_in_input']) {
27
+ var element;
28
+ if (e.target)
29
+ element = e.target;
30
+ else if (e.srcElement)
31
+ element = e.srcElement;
32
+ if (element.nodeType == 3)
33
+ element = element.parentNode;
34
+ if (element.tagName == 'INPUT' || element.tagName == 'TEXTAREA')
35
+ return;
36
+ }
37
+ if (e.keyCode)
38
+ code = e.keyCode;
39
+ else if (e.which)
40
+ code = e.which;
41
+ var character = String.fromCharCode(code).toLowerCase();
42
+ if (code == 188)
43
+ character = ",";
44
+ if (code == 190)
45
+ character = ".";
46
+ var keys = shortcut_combination.split("+");
47
+ var kp = 0;
48
+ var shift_nums = {
49
+ "`" : "~",
50
+ "1" : "!",
51
+ "2" : "@",
52
+ "3" : "#",
53
+ "4" : "$",
54
+ "5" : "%",
55
+ "6" : "^",
56
+ "7" : "&",
57
+ "8" : "*",
58
+ "9" : "(",
59
+ "0" : ")",
60
+ "-" : "_",
61
+ "=" : "+",
62
+ ";" : ":",
63
+ "'" : "\"",
64
+ "," : "<",
65
+ "." : ">",
66
+ "/" : "?",
67
+ "\\" : "|"
68
+ }
69
+ var special_keys = {
70
+ 'esc' : 27,
71
+ 'escape' : 27,
72
+ 'tab' : 9,
73
+ 'space' : 32,
74
+ 'return' : 13,
75
+ 'enter' : 13,
76
+ 'backspace' : 8,
77
+ 'scrolllock' : 145,
78
+ 'scroll_lock' : 145,
79
+ 'scroll' : 145,
80
+ 'capslock' : 20,
81
+ 'caps_lock' : 20,
82
+ 'caps' : 20,
83
+ 'numlock' : 144,
84
+ 'num_lock' : 144,
85
+ 'num' : 144,
86
+ 'pause' : 19,
87
+ 'break' : 19,
88
+ 'insert' : 45,
89
+ 'home' : 36,
90
+ 'delete' : 46,
91
+ 'end' : 35,
92
+ 'pageup' : 33,
93
+ 'page_up' : 33,
94
+ 'pu' : 33,
95
+ 'pagedown' : 34,
96
+ 'page_down' : 34,
97
+ 'pd' : 34,
98
+ 'left' : 37,
99
+ 'up' : 38,
100
+ 'right' : 39,
101
+ 'down' : 40,
102
+ 'f1' : 112,
103
+ 'f2' : 113,
104
+ 'f3' : 114,
105
+ 'f4' : 115,
106
+ 'f5' : 116,
107
+ 'f6' : 117,
108
+ 'f7' : 118,
109
+ 'f8' : 119,
110
+ 'f9' : 120,
111
+ 'f10' : 121,
112
+ 'f11' : 122,
113
+ 'f12' : 123
114
+ }
115
+ var modifiers = {
116
+ shift : {
117
+ wanted : false,
118
+ pressed : false
119
+ },
120
+ ctrl : {
121
+ wanted : false,
122
+ pressed : false
123
+ },
124
+ alt : {
125
+ wanted : false,
126
+ pressed : false
127
+ },
128
+ meta : {
129
+ wanted : false,
130
+ pressed : false
131
+ }
132
+ };
133
+ if (e.ctrlKey)
134
+ modifiers.ctrl.pressed = true;
135
+ if (e.shiftKey)
136
+ modifiers.shift.pressed = true;
137
+ if (e.altKey)
138
+ modifiers.alt.pressed = true;
139
+ if (e.metaKey)
140
+ modifiers.meta.pressed = true;
141
+ for (var i = 0; k = keys[i], i < keys.length; i++) {
142
+ if (k == 'ctrl' || k == 'control') {
143
+ kp++;
144
+ modifiers.ctrl.wanted = true;
145
+ } else if (k == 'shift') {
146
+ kp++;
147
+ modifiers.shift.wanted = true;
148
+ } else if (k == 'alt') {
149
+ kp++;
150
+ modifiers.alt.wanted = true;
151
+ } else if (k == 'meta') {
152
+ kp++;
153
+ modifiers.meta.wanted = true;
154
+ } else if (k.length > 1) {
155
+ if (special_keys[k] == code)
156
+ kp++;
157
+ } else if (opt['keycode']) {
158
+ if (opt['keycode'] == code)
159
+ kp++;
160
+ } else {
161
+ if (character == k)
162
+ kp++;
163
+ else {
164
+ if (shift_nums[character] && e.shiftKey) {
165
+ character = shift_nums[character];
166
+ if (character == k)
167
+ kp++;
168
+ }
169
+ }
170
+ }
171
+ }
172
+ if (kp == keys.length && modifiers.ctrl.pressed == modifiers.ctrl.wanted && modifiers.shift.pressed == modifiers.shift.wanted && modifiers.alt.pressed == modifiers.alt.wanted && modifiers.meta.pressed == modifiers.meta.wanted) {
173
+ callback(e);
174
+ if (!opt['propagate']) {
175
+ e.cancelBubble = true;
176
+ e.returnValue = false;
177
+ if (e.stopPropagation) {
178
+ e.stopPropagation();
179
+ e.preventDefault();
180
+ }
181
+ return false;
182
+ }
183
+ }
184
+ }
185
+ this.all_shortcuts[shortcut_combination] = {
186
+ 'callback' : func,
187
+ 'target' : ele,
188
+ 'event' : opt['type']
189
+ };
190
+ if (ele.addEventListener)
191
+ ele.addEventListener(opt['type'], func, false);
192
+ else if (ele.attachEvent)
193
+ ele.attachEvent('on' + opt['type'], func);
194
+ else
195
+ ele['on' + opt['type']] = func;
196
+ },
197
+ 'remove' : function (shortcut_combination) {
198
+ shortcut_combination = shortcut_combination.toLowerCase();
199
+ var binding = this.all_shortcuts[shortcut_combination];
200
+ delete(this.all_shortcuts[shortcut_combination])
201
+ if (!binding)
202
+ return;
203
+ var type = binding['event'];
204
+ var ele = binding['target'];
205
+ var callback = binding['callback'];
206
+ if (ele.detachEvent)
207
+ ele.detachEvent('on' + type, callback);
208
+ else if (ele.removeEventListener)
209
+ ele.removeEventListener(type, callback, false);
210
+ else
211
+ ele['on' + type] = false;
212
+ }
213
+ }
@@ -0,0 +1,35 @@
1
+ Ext.define('Abstract.util.Store', {
2
+ extend: 'Ext.data.Store',
3
+
4
+ modulo : false,
5
+ model : false,
6
+
7
+ remoteSort: false,
8
+ extraParams: {
9
+ action: 'LIST'
10
+ },
11
+
12
+ constructor: function(cfg) {
13
+ var me = this;
14
+ cfg = cfg || {};
15
+ me.callParent([Ext.apply({
16
+ proxy: {
17
+ type: 'ajax',
18
+ extraParams: me.extraParams,
19
+ actionMethods: {
20
+ create : 'POST',
21
+ read : 'POST',
22
+ update : 'POST',
23
+ destroy: 'POST'
24
+ },
25
+ url : 'server/modulos/'+me.modulo.toLowerCase()+'/list.php',
26
+ reader: {
27
+ type: 'json',
28
+ root: 'dados'
29
+ }
30
+ }
31
+
32
+ }, cfg)]);
33
+ }
34
+
35
+ });
@@ -0,0 +1,141 @@
1
+ Ext.define('Ext.tab.TabCloseMenu', {
2
+ alias : 'plugin.tabclosemenu',
3
+ alternateClassName : 'Ext.ux.TabCloseMenu',
4
+ mixins : {
5
+ observable : 'Ext.util.Observable'
6
+ },
7
+ closeTabText : 'Fechar aba',
8
+ showCloseOthers : true,
9
+ closeOthersTabsText : 'Fechar outras abas',
10
+ showCloseAll : true,
11
+ closeAllTabsText : 'Fechar todas as abas',
12
+ extraItemsHead : null,
13
+ extraItemsTail : null,
14
+ constructor : function (config) {
15
+ this.addEvents('aftermenu', 'beforemenu');
16
+ this.mixins.observable.constructor.call(this, config);
17
+ },
18
+ init : function (tabpanel) {
19
+ this.tabPanel = tabpanel;
20
+ this.tabBar = tabpanel.down("tabbar");
21
+ this.mon(this.tabPanel, {
22
+ scope : this,
23
+ afterlayout : this.onAfterLayout,
24
+ single : true
25
+ });
26
+ },
27
+ onAfterLayout : function () {
28
+ this.mon(this.tabBar.el, {
29
+ scope : this,
30
+ contextmenu : this.onContextMenu,
31
+ delegate : 'div.x-tab'
32
+ });
33
+ },
34
+ onBeforeDestroy : function () {
35
+ Ext.destroy(this.menu);
36
+ this.callParent(arguments);
37
+ },
38
+ onContextMenu : function (event, target) {
39
+ var me = this,
40
+ menu = me.createMenu(),
41
+ disableAll = true,
42
+ disableOthers = true,
43
+ tab = me.tabBar.getChildByElement(target),
44
+ index = me.tabBar.items.indexOf(tab);
45
+ me.item = me.tabPanel.getComponent(index);
46
+ menu.child('*[text="' + me.closeTabText + '"]').setDisabled(!me.item.closable);
47
+ if (me.showCloseAll || me.showCloseOthers) {
48
+ me.tabPanel.items.each(function (item) {
49
+ if (item.closable) {
50
+ disableAll = false;
51
+ if (item != me.item) {
52
+ disableOthers = false;
53
+ return false;
54
+ }
55
+ }
56
+ return true;
57
+ });
58
+ if (me.showCloseAll) {
59
+ menu.child('*[text="' + me.closeAllTabsText + '"]').setDisabled(disableAll);
60
+ }
61
+ if (me.showCloseOthers) {
62
+ menu.child('*[text="' + me.closeOthersTabsText + '"]').setDisabled(disableOthers);
63
+ }
64
+ }
65
+ event.preventDefault();
66
+ me.fireEvent('beforemenu', menu, me.item, me);
67
+ menu.showAt(event.getXY());
68
+ },
69
+ createMenu : function () {
70
+ var me = this;
71
+ if (!me.menu) {
72
+ var items = [{
73
+ text : me.closeTabText,
74
+ scope : me,
75
+ iconCls : 'bt_close',
76
+ handler : me.onClose
77
+ }
78
+ ];
79
+ if (me.showCloseAll || me.showCloseOthers) {
80
+ items.push('-');
81
+ }
82
+ if (me.showCloseOthers) {
83
+ items.push({
84
+ text : me.closeOthersTabsText,
85
+ scope : me,
86
+ iconCls : 'bt_close',
87
+ handler : me.onCloseOthers
88
+ });
89
+ }
90
+ if (me.showCloseAll) {
91
+ items.push({
92
+ text : me.closeAllTabsText,
93
+ scope : me,
94
+ iconCls : 'bt_close',
95
+ handler : me.onCloseAll
96
+ });
97
+ }
98
+ if (me.extraItemsHead) {
99
+ items = me.extraItemsHead.concat(items);
100
+ }
101
+ if (me.extraItemsTail) {
102
+ items = items.concat(me.extraItemsTail);
103
+ }
104
+ me.menu = Ext.create('Ext.menu.Menu', {
105
+ items : items,
106
+ listeners : {
107
+ hide : me.onHideMenu,
108
+ scope : me
109
+ }
110
+ });
111
+ }
112
+ return me.menu;
113
+ },
114
+ onHideMenu : function () {
115
+ var me = this;
116
+ me.item = null;
117
+ me.fireEvent('aftermenu', me.menu, me);
118
+ },
119
+ onClose : function () {
120
+ this.tabPanel.remove(this.item);
121
+ },
122
+ onCloseOthers : function () {
123
+ this.doClose(true);
124
+ },
125
+ onCloseAll : function () {
126
+ this.doClose(false);
127
+ },
128
+ doClose : function (excludeActive) {
129
+ var items = [];
130
+ this.tabPanel.items.each(function (item) {
131
+ if (item.closable) {
132
+ if (!excludeActive || item != this.item) {
133
+ items.push(item);
134
+ }
135
+ }
136
+ }, this);
137
+ Ext.each(items, function (item) {
138
+ this.tabPanel.remove(item);
139
+ }, this);
140
+ }
141
+ });