X-Git-Url: https://dev.renevier.net/?p=syj.git;a=blobdiff_plain;f=public%2Fjs%2Fsyj.js;h=7864fe9309575aa371e0109b49bc78816c6a82de;hp=fbe3f737efcc06d9ff0eef3a091e0b03aa59c554;hb=ff69f7714757b203baa031cf3c86a7f4256b11e2;hpb=6a642fc4ff9526efe4ac180e53f356be79235c62 diff --git a/public/js/syj.js b/public/js/syj.js index fbe3f73..7864fe9 100644 --- a/public/js/syj.js +++ b/public/js/syj.js @@ -1,11 +1,15 @@ /* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier, and is published under the AGPL license. */ +"use strict"; + // avoid openlayers alerts OpenLayers.Console.userError = function(error) { SYJView.messenger.setMessage(error, "error"); }; +OpenLayers.Layer.Vector.prototype.renderers = ["SVG2", "VML", "Canvas"]; + var SyjSaveUI = { status: "unknown", @@ -292,7 +296,7 @@ var SYJView = { 'http://a.tile.openstreetmap.org/${z}/${x}/${y}.png', 'http://b.tile.openstreetmap.org/${z}/${x}/${y}.png', 'http://c.tile.openstreetmap.org/${z}/${x}/${y}.png'], - { wrapDateLine: true , attribution: SyjStrings.osmAttribution }); + { attribution: SyjStrings.osmAttribution }); layerOptions = {format: OpenLayers.Format.WKT, projection: WGS84, @@ -305,7 +309,7 @@ var SYJView = { if ($("edit-btn")) { $("edit-btn").observe('click', function() { $("geom_submit").value = SyjStrings.editAction; - this.messenger.hide(); + this.messenger.clearMessages(); this.editMode(); this.mode = 'edit'; }.bind(this)); @@ -314,7 +318,7 @@ var SYJView = { if ($("create-btn")) { $("create-btn").observe('click', function() { $("geom_submit").value = SyjStrings.createAction; - this.messenger.hide(); + this.messenger.clearMessages(); this.editMode(); this.mode = 'create'; }.bind(this)); @@ -324,7 +328,7 @@ var SYJView = { $("clone-btn").observe('click', function() { $("geom_submit").value = SyjStrings.cloneAction; $("geom_title").value = ""; - this.messenger.hide(); + this.messenger.clearMessages(); this.editMode(); this.mode = 'create'; }.bind(this)); @@ -454,7 +458,7 @@ var SYJView = { observer: function(evt) { if (evt.eventName === "simplebox:shown" && evt.memo.element !== $("termsofusearea")) { - this.messenger.hide(); + this.messenger.clearMessages(); } }, @@ -490,7 +494,7 @@ var SYJView = { } this.needsFormResubmit = false; SyjSaveUI.disable.bind(SyjSaveUI).defer(); - this.messenger.hide(); + this.messenger.clearMessages(); return true; }, @@ -569,7 +573,7 @@ var SYJView = { } }, create: function(f, line) { - this.messenger.hide(); + this.messenger.clearMessages(); $("geom_upload_container").hide(); }.bind(this) }, @@ -738,7 +742,7 @@ var SYJModalClass = Class.create({ }, reset: function() { - this.messenger.hide(); + this.messenger.clearMessages(); this.area.select('.message').invoke('setMessageStatus', null); } }); @@ -751,7 +755,11 @@ var SYJUserClass = Class.create(SYJModalClass, { $super(); $("termsofusearea").hide(); - $$("#user_termsofuse_anchor, #geom_termsofuse_anchor").invoke('observe', "click", function(evt) { + var touevt = (function(evt) { + if (evt.type === "keyup" && evt.keyCode !== 32) { // 32 = space + // allow opening box by pressing space + return; + } if (!this.toubox) { this.toubox = new SimpleBox($("termsofusearea"), { closeMethods: ["onescapekey", "onouterclick", "onbutton"] @@ -763,7 +771,11 @@ var SYJUserClass = Class.create(SYJModalClass, { $("termsofuseiframe").setAttribute("src", evt.target.href); } evt.stop(); - }.bindAsEventListener(this)); + }).bindAsEventListener(this); + + ["click", "keyup"].each(function (evtName) { + $$("#user_termsofuse_anchor, #geom_termsofuse_anchor").invoke('observe', evtName, touevt); + }) $$("#login_area_create > a").invoke('observe', 'click', function(evt) { @@ -796,7 +808,7 @@ var SYJUserClass = Class.create(SYJModalClass, { }, presubmit: function() { - this.messenger.hide(); + this.messenger.clearMessages(); PseudoChecker.reset(); if (!(this.checkNotEmpty("user_pseudo", SyjStrings.userEmptyWarn))) { return false; @@ -914,7 +926,7 @@ var SYJLoginClass = Class.create(SYJModalClass, { }, presubmit: function() { - this.messenger.hide(); + this.messenger.clearMessages(); if (!(this.checkNotEmpty("login_user", SyjStrings.userEmptyWarn))) { return false; }