From ffc9883282e53335dac6539d6cba850857649a87 Mon Sep 17 00:00:00 2001 From: Zach Wise Date: Wed, 23 May 2012 10:16:31 -0500 Subject: [PATCH] Organizational changes --- source/js/VMM.TouchSlider.js | 190 -------- source/js/VMM.Util.js | 813 ----------------------------------- source/js/VMM.js | 333 -------------- 3 files changed, 1336 deletions(-) delete mode 100644 source/js/VMM.TouchSlider.js delete mode 100644 source/js/VMM.Util.js delete mode 100644 source/js/VMM.js diff --git a/source/js/VMM.TouchSlider.js b/source/js/VMM.TouchSlider.js deleted file mode 100644 index 1d0b713..0000000 --- a/source/js/VMM.TouchSlider.js +++ /dev/null @@ -1,190 +0,0 @@ -/* TOUCH SLIDER -================================================== */ -if(typeof VMM != 'undefined' && typeof VMM.TouchSlider == 'undefined') { - - // VMM.TouchSlider.createSlidePanel(touch_object, move_object, w, padding, vertical, h) ; - VMM.TouchSlider = { - createPanel: function(touch_object, move_object, w, padding, vertical, h) { - VMM.TouchSlider.vertical = false; - VMM.TouchSlider.vertical = vertical; - - var x = padding; - VMM.TouchSlider.width = w; - VMM.TouchSlider.height = h; - VMM.TouchSlider.makeTouchable(touch_object, move_object); - /* - if (sticky != null && sticky != "") { - VMM.TouchSlider.sticky = sticky; - } else { - VMM.TouchSlider.sticky = false; - } - */ - // VMM.TouchSlider.sticky = sticky; - - }, - - removePanel: function(touch_object) { - VMM.unbindEvent(touch_object, VMM.TouchSlider.onTouchStart, "touchstart"); - VMM.unbindEvent(touch_object, VMM.TouchSlider.onTouchMove, "touchmove"); - VMM.unbindEvent(touch_object, VMM.TouchSlider.onTouchEnd, "touchend"); - }, - - makeTouchable: function(touch_object, move_object) { - VMM.bindEvent(touch_object, VMM.TouchSlider.onTouchStart, "touchstart", {element: move_object}); - VMM.bindEvent(touch_object, VMM.TouchSlider.onTouchMove, "touchmove", {element: move_object}); - VMM.bindEvent(touch_object, VMM.TouchSlider.onTouchEnd, "touchend", {element: move_object}); - }, - onTouchStart: function(e) { - VMM.TouchSlider.touchStart(e.data.element, e); - e.stopPropagation(); - return true; - }, - onTouchEnd: function(e) { - e.stopPropagation(); - - if (VMM.TouchSlider.sliding) { - VMM.TouchSlider.sliding = false; - VMM.TouchSlider.touchEnd(e.data.element, e); - return false; - } else { - return true; - } - - }, - onTouchMove: function(e) { - VMM.TouchSlider.touchMove(e.data.element, e); - e.preventDefault(); - e.stopPropagation(); - return false; - }, - getLeft: function(elem) { - return parseInt(VMM.Lib.css(elem, 'left').substring(0, VMM.Lib.css(elem, 'left').length - 2), 10); - }, - getTop: function(elem) { - return parseInt(VMM.Lib.css(elem, 'top').substring(0, VMM.Lib.css(elem, 'top').length - 2), 10); - }, - touchStart: function(elem, e) { - - VMM.Lib.css(elem, '-webkit-transition-duration', '0'); - - VMM.TouchSlider.startX = e.originalEvent.touches[0].screenX; - VMM.TouchSlider.startY = e.originalEvent.touches[0].screenY; - - VMM.TouchSlider.startLeft = VMM.TouchSlider.getLeft(elem); - VMM.TouchSlider.startTop = VMM.TouchSlider.getTop(elem); - - VMM.TouchSlider.touchStartTime = new Date().getTime(); - - }, - touchEnd: function(elem, e) { - if (VMM.TouchSlider.getLeft(elem) > 0) { - - //This means they dragged to the right past the first item - - if (VMM.TouchSlider.vertical) { - VMM.Lib.animate(elem, 1000, "", {"top": 0}); - } else { - VMM.Lib.animate(elem, 1000, "", {"left": 0}); - } - - VMM.TouchSlider.startX = null; - VMM.TouchSlider.startY = null; - - VMM.fireEvent(elem, "TOUCHUPDATE", [0]); - - } else { - //This means they were just dragging within the bounds of the grid and we just need to handle the momentum and snap to the grid. - VMM.TouchSlider.slideMomentum(elem, e); - } - }, - slideMomentum: function(elem, e) { - var slideAdjust = (new Date().getTime() - VMM.TouchSlider.touchStartTime) * 10; - var timeAdjust = slideAdjust; - - var left = VMM.TouchSlider.getLeft(elem); - var top = VMM.TouchSlider.getTop(elem); - - var changeX = 6000 * (Math.abs(VMM.TouchSlider.startLeft) - Math.abs(left)); - var changeY = 6000 * (Math.abs(VMM.TouchSlider.startTop) - Math.abs(top)); - - slideAdjust = Math.round(changeX / slideAdjust); - slideAdjustY = Math.round(changeY / slideAdjust); - - var newLeft = slideAdjust + left; - var newTop = slideAdjustY + top; - - var y = newTop % VMM.TouchSlider.height; - var t = newLeft % VMM.TouchSlider.width; - - - var _r_object = { - top: Math.min(0, newTop), - left: Math.min(0, newLeft), - time: timeAdjust - } - VMM.fireEvent(elem, "TOUCHUPDATE", [_r_object]); - /* - if (VMM.TouchSlider.sticky) { - trace("sticky"); - if ((Math.abs(t)) > ((VMM.TouchSlider.width / 2))) { - //Show the next cell - newLeft -= (VMM.TouchSlider.width - Math.abs(t)); - } else { - //Stay on the current cell - newLeft -= t; - } - - VMM.fireEvent(elem, "TOUCHUPDATE", [Math.min(0, newLeft)]); - - } else { - trace("not sticky"); - //VMM.TouchSlider.doSlide(elem, Math.min(0, newLeft), '0.5s'); - VMM.Lib.animate(elem, 500, "", {"left": Math.min(0, newLeft)}); - } - */ - - VMM.TouchSlider.startX = null; - VMM.TouchSlider.startY = null; - - }, - doSlide: function(elem, x, duration) { - VMM.Lib.css(elem, '-webkit-transition-property', 'left'); - VMM.Lib.css(elem, '-webkit-transition-duration', duration); - VMM.Lib.css(elem, 'left', x); - }, - touchMove: function(elem, e) { - - if (!VMM.TouchSlider.sliding) { - //elem.parent().addClass('sliding'); - } - - VMM.TouchSlider.sliding = true; - - if (VMM.TouchSlider.vertical) { - - if (VMM.TouchSlider.startY > e.originalEvent.touches[0].screenY) { - VMM.Lib.css(elem, 'top', -(VMM.TouchSlider.startY - e.originalEvent.touches[0].screenY - VMM.TouchSlider.startTop)); - VMM.TouchSlider.slidingTop = true; - } else { - var top = (e.originalEvent.touches[0].screenY - VMM.TouchSlider.startY + VMM.TouchSlider.startTop); - VMM.Lib.css(elem, 'top', -(VMM.TouchSlider.startY - e.originalEvent.touches[0].screenY - VMM.TouchSlider.startTop)); - VMM.TouchSlider.slidingTop = false; - } - - } else { - - if (VMM.TouchSlider.startX > e.originalEvent.touches[0].screenX) { - VMM.Lib.css(elem, 'left', -(VMM.TouchSlider.startX - e.originalEvent.touches[0].screenX - VMM.TouchSlider.startLeft)); - VMM.TouchSlider.slidingLeft = true; - } else { - var left = (e.originalEvent.touches[0].screenX - VMM.TouchSlider.startX + VMM.TouchSlider.startLeft); - VMM.Lib.css(elem, 'left', -(VMM.TouchSlider.startX - e.originalEvent.touches[0].screenX - VMM.TouchSlider.startLeft)); - VMM.TouchSlider.slidingLeft = false; - } - - } - - - } - } -} \ No newline at end of file diff --git a/source/js/VMM.Util.js b/source/js/VMM.Util.js deleted file mode 100644 index b585cab..0000000 --- a/source/js/VMM.Util.js +++ /dev/null @@ -1,813 +0,0 @@ -/* Utilities and Useful Functions -================================================== */ -if(typeof VMM != 'undefined' && typeof VMM.Util == 'undefined') { - - VMM.Util = ({ - - init: function() { - return this; - }, - - /* CORRECT PROTOCOL (DOES NOT WORK) - ================================================== */ - correctProtocol: function(url) { - var loc = (window.parent.location.protocol).toString(); - var prefix = ""; - var _url = url.split("://", 2); - - if (loc.match("http")) { - prefix = loc; - } else { - prefix = "https"; - } - - return prefix + "://" + _url[1]; - - }, - - /* GET OBJECT ATTRIBUTE BY INDEX - ================================================== */ - getObjectAttributeByIndex: function(obj, index) { - if(typeof obj != 'undefined') { - var i = 0; - for (var attr in obj){ - if (index === i){ - return obj[attr]; - } - i++; - } - return ""; - } else { - return ""; - } - - }, - /* RANDOM BETWEEN - ================================================== */ - //VMM.Util.randomBetween(1, 3) - randomBetween: function(min, max) { - return Math.floor(Math.random() * (max - min + 1) + min); - }, - - /* AVERAGE - http://jsfromhell.com/array/average - var x = VMM.Util.average([2, 3, 4]); - VMM.Util.average([2, 3, 4]).mean - ================================================== */ - average: function(a) { - var r = {mean: 0, variance: 0, deviation: 0}, t = a.length; - for(var m, s = 0, l = t; l--; s += a[l]); - for(m = r.mean = s / t, l = t, s = 0; l--; s += Math.pow(a[l] - m, 2)); - return r.deviation = Math.sqrt(r.variance = s / t), r; - }, - - /* CUSTOM SORT - ================================================== */ - customSort: function(a, b) { - var a1= a, b1= b; - if(a1== b1) return 0; - return a1> b1? 1: -1; - }, - - /* Remove Duplicates from Array - ================================================== */ - deDupeArray: function(arr) { - var i, - len=arr.length, - out=[], - obj={}; - - for (i=0;i 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); - } - } - }, - - date: { - - 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'
'mmmm d',' yyyy''", - full_long: "mmm d',' yyyy 'at' hh:MM TT", - full_long_small_date: "hh:MM TT'
mmm d',' yyyy''", - }, - - month: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], - month_abbr: ["Jan.", "Feb.", "March", "April", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."], - day: ["Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], - day_abbr: ["Sun.","Mon.", "Tues.", "Wed.", "Thurs.", "Fri.", "Sat."], - hour: [1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12], - hour_suffix: ["am"], - - //B.C. - bc_format: { - year: "yyyy", - month_short: "mmm", - month: "mmmm yyyy", - full_short: "mmm d", - full: "mmmm d',' yyyy", - time_no_seconds_short: "h:MM TT", - time_no_seconds_small_date: "dddd', 'h:MM TT'
'mmmm d',' yyyy''", - full_long: "dddd',' mmm d',' yyyy 'at' hh:MM TT", - full_long_small_date: "hh:MM TT'
'dddd',' mmm d',' yyyy''", - }, - - 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); - }, - - parse: function(d) { - if (type.of(d) == "date") { - return d; - } else { - 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; - } - }, - - 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; - } - - 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; - } - } - - }, - - // 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). - ================================================== */ - truncateWords: function(s, min, max) { - - if (!min) min = 30; - if (!max) max = min; - - var initial_whitespace_rExp = /^[^A-Za-z0-9\'\-]+/gi; - var left_trimmedStr = s.replace(initial_whitespace_rExp, ""); - var words = left_trimmedStr.split(" "); - - var result = []; - - min = Math.min(words.length, min); - max = Math.min(words.length, max); - - for (var i = 0; i$&") - .replace(pseudoUrlPattern, "$1$2") - .replace(emailAddressPattern, "$1"); - }, - - linkify_with_twitter: function(text,targets,is_touch) { - - // http://, https://, ftp:// - var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim; - var url_pattern = /(\()((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(\))|(\[)((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(\])|(\{)((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(\})|(<|&(?:lt|#60|#x3c);)((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(>|&(?:gt|#62|#x3e);)|((?:^|[^=\s'"\]])\s*['"]?|[^=\s]\s+)(\b(?:ht|f)tps?:\/\/[a-z0-9\-._~!$'()*+,;=:\/?#[\]@%]+(?:(?!&(?:gt|#0*62|#x0*3e);|&(?:amp|apos|quot|#0*3[49]|#x0*2[27]);[.!&',:?;]?(?:[^a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]|$))&[a-z0-9\-._~!$'()*+,;=:\/?#[\]@%]*)*[a-z0-9\-_~$()*+=\/#[\]@%])/img; - var url_replace = '$1$4$7$10$13$2$5$8$11$14$3$6$9$12'; - - // www. sans http:// or https:// - var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim; - function replaceURLWithHTMLLinks(text) { - var exp = /(\b(https?|ftp|file):\/\/([-A-Z0-9+&@#%?=~_|!:,.;]*)([-A-Z0-9+&@#%?\/=~_|!:,.;]*)[-A-Z0-9+&@#\/%=~_|])/ig; - return text.replace(exp, "$3"); - } - // 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; - - return text - //.replace(urlPattern, "$&") - .replace(url_pattern, url_replace) - .replace(pseudoUrlPattern, "$1$2") - .replace(emailAddressPattern, "$1") - .replace(twitterHandlePattern, "$1") - .replace(twitterSearchPattern, "$1"); - }, - - linkify_wikipedia: function(text) { - - var urlPattern = /]*>(.*?)<\/i>/gim; - return text - .replace(urlPattern, "$&") - .replace(/]*>/gim, "") - .replace(/<\/i>/gim, "") - .replace(/]*>/gim, "") - .replace(/<\/b>/gim, ""); - }, - /* Turns plain text links into real links - ================================================== */ - // VMM.Util.unlinkify(); - unlinkify: function(text) { - if(!text) return text; - text = text.replace(/]*>/i,""); - text = text.replace(/<\/a>/i, ""); - return text; - }, - - /* TK - ================================================== */ - nl2br: function(text) { - return text.replace(/(\r\n|[\r\n]|\\n|\\r)/g,"
"); - }, - - /* Generate a Unique ID - ================================================== */ - // VMM.Util.unique_ID(size); - unique_ID: function(size) { - - var getRandomNumber = function(range) { - return Math.floor(Math.random() * range); - }; - - var getRandomChar = function() { - var chars = "abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ"; - return chars.substr( getRandomNumber(62), 1 ); - }; - - var randomID = function(size) { - var str = ""; - for(var i = 0; i < size; i++) { - str += getRandomChar(); - } - return str; - }; - - return randomID(size); - }, - /* Tells you if a number is even or not - ================================================== */ - // VMM.Util.isEven(n) - isEven: function(n){ - return (n%2 === 0) ? true : false; - }, - /* Get URL Variables - ================================================== */ - // var somestring = VMM.Util.getUrlVars(str_url)["varname"]; - getUrlVars: function(string) { - - var str = string.toString(); - - if (str.match('&')) { - str = str.replace("&", "&"); - } else if (str.match('&')) { - str = str.replace("&", "&"); - } else if (str.match('&')) { - str = str.replace("&", "&"); - } - - var vars = [], hash; - var hashes = str.slice(str.indexOf('?') + 1).split('&'); - for(var i = 0; i < hashes.length; i++) { - hash = hashes[i].split('='); - vars.push(hash[0]); - vars[hash[0]] = hash[1]; - } - - - return vars; - }, - - /* Cleans up strings to become real HTML - ================================================== */ - toHTML: function(text) { - - text = this.nl2br(text); - text = this.linkify(text); - - return text.replace(/\s\s/g,"  "); - }, - - /* Returns text strings as CamelCase - ================================================== */ - toCamelCase: function(s,forceLowerCase) { - - if(forceLowerCase !== false) forceLowerCase = true; - - var sps = ((forceLowerCase) ? s.toLowerCase() : s).split(" "); - - for(var i=0; i= 7) { - return t.replace("_", "%20"); - } else { - var __TitleCase = { - __smallWords: ['a', 'an', 'and', 'as', 'at', 'but','by', 'en', 'for', 'if', 'in', 'of', 'on', 'or','the', 'to', 'v[.]?', 'via', 'vs[.]?'], - - init: function() { - this.__smallRE = this.__smallWords.join('|'); - this.__lowerCaseWordsRE = new RegExp('\\b(' + this.__smallRE + ')\\b', 'gi'); - this.__firstWordRE = new RegExp('^([^a-zA-Z0-9 \\r\\n\\t]*)(' + this.__smallRE + ')\\b', 'gi'); - this.__lastWordRE = new RegExp('\\b(' + this.__smallRE + ')([^a-zA-Z0-9 \\r\\n\\t]*)$', 'gi'); - }, - - toTitleCase: function(string) { - var line = ''; - - var split = string.split(/([:.;?!][ ]|(?:[ ]|^)["“])/); - - for (var i = 0; i < split.length; ++i) { - var s = split[i]; - - s = s.replace(/\b([a-zA-Z][a-z.'’]*)\b/g,this.__titleCaseDottedWordReplacer); - - // lowercase the list of small words - s = s.replace(this.__lowerCaseWordsRE, this.__lowerReplacer); - - // if the first word in the title is a small word then capitalize it - s = s.replace(this.__firstWordRE, this.__firstToUpperCase); - - // if the last word in the title is a small word, then capitalize it - s = s.replace(this.__lastWordRE, this.__firstToUpperCase); - - line += s; - } - - // special cases - line = line.replace(/ V(s?)\. /g, ' v$1. '); - line = line.replace(/(['’])S\b/g, '$1s'); - line = line.replace(/\b(AT&T|Q&A)\b/ig, this.__upperReplacer); - - return line; - }, - - __titleCaseDottedWordReplacer: function (w) { - return (w.match(/[a-zA-Z][.][a-zA-Z]/)) ? w : __TitleCase.__firstToUpperCase(w); - }, - - __lowerReplacer: function (w) { return w.toLowerCase() }, - - __upperReplacer: function (w) { return w.toUpperCase() }, - - __firstToUpperCase: function (w) { - var split = w.split(/(^[^a-zA-Z0-9]*[a-zA-Z0-9])(.*)$/); - if (split[1]) { - split[1] = split[1].toUpperCase(); - } - - return split.join(''); - - - }, - }; - - __TitleCase.init(); - - t = t.replace(/_/g," "); - t = __TitleCase.toTitleCase(t); - - return t; - - } - - }, - - }).init(); - - //'string'.linkify(); - if(!String.linkify) { - String.prototype.linkify = function() { - - // 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; - - var twitterHandlePattern = /(@([\w]+))/g; - - var twitterSearchPattern = /(#([\w]+))/g; - - return this - .replace(urlPattern, '$&') - .replace(pseudoUrlPattern, '$1$2') - .replace(emailAddressPattern, '$1') - .replace(twitterHandlePattern, "$1") - .replace(twitterSearchPattern, "$1"); - }; - }; - //str.substr(3,4) - /* - * Date Format 1.2.3 - * (c) 2007-2009 Steven Levithan - * MIT license - * - * Includes enhancements by Scott Trenda - * and Kris Kowal - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - */ - - var dateFormat = function () { - var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[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; - }; - - // Regexes and supporting functions are cached through closure - return function (date, mask, utc) { - var dF = dateFormat; - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - 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; - } - - 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); - }); - }; - }(); - - // Some common format strings - dateFormat.masks = { - "default": "ddd mmm dd yyyy HH:MM:ss", - shortDate: "m/d/yy", - mediumDate: "mmm d, yyyy", - longDate: "mmmm d, yyyy", - fullDate: "dddd, mmmm d, yyyy", - shortTime: "h:MM TT", - mediumTime: "h:MM:ss TT", - longTime: "h:MM:ss TT Z", - isoDate: "yyyy-mm-dd", - isoTime: "HH:MM:ss", - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" - }; - - // Internationalization strings - dateFormat.i18n = { - dayNames: [ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - ], - monthNames: [ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - ] - }; - - // For convenience... - Date.prototype.format = function (mask, utc) { - return dateFormat(this, mask, utc); - }; - -} \ No newline at end of file diff --git a/source/js/VMM.js b/source/js/VMM.js deleted file mode 100644 index 3bbfeb8..0000000 --- a/source/js/VMM.js +++ /dev/null @@ -1,333 +0,0 @@ -/* Verite - * Verite JS Master - * Version: 0.6 - * Date: April 26, 2012 - * Copyright 2012 Verite unless part of Verite Timeline, - * if part of Timeline then it inherits Timeline's license. - * Designed and built by Zach Wise digitalartwork.net - * ----------------------------------------------------- */ - - -/* Simple JavaScript Inheritance - * By John Resig http://ejohn.org/ - * MIT Licensed. -================================================== */ -(function() { - var initializing = false, - fnTest = /xyz/.test(function() { - xyz; - }) ? /\b_super\b/: /.*/; - // The base Class implementation (does nothing) - this.Class = function() {}; - - // Create a new Class that inherits from this class - Class.extend = function(prop) { - var _super = this.prototype; - - // Instantiate a base class (but only create the instance, - // don't run the init constructor) - initializing = true; - var prototype = new this(); - initializing = false; - - // Copy the properties over onto the new prototype - for (var name in prop) { - // Check if we're overwriting an existing function - prototype[name] = typeof prop[name] == "function" && - typeof _super[name] == "function" && fnTest.test(prop[name]) ? - (function(name, fn) { - return function() { - var tmp = this._super; - - // Add a new ._super() method that is the same method - // but on the super-class - this._super = _super[name]; - - // The method only need to be bound temporarily, so we - // remove it when we're done executing - var ret = fn.apply(this, arguments); - this._super = tmp; - - return ret; - }; - })(name, prop[name]) : - prop[name]; - } - - // The dummy class constructor - function Class() { - // All construction is actually done in the init method - if (!initializing && this.init) - this.init.apply(this, arguments); - } - - // Populate our constructed prototype object - Class.prototype = prototype; - - // Enforce the constructor to be what we expect - Class.prototype.constructor = Class; - - // And make this class extendable - Class.extend = arguments.callee; - - return Class; - }; -})(); - -/* Access to the Global Object - * access the global object without hard-coding the identifier window -================================================== */ -var global = (function () { - return this || (1,eval)('this'); -}()); - -/* VMM -================================================== */ -if (typeof VMM == 'undefined') { - - /* Main Scope Container - ================================================== */ - //var VMM = {}; - var VMM = Class.extend({}); - - /* Debug - ================================================== */ - VMM.debug = true; - - /* Master Config - ================================================== */ - - VMM.master_config = ({ - - init: function() { - return this; - }, - - sizes: { - api: { - width: 0, - height: 0 - } - }, - - vp: "Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo", - - api_keys_master: { - flickr: "RAIvxHY4hE/Elm5cieh4X5ptMyDpj7MYIxziGxi0WGCcy1s+yr7rKQ==", - google: "jwNGnYw4hE9lmAez4ll0QD+jo6SKBJFknkopLS4FrSAuGfIwyj57AusuR0s8dAo=", - twitter: "" - }, - - flickr: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - youtube: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - vimeo: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - googlemaps: { - active: false, - map_active: false, - places_active: false, - array: [], - api_loaded: false, - que: [] - }, - - googledocs: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - wikipedia: { - active: false, - array: [], - api_loaded: false, - que: [] - }, - - soundcloud: { - active: false, - array: [], - api_loaded: false, - que: [] - } - - }).init(); - - //VMM.createElement(tag, value, cName, attrs, styles); - VMM.createElement = function(tag, value, cName, attrs, styles) { - - var ce = ""; - - if (tag != null && tag != "") { - - // TAG - ce += "<" + tag; - if (cName != null && cName != "") { - ce += " class='" + cName + "'"; - }; - - if (attrs != null && attrs != "") { - ce += " " + attrs; - }; - - if (styles != null && styles != "") { - ce += " style='" + styles + "'"; - }; - - ce += ">"; - - if (value != null && value != "") { - ce += value; - } - - // CLOSE TAG - ce = ce + ""; - } - - return ce; - - }; - - VMM.createMediaElement = function(media, caption, credit) { - - var ce = ""; - - var _valid = false; - - ce += "
"; - - if (media != null && media != "") { - - valid = true; - - ce += ""; - - // CREDIT - if (credit != null && credit != "") { - ce += VMM.createElement("div", credit, "credit"); - } - - // CAPTION - if (caption != null && caption != "") { - ce += VMM.createElement("div", caption, "caption"); - } - - } - - ce += "
"; - - return ce; - - }; - - // Hide URL Bar for iOS and Android by Scott Jehl - // https://gist.github.com/1183357 - - VMM.hideUrlBar = function () { - var win = window, - doc = win.document; - - // If there's a hash, or addEventListener is undefined, stop here - if( !location.hash || !win.addEventListener ){ - - //scroll to 1 - window.scrollTo( 0, 1 ); - var scrollTop = 1, - - //reset to 0 on bodyready, if needed - bodycheck = setInterval(function(){ - if( doc.body ){ - clearInterval( bodycheck ); - scrollTop = "scrollTop" in doc.body ? doc.body.scrollTop : 1; - win.scrollTo( 0, scrollTop === 1 ? 0 : 1 ); - } - }, 15 ); - - win.addEventListener( "load", function(){ - setTimeout(function(){ - //reset to hide addr bar at onload - win.scrollTo( 0, scrollTop === 1 ? 0 : 1 ); - }, 0); - }, false ); - } - }; - - -} - -/* Trace (console.log) -================================================== */ -function trace( msg ) { - if (VMM.debug) { - if (window.console) { - console.log(msg); - } else if ( typeof( jsTrace ) != 'undefined' ) { - jsTrace.send( msg ); - } else { - //alert(msg); - } - } -} - -/* Extending Date to include Week -================================================== */ -Date.prototype.getWeek = function() { - var onejan = new Date(this.getFullYear(),0,1); - return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7); -} - -/* Extending Date to include Day of Year -================================================== */ -Date.prototype.getDayOfYear = function() { - var onejan = new Date(this.getFullYear(),0,1); - return Math.ceil((this - onejan) / 86400000); -} - -/* A MORE SPECIFIC TYPEOF(); -// http://rolandog.com/archives/2007/01/18/typeof-a-more-specific-typeof/ -================================================== */ -// type.of() -var is={ - Null:function(a){return a===null;}, - Undefined:function(a){return a===undefined;}, - nt:function(a){return(a===null||a===undefined);}, - Function:function(a){return(typeof(a)==="function")?a.constructor.toString().match(/Function/)!==null:false;}, - String:function(a){return(typeof(a)==="string")?true:(typeof(a)==="object")?a.constructor.toString().match(/string/i)!==null:false;}, - Array:function(a){return(typeof(a)==="object")?a.constructor.toString().match(/array/i)!==null||a.length!==undefined:false;}, - Boolean:function(a){return(typeof(a)==="boolean")?true:(typeof(a)==="object")?a.constructor.toString().match(/boolean/i)!==null:false;}, - Date:function(a){return(typeof(a)==="date")?true:(typeof(a)==="object")?a.constructor.toString().match(/date/i)!==null:false;}, - HTML:function(a){return(typeof(a)==="object")?a.constructor.toString().match(/html/i)!==null:false;}, - Number:function(a){return(typeof(a)==="number")?true:(typeof(a)==="object")?a.constructor.toString().match(/Number/)!==null:false;}, - Object:function(a){return(typeof(a)==="object")?a.constructor.toString().match(/object/i)!==null:false;}, - RegExp:function(a){return(typeof(a)==="function")?a.constructor.toString().match(/regexp/i)!==null:false;} -}; -var type={ - of:function(a){ - for(var i in is){ - if(is[i](a)){ - return i.toLowerCase(); - } - } - } -}; - - -