@fintatech/fintachart 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +10 -8
  3. package/THIRD_PARTY_NOTICES.md +1 -1
  4. package/basic-objects.html +2 -6
  5. package/css/FintaChart.min.css +1 -1
  6. package/custom-indicator.html +2 -6
  7. package/d.ts/FintaChart.d.ts +523 -179
  8. package/d.ts/frameworks/bootstrap.v3.datetimepicker.d.ts +3 -3
  9. package/d.ts/frameworks/html2canvas.d.ts +0 -2
  10. package/d.ts/frameworks-modified/autocolumnlist.d.ts +8 -0
  11. package/d.ts/frameworks-modified/spectrum.d.ts +17 -26
  12. package/d.ts/frameworks-modified/toastr.d.ts +9 -10
  13. package/htmldialogs/Toolbar.html +4 -4
  14. package/index-dark.html +2 -6
  15. package/index.html +2 -6
  16. package/multiple-charts.html +2 -6
  17. package/package.json +1 -1
  18. package/scripts/FintaChart.min.js +2 -2
  19. package/scripts/frameworks/bootstrap.v3.datetimepicker.min.js +10 -10
  20. package/scripts/frameworks-modified/autocolumnlist.js +48 -0
  21. package/scripts/frameworks-modified/spectrum.js +187 -6
  22. package/scripts/frameworks-modified/switchery.js +1 -1
  23. package/scripts/frameworks-modified/toastr.js +283 -382
  24. package/scripts/jsdataadapters/fileDataAdapter.js +2 -0
  25. package/d.ts/frameworks/jquery-i18next.d.ts +0 -14
  26. package/d.ts/frameworks/jquery-ui.d.ts +0 -1914
  27. package/d.ts/frameworks/jquery.d.ts +0 -3779
  28. package/d.ts/frameworks/jquery.ui.touch-punch.d.ts +0 -12
  29. package/d.ts/frameworks-modified/bootstrap-select.d.ts +0 -18
  30. package/d.ts/frameworks-modified/jquery.autocolumnlist.d.ts +0 -17
  31. package/d.ts/frameworks-modified/jquery.resizable.d.ts +0 -20
  32. package/scripts/frameworks/jquery-i18next.min.js +0 -1
  33. package/scripts/frameworks/jquery-ui.min.js +0 -8
  34. package/scripts/frameworks/jquery.min.js +0 -3
  35. package/scripts/frameworks/jquery.ui.touch-punch.min.js +0 -1
  36. package/scripts/frameworks-modified/bootstrap-select.js +0 -1024
  37. package/scripts/frameworks-modified/jquery.autocolumnlist.js +0 -48
  38. package/scripts/frameworks-modified/jquery.resizable.js +0 -229
@@ -1,1024 +0,0 @@
1
- 'use strict';
2
-
3
- var FintaChart;
4
- (function (FintaChart) {
5
- var External;
6
- (function (External) {
7
- var $ = window.jQuery;
8
- var HtmlContainer = FintaChart.HtmlContainer;
9
-
10
- var Selectpicker = (function() {
11
-
12
- $.expr[':'].icontains = function(obj, index, meta) {
13
- return $(obj).text().toUpperCase().indexOf(meta[3].toUpperCase()) >= 0;
14
- };
15
-
16
- var Selectpicker = function(element, options, e) {
17
- if (e) {
18
- e.stopPropagation();
19
- e.preventDefault();
20
- }
21
- this.$element = $(element);
22
-
23
- this.$newElement = null;
24
- this.$button = null;
25
- this.$menu = null;
26
- this.$lis = null;
27
-
28
- //Merge defaults, options and data-attributes to make our options
29
- this.options = $.extend({}, $.fn.selectpicker.defaults, this.$element.data(), typeof options == 'object' && options);
30
-
31
- //If we have no title yet, check the attribute 'title' (this is missed by jq as its not a data-attribute
32
- if (this.options.title === null) {
33
- this.options.title = this.$element.attr('title');
34
- }
35
-
36
- //Expose public methods
37
- this.val = Selectpicker.prototype.val;
38
- this.render = Selectpicker.prototype.render;
39
- this.refresh = Selectpicker.prototype.refresh;
40
- this.setStyle = Selectpicker.prototype.setStyle;
41
- this.selectAll = Selectpicker.prototype.selectAll;
42
- this.deselectAll = Selectpicker.prototype.deselectAll;
43
-
44
- this.init();
45
- };
46
-
47
- Selectpicker.prototype = {
48
-
49
- constructor: Selectpicker,
50
-
51
- init: function() {
52
- var that = this,
53
- id = this.$element.attr('id');
54
-
55
- this.$element.hide();
56
- this.multiple = this.$element.prop('multiple');
57
- this.autofocus = this.$element.prop('autofocus');
58
- this.$newElement = this.createView();
59
- this.$element.after(this.$newElement);
60
- this.$menu = this.$newElement.find('> .dropdown-menu');
61
- this.$button = this.$newElement.find('> button');
62
- this.$searchbox = this.$newElement.find('input');
63
-
64
- if (id !== undefined) {
65
- this.$button.attr('data-id', id);
66
- $('label[for="' + id + '"]').click(function(e) {
67
- e.preventDefault();
68
- that.$button.focus();
69
- });
70
- }
71
-
72
- this.checkDisabled();
73
- this.clickListener();
74
- if (this.options.liveSearch) this.liveSearchListener();
75
- this.render();
76
- this.liHeight();
77
- this.setStyle();
78
- this.setWidth();
79
- if (this.options.container) this.selectPosition();
80
- this.$menu.data('this', this);
81
- this.$newElement.data('this', this);
82
- },
83
-
84
- createDropdown: function() {
85
- //If we are multiple, then add the show-tick class by default
86
- var multiple = this.multiple ? ' show-tick' : '';
87
- var inputGroup = this.$element.parent().hasClass('input-group') ? ' input-group-btn' : '';
88
- var autofocus = this.autofocus ? ' autofocus' : '';
89
- var header = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">&times;</button>' + this.options.header + '</div>' : '';
90
- var searchbox = this.options.liveSearch ? '<div class="tcd-select-searchbox"><input type="text" class="input-block-level form-control" autocomplete="off" /></div>' : '';
91
- var actionsbox = this.options.actionsBox ? '<div class="bs-actionsbox">' +
92
- '<div class="btn-group btn-block">' +
93
- '<button class="actions-btn bs-select-all btn btn-sm btn-default">' +
94
- 'Select All' +
95
- '</button>' +
96
- '<button class="actions-btn bs-deselect-all btn btn-sm btn-default">' +
97
- 'Deselect All' +
98
- '</button>' +
99
- '</div>' +
100
- '</div>' : '';
101
- var drop =
102
- '<div class="btn-group tcd-select' + multiple + inputGroup + '">' +
103
- '<button type="button" class="btn dropdown-toggle selectpicker" data-toggle="dropdown"'+ autofocus +'>' +
104
- '<span class="filter-option pull-left"></span>&nbsp;' +
105
- '<span class="caret"></span>' +
106
- '</button>' +
107
- '<div class="dropdown-menu open">' +
108
- header +
109
- searchbox +
110
- actionsbox +
111
- '<ul class="dropdown-menu inner selectpicker" role="menu">' +
112
- '</ul>' +
113
- '</div>' +
114
- '</div>';
115
-
116
- return $(drop);
117
- },
118
-
119
- createView: function() {
120
- var $drop = this.createDropdown();
121
- var $li = this.createLi();
122
- $drop.find('ul').append($li);
123
- return $drop;
124
- },
125
-
126
- reloadLi: function() {
127
- //Remove all children.
128
- this.destroyLi();
129
- //Re build
130
- var $li = this.createLi();
131
- this.$menu.find('ul').append( $li );
132
- },
133
-
134
- destroyLi: function() {
135
- this.$menu.find('li').remove();
136
- },
137
-
138
- createLi: function() {
139
- var that = this,
140
- _liA = [],
141
- _liHtml = '';
142
-
143
- this.$element.find('option').each(function() {
144
- var $this = $(this),
145
- i18nAttr = $(this).data('i18n') || '';
146
-
147
- //Get the class and text for the option
148
- var optionClass = $this.attr('class') || '';
149
- var inline = $this.attr('style') || '';
150
- var text = $this.data('content') ? $this.data('content') : $this.html();
151
- var subtext = $this.data('subtext') !== undefined ? '<small class="muted text-muted">' + $this.data('subtext') + '</small>' : '';
152
- var icon = $this.data('icon') !== undefined ? '<i class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></i> ' : '';
153
- if (icon !== '' && ($this.is(':disabled') || $this.parent().is(':disabled'))) {
154
- icon = '<span>'+icon+'</span>';
155
- }
156
-
157
- if (!$this.data('content')) {
158
- //Prepend any icon and append any subtext to the main text.
159
- text = icon + '<span class="text" data-i18n="' + i18nAttr + '">' + text + subtext + '</span>';
160
- // text = icon + '<span class="text">' + text + subtext + '</span>';
161
- }
162
-
163
- if (that.options.hideDisabled && ($this.is(':disabled') || $this.parent().is(':disabled'))) {
164
- _liA.push('<a style="min-height: 0; padding: 0"></a>');
165
- } else if ($this.parent().is('optgroup') && $this.data('divider') !== true) {
166
- if ($this.index() === 0) {
167
- //Get the opt group label
168
- var label = $this.parent().attr('label');
169
- var labelSubtext = $this.parent().data('subtext') !== undefined ? '<small class="muted text-muted">'+$this.parent().data('subtext')+'</small>' : '';
170
- var labelIcon = $this.parent().data('icon') ? '<i class="'+$this.parent().data('icon')+'"></i> ' : '';
171
- label = labelIcon + '<span class="text">' + label + labelSubtext + '</span>';
172
-
173
- if ($this[0].index !== 0) {
174
- _liA.push(
175
- '<div class="div-contain"><div class="divider"></div></div>'+
176
- '<dt>'+label+'</dt>'+
177
- that.createA(text, 'opt ' + optionClass, inline )
178
- );
179
- } else {
180
- _liA.push(
181
- '<dt>'+label+'</dt>'+
182
- that.createA(text, 'opt ' + optionClass, inline ));
183
- }
184
- } else {
185
- _liA.push(that.createA(text, 'opt ' + optionClass, inline ));
186
- }
187
- } else if ($this.data('divider') === true) {
188
- _liA.push('<div class="div-contain"><div class="divider"></div></div>');
189
- } else if ($(this).data('hidden') === true) {
190
- _liA.push('<a></a>');
191
- } else {
192
- _liA.push(that.createA(text, optionClass, inline ));
193
- }
194
- });
195
-
196
- $.each(_liA, function(i, item) {
197
- var hide = item === '<a></a>' ? 'class="hide is-hidden"' : '';
198
- _liHtml += '<li rel="' + i + '"' + hide + '>' + item + '</li>';
199
- });
200
-
201
- //If we are not multiple, and we dont have a selected item, and we dont have a title, select the first element so something is set in the button
202
- if (!this.multiple && this.$element.find('option:selected').length===0 && !this.options.title) {
203
- this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected');
204
- }
205
-
206
- return $(_liHtml);
207
- },
208
-
209
- createA: function(text, classes, inline) {
210
- return '<a tabindex="0" class="'+classes+'" style="'+inline+'">' +
211
- text +
212
- '<i class="' + this.options.iconBase + ' ' + this.options.tickIcon + ' icon-ok check-mark"></i>' +
213
- '</a>';
214
- },
215
-
216
- render: function(updateLi) {
217
- var that = this,
218
- haveAttr = false;
219
-
220
- //Update the LI to match the SELECT
221
- if (updateLi !== false) {
222
- this.$element.find('option').each(function(index) {
223
- that.setDisabled(index, $(this).is(':disabled') || $(this).parent().is(':disabled') );
224
- that.setSelected(index, $(this).is(':selected') );
225
- });
226
- }
227
-
228
- this.tabIndex();
229
-
230
- var selectedItems = this.$element.find('option:selected').map(function() {
231
- var $this = $(this),
232
- attr = $this.data('i18n');
233
- if (attr && attr.length) {
234
- haveAttr = true;
235
- return attr;
236
- } else {
237
- var icon = $this.data('icon') && that.options.showIcon ? '<i class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></i> ' : '';
238
- var subtext;
239
- if (that.options.showSubtext && $this.attr('data-subtext') && !that.multiple) {
240
- subtext = ' <small class="muted text-muted">'+$this.data('subtext') +'</small>';
241
- } else {
242
- subtext = '';
243
- }
244
- if ($this.data('content') && that.options.showContent) {
245
- return $this.data('content');
246
- } else if ($this.attr('title') !== undefined) {
247
- return $this.attr('title');
248
- } else {
249
- return icon + $this.html() + subtext;
250
- }
251
- }
252
- }).toArray();
253
-
254
- //Fixes issue in IE10 occurring when no default option is selected and at least one option is disabled
255
- //Convert all the values into a comma delimited string
256
- var title = !this.multiple ? selectedItems[0] : selectedItems.join(this.options.multipleSeparator);
257
-
258
- //If this is multi select, and the selectText type is count, the show 1 of 2 selected etc..
259
- if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) {
260
- var max = this.options.selectedTextFormat.split('>');
261
- var notDisabled = this.options.hideDisabled ? ':not([disabled])' : '';
262
- if ( (max.length>1 && selectedItems.length > max[1]) || (max.length==1 && selectedItems.length>=2)) {
263
- title = this.options.countSelectedText.replace('{0}', selectedItems.length).replace('{1}', this.$element.find('option:not([data-divider="true"]):not([data-hidden="true"])'+notDisabled).length);
264
- }
265
- }
266
-
267
- this.options.title = this.$element.attr('title');
268
-
269
- //If we dont have a title, then use the default, or if nothing is set at all, use the not selected text
270
- if (!title) {
271
- title = this.options.title !== undefined ? this.options.title : this.options.noneSelectedText;
272
- }
273
-
274
- // Fix for title attr
275
- this.$button.attr('title', "");
276
- this.$newElement.find('.filter-option').removeAttr('data-i18n');
277
- this.$button.removeAttr('data-i18n');
278
-
279
- if (haveAttr) {
280
- this.$newElement.find('.filter-option').text(this.$element.val()).attr('data-i18n', title);
281
- this.$button.attr('data-i18n', '[title]' + title);
282
- this.$button.attr('title', this.$element.val());
283
- } else {
284
- this.$newElement.find('.filter-option').html(title);
285
- var manualData = this.$element.find('option:selected').data('manuali18');
286
- if (manualData) {
287
- this.$button.attr('data-i18n', "[title]" + manualData);
288
- } else {
289
- this.$button.attr('title',title);
290
- }
291
- }
292
-
293
- //FIX: issue with set of value
294
- this.$button.attr("data-selectValue", this.$element.val());
295
- },
296
-
297
- setStyle: function(style, status) {
298
- if (this.$element.attr('class')) {
299
- this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|validate\[.*\]/gi, ''));
300
- }
301
-
302
- var buttonClass = style ? style : this.options.style;
303
-
304
- if (status == 'add') {
305
- this.$button.addClass(buttonClass);
306
- } else if (status == 'remove') {
307
- this.$button.removeClass(buttonClass);
308
- } else {
309
- this.$button.removeClass(this.options.style);
310
- this.$button.addClass(buttonClass);
311
- }
312
- },
313
-
314
- liHeight: function() {
315
- if (this.options.size === false) return;
316
-
317
- var $selectClone = this.$menu.parent().clone().find('> .dropdown-toggle').prop('autofocus', false).end().appendTo('body'),
318
- $menuClone = $selectClone.addClass('open').find('> .dropdown-menu'),
319
- liHeight = $menuClone.find('li > a').outerHeight(),
320
- headerHeight = this.options.header ? $menuClone.find('.popover-title').outerHeight() : 0,
321
- searchHeight = this.options.liveSearch ? $menuClone.find('.tcd-select-searchbox').outerHeight() : 0,
322
- actionsHeight = this.options.actionsBox ? $menuClone.find('.bs-actionsbox').outerHeight() : 0;
323
-
324
- $selectClone.remove();
325
-
326
- this.$newElement
327
- .data('liHeight', liHeight)
328
- .data('headerHeight', headerHeight)
329
- .data('searchHeight', searchHeight)
330
- .data('actionsHeight', actionsHeight);
331
- },
332
-
333
- setSize: function() {
334
- var that = this,
335
- menu = this.$menu,
336
- menuInner = menu.find('.inner'),
337
- selectHeight = this.$newElement.outerHeight(),
338
- liHeight = this.$newElement.data('liHeight'),
339
- headerHeight = this.$newElement.data('headerHeight'),
340
- searchHeight = this.$newElement.data('searchHeight'),
341
- actionsHeight = this.$newElement.data('actionsHeight'),
342
- divHeight = menu.find('li .divider').outerHeight(true),
343
- menuPadding = parseInt(menu.css('padding-top')) +
344
- parseInt(menu.css('padding-bottom')) +
345
- parseInt(menu.css('border-top-width')) +
346
- parseInt(menu.css('border-bottom-width')),
347
- notDisabled = this.options.hideDisabled ? ':not(.disabled)' : '',
348
- $window = $(window),
349
- menuExtras = menuPadding + parseInt(menu.css('margin-top')) + parseInt(menu.css('margin-bottom')) + 2,
350
- menuHeight,
351
- selectOffsetTop,
352
- selectOffsetBot,
353
- posVert = function() {
354
- selectOffsetTop = that.$newElement.offset().top - $window.scrollTop();
355
- selectOffsetBot = $window.height() - selectOffsetTop - selectHeight;
356
- };
357
- posVert();
358
- if (this.options.header) menu.css('padding-top', 0);
359
-
360
- if (this.options.size == 'auto') {
361
- var getSize = function() {
362
- var minHeight,
363
- lisVis = that.$lis.not('.hide');
364
-
365
- posVert();
366
- menuHeight = selectOffsetBot - menuExtras;
367
-
368
- if (that.options.dropupAuto) {
369
- that.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && ((menuHeight - menuExtras) < menu.height()));
370
- }
371
- if (that.$newElement.hasClass('dropup')) {
372
- menuHeight = selectOffsetTop - menuExtras;
373
- }
374
-
375
- if ((lisVis.length + lisVis.find('dt').length) > 3) {
376
- minHeight = liHeight*3 + menuExtras - 2;
377
- } else {
378
- minHeight = 0;
379
- }
380
-
381
- menu.css({'max-height' : menuHeight + 'px', 'overflow' : 'hidden', 'min-height' : minHeight + headerHeight + searchHeight + actionsHeight + 'px'});
382
- menuInner.css({'max-height' : menuHeight - headerHeight - searchHeight - actionsHeight - menuPadding + 'px', 'overflow-y' : 'auto', 'min-height' : Math.max(minHeight - menuPadding, 0) + 'px'});
383
- };
384
- getSize();
385
- this.$searchbox.off('input.getSize propertychange.getSize').on('input.getSize propertychange.getSize', getSize);
386
- $(window).off('resize.getSize').on('resize.getSize', getSize);
387
- $(window).off('scroll.getSize').on('scroll.getSize', getSize);
388
- } else if (this.options.size && this.options.size != 'auto' && menu.find('li'+notDisabled).length > this.options.size) {
389
- var optIndex = menu.find('li'+notDisabled+' > *').filter(':not(.div-contain)').slice(0,this.options.size).last().parent().index();
390
- var divLength = menu.find('li').slice(0,optIndex + 1).find('.div-contain').length;
391
- menuHeight = liHeight*this.options.size + divLength*divHeight + menuPadding;
392
- if (that.options.dropupAuto) {
393
- this.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && (menuHeight < menu.height()));
394
- }
395
- menu.css({'max-height' : menuHeight + headerHeight + searchHeight + actionsHeight + 'px', 'overflow' : 'hidden'});
396
- menuInner.css({'max-height' : menuHeight - menuPadding + 'px', 'overflow-y' : 'auto'});
397
- }
398
- },
399
-
400
- setWidth: function() {
401
- if (this.options.width == 'auto') {
402
- this.$menu.css('min-width', '0');
403
-
404
- // Get correct width if element hidden
405
- var selectClone = this.$newElement.clone().appendTo('body');
406
- var ulWidth = selectClone.find('> .dropdown-menu').css('width');
407
- var btnWidth = selectClone.css('width', 'auto').find('> button').css('width');
408
- selectClone.remove();
409
-
410
- // Set width to whatever's larger, button title or longest option
411
- this.$newElement.css('width', Math.max(parseInt(ulWidth), parseInt(btnWidth)) + 'px');
412
- } else if (this.options.width == 'fit') {
413
- // Remove inline min-width so width can be changed from 'auto'
414
- this.$menu.css('min-width', '');
415
- this.$newElement.css('width', '').addClass('fit-width');
416
- } else if (this.options.width) {
417
- // Remove inline min-width so width can be changed from 'auto'
418
- this.$menu.css('min-width', '');
419
- this.$newElement.css('width', this.options.width);
420
- } else {
421
- // Remove inline min-width/width so width can be changed
422
- this.$menu.css('min-width', '');
423
- this.$newElement.css('width', '');
424
- }
425
- // Remove fit-width class if width is changed programmatically
426
- if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') {
427
- this.$newElement.removeClass('fit-width');
428
- }
429
- },
430
-
431
- selectPosition: function() {
432
- var that = this,
433
- drop = '<div />',
434
- $drop = $(drop),
435
- pos,
436
- actualHeight,
437
- getPlacement = function($element) {
438
- $drop.addClass($element.attr('class').replace(/form-control/gi, '')).toggleClass('dropup', $element.hasClass('dropup'));
439
- pos = $element.offset();
440
- actualHeight = $element.hasClass('dropup') ? 0 : $element[0].offsetHeight;
441
- $drop.css({'top' : pos.top + actualHeight, 'left' : pos.left, 'width' : $element[0].offsetWidth, 'position' : 'absolute'});
442
- };
443
- this.$newElement.on('click', function() {
444
- if (that.isDisabled()) {
445
- return;
446
- }
447
- getPlacement($(this));
448
-
449
- //FIX: issue with update of root container in full screen mode
450
- // $drop.appendTo(that.options.container);
451
- $drop.appendTo(FintaChart.HtmlContainer.container);
452
-
453
- $drop.toggleClass('open', !$(this).hasClass('open'));
454
- $drop.append(that.$menu);
455
- });
456
- $(window).resize(function() {
457
- getPlacement(that.$newElement);
458
- });
459
- $(window).on('scroll', function() {
460
- getPlacement(that.$newElement);
461
- });
462
- $('html').on('click', function(e) {
463
- if ($(e.target).closest(that.$newElement).length < 1) {
464
- $drop.removeClass('open');
465
- }
466
- });
467
- $('html').on('mousedown', function (e) {
468
- if ($('.tcd-select').has(e.target).length === 0)
469
- $drop.removeClass('open');
470
- });
471
- $('html').on('DOMMouseScroll mousewheel', function (e) {
472
- if ($('.tcd-select').has(e.target).length === 0)
473
- $drop.removeClass('open');
474
- });
475
- },
476
-
477
- mobile: function() {
478
- this.$element.addClass('mobile-device').appendTo(this.$newElement);
479
- if (this.options.container) this.$menu.hide();
480
- },
481
-
482
- refresh: function() {
483
- this.$lis = null;
484
- this.reloadLi();
485
- this.render();
486
- this.setWidth();
487
- this.setStyle();
488
- this.checkDisabled();
489
- this.liHeight();
490
- },
491
-
492
- update: function() {
493
- this.reloadLi();
494
- this.setWidth();
495
- this.setStyle();
496
- this.checkDisabled();
497
- this.liHeight();
498
- },
499
-
500
- setSelected: function(index, selected) {
501
- if (this.$lis == null) this.$lis = this.$menu.find('li');
502
- $(this.$lis[index]).toggleClass('selected', selected);
503
- },
504
-
505
- setDisabled: function(index, disabled) {
506
- if (this.$lis == null) this.$lis = this.$menu.find('li');
507
- if (disabled) {
508
- $(this.$lis[index]).addClass('disabled').find('a').attr('href', '#').attr('tabindex', -1);
509
- } else {
510
- $(this.$lis[index]).removeClass('disabled').find('a').removeAttr('href').attr('tabindex', 0);
511
- }
512
- },
513
-
514
- isDisabled: function() {
515
- return this.$element.is(':disabled');
516
- },
517
-
518
- checkDisabled: function() {
519
- var that = this;
520
-
521
- if (this.isDisabled()) {
522
- this.$button.addClass('disabled').attr('tabindex', -1);
523
- } else {
524
- if (this.$button.hasClass('disabled')) {
525
- this.$button.removeClass('disabled');
526
- }
527
-
528
- if (this.$button.attr('tabindex') == -1) {
529
- if (!this.$element.data('tabindex')) this.$button.removeAttr('tabindex');
530
- }
531
- }
532
-
533
- this.$button.click(function() {
534
- return !that.isDisabled();
535
- });
536
- },
537
-
538
- tabIndex: function() {
539
- if (this.$element.is('[tabindex]')) {
540
- this.$element.data('tabindex', this.$element.attr('tabindex'));
541
- this.$button.attr('tabindex', this.$element.data('tabindex'));
542
- }
543
- },
544
-
545
- clickListener: function() {
546
- var that = this;
547
-
548
- $('body').on('touchstart.dropdown', '.dropdown-menu', function(e) {
549
- e.stopPropagation();
550
- });
551
-
552
- this.$newElement.on('click', function() {
553
- that.setSize();
554
- if (!that.options.liveSearch && !that.multiple) {
555
- setTimeout(function() {
556
- that.$menu.find('.selected a').focus();
557
- }, 10);
558
- }
559
- });
560
-
561
- this.$menu.on('click', 'li a', function(e) {
562
- var clickedIndex = $(this).parent().index(),
563
- prevValue = that.$element.val(),
564
- prevIndex = that.$element.prop('selectedIndex');
565
-
566
- //Dont close on multi choice menu
567
- if (that.multiple) {
568
- e.stopPropagation();
569
- }
570
-
571
- e.preventDefault();
572
-
573
- //Dont run if we have been disabled
574
- if (!that.isDisabled() && !$(this).parent().hasClass('disabled')) {
575
- var $options = that.$element.find('option'),
576
- $option = $options.eq(clickedIndex),
577
- state = $option.prop('selected'),
578
- $optgroup = $option.parent('optgroup'),
579
- maxOptions = that.options.maxOptions,
580
- maxOptionsGrp = $optgroup.data('maxOptions') || false;
581
-
582
- //Deselect all others if not multi select box
583
- if (!that.multiple) {
584
- $options.prop('selected', false);
585
- $option.prop('selected', true);
586
- that.$menu.find('.selected').removeClass('selected');
587
- that.setSelected(clickedIndex, true);
588
- }
589
- //Else toggle the one we have chosen if we are multi select.
590
- else {
591
- $option.prop('selected', !state);
592
- that.setSelected(clickedIndex, !state);
593
-
594
- if ((maxOptions !== false) || (maxOptionsGrp !== false)) {
595
- var maxReached = maxOptions < $options.filter(':selected').length,
596
- maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length,
597
- maxOptionsArr = that.options.maxOptionsText,
598
- maxTxt = maxOptionsArr[0].replace('{n}', maxOptions),
599
- maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp),
600
- $notify = $('<div class="notify"></div>');
601
-
602
- if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) {
603
- // If {var} is set in array, replace it
604
- if (maxOptionsArr[2]) {
605
- maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]);
606
- maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]);
607
- }
608
-
609
- $option.prop('selected', false);
610
-
611
- that.$menu.append($notify);
612
-
613
- if (maxOptions && maxReached) {
614
- $notify.append($('<div>' + maxTxt + '</div>'));
615
- that.$element.trigger('maxReached.bs.select');
616
- }
617
-
618
- if (maxOptionsGrp && maxReachedGrp) {
619
- $notify.append($('<div>' + maxTxtGrp + '</div>'));
620
- that.$element.trigger('maxReachedGrp.bs.select');
621
- }
622
-
623
- setTimeout(function() {
624
- that.setSelected(clickedIndex, false);
625
- }, 10);
626
-
627
- $notify.delay(750).fadeOut(300, function() { $(this).remove(); });
628
- }
629
- }
630
- }
631
-
632
- if (!that.multiple) {
633
- that.$button.focus();
634
- } else if (that.options.liveSearch) {
635
- that.$searchbox.focus();
636
- }
637
-
638
- // Trigger select 'change'
639
- if ((prevValue != that.$element.val() && that.multiple) || (prevIndex != that.$element.prop('selectedIndex') && !that.multiple)) {
640
- that.$element.change();
641
- }
642
- }
643
- });
644
-
645
- this.$menu.on('click', 'li.disabled a, li dt, li .div-contain, .popover-title, .popover-title :not(.close)', function(e) {
646
- if (e.target == this) {
647
- e.preventDefault();
648
- e.stopPropagation();
649
- if (!that.options.liveSearch) {
650
- that.$button.focus();
651
- } else {
652
- that.$searchbox.focus();
653
- }
654
- }
655
- });
656
-
657
- this.$menu.on('click', '.popover-title .close', function() {
658
- that.$button.focus();
659
- });
660
-
661
- this.$searchbox.on('click', function(e) {
662
- e.stopPropagation();
663
- });
664
-
665
-
666
- this.$menu.on('click', '.actions-btn', function(e) {
667
- if (that.options.liveSearch) {
668
- that.$searchbox.focus();
669
- } else {
670
- that.$button.focus();
671
- }
672
-
673
- e.preventDefault();
674
- e.stopPropagation();
675
-
676
- if ($(this).is('.bs-select-all')) {
677
- that.selectAll();
678
- } else {
679
- that.deselectAll();
680
- }
681
- that.$element.change();
682
- });
683
-
684
- this.$element.change(function() {
685
- that.render(false);
686
- $('body')
687
- .trigger('localize', [this.$newElement.find('.filter-option')])
688
- .trigger('localize', [this.$menu])
689
- .trigger('localize', [this.$button]);
690
- }.bind(this));
691
- },
692
-
693
- liveSearchListener: function() {
694
- var that = this,
695
- no_results = $('<li class="no-results"></li>');
696
-
697
- this.$newElement.on('click.dropdown.data-api', function() {
698
- that.$menu.find('.active').removeClass('active');
699
- if (!!that.$searchbox.val()) {
700
- that.$searchbox.val('');
701
- that.$lis.not('.is-hidden').removeClass('hide');
702
- if (!!no_results.parent().length) no_results.remove();
703
- }
704
- if (!that.multiple) that.$menu.find('.selected').addClass('active');
705
- setTimeout(function() {
706
- that.$searchbox.focus();
707
- }, 10);
708
- });
709
-
710
- this.$searchbox.on('input propertychange', function() {
711
- if (that.$searchbox.val()) {
712
- that.$lis.not('.is-hidden').removeClass('hide').find('a').not(':icontains(' + that.$searchbox.val() + ')').parent().addClass('hide');
713
-
714
- if (!that.$menu.find('li').filter(':visible:not(.no-results)').length) {
715
- if (!!no_results.parent().length) no_results.remove();
716
- no_results.html(that.options.noneResultsText + ' "'+ that.$searchbox.val() + '"').show();
717
- that.$menu.find('li').last().after(no_results);
718
- } else if (!!no_results.parent().length) {
719
- no_results.remove();
720
- }
721
-
722
- } else {
723
- that.$lis.not('.is-hidden').removeClass('hide');
724
- if (!!no_results.parent().length) no_results.remove();
725
- }
726
-
727
- that.$menu.find('li.active').removeClass('active');
728
- that.$menu.find('li').filter(':visible:not(.divider)').eq(0).addClass('active').find('a').focus();
729
- $(this).focus();
730
- });
731
-
732
- this.$menu.on('mouseenter', 'a', function(e) {
733
- that.$menu.find('.active').removeClass('active');
734
- $(e.currentTarget).parent().not('.disabled').addClass('active');
735
- });
736
-
737
- this.$menu.on('mouseleave', 'a', function() {
738
- that.$menu.find('.active').removeClass('active');
739
- });
740
- },
741
-
742
- val: function(value) {
743
- if (value !== undefined) {
744
- this.$element.val( value );
745
-
746
- this.$element.change();
747
- return this.$element;
748
- } else {
749
- return this.$element.val();
750
- }
751
- },
752
-
753
- selectAll: function() {
754
- if (this.$lis == null) this.$lis = this.$menu.find('li');
755
- this.$element.find('option:enabled').prop('selected', true);
756
- $(this.$lis).filter(':not(.disabled)').addClass('selected');
757
- this.render(false);
758
- },
759
-
760
- deselectAll: function() {
761
- if (this.$lis == null) this.$lis = this.$menu.find('li');
762
- this.$element.find('option:enabled').prop('selected', false);
763
- $(this.$lis).filter(':not(.disabled)').removeClass('selected');
764
- this.render(false);
765
- },
766
-
767
- keydown: function(e) {
768
- var $this,
769
- $items,
770
- $parent,
771
- index,
772
- next,
773
- first,
774
- last,
775
- prev,
776
- nextPrev,
777
- that,
778
- prevIndex,
779
- isActive,
780
- keyCodeMap = {
781
- 32:' ', 48:'0', 49:'1', 50:'2', 51:'3', 52:'4', 53:'5', 54:'6', 55:'7', 56:'8', 57:'9', 59:';',
782
- 65:'a', 66:'b', 67:'c', 68:'d', 69:'e', 70:'f', 71:'g', 72:'h', 73:'i', 74:'j', 75:'k', 76:'l',
783
- 77:'m', 78:'n', 79:'o', 80:'p', 81:'q', 82:'r', 83:'s', 84:'t', 85:'u', 86:'v', 87:'w', 88:'x',
784
- 89:'y', 90:'z', 96:'0', 97:'1', 98:'2', 99:'3', 100:'4', 101:'5', 102:'6', 103:'7', 104:'8', 105:'9'
785
- };
786
-
787
- $this = $(this);
788
-
789
- $parent = $this.parent();
790
-
791
- if ($this.is('input')) $parent = $this.parent().parent();
792
-
793
- that = $parent.data('this');
794
-
795
- if (that.options.liveSearch) $parent = $this.parent().parent();
796
-
797
- if (that.options.container) $parent = that.$menu;
798
-
799
- $items = $('[role=menu] li:not(.divider) a', $parent);
800
-
801
- isActive = that.$menu.parent().hasClass('open');
802
-
803
- if (!isActive && /([0-9]|[A-z])/.test(String.fromCharCode(e.keyCode))) {
804
- if (!that.options.container) {
805
- that.setSize();
806
- that.$menu.parent().addClass('open');
807
- isActive = that.$menu.parent().hasClass('open');
808
- } else {
809
- that.$newElement.trigger('click');
810
- }
811
- that.$searchbox.focus();
812
- }
813
-
814
- if (that.options.liveSearch) {
815
- if (/(^9$|27)/.test(e.keyCode) && isActive && that.$menu.find('.active').length === 0) {
816
- e.preventDefault();
817
- that.$menu.parent().removeClass('open');
818
- that.$button.focus();
819
- }
820
- $items = $('[role=menu] li:not(.divider):visible', $parent);
821
- if (!$this.val() && !/(38|40)/.test(e.keyCode)) {
822
- if ($items.filter('.active').length === 0) {
823
- $items = that.$newElement.find('li').filter(':icontains(' + keyCodeMap[e.keyCode] + ')');
824
- }
825
- }
826
- }
827
-
828
- if (!$items.length) return;
829
-
830
- if (/(38|40)/.test(e.keyCode)) {
831
-
832
- index = $items.index($items.filter(':focus'));
833
- first = $items.parent(':not(.disabled):visible').first().index();
834
- last = $items.parent(':not(.disabled):visible').last().index();
835
- next = $items.eq(index).parent().nextAll(':not(.disabled):visible').eq(0).index();
836
- prev = $items.eq(index).parent().prevAll(':not(.disabled):visible').eq(0).index();
837
- nextPrev = $items.eq(next).parent().prevAll(':not(.disabled):visible').eq(0).index();
838
-
839
- if (that.options.liveSearch) {
840
- $items.each(function(i) {
841
- if ($(this).is(':not(.disabled)')) {
842
- $(this).data('index', i);
843
- }
844
- });
845
- index = $items.index($items.filter('.active'));
846
- first = $items.filter(':not(.disabled):visible').first().data('index');
847
- last = $items.filter(':not(.disabled):visible').last().data('index');
848
- next = $items.eq(index).nextAll(':not(.disabled):visible').eq(0).data('index');
849
- prev = $items.eq(index).prevAll(':not(.disabled):visible').eq(0).data('index');
850
- nextPrev = $items.eq(next).prevAll(':not(.disabled):visible').eq(0).data('index');
851
- }
852
-
853
- prevIndex = $this.data('prevIndex');
854
-
855
- if (e.keyCode == 38) {
856
- if (that.options.liveSearch) index -= 1;
857
- if (index != nextPrev && index > prev) index = prev;
858
- if (index < first) index = first;
859
- if (index == prevIndex) index = last;
860
- }
861
-
862
- if (e.keyCode == 40) {
863
- if (that.options.liveSearch) index += 1;
864
- if (index == -1) index = 0;
865
- if (index != nextPrev && index < next) index = next;
866
- if (index > last) index = last;
867
- if (index == prevIndex) index = first;
868
- }
869
-
870
- $this.data('prevIndex', index);
871
-
872
- if (!that.options.liveSearch) {
873
- $items.eq(index).focus();
874
- } else {
875
- e.preventDefault();
876
- if (!$this.is('.dropdown-toggle')) {
877
- $items.removeClass('active');
878
- $items.eq(index).addClass('active').find('a').focus();
879
- $this.focus();
880
- }
881
- }
882
-
883
- } else if (!$this.is('input')) {
884
-
885
- var keyIndex = [],
886
- count,
887
- prevKey;
888
-
889
- $items.each(function() {
890
- if ($(this).parent().is(':not(.disabled)')) {
891
- if ($.trim($(this).text().toLowerCase()).substring(0,1) == keyCodeMap[e.keyCode]) {
892
- keyIndex.push($(this).parent().index());
893
- }
894
- }
895
- });
896
-
897
- count = $(document).data('keycount');
898
- count++;
899
- $(document).data('keycount',count);
900
-
901
- prevKey = $.trim($(':focus').text().toLowerCase()).substring(0,1);
902
-
903
- if (prevKey != keyCodeMap[e.keyCode]) {
904
- count = 1;
905
- $(document).data('keycount', count);
906
- } else if (count >= keyIndex.length) {
907
- $(document).data('keycount', 0);
908
- if (count > keyIndex.length) count = 1;
909
- }
910
-
911
- $items.eq(keyIndex[count - 1]).focus();
912
- }
913
-
914
- // Select focused option if "Enter", "Spacebar", "Tab" are pressed inside the menu.
915
- if (/(13|32|^9$)/.test(e.keyCode) && isActive) {
916
- if (!/(32)/.test(e.keyCode)) e.preventDefault();
917
- if (!that.options.liveSearch) {
918
- $(':focus').click();
919
- } else if (!/(32)/.test(e.keyCode)) {
920
- that.$menu.find('.active a').click();
921
- $this.focus();
922
- }
923
- $(document).data('keycount',0);
924
- }
925
-
926
- if ((/(^9$|27)/.test(e.keyCode) && isActive && (that.multiple || that.options.liveSearch)) || (/(27)/.test(e.keyCode) && !isActive)) {
927
- that.$menu.parent().removeClass('open');
928
- that.$button.focus();
929
- }
930
-
931
- },
932
-
933
- hide: function() {
934
- this.$newElement.hide();
935
- },
936
-
937
- show: function() {
938
- this.$newElement.show();
939
- },
940
-
941
- destroy: function() {
942
- this.$newElement.remove();
943
- this.$element.remove();
944
- }
945
- };
946
-
947
- $.fn.selectpicker = function(option, event) {
948
- //get the args of the outer function..
949
- var args = arguments;
950
- var value;
951
- var chain = this.each(function() {
952
- if ($(this).is('select')) {
953
- var $this = $(this),
954
- data = $this.data('selectpicker'),
955
- options = typeof option == 'object' && option;
956
-
957
- if (!data) {
958
- $this.data('selectpicker', (data = new Selectpicker(this, options, event)));
959
- } else if (options) {
960
- for(var i in options) {
961
- data.options[i] = options[i];
962
- }
963
- }
964
-
965
- if (typeof option == 'string') {
966
- //Copy the value of option, as once we shift the arguments
967
- //it also shifts the value of option.
968
- var property = option;
969
- if (data[property] instanceof Function) {
970
- [].shift.apply(args);
971
- value = data[property].apply(data, args);
972
- } else {
973
- value = data.options[property];
974
- }
975
- }
976
- }
977
- });
978
-
979
- if (value !== undefined) {
980
- return value;
981
- } else {
982
- return chain;
983
- }
984
- };
985
-
986
- $.fn.selectpicker.defaults = {
987
- style: 'btn-default',
988
- size: 'auto',
989
- title: null,
990
- selectedTextFormat : 'values',
991
- noneSelectedText : 'Nothing selected',
992
- noneResultsText : 'No results match',
993
- countSelectedText: '{0} of {1} selected',
994
- maxOptionsText: ['Limit reached ({n} {var} max)', 'Group limit reached ({n} {var} max)', ['items','item']],
995
- width: false,
996
- container: false,
997
- hideDisabled: false,
998
- showSubtext: false,
999
- showIcon: true,
1000
- showContent: true,
1001
- dropupAuto: true,
1002
- header: false,
1003
- liveSearch: false,
1004
- actionsBox: false,
1005
- multipleSeparator: ', ',
1006
- iconBase: 'glyphicon',
1007
- tickIcon: 'glyphicon-ok',
1008
- maxOptions: false
1009
- };
1010
-
1011
- $(document)
1012
- .data('keycount', 0)
1013
- .on('keydown', '.tcd-select [data-toggle=dropdown], .tcd-select [role=menu], .tcd-select-searchbox input', Selectpicker.prototype.keydown)
1014
- .on('focusin.modal', '.tcd-select [data-toggle=dropdown], .tcd-select [role=menu], .tcd-select-searchbox input', function (e) { e.stopPropagation(); });
1015
-
1016
- return Selectpicker;
1017
- }());
1018
-
1019
- External.Selectpicker = Selectpicker;
1020
-
1021
- })(External = FintaChart.External || (FintaChart.External = {}));
1022
- })(FintaChart || (FintaChart = {}));
1023
-
1024
-