From 693a35b6f901c4588b4a8cee70d31136127d1ad8 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 14 Jul 2015 08:45:30 +0800 Subject: [PATCH 001/121] Upgrade all dependencies --- Gruntfile.js | 18 ++--- assets/js/libs/amplify.store.js | 4 +- assets/js/libs/classList.js | 77 +++++++++++++++++--- assets/js/libs/hogan.js | 48 ++++++------- assets/js/libs/requestanimationframe.js | 15 ++-- assets/js/libs/tween.js | 96 +++++++++++++++++++------ package.json | 8 +-- 7 files changed, 184 insertions(+), 82 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 7427f2bd..6149a27d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,10 +10,8 @@ module.exports = function(grunt) { return path.replace(/^js\//i, '') + '.map'; }, sourceMapRoot: '../', - beautify: { - max_line_len: 500, - screw_ie8: true - } + maxLineLen: 500, + screwIE8: true }, files: { 'js/hw-web.min.js': [ @@ -36,10 +34,8 @@ module.exports = function(grunt) { return path.replace(/^js\//i, '') + '.map'; }, sourceMapRoot: '../', - beautify: { - max_line_len: 500, - screw_ie8: true - } + maxLineLen: 500, + screwIE8: true }, files: { 'js/hw-ios.min.js': [ @@ -63,10 +59,8 @@ module.exports = function(grunt) { return path.replace(/^js\//i, '') + '.map'; }, sourceMapRoot: '../', - beautify: { - max_line_len: 500, - screw_ie8: true - } + maxLineLen: 500, + screwIE8: true }, files: { 'js/hw-ios-2.min.js': [ diff --git a/assets/js/libs/amplify.store.js b/assets/js/libs/amplify.store.js index fe68bf60..d5bec156 100644 --- a/assets/js/libs/amplify.store.js +++ b/assets/js/libs/amplify.store.js @@ -1,7 +1,7 @@ /*! - * Amplify Store - Persistent Client-Side Storage 1.1.0 + * Amplify Store - Persistent Client-Side Storage 1.1.2 * - * Copyright 2012 appendTo LLC. (http://appendto.com/team) + * Copyright 2011 - 2013 appendTo LLC. (http://appendto.com/team) * Dual licensed under the MIT or GPL licenses. * http://appendto.com/open-source-licenses * diff --git a/assets/js/libs/classList.js b/assets/js/libs/classList.js index ae90d99e..6b24565e 100644 --- a/assets/js/libs/classList.js +++ b/assets/js/libs/classList.js @@ -1,17 +1,20 @@ /* * classList.js: Cross-browser full element.classList implementation. - * 2014-01-31 + * 1.1.20150312 * * By Eli Grey, http://eligrey.com - * Public Domain. - * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + * License: Dedicated to the public domain. + * See https://github.com/eligrey/classList.js/blob/master/LICENSE.md */ /*global self, document, DOMException */ -/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/ +/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */ -if ("document" in self && !("classList" in document.createElement("_"))) { +if ("document" in self) { + +// Full polyfill for browsers with no classList support +if (!("classList" in document.createElement("_"))) { (function (view) { @@ -117,13 +120,15 @@ classListProto.remove = function () { , l = tokens.length , token , updated = false + , index ; do { token = tokens[i] + ""; - var index = checkTokenAndGetIndex(this, token); - if (index !== -1) { + index = checkTokenAndGetIndex(this, token); + while (index !== -1) { this.splice(index, 1); updated = true; + index = checkTokenAndGetIndex(this, token); } } while (++i < l); @@ -147,7 +152,11 @@ classListProto.toggle = function (token, force) { this[method](token); } - return !result; + if (force === true || force === false) { + return force; + } else { + return !result; + } }; classListProto.toString = function () { return this.join(" "); @@ -173,4 +182,56 @@ if (objCtr.defineProperty) { }(self)); +} else { +// There is full or partial native classList support, so just check if we need +// to normalize the add/remove and toggle APIs. + +(function () { + "use strict"; + + var testElement = document.createElement("_"); + + testElement.classList.add("c1", "c2"); + + // Polyfill for IE 10/11 and Firefox <26, where classList.add and + // classList.remove exist but support only one argument at a time. + if (!testElement.classList.contains("c2")) { + var createMethod = function(method) { + var original = DOMTokenList.prototype[method]; + + DOMTokenList.prototype[method] = function(token) { + var i, len = arguments.length; + + for (i = 0; i < len; i++) { + token = arguments[i]; + original.call(this, token); + } + }; + }; + createMethod('add'); + createMethod('remove'); + } + + testElement.classList.toggle("c3", false); + + // Polyfill for IE 10 and Firefox <24, where classList.toggle does not + // support the second argument. + if (testElement.classList.contains("c3")) { + var _toggle = DOMTokenList.prototype.toggle; + + DOMTokenList.prototype.toggle = function(token, force) { + if (1 in arguments && !this.contains(token) === !force) { + return force; + } else { + return _toggle.call(this, token); + } + }; + + } + + testElement = null; +}()); + +} + } diff --git a/assets/js/libs/hogan.js b/assets/js/libs/hogan.js index 5d2bb913..14f396d1 100644 --- a/assets/js/libs/hogan.js +++ b/assets/js/libs/hogan.js @@ -15,7 +15,7 @@ var Hogan = {}; -(function (Hogan, useArrayBuffer) { +(function (Hogan) { Hogan.Template = function (codeObj, text, compiler, options) { codeObj = codeObj || {}; this.r = codeObj.code || this.r; @@ -24,7 +24,7 @@ var Hogan = {}; this.text = text || ''; this.partials = codeObj.partials || {}; this.subs = codeObj.subs || {}; - this.ib(); + this.buf = ''; } Hogan.Template.prototype = { @@ -72,12 +72,14 @@ var Hogan = {}; if (partial.subs) { // Make sure we consider parent template now - if (this.activeSub === undefined) { - // Store parent template text in partials.stackText to perform substitutions in child templates correctly - partials.stackText = this.text; + if (!partials.stackText) partials.stackText = {}; + for (key in partial.subs) { + if (!partials.stackText[key]) { + partials.stackText[key] = (this.activeSub !== undefined && partials.stackText[this.activeSub]) ? partials.stackText[this.activeSub] : this.text; + } } template = createSpecializedPartial(template, partial.subs, partial.partials, - this.stackSubs, this.stackPartials, partials.stackText || this.text); + this.stackSubs, this.stackPartials, partials.stackText); } this.partials[symbol].instance = template; @@ -144,7 +146,7 @@ var Hogan = {}; } else { for (var i = 1; i < names.length; i++) { found = findInScope(names[i], val, doModelGet); - if (found != null) { + if (found !== undefined) { cx = val; val = found; } else { @@ -176,7 +178,7 @@ var Hogan = {}; for (var i = ctx.length - 1; i >= 0; i--) { v = ctx[i]; val = findInScope(key, v, doModelGet); - if (val != null) { + if (val !== undefined) { found = true; break; } @@ -194,11 +196,11 @@ var Hogan = {}; }, // higher order templates - ls: function(func, cx, partials, text, tags) { + ls: function(func, cx, ctx, partials, text, tags) { var oldTags = this.options.delimiters; this.options.delimiters = tags; - this.b(this.ct(coerceToString(func.call(cx, text)), cx, partials)); + this.b(this.ct(coerceToString(func.call(cx, text, ctx)), cx, partials)); this.options.delimiters = oldTags; return false; @@ -213,15 +215,9 @@ var Hogan = {}; }, // template result buffering - b: (useArrayBuffer) ? function(s) { this.buf.push(s); } : - function(s) { this.buf += s; }, - - fl: (useArrayBuffer) ? function() { var r = this.buf.join(''); this.buf = []; return r; } : - function() { var r = this.buf; this.buf = ''; return r; }, - // init the buffer - ib: function () { - this.buf = (useArrayBuffer) ? [] : ''; - }, + b: function(s) { this.buf += s; }, + + fl: function() { var r = this.buf; this.buf = ''; return r; }, // method replace section ms: function(func, ctx, partials, inverted, start, end, tags) { @@ -233,8 +229,8 @@ var Hogan = {}; if (inverted) { return true; } else { - textSource = (this.activeSub && this.subsText[this.activeSub]) ? this.subsText[this.activeSub] : this.text; - return this.ls(result, cx, partials, textSource.substring(start, end), tags); + textSource = (this.activeSub && this.subsText && this.subsText[this.activeSub]) ? this.subsText[this.activeSub] : this.text; + return this.ls(result, cx, ctx, partials, textSource.substring(start, end), tags); } } @@ -266,11 +262,11 @@ var Hogan = {}; //Find a key in an object function findInScope(key, scope, doModelGet) { - var val, checkVal; + var val; if (scope && typeof scope == 'object') { - if (scope[key] != null) { + if (scope[key] !== undefined) { val = scope[key]; // try lookup with get for backbone or similar model data @@ -282,7 +278,7 @@ var Hogan = {}; return val; } - function createSpecializedPartial(instance, subs, partials, stackSubs, stackPartials, childText) { + function createSpecializedPartial(instance, subs, partials, stackSubs, stackPartials, stackText) { function PartialTemplate() {}; PartialTemplate.prototype = instance; function Substitutions() {}; @@ -291,13 +287,13 @@ var Hogan = {}; var partial = new PartialTemplate(); partial.subs = new Substitutions(); partial.subsText = {}; //hehe. substext. - partial.ib(); + partial.buf = ''; stackSubs = stackSubs || {}; partial.stackSubs = stackSubs; + partial.subsText = stackText; for (key in subs) { if (!stackSubs[key]) stackSubs[key] = subs[key]; - partial.subsText[key] = childText; } for (key in stackSubs) { partial.subs[key] = stackSubs[key]; diff --git a/assets/js/libs/requestanimationframe.js b/assets/js/libs/requestanimationframe.js index 2ce3a97e..705880c1 100644 --- a/assets/js/libs/requestanimationframe.js +++ b/assets/js/libs/requestanimationframe.js @@ -1,29 +1,30 @@ // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating -// requestAnimationFrame polyfill by Erik Möller -// fixes from Paul Irish and Tino Zijdel +// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel + +// MIT license (function() { var lastTime = 0; - var vendors = ['ms', 'moz', 'webkit', 'o']; + var vendors = ['webkit', 'moz']; for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; } - + if (!window.requestAnimationFrame) window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, + var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; }; - + if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(id) { clearTimeout(id); }; -}()); \ No newline at end of file +}()); diff --git a/assets/js/libs/tween.js b/assets/js/libs/tween.js index 781bdc28..30405c4a 100644 --- a/assets/js/libs/tween.js +++ b/assets/js/libs/tween.js @@ -1,27 +1,34 @@ /** - * @author sole / http://soledadpenades.com - * @author mrdoob / http://mrdoob.com - * @author Robert Eisele / http://www.xarg.org - * @author Philippe / http://philippe.elsass.me - * @author Robert Penner / http://www.robertpenner.com/easing_terms_of_use.html - * @author Paul Lewis / http://www.aerotwist.com/ - * @author lechecacharro - * @author Josh Faul / http://jocafa.com/ - * @author egraether / http://egraether.com/ - * @author endel / http://endel.me - * @author Ben Delarre / http://delarre.net + * Tween.js - Licensed under the MIT license + * https://github.com/sole/tween.js + * ---------------------------------------------- + * + * See https://github.com/sole/tween.js/graphs/contributors for the full list of contributors. + * Thank you all, you're awesome! */ -// Date.now shim for (ahem) Internet Explo(d|r)er -if ( Date.now === undefined ) { +// performance.now polyfill +( function ( root ) { - Date.now = function () { + if ( 'performance' in root === false ) { + root.performance = {}; + } - return new Date().valueOf(); + // IE 8 + Date.now = ( Date.now || function () { + return new Date().getTime(); + } ); - }; + if ( 'now' in root.performance === false ) { + var offset = root.performance.timing && root.performance.timing.navigationStart ? performance.timing.navigationStart + : Date.now(); + + root.performance.now = function () { + return Date.now() - offset; + }; + } -} +} )( this ); var TWEEN = TWEEN || ( function () { @@ -29,7 +36,7 @@ var TWEEN = TWEEN || ( function () { return { - REVISION: '12', + REVISION: '14', getAll: function () { @@ -67,7 +74,7 @@ var TWEEN = TWEEN || ( function () { var i = 0; - time = time !== undefined ? time : ( typeof window !== 'undefined' && window.performance !== undefined && window.performance.now !== undefined ? window.performance.now() : Date.now() ); + time = time !== undefined ? time : window.performance.now(); while ( i < _tweens.length ) { @@ -110,6 +117,7 @@ TWEEN.Tween = function ( object ) { var _onStartCallbackFired = false; var _onUpdateCallback = null; var _onCompleteCallback = null; + var _onStopCallback = null; // Set all starting values present on the target object for ( var field in object ) { @@ -140,7 +148,7 @@ TWEEN.Tween = function ( object ) { _onStartCallbackFired = false; - _startTime = time !== undefined ? time : ( typeof window !== 'undefined' && window.performance !== undefined && window.performance.now !== undefined ? window.performance.now() : Date.now() ); + _startTime = time !== undefined ? time : window.performance.now(); _startTime += _delayTime; for ( var property in _valuesEnd ) { @@ -181,6 +189,13 @@ TWEEN.Tween = function ( object ) { TWEEN.remove( this ); _isPlaying = false; + + if ( _onStopCallback !== null ) { + + _onStopCallback.call( _object ); + + } + this.stopChainedTweens(); return this; @@ -260,6 +275,13 @@ TWEEN.Tween = function ( object ) { }; + this.onStop = function ( callback ) { + + _onStopCallback = callback; + return this; + + }; + this.update = function ( time ) { var property; @@ -298,13 +320,13 @@ TWEEN.Tween = function ( object ) { } else { - // Parses relative end values with start as base (e.g.: +10, -3) + // Parses relative end values with start as base (e.g.: +10, -3) if ( typeof(end) === "string" ) { end = start + parseFloat(end, 10); } // protect against non numeric properties. - if ( typeof(end) === "number" ) { + if ( typeof(end) === "number" ) { _object[ property ] = start + ( end - start ) * value; } @@ -337,12 +359,16 @@ TWEEN.Tween = function ( object ) { var tmp = _valuesStartRepeat[ property ]; _valuesStartRepeat[ property ] = _valuesEnd[ property ]; _valuesEnd[ property ] = tmp; - _reversed = !_reversed; } + _valuesStart[ property ] = _valuesStartRepeat[ property ]; } + if (_yoyo) { + _reversed = !_reversed; + } + _startTime = time + _delayTime; return true; @@ -739,3 +765,27 @@ TWEEN.Interpolation = { } }; + +// UMD (Universal Module Definition) +( function ( root ) { + + if ( typeof define === 'function' && define.amd ) { + + // AMD + define( [], function () { + return TWEEN; + } ); + + } else if ( typeof exports === 'object' ) { + + // Node.js + module.exports = TWEEN; + + } else { + + // Global variable + root.TWEEN = TWEEN; + + } + +} )( this ); diff --git a/package.json b/package.json index 2fcffc6f..c02a3aa4 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,12 @@ "version": "0.1.0", "devDependencies": { "grunt": "~0.4.5", - "grunt-contrib-uglify": "~0.9.0", - "grunt-contrib-jshint": "~0.11.1", - "hogan.js": "git://github.com/twitter/hogan.js.git", + "grunt-concurrent": "~2.0.0", "grunt-contrib-connect": "~0.10.1", + "grunt-contrib-jshint": "~0.11.2", + "grunt-contrib-uglify": "~0.9.1", + "hogan.js": "git://github.com/twitter/hogan.js.git", "grunt-contrib-watch": "~0.6.1", - "grunt-concurrent": "~1.0.0", "mime": "~1.3.4", "grunt-shell": "~1.1.2" } From 655abdc38636fef659e3d5b7f8cc4f0b9db81558 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 14 Jul 2015 08:45:49 +0800 Subject: [PATCH 002/121] No more appcache. --- index.html | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/index.html b/index.html index 9f726053..90bb5daf 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ - + @@ -48,49 +48,6 @@ // Track device pixel ratios if (window.devicePixelRatio) ga('set', 'dimension1', window.devicePixelRatio); } - -if (window.applicationCache){ - // "Naturally" reload when an update is available - var reload = false; - window.applicationCache.addEventListener('updateready', function(){ - if (window.applicationCache.status == window.applicationCache.UPDATEREADY){ - window.applicationCache.swapCache(); - reload = true; - } - }, false); - - setInterval(function(){ - try { // There's nothing to update for first-time load, browser freaks out :/ - window.applicationCache.update(); - } catch (e){} - }, 1000*60*60); // Every hour - - var checkReload = function(){ - if (reload) location.reload(); - }; - window.addEventListener('pageshow', checkReload, false); - window.addEventListener('focus', checkReload, false); - - // Use GA to track the update rate of this manifest appcache thing - // and see how fast users are updated to the latest cache/version - if (typeof ga != 'undefined') window.addEventListener('load', function(){ - setTimeout(function(){ - var r = new XMLHttpRequest(); - r.open('GET', 'manifest.appcache', true); - r.onload = function(){ - var text = this.responseText; - if (!text) return; - var version = (text.match(/#\s\d[^\n\r]+/) || [])[0]; - if (version) ga('send', 'event', 'Appcache', 'Version', version.replace(/^#\s/, '')); - }; - r.send(); - }, 1000); - }, false); -} else { - setTimeout(function(){ - if (typeof ga != 'undefined') ga('send', 'event', 'Appcache', 'Version', 'n/a'); - }, 1000); -} From b74b02ac4a60ad86fde20f51a2939030a044d7eb Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 14 Jul 2015 08:47:00 +0800 Subject: [PATCH 003/121] Don't show username for deleted comments. --- assets/css/hw-ios-2.css | 8 +++++++- assets/css/hw-ios.css | 5 ++++- assets/css/hw-web.css | 6 ++++++ assets/js/templates.js | 2 +- assets/templates/comments.mustache | 12 +++++++++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/assets/css/hw-ios-2.css b/assets/css/hw-ios-2.css index f44ed915..26e8bb84 100644 --- a/assets/css/hw-ios-2.css +++ b/assets/css/hw-ios-2.css @@ -592,6 +592,12 @@ ol.grouped-tableview-links li>a.tappable-active{ float: left; color: #bf223f; } +.view section.comments p.metadata.deleted{ + margin-bottom: 8px; +} +.view section.comments p.metadata.deleted span{ + float: left; +} .view section.comments p.metadata .user.op:after{ content: 'OP'; display: inline-block; @@ -1130,4 +1136,4 @@ ol.grouped-tableview-links li>a.tappable-active{ #app-desc{ margin-left: 86px; } -} \ No newline at end of file +} diff --git a/assets/css/hw-ios.css b/assets/css/hw-ios.css index 3ad6e0e4..bf3cfc09 100644 --- a/assets/css/hw-ios.css +++ b/assets/css/hw-ios.css @@ -806,6 +806,9 @@ ol.grouped-tableview-links li>a.disclosure.tappable-active:after{ display: -webkit-box; display: box; } +.view section.comments p.metadata.deleted{ + margin-bottom: 8px; +} .view section.comments p.metadata .user{ color: #b23914; } @@ -1549,4 +1552,4 @@ ol.grouped-tableview-links li>a.disclosure.tappable-active:after{ #view-comments{ left: 321px; } -} \ No newline at end of file +} diff --git a/assets/css/hw-web.css b/assets/css/hw-web.css index 5775ab0e..f1a4f650 100644 --- a/assets/css/hw-web.css +++ b/assets/css/hw-web.css @@ -480,6 +480,12 @@ ol.grouped-tableview-links li>a:hover{ float: left; color: #bf223f; } +.view section.comments p.metadata.deleted{ + margin-bottom: 8px; +} +.view section.comments p.metadata.deleted span{ + float: left; +} .view section.comments p.metadata .user.op:after{ content: 'OP'; display: inline-block; diff --git a/assets/js/templates.js b/assets/js/templates.js index 229095c5..428c9c92 100644 --- a/assets/js/templates.js +++ b/assets/js/templates.js @@ -1,7 +1,7 @@ (function(t){ TEMPLATES = { 'comments-toggle': new t({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("");return t.fl(); },partials: {}, subs: { }}), - 'comments': new t({code: function (c,p,i) { var t=this;t.b(i=i||"");if(t.s(t.f("comments",c,p,1),c,p,0,13,202,"{{ }}")){t.rs(c,p,function(c,p,t){t.b("
  • ");t.b(t.v(t.f("user",c,p,0)));t.b("

    ");t.b(t.t(t.f("content",c,p,0)));t.b("