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

This commit is contained in:
2016-01-10 22:18:54 +00:00
parent 66318c9124
commit d6e19b50d8
7 changed files with 295 additions and 29 deletions
+84 -4
View File
@@ -7,21 +7,93 @@ define(['jquery', 'underscore', 'backbone','text!modules/settings/settingsViewTe
template:_.template(settingsViewTemplate),
initialize: function () {
var self = this;
this.id = "SettingsView";
SettingsView.__super__.initialize.call(this);
},
events: {
"click #saveBtn": "saveBtn"
"click #saveBtn": "saveBtn",
"change #spacc-PMChk": "spaccPMClick"
},
saveBtn:function(e){
e.preventDefault();
Profile.data.risRic = this.$el.find('#nResult').val();
Profile.data.tema = this.$el.find('#theme').val();
Profile.updateProfile(function(){
Backbone.history.loadUrl();
});
if($('#mapSpacc').is(':visible'))
{
Profile.data.isSpacc = this.$el.find('#spacc-PMChk').prop('checked')?"1":"0";
Profile.data.email = this.$el.find('#email').val();
Profile.data.dataSpacc.provincia = this.$el.find('#prov').val();
Profile.data.dataSpacc.comune = this.$el.find('#comune').val();
Profile.data.dataSpacc.cap = this.$el.find('#CAP').val();
Profile.data.dataSpacc.tipopm = this.$el.find('#tPM').val();
Profile.data.dataSpacc.privacy = this.$el.find('#privacyChk').prop('checked')?"1":"0";
$.ajax({
url: "http://maps.google.com/maps/api/geocode/json?address=" +
Profile.data.dataSpacc.comune + "+" +
Profile.data.dataSpacc.comune + "+" +
Profile.data.dataSpacc.provincia + "+italia&sensor=false",
                Type: "GET"
            }).then(function ( response ) {
});
}
else
{
Profile.updateProfile(function(){
Backbone.history.loadUrl();
});
}
},
onShowed: function(){
var self = this;
if(Profile.data.isSpacc==="0"){
this.$el.find('#mapSpacc > :not(.ui-checkbox:has(#spacc-PMChk))').hide();
}
else
this.$el.find('#mapSpacc > :not(.ui-checkbox:has(#spacc-PMChk))').show();
$( "#autocomplete_comune" ).on( "filterablebeforefilter", function ( e, data ) {
        var $ul = $( this ),
            $input = $( data.input ),
            value = $input.val(),
            html = "";
        $ul.html( "" );
        if ( value && value.length > 0 ) {
            $ul.html( "<li><div class='ui-loader'><span class='ui-icon ui-icon-loading'></span></div></li>" );
            $ul.listview( "refresh" );
            $.ajax({
url: myManifest.Settings.DefaultURL + "/api/profile/comuni/" + self.$el.find('#prov').val() + "/" + $input.val(),
                Type: "GET"
            })
            .then( function ( response ) {
                $.each( response, function ( i, val ) {
                    html += "<li>" + val.Comune + "<input id='hdnCAP" + i + "'' type='hidden' value='" + val.CAP + "'></li>";
                });
                $ul.html( html );
                $ul.listview( "refresh" );
                $ul.trigger( "updatelayout");
$ul.find('li').on("click", function(e){
$input.val($(this).text());
self.$el.find('#CAP').val($(this).find(":hidden").val());
$ul.html( "" );
$ul.listview( "refresh" );
$ul.trigger( "updatelayout");
});
            });
        }
    });
},
spaccPMClick: function(e){
if(this.$el.find('#spacc-PMChk').prop('checked')){
this.$el.find('#mapSpacc > :not(.ui-checkbox:has(#spacc-PMChk))').show();
}
else
this.$el.find('#mapSpacc > :not(.ui-checkbox:has(#spacc-PMChk))').hide();
},
//render the content into div of view
@@ -39,6 +111,14 @@ define(['jquery', 'underscore', 'backbone','text!modules/settings/settingsViewTe
this.$el.find('#nResult').val(Profile.data.risRic);
this.$el.find('#theme').val(Profile.data.tema);
this.$el.find('#spacc-PMChk').prop('checked', Profile.data.isSpacc==="0"?false:true);
this.$el.find('#email').val(Profile.data.email);
this.$el.find('#prov').val(Profile.data.dataSpacc.provincia);
this.$el.find('#comune').val(Profile.data.dataSpacc.comune);
this.$el.find('#CAP').val(Profile.data.dataSpacc.cap);
this.$el.find('#tPM').val(Profile.data.dataSpacc.tipopm);
this.$el.find('#privacyChk').prop('checked', Profile.data.dataSpacc.privacy==="0"?false:true);
this.$el.find("#moreBtn").addClass("ui-btn-active");
//$("#homeBtn").addClass("ui-btn-active");
//return to enable chained calls