Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Update rocketfuel to commonplace 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbasta committed Dec 16, 2013
1 parent 5ea45f7 commit c900d9d
Show file tree
Hide file tree
Showing 25 changed files with 282 additions and 413 deletions.
2 changes: 1 addition & 1 deletion fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def pre_update(ref):
def update():
with lcd(ROCKETFUEL):
local('npm install')
local('npm install --force [email protected].2')
local('npm install --force [email protected].4')
local('commonplace includes')
local('commonplace langpacks')

Expand Down
2 changes: 1 addition & 1 deletion src/.commonplace
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"0.2.0","ignore":["media/js/forms.js"]}
{"version":"0.2.5","ignore":["media/js/forms.js"]}
2 changes: 1 addition & 1 deletion src/media/js/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ define('assert', ['underscore'], function(_) {
// If it's an array, convert it to an array-like object.
// Require.js freaks out when you give it an array, but this
// should work in (almost) all circumstances.
x[1] = _.extend({}, x[1])
x[1] = _.extend({}, x[1]);
}

return x;
Expand Down
7 changes: 5 additions & 2 deletions src/media/js/capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ define('capabilities', [], function() {
'firefoxOS': navigator.mozApps && navigator.mozApps.installPackage &&
navigator.userAgent.indexOf('Android') === -1 &&
navigator.userAgent.indexOf('Mobile') !== -1,
'persona': !!navigator.id,
'phantom': navigator.userAgent.match(/Phantom/) // Don't use this if you can help it.
};

static_caps.persona = !!navigator.id && !static_caps.phantom;

// True if the login should inherit mobile behaviors such as allowUnverified.
// The _shimmed check is for B2G where identity is native (not shimmed).
static_caps.mobileLogin = !navigator.id._shimmed || static_caps.firefoxAndroid;
static_caps.mobileLogin = static_caps.persona && (!navigator.id._shimmed || static_caps.firefoxAndroid);

static_caps.device_type = function() {
if (static_caps.firefoxOS) {
Expand All @@ -41,7 +44,7 @@ define('capabilities', [], function() {
} else {
return 'desktop';
}
}
};

return static_caps;

Expand Down
8 changes: 5 additions & 3 deletions src/media/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ define('helpers',
for (var i = 0; i < list.length; i++) {
var val = list[i];
inner:
for (prop in kwargs) {
for (var prop in kwargs) {
if (!kwargs.hasOwnProperty(prop) || prop === '__keywords') continue inner;
if (!(prop in val)) continue outer;
if (Array.isArray(kwargs[prop]) ?
Expand All @@ -91,7 +91,7 @@ define('helpers',
(hex >> 16) + ',' +
((hex & 0x00FF00) >> 8) + ',' +
(hex & 0x0000FF) + ',' + o + ')';
}
};

safe_filter('stringify', JSON.stringify);

Expand All @@ -104,7 +104,9 @@ define('helpers',
var user = require('user');
var userobj = {
get_setting: user.get_setting,
// We don't expose `get_settings` because it's a direct reference.
get_settings: function() {
return _.clone(user.get_settings());
},
get_permission: user.get_permission,
logged_in: user.logged_in
};
Expand Down
6 changes: 4 additions & 2 deletions src/media/js/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

var languages = [
'bg', 'ca', 'cs', 'de', 'el', 'en-US', 'es', 'eu', 'fr', 'ga-IE', 'hr',
'hu', 'it', 'ja', 'nl', 'pl', 'pt-BR', 'ro', 'ru', 'sk', 'sr', 'sr-Latn',
'tr', 'zh-TW', 'dbg'
'hu', 'it', 'ja', 'mk', 'nl', 'pl', 'pt-BR', 'ro', 'ru', 'sk', 'sr',
'sr-Latn', 'tr', 'zh-TW', 'dbg'
];
var body_langs;
if (body_langs = document.body.getAttribute('data-languages')) {
Expand Down Expand Up @@ -44,7 +44,9 @@ if (!window.define) {
// Cachebust the .js file for our CDN.
var build_id = document.body.getAttribute('data-buildIdJs') || +new Date();
var repo = document.body.getAttribute('data-repo');
/* jshint ignore:start */
document.write('<script src="/media/' + (repo ? repo + '/' : '') + 'locales/' + locale + '.js?b=' + build_id + '"></script>');
/* jshint ignore:end */

} else {
define('l10n', ['format'], function(format) {
Expand Down
98 changes: 1 addition & 97 deletions src/media/js/lib/nunjucks.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,6 @@ exports.groupBy = function(obj, val) {
return result;
};

exports.toArray = function(obj) {
return Array.prototype.slice.call(obj);
};

exports.without = function(array) {
var result = [];
if (!array) {
return result;
}
var index = -1,
length = array.length,
contains = exports.toArray(arguments).slice(1);

while(++index < length) {
if(contains.indexOf(array[index]) === -1) {
result.push(array[index]);
}
}
return result;
};

exports.extend = function(obj, obj2) {
for(var k in obj2) {
obj[k] = obj2[k];
Expand Down Expand Up @@ -254,27 +233,6 @@ exports.map = function(obj, func) {
return results;
};

exports.asyncParallel = function(funcs, done) {
var count = funcs.length,
result = new Array(count),
current = 0;

var makeNext = function(i) {
return function(res) {
result[i] = res;
current += 1;

if (current === count) {
done(result);
}
};
};

for (var i = 0; i < count; i++) {
funcs[i](makeNext(i));
}
};

exports.asyncIter = function(arr, iter, cb) {
var i = -1;

Expand Down Expand Up @@ -312,44 +270,6 @@ exports.asyncFor = function(obj, iter, cb) {
next();
};

if(!Array.prototype.indexOf) {
Array.prototype.indexOf = function(array, searchElement /*, fromIndex */) {
if (array === null) {
throw new TypeError();
}
var t = Object(array);
var len = t.length >>> 0;
if (len === 0) {
return -1;
}
var n = 0;
if (arguments.length > 2) {
n = Number(arguments[2]);
if (n != n) { // shortcut for verifying if it's NaN
n = 0;
} else if (n !== 0 && n !== Infinity && n !== -Infinity) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
}
if (n >= len) {
return -1;
}
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
for (; k < len; k++) {
if (k in t && t[k] === searchElement) {
return k;
}
}
return -1;
};
}

if(!Array.prototype.map) {
Array.prototype.map = function() {
throw new Error("map is unimplemented for this js engine");
};
}

exports.keys = function(obj) {
if(Object.prototype.keys) {
return obj.keys();
Expand Down Expand Up @@ -577,17 +497,6 @@ function memberLookup(obj, val) {
return obj[val];
}

function callWrap(obj, name, args) {
if(!obj) {
throw new Error('Unable to call `' + name + '`, which is undefined or falsey');
}
else if(typeof obj !== 'function') {
throw new Error('Unable to call `' + name + '`, which is not a function');
}

return obj.apply(this, args);
}

function contextOrFrameLookup(context, frame, name) {
var val = frame.lookup(name);
return (val !== undefined && val !== null) ?
Expand Down Expand Up @@ -687,7 +596,6 @@ modules.runtime = {
suppressValue: suppressValue,
memberLookup: memberLookup,
contextOrFrameLookup: contextOrFrameLookup,
callWrap: callWrap,
handleError: handleError,
isArray: lib.isArray,
keys: lib.keys,
Expand Down Expand Up @@ -1390,11 +1298,7 @@ nunjucks.configure = function(templatesPath, opts) {
opts = templatesPath;
templatesPath = null;
}

var noWatch = 'watch' in opts ? !opts.watch : false;
e = new env.Environment(null, opts);

return e;
return e = new env.Environment(null, opts);
};

nunjucks.render = function(name, ctx, cb) {
Expand Down
4 changes: 2 additions & 2 deletions src/media/js/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ define('log', ['storage', 'utils'], function(storage, utils) {

// Have log('payments') but want log('payments', 'mock')?
// log('payments').tagged('mock') gives you the latter.
tagged: function(tag) {
return logger(type, tag);
tagged: function(newTag) {
return logger(type, tag + '][' + newTag, onlog);
}
};
};
Expand Down
6 changes: 3 additions & 3 deletions src/media/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ define('login',
z.body.removeClass('logged-in');
z.page.trigger('reload_chrome').trigger('before_logout');

if (!capabilities.phantom) {
if (capabilities.persona) {
console.log('Triggering Persona logout');
navigator.id.logout();
}
Expand Down Expand Up @@ -76,7 +76,7 @@ define('login',
console.log('Not allowing unverified emails');
}

if (!capabilities.phantom) {
if (capabilities.persona) {
console.log('Requesting login from Persona');
navigator.id.request(opt);
}
Expand Down Expand Up @@ -147,7 +147,7 @@ define('login',
console.log('No previous user detected');
}

if (!capabilities.phantom) {
if (capabilities.persona) {
console.log('Calling navigator.id.watch');
navigator.id.watch({
loggedInUser: email,
Expand Down
Loading

0 comments on commit c900d9d

Please sign in to comment.