Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new inline layouts, top and center, for custom containers #116

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/noty/jquery.noty.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (typeof Object.create !== 'function') {
// Mix in the passed in options with the default options
this.options = $.extend({}, $.noty.defaults, options);

this.options.layout = (this.options.custom) ? $.noty.layouts['inline'] : $.noty.layouts[this.options.layout];
this.options.layout = (this.options.custom) ? $.noty.layouts['inline' + (options.layout ? '_' + options.layout : '')] : $.noty.layouts[this.options.layout];
this.options.theme = $.noty.themes[this.options.theme];

delete options.layout;
Expand Down
56 changes: 56 additions & 0 deletions js/noty/layouts/inline.center.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
;(function($) {

$.noty.layouts.inline_center = {
name: 'inline_center',
options: {},
container: {
object: '<ul id="noty_inline_layout_container" />',
selector: 'ul#noty_inline_layout_container',
style: function() {
$(this).parent().css({position: 'relative'});



$(this).css({
position: 'absolute',
width: '310px',
height: 'auto',
margin: 0,
padding: 0,
listStyleType: 'none',
zIndex: 10000000
});

// getting hidden height
var dupe = $(this).clone().css({visibility:"hidden", display:"block", position:"absolute", top: 0, left: 0}).attr('id', 'dupe');
$("body").append(dupe);
dupe.find('.i-am-closing-now').remove();
dupe.find('li').css('display', 'block');
var actual_height = dupe.height();
dupe.remove();

if ($(this).hasClass('i-am-new')) {
$(this).css({
left: ($(this).parent().width() - $(this).outerWidth(false)) / 2 + 'px',
top: ($(this).parent().outerHeight(false) - actual_height) / 2 + $(this).parent().scrollTop() + 'px'
});
} else {
$(this).animate({
left: ($(this).parent().width() - $(this).outerWidth(false)) / 2 + 'px',
top: ($(this).parent().outerHeight(false) - $(this).parent().scrollTop() - actual_height) / 2 + $(this).parent().scrollTop() + 'px'
}, 500);
}
}
},
parent: {
object: '<li />',
selector: 'li',
css: {}
},
css: {
display: 'none'
},
addClass: ''
};

})(jQuery);
36 changes: 36 additions & 0 deletions js/noty/layouts/inline.top.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
;(function($) {

$.noty.layouts.inline_top = {
name: 'inline_top',
options: {},
container: {
object: '<ul id="noty_inline_layout_container" />',
selector: 'ul#noty_inline_layout_container',
style: function() {
$(this).parent().css({position: 'relative'});

$(this).css({
position: 'absolute',
top: $(this).parent().scrollTop() + 'px',
left: '5%',
width: '90%',
height: 'auto',
margin: 0,
padding: 0,
listStyleType: 'none',
zIndex: 9999999
});
}
},
parent: {
object: '<li />',
selector: 'li',
css: {}
},
css: {
display: 'none'
},
addClass: ''
};

})(jQuery);
4 changes: 3 additions & 1 deletion js/noty/themes/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
var selector = this.options.layout.container.selector + ' ' + this.options.layout.parent.selector;
switch (this.options.layout.name) {
case 'top':
case 'inline_top':
$(selector).css({borderRadius: '0px 0px 0px 0px'});
$(selector).last().css({borderRadius: '0px 0px 5px 5px'}); break;
case 'topCenter': case 'topLeft': case 'topRight':
Expand Down Expand Up @@ -84,6 +85,7 @@

switch (this.options.layout.name) {
case 'top':
case 'inline_top':
this.$bar.css({
borderRadius: '0px 0px 5px 5px',
borderBottom: '2px solid #eee',
Expand All @@ -92,7 +94,7 @@
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)"
});
break;
case 'topCenter': case 'center': case 'bottomCenter': case 'inline':
case 'topCenter': case 'center': case 'bottomCenter': case 'inline': case 'inline_center':
this.$bar.css({
borderRadius: '5px',
border: '1px solid #eee',
Expand Down