handle most dependencies using requirejs

This commit is contained in:
Nils Schneider 2015-03-29 03:35:10 +02:00
parent ca8992b07a
commit 5651c605de
9 changed files with 30 additions and 15 deletions

21
app.js Normal file
View file

@ -0,0 +1,21 @@
require.config({
urlArgs: "bust=" + (new Date()).getTime(),
baseUrl: "lib",
paths: {
"leaflet": "../bower_components/leaflet/dist/leaflet",
"leaflet.label": "../bower_components/Leaflet.label/dist/leaflet.label",
"chroma-js": "../bower_components/chroma-js/chroma.min",
"moment": "../bower_components/moment/min/moment-with-locales.min",
"tablesort": "../bower_components/tablesort/tablesort.min",
"tablesort.numeric": "../bower_components/tablesort/src/sorts/tablesort.numeric"
},
shim: {
"leaflet.label": ["leaflet"],
"tablesort": {
exports: "Tablesort"
},
"tablesort.numeric": ["tablesort"]
}
})
require(["main"])

View file

@ -9,15 +9,9 @@
<link rel="stylesheet" href="bower_components/ionicons/css/ionicons.min.css">
<link rel="stylesheet" href="style.css">
<script src="bower_components/es6-shim/es6-shim.min.js"></script>
<script src="bower_components/chroma-js/chroma.min.js"></script>
<script src="bower_components/moment/min/moment-with-locales.min.js"></script>
<script src="bower_components/leaflet/dist/leaflet.js"></script>
<script src="bower_components/Leaflet.label/dist/leaflet.label.js"></script>
<script src="bower_components/tablesort/tablesort.min.js"></script>
<script src="bower_components/tablesort/src/sorts/tablesort.numeric.js"></script>
<script src="bower_components/intl/Intl.complete.js"></script>
<script src="helper.js"></script>
<script src="bower_components/requirejs/require.js" data-main="lib/main"></script>
<script src="bower_components/requirejs/require.js" data-main="app"></script>
</head>
<body>
</body>

View file

@ -1,4 +1,4 @@
define(function () {
define(["moment", "tablesort", "tablesort.numeric"], function (moment, Tablesort) {
return function(config, el, router, d) {
var h2 = document.createElement("h2")
h2.textContent = d.nodeinfo.hostname

View file

@ -1,4 +1,4 @@
define(function () {
define(["tablesort", "tablesort.numeric"], function (Tablesort) {
return function(linkScale, router) {
var self = this
var el

View file

@ -1,5 +1,5 @@
require(["config", "router", "map", "sidebar", "tabs", "container", "meshstats", "linklist", "nodelist", "simplenodelist", "infobox/main"],
function (Config, Router, Map, Sidebar, Tabs, Container, Meshstats, Linklist, Nodelist, SimpleNodelist, Infobox) {
require(["config", "moment", "chroma-js", "router", "map", "sidebar", "tabs", "container", "meshstats", "linklist", "nodelist", "simplenodelist", "infobox/main"],
function (Config, moment, chroma, Router, Map, Sidebar, Tabs, Container, Meshstats, Linklist, Nodelist, SimpleNodelist, Infobox) {
main(Config)
function main(config) {

View file

@ -1,4 +1,4 @@
define(function () {
define(["leaflet", "moment", "leaflet.label"], function (L, moment) {
var options = { worldCopyJump: true,
zoomControl: false
}

View file

@ -1,4 +1,4 @@
define(function () {
define(["moment"], function (moment) {
return function () {
var self = this
var p

View file

@ -1,4 +1,4 @@
define(function () {
define(["tablesort", "tablesort.numeric"], function (Tablesort) {
return function(router) {
var self = this
var el

View file

@ -1,4 +1,4 @@
define(function () {
define(["moment"], function (moment) {
return function(config, field, router, title) {
var self = this
var el