Browse Source

Updated date handling to allow precision dates including allowing first of the month to display

also closes issue #237
pull/300/merge
Zach Wise 13 years ago
parent
commit
90cb9d7928
  1. 26
      README.markdown
  2. 10
      compiled/js/timeline-min.js
  3. 333
      compiled/js/timeline.js
  4. 2
      source/js/Core
  5. 34
      source/js/VMM.Timeline.TimeNav.js
  6. 27
      source/js/VMM.Timeline.js

26
README.markdown

@ -1,3 +1,29 @@
**Table of Contents**
- [TimelineJS](#timelinejs)
- [Document history with TimelineJS](#document-history-with-timelinejs)
- [Add it to your site](#add-it-to-your-site)
- [Using Inline (easiest)](#using-inline-easiest)
- [Using a method (advanced)](#using-a-method-advanced)
- [Config Options](#config-options)
- [Language](#language)
- [Start at End](#start-at-end)
- [Start at Slide](#start-at-slide)
- [Start Zoom Adjust](#start-zoom-adjust)
- [Hash Bookmark](#hash-bookmark)
- [Debug](#debug)
- [Map Style Types](#map-style-types)
- [Font Options](#font-options)
- [Font Combination Preview:](#font-combination-preview)
- [File Formats](#file-formats)
- [JSON:](#json)
- [JSONP :](#jsonp-)
- [Google Docs:](#google-docs)
- [Storify:](#storify)
- [Media](#media)
- [Best practices](#best-practices)
- [License](#license)
# TimelineJS # TimelineJS
## Document history with TimelineJS ## Document history with TimelineJS

10
compiled/js/timeline-min.js vendored

File diff suppressed because one or more lines are too long

333
compiled/js/timeline.js

@ -1253,12 +1253,21 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
dateFormat.i18n.monthNames = lang.date.month_abbr.concat(lang.date.month); dateFormat.i18n.monthNames = lang.date.month_abbr.concat(lang.date.month);
}, },
parse: function(d) { parse: function(d, precision) {
"use strict"; "use strict";
var date, var date,
date_array, date_array,
time_array, time_array,
time_parse; time_parse,
p = {
year: false,
month: false,
day: false,
hour: false,
minute: false,
second: false,
millisecond: false
};
if (type.of(d) == "date") { if (type.of(d) == "date") {
date = d; date = d;
@ -1270,54 +1279,120 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
for(var i = 0; i < date_array.length; i++) { for(var i = 0; i < date_array.length; i++) {
date_array[i] = parseInt(date_array[i], 10); date_array[i] = parseInt(date_array[i], 10);
} }
if ( date_array[0] ) { date.setFullYear( date_array[0]); } if (date_array[0]) {
if ( date_array[1] > 1 ) { date.setMonth( date_array[1] - 1); } date.setFullYear(date_array[0]);
if ( date_array[2] > 1 ) { date.setDate( date_array[2]); } p.year = true;
if ( date_array[3] > 1 ) { date.setHours( date_array[3]); } }
if ( date_array[4] > 1 ) { date.setMinutes( date_array[4]); } if (date_array[1]) {
if ( date_array[5] > 1 ) { date.setSeconds( date_array[5]); } date.setMonth(date_array[1] - 1);
if ( date_array[6] > 1 ) { date.setMilliseconds( date_array[6]); } p.month = true;
}
if (date_array[2]) {
date.setDate(date_array[2]);
p.day = true;
}
if (date_array[3]) {
date.setHours(date_array[3]);
p.hour = true;
}
if (date_array[4]) {
date.setMinutes(date_array[4]);
p.minute = true;
}
if (date_array[5]) {
date.setSeconds(date_array[5]);
p.second = true;
}
if (date_array[6]) {
date.setMilliseconds(date_array[6]);
p.millisecond = true;
}
} else if (d.match("/")) { } else if (d.match("/")) {
if (d.match(" ")) { if (d.match(" ")) {
time_parse = d.split(" "); time_parse = d.split(" ");
if (d.match(":")) { if (d.match(":")) {
time_array = time_parse[1].split(":"); time_array = time_parse[1].split(":");
if ( time_array[0] >= 1 ) { date.setHours( time_array[0]); } if (time_array[0] >= 0 ) {
if ( time_array[1] >= 1 ) { date.setMinutes( time_array[1]); } date.setHours(time_array[0]);
if ( time_array[2] >= 1 ) { date.setSeconds( time_array[2]); } p.hour = true;
if ( time_array[3] >= 1 ) { date.setMilliseconds( time_array[3]); } }
if (time_array[1] >= 0) {
date.setMinutes(time_array[1]);
p.minute = true;
}
if (time_array[2] >= 0) {
date.setSeconds(time_array[2]);
p.second = true;
}
if (time_array[3] >= 0) {
date.setMilliseconds(time_array[3]);
p.millisecond = true;
}
} }
date_array = time_parse[0].split("/"); date_array = time_parse[0].split("/");
} else { } else {
date_array = d.split("/"); date_array = d.split("/");
} }
if ( date_array[2] ) { date.setFullYear( date_array[2]); } if (date_array[2]) {
if ( date_array[0] > 1 ) { date.setMonth( date_array[0] - 1); } date.setFullYear(date_array[2]);
if ( date_array[1] > 1 ) { date.setDate( date_array[1]); } p.year = true;
}
if (date_array[0] >= 0) {
date.setMonth(date_array[0] - 1);
p.month = true;
}
if (date_array[1] >= 0) {
if (date_array[1].length > 2) {
date.setFullYear(date_array[1]);
p.year = true;
} else {
date.setDate(date_array[1]);
p.day = true;
}
}
} else if (d.match("now")) { } else if (d.match("now")) {
var now = new Date(); var now = new Date();
date.setFullYear(now.getFullYear()); date.setFullYear(now.getFullYear());
p.year = true;
date.setMonth(now.getMonth()); date.setMonth(now.getMonth());
p.month = true;
date.setDate(now.getDate()); date.setDate(now.getDate());
p.day = true;
if (d.match("hours")) { if (d.match("hours")) {
date.setHours(now.getHours()); date.setHours(now.getHours());
p.hour = true;
} }
if (d.match("minutes")) { if (d.match("minutes")) {
date.setHours(now.getHours()); date.setHours(now.getHours());
date.setMinutes(now.getMinutes()); date.setMinutes(now.getMinutes());
p.hour = true;
p.minute = true;
} }
if (d.match("seconds")) { if (d.match("seconds")) {
date.setHours(now.getHours()); date.setHours(now.getHours());
date.setMinutes(now.getMinutes()); date.setMinutes(now.getMinutes());
date.setSeconds(now.getSeconds()); date.setSeconds(now.getSeconds());
p.hour = true;
p.minute = true;
p.second = true;
} }
if (d.match("milliseconds")) { if (d.match("milliseconds")) {
date.setHours(now.getHours()); date.setHours(now.getHours());
date.setMinutes(now.getMinutes()); date.setMinutes(now.getMinutes());
date.setSeconds(now.getSeconds()); date.setSeconds(now.getSeconds());
date.setMilliseconds(now.getMilliseconds()); date.setMilliseconds(now.getMilliseconds());
p.hour = true;
p.minute = true;
p.second = true;
p.millisecond = true;
} }
} else if (d.length <= 5) { } else if (d.length <= 5) {
p.year = true;
date.setFullYear(parseInt(d, 10)); date.setFullYear(parseInt(d, 10));
date.setMonth(0); date.setMonth(0);
date.setDate(1); date.setDate(1);
@ -1331,20 +1406,48 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
time_parse = d.split("T"); time_parse = d.split("T");
if (d.match(":")) { if (d.match(":")) {
time_array = _time_parse[1].split(":"); time_array = _time_parse[1].split(":");
if ( time_array[0] >= 1 ) { date.setHours( time_array[0]); } if (time_array[0] >= 1) {
if ( time_array[1] >= 1 ) { date.setMinutes( time_array[1]); } date.setHours(time_array[0]);
if ( time_array[2] >= 1 ) { date.setSeconds( time_array[2]); } p.hour = true;
if ( time_array[3] >= 1 ) { date.setMilliseconds( time_array[3]); } }
if (time_array[1] >= 1) {
date.setMinutes(time_array[1]);
p.minute = true;
}
if (time_array[2] >= 1) {
date.setSeconds(time_array[2]);
p.second = true;
}
if (time_array[3] >= 1) {
date.setMilliseconds(time_array[3]);
p.millisecond = true;
}
} }
_d_array = time_parse[0].split("-"); _d_array = time_parse[0].split("-");
if ( date_array[0] ) { date.setFullYear( date_array[0]); } if (date_array[0]) {
if ( date_array[1] > 1 ) { date.setMonth( date_array[1] - 1); } date.setFullYear(date_array[0]);
if ( date_array[2] > 1 ) { date.setDate( date_array[2]); } p.year = true;
}
if (date_array[1] >= 0) {
date.setMonth(date_array[1] - 1);
p.month = true;
}
if (date_array[2] >= 0) {
date.setDate(date_array[2]);
p.day = true;
}
} else { } else {
date = new Date(Date.parse(d)); date = new Date(Date.parse(d));
} }
} else { } else {
p.year = true;
p.month = true;
p.day = true;
p.hour = true;
p.minute = true;
p.second = true;
p.millisecond = true;
date = new Date( date = new Date(
parseInt(d.slice(0,4), 10), parseInt(d.slice(0,4), 10),
parseInt(d.slice(4,6), 10) - 1, parseInt(d.slice(4,6), 10) - 1,
@ -1355,10 +1458,20 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
} }
} }
return date;
if (precision != null && precision != "") {
return {
date: date,
precision: p
};
} else {
return date;
}
}, },
prettyDate: function(d, is_abbr, d2) {
prettyDate: function(d, is_abbr, p, d2) {
var _date, var _date,
_date2, _date2,
format, format,
@ -1368,46 +1481,87 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
bc_number, bc_number,
bc_string; bc_string;
if (d2 != null) { if (d2 != null && d2 != "" && typeof d2 != 'undefined') {
is_pair = true; is_pair = true;
trace("D2 " + d2);
} }
if (type.of(d) == "date") { if (type.of(d) == "date") {
if (d.getMonth() === 0 && d.getDate() == 1 && d.getHours() === 0 && d.getMinutes() === 0 ) {
// YEAR ONLY if (type.of(p) == "object") {
format = VMM.Date.dateformats.year; if (p.millisecond || p.second || p.minute) {
} else if (d.getDate() <= 1 && d.getHours() === 0 && d.getMinutes() === 0) { // YEAR MONTH DAY HOUR MINUTE
// YEAR MONTH if (is_abbr){
if (is_abbr) { format = VMM.Date.dateformats.time_no_seconds_short;
format = VMM.Date.dateformats.month_short; } else {
} else { format = VMM.Date.dateformats.time_no_seconds_small_date;
format = VMM.Date.dateformats.month; }
} } else if (p.hour) {
} else if (d.getHours() === 0 && d.getMinutes() === 0) { // YEAR MONTH DAY HOUR
// YEAR MONTH DAY if (is_abbr) {
if (is_abbr) { format = VMM.Date.dateformats.time_no_seconds_short;
format = VMM.Date.dateformats.full_short; } else {
} else { format = VMM.Date.dateformats.time_no_seconds_small_date;
format = VMM.Date.dateformats.full; }
} } else if (p.day) {
} else if (d.getMinutes() === 0) { // YEAR MONTH DAY
// YEAR MONTH DAY HOUR if (is_abbr) {
if (is_abbr) { format = VMM.Date.dateformats.full_short;
format = VMM.Date.dateformats.time_no_seconds_short; } else {
format = VMM.Date.dateformats.full;
}
} else if (p.month) {
// YEAR MONTH
if (is_abbr) {
format = VMM.Date.dateformats.month_short;
} else {
format = VMM.Date.dateformats.month;
}
} else if (p.year) {
format = VMM.Date.dateformats.year;
} else { } else {
format = VMM.Date.dateformats.time_no_seconds_small_date; format = VMM.Date.dateformats.year;
} }
} else { } else {
// YEAR MONTH DAY HOUR MINUTE
if (is_abbr){ if (d.getMonth() === 0 && d.getDate() == 1 && d.getHours() === 0 && d.getMinutes() === 0 ) {
format = VMM.Date.dateformats.time_no_seconds_short; // YEAR ONLY
format = VMM.Date.dateformats.year;
} else if (d.getDate() <= 1 && d.getHours() === 0 && d.getMinutes() === 0) {
// YEAR MONTH
if (is_abbr) {
format = VMM.Date.dateformats.month_short;
} else {
format = VMM.Date.dateformats.month;
}
} else if (d.getHours() === 0 && d.getMinutes() === 0) {
// YEAR MONTH DAY
if (is_abbr) {
format = VMM.Date.dateformats.full_short;
} else {
format = VMM.Date.dateformats.full;
}
} else if (d.getMinutes() === 0) {
// YEAR MONTH DAY HOUR
if (is_abbr) {
format = VMM.Date.dateformats.time_no_seconds_short;
} else {
format = VMM.Date.dateformats.time_no_seconds_small_date;
}
} else { } else {
format = VMM.Date.dateformats.full_long; // YEAR MONTH DAY HOUR MINUTE
if (is_abbr){
format = VMM.Date.dateformats.time_no_seconds_short;
} else {
format = VMM.Date.dateformats.full_long;
}
} }
} }
_date = dateFormat(d, format, false); _date = dateFormat(d, format, false);
//_date = "Jan"
bc_check = _date.split(" "); bc_check = _date.split(" ");
// BC TIME SUPPORT // BC TIME SUPPORT
@ -1423,7 +1577,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
if (is_pair) { if (is_pair) {
_date2 = dateFormat(d2, format); _date2 = dateFormat(d2, format, false);
bc_check = _date2.split(" "); bc_check = _date2.split(" ");
// BC TIME SUPPORT // BC TIME SUPPORT
for(var j = 0; j < bc_check.length; j++) { for(var j = 0; j < bc_check.length; j++) {
@ -5306,7 +5460,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
/* POSITION SLIDES /* POSITION SLIDES
================================================== */ ================================================== */
var positionSlides = function() { function positionSlides() {
var pos = 0, var pos = 0,
i = 0; i = 0;
@ -5318,7 +5472,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
/* OPACITY SLIDES /* OPACITY SLIDES
================================================== */ ================================================== */
var opacitySlides = function(n) { function opacitySlides(n) {
var _ease = "linear", var _ease = "linear",
i = 0; i = 0;
@ -5377,7 +5531,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
VMM.attachElement(navigation.prevDate, _title); VMM.attachElement(navigation.prevDate, _title);
VMM.attachElement(navigation.prevTitle, ""); VMM.attachElement(navigation.prevTitle, "");
} else { } else {
VMM.attachElement(navigation.prevDate, VMM.Date.prettyDate(data[current_slide - 1].startdate)); VMM.attachElement(navigation.prevDate, VMM.Date.prettyDate(data[current_slide - 1].startdate, false, data[current_slide - 1].precisiondate));
VMM.attachElement(navigation.prevTitle, _title); VMM.attachElement(navigation.prevTitle, _title);
} }
} else { } else {
@ -5395,7 +5549,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
VMM.attachElement(navigation.nextDate, _title); VMM.attachElement(navigation.nextDate, _title);
VMM.attachElement(navigation.nextTitle, ""); VMM.attachElement(navigation.nextTitle, "");
} else { } else {
VMM.attachElement(navigation.nextDate, VMM.Date.prettyDate(data[current_slide + 1].startdate) ); VMM.attachElement(navigation.nextDate, VMM.Date.prettyDate(data[current_slide + 1].startdate, false, data[current_slide + 1].precisiondate) );
VMM.attachElement(navigation.nextTitle, _title); VMM.attachElement(navigation.nextTitle, _title);
} }
} else { } else {
@ -5730,8 +5884,8 @@ if (typeof VMM.Slider != 'undefined') {
if (data.startdate != null && data.startdate != "") { if (data.startdate != null && data.startdate != "") {
if (type.of(data.startdate) == "date") { if (type.of(data.startdate) == "date") {
if (data.type != "start") { if (data.type != "start") {
var st = VMM.Date.prettyDate(data.startdate); var st = VMM.Date.prettyDate(data.startdate, false, data.precisiondate);
var en = VMM.Date.prettyDate(data.enddate); var en = VMM.Date.prettyDate(data.enddate, false, data.precisiondate);
var tag = ""; var tag = "";
/* TAG / CATEGORY /* TAG / CATEGORY
================================================== */ ================================================== */
@ -7199,25 +7353,19 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
if (data.date[i].startDate != null && data.date[i].startDate != "") { if (data.date[i].startDate != null && data.date[i].startDate != "") {
var _date = {}; var _date = {},
do_start = VMM.Date.parse(data.date[i].startDate, true),
do_end;
// START DATE _date.startdate = do_start.date;
if (data.date[i].type == "tweets") { _date.precisiondate = do_start.precision;
_date.startdate = VMM.ExternalAPI.twitter.parseTwitterDate(data.date[i].startDate);
} else {
_date.startdate = VMM.Date.parse(data.date[i].startDate);
}
if (!isNaN(_date.startdate)) { if (!isNaN(_date.startdate)) {
// END DATE // END DATE
if (data.date[i].endDate != null && data.date[i].endDate != "") { if (data.date[i].endDate != null && data.date[i].endDate != "") {
if (data.date[i].type == "tweets") { _date.enddate = VMM.Date.parse(data.date[i].endDate);
_date.enddate = VMM.ExternalAPI.twitter.parseTwitterDate(data.date[i].endDate);
} else {
_date.enddate = VMM.Date.parse(data.date[i].endDate);
}
} else { } else {
_date.enddate = _date.startdate; _date.enddate = _date.startdate;
} }
@ -7233,7 +7381,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
_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;
_date.date = VMM.Date.prettyDate(_date.startdate); _date.date = VMM.Date.prettyDate(_date.startdate, false, _date.precisiondate);
_date.asset = data.date[i].asset; _date.asset = data.date[i].asset;
_date.fulldate = _date.startdate.getTime(); _date.fulldate = _date.startdate.getTime();
_date.text = data.date[i].text; _date.text = data.date[i].text;
@ -7262,12 +7410,14 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
if (data.headline != null && data.headline != "" && data.text != null && data.text != "") { if (data.headline != null && data.headline != "" && data.text != null && data.text != "") {
var startpage_date, var startpage_date,
do_start,
_date = {}, _date = {},
td_num = 0, td_num = 0,
td; td;
if (typeof data.startDate != 'undefined') { if (typeof data.startDate != 'undefined') {
startpage_date = VMM.Date.parse(data.startDate); do_start = VMM.Date.parse(data.startDate, true);
startpage_date = do_start.date;
} else { } else {
startpage_date = false; startpage_date = false;
} }
@ -7300,11 +7450,12 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
_date.uniqueid = VMM.Util.unique_ID(7); _date.uniqueid = VMM.Util.unique_ID(7);
_date.enddate = _date.startdate; _date.enddate = _date.startdate;
_date.precisiondate = do_start.precision;
_date.title = data.headline; _date.title = data.headline;
_date.headline = data.headline; _date.headline = data.headline;
_date.text = data.text; _date.text = data.text;
_date.type = "start"; _date.type = "start";
_date.date = VMM.Date.prettyDate(data.startDate); _date.date = VMM.Date.prettyDate(data.startDate, false, _date.precisiondate);
_date.asset = data.asset; _date.asset = data.asset;
_date.slug = false; _date.slug = false;
_date.needs_slug = false; _date.needs_slug = false;
@ -7634,7 +7785,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
VMM.Lib.css($timenav, "left", scroll_to); VMM.Lib.css($timenav, "left", scroll_to);
} }
var refreshTimeline = function() { function refreshTimeline() {
trace("config.nav.multiplier " + config.nav.multiplier.current); trace("config.nav.multiplier " + config.nav.multiplier.current);
positionMarkers(true); positionMarkers(true);
positionEras(true); positionEras(true);
@ -7657,7 +7808,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
VMM.Lib.toggleClass(e.data.elem, "zFront"); VMM.Lib.toggleClass(e.data.elem, "zFront");
}; };
var goToMarker = function(n, ease, duration, fast, firstrun) { function goToMarker(n, ease, duration, fast, firstrun) {
trace("GO TO MARKER"); trace("GO TO MARKER");
var _ease = config.ease, var _ease = config.ease,
_duration = config.duration, _duration = config.duration,
@ -7705,7 +7856,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* CALCULATIONS /* CALCULATIONS
================================================== */ ================================================== */
var averageMarkerPositionDistance = function() { function averageMarkerPositionDistance() {
var last_pos = 0, var last_pos = 0,
pos = 0, pos = 0,
pos_dif = 0, pos_dif = 0,
@ -7726,7 +7877,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return VMM.Util.average(mp_diff).mean; return VMM.Util.average(mp_diff).mean;
} }
var averageDateDistance = function() { function averageDateDistance() {
var last_dd = 0, var last_dd = 0,
dd = 0, dd = 0,
_dd = "", _dd = "",
@ -7750,7 +7901,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return VMM.Util.average(date_diffs); return VMM.Util.average(date_diffs);
} }
var calculateMultiplier = function() { function calculateMultiplier() {
var temp_multiplier = config.nav.multiplier.current, var temp_multiplier = config.nav.multiplier.current,
i = 0; i = 0;
@ -7764,7 +7915,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
var calculateInterval = function() { function calculateInterval() {
// NEED TO REWRITE ALL OF THIS // NEED TO REWRITE ALL OF THIS
var _first = getDateFractions(data[0].startdate), var _first = getDateFractions(data[0].startdate),
_last = getDateFractions(data[data.length - 1].enddate); _last = getDateFractions(data[data.length - 1].enddate);
@ -7897,7 +8048,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
interval_calc.second.minor = 10; interval_calc.second.minor = 10;
} }
var getDateFractions = function(the_date, is_utc) { function getDateFractions(the_date, is_utc) {
var _time = {}; var _time = {};
_time.days = the_date / dateFractionBrowser.day; _time.days = the_date / dateFractionBrowser.day;
@ -7936,7 +8087,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
Positions elements on the timeline based on date Positions elements on the timeline based on date
relative to the calculated interval relative to the calculated interval
================================================== */ ================================================== */
var positionRelative = function(_interval, first, last) { function positionRelative(_interval, first, last) {
var _first, var _first,
_last, _last,
_type = _interval.type, _type = _interval.type,
@ -8023,14 +8174,14 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return timerelative return timerelative
} }
var positionOnTimeline = function(the_interval, timerelative) { function positionOnTimeline(the_interval, timerelative) {
return { return {
begin: (timerelative.start - interval.base) * (config.nav.interval_width / config.nav.multiplier.current), begin: (timerelative.start - interval.base) * (config.nav.interval_width / config.nav.multiplier.current),
end: (timerelative.end - interval.base) * (config.nav.interval_width / config.nav.multiplier.current) end: (timerelative.end - interval.base) * (config.nav.interval_width / config.nav.multiplier.current)
}; };
} }
var positionMarkers = function(is_animated) { function positionMarkers(is_animated) {
var row = 2, var row = 2,
previous_pos = 0, previous_pos = 0,
@ -8191,7 +8342,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
var positionEras = function(is_animated) { function positionEras(is_animated) {
var i = 0, var i = 0,
p = 0; p = 0;
@ -8238,7 +8389,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
} }
var positionInterval = function(the_main_element, the_intervals, is_animated, is_minor) { function positionInterval(the_main_element, the_intervals, is_animated, is_minor) {
var last_position = 0, var last_position = 0,
last_position_major = 0, last_position_major = 0,
@ -8373,7 +8524,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* Interval Elements /* Interval Elements
================================================== */ ================================================== */
var createIntervalElements = function(_interval, _array, _element_parent) { function createIntervalElements(_interval, _array, _element_parent) {
var inc_time = 0, var inc_time = 0,
_first_run = true, _first_run = true,
@ -8579,7 +8730,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* BUILD /* BUILD
================================================== */ ================================================== */
var build = function() { function build() {
var i = 0, var i = 0,
j = 0; j = 0;
@ -8674,7 +8825,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
}; };
var buildInterval = function() { function buildInterval() {
var i = 0, var i = 0,
j = 0; j = 0;
// CALCULATE INTERVAL // CALCULATE INTERVAL
@ -8763,7 +8914,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
} }
var buildMarkers = function() { function buildMarkers() {
var row = 2, var row = 2,
lpos = 0, lpos = 0,
@ -8908,7 +9059,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
var buildEras = function() { function buildEras() {
var number_of_colors = 6, var number_of_colors = 6,
current_color = 0, current_color = 0,
j = 0; j = 0;

2
source/js/Core

@ -1 +1 @@
Subproject commit 70146112d255ca80bb3909491214b53880e69444 Subproject commit bebc6a6daaeb3c01e153bab7f8a4b7070a13dbfa

34
source/js/VMM.Timeline.TimeNav.js

@ -294,7 +294,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
VMM.Lib.css($timenav, "left", scroll_to); VMM.Lib.css($timenav, "left", scroll_to);
} }
var refreshTimeline = function() { function refreshTimeline() {
trace("config.nav.multiplier " + config.nav.multiplier.current); trace("config.nav.multiplier " + config.nav.multiplier.current);
positionMarkers(true); positionMarkers(true);
positionEras(true); positionEras(true);
@ -317,7 +317,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
VMM.Lib.toggleClass(e.data.elem, "zFront"); VMM.Lib.toggleClass(e.data.elem, "zFront");
}; };
var goToMarker = function(n, ease, duration, fast, firstrun) { function goToMarker(n, ease, duration, fast, firstrun) {
trace("GO TO MARKER"); trace("GO TO MARKER");
var _ease = config.ease, var _ease = config.ease,
_duration = config.duration, _duration = config.duration,
@ -365,7 +365,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* CALCULATIONS /* CALCULATIONS
================================================== */ ================================================== */
var averageMarkerPositionDistance = function() { function averageMarkerPositionDistance() {
var last_pos = 0, var last_pos = 0,
pos = 0, pos = 0,
pos_dif = 0, pos_dif = 0,
@ -386,7 +386,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return VMM.Util.average(mp_diff).mean; return VMM.Util.average(mp_diff).mean;
} }
var averageDateDistance = function() { function averageDateDistance() {
var last_dd = 0, var last_dd = 0,
dd = 0, dd = 0,
_dd = "", _dd = "",
@ -410,7 +410,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return VMM.Util.average(date_diffs); return VMM.Util.average(date_diffs);
} }
var calculateMultiplier = function() { function calculateMultiplier() {
var temp_multiplier = config.nav.multiplier.current, var temp_multiplier = config.nav.multiplier.current,
i = 0; i = 0;
@ -424,7 +424,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
var calculateInterval = function() { function calculateInterval() {
// NEED TO REWRITE ALL OF THIS // NEED TO REWRITE ALL OF THIS
var _first = getDateFractions(data[0].startdate), var _first = getDateFractions(data[0].startdate),
_last = getDateFractions(data[data.length - 1].enddate); _last = getDateFractions(data[data.length - 1].enddate);
@ -557,7 +557,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
interval_calc.second.minor = 10; interval_calc.second.minor = 10;
} }
var getDateFractions = function(the_date, is_utc) { function getDateFractions(the_date, is_utc) {
var _time = {}; var _time = {};
_time.days = the_date / dateFractionBrowser.day; _time.days = the_date / dateFractionBrowser.day;
@ -596,7 +596,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
Positions elements on the timeline based on date Positions elements on the timeline based on date
relative to the calculated interval relative to the calculated interval
================================================== */ ================================================== */
var positionRelative = function(_interval, first, last) { function positionRelative(_interval, first, last) {
var _first, var _first,
_last, _last,
_type = _interval.type, _type = _interval.type,
@ -683,14 +683,14 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return timerelative return timerelative
} }
var positionOnTimeline = function(the_interval, timerelative) { function positionOnTimeline(the_interval, timerelative) {
return { return {
begin: (timerelative.start - interval.base) * (config.nav.interval_width / config.nav.multiplier.current), begin: (timerelative.start - interval.base) * (config.nav.interval_width / config.nav.multiplier.current),
end: (timerelative.end - interval.base) * (config.nav.interval_width / config.nav.multiplier.current) end: (timerelative.end - interval.base) * (config.nav.interval_width / config.nav.multiplier.current)
}; };
} }
var positionMarkers = function(is_animated) { function positionMarkers(is_animated) {
var row = 2, var row = 2,
previous_pos = 0, previous_pos = 0,
@ -851,7 +851,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
var positionEras = function(is_animated) { function positionEras(is_animated) {
var i = 0, var i = 0,
p = 0; p = 0;
@ -898,7 +898,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
} }
var positionInterval = function(the_main_element, the_intervals, is_animated, is_minor) { function positionInterval(the_main_element, the_intervals, is_animated, is_minor) {
var last_position = 0, var last_position = 0,
last_position_major = 0, last_position_major = 0,
@ -1033,7 +1033,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* Interval Elements /* Interval Elements
================================================== */ ================================================== */
var createIntervalElements = function(_interval, _array, _element_parent) { function createIntervalElements(_interval, _array, _element_parent) {
var inc_time = 0, var inc_time = 0,
_first_run = true, _first_run = true,
@ -1239,7 +1239,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* BUILD /* BUILD
================================================== */ ================================================== */
var build = function() { function build() {
var i = 0, var i = 0,
j = 0; j = 0;
@ -1334,7 +1334,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
}; };
var buildInterval = function() { function buildInterval() {
var i = 0, var i = 0,
j = 0; j = 0;
// CALCULATE INTERVAL // CALCULATE INTERVAL
@ -1423,7 +1423,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
} }
var buildMarkers = function() { function buildMarkers() {
var row = 2, var row = 2,
lpos = 0, lpos = 0,
@ -1568,7 +1568,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
} }
var buildEras = function() { function buildEras() {
var number_of_colors = 6, var number_of_colors = 6,
current_color = 0, current_color = 0,
j = 0; j = 0;

27
source/js/VMM.Timeline.js

@ -596,25 +596,19 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
if (data.date[i].startDate != null && data.date[i].startDate != "") { if (data.date[i].startDate != null && data.date[i].startDate != "") {
var _date = {}; var _date = {},
do_start = VMM.Date.parse(data.date[i].startDate, true),
do_end;
// START DATE _date.startdate = do_start.date;
if (data.date[i].type == "tweets") { _date.precisiondate = do_start.precision;
_date.startdate = VMM.ExternalAPI.twitter.parseTwitterDate(data.date[i].startDate);
} else {
_date.startdate = VMM.Date.parse(data.date[i].startDate);
}
if (!isNaN(_date.startdate)) { if (!isNaN(_date.startdate)) {
// END DATE // END DATE
if (data.date[i].endDate != null && data.date[i].endDate != "") { if (data.date[i].endDate != null && data.date[i].endDate != "") {
if (data.date[i].type == "tweets") { _date.enddate = VMM.Date.parse(data.date[i].endDate);
_date.enddate = VMM.ExternalAPI.twitter.parseTwitterDate(data.date[i].endDate);
} else {
_date.enddate = VMM.Date.parse(data.date[i].endDate);
}
} else { } else {
_date.enddate = _date.startdate; _date.enddate = _date.startdate;
} }
@ -630,7 +624,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
_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;
_date.date = VMM.Date.prettyDate(_date.startdate); _date.date = VMM.Date.prettyDate(_date.startdate, false, _date.precisiondate);
_date.asset = data.date[i].asset; _date.asset = data.date[i].asset;
_date.fulldate = _date.startdate.getTime(); _date.fulldate = _date.startdate.getTime();
_date.text = data.date[i].text; _date.text = data.date[i].text;
@ -659,12 +653,14 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
if (data.headline != null && data.headline != "" && data.text != null && data.text != "") { if (data.headline != null && data.headline != "" && data.text != null && data.text != "") {
var startpage_date, var startpage_date,
do_start,
_date = {}, _date = {},
td_num = 0, td_num = 0,
td; td;
if (typeof data.startDate != 'undefined') { if (typeof data.startDate != 'undefined') {
startpage_date = VMM.Date.parse(data.startDate); do_start = VMM.Date.parse(data.startDate, true);
startpage_date = do_start.date;
} else { } else {
startpage_date = false; startpage_date = false;
} }
@ -697,11 +693,12 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
_date.uniqueid = VMM.Util.unique_ID(7); _date.uniqueid = VMM.Util.unique_ID(7);
_date.enddate = _date.startdate; _date.enddate = _date.startdate;
_date.precisiondate = do_start.precision;
_date.title = data.headline; _date.title = data.headline;
_date.headline = data.headline; _date.headline = data.headline;
_date.text = data.text; _date.text = data.text;
_date.type = "start"; _date.type = "start";
_date.date = VMM.Date.prettyDate(data.startDate); _date.date = VMM.Date.prettyDate(data.startDate, false, _date.precisiondate);
_date.asset = data.asset; _date.asset = data.asset;
_date.slug = false; _date.slug = false;
_date.needs_slug = false; _date.needs_slug = false;

Loading…
Cancel
Save