diff --git a/src/app/index.coffee b/src/app/index.coffee index 715457b973..c533f5360c 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -1,7 +1,7 @@ derby = require('derby') {get, view, ready} = derby.createApp module derby.use require('derby-ui-boot') -#derby.use(require('../../ui')) +derby.use(require('../../ui')) ## ROUTES ## diff --git a/styles/ui.styl b/styles/ui.styl new file mode 100644 index 0000000000..a62c8e62b5 --- /dev/null +++ b/styles/ui.styl @@ -0,0 +1,15 @@ +.connection { + position: absolute; + text-align: center; + top: 0; + left: 0; + width: 100%; + height: 0; + z-index: 99; +} +.connection > .alert { + border-top: 0; + border-radius: 0 0 4px 4px; + padding-right: 14px; + display: inline-block; +} diff --git a/ui/connectionAlert/index.html b/ui/connectionAlert/index.html new file mode 100644 index 0000000000..21df475b49 --- /dev/null +++ b/ui/connectionAlert/index.html @@ -0,0 +1,15 @@ + +
+ {#unless connected} +

+ {#if canConnect} + Offline + {#unless :self.hideReconnect} + – Reconnect + {/} + {else} + Unable to reconnect – Reload + {/} +

+ {/} +
diff --git a/ui/connectionAlert/index.js b/ui/connectionAlert/index.js new file mode 100644 index 0000000000..01808549ba --- /dev/null +++ b/ui/connectionAlert/index.js @@ -0,0 +1,15 @@ +exports.create = function(model) { + + this.connect = function() { + // Hide the reconnect link for a second after clicking it + model.set('hideReconnect', true) + setTimeout(function() { + model.set('hideReconnect', false) + }, 1000) + model.socket.socket.connect() + } + + this.reload = function() { + window.location.reload() + } +} diff --git a/ui/index.js b/ui/index.js new file mode 100644 index 0000000000..229e0ad12e --- /dev/null +++ b/ui/index.js @@ -0,0 +1,14 @@ +var config = { + filename: __filename +, styles: '../styles/ui' +, scripts: { + connectionAlert: require('./connectionAlert') + } +}; + +module.exports = ui +ui.decorate = 'derby' + +function ui(derby, options) { + derby.createLibrary(config, options) +} diff --git a/views/app/index.html b/views/app/index.html index 97bb6dd0de..b727d4b147 100644 --- a/views/app/index.html +++ b/views/app/index.html @@ -2,7 +2,8 @@ HabitRPG - + +