commonplace
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -186,16 +186,16 @@ var fs = require('fs'); | ||
function extract_callextension(tree) { | ||
var calls = []; | ||
var defers = tree.findAll(nodes.CallExtension); | ||
for (var i = 0, e; e = defers[i++];) { | ||
e.contentArgs.map(function(arg) { | ||
if (!arg) { | ||
return; | ||
} | ||
calls = calls.concat(arg.findAll(nodes.FunCall)); | ||
calls = calls.concat(extract_callextension(arg).map(calls.push)); | ||
}); | ||
} | ||
return calls; | ||
} | ||
function extract_callextension(tree) { | ||
var calls = []; | ||
var defers = tree.findAll(nodes.CallExtension); | ||
for (var i = 0, e; e = defers[i++];) { | ||
e.contentArgs.map(function(arg) { | ||
if (!arg) { | ||
return; | ||
} | ||
calls = calls.concat(arg.findAll(nodes.FunCall)); | ||
calls = calls.concat(extract_callextension(arg)); | ||
}); | ||
} | ||
return calls; | ||
} | ||
@@ -290,3 +290,3 @@ var calls = parseTree.findAll(nodes.FunCall); | ||
this.save_po = function(path, callback) { | ||
var data = [ | ||
var data = [ | ||
'#, fuzzy', | ||
@@ -313,3 +313,3 @@ 'msgid ""', | ||
this.string_count = function() { | ||
return localizable_strings.length; | ||
return localizable_strings.length; | ||
}; | ||
@@ -316,0 +316,0 @@ |
{ | ||
"name": "commonplace", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "url": "git://github.com/mozilla/commonplace.git", |
@@ -89,3 +89,3 @@ define('builder', | ||
// visible page. | ||
var url = el.dataset.url; | ||
var url = el.getAttribute('data-url'); | ||
injector(url, el.parentNode, target).done(function() { | ||
@@ -92,0 +92,0 @@ console.log('Pagination completed'); |
@@ -22,3 +22,3 @@ define('capabilities', [], function() { | ||
'navPay': !!navigator.mozPay, | ||
'webactivities': !!(window.setMessageHandler || window.mozSetMessageHandler), | ||
'webactivities': !!(navigator.setMessageHandler || navigator.mozSetMessageHandler), | ||
'firefoxOS': navigator.mozApps && navigator.mozApps.installPackage && | ||
@@ -25,0 +25,0 @@ navigator.userAgent.indexOf('Android') === -1 && |
@@ -87,2 +87,11 @@ define('helpers', | ||
// Credit to ngoke and potch. | ||
filters.hex2rgba = function(hex, o) { | ||
hex = parseInt(hex.substring(hex[0] == '#' ? 1 : 0), 16); | ||
return 'rgba(' + | ||
(hex >> 16) + ',' + | ||
((hex & 0x00FF00) >> 8) + ',' + | ||
(hex & 0x0000FF) + ',' + o + ')'; | ||
} | ||
safe_filter('stringify', JSON.stringify); | ||
@@ -121,2 +130,3 @@ | ||
navigator: window.navigator, | ||
screen: window.screen, | ||
language: window.navigator.l10n ? window.navigator.l10n.language : 'en-US' | ||
@@ -123,0 +133,0 @@ }; |
(function() { | ||
var languages = [ | ||
'bg', 'ca', 'cs', 'de', 'en-US', 'es', 'eu', 'fr', 'ga-IE', 'hr', 'hu', 'it', | ||
'ja', 'nl', 'pl', 'pt-BR', 'ru', 'sk', 'zh-TW', 'dbg' | ||
'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' | ||
]; | ||
var body_langs; | ||
if (body_langs = document.body.getAttribute('data-languages')) { | ||
languages = JSON.parse(body_langs); | ||
} | ||
@@ -40,4 +45,4 @@ var lang_expander = { | ||
// Cachebust the .js file for our CDN. | ||
var build_id = document.body.dataset.buildIdJs || +new Date(); | ||
var repo = document.body.dataset.repo; | ||
var build_id = document.body.getAttribute('data-buildIdJs') || +new Date(); | ||
var repo = document.body.getAttribute('data-repo'); | ||
document.write('<script src="/media/' + (repo ? repo + '/' : '') + 'locales/' + locale + '.js?b=' + build_id + '"></script>'); | ||
@@ -44,0 +49,0 @@ |
@@ -1,3 +0,8 @@ | ||
define('log', ['storage'], function(storage) { | ||
define('log', ['storage', 'utils'], function(storage, utils) { | ||
if (!('groupCollapsed' in window.console)) { | ||
window.console.groupCollapsed = window.console.group = window.console.log; | ||
window.console.groupEnd = function() {}; | ||
} | ||
var slice = Array.prototype.slice; | ||
@@ -70,3 +75,3 @@ var filter; | ||
logger.unmentionables.push(term); | ||
logger.unmentionables.push(encodeURIComponent(term)); | ||
logger.unmentionables.push(utils.encodeURIComponent(term)); | ||
}; | ||
@@ -73,0 +78,0 @@ |
define('login', | ||
['cache', 'capabilities', 'defer', 'jquery', 'log', 'models', 'notification', 'settings', 'underscore', 'urls', 'user', 'requests', 'z'], | ||
function(cache, capabilities, defer, $, log, models, notification, settings, _, urls, user, requests, z) { | ||
['capabilities', 'defer', 'jquery', 'log', 'notification', 'settings', 'underscore', 'urls', 'user', 'requests', 'z'], | ||
function(capabilities, defer, $, log, notification, settings, _, urls, user, requests, z) { | ||
@@ -55,4 +55,4 @@ var console = log('login'); | ||
var opt = { | ||
termsOfService: '/terms-of-use', | ||
privacyPolicy: '/privacy-policy', | ||
termsOfService: settings.persona_tos, | ||
privacyPolicy: settings.persona_privacy, | ||
siteLogo: settings.persona_site_logo, | ||
@@ -59,0 +59,0 @@ oncancel: function() { |
@@ -8,2 +8,4 @@ define('navigation', | ||
var encodeURIComponent = utils.encodeURIComponent; | ||
var gettext = l10n.gettext; | ||
@@ -122,3 +124,2 @@ var stack = [ | ||
// TODO(fireplace): Make this work with views | ||
// Does the page have a parent? If so, handle the parent logic. | ||
@@ -125,0 +126,0 @@ if (z.context.parent) { |
@@ -67,4 +67,12 @@ define('requests', | ||
requests.on('hookname', function(xhr) {}) | ||
requests.on('hookname', function(xhr) {}) | ||
Available hooks: | ||
- success: Fired when a request is successful. Same arguments that would | ||
be sent to the deferred of the request. | ||
- failure: Fired when a request is unsuccessful. Same arguments that would | ||
be sent to the deferred of the request. | ||
- deprecated: Fired when a request is returned with an API-Status header of | ||
"Deprecated". | ||
*/ | ||
@@ -104,5 +112,7 @@ | ||
if (xhr.getResponseHeader('API-Status') === 'Deprecated') { | ||
callHooks('deprecated', [xhr]); | ||
} | ||
try { | ||
if (xhr.getResponseHeader('API-Status') === 'Deprecated') { | ||
callHooks('deprecated', [xhr]); | ||
} | ||
} catch(e) {} | ||
@@ -109,0 +119,0 @@ var statusCode = xhr.status / 100 | 0; |
@@ -23,4 +23,8 @@ define('settings', ['l10n', 'settings_local', 'underscore'], function(l10n, settings_local, _) { | ||
// The URLs for the Persona ToS and Privacy Policy. | ||
persona_tos: null, | ||
persona_privacy: null, | ||
title_suffix: 'Commonplace App' | ||
}); | ||
}); |
define('storage', ['settings'], function(settings) { | ||
// U MAD? | ||
// OH I MAD | ||
var fakeStorage = {}; | ||
function prefix(func) { | ||
var ls; | ||
try { ls = localStorage;} | ||
catch(e) {} | ||
function prefix(func, backup_func) { | ||
return function() { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
args[0] = settings.storage_version + '::' + args[0]; | ||
return func.apply(localStorage, args); | ||
try { | ||
return func.apply(ls, args); | ||
} catch(e) { | ||
return backup_func.apply(fakeStorage, args) | ||
} | ||
} | ||
} | ||
try { | ||
var ls = localStorage; | ||
return { | ||
clear: function() {ls.clear();}, | ||
getItem: prefix(ls.getItem), | ||
removeItem: prefix(ls.removeItem), | ||
setItem: prefix(ls.setItem) | ||
}; | ||
} catch(e) { | ||
// TODO: Try saving this to a cookie or something? | ||
return { | ||
clear: function() {}, | ||
getItem: function() {}, | ||
removeItem: function() {}, | ||
setItem: function() {} | ||
}; | ||
} | ||
return { | ||
clear: function() { | ||
try { ls.clear(); } | ||
catch(e) { fakeStorage = {}; } | ||
}, | ||
getItem: prefix( | ||
ls.getItem, | ||
function(key) { return this[key]; } | ||
), | ||
removeItem: prefix( | ||
ls.removeItem, | ||
function(key) { delete this[key]; } | ||
), | ||
setItem: prefix( | ||
ls.setItem, | ||
function(key, value) { this[key] = value; } | ||
) | ||
}; | ||
}); |
@@ -91,3 +91,3 @@ define('urls', | ||
var media = function(path) { | ||
var media_url = document.body.dataset.media || settings.media_url; | ||
var media_url = document.body.getAttribute('data-media') || settings.media_url; | ||
if (media_url[media_url.length - 1] !== '/') { | ||
@@ -94,0 +94,0 @@ media_url += '/'; |
@@ -1,2 +0,5 @@ | ||
define('utils', ['jquery', 'underscore'], function($, _) { | ||
define('utils', ['jquery', 'l10n', 'underscore'], function($, l10n, _) { | ||
var ngettext = l10n.ngettext; | ||
_.extend(String.prototype, { | ||
@@ -46,2 +49,16 @@ strip: function(str) { | ||
function slugify(s, limit) { | ||
if (typeof s !== 'string') { | ||
return s; | ||
} | ||
var value = s.toLowerCase().trim() | ||
.replace(/[ _]/g, '-') | ||
.replace(/[^-\w]/g, '') | ||
.replace(/-+/g, '-'); | ||
if (limit) { | ||
value = value.substr(0, limit); // Cap the slug length. | ||
} | ||
return value; | ||
} | ||
function fieldFocused(e) { | ||
@@ -172,2 +189,4 @@ var tags = /input|keygen|meter|option|output|progress|select|textarea/i; | ||
'browser': browser, | ||
'encodeURIComponent': encodeURIComponent, | ||
'decodeURIComponent': decodeURIComponent, | ||
'escape_': escape_, | ||
@@ -178,2 +197,3 @@ 'fieldFocused': fieldFocused, | ||
'querystring': querystring, | ||
'slugify': slugify, | ||
'urlencode': urlencode, | ||
@@ -180,0 +200,0 @@ 'urlparams': urlparams, |
@@ -10,2 +10,10 @@ define('views/debug', | ||
notification.notification({message: 'localStorage cleared', timeout: 1000}); | ||
}).on('click', '#clear-cookies', function(e) { | ||
var cookies = document.cookie.split(';'); | ||
for (var i = 0; i < cookies.length; i++) { | ||
var e = cookies[i].indexOf('='); | ||
var name = e > -1 ? cookies[i].substr(0, e) : c[i]; | ||
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT'; | ||
} | ||
notification.notification({message: 'cookies cleared', timeout: 1000}); | ||
}).on('click', '.cache-menu a', function(e) { | ||
@@ -36,3 +44,3 @@ e.preventDefault(); | ||
return function debug_view(builder, args) { | ||
return function(builder, args) { | ||
var recent_logs = log.get_recent(100); | ||
@@ -39,0 +47,0 @@ |
@@ -12,4 +12,4 @@ define('z', ['jquery'], function($) { | ||
context: {}, | ||
spaceheater: !!document.body.dataset.spaceheater | ||
spaceheater: !!document.body.getAttribute('data-spaceheater') | ||
}; | ||
}); |
@@ -25,2 +25,25 @@ (function() { | ||
test('slugify', function(done) { | ||
eq_(utils.slugify(null), null); | ||
eq_(utils.slugify(undefined), undefined); | ||
eq_(utils.slugify(''), ''); | ||
eq_(utils.slugify(' '), ''); | ||
eq_(utils.slugify(' - '), '-'); | ||
eq_(utils.slugify('<b> & "\'<'), 'b-'); | ||
eq_(utils.slugify('42'), '42'); | ||
eq_(utils.slugify('4 & square™'), '4-square'); | ||
eq_(utils.slugify('xx x - "#$@ x'), 'xx-x-x'); | ||
eq_(utils.slugify('Bän...g (bang)'), 'bng-bang'); | ||
eq_(utils.slugify('Ελληνικά'), ''); | ||
eq_(utils.slugify(' a '), 'a'); | ||
eq_(utils.slugify('tags/'), 'tags'); | ||
eq_(utils.slugify('holy_wars'), 'holy-wars'); | ||
eq_(utils.slugify('x荿'), 'x'); | ||
eq_(utils.slugify('ϧ蒬蓣'), ''); | ||
eq_(utils.slugify('¿x'), 'x'); | ||
done(); | ||
}); | ||
test('fieldFocused', function(done) { | ||
@@ -27,0 +50,0 @@ eq_(utils.fieldFocused({target: {nodeName: 'input'}}), true); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
858292
11434
82