73 lines
2.7 KiB
JavaScript
73 lines
2.7 KiB
JavaScript
define(['jquery', 'underscore', 'backbone','text!modules/search/searchViewTemplate.html', 'modules/base/baseView', 'classes/profile', 'jQueryPlugins'],
|
|
function($, _, Backbone, searchViewTemplate, BaseView, Profile) {
|
|
var SearchView = BaseView.extend({
|
|
collection: null,
|
|
//initialize template
|
|
template:_.template(searchViewTemplate),
|
|
|
|
initialize: function (options) {
|
|
this.id = "SearchView";
|
|
var self = this;
|
|
SearchView.__super__.initialize.call(this);
|
|
},
|
|
|
|
events: {
|
|
"click [button='true']": "performSearch"
|
|
},
|
|
|
|
performSearch: function (e) {
|
|
e.preventDefault();
|
|
var titolo = $('#titolo').val();
|
|
var autore = $('#autore').val();
|
|
var categoria = $('#categoria').val();
|
|
var nResult = $('#nResult').val();
|
|
var diffi = $('#difficoltaFrm').serialize();
|
|
diffi = diffi.replace("difficolta=", "");
|
|
if (diffi === "") {
|
|
diffi = "0";
|
|
}
|
|
if (autore === "" || autore == undefined) {
|
|
autore = "_";
|
|
}
|
|
Backbone.history.navigate('search/' + nResult + "/"+ categoria + "/" + diffi + "/" + autore + "/"+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 () {
|
|
if (this.created === true)
|
|
{
|
|
SearchView.__super__.render.call(this);
|
|
this.$el.append(this.header.$el);
|
|
this.$el.append(this.template());
|
|
this.$el.append(this.footer.$el);
|
|
}
|
|
this.$el.find('#nResult').val(Profile.data.risRic);
|
|
this.trigger("renderCompleted:Search", this);
|
|
this.$el.find("#searchBtn").addClass("ui-btn-active");
|
|
return this;
|
|
}
|
|
});
|
|
return SearchView;
|
|
}); |