diff --git a/source/js/VMM.js b/source/js/VMM.js index b6a57b4..c8e470e 100644 --- a/source/js/VMM.js +++ b/source/js/VMM.js @@ -1,8 +1,9 @@ /* Verite * Verite JS Master - * Version: 0.1 - * Date: December 12, 2011 - * Copyright 2011 Verite + * Version: 0.5 + * Date: April 5, 2012 + * Copyright 2012 Verite unless part of Verite Timeline, + * if part of Timeline then it inherits Timeline's license. * Designed and built by Zach Wise digitalartwork.net * ----------------------------------------------------- */ @@ -11,131 +12,87 @@ ================================================== */ - /* Simple JavaScript Inheritance * By John Resig http://ejohn.org/ * MIT Licensed. ================================================== */ +(function() { + var initializing = false, + fnTest = /xyz/.test(function() { + xyz; + }) ? /\b_super\b/: /.*/; + // The base Class implementation (does nothing) + this.Class = function() {}; + + // Create a new Class that inherits from this class + Class.extend = function(prop) { + var _super = this.prototype; + + // Instantiate a base class (but only create the instance, + // don't run the init constructor) + initializing = true; + var prototype = new this(); + initializing = false; + + // Copy the properties over onto the new prototype + for (var name in prop) { + // Check if we're overwriting an existing function + prototype[name] = typeof prop[name] == "function" && + typeof _super[name] == "function" && fnTest.test(prop[name]) ? + (function(name, fn) { + return function() { + var tmp = this._super; + + // Add a new ._super() method that is the same method + // but on the super-class + this._super = _super[name]; + + // The method only need to be bound temporarily, so we + // remove it when we're done executing + var ret = fn.apply(this, arguments); + this._super = tmp; + + return ret; + }; + })(name, prop[name]) : + prop[name]; + } -(function(){ - var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; - // The base Class implementation (does nothing) - this.Class = function(){}; - - // Create a new Class that inherits from this class - Class.extend = function(prop) { - var _super = this.prototype; - - // Instantiate a base class (but only create the instance, - // don't run the init constructor) - initializing = true; - var prototype = new this(); - initializing = false; - - // Copy the properties over onto the new prototype - for (var name in prop) { - // Check if we're overwriting an existing function - prototype[name] = typeof prop[name] == "function" && - typeof _super[name] == "function" && fnTest.test(prop[name]) ? - (function(name, fn){ - return function() { - var tmp = this._super; - - // Add a new ._super() method that is the same method - // but on the super-class - this._super = _super[name]; - - // The method only need to be bound temporarily, so we - // remove it when we're done executing - var ret = fn.apply(this, arguments); - this._super = tmp; - - return ret; - }; - })(name, prop[name]) : - prop[name]; - } - - // The dummy class constructor - function Class() { - // All construction is actually done in the init method - if ( !initializing && this.init ) - this.init.apply(this, arguments); - } - - // Populate our constructed prototype object - Class.prototype = prototype; - - // Enforce the constructor to be what we expect - Class.prototype.constructor = Class; - - // And make this class extendable - Class.extend = arguments.callee; - - return Class; - }; -})(); - - - -/* CLASS EXTEND EXAMPLE -================================================== */ -/* -var Person = Class.extend({ - init: function(isDancing){ - this.dancing = isDancing; - }, - dance: function(){ - return this.dancing; - } -}); -var Ninja = Person.extend({ - init: function(){ - this._super( false ); - }, - dance: function(){ - // Call the inherited version of dance() - return this._super(); - }, - swingSword: function(){ - return true; - } -}); - -var p = new Person(true); -p.dance(); // => true + // The dummy class constructor + function Class() { + // All construction is actually done in the init method + if (!initializing && this.init) + this.init.apply(this, arguments); + } -var n = new Ninja(); -n.dance(); // => false -n.swingSword(); // => true + // Populate our constructed prototype object + Class.prototype = prototype; -// Should all be true -p instanceof Person && p instanceof Class && -n instanceof Ninja && n instanceof Person && n instanceof Class -*/ + // Enforce the constructor to be what we expect + Class.prototype.constructor = Class; + // And make this class extendable + Class.extend = arguments.callee; + return Class; + }; +})(); /* Access to the Global Object * access the global object without hard-coding the identifier window ================================================== */ - var global = (function () { return this || (1,eval)('this'); }()); - /* VMM ================================================== */ - if (typeof VMM == 'undefined') { /* Main Scope Container ================================================== */ //var VMM = {}; - var VMM = Class.extend({ - - }); + var VMM = Class.extend({}); /* Master Config ================================================== */ @@ -239,7 +196,6 @@ if (typeof VMM == 'undefined') { }; - /* LIBRARY ABSTRACTION ================================================== */ @@ -344,7 +300,30 @@ if (typeof VMM == 'undefined') { // VMM.getJSON(url, the_function); VMM.getJSON = function(url, the_function) { if( typeof( jQuery ) != 'undefined' ){ - $.getJSON(url, the_function); + + /* CHECK FOR IE AND USE Use Microsoft XDR + ================================================== */ + if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 8 && window.XDomainRequest) { + trace("it's ie"); + var ie_url = url; + + if (ie_url.match('^http://')){ + //ie_url = ie_url.replace("http://","//"); + $.getJSON(url, the_function); + } else if (ie_url.match('^https://')) { + ie_url = ie_url.replace("https://","http://"); + var xdr = new XDomainRequest(); + xdr.open("get", ie_url); + xdr.onload = function() { + var ie_json = VMM.parseJSON(xdr.responseText); + return the_function(ie_json); + } + xdr.send(); + } + } else { + $.getJSON(url, the_function); + + } } } // VMM.parseJSON(the_json); @@ -1259,6 +1238,8 @@ if (typeof VMM == 'undefined') { } else if (m.type == "youtube") { mediaElem = "
"; return mediaElem; + } else if (m.type == "googledoc") { + mediaElem = ""; } else if (m.type == "vimeo") { mediaElem = ""; return mediaElem; @@ -1278,7 +1259,9 @@ if (typeof VMM == 'undefined') { mediaElem = ""; return mediaElem; } else if (m.type == "website") { - mediaElem = ""; + //mediaElem = ""; + mediaElem = ""; + return mediaElem; } else { mediaElem = ""; @@ -1331,6 +1314,14 @@ if (typeof VMM == 'undefined') { var flickr_id = "flickr_" + m.id; mediaElem = ""; VMM.ExternalAPI.flickr.getPhoto(m.id, "#" + flickr_id); + } else if (m.type == "googledoc") { + if (m.id.match(/docs.google.com/i)) { + mediaElem = ""; + } else { + mediaElem = ""; + } + + } else if (m.type == "youtube") { mediaElem = ""; - //twit += "— " + d.user.name + " (@" + d.user.screen_name + ") " + d.created_at + " "; - //twit += "" + VMM.ExternalAPI.twitter.prettyParseTwitterDate(d.created_at); - //twit += "" + VMM.ExternalAPI.twitter.prettyParseTwitterDate(d.created_at) + " "; - //twit += "" + "Tweet Details" + " "; twit += " " + "" + " "; - twit += " "; - - /* -"; var td = VMM.Util.linkify(d.text); td = td.replace(/(@([\w]+))/g,"$1"); td = td.replace(/(#([\w]+))/g,"$1"); - //twit += VMM.Util.linkify(d.text); twit += td; twit += "
-- */ VMM.attachElement("#"+id, twit ); - //VMM.attachElement("#"+id, VMM.ExternalAPI.twitter.linkify(twit) ); + } }, @@ -1650,32 +1637,38 @@ if (typeof VMM == 'undefined') { flickr: { getPhoto: function(mid, id) { - // http://soundcloud.com/oembed?iframe=true&url=http://soundcloud.com/erasedtapes/olafur-arnalds-poland - var the_url = "http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=" + VMM.Keys.flickr + "&photo_id=" + mid + "&format=json&nojsoncallback=1"; - VMM.getJSON(the_url, function(d) { - - var flickr_large_id = id + "_large"; - var flickr_thumb_id = id + "_thumb"; - var flickr_img_large = d.sizes.size[d.sizes.size.length - 1].source; - var flickr_img_thumb = d.sizes.size[0].source; - - VMM.Element.attr(flickr_large_id, "src", flickr_img_large); - VMM.Element.attr(flickr_thumb_id, "src", flickr_img_thumb); - }); + // http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=6d6f59d8d30d79f4f402a7644d5073e3&photo_id=6115056146&format=json&nojsoncallback=1 + var the_url = "http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=" + VMM.Keys.flickr + "&photo_id=" + mid + "&format=json&jsoncallback=?"; + VMM.getJSON(the_url, VMM.ExternalAPI.flickr.setPhoto); }, + //VMM.ExternalAPI.flickr.setPhoto(d); + setPhoto: function(d) { + var flickr_id = d.sizes.size[0].url.split("photos\/")[1].split("/")[1]; + var id = "flickr_" + flickr_id; + var flickr_large_id = id + "_large"; + var flickr_thumb_id = id + "_thumb"; + var flickr_img_large = d.sizes.size[d.sizes.size.length - 1].source; + var flickr_img_thumb = d.sizes.size[0].source; + VMM.Element.attr("#"+flickr_large_id, "src", flickr_img_large); + VMM.Element.attr("#"+flickr_thumb_id, "src", flickr_img_thumb); + } }, soundcloud: { // VMM.ExternalAPI.soundcloud.getSound(url, id) + /* + REFORMAT TO USE API FOR CUSTOM PLAYERS + */ getSound: function(url, id) { // http://soundcloud.com/oembed?iframe=true&url=http://soundcloud.com/erasedtapes/olafur-arnalds-poland - var the_url = "http://soundcloud.com/oembed?iframe=true&url=" + url + ""; + var the_url = "http://soundcloud.com/oembed?url=" + url + "&format=js&callback=?"; VMM.getJSON(the_url, function(d) { VMM.attachElement("#"+id, d.html ); }); }, + }, // VMM.ExternalAPI.youtube.init(id); @@ -1691,11 +1684,10 @@ if (typeof VMM == 'undefined') { if (VMM.master_config.youtube.api_loaded) { } else { - var tag = document.createElement('script'); - tag.src = "http://www.youtube.com/player_api"; - var firstScriptTag = document.getElementsByTagName('script')[0]; - firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); - VMM.master_config.youtube.api_loaded = true; + + VMM.LoadLib.js('http://www.youtube.com/player_api', function() { + trace("YouTube API Library Loaded"); + }); } } @@ -2034,18 +2026,3 @@ if( typeof( jQuery ) != 'undefined' ){ - - -/* CLONE OBJECTS -================================================== */ -/* -Object.prototype.clone = function() { - var newObj = (this instanceof Array) ? [] : {}; - for (i in this) { - if (i == 'clone') continue; - if (this[i] && typeof this[i] == "object") { - newObj[i] = this[i].clone(); - } else newObj[i] = this[i] - } return newObj; -}; -*/ diff --git a/source/js/timeline.js b/source/js/timeline.js index 66b9daa..45319f7 100755 --- a/source/js/timeline.js +++ b/source/js/timeline.js @@ -38,6 +38,7 @@ // @codekit-prepend "VMM.js"; // @codekit-prepend "VMM.Core.js"; // @codekit-prepend "VMM.Util.js"; +// @codekit-prepend "VMM.LoadLib.js"; // @codekit-prepend "bootstrap-tooltip.js"; /* Timeline Class contained in VMM (verite) namespace @@ -350,6 +351,9 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { //c._media = VMM.createElement("div", c._media, "media-wrapper"); slide = VMM.createElement("div", c._text + c._media, _layout_class); + + + //trace(slide); } @@ -1973,7 +1977,8 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { getData: function(raw_data) { var _key = VMM.Util.getUrlVars(raw_data)["key"]; var _url = "https://spreadsheets.google.com/feeds/list/" + _key + "/od6/public/values?alt=json"; - + VMM.getJSON(_url, VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData); + /* if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 8 && window.XDomainRequest) { // Use Microsoft XDR // going to move this to VMM.getJSON @@ -1993,11 +1998,11 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { trace("not ie"); VMM.getJSON(_url, VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData); } + */ }, buildData: function(d) { - var _data_obj = VMM.Timeline.DataObj.data_template_obj; for(var i = 0; i < d.feed.entry.length; i++) { diff --git a/timeline-min.js b/timeline-min.js index 93b1144..7b5928a 100644 --- a/timeline-min.js +++ b/timeline-min.js @@ -1,13 +1 @@ -/* 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+="Tom Brokaw asks #Romney to remove from ads 1997 NBC report on #Gingrich legal troubles. Romney unmoved. thecaucus.blogs.nytimes.com/2012/01/28/nbc…
- — Jim Roberts (@nytjim) January 29, 2012 -
";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+="