Commit d1c264c2 authored by Raph El's avatar Raph El Committed by GitHub
Browse files

Merge pull request #483 from GrondinDam/copedia

Copedia
parents f01c3a97 f91ee221
function bindCommunexionScopeEvents(){
$(".btn-decommunecter").click(function(){
$(".btn-decommunecter").off().on('click',function(){
activateGlobalCommunexion(false);
});
$(".item-globalscope-checker").click(function(){
......@@ -34,6 +34,10 @@ function bindCommunexionScopeEvents(){
if(actionOnSetGlobalScope=="filter"){
if(location.hash.indexOf("#live") >= 0){
startNewsSearch(true)
}
else if (location.hash.indexOf("#interoperability") >= 0) {
initTypeSearchInterop();
startSearchInterop(0,30);
}
else{
startSearch(0, indexStepInit);
......@@ -84,6 +88,7 @@ function activateGlobalCommunexion(active, firstLoad){
//rebuildSearchScopeInput();
showTagsScopesMin();
bindCommunexionScopeEvents();
if(actionOnSetGlobalScope=="filter"){
if(location.hash.indexOf("#live") >=0)
startNewsSearch(true);
......
......@@ -592,7 +592,7 @@ function connectTo(parentType, parentId, childId, childType, connectType, parent
$.ajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/link/connect",
data: formData,
data: formData,
dataType: "json",
success: function(data) {
if(data.result){
......@@ -660,6 +660,7 @@ var urlCtrl = {
"#element" : {title:'DETAIL ENTITY', icon : 'legal'},
"#gallery" : {title:'ACTION ROOMS ', icon : 'photo'},
"#comment" : {title:'DISCUSSION ROOMS ', icon : 'comments'},
"#admin.checkgeocodage" : {title:'CHECKGEOCODAGE ', icon : 'download', useHeader: true},
"#admin.openagenda" : {title:'OPENAGENDA ', icon : 'download', useHeader: true},
"#admin.adddata" : {title:'ADDDATA ', icon : 'download', useHeader: true},
......@@ -676,6 +677,7 @@ var urlCtrl = {
"#adminpublic.index" : {title:'SOURCE ADMIN', icon : 'download', useHeader: true},
"#adminpublic.createfile" : {title:'IMPORT DATA', icon : 'download', useHeader : true},
"#adminpublic.adddata" : {title:'ADDDATA ', icon : 'download', useHeader : true},
"#adminpublic.interopproposed" : {title : 'INTEROP PROPOSED', icon : 'download', useHeader : true},
"#admin.cleantags" : {title : 'CLEAN TAGS', icon : 'download'},
"#default.directory" : {title:'COMMUNECTED DIRECTORY', icon : 'connectdevelop', menuId:"menu-btn-directory"},
"#default.news" : {title:'COMMUNECTED NEWS ', icon : 'rss', menuId:"menu-btn-news" },
......@@ -693,6 +695,10 @@ var urlCtrl = {
"#define." : {title:'TAG MAP ', icon : 'map-marker', action:function( hash ){ showDefinition("explain"+hash.split('.')[1]) } },
"#data.index" : {title:'OPEN DATA FOR ALL', icon : 'fa-folder-open-o'},
"#opendata" : {"alias":"#data.index"},
"#interoperability.copedia" : {title:'COPEDIA', icon : 'fa-folder-open-o','useHeader' : true},
"#interoperability.co-osm" : {title:'COSM', icon : 'fa-folder-open-o','useHeader' : true},
"#chatAction" : {title:'CHAT', icon : 'comments', action:function(){ rcObj.loadChat("","citoyens", true, true) }, removeAfterLoad : true },
},
shortVal : ["p","poi","s","o","e","pr","c","cl"/* "s","v","a", "r",*/],
......@@ -794,7 +800,6 @@ var urlCtrl = {
path = urlCtrl.convertToPath(hash);
pathT = path.split('/');
//open path in a modal (#openModal)
if(pathT[0] == "modal"){
path = path.substring(5);
alert(baseUrl+'/'+moduleId+path);
......
......@@ -60,6 +60,8 @@ function startSearch(indexMin, indexMax, callBack){
if(levelCommunexion == 3) locality = inseeCommunexion;
if(levelCommunexion == 4) locality = inseeCommunexion;
if(levelCommunexion == 5) locality = "";
mylog.log("Locality : ", locality);
}
console.log("locality",locality);
autoCompleteSearch(name, locality, indexMin, indexMax, callBack);
......@@ -150,7 +152,7 @@ function autoCompleteSearch(name, locality, indexMin, indexMax, callBack){
if(isMapEnd)
$("#map-loading-data").html("<i class='fa fa-spin fa-circle-o-notch'></i> chargement en cours");
mylog.dir(data);
//alert();
$.ajax({
......@@ -330,7 +332,7 @@ function autoCompleteSearch(name, locality, indexMin, indexMax, callBack){
Sig.showMapElements(Sig.map, mapElements, "search", "Résultats de votre recherche");
if(typeof callBack == "function")
callBack();
callBack();
}
});
......@@ -667,7 +669,7 @@ var directory = {
colPos: "left",
dirLog : false,
defaultPanelHtml : function(params){
mylog.log("----------- defaultPanelHtml",params.type,params.name);
mylog.log("----------- defaultPanelHtml",params, params.type,params.name, params.url);
str = "";
str += "<div class='col-lg-4 col-md-6 col-sm-6 col-xs-12 searchEntityContainer "+params.type+" "+params.elTagsList+" "+params.elRolesList+" '>";
str += "<div class='searchEntity' id='entity"+params.id+"'>";
......@@ -832,7 +834,7 @@ var directory = {
// ********************************
elementPanelHtml : function(params){
if(directory.dirLog) mylog.log("----------- elementPanelHtml",params.type,params.name);
//mylog.log("----------- elementPanelHtml",params.type,params.name, params);
// mylog.log("----------- elementPanelHtml",params.type,params.name, params);
str = "";
var grayscale = ( ( notNull(params.isInviting) && params.isInviting == true) ? "grayscale" : "" ) ;
var tipIsInviting = ( ( notNull(params.isInviting) && params.isInviting == true) ? trad["Wait for confirmation"] : "" ) ;
......@@ -1739,11 +1741,23 @@ var directory = {
var str = "";
directory.colPos = "left";
if(typeof data == "object" && data!=null)
$.each(data, function(i, params) {
if(directory.dirLog) mylog.log("params", params, typeof params);
if(params["_id"] != null || params["id"] != null){
mylog.log("params", params, typeof params);
if ((typeof(params.id) == "undefined") && (typeof(params["_id"]) !== "undefined")) {
params['id'] = params['_id'];
} else if (typeof(params.id) == "undefined") {
params['id'] = Math.random();
params['type'] = "poi";
}
mylog.log("params", params["name"] , params.name, params.id, params["id"], typeof params["id"]);
if(notNull(params["_id"]) || notNull(params["id"])){
itemType=(contentType) ? contentType :params.type;
if( itemType ){
......@@ -1754,6 +1768,7 @@ var directory = {
var typeIco = i;
params.size = size;
params.id = getObjectId(params);
mylog.log(params.id);
params.name = notEmpty(params.name) ? params.name : "";
params.description = notEmpty(params.shortDescription) ? params.shortDescription :
(notEmpty(params.message)) ? params.message :
......@@ -1765,8 +1780,13 @@ var directory = {
if(typeof edit != "undefined" && edit != false)
params.edit = edit;
/*if( dyFInputs.get( itemType ) == null)
itemType="poi";*/
if(typeof( typeObj[itemType] ) == "undefined") {
itemType="poi";
}
if( dyFInputs.get( itemType ) == null)
itemType="poi";
typeIco = itemType;
if(directory.dirLog) mylog.warn("itemType",itemType,"typeIco",typeIco);
......@@ -1826,13 +1846,25 @@ var directory = {
params.urlParent = (notEmpty(params.parentType) && notEmpty(params.parentId)) ?
'#page.type.'+params.parentType+'.id.' + params.parentId : "";
//params.url = '#page.type.'+params.type+'.id.' + params.id;
params.hash = '#page.type.'+params.type+'.id.' + params.id;
/*if(params.type == "poi")
params.hash = '#element.detail.type.poi.id.' + params.id;*/
if( params.type == "poi" && params.source.insertOrign == "import") {
var interop_type = getTypeInteropData(params.source.key);
params.hash = getUrlForInteropDirectoryElements(interop_type, params.shortDescription, params.url);
params.url = params.hash;
params.color = getIconColorForInteropElements(interop_type);
params.htmlIco = getImageIcoForInteropElements(interop_type);
params.type = "poi.interop."+interop_type;
if (typeof params.tags == "undefined")
params.tags = [];
params.tags.push(interop_type);
} else {
params.onclick = 'urlCtrl.loadByHash("' + params.hash + '");';
params.hash = '#page.type.'+params.type+'.id.' + params.id;
}
params.onclick = 'urlCtrl.loadByHash("' + params.url + '");';
// params.tags = "";
params.elTagsList = "";
var thisTags = "";
if(typeof params.tags != "undefined" && params.tags != null){
......@@ -1888,6 +1920,7 @@ var directory = {
str += directory.coopPanelHtml(params);
else
str += directory.defaultPanelHtml(params);
}
}else{
......
This diff is collapsed.
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['module'], factory);
} else if (typeof exports !== "undefined") {
factory(module);
} else {
var mod = {
exports: {}
};
factory(mod);
global.TimelineChart = mod.exports;
}
})(this, function (module) {
'use strict';
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var TimelineChart = function () {
function TimelineChart(element, data, opts, label_dbpedia, wikidataID) {
_classCallCheck(this, TimelineChart);
var self = this;
element.classList.add('timeline-chart');
var options = this.extendOptions(opts);
var allElements = data.reduce(function (agg, e) {
return agg.concat(e.data);
}, []);
var minDt = d3.min(allElements, this.getPointMinDt);
var maxDt = d3.max(allElements, this.getPointMaxDt);
var elementWidth = options.width || element.clientWidth;
var elementHeight = options.height || element.clientHeight;
var margin = {
top: 0,
right: 0,
bottom: 20,
left: 0
};
var width = elementWidth - margin.left - margin.right;
var height = elementHeight - margin.top - margin.bottom;
var groupWidth = 200;
var x = d3.time.scale().domain([minDt, maxDt]).range([groupWidth, width]);
var xAxis = d3.svg.axis().scale(x).orient('bottom').tickSize(-height);
var zoom = d3.behavior.zoom().x(x).on('zoom', zoomed);
var svg = d3.select(element).append('svg').attr('width', width + margin.left + margin.right).attr('height', height + margin.top + margin.bottom).append('g').attr('transform', 'translate(' + margin.left + ',' + margin.top + ')').call(zoom);
svg.append('defs').append('clipPath').attr('id', 'chart-content').append('rect').attr('x', groupWidth).attr('y', 0).attr('height', height).attr('width', width - groupWidth);
svg.append('rect').attr('class', 'chart-bounds').attr('x', groupWidth).attr('y', 0).attr('height', height).attr('width', width - groupWidth);
svg.append('g').attr('class', 'x axis').attr('transform', 'translate(0,' + height + ')').call(xAxis);
if (options.enableLiveTimer) {
self.now = svg.append('line').attr('clip-path', 'url(#chart-content)').attr('class', 'vertical-marker now').attr("y1", 0).attr("y2", height);
}
var groupHeight = height / data.length;
var groupSection = svg.selectAll('.group-section').data(data).enter().append('line').attr('class', 'group-section').attr('x1', 0).attr('x2', width).attr('y1', function (d, i) {
return groupHeight * (i + 1);
}).attr('y2', function (d, i) {
return groupHeight * (i + 1);
});
var groupLabels = svg.selectAll('.group-label').data(data).enter().append('text').attr('class', 'group-label').attr('x', 0).attr('y', function (d, i) {
return groupHeight * i + groupHeight / 2 + 5.5;
}).attr('dx', '0.5em').text(function (d) {
return d.label;
});
var lineSection = svg.append('line').attr('x1', groupWidth).attr('x2', groupWidth).attr('y1', 0).attr('y2', height).attr('stroke', 'black');
var groupIntervalItems = svg.selectAll('.group-interval-item').data(data).enter().append('g').attr('clip-path', 'url(#chart-content)').attr('class', 'item').attr('transform', function (d, i) {
return 'translate(0, ' + groupHeight * i + ')';
}).selectAll('.dot').data(function (d) {
return d.data.filter(function (_) {
return _.type === TimelineChart.TYPE.INTERVAL;
});
}).enter();
var intervalBarHeight = 0.8 * groupHeight;
var intervalBarMargin = (groupHeight - intervalBarHeight) / 2;
var intervals = groupIntervalItems.append('rect').attr('class', withCustom('interval')).attr('width', function (d) {
return Math.max(options.intervalMinWidth, x(d.to) - x(d.from));
}).attr('height', intervalBarHeight).attr('y', intervalBarMargin).attr('x', function (d) {
return x(d.from);
});
var intervalTexts = groupIntervalItems.append('text').text(function (d) {
return d.label;
}).attr('fill', 'white').attr('class', withCustom('interval-text')).attr('y', groupHeight / 2 + 5).attr('x', function (d) {
return x(d.from);
});
var groupDotItems = svg.selectAll('.group-dot-item').data(data).enter().append('g').attr('clip-path', 'url(#chart-content)').attr('class', 'item').attr('transform', function (d, i) {
return 'translate(0, ' + groupHeight * i + ')';
}).selectAll('.dot').data(function (d) {
return d.data.filter(function (_) {
return _.type === TimelineChart.TYPE.POINT;
});
}).enter();
var dots = groupDotItems.append('circle').attr('class', withCustom('dot')).attr('cx', function (d) {
return x(d.at);
}).attr('cy', groupHeight / 2).attr('r', 5);
var tip_link = {};
tip_link.label_dbpedia = label_dbpedia;
if (options.tip) {
if (d3.tip) {
var tip = d3.tip().attr('class', 'd3-tip').html(options.tip);
console.log(tip);
svg.call(tip);
dots.on('mouseover', tip.show).on('mouseout', tip.hide);
dots.on('click', function() {
mylog.log('LE FOCUS EST SUR : ', $(".n")[0].innerHTML);
displayDetailModal($(".n")[0].innerHTML);
});
} else {
console.error('Please make sure you have d3.tip included as dependency (https://github.com/Caged/d3-tip)');
}
}
zoomed();
if (options.enableLiveTimer) {
setInterval(updateNowMarker, options.timerTickInterval);
}
function updateNowMarker() {
var nowX = x(new Date());
self.now.attr('x1', nowX).attr('x2', nowX);
}
function withCustom(defaultClass) {
return function (d) {
return d.customClass ? [d.customClass, defaultClass].join(' ') : defaultClass;
};
}
function zoomed() {
if (self.onVizChangeFn && d3.event) {
self.onVizChangeFn.call(self, {
scale: d3.event.scale,
translate: d3.event.translate,
domain: x.domain()
});
}
if (options.enableLiveTimer) {
updateNowMarker();
}
svg.select('.x.axis').call(xAxis);
svg.selectAll('circle.dot').attr('cx', function (d) {
return x(d.at);
});
svg.selectAll('rect.interval').attr('x', function (d) {
return x(d.from);
}).attr('width', function (d) {
return Math.max(options.intervalMinWidth, x(d.to) - x(d.from));
});
svg.selectAll('.interval-text').attr('x', function (d) {
var positionData = getTextPositionData.call(this, d);
if (positionData.upToPosition - groupWidth - 10 < positionData.textWidth) {
return positionData.upToPosition;
} else if (positionData.xPosition < groupWidth && positionData.upToPosition > groupWidth) {
return groupWidth;
}
return positionData.xPosition;
}).attr('text-anchor', function (d) {
var positionData = getTextPositionData.call(this, d);
if (positionData.upToPosition - groupWidth - 10 < positionData.textWidth) {
return 'end';
}
return 'start';
}).attr('dx', function (d) {
var positionData = getTextPositionData.call(this, d);
if (positionData.upToPosition - groupWidth - 10 < positionData.textWidth) {
return '-0.5em';
}
return '0.5em';
}).text(function (d) {
var positionData = getTextPositionData.call(this, d);
var percent = (positionData.width - options.textTruncateThreshold) / positionData.textWidth;
if (percent < 1) {
if (positionData.width > options.textTruncateThreshold) {
return d.label.substr(0, Math.floor(d.label.length * percent)) + '...';
} else {
return '';
}
}
return d.label;
});
function getTextPositionData(d) {
this.textSizeInPx = this.textSizeInPx || this.getComputedTextLength();
var from = x(d.from);
var to = x(d.to);
return {
xPosition: from,
upToPosition: to,
width: to - from,
textWidth: this.textSizeInPx
};
}
}
}
_createClass(TimelineChart, [{
key: 'extendOptions',
value: function extendOptions() {
var ext = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var defaultOptions = {
intervalMinWidth: 8, // px
tip: undefined,
textTruncateThreshold: 30,
enableLiveTimer: false,
timerTickInterval: 1000
};
Object.keys(ext).map(function (k) {
return defaultOptions[k] = ext[k];
});
return defaultOptions;
}
}, {
key: 'getPointMinDt',
value: function getPointMinDt(p) {
return p.type === TimelineChart.TYPE.POINT ? p.at : p.from;
}
}, {
key: 'getPointMaxDt',
value: function getPointMaxDt(p) {
return p.type === TimelineChart.TYPE.POINT ? p.at : p.to;
}
}, {
key: 'onVizChange',
value: function onVizChange(fn) {
this.onVizChangeFn = fn;
return this;
}
}]);
return TimelineChart;
}();
TimelineChart.TYPE = {
POINT: Symbol(),
INTERVAL: Symbol()
};
module.exports = TimelineChart;
});
\ No newline at end of file
......@@ -13,16 +13,16 @@ function saveMultiScope(){ mylog.log("saveMultiScope() try - userId = ",userId);
data: {"multiscopes" : myMultiScopes},
dataType: "json",
success: function(data){
mylog.log("updatemultiscope success");
mylog.log("updatemultiscope success");
},
error: function(error){
mylog.log("Une erreur est survenue pendant l'enregistrement des scopes");
}
});
}else{
}
}
showCountScope();
//rebuildSearchScopeInput();
setTimeout(function(){ rebuildSearchScopeInput() }, 1000);
......
......@@ -144,9 +144,13 @@
var markerName = this.getIcoNameByType(thisData);
//mylog.log("markerName", markerName);
var iconUrl = assetPath+'/images/sig/markers/icons_carto/'+markerName+'.png';
if(typeof thisData.profilMarkerImageUrl !== "undefined" && thisData.profilMarkerImageUrl != ""){
iconUrl = baseUrl + thisData.profilMarkerImageUrl;
}
if (thisData.typeSig.substr(0,11) == "poi.interop") {
var iconUrl = getimgProfilPathForInteropDataOnMap(thisData.typeSig);
}
return L.icon({
iconUrl: iconUrl,
iconSize: [53, 60], //38, 95],
......
......@@ -381,8 +381,18 @@
"markerPlace" : { ico : "map-marker", color : "red" },
"me" : { ico : "map-marker", color : "blue" },
"poi" : { ico : "map-marker", color : "green-poi" },
"poi.video" : { ico : "video-camera", color : "green-poi" },
"poi" : { ico : "info-circle", color : "dark" },
"poi.video" : { ico : "video-camera", color : "dark" },
"poi.interop.wiki" : { ico : "folder-open", color : "yellow" },
"poi.interop.datagouv" : { ico : "folder-open", color : "yellow" },
"poi.interop.osm" : { ico : "folder-open", color : "yellow" },
"poi.interop.ods" : { ico : "folder-open", color : "yellow" },
"poi.interop.datanova" : { ico : "folder-open", color : "yellow" },
"poi.interop.poleemploi" : { ico : "folder-open", color : "yellow" },