figureslibres 5 years ago
parent
commit
1b3eff32e6
1 changed files with 71 additions and 111 deletions
  1. 71 111
      user/themes/r2c/js/script.js

+ 71 - 111
user/themes/r2c/js/script.js

@@ -3,7 +3,7 @@ function synchro() {
 
 }
 // Streetmap
-function map() {
+function map(targets) {
   var mymap = L.map('mapid').setView([48.9367935,2.3569287], 17);
   setTimeout(mymap.invalidateSize.bind(map));
   L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
@@ -39,50 +39,53 @@ function map() {
       })
       .bindPopup(dyn_data.mappoints[i].title)
       .addTo(mymap);
-
-
     markers[id]._icon.id = id;
-
     var cible = dyn_data.mappoints[i].target;
   }
 
-  // function markerFunction(id){
-  //   // console.log('id', hash);
-  //
-  //   // var hrefs = $(this).attr("alt").split(',');
-  //   // // console.log('hrefs', hrefs);
-  //   // var h, h_parts;
-  //   // for (var i = 0; i < hrefs.length; i++) {
-  //   //   h = hrefs[i];
-  //   //   h_parts = h.match(/^#(([^_]+)_(.+)$)/);
-  //   //   // console.log('h_parts', h_parts);
-  //
-  //
-  //    for (var i in markers){
-  //        var markerID = markers[i]._icon.id;
-  //        // console.log('markerID',markers[i]);
-  //        var hrefsMarker = markerID.split(',');
-  //        var hM, h_partsM;
-  //
-  //        for (var i = 0; i < hrefsMarker.length; i++) {
-  //          hM = hrefsMarker[i];
-  //         h_partsM = hM.match(/^#(([^_]+)_(.+)$)/);
-  //        console.log('h_partsM', hM);
-  //      }
-  //
-  //        if (hM == id){
-  //            markers[i].openPopup();
-  //        };
-  //    }
-  // }
+  $("a").click(function(){
+    console.log('targets',targets);
+  });
+};
 
+function markerFunction(targets, markers ){
+  // console.log('id', hash);
 
-  // TODO a quoi ça sert ça ? sur TOUS les liens ? vraiment ?
+  // var hrefs = $(this).attr("alt").split(',');
+  // // console.log('hrefs', hrefs);
+  // var h, h_parts;
+  // for (var i = 0; i < hrefs.length; i++) {
+  //   h = hrefs[i];
+  //   h_parts = h.match(/^#(([^_]+)_(.+)$)/);
+  //   // console.log('h_parts', h_parts);
+
+  // console.log('targets',targets);
+  // console.log('markers[id]',markers[0]);
   // $("a").click(function(){
   //   markerFunction($(this)[0].hash);
   //   console.log('$(this)[0]',$(this)[0].hash);
   // });
-};
+  // if (targets == markers[0]) {
+  //   console.log('cc');
+  //   markers.openPopup;
+  // }
+   // for (var i in markers){
+   //     var markerID = markers[i]._icon.id;
+   //     console.log('markerID',markers[i]);
+   //     var hrefsMarker = markerID.split(',');
+   //     var hM, h_partsM;
+   //
+   //     for (var i = 0; i < hrefsMarker.length; i++) {
+   //       hM = hrefsMarker[i];
+   //      h_partsM = hM.match(/^#(([^_]+)_(.+)$)/);
+   //     console.log('h_partsM', hM);
+   //   }
+   //
+   //     if (hM == id){
+   //         markers[i].openPopup();
+   //     };
+   // }
+}
 
 // change mouse_event
 function clickhand(){
@@ -94,7 +97,6 @@ function clickhand(){
   });
 };
 
-
 function drag() {
   var $hand = $( ".handler" );
   var $hand1 = $( ".hand1" );
@@ -323,6 +325,7 @@ function dragcanvas() {
 
 // hidden scroll + synchro
 function mCustomScrollbar() {
+
     $('.blocs').mCustomScrollbar({
       mouseWheel:{
         deltaFactor: 5
@@ -330,7 +333,7 @@ function mCustomScrollbar() {
           scrollInertia: 1000,
     });
 
-    $(document).on("click","a[href^='#'],#links .nodes text[href^='#'],#streetmap img[href^='#']",function(e){
+    $(document).on("click","a[href^='#'],#links .nodes text[href^='#'],#streetmap img[href^='#'], #images img[href^='#']",function(e){
       e.preventDefault();
       var targets = $(this).attr("href").split(',');
       // console.log('hrefs', hrefs);
@@ -338,28 +341,49 @@ function mCustomScrollbar() {
     });
 }
 
-
 function scrollBlockTo($block, href){
   $block.mCustomScrollbar("scrollTo",href,{
     scrollInertia:1000,
   });
 }
 
+function fillColorMapLink(targets, h_parts){
 
-function synchBloks(targets) {
-  // stop function if targets is not an array or an empty one
-  // console.log("typeof targets", typeof targets);
-  // if(typeof targets != "array" || !targets.length)
-  //   return
+  var target = $('#links.mCustomScrollbar');
+  var href = target.find(h_parts[0]);
+  var $text0 = $(this).find(href);
+  var text = $('.nodes text.group1');
+  var text2 = $('.nodes text.group2');
+  var text3 = $('.nodes text.group3');
 
+  text.css({
+    'font-size':'inherit',
+    'fill':'black',
+  });
+  text2.css({
+    'font-size':'inherit',
+    'fill':'grey',
+  });
+  text3.css({
+    'font-size':'inherit',
+    'fill':'lightgrey',
+  });
+  if (href) {
+    href.css({
+      'font-size':'1.2rem',
+      'fill':'blue',
+    });
+  }
+}
+
+function synchBloks(targets) {
   console.log('synchBloks : targets', targets);
 
   var h, h_parts;
+
   for (var i = 0; i < targets.length; i++) {
     h = targets[i];
     h_parts = h.match(/^#(([^_]+)_(.+)$)/);
-    // console.log('h_parts', h_parts);
-
     switch (h_parts[2]) {
       case 'rct':
       scrollBlockTo($('#recits.mCustomScrollbar'), h);
@@ -372,36 +396,11 @@ function synchBloks(targets) {
         break;
       case 'mp':
         scrollBlockTo($('#streetmap.mCustomScrollbar'), h);
+        markerFunction(h, h_parts);
         break;
       case 'lk':
         scrollBlockTo($('#links.mCustomScrollbar'), h);
-
-        // ICI IL FAUT FAIRE UNE AUTRE FUNCTION COMME CE N4EST PAS UN SCROLL QUI SE PASSE
-        // var href = target.find(h_parts[0]);
-        // var text = $('.nodes text.group1');
-        // var text2 = $('.nodes text.group2');
-        // var text3 = $('.nodes text.group3');
-        // console.log('cc');
-
-        // text.css({
-        //   'font-size':'inherit',
-        //   'fill':'black',
-        // });
-        // text2.css({
-        //   'font-size':'inherit',
-        //   'fill':'grey',
-        // });
-        // text3.css({
-        //   'font-size':'inherit',
-        //   'fill':'lightgrey',
-        // });
-        //
-        // if (href) {
-        //   href.css({
-        //     'font-size':'1.2rem',
-        //     'fill':'blue',
-        //   });
-        // }
+        fillColorMapLink(h, h_parts);
         break;
       // case 'rs':
       //   var target = $('#reseaux-sociaux.mCustomScrollbar');
@@ -413,43 +412,6 @@ function synchBloks(targets) {
       default:
     }
   }
-
-}
-
-
-function clicklinkmap() {
-  $("text#lk_martine").on("click", function(){
-
-    // var href = target.find(h_parts[0]);
-    // var text = $('.nodes text.group1');
-    // var text2 = $('.nodes text.group2');
-    // var text3 = $('.nodes text.group3');
-    // text.css({
-    //   'font-size':'inherit',
-    //   'fill':'black',
-    // });
-    // text2.css({
-    //   'font-size':'inherit',
-    //   'fill':'grey',
-    // });
-    // text3.css({
-    //   'font-size':'inherit',
-    //   'fill':'lightgrey',
-    // });
-    //
-    // if (href) {
-    //   href.css({
-    //     'font-size':'1.2rem',
-    //     'fill':'blue',
-    //   });
-    // }
-
-    // $("svg .nodes text").css({
-    //   'font-size':'1.2rem',
-    //   'z-index': '999',
-    //   'fill':'blue',
-    // })
- });
 }
 
 function paperjs() {
@@ -667,13 +629,11 @@ function paperjs() {
 $(document).ready(function() {
   // paperjs();
   // clickcanvena();
-  clicklinkmap();
   mCustomScrollbar();
   clickhand();
   drag();
   // dragcanvas();
   map();
-  clicklinkmap();
   // paperjs();
   // D3js();
 });