Skip to content

Commit

Permalink
v2.3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
needim committed Dec 20, 2016
1 parent 95f9f30 commit d03d12f
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 35 deletions.
3 changes: 3 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<div>
<a href="allLayouts.html">See All Layouts</a>
</div>
<div>
<a href="noanim.html">Using without animations</a>
</div>
<div>
<a href="allTypes.html">See All Types</a>
</div>
Expand Down
75 changes: 75 additions & 0 deletions demo/noanim.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>No Animation</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="demonstration of some noty capabilities">

<link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic&amp;subset=latin,latin-ext,cyrillic' rel='stylesheet' type='text/css'>
<style type="text/css">

html {
height: 100%;
width: 100%;
}

body {
font-family: 'PT Sans', Tahoma, Arial, serif;
line-height: 13px
}

</style>

<link rel="stylesheet" type="text/css" href="buttons.css"/>
<link rel="stylesheet" type="text/css" href="animate.css"/>

</head>
<body>

<div class="container">

<div id="customContainer"></div>

</div>

<script src="jquery-1.7.2.min.js"></script>

<!-- noty -->
<script type="text/javascript" src="../js/noty/packaged/jquery.noty.packaged.js"></script>

<script type="text/javascript">

function generate(type) {
var n = noty({
text : type,
type : type,
dismissQueue: true,
closeWith: ['click'],
layout : 'topCenter',
theme : 'relax',
animation: {
open: null,
close: null
}
});
console.log(type + ' - ' + n.options.id);
return n;
}

$(document).ready(function () {

var alert = generate('alert');
var information = generate('information');
var error = generate('error');
var warning = generate('warning');
var notification = generate('notification');
var success = generate('success');


});

</script>
</body>
</html>
1 change: 1 addition & 0 deletions demo/usingWithAnimate.css.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
}
});
console.log('html: ' + n.options.id);
return n;
}

function generateAll() {
Expand Down
83 changes: 67 additions & 16 deletions js/noty/jquery.noty.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
@package noty - jQuery Notification Plugin
@version version: 2.3.10
@version version: 2.3.11
@contributors https://github.com/needim/noty/graphs/contributors
@documentation Examples and Documentation - http://needim.github.com/noty/
Expand Down Expand Up @@ -39,8 +39,15 @@ var NotyObject = {
this.options.themeClassName = this.options.theme;
}

this.options = $.extend({}, this.options, this.options.layout.options);
this.options.id = 'noty_' + (new Date().getTime() * Math.floor(Math.random() * 1000000));
this.options = $.extend({}, this.options, this.options.layout.options);

if (this.options.id) {
if ($.noty.store[this.options.id]) {
return $.noty.store[this.options.id];
}
} else {
this.options.id = 'noty_' + (new Date().getTime() * Math.floor(Math.random() * 1000000));
}

// Build the noty dom initial structure
this._build();
Expand All @@ -63,10 +70,6 @@ var NotyObject = {
// Set buttons if available
if (this.options.buttons) {

// If we have button disable closeWith & timeout options
this.options.closeWith = [];
this.options.timeout = false;

var $buttons;
// Try find container for buttons in presented template, and create it if not found
if (this.$bar.find('.noty_buttons').length > 0) {
Expand Down Expand Up @@ -123,7 +126,7 @@ var NotyObject = {
self.options.theme.callback.onShow.apply(this);

if ($.inArray('click', self.options.closeWith) > -1)
self.$bar.css('cursor', 'pointer').one('click', function (evt) {
self.$bar.css('cursor', 'pointer').on('click', function (evt) {
self.stopPropagation(evt);
if (self.options.callback.onCloseClick) {
self.options.callback.onCloseClick.apply(self);
Expand All @@ -145,15 +148,21 @@ var NotyObject = {
if ($.inArray('button', self.options.closeWith) == -1)
self.$closeButton.remove();

if (self.options.callback.onShow)
self.options.callback.onShow.apply(self);
if (self.options.callback.beforeShow)
self.options.callback.beforeShow.apply(self);

if (typeof self.options.animation.open == 'string') {
self.animationTypeOpen = 'css';
self.$bar.css('min-height', self.$bar.innerHeight());
self.$bar.on('click', function (e) {
self.wasClicked = true;
});
self.$bar.show().addClass(self.options.animation.open).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
self.$bar.show();

if (self.options.callback.onShow)
self.options.callback.onShow.apply(self);

self.$bar.addClass(self.options.animation.open).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
if (self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
self.showing = false;
self.shown = true;
Expand All @@ -165,7 +174,26 @@ var NotyObject = {
}
});

} else if (typeof self.options.animation.open == 'object' && self.options.animation.open == null) {
self.animationTypeOpen = 'none';
self.showing = false;
self.shown = true;
self.$bar.show();

if (self.options.callback.onShow)
self.options.callback.onShow.apply(self);

self.$bar.queue(function () {
if (self.options.callback.afterShow)
self.options.callback.afterShow.apply(self);
});

} else {
self.animationTypeOpen = 'anim';

if (self.options.callback.onShow)
self.options.callback.onShow.apply(self);

self.$bar.animate(
self.options.animation.open,
self.options.animation.speed,
Expand Down Expand Up @@ -211,13 +239,17 @@ var NotyObject = {

var self = this;

if (this.showing) {
if (this.showing && (this.animationTypeOpen == 'anim' || this.animationTypeOpen == 'none')) {
self.$bar.queue(
function () {
self.close.apply(self);
}
);
return;
} else if (this.showing && this.animationTypeOpen == 'css') {
self.$bar.on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
self.close();
});
}

if (!this.shown && !this.showing) { // If we are still waiting in the queue just delete from queue
Expand All @@ -242,6 +274,13 @@ var NotyObject = {
if (self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
self.closeCleanUp();
});

} else if (typeof self.options.animation.close == 'object' && self.options.animation.close == null) {
self.$bar.dequeue().hide(0, function() {
if (self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
self.closeCleanUp();
});

} else {
self.$bar.clearQueue().stop().animate(
self.options.animation.close,
Expand Down Expand Up @@ -277,7 +316,7 @@ var NotyObject = {
if (typeof self.$bar !== 'undefined' && self.$bar !== null) {

if (typeof self.options.animation.close == 'string') {
self.$bar.css('transition', 'all 100ms ease').css('border', 0).css('margin', 0).height(0);
self.$bar.css('transition', 'all 10ms ease').css('border', 0).css('margin', 0).height(0);
self.$bar.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function () {
self.$bar.remove();
self.$bar = null;
Expand All @@ -286,14 +325,25 @@ var NotyObject = {
if (self.options.theme.callback && self.options.theme.callback.onClose) {
self.options.theme.callback.onClose.apply(self);
}

self.handleNext();
});
} else {
self.$bar.remove();
self.$bar = null;
self.closed = true;

self.handleNext();
}
} else {
self.handleNext();
}

}, // end close clean up

handleNext: function () {
var self = this;

delete $.noty.store[self.options.id]; // deleting noty from store

if (self.options.theme.callback && self.options.theme.callback.onClose) {
Expand All @@ -310,8 +360,7 @@ var NotyObject = {
if (self.options.maxVisible > 0 && self.options.dismissQueue) {
$.notyRenderer.render();
}

}, // end close clean up
},

setText: function (text) {
if (!this.closed) {
Expand Down Expand Up @@ -445,7 +494,7 @@ $.notyRenderer.createModalFor = function (notification) {
modal.prependTo($('body')).fadeIn(notification.options.animation.fadeSpeed);

if ($.inArray('backdrop', notification.options.closeWith) > -1)
modal.on('click', function (e) {
modal.on('click', function () {
$.noty.closeAll();
});
}
Expand Down Expand Up @@ -546,6 +595,8 @@ $.noty.defaults = {
killer : false,
closeWith : ['click'],
callback : {
beforeShow : function () {
},
onShow : function () {
},
afterShow : function () {
Expand Down
Loading

0 comments on commit d03d12f

Please sign in to comment.