devmate 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +8 -8
  2. data/{LICENSE.txt → MIT-LICENSE} +1 -3
  3. data/README.rdoc +7 -0
  4. data/Rakefile +39 -1
  5. data/app/assets/javascripts/devmate/application.js +35 -0
  6. data/app/assets/javascripts/devmate/noty-2.2.4/LICENSE.txt +20 -0
  7. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/jquery.noty.js +488 -0
  8. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/bottom.js +34 -0
  9. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/bottomCenter.js +41 -0
  10. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/bottomLeft.js +43 -0
  11. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/bottomRight.js +43 -0
  12. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/center.js +56 -0
  13. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/centerLeft.js +61 -0
  14. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/centerRight.js +61 -0
  15. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/inline.js +31 -0
  16. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/top.js +34 -0
  17. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/topCenter.js +41 -0
  18. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/topLeft.js +43 -0
  19. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/layouts/topRight.js +43 -0
  20. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/packaged/jquery.noty.packaged.js +1180 -0
  21. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/packaged/jquery.noty.packaged.min.js +1 -0
  22. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/promise.js +432 -0
  23. data/app/assets/javascripts/devmate/noty-2.2.4/js/noty/themes/default.js +157 -0
  24. data/app/assets/stylesheets/devmate/application.css +13 -0
  25. data/app/controllers/devmate/application_controller.rb +26 -0
  26. data/app/helpers/devmate/application_helper.rb +4 -0
  27. data/app/views/layouts/devmate/application.html.erb +14 -0
  28. data/config/data/quotes.json +36 -0
  29. data/config/routes.rb +3 -0
  30. data/lib/devmate.rb +14 -4
  31. data/lib/devmate/engine.rb +5 -0
  32. data/lib/devmate/version.rb +1 -1
  33. data/lib/generators/devmate_generator.rb +27 -0
  34. data/test/devmate_test.rb +7 -0
  35. data/test/dummy/README.rdoc +261 -0
  36. data/test/dummy/Rakefile +7 -0
  37. data/test/dummy/app/assets/javascripts/application.js +15 -0
  38. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  39. data/test/dummy/app/controllers/application_controller.rb +3 -0
  40. data/test/dummy/app/helpers/application_helper.rb +2 -0
  41. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  42. data/test/dummy/config.ru +4 -0
  43. data/test/dummy/config/application.rb +59 -0
  44. data/test/dummy/config/boot.rb +10 -0
  45. data/test/dummy/config/database.yml +25 -0
  46. data/test/dummy/config/environment.rb +5 -0
  47. data/test/dummy/config/environments/development.rb +37 -0
  48. data/test/dummy/config/environments/production.rb +67 -0
  49. data/test/dummy/config/environments/test.rb +37 -0
  50. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  51. data/test/dummy/config/initializers/inflections.rb +15 -0
  52. data/test/dummy/config/initializers/mime_types.rb +5 -0
  53. data/test/dummy/config/initializers/secret_token.rb +7 -0
  54. data/test/dummy/config/initializers/session_store.rb +8 -0
  55. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  56. data/test/dummy/config/locales/en.yml +5 -0
  57. data/test/dummy/config/routes.rb +4 -0
  58. data/test/dummy/public/404.html +26 -0
  59. data/test/dummy/public/422.html +26 -0
  60. data/test/dummy/public/500.html +25 -0
  61. data/test/dummy/public/favicon.ico +0 -0
  62. data/test/dummy/script/rails +6 -0
  63. data/test/functional/devmate/prompts_controller_test.rb +9 -0
  64. data/test/integration/navigation_test.rb +10 -0
  65. data/test/test_helper.rb +15 -0
  66. metadata +117 -30
  67. data/.gitignore +0 -22
  68. data/Gemfile +0 -4
  69. data/README.md +0 -29
  70. data/devmate.gemspec +0 -24
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzQwYjY1NTZkNGNkNGQ3ZTUzN2U2OTMyZTI0M2U2MTE0MTgzZWM5Yg==
4
+ N2Y0Yjg5OWZkODBlZGVjNTQwMGE1NDY4YjIzMjQ3OTY0NWQxODQxMQ==
5
5
  data.tar.gz: !binary |-
6
- Y2FkZDE4NGUzYzkzMjVjNmE0N2NmMjkzZWJjOGNjMjJkYTM2ZTZlYg==
6
+ YzIwZTNlYTQ0YWRmMjlhYTJiYzQ5OGYyOTIwMjQ5ZTJjNzA2MWZjNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjA0YTJlY2ZmMzU0MmYzYjcyODhhOTBiM2RmZDI2ZDQ5NmExM2ZkZjRlZGM2
10
- OTk4NmZkMTY5YmM1ZmM0ZGQyYmZmMDdjN2RjNWY5ZmMzYmZiZjViZTFiNTdh
11
- MGIzZjVjYTAzN2ZkNDliMTYzMmViMjU4OWFmM2I4N2IwNGQ3M2E=
9
+ YmI2OGEzMzVkZTc3MTI5OGYyMWZiY2Q2NzFmOGRmNWY5ZmU1Y2Q4Mjg3NjBm
10
+ YTFiZjNhYWYwZGQ4Zjg0MGI3MjE3ZGQyN2RiYjNmNDNmMzU2YzU3MTIwOTM0
11
+ NTc4YTg5M2UwODYyMzc2ZjEwNTA4MzNhMTIyZmQzMTVmODU4NTY=
12
12
  data.tar.gz: !binary |-
13
- MmUyYmQ4ODdhZjYyNzE5M2ZlZWY1YWI4ZmRkZTg0N2RkZmYzNzMxZmUwYTE3
14
- ZWUwZjMyMTI5ZjUzYTkyOTE2OTdjODMzM2M3NTUxZWIzNDBhZDUyM2RjN2Fk
15
- NWNmNGIzMGI2M2I5YmU4NjUyMDQ5OTJmYjQ5NTM4MTY1ZDY0ODc=
13
+ YmNhNDRmNmUzMGJmZDVhMDIyMjMzZDBiMWU1MjFiMGNhMmE3NzY3NjViNGM3
14
+ N2QxMmVhNjE0Y2IxZTdmNzNlNzIxOWRiZGFjYmFjNGE5NDUyMTI1NTZjMjll
15
+ ODBkY2IxNjFhYmQ5Mjc1N2U0YjVhNTY5MGFiMTM5OTU2ZWUyMTE=
@@ -1,6 +1,4 @@
1
- Copyright (c) 2014 Siddharth Bhagwan
2
-
3
- MIT License
1
+ Copyright 2014 YOURNAME
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining
6
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,7 @@
1
+ Devmate is a gem that uses [noty](http://ned.im/noty/) to popup random programming and tech quotes from time to time.
2
+
3
+ Customize the quotes and the timing as per your convenience!
4
+
5
+ To install, add the gemfile to the development group
6
+
7
+ This project rocks and uses MIT-LICENSE.
data/Rakefile CHANGED
@@ -1,2 +1,40 @@
1
- require "bundler/gem_tasks"
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
2
14
 
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Devmate'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,35 @@
1
+ //
2
+ //= require jquery
3
+ //= require jquery_ujs
4
+ //= require_tree .
5
+
6
+ // Fetch Data
7
+ var quotes = undefined;
8
+
9
+ $.ajax({
10
+ url: '/fetchData.json',
11
+ success: function(msg) {
12
+ quotes = msg;
13
+ },
14
+ error: function(jqXHR, textStatus, errorThrown){
15
+ },
16
+ complete: function(){
17
+ setTimeout(setPrompt, 1000);
18
+ }
19
+ });
20
+
21
+
22
+ setPrompt = function() {
23
+ // Generate a random number of the quote to be picked
24
+ random_index = ((Math.floor((Math.random() * 100))% quotes.data_count) + 1)
25
+ noty({
26
+ text: quotes.data[random_index],
27
+ layout: quotes.position,
28
+ maxVisible: quotes.maxVisible,
29
+ timeout: quotes.timeout,
30
+ type: 'default'
31
+ });
32
+
33
+ setTimeout(setPrompt, quotes.call_timeout);
34
+ };
35
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Nedim Arabacı
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,488 @@
1
+ /**
2
+ * noty - jQuery Notification Plugin v2.2.2
3
+ * Contributors: https://github.com/needim/noty/graphs/contributors
4
+ *
5
+ * Examples and Documentation - http://needim.github.com/noty/
6
+ *
7
+ * Licensed under the MIT licenses:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ *
10
+ **/
11
+
12
+ if (typeof Object.create !== 'function') {
13
+ Object.create = function (o) {
14
+ function F() {
15
+ }
16
+
17
+ F.prototype = o;
18
+ return new F();
19
+ };
20
+ }
21
+
22
+ (function ($) {
23
+
24
+ var NotyObject = {
25
+
26
+ init:function (options) {
27
+
28
+ // Mix in the passed in options with the default options
29
+ this.options = $.extend({}, $.noty.defaults, options);
30
+
31
+ this.options.layout = (this.options.custom) ? $.noty.layouts['inline'] : $.noty.layouts[this.options.layout];
32
+
33
+ if ($.noty.themes[this.options.theme])
34
+ this.options.theme = $.noty.themes[this.options.theme];
35
+ else
36
+ options.themeClassName = this.options.theme;
37
+
38
+ delete options.layout;
39
+ delete options.theme;
40
+
41
+ this.options = $.extend({}, this.options, this.options.layout.options);
42
+ this.options.id = 'noty_' + (new Date().getTime() * Math.floor(Math.random() * 1000000));
43
+
44
+ this.options = $.extend({}, this.options, options);
45
+
46
+ // Build the noty dom initial structure
47
+ this._build();
48
+
49
+ // return this so we can chain/use the bridge with less code.
50
+ return this;
51
+ }, // end init
52
+
53
+ _build:function () {
54
+
55
+ // Generating noty bar
56
+ var $bar = $('<div class="noty_bar noty_type_' + this.options.type + '"></div>').attr('id', this.options.id);
57
+ $bar.append(this.options.template).find('.noty_text').html(this.options.text);
58
+
59
+ this.$bar = (this.options.layout.parent.object !== null) ? $(this.options.layout.parent.object).css(this.options.layout.parent.css).append($bar) : $bar;
60
+
61
+ if (this.options.themeClassName)
62
+ this.$bar.addClass(this.options.themeClassName).addClass('noty_container_type_' + this.options.type);
63
+
64
+ // Set buttons if available
65
+ if (this.options.buttons) {
66
+
67
+ // If we have button disable closeWith & timeout options
68
+ this.options.closeWith = [];
69
+ this.options.timeout = false;
70
+
71
+ var $buttons = $('<div/>').addClass('noty_buttons');
72
+
73
+ (this.options.layout.parent.object !== null) ? this.$bar.find('.noty_bar').append($buttons) : this.$bar.append($buttons);
74
+
75
+ var self = this;
76
+
77
+ $.each(this.options.buttons, function (i, button) {
78
+ var $button = $('<button/>').addClass((button.addClass) ? button.addClass : 'gray').html(button.text).attr('id', button.id ? button.id : 'button-' + i)
79
+ .appendTo(self.$bar.find('.noty_buttons'))
80
+ .on('click', function () {
81
+ if ($.isFunction(button.onClick)) {
82
+ button.onClick.call($button, self);
83
+ }
84
+ });
85
+ });
86
+ }
87
+
88
+ // For easy access
89
+ this.$message = this.$bar.find('.noty_message');
90
+ this.$closeButton = this.$bar.find('.noty_close');
91
+ this.$buttons = this.$bar.find('.noty_buttons');
92
+
93
+ $.noty.store[this.options.id] = this; // store noty for api
94
+
95
+ }, // end _build
96
+
97
+ show:function () {
98
+
99
+ var self = this;
100
+
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
+
103
+ if (self.options.theme && self.options.theme.style)
104
+ self.options.theme.style.apply(self);
105
+
106
+ ($.type(self.options.layout.css) === 'function') ? this.options.layout.css.apply(self.$bar) : self.$bar.css(this.options.layout.css || {});
107
+
108
+ self.$bar.addClass(self.options.layout.addClass);
109
+
110
+ self.options.layout.container.style.apply($(self.options.layout.container.selector));
111
+
112
+ self.showing = true;
113
+
114
+ if (self.options.theme && self.options.theme.style)
115
+ self.options.theme.callback.onShow.apply(this);
116
+
117
+ if ($.inArray('click', self.options.closeWith) > -1)
118
+ self.$bar.css('cursor', 'pointer').one('click', function (evt) {
119
+ self.stopPropagation(evt);
120
+ if (self.options.callback.onCloseClick) {
121
+ self.options.callback.onCloseClick.apply(self);
122
+ }
123
+ self.close();
124
+ });
125
+
126
+ if ($.inArray('hover', self.options.closeWith) > -1)
127
+ self.$bar.one('mouseenter', function () {
128
+ self.close();
129
+ });
130
+
131
+ if ($.inArray('button', self.options.closeWith) > -1)
132
+ self.$closeButton.one('click', function (evt) {
133
+ self.stopPropagation(evt);
134
+ self.close();
135
+ });
136
+
137
+ if ($.inArray('button', self.options.closeWith) == -1)
138
+ self.$closeButton.remove();
139
+
140
+ if (self.options.callback.onShow)
141
+ self.options.callback.onShow.apply(self);
142
+
143
+ self.$bar.animate(
144
+ self.options.animation.open,
145
+ self.options.animation.speed,
146
+ self.options.animation.easing,
147
+ function () {
148
+ if (self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
149
+ self.showing = false;
150
+ self.shown = true;
151
+ });
152
+
153
+ // If noty is have a timeout option
154
+ if (self.options.timeout)
155
+ self.$bar.delay(self.options.timeout).promise().done(function () {
156
+ self.close();
157
+ });
158
+
159
+ return this;
160
+
161
+ }, // end show
162
+
163
+ close:function () {
164
+
165
+ if (this.closed) return;
166
+ if (this.$bar && this.$bar.hasClass('i-am-closing-now')) return;
167
+
168
+ var self = this;
169
+
170
+ if (this.showing) {
171
+ self.$bar.queue(
172
+ function () {
173
+ self.close.apply(self);
174
+ }
175
+ )
176
+ return;
177
+ }
178
+
179
+ if (!this.shown && !this.showing) { // If we are still waiting in the queue just delete from queue
180
+ var queue = [];
181
+ $.each($.noty.queue, function (i, n) {
182
+ if (n.options.id != self.options.id) {
183
+ queue.push(n);
184
+ }
185
+ });
186
+ $.noty.queue = queue;
187
+ return;
188
+ }
189
+
190
+ self.$bar.addClass('i-am-closing-now');
191
+
192
+ if (self.options.callback.onClose) {
193
+ self.options.callback.onClose.apply(self);
194
+ }
195
+
196
+ self.$bar.clearQueue().stop().animate(
197
+ self.options.animation.close,
198
+ self.options.animation.speed,
199
+ self.options.animation.easing,
200
+ function () {
201
+ if (self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
202
+ })
203
+ .promise().done(function () {
204
+
205
+ // Modal Cleaning
206
+ if (self.options.modal) {
207
+ $.notyRenderer.setModalCount(-1);
208
+ if ($.notyRenderer.getModalCount() == 0) $('.noty_modal').fadeOut('fast', function () {
209
+ $(this).remove();
210
+ });
211
+ }
212
+
213
+ // Layout Cleaning
214
+ $.notyRenderer.setLayoutCountFor(self, -1);
215
+ if ($.notyRenderer.getLayoutCountFor(self) == 0) $(self.options.layout.container.selector).remove();
216
+
217
+ // Make sure self.$bar has not been removed before attempting to remove it
218
+ if (typeof self.$bar !== 'undefined' && self.$bar !== null ) {
219
+ self.$bar.remove();
220
+ self.$bar = null;
221
+ self.closed = true;
222
+ }
223
+
224
+ delete $.noty.store[self.options.id]; // deleting noty from store
225
+
226
+ if(self.options.theme.callback && self.options.theme.callback.onClose) {
227
+ self.options.theme.callback.onClose.apply(self);
228
+ }
229
+
230
+ if (!self.options.dismissQueue) {
231
+ // Queue render
232
+ $.noty.ontap = true;
233
+
234
+ $.notyRenderer.render();
235
+ }
236
+
237
+ if (self.options.maxVisible > 0 && self.options.dismissQueue) {
238
+ $.notyRenderer.render();
239
+ }
240
+ })
241
+
242
+ }, // end close
243
+
244
+ setText:function (text) {
245
+ if (!this.closed) {
246
+ this.options.text = text;
247
+ this.$bar.find('.noty_text').html(text);
248
+ }
249
+ return this;
250
+ },
251
+
252
+ setType:function (type) {
253
+ if (!this.closed) {
254
+ this.options.type = type;
255
+ this.options.theme.style.apply(this);
256
+ this.options.theme.callback.onShow.apply(this);
257
+ }
258
+ return this;
259
+ },
260
+
261
+ setTimeout:function (time) {
262
+ if (!this.closed) {
263
+ var self = this;
264
+ this.options.timeout = time;
265
+ self.$bar.delay(self.options.timeout).promise().done(function () {
266
+ self.close();
267
+ });
268
+ }
269
+ return this;
270
+ },
271
+
272
+ stopPropagation:function (evt) {
273
+ evt = evt || window.event;
274
+ if (typeof evt.stopPropagation !== "undefined") {
275
+ evt.stopPropagation();
276
+ } else {
277
+ evt.cancelBubble = true;
278
+ }
279
+ },
280
+
281
+ closed:false,
282
+ showing:false,
283
+ shown:false
284
+
285
+ }; // end NotyObject
286
+
287
+ $.notyRenderer = {};
288
+
289
+ $.notyRenderer.init = function (options) {
290
+
291
+ // Renderer creates a new noty
292
+ var notification = Object.create(NotyObject).init(options);
293
+
294
+ if (notification.options.killer)
295
+ $.noty.closeAll();
296
+
297
+ (notification.options.force) ? $.noty.queue.unshift(notification) : $.noty.queue.push(notification);
298
+
299
+ $.notyRenderer.render();
300
+
301
+ return ($.noty.returns == 'object') ? notification : notification.options.id;
302
+ };
303
+
304
+ $.notyRenderer.render = function () {
305
+
306
+ var instance = $.noty.queue[0];
307
+
308
+ if ($.type(instance) === 'object') {
309
+ if (instance.options.dismissQueue) {
310
+ if (instance.options.maxVisible > 0) {
311
+ if ($(instance.options.layout.container.selector + ' li').length < instance.options.maxVisible) {
312
+ $.notyRenderer.show($.noty.queue.shift());
313
+ } else {
314
+
315
+ }
316
+ } else {
317
+ $.notyRenderer.show($.noty.queue.shift());
318
+ }
319
+ } else {
320
+ if ($.noty.ontap) {
321
+ $.notyRenderer.show($.noty.queue.shift());
322
+ $.noty.ontap = false;
323
+ }
324
+ }
325
+ } else {
326
+ $.noty.ontap = true; // Queue is over
327
+ }
328
+
329
+ };
330
+
331
+ $.notyRenderer.show = function (notification) {
332
+
333
+ if (notification.options.modal) {
334
+ $.notyRenderer.createModalFor(notification);
335
+ $.notyRenderer.setModalCount(+1);
336
+ }
337
+
338
+ // Where is the container?
339
+ if (notification.options.custom) {
340
+ if (notification.options.custom.find(notification.options.layout.container.selector).length == 0) {
341
+ notification.options.custom.append($(notification.options.layout.container.object).addClass('i-am-new'));
342
+ } else {
343
+ notification.options.custom.find(notification.options.layout.container.selector).removeClass('i-am-new');
344
+ }
345
+ } else {
346
+ if ($(notification.options.layout.container.selector).length == 0) {
347
+ $('body').append($(notification.options.layout.container.object).addClass('i-am-new'));
348
+ } else {
349
+ $(notification.options.layout.container.selector).removeClass('i-am-new');
350
+ }
351
+ }
352
+
353
+ $.notyRenderer.setLayoutCountFor(notification, +1);
354
+
355
+ notification.show();
356
+ };
357
+
358
+ $.notyRenderer.createModalFor = function (notification) {
359
+ if ($('.noty_modal').length == 0) {
360
+ var modal = $('<div/>').addClass('noty_modal').addClass(notification.options.theme).data('noty_modal_count', 0);
361
+
362
+ if (notification.options.theme.modal && notification.options.theme.modal.css)
363
+ modal.css(notification.options.theme.modal.css);
364
+
365
+ modal.prependTo($('body')).fadeIn('fast');
366
+ }
367
+ };
368
+
369
+ $.notyRenderer.getLayoutCountFor = function (notification) {
370
+ return $(notification.options.layout.container.selector).data('noty_layout_count') || 0;
371
+ };
372
+
373
+ $.notyRenderer.setLayoutCountFor = function (notification, arg) {
374
+ return $(notification.options.layout.container.selector).data('noty_layout_count', $.notyRenderer.getLayoutCountFor(notification) + arg);
375
+ };
376
+
377
+ $.notyRenderer.getModalCount = function () {
378
+ return $('.noty_modal').data('noty_modal_count') || 0;
379
+ };
380
+
381
+ $.notyRenderer.setModalCount = function (arg) {
382
+ return $('.noty_modal').data('noty_modal_count', $.notyRenderer.getModalCount() + arg);
383
+ };
384
+
385
+ // This is for custom container
386
+ $.fn.noty = function (options) {
387
+ options.custom = $(this);
388
+ return $.notyRenderer.init(options);
389
+ };
390
+
391
+ $.noty = {};
392
+ $.noty.queue = [];
393
+ $.noty.ontap = true;
394
+ $.noty.layouts = {};
395
+ $.noty.themes = {};
396
+ $.noty.returns = 'object';
397
+ $.noty.store = {};
398
+
399
+ $.noty.get = function (id) {
400
+ return $.noty.store.hasOwnProperty(id) ? $.noty.store[id] : false;
401
+ };
402
+
403
+ $.noty.close = function (id) {
404
+ return $.noty.get(id) ? $.noty.get(id).close() : false;
405
+ };
406
+
407
+ $.noty.setText = function (id, text) {
408
+ return $.noty.get(id) ? $.noty.get(id).setText(text) : false;
409
+ };
410
+
411
+ $.noty.setType = function (id, type) {
412
+ return $.noty.get(id) ? $.noty.get(id).setType(type) : false;
413
+ };
414
+
415
+ $.noty.clearQueue = function () {
416
+ $.noty.queue = [];
417
+ };
418
+
419
+ $.noty.closeAll = function () {
420
+ $.noty.clearQueue();
421
+ $.each($.noty.store, function (id, noty) {
422
+ noty.close();
423
+ });
424
+ };
425
+
426
+ var windowAlert = window.alert;
427
+
428
+ $.noty.consumeAlert = function (options) {
429
+ window.alert = function (text) {
430
+ if (options)
431
+ options.text = text;
432
+ else
433
+ options = {text:text};
434
+
435
+ $.notyRenderer.init(options);
436
+ };
437
+ };
438
+
439
+ $.noty.stopConsumeAlert = function () {
440
+ window.alert = windowAlert;
441
+ };
442
+
443
+ $.noty.defaults = {
444
+ layout:'top',
445
+ theme:'defaultTheme',
446
+ type:'alert',
447
+ text:'',
448
+ dismissQueue:true,
449
+ template:'<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
450
+ animation:{
451
+ open:{height:'toggle'},
452
+ close:{height:'toggle'},
453
+ easing:'swing',
454
+ speed:500
455
+ },
456
+ timeout:false,
457
+ force:false,
458
+ modal:false,
459
+ maxVisible:5,
460
+ killer: false,
461
+ closeWith:['click'],
462
+ callback:{
463
+ onShow:function () {
464
+ },
465
+ afterShow:function () {
466
+ },
467
+ onClose:function () {
468
+ },
469
+ afterClose:function () {
470
+ },
471
+ onCloseClick:function () {
472
+ }
473
+ },
474
+ buttons:false
475
+ };
476
+
477
+ $(window).on('resize', function () {
478
+ $.each($.noty.layouts, function (index, layout) {
479
+ layout.container.style.apply($(layout.container.selector));
480
+ });
481
+ });
482
+
483
+ })(jQuery);
484
+
485
+ // Helpers
486
+ window.noty = function noty(options) {
487
+ return jQuery.notyRenderer.init(options);
488
+ };