/* Verite
* Verite JS Master
* Version: 0.6
* Date: April 26, 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
* ----------------------------------------------------- */
/* 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];
}
// 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;
};
})();
/* 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({});
/* Master Config
================================================== */
VMM.master_config = ({
init: function() {
return this;
},
vp: "Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo",
keys: {
flickr: "RAIvxHY4hE/Elm5cieh4X5ptMyDpj7MYIxziGxi0WGCcy1s+yr7rKQ==",
google: "jwNGnYw4hE9lmAez4ll0QD+jo6SKBJFknkopLS4FrSAuGfIwyj57AusuR0s8dAo="
},
youtube: {
active: false,
array: [],
api_loaded:false,
que: []
},
googlemaps: {
active: false,
map_active: false,
places_active: false,
array: [],
api_loaded:false,
que: []
}
}).init();
//VMM.createElement(tag, value, cName, attrs, styles);
VMM.createElement = function(tag, value, cName, attrs, styles) {
var ce = "";
if (tag != null && tag != "") {
// TAG
ce += "<" + tag;
if (cName != null && cName != "") {
ce += " class='" + cName + "'";
};
if (attrs != null && attrs != "") {
ce += " " + attrs;
};
if (styles != null && styles != "") {
ce += " " + styles;
};
ce += ">";
if (value != null && value != "") {
ce += value;
}
// CLOSE TAG
ce = ce + "" + tag + ">";
}
return ce;
};
VMM.createMediaElement = function(media, caption, credit) {
var ce = "";
var _valid = false;
ce += "
";
if (media != null && media != "") {
valid = true;
ce += "";
// CREDIT
if (credit != null && credit != "") {
ce += VMM.createElement("div", credit, "credit");
}
// CAPTION
if (caption != null && caption != "") {
ce += VMM.createElement("div", caption, "caption");
}
}
ce += "
";
return ce;
};
// Hide URL Bar for iOS and Android by Scott Jehl
// https://gist.github.com/1183357
VMM.hideUrlBar = function () {
var win = window,
doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash || !win.addEventListener ){
//scroll to 1
window.scrollTo( 0, 1 );
var scrollTop = 1,
//reset to 0 on bodyready, if needed
bodycheck = setInterval(function(){
if( doc.body ){
clearInterval( bodycheck );
scrollTop = "scrollTop" in doc.body ? doc.body.scrollTop : 1;
win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
}
}, 15 );
win.addEventListener( "load", function(){
setTimeout(function(){
//reset to hide addr bar at onload
win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
}, 0);
}, false );
}
};
}
/* Trace (console.log)
================================================== */
function trace( msg ) {
if (window.console) {
console.log(msg);
} else if ( typeof( jsTrace ) != 'undefined' ) {
jsTrace.send( msg );
} else {
//alert(msg);
}
}
/* Extending Date to include Week
================================================== */
Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
}
/* Extending Date to include Day of Year
================================================== */
Date.prototype.getDayOfYear = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((this - onejan) / 86400000);
}
/* A MORE SPECIFIC TYPEOF();
// http://rolandog.com/archives/2007/01/18/typeof-a-more-specific-typeof/
================================================== */
// type.of()
var is={
Null:function(a){return a===null;},
Undefined:function(a){return a===undefined;},
nt:function(a){return(a===null||a===undefined);},
Function:function(a){return(typeof(a)==="function")?a.constructor.toString().match(/Function/)!==null:false;},
String:function(a){return(typeof(a)==="string")?true:(typeof(a)==="object")?a.constructor.toString().match(/string/i)!==null:false;},
Array:function(a){return(typeof(a)==="object")?a.constructor.toString().match(/array/i)!==null||a.length!==undefined:false;},
Boolean:function(a){return(typeof(a)==="boolean")?true:(typeof(a)==="object")?a.constructor.toString().match(/boolean/i)!==null:false;},
Date:function(a){return(typeof(a)==="date")?true:(typeof(a)==="object")?a.constructor.toString().match(/date/i)!==null:false;},
HTML:function(a){return(typeof(a)==="object")?a.constructor.toString().match(/html/i)!==null:false;},
Number:function(a){return(typeof(a)==="number")?true:(typeof(a)==="object")?a.constructor.toString().match(/Number/)!==null:false;},
Object:function(a){return(typeof(a)==="object")?a.constructor.toString().match(/object/i)!==null:false;},
RegExp:function(a){return(typeof(a)==="function")?a.constructor.toString().match(/regexp/i)!==null:false;}
};
var type={
of:function(a){
for(var i in is){
if(is[i](a)){
return i.toLowerCase();
}
}
}
};
/***********************************************
Begin VMM.Library.js
***********************************************/
/* LIBRARY ABSTRACTION
================================================== */
if(typeof VMM != 'undefined') {
//VMM.attachElement(element, content);
VMM.attachElement = function(element, content) {
if( typeof( jQuery ) != 'undefined' ){
$(element).html(content);
}
};
//VMM.appendElement(element, content);
VMM.appendElement = function(element, content) {
if( typeof( jQuery ) != 'undefined' ){
$(element).append(content);
}
};
VMM.getHTML = function(element) {
var e;
if( typeof( jQuery ) != 'undefined' ){
e = jQuery(element).html();
return e;
}
};
//VMM.getElement(element);
VMM.getElement = function(element, p) {
var e;
if( typeof( jQuery ) != 'undefined' ){
if (p) {
e = jQuery(element).parent().get(0);
} else {
e = jQuery(element).get(0);
}
return e;
}
};
//VMM.bindEvent(element, the_handler, the_event_type, event_data);
//VMM.bindEvent(window, the_handler, "event type", {event_data});
VMM.bindEvent = function(element, the_handler, the_event_type, event_data) {
var e;
var _event_type = "click";
var _event_data = {};
if (the_event_type != null && the_event_type != "") {
_event_type = the_event_type;
}
if (_event_data != null && _event_data != "") {
_event_data = event_data;
}
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).bind(_event_type, _event_data, the_handler);
//return e;
}
};
//VMM.unbindEvent(window, the_handler, "event type");
VMM.unbindEvent = function(element, the_handler, the_event_type) {
var e;
var _event_type = "click";
var _event_data = {};
if (the_event_type != null && the_event_type != "") {
_event_type = the_event_type;
}
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).unbind(_event_type, the_handler);
//return e;
}
};
//VMM.fireEvent(element, "resize", [data]);
VMM.fireEvent = function(element, the_event_type, the_data) {
var e;
var _event_type = "click";
var _data = [];
if (the_event_type != null && the_event_type != "") {
_event_type = the_event_type;
}
if (the_data != null && the_data != "") {
_data = the_data;
}
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).trigger(_event_type, _data);
//return e;
}
};
// VMM.getJSON(url, the_function);
VMM.getJSON = function(url, data, callback) {
if( typeof( jQuery ) != 'undefined' ){
/* CHECK FOR IE AND USE Use Microsoft XDR
================================================== */
if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 7 && window.XDomainRequest) {
trace("it's ie");
var ie_url = url;
if (ie_url.match('^http://')){
trace("RUNNING GET JSON")
ie_url = ie_url.replace("http://","//");
return jQuery.getJSON(url, data, callback);
} else if (ie_url.match('^https://')) {
trace("RUNNING XDR");
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);
trace(xdr.responseText);
if (type.of(ie_json) == "null" || type.of(ie_json) == "undefined") {
trace("IE JSON ERROR")
} else {
return data(ie_json)
}
}
xdr.send();
} else {
return jQuery.getJSON(url, data, callback);
}
} else {
//$.getJSON(url, data);
trace("getJSON");
return jQuery.getJSON(url, data, callback);
}
}
}
// VMM.parseJSON(the_json);
VMM.parseJSON = function(the_json) {
if( typeof( jQuery ) != 'undefined' ){
return jQuery.parseJSON(the_json);
}
}
// ADD ELEMENT AND RETURN IT
// VMM.appendAndGetElement(append_to_element, tag, cName, content, [attrib]);
VMM.appendAndGetElement = function(append_to_element, tag, cName, content) {
var e;
var _tag = "
";
VMM.ExternalAPI.googlemaps.getMap(m.id, map_id);
} else if (m.type == "unknown") {
trace("NO KNOWN MEDIA TYPE FOUND TRYING TO JUST PLACE THE HTML");
mediaElem = VMM.Util.properQuotes(m.id);
} else if (m.type == "website") {
mediaElem = "";
//mediaElem = "" + "";
} else {
trace("NO KNOWN MEDIA TYPE FOUND");
trace(m.type);
}
// WRAP THE MEDIA ELEMENT
mediaElem = "
" + mediaElem + creditElem + captionElem + "
";
if (_return) {
if (isTextMedia) {
return "
" + mediaElem + "
";
} else {
return "
" + mediaElem + "
";
}
} else {
VMM.appendElement($mediacontainer, mediaElem);
VMM.appendElement($mediacontainer, creditElem);
VMM.appendElement($mediacontainer, captionElem);
}
};
},
}).init();
}
/***********************************************
Begin VMM.MediaType.js
***********************************************/
/* MediaType
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.MediaType == 'undefined') {
//VMM.mediaType.youtube(d); //should return a true or false
// VMM.MediaType(url); //returns an object with .type and .id
VMM.MediaType = function(d) {
var success = false;
var media = {};
if (d.match("div class='twitter'")) {
media.type = "twitter-ready";
media.id = d;
success = true;
} else if (d.match('(www.)?youtube|youtu\.be')) {
if (d.match('v=')) {
youtube_id = VMM.Util.getUrlVars(d)["v"];
//youtube_id = d.split(/embed\//)[1].split('"')[0];
} else {
youtube_id = d.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];
}
//youtube_id = d.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];
// http://www.youtube.com/watch?feature=player_embedded&v=0l-ivcnLrSc
//http://www.youtube.com/watch?v=0l-ivcnLrSc
media.type = "youtube";
media.id = youtube_id;
success = true;
} else if (d.match('(player.)?vimeo\.com')) {
//vimeo_id = d.split(/video\/|http:\/\/vimeo\.com\//)[1].split(/[?&]/)[0];
vimeo_id = d.split(/video\/|\/\/vimeo\.com\//)[1].split(/[?&]/)[0];
media.type = "vimeo";
media.id = vimeo_id;
success = true;
} else if (d.match('(player.)?soundcloud\.com')) {
//soundcloud_url = unescape(d.split(/value="/)[1].split(/["]/)[0]);
//soundcloud_id = soundcloud_url.split(/tracks\//)[1].split(/[&"]/)[0];
media.type = "soundcloud";
media.id = d;
success = true;
} else if (d.match('(www.)?twitter\.com')) {
trace("TWITTER MATCH");
// https://twitter.com/#!/twitterapi/statuses/133640144317198338
// https://twitter.com/#!/DeliciousHot/status/23189589820702720
if (d.match("status\/")) {
twitter_id = d.split("status\/")[1];
} else if (d.match("statuses\/")) {
twitter_id = d.split("statuses\/")[1];
} else {
twitter_id = "";
}
media.type = "twitter";
media.id = twitter_id;
success = true;
} else if (d.match("maps.google")) {
//maps.google.com
media.type = "google-map";
media.id = d.split(/src=['|"][^'|"]*?['|"]/gi);
//trace("google map " + media.id);
success = true;
} else if (d.match("flickr.com/photos")) {
media.type = "flickr";
//media.id = d.split('/photos/[^/]+/([0-9]+)/gi');
media.id = d.split("photos\/")[1].split("/")[1];
media.link = d;
//media.id = media.id.split("/")[1];
//trace("FLICKR " + media.id);
success = true;
} else if (d.match(/jpg|jpeg|png|gif/i)) {
media.type = "image";
media.id = d;
success = true;
} else if (VMM.FileExtention.googleDocType(d)) {
media.type = "googledoc";
media.id = d;
success = true;
} else if (d.indexOf('http://') == 0) {
media.type = "website";
media.id = d;
success = true;
} else {
trace("unknown media");
media.type = "unknown";
media.id = d;
success = true;
}
if (success) {
return media;
} else {
trace("No valid media id detected");
trace(d);
}
return false;
}
}
/***********************************************
Begin VMM.Media.js
***********************************************/
/* Media
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.Media == 'undefined') {
// something = new VMM.Media(parent, w, h, {thedata});
VMM.Media = function(parent, w, h, thedata) {
/* PRIVATE VARS
================================================== */
var data = {}; // HOLDS DATA
var _valid = false;
var config = {
width: 720,
height: 400,
content_width: 720,
content_height: 400,
ease: "easeInOutExpo",
duration: 1000,
spacing: 15
};
/* ELEMENTS
================================================== */
var $media = "";
var $container = "";
var $mediacontainer = "";
var $mediaelement = "";
var layout = parent; // expecting media div
if (w != null && w != "") {config.width = w};
if (h != null && h != "") {config.height = h};
/*
if (typeof thedata != "undefined") {
data = thedata;
this.init(data);
}
*/
/* PUBLIC FUNCTIONS
================================================== */
this.init = function(d) {
if(typeof d != 'undefined') {
this.setData(d);
} else {
trace("WAITING ON DATA");
}
};
var build = function(media, caption, credit) {
$media = VMM.appendAndGetElement(layout, "
", "media-container");
if (data.media != null && data.media != "") {
_valid = true;
var m = {};
m = VMM.MediaType(data.media); //returns an object with .type and .id
if (m.type == "image") {
VMM.appendElement($mediacontainer, "");
} else if (m.type == "youtube") {
VMM.appendElement($mediacontainer, "