Browse Source

Recovers removed source files.

master
Boris Grozev 9 years ago
parent
commit
cd1f56fa8f
9 changed files with 26186 additions and 1 deletions
  1. 0
    1
      Makefile
  2. 9190
    0
      libs/jquery-2.1.1.js
  3. 1
    0
      libs/jquery-2.1.1.min.js
  4. 863
    0
      libs/jquery-impromptu.js
  5. 15008
    0
      libs/jquery-ui.js
  6. 250
    0
      libs/jquery.autosize.js
  7. 110
    0
      libs/popover.js
  8. 342
    0
      libs/toastr.js
  9. 422
    0
      libs/tooltip.js

+ 0
- 1
Makefile View File

28
 
28
 
29
 uglify:
29
 uglify:
30
 	uglifyjs libs/app.bundle.js -o libs/app.bundle.min.js --source-map libs/app.bundle.js.map --source-map-url=app.bundle.js.map
30
 	uglifyjs libs/app.bundle.js -o libs/app.bundle.min.js --source-map libs/app.bundle.js.map --source-map-url=app.bundle.js.map
31
-	rm -f libs/app.bundle.js
32
 
31
 
33
 source-package:
32
 source-package:
34
 	mkdir -p source_package/jitsi-meet && \
33
 	mkdir -p source_package/jitsi-meet && \

+ 9190
- 0
libs/jquery-2.1.1.js
File diff suppressed because it is too large
View File


+ 1
- 0
libs/jquery-2.1.1.min.js
File diff suppressed because it is too large
View File


+ 863
- 0
libs/jquery-impromptu.js View File

1
+/*! jQuery-Impromptu - v6.0.0 - 2014-12-27
2
+* http://trentrichardson.com/Impromptu
3
+* Copyright (c) 2014 Trent Richardson; Licensed MIT */
4
+(function(root, factory) {
5
+	if (typeof define === 'function' && define.amd) {
6
+		define(['jquery'], factory);
7
+	} else {
8
+		factory(root.jQuery);
9
+	}
10
+}(this, function($) {
11
+	'use strict';
12
+
13
+	// ########################################################################
14
+	// Base object
15
+	// ########################################################################
16
+
17
+	/**
18
+	* Imp - Impromptu object - passing no params will not open, only return the instance
19
+	* @param message String/Object - String of html or Object of states
20
+	* @param options Object - Options to set the prompt
21
+	* @return Imp - the instance of this Impromptu object
22
+	*/
23
+	var Imp = function(message, options){
24
+		var t = this;
25
+		t.id = Imp.count++;
26
+
27
+		Imp.lifo.push(t);
28
+
29
+		if(message){
30
+			t.open(message, options);
31
+		}
32
+		return t;
33
+	};
34
+
35
+	// ########################################################################
36
+	// static properties and methods
37
+	// ########################################################################
38
+
39
+	/**
40
+	* defaults - the default options
41
+	*/
42
+	Imp.defaults = {
43
+		prefix:'jqi',
44
+		classes: {
45
+			box: '',
46
+			fade: '',
47
+			prompt: '',
48
+			form: '',
49
+			close: '',
50
+			title: '',
51
+			message: '',
52
+			buttons: '',
53
+			button: '',
54
+			defaultButton: ''
55
+		},
56
+		title: '',
57
+		closeText: '×',
58
+		buttons: {
59
+			Ok: true
60
+		},
61
+		loaded: function(e){},
62
+		submit: function(e,v,m,f){},
63
+		close: function(e,v,m,f){},
64
+		statechanging: function(e, from, to){},
65
+		statechanged: function(e, to){},
66
+		opacity: 0.6,
67
+		zIndex: 999,
68
+		overlayspeed: 'slow',
69
+		promptspeed: 'fast',
70
+		show: 'fadeIn',
71
+		hide: 'fadeOut',
72
+		focus: 0,
73
+		defaultButton: 0,
74
+		useiframe: false,
75
+		top: '15%',
76
+		position: {
77
+			container: null,
78
+			x: null,
79
+			y: null,
80
+			arrow: null,
81
+			width: null
82
+		},
83
+		persistent: true,
84
+		timeout: 0,
85
+		states: {},
86
+		state: {
87
+			name: null,
88
+			title: '',
89
+			html: '',
90
+			buttons: {
91
+				Ok: true
92
+			},
93
+			focus: 0,
94
+			defaultButton: 0,
95
+			position: {
96
+				container: null,
97
+				x: null,
98
+				y: null,
99
+				arrow: null,
100
+				width: null
101
+			},
102
+			submit: function(e,v,m,f){
103
+				return true;
104
+			}
105
+		}
106
+	};
107
+
108
+	/**
109
+	* setDefaults - Sets the default options
110
+	* @param o Object - Options to set as defaults
111
+	* @return void
112
+	*/
113
+	Imp.setDefaults = function(o) {
114
+		Imp.defaults = $.extend({}, Imp.defaults, o);
115
+	};
116
+
117
+	/**
118
+	* setStateDefaults - Sets the default options for a state
119
+	* @param o Object - Options to set as defaults
120
+	* @return void
121
+	*/
122
+	Imp.setStateDefaults = function(o) {
123
+		Imp.defaults.state = $.extend({}, Imp.defaults.state, o);
124
+	};
125
+
126
+	/**
127
+	* @var Int - A counter used to provide a unique ID for new prompts
128
+	*/
129
+	Imp.count = 0;
130
+
131
+	/**
132
+	* @var Array - An array of Impromptu intances in a LIFO queue (last in first out)
133
+	*/
134
+	Imp.lifo = [];
135
+
136
+	/**
137
+	* getLast - get the last element from the queue (doesn't pop, just returns)
138
+	* @return Imp - the instance of this Impromptu object or false if queue is empty
139
+	*/
140
+	Imp.getLast = function(){
141
+		var l = Imp.lifo.length;
142
+		return (l > 0)? Imp.lifo[l-1] : false;
143
+	};
144
+
145
+	/**
146
+	* removeFromStack - remove an element from the lifo stack by its id
147
+	* @param id int - id of the instance to remove
148
+	* @return api - The api of the element removed from the stack or void
149
+	*/
150
+	Imp.removeFromStack = function(id){
151
+		for(var i=Imp.lifo.length-1; i>=0; i--){
152
+			if(Imp.lifo[i].id === id){
153
+				return Imp.lifo.splice(i,1)[0];
154
+			}
155
+		}
156
+	};
157
+
158
+	// ########################################################################
159
+	// extend our object instance properties and methods
160
+	// ########################################################################
161
+	Imp.prototype = {
162
+
163
+		/**
164
+		* @var Int - A unique id, simply an autoincremented number
165
+		*/
166
+		id: null,
167
+
168
+		/**
169
+		* open - Opens the prompt
170
+		* @param message String/Object - String of html or Object of states
171
+		* @param options Object - Options to set the prompt
172
+		* @return Imp - the instance of this Impromptu object
173
+		*/
174
+		open: function(message, options) {
175
+			var t = this;
176
+
177
+			t.options = $.extend({},Imp.defaults,options);
178
+
179
+			// Be sure any previous timeouts are destroyed
180
+			if(t.timeout){
181
+				clearTimeout(t.timeout);
182
+			}
183
+			t.timeout = false;
184
+
185
+			var opts = t.options,
186
+				$body = $(document.body),
187
+				$window = $(window);
188
+
189
+			//build the box and fade
190
+			var msgbox = '<div class="'+ opts.prefix +'box '+ opts.classes.box +'">';
191
+			if(opts.useiframe && ($('object, applet').length > 0)) {
192
+				msgbox += '<iframe src="javascript:false;" style="display:block;position:absolute;z-index:-1;" class="'+ opts.prefix +'fade '+ opts.classes.fade +'"></iframe>';
193
+			} else {
194
+				msgbox += '<div class="'+ opts.prefix +'fade '+ opts.classes.fade +'"></div>';
195
+			}
196
+			msgbox += '<div class="'+ opts.prefix +' '+ opts.classes.prompt +'">'+
197
+						'<form action="javascript:false;" onsubmit="return false;" class="'+ opts.prefix +'form '+ opts.classes.form +'">'+
198
+							'<div class="'+ opts.prefix +'close '+ opts.classes.close +'">'+ opts.closeText +'</div>'+
199
+							'<div class="'+ opts.prefix +'states"></div>'+
200
+						'</form>'+
201
+					'</div>'+
202
+				'</div>';
203
+
204
+			t.jqib = $(msgbox).appendTo($body);
205
+			t.jqi = t.jqib.children('.'+ opts.prefix);
206
+			t.jqif = t.jqib.children('.'+ opts.prefix +'fade');
207
+
208
+			//if a string was passed, convert to a single state
209
+			if(message.constructor === String){
210
+				message = {
211
+					state0: {
212
+						title: opts.title,
213
+						html: message,
214
+						buttons: opts.buttons,
215
+						position: opts.position,
216
+						focus: opts.focus,
217
+						defaultButton: opts.defaultButton,
218
+						submit: opts.submit
219
+					}
220
+				};
221
+			}
222
+
223
+			//build the states
224
+			t.options.states = {};
225
+			var k,v;
226
+			for(k in message){
227
+				v = $.extend({},Imp.defaults.state,{name:k},message[k]);
228
+				t.addState(v.name, v);
229
+
230
+				if(t.currentStateName === ''){
231
+					t.currentStateName = v.name;
232
+				}
233
+			}
234
+
235
+			//Events
236
+			t.jqi.on('click', '.'+ opts.prefix +'buttons button', function(e){
237
+				var $t = $(this),
238
+					$state = $t.parents('.'+ opts.prefix +'state'),
239
+					stateobj = t.options.states[$state.data('jqi-name')],
240
+					msg = $state.children('.'+ opts.prefix +'message'),
241
+					clicked = stateobj.buttons[$t.text()] || stateobj.buttons[$t.html()],
242
+					forminputs = {};
243
+
244
+				// if for some reason we couldn't get the value
245
+				if(clicked === undefined){
246
+					for(var i in stateobj.buttons){
247
+						if(stateobj.buttons[i].title === $t.text() || stateobj.buttons[i].title === $t.html()){
248
+							clicked = stateobj.buttons[i].value;
249
+						}
250
+					}
251
+				}
252
+
253
+				//collect all form element values from all states.
254
+				$.each(t.jqi.children('form').serializeArray(),function(i,obj){
255
+					if (forminputs[obj.name] === undefined) {
256
+						forminputs[obj.name] = obj.value;
257
+					} else if (typeof forminputs[obj.name] === Array || typeof forminputs[obj.name] === 'object') {
258
+						forminputs[obj.name].push(obj.value);
259
+					} else {
260
+						forminputs[obj.name] = [forminputs[obj.name],obj.value];
261
+					}
262
+				});
263
+
264
+				// trigger an event
265
+				var promptsubmite = new $.Event('impromptu:submit');
266
+				promptsubmite.stateName = stateobj.name;
267
+				promptsubmite.state = $state;
268
+				$state.trigger(promptsubmite, [clicked, msg, forminputs]);
269
+
270
+				if(!promptsubmite.isDefaultPrevented()){
271
+					t.close(true, clicked,msg,forminputs);
272
+				}
273
+			});
274
+
275
+			// if the fade is clicked blink the prompt
276
+			var fadeClicked = function(){
277
+				if(opts.persistent){
278
+					var offset = (opts.top.toString().indexOf('%') >= 0? ($window.height()*(parseInt(opts.top,10)/100)) : parseInt(opts.top,10)),
279
+						top = parseInt(t.jqi.css('top').replace('px',''),10) - offset;
280
+
281
+					//$window.scrollTop(top);
282
+					$('html,body').animate({ scrollTop: top }, 'fast', function(){
283
+						var i = 0;
284
+						t.jqib.addClass(opts.prefix +'warning');
285
+						var intervalid = setInterval(function(){
286
+							t.jqib.toggleClass(opts.prefix +'warning');
287
+							if(i++ > 1){
288
+								clearInterval(intervalid);
289
+								t.jqib.removeClass(opts.prefix +'warning');
290
+							}
291
+						}, 100);
292
+					});
293
+				}
294
+				else {
295
+					t.close(true);
296
+				}
297
+			};
298
+
299
+			// listen for esc or tab keys
300
+			var keyDownEventHandler = function(e){
301
+				var key = (window.event) ? event.keyCode : e.keyCode;
302
+
303
+				//escape key closes
304
+				if(key === 27) {
305
+					fadeClicked();
306
+				}
307
+
308
+				//enter key pressed trigger the default button if its not on it, ignore if it is a textarea
309
+				if(key === 13){
310
+					var $defBtn = t.getCurrentState().find('.'+ opts.prefix +'defaultbutton');
311
+					var $tgt = $(e.target);
312
+
313
+					if($tgt.is('textarea,.'+opts.prefix+'button') === false && $defBtn.length > 0){
314
+						e.preventDefault();
315
+						$defBtn.click();
316
+					}
317
+				}
318
+
319
+				//constrain tabs, tabs should iterate through the state and not leave
320
+				if (key === 9){
321
+					var $inputels = $('input,select,textarea,button',t.getCurrentState());
322
+					var fwd = !e.shiftKey && e.target === $inputels[$inputels.length-1];
323
+					var back = e.shiftKey && e.target === $inputels[0];
324
+					if (fwd || back) {
325
+						setTimeout(function(){
326
+							if (!$inputels){
327
+								return;
328
+							}
329
+							var el = $inputels[back===true ? $inputels.length-1 : 0];
330
+
331
+							if (el){
332
+								el.focus();
333
+							}
334
+						},10);
335
+						return false;
336
+					}
337
+				}
338
+			};
339
+
340
+			t.position();
341
+			t.style();
342
+
343
+			// store copy of the window resize function for interal use only
344
+			t._windowResize = function(e){
345
+				t.position(e);
346
+			};
347
+			$window.resize({ animate: false }, t._windowResize);
348
+
349
+			t.jqif.click(fadeClicked);
350
+			t.jqi.find('.'+ opts.prefix +'close').click(function(){ t.close(); });
351
+			t.jqib.on("keydown",keyDownEventHandler)
352
+						.on('impromptu:loaded', opts.loaded)
353
+						.on('impromptu:close', opts.close)
354
+						.on('impromptu:statechanging', opts.statechanging)
355
+						.on('impromptu:statechanged', opts.statechanged);
356
+
357
+			// Show it
358
+			t.jqif[opts.show](opts.overlayspeed);
359
+			t.jqi[opts.show](opts.promptspeed, function(){
360
+
361
+				var $firstState = t.jqi.find('.'+ opts.prefix +'states .'+ opts.prefix +'state').eq(0);
362
+				t.goToState($firstState.data('jqi-name'));
363
+
364
+				t.jqib.trigger('impromptu:loaded');
365
+			});
366
+
367
+			// Timeout
368
+			if(opts.timeout > 0){
369
+				t.timeout = setTimeout(function(){ t.close(true); },opts.timeout);
370
+			}
371
+
372
+			return t;
373
+		},
374
+
375
+		/**
376
+		* close - Closes the prompt
377
+		* @param callback Function - called when the transition is complete
378
+		* @param clicked String - value of the button clicked (only used internally)
379
+		* @param msg jQuery - The state message body (only used internally)
380
+		* @param forvals Object - key/value pairs of all form field names and values (only used internally)
381
+		* @return Imp - the instance of this Impromptu object
382
+		*/
383
+		close: function(callCallback, clicked, msg, formvals){
384
+			var t = this;
385
+			Imp.removeFromStack(t.id);
386
+
387
+			if(t.timeout){
388
+				clearTimeout(t.timeout);
389
+				t.timeout = false;
390
+			}
391
+
392
+			if(t.jqib){
393
+				t.jqib[t.options.hide]('fast',function(){
394
+					
395
+					t.jqib.trigger('impromptu:close', [clicked,msg,formvals]);
396
+					
397
+					t.jqib.remove();
398
+					
399
+					$(window).off('resize', t._windowResize);
400
+
401
+					if(typeof callCallback === 'function'){
402
+						callCallback();
403
+					}
404
+				});
405
+			}
406
+			t.currentStateName = "";
407
+
408
+			return t;
409
+		},
410
+
411
+		/**
412
+		* addState - Injects a state into the prompt
413
+		* @param statename String - Name of the state
414
+		* @param stateobj Object - options for the state
415
+		* @param afterState String - selector of the state to insert after
416
+		* @return jQuery - the newly created state
417
+		*/
418
+		addState: function(statename, stateobj, afterState) {
419
+			var t = this,
420
+				state = '',
421
+				$state = null,
422
+				arrow = '',
423
+				title = '',
424
+				opts = t.options,
425
+				$jqistates = $('.'+ opts.prefix +'states'),
426
+				buttons = [],
427
+				showHtml,defbtn,k,v,l,i=0;
428
+
429
+			stateobj = $.extend({},Imp.defaults.state, {name:statename}, stateobj);
430
+
431
+			if(stateobj.position.arrow !== null){
432
+				arrow = '<div class="'+ opts.prefix + 'arrow '+ opts.prefix + 'arrow'+ stateobj.position.arrow +'"></div>';
433
+			}
434
+			if(stateobj.title && stateobj.title !== ''){
435
+				title = '<div class="lead '+ opts.prefix + 'title '+ opts.classes.title +'">'+  stateobj.title +'</div>';
436
+			}
437
+
438
+			showHtml = stateobj.html;
439
+			if (typeof stateobj.html === 'function') {
440
+				showHtml = 'Error: html function must return text';
441
+			}
442
+
443
+			state += '<div class="'+ opts.prefix + 'state" data-jqi-name="'+ statename +'" style="display:none;">'+
444
+						arrow + title +
445
+						'<div class="'+ opts.prefix +'message '+ opts.classes.message +'">' + showHtml +'</div>'+
446
+						'<div class="'+ opts.prefix +'buttons '+ opts.classes.buttons +'"'+ ($.isEmptyObject(stateobj.buttons)? 'style="display:none;"':'') +'>';
447
+
448
+			// state buttons may be in object or array, lets convert objects to arrays
449
+			if($.isArray(stateobj.buttons)){
450
+				buttons = stateobj.buttons;
451
+			}
452
+			else if($.isPlainObject(stateobj.buttons)){
453
+				for(k in stateobj.buttons){
454
+					if(stateobj.buttons.hasOwnProperty(k)){
455
+						buttons.push({ title: k, value: stateobj.buttons[k] });
456
+					}
457
+				}
458
+			}
459
+
460
+			// iterate over each button and create them
461
+			for(i=0, l=buttons.length; i<l; i++){
462
+				v = buttons[i],
463
+				defbtn = stateobj.focus === i || (isNaN(stateobj.focus) && stateobj.defaultButton === i) ? (opts.prefix + 'defaultbutton ' + opts.classes.defaultButton) : '';
464
+
465
+				state += '<button class="'+ opts.classes.button +' '+ opts.prefix + 'button '+ defbtn;
466
+
467
+				if(typeof v.classes !== "undefined"){
468
+					state += ' '+ ($.isArray(v.classes)? v.classes.join(' ') : v.classes) + ' ';
469
+				}
470
+
471
+				state += '" name="' + opts.prefix + '_' + statename + '_button' + v.title.replace(/[^a-z0-9]+/gi,'') + '" value="' + v.value + '">' + v.title + '</button>';
472
+			}
473
+			
474
+			state += '</div></div>';
475
+
476
+			$state = $(state);
477
+
478
+			$state.on('impromptu:submit', stateobj.submit);
479
+
480
+			if(afterState !== undefined){
481
+				$jqistates.find('[data-jqi-name="'+afterState+'"]').after($state);
482
+			}
483
+			else{
484
+				$jqistates.append($state);
485
+			}
486
+
487
+			t.options.states[statename] = stateobj;
488
+
489
+			return $state;
490
+		},
491
+
492
+		/**
493
+		* removeState - Removes a state from the prompt
494
+		* @param state String - Name of the state
495
+		* @param newState String - Name of the state to transition to
496
+		* @return Boolean - returns true on success, false on failure
497
+		*/
498
+		removeState: function(state, newState) {
499
+			var t = this,
500
+				$state = t.getState(state),
501
+				rm = function(){ $state.remove(); };
502
+
503
+			if($state.length === 0){
504
+				return false;
505
+			}
506
+
507
+			// transition away from it before deleting
508
+			if($state.css('display') !== 'none'){
509
+				if(newState !== undefined && t.getState(newState).length > 0){
510
+					t.goToState(newState, false, rm);
511
+				}
512
+				else if($state.next().length > 0){
513
+					t.nextState(rm);
514
+				}
515
+				else if($state.prev().length > 0){
516
+					t.prevState(rm);
517
+				}
518
+				else{
519
+					t.close();
520
+				}
521
+			}
522
+			else{
523
+				$state.slideUp('slow', rm);
524
+			}
525
+
526
+			return true;
527
+		},
528
+
529
+		/**
530
+		* getApi - Get the api, so you can extract it from $.prompt stack
531
+		* @return jQuery - the prompt
532
+		*/
533
+		getApi: function() {
534
+			return this;
535
+		},
536
+
537
+		/**
538
+		* getBox - Get the box containing fade and prompt
539
+		* @return jQuery - the prompt
540
+		*/
541
+		getBox: function() {
542
+			return this.jqib;
543
+		},
544
+
545
+		/**
546
+		* getPrompt - Get the prompt
547
+		* @return jQuery - the prompt
548
+		*/
549
+		getPrompt: function() {
550
+			return this.jqi;
551
+		},
552
+
553
+		/**
554
+		* getState - Get the state by its name
555
+		* @param statename String - Name of the state
556
+		* @return jQuery - the state
557
+		*/
558
+		getState: function(statename) {
559
+			return this.jqi.find('[data-jqi-name="'+ statename +'"]');
560
+		},
561
+
562
+		/**
563
+		* getCurrentState - Get the current visible state
564
+		* @return jQuery - the current visible state
565
+		*/
566
+		getCurrentState: function() {
567
+			return this.getState(this.getCurrentStateName());
568
+		},
569
+
570
+		/**
571
+		* getCurrentStateName - Get the name of the current visible state/substate
572
+		* @return String - the current visible state's name
573
+		*/
574
+		getCurrentStateName: function() {
575
+			return this.currentStateName;
576
+		},
577
+
578
+		/**
579
+		* position - Repositions the prompt (Used internally)
580
+		* @return void
581
+		*/
582
+		position: function(e){
583
+			var t = this,
584
+				restoreFx = $.fx.off,
585
+				$state = t.getCurrentState(),
586
+				stateObj = t.options.states[$state.data('jqi-name')],
587
+				pos = stateObj? stateObj.position : undefined,
588
+				$window = $(window),
589
+				bodyHeight = document.body.scrollHeight, //$(document.body).outerHeight(true),
590
+				windowHeight = $(window).height(),
591
+				documentHeight = $(document).height(),
592
+				height = bodyHeight > windowHeight ? bodyHeight : windowHeight,
593
+				top = parseInt($window.scrollTop(),10) + (t.options.top.toString().indexOf('%') >= 0?
594
+						(windowHeight*(parseInt(t.options.top,10)/100)) : parseInt(t.options.top,10));
595
+
596
+			// when resizing the window turn off animation
597
+			if(e !== undefined && e.data.animate === false){
598
+				$.fx.off = true;
599
+			}
600
+
601
+			t.jqib.css({
602
+				position: "absolute",
603
+				height: height,
604
+				width: "100%",
605
+				top: 0,
606
+				left: 0,
607
+				right: 0,
608
+				bottom: 0
609
+			});
610
+			t.jqif.css({
611
+				position: "fixed",
612
+				height: height,
613
+				width: "100%",
614
+				top: 0,
615
+				left: 0,
616
+				right: 0,
617
+				bottom: 0
618
+			});
619
+
620
+			// tour positioning
621
+			if(pos && pos.container){
622
+				var offset = $(pos.container).offset();
623
+
624
+				if($.isPlainObject(offset) && offset.top !== undefined){
625
+					t.jqi.css({
626
+						position: "absolute"
627
+					});
628
+					t.jqi.animate({
629
+						top: offset.top + pos.y,
630
+						left: offset.left + pos.x,
631
+						marginLeft: 0,
632
+						width: (pos.width !== undefined)? pos.width : null
633
+					});
634
+					top = (offset.top + pos.y) - (t.options.top.toString().indexOf('%') >= 0? (windowHeight*(parseInt(t.options.top,10)/100)) : parseInt(t.options.top,10));
635
+					$('html,body').animate({ scrollTop: top }, 'slow', 'swing', function(){});
636
+				}
637
+			}
638
+			// custom state width animation
639
+			else if(pos && pos.width){
640
+				t.jqi.css({
641
+						position: "absolute",
642
+						left: '50%'
643
+					});
644
+				t.jqi.animate({
645
+						top: pos.y || top,
646
+						left: pos.x || '50%',
647
+						marginLeft: ((pos.width/2)*-1),
648
+						width: pos.width
649
+					});
650
+			}
651
+			// standard prompt positioning
652
+			else{
653
+				t.jqi.css({
654
+					position: "absolute",
655
+					top: top,
656
+					left: '50%',//$window.width()/2,
657
+					marginLeft: ((t.jqi.outerWidth(false)/2)*-1)
658
+				});
659
+			}
660
+
661
+			// restore fx settings
662
+			if(e !== undefined && e.data.animate === false){
663
+				$.fx.off = restoreFx;
664
+			}
665
+		},
666
+
667
+		/**
668
+		* style - Restyles the prompt (Used internally)
669
+		* @return void
670
+		*/
671
+		style: function(){
672
+			var t = this;
673
+			
674
+			t.jqif.css({
675
+				zIndex: t.options.zIndex,
676
+				display: "none",
677
+				opacity: t.options.opacity
678
+			});
679
+			t.jqi.css({
680
+				zIndex: t.options.zIndex+1,
681
+				display: "none"
682
+			});
683
+			t.jqib.css({
684
+				zIndex: t.options.zIndex
685
+			});
686
+		},
687
+
688
+		/**
689
+		* goToState - Goto the specified state
690
+		* @param state String - name of the state to transition to
691
+		* @param subState Boolean - true to be a sub state within the currently open state
692
+		* @param callback Function - called when the transition is complete
693
+		* @return jQuery - the newly active state
694
+		*/
695
+		goToState: function(state, subState, callback) {
696
+			var t = this,
697
+				$jqi = t.jqi,
698
+				jqiopts = t.options,
699
+				$state = t.getState(state),
700
+				stateobj = jqiopts.states[$state.data('jqi-name')],
701
+				promptstatechanginge = new $.Event('impromptu:statechanging'),
702
+				opts = t.options;
703
+
704
+			if(stateobj !== undefined){
705
+
706
+
707
+				if (typeof stateobj.html === 'function') {
708
+					var contentLaterFunc = stateobj.html;
709
+					$state.find('.' + opts.prefix +'message ').html(contentLaterFunc());
710
+				}
711
+
712
+				// subState can be ommitted
713
+				if(typeof subState === 'function'){
714
+					callback = subState;
715
+					subState = false;
716
+				}
717
+
718
+				t.jqib.trigger(promptstatechanginge, [t.getCurrentStateName(), state]);
719
+
720
+				if(!promptstatechanginge.isDefaultPrevented() && $state.length > 0){
721
+					t.jqi.find('.'+ opts.prefix +'parentstate').removeClass(opts.prefix +'parentstate');
722
+
723
+					if(subState){ // hide any open substates
724
+						// get rid of any substates
725
+						t.jqi.find('.'+ opts.prefix +'substate').not($state)
726
+							.slideUp(jqiopts.promptspeed)
727
+							.removeClass('.'+ opts.prefix +'substate')
728
+							.find('.'+ opts.prefix +'arrow').hide();
729
+
730
+						// add parent state class so it can be visible, but blocked
731
+						t.jqi.find('.'+ opts.prefix +'state:visible').addClass(opts.prefix +'parentstate');
732
+
733
+						// add substate class so we know it will be smaller
734
+						$state.addClass(opts.prefix +'substate');
735
+					}
736
+					else{ // hide any open states
737
+						t.jqi.find('.'+ opts.prefix +'state').not($state)
738
+							.slideUp(jqiopts.promptspeed)
739
+							.find('.'+ opts.prefix +'arrow').hide();
740
+					}
741
+					t.currentStateName = stateobj.name;
742
+
743
+					$state.slideDown(jqiopts.promptspeed,function(){
744
+						var $t = $(this);
745
+
746
+						// if focus is a selector, find it, else its button index
747
+						if(typeof(stateobj.focus) === 'string'){
748
+							$t.find(stateobj.focus).eq(0).focus();
749
+						}
750
+						else{
751
+							$t.find('.'+ opts.prefix +'defaultbutton').focus();
752
+						}
753
+
754
+						$t.find('.'+ opts.prefix +'arrow').show(jqiopts.promptspeed);
755
+
756
+						if (typeof callback === 'function'){
757
+							t.jqib.on('impromptu:statechanged', callback);
758
+						}
759
+						t.jqib.trigger('impromptu:statechanged', [state]);
760
+						if (typeof callback === 'function'){
761
+							t.jqib.off('impromptu:statechanged', callback);
762
+						}
763
+					});
764
+					if(!subState){
765
+						t.position();
766
+					}
767
+				} // end isDefaultPrevented()	
768
+			}// end stateobj !== undefined
769
+
770
+			return $state;
771
+		},
772
+
773
+		/**
774
+		* nextState - Transition to the next state
775
+		* @param callback Function - called when the transition is complete
776
+		* @return jQuery - the newly active state
777
+		*/
778
+		nextState: function(callback) {
779
+			var t = this,
780
+				$next = t.getCurrentState().next();
781
+			if($next.length > 0){
782
+				t.goToState( $next.data('jqi-name'), callback );
783
+			}
784
+			return $next;
785
+		},
786
+
787
+		/**
788
+		* prevState - Transition to the previous state
789
+		* @param callback Function - called when the transition is complete
790
+		* @return jQuery - the newly active state
791
+		*/
792
+		prevState: function(callback) {
793
+			var t = this,
794
+				$prev = t.getCurrentState().prev();
795
+			if($prev.length > 0){
796
+				t.goToState( $prev.data('jqi-name'), callback );
797
+			}
798
+			return $prev;
799
+		}
800
+
801
+	};
802
+
803
+	// ########################################################################
804
+	// $.prompt will manage a queue of Impromptu instances
805
+	// ########################################################################
806
+
807
+	/**
808
+	* $.prompt create a new Impromptu instance and push it on the stack of instances
809
+	* @param message String/Object - String of html or Object of states
810
+	* @param options Object - Options to set the prompt
811
+	* @return jQuery - the jQuery object of the prompt within the modal
812
+	*/
813
+	$.prompt = function(message, options){
814
+		var api = new Imp(message, options);
815
+		return api.jqi;
816
+	};
817
+
818
+	/**
819
+	* Copy over static methods
820
+	*/
821
+	$.each(Imp, function(k,v){
822
+		$.prompt[k] = v;
823
+	});
824
+
825
+	/**
826
+	* Create a proxy for accessing all instance methods. The close method pops from queue.
827
+	*/
828
+	$.each(Imp.prototype, function(k,v){
829
+		$.prompt[k] = function(){
830
+			var api = Imp.getLast(); // always use the last instance on the stack
831
+
832
+			if(api && typeof api[k] === "function"){
833
+				return api[k].apply(api, arguments);
834
+			}
835
+		};
836
+	});
837
+
838
+	// ########################################################################
839
+	// jQuery Plugin and public access
840
+	// ########################################################################
841
+
842
+	/**
843
+	* Enable using $('.selector').prompt({});
844
+	* This will grab the html within the prompt as the prompt message
845
+	*/
846
+	$.fn.prompt = function(options){
847
+		if(options === undefined){
848
+			options = {};
849
+		}
850
+		if(options.withDataAndEvents === undefined){
851
+			options.withDataAndEvents = false;
852
+		}
853
+
854
+		$.prompt($(this).clone(options.withDataAndEvents).html(),options);
855
+	};
856
+
857
+	/**
858
+	* Export it as Impromptu and $.prompt
859
+	* Can be used from here forth as new Impromptu(states, opts)
860
+	*/
861
+	window.Impromptu = Imp;
862
+
863
+}));

+ 15008
- 0
libs/jquery-ui.js
File diff suppressed because it is too large
View File


+ 250
- 0
libs/jquery.autosize.js View File

1
+/*!
2
+	Autosize v1.18.1 - 2013-11-05
3
+	Automatically adjust textarea height based on user input.
4
+	(c) 2013 Jack Moore - http://www.jacklmoore.com/autosize
5
+	license: http://www.opensource.org/licenses/mit-license.php
6
+*/
7
+(function ($) {
8
+	var
9
+	defaults = {
10
+		className: 'autosizejs',
11
+		append: '',
12
+		callback: false,
13
+		resizeDelay: 10
14
+	},
15
+
16
+	// border:0 is unnecessary, but avoids a bug in Firefox on OSX
17
+	copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
18
+
19
+	// line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
20
+	typographyStyles = [
21
+		'fontFamily',
22
+		'fontSize',
23
+		'fontWeight',
24
+		'fontStyle',
25
+		'letterSpacing',
26
+		'textTransform',
27
+		'wordSpacing',
28
+		'textIndent'
29
+	],
30
+
31
+	// to keep track which textarea is being mirrored when adjust() is called.
32
+	mirrored,
33
+
34
+	// the mirror element, which is used to calculate what size the mirrored element should be.
35
+	mirror = $(copy).data('autosize', true)[0];
36
+
37
+	// test that line-height can be accurately copied.
38
+	mirror.style.lineHeight = '99px';
39
+	if ($(mirror).css('lineHeight') === '99px') {
40
+		typographyStyles.push('lineHeight');
41
+	}
42
+	mirror.style.lineHeight = '';
43
+
44
+	$.fn.autosize = function (options) {
45
+		if (!this.length) {
46
+			return this;
47
+		}
48
+
49
+		options = $.extend({}, defaults, options || {});
50
+
51
+		if (mirror.parentNode !== document.body) {
52
+			$(document.body).append(mirror);
53
+		}
54
+
55
+		return this.each(function () {
56
+			var
57
+			ta = this,
58
+			$ta = $(ta),
59
+			maxHeight,
60
+			minHeight,
61
+			boxOffset = 0,
62
+			callback = $.isFunction(options.callback),
63
+			originalStyles = {
64
+				height: ta.style.height,
65
+				overflow: ta.style.overflow,
66
+				overflowY: ta.style.overflowY,
67
+				wordWrap: ta.style.wordWrap,
68
+				resize: ta.style.resize
69
+			},
70
+			timeout,
71
+			width = $ta.width();
72
+
73
+			if ($ta.data('autosize')) {
74
+				// exit if autosize has already been applied, or if the textarea is the mirror element.
75
+				return;
76
+			}
77
+			$ta.data('autosize', true);
78
+
79
+			if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
80
+				boxOffset = $ta.outerHeight() - $ta.height();
81
+			}
82
+
83
+			// IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
84
+			minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
85
+
86
+			$ta.css({
87
+				overflow: 'hidden',
88
+				overflowY: 'hidden',
89
+				wordWrap: 'break-word', // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
90
+				resize: ($ta.css('resize') === 'none' || $ta.css('resize') === 'vertical') ? 'none' : 'horizontal'
91
+			});
92
+
93
+			// The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
94
+			function setWidth() {
95
+				var style, width;
96
+				
97
+				if ('getComputedStyle' in window) {
98
+					style = window.getComputedStyle(ta, null);
99
+					width = ta.getBoundingClientRect().width;
100
+
101
+					$.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
102
+						width -= parseInt(style[val],10);
103
+					});
104
+
105
+					mirror.style.width = width + 'px';
106
+				}
107
+				else {
108
+					// window.getComputedStyle, getBoundingClientRect returning a width are unsupported and unneeded in IE8 and lower.
109
+					mirror.style.width = Math.max($ta.width(), 0) + 'px';
110
+				}
111
+			}
112
+
113
+			function initMirror() {
114
+				var styles = {};
115
+
116
+				mirrored = ta;
117
+				mirror.className = options.className;
118
+				maxHeight = parseInt($ta.css('maxHeight'), 10);
119
+
120
+				// mirror is a duplicate textarea located off-screen that
121
+				// is automatically updated to contain the same text as the
122
+				// original textarea.  mirror always has a height of 0.
123
+				// This gives a cross-browser supported way getting the actual
124
+				// height of the text, through the scrollTop property.
125
+				$.each(typographyStyles, function(i,val){
126
+					styles[val] = $ta.css(val);
127
+				});
128
+				$(mirror).css(styles);
129
+
130
+				setWidth();
131
+
132
+				// Chrome-specific fix:
133
+				// When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
134
+				// made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
135
+				if (window.chrome) {
136
+					var width = ta.style.width;
137
+					ta.style.width = '0px';
138
+					var ignore = ta.offsetWidth;
139
+					ta.style.width = width;
140
+				}
141
+			}
142
+
143
+			// Using mainly bare JS in this function because it is going
144
+			// to fire very often while typing, and needs to very efficient.
145
+			function adjust() {
146
+				var height, original;
147
+
148
+				if (mirrored !== ta) {
149
+					initMirror();
150
+				} else {
151
+					setWidth();
152
+				}
153
+
154
+				mirror.value = ta.value + options.append;
155
+				mirror.style.overflowY = ta.style.overflowY;
156
+				original = parseInt(ta.style.height,10);
157
+
158
+				// Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
159
+				mirror.scrollTop = 0;
160
+
161
+				mirror.scrollTop = 9e4;
162
+
163
+				// Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
164
+				height = mirror.scrollTop;
165
+
166
+				if (maxHeight && height > maxHeight) {
167
+					ta.style.overflowY = 'scroll';
168
+					height = maxHeight;
169
+				} else {
170
+					ta.style.overflowY = 'hidden';
171
+					if (height < minHeight) {
172
+						height = minHeight;
173
+					}
174
+				}
175
+
176
+				height += boxOffset;
177
+
178
+				if (original !== height) {
179
+					ta.style.height = height + 'px';
180
+					if (callback) {
181
+						options.callback.call(ta,ta);
182
+					}
183
+				}
184
+			}
185
+
186
+			function resize () {
187
+				clearTimeout(timeout);
188
+				timeout = setTimeout(function(){
189
+					var newWidth = $ta.width();
190
+
191
+					if (newWidth !== width) {
192
+						width = newWidth;
193
+						adjust();
194
+					}
195
+				}, parseInt(options.resizeDelay,10));
196
+			}
197
+
198
+			if ('onpropertychange' in ta) {
199
+				if ('oninput' in ta) {
200
+					// Detects IE9.  IE9 does not fire onpropertychange or oninput for deletions,
201
+					// so binding to onkeyup to catch most of those occasions.  There is no way that I
202
+					// know of to detect something like 'cut' in IE9.
203
+					$ta.on('input.autosize keyup.autosize', adjust);
204
+				} else {
205
+					// IE7 / IE8
206
+					$ta.on('propertychange.autosize', function(){
207
+						if(event.propertyName === 'value'){
208
+							adjust();
209
+						}
210
+					});
211
+				}
212
+			} else {
213
+				// Modern Browsers
214
+				$ta.on('input.autosize', adjust);
215
+			}
216
+
217
+			// Set options.resizeDelay to false if using fixed-width textarea elements.
218
+			// Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
219
+
220
+			if (options.resizeDelay !== false) {
221
+				$(window).on('resize.autosize', resize);
222
+			}
223
+
224
+			// Event for manual triggering if needed.
225
+			// Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
226
+			$ta.on('autosize.resize', adjust);
227
+
228
+			// Event for manual triggering that also forces the styles to update as well.
229
+			// Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
230
+			$ta.on('autosize.resizeIncludeStyle', function() {
231
+				mirrored = null;
232
+				adjust();
233
+			});
234
+
235
+			$ta.on('autosize.destroy', function(){
236
+				mirrored = null;
237
+				clearTimeout(timeout);
238
+				$(window).off('resize', resize);
239
+				$ta
240
+					.off('autosize')
241
+					.off('.autosize')
242
+					.css(originalStyles)
243
+					.removeData('autosize');
244
+			});
245
+
246
+			// Call adjust in case the textarea already contains text.
247
+			adjust();
248
+		});
249
+	};
250
+}(window.jQuery || window.$)); // jQuery or jQuery-like library, such as Zepto

+ 110
- 0
libs/popover.js View File

1
+/* ========================================================================
2
+ * Bootstrap: popover.js v3.1.1
3
+ * http://getbootstrap.com/javascript/#popovers
4
+ * ========================================================================
5
+ * Copyright 2011-2014 Twitter, Inc.
6
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7
+ * ======================================================================== */
8
+
9
+
10
++function ($) {
11
+  'use strict';
12
+
13
+  // POPOVER PUBLIC CLASS DEFINITION
14
+  // ===============================
15
+
16
+  var Popover = function (element, options) {
17
+    this.init('popover', element, options)
18
+  }
19
+
20
+  if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
21
+
22
+  Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
23
+    placement: 'right',
24
+    trigger: 'click',
25
+    content: '',
26
+    template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
27
+  })
28
+
29
+
30
+  // NOTE: POPOVER EXTENDS tooltip.js
31
+  // ================================
32
+
33
+  Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
34
+
35
+  Popover.prototype.constructor = Popover
36
+
37
+  Popover.prototype.getDefaults = function () {
38
+    return Popover.DEFAULTS
39
+  }
40
+
41
+  Popover.prototype.setContent = function () {
42
+    var $tip    = this.tip()
43
+    var title   = this.getTitle()
44
+    var content = this.getContent()
45
+
46
+    $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
47
+    $tip.find('.popover-content')[ // we use append for html objects to maintain js events
48
+      this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
49
+    ](content)
50
+
51
+    $tip.removeClass('fade top bottom left right in')
52
+
53
+    // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
54
+    // this manually by checking the contents.
55
+    if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
56
+  }
57
+
58
+  Popover.prototype.hasContent = function () {
59
+    return this.getTitle() || this.getContent()
60
+  }
61
+
62
+  Popover.prototype.getContent = function () {
63
+    var $e = this.$element
64
+    var o  = this.options
65
+
66
+    return $e.attr('data-content')
67
+      || (typeof o.content == 'function' ?
68
+            o.content.call($e[0]) :
69
+            o.content)
70
+  }
71
+
72
+  Popover.prototype.arrow = function () {
73
+    return this.$arrow = this.$arrow || this.tip().find('.arrow')
74
+  }
75
+
76
+  Popover.prototype.tip = function () {
77
+    if (!this.$tip) this.$tip = $(this.options.template)
78
+    return this.$tip
79
+  }
80
+
81
+
82
+  // POPOVER PLUGIN DEFINITION
83
+  // =========================
84
+
85
+  var old = $.fn.popover
86
+
87
+  $.fn.popover = function (option) {
88
+    return this.each(function () {
89
+      var $this   = $(this)
90
+      var data    = $this.data('bs.popover')
91
+      var options = typeof option == 'object' && option
92
+
93
+      if (!data && option == 'destroy') return
94
+      if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
95
+      if (typeof option == 'string') data[option]()
96
+    })
97
+  }
98
+
99
+  $.fn.popover.Constructor = Popover
100
+
101
+
102
+  // POPOVER NO CONFLICT
103
+  // ===================
104
+
105
+  $.fn.popover.noConflict = function () {
106
+    $.fn.popover = old
107
+    return this
108
+  }
109
+
110
+}(jQuery);

+ 342
- 0
libs/toastr.js View File

1
+/*
2
+ * Toastr
3
+ * Copyright 2012-2014 John Papa and Hans Fjällemark.
4
+ * All Rights Reserved.
5
+ * Use, reproduction, distribution, and modification of this code is subject to the terms and
6
+ * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
7
+ *
8
+ * Author: John Papa and Hans Fjällemark
9
+ * ARIA Support: Greta Krafsig
10
+ * Project: https://github.com/CodeSeven/toastr
11
+ */
12
+; (function (define) {
13
+    define(['jquery'], function ($) {
14
+        return (function () {
15
+            var $container;
16
+            var listener;
17
+            var toastId = 0;
18
+            var toastType = {
19
+                error: 'error',
20
+                info: 'info',
21
+                success: 'success',
22
+                warning: 'warning'
23
+            };
24
+
25
+            var toastr = {
26
+                clear: clear,
27
+                remove: remove,
28
+                error: error,
29
+                getContainer: getContainer,
30
+                info: info,
31
+                options: {},
32
+                subscribe: subscribe,
33
+                success: success,
34
+                version: '2.0.3',
35
+                warning: warning
36
+            };
37
+
38
+            return toastr;
39
+
40
+            //#region Accessible Methods
41
+            function error(message, title, optionsOverride) {
42
+                return notify({
43
+                    type: toastType.error,
44
+                    iconClass: getOptions().iconClasses.error,
45
+                    message: message,
46
+                    optionsOverride: optionsOverride,
47
+                    title: title
48
+                });
49
+            }
50
+
51
+            function getContainer(options, create) {
52
+                if (!options) { options = getOptions(); }
53
+                $container = $('#' + options.containerId);
54
+                if ($container.length) {
55
+                    return $container;
56
+                }
57
+                if(create) {
58
+                    $container = createContainer(options);
59
+                }
60
+                return $container;
61
+            }
62
+
63
+            function info(message, title, optionsOverride) {
64
+                return notify({
65
+                    type: toastType.info,
66
+                    iconClass: getOptions().iconClasses.info,
67
+                    message: message,
68
+                    optionsOverride: optionsOverride,
69
+                    title: title
70
+                });
71
+            }
72
+
73
+            function subscribe(callback) {
74
+                listener = callback;
75
+            }
76
+
77
+            function success(message, title, optionsOverride) {
78
+                return notify({
79
+                    type: toastType.success,
80
+                    iconClass: getOptions().iconClasses.success,
81
+                    message: message,
82
+                    optionsOverride: optionsOverride,
83
+                    title: title
84
+                });
85
+            }
86
+
87
+            function warning(message, title, optionsOverride) {
88
+                return notify({
89
+                    type: toastType.warning,
90
+                    iconClass: getOptions().iconClasses.warning,
91
+                    message: message,
92
+                    optionsOverride: optionsOverride,
93
+                    title: title
94
+                });
95
+            }
96
+
97
+            function clear($toastElement) {
98
+                var options = getOptions();
99
+                if (!$container) { getContainer(options); }
100
+                if (!clearToast($toastElement, options)) {
101
+                    clearContainer(options);
102
+                }
103
+            }
104
+
105
+            function remove($toastElement) {
106
+                var options = getOptions();
107
+                if (!$container) { getContainer(options); }
108
+                if ($toastElement && $(':focus', $toastElement).length === 0) {
109
+                    removeToast($toastElement);
110
+                    return;
111
+                }
112
+                if ($container.children().length) {
113
+                    $container.remove();
114
+                }
115
+            }
116
+            //#endregion
117
+
118
+            //#region Internal Methods
119
+
120
+            function clearContainer(options){
121
+                var toastsToClear = $container.children();
122
+                for (var i = toastsToClear.length - 1; i >= 0; i--) {
123
+                    clearToast($(toastsToClear[i]), options);
124
+                };
125
+            }
126
+
127
+            function clearToast($toastElement, options){
128
+                if ($toastElement && $(':focus', $toastElement).length === 0) {
129
+                    $toastElement[options.hideMethod]({
130
+                        duration: options.hideDuration,
131
+                        easing: options.hideEasing,
132
+                        complete: function () { removeToast($toastElement); }
133
+                    });
134
+                    return true;
135
+                }
136
+                return false;
137
+            }
138
+
139
+            function createContainer(options) {
140
+                $container = $('<div/>')
141
+                    .attr('id', options.containerId)
142
+                    .addClass(options.positionClass)
143
+                    .attr('aria-live', 'polite')
144
+                    .attr('role', 'alert');
145
+
146
+                $container.appendTo($(options.target));
147
+                return $container;
148
+            }
149
+
150
+            function getDefaults() {
151
+                return {
152
+                    tapToDismiss: true,
153
+                    toastClass: 'toast',
154
+                    containerId: 'toast-container',
155
+                    debug: false,
156
+
157
+                    showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
158
+                    showDuration: 300,
159
+                    showEasing: 'swing', //swing and linear are built into jQuery
160
+                    onShown: undefined,
161
+                    hideMethod: 'fadeOut',
162
+                    hideDuration: 1000,
163
+                    hideEasing: 'swing',
164
+                    onHidden: undefined,
165
+
166
+                    extendedTimeOut: 1000,
167
+                    iconClasses: {
168
+                        error: 'toast-error',
169
+                        info: 'toast-info',
170
+                        success: 'toast-success',
171
+                        warning: 'toast-warning'
172
+                    },
173
+                    iconClass: 'toast-info',
174
+                    positionClass: 'toast-top-right',
175
+                    timeOut: 5000, // Set timeOut and extendedTimeout to 0 to make it sticky
176
+                    titleClass: 'toast-title',
177
+                    messageClass: 'toast-message',
178
+                    target: 'body',
179
+                    closeHtml: '<button>&times;</button>',
180
+                    newestOnTop: true
181
+                };
182
+            }
183
+
184
+            function publish(args) {
185
+                if (!listener) { return; }
186
+                listener(args);
187
+            }
188
+
189
+            function notify(map) {
190
+                var options = getOptions(),
191
+                    iconClass = map.iconClass || options.iconClass;
192
+
193
+                if (typeof (map.optionsOverride) !== 'undefined') {
194
+                    options = $.extend(options, map.optionsOverride);
195
+                    iconClass = map.optionsOverride.iconClass || iconClass;
196
+                }
197
+
198
+                toastId++;
199
+
200
+                $container = getContainer(options, true);
201
+                var intervalId = null,
202
+                    $toastElement = $('<div/>'),
203
+                    $titleElement = $('<div/>'),
204
+                    $messageElement = $('<div/>'),
205
+                    $closeElement = $(options.closeHtml),
206
+                    response = {
207
+                        toastId: toastId,
208
+                        state: 'visible',
209
+                        startTime: new Date(),
210
+                        options: options,
211
+                        map: map
212
+                    };
213
+
214
+                if (map.iconClass) {
215
+                    $toastElement.addClass(options.toastClass).addClass(iconClass);
216
+                }
217
+
218
+                if (map.title) {
219
+                    $titleElement.append(map.title).addClass(options.titleClass);
220
+                    $toastElement.append($titleElement);
221
+                }
222
+
223
+                if (map.message) {
224
+                    $messageElement.append(map.message).addClass(options.messageClass);
225
+                    $toastElement.append($messageElement);
226
+                }
227
+
228
+                if (options.closeButton) {
229
+                    $closeElement.addClass('toast-close-button').attr("role", "button");
230
+                    $toastElement.prepend($closeElement);
231
+                }
232
+
233
+                if (options.reposition) {
234
+                    options.reposition();
235
+                }
236
+
237
+                $toastElement.hide();
238
+                if (options.newestOnTop) {
239
+                    $container.prepend($toastElement);
240
+                } else {
241
+                    $container.append($toastElement);
242
+                }
243
+
244
+
245
+                $toastElement[options.showMethod](
246
+                    { duration: options.showDuration, easing: options.showEasing, complete: options.onShown }
247
+                );
248
+
249
+                if (options.timeOut > 0) {
250
+                    intervalId = setTimeout(hideToast, options.timeOut);
251
+                }
252
+
253
+                $toastElement.hover(stickAround, delayedHideToast);
254
+                if (!options.onclick && options.tapToDismiss) {
255
+                    $toastElement.click(hideToast);
256
+                }
257
+
258
+                if (options.closeButton && $closeElement) {
259
+                    $closeElement.click(function (event) {
260
+                        if( event.stopPropagation ) {
261
+                            event.stopPropagation();
262
+                        } else if( event.cancelBubble !== undefined && event.cancelBubble !== true ) {
263
+                            event.cancelBubble = true;
264
+                        }
265
+                        hideToast(true);
266
+                    });
267
+                }
268
+
269
+                if (options.onclick) {
270
+                    $toastElement.click(function () {
271
+                        options.onclick();
272
+                        hideToast();
273
+                    });
274
+                }
275
+
276
+                publish(response);
277
+
278
+                if (options.debug && console) {
279
+                    console.log(response);
280
+                }
281
+
282
+                return $toastElement;
283
+
284
+                function hideToast(override) {
285
+                    if ($(':focus', $toastElement).length && !override) {
286
+                        return;
287
+                    }
288
+                    return $toastElement[options.hideMethod]({
289
+                        duration: options.hideDuration,
290
+                        easing: options.hideEasing,
291
+                        complete: function () {
292
+                            removeToast($toastElement);
293
+                            if (options.onHidden && response.state !== 'hidden') {
294
+                                options.onHidden();
295
+                            }
296
+                            response.state = 'hidden';
297
+                            response.endTime = new Date();
298
+                            publish(response);
299
+                        }
300
+                    });
301
+                }
302
+
303
+                function delayedHideToast() {
304
+                    if (options.timeOut > 0 || options.extendedTimeOut > 0) {
305
+                        intervalId = setTimeout(hideToast, options.extendedTimeOut);
306
+                    }
307
+                }
308
+
309
+                function stickAround() {
310
+                    clearTimeout(intervalId);
311
+                    $toastElement.stop(true, true)[options.showMethod](
312
+                        { duration: options.showDuration, easing: options.showEasing }
313
+                    );
314
+                }
315
+            }
316
+
317
+            function getOptions() {
318
+                return $.extend({}, getDefaults(), toastr.options);
319
+            }
320
+
321
+            function removeToast($toastElement) {
322
+                if (!$container) { $container = getContainer(); }
323
+                if ($toastElement.is(':visible')) {
324
+                    return;
325
+                }
326
+                $toastElement.remove();
327
+                $toastElement = null;
328
+                if ($container.children().length === 0) {
329
+                    $container.remove();
330
+                }
331
+            }
332
+            //#endregion
333
+
334
+        })();
335
+    });
336
+}(typeof define === 'function' && define.amd ? define : function (deps, factory) {
337
+    if (typeof module !== 'undefined' && module.exports) { //Node
338
+        module.exports = factory(require('jquery'));
339
+    } else {
340
+        window['toastr'] = factory(window['jQuery']);
341
+    }
342
+}));

+ 422
- 0
libs/tooltip.js View File

1
+/* ========================================================================
2
+ * Bootstrap: tooltip.js v3.1.1
3
+ * http://getbootstrap.com/javascript/#tooltip
4
+ * Inspired by the original jQuery.tipsy by Jason Frame
5
+ * ========================================================================
6
+ * Copyright 2011-2014 Twitter, Inc.
7
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
8
+ * ======================================================================== */
9
+
10
+
11
++function ($) {
12
+  'use strict';
13
+
14
+  // TOOLTIP PUBLIC CLASS DEFINITION
15
+  // ===============================
16
+
17
+  var Tooltip = function (element, options) {
18
+    this.type       =
19
+    this.options    =
20
+    this.enabled    =
21
+    this.timeout    =
22
+    this.hoverState =
23
+    this.$element   = null
24
+
25
+    this.init('tooltip', element, options)
26
+  }
27
+
28
+  Tooltip.DEFAULTS = {
29
+    animation: true,
30
+    placement: 'top',
31
+    selector: false,
32
+    template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
33
+    trigger: 'hover focus',
34
+    title: '',
35
+    delay: 0,
36
+    html: false,
37
+    container: false
38
+  }
39
+
40
+  Tooltip.prototype.init = function (type, element, options) {
41
+    this.enabled  = true
42
+    this.type     = type
43
+    this.$element = $(element)
44
+    this.options  = this.getOptions(options)
45
+
46
+    var triggers = this.options.trigger.split(' ')
47
+
48
+    for (var i = triggers.length; i--;) {
49
+      var trigger = triggers[i]
50
+
51
+      if (trigger == 'click') {
52
+        this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
53
+      } else if (trigger != 'manual') {
54
+        var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focusin'
55
+        var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
56
+
57
+        this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
58
+        this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
59
+      }
60
+    }
61
+
62
+    this.options.selector ?
63
+      (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
64
+      this.fixTitle()
65
+  }
66
+
67
+  Tooltip.prototype.getDefaults = function () {
68
+    return Tooltip.DEFAULTS
69
+  }
70
+
71
+  Tooltip.prototype.getOptions = function (options) {
72
+    options = $.extend({}, this.getDefaults(), this.$element.data(), options)
73
+
74
+    if (options.delay && typeof options.delay == 'number') {
75
+      options.delay = {
76
+        show: options.delay,
77
+        hide: options.delay
78
+      }
79
+    }
80
+
81
+    return options
82
+  }
83
+
84
+  Tooltip.prototype.getDelegateOptions = function () {
85
+    var options  = {}
86
+    var defaults = this.getDefaults()
87
+
88
+    this._options && $.each(this._options, function (key, value) {
89
+      if (defaults[key] != value) options[key] = value
90
+    })
91
+
92
+    return options
93
+  }
94
+
95
+  Tooltip.prototype.enter = function (obj) {
96
+    var self = obj instanceof this.constructor ?
97
+      obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
98
+
99
+    clearTimeout(self.timeout)
100
+
101
+    self.hoverState = 'in'
102
+
103
+    if (!self.options.delay || !self.options.delay.show) return self.show()
104
+
105
+    self.timeout = setTimeout(function () {
106
+      if (self.hoverState == 'in') self.show()
107
+    }, self.options.delay.show)
108
+  }
109
+
110
+  Tooltip.prototype.leave = function (obj) {
111
+    var self = obj instanceof this.constructor ?
112
+      obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
113
+
114
+    clearTimeout(self.timeout)
115
+
116
+    self.hoverState = 'out'
117
+
118
+    if (!self.options.delay || !self.options.delay.hide) return self.hide()
119
+
120
+    self.timeout = setTimeout(function () {
121
+      if (self.hoverState == 'out') self.hide()
122
+    }, self.options.delay.hide)
123
+  }
124
+
125
+  Tooltip.prototype.show = function () {
126
+    var e = $.Event('show.bs.' + this.type)
127
+
128
+    if (this.hasContent() && this.enabled) {
129
+      this.$element.trigger(e)
130
+
131
+      if (e.isDefaultPrevented()) return
132
+      var that = this;
133
+
134
+      var $tip = this.tip()
135
+
136
+      this.setContent()
137
+
138
+      if (this.options.animation) $tip.addClass('fade')
139
+
140
+      var placement = typeof this.options.placement == 'function' ?
141
+        this.options.placement.call(this, $tip[0], this.$element[0]) :
142
+        this.options.placement
143
+
144
+      var autoToken = /\s?auto?\s?/i
145
+      var autoPlace = autoToken.test(placement)
146
+      if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
147
+
148
+      $tip
149
+        .detach()
150
+        .css({ top: 0, left: 0, display: 'block' })
151
+        .addClass(placement)
152
+
153
+      this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
154
+
155
+      var pos          = this.getPosition()
156
+      var actualWidth  = $tip[0].offsetWidth
157
+      var actualHeight = $tip[0].offsetHeight
158
+
159
+      if (autoPlace) {
160
+        var $parent = this.$element.parent()
161
+
162
+        var orgPlacement = placement
163
+        var docScroll    = document.documentElement.scrollTop || document.body.scrollTop
164
+        var parentWidth  = this.options.container == 'body' ? window.innerWidth  : $parent.outerWidth()
165
+        var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
166
+        var parentLeft   = this.options.container == 'body' ? 0 : $parent.offset().left
167
+
168
+        placement = placement == 'bottom' && pos.top   + pos.height  + actualHeight - docScroll > parentHeight  ? 'top'    :
169
+                    placement == 'top'    && pos.top   - docScroll   - actualHeight < 0                         ? 'bottom' :
170
+                    placement == 'right'  && pos.right + actualWidth > parentWidth                              ? 'left'   :
171
+                    placement == 'left'   && pos.left  - actualWidth < parentLeft                               ? 'right'  :
172
+                    placement
173
+
174
+        $tip
175
+          .removeClass(orgPlacement)
176
+          .addClass(placement)
177
+      }
178
+
179
+      var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
180
+
181
+      this.applyPlacement(calculatedOffset, placement)
182
+      this.hoverState = null
183
+
184
+      var complete = function() {
185
+        that.$element.trigger('shown.bs.' + that.type)
186
+      }
187
+
188
+      var deltas = {
189
+          "bottom": $tip[0].getBoundingClientRect().bottom - window.innerHeight,
190
+          "right": $tip[0].getBoundingClientRect().right - window.innerWidth,
191
+          "left": -$tip[0].getBoundingClientRect().left,
192
+          "top": -$tip[0].getBoundingClientRect().top
193
+      };
194
+      for(var direction in deltas) {
195
+          if (deltas[direction] > 0) {
196
+              var delta = deltas[direction];
197
+              if(direction === "right" || direction === "bottom") {
198
+                  delta = -delta;
199
+              }
200
+              direction = direction === "top" || direction === "bottom" ? "top" : "left";
201
+              var currentPosition = parseInt($tip.css(direction), 10);
202
+              $tip.css(direction, currentPosition + delta);
203
+              if(direction === "left") {
204
+                  $tip.children(".arrow").css(direction, parseInt($tip.children(".arrow").css(direction), 10) - delta);
205
+              } else {
206
+                  $tip.children(".arrow").css(direction, 50 - $tip[0].getBoundingClientRect().height / delta + "%");
207
+              }
208
+          }
209
+      }
210
+
211
+      $.support.transition && this.$tip.hasClass('fade') ?
212
+        $tip
213
+          .one($.support.transition.end, complete)
214
+          .emulateTransitionEnd(150) :
215
+        complete()
216
+    }
217
+  }
218
+
219
+  Tooltip.prototype.applyPlacement = function (offset, placement) {
220
+    var replace
221
+    var $tip   = this.tip()
222
+    var width  = $tip[0].offsetWidth
223
+    var height = $tip[0].offsetHeight
224
+
225
+    // manually read margins because getBoundingClientRect includes difference
226
+    var marginTop = parseInt($tip.css('margin-top'), 10)
227
+    var marginLeft = parseInt($tip.css('margin-left'), 10)
228
+
229
+    // we must check for NaN for ie 8/9
230
+    if (isNaN(marginTop))  marginTop  = 0
231
+    if (isNaN(marginLeft)) marginLeft = 0
232
+
233
+    offset.top  = offset.top  + marginTop
234
+    offset.left = offset.left + marginLeft
235
+
236
+    // $.fn.offset doesn't round pixel values
237
+    // so we use setOffset directly with our own function B-0
238
+    $.offset.setOffset($tip[0], $.extend({
239
+      using: function (props) {
240
+        $tip.css({
241
+          top: Math.round(props.top),
242
+          left: Math.round(props.left)
243
+        })
244
+      }
245
+    }, offset), 0)
246
+
247
+    $tip.addClass('in')
248
+
249
+    // check to see if placing tip in new offset caused the tip to resize itself
250
+    var actualWidth  = $tip[0].offsetWidth
251
+    var actualHeight = $tip[0].offsetHeight
252
+
253
+    if (placement == 'top' && actualHeight != height) {
254
+      replace = true
255
+      offset.top = offset.top + height - actualHeight
256
+    }
257
+
258
+    if (/bottom|top/.test(placement)) {
259
+      var delta = 0
260
+
261
+      if (offset.left < 0) {
262
+        delta       = offset.left * -2
263
+        offset.left = 0
264
+
265
+        $tip.offset(offset)
266
+
267
+        actualWidth  = $tip[0].offsetWidth
268
+        actualHeight = $tip[0].offsetHeight
269
+      }
270
+
271
+      this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
272
+    } else {
273
+      this.replaceArrow(actualHeight - height, actualHeight, 'top')
274
+    }
275
+
276
+    if (replace) $tip.offset(offset)
277
+  }
278
+
279
+  Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
280
+    this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
281
+  }
282
+
283
+  Tooltip.prototype.setContent = function () {
284
+    var $tip  = this.tip()
285
+    var title = this.getTitle()
286
+
287
+    $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
288
+    $tip.removeClass('fade in top bottom left right')
289
+  }
290
+
291
+  Tooltip.prototype.hide = function () {
292
+    var that = this
293
+    var $tip = this.tip()
294
+    var e    = $.Event('hide.bs.' + this.type)
295
+
296
+    function complete() {
297
+      if (that.hoverState != 'in') $tip.detach()
298
+      that.$element.trigger('hidden.bs.' + that.type)
299
+    }
300
+
301
+    this.$element.trigger(e)
302
+
303
+    if (e.isDefaultPrevented()) return
304
+
305
+    $tip.removeClass('in')
306
+
307
+    $.support.transition && this.$tip.hasClass('fade') ?
308
+      $tip
309
+        .one($.support.transition.end, complete)
310
+        .emulateTransitionEnd(150) :
311
+      complete()
312
+
313
+    this.hoverState = null
314
+
315
+    return this
316
+  }
317
+
318
+  Tooltip.prototype.fixTitle = function () {
319
+    var $e = this.$element
320
+    if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
321
+      $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
322
+    }
323
+  }
324
+
325
+  Tooltip.prototype.hasContent = function () {
326
+    return this.getTitle()
327
+  }
328
+
329
+  Tooltip.prototype.getPosition = function () {
330
+    var el = this.$element[0]
331
+    return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
332
+      width: el.offsetWidth,
333
+      height: el.offsetHeight
334
+    }, this.$element.offset())
335
+  }
336
+
337
+  Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
338
+    return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2  } :
339
+           placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2  } :
340
+           placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
341
+        /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width   }
342
+  }
343
+
344
+  Tooltip.prototype.getTitle = function () {
345
+    var title
346
+    var $e = this.$element
347
+    var o  = this.options
348
+
349
+    title = $e.attr('data-original-title')
350
+      || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
351
+
352
+    return title
353
+  }
354
+
355
+  Tooltip.prototype.tip = function () {
356
+    return this.$tip = this.$tip || $(this.options.template)
357
+  }
358
+
359
+  Tooltip.prototype.arrow = function () {
360
+    return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
361
+  }
362
+
363
+  Tooltip.prototype.validate = function () {
364
+    if (!this.$element[0].parentNode) {
365
+      this.hide()
366
+      this.$element = null
367
+      this.options  = null
368
+    }
369
+  }
370
+
371
+  Tooltip.prototype.enable = function () {
372
+    this.enabled = true
373
+  }
374
+
375
+  Tooltip.prototype.disable = function () {
376
+    this.enabled = false
377
+  }
378
+
379
+  Tooltip.prototype.toggleEnabled = function () {
380
+    this.enabled = !this.enabled
381
+  }
382
+
383
+  Tooltip.prototype.toggle = function (e) {
384
+    var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
385
+    self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
386
+  }
387
+
388
+  Tooltip.prototype.destroy = function () {
389
+    clearTimeout(this.timeout)
390
+    this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
391
+  }
392
+
393
+
394
+  // TOOLTIP PLUGIN DEFINITION
395
+  // =========================
396
+
397
+  var old = $.fn.tooltip
398
+
399
+  $.fn.tooltip = function (option) {
400
+    return this.each(function () {
401
+      var $this   = $(this)
402
+      var data    = $this.data('bs.tooltip')
403
+      var options = typeof option == 'object' && option
404
+
405
+      if (!data && option == 'destroy') return
406
+      if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
407
+      if (typeof option == 'string') data[option]()
408
+    })
409
+  }
410
+
411
+  $.fn.tooltip.Constructor = Tooltip
412
+
413
+
414
+  // TOOLTIP NO CONFLICT
415
+  // ===================
416
+
417
+  $.fn.tooltip.noConflict = function () {
418
+    $.fn.tooltip = old
419
+    return this
420
+  }
421
+
422
+}(jQuery);

Loading…
Cancel
Save