95 lines
4.1 KiB
JavaScript
95 lines
4.1 KiB
JavaScript
define(['jquery', 'underscore', 'backbone', 'text!modules/home/homeViewTemplate.html',
|
|
'modules/base/baseView', 'modules/ricette/ricette', 'modules/editricetta/editricetta', 'modules/photos/photos', 'modules/statistics/statistics',
|
|
'jqx'],
|
|
function($, _, Backbone, homeViewTemplate, BaseView, RicetteView, EditRicettaView, PhotosView, StatisticsView) {
|
|
|
|
var HomeView = BaseView.extend({
|
|
ricetteView: null,
|
|
statiView: null,
|
|
//initialize template
|
|
template: _.template(homeViewTemplate),
|
|
initialize: function() {
|
|
HomeView.__super__.initialize.call(this);
|
|
//this.header.title = "pippo";
|
|
},
|
|
addRicetta: function() {
|
|
//e.preventDefault();
|
|
var editRicetteView = new EditRicettaView();
|
|
editRicetteView.render();
|
|
$('body').append(editRicetteView.$el);
|
|
editRicetteView.openRicetta();
|
|
},
|
|
modifyRicetta: function() {
|
|
//e.preventDefault();
|
|
if(this.ricetteView == null)
|
|
{
|
|
this.ricetteView = new RicetteView();
|
|
this.ricetteView.render();
|
|
$('body').append(this.ricetteView.$el);
|
|
}
|
|
else
|
|
this.ricetteView.render();
|
|
},
|
|
photosView: function(){
|
|
var photosView = new PhotosView();
|
|
photosView.render();
|
|
$('body').append(photosView.$el);
|
|
},
|
|
statisticsView: function(){
|
|
if(this.statiView == null)
|
|
{
|
|
this.statiView = new StatisticsView();
|
|
this.statiView.render();
|
|
$('body').append(this.statiView.$el);
|
|
}
|
|
else
|
|
this.statiView.render();
|
|
},
|
|
clickMenu: function(event) {
|
|
var item = $(event.target);
|
|
//var clickedItem = event.args;
|
|
if(item[0].id === "addRicetta" ||
|
|
item[0].lastChild.id === "addRicetta")
|
|
{
|
|
event.data.scope.addRicetta();
|
|
}
|
|
else if(item[0].id === "modifyRicetta" ||
|
|
item[0].lastChild.id === "modifyRicetta")
|
|
{
|
|
event.data.scope.modifyRicetta();
|
|
}
|
|
else if(item[0].id === "viewPhotos" ||
|
|
item[0].lastChild.id === "viewPhotos")
|
|
{
|
|
event.data.scope.photosView();
|
|
}
|
|
else if(item[0].id === "viewStatistics" ||
|
|
item[0].lastChild.id === "viewStatistics")
|
|
{
|
|
event.data.scope.statisticsView();
|
|
}
|
|
},
|
|
//render the content into div of view
|
|
render: function() {
|
|
//this.header.title = "pippo";
|
|
HomeView.__super__.render.call(this);
|
|
|
|
if ($('#jqxMenu').length === 0)
|
|
{
|
|
this.$el.append(this.template());
|
|
|
|
this.$el.find("#jqxMenu").jqxMenu({
|
|
width: '60%',
|
|
height: '30px'
|
|
});
|
|
|
|
this.$el.find('#jqxMenu').on('itemclick', { scope: this }, this.clickMenu);
|
|
}
|
|
|
|
//$("#homeBtn").addClass("ui-btn-active");
|
|
//return to enable chained calls
|
|
return this;
|
|
}
|
|
});
|
|
return HomeView;
|
|
}); |