Browse Source

Organization changes

pull/127/head
Zach Wise 13 years ago
parent
commit
f432f4716d
  1. 1
      .gitignore
  2. 739
      codekit-config.json
  3. 149
      source/js/VMM.Browser.js
  4. 147
      source/js/VMM.DragSlider.js
  5. 784
      source/js/VMM.ExternalAPI.js
  6. 27
      source/js/VMM.FileExtention.js
  7. 548
      source/js/VMM.Library.js
  8. 247
      source/js/VMM.LoadLib.js
  9. 163
      source/js/VMM.Media.js
  10. 186
      source/js/VMM.MediaElement.js
  11. 88
      source/js/VMM.MediaType.js
  12. 198
      source/js/VMM.Slider.Slide.js
  13. 629
      source/js/VMM.Slider.js

1
.gitignore vendored

@ -5,6 +5,7 @@ cdn/
<<<<<<< HEAD
=======
VMM.Timeline.CDN.js
CDN.js
>>>>>>> Canary
*.tmproj
*.tmproject

739
codekit-config.json

File diff suppressed because it is too large Load Diff

149
source/js/VMM.Browser.js

@ -1,149 +0,0 @@
/* 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"
}
]
}
VMM.Browser.init();
}

147
source/js/VMM.DragSlider.js

@ -1,147 +0,0 @@
/* DRAG SLIDER
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.DragSlider == 'undefined') {
// VMM.DragSlider.createSlidePanel(drag_object, move_object, w, padding, sticky);
// VMM.DragSlider.cancelSlide();
VMM.DragSlider = {
createPanel: function(drag_object, move_object, w, padding, sticky) {
var x = padding;
VMM.DragSlider.width = w;
VMM.DragSlider.makeDraggable(drag_object, move_object);
VMM.DragSlider.drag_elem = drag_object;
/*
if (sticky != null && sticky != "") {
VMM.TouchSlider.sticky = sticky;
} else {
VMM.TouchSlider.sticky = false;
}
*/
VMM.DragSlider.sticky = sticky;
},
makeDraggable: function(drag_object, move_object) {
VMM.bindEvent(drag_object, VMM.DragSlider.onDragStart, "mousedown", {element: move_object, delement: drag_object});
//VMM.bindEvent(drag_object, VMM.DragSlider.onDragMove, "mousemove", {element: move_object});
VMM.bindEvent(drag_object, VMM.DragSlider.onDragEnd, "mouseup", {element: move_object, delement: drag_object});
VMM.bindEvent(drag_object, VMM.DragSlider.onDragLeave, "mouseleave", {element: move_object, delement: drag_object});
},
cancelSlide: function(e) {
VMM.unbindEvent(VMM.DragSlider.drag_elem, VMM.DragSlider.onDragMove, "mousemove");
//VMM.DragSlider.drag_elem.preventDefault();
//VMM.DragSlider.drag_elem.stopPropagation();
return true;
},
onDragLeave: function(e) {
VMM.unbindEvent(e.data.delement, VMM.DragSlider.onDragMove, "mousemove");
e.preventDefault();
e.stopPropagation();
return true;
},
onDragStart: function(e) {
VMM.DragSlider.dragStart(e.data.element, e.data.delement, e);
e.preventDefault();
e.stopPropagation();
return true;
},
onDragEnd: function(e) {
e.preventDefault();
e.stopPropagation();
if (VMM.DragSlider.sliding) {
VMM.DragSlider.sliding = false;
VMM.DragSlider.dragEnd(e.data.element, e.data.delement, e);
return false;
} else {
return true;
}
},
onDragMove: function(e) {
VMM.DragSlider.dragMove(e.data.element, e);
e.preventDefault();
e.stopPropagation();
return false;
},
dragStart: function(elem, delem, e) {
VMM.DragSlider.startX = e.pageX;
VMM.DragSlider.startLeft = VMM.DragSlider.getLeft(elem);
VMM.DragSlider.dragStartTime = new Date().getTime();
VMM.DragSlider.dragWidth = VMM.Lib.width(delem);
// CANCEL CURRENT ANIMATION IF ANIMATING
var _newx = Math.round(VMM.DragSlider.startX - e.pageX - VMM.DragSlider.startLeft);
VMM.Lib.stop(elem);
VMM.bindEvent(delem, VMM.DragSlider.onDragMove, "mousemove", {element: elem});
},
dragEnd: function(elem, delem, e) {
VMM.unbindEvent(delem, VMM.DragSlider.onDragMove, "mousemove");
//VMM.DragSlider.dragMomentum(elem, e);
if (VMM.DragSlider.getLeft(elem) > 0) {
//(VMM.DragSlider.dragWidth/2)
//This means they dragged to the right past the first item
//VMM.Lib.animate(elem, 1000, "linear", {"left": 0});
//VMM.fireEvent(elem, "DRAGUPDATE", [0]);
} else {
//This means they were just dragging within the bounds of the grid and we just need to handle the momentum and snap to the grid.
VMM.DragSlider.dragMomentum(elem, e);
}
},
dragMove: function(elem, e) {
if (!VMM.DragSlider.sliding) {
//elem.parent().addClass('sliding');
}
VMM.DragSlider.sliding = true;
if (VMM.DragSlider.startX > e.pageX) {
//Sliding to the left
VMM.Lib.css(elem, 'left', -(VMM.DragSlider.startX - e.pageX - VMM.DragSlider.startLeft));
VMM.DragSlider.slidingLeft = true;
} else {
//Sliding to the right
var left = (e.pageX - VMM.DragSlider.startX + VMM.DragSlider.startLeft);
VMM.Lib.css(elem, 'left', -(VMM.DragSlider.startX - e.pageX - VMM.DragSlider.startLeft));
VMM.DragSlider.slidingLeft = false;
}
},
dragMomentum: function(elem, e) {
var slideAdjust = (new Date().getTime() - VMM.DragSlider.dragStartTime) * 10;
var timeAdjust = slideAdjust;
var left = VMM.DragSlider.getLeft(elem);
var changeX = 6000 * (Math.abs(VMM.DragSlider.startLeft) - Math.abs(left));
//var changeX = 6000 * (VMM.DragSlider.startLeft - left);
slideAdjust = Math.round(changeX / slideAdjust);
var newLeft = left + slideAdjust;
var t = newLeft % VMM.DragSlider.width;
//left: Math.min(0, newLeft),
var _r_object = {
left: Math.min(newLeft),
time: timeAdjust
}
VMM.fireEvent(elem, "DRAGUPDATE", [_r_object]);
var _ease = "easeOutExpo";
if (_r_object.time > 0) {
VMM.Lib.animate(elem, _r_object.time, _ease, {"left": _r_object.left});
};
//VMM.DragSlider.startX = null;
},
getLeft: function(elem) {
return parseInt(VMM.Lib.css(elem, 'left').substring(0, VMM.Lib.css(elem, 'left').length - 2), 10);
}
}
}

784
source/js/VMM.ExternalAPI.js

@ -1,784 +0,0 @@
/* External API
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
VMM.ExternalAPI = {
pushQues: function() {
if (VMM.master_config.googlemaps.active) {
VMM.ExternalAPI.googlemaps.pushQue();
}
if (VMM.master_config.youtube.active) {
VMM.ExternalAPI.youtube.pushQue();
}
if (VMM.master_config.soundcloud.active) {
VMM.ExternalAPI.soundcloud.pushQue();
}
if (VMM.master_config.googledocs.active) {
VMM.ExternalAPI.googledocs.pushQue();
}
if (VMM.master_config.wikipedia.active) {
VMM.ExternalAPI.wikipedia.pushQue();
}
if (VMM.master_config.vimeo.active) {
VMM.ExternalAPI.vimeo.pushQue();
}
},
twitter: {
tweetArray: [],
// VMM.ExternalAPI.twitter.getHTML(id);
getHTML: function(id) {
//var the_url = document.location.protocol + "//api.twitter.com/1/statuses/oembed.json?id=" + id+ "&callback=?";
var the_url = "http://api.twitter.com/1/statuses/oembed.json?id=" + id+ "&callback=?";
VMM.getJSON(the_url, VMM.ExternalAPI.twitter.onJSONLoaded);
},
onJSONLoaded: function(d) {
trace("TWITTER JSON LOADED");
var id = d.id;
VMM.attachElement("#"+id, VMM.Util.linkify_with_twitter(d.html) );
},
// VMM.ExternalAPI.twitter.parseTwitterDate(date);
parseTwitterDate: function(d) {
var date = new Date(Date.parse(d));
/*
var t = d.replace(/(\d{1,2}[:]\d{2}[:]\d{2}) (.*)/, '$2 $1');
t = t.replace(/(\+\S+) (.*)/, '$2 $1');
var date = new Date(Date.parse(t)).toLocaleDateString();
var time = new Date(Date.parse(t)).toLocaleTimeString();
*/
return date;
},
prettyParseTwitterDate: function(d) {
var date = new Date(Date.parse(d));
return VMM.Util.date.prettyDate(date, true);
},
// VMM.ExternalAPI.twitter.getTweets(tweets_array);
getTweets: function(tweets) {
var tweetArray = [];
var number_of_tweets = tweets.length;
for(var i = 0; i < tweets.length; i++) {
var twitter_id = "";
/* 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"); });
}
},
// VMM.ExternalAPI.twitter.getTweetSearch(search string);
getTweetSearch: function(tweets, number_of_tweets) {
var _number_of_tweets = 40;
if (number_of_tweets != null && number_of_tweets != "") {
_number_of_tweets = number_of_tweets;
}
var the_url = "http://search.twitter.com/search.json?q=" + tweets + "&rpp=" + _number_of_tweets + "&include_entities=true&result_type=mixed";
var tweetArray = [];
VMM.getJSON(the_url, function(d) {
/* 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);
VMM.getJSON(the_url, VMM.ExternalAPI.twitter.formatJSON)
.error(function(jqXHR, textStatus, errorThrown) {
trace("TWITTER error");
trace("TWITTER ERROR: " + textStatus + " " + jqXHR.responseText);
VMM.attachElement("#twitter_"+id, "<p>ERROR LOADING TWEET " + id + "</p>" );
})
.success(function() {
clearTimeout(twitter_timeout);
});
},
notFoundError: function(id) {
trace("TWITTER JSON ERROR TIMEOUT " + id);
VMM.attachElement("#twitter_" + id, "<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 );
}
},
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) {
} else {
VMM.LoadLib.js(map_url, function() {
trace("Google Maps API Library Loaded");
});
}
}
},
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];
} else {
if (VMM.ExternalAPI.googlemaps.defaultType(name)) {
trace("GOOGLE MAP DEFAULT TYPE");
return google.maps.MapTypeId[name.toUpperCase()];
} else {
trace("Not a maptype: " + name );
}
}
}
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";
}
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"]);
}
var map_options = {
zoom: zoom,
disableDefaultUI: true,
mapTypeControl: false,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL,
position: google.maps.ControlPosition.TOP_RIGHT
},
center: location,
mapTypeId: layer,
mapTypeControlOptions: {
mapTypeIds: [layer]
}
}
var unique_map_id = m.id.toString() + "_gmap";
VMM.attachElement("#" + m.id, "<div class='google-map' id='" + unique_map_id + "' style='width=100%;height=100%;'></div>");
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);
}
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);
}
});
}
},
pushQue: function() {
for(var i = 0; i < VMM.master_config.googlemaps.que.length; i++) {
VMM.ExternalAPI.googlemaps.create(VMM.master_config.googlemaps.que[i]);
}
VMM.master_config.googlemaps.que = [];
},
onMapAPIReady: function() {
VMM.master_config.googlemaps.map_active = true;
VMM.master_config.googlemaps.places_active = true;
VMM.ExternalAPI.googlemaps.onAPIReady();
},
onPlacesAPIReady: function() {
VMM.master_config.googlemaps.places_active = true;
VMM.ExternalAPI.googlemaps.onAPIReady();
},
onAPIReady: function() {
if (!VMM.master_config.googlemaps.active) {
if (VMM.master_config.googlemaps.map_active && VMM.master_config.googlemaps.places_active) {
VMM.master_config.googlemaps.active = true;
VMM.ExternalAPI.googlemaps.pushQue();
}
}
},
defaultType: function(name) {
if (name.toLowerCase() == "satellite" || name.toLowerCase() == "hybrid" || name.toLowerCase() == "terrain" || name.toLowerCase() == "roadmap") {
return true;
} else {
return false;
}
},
map_subdomains: ["", "a.", "b.", "c.", "d."],
map_attribution: {
"stamen": "Map tiles by <a href='http://stamen.com'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0'>CC BY SA</a>.",
"apple": "Map data &copy; 2012 Apple, Imagery &copy; 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"
}
},
},
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)) {
mediaElem = "<iframe class='doc' frameborder='0' width='100%' height='100%' src='" + doc.url + "&amp;embedded=true'></iframe>";
} else {
mediaElem = "<iframe class='doc' frameborder='0' width='100%' height='100%' src='" + "http://docs.google.com/viewer?url=" + doc.url + "&amp;embedded=true'></iframe>";
}
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)
}
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";
var flickr_img_size, flickr_img_thumb, flickr_size_found = false;
var flickr_best_size = "Large";
flickr_best_size = VMM.ExternalAPI.flickr.sizes(VMM.master_config.sizes.api.height);
for(var i = 0; i < d.sizes.size.length; i++) {
if (d.sizes.size[i].label == flickr_best_size) {
flickr_size_found = true;
flickr_img_size = d.sizes.size[i].source;
}
}
if (!flickr_size_found) {
flickr_img_size = d.sizes.size[d.sizes.size.length - 1].source;
}
flickr_img_thumb = d.sizes.size[0].source;
VMM.Lib.attr("#"+flickr_large_id, "src", flickr_img_size);
VMM.attachElement("#"+flickr_thumb_id, "<img src='" + flickr_img_thumb + "'>");
},
sizes: function(s) {
var _size = "";
if (s <= 75) {
_size = "Thumbnail";
} else if (s <= 180) {
_size = "Small";
} else if (s <= 240) {
_size = "Small 320";
} else if (s <= 375) {
_size = "Medium";
} else if (s <= 480) {
_size = "Medium 640";
} else if (s <= 600) {
_size = "Medium 800";
} else {
_size = "Large";
}
return _size;
}
},
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]);
}
VMM.master_config.soundcloud.que = [];
},
},
wikipedia: {
get: function(url, id) {
var api_obj = {url: url, id: id};
VMM.master_config.wikipedia.que.push(api_obj);
VMM.master_config.wikipedia.active = true;
},
create: function(api_obj) {
var the_url = "http://en.wikipedia.org/w/api.php?action=query&prop=extracts&redirects=&titles=" + api_obj.url + "&exintro=1&format=json&callback=?";
if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 7 && window.XDomainRequest) {
var temp_text = "<h4><a href='http://en.wikipedia.org/wiki/" + api_obj.url + "' target='_blank'>" + api_obj.url + "</a></h4>";
temp_text += "<div class='wiki-source'>From Wikipedia, the free encyclopedia</span>";
temp_text += "<p>Wikipedia entry unable to load using Internet Explorer 8 or below.</p>";
VMM.attachElement("#"+api_obj.id, temp_text );
}
VMM.getJSON(the_url, function(d) {
if (d.query) {
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 = 1;
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><a href='http://" + VMM.master_config.language.api.wikipedia + ".wikipedia.org/wiki/" + wiki_title + "' target='_blank'>" + wiki_title + "</a></h4>";
_wiki += "<div class='wiki-source'>" + VMM.master_config.language.messages.wikipedia + "</span>";
_wiki += VMM.Util.linkify_wikipedia(wiki_text);
if (wiki_extract.match("REDIRECT")) {
} else {
VMM.attachElement("#"+api_obj.id, _wiki );
}
}
});
},
pushQue: function() {
trace("WIKIPEDIA PUSH QUE");
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 = [];
},
},
youtube: {
get: function(id) {
var url = "http://gdata.youtube.com/feeds/api/videos/" + id + "?v=2&alt=jsonc&callback=?";
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");
});
}
}
// THUMBNAIL
VMM.getJSON(url, VMM.ExternalAPI.youtube.createThumb);
},
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);
},
createThumb: function(d) {
trace(d.data.id);
trace(d.data.thumbnail.sqDefault);
var thumb_id = "youtube_" + d.data.id + "_thumb";
VMM.attachElement("#" + thumb_id, "<img src='" + d.data.thumbnail.sqDefault + "'>");
},
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 = [];
},
onAPIReady: function() {
VMM.master_config.youtube.active = true;
VMM.ExternalAPI.youtube.pushQue();
},
stopPlayers: function() {
for(var i = 0; i < VMM.master_config.youtube.array.length; i++) {
if (VMM.master_config.youtube.array[i].playing) {
var the_name = VMM.master_config.youtube.array[i].name;
VMM.master_config.youtube.array[i].player[the_name].stopVideo();
}
}
},
onStateChange: function(e) {
for(var i = 0; i < VMM.master_config.youtube.array.length; i++) {
var the_name = VMM.master_config.youtube.array[i].name;
if (VMM.master_config.youtube.array[i].player[the_name] == e.target) {
if (e.data == YT.PlayerState.PLAYING) {
VMM.master_config.youtube.array[i].playing = true;
}
}
}
},
onPlayerReady: function(e) {
}
},
vimeo: {
get: function(id) {
VMM.master_config.vimeo.que.push(id);
VMM.master_config.vimeo.active = true;
},
create: function(d) {
trace("VIMEO CREATE");
// THUMBNAIL
var url = "http://vimeo.com/api/v2/video/" + d + ".json";
VMM.getJSON(url, VMM.ExternalAPI.vimeo.createThumb);
},
createThumb: function(d) {
trace("VIMEO CREATE THUMB");
var thumb_id = "vimeo_" + d[0].id + "_thumb";
VMM.attachElement("#" + thumb_id, "<img src='" + d[0].thumbnail_small + "'>");
},
pushQue: function() {
for(var i = 0; i < VMM.master_config.vimeo.que.length; i++) {
VMM.ExternalAPI.vimeo.create(VMM.master_config.vimeo.que[i]);
}
VMM.master_config.vimeo.que = [];
}
}
}
}
/* 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();
}

27
source/js/VMM.FileExtention.js

@ -1,27 +0,0 @@
/* 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;
for (var i = 0; i < validFileExtensions.length; i++) {
if (fileExtension.toLowerCase().match(validFileExtensions[i].toString().toLowerCase()) || fileName.match("docs.google.com") ) {
flag = true;
}
}
return flag;
}
}
}

548
source/js/VMM.Library.js

@ -1,548 +0,0 @@
/* 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;
}
};
VMM.getJSON = function(url, data, callback) {
if( typeof( jQuery ) != 'undefined' ){
/* CHECK FOR IE
================================================== */
if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 7 && window.XDomainRequest) {
trace("IE JSON");
var ie_url = url;
if (ie_url.match('^http://')){
return jQuery.getJSON(ie_url, data, callback);
} else if (ie_url.match('^https://')) {
ie_url = ie_url.replace("https://","http://");
return jQuery.getJSON(ie_url, data, callback);
} else {
return jQuery.getJSON(url, data, callback);
}
} else {
return jQuery.getJSON(url, data, callback);
}
}
}
VMM.parseJSON = function(the_json) {
if( typeof( jQuery ) != 'undefined' ){
return jQuery.parseJSON(the_json);
}
}
// ADD ELEMENT AND RETURN IT
VMM.appendAndGetElement = function(append_to_element, tag, cName, content) {
var e;
var _tag = "<div>";
var _class = "";
var _content = "";
if (tag != null && tag != "") {
_tag = tag;
}
if (cName != null && cName != "") {
_class = cName;
}
if (content != null && content != "") {
_content = content;
}
if( typeof( jQuery ) != 'undefined' ){
e = jQuery(tag);
e.addClass(_class);
e.html(_content);
jQuery(append_to_element).append(e);
}
return e;
};
VMM.Lib = {
init: function() {
return this;
},
hide: function(element, duration) {
if (duration != null && duration != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).hide(duration);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).hide();
}
}
},
remove: function(element) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).remove();
}
},
detach: function(element) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).detach();
}
},
append: function(element, value) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).append(value);
}
},
prepend: function(element, value) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).prepend(value);
}
},
show: function(element, duration) {
if (duration != null && duration != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).show(duration);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).show();
}
}
},
load: function(element, callback_function, event_data) {
var _event_data = {elem:element}; // return element by default
if (_event_data != null && _event_data != "") {
_event_data = event_data;
}
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).load(_event_data, callback_function);
}
},
addClass: function(element, cName) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).addClass(cName);
}
},
removeClass: function(element, cName) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).removeClass(cName);
}
},
attr: function(element, aName, value) {
if (value != null && value != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).attr(aName, value);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).attr(aName);
}
}
},
prop: function(element, aName, value) {
if (typeof jQuery == 'undefined' || !/[1-9]\.[3-9].[1-9]/.test(jQuery.fn.jquery)) {
VMM.Lib.attribute(element, aName, value);
} else {
jQuery(element).prop(aName, value);
}
},
attribute: function(element, aName, value) {
if (value != null && value != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).attr(aName, value);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).attr(aName);
}
}
},
visible: function(element, show) {
if (show != null) {
if( typeof( jQuery ) != 'undefined' ){
if (show) {
jQuery(element).show(0);
} else {
jQuery(element).hide(0);
}
}
} else {
if( typeof( jQuery ) != 'undefined' ){
if ( jQuery(element).is(':visible')){
return true;
} else {
return false;
}
}
}
},
css: function(element, prop, value) {
if (value != null && value != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).css(prop, value);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).css(prop);
}
}
},
cssmultiple: function(element, propval) {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).css(propval);
}
},
offset: function(element) {
var p;
if( typeof( jQuery ) != 'undefined' ){
p = jQuery(element).offset();
}
return p;
},
position: function(element) {
var p;
if( typeof( jQuery ) != 'undefined' ){
p = jQuery(element).position();
}
return p;
},
width: function(element, s) {
if (s != null && s != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).width(s);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).width();
}
}
},
height: function(element, s) {
if (s != null && s != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).height(s);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).height();
}
}
},
toggleClass: function(element, cName) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).toggleClass(cName);
}
},
each:function(element, return_function) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).each(return_function);
}
},
html: function(element, str) {
var e;
if( typeof( jQuery ) != 'undefined' ){
e = jQuery(element).html();
return e;
}
if (str != null && str != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).html(str);
}
} else {
var e;
if( typeof( jQuery ) != 'undefined' ){
e = jQuery(element).html();
return e;
}
}
},
find: function(element, selec) {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).find(selec);
}
},
stop: function(element) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).stop();
}
},
animate: function(element, duration, ease, att, callback_function) {
var _ease = "easein";
var _duration = 1000;
var _att = {};
if (duration != null) {
if (duration < 1) {
_duration = 1;
} else {
_duration = Math.round(duration);
}
}
if (ease != null && ease != "") {
_ease = ease;
}
if (att != null) {
_att = att
} else {
_att = {opacity: 0}
}
if (VMM.Browser.device == "mobile" || VMM.Browser.device == "tablet") {
var _tdd = Math.round((_duration/1500)*10)/10
var __duration = _tdd + 's';
VMM.Lib.css(element, '-webkit-transition', 'all '+ __duration + ' ease');
VMM.Lib.css(element, '-moz-transition', 'all '+ __duration + ' ease');
VMM.Lib.css(element, '-o-transition', 'all '+ __duration + ' ease');
VMM.Lib.css(element, '-ms-transition', 'all '+ __duration + ' ease');
VMM.Lib.css(element, 'transition', 'all '+ __duration + ' ease');
VMM.Lib.cssmultiple(element, _att);
//callback_function();
/*
if( typeof( jQuery ) != 'undefined' ){
if (callback_function != null && callback_function != "") {
jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease, complete:callback_function} );
} else {
jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease} );
}
}
*/
} else {
if( typeof( jQuery ) != 'undefined' ){
if (callback_function != null && callback_function != "") {
jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease, complete:callback_function} );
} else {
jQuery(element).animate(_att, {queue:false, duration:_duration, easing:_ease} );
}
}
}
},
}
}
if( typeof( jQuery ) != 'undefined' ){
/* XDR AJAX EXTENTION FOR jQuery
https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js
================================================== */
(function( jQuery ) {
if ( window.XDomainRequest ) {
jQuery.ajaxTransport(function( s ) {
if ( s.crossDomain && s.async ) {
if ( s.timeout ) {
s.xdrTimeout = s.timeout;
delete s.timeout;
}
var xdr;
return {
send: function( _, complete ) {
function callback( status, statusText, responses, responseHeaders ) {
xdr.onload = xdr.onerror = xdr.ontimeout = jQuery.noop;
xdr = undefined;
complete( status, statusText, responses, responseHeaders );
}
xdr = new XDomainRequest();
xdr.open( s.type, s.url );
xdr.onload = function() {
callback( 200, "OK", { text: xdr.responseText }, "Content-Type: " + xdr.contentType );
};
xdr.onerror = function() {
callback( 404, "Not Found" );
};
if ( s.xdrTimeout ) {
xdr.ontimeout = function() {
callback( 0, "timeout" );
};
xdr.timeout = s.xdrTimeout;
}
xdr.send( ( s.hasContent && s.data ) || null );
},
abort: function() {
if ( xdr ) {
xdr.onerror = jQuery.noop();
xdr.abort();
}
}
};
}
});
}
})( jQuery );
/* jQuery Easing v1.3
http://gsgd.co.uk/sandbox/jquery/easing/
================================================== */
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing, {
def: 'easeOutQuad',
swing: function (x, t, b, c, d) {
//alert(jQuery.easing.default);
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
},
easeInExpo: function (x, t, b, c, d) {
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
},
easeOutExpo: function (x, t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
easeInQuad: function (x, t, b, c, d) {
return c*(t/=d)*t + b;
},
easeOutQuad: function (x, t, b, c, d) {
return -c *(t/=d)*(t-2) + b;
},
easeInOutQuad: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
},
});
}

247
source/js/VMM.LoadLib.js

@ -1,247 +0,0 @@
/*
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.
================================================== */
window.loadedJS = [];
if(typeof VMM != 'undefined' && typeof VMM.LoadLib == 'undefined') {
//VMM.LoadLib.js('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', onJQueryLoaded);
//VMM.LoadLib.css('http://someurl.css', onCSSLoaded);
VMM.LoadLib = (function (doc) {
var env,
head,
pending = {},
pollCount = 0,
queue = {css: [], js: []},
styleSheets = doc.styleSheets;
var loaded_Array = [];
function isLoaded(url) {
var has_been_loaded = false;
for(var i=0; i<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;
}
function createNode(name, attrs) {
var node = doc.createElement(name), attr;
for (attr in attrs) {
if (attrs.hasOwnProperty(attr)) {
node.setAttribute(attr, attrs[attr]);
}
}
return node;
}
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);
}
},
js: function (urls, callback, obj, context) {
if (isLoaded(urls)) {
return callback;
} else {
load('js', urls, callback, obj, context);
}
}
};
})(this.document);
}

163
source/js/VMM.Media.js

@ -1,163 +0,0 @@
/* 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");
if (data.media != null && data.media != "") {
_valid = true;
var m = {};
m = VMM.MediaType(data.media); //returns an object with .type and .id
if (m.type == "image") {
VMM.appendElement($mediacontainer, "<img src='" + m.id + "'>");
} else if (m.type == "youtube") {
VMM.appendElement($mediacontainer, "<iframe frameborder='0' src='http://www.youtube.com/embed/" + m.id + "?&rel=0&theme=light&showinfo=0&hd=1&autohide=0&color=white' allowfullscreen>");
} else if (m.type == "vimeo") {
VMM.appendElement($mediacontainer, "<iframe frameborder='0' src='http://player.vimeo.com/video/" + m.id + "?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff'>");
} else {
}
// CREDIT
if (data.credit != null && data.credit != "") {
VMM.appendElement($container, VMM.createElement("div", data.credit, "credit"));
}
// CAPTION
if (data.caption != null && data.caption != "") {
VMM.appendElement($container, VMM.createElement("div", data.caption, "caption"));
}
}
};
/* GETTERS AND SETTERS
================================================== */
this.setData = function(d) {
if(typeof d != 'undefined') {
data = d;
build();
} else{
trace("NO DATA");
}
};
/* RESIZE
================================================== */
function reSize() {
}
}
// Less expensive to use prototype
VMM.Media.prototype.height = function(h) {
if (h != null && h != "") {
config.height = h;
reSize();
} else {
return config.height;
}
};
VMM.Media.prototype.width = function(w) {
if (w != null && w != "") {
config.width = w;
reSize();
} else {
return config.width;
}
};
/* GETTERS AND SETTERS
================================================== */
VMM.Media.prototype.getData = function() {
return data;
};
VMM.Media.prototype.setConfig = function(d) {
if(typeof d != 'undefined') {
config = d;
} else{
trace("NO CONFIG DATA");
}
};
VMM.Media.prototype.getConfig = function() {
return config;
};
VMM.Media.prototype.setSize = function(w, h) {
if (w != null) {config.width = w};
if (h != null) {config.height = h};
if (_active) {
reSize();
}
}
VMM.Media.prototype.active = function() {
return _active;
};
}

186
source/js/VMM.MediaElement.js

@ -1,186 +0,0 @@
/* 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' id='flickr_" + m.id + "_thumb'></div>";
return mediaElem;
} else if (m.type == "youtube") {
mediaElem = "<div class='thumbnail thumb-youtube' id='youtube_" + m.id + "_thumb'></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' id='vimeo_" + m.id + "_thumb'></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;
} else if (m.type == "wikipedia") {
mediaElem = "<div class='thumbnail thumb-wikipedia'></div>";
return mediaElem;
} 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;
var _id = "";
_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 = "<div class='media-image media-shadow'><img src='" + m.id + "' class='media-image'></div>";
// FLICKR
} else if (m.type == "flickr") {
_id = "flickr_" + m.id;
mediaElem = "<div class='media-image media-shadow'><a href='" + m.link + "' target='_blank'><img id='" + _id + "_large" + "'></a></div>";
VMM.ExternalAPI.flickr.get(m.id, "#" + _id);
// GOOGLE DOCS
} else if (m.type == "googledoc") {
_id = "googledoc_" + VMM.Util.unique_ID(5);
mediaElem = "<div class='media-frame media-shadow doc' id='" + _id + "'><span class='messege'><p>Loading Document</p></span></div>";
VMM.ExternalAPI.googledocs.get(m.id, _id);
// YOUTUBE
} else if (m.type == "youtube") {
mediaElem = "<div class='media-shadow'><div class='media-frame video youtube' id='youtube_" + m.id + "'><span class='messege'><p>Loading YouTube video</p></span></div></div>";
VMM.ExternalAPI.youtube.get(m.id);
// VIMEO
} else if (m.type == "vimeo") {
mediaElem = "<div class='media-shadow'><iframe class='media-frame video vimeo' autostart='false' frameborder='0' width='100%' height='100%' src='http://player.vimeo.com/video/" + m.id + "?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff'></iframe></div>";
VMM.ExternalAPI.vimeo.get(m.id);
// DAILYMOTION
} else if (m.type == "dailymotion") {
mediaElem = "<div class='media-shadow'><iframe class='media-frame video dailymotion' autostart='false' frameborder='0' width='100%' height='100%' src='http://www.dailymotion.com/embed/video/" + m.id + "'></iframe></div>";
// 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") {
isTextMedia = true;
mediaElem = m.id;
// SOUNDCLOUD
} else if (m.type == "soundcloud") {
_id = "soundcloud_" + VMM.Util.unique_ID(5);
mediaElem = "<div class='media-frame media-shadow soundcloud' id='" + _id + "'><span class='messege'><p>Loading Sound</p></span></div>";
VMM.ExternalAPI.soundcloud.get(m.id, _id);
// GOOGLE MAPS
} else if (m.type == "google-map") {
_id = "googlemap_" + VMM.Util.unique_ID(7);
mediaElem = "<div class='media-frame media-shadow 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);
mediaElem = "<div class='wikipedia' id='" + _id + "'><span class='messege'><p>Loading Wikipedia</p></span></div>";
isTextMedia = true;
VMM.ExternalAPI.wikipedia.get(m.id, _id);
// UNKNOWN
} else if (m.type == "unknown") {
trace("NO KNOWN MEDIA TYPE FOUND TRYING TO JUST PLACE THE HTML");
isTextMedia = true;
mediaElem = "<div class='plain-text'><div class='container'>" + VMM.Util.properQuotes(m.id) + "</div></div>";
// WEBSITE
} else if (m.type == "website") {
mediaElem = "<div class='media-shadow'><iframe class='media-frame website' frameborder='0' autostart='false' width='100%' height='100%' scrolling='yes' marginheight='0' marginwidth='0' src='" + m.id + "'></iframe></div>";
//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='text-media'><div class='media-wrapper'>" + mediaElem + "</div></div>";
} else {
return "<div class='media-wrapper'>" + mediaElem + "</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();
}

88
source/js/VMM.MediaType.js

@ -1,88 +0,0 @@
/* MediaType
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.MediaType == 'undefined') {
//VMM.mediaType.youtube(d); //should return a true or false
// VMM.MediaType(url); //returns an object with .type and .id
VMM.MediaType = function(d) {
var success = false;
var media = {};
if (d.match("div class='twitter'")) {
media.type = "twitter-ready";
media.id = d;
success = true;
} else if (d.match('(www.)?youtube|youtu\.be')) {
if (d.match('v=')) {
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;
} else if (d.match('(www.)?wikipedia\.org')) {
media.type = "wikipedia";
//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");
success = true;
} else if (d.indexOf('http://') == 0) {
media.type = "website";
media.id = d;
success = true;
} else {
trace("unknown media");
media.type = "unknown";
media.id = d;
success = true;
}
if (success) {
return media;
} else {
trace("No valid media id detected");
trace(d);
}
return false;
}
}

198
source/js/VMM.Slider.Slide.js

@ -1,198 +0,0 @@
/* Slider Slide
================================================== */
if (typeof VMM.Slider != 'undefined') {
// VMM.Slider.Slide(element, data)
VMM.Slider.Slide = function(d, _parent) {
var data = d;
var slide = {};
var media = "";
var loaded = false;
var preloaded = false;
var is_skinny = false;
var element = VMM.appendAndGetElement(_parent, "<div>", "slider-item");
var c = {slide:"", text: "", media: "", media_element: "", layout: "content-container layout", has: { headline: false, text: false, media: false }};
var $media, $text, $slide, $wrap;
/* PUBLIC
================================================== */
this.show = function(skinny) {
if (!loaded) {
if (preloaded) {
reLayout(skinny);
} else {
render(skinny);
}
}
};
this.hide = function() {
if (loaded) {
removeSlide();
}
};
this.layout = function(skinny) {
if (loaded && preloaded) {
reLayout(skinny);
}
};
this.elem = function() {
return element;
};
this.position = function() {
return VMM.Lib.position(element);
};
this.leftpos = function(p) {
if(typeof p != 'undefined') {
VMM.Lib.css(element, "left", p);
} else {
return VMM.Lib.position(element).left
}
};
this.animate = function(d, e, p) {
VMM.Lib.animate(element, d, e, p);
};
this.css = function(p, v) {
VMM.Lib.css(element, p, v );
}
this.opacity = function(p) {
VMM.Lib.css(element, "opacity", p);
}
this.width = function() {
return VMM.Lib.width(element);
};
this.height = function() {
return VMM.Lib.height(element);
};
this.content_height = function () {
var ch = VMM.Lib.find( element, ".content")[0];
if (ch != 'undefined' && ch != null) {
return VMM.Lib.height(ch);
} else {
return 0;
}
}
/* PRIVATE
================================================== */
var render = function(skinny) {
buildSlide(skinny);
loaded = true;
preloaded = true;
var timer = setTimeout(VMM.ExternalAPI.pushQues, 500);
};
var removeSlide = function() {
//VMM.attachElement(element, "");
loaded = false;
}
var reLayout = function(skinny) {
if (c.has.text) {
if (skinny) {
if (!is_skinny) {
VMM.Lib.removeClass($slide, "pad-left");
VMM.Lib.detach($text);
VMM.Lib.prepend($slide, $text);
is_skinny = true;
}
} else {
if (is_skinny) {
VMM.Lib.addClass($slide, "pad-left");
VMM.Lib.detach($text);
VMM.Lib.append($slide, $text);
is_skinny = false
}
}
}
}
var buildSlide = function(skinny) {
$wrap = VMM.appendAndGetElement(element, "<div>", "content");
$slide = VMM.appendAndGetElement($wrap, "<div>");
/* DATE
================================================== */
if (data.startdate != null && data.startdate != "") {
if (type.of(data.startdate) == "date") {
if (data.type != "start") {
var st = data.startdate_str;
var en = data.enddate_str;
if (st != en) {
c.text += VMM.createElement("h2", st + " &mdash; " + en + "", "date");
} else {
c.text += VMM.createElement("h2", st, "date");
}
}
}
}
/* HEADLINE
================================================== */
if (data.headline != null && data.headline != "") {
c.has.headline = true;
if (data.type == "start") {
c.text += VMM.createElement("h2", VMM.Util.linkify_with_twitter(data.headline, "_blank"), "start");
} else {
c.text += VMM.createElement("h3", VMM.Util.linkify_with_twitter(data.headline, "_blank"));
}
}
/* TEXT
================================================== */
if (data.text != null && data.text != "") {
c.has.text = true;
c.text += VMM.createElement("p", VMM.Util.linkify_with_twitter(data.text, "_blank"));
}
if (c.has.text || c.has.headline) {
c.text = VMM.createElement("div", c.text, "container");
$text = VMM.appendAndGetElement($slide, "<div>", "text", c.text);
}
/* MEDIA
================================================== */
if (data.asset != null && data.asset != "") {
if (data.asset.media != null && data.asset.media != "") {
c.has.media = true;
$media = VMM.appendAndGetElement($slide, "<div>", "media", VMM.MediaElement.create(data.asset));
}
}
/* COMBINE
================================================== */
if (c.has.text) { c.layout += "-text" };
if (c.has.media){ c.layout += "-media" };
if (c.has.text) {
if (skinny) {
VMM.Lib.addClass($slide, c.layout);
is_skinny = true;
} else {
VMM.Lib.addClass($slide, c.layout);
VMM.Lib.addClass($slide, "pad-left");
VMM.Lib.detach($text);
VMM.Lib.append($slide, $text);
}
} else {
VMM.Lib.addClass($slide, c.layout);
}
};
}
};

629
source/js/VMM.Slider.js

@ -1,629 +0,0 @@
/* Slider
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.Slider == 'undefined') {
VMM.Slider = function(parent, parent_config) {
var events = {}, config;
var $slider, $slider_mask, $slider_container, $slides_items;
var data = [], slides = [], slide_positions = [];
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;
// 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
}
}
};
}
/* PUBLIC VARS
================================================== */
this.ver = "0.6";
config.slider.width = config.width;
config.slider.height = config.height;
/* PUBLIC FUNCTIONS
================================================== */
this.init = function(d) {
slides = [];
slide_positions = [];
if(typeof d != 'undefined') {
this.setData(d);
} else {
trace("WAITING ON DATA");
}
};
this.width = function(w) {
if (w != null && w != "") {
config.slider.width = w;
reSize();
} else {
return config.slider.width;
}
}
this.height = function(h) {
if (h != null && h != "") {
config.slider.height = h;
reSize();
} else {
return config.slider.height;
}
}
/* GETTERS AND SETTERS
================================================== */
this.setData = function(d) {
if(typeof d != 'undefined') {
data = d;
build();
} else{
trace("NO DATA");
}
};
this.getData = function() {
return data;
};
this.setConfig = function(d) {
if(typeof d != 'undefined') {
config = d;
} else{
trace("NO CONFIG DATA");
}
}
this.getConfig = function() {
return config;
};
this.setSize = function(w, h) {
if (w != null) {config.slider.width = w};
if (h != null) {config.slider.height = h};
if (_active) {
reSize();
}
}
this.active = function() {
return _active;
};
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) {
var _go_to_slide = true;
var _from_start = false;
if (go_to_slide != null) {_go_to_slide = go_to_slide};
if (from_start != null) {_from_start = from_start};
current_width = config.slider.width;
config.slider.nav.height = VMM.Lib.height(navigation.prevBtnContainer);
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);
}
// RESIZE SLIDES
sizeSlides();
// POSITION SLIDES
positionSlides();
// 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) ) + 10 );
VMM.Lib.css(navigation.prevBtnContainer, "top", ( (config.slider.height/2) - (config.slider.nav.height/2) ) + 10 );
// 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
},
text: {
width: ((config.slider.content.width/100) * 40) - 30,
height: config.slider.height
}
},
media: {
width: config.slider.content.width,
height: config.slider.height - 110,
video: {
width: 0,
height: 0
}
}
}
VMM.master_config.sizes.api.width = mediasize.media.width;
VMM.master_config.sizes.api.height = mediasize.media.height;
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 <= 640) {
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) {
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;
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 .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 );
VMM.Lib.css(".slider-item .layout-text-media .media", "float", "none" );
VMM.Lib.addClass(".slider-item .content-container", "pad-top");
VMM.Lib.css(".slider-item .media blockquote p", "line-height", "18px" );
VMM.Lib.css(".slider-item .media blockquote p", "font-size", "16px" );
VMM.Lib.css(".slider-item", "overflow-y", "auto" );
} else {
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" );
VMM.Lib.css(".slider-item .layout-text-media .text .container .start", "width", mediasize.text_media.text.width );
//VMM.Lib.addClass(".slider-item .content-container", "pad-left");
VMM.Lib.removeClass(".slider-item .content-container", "pad-top");
VMM.Lib.css(".slider-item .layout-text-media .media", "float", "left" );
VMM.Lib.css(".slider-item .layout-text-media", "display", "table" );
VMM.Lib.css(".slider-item .media blockquote p", "line-height", "36px" );
VMM.Lib.css(".slider-item .media blockquote p", "font-size", "28px" );
VMM.Lib.css(".slider-item", "display", "table" );
VMM.Lib.css(".slider-item", "overflow-y", "auto" );
}
// 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);
// 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 );
// 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 );
// 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);
// 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 );
// 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);
// MAINTAINS VERTICAL CENTER IF IT CAN
for(var i = 0; i < slides.length; i++) {
slides[i].layout(is_skinny);
if (slides[i].content_height() > config.slider.height + 20) {
slides[i].css("display", "block");
} else {
slides[i].css("display", "table");
}
}
}
/* POSITION SLIDES
================================================== */
var positionSlides = function() {
var pos = 0;
for(var i = 0; i < slides.length; i++) {
pos = i * (config.slider.width+config.spacing);
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) {
slides[i].animate(config.duration, _ease, {"opacity": 1});
} else if (i == current_slide - 1 || i == current_slide + 1) {
slides[i].animate(config.duration, _ease, {"opacity": 0.1});
} else {
slides[i].opacity(n);
}
}
}
/* GO TO SLIDE
goToSlide(n, ease, duration);
================================================== */
var goToSlide = function(n, ease, duration, fast, firstrun) {
/* STOP ANY VIDEO PLAYERS ACTIVE
================================================== */
VMM.ExternalAPI.youtube.stopPlayers();
// Set current slide
current_slide = n;
var _ease = config.ease;
var _duration = config.duration;
var is_last = false;
var is_first = false;
var _pos = slides[current_slide].leftpos();
var _title = "";
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};
/* set proper nav titles and dates etc.
================================================== */
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].startdate_str);
VMM.attachElement(navigation.prevTitle, _title);
}
} else {
VMM.attachElement(navigation.prevTitle, _title);
}
}
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].startdate_str);
VMM.attachElement(navigation.nextTitle, _title);
}
} else {
VMM.attachElement(navigation.nextTitle, _title);
}
}
/* 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)});
}
if (firstrun) {
VMM.fireEvent(layout, "LOADED");
}
/* SET Vertical Scoll
================================================== */
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) });
}
preloadSlides();
}
/* BUILD NAVIGATION
================================================== */
var buildNavigation = function() {
var temp_icon = "<div class='icon'>&nbsp;</div>";
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");
VMM.bindEvent(".nav-next", onNextClick);
VMM.bindEvent(".nav-previous", onPrevClick);
VMM.bindEvent(window, onKeypressNav, 'keydown');
}
/* BUILD
================================================== */
var build = function() {
// Clear out existing content
VMM.attachElement(layout, "");
// 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");
// BUILD NAVIGATION
buildNavigation();
// ATTACH SLIDES
buildSlides(data);
/* MAKE SLIDER TOUCHABLE
================================================== */
var __duration = 3000;
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") {
} else {
//VMM.DragSlider.createPanel($slider_container, $slider_container, VMM.Lib.width(slides[0]), config.spacing, true);
}
reSize(false, true);
VMM.Lib.visible(navigation.prevBtn, false);
goToSlide(config.current_slide, "easeOutExpo", __duration, true, true);
_active = true;
};
};
}
Loading…
Cancel
Save