http://git-wip-us.apache.org/repos/asf/ambari/blob/f613d391/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/libs/other/timeline/js/timeline.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/libs/other/timeline/js/timeline.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/libs/other/timeline/js/timeline.js deleted file mode 100644 index 6d8324b..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/libs/other/timeline/js/timeline.js +++ /dev/null @@ -1,10116 +0,0 @@ -/* - TimelineJS - ver. 2015-06-10-16-17-35 - 2015-06-10 - Copyright (c) 2012-2015 Northwestern University - a project of the Northwestern University Knight Lab, originally created by Zach Wise - https://github.com/NUKnightLab/TimelineJS - This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. - If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -/* ********************************************** - Begin VMM.js -********************************************** */ - -/** - * VéritéCo JS Core - * Designed and built by Zach Wise at VéritéCo z...@verite.co - - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - -*/ - - -/* 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=", - google: "uQKadH1VMlCsp560gN2aOiMz4evWkl1s34yryl3F/9FJOsn+/948CbBUvKLN46U=", - twitter: "" - }, - - timers: { - api: 7000 - }, - - api: { - pushques: [] - - }, - - twitter: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - flickr: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - youtube: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - vimeo: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - vine: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - webthumb: { - 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: [] - }, - - googleplus: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - wikipedia: { - active: false, - array: [], - api_loaded: false, - que: [], - tries: 0 - }, - - 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 + "</" + 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; - - }; - - // 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 ) { - VMM.debug = false; - 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(); - } - } - } -}; - - - - - -/* ********************************************** - Begin VMM.Library.js -********************************************** */ - -/* * LIBRARY ABSTRACTION -================================================== */ -if(typeof VMM != 'undefined') { - - VMM.smoothScrollTo = function(elem, duration, ease) { - if( typeof( jQuery ) != 'undefined' ){ - var _ease = "easein", - _duration = 1000; - - if (duration != null) { - if (duration < 1) { - _duration = 1; - } else { - _duration = Math.round(duration); - } - - } - - if (ease != null && ease != "") { - _ease = ease; - } - - if (jQuery(window).scrollTop() != VMM.Lib.offset(elem).top) { - VMM.Lib.animate('html,body', _duration, _ease, {scrollTop: VMM.Lib.offset(elem).top}) - } - - } - - }; - - VMM.attachElement = function(element, content) { - if( typeof( jQuery ) != 'undefined' ){ - jQuery(element).html(content); - } - - }; - - VMM.appendElement = function(element, content) { - - if( typeof( jQuery ) != 'undefined' ){ - jQuery(element).append(content); - } - - }; - - VMM.getHTML = function(element) { - var e; - if( typeof( jQuery ) != 'undefined' ){ - e = jQuery(element).html(); - return e; - } - - }; - - 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 = 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 = 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 = 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 = function(url, data, callback) { - if( typeof( jQuery ) != 'undefined' ){ - jQuery.ajaxSetup({ - timeout: 3000 - }); - /* CHECK FOR IE - ================================================== */ - if ( VMM.Browser.browser == "Explorer" && - parseInt(VMM.Browser.version, 10) >= 7 && - window.XDomainRequest && - url.match('^https?://')) { - trace("old IE JSON doesn't like retrieving from different protocol"); - var colon = url.indexOf(':'); - url = url.substr(colon+1); - } - 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, - _tag = "<div>", - _class = "", - _content = "", - _id = ""; - - 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(); - } - }, - - delay_animate: function(delay, element, duration, ease, att, callback_function) { - if (VMM.Browser.device == "mobile" || VMM.Browser.device == "tablet") { - var _tdd = Math.round((duration/1500)*10)/10, - __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); - } else { - if( typeof( jQuery ) != 'undefined' ){ - jQuery(element).delay(delay).animate(att, {duration:duration, easing:ease} ); - } - } - - }, - - animate: function(element, duration, ease, att, que, callback_function) { - - var _ease = "easein", - _que = false, - _duration = 1000, - _att = {}; - - if (duration != null) { - if (duration < 1) { - _duration = 1; - } else { - _duration = Math.round(duration); - } - - } - - if (ease != null && ease != "") { - _ease = ease; - } - - if (que != null && que != "") { - _que = que; - } - - - 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, - __duration = _tdd + 's'; - - _ease = " cubic-bezier(0.33, 0.66, 0.66, 1)"; - //_ease = " ease-in-out"; - for (x in _att) { - if (Object.prototype.hasOwnProperty.call(_att, x)) { - trace(x + " to " + _att[x]); - VMM.Lib.css(element, '-webkit-transition', x + ' ' + __duration + _ease); - VMM.Lib.css(element, '-moz-transition', x + ' ' + __duration + _ease); - VMM.Lib.css(element, '-o-transition', x + ' ' + __duration + _ease); - VMM.Lib.css(element, '-ms-transition', x + ' ' + __duration + _ease); - VMM.Lib.css(element, 'transition', x + ' ' + __duration + _ease); - } - } - - VMM.Lib.cssmultiple(element, _att); - - } else { - if( typeof( jQuery ) != 'undefined' ){ - if (callback_function != null && callback_function != "") { - jQuery(element).animate(_att, {queue:_que, duration:_duration, easing:_ease, complete:callback_function} ); - } else { - jQuery(element).animate(_att, {queue:_que, 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; - } - }); -} - - -/* ********************************************** - Begin VMM.Browser.js -********************************************** */ - -/* * 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.tridentVersion = this.searchTridentVersion(navigator.userAgent); - this.OS = this.searchString(this.dataOS) || "an unknown OS"; - this.device = this.searchDevice(navigator.userAgent); - this.orientation = this.searchOrientation(window.orientation); - }, - searchOrientation: function(orientation) { - var orient = ""; - if ( orientation == 0 || orientation == 180) { - orient = "portrait"; - } else if ( orientation == 90 || orientation == -90) { - orient = "landscape"; - } else { - orient = "normal"; - } - return orient; - }, - searchDevice: function(d) { - var device = ""; - if (d.match(/Android/i) || d.match(/iPhone|iPod/i)) { - device = "mobile"; - } else if (d.match(/iPad/i)) { - device = "tablet"; - } else if (d.match(/BlackBerry/i) || d.match(/IEMobile/i)) { - device = "other mobile"; - } else { - device = "desktop"; - } - return device; - }, - searchString: function (data) { - for (var i=0;i<data.length;i++) { - var dataString = data[i].string, - 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)); - }, - searchTridentVersion: function (dataString) { - var index = dataString.indexOf("Trident/"); - if (index == -1) return 0; - return parseFloat(dataString.substring(index + 8)); - }, - 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(); -} - -/* ********************************************** - Begin VMM.FileExtention.js -********************************************** */ - -/* * File Extention -================================================== */ -if(typeof VMM != 'undefined' && typeof VMM.FileExtention == 'undefined') { - VMM.FileExtention = { - googleDocType: function(url) { - var fileName = url.replace(/\s\s*$/, ''), - fileExtension = "", - validFileExtensions = ["DOC","DOCX","XLS","XLSX","PPT","PPTX","PDF","PAGES","AI","PSD","TIFF","DXF","SVG","EPS","PS","TTF","XPS","ZIP","RAR"], - flag = false; - - fileExtension = fileName.substr(fileName.length - 5, 5); - - 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; - } - } -} - -/* ********************************************** - Begin VMM.Date.js -********************************************** */ - -/* * Utilities and Useful Functions -================================================== */ -if(typeof VMM != 'undefined' && typeof VMM.Date == 'undefined') { - - VMM.Date = ({ - - init: function() { - return this; - }, - - dateformats: { - year: "yyyy", - month_short: "mmm", - month: "mmmm yyyy", - full_short: "mmm d", - full: "mmmm d',' yyyy", - time_short: "h:MM:ss TT", - time_no_seconds_short: "h:MM TT", - time_no_seconds_small_date: "h:MM TT'<br/><small>'mmmm d',' yyyy'</small>'", - full_long: "mmm d',' yyyy 'at' hh:MM TT", - full_long_small_date: "hh:MM TT'<br/><small>mmm d',' yyyy'</small>'" - }, - - month: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], - month_abbr: ["Jan.", "Feb.", "March", "April", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."], - day: ["Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], - day_abbr: ["Sun.", "Mon.", "Tues.", "Wed.", "Thurs.", "Fri.", "Sat."], - hour: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], - hour_suffix: ["am"], - - //B.C. - bc_format: { - year: "yyyy", - month_short: "mmm", - month: "mmmm yyyy", - full_short: "mmm d", - full: "mmmm d',' yyyy", - time_no_seconds_short: "h:MM TT", - time_no_seconds_small_date: "dddd', 'h:MM TT'<br/><small>'mmmm d',' yyyy'</small>'", - full_long: "dddd',' mmm d',' yyyy 'at' hh:MM TT", - full_long_small_date: "hh:MM TT'<br/><small>'dddd',' mmm d',' yyyy'</small>'" - }, - - setLanguage: function(lang) { - trace("SET DATE LANGUAGE"); - VMM.Date.dateformats = lang.dateformats; - VMM.Date.month = lang.date.month; - VMM.Date.month_abbr = lang.date.month_abbr; - VMM.Date.day = lang.date.day; - VMM.Date.day_abbr = lang.date.day_abbr; - dateFormat.i18n.dayNames = lang.date.day_abbr.concat(lang.date.day); - dateFormat.i18n.monthNames = lang.date.month_abbr.concat(lang.date.month); - }, - - parse: function(d, precision) { - "use strict"; - var date, - date_array, - time_array, - time_parse, - p = { - year: false, - month: false, - day: false, - hour: false, - minute: false, - second: false, - millisecond: false - }; - - if (type.of(d) == "date") { - trace("DEBUG THIS, ITs A DATE"); - date = d; - } else { - date = new Date(0); - date.setMonth(0); date.setDate(1); date.setHours(0); date.setMinutes(0); date.setSeconds(0); date.setMilliseconds(0); - if ( d.match(/,/gi) ) { - date_array = d.split(","); - for(var i = 0; i < date_array.length; i++) { - date_array[i] = parseInt(date_array[i], 10); - } - if (date_array[0]) { - date.setFullYear(date_array[0]); - p.year = true; - } - if (date_array[1]) { - date.setMonth(date_array[1] - 1); - p.month = true; - } - if (date_array[2]) { - date.setDate(date_array[2]); - p.day = true; - } - if (date_array[3]) { - date.setHours(date_array[3]); - p.hour = true; - } - if (date_array[4]) { - date.setMinutes(date_array[4]); - p.minute = true; - } - if (date_array[5]) { - date.setSeconds(date_array[5]); - if (date_array[5] >= 1) { - p.second = true; - } - } - if (date_array[6]) { - date.setMilliseconds(date_array[6]); - if (date_array[6] >= 1) { - p.millisecond = true; - } - } - } else if (d.match("/")) { - if (d.match(" ")) { - - time_parse = d.split(" "); - if (d.match(":")) { - time_array = time_parse[1].split(":"); - if (time_array[0] >= 0 ) { - date.setHours(time_array[0]); - p.hour = true; - } - if (time_array[1] >= 0) { - date.setMinutes(time_array[1]); - p.minute = true; - } - if (time_array[2] >= 0) { - date.setSeconds(time_array[2]); - p.second = true; - } - if (time_array[3] >= 0) { - date.setMilliseconds(time_array[3]); - p.millisecond = true; - } - } - date_array = time_parse[0].split("/"); - } else { - date_array = d.split("/"); - } - if (date_array[2]) { - date.setFullYear(date_array[2]); - p.year = true; - } - if (date_array[0] >= 0) { - var month = date_array[0] - 1; - date.setMonth(month); - // if (date.getMonth() != month) { - // date.setMonth(month); // WTF javascript? - // } - p.month = true; - } - if (date_array[1] >= 0) { - if (date_array[1].length > 2) { - date.setFullYear(date_array[1]); - p.year = true; - } else { - date.setDate(date_array[1]); - p.day = true; - } - } - } else if (d.match("now")) { - var now = new Date(); - - date.setFullYear(now.getFullYear()); - p.year = true; - - date.setMonth(now.getMonth()); - p.month = true; - - date.setDate(now.getDate()); - p.day = true; - - if (d.match("hours")) { - date.setHours(now.getHours()); - p.hour = true; - } - if (d.match("minutes")) { - date.setHours(now.getHours()); - date.setMinutes(now.getMinutes()); - p.hour = true; - p.minute = true; - } - if (d.match("seconds")) { - date.setHours(now.getHours()); - date.setMinutes(now.getMinutes()); - date.setSeconds(now.getSeconds()); - p.hour = true; - p.minute = true; - p.second = true; - } - if (d.match("milliseconds")) { - date.setHours(now.getHours()); - date.setMinutes(now.getMinutes()); - date.setSeconds(now.getSeconds()); - date.setMilliseconds(now.getMilliseconds()); - p.hour = true; - p.minute = true; - p.second = true; - p.millisecond = true; - } - } else if (d.length <= 8) { - p.year = true; - date.setFullYear(parseInt(d, 10)); - date.setMonth(0); - date.setDate(1); - date.setHours(0); - date.setMinutes(0); - date.setSeconds(0); - date.setMilliseconds(0); - } else if (d.match("T")) { - if (navigator.userAgent.match(/MSIE\s(?!9.0)/)) { - // IE 8 < Won't accept dates with a "-" in them. - time_parse = d.split("T"); - if (d.match(":")) { - time_array = time_parse[1].split(":"); - if (time_array[0] >= 1) { - date.setHours(time_array[0]); - p.hour = true; - } - if (time_array[1] >= 1) { - date.setMinutes(time_array[1]); - p.minute = true; - } - if (time_array[2] >= 1) { - date.setSeconds(time_array[2]); - if (time_array[2] >= 1) { - p.second = true; - } - } - if (time_array[3] >= 1) { - date.setMilliseconds(time_array[3]); - if (time_array[3] >= 1) { - p.millisecond = true; - } - } - } - date_array = time_parse[0].split("-"); - if (date_array[0]) { - date.setFullYear(date_array[0]); - p.year = true; - } - if (date_array[1] >= 0) { - date.setMonth(date_array[1] - 1); - p.month = true; - } - if (date_array[2] >= 0) { - date.setDate(date_array[2]); - p.day = true; - } - - } else { - date = new Date(Date.parse(d)); - p.year = true; - p.month = true; - p.day = true; - p.hour = true; - p.minute = true; - if (date.getSeconds() >= 1) { - p.second = true; - } - if (date.getMilliseconds() >= 1) { - p.millisecond = true; - } - } - } else { - date = new Date( - parseInt(d.slice(0,4), 10), - parseInt(d.slice(4,6), 10) - 1, - parseInt(d.slice(6,8), 10), - parseInt(d.slice(8,10), 10), - parseInt(d.slice(10,12), 10) - ); - p.year = true; - p.month = true; - p.day = true; - p.hour = true; - p.minute = true; - if (date.getSeconds() >= 1) { - p.second = true; - } - if (date.getMilliseconds() >= 1) { - p.millisecond = true; - } - - } - - } - - if (precision != null && precision != "") { - return { - date: date, - precision: p - }; - } else { - return date; - } - }, - - - - prettyDate: function(d, is_abbr, p, d2) { - var _date, - _date2, - format, - bc_check, - is_pair = false, - bc_original, - bc_number, - bc_string; - - if (d2 != null && d2 != "" && typeof d2 != 'undefined') { - is_pair = true; - trace("D2 " + d2); - } - - - if (type.of(d) == "date") { - - if (type.of(p) == "object") { - if (p.millisecond || p.second && d.getSeconds() >= 1) { - // YEAR MONTH DAY HOUR MINUTE - if (is_abbr){ - format = VMM.Date.dateformats.time_short; - } else { - format = VMM.Date.dateformats.time_short; - } - } else if (p.minute) { - // YEAR MONTH DAY HOUR MINUTE - if (is_abbr){ - format = VMM.Date.dateformats.time_no_seconds_short; - } else { - format = VMM.Date.dateformats.time_no_seconds_small_date; - } - } else if (p.hour) { - // YEAR MONTH DAY HOUR - if (is_abbr) { - format = VMM.Date.dateformats.time_no_seconds_short; - } else { - format = VMM.Date.dateformats.time_no_seconds_small_date; - } - } else if (p.day) { - // YEAR MONTH DAY - if (is_abbr) { - format = VMM.Date.dateformats.full_short; - } else { - format = VMM.Date.dateformats.full; - } - } else if (p.month) { - // YEAR MONTH - if (is_abbr) { - format = VMM.Date.dateformats.month_short; - } else { - format = VMM.Date.dateformats.month; - } - } else if (p.year) { - format = VMM.Date.dateformats.year; - } else { - format = VMM.Date.dateformats.year; - } - - } else { - - if (d.getMonth() === 0 && d.getDate() == 1 && d.getHours() === 0 && d.getMinutes() === 0 ) { - // YEAR ONLY - format = VMM.Date.dateformats.year; - } else if (d.getDate() <= 1 && d.getHours() === 0 && d.getMinutes() === 0) { - // YEAR MONTH - if (is_abbr) { - format = VMM.Date.dateformats.month_short; - } else { - format = VMM.Date.dateformats.month; - } - } else if (d.getHours() === 0 && d.getMinutes() === 0) { - // YEAR MONTH DAY - if (is_abbr) { - format = VMM.Date.dateformats.full_short; - } else { - format = VMM.Date.dateformats.full; - } - } else if (d.getMinutes() === 0) { - // YEAR MONTH DAY HOUR - if (is_abbr) { - format = VMM.Date.dateformats.time_no_seconds_short; - } else { - format = VMM.Date.dateformats.time_no_seconds_small_date; - } - } else { - // YEAR MONTH DAY HOUR MINUTE - if (is_abbr){ - format = VMM.Date.dateformats.time_no_seconds_short; - } else { - format = VMM.Date.dateformats.full_long; - } - } - } - - _date = dateFormat(d, format, false); - //_date = "Jan" - bc_check = _date.split(" "); - - // BC TIME SUPPORT - for(var i = 0; i < bc_check.length; i++) { - if ( parseInt(bc_check[i], 10) < 0 ) { - trace("YEAR IS BC"); - bc_original = bc_check[i]; - bc_number = Math.abs( parseInt(bc_check[i], 10) ); - bc_string = bc_number.toString() + " B.C."; - _date = _date.replace(bc_original, bc_string); - } - } - - - if (is_pair) { - _date2 = dateFormat(d2, format, false); - bc_check = _date2.split(" "); - // BC TIME SUPPORT - for(var j = 0; j < bc_check.length; j++) { - if ( parseInt(bc_check[j], 10) < 0 ) { - trace("YEAR IS BC"); - bc_original = bc_check[j]; - bc_number = Math.abs( parseInt(bc_check[j], 10) ); - bc_string = bc_number.toString() + " B.C."; - _date2 = _date2.replace(bc_original, bc_string); - } - } - - } - } else { - trace("NOT A VALID DATE?"); - trace(d); - } - - if (is_pair) { - return _date + " — " + _date2; - } else { - return _date; - } - } - - }).init(); - - /* - * Date Format 1.2.3 - * (c) 2007-2009 Steven Levithan <stevenlevithan.com> - * MIT license - * - * Includes enhancements by Scott Trenda <scott.trenda.net> - * and Kris Kowal <cixar.com/~kris.kowal/> - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - */ - - var dateFormat = function () { - var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[WLloSZ]|"[^"]*"|'[^']*'/g, - timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, - timezoneClip = /[^-+\dA-Z]/g, - pad = function (val, len) { - val = String(val); - len = len || 2; - while (val.length < len) val = "0" + val; - return val; - }; - - // Regexes and supporting functions are cached through closure - return function (date, mask, utc) { - var dF = dateFormat; - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - // Caused problems in IE - // date = date ? new Date(date) : new Date; - if (isNaN(date)) { - trace("invalid date " + date); - //return ""; - } - - mask = String(dF.masks[mask] || mask || dF.masks["default"]); - - // Allow setting the utc argument via the mask - if (mask.slice(0, 4) == "UTC:") { - mask = mask.slice(4); - utc = true; - } - - var _ = utc ? "getUTC" : "get", - d = date[_ + "Date"](), - D = date[_ + "Day"](), - m = date[_ + "Month"](), - y = date[_ + "FullYear"](), - H = date[_ + "Hours"](), - M = date[_ + "Minutes"](), - s = date[_ + "Seconds"](), - L = date[_ + "Milliseconds"](), - W = date.getWeek(), - o = utc ? 0 : date.getTimezoneOffset(), - flags = { - d: d, - dd: pad(d), - ddd: dF.i18n.dayNames[D], - dddd: dF.i18n.dayNames[D + 7], - m: m + 1, - mm: pad(m + 1), - mmm: dF.i18n.monthNames[m], - mmmm: dF.i18n.monthNames[m + 12], - yy: String(y).slice(2), - yyyy: y, - h: H % 12 || 12, - hh: pad(H % 12 || 12), - H: H, - HH: pad(H), - M: M, - MM: pad(M), - s: s, - ss: pad(s), - l: pad(L, 3), - L: pad(L > 99 ? Math.round(L / 10) : L), - t: H < 12 ? "a" : "p", - tt: H < 12 ? "am" : "pm", - T: H < 12 ? "A" : "P", - TT: H < 12 ? "AM" : "PM", - Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), - o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), - S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10], - W: W - }; - - return mask.replace(token, function ($0) { - return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); - }); - }; - }(); - - // Some common format strings - dateFormat.masks = { - "default": "ddd mmm dd yyyy HH:MM:ss", - shortDate: "m/d/yy", - mediumDate: "mmm d, yyyy", - longDate: "mmmm d, yyyy", - fullDate: "dddd, mmmm d, yyyy", - shortTime: "h:MM TT", - mediumTime: "h:MM:ss TT", - longTime: "h:MM:ss TT Z", - isoDate: "yyyy-mm-dd", - isoTime: "HH:MM:ss", - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" - }; - - // Internationalization strings - dateFormat.i18n = { - dayNames: [ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - ], - monthNames: [ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - ] - }; - - // For convenience... - Date.prototype.format = function (mask, utc) { - return dateFormat(this, mask, utc); - }; - -} - -/* ********************************************** - Begin VMM.Util.js -********************************************** */ - -/* * Utilities and Useful Functions -================================================== */ -if(typeof VMM != 'undefined' && typeof VMM.Util == 'undefined') { - - VMM.Util = ({ - - init: function() { - return this; - }, - - removeRange: function(array, from, to) { // rather than change Array.prototype; Thanks Jeff McWhirter for nudge - var rest = array.slice((to || from) + 1 || array.length); - array.length = from < 0 ? array.length + from : from; - return array.push.apply(array, rest); - }, - - /* * CORRECT PROTOCOL (DOES NOT WORK) - ================================================== */ - correctProtocol: function(url) { - var loc = (window.parent.location.protocol).toString(), - prefix = "", - the_url = url.split("://", 2); - - if (loc.match("http")) { - prefix = loc; - } else { - prefix = "https"; - } - - return prefix + "://" + the_url[1]; - - }, - - /* * MERGE CONFIG - ================================================== */ - mergeConfig: function(config_main, config_to_merge) { - var x; - for (x in config_to_merge) { - if (Object.prototype.hasOwnProperty.call(config_to_merge, x)) { - config_main[x] = config_to_merge[x]; - } - } - return config_main; - }, - - /* * GET OBJECT ATTRIBUTE BY INDEX - ================================================== */ - getObjectAttributeByIndex: function(obj, index) { - if(typeof obj != 'undefined') { - var i = 0; - for (var attr in obj){ - if (index === i){ - return obj[attr]; - } - i++; - } - return ""; - } else { - return ""; - } - - }, - - /* * ORDINAL - ================================================== */ - ordinal: function(n) { - return ["th","st","nd","rd"][(!( ((n%10) >3) || (Math.floor(n%100/10)==1)) ) * (n%10)]; - }, - - /* * RANDOM BETWEEN - ================================================== */ - //VMM.Util.randomBetween(1, 3) - randomBetween: function(min, max) { - return Math.floor(Math.random() * (max - min + 1) + min); - }, - - /* * AVERAGE - * http://jsfromhell.com/array/average - * var x = VMM.Util.average([2, 3, 4]); - * VMM.Util.average([2, 3, 4]).mean - ================================================== */ - average: function(a) { - var r = {mean: 0, variance: 0, deviation: 0}, t = a.length; - for(var m, s = 0, l = t; l--; s += a[l]); - for(m = r.mean = s / t, l = t, s = 0; l--; s += Math.pow(a[l] - m, 2)); - return r.deviation = Math.sqrt(r.variance = s / t), r; - }, - - /* * CUSTOM SORT - ================================================== */ - customSort: function(a, b) { - var a1= a, b1= b; - if(a1== b1) return 0; - return a1> b1? 1: -1; - }, - - /* * Remove Duplicates from Array - ================================================== */ - deDupeArray: function(arr) { - var i, - len=arr.length, - out=[], - obj={}; - - for (i=0;i<len;i++) { - obj[arr[i]]=0; - } - for (i in obj) { - out.push(i); - } - return out; - }, - - /* * Returns a word count number - ================================================== */ - wordCount: function(s) { - var fullStr = s + " "; - var initial_whitespace_rExp = /^[^A-Za-z0-9\'\-]+/gi; - var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, ""); - var non_alphanumerics_rExp = /[^A-Za-z0-9\'\-]+/gi; - var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " "); - var splitString = cleanedStr.split(" "); - var word_count = splitString.length -1; - if (fullStr.length <2) { - word_count = 0; - } - return word_count; - }, - - ratio: { - fit: function(w, h, ratio_w, ratio_h) { - //VMM.Util.ratio.fit(w, h, ratio_w, ratio_h).width; - var _fit = {width:0,height:0}; - // TRY WIDTH FIRST - _fit.width = w; - //_fit.height = Math.round((h / ratio_h) * ratio_w); - _fit.height = Math.round((w / ratio_w) * ratio_h); - if (_fit.height > h) { - _fit.height = h; - //_fit.width = Math.round((w / ratio_w) * ratio_h); - _fit.width = Math.round((h / ratio_h) * ratio_w); - - if (_fit.width > w) { - trace("FIT: DIDN'T FIT!!! ") - } - } - - return _fit; - - }, - r16_9: function(w,h) { - //VMM.Util.ratio.r16_9(w, h) // Returns corresponding number - if (w !== null && w !== "") { - return Math.round((h / 16) * 9); - } else if (h !== null && h !== "") { - return Math.round((w / 9) * 16); - } - }, - r4_3: function(w,h) { - if (w !== null && w !== "") { - return Math.round((h / 4) * 3); - } else if (h !== null && h !== "") { - return Math.round((w / 3) * 4); - } - } - }, - - doubledigit: function(n) { - return (n < 10 ? '0' : '') + n; - }, - - /* * Returns a truncated segement of a long string of between min and max words. If possible, ends on a period (otherwise goes to max). - ================================================== */ - truncateWords: function(s, min, max) { - - if (!min) min = 30; - if (!max) max = min; - - var initial_whitespace_rExp = /^[^A-Za-z0-9\'\-]+/gi; - var left_trimmedStr = s.replace(initial_whitespace_rExp, ""); - var words = left_trimmedStr.split(" "); - - var result = []; - - min = Math.min(words.length, min); - max = Math.min(words.length, max); - - for (var i = 0; i<min; i++) { - result.push(words[i]); - } - - for (var j = min; i<max; i++) { - var word = words[i]; - - result.push(word); - - if (word.charAt(word.length-1) == '.') { - break; - } - } - - return (result.join(' ')); - }, - - /* * Turns plain text links into real links - ================================================== */ - linkify: function(text,targets,is_touch) { - - // http://, https://, ftp:// - var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim; - - // www. sans http:// or https:// - var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim; - - // Email addresses - var emailAddressPattern = /(([a-zA-Z0-9_\-\.]+)@[a-zA-Z_]+?(?:\.[a-zA-Z]{2,6}))+/gim; - - - return text - .replace(urlPattern, "<a target='_blank' href='$&' onclick='void(0)'>$&</a>") - .replace(pseudoUrlPattern, "$1<a target='_blank' onclick='void(0)' href='http://$2'>$2</a>") - .replace(emailAddressPattern, "<a target='_blank' onclick='void(0)' href='mailto:$1'>$1</a>"); - }, - - linkify_with_twitter: function(text,targets,is_touch) { - - // http://, https://, ftp:// - var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim; - var url_pattern = /(\()((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(\))|(\[)((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(\])|(\{)((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(\})|(<|&(?:lt|#60|#x3c);)((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(>|&(?:gt|#62|#x3e);)|((?:^|[^=\s'"\]])\s*['"]?|[^=\s]\s+)(\b(?:ht|f)tps?:\/\/[a-z0-9\-._~!$'()*+,;=:\/?#[\]@%]+(?:(?!&(?:gt|#0*62|#x0*3e);|&(?:amp|apos|quot|#0*3[49]|#x0*2[27]);[.!&',:?;]?(?:[^a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]|$))&[a-z0-9\-._~!$'()*+,;=:\/?#[\]@%]*)*[a-z0-9\-_~$()*+=\/#[\]@%])/img; - var url_replace = '$1$4$7$10$13<a href="$2$5$8$11$14" target="_blank" class="hyphenate">$2$5$8$11$14</a>$3$6$9$12'; - - // www. sans http:// or https:// - var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim; - function replaceURLWithHTMLLinks(text) { - var exp = /(\b(https?|ftp|file):\/\/([-A-Z0-9+&@#%?=~_|!:,.;]*)([-A-Z0-9+&@#%?\/=~_|!:,.;]*)[-A-Z0-9+&@#\/%=~_|])/ig; - return text.replace(exp, "<a href='$1' target='_blank'>$3</a>"); - } - // Email addresses - var emailAddressPattern = /([a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)/gim; - - //var twitterHandlePattern = /(@([\w]+))/g; - var twitterHandlePattern = /\B@([\w-]+)/gm; - var twitterSearchPattern = /(#([\w]+))/g; - - return text - //.replace(urlPattern, "<a target='_blank' href='$&' onclick='void(0)'>$&</a>") - .replace(url_pattern, url_replace) - .replace(pseudoUrlPattern, "$1<a target='_blank' class='hyphenate' onclick='void(0)' href='http://$2'>$2</a>") - .replace(emailAddressPattern, "<a target='_blank' onclick='void(0)' href='mailto:$1'>$1</a>") - .replace(twitterHandlePattern, "<a href='http://twitter.com/$1' target='_blank' onclick='void(0)'>@$1</a>"); - - // TURN THIS BACK ON TO AUTOMAGICALLY LINK HASHTAGS TO TWITTER SEARCH - //.replace(twitterSearchPattern, "<a href='http://twitter.com/search?q=%23$2' target='_blank' 'void(0)'>$1</a>"); - }, - - linkify_wikipedia: function(text) { - - var urlPattern = /<i[^>]*>(.*?)<\/i>/gim; - return text - .replace(urlPattern, "<a target='_blank' href='http://en.wikipedia.org/wiki/$&' onclick='void(0)'>$&</a>") - .replace(/<i\b[^>]*>/gim, "") - .replace(/<\/i>/gim, "") - .replace(/<b\b[^>]*>/gim, "") - .replace(/<\/b>/gim, ""); - }, - - /* * Turns plain text links into real links - ================================================== */ - // VMM.Util.unlinkify(); - unlinkify: function(text) { - if(!text) return text; - text = text.replace(/<a\b[^>]*>/i,""); - text = text.replace(/<\/a>/i, ""); - return text; - }, - - untagify: function(text) { - if (!text) { - return text; - } - text = text.replace(/<\/?\s*\w.*?>/g,""); - return text; - }, - - /* * TK - ================================================== */ - nl2br: function(text) { - return text.replace(/(\r\n|[\r\n]|\\n|\\r)/g,"<br/>"); - }, - - /* * Generate a Unique ID - ================================================== */ - // VMM.Util.unique_ID(size); - unique_ID: function(size) { - - var getRandomNumber = function(range) { - return Math.floor(Math.random() * range); - }; - - var getRandomChar = function() { - var chars = "abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ"; - return chars.substr( getRandomNumber(62), 1 ); - }; - - var randomID = function(size) { - var str = ""; - for(var i = 0; i < size; i++) { - str += getRandomChar(); - } - return str; - }; - - return randomID(size); - }, - /* * Tells you if a number is even or not - ================================================== */ - // VMM.Util.isEven(n) - isEven: function(n){ - return (n%2 === 0) ? true : false; - }, - /* * Get URL Variables - ================================================== */ - // var somestring = VMM.Util.getUrlVars(str_url)["varname"]; - getUrlVars: function(string) { - - var str = string.toString(); - - if (str.match('&')) { - str = str.replace("&", "&"); - } else if (str.match('&')) { - str = str.replace("&", "&"); - } else if (str.match('&')) { - str = str.replace("&", "&"); - } - - var vars = [], hash; - var hashes = str.slice(str.indexOf('?') + 1).split('&'); - for(var i = 0; i < hashes.length; i++) { - hash = hashes[i].split('='); - vars.push(hash[0]); - vars[hash[0]] = hash[1]; - } - - - return vars; - }, - - /* * Cleans up strings to become real HTML - ================================================== */ - toHTML: function(text) { - - text = this.nl2br(text); - text = this.linkify(text); - - return text.replace(/\s\s/g," "); - }, - - /* * Returns text strings as CamelCase - ================================================== */ - toCamelCase: function(s,forceLowerCase) { - - if(forceLowerCase !== false) forceLowerCase = true; - - var sps = ((forceLowerCase) ? s.toLowerCase() : s).split(" "); - - for(var i=0; i<sps.length; i++) { - - sps[i] = sps[i].substr(0,1).toUpperCase() + sps[i].substr(1); - } - - return sps.join(" "); - }, - - /* * Replaces dumb quote marks with smart ones - ================================================== */ - properQuotes: function(str) { - return str.replace(/\"([^\"]*)\"/gi,"“$1”"); - }, - /* * Add Commas to numbers - ================================================== */ - niceNumber: function(nStr){ - nStr += ''; - x = nStr.split('.'); - x1 = x[0]; - x2 = x.length > 1 ? '.' + x[1] : ''; - var rgx = /(\d+)(\d{3})/; - while (rgx.test(x1)) { - x1 = x1.replace(rgx, '$1' + ',' + '$2'); - } - return x1 + x2; - }, - /* * Transform text to Title Case - ================================================== */ - toTitleCase: function(t){ - if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 7) { - return t.replace("_", "%20"); - } else { - var __TitleCase = { - __smallWords: ['a', 'an', 'and', 'as', 'at', 'but','by', 'en', 'for', 'if', 'in', 'of', 'on', 'or','the', 'to', 'v[.]?', 'via', 'vs[.]?'], - - init: function() { - this.__smallRE = this.__smallWords.join('|'); - this.__lowerCaseWordsRE = new RegExp('\\b(' + this.__smallRE + ')\\b', 'gi'); - this.__firstWordRE = new RegExp('^([^a-zA-Z0-9 \\r\\n\\t]*)(' + this.__smallRE + ')\\b', 'gi'); - this.__lastWordRE = new RegExp('\\b(' + this.__smallRE + ')([^a-zA-Z0-9 \\r\\n\\t]*)$', 'gi'); - }, - - toTitleCase: function(string) { - var line = ''; - - var split = string.split(/([:.;?!][ ]|(?:[ ]|^)["â])/); - - for (var i = 0; i < split.length; ++i) { - var s = split[i]; - - s = s.replace(/\b([a-zA-Z][a-z.'â]*)\b/g,this.__titleCaseDottedWordReplacer); - - // lowercase the list of small words - s = s.replace(this.__lowerCaseWordsRE, this.__lowerReplacer); - - // if the first word in the title is a small word then capitalize it - s = s.replace(this.__firstWordRE, this.__firstToUpperCase); - - // if the last word in the title is a small word, then capitalize it - s = s.replace(this.__lastWordRE, this.__firstToUpperCase); - - line += s; - } - - // special cases - line = line.replace(/ V(s?)\. /g, ' v$1. '); - line = line.replace(/(['â])S\b/g, '$1s'); - line = line.replace(/\b(AT&T|Q&A)\b/ig, this.__upperReplacer); - - return line; - }, - - __titleCaseDottedWordReplacer: function (w) { - return (w.match(/[a-zA-Z][.][a-zA-Z]/)) ? w : __TitleCase.__firstToUpperCase(w); - }, - - __lowerReplacer: function (w) { return w.toLowerCase() }, - - __upperReplacer: function (w) { return w.toUpperCase() }, - - __firstToUpperCase: function (w) { - var split = w.split(/(^[^a-zA-Z0-9]*[a-zA-Z0-9])(.*)$/); - if (split[1]) { - split[1] = split[1].toUpperCase(); - } - - return split.join(''); - - - } - }; - - __TitleCase.init(); - - t = t.replace(/_/g," "); - t = __TitleCase.toTitleCase(t); - - return t; - - } - - } - - }).init(); -} - - -/* ********************************************** - Begin LazyLoad.js -********************************************** */ - -/*jslint browser: true, eqeqeq: true, bitwise: true, newcap: true, immed: true, regexp: false */ - -/* -LazyLoad makes it easy and painless to lazily load one or more external -JavaScript or CSS files on demand either during or after the rendering of a web -page. - -Supported browsers include Firefox 2+, IE6+, Safari 3+ (including Mobile -Safari), Google Chrome, and Opera 9+. Other browsers may or may not work and -are not officially supported. - -Visit https://github.com/rgrove/lazyload/ for more info. - -Copyright (c) 2011 Ryan Grove <r...@wonko.com> -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. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -@module lazyload -@class LazyLoad -@static -@version 2.0.3 (git) -*/ - -LazyLoad = (function (doc) { - // -- Private Variables ------------------------------------------------------ - - // User agent and feature test information. - var env, - - // Reference to the <head> element (populated lazily). - head, - - // Requests currently in progress, if any. - pending = {}, - - // Number of times we've polled to check whether a pending stylesheet has - // finished loading. If this gets too high, we're probably stalled. - pollCount = 0, - - // Queued requests. - queue = {css: [], js: []}, - - // Reference to the browser's list of stylesheets. - styleSheets = doc.styleSheets; - - // -- Private Methods -------------------------------------------------------- - - /** - Creates and returns an HTML element with the specified name and attributes. - - @method createNode - @param {String} name element name - @param {Object} attrs name/value mapping of element attributes - @return {HTMLElement} - @private - */ - function createNode(name, attrs) { - var node = doc.createElement(name), attr; - - for (attr in attrs) { - if (attrs.hasOwnProperty(attr)) { - node.setAttribute(attr, attrs[attr]); - } - } - - return node; - } - - /** - Called when the current pending resource of the specified type has finished - loading. Executes the associated callback (if any) and loads the next - resource in the queue. - - @method finish - @param {String} type resource type ('css' or 'js') - @private - */ - function finish(type) { - var p = pending[type], - callback, - urls; - - if (p) { - callback = p.callback; - urls = p.urls; - - urls.shift(); - pollCount = 0; - - // If this is the last of the pending URLs, execute the callback and - // start the next request in the queue (if any). - if (!urls.length) { - callback && callback.call(p.context, p.obj); - pending[type] = null; - queue[type].length && load(type); - } - } - } - - /** - Populates the <code>env</code> variable with user agent and feature test - information. - - @method getEnv - @private - */ - function getEnv() { - var ua = navigator.userAgent; - - env = { - // True if this browser supports disabling async mode on dynamically - // created script nodes. See - // http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order - async: doc.createElement('script').async === true - }; - - (env.webkit = /AppleWebKit\//.test(ua)) - || (env.ie = /MSIE/.test(ua)) - || (env.opera = /Opera/.test(ua)) - || (env.gecko = /Gecko\//.test(ua)) - || (env.unknown = true); - } - - /** - Loads the specified resources, or the next resource of the specified type - in the queue if no resources are specified. If a resource of the specified - type is already being loaded, the new request will be queued until the - first request has been finished. - - When an array of resource URLs is specified, those URLs will be loaded in - parallel if it is possible to do so while preserving execution order. All - browsers support parallel loading of CSS, but only Firefox and Opera - support parallel loading of scripts. In other browsers, scripts will be - queued and loaded one at a time to ensure correct execution order. - - @method load - @param {String} type resource type ('css' or 'js') - @param {String|Array} urls (optional) URL or array of URLs to load - @param {Function} callback (optional) callback function to execute when the - resource is loaded - @param {Object} obj (optional) object to pass to the callback function - @param {Object} context (optional) if provided, the callback function will - be executed in this object's context - @private - */ - function load(type, urls, callback, obj, context) { - var _finish = function () { finish(type); }, - isCSS = type === 'css', - nodes = [], - i, len, node, p, pendingUrls, url; - - env || getEnv(); - - if (urls) { - // If urls is a string, wrap it in an array. Otherwise assume it's an - // array and create a copy of it so modifications won't be made to the - // original. - urls = typeof urls === 'string' ? [urls] : urls.concat(); - - // Create a request object for each URL. If multiple URLs are specified, - // the callback will only be executed after all URLs have been loaded. - // - // Sadly, Firefox and Opera are the only browsers capable of loading - // scripts in parallel while preserving execution order. In all other - // browsers, scripts must be loaded sequentially. - // - // All browsers respect CSS specificity based on the order of the link - // elements in the DOM, regardless of the order in which the stylesheets - // are actually downloaded. - if (isCSS || env.async || env.gecko || env.opera) { - // Load in parallel. - queue[type].push({ - urls : urls, - callback: callback, - obj : obj, - context : context - }); - } else { - // Load sequentially. - for (i = 0, len = urls.length; i < len; ++i) { - queue[type].push({ - urls : [urls[i]], - callback: i === len - 1 ? callback : null, // callback is only added to the last URL - obj : obj, - context : context - }); - } - } - } - - // If a previous load request of this type is currently in progress, we'll - // wait our turn. Otherwise, grab the next item in the queue. - if (pending[type] || !(p = pending[type] = queue[type].shift())) { - return; - } - - head || (head = doc.head || doc.getElementsByTagName('head')[0]); - pendingUrls = p.urls; - - for (i = 0, len = pendingUrls.length; i < len; ++i) { - url = pendingUrls[i]; - - if (isCSS) { - node = env.gecko ? createNode('style') : createNode('link', { - href: url, - rel : 'stylesheet' - }); - } else { - node = createNode('script', {src: url}); - node.async = false; - } - - node.className = 'lazyload'; - node.setAttribute('charset', 'utf-8'); - - if (env.ie && !isCSS) { - node.onreadystatechange = function () { - if (/loaded|complete/.test(node.readyState)) { - node.onreadystatechange = null; - _finish(); - } - }; - } else if (isCSS && (env.gecko || env.webkit)) { - // Gecko and WebKit don't support the onload event on link nodes. - if (env.webkit) { - // In WebKit, we can poll for changes to document.styleSheets to - // figure out when stylesheets have loaded. - p.urls[i] = node.href; // resolve relative URLs (or polling won't work) - pollWebKit(); - } else { - // In Gecko, we can import the requested URL into a <style> node and - // poll for the existence of node.sheet.cssRules. Props to Zach - // Leatherman for calling my attention to this technique. - node.innerHTML = '@import "' + url + '";'; - pollGecko(node); - } - } else { - node.onload = node.onerror = _finish; - } - - nodes.push(node); - } - - for (i = 0, len = nodes.length; i < len; ++i) { - head.appendChild(nodes[i]); - } - } - - /** - Begins polling to determine when the specified stylesheet has finished loading - in Gecko. Polling stops when all pending stylesheets have loaded or after 10 - seconds (to prevent stalls). - - Thanks to Zach Leatherman for calling my attention to the @import-based - cross-domain technique used here, and to Oleg Slobodskoi for an earlier - same-domain implementation. See Zach's blog for more details: - http://www.zachleat.com/web/2010/07/29/load-css-dynamically/ - - @method pollGecko - @param {HTMLElement} node Style node to poll. - @private - */ - function pollGecko(node) { - var hasRules; - - try { - // We don't really need to store this value or ever refer to it again, but - // if we don't store it, Closure Compiler assumes the code is useless and - // removes it. - hasRules = !!node.sheet.cssRules; - } catch (ex) { - // An exception means the stylesheet is still loading. - pollCount += 1; - - if (pollCount < 200) { - setTimeout(function () { pollGecko(node); }, 50); - } else { - // We've been polling for 10 seconds and nothing's happened. Stop - // polling and finish the pending requests to avoid blocking further - // requests. - hasRules && finish('css'); - } - - return; - } - - // If we get here, the stylesheet has loaded. - finish('css'); - } - - /** - Begins polling to determine when pending stylesheets have finished loading - in WebKit. Polling stops when all pending stylesheets have loaded or after 10 - seconds (to prevent stalls). - - @method pollWebKit - @private - */ - function pollWebKit() { - var css = pending.css, i; - - if (css) { - i = styleSheets.length; - - // Look for a stylesheet matching the pending URL. - while (--i >= 0) { - if (styleSheets[i].href === css.urls[0]) { - finish('css'); - break; - } - } - - pollCount += 1; - - if (css) { - if (pollCount < 200) { - setTimeout(pollWebKit, 50); - } else { - // We've been polling for 10 seconds and nothing's happened, which may - // indicate that the stylesheet has been removed from the document - // before it had a chance to load. Stop polling and finish the pending - // request to prevent blocking further requests. - finish('css'); - } - } - } - } - - return { - - /** - Requests the specified CSS URL or URLs and executes the specified - callback (if any) when they have finished loading. If an array of URLs is - specified, the stylesheets will be loaded in parallel and the callback - will be executed after all stylesheets have finished loading. - - @method css - @param {String|Array} urls CSS URL or array of CSS URLs to load - @param {Function} callback (optional) callback function to execute when - the specified stylesheets are loaded - @param {Object} obj (optional) object to pass to the callback function - @param {Object} context (optional) if provided, the callback function - will be executed in this object's context - @static - */ - css: function (urls, callback, obj, context) { - load('css', urls, callback, obj, context); - }, - - /** - Requests the specified JavaScript URL or URLs and executes the specified - callback (if any) when they have finished loading. If an array of URLs is - specified and the browser supports it, the scripts will be loaded in - parallel and the callback will be executed after all scripts have - finished loading. - - Currently, only Firefox and Opera support parallel loading of scripts while - preserving execution order. In other browsers, scripts will be - queued and loaded one at a time to ensure correct execution order. - - @method js - @param {String|Array} urls JS URL or array of JS URLs to load - @param {Function} callback (optional) callback function to execute when - the specified scripts are loaded - @param {Object} obj (optional) object to pass to the callback function - @param {Object} context (optional) if provided, the callback function - will be executed in this object's context - @static - */ - js: function (urls, callback, obj, context) { - load('js', urls, callback, obj, context); - } - - }; -})(this.document); - - -/* ********************************************** - Begin VMM.LoadLib.js -********************************************** */ - -/* - LoadLib - Designed and built by Zach Wise digitalartwork.net -*/ - -/* * CodeKit Import - * http://incident57.com/codekit/ -================================================== */ -// @codekit-prepend "../Library/LazyLoad.js"; - -LoadLib = (function (doc) { - var loaded = []; - - function isLoaded(url) { - - var i = 0, - has_loaded = false; - - for (i = 0; i < loaded.length; i++) { - if (loaded[i] == url) { - has_loaded = true; - } - } - - if (has_loaded) { - return true; - } else { - loaded.push(url); - return false; - } - - } - - return { - - css: function (urls, callback, obj, context) { - if (!isLoaded(urls)) { - LazyLoad.css(urls, callback, obj, context); - } - }, - - js: function (urls, callback, obj, context) { - if (!isLoaded(urls)) { - LazyLoad.js(urls, callback, obj, context); - } - } - }; - -})(this.document); - - -/* ********************************************** - Begin VMM.Language.js -********************************************** */ - -/* DEFAULT LANGUAGE -================================================== */ -if(typeof VMM != 'undefined' && typeof VMM.Language == 'undefined') { - VMM.Language = { - lang: "en", - api: { - wikipedia: "en" - }, - date: { - month: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], - month_abbr: ["Jan.", "Feb.", "March", "April", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."], - day: ["Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], - day_abbr: ["Sun.","Mon.", "Tues.", "Wed.", "Thurs.", "Fri.", "Sat."] - }, - dateformats: { - year: "yyyy", - month_short: "mmm", - month: "mmmm yyyy", - full_short: "mmm d", - full: "mmmm d',' yyyy", - time_short: "h:MM:ss TT", - time_no_seconds_short: "h:MM TT", - time_no_seconds_small_date: "h:MM TT'<br/><small>'mmmm d',' yyyy'</small>'", - full_long: "mmm d',' yyyy 'at' h:MM TT", - full_long_small_date: "h:MM TT'<br/><small>mmm d',' yyyy'</small>'" - }, - messages: { - loading_timeline: "Loading Timeline... ", - return_to_title: "Return to Title", - expand_timeline: "Expand Timeline", - contract_timeline: "Contract Timeline", - wikipedia: "From Wikipedia, the free encyclopedia", - loading_content: "Loading Content", - loading: "Loading", - swipe_nav: "Swipe to Navigate" - } - } -}; - -/* ********************************************** - Begin VMM.Core.js -********************************************** */ - -/* VeriteCo Core -================================================== */ - -/* * CodeKit Import - * http://incident57.com/codekit/ -================================================== */ -// @codekit-prepend "VMM.js"; -// @codekit-prepend "VMM.Library.js"; -// @codekit-prepend "VMM.Browser.js"; -// @codekit-prepend "VMM.FileExtention.js"; -// @codekit-prepend "VMM.Date.js"; -// @codekit-prepend "VMM.Util.js"; -// @codekit-prepend "VMM.LoadLib.js"; -// @codekit-prepend "VMM.Language.js"; - - - -/* ********************************************** - Begin VMM.ExternalAPI.js -********************************************** */ - -/* External API -================================================== */ -if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { - - VMM.ExternalAPI = ({ - - keys: { - google: "", - flickr: "", - twitter: "" - }, - - keys_master: { - vp: "Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo", - flickr: "RAIvxHY4hE/Elm5cieh4X5ptMyDpj7MYIxziGxi0WGCcy1s+yr7rKQ==", - google: "jwNGnYw4hE9lmAez4ll0QD+jo6SKBJFknkopLS4FrSAuGfIwyj57AusuR0s8dAo=", - twitter: "" - }, - - init: function() { - return this; - }, - - setKeys: function(d) { - VMM.ExternalAPI.keys = d; - }, - - pushQues: function() { - - if (VMM.master_config.googlemaps.active) { - VMM.ExternalAPI.googlemaps.pushQue(); - } - if (VMM.master_config.youtube.active) { - VMM.ExternalAPI.youtube.pushQue(); - } - if (VMM.master_config.soundcloud.active) { - VMM.ExternalAPI.soundcloud.pushQue(); - } - if (VMM.master_config.googledocs.active) { - VMM.ExternalAPI.googledocs.pushQue(); - } - if (VMM.master_config.googleplus.active) { - VMM.ExternalAPI.googleplus.pushQue(); - } - if (VMM.master_config.wikipedia.active) { - VMM.ExternalAPI.wikipedia.pushQue(); - } - if (VMM.master_config.vimeo.active) { - VMM.ExternalAPI.vimeo.pushQue(); - } - if (VMM.master_config.vine.active) { - VMM.ExternalAPI.vine.pushQue(); - } - if (VMM.master_config.twitter.active) { - VMM.ExternalAPI.twitter.pushQue(); - } - if (VMM.master_config.flickr.active) { - VMM.ExternalAPI.flickr.pushQue(); - } - if (VMM.master_config.webthumb.active) { - VMM.ExternalAPI.webthumb.pushQue(); - } - }, - - twitter: { - tweetArray: [], - - get: function(m) { - var tweet = {mid: m.id, id: m.uid}; - VMM.master_config.twitter.que.push(tweet); - VMM.master_config.twitter.active = true; - //VMM.master_config.api.pushques.push(VMM.ExternalAPI.twitter.pushQue); - - }, - - create: function(tweet, callback) { - - var id = tweet.mid.toString(), - error_obj = { twitterid: tweet.mid }, - the_url = "//api.twitter.com/1/statuses/show.json?id=" + tweet.mid + "&include_entities=true&callback=?"; - //twitter_timeout = setTimeout(VMM.ExternalAPI.twitter.errorTimeOut, VMM.master_config.timers.api, tweet), - //callback_timeout= setTimeout(callback, VMM.master_config.timers.api, tweet); - - VMM.ExternalAPI.twitter.getOEmbed(tweet, callback); - - /* - // Disabled thanks to twitter's new api - - VMM.getJSON(the_url, function(d) { - var id = d.id_str, - twit = "<blockquote><p>", - td = VMM.Util.linkify_with_twitter(d.text, "_blank"); - - // TWEET CONTENT - twit += td; - twit += "</p></blockquote>"; - - // TWEET MEDIA - if (typeof d.entities.media != 'undefined') { - if (d.entities.media[0].type == "photo") { - //twit += "<img src=' " + d.entities.media[0].media_url + "' alt=''>" - } - } - - // TWEET AUTHOR - 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 class='thumbnail-inline'></span></span>"; - twit += "</a>"; - twit += "</div>"; - - - - VMM.attachElement("#"+tweet.id.toString(), twit ); - VMM.attachElement("#text_thumb_"+tweet.id.toString(), d.text ); - VMM.attachElement("#marker_content_" + tweet.id.toString(), d.text ); - - }) - .error(function(jqXHR, textStatus, errorThrown) { - trace("TWITTER error"); - trace("TWITTER ERROR: " + textStatus + " " + jqXHR.responseText); - VMM.attachElement("#"+tweet.id, VMM.MediaElement.loadingmessage("ERROR LOADING TWEET " + tweet.mid) ); - }) - .success(function(d) { - clearTimeout(twitter_timeout); - clearTimeout(callback_timeout); - callback(); - }); - - */ - }, - - errorTimeOut: function(tweet) { - trace("TWITTER JSON ERROR TIMEOUT " + tweet.mid); - VMM.attachElement("#"+tweet.id.toString(), VMM.MediaElement.loadingmessage("Still waiting on Twitter: " + tweet.mid) ); - // CHECK RATE STATUS - VMM.getJSON("//api.twitter.com/1/account/rate_limit_status.json", function(d) { - trace("REMAINING TWITTER API CALLS " + d.remaining_hits); - trace("TWITTER RATE LIMIT WILL RESET AT " + d.reset_time); - var mes = ""; - if (d.remaining_hits == 0) { - mes = "<p>You've reached the maximum number of tweets you can load in an hour.</p>"; - mes += "<p>You can view tweets again starting at: <br/>" + d.reset_time + "</p>"; - } else { - mes = "<p>Still waiting on Twitter. " + tweet.mid + "</p>"; - //mes = "<p>Tweet " + id + " was not found.</p>"; - } - VMM.attachElement("#"+tweet.id.toString(), VMM.MediaElement.loadingmessage(mes) ); - }); - - }, - - errorTimeOutOembed: function(tweet) { - trace("TWITTER JSON ERROR TIMEOUT " + tweet.mid); - VMM.attachElement("#"+tweet.id.toString(), VMM.MediaElement.loadingmessage("Still waiting on Twitter: " + tweet.mid) ); - }, - - pushQue: function() { - if (VMM.master_config.twitter.que.length > 0) { - VMM.ExternalAPI.twitter.create(VMM.master_config.twitter.que[0], VMM.ExternalAPI.twitter.pushQue); - VMM.Util.removeRange(VMM.master_config.twitter.que,0); - } - }, - - getOEmbed: function(tweet, callback) { - - var the_url = "https://api.twitter.com/1/statuses/oembed.json?id=" + tweet.mid + "&omit_script=true&include_entities=true&callback=?", - twitter_timeout = setTimeout(VMM.ExternalAPI.twitter.errorTimeOutOembed, VMM.master_config.timers.api, tweet); - //callback_timeout= setTimeout(callback, VMM.master_config.timers.api, tweet); - - VMM.getJSON(the_url, function(d) { - var twit = "", - tuser = ""; - - - // TWEET CONTENT - twit += d.html.split("<\/p>\—")[0] + "</p></blockquote>"; - tuser = d.author_url.split("twitter.com\/")[1]; - - - // TWEET AUTHOR - twit += "<div class='vcard author'>"; - twit += "<a class='screen-name url' href='" + d.author_url + "' target='_blank'>"; - twit += "<span class='avatar'></span>"; - twit += "<span class='fn'>" + d.author_name + "</span>"; - twit += "<span class='nickname'>@" + tuser + "<span class='thumbnail-inline'></span></span>"; - twit += "</a>"; - twit += "</div>"; - - VMM.attachElement("#"+tweet.id.toString(), twit ); - VMM.attachElement("#text_thumb_"+tweet.id.toString(), d.html ); - VMM.attachElement("#marker_content_" + tweet.id.toString(), d.html ); - }) - .error(function(jqXHR, textStatus, errorThrown) { - trace("TWITTER error"); - trace("TWITTER ERROR: " + textStatus + " " + jqXHR.responseText); - clearTimeout(twitter_timeout); - //clearTimeout(callback_timeout); - VMM.attachElement("#"+tweet.id, VMM.MediaElement.loadingmessage("ERROR LOADING TWEET " + tweet.mid) ); - }) - .success(function(d) { - clearTimeout(twitter_timeout); - // clearTimeout(callback_timeout); - callback(); - }); - - }, - - getHTML: function(id) { - //var the_url = document.location.protocol + "//api.twitter.com/1/statuses/oembed.json?id=" + id+ "&callback=?"; - var the_url = "https://api.twitter.com/1/statuses/oembed.json?id=" + id+ "&omit_script=true&include_entities=true&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) ); - }, - - 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.Date.prettyDate(date, true); - }, - - getTweets: function(tweets) { - var tweetArray = []; - var number_of_tweets = tweets.length; - - for(var i = 0; i < tweets.length; i++) { - - var twitter_id = ""; - - - /* FIND THE TWITTER ID - ================================================== */ - 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 = ""; - } - - /* FETCH THE DATA - ================================================== */ - var the_url = "//api.twitter.com/1/statuses/show.json?id=" + twitter_id + "&include_entities=true&callback=?"; - VMM.getJSON(the_url, function(d) { - - var tweet = {} - /* FORMAT RESPONSE - ================================================== */ - 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); - - - /* CHECK IF THATS ALL OF THEM - ================================================== */ - 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"); }); - - } - - - }, - - 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 = "//search.twitter.com/search.json?q=" + tweets + "&rpp=" + _number_of_tweets + "&include_entities=true&resul
<TRUNCATED>