/** * @author Olivier Monod */ var SignupDlg = function(){ var errorMsg = {0: "
Votre pseudonyme n'a pas la taille requise. Il doit impérativement comporter entre 4 et 20 caractères.
", 1: "
Votre pseudonyme contient des caractères invalides. Merci d'en choisir un autre composé uniquement de lettres sans accent, de chiffres et du tiret bas.
", 2: "
Votre mot de passe n'a pas la taille requise. Il doit impérativement comporter entre 4 et 16 caractères.
", 3: "
Votre mot de passe contient des caractères invalides. Merci d'en choisir un autre composé uniquement de lettres sans accent, de chiffres et du tiret bas sans espace.
", 4: "
Une adresse email valide est nécessaire pour vous inscrire.
", 5: "
Merci d'indiquer votre code postal.
", 6: "
Veuillez préciser votre recherche.
", 7: "
Désoslé, pour s'inscrire il faut avoir 18 ans ou plus.
", 8: "
Votre date de naissance ne semble pas valide. Merci de la rectifier.
", 9: "
Veuillez indiquer votre date de naissance.
"}; return { dlgZIndex : "100501", urlBack : './data/signup2.php', sid : 'egeg0uu8iam63mug62t0c8dnf1', rendered: false, render : function(){ Ext.QuickTips.init(); this.parent = Ext.get("ideelic-signup"); if(this.parent) { this.el = Ext.get("ideelic-signup-ct"); //this.btSend = new Ext.Button( this.el.child("div#ideelic-signup-bt"), {text:" Je m\'inscris ! ", type:"submit", minWidth:70, handler:this.submit, scope:this}); this.btSend = this.el.child("div#bt-signup"); this.btSend.on("click", this.submit, this); //this.layout = this.dialog.getLayout(); //this.layout.beginUpdate(); //this.cpNorth = this.layout.add('north', new Ext.ContentPanel('north', 'North')); //this.cpCenter = this.layout.add('center', new Ext.ContentPanel('center', {fitToFrame:true})); //this.cpSouth = this.layout.add('south', new Ext.ContentPanel('south', 'South')); //this.layout.endUpdate(); //this.cpCenter.getEl().dom.style.position = 'relative'; //this.cpCenter.getEl().findParent('div.x-layout-panel-body', 2).style.position = 'relative'; //this.cpCenter.getEl().findParent('div.x-layout-panel-body', 2).style.overflowX = 'hidden'; //this.bar = new Ext.Bar3d('bar-3d'); //this.btSt1 = new Ext.Bar3d.Item({label:"Renseignements personnels"}); //this.btSt2 = new Ext.Bar3d.Item({label:"Mon profil"}); //this.btSt3 = new Ext.Bar3d.Item({label:"Ma recherche"}); //this.bar.add(this.btSt1, this.btSt2, this.btSt3); //this.bar.render(); //this.bar.select(this.btSt1); //this.iBox = this.cpNorth.getEl().child("img#i-box", true); tfPseudo = new Ext.form.TextFieldExtended({ fieldLabel: 'Mon pseudonyme ', name: 'pseudo', msgTarget:'under', remoteValidation: 'onValidate', //'onBlur' urlRemoteVal: this.urlBack, paramsRemoteVal: { w: 'testPseudo' }, bullet: true, allowBlank:false, blankText:errorMsg[0], minLength:4, minLengthText:errorMsg[0], maxLength:20, maxLengthText:errorMsg[0], invalidText:errorMsg[1], vtype:'pseudo', width:200 }); Ext.form.VTypes['emailText'] = '
Cette adresse email ne semble pas valide, merci de la rectifier.
'; tfPasswd = new Ext.form.TextField({ fieldLabel: 'Mon mot de passe ', msgTarget:'under', name: 'pwd', allowBlank:false, bullet: true, blankText:errorMsg[2], minLength:4, minLengthText:errorMsg[2], maxLength:16, maxLengthText:errorMsg[2], invalidText:errorMsg[3], vtype:'passwd', inputType: "password", width:200 }); tfEmail = new Ext.form.TextFieldExtended({ fieldLabel: 'Mon email ', msgTarget:'under', iconType:'input-lock', iconText:'Votre email ne sera jamais visible
par les autres membres', name: 'email', remoteValidation: 'onBlur', //'onBlur' urlRemoteVal: this.urlBack, paramsRemoteVal: { w: 'testEmail' }, allowBlank:false, bullet: true, blankText:errorMsg[4], vtype:'email', width:200 }); this.cbSex = new Ext.form.ComboBox({ fieldLabel: 'Je suis ', msgTarget:'under', hiddenName:'sexandsearch', bullet: true, allowBlank:false, store: new Ext.data.SimpleStore({ fields: ['value', 'label'], data : [['1', 'une femme qui cherche un homme'], ['2', 'un homme qui cherche une femme'], ['3', 'une femme qui cherche une femme'], ['4', 'un homme qui cherche un homme']] }), blankText:errorMsg[6], displayField:'label', valueField: 'value', mode: 'local', editable:false, forceSelection:true, width:200 }); this.cbCountry = new Ext.form.ComboBox({ fieldLabel: 'Mon pays de résidence ', msgTarget:'under', hiddenName:'country', bullet: true, store: new Ext.data.SimpleStore({ fields: ['value', 'label'], data : [['1', 'France'], ['2', 'Suisse'], ['3', 'Belgique'], ['4', 'Luxembourg'], ['5', 'Canada']] }), displayField:'label', valueField: 'value', mode: 'local', editable:false, forceSelection: true, width:200 }); tfZip = new Ext.form.TextFieldExtended({ fieldLabel: 'Mon code postal ', msgTarget:'under', name: 'zip', remoteValidation: 'onBlur', //'onBlur' urlRemoteVal: this.urlBack, paramsRemoteVal: { w: 'cityFromZip', countryId: '' }, bullet: true, /*maskRe: /[0-9]/,*/ allowBlank:false, blankText:errorMsg[5], invalidText:errorMsg[6], width:200 }); this.cbCity = new Ext.form.ComboBox({ fieldLabel: 'Ma ville ', msgTarget:'under', hiddenName:'city', allowBlank:false, bullet: true, store: new Ext.data.SimpleStore({ fields: ['value', 'label'], data : [['0', '']] }), displayField:'label', valueField: 'value', mode: 'local', editable:false, forceSelection: true, width:200 }); tfDob = new Ext.form.TextField({ fieldLabel: 'Ma date de naissance ', msgTarget:'under', name: 'dob', iconType:'input-lock', iconText:'Votre date de naissance ne sera jamais visible
par les autres membres, par contre votre
âge le sera', allowBlank:false, blankText:errorMsg[9], bullet: true, emptyText: 'JJ/MM/AAAA', width:200, maskRe: /[0-9\/]/i, regex: /[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4,4}$/, validator: this.validDob.createDelegate(this) }); frm = new Ext.form.Form({ labelWidth: 134, // label settings here cascade unless overridden labelPad: 30, url:this.urlBack }); this.fieldsPan = Ext.get("ideelic-signup-fields") frm.add(tfPseudo, tfPasswd, tfEmail, this.cbSex, this.cbCountry, tfZip, this.cbCity, tfDob); frm.render(this.fieldsPan); tfPseudo.on("invalid", this.upSize, this); tfPasswd.on("invalid", this.upSize, this); tfEmail.on("invalid", this.upSize, this); this.cbSex.on("invalid", this.upSize, this); this.cbCountry.on("invalid", this.upSize, this); tfZip.on("invalid", this.upSize, this); this.cbCity.on("invalid", this.upSize, this); tfDob.on("invalid", this.upSize, this); tfPseudo.on("valid", this.upSize, this); tfPasswd.on("valid", this.upSize, this); tfEmail.on("valid", this.upSize, this); this.cbSex.on("valid", this.upSize, this); this.cbCountry.on("valid", this.upSize, this); tfZip.on("valid", this.upSize, this); this.cbCity.on("valid", this.upSize, this); tfDob.on("valid", this.upSize, this); this.cbCountry.setValue('1'); cbCityArea = this.cbCity.container.findParent('div.x-form-item', 2, true); cbCityArea.setVisibilityMode(Ext.Element.DISPLAY); cbCityArea.hide(); this.cbSex.list.setZIndex(parseInt(this.dlgZIndex)+1); this.cbCountry.list.setZIndex(parseInt(this.dlgZIndex)+1); this.cbCity.list.setZIndex(parseInt(this.dlgZIndex)+1); this.cbCountry.on('select', this.countryChange.createDelegate(this) ); tfZip.on({'textChange': {fn: this.changeZip, scope: this}, 'beforeRemoteVal': {fn: this.beforeZipRM, scope: this}, 'afterRemoteVal': {fn: this.afterZipRM, scope: this}, 'errorRemoteVal': {fn: this.errorZipRM, scope: this}}); //this.ct = this.cpCenter.getEl().findParent('div.x-layout-panel-center', 3, true); this.rendered = true; } this.mask = Ext.DomHelper.append(document.body, {tag: "div", cls:"signup-class-mask"}, true); this.mask.enableDisplayMode("block"); this.mask.hide(); this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true)); Ext.EventManager.onWindowResize(this.onWindowResize, this, true); }, upSize: function() { this.parent.setHeight(this.el.getHeight()); }, countryChange : function(cb) { tfZip.reset(); this.cbCity.reset(); cbCityArea.hide(); }, changeZip: function(tf) { if( !this.cbCity.disabled ) { this.cbCity.reset(); cbCityArea.hide(); } }, errorZipRM: function(tf, result) { tf.errorEl.dom.innerHTML = result.errors; this.cbCity.reset(); cbCityArea.hide(); }, beforeZipRM: function(tf) { this.cbCity.reset(); cbCityArea.hide(); tf.paramsRemoteVal.countryId = this.cbCountry.getValue(); }, afterZipRM: function(tf, result) { if(result.values) { this.cbCity.store.loadData(result.values); if(result.values.length <= 1) { this.cbCity.setValue(result.values[0][0]); } cbCityArea.show(true); } else if(result.values==null) { //cbCityArea.show(true); cbCityArea.hide(); } }, validDob: function(val) { var value = (!val || val instanceof Date) ? val : Date.parseDate(val, 'j/n/Y'); var minValue = Date.parseDate('08/09/1900', 'j/n/Y'); var maxValue = Date.parseDate('08/09/1992', 'j/n/Y'); //var minValue = ; //var maxValue = ; if(!value){ return errorMsg[8]; } var time = value.getTime(); if(minValue && time < minValue.getTime()){ return errorMsg[8]; } if(maxValue && time > maxValue.getTime()){ return errorMsg[7]; } var day = val.split("/")[0]; var month = val.split("/")[1]; var year = val.split("/")[2]; var d = new Date(parseInt(year, 10), parseInt(month-1, 10), parseInt(day, 10)); if((d.getMonth()+1!=parseInt(month, 10))||(d.getDate()!=parseInt(day, 10))||(d.getFullYear()!=parseInt(year, 10))) { return errorMsg[8]; } return true; }, submit: function() { var cgu = Ext.get('cgu_ok').dom.checked; //var jeu = Ext.get('jeu_ok').dom.checked var partners = Ext.get('partners_ok').dom.checked if(!frm.isValid() || !tfPseudo.isValid()) { this.el.SlideBox('Pour vous inscrire, merci de bien vouloir renseigner tous les champs.', {maskEl:this.el, duration:2, width:200}); } else if( ! cgu ) { this.el.SlideBox('Pour vous inscrire, vous devez lire et accepter les Conditions Générales d\'Utilisation.', {maskEl:this.el, duration:2, width:200}); } else { this.mask.show(); this.el.mask('Enregistrement...', 'x-loading-box'); frm.submit({params:{cgu_ok : (cgu?"1":"0"), jeu_ok: /*(jeu?"1":"0")*/ "0", partners_ok: (partners?"1":"0"), w: 'setInfo' }, success:this.success, failure:this.failure, scope:this}); } }, failure: function(frm, action) { //this.dialog.el.dom.style.zIndex = this.dialog.lastZIndex; this.mask.hide(); this.el.unmask(); if(typeof action.result.msg != "undefined") { this.el.SlideBox(action.result.msg, {maskEl:this.el, closable:true, width:200}); } else { this.el.SlideBox('Une erreur est survenue, merci de bien vouloir recommencer.', {maskEl:this.el, closable:true, width:200}); } }, success: function(frm, action) { var o = Ext.decode( action.response.responseText); if(o.success) { this.el.setSize( this.el.getSize() ); Ext.apply(this, eval(o.object)); Ext.apply(this, eval(o.critereProfil)); eval(o.critereSearch) this.uid = o.uid; this.k = o.k; this.action(); } else { this.failure(frm, action); } }, onWindowResize:function(w, h) { if(this.mask && this.mask.isVisible()){ this.mask.setSize(w, h); // first make sure the mask isn't causing overflow this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true)); } }, destroy: function() { this.cbCity.destroy(); this.cbCountry.destroy(); this.cbSex.destroy(); Ext.EventManager.removeResizeListener(this.onWindowResize, this); this.mask.remove(); Ext.get("ideelic-signup").remove(); } }; }(); // using onDocumentReady instead of window.onload initializes the application // when the DOM is ready, without waiting for images and other resources to load // Ext.EventManager.onDocumentReady(SignupDlg.init, SignupDlg, true);