diff --git a/source/js/Core/VMM.Browser.js b/source/js/Core/VMM.Browser.js new file mode 100644 index 0000000..b08a895 --- /dev/null +++ b/source/js/Core/VMM.Browser.js @@ -0,0 +1,149 @@ +/* DEVICE AND BROWSER DETECTION +================================================== */ +if(typeof VMM != 'undefined' && typeof VMM.Browser == 'undefined') { + + VMM.Browser = { + init: function () { + this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; + this.version = this.searchVersion(navigator.userAgent) + || this.searchVersion(navigator.appVersion) + || "an unknown version"; + this.OS = this.searchString(this.dataOS) || "an unknown OS"; + this.device = this.searchDevice(navigator.userAgent); + this.orientation = this.searchOrientation(window.orientation); + }, + searchOrientation: function(orientation) { + if ( orientation == 0 || orientation == 180) { + return "portrait"; + } else if ( orientation == 90 || orientation == -90) { + return "landscape"; + } else { + return "normal"; + } + }, + searchDevice: function(d) { + if (d.match(/Android/i) || d.match(/iPhone|iPod/i)) { + return "mobile"; + } else if (d.match(/iPad/i)) { + return "tablet"; + } else if (d.match(/BlackBerry/i) || d.match(/IEMobile/i)) { + return "other mobile"; + } else { + return "desktop"; + } + }, + searchString: function (data) { + for (var i=0;i= 7 && window.XDomainRequest) { + trace("IE JSON"); + var ie_url = url; + if (ie_url.match('^http://')){ + return jQuery.getJSON(ie_url, data, callback); + } else if (ie_url.match('^https://')) { + ie_url = ie_url.replace("https://","http://"); + return jQuery.getJSON(ie_url, data, callback); + } else { + return jQuery.getJSON(url, data, callback); + } + + } else { + return jQuery.getJSON(url, data, callback); + } + } + } + + VMM.parseJSON = function(the_json) { + if( typeof( jQuery ) != 'undefined' ){ + return jQuery.parseJSON(the_json); + } + } + + // ADD ELEMENT AND RETURN IT + VMM.appendAndGetElement = function(append_to_element, tag, cName, content) { + var e; + var _tag = "
"; + var _class = ""; + var _content = ""; + + + if (tag != null && tag != "") { + _tag = tag; + } + + if (cName != null && cName != "") { + _class = cName; + } + + if (content != null && content != "") { + _content = content; + } + + if( typeof( jQuery ) != 'undefined' ){ + + e = jQuery(tag); + + e.addClass(_class); + e.html(_content); + + jQuery(append_to_element).append(e); + + } + + return e; + + }; + + VMM.Lib = { + + init: function() { + return this; + }, + + hide: function(element, duration) { + if (duration != null && duration != "") { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).hide(duration); + } + } else { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).hide(); + } + } + + }, + + remove: function(element) { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).remove(); + } + }, + + detach: function(element) { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).detach(); + } + }, + + append: function(element, value) { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).append(value); + } + }, + + prepend: function(element, value) { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).prepend(value); + } + }, + + show: function(element, duration) { + if (duration != null && duration != "") { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).show(duration); + } + } else { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).show(); + } + } + + }, + + load: function(element, callback_function, event_data) { + var _event_data = {elem:element}; // return element by default + if (_event_data != null && _event_data != "") { + _event_data = event_data; + } + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).load(_event_data, callback_function); + } + }, + + addClass: function(element, cName) { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).addClass(cName); + } + }, + + removeClass: function(element, cName) { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).removeClass(cName); + } + }, + + attr: function(element, aName, value) { + if (value != null && value != "") { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).attr(aName, value); + } + } else { + if( typeof( jQuery ) != 'undefined' ){ + return jQuery(element).attr(aName); + } + } + }, + + prop: function(element, aName, value) { + if (typeof jQuery == 'undefined' || !/[1-9]\.[3-9].[1-9]/.test(jQuery.fn.jquery)) { + VMM.Lib.attribute(element, aName, value); + } else { + jQuery(element).prop(aName, value); + } + }, + + attribute: function(element, aName, value) { + + if (value != null && value != "") { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).attr(aName, value); + } + } else { + if( typeof( jQuery ) != 'undefined' ){ + return jQuery(element).attr(aName); + } + } + }, + + visible: function(element, show) { + if (show != null) { + if( typeof( jQuery ) != 'undefined' ){ + if (show) { + jQuery(element).show(0); + } else { + jQuery(element).hide(0); + } + } + } else { + if( typeof( jQuery ) != 'undefined' ){ + if ( jQuery(element).is(':visible')){ + return true; + } else { + return false; + } + } + } + }, + + css: function(element, prop, value) { + + if (value != null && value != "") { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).css(prop, value); + } + } else { + if( typeof( jQuery ) != 'undefined' ){ + return jQuery(element).css(prop); + } + } + }, + + cssmultiple: function(element, propval) { + + if( typeof( jQuery ) != 'undefined' ){ + return jQuery(element).css(propval); + } + }, + + offset: function(element) { + var p; + if( typeof( jQuery ) != 'undefined' ){ + p = jQuery(element).offset(); + } + return p; + }, + + position: function(element) { + var p; + if( typeof( jQuery ) != 'undefined' ){ + p = jQuery(element).position(); + } + return p; + }, + + width: function(element, s) { + if (s != null && s != "") { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).width(s); + } + } else { + if( typeof( jQuery ) != 'undefined' ){ + return jQuery(element).width(); + } + } + }, + + height: function(element, s) { + if (s != null && s != "") { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).height(s); + } + } else { + if( typeof( jQuery ) != 'undefined' ){ + return jQuery(element).height(); + } + } + }, + + toggleClass: function(element, cName) { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).toggleClass(cName); + } + }, + + each:function(element, return_function) { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).each(return_function); + } + + }, + + html: function(element, str) { + var e; + if( typeof( jQuery ) != 'undefined' ){ + e = jQuery(element).html(); + return e; + } + + if (str != null && str != "") { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).html(str); + } + } else { + var e; + if( typeof( jQuery ) != 'undefined' ){ + e = jQuery(element).html(); + return e; + } + } + + }, + + find: function(element, selec) { + if( typeof( jQuery ) != 'undefined' ){ + return jQuery(element).find(selec); + } + }, + + stop: function(element) { + if( typeof( jQuery ) != 'undefined' ){ + jQuery(element).stop(); + } + }, + + animate: function(element, duration, ease, att, callback_function) { + + var _ease = "easein"; + var _duration = 1000; + var _att = {}; + + if (duration != null) { + if (duration < 1) { + _duration = 1; + } else { + _duration = Math.round(duration); + } + + } + + if (ease != null && ease != "") { + _ease = ease; + } + + if (att != null) { + _att = att + } else { + _att = {opacity: 0} + } + + + if (VMM.Browser.device == "mobile" || VMM.Browser.device == "tablet") { + + var _tdd = Math.round((_duration/1500)*10)/10 + var __duration = _tdd + 's'; + VMM.Lib.css(element, '-webkit-transition', 'all '+ __duration + ' ease'); + VMM.Lib.css(element, '-moz-transition', 'all '+ __duration + ' ease'); + VMM.Lib.css(element, '-o-transition', 'all '+ __duration + ' ease'); + VMM.Lib.css(element, '-ms-transition', 'all '+ __duration + ' ease'); + VMM.Lib.css(element, 'transition', 'all '+ __duration + ' ease'); + VMM.Lib.cssmultiple(element, _att); + + //callback_function(); + /* + if( typeof( jQuery ) != 'undefined' ){ + if (callback_function != null && callback_function != "") { + jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease, complete:callback_function} ); + } else { + jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease} ); + } + } + */ + + } else { + if( typeof( jQuery ) != 'undefined' ){ + if (callback_function != null && callback_function != "") { + jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease, complete:callback_function} ); + } else { + jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease} ); + } + } + } + + }, + + } +} + +if( typeof( jQuery ) != 'undefined' ){ + + /* XDR AJAX EXTENTION FOR jQuery + https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js + ================================================== */ + (function( jQuery ) { + if ( window.XDomainRequest ) { + jQuery.ajaxTransport(function( s ) { + if ( s.crossDomain && s.async ) { + if ( s.timeout ) { + s.xdrTimeout = s.timeout; + delete s.timeout; + } + var xdr; + return { + send: function( _, complete ) { + function callback( status, statusText, responses, responseHeaders ) { + xdr.onload = xdr.onerror = xdr.ontimeout = jQuery.noop; + xdr = undefined; + complete( status, statusText, responses, responseHeaders ); + } + xdr = new XDomainRequest(); + xdr.open( s.type, s.url ); + xdr.onload = function() { + callback( 200, "OK", { text: xdr.responseText }, "Content-Type: " + xdr.contentType ); + }; + xdr.onerror = function() { + callback( 404, "Not Found" ); + }; + if ( s.xdrTimeout ) { + xdr.ontimeout = function() { + callback( 0, "timeout" ); + }; + xdr.timeout = s.xdrTimeout; + } + xdr.send( ( s.hasContent && s.data ) || null ); + }, + abort: function() { + if ( xdr ) { + xdr.onerror = jQuery.noop(); + xdr.abort(); + } + } + }; + } + }); + } + })( jQuery ); + + /* jQuery Easing v1.3 + http://gsgd.co.uk/sandbox/jquery/easing/ + ================================================== */ + jQuery.easing['jswing'] = jQuery.easing['swing']; + + jQuery.extend( jQuery.easing, { + def: 'easeOutQuad', + swing: function (x, t, b, c, d) { + //alert(jQuery.easing.default); + return jQuery.easing[jQuery.easing.def](x, t, b, c, d); + }, + easeInExpo: function (x, t, b, c, d) { + return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; + }, + easeOutExpo: function (x, t, b, c, d) { + return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; + }, + easeInOutExpo: function (x, t, b, c, d) { + if (t==0) return b; + if (t==d) return b+c; + if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; + return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; + }, + easeInQuad: function (x, t, b, c, d) { + return c*(t/=d)*t + b; + }, + easeOutQuad: function (x, t, b, c, d) { + return -c *(t/=d)*(t-2) + b; + }, + easeInOutQuad: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t + b; + return -c/2 * ((--t)*(t-2) - 1) + b; + }, + }); +} diff --git a/source/js/Core/VMM.LoadLib.js b/source/js/Core/VMM.LoadLib.js new file mode 100644 index 0000000..5f3153f --- /dev/null +++ b/source/js/Core/VMM.LoadLib.js @@ -0,0 +1,247 @@ +/* + LoadLib + Based on LazyLoad by Ryan Grove + https://github.com/rgrove/lazyload/ + Copyright (c) 2011 Ryan Grove + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the 'Software'), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +================================================== */ +window.loadedJS = []; + + +if(typeof VMM != 'undefined' && typeof VMM.LoadLib == 'undefined') { + //VMM.LoadLib.js('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', onJQueryLoaded); + //VMM.LoadLib.css('http://someurl.css', onCSSLoaded); + + + + VMM.LoadLib = (function (doc) { + var env, + head, + pending = {}, + pollCount = 0, + queue = {css: [], js: []}, + styleSheets = doc.styleSheets; + + var loaded_Array = []; + + function isLoaded(url) { + var has_been_loaded = false; + for(var i=0; i= 0) { + if (styleSheets[i].href === css.urls[0]) { + finish('css'); + break; + } + } + + pollCount += 1; + + if (css) { + if (pollCount < 200) { + setTimeout(pollWebKit, 50); + } else { + + finish('css'); + } + } + } + } + + return { + + css: function (urls, callback, obj, context) { + if (isLoaded(urls)) { + return callback; + } else { + load('css', urls, callback, obj, context); + } + }, + + js: function (urls, callback, obj, context) { + if (isLoaded(urls)) { + return callback; + } else { + load('js', urls, callback, obj, context); + } + } + + }; + })(this.document); +} + diff --git a/source/js/Core/VMM.js b/source/js/Core/VMM.js new file mode 100644 index 0000000..3bbfeb8 --- /dev/null +++ b/source/js/Core/VMM.js @@ -0,0 +1,333 @@ +/* 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({}); + + /* Debug + ================================================== */ + VMM.debug = true; + + /* Master Config + ================================================== */ + + VMM.master_config = ({ + + init: function() { + return this; + }, + + sizes: { + api: { + width: 0, + height: 0 + } + }, + + vp: "Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo", + + api_keys_master: { + flickr: "RAIvxHY4hE/Elm5cieh4X5ptMyDpj7MYIxziGxi0WGCcy1s+yr7rKQ==", + google: "jwNGnYw4hE9lmAez4ll0QD+jo6SKBJFknkopLS4FrSAuGfIwyj57AusuR0s8dAo=", + twitter: "" + }, + + flickr: { + active: false, + array: [], + api_loaded: false, + que: [] + }, + + youtube: { + active: false, + array: [], + api_loaded: false, + que: [] + }, + + vimeo: { + active: false, + array: [], + api_loaded: false, + que: [] + }, + + googlemaps: { + active: false, + map_active: false, + places_active: false, + array: [], + api_loaded: false, + que: [] + }, + + googledocs: { + active: false, + array: [], + api_loaded: false, + que: [] + }, + + wikipedia: { + active: false, + array: [], + api_loaded: false, + que: [] + }, + + soundcloud: { + 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 += " style='" + styles + "'"; + }; + + ce += ">"; + + if (value != null && value != "") { + ce += value; + } + + // CLOSE TAG + ce = ce + ""; + } + + 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 (VMM.debug) { + 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(); + } + } + } +}; + + + diff --git a/source/js/Media/VMM.TextElement.js b/source/js/Media/VMM.TextElement.js new file mode 100644 index 0000000..80a9409 --- /dev/null +++ b/source/js/Media/VMM.TextElement.js @@ -0,0 +1,115 @@ +/* TextElement +================================================== */ +if(typeof VMM != 'undefined' && typeof VMM.TextElement == 'undefined') { + + VMM.TextElement = ({ + + init: function() { + return this; + }, + + create: function(data) { + + return data; + + //$mediacontainer = element; + /* + var _valid = false; + + if (data.media != null && data.media != "") { + var mediaElem = "", captionElem = "", creditElem = "", _id = "", isTextMedia = false; + var m = VMM.MediaType(data.media); //returns an object with .type and .id + _valid = true; + + // CREDIT + if (data.credit != null && data.credit != "") { + creditElem = "
" + VMM.Util.linkify_with_twitter(data.credit, "_blank") + "
"; + } + // CAPTION + if (data.caption != null && data.caption != "") { + captionElem = "
" + VMM.Util.linkify_with_twitter(data.caption, "_blank") + "
"; + } + // IMAGE + if (m.type == "image") { + mediaElem = "
"; + // FLICKR + } else if (m.type == "flickr") { + _id = "flickr_" + m.id; + mediaElem = "
"; + VMM.ExternalAPI.flickr.get(m.id, "#" + _id); + // GOOGLE DOCS + } else if (m.type == "googledoc") { + _id = "googledoc_" + VMM.Util.unique_ID(5); + mediaElem = "

Loading Document

"; + VMM.ExternalAPI.googledocs.get(m.id, _id); + // YOUTUBE + } else if (m.type == "youtube") { + mediaElem = "

Loading YouTube video

"; + VMM.ExternalAPI.youtube.get(m.id); + // VIMEO + } else if (m.type == "vimeo") { + mediaElem = "
"; + VMM.ExternalAPI.vimeo.get(m.id); + // DAILYMOTION + } else if (m.type == "dailymotion") { + mediaElem = "
"; + // TWITTER + } else if (m.type == "twitter"){ + mediaElem = ""; + isTextMedia = true; + VMM.ExternalAPI.twitter.prettyHTML(m.id, secondary); + // TWITTER + } else if (m.type == "twitter-ready") { + isTextMedia = true; + mediaElem = m.id; + // SOUNDCLOUD + } else if (m.type == "soundcloud") { + _id = "soundcloud_" + VMM.Util.unique_ID(5); + mediaElem = "

Loading Sound

"; + VMM.ExternalAPI.soundcloud.get(m.id, _id); + // GOOGLE MAPS + } else if (m.type == "google-map") { + _id = "googlemap_" + VMM.Util.unique_ID(7); + mediaElem = "

Loading Map

"; + VMM.ExternalAPI.googlemaps.get(m.id, _id); + // WIKIPEDIA + } else if (m.type == "wikipedia") { + _id = "wikipedia_" + VMM.Util.unique_ID(7); + mediaElem = "

Loading Wikipedia

"; + isTextMedia = true; + VMM.ExternalAPI.wikipedia.get(m.id, _id); + // UNKNOWN + } else if (m.type == "quote") { + isTextMedia = true; + mediaElem = "
" + m.id + "
"; + // UNKNOWN + } else if (m.type == "unknown") { + trace("NO KNOWN MEDIA TYPE FOUND TRYING TO JUST PLACE THE HTML"); + isTextMedia = true; + mediaElem = "
" + VMM.Util.properQuotes(m.id) + "
"; + // WEBSITE + } else if (m.type == "website") { + mediaElem = "
"; + //mediaElem = "" + ""; + // NO MATCH + } else { + trace("NO KNOWN MEDIA TYPE FOUND"); + trace(m.type); + } + + // WRAP THE MEDIA ELEMENT + mediaElem = "
" + mediaElem + creditElem + captionElem + "
"; + // RETURN + if (isTextMedia) { + return "
" + mediaElem + "
"; + } else { + return "
" + mediaElem + "
"; + } + + + }; + */ + } + + }).init(); +} \ No newline at end of file diff --git a/source/js/Slider/VMM.DragSlider.js b/source/js/Slider/VMM.DragSlider.js new file mode 100644 index 0000000..87d14d0 --- /dev/null +++ b/source/js/Slider/VMM.DragSlider.js @@ -0,0 +1,147 @@ +/* DRAG SLIDER +================================================== */ +if(typeof VMM != 'undefined' && typeof VMM.DragSlider == 'undefined') { + // VMM.DragSlider.createSlidePanel(drag_object, move_object, w, padding, sticky); + // VMM.DragSlider.cancelSlide(); + VMM.DragSlider = { + createPanel: function(drag_object, move_object, w, padding, sticky) { + + + + var x = padding; + VMM.DragSlider.width = w; + VMM.DragSlider.makeDraggable(drag_object, move_object); + VMM.DragSlider.drag_elem = drag_object; + /* + if (sticky != null && sticky != "") { + VMM.TouchSlider.sticky = sticky; + } else { + VMM.TouchSlider.sticky = false; + } + */ + VMM.DragSlider.sticky = sticky; + }, + makeDraggable: function(drag_object, move_object) { + VMM.bindEvent(drag_object, VMM.DragSlider.onDragStart, "mousedown", {element: move_object, delement: drag_object}); + //VMM.bindEvent(drag_object, VMM.DragSlider.onDragMove, "mousemove", {element: move_object}); + VMM.bindEvent(drag_object, VMM.DragSlider.onDragEnd, "mouseup", {element: move_object, delement: drag_object}); + VMM.bindEvent(drag_object, VMM.DragSlider.onDragLeave, "mouseleave", {element: move_object, delement: drag_object}); + }, + cancelSlide: function(e) { + VMM.unbindEvent(VMM.DragSlider.drag_elem, VMM.DragSlider.onDragMove, "mousemove"); + //VMM.DragSlider.drag_elem.preventDefault(); + //VMM.DragSlider.drag_elem.stopPropagation(); + return true; + }, + onDragLeave: function(e) { + + VMM.unbindEvent(e.data.delement, VMM.DragSlider.onDragMove, "mousemove"); + e.preventDefault(); + e.stopPropagation(); + return true; + }, + onDragStart: function(e) { + VMM.DragSlider.dragStart(e.data.element, e.data.delement, e); + + e.preventDefault(); + e.stopPropagation(); + return true; + }, + onDragEnd: function(e) { + e.preventDefault(); + e.stopPropagation(); + + if (VMM.DragSlider.sliding) { + VMM.DragSlider.sliding = false; + VMM.DragSlider.dragEnd(e.data.element, e.data.delement, e); + return false; + } else { + return true; + } + + }, + onDragMove: function(e) { + VMM.DragSlider.dragMove(e.data.element, e); + e.preventDefault(); + e.stopPropagation(); + return false; + }, + dragStart: function(elem, delem, e) { + + VMM.DragSlider.startX = e.pageX; + + VMM.DragSlider.startLeft = VMM.DragSlider.getLeft(elem); + VMM.DragSlider.dragStartTime = new Date().getTime(); + VMM.DragSlider.dragWidth = VMM.Lib.width(delem); + + // CANCEL CURRENT ANIMATION IF ANIMATING + var _newx = Math.round(VMM.DragSlider.startX - e.pageX - VMM.DragSlider.startLeft); + + VMM.Lib.stop(elem); + VMM.bindEvent(delem, VMM.DragSlider.onDragMove, "mousemove", {element: elem}); + + }, + dragEnd: function(elem, delem, e) { + VMM.unbindEvent(delem, VMM.DragSlider.onDragMove, "mousemove"); + //VMM.DragSlider.dragMomentum(elem, e); + if (VMM.DragSlider.getLeft(elem) > 0) { + //(VMM.DragSlider.dragWidth/2) + //This means they dragged to the right past the first item + //VMM.Lib.animate(elem, 1000, "linear", {"left": 0}); + + //VMM.fireEvent(elem, "DRAGUPDATE", [0]); + } else { + //This means they were just dragging within the bounds of the grid and we just need to handle the momentum and snap to the grid. + VMM.DragSlider.dragMomentum(elem, e); + } + }, + dragMove: function(elem, e) { + if (!VMM.DragSlider.sliding) { + //elem.parent().addClass('sliding'); + } + + VMM.DragSlider.sliding = true; + if (VMM.DragSlider.startX > e.pageX) { + //Sliding to the left + VMM.Lib.css(elem, 'left', -(VMM.DragSlider.startX - e.pageX - VMM.DragSlider.startLeft)); + VMM.DragSlider.slidingLeft = true; + } else { + //Sliding to the right + var left = (e.pageX - VMM.DragSlider.startX + VMM.DragSlider.startLeft); + VMM.Lib.css(elem, 'left', -(VMM.DragSlider.startX - e.pageX - VMM.DragSlider.startLeft)); + VMM.DragSlider.slidingLeft = false; + } + }, + dragMomentum: function(elem, e) { + var slideAdjust = (new Date().getTime() - VMM.DragSlider.dragStartTime) * 10; + var timeAdjust = slideAdjust; + var left = VMM.DragSlider.getLeft(elem); + + var changeX = 6000 * (Math.abs(VMM.DragSlider.startLeft) - Math.abs(left)); + //var changeX = 6000 * (VMM.DragSlider.startLeft - left); + slideAdjust = Math.round(changeX / slideAdjust); + + var newLeft = left + slideAdjust; + + var t = newLeft % VMM.DragSlider.width; + //left: Math.min(0, newLeft), + var _r_object = { + left: Math.min(newLeft), + time: timeAdjust + } + + VMM.fireEvent(elem, "DRAGUPDATE", [_r_object]); + var _ease = "easeOutExpo"; + if (_r_object.time > 0) { + VMM.Lib.animate(elem, _r_object.time, _ease, {"left": _r_object.left}); + }; + + + //VMM.DragSlider.startX = null; + }, + getLeft: function(elem) { + return parseInt(VMM.Lib.css(elem, 'left').substring(0, VMM.Lib.css(elem, 'left').length - 2), 10); + } + + } +} \ No newline at end of file diff --git a/source/js/Slider/VMM.Slider.Slide.js b/source/js/Slider/VMM.Slider.Slide.js new file mode 100644 index 0000000..ddb910b --- /dev/null +++ b/source/js/Slider/VMM.Slider.Slide.js @@ -0,0 +1,201 @@ +/* Slider Slide +================================================== */ +if (typeof VMM.Slider != 'undefined') { + // VMM.Slider.Slide(element, data) + VMM.Slider.Slide = function(d, _parent) { + + var data = d; + var slide = {}; + var media = ""; + var loaded = false; + var preloaded = false; + var is_skinny = false; + var element = VMM.appendAndGetElement(_parent, "
", "slider-item"); + var c = {slide:"", text: "", media: "", media_element: "", layout: "content-container layout", has: { headline: false, text: false, media: false }}; + var $media, $text, $slide, $wrap; + /* PUBLIC + ================================================== */ + this.show = function(skinny) { + if (!loaded) { + if (preloaded) { + reLayout(skinny); + } else { + render(skinny); + } + } + }; + + this.hide = function() { + if (loaded) { + removeSlide(); + } + }; + + this.layout = function(skinny) { + if (loaded && preloaded) { + reLayout(skinny); + } + }; + + this.elem = function() { + return element; + }; + + this.position = function() { + return VMM.Lib.position(element); + }; + + this.leftpos = function(p) { + if(typeof p != 'undefined') { + VMM.Lib.css(element, "left", p); + } else { + return VMM.Lib.position(element).left + } + }; + + this.animate = function(d, e, p) { + VMM.Lib.animate(element, d, e, p); + }; + + this.css = function(p, v) { + VMM.Lib.css(element, p, v ); + } + + this.opacity = function(p) { + VMM.Lib.css(element, "opacity", p); + } + + this.width = function() { + return VMM.Lib.width(element); + }; + + this.height = function() { + return VMM.Lib.height(element); + }; + + this.content_height = function () { + var ch = VMM.Lib.find( element, ".content")[0]; + + if (ch != 'undefined' && ch != null) { + return VMM.Lib.height(ch); + } else { + return 0; + } + } + + /* PRIVATE + ================================================== */ + var render = function(skinny) { + buildSlide(skinny); + loaded = true; + preloaded = true; + var timer = setTimeout(VMM.ExternalAPI.pushQues, 500); + }; + + var removeSlide = function() { + //VMM.attachElement(element, ""); + loaded = false; + } + + var reLayout = function(skinny) { + + if (c.has.text) { + if (skinny) { + if (!is_skinny) { + VMM.Lib.removeClass($slide, "pad-left"); + VMM.Lib.detach($text); + VMM.Lib.prepend($slide, $text); + is_skinny = true; + } + } else { + if (is_skinny) { + VMM.Lib.addClass($slide, "pad-left"); + VMM.Lib.detach($text); + VMM.Lib.append($slide, $text); + is_skinny = false + } + } + } + } + + var buildSlide = function(skinny) { + $wrap = VMM.appendAndGetElement(element, "
", "content"); + $slide = VMM.appendAndGetElement($wrap, "
"); + + /* DATE + ================================================== */ + if (data.startdate != null && data.startdate != "") { + if (type.of(data.startdate) == "date") { + if (data.type != "start") { + var st = VMM.Date.prettyDate(data.startdate); + var en = VMM.Date.prettyDate(data.enddate); + if (st != en) { + c.text += VMM.createElement("h2", st + " — " + en + "", "date"); + } else { + c.text += VMM.createElement("h2", st, "date"); + } + } + } + } + + /* HEADLINE + ================================================== */ + if (data.headline != null && data.headline != "") { + c.has.headline = true; + if (data.type == "start") { + c.text += VMM.createElement("h2", VMM.Util.linkify_with_twitter(data.headline, "_blank"), "start"); + } else { + c.text += VMM.createElement("h3", VMM.Util.linkify_with_twitter(data.headline, "_blank")); + } + } + + /* TEXT + ================================================== */ + if (data.text != null && data.text != "") { + c.has.text = true; + c.text += VMM.createElement("p", VMM.Util.linkify_with_twitter(data.text, "_blank")); + } + + if (c.has.text || c.has.headline) { + c.text = VMM.createElement("div", c.text, "container"); + //$text = VMM.appendAndGetElement($slide, "
", "text", c.text); + + $text = VMM.appendAndGetElement($slide, "
", "text", VMM.TextElement.create(c.text)); + + } + + /* MEDIA + ================================================== */ + if (data.asset != null && data.asset != "") { + if (data.asset.media != null && data.asset.media != "") { + c.has.media = true; + $media = VMM.appendAndGetElement($slide, "
", "media", VMM.MediaElement.create(data.asset)); + } + } + + /* COMBINE + ================================================== */ + if (c.has.text) { c.layout += "-text" }; + if (c.has.media){ c.layout += "-media" }; + + if (c.has.text) { + if (skinny) { + VMM.Lib.addClass($slide, c.layout); + is_skinny = true; + } else { + VMM.Lib.addClass($slide, c.layout); + VMM.Lib.addClass($slide, "pad-left"); + VMM.Lib.detach($text); + VMM.Lib.append($slide, $text); + } + + } else { + VMM.Lib.addClass($slide, c.layout); + } + + + }; + + } + +}; diff --git a/source/js/Slider/VMM.TouchSlider.js b/source/js/Slider/VMM.TouchSlider.js new file mode 100644 index 0000000..1d0b713 --- /dev/null +++ b/source/js/Slider/VMM.TouchSlider.js @@ -0,0 +1,190 @@ +/* TOUCH SLIDER +================================================== */ +if(typeof VMM != 'undefined' && typeof VMM.TouchSlider == 'undefined') { + + // VMM.TouchSlider.createSlidePanel(touch_object, move_object, w, padding, vertical, h) ; + VMM.TouchSlider = { + createPanel: function(touch_object, move_object, w, padding, vertical, h) { + VMM.TouchSlider.vertical = false; + VMM.TouchSlider.vertical = vertical; + + var x = padding; + VMM.TouchSlider.width = w; + VMM.TouchSlider.height = h; + VMM.TouchSlider.makeTouchable(touch_object, move_object); + /* + if (sticky != null && sticky != "") { + VMM.TouchSlider.sticky = sticky; + } else { + VMM.TouchSlider.sticky = false; + } + */ + // VMM.TouchSlider.sticky = sticky; + + }, + + removePanel: function(touch_object) { + VMM.unbindEvent(touch_object, VMM.TouchSlider.onTouchStart, "touchstart"); + VMM.unbindEvent(touch_object, VMM.TouchSlider.onTouchMove, "touchmove"); + VMM.unbindEvent(touch_object, VMM.TouchSlider.onTouchEnd, "touchend"); + }, + + makeTouchable: function(touch_object, move_object) { + VMM.bindEvent(touch_object, VMM.TouchSlider.onTouchStart, "touchstart", {element: move_object}); + VMM.bindEvent(touch_object, VMM.TouchSlider.onTouchMove, "touchmove", {element: move_object}); + VMM.bindEvent(touch_object, VMM.TouchSlider.onTouchEnd, "touchend", {element: move_object}); + }, + onTouchStart: function(e) { + VMM.TouchSlider.touchStart(e.data.element, e); + e.stopPropagation(); + return true; + }, + onTouchEnd: function(e) { + e.stopPropagation(); + + if (VMM.TouchSlider.sliding) { + VMM.TouchSlider.sliding = false; + VMM.TouchSlider.touchEnd(e.data.element, e); + return false; + } else { + return true; + } + + }, + onTouchMove: function(e) { + VMM.TouchSlider.touchMove(e.data.element, e); + e.preventDefault(); + e.stopPropagation(); + return false; + }, + getLeft: function(elem) { + return parseInt(VMM.Lib.css(elem, 'left').substring(0, VMM.Lib.css(elem, 'left').length - 2), 10); + }, + getTop: function(elem) { + return parseInt(VMM.Lib.css(elem, 'top').substring(0, VMM.Lib.css(elem, 'top').length - 2), 10); + }, + touchStart: function(elem, e) { + + VMM.Lib.css(elem, '-webkit-transition-duration', '0'); + + VMM.TouchSlider.startX = e.originalEvent.touches[0].screenX; + VMM.TouchSlider.startY = e.originalEvent.touches[0].screenY; + + VMM.TouchSlider.startLeft = VMM.TouchSlider.getLeft(elem); + VMM.TouchSlider.startTop = VMM.TouchSlider.getTop(elem); + + VMM.TouchSlider.touchStartTime = new Date().getTime(); + + }, + touchEnd: function(elem, e) { + if (VMM.TouchSlider.getLeft(elem) > 0) { + + //This means they dragged to the right past the first item + + if (VMM.TouchSlider.vertical) { + VMM.Lib.animate(elem, 1000, "", {"top": 0}); + } else { + VMM.Lib.animate(elem, 1000, "", {"left": 0}); + } + + VMM.TouchSlider.startX = null; + VMM.TouchSlider.startY = null; + + VMM.fireEvent(elem, "TOUCHUPDATE", [0]); + + } else { + //This means they were just dragging within the bounds of the grid and we just need to handle the momentum and snap to the grid. + VMM.TouchSlider.slideMomentum(elem, e); + } + }, + slideMomentum: function(elem, e) { + var slideAdjust = (new Date().getTime() - VMM.TouchSlider.touchStartTime) * 10; + var timeAdjust = slideAdjust; + + var left = VMM.TouchSlider.getLeft(elem); + var top = VMM.TouchSlider.getTop(elem); + + var changeX = 6000 * (Math.abs(VMM.TouchSlider.startLeft) - Math.abs(left)); + var changeY = 6000 * (Math.abs(VMM.TouchSlider.startTop) - Math.abs(top)); + + slideAdjust = Math.round(changeX / slideAdjust); + slideAdjustY = Math.round(changeY / slideAdjust); + + var newLeft = slideAdjust + left; + var newTop = slideAdjustY + top; + + var y = newTop % VMM.TouchSlider.height; + var t = newLeft % VMM.TouchSlider.width; + + + var _r_object = { + top: Math.min(0, newTop), + left: Math.min(0, newLeft), + time: timeAdjust + } + VMM.fireEvent(elem, "TOUCHUPDATE", [_r_object]); + /* + if (VMM.TouchSlider.sticky) { + trace("sticky"); + if ((Math.abs(t)) > ((VMM.TouchSlider.width / 2))) { + //Show the next cell + newLeft -= (VMM.TouchSlider.width - Math.abs(t)); + } else { + //Stay on the current cell + newLeft -= t; + } + + VMM.fireEvent(elem, "TOUCHUPDATE", [Math.min(0, newLeft)]); + + } else { + trace("not sticky"); + //VMM.TouchSlider.doSlide(elem, Math.min(0, newLeft), '0.5s'); + VMM.Lib.animate(elem, 500, "", {"left": Math.min(0, newLeft)}); + } + */ + + VMM.TouchSlider.startX = null; + VMM.TouchSlider.startY = null; + + }, + doSlide: function(elem, x, duration) { + VMM.Lib.css(elem, '-webkit-transition-property', 'left'); + VMM.Lib.css(elem, '-webkit-transition-duration', duration); + VMM.Lib.css(elem, 'left', x); + }, + touchMove: function(elem, e) { + + if (!VMM.TouchSlider.sliding) { + //elem.parent().addClass('sliding'); + } + + VMM.TouchSlider.sliding = true; + + if (VMM.TouchSlider.vertical) { + + if (VMM.TouchSlider.startY > e.originalEvent.touches[0].screenY) { + VMM.Lib.css(elem, 'top', -(VMM.TouchSlider.startY - e.originalEvent.touches[0].screenY - VMM.TouchSlider.startTop)); + VMM.TouchSlider.slidingTop = true; + } else { + var top = (e.originalEvent.touches[0].screenY - VMM.TouchSlider.startY + VMM.TouchSlider.startTop); + VMM.Lib.css(elem, 'top', -(VMM.TouchSlider.startY - e.originalEvent.touches[0].screenY - VMM.TouchSlider.startTop)); + VMM.TouchSlider.slidingTop = false; + } + + } else { + + if (VMM.TouchSlider.startX > e.originalEvent.touches[0].screenX) { + VMM.Lib.css(elem, 'left', -(VMM.TouchSlider.startX - e.originalEvent.touches[0].screenX - VMM.TouchSlider.startLeft)); + VMM.TouchSlider.slidingLeft = true; + } else { + var left = (e.originalEvent.touches[0].screenX - VMM.TouchSlider.startX + VMM.TouchSlider.startLeft); + VMM.Lib.css(elem, 'left', -(VMM.TouchSlider.startX - e.originalEvent.touches[0].screenX - VMM.TouchSlider.startLeft)); + VMM.TouchSlider.slidingLeft = false; + } + + } + + + } + } +} \ No newline at end of file