git-svn-id: https://msi/svn/firstRepo/WebClient/branches/Manut_2.2.3@25 0f545695-f87b-41b6-9a03-7f16563b5454

This commit is contained in:
2015-01-25 13:57:37 +00:00
parent 1b92a374cc
commit d0d55ee8e5
19 changed files with 517 additions and 292 deletions
+59 -63
View File
@@ -1,66 +1,62 @@
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");
$ul.find('input[type=radio].star').rating({
callback: function (value, link) {
var tip = $('#hover-test');
if (value === undefined)
{
$('#hover-test').html("Nessuna" || 'value: ');
var items = this.itemtemplate({data: this.collection.toJSON()});
$ul.html(items);
$ul.listview("refresh");
$ul.trigger("updatelayout");
$ul.find('input[type=radio].star').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);
}
});
$.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;
}
else
$('#hover-test').html(link.title || 'value: ' + value);
}
});
$.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;
});
});
return CategoryView;
});
+129 -158
View File
@@ -1,164 +1,135 @@
define(['jquery', 'underscore', 'backbone','text!modules/sync/syncViewTemplate.html', 'modules/base/baseView', 'classes/profile'],
function($, _, Backbone, syncViewTemplate, BaseView, Profile){
define(['jquery', 'underscore', 'backbone', 'text!modules/sync/syncViewTemplate.html', 'modules/base/baseView', 'classes/profile'],
function ($, _, Backbone, syncViewTemplate, BaseView, Profile) {
var SyncView = BaseView.extend({
//initialize template
template:_.template(syncViewTemplate),
initialize: function (options) {
SyncView.__super__.initialize.call(this);
if(options &&
options.tokenFound == 1)
{
if(window.localStorage.getItem("tryLogin")=="fb")
var SyncView = BaseView.extend({
//initialize template
template: _.template(syncViewTemplate),
initialize: function (options) {
SyncView.__super__.initialize.call(this);
if (options &&
options.tokenFound == 1)
{
this.fbAfterLogin();
this.updateLoginBtn();
}
else if(window.localStorage.getItem("tryLogin")=="gplus")
{
this.gPlusAfterLogin();
}
}
window.localStorage.setItem("tryLogin", null);
},
window.localStorage.setItem("tryLogin", null);
},
events: {
"click #backBtn": "backBtn",
"click #fblogin": "fbLogin",
"click #gpluslogin": "gplusLogin",
"click #resetBtn": "resetBtn"
},
resetBtn: function (e) {
e.preventDefault();
Profile.setKeySave(null);
window.localStorage.setItem("hello", null);
Backbone.history.loadUrl();
},
backBtn: function (e) {
e.preventDefault();
window.history.back();
},
fbLogin: function (e) {
var self = this;
e.preventDefault();
events: {
"click #backBtn": "backBtn",
"click #fblogin": "fbLogin",
"click #gpluslogin": "gplusLogin",
"click #resetBtn": "resetBtn"
},
resetBtn:function(e){
e.preventDefault();
Profile.setKeySave(null);
Backbone.history.loadUrl();
},
backBtn:function(e){
e.preventDefault();
window.history.back();
},
fbLogin: function(e){
var self = this;
e.preventDefault();
if(!Profile.isConnected()) {
window.localStorage.setItem("tryLogin", "fb");
openFB.login('email');
}
else if(Profile.isConnected() && Profile.isFbConnected())
openFB.revokePermissions(function(){
Profile.setKeySave(null);
self.updateLoginBtn();
});
},
fbAfterLogin: function()
{
var self = this;
openFB.api({
path: '/me',
success: function (data) {
Profile.internalLoadProfile(data.id, function(retVal){
if(retVal == false)
Profile.createProfile(
data.id,
"fb",
data.name,
data.email,
data.gender,
function(){
//Backbone.history.loadUrl();
});
self.updateLoginBtn();
});
}});
},
gplusLogin: function(e){
var self = this;
e.preventDefault();
if(!Profile.isConnected()) {
window.localStorage.setItem("tryLogin", "gplus");
openGPlus.login('email');
}
else if(Profile.isConnected() && Profile.isGPlusConnected())
openGPlus.revokePermissions(function(){
Profile.setKeySave(null);
self.updateLoginBtn();
});
},
gPlusAfterLogin: function()
{
var self = this;
openGPlus.api({
path: 'people/me',
success: function (data) {
Profile.internalLoadProfile(data.id, function(retVal){
if(retVal == false)
Profile.createProfile(
data.id,
"gplus",
data.displayName,
data.emails[0].value,
data.gender,
function(){
//Backbone.history.loadUrl();
}
);
self.updateLoginBtn();
});
}});
},
updateLoginBtn: function()
{
if(Profile.isConnected()) {
if (Profile.isFbConnected()) {
this.$el.find("#fblogin").show();
this.$el.find("#gpluslogin").hide();
this.$el.find("#fblogin").removeClass("loginfb");
this.$el.find("#fblogin").addClass("logoutfb");
}
if (Profile.isGPlusConnected()) {
this.$el.find("#gpluslogin").show();
this.$el.find("#fblogin").hide();
this.$el.find("#gpluslogin").removeClass("logingplus");
this.$el.find("#gpluslogin").addClass("logoutgplus");
}
}
else
hello('facebook').login();
},
fbAfterLogin: function ()
{
this.$el.find("#fblogin").removeClass("logoutfb");
this.$el.find("#fblogin").addClass("loginfb");
this.$el.find("#gpluslogin").removeClass("logoutgplus");
this.$el.find("#gpluslogin").addClass("logingplus");
/*
var self = this;
openFB.api({
path: '/me',
success: function (data) {
Profile.internalLoadProfile(data.id, function(retVal){
if(retVal == false)
Profile.createProfile(
data.id,
"fb",
data.name,
data.email,
data.gender,
function(){
//Backbone.history.loadUrl();
});
self.updateLoginBtn();
});
}});
*/
},
gplusLogin: function (e) {
var self = this;
e.preventDefault();
hello('google').login();
},
gPlusAfterLogin: function ()
{
/*
var self = this;
openGPlus.api({
path: 'people/me',
success: function (data) {
Profile.internalLoadProfile(data.id, function(retVal){
if(retVal == false)
Profile.createProfile(
data.id,
"gplus",
data.displayName,
data.emails[0].value,
data.gender,
function(){
//Backbone.history.loadUrl();
}
);
self.updateLoginBtn();
});
}});
*/
},
updateLoginBtn: function ()
{
if (Profile.isConnected()) {
if (Profile.isFbConnected()) {
this.$el.find("#fblogin").show();
this.$el.find("#gpluslogin").hide();
this.$el.find("#fblogin").removeClass("loginfb");
this.$el.find("#fblogin").addClass("logoutfb");
}
if (Profile.isGPlusConnected()) {
this.$el.find("#gpluslogin").show();
this.$el.find("#fblogin").hide();
this.$el.find("#gpluslogin").removeClass("logingplus");
this.$el.find("#gpluslogin").addClass("logoutgplus");
}
}
else
{
this.$el.find("#fblogin").removeClass("logoutfb");
this.$el.find("#fblogin").addClass("loginfb");
this.$el.find("#gpluslogin").removeClass("logoutgplus");
this.$el.find("#gpluslogin").addClass("logingplus");
}
},
//render the content into div of view
render: function () {
var self = this;
//this.header.title = "pippo";
SyncView.__super__.render.call(this);
this.header.$el.append("<a id=\"backBtn\" href=\"\" data-role=\"button\" class=\"ui-btn-right\" data-icon=\"custom\">Indietro</a>");
this.$el.append(this.header.$el);
this.$el.append(this.template({app: myManifest}));
this.$el.append(this.footer.$el);
this.$el.find("#moreBtn").addClass("ui-btn-active");
this.updateLoginBtn();
return this;
}
},
//render the content into div of view
render: function(){
var self = this;
//this.header.title = "pippo";
SyncView.__super__.render.call(this);
this.header.$el.append("<a id=\"backBtn\" href=\"\" data-role=\"button\" class=\"ui-btn-right\" data-icon=\"custom\">Indietro</a>");
this.$el.append(this.header.$el);
this.$el.append(this.template( { app: myManifest }));
this.$el.append(this.footer.$el);
this.$el.find("#moreBtn").addClass("ui-btn-active");
this.updateLoginBtn();
return this;
}
});
return SyncView;
});
});
return SyncView;
});