X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;f=public%2Fjs%2Fsyj.js;h=39ecd4f90bdf86b8321054ead2e08f823a28612d;hb=6cc4b3cd4538430770c935bd3192f1f72d75d96b;hp=190cc76ee4d7a192aa56cb298cad4289c7b99f96;hpb=17ac0916d7f99be6c7568f0100e5bd628b52124d;p=syj.git diff --git a/public/js/syj.js b/public/js/syj.js index 190cc76..39ecd4f 100644 --- a/public/js/syj.js +++ b/public/js/syj.js @@ -14,18 +14,6 @@ var SyjSaveUI = { return this; }, - hide: function() { - $("geom_submit").blur(); - $("geom_title").blur(); - $("geomform").hide(); - return this; - }, - - show: function() { - $("geomform").show(); - return this; - }, - enable: function() { if (this.status === "enabled") { return this; @@ -52,6 +40,7 @@ var SyjSaveUI = { enableSubmit: function() { $("geom_submit").disabled = false; + $("geom_accept").disabled = false; this.status = "partial"; return this; }, @@ -59,23 +48,30 @@ var SyjSaveUI = { disableSubmit: function() { $("geom_submit").blur(); $("geom_submit").disabled = true; + $("geom_accept").blur(); + $("geom_accept").disabled = true; this.status = "partial"; return this; } }; -var SyjEditUI = { - hide: function() { - $("data_controls_btns").blur(); - $("data_controls_btns").hide(); - return this; - }, - - show: function() { - $("data_controls_btns").show(); - return this; - } -}; +var SYJDataUi = (function() { + var deck = null, + getdeck = function() { + if (!deck) { + deck = new Deck("data_controls"); + } + return deck; + }; + return { + viewmode: function() { + getdeck().setIndex(0); + }, + editmode: function() { + getdeck().setIndex(1); + } + }; +}()); OpenLayers.Handler.SyjModifiablePath = OpenLayers.Class(OpenLayers.Handler.ModifiablePath, { mouseup: function(evt) { @@ -234,10 +230,8 @@ var SYJView = { layerOptions = {format: OpenLayers.Format.WKT, projection: WGS84, - styleMap: styleMap.view}; - if (gLoggedInfo.creatorname) { - layerOptions.attribution = SyjStrings.routeBy + ' ' + '' + gLoggedInfo.creatorname + ''; - } + styleMap: styleMap.view, + attribution: SyjStrings.geomAttribution }; this.viewLayer = new OpenLayers.Layer.Vector("View Layer", layerOptions); this.map.addLayers([baseLayer, this.viewLayer]); @@ -267,7 +261,6 @@ var SYJView = { this.messenger.hide(); this.editMode(); this.mode = 'create'; - SyjSaveUI.enableSubmit(); }.bind(this)); } @@ -276,7 +269,7 @@ var SYJView = { onSuccess: this.saveSuccess.bind(this), onFailure: this.saveFailure.bind(this) }); - SyjSaveUI.init().hide(); + SyjSaveUI.init(); this.messenger = $('message'); hidemessenger = this.messenger.empty(); @@ -378,12 +371,11 @@ var SYJView = { this.viewLayer.destroyFeatures(); - SyjEditUI.hide(); + SYJDataUi.editmode(); if (this.editControl.handler.realPoints && this.editControl.handler.realPoints.length >= 2) { - SyjSaveUI.show(); SyjSaveUI.disableSubmit(); } else { - SyjSaveUI.show().disable(); + SyjSaveUI.disable(); } }, @@ -401,9 +393,9 @@ var SYJView = { SYJView.unsavedRoute = {}; } if (this.handler.realPoints.length < 2) { - SyjSaveUI.show().disable(); + SyjSaveUI.disable(); } else { - SyjSaveUI.show().enable(); + SyjSaveUI.enable(); } } }, @@ -428,8 +420,7 @@ var SYJView = { callback: function(form) { this.viewMode(); this.mode = 'view'; - SyjSaveUI.hide(); - SyjEditUI.show(); + SYJDataUi.viewmode(); this.messenger.hide(); if (this.unsavedRoute && typeof this.unsavedRoute.features !== "undefined") { @@ -454,8 +445,7 @@ var SYJView = { } this.messenger.setMessage(SyjStrings.saveSuccess, "success"); - SyjSaveUI.hide(); - SyjEditUI.show(); + SYJDataUi.viewmode(); document.title = $('geom_title').value; }, @@ -609,13 +599,15 @@ var SYJUserClass = Class.create(SYJModalClass, { $$("#user_termsofuse_anchor, #geom_termsofuse_anchor").invoke('observe', "click", function(evt) { if (!this.toubox) { - $("termsofusearea").show(); - $("termsofuseiframe").setAttribute("src", evt.target.href); this.toubox = new SimpleBox($("termsofusearea"), { closeMethods: ["onescapekey", "onouterclick", "onbutton"] }); } this.toubox.show(); + if (!$("termsofuseiframe").getAttribute("src")) { + $("termsofusearea").show(); + $("termsofuseiframe").setAttribute("src", evt.target.href); + } evt.stop(); }.bindAsEventListener(this)); @@ -646,18 +638,7 @@ var SYJUserClass = Class.create(SYJModalClass, { } }.bindAsEventListener(this)); - $("account-info").hide(); - $("account-info-bullet").observe('click', function(evt) { - var elt = $("account-info"); - if (elt.visible()) { - evt.target.src = "icons/bullet_arrow_right.png"; - elt.hide(); - } else { - evt.target.src = "icons/bullet_arrow_down.png"; - elt.show(); - } - evt.stop(); - }); + $('account-create-anchor').insert({after: new Toggler('account-info').element}); }, presubmit: function() { @@ -782,11 +763,21 @@ var SYJLoginClass = Class.create(SYJModalClass, { }, success: function(transport) { - if (transport.responseText === "1") { - LoginMgr.login(true); - } else { - LoginMgr.login(); + if (!transport.responseJSON || + typeof transport.responseJSON.iscreator !== "boolean" || + typeof transport.responseJSON.pseudo !== "string" + ) { + this.messenger.setMessage(SyjStrings.unknownError, "error"); + return; } + LoginMgr.login(transport.responseJSON.iscreator); + $$('.logged-pseudo').each(function(elt) { + $A(elt.childNodes).filter(function(node) { + return (node.nodeType === 3 || node.tagName.toLowerCase() === 'br'); + }).each(function(node) { + node.nodeValue = node.nodeValue.replace('%s', transport.responseJSON.pseudo); + }); + }); SYJView.messenger.setMessage(SyjStrings.loginSuccess, "success"); this.modalbox.hide(); if (SYJView.needsFormResubmit) { @@ -975,6 +966,7 @@ var PseudoChecker = { document.observe("dom:loaded", function() { SYJLogin.init(); SYJUser.init(); + SYJDataUi.viewmode(); SYJView.init(); SYJNewpwd.init(); LoginMgr.updateUI();