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
+82
View File
@@ -0,0 +1,82 @@
define(['jquery', 'underscore', 'backbone','text!modules/note/noteViewTemplate.html', 'text!modules/note/noteItemTemplate.html', 'modules/base/baseView', 'classes/profile'],
function($, _, Backbone, noteViewTemplate, noteItemTemplate, BaseView, Profile){
var NoteView = BaseView.extend({
collection: null,
//initialize template
template:_.template(noteViewTemplate),
itemtemplate:_.template(noteItemTemplate),
current_ricetta_id: null,
initialize: function (options) {
var self = this;
NoteView.__super__.initialize.call(this);
this.collection = options.collection;
this.collection.fetch({ success: function(){ self.renderItem(); } });
},
events: {
"click #deleteItem": "deleteItemClick",
"popupafterclose #popupMenu": "popupMenuPopupafterclose"
},
updateList: function(){
var $ul = this.$el.find('#allNote');
var items = this.itemtemplate({data:this.collection.toJSON()});
$ul.html( items );
$ul.listview( "refresh" );
$ul.trigger( "updatelayout");
},
renderItem: function(){
this.updateList();
$.mobile.loading( 'hide' );
var self = this;
this.$el.find('.optionLink').on("click", function(e){
e.preventDefault();
self.current_ricetta_id = $(e.target.parentElement).find('#itemID').text();
self.$el.find('#popupMenu').popup("open");
});
},
deleteItemClick: function(e){
e.preventDefault();
var self = this;
Profile.removeRicettaBloccoNote(this.current_ricetta_id, function(msg) {
var item = self.collection.get(self.current_ricetta_id);
self.$el.find('#popupMenu').popup("close");
self.collection.remove(item);
self.updateList();
});
},
popupMenuPopupafterclose: function( event, ui ) {
this.current_ricetta_id = null;
},
//render the content into div of view
render: function(){
//this.header.title = "pippo";
NoteView.__super__.render.call(this);
var self = 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("#noteBtn").addClass("ui-btn-active");
return this;
}
});
return NoteView;
});
+13
View File
@@ -0,0 +1,13 @@
<% 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%>">
<div id="itemID" style="display: none;"><%= item.ricetta_id%></div>
<div class='ricettaTitolo'><%= unescape(item.titolo) %></div>
<div class='ricettaAutore'><%= unescape(item.autore) %></div>
</a>
<a href="" class="optionLink" data-rel="popup" data-position-to="window" data-transition="pop">Opzioni</a>
</li>
<% }} %>
+11
View File
@@ -0,0 +1,11 @@
<div id="noteListContent" data-role="content">
<h1>Blocco note</h1>
<ul id="allNote" data-role="listview" data-inset="true" data-split-icon="gear">
</ul>
<div data-role="popup" id="popupMenu" data-theme="b">
<ul data-role="listview" data-inset="true" style="min-width:210px;">
<li data-role="list-divider">Scegliere l'azione</li>
<li><a href="" id="deleteItem">Elimina dal Blocco</a></li>
</ul>
</div>
</div>