]> git.proxmox.com Git - sencha-touch.git/blob - src/examples/kitchensink/app/controller/tablet/Main.js
import Sencha Touch 2.4.2 source
[sencha-touch.git] / src / examples / kitchensink / app / controller / tablet / Main.js
1 /**
2 * @class Kitchensink.controller.tablet.Main
3 * @extends Kitchensink.controller.Main
4 *
5 * This is the Main controller subclass for the 'tablet' profile. Almost all of the functionality is implemented in the
6 * superclass, here we just define showView, which is the function that is called whenever any view is navigated to via
7 * the navigation NestedList or a url change.
8 */
9 Ext.define('Kitchensink.controller.tablet.Main', {
10 extend: 'Kitchensink.controller.Main',
11
12 /**
13 * This is called whenever the user taps on an item in the main navigation NestedList
14 */
15 onNavTap: function(nestedList, list, index) {
16 var record = list.getStore().getAt(index);
17
18 if (record.isLeaf()) {
19 this.redirectTo(record);
20 }
21 },
22
23 /**
24 * For a given Demo model instance, shows the appropriate view. This is the endpoint for all routes matching
25 * 'demo/:id', so is called automatically whenever the user navigates back or forward between demos.
26 * @param {Kitchensink.model.Demo} item The Demo model instance for which we want to show a view
27 */
28 showView: function(item) {
29 var nav = this.getNav(),
30 view = this.createView(item),
31 main = this.getMain(),
32 anim = item.get('animation'),
33 layout = main.getLayout(),
34 initialAnim = layout.getAnimation(),
35 newAnim;
36
37 if (anim) {
38 layout.setAnimation(anim);
39 newAnim = layout.getAnimation();
40 }
41
42 nav.setDetailContainer(main);
43 nav.setDetailCard(view);
44 nav.goToNode(item.parentNode);
45 nav.goToLeaf(item);
46 nav.getActiveItem().select(item);
47
48 if (newAnim) {
49 newAnim.on('animationend', function() {
50 layout.setAnimation(initialAnim);
51 }, this, { single: true });
52 }
53
54 this.getToolbar().setTitle(item.get('text'));
55 this.getSourceButton().setHidden(false);
56 // nav.goToNode(item.parentNode);
57 // nav.goToLeaf(item);
58 // },
59 //
60 // /**
61 // * This is how the view above should look once the animation is fixed
62 // */
63 // XshowView: function(item) {
64 // var nav = this.getNav(),
65 // view = this.createView(this.getViewName(item));
66 //
67 // nav.setDetailCard(view);
68 // nav.goToNode(item.parentNode);
69 // nav.goToLeaf(item);
70 // nav.getCurrentList().select(item);
71 //
72 // this.getToolbar().setTitle(item.get('text'));
73 // this.getSourceButton().setHidden(false);
74 // },
75 //
76 // /**
77 // * Ideally, even that could be reduced to this by implementing an ensureVisible function onto List
78 // * and NestedList
79 // */
80 // XshowView: function(item) {
81 // var nav = this.getNav();
82 //
83 // nav.ensureVisible(item);
84 // nav.setDetailCard(this.createDemoView(item));
85 //
86 // this.getToolbar().setTitle(item.get('text'));
87 // this.getSourceButton().setHidden(false);
88 },
89
90 showMenuById: function() {
91 this.hideSheets();
92 }
93 });