git-svn-id: https://msi/svn/firstRepo/WebClient/branches/NewRelease@33 0f545695-f87b-41b6-9a03-7f16563b5454

This commit is contained in:
2015-05-07 13:16:11 +00:00
parent d0d55ee8e5
commit 282ad76c48
79 changed files with 2416 additions and 1824 deletions
+69 -54
View File
@@ -2,19 +2,45 @@ define(['jquery', 'underscore', 'backbone',
'modules/home/home', 'modules/faq/faq', 'modules/index/index', 'modules/category/category', 'modules/item/item',
'modules/about/about', 'modules/search/search', 'modules/search/found', 'modules/more/more', 'modules/note/note',
'modules/sync/sync', 'modules/converter/converter', 'modules/donation/donation', 'modules/settings/settings',
'modules/debug/debug',
'model/note/noteCollection', 'model/category/categoryCollection', 'model/categoryItem/categoryItemCollection',
'model/item/itemCollection', 'model/item/ingredientiCollection', 'model/categoryItem/foundItemCollection',
'libs/fastclick', 'classes/cache', 'jqm', 'jQueryPlugins'],
'classes/cache', 'libs/fastclick',
'jqm', 'jQueryPlugins'],
function ($, _, Backbone,
HomeView, FaqView, IndexView, CategoryView, ItemView,
AboutView, SearchView, FoundView, MoreView, NoteView,
SyncView, ConverterView, DonationView, SettingsView,
DebugView,
NoteCollection, CategoryCollection, CategoryItemCollection,
ItemCollection, IngredientiCollection, FoundItemCollection,
FastClick, Cache) {
Cache, FastClick) {
'use strict';
var Router = Backbone.Router.extend({
initialize: function (options) {
var self = this;
$(document).on("pagecontainershow", function (event, ui) {
try
{
ga('send', 'pageview',
{
'page': "/" + this.location.hash,
'title': document.title
});
}
catch (err)
{
}
if (self.activeView.onShowed !== null)
self.activeView.onShowed();
// if (self.fastClickInstance !== null)
// self.fastClickInstance.destroy();
// self.fastClickInstance = FastClick.attach(document.body);
});
},
//define routes and mapping route to the function
routes: {
'': 'showHome', //home view
@@ -27,13 +53,14 @@ define(['jquery', 'underscore', 'backbone',
'syncView(/)*founded': 'showSync',
'noteView': 'showNote',
'searchView': 'showSearch',
'debugView': 'showDebug',
'settingsView': 'showSettings',
'donationView': 'showDonation',
'search/:nresult/:categoria/:difficolta/*titolo': 'searchFn',
'converterView': 'showConverter',
'moreView': 'showMore',
'*actions': 'defaultAction' //default action
},
},
defaultAction: function (actions) {
this.showHome(actions);
},
@@ -85,27 +112,29 @@ define(['jquery', 'underscore', 'backbone',
},
showIndex: function (actions) {
Cache.checkCacheFromServer();
var categories = new CategoryCollection();
//var categories = new CategoryCollection();
// will render home view and navigate to homeView
var indexView = new IndexView({collection: categories});
//indexView.render();
indexView.bind('renderCompleted:Categories', this.changePage, this);
var indexView = new IndexView();//{collection: categories});
indexView.render();
this.changePage(indexView);
//indexView.bind('renderCompleted:Categories', this.changePage, this);
},
showCategory: function (categoryName, categoryId) {
var categories = new CategoryItemCollection({categoryId: categoryId});
// will render home view and navigate to homeView
var categoryView = new CategoryView({categoryName: categoryName, collection: categories});
var categoryView = new CategoryView({categoryName: categoryName, categoryId: categoryId, collection: categories});
categoryView.render();
this.changePage(categoryView);
$.mobile.loading('show', {
text: 'Caricamento categoria ' + categoryName + '...',
textVisible: true,
//theme: 'z',
html: ""
});
if(!categories.isCached() || categoryView.created){
$.mobile.loading('show', {
text: 'Caricamento categoria ' + categoryName + '...',
textVisible: true,
//theme: 'z',
html: ""
});
}
//categoryView.bind('renderCompleted:Category',this.changePage,this);
},
showItem: function (itemId) {
@@ -129,6 +158,11 @@ define(['jquery', 'underscore', 'backbone',
moreView.render();
this.changePage(moreView);
},
showDebug: function () {
var debugView = new DebugView();
debugView.render();
this.changePage(debugView);
},
showSearch: function () {
var categories = new CategoryCollection();
// will render home view and navigate to homeView
@@ -137,9 +171,7 @@ define(['jquery', 'underscore', 'backbone',
searchView.bind('renderCompleted:Search', this.changePage, this);
},
searchFn: function (nresult, categoria, difficolta, titolo) {
//console.log("Search by Titolo: " + titolo + ", Categoria: " + categoria + ", Difficoltà: " + difficolta);
var foundedItems = new FoundItemCollection({categoryId: categoria, difficolta: difficolta, titolo: titolo, nResult: nresult});
var foundedItems = new FoundItemCollection({categoryId: categoria, difficolta: difficolta, titolo: titolo, nResult: nresult, indexItems: 0});
var foundView = new FoundView({collection: foundedItems});
foundView.render();
@@ -152,52 +184,35 @@ define(['jquery', 'underscore', 'backbone',
html: ""
});
},
init: true,
fastClickInstance: null,
activeView: null,
//1. changePage will insert view into DOM and then call changePage to enhance and transition
//2. for the first page, jQuery mobile will present and enhance automatically
//3. for the other page, we will call $.mobile.changePage() to enhance page and make transition
//4. argument 'view' is passed from event trigger
changePage: function (view) {
var self = this;
//append to dom
$('body').append(view.$el);
if (view.created === true)
{
$('body').append(view.$el);
}
if (this.activeView !== null &&
this.activeView.onClosing !== null)
this.activeView.onClosing();
$.mobile.pageContainer.pagecontainer("change", $(view.el), {changeHash: false});
FastClick.attach(document.body);
var lastView = this.activeView;
this.activeView = view;
$(":jqmData(role='page'):last").on("pageshow", function (event) {
if (view.onShowed !== null)
view.onShowed();
});
if (lastView !== null &&
lastView.onClosed !== null)
lastView.onClosed();
$('input[type=radio].star').rating({
callback: function (value, link) {
var tip = $('#hover-test');
if (value === undefined)
{
$('#hover-test').html("Nessuna" || 'value: ');
}
else
$('#hover-test').html(link.title || 'value: ' + value);
},
focus: function (value, link) {
var tip = $('#hover-test');
tip[0].data = tip[0].data || tip.html();
tip.html(link.title || 'value: ' + value);
}
// ,
// blur: function(value, link){
// var tip = $('#hover-test');
// $('#hover-test').html(tip[0].data || '');
// }
});
if (!this.init) {
} else {
this.init = false;
}
if (this.activeView.onShowing !== null)
this.activeView.onShowing();
}
});