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

This commit is contained in:
2014-12-10 15:06:13 +00:00
parent 876ee18579
commit f57f55e2a9
58 changed files with 873 additions and 487 deletions
+48 -52
View File
@@ -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
View File
@@ -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;
+3 -3
View File
@@ -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
View File
@@ -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;
});
+14 -2
View File
@@ -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>
+49
View File
@@ -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>