pwpush 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 (139) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/Capfile +8 -0
  4. data/Gemfile +51 -0
  5. data/Gemfile.lock +224 -0
  6. data/LICENSE.txt +674 -0
  7. data/Procfile +3 -0
  8. data/README.md +91 -0
  9. data/Rakefile +8 -0
  10. data/TODO +21 -0
  11. data/app.json +21 -0
  12. data/app/assets/flash/clippy.swf +0 -0
  13. data/app/assets/flash/github-clippy.swf +0 -0
  14. data/app/assets/images/apple-touch-icon-ipad.png +0 -0
  15. data/app/assets/images/apple-touch-icon-ipad3.png +0 -0
  16. data/app/assets/images/apple-touch-icon-iphone.png +0 -0
  17. data/app/assets/images/apple-touch-icon-iphone4.png +0 -0
  18. data/app/assets/images/black_wood.jpg +0 -0
  19. data/app/assets/images/broken_noise.png +0 -0
  20. data/app/assets/images/button_down.png +0 -0
  21. data/app/assets/images/button_over.png +0 -0
  22. data/app/assets/images/button_up.png +0 -0
  23. data/app/assets/images/concrete_wall_3.png +0 -0
  24. data/app/assets/images/favicon.ico +0 -0
  25. data/app/assets/images/forkme.png +0 -0
  26. data/app/assets/images/outlets.png +0 -0
  27. data/app/assets/images/pwpush_favicon.jpg +0 -0
  28. data/app/assets/images/pwpush_logo.png +0 -0
  29. data/app/assets/images/rails.png +0 -0
  30. data/app/assets/javascripts/api.js.coffee +4 -0
  31. data/app/assets/javascripts/application.js +52 -0
  32. data/app/assets/javascripts/errors.js.coffee +3 -0
  33. data/app/assets/javascripts/fd-slider.js +1299 -0
  34. data/app/assets/javascripts/jquery-cookie.js +117 -0
  35. data/app/assets/javascripts/jquery.noty.js +520 -0
  36. data/app/assets/javascripts/layouts/top.js +34 -0
  37. data/app/assets/javascripts/passwords.js +62 -0
  38. data/app/assets/javascripts/spoiler.js +101 -0
  39. data/app/assets/javascripts/themes/default.js +156 -0
  40. data/app/assets/stylesheets/api.css.scss +3 -0
  41. data/app/assets/stylesheets/application.css +7 -0
  42. data/app/assets/stylesheets/errors.css.scss +3 -0
  43. data/app/assets/stylesheets/fd-slider.css +650 -0
  44. data/app/assets/stylesheets/global.css.scss +52 -0
  45. data/app/assets/stylesheets/passwords.css.scss +114 -0
  46. data/app/assets/stylesheets/users.css.scss +11 -0
  47. data/app/controllers/api_controller.rb +30 -0
  48. data/app/controllers/application_controller.rb +23 -0
  49. data/app/controllers/errors_controller.rb +7 -0
  50. data/app/controllers/passwords_controller.rb +153 -0
  51. data/app/controllers/users/omniauth_callbacks_controller.rb +71 -0
  52. data/app/controllers/views_controller.rb +11 -0
  53. data/app/helpers/api_helper.rb +2 -0
  54. data/app/helpers/application_helper.rb +31 -0
  55. data/app/helpers/errors_helper.rb +2 -0
  56. data/app/helpers/passwords_helper.rb +2 -0
  57. data/app/helpers/views_helper.rb +2 -0
  58. data/app/mailers/.gitkeep +0 -0
  59. data/app/models/.gitkeep +0 -0
  60. data/app/models/password.rb +51 -0
  61. data/app/models/user.rb +20 -0
  62. data/app/models/view.rb +4 -0
  63. data/app/views/api/config.html.haml +2 -0
  64. data/app/views/api/create.html.haml +2 -0
  65. data/app/views/api/generate.html.haml +2 -0
  66. data/app/views/api/list.html.haml +2 -0
  67. data/app/views/devise/confirmations/new.html.erb +12 -0
  68. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  69. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  70. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  71. data/app/views/devise/passwords/edit.html.erb +16 -0
  72. data/app/views/devise/passwords/new.html.erb +12 -0
  73. data/app/views/devise/registrations/edit.html.erb +25 -0
  74. data/app/views/devise/registrations/new.html.haml +50 -0
  75. data/app/views/devise/sessions/new.html.haml +51 -0
  76. data/app/views/devise/shared/_links.erb +25 -0
  77. data/app/views/devise/unlocks/new.html.erb +12 -0
  78. data/app/views/errors/error_404.html.haml +21 -0
  79. data/app/views/errors/error_500.html.haml +21 -0
  80. data/app/views/layouts/_ga.html.erb +14 -0
  81. data/app/views/layouts/application.html.haml +41 -0
  82. data/app/views/pages/about.html.haml +159 -0
  83. data/app/views/passwords/edit.html.haml +7 -0
  84. data/app/views/passwords/index.html.haml +17 -0
  85. data/app/views/passwords/new.html.haml +68 -0
  86. data/app/views/passwords/show.html.haml +58 -0
  87. data/app/views/shared/_auth_providers.html.haml +9 -0
  88. data/app/views/shared/_messages.html.haml +4 -0
  89. data/app/views/views/_form.html.erb +16 -0
  90. data/app/views/views/edit.html.erb +8 -0
  91. data/app/views/views/index.html.erb +21 -0
  92. data/app/views/views/new.html.erb +5 -0
  93. data/app/views/views/show.html.erb +20 -0
  94. data/bin/bundle +13 -0
  95. data/config.ru +4 -0
  96. data/config/application.rb +51 -0
  97. data/config/boot.rb +6 -0
  98. data/config/capistrano_database_yml.rb +158 -0
  99. data/config/database.yml +19 -0
  100. data/config/deploy.rb +140 -0
  101. data/config/deploy/database.yml.erb +52 -0
  102. data/config/deploy/local_cap_config.rb.example +54 -0
  103. data/config/environment.rb +42 -0
  104. data/config/environments/development.rb +30 -0
  105. data/config/environments/engineyard.rb +60 -0
  106. data/config/environments/private.rb +60 -0
  107. data/config/environments/production.rb +60 -0
  108. data/config/environments/test.rb +39 -0
  109. data/config/initializers/backtrace_silencers.rb +7 -0
  110. data/config/initializers/devise.rb +211 -0
  111. data/config/initializers/inflections.rb +10 -0
  112. data/config/initializers/mime_types.rb +5 -0
  113. data/config/initializers/secret_token.rb +7 -0
  114. data/config/initializers/session_store.rb +8 -0
  115. data/config/initializers/wrap_parameters.rb +14 -0
  116. data/config/locales/devise.en.yml +58 -0
  117. data/config/locales/en.yml +5 -0
  118. data/config/routes.rb +16 -0
  119. data/config/unicorn.rb +22 -0
  120. data/db/migrate/20111128183630_create_passwords.rb +12 -0
  121. data/db/migrate/20111228183300_create_views.rb +16 -0
  122. data/db/migrate/20120102210558_devise_create_users.rb +54 -0
  123. data/db/migrate/20120102210559_create_rails_admin_histories_table.rb +18 -0
  124. data/db/migrate/20120102220933_add_admin_to_user.rb +9 -0
  125. data/db/migrate/20120129211750_add_lockable_to_users.rb +10 -0
  126. data/db/migrate/20120220172426_add_user_to_password.rb +11 -0
  127. data/db/migrate/20121105144421_add_deleted_to_password.rb +5 -0
  128. data/db/migrate/20150323145847_add_first_view_flag.rb +9 -0
  129. data/db/migrate/20160214205926_add_deletable_to_password.rb +5 -0
  130. data/db/schema.rb +78 -0
  131. data/db/seeds.rb +7 -0
  132. data/log/.gitkeep +0 -0
  133. data/public/404.html +26 -0
  134. data/public/422.html +26 -0
  135. data/public/500.html +26 -0
  136. data/public/favicon.ico +0 -0
  137. data/public/robots.txt +3 -0
  138. data/script/rails +6 -0
  139. metadata +226 -0
@@ -0,0 +1,117 @@
1
+ /*!
2
+ * jQuery Cookie Plugin v1.4.0
3
+ * https://github.com/carhartl/jquery-cookie
4
+ *
5
+ * Copyright 2013 Klaus Hartl
6
+ * Released under the MIT license
7
+ */
8
+ (function (factory) {
9
+ if (typeof define === 'function' && define.amd) {
10
+ // AMD. Register as anonymous module.
11
+ define(['jquery'], factory);
12
+ } else {
13
+ // Browser globals.
14
+ factory(jQuery);
15
+ }
16
+ }(function ($) {
17
+
18
+ var pluses = /\+/g;
19
+
20
+ function encode(s) {
21
+ return config.raw ? s : encodeURIComponent(s);
22
+ }
23
+
24
+ function decode(s) {
25
+ return config.raw ? s : decodeURIComponent(s);
26
+ }
27
+
28
+ function stringifyCookieValue(value) {
29
+ return encode(config.json ? JSON.stringify(value) : String(value));
30
+ }
31
+
32
+ function parseCookieValue(s) {
33
+ if (s.indexOf('"') === 0) {
34
+ // This is a quoted cookie as according to RFC2068, unescape...
35
+ s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
36
+ }
37
+
38
+ try {
39
+ // Replace server-side written pluses with spaces.
40
+ // If we can't decode the cookie, ignore it, it's unusable.
41
+ s = decodeURIComponent(s.replace(pluses, ' '));
42
+ } catch(e) {
43
+ return;
44
+ }
45
+
46
+ try {
47
+ // If we can't parse the cookie, ignore it, it's unusable.
48
+ return config.json ? JSON.parse(s) : s;
49
+ } catch(e) {}
50
+ }
51
+
52
+ function read(s, converter) {
53
+ var value = config.raw ? s : parseCookieValue(s);
54
+ return $.isFunction(converter) ? converter(value) : value;
55
+ }
56
+
57
+ var config = $.cookie = function (key, value, options) {
58
+
59
+ // Write
60
+ if (value !== undefined && !$.isFunction(value)) {
61
+ options = $.extend({}, config.defaults, options);
62
+
63
+ if (typeof options.expires === 'number') {
64
+ var days = options.expires, t = options.expires = new Date();
65
+ t.setDate(t.getDate() + days);
66
+ }
67
+
68
+ return (document.cookie = [
69
+ encode(key), '=', stringifyCookieValue(value),
70
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
71
+ options.path ? '; path=' + options.path : '',
72
+ options.domain ? '; domain=' + options.domain : '',
73
+ options.secure ? '; secure' : ''
74
+ ].join(''));
75
+ }
76
+
77
+ // Read
78
+
79
+ var result = key ? undefined : {};
80
+
81
+ // To prevent the for loop in the first place assign an empty array
82
+ // in case there are no cookies at all. Also prevents odd result when
83
+ // calling $.cookie().
84
+ var cookies = document.cookie ? document.cookie.split('; ') : [];
85
+
86
+ for (var i = 0, l = cookies.length; i < l; i++) {
87
+ var parts = cookies[i].split('=');
88
+ var name = decode(parts.shift());
89
+ var cookie = parts.join('=');
90
+
91
+ if (key && key === name) {
92
+ // If second argument (value) is a function it's a converter...
93
+ result = read(cookie, value);
94
+ break;
95
+ }
96
+
97
+ // Prevent storing a cookie that we couldn't decode.
98
+ if (!key && (cookie = read(cookie)) !== undefined) {
99
+ result[name] = cookie;
100
+ }
101
+ }
102
+
103
+ return result;
104
+ };
105
+
106
+ config.defaults = {};
107
+
108
+ $.removeCookie = function (key, options) {
109
+ if ($.cookie(key) !== undefined) {
110
+ // Must not alter options, thus extending a fresh object...
111
+ $.cookie(key, '', $.extend({}, options, { expires: -1 }));
112
+ return true;
113
+ }
114
+ return false;
115
+ };
116
+
117
+ }));
@@ -0,0 +1,520 @@
1
+ /**
2
+ * noty - jQuery Notification Plugin v2.0.3
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
+ this.options.theme = $.noty.themes[this.options.theme];
33
+
34
+ delete options.layout;
35
+ delete options.theme;
36
+
37
+ this.options = $.extend({}, this.options, this.options.layout.options);
38
+ this.options.id = 'noty_' + (new Date().getTime() * Math.floor(Math.random() * 1000000));
39
+
40
+ this.options = $.extend({}, this.options, options);
41
+
42
+ // Build the noty dom initial structure
43
+ this._build();
44
+
45
+ // return this so we can chain/use the bridge with less code.
46
+ return this;
47
+ }, // end init
48
+
49
+ _build:function () {
50
+
51
+ // Generating noty bar
52
+ var $bar = $('<div class="noty_bar"></div>').attr('id', this.options.id);
53
+ $bar.append(this.options.template).find('.noty_text').html(this.options.text);
54
+
55
+ this.$bar = (this.options.layout.parent.object !== null) ? $(this.options.layout.parent.object).css(this.options.layout.parent.css).append($bar) : $bar;
56
+
57
+ // Set buttons if available
58
+ if (this.options.buttons) {
59
+
60
+ // If we have button disable closeWith & timeout options
61
+ this.options.closeWith = [];
62
+ this.options.timeout = false;
63
+
64
+ var $buttons = $('<div/>').addClass('noty_buttons');
65
+
66
+ (this.options.layout.parent.object !== null) ? this.$bar.find('.noty_bar').append($buttons) : this.$bar.append($buttons);
67
+
68
+ var self = this;
69
+
70
+ $.each(this.options.buttons, function (i, button) {
71
+ var $button = $('<button/>').addClass((button.addClass) ? button.addClass : 'gray').html(button.text)
72
+ .appendTo(self.$bar.find('.noty_buttons'))
73
+ .bind('click', function () {
74
+ if ($.isFunction(button.onClick)) {
75
+ button.onClick.call($button, self);
76
+ }
77
+ });
78
+ });
79
+ }
80
+
81
+ // For easy access
82
+ this.$message = this.$bar.find('.noty_message');
83
+ this.$closeButton = this.$bar.find('.noty_close');
84
+ this.$buttons = this.$bar.find('.noty_buttons');
85
+
86
+ $.noty.store[this.options.id] = this; // store noty for api
87
+
88
+ }, // end _build
89
+
90
+ show:function () {
91
+
92
+ var self = this;
93
+
94
+ $(self.options.layout.container.selector).append(self.$bar);
95
+
96
+ self.options.theme.style.apply(self);
97
+
98
+ ($.type(self.options.layout.css) === 'function') ? this.options.layout.css.apply(self.$bar) : self.$bar.css(this.options.layout.css || {});
99
+
100
+ self.$bar.addClass(self.options.layout.addClass);
101
+
102
+ self.options.layout.container.style.apply($(self.options.layout.container.selector));
103
+
104
+ self.options.theme.callback.onShow.apply(this);
105
+
106
+ if ($.inArray('click', self.options.closeWith) > -1)
107
+ self.$bar.css('cursor', 'pointer').one('click', function () {
108
+ self.close();
109
+ });
110
+
111
+ if ($.inArray('hover', self.options.closeWith) > -1)
112
+ self.$bar.one('mouseenter', function () {
113
+ self.close();
114
+ });
115
+
116
+ if ($.inArray('button', self.options.closeWith) > -1)
117
+ self.$closeButton.one('click', function () {
118
+ self.close();
119
+ });
120
+
121
+ if ($.inArray('button', self.options.closeWith) == -1)
122
+ self.$closeButton.remove();
123
+
124
+ if (self.options.callback.onShow)
125
+ self.options.callback.onShow.apply(self);
126
+
127
+ self.$bar.animate(
128
+ self.options.animation.open,
129
+ self.options.animation.speed,
130
+ self.options.animation.easing,
131
+ function () {
132
+ if (self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
133
+ self.shown = true;
134
+ });
135
+
136
+ // If noty is have a timeout option
137
+ if (self.options.timeout)
138
+ self.$bar.delay(self.options.timeout).promise().done(function () {
139
+ self.close();
140
+ });
141
+
142
+ return this;
143
+
144
+ }, // end show
145
+
146
+ close:function () {
147
+
148
+ if (this.closed) return;
149
+
150
+ var self = this;
151
+
152
+ if (!this.shown) { // If we are still waiting in the queue just delete from queue
153
+ var queue = [];
154
+ $.each($.noty.queue, function (i, n) {
155
+ if (n.options.id != self.options.id) {
156
+ queue.push(n);
157
+ }
158
+ });
159
+ $.noty.queue = queue;
160
+ return;
161
+ }
162
+
163
+ self.$bar.addClass('i-am-closing-now');
164
+
165
+ if (self.options.callback.onClose) {
166
+ self.options.callback.onClose.apply(self);
167
+ }
168
+
169
+ self.$bar.clearQueue().stop().animate(
170
+ self.options.animation.close,
171
+ self.options.animation.speed,
172
+ self.options.animation.easing,
173
+ function () {
174
+ if (self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
175
+ })
176
+ .promise().done(function () {
177
+
178
+ // Modal Cleaning
179
+ if (self.options.modal) {
180
+ $.notyRenderer.setModalCount(-1);
181
+ if ($.notyRenderer.getModalCount() == 0) $('.noty_modal').fadeOut('fast', function () {
182
+ $(this).remove();
183
+ });
184
+ }
185
+
186
+ // Layout Cleaning
187
+ $.notyRenderer.setLayoutCountFor(self, -1);
188
+ if ($.notyRenderer.getLayoutCountFor(self) == 0) $(self.options.layout.container.selector).remove();
189
+
190
+ // Make sure self.$bar has not been removed before attempting to remove it
191
+ if (typeof self.$bar !== 'undefined' && self.$bar !== null ) {
192
+ self.$bar.remove();
193
+ self.$bar = null;
194
+ self.closed = true;
195
+ }
196
+
197
+ delete $.noty.store[self.options.id]; // deleting noty from store
198
+
199
+ self.options.theme.callback.onClose.apply(self);
200
+
201
+ if (!self.options.dismissQueue) {
202
+ // Queue render
203
+ $.noty.ontap = true;
204
+
205
+ $.notyRenderer.render();
206
+ }
207
+
208
+ });
209
+
210
+ }, // end close
211
+
212
+ setText:function (text) {
213
+ if (!this.closed) {
214
+ this.options.text = text;
215
+ this.$bar.find('.noty_text').html(text);
216
+ }
217
+ return this;
218
+ },
219
+
220
+ setType:function (type) {
221
+ if (!this.closed) {
222
+ this.options.type = type;
223
+ this.options.theme.style.apply(this);
224
+ this.options.theme.callback.onShow.apply(this);
225
+ }
226
+ return this;
227
+ },
228
+
229
+ setTimeout:function (time) {
230
+ if (!this.closed) {
231
+ var self = this;
232
+ this.options.timeout = time;
233
+ self.$bar.delay(self.options.timeout).promise().done(function () {
234
+ self.close();
235
+ });
236
+ }
237
+ return this;
238
+ },
239
+
240
+ closed:false,
241
+ shown:false
242
+
243
+ }; // end NotyObject
244
+
245
+ $.notyRenderer = {};
246
+
247
+ $.notyRenderer.init = function (options) {
248
+
249
+ // Renderer creates a new noty
250
+ var notification = Object.create(NotyObject).init(options);
251
+
252
+ (notification.options.force) ? $.noty.queue.unshift(notification) : $.noty.queue.push(notification);
253
+
254
+ $.notyRenderer.render();
255
+
256
+ return ($.noty.returns == 'object') ? notification : notification.options.id;
257
+ };
258
+
259
+ $.notyRenderer.render = function () {
260
+
261
+ var instance = $.noty.queue[0];
262
+
263
+ if ($.type(instance) === 'object') {
264
+ if (instance.options.dismissQueue) {
265
+ $.notyRenderer.show($.noty.queue.shift());
266
+ } else {
267
+ if ($.noty.ontap) {
268
+ $.notyRenderer.show($.noty.queue.shift());
269
+ $.noty.ontap = false;
270
+ }
271
+ }
272
+ } else {
273
+ $.noty.ontap = true; // Queue is over
274
+ }
275
+
276
+ };
277
+
278
+ $.notyRenderer.show = function (notification) {
279
+
280
+ if (notification.options.modal) {
281
+ $.notyRenderer.createModalFor(notification);
282
+ $.notyRenderer.setModalCount(+1);
283
+ }
284
+
285
+ // Where is the container?
286
+ if ($(notification.options.layout.container.selector).length == 0) {
287
+ if (notification.options.custom) {
288
+ notification.options.custom.append($(notification.options.layout.container.object).addClass('i-am-new'));
289
+ } else {
290
+ $('body').append($(notification.options.layout.container.object).addClass('i-am-new'));
291
+ }
292
+ } else {
293
+ $(notification.options.layout.container.selector).removeClass('i-am-new');
294
+ }
295
+
296
+ $.notyRenderer.setLayoutCountFor(notification, +1);
297
+
298
+ notification.show();
299
+ };
300
+
301
+ $.notyRenderer.createModalFor = function (notification) {
302
+ if ($('.noty_modal').length == 0)
303
+ $('<div/>').addClass('noty_modal').data('noty_modal_count', 0).css(notification.options.theme.modal.css).prependTo($('body')).fadeIn('fast');
304
+ };
305
+
306
+ $.notyRenderer.getLayoutCountFor = function (notification) {
307
+ return $(notification.options.layout.container.selector).data('noty_layout_count') || 0;
308
+ };
309
+
310
+ $.notyRenderer.setLayoutCountFor = function (notification, arg) {
311
+ return $(notification.options.layout.container.selector).data('noty_layout_count', $.notyRenderer.getLayoutCountFor(notification) + arg);
312
+ };
313
+
314
+ $.notyRenderer.getModalCount = function () {
315
+ return $('.noty_modal').data('noty_modal_count') || 0;
316
+ };
317
+
318
+ $.notyRenderer.setModalCount = function (arg) {
319
+ return $('.noty_modal').data('noty_modal_count', $.notyRenderer.getModalCount() + arg);
320
+ };
321
+
322
+ // This is for custom container
323
+ $.fn.noty = function (options) {
324
+ options.custom = $(this);
325
+ return $.notyRenderer.init(options);
326
+ };
327
+
328
+ $.noty = {};
329
+ $.noty.queue = [];
330
+ $.noty.ontap = true;
331
+ $.noty.layouts = {};
332
+ $.noty.themes = {};
333
+ $.noty.returns = 'object';
334
+ $.noty.store = {};
335
+
336
+ $.noty.get = function (id) {
337
+ return $.noty.store.hasOwnProperty(id) ? $.noty.store[id] : false;
338
+ };
339
+
340
+ $.noty.close = function (id) {
341
+ return $.noty.get(id) ? $.noty.get(id).close() : false;
342
+ };
343
+
344
+ $.noty.setText = function (id, text) {
345
+ return $.noty.get(id) ? $.noty.get(id).setText(text) : false;
346
+ };
347
+
348
+ $.noty.setType = function (id, type) {
349
+ return $.noty.get(id) ? $.noty.get(id).setType(type) : false;
350
+ };
351
+
352
+ $.noty.clearQueue = function () {
353
+ $.noty.queue = [];
354
+ };
355
+
356
+ $.noty.closeAll = function () {
357
+ $.noty.clearQueue();
358
+ $.each($.noty.store, function (id, noty) {
359
+ noty.close();
360
+ });
361
+ };
362
+
363
+ var windowAlert = window.alert;
364
+
365
+ $.noty.consumeAlert = function (options) {
366
+ window.alert = function (text) {
367
+ if (options)
368
+ options.text = text;
369
+ else
370
+ options = {text:text};
371
+
372
+ $.notyRenderer.init(options);
373
+ };
374
+ };
375
+
376
+ $.noty.stopConsumeAlert = function () {
377
+ window.alert = windowAlert;
378
+ };
379
+
380
+ $.noty.defaults = {
381
+ layout:'top',
382
+ theme:'defaultTheme',
383
+ type:'alert',
384
+ text:'',
385
+ dismissQueue:true,
386
+ template:'<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
387
+ animation:{
388
+ open:{height:'toggle'},
389
+ close:{height:'toggle'},
390
+ easing:'swing',
391
+ speed:500
392
+ },
393
+ timeout:false,
394
+ force:false,
395
+ modal:false,
396
+ closeWith:['click'],
397
+ callback:{
398
+ onShow:function () {
399
+ },
400
+ afterShow:function () {
401
+ },
402
+ onClose:function () {
403
+ },
404
+ afterClose:function () {
405
+ }
406
+ },
407
+ buttons:false
408
+ };
409
+
410
+ $(window).resize(function () {
411
+ $.each($.noty.layouts, function (index, layout) {
412
+ layout.container.style.apply($(layout.container.selector));
413
+ });
414
+ });
415
+
416
+ })(jQuery);
417
+
418
+ // Helpers
419
+ function noty(options) {
420
+
421
+ // This is for BC - Will be deleted on v2.2.0
422
+ var using_old = 0
423
+ , old_to_new = {
424
+ 'animateOpen':'animation.open',
425
+ 'animateClose':'animation.close',
426
+ 'easing':'animation.easing',
427
+ 'speed':'animation.speed',
428
+ 'onShow':'callback.onShow',
429
+ 'onShown':'callback.afterShow',
430
+ 'onClose':'callback.onClose',
431
+ 'onClosed':'callback.afterClose'
432
+ };
433
+
434
+ jQuery.each(options, function (key, value) {
435
+ if (old_to_new[key]) {
436
+ using_old++;
437
+ var _new = old_to_new[key].split('.');
438
+
439
+ if (!options[_new[0]]) options[_new[0]] = {};
440
+
441
+ options[_new[0]][_new[1]] = (value) ? value : function () {
442
+ };
443
+ delete options[key];
444
+ }
445
+ });
446
+
447
+ if (!options.closeWith) {
448
+ options.closeWith = jQuery.noty.defaults.closeWith;
449
+ }
450
+
451
+ if (options.hasOwnProperty('closeButton')) {
452
+ using_old++;
453
+ if (options.closeButton) options.closeWith.push('button');
454
+ delete options.closeButton;
455
+ }
456
+
457
+ if (options.hasOwnProperty('closeOnSelfClick')) {
458
+ using_old++;
459
+ if (options.closeOnSelfClick) options.closeWith.push('click');
460
+ delete options.closeOnSelfClick;
461
+ }
462
+
463
+ if (options.hasOwnProperty('closeOnSelfOver')) {
464
+ using_old++;
465
+ if (options.closeOnSelfOver) options.closeWith.push('hover');
466
+ delete options.closeOnSelfOver;
467
+ }
468
+
469
+ if (options.hasOwnProperty('custom')) {
470
+ using_old++;
471
+ if (options.custom.container != 'null') options.custom = options.custom.container;
472
+ }
473
+
474
+ if (options.hasOwnProperty('cssPrefix')) {
475
+ using_old++;
476
+ delete options.cssPrefix;
477
+ }
478
+
479
+ if (options.theme == 'noty_theme_default') {
480
+ using_old++;
481
+ options.theme = 'defaultTheme';
482
+ }
483
+
484
+ if (!options.hasOwnProperty('dismissQueue')) {
485
+ if (options.layout == 'topLeft'
486
+ || options.layout == 'topRight'
487
+ || options.layout == 'bottomLeft'
488
+ || options.layout == 'bottomRight') {
489
+ options.dismissQueue = true;
490
+ } else {
491
+ options.dismissQueue = false;
492
+ }
493
+ }
494
+
495
+ if (options.buttons) {
496
+ jQuery.each(options.buttons, function (i, button) {
497
+ if (button.click) {
498
+ using_old++;
499
+ button.onClick = button.click;
500
+ delete button.click;
501
+ }
502
+ if (button.type) {
503
+ using_old++;
504
+ button.addClass = button.type;
505
+ delete button.type;
506
+ }
507
+ });
508
+ }
509
+
510
+ if (using_old) {
511
+ if (typeof console !== "undefined" && console.warn) {
512
+ console.warn('You are using noty v2 with v1.x.x options. @deprecated until v2.2.0 - Please update your options.');
513
+ }
514
+ }
515
+
516
+ // console.log(options);
517
+ // End of the BC
518
+
519
+ return jQuery.notyRenderer.init(options);
520
+ }