Correction de la non-navigation lors du clic sur un numéro de fiche
This commit is contained in:
parent
8ce0d22746
commit
996dd38060
|
@ -2,4 +2,4 @@ function inputPhoneContact(a){this.container=a}inputPhoneContact.prototype={cont
|
|||
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$("article.contact-panel .new-contact"),c=0;c<a.length;c++){var d=a[c].parentNode.children.indexOf(a[c]),b=(new FormDeflater(a[c],["input"],["data-name"])).deflate(),e=0<b.number.value.length;if(e=e&&0<b.username.value.length+b.firstname.value.length+b.lastname.value.length)b={uid:d,number:b.number.value,username:b.username.value,firstname:b.firstname.value,lastname:b.lastname.value},b.hash=
|
||||
crc32(JSON.stringify(b)),lsi.set("contacts","form"+d,b)}};
|
||||
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";this.container.innerHTML+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");for(var c=this,d=0;d<a.length;d++)a[d].removeEventListener("click",function(a){c.handler(a.target)},!1),a[d].addEventListener("click",function(a){c.handler(a.target)},!1)};
|
||||
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi["export"]("contacts");this.container.innerHTML="";for(var c in a)this.add(a[c]);this.add({number:"",firstname:"",lastname:"",username:""})};inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("contacts");this.handler=a;this.storageToFields()};
|
||||
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi["export"]("contacts");this.container.innerHTML="";for(var c in a)this.add(a[c]);this.add({number:"",firstname:"",lastname:"",username:""})};inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("contacts");this.handler=a};
|
||||
|
|
|
@ -143,5 +143,5 @@ inputPhoneContact.prototype.attach = function(handler){
|
|||
this.handler = handler;
|
||||
|
||||
/* (3) On charge les contacts depuis la mémoire ('localStorage') */
|
||||
this.storageToFields();
|
||||
// this.storageToFields();
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@ c[b].removeAttribute("checked");for(c=0;c<a.freq.length;c++)for(var d=$$('articl
|
|||
d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";var b=[],c;for(c in a){var d=a[c].uid;d==this.selected&&this.add(a[c]);b.push(d)}this.updateNavBar(b)};
|
||||
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");for(var a=lsi.keys("contacts"),b=0;b<a.length&&10>b;b++){var c=lsi.get("contacts",a[b]),d=lsi.get("fiches",a[b]);null==d&&(d=this.defaultData);d.uid=c.uid;d.firstname=c.firstname;d.lastname=c.lastname;d.username=c.username;lsi.set("fiches",a[b],d)}};
|
||||
inputPhoneFiche.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))return!1;for(var b=$$("#nav-fiche > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(a){this.nav_container.innerHTML="";for(var b=0;b<a.length;b++){var c=parseInt(a[b])+1;this.nav_container.innerHTML+="<span>"+c+"</span>"}a=lsi["export"]("fiches");for(var d in a)!0===a[d].valid?this.nav_container.children[a[d].uid].addClass("done"):this.nav_container.children[a[d].uid].remClass("done");this.nav(this.nav_container.children[this.selected])};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
|
||||
inputPhoneFiche.prototype.check=function(a){if(isNaN(parseInt(a.age))||2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||!checkRadioValue(a.sexe)||!checkRadioValue(a.famsit)||!checkRadioValue(a.reltype)||!checkRadioValue(a.loc)||!checkRadioValue(a.context))return!1;for(var b=0;b<a.freq.length;b++)if(!checkRadioValue(a.freq[b]))return!1;for(b=0;b<
|
||||
a.connect.length;b++)if(!checkRadioValue(a.connect[b]))return!1;return a.reltype[8].status&&2>a.reltypeSpecial.length||a.context[11].status&&2>a.contextSpecial[0].length||a.context[12].status&&2>a.contextSpecial[1].length||a.context[13].status&&2>a.contextSpecial[2].length?!1:!0};
|
||||
inputPhoneFiche.prototype.attach=function(a){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler()},!1)};
|
||||
inputPhoneFiche.prototype.attach=function(a){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};
|
||||
|
|
|
@ -391,27 +391,35 @@ inputPhoneFiche.prototype.nav = function(element){
|
|||
|
||||
/* [7] Mise à jour de la navigation
|
||||
=========================================================*/
|
||||
inputPhoneFiche.prototype.updateNavBar = function(uid_list){
|
||||
/* (1) On vide la nav bar */
|
||||
inputPhoneFiche.prototype.updateNavBar = function(){
|
||||
var ficheData = lsi.export('fiches');
|
||||
var len = Object.keys(ficheData).length;
|
||||
|
||||
|
||||
/* (1) On vérifie si la barre de navigation est à jour */
|
||||
var navBarUpToDate = this.nav_container.children.length == len;
|
||||
|
||||
|
||||
/* (2) On vide et remplit la barre de nav, si elle n'est pas à jour */
|
||||
if( !navBarUpToDate ){
|
||||
this.nav_container.innerHTML = '';
|
||||
|
||||
/* (2) On la re-remplit avec toutes les données */
|
||||
for( var i = 0 ; i < uid_list.length ; i++ ){
|
||||
// On rajoute 1 pour la lisibilité
|
||||
var realIndex = parseInt(uid_list[i]) + 1;
|
||||
|
||||
this.nav_container.innerHTML += '<span>'+realIndex+'</span>';
|
||||
|
||||
for( var i = 0 ; i < len ; i++ )
|
||||
this.nav_container.innerHTML += '<span></span>';
|
||||
}
|
||||
|
||||
/* (3) On montre les FICHES qui sont correctes */
|
||||
var ficheData = lsi.export('fiches');
|
||||
for( var key in ficheData ){
|
||||
|
||||
var currentElement = this.nav_container.children[ ficheData[key].uid ];
|
||||
|
||||
// On remplit avec le numéro de la fiche
|
||||
currentElement.innerHTML = ficheData[key].uid+1;
|
||||
|
||||
// Si la MINI fiche est valide
|
||||
if( ficheData[key].valid === true ) this.nav_container.children[ficheData[key].uid].addClass('done');
|
||||
if( ficheData[key].valid === true ) currentElement.addClass('done');
|
||||
// Si elle est invalide
|
||||
else this.nav_container.children[ficheData[key].uid].remClass('done');
|
||||
else currentElement.remClass('done');
|
||||
|
||||
}
|
||||
|
||||
|
@ -525,7 +533,7 @@ inputPhoneFiche.prototype.attach = function(handler){
|
|||
// 1. On gère la navigation
|
||||
ptr.nav(e.target);
|
||||
// 2. On gere le chargement dynamique
|
||||
ptr.handler();
|
||||
ptr.handler(e.target);
|
||||
}, false);
|
||||
|
||||
};
|
||||
|
|
|
@ -6,5 +6,5 @@ miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.use
|
|||
"checked"):c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length&&b<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi["export"]("mini-fiches");this.container.innerHTML="";this.add(a["form"+this.selected]);this.updateNavBar()};
|
||||
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b;for(b in a){var c=lsi.get("mini-fiches",b);null==c&&(c=this.defaultData,c.valid=!1);c.uid=a[b].uid;c.firstname=a[b].firstname;c.lastname=a[b].lastname;c.username=a[b].username;lsi.set("mini-fiches",b,c)}};
|
||||
inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))return!1;for(var b=$$("#nav-mini > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1};
|
||||
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),a=Object.keys(a).length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var b=0;b<a;b++)this.nav_container.innerHTML+="<span></span>"}var a=lsi["export"]("mini-fiches"),c;for(c in a)b=this.nav_container.children[a[c].uid],b.innerHTML=a[c].uid+1,!0===a[c].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
|
||||
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
|
||||
inputPhoneMini.prototype.check=function(a){return!isNaN(parseInt(a.age))&&checkRadioValue(a.sexe)&&"."!=a.job&&checkRadioValue(a.loc)?!0:!1};inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};
|
||||
|
|
|
@ -248,10 +248,12 @@ inputPhoneMini.prototype.updateNavBar = function(){
|
|||
var miniData = lsi.export('mini-fiches');
|
||||
var len = Object.keys(miniData).length;
|
||||
|
||||
|
||||
/* (1) On vérifie si la barre de navigation est à jour */
|
||||
var navBarUpToDate = this.nav_container.children.length == len;
|
||||
|
||||
/* (1) On vide et remplit la barre de nav, si elle n'est pas à jour */
|
||||
|
||||
/* (2) On vide et remplit la barre de nav, si elle n'est pas à jour */
|
||||
if( !navBarUpToDate ){
|
||||
this.nav_container.innerHTML = '';
|
||||
|
||||
|
@ -260,11 +262,11 @@ inputPhoneMini.prototype.updateNavBar = function(){
|
|||
}
|
||||
|
||||
/* (3) On montre les MINI fiches qui sont correctes dans la navbar */
|
||||
var miniData = lsi.export('mini-fiches');
|
||||
for( var key in miniData ){
|
||||
|
||||
var currentElement = this.nav_container.children[miniData[key].uid];
|
||||
var currentElement = this.nav_container.children[ miniData[key].uid ];
|
||||
|
||||
// On remplit avec le numéro de la MINI fiche
|
||||
currentElement.innerHTML = miniData[key].uid+1;
|
||||
|
||||
// Si la MINI fiche est valide
|
||||
|
|
Loading…
Reference in New Issue