Skip to content

Commit

Permalink
visibilityControl behaviour fix & progressbar fix
Browse files Browse the repository at this point in the history
  • Loading branch information
needim committed Jul 12, 2017
1 parent 463c55f commit a6cccf8
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 45 deletions.
17 changes: 17 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ module.exports = function (grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
usebanner: {
taskName: {
options: {
position: 'top',
banner: '/* \n @package NOTY - Dependency-free notification library \n' +
' @version version: <%= pkg.version %> \n' +
' @contributors https://github.com/needim/noty/graphs/contributors \n' +
' @documentation Examples and Documentation - http://needim.github.com/noty \n' +
' @license Licensed under the MIT licenses: http://www.opensource.org/licenses/mit-license.php \n*/\n',
linebreak: true
},
files: {
src: ['lib/noty.js', 'lib/noty.min.js']
}
}
},
qunit: {
options: {
inject: 'test/unit/phantom.js'
Expand Down Expand Up @@ -88,6 +104,7 @@ module.exports = function (grunt) {

require('load-grunt-tasks')(grunt)

grunt.registerTask('banner', 'usebanner')
grunt.registerTask('test', 'qunit')
grunt.registerTask('saucelabs', ['qunit', 'connect', 'saucelabs-qunit'])
grunt.registerTask('default', ['test'])
Expand Down
2 changes: 1 addition & 1 deletion lib/noty.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 30 additions & 15 deletions lib/noty.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/noty.js.map

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions lib/noty.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/noty.min.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "noty",
"version": "3.1.0",
"version": "3.1.1",
"title": "Noty - Notification library",
"description": "Noty is a library that makes it easy to create alert - success - error - warning - information - confirmation messages as an alternative the standard alert dialog. Each notification is added to a queue. (Optional)",
"homepage": "http://ned.im/noty",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"license": "MIT",
"scripts": {
"build": "webpack --env build",
"build": "webpack --env build && grunt banner",
"dev": "webpack --progress --colors --watch --env dev",
"format": "prettier-standard 'src/**/*.js'",
"test": "npm run format && standard && grunt test",
Expand Down Expand Up @@ -61,6 +61,7 @@
"eslint-loader": "1.7.1",
"extract-text-webpack-plugin": "2.1.0",
"grunt": "^1.0.1",
"grunt-banner": "^0.6.0",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-qunit": "^2.0.0",
"grunt-exec": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export let Defaults = {
conditions: []
},
modal: false,
visibilityControl: true
visibilityControl: false
}

/**
Expand Down
48 changes: 27 additions & 21 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,36 @@ export default class Noty {
* @return {Noty}
*/
show () {
if (this.options.killer === true && !API.PageHidden) {
if (this.options.killer === true) {
Noty.closeAll()
} else if (typeof this.options.killer === 'string' && !API.PageHidden) {
} else if (typeof this.options.killer === 'string') {
Noty.closeAll(this.options.killer)
} else {
let queueCounts = API.getQueueCounts(this.options.queue)

if (queueCounts.current >= queueCounts.maxVisible || API.PageHidden) {
API.addToQueue(this)
}

if (
API.PageHidden &&
this.hasSound &&
Utils.inArray('docHidden', this.options.sounds.conditions)
) {
Utils.createAudioElements(this)
}
let queueCounts = API.getQueueCounts(this.options.queue)

if (
API.PageHidden &&
Utils.inArray('docHidden', this.options.titleCount.conditions)
) {
API.docTitle.increment()
}
if (
queueCounts.current >= queueCounts.maxVisible ||
(API.PageHidden && this.options.visibilityControl)
) {
API.addToQueue(this)

if (
API.PageHidden &&
this.hasSound &&
Utils.inArray('docHidden', this.options.sounds.conditions)
) {
Utils.createAudioElements(this)
}

return this
if (
API.PageHidden &&
Utils.inArray('docHidden', this.options.titleCount.conditions)
) {
API.docTitle.increment()
}

return this
}

API.Store[this.id] = this
Expand Down Expand Up @@ -172,6 +175,9 @@ export default class Noty {
)

if (this.options.timeout) Utils.addClass(this.barDom, 'noty_has_timeout')
if (this.options.progressBar) {
Utils.addClass(this.barDom, 'noty_has_progressbar')
}

if (Utils.inArray('button', this.options.closeWith)) {
Utils.addClass(this.barDom, 'noty_close_with_button')
Expand Down
2 changes: 1 addition & 1 deletion src/noty.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ $corner-space: 20px;
display: none;
}

.noty_has_timeout .noty_progressbar {
.noty_has_timeout.noty_has_progressbar .noty_progressbar {
display: block;
position: absolute;
left: 0;
Expand Down

0 comments on commit a6cccf8

Please sign in to comment.