git-svn-id: https://msi/svn/firstRepo/WebClient/branches/NewRelease@33 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
+84
-42
@@ -1,48 +1,90 @@
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/search/foundViewTemplate.html','text!modules/search/foundItemTemplate.html', 'modules/base/baseView'],
|
||||
function($, _, Backbone, foundViewTemplate, foundItemTemplate, BaseView){
|
||||
define(['jquery', 'underscore', 'backbone', 'text!modules/search/foundViewTemplate.html', 'text!modules/search/foundItemTemplate.html', 'modules/base/baseView'],
|
||||
function ($, _, Backbone, foundViewTemplate, foundItemTemplate, BaseView) {
|
||||
|
||||
var FoundView = BaseView.extend({
|
||||
var FoundView = BaseView.extend({
|
||||
collection: null,
|
||||
//initialize template
|
||||
template: _.template(foundViewTemplate),
|
||||
itemTemplate: _.template(foundItemTemplate),
|
||||
initialize: function (options) {
|
||||
this.id = "FoundView";
|
||||
var self = this;
|
||||
FoundView.__super__.initialize.call(this);
|
||||
this.collection = options.collection;
|
||||
|
||||
collection: null,
|
||||
//initialize template
|
||||
template:_.template(foundViewTemplate),
|
||||
itemTemplate:_.template(foundItemTemplate),
|
||||
this.collection.fetch({
|
||||
success: function () {
|
||||
self.renderItem();
|
||||
}});
|
||||
},
|
||||
isStayInPage: function () {
|
||||
return false;
|
||||
},
|
||||
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()});
|
||||
|
||||
initialize: function (options) {
|
||||
var self = this;
|
||||
FoundView.__super__.initialize.call(this);
|
||||
this.collection = options.collection;
|
||||
this.collection.fetch({
|
||||
success: function(){ self.renderItem(); } });
|
||||
},
|
||||
$ul.html(items);
|
||||
$ul.listview("refresh");
|
||||
$ul.trigger("updatelayout");
|
||||
|
||||
renderItem: function(){
|
||||
var $ul = $('#foundRicette');
|
||||
if (this.collection.indexItems === 0)
|
||||
$('#pagPrec').hide();
|
||||
else
|
||||
$('#pagPrec').show();
|
||||
|
||||
var items = this.itemTemplate({data:this.collection.toJSON()});
|
||||
if (this.collection.getTotalRecords() < (this.collection.indexItems + 1) * this.collection.numItems)
|
||||
$('#pagSucc').hide();
|
||||
else
|
||||
$('#pagSucc').show();
|
||||
|
||||
$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";
|
||||
FoundView.__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("#searchBtn").addClass("ui-btn-active");
|
||||
return this;
|
||||
}
|
||||
});
|
||||
return FoundView;
|
||||
});
|
||||
$.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 () {
|
||||
//this.header.title = "pippo";
|
||||
FoundView.__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("#searchBtn").addClass("ui-btn-active");
|
||||
return this;
|
||||
}
|
||||
});
|
||||
return FoundView;
|
||||
});
|
||||
@@ -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>
|
||||
@@ -6,6 +6,7 @@ define(['jquery', 'underscore', 'backbone','text!modules/search/searchViewTempla
|
||||
template:_.template(searchViewTemplate),
|
||||
|
||||
initialize: function (options) {
|
||||
this.id = "SearchView";
|
||||
var self = this;
|
||||
SearchView.__super__.initialize.call(this);
|
||||
this.collection = options.collection;
|
||||
@@ -29,17 +30,40 @@ define(['jquery', 'underscore', 'backbone','text!modules/search/searchViewTempla
|
||||
}
|
||||
Backbone.history.navigate('search/' + nResult + "/"+ categoria + "/" + diffi + "/" + titolo, { trigger: true });
|
||||
},
|
||||
|
||||
onShowed: function(){
|
||||
var stars = $('input[type=radio].star');
|
||||
if (stars.length > 0)
|
||||
{
|
||||
stars.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);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
//render the content into div of view
|
||||
render: function () {
|
||||
//this.header.title = "pippo";
|
||||
if (this.created === true)
|
||||
{
|
||||
SearchView.__super__.render.call(this);
|
||||
this.$el.append(this.header.$el);
|
||||
this.$el.append(this.template({data:this.collection.toJSON()}));
|
||||
this.$el.append(this.footer.$el);
|
||||
|
||||
this.$el.find('#nResult').val(Profile.data.risRic);
|
||||
this.trigger("renderCompleted:Search", this);
|
||||
|
||||
}
|
||||
this.$el.find('#nResult').val(Profile.data.risRic);
|
||||
this.trigger("renderCompleted:Search", this);
|
||||
this.$el.find("#searchBtn").addClass("ui-btn-active");
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user