git-svn-id: https://msi/svn/firstRepo/WebClient/trunk@15 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -1,29 +1,33 @@
|
||||
define(['jquery','underscore', 'backbone', 'router', 'classes/profile'],function
|
||||
($, _, Backbone,Router, Profile) {
|
||||
'use strict';
|
||||
var init=function(){
|
||||
//create backbone router
|
||||
var router=new Router();
|
||||
Backbone.history.start();
|
||||
Backbone.emulateJSON = true;
|
||||
var origin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') + (location.pathname?location.pathname:'');
|
||||
openFB.init('1466942266882168', origin, window.localStorage);
|
||||
openGPlus.init('319140243944-qk0lfhgmi8shi4go97r83l69f1k0gdf4.apps.googleusercontent.com', origin, window.localStorage);
|
||||
//console.log("Backbone history start");
|
||||
// Trigger 'route' event on router instance.
|
||||
router.on('route', function(name, args) {
|
||||
//alert(name);
|
||||
});
|
||||
define(['jquery','underscore', 'backbone', 'router', 'classes/profile'],
|
||||
function($, _, Backbone, Router, Profile) {
|
||||
|
||||
var Application={
|
||||
_retThis: function() {
|
||||
return this;
|
||||
},
|
||||
router: null,
|
||||
initialize:function(){
|
||||
//create backbone router
|
||||
this.router=new Router();
|
||||
Backbone.history.start();
|
||||
Backbone.emulateJSON = true;
|
||||
var origin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') + (location.pathname?location.pathname:'');
|
||||
openFB.init('1466942266882168', origin, window.localStorage);
|
||||
openGPlus.init('319140243944-qk0lfhgmi8shi4go97r83l69f1k0gdf4.apps.googleusercontent.com', origin, window.localStorage);
|
||||
//console.log("Backbone history start");
|
||||
// Trigger 'route' event on router instance.
|
||||
this.router.on('route', function(name, args) {
|
||||
//alert(name);
|
||||
});
|
||||
|
||||
if( Profile.isConnected()) {
|
||||
Profile.loadProfile();
|
||||
if( Profile.isConnected()) {
|
||||
Profile.loadProfile();
|
||||
}
|
||||
|
||||
$('body').css('background-color', '');
|
||||
$('#loadingFrm').remove();
|
||||
}
|
||||
|
||||
$('body').css('background-color', '');
|
||||
$('#loadingFrm').remove();
|
||||
};
|
||||
|
||||
return {
|
||||
initialize:init
|
||||
};
|
||||
return Application._retThis();
|
||||
});
|
||||
@@ -27,7 +27,8 @@ define(['jquery', 'backbone'],
|
||||
"gender":null,
|
||||
"tema": 'b',
|
||||
"risRic": '10',
|
||||
"type": null
|
||||
"type": null,
|
||||
"lastNumRicette": null
|
||||
},
|
||||
|
||||
isConnected: function(){
|
||||
@@ -64,12 +65,16 @@ define(['jquery', 'backbone'],
|
||||
self.data.tema = response[0].TemaUI;
|
||||
self.data.risRic = response[0].RisultatiRicerca;
|
||||
self.data.type = response[0].TipoAccesso;
|
||||
self.data.lastNumRicette = response[0].NumRicette;
|
||||
retBool = true;
|
||||
}
|
||||
if(successFn)
|
||||
successFn(retBool);
|
||||
},
|
||||
|
||||
getLastNumRicette: function(){
|
||||
return this.data.lastNumRicette;
|
||||
},
|
||||
getKeySave: function(){
|
||||
return window.localStorage.getItem("KeySave");
|
||||
},
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
/**
|
||||
* Created by Denis on 19/06/2014.
|
||||
*/
|
||||
define(['jquery', 'backbone','libs/fastclick', 'jqm', 'jQueryPlugins'],
|
||||
function($, Backbone, FastClick){
|
||||
|
||||
var Utility = {
|
||||
retMe: function(){
|
||||
return this;
|
||||
},
|
||||
changePage: function(view){
|
||||
//append to dom
|
||||
$('body').append(view.$el);
|
||||
|
||||
$.mobile.pageContainer.pagecontainer ("change", $(view.el), {changeHash:false});
|
||||
|
||||
FastClick.attach(document.body);
|
||||
|
||||
$(":jqmData(role='page'):last").on("pageshow", function (event) {
|
||||
if (view.onShowed !== null)
|
||||
view.onShowed();
|
||||
});
|
||||
|
||||
$('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);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return Utility.retMe();
|
||||
});
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
var pathJquery = "http://ajax.googleapis.com/ajax/libs/jquery/" + myManifest.Settings.JQueryVersion + "/jquery.min";
|
||||
var pathJqueryMobile = "http://ajax.googleapis.com/ajax/libs/jquerymobile/"+ myManifest.Settings.JQueryMobileVersion + "/jquery.mobile.min";
|
||||
var pathJqueryMobile = "http://code.jquery.com/mobile/" + myManifest.Settings.JQueryMobileVersion + "/jquery.mobile-" + myManifest.Settings.JQueryMobileVersion + ".min";
|
||||
// "http://ajax.googleapis.com/ajax/libs/jquerymobile/"+ myManifest.Settings.JQueryMobileVersion + "/jquery.mobile.min";
|
||||
|
||||
requirejs.config({
|
||||
baseUrl: 'js',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['jquery', 'underscore', 'backbone','text!controls/header/headerTemplate.html'],
|
||||
function($, _, Backbone, headerTemplate){
|
||||
define(['jquery', 'underscore', 'backbone','text!controls/header/headerTemplate.html', 'classes/profile'],
|
||||
function($, _, Backbone, headerTemplate, Profile){
|
||||
|
||||
var header = Backbone.View.extend({
|
||||
|
||||
@@ -22,6 +22,7 @@ define(['jquery', 'underscore', 'backbone','text!controls/header/headerTemplate.
|
||||
//append the compiled template into view div container
|
||||
this.$el.append(this.template( { "title":this.title } ));
|
||||
|
||||
this.$el.find('#notifyBtn').closest('.ui-btn').hide();
|
||||
//return to enable chained calls
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
<a href="#homeView" class="nav-glyphish-example ui-btn ui-icon-myHome ui-btn-icon-notext">Home</a>
|
||||
<h4><%= title %></h4>
|
||||
<a id="homeBtn" href="#homeView" class="nav-glyphish-example ui-btn ui-icon-myHome ui-btn-icon-notext">Home</a>
|
||||
<h4><%= title %></h4>
|
||||
<a href="#newsView" id="notifyBtn" class="ui-btn ui-icon-withoutCorner ui-btn-icon-notext">News<div class="circle">3</div></a>
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
//1. load app.js,
|
||||
//2. configure jquery mobile to prevent default JQM ajax navigation
|
||||
//3. bootstrapping application
|
||||
define(["app", "jqm", "jqm-config", 'jQueryPlugins'], function( app ){
|
||||
define(["app", "jqm", "jqm-config", 'jQueryPlugins'],
|
||||
function( app ){
|
||||
if(myManifest.Agent.browser.name == "IE Mobile" && myManifest.Agent.browser.version <= 9 ) {
|
||||
window.location.href = "http://old.gruppolapastamadre.it";
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,20 +1,20 @@
|
||||
var myManifest = {
|
||||
Debug: false,
|
||||
Name: "Il Lievitario",
|
||||
Version: "2.2.3",
|
||||
Version: "3.0.0.0",
|
||||
Author: "Denis Ironi",
|
||||
Settings: {
|
||||
//DefaultURL: "http://localhost:8081/Service",
|
||||
DefaultURL: "http://app.gruppolapastamadre.it/Service",
|
||||
DefaultURL: "http://localhost:8081/Service",
|
||||
//DefaultURL: "http://dev.gruppolapastamadre.it/Service",
|
||||
JQueryVersion: "1.11.1",
|
||||
JQueryMobileVersion: "1.4.3",
|
||||
Device:{
|
||||
JQueryMobileVersion: "1.4.5",
|
||||
Device: {
|
||||
Width: (window.innerWidth > 0) ? window.innerWidth : screen.width,
|
||||
Height: (window.innerHeight > 0) ? window.innerHeight : screen.height
|
||||
}
|
||||
},
|
||||
Agent: (new UAParser()).getResult(),
|
||||
getUrlArg: function(){
|
||||
Agent: (new UAParser()).getResult(),
|
||||
getUrlArg: function() {
|
||||
return (this.Debug ? this.Version + "." + (Math.random() * 1000) : this.Version);
|
||||
}
|
||||
};
|
||||
@@ -11,7 +11,7 @@ var CategoryItems=Backbone.Collection.extend({
|
||||
model:Category,
|
||||
|
||||
url: function() {
|
||||
return myManifest.Settings.DefaultURL + "/api/categoryitems/" + this.categoryId;
|
||||
return myManifest.Settings.DefaultURL + "/api/ricette/" + this.categoryId;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['jquery', 'underscore', 'backbone'],
|
||||
function ($, _, Backbone){
|
||||
function($, _, Backbone) {
|
||||
|
||||
var CategoryItem = Backbone.Model.extend({
|
||||
//default attributes
|
||||
@@ -13,6 +13,6 @@ function ($, _, Backbone){
|
||||
}
|
||||
});
|
||||
|
||||
return CategoryItem;
|
||||
});
|
||||
return CategoryItem;
|
||||
});
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ define(['app', 'jquery', 'underscore', 'backbone', 'model/categoryItem/categoryI
|
||||
model:Category,
|
||||
|
||||
url: function() {
|
||||
var u = myManifest.Settings.DefaultURL + "/api/categoryitems/search/" + this.numItems +
|
||||
var u = myManifest.Settings.DefaultURL + "/api/ricette/search/" + this.numItems +
|
||||
"/" + this.dataFilter.categoryId +
|
||||
"/" + this.dataFilter.difficolta;
|
||||
if(this.dataFilter.titolo !== null)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
define(['app', 'jquery', 'underscore', 'backbone', 'model/lastRicette/lastRicetteModel'],
|
||||
function (app, $, _, Backbone, LastRicette){
|
||||
|
||||
var lastRicette=Backbone.Collection.extend({
|
||||
|
||||
profileID: null,
|
||||
initialize: function (options) {
|
||||
this.profileID = options.profileID;
|
||||
},
|
||||
// Book is the model of the collection
|
||||
model:LastRicette,
|
||||
|
||||
url: function() {
|
||||
return myManifest.Settings.DefaultURL + "/api/ricette/lastinserted/" + this.profileID;
|
||||
}
|
||||
});
|
||||
|
||||
return lastRicette;
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
define(['jquery', 'underscore', 'backbone'],
|
||||
function($, _, Backbone) {
|
||||
|
||||
var LastRicette = Backbone.Model.extend({
|
||||
//default attributes
|
||||
defaults: {
|
||||
ricetta_id: "",
|
||||
titolo: '',
|
||||
autore: '',
|
||||
valutazione: 0,
|
||||
difficolta: 0,
|
||||
categoria_name: ''
|
||||
}
|
||||
});
|
||||
|
||||
return LastRicette;
|
||||
});
|
||||
|
||||
@@ -1,54 +1,50 @@
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/category/categoryViewTemplate.html', 'text!modules/category/categoryItemTemplate.html', 'modules/base/baseView'],
|
||||
function($, _, Backbone, categoryViewTemplate, categoryItemTemplate, BaseView){
|
||||
define(['jquery', 'underscore', 'backbone', 'text!modules/category/categoryViewTemplate.html', 'text!modules/category/categoryItemTemplate.html', 'modules/base/baseView'],
|
||||
function($, _, Backbone, categoryViewTemplate, categoryItemTemplate, BaseView) {
|
||||
|
||||
var CategoryView = BaseView.extend({
|
||||
var CategoryView = BaseView.extend({
|
||||
collection: null,
|
||||
categoryName: null,
|
||||
//initialize template
|
||||
template: _.template(categoryViewTemplate),
|
||||
itemtemplate: _.template(categoryItemTemplate),
|
||||
initialize: function(options) {
|
||||
var self = this;
|
||||
CategoryView.__super__.initialize.call(this);
|
||||
this.collection = options.collection;
|
||||
this.categoryName = options.categoryName;
|
||||
this.collection.fetch({
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
self.renderItem();
|
||||
}
|
||||
//success: function(){ self.renderItem(); }
|
||||
});
|
||||
},
|
||||
renderItem: function() {
|
||||
var $ul = $('#allRicette');
|
||||
|
||||
collection: null,
|
||||
categoryName: null,
|
||||
//initialize template
|
||||
template:_.template(categoryViewTemplate),
|
||||
itemtemplate:_.template(categoryItemTemplate),
|
||||
|
||||
initialize: function (options) {
|
||||
var self = this;
|
||||
CategoryView.__super__.initialize.call(this);
|
||||
this.collection = options.collection;
|
||||
this.categoryName = options.categoryName;
|
||||
this.collection.fetch({
|
||||
success: function(data, textStatus, jqXHR){
|
||||
self.renderItem();
|
||||
}
|
||||
//success: function(){ self.renderItem(); }
|
||||
});
|
||||
},
|
||||
|
||||
renderItem: function(){
|
||||
var $ul = $('#allRicette');
|
||||
|
||||
var items = this.itemtemplate({data:this.collection.toJSON()});
|
||||
|
||||
$ul.html( items );
|
||||
$ul.listview( "refresh" );
|
||||
$ul.trigger( "updatelayout");
|
||||
|
||||
$.mobile.loading( 'hide' );
|
||||
//$( '[data-alpha="true"]' ).alphascroll();
|
||||
},
|
||||
|
||||
//render the content into div of view
|
||||
render: function(){
|
||||
//this.header.title = "pippo";
|
||||
CategoryView.__super__.render.call(this);
|
||||
//this.el is the root element of Backbone.View. By default, it is a div.
|
||||
//$el is cached jQuery object for the view's element.
|
||||
//append the compiled template into view div container
|
||||
this.$el.append(this.header.$el);
|
||||
this.$el.append(this.template({ categoryName: this.categoryName }));
|
||||
this.$el.append(this.footer.$el);
|
||||
//return to enable chained calls
|
||||
this.$el.find("#indexBtn").addClass("ui-btn-active");
|
||||
return this;
|
||||
}
|
||||
});
|
||||
return CategoryView;
|
||||
});
|
||||
var items = this.itemtemplate({data: this.collection.toJSON()});
|
||||
|
||||
$ul.html(items);
|
||||
$ul.listview("refresh");
|
||||
$ul.trigger("updatelayout");
|
||||
|
||||
$.mobile.loading('hide');
|
||||
//$( '[data-alpha="true"]' ).alphascroll();
|
||||
},
|
||||
//render the content into div of view
|
||||
render: function() {
|
||||
//this.header.title = "pippo";
|
||||
CategoryView.__super__.render.call(this);
|
||||
//this.el is the root element of Backbone.View. By default, it is a div.
|
||||
//$el is cached jQuery object for the view's element.
|
||||
//append the compiled template into view div container
|
||||
this.$el.append(this.header.$el);
|
||||
this.$el.append(this.template({categoryName: this.categoryName}));
|
||||
this.$el.append(this.footer.$el);
|
||||
//return to enable chained calls
|
||||
this.$el.find("#indexBtn").addClass("ui-btn-active");
|
||||
return this;
|
||||
}
|
||||
});
|
||||
return CategoryView;
|
||||
});
|
||||
+21
-3
@@ -1,5 +1,7 @@
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/home/homeViewTemplate.html', 'modules/base/baseView', 'classes/profile'],
|
||||
function($, _, Backbone, homeViewTemplate, BaseView, Profile){
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/home/homeViewTemplate.html',
|
||||
'modules/base/baseView', 'classes/profile', 'classes/utility', 'model/lastRicette/lastRicetteCollection', 'modules/lastricette/lastRicette'],
|
||||
function($, _, Backbone, homeViewTemplate,
|
||||
BaseView, Profile, Utility, LastRicetteCollection, LastRicette ){
|
||||
|
||||
var HomeView = BaseView.extend({
|
||||
|
||||
@@ -12,7 +14,8 @@ define(['jquery', 'underscore', 'backbone','text!modules/home/homeViewTemplate.h
|
||||
},
|
||||
|
||||
events: {
|
||||
"click #goFbGroup": "goFbGroup"
|
||||
"click #goFbGroup": "goFbGroup",
|
||||
"click #notifyBtn": "onNotifyBtn"
|
||||
},
|
||||
|
||||
goFbGroup: function(){
|
||||
@@ -20,6 +23,14 @@ define(['jquery', 'underscore', 'backbone','text!modules/home/homeViewTemplate.h
|
||||
window.location.href = "https://www.facebook.com/groups/732844273469518/";
|
||||
},
|
||||
|
||||
onNotifyBtn:function(){
|
||||
var lastricette = new LastRicetteCollection();
|
||||
// will render home view and navigate to homeView
|
||||
var lastRicetteView=new LastRicette({ collection: lastricette});
|
||||
//indexView.render();
|
||||
lastRicetteView.bind('renderCompleted:Categories',Utility.changePage,this);
|
||||
},
|
||||
|
||||
onShowed: function()
|
||||
{
|
||||
if(window.localStorage.getItem("goFbGroup") !== "1")
|
||||
@@ -38,6 +49,13 @@ define(['jquery', 'underscore', 'backbone','text!modules/home/homeViewTemplate.h
|
||||
this.$el.append(this.footer.$el);
|
||||
this.$el.find("#homeBtn").addClass("ui-btn-active");
|
||||
|
||||
var lastNumRicette = Profile.getLastNumRicette();
|
||||
//if( lastNumRicette > 0)
|
||||
{
|
||||
this.$el.find('#notifyBtn').closest('.ui-btn').show();
|
||||
this.$el.find('#notifyBtn').addClass("notification");
|
||||
this.$el.find('.circle').text(12);
|
||||
}
|
||||
//$("#homeBtn").addClass("ui-btn-active");
|
||||
//return to enable chained calls
|
||||
return this;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<div data-role="content">
|
||||
<div style="text-align: center;">
|
||||
<div style="text-align: center;">
|
||||
<% if(profile.data.name){ %>
|
||||
<h2 id="benvenuto">Bentornat<% if(profile.data.gender=="male"){%>o<%}else{%>a<%}%>
|
||||
<br><%=profile.data.name %></h2>
|
||||
<% } %>
|
||||
<img id="sfondo" src="https://dl.dropboxusercontent.com/s/6qrdp9mbi1rb92k/sfondo.png">
|
||||
<img id="sfondo" src="https://dl.dropboxusercontent.com/s/6qrdp9mbi1rb92k/sfondo.png">
|
||||
</div>
|
||||
</div>
|
||||
<div data-role="popup" id="nuovoGruppo" data-history="false" data-dismissible="false">
|
||||
<div data-role="header"><h1>IMPORTANTE</h1></div>
|
||||
<div role="main" class="ui-content">
|
||||
<div role="main" class="ui-content">
|
||||
<p style="text-align: center;font-style: italic;">
|
||||
<img src="https://dl.dropboxusercontent.com/s/xnbrbbe7eejkfv2/festa.png"><br><br>
|
||||
Le admin <br><br><b>Alessia, Elena e Francesca</b><br><br>hanno RIFONDATO IL GRUPPO!!<br>
|
||||
|
||||
+166
-98
@@ -1,21 +1,18 @@
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/item/itemViewTemplate.html', 'modules/base/baseView', 'classes/profile'],
|
||||
function($, _, Backbone, itemViewTemplate, BaseView, Profile){
|
||||
define(['jquery', 'underscore', 'backbone', 'text!modules/item/itemViewTemplate.html', 'modules/base/baseView', 'classes/profile'],
|
||||
function($, _, Backbone, itemViewTemplate, BaseView, Profile) {
|
||||
|
||||
var ItemView = BaseView.extend({
|
||||
|
||||
collRicetta: null,
|
||||
collIngredienti: null,
|
||||
|
||||
fetchedRicetta: false,
|
||||
fetchedIngredienti: false,
|
||||
//initialize template
|
||||
template:_.template(itemViewTemplate),
|
||||
|
||||
initialize: function (options) {
|
||||
var self = this;
|
||||
ItemView.__super__.initialize.call(this);
|
||||
this.collRicetta = options.collRicetta;
|
||||
this.collIngredienti = options.collIngredienti;
|
||||
var ItemView = BaseView.extend({
|
||||
collRicetta: null,
|
||||
collIngredienti: null,
|
||||
fetchedRicetta: false,
|
||||
fetchedIngredienti: false,
|
||||
//initialize template
|
||||
template: _.template(itemViewTemplate),
|
||||
initialize: function(options) {
|
||||
var self = this;
|
||||
ItemView.__super__.initialize.call(this);
|
||||
this.collRicetta = options.collRicetta;
|
||||
this.collIngredienti = options.collIngredienti;
|
||||
|
||||
this.collRicetta.fetch({success: function() {
|
||||
self.fetchedRicetta = true;
|
||||
@@ -26,88 +23,160 @@ define(['jquery', 'underscore', 'backbone','text!modules/item/itemViewTemplate.h
|
||||
self.render();
|
||||
}});
|
||||
},
|
||||
|
||||
events: {
|
||||
"click #favoriteBtn": "favBtn",
|
||||
"click #backBtn": "backBtn"
|
||||
},
|
||||
|
||||
backBtn:function(e){
|
||||
e.preventDefault();
|
||||
window.history.back();
|
||||
},
|
||||
|
||||
favBtn:function(e){
|
||||
e.preventDefault();
|
||||
var self = this;
|
||||
var ric = this.collRicetta.toJSON()[0];
|
||||
|
||||
if(!Profile.isConnected())
|
||||
{
|
||||
self.$el.find('#popupDialog').popup("open");
|
||||
return;
|
||||
}
|
||||
|
||||
Profile.addRicettaBloccoNote(ric.ricetta_id,
|
||||
function(msg) {
|
||||
var favBtn = self.$el.find('#favoriteBtn');
|
||||
favBtn.addClass('ui-disabled');
|
||||
}
|
||||
);
|
||||
},
|
||||
//render the content into div of view
|
||||
render: function(){
|
||||
if(this.fetchedIngredienti && this.fetchedRicetta )
|
||||
{
|
||||
ItemView.__super__.render.call(this);
|
||||
events: {
|
||||
"click #favoriteBtn": "favBtn",
|
||||
"click #optionBtn": "optionBtn",
|
||||
"click #backBtn": "backBtn",
|
||||
"click #scattaPhotoBtn": "scattaPhotoBtn",
|
||||
"change #cameraFile": "cameraFileChanged",
|
||||
"click #uploadPhotoBtn": "uploadPhotoBtn",
|
||||
"change #galleyFile": "galleyFileChanged"
|
||||
},
|
||||
backBtn: function(e) {
|
||||
e.preventDefault();
|
||||
window.history.back();
|
||||
},
|
||||
optionBtn: function(e) {
|
||||
e.preventDefault();
|
||||
var self = this;
|
||||
self.$el.find('#optionPopupDialog').popup("open");
|
||||
},
|
||||
scattaPhotoBtn: function(e) {
|
||||
e.preventDefault();
|
||||
var self = this;
|
||||
|
||||
var ric = self.collRicetta.toJSON()[0];
|
||||
if (!Profile.isConnected())
|
||||
{
|
||||
self.$el.find('#popupDialog').popup("open");
|
||||
return;
|
||||
}
|
||||
|
||||
Profile.existRicettaBloccoNote(ric.ricetta_id,
|
||||
function(exist) {
|
||||
self.$el.append(self.template({
|
||||
ricetta: self.collRicetta.toJSON()[0],
|
||||
ingredienti: self.collIngredienti.toJSON()
|
||||
}));
|
||||
$("#cameraFile").click();
|
||||
},
|
||||
uploadPhotoBtn: function(e) {
|
||||
e.preventDefault();
|
||||
var self = this;
|
||||
|
||||
self.$arrayContent = self.$el.find('div[data-role="content"]');
|
||||
self.$arrayNavBar = self.$el.find('div[data-role="navbar"] a');
|
||||
if (!Profile.isConnected())
|
||||
{
|
||||
self.$el.find('#popupDialog').popup("open");
|
||||
return;
|
||||
}
|
||||
|
||||
var favBtn = self.$el.find('#favoriteBtn');
|
||||
if(exist > 0)
|
||||
favBtn.addClass('ui-disabled');
|
||||
$("#galleyFile").click();
|
||||
},
|
||||
loadPhoto: function(objInputFile){
|
||||
var self = this;
|
||||
self.$el.find('#optionPopupDialog').popup("close");
|
||||
$.mobile.loading( "show", {
|
||||
text: "Caricamento immagine in corso...",
|
||||
textVisible: true,
|
||||
theme: "a",
|
||||
textonly: false
|
||||
});
|
||||
|
||||
var ric = this.collRicetta.toJSON()[0];
|
||||
|
||||
self.$arrayNavBar.on("click", function(e){
|
||||
e.preventDefault();
|
||||
var index = jQuery.inArray( this , self.$arrayNavBar);
|
||||
self.goToContent(index);
|
||||
});
|
||||
var data = new FormData();
|
||||
data.append("ricetta_id", ric.ricetta_id);
|
||||
data.append("image", objInputFile[0].files[0]);
|
||||
data.append("keyStore", Profile.getKeySave());
|
||||
|
||||
self.$arrayContent.on("swipeleft", function(e) {
|
||||
var index = jQuery.inArray(this, self.$arrayContent);
|
||||
self.goToContent(index + 1 );
|
||||
});
|
||||
self.$arrayContent.on("swiperight", function(e) {
|
||||
var index = jQuery.inArray(this, self.$arrayContent);
|
||||
self.goToContent(index - 1 );
|
||||
});
|
||||
self.trigger("renderCompleted:Item",self);
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/photos",
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(msg) {
|
||||
$.mobile.loading( "hide" );
|
||||
alert("Immagine inviata con successo\n\nSarà cura degl'admin di validare la foto inviata");
|
||||
objInputFile.val("");
|
||||
}
|
||||
});
|
||||
},
|
||||
galleyFileChanged: function(e) {
|
||||
e.preventDefault();
|
||||
this.loadPhoto($("#galleyFile"));
|
||||
},
|
||||
cameraFileChanged: function(e) {
|
||||
e.preventDefault();
|
||||
this.loadPhoto($("#cameraFile"));
|
||||
},
|
||||
favBtn: function(e) {
|
||||
e.preventDefault();
|
||||
var self = this;
|
||||
var ric = this.collRicetta.toJSON()[0];
|
||||
|
||||
if (!Profile.isConnected())
|
||||
{
|
||||
self.$el.find('#popupDialog').popup("open");
|
||||
return;
|
||||
}
|
||||
|
||||
Profile.addRicettaBloccoNote(ric.ricetta_id,
|
||||
function(msg) {
|
||||
var favBtn = self.$el.find('#favoriteBtn');
|
||||
favBtn.addClass('ui-disabled');
|
||||
}
|
||||
);
|
||||
},
|
||||
//render the content into div of view
|
||||
render: function() {
|
||||
if (this.fetchedIngredienti && this.fetchedRicetta)
|
||||
{
|
||||
ItemView.__super__.render.call(this);
|
||||
var self = this;
|
||||
|
||||
var ric = self.collRicetta.toJSON()[0];
|
||||
|
||||
Profile.existRicettaBloccoNote(ric.ricetta_id,
|
||||
function(exist) {
|
||||
self.$el.append(self.template({
|
||||
ricetta: self.collRicetta.toJSON()[0],
|
||||
ingredienti: self.collIngredienti.toJSON()
|
||||
}));
|
||||
|
||||
self.$arrayContent = self.$el.find('div[data-role="content"]');
|
||||
self.$arrayNavBar = self.$el.find('div[data-role="navbar"] a');
|
||||
|
||||
var favBtn = self.$el.find('#favoriteBtn');
|
||||
if (exist > 0)
|
||||
favBtn.addClass('ui-disabled');
|
||||
|
||||
self.$arrayNavBar.on("click", function(e) {
|
||||
e.preventDefault();
|
||||
var index = jQuery.inArray(this, self.$arrayNavBar);
|
||||
self.goToContent(index);
|
||||
});
|
||||
|
||||
self.$arrayContent.on("swipeleft", function(e) {
|
||||
var index = jQuery.inArray(this, self.$arrayContent);
|
||||
self.goToContent(index + 1 );
|
||||
});
|
||||
self.$arrayContent.on("swiperight", function(e) {
|
||||
var index = jQuery.inArray(this, self.$arrayContent);
|
||||
self.goToContent(index - 1 );
|
||||
});
|
||||
// self.$arrayContent.on("tap", function(e) {
|
||||
// self.optionBtn(e);
|
||||
// });
|
||||
self.trigger("renderCompleted:Item", self);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
//this.el is the root element of Backbone.View. By default, it is a div.
|
||||
//$el is cached jQuery object for the view's element.
|
||||
//append the compiled template into view div container
|
||||
//this.el is the root element of Backbone.View. By default, it is a div.
|
||||
//$el is cached jQuery object for the view's element.
|
||||
//append the compiled template into view div container
|
||||
|
||||
//return to enable chained calls
|
||||
return this;
|
||||
}
|
||||
},
|
||||
|
||||
goToContent:function(newIndex)
|
||||
//return to enable chained calls
|
||||
return this;
|
||||
}
|
||||
},
|
||||
goToContent: function(newIndex)
|
||||
{
|
||||
if(this.$arrayContent.length > newIndex && newIndex >= 0)
|
||||
{
|
||||
@@ -115,15 +184,14 @@ define(['jquery', 'underscore', 'backbone','text!modules/item/itemViewTemplate.h
|
||||
this.switchContent();
|
||||
}
|
||||
},
|
||||
|
||||
switchContent: function(){
|
||||
this.$arrayContent.hide();
|
||||
this.$arrayNavBar.removeClass('ui-btn-active');
|
||||
this.$arrayNavBar.removeClass('ui-state-persist');
|
||||
$(this.$arrayContent[this.indexContent]).show();
|
||||
$(this.$arrayNavBar[this.indexContent]).addClass('ui-btn-active');
|
||||
$(this.$arrayNavBar[this.indexContent]).addClass('ui-state-persist');
|
||||
}
|
||||
});
|
||||
return ItemView;
|
||||
});
|
||||
switchContent: function() {
|
||||
this.$arrayContent.hide();
|
||||
this.$arrayNavBar.removeClass('ui-btn-active');
|
||||
this.$arrayNavBar.removeClass('ui-state-persist');
|
||||
$(this.$arrayContent[this.indexContent]).show();
|
||||
$(this.$arrayNavBar[this.indexContent]).addClass('ui-btn-active');
|
||||
$(this.$arrayNavBar[this.indexContent]).addClass('ui-state-persist');
|
||||
}
|
||||
});
|
||||
return ItemView;
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
<div data-role="header" data-position="fixed" data-tap-toggle="false">
|
||||
<a id="favoriteBtn" href="" data-role="button" class="ui-btn-left" data-icon="custom" style="font-size: x-small;">Agg. al Blocco</a>
|
||||
<a id="optionBtn" href="" class="ui-btn ui-icon-withoutCorner ui-btn-icon-notext"></a>
|
||||
<h3 id='titoloRicetta'><%= unescape(ricetta.titolo)%></h3>
|
||||
<a id="backBtn" href="" data-role="button" class="ui-btn-right" data-icon="custom">Indietro</a>
|
||||
<a id="backBtn" href="" class="ui-btn ui-icon-withoutCorner ui-btn-icon-notext">Indietro</a>
|
||||
</div>
|
||||
<div id="contentIngredienti" data-role="content">
|
||||
<h1>Ingredienti</h1>
|
||||
@@ -46,6 +46,18 @@
|
||||
<h1 id="linkFonte" style="padding: 0px;"><a target="_blank" href="<%= ricetta.link_fonte%>">Link Fonte</a></h1>
|
||||
<% }%>
|
||||
</div>
|
||||
<div data-role="popup" id="optionPopupDialog">
|
||||
<div data-role="header">
|
||||
<h1>Opzioni</h1>
|
||||
</div>
|
||||
<div role="main" class="ui-content">
|
||||
<a id="favoriteBtn" href="" class="ui-btn ui-icon-withoutCorner ui-btn-icon-left">Agg. al Blocco</a>
|
||||
<a id="scattaPhotoBtn" href="" class="ui-btn ui-icon-withoutCorner ui-btn-icon-left">Scatta Foto</a>
|
||||
<a id="uploadPhotoBtn" href="" class="ui-btn ui-icon-withoutCorner ui-btn-icon-left">Carica Foto</a>
|
||||
<input id="cameraFile" type="file" accept="image/*" capture style="position:absolute; top:-100px; visibility: hidden;">
|
||||
<input id="galleyFile" type="file" accept="image/*" style="position:absolute; top:-100px; visibility: hidden;">
|
||||
</div>
|
||||
</div>
|
||||
<div data-role="popup" id="popupDialog">
|
||||
<div data-role="header">
|
||||
<h1>Informazione</h1>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
define(['jquery', 'underscore', 'backbone', 'text!modules/lastRicette/lastRicetteViewTemplate.html',
|
||||
'text!modules/lastRicette/lastRicetteItemTemplate.html', 'modules/base/baseView'],
|
||||
function($, _, Backbone, lastRicetteViewTemplate, lastRicetteItemTemplate, BaseView) {
|
||||
|
||||
var LastRicetteView = BaseView.extend({
|
||||
collection: null,
|
||||
//initialize template
|
||||
template: _.template(lastRicetteViewTemplate),
|
||||
itemtemplate: _.template(lastRicetteItemTemplate),
|
||||
initialize: function(options) {
|
||||
var self = this;
|
||||
LastRicetteView.__super__.initialize.call(this);
|
||||
this.collection = options.collection;
|
||||
this.collection.fetch({
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
self.renderItem();
|
||||
}
|
||||
//success: function(){ self.renderItem(); }
|
||||
});
|
||||
},
|
||||
renderItem: function() {
|
||||
var $ul = $('#allRicette');
|
||||
|
||||
var items = this.itemtemplate({data: this.collection.toJSON()});
|
||||
|
||||
$ul.html(items);
|
||||
$ul.listview("refresh");
|
||||
$ul.trigger("updatelayout");
|
||||
|
||||
$.mobile.loading('hide');
|
||||
//$( '[data-alpha="true"]' ).alphascroll();
|
||||
},
|
||||
//render the content into div of view
|
||||
render: function() {
|
||||
//this.header.title = "pippo";
|
||||
LastRicetteView.__super__.render.call(this);
|
||||
//this.el is the root element of Backbone.View. By default, it is a div.
|
||||
//$el is cached jQuery object for the view's element.
|
||||
//append the compiled template into view div container
|
||||
this.$el.append(this.header.$el);
|
||||
this.$el.append(this.template());
|
||||
this.$el.append(this.footer.$el);
|
||||
//return to enable chained calls
|
||||
//this.$el.find("#indexBtn").addClass("ui-btn-active");
|
||||
return this;
|
||||
}
|
||||
});
|
||||
return LastRicetteView;
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
<% if(data.length == 0){ %>
|
||||
<h1>Nessuna ricetta trovata</h1>
|
||||
<%} else { for (var i = 0; i < data.length; i++) { %>
|
||||
<% var item = data[i]; %>
|
||||
<li><a href="#ricetta/<%= item.ricetta_id%>" class="ui-btn ui-btn-icon-right ui-icon-carat-r"><div class='ricettaTitolo'><%= unescape(item.titolo) %></div><div class='ricettaAutore'><%= unescape(item.autore) %></div></a></li>
|
||||
<% }} %>
|
||||
@@ -0,0 +1,5 @@
|
||||
<div id="lastRicetteListContent" data-role="content">
|
||||
<h1>Ultime Ricette Inserite</h1>
|
||||
<ul id="allRicette" data-role="listview" data-autodividers="true" data-alpha="true" data-inset="true">
|
||||
</ul>
|
||||
</div>
|
||||
+173
-194
@@ -1,203 +1,182 @@
|
||||
define(['jquery', 'underscore', 'backbone',
|
||||
'modules/home/home', 'modules/faq/faq', 'modules/index/index', 'modules/category/category', 'modules/item/item',
|
||||
'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',
|
||||
'model/note/noteCollection', 'model/category/categoryCollection', 'model/categoryItem/categoryItemCollection',
|
||||
'model/item/itemCollection', 'model/item/ingredientiCollection', 'model/categoryItem/foundItemCollection',
|
||||
'libs/fastclick', 'jqm', 'jQueryPlugins'],
|
||||
function ($, _, Backbone,
|
||||
HomeView, FaqView, IndexView, CategoryView, ItemView,
|
||||
AboutView, SearchView, FoundView, MoreView, NoteView,
|
||||
SyncView, ConverterView, DonationView, SettingsView,
|
||||
NoteCollection, CategoryCollection, CategoryItemCollection,
|
||||
ItemCollection, IngredientiCollection, FoundItemCollection,
|
||||
FastClick) {
|
||||
'modules/sync/sync', 'modules/donation/donation','modules/settings/settings',
|
||||
'model/note/noteCollection', 'model/category/categoryCollection','model/categoryItem/categoryItemCollection',
|
||||
'model/item/itemCollection','model/item/ingredientiCollection','model/categoryItem/foundItemCollection',
|
||||
'classes/utility', 'jqm', 'jQueryPlugins'],
|
||||
function($, _, Backbone,
|
||||
HomeView, FaqView, IndexView, CategoryView, ItemView,
|
||||
AboutView, SearchView, FoundView, MoreView, NoteView,
|
||||
SyncView, DonationView, SettingsView,
|
||||
NoteCollection, CategoryCollection, CategoryItemCollection,
|
||||
ItemCollection, IngredientiCollection, FoundItemCollection,
|
||||
Utility) {
|
||||
|
||||
'use strict';
|
||||
var Router = Backbone.Router.extend({
|
||||
//define routes and mapping route to the function
|
||||
routes: {
|
||||
'': 'showHome', //home view
|
||||
'homeView': 'showHome', //home view as well
|
||||
'faqView': 'showFaq', //home view as well
|
||||
'indexView': 'showIndex', //home view as well
|
||||
'category/:categoryName/:categoryId' : 'showCategory',
|
||||
'ricetta/:itemId' : 'showItem',
|
||||
'aboutView' : 'showAbout',
|
||||
'syncView(/)*founded' : 'showSync',
|
||||
'noteView': 'showNote',
|
||||
'searchView': 'showSearch',
|
||||
'settingsView': 'showSettings',
|
||||
'donationView': 'showDonation',
|
||||
'search/:nresult/:categoria/:difficolta/*titolo': 'searchFn',
|
||||
'converterView': 'showConverter',
|
||||
'moreView': 'showMore',
|
||||
'*actions': 'defaultAction' //default action
|
||||
},
|
||||
|
||||
defaultAction: function(actions){
|
||||
this.showHome(actions);
|
||||
},
|
||||
|
||||
'use strict';
|
||||
var Router = Backbone.Router.extend({
|
||||
//define routes and mapping route to the function
|
||||
routes: {
|
||||
'': 'showHome', //home view
|
||||
'homeView': 'showHome', //home view as well
|
||||
'faqView': 'showFaq', //home view as well
|
||||
'indexView': 'showIndex', //home view as well
|
||||
'category/:categoryName/:categoryId': 'showCategory',
|
||||
'ricetta/:itemId': 'showItem',
|
||||
'aboutView': 'showAbout',
|
||||
'syncView(/)*founded': 'showSync',
|
||||
'noteView': 'showNote',
|
||||
'searchView': 'showSearch',
|
||||
'settingsView': 'showSettings',
|
||||
'donationView': 'showDonation',
|
||||
'search/:nresult/:categoria/:difficolta/*titolo': 'searchFn',
|
||||
'converterView': 'showConverter',
|
||||
'moreView': 'showMore',
|
||||
'*actions': 'defaultAction' //default action
|
||||
},
|
||||
defaultAction: function (actions) {
|
||||
this.showHome(actions);
|
||||
},
|
||||
showHome: function (actions) {
|
||||
// will render home view and navigate to homeView
|
||||
var homeView = new HomeView();
|
||||
homeView.render();
|
||||
this.changePage(homeView);
|
||||
},
|
||||
showSettings: function (actions) {
|
||||
var settingsView = new SettingsView();
|
||||
settingsView.render();
|
||||
this.changePage(settingsView);
|
||||
},
|
||||
showDonation: function (actions) {
|
||||
var donationView = new DonationView();
|
||||
donationView.render();
|
||||
this.changePage(donationView);
|
||||
},
|
||||
showAbout: function (actions) {
|
||||
// will render home view and navigate to homeView
|
||||
var aboutView = new AboutView();
|
||||
aboutView.render();
|
||||
this.changePage(aboutView);
|
||||
},
|
||||
showSync: function (actions) {
|
||||
var option = {};
|
||||
if (actions)
|
||||
{
|
||||
option = {tokenFound: 1};
|
||||
}
|
||||
// will render home view and navigate to homeView
|
||||
var syncView = new SyncView(option);
|
||||
syncView.render();
|
||||
this.changePage(syncView);
|
||||
},
|
||||
showNote: function (actions) {
|
||||
var notes = new NoteCollection();
|
||||
// will render home view and navigate to homeView
|
||||
var noteView = new NoteView({collection: notes});
|
||||
noteView.render();
|
||||
this.changePage(noteView);
|
||||
},
|
||||
showFaq: function (actions) {
|
||||
// will render home view and navigate to homeView
|
||||
var faqView = new FaqView();
|
||||
faqView.render();
|
||||
this.changePage(faqView);
|
||||
},
|
||||
showIndex: function (actions) {
|
||||
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);
|
||||
},
|
||||
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});
|
||||
showHome:function(actions){
|
||||
// will render home view and navigate to homeView
|
||||
var homeView=new HomeView();
|
||||
homeView.render();
|
||||
this.changePage(homeView);
|
||||
},
|
||||
|
||||
categoryView.render();
|
||||
this.changePage(categoryView);
|
||||
showSettings:function(actions){
|
||||
var settingsView=new SettingsView();
|
||||
settingsView.render();
|
||||
this.changePage(settingsView);
|
||||
},
|
||||
|
||||
$.mobile.loading('show', {
|
||||
text: 'Caricamento categoria ' + categoryName + '...',
|
||||
textVisible: true,
|
||||
//theme: 'z',
|
||||
html: ""
|
||||
});
|
||||
//categoryView.bind('renderCompleted:Category',this.changePage,this);
|
||||
},
|
||||
showItem: function (itemId) {
|
||||
var item = new ItemCollection({ricettaId: itemId});
|
||||
var ingr = new IngredientiCollection({ricettaId: itemId});
|
||||
// will render home view and navigate to homeView
|
||||
var itemView = new ItemView({
|
||||
collRicetta: item,
|
||||
collIngredienti: ingr
|
||||
});
|
||||
//indexView.render();
|
||||
itemView.bind('renderCompleted:Item', this.changePage, this);
|
||||
},
|
||||
showConverter: function () {
|
||||
var converterView = new ConverterView();
|
||||
converterView.render();
|
||||
this.changePage(converterView);
|
||||
},
|
||||
showMore: function () {
|
||||
var moreView = new MoreView();
|
||||
moreView.render();
|
||||
this.changePage(moreView);
|
||||
},
|
||||
showSearch: function () {
|
||||
var categories = new CategoryCollection();
|
||||
// will render home view and navigate to homeView
|
||||
var searchView = new SearchView({collection: categories});
|
||||
//indexView.render();
|
||||
searchView.bind('renderCompleted:Search', this.changePage, this);
|
||||
},
|
||||
searchFn: function (nresult, categoria, difficolta, titolo) {
|
||||
showDonation:function(actions){
|
||||
var donationView=new DonationView();
|
||||
donationView.render();
|
||||
this.changePage(donationView);
|
||||
},
|
||||
|
||||
showAbout:function(actions){
|
||||
// will render home view and navigate to homeView
|
||||
var aboutView=new AboutView();
|
||||
aboutView.render();
|
||||
this.changePage(aboutView);
|
||||
},
|
||||
|
||||
//console.log("Search by Titolo: " + titolo + ", Categoria: " + categoria + ", Difficoltà: " + difficolta);
|
||||
var foundedItems = new FoundItemCollection({categoryId: categoria, difficolta: difficolta, titolo: titolo, nResult: nresult});
|
||||
var foundView = new FoundView({collection: foundedItems});
|
||||
showSync:function(actions){
|
||||
var option = {};
|
||||
if(actions)
|
||||
{
|
||||
option = { tokenFound: 1 };
|
||||
}
|
||||
// will render home view and navigate to homeView
|
||||
var syncView=new SyncView(option);
|
||||
syncView.render();
|
||||
this.changePage(syncView);
|
||||
},
|
||||
|
||||
foundView.render();
|
||||
this.changePage(foundView);
|
||||
|
||||
$.mobile.loading('show', {
|
||||
text: 'Caricamento ricerca ricette...',
|
||||
textVisible: true,
|
||||
//theme: 'z',
|
||||
html: ""
|
||||
});
|
||||
},
|
||||
init: true,
|
||||
//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) {
|
||||
|
||||
//append to dom
|
||||
$('body').append(view.$el);
|
||||
|
||||
$.mobile.pageContainer.pagecontainer("change", $(view.el), {changeHash: false});
|
||||
|
||||
FastClick.attach(document.body);
|
||||
|
||||
$(":jqmData(role='page'):last").on("pageshow", function (event) {
|
||||
if (view.onShowed !== null)
|
||||
view.onShowed();
|
||||
});
|
||||
|
||||
$('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;
|
||||
}
|
||||
}
|
||||
showNote:function(actions){
|
||||
var notes = new NoteCollection();
|
||||
// will render home view and navigate to homeView
|
||||
var noteView=new NoteView({collection: notes});
|
||||
noteView.render();
|
||||
this.changePage(noteView);
|
||||
},
|
||||
|
||||
showFaq:function(actions){
|
||||
// will render home view and navigate to homeView
|
||||
var faqView=new FaqView();
|
||||
faqView.render();
|
||||
this.changePage(faqView);
|
||||
},
|
||||
|
||||
showIndex:function(actions){
|
||||
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);
|
||||
},
|
||||
|
||||
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});
|
||||
|
||||
categoryView.render();
|
||||
this.changePage(categoryView);
|
||||
|
||||
$.mobile.loading( 'show', {
|
||||
text: 'Caricamento categoria ' + categoryName + '...',
|
||||
textVisible: true,
|
||||
//theme: 'z',
|
||||
html: ""
|
||||
});
|
||||
//categoryView.bind('renderCompleted:Category',this.changePage,this);
|
||||
},
|
||||
|
||||
showItem: function(itemId){
|
||||
var item = new ItemCollection({ ricettaId: itemId });
|
||||
var ingr = new IngredientiCollection({ ricettaId: itemId });
|
||||
// will render home view and navigate to homeView
|
||||
var itemView=new ItemView({
|
||||
collRicetta: item,
|
||||
collIngredienti: ingr
|
||||
});
|
||||
//indexView.render();
|
||||
itemView.bind('renderCompleted:Item',this.changePage,this);
|
||||
},
|
||||
|
||||
return Router;
|
||||
});
|
||||
showMore: function(){
|
||||
var moreView = new MoreView();
|
||||
moreView.render();
|
||||
this.changePage(moreView);
|
||||
},
|
||||
|
||||
showSearch: function(){
|
||||
var categories = new CategoryCollection();
|
||||
// will render home view and navigate to homeView
|
||||
var searchView=new SearchView({ collection: categories});
|
||||
//indexView.render();
|
||||
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 foundView = new FoundView({ collection: foundedItems });
|
||||
|
||||
foundView.render();
|
||||
this.changePage(foundView);
|
||||
|
||||
$.mobile.loading( 'show', {
|
||||
text: 'Caricamento ricerca ricette...',
|
||||
textVisible: true,
|
||||
//theme: 'z',
|
||||
html: ""
|
||||
});
|
||||
},
|
||||
|
||||
init:true,
|
||||
|
||||
//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) {
|
||||
|
||||
Utility.changePage(view);
|
||||
|
||||
if(!this.init){
|
||||
|
||||
}else{
|
||||
this.init = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Router;
|
||||
});
|
||||
Reference in New Issue
Block a user