Finally, I managed to implement the third solution: I created a web module that wraps the library in a file called notiy.js:
define(['jquery', 'noty/layouts/topCenter', 'noty/layouts/bottomRight', 'noty/themes/default'], function($){ $.noty.defaults.timeout = 20000; return function(type, msg){ var topLayout = 'topCenter', bottomLayout = 'bottomRight', layout = { 'alert' : topLayout, 'info' : bottomLayout, 'confirm' : topLayout, 'success' : bottomLayout, 'error' : topLayout, 'warning' : topLayout }; if(msg && type){ return noty({ text : msg, layout: layout[type] || topLayout, type : type }); } } });
I declared the dependencies in the shim configuration (to fix the order of the dependencies) in my app.js application:
requirejs.config({ baseUrl: 'js/lib', urlArgs: 'bust=' + (new Date()).getTime(), //only for dev : no-cache paths: { user: '../user' }, shim: { 'jquery-ui' : ['jquery'], 'jquery-tmpl' : ['jquery'], 'gridy' : ['jquery'], 'noty/jquery.noty' : ['jquery'], 'notify' : ['noty/jquery.noty'] } }); requirejs(['jquery', 'jquery-ui', 'jquery-tmpl', 'notify'], function($, ui, tmpl, notify){ //... });
Ans works like a charm!
source share