Skip to content

Commit

Permalink
amd compability #73
Browse files Browse the repository at this point in the history
  • Loading branch information
needim committed Oct 23, 2014
1 parent d0ad9b6 commit 2e0a79e
Show file tree
Hide file tree
Showing 21 changed files with 1,413 additions and 1,510 deletions.
15 changes: 13 additions & 2 deletions Gruntfile.js
Expand Up @@ -23,6 +23,16 @@ module.exports = function(grunt) {
}
},

wrap: {
basic: {
src: 'js/noty/packaged/jquery.noty.packaged.js',
dest: 'js/noty/packaged/jquery.noty.packaged.js',
options: {
wrapper: ["!function(root, factory) {\n\t if (typeof define === 'function' && define.amd) {\n\t\t define(['jquery'], factory);\n\t } else {\n\t\t factory(root.jQuery);\n } }(this, function($) {\n", "\n});"]
}
}
},

uglify: {
options : {
preserveComments: function(a) {
Expand All @@ -40,8 +50,9 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-wrap');

grunt.registerTask('build', ['bump', 'concat', 'uglify:minifyJS']);
grunt.registerTask('conc', ['concat']);
grunt.registerTask('build', ['bump', 'concat', 'wrap', 'uglify:minifyJS']);
grunt.registerTask('conc', ['concat', 'wrap']);
grunt.registerTask('ugly', ['uglify:minifyJS']);
};
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name" : "noty",
"version" : "2.2.9",
"version" : "2.2.10",
"main" : "js/noty/packaged/jquery.noty.packaged.js",
"authors" : [
"Nedim Arabacı"
Expand Down
30 changes: 13 additions & 17 deletions js/noty/jquery.noty.js
@@ -1,24 +1,22 @@
/*!
@package noty - jQuery Notification Plugin
@version version: 2.2.9
@version version: 2.2.10
@contributors https://github.com/needim/noty/graphs/contributors
@documentation Examples and Documentation - http://needim.github.com/noty/
@license Licensed under the MIT licenses: http://www.opensource.org/licenses/mit-license.php
*/

if(typeof Object.create !== 'function') {
Object.create = function(o) {
function F() {
}

F.prototype = o;
return new F();
};
}
if(typeof Object.create !== 'function') {
Object.create = function(o) {
function F() {
}

(function($) {
F.prototype = o;
return new F();
};
}

var NotyObject = {

Expand Down Expand Up @@ -494,9 +492,7 @@ if(typeof Object.create !== 'function') {
});
});

})(jQuery);

// Helpers
window.noty = function noty(options) {
return jQuery.notyRenderer.init(options);
};
// Helpers
window.noty = function noty(options) {
return jQuery.notyRenderer.init(options);

This comment has been minimized.

Copy link
@purtuga

purtuga Oct 24, 2014

It was good that you moved this block of code to be inside of the jQuery wrapper function, but you are still referencing a global jQuery variable here... jQuery in this line needs to be changed to $.
Also, is there a way to prevent the global space (window) from having this set, specially when in an AMD mode?

};
64 changes: 30 additions & 34 deletions js/noty/layouts/bottom.js
@@ -1,34 +1,30 @@
(function($) {

$.noty.layouts.bottom = {
name : 'bottom',
options : {},
container: {
object : '<ul id="noty_bottom_layout_container" />',
selector: 'ul#noty_bottom_layout_container',
style : function() {
$(this).css({
bottom : 0,
left : '5%',
position : 'fixed',
width : '90%',
height : 'auto',
margin : 0,
padding : 0,
listStyleType: 'none',
zIndex : 9999999
});
}
},
parent : {
object : '<li />',
selector: 'li',
css : {}
},
css : {
display: 'none'
},
addClass : ''
};

})(jQuery);
$.noty.layouts.bottom = {
name : 'bottom',
options : {},
container: {
object : '<ul id="noty_bottom_layout_container" />',
selector: 'ul#noty_bottom_layout_container',
style : function() {
$(this).css({
bottom : 0,
left : '5%',
position : 'fixed',
width : '90%',
height : 'auto',
margin : 0,
padding : 0,
listStyleType: 'none',
zIndex : 9999999
});
}
},
parent : {
object : '<li />',
selector: 'li',
css : {}
},
css : {
display: 'none'
},
addClass : ''
};
73 changes: 35 additions & 38 deletions js/noty/layouts/bottomCenter.js
@@ -1,41 +1,38 @@
(function($) {
$.noty.layouts.bottomCenter = {
name : 'bottomCenter',
options : { // overrides options

$.noty.layouts.bottomCenter = {
name : 'bottomCenter',
options : { // overrides options
},
container: {
object : '<ul id="noty_bottomCenter_layout_container" />',
selector: 'ul#noty_bottomCenter_layout_container',
style : function() {
$(this).css({
bottom : 20,
left : 0,
position : 'fixed',
width : '310px',
height : 'auto',
margin : 0,
padding : 0,
listStyleType: 'none',
zIndex : 10000000
});

},
container: {
object : '<ul id="noty_bottomCenter_layout_container" />',
selector: 'ul#noty_bottomCenter_layout_container',
style : function() {
$(this).css({
bottom : 20,
left : 0,
position : 'fixed',
width : '310px',
height : 'auto',
margin : 0,
padding : 0,
listStyleType: 'none',
zIndex : 10000000
});
$(this).css({
left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px'
});
}
},
parent : {
object : '<li />',
selector: 'li',
css : {}
},
css : {
display: 'none',
width : '310px'
},
addClass : ''
};

$(this).css({
left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px'
});
}
},
parent : {
object : '<li />',
selector: 'li',
css : {}
},
css : {
display: 'none',
width : '310px'
},
addClass : ''
};

})(jQuery);
72 changes: 34 additions & 38 deletions js/noty/layouts/bottomLeft.js
@@ -1,43 +1,39 @@
(function($) {
$.noty.layouts.bottomLeft = {
name : 'bottomLeft',
options : { // overrides options

$.noty.layouts.bottomLeft = {
name : 'bottomLeft',
options : { // overrides options
},
container: {
object : '<ul id="noty_bottomLeft_layout_container" />',
selector: 'ul#noty_bottomLeft_layout_container',
style : function() {
$(this).css({
bottom : 20,
left : 20,
position : 'fixed',
width : '310px',
height : 'auto',
margin : 0,
padding : 0,
listStyleType: 'none',
zIndex : 10000000
});

},
container: {
object : '<ul id="noty_bottomLeft_layout_container" />',
selector: 'ul#noty_bottomLeft_layout_container',
style : function() {
if(window.innerWidth < 600) {
$(this).css({
bottom : 20,
left : 20,
position : 'fixed',
width : '310px',
height : 'auto',
margin : 0,
padding : 0,
listStyleType: 'none',
zIndex : 10000000
left: 5
});

if(window.innerWidth < 600) {
$(this).css({
left: 5
});
}
}
},
parent : {
object : '<li />',
selector: 'li',
css : {}
},
css : {
display: 'none',
width : '310px'
},
addClass : ''
};

})(jQuery);
}
},
parent : {
object : '<li />',
selector: 'li',
css : {}
},
css : {
display: 'none',
width : '310px'
},
addClass : ''
};
72 changes: 34 additions & 38 deletions js/noty/layouts/bottomRight.js
@@ -1,43 +1,39 @@
(function($) {
$.noty.layouts.bottomRight = {
name : 'bottomRight',
options : { // overrides options

$.noty.layouts.bottomRight = {
name : 'bottomRight',
options : { // overrides options
},
container: {
object : '<ul id="noty_bottomRight_layout_container" />',
selector: 'ul#noty_bottomRight_layout_container',
style : function() {
$(this).css({
bottom : 20,
right : 20,
position : 'fixed',
width : '310px',
height : 'auto',
margin : 0,
padding : 0,
listStyleType: 'none',
zIndex : 10000000
});

},
container: {
object : '<ul id="noty_bottomRight_layout_container" />',
selector: 'ul#noty_bottomRight_layout_container',
style : function() {
if(window.innerWidth < 600) {
$(this).css({
bottom : 20,
right : 20,
position : 'fixed',
width : '310px',
height : 'auto',
margin : 0,
padding : 0,
listStyleType: 'none',
zIndex : 10000000
right: 5
});

if(window.innerWidth < 600) {
$(this).css({
right: 5
});
}
}
},
parent : {
object : '<li />',
selector: 'li',
css : {}
},
css : {
display: 'none',
width : '310px'
},
addClass : ''
};

})(jQuery);
}
},
parent : {
object : '<li />',
selector: 'li',
css : {}
},
css : {
display: 'none',
width : '310px'
},
addClass : ''
};

0 comments on commit 2e0a79e

Please sign in to comment.