/ * V e r i t e
* Verite JS Master
* 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
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * /
/ * C o d e K i t I m p o r t
=== === === === === === === === === === === === === === === === == * /
/ * S i m p l e J a v a S c r i p t I n h e r i t a n c e
* 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 ;
} ;
} ) ( ) ;
/ * A c c e s s t o t h e G l o b a l O b j e c t
* access the global object without hard - coding the identifier window
=== === === === === === === === === === === === === === === === == * /
var global = ( function ( ) {
return this || ( 1 , eval ) ( 'this' ) ;
} ( ) ) ;
/ * V M M
=== === === === === === === === === === === === === === === === == * /
if ( typeof VMM == 'undefined' ) {
/ * E N S U R E j Q u e r y i s a v a i l a b l e a s $
=== === === === === === === === === === === === === === === === == * /
var $ ;
if ( typeof ( jQuery ) != 'undefined' ) {
$ = jQuery ;
}
/ * M a i n S c o p e C o n t a i n e r
=== === === === === === === === === === === === === === === === == * /
//var VMM = {};
var VMM = Class . extend ( { } ) ;
/ * M a s t e r C o n f i g
=== === === === === === === === === === === === === === === === == * /
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 ( ) ;
/ * A b s t r a c t o u t D O M e l e m e n t c r e a t i o n t o m a k e i n d e p e n d e n t o f l i b r a r y
=== === === === === === === === === === === === === === === === == * /
//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 += "<div class='media'>" ;
if ( media != null && media != "" ) {
valid = true ;
ce += "<img src='" + media + "'>" ;
// CREDIT
if ( credit != null && credit != "" ) {
ce += VMM . createElement ( "div" , credit , "credit" ) ;
}
// CAPTION
if ( caption != null && caption != "" ) {
ce += VMM . createElement ( "div" , caption , "caption" ) ;
}
}
ce += "</div>" ;
return ce ;
} ;
/ * L I B R A R Y A B S T R A C T I O N
=== === === === === === === === === === === === === === === === == * /
//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' ) {
/ * C H E C K F O R I E A N D U S E U s e M i c r o s o f t X D R
=== === === === === === === === === === === === === === === === == * /
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://' ) ) {
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 )
}
//.error(function() { trace("IE ERROR")})
//.success(function() { trace("IE SUCCESS")});
}
xdr . send ( ) ;
} else {
return jQuery . getJSON ( url , data , callback ) ;
}
} else {
//$.getJSON(url, data);
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 = "<div>" ;
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 = $ ( tag ) ;
e . addClass ( _class ) ;
e . html ( _content ) ;
jQuery ( append _to _element ) . append ( e ) ;
//$(e).appendTo(element);
}
return e ;
} ;
VMM . Element = ( {
init : function ( ) {
return this ;
} ,
// VMM.Element.hide(element);
hide : function ( element , duration ) {
if ( duration != null && duration != "" ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . hide ( duration ) ;
}
} else {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . hide ( ) ;
}
}
} ,
// VMM.Element.remove(element);
remove : function ( element ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . remove ( ) ;
}
} ,
// VMM.Element.detach(element);
detach : function ( element ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . detach ( ) ;
}
} ,
// VMM.Element.append(element, value);
append : function ( element , value ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . append ( value ) ;
}
} ,
// VMM.Element.show(element);
show : function ( element , duration ) {
if ( duration != null && duration != "" ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . show ( duration ) ;
}
} else {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . show ( ) ;
}
}
} ,
// VMM.Element.load(element, callback_function, event_data);
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 ) ;
}
} ,
//VMM.Element.addClass(element, cName);
addClass : function ( element , cName ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . addClass ( cName ) ;
}
} ,
//VMM.Element.removeClass(element, cName);
removeClass : function ( element , cName ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . removeClass ( cName ) ;
}
} ,
//VMM.Element.attr(element, aName, value);
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 ) ;
}
}
} ,
//VMM.Element.prop(element, aName, value);
prop : function ( element , aName , value ) {
if ( typeof jQuery == 'undefined' || ! /[1-9]\.[3-9].[1-9]/ . test ( $ . fn . jquery ) ) {
VMM . Element . attribute ( element , aName , value ) ;
} else {
jQuery ( element ) . prop ( aName , value ) ;
}
} ,
//VMM.Element.attribute(element, 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 ) ;
}
}
} ,
/ * S e t s o r g e t s t h e v i s a b i l i t y o f a d o m e l e m e n t
=== === === === === === === === === === === === === === === === == * /
//VMM.Element.visible(element, show);
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 ;
}
}
}
} ,
/ * S e t s a s t y l e f o r t h e s p e c i f i e d e l e m e n t o r g e t s t h e s t y l e
=== === === === === === === === === === === === === === === === == * /
//VMM.Element.css(element, prop, value);
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 ) ;
}
} ,
/ * G e t s o f f s e t
=== === === === === === === === === === === === === === === === == * /
//VMM.Element.offset(element);
offset : function ( element ) {
var p ;
if ( typeof ( jQuery ) != 'undefined' ) {
p = jQuery ( element ) . offset ( ) ;
}
return p ;
} ,
/ * G e t s p o s i t i o n
=== === === === === === === === === === === === === === === === == * /
//VMM.Element.position(element);
position : function ( element ) {
var p ;
if ( typeof ( jQuery ) != 'undefined' ) {
p = jQuery ( element ) . position ( ) ;
}
return p ;
} ,
/ * S e t s o r g e t s t h e w i d t h o f a d o m e l e m e n t
=== === === === === === === === === === === === === === === === == * /
//VMM.Element.width(element, s);
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 ( ) ;
}
}
} ,
/ * S e t s o r g e t s t h e w i d t h o f a d o m e l e m e n t
=== === === === === === === === === === === === === === === === == * /
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 ( ) ;
}
}
} ,
/ * T O G G L E C L A S S
=== === === === === === === === === === === === === === === === == * /
// VMM.Element.toggleClass(element, cName);
toggleClass : function ( element , cName ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . toggleClass ( cName ) ;
}
} ,
/ * E a c h
=== === === === === === === === === === === === === === === === == * /
// VMM.Element.each(element, return_function);
each : function ( element , return _function ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . each ( return _function ) ;
}
} ,
/ * E a c h
=== === === === === === === === === === === === === === === === == * /
// VMM.Element.html(element, str);
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 ;
}
}
} ,
/ * F i n d
=== === === === === === === === === === === === === === === === == * /
// VMM.Element.find(element, selec);
find : function ( element , selec ) {
if ( typeof ( jQuery ) != 'undefined' ) {
return jQuery ( element ) . find ( selec ) ;
}
} ,
/ * A n i m a t e
=== === === === === === === === === === === === === === === === == * /
// VMM.Element.stop(element);
stop : function ( element ) {
if ( typeof ( jQuery ) != 'undefined' ) {
jQuery ( element ) . stop ( ) ;
}
} ,
// VMM.Element.animate(element, duration, ease, att, callback_function);
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 . Element . css ( element , '-webkit-transition' , 'all ' + _ _duration + ' ease' ) ;
VMM . Element . css ( element , '-moz-transition' , 'all ' + _ _duration + ' ease' ) ;
VMM . Element . css ( element , '-o-transition' , 'all ' + _ _duration + ' ease' ) ;
VMM . Element . css ( element , '-ms-transition' , 'all ' + _ _duration + ' ease' ) ;
VMM . Element . css ( element , 'transition' , 'all ' + _ _duration + ' ease' ) ;
VMM . Element . cssmultiple ( element , _att ) ;
//callback_function();
/ *
if ( typeof ( jQuery ) != 'undefined' ) {
if ( callback _function != null && callback _function != "" ) {
$ ( element ) . animate ( _att , { queue : false , duration : _duration , easing : "ease" , complete : callback _function } ) ;
} else {
$ ( 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 } ) ;
}
}
}
/ *
VMM . Element . cssmultiple ( element , {
'-webkit-transition' : 'all 1s ease-in-out' ,
'-moz-transition' : 'all 1s ease-in-out' ,
'-o-transition' : 'all 1s ease-in-out' ,
'-ms-transition' : 'all 1s ease-in-out' ,
'transition' : 'all 1s ease-in-out' ,
} ) ;
* /
} ,
} ) . init ( ) ;
/ * T O U C H
=== === === === === === === === === === === === === === === === == * /
// 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 . preventDefault ( ) ;
e . stopPropagation ( ) ;
return true ;
} ,
onTouchEnd : function ( e ) {
e . preventDefault ( ) ;
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 . Element . css ( elem , 'left' ) . substring ( 0 , VMM . Element . css ( elem , 'left' ) . length - 2 ) , 10 ) ;
} ,
getTop : function ( elem ) {
return parseInt ( VMM . Element . css ( elem , 'top' ) . substring ( 0 , VMM . Element . css ( elem , 'top' ) . length - 2 ) , 10 ) ;
} ,
touchStart : function ( elem , e ) {
VMM . Element . 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 . Element . animate ( elem , 1000 , "" , { "top" : 0 } ) ;
} else {
VMM . Element . 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 . Element . animate ( elem , 500 , "" , { "left" : Math . min ( 0 , newLeft ) } ) ;
}
* /
VMM . TouchSlider . startX = null ;
VMM . TouchSlider . startY = null ;
} ,
doSlide : function ( elem , x , duration ) {
VMM . Element . css ( elem , '-webkit-transition-property' , 'left' ) ;
VMM . Element . css ( elem , '-webkit-transition-duration' , duration ) ;
VMM . Element . 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 . Element . 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 . Element . 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 . Element . 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 . Element . css ( elem , 'left' , - ( VMM . TouchSlider . startX - e . originalEvent . touches [ 0 ] . screenX - VMM . TouchSlider . startLeft ) ) ;
VMM . TouchSlider . slidingLeft = false ;
}
}
}
}
// 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 ) ;
}
} ;
/ * D R A G
=== === === === === === === === === === === === === === === === == * /
// 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 . Element . width ( delem ) ;
// CANCEL CURRENT ANIMATION IF ANIMATING
var _newx = Math . round ( VMM . DragSlider . startX - e . pageX - VMM . DragSlider . startLeft ) ;
VMM . Element . 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.Element.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 . Element . 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 . Element . 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 . Element . animate ( elem , _r _object . time , _ease , { "left" : _r _object . left } ) ;
} ;
//VMM.DragSlider.startX = null;
} ,
getLeft : function ( elem ) {
return parseInt ( VMM . Element . css ( elem , 'left' ) . substring ( 0 , VMM . Element . css ( elem , 'left' ) . length - 2 ) , 10 ) ;
}
}
/ * D E V I C E
=== === === === === === === === === === === === === === === === == * /
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 ) ;
} ,
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 < data . length ; i ++ ) {
var dataString = data [ i ] . string ;
var dataProp = data [ i ] . prop ;
this . versionSearchString = data [ i ] . versionSearch || data [ i ] . identity ;
if ( dataString ) {
if ( dataString . indexOf ( data [ i ] . subString ) != - 1 )
return data [ i ] . identity ;
}
else if ( dataProp )
return data [ i ] . identity ;
}
} ,
searchVersion : function ( dataString ) {
var index = dataString . indexOf ( this . versionSearchString ) ;
if ( index == - 1 ) return ;
return parseFloat ( dataString . substring ( index + this . versionSearchString . length + 1 ) ) ;
} ,
dataBrowser : [
{
string : navigator . userAgent ,
subString : "Chrome" ,
identity : "Chrome"
} ,
{ string : navigator . userAgent ,
subString : "OmniWeb" ,
versionSearch : "OmniWeb/" ,
identity : "OmniWeb"
} ,
{
string : navigator . vendor ,
subString : "Apple" ,
identity : "Safari" ,
versionSearch : "Version"
} ,
{
prop : window . opera ,
identity : "Opera" ,
versionSearch : "Version"
} ,
{
string : navigator . vendor ,
subString : "iCab" ,
identity : "iCab"
} ,
{
string : navigator . vendor ,
subString : "KDE" ,
identity : "Konqueror"
} ,
{
string : navigator . userAgent ,
subString : "Firefox" ,
identity : "Firefox"
} ,
{
string : navigator . vendor ,
subString : "Camino" ,
identity : "Camino"
} ,
{ // for newer Netscapes (6+)
string : navigator . userAgent ,
subString : "Netscape" ,
identity : "Netscape"
} ,
{
string : navigator . userAgent ,
subString : "MSIE" ,
identity : "Explorer" ,
versionSearch : "MSIE"
} ,
{
string : navigator . userAgent ,
subString : "Gecko" ,
identity : "Mozilla" ,
versionSearch : "rv"
} ,
{ // for older Netscapes (4-)
string : navigator . userAgent ,
subString : "Mozilla" ,
identity : "Netscape" ,
versionSearch : "Mozilla"
}
] ,
dataOS : [
{
string : navigator . platform ,
subString : "Win" ,
identity : "Windows"
} ,
{
string : navigator . platform ,
subString : "Mac" ,
identity : "Mac"
} ,
{
string : navigator . userAgent ,
subString : "iPhone" ,
identity : "iPhone/iPod"
} ,
{
string : navigator . userAgent ,
subString : "iPad" ,
identity : "iPad"
} ,
{
string : navigator . platform ,
subString : "Linux" ,
identity : "Linux"
}
]
}
VMM . Browser . init ( ) ;
/ * M E D I A T Y P E
=== === === === === === === === === === === === === === === === == * /
VMM . MediaElement = ( {
init : function ( ) {
return this ;
} ,
// somestring = VMM.MediaElement.thumbnail(data);
thumbnail : function ( data , w , h ) {
_w = 32 ;
_h = 32 ;
if ( w != null && w != "" ) {
_w = w ;
}
if ( h != null && h != "" ) {
_h = h ;
}
if ( data . media != null && data . media != "" ) {
_valid = true ;
var mediaElem = "" ;
var m = { } ;
// MEDIA TYPE
m = VMM . MediaType ( data . media ) ; //returns an object with .type and .id
// CREATE MEDIA CODE
if ( m . type == "image" ) {
mediaElem = "<div class='thumbnail'><img src='" + m . id + "' width='" + _w + "px' height='" + _h + "px'></div>" ;
return mediaElem ;
} else if ( m . type == "flickr" ) {
mediaElem = "<div class='thumbnail'><img id='flickr_" + m . id + "_thumb' width='" + _w + "px' height='" + _h + "px'></div>" ;
return mediaElem ;
} else if ( m . type == "youtube" ) {
mediaElem = "<div class='thumbnail youtube'></div>" ;
return mediaElem ;
} else if ( m . type == "googledoc" ) {
mediaElem = "" ;
} else if ( m . type == "vimeo" ) {
mediaElem = "<div class='thumbnail vimeo'></div>" ;
return mediaElem ;
} else if ( m . type == "twitter" ) {
mediaElem = "<div class='thumbnail twitter'></div>" ;
return mediaElem ;
} else if ( m . type == "twitter-ready" ) {
mediaElem = "<div class='thumbnail twitter'></div>" ;
return mediaElem ;
} else if ( m . type == "soundcloud" ) {
mediaElem = "<div class='thumbnail soundcloud'></div>" ;
return mediaElem ;
} else if ( m . type == "google-map" ) {
mediaElem = "<div class='thumbnail map'></div>" ;
return mediaElem ;
} else if ( m . type == "unknown" ) {
mediaElem = "" ;
return mediaElem ;
} else if ( m . type == "website" ) {
mediaElem = "<div class='thumbnail website'></div>" ;
//mediaElem = "<div class='thumbnail'><img src='http://api.snapito.com/free/sc?url=" + m.id + "' width='" + _w + "px' height='" + _h + "px'></div>";
return mediaElem ;
} else {
mediaElem = "<div class='thumbnail'></div>" ;
return mediaElem ;
}
}
} ,
//VMM.MediaElement.create(element, data, returntrue);
create : function ( element , data , _ _return , w , h ) {
_return = _ _return ;
_w = 500 ;
_h = 400 ;
$mediacontainer = element ;
//VMM.MediaElement.container = element;
var _valid = false ;
if ( w != null && w != "" ) {
_w = w ;
}
if ( h != null && h != "" ) {
_h = h ;
}
if ( data . media != null && data . media != "" ) {
_valid = true ;
var mediaElem = "" ;
var captionElem = "" ;
var creditElem = "" ;
var m = { } ;
var media _height = ( _h - 50 ) ;
var isTextMedia = false ;
// CREDIT
if ( data . credit != null && data . credit != "" ) {
creditElem = "<div class='credit'>" + VMM . Util . linkify _with _twitter ( data . credit , "_blank" ) + "</div>" ;
}
// CAPTION
if ( data . caption != null && data . caption != "" ) {
captionElem = "<div class='caption'>" + VMM . Util . linkify _with _twitter ( data . caption , "_blank" ) + "</div>" ;
}
// MEDIA TYPE
m = VMM . MediaType ( data . media ) ; //returns an object with .type and .id
// CREATE MEDIA CODE
if ( m . type == "image" ) {
mediaElem = "<img src='" + m . id + "'>" ;
} else if ( m . type == "flickr" ) {
var flickr _id = "flickr_" + m . id ;
mediaElem = "<a href='" + m . link + "' target='_blank'><img id='" + flickr _id + "_large" + "'></a>" ;
VMM . ExternalAPI . flickr . getPhoto ( m . id , "#" + flickr _id ) ;
} else if ( m . type == "googledoc" ) {
if ( m . id . match ( /docs.google.com/i ) ) {
mediaElem = "<iframe class='media-frame doc' frameborder='0' width='100%' height='100%' src='" + m . id + "&embedded=true'></iframe>" ;
} else {
mediaElem = "<iframe class='media-frame doc' frameborder='0' width='100%' height='100%' src='http://docs.google.com/viewer?url=" + m . id + "&embedded=true'></iframe>" ;
}
} else if ( m . type == "youtube" ) {
mediaElem = "<div class='media-frame video youtube' id='youtube_" + m . id + "'>Loading YouTube video...</div>" ;
VMM . ExternalAPI . youtube . init ( m . id ) ;
//mediaElem = "<iframe class='media-frame youtube' onload='timeline.iframeLoaded()' frameborder='0' width='100%' height='100%' src='http://www.youtube.com/embed/" + m.id + "?&rel=0&theme=light&showinfo=0&hd=1&autohide=0&color=white&enablejsapi=1' allowfullscreen></iframe>";
} else if ( m . type == "vimeo" ) {
mediaElem = "<iframe class='media-frame video vimeo' frameborder='0' width='100%' height='100%' src='http://player.vimeo.com/video/" + m . id + "?title=0&byline=0&portrait=0&color=ffffff'></iframe>" ;
} else if ( m . type == "twitter" ) {
mediaElem = "<div class='twitter' id='" + "twitter_" + m . id + "'>Loading Tweet</div>" ;
//VMM.ExternalAPI.twitter.getHTML(m.id);
trace ( "TWITTER" ) ;
VMM . ExternalAPI . twitter . prettyHTML ( m . id ) ;
isTextMedia = true ;
} else if ( m . type == "twitter-ready" ) {
mediaElem = m . id ;
} else if ( m . type == "soundcloud" ) {
var soundcloud _id = "soundcloud_" + VMM . Util . unique _ID ( 5 ) ;
mediaElem = "<div class='media-frame soundcloud' id='" + soundcloud _id + "'>Loading Sound</div>" ;
VMM . ExternalAPI . soundcloud . getSound ( m . id , soundcloud _id )
} else if ( m . type == "google-map" ) {
//mediaElem = "<iframe class='media-frame map' frameborder='0' width='100%' height='100%' scrolling='no' marginheight='0' marginwidth='0' src='" + m.id + "&output=embed'></iframe>"
var map _id = "googlemap_" + VMM . Util . unique _ID ( 7 ) ;
mediaElem = "<div class='media-frame map' id='" + map _id + "'>Loading Map...</div>" ;
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 = "<iframe class='media-frame' frameborder='0' width='100%' height='100%' scrolling='yes' marginheight='0' marginwidth='0' src='" + m . id + "'></iframe>" ;
//mediaElem = "<a href='" + m.id + "' target='_blank'>" + "<img src='http://api.snapito.com/free/lc?url=" + m.id + "'></a>";
} else {
trace ( "NO KNOWN MEDIA TYPE FOUND" ) ;
trace ( m . type ) ;
}
// WRAP THE MEDIA ELEMENT
mediaElem = "<div class='media-container' >" + mediaElem + creditElem + captionElem + "</div>" ;
if ( _return ) {
if ( isTextMedia ) {
return "<div class='media text-media'><div class='media-wrapper'>" + mediaElem + "</div></div>" ;
} else {
return "<div class='media'><div class='media-wrapper'>" + mediaElem + "</div></div>" ;
}
} else {
VMM . appendElement ( $mediacontainer , mediaElem ) ;
VMM . appendElement ( $mediacontainer , creditElem ) ;
VMM . appendElement ( $mediacontainer , captionElem ) ;
}
} ;
} ,
} ) . init ( ) ;
//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 ( 'embed' ) ) {
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];
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 ;
}
//VMM.FileExtention.googleDocType(url);
VMM . FileExtention = {
googleDocType : function ( url ) {
var fileName = url ;
var fileExtension = "" ;
//fileExtension = fileName.substr(5);
fileExtension = fileName . substr ( fileName . length - 5 , 5 ) ;
var validFileExtensions = [ "DOC" , "DOCX" , "XLS" , "XLSX" , "PPT" , "PPTX" , "PDF" , "PAGES" , "AI" , "PSD" , "TIFF" , "DXF" , "SVG" , "EPS" , "PS" , "TTF" , "XPS" , "ZIP" , "RAR" ] ;
var flag = false ;
for ( var i = 0 ; i < validFileExtensions . length ; i ++ ) {
if ( fileExtension . toLowerCase ( ) . match ( validFileExtensions [ i ] . toString ( ) . toLowerCase ( ) ) || fileName . match ( "docs.google.com" ) ) {
flag = true ;
}
}
return flag ;
}
}
VMM . ExternalAPI = {
twitter : {
tweetArray : [ ] ,
// VMM.ExternalAPI.twitter.getHTML(id);
getHTML : function ( id ) {
//var the_url = document.location.protocol + "//api.twitter.com/1/statuses/oembed.json?id=" + id+ "&callback=?";
var the _url = "http://api.twitter.com/1/statuses/oembed.json?id=" + id + "&callback=?" ;
VMM . getJSON ( the _url , VMM . ExternalAPI . twitter . onJSONLoaded ) ;
} ,
onJSONLoaded : function ( d ) {
trace ( "TWITTER JSON LOADED" ) ;
var id = d . id ;
VMM . attachElement ( "#" + id , VMM . Util . linkify _with _twitter ( d . html ) ) ;
} ,
// VMM.ExternalAPI.twitter.parseTwitterDate(date);
parseTwitterDate : function ( d ) {
var date = new Date ( Date . parse ( d ) ) ;
/ *
var t = d . replace ( /(\d{1,2}[:]\d{2}[:]\d{2}) (.*)/ , '$2 $1' ) ;
t = t . replace ( /(\+\S+) (.*)/ , '$2 $1' ) ;
var date = new Date ( Date . parse ( t ) ) . toLocaleDateString ( ) ;
var time = new Date ( Date . parse ( t ) ) . toLocaleTimeString ( ) ;
* /
return date ;
} ,
prettyParseTwitterDate : function ( d ) {
var date = new Date ( Date . parse ( d ) ) ;
return VMM . Util . date . prettyDate ( date , true ) ;
} ,
// VMM.ExternalAPI.twitter.getTweets(tweets_array);
getTweets : function ( tweets ) {
var tweetArray = [ ] ;
var number _of _tweets = tweets . length ;
for ( var i = 0 ; i < tweets . length ; i ++ ) {
var twitter _id = "" ;
/ * F I N D T H E T W I T T E R I D
=== === === === === === === === === === === === === === === === == * /
if ( tweets [ i ] . tweet . match ( "status\/" ) ) {
twitter _id = tweets [ i ] . tweet . split ( "status\/" ) [ 1 ] ;
} else if ( tweets [ i ] . tweet . match ( "statuses\/" ) ) {
twitter _id = tweets [ i ] . tweet . split ( "statuses\/" ) [ 1 ] ;
} else {
twitter _id = "" ;
}
/ * F E T C H T H E D A T A
=== === === === === === === === === === === === === === === === == * /
var the _url = "http://api.twitter.com/1/statuses/show.json?id=" + twitter _id + "&include_entities=true&callback=?" ;
VMM . getJSON ( the _url , function ( d ) {
var tweet = { }
/ * F O R M A T R E S P O N S E
=== === === === === === === === === === === === === === === === == * /
var twit = "<div class='twitter'><blockquote><p>" ;
var td = VMM . Util . linkify _with _twitter ( d . text , "_blank" ) ;
twit += td ;
twit += "</p>" ;
twit += "— " + d . user . name + " (<a href='https://twitter.com/" + d . user . screen _name + "'>@" + d . user . screen _name + "</a>) <a href='https://twitter.com/" + d . user . screen _name + "/status/" + d . id + "'>" + VMM . ExternalAPI . twitter . prettyParseTwitterDate ( d . created _at ) + " </a></blockquote></div>" ;
tweet . content = twit ;
tweet . raw = d ;
tweetArray . push ( tweet ) ;
/ * C H E C K I F T H A T S A L L O F T H E M
=== === === === === === === === === === === === === === === === == * /
if ( tweetArray . length == number _of _tweets ) {
var the _tweets = { tweetdata : tweetArray }
VMM . fireEvent ( global , "TWEETSLOADED" , the _tweets ) ;
}
} )
. success ( function ( ) { trace ( "second success" ) ; } )
. error ( function ( ) { trace ( "error" ) ; } )
. complete ( function ( ) { trace ( "complete" ) ; } ) ;
}
} ,
// VMM.ExternalAPI.twitter.getTweetSearch(search string);
getTweetSearch : function ( tweets , number _of _tweets ) {
var _number _of _tweets = 40 ;
if ( number _of _tweets != null && number _of _tweets != "" ) {
_number _of _tweets = number _of _tweets ;
}
var the _url = "http://search.twitter.com/search.json?q=" + tweets + "&rpp=" + _number _of _tweets + "&include_entities=true&result_type=mixed" ;
var tweetArray = [ ] ;
VMM . getJSON ( the _url , function ( d ) {
/ * F O R M A T R E S P O N S E
=== === === === === === === === === === === === === === === === == * /
for ( var i = 0 ; i < d . results . length ; i ++ ) {
var tweet = { }
var twit = "<div class='twitter'><blockquote><p>" ;
var td = VMM . Util . linkify _with _twitter ( d . results [ i ] . text , "_blank" ) ;
twit += td ;
twit += "</p>" ;
twit += "— " + d . results [ i ] . from _user _name + " (<a href='https://twitter.com/" + d . results [ i ] . from _user + "'>@" + d . results [ i ] . from _user + "</a>) <a href='https://twitter.com/" + d . results [ i ] . from _user + "/status/" + d . id + "'>" + VMM . ExternalAPI . twitter . prettyParseTwitterDate ( d . results [ i ] . created _at ) + " </a></blockquote></div>" ;
tweet . content = twit ;
tweet . raw = d . results [ i ] ;
tweetArray . push ( tweet ) ;
}
var the _tweets = { tweetdata : tweetArray }
VMM . fireEvent ( global , "TWEETSLOADED" , the _tweets ) ;
} ) ;
} ,
// VMM.ExternalAPI.twitter.prettyHTML(id);
prettyHTML : function ( id ) {
var id = id . toString ( ) ;
var error _obj = {
twitterid : id
} ;
var the _url = "http://api.twitter.com/1/statuses/show.json?id=" + id + "&include_entities=true&callback=?" ;
trace ( "id " + id ) ;
var twitter _timeout = setTimeout ( VMM . ExternalAPI . twitter . notFoundError , 4000 , id ) ;
VMM . getJSON ( the _url , VMM . ExternalAPI . twitter . formatJSON )
. error ( function ( jqXHR , textStatus , errorThrown ) {
trace ( "TWITTER error" ) ;
trace ( "TWITTER ERROR: " + textStatus + " " + jqXHR . responseText ) ;
VMM . attachElement ( "#twitter_" + id , "<p>ERROR LOADING TWEET " + id + "</p>" ) ;
} )
. success ( function ( ) {
clearTimeout ( twitter _timeout ) ;
} ) ;
} ,
notFoundError : function ( id ) {
trace ( "TWITTER JSON ERROR TIMEOUT " + id ) ;
VMM . attachElement ( "#twitter_" + id , "<p>TWEET NOT FOUND " + id + "</p>" ) ;
} ,
formatJSON : function ( d ) {
trace ( "TWITTER JSON LOADED F" ) ;
trace ( d ) ;
var id = d . id _str ;
var twit = "<blockquote><p>" ;
var td = VMM . Util . linkify _with _twitter ( d . text , "_blank" ) ;
//td = td.replace(/(@([\w]+))/g,"<a href='http://twitter.com/$2' target='_blank'>$1</a>");
//td = td.replace(/(#([\w]+))/g,"<a href='http://twitter.com/#search?q=%23$2' target='_blank'>$1</a>");
twit += td ;
twit += "</p></blockquote>" ;
twit += " <a href='https://twitter.com/" + d . user . screen _name + "/status/" + d . id + "' target='_blank' alt='link to original tweet' title='link to original tweet'>" + "<span class='created-at'></span>" + " </a>" ;
twit += "<div class='vcard author'>" ;
twit += "<a class='screen-name url' href='https://twitter.com/" + d . user . screen _name + "' data-screen-name='" + d . user . screen _name + "' target='_blank'>" ;
twit += "<span class='avatar'><img src=' " + d . user . profile _image _url + "' alt=''></span>" ;
twit += "<span class='fn'>" + d . user . name + "</span>" ;
twit += "<span class='nickname'>@" + d . user . screen _name + "</span>" ;
twit += "</a>" ;
twit += "</div>" ;
VMM . attachElement ( "#twitter_" + id . toString ( ) , twit ) ;
}
} ,
//VMM.ExternalAPI.googlemaps.getMap()
googlemaps : {
/ *
//http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_US&z={z}&x={x}&y={y}&v=9
http : //maps.google.com/maps?q=chicago&hl=en&sll=41.874961,-87.619054&sspn=0.159263,0.351906&t=t&hnear=Chicago,+Cook,+Illinois&z=11&output=kml
http : //maps.google.com/maps/ms?msid=215143221704623082244.0004a53ad1e3365113a32&msa=0
http : //maps.google.com/maps/ms?msid=215143221704623082244.0004a53ad1e3365113a32&msa=0&output=kml
http : //maps.google.com/maps/ms?msid=215143221704623082244.0004a21354b1a2f188082&msa=0&ll=38.719738,-9.142599&spn=0.04172,0.087976&iwloc=0004a214c0e99e2da91e0
http : //maps.google.com/maps?q=Bavaria&hl=en&ll=47.597829,9.398804&spn=1.010316,2.709503&sll=37.0625,-95.677068&sspn=73.579623,173.408203&hnear=Bavaria,+Germany&t=m&z=10&output=embed
* /
getMap : function ( url , id ) {
var map _vars = VMM . Util . getUrlVars ( url ) ;
trace ( map _vars ) ;
var map _url = "http://maps.googleapis.com/maps/api/js?key=" + Aes . Ctr . decrypt ( VMM . master _config . keys . google , VMM . master _config . vp , 256 ) + "&libraries=places&sensor=false&callback=VMM.ExternalAPI.googlemaps.onMapAPIReady" ;
var map = {
url : url ,
vars : map _vars ,
id : id
}
if ( VMM . master _config . googlemaps . active ) {
VMM . master _config . googlemaps . createMap ( map ) ;
} else {
VMM . master _config . googlemaps . que . push ( map ) ;
if ( VMM . master _config . googlemaps . api _loaded ) {
} else {
VMM . LoadLib . js ( map _url , function ( ) {
trace ( "Google Maps API Library Loaded" ) ;
} ) ;
}
}
} ,
onMapAPIReady : function ( ) {
VMM . master _config . googlemaps . map _active = true ;
VMM . master _config . googlemaps . places _active = true ;
VMM . ExternalAPI . googlemaps . onAPIReady ( ) ;
} ,
onPlacesAPIReady : function ( ) {
VMM . master _config . googlemaps . places _active = true ;
VMM . ExternalAPI . googlemaps . onAPIReady ( ) ;
} ,
onAPIReady : function ( ) {
if ( ! VMM . master _config . googlemaps . active ) {
if ( VMM . master _config . googlemaps . map _active && VMM . master _config . googlemaps . places _active ) {
VMM . master _config . googlemaps . active = true ;
for ( var i = 0 ; i < VMM . master _config . googlemaps . que . length ; i ++ ) {
VMM . ExternalAPI . googlemaps . createMap ( VMM . master _config . googlemaps . que [ i ] ) ;
}
}
}
} ,
map _subdomains : [ "" , "a." , "b." , "c." , "d." ] ,
map _attribution : {
"stamen" : "Map tiles by <a href='http://stamen.com'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0'>CC BY SA</a>." ,
"apple" : "Map data © 2012 Apple, Imagery © 2012 Apple"
} ,
map _providers : {
"toner" : {
"url" : "http://{S}tile.stamen.com/toner/{Z}/{X}/{Y}.png" ,
"minZoom" : 0 ,
"maxZoom" : 20 ,
"attribution" : "stamen"
} ,
"toner-lines" : {
"url" : "http://{S}tile.stamen.com/toner-lines/{Z}/{X}/{Y}.png" ,
"minZoom" : 0 ,
"maxZoom" : 20 ,
"attribution" : "stamen"
} ,
"toner-labels" : {
"url" : "http://{S}tile.stamen.com/toner-labels/{Z}/{X}/{Y}.png" ,
"minZoom" : 0 ,
"maxZoom" : 20 ,
"attribution" : "stamen"
} ,
"sterrain" : {
"url" : "http://{S}tile.stamen.com/terrain/{Z}/{X}/{Y}.jpg" ,
"minZoom" : 4 ,
"maxZoom" : 20 ,
"attribution" : "stamen"
} ,
"apple" : {
"url" : "http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_US&z={z}&x={x}&y={y}&v=9" ,
"minZoom" : 4 ,
"maxZoom" : 20 ,
"attribution" : "apple"
} ,
"watercolor" : {
"url" : "http://{S}tile.stamen.com/watercolor/{Z}/{X}/{Y}.jpg" ,
"minZoom" : 3 ,
"maxZoom" : 16 ,
"attribution" : "stamen"
}
} ,
createMap : function ( m ) {
trace ( VMM . ExternalAPI . googlemaps . stamen _map _attribution ) ;
/ * M A P P R O V I D E R S
Including Stamen Maps
http : //maps.stamen.com/
Except otherwise noted , each of these map tile sets are © Stamen Design , under a Creative Commons Attribution ( CC BY 3.0 ) license .
=== === === === === === === === === === === === === === === === == * /
var map _attribution = "" ;
function mapProvider ( name ) {
if ( name in VMM . ExternalAPI . googlemaps . map _providers ) {
map _attribution = VMM . ExternalAPI . googlemaps . map _attribution [ VMM . ExternalAPI . googlemaps . map _providers [ name ] . attribution ] ;
return VMM . ExternalAPI . googlemaps . map _providers [ name ] ;
} else {
throw 'No such provider: "' + name + '"' ;
}
}
google . maps . VeriteMapType = function ( name ) {
var provider = mapProvider ( name ) ;
return google . maps . ImageMapType . call ( this , {
"getTileUrl" : function ( coord , zoom ) {
var index = ( zoom + coord . x + coord . y ) % VMM . ExternalAPI . googlemaps . map _subdomains . length ;
return [
provider . url
. replace ( "{S}" , VMM . ExternalAPI . googlemaps . map _subdomains [ index ] )
. replace ( "{Z}" , zoom )
. replace ( "{X}" , coord . x )
. replace ( "{Y}" , coord . y )
. replace ( "{z}" , zoom )
. replace ( "{x}" , coord . x )
. replace ( "{y}" , coord . y )
] ;
} ,
"tileSize" : new google . maps . Size ( 256 , 256 ) ,
"name" : name ,
"minZoom" : provider . minZoom ,
"maxZoom" : provider . maxZoom
} ) ;
} ;
google . maps . VeriteMapType . prototype = new google . maps . ImageMapType ( "_" ) ;
/ * M a k e t h e M a p
=== === === === === === === === === === === === === === === === == * /
var layer ;
if ( type . of ( VMM . master _config . Timeline . maptype ) == "string" ) {
layer = VMM . master _config . Timeline . maptype ;
} else {
layer = "toner" ;
}
var location = new google . maps . LatLng ( 41.875696 , - 87.624207 ) ;
var latlong ;
var zoom = 11 ;
var has _location = false ;
var has _zoom = false ;
var map _bounds ;
if ( type . of ( VMM . Util . getUrlVars ( m . url ) [ "ll" ] ) == "string" ) {
has _location = true ;
latlong = VMM . Util . getUrlVars ( m . url ) [ "ll" ] . split ( "," ) ;
location = new google . maps . LatLng ( parseFloat ( latlong [ 0 ] ) , parseFloat ( latlong [ 1 ] ) ) ;
} else if ( type . of ( VMM . Util . getUrlVars ( m . url ) [ "sll" ] ) == "string" ) {
has _location = true ;
latlong = VMM . Util . getUrlVars ( m . url ) [ "sll" ] . split ( "," ) ;
location = new google . maps . LatLng ( parseFloat ( latlong [ 0 ] ) , parseFloat ( latlong [ 1 ] ) ) ;
}
if ( type . of ( VMM . Util . getUrlVars ( m . url ) [ "z" ] ) == "string" ) {
has _zoom = true ;
zoom = parseFloat ( VMM . Util . getUrlVars ( m . url ) [ "z" ] ) ;
}
var map _options = {
zoom : zoom ,
disableDefaultUI : true ,
mapTypeControl : false ,
zoomControl : true ,
zoomControlOptions : {
style : google . maps . ZoomControlStyle . SMALL ,
position : google . maps . ControlPosition . TOP _RIGHT
} ,
center : location ,
mapTypeId : layer ,
mapTypeControlOptions : {
mapTypeIds : [ layer ]
}
}
var unique _map _id = m . id . toString ( ) + "_gmap" ;
VMM . attachElement ( "#" + m . id , "<div class='google-map' id='" + unique _map _id + "' style='width=100%;height=100%;'></div>" ) ;
/ * A T T R I B U T I O N
=== === === === === === === === === === === === === === === === == * /
//var map_attribution_html = "<div class='map-attribution'><div class='attribution-text'>" + map_attribution + "</div></div>";
//VMM.appendElement("#" + m.id, map_attribution_html);
var map = new google . maps . Map ( document . getElementById ( unique _map _id ) , map _options ) ;
map . mapTypes . set ( layer , new google . maps . VeriteMapType ( layer ) ) ;
/ * A T T R I B U T I O N
=== === === === === === === === === === === === === === === === == * /
var map _attribution _html = "<div class='map-attribution'><div class='attribution-text'>" + map _attribution + "</div></div>" ;
VMM . appendElement ( "#" + unique _map _id , map _attribution _html ) ;
//.map-attribution
//.attribution-text
loadKML ( ) ;
/ * K M L
=== === === === === === === === === === === === === === === === == * /
function loadKML ( ) {
var kml _url = m . url + "&output=kml" ;
kml _url = kml _url . replace ( "&output=embed" , "" ) ;
var kml _layer = new google . maps . KmlLayer ( kml _url , { preserveViewport : true } ) ;
kml _layer . setMap ( map ) ;
var infowindow = new google . maps . InfoWindow ( ) ;
google . maps . event . addListenerOnce ( kml _layer , "defaultviewport_changed" , function ( ) {
if ( has _location ) {
map . panTo ( location ) ;
}
if ( has _zoom ) {
map . setZoom ( zoom ) ;
} else {
map . fitBounds ( kml _layer . getDefaultViewport ( ) ) ;
}
} ) ;
google . maps . event . addListener ( kml _layer , 'click' , function ( kmlEvent ) {
var text = kmlEvent . featureData . description ;
trace ( kmlEvent . featureData . infoWindowHtml )
showInfoWindow ( text ) ;
function showInfoWindow ( c ) {
//trace("showInfoWindow")
infowindow . setContent ( c ) ;
infowindow . open ( map ) ;
}
} ) ;
}
} ,
} ,
//VMM.ExternalAPI.flickr.getPhoto(mediaID, htmlID);
flickr : {
getPhoto : function ( mid , id ) {
// 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=" + Aes . Ctr . decrypt ( VMM . master _config . keys . flickr , VMM . master _config . vp , 256 ) + "&photo_id=" + mid + "&format=json&jsoncallback=?" ;
VMM . getJSON ( the _url , VMM . ExternalAPI . flickr . setPhoto ) ;
} ,
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" ;
// FIND LARGE SIZE
var flickr _img _large ;
var flickr _large _found = false ;
for ( var i = 0 ; i < d . sizes . size . length ; i ++ ) {
if ( d . sizes . size [ i ] . label == "Large" ) {
flickr _large _found = true ;
flickr _img _large = d . sizes . size [ i ] . source ;
}
}
if ( ! flickr _large _found ) {
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?url=" + url + "&format=js&callback=?" ;
VMM . getJSON ( the _url , function ( d ) {
VMM . attachElement ( "#" + id , d . html ) ;
} ) ;
} ,
} ,
// VMM.ExternalAPI.youtube.init(id);
youtube : {
init : function ( id ) {
if ( VMM . master _config . youtube . active ) {
VMM . master _config . youtube . createPlayer ( id ) ;
} else {
VMM . master _config . youtube . que . push ( id ) ;
if ( VMM . master _config . youtube . api _loaded ) {
} else {
VMM . LoadLib . js ( 'http://www.youtube.com/player_api' , function ( ) {
trace ( "YouTube API Library Loaded" ) ;
} ) ;
}
}
} ,
onAPIReady : function ( ) {
trace ( "YOUTUBE API READY" )
VMM . master _config . youtube . active = true ;
for ( var i = 0 ; i < VMM . master _config . youtube . que . length ; i ++ ) {
VMM . ExternalAPI . youtube . createPlayer ( VMM . master _config . youtube . que [ i ] ) ;
}
} ,
// VMM.ExternalAPI.youtube.createPlayer(id);
createPlayer : function ( id ) {
var p = {
active : false ,
player : { } ,
name : 'youtube_' + id ,
playing : false
} ;
p . player [ 'youtube_' + id ] = new YT . Player ( 'youtube_' + id , {
height : '390' ,
width : '640' ,
playerVars : {
enablejsapi : 1 ,
color : 'white' ,
showinfo : 0 ,
theme : 'light' ,
rel : 0 ,
origin : 'http://timeline.verite.co'
} ,
videoId : id ,
events : {
'onReady' : VMM . ExternalAPI . youtube . onPlayerReady ,
'onStateChange' : VMM . ExternalAPI . youtube . onStateChange
}
} ) ;
VMM . master _config . youtube . array . push ( p ) ;
} ,
//VMM.ExternalAPI.youtube.stopPlayers();
stopPlayers : function ( ) {
for ( var i = 0 ; i < VMM . master _config . youtube . array . length ; i ++ ) {
if ( VMM . master _config . youtube . array [ i ] . playing ) {
var the _name = VMM . master _config . youtube . array [ i ] . name ;
VMM . master _config . youtube . array [ i ] . player [ the _name ] . stopVideo ( ) ;
}
}
} ,
onStateChange : function ( e ) {
for ( var i = 0 ; i < VMM . master _config . youtube . array . length ; i ++ ) {
var the _name = VMM . master _config . youtube . array [ i ] . name ;
if ( VMM . master _config . youtube . array [ i ] . player [ the _name ] == e . target ) {
if ( e . data == YT . PlayerState . PLAYING ) {
VMM . master _config . youtube . array [ i ] . playing = true ;
}
}
}
} ,
onPlayerReady : function ( e ) {
}
}
}
/ * M E D I A
=== === === === === === === === === === === === === === === === == * /
// something = new VMM.Media(parent, w, h, {thedata});
VMM . Media = function ( parent , w , h , thedata ) {
/ * P R I V A T E V A R S
=== === === === === === === === === === === === === === === === == * /
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
} ;
/ * E L E M E N T S
=== === === === === === === === === === === === === === === === == * /
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 ) ;
}
* /
/ * P U B L I C F U N C T I O N S
=== === === === === === === === === === === === === === === === == * /
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 , "<div>" , "media" ) ;
$container = VMM . appendAndGetElement ( $media , "<div>" , "container" ) ;
$mediacontainer = VMM . appendAndGetElement ( $container , "<div>" , "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 , "<img src='" + m . id + "'>" ) ;
} else if ( m . type == "youtube" ) {
VMM . appendElement ( $mediacontainer , "<iframe frameborder='0' src='http://www.youtube.com/embed/" + m . id + "?&rel=0&theme=light&showinfo=0&hd=1&autohide=0&color=white' allowfullscreen>" ) ;
} else if ( m . type == "vimeo" ) {
VMM . appendElement ( $mediacontainer , "<iframe frameborder='0' src='http://player.vimeo.com/video/" + m . id + "?title=0&byline=0&portrait=0&color=ffffff'>" ) ;
} else {
}
// CREDIT
if ( data . credit != null && data . credit != "" ) {
VMM . appendElement ( $container , VMM . createElement ( "div" , data . credit , "credit" ) ) ;
}
// CAPTION
if ( data . caption != null && data . caption != "" ) {
VMM . appendElement ( $container , VMM . createElement ( "div" , data . caption , "caption" ) ) ;
}
}
} ;
/ * G E T T E R S A N D S E T T E R S
=== === === === === === === === === === === === === === === === == * /
this . setData = function ( d ) {
if ( typeof d != 'undefined' ) {
data = d ;
build ( ) ;
} else {
trace ( "NO DATA" ) ;
}
} ;
/ * R E S I Z E
=== === === === === === === === === === === === === === === === == * /
function reSize ( ) {
}
}
// Less expensive to use prototype
VMM . Media . prototype . height = function ( h ) {
if ( h != null && h != "" ) {
config . height = h ;
reSize ( ) ;
} else {
return config . height ;
}
} ;
VMM . Media . prototype . width = function ( w ) {
if ( w != null && w != "" ) {
config . width = w ;
reSize ( ) ;
} else {
return config . width ;
}
} ;
/ * G E T T E R S A N D S E T T E R S
=== === === === === === === === === === === === === === === === == * /
VMM . Media . prototype . getData = function ( ) {
return data ;
} ;
VMM . Media . prototype . setConfig = function ( d ) {
if ( typeof d != 'undefined' ) {
config = d ;
} else {
trace ( "NO CONFIG DATA" ) ;
}
} ;
VMM . Media . prototype . getConfig = function ( ) {
return config ;
} ;
VMM . Media . prototype . setSize = function ( w , h ) {
if ( w != null ) { config . width = w } ;
if ( h != null ) { config . height = h } ;
if ( _active ) {
reSize ( ) ;
}
}
VMM . Media . prototype . active = function ( ) {
return _active ;
} ;
}
/ * T r a c e ( c o n s o l e . l o g )
=== === === === === === === === === === === === === === === === == * /
function trace ( msg ) {
if ( window . console ) {
console . log ( msg ) ;
} else if ( typeof ( jsTrace ) != 'undefined' ) {
jsTrace . send ( msg ) ;
} else {
//alert(msg);
}
}
/ * E x t e n d i n g D a t e t o i n c l u d e W e e k
=== === === === === === === === === === === === === === === === == * /
Date . prototype . getWeek = function ( ) {
var onejan = new Date ( this . getFullYear ( ) , 0 , 1 ) ;
return Math . ceil ( ( ( ( this - onejan ) / 86400000 ) + onejan . getDay ( ) + 1 ) / 7 ) ;
}
/ * E x t e n d i n g D a t e t o i n c l u d e D a y o f Y e a r
=== === === === === === === === === === === === === === === === == * /
Date . prototype . getDayOfYear = function ( ) {
var onejan = new Date ( this . getFullYear ( ) , 0 , 1 ) ;
return Math . ceil ( ( this - onejan ) / 86400000 ) ;
}
/ * A M O R E S P E C I F I C T Y P E O F ( ) ;
// 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 ( ) ;
}
}
}
} ;
/ * Y O U T U B E A P I R E A D Y
Can ' t find a way to customize this callback and keep it in the VMM namespace
Youtube wants it to be this function .
=== === === === === === === === === === === === === === === === == * /
function onYouTubePlayerAPIReady ( ) {
trace ( "GLOBAL YOUTUBE API CALLED" )
VMM . ExternalAPI . youtube . onAPIReady ( ) ;
}
/ * j Q u e r y E a s i n g v 1 . 3
http : //gsgd.co.uk/sandbox/jquery/easing/
=== === === === === === === === === === === === === === === === == * /
if ( typeof ( jQuery ) != 'undefined' ) {
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 ;
} ,
} ) ;
}