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. 8
      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; _id = _id + data.uniqueid;
this.enqueue = _enqueue; this.enqueue = _enqueue;
this.id = _id; this.id = _id;
this.slideName = data.slideName;
element = VMM.appendAndGetElement(_parent, "<div>", "slider-item"); 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 /* GETTERS AND SETTERS
================================================== */ ================================================== */
this.setData = function(d) { 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 { } else {
var date = { var date = {
type: "google spreadsheet", type: "google spreadsheet",
slideName: getGVar(dd.gsx$slidename),
startDate: getGVar(dd.gsx$startdate), startDate: getGVar(dd.gsx$startdate),
endDate: getGVar(dd.gsx$enddate), endDate: getGVar(dd.gsx$enddate),
headline: getGVar(dd.gsx$headline), headline: getGVar(dd.gsx$headline),

8
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 () { window.onhashchange = function () {
var hash = window.location.hash.substring(1); var hash = window.location.hash.substring(1);
if (config.hash_bookmark) { if (config.hash_bookmark) {
if (is_moving) { if (is_moving) {
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)); goToEvent(parseInt(hash));
}
} else { } else {
is_moving = false; 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.title = data.date[i].headline;
_date.headline = data.date[i].headline; _date.headline = data.date[i].headline;
_date.type = data.date[i].type; _date.type = data.date[i].type;

Loading…
Cancel
Save