portale per la richiesta autorizzazioni sismiche da parte del Genio Civile
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

114 righe
3.9 KiB

var versionamento = {
changes : [],
init:function(idPratica, company, lastVersion, currentVersion){
var scope = this;
// console.log("lastVersion: "+lastVersion);
// console.log("currentVersion: "+currentVersion);
this.loadJsonVersion(idPratica, company, lastVersion, true);
if(currentVersion > 0){
this.loadJsonVersion(idPratica, company, currentVersion, false);
setTimeout(function(){
scope.getChanges(idPratica, company, currentVersion);
}, 300)
} else {
$('#_1_WAR_portosboportlet_version_number .version_body').html("<p class=\"text-center version_item\">Nessuna Versione precedente all'attuale</p>")
}
},
sliderChange:function(idPratica, company, currentVersion){
var scope = this;
this.loadJsonVersion(idPratica, company, currentVersion, false);
setTimeout(function(){
scope.getChanges(idPratica, company, currentVersion);
}, 300)
},
loadJsonVersion: function(idPratica, company, versionNumber, last) {
var scope = this;
Liferay.Service(
'/portos-bo-portlet.dettpratica/get-json-version',
{
intPraticaId: idPratica,
companyId : company,
version: versionNumber
},
function(obj) {
var item = last ? "_1_WAR_portosboportlet_version_last" : "_1_WAR_portosboportlet_version_number";
scope.updateHTML(JSON.parse(obj), item, last ? false : versionNumber);
}
);
},
getChanges: function(idPratica, company, versionNumber) {
var scope = this;
Liferay.Service(
'/portos-bo-portlet.dettpratica/call-for-changes',
{
intPraticaId: idPratica,
companyId : company,
version: versionNumber
},
function(obj) {
var arr = JSON.parse(obj);
$("#_1_WAR_portosboportlet_version_number .version_item").removeClass("background-red")
$("#_1_WAR_portosboportlet_version_last .version_item").removeClass("background-green")
for( index in arr){
var key = arr[index];
var left = $("#_1_WAR_portosboportlet_version_number .item_"+key),
right = $("#_1_WAR_portosboportlet_version_last .item_"+key);
left.addClass("background-red")
right.addClass("background-green")
var heights = [left,right].map(function (item)
{
return $(item).outerHeight();
});
left.css('height', Math.max.apply(null, heights));
right.css('height', Math.max.apply(null, heights));
}
}
);
},
updateHTML: function(obj, containerId, versionNumber) {
var scope = this;
var version_container = $('#'+containerId);
if(versionNumber){
version_container.find(".number").html(versionNumber);
}
for( item in obj ){
var item_value=obj[item].replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#034;/g,"\"");
version_container.find('.item_'+item+" .item_value")
.html("<strong>"+item_value+"</strong>")
}
}
}
var sliderVersion = {
init:function(val, idPratica, company){
/*alert('Slider INIT');*/
var initialValue = val, min = 1, maxValue = (val-1) > 0 ? (val-1) : 0;
versionamento.init(idPratica, company, val, maxValue);
$("#label-slider").text(maxValue);
if(maxValue <= 1) {
$("#label-slider").css("margin-left", '0');
}
$( function() {
$( "#slider" ).slider({
value: val,
min: 1,
max: maxValue,
step: 1,
slide: function( event, ui ) {
$("#label-slider").text(ui.value);
if(maxValue == 0) {
$("#label-slider").css("margin-left", '0');
}else {
$("#label-slider").css("margin-left", (ui.value-min)/(maxValue-min)*100+'%');
}
$("#label-slider").css("left", "-15px");
versionamento.sliderChange(idPratica, company, ui.value);
}
});
});
},
}