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

This commit is contained in:
2014-12-10 14:58:10 +00:00
parent 90e0252f4b
commit 876ee18579
238 changed files with 35068 additions and 0 deletions
+129
View File
@@ -0,0 +1,129 @@
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;
this.collRicetta.fetch({success: function() {
self.fetchedRicetta = true;
self.render();
}});
this.collIngredienti.fetch({success: function() {
self.fetchedIngredienti = true;
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);
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.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
//return to enable chained calls
return this;
}
},
goToContent:function(newIndex)
{
if(this.$arrayContent.length > newIndex && newIndex >= 0)
{
this.indexContent = newIndex;
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;
});
+62
View File
@@ -0,0 +1,62 @@
<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>
<h3 id='titoloRicetta'><%= unescape(ricetta.titolo)%></h3>
<a id="backBtn" href="" data-role="button" class="ui-btn-right" data-icon="custom">Indietro</a>
</div>
<div id="contentIngredienti" data-role="content">
<h1>Ingredienti</h1>
<center><p id='ingredienti'>
<% _.each(ingredienti, function(ingrediente) {
var liStyle = "";
var qty = ": " + ingrediente.quantita;
var nome_ingr = ingrediente.nome_ingrediente;
if(ingrediente.id_tipo_ingredienti == 22)
{
liStyle="list-style-type: none;";
qty = "";
nome_ingr = "";
} %> <li style="<%= liStyle %>"><b><%= nome_ingr %></b><%= qty %> <%= ingrediente.unita %> <%= ingrediente.note %></li><br> <% }); %>
</p></center>
</div>
<div id="contentProcedimento" data-role="content" style="display: none;">
<h1>Procedimento</h1>
<p id='procedimento'><%= ricetta.procedimento%></p>
</div>
<!--<div id="contentFoto" data-role="content" data-theme="d" style="display: none;" data-iscroll>
<h1>Foto</h1>
<ul id="Gallery" class="gallery">
</ul>
</div>
<div id="contentVideo" data-role="content" data-theme="d" style="display: none;" data-iscroll>
<h1>Video</h1>
<p id='video'></p>
</div>-->
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar">
<ul>
<li><a href="" class="ui-btn-active ui-state-persist">Ingredienti</a></li>
<li><a href="">Procedimento</a></li>
<!--<li><a href="">Foto</a></li>
<li><a href="">Video</a></li>-->
</ul>
</div><!-- /navbar -->
<% if(ricetta.autore.length > 0){ %>
<h1 id="autore" style="padding: 0px;">Autore: <%= unescape(ricetta.autore)%></h1>
<% }if(ricetta.link_fonte.length > 0){ %>
<h1 id="linkFonte" style="padding: 0px;"><a target="_blank" href="<%= ricetta.link_fonte%>">Link Fonte</a></h1>
<% }%>
</div>
<div data-role="popup" id="popupDialog">
<div data-role="header">
<h1>Informazione</h1>
</div>
<div role="main" class="ui-content">
<p style="text-align: center;font-style: italic;">IMPORTANTE<br><br>
Questa funzionalità è disponibile solo se si è abilitata la Sincronizzazione tramite Facebook o Google.
</p>
<p style="text-align: center;">
<a id="syncBtn" href="#syncView" class="ui-btn ui-corner-all ui-btn-inline ui-shadow ui-icon-custom ui-btn-icon-left">Sincronizza</a>
<a href="" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-icon-check" data-rel="back">Cancel</a>
</p>
</div>
</div>