maxmertkit-rails 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/lib/maxmertkit-rails/engine.rb +9 -0
- data/lib/maxmertkit-rails/version.rb +5 -0
- data/lib/maxmertkit-rails.rb +8 -0
- data/maxmertkit-rails.gemspec +19 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.svg +255 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/zocial/zocial-regular-webfont.eot +0 -0
- data/vendor/assets/fonts/zocial/zocial-regular-webfont.svg +151 -0
- data/vendor/assets/fonts/zocial/zocial-regular-webfont.ttf +0 -0
- data/vendor/assets/fonts/zocial/zocial-regular-webfont.woff +0 -0
- data/vendor/assets/javascript/libs/easing.js +205 -0
- data/vendor/assets/javascript/libs/html5shiv.js +298 -0
- data/vendor/assets/javascript/libs/imagesLoaded.js +3 -0
- data/vendor/assets/javascript/libs/modernizr.js +4 -0
- data/vendor/assets/javascript/maxmertkit.affix.js +85 -0
- data/vendor/assets/javascript/maxmertkit.button.js +182 -0
- data/vendor/assets/javascript/maxmertkit.carousel.js +688 -0
- data/vendor/assets/javascript/maxmertkit.js +112 -0
- data/vendor/assets/javascript/maxmertkit.modal.js +301 -0
- data/vendor/assets/javascript/maxmertkit.notify.js +186 -0
- data/vendor/assets/javascript/maxmertkit.popup.js +396 -0
- data/vendor/assets/javascript/maxmertkit.scrollspy.js +107 -0
- data/vendor/assets/javascript/maxmertkit.tabs.js +228 -0
- data/vendor/assets/stylesheet/_init.scss +240 -0
- data/vendor/assets/stylesheet/_mixins.scss +218 -0
- data/vendor/assets/stylesheet/animations/_keyframes.scss +2914 -0
- data/vendor/assets/stylesheet/classes/_object.scss +14 -0
- data/vendor/assets/stylesheet/maxmertkit-animation.scss +146 -0
- data/vendor/assets/stylesheet/maxmertkit-components.scss +25 -0
- data/vendor/assets/stylesheet/maxmertkit.scss +14 -0
- data/vendor/assets/stylesheet/modificators/__methods.scss +116 -0
- data/vendor/assets/stylesheet/modificators/_size.scss +208 -0
- data/vendor/assets/stylesheet/modificators/_status.scss +195 -0
- data/vendor/assets/stylesheet/themes/_basic.scss +330 -0
- data/vendor/assets/stylesheet/widgets/_arrow.scss +74 -0
- data/vendor/assets/stylesheet/widgets/_badge.scss +15 -0
- data/vendor/assets/stylesheet/widgets/_button.scss +131 -0
- data/vendor/assets/stylesheet/widgets/_caret.scss +34 -0
- data/vendor/assets/stylesheet/widgets/_carousel.scss +146 -0
- data/vendor/assets/stylesheet/widgets/_dropdown.scss +116 -0
- data/vendor/assets/stylesheet/widgets/_form.scss +327 -0
- data/vendor/assets/stylesheet/widgets/_group.scss +245 -0
- data/vendor/assets/stylesheet/widgets/_icon.scss +92 -0
- data/vendor/assets/stylesheet/widgets/_label.scss +4 -0
- data/vendor/assets/stylesheet/widgets/_menu.scss +283 -0
- data/vendor/assets/stylesheet/widgets/_modal.scss +172 -0
- data/vendor/assets/stylesheet/widgets/_notify.scss +190 -0
- data/vendor/assets/stylesheet/widgets/_progressbar.scss +70 -0
- data/vendor/assets/stylesheet/widgets/_table.scss +270 -0
- data/vendor/assets/stylesheet/widgets/_tabs.scss +211 -0
- data/vendor/assets/stylesheet/widgets/_toolbar.scss +118 -0
- data/vendor/assets/stylesheet/widgets/_tooltip.scss +19 -0
- metadata +104 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
;(function ( $, window, document, undefined ) {
|
2
|
+
|
3
|
+
var _name = 'kit'
|
4
|
+
, _defaults = {
|
5
|
+
enabled: true
|
6
|
+
, animation: null
|
7
|
+
, animationDuration: 0
|
8
|
+
, theme: 'dark'
|
9
|
+
}
|
10
|
+
|
11
|
+
$.kit = function(element, options) {
|
12
|
+
this.name = _name;
|
13
|
+
this.state = 'uninitialized'; // closed in opened out
|
14
|
+
|
15
|
+
this.element = element;
|
16
|
+
this.options = $.extend({}, _defaults, options);
|
17
|
+
this.El = $(this.options.template);
|
18
|
+
|
19
|
+
// this._setOptions( options );
|
20
|
+
}
|
21
|
+
|
22
|
+
$.kit.prototype._setOptions = function( options_ ) {
|
23
|
+
var me = this;
|
24
|
+
var $me = $(me.element);
|
25
|
+
|
26
|
+
$.each( options_, function( key_, value_ ) {
|
27
|
+
me._setOption( key_, value_ );
|
28
|
+
me.__setOption( key_, value_ );
|
29
|
+
|
30
|
+
var currentOption = { };
|
31
|
+
currentOption[ key_ ] = value_;
|
32
|
+
|
33
|
+
if( $.isFunction( value_ ) ) {
|
34
|
+
me._on( $me, currentOption );
|
35
|
+
}
|
36
|
+
|
37
|
+
});
|
38
|
+
}
|
39
|
+
|
40
|
+
$.kit.prototype._setOption = function( key_, value_ ) {
|
41
|
+
var me = this;
|
42
|
+
var $me = $(me.element);
|
43
|
+
|
44
|
+
switch( key_ ) {
|
45
|
+
case 'theme':
|
46
|
+
me.El.removeClass( '-' + me.options.theme + '-' );
|
47
|
+
me.El.addClass( '-' + value_ + '-' )
|
48
|
+
break;
|
49
|
+
|
50
|
+
case 'enabled':
|
51
|
+
value_ === true ? me.El.removeClass( '-disabled-' ) : me.El.addClass( '-disabled-' );
|
52
|
+
break;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
$.kit.prototype.__setOption = function ( key_, value_ ) {
|
57
|
+
this.options[ key_ ] = value_;
|
58
|
+
}
|
59
|
+
|
60
|
+
$.kit.prototype._on = function( element_, handlers_ ) {
|
61
|
+
var me = this;
|
62
|
+
|
63
|
+
$.each( handlers_, function( event, handler ) {
|
64
|
+
element_.bind( event + '.' + me.name, handler );
|
65
|
+
});
|
66
|
+
}
|
67
|
+
|
68
|
+
$.kit.prototype.enable = function() {
|
69
|
+
var me = this;
|
70
|
+
|
71
|
+
me._setOption( 'enabled', true )
|
72
|
+
}
|
73
|
+
|
74
|
+
$.kit.prototype.disable = function() {
|
75
|
+
var me = this;
|
76
|
+
|
77
|
+
me._setOption( 'enabled', false )
|
78
|
+
}
|
79
|
+
|
80
|
+
$.kit.prototype.getState = function() {
|
81
|
+
return this.state;
|
82
|
+
}
|
83
|
+
|
84
|
+
$.kit.prototype._getOtherInstanses = function( instanses_ ) {
|
85
|
+
var me = this;
|
86
|
+
|
87
|
+
return $.grep( instanses_ , function( el ) {
|
88
|
+
return $.data($(el[0]), 'kit-' + me.name) !== me;
|
89
|
+
});
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
$.kit.prototype._removeInstanse = function( instanses_ ) {
|
94
|
+
var me = this;
|
95
|
+
|
96
|
+
var what
|
97
|
+
, a = arguments.splice(0,1)
|
98
|
+
, L = a.length
|
99
|
+
, ax;
|
100
|
+
|
101
|
+
while( L && instanses_.length ) {
|
102
|
+
what = a[ --L ];
|
103
|
+
|
104
|
+
while( (ax = instanses_.indexOf( what ) ) != -1 ){
|
105
|
+
instanses_.splice( ax, 1 );
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
return me;
|
110
|
+
}
|
111
|
+
|
112
|
+
})( jQuery, window, document );
|
@@ -0,0 +1,301 @@
|
|
1
|
+
;(function ( $, window, document, undefined ) {
|
2
|
+
var _name = 'modal'
|
3
|
+
, _defaults = {
|
4
|
+
autoOpen: false
|
5
|
+
, onlyOne: true
|
6
|
+
, shaderClass: '-shader'
|
7
|
+
, closerClass: '-closer'
|
8
|
+
|
9
|
+
, beforeOpen: $.noop()
|
10
|
+
, open: $.noop()
|
11
|
+
, ifOpenedOrNot: $.noop()
|
12
|
+
, ifNotOpened: $.noop()
|
13
|
+
, beforeClose: $.noop()
|
14
|
+
, close: $.noop()
|
15
|
+
, ifClosedOrNot: $.noop()
|
16
|
+
, ifNotClosed: $.noop()
|
17
|
+
}
|
18
|
+
|
19
|
+
Modal = function( element_, options_ ) {
|
20
|
+
this.element = element_;
|
21
|
+
this.name = _name;
|
22
|
+
this.options = $.extend( {}, this.options, _defaults, options_ );
|
23
|
+
this._setOptions( this.options );
|
24
|
+
|
25
|
+
if( typeof $.modal === 'undefined' )
|
26
|
+
$.modal = [];
|
27
|
+
if( this.element !== 'undefined' )
|
28
|
+
$.modal.push( this.element );
|
29
|
+
|
30
|
+
$(this.element).css({
|
31
|
+
display: 'none'
|
32
|
+
, left: '50%'
|
33
|
+
, top: '50%'
|
34
|
+
, position: 'fixed'
|
35
|
+
});
|
36
|
+
|
37
|
+
var me = this;
|
38
|
+
$(this.element).find( '.' + me.options.closerClass ).on( 'click', function() {
|
39
|
+
me.close();
|
40
|
+
})
|
41
|
+
|
42
|
+
this.init();
|
43
|
+
}
|
44
|
+
|
45
|
+
Modal.prototype = new $.kit();
|
46
|
+
Modal.prototype.constructor = Modal;
|
47
|
+
|
48
|
+
Modal.prototype.__setOption = function( key_, value_ ) {
|
49
|
+
var me = this
|
50
|
+
, $me = $(me.element);
|
51
|
+
|
52
|
+
switch( key_ ) {
|
53
|
+
case 'animation':
|
54
|
+
if( $.easing === undefined || !(value_ in $.easing) )
|
55
|
+
switch( value_ ) {
|
56
|
+
case 'scaleIn':
|
57
|
+
$me.addClass('-mx-scaleIn');
|
58
|
+
break;
|
59
|
+
|
60
|
+
case 'growUp':
|
61
|
+
$me.addClass('-mx-growUp');
|
62
|
+
break;
|
63
|
+
|
64
|
+
case 'rotateIn':
|
65
|
+
$me.addClass('-mx-rotateIn');
|
66
|
+
break;
|
67
|
+
|
68
|
+
case 'dropIn':
|
69
|
+
$me.addClass('-mx-dropIn');
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
|
73
|
+
break;
|
74
|
+
|
75
|
+
case 'theme':
|
76
|
+
$me.addClass( '-' + value_ + '-' );
|
77
|
+
break;
|
78
|
+
}
|
79
|
+
|
80
|
+
me.options[ key_ ] = value_;
|
81
|
+
}
|
82
|
+
|
83
|
+
Modal.prototype.init = function() {
|
84
|
+
var me = this;
|
85
|
+
|
86
|
+
if( me.options.autoOpen )
|
87
|
+
me.open();
|
88
|
+
}
|
89
|
+
|
90
|
+
Modal.prototype._setPosition = function() {
|
91
|
+
var me = this
|
92
|
+
, $me = $(me.element)
|
93
|
+
, width = $me.outerWidth()
|
94
|
+
, height = $me.outerHeight();
|
95
|
+
|
96
|
+
$me.css({
|
97
|
+
marginLeft: -width / 2,
|
98
|
+
marginTop: -height / 2
|
99
|
+
});
|
100
|
+
}
|
101
|
+
|
102
|
+
Modal.prototype.open = function() {
|
103
|
+
var me = this
|
104
|
+
, $me = $(me.element);
|
105
|
+
|
106
|
+
if( me.options.enabled === true && me.state !== 'opened' ) {
|
107
|
+
|
108
|
+
me._openShader();
|
109
|
+
me.state = 'in';
|
110
|
+
|
111
|
+
if( me.options.beforeOpen !== 'undefined' && (typeof me.options.beforeOpen === 'object' || typeof me.options.beforeOpen === 'function' )) {
|
112
|
+
|
113
|
+
try {
|
114
|
+
var deferred = me.options.beforeOpen.call( $me );
|
115
|
+
deferred
|
116
|
+
.done(function(){
|
117
|
+
me._open();
|
118
|
+
})
|
119
|
+
.fail(function(){
|
120
|
+
me._closeShader();
|
121
|
+
me.state = 'closed';
|
122
|
+
$me.trigger('ifNotOpened.' + me.name);
|
123
|
+
$me.trigger('ifOpenedOrNot.' + me.name);
|
124
|
+
})
|
125
|
+
} catch( e ) {
|
126
|
+
me._open();
|
127
|
+
}
|
128
|
+
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
me._open();
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
Modal.prototype._open = function() {
|
137
|
+
var me = this;
|
138
|
+
var $me = $(me.element);
|
139
|
+
|
140
|
+
if( me.state === 'in' ) {
|
141
|
+
|
142
|
+
if( me.options.onlyOne )
|
143
|
+
|
144
|
+
$.each( me._getOtherInstanses( $.modal ), function() {
|
145
|
+
if( $.data( this, 'kit-' + me.name ).getState() === 'opened' )
|
146
|
+
$.data( this, 'kit-' + me.name ).close();
|
147
|
+
});
|
148
|
+
|
149
|
+
me._setPosition();
|
150
|
+
|
151
|
+
if( me.options.animation !== null && me.options.animation !== false )
|
152
|
+
{
|
153
|
+
me._openAnimation();
|
154
|
+
}
|
155
|
+
else
|
156
|
+
{
|
157
|
+
$me.css({opacity:1}).show();
|
158
|
+
}
|
159
|
+
|
160
|
+
me.state = 'opened';
|
161
|
+
$me.trigger('open.' + me.name);
|
162
|
+
}
|
163
|
+
|
164
|
+
$me.trigger('ifOpenedOrNot.' + me.name);
|
165
|
+
}
|
166
|
+
|
167
|
+
Modal.prototype._openAnimation = function() {
|
168
|
+
var me = this;
|
169
|
+
var $me = $(me.element);
|
170
|
+
|
171
|
+
$('html').addClass( '-mx-shader' );
|
172
|
+
|
173
|
+
if( $.easing !== 'undefined' && (me.options.animation.split(/[ ,]+/)[1] in $.easing || me.options.animation.split(/[ ,]+/)[0] in $.easing) ) {
|
174
|
+
me.element.css({opacity:1}).slideDown({
|
175
|
+
duration: me.options.animationDuration,
|
176
|
+
easing: me.options.animation.split(/[ ,]+/)[0]
|
177
|
+
});
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
$me.show();
|
181
|
+
$me.addClass('-mx-start');
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
Modal.prototype.close = function() {
|
186
|
+
var me = this;
|
187
|
+
var $me = $(me.element);
|
188
|
+
|
189
|
+
if( me.options.enabled === true && me.state !== 'closed' ) {
|
190
|
+
|
191
|
+
me.state = 'out';
|
192
|
+
|
193
|
+
if( me.options.beforeClose != 'undefined' && (typeof me.options.beforeClose === 'object' || typeof me.options.beforeClose === 'function' ))
|
194
|
+
{
|
195
|
+
|
196
|
+
try {
|
197
|
+
var deferred = me.options.beforeClose.call( $me );
|
198
|
+
deferred
|
199
|
+
.done(function(){
|
200
|
+
me._close();
|
201
|
+
})
|
202
|
+
.fail(function(){
|
203
|
+
me._closeShader();
|
204
|
+
$me.trigger('ifNotClosed.' + me.name);
|
205
|
+
$me.trigger('ifClosedOrNot.' + me.name);
|
206
|
+
me.state = 'opened';
|
207
|
+
})
|
208
|
+
} catch( e ) {
|
209
|
+
me._close();
|
210
|
+
}
|
211
|
+
|
212
|
+
}
|
213
|
+
else {
|
214
|
+
me._close();
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
Modal.prototype._close = function() {
|
220
|
+
var me = this;
|
221
|
+
var $me = $(me.element);
|
222
|
+
|
223
|
+
me._closeShader();
|
224
|
+
if( me.state === 'out' ) {
|
225
|
+
|
226
|
+
if( me.options.animation === null )
|
227
|
+
me.element.hide();
|
228
|
+
else {
|
229
|
+
me._closeAnimation();
|
230
|
+
}
|
231
|
+
me.state = 'closed';
|
232
|
+
|
233
|
+
$me.trigger('close');
|
234
|
+
}
|
235
|
+
|
236
|
+
$me.trigger('ifClosedOrNot.' + me.name);
|
237
|
+
}
|
238
|
+
|
239
|
+
Modal.prototype._closeAnimation = function() {
|
240
|
+
var me = this;
|
241
|
+
var $me = $(me.element);
|
242
|
+
|
243
|
+
$('html').removeClass( '-mx-shader' );
|
244
|
+
|
245
|
+
if( $.easing !== 'undefined' && (me.options.animation.split(/[ ,]+/)[1] in $.easing || me.options.animation.split(/[ ,]+/)[0] in $.easing) ) {
|
246
|
+
$me.slideUp({
|
247
|
+
duration: me.options.animationDuration,
|
248
|
+
easing: me.options.animation.split(/[ ,]+/)[1] !== 'undefined' ? me.options.animation.split(/[ ,]+/)[1] : me.options.animation
|
249
|
+
});
|
250
|
+
}
|
251
|
+
else {
|
252
|
+
$me.removeClass('-mx-start');
|
253
|
+
$me.hide();
|
254
|
+
}
|
255
|
+
}
|
256
|
+
|
257
|
+
Modal.prototype._openShader = function() {
|
258
|
+
var me = this
|
259
|
+
, $me = $(me.element);
|
260
|
+
|
261
|
+
if( $.shader === undefined ) {
|
262
|
+
$.shader = $('<div class="' + me.options.shaderClass + '"></div>');
|
263
|
+
$('body').append( $.shader );
|
264
|
+
}
|
265
|
+
|
266
|
+
if( me.options.animation !== null || me.options.animation !== undefined )
|
267
|
+
$.shader.fadeIn(150);
|
268
|
+
else
|
269
|
+
$.shader.css({ opacity: 1 }).show();
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
Modal.prototype._closeShader = function() {
|
274
|
+
var me = this
|
275
|
+
, $me = $(me.element);
|
276
|
+
|
277
|
+
if( $.shader === undefined ) {
|
278
|
+
$.shader = '<div class="' + me.options.shaderClass + '"></div>';
|
279
|
+
$(document).append( $.shader );
|
280
|
+
}
|
281
|
+
|
282
|
+
if( me.options.animation !== null || me.options.animation !== undefined )
|
283
|
+
$.shader.fadeOut(350);
|
284
|
+
else
|
285
|
+
$.shader.css({ opacity: 0 }).hide();
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
$.fn[_name] = function( options_ ) {
|
290
|
+
return this.each(function() {
|
291
|
+
if( ! $.data( this, 'kit-' + _name ) ) {
|
292
|
+
$.data( this, 'kit-' + _name, new Modal( this, options_ ) );
|
293
|
+
}
|
294
|
+
else {
|
295
|
+
typeof options_ === 'object' ? $.data( this, 'kit-' + _name )._setOptions( options_ ) :
|
296
|
+
typeof options_ === 'string' && options_.charAt(0) !== '_' ? $.data( this, 'kit-' + _name )[ options_ ] : $.error( 'What do you want to do?' );
|
297
|
+
}
|
298
|
+
});
|
299
|
+
}
|
300
|
+
|
301
|
+
})( jQuery, window, document );
|
@@ -0,0 +1,186 @@
|
|
1
|
+
;(function ( $, window, document, undefined ) {
|
2
|
+
|
3
|
+
var _name = 'notify'
|
4
|
+
, _defaults = {
|
5
|
+
enabled: true
|
6
|
+
, theme: 'dark'
|
7
|
+
|
8
|
+
, template: '<div class="-notify-container js-notify-container"></div>'
|
9
|
+
, templateNotify: '<div class="-notify -mx-releaseIn _bottom_"></div>'
|
10
|
+
, templateNotifyHeader: '<div class="-notify-header"></div>'
|
11
|
+
, templateNotifyContent: '<div class="-notify-content"></div>'
|
12
|
+
, templateCloser: '<div class="-notify-closeAll -label -dark-">close all <i class="-icon-remove-circle -icon-light-"></i></div>'
|
13
|
+
}
|
14
|
+
|
15
|
+
Notify = function(message, options) {
|
16
|
+
var me = this;
|
17
|
+
|
18
|
+
if( this.state === 'uninitialized' ) {
|
19
|
+
this.name = _name;
|
20
|
+
this._id = 0;
|
21
|
+
this.notifications = [];
|
22
|
+
this.archive = [];
|
23
|
+
|
24
|
+
this.options = options === undefined ?
|
25
|
+
$.extend({}, _defaults, message) :
|
26
|
+
$.extend({}, _defaults, options);
|
27
|
+
|
28
|
+
this.$element = $('<div class="-notify-container js-notify-container"></div>');
|
29
|
+
$('body').append( this.$element );
|
30
|
+
this.closer = $(this.options.templateCloser)//$element.find('.-notify-closeAll');
|
31
|
+
|
32
|
+
this.closer.on('click', function( event_ ){
|
33
|
+
var i = 0;
|
34
|
+
while( me.notifications.length !== 0 ){
|
35
|
+
clearTimeout( me.notifications[i].timer );
|
36
|
+
me.notifyClose( me.notifications[i] );
|
37
|
+
}
|
38
|
+
});
|
39
|
+
|
40
|
+
this.$element.append( this.closer );
|
41
|
+
}
|
42
|
+
|
43
|
+
typeof options === 'object' && this._setOptions( options );
|
44
|
+
typeof message === 'string' && this.notify( message, options );
|
45
|
+
// options === undefined && this.showNotificationCenter();
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
Notify.prototype = new $.kit();
|
50
|
+
Notify.prototype.constructor = Notify;
|
51
|
+
|
52
|
+
|
53
|
+
Notify.prototype.__setOption = function( key_, value_ ) {
|
54
|
+
var me = this;
|
55
|
+
var $me = me.$element;
|
56
|
+
|
57
|
+
switch( key_ ) {
|
58
|
+
case 'theme':
|
59
|
+
$me.removeClass( '-' + me.options.theme + '-' );
|
60
|
+
$me.addClass( '-' + value_ + '-' )
|
61
|
+
break;
|
62
|
+
|
63
|
+
case 'enabled':
|
64
|
+
value_ === true ? $me.removeClass( '-disabled-' ) : $me.addClass( '-disabled-' );
|
65
|
+
break;
|
66
|
+
|
67
|
+
|
68
|
+
}
|
69
|
+
|
70
|
+
me.options[ key_ ] = value_;
|
71
|
+
}
|
72
|
+
|
73
|
+
Notify.prototype.notify = function( message_, options_ ) {
|
74
|
+
var me = this
|
75
|
+
, $me = me.$element
|
76
|
+
, notification = {}
|
77
|
+
, header;
|
78
|
+
|
79
|
+
notification.$element = $( me.options.templateNotify );
|
80
|
+
notification._id = me._id++;
|
81
|
+
notification.$element.attr('id', 'notification' + notification._id );
|
82
|
+
notification.$element.css('z-index', 10*notification._id );
|
83
|
+
|
84
|
+
options_ && $.each( options_, function( key_, value_ ) {
|
85
|
+
switch( key_ ) {
|
86
|
+
case 'header':
|
87
|
+
notification.header = $( me.options.templateNotifyHeader ).append( value_ );
|
88
|
+
break;
|
89
|
+
|
90
|
+
case 'theme':
|
91
|
+
notification.theme && notification.$element.removeClass( notification.theme );
|
92
|
+
notification.$element.addClass( '-' + value_ + '-' );
|
93
|
+
notification.theme = value_;
|
94
|
+
break;
|
95
|
+
|
96
|
+
case 'type':
|
97
|
+
notification.type = value_;
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
});
|
101
|
+
|
102
|
+
if (notification.type === undefined) notification.type = 4000;
|
103
|
+
notification.content = $( me.options.templateNotifyContent ).append( message_ );
|
104
|
+
|
105
|
+
notification.header !== undefined && typeof notification.type !== 'number' && notification.header.append('<i class="-closer">×</i>');
|
106
|
+
|
107
|
+
notification.$element.append( notification.header !== undefined && notification.header, notification.content );
|
108
|
+
|
109
|
+
me.notifyShow( notification );
|
110
|
+
}
|
111
|
+
|
112
|
+
Notify.prototype.notifyShow = function( notification_ ) {
|
113
|
+
var me = this
|
114
|
+
, $me = me.$element;
|
115
|
+
|
116
|
+
notification_.$element.on( 'click', function( event_ ) {
|
117
|
+
$(event_.target).hasClass('-closer') && me.notifyClose( notification_ );
|
118
|
+
});
|
119
|
+
|
120
|
+
me.notifications.push( notification_ );
|
121
|
+
$me.append( notification_.$element );
|
122
|
+
setTimeout(function(){ notification_.$element.addClass('-mx-start'); },1);
|
123
|
+
|
124
|
+
me.notifications.length > 1 && me.closer.fadeIn();
|
125
|
+
|
126
|
+
if( typeof notification_.type === 'number' ) {
|
127
|
+
me.notifyTimerClose( notification_ );
|
128
|
+
|
129
|
+
notification_.$element.on( 'mouseenter', function( event_ ) {
|
130
|
+
clearTimeout( notification_.timer );
|
131
|
+
});
|
132
|
+
|
133
|
+
notification_.$element.on( 'mouseleave', function( event_ ) {
|
134
|
+
me.notifyTimerClose( notification_ );
|
135
|
+
});
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
Notify.prototype.notifyTimerClose = function( notification_ ) {
|
140
|
+
var me = this
|
141
|
+
, $me = me.$element;
|
142
|
+
|
143
|
+
notification_.timer = setTimeout(function(){
|
144
|
+
me.notifyClose( notification_ );
|
145
|
+
}, notification_.type);
|
146
|
+
}
|
147
|
+
|
148
|
+
Notify.prototype.notifyClose = function( notification_ ) {
|
149
|
+
var me = this
|
150
|
+
, $me = me.$element;
|
151
|
+
|
152
|
+
$me.find('#notification'+notification_._id).animate({opacity:0}, function(){
|
153
|
+
$(this).slideUp( function(){
|
154
|
+
$(this).remove()
|
155
|
+
} )
|
156
|
+
});
|
157
|
+
|
158
|
+
me.removeNotifyInstance( notification_ ) && me.notifications.length <= 1 && me.closer.fadeOut();
|
159
|
+
}
|
160
|
+
|
161
|
+
Notify.prototype.removeNotifyInstance = function( notification_ ) {
|
162
|
+
var me = this
|
163
|
+
, $me = me.$element
|
164
|
+
, i = 0;
|
165
|
+
|
166
|
+
while( me.notifications[i]._id !== notification_._id && i < me.notifications.length ) i++;
|
167
|
+
|
168
|
+
if( me.notifications[i]._id === notification_._id ) {
|
169
|
+
me.archive.push( me.notifications[i] );
|
170
|
+
me.notifications.splice( i, 1 );
|
171
|
+
}
|
172
|
+
|
173
|
+
return true;
|
174
|
+
}
|
175
|
+
|
176
|
+
$[_name] = function( message_, options_ ) {
|
177
|
+
|
178
|
+
if( ! $('body').data( 'kit-' + _name ) ) {
|
179
|
+
$('body').data( 'kit-' + _name, new Notify( message_, options_ ) );
|
180
|
+
}
|
181
|
+
else {
|
182
|
+
options_ === undefined && typeof message_ === 'string' ? $('body').data( 'kit-' + _name).init( message_ ) : $('body').data( 'kit-' + _name).notify( message_, options_ );
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
186
|
+
})( jQuery, window, document );
|