Skip to content

Commit

Permalink
Add new inline layouts, top and center, for custom containers
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrykt committed Jan 13, 2013
1 parent 3c32c0d commit 812c707
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/noty/jquery.noty.js
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
@@ -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
@@ -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
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

0 comments on commit 812c707

Please sign in to comment.