Browse Source

don't maintain global state #18

pull/39/head
gregwebs 13 years ago
parent
commit
1e145da829
  1. 54
      timeline.js

54
timeline.js

@ -4505,14 +4505,24 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
VMM.Timeline = function(w, h, conf) { VMM.Timeline = function(w, h, conf) {
var version = "0.90"; var version = "0.90";
trace("TIMELINE VERSION " + version); trace("OPEN TIMELINE VERSION " + version);
var $timeline = VMM.getElement("#timeline"); // expecting name only for parent /* CHECK FOR IE7
var $feedback; ================================================== */
var $messege; var ie7 = false;
if (VMM.Browser.browser == "MSIE") {
if ( parseInt(VMM.Browser.version, 10) == 7) {
ie7 = true;
}
}
var html_string = VMM.getElement("#timeline"); // used by prepare
var $timeline, html_string, $feedback, $messege, slider, timenav, _private_var, events, data, _dates, config;
var prepare = function(){
$timeline = VMM.getElement("#timeline"); // expecting name only for parent
html_string = VMM.getElement("#timeline");
/* CREATE DOM STRUCTURE /* CREATE DOM STRUCTURE
================================================== */ ================================================== */
@ -4527,21 +4537,21 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
/* CREATE COMPONENTS /* CREATE COMPONENTS
================================================== */ ================================================== */
// SLIDER // SLIDER
var slider = new VMM.Slider("div.slider", 720, 400, true); slider = new VMM.Slider("div.slider", 720, 400, true);
// TIMENAV // TIMENAV
var timenav = new VMM.Timeline.TimeNav("div.navigation", 720, 400, true); timenav = new VMM.Timeline.TimeNav("div.navigation", 720, 400, true);
/* PRIVATE VARS /* PRIVATE VARS
================================================== */ ================================================== */
var _private_var = 'private'; _private_var = 'private';
var events = {}; // CUSTOM EVENT HOLDER events = {}; // CUSTOM EVENT HOLDER
var data = {}; // HOLDS DATA data = {}; // HOLDS DATA
var _dates = []; // HOLDES PROCESSED DATES _dates = []; // HOLDES PROCESSED DATES
/* CONFIG /* CONFIG
================================================== */ ================================================== */
var config = VMM.Timeline.Config; config = VMM.Timeline.Config;
VMM.master_config.Timeline = VMM.Timeline.Config; VMM.master_config.Timeline = VMM.Timeline.Config;
/* MAP TYPE /* MAP TYPE
@ -4603,15 +4613,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
} }
} }
} }
}
/* CHECK FOR IE7
================================================== */
var ie7 = false;
if (VMM.Browser.browser == "MSIE") {
if ( parseInt(VMM.Browser.version, 10) == 7) {
ie7 = true;
}
}
/* ON EVENT /* ON EVENT
@ -4671,6 +4673,7 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
/* PUBLIC FUNCTIONS /* PUBLIC FUNCTIONS
================================================== */ ================================================== */
this.init = function(d) { this.init = function(d) {
prepare();
trace('init'); trace('init');
@ -4684,6 +4687,9 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
} else { } else {
if (type.of(d) == "string") { if (type.of(d) == "string") {
VMM.Timeline.DataObj.getData(d); VMM.Timeline.DataObj.getData(d);
} else if (type.of(d) == 'object' && d.timeline && d.timeline.type == "default") {
// we got a JSON object passed in, let's go!
onDataReady(null, d);
} else { } else {
VMM.Timeline.DataObj.getData(html_string); VMM.Timeline.DataObj.getData(html_string);
//VMM.attachElement(element, content); //VMM.attachElement(element, content);
@ -6578,4 +6584,4 @@ $(document).ready(function() {
timeline.init("example.json"); // Pass in the data timeline.init("example.json"); // Pass in the data
}); });
*/ */

Loading…
Cancel
Save