Browse Source

Added device orientation layout changes and start slide tweak to allow custom date

pull/227/head
Zach Wise 13 years ago
parent
commit
56f3ba5fce
  1. 83
      source/js/VMM.Timeline.js

83
source/js/VMM.Timeline.js

@ -42,7 +42,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
$navigation, $navigation,
slider, slider,
timenav, timenav,
version = "2.01", version = "2.05",
timeline_id = "#timelinejs", timeline_id = "#timelinejs",
events = {}, events = {},
data = {}, data = {},
@ -81,6 +81,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
source: "nothing", source: "nothing",
type: "timeline", type: "timeline",
touch: false, touch: false,
orientation: "normal",
maptype: "toner", maptype: "toner",
preload: 4, preload: 4,
current_slide: 0, current_slide: 0,
@ -151,6 +152,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
}, },
ease: "easeInOutExpo", ease: "easeInOutExpo",
duration: 1000, duration: 1000,
gmap_key: "",
language: VMM.Language language: VMM.Language
}; };
@ -211,6 +213,10 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
VMM.Timeline.Config = config; VMM.Timeline.Config = config;
VMM.master_config.Timeline = VMM.Timeline.Config; VMM.master_config.Timeline = VMM.Timeline.Config;
this.events = config.events; this.events = config.events;
if (config.gmap_key != "") {
config.api_keys.google = config.gmap_key;
}
} }
/* CREATE TIMELINE STRUCTURE /* CREATE TIMELINE STRUCTURE
@ -275,9 +281,13 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
} }
function reSize() { function reSize() {
if (orientationChange()) {
setViewport();
}
updateSize(); updateSize();
slider.setSize(config.feature.width, config.feature.height); slider.setSize(config.feature.width, config.feature.height);
timenav.setSize(config.width, config.height); timenav.setSize(config.width, config.height);
}; };
function onSliderLoaded(e) { function onSliderLoaded(e) {
@ -326,6 +336,63 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
} }
} }
function getViewport() {
}
function setViewport() {
var viewport_content = "",
viewport_orientation = searchOrientation(window.orientation);
if (VMM.Browser.device == "mobile") {
if (viewport_orientation == "portrait") {
viewport_content = "width=device-width; initial-scale=0.75, maximum-scale=0.75";
} else if (viewport_orientation == "landscape") {
viewport_content = "width=device-width; initial-scale=0.5, maximum-scale=0.5";
} else {
viewport_content = "width=device-width, initial-scale=1, maximum-scale=1.0";
}
} else if (VMM.Browser.device == "tablet") {
viewport_content = "width=device-width, initial-scale=1, maximum-scale=1.0";
}
if (document.getElementById("viewport")) {
VMM.Lib.attr("#viewport", "content", viewport_content);
} else {
VMM.appendElement("head", "<meta id='viewport' name='viewport' content=" + viewport_content + "/>");
}
}
/* ORIENTATION
================================================== */
function searchOrientation(orientation) {
var orient = "";
if ( orientation == 0 || orientation == 180) {
orient = "portrait";
} else if ( orientation == 90 || orientation == -90) {
orient = "landscape";
} else {
orient = "normal";
}
return orient;
}
function orientationChange() {
var orientation = searchOrientation(window.orientation);
if (orientation == config.orientation) {
return false;
} else {
config.orientation = orientation;
return true;
}
}
/* PUBLIC FUNCTIONS /* PUBLIC FUNCTIONS
================================================== */ ================================================== */
this.init = function(c, _data) { this.init = function(c, _data) {
@ -441,6 +508,9 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
// RESIZE EVENT LISTENERS // RESIZE EVENT LISTENERS
VMM.bindEvent(global, reSize, config.events.resize); VMM.bindEvent(global, reSize, config.events.resize);
// VIEWPORT
setViewport();
} }
@ -556,9 +626,17 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
/* CREATE START PAGE IF AVAILABLE /* CREATE START PAGE IF AVAILABLE
================================================== */ ================================================== */
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 = VMM.Date.parse(data.startDate),
_date = {},
td_num = 0,
td;
trace("HAS STARTPAGE"); trace("HAS STARTPAGE");
var _date = {}, td_num = 0, td; trace(startpage_date);
if (startpage_date < _dates[0].startdate) {
_date.startdate = new Date(startpage_date);
} else {
td = _dates[0].startdate; td = _dates[0].startdate;
_date.startdate = new Date(_dates[0].startdate); _date.startdate = new Date(_dates[0].startdate);
@ -578,6 +656,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
// trace("YEAR MONTH DAY HOUR MINUTE"); // trace("YEAR MONTH DAY HOUR MINUTE");
_date.startdate.setMinutes(td.getMinutes() - 1); _date.startdate.setMinutes(td.getMinutes() - 1);
} }
}
_date.uniqueid = VMM.Util.unique_ID(7); _date.uniqueid = VMM.Util.unique_ID(7);
_date.enddate = _date.startdate; _date.enddate = _date.startdate;

Loading…
Cancel
Save