jquery.noty.packaged.js 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289
  1. !function(root, factory) {
  2. if (typeof define === 'function' && define.amd) {
  3. define(['jquery'], factory);
  4. } else if (typeof exports === 'object') {
  5. module.exports = factory(require('jquery'));
  6. } else {
  7. factory(root.jQuery);
  8. }
  9. }(this, function($) {
  10. /*!
  11. @package noty - jQuery Notification Plugin
  12. @version version: 2.3.8
  13. @contributors https://github.com/needim/noty/graphs/contributors
  14. @documentation Examples and Documentation - http://needim.github.com/noty/
  15. @license Licensed under the MIT licenses: http://www.opensource.org/licenses/mit-license.php
  16. */
  17. if(typeof Object.create !== 'function') {
  18. Object.create = function(o) {
  19. function F() {
  20. }
  21. F.prototype = o;
  22. return new F();
  23. };
  24. }
  25. var NotyObject = {
  26. init: function(options) {
  27. // Mix in the passed in options with the default options
  28. this.options = $.extend({}, $.noty.defaults, options);
  29. this.options.layout = (this.options.custom) ? $.noty.layouts['inline'] : $.noty.layouts[this.options.layout];
  30. if($.noty.themes[this.options.theme])
  31. this.options.theme = $.noty.themes[this.options.theme];
  32. else
  33. this.options.themeClassName = this.options.theme;
  34. this.options = $.extend({}, this.options, this.options.layout.options);
  35. this.options.id = 'noty_' + (new Date().getTime() * Math.floor(Math.random() * 1000000));
  36. // Build the noty dom initial structure
  37. this._build();
  38. // return this so we can chain/use the bridge with less code.
  39. return this;
  40. }, // end init
  41. _build: function() {
  42. // Generating noty bar
  43. var $bar = $('<div class="noty_bar noty_type_' + this.options.type + '"></div>').attr('id', this.options.id);
  44. $bar.append(this.options.template).find('.noty_text').html(this.options.text);
  45. this.$bar = (this.options.layout.parent.object !== null) ? $(this.options.layout.parent.object).css(this.options.layout.parent.css).append($bar) : $bar;
  46. if(this.options.themeClassName)
  47. this.$bar.addClass(this.options.themeClassName).addClass('noty_container_type_' + this.options.type);
  48. // Set buttons if available
  49. if(this.options.buttons) {
  50. // If we have button disable closeWith & timeout options
  51. this.options.closeWith = [];
  52. this.options.timeout = false;
  53. var $buttons = $('<div/>').addClass('noty_buttons');
  54. (this.options.layout.parent.object !== null) ? this.$bar.find('.noty_bar').append($buttons) : this.$bar.append($buttons);
  55. var self = this;
  56. $.each(this.options.buttons, function(i, button) {
  57. var $button = $('<button/>').addClass((button.addClass) ? button.addClass : 'gray').html(button.text).attr('id', button.id ? button.id : 'button-' + i)
  58. .attr('title', button.title)
  59. .appendTo(self.$bar.find('.noty_buttons'))
  60. .on('click', function(event) {
  61. if($.isFunction(button.onClick)) {
  62. button.onClick.call($button, self, event);
  63. }
  64. });
  65. });
  66. }
  67. // For easy access
  68. this.$message = this.$bar.find('.noty_message');
  69. this.$closeButton = this.$bar.find('.noty_close');
  70. this.$buttons = this.$bar.find('.noty_buttons');
  71. $.noty.store[this.options.id] = this; // store noty for api
  72. }, // end _build
  73. show: function() {
  74. var self = this;
  75. (self.options.custom) ? self.options.custom.find(self.options.layout.container.selector).append(self.$bar) : $(self.options.layout.container.selector).append(self.$bar);
  76. if(self.options.theme && self.options.theme.style)
  77. self.options.theme.style.apply(self);
  78. ($.type(self.options.layout.css) === 'function') ? this.options.layout.css.apply(self.$bar) : self.$bar.css(this.options.layout.css || {});
  79. self.$bar.addClass(self.options.layout.addClass);
  80. self.options.layout.container.style.apply($(self.options.layout.container.selector), [self.options.within]);
  81. self.showing = true;
  82. if(self.options.theme && self.options.theme.style)
  83. self.options.theme.callback.onShow.apply(this);
  84. if($.inArray('click', self.options.closeWith) > -1)
  85. self.$bar.css('cursor', 'pointer').one('click', function(evt) {
  86. self.stopPropagation(evt);
  87. if(self.options.callback.onCloseClick) {
  88. self.options.callback.onCloseClick.apply(self);
  89. }
  90. self.close();
  91. });
  92. if($.inArray('hover', self.options.closeWith) > -1)
  93. self.$bar.one('mouseenter', function() {
  94. self.close();
  95. });
  96. if($.inArray('button', self.options.closeWith) > -1)
  97. self.$closeButton.one('click', function(evt) {
  98. self.stopPropagation(evt);
  99. self.close();
  100. });
  101. if($.inArray('button', self.options.closeWith) == -1)
  102. self.$closeButton.remove();
  103. if(self.options.callback.onShow)
  104. self.options.callback.onShow.apply(self);
  105. if (typeof self.options.animation.open == 'string') {
  106. self.$bar.css('height', self.$bar.innerHeight());
  107. self.$bar.on('click',function(e){
  108. self.wasClicked = true;
  109. });
  110. self.$bar.show().addClass(self.options.animation.open).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
  111. if(self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
  112. self.showing = false;
  113. self.shown = true;
  114. if(self.hasOwnProperty('wasClicked')){
  115. self.$bar.off('click',function(e){
  116. self.wasClicked = true;
  117. });
  118. self.close();
  119. }
  120. });
  121. } else {
  122. self.$bar.animate(
  123. self.options.animation.open,
  124. self.options.animation.speed,
  125. self.options.animation.easing,
  126. function() {
  127. if(self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
  128. self.showing = false;
  129. self.shown = true;
  130. });
  131. }
  132. // If noty is have a timeout option
  133. if(self.options.timeout)
  134. self.$bar.delay(self.options.timeout).promise().done(function() {
  135. self.close();
  136. });
  137. return this;
  138. }, // end show
  139. close: function() {
  140. if(this.closed) return;
  141. if(this.$bar && this.$bar.hasClass('i-am-closing-now')) return;
  142. var self = this;
  143. if(this.showing) {
  144. self.$bar.queue(
  145. function() {
  146. self.close.apply(self);
  147. }
  148. );
  149. return;
  150. }
  151. if(!this.shown && !this.showing) { // If we are still waiting in the queue just delete from queue
  152. var queue = [];
  153. $.each($.noty.queue, function(i, n) {
  154. if(n.options.id != self.options.id) {
  155. queue.push(n);
  156. }
  157. });
  158. $.noty.queue = queue;
  159. return;
  160. }
  161. self.$bar.addClass('i-am-closing-now');
  162. if(self.options.callback.onClose) {
  163. self.options.callback.onClose.apply(self);
  164. }
  165. if (typeof self.options.animation.close == 'string') {
  166. self.$bar.addClass(self.options.animation.close).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
  167. if(self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
  168. self.closeCleanUp();
  169. });
  170. } else {
  171. self.$bar.clearQueue().stop().animate(
  172. self.options.animation.close,
  173. self.options.animation.speed,
  174. self.options.animation.easing,
  175. function() {
  176. if(self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
  177. })
  178. .promise().done(function() {
  179. self.closeCleanUp();
  180. });
  181. }
  182. }, // end close
  183. closeCleanUp: function() {
  184. var self = this;
  185. // Modal Cleaning
  186. if(self.options.modal) {
  187. $.notyRenderer.setModalCount(-1);
  188. if($.notyRenderer.getModalCount() == 0) $('.noty_modal').fadeOut(self.options.animation.fadeSpeed, function() {
  189. $(this).remove();
  190. });
  191. }
  192. // Layout Cleaning
  193. $.notyRenderer.setLayoutCountFor(self, -1);
  194. if($.notyRenderer.getLayoutCountFor(self) == 0) $(self.options.layout.container.selector).remove();
  195. // Make sure self.$bar has not been removed before attempting to remove it
  196. if(typeof self.$bar !== 'undefined' && self.$bar !== null) {
  197. if (typeof self.options.animation.close == 'string') {
  198. self.$bar.css('transition', 'all 100ms ease').css('border', 0).css('margin', 0).height(0);
  199. self.$bar.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
  200. self.$bar.remove();
  201. self.$bar = null;
  202. self.closed = true;
  203. if(self.options.theme.callback && self.options.theme.callback.onClose) {
  204. self.options.theme.callback.onClose.apply(self);
  205. }
  206. });
  207. } else {
  208. self.$bar.remove();
  209. self.$bar = null;
  210. self.closed = true;
  211. }
  212. }
  213. delete $.noty.store[self.options.id]; // deleting noty from store
  214. if(self.options.theme.callback && self.options.theme.callback.onClose) {
  215. self.options.theme.callback.onClose.apply(self);
  216. }
  217. if(!self.options.dismissQueue) {
  218. // Queue render
  219. $.noty.ontap = true;
  220. $.notyRenderer.render();
  221. }
  222. if(self.options.maxVisible > 0 && self.options.dismissQueue) {
  223. $.notyRenderer.render();
  224. }
  225. }, // end close clean up
  226. setText: function(text) {
  227. if(!this.closed) {
  228. this.options.text = text;
  229. this.$bar.find('.noty_text').html(text);
  230. }
  231. return this;
  232. },
  233. setType: function(type) {
  234. if(!this.closed) {
  235. this.options.type = type;
  236. this.options.theme.style.apply(this);
  237. this.options.theme.callback.onShow.apply(this);
  238. }
  239. return this;
  240. },
  241. setTimeout: function(time) {
  242. if(!this.closed) {
  243. var self = this;
  244. this.options.timeout = time;
  245. self.$bar.delay(self.options.timeout).promise().done(function() {
  246. self.close();
  247. });
  248. }
  249. return this;
  250. },
  251. stopPropagation: function(evt) {
  252. evt = evt || window.event;
  253. if(typeof evt.stopPropagation !== "undefined") {
  254. evt.stopPropagation();
  255. }
  256. else {
  257. evt.cancelBubble = true;
  258. }
  259. },
  260. closed : false,
  261. showing: false,
  262. shown : false
  263. }; // end NotyObject
  264. $.notyRenderer = {};
  265. $.notyRenderer.init = function(options) {
  266. // Renderer creates a new noty
  267. var notification = Object.create(NotyObject).init(options);
  268. if(notification.options.killer)
  269. $.noty.closeAll();
  270. (notification.options.force) ? $.noty.queue.unshift(notification) : $.noty.queue.push(notification);
  271. $.notyRenderer.render();
  272. return ($.noty.returns == 'object') ? notification : notification.options.id;
  273. };
  274. $.notyRenderer.render = function() {
  275. var instance = $.noty.queue[0];
  276. if($.type(instance) === 'object') {
  277. if(instance.options.dismissQueue) {
  278. if(instance.options.maxVisible > 0) {
  279. if($(instance.options.layout.container.selector + ' > li').length < instance.options.maxVisible) {
  280. $.notyRenderer.show($.noty.queue.shift());
  281. }
  282. else {
  283. }
  284. }
  285. else {
  286. $.notyRenderer.show($.noty.queue.shift());
  287. }
  288. }
  289. else {
  290. if($.noty.ontap) {
  291. $.notyRenderer.show($.noty.queue.shift());
  292. $.noty.ontap = false;
  293. }
  294. }
  295. }
  296. else {
  297. $.noty.ontap = true; // Queue is over
  298. }
  299. };
  300. $.notyRenderer.show = function(notification) {
  301. if(notification.options.modal) {
  302. $.notyRenderer.createModalFor(notification);
  303. $.notyRenderer.setModalCount(+1);
  304. }
  305. // Where is the container?
  306. if(notification.options.custom) {
  307. if(notification.options.custom.find(notification.options.layout.container.selector).length == 0) {
  308. notification.options.custom.append($(notification.options.layout.container.object).addClass('i-am-new'));
  309. }
  310. else {
  311. notification.options.custom.find(notification.options.layout.container.selector).removeClass('i-am-new');
  312. }
  313. }
  314. else {
  315. if($(notification.options.layout.container.selector).length == 0) {
  316. $('body').append($(notification.options.layout.container.object).addClass('i-am-new'));
  317. }
  318. else {
  319. $(notification.options.layout.container.selector).removeClass('i-am-new');
  320. }
  321. }
  322. $.notyRenderer.setLayoutCountFor(notification, +1);
  323. notification.show();
  324. };
  325. $.notyRenderer.createModalFor = function(notification) {
  326. if($('.noty_modal').length == 0) {
  327. var modal = $('<div/>').addClass('noty_modal').addClass(notification.options.theme).data('noty_modal_count', 0);
  328. if(notification.options.theme.modal && notification.options.theme.modal.css)
  329. modal.css(notification.options.theme.modal.css);
  330. modal.prependTo($('body')).fadeIn(notification.options.animation.fadeSpeed);
  331. if($.inArray('backdrop', notification.options.closeWith) > -1)
  332. modal.on('click', function(e) {
  333. $.noty.closeAll();
  334. });
  335. }
  336. };
  337. $.notyRenderer.getLayoutCountFor = function(notification) {
  338. return $(notification.options.layout.container.selector).data('noty_layout_count') || 0;
  339. };
  340. $.notyRenderer.setLayoutCountFor = function(notification, arg) {
  341. return $(notification.options.layout.container.selector).data('noty_layout_count', $.notyRenderer.getLayoutCountFor(notification) + arg);
  342. };
  343. $.notyRenderer.getModalCount = function() {
  344. return $('.noty_modal').data('noty_modal_count') || 0;
  345. };
  346. $.notyRenderer.setModalCount = function(arg) {
  347. return $('.noty_modal').data('noty_modal_count', $.notyRenderer.getModalCount() + arg);
  348. };
  349. // This is for custom container
  350. $.fn.noty = function(options) {
  351. options.custom = $(this);
  352. return $.notyRenderer.init(options);
  353. };
  354. $.noty = {};
  355. $.noty.queue = [];
  356. $.noty.ontap = true;
  357. $.noty.layouts = {};
  358. $.noty.themes = {};
  359. $.noty.returns = 'object';
  360. $.noty.store = {};
  361. $.noty.get = function(id) {
  362. return $.noty.store.hasOwnProperty(id) ? $.noty.store[id] : false;
  363. };
  364. $.noty.close = function(id) {
  365. return $.noty.get(id) ? $.noty.get(id).close() : false;
  366. };
  367. $.noty.setText = function(id, text) {
  368. return $.noty.get(id) ? $.noty.get(id).setText(text) : false;
  369. };
  370. $.noty.setType = function(id, type) {
  371. return $.noty.get(id) ? $.noty.get(id).setType(type) : false;
  372. };
  373. $.noty.clearQueue = function() {
  374. $.noty.queue = [];
  375. };
  376. $.noty.closeAll = function() {
  377. $.noty.clearQueue();
  378. $.each($.noty.store, function(id, noty) {
  379. noty.close();
  380. });
  381. };
  382. var windowAlert = window.alert;
  383. $.noty.consumeAlert = function(options) {
  384. window.alert = function(text) {
  385. if(options)
  386. options.text = text;
  387. else
  388. options = {text: text};
  389. $.notyRenderer.init(options);
  390. };
  391. };
  392. $.noty.stopConsumeAlert = function() {
  393. window.alert = windowAlert;
  394. };
  395. $.noty.defaults = {
  396. layout : 'top',
  397. theme : 'defaultTheme',
  398. type : 'alert',
  399. text : '',
  400. dismissQueue: true,
  401. template : '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
  402. animation : {
  403. open : {height: 'toggle'},
  404. close : {height: 'toggle'},
  405. easing: 'swing',
  406. speed : 500,
  407. fadeSpeed: 'fast',
  408. },
  409. timeout : false,
  410. force : false,
  411. modal : false,
  412. maxVisible : 5,
  413. killer : false,
  414. closeWith : ['click'],
  415. callback : {
  416. onShow : function() {
  417. },
  418. afterShow : function() {
  419. },
  420. onClose : function() {
  421. },
  422. afterClose : function() {
  423. },
  424. onCloseClick: function() {
  425. }
  426. },
  427. buttons : false
  428. };
  429. $(window).on('resize', function() {
  430. $.each($.noty.layouts, function(index, layout) {
  431. layout.container.style.apply($(layout.container.selector));
  432. });
  433. });
  434. // Helpers
  435. window.noty = function noty(options) {
  436. return $.notyRenderer.init(options);
  437. };
  438. $.noty.layouts.bottom = {
  439. name : 'bottom',
  440. options : {},
  441. container: {
  442. object : '<ul id="noty_bottom_layout_container" />',
  443. selector: 'ul#noty_bottom_layout_container',
  444. style : function() {
  445. $(this).css({
  446. bottom : 0,
  447. left : '5%',
  448. position : 'fixed',
  449. width : '90%',
  450. height : 'auto',
  451. margin : 0,
  452. padding : 0,
  453. listStyleType: 'none',
  454. zIndex : 9999999
  455. });
  456. }
  457. },
  458. parent : {
  459. object : '<li />',
  460. selector: 'li',
  461. css : {}
  462. },
  463. css : {
  464. display: 'none'
  465. },
  466. addClass : ''
  467. };
  468. $.noty.layouts.bottomCenter = {
  469. name : 'bottomCenter',
  470. options : { // overrides options
  471. },
  472. container: {
  473. object : '<ul id="noty_bottomCenter_layout_container" />',
  474. selector: 'ul#noty_bottomCenter_layout_container',
  475. style : function() {
  476. $(this).css({
  477. bottom : 20,
  478. left : 0,
  479. position : 'fixed',
  480. width : '310px',
  481. height : 'auto',
  482. margin : 0,
  483. padding : 0,
  484. listStyleType: 'none',
  485. zIndex : 10000000
  486. });
  487. $(this).css({
  488. left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px'
  489. });
  490. }
  491. },
  492. parent : {
  493. object : '<li />',
  494. selector: 'li',
  495. css : {}
  496. },
  497. css : {
  498. display: 'none',
  499. width : '310px'
  500. },
  501. addClass : ''
  502. };
  503. $.noty.layouts.bottomLeft = {
  504. name : 'bottomLeft',
  505. options : { // overrides options
  506. },
  507. container: {
  508. object : '<ul id="noty_bottomLeft_layout_container" />',
  509. selector: 'ul#noty_bottomLeft_layout_container',
  510. style : function() {
  511. $(this).css({
  512. bottom : 20,
  513. left : 20,
  514. position : 'fixed',
  515. width : '310px',
  516. height : 'auto',
  517. margin : 0,
  518. padding : 0,
  519. listStyleType: 'none',
  520. zIndex : 10000000
  521. });
  522. if(window.innerWidth < 600) {
  523. $(this).css({
  524. left: 5
  525. });
  526. }
  527. }
  528. },
  529. parent : {
  530. object : '<li />',
  531. selector: 'li',
  532. css : {}
  533. },
  534. css : {
  535. display: 'none',
  536. width : '310px'
  537. },
  538. addClass : ''
  539. };
  540. $.noty.layouts.bottomRight = {
  541. name : 'bottomRight',
  542. options : { // overrides options
  543. },
  544. container: {
  545. object : '<ul id="noty_bottomRight_layout_container" />',
  546. selector: 'ul#noty_bottomRight_layout_container',
  547. style : function() {
  548. $(this).css({
  549. bottom : 20,
  550. right : 20,
  551. position : 'fixed',
  552. width : '310px',
  553. height : 'auto',
  554. margin : 0,
  555. padding : 0,
  556. listStyleType: 'none',
  557. zIndex : 10000000
  558. });
  559. if(window.innerWidth < 600) {
  560. $(this).css({
  561. right: 5
  562. });
  563. }
  564. }
  565. },
  566. parent : {
  567. object : '<li />',
  568. selector: 'li',
  569. css : {}
  570. },
  571. css : {
  572. display: 'none',
  573. width : '310px'
  574. },
  575. addClass : ''
  576. };
  577. $.noty.layouts.center = {
  578. name : 'center',
  579. options : { // overrides options
  580. },
  581. container: {
  582. object : '<ul id="noty_center_layout_container" />',
  583. selector: 'ul#noty_center_layout_container',
  584. style : function() {
  585. $(this).css({
  586. position : 'fixed',
  587. width : '310px',
  588. height : 'auto',
  589. margin : 0,
  590. padding : 0,
  591. listStyleType: 'none',
  592. zIndex : 10000000
  593. });
  594. // getting hidden height
  595. var dupe = $(this).clone().css({visibility: "hidden", display: "block", position: "absolute", top: 0, left: 0}).attr('id', 'dupe');
  596. $("body").append(dupe);
  597. dupe.find('.i-am-closing-now').remove();
  598. dupe.find('li').css('display', 'block');
  599. var actual_height = dupe.height();
  600. dupe.remove();
  601. if($(this).hasClass('i-am-new')) {
  602. $(this).css({
  603. left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px',
  604. top : ($(window).height() - actual_height) / 2 + 'px'
  605. });
  606. }
  607. else {
  608. $(this).animate({
  609. left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px',
  610. top : ($(window).height() - actual_height) / 2 + 'px'
  611. }, 500);
  612. }
  613. }
  614. },
  615. parent : {
  616. object : '<li />',
  617. selector: 'li',
  618. css : {}
  619. },
  620. css : {
  621. display: 'none',
  622. width : '310px'
  623. },
  624. addClass : ''
  625. };
  626. $.noty.layouts.centerLeft = {
  627. name : 'centerLeft',
  628. options : { // overrides options
  629. },
  630. container: {
  631. object : '<ul id="noty_centerLeft_layout_container" />',
  632. selector: 'ul#noty_centerLeft_layout_container',
  633. style : function() {
  634. $(this).css({
  635. left : 20,
  636. position : 'fixed',
  637. width : '310px',
  638. height : 'auto',
  639. margin : 0,
  640. padding : 0,
  641. listStyleType: 'none',
  642. zIndex : 10000000
  643. });
  644. // getting hidden height
  645. var dupe = $(this).clone().css({visibility: "hidden", display: "block", position: "absolute", top: 0, left: 0}).attr('id', 'dupe');
  646. $("body").append(dupe);
  647. dupe.find('.i-am-closing-now').remove();
  648. dupe.find('li').css('display', 'block');
  649. var actual_height = dupe.height();
  650. dupe.remove();
  651. if($(this).hasClass('i-am-new')) {
  652. $(this).css({
  653. top: ($(window).height() - actual_height) / 2 + 'px'
  654. });
  655. }
  656. else {
  657. $(this).animate({
  658. top: ($(window).height() - actual_height) / 2 + 'px'
  659. }, 500);
  660. }
  661. if(window.innerWidth < 600) {
  662. $(this).css({
  663. left: 5
  664. });
  665. }
  666. }
  667. },
  668. parent : {
  669. object : '<li />',
  670. selector: 'li',
  671. css : {}
  672. },
  673. css : {
  674. display: 'none',
  675. width : '310px'
  676. },
  677. addClass : ''
  678. };
  679. $.noty.layouts.centerRight = {
  680. name : 'centerRight',
  681. options : { // overrides options
  682. },
  683. container: {
  684. object : '<ul id="noty_centerRight_layout_container" />',
  685. selector: 'ul#noty_centerRight_layout_container',
  686. style : function() {
  687. $(this).css({
  688. right : 20,
  689. position : 'fixed',
  690. width : '310px',
  691. height : 'auto',
  692. margin : 0,
  693. padding : 0,
  694. listStyleType: 'none',
  695. zIndex : 10000000
  696. });
  697. // getting hidden height
  698. var dupe = $(this).clone().css({visibility: "hidden", display: "block", position: "absolute", top: 0, left: 0}).attr('id', 'dupe');
  699. $("body").append(dupe);
  700. dupe.find('.i-am-closing-now').remove();
  701. dupe.find('li').css('display', 'block');
  702. var actual_height = dupe.height();
  703. dupe.remove();
  704. if($(this).hasClass('i-am-new')) {
  705. $(this).css({
  706. top: ($(window).height() - actual_height) / 2 + 'px'
  707. });
  708. }
  709. else {
  710. $(this).animate({
  711. top: ($(window).height() - actual_height) / 2 + 'px'
  712. }, 500);
  713. }
  714. if(window.innerWidth < 600) {
  715. $(this).css({
  716. right: 5
  717. });
  718. }
  719. }
  720. },
  721. parent : {
  722. object : '<li />',
  723. selector: 'li',
  724. css : {}
  725. },
  726. css : {
  727. display: 'none',
  728. width : '310px'
  729. },
  730. addClass : ''
  731. };
  732. $.noty.layouts.inline = {
  733. name : 'inline',
  734. options : {},
  735. container: {
  736. object : '<ul class="noty_inline_layout_container" />',
  737. selector: 'ul.noty_inline_layout_container',
  738. style : function() {
  739. $(this).css({
  740. width : '100%',
  741. height : 'auto',
  742. margin : 0,
  743. padding : 0,
  744. listStyleType: 'none',
  745. zIndex : 9999999
  746. });
  747. }
  748. },
  749. parent : {
  750. object : '<li />',
  751. selector: 'li',
  752. css : {}
  753. },
  754. css : {
  755. display: 'none'
  756. },
  757. addClass : ''
  758. };
  759. $.noty.layouts.top = {
  760. name : 'top',
  761. options : {},
  762. container: {
  763. object : '<ul id="noty_top_layout_container" />',
  764. selector: 'ul#noty_top_layout_container',
  765. style : function() {
  766. $(this).css({
  767. top : 0,
  768. left : '5%',
  769. position : 'fixed',
  770. width : '90%',
  771. height : 'auto',
  772. margin : 0,
  773. padding : 0,
  774. listStyleType: 'none',
  775. zIndex : 9999999
  776. });
  777. }
  778. },
  779. parent : {
  780. object : '<li />',
  781. selector: 'li',
  782. css : {}
  783. },
  784. css : {
  785. display: 'none'
  786. },
  787. addClass : ''
  788. };
  789. $.noty.layouts.topCenter = {
  790. name : 'topCenter',
  791. options : { // overrides options
  792. },
  793. container: {
  794. object : '<ul id="noty_topCenter_layout_container" />',
  795. selector: 'ul#noty_topCenter_layout_container',
  796. style : function() {
  797. $(this).css({
  798. top : 20,
  799. left : 0,
  800. position : 'fixed',
  801. width : '310px',
  802. height : 'auto',
  803. margin : 0,
  804. padding : 0,
  805. listStyleType: 'none',
  806. zIndex : 10000000
  807. });
  808. $(this).css({
  809. left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px'
  810. });
  811. }
  812. },
  813. parent : {
  814. object : '<li />',
  815. selector: 'li',
  816. css : {}
  817. },
  818. css : {
  819. display: 'none',
  820. width : '310px'
  821. },
  822. addClass : ''
  823. };
  824. $.noty.layouts.topLeft = {
  825. name : 'topLeft',
  826. options : { // overrides options
  827. },
  828. container: {
  829. object : '<ul id="noty_topLeft_layout_container" />',
  830. selector: 'ul#noty_topLeft_layout_container',
  831. style : function() {
  832. $(this).css({
  833. top : 20,
  834. left : 20,
  835. position : 'fixed',
  836. width : '310px',
  837. height : 'auto',
  838. margin : 0,
  839. padding : 0,
  840. listStyleType: 'none',
  841. zIndex : 10000000
  842. });
  843. if(window.innerWidth < 600) {
  844. $(this).css({
  845. left: 5
  846. });
  847. }
  848. }
  849. },
  850. parent : {
  851. object : '<li />',
  852. selector: 'li',
  853. css : {}
  854. },
  855. css : {
  856. display: 'none',
  857. width : '310px'
  858. },
  859. addClass : ''
  860. };
  861. $.noty.layouts.topRight = {
  862. name : 'topRight',
  863. options : { // overrides options
  864. },
  865. container: {
  866. object : '<ul id="noty_topRight_layout_container" />',
  867. selector: 'ul#noty_topRight_layout_container',
  868. style : function() {
  869. $(this).css({
  870. top : 20,
  871. right : 20,
  872. position : 'fixed',
  873. width : '310px',
  874. height : 'auto',
  875. margin : 0,
  876. padding : 0,
  877. listStyleType: 'none',
  878. zIndex : 10000000
  879. });
  880. if(window.innerWidth < 600) {
  881. $(this).css({
  882. right: 5
  883. });
  884. }
  885. }
  886. },
  887. parent : {
  888. object : '<li />',
  889. selector: 'li',
  890. css : {}
  891. },
  892. css : {
  893. display: 'none',
  894. width : '310px'
  895. },
  896. addClass : ''
  897. };
  898. $.noty.themes.bootstrapTheme = {
  899. name: 'bootstrapTheme',
  900. modal: {
  901. css: {
  902. position: 'fixed',
  903. width: '100%',
  904. height: '100%',
  905. backgroundColor: '#000',
  906. zIndex: 10000,
  907. opacity: 0.6,
  908. display: 'none',
  909. left: 0,
  910. top: 0
  911. }
  912. },
  913. style: function() {
  914. var containerSelector = this.options.layout.container.selector;
  915. $(containerSelector).addClass('list-group');
  916. this.$closeButton.append('<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>');
  917. this.$closeButton.addClass('close');
  918. this.$bar.addClass( "list-group-item" ).css('padding', '0px');
  919. switch (this.options.type) {
  920. case 'alert': case 'notification':
  921. this.$bar.addClass( "list-group-item-info" );
  922. break;
  923. case 'warning':
  924. this.$bar.addClass( "list-group-item-warning" );
  925. break;
  926. case 'error':
  927. this.$bar.addClass( "list-group-item-danger" );
  928. break;
  929. case 'information':
  930. this.$bar.addClass("list-group-item-info");
  931. break;
  932. case 'success':
  933. this.$bar.addClass( "list-group-item-success" );
  934. break;
  935. }
  936. this.$message.css({
  937. fontSize: '13px',
  938. lineHeight: '16px',
  939. textAlign: 'center',
  940. padding: '8px 10px 9px',
  941. width: 'auto',
  942. position: 'relative'
  943. });
  944. },
  945. callback: {
  946. onShow: function() { },
  947. onClose: function() { }
  948. }
  949. };
  950. $.noty.themes.defaultTheme = {
  951. name : 'defaultTheme',
  952. helpers : {
  953. borderFix: function() {
  954. if(this.options.dismissQueue) {
  955. var selector = this.options.layout.container.selector + ' ' + this.options.layout.parent.selector;
  956. switch(this.options.layout.name) {
  957. case 'top':
  958. $(selector).css({borderRadius: '0px 0px 0px 0px'});
  959. $(selector).last().css({borderRadius: '0px 0px 5px 5px'});
  960. break;
  961. case 'topCenter':
  962. case 'topLeft':
  963. case 'topRight':
  964. case 'bottomCenter':
  965. case 'bottomLeft':
  966. case 'bottomRight':
  967. case 'center':
  968. case 'centerLeft':
  969. case 'centerRight':
  970. case 'inline':
  971. $(selector).css({borderRadius: '0px 0px 0px 0px'});
  972. $(selector).first().css({'border-top-left-radius': '5px', 'border-top-right-radius': '5px'});
  973. $(selector).last().css({'border-bottom-left-radius': '5px', 'border-bottom-right-radius': '5px'});
  974. break;
  975. case 'bottom':
  976. $(selector).css({borderRadius: '0px 0px 0px 0px'});
  977. $(selector).first().css({borderRadius: '5px 5px 0px 0px'});
  978. break;
  979. default:
  980. break;
  981. }
  982. }
  983. }
  984. },
  985. modal : {
  986. css: {
  987. position : 'fixed',
  988. width : '100%',
  989. height : '100%',
  990. backgroundColor: '#000',
  991. zIndex : 10000,
  992. opacity : 0.6,
  993. display : 'none',
  994. left : 0,
  995. top : 0
  996. }
  997. },
  998. style : function() {
  999. this.$bar.css({
  1000. overflow : 'hidden',
  1001. background: ""//"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAoCAQAAAClM0ndAAAAhklEQVR4AdXO0QrCMBBE0bttkk38/w8WRERpdyjzVOc+HxhIHqJGMQcFFkpYRQotLLSw0IJ5aBdovruMYDA/kT8plF9ZKLFQcgF18hDj1SbQOMlCA4kao0iiXmah7qBWPdxpohsgVZyj7e5I9KcID+EhiDI5gxBYKLBQYKHAQoGFAoEks/YEGHYKB7hFxf0AAAAASUVORK5CYII=') repeat-x scroll left top #fff"
  1002. });
  1003. this.$message.css({
  1004. fontSize : '13px',
  1005. lineHeight: '16px',
  1006. textAlign : 'center',
  1007. padding : '8px 10px 9px',
  1008. width : 'auto',
  1009. position : 'relative'
  1010. });
  1011. this.$closeButton.css({
  1012. position : 'absolute',
  1013. top : 4, right: 4,
  1014. width : 10, height: 10,
  1015. background: "",// "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAxUlEQVR4AR3MPUoDURSA0e++uSkkOxC3IAOWNtaCIDaChfgXBMEZbQRByxCwk+BasgQRZLSYoLgDQbARxry8nyumPcVRKDfd0Aa8AsgDv1zp6pYd5jWOwhvebRTbzNNEw5BSsIpsj/kurQBnmk7sIFcCF5yyZPDRG6trQhujXYosaFoc+2f1MJ89uc76IND6F9BvlXUdpb6xwD2+4q3me3bysiHvtLYrUJto7PD/ve7LNHxSg/woN2kSz4txasBdhyiz3ugPGetTjm3XRokAAAAASUVORK5CYII=)",
  1016. display : 'none',
  1017. cursor : 'pointer'
  1018. });
  1019. this.$buttons.css({
  1020. padding : 5,
  1021. textAlign : 'right',
  1022. borderTop : '1px solid #DBE0E4',
  1023. backgroundColor: '#fff'
  1024. });
  1025. this.$buttons.find('button').css({
  1026. marginLeft: 5
  1027. });
  1028. this.$buttons.find('button:first').css({
  1029. marginLeft: 0
  1030. });
  1031. this.$bar.on({
  1032. mouseenter: function() {
  1033. $(this).find('.noty_close').stop().fadeTo('normal', 1);
  1034. },
  1035. mouseleave: function() {
  1036. $(this).find('.noty_close').stop().fadeTo('normal', 0);
  1037. }
  1038. });
  1039. switch(this.options.layout.name) {
  1040. case 'top':
  1041. this.$bar.css({
  1042. borderRadius: '0px 0px 5px 5px',
  1043. borderBottom: '1px solid #DBE0E4',
  1044. borderLeft : '1px solid #DBE0E4',
  1045. borderRight : '1px solid #DBE0E4',
  1046. boxShadow : "0px 2px 8px rgba(0, 0, 0, 0.1)"
  1047. });
  1048. break;
  1049. case 'topCenter':
  1050. case 'center':
  1051. case 'bottomCenter':
  1052. case 'inline':
  1053. this.$bar.css({
  1054. borderRadius: '5px',
  1055. border : '1px solid #DBE0E4',
  1056. boxShadow : "0px 2px 8px rgba(0, 0, 0, 0.1)"
  1057. });
  1058. this.$message.css({fontSize: '13px', textAlign: 'center'});
  1059. break;
  1060. case 'topLeft':
  1061. case 'topRight':
  1062. case 'bottomLeft':
  1063. case 'bottomRight':
  1064. case 'centerLeft':
  1065. case 'centerRight':
  1066. this.$bar.css({
  1067. borderRadius: '5px',
  1068. border : '1px solid #DBE0E4',
  1069. boxShadow : "0px 2px 8px rgba(0, 0, 0, 0.1)"
  1070. });
  1071. this.$message.css({fontSize: '12px', textAlign: 'left'});
  1072. break;
  1073. case 'bottom':
  1074. this.$bar.css({
  1075. borderRadius: '5px 5px 0px 0px',
  1076. borderTop : '2px solid #DBE0E4',
  1077. borderLeft : '2px solid #DBE0E4',
  1078. borderRight : '2px solid #DBE0E4',
  1079. boxShadow : "0px 2px 8px rgba(0, 0, 0, 0.1)"
  1080. });
  1081. break;
  1082. default:
  1083. this.$bar.css({
  1084. border : '2px solid #DBE0E4',
  1085. boxShadow: "0px 2px 8px rgba(0, 0, 0, 0.1)"
  1086. });
  1087. break;
  1088. }
  1089. switch(this.options.type) {
  1090. case 'alert':
  1091. case 'notification':
  1092. this.$bar.css({backgroundColor: '#FFF', borderColor: '#DBE0E4', color: '#454545'});
  1093. break;
  1094. case 'warning':
  1095. this.$bar.css({backgroundColor: '#F69F00', borderColor: '#F69F00', color: '#FFF'});
  1096. this.$buttons.css({borderTop: '1px solid #F69F00'});
  1097. break;
  1098. case 'error':
  1099. this.$bar.css({backgroundColor: '#F04E51', borderColor: '#F04E51', color: '#FFF'});
  1100. this.$buttons.css({borderTop: '1px solid #F04E51'});
  1101. break;
  1102. case 'information':
  1103. this.$bar.css({backgroundColor: '#4FB5DD', borderColor: '#4FB5DD', color: '#FFF'});
  1104. this.$buttons.css({borderTop: '1px solid #4FB5DD'});
  1105. break;
  1106. case 'success':
  1107. this.$bar.css({backgroundColor: '#76AB3C', borderColor: '#76AB3C', color: '#FFF'});
  1108. this.$buttons.css({borderTop: '1px solid #76AB3C'});
  1109. break;
  1110. default:
  1111. this.$bar.css({backgroundColor: '#FFF', borderColor: '#DBE0E4', color: '#454545'});
  1112. break;
  1113. }
  1114. },
  1115. callback: {
  1116. onShow : function() {
  1117. $.noty.themes.defaultTheme.helpers.borderFix.apply(this);
  1118. },
  1119. onClose: function() {
  1120. $.noty.themes.defaultTheme.helpers.borderFix.apply(this);
  1121. }
  1122. }
  1123. };
  1124. return window.noty;
  1125. });