git-svn-id: https://msi/svn/firstRepo/WebClient/branches/Manut_2.2.3@29 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -7,11 +7,13 @@ define(['jquery', 'underscore', 'backbone', 'router', 'classes/profile', 'classe
|
||||
Backbone.history.start();
|
||||
Backbone.emulateJSON = true;
|
||||
|
||||
|
||||
hello.init({
|
||||
facebook: '1466942266882168',
|
||||
google: '319140243944-qk0lfhgmi8shi4go97r83l69f1k0gdf4.apps.googleusercontent.com'
|
||||
}, {display: 'page', scope: 'email'});
|
||||
|
||||
|
||||
|
||||
//console.log("Backbone history start");
|
||||
// Trigger 'route' event on router instance.
|
||||
router.on('route', function (name, args) {
|
||||
|
||||
@@ -20,12 +20,15 @@ define(['jquery', 'underscore', 'backbone', 'classes/cache'],
|
||||
{
|
||||
window.setTimeout(function () {
|
||||
self[options.reset ? 'reset' : 'set'](false, options);
|
||||
deferred.resolve(cachedItem);
|
||||
self.push(cachedItem);
|
||||
//deferred.resolve(cachedItem);
|
||||
|
||||
self.trigger('sync', self, false, options);
|
||||
deferred.notify(self);
|
||||
self.push(cachedItem);
|
||||
if (_.isFunction(options.success)) {
|
||||
options.success(self, false, options);
|
||||
}
|
||||
}
|
||||
deferred.resolve(cachedItem);
|
||||
return deferred;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
+150
-163
@@ -2,165 +2,132 @@
|
||||
* Created by Denis on 19/06/2014.
|
||||
*/
|
||||
define(['jquery', 'backbone'],
|
||||
function($, Backbone){
|
||||
function ($, Backbone) {
|
||||
|
||||
var Profile = {
|
||||
|
||||
_loadme:function(){
|
||||
if(this.isConnected()) {
|
||||
if (this.data.type == null)
|
||||
this.loadProfile();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
dataloaded: false,
|
||||
|
||||
data: {
|
||||
"name": null,
|
||||
"email": null,
|
||||
"gender":null,
|
||||
"tema": 'b',
|
||||
"risRic": '10',
|
||||
"type": null
|
||||
},
|
||||
|
||||
isConnected: function(){
|
||||
return this.getKeySave() != "null" &&
|
||||
this.getKeySave() != null &&
|
||||
this.getKeySave() != "undefined" &&
|
||||
this.getKeySave() != undefined;
|
||||
},
|
||||
|
||||
loadProfile:function(successFn) {
|
||||
this.internalLoadProfile(this.getKeySave(), successFn);
|
||||
},
|
||||
|
||||
internalLoadProfile:function(keyStore, successFn){
|
||||
if(this.dataloaded)
|
||||
return;
|
||||
//var keyStore = this.getKeySave();
|
||||
var self = this;
|
||||
var retBool = false;
|
||||
var resp = $.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile/" + keyStore,
|
||||
//dataType: "json",
|
||||
async: false,
|
||||
type: 'GET'
|
||||
}).responseText;
|
||||
|
||||
var response = JSON.parse(resp);
|
||||
if(response.length > 0)
|
||||
{
|
||||
self.dataloaded = true;
|
||||
self.setKeySave(keyStore);
|
||||
self.data.name = response[0].Name;
|
||||
self.data.gender = response[0].Gender;
|
||||
self.data.tema = response[0].TemaUI;
|
||||
self.data.risRic = response[0].RisultatiRicerca;
|
||||
self.data.type = response[0].TipoAccesso;
|
||||
retBool = true;
|
||||
}
|
||||
if(successFn)
|
||||
successFn(retBool);
|
||||
},
|
||||
|
||||
getKeySave: function(){
|
||||
return window.localStorage.getItem("KeySave");
|
||||
},
|
||||
setKeySave: function(val){
|
||||
window.localStorage.setItem("KeySave", val);
|
||||
},
|
||||
|
||||
isGPlusConnected: function(){
|
||||
if(this.data.type === "google")
|
||||
return true;
|
||||
return false;
|
||||
},
|
||||
isFbConnected: function(){
|
||||
if(this.data.type === "facebook")
|
||||
return true;
|
||||
return false;
|
||||
},
|
||||
|
||||
addRicettaBloccoNote: function(ricetta_id, successFn) {
|
||||
var sendobj = {
|
||||
"ricetta_id": ricetta_id,
|
||||
"keyStore": this.getKeySave()
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile/ricetta",
|
||||
//dataType: "json",
|
||||
type: 'POST',
|
||||
data: { dataPair: JSON.stringify(sendobj) },
|
||||
success: function(msg){
|
||||
if(successFn)
|
||||
successFn(msg);
|
||||
var Profile = {
|
||||
_loadme: function () {
|
||||
if (this.isConnected()) {
|
||||
if (this.data.type == null)
|
||||
this.loadProfile();
|
||||
}
|
||||
});
|
||||
},
|
||||
return this;
|
||||
},
|
||||
dataloaded: false,
|
||||
data: {
|
||||
"name": null,
|
||||
"email": null,
|
||||
"gender": null,
|
||||
"tema": 'b',
|
||||
"risRic": '10',
|
||||
"type": null
|
||||
},
|
||||
isConnected: function () {
|
||||
return this.getKeySave() != "null" &&
|
||||
this.getKeySave() != null &&
|
||||
this.getKeySave() != "undefined" &&
|
||||
this.getKeySave() != undefined;
|
||||
},
|
||||
loadProfile: function (successFn) {
|
||||
this.internalLoadProfile(this.getKeySave(), successFn);
|
||||
},
|
||||
internalLoadProfile: function (keyStore, successFn) {
|
||||
if (this.dataloaded)
|
||||
return;
|
||||
//var keyStore = this.getKeySave();
|
||||
var self = this;
|
||||
var retBool = false;
|
||||
var resp = $.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile/" + keyStore,
|
||||
//dataType: "json",
|
||||
//async: false,
|
||||
type: 'GET',
|
||||
success: function (response) {
|
||||
if (response.length > 0)
|
||||
{
|
||||
self.dataloaded = true;
|
||||
self.setKeySave(keyStore);
|
||||
self.data.name = response[0].Name;
|
||||
self.data.gender = response[0].Gender;
|
||||
self.data.tema = response[0].TemaUI;
|
||||
self.data.risRic = response[0].RisultatiRicerca;
|
||||
self.data.type = response[0].TipoAccesso;
|
||||
retBool = true;
|
||||
}
|
||||
if (successFn)
|
||||
successFn(retBool);
|
||||
}
|
||||
});
|
||||
},
|
||||
getKeySave: function () {
|
||||
return window.localStorage.getItem("KeySave");
|
||||
},
|
||||
setKeySave: function (val) {
|
||||
window.localStorage.setItem("KeySave", val);
|
||||
},
|
||||
isGPlusConnected: function () {
|
||||
if (this.data.type === "google")
|
||||
return true;
|
||||
return false;
|
||||
},
|
||||
isFbConnected: function () {
|
||||
if (this.data.type === "facebook")
|
||||
return true;
|
||||
return false;
|
||||
},
|
||||
addRicettaBloccoNote: function (ricetta_id, successFn) {
|
||||
var sendobj = {
|
||||
"ricetta_id": ricetta_id,
|
||||
"keyStore": this.getKeySave()
|
||||
};
|
||||
|
||||
removeRicettaBloccoNote: function(ricetta_id, successFn) {
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile/" + this.getKeySave() + "/ricetta/" + ricetta_id,
|
||||
//dataType: "json",
|
||||
type: 'DELETE',
|
||||
success: function(msg){
|
||||
if(successFn)
|
||||
successFn(msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile/ricetta",
|
||||
//dataType: "json",
|
||||
type: 'POST',
|
||||
data: {dataPair: JSON.stringify(sendobj)},
|
||||
success: function (msg) {
|
||||
if (successFn)
|
||||
successFn(msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
removeRicettaBloccoNote: function (ricetta_id, successFn) {
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile/" + this.getKeySave() + "/ricetta/" + ricetta_id,
|
||||
//dataType: "json",
|
||||
type: 'DELETE',
|
||||
success: function (msg) {
|
||||
if (successFn)
|
||||
successFn(msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
existRicettaBloccoNote: function (ricettaID, successFn) {
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile/" + this.getKeySave() + "/ricetta/" + ricettaID,
|
||||
//dataType: "json",
|
||||
type: 'GET',
|
||||
success: function (msg) {
|
||||
if (successFn)
|
||||
successFn(msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
createProfile: function (keyStore, typeProfile, name, email, gender, successFn) {
|
||||
this.data.type = typeProfile;
|
||||
this.data.name = name;
|
||||
this.data.email = email;
|
||||
this.data.gender = gender;
|
||||
this.setKeySave(keyStore);
|
||||
|
||||
existRicettaBloccoNote: function(ricettaID, successFn){
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile/" + this.getKeySave() + "/ricetta/" + ricettaID,
|
||||
//dataType: "json",
|
||||
type: 'GET',
|
||||
success: function(msg){
|
||||
if(successFn)
|
||||
successFn(msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
window.localStorage.removeItem("risRic");
|
||||
window.localStorage.removeItem("tema");
|
||||
|
||||
createProfile: function(keyStore, typeProfile, name, email,gender, successFn) {
|
||||
this.data.type = typeProfile;
|
||||
this.data.name = name;
|
||||
this.data.email = email;
|
||||
this.data.gender = gender;
|
||||
this.setKeySave(keyStore);
|
||||
|
||||
window.localStorage.removeItem("risRic");
|
||||
window.localStorage.removeItem("tema");
|
||||
|
||||
var sendobj = {
|
||||
"keyStore": this.getKeySave(),
|
||||
"name": this.data.name,
|
||||
"email": this.data.email,
|
||||
"gender": this.data.gender,
|
||||
"tema": this.data.tema,
|
||||
"risRic": this.data.risRic,
|
||||
"type": this.data.type
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile",
|
||||
//dataType: "json",
|
||||
type: 'POST',
|
||||
data: { dataPair: JSON.stringify(sendobj) },
|
||||
success: function(msg){
|
||||
if(successFn)
|
||||
successFn(msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
updateProfile: function(successFn) {
|
||||
if(this.isConnected()) {
|
||||
var sendobj = {
|
||||
"keyStore": this.getKeySave(),
|
||||
"name": this.data.name,
|
||||
"email": this.data.email,
|
||||
"gender": this.data.gender,
|
||||
"tema": this.data.tema,
|
||||
"risRic": this.data.risRic,
|
||||
"type": this.data.type
|
||||
@@ -169,20 +136,40 @@ define(['jquery', 'backbone'],
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile",
|
||||
//dataType: "json",
|
||||
type: 'PUT',
|
||||
data: { dataPair: JSON.stringify(sendobj) },
|
||||
type: 'POST',
|
||||
data: {dataPair: JSON.stringify(sendobj)},
|
||||
success: function (msg) {
|
||||
if (successFn)
|
||||
successFn(msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
updateProfile: function (successFn) {
|
||||
if (this.isConnected()) {
|
||||
var sendobj = {
|
||||
"keyStore": this.getKeySave(),
|
||||
"tema": this.data.tema,
|
||||
"risRic": this.data.risRic,
|
||||
"type": this.data.type
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: myManifest.Settings.DefaultURL + "/api/profile",
|
||||
//dataType: "json",
|
||||
type: 'PUT',
|
||||
data: {dataPair: JSON.stringify(sendobj)},
|
||||
success: function (msg) {
|
||||
if (successFn)
|
||||
successFn(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
window.localStorage.setItem("risRic", this.data.risRic);
|
||||
window.localStorage.setItem("tema", this.data.tema);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
window.localStorage.setItem("risRic", this.data.risRic);
|
||||
window.localStorage.setItem("tema", this.data.tema);
|
||||
}
|
||||
}
|
||||
};
|
||||
return Profile._loadme();
|
||||
});
|
||||
};
|
||||
return Profile._loadme();
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
<div data-role="navbar" class="nav-glyphish-example">
|
||||
<ul>
|
||||
<li><a href="#noteView" id="noteBtn" data-icon="custom">Blocco note</a></li>
|
||||
<li><a href="#faqView" id="faqBtn" data-icon="custom">Lo sai che?</a></li>
|
||||
<li><a href="#faqView" id="faqBtn" data-icon="custom">Lo sai che?</a></li>
|
||||
<li><a href="#indexView" id="indexBtn" data-icon="custom">Indice</a></li>
|
||||
<li><a href="#searchView" id="searchBtn" data-icon="custom">Cerca</a></li>
|
||||
<li><a href="#moreView" id="moreBtn" data-icon="custom">Altro</a></li>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ define(['jquery'], function ($){
|
||||
$.mobile.pushStateEnabled = false;
|
||||
$.support.cors = true;
|
||||
$.mobile.allowCrossDomainPages = true;
|
||||
//$.mobile.defaultPageTransition = 'slidefade';
|
||||
$.mobile.defaultPageTransition = 'flip';
|
||||
// Remove page from DOM when it's being replaced
|
||||
$(document).on("pagecontainerhide", function (event, ui) {
|
||||
$("div[data-role='page']:not(.ui-page-active)").remove();
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
var myManifest = {
|
||||
Debug: false,
|
||||
Name: "Il Lievitario",
|
||||
Version: "2.5.7",
|
||||
Version: "2.6.0",
|
||||
Author: "Denis Ironi",
|
||||
Settings: {
|
||||
//DefaultURL: "http://localhost:8081/Service_Manut",
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
define(['app', 'jquery', 'underscore', 'backbone', 'model/categoryItem/categoryItemModel'],
|
||||
function (app, $, _, Backbone, Category){
|
||||
define(['app', 'jquery', 'underscore', 'backbone', 'model/categoryItem/searchItemModel'],
|
||||
function (app, $, _, Backbone, SearchItem){
|
||||
|
||||
var FoundItems=Backbone.Collection.extend({
|
||||
dataFilter: null,
|
||||
numItems: null,
|
||||
indexItems: null,
|
||||
totalRecords: 0,
|
||||
initialize: function (options) {
|
||||
this.dataFilter = {
|
||||
titolo: options.titolo,
|
||||
@@ -10,14 +13,24 @@ define(['app', 'jquery', 'underscore', 'backbone', 'model/categoryItem/categoryI
|
||||
categoryId: options.categoryId
|
||||
};
|
||||
this.numItems = options.nResult;
|
||||
this.indexItems = options.indexItems;
|
||||
},
|
||||
|
||||
parse: function(data){
|
||||
this.totalRecords = data["0"].TotalRecords;
|
||||
return data.records;
|
||||
},
|
||||
// Book is the model of the collection
|
||||
model:SearchItem,
|
||||
|
||||
getTotalRecords: function(){
|
||||
return this.totalRecords;
|
||||
},
|
||||
|
||||
|
||||
// Book is the model of the collection
|
||||
model:Category,
|
||||
|
||||
url: function() {
|
||||
var u = myManifest.Settings.DefaultURL + "/api/categoryitems/search/" + this.numItems +
|
||||
var u = myManifest.Settings.DefaultURL + "/api/categoryitems/search/" +
|
||||
this.numItems +
|
||||
"/" + this.indexItems +
|
||||
"/" + this.dataFilter.categoryId +
|
||||
"/" + this.dataFilter.difficolta;
|
||||
if(this.dataFilter.titolo !== null)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
define(['jquery', 'underscore', 'backbone'],
|
||||
function ($, _, Backbone){
|
||||
|
||||
var SearchItem = Backbone.Model.extend({
|
||||
//default attributes
|
||||
defaults: {
|
||||
ricetta_id: "",
|
||||
titolo: '',
|
||||
autore: '',
|
||||
valutazione: 0,
|
||||
difficolta: 0,
|
||||
categoria_name: 0
|
||||
}
|
||||
});
|
||||
|
||||
return SearchItem;
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/category/categoryViewT
|
||||
categoryName: null,
|
||||
//initialize template
|
||||
template: _.template(categoryViewTemplate),
|
||||
itemtemplate: _.template(categoryItemTemplate),
|
||||
itemtemplate: _.template(categoryItemTemplate, {variable: 'item'}),
|
||||
initialize: function (options) {
|
||||
var self = this;
|
||||
CategoryView.__super__.initialize.call(this);
|
||||
@@ -16,15 +16,18 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/category/categoryViewT
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
self.renderItem();
|
||||
}
|
||||
//success: function(){ self.renderItem(); }
|
||||
});
|
||||
},
|
||||
renderItem: function () {
|
||||
var $ul = $('#allRicette');
|
||||
var self = this;
|
||||
var html = "";
|
||||
_.each(this.collection.toJSON(), function(d) {
|
||||
html += self.itemtemplate(d);
|
||||
});
|
||||
//var items = this.itemtemplate({data: this.collection.toJSON()});
|
||||
|
||||
var items = this.itemtemplate({data: this.collection.toJSON()});
|
||||
|
||||
$ul.html(items);
|
||||
$ul.html(html);
|
||||
$ul.listview("refresh");
|
||||
$ul.trigger("updatelayout");
|
||||
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
<% 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>
|
||||
<br><div class='ricettaAutore'>Diff.: </div>
|
||||
<div id="valutazione" style="">
|
||||
<form id="difficoltaFrm" data-role="none">
|
||||
<input name="difficolta" <% if(item.difficolta==="1"){%>checked="checked"<%}%> type="radio" data-role="none" value="1" disabled="disabled" title="Molto Semplice" class="star"/>
|
||||
<input name="difficolta" <% if(item.difficolta==="2"){%>checked="checked"<%}%> type="radio" data-role="none" value="2" disabled="disabled" title="Semplice" class="star"/>
|
||||
<input name="difficolta" <% if(item.difficolta==="3"){%>checked="checked"<%}%> type="radio" data-role="none" value="3" disabled="disabled" title="Normale" class="star"/>
|
||||
<input name="difficolta" <% if(item.difficolta==="4"){%>checked="checked"<%}%> type="radio" data-role="none" value="4" disabled="disabled" title="Difficile" class="star"/>
|
||||
<input name="difficolta" <% if(item.difficolta==="5"){%>checked="checked"<%}%> type="radio" data-role="none" value="5" disabled="disabled" title="Molto Difficile" class="star"/>
|
||||
</form>
|
||||
</div>
|
||||
</a></li>
|
||||
<% }} %>
|
||||
<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>
|
||||
<br><div class='ricettaAutore'>Diff.: </div>
|
||||
<div id="valutazione" style="">
|
||||
<form id="difficoltaFrm" data-role="none">
|
||||
<input name="difficolta" <% if(item.difficolta==="1"){%>checked="checked"<%}%> type="radio" data-role="none" value="1" disabled="disabled" title="Molto Semplice" class="star"/>
|
||||
<input name="difficolta" <% if(item.difficolta==="2"){%>checked="checked"<%}%> type="radio" data-role="none" value="2" disabled="disabled" title="Semplice" class="star"/>
|
||||
<input name="difficolta" <% if(item.difficolta==="3"){%>checked="checked"<%}%> type="radio" data-role="none" value="3" disabled="disabled" title="Normale" class="star"/>
|
||||
<input name="difficolta" <% if(item.difficolta==="4"){%>checked="checked"<%}%> type="radio" data-role="none" value="4" disabled="disabled" title="Difficile" class="star"/>
|
||||
<input name="difficolta" <% if(item.difficolta==="5"){%>checked="checked"<%}%> type="radio" data-role="none" value="5" disabled="disabled" title="Molto Difficile" class="star"/>
|
||||
</form>
|
||||
</div>
|
||||
</a></li>
|
||||
@@ -1,21 +1,30 @@
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/index/indexViewTemplate.html', 'modules/base/baseView'],
|
||||
function($, _, Backbone, indexViewTemplate, BaseView){
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/index/indexViewTemplate.html','text!modules/index/indexItemViewTemplate.html', 'modules/base/baseView'],
|
||||
function($, _, Backbone, indexViewTemplate, indexItemViewTemplate, BaseView){
|
||||
|
||||
var IndexView = BaseView.extend({
|
||||
|
||||
collection: null,
|
||||
//initialize template
|
||||
template:_.template(indexViewTemplate),
|
||||
templateItem:_.template(indexItemViewTemplate, {variable: 'item'}),
|
||||
|
||||
initialize: function (options) {
|
||||
var self = this;
|
||||
IndexView.__super__.initialize.call(this);
|
||||
this.collection = options.collection;
|
||||
this.collection.fetch({
|
||||
success: function(data, textStatus, jqXHR){
|
||||
self.render();
|
||||
}
|
||||
});
|
||||
success: function(){
|
||||
var $ul = $('#categoryList');
|
||||
var html = "";
|
||||
_.each(self.collection.toJSON(), function(d) {
|
||||
html += self.templateItem(d);
|
||||
});
|
||||
$ul.html(html);
|
||||
//$ul.listview("refresh");
|
||||
//$ul.trigger("updatelayout");
|
||||
//self.trigger("renderCompleted:Categories",self);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//render the content into div of view
|
||||
@@ -26,9 +35,9 @@ define(['jquery', 'underscore', 'backbone','text!modules/index/indexViewTemplate
|
||||
//$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({data:this.collection.toJSON()}));
|
||||
this.$el.append(this.footer.$el);
|
||||
this.trigger("renderCompleted:Categories",this);
|
||||
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;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<li><a href="#category/<%=item.name%>/<%= item.category_id%>" class="ui-btn ui-btn-icon-right ui-icon-carat-r"><%= item.name %></a></li>
|
||||
@@ -1,9 +1,5 @@
|
||||
<div id="categoryListContent" data-role="content">
|
||||
<h1>Indice</h1>
|
||||
<h1>Indice</h1>
|
||||
<ul id="categoryList" data-role="listview" data-inset="true">
|
||||
<% for (var i = 0; i < data.length; i++) { %>
|
||||
<% var item = data[i]; %>
|
||||
<li><a href="#category/<%=item.name%>/<%= item.category_id%>" class="ui-btn ui-btn-icon-right ui-icon-carat-r"><%= item.name %></a></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -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="favoriteBtn" href="#" class="nav-glyphish-example ui-btn ui-icon-myHome ui-btn-icon-notext ui-btn-left" data-icon="custom"></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="nav-glyphish-example ui-btn ui-icon-myHome ui-btn-icon-notext ui-btn-right" data-icon="custom"></a>
|
||||
</div>
|
||||
<div id="contentIngredienti" data-role="content">
|
||||
<h1>Ingredienti</h1>
|
||||
|
||||
@@ -12,22 +12,62 @@ define(['jquery', 'underscore', 'backbone','text!modules/search/foundViewTemplat
|
||||
var self = this;
|
||||
FoundView.__super__.initialize.call(this);
|
||||
this.collection = options.collection;
|
||||
|
||||
this.collection.fetch({
|
||||
success: function(){ self.renderItem(); } });
|
||||
},
|
||||
|
||||
events: {
|
||||
"click #pagSucc": "nextPageSearch",
|
||||
"click #pagPrec": "prevPageSearch"
|
||||
},
|
||||
|
||||
goTop: function(element) {
|
||||
$('html, body').animate({
|
||||
scrollTop: '0px'
|
||||
}, 'fast');
|
||||
return element; // for chaining...
|
||||
},
|
||||
|
||||
renderItem: function(){
|
||||
var $ul = $('#foundRicette');
|
||||
|
||||
$ul.html('');
|
||||
var items = this.itemTemplate({data:this.collection.toJSON()});
|
||||
|
||||
$ul.html( items );
|
||||
$ul.listview( "refresh" );
|
||||
$ul.trigger( "updatelayout");
|
||||
|
||||
if(this.collection.indexItems === 0)
|
||||
$('#pagPrec').hide();
|
||||
else
|
||||
$('#pagPrec').show();
|
||||
|
||||
if(this.collection.getTotalRecords() < (this.collection.indexItems + 1) * this.collection.numItems)
|
||||
$('#pagSucc').hide();
|
||||
else
|
||||
$('#pagSucc').show();
|
||||
|
||||
$.mobile.loading( 'hide' );
|
||||
//$( '[data-alpha="true"]' ).alphascroll();
|
||||
},
|
||||
|
||||
nextPageSearch: function(e){
|
||||
e.preventDefault();
|
||||
var self=this;
|
||||
this.collection.indexItems++;
|
||||
this.collection.fetch({reset: true,
|
||||
success: function(){ self.renderItem(); } });
|
||||
this.goTop();
|
||||
},
|
||||
|
||||
prevPageSearch: function(e){
|
||||
e.preventDefault();
|
||||
var self=this;
|
||||
this.collection.indexItems--;
|
||||
this.collection.fetch({reset: true,
|
||||
success: function(){ self.renderItem(); } });
|
||||
},
|
||||
|
||||
//render the content into div of view
|
||||
render: function(){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<div id="categoryListContent" data-role="content">
|
||||
<h1>Ricerca Ricette...</h1>
|
||||
<ul id="foundRicette" data-role="listview" data-autodividers="true" data-inset="true">
|
||||
</ul>
|
||||
<h1>Ricerca Ricette...</h1>
|
||||
<center><a href="" id="pagPrec" button="true" class="ui-btn ui-corner-all">Pagina precedente</a></center>
|
||||
<ul id="foundRicette" data-role="listview" data-autodividers="true" data-inset="true"></ul>
|
||||
<center><a href="" id="pagSucc" button="true" class="ui-btn ui-corner-all">Pagina successiva</a></center>
|
||||
</div>
|
||||
+4
-5
@@ -89,8 +89,9 @@ define(['jquery', 'underscore', 'backbone',
|
||||
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);
|
||||
indexView.render();
|
||||
this.changePage(indexView);
|
||||
//indexView.bind('renderCompleted:Categories', this.changePage, this);
|
||||
},
|
||||
showCategory: function (categoryName, categoryId) {
|
||||
var categories = new CategoryItemCollection({categoryId: categoryId});
|
||||
@@ -137,9 +138,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();
|
||||
|
||||
Reference in New Issue
Block a user