X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;f=public%2Fjs%2Fsyj.js;h=3ed9ad60b8b639cb7995754066ae02ada1428244;hb=9ff9fe8e9026595f8304b1dc0f36e5dffba49c8b;hp=6c4fabe79a206c7193ce0072684b3e8572314a62;hpb=a73afe740db490814c19e8a0023480b11b867db2;p=syj.git diff --git a/public/js/syj.js b/public/js/syj.js index 6c4fabe..3ed9ad6 100644 --- a/public/js/syj.js +++ b/public/js/syj.js @@ -1,4 +1,4 @@ -/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier, +/* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier, and is published under the AGPL license. */ // avoid openlayers alerts @@ -100,7 +100,12 @@ var SYJDataUi = (function() { if (!infotoggler) { infotoggler = new Toggler('path-infos-content'); $("path-infos-toggler").insert({bottom: infotoggler.element}); - $("path-infos-anchor").observe('click', function(evt) { + var anchor = $("path-infos-anchor"); + var parent = anchor.up('.menu-item'); + if (parent) { + anchor = parent; + } + anchor.observe('click', function(evt) { evt.stop(); infotoggler.toggle(evt); }); @@ -283,7 +288,11 @@ var SYJView = { theme: null }); - baseLayer = new OpenLayers.Layer.OSM("OSM", null, { wrapDateLine: true , attribution: SyjStrings.osmAttribution }); + baseLayer = new OpenLayers.Layer.OSM("OSM", [ + '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'], + { attribution: SyjStrings.osmAttribution }); layerOptions = {format: OpenLayers.Format.WKT, projection: WGS84, @@ -296,7 +305,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)); @@ -305,7 +314,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)); @@ -315,7 +324,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)); @@ -427,7 +436,7 @@ var SYJView = { if (aPos.hasOwnProperty('lon') && aPos.hasOwnProperty('lat') && aPos.hasOwnProperty('zoom')) { center = new OpenLayers.LonLat(parseFloat(aPos.lon), parseFloat(aPos.lat)).transform(WGS84, Mercator); - zoom = parseInt(aPos.zoom); + zoom = parseInt(aPos.zoom, 10); } else if (aPos.hasOwnProperty('minlon') && aPos.hasOwnProperty('minlat') && aPos.hasOwnProperty('maxlon') && aPos.hasOwnProperty('maxlat')) { extent = new OpenLayers.Bounds(aPos.minlon, aPos.minlat, aPos.maxlon, aPos.maxlat) @@ -445,7 +454,7 @@ var SYJView = { observer: function(evt) { if (evt.eventName === "simplebox:shown" && evt.memo.element !== $("termsofusearea")) { - this.messenger.hide(); + this.messenger.clearMessages(); } }, @@ -481,7 +490,7 @@ var SYJView = { } this.needsFormResubmit = false; SyjSaveUI.disable.bind(SyjSaveUI).defer(); - this.messenger.hide(); + this.messenger.clearMessages(); return true; }, @@ -560,7 +569,7 @@ var SYJView = { } }, create: function(f, line) { - this.messenger.hide(); + this.messenger.clearMessages(); $("geom_upload_container").hide(); }.bind(this) }, @@ -611,15 +620,6 @@ var SYJView = { case 400: case 404: message = SyjStrings.requestError; - if (transport.responseJSON) { - switch (transport.responseJSON.message) { - case "uniquepath": - message = SyjStrings.uniquePathError; - break; - default: - break; - } - } break; case 403: message = ""; @@ -660,7 +660,12 @@ var SYJModalClass = Class.create({ closeMethods: ["onescapekey", "onouterclick", "onbutton"] }); - $(this.type + "_control_anchor").observe("click", function(evt) { + var anchor = $(this.type + '_control_anchor'); + var parent = anchor.up('.menu-item'); + if (parent) { + anchor = parent; + } + anchor.observe("click", function(evt) { this.modalbox.show(); evt.stop(); }.bindAsEventListener(this)); @@ -693,7 +698,7 @@ var SYJModalClass = Class.create({ input = this.area.select('input[type="text"]')[0]; (function () { input.activate(); - }).defer(); + }.defer()); } else { this.modalbox.hide(); } @@ -733,7 +738,7 @@ var SYJModalClass = Class.create({ }, reset: function() { - this.messenger.hide(); + this.messenger.clearMessages(); this.area.select('.message').invoke('setMessageStatus', null); } }); @@ -791,7 +796,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; @@ -909,7 +914,7 @@ var SYJLoginClass = Class.create(SYJModalClass, { }, presubmit: function() { - this.messenger.hide(); + this.messenger.clearMessages(); if (!(this.checkNotEmpty("login_user", SyjStrings.userEmptyWarn))) { return false; }