set a first_exec var for project detection
This commit is contained in:
@@ -18,20 +18,23 @@
|
||||
</div>
|
||||
<script type="text/javascript" src="script/lightbox.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
self.onSamePageMove = function(asHash){
|
||||
if(typeof self.tmp('map') != 'undefined') {
|
||||
oSpot.onSamePageMove = function(asHash) {
|
||||
if(self.tmp('first_exec')) initPage(asHash);
|
||||
else {
|
||||
self.tmp('map').remove();
|
||||
self.tmp('$Map').empty();
|
||||
self.tmp('map', null);
|
||||
initProject(asHash.items[0]);
|
||||
}
|
||||
else self.pageInit(asHash);
|
||||
return false;
|
||||
};
|
||||
|
||||
oSpot.pageInit = function(asHash)
|
||||
{
|
||||
//Set active project
|
||||
oSpot.pageInit = function(asHash) {
|
||||
self.tmp('first_exec', true);
|
||||
initPage(asHash);
|
||||
};
|
||||
|
||||
function initPage(asHash) {
|
||||
if(asHash.items.length==0) self.setHash(asHash.page, [self.vars('default_project_codename')]);
|
||||
else {
|
||||
self.tmp('$Map', $('#map'));
|
||||
@@ -60,9 +63,10 @@ oSpot.pageInit = function(asHash)
|
||||
//project Bootstrap
|
||||
initProject(asHash.items[0]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function initProject(sProjectCodeName){
|
||||
self.tmp('first_exec', false);
|
||||
self.vars('project', self.vars(['projects', sProjectCodeName]));
|
||||
|
||||
//Spot Messages
|
||||
@@ -79,15 +83,49 @@ function initProject(sProjectCodeName){
|
||||
mimeType: 'application/json'
|
||||
})
|
||||
).done(function(aoMessages, aoTracks) {
|
||||
buildSpotMessages(aoMessages[0]['data'], aoTracks[0]);
|
||||
initSpotMessages(aoMessages[0]['data'], aoTracks[0]);
|
||||
});
|
||||
|
||||
//Posts
|
||||
updateFeed(true);
|
||||
initPosts();
|
||||
}
|
||||
|
||||
function buildSpotMessages(aoMessages, aoTracks) {
|
||||
function initPosts() {
|
||||
var $Poster = $('#poster').empty();
|
||||
if(self.vars(['project', 'mode'])==self.consts.modes.histo) $Poster.hide();
|
||||
else {
|
||||
var asPoster = {
|
||||
type: 'poster',
|
||||
formatted_time: '',
|
||||
relative_time: 'Nouveau message'
|
||||
};
|
||||
getPost(asPoster).appendTo($Poster.show());
|
||||
|
||||
$('#submit').click(function(){
|
||||
if($Poster.checkForm())
|
||||
{
|
||||
self.get(
|
||||
'add_post',
|
||||
function()
|
||||
{
|
||||
$('#name').val('');
|
||||
$('#post').val('');
|
||||
updateFeed(true);
|
||||
},
|
||||
{
|
||||
project_id: self.vars(['project', 'id']),
|
||||
name: $('#name').val(),
|
||||
content: $('#post').val()
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateFeed(true);
|
||||
}
|
||||
|
||||
function initSpotMessages(aoMessages, aoTracks) {
|
||||
|
||||
//Tile layers
|
||||
var oMapBoxSat = L.tileLayer(self.tmp('tile_api'), {id: 'mapbox.satellite', minZoom: 0, maxZoom: 19}),
|
||||
@@ -240,39 +278,6 @@ function buildSpotMessages(aoMessages, aoTracks) {
|
||||
oProjects.addTo(oMap);
|
||||
}
|
||||
|
||||
function initPosts() {
|
||||
var $Poster = $('#poster').empty();
|
||||
if(self.vars(['project', 'mode'])==self.consts.modes.histo) $Poster.hide();
|
||||
else {
|
||||
var asPoster = {
|
||||
type: 'poster',
|
||||
formatted_time: '',
|
||||
relative_time: 'Nouveau message'
|
||||
};
|
||||
getPost(asPoster).appendTo($Poster.show());
|
||||
|
||||
$('#submit').click(function(){
|
||||
if($Poster.checkForm())
|
||||
{
|
||||
self.get(
|
||||
'add_post',
|
||||
function()
|
||||
{
|
||||
$('#name').val('');
|
||||
$('#post').val('');
|
||||
updateFeed(true);
|
||||
},
|
||||
{
|
||||
project_id: self.vars(['project', 'id']),
|
||||
name: $('#name').val(),
|
||||
content: $('#post').val()
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getBoundsZoomLevel(bounds, mapDim) {
|
||||
var WORLD_DIM = { height: 256, width: 256 };
|
||||
var ZOOM_MAX = 21;
|
||||
|
||||
Reference in New Issue
Block a user