diff --git a/src/_h5ai/client/css/inc/view/notify.less b/src/_h5ai/client/css/inc/view/notification.less similarity index 86% rename from src/_h5ai/client/css/inc/view/notify.less rename to src/_h5ai/client/css/inc/view/notification.less index 349f93a0..fc4f417e 100644 --- a/src/_h5ai/client/css/inc/view/notify.less +++ b/src/_h5ai/client/css/inc/view/notification.less @@ -1,4 +1,4 @@ -#notify { +#notification { position: fixed; left: 50%; width: 200px; @@ -9,4 +9,5 @@ background: rgba(0,0,0,0.2); border-radius: 0 0 4px 4px; text-align: center; + overflow: hidden; } diff --git a/src/_h5ai/client/js/inc/core/location.js b/src/_h5ai/client/js/inc/core/location.js index 7f416270..b667ed31 100644 --- a/src/_h5ai/client/js/inc/core/location.js +++ b/src/_h5ai/client/js/inc/core/location.js @@ -1,4 +1,4 @@ -modulejs.define('core/location', ['_', 'modernizr', 'core/event', 'core/notify', 'core/settings'], function (_, modernizr, event, notify, allsettings) { +modulejs.define('core/location', ['_', 'modernizr', 'core/event', 'core/settings', 'view/notification'], function (_, modernizr, event, allsettings, notification) { var settings = _.extend({ fastBrowsing: true, @@ -135,10 +135,10 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/event', 'core/notify', event.pub('location.changed', item); refresh(); } else { - notify.set('loading...'); + notification.set('loading...'); load(function () { item.isLoaded = true; - notify.set(); + notification.set(); event.pub('location.changed', item); }); } diff --git a/src/_h5ai/client/js/inc/core/notify.js b/src/_h5ai/client/js/inc/core/notify.js deleted file mode 100644 index 281908ad..00000000 --- a/src/_h5ai/client/js/inc/core/notify.js +++ /dev/null @@ -1,19 +0,0 @@ -modulejs.define('core/notify', ['$'], function ($) { - - var template = '
'; - - function set(content) { - - if (content) { - $('#notify').stop(true, true).html(content).fadeIn(400); - } else { - $('#notify').stop(true, true).fadeOut(400); - } - } - - $(template).hide().appendTo('body'); - - return { - set: set - }; -}); diff --git a/src/_h5ai/client/js/inc/view/notification.js b/src/_h5ai/client/js/inc/view/notification.js new file mode 100644 index 00000000..a3e44ec9 --- /dev/null +++ b/src/_h5ai/client/js/inc/view/notification.js @@ -0,0 +1,19 @@ +modulejs.define('view/notification', ['$'], function ($) { + + var template = '
'; + + function set(content) { + + if (content) { + $('#notification').stop(true, true).html(content).fadeIn(400); + } else { + $('#notification').stop(true, true).fadeOut(400); + } + } + + $(template).hide().appendTo('body'); + + return { + set: set + }; +}); diff --git a/test/tests/unit/core/location.js b/test/tests/unit/core/location.js index a44f5b65..d0e1e922 100644 --- a/test/tests/unit/core/location.js +++ b/test/tests/unit/core/location.js @@ -2,7 +2,7 @@ 'use strict'; var ID = 'core/location'; -var DEPS = ['_', 'modernizr', 'core/event', 'core/notify', 'core/settings']; +var DEPS = ['_', 'modernizr', 'core/event', 'core/settings', 'view/notification']; describe('module \'' + ID + '\'', function () { @@ -21,16 +21,16 @@ describe('module \'' + ID + '\'', function () { pub: sinon.stub(), sub: sinon.stub() }; - this.xNotify = { + this.xNotification = { set: sinon.stub() }; this.applyFn = function () { this.xEvent.pub.reset(); this.xEvent.sub.reset(); - this.xNotify.set.reset(); + this.xNotification.set.reset(); - return this.definition.fn(_, this.xModernizr, this.xEvent, this.xNotify, this.xSettings); + return this.definition.fn(_, this.xModernizr, this.xEvent, this.xSettings, this.xNotification); }; }); diff --git a/test/tests/unit/core/notify.js b/test/tests/unit/view/notification.js similarity index 72% rename from test/tests/unit/core/notify.js rename to test/tests/unit/view/notification.js index 20a9a5c0..bc7ee417 100644 --- a/test/tests/unit/core/notify.js +++ b/test/tests/unit/view/notification.js @@ -1,7 +1,7 @@ (function () { 'use strict'; -var ID = 'core/notify'; +var ID = 'view/notification'; var DEPS = ['$']; describe('module \'' + ID + '\'', function () { @@ -71,9 +71,9 @@ describe('module \'' + ID + '\'', function () { it('adds HTML', function () { this.applyFn(); - assert.lengthOf($('#notify'), 1); - assert.lengthOf($('#notify:visible'), 0); - assert.strictEqual($('#notify').text(), ''); + assert.lengthOf($('#notification'), 1); + assert.lengthOf($('#notification:visible'), 0); + assert.strictEqual($('#notification').text(), ''); }); }); @@ -90,20 +90,20 @@ describe('module \'' + ID + '\'', function () { var instance = this.applyFn(); instance.set(); - assert.lengthOf($('#notify:visible'), 0); - assert.strictEqual($('#notify').text(), ''); + assert.lengthOf($('#notification:visible'), 0); + assert.strictEqual($('#notification').text(), ''); instance.set('hello'); - assert.lengthOf($('#notify:visible'), 1); - assert.strictEqual($('#notify').text(), 'hello'); + assert.lengthOf($('#notification:visible'), 1); + assert.strictEqual($('#notification').text(), 'hello'); instance.set('world'); - assert.lengthOf($('#notify:visible'), 1); - assert.strictEqual($('#notify').text(), 'world'); + assert.lengthOf($('#notification:visible'), 1); + assert.strictEqual($('#notification').text(), 'world'); instance.set(); - // assert.lengthOf($('#notify:visible'), 0); - assert.strictEqual($('#notify').text(), 'world'); + // assert.lengthOf($('#notification:visible'), 0); + assert.strictEqual($('#notification').text(), 'world'); }); }); });