noty-2.4.1.js 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907
  1. if(Wind){
  2. Wind.css('animate');
  3. }
  4. !function(root, factory) {
  5. if (typeof define === 'function' && define.amd) {
  6. define(['jquery'], factory);
  7. } else if (typeof exports === 'object') {
  8. module.exports = factory(require('jquery'));
  9. } else {
  10. factory(root.jQuery);
  11. }
  12. }(this, function($) {
  13. /*!
  14. @package noty - jQuery Notification Plugin
  15. @version version: 2.4.1
  16. @contributors https://github.com/needim/noty/graphs/contributors
  17. @documentation Examples and Documentation - http://needim.github.com/noty/
  18. @license Licensed under the MIT licenses: http://www.opensource.org/licenses/mit-license.php
  19. */
  20. if (typeof Object.create !== 'function') {
  21. Object.create = function (o) {
  22. function F() {
  23. }
  24. F.prototype = o;
  25. return new F();
  26. };
  27. }
  28. var NotyObject = {
  29. init: function (options) {
  30. // Mix in the passed in options with the default options
  31. this.options = $.extend({}, $.noty.defaults, options);
  32. this.options.layout = (this.options.custom) ? $.noty.layouts['inline'] : $.noty.layouts[this.options.layout];
  33. if ($.noty.themes[this.options.theme]) {
  34. this.options.theme = $.noty.themes[this.options.theme];
  35. if (this.options.theme.template)
  36. this.options.template = this.options.theme.template;
  37. if (this.options.theme.animation)
  38. this.options.animation = this.options.theme.animation;
  39. }
  40. else {
  41. this.options.themeClassName = this.options.theme;
  42. }
  43. this.options = $.extend({}, this.options, this.options.layout.options);
  44. if (this.options.id) {
  45. if ($.noty.store[this.options.id]) {
  46. return $.noty.store[this.options.id];
  47. }
  48. } else {
  49. this.options.id = 'noty_' + (new Date().getTime() * Math.floor(Math.random() * 1000000));
  50. }
  51. // Build the noty dom initial structure
  52. this._build();
  53. // return this so we can chain/use the bridge with less code.
  54. return this;
  55. }, // end init
  56. _build: function () {
  57. // Generating noty bar
  58. var $bar = $('<div class="noty_bar noty_type_' + this.options.type + '"></div>').attr('id', this.options.id);
  59. $bar.append(this.options.template).find('.noty_text').html(this.options.text);
  60. this.$bar = (this.options.layout.parent.object !== null) ? $(this.options.layout.parent.object).css(this.options.layout.parent.css).append($bar) : $bar;
  61. if (this.options.themeClassName)
  62. this.$bar.addClass(this.options.themeClassName).addClass('noty_container_type_' + this.options.type);
  63. // Set buttons if available
  64. if (this.options.buttons) {
  65. var $buttons;
  66. // Try find container for buttons in presented template, and create it if not found
  67. if (this.$bar.find('.noty_buttons').length > 0) {
  68. $buttons = this.$bar.find('.noty_buttons');
  69. } else {
  70. $buttons = $('<div/>').addClass('noty_buttons');
  71. (this.options.layout.parent.object !== null) ? this.$bar.find('.noty_bar').append($buttons) : this.$bar.append($buttons);
  72. }
  73. var self = this;
  74. $.each(this.options.buttons, function (i, button) {
  75. var $button = $('<button/>').addClass((button.addClass) ? button.addClass : 'gray').html(button.text).attr('id', button.id ? button.id : 'button-' + i)
  76. .attr('title', button.title)
  77. .appendTo($buttons)
  78. .on('click', function (event) {
  79. if ($.isFunction(button.onClick)) {
  80. button.onClick.call($button, self, event);
  81. }
  82. });
  83. });
  84. } else {
  85. // If buttons is not available, then remove containers if exist
  86. this.$bar.find('.noty_buttons').remove();
  87. }
  88. if (this.options.progressBar && this.options.timeout) {
  89. var $progressBar = $('<div/>').addClass('noty_progress_bar');
  90. (this.options.layout.parent.object !== null) ? this.$bar.find('.noty_bar').append($progressBar) : this.$bar.append($progressBar);
  91. }
  92. // For easy access
  93. this.$message = this.$bar.find('.noty_message');
  94. this.$closeButton = this.$bar.find('.noty_close');
  95. this.$buttons = this.$bar.find('.noty_buttons');
  96. this.$progressBar = this.$bar.find('.noty_progress_bar');
  97. $.noty.store[this.options.id] = this; // store noty for api
  98. }, // end _build
  99. show: function () {
  100. var self = this;
  101. (self.options.custom) ? self.options.custom.find(self.options.layout.container.selector).append(self.$bar) : $(self.options.layout.container.selector).append(self.$bar);
  102. if (self.options.theme && self.options.theme.style)
  103. self.options.theme.style.apply(self);
  104. ($.type(self.options.layout.css) === 'function') ? this.options.layout.css.apply(self.$bar) : self.$bar.css(this.options.layout.css || {});
  105. self.$bar.addClass(self.options.layout.addClass);
  106. self.options.layout.container.style.apply($(self.options.layout.container.selector), [self.options.within]);
  107. self.showing = true;
  108. if (self.options.theme && self.options.theme.style)
  109. self.options.theme.callback.onShow.apply(this);
  110. if ($.inArray('click', self.options.closeWith) > -1)
  111. self.$bar.css('cursor', 'pointer').on('click', function (evt) {
  112. self.stopPropagation(evt);
  113. if (self.options.callback.onCloseClick) {
  114. self.options.callback.onCloseClick.apply(self);
  115. }
  116. self.close();
  117. });
  118. if ($.inArray('hover', self.options.closeWith) > -1)
  119. self.$bar.one('mouseenter', function () {
  120. self.close();
  121. });
  122. if ($.inArray('button', self.options.closeWith) > -1)
  123. self.$closeButton.one('click', function (evt) {
  124. self.stopPropagation(evt);
  125. self.close();
  126. });
  127. if ($.inArray('button', self.options.closeWith) == -1)
  128. self.$closeButton.remove();
  129. if (self.options.callback.beforeShow)
  130. self.options.callback.beforeShow.apply(self);
  131. if (typeof self.options.animation.open == 'string') {
  132. self.animationTypeOpen = 'css';
  133. self.$bar.css('min-height', self.$bar.innerHeight());
  134. self.$bar.on('click', function (e) {
  135. self.wasClicked = true;
  136. });
  137. self.$bar.show();
  138. if (self.options.callback.onShow)
  139. self.options.callback.onShow.apply(self);
  140. self.$bar.addClass(self.options.animation.open).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
  141. if (self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
  142. self.showing = false;
  143. self.shown = true;
  144. self.bindTimeout();
  145. if (self.hasOwnProperty('wasClicked')) {
  146. self.$bar.off('click', function (e) {
  147. self.wasClicked = true;
  148. });
  149. self.close();
  150. }
  151. });
  152. } else if (typeof self.options.animation.open == 'object' && self.options.animation.open == null) {
  153. self.animationTypeOpen = 'none';
  154. self.showing = false;
  155. self.shown = true;
  156. self.$bar.show();
  157. self.bindTimeout();
  158. if (self.options.callback.onShow)
  159. self.options.callback.onShow.apply(self);
  160. self.$bar.queue(function () {
  161. if (self.options.callback.afterShow)
  162. self.options.callback.afterShow.apply(self);
  163. });
  164. } else {
  165. self.animationTypeOpen = 'anim';
  166. if (self.options.callback.onShow)
  167. self.options.callback.onShow.apply(self);
  168. self.$bar.animate(
  169. self.options.animation.open,
  170. self.options.animation.speed,
  171. self.options.animation.easing,
  172. function () {
  173. if (self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
  174. self.showing = false;
  175. self.shown = true;
  176. self.bindTimeout();
  177. });
  178. }
  179. return this;
  180. }, // end show
  181. bindTimeout: function () {
  182. var self = this;
  183. // If noty is have a timeout option
  184. if (self.options.timeout) {
  185. if (self.options.progressBar && self.$progressBar) {
  186. self.$progressBar.css({
  187. transition: 'all ' + self.options.timeout + 'ms linear',
  188. width: '0%'
  189. });
  190. }
  191. self.queueClose(self.options.timeout);
  192. self.$bar.on('mouseenter', self.dequeueClose.bind(self));
  193. self.$bar.on('mouseleave', self.queueClose.bind(self, self.options.timeout));
  194. }
  195. },
  196. dequeueClose: function () {
  197. var self = this;
  198. if (self.options.progressBar) {
  199. this.$progressBar.css({
  200. transition: 'none',
  201. width: '100%'
  202. });
  203. }
  204. if (!this.closeTimer) return;
  205. clearTimeout(this.closeTimer);
  206. this.closeTimer = null;
  207. },
  208. queueClose: function (timeout) {
  209. var self = this;
  210. if (self.options.progressBar) {
  211. self.$progressBar.css({
  212. transition: 'all ' + self.options.timeout + 'ms linear',
  213. width: '0%'
  214. });
  215. }
  216. if (this.closeTimer) return;
  217. self.closeTimer = window.setTimeout(function () {
  218. self.close();
  219. }, timeout);
  220. return self.closeTimer;
  221. },
  222. close: function () {
  223. if (this.$progressBar) {
  224. this.$progressBar.remove();
  225. }
  226. if (this.closeTimer) this.dequeueClose();
  227. if (this.closed) return;
  228. if (this.$bar && this.$bar.hasClass('i-am-closing-now')) return;
  229. var self = this;
  230. if (this.showing && (this.animationTypeOpen == 'anim' || this.animationTypeOpen == 'none')) {
  231. self.$bar.queue(
  232. function () {
  233. self.close.apply(self);
  234. }
  235. );
  236. return;
  237. } else if (this.showing && this.animationTypeOpen == 'css') {
  238. self.$bar.on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
  239. self.close();
  240. });
  241. }
  242. if (!this.shown && !this.showing) { // If we are still waiting in the queue just delete from queue
  243. var queue = [];
  244. $.each($.noty.queue, function (i, n) {
  245. if (n.options.id != self.options.id) {
  246. queue.push(n);
  247. }
  248. });
  249. $.noty.queue = queue;
  250. return;
  251. }
  252. self.$bar.addClass('i-am-closing-now');
  253. if (self.options.callback.onClose) {
  254. self.options.callback.onClose.apply(self);
  255. }
  256. if (typeof self.options.animation.close == 'string') {
  257. self.$bar.removeClass(self.options.animation.open).addClass(self.options.animation.close).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
  258. if (self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
  259. self.closeCleanUp();
  260. });
  261. } else if (typeof self.options.animation.close == 'object' && self.options.animation.close == null) {
  262. self.$bar.dequeue().hide(0, function () {
  263. if (self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
  264. self.closeCleanUp();
  265. });
  266. } else {
  267. self.$bar.clearQueue().stop().animate(
  268. self.options.animation.close,
  269. self.options.animation.speed,
  270. self.options.animation.easing,
  271. function () {
  272. if (self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
  273. })
  274. .promise().done(function () {
  275. self.closeCleanUp();
  276. });
  277. }
  278. }, // end close
  279. closeCleanUp: function () {
  280. var self = this;
  281. // Modal Cleaning
  282. if (self.options.modal) {
  283. $.notyRenderer.setModalCount(-1);
  284. if ($.notyRenderer.getModalCount() == 0 && !$.noty.queue.length) $('.noty_modal').fadeOut(self.options.animation.fadeSpeed, function () {
  285. $(this).remove();
  286. });
  287. }
  288. // Layout Cleaning
  289. $.notyRenderer.setLayoutCountFor(self, -1);
  290. if ($.notyRenderer.getLayoutCountFor(self) == 0) $(self.options.layout.container.selector).remove();
  291. // Make sure self.$bar has not been removed before attempting to remove it
  292. if (typeof self.$bar !== 'undefined' && self.$bar !== null) {
  293. if (typeof self.options.animation.close == 'string') {
  294. self.$bar.css('transition', 'all 10ms ease').css('border', 0).css('margin', 0).height(0);
  295. self.$bar.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function () {
  296. self.$bar.remove();
  297. self.$bar = null;
  298. self.closed = true;
  299. if (self.options.theme.callback && self.options.theme.callback.onClose) {
  300. self.options.theme.callback.onClose.apply(self);
  301. }
  302. self.handleNext();
  303. });
  304. } else {
  305. self.$bar.remove();
  306. self.$bar = null;
  307. self.closed = true;
  308. self.handleNext();
  309. }
  310. } else {
  311. self.handleNext();
  312. }
  313. }, // end close clean up
  314. handleNext: function () {
  315. var self = this;
  316. delete $.noty.store[self.options.id]; // deleting noty from store
  317. if (self.options.theme.callback && self.options.theme.callback.onClose) {
  318. self.options.theme.callback.onClose.apply(self);
  319. }
  320. if (!self.options.dismissQueue) {
  321. // Queue render
  322. $.noty.ontap = true;
  323. $.notyRenderer.render();
  324. }
  325. if (self.options.maxVisible > 0 && self.options.dismissQueue) {
  326. $.notyRenderer.render();
  327. }
  328. },
  329. setText: function (text) {
  330. if (!this.closed) {
  331. this.options.text = text;
  332. this.$bar.find('.noty_text').html(text);
  333. }
  334. return this;
  335. },
  336. setType: function (type) {
  337. if (!this.closed) {
  338. this.options.type = type;
  339. this.options.theme.style.apply(this);
  340. this.options.theme.callback.onShow.apply(this);
  341. }
  342. return this;
  343. },
  344. setTimeout: function (time) {
  345. if (!this.closed) {
  346. var self = this;
  347. this.options.timeout = time;
  348. self.$bar.delay(self.options.timeout).promise().done(function () {
  349. self.close();
  350. });
  351. }
  352. return this;
  353. },
  354. stopPropagation: function (evt) {
  355. evt = evt || window.event;
  356. if (typeof evt.stopPropagation !== "undefined") {
  357. evt.stopPropagation();
  358. }
  359. else {
  360. evt.cancelBubble = true;
  361. }
  362. },
  363. closed : false,
  364. showing: false,
  365. shown : false
  366. }; // end NotyObject
  367. $.notyRenderer = {};
  368. $.notyRenderer.init = function (options) {
  369. // Renderer creates a new noty
  370. var notification = Object.create(NotyObject).init(options);
  371. if (notification.options.killer)
  372. $.noty.closeAll();
  373. (notification.options.force) ? $.noty.queue.unshift(notification) : $.noty.queue.push(notification);
  374. $.notyRenderer.render();
  375. return ($.noty.returns == 'object') ? notification : notification.options.id;
  376. };
  377. $.notyRenderer.render = function () {
  378. var instance = $.noty.queue[0];
  379. if ($.type(instance) === 'object') {
  380. if (instance.options.dismissQueue) {
  381. if (instance.options.maxVisible > 0) {
  382. if ($(instance.options.layout.container.selector + ' > li').length < instance.options.maxVisible) {
  383. $.notyRenderer.show($.noty.queue.shift());
  384. }
  385. else {
  386. }
  387. }
  388. else {
  389. $.notyRenderer.show($.noty.queue.shift());
  390. }
  391. }
  392. else {
  393. if ($.noty.ontap) {
  394. $.notyRenderer.show($.noty.queue.shift());
  395. $.noty.ontap = false;
  396. }
  397. }
  398. }
  399. else {
  400. $.noty.ontap = true; // Queue is over
  401. }
  402. };
  403. $.notyRenderer.show = function (notification) {
  404. if (notification.options.modal) {
  405. $.notyRenderer.createModalFor(notification);
  406. $.notyRenderer.setModalCount(+1);
  407. }
  408. // Where is the container?
  409. if (notification.options.custom) {
  410. if (notification.options.custom.find(notification.options.layout.container.selector).length == 0) {
  411. notification.options.custom.append($(notification.options.layout.container.object).addClass('i-am-new'));
  412. }
  413. else {
  414. notification.options.custom.find(notification.options.layout.container.selector).removeClass('i-am-new');
  415. }
  416. }
  417. else {
  418. if ($(notification.options.layout.container.selector).length == 0) {
  419. $('body').append($(notification.options.layout.container.object).addClass('i-am-new'));
  420. }
  421. else {
  422. $(notification.options.layout.container.selector).removeClass('i-am-new');
  423. }
  424. }
  425. $.notyRenderer.setLayoutCountFor(notification, +1);
  426. notification.show();
  427. };
  428. $.notyRenderer.createModalFor = function (notification) {
  429. if ($('.noty_modal').length == 0) {
  430. var modal = $('<div/>').addClass('noty_modal').addClass(notification.options.theme).data('noty_modal_count', 0);
  431. if (notification.options.theme.modal && notification.options.theme.modal.css)
  432. modal.css(notification.options.theme.modal.css);
  433. modal.prependTo($('body')).fadeIn(notification.options.animation.fadeSpeed);
  434. if ($.inArray('backdrop', notification.options.closeWith) > -1)
  435. modal.on('click', function () {
  436. $.noty.closeAll();
  437. });
  438. }
  439. };
  440. $.notyRenderer.getLayoutCountFor = function (notification) {
  441. return $(notification.options.layout.container.selector).data('noty_layout_count') || 0;
  442. };
  443. $.notyRenderer.setLayoutCountFor = function (notification, arg) {
  444. return $(notification.options.layout.container.selector).data('noty_layout_count', $.notyRenderer.getLayoutCountFor(notification) + arg);
  445. };
  446. $.notyRenderer.getModalCount = function () {
  447. return $('.noty_modal').data('noty_modal_count') || 0;
  448. };
  449. $.notyRenderer.setModalCount = function (arg) {
  450. return $('.noty_modal').data('noty_modal_count', $.notyRenderer.getModalCount() + arg);
  451. };
  452. // This is for custom container
  453. $.fn.noty = function (options) {
  454. options.custom = $(this);
  455. return $.notyRenderer.init(options);
  456. };
  457. $.noty = {};
  458. $.noty.queue = [];
  459. $.noty.ontap = true;
  460. $.noty.layouts = {};
  461. $.noty.themes = {};
  462. $.noty.returns = 'object';
  463. $.noty.store = {};
  464. $.noty.get = function (id) {
  465. return $.noty.store.hasOwnProperty(id) ? $.noty.store[id] : false;
  466. };
  467. $.noty.close = function (id) {
  468. return $.noty.get(id) ? $.noty.get(id).close() : false;
  469. };
  470. $.noty.setText = function (id, text) {
  471. return $.noty.get(id) ? $.noty.get(id).setText(text) : false;
  472. };
  473. $.noty.setType = function (id, type) {
  474. return $.noty.get(id) ? $.noty.get(id).setType(type) : false;
  475. };
  476. $.noty.clearQueue = function () {
  477. $.noty.queue = [];
  478. };
  479. $.noty.closeAll = function () {
  480. $.noty.clearQueue();
  481. $.each($.noty.store, function (id, noty) {
  482. noty.close();
  483. });
  484. };
  485. var windowAlert = window.alert;
  486. $.noty.consumeAlert = function (options) {
  487. window.alert = function (text) {
  488. if (options)
  489. options.text = text;
  490. else
  491. options = {text: text};
  492. $.notyRenderer.init(options);
  493. };
  494. };
  495. $.noty.stopConsumeAlert = function () {
  496. window.alert = windowAlert;
  497. };
  498. $.noty.defaults = {
  499. layout : 'topRight',
  500. theme : 'relax',
  501. type : 'alert',
  502. text : '',
  503. progressBar : false,
  504. dismissQueue: true,
  505. template : '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
  506. animation : {
  507. open : {height: 'toggle'},
  508. close : {height: 'toggle'},
  509. easing : 'swing',
  510. speed : 500,
  511. fadeSpeed: 'fast'
  512. },
  513. timeout : false,
  514. force : false,
  515. modal : false,
  516. maxVisible : 5,
  517. killer : false,
  518. closeWith : ['click'],
  519. callback : {
  520. beforeShow : function () {
  521. },
  522. onShow : function () {
  523. },
  524. afterShow : function () {
  525. },
  526. onClose : function () {
  527. },
  528. afterClose : function () {
  529. },
  530. onCloseClick: function () {
  531. }
  532. },
  533. buttons : false
  534. };
  535. $(window).on('resize', function () {
  536. $.each($.noty.layouts, function (index, layout) {
  537. layout.container.style.apply($(layout.container.selector));
  538. });
  539. });
  540. // Helpers
  541. window.noty = function noty(options) {
  542. return $.notyRenderer.init(options);
  543. };
  544. $.noty.layouts.bottom = {
  545. name : 'bottom',
  546. options : {},
  547. container: {
  548. object : '<ul id="noty_bottom_layout_container" />',
  549. selector: 'ul#noty_bottom_layout_container',
  550. style : function() {
  551. $(this).css({
  552. bottom : 0,
  553. left : '5%',
  554. position : 'fixed',
  555. width : '90%',
  556. height : 'auto',
  557. margin : 0,
  558. padding : 0,
  559. listStyleType: 'none',
  560. zIndex : 9999999
  561. });
  562. }
  563. },
  564. parent : {
  565. object : '<li />',
  566. selector: 'li',
  567. css : {}
  568. },
  569. css : {
  570. display: 'none'
  571. },
  572. addClass : ''
  573. };
  574. $.noty.layouts.bottomCenter = {
  575. name : 'bottomCenter',
  576. options : { // overrides options
  577. },
  578. container: {
  579. object : '<ul id="noty_bottomCenter_layout_container" />',
  580. selector: 'ul#noty_bottomCenter_layout_container',
  581. style : function() {
  582. $(this).css({
  583. bottom : 20,
  584. left : 0,
  585. position : 'fixed',
  586. width : '310px',
  587. height : 'auto',
  588. margin : 0,
  589. padding : 0,
  590. listStyleType: 'none',
  591. zIndex : 10000000
  592. });
  593. $(this).css({
  594. left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px'
  595. });
  596. }
  597. },
  598. parent : {
  599. object : '<li />',
  600. selector: 'li',
  601. css : {}
  602. },
  603. css : {
  604. display: 'none',
  605. width : '310px'
  606. },
  607. addClass : ''
  608. };
  609. $.noty.layouts.bottomLeft = {
  610. name : 'bottomLeft',
  611. options : { // overrides options
  612. },
  613. container: {
  614. object : '<ul id="noty_bottomLeft_layout_container" />',
  615. selector: 'ul#noty_bottomLeft_layout_container',
  616. style : function() {
  617. $(this).css({
  618. bottom : 20,
  619. left : 20,
  620. position : 'fixed',
  621. width : '310px',
  622. height : 'auto',
  623. margin : 0,
  624. padding : 0,
  625. listStyleType: 'none',
  626. zIndex : 10000000
  627. });
  628. if(window.innerWidth < 600) {
  629. $(this).css({
  630. left: 5
  631. });
  632. }
  633. }
  634. },
  635. parent : {
  636. object : '<li />',
  637. selector: 'li',
  638. css : {}
  639. },
  640. css : {
  641. display: 'none',
  642. width : '310px'
  643. },
  644. addClass : ''
  645. };
  646. $.noty.layouts.bottomRight = {
  647. name : 'bottomRight',
  648. options : { // overrides options
  649. },
  650. container: {
  651. object : '<ul id="noty_bottomRight_layout_container" />',
  652. selector: 'ul#noty_bottomRight_layout_container',
  653. style : function() {
  654. $(this).css({
  655. bottom : 20,
  656. right : 20,
  657. position : 'fixed',
  658. width : '310px',
  659. height : 'auto',
  660. margin : 0,
  661. padding : 0,
  662. listStyleType: 'none',
  663. zIndex : 10000000
  664. });
  665. if(window.innerWidth < 600) {
  666. $(this).css({
  667. right: 5
  668. });
  669. }
  670. }
  671. },
  672. parent : {
  673. object : '<li />',
  674. selector: 'li',
  675. css : {}
  676. },
  677. css : {
  678. display: 'none',
  679. width : '310px'
  680. },
  681. addClass : ''
  682. };
  683. $.noty.layouts.center = {
  684. name : 'center',
  685. options : { // overrides options
  686. },
  687. container: {
  688. object : '<ul id="noty_center_layout_container" />',
  689. selector: 'ul#noty_center_layout_container',
  690. style : function() {
  691. $(this).css({
  692. position : 'fixed',
  693. width : '310px',
  694. height : 'auto',
  695. margin : 0,
  696. padding : 0,
  697. listStyleType: 'none',
  698. zIndex : 10000000
  699. });
  700. // getting hidden height
  701. var dupe = $(this).clone().css({visibility: "hidden", display: "block", position: "absolute", top: 0, left: 0}).attr('id', 'dupe');
  702. $("body").append(dupe);
  703. dupe.find('.i-am-closing-now').remove();
  704. dupe.find('li').css('display', 'block');
  705. var actual_height = dupe.height();
  706. dupe.remove();
  707. if($(this).hasClass('i-am-new')) {
  708. $(this).css({
  709. left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px',
  710. top : ($(window).height() - actual_height) / 2 + 'px'
  711. });
  712. }
  713. else {
  714. $(this).animate({
  715. left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px',
  716. top : ($(window).height() - actual_height) / 2 + 'px'
  717. }, 500);
  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.centerLeft = {
  733. name : 'centerLeft',
  734. options : { // overrides options
  735. },
  736. container: {
  737. object : '<ul id="noty_centerLeft_layout_container" />',
  738. selector: 'ul#noty_centerLeft_layout_container',
  739. style : function() {
  740. $(this).css({
  741. left : 20,
  742. position : 'fixed',
  743. width : '310px',
  744. height : 'auto',
  745. margin : 0,
  746. padding : 0,
  747. listStyleType: 'none',
  748. zIndex : 10000000
  749. });
  750. // getting hidden height
  751. var dupe = $(this).clone().css({visibility: "hidden", display: "block", position: "absolute", top: 0, left: 0}).attr('id', 'dupe');
  752. $("body").append(dupe);
  753. dupe.find('.i-am-closing-now').remove();
  754. dupe.find('li').css('display', 'block');
  755. var actual_height = dupe.height();
  756. dupe.remove();
  757. if($(this).hasClass('i-am-new')) {
  758. $(this).css({
  759. top: ($(window).height() - actual_height) / 2 + 'px'
  760. });
  761. }
  762. else {
  763. $(this).animate({
  764. top: ($(window).height() - actual_height) / 2 + 'px'
  765. }, 500);
  766. }
  767. if(window.innerWidth < 600) {
  768. $(this).css({
  769. left: 5
  770. });
  771. }
  772. }
  773. },
  774. parent : {
  775. object : '<li />',
  776. selector: 'li',
  777. css : {}
  778. },
  779. css : {
  780. display: 'none',
  781. width : '310px'
  782. },
  783. addClass : ''
  784. };
  785. $.noty.layouts.centerRight = {
  786. name : 'centerRight',
  787. options : { // overrides options
  788. },
  789. container: {
  790. object : '<ul id="noty_centerRight_layout_container" />',
  791. selector: 'ul#noty_centerRight_layout_container',
  792. style : function() {
  793. $(this).css({
  794. right : 20,
  795. position : 'fixed',
  796. width : '310px',
  797. height : 'auto',
  798. margin : 0,
  799. padding : 0,
  800. listStyleType: 'none',
  801. zIndex : 10000000
  802. });
  803. // getting hidden height
  804. var dupe = $(this).clone().css({visibility: "hidden", display: "block", position: "absolute", top: 0, left: 0}).attr('id', 'dupe');
  805. $("body").append(dupe);
  806. dupe.find('.i-am-closing-now').remove();
  807. dupe.find('li').css('display', 'block');
  808. var actual_height = dupe.height();
  809. dupe.remove();
  810. if($(this).hasClass('i-am-new')) {
  811. $(this).css({
  812. top: ($(window).height() - actual_height) / 2 + 'px'
  813. });
  814. }
  815. else {
  816. $(this).animate({
  817. top: ($(window).height() - actual_height) / 2 + 'px'
  818. }, 500);
  819. }
  820. if(window.innerWidth < 600) {
  821. $(this).css({
  822. right: 5
  823. });
  824. }
  825. }
  826. },
  827. parent : {
  828. object : '<li />',
  829. selector: 'li',
  830. css : {}
  831. },
  832. css : {
  833. display: 'none',
  834. width : '310px'
  835. },
  836. addClass : ''
  837. };
  838. $.noty.layouts.inline = {
  839. name : 'inline',
  840. options : {},
  841. container: {
  842. object : '<ul class="noty_inline_layout_container" />',
  843. selector: 'ul.noty_inline_layout_container',
  844. style : function() {
  845. $(this).css({
  846. width : '100%',
  847. height : 'auto',
  848. margin : 0,
  849. padding : 0,
  850. listStyleType: 'none',
  851. zIndex : 9999999
  852. });
  853. }
  854. },
  855. parent : {
  856. object : '<li />',
  857. selector: 'li',
  858. css : {}
  859. },
  860. css : {
  861. display: 'none'
  862. },
  863. addClass : ''
  864. };
  865. $.noty.layouts.top = {
  866. name : 'top',
  867. options : {},
  868. container: {
  869. object : '<ul id="noty_top_layout_container" />',
  870. selector: 'ul#noty_top_layout_container',
  871. style : function() {
  872. $(this).css({
  873. top : 0,
  874. left : '5%',
  875. position : 'fixed',
  876. width : '90%',
  877. height : 'auto',
  878. margin : 0,
  879. padding : 0,
  880. listStyleType: 'none',
  881. zIndex : 9999999
  882. });
  883. }
  884. },
  885. parent : {
  886. object : '<li />',
  887. selector: 'li',
  888. css : {}
  889. },
  890. css : {
  891. display: 'none'
  892. },
  893. addClass : ''
  894. };
  895. $.noty.layouts.topCenter = {
  896. name : 'topCenter',
  897. options : { // overrides options
  898. },
  899. container: {
  900. object : '<ul id="noty_topCenter_layout_container" />',
  901. selector: 'ul#noty_topCenter_layout_container',
  902. style : function() {
  903. $(this).css({
  904. top : 20,
  905. left : 0,
  906. position : 'fixed',
  907. width : '310px',
  908. height : 'auto',
  909. margin : 0,
  910. padding : 0,
  911. listStyleType: 'none',
  912. zIndex : 10000000
  913. });
  914. $(this).css({
  915. left: ($(window).width() - $(this).outerWidth(false)) / 2 + 'px'
  916. });
  917. }
  918. },
  919. parent : {
  920. object : '<li />',
  921. selector: 'li',
  922. css : {}
  923. },
  924. css : {
  925. display: 'none',
  926. width : '310px'
  927. },
  928. addClass : ''
  929. };
  930. $.noty.layouts.topLeft = {
  931. name : 'topLeft',
  932. options : { // overrides options
  933. },
  934. container: {
  935. object : '<ul id="noty_topLeft_layout_container" />',
  936. selector: 'ul#noty_topLeft_layout_container',
  937. style : function() {
  938. $(this).css({
  939. top : 20,
  940. left : 20,
  941. position : 'fixed',
  942. width : '310px',
  943. height : 'auto',
  944. margin : 0,
  945. padding : 0,
  946. listStyleType: 'none',
  947. zIndex : 10000000
  948. });
  949. if(window.innerWidth < 600) {
  950. $(this).css({
  951. left: 5
  952. });
  953. }
  954. }
  955. },
  956. parent : {
  957. object : '<li />',
  958. selector: 'li',
  959. css : {}
  960. },
  961. css : {
  962. display: 'none',
  963. width : '310px'
  964. },
  965. addClass : ''
  966. };
  967. $.noty.layouts.topRight = {
  968. name : 'topRight',
  969. options : { // overrides options
  970. },
  971. container: {
  972. object : '<ul id="noty_topRight_layout_container" />',
  973. selector: 'ul#noty_topRight_layout_container',
  974. style : function() {
  975. $(this).css({
  976. top : 20,
  977. right : 20,
  978. position : 'fixed',
  979. width : '310px',
  980. height : 'auto',
  981. margin : 0,
  982. padding : 0,
  983. listStyleType: 'none',
  984. zIndex : 10000000
  985. });
  986. if(window.innerWidth < 600) {
  987. $(this).css({
  988. right: 5
  989. });
  990. }
  991. }
  992. },
  993. parent : {
  994. object : '<li />',
  995. selector: 'li',
  996. css : {}
  997. },
  998. css : {
  999. display: 'none',
  1000. width : '310px'
  1001. },
  1002. addClass : ''
  1003. };
  1004. $.noty.themes.bootstrapTheme = {
  1005. name : 'bootstrapTheme',
  1006. modal : {
  1007. css: {
  1008. position : 'fixed',
  1009. width : '100%',
  1010. height : '100%',
  1011. backgroundColor: '#000',
  1012. zIndex : 10000,
  1013. opacity : 0.6,
  1014. display : 'none',
  1015. left : 0,
  1016. top : 0,
  1017. wordBreak : 'break-all'
  1018. }
  1019. },
  1020. style : function () {
  1021. var containerSelector = this.options.layout.container.selector;
  1022. $(containerSelector).addClass('list-group');
  1023. this.$closeButton.append('<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>');
  1024. this.$closeButton.addClass('close');
  1025. this.$bar.addClass("list-group-item").css('padding', '0px').css('position', 'relative');
  1026. this.$progressBar.css({
  1027. position : 'absolute',
  1028. left : 0,
  1029. bottom : 0,
  1030. height : 4,
  1031. width : '100%',
  1032. backgroundColor: '#000000',
  1033. opacity : 0.2,
  1034. '-ms-filter' : 'progid:DXImageTransform.Microsoft.Alpha(Opacity=20)',
  1035. filter : 'alpha(opacity=20)'
  1036. });
  1037. switch (this.options.type) {
  1038. case 'alert':
  1039. case 'notification':
  1040. this.$bar.addClass("list-group-item-info");
  1041. break;
  1042. case 'warning':
  1043. this.$bar.addClass("list-group-item-warning");
  1044. break;
  1045. case 'error':
  1046. this.$bar.addClass("list-group-item-danger");
  1047. break;
  1048. case 'information':
  1049. this.$bar.addClass("list-group-item-info");
  1050. break;
  1051. case 'success':
  1052. this.$bar.addClass("list-group-item-success");
  1053. break;
  1054. }
  1055. this.$message.css({
  1056. textAlign: 'center',
  1057. padding : '8px 10px 9px',
  1058. width : 'auto',
  1059. position : 'relative'
  1060. });
  1061. },
  1062. callback: {
  1063. onShow : function () { },
  1064. onClose: function () { }
  1065. }
  1066. };
  1067. $.noty.themes.defaultTheme = {
  1068. name : 'defaultTheme',
  1069. helpers : {
  1070. borderFix: function () {
  1071. if (this.options.dismissQueue) {
  1072. var selector = this.options.layout.container.selector + ' ' + this.options.layout.parent.selector;
  1073. switch (this.options.layout.name) {
  1074. case 'top':
  1075. $(selector).css({borderRadius: '0px 0px 0px 0px'});
  1076. $(selector).last().css({borderRadius: '0px 0px 5px 5px'});
  1077. break;
  1078. case 'topCenter':
  1079. case 'topLeft':
  1080. case 'topRight':
  1081. case 'bottomCenter':
  1082. case 'bottomLeft':
  1083. case 'bottomRight':
  1084. case 'center':
  1085. case 'centerLeft':
  1086. case 'centerRight':
  1087. case 'inline':
  1088. $(selector).css({borderRadius: '0px 0px 0px 0px'});
  1089. $(selector).first().css({'border-top-left-radius': '5px', 'border-top-right-radius': '5px'});
  1090. $(selector).last().css({'border-bottom-left-radius': '5px', 'border-bottom-right-radius': '5px'});
  1091. break;
  1092. case 'bottom':
  1093. $(selector).css({borderRadius: '0px 0px 0px 0px'});
  1094. $(selector).first().css({borderRadius: '5px 5px 0px 0px'});
  1095. break;
  1096. default:
  1097. break;
  1098. }
  1099. }
  1100. }
  1101. },
  1102. modal : {
  1103. css: {
  1104. position : 'fixed',
  1105. width : '100%',
  1106. height : '100%',
  1107. backgroundColor: '#000',
  1108. zIndex : 10000,
  1109. opacity : 0.006,
  1110. display : 'none',
  1111. left : 0,
  1112. top : 0
  1113. }
  1114. },
  1115. style : function () {
  1116. this.$bar.css({
  1117. overflow : 'hidden',
  1118. background: "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAoCAQAAAClM0ndAAAAhklEQVR4AdXO0QrCMBBE0bttkk38/w8WRERpdyjzVOc+HxhIHqJGMQcFFkpYRQotLLSw0IJ5aBdovruMYDA/kT8plF9ZKLFQcgF18hDj1SbQOMlCA4kao0iiXmah7qBWPdxpohsgVZyj7e5I9KcID+EhiDI5gxBYKLBQYKHAQoGFAoEks/YEGHYKB7hFxf0AAAAASUVORK5CYII=') repeat-x scroll left top #fff",
  1119. position : 'relative'
  1120. });
  1121. this.$progressBar.css({
  1122. position : 'absolute',
  1123. left : 0,
  1124. bottom : 0,
  1125. height : 4,
  1126. width : '100%',
  1127. backgroundColor: '#000000',
  1128. opacity : 0.2,
  1129. '-ms-filter' : 'progid:DXImageTransform.Microsoft.Alpha(Opacity=20)',
  1130. filter : 'alpha(opacity=20)'
  1131. });
  1132. this.$message.css({
  1133. textAlign: 'center',
  1134. padding : '8px 10px 9px',
  1135. width : 'auto',
  1136. position : 'relative'
  1137. });
  1138. this.$closeButton.css({
  1139. position : 'absolute',
  1140. top : 4, right: 4,
  1141. width : 10, height: 10,
  1142. background: "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAxUlEQVR4AR3MPUoDURSA0e++uSkkOxC3IAOWNtaCIDaChfgXBMEZbQRByxCwk+BasgQRZLSYoLgDQbARxry8nyumPcVRKDfd0Aa8AsgDv1zp6pYd5jWOwhvebRTbzNNEw5BSsIpsj/kurQBnmk7sIFcCF5yyZPDRG6trQhujXYosaFoc+2f1MJ89uc76IND6F9BvlXUdpb6xwD2+4q3me3bysiHvtLYrUJto7PD/ve7LNHxSg/woN2kSz4txasBdhyiz3ugPGetTjm3XRokAAAAASUVORK5CYII=)",
  1143. display : 'none',
  1144. cursor : 'pointer'
  1145. });
  1146. this.$buttons.css({
  1147. padding : 5,
  1148. textAlign : 'right',
  1149. borderTop : '1px solid #ccc',
  1150. backgroundColor: '#fff'
  1151. });
  1152. this.$buttons.find('button').css({
  1153. marginLeft: 5
  1154. });
  1155. this.$buttons.find('button:first').css({
  1156. marginLeft: 0
  1157. });
  1158. this.$bar.on({
  1159. mouseenter: function () {
  1160. $(this).find('.noty_close').stop().fadeTo('normal', 1);
  1161. },
  1162. mouseleave: function () {
  1163. $(this).find('.noty_close').stop().fadeTo('normal', 0);
  1164. }
  1165. });
  1166. switch (this.options.layout.name) {
  1167. case 'top':
  1168. this.$bar.css({
  1169. borderRadius: '0px 0px 5px 5px',
  1170. borderBottom: '2px solid #eee',
  1171. borderLeft : '2px solid #eee',
  1172. borderRight : '2px solid #eee',
  1173. boxShadow : "0 2px 4px rgba(0, 0, 0, 0.1)"
  1174. });
  1175. break;
  1176. case 'topCenter':
  1177. case 'center':
  1178. case 'bottomCenter':
  1179. case 'inline':
  1180. this.$bar.css({
  1181. borderRadius: '5px',
  1182. border : '1px solid #eee',
  1183. boxShadow : "0 2px 4px rgba(0, 0, 0, 0.1)"
  1184. });
  1185. this.$message.css({textAlign: 'center'});
  1186. break;
  1187. case 'topLeft':
  1188. case 'topRight':
  1189. case 'bottomLeft':
  1190. case 'bottomRight':
  1191. case 'centerLeft':
  1192. case 'centerRight':
  1193. this.$bar.css({
  1194. borderRadius: '5px',
  1195. border : '1px solid #eee',
  1196. boxShadow : "0 2px 4px rgba(0, 0, 0, 0.1)"
  1197. });
  1198. this.$message.css({textAlign: 'left'});
  1199. break;
  1200. case 'bottom':
  1201. this.$bar.css({
  1202. borderRadius: '5px 5px 0px 0px',
  1203. borderTop : '2px solid #eee',
  1204. borderLeft : '2px solid #eee',
  1205. borderRight : '2px solid #eee',
  1206. boxShadow : "0 -2px 4px rgba(0, 0, 0, 0.1)"
  1207. });
  1208. break;
  1209. default:
  1210. this.$bar.css({
  1211. border : '2px solid #eee',
  1212. boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)"
  1213. });
  1214. break;
  1215. }
  1216. switch (this.options.type) {
  1217. case 'alert':
  1218. case 'notification':
  1219. this.$bar.css({backgroundColor: '#FFF', borderColor: '#CCC', color: '#444'});
  1220. break;
  1221. case 'warning':
  1222. this.$bar.css({backgroundColor: '#FFEAA8', borderColor: '#FFC237', color: '#826200'});
  1223. this.$buttons.css({borderTop: '1px solid #FFC237'});
  1224. break;
  1225. case 'error':
  1226. this.$bar.css({backgroundColor: 'red', borderColor: 'darkred', color: '#FFF'});
  1227. this.$message.css({fontWeight: 'bold'});
  1228. this.$buttons.css({borderTop: '1px solid darkred'});
  1229. break;
  1230. case 'information':
  1231. this.$bar.css({backgroundColor: '#57B7E2', borderColor: '#0B90C4', color: '#FFF'});
  1232. this.$buttons.css({borderTop: '1px solid #0B90C4'});
  1233. break;
  1234. case 'success':
  1235. this.$bar.css({backgroundColor: 'lightgreen', borderColor: '#50C24E', color: 'darkgreen'});
  1236. this.$buttons.css({borderTop: '1px solid #50C24E'});
  1237. break;
  1238. default:
  1239. this.$bar.css({backgroundColor: '#FFF', borderColor: '#CCC', color: '#444'});
  1240. break;
  1241. }
  1242. },
  1243. callback: {
  1244. onShow : function () {
  1245. $.noty.themes.defaultTheme.helpers.borderFix.apply(this);
  1246. },
  1247. onClose: function () {
  1248. $.noty.themes.defaultTheme.helpers.borderFix.apply(this);
  1249. }
  1250. }
  1251. };
  1252. $.noty.themes.metroui = {
  1253. name : 'metroui',
  1254. helpers : {},
  1255. modal : {
  1256. css: {
  1257. position : 'fixed',
  1258. width : '100%',
  1259. height : '100%',
  1260. backgroundColor: '#000',
  1261. zIndex : 10000,
  1262. opacity : 0.6,
  1263. display : 'none',
  1264. left : 0,
  1265. top : 0
  1266. }
  1267. },
  1268. style : function () {
  1269. this.$bar.css({
  1270. overflow : 'hidden',
  1271. margin : '4px 0',
  1272. borderRadius: '0',
  1273. position : 'relative'
  1274. });
  1275. this.$progressBar.css({
  1276. position : 'absolute',
  1277. left : 0,
  1278. bottom : 0,
  1279. height : 4,
  1280. width : '100%',
  1281. backgroundColor: '#000000',
  1282. opacity : 0.2,
  1283. '-ms-filter' : 'progid:DXImageTransform.Microsoft.Alpha(Opacity=20)',
  1284. filter : 'alpha(opacity=20)'
  1285. });
  1286. this.$message.css({
  1287. textAlign: 'center',
  1288. padding : '1.25rem',
  1289. width : 'auto',
  1290. position : 'relative'
  1291. });
  1292. this.$closeButton.css({
  1293. position : 'absolute',
  1294. top : '.25rem', right: '.25rem',
  1295. width : 10, height: 10,
  1296. background: "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAxUlEQVR4AR3MPUoDURSA0e++uSkkOxC3IAOWNtaCIDaChfgXBMEZbQRByxCwk+BasgQRZLSYoLgDQbARxry8nyumPcVRKDfd0Aa8AsgDv1zp6pYd5jWOwhvebRTbzNNEw5BSsIpsj/kurQBnmk7sIFcCF5yyZPDRG6trQhujXYosaFoc+2f1MJ89uc76IND6F9BvlXUdpb6xwD2+4q3me3bysiHvtLYrUJto7PD/ve7LNHxSg/woN2kSz4txasBdhyiz3ugPGetTjm3XRokAAAAASUVORK5CYII=)",
  1297. display : 'none',
  1298. cursor : 'pointer'
  1299. });
  1300. this.$buttons.css({
  1301. padding : 5,
  1302. textAlign : 'right',
  1303. borderTop : '1px solid #ccc',
  1304. backgroundColor: '#fff'
  1305. });
  1306. this.$buttons.find('button').css({
  1307. marginLeft: 5
  1308. });
  1309. this.$buttons.find('button:first').css({
  1310. marginLeft: 0
  1311. });
  1312. this.$bar.on({
  1313. mouseenter: function () {
  1314. $(this).find('.noty_close').stop().fadeTo('normal', 1);
  1315. },
  1316. mouseleave: function () {
  1317. $(this).find('.noty_close').stop().fadeTo('normal', 0);
  1318. }
  1319. });
  1320. switch (this.options.layout.name) {
  1321. case 'top':
  1322. this.$bar.css({
  1323. border : 'none',
  1324. boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.3)"
  1325. });
  1326. break;
  1327. case 'topCenter':
  1328. case 'center':
  1329. case 'bottomCenter':
  1330. case 'inline':
  1331. this.$bar.css({
  1332. border : 'none',
  1333. boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.3)"
  1334. });
  1335. this.$message.css({textAlign: 'center'});
  1336. break;
  1337. case 'topLeft':
  1338. case 'topRight':
  1339. case 'bottomLeft':
  1340. case 'bottomRight':
  1341. case 'centerLeft':
  1342. case 'centerRight':
  1343. this.$bar.css({
  1344. border : 'none',
  1345. boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.3)"
  1346. });
  1347. this.$message.css({textAlign: 'left'});
  1348. break;
  1349. case 'bottom':
  1350. this.$bar.css({
  1351. border : 'none',
  1352. boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.3)"
  1353. });
  1354. break;
  1355. default:
  1356. this.$bar.css({
  1357. border : 'none',
  1358. boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.3)"
  1359. });
  1360. break;
  1361. }
  1362. switch (this.options.type) {
  1363. case 'alert':
  1364. case 'notification':
  1365. this.$bar.css({backgroundColor: '#fff', border: 'none', color: '#1d1d1d'});
  1366. break;
  1367. case 'warning':
  1368. this.$bar.css({backgroundColor: '#FA6800', border: 'none', color: '#fff'});
  1369. this.$buttons.css({borderTop: '1px solid #FA6800'});
  1370. break;
  1371. case 'error':
  1372. this.$bar.css({backgroundColor: '#CE352C', border: 'none', color: '#fff'});
  1373. this.$message.css({fontWeight: 'bold'});
  1374. this.$buttons.css({borderTop: '1px solid #CE352C'});
  1375. break;
  1376. case 'information':
  1377. this.$bar.css({backgroundColor: '#1BA1E2', border: 'none', color: '#fff'});
  1378. this.$buttons.css({borderTop: '1px solid #1BA1E2'});
  1379. break;
  1380. case 'success':
  1381. this.$bar.css({backgroundColor: '#60A917', border: 'none', color: '#fff'});
  1382. this.$buttons.css({borderTop: '1px solid #50C24E'});
  1383. break;
  1384. default:
  1385. this.$bar.css({backgroundColor: '#fff', border: 'none', color: '#1d1d1d'});
  1386. break;
  1387. }
  1388. },
  1389. callback: {
  1390. onShow : function () {
  1391. },
  1392. onClose: function () {
  1393. }
  1394. }
  1395. };
  1396. $.noty.themes.relax = {
  1397. name : 'relax',
  1398. helpers : {},
  1399. modal : {
  1400. css: {
  1401. position : 'fixed',
  1402. width : '100%',
  1403. height : '100%',
  1404. backgroundColor: '#000',
  1405. zIndex : 10000,
  1406. opacity : 0.6,
  1407. display : 'none',
  1408. left : 0,
  1409. top : 0
  1410. }
  1411. },
  1412. style : function () {
  1413. this.$bar.css({
  1414. overflow : 'hidden',
  1415. margin : '4px 0',
  1416. borderRadius: '2px',
  1417. position : 'relative'
  1418. });
  1419. this.$progressBar.css({
  1420. position : 'absolute',
  1421. left : 0,
  1422. bottom : 0,
  1423. height : 4,
  1424. width : '100%',
  1425. backgroundColor: '#000000',
  1426. opacity : 0.2,
  1427. '-ms-filter' : 'progid:DXImageTransform.Microsoft.Alpha(Opacity=20)',
  1428. filter : 'alpha(opacity=20)'
  1429. });
  1430. this.$message.css({
  1431. textAlign: 'center',
  1432. padding : '10px',
  1433. width : 'auto',
  1434. position : 'relative'
  1435. });
  1436. this.$closeButton.css({
  1437. position : 'absolute',
  1438. top : 4, right: 4,
  1439. width : 10, height: 10,
  1440. background: "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAxUlEQVR4AR3MPUoDURSA0e++uSkkOxC3IAOWNtaCIDaChfgXBMEZbQRByxCwk+BasgQRZLSYoLgDQbARxry8nyumPcVRKDfd0Aa8AsgDv1zp6pYd5jWOwhvebRTbzNNEw5BSsIpsj/kurQBnmk7sIFcCF5yyZPDRG6trQhujXYosaFoc+2f1MJ89uc76IND6F9BvlXUdpb6xwD2+4q3me3bysiHvtLYrUJto7PD/ve7LNHxSg/woN2kSz4txasBdhyiz3ugPGetTjm3XRokAAAAASUVORK5CYII=)",
  1441. display : 'none',
  1442. cursor : 'pointer'
  1443. });
  1444. this.$buttons.css({
  1445. padding : 5,
  1446. textAlign : 'right',
  1447. borderTop : '1px solid #ccc',
  1448. backgroundColor: '#fff'
  1449. });
  1450. this.$buttons.find('button').css({
  1451. marginLeft: 5
  1452. });
  1453. this.$buttons.find('button:first').css({
  1454. marginLeft: 0
  1455. });
  1456. this.$bar.on({
  1457. mouseenter: function () {
  1458. $(this).find('.noty_close').stop().fadeTo('normal', 1);
  1459. },
  1460. mouseleave: function () {
  1461. $(this).find('.noty_close').stop().fadeTo('normal', 0);
  1462. }
  1463. });
  1464. switch (this.options.layout.name) {
  1465. case 'top':
  1466. this.$bar.css({
  1467. borderBottom: '2px solid #eee',
  1468. borderLeft : '2px solid #eee',
  1469. borderRight : '2px solid #eee',
  1470. borderTop : '2px solid #eee',
  1471. boxShadow : "0 2px 4px rgba(0, 0, 0, 0.1)"
  1472. });
  1473. break;
  1474. case 'topCenter':
  1475. case 'center':
  1476. case 'bottomCenter':
  1477. case 'inline':
  1478. this.$bar.css({
  1479. border : '1px solid #eee',
  1480. boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)"
  1481. });
  1482. this.$message.css({textAlign: 'center'});
  1483. break;
  1484. case 'topLeft':
  1485. case 'topRight':
  1486. case 'bottomLeft':
  1487. case 'bottomRight':
  1488. case 'centerLeft':
  1489. case 'centerRight':
  1490. this.$bar.css({
  1491. border : '1px solid #eee',
  1492. boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)"
  1493. });
  1494. this.$message.css({textAlign: 'left'});
  1495. break;
  1496. case 'bottom':
  1497. this.$bar.css({
  1498. borderTop : '2px solid #eee',
  1499. borderLeft : '2px solid #eee',
  1500. borderRight : '2px solid #eee',
  1501. borderBottom: '2px solid #eee',
  1502. boxShadow : "0 -2px 4px rgba(0, 0, 0, 0.1)"
  1503. });
  1504. break;
  1505. default:
  1506. this.$bar.css({
  1507. border : '2px solid #eee',
  1508. boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)"
  1509. });
  1510. break;
  1511. }
  1512. switch (this.options.type) {
  1513. case 'alert':
  1514. case 'notification':
  1515. this.$bar.css({backgroundColor: '#FFF', borderColor: '#dedede', color: '#444'});
  1516. break;
  1517. case 'warning':
  1518. this.$bar.css({backgroundColor: '#FFEAA8', borderColor: '#FFC237', color: '#826200'});
  1519. this.$buttons.css({borderTop: '1px solid #FFC237'});
  1520. break;
  1521. case 'error':
  1522. this.$bar.css({backgroundColor: '#FF8181', borderColor: '#e25353', color: '#FFF'});
  1523. this.$message.css({fontWeight: 'bold'});
  1524. this.$buttons.css({borderTop: '1px solid darkred'});
  1525. break;
  1526. case 'information':
  1527. this.$bar.css({backgroundColor: '#78C5E7', borderColor: '#3badd6', color: '#FFF'});
  1528. this.$buttons.css({borderTop: '1px solid #0B90C4'});
  1529. break;
  1530. case 'success':
  1531. this.$bar.css({backgroundColor: '#BCF5BC', borderColor: '#7cdd77', color: 'darkgreen'});
  1532. this.$buttons.css({borderTop: '1px solid #50C24E'});
  1533. break;
  1534. default:
  1535. this.$bar.css({backgroundColor: '#FFF', borderColor: '#CCC', color: '#444'});
  1536. break;
  1537. }
  1538. },
  1539. callback: {
  1540. onShow : function () {
  1541. },
  1542. onClose: function () {
  1543. }
  1544. }
  1545. };
  1546. $.noty.themes.semanticUI = {
  1547. name: 'semanticUI',
  1548. template: '<div class="ui message"><div class="content"><div class="header"></div></div></div>',
  1549. animation: {
  1550. open : {
  1551. animation: 'fade',
  1552. duration : '800ms'
  1553. },
  1554. close: {
  1555. animation: 'fade left',
  1556. duration : '800ms'
  1557. }
  1558. },
  1559. modal : {
  1560. css: {
  1561. position : 'fixed',
  1562. width : '100%',
  1563. height : '100%',
  1564. backgroundColor: '#000',
  1565. zIndex : 10000,
  1566. opacity : 0.6,
  1567. display : 'none',
  1568. left : 0,
  1569. top : 0
  1570. }
  1571. },
  1572. style : function () {
  1573. this.$message = this.$bar.find('.ui.message');
  1574. this.$message.find('.header').html(this.options.header);
  1575. this.$message.find('.content').append(this.options.text);
  1576. this.$bar.css({
  1577. margin : '0.5em',
  1578. position: 'relative'
  1579. });
  1580. if (this.options.icon) {
  1581. this.$message.addClass('icon').prepend($('<i/>').addClass(this.options.icon));
  1582. }
  1583. this.$progressBar.css({
  1584. position : 'absolute',
  1585. left : 0,
  1586. bottom : 0,
  1587. height : 4,
  1588. width : '100%',
  1589. backgroundColor: '#000000',
  1590. opacity : 0.2,
  1591. '-ms-filter' : 'progid:DXImageTransform.Microsoft.Alpha(Opacity=20)',
  1592. filter : 'alpha(opacity=20)'
  1593. });
  1594. switch (this.options.size) {
  1595. case 'mini':
  1596. this.$message.addClass('mini');
  1597. break;
  1598. case 'tiny':
  1599. this.$message.addClass('tiny');
  1600. break;
  1601. case 'small':
  1602. this.$message.addClass('small');
  1603. break;
  1604. case 'large':
  1605. this.$message.addClass('large');
  1606. break;
  1607. case 'big':
  1608. this.$message.addClass('big');
  1609. break;
  1610. case 'huge':
  1611. this.$message.addClass('huge');
  1612. break;
  1613. case 'massive':
  1614. this.$message.addClass('massive');
  1615. break;
  1616. }
  1617. switch (this.options.type) {
  1618. case 'info':
  1619. this.$message.addClass('info');
  1620. break;
  1621. case 'warning':
  1622. this.$message.addClass('warning');
  1623. break;
  1624. case 'error':
  1625. this.$message.addClass('error');
  1626. break;
  1627. case 'negative':
  1628. this.$message.addClass('negative');
  1629. break;
  1630. case 'success':
  1631. this.$message.addClass('success');
  1632. break;
  1633. case 'positive':
  1634. this.$message.addClass('positive');
  1635. break;
  1636. case 'floating':
  1637. this.$message.addClass('floating');
  1638. break;
  1639. }
  1640. },
  1641. callback: {
  1642. onShow : function () {
  1643. // Enable transition
  1644. this.$bar.addClass('transition');
  1645. // Actual transition
  1646. this.$bar.transition(this.options.animation.open);
  1647. },
  1648. onClose: function () {
  1649. this.$bar.transition(this.options.animation.close);
  1650. }
  1651. }
  1652. };
  1653. return window.noty;
  1654. });
  1655. $.noty.defaults = {
  1656. layout: 'top',
  1657. theme: 'defaultTheme',
  1658. type: 'alert',
  1659. text: '', // can be html or string
  1660. dismissQueue: true, // If you want to use queue feature set this true
  1661. template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
  1662. animation: {
  1663. open: {height: 'toggle'},
  1664. close: {height: 'toggle'},
  1665. easing: 'swing',
  1666. speed: 500 // opening & closing animation speed
  1667. },
  1668. timeout: 1000, // delay for closing event. Set false for sticky notifications
  1669. force: false, // adds notification to the beginning of queue when set to true
  1670. modal: false,
  1671. maxVisible: 5, // you can set max visible notification for dismissQueue true option,
  1672. killer: false, // for close all notifications before show
  1673. closeWith: ['click'], // ['click', 'button', 'hover', 'backdrop'] // backdrop click will close all open notifications
  1674. callback: {
  1675. onShow: function() {},
  1676. afterShow: function() {},
  1677. onClose: function() {},
  1678. afterClose: function() {}
  1679. },
  1680. buttons: false // an array of buttons
  1681. };