Created
November 28, 2011 13:00
-
-
Save tomasfejfar/1400315 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.views.Viewport = Ext.extend(Ext.Panel, { | |
initComponent: function() { | |
//put instances of cards into app.views namespace | |
Ext.apply(app.views, { | |
question : new app.views.Question(), | |
articlesList : new app.views.ArticlesList(), | |
articlesDetail: new app.views.ArticlesDetail() | |
/*videos : new app.views.Videos(), | |
events : new app.views.Events(), | |
tags : new app.views.Tags(), | |
setup : new app.views.Setup()*/ | |
}); | |
//put instances of cards into viewport | |
var localItems = []; | |
if (!window.localStorage.getItem('isDoctor')) { | |
localItems.push(app.views.question); | |
} | |
localItems.push(app.views.articlesList); | |
localItems.push(app.views.articlesDetail); | |
Ext.apply(this, { | |
items: localItems, | |
fullscreen: true, | |
layout: 'card', | |
cardSwitchAnimation: 'slide' | |
}); | |
app.views.Viewport.superclass.initComponent.apply(this, arguments); | |
} | |
}); | |
// app | |
Ext.regApplication({ | |
name: 'app', | |
launch: function() { | |
this.launched = true; | |
this.mainLaunch(); | |
}, | |
mainLaunch: function() { | |
//if (!device || !this.launched) {return;} | |
app.views.viewport = new app.views.Viewport(); | |
} | |
}); | |
// list view | |
app.views.ArticlesList = Ext.extend(Ext.Panel, { | |
initComponent : function() { | |
Ext.apply(this, { | |
layout : 'fit', | |
dockedItems : [ { | |
xtype : 'toolbar', | |
title : '<img src="http://widgetsplus.com/images/google-logo-plus.png">' | |
}, { | |
xtype : 'toolbar', | |
dock : 'bottom', | |
items : [{ | |
text : 'Čl', | |
ui : 'plain', | |
iconMask : true, | |
iconCls : 'home' | |
}, { | |
text : 'Vi', | |
ui : 'plain', | |
iconMask : true, | |
iconCls : 'bookmarks' | |
}, { | |
text : 'Ud', | |
ui : 'plain', | |
iconMask : true, | |
iconCls : 'favorites' | |
}, { | |
text : 'Št', | |
ui : 'plain', | |
iconMask : true, | |
iconCls : 'time' | |
}, { | |
text : 'Na', | |
ui : 'plain', | |
iconMask : true, | |
iconCls : 'team' | |
}] | |
} ], | |
items : [ { | |
xtype : 'list', | |
store : app.stores.articles, | |
itemTpl : app.partials.articlesListItem, | |
onItemDisclosure: function(record) { | |
Ext.dispatch({ | |
controller: app.controllers.articles, | |
action: 'show' | |
}); | |
}, | |
listeners : { | |
itemtap : function(list, index, item, event){ | |
console.log(list.getStore().getAt(index).data); | |
Ext.dispatch({ | |
controller: app.controllers.articles, | |
action: 'show', | |
id: list.getStore().getAt(index).data.id | |
}); | |
} | |
} | |
} ] | |
}); | |
app.stores.articles.load(); | |
app.views.ArticlesList.superclass.initComponent.apply(this, arguments); | |
} | |
}); | |
//index has only this line in script and empty body: | |
document.addEventListener("deviceready", app.launch, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment