replace Intl.NumberFormat with numeraljs

This commit is contained in:
Nils Schneider 2015-04-02 02:33:17 +02:00
parent 534f7bbed4
commit 141e98f027
7 changed files with 13 additions and 14 deletions

5
app.js
View File

@ -8,6 +8,8 @@ require.config({
"tablesort": "../bower_components/tablesort/tablesort.min", "tablesort": "../bower_components/tablesort/tablesort.min",
"tablesort.numeric": "../bower_components/tablesort/src/sorts/tablesort.numeric", "tablesort.numeric": "../bower_components/tablesort/src/sorts/tablesort.numeric",
"d3": "../bower_components/d3/d3.min", "d3": "../bower_components/d3/d3.min",
"numeral": "../bower_components/numeraljs/min/numeral.min",
"numeral-intl": "../bower_components/numeraljs/min/languages.min",
"helper": "../helper" "helper": "../helper"
}, },
shim: { shim: {
@ -15,8 +17,9 @@ require.config({
"tablesort": { "tablesort": {
exports: "Tablesort" exports: "Tablesort"
}, },
"numeral-intl": ["numeral"],
"tablesort.numeric": ["tablesort"], "tablesort.numeric": ["tablesort"],
"helper": [] "helper": ["numeral-intl"]
} }
}) })

View File

@ -10,7 +10,6 @@
"dependencies": { "dependencies": {
"Leaflet.label": "~0.2.1", "Leaflet.label": "~0.2.1",
"chroma-js": "~0.6.1", "chroma-js": "~0.6.1",
"intl": "~0.1.4",
"leaflet": "~0.7.3", "leaflet": "~0.7.3",
"ionicons": "~2.0.1", "ionicons": "~2.0.1",
"moment": "~2.9.0", "moment": "~2.9.0",
@ -20,7 +19,8 @@
"es6-shim": "~0.27.1", "es6-shim": "~0.27.1",
"almond": "~0.3.1", "almond": "~0.3.1",
"r.js": "~2.1.16", "r.js": "~2.1.16",
"d3": "~3.5.5" "d3": "~3.5.5",
"numeraljs": "~1.5.3"
}, },
"authors": [ "authors": [
"Nils Schneider <nils@nilsschneider.net>" "Nils Schneider <nils@nilsschneider.net>"

View File

@ -105,13 +105,11 @@ function showDistance(d) {
if (isNaN(d.distance)) if (isNaN(d.distance))
return return
return (new Intl.NumberFormat("de-DE", {maximumFractionDigits: 0}).format(d.distance)) + " m" return numeral(d.distance).format("0,0") + " m"
} }
function showTq(d) { function showTq(d) {
var opts = { maximumFractionDigits: 0 } return numeral(1/d.tq).format("0%")
return (new Intl.NumberFormat("de-DE", opts).format(100/d.tq)) + "%"
} }
function linkId(d) { function linkId(d) {

View File

@ -7,7 +7,6 @@
<link rel="stylesheet" href="roboto-slab-fontface.css"> <link rel="stylesheet" href="roboto-slab-fontface.css">
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<script src="vendor/es6-shim/es6-shim.min.js"></script> <script src="vendor/es6-shim/es6-shim.min.js"></script>
<script src="vendor/intl/Intl.complete.js"></script>
<script src="app.js"></script> <script src="app.js"></script>
</head> </head>
<body> <body>

View File

@ -9,7 +9,6 @@
<link rel="stylesheet" href="bower_components/ionicons/css/ionicons.min.css"> <link rel="stylesheet" href="bower_components/ionicons/css/ionicons.min.css">
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<script src="bower_components/es6-shim/es6-shim.min.js"></script> <script src="bower_components/es6-shim/es6-shim.min.js"></script>
<script src="bower_components/intl/Intl.complete.js"></script>
<script src="bower_components/requirejs/require.js" data-main="app"></script> <script src="bower_components/requirejs/require.js" data-main="app"></script>
</head> </head>
<body> <body>

View File

@ -1,5 +1,5 @@
define(["config", "moment", "router", "leaflet", "gui"], define(["config", "moment", "router", "leaflet", "gui", "numeral"],
function (config, moment, Router, L, GUI) { function (config, moment, Router, L, GUI, numeral) {
return function () { return function () {
function handleData(data) { function handleData(data) {
var nodes = Object.keys(data[0].nodes).map(function (key) { return data[0].nodes[key] }) var nodes = Object.keys(data[0].nodes).map(function (key) { return data[0].nodes[key] })
@ -77,7 +77,9 @@ function (config, moment, Router, L, GUI) {
} }
} }
numeral.language("de")
moment.locale("de") moment.locale("de")
var router = new Router() var router = new Router()
var urls = [ config.dataPath + "nodes.json", var urls = [ config.dataPath + "nodes.json",

View File

@ -13,9 +13,7 @@ module.exports = function(grunt) {
dest: "build/" dest: "build/"
}, },
vendorjs: { vendorjs: {
src: [ "es6-shim/es6-shim.min.js", src: [ "es6-shim/es6-shim.min.js" ],
"intl/Intl.complete.js"
],
expand: true, expand: true,
cwd: "bower_components/", cwd: "bower_components/",
dest: "build/vendor/" dest: "build/vendor/"