lobiboxing-rails 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +25 -0
- data/lib/lobiboxing/rails.rb +8 -0
- data/lib/lobiboxing/rails/version.rb +5 -0
- data/vendor/assets/javascripts/lobibox.js +1572 -0
- data/vendor/assets/javascripts/lobibox/messageboxes.js +1136 -0
- data/vendor/assets/javascripts/lobibox/notifications.js +435 -0
- data/vendor/assets/sounds/sound1.ogg +0 -0
- data/vendor/assets/sounds/sound2.ogg +0 -0
- data/vendor/assets/sounds/sound3.ogg +0 -0
- data/vendor/assets/sounds/sound4.ogg +0 -0
- data/vendor/assets/sounds/sound5.ogg +0 -0
- data/vendor/assets/sounds/sound6.ogg +0 -0
- data/vendor/assets/stylesheets/lobibox.css +1058 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c0727d59b996f0aee955b6d76b2b3edcd1df463
|
4
|
+
data.tar.gz: dcb1806e6c8fb8d4ee6b936a5e12349cf919ac64
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37f2a6261ee69cc405067f61676b52172fd302087079170558bbec1f7bd2f5420cd9264422ccfb9087d5c1eed364e18f40757014476bebd52f2158f7ba9dff66
|
7
|
+
data.tar.gz: 1a983a2b93c1f1e3024b3748824ad6b2882038af714d0a7aab75b848191ec2349d6b5162e7226987aaab449aa3edee810ba9ec55960bc3756245d870316268c6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Adam Griffis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# lobiboxrails
|
2
|
+
|
3
|
+
lobiboxrails wraps the [lobibox](https://github.com/arboshiki/lobibox) library in a rails engine for simple
|
4
|
+
use with the asset pipeline provided by rails 4.0. The gem includes the development (non-minified)
|
5
|
+
source for ease of exploration. The asset pipeline will minify in production.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Add the following to your gemfile:
|
10
|
+
|
11
|
+
gem 'lobiboxrails'
|
12
|
+
|
13
|
+
Add the following directive to your Javascript manifest file (application.js):
|
14
|
+
|
15
|
+
//= require lobibox
|
16
|
+
//= require lobibox/messageboxes
|
17
|
+
//= require lobibox/notifications
|
18
|
+
|
19
|
+
Application.css
|
20
|
+
|
21
|
+
//= require lobibox
|
22
|
+
|
23
|
+
## Versioning
|
24
|
+
|
25
|
+
lobiboxrails 1.2.4 == lobibox.js 1.2.4
|
@@ -0,0 +1,1572 @@
|
|
1
|
+
//Author : @arboshiki
|
2
|
+
//create lobibox object
|
3
|
+
var Lobibox = Lobibox || {};
|
4
|
+
(function () {
|
5
|
+
|
6
|
+
Lobibox.counter = 0;
|
7
|
+
//------------------------------------------------------------------------------
|
8
|
+
//------------------------------------------------------------------------------
|
9
|
+
|
10
|
+
//User can set default properties for prompt in the following way
|
11
|
+
//Lobibox.prompt.DEFAULT_OPTIONS = object;
|
12
|
+
Lobibox.prompt = function (type, options) {
|
13
|
+
return new LobiboxPrompt(type, options);
|
14
|
+
};
|
15
|
+
//User can set default properties for confirm in the following way
|
16
|
+
//Lobibox.confirm.DEFAULT_OPTIONS = object;
|
17
|
+
Lobibox.confirm = function (options) {
|
18
|
+
return new LobiboxConfirm(options);
|
19
|
+
};
|
20
|
+
//User can set default properties for progress in the following way
|
21
|
+
//Lobibox.progress.DEFAULT_OPTIONS = object;
|
22
|
+
Lobibox.progress = function (options) {
|
23
|
+
return new LobiboxProgress(options);
|
24
|
+
};
|
25
|
+
//Create empty objects in order user to be able to set default options in the following way
|
26
|
+
//Lobibox.error.DEFAULT_OPTIONS = object;
|
27
|
+
//Lobibox.success.DEFAULT_OPTIONS = object;
|
28
|
+
//Lobibox.warning.DEFAULT_OPTIONS = object;
|
29
|
+
//Lobibox.info.DEFAULT_OPTIONS = object;
|
30
|
+
|
31
|
+
Lobibox.error = {};
|
32
|
+
Lobibox.success = {};
|
33
|
+
Lobibox.warning = {};
|
34
|
+
Lobibox.info = {};
|
35
|
+
|
36
|
+
//User can set default properties for alert in the following way
|
37
|
+
//Lobibox.alert.DEFAULT_OPTIONS = object;
|
38
|
+
Lobibox.alert = function (type, options) {
|
39
|
+
if (["success", "error", "warning", "info"].indexOf(type) > -1) {
|
40
|
+
return new LobiboxAlert(type, options);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
//User can set default properties for window in the following way
|
44
|
+
//Lobibox.window.DEFAULT_OPTIONS = object;
|
45
|
+
Lobibox.window = function (options) {
|
46
|
+
return new LobiboxWindow('window', options);
|
47
|
+
};
|
48
|
+
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Base prototype for all messageboxes and window
|
52
|
+
*/
|
53
|
+
var LobiboxBase = {
|
54
|
+
$type: null,
|
55
|
+
$el: null,
|
56
|
+
$options: null,
|
57
|
+
debug: function () {
|
58
|
+
if (this.$options.debug) {
|
59
|
+
window.console.debug.apply(window.console, arguments);
|
60
|
+
}
|
61
|
+
},
|
62
|
+
_processInput: function (options) {
|
63
|
+
if ($.isArray(options.buttons)) {
|
64
|
+
var btns = {};
|
65
|
+
for (var i = 0; i < options.buttons.length; i++) {
|
66
|
+
btns[options.buttons[i]] = Lobibox.base.OPTIONS.buttons[options.buttons[i]];
|
67
|
+
}
|
68
|
+
options.buttons = btns;
|
69
|
+
}
|
70
|
+
options.customBtnClass = options.customBtnClass ? options.customBtnClass : Lobibox.base.DEFAULTS.customBtnClass;
|
71
|
+
for (var i in options.buttons) {
|
72
|
+
if (options.buttons.hasOwnProperty(i)) {
|
73
|
+
var btn = options.buttons[i];
|
74
|
+
btn = $.extend({}, Lobibox.base.OPTIONS.buttons[i], btn);
|
75
|
+
if (!btn['class']) {
|
76
|
+
btn['class'] = options.customBtnClass;
|
77
|
+
}
|
78
|
+
options.buttons[i] = btn;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
options = $.extend({}, Lobibox.base.DEFAULTS, options);
|
82
|
+
if (options.showClass === undefined) {
|
83
|
+
options.showClass = Lobibox.base.OPTIONS.showClass;
|
84
|
+
}
|
85
|
+
if (options.hideClass === undefined) {
|
86
|
+
options.hideClass = Lobibox.base.OPTIONS.hideClass;
|
87
|
+
}
|
88
|
+
if (options.baseClass === undefined) {
|
89
|
+
options.baseClass = Lobibox.base.OPTIONS.baseClass;
|
90
|
+
}
|
91
|
+
if (options.delayToRemove === undefined) {
|
92
|
+
options.delayToRemove = Lobibox.base.OPTIONS.delayToRemove;
|
93
|
+
}
|
94
|
+
if (!options.iconClass) {
|
95
|
+
options.iconClass = Lobibox.base.OPTIONS.icons[options.iconSource][this.$type];
|
96
|
+
}
|
97
|
+
return options;
|
98
|
+
},
|
99
|
+
_init: function () {
|
100
|
+
var me = this;
|
101
|
+
|
102
|
+
me._createMarkup();
|
103
|
+
me.setTitle(me.$options.title);
|
104
|
+
if (me.$options.draggable && !me._isMobileScreen()) {
|
105
|
+
me.$el.addClass('draggable');
|
106
|
+
me._enableDrag();
|
107
|
+
}
|
108
|
+
if (me.$options.closeButton) {
|
109
|
+
me._addCloseButton();
|
110
|
+
}
|
111
|
+
if (me.$options.closeOnEsc) {
|
112
|
+
$(document).on('keyup.lobibox', function (ev) {
|
113
|
+
if (ev.which === 27) {
|
114
|
+
me.destroy();
|
115
|
+
}
|
116
|
+
});
|
117
|
+
}
|
118
|
+
if (me.$options.baseClass) {
|
119
|
+
me.$el.addClass(me.$options.baseClass);
|
120
|
+
}
|
121
|
+
if (me.$options.showClass) {
|
122
|
+
me.$el.removeClass(me.$options.hideClass);
|
123
|
+
me.$el.addClass(me.$options.showClass);
|
124
|
+
}
|
125
|
+
me.$el.data('lobibox', me);
|
126
|
+
},
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Calculate top, left position based on string keyword
|
130
|
+
*
|
131
|
+
* @param {string} position "'top', 'center', 'bottom'"
|
132
|
+
* @returns {{left: number, top: number}}
|
133
|
+
* @private
|
134
|
+
*/
|
135
|
+
_calculatePosition: function (position) {
|
136
|
+
var me = this;
|
137
|
+
var top;
|
138
|
+
if (position === 'top') {
|
139
|
+
top = 30;
|
140
|
+
} else if (position === 'bottom') {
|
141
|
+
top = $(window).outerHeight() - me.$el.outerHeight() - 30;
|
142
|
+
} else {
|
143
|
+
top = ($(window).outerHeight() - me.$el.outerHeight()) / 2;
|
144
|
+
}
|
145
|
+
var left = ($(window).outerWidth() - me.$el.outerWidth()) / 2;
|
146
|
+
return {
|
147
|
+
left: left,
|
148
|
+
top: top
|
149
|
+
};
|
150
|
+
},
|
151
|
+
|
152
|
+
_createButton: function (type, op) {
|
153
|
+
var me = this;
|
154
|
+
var btn = $('<button></button>')
|
155
|
+
.addClass(op['class'])
|
156
|
+
.attr('data-type', type)
|
157
|
+
.html(op.text);
|
158
|
+
if (me.$options.callback && typeof me.$options.callback === 'function') {
|
159
|
+
btn.on('click.lobibox', function (ev) {
|
160
|
+
var bt = $(this);
|
161
|
+
me._onButtonClick(me.$options.buttons[type], type);
|
162
|
+
me.$options.callback(me, bt.data('type'), ev);
|
163
|
+
});
|
164
|
+
}
|
165
|
+
btn.click(function () {
|
166
|
+
me._onButtonClick(me.$options.buttons[type], type);
|
167
|
+
});
|
168
|
+
return btn;
|
169
|
+
},
|
170
|
+
|
171
|
+
_onButtonClick: function (buttonOptions, type) {
|
172
|
+
var me = this;
|
173
|
+
|
174
|
+
if ((type === 'ok' && me.$type === 'prompt' && me.isValid() || me.$type !== 'prompt' || type !== 'ok')
|
175
|
+
&& buttonOptions && buttonOptions.closeOnClick) {
|
176
|
+
me.destroy();
|
177
|
+
}
|
178
|
+
},
|
179
|
+
|
180
|
+
_generateButtons: function () {
|
181
|
+
var me = this;
|
182
|
+
var btns = [];
|
183
|
+
for (var i in me.$options.buttons) {
|
184
|
+
if (me.$options.buttons.hasOwnProperty(i)) {
|
185
|
+
var op = me.$options.buttons[i];
|
186
|
+
var btn = me._createButton(i, op);
|
187
|
+
btns.push(btn);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
return btns;
|
191
|
+
},
|
192
|
+
_createMarkup: function () {
|
193
|
+
var me = this;
|
194
|
+
var lobibox = $('<div class="lobibox"></div>');
|
195
|
+
lobibox.attr('data-is-modal', me.$options.modal);
|
196
|
+
var header = $('<div class="lobibox-header"></div>')
|
197
|
+
.append('<span class="lobibox-title"></span>')
|
198
|
+
;
|
199
|
+
var body = $('<div class="lobibox-body"></div>');
|
200
|
+
lobibox.append(header);
|
201
|
+
lobibox.append(body);
|
202
|
+
if (me.$options.buttons && !$.isEmptyObject(me.$options.buttons)) {
|
203
|
+
var footer = $('<div class="lobibox-footer"></div>');
|
204
|
+
footer.append(me._generateButtons());
|
205
|
+
lobibox.append(footer);
|
206
|
+
if (Lobibox.base.OPTIONS.buttonsAlign.indexOf(me.$options.buttonsAlign) > -1) {
|
207
|
+
footer.addClass('text-' + me.$options.buttonsAlign);
|
208
|
+
}
|
209
|
+
}
|
210
|
+
me.$el = lobibox
|
211
|
+
.addClass(Lobibox.base.OPTIONS.modalClasses[me.$type])
|
212
|
+
;
|
213
|
+
},
|
214
|
+
_setSize: function () {
|
215
|
+
var me = this;
|
216
|
+
me.setWidth(me.$options.width);
|
217
|
+
if (me.$options.height === 'auto') {
|
218
|
+
me.setHeight(me.$el.outerHeight());
|
219
|
+
} else {
|
220
|
+
me.setHeight(me.$options.height);
|
221
|
+
}
|
222
|
+
},
|
223
|
+
_calculateBodyHeight: function (height) {
|
224
|
+
var me = this;
|
225
|
+
var headerHeight = me.$el.find('.lobibox-header').outerHeight();
|
226
|
+
var footerHeight = me.$el.find('.lobibox-footer').outerHeight();
|
227
|
+
return height - (headerHeight ? headerHeight : 0) - (footerHeight ? footerHeight : 0);
|
228
|
+
|
229
|
+
},
|
230
|
+
|
231
|
+
/**
|
232
|
+
* Add backdrop in case if backdrop does not exist
|
233
|
+
*
|
234
|
+
* @private
|
235
|
+
*/
|
236
|
+
_addBackdrop: function () {
|
237
|
+
if ($('.lobibox-backdrop').length === 0) {
|
238
|
+
$('body').append('<div class="lobibox-backdrop"></div>');
|
239
|
+
}
|
240
|
+
},
|
241
|
+
|
242
|
+
_triggerEvent: function (type) {
|
243
|
+
var me = this;
|
244
|
+
if (me.$options[type] && typeof me.$options[type] === 'function') {
|
245
|
+
me.$options[type](me);
|
246
|
+
}
|
247
|
+
},
|
248
|
+
|
249
|
+
_calculateWidth: function (width) {
|
250
|
+
var me = this;
|
251
|
+
width = Math.min(Math.max(width, me.$options.width), $(window).outerWidth());
|
252
|
+
if (width === $(window).outerWidth()) {
|
253
|
+
width -= 2 * me.$options.horizontalOffset;
|
254
|
+
}
|
255
|
+
return width;
|
256
|
+
},
|
257
|
+
|
258
|
+
_calculateHeight: function (height) {
|
259
|
+
var me = this;
|
260
|
+
console.log(me.$options.height);
|
261
|
+
height = Math.min(Math.max(height, me.$options.height), $(window).outerHeight());
|
262
|
+
if (height === $(window).outerHeight()) {
|
263
|
+
height -= 2 * me.$options.verticalOffset;
|
264
|
+
}
|
265
|
+
return height;
|
266
|
+
},
|
267
|
+
|
268
|
+
_addCloseButton: function () {
|
269
|
+
var me = this;
|
270
|
+
var closeBtn = $('<span class="btn-close">×</span>');
|
271
|
+
me.$el.find('.lobibox-header').append(closeBtn);
|
272
|
+
closeBtn.on('mousedown', function (ev) {
|
273
|
+
ev.stopPropagation();
|
274
|
+
});
|
275
|
+
closeBtn.on('click.lobibox', function () {
|
276
|
+
me.destroy();
|
277
|
+
});
|
278
|
+
},
|
279
|
+
_position: function () {
|
280
|
+
var me = this;
|
281
|
+
|
282
|
+
me._setSize();
|
283
|
+
var pos = me._calculatePosition();
|
284
|
+
me.setPosition(pos.left, pos.top);
|
285
|
+
},
|
286
|
+
_isMobileScreen: function () {
|
287
|
+
return $(window).outerWidth() < 768;
|
288
|
+
},
|
289
|
+
_enableDrag: function () {
|
290
|
+
var el = this.$el,
|
291
|
+
heading = el.find('.lobibox-header');
|
292
|
+
|
293
|
+
heading.on('mousedown.lobibox', function (ev) {
|
294
|
+
el.attr('offset-left', ev.offsetX);
|
295
|
+
el.attr('offset-top', ev.offsetY);
|
296
|
+
el.attr('allow-drag', 'true');
|
297
|
+
});
|
298
|
+
$(document).on('mouseup.lobibox', function () {
|
299
|
+
el.attr('allow-drag', 'false');
|
300
|
+
});
|
301
|
+
$(document).on('mousemove.lobibox', function (ev) {
|
302
|
+
if (el.attr('allow-drag') === 'true') {
|
303
|
+
var left = ev.clientX - parseInt(el.attr('offset-left'), 10) - parseInt(el.css('border-left-width'), 10);
|
304
|
+
var top = ev.clientY - parseInt(el.attr('offset-top'), 10) - parseInt(el.css('border-top-width'), 10);
|
305
|
+
el.css({
|
306
|
+
left: left,
|
307
|
+
top: top
|
308
|
+
});
|
309
|
+
}
|
310
|
+
});
|
311
|
+
},
|
312
|
+
|
313
|
+
/**
|
314
|
+
* Set the message of messagebox
|
315
|
+
*
|
316
|
+
* @param {string} msg "new message of messagebox"
|
317
|
+
* @returns {LobiboxBase}
|
318
|
+
* @private
|
319
|
+
*/
|
320
|
+
_setContent: function (msg) {
|
321
|
+
var me = this;
|
322
|
+
me.$el.find('.lobibox-body').html(msg);
|
323
|
+
return me;
|
324
|
+
},
|
325
|
+
|
326
|
+
_beforeShow: function () {
|
327
|
+
var me = this;
|
328
|
+
me._triggerEvent('onShow');
|
329
|
+
},
|
330
|
+
|
331
|
+
_afterShow: function () {
|
332
|
+
var me = this;
|
333
|
+
Lobibox.counter++;
|
334
|
+
me.$el.attr('data-nth', Lobibox.counter);
|
335
|
+
if (!me.$options.draggable){
|
336
|
+
$(window).on('resize.lobibox-'+me.$el.attr('data-nth'), function(){
|
337
|
+
me.refreshWidth();
|
338
|
+
me.refreshHeight();
|
339
|
+
me.$el.css('left', '50%').css('margin-left', '-'+(me.$el.width()/2)+'px');
|
340
|
+
me.$el.css('top', '50%').css('margin-top', '-'+(me.$el.height()/2)+'px');
|
341
|
+
});
|
342
|
+
}
|
343
|
+
|
344
|
+
me._triggerEvent('shown');
|
345
|
+
},
|
346
|
+
|
347
|
+
_beforeClose: function () {
|
348
|
+
var me = this;
|
349
|
+
me._triggerEvent('beforeClose');
|
350
|
+
},
|
351
|
+
|
352
|
+
_afterClose: function () {
|
353
|
+
var me = this;
|
354
|
+
if (!me.$options.draggable){
|
355
|
+
$(window).off('resize.lobibox-'+me.$el.attr('data-nth'));
|
356
|
+
}
|
357
|
+
me._triggerEvent('closed');
|
358
|
+
},
|
359
|
+
//------------------------------------------------------------------------------
|
360
|
+
//--------------------------PUBLIC METHODS--------------------------------------
|
361
|
+
//------------------------------------------------------------------------------
|
362
|
+
|
363
|
+
/**
|
364
|
+
* Hide the messagebox
|
365
|
+
*
|
366
|
+
* @returns {LobiboxBase}
|
367
|
+
*/
|
368
|
+
hide: function () {
|
369
|
+
var me = this;
|
370
|
+
if (me.$options.hideClass) {
|
371
|
+
me.$el.removeClass(me.$options.showClass);
|
372
|
+
me.$el.addClass(me.$options.hideClass);
|
373
|
+
setTimeout(function () {
|
374
|
+
callback();
|
375
|
+
}, me.$options.delayToRemove);
|
376
|
+
} else {
|
377
|
+
callback();
|
378
|
+
}
|
379
|
+
function callback() {
|
380
|
+
me.$el.addClass('lobibox-hidden');
|
381
|
+
if ($('.lobibox[data-is-modal=true]:not(.lobibox-hidden)').length === 0) {
|
382
|
+
$('.lobibox-backdrop').remove();
|
383
|
+
$('body').removeClass(Lobibox.base.OPTIONS.bodyClass);
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
return this;
|
388
|
+
},
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Removes the messagebox from document
|
392
|
+
*
|
393
|
+
* @returns {LobiboxBase}
|
394
|
+
*/
|
395
|
+
destroy: function () {
|
396
|
+
var me = this;
|
397
|
+
me._beforeClose();
|
398
|
+
if (me.$options.hideClass) {
|
399
|
+
me.$el.removeClass(me.$options.showClass).addClass(me.$options.hideClass);
|
400
|
+
setTimeout(function () {
|
401
|
+
callback();
|
402
|
+
}, me.$options.delayToRemove);
|
403
|
+
} else {
|
404
|
+
callback();
|
405
|
+
}
|
406
|
+
function callback() {
|
407
|
+
me.$el.remove();
|
408
|
+
if ($('.lobibox[data-is-modal=true]').length === 0) {
|
409
|
+
$('.lobibox-backdrop').remove();
|
410
|
+
$('body').removeClass(Lobibox.base.OPTIONS.bodyClass);
|
411
|
+
}
|
412
|
+
me._afterClose();
|
413
|
+
}
|
414
|
+
|
415
|
+
return this;
|
416
|
+
},
|
417
|
+
|
418
|
+
/**
|
419
|
+
* Set the width of messagebox
|
420
|
+
*
|
421
|
+
* @param {number} width "new width of messagebox"
|
422
|
+
* @returns {LobiboxBase}
|
423
|
+
*/
|
424
|
+
setWidth: function (width) {
|
425
|
+
var me = this;
|
426
|
+
me.$el.css('width', me._calculateWidth(width));
|
427
|
+
return me;
|
428
|
+
},
|
429
|
+
|
430
|
+
refreshWidth: function(){
|
431
|
+
this.setWidth(this.$el.width());
|
432
|
+
},
|
433
|
+
|
434
|
+
refreshHeight: function(){
|
435
|
+
this.setHeight(this.$el.height());
|
436
|
+
},
|
437
|
+
|
438
|
+
/**
|
439
|
+
* Set the height of messagebox
|
440
|
+
*
|
441
|
+
* @param {number} height "new height of messagebox"
|
442
|
+
* @returns {LobiboxBase}
|
443
|
+
*/
|
444
|
+
setHeight: function (height) {
|
445
|
+
var me = this;
|
446
|
+
me.$el.css('height', me._calculateHeight(height))
|
447
|
+
.find('.lobibox-body')
|
448
|
+
.css('height', me._calculateBodyHeight(me.$el.innerHeight()));
|
449
|
+
return me;
|
450
|
+
},
|
451
|
+
|
452
|
+
/**
|
453
|
+
* Set the width and height of messagebox
|
454
|
+
*
|
455
|
+
* @param {number} width "new width of messagebox"
|
456
|
+
* @param {number} height "new height of messagebox"
|
457
|
+
* @returns {LobiboxBase}
|
458
|
+
*/
|
459
|
+
setSize: function (width, height) {
|
460
|
+
var me = this;
|
461
|
+
me.setWidth(width);
|
462
|
+
me.setHeight(height);
|
463
|
+
return me;
|
464
|
+
},
|
465
|
+
|
466
|
+
/**
|
467
|
+
* Set position of messagebox
|
468
|
+
*
|
469
|
+
* @param {number|String} left "left coordinate of messsagebox or string representaing position. Available: ('top', 'center', 'bottom')"
|
470
|
+
* @param {number} top
|
471
|
+
* @returns {LobiboxBase}
|
472
|
+
*/
|
473
|
+
setPosition: function (left, top) {
|
474
|
+
var pos;
|
475
|
+
if (typeof left === 'number' && typeof top === 'number') {
|
476
|
+
pos = {
|
477
|
+
left: left,
|
478
|
+
top: top
|
479
|
+
};
|
480
|
+
} else if (typeof left === 'string') {
|
481
|
+
pos = this._calculatePosition(left);
|
482
|
+
}
|
483
|
+
this.$el.css(pos);
|
484
|
+
return this;
|
485
|
+
},
|
486
|
+
/**
|
487
|
+
* Set the title of messagebox
|
488
|
+
*
|
489
|
+
* @param {string} title "new title of messagebox"
|
490
|
+
* @returns {LobiboxBase}
|
491
|
+
*/
|
492
|
+
setTitle: function (title) {
|
493
|
+
return this.$el.find('.lobibox-title').html(title);
|
494
|
+
},
|
495
|
+
|
496
|
+
/**
|
497
|
+
* Get the title of messagebox
|
498
|
+
*
|
499
|
+
* @returns {string}
|
500
|
+
*/
|
501
|
+
getTitle: function () {
|
502
|
+
return this.$el.find('.lobibox-title').html();
|
503
|
+
},
|
504
|
+
|
505
|
+
/**
|
506
|
+
* Show messagebox
|
507
|
+
*
|
508
|
+
* @returns {LobiboxBase}
|
509
|
+
*/
|
510
|
+
show: function () {
|
511
|
+
var me = this,
|
512
|
+
$body = $('body');
|
513
|
+
|
514
|
+
me._beforeShow();
|
515
|
+
|
516
|
+
me.$el.removeClass('lobibox-hidden');
|
517
|
+
$body.append(me.$el);
|
518
|
+
if (me.$options.buttons) {
|
519
|
+
var buttons = me.$el.find('.lobibox-footer').children();
|
520
|
+
buttons[0].focus();
|
521
|
+
}
|
522
|
+
if (me.$options.modal) {
|
523
|
+
$body.addClass(Lobibox.base.OPTIONS.bodyClass);
|
524
|
+
me._addBackdrop();
|
525
|
+
}
|
526
|
+
if (me.$options.delay !== false) {
|
527
|
+
setTimeout(function () {
|
528
|
+
me.destroy();
|
529
|
+
}, me.$options.delay);
|
530
|
+
}
|
531
|
+
me._afterShow();
|
532
|
+
return me;
|
533
|
+
}
|
534
|
+
};
|
535
|
+
//User can set default options by this variable
|
536
|
+
Lobibox.base = {};
|
537
|
+
Lobibox.base.OPTIONS = {
|
538
|
+
bodyClass: 'lobibox-open',
|
539
|
+
|
540
|
+
modalClasses: {
|
541
|
+
'error': 'lobibox-error',
|
542
|
+
'success': 'lobibox-success',
|
543
|
+
'info': 'lobibox-info',
|
544
|
+
'warning': 'lobibox-warning',
|
545
|
+
'confirm': 'lobibox-confirm',
|
546
|
+
'progress': 'lobibox-progress',
|
547
|
+
'prompt': 'lobibox-prompt',
|
548
|
+
'default': 'lobibox-default',
|
549
|
+
'window': 'lobibox-window'
|
550
|
+
},
|
551
|
+
buttonsAlign: ['left', 'center', 'right'],
|
552
|
+
buttons: {
|
553
|
+
ok: {
|
554
|
+
'class': 'lobibox-btn lobibox-btn-default',
|
555
|
+
text: 'OK',
|
556
|
+
closeOnClick: true
|
557
|
+
},
|
558
|
+
cancel: {
|
559
|
+
'class': 'lobibox-btn lobibox-btn-cancel',
|
560
|
+
text: 'Cancel',
|
561
|
+
closeOnClick: true
|
562
|
+
},
|
563
|
+
yes: {
|
564
|
+
'class': 'lobibox-btn lobibox-btn-yes',
|
565
|
+
text: 'Yes',
|
566
|
+
closeOnClick: true
|
567
|
+
},
|
568
|
+
no: {
|
569
|
+
'class': 'lobibox-btn lobibox-btn-no',
|
570
|
+
text: 'No',
|
571
|
+
closeOnClick: true
|
572
|
+
}
|
573
|
+
},
|
574
|
+
icons: {
|
575
|
+
bootstrap: {
|
576
|
+
confirm: 'glyphicon glyphicon-question-sign',
|
577
|
+
success: 'glyphicon glyphicon-ok-sign',
|
578
|
+
error: 'glyphicon glyphicon-remove-sign',
|
579
|
+
warning: 'glyphicon glyphicon-exclamation-sign',
|
580
|
+
info: 'glyphicon glyphicon-info-sign'
|
581
|
+
},
|
582
|
+
fontAwesome: {
|
583
|
+
confirm: 'fa fa-question-circle',
|
584
|
+
success: 'fa fa-check-circle',
|
585
|
+
error: 'fa fa-times-circle',
|
586
|
+
warning: 'fa fa-exclamation-circle',
|
587
|
+
info: 'fa fa-info-circle'
|
588
|
+
}
|
589
|
+
}
|
590
|
+
};
|
591
|
+
Lobibox.base.DEFAULTS = {
|
592
|
+
horizontalOffset: 5, //If the messagebox is larger (in width) than window's width. The messagebox's width is reduced to window width - 2 * horizontalOffset
|
593
|
+
verticalOffset: 5, //If the messagebox is larger (in height) than window's height. The messagebox's height is reduced to window height - 2 * verticalOffset
|
594
|
+
width: 600,
|
595
|
+
height: 'auto', // Height is automatically calculated by width
|
596
|
+
closeButton: true, // Show close button or not
|
597
|
+
draggable: false, // Make messagebox draggable
|
598
|
+
customBtnClass: 'lobibox-btn lobibox-btn-default', // Class for custom buttons
|
599
|
+
modal: true,
|
600
|
+
debug: false,
|
601
|
+
buttonsAlign: 'center', // Position where buttons should be aligned
|
602
|
+
closeOnEsc: true, // Close messagebox on Esc press
|
603
|
+
delayToRemove: 200, // Time after which lobibox will be removed after remove call. (This option is for hide animation to finish)
|
604
|
+
delay: false, // Time to remove lobibox after shown
|
605
|
+
baseClass: 'animated-super-fast', // Base class to add all messageboxes
|
606
|
+
showClass: 'zoomIn', // Show animation class
|
607
|
+
hideClass: 'zoomOut', // Hide animation class
|
608
|
+
iconSource: 'bootstrap', // "bootstrap" or "fontAwesome" the library which will be used for icons
|
609
|
+
|
610
|
+
//events
|
611
|
+
//When messagebox show is called but before it is actually shown
|
612
|
+
onShow: null,
|
613
|
+
//After messagebox is shown
|
614
|
+
shown: null,
|
615
|
+
//When messagebox remove method is called but before it is actually hidden
|
616
|
+
beforeClose: null,
|
617
|
+
//After messagebox is hidden
|
618
|
+
closed: null
|
619
|
+
};
|
620
|
+
//------------------------------------------------------------------------------
|
621
|
+
//-------------------------LobiboxPrompt----------------------------------------
|
622
|
+
//------------------------------------------------------------------------------
|
623
|
+
function LobiboxPrompt(type, options) {
|
624
|
+
this.$input = null;
|
625
|
+
this.$type = 'prompt';
|
626
|
+
this.$promptType = type;
|
627
|
+
|
628
|
+
options = $.extend({}, Lobibox.prompt.DEFAULT_OPTIONS, options);
|
629
|
+
|
630
|
+
this.$options = this._processInput(options);
|
631
|
+
|
632
|
+
this._init();
|
633
|
+
this.debug(this);
|
634
|
+
}
|
635
|
+
|
636
|
+
LobiboxPrompt.prototype = $.extend({}, LobiboxBase, {
|
637
|
+
constructor: LobiboxPrompt,
|
638
|
+
|
639
|
+
_processInput: function (options) {
|
640
|
+
var me = this;
|
641
|
+
|
642
|
+
var mergedOptions = LobiboxBase._processInput.call(me, options);
|
643
|
+
mergedOptions.buttons = {
|
644
|
+
ok: Lobibox.base.OPTIONS.buttons.ok,
|
645
|
+
cancel: Lobibox.base.OPTIONS.buttons.cancel
|
646
|
+
};
|
647
|
+
options = $.extend({}, mergedOptions, LobiboxPrompt.DEFAULT_OPTIONS, options);
|
648
|
+
return options;
|
649
|
+
},
|
650
|
+
|
651
|
+
_init: function () {
|
652
|
+
var me = this;
|
653
|
+
LobiboxBase._init.call(me);
|
654
|
+
me.show();
|
655
|
+
},
|
656
|
+
|
657
|
+
_afterShow: function () {
|
658
|
+
var me = this;
|
659
|
+
me._setContent(me._createInput())._position();
|
660
|
+
me.$input.focus();
|
661
|
+
LobiboxBase._afterShow.call(me);
|
662
|
+
},
|
663
|
+
|
664
|
+
_createInput: function () {
|
665
|
+
var me = this,
|
666
|
+
label;
|
667
|
+
if (me.$options.multiline) {
|
668
|
+
me.$input = $('<textarea></textarea>').attr('rows', me.$options.lines);
|
669
|
+
} else {
|
670
|
+
me.$input = $('<input type="' + me.$promptType + '"/>');
|
671
|
+
}
|
672
|
+
me.$input.addClass('lobibox-input').attr(me.$options.attrs);
|
673
|
+
if (me.$options.value) {
|
674
|
+
me.setValue(me.$options.value);
|
675
|
+
}
|
676
|
+
if (me.$options.label) {
|
677
|
+
label = $('<label>' + me.$options.label + '</label>');
|
678
|
+
}
|
679
|
+
return $('<div></div>').append(label, me.$input);
|
680
|
+
},
|
681
|
+
|
682
|
+
/**
|
683
|
+
* Set value of input
|
684
|
+
*
|
685
|
+
* @param {string} val "value of input"
|
686
|
+
* @returns {LobiboxPrompt}
|
687
|
+
*/
|
688
|
+
setValue: function (val) {
|
689
|
+
this.$input.val(val);
|
690
|
+
return this;
|
691
|
+
},
|
692
|
+
|
693
|
+
/**
|
694
|
+
* Get value of input
|
695
|
+
*
|
696
|
+
* @returns {String}
|
697
|
+
*/
|
698
|
+
getValue: function () {
|
699
|
+
return this.$input.val();
|
700
|
+
},
|
701
|
+
|
702
|
+
isValid: function () {
|
703
|
+
var me = this,
|
704
|
+
$error = me.$el.find('.lobibox-input-error-message');
|
705
|
+
|
706
|
+
if (me.$options.required && !me.getValue()){
|
707
|
+
me.$input.addClass('invalid');
|
708
|
+
if ($error.length === 0){
|
709
|
+
me.$el.find('.lobibox-body').append('<p class="lobibox-input-error-message">'+me.$options.errorMessage+'</p>');
|
710
|
+
me._position();
|
711
|
+
me.$input.focus();
|
712
|
+
}
|
713
|
+
return false;
|
714
|
+
}
|
715
|
+
me.$input.removeClass('invalid');
|
716
|
+
$error.remove();
|
717
|
+
me._position();
|
718
|
+
me.$input.focus();
|
719
|
+
|
720
|
+
return true;
|
721
|
+
}
|
722
|
+
});
|
723
|
+
|
724
|
+
LobiboxPrompt.DEFAULT_OPTIONS = {
|
725
|
+
width: 400,
|
726
|
+
attrs: {}, // Object of any valid attribute of input field
|
727
|
+
value: '', // Value which is given to textfield when messagebox is created
|
728
|
+
multiline: false, // Set this true for multiline prompt
|
729
|
+
lines: 3, // This works only for multiline prompt. Number of lines
|
730
|
+
type: 'text', // Prompt type. Available types (text|number|color)
|
731
|
+
label: '', // Set some text which will be shown exactly on top of textfield
|
732
|
+
required: true,
|
733
|
+
errorMessage: 'The field is required'
|
734
|
+
};
|
735
|
+
//------------------------------------------------------------------------------
|
736
|
+
//-------------------------LobiboxConfirm---------------------------------------
|
737
|
+
//------------------------------------------------------------------------------
|
738
|
+
function LobiboxConfirm(options) {
|
739
|
+
this.$type = 'confirm';
|
740
|
+
|
741
|
+
// options = $.extend({}, Lobibox.confirm.DEFAULT_OPTIONS, options);
|
742
|
+
|
743
|
+
this.$options = this._processInput(options);
|
744
|
+
this._init();
|
745
|
+
this.debug(this);
|
746
|
+
}
|
747
|
+
|
748
|
+
LobiboxConfirm.prototype = $.extend({}, LobiboxBase, {
|
749
|
+
constructor: LobiboxConfirm,
|
750
|
+
|
751
|
+
_processInput: function (options) {
|
752
|
+
var me = this;
|
753
|
+
|
754
|
+
var mergedOptions = LobiboxBase._processInput.call(me, options);
|
755
|
+
mergedOptions.buttons = {
|
756
|
+
yes: Lobibox.base.OPTIONS.buttons.yes,
|
757
|
+
no: Lobibox.base.OPTIONS.buttons.no
|
758
|
+
};
|
759
|
+
options = $.extend({}, mergedOptions, Lobibox.confirm.DEFAULTS, options);
|
760
|
+
return options;
|
761
|
+
},
|
762
|
+
|
763
|
+
_init: function () {
|
764
|
+
var me = this;
|
765
|
+
|
766
|
+
LobiboxBase._init.call(me);
|
767
|
+
me.show();
|
768
|
+
},
|
769
|
+
|
770
|
+
_afterShow: function () {
|
771
|
+
var me = this;
|
772
|
+
|
773
|
+
var d = $('<div></div>');
|
774
|
+
if (me.$options.iconClass) {
|
775
|
+
d.append($('<div class="lobibox-icon-wrapper"></div>')
|
776
|
+
.append('<i class="lobibox-icon ' + me.$options.iconClass + '"></i>'))
|
777
|
+
;
|
778
|
+
}
|
779
|
+
d.append('<div class="lobibox-body-text-wrapper"><span class="lobibox-body-text">' + me.$options.msg + '</span></div>');
|
780
|
+
me._setContent(d.html());
|
781
|
+
|
782
|
+
me._position();
|
783
|
+
|
784
|
+
LobiboxBase._afterShow.call(me);
|
785
|
+
}
|
786
|
+
});
|
787
|
+
|
788
|
+
Lobibox.confirm.DEFAULTS = {
|
789
|
+
title: 'Question',
|
790
|
+
width: 500
|
791
|
+
};
|
792
|
+
//------------------------------------------------------------------------------
|
793
|
+
//-------------------------LobiboxAlert------------------------------------------
|
794
|
+
//------------------------------------------------------------------------------
|
795
|
+
function LobiboxAlert(type, options) {
|
796
|
+
this.$type = type;
|
797
|
+
|
798
|
+
// options = $.extend({}, Lobibox.alert.DEFAULT_OPTIONS, Lobibox[type].DEFAULT_OPTIONS, options);
|
799
|
+
|
800
|
+
this.$options = this._processInput(options);
|
801
|
+
|
802
|
+
this._init();
|
803
|
+
this.debug(this);
|
804
|
+
}
|
805
|
+
|
806
|
+
LobiboxAlert.prototype = $.extend({}, LobiboxBase, {
|
807
|
+
constructor: LobiboxAlert,
|
808
|
+
|
809
|
+
_processInput: function (options) {
|
810
|
+
|
811
|
+
// ALERT_OPTIONS = $.extend({}, LobiboxAlert.OPTIONS, Lobibox.alert.DEFAULTS);
|
812
|
+
var me = this;
|
813
|
+
var mergedOptions = LobiboxBase._processInput.call(me, options);
|
814
|
+
mergedOptions.buttons = {
|
815
|
+
ok: Lobibox.base.OPTIONS.buttons.ok
|
816
|
+
};
|
817
|
+
|
818
|
+
options = $.extend({}, mergedOptions, Lobibox.alert.OPTIONS[me.$type], Lobibox.alert.DEFAULTS, options);
|
819
|
+
|
820
|
+
return options;
|
821
|
+
},
|
822
|
+
|
823
|
+
_init: function () {
|
824
|
+
var me = this;
|
825
|
+
LobiboxBase._init.call(me);
|
826
|
+
me.show();
|
827
|
+
},
|
828
|
+
|
829
|
+
_afterShow: function () {
|
830
|
+
var me = this;
|
831
|
+
|
832
|
+
var d = $('<div></div>');
|
833
|
+
if (me.$options.iconClass) {
|
834
|
+
d.append($('<div class="lobibox-icon-wrapper"></div>')
|
835
|
+
.append('<i class="lobibox-icon ' + me.$options.iconClass + '"></i>'))
|
836
|
+
;
|
837
|
+
}
|
838
|
+
d.append('<div class="lobibox-body-text-wrapper"><span class="lobibox-body-text">' + me.$options.msg + '</span></div>');
|
839
|
+
me._setContent(d.html());
|
840
|
+
me._position();
|
841
|
+
|
842
|
+
LobiboxBase._afterShow.call(me);
|
843
|
+
}
|
844
|
+
});
|
845
|
+
Lobibox.alert.OPTIONS = {
|
846
|
+
warning: {
|
847
|
+
title: 'Warning'
|
848
|
+
},
|
849
|
+
info: {
|
850
|
+
title: 'Information'
|
851
|
+
},
|
852
|
+
success: {
|
853
|
+
title: 'Success'
|
854
|
+
},
|
855
|
+
error: {
|
856
|
+
title: 'Error'
|
857
|
+
}
|
858
|
+
};
|
859
|
+
//User can set default options by this variable
|
860
|
+
Lobibox.alert.DEFAULTS = {};
|
861
|
+
//------------------------------------------------------------------------------
|
862
|
+
//-------------------------LobiboxProgress--------------------------------------
|
863
|
+
//------------------------------------------------------------------------------
|
864
|
+
function LobiboxProgress(options) {
|
865
|
+
this.$type = 'progress';
|
866
|
+
this.$progressBarElement = null;
|
867
|
+
this.$options = this._processInput(options);
|
868
|
+
this.$progress = 0;
|
869
|
+
|
870
|
+
this._init();
|
871
|
+
this.debug(this);
|
872
|
+
}
|
873
|
+
|
874
|
+
LobiboxProgress.prototype = $.extend({}, LobiboxBase, {
|
875
|
+
constructor: LobiboxProgress,
|
876
|
+
|
877
|
+
_processInput: function (options) {
|
878
|
+
var me = this;
|
879
|
+
var mergedOptions = LobiboxBase._processInput.call(me, options);
|
880
|
+
|
881
|
+
options = $.extend({}, mergedOptions, Lobibox.progress.DEFAULTS, options);
|
882
|
+
return options;
|
883
|
+
},
|
884
|
+
|
885
|
+
_init: function () {
|
886
|
+
var me = this;
|
887
|
+
|
888
|
+
LobiboxBase._init.call(me);
|
889
|
+
me.show();
|
890
|
+
},
|
891
|
+
|
892
|
+
_afterShow: function () {
|
893
|
+
var me = this;
|
894
|
+
|
895
|
+
if (me.$options.progressTpl) {
|
896
|
+
me.$progressBarElement = $(me.$options.progressTpl);
|
897
|
+
} else {
|
898
|
+
me.$progressBarElement = me._createProgressbar();
|
899
|
+
}
|
900
|
+
var label;
|
901
|
+
if (me.$options.label) {
|
902
|
+
label = $('<label>' + me.$options.label + '</label>');
|
903
|
+
}
|
904
|
+
var innerHTML = $('<div></div>').append(label, me.$progressBarElement);
|
905
|
+
me._setContent(innerHTML);
|
906
|
+
me._position();
|
907
|
+
|
908
|
+
LobiboxBase._afterShow.call(me);
|
909
|
+
},
|
910
|
+
|
911
|
+
_createProgressbar: function () {
|
912
|
+
var me = this;
|
913
|
+
var outer = $('<div class="lobibox-progress-bar-wrapper lobibox-progress-outer"></div>')
|
914
|
+
.append('<div class="lobibox-progress-bar lobibox-progress-element"></div>')
|
915
|
+
;
|
916
|
+
if (me.$options.showProgressLabel) {
|
917
|
+
outer.append('<span class="lobibox-progress-text" data-role="progress-text"></span>');
|
918
|
+
}
|
919
|
+
|
920
|
+
return outer;
|
921
|
+
},
|
922
|
+
|
923
|
+
/**
|
924
|
+
* Set progress value
|
925
|
+
*
|
926
|
+
* @param {number} progress "progress value"
|
927
|
+
* @returns {LobiboxProgress}
|
928
|
+
*/
|
929
|
+
setProgress: function (progress) {
|
930
|
+
var me = this;
|
931
|
+
if (me.$progress === 100) {
|
932
|
+
return;
|
933
|
+
}
|
934
|
+
progress = Math.min(100, Math.max(0, progress));
|
935
|
+
me.$progress = progress;
|
936
|
+
me._triggerEvent('progressUpdated');
|
937
|
+
if (me.$progress === 100) {
|
938
|
+
me._triggerEvent('progressCompleted');
|
939
|
+
}
|
940
|
+
me.$el.find('.lobibox-progress-element').css('width', progress.toFixed(1) + "%");
|
941
|
+
me.$el.find('[data-role="progress-text"]').html(progress.toFixed(1) + "%");
|
942
|
+
return me;
|
943
|
+
},
|
944
|
+
|
945
|
+
/**
|
946
|
+
* Get progress value
|
947
|
+
*
|
948
|
+
* @returns {number}
|
949
|
+
*/
|
950
|
+
getProgress: function () {
|
951
|
+
return this.$progress;
|
952
|
+
}
|
953
|
+
});
|
954
|
+
|
955
|
+
Lobibox.progress.DEFAULTS = {
|
956
|
+
width: 500,
|
957
|
+
showProgressLabel: true, // Show percentage of progress
|
958
|
+
label: '', // Show progress label
|
959
|
+
progressTpl: false, //Template of progress bar
|
960
|
+
|
961
|
+
//Events
|
962
|
+
progressUpdated: null,
|
963
|
+
progressCompleted: null
|
964
|
+
};
|
965
|
+
//------------------------------------------------------------------------------
|
966
|
+
//-------------------------LobiboxWindow----------------------------------------
|
967
|
+
//------------------------------------------------------------------------------
|
968
|
+
function LobiboxWindow(type, options) {
|
969
|
+
this.$type = type;
|
970
|
+
|
971
|
+
this.$options = this._processInput(options);
|
972
|
+
|
973
|
+
this._init();
|
974
|
+
this.debug(this);
|
975
|
+
}
|
976
|
+
|
977
|
+
LobiboxWindow.prototype = $.extend({}, LobiboxBase, {
|
978
|
+
constructor: LobiboxWindow,
|
979
|
+
_processInput: function (options) {
|
980
|
+
var me = this;
|
981
|
+
var mergedOptions = LobiboxBase._processInput.call(me, options);
|
982
|
+
|
983
|
+
if (options.content && typeof options.content === 'function') {
|
984
|
+
options.content = options.content();
|
985
|
+
}
|
986
|
+
if (options.content instanceof jQuery) {
|
987
|
+
options.content = options.content.clone();
|
988
|
+
}
|
989
|
+
options = $.extend({}, mergedOptions, Lobibox.window.DEFAULTS, options);
|
990
|
+
return options;
|
991
|
+
},
|
992
|
+
|
993
|
+
_init: function () {
|
994
|
+
var me = this;
|
995
|
+
|
996
|
+
LobiboxBase._init.call(me);
|
997
|
+
me.setContent(me.$options.content);
|
998
|
+
if (me.$options.url && me.$options.autoload) {
|
999
|
+
if (!me.$options.showAfterLoad) {
|
1000
|
+
me.show();
|
1001
|
+
}
|
1002
|
+
me.load(function () {
|
1003
|
+
if (me.$options.showAfterLoad) {
|
1004
|
+
me.show();
|
1005
|
+
}
|
1006
|
+
});
|
1007
|
+
} else {
|
1008
|
+
me.show();
|
1009
|
+
}
|
1010
|
+
},
|
1011
|
+
|
1012
|
+
_afterShow: function () {
|
1013
|
+
var me = this;
|
1014
|
+
|
1015
|
+
me._position();
|
1016
|
+
|
1017
|
+
LobiboxBase._afterShow.call(me);
|
1018
|
+
},
|
1019
|
+
|
1020
|
+
/**
|
1021
|
+
* Setter method for <code>params</code> option
|
1022
|
+
*
|
1023
|
+
* @param {object} params "new params"
|
1024
|
+
* @returns {LobiboxWindow}
|
1025
|
+
*/
|
1026
|
+
setParams: function (params) {
|
1027
|
+
var me = this;
|
1028
|
+
me.$options.params = params;
|
1029
|
+
return me;
|
1030
|
+
},
|
1031
|
+
/**
|
1032
|
+
* Getter method for <code>params</code>
|
1033
|
+
*
|
1034
|
+
* @returns {object}
|
1035
|
+
*/
|
1036
|
+
getParams: function () {
|
1037
|
+
var me = this;
|
1038
|
+
return me.$options.params;
|
1039
|
+
},
|
1040
|
+
/**
|
1041
|
+
* Setter method of <code>loadMethod</code> option
|
1042
|
+
*
|
1043
|
+
* @param {string} method "new method"
|
1044
|
+
* @returns {LobiboxWindow}
|
1045
|
+
*/
|
1046
|
+
setLoadMethod: function (method) {
|
1047
|
+
var me = this;
|
1048
|
+
me.$options.loadMethod = method;
|
1049
|
+
return me;
|
1050
|
+
},
|
1051
|
+
/**
|
1052
|
+
* Getter method for <code>loadMethod</code> option
|
1053
|
+
*
|
1054
|
+
* @returns {string}
|
1055
|
+
*/
|
1056
|
+
getLoadMethod: function () {
|
1057
|
+
var me = this;
|
1058
|
+
return me.$options.loadMethod;
|
1059
|
+
},
|
1060
|
+
/**
|
1061
|
+
* Setter method of <code>content</code> option.
|
1062
|
+
* Change the content of window
|
1063
|
+
*
|
1064
|
+
* @param {string} content "new content"
|
1065
|
+
* @returns {LobiboxWindow}
|
1066
|
+
*/
|
1067
|
+
setContent: function (content) {
|
1068
|
+
var me = this;
|
1069
|
+
me.$options.content = content;
|
1070
|
+
me.$el.find('.lobibox-body').html('').append(content);
|
1071
|
+
return me;
|
1072
|
+
},
|
1073
|
+
/**
|
1074
|
+
* Getter method of <code>content</code> option
|
1075
|
+
*
|
1076
|
+
* @returns {string}
|
1077
|
+
*/
|
1078
|
+
getContent: function () {
|
1079
|
+
var me = this;
|
1080
|
+
return me.$options.content;
|
1081
|
+
},
|
1082
|
+
/**
|
1083
|
+
* Setter method of <code>url</code> option
|
1084
|
+
*
|
1085
|
+
* @param {string} url "new url"
|
1086
|
+
* @returns {LobiboxWindow}
|
1087
|
+
*/
|
1088
|
+
setUrl: function (url) {
|
1089
|
+
this.$options.url = url;
|
1090
|
+
return this;
|
1091
|
+
},
|
1092
|
+
/**
|
1093
|
+
* Getter method of <code>url</code> option
|
1094
|
+
*
|
1095
|
+
* @returns {String}
|
1096
|
+
*/
|
1097
|
+
getUrl: function () {
|
1098
|
+
return this.$options.url;
|
1099
|
+
},
|
1100
|
+
/**
|
1101
|
+
* Loads content to window by ajax from specific url
|
1102
|
+
*
|
1103
|
+
* @param {Function} callback "callback function"
|
1104
|
+
* @returns {LobiboxWindow}
|
1105
|
+
*/
|
1106
|
+
load: function (callback) {
|
1107
|
+
var me = this;
|
1108
|
+
if (!me.$options.url) {
|
1109
|
+
return me;
|
1110
|
+
}
|
1111
|
+
$.ajax(me.$options.url, {
|
1112
|
+
method: me.$options.loadMethod,
|
1113
|
+
data: me.$options.params
|
1114
|
+
}).done(function (res) {
|
1115
|
+
me.setContent(res);
|
1116
|
+
if (callback && typeof callback === 'function') {
|
1117
|
+
callback(res);
|
1118
|
+
}
|
1119
|
+
});
|
1120
|
+
return me;
|
1121
|
+
}
|
1122
|
+
});
|
1123
|
+
|
1124
|
+
Lobibox.window.DEFAULTS = {
|
1125
|
+
width: 480,
|
1126
|
+
height: 600,
|
1127
|
+
content: '', // HTML Content of window
|
1128
|
+
url: '', // URL which will be used to load content
|
1129
|
+
draggable: true, // Override default option
|
1130
|
+
autoload: true, // Auto load from given url when window is created
|
1131
|
+
loadMethod: 'GET', // Ajax method to load content
|
1132
|
+
showAfterLoad: true, // Show window after content is loaded or show and then load content
|
1133
|
+
params: {} // Parameters which will be send by ajax for loading content
|
1134
|
+
};
|
1135
|
+
|
1136
|
+
})();
|
1137
|
+
|
1138
|
+
//Author : @arboshiki
|
1139
|
+
/**
|
1140
|
+
* Generates random string of n length.
|
1141
|
+
* String contains only letters and numbers
|
1142
|
+
*
|
1143
|
+
* @param {int} n
|
1144
|
+
* @returns {String}
|
1145
|
+
*/
|
1146
|
+
Math.randomString = function (n) {
|
1147
|
+
var text = "";
|
1148
|
+
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
1149
|
+
|
1150
|
+
for (var i = 0; i < n; i++)
|
1151
|
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
1152
|
+
|
1153
|
+
return text;
|
1154
|
+
};
|
1155
|
+
var Lobibox = Lobibox || {};
|
1156
|
+
(function () {
|
1157
|
+
|
1158
|
+
var LobiboxNotify = function (type, options) {
|
1159
|
+
//------------------------------------------------------------------------------
|
1160
|
+
//----------------PROTOTYPE VARIABLES-------------------------------------------
|
1161
|
+
//------------------------------------------------------------------------------
|
1162
|
+
this.$type = null;
|
1163
|
+
this.$options = null;
|
1164
|
+
this.$el = null;
|
1165
|
+
//------------------------------------------------------------------------------
|
1166
|
+
//-----------------PRIVATE VARIABLES--------------------------------------------
|
1167
|
+
//------------------------------------------------------------------------------
|
1168
|
+
var me = this;
|
1169
|
+
//------------------------------------------------------------------------------
|
1170
|
+
//-----------------PRIVATE FUNCTIONS--------------------------------------------
|
1171
|
+
//------------------------------------------------------------------------------
|
1172
|
+
var _processInput = function (options) {
|
1173
|
+
|
1174
|
+
if (options.size === 'mini' || options.size === 'large') {
|
1175
|
+
options = $.extend({}, Lobibox.notify.OPTIONS[options.size], options);
|
1176
|
+
}
|
1177
|
+
options = $.extend({}, Lobibox.notify.OPTIONS[me.$type], Lobibox.notify.DEFAULTS, options);
|
1178
|
+
|
1179
|
+
if (options.size !== 'mini' && options.title === true) {
|
1180
|
+
options.title = Lobibox.notify.OPTIONS[me.$type].title;
|
1181
|
+
} else if (options.size === 'mini' && options.title === true) {
|
1182
|
+
options.title = false;
|
1183
|
+
}
|
1184
|
+
if (options.icon === true) {
|
1185
|
+
options.icon = Lobibox.notify.OPTIONS.icons[options.iconSource][me.$type];
|
1186
|
+
}
|
1187
|
+
if (options.sound === true) {
|
1188
|
+
options.sound = Lobibox.notify.OPTIONS[me.$type].sound;
|
1189
|
+
}
|
1190
|
+
if (options.sound) {
|
1191
|
+
options.sound = options.soundPath + options.sound + options.soundExt;
|
1192
|
+
}
|
1193
|
+
return options;
|
1194
|
+
};
|
1195
|
+
|
1196
|
+
var _appendInWrapper = function ($el, $wrapper) {
|
1197
|
+
if (me.$options.size === 'normal') {
|
1198
|
+
if ($wrapper.hasClass('bottom')) {
|
1199
|
+
$wrapper.prepend($el);
|
1200
|
+
} else {
|
1201
|
+
$wrapper.append($el);
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
} else if (me.$options.size === 'mini') {
|
1205
|
+
if ($wrapper.hasClass('bottom')) {
|
1206
|
+
$wrapper.prepend($el);
|
1207
|
+
} else {
|
1208
|
+
$wrapper.append($el);
|
1209
|
+
}
|
1210
|
+
} else if (me.$options.size === 'large') {
|
1211
|
+
var tabPane = _createTabPane().append($el);
|
1212
|
+
var $li = _createTabControl(tabPane.attr('id'));
|
1213
|
+
$wrapper.find('.lb-notify-wrapper').append(tabPane);
|
1214
|
+
$wrapper.find('.lb-notify-tabs').append($li);
|
1215
|
+
_activateTab($li);
|
1216
|
+
$li.find('>a').click(function () {
|
1217
|
+
_activateTab($li);
|
1218
|
+
});
|
1219
|
+
}
|
1220
|
+
};
|
1221
|
+
var _activateTab = function ($li) {
|
1222
|
+
$li.closest('.lb-notify-tabs').find('>li').removeClass('active');
|
1223
|
+
$li.addClass('active');
|
1224
|
+
var $current = $($li.find('>a').attr('href'));
|
1225
|
+
$current.closest('.lb-notify-wrapper').find('>.lb-tab-pane').removeClass('active');
|
1226
|
+
$current.addClass('active')
|
1227
|
+
};
|
1228
|
+
var _createTabControl = function (tabPaneId) {
|
1229
|
+
var $li = $('<li></li>', {
|
1230
|
+
'class': Lobibox.notify.OPTIONS[me.$type]['class']
|
1231
|
+
});
|
1232
|
+
$('<a></a>', {
|
1233
|
+
'href': '#' + tabPaneId
|
1234
|
+
}).append('<i class="tab-control-icon ' + me.$options.icon + '"></i>')
|
1235
|
+
.appendTo($li);
|
1236
|
+
return $li;
|
1237
|
+
};
|
1238
|
+
var _createTabPane = function () {
|
1239
|
+
return $('<div></div>', {
|
1240
|
+
'class': 'lb-tab-pane',
|
1241
|
+
'id': Math.randomString(10)
|
1242
|
+
})
|
1243
|
+
};
|
1244
|
+
var _createNotifyWrapper = function () {
|
1245
|
+
var selector = (me.$options.size === 'large' ? '.lobibox-notify-wrapper-large' : '.lobibox-notify-wrapper')
|
1246
|
+
+ "." + me.$options.position.replace(/\s/gi, '.'),
|
1247
|
+
$wrapper;
|
1248
|
+
|
1249
|
+
//var classes = me.$options.position.split(" ");
|
1250
|
+
$wrapper = $(selector);
|
1251
|
+
if ($wrapper.length === 0) {
|
1252
|
+
$wrapper = $('<div></div>')
|
1253
|
+
.addClass(selector.replace(/\./g, ' ').trim())
|
1254
|
+
.appendTo($('body'));
|
1255
|
+
if (me.$options.size === 'large') {
|
1256
|
+
$wrapper.append($('<ul class="lb-notify-tabs"></ul>'))
|
1257
|
+
.append($('<div class="lb-notify-wrapper"></div>'));
|
1258
|
+
}
|
1259
|
+
}
|
1260
|
+
return $wrapper;
|
1261
|
+
};
|
1262
|
+
var _createNotify = function () {
|
1263
|
+
var OPTS = Lobibox.notify.OPTIONS,
|
1264
|
+
$iconEl,
|
1265
|
+
$innerIconEl,
|
1266
|
+
$iconWrapper,
|
1267
|
+
$body,
|
1268
|
+
$msg,
|
1269
|
+
$notify = $('<div></div>', {
|
1270
|
+
'class': 'lobibox-notify ' + OPTS[me.$type]['class'] + ' ' + OPTS['class'] + ' ' + me.$options.showClass
|
1271
|
+
});
|
1272
|
+
|
1273
|
+
$iconWrapper = $('<div class="lobibox-notify-icon-wrapper"></div>').appendTo($notify);
|
1274
|
+
$iconEl = $('<div class="lobibox-notify-icon"></div>').appendTo($iconWrapper);
|
1275
|
+
$innerIconEl = $('<div></div>').appendTo($iconEl);
|
1276
|
+
|
1277
|
+
// Add image or icon depending on given parameters
|
1278
|
+
if (me.$options.img) {
|
1279
|
+
$innerIconEl.append('<img src="' + me.$options.img + '"/>');
|
1280
|
+
} else if (me.$options.icon) {
|
1281
|
+
$innerIconEl.append('<div class="icon-el"><i class="' + me.$options.icon + '"></i></div>');
|
1282
|
+
} else {
|
1283
|
+
$notify.addClass('without-icon');
|
1284
|
+
}
|
1285
|
+
// Create body, append title and message in body and append body in notification
|
1286
|
+
$msg = $('<div class="lobibox-notify-msg">' + me.$options.msg + '</div>');
|
1287
|
+
|
1288
|
+
if (me.$options.messageHeight !== false) {
|
1289
|
+
$msg.css('max-height', me.$options.messageHeight);
|
1290
|
+
}
|
1291
|
+
|
1292
|
+
$body = $('<div></div>', {
|
1293
|
+
'class': 'lobibox-notify-body'
|
1294
|
+
}).append($msg).appendTo($notify);
|
1295
|
+
|
1296
|
+
if (me.$options.title) {
|
1297
|
+
$body.prepend('<div class="lobibox-notify-title">' + me.$options.title + '<div>');
|
1298
|
+
}
|
1299
|
+
_addCloseButton($notify);
|
1300
|
+
if (me.$options.size === 'normal' || me.$options.size === 'mini') {
|
1301
|
+
_addCloseOnClick($notify);
|
1302
|
+
_addDelay($notify);
|
1303
|
+
}
|
1304
|
+
|
1305
|
+
// Give width to notification
|
1306
|
+
if (me.$options.width) {
|
1307
|
+
$notify.css('width', _calculateWidth(me.$options.width));
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
return $notify;
|
1311
|
+
};
|
1312
|
+
var _addCloseButton = function ($el) {
|
1313
|
+
if (!me.$options.closable) {
|
1314
|
+
return;
|
1315
|
+
}
|
1316
|
+
$('<span class="lobibox-close">×</span>').click(function () {
|
1317
|
+
me.remove();
|
1318
|
+
}).appendTo($el);
|
1319
|
+
};
|
1320
|
+
var _addCloseOnClick = function ($el) {
|
1321
|
+
if (!me.$options.closeOnClick) {
|
1322
|
+
return;
|
1323
|
+
}
|
1324
|
+
$el.click(function () {
|
1325
|
+
me.remove();
|
1326
|
+
});
|
1327
|
+
};
|
1328
|
+
var _addDelay = function ($el) {
|
1329
|
+
if (!me.$options.delay) {
|
1330
|
+
return;
|
1331
|
+
}
|
1332
|
+
if (me.$options.delayIndicator) {
|
1333
|
+
var delay = $('<div class="lobibox-delay-indicator"><div></div></div>');
|
1334
|
+
$el.append(delay);
|
1335
|
+
}
|
1336
|
+
var time = 0;
|
1337
|
+
var interval = 1000 / 30;
|
1338
|
+
var currentTime = new Date().getTime();
|
1339
|
+
var timer = setInterval(function () {
|
1340
|
+
if (me.$options.continueDelayOnInactiveTab){
|
1341
|
+
time = new Date().getTime() - currentTime;
|
1342
|
+
} else {
|
1343
|
+
time += interval;
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
var width = 100 * time / me.$options.delay;
|
1347
|
+
if (width >= 100) {
|
1348
|
+
width = 100;
|
1349
|
+
me.remove();
|
1350
|
+
timer = clearInterval(timer);
|
1351
|
+
}
|
1352
|
+
if (me.$options.delayIndicator) {
|
1353
|
+
delay.find('div').css('width', width + "%");
|
1354
|
+
}
|
1355
|
+
|
1356
|
+
}, interval);
|
1357
|
+
|
1358
|
+
if (me.$options.pauseDelayOnHover) {
|
1359
|
+
$el.on('mouseenter.lobibox', function () {
|
1360
|
+
interval = 0;
|
1361
|
+
}).on('mouseleave.lobibox', function () {
|
1362
|
+
interval = 1000 / 30;
|
1363
|
+
});
|
1364
|
+
}
|
1365
|
+
};
|
1366
|
+
var _findTabToActivate = function ($li) {
|
1367
|
+
var $itemToActivate = $li.prev();
|
1368
|
+
if ($itemToActivate.length === 0) {
|
1369
|
+
$itemToActivate = $li.next();
|
1370
|
+
}
|
1371
|
+
if ($itemToActivate.length === 0) {
|
1372
|
+
return null;
|
1373
|
+
}
|
1374
|
+
return $itemToActivate;
|
1375
|
+
};
|
1376
|
+
var _calculateWidth = function (width) {
|
1377
|
+
width = Math.min($(window).outerWidth(), width);
|
1378
|
+
return width;
|
1379
|
+
};
|
1380
|
+
//------------------------------------------------------------------------------
|
1381
|
+
//----------------PROTOTYPE FUNCTIONS-------------------------------------------
|
1382
|
+
//------------------------------------------------------------------------------
|
1383
|
+
/**
|
1384
|
+
* Delete the notification
|
1385
|
+
*
|
1386
|
+
* @returns {LobiboxNotify}
|
1387
|
+
*/
|
1388
|
+
this.remove = function () {
|
1389
|
+
me.$el.removeClass(me.$options.showClass)
|
1390
|
+
.addClass(me.$options.hideClass);
|
1391
|
+
var parent = me.$el.parent();
|
1392
|
+
var wrapper = parent.closest('.lobibox-notify-wrapper-large');
|
1393
|
+
|
1394
|
+
var href = '#' + parent.attr('id');
|
1395
|
+
|
1396
|
+
var $li = wrapper.find('>.lb-notify-tabs>li:has(a[href="' + href + '"])');
|
1397
|
+
$li.addClass(Lobibox.notify.OPTIONS['class'])
|
1398
|
+
.addClass(me.$options.hideClass);
|
1399
|
+
setTimeout(function () {
|
1400
|
+
if (me.$options.size === 'normal' || me.$options.size === 'mini') {
|
1401
|
+
me.$el.remove();
|
1402
|
+
} else if (me.$options.size === 'large') {
|
1403
|
+
|
1404
|
+
var $newLi = _findTabToActivate($li);
|
1405
|
+
if ($newLi) {
|
1406
|
+
_activateTab($newLi);
|
1407
|
+
}
|
1408
|
+
$li.remove();
|
1409
|
+
parent.remove();
|
1410
|
+
}
|
1411
|
+
var list = Lobibox.notify.list;
|
1412
|
+
var ind = list.indexOf(me);
|
1413
|
+
list.splice(ind, 1);
|
1414
|
+
var next = list[ind];
|
1415
|
+
if (next && next.$options.showAfterPrevious){
|
1416
|
+
next._init();
|
1417
|
+
}
|
1418
|
+
}, 500);
|
1419
|
+
return me;
|
1420
|
+
};
|
1421
|
+
me._init = function () {
|
1422
|
+
// Create notification
|
1423
|
+
var $notify = _createNotify();
|
1424
|
+
if (me.$options.size === 'mini') {
|
1425
|
+
$notify.addClass('notify-mini');
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
if (typeof me.$options.position === 'string') {
|
1429
|
+
var $wrapper = _createNotifyWrapper();
|
1430
|
+
_appendInWrapper($notify, $wrapper);
|
1431
|
+
if ($wrapper.hasClass('center')) {
|
1432
|
+
$wrapper.css('margin-left', '-' + ($wrapper.width() / 2) + "px");
|
1433
|
+
}
|
1434
|
+
} else {
|
1435
|
+
$('body').append($notify);
|
1436
|
+
$notify.css({
|
1437
|
+
'position': 'fixed',
|
1438
|
+
left: me.$options.position.left,
|
1439
|
+
top: me.$options.position.top
|
1440
|
+
})
|
1441
|
+
}
|
1442
|
+
|
1443
|
+
me.$el = $notify;
|
1444
|
+
if (me.$options.sound) {
|
1445
|
+
var snd = new Audio(me.$options.sound); // buffers automatically when created
|
1446
|
+
snd.play();
|
1447
|
+
}
|
1448
|
+
if (me.$options.rounded) {
|
1449
|
+
me.$el.addClass('rounded');
|
1450
|
+
}
|
1451
|
+
me.$el.on('click.lobibox', function(ev){
|
1452
|
+
if (me.$options.onClickUrl){
|
1453
|
+
window.location.href = me.$options.onClickUrl;
|
1454
|
+
}
|
1455
|
+
if (me.$options.onClick && typeof me.$options.onClick === 'function'){
|
1456
|
+
me.$options.onClick.call(me, ev);
|
1457
|
+
}
|
1458
|
+
});
|
1459
|
+
me.$el.data('lobibox', me);
|
1460
|
+
};
|
1461
|
+
//------------------------------------------------------------------------------
|
1462
|
+
//------------------------------------------------------------------------------
|
1463
|
+
//------------------------------------------------------------------------------
|
1464
|
+
this.$type = type;
|
1465
|
+
this.$options = _processInput(options);
|
1466
|
+
if (!me.$options.showAfterPrevious || Lobibox.notify.list.length === 0){
|
1467
|
+
this._init();
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
};
|
1471
|
+
|
1472
|
+
Lobibox.notify = function (type, options) {
|
1473
|
+
if (["default", "info", "warning", "error", "success"].indexOf(type) > -1) {
|
1474
|
+
var lobibox = new LobiboxNotify(type, options);
|
1475
|
+
Lobibox.notify.list.push(lobibox);
|
1476
|
+
return lobibox;
|
1477
|
+
}
|
1478
|
+
};
|
1479
|
+
Lobibox.notify.list = [];
|
1480
|
+
Lobibox.notify.closeAll = function () {
|
1481
|
+
var list = Lobibox.notify.list;
|
1482
|
+
for (var i in list){
|
1483
|
+
list[i].remove();
|
1484
|
+
}
|
1485
|
+
};
|
1486
|
+
//User can set default options to this variable
|
1487
|
+
Lobibox.notify.DEFAULTS = {
|
1488
|
+
title: true, // Title of notification. If you do not include the title in options it will automatically takes its value
|
1489
|
+
//from Lobibox.notify.OPTIONS object depending of the type of the notifications or set custom string. Set this false to disable title
|
1490
|
+
size: 'normal', // normal, mini, large
|
1491
|
+
soundPath: 'sounds/', // The folder path where sounds are located
|
1492
|
+
soundExt: '.ogg', // Default extension for all sounds
|
1493
|
+
showClass: 'fadeInDown', // Show animation class.
|
1494
|
+
hideClass: 'zoomOut', // Hide animation class.
|
1495
|
+
icon: true, // Icon of notification. Leave as is for default icon or set custom string
|
1496
|
+
msg: '', // Message of notification
|
1497
|
+
img: null, // Image source string
|
1498
|
+
closable: true, // Make notifications closable
|
1499
|
+
hideCloseButton: false, // Notification may be closable but you can hide close button and it will be closed by clicking on notification itsef
|
1500
|
+
delay: 5000, // Hide notification after this time (in miliseconds)
|
1501
|
+
delayIndicator: true, // Show timer indicator
|
1502
|
+
closeOnClick: true, // Close notifications by clicking on them
|
1503
|
+
width: 400, // Width of notification box
|
1504
|
+
sound: true, // Sound of notification. Set this false to disable sound. Leave as is for default sound or set custom soud path
|
1505
|
+
// Place to show notification. Available options: "top left", "top right", "bottom left", "bottom right", "center top", "center bottom"
|
1506
|
+
// It can also be object {left: number, top: number} to position notification at any place
|
1507
|
+
position: "bottom right",
|
1508
|
+
iconSource: 'bootstrap', // "bootstrap" or "fontAwesome" the library which will be used for icons
|
1509
|
+
rounded: false, // Whether to make notification corners rounded
|
1510
|
+
messageHeight: 60, // Notification message maximum height. This is not for notification itself, this is for <code>.lobibox-notify-msg</code>
|
1511
|
+
pauseDelayOnHover: true, // When you mouse over on notification delay (if it is enabled) will be paused.
|
1512
|
+
onClickUrl: null, // The url which will be opened when notification is clicked
|
1513
|
+
showAfterPrevious: false, // Set this to true if you want notification not to be shown until previous notification is closed. This is useful for notification queues
|
1514
|
+
continueDelayOnInactiveTab: true, // Continue delay when browser tab is inactive
|
1515
|
+
|
1516
|
+
// Events
|
1517
|
+
onClick: null
|
1518
|
+
};
|
1519
|
+
//This variable is necessary.
|
1520
|
+
Lobibox.notify.OPTIONS = {
|
1521
|
+
'class': 'animated-fast',
|
1522
|
+
large: {
|
1523
|
+
width: 500,
|
1524
|
+
messageHeight: 96
|
1525
|
+
},
|
1526
|
+
mini: {
|
1527
|
+
'class': 'notify-mini',
|
1528
|
+
messageHeight: 32
|
1529
|
+
},
|
1530
|
+
default: {
|
1531
|
+
'class': 'lobibox-notify-default',
|
1532
|
+
'title': 'Default',
|
1533
|
+
sound: false
|
1534
|
+
},
|
1535
|
+
success: {
|
1536
|
+
'class': 'lobibox-notify-success',
|
1537
|
+
'title': 'Success',
|
1538
|
+
sound: 'sound2'
|
1539
|
+
},
|
1540
|
+
error: {
|
1541
|
+
'class': 'lobibox-notify-error',
|
1542
|
+
'title': 'Error',
|
1543
|
+
sound: 'sound4'
|
1544
|
+
},
|
1545
|
+
warning: {
|
1546
|
+
'class': 'lobibox-notify-warning',
|
1547
|
+
'title': 'Warning',
|
1548
|
+
sound: 'sound5'
|
1549
|
+
},
|
1550
|
+
info: {
|
1551
|
+
'class': 'lobibox-notify-info',
|
1552
|
+
'title': 'Information',
|
1553
|
+
sound: 'sound6'
|
1554
|
+
},
|
1555
|
+
icons: {
|
1556
|
+
bootstrap: {
|
1557
|
+
success: 'glyphicon glyphicon-ok-sign',
|
1558
|
+
error: 'glyphicon glyphicon-remove-sign',
|
1559
|
+
warning: 'glyphicon glyphicon-exclamation-sign',
|
1560
|
+
info: 'glyphicon glyphicon-info-sign'
|
1561
|
+
},
|
1562
|
+
fontAwesome: {
|
1563
|
+
success: 'fa fa-check-circle',
|
1564
|
+
error: 'fa fa-times-circle',
|
1565
|
+
warning: 'fa fa-exclamation-circle',
|
1566
|
+
info: 'fa fa-info-circle'
|
1567
|
+
}
|
1568
|
+
}
|
1569
|
+
};
|
1570
|
+
})();
|
1571
|
+
|
1572
|
+
|