X-Git-Url: https://dev.renevier.net/gitweb.cgi?a=blobdiff_plain;f=public%2Fjs%2Fsyj.js;h=bb8ce117dab0e65263eff9496b0b0df920a71cc8;hb=a602acd4b5d049d92b5793afb8e024717d2aa33f;hp=db4259e497c33389df77c19349749c79deb29650;hpb=3c4eae3c94fd2369087cd3cc73e195cbc48fc433;p=syj.git
diff --git a/public/js/syj.js b/public/js/syj.js
index db4259e..bb8ce11 100644
--- a/public/js/syj.js
+++ b/public/js/syj.js
@@ -4,7 +4,7 @@ Element.addMethods('input', {
observe : Element.Methods.observe.wrap(function(proceed, element, eventName, handler) {
if (eventName === "contentchange") {
proceed(element, 'keyup', function(evt) {
- if (evt.keyCode == 13) {
+ if (evt.keyCode === 13) {
return;
}
handler.apply(null, arguments);
@@ -47,8 +47,7 @@ var SyjSaveUI = {
}
this.enableSubmit();
$("geom_title").disabled = false;
- $("geom_title").focus();
- $("geom_title").select();
+ $("geom_title").activate();
$("geomform").removeClassName("disabled");
this.status = "enabled";
return this;
@@ -81,10 +80,6 @@ var SyjSaveUI = {
};
var SyjEditUI = {
- init: function() {
- return this;
- },
-
hide: function() {
$("edit-btn").blur();
$("edit-btn").hide();
@@ -232,7 +227,7 @@ var SYJView = {
needsFormResubmit: false,
init: function() {
- var externalGraphic, baseURL, baseLayer, layerOptions, extent = null, hidemessenger;
+ var externalGraphic, baseURL, baseLayer, layerOptions, extent, hidemessenger;
// is svg context, opera does not resolve links with base element is svg context
externalGraphic = styleMap.edit.styles.select.defaultStyle.externalGraphic;
@@ -253,8 +248,8 @@ var SYJView = {
layerOptions = {format: OpenLayers.Format.WKT,
projection: WGS84,
styleMap: styleMap.view};
- if (gLoggedInfo.ownername) {
- layerOptions.attribution = SyjStrings.routeBy + ' ' + '' + gLoggedInfo.ownername + '';
+ if (gLoggedInfo.creatorname) {
+ layerOptions.attribution = SyjStrings.routeBy + ' ' + '' + gLoggedInfo.creatorname + '';
}
this.viewLayer = new OpenLayers.Layer.Vector("View Layer", layerOptions);
@@ -264,7 +259,6 @@ var SYJView = {
this.messenger.hide();
this.editMode();
}).bind(this));
- SyjEditUI.init().hide();
$("geomform").ajaxize({
presubmit: this.prepareForm.bind(this),
@@ -284,18 +278,15 @@ var SYJView = {
this.messenger.hide();
}
- extent = null;
if ($("geom_data").value) {
this.viewLayer.addFeatures([this.wkt.read($("geom_data").value)]);
extent = this.viewLayer.getDataExtent();
// XXX: ie has not guessed height of map main div yet during map
// initialisation. Now, it will read it correctly.
this.map.updateSize();
- SyjEditUI.show();
} else {
extent = new OpenLayers.Bounds(gMaxExtent.minlon, gMaxExtent.minlat, gMaxExtent.maxlon, gMaxExtent.maxlat)
.transform(WGS84, Mercator);
- this.editMode();
}
this.map.zoomToExtent(extent);
document.observe('simplebox:shown', this.observer.bindAsEventListener(this));
@@ -308,6 +299,13 @@ var SYJView = {
},
prepareForm: function(form) {
+ if (!loginMgr.logged && !$("geom_accept").checked) {
+ this.messenger.setMessage(SyjStrings.acceptTermsofuseWarn, "warn");
+ $("geom_accept_container").highlight('#F08080');
+ $("geom_accept").activate();
+ return false;
+ }
+
var line, realPoints, idx, handler;
line = new OpenLayers.Geometry.LineString();
@@ -328,6 +326,7 @@ var SYJView = {
this.needsFormResubmit = false;
SyjSaveUI.disable.bind(SyjSaveUI).defer();
this.messenger.hide();
+ return true;
},
editMode: function() {
@@ -412,7 +411,6 @@ var SYJView = {
if (transport) {
httpCode = transport.getStatus();
}
- message = "";
switch (httpCode) {
case 0:
message = SyjStrings.notReachedError;
@@ -434,16 +432,6 @@ var SYJView = {
}
}
break;
- case 403:
- message = "";
- this.needsFormResubmit = true;
- if (loginMgr.hasAlreadyConnected()) {
- SYJLogin.messenger.setMessage(SyjStrings.cookiesNeeded, "warn");
- } else {
- SYJLogin.messenger.setMessage(SyjStrings.loginNeeded, "warn");
- }
- SYJLogin.modalbox.show();
- break;
case 500:
message = SyjStrings.serverError;
this.needsFormResubmit = true;
@@ -492,7 +480,7 @@ var SYJModalClass = Class.create({
checkNotEmpty: function(input, message) {
if ($(input).value.strip().empty()) {
this.messenger.setMessage(message, "warn");
- $(input).highlight('#F08080').focus();
+ $(input).highlight('#F08080').activate();
return false;
}
return true;
@@ -506,8 +494,7 @@ var SYJModalClass = Class.create({
if (simplebox === this.modalbox) {
input = this.area.select('input[type="text"]')[0];
(function () {
- input.focus();
- input.select();
+ input.activate();
}).defer();
} else {
this.modalbox.hide();
@@ -544,8 +531,7 @@ var SYJModalClass = Class.create({
this.messenger.setMessage(message, "error");
input = this.area.select('input[type="text"]')[0];
- input.highlight('#F08080').focus();
- input.select();
+ input.highlight('#F08080').activate();
},
reset: function() {
@@ -562,7 +548,7 @@ var SYJUserClass = Class.create(SYJModalClass, {
$super();
$("termsofusearea").hide();
- $("user_termsofuse_anchor").observe("click", function(evt) {
+ $$("#user_termsofuse_anchor, #geom_termsofuse_anchor").invoke('observe', "click", function(evt) {
if (!this.toubox) {
$("termsofusearea").show();
$("termsofuseiframe").setAttribute("src", evt.target.href);
@@ -587,6 +573,19 @@ var SYJUserClass = Class.create(SYJModalClass, {
$("user_password-desc").setMessageStatus("success");
}
}.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();
+ });
},
presubmit: function() {
@@ -596,8 +595,7 @@ var SYJUserClass = Class.create(SYJModalClass, {
if (!($("user_pseudo").value.match(/^[a-zA-Z0-9_.]+$/))) {
this.messenger.setMessage(SyjStrings.invalidPseudo, "warn");
- $("user_pseudo").highlight('#F08080').focus();
- $("user_pseudo").select();
+ $("user_pseudo").highlight('#F08080').activate();
return false;
}
@@ -607,15 +605,13 @@ var SYJUserClass = Class.create(SYJModalClass, {
if ($("user_password").value.length < 6) {
$("user_password-desc").setMessageStatus("warn");
- $("user_password").highlight('#F08080').focus();
- $("user_password").select();
+ $("user_password").highlight('#F08080').activate();
return false;
}
if ($("user_password").value !== $("user_password_confirm").value) {
this.messenger.setMessage(SyjStrings.passwordNoMatchWarn, "warn");
- $("user_password").highlight('#F08080').focus();
- $("user_password").select();
+ $("user_password").highlight('#F08080').activate();
return false;
}
@@ -625,7 +621,8 @@ var SYJUserClass = Class.create(SYJModalClass, {
if (!$("user_accept").checked) {
this.messenger.setMessage(SyjStrings.acceptTermsofuseWarn, "warn");
- $("user_accept").highlight('#F08080').focus();
+ $("user_accept_container").highlight('#F08080');
+ $("user_accept").activate();
return false;
}
@@ -639,7 +636,7 @@ var SYJUserClass = Class.create(SYJModalClass, {
this.modalbox.hide();
if (SYJView.needsFormResubmit) {
SYJView.messenger.addMessage(SyjStrings.canResubmit);
- $("geom_submit").focus();
+ $("geom_submit").activate();
}
},
@@ -677,8 +674,7 @@ var SYJUserClass = Class.create(SYJModalClass, {
if (message) {
this.messenger.setMessage(message, "error");
if (focusInput) {
- focusInput.highlight('#F08080').focus();
- focusInput.select();
+ focusInput.highlight('#F08080').activate();
}
return;
}
@@ -714,7 +710,7 @@ var SYJLoginClass = Class.create(SYJModalClass, {
this.modalbox.hide();
if (SYJView.needsFormResubmit) {
SYJView.messenger.addMessage(SyjStrings.canResubmit);
- $("geom_submit").focus();
+ $("geom_submit").activate();
}
},
@@ -738,8 +734,7 @@ var SYJLoginClass = Class.create(SYJModalClass, {
if (message) {
this.messenger.setMessage(message, "error");
if (focusInput) {
- focusInput.highlight('#F08080').focus();
- focusInput.select();
+ focusInput.highlight('#F08080').activate();
}
return;
}
@@ -776,30 +771,27 @@ var loginMgr = Object.extend(gLoggedInfo, {
}
if (this.logged) {
this.controlsdeck.setIndex(1);
+ $$(".logged-hide").invoke('hide');
+ $$(".logged-show").invoke('show');
} else {
this.controlsdeck.setIndex(0);
+ $$(".logged-hide").invoke('show');
+ $$(".logged-show").invoke('hide');
}
- if (this.isowner) {
+ if (this.iscreator) {
$("data_controls").show();
} else {
$("data_controls").hide();
}
},
- login: function(aIsOwner) {
- if (typeof aIsOwner === "boolean") {
- this.isowner = aIsOwner;
+ login: function(aIsCreator) {
+ if (typeof aIsCreator === "boolean") {
+ this.iscreator = aIsCreator;
}
this.logged = true;
- this.connections++;
this.updateUI();
- },
-
- // needed in case of 403 errors: if user has already connected successfully
- // before, it probably means he has cookies disabled
- hasAlreadyConnected: function() {
- return (this.connections >= 1);
}
});