]> git.proxmox.com Git - extjs.git/blame - extjs/templates/admin-dashboard/classic/src/view/forms/WizardFormController.js
add extjs 6.0.1 sources
[extjs.git] / extjs / templates / admin-dashboard / classic / src / view / forms / WizardFormController.js
CommitLineData
6527f429
DM
1/**\r
2 * @class Admin.view.forms.WizardFormController\r
3 */\r
4Ext.define('Admin.view.forms.WizardFormController', {\r
5 extend: 'Ext.app.ViewController',\r
6 alias: 'controller.wizardform',\r
7\r
8\r
9 init: function(view) {\r
10 var tb = this.lookupReference('navigation-toolbar'),\r
11 buttons = tb.items.items,\r
12 ui = view.colorScheme;\r
13\r
14 //Apply styling buttons\r
15 if (ui) {\r
16 buttons[1].setUI(ui);\r
17 buttons[2].setUI(ui);\r
18 }\r
19 },\r
20\r
21 onNextClick: function(button) {\r
22 //This is where you can handle any logic prior to moving to the next card\r
23 var panel = button.up('panel');\r
24\r
25 panel.getViewModel().set('atBeginning', false);\r
26 \r
27 this.navigate(button, panel, 'next');\r
28 },\r
29\r
30 onPreviousClick: function(button) {\r
31 var panel = button.up('panel');\r
32\r
33 panel.getViewModel().set('atEnd', false);\r
34 \r
35 this.navigate(button, panel, 'prev');\r
36 },\r
37\r
38 navigate: function(button, panel, direction) {\r
39 var layout = panel.getLayout(),\r
40 progress = this.lookupReference('progress'),\r
41 model = panel.getViewModel(),\r
42 progressItems = progress.items.items,\r
43 item, i, activeItem, activeIndex;\r
44\r
45 layout[direction]();\r
46\r
47 activeItem = layout.getActiveItem();\r
48 activeIndex = panel.items.indexOf(activeItem);\r
49\r
50 for (i = 0; i < progressItems.length; i++) {\r
51 item = progressItems[i];\r
52\r
53 if (activeIndex === item.step) {\r
54 item.setPressed(true);\r
55 }\r
56 else {\r
57 item.setPressed(false);\r
58 }\r
59 \r
60 // IE8 has an odd bug with handling font icons in pseudo elements;\r
61 // it will render the icon once and not update it when something\r
62 // like text color is changed via style addition or removal.\r
63 // We have to force icon repaint by adding a style with forced empty\r
64 // pseudo element content, (x-sync-repaint) and removing it back to work\r
65 // around this issue.\r
66 // See this: https://github.com/FortAwesome/Font-Awesome/issues/954\r
67 // and this: https://github.com/twbs/bootstrap/issues/13863\r
68 if (Ext.isIE8) {\r
69 item.btnIconEl.syncRepaint();\r
70 }\r
71 }\r
72\r
73 activeItem.focus();\r
74\r
75 // beginning disables previous\r
76 if (activeIndex === 0) {\r
77 model.set('atBeginning', true);\r
78 }\r
79 \r
80 // wizard is 4 steps. Disable next at end.\r
81 if (activeIndex === 3) {\r
82 model.set('atEnd', true);\r
83 }\r
84 }\r
85});\r