diff --git a/source/js/timeline-embed.js b/source/js/timeline-embed.js index 12c6bff..b0a2fda 100644 --- a/source/js/timeline-embed.js +++ b/source/js/timeline-embed.js @@ -24,29 +24,72 @@ /* TIMELINE CDN LOADER - Add container div so that user can set width and height - ================================================== */ -//
+/* Embed code with config +================================================== */ +/* + + + + + +*/ -(function(embed_loc, embed_doc, embed_window) { + +(function() { + /* CONFIG Default + ================================================== */ + var embed_config = { + width: 800, + height: 600, + source: 'taylor/data.json', + css: 'http://veritetimeline.appspot.com/latest/timeline.css', + js: 'http://veritetimeline.appspot.com/latest/timeline-min.js' + } + if (typeof config == 'object') { + var x; + for (x in config) { + if (Object.prototype.hasOwnProperty.call(config, x)) { + embed_config[x] = config[x]; + } + } + } + + /* VARS + ================================================== */ var jsReady = false; var cssReady = false; + var isReady = false; var preload_checks = 0; - + var timeout; + var timeline; /* Add Timeline Div ================================================== */ var t = document.createElement('div'); - document.getElementById("timeline-embed").appendChild(t); + var te = document.getElementById("timeline-embed"); + te.appendChild(t); t.setAttribute("id", 'timeline'); + te.style.width = embed_config.width + 'px'; + te.style.height = embed_config.height + 'px'; + t.style.position = 'relative'; + /* Load CSS + ================================================== */ + LazyLoad.css(embed_config.css, cssComplete); - - LazyLoad.css('http://veritetimeline.appspot.com/latest/timeline.css', cssComplete); - + /* Check for jQuery + ================================================== */ try { var jqueryLoaded=jQuery; jqueryLoaded=true; @@ -54,7 +97,8 @@ var jqueryLoaded=false; } - //var head= document.getElementsByTagName('head')[0]; + /* Load jQuery if it doesn't exist + ================================================== */ if (!jqueryLoaded) { LazyLoad.js('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', onJQueryLoaded); } else { @@ -63,7 +107,7 @@ function onJQueryLoaded() { - LazyLoad.js('http://veritetimeline.appspot.com/latest/timeline-min.js', onJSLoaded); + LazyLoad.js(embed_config.js, onJSLoaded); } function onJSLoaded() { @@ -76,65 +120,50 @@ checkLoad(); } + /* Check to see if everything is loaded. + ================================================== */ function checkLoad() { if (preload_checks > 40) { return; - alert("Error Loading Files") + alert("Error Loading Files"); } else { preload_checks++; if (jsReady && cssReady) { - var timeline = new VMM.Timeline(); - timeline.init("taylor/data.json"); + if (!isReady) { + isReady = true; + timeline = new VMM.Timeline(); + timeline.init(embed_config.source); + } } else { - setTimeout('checkLoad();', 250); + //alert("run timeout"); + timeout = setTimeout('checkAgain();', 250); } } } + + this.checkAgain = function() { + checkLoad(); + } - /* - var stylesheet = document.createElement('link'); - stylesheet.href = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css'; - stylesheet.rel = 'stylesheet'; - stylesheet.type = 'text/css'; - document.getElementsByTagName('head')[0].appendChild(stylesheet); - - var tjs = document.createElement('script'); - tjs.type = 'text/javascript'; - tjs.async = true; - tjs.url = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css'; - document.getElementsByTagName('head')[0].appendChild(tjs); - */ -}) (this, document, window); +})(); + +/* + Thinking of ditching Lazy loader after some more testing. +*/ /* +var stylesheet = document.createElement('link'); +stylesheet.href = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css'; +stylesheet.rel = 'stylesheet'; +stylesheet.type = 'text/css'; +document.getElementsByTagName('head')[0].appendChild(stylesheet); -document.getElementById('myText'); -function(embed_loc, embed_doc, embed_window) { - function e(embed_loc, embed_doc) { - var c, - d = [], - e, - g; - try { - if (document.querySelectorAll) d = document.querySelectorAll(embed_loc + "." + embed_doc); - else if (document.getElementsByClassName) { - c = document.getElementsByClassName(embed_doc); - for (e = 0; g = c[e]; e++) g.tagName.toLowerCase() == embed_loc && d.push(g) - } else { - c = document.getElementsByTagName(a); - var h = RegExp("\\b" + embed_doc + "\\b"); - f(c, - function(embed_loc, embed_doc) { - var c = embed_loc.className || embed_loc.getAttribute("class"); - c && c.match(h) && d.push(embed_loc) - }) - } - } catch(i) {} - return d - } - -} (this, document, window) +var tjs = document.createElement('script'); +tjs.type = 'text/javascript'; +tjs.async = true; +tjs.url = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css'; +document.getElementsByTagName('head')[0].appendChild(tjs); */ \ No newline at end of file diff --git a/source/less/structure.less b/source/less/structure.less index 991e5ca..f67f24d 100644 --- a/source/less/structure.less +++ b/source/less/structure.less @@ -32,6 +32,9 @@ background-color:@color-background; position: absolute; //border: 1px solid @color-line; + + z-index:100; + clear:both; overflow:hidden; diff --git a/timeline-embed.js b/timeline-embed.js index 44eb0f4..d25d86f 100644 --- a/timeline-embed.js +++ b/timeline-embed.js @@ -421,29 +421,72 @@ LazyLoad = (function (doc) { /* TIMELINE CDN LOADER - Add container div so that user can set width and height - ================================================== */ -// + +/* Embed code with config +================================================== */ +/* + + + + + +*/ -(function(embed_loc, embed_doc, embed_window) { +(function() { + /* CONFIG Default + ================================================== */ + var embed_config = { + width: 800, + height: 600, + source: 'taylor/data.json', + css: 'http://veritetimeline.appspot.com/latest/timeline.css', + js: 'http://veritetimeline.appspot.com/latest/timeline-min.js' + } + if (typeof config == 'object') { + var x; + for (x in config) { + if (Object.prototype.hasOwnProperty.call(config, x)) { + embed_config[x] = config[x]; + } + } + } + + /* VARS + ================================================== */ var jsReady = false; var cssReady = false; + var isReady = false; var preload_checks = 0; - + var timeout; + var timeline; /* Add Timeline Div ================================================== */ var t = document.createElement('div'); - document.getElementById("timeline-embed").appendChild(t); + var te = document.getElementById("timeline-embed"); + te.appendChild(t); t.setAttribute("id", 'timeline'); + te.style.width = embed_config.width + 'px'; + te.style.height = embed_config.height + 'px'; + t.style.position = 'relative'; + /* Load CSS + ================================================== */ + LazyLoad.css(embed_config.css, cssComplete); - - LazyLoad.css('http://veritetimeline.appspot.com/latest/timeline.css', cssComplete); - + /* Check for jQuery + ================================================== */ try { var jqueryLoaded=jQuery; jqueryLoaded=true; @@ -451,7 +494,8 @@ LazyLoad = (function (doc) { var jqueryLoaded=false; } - //var head= document.getElementsByTagName('head')[0]; + /* Load jQuery if it doesn't exist + ================================================== */ if (!jqueryLoaded) { LazyLoad.js('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', onJQueryLoaded); } else { @@ -460,7 +504,7 @@ LazyLoad = (function (doc) { function onJQueryLoaded() { - LazyLoad.js('http://veritetimeline.appspot.com/latest/timeline-min.js', onJSLoaded); + LazyLoad.js(embed_config.js, onJSLoaded); } function onJSLoaded() { @@ -473,65 +517,50 @@ LazyLoad = (function (doc) { checkLoad(); } + /* Check to see if everything is loaded. + ================================================== */ function checkLoad() { if (preload_checks > 40) { return; - alert("Error Loading Files") + alert("Error Loading Files"); } else { preload_checks++; if (jsReady && cssReady) { - var timeline = new VMM.Timeline(); - timeline.init("taylor/data.json"); + if (!isReady) { + isReady = true; + timeline = new VMM.Timeline(); + timeline.init(embed_config.source); + } } else { - setTimeout('checkLoad();', 250); + //alert("run timeout"); + timeout = setTimeout('checkAgain();', 250); } } } + + this.checkAgain = function() { + checkLoad(); + } - /* - var stylesheet = document.createElement('link'); - stylesheet.href = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css'; - stylesheet.rel = 'stylesheet'; - stylesheet.type = 'text/css'; - document.getElementsByTagName('head')[0].appendChild(stylesheet); - - var tjs = document.createElement('script'); - tjs.type = 'text/javascript'; - tjs.async = true; - tjs.url = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css'; - document.getElementsByTagName('head')[0].appendChild(tjs); - */ -}) (this, document, window); +})(); -/* -document.getElementById('myText'); -function(embed_loc, embed_doc, embed_window) { - function e(embed_loc, embed_doc) { - var c, - d = [], - e, - g; - try { - if (document.querySelectorAll) d = document.querySelectorAll(embed_loc + "." + embed_doc); - else if (document.getElementsByClassName) { - c = document.getElementsByClassName(embed_doc); - for (e = 0; g = c[e]; e++) g.tagName.toLowerCase() == embed_loc && d.push(g) - } else { - c = document.getElementsByTagName(a); - var h = RegExp("\\b" + embed_doc + "\\b"); - f(c, - function(embed_loc, embed_doc) { - var c = embed_loc.className || embed_loc.getAttribute("class"); - c && c.match(h) && d.push(embed_loc) - }) - } - } catch(i) {} - return d - } - -} (this, document, window) +/* + Thinking of ditching Lazy loader after some more testing. +*/ +/* +var stylesheet = document.createElement('link'); +stylesheet.href = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css'; +stylesheet.rel = 'stylesheet'; +stylesheet.type = 'text/css'; +document.getElementsByTagName('head')[0].appendChild(stylesheet); + +var tjs = document.createElement('script'); +tjs.type = 'text/javascript'; +tjs.async = true; +tjs.url = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css'; +document.getElementsByTagName('head')[0].appendChild(tjs); */ \ No newline at end of file diff --git a/timeline-min.js b/timeline-min.js new file mode 100644 index 0000000..93b1144 --- /dev/null +++ b/timeline-min.js @@ -0,0 +1,13 @@ +/* Verite + * Verite JS Master + * Version: 0.1 + * Date: December 12, 2011 + * Copyright 2011 Verite + * Designed and built by Zach Wise digitalartwork.net + * ----------------------------------------------------- *//* CodeKit Import +================================================== *//* Simple JavaScript Inheritance + * By John Resig http://ejohn.org/ + * MIT Licensed. +================================================== */function trace(a){window.console?console.log(a):typeof jsTrace!="undefined"&&jsTrace.send(a)}function onYouTubePlayerAPIReady(){VMM.ExternalAPI.youtube.onAPIReady()}(function(){var a=!1,b=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(c){function g(){!a&&this.init&&this.init.apply(this,arguments)}var d=this.prototype;a=!0;var e=new this;a=!1;for(var f in c)e[f]=typeof c[f]=="function"&&typeof d[f]=="function"&&b.test(c[f])?function(a,b){return function(){var c=this._super;this._super=d[a];var e=b.apply(this,arguments);this._super=c;return e}}(f,c[f]):c[f];g.prototype=e;g.prototype.constructor=g;g.extend=arguments.callee;return g}})();var global=function(){return this||(1,eval)("this")}();if(typeof VMM=="undefined"){var VMM=Class.extend({});VMM.master_config={init:function(){return this},youtube:{active:!1,array:[],api_loaded:!1}}.init();VMM.master_config={init:function(){return this},youtube:{active:!1,array:[],api_loaded:!1,que:[]}}.init();VMM.createElement=function(a,b,c,d,e){var f="";if(a!=null&&a!=""){f+="<"+a;c!=null&&c!=""&&(f+=" class='"+c+"'");d!=null&&d!=""&&(f+=" "+d);e!=null&&e!=""&&(f+=" "+e);f+=">";b!=null&&b!=""&&(f+=b);f=f+""+a+">"}return f};VMM.createMediaElement=function(a,b,c){var d="",e=!1;d+="";d.content=e;d.raw=a;b.push(d);if(b.length==c){var g={tweetdata:b};VMM.fireEvent(global,"TWEETSLOADED",g)}})}},getTweetSearch:function(a,b){var c=40;b!=null&&b!=""&&(c=b);var d="http://search.twitter.com/search.json?q="+a+"&rpp="+c+"&include_entities=true&result_type=mixed",e=[];VMM.getJSON(d,function(a){for(var b=0;b",f=VMM.Util.linkify(a.text);f=f.replace(/(@([\w]+))/g,"$1");f=f.replace(/(#([\w]+))/g,"$1");e+=f;e+="
";e+="— "+a.user.name+" (@"+a.user.screen_name+") "+VMM.ExternalAPI.twitter.prettyParseTwitterDate(a.created_at)+"
";c.content=d;c.raw=a.results[b];e.push(c)}var g={tweetdata:e};VMM.fireEvent(global,"TWEETSLOADED",g)})},prettyHTML:function(a){var b="https://api.twitter.com/1/statuses/show.json?id="+a+"&include_entities=true&callback=?";VMM.getJSON(b,function(b){VMM.ExternalAPI.twitter.formatJSON(b,a)})},formatJSON:function(a,b){var c="",f=VMM.Util.linkify(a.results[b].text);f=f.replace(/(@([\w]+))/g,"$1");f=f.replace(/(#([\w]+))/g,"$1");d+=f;d+="
";d+="— "+a.results[b].from_user_name+" (@"+a.results[b].from_user+") "+VMM.ExternalAPI.twitter.prettyParseTwitterDate(a.results[b].created_at)+"
";c+=" "+""+" ";c+=" ";VMM.attachElement("#"+b,c)}},maps:{},flickr:{getPhoto:function(a,b){var c="http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key="+VMM.Keys.flickr+"&photo_id="+a+"&format=json&nojsoncallback=1";VMM.getJSON(c,function(a){var c=b+"_large",d=b+"_thumb",e=a.sizes.size[a.sizes.size.length-1].source,f=a.sizes.size[0].source;VMM.Element.attr(c,"src",e);VMM.Element.attr(d,"src",f)})}},soundcloud:{getSound:function(a,b){var c="http://soundcloud.com/oembed?iframe=true&url="+a+"";VMM.getJSON(c,function(a){VMM.attachElement("#"+b,a.html)})}},youtube:{init:function(a){if(VMM.master_config.youtube.active)VMM.master_config.youtube.createPlayer(a);else{VMM.master_config.youtube.que.push(a);if(!VMM.master_config.youtube.api_loaded){var b=document.createElement("script");b.src="http://www.youtube.com/player_api";var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c);VMM.master_config.youtube.api_loaded=!0}}},onAPIReady:function(){VMM.master_config.youtube.active=!0;for(var a=0;a",d=VMM.Util.linkify(a.text);d=d.replace(/(@([\w]+))/g,"$1");d=d.replace(/(#([\w]+))/g,"$1");c+=d;c+="