--- a/src/hdalab/static/hdalab/js/gomina.js Fri Mar 20 01:42:58 2015 +0100
+++ b/src/hdalab/static/hdalab/js/gomina.js Fri Mar 20 11:54:04 2015 +0100
@@ -120,7 +120,6 @@
_curView[_type].push(_label);
}
updateFilters();
- //debouncedSaveChanges();
}
}
@@ -129,7 +128,6 @@
if (_curView.type == 'filter') {
_curView[_type].splice(_index,1);
updateFilters();
- //debouncedSaveChanges();
}
}
@@ -162,7 +160,6 @@
_curView.period[_n] = _int;
}
updateFilters();
- //debouncedSaveChanges();
}
}
}
@@ -173,7 +170,6 @@
_curView.period[0] = gomNs.minYear;
_curView.period[1] = gomNs.maxYear;
updateFilters();
- //debouncedSaveChanges();
}
}
@@ -314,78 +310,47 @@
+ ' <a class="mind-map-icon-white" href="' + gomNs.urls.renkan + '?label=' + _t.label + '" target="_blank">placeholder</a></h3>'
+ '</li>';
}).join('')
- /*+ '</ul><h4>'+gettext("Annotations")+'</h4><div class="content-annotation" contentid="'
- + _d.id
- + '">'
- + ( gomNs.sessiondata.annotations[_d.id] && gomNs.sessiondata.annotations[_d.id].texte
- ? '<ul><li>'
- + _.escape(gomNs.sessiondata.annotations[_d.id].texte).replace(/\n/gm,"</li><li>")
- + '</li>'
- : ( gomNs.write_allowed ? '<ul><li>'+gettext("Annoter ce contenu")+'...</li></ul>' : '' ) )*/
+ '</div>';
- /*if (gomNs.write_allowed) {
- _(gomNs.sessiondata.views).each(function(_view, _k) {
- if (_view.type == 'list') {
- _html += '<p><a href="#" class="addremlist" contentid="'
- + _d.id
- + '" viewid="'
- + _k
- + '">'
- + str_format(( _view.list.indexOf(_d.id) == -1 ? gettext('Ajouter a {0}') : gettext('Retirer de {0}') ),'"'+ _.escape(_view.name)+ '"')
- + '</a></p>'
- }
- });
- }*/
_html += '</li>';
return _html;
}).join('')
+ '</ul>';
$("#contents").html(_htmlCl).scrollTop(0);
- /*$("a.addremlist").click(function() {
- var _id = $(this).attr("contentid"),
- _vid =
- _view = gomNs.sessiondata.views[$(this).attr("viewid")],
- _io = _view.list.indexOf(_id);
- if ( _io == -1) {
- _view.list.push(_id);
- $(this).html(str_format(gettext('Retirer de {0}'),'"' + _.escape(_view.name) + '"' ));
- } else {
- _view.list.splice(_io, 1);
- $(this).html(str_format(gettext('Ajouter a {0}'),'"' + _.escape(_view.name) + '"'));
- }
- if (gomNs.sessiondata.view == 1) {
- showView();
- }
- debouncedSaveChanges();
- return false;
- });*/
- /*if (gomNs.write_allowed) {
- $("div.content-annotation").click(function() {
- if (this.children[0].tagName == 'UL') {
- var _el = document.createElement('textarea'),
- _id = $(this).attr("contentid");
- _el.innerHTML = (gomNs.sessiondata.annotations[_id] && gomNs.sessiondata.annotations[_id].texte) ? gomNs.sessiondata.annotations[_id].texte : '';
- $(_el).focusout(function() {
- var _id = this.parentNode.attributes.contentid.nodeValue;
- if (!gomNs.sessiondata.annotations[_id]) {
- gomNs.sessiondata.annotations[_id] = {};
- }
- gomNs.sessiondata.annotations[_id].texte = this.value;
- this.parentNode.innerHTML = '<ul><li>' + (this.value.length ? _.escape(gomNs.sessiondata.annotations[_id].texte).replace(/\n/gm,"</li><li>") : gettext('Annoter ce contenu')+'...' ) + '</ul>';
- debouncedSaveChanges();
- });
- $(this).html(_el);
- _el.focus();
- _el.select();
- }
- });
- }*/
+
}
else {
$("#contents").html("");
}
}
+function updateMap() {
+ if (gomNs.countries && gomNs.filterCountries) {
+ var _max = Math.max(1, _(gomNs.filterCountries).max());
+ _(gomNs.countries).each(function(_country, _k) {
+ _k = decodeURIComponent(_k);
+ var _val = gomNs.filterCountries[_k] || 0,
+ _fill = getGradient(_val/_max);
+ switch(gomNs.mappingLibrary) {
+ case 'gmaps':
+ _(_country.gPolygons).each(function(_p) {
+ _p.setOptions({
+ "fillColor" : _fill,
+ "fillOpacity" : 1
+ });
+ });
+ break;
+ case 'leaflet':
+ _country.layer.setStyle({
+ "fillColor" : _fill,
+ "fillOpacity" : 1
+ })
+ break;
+ }
+ });
+ }
+}
+
+
function updateDisplay(data) {
animStop();
@@ -451,29 +416,9 @@
$("#tagcloud").html("<h4>Pas de mots-clés trouvés</h4>");
}
displayContents(data.contents);
- if (gomNs.countries && data.countries) {
- var _max = Math.max(1, _(data.countries).max());
- _(gomNs.countries).each(function(_country, _k) {
- _k = decodeURIComponent(_k);
- var _val = data.countries[_k] || 0,
- _fill = getGradient(_val/_max);
- switch(gomNs.mappingLibrary) {
- case 'gmaps':
- _(_country.gPolygons).each(function(_p) {
- _p.setOptions({
- "fillColor" : _fill,
- "fillOpacity" : 1
- });
- });
- break;
- case 'leaflet':
- _country.layer.setStyle({
- "fillColor" : _fill,
- "fillOpacity" : 1
- })
- break;
- }
- });
+ if(data.countries) {
+ gomNs.filterCountries = data.countries;
+ $("#map").trigger('mapUpdate.gomina');
}
if (data.disciplines) {
var _disc = data.disciplines.filter(function(_d) {
@@ -502,28 +447,6 @@
}
}
-/*function saveChanges() {
- if (gomNs.sessionid && gomNs.sessionkey) {
- $.getJSON(gomNs.urls['session_info'], {
- "sessionid" : gomNs.sessionid,
- "sessionkey" : gomNs.sessionkey,
- "data" : JSON.stringify(gomNs.sessiondata),
- });
- }
-}*/
-
-//var debouncedSaveChanges = _.debounce(saveChanges, 3000);
-
-/*function changeView(nview) {
- var _curView = gomNs.sessiondata.views[nview];
- if (_curView.type == 'list' && (!_curView.list || !_curView.list.length)) {
- alert(gettext("La liste de contenus est vide ! Ajoutez des contenus pour afficher la liste !"));
- } else {
- gomNs.sessiondata.view = nview;
- debouncedSaveChanges();
- showView();
- }
-}*/
function showView(initial) {
if(typeof initial==="undefined"){
@@ -558,18 +481,6 @@
}
}
-/*function displayViewList() {
- $("#ongletsvues").html(gomNs.sessiondata.views.map(function(_v, _k) {
- return '<li class="lienvue" id="view_'
- + _k
- + '" onclick="changeView('
- + _k
- + '); return false;"><a href="#">'
- + _.escape(_v.name)
- + '</a></li>';
- }).join(""))
-}*/
-
function getURLParameter(name) {
return decodeURI(
@@ -626,76 +537,14 @@
}
};
- /*gomNs.sessionid = data.sessionid;
- if (data.sessionkey) {
- gomNs.sessionkey = data.sessionkey;
- }
- gomNs.write_allowed = data.write_allowed;
- if (data.write_allowed) {
- $("#partagerw").show();
- } else {
- $("#partagerw").hide();
- }*/
- //var _baseUrl = document.location.href.split("#")[0];
- //gomNs.hash = "#" + data.sessionid + (data.sessionkey ? (':' + data.sessionkey) : '');
- //document.location.hash = gomNs.hash;
gomNs.sessiondata = typeof data.data == "string" ? JSON.parse(data.data) : (typeof data.data == "object" ? data.data : {});
- /*if (!gomNs.sessiondata.title) {
- gomNs.sessiondata.title = gettext('Nouvelle session');
- }*/
+
if (!gomNs.sessiondata.views) {
gomNs.sessiondata.views = [];
}
- /*if (!gomNs.sessiondata.views.length) {
- addView( 'filter', gettext('Mes resultats de recherche') );
- addView( 'list', gettext('Ma liste') );
- }
- if (!gomNs.sessiondata.annotations) {
- gomNs.sessiondata.annotations = {};
- }
- if (data.write_allowed) {
- $("#bloc_gestvue").show();
- } else {
- $("#bloc_gestvue").hide();
- }
- $("#sessionname").html(_.escape(gomNs.sessiondata.title)
- + ( data.write_allowed ? '' : '<span class="lectseul"> ('+gettext("lecture seule")+')</span>' ) );
- gomNs.hrefinterval = setInterval(function() {
- if (document.location.hash != gomNs.hash) {
- clearInterval(gomNs.hrefinterval);
- getInitialView();
- }
- }, 500);*/
- //displayViewList();
showView(true);
}
-/*function changeSessionTitle(title) {
- gomNs.sessiondata.title = title;
- $("#sessionname").html(_.escape(gomNs.sessiondata.title));
- debouncedSaveChanges();
-}*/
-
-/*function addView(viewtype, viewname) {
- var _content = {
- type: viewtype,
- name: viewname,
- hiddenWidgets: [],
- };
- switch(viewtype) {
- case 'filter':
- _content.period = [ gomNs.minYear, gomNs.maxYear ];
- _content.tag = [];
- _content.country = [];
- gomNs.sessiondata.view = gomNs.sessiondata.views.length;
- break;
- case 'list':
- _content.list = [];
- break;
- }
- gomNs.sessiondata.views.push(_content);
- debouncedSaveChanges();
-}*/
function animLoad() {
var _d = $("#waiting"),
@@ -746,6 +595,7 @@
);
$(document).ready(function() {
+ var showMethod;
switch(gomNs.mappingLibrary) {
case 'gmaps':
gomNs.map = new google.maps.Map(document.getElementById("map"),
@@ -754,7 +604,7 @@
zoom: 1,
mapTypeId: google.maps.MapTypeId.SATELLITE
});
- $.getJSON(gomNs.urls['countries'], showCountriesGmap);
+ showMethod = showCountriesGmap;
break;
case 'leaflet':
gomNs.map = new L.Map('map', {
@@ -765,9 +615,15 @@
});
gomNs.map.addControl(new L.Control.ZoomMin())
//gomNs.map.addLayer(new L.TileLayer("http://s3.amazonaws.com/com.modestmaps.bluemarble/{z}-r{y}-c{x}.jpg", {maxZoom: 9}));
- $.getJSON(gomNs.urls['countries'], showCountriesLeaflet);
+ showMethod = showCountriesLeaflet;
break;
}
+ $("#map").on('mapUpdate.gomina', updateMap);
+ $.getJSON(gomNs.urls['countries'], function(geoJson) {
+ showMethod(geoJson);
+ $("#map").trigger('mapUpdate.gomina');
+ });
+
var _html = gomNs.displayedDates.map(function(_v) {
return '<li style="left: '
+ parseInt(yearToPx(_v))
@@ -776,49 +632,7 @@
+ '</div></li>'
}).join('');
$("#dates").html(_html);
- /*$("#apartager").click(function() {
- var _pu = $("#partageurls");
- if (_pu.is(":visible")) {
- $(this).removeClass("actif");
- } else {
- $(this).addClass("actif");
- $("#partagero").addClass("actif");
- $("#partagerw").removeClass("actif");
- var _url = document.location.href.split("#")[0] + "#" + gomNs.sessionid;
- $("#zc-partageinput").val( _url.replace(/^(.{30}).{3,1000}(.{20})$/,'$1 … $2') );
- }
- $(this).attr("class",_pu.is(":visible") ? "" : "actif");
- _pu.slideToggle(function() {
- if ($(this).is(":visible")) {
- if (typeof gomNs.clip == "undefined") {
- gomNs.clip = new ZeroClipboard.Client();
- gomNs.clip.setHandCursor( true );
- gomNs.clip.glue('zc-partageinput');
- }
- gomNs.clip.show();
- gomNs.clip.setText( _url );
- } else {
- gomNs.clip.hide();
- }
- });
- return false;
- });*/
- /*$("#partagero").click(function() {
- $("#partagero").addClass("actif");
- $("#partagerw").removeClass("actif");
- var _url = document.location.href.split("#")[0] + "#" + gomNs.sessionid;
- $("#zc-partageinput").val( _url.replace(/^(.{30}).{3,1000}(.{20})$/,'$1 … $2') );
- gomNs.clip.setText( _url );
- return false;
- });
- $("#partagerw").click(function() {
- $("#partagerw").addClass("actif");
- $("#partagero").removeClass("actif");
- var _url = document.location.href.split("#")[0] + gomNs.hash;
- $("#zc-partageinput").val( _url.replace(/^(.{30}).{3,1000}(.{20})$/,'$1 … $2') );
- gomNs.clip.setText( _url );
- return false;
- });*/
+
$(".handle").draggable({
"axis" : "x",
"containment" : "parent",
@@ -842,46 +656,7 @@
}
}
});
- /*$("#sessionname").click(function() {
- if (gomNs.write_allowed && !$(this).children().length) {
- var _el = document.createElement('input');
- _el.value = gomNs.sessiondata.title;
- $(_el).focusout(function() {
- changeSessionTitle(this.value);
- }).keypress(function(e) {
- if (e.keyCode == 13) {
- changeSessionTitle(this.value);
- }
- });
- $(this).html(_el);
- _el.focus();
- _el.select();
- }
- });*/
- /*$("#titrevue").keyup(function() {
- var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view];
- _curView.name = $(this).val();
- $("#view_" + gomNs.sessiondata.view + " a").html(_.escape(_curView.name))
- $("#bloc_gestvue h2").html(gettext('Gerer la vue')+' "' + _.escape(_curView.name) + '"');
- debouncedSaveChanges();
- });*/
- /*$("#notes").click(function() {
- if (gomNs.write_allowed) {
- if (this.children[0].tagName == 'UL') {
- var _el = document.createElement('textarea'),
- _curView = gomNs.sessiondata.views[gomNs.sessiondata.view];
- _el.innerHTML = _curView.notes ? _curView.notes : '';
- $(_el).focusout(function() {
- _curView.notes = this.value;
- this.parentNode.innerHTML = '<ul><li>' + (this.value.length ? _.escape(_curView.notes).replace(/\n/gm,"</li><li>") : gettext('Annoter cette vue')+'...' ) + '</ul>';
- debouncedSaveChanges();
- });
- $(this).html(_el);
- _el.focus();
- _el.select();
- }
- }
- });*/
+
getInitialView();
$(".barrebloc").click(function() {
$(this).next().slideToggle();
@@ -895,42 +670,8 @@
+ '" /><label>' + $(this).find("h2").html() + '</label></li>'
});
_html + '</ul>';
- /*$("#gestvue").append(_html);
- $("#nouvellevue").click(function() {
- $("#plusdevues").slideToggle();
- return false;
- })
- $("#widgetlist input").change(function() {
- var _newWL = [];
- $("#widgetlist input").each(function(_k, _e) {
- var _id = _e.id.substr(5);
- if (!$(_e).prop("checked")) {
- $("#" + _id).hide();
- _newWL.push(_id);
- } else {
- $("#" + _id).show();
- }
- });
- gomNs.sessiondata.views[gomNs.sessiondata.view].hiddenWidgets = _newWL;
- debouncedSaveChanges();
- });
- $("#nouv_resrech").click(function() {
- var _txt = prompt(gettext("Comment souhaitez-vous nommer votre nouvelle vue ?"),gettext("Nouveaux resultats de recherche"));
- if (_txt !== null) {
- addView('filter', _txt);
- displayViewList();
- }
- return false;
- });
- $("#nouv_liste").click(function() {
- var _txt = prompt(gettext("Comment souhaitez-vous nommer votre nouvelle vue ?"),gettext("Nouvelle liste"));
- if (_txt !== null) {
- addView('list', _txt);
- displayViewList();
- }
- return false;
- });*/
- $(" #tagform ").submit(function() {
+
+ $(" #tagform ").submit(function() {
return false;
});
var cache = {}, /*CACHE => http://jqueryui.com/demos/autocomplete/#remote-with-cache */