Browse Source

Bugfix for languages not loading. Added more robust Google Spreadsheet data parsing to try and prevent parsing errors. Should help with issue #183

pull/197/head
Zach Wise 12 years ago
parent
commit
32440e2333
  1. 35
      compiled/js/storyjs-embed-cdn.js
  2. 35
      compiled/js/storyjs-embed.js
  3. 8
      compiled/js/timeline-min.js
  4. 117
      compiled/js/timeline.js

35
compiled/js/storyjs-embed-cdn.js

@ -584,7 +584,7 @@ function createStoryJS(c, src) {
================================================== */ ================================================== */
var storyjs_embedjs, t, te, x, var storyjs_embedjs, t, te, x,
isCDN = false, isCDN = false,
js_version = "1.71", js_version = "2.01",
jquery_version_required = "1.7.1", jquery_version_required = "1.7.1",
jquery_version = "", jquery_version = "",
ready = { ready = {
@ -621,7 +621,7 @@ function createStoryJS(c, src) {
embed_id: 'timeline-embed', embed_id: 'timeline-embed',
embed: true, embed: true,
width: '100%', width: '100%',
height: '650', height: '100%',
source: 'https://docs.google.com/spreadsheet/pub?key=0Agl_Dv6iEbDadFYzRjJPUGktY0NkWXFUWkVIZDNGRHc&output=html', source: 'https://docs.google.com/spreadsheet/pub?key=0Agl_Dv6iEbDadFYzRjJPUGktY0NkWXFUWkVIZDNGRHc&output=html',
lang: 'en', lang: 'en',
font: 'default', font: 'default',
@ -678,6 +678,12 @@ function createStoryJS(c, src) {
/* DETERMINE TYPE /* DETERMINE TYPE
================================================== */ ================================================== */
// Check for old installs still using the old method of language
if (storyjs_e_config.js.match("locale")) {
storyjs_e_config.lang = storyjs_e_config.js.split("locale/")[1].replace(".js", "");
storyjs_e_config.js = path.js + 'timeline-min.js?' + js_version;
}
if (storyjs_e_config.js.match("/")) { if (storyjs_e_config.js.match("/")) {
} else { } else {
@ -686,12 +692,6 @@ function createStoryJS(c, src) {
storyjs_e_config.id = "storyjs-" + storyjs_e_config.type; storyjs_e_config.id = "storyjs-" + storyjs_e_config.type;
} }
// Check for old installs still using the old method of language
if (storyjs_e_config.js.match("locale")) {
storyjs_e_config.lang = storyjs_e_config.js.split("locale/")[1].replace(".js", "");
storyjs_e_config.js = path.js + 'timeline-min.js?' + js_version;
}
/* PREPARE LANGUAGE /* PREPARE LANGUAGE
================================================== */ ================================================== */
if (storyjs_e_config.lang.match("/")) { if (storyjs_e_config.lang.match("/")) {
@ -699,28 +699,15 @@ function createStoryJS(c, src) {
} else { } else {
path.locale = path.locale + storyjs_e_config.lang + ".js?" + js_version; path.locale = path.locale + storyjs_e_config.lang + ".js?" + js_version;
} }
// Check for old installs still using the old method of language
if (storyjs_e_config.js.match("locale")) {
storyjs_e_config.lang = storyjs_e_config.js.split("locale/")[1].replace(".js", "");
}
/* PREPARE /* PREPARE
================================================== */ ================================================== */
createEmbedDiv(); createEmbedDiv();
load_css();
/* Load CSS /* Load CSS
================================================== */ ================================================== */
function load_css() { LoadLib.css(storyjs_e_config.css, onloaded_css);
LoadLib.css(storyjs_e_config.css, onloaded_css);
}
/* Load CSS
================================================== */
function load_js() {
LoadLib.js(storyjs_e_config.js, onloaded_js);
}
/* Load FONT /* Load FONT
================================================== */ ================================================== */
@ -789,7 +776,7 @@ function createStoryJS(c, src) {
function onloaded_js() { function onloaded_js() {
ready.js = true; ready.js = true;
if (storyjs_e_config.lang != "en") { if (storyjs_e_config.lang != "en") {
load_js(); LazyLoad.js(path.locale, onloaded_language);
} else { } else {
ready.language = true; ready.language = true;
} }

35
compiled/js/storyjs-embed.js

@ -505,7 +505,7 @@ function createStoryJS(c, src) {
================================================== */ ================================================== */
var storyjs_embedjs, t, te, x, var storyjs_embedjs, t, te, x,
isCDN = false, isCDN = false,
js_version = "1.71", js_version = "2.01",
jquery_version_required = "1.7.1", jquery_version_required = "1.7.1",
jquery_version = "", jquery_version = "",
ready = { ready = {
@ -542,7 +542,7 @@ function createStoryJS(c, src) {
embed_id: 'timeline-embed', embed_id: 'timeline-embed',
embed: true, embed: true,
width: '100%', width: '100%',
height: '650', height: '100%',
source: 'https://docs.google.com/spreadsheet/pub?key=0Agl_Dv6iEbDadFYzRjJPUGktY0NkWXFUWkVIZDNGRHc&output=html', source: 'https://docs.google.com/spreadsheet/pub?key=0Agl_Dv6iEbDadFYzRjJPUGktY0NkWXFUWkVIZDNGRHc&output=html',
lang: 'en', lang: 'en',
font: 'default', font: 'default',
@ -599,6 +599,12 @@ function createStoryJS(c, src) {
/* DETERMINE TYPE /* DETERMINE TYPE
================================================== */ ================================================== */
// Check for old installs still using the old method of language
if (storyjs_e_config.js.match("locale")) {
storyjs_e_config.lang = storyjs_e_config.js.split("locale/")[1].replace(".js", "");
storyjs_e_config.js = path.js + 'timeline-min.js?' + js_version;
}
if (storyjs_e_config.js.match("/")) { if (storyjs_e_config.js.match("/")) {
} else { } else {
@ -607,12 +613,6 @@ function createStoryJS(c, src) {
storyjs_e_config.id = "storyjs-" + storyjs_e_config.type; storyjs_e_config.id = "storyjs-" + storyjs_e_config.type;
} }
// Check for old installs still using the old method of language
if (storyjs_e_config.js.match("locale")) {
storyjs_e_config.lang = storyjs_e_config.js.split("locale/")[1].replace(".js", "");
storyjs_e_config.js = path.js + 'timeline-min.js?' + js_version;
}
/* PREPARE LANGUAGE /* PREPARE LANGUAGE
================================================== */ ================================================== */
if (storyjs_e_config.lang.match("/")) { if (storyjs_e_config.lang.match("/")) {
@ -620,28 +620,15 @@ function createStoryJS(c, src) {
} else { } else {
path.locale = path.locale + storyjs_e_config.lang + ".js?" + js_version; path.locale = path.locale + storyjs_e_config.lang + ".js?" + js_version;
} }
// Check for old installs still using the old method of language
if (storyjs_e_config.js.match("locale")) {
storyjs_e_config.lang = storyjs_e_config.js.split("locale/")[1].replace(".js", "");
}
/* PREPARE /* PREPARE
================================================== */ ================================================== */
createEmbedDiv(); createEmbedDiv();
load_css();
/* Load CSS /* Load CSS
================================================== */ ================================================== */
function load_css() { LoadLib.css(storyjs_e_config.css, onloaded_css);
LoadLib.css(storyjs_e_config.css, onloaded_css);
}
/* Load CSS
================================================== */
function load_js() {
LoadLib.js(storyjs_e_config.js, onloaded_js);
}
/* Load FONT /* Load FONT
================================================== */ ================================================== */
@ -710,7 +697,7 @@ function createStoryJS(c, src) {
function onloaded_js() { function onloaded_js() {
ready.js = true; ready.js = true;
if (storyjs_e_config.lang != "en") { if (storyjs_e_config.lang != "en") {
load_js(); LazyLoad.js(path.locale, onloaded_language);
} else { } else {
ready.language = true; ready.language = true;
} }

8
compiled/js/timeline-min.js vendored

File diff suppressed because one or more lines are too long

117
compiled/js/timeline.js

@ -2915,7 +2915,7 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
if (VMM.master_config.googlemaps.api_loaded) { if (VMM.master_config.googlemaps.api_loaded) {
} else { } else {
VMM.LoadLib.js(map_url, function() { LoadLib.js(map_url, function() {
trace("Google Maps API Library Loaded"); trace("Google Maps API Library Loaded");
}); });
} }
@ -3573,7 +3573,7 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
if (!VMM.master_config.youtube.active) { if (!VMM.master_config.youtube.active) {
if (!VMM.master_config.youtube.api_loaded) { if (!VMM.master_config.youtube.api_loaded) {
VMM.LoadLib.js('http://www.youtube.com/player_api', function() { LoadLib.js('http://www.youtube.com/player_api', function() {
trace("YouTube API Library Loaded"); trace("YouTube API Library Loaded");
}); });
} }
@ -3867,6 +3867,9 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaElement == 'undefined') {
} }
// IMAGE // IMAGE
if (m.type == "image") { if (m.type == "image") {
if (m.id.match("https://")) {
m.id = m.id.replace("https://","http://");
}
mediaElem = "<div class='media-image media-shadow'><img src='" + m.id + "' class='media-image'></div>"; mediaElem = "<div class='media-image media-shadow'><img src='" + m.id + "' class='media-image'></div>";
// FLICKR // FLICKR
} else if (m.type == "flickr") { } else if (m.type == "flickr") {
@ -6176,7 +6179,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
$navigation, $navigation,
slider, slider,
timenav, timenav,
version = "1.70", version = "2.01",
timeline_id = "#timelinejs", timeline_id = "#timelinejs",
events = {}, events = {},
data = {}, data = {},
@ -7044,7 +7047,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
scroll_to = config.nav.constraint.right; scroll_to = config.nav.constraint.right;
} }
VMM.Lib.stop($timenav); //VMM.Lib.stop($timenav);
//VMM.Lib.animate($timenav, config.duration/2, "linear", {"left": scroll_to}); //VMM.Lib.animate($timenav, config.duration/2, "linear", {"left": scroll_to});
VMM.Lib.css($timenav, "left", scroll_to); VMM.Lib.css($timenav, "left", scroll_to);
} }
@ -7073,6 +7076,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
}; };
var goToMarker = function(n, ease, duration, fast, firstrun) { var goToMarker = function(n, ease, duration, fast, firstrun) {
trace("GO TO MARKER");
var _ease = config.ease, var _ease = config.ease,
_duration = config.duration, _duration = config.duration,
is_last = false, is_last = false,
@ -7080,7 +7084,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
current_marker = n; current_marker = n;
timenav_pos.left = (config.width/2) - VMM.Lib.position(markers[current_marker].marker).left; timenav_pos.left = (config.width/2) - markers[current_marker].pos_left
timenav_pos.visible.left = Math.abs(timenav_pos.left) - 100; timenav_pos.visible.left = Math.abs(timenav_pos.left) - 100;
timenav_pos.visible.right = Math.abs(timenav_pos.left) + config.width + 100; timenav_pos.visible.right = Math.abs(timenav_pos.left) + config.width + 100;
@ -7485,6 +7489,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
pos.begin = Math.round(pos.begin + pos_offset); pos.begin = Math.round(pos.begin + pos_offset);
pos.end = Math.round(pos.end + pos_offset); pos.end = Math.round(pos.end + pos_offset);
line = Math.round(pos.end - pos.begin); line = Math.round(pos.end - pos.begin);
marker.pos_left = pos.begin;
if (current_marker == i) { if (current_marker == i) {
timenav_pos.left = (config.width/2) - pos; timenav_pos.left = (config.width/2) - pos;
@ -7592,8 +7597,13 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
// ANIMATE THE TIMELINE TO ADJUST TO CHANGES // ANIMATE THE TIMELINE TO ADJUST TO CHANGES
VMM.Lib.stop($timenav); if (is_animated) {
VMM.Lib.animate($timenav, config.duration/2, config.ease, {"left": (config.width/2) - (cur_mark)}); VMM.Lib.stop($timenav);
VMM.Lib.animate($timenav, config.duration/2, config.ease, {"left": (config.width/2) - (cur_mark)});
} else {
}
//VMM.Lib.delay_animate(config.duration, $timenav, config.duration/2, config.ease, {"left": (config.width/2) - (cur_mark)}); //VMM.Lib.delay_animate(config.duration, $timenav, config.duration/2, config.ease, {"left": (config.width/2) - (cur_mark)});
@ -8011,7 +8021,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
buildMarkers(); buildMarkers();
buildEras(); buildEras();
calculateMultiplier(); calculateMultiplier();
positionMarkers(); positionMarkers(false);
positionEras(); positionEras();
positionInterval($timeinterval, interval_array, false, true); positionInterval($timeinterval, interval_array, false, true);
@ -8052,10 +8062,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
VMM.bindEvent(layout, onMouseScroll, 'mousewheel'); VMM.bindEvent(layout, onMouseScroll, 'mousewheel');
} }
VMM.fireEvent(layout, "LOADED");
_active = true;
reSize(true);
// USER CONFIGURABLE ADJUSTMENT TO DEFAULT ZOOM // USER CONFIGURABLE ADJUSTMENT TO DEFAULT ZOOM
if (config.nav.zoom.adjust != 0) { if (config.nav.zoom.adjust != 0) {
@ -8070,6 +8077,12 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
} }
//VMM.fireEvent(layout, "LOADED");
_active = true;
reSize(true);
VMM.fireEvent(layout, "LOADED");
}; };
var buildInterval = function() { var buildInterval = function() {
@ -8248,7 +8261,8 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
type: "marker", type: "marker",
full: true, full: true,
relative_pos: _marker_relative_pos, relative_pos: _marker_relative_pos,
tag: data[i].tag tag: data[i].tag,
pos_left: 0
}; };
@ -8535,8 +8549,17 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
}, },
buildData: function(d) { buildData: function(d) {
var data_obj = VMM.Timeline.DataObj.data_template_obj;
VMM.fireEvent(global, VMM.Timeline.Config.events.messege, "Parsing Data"); VMM.fireEvent(global, VMM.Timeline.Config.events.messege, "Parsing Data");
var _data_obj = VMM.Timeline.DataObj.data_template_obj;
function getGVar(v) {
if (typeof v != 'undefined') {
return v.$t;
} else {
return "";
}
}
for(var i = 0; i < d.feed.entry.length; i++) { for(var i = 0; i < d.feed.entry.length; i++) {
var dd = d.feed.entry[i], var dd = d.feed.entry[i],
@ -8549,52 +8572,44 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
} }
if (dd_type.match("start") || dd_type.match("title") ) { if (dd_type.match("start") || dd_type.match("title") ) {
_data_obj.timeline.startDate = dd.gsx$startdate.$t; data_obj.timeline.startDate = getGVar(dd.gsx$startdate);
_data_obj.timeline.headline = dd.gsx$headline.$t; data_obj.timeline.headline = getGVar(dd.gsx$headline);
_data_obj.timeline.asset.media = dd.gsx$media.$t; data_obj.timeline.asset.media = getGVar(dd.gsx$media);
_data_obj.timeline.asset.caption = dd.gsx$mediacaption.$t; data_obj.timeline.asset.caption = getGVar(dd.gsx$mediacaption);
_data_obj.timeline.asset.credit = dd.gsx$mediacredit.$t; data_obj.timeline.asset.credit = getGVar(dd.gsx$mediacredit);
_data_obj.timeline.text = dd.gsx$text.$t; data_obj.timeline.text = getGVar(dd.gsx$text);
_data_obj.timeline.type = "google spreadsheet"; data_obj.timeline.type = "google spreadsheet";
} else if (dd_type.match("era")) { } else if (dd_type.match("era")) {
var _era = { var era = {
"startDate": dd.gsx$startdate.$t, startDate: getGVar(dd.gsx$startdate),
"endDate": dd.gsx$enddate.$t, endDate: getGVar(dd.gsx$enddate),
"headline": dd.gsx$headline.$t, headline: getGVar(dd.gsx$headline),
"text": dd.gsx$text.$t, text: getGVar(dd.gsx$text),
"tag": "" tag: getGVar(dd.gsx$tag)
};
if (typeof dd.gsx$tag != 'undefined') {
_era.tag = dd.gsx$tag.$t;
} }
_data_obj.timeline.era.push(_era); data_obj.timeline.era.push(era);
} else { } else {
var _date = { var date = {
"type": "google spreadsheet", type: "google spreadsheet",
"startDate": dd.gsx$startdate.$t, startDate: getGVar(dd.gsx$startdate),
"endDate": dd.gsx$enddate.$t, endDate: getGVar(dd.gsx$enddate),
"headline": dd.gsx$headline.$t, headline: getGVar(dd.gsx$headline),
"text": dd.gsx$text.$t, tag: getGVar(dd.gsx$tag),
"asset": { asset: {
"media": dd.gsx$media.$t, media: getGVar(dd.gsx$media),
"credit": dd.gsx$mediacredit.$t, credit: getGVar(dd.gsx$mediacredit),
"caption": dd.gsx$mediacaption.$t caption: getGVar(dd.gsx$mediacaption),
}, thumbnail: getGVar(dd.gsx$mediathumbnail)
"tag": "" }
}; };
if (typeof dd.gsx$tag != 'undefined') {
_date.tag = dd.gsx$tag.$t;
}
if (typeof dd.gsx$mediathumbnail != 'undefined') {
_date.asset.thumbnail = dd.gsx$mediathumbnail.$t;
}
_data_obj.timeline.date.push(_date); data_obj.timeline.date.push(date);
} }
}; };
VMM.fireEvent(global, VMM.Timeline.Config.events.data_ready, _data_obj); VMM.fireEvent(global, VMM.Timeline.Config.events.messege, "Finished Parsing Data");
VMM.fireEvent(global, VMM.Timeline.Config.events.data_ready, data_obj);
} }
}, },

Loading…
Cancel
Save