Beautifully crafted timelines that are easy and intuitive to use. http://timeline.knightlab.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
7065 lines
215 KiB
7065 lines
215 KiB
13 years ago
|
/*!
|
||
|
Timeline
|
||
|
Designed and built by Zach Wise at VéritéCo
|
||
|
|
||
|
This program is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
http://www.gnu.org/licenses/
|
||
|
|
||
|
*/
|
||
|
|
||
|
/***********************************************
|
||
|
Begin VMM.js
|
||
|
***********************************************/
|
||
|
|
||
13 years ago
|
/* Verite
|
||
|
* Verite JS Master
|
||
13 years ago
|
* Version: 0.6
|
||
|
* Date: April 26, 2012
|
||
13 years ago
|
* Copyright 2012 Verite unless part of Verite Timeline,
|
||
|
* if part of Timeline then it inherits Timeline's license.
|
||
13 years ago
|
* Designed and built by Zach Wise digitalartwork.net
|
||
|
* ----------------------------------------------------- */
|
||
13 years ago
|
|
||
|
|
||
|
/* Simple JavaScript Inheritance
|
||
|
* By John Resig http://ejohn.org/
|
||
|
* MIT Licensed.
|
||
|
================================================== */
|
||
13 years ago
|
(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];
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
// The dummy class constructor
|
||
|
function Class() {
|
||
|
// All construction is actually done in the init method
|
||
|
if (!initializing && this.init)
|
||
|
this.init.apply(this, arguments);
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
// Populate our constructed prototype object
|
||
|
Class.prototype = prototype;
|
||
13 years ago
|
|
||
13 years ago
|
// Enforce the constructor to be what we expect
|
||
|
Class.prototype.constructor = Class;
|
||
13 years ago
|
|
||
13 years ago
|
// And make this class extendable
|
||
|
Class.extend = arguments.callee;
|
||
13 years ago
|
|
||
13 years ago
|
return Class;
|
||
|
};
|
||
|
})();
|
||
13 years ago
|
|
||
|
/* 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 = {};
|
||
13 years ago
|
var VMM = Class.extend({});
|
||
13 years ago
|
|
||
13 years ago
|
/* Debug
|
||
|
================================================== */
|
||
|
VMM.debug = true;
|
||
|
|
||
13 years ago
|
/* Master Config
|
||
|
================================================== */
|
||
|
|
||
|
VMM.master_config = ({
|
||
|
|
||
|
init: function() {
|
||
|
return this;
|
||
|
},
|
||
|
|
||
13 years ago
|
vp: "Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo",
|
||
13 years ago
|
|
||
13 years ago
|
api_keys_master: {
|
||
13 years ago
|
flickr: "RAIvxHY4hE/Elm5cieh4X5ptMyDpj7MYIxziGxi0WGCcy1s+yr7rKQ==",
|
||
13 years ago
|
google: "jwNGnYw4hE9lmAez4ll0QD+jo6SKBJFknkopLS4FrSAuGfIwyj57AusuR0s8dAo=",
|
||
|
twitter: ""
|
||
13 years ago
|
},
|
||
|
|
||
13 years ago
|
youtube: {
|
||
13 years ago
|
active: false,
|
||
|
array: [],
|
||
|
api_loaded: false,
|
||
|
que: []
|
||
13 years ago
|
},
|
||
|
|
||
13 years ago
|
googlemaps: {
|
||
13 years ago
|
active: false,
|
||
|
map_active: false,
|
||
|
places_active: false,
|
||
|
array: [],
|
||
|
api_loaded: false,
|
||
|
que: []
|
||
|
},
|
||
|
|
||
|
googledocs: {
|
||
|
active: false,
|
||
|
array: [],
|
||
|
api_loaded: false,
|
||
|
que: []
|
||
|
},
|
||
|
|
||
13 years ago
|
wikipedia: {
|
||
|
active: false,
|
||
|
array: [],
|
||
|
api_loaded: false,
|
||
|
que: []
|
||
|
},
|
||
|
|
||
13 years ago
|
soundcloud: {
|
||
|
active: false,
|
||
|
array: [],
|
||
|
api_loaded: false,
|
||
|
que: []
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
}).init();
|
||
|
|
||
|
//VMM.createElement(tag, value, cName, attrs, styles);
|
||
|
VMM.createElement = function(tag, value, cName, attrs, styles) {
|
||
|
|
||
|
var ce = "";
|
||
|
|
||
|
if (tag != null && tag != "") {
|
||
|
|
||
|
// TAG
|
||
|
ce += "<" + tag;
|
||
|
if (cName != null && cName != "") {
|
||
|
ce += " class='" + cName + "'";
|
||
|
};
|
||
|
|
||
|
if (attrs != null && attrs != "") {
|
||
|
ce += " " + attrs;
|
||
|
};
|
||
|
|
||
|
if (styles != null && styles != "") {
|
||
|
ce += " " + styles;
|
||
|
};
|
||
|
|
||
|
ce += ">";
|
||
|
|
||
|
if (value != null && value != "") {
|
||
|
ce += value;
|
||
|
}
|
||
|
|
||
|
// CLOSE TAG
|
||
|
ce = ce + "</" + tag + ">";
|
||
|
}
|
||
|
|
||
|
return ce;
|
||
|
|
||
|
};
|
||
|
|
||
|
VMM.createMediaElement = function(media, caption, credit) {
|
||
|
|
||
|
var ce = "";
|
||
|
|
||
|
var _valid = false;
|
||
|
|
||
|
ce += "<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;
|
||
|
|
||
|
};
|
||
|
|
||
13 years ago
|
// 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 );
|
||
|
}
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
}
|
||
|
|
||
|
/* Trace (console.log)
|
||
|
================================================== */
|
||
|
function trace( msg ) {
|
||
13 years ago
|
if (VMM.debug) {
|
||
|
if (window.console) {
|
||
|
console.log(msg);
|
||
|
} else if ( typeof( jsTrace ) != 'undefined' ) {
|
||
|
jsTrace.send( msg );
|
||
|
} else {
|
||
|
//alert(msg);
|
||
|
}
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
|
/* 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();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/***********************************************
|
||
13 years ago
|
Begin VMM.Library.js
|
||
13 years ago
|
***********************************************/
|
||
|
|
||
13 years ago
|
/* LIBRARY ABSTRACTION
|
||
|
================================================== */
|
||
|
if(typeof VMM != 'undefined') {
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
VMM.getJSON = function(url, data, callback) {
|
||
|
if( typeof( jQuery ) != 'undefined' ){
|
||
|
|
||
|
/* CHECK FOR IE AND USE Use Microsoft XDR
|
||
|
================================================== */
|
||
|
if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 7 && window.XDomainRequest) {
|
||
|
trace("it's ie");
|
||
|
var ie_url = url;
|
||
13 years ago
|
|
||
13 years ago
|
if (ie_url.match('^http://')){
|
||
|
trace("RUNNING GET JSON")
|
||
|
ie_url = ie_url.replace("http://","//");
|
||
|
return jQuery.getJSON(url, data, callback);
|
||
|
} else if (ie_url.match('^https://')) {
|
||
|
trace("RUNNING XDR");
|
||
|
ie_url = ie_url.replace("https://","http://");
|
||
|
var xdr = new XDomainRequest();
|
||
|
xdr.open("get", ie_url);
|
||
|
xdr.onload = function() {
|
||
|
var ie_json = VMM.parseJSON(xdr.responseText);
|
||
|
trace(xdr.responseText);
|
||
|
if (type.of(ie_json) == "null" || type.of(ie_json) == "undefined") {
|
||
|
trace("IE JSON ERROR")
|
||
|
} else {
|
||
|
return data(ie_json)
|
||
|
}
|
||
|
|
||
|
}
|
||
|
xdr.send();
|
||
|
} else {
|
||
|
return jQuery.getJSON(url, data, callback);
|
||
|
}
|
||
|
} else {
|
||
|
return jQuery.getJSON(url, data, callback);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
VMM.parseJSON = function(the_json) {
|
||
|
if( typeof( jQuery ) != 'undefined' ){
|
||
|
return jQuery.parseJSON(the_json);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ADD ELEMENT AND RETURN IT
|
||
|
VMM.appendAndGetElement = function(append_to_element, tag, cName, content) {
|
||
|
var e;
|
||
|
var _tag = "<div>";
|
||
|
var _class = "";
|
||
|
var _content = "";
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
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);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
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) {
|
||
13 years ago
|
|
||
13 years ago
|
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) {
|
||
13 years ago
|
|
||
13 years ago
|
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;
|
||
|
}
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
},
|
||
|
|
||
|
find: function(element, selec) {
|
||
|
if( typeof( jQuery ) != 'undefined' ){
|
||
|
return jQuery(element).find(selec);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
stop: function(element) {
|
||
|
if( typeof( jQuery ) != 'undefined' ){
|
||
|
jQuery(element).stop();
|
||
|
}
|
||
|
},
|
||
|
|
||
|
animate: function(element, duration, ease, att, callback_function) {
|
||
|
|
||
|
var _ease = "easein";
|
||
|
var _duration = 1000;
|
||
|
var _att = {};
|
||
|
|
||
|
if (duration != null) {
|
||
|
if (duration < 1) {
|
||
|
_duration = 1;
|
||
|
} else {
|
||
|
_duration = Math.round(duration);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
if (ease != null && ease != "") {
|
||
|
_ease = ease;
|
||
|
}
|
||
|
|
||
|
if (att != null) {
|
||
|
_att = att
|
||
|
} else {
|
||
|
_att = {opacity: 0}
|
||
|
}
|
||
|
|
||
|
|
||
|
if (VMM.Browser.device == "mobile" || VMM.Browser.device == "tablet") {
|
||
|
|
||
|
var _tdd = Math.round((_duration/1500)*10)/10
|
||
|
var __duration = _tdd + 's';
|
||
|
VMM.Lib.css(element, '-webkit-transition', 'all '+ __duration + ' ease');
|
||
|
VMM.Lib.css(element, '-moz-transition', 'all '+ __duration + ' ease');
|
||
|
VMM.Lib.css(element, '-o-transition', 'all '+ __duration + ' ease');
|
||
|
VMM.Lib.css(element, '-ms-transition', 'all '+ __duration + ' ease');
|
||
|
VMM.Lib.css(element, 'transition', 'all '+ __duration + ' ease');
|
||
|
VMM.Lib.cssmultiple(element, _att);
|
||
|
|
||
|
//callback_function();
|
||
|
/*
|
||
|
if( typeof( jQuery ) != 'undefined' ){
|
||
|
if (callback_function != null && callback_function != "") {
|
||
|
jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease, complete:callback_function} );
|
||
|
} else {
|
||
|
jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease} );
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
} else {
|
||
|
if( typeof( jQuery ) != 'undefined' ){
|
||
|
if (callback_function != null && callback_function != "") {
|
||
|
jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease, complete:callback_function} );
|
||
|
} else {
|
||
|
jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease} );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
},
|
||
|
|
||
|
}).init();
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/* jQuery Easing v1.3
|
||
|
http://gsgd.co.uk/sandbox/jquery/easing/
|
||
|
================================================== */
|
||
|
if( typeof( jQuery ) != 'undefined' ){
|
||
|
|
||
|
jQuery.easing['jswing'] = jQuery.easing['swing'];
|
||
13 years ago
|
|
||
13 years ago
|
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;
|
||
|
},
|
||
|
});
|
||
|
}
|
||
13 years ago
|
|
||
|
|
||
13 years ago
|
/***********************************************
|
||
|
Begin VMM.Browser.js
|
||
|
***********************************************/
|
||
13 years ago
|
|
||
13 years ago
|
/* DEVICE AND BROWSER DETECTION
|
||
|
================================================== */
|
||
|
if(typeof VMM != 'undefined' && typeof VMM.Browser == 'undefined') {
|
||
|
|
||
|
VMM.Browser = {
|
||
|
init: function () {
|
||
|
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
|
||
|
this.version = this.searchVersion(navigator.userAgent)
|
||
|
|| this.searchVersion(navigator.appVersion)
|
||
|
|| "an unknown version";
|
||
|
this.OS = this.searchString(this.dataOS) || "an unknown OS";
|
||
|
this.device = this.searchDevice(navigator.userAgent);
|
||
|
this.orientation = this.searchOrientation(window.orientation);
|
||
|
},
|
||
|
searchOrientation: function(orientation) {
|
||
|
if ( orientation == 0 || orientation == 180) {
|
||
|
return "portrait";
|
||
|
} else if ( orientation == 90 || orientation == -90) {
|
||
|
return "landscape";
|
||
|
} else {
|
||
|
return "normal";
|
||
|
}
|
||
|
},
|
||
|
searchDevice: function(d) {
|
||
|
if (d.match(/Android/i) || d.match(/iPhone|iPod/i)) {
|
||
|
return "mobile";
|
||
|
} else if (d.match(/iPad/i)) {
|
||
|
return "tablet";
|
||
|
} else if (d.match(/BlackBerry/i) || d.match(/IEMobile/i)) {
|
||
|
return "other mobile";
|
||
|
} else {
|
||
|
return "desktop";
|
||
|
}
|
||
|
},
|
||
|
searchString: function (data) {
|
||
|
for (var i=0;i<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"
|
||
|
}
|
||
|
]
|
||
13 years ago
|
|
||
13 years ago
|
}
|
||
|
VMM.Browser.init();
|
||
|
}
|
||
13 years ago
|
|
||
|
/***********************************************
|
||
13 years ago
|
Begin VMM.MediaElement.js
|
||
13 years ago
|
***********************************************/
|
||
|
|
||
13 years ago
|
/* MediaElement
|
||
|
================================================== */
|
||
|
if(typeof VMM != 'undefined' && typeof VMM.MediaElement == 'undefined') {
|
||
|
|
||
|
VMM.MediaElement = ({
|
||
|
|
||
|
init: function() {
|
||
|
return this;
|
||
|
},
|
||
|
|
||
|
thumbnail: function(data, w, h) {
|
||
|
_w = 16;
|
||
|
_h = 24;
|
||
|
if (w != null && w != "") {_w = w};
|
||
|
if (h != null && h != "") {_h = h};
|
||
|
|
||
|
if (data.media != null && data.media != "") {
|
||
|
_valid = true;
|
||
|
var mediaElem = "";
|
||
|
var m = VMM.MediaType(data.media); //returns an object with .type and .id
|
||
|
// CREATE MEDIA CODE
|
||
|
if (m.type == "image") {
|
||
|
//mediaElem = "<div class='thumbnail thumb-photo'><img src='" + m.id + "' width='" + _w + "px' height='" + _h + "px'></div>";
|
||
|
mediaElem = "<div class='thumbnail thumb-photo'></div>";
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "flickr") {
|
||
|
//mediaElem = "<div class='thumbnail thumb-photo'><img id='flickr_" + m.id + "_thumb' width='" + _w + "px' height='" + _h + "px'></div>";
|
||
|
mediaElem = "<div class='thumbnail thumb-photo'></div>";
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "youtube") {
|
||
|
mediaElem = "<div class='thumbnail thumb-youtube'></div>";
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "googledoc") {
|
||
|
mediaElem = "<div class='thumbnail thumb-document'></div>";
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "vimeo") {
|
||
|
mediaElem = "<div class='thumbnail thumb-vimeo'></div>";
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "dailymotion") {
|
||
|
mediaElem = "<div class='thumbnail thumb-video'></div>";
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "twitter"){
|
||
|
mediaElem = "<div class='thumbnail thumb-twitter'></div>";
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "twitter-ready") {
|
||
|
mediaElem = "<div class='thumbnail thumb-twitter'></div>";
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "soundcloud") {
|
||
|
mediaElem = "<div class='thumbnail thumb-audio'></div>";
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "google-map") {
|
||
|
mediaElem = "<div class='thumbnail thumb-map'></div>";
|
||
|
return mediaElem;
|
||
13 years ago
|
} else if (m.type == "wikipedia") {
|
||
|
mediaElem = "<div class='thumbnail thumb-wikipedia'></div>";
|
||
|
return mediaElem;
|
||
13 years ago
|
} else if (m.type == "unknown") {
|
||
|
if (m.id.match("blockquote")) {
|
||
|
mediaElem = "<div class='thumbnail thumb-quote'></div>";
|
||
|
} else {
|
||
|
mediaElem = "<div class='thumbnail thumb-plaintext'></div>";
|
||
|
}
|
||
|
return mediaElem;
|
||
|
} else if (m.type == "website") {
|
||
|
mediaElem = "<div class='thumbnail thumb-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 thumb-plaintext'></div>";
|
||
|
return mediaElem;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
create: function(data) {
|
||
|
//$mediacontainer = element;
|
||
|
var _valid = false;
|
||
|
|
||
|
if (data.media != null && data.media != "") {
|
||
|
var mediaElem = "";
|
||
|
var captionElem = "";
|
||
|
var creditElem = "";
|
||
|
var m = VMM.MediaType(data.media); //returns an object with .type and .id
|
||
|
var isTextMedia = false;
|
||
13 years ago
|
var _id = "";
|
||
13 years ago
|
_valid = true;
|
||
|
|
||
|
// 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>";
|
||
|
}
|
||
|
// IMAGE
|
||
|
if (m.type == "image") {
|
||
|
mediaElem = "<img src='" + m.id + "'>";
|
||
|
// FLICKR
|
||
|
} else if (m.type == "flickr") {
|
||
13 years ago
|
_id = "flickr_" + m.id;
|
||
|
mediaElem = "<a href='" + m.link + "' target='_blank'><img id='" + _id + "_large" + "'></a>";
|
||
|
VMM.ExternalAPI.flickr.get(m.id, "#" + _id);
|
||
13 years ago
|
// GOOGLE DOCS
|
||
|
} else if (m.type == "googledoc") {
|
||
13 years ago
|
_id = "googledoc_" + VMM.Util.unique_ID(5);
|
||
|
mediaElem = "<div class='media-frame doc' id='" + _id + "'><span class='messege'><p>Loading Document</p></span></div>";
|
||
|
VMM.ExternalAPI.googledocs.get(m.id, _id);
|
||
13 years ago
|
// YOUTUBE
|
||
|
} else if (m.type == "youtube") {
|
||
|
mediaElem = "<div class='media-frame video youtube' id='youtube_" + m.id + "'><span class='messege'><p>Loading YouTube video</p></span></div>";
|
||
|
VMM.ExternalAPI.youtube.get(m.id);
|
||
|
// VIMEO
|
||
|
} else if (m.type == "vimeo") {
|
||
|
mediaElem = "<iframe class='media-frame video vimeo' autostart='false' frameborder='0' width='100%' height='100%' src='http://player.vimeo.com/video/" + m.id + "?title=0&byline=0&portrait=0&color=ffffff'></iframe>";
|
||
|
// DAILYMOTION
|
||
|
} else if (m.type == "dailymotion") {
|
||
|
mediaElem = "<iframe class='media-frame video dailymotion' autostart='false' frameborder='0' width='100%' height='100%' src='http://www.dailymotion.com/embed/video/" + m.id + "'></iframe>";
|
||
|
// TWITTER
|
||
|
} else if (m.type == "twitter"){
|
||
|
mediaElem = "<div class='twitter' id='" + "twitter_" + m.id + "'><span class='messege'><p>Loading Tweet</p></span></div>";
|
||
|
isTextMedia = true;
|
||
|
VMM.ExternalAPI.twitter.prettyHTML(m.id);
|
||
|
// TWITTER
|
||
|
} else if (m.type == "twitter-ready") {
|
||
|
mediaElem = m.id;
|
||
|
// SOUNDCLOUD
|
||
|
} else if (m.type == "soundcloud") {
|
||
13 years ago
|
_id = "soundcloud_" + VMM.Util.unique_ID(5);
|
||
|
mediaElem = "<div class='media-frame soundcloud' id='" + _id + "'><span class='messege'><p>Loading Sound</p></span></div>";
|
||
|
VMM.ExternalAPI.soundcloud.get(m.id, _id);
|
||
13 years ago
|
// GOOGLE MAPS
|
||
|
} else if (m.type == "google-map") {
|
||
13 years ago
|
_id = "googlemap_" + VMM.Util.unique_ID(7);
|
||
|
mediaElem = "<div class='media-frame map' id='" + _id + "'><span class='messege'><p>Loading Map</p></span></div>";
|
||
|
VMM.ExternalAPI.googlemaps.get(m.id, _id);
|
||
|
// WIKIPEDIA
|
||
|
} else if (m.type == "wikipedia") {
|
||
|
_id = "wikipedia_" + VMM.Util.unique_ID(7);
|
||
13 years ago
|
mediaElem = "<div class='wikipedia' id='" + _id + "'><span class='messege'><p>Loading Wikipedia</p></span></div>";
|
||
13 years ago
|
VMM.ExternalAPI.wikipedia.get(m.id, _id);
|
||
13 years ago
|
// UNKNOWN
|
||
|
} else if (m.type == "unknown") {
|
||
|
trace("NO KNOWN MEDIA TYPE FOUND TRYING TO JUST PLACE THE HTML");
|
||
|
mediaElem = "<div class='media-frame plain-text'><div class='container'>" + VMM.Util.properQuotes(m.id) + "</div></div>";
|
||
|
// WEBSITE
|
||
|
} else if (m.type == "website") {
|
||
|
mediaElem = "<iframe class='media-frame website' frameborder='0' autostart='false' 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>";
|
||
|
// NO MATCH
|
||
|
} else {
|
||
|
trace("NO KNOWN MEDIA TYPE FOUND");
|
||
|
trace(m.type);
|
||
|
}
|
||
|
|
||
|
// WRAP THE MEDIA ELEMENT
|
||
|
mediaElem = "<div class='media-container' >" + mediaElem + creditElem + captionElem + "</div>";
|
||
|
// 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>";
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
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();
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
/***********************************************
|
||
|
Begin VMM.MediaType.js
|
||
|
***********************************************/
|
||
13 years ago
|
|
||
13 years ago
|
/* MediaType
|
||
|
================================================== */
|
||
|
if(typeof VMM != 'undefined' && typeof VMM.MediaType == 'undefined') {
|
||
13 years ago
|
|
||
13 years ago
|
//VMM.mediaType.youtube(d); //should return a true or false
|
||
|
// VMM.MediaType(url); //returns an object with .type and .id
|
||
|
|
||
|
VMM.MediaType = function(d) {
|
||
|
var success = false;
|
||
|
var media = {};
|
||
|
|
||
|
if (d.match("div class='twitter'")) {
|
||
|
media.type = "twitter-ready";
|
||
|
media.id = d;
|
||
|
success = true;
|
||
|
} else if (d.match('(www.)?youtube|youtu\.be')) {
|
||
|
if (d.match('v=')) {
|
||
|
media.id = VMM.Util.getUrlVars(d)["v"];
|
||
|
} else {
|
||
|
media.id = d.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];
|
||
|
}
|
||
|
media.type = "youtube";
|
||
|
success = true;
|
||
|
} else if (d.match('(player.)?vimeo\.com')) {
|
||
|
media.type = "vimeo";
|
||
|
media.id = d.split(/video\/|\/\/vimeo\.com\//)[1].split(/[?&]/)[0];;
|
||
|
success = true;
|
||
|
} else if (d.match('(www.)?dailymotion\.com')) {
|
||
|
media.id = d.split(/video\/|\/\/dailymotion\.com\//)[1];
|
||
|
media.type = "dailymotion";
|
||
|
success = true;
|
||
|
} else if (d.match('(player.)?soundcloud\.com')) {
|
||
|
media.type = "soundcloud";
|
||
|
media.id = d;
|
||
|
success = true;
|
||
|
} else if (d.match('(www.)?twitter\.com')) {
|
||
|
if (d.match("status\/")) {
|
||
|
media.id = d.split("status\/")[1];
|
||
|
} else if (d.match("statuses\/")) {
|
||
|
media.id = d.split("statuses\/")[1];
|
||
|
} else {
|
||
|
media.id = "";
|
||
|
}
|
||
|
media.type = "twitter";
|
||
|
success = true;
|
||
|
} else if (d.match("maps.google") && !d.match("staticmap")) {
|
||
|
media.type = "google-map";
|
||
|
media.id = d.split(/src=['|"][^'|"]*?['|"]/gi);
|
||
|
success = true;
|
||
|
} else if (d.match("flickr.com/photos")) {
|
||
|
media.type = "flickr";
|
||
|
media.id = d.split("photos\/")[1].split("/")[1];
|
||
|
media.link = d;
|
||
|
success = true;
|
||
|
} else if (d.match(/jpg|jpeg|png|gif/i) || d.match("staticmap")) {
|
||
|
media.type = "image";
|
||
|
media.id = d;
|
||
|
success = true;
|
||
|
} else if (VMM.FileExtention.googleDocType(d)) {
|
||
|
media.type = "googledoc";
|
||
|
media.id = d;
|
||
|
success = true;
|
||
13 years ago
|
} else if (d.match('(www.)?wikipedia\.org')) {
|
||
|
media.type = "wikipedia";
|
||
13 years ago
|
//media.id = d.split("wiki\/")[1];
|
||
|
var wiki_id = d.split("wiki\/")[1].split("#")[0].replace("_", " ");
|
||
|
media.id = VMM.Util.toTitleCase(wiki_id).replace(" ", "%20");
|
||
|
trace("WIKIPEDIA " + media.id);
|
||
13 years ago
|
success = true;
|
||
13 years ago
|
} 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;
|
||
|
}
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/***********************************************
|
||
|
Begin VMM.Media.js
|
||
|
***********************************************/
|
||
13 years ago
|
|
||
13 years ago
|
/* Media
|
||
|
================================================== */
|
||
|
if(typeof VMM != 'undefined' && typeof VMM.Media == 'undefined') {
|
||
|
|
||
|
// something = new VMM.Media(parent, w, h, {thedata});
|
||
|
VMM.Media = function(parent, w, h, thedata) {
|
||
|
|
||
|
/* PRIVATE VARS
|
||
|
================================================== */
|
||
|
var data = {}; // HOLDS DATA
|
||
|
|
||
|
var _valid = false;
|
||
|
|
||
|
var config = {
|
||
|
width: 720,
|
||
|
height: 400,
|
||
|
content_width: 720,
|
||
|
content_height: 400,
|
||
|
ease: "easeInOutExpo",
|
||
|
duration: 1000,
|
||
|
spacing: 15
|
||
|
};
|
||
|
/* ELEMENTS
|
||
|
================================================== */
|
||
|
var $media = "";
|
||
|
var $container = "";
|
||
|
var $mediacontainer = "";
|
||
|
var $mediaelement = "";
|
||
|
var layout = parent; // expecting media div
|
||
|
|
||
|
if (w != null && w != "") {config.width = w};
|
||
|
if (h != null && h != "") {config.height = h};
|
||
|
/*
|
||
|
if (typeof thedata != "undefined") {
|
||
|
data = thedata;
|
||
|
this.init(data);
|
||
|
}
|
||
|
*/
|
||
|
/* PUBLIC FUNCTIONS
|
||
|
================================================== */
|
||
|
this.init = function(d) {
|
||
|
if(typeof d != 'undefined') {
|
||
|
this.setData(d);
|
||
|
} else {
|
||
|
trace("WAITING ON DATA");
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var build = function(media, caption, credit) {
|
||
|
|
||
|
$media = VMM.appendAndGetElement(layout, "<div>", "media");
|
||
|
$container = VMM.appendAndGetElement($media, "<div>", "container");
|
||
|
$mediacontainer = VMM.appendAndGetElement($container, "<div>", "media-container");
|
||
|
|
||
13 years ago
|
|
||
13 years ago
|
if (data.media != null && data.media != "") {
|
||
13 years ago
|
|
||
13 years ago
|
_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"));
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
// CAPTION
|
||
|
if (data.caption != null && data.caption != "") {
|
||
|
VMM.appendElement($container, VMM.createElement("div", data.caption, "caption"));
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
}
|
||
|
};
|
||
13 years ago
|
|
||
|
|
||
13 years ago
|
|
||
13 years ago
|
/* GETTERS AND SETTERS
|
||
|
================================================== */
|
||
13 years ago
|
|
||
13 years ago
|
this.setData = function(d) {
|
||
|
if(typeof d != 'undefined') {
|
||
|
data = d;
|
||
|
build();
|
||
|
} else{
|
||
|
trace("NO DATA");
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/* RESIZE
|
||
|
================================================== */
|
||
|
|
||
|
function reSize() {
|
||
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
// Less expensive to use prototype
|
||
|
|
||
|
VMM.Media.prototype.height = function(h) {
|
||
|
if (h != null && h != "") {
|
||
|
config.height = h;
|
||
|
reSize();
|
||
|
} else {
|
||
|
return config.height;
|
||
13 years ago
|
}
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Media.prototype.width = function(w) {
|
||
|
if (w != null && w != "") {
|
||
|
config.width = w;
|
||
|
reSize();
|
||
|
} else {
|
||
|
return config.width;
|
||
13 years ago
|
}
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
/* GETTERS AND SETTERS
|
||
|
================================================== */
|
||
|
|
||
|
VMM.Media.prototype.getData = function() {
|
||
|
return data;
|
||
13 years ago
|
};
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Media.prototype.setConfig = function(d) {
|
||
|
if(typeof d != 'undefined') {
|
||
|
config = d;
|
||
|
} else{
|
||
|
trace("NO CONFIG DATA");
|
||
13 years ago
|
}
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
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();
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
}
|
||
|
|
||
|
VMM.Media.prototype.active = function() {
|
||
|
return _active;
|
||
13 years ago
|
};
|
||
13 years ago
|
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/***********************************************
|
||
|
Begin VMM.FileExtention.js
|
||
|
***********************************************/
|
||
|
|
||
|
/* File Extention
|
||
|
================================================== */
|
||
|
if(typeof VMM != 'undefined' && typeof VMM.FileExtention == 'undefined') {
|
||
|
//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;
|
||
13 years ago
|
|
||
13 years ago
|
for (var i = 0; i < validFileExtensions.length; i++) {
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
if (fileExtension.toLowerCase().match(validFileExtensions[i].toString().toLowerCase()) || fileName.match("docs.google.com") ) {
|
||
|
flag = true;
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
return flag;
|
||
|
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/***********************************************
|
||
|
Begin VMM.ExternalAPI.js
|
||
|
***********************************************/
|
||
|
|
||
|
/* External API
|
||
|
================================================== */
|
||
|
if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
|
||
13 years ago
|
|
||
13 years ago
|
VMM.ExternalAPI = {
|
||
13 years ago
|
|
||
13 years ago
|
pushQues: function() {
|
||
13 years ago
|
|
||
13 years ago
|
if (VMM.master_config.googlemaps.active) {
|
||
|
VMM.ExternalAPI.googlemaps.pushQue();
|
||
13 years ago
|
}
|
||
13 years ago
|
if (VMM.master_config.youtube.active) {
|
||
|
VMM.ExternalAPI.youtube.pushQue();
|
||
13 years ago
|
}
|
||
13 years ago
|
if (VMM.master_config.soundcloud.active) {
|
||
|
VMM.ExternalAPI.soundcloud.pushQue();
|
||
13 years ago
|
}
|
||
13 years ago
|
if (VMM.master_config.googledocs.active) {
|
||
|
VMM.ExternalAPI.googledocs.pushQue();
|
||
13 years ago
|
}
|
||
13 years ago
|
if (VMM.master_config.wikipedia.active) {
|
||
|
VMM.ExternalAPI.wikipedia.pushQue();
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
13 years ago
|
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) );
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
// 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 = "";
|
||
|
|
||
|
|
||
|
/* 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 = "http://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"); });
|
||
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
|
||
|
},
|
||
|
|
||
|
// 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;
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
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) {
|
||
|
|
||
|
/* FORMAT RESPONSE
|
||
|
================================================== */
|
||
|
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);
|
||
|
});
|
||
|
|
||
|
},
|
||
|
|
||
|
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);
|
||
|
|
||
13 years ago
|
VMM.getJSON(the_url, VMM.ExternalAPI.twitter.formatJSON)
|
||
13 years ago
|
.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, "<span class='messege'><p>Error loading tweet: " + id + "</p></span>" );
|
||
|
|
||
|
// CHECK RATE STATUS
|
||
|
VMM.getJSON("http://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>Tweet " + id + " was not found.</p>";
|
||
|
}
|
||
|
VMM.attachElement("#twitter_" + id, "<span class='messege'>" + mes + "</span>" );
|
||
|
});
|
||
|
|
||
|
},
|
||
|
|
||
|
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 );
|
||
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
13 years ago
|
googlemaps: {
|
||
|
|
||
|
get: function(url, id) {
|
||
|
var timer;
|
||
|
var map_vars = VMM.Util.getUrlVars(url);
|
||
|
var api_key;
|
||
|
|
||
|
if (VMM.master_config.Timeline.api_keys.google != "") {
|
||
|
api_key = VMM.master_config.Timeline.api_keys.google;
|
||
|
} else {
|
||
|
api_key = Aes.Ctr.decrypt(VMM.master_config.api_keys_master.google, VMM.master_config.vp, 256);
|
||
|
}
|
||
|
|
||
|
var map_url = "http://maps.googleapis.com/maps/api/js?key=" + api_key + "&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.que.push(map);
|
||
|
} else {
|
||
|
VMM.master_config.googlemaps.que.push(map);
|
||
|
|
||
|
if (VMM.master_config.googlemaps.api_loaded) {
|
||
|
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.LoadLib.js(map_url, function() {
|
||
|
trace("Google Maps API Library Loaded");
|
||
|
});
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
},
|
||
|
|
||
|
create: function(m) {
|
||
|
var map_attribution = "";
|
||
|
var layer;
|
||
|
var map;
|
||
|
|
||
|
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];
|
||
13 years ago
|
} else {
|
||
13 years ago
|
if (VMM.ExternalAPI.googlemaps.defaultType(name)) {
|
||
|
trace("GOOGLE MAP DEFAULT TYPE");
|
||
|
return google.maps.MapTypeId[name.toUpperCase()];
|
||
|
} else {
|
||
|
trace("Not a maptype: " + name );
|
||
|
}
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
|
||
|
google.maps.VeriteMapType = function(name) {
|
||
|
if (VMM.ExternalAPI.googlemaps.defaultType(name)) {
|
||
|
return google.maps.MapTypeId[name.toUpperCase()];
|
||
|
} else {
|
||
|
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("_");
|
||
|
|
||
|
/* Make the Map
|
||
|
================================================== */
|
||
|
|
||
|
|
||
|
if (type.of(VMM.master_config.Timeline.maptype) == "string") {
|
||
|
if (VMM.ExternalAPI.googlemaps.defaultType(VMM.master_config.Timeline.maptype)) {
|
||
|
layer = google.maps.MapTypeId[VMM.master_config.Timeline.maptype.toUpperCase()];
|
||
|
} else {
|
||
|
layer = VMM.master_config.Timeline.maptype;
|
||
|
}
|
||
|
} else {
|
||
|
layer = "toner";
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
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") {
|
||
|
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"]);
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
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]
|
||
|
}
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
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>");
|
||
|
|
||
|
var map = new google.maps.Map(document.getElementById(unique_map_id), map_options);
|
||
|
|
||
|
if (VMM.ExternalAPI.googlemaps.defaultType(VMM.master_config.Timeline.maptype)) {
|
||
|
|
||
|
} else {
|
||
|
map.mapTypes.set(layer, new google.maps.VeriteMapType(layer));
|
||
|
// ATTRIBUTION
|
||
|
var map_attribution_html = "<div class='map-attribution'><div class='attribution-text'>" + map_attribution + "</div></div>";
|
||
|
VMM.appendElement("#"+unique_map_id, map_attribution_html);
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
loadKML();
|
||
|
|
||
|
// KML
|
||
|
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});
|
||
|
var infowindow = new google.maps.InfoWindow();
|
||
|
kml_layer.setMap(map);
|
||
|
|
||
|
google.maps.event.addListenerOnce(kml_layer, "defaultviewport_changed", function() {
|
||
|
map.fitBounds(kml_layer.getDefaultViewport() );
|
||
|
if (has_location) {
|
||
|
map.panTo(location);
|
||
|
}
|
||
|
if (has_zoom) {
|
||
|
map.setZoom(zoom);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
google.maps.event.addListener(kml_layer, 'click', function(kmlEvent) {
|
||
|
var text = kmlEvent.featureData.description;
|
||
|
showInfoWindow(text);
|
||
|
|
||
|
function showInfoWindow(c) {
|
||
|
infowindow.setContent(c);
|
||
|
infowindow.open(map);
|
||
|
}
|
||
|
});
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
},
|
||
|
|
||
|
pushQue: function() {
|
||
|
for(var i = 0; i < VMM.master_config.googlemaps.que.length; i++) {
|
||
|
VMM.ExternalAPI.googlemaps.create(VMM.master_config.googlemaps.que[i]);
|
||
13 years ago
|
}
|
||
13 years ago
|
VMM.master_config.googlemaps.que = [];
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
onMapAPIReady: function() {
|
||
|
VMM.master_config.googlemaps.map_active = true;
|
||
|
VMM.master_config.googlemaps.places_active = true;
|
||
|
VMM.ExternalAPI.googlemaps.onAPIReady();
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
onPlacesAPIReady: function() {
|
||
|
VMM.master_config.googlemaps.places_active = true;
|
||
|
VMM.ExternalAPI.googlemaps.onAPIReady();
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
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;
|
||
|
VMM.ExternalAPI.googlemaps.pushQue();
|
||
|
}
|
||
|
}
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
defaultType: function(name) {
|
||
|
if (name.toLowerCase() == "satellite" || name.toLowerCase() == "hybrid" || name.toLowerCase() == "terrain" || name.toLowerCase() == "roadmap") {
|
||
|
return true;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
return false;
|
||
13 years ago
|
}
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
13 years ago
|
map_subdomains: ["", "a.", "b.", "c.", "d."],
|
||
13 years ago
|
|
||
13 years ago
|
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": 14,
|
||
|
"attribution": "apple"
|
||
|
},
|
||
|
"watercolor": {
|
||
|
"url": "http://{S}tile.stamen.com/watercolor/{Z}/{X}/{Y}.jpg",
|
||
|
"minZoom": 3,
|
||
|
"maxZoom": 16,
|
||
|
"attribution": "stamen"
|
||
|
}
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
},
|
||
|
|
||
|
googledocs: {
|
||
|
|
||
|
get: function(url, id) {
|
||
|
var doc = {url: url, id: id};
|
||
|
VMM.master_config.googledocs.que.push(doc);
|
||
|
VMM.master_config.googledocs.active = true;
|
||
|
},
|
||
|
|
||
|
create: function(doc) {
|
||
|
var mediaElem = "";
|
||
|
if (doc.url.match(/docs.google.com/i)) {
|
||
13 years ago
|
mediaElem = "<iframe class='doc' frameborder='0' width='100%' height='100%' src='" + doc.url + "&embedded=true'></iframe>";
|
||
13 years ago
|
} else {
|
||
13 years ago
|
mediaElem = "<iframe class='doc' frameborder='0' width='100%' height='100%' src='" + "http://docs.google.com/viewer?url=" + doc.url + "&embedded=true'></iframe>";
|
||
13 years ago
|
}
|
||
|
VMM.attachElement("#"+doc.id, mediaElem);
|
||
|
},
|
||
|
|
||
|
pushQue: function() {
|
||
|
for(var i = 0; i < VMM.master_config.googledocs.que.length; i++) {
|
||
|
VMM.ExternalAPI.googledocs.create(VMM.master_config.googledocs.que[i]);
|
||
|
}
|
||
|
VMM.master_config.googledocs.que = [];
|
||
|
}
|
||
|
|
||
|
},
|
||
|
|
||
|
flickr: {
|
||
|
|
||
|
get: function(mid, id) {
|
||
|
var api_key;
|
||
|
if (VMM.master_config.Timeline.api_keys.flickr != "") {
|
||
|
api_key = VMM.master_config.Timeline.api_keys.flickr;
|
||
|
} else {
|
||
|
api_key = Aes.Ctr.decrypt(VMM.master_config.api_keys_master.flickr, VMM.master_config.vp, 256)
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
var the_url = "http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=" + api_key + "&photo_id=" + mid + "&format=json&jsoncallback=?";
|
||
|
VMM.getJSON(the_url, VMM.ExternalAPI.flickr.create);
|
||
|
},
|
||
|
|
||
|
create: 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;
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
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.Lib.attr("#"+flickr_large_id, "src", flickr_img_large);
|
||
|
VMM.Lib.attr("#"+flickr_thumb_id, "src", flickr_img_thumb);
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
},
|
||
|
|
||
13 years ago
|
soundcloud: {
|
||
|
|
||
|
get: function(url, id) {
|
||
|
var sound = {url: url, id: id};
|
||
|
VMM.master_config.soundcloud.que.push(sound);
|
||
|
VMM.master_config.soundcloud.active = true;
|
||
|
},
|
||
|
|
||
|
create: function(sound) {
|
||
|
var the_url = "http://soundcloud.com/oembed?url=" + sound.url + "&format=js&callback=?";
|
||
|
VMM.getJSON(the_url, function(d) {
|
||
|
VMM.attachElement("#"+sound.id, d.html);
|
||
|
});
|
||
|
},
|
||
|
|
||
|
pushQue: function() {
|
||
|
for(var i = 0; i < VMM.master_config.soundcloud.que.length; i++) {
|
||
|
VMM.ExternalAPI.soundcloud.create(VMM.master_config.soundcloud.que[i]);
|
||
13 years ago
|
}
|
||
13 years ago
|
VMM.master_config.soundcloud.que = [];
|
||
|
},
|
||
|
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
wikipedia: {
|
||
|
|
||
|
get: function(url, id) {
|
||
13 years ago
|
trace("WIKIPEDIA GET");
|
||
13 years ago
|
var api_obj = {url: url, id: id};
|
||
|
VMM.master_config.wikipedia.que.push(api_obj);
|
||
13 years ago
|
VMM.master_config.wikipedia.active = true;
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
13 years ago
|
create: function(api_obj) {
|
||
13 years ago
|
|
||
|
var the_url = "http://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles=" + api_obj.url + "&format=json&exintro=1&callback=?";
|
||
13 years ago
|
VMM.getJSON(the_url, function(d) {
|
||
13 years ago
|
var wiki_extract = VMM.Util.getObjectAttributeByIndex(d.query.pages, 0).extract;
|
||
|
var wiki_title = VMM.Util.getObjectAttributeByIndex(d.query.pages, 0).title;
|
||
|
var _wiki = "";
|
||
|
var wiki_text = "";
|
||
|
var wiki_text_array = wiki_extract.split("<p>");
|
||
|
var wiki_number_of_paragraphs = 2;
|
||
|
|
||
|
for(var i = 0; i < wiki_text_array.length; i++) {
|
||
|
if (i+1 <= wiki_number_of_paragraphs && i+1 < wiki_text_array.length) {
|
||
|
wiki_text += "<p>" + wiki_text_array[i+1];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
_wiki = "<h4>" + wiki_title + "</h4>";
|
||
|
_wiki += "<div class='wiki-source'>From Wikipedia, the free encyclopedia</span>";
|
||
|
_wiki += VMM.Util.linkify_wikipedia(wiki_text);
|
||
|
|
||
|
if (wiki_extract.match("REDIRECT")) {
|
||
13 years ago
|
|
||
13 years ago
|
} else {
|
||
|
VMM.attachElement("#"+api_obj.id, _wiki );
|
||
13 years ago
|
}
|
||
|
});
|
||
13 years ago
|
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
pushQue: function() {
|
||
13 years ago
|
trace("WIKIPEDIA PUSH QUE");
|
||
13 years ago
|
for(var i = 0; i < VMM.master_config.wikipedia.que.length; i++) {
|
||
|
VMM.ExternalAPI.wikipedia.create(VMM.master_config.wikipedia.que[i]);
|
||
|
}
|
||
|
VMM.master_config.wikipedia.que = [];
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
},
|
||
|
|
||
|
youtube: {
|
||
|
|
||
|
get: function(id) {
|
||
|
if (VMM.master_config.youtube.active) {
|
||
|
VMM.master_config.youtube.que.push(id);
|
||
|
} else {
|
||
|
VMM.master_config.youtube.que.push(id);
|
||
|
if (!VMM.master_config.youtube.api_loaded) {
|
||
|
VMM.LoadLib.js('http://www.youtube.com/player_api', function() {
|
||
|
trace("YouTube API Library Loaded");
|
||
|
});
|
||
|
}
|
||
|
}
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
create: 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
|
||
|
},
|
||
|
videoId: id,
|
||
|
events: {
|
||
|
'onReady': VMM.ExternalAPI.youtube.onPlayerReady,
|
||
|
'onStateChange': VMM.ExternalAPI.youtube.onStateChange
|
||
|
}
|
||
|
});
|
||
|
|
||
|
VMM.master_config.youtube.array.push(p);
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
pushQue: function() {
|
||
|
for(var i = 0; i < VMM.master_config.youtube.que.length; i++) {
|
||
|
VMM.ExternalAPI.youtube.create(VMM.master_config.youtube.que[i]);
|
||
|
}
|
||
|
VMM.master_config.youtube.que = [];
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
onAPIReady: function() {
|
||
|
VMM.master_config.youtube.active = true;
|
||
|
VMM.ExternalAPI.youtube.pushQue();
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
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();
|
||
|
}
|
||
|
}
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
onPlayerReady: function(e) {
|
||
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
|
||
|
}
|
||
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
}
|
||
|
|
||
|
/* YOUTUBE API READY
|
||
|
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();
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/***********************************************
|
||
13 years ago
|
Begin VMM.TouchSlider.js
|
||
13 years ago
|
***********************************************/
|
||
13 years ago
|
|
||
13 years ago
|
/* TOUCH SLIDER
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
if(typeof VMM != 'undefined' && typeof VMM.TouchSlider == 'undefined') {
|
||
13 years ago
|
|
||
13 years ago
|
// 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;
|
||
|
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
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");
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
13 years ago
|
makeTouchable: function(touch_object, move_object) {
|
||
|
VMM.bindEvent(touch_object, VMM.TouchSlider.onTouchStart, "touchstart", {element: move_object});
|
||
|
VMM.bindEvent(touch_object, VMM.TouchSlider.onTouchMove, "touchmove", {element: move_object});
|
||
|
VMM.bindEvent(touch_object, VMM.TouchSlider.onTouchEnd, "touchend", {element: move_object});
|
||
|
},
|
||
|
onTouchStart: function(e) {
|
||
|
VMM.TouchSlider.touchStart(e.data.element, e);
|
||
|
e.stopPropagation();
|
||
|
return true;
|
||
|
},
|
||
|
onTouchEnd: function(e) {
|
||
|
e.stopPropagation();
|
||
|
|
||
|
if (VMM.TouchSlider.sliding) {
|
||
|
VMM.TouchSlider.sliding = false;
|
||
|
VMM.TouchSlider.touchEnd(e.data.element, e);
|
||
|
return false;
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
13 years ago
|
|
||
|
},
|
||
13 years ago
|
onTouchMove: function(e) {
|
||
|
VMM.TouchSlider.touchMove(e.data.element, e);
|
||
|
e.preventDefault();
|
||
|
e.stopPropagation();
|
||
|
return false;
|
||
|
},
|
||
|
getLeft: function(elem) {
|
||
|
return parseInt(VMM.Lib.css(elem, 'left').substring(0, VMM.Lib.css(elem, 'left').length - 2), 10);
|
||
|
},
|
||
|
getTop: function(elem) {
|
||
|
return parseInt(VMM.Lib.css(elem, 'top').substring(0, VMM.Lib.css(elem, 'top').length - 2), 10);
|
||
|
},
|
||
|
touchStart: function(elem, e) {
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(elem, '-webkit-transition-duration', '0');
|
||
|
|
||
|
VMM.TouchSlider.startX = e.originalEvent.touches[0].screenX;
|
||
|
VMM.TouchSlider.startY = e.originalEvent.touches[0].screenY;
|
||
|
|
||
|
VMM.TouchSlider.startLeft = VMM.TouchSlider.getLeft(elem);
|
||
|
VMM.TouchSlider.startTop = VMM.TouchSlider.getTop(elem);
|
||
|
|
||
|
VMM.TouchSlider.touchStartTime = new Date().getTime();
|
||
|
|
||
|
},
|
||
|
touchEnd: function(elem, e) {
|
||
|
if (VMM.TouchSlider.getLeft(elem) > 0) {
|
||
13 years ago
|
|
||
13 years ago
|
//This means they dragged to the right past the first item
|
||
|
|
||
|
if (VMM.TouchSlider.vertical) {
|
||
|
VMM.Lib.animate(elem, 1000, "", {"top": 0});
|
||
|
} else {
|
||
|
VMM.Lib.animate(elem, 1000, "", {"left": 0});
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
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));
|
||
13 years ago
|
} else {
|
||
13 years ago
|
//Stay on the current cell
|
||
|
newLeft -= t;
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
VMM.fireEvent(elem, "TOUCHUPDATE", [Math.min(0, newLeft)]);
|
||
|
|
||
|
} else {
|
||
|
trace("not sticky");
|
||
|
//VMM.TouchSlider.doSlide(elem, Math.min(0, newLeft), '0.5s');
|
||
|
VMM.Lib.animate(elem, 500, "", {"left": Math.min(0, newLeft)});
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
VMM.TouchSlider.startX = null;
|
||
|
VMM.TouchSlider.startY = null;
|
||
|
|
||
|
},
|
||
|
doSlide: function(elem, x, duration) {
|
||
|
VMM.Lib.css(elem, '-webkit-transition-property', 'left');
|
||
|
VMM.Lib.css(elem, '-webkit-transition-duration', duration);
|
||
|
VMM.Lib.css(elem, 'left', x);
|
||
|
},
|
||
|
touchMove: function(elem, e) {
|
||
|
|
||
|
if (!VMM.TouchSlider.sliding) {
|
||
|
//elem.parent().addClass('sliding');
|
||
|
}
|
||
|
|
||
|
VMM.TouchSlider.sliding = true;
|
||
|
|
||
|
if (VMM.TouchSlider.vertical) {
|
||
|
|
||
|
if (VMM.TouchSlider.startY > e.originalEvent.touches[0].screenY) {
|
||
|
VMM.Lib.css(elem, 'top', -(VMM.TouchSlider.startY - e.originalEvent.touches[0].screenY - VMM.TouchSlider.startTop));
|
||
|
VMM.TouchSlider.slidingTop = true;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
var top = (e.originalEvent.touches[0].screenY - VMM.TouchSlider.startY + VMM.TouchSlider.startTop);
|
||
|
VMM.Lib.css(elem, 'top', -(VMM.TouchSlider.startY - e.originalEvent.touches[0].screenY - VMM.TouchSlider.startTop));
|
||
|
VMM.TouchSlider.slidingTop = false;
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
} else {
|
||
|
|
||
|
if (VMM.TouchSlider.startX > e.originalEvent.touches[0].screenX) {
|
||
|
VMM.Lib.css(elem, 'left', -(VMM.TouchSlider.startX - e.originalEvent.touches[0].screenX - VMM.TouchSlider.startLeft));
|
||
|
VMM.TouchSlider.slidingLeft = true;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
var left = (e.originalEvent.touches[0].screenX - VMM.TouchSlider.startX + VMM.TouchSlider.startLeft);
|
||
|
VMM.Lib.css(elem, 'left', -(VMM.TouchSlider.startX - e.originalEvent.touches[0].screenX - VMM.TouchSlider.startLeft));
|
||
|
VMM.TouchSlider.slidingLeft = false;
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
}
|
||
|
}
|
||
13 years ago
|
}
|
||
|
|
||
|
/***********************************************
|
||
13 years ago
|
Begin VMM.DragSlider.js
|
||
13 years ago
|
***********************************************/
|
||
|
|
||
13 years ago
|
/* DRAG SLIDER
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
if(typeof VMM != 'undefined' && typeof VMM.DragSlider == 'undefined') {
|
||
|
// VMM.DragSlider.createSlidePanel(drag_object, move_object, w, padding, sticky);
|
||
|
// VMM.DragSlider.cancelSlide();
|
||
|
VMM.DragSlider = {
|
||
|
createPanel: function(drag_object, move_object, w, padding, sticky) {
|
||
|
|
||
|
|
||
|
|
||
|
var x = padding;
|
||
|
VMM.DragSlider.width = w;
|
||
|
VMM.DragSlider.makeDraggable(drag_object, move_object);
|
||
|
VMM.DragSlider.drag_elem = drag_object;
|
||
|
/*
|
||
|
if (sticky != null && sticky != "") {
|
||
|
VMM.TouchSlider.sticky = sticky;
|
||
|
} else {
|
||
|
VMM.TouchSlider.sticky = false;
|
||
13 years ago
|
}
|
||
13 years ago
|
*/
|
||
|
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;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
return true;
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
},
|
||
|
onDragMove: function(e) {
|
||
|
VMM.DragSlider.dragMove(e.data.element, e);
|
||
|
e.preventDefault();
|
||
|
e.stopPropagation();
|
||
|
return false;
|
||
|
},
|
||
|
dragStart: function(elem, delem, e) {
|
||
|
|
||
|
VMM.DragSlider.startX = e.pageX;
|
||
|
|
||
|
VMM.DragSlider.startLeft = VMM.DragSlider.getLeft(elem);
|
||
|
VMM.DragSlider.dragStartTime = new Date().getTime();
|
||
|
VMM.DragSlider.dragWidth = VMM.Lib.width(delem);
|
||
|
|
||
|
// CANCEL CURRENT ANIMATION IF ANIMATING
|
||
|
var _newx = Math.round(VMM.DragSlider.startX - e.pageX - VMM.DragSlider.startLeft);
|
||
|
|
||
|
VMM.Lib.stop(elem);
|
||
|
VMM.bindEvent(delem, VMM.DragSlider.onDragMove, "mousemove", {element: elem});
|
||
|
|
||
|
},
|
||
|
dragEnd: function(elem, delem, e) {
|
||
|
VMM.unbindEvent(delem, VMM.DragSlider.onDragMove, "mousemove");
|
||
|
//VMM.DragSlider.dragMomentum(elem, e);
|
||
|
if (VMM.DragSlider.getLeft(elem) > 0) {
|
||
|
//(VMM.DragSlider.dragWidth/2)
|
||
|
//This means they dragged to the right past the first item
|
||
|
//VMM.Lib.animate(elem, 1000, "linear", {"left": 0});
|
||
|
|
||
|
//VMM.fireEvent(elem, "DRAGUPDATE", [0]);
|
||
|
} else {
|
||
|
//This means they were just dragging within the bounds of the grid and we just need to handle the momentum and snap to the grid.
|
||
|
VMM.DragSlider.dragMomentum(elem, e);
|
||
|
}
|
||
|
},
|
||
|
dragMove: function(elem, e) {
|
||
|
if (!VMM.DragSlider.sliding) {
|
||
|
//elem.parent().addClass('sliding');
|
||
|
}
|
||
|
|
||
|
VMM.DragSlider.sliding = true;
|
||
|
if (VMM.DragSlider.startX > e.pageX) {
|
||
|
//Sliding to the left
|
||
|
VMM.Lib.css(elem, 'left', -(VMM.DragSlider.startX - e.pageX - VMM.DragSlider.startLeft));
|
||
|
VMM.DragSlider.slidingLeft = true;
|
||
|
} else {
|
||
|
//Sliding to the right
|
||
|
var left = (e.pageX - VMM.DragSlider.startX + VMM.DragSlider.startLeft);
|
||
|
VMM.Lib.css(elem, 'left', -(VMM.DragSlider.startX - e.pageX - VMM.DragSlider.startLeft));
|
||
|
VMM.DragSlider.slidingLeft = false;
|
||
|
}
|
||
|
},
|
||
|
dragMomentum: function(elem, e) {
|
||
|
var slideAdjust = (new Date().getTime() - VMM.DragSlider.dragStartTime) * 10;
|
||
|
var timeAdjust = slideAdjust;
|
||
|
var left = VMM.DragSlider.getLeft(elem);
|
||
|
|
||
|
var changeX = 6000 * (Math.abs(VMM.DragSlider.startLeft) - Math.abs(left));
|
||
|
//var changeX = 6000 * (VMM.DragSlider.startLeft - left);
|
||
|
slideAdjust = Math.round(changeX / slideAdjust);
|
||
|
|
||
|
var newLeft = left + slideAdjust;
|
||
|
|
||
|
var t = newLeft % VMM.DragSlider.width;
|
||
|
//left: Math.min(0, newLeft),
|
||
|
var _r_object = {
|
||
|
left: Math.min(newLeft),
|
||
|
time: timeAdjust
|
||
|
}
|
||
|
|
||
|
VMM.fireEvent(elem, "DRAGUPDATE", [_r_object]);
|
||
|
var _ease = "easeOutExpo";
|
||
|
if (_r_object.time > 0) {
|
||
|
VMM.Lib.animate(elem, _r_object.time, _ease, {"left": _r_object.left});
|
||
|
};
|
||
|
|
||
|
|
||
|
//VMM.DragSlider.startX = null;
|
||
|
},
|
||
|
getLeft: function(elem) {
|
||
|
return parseInt(VMM.Lib.css(elem, 'left').substring(0, VMM.Lib.css(elem, 'left').length - 2), 10);
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/***********************************************
|
||
13 years ago
|
Begin VMM.Slider.js
|
||
13 years ago
|
***********************************************/
|
||
13 years ago
|
|
||
13 years ago
|
/* Slider
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Slider = function(parent, parent_config) {
|
||
13 years ago
|
|
||
13 years ago
|
var events = {}, config;
|
||
|
var $slider, $slider_mask, $slider_container, $slides_items;
|
||
|
var data = [], slides = [], slide_positions = [];
|
||
13 years ago
|
|
||
13 years ago
|
var slides_content = "";
|
||
|
var current_slide = 0;
|
||
|
var current_width = 960;
|
||
|
var touch = {move: false, x: 10, y:0, off: 0, dampen: 48};
|
||
|
var content = "";
|
||
|
var _active = false;
|
||
|
var layout = parent;
|
||
|
var navigation = {nextBtn:"", prevBtn:"", nextDate:"", prevDate:"", nextTitle:"", prevTitle:""};
|
||
|
var timer;
|
||
13 years ago
|
|
||
13 years ago
|
// CONFIG
|
||
|
if(typeof VMM.Timeline != 'undefined') {
|
||
|
config = VMM.Timeline.Config;
|
||
|
} else {
|
||
|
config = {
|
||
|
preload: 4,
|
||
|
current_slide: 0,
|
||
|
interval: 10,
|
||
|
something: 0,
|
||
|
width: 720,
|
||
|
height: 400,
|
||
|
ease: "easeInOutExpo",
|
||
|
duration: 1000,
|
||
|
timeline: false,
|
||
|
spacing: 15,
|
||
|
slider: {
|
||
|
width: 720,
|
||
|
height: 400,
|
||
|
content: {
|
||
|
width: 720,
|
||
|
height: 400,
|
||
|
padding: 130
|
||
|
},
|
||
|
nav: {
|
||
|
width: 100,
|
||
|
height: 200
|
||
|
}
|
||
|
}
|
||
|
};
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
/* PUBLIC VARS
|
||
|
================================================== */
|
||
|
this.ver = "0.6";
|
||
|
|
||
|
config.slider.width = config.width;
|
||
|
config.slider.height = config.height;
|
||
|
|
||
13 years ago
|
/* PUBLIC FUNCTIONS
|
||
|
================================================== */
|
||
|
this.init = function(d) {
|
||
13 years ago
|
slides = [];
|
||
|
slide_positions = [];
|
||
|
|
||
13 years ago
|
if(typeof d != 'undefined') {
|
||
|
this.setData(d);
|
||
|
} else {
|
||
|
trace("WAITING ON DATA");
|
||
|
}
|
||
|
};
|
||
|
|
||
13 years ago
|
this.width = function(w) {
|
||
|
if (w != null && w != "") {
|
||
|
config.slider.width = w;
|
||
|
reSize();
|
||
|
} else {
|
||
|
return config.slider.width;
|
||
13 years ago
|
}
|
||
13 years ago
|
}
|
||
|
|
||
|
this.height = function(h) {
|
||
|
if (h != null && h != "") {
|
||
|
config.slider.height = h;
|
||
|
reSize();
|
||
|
} else {
|
||
|
return config.slider.height;
|
||
|
}
|
||
|
}
|
||
13 years ago
|
|
||
|
/* GETTERS AND SETTERS
|
||
|
================================================== */
|
||
|
this.setData = function(d) {
|
||
|
if(typeof d != 'undefined') {
|
||
|
data = d;
|
||
|
build();
|
||
|
} else{
|
||
|
trace("NO DATA");
|
||
|
}
|
||
|
};
|
||
|
|
||
13 years ago
|
this.getData = function() {
|
||
|
return data;
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
this.setConfig = function(d) {
|
||
|
if(typeof d != 'undefined') {
|
||
|
config = d;
|
||
|
} else{
|
||
|
trace("NO CONFIG DATA");
|
||
|
}
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
this.getConfig = function() {
|
||
|
return config;
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
this.setSize = function(w, h) {
|
||
|
if (w != null) {config.slider.width = w};
|
||
|
if (h != null) {config.slider.height = h};
|
||
|
if (_active) {
|
||
|
reSize();
|
||
13 years ago
|
}
|
||
|
|
||
|
}
|
||
|
|
||
13 years ago
|
this.active = function() {
|
||
|
return _active;
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
this.getCurrentNumber = function() {
|
||
|
return current_slide;
|
||
|
};
|
||
|
|
||
|
this.setSlide = function(n) {
|
||
|
goToSlide(n);
|
||
|
};
|
||
|
|
||
|
/* ON EVENT
|
||
|
================================================== */
|
||
|
function onConfigSet() {
|
||
|
trace("onConfigSet");
|
||
|
};
|
||
|
|
||
|
function reSize(go_to_slide, from_start) {
|
||
13 years ago
|
|
||
13 years ago
|
var _go_to_slide = true;
|
||
|
var _from_start = false;
|
||
13 years ago
|
|
||
13 years ago
|
if (go_to_slide != null) {_go_to_slide = go_to_slide};
|
||
|
if (from_start != null) {_from_start = from_start};
|
||
13 years ago
|
|
||
13 years ago
|
current_width = config.slider.width;
|
||
13 years ago
|
|
||
13 years ago
|
config.slider.nav.height = VMM.Lib.height(navigation.prevBtnContainer);
|
||
13 years ago
|
|
||
13 years ago
|
config.slider.content.width = current_width - (config.slider.content.padding *2);
|
||
|
|
||
|
VMM.Lib.width($slides_items, (slides.length * config.slider.content.width));
|
||
|
|
||
|
if (_from_start) {
|
||
|
var _pos = slides[current_slide].leftpos();
|
||
|
VMM.Lib.css($slider_container, "left", _pos);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
// RESIZE SLIDES
|
||
|
sizeSlides();
|
||
13 years ago
|
|
||
13 years ago
|
// POSITION SLIDES
|
||
|
positionSlides();
|
||
13 years ago
|
|
||
13 years ago
|
// POSITION NAV
|
||
|
VMM.Lib.css(navigation.nextBtn, "left", (current_width - config.slider.nav.width));
|
||
|
VMM.Lib.height(navigation.prevBtn, config.slider.height);
|
||
|
VMM.Lib.height(navigation.nextBtn, config.slider.height);
|
||
|
VMM.Lib.css(navigation.nextBtnContainer, "top", ( (config.slider.height/2) - (config.slider.nav.height/2) ) );
|
||
|
VMM.Lib.css(navigation.prevBtnContainer, "top", ( (config.slider.height/2) - (config.slider.nav.height/2) ) );
|
||
|
|
||
|
// Animate Changes
|
||
|
VMM.Lib.height($slider_mask, config.slider.height);
|
||
|
VMM.Lib.width($slider_mask, current_width);
|
||
|
|
||
|
if (_go_to_slide) {
|
||
|
goToSlide(current_slide, "linear", 1);
|
||
|
};
|
||
|
|
||
|
if (current_slide == 0) {
|
||
|
VMM.Lib.visible(navigation.prevBtn, false);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/* NAVIGATION
|
||
|
================================================== */
|
||
|
function onNextClick(e) {
|
||
|
if (current_slide == slides.length - 1) {
|
||
|
VMM.Lib.animate($slider_container, config.duration, config.ease, {"left": -(slides[current_slide].leftpos()) } );
|
||
|
} else {
|
||
|
goToSlide(current_slide+1);
|
||
|
upDate();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function onPrevClick(e) {
|
||
|
if (current_slide == 0) {
|
||
|
goToSlide(current_slide);
|
||
|
} else {
|
||
|
goToSlide(current_slide-1);
|
||
|
upDate();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function onKeypressNav(e) {
|
||
|
switch(e.keyCode) {
|
||
|
case 39:
|
||
|
// RIGHT ARROW
|
||
|
onNextClick(e);
|
||
|
break;
|
||
|
case 37:
|
||
|
// LEFT ARROW
|
||
|
onPrevClick(e);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function onTouchUpdate(e, b) {
|
||
|
if (slide_positions.length == 0) {
|
||
|
for(var i = 0; i < slides.length; i++) {
|
||
|
slide_positions.push( slides[i].leftpos() );
|
||
|
}
|
||
|
}
|
||
|
if (typeof b.left == "number") {
|
||
|
var _pos = b.left;
|
||
|
var _slide_pos = -(slides[current_slide].leftpos());
|
||
|
if (_pos < _slide_pos - (config.slider_width/3)) {
|
||
|
onNextClick();
|
||
|
} else if (_pos > _slide_pos + (config.slider_width/3)) {
|
||
|
onPrevClick();
|
||
|
} else {
|
||
|
VMM.Lib.animate($slider_container, config.duration, config.ease, {"left": _slide_pos });
|
||
|
}
|
||
|
} else {
|
||
|
VMM.Lib.animate($slider_container, config.duration, config.ease, {"left": _slide_pos });
|
||
|
}
|
||
|
|
||
|
if (typeof b.top == "number") {
|
||
|
VMM.Lib.animate($slider_container, config.duration, config.ease, {"top": -b.top});
|
||
|
} else {
|
||
|
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/* UPDATE
|
||
|
================================================== */
|
||
|
function upDate() {
|
||
|
config.current_slide = current_slide;
|
||
|
VMM.fireEvent(layout, "UPDATE");
|
||
|
};
|
||
|
|
||
|
/* GET DATA
|
||
|
================================================== */
|
||
|
var getData = function(d) {
|
||
|
data = d;
|
||
|
};
|
||
|
|
||
|
/* BUILD SLIDES
|
||
|
================================================== */
|
||
|
var buildSlides = function(d) {
|
||
|
VMM.attachElement($slides_items, "");
|
||
|
slides = [];
|
||
|
|
||
|
for(var i = 0; i < d.length; i++) {
|
||
|
var _slide = new VMM.Slider.Slide(d[i], $slides_items);
|
||
|
//_slide.show();
|
||
|
slides.push(_slide);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var preloadSlides = function(skip) {
|
||
|
if (skip) {
|
||
|
preloadTimeOutSlides();
|
||
|
} else {
|
||
|
timer = setTimeout(preloadTimeOutSlides, config.duration);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var preloadTimeOutSlides = function() {
|
||
|
for(var j = 0; j < config.preload; j++) {
|
||
|
if ( !((current_slide + j) >= slides.length - 1)) {
|
||
|
slides[current_slide + j].show();
|
||
|
}
|
||
|
if ( !( (current_slide - j) < 0 ) ) {
|
||
|
slides[current_slide - j].show();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sizeSlides();
|
||
|
}
|
||
|
|
||
|
/* SIZE SLIDES
|
||
|
================================================== */
|
||
|
var sizeSlides = function() {
|
||
|
var layout_text_media = ".slider-item .layout-text-media .media .media-container ";
|
||
|
var layout_media = ".slider-item .layout-media .media .media-container ";
|
||
|
var layout_both = ".slider-item .media .media-container";
|
||
|
var mediasize = {
|
||
|
text_media: {
|
||
|
width: (config.slider.content.width/100) * 60,
|
||
|
height: config.slider.height - 60,
|
||
|
video: {
|
||
|
width: 0,
|
||
|
height: 0
|
||
13 years ago
|
}
|
||
13 years ago
|
},
|
||
|
media: {
|
||
|
width: config.slider.content.width,
|
||
|
height: config.slider.height - 110,
|
||
|
video: {
|
||
|
width: 0,
|
||
|
height: 0
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
mediasize.text_media.video = VMM.Util.ratio.fit(mediasize.text_media.width, mediasize.text_media.height, 16, 9);
|
||
|
mediasize.media.video = VMM.Util.ratio.fit(mediasize.media.width, mediasize.media.height, 16, 9);
|
||
|
|
||
|
VMM.Lib.css(".slider-item", "width", config.slider.content.width );
|
||
|
VMM.Lib.height(".slider-item", config.slider.height);
|
||
|
|
||
|
// HANDLE SMALLER SIZES
|
||
|
var is_skinny = false;
|
||
|
|
||
|
if (current_width <= 650) {
|
||
|
is_skinny = true;
|
||
|
} else if (VMM.Browser.device == "mobile" && VMM.Browser.orientation == "portrait") {
|
||
|
is_skinny = true;
|
||
|
} else if (VMM.Browser.device == "tablet" && VMM.Browser.orientation == "portrait") {
|
||
|
//is_skinny = true;
|
||
|
}
|
||
|
|
||
|
if (is_skinny) {
|
||
13 years ago
|
|
||
13 years ago
|
mediasize.text_media.width = config.slider.content.width;
|
||
|
mediasize.text_media.height = ((config.slider.height/100) * 50 ) - 50;
|
||
|
mediasize.media.height = ((config.slider.height/100) * 70 ) - 40;
|
||
13 years ago
|
|
||
13 years ago
|
mediasize.text_media.video = VMM.Util.ratio.fit(mediasize.text_media.width, mediasize.text_media.height, 16, 9);
|
||
|
mediasize.media.video = VMM.Util.ratio.fit(mediasize.media.width, mediasize.media.height, 16, 9);
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(".slider-item .layout-text-media .text", "width", "100%" );
|
||
|
VMM.Lib.css(".slider-item .layout-text-media .text", "display", "block" );
|
||
|
VMM.Lib.css(".slider-item .layout-text-media .text .container", "display", "block" );
|
||
|
VMM.Lib.css(".slider-item .layout-text-media .text .container", "width", config.slider.content.width );
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(".slider-item .layout-text-media .media", "float", "none" );
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(".slider-item .media blockquote p", "line-height", "18px" );
|
||
|
VMM.Lib.css(".slider-item .media blockquote p", "font-size", "16px" );
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(".slider-item", "overflow-y", "auto" );
|
||
13 years ago
|
|
||
13 years ago
|
// MAINTAINS VERTICAL CENTER IF IT CAN
|
||
|
for(var i = 0; i < slides.length; i++) {
|
||
|
if (VMM.Lib.height(VMM.Lib.find( slides[i], ".content")) > config.slider.height) {
|
||
|
slides[i].css("display", "block");
|
||
|
} else {
|
||
|
slides[i].css("display", "table");
|
||
|
}
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
} else {
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(".slider-item .layout-text-media .text", "width", "40%" );
|
||
|
VMM.Lib.css(".slider-item .layout-text-media .text", "display", "table-cell" );
|
||
|
VMM.Lib.css(".slider-item .layout-text-media .text .container", "display", "table-cell" );
|
||
|
VMM.Lib.css(".slider-item .layout-text-media .text .container", "width", "auto" );
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(".slider-item .layout-text-media .media", "float", "left" );
|
||
|
VMM.Lib.css(".slider-item .layout-text-media", "display", "table" );
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(".slider-item .media blockquote p", "line-height", "36px" );
|
||
|
VMM.Lib.css(".slider-item .media blockquote p", "font-size", "28px" );
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(".slider-item", "display", "table" );
|
||
|
VMM.Lib.css(".slider-item", "overflow-y", "auto" );
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
// MEDIA FRAME
|
||
|
VMM.Lib.css( layout_text_media + ".media-frame", "max-width", mediasize.text_media.width);
|
||
|
VMM.Lib.height( layout_text_media + ".media-frame", mediasize.text_media.height);
|
||
|
VMM.Lib.width( layout_text_media + ".media-frame", mediasize.text_media.width);
|
||
13 years ago
|
|
||
13 years ago
|
// IMAGES
|
||
|
VMM.Lib.css( layout_text_media + "img", "max-height", mediasize.text_media.height );
|
||
|
VMM.Lib.css( layout_media + "img", "max-height", mediasize.media.height );
|
||
13 years ago
|
|
||
13 years ago
|
// FIX FOR NON-WEBKIT BROWSERS
|
||
|
VMM.Lib.css( layout_text_media + "img", "max-width", mediasize.text_media.width );
|
||
|
VMM.Lib.css( layout_text_media + ".twitter .avatar img", "max-width", 32 );
|
||
|
VMM.Lib.css( layout_text_media + ".twitter .avatar img", "max-height", 32 );
|
||
|
VMM.Lib.css( layout_media + ".twitter .avatar img", "max-width", 32 );
|
||
|
VMM.Lib.css( layout_media + ".twitter .avatar img", "max-height", 32 );
|
||
13 years ago
|
|
||
13 years ago
|
// IFRAME FULL SIZE VIDEO
|
||
|
VMM.Lib.width( layout_text_media + ".media-frame", mediasize.text_media.video.width);
|
||
|
VMM.Lib.height( layout_text_media + ".media-frame", mediasize.text_media.video.height);
|
||
|
VMM.Lib.width( layout_media + ".media-frame", mediasize.media.video.width);
|
||
|
VMM.Lib.height( layout_media + ".media-frame", mediasize.media.video.height);
|
||
|
VMM.Lib.css( layout_media + ".media-frame", "max-height", mediasize.media.video.height);
|
||
|
VMM.Lib.css( layout_media + ".media-frame", "max-width", mediasize.media.video.width);
|
||
13 years ago
|
|
||
13 years ago
|
// SOUNDCLOUD
|
||
|
VMM.Lib.height( layout_media + ".soundcloud", 168);
|
||
|
VMM.Lib.height( layout_text_media + ".soundcloud", 168);
|
||
|
VMM.Lib.width( layout_media + ".soundcloud", mediasize.media.width);
|
||
|
VMM.Lib.width( layout_text_media + ".soundcloud", mediasize.text_media.width);
|
||
|
VMM.Lib.css( layout_both + ".soundcloud", "max-height", 168 );
|
||
13 years ago
|
|
||
13 years ago
|
// MAPS
|
||
|
VMM.Lib.height( layout_text_media + ".map", mediasize.text_media.height);
|
||
|
VMM.Lib.css( layout_media + ".map", "max-height", mediasize.media.height);
|
||
|
VMM.Lib.width( layout_media + ".map", mediasize.media.width);
|
||
|
|
||
|
// DOCS
|
||
|
VMM.Lib.height( layout_text_media + ".doc", mediasize.text_media.height);
|
||
|
VMM.Lib.height( layout_media + ".doc", mediasize.media.height);
|
||
13 years ago
|
|
||
13 years ago
|
trace(mediasize);
|
||
|
}
|
||
|
|
||
|
/* POSITION SLIDES
|
||
|
================================================== */
|
||
|
var positionSlides = function() {
|
||
|
var pos = 0;
|
||
|
for(var i = 0; i < slides.length; i++) {
|
||
|
pos = i * (config.slider.width+config.spacing);
|
||
|
//VMM.Lib.css(slides[i], "left", pos);
|
||
|
slides[i].leftpos(pos);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* OPACITY SLIDES
|
||
|
================================================== */
|
||
|
var opacitySlides = function(n) {
|
||
|
var _ease = "linear";
|
||
|
for(var i = 0; i < slides.length; i++) {
|
||
|
if (i == current_slide) {
|
||
|
//VMM.Lib.animate(slides[i], config.duration, _ease, {"opacity": 1});
|
||
|
slides[i].animate(config.duration, _ease, {"opacity": 1});
|
||
|
} else if (i == current_slide - 1 || i == current_slide + 1) {
|
||
|
//VMM.Lib.animate(slides[i], config.duration, _ease, {"opacity": 0.1});
|
||
|
slides[i].animate(config.duration, _ease, {"opacity": 0.1});
|
||
|
} else {
|
||
|
//VMM.Lib.css(slides[i], "opacity", n);
|
||
|
slides[i].opacity(n);
|
||
13 years ago
|
}
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
|
/* GO TO SLIDE
|
||
|
goToSlide(n, ease, duration);
|
||
|
================================================== */
|
||
|
var goToSlide = function(n, ease, duration, fast, firstrun) {
|
||
13 years ago
|
|
||
13 years ago
|
/* STOP ANY VIDEO PLAYERS ACTIVE
|
||
|
================================================== */
|
||
|
VMM.ExternalAPI.youtube.stopPlayers();
|
||
13 years ago
|
|
||
13 years ago
|
// Set current slide
|
||
|
current_slide = n;
|
||
13 years ago
|
|
||
13 years ago
|
var _ease = config.ease;
|
||
|
var _duration = config.duration;
|
||
|
var is_last = false;
|
||
|
var is_first = false;
|
||
|
var _pos = slides[current_slide].leftpos();
|
||
|
var _title = "";
|
||
|
//var _pos = VMM.Lib.position(slides[current_slide]);
|
||
13 years ago
|
|
||
13 years ago
|
if (current_slide == 0) {is_first = true};
|
||
|
if (current_slide +1 >= slides.length) {is_last = true};
|
||
|
if (ease != null && ease != "") {_ease = ease};
|
||
|
if (duration != null && duration != "") {_duration = duration};
|
||
13 years ago
|
|
||
13 years ago
|
/* set proper nav titles and dates etc.
|
||
|
================================================== */
|
||
|
trace(data[current_slide]);
|
||
|
if (is_first) {
|
||
|
VMM.Lib.visible(navigation.prevBtn, false);
|
||
|
} else {
|
||
|
VMM.Lib.visible(navigation.prevBtn, true);
|
||
|
_title = VMM.Util.unlinkify(data[current_slide - 1].title)
|
||
|
if (config.type == "timeline") {
|
||
|
if(typeof data[current_slide - 1].date === "undefined") {
|
||
|
VMM.attachElement(navigation.prevDate, _title);
|
||
|
VMM.attachElement(navigation.prevTitle, "");
|
||
|
} else {
|
||
|
VMM.attachElement(navigation.prevDate, data[current_slide - 1].date);
|
||
|
VMM.attachElement(navigation.prevTitle, _title);
|
||
|
}
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.attachElement(navigation.prevTitle, _title);
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
}
|
||
13 years ago
|
if (is_last) {
|
||
|
VMM.Lib.visible(navigation.nextBtn, false);
|
||
|
} else {
|
||
|
VMM.Lib.visible(navigation.nextBtn, true);
|
||
|
_title = VMM.Util.unlinkify(data[current_slide + 1].title);
|
||
|
if (config.type == "timeline") {
|
||
|
if(typeof data[current_slide + 1].date === "undefined") {
|
||
|
VMM.attachElement(navigation.nextDate, _title);
|
||
|
VMM.attachElement(navigation.nextTitle, "");
|
||
|
} else {
|
||
|
VMM.attachElement(navigation.nextDate, data[current_slide + 1].date);
|
||
|
VMM.attachElement(navigation.nextTitle, _title);
|
||
|
}
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.attachElement(navigation.nextTitle, _title);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/* ANIMATE SLIDE
|
||
|
================================================== */
|
||
|
if (fast) {
|
||
|
VMM.Lib.css($slider_container, "left", -(_pos - config.slider.content.padding));
|
||
|
} else{
|
||
|
VMM.Lib.stop($slider_container);
|
||
|
VMM.Lib.animate($slider_container, _duration, _ease, {"left": -(_pos - config.slider.content.padding)});
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
if (firstrun) {
|
||
|
VMM.fireEvent(layout, "LOADED");
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/* SET Vertical Scoll
|
||
|
================================================== */
|
||
|
//opacitySlides(0.85);
|
||
|
//if (VMM.Lib.height(slides[current_slide]) > config.slider_height) {
|
||
|
if (slides[current_slide].height() > config.slider_height) {
|
||
|
VMM.Lib.css(".slider", "overflow-y", "scroll" );
|
||
|
} else {
|
||
|
VMM.Lib.css(layout, "overflow-y", "hidden" );
|
||
|
VMM.Lib.animate(layout, _duration, _ease, {scrollTop: VMM.Lib.prop(layout, "scrollHeight") - VMM.Lib.height(layout) });
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
preloadSlides();
|
||
|
//VMM.Lib.css(navigation.nextBtnContainer, "left", ( VMM.Lib.width(navigation.nextBtnContainer) - config.slider.nav.width) );
|
||
|
}
|
||
|
|
||
|
/* BUILD NAVIGATION
|
||
|
================================================== */
|
||
|
var buildNavigation = function() {
|
||
13 years ago
|
|
||
13 years ago
|
var temp_icon = "<div class='icon'> </div>";
|
||
13 years ago
|
|
||
13 years ago
|
navigation.nextBtn = VMM.appendAndGetElement($slider, "<div>", "nav-next");
|
||
|
navigation.prevBtn = VMM.appendAndGetElement($slider, "<div>", "nav-previous");
|
||
|
navigation.nextBtnContainer = VMM.appendAndGetElement(navigation.nextBtn, "<div>", "nav-container", temp_icon);
|
||
|
navigation.prevBtnContainer = VMM.appendAndGetElement(navigation.prevBtn, "<div>", "nav-container", temp_icon);
|
||
|
if (config.type == "timeline") {
|
||
|
navigation.nextDate = VMM.appendAndGetElement(navigation.nextBtnContainer, "<div>", "date", "");
|
||
|
navigation.prevDate = VMM.appendAndGetElement(navigation.prevBtnContainer, "<div>", "date", "");
|
||
|
}
|
||
|
navigation.nextTitle = VMM.appendAndGetElement(navigation.nextBtnContainer, "<div>", "title", "Title Goes Here");
|
||
|
navigation.prevTitle = VMM.appendAndGetElement(navigation.prevBtnContainer, "<div>", "title", "Title Goes Here");
|
||
13 years ago
|
|
||
13 years ago
|
VMM.bindEvent(".nav-next", onNextClick);
|
||
|
VMM.bindEvent(".nav-previous", onPrevClick);
|
||
|
VMM.bindEvent(window, onKeypressNav, 'keydown');
|
||
|
}
|
||
|
|
||
|
/* BUILD
|
||
|
================================================== */
|
||
|
var build = function() {
|
||
13 years ago
|
|
||
13 years ago
|
// Clear out existing content
|
||
|
VMM.attachElement(layout, "");
|
||
13 years ago
|
|
||
13 years ago
|
// Get DOM Objects to local objects
|
||
|
$slider = VMM.getElement("div.slider");
|
||
|
$slider_mask = VMM.appendAndGetElement($slider, "<div>", "slider-container-mask");
|
||
|
$slider_container = VMM.appendAndGetElement($slider_mask, "<div>", "slider-container");
|
||
|
$slides_items = VMM.appendAndGetElement($slider_container, "<div>", "slider-item-container");
|
||
13 years ago
|
|
||
13 years ago
|
// BUILD NAVIGATION
|
||
|
buildNavigation();
|
||
|
|
||
|
// ATTACH SLIDES
|
||
|
buildSlides(data);
|
||
13 years ago
|
|
||
13 years ago
|
/* MAKE SLIDER TOUCHABLE
|
||
|
================================================== */
|
||
13 years ago
|
|
||
13 years ago
|
var __duration = 3000;
|
||
13 years ago
|
|
||
13 years ago
|
if (VMM.Browser.device == "tablet" || VMM.Browser.device == "mobile") {
|
||
|
config.duration = 500;
|
||
|
__duration = 1000;
|
||
|
//VMM.TouchSlider.createPanel($slider_container, $slider_container, VMM.Lib.width(slides[0]), config.spacing, true);
|
||
|
VMM.TouchSlider.createPanel($slider_container, $slider_container, slides[0].width(), config.spacing, true);
|
||
|
VMM.bindEvent($slider_container, onTouchUpdate, "TOUCHUPDATE");
|
||
|
} else if (VMM.Browser.device == "mobile") {
|
||
13 years ago
|
|
||
13 years ago
|
} else {
|
||
|
//VMM.DragSlider.createPanel($slider_container, $slider_container, VMM.Lib.width(slides[0]), config.spacing, true);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
reSize(false, true);
|
||
|
VMM.Lib.visible(navigation.prevBtn, false);
|
||
|
// GO TO FIRST SLIDE
|
||
|
trace("config.current_slide " + config.current_slide);
|
||
|
goToSlide(config.current_slide, "easeOutExpo", __duration, true, true);
|
||
13 years ago
|
|
||
13 years ago
|
_active = true;
|
||
|
};
|
||
|
|
||
|
};
|
||
13 years ago
|
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
|
||
|
|
||
|
|
||
13 years ago
|
|
||
13 years ago
|
/***********************************************
|
||
13 years ago
|
Begin VMM.Slider.Slide.js
|
||
13 years ago
|
***********************************************/
|
||
13 years ago
|
|
||
13 years ago
|
/* Slider Slide
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
if (typeof VMM.Slider != 'undefined') {
|
||
|
// VMM.Slider.Slide(element, data)
|
||
|
VMM.Slider.Slide = function(d, _parent) {
|
||
|
|
||
|
var data = d;
|
||
|
var slide = {};
|
||
|
var media = "";
|
||
|
var loaded = false;
|
||
|
var element = VMM.appendAndGetElement(_parent, "<div>", "slider-item");
|
||
|
|
||
|
/* PUBLIC
|
||
|
================================================== */
|
||
|
this.show = function() {
|
||
|
if (!loaded) {
|
||
|
render();
|
||
13 years ago
|
}
|
||
13 years ago
|
};
|
||
13 years ago
|
|
||
13 years ago
|
this.hide = function() {
|
||
|
if (loaded) {
|
||
|
removeSlide();
|
||
|
}
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
this.elem = function() {
|
||
|
return element;
|
||
|
};
|
||
|
|
||
|
this.position = function() {
|
||
|
return VMM.Lib.position(element);
|
||
|
};
|
||
|
|
||
|
this.leftpos = function(p) {
|
||
|
if(typeof p != 'undefined') {
|
||
|
VMM.Lib.css(element, "left", p);
|
||
13 years ago
|
} else {
|
||
13 years ago
|
trace("LEFT: " + VMM.Lib.position(element).left);
|
||
|
return VMM.Lib.position(element).left
|
||
13 years ago
|
}
|
||
13 years ago
|
};
|
||
|
|
||
|
this.animate = function(d, e, p) {
|
||
|
VMM.Lib.animate(element, d, e, p);
|
||
|
};
|
||
|
|
||
|
this.css = function(p, v) {
|
||
|
VMM.Lib.css(element, p, v );
|
||
|
}
|
||
|
|
||
|
this.opacity = function(p) {
|
||
|
VMM.Lib.css(element, "opacity", p);
|
||
|
}
|
||
|
|
||
|
this.width = function() {
|
||
|
return VMM.Lib.width(element);
|
||
|
};
|
||
|
|
||
|
this.height = function() {
|
||
|
return VMM.Lib.height(element);
|
||
|
};
|
||
|
|
||
|
/* PRIVATE
|
||
|
================================================== */
|
||
|
var render = function() {
|
||
|
VMM.attachElement(element, "");
|
||
|
VMM.appendElement(element, buildSlide() );
|
||
|
loaded = true;
|
||
|
var timer = setTimeout(VMM.ExternalAPI.pushQues, 500);
|
||
|
};
|
||
|
|
||
|
var removeSlide = function() {
|
||
|
VMM.attachElement(element, "");
|
||
|
loaded = false;
|
||
|
}
|
||
|
|
||
|
var buildSlide = function() {
|
||
|
var c = {slide:"", text: "", media: "", layout: "content-container layout", has: { headline: false, text: false, media: false }};
|
||
|
var b_slide, c_wrap;
|
||
13 years ago
|
|
||
13 years ago
|
/* DATE
|
||
|
================================================== */
|
||
|
if (data.startdate != null && data.startdate != "") {
|
||
|
if (type.of(data.startdate) == "date") {
|
||
|
if (data.type != "start") {
|
||
|
var st = VMM.Util.date.prettyDate(data.startdate);
|
||
|
var en = VMM.Util.date.prettyDate(data.enddate);
|
||
|
if (st != en) {
|
||
|
c.text += VMM.createElement("h2", st + " — " + en + "", "date");
|
||
|
} else {
|
||
|
c.text += VMM.createElement("h2", st, "date");
|
||
|
}
|
||
|
}
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
|
||
|
/* HEADLINE
|
||
|
================================================== */
|
||
|
if (data.headline != null && data.headline != "") {
|
||
|
c.has.headline = true;
|
||
|
if (data.type == "start") {
|
||
|
c.text += VMM.createElement("h2", VMM.Util.linkify_with_twitter(data.headline, "_blank"), "start");
|
||
13 years ago
|
} else {
|
||
13 years ago
|
c.text += VMM.createElement("h3", VMM.Util.linkify_with_twitter(data.headline, "_blank"));
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
/* TEXT
|
||
|
================================================== */
|
||
|
if (data.text != null && data.text != "") {
|
||
|
c.has.text = true;
|
||
|
c.text += VMM.createElement("p", VMM.Util.linkify_with_twitter(data.text, "_blank"));
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
if (c.has.text || c.has.headline) {
|
||
|
c.text = VMM.createElement("div", c.text, "container");
|
||
|
c.text = VMM.createElement("div", c.text, "text");
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
/* MEDIA
|
||
|
================================================== */
|
||
|
if (data.asset != null && data.asset != "") {
|
||
|
if (data.asset.media != null && data.asset.media != "") {
|
||
|
c.has.media = true;
|
||
|
c.media = VMM.MediaElement.create(data.asset);
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
/* COMBINE
|
||
|
================================================== */
|
||
|
if (c.has.text) { c.layout += "-text" };
|
||
|
if (c.has.media){ c.layout += "-media" };
|
||
13 years ago
|
|
||
13 years ago
|
c.slide = VMM.createElement("div", c.text + c.media, c.layout);
|
||
|
c_wrap = VMM.createElement("div", c.slide, "content");
|
||
|
|
||
|
/* RETURN
|
||
|
================================================== */
|
||
|
// return c.slide;
|
||
|
return c_wrap;
|
||
|
|
||
|
};
|
||
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
};
|
||
|
|
||
13 years ago
|
|
||
13 years ago
|
/***********************************************
|
||
13 years ago
|
Begin VMM.Util.js
|
||
13 years ago
|
***********************************************/
|
||
13 years ago
|
|
||
13 years ago
|
/* Utilities and Useful Functions
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
if(typeof VMM != 'undefined' && typeof VMM.Util == 'undefined') {
|
||
|
|
||
|
VMM.Util = ({
|
||
|
|
||
|
init: function() {
|
||
|
return this;
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
13 years ago
|
/* CORRECT PROTOCOL (DOES NOT WORK)
|
||
13 years ago
|
================================================== */
|
||
|
correctProtocol: function(url) {
|
||
|
var loc = (window.parent.location.protocol).toString();
|
||
|
var prefix = "";
|
||
|
var _url = url.split("://", 2);
|
||
13 years ago
|
|
||
13 years ago
|
if (loc.match("http")) {
|
||
|
prefix = loc;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
prefix = "https";
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
return prefix + "://" + _url[1];
|
||
13 years ago
|
|
||
|
},
|
||
13 years ago
|
|
||
|
/* GET OBJECT ATTRIBUTE BY INDEX
|
||
|
================================================== */
|
||
|
getObjectAttributeByIndex: function(obj, index) {
|
||
|
var i = 0;
|
||
|
for (var attr in obj){
|
||
|
if (index === i){
|
||
|
return obj[attr];
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
return null;
|
||
|
},
|
||
13 years ago
|
/* RANDOM BETWEEN
|
||
|
================================================== */
|
||
|
//VMM.Util.randomBetween(1, 3)
|
||
|
randomBetween: function(min, max) {
|
||
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
||
13 years ago
|
},
|
||
|
|
||
13 years ago
|
/* 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;
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
/* CUSTOM SORT
|
||
|
================================================== */
|
||
13 years ago
|
|
||
13 years ago
|
customSort: function(a, b) {
|
||
|
var a1= a, b1= b;
|
||
|
if(a1== b1) return 0;
|
||
|
return a1> b1? 1: -1;
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
/* Given an int or decimal, turn that into string in $xxx,xxx.xx format.
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
number2money: function(n, symbol, padding) {
|
||
|
var symbol = (symbol !== null) ? symbol : true; // add $
|
||
|
var padding = (padding !== null) ? padding : false; //pad with .00
|
||
|
var number = VMM.Math2.floatPrecision(n,2); // rounded correctly to two digits, if decimals passed
|
||
|
var formatted = this.niceNumber(number);
|
||
|
// no decimal and padding is enabled
|
||
|
if (!formatted.split(/\./g)[1] && padding) formatted = formatted + ".00";
|
||
|
// add money sign
|
||
|
if (symbol) formatted = "$"+formatted;
|
||
|
return formatted;
|
||
|
},
|
||
13 years ago
|
|
||
|
|
||
13 years ago
|
/* Returns a word count number
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
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;
|
||
13 years ago
|
}
|
||
13 years ago
|
return word_count;
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
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);
|
||
|
}
|
||
13 years ago
|
}
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
13 years ago
|
date: {
|
||
13 years ago
|
|
||
13 years ago
|
dateformats: {
|
||
|
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: "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>'",
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
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"],
|
||
13 years ago
|
|
||
13 years ago
|
//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>'",
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
setLanguage: function(lang) {
|
||
|
trace("SET DATE LANGUAGE");
|
||
|
VMM.Util.date.dateformats = lang.dateformats;
|
||
|
VMM.Util.date.month = lang.date.month;
|
||
|
VMM.Util.date.month_abbr = lang.date.month_abbr;
|
||
|
VMM.Util.date.day = lang.date.day;
|
||
|
VMM.Util.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);
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
parse: function(d) {
|
||
|
if (type.of(d) == "date") {
|
||
|
return d;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
var _date = new Date(0, 0, 1, 0, 0, 0, 0);
|
||
|
var _d_array; // DATE ARRAY
|
||
|
var _t_array; // TIME ARRAY
|
||
|
if ( d.match(/,/gi) ) {
|
||
|
_d_array = d.split(",");
|
||
|
for(var i = 0; i < _d_array.length; i++) {
|
||
|
_d_array[i] = parseInt(_d_array[i]);
|
||
|
}
|
||
|
if ( _d_array[0] ) { _date.setFullYear( _d_array[0]); }
|
||
|
if ( _d_array[1] > 1 ) { _date.setMonth( _d_array[1] - 1); }
|
||
|
if ( _d_array[2] > 1 ) { _date.setDate( _d_array[2]); }
|
||
|
if ( _d_array[3] > 1 ) { _date.setHours( _d_array[3]); }
|
||
|
if ( _d_array[4] > 1 ) { _date.setMinutes( _d_array[4]); }
|
||
|
if ( _d_array[5] > 1 ) { _date.setSeconds( _d_array[5]); }
|
||
|
if ( _d_array[6] > 1 ) { _date.setMilliseconds( _d_array[6]); }
|
||
|
} else if (d.match("/")) {
|
||
|
var _time_parse;
|
||
|
var _times;
|
||
|
if (d.match(" ")) {
|
||
|
_time_parse = d.split(" ");
|
||
|
if (d.match(":")) {
|
||
|
_t_array = _time_parse[1].split(":");
|
||
|
if ( _t_array[0] >= 1 ) { _date.setHours( _t_array[0]); }
|
||
|
if ( _t_array[1] >= 1 ) { _date.setMinutes( _t_array[1]); }
|
||
|
if ( _t_array[2] >= 1 ) { _date.setSeconds( _t_array[2]); }
|
||
|
if ( _t_array[3] >= 1 ) { _date.setMilliseconds( _t_array[3]); }
|
||
|
}
|
||
|
_d_array = _time_parse[0].split("/");
|
||
|
} else {
|
||
|
_d_array = d.split("/");
|
||
|
}
|
||
|
if ( _d_array[2] ) { _date.setFullYear( _d_array[2]); }
|
||
|
if ( _d_array[0] > 1 ) { _date.setMonth( _d_array[0] - 1); }
|
||
|
if ( _d_array[1] > 1 ) { _date.setDate( _d_array[1]); }
|
||
|
} else if (d.length < 5) {
|
||
|
_date.setFullYear(parseInt(d));
|
||
|
_date.setMonth(0);
|
||
|
_date.setDate(1);
|
||
|
_date.setHours(0);
|
||
|
_date.setMinutes(0);
|
||
|
_date.setSeconds(0);
|
||
|
_date.setMilliseconds(0);
|
||
|
}else {
|
||
|
_date = new Date(
|
||
|
parseInt(d.slice(0,4)),
|
||
|
parseInt(d.slice(4,6)) - 1,
|
||
|
parseInt(d.slice(6,8)),
|
||
|
parseInt(d.slice(8,10)),
|
||
|
parseInt(d.slice(10,12))
|
||
|
);
|
||
|
}
|
||
|
return _date;
|
||
|
}
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
prettyDate: function(d, is_abbr, d2) {
|
||
|
var _date;
|
||
|
var _date2;
|
||
|
var format;
|
||
|
var bc_check;
|
||
|
var is_pair = false;
|
||
|
|
||
|
if (d2 != null) {
|
||
|
is_pair = true;
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
if (type.of(d) == "date") {
|
||
|
if (d.getMonth() === 0 && d.getDate() == 1 && d.getHours() === 0 && d.getMinutes() === 0 ) {
|
||
|
// YEAR ONLY
|
||
|
format = VMM.Util.date.dateformats.year;
|
||
|
} else if (d.getDate() <= 1 && d.getHours() === 0 && d.getMinutes() === 0) {
|
||
|
// YEAR MONTH
|
||
|
if (is_abbr) {
|
||
|
format = VMM.Util.date.dateformats.month_short;
|
||
|
} else {
|
||
|
format = VMM.Util.date.dateformats.month;
|
||
|
}
|
||
|
} else if (d.getHours() === 0 && d.getMinutes() === 0) {
|
||
|
// YEAR MONTH DAY
|
||
|
if (is_abbr) {
|
||
|
format = VMM.Util.date.dateformats.full_short;
|
||
|
} else {
|
||
|
format = VMM.Util.date.dateformats.full;
|
||
|
}
|
||
|
} else if (d.getMinutes() === 0) {
|
||
|
// YEAR MONTH DAY HOUR
|
||
|
if (is_abbr) {
|
||
|
format = VMM.Util.date.dateformats.time_no_seconds_short;
|
||
|
} else {
|
||
|
format = VMM.Util.date.dateformats.time_no_seconds_small_date;
|
||
|
}
|
||
|
} else {
|
||
|
// YEAR MONTH DAY HOUR MINUTE
|
||
|
if (is_abbr){
|
||
|
format = VMM.Util.date.dateformats.time_no_seconds_short;
|
||
|
} else {
|
||
|
format = VMM.Util.date.dateformats.full_long;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
_date = dateFormat(d, format);
|
||
|
bc_check = _date.split(" ");
|
||
|
|
||
|
// BC TIME SUPPORT
|
||
|
for(var i = 0; i < bc_check.length; i++) {
|
||
|
if ( parseInt(bc_check[i]) < 0 ) {
|
||
|
trace("YEAR IS BC");
|
||
|
var bc_original = bc_check[i];
|
||
|
var bc_number = Math.abs( parseInt(bc_check[i]) );
|
||
|
var bc_string = bc_number.toString() + " B.C.";
|
||
|
_date = _date.replace(bc_original, bc_string);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
if (is_pair) {
|
||
|
_date2 = dateFormat(d2, format);
|
||
|
bc_check = _date2.split(" ");
|
||
|
// BC TIME SUPPORT
|
||
|
for(var i = 0; i < bc_check.length; i++) {
|
||
|
if ( parseInt(bc_check[i]) < 0 ) {
|
||
|
trace("YEAR IS BC");
|
||
|
var bc_original = bc_check[i];
|
||
|
var bc_number = Math.abs( parseInt(bc_check[i]) );
|
||
|
var 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;
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
13 years ago
|
// VMM.Util.doubledigit(number).
|
||
|
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).
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
truncateWords: function(s, min, max) {
|
||
13 years ago
|
|
||
13 years ago
|
if (!min) min = 30;
|
||
|
if (!max) max = min;
|
||
13 years ago
|
|
||
13 years ago
|
var initial_whitespace_rExp = /^[^A-Za-z0-9\'\-]+/gi;
|
||
|
var left_trimmedStr = s.replace(initial_whitespace_rExp, "");
|
||
|
var words = left_trimmedStr.split(" ");
|
||
13 years ago
|
|
||
13 years ago
|
var result = [];
|
||
13 years ago
|
|
||
13 years ago
|
min = Math.min(words.length, min);
|
||
|
max = Math.min(words.length, max);
|
||
13 years ago
|
|
||
13 years ago
|
for (var i = 0; i<min; i++) {
|
||
|
result.push(words[i]);
|
||
|
}
|
||
|
|
||
|
for (var j = min; i<max; i++) {
|
||
|
var word = words[i];
|
||
13 years ago
|
|
||
13 years ago
|
result.push(word);
|
||
13 years ago
|
|
||
13 years ago
|
if (word.charAt(word.length-1) == '.') {
|
||
|
break;
|
||
13 years ago
|
}
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
return (result.join(' '));
|
||
|
},
|
||
|
|
||
|
/* Turns plain text links into real links
|
||
|
================================================== */
|
||
|
// VMM.Util.linkify();
|
||
|
linkify: function(text,targets,is_touch) {
|
||
13 years ago
|
|
||
13 years ago
|
// 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;
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
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) {
|
||
13 years ago
|
|
||
13 years ago
|
// 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" class="hyphenate">$2$5$8$11$14</a>$3$6$9$12';
|
||
13 years ago
|
|
||
13 years ago
|
// 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-zA-Z0-9_\-\.]+)@[a-zA-Z_]+?(?:\.[a-zA-Z]{2,6}))+/gim;
|
||
13 years ago
|
|
||
13 years ago
|
var twitterHandlePattern = /(@([\w]+))/g;
|
||
13 years ago
|
|
||
13 years ago
|
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/$2' target='_blank' onclick='void(0)'>$1</a>")
|
||
|
.replace(twitterSearchPattern, "<a href='http://twitter.com/#search?q=%23$2' target='_blank' 'void(0)'>$1</a>");
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
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, "");
|
||
|
},
|
||
13 years ago
|
/* Turns plain text links into real links
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
// VMM.Util.unlinkify();
|
||
|
unlinkify: function(text) {
|
||
|
if(!text) return text;
|
||
|
text = text.replace(/<a\b[^>]*>/i,"");
|
||
|
text = text.replace(/<\/a>/i, "");
|
||
|
return text;
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
/* TK
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
nl2br: function(text) {
|
||
|
return text.replace(/(\r\n|[\r\n]|\\n|\\r)/g,"<br/>");
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
/* Generate a Unique ID
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
// VMM.Util.unique_ID(size);
|
||
|
unique_ID: function(size) {
|
||
13 years ago
|
|
||
13 years ago
|
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;
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
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) {
|
||
13 years ago
|
|
||
13 years ago
|
var str = string.toString();
|
||
13 years ago
|
|
||
13 years ago
|
if (str.match('&')) {
|
||
|
str = str.replace("&", "&");
|
||
|
} else if (str.match('&')) {
|
||
|
str = str.replace("&", "&");
|
||
|
} else if (str.match('&')) {
|
||
|
str = str.replace("&", "&");
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
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];
|
||
13 years ago
|
}
|
||
|
|
||
|
|
||
13 years ago
|
return vars;
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
/* Cleans up strings to become real HTML
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
toHTML: function(text) {
|
||
13 years ago
|
|
||
13 years ago
|
text = this.nl2br(text);
|
||
|
text = this.linkify(text);
|
||
13 years ago
|
|
||
13 years ago
|
return text.replace(/\s\s/g," ");
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
/* Returns text strings as CamelCase
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
toCamelCase: function(s,forceLowerCase) {
|
||
13 years ago
|
|
||
13 years ago
|
if(forceLowerCase !== false) forceLowerCase = true;
|
||
13 years ago
|
|
||
13 years ago
|
var sps = ((forceLowerCase) ? s.toLowerCase() : s).split(" ");
|
||
13 years ago
|
|
||
13 years ago
|
for(var i=0; i<sps.length; i++) {
|
||
13 years ago
|
|
||
13 years ago
|
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”");
|
||
|
},
|
||
|
/* Given an int or decimal, return a string with pretty commas in the correct spot.
|
||
|
================================================== */
|
||
|
niceNumber: function(n){
|
||
|
|
||
|
var amount = String( Math.abs(Number(n) ) );
|
||
|
|
||
|
var leftOfDecimal = amount.split(/\./g)[0];
|
||
|
var rightOfDecimal = amount.split(/\./g)[1];
|
||
|
|
||
|
var formatted_text = '';
|
||
|
|
||
|
var num_a = leftOfDecimal.toArray();
|
||
|
num_a.reverse();
|
||
|
|
||
|
for (var i=1; i <= num_a.length; i++) {
|
||
|
if ( (i%3 == 0) && (i < num_a.length ) ) {
|
||
|
formatted_text = "," + num_a[i-1] + formatted_text;
|
||
|
} else {
|
||
|
formatted_text = num_a[i-1] + formatted_text;
|
||
|
}
|
||
|
}
|
||
|
if (rightOfDecimal != null && rightOfDecimal != '' && rightOfDecimal != undefined) {
|
||
|
return formatted_text + "." + rightOfDecimal;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
return formatted_text;
|
||
13 years ago
|
}
|
||
13 years ago
|
},
|
||
|
|
||
|
/* Transform text to Title Case
|
||
|
================================================== */
|
||
|
toTitleCase: function(t){
|
||
13 years ago
|
|
||
13 years ago
|
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])(.*)$/);
|
||
|
split[1] = split[1].toUpperCase();
|
||
|
return split.join('');
|
||
|
},
|
||
|
};
|
||
|
|
||
|
__TitleCase.init();
|
||
13 years ago
|
|
||
13 years ago
|
t = t.replace(/_/g," ");
|
||
|
t = __TitleCase.toTitleCase(t);
|
||
|
|
||
|
return t;
|
||
|
},
|
||
13 years ago
|
|
||
13 years ago
|
}).init();
|
||
13 years ago
|
|
||
13 years ago
|
//'string'.linkify();
|
||
|
if(!String.linkify) {
|
||
|
String.prototype.linkify = function() {
|
||
13 years ago
|
|
||
13 years ago
|
// http://, https://, ftp://
|
||
|
var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim;
|
||
13 years ago
|
|
||
13 years ago
|
// www. sans http:// or https://
|
||
|
var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
|
||
13 years ago
|
|
||
13 years ago
|
// Email addresses
|
||
|
var emailAddressPattern = /(([a-zA-Z0-9_\-\.]+)@[a-zA-Z_]+?(?:\.[a-zA-Z]{2,6}))+/gim;
|
||
|
|
||
|
var twitterHandlePattern = /(@([\w]+))/g;
|
||
|
|
||
|
var twitterSearchPattern = /(#([\w]+))/g;
|
||
13 years ago
|
|
||
13 years ago
|
return this
|
||
|
.replace(urlPattern, '<a target="_blank" href="$&">$&</a>')
|
||
|
.replace(pseudoUrlPattern, '$1<a target="_blank" href="http://$2">$2</a>')
|
||
|
.replace(emailAddressPattern, '<a target="_blank" href="mailto:$1">$1</a>')
|
||
|
.replace(twitterHandlePattern, "<a href='http://twitter.com/$2' target='_blank'>$1</a>")
|
||
|
.replace(twitterSearchPattern, "<a href='http://twitter.com/#search?q=%23$2' target='_blank'>$1</a>");
|
||
|
};
|
||
|
};
|
||
|
//str.substr(3,4)
|
||
|
/*
|
||
|
* 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.
|
||
|
*/
|
||
13 years ago
|
|
||
13 years ago
|
var dateFormat = function () {
|
||
|
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/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;
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
// Regexes and supporting functions are cached through closure
|
||
|
return function (date, mask, utc) {
|
||
|
var dF = dateFormat;
|
||
13 years ago
|
|
||
13 years ago
|
// 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;
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
// Passing date through Date applies Date.parse, if necessary
|
||
|
date = date ? new Date(date) : new Date;
|
||
|
if (isNaN(date)) throw SyntaxError("invalid date");
|
||
|
|
||
|
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;
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
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"](),
|
||
|
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]
|
||
|
};
|
||
|
|
||
|
return mask.replace(token, function ($0) {
|
||
|
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
|
||
|
});
|
||
13 years ago
|
};
|
||
13 years ago
|
}();
|
||
|
|
||
|
// 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"
|
||
|
]
|
||
|
};
|
||
13 years ago
|
|
||
13 years ago
|
// For convenience...
|
||
|
Date.prototype.format = function (mask, utc) {
|
||
|
return dateFormat(this, mask, utc);
|
||
|
};
|
||
|
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/***********************************************
|
||
13 years ago
|
Begin VMM.LoadLib.js
|
||
13 years ago
|
***********************************************/
|
||
13 years ago
|
|
||
13 years ago
|
/*
|
||
|
LoadLib
|
||
|
Based on LazyLoad by Ryan Grove
|
||
|
https://github.com/rgrove/lazyload/
|
||
|
Copyright (c) 2011 Ryan Grove <ryan@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.
|
||
|
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
window.loadedJS = [];
|
||
|
|
||
|
|
||
|
if(typeof VMM != 'undefined' && typeof VMM.LoadLib == 'undefined') {
|
||
|
//VMM.LoadLib.js('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', onJQueryLoaded);
|
||
|
//VMM.LoadLib.css('http://someurl.css', onCSSLoaded);
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
|
||
|
VMM.LoadLib = (function (doc) {
|
||
|
var env,
|
||
|
head,
|
||
|
pending = {},
|
||
|
pollCount = 0,
|
||
|
queue = {css: [], js: []},
|
||
|
styleSheets = doc.styleSheets;
|
||
|
|
||
|
var loaded_Array = [];
|
||
|
|
||
|
function isLoaded(url) {
|
||
|
var has_been_loaded = false;
|
||
|
for(var i=0; i<loaded_Array.length; i++) {
|
||
|
if (loaded_Array[i] == url) {
|
||
|
has_been_loaded = true;
|
||
|
}
|
||
|
}
|
||
|
if (!has_been_loaded) {
|
||
|
loaded_Array.push(url);
|
||
|
}
|
||
|
return has_been_loaded;
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
function createNode(name, attrs) {
|
||
|
var node = doc.createElement(name), attr;
|
||
|
|
||
|
for (attr in attrs) {
|
||
|
if (attrs.hasOwnProperty(attr)) {
|
||
|
node.setAttribute(attr, attrs[attr]);
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
|
||
|
return node;
|
||
|
}
|
||
|
|
||
|
function finish(type) {
|
||
|
var p = pending[type],
|
||
|
callback,
|
||
|
urls;
|
||
|
|
||
|
if (p) {
|
||
|
callback = p.callback;
|
||
|
urls = p.urls;
|
||
|
urls.shift();
|
||
|
pollCount = 0;
|
||
|
if (!urls.length) {
|
||
|
callback && callback.call(p.context, p.obj);
|
||
|
pending[type] = null;
|
||
|
queue[type].length && load(type);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function getEnv() {
|
||
|
var ua = navigator.userAgent;
|
||
|
|
||
|
env = {
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
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) {
|
||
|
|
||
|
urls = typeof urls === 'string' ? [urls] : urls.concat();
|
||
|
|
||
|
if (isCSS || env.async || env.gecko || env.opera) {
|
||
|
|
||
|
queue[type].push({
|
||
|
urls : urls,
|
||
|
callback: callback,
|
||
|
obj : obj,
|
||
|
context : context
|
||
|
});
|
||
|
} else {
|
||
|
for (i = 0, len = urls.length; i < len; ++i) {
|
||
|
queue[type].push({
|
||
|
urls : [urls[i]],
|
||
|
callback: i === len - 1 ? callback : null,
|
||
|
obj : obj,
|
||
|
context : context
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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)) {
|
||
|
if (env.webkit) {
|
||
|
p.urls[i] = node.href;
|
||
|
pollWebKit();
|
||
|
} else {
|
||
|
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]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function pollGecko(node) {
|
||
|
var hasRules;
|
||
|
|
||
|
try {
|
||
|
|
||
|
hasRules = !!node.sheet.cssRules;
|
||
|
} catch (ex) {
|
||
|
pollCount += 1;
|
||
|
|
||
|
if (pollCount < 200) {
|
||
|
setTimeout(function () { pollGecko(node); }, 50);
|
||
|
} else {
|
||
|
|
||
|
hasRules && finish('css');
|
||
|
}
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
finish('css');
|
||
|
}
|
||
|
|
||
|
function pollWebKit() {
|
||
|
var css = pending.css, i;
|
||
|
|
||
|
if (css) {
|
||
|
i = styleSheets.length;
|
||
|
|
||
|
while (--i >= 0) {
|
||
|
if (styleSheets[i].href === css.urls[0]) {
|
||
|
finish('css');
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pollCount += 1;
|
||
|
|
||
|
if (css) {
|
||
|
if (pollCount < 200) {
|
||
|
setTimeout(pollWebKit, 50);
|
||
|
} else {
|
||
|
|
||
|
finish('css');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
|
||
|
css: function (urls, callback, obj, context) {
|
||
|
if (isLoaded(urls)) {
|
||
|
return callback;
|
||
|
} else {
|
||
|
load('css', urls, callback, obj, context);
|
||
13 years ago
|
}
|
||
13 years ago
|
},
|
||
13 years ago
|
|
||
|
js: function (urls, callback, obj, context) {
|
||
|
if (isLoaded(urls)) {
|
||
|
return callback;
|
||
|
} else {
|
||
|
load('js', urls, callback, obj, context);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
};
|
||
|
})(this.document);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***********************************************
|
||
|
Begin VMM.Language.js
|
||
|
***********************************************/
|
||
|
|
||
|
/* LANGUAGE
|
||
|
================================================== */
|
||
|
if(typeof VMM != 'undefined' && typeof VMM.Language == 'undefined') {
|
||
|
VMM.Language = {
|
||
|
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_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>'",
|
||
13 years ago
|
},
|
||
13 years ago
|
messages: {
|
||
|
loading_timeline: "Loading Timeline... ",
|
||
|
return_to_title: "Return to Title",
|
||
|
expand_timeline: "Expand Timeline",
|
||
|
contract_timeline: "Contract Timeline"
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/***********************************************
|
||
|
Begin AES.js
|
||
|
***********************************************/
|
||
|
|
||
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||
|
/* AES implementation in JavaScript (c) Chris Veness 2005-2011 */
|
||
|
/* - see http://csrc.nist.gov/publications/PubsFIPS.html#197 */
|
||
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||
|
|
||
|
var Aes = {}; // Aes namespace
|
||
|
|
||
|
/**
|
||
|
* AES Cipher function: encrypt 'input' state with Rijndael algorithm
|
||
|
* applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
|
||
|
*
|
||
|
* @param {Number[]} input 16-byte (128-bit) input state array
|
||
|
* @param {Number[][]} w Key schedule as 2D byte-array (Nr+1 x Nb bytes)
|
||
|
* @returns {Number[]} Encrypted output state array
|
||
|
*/
|
||
|
Aes.cipher = function(input, w) { // main Cipher function [§5.1]
|
||
|
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
|
||
|
var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
|
||
|
|
||
|
var state = [[],[],[],[]]; // initialise 4xNb byte-array 'state' with input [§3.4]
|
||
|
for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
|
||
|
|
||
|
state = Aes.addRoundKey(state, w, 0, Nb);
|
||
|
|
||
|
for (var round=1; round<Nr; round++) {
|
||
|
state = Aes.subBytes(state, Nb);
|
||
|
state = Aes.shiftRows(state, Nb);
|
||
|
state = Aes.mixColumns(state, Nb);
|
||
|
state = Aes.addRoundKey(state, w, round, Nb);
|
||
|
}
|
||
|
|
||
|
state = Aes.subBytes(state, Nb);
|
||
|
state = Aes.shiftRows(state, Nb);
|
||
|
state = Aes.addRoundKey(state, w, Nr, Nb);
|
||
|
|
||
|
var output = new Array(4*Nb); // convert state to 1-d array before returning [§3.4]
|
||
|
for (var i=0; i<4*Nb; i++) output[i] = state[i%4][Math.floor(i/4)];
|
||
|
return output;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Perform Key Expansion to generate a Key Schedule
|
||
|
*
|
||
|
* @param {Number[]} key Key as 16/24/32-byte array
|
||
|
* @returns {Number[][]} Expanded key schedule as 2D byte-array (Nr+1 x Nb bytes)
|
||
|
*/
|
||
|
Aes.keyExpansion = function(key) { // generate Key Schedule (byte-array Nr+1 x Nb) from Key [§5.2]
|
||
|
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
|
||
|
var Nk = key.length/4 // key length (in words): 4/6/8 for 128/192/256-bit keys
|
||
|
var Nr = Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
|
||
|
|
||
|
var w = new Array(Nb*(Nr+1));
|
||
|
var temp = new Array(4);
|
||
|
|
||
|
for (var i=0; i<Nk; i++) {
|
||
|
var r = [key[4*i], key[4*i+1], key[4*i+2], key[4*i+3]];
|
||
|
w[i] = r;
|
||
|
}
|
||
|
|
||
|
for (var i=Nk; i<(Nb*(Nr+1)); i++) {
|
||
|
w[i] = new Array(4);
|
||
|
for (var t=0; t<4; t++) temp[t] = w[i-1][t];
|
||
|
if (i % Nk == 0) {
|
||
|
temp = Aes.subWord(Aes.rotWord(temp));
|
||
|
for (var t=0; t<4; t++) temp[t] ^= Aes.rCon[i/Nk][t];
|
||
|
} else if (Nk > 6 && i%Nk == 4) {
|
||
|
temp = Aes.subWord(temp);
|
||
|
}
|
||
|
for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
|
||
|
}
|
||
|
|
||
|
return w;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* ---- remaining routines are private, not called externally ----
|
||
|
*/
|
||
|
|
||
|
Aes.subBytes = function(s, Nb) { // apply SBox to state S [§5.1.1]
|
||
|
for (var r=0; r<4; r++) {
|
||
|
for (var c=0; c<Nb; c++) s[r][c] = Aes.sBox[s[r][c]];
|
||
|
}
|
||
|
return s;
|
||
|
}
|
||
|
|
||
|
Aes.shiftRows = function(s, Nb) { // shift row r of state S left by r bytes [§5.1.2]
|
||
|
var t = new Array(4);
|
||
|
for (var r=1; r<4; r++) {
|
||
|
for (var c=0; c<4; c++) t[c] = s[r][(c+r)%Nb]; // shift into temp copy
|
||
|
for (var c=0; c<4; c++) s[r][c] = t[c]; // and copy back
|
||
|
} // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
|
||
|
return s; // see asmaes.sourceforge.net/rijndael/rijndaelImplementation.pdf
|
||
|
}
|
||
|
|
||
|
Aes.mixColumns = function(s, Nb) { // combine bytes of each col of state S [§5.1.3]
|
||
|
for (var c=0; c<4; c++) {
|
||
|
var a = new Array(4); // 'a' is a copy of the current column from 's'
|
||
|
var b = new Array(4); // 'b' is a•{02} in GF(2^8)
|
||
|
for (var i=0; i<4; i++) {
|
||
|
a[i] = s[i][c];
|
||
|
b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1;
|
||
|
|
||
|
}
|
||
|
// a[n] ^ b[n] is a•{03} in GF(2^8)
|
||
|
s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3
|
||
|
s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3
|
||
|
s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3
|
||
|
s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // 3*a0 + a1 + a2 + 2*a3
|
||
|
}
|
||
|
return s;
|
||
|
}
|
||
|
|
||
|
Aes.addRoundKey = function(state, w, rnd, Nb) { // xor Round Key into state S [§5.1.4]
|
||
|
for (var r=0; r<4; r++) {
|
||
|
for (var c=0; c<Nb; c++) state[r][c] ^= w[rnd*4+c][r];
|
||
|
}
|
||
|
return state;
|
||
|
}
|
||
|
|
||
|
Aes.subWord = function(w) { // apply SBox to 4-byte word w
|
||
|
for (var i=0; i<4; i++) w[i] = Aes.sBox[w[i]];
|
||
|
return w;
|
||
|
}
|
||
|
|
||
|
Aes.rotWord = function(w) { // rotate 4-byte word w left by one byte
|
||
|
var tmp = w[0];
|
||
|
for (var i=0; i<3; i++) w[i] = w[i+1];
|
||
|
w[3] = tmp;
|
||
|
return w;
|
||
|
}
|
||
|
|
||
|
// sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [§5.1.1]
|
||
|
Aes.sBox = [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
|
||
|
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
|
||
|
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
|
||
|
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
|
||
|
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
|
||
|
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
|
||
|
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
|
||
|
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
|
||
|
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
|
||
|
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
|
||
|
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
|
||
|
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
|
||
|
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
|
||
|
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
|
||
|
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
|
||
|
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16];
|
||
|
|
||
|
// rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [§5.2]
|
||
|
Aes.rCon = [ [0x00, 0x00, 0x00, 0x00],
|
||
|
[0x01, 0x00, 0x00, 0x00],
|
||
|
[0x02, 0x00, 0x00, 0x00],
|
||
|
[0x04, 0x00, 0x00, 0x00],
|
||
|
[0x08, 0x00, 0x00, 0x00],
|
||
|
[0x10, 0x00, 0x00, 0x00],
|
||
|
[0x20, 0x00, 0x00, 0x00],
|
||
|
[0x40, 0x00, 0x00, 0x00],
|
||
|
[0x80, 0x00, 0x00, 0x00],
|
||
|
[0x1b, 0x00, 0x00, 0x00],
|
||
|
[0x36, 0x00, 0x00, 0x00] ];
|
||
|
|
||
|
|
||
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||
|
/* AES Counter-mode implementation in JavaScript (c) Chris Veness 2005-2011 */
|
||
|
/* - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf */
|
||
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||
|
|
||
|
Aes.Ctr = {}; // Aes.Ctr namespace: a subclass or extension of Aes
|
||
|
|
||
|
/**
|
||
|
* Encrypt a text using AES encryption in Counter mode of operation
|
||
|
*
|
||
|
* Unicode multi-byte character safe
|
||
|
*
|
||
|
* @param {String} plaintext Source text to be encrypted
|
||
|
* @param {String} password The password to use to generate a key
|
||
|
* @param {Number} nBits Number of bits to be used in the key (128, 192, or 256)
|
||
|
* @returns {string} Encrypted text
|
||
|
*/
|
||
|
Aes.Ctr.encrypt = function(plaintext, password, nBits) {
|
||
|
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
|
||
|
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
|
||
|
plaintext = Utf8.encode(plaintext);
|
||
|
password = Utf8.encode(password);
|
||
|
//var t = new Date(); // timer
|
||
|
|
||
|
// use AES itself to encrypt password to get cipher key (using plain password as source for key
|
||
|
// expansion) - gives us well encrypted key (though hashed key might be preferred for prod'n use)
|
||
|
var nBytes = nBits/8; // no bytes in key (16/24/32)
|
||
|
var pwBytes = new Array(nBytes);
|
||
|
for (var i=0; i<nBytes; i++) { // use 1st 16/24/32 chars of password for key
|
||
|
pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i);
|
||
|
}
|
||
|
var key = Aes.cipher(pwBytes, Aes.keyExpansion(pwBytes)); // gives us 16-byte key
|
||
|
key = key.concat(key.slice(0, nBytes-16)); // expand key to 16/24/32 bytes long
|
||
|
|
||
|
// initialise 1st 8 bytes of counter block with nonce (NIST SP800-38A §B.2): [0-1] = millisec,
|
||
|
// [2-3] = random, [4-7] = seconds, together giving full sub-millisec uniqueness up to Feb 2106
|
||
|
var counterBlock = new Array(blockSize);
|
||
|
|
||
|
var nonce = (new Date()).getTime(); // timestamp: milliseconds since 1-Jan-1970
|
||
|
var nonceMs = nonce%1000;
|
||
|
var nonceSec = Math.floor(nonce/1000);
|
||
|
var nonceRnd = Math.floor(Math.random()*0xffff);
|
||
|
|
||
|
for (var i=0; i<2; i++) counterBlock[i] = (nonceMs >>> i*8) & 0xff;
|
||
|
for (var i=0; i<2; i++) counterBlock[i+2] = (nonceRnd >>> i*8) & 0xff;
|
||
|
for (var i=0; i<4; i++) counterBlock[i+4] = (nonceSec >>> i*8) & 0xff;
|
||
|
|
||
|
// and convert it to a string to go on the front of the ciphertext
|
||
|
var ctrTxt = '';
|
||
|
for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);
|
||
|
|
||
|
// generate key schedule - an expansion of the key into distinct Key Rounds for each round
|
||
|
var keySchedule = Aes.keyExpansion(key);
|
||
|
|
||
|
var blockCount = Math.ceil(plaintext.length/blockSize);
|
||
|
var ciphertxt = new Array(blockCount); // ciphertext as array of strings
|
||
|
|
||
|
for (var b=0; b<blockCount; b++) {
|
||
|
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
|
||
|
// done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB)
|
||
|
for (var c=0; c<4; c++) counterBlock[15-c] = (b >>> c*8) & 0xff;
|
||
|
for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)
|
||
|
|
||
|
var cipherCntr = Aes.cipher(counterBlock, keySchedule); // -- encrypt counter block --
|
||
|
|
||
|
// block size is reduced on final block
|
||
|
var blockLength = b<blockCount-1 ? blockSize : (plaintext.length-1)%blockSize+1;
|
||
|
var cipherChar = new Array(blockLength);
|
||
|
|
||
|
for (var i=0; i<blockLength; i++) { // -- xor plaintext with ciphered counter char-by-char --
|
||
|
cipherChar[i] = cipherCntr[i] ^ plaintext.charCodeAt(b*blockSize+i);
|
||
|
cipherChar[i] = String.fromCharCode(cipherChar[i]);
|
||
|
}
|
||
|
ciphertxt[b] = cipherChar.join('');
|
||
|
}
|
||
|
|
||
|
// Array.join is more efficient than repeated string concatenation in IE
|
||
|
var ciphertext = ctrTxt + ciphertxt.join('');
|
||
|
ciphertext = Base64.encode(ciphertext); // encode in base64
|
||
|
|
||
|
//alert((new Date()) - t);
|
||
|
return ciphertext;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Decrypt a text encrypted by AES in counter mode of operation
|
||
|
*
|
||
|
* @param {String} ciphertext Source text to be encrypted
|
||
|
* @param {String} password The password to use to generate a key
|
||
|
* @param {Number} nBits Number of bits to be used in the key (128, 192, or 256)
|
||
|
* @returns {String} Decrypted text
|
||
|
*/
|
||
|
Aes.Ctr.decrypt = function(ciphertext, password, nBits) {
|
||
|
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
|
||
|
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
|
||
|
ciphertext = Base64.decode(ciphertext);
|
||
|
password = Utf8.encode(password);
|
||
|
//var t = new Date(); // timer
|
||
|
|
||
|
// use AES to encrypt password (mirroring encrypt routine)
|
||
|
var nBytes = nBits/8; // no bytes in key
|
||
|
var pwBytes = new Array(nBytes);
|
||
|
for (var i=0; i<nBytes; i++) {
|
||
|
pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i);
|
||
|
}
|
||
|
var key = Aes.cipher(pwBytes, Aes.keyExpansion(pwBytes));
|
||
|
key = key.concat(key.slice(0, nBytes-16)); // expand key to 16/24/32 bytes long
|
||
|
|
||
|
// recover nonce from 1st 8 bytes of ciphertext
|
||
|
var counterBlock = new Array(8);
|
||
|
ctrTxt = ciphertext.slice(0, 8);
|
||
|
for (var i=0; i<8; i++) counterBlock[i] = ctrTxt.charCodeAt(i);
|
||
|
|
||
|
// generate key schedule
|
||
|
var keySchedule = Aes.keyExpansion(key);
|
||
|
|
||
|
// separate ciphertext into blocks (skipping past initial 8 bytes)
|
||
|
var nBlocks = Math.ceil((ciphertext.length-8) / blockSize);
|
||
|
var ct = new Array(nBlocks);
|
||
|
for (var b=0; b<nBlocks; b++) ct[b] = ciphertext.slice(8+b*blockSize, 8+b*blockSize+blockSize);
|
||
|
ciphertext = ct; // ciphertext is now array of block-length strings
|
||
|
|
||
|
// plaintext will get generated block-by-block into array of block-length strings
|
||
|
var plaintxt = new Array(ciphertext.length);
|
||
|
|
||
|
for (var b=0; b<nBlocks; b++) {
|
||
|
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
|
||
|
for (var c=0; c<4; c++) counterBlock[15-c] = ((b) >>> c*8) & 0xff;
|
||
|
for (var c=0; c<4; c++) counterBlock[15-c-4] = (((b+1)/0x100000000-1) >>> c*8) & 0xff;
|
||
|
|
||
|
var cipherCntr = Aes.cipher(counterBlock, keySchedule); // encrypt counter block
|
||
|
|
||
|
var plaintxtByte = new Array(ciphertext[b].length);
|
||
|
for (var i=0; i<ciphertext[b].length; i++) {
|
||
|
// -- xor plaintxt with ciphered counter byte-by-byte --
|
||
|
plaintxtByte[i] = cipherCntr[i] ^ ciphertext[b].charCodeAt(i);
|
||
|
plaintxtByte[i] = String.fromCharCode(plaintxtByte[i]);
|
||
|
}
|
||
|
plaintxt[b] = plaintxtByte.join('');
|
||
|
}
|
||
|
|
||
|
// join array of blocks into single plaintext string
|
||
|
var plaintext = plaintxt.join('');
|
||
|
plaintext = Utf8.decode(plaintext); // decode from UTF8 back to Unicode multi-byte chars
|
||
|
|
||
|
//alert((new Date()) - t);
|
||
|
return plaintext;
|
||
|
}
|
||
|
|
||
|
|
||
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||
|
/* Base64 class: Base 64 encoding / decoding (c) Chris Veness 2002-2011 */
|
||
|
/* note: depends on Utf8 class */
|
||
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||
|
|
||
|
var Base64 = {}; // Base64 namespace
|
||
|
|
||
|
Base64.code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||
|
|
||
|
/**
|
||
|
* Encode string into Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
|
||
|
* (instance method extending String object). As per RFC 4648, no newlines are added.
|
||
|
*
|
||
|
* @param {String} str The string to be encoded as base-64
|
||
|
* @param {Boolean} [utf8encode=false] Flag to indicate whether str is Unicode string to be encoded
|
||
|
* to UTF8 before conversion to base64; otherwise string is assumed to be 8-bit characters
|
||
|
* @returns {String} Base64-encoded string
|
||
|
*/
|
||
|
Base64.encode = function(str, utf8encode) { // http://tools.ietf.org/html/rfc4648
|
||
|
utf8encode = (typeof utf8encode == 'undefined') ? false : utf8encode;
|
||
|
var o1, o2, o3, bits, h1, h2, h3, h4, e=[], pad = '', c, plain, coded;
|
||
|
var b64 = Base64.code;
|
||
|
|
||
|
plain = utf8encode ? str.encodeUTF8() : str;
|
||
|
|
||
|
c = plain.length % 3; // pad string to length of multiple of 3
|
||
|
if (c > 0) { while (c++ < 3) { pad += '='; plain += '\0'; } }
|
||
|
// note: doing padding here saves us doing special-case packing for trailing 1 or 2 chars
|
||
|
|
||
|
for (c=0; c<plain.length; c+=3) { // pack three octets into four hexets
|
||
|
o1 = plain.charCodeAt(c);
|
||
|
o2 = plain.charCodeAt(c+1);
|
||
|
o3 = plain.charCodeAt(c+2);
|
||
|
|
||
|
bits = o1<<16 | o2<<8 | o3;
|
||
|
|
||
|
h1 = bits>>18 & 0x3f;
|
||
|
h2 = bits>>12 & 0x3f;
|
||
|
h3 = bits>>6 & 0x3f;
|
||
|
h4 = bits & 0x3f;
|
||
|
|
||
|
// use hextets to index into code string
|
||
|
e[c/3] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
|
||
|
}
|
||
|
coded = e.join(''); // join() is far faster than repeated string concatenation in IE
|
||
|
|
||
|
// replace 'A's from padded nulls with '='s
|
||
|
coded = coded.slice(0, coded.length-pad.length) + pad;
|
||
|
|
||
|
return coded;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Decode string from Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
|
||
|
* (instance method extending String object). As per RFC 4648, newlines are not catered for.
|
||
|
*
|
||
|
* @param {String} str The string to be decoded from base-64
|
||
|
* @param {Boolean} [utf8decode=false] Flag to indicate whether str is Unicode string to be decoded
|
||
|
* from UTF8 after conversion from base64
|
||
|
* @returns {String} decoded string
|
||
|
*/
|
||
|
Base64.decode = function(str, utf8decode) {
|
||
|
utf8decode = (typeof utf8decode == 'undefined') ? false : utf8decode;
|
||
|
var o1, o2, o3, h1, h2, h3, h4, bits, d=[], plain, coded;
|
||
|
var b64 = Base64.code;
|
||
|
|
||
|
coded = utf8decode ? str.decodeUTF8() : str;
|
||
|
|
||
|
|
||
|
for (var c=0; c<coded.length; c+=4) { // unpack four hexets into three octets
|
||
|
h1 = b64.indexOf(coded.charAt(c));
|
||
|
h2 = b64.indexOf(coded.charAt(c+1));
|
||
|
h3 = b64.indexOf(coded.charAt(c+2));
|
||
|
h4 = b64.indexOf(coded.charAt(c+3));
|
||
|
|
||
|
bits = h1<<18 | h2<<12 | h3<<6 | h4;
|
||
|
|
||
|
o1 = bits>>>16 & 0xff;
|
||
|
o2 = bits>>>8 & 0xff;
|
||
|
o3 = bits & 0xff;
|
||
|
|
||
|
d[c/4] = String.fromCharCode(o1, o2, o3);
|
||
|
// check for padding
|
||
|
if (h4 == 0x40) d[c/4] = String.fromCharCode(o1, o2);
|
||
|
if (h3 == 0x40) d[c/4] = String.fromCharCode(o1);
|
||
|
}
|
||
|
plain = d.join(''); // join() is far faster than repeated string concatenation in IE
|
||
|
|
||
|
return utf8decode ? plain.decodeUTF8() : plain;
|
||
|
}
|
||
|
|
||
|
|
||
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||
|
/* Utf8 class: encode / decode between multi-byte Unicode characters and UTF-8 multiple */
|
||
|
/* single-byte character encoding (c) Chris Veness 2002-2011 */
|
||
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||
|
|
||
|
var Utf8 = {}; // Utf8 namespace
|
||
|
|
||
|
/**
|
||
|
* Encode multi-byte Unicode string into utf-8 multiple single-byte characters
|
||
|
* (BMP / basic multilingual plane only)
|
||
|
*
|
||
|
* Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars
|
||
|
*
|
||
|
* @param {String} strUni Unicode string to be encoded as UTF-8
|
||
|
* @returns {String} encoded string
|
||
|
*/
|
||
|
Utf8.encode = function(strUni) {
|
||
|
// use regular expressions & String.replace callback function for better efficiency
|
||
|
// than procedural approaches
|
||
|
var strUtf = strUni.replace(
|
||
|
/[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz
|
||
|
function(c) {
|
||
|
var cc = c.charCodeAt(0);
|
||
|
return String.fromCharCode(0xc0 | cc>>6, 0x80 | cc&0x3f); }
|
||
|
);
|
||
|
strUtf = strUtf.replace(
|
||
|
/[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz
|
||
|
function(c) {
|
||
|
var cc = c.charCodeAt(0);
|
||
|
return String.fromCharCode(0xe0 | cc>>12, 0x80 | cc>>6&0x3F, 0x80 | cc&0x3f); }
|
||
|
);
|
||
|
return strUtf;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Decode utf-8 encoded string back into multi-byte Unicode characters
|
||
|
*
|
||
|
* @param {String} strUtf UTF-8 string to be decoded back to Unicode
|
||
|
* @returns {String} decoded string
|
||
|
*/
|
||
|
Utf8.decode = function(strUtf) {
|
||
|
// note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char!
|
||
|
var strUni = strUtf.replace(
|
||
|
/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars
|
||
|
function(c) { // (note parentheses for precence)
|
||
|
var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f);
|
||
|
return String.fromCharCode(cc); }
|
||
|
);
|
||
|
strUni = strUni.replace(
|
||
|
/[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars
|
||
|
function(c) { // (note parentheses for precence)
|
||
|
var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f;
|
||
|
return String.fromCharCode(cc); }
|
||
|
);
|
||
|
return strUni;
|
||
|
}
|
||
|
|
||
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||
|
|
||
|
/***********************************************
|
||
|
Begin bootstrap-tooltip.js
|
||
|
***********************************************/
|
||
|
|
||
|
/* ===========================================================
|
||
|
* bootstrap-tooltip.js v2.0.1
|
||
|
* http://twitter.github.com/bootstrap/javascript.html#tooltips
|
||
|
* Inspired by the original jQuery.tipsy by Jason Frame
|
||
|
* ===========================================================
|
||
|
* Copyright 2012 Twitter, Inc.
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
* ========================================================== */
|
||
|
|
||
|
!function( $ ) {
|
||
|
|
||
|
"use strict"
|
||
|
|
||
|
/* TOOLTIP PUBLIC CLASS DEFINITION
|
||
|
* =============================== */
|
||
|
|
||
|
var Tooltip = function ( element, options ) {
|
||
|
this.init('tooltip', element, options)
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
Tooltip.prototype = {
|
||
13 years ago
|
|
||
13 years ago
|
constructor: Tooltip
|
||
13 years ago
|
|
||
13 years ago
|
, init: function ( type, element, options ) {
|
||
|
var eventIn
|
||
|
, eventOut
|
||
13 years ago
|
|
||
13 years ago
|
this.type = type
|
||
|
this.$element = $(element)
|
||
|
this.options = this.getOptions(options)
|
||
|
this.enabled = true
|
||
13 years ago
|
|
||
13 years ago
|
if (this.options.trigger != 'manual') {
|
||
|
eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
|
||
|
eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
|
||
|
this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
|
||
|
this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
this.options.selector ?
|
||
|
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
|
||
|
this.fixTitle()
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, getOptions: function ( options ) {
|
||
|
options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
|
||
|
|
||
|
if (options.delay && typeof options.delay == 'number') {
|
||
|
options.delay = {
|
||
|
show: options.delay
|
||
|
, hide: options.delay
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return options
|
||
|
}
|
||
|
|
||
|
, enter: function ( e ) {
|
||
|
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
|
||
|
|
||
|
if (!self.options.delay || !self.options.delay.show) {
|
||
|
self.show()
|
||
|
} else {
|
||
|
self.hoverState = 'in'
|
||
|
setTimeout(function() {
|
||
|
if (self.hoverState == 'in') {
|
||
|
self.show()
|
||
|
}
|
||
|
}, self.options.delay.show)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
, leave: function ( e ) {
|
||
|
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
|
||
|
|
||
|
if (!self.options.delay || !self.options.delay.hide) {
|
||
|
self.hide()
|
||
|
} else {
|
||
|
self.hoverState = 'out'
|
||
|
setTimeout(function() {
|
||
|
if (self.hoverState == 'out') {
|
||
|
self.hide()
|
||
|
}
|
||
|
}, self.options.delay.hide)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
, show: function () {
|
||
|
var $tip
|
||
|
, inside
|
||
|
, pos
|
||
|
, actualWidth
|
||
|
, actualHeight
|
||
|
, placement
|
||
|
, tp
|
||
|
|
||
|
if (this.hasContent() && this.enabled) {
|
||
|
$tip = this.tip()
|
||
|
this.setContent()
|
||
|
|
||
|
if (this.options.animation) {
|
||
|
$tip.addClass('fade')
|
||
|
}
|
||
|
|
||
|
placement = typeof this.options.placement == 'function' ?
|
||
|
this.options.placement.call(this, $tip[0], this.$element[0]) :
|
||
|
this.options.placement
|
||
13 years ago
|
|
||
13 years ago
|
inside = /in/.test(placement)
|
||
13 years ago
|
|
||
13 years ago
|
$tip
|
||
|
.remove()
|
||
|
.css({ top: 0, left: 0, display: 'block' })
|
||
|
.appendTo(inside ? this.$element : document.body)
|
||
13 years ago
|
|
||
13 years ago
|
pos = this.getPosition(inside)
|
||
13 years ago
|
|
||
13 years ago
|
actualWidth = $tip[0].offsetWidth
|
||
|
actualHeight = $tip[0].offsetHeight
|
||
13 years ago
|
|
||
13 years ago
|
switch (inside ? placement.split(' ')[1] : placement) {
|
||
|
case 'bottom':
|
||
|
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
|
||
|
break
|
||
|
case 'top':
|
||
|
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
|
||
|
break
|
||
|
case 'left':
|
||
|
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
|
||
|
break
|
||
|
case 'right':
|
||
|
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
|
||
|
break
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
$tip
|
||
|
.css(tp)
|
||
|
.addClass(placement)
|
||
|
.addClass('in')
|
||
|
}
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, setContent: function () {
|
||
|
var $tip = this.tip()
|
||
|
$tip.find('.tooltip-inner').html(this.getTitle())
|
||
|
$tip.removeClass('fade in top bottom left right')
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, hide: function () {
|
||
|
var that = this
|
||
|
, $tip = this.tip()
|
||
13 years ago
|
|
||
13 years ago
|
$tip.removeClass('in')
|
||
13 years ago
|
|
||
13 years ago
|
function removeWithAnimation() {
|
||
|
var timeout = setTimeout(function () {
|
||
|
$tip.off($.support.transition.end).remove()
|
||
|
}, 500)
|
||
13 years ago
|
|
||
13 years ago
|
$tip.one($.support.transition.end, function () {
|
||
|
clearTimeout(timeout)
|
||
|
$tip.remove()
|
||
|
})
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
$.support.transition && this.$tip.hasClass('fade') ?
|
||
|
removeWithAnimation() :
|
||
|
$tip.remove()
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, fixTitle: function () {
|
||
|
var $e = this.$element
|
||
|
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
|
||
|
$e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
|
||
|
}
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, hasContent: function () {
|
||
|
return this.getTitle()
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, getPosition: function (inside) {
|
||
|
return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
|
||
|
width: this.$element[0].offsetWidth
|
||
|
, height: this.$element[0].offsetHeight
|
||
|
})
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, getTitle: function () {
|
||
|
var title
|
||
|
, $e = this.$element
|
||
|
, o = this.options
|
||
13 years ago
|
|
||
13 years ago
|
title = $e.attr('data-original-title')
|
||
|
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
|
||
13 years ago
|
|
||
13 years ago
|
title = title.toString().replace(/(^\s*|\s*$)/, "")
|
||
13 years ago
|
|
||
13 years ago
|
return title
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, tip: function () {
|
||
|
return this.$tip = this.$tip || $(this.options.template)
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, validate: function () {
|
||
|
if (!this.$element[0].parentNode) {
|
||
|
this.hide()
|
||
|
this.$element = null
|
||
|
this.options = null
|
||
|
}
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, enable: function () {
|
||
|
this.enabled = true
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, disable: function () {
|
||
|
this.enabled = false
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, toggleEnabled: function () {
|
||
|
this.enabled = !this.enabled
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
, toggle: function () {
|
||
|
this[this.tip().hasClass('in') ? 'hide' : 'show']()
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
|
||
13 years ago
|
/* TOOLTIP PLUGIN DEFINITION
|
||
|
* ========================= */
|
||
|
|
||
|
$.fn.tooltip = function ( option ) {
|
||
|
return this.each(function () {
|
||
|
var $this = $(this)
|
||
|
, data = $this.data('tooltip')
|
||
|
, options = typeof option == 'object' && option
|
||
|
if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
|
||
|
if (typeof option == 'string') data[option]()
|
||
|
})
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
$.fn.tooltip.Constructor = Tooltip
|
||
13 years ago
|
|
||
13 years ago
|
$.fn.tooltip.defaults = {
|
||
|
animation: true
|
||
|
, delay: 0
|
||
|
, selector: false
|
||
|
, placement: 'top'
|
||
|
, trigger: 'hover'
|
||
|
, title: ''
|
||
|
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
}( window.jQuery );
|
||
13 years ago
|
|
||
13 years ago
|
/***********************************************
|
||
|
Begin VMM.Timeline.js
|
||
|
***********************************************/
|
||
|
|
||
|
/*!
|
||
13 years ago
|
Timeline
|
||
13 years ago
|
Designed and built by Zach Wise at VéritéCo
|
||
13 years ago
|
|
||
|
This program is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
http://www.gnu.org/licenses/
|
||
|
|
||
|
*/
|
||
|
|
||
|
/* CodeKit Import
|
||
|
http://incident57.com/codekit/
|
||
|
================================================== */
|
||
13 years ago
|
// @codekit-prepend "VMM.Timeline.License.js";
|
||
13 years ago
|
// @codekit-prepend "VMM.js";
|
||
|
// @codekit-prepend "VMM.Library.js";
|
||
|
// @codekit-prepend "VMM.Browser.js";
|
||
|
// @codekit-prepend "VMM.MediaElement.js";
|
||
|
// @codekit-prepend "VMM.MediaType.js";
|
||
|
// @codekit-prepend "VMM.Media.js";
|
||
|
// @codekit-prepend "VMM.FileExtention.js";
|
||
|
// @codekit-prepend "VMM.ExternalAPI.js";
|
||
|
// @codekit-prepend "VMM.TouchSlider.js";
|
||
|
// @codekit-prepend "VMM.DragSlider.js";
|
||
|
// @codekit-prepend "VMM.Slider.js";
|
||
13 years ago
|
// @codekit-prepend "VMM.Slider.Slide.js";
|
||
13 years ago
|
// @codekit-prepend "VMM.Util.js";
|
||
|
// @codekit-prepend "VMM.LoadLib.js";
|
||
|
// @codekit-prepend "VMM.Language.js";
|
||
|
|
||
|
// @codekit-append "VMM.Timeline.TimeNav.js";
|
||
|
// @codekit-append "VMM.Timeline.DataObj.js";
|
||
|
|
||
13 years ago
|
// @codekit-prepend "lib/AES.js";
|
||
|
// @codekit-prepend "lib/bootstrap-tooltip.js";
|
||
|
|
||
13 years ago
|
|
||
|
|
||
|
|
||
13 years ago
|
/* Timeline
|
||
|
================================================== */
|
||
|
|
||
13 years ago
|
if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') {
|
||
|
|
||
13 years ago
|
VMM.Timeline = function(w, h, conf, _timeline_id) {
|
||
13 years ago
|
|
||
13 years ago
|
var $timeline, $feedback, $messege, slider, timenav, version, timeline_id;
|
||
|
var events = {}, data = {}, _dates = [], config = {};
|
||
13 years ago
|
var has_width = false, has_height = false, ie7 = false, is_moving = false;
|
||
13 years ago
|
|
||
13 years ago
|
if (type.of(_timeline_id) == "string") {
|
||
13 years ago
|
timeline_id = _timeline_id;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
timeline_id = "#timeline";
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
version = "1.10";
|
||
13 years ago
|
|
||
|
trace("TIMELINE VERSION " + version);
|
||
13 years ago
|
|
||
|
/* CONFIG
|
||
|
================================================== */
|
||
13 years ago
|
config = {
|
||
13 years ago
|
id: timeline_id,
|
||
|
type: "timeline",
|
||
|
maptype: "toner",
|
||
13 years ago
|
preload: 4,
|
||
13 years ago
|
current_slide: 0,
|
||
|
hash_bookmark: false,
|
||
|
start_at_end: false,
|
||
13 years ago
|
start_page: false,
|
||
13 years ago
|
api_keys: {
|
||
|
google: "",
|
||
|
flickr: "",
|
||
|
twitter: ""
|
||
|
},
|
||
13 years ago
|
interval: 10,
|
||
|
something: 0,
|
||
|
width: 960,
|
||
|
height: 540,
|
||
|
spacing: 15,
|
||
13 years ago
|
loaded: {
|
||
13 years ago
|
slider: false,
|
||
|
timenav: false,
|
||
|
percentloaded: 0
|
||
13 years ago
|
},
|
||
|
nav: {
|
||
13 years ago
|
start_page: false,
|
||
|
interval_width: 200,
|
||
|
density: 4,
|
||
|
minor_width: 0,
|
||
|
multiplier: {
|
||
|
current: 6,
|
||
|
min: .1,
|
||
|
max: 50
|
||
|
},
|
||
|
rows: [1, 1, 1],
|
||
|
width: 960,
|
||
|
height: 200,
|
||
|
marker: {
|
||
|
width: 150,
|
||
|
height: 48
|
||
|
}
|
||
13 years ago
|
},
|
||
|
feature: {
|
||
13 years ago
|
width: 960,
|
||
|
height: 540
|
||
13 years ago
|
},
|
||
|
slider: {
|
||
13 years ago
|
width: 720,
|
||
|
height: 400,
|
||
13 years ago
|
content: {
|
||
13 years ago
|
width: 720,
|
||
|
height: 400,
|
||
|
padding: 130,
|
||
13 years ago
|
},
|
||
|
nav: {
|
||
13 years ago
|
width: 100,
|
||
|
height: 200
|
||
13 years ago
|
}
|
||
|
},
|
||
13 years ago
|
ease: "easeInOutExpo",
|
||
|
duration: 1000,
|
||
|
language: VMM.Language
|
||
13 years ago
|
};
|
||
|
|
||
13 years ago
|
if ( w != null && w != "") {
|
||
13 years ago
|
config.width = w;
|
||
13 years ago
|
has_width = true;
|
||
|
}
|
||
|
|
||
|
if ( h != null && h != "") {
|
||
13 years ago
|
config.height = h;
|
||
13 years ago
|
has_height = true;
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
if(window.location.hash) {
|
||
|
var hash = window.location.hash.substring(1);
|
||
13 years ago
|
if (!isNaN(hash)) {
|
||
|
config.current_slide = parseInt(hash);
|
||
|
}
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
window.onhashchange = function () {
|
||
|
if (config.hash_bookmark) {
|
||
|
if (is_moving) {
|
||
|
var hash = window.location.hash.substring(1);
|
||
|
goToEvent(parseInt(hash));
|
||
|
} else {
|
||
|
is_moving = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
/* CREATE CONFIG
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
var createConfig = function(conf) {
|
||
|
|
||
|
// APPLY SUPPLIED CONFIG TO TIMELINE CONFIG
|
||
|
if (typeof timeline_config == 'object') {
|
||
|
trace("HAS TIMELINE CONFIG");
|
||
|
var x;
|
||
13 years ago
|
for (x in timeline_config) {
|
||
|
if (Object.prototype.hasOwnProperty.call(timeline_config, x)) {
|
||
|
config[x] = timeline_config[x];
|
||
13 years ago
|
}
|
||
13 years ago
|
}
|
||
13 years ago
|
} else if (typeof conf == 'object') {
|
||
|
var x;
|
||
|
for (x in conf) {
|
||
|
if (Object.prototype.hasOwnProperty.call(conf, x)) {
|
||
|
config[x] = conf[x];
|
||
|
}
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
config.nav.width = config.width;
|
||
|
config.nav.height = 200;
|
||
|
config.feature.width = config.width;
|
||
|
config.feature.height = config.height - config.nav.height;
|
||
|
VMM.Timeline.Config = config;
|
||
|
VMM.master_config.Timeline = VMM.Timeline.Config;
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
/* CREATE TIMELINE STRUCTURE
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
var createStructure = function(w, h) {
|
||
|
$timeline = VMM.getElement(timeline_id);
|
||
|
|
||
13 years ago
|
VMM.Lib.addClass(timeline_id, "vmm-timeline");
|
||
13 years ago
|
|
||
|
$feedback = VMM.appendAndGetElement($timeline, "<div>", "feedback", "");
|
||
|
$messege = VMM.appendAndGetElement($feedback, "<div>", "messege", "Timeline");
|
||
|
slider = new VMM.Slider(timeline_id + " div.slider", config);
|
||
13 years ago
|
timenav = new VMM.Timeline.TimeNav(timeline_id + " div.navigation");
|
||
13 years ago
|
|
||
|
if (!has_width) {
|
||
13 years ago
|
config.width = VMM.Lib.width($timeline);
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.Lib.width($timeline, config.width);
|
||
13 years ago
|
}
|
||
|
|
||
|
if (!has_height) {
|
||
13 years ago
|
config.height = VMM.Lib.height($timeline);
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.Lib.height($timeline, config.height);
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/* ON EVENT
|
||
|
================================================== */
|
||
|
|
||
|
function onDataReady(e, d) {
|
||
|
|
||
|
data = d.timeline;
|
||
|
|
||
|
if (type.of(data.era) == "array") {
|
||
|
|
||
|
} else {
|
||
|
data.era = [];
|
||
|
}
|
||
|
|
||
|
buildDates();
|
||
|
|
||
|
};
|
||
|
|
||
|
function onDatesProcessed() {
|
||
|
build();
|
||
|
}
|
||
|
|
||
|
function reSize() {
|
||
|
updateSize();
|
||
13 years ago
|
slider.setSize(config.feature.width, config.feature.height);
|
||
13 years ago
|
timenav.setSize(config.width, config.height);
|
||
|
};
|
||
|
|
||
|
function onSliderLoaded(e) {
|
||
|
config.loaded.slider = true;
|
||
|
onComponentLoaded();
|
||
|
};
|
||
|
|
||
|
function onComponentLoaded(e) {
|
||
|
config.loaded.percentloaded = config.loaded.percentloaded + 25;
|
||
13 years ago
|
|
||
13 years ago
|
if (config.loaded.slider && config.loaded.timenav) {
|
||
|
hideMessege();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function onTimeNavLoaded(e) {
|
||
|
config.loaded.timenav = true;
|
||
|
onComponentLoaded();
|
||
|
}
|
||
|
|
||
|
function onSlideUpdate(e) {
|
||
13 years ago
|
is_moving = true;
|
||
|
config.current_slide = slider.getCurrentNumber();
|
||
|
setHash(config.current_slide);
|
||
|
timenav.setMarker(config.current_slide, config.ease,config.duration);
|
||
13 years ago
|
};
|
||
|
|
||
|
function onMarkerUpdate(e) {
|
||
13 years ago
|
is_moving = true;
|
||
|
config.current_slide = timenav.getCurrentNumber();
|
||
|
setHash(config.current_slide);
|
||
|
slider.setSlide(config.current_slide);
|
||
13 years ago
|
};
|
||
|
|
||
13 years ago
|
var goToEvent = function(n) {
|
||
|
if (n <= _dates.length - 1 && n >= 0) {
|
||
|
config.current_slide = n;
|
||
|
slider.setSlide(config.current_slide);
|
||
|
timenav.setMarker(config.current_slide, config.ease,config.duration);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function setHash(n) {
|
||
|
if (config.hash_bookmark) {
|
||
|
window.location.hash = "#" + n.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
/* PUBLIC FUNCTIONS
|
||
|
================================================== */
|
||
13 years ago
|
this.init = function(_data, _timeline_id, conf) {
|
||
|
|
||
|
if (type.of(_timeline_id) == "string") {
|
||
|
if (_timeline_id.match("#")) {
|
||
|
timeline_id = _timeline_id;
|
||
|
} else {
|
||
|
timeline_id = "#" + _timeline_id;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
createConfig(conf);
|
||
|
createStructure(w,h);
|
||
13 years ago
|
|
||
13 years ago
|
trace('TIMELINE INIT');
|
||
|
VMM.Util.date.setLanguage(VMM.Timeline.Config.language);
|
||
13 years ago
|
|
||
13 years ago
|
$feedback = VMM.appendAndGetElement($timeline, "<div>", "feedback", "");
|
||
|
$messege = VMM.appendAndGetElement($feedback, "<div>", "messege", VMM.Timeline.Config.language.messages.loading_timeline);
|
||
|
|
||
13 years ago
|
VMM.bindEvent(global, onDataReady, "DATAREADY");
|
||
13 years ago
|
VMM.bindEvent(global, showMessege, "MESSEGE");
|
||
13 years ago
|
|
||
|
/* GET DATA
|
||
|
================================================== */
|
||
13 years ago
|
|
||
|
if (VMM.Browser.browser == "MSIE" && parseInt(VMM.Browser.version, 10) == 7) {
|
||
|
ie7 = true;
|
||
|
VMM.fireEvent(global, "MESSEGE", "Internet Explorer 7 is not supported by #Timeline.");
|
||
13 years ago
|
} else {
|
||
13 years ago
|
if (type.of(_data) == "string" || type.of(_data) == "object") {
|
||
13 years ago
|
trace("GET DATA 1")
|
||
13 years ago
|
VMM.Timeline.DataObj.getData(_data);
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.Timeline.DataObj.getData(VMM.getElement(timeline_id));
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
this.iframeLoaded = function() {
|
||
|
trace("iframeLoaded");
|
||
|
};
|
||
|
|
||
|
/* DATA
|
||
|
================================================== */
|
||
|
var getData = function(url) {
|
||
|
VMM.getJSON(url, function(d) {
|
||
|
data = VMM.Timeline.DataObj.getData(d);
|
||
|
VMM.fireEvent(global, "DATAREADY");
|
||
|
});
|
||
|
};
|
||
|
|
||
|
/* MESSEGES
|
||
|
================================================== */
|
||
13 years ago
|
|
||
|
var showMessege = function(e, msg) {
|
||
13 years ago
|
trace("showMessege " + msg);
|
||
|
VMM.attachElement($messege, msg);
|
||
13 years ago
|
};
|
||
13 years ago
|
|
||
13 years ago
|
var hideMessege = function() {
|
||
13 years ago
|
VMM.Lib.animate($feedback, config.duration, config.ease*4, {"opacity": 0}, detachMessege);
|
||
13 years ago
|
};
|
||
|
|
||
|
var detachMessege = function() {
|
||
13 years ago
|
VMM.Lib.detach($feedback);
|
||
13 years ago
|
}
|
||
|
|
||
|
/* BUILD DISPLAY
|
||
|
================================================== */
|
||
|
var build = function() {
|
||
|
|
||
13 years ago
|
// START AT END?
|
||
|
if (config.start_at_end) {
|
||
|
config.current_slide = _dates.length - 1;
|
||
|
}
|
||
|
// CREATE DOM STRUCTURE
|
||
13 years ago
|
VMM.attachElement($timeline, "");
|
||
|
VMM.appendElement($timeline, "<div class='container main'><div class='feature'><div class='slider'></div></div><div class='navigation'></div></div>");
|
||
|
|
||
|
reSize();
|
||
|
|
||
|
VMM.bindEvent("div.slider", onSliderLoaded, "LOADED");
|
||
|
VMM.bindEvent("div.navigation", onTimeNavLoaded, "LOADED");
|
||
|
VMM.bindEvent("div.slider", onSlideUpdate, "UPDATE");
|
||
|
VMM.bindEvent("div.navigation", onMarkerUpdate, "UPDATE");
|
||
|
|
||
|
slider.init(_dates);
|
||
|
timenav.init(_dates, data.era);
|
||
|
|
||
13 years ago
|
// RESIZE EVENT LISTENERS
|
||
13 years ago
|
VMM.bindEvent(global, reSize, "resize");
|
||
13 years ago
|
//VMM.bindEvent(global, function(e) {e.preventDefault()}, "touchmove");
|
||
13 years ago
|
|
||
|
};
|
||
|
|
||
|
var updateSize = function() {
|
||
13 years ago
|
trace("UPDATE SIZE");
|
||
13 years ago
|
config.width = VMM.Lib.width($timeline);
|
||
|
config.height = VMM.Lib.height($timeline);
|
||
13 years ago
|
|
||
13 years ago
|
config.nav.width = config.width;
|
||
|
config.feature.width = config.width;
|
||
13 years ago
|
|
||
|
if (VMM.Browser.device == "mobile") {
|
||
13 years ago
|
//config.feature.height = config.height;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
//config.feature.height = config.height - config.nav.height - 3;
|
||
13 years ago
|
}
|
||
13 years ago
|
config.feature.height = config.height - config.nav.height - 3;
|
||
13 years ago
|
};
|
||
|
|
||
|
// BUILD DATE OBJECTS
|
||
|
var buildDates = function() {
|
||
|
|
||
|
updateSize();
|
||
13 years ago
|
|
||
|
VMM.fireEvent(global, "MESSEGE", "Building Dates");
|
||
13 years ago
|
|
||
|
for(var i = 0; i < data.date.length; i++) {
|
||
|
|
||
|
if (data.date[i].startDate != null && data.date[i].startDate != "") {
|
||
|
|
||
|
var _date = {};
|
||
|
|
||
13 years ago
|
// START DATE
|
||
13 years ago
|
if (data.date[i].type == "tweets") {
|
||
|
_date.startdate = VMM.ExternalAPI.twitter.parseTwitterDate(data.date[i].startDate);
|
||
|
} else {
|
||
13 years ago
|
_date.startdate = VMM.Util.date.parse(data.date[i].startDate);
|
||
13 years ago
|
}
|
||
|
|
||
|
_date.uniqueid = (data.date[i].startDate).toString() + "-" + i.toString();
|
||
|
|
||
|
// END DATE
|
||
|
if (data.date[i].endDate != null && data.date[i].endDate != "") {
|
||
|
if (data.date[i].type == "tweets") {
|
||
|
_date.enddate = VMM.ExternalAPI.twitter.parseTwitterDate(data.date[i].endDate);
|
||
|
} else {
|
||
13 years ago
|
_date.enddate = VMM.Util.date.parse(data.date[i].endDate);
|
||
13 years ago
|
}
|
||
|
} else {
|
||
|
_date.enddate = _date.startdate;
|
||
|
}
|
||
|
|
||
13 years ago
|
_date.title = data.date[i].headline;
|
||
|
_date.headline = data.date[i].headline;
|
||
|
_date.type = data.date[i].type;
|
||
|
_date.date = VMM.Util.date.prettyDate(_date.startdate);
|
||
|
_date.asset = data.date[i].asset;
|
||
|
_date.fulldate = _date.startdate.getTime();
|
||
|
_date.text = data.date[i].text;
|
||
|
_date.content = "";
|
||
13 years ago
|
|
||
13 years ago
|
_dates.push(_date);
|
||
13 years ago
|
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
/* CUSTOM SORT
|
||
|
================================================== */
|
||
|
_dates.sort(function(a, b){
|
||
|
return a.fulldate - b.fulldate
|
||
|
});
|
||
13 years ago
|
|
||
|
/* CREATE START PAGE IF AVAILABLE
|
||
|
================================================== */
|
||
|
if (data.headline != null && data.headline != "" && data.text != null && data.text != "") {
|
||
|
trace("HAS STARTPAGE");
|
||
13 years ago
|
var _date = {};
|
||
|
var td_num = 0;
|
||
|
var td = _dates[0].startdate;
|
||
13 years ago
|
_date.startdate = _dates[0].startdate;
|
||
|
trace(_dates[0].startdate);
|
||
|
trace(_date.startdate);
|
||
13 years ago
|
|
||
|
if (td.getMonth() === 0 && td.getDate() == 1 && td.getHours() === 0 && td.getMinutes() === 0 ) {
|
||
|
// trace("YEAR ONLY");
|
||
|
_date.startdate.setFullYear(td.getFullYear() - 1);
|
||
|
} else if (td.getDate() <= 1 && td.getHours() === 0 && td.getMinutes() === 0) {
|
||
|
// trace("YEAR MONTH");
|
||
|
_date.startdate.setMonth(td.getMonth() - 1);
|
||
|
} else if (td.getHours() === 0 && td.getMinutes() === 0) {
|
||
|
// trace("YEAR MONTH DAY");
|
||
|
_date.startdate.setDate(td.getDate() - 1);
|
||
|
} else if (td.getMinutes() === 0) {
|
||
|
// trace("YEAR MONTH DAY HOUR");
|
||
|
_date.startdate.setHours(td.getHours() - 1);
|
||
|
} else {
|
||
|
// trace("YEAR MONTH DAY HOUR MINUTE");
|
||
|
_date.startdate.setMinutes(td.getMinutes() - 1);
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
_date.uniqueid = VMM.Util.unique_ID(5);
|
||
|
_date.enddate = _date.startdate;
|
||
|
_date.title = data.headline;
|
||
|
_date.headline = data.headline;
|
||
|
_date.text = data.text;
|
||
|
_date.type = "start";
|
||
|
_date.date = VMM.Util.date.prettyDate(data.startDate);
|
||
|
_date.asset = data.asset;
|
||
|
_date.fulldate = _date.startdate.getTime();
|
||
|
|
||
|
_dates.push(_date);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
/* CUSTOM SORT
|
||
|
================================================== */
|
||
|
_dates.sort(function(a, b){
|
||
|
return a.fulldate - b.fulldate
|
||
|
});
|
||
|
|
||
13 years ago
|
onDatesProcessed();
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
13 years ago
|
VMM.Timeline.Config = {};
|
||
|
|
||
|
};
|
||
|
|
||
|
/***********************************************
|
||
|
Begin VMM.Timeline.TimeNav.js
|
||
|
***********************************************/
|
||
|
|
||
|
/* TIMELINE NAVIGATION
|
||
|
================================================== */
|
||
13 years ago
|
|
||
13 years ago
|
if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.TimeNav == 'undefined') {
|
||
|
|
||
13 years ago
|
VMM.Timeline.TimeNav = function(parent, content_width, content_height) {
|
||
|
trace("VMM.Timeline.TimeNav");
|
||
|
|
||
13 years ago
|
var events = {}, timespan = {}, layout = parent;
|
||
13 years ago
|
var data = [], era_markers = [], markers = [], interval_array = [], interval_major_array = [], eras, content;
|
||
13 years ago
|
|
||
|
var current_marker = 0;
|
||
|
var _active = false;
|
||
|
var timelookup = {day: 24, month: 12, year: 10, hour: 60, minute: 60, second: 1000, decade: 10, century: 100, millenium: 1000, age: 1000000, epoch: 10000000, era: 100000000, eon: 500000000, week: 4.34812141, days_in_month: 30.4368499, days_in_week: 7, weeks_in_month:4.34812141, weeks_in_year:52.177457, days_in_year: 365.242199, hours_in_day: 24 };
|
||
|
var dateFractionBrowser = {day: 86400000, week: 7, month: 30.4166666667, year: 12, hour: 24, minute: 1440, second: 86400, decade: 10, century: 100, millenium: 1000, age: 1000000, epoch: 10000000, era: 100000000, eon: 500000000 };
|
||
|
|
||
|
var interval = {type: "year", number: 10, first: 1970, last: 2011, multiplier: 100, classname:"_idd", interval_type:"interval"};
|
||
|
var interval_major = {type: "year", number: 10, first: 1970, last: 2011, multiplier: 100, classname:"major", interval_type:"interval major"};
|
||
|
var interval_macro = {type: "year", number: 10, first: 1970, last: 2011, multiplier: 100, classname:"_dd_minor", interval_type:"interval minor"};
|
||
|
var interval_calc = {day: {},month: {},year: {},hour: {},minute: {}, second: {},decade: {},century: {},millenium: {},week: {}, age: {}, epoch: {}, era: {}, eon: {} };
|
||
13 years ago
|
|
||
13 years ago
|
/* ELEMENTS
|
||
|
================================================== */
|
||
13 years ago
|
var $timenav, $content, $time, $timeintervalminor, $timeinterval, $timeintervalmajor, $timebackground,
|
||
|
$timeintervalbackground, $timenavline, $timeintervalminor_minor, $toolbar, $zoomin, $zoomout;
|
||
13 years ago
|
|
||
13 years ago
|
/* ADD to Config
|
||
|
================================================== */
|
||
13 years ago
|
var config = VMM.Timeline.Config;
|
||
|
config.nav.rows = [config.nav.marker.height, config.nav.marker.height*2, 1];
|
||
13 years ago
|
|
||
|
if (content_width != null && content_width != "") {
|
||
13 years ago
|
config.nav.width = content_width;
|
||
13 years ago
|
}
|
||
|
if (content_height != null && content_height != "") {
|
||
13 years ago
|
config.nav.height = content_height;
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
/*
|
||
|
config.nav.density = 2;
|
||
|
config.nav.multiplier = {
|
||
|
current: 6,
|
||
|
min: .1,
|
||
|
max: 50
|
||
|
};
|
||
|
*/
|
||
13 years ago
|
|
||
13 years ago
|
/* INIT
|
||
13 years ago
|
================================================== */
|
||
|
this.init = function(d,e) {
|
||
|
trace('VMM.Timeline.TimeNav init');
|
||
|
// need to evaluate d
|
||
|
// some function to determine type of data and prepare it
|
||
|
if(typeof d != 'undefined') {
|
||
|
this.setData(d, e);
|
||
|
} else {
|
||
|
trace("WAITING ON DATA");
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/* GETTERS AND SETTERS
|
||
|
================================================== */
|
||
|
this.setData = function(d,e) {
|
||
|
if(typeof d != 'undefined') {
|
||
13 years ago
|
data = {};
|
||
13 years ago
|
data = d;
|
||
|
eras = e;
|
||
|
build();
|
||
|
} else{
|
||
|
trace("NO DATA");
|
||
|
}
|
||
|
};
|
||
|
|
||
|
this.setSize = function(w, h) {
|
||
|
if (w != null) {config.width = w};
|
||
|
if (h != null) {config.height = h};
|
||
|
if (_active) {
|
||
|
reSize();
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
this.setMarker = function(n, ease, duration, fast) {
|
||
|
goToMarker(n, ease, duration);
|
||
|
}
|
||
|
|
||
|
this.getCurrentNumber = function() {
|
||
|
return current_marker;
|
||
|
}
|
||
|
|
||
|
/* ON EVENT
|
||
|
================================================== */
|
||
|
|
||
|
function onConfigSet() {
|
||
|
trace("onConfigSet");
|
||
|
};
|
||
|
|
||
|
function reSize(firstrun) {
|
||
13 years ago
|
VMM.Lib.css($timenavline, "left", Math.round(config.width/2)+2);
|
||
13 years ago
|
goToMarker(config.current_slide, config.ease, config.duration, true, firstrun);
|
||
13 years ago
|
};
|
||
|
|
||
|
function upDate() {
|
||
|
VMM.fireEvent(layout, "UPDATE");
|
||
|
}
|
||
|
|
||
|
function onZoomIn() {
|
||
|
VMM.DragSlider.cancelSlide();
|
||
13 years ago
|
if (config.nav.multiplier.current > config.nav.multiplier.min) {
|
||
|
if (config.nav.multiplier.current <= 1) {
|
||
|
config.nav.multiplier.current = config.nav.multiplier.current - .25;
|
||
13 years ago
|
} else {
|
||
13 years ago
|
if (config.nav.multiplier.current > 5) {
|
||
|
if (config.nav.multiplier.current > 16) {
|
||
|
config.nav.multiplier.current = Math.round(config.nav.multiplier.current - 10);
|
||
13 years ago
|
} else {
|
||
13 years ago
|
config.nav.multiplier.current = Math.round(config.nav.multiplier.current - 4);
|
||
13 years ago
|
}
|
||
13 years ago
|
} else {
|
||
13 years ago
|
config.nav.multiplier.current = Math.round(config.nav.multiplier.current - 1);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
}
|
||
13 years ago
|
if (config.nav.multiplier.current <= 0) {
|
||
|
config.nav.multiplier.current = config.nav.multiplier.min;
|
||
13 years ago
|
}
|
||
|
refreshTimeline();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function onZoomOut() {
|
||
|
VMM.DragSlider.cancelSlide();
|
||
13 years ago
|
if (config.nav.multiplier.current < config.nav.multiplier.max) {
|
||
|
if (config.nav.multiplier.current > 4) {
|
||
|
if (config.nav.multiplier.current > 16) {
|
||
|
config.nav.multiplier.current = Math.round(config.nav.multiplier.current + 10);
|
||
13 years ago
|
} else {
|
||
13 years ago
|
config.nav.multiplier.current = Math.round(config.nav.multiplier.current + 4);
|
||
13 years ago
|
}
|
||
13 years ago
|
} else {
|
||
13 years ago
|
config.nav.multiplier.current = Math.round(config.nav.multiplier.current + 1);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
if (config.nav.multiplier.current >= config.nav.multiplier.max) {
|
||
|
config.nav.multiplier.current = config.nav.multiplier.max;
|
||
13 years ago
|
}
|
||
|
refreshTimeline();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function onBackHome(e) {
|
||
|
VMM.DragSlider.cancelSlide();
|
||
|
goToMarker(0);
|
||
|
upDate();
|
||
|
}
|
||
13 years ago
|
|
||
|
var refreshTimeline = function() {
|
||
|
trace("config.nav.multiplier " + config.nav.multiplier.current);
|
||
|
positionMarkers(true);
|
||
|
positionInterval(interval_array, true, true);
|
||
|
positionInterval(interval_major_array, true);
|
||
|
};
|
||
|
|
||
13 years ago
|
/* MARKER EVENTS
|
||
|
================================================== */
|
||
|
function onMarkerClick(e) {
|
||
|
VMM.DragSlider.cancelSlide();
|
||
|
goToMarker(e.data.number);
|
||
|
upDate();
|
||
|
};
|
||
|
|
||
|
function onMarkerHover(e) {
|
||
13 years ago
|
VMM.Lib.toggleClass(e.data.elem, "zFront");
|
||
13 years ago
|
};
|
||
|
|
||
13 years ago
|
var goToMarker = function(n, ease, duration, fast, firstrun) {
|
||
|
|
||
|
current_marker = n;
|
||
|
var _ease = config.ease;
|
||
|
var _duration = config.duration;
|
||
|
var is_last = false;
|
||
|
var is_first = false;
|
||
13 years ago
|
var _pos = VMM.Lib.position(markers[current_marker].marker);
|
||
13 years ago
|
|
||
|
if (current_marker == 0) {
|
||
|
is_first = true;
|
||
|
}
|
||
|
if (current_marker +1 == markers.length) {
|
||
|
is_last = true
|
||
|
}
|
||
|
if (ease != null && ease != "") {_ease = ease};
|
||
|
if (duration != null && duration != "") {_duration = duration};
|
||
|
|
||
|
// set marker style
|
||
|
for(var i = 0; i < markers.length; i++) {
|
||
13 years ago
|
VMM.Lib.removeClass(markers[i].marker, "active");
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
if (config.start_page && markers[0].type == "start") {
|
||
13 years ago
|
VMM.Lib.visible(markers[0].marker, false);
|
||
|
VMM.Lib.addClass(markers[0].marker, "start");
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
VMM.Lib.addClass(markers[current_marker].marker, "active");
|
||
13 years ago
|
|
||
|
// ANIMATE MARKER
|
||
13 years ago
|
VMM.Lib.stop($timenav);
|
||
|
VMM.Lib.animate($timenav, _duration, _ease, {"left": (config.width/2) - (_pos.left)});
|
||
13 years ago
|
|
||
|
}
|
||
|
|
||
13 years ago
|
/* TOUCH EVENTS
|
||
|
================================================== */
|
||
|
function onTouchUpdate(e, b) {
|
||
13 years ago
|
VMM.Lib.animate($timenav, b.time/2, config.ease, {"left": b.left});
|
||
13 years ago
|
};
|
||
|
|
||
13 years ago
|
/* CALCULATIONS
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
var averageMarkerPositionDistance = function() {
|
||
|
var last_pos = 0;
|
||
|
var pos = 0;
|
||
|
var pos_dif = 0;
|
||
|
var mp_diff = [];
|
||
13 years ago
|
|
||
13 years ago
|
for(var i = 0; i < markers.length; i++) {
|
||
|
if (data[i].type == "start") {
|
||
|
|
||
|
} else {
|
||
|
var _pos = positionOnTimeline(interval, data[i].startdate, data[i].enddate);
|
||
|
last_pos = pos;
|
||
|
pos = _pos.begin;
|
||
|
pos_dif = pos - last_pos;
|
||
|
mp_diff.push(pos_dif);
|
||
|
}
|
||
|
}
|
||
|
return VMM.Util.average(mp_diff).mean;
|
||
|
}
|
||
|
|
||
|
var averageDateDistance = function() {
|
||
|
var last_dd = 0;
|
||
|
var dd = 0;
|
||
|
var date_dif = 0;
|
||
|
var date_diffs = [];
|
||
|
var is_first_date = true;
|
||
13 years ago
|
|
||
|
for(var i = 0; i < data.length; i++) {
|
||
|
if (data[i].type == "start") {
|
||
13 years ago
|
trace("DATA DATE IS START")
|
||
|
} else {
|
||
|
var _dd = data[i].startdate;
|
||
|
last_dd = dd;
|
||
|
dd = _dd;
|
||
|
date_dif = dd - last_dd;
|
||
|
|
||
|
date_diffs.push(date_dif);
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
return VMM.Util.average(date_diffs);
|
||
|
}
|
||
|
|
||
|
var calculateMultiplier = function() {
|
||
|
var temp_multiplier = config.nav.multiplier.current;
|
||
|
for(var i = 0; i < temp_multiplier; i++) {
|
||
|
if (averageMarkerPositionDistance() < 75) {
|
||
|
if (config.nav.multiplier.current > 1) {
|
||
|
config.nav.multiplier.current = config.nav.multiplier.current - 1;
|
||
|
}
|
||
|
}
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
var calculateInterval = function() {
|
||
13 years ago
|
// NEED TO REWRITE ALL OF THIS
|
||
|
var _first = getDateFractions(data[0].startdate);
|
||
|
var _last = getDateFractions(data[data.length - 1].enddate);
|
||
|
|
||
|
// EON
|
||
|
interval_calc.eon.type = "eon";
|
||
|
interval_calc.eon.first = _first.eons;
|
||
|
interval_calc.eon.base = Math.floor(_first.eons);
|
||
|
interval_calc.eon.last = _last.eons;
|
||
|
interval_calc.eon.number = timespan.eons;
|
||
|
interval_calc.eon.multiplier = timelookup.eons;
|
||
|
interval_calc.eon.minor = timelookup.eons;
|
||
|
|
||
|
// ERA
|
||
|
interval_calc.era.type = "era";
|
||
|
interval_calc.era.first = _first.eras;
|
||
|
interval_calc.era.base = Math.floor(_first.eras);
|
||
|
interval_calc.era.last = _last.eras;
|
||
|
interval_calc.era.number = timespan.eras;
|
||
|
interval_calc.era.multiplier = timelookup.eras;
|
||
|
interval_calc.era.minor = timelookup.eras;
|
||
|
|
||
|
// EPOCH
|
||
|
interval_calc.epoch.type = "epoch";
|
||
|
interval_calc.epoch.first = _first.epochs;
|
||
|
interval_calc.epoch.base = Math.floor(_first.epochs);
|
||
|
interval_calc.epoch.last = _last.epochs;
|
||
|
interval_calc.epoch.number = timespan.epochs;
|
||
|
interval_calc.epoch.multiplier = timelookup.epochs;
|
||
|
interval_calc.epoch.minor = timelookup.epochs;
|
||
|
|
||
|
// AGE
|
||
|
interval_calc.age.type = "age";
|
||
|
interval_calc.age.first = _first.ages;
|
||
|
interval_calc.age.base = Math.floor(_first.ages);
|
||
|
interval_calc.age.last = _last.ages;
|
||
|
interval_calc.age.number = timespan.ages;
|
||
|
interval_calc.age.multiplier = timelookup.ages;
|
||
|
interval_calc.age.minor = timelookup.ages;
|
||
|
|
||
|
// MILLENIUM
|
||
|
interval_calc.millenium.type = "millenium";
|
||
|
interval_calc.millenium.first = _first.milleniums;
|
||
|
interval_calc.millenium.base = Math.floor(_first.milleniums);
|
||
|
interval_calc.millenium.last = _last.milleniums;
|
||
|
interval_calc.millenium.number = timespan.milleniums;
|
||
|
interval_calc.millenium.multiplier = timelookup.millenium;
|
||
|
interval_calc.millenium.minor = timelookup.millenium;
|
||
|
|
||
|
// CENTURY
|
||
13 years ago
|
interval_calc.century.type = "century";
|
||
|
interval_calc.century.first = _first.centuries;
|
||
|
interval_calc.century.base = Math.floor(_first.centuries);
|
||
|
interval_calc.century.last = _last.centuries;
|
||
|
interval_calc.century.number = timespan.centuries;
|
||
|
interval_calc.century.multiplier = timelookup.century;
|
||
|
interval_calc.century.minor = timelookup.century;
|
||
13 years ago
|
|
||
13 years ago
|
// DECADE
|
||
13 years ago
|
interval_calc.decade.type = "decade";
|
||
|
interval_calc.decade.first = _first.decades;
|
||
|
interval_calc.decade.base = Math.floor(_first.decades);
|
||
|
interval_calc.decade.last = _last.decades;
|
||
|
interval_calc.decade.number = timespan.decades;
|
||
|
interval_calc.decade.multiplier = timelookup.decade;
|
||
|
interval_calc.decade.minor = timelookup.decade;
|
||
13 years ago
|
|
||
13 years ago
|
// YEAR
|
||
13 years ago
|
interval_calc.year.type = "year";
|
||
|
interval_calc.year.first = _first.years;
|
||
|
interval_calc.year.base = Math.floor(_first.years);
|
||
|
interval_calc.year.last = _last.years;
|
||
|
interval_calc.year.number = timespan.years;
|
||
|
interval_calc.year.multiplier = 1;
|
||
|
interval_calc.year.minor = timelookup.month;
|
||
|
|
||
13 years ago
|
// MONTH
|
||
13 years ago
|
interval_calc.month.type = "month";
|
||
|
interval_calc.month.first = _first.months;
|
||
|
interval_calc.month.base = Math.floor(_first.months);
|
||
|
interval_calc.month.last = _last.months;
|
||
|
interval_calc.month.number = timespan.months;
|
||
|
interval_calc.month.multiplier = 1;
|
||
|
interval_calc.month.minor = Math.round(timelookup.week);
|
||
|
|
||
13 years ago
|
// WEEK
|
||
13 years ago
|
// NOT DONE
|
||
|
interval_calc.week.type = "week";
|
||
|
interval_calc.week.first = _first.weeks;
|
||
|
interval_calc.week.base = Math.floor(_first.weeks);
|
||
|
interval_calc.week.last = _last.weeks;
|
||
|
interval_calc.week.number = timespan.weeks;
|
||
|
interval_calc.week.multiplier = 1;
|
||
|
interval_calc.week.minor = 7;
|
||
|
|
||
13 years ago
|
// DAY
|
||
13 years ago
|
interval_calc.day.type = "day";
|
||
|
interval_calc.day.first = _first.days;
|
||
|
interval_calc.day.base = Math.floor(_first.days);
|
||
|
interval_calc.day.last = _last.days;
|
||
|
interval_calc.day.number = timespan.days;
|
||
|
interval_calc.day.multiplier = 1;
|
||
|
interval_calc.day.minor = 24;
|
||
|
|
||
13 years ago
|
// HOUR
|
||
13 years ago
|
interval_calc.hour.type = "hour";
|
||
|
interval_calc.hour.first = _first.hours;
|
||
|
interval_calc.hour.base = Math.floor(_first.hours);
|
||
|
interval_calc.hour.last = _last.hours;
|
||
|
interval_calc.hour.number = timespan.hours;
|
||
|
interval_calc.hour.multiplier = 1;
|
||
|
interval_calc.hour.minor = 60;
|
||
|
|
||
13 years ago
|
// MINUTE
|
||
13 years ago
|
interval_calc.minute.type = "minute";
|
||
|
interval_calc.minute.first = _first.minutes;
|
||
|
interval_calc.minute.base = Math.floor(_first.minutes);
|
||
|
interval_calc.minute.last = _last.minutes;
|
||
|
interval_calc.minute.number = timespan.minutes;
|
||
|
interval_calc.minute.multiplier = 1;
|
||
|
interval_calc.minute.minor = 60;
|
||
|
|
||
13 years ago
|
// SECOND
|
||
13 years ago
|
interval_calc.second.type = "decade";
|
||
|
interval_calc.second.first = _first.seconds;
|
||
|
interval_calc.second.base = Math.floor(_first.seconds);
|
||
|
interval_calc.second.last = _last.seconds;
|
||
|
interval_calc.second.number = timespan.seconds;
|
||
|
interval_calc.second.multiplier = 1;
|
||
|
interval_calc.second.minor = 10;
|
||
|
}
|
||
|
|
||
|
var getDateFractions = function(the_date, is_utc) {
|
||
|
|
||
|
var _time = {};
|
||
13 years ago
|
_time.days = the_date / dateFractionBrowser.day;
|
||
|
_time.weeks = _time.days / dateFractionBrowser.week;
|
||
|
_time.months = _time.days / dateFractionBrowser.month;
|
||
|
_time.years = _time.months / dateFractionBrowser.year;
|
||
|
_time.hours = _time.days * dateFractionBrowser.hour;
|
||
|
_time.minutes = _time.days * dateFractionBrowser.minute;
|
||
|
_time.seconds = _time.days * dateFractionBrowser.second;
|
||
|
_time.decades = _time.years / dateFractionBrowser.decade;
|
||
|
_time.centuries = _time.years / dateFractionBrowser.century;
|
||
|
_time.milleniums = _time.years / dateFractionBrowser.millenium;
|
||
|
_time.ages = _time.years / dateFractionBrowser.age;
|
||
|
_time.epochs = _time.years / dateFractionBrowser.epoch;
|
||
|
_time.eras = _time.years / dateFractionBrowser.era;
|
||
|
_time.eons = _time.years / dateFractionBrowser.eon;
|
||
|
|
||
13 years ago
|
/*
|
||
13 years ago
|
trace("AGES " + _time.ages);
|
||
|
trace("EPOCHS " + _time.epochs);
|
||
|
trace("MILLENIUMS " + _time.milleniums);
|
||
13 years ago
|
trace("CENTURIES " + _time.centuries);
|
||
|
trace("DECADES " + _time.decades);
|
||
|
trace("YEARS " + _time.years);
|
||
|
trace("MONTHS " + _time.months);
|
||
|
trace("WEEKS " + _time.weeks);
|
||
|
trace("DAYS " + _time.days);
|
||
|
trace("HOURS " + _time.hours);
|
||
|
trace("MINUTES " + _time.minutes);
|
||
|
trace("SECONDS " + _time.seconds);
|
||
|
*/
|
||
|
return _time;
|
||
|
}
|
||
|
|
||
|
/* POSITION
|
||
|
================================================== */
|
||
|
var positionOnTimeline = function(the_interval, first, last) {
|
||
|
|
||
|
var _type = the_interval.type;
|
||
|
var _multiplier = the_interval.multiplier;
|
||
|
|
||
|
var _first = getDateFractions(first);
|
||
|
var _last;
|
||
|
|
||
|
var tsd;
|
||
|
var ted;
|
||
|
/* CALCULATE POSITION ON TIMELINE
|
||
|
================================================== */
|
||
|
tsd = first.months;
|
||
|
|
||
|
if (type.of(last) == "date") {
|
||
|
|
||
|
/* LAST
|
||
|
================================================== */
|
||
|
_last = getDateFractions(last);
|
||
|
ted = last.months;
|
||
|
|
||
13 years ago
|
if (_type == "eon") {
|
||
|
tsd = _first.eons;
|
||
|
ted = _last.eons;
|
||
|
} else if (_type == "era") {
|
||
|
tsd = _first.eras;
|
||
|
ted = _last.eras;
|
||
|
} else if (_type == "epoch") {
|
||
|
tsd = _first.epochs;
|
||
|
ted = _last.epochs;
|
||
|
} else if (_type == "age") {
|
||
|
tsd = _first.ages;
|
||
|
ted = _last.ages;
|
||
|
} else if (_type == "millenium") {
|
||
13 years ago
|
tsd = first.milleniums;
|
||
|
ted = last.milleniums;
|
||
|
} else if (_type == "century") {
|
||
|
tsd = _first.centuries;
|
||
|
ted = _last.centuries;
|
||
|
} else if (_type == "decade") {
|
||
|
tsd = _first.decades;
|
||
|
ted = _last.decades;
|
||
|
} else if (_type == "year") {
|
||
|
tsd = _first.years;
|
||
13 years ago
|
ted = _last.years;
|
||
|
} else if (_type == "month") {
|
||
|
tsd = _first.months;
|
||
|
ted = _last.months;
|
||
|
} else if (_type == "week") {
|
||
|
tsd = _first.weeks;
|
||
|
ted = _last.weeks;
|
||
|
} else if (_type == "day") {
|
||
|
tsd = _first.days;
|
||
|
ted = _last.days;
|
||
|
} else if (_type == "hour") {
|
||
|
tsd = _first.hours;
|
||
|
ted = _last.hours;
|
||
|
} else if (_type == "minute") {
|
||
|
tsd = _first.minutes;
|
||
|
ted = _last.minutes;
|
||
|
}
|
||
|
|
||
13 years ago
|
_pos = ( tsd - interval.base ) * (config.nav.interval_width / config.nav.multiplier.current);
|
||
|
_pos_end = ( ted - interval.base ) * (config.nav.interval_width / config.nav.multiplier.current);
|
||
13 years ago
|
|
||
|
} else {
|
||
13 years ago
|
if (_type == "eon") {
|
||
|
tsd = _first.eons;
|
||
|
ted = _first.eons;
|
||
|
} else if (_type == "era") {
|
||
|
tsd = _first.eras;
|
||
|
ted = _first.eras;
|
||
|
} else if (_type == "epoch") {
|
||
|
tsd = _first.epochs;
|
||
|
ted = _first.epochs;
|
||
|
} else if (_type == "age") {
|
||
|
tsd = _first.ages;
|
||
|
ted = _first.ages;
|
||
|
} else if (_type == "millenium") {
|
||
13 years ago
|
tsd = first.milleniums;
|
||
|
ted = first.milleniums;
|
||
|
} else if (_type == "century") {
|
||
|
tsd = _first.centuries;
|
||
|
ted = _first.centuries;
|
||
|
} else if (_type == "decade") {
|
||
|
tsd = _first.decades;
|
||
|
ted = _first.decades;
|
||
|
} else if (_type == "year") {
|
||
|
tsd = _first.years;
|
||
|
ted = _first.years;
|
||
|
} else if (_type == "month") {
|
||
|
tsd = _first.months;
|
||
|
ted = _first.months;
|
||
|
} else if (_type == "week") {
|
||
|
tsd = _first.weeks;
|
||
|
ted = _first.weeks;
|
||
|
} else if (_type == "day") {
|
||
|
tsd = _first.days;
|
||
|
ted = _first.days;
|
||
|
} else if (_type == "hour") {
|
||
|
tsd = _first.hours;
|
||
|
ted = _first.hours;
|
||
|
} else if (_type == "minute") {
|
||
|
tsd = _first.minutes;
|
||
|
ted = _first.minutes;
|
||
|
}
|
||
|
|
||
13 years ago
|
_pos = ( tsd - interval.base ) * (config.nav.interval_width / config.nav.multiplier.current);
|
||
13 years ago
|
_pos_end = _pos;
|
||
|
|
||
|
}
|
||
|
|
||
13 years ago
|
return pos = {begin:_pos ,end:_pos_end};
|
||
|
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
var positionMarkers = function(is_animated) {
|
||
|
|
||
|
var _type = interval.type;
|
||
|
var _multiplier = interval.multiplier;
|
||
|
|
||
|
// ROWS
|
||
13 years ago
|
var row = 2; //row
|
||
|
var lpos = 0; // last marker pos;
|
||
|
var row_depth = 0;
|
||
|
var _line_last_height_pos = 150;
|
||
|
var _line_height = 6;
|
||
|
var cur_mark = 0;
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.removeClass(".flag", "row1");
|
||
|
VMM.Lib.removeClass(".flag", "row2");
|
||
|
VMM.Lib.removeClass(".flag", "row3");
|
||
13 years ago
|
|
||
|
for(var i = 0; i < markers.length; i++) {
|
||
|
|
||
|
var _line; // EVENT LENGTH
|
||
13 years ago
|
var _marker = markers[i].marker;
|
||
|
var _marker_flag = markers[i].flag;
|
||
|
var _marker_line_event = markers[i].lineevent;
|
||
|
var _pos = positionOnTimeline(interval, data[i].startdate, data[i].enddate);
|
||
|
var _pos_offset = -2;
|
||
13 years ago
|
|
||
13 years ago
|
pos = _pos.begin;
|
||
|
_pos_end = _pos.end;
|
||
13 years ago
|
|
||
13 years ago
|
// COMPENSATE FOR DATES BEING POITIONED IN THE MIDDLE
|
||
|
pos = Math.round(pos + _pos_offset);
|
||
|
_pos_end = Math.round(_pos_end + _pos_offset);
|
||
|
_line = Math.round(_pos_end - pos);
|
||
13 years ago
|
|
||
13 years ago
|
// APPLY POSITION TO MARKER
|
||
13 years ago
|
if (is_animated) {
|
||
13 years ago
|
VMM.Lib.stop(_marker);
|
||
|
VMM.Lib.animate(_marker, config.duration/2, config.ease, {"left": pos});
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.Lib.css(_marker, "left", pos);
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
if (i == current_marker) {
|
||
|
cur_mark = pos;
|
||
|
}
|
||
|
|
||
13 years ago
|
// EVENT LENGTH LINE
|
||
13 years ago
|
if (_line > 5) {
|
||
13 years ago
|
VMM.Lib.css(_marker_line_event, "height", _line_height);
|
||
|
VMM.Lib.css(_marker_line_event, "width", _line);
|
||
|
VMM.Lib.css(_marker_line_event, "top", _line_last_height_pos);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
// CONTROL ROW POSITION
|
||
|
if (pos - lpos < (config.nav.marker.width + config.spacing)) {
|
||
|
if (row < config.nav.rows.length - 1) {
|
||
13 years ago
|
row ++;
|
||
|
|
||
|
} else {
|
||
|
row = 0;
|
||
|
row_depth ++;
|
||
|
}
|
||
|
} else {
|
||
|
row_depth = 0;
|
||
|
row = 0;
|
||
|
}
|
||
|
|
||
13 years ago
|
// SET LAST MARKER POSITION
|
||
13 years ago
|
lpos = pos;
|
||
|
|
||
|
if (is_animated) {
|
||
13 years ago
|
VMM.Lib.stop(_marker_flag);
|
||
|
VMM.Lib.animate(_marker_flag, config.duration, config.ease, {"top": config.nav.rows[row]});
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.Lib.css(_marker_flag, "top", config.nav.rows[row]);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
// IS THE MARKER A REPRESENTATION OF A START SCREEN?
|
||
|
if (config.start_page && markers[i].type == "start") {
|
||
13 years ago
|
VMM.Lib.visible(_marker, false);
|
||
13 years ago
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
for(var j = 0; j < era_markers.length; j++) {
|
||
13 years ago
|
var _line;
|
||
|
var era = era_markers[j];
|
||
|
var era_elem = era.content;
|
||
|
var pos = positionOnTimeline(interval, era.startdate, era.enddate);
|
||
|
var era_length = pos.end - pos.begin;
|
||
|
var era_height = 25;
|
||
|
|
||
|
// APPLY POSITION TO MARKER
|
||
13 years ago
|
VMM.Lib.css(era_elem, "left", pos.begin);
|
||
|
VMM.Lib.css(era_elem, "width", era_length);
|
||
13 years ago
|
}
|
||
|
|
||
|
|
||
13 years ago
|
// ANIMATE THE TIMELINE TO ADJUST TO CHANGES
|
||
13 years ago
|
VMM.Lib.stop($timenav);
|
||
|
VMM.Lib.animate($timenav, config.duration/2, config.ease, {"left": (config.width/2) - (cur_mark)});
|
||
13 years ago
|
|
||
|
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
var positionInterval = function(the_intervals, is_animated, is_minor) {
|
||
13 years ago
|
|
||
|
var _type = interval.type;
|
||
|
var _multiplier = interval.multiplier;
|
||
|
var last_position = 0;
|
||
|
var last_position_major = 0;
|
||
|
|
||
|
for(var i = 0; i < the_intervals.length; i++) {
|
||
|
var _interval = the_intervals[i].interval_element;
|
||
|
var _interval_date = the_intervals[i].interval_date;
|
||
|
var _interval_visible = the_intervals[i].interval_visible;
|
||
|
var _pos = positionOnTimeline(interval, _interval_date);
|
||
|
var pos = _pos.begin;
|
||
13 years ago
|
var is_visible = true;
|
||
|
var pos_offset = 50;
|
||
13 years ago
|
|
||
13 years ago
|
// APPLY POSITION TO MARKER
|
||
13 years ago
|
if (is_animated) {
|
||
13 years ago
|
VMM.Lib.animate(_interval, config.duration/2, config.ease, {"left": pos});
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.Lib.css(_interval, "left", pos);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
// CONDENSE WHAT IS DISPLAYED
|
||
|
if (config.nav.multiplier.current > 16 && is_minor) {
|
||
13 years ago
|
is_visible = false;
|
||
|
} else {
|
||
|
if ((pos - last_position) < 65 ) {
|
||
|
if ((pos - last_position) < 35 ) {
|
||
|
if (i%4 == 0) {
|
||
|
if (pos == 0) {
|
||
|
is_visible = false;
|
||
|
}
|
||
|
} else {
|
||
13 years ago
|
is_visible = false;
|
||
|
}
|
||
|
} else {
|
||
13 years ago
|
if (!VMM.Util.isEven(i)) {
|
||
|
is_visible = false;
|
||
|
}
|
||
13 years ago
|
}
|
||
|
}
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
if (_interval_visible) {
|
||
|
if (!is_visible) {
|
||
13 years ago
|
if (is_animated) {
|
||
13 years ago
|
VMM.Lib.animate(_interval, config.duration*2, config.ease, {"opacity": 0});
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.Lib.css(_interval, "opacity", 0);
|
||
13 years ago
|
}
|
||
13 years ago
|
the_intervals[i].interval_visible = false;
|
||
|
}
|
||
|
} else {
|
||
|
if (is_visible) {
|
||
13 years ago
|
if (is_animated) {
|
||
13 years ago
|
VMM.Lib.animate(_interval, config.duration*2, config.ease, {"opacity": 100});
|
||
13 years ago
|
} else {
|
||
13 years ago
|
VMM.Lib.css(_interval, "opacity", 100);
|
||
13 years ago
|
}
|
||
13 years ago
|
the_intervals[i].interval_visible = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
last_position = pos;
|
||
|
|
||
13 years ago
|
if (pos > config.nav.minor_width) {
|
||
|
config.nav.minor_width = pos;
|
||
|
}
|
||
|
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
VMM.Lib.css($timeintervalminor_minor, "left", -(config.width/2));
|
||
|
VMM.Lib.width($timeintervalminor_minor, (config.nav.minor_width)+(config.width) );
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
var createIntervalElements = function(_interval, _array, _element_parent) {
|
||
13 years ago
|
|
||
|
var inc_time = 0;
|
||
|
var _first_run = true;
|
||
|
var _last_pos = 0;
|
||
13 years ago
|
var _largest_pos = 0;
|
||
13 years ago
|
|
||
13 years ago
|
VMM.attachElement(_element_parent, "");
|
||
|
|
||
|
_interval.date = new Date(data[0].startdate.getFullYear(), 0, 1, 0,0,0);
|
||
|
|
||
|
for(var i = 0; i < Math.ceil(_interval.number) + 1; i++) {
|
||
13 years ago
|
var _idd;
|
||
13 years ago
|
var _pos;
|
||
|
var pos;
|
||
|
var _element = VMM.appendAndGetElement(_element_parent, "<div>", _interval.classname);
|
||
|
var _date;
|
||
|
var _visible = false;
|
||
13 years ago
|
|
||
13 years ago
|
if (_interval.type == "eon") {
|
||
|
if (_first_run) {
|
||
|
_interval.date.setFullYear( Math.floor(data[0].startdate.getFullYear() / 500000000) * 500000000 );
|
||
|
}
|
||
|
_interval.date.setFullYear(_interval.date.getFullYear() + (inc_time * 500000000));
|
||
|
} else if (_interval.type == "era") {
|
||
|
if (_first_run) {
|
||
|
_interval.date.setFullYear( Math.floor(data[0].startdate.getFullYear() / 100000000) * 100000000 );
|
||
|
}
|
||
|
_interval.date.setFullYear(_interval.date.getFullYear() + (inc_time * 100000000));
|
||
|
} else if (_interval.type == "epoch") {
|
||
|
if (_first_run) {
|
||
|
_interval.date.setFullYear( Math.floor(data[0].startdate.getFullYear() / 10000000) * 10000000 );
|
||
|
}
|
||
|
_interval.date.setFullYear(_interval.date.getFullYear() + (inc_time * 10000000));
|
||
|
} else if (_interval.type == "age") {
|
||
|
if (_first_run) {
|
||
|
_interval.date.setFullYear( Math.floor(data[0].startdate.getFullYear() / 1000000) * 1000000 );
|
||
|
}
|
||
|
_interval.date.setFullYear(_interval.date.getFullYear() + (inc_time * 1000000));
|
||
|
} else if (_interval.type == "millenium") {
|
||
13 years ago
|
if (_first_run) {
|
||
|
_interval.date.setFullYear( Math.floor(data[0].startdate.getFullYear() / 1000) * 1000 );
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setFullYear(_interval.date.getFullYear() + (inc_time * 1000));
|
||
13 years ago
|
} else if (_interval.type == "century") {
|
||
13 years ago
|
if (_first_run) {
|
||
13 years ago
|
_interval.date.setFullYear( Math.floor(data[0].startdate.getFullYear() / 100) * 100 );
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setFullYear(_interval.date.getFullYear() + (inc_time * 100));
|
||
|
} else if (_interval.type == "decade") {
|
||
13 years ago
|
if (_first_run) {
|
||
13 years ago
|
_interval.date.setFullYear( Math.floor(data[0].startdate.getFullYear() / 10) * 10 );
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setFullYear(_interval.date.getFullYear() + (inc_time * 10));
|
||
|
} else if (interval.type == "year") {
|
||
13 years ago
|
if (_first_run) {
|
||
13 years ago
|
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setFullYear(_interval.date.getFullYear() + inc_time);
|
||
|
} else if (_interval.type == "month") {
|
||
13 years ago
|
if (_first_run) {
|
||
13 years ago
|
_interval.date.setMonth(data[0].startdate.getMonth());
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setMonth(_interval.date.getMonth() + inc_time);
|
||
|
} else if (_interval.type == "week") {
|
||
13 years ago
|
if (_first_run) {
|
||
13 years ago
|
_interval.date.setMonth( data[0].startdate.getMonth() );
|
||
|
_interval.date.setDate( Math.floor(data[0].startdate.getDate() *7) );
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setDate(_interval.date.getDate() + (inc_time * 7) );
|
||
|
} else if (_interval.type == "day") {
|
||
13 years ago
|
if (_first_run) {
|
||
13 years ago
|
_interval.date.setMonth( data[0].startdate.getMonth() );
|
||
|
_interval.date.setDate( data[0].startdate.getDate() );
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setDate(_interval.date.getDate() + inc_time);
|
||
|
} else if (_interval.type == "hour") {
|
||
13 years ago
|
if (_first_run) {
|
||
13 years ago
|
_interval.date.setMonth( data[0].startdate.getMonth() );
|
||
|
_interval.date.setDate( data[0].startdate.getDate() );
|
||
|
_interval.date.setHours( data[0].startdate.getHours() );
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setHours(_interval.date.getHours() + inc_time);
|
||
|
} else if (_interval.type == "minute") {
|
||
13 years ago
|
if (_first_run) {
|
||
13 years ago
|
_interval.date.setMonth( data[0].startdate.getMonth() );
|
||
|
_interval.date.setDate( data[0].startdate.getDate() );
|
||
|
_interval.date.setHours( data[0].startdate.getHours() );
|
||
|
_interval.date.setMinutes( data[0].startdate.getMinutes() );
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setMinutes(_interval.date.getMinutes() + inc_time);
|
||
|
} else if (_interval.type == "second") {
|
||
13 years ago
|
if (_first_run) {
|
||
13 years ago
|
_interval.date.setMonth( data[0].startdate.getMonth() );
|
||
|
_interval.date.setDate( data[0].startdate.getDate() );
|
||
|
_interval.date.setHours( data[0].startdate.getHours() );
|
||
|
_interval.date.setMinutes( data[0].startdate.getMinutes() );
|
||
|
_interval.date.setSeconds( data[0].startdate.getSeconds() );
|
||
13 years ago
|
}
|
||
13 years ago
|
_interval.date.setSeconds(_interval.date.getSeconds() + inc_time);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
_idd = VMM.Util.date.prettyDate(_interval.date, true);
|
||
13 years ago
|
|
||
13 years ago
|
inc_time = 1;
|
||
13 years ago
|
|
||
13 years ago
|
_first_run = false;
|
||
13 years ago
|
|
||
13 years ago
|
_pos = positionOnTimeline(_interval, _interval.date);
|
||
|
pos = _pos.begin;
|
||
13 years ago
|
|
||
13 years ago
|
VMM.appendElement(_element, _idd);
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.css(_element, "text-indent", -(VMM.Lib.width(_element)/2));
|
||
|
VMM.Lib.css(_element, "opacity", "0");
|
||
13 years ago
|
|
||
|
_last_pos = pos;
|
||
13 years ago
|
|
||
13 years ago
|
if (pos > _largest_pos) {
|
||
|
_largest_pos = pos;
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
_date = new Date(_interval.date);
|
||
13 years ago
|
|
||
13 years ago
|
var _obj = {
|
||
|
interval_element: _element,
|
||
|
interval_date: _date,
|
||
|
interval_visible: _visible,
|
||
|
type: _interval.interval_type
|
||
13 years ago
|
};
|
||
|
|
||
13 years ago
|
_array.push(_obj);
|
||
13 years ago
|
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
VMM.Lib.width($timeintervalminor_minor, _largest_pos);
|
||
13 years ago
|
|
||
13 years ago
|
positionInterval(_array);
|
||
13 years ago
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/* BUILD
|
||
|
================================================== */
|
||
|
var build = function() {
|
||
13 years ago
|
|
||
13 years ago
|
VMM.attachElement(layout, "");
|
||
|
|
||
13 years ago
|
$timenav = VMM.appendAndGetElement(layout, "<div>", "timenav");
|
||
|
$content = VMM.appendAndGetElement($timenav, "<div>", "content");
|
||
|
$time = VMM.appendAndGetElement($timenav, "<div>", "time");
|
||
|
$timeintervalminor = VMM.appendAndGetElement($time, "<div>", "time-interval-minor");
|
||
|
$timeintervalminor_minor = VMM.appendAndGetElement($timeintervalminor, "<div>", "minor");
|
||
|
$timeintervalmajor = VMM.appendAndGetElement($time, "<div>", "time-interval-major");
|
||
|
$timeinterval = VMM.appendAndGetElement($time, "<div>", "time-interval");
|
||
|
$timebackground = VMM.appendAndGetElement(layout, "<div>", "timenav-background");
|
||
|
$timenavline = VMM.appendAndGetElement($timebackground, "<div>", "timenav-line");
|
||
|
$timeintervalbackground = VMM.appendAndGetElement($timebackground, "<div>", "timenav-interval-background", "<div class='top-highlight'></div>");
|
||
|
$toolbar = VMM.appendAndGetElement(layout, "<div>", "toolbar");
|
||
13 years ago
|
|
||
|
buildInterval();
|
||
|
buildMarkers();
|
||
13 years ago
|
calculateMultiplier();
|
||
|
positionMarkers();
|
||
13 years ago
|
positionInterval(interval_array, false, true);
|
||
|
positionInterval(interval_major_array);
|
||
13 years ago
|
//reSize(true);
|
||
13 years ago
|
|
||
13 years ago
|
if (config.start_page) {
|
||
13 years ago
|
$backhome = VMM.appendAndGetElement($toolbar, "<div>", "back-home", "<div class='icon'></div>");
|
||
|
VMM.bindEvent(".back-home", onBackHome, "click");
|
||
13 years ago
|
VMM.Lib.css($toolbar, "top", 27);
|
||
|
VMM.Lib.attribute($backhome, "title", VMM.Timeline.Config.language.messages.return_to_title);
|
||
|
VMM.Lib.attribute($backhome, "rel", "tooltip");
|
||
13 years ago
|
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
$zoomin = VMM.appendAndGetElement($toolbar, "<div>", "zoom-in", "<div class='icon'></div>");
|
||
|
$zoomout = VMM.appendAndGetElement($toolbar, "<div>", "zoom-out", "<div class='icon'></div>");
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Lib.attribute($zoomin, "title", VMM.Timeline.Config.language.messages.expand_timeline);
|
||
|
VMM.Lib.attribute($zoomin, "rel", "tooltip");
|
||
|
VMM.Lib.attribute($zoomout, "title", VMM.Timeline.Config.language.messages.contract_timeline);
|
||
|
VMM.Lib.attribute($zoomout, "rel", "tooltip");
|
||
13 years ago
|
|
||
13 years ago
|
$toolbar.tooltip({selector: "div[rel=tooltip]", placement: "right"})
|
||
|
|
||
|
// MAKE TIMELINE TOUCHABLE
|
||
13 years ago
|
if (VMM.Browser.device == "mobile" || VMM.Browser.device == "tablet") {
|
||
|
VMM.TouchSlider.createPanel($timebackground, $timenav, config.width, config.spacing, false);
|
||
|
VMM.bindEvent($timenav, onTouchUpdate, "TOUCHUPDATE");
|
||
|
} else {
|
||
|
VMM.DragSlider.createPanel(layout, $timenav, config.width, config.spacing, false);
|
||
|
}
|
||
|
|
||
13 years ago
|
|
||
13 years ago
|
VMM.bindEvent(".zoom-in", onZoomIn, "click");
|
||
|
VMM.bindEvent(".zoom-out", onZoomOut, "click");
|
||
|
VMM.fireEvent(layout, "LOADED");
|
||
13 years ago
|
_active = true;
|
||
|
|
||
13 years ago
|
reSize(true);
|
||
|
|
||
13 years ago
|
};
|
||
|
|
||
13 years ago
|
var buildInterval = function() {
|
||
|
|
||
13 years ago
|
// CALCULATE INTERVAL
|
||
13 years ago
|
timespan = getDateFractions((data[data.length - 1].enddate) - (data[0].startdate), true);
|
||
|
trace(timespan);
|
||
|
calculateInterval();
|
||
|
|
||
|
/* DETERMINE DEFAULT INTERVAL TYPE
|
||
13 years ago
|
millenium, ages, epoch, era and eon are not working yet
|
||
13 years ago
|
================================================== */
|
||
13 years ago
|
/*
|
||
|
if (timespan.eons > data.length / config.nav.density) {
|
||
|
interval = interval_calc.eon;
|
||
|
interval_major = interval_calc.eon;
|
||
|
interval_macro = interval_calc.era;
|
||
|
} else if (timespan.eras > data.length / config.nav.density) {
|
||
|
interval = interval_calc.era;
|
||
|
interval_major = interval_calc.eon;
|
||
|
interval_macro = interval_calc.epoch;
|
||
|
} else if (timespan.epochs > data.length / config.nav.density) {
|
||
|
interval = interval_calc.epoch;
|
||
|
interval_major = interval_calc.era;
|
||
|
interval_macro = interval_calc.age;
|
||
|
} else if (timespan.ages > data.length / config.nav.density) {
|
||
|
interval = interval_calc.ages;
|
||
|
interval_major = interval_calc.epoch;
|
||
|
interval_macro = interval_calc.millenium;
|
||
|
} else if (timespan.milleniums > data.length / config.nav.density) {
|
||
|
interval = interval_calc.millenium;
|
||
|
interval_major = interval_calc.age;
|
||
|
interval_macro = interval_calc.century;
|
||
|
} else
|
||
|
*/
|
||
|
if (timespan.centuries > data.length / config.nav.density) {
|
||
|
interval = interval_calc.century;
|
||
|
interval_major = interval_calc.millenium;
|
||
|
interval_macro = interval_calc.decade;
|
||
|
} else if (timespan.decades > data.length / config.nav.density) {
|
||
|
interval = interval_calc.decade;
|
||
|
interval_major = interval_calc.century;
|
||
|
interval_macro = interval_calc.year;
|
||
|
} else if (timespan.years > data.length / config.nav.density) {
|
||
|
interval = interval_calc.year;
|
||
|
interval_major = interval_calc.decade;
|
||
|
interval_macro = interval_calc.month;
|
||
|
} else if (timespan.months > data.length / config.nav.density) {
|
||
|
interval = interval_calc.month;
|
||
|
interval_major = interval_calc.year;
|
||
|
interval_macro = interval_calc.day;
|
||
|
} else if (timespan.days > data.length / config.nav.density) {
|
||
|
interval = interval_calc.day;
|
||
|
interval_major = interval_calc.month;
|
||
|
interval_macro = interval_calc.hour;
|
||
|
} else if (timespan.hours > data.length / config.nav.density) {
|
||
|
interval = interval_calc.hour;
|
||
|
interval_major = interval_calc.day;
|
||
|
interval_macro = interval_calc.minute;
|
||
|
} else if (timespan.minutes > data.length / config.nav.density) {
|
||
|
interval = interval_calc.minute;
|
||
|
interval_major = interval_calc.hour;
|
||
|
interval_macro = interval_calc.second;
|
||
|
} else if (timespan.seconds > data.length / config.nav.density) {
|
||
|
interval = interval_calc.second;
|
||
|
interval_major = interval_calc.minute;
|
||
|
interval_macro = interval_calc.second;
|
||
13 years ago
|
} else {
|
||
|
trace("NO IDEA WHAT THE TYPE SHOULD BE");
|
||
13 years ago
|
interval = interval_calc.day;
|
||
|
interval_major = interval_calc.month;
|
||
|
interval_macro = interval_calc.hour;
|
||
13 years ago
|
}
|
||
|
|
||
|
trace("INTERVAL TYPE: " + interval.type);
|
||
|
trace("INTERVAL MAJOR TYPE: " + interval_major.type);
|
||
|
|
||
|
createIntervalElements(interval, interval_array, $timeinterval);
|
||
|
createIntervalElements(interval_major, interval_major_array, $timeintervalmajor);
|
||
|
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
var buildMarkers = function() {
|
||
|
|
||
|
var row = 2; //row
|
||
|
var lpos = 0; // last marker pos;
|
||
|
var row_depth = 0;
|
||
13 years ago
|
markers = [];
|
||
|
era_markers = [];
|
||
13 years ago
|
|
||
|
for(var i = 0; i < data.length; i++) {
|
||
|
|
||
|
var _marker, _marker_flag, _marker_content, _marker_dot, _marker_line, _marker_line_event;
|
||
|
|
||
|
_marker = VMM.appendAndGetElement($content, "<div>", "marker");
|
||
|
_marker_flag = VMM.appendAndGetElement(_marker, "<div>", "flag");
|
||
|
_marker_content = VMM.appendAndGetElement(_marker_flag, "<div>", "flag-content");
|
||
|
_marker_dot = VMM.appendAndGetElement(_marker, "<div>", "dot");
|
||
|
_marker_line = VMM.appendAndGetElement(_marker, "<div>", "line");
|
||
|
_marker_line_event = VMM.appendAndGetElement(_marker_line, "<div>", "event-line");
|
||
|
|
||
|
|
||
|
// THUMBNAIL
|
||
|
if (data[i].asset != null && data[i].asset != "") {
|
||
13 years ago
|
VMM.appendElement(_marker_content, VMM.MediaElement.thumbnail(data[i].asset, 24, 24));
|
||
|
} else {
|
||
|
//VMM.appendElement(_marker_content, "<div class='thumbnail thumb-plaintext'></div>");
|
||
|
VMM.appendElement(_marker_content, "<div style='margin-right:7px;height:50px;width:2px;float:left;'></div>");
|
||
13 years ago
|
}
|
||
|
|
||
|
// ADD DATE AND TITLE
|
||
|
VMM.appendElement(_marker_content, "<h3>" + VMM.Util.unlinkify(data[i].title) + "</h3><h4>" + data[i].date + "</h4>");
|
||
|
|
||
|
// ADD ID
|
||
13 years ago
|
VMM.Lib.attr(_marker, "id", (data[i].uniqueid).toString());
|
||
13 years ago
|
|
||
|
// MARKER CLICK
|
||
|
VMM.bindEvent(_marker_flag, onMarkerClick, "", {number: i});
|
||
|
VMM.bindEvent(_marker_flag, onMarkerHover, "mouseenter mouseleave", {number: i, elem:_marker_flag});
|
||
|
|
||
|
var _marker_obj = {
|
||
|
marker: _marker,
|
||
|
flag: _marker_flag,
|
||
|
lineevent: _marker_line_event,
|
||
|
type: "marker"
|
||
|
};
|
||
|
|
||
|
|
||
|
if (data[i].type == "start") {
|
||
|
trace("BUILD MARKER HAS START PAGE")
|
||
|
config.start_page = true;
|
||
|
_marker_obj.type = "start";
|
||
|
}
|
||
|
|
||
|
markers.push(_marker_obj);
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
// CREATE ERAS
|
||
|
for(var j = 0; j < eras.length; j++) {
|
||
|
|
||
|
var era = {
|
||
|
content: VMM.appendAndGetElement($content, "<div>", "era"),
|
||
|
startdate: VMM.Util.parseDate(eras[j].startDate),
|
||
|
enddate: VMM.Util.parseDate(eras[j].endDate),
|
||
|
title: eras[j].headline,
|
||
|
uniqueid: VMM.Util.unique_ID(4),
|
||
|
color: eras[j].color
|
||
|
};
|
||
|
|
||
13 years ago
|
VMM.Lib.attr(era.content, "id", era.uniqueid);
|
||
|
VMM.Lib.css(era.content, "background", era.color);
|
||
13 years ago
|
VMM.appendElement(era.content, "<h3>" + VMM.Util.unlinkify(era.title) + "</h3>");
|
||
|
|
||
|
era_markers.push(era);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
13 years ago
|
|
||
|
};
|
||
|
|
||
13 years ago
|
}
|
||
|
|
||
|
/***********************************************
|
||
|
Begin VMM.Timeline.DataObj.js
|
||
|
***********************************************/
|
||
|
|
||
|
/* TIMELINE SOURCE DATA PROCESSOR
|
||
|
================================================== */
|
||
|
|
||
|
if(typeof VMM.Timeline != 'undefined' && typeof VMM.Timeline.DataObj == 'undefined') {
|
||
13 years ago
|
|
||
13 years ago
|
VMM.Timeline.DataObj = {
|
||
|
|
||
|
data_obj: {},
|
||
|
|
||
|
model_array: [],
|
||
|
|
||
|
getData: function(raw_data) {
|
||
|
|
||
|
data = VMM.Timeline.DataObj.data_obj;
|
||
|
|
||
13 years ago
|
if (type.of(raw_data) == "object") {
|
||
|
trace("DATA SOURCE: JSON OBJECT");
|
||
|
VMM.Timeline.DataObj.parseJSON(raw_data);
|
||
|
} else if (type.of(raw_data) == "string") {
|
||
13 years ago
|
if (raw_data.match("%23")) {
|
||
|
trace("DATA SOURCE: TWITTER SEARCH");
|
||
|
VMM.Timeline.DataObj.model_Tweets.getData("%23medill");
|
||
|
|
||
13 years ago
|
} else if ( raw_data.match("spreadsheet") ) {
|
||
13 years ago
|
VMM.fireEvent(global, "MESSEGE", VMM.Timeline.Config.language.messages.loading_timeline);
|
||
13 years ago
|
trace("DATA SOURCE: GOOGLE SPREADSHEET");
|
||
|
VMM.Timeline.DataObj.model_GoogleSpreadsheet.getData(raw_data);
|
||
|
|
||
|
} else {
|
||
13 years ago
|
VMM.fireEvent(global, "MESSEGE", VMM.Timeline.Config.language.messages.loading_timeline);
|
||
13 years ago
|
trace("DATA SOURCE: JSON");
|
||
|
VMM.getJSON(raw_data, VMM.Timeline.DataObj.parseJSON);
|
||
|
}
|
||
13 years ago
|
} else if (type.of(raw_data) == "html") {
|
||
|
trace("DATA SOURCE: HTML");
|
||
|
VMM.Timeline.DataObj.parseHTML(raw_data);
|
||
|
} else {
|
||
|
trace("DATA SOURCE: UNKNOWN");
|
||
13 years ago
|
}
|
||
|
|
||
|
},
|
||
|
|
||
|
parseHTML: function(d) {
|
||
|
trace("parseHTML");
|
||
13 years ago
|
trace("WARNING: THIS IS STILL ALPHA AND WILL NOT WORK WITH ID's other than #timeline");
|
||
13 years ago
|
var _data_obj = VMM.Timeline.DataObj.data_template_obj;
|
||
|
|
||
|
/* Timeline start slide
|
||
|
================================================== */
|
||
13 years ago
|
if (VMM.Lib.find("#timeline section", "time")[0]) {
|
||
|
_data_obj.timeline.startDate = VMM.Lib.html(VMM.Lib.find("#timeline section", "time")[0]);
|
||
|
_data_obj.timeline.headline = VMM.Lib.html(VMM.Lib.find("#timeline section", "h2"));
|
||
|
_data_obj.timeline.text = VMM.Lib.html(VMM.Lib.find("#timeline section", "article"));
|
||
13 years ago
|
|
||
|
var found_main_media = false;
|
||
|
|
||
13 years ago
|
if (VMM.Lib.find("#timeline section", "figure img").length != 0) {
|
||
13 years ago
|
found_main_media = true;
|
||
13 years ago
|
_data_obj.timeline.asset.media = VMM.Lib.attr(VMM.Lib.find("#timeline section", "figure img"), "src");
|
||
|
} else if (VMM.Lib.find("#timeline section", "figure a").length != 0) {
|
||
13 years ago
|
found_main_media = true;
|
||
13 years ago
|
_data_obj.timeline.asset.media = VMM.Lib.attr(VMM.Lib.find("#timeline section", "figure a"), "href");
|
||
13 years ago
|
} else {
|
||
|
//trace("NOT FOUND");
|
||
|
}
|
||
|
|
||
|
if (found_main_media) {
|
||
13 years ago
|
if (VMM.Lib.find("#timeline section", "cite").length != 0) {
|
||
|
_data_obj.timeline.asset.credit = VMM.Lib.html(VMM.Lib.find("#timeline section", "cite"));
|
||
13 years ago
|
}
|
||
13 years ago
|
if (VMM.Lib.find(this, "figcaption").length != 0) {
|
||
|
_data_obj.timeline.asset.caption = VMM.Lib.html(VMM.Lib.find("#timeline section", "figcaption"));
|
||
13 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* Timeline Date Slides
|
||
|
================================================== */
|
||
13 years ago
|
VMM.Lib.each("#timeline li", function(i, elem){
|
||
13 years ago
|
|
||
|
var valid_date = false;
|
||
|
|
||
|
var _date = {
|
||
|
"type":"default",
|
||
|
"startDate":"",
|
||
|
"headline":"",
|
||
|
"text":"",
|
||
|
"asset":
|
||
|
{
|
||
|
"media":"",
|
||
|
"credit":"",
|
||
|
"caption":""
|
||
|
},
|
||
|
"tags":"Optional"
|
||
|
};
|
||
|
|
||
13 years ago
|
if (VMM.Lib.find(this, "time") != 0) {
|
||
13 years ago
|
|
||
|
valid_date = true;
|
||
|
|
||
13 years ago
|
_date.startDate = VMM.Lib.html(VMM.Lib.find(this, "time")[0]);
|
||
13 years ago
|
|
||
13 years ago
|
if (VMM.Lib.find(this, "time")[1]) {
|
||
|
_date.endDate = VMM.Lib.html(VMM.Lib.find(this, "time")[0]);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
_date.headline = VMM.Lib.html(VMM.Lib.find(this, "h3"));
|
||
13 years ago
|
|
||
13 years ago
|
_date.text = VMM.Lib.html(VMM.Lib.find(this, "article"));
|
||
13 years ago
|
|
||
|
var found_media = false;
|
||
13 years ago
|
if (VMM.Lib.find(this, "figure img").length != 0) {
|
||
13 years ago
|
found_media = true;
|
||
13 years ago
|
_date.asset.media = VMM.Lib.attr(VMM.Lib.find(this, "figure img"), "src");
|
||
|
} else if (VMM.Lib.find(this, "figure a").length != 0) {
|
||
13 years ago
|
found_media = true;
|
||
13 years ago
|
_date.asset.media = VMM.Lib.attr(VMM.Lib.find(this, "figure a"), "href");
|
||
13 years ago
|
} else {
|
||
|
//trace("NOT FOUND");
|
||
|
}
|
||
|
|
||
|
if (found_media) {
|
||
13 years ago
|
if (VMM.Lib.find(this, "cite").length != 0) {
|
||
|
_date.asset.credit = VMM.Lib.html(VMM.Lib.find(this, "cite"));
|
||
13 years ago
|
}
|
||
13 years ago
|
if (VMM.Lib.find(this, "figcaption").length != 0) {
|
||
|
_date.asset.caption = VMM.Lib.html(VMM.Lib.find(this, "figcaption"));
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
|
trace(_date);
|
||
|
_data_obj.timeline.date.push(_date);
|
||
|
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
VMM.fireEvent(global, "DATAREADY", _data_obj);
|
||
|
|
||
|
},
|
||
|
|
||
|
parseJSON: function(d) {
|
||
|
if (d.timeline.type == "default") {
|
||
|
|
||
|
trace("DATA SOURCE: JSON STANDARD TIMELINE");
|
||
|
VMM.fireEvent(global, "DATAREADY", d);
|
||
|
|
||
|
} else if (d.timeline.type == "twitter") {
|
||
|
|
||
|
trace("DATA SOURCE: JSON TWEETS");
|
||
|
VMM.Timeline.DataObj.model_Tweets.buildData(d);
|
||
|
|
||
|
} else {
|
||
13 years ago
|
|
||
|
trace("DATA SOURCE: UNKNOWN JSON");
|
||
13 years ago
|
trace(type.of(d.timeline));
|
||
13 years ago
|
|
||
13 years ago
|
};
|
||
|
},
|
||
|
|
||
|
/* MODEL OBJECTS
|
||
|
New Types of Data can be formatted for the timeline here
|
||
|
================================================== */
|
||
|
|
||
|
model_Tweets: {
|
||
|
|
||
|
type: "twitter",
|
||
|
|
||
|
buildData: function(raw_data) {
|
||
|
VMM.bindEvent(global, VMM.Timeline.DataObj.model_Tweets.onTwitterDataReady, "TWEETSLOADED");
|
||
|
VMM.ExternalAPI.twitter.getTweets(raw_data.timeline.tweets);
|
||
|
},
|
||
|
|
||
|
getData: function(raw_data) {
|
||
|
VMM.bindEvent(global, VMM.Timeline.DataObj.model_Tweets.onTwitterDataReady, "TWEETSLOADED");
|
||
|
VMM.ExternalAPI.twitter.getTweetSearch(raw_data);
|
||
|
},
|
||
|
|
||
|
onTwitterDataReady: function(e, d) {
|
||
|
var _data_obj = VMM.Timeline.DataObj.data_template_obj;
|
||
|
|
||
|
for(var i = 0; i < d.tweetdata.length; i++) {
|
||
|
|
||
|
var _date = {
|
||
|
"type":"tweets",
|
||
|
"startDate":"",
|
||
|
"headline":"",
|
||
|
"text":"",
|
||
|
"asset":
|
||
|
{
|
||
|
"media":"",
|
||
|
"credit":"",
|
||
|
"caption":""
|
||
|
},
|
||
|
"tags":"Optional"
|
||
|
};
|
||
|
// pass in the 'created_at' string returned from twitter //
|
||
|
// stamp arrives formatted as Tue Apr 07 22:52:51 +0000 2009 //
|
||
|
|
||
|
//var twit_date = VMM.ExternalAPI.twitter.parseTwitterDate(d.tweetdata[i].raw.created_at);
|
||
|
//trace(twit_date);
|
||
13 years ago
|
|
||
13 years ago
|
_date.startDate = d.tweetdata[i].raw.created_at;
|
||
|
|
||
|
if (type.of(d.tweetdata[i].raw.from_user_name)) {
|
||
|
_date.headline = d.tweetdata[i].raw.from_user_name + " (<a href='https://twitter.com/" + d.tweetdata[i].raw.from_user + "'>" + "@" + d.tweetdata[i].raw.from_user + "</a>)" ;
|
||
|
} else {
|
||
|
_date.headline = d.tweetdata[i].raw.user.name + " (<a href='https://twitter.com/" + d.tweetdata[i].raw.user.screen_name + "'>" + "@" + d.tweetdata[i].raw.user.screen_name + "</a>)" ;
|
||
|
}
|
||
|
|
||
|
_date.asset.media = d.tweetdata[i].content;
|
||
|
_data_obj.timeline.date.push(_date);
|
||
|
|
||
|
};
|
||
|
|
||
|
VMM.fireEvent(global, "DATAREADY", _data_obj);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
model_GoogleSpreadsheet: {
|
||
13 years ago
|
// TEMPLATE CAN BE FOUND HERE
|
||
|
// https://docs.google.com/previewtemplate?id=0AppSVxABhnltdEhzQjQ4MlpOaldjTmZLclQxQWFTOUE&mode=public
|
||
13 years ago
|
type: "google spreadsheet",
|
||
|
|
||
13 years ago
|
|
||
13 years ago
|
getData: function(raw_data) {
|
||
13 years ago
|
|
||
13 years ago
|
var _key = VMM.Util.getUrlVars(raw_data)["key"];
|
||
13 years ago
|
var _url = "https://spreadsheets.google.com/feeds/list/" + _key + "/od6/public/values?alt=json";
|
||
|
|
||
13 years ago
|
VMM.getJSON(_url, VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData);
|
||
13 years ago
|
},
|
||
|
|
||
|
buildData: function(d) {
|
||
13 years ago
|
VMM.fireEvent(global, "MESSEGE", "Parsing Data");
|
||
13 years ago
|
var _data_obj = VMM.Timeline.DataObj.data_template_obj;
|
||
|
|
||
|
for(var i = 0; i < d.feed.entry.length; i++) {
|
||
|
var dd = d.feed.entry[i];
|
||
|
|
||
|
if (dd.gsx$titleslide.$t.match("start")) {
|
||
13 years ago
|
_data_obj.timeline.startDate = dd.gsx$startdate.$t;
|
||
|
_data_obj.timeline.headline = dd.gsx$headline.$t;
|
||
|
_data_obj.timeline.asset.media = dd.gsx$media.$t;
|
||
|
_data_obj.timeline.asset.caption = dd.gsx$mediacaption.$t;
|
||
|
_data_obj.timeline.asset.credit = dd.gsx$mediacredit.$t;
|
||
|
_data_obj.timeline.text = dd.gsx$text.$t;
|
||
|
_data_obj.timeline.type = "google spreadsheet";
|
||
13 years ago
|
} else {
|
||
|
var _date = {
|
||
13 years ago
|
"type": "google spreadsheet",
|
||
|
"startDate": dd.gsx$startdate.$t,
|
||
|
"endDate": dd.gsx$enddate.$t,
|
||
|
"headline": dd.gsx$headline.$t,
|
||
|
"text": dd.gsx$text.$t,
|
||
|
"asset": {
|
||
|
"media": dd.gsx$media.$t,
|
||
|
"credit": dd.gsx$mediacredit.$t,
|
||
|
"caption": dd.gsx$mediacaption.$t
|
||
|
},
|
||
|
"tags": "Optional"
|
||
13 years ago
|
};
|
||
|
_data_obj.timeline.date.push(_date);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
VMM.fireEvent(global, "DATAREADY", _data_obj);
|
||
|
|
||
|
}
|
||
|
|
||
|
},
|
||
|
|
||
|
/* TEMPLATE OBJECTS
|
||
|
================================================== */
|
||
13 years ago
|
data_template_obj: { "timeline": { "headline":"", "description":"", "asset": { "media":"", "credit":"", "caption":"" }, "date": [] } },
|
||
|
date_obj: {"startDate":"2012,2,2,11,30", "headline":"", "text":"", "asset": {"media":"http://youtu.be/vjVfu8-Wp6s", "credit":"", "caption":"" }, "tags":"Optional"}
|
||
|
|
||
13 years ago
|
};
|
||
13 years ago
|
|
||
13 years ago
|
}
|