Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hash string routing ability with slideName. #747

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/js/Core/Slider/VMM.Slider.Slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
16 changes: 12 additions & 4 deletions source/js/Core/Slider/VMM.Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -799,7 +811,3 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
};

}




3 changes: 2 additions & 1 deletion source/js/VMM.Timeline.DataObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -794,4 +795,4 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef

};

}
}
10 changes: 9 additions & 1 deletion source/js/VMM.Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down