Browse Source

add hash string routing ability with slideName.

pull/747/head
lcb931023 10 years ago
parent
commit
56816cedba
  1. 1
      source/js/Core/Slider/VMM.Slider.Slide.js
  2. 16
      source/js/Core/Slider/VMM.Slider.js
  3. 1
      source/js/VMM.Timeline.DataObj.js
  4. 10
      source/js/VMM.Timeline.js

1
source/js/Core/Slider/VMM.Slider.Slide.js

@ -22,6 +22,7 @@ if (typeof VMM.Slider != 'undefined') {
_id = _id + data.uniqueid;
this.enqueue = _enqueue;
this.id = _id;
this.slideName = data.slideName;
element = VMM.appendAndGetElement(_parent, "<div>", "slider-item");

16
source/js/Core/Slider/VMM.Slider.js

@ -113,6 +113,18 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
}
}
// Get index using Slide Name for hash routing
this.findSlideIndexByName = function(n) {
for (var i = 0; i < slides.length; i++)
{
if (slides[i].slideName == n) {
return i;
}
}
return -1;
};
/* GETTERS AND SETTERS
================================================== */
this.setData = function(d) {
@ -799,7 +811,3 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
};
}

1
source/js/VMM.Timeline.DataObj.js

@ -282,6 +282,7 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
} else {
var date = {
type: "google spreadsheet",
slideName: getGVar(dd.gsx$slidename),
startDate: getGVar(dd.gsx$startdate),
endDate: getGVar(dd.gsx$enddate),
headline: getGVar(dd.gsx$headline),

10
source/js/VMM.Timeline.js

@ -155,11 +155,18 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
}
}
// Routes number AND Slide Name
window.onhashchange = function () {
var hash = window.location.hash.substring(1);
if (config.hash_bookmark) {
if (is_moving) {
goToEvent(parseInt(hash));
if ( isNaN(parseInt(hash)) ) {
// if string, find the index and route to it
var slideI = slider.findSlideIndexByName(hash);
if ( slideI != -1 ) goToEvent(slideI);
} else {
goToEvent(parseInt(hash));
}
} else {
is_moving = false;
}
@ -580,6 +587,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
}
}
_date.slideName = data.date[i].slideName;
_date.title = data.date[i].headline;
_date.headline = data.date[i].headline;
_date.type = data.date[i].type;

Loading…
Cancel
Save