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 12 years ago
parent
commit
90cb9d7928
  1. 26
      README.markdown
  2. 10
      compiled/js/timeline-min.js
  3. 341
      compiled/js/timeline.js
  4. 2
      source/js/Core
  5. 34
      source/js/VMM.Timeline.TimeNav.js
  6. 31
      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
## Document history with TimelineJS

10
compiled/js/timeline-min.js vendored

File diff suppressed because one or more lines are too long

341
compiled/js/timeline.js

@ -1253,13 +1253,22 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
dateFormat.i18n.monthNames = lang.date.month_abbr.concat(lang.date.month);
},
parse: function(d) {
parse: function(d, precision) {
"use strict";
var date,
date_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") {
date = d;
} else {
@ -1270,54 +1279,120 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
for(var i = 0; i < date_array.length; i++) {
date_array[i] = parseInt(date_array[i], 10);
}
if ( date_array[0] ) { date.setFullYear( date_array[0]); }
if ( date_array[1] > 1 ) { date.setMonth( date_array[1] - 1); }
if ( date_array[2] > 1 ) { date.setDate( date_array[2]); }
if ( date_array[3] > 1 ) { date.setHours( date_array[3]); }
if ( date_array[4] > 1 ) { date.setMinutes( date_array[4]); }
if ( date_array[5] > 1 ) { date.setSeconds( date_array[5]); }
if ( date_array[6] > 1 ) { date.setMilliseconds( date_array[6]); }
if (date_array[0]) {
date.setFullYear(date_array[0]);
p.year = true;
}
if (date_array[1]) {
date.setMonth(date_array[1] - 1);
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("/")) {
if (d.match(" ")) {
time_parse = d.split(" ");
if (d.match(":")) {
time_array = time_parse[1].split(":");
if ( time_array[0] >= 1 ) { date.setHours( time_array[0]); }
if ( time_array[1] >= 1 ) { date.setMinutes( time_array[1]); }
if ( time_array[2] >= 1 ) { date.setSeconds( time_array[2]); }
if ( time_array[3] >= 1 ) { date.setMilliseconds( time_array[3]); }
if (time_array[0] >= 0 ) {
date.setHours(time_array[0]);
p.hour = true;
}
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("/");
} else {
date_array = d.split("/");
}
if ( date_array[2] ) { date.setFullYear( date_array[2]); }
if ( date_array[0] > 1 ) { date.setMonth( date_array[0] - 1); }
if ( date_array[1] > 1 ) { date.setDate( date_array[1]); }
if (date_array[2]) {
date.setFullYear(date_array[2]);
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")) {
var now = new Date();
var now = new Date();
date.setFullYear(now.getFullYear());
p.year = true;
date.setMonth(now.getMonth());
p.month = true;
date.setDate(now.getDate());
p.day = true;
if (d.match("hours")) {
date.setHours(now.getHours());
p.hour = true;
}
if (d.match("minutes")) {
date.setHours(now.getHours());
date.setMinutes(now.getMinutes());
p.hour = true;
p.minute = true;
}
if (d.match("seconds")) {
date.setHours(now.getHours());
date.setMinutes(now.getMinutes());
date.setSeconds(now.getSeconds());
p.hour = true;
p.minute = true;
p.second = true;
}
if (d.match("milliseconds")) {
date.setHours(now.getHours());
date.setMinutes(now.getMinutes());
date.setSeconds(now.getSeconds());
date.setMilliseconds(now.getMilliseconds());
p.hour = true;
p.minute = true;
p.second = true;
p.millisecond = true;
}
} else if (d.length <= 5) {
p.year = true;
date.setFullYear(parseInt(d, 10));
date.setMonth(0);
date.setDate(1);
@ -1331,20 +1406,48 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
time_parse = d.split("T");
if (d.match(":")) {
time_array = _time_parse[1].split(":");
if ( time_array[0] >= 1 ) { date.setHours( time_array[0]); }
if ( time_array[1] >= 1 ) { date.setMinutes( time_array[1]); }
if ( time_array[2] >= 1 ) { date.setSeconds( time_array[2]); }
if ( time_array[3] >= 1 ) { date.setMilliseconds( time_array[3]); }
if (time_array[0] >= 1) {
date.setHours(time_array[0]);
p.hour = true;
}
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("-");
if ( date_array[0] ) { date.setFullYear( date_array[0]); }
if ( date_array[1] > 1 ) { date.setMonth( date_array[1] - 1); }
if ( date_array[2] > 1 ) { date.setDate( date_array[2]); }
if (date_array[0]) {
date.setFullYear(date_array[0]);
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 {
date = new Date(Date.parse(d));
}
} 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(
parseInt(d.slice(0,4), 10),
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,
_date2,
format,
@ -1368,46 +1481,87 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
bc_number,
bc_string;
if (d2 != null) {
if (d2 != null && d2 != "" && typeof d2 != 'undefined') {
is_pair = true;
trace("D2 " + d2);
}
if (type.of(d) == "date") {
if (d.getMonth() === 0 && d.getDate() == 1 && d.getHours() === 0 && d.getMinutes() === 0 ) {
// 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;
if (type.of(p) == "object") {
if (p.millisecond || p.second || p.minute) {
// YEAR MONTH DAY HOUR MINUTE
if (is_abbr){
format = VMM.Date.dateformats.time_no_seconds_short;
} else {
format = VMM.Date.dateformats.time_no_seconds_small_date;
}
} else if (p.hour) {
// 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 if (p.day) {
// YEAR MONTH DAY
if (is_abbr) {
format = VMM.Date.dateformats.full_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 {
format = VMM.Date.dateformats.time_no_seconds_small_date;
format = VMM.Date.dateformats.year;
}
} else {
// YEAR MONTH DAY HOUR MINUTE
if (is_abbr){
format = VMM.Date.dateformats.time_no_seconds_short;
if (d.getMonth() === 0 && d.getDate() == 1 && d.getHours() === 0 && d.getMinutes() === 0 ) {
// 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 {
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 = "Jan"
bc_check = _date.split(" ");
// BC TIME SUPPORT
@ -1423,7 +1577,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') {
if (is_pair) {
_date2 = dateFormat(d2, format);
_date2 = dateFormat(d2, format, false);
bc_check = _date2.split(" ");
// BC TIME SUPPORT
for(var j = 0; j < bc_check.length; j++) {
@ -5306,7 +5460,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
/* POSITION SLIDES
================================================== */
var positionSlides = function() {
function positionSlides() {
var pos = 0,
i = 0;
@ -5318,7 +5472,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
/* OPACITY SLIDES
================================================== */
var opacitySlides = function(n) {
function opacitySlides(n) {
var _ease = "linear",
i = 0;
@ -5377,7 +5531,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
VMM.attachElement(navigation.prevDate, _title);
VMM.attachElement(navigation.prevTitle, "");
} 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);
}
} else {
@ -5395,7 +5549,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
VMM.attachElement(navigation.nextDate, _title);
VMM.attachElement(navigation.nextTitle, "");
} 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);
}
} else {
@ -5730,8 +5884,8 @@ if (typeof VMM.Slider != 'undefined') {
if (data.startdate != null && data.startdate != "") {
if (type.of(data.startdate) == "date") {
if (data.type != "start") {
var st = VMM.Date.prettyDate(data.startdate);
var en = VMM.Date.prettyDate(data.enddate);
var st = VMM.Date.prettyDate(data.startdate, false, data.precisiondate);
var en = VMM.Date.prettyDate(data.enddate, false, data.precisiondate);
var tag = "";
/* TAG / CATEGORY
================================================== */
@ -7199,25 +7353,19 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
if (data.date[i].startDate != null && data.date[i].startDate != "") {
var _date = {};
// START DATE
if (data.date[i].type == "tweets") {
_date.startdate = VMM.ExternalAPI.twitter.parseTwitterDate(data.date[i].startDate);
} else {
_date.startdate = VMM.Date.parse(data.date[i].startDate);
}
var _date = {},
do_start = VMM.Date.parse(data.date[i].startDate, true),
do_end;
_date.startdate = do_start.date;
_date.precisiondate = do_start.precision;
if (!isNaN(_date.startdate)) {
// END DATE
if (data.date[i].endDate != null && data.date[i].endDate != "") {
if (data.date[i].type == "tweets") {
_date.enddate = VMM.ExternalAPI.twitter.parseTwitterDate(data.date[i].endDate);
} else {
_date.enddate = VMM.Date.parse(data.date[i].endDate);
}
_date.enddate = VMM.Date.parse(data.date[i].endDate);
} else {
_date.enddate = _date.startdate;
}
@ -7229,11 +7377,11 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
_date.needs_slug = true;
}
}
_date.title = data.date[i].headline;
_date.headline = data.date[i].headline;
_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.fulldate = _date.startdate.getTime();
_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 != "") {
var startpage_date,
do_start,
_date = {},
td_num = 0,
td;
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 {
startpage_date = false;
}
@ -7300,11 +7450,12 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
_date.uniqueid = VMM.Util.unique_ID(7);
_date.enddate = _date.startdate;
_date.precisiondate = do_start.precision;
_date.title = data.headline;
_date.headline = data.headline;
_date.text = data.text;
_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.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);
}
var refreshTimeline = function() {
function refreshTimeline() {
trace("config.nav.multiplier " + config.nav.multiplier.current);
positionMarkers(true);
positionEras(true);
@ -7657,7 +7808,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
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");
var _ease = config.ease,
_duration = config.duration,
@ -7705,7 +7856,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* CALCULATIONS
================================================== */
var averageMarkerPositionDistance = function() {
function averageMarkerPositionDistance() {
var last_pos = 0,
pos = 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;
}
var averageDateDistance = function() {
function averageDateDistance() {
var last_dd = 0,
dd = 0,
_dd = "",
@ -7750,7 +7901,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return VMM.Util.average(date_diffs);
}
var calculateMultiplier = function() {
function calculateMultiplier() {
var temp_multiplier = config.nav.multiplier.current,
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
var _first = getDateFractions(data[0].startdate),
_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;
}
var getDateFractions = function(the_date, is_utc) {
function getDateFractions(the_date, is_utc) {
var _time = {};
_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
relative to the calculated interval
================================================== */
var positionRelative = function(_interval, first, last) {
function positionRelative(_interval, first, last) {
var _first,
_last,
_type = _interval.type,
@ -8023,14 +8174,14 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return timerelative
}
var positionOnTimeline = function(the_interval, timerelative) {
function positionOnTimeline(the_interval, timerelative) {
return {
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)
};
}
var positionMarkers = function(is_animated) {
function positionMarkers(is_animated) {
var row = 2,
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,
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,
last_position_major = 0,
@ -8373,7 +8524,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* Interval Elements
================================================== */
var createIntervalElements = function(_interval, _array, _element_parent) {
function createIntervalElements(_interval, _array, _element_parent) {
var inc_time = 0,
_first_run = true,
@ -8579,7 +8730,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* BUILD
================================================== */
var build = function() {
function build() {
var i = 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,
j = 0;
// CALCULATE INTERVAL
@ -8763,7 +8914,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
}
}
var buildMarkers = function() {
function buildMarkers() {
var row = 2,
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,
current_color = 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);
}
var refreshTimeline = function() {
function refreshTimeline() {
trace("config.nav.multiplier " + config.nav.multiplier.current);
positionMarkers(true);
positionEras(true);
@ -317,7 +317,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
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");
var _ease = config.ease,
_duration = config.duration,
@ -365,7 +365,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* CALCULATIONS
================================================== */
var averageMarkerPositionDistance = function() {
function averageMarkerPositionDistance() {
var last_pos = 0,
pos = 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;
}
var averageDateDistance = function() {
function averageDateDistance() {
var last_dd = 0,
dd = 0,
_dd = "",
@ -410,7 +410,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return VMM.Util.average(date_diffs);
}
var calculateMultiplier = function() {
function calculateMultiplier() {
var temp_multiplier = config.nav.multiplier.current,
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
var _first = getDateFractions(data[0].startdate),
_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;
}
var getDateFractions = function(the_date, is_utc) {
function getDateFractions(the_date, is_utc) {
var _time = {};
_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
relative to the calculated interval
================================================== */
var positionRelative = function(_interval, first, last) {
function positionRelative(_interval, first, last) {
var _first,
_last,
_type = _interval.type,
@ -683,14 +683,14 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
return timerelative
}
var positionOnTimeline = function(the_interval, timerelative) {
function positionOnTimeline(the_interval, timerelative) {
return {
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)
};
}
var positionMarkers = function(is_animated) {
function positionMarkers(is_animated) {
var row = 2,
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,
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,
last_position_major = 0,
@ -1033,7 +1033,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* Interval Elements
================================================== */
var createIntervalElements = function(_interval, _array, _element_parent) {
function createIntervalElements(_interval, _array, _element_parent) {
var inc_time = 0,
_first_run = true,
@ -1239,7 +1239,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
/* BUILD
================================================== */
var build = function() {
function build() {
var i = 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,
j = 0;
// CALCULATE INTERVAL
@ -1423,7 +1423,7 @@ if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefin
}
}
var buildMarkers = function() {
function buildMarkers() {
var row = 2,
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,
current_color = 0,
j = 0;

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

Loading…
Cancel
Save