mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-19 04:49:30 +00:00
Various code cleanup
This commit is contained in:
306
public/js/lib/bootstrap-multiselect.js
vendored
306
public/js/lib/bootstrap-multiselect.js
vendored
@@ -48,7 +48,7 @@
|
||||
ko.bindingHandlers.multiselect = {
|
||||
after: ['options', 'value', 'selectedOptions', 'enable', 'disable'],
|
||||
|
||||
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
|
||||
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
|
||||
var $element = $(element);
|
||||
var config = ko.toJS(valueAccessor());
|
||||
|
||||
@@ -58,17 +58,17 @@
|
||||
var options = allBindings.get('options');
|
||||
if (ko.isObservable(options)) {
|
||||
ko.computed({
|
||||
read: function() {
|
||||
options();
|
||||
setTimeout(function() {
|
||||
var ms = $element.data('multiselect');
|
||||
if (ms)
|
||||
ms.updateOriginalOptions();//Not sure how beneficial this is.
|
||||
$element.multiselect('rebuild');
|
||||
}, 1);
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
});
|
||||
read: function () {
|
||||
options();
|
||||
setTimeout(function () {
|
||||
var ms = $element.data('multiselect');
|
||||
if (ms)
|
||||
ms.updateOriginalOptions();//Not sure how beneficial this is.
|
||||
$element.multiselect('rebuild');
|
||||
}, 1);
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,14 +79,14 @@
|
||||
var value = allBindings.get('value');
|
||||
if (ko.isObservable(value)) {
|
||||
ko.computed({
|
||||
read: function() {
|
||||
value();
|
||||
setTimeout(function() {
|
||||
$element.multiselect('refresh');
|
||||
}, 1);
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
}).extend({ rateLimit: 100, notifyWhenChangesStop: true });
|
||||
read: function () {
|
||||
value();
|
||||
setTimeout(function () {
|
||||
$element.multiselect('refresh');
|
||||
}, 1);
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
}).extend({rateLimit: 100, notifyWhenChangesStop: true});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,14 +96,14 @@
|
||||
var selectedOptions = allBindings.get('selectedOptions');
|
||||
if (ko.isObservable(selectedOptions)) {
|
||||
ko.computed({
|
||||
read: function() {
|
||||
selectedOptions();
|
||||
setTimeout(function() {
|
||||
$element.multiselect('refresh');
|
||||
}, 1);
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
}).extend({ rateLimit: 100, notifyWhenChangesStop: true });
|
||||
read: function () {
|
||||
selectedOptions();
|
||||
setTimeout(function () {
|
||||
$element.multiselect('refresh');
|
||||
}, 1);
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
}).extend({rateLimit: 100, notifyWhenChangesStop: true});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,11 +120,11 @@
|
||||
var enable = allBindings.get('enable');
|
||||
if (ko.isObservable(enable)) {
|
||||
ko.computed({
|
||||
read: function () {
|
||||
setEnabled(enable());
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
}).extend({ rateLimit: 100, notifyWhenChangesStop: true });
|
||||
read: function () {
|
||||
setEnabled(enable());
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
}).extend({rateLimit: 100, notifyWhenChangesStop: true});
|
||||
} else {
|
||||
setEnabled(enable);
|
||||
}
|
||||
@@ -134,22 +134,22 @@
|
||||
var disable = allBindings.get('disable');
|
||||
if (ko.isObservable(disable)) {
|
||||
ko.computed({
|
||||
read: function () {
|
||||
setEnabled(!disable());
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
}).extend({ rateLimit: 100, notifyWhenChangesStop: true });
|
||||
read: function () {
|
||||
setEnabled(!disable());
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
}).extend({rateLimit: 100, notifyWhenChangesStop: true});
|
||||
} else {
|
||||
setEnabled(!disable);
|
||||
}
|
||||
}
|
||||
|
||||
ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
|
||||
ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
|
||||
$element.multiselect('destroy');
|
||||
});
|
||||
},
|
||||
|
||||
update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
|
||||
update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
|
||||
var $element = $(element);
|
||||
var config = ko.toJS(valueAccessor());
|
||||
|
||||
@@ -236,9 +236,9 @@
|
||||
* @param {jQuery} select
|
||||
* @returns {String}
|
||||
*/
|
||||
buttonText: function(options, select) {
|
||||
buttonText: function (options, select) {
|
||||
if (this.disabledText.length > 0
|
||||
&& (select.prop('disabled') || (options.length == 0 && this.disableIfEmpty))) {
|
||||
&& (select.prop('disabled') || (options.length == 0 && this.disableIfEmpty))) {
|
||||
|
||||
return this.disabledText;
|
||||
}
|
||||
@@ -246,9 +246,9 @@
|
||||
return this.nonSelectedText;
|
||||
}
|
||||
else if (this.allSelectedText
|
||||
&& options.length === $('option', $(select)).length
|
||||
&& $('option', $(select)).length !== 1
|
||||
&& this.multiple) {
|
||||
&& options.length === $('option', $(select)).length
|
||||
&& $('option', $(select)).length !== 1
|
||||
&& this.multiple) {
|
||||
|
||||
if (this.selectAllNumber) {
|
||||
return this.allSelectedText + ' (' + options.length + ')';
|
||||
@@ -264,7 +264,7 @@
|
||||
var selected = '';
|
||||
var delimiter = this.delimiterText;
|
||||
|
||||
options.each(function() {
|
||||
options.each(function () {
|
||||
var label = ($(this).attr('label') !== undefined) ? $(this).attr('label') : $(this).text();
|
||||
selected += label + delimiter;
|
||||
});
|
||||
@@ -279,7 +279,7 @@
|
||||
* @param {jQuery} select
|
||||
* @returns {@exp;selected@call;substr}
|
||||
*/
|
||||
buttonTitle: function(options, select) {
|
||||
buttonTitle: function (options, select) {
|
||||
if (options.length === 0) {
|
||||
return this.nonSelectedText;
|
||||
}
|
||||
@@ -294,7 +294,7 @@
|
||||
return selected.substr(0, selected.length - this.delimiterText.length);
|
||||
}
|
||||
},
|
||||
checkboxName: function(option) {
|
||||
checkboxName: function (option) {
|
||||
return false; // no checkbox name
|
||||
},
|
||||
/**
|
||||
@@ -303,7 +303,7 @@
|
||||
* @param {jQuery} element
|
||||
* @returns {String}
|
||||
*/
|
||||
optionLabel: function(element){
|
||||
optionLabel: function (element) {
|
||||
return $(element).attr('label') || $(element).text();
|
||||
},
|
||||
/**
|
||||
@@ -312,7 +312,7 @@
|
||||
* @param {jQuery} element
|
||||
* @returns {String}
|
||||
*/
|
||||
optionClass: function(element) {
|
||||
optionClass: function (element) {
|
||||
return $(element).attr('class') || '';
|
||||
},
|
||||
/**
|
||||
@@ -323,7 +323,7 @@
|
||||
* @param {jQuery} option
|
||||
* @param {Boolean} checked
|
||||
*/
|
||||
onChange : function(option, checked) {
|
||||
onChange: function (option, checked) {
|
||||
|
||||
},
|
||||
/**
|
||||
@@ -331,7 +331,7 @@
|
||||
*
|
||||
* @param {jQuery} event
|
||||
*/
|
||||
onDropdownShow: function(event) {
|
||||
onDropdownShow: function (event) {
|
||||
|
||||
},
|
||||
/**
|
||||
@@ -339,7 +339,7 @@
|
||||
*
|
||||
* @param {jQuery} event
|
||||
*/
|
||||
onDropdownHide: function(event) {
|
||||
onDropdownHide: function (event) {
|
||||
|
||||
},
|
||||
/**
|
||||
@@ -347,7 +347,7 @@
|
||||
*
|
||||
* @param {jQuery} event
|
||||
*/
|
||||
onDropdownShown: function(event) {
|
||||
onDropdownShown: function (event) {
|
||||
|
||||
},
|
||||
/**
|
||||
@@ -355,19 +355,19 @@
|
||||
*
|
||||
* @param {jQuery} event
|
||||
*/
|
||||
onDropdownHidden: function(event) {
|
||||
onDropdownHidden: function (event) {
|
||||
|
||||
},
|
||||
/**
|
||||
* Triggered on select all.
|
||||
*/
|
||||
onSelectAll: function() {
|
||||
onSelectAll: function () {
|
||||
|
||||
},
|
||||
/**
|
||||
* Triggered on deselect all.
|
||||
*/
|
||||
onDeselectAll: function() {
|
||||
onDeselectAll: function () {
|
||||
|
||||
},
|
||||
/**
|
||||
@@ -376,7 +376,7 @@
|
||||
* @param {jQuery} $select
|
||||
* @param {jQuery} $container
|
||||
*/
|
||||
onInitialized: function($select, $container) {
|
||||
onInitialized: function ($select, $container) {
|
||||
|
||||
},
|
||||
/**
|
||||
@@ -384,7 +384,7 @@
|
||||
*
|
||||
* @param {jQuery} $filter
|
||||
*/
|
||||
onFiltering: function($filter) {
|
||||
onFiltering: function ($filter) {
|
||||
|
||||
},
|
||||
enableHTML: false,
|
||||
@@ -438,7 +438,7 @@
|
||||
/**
|
||||
* Builds the container of the multiselect.
|
||||
*/
|
||||
buildContainer: function() {
|
||||
buildContainer: function () {
|
||||
this.$container = $(this.options.buttonContainer);
|
||||
this.$container.on('show.bs.dropdown', this.options.onDropdownShow);
|
||||
this.$container.on('hide.bs.dropdown', this.options.onDropdownHide);
|
||||
@@ -449,7 +449,7 @@
|
||||
/**
|
||||
* Builds the button of the multiselect.
|
||||
*/
|
||||
buildButton: function() {
|
||||
buildButton: function () {
|
||||
this.$button = $(this.options.templates.button).addClass(this.options.buttonClass);
|
||||
if (this.$select.attr('class') && this.options.inheritClass) {
|
||||
this.$button.addClass(this.$select.attr('class'));
|
||||
@@ -465,13 +465,13 @@
|
||||
// Manually add button width if set.
|
||||
if (this.options.buttonWidth && this.options.buttonWidth !== 'auto') {
|
||||
this.$button.css({
|
||||
'width' : '100%', //this.options.buttonWidth,
|
||||
'overflow' : 'hidden',
|
||||
'text-overflow' : 'ellipsis'
|
||||
});
|
||||
'width': '100%', //this.options.buttonWidth,
|
||||
'overflow': 'hidden',
|
||||
'text-overflow': 'ellipsis'
|
||||
});
|
||||
this.$container.css({
|
||||
'width': this.options.buttonWidth
|
||||
});
|
||||
'width': this.options.buttonWidth
|
||||
});
|
||||
}
|
||||
|
||||
// Keep the tab index from the select.
|
||||
@@ -486,7 +486,7 @@
|
||||
/**
|
||||
* Builds the ul representing the dropdown menu.
|
||||
*/
|
||||
buildDropdown: function() {
|
||||
buildDropdown: function () {
|
||||
|
||||
// Build ul.
|
||||
this.$ul = $(this.options.templates.ul);
|
||||
@@ -499,23 +499,23 @@
|
||||
if (this.options.maxHeight) {
|
||||
// TODO: Add a class for this option to move the css declarations.
|
||||
this.$ul.css({
|
||||
'max-height': this.options.maxHeight + 'px',
|
||||
'overflow-y': 'auto',
|
||||
'overflow-x': 'hidden'
|
||||
});
|
||||
'max-height': this.options.maxHeight + 'px',
|
||||
'overflow-y': 'auto',
|
||||
'overflow-x': 'hidden'
|
||||
});
|
||||
}
|
||||
|
||||
if (this.options.dropUp) {
|
||||
|
||||
var height = Math.min(this.options.maxHeight, $('option[data-role!="divider"]', this.$select).length*26 + $('option[data-role="divider"]', this.$select).length*19 + (this.options.includeSelectAllOption ? 26 : 0) + (this.options.enableFiltering || this.options.enableCaseInsensitiveFiltering ? 44 : 0));
|
||||
var height = Math.min(this.options.maxHeight, $('option[data-role!="divider"]', this.$select).length * 26 + $('option[data-role="divider"]', this.$select).length * 19 + (this.options.includeSelectAllOption ? 26 : 0) + (this.options.enableFiltering || this.options.enableCaseInsensitiveFiltering ? 44 : 0));
|
||||
var moveCalc = height + 34;
|
||||
|
||||
this.$ul.css({
|
||||
'max-height': height + 'px',
|
||||
'overflow-y': 'auto',
|
||||
'overflow-x': 'hidden',
|
||||
'margin-top': "-" + moveCalc + 'px'
|
||||
});
|
||||
'max-height': height + 'px',
|
||||
'overflow-y': 'auto',
|
||||
'overflow-x': 'hidden',
|
||||
'margin-top': "-" + moveCalc + 'px'
|
||||
});
|
||||
}
|
||||
|
||||
this.$container.append(this.$ul);
|
||||
@@ -526,9 +526,9 @@
|
||||
*
|
||||
* Uses createDivider and createOptionValue to create the necessary options.
|
||||
*/
|
||||
buildDropdownOptions: function() {
|
||||
buildDropdownOptions: function () {
|
||||
|
||||
this.$select.children().each($.proxy(function(index, element) {
|
||||
this.$select.children().each($.proxy(function (index, element) {
|
||||
|
||||
var $element = $(element);
|
||||
// Support optgroups and options without a group simultaneously.
|
||||
@@ -557,7 +557,7 @@
|
||||
}, this));
|
||||
|
||||
// Bind the change event on the dropdown elements.
|
||||
$('li:not(.multiselect-group) input', this.$ul).on('change', $.proxy(function(event) {
|
||||
$('li:not(.multiselect-group) input', this.$ul).on('change', $.proxy(function (event) {
|
||||
var $target = $(event.target);
|
||||
|
||||
var checked = $target.prop('checked') || false;
|
||||
@@ -635,25 +635,25 @@
|
||||
this.$select.change();
|
||||
this.updateButtonText();
|
||||
|
||||
if(this.options.preventInputChangeEvent) {
|
||||
if (this.options.preventInputChangeEvent) {
|
||||
return false;
|
||||
}
|
||||
}, this));
|
||||
|
||||
$('li a', this.$ul).on('mousedown', function(e) {
|
||||
$('li a', this.$ul).on('mousedown', function (e) {
|
||||
if (e.shiftKey) {
|
||||
// Prevent selecting text by Shift+click
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('li a', this.$ul).on('touchstart click', $.proxy(function(event) {
|
||||
$('li a', this.$ul).on('touchstart click', $.proxy(function (event) {
|
||||
event.stopPropagation();
|
||||
|
||||
var $target = $(event.target);
|
||||
|
||||
if (event.shiftKey && this.options.multiple) {
|
||||
if($target.is("label")){ // Handles checkbox selection manually (see https://github.com/davidstutz/bootstrap-multiselect/issues/431)
|
||||
if ($target.is("label")) { // Handles checkbox selection manually (see https://github.com/davidstutz/bootstrap-multiselect/issues/431)
|
||||
event.preventDefault();
|
||||
$target = $target.find("input");
|
||||
$target.prop("checked", !$target.prop("checked"));
|
||||
@@ -697,7 +697,7 @@
|
||||
}
|
||||
|
||||
// Remembers last clicked option
|
||||
if($target.is("input") && !$target.closest("li").is(".multiselect-item")){
|
||||
if ($target.is("input") && !$target.closest("li").is(".multiselect-item")) {
|
||||
this.lastToggledInput = $target;
|
||||
}
|
||||
|
||||
@@ -705,7 +705,7 @@
|
||||
}, this));
|
||||
|
||||
// Keyboard support.
|
||||
this.$container.off('keydown.multiselect').on('keydown.multiselect', $.proxy(function(event) {
|
||||
this.$container.off('keydown.multiselect').on('keydown.multiselect', $.proxy(function (event) {
|
||||
if ($('input[type="text"]', this.$container).is(':focus')) {
|
||||
return;
|
||||
}
|
||||
@@ -750,7 +750,7 @@
|
||||
}, this));
|
||||
|
||||
if (this.options.enableClickableOptGroups && this.options.multiple) {
|
||||
$("li.multiselect-group input", this.$ul).on("change", $.proxy(function(event) {
|
||||
$("li.multiselect-group input", this.$ul).on("change", $.proxy(function (event) {
|
||||
event.stopPropagation();
|
||||
|
||||
var $target = $(event.target);
|
||||
@@ -775,7 +775,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$.each($inputs, $.proxy(function(index, input) {
|
||||
$.each($inputs, $.proxy(function (index, input) {
|
||||
var value = $(input).val();
|
||||
var $option = this.getOptionByValue(value);
|
||||
|
||||
@@ -807,13 +807,13 @@
|
||||
}
|
||||
|
||||
if (this.options.enableCollapsibleOptGroups && this.options.multiple) {
|
||||
$("li.multiselect-group .caret-container", this.$ul).on("click", $.proxy(function(event) {
|
||||
$("li.multiselect-group .caret-container", this.$ul).on("click", $.proxy(function (event) {
|
||||
var $li = $(event.target).closest('li');
|
||||
var $inputs = $li.nextUntil("li.multiselect-group")
|
||||
.not('.multiselect-filter-hidden');
|
||||
.not('.multiselect-filter-hidden');
|
||||
|
||||
var visible = true;
|
||||
$inputs.each(function() {
|
||||
$inputs.each(function () {
|
||||
visible = visible && $(this).is(':visible');
|
||||
});
|
||||
|
||||
@@ -838,7 +838,7 @@
|
||||
*
|
||||
* @param {jQuery} element
|
||||
*/
|
||||
createOptionValue: function(element) {
|
||||
createOptionValue: function (element) {
|
||||
var $element = $(element);
|
||||
if ($element.is(':selected')) {
|
||||
$element.prop('selected', true);
|
||||
@@ -906,7 +906,7 @@
|
||||
*
|
||||
* @param {jQuery} element
|
||||
*/
|
||||
createDivider: function(element) {
|
||||
createDivider: function (element) {
|
||||
var $divider = $(this.options.templates.divider);
|
||||
this.$ul.append($divider);
|
||||
},
|
||||
@@ -916,7 +916,7 @@
|
||||
*
|
||||
* @param {jQuery} group
|
||||
*/
|
||||
createOptgroup: function(group) {
|
||||
createOptgroup: function (group) {
|
||||
var label = $(group).attr("label");
|
||||
var value = $(group).attr("value");
|
||||
var $li = $('<li class="multiselect-item multiselect-group"><a href="javascript:void(0);"><label><b></b></label></a></li>');
|
||||
@@ -945,7 +945,7 @@
|
||||
|
||||
this.$ul.append($li);
|
||||
|
||||
$("option", group).each($.proxy(function($, group) {
|
||||
$("option", group).each($.proxy(function ($, group) {
|
||||
this.createOptionValue(group);
|
||||
}, this))
|
||||
},
|
||||
@@ -955,7 +955,7 @@
|
||||
*
|
||||
* Checks if a select all has already been created.
|
||||
*/
|
||||
buildSelectAll: function() {
|
||||
buildSelectAll: function () {
|
||||
if (typeof this.options.selectAllValue === 'number') {
|
||||
this.options.selectAllValue = this.options.selectAllValue.toString();
|
||||
}
|
||||
@@ -963,7 +963,7 @@
|
||||
var alreadyHasSelectAll = this.hasSelectAll();
|
||||
|
||||
if (!alreadyHasSelectAll && this.options.includeSelectAllOption && this.options.multiple
|
||||
&& $('option', this.$select).length > this.options.includeSelectAllIfMoreThan) {
|
||||
&& $('option', this.$select).length > this.options.includeSelectAllIfMoreThan) {
|
||||
|
||||
// Check whether to add a divider after the select all.
|
||||
if (this.options.includeSelectAllDivider) {
|
||||
@@ -1003,7 +1003,7 @@
|
||||
/**
|
||||
* Builds the filter.
|
||||
*/
|
||||
buildFilter: function() {
|
||||
buildFilter: function () {
|
||||
|
||||
// Build filter if filtering OR case insensitive filtering is enabled and the number of options exceeds (or equals) enableFilterLength.
|
||||
if (this.options.enableFiltering || this.options.enableCaseInsensitiveFiltering) {
|
||||
@@ -1015,9 +1015,9 @@
|
||||
$('input', this.$filter).attr('placeholder', this.options.filterPlaceholder);
|
||||
|
||||
// Adds optional filter clear button
|
||||
if(this.options.includeFilterClearBtn) {
|
||||
if (this.options.includeFilterClearBtn) {
|
||||
var clearBtn = $(this.options.templates.filterClearBtn);
|
||||
clearBtn.on('click', $.proxy(function(event){
|
||||
clearBtn.on('click', $.proxy(function (event) {
|
||||
clearTimeout(this.searchTimeout);
|
||||
|
||||
this.$filter.find('.multiselect-search').val('');
|
||||
@@ -1035,24 +1035,24 @@
|
||||
|
||||
this.$ul.prepend(this.$filter);
|
||||
|
||||
this.$filter.val(this.query).on('click', function(event) {
|
||||
this.$filter.val(this.query).on('click', function (event) {
|
||||
event.stopPropagation();
|
||||
}).on('input keydown', $.proxy(function(event) {
|
||||
}).on('input keydown', $.proxy(function (event) {
|
||||
// Cancel enter key default behaviour
|
||||
if (event.which === 13) {
|
||||
event.preventDefault();
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// This is useful to catch "keydown" events after the browser has updated the control.
|
||||
clearTimeout(this.searchTimeout);
|
||||
|
||||
this.searchTimeout = this.asyncFunction($.proxy(function() {
|
||||
this.searchTimeout = this.asyncFunction($.proxy(function () {
|
||||
|
||||
if (this.query !== event.target.value) {
|
||||
this.query = event.target.value;
|
||||
|
||||
var currentGroup, currentGroupVisible;
|
||||
$.each($('li', this.$ul), $.proxy(function(index, element) {
|
||||
$.each($('li', this.$ul), $.proxy(function (index, element) {
|
||||
var value = $('input', element).length > 0 ? $('input', element).val() : "";
|
||||
var text = $('label', element).text();
|
||||
|
||||
@@ -1132,7 +1132,7 @@
|
||||
/**
|
||||
* Unbinds the whole plugin.
|
||||
*/
|
||||
destroy: function() {
|
||||
destroy: function () {
|
||||
this.$container.remove();
|
||||
this.$select.show();
|
||||
|
||||
@@ -1205,8 +1205,8 @@
|
||||
* @param {Array} selectValues
|
||||
* @param {Boolean} triggerOnChange
|
||||
*/
|
||||
select: function(selectValues, triggerOnChange) {
|
||||
if(!$.isArray(selectValues)) {
|
||||
select: function (selectValues, triggerOnChange) {
|
||||
if (!$.isArray(selectValues)) {
|
||||
selectValues = [selectValues];
|
||||
}
|
||||
|
||||
@@ -1220,7 +1220,7 @@
|
||||
var $option = this.getOptionByValue(value);
|
||||
var $checkbox = this.getInputByValue(value);
|
||||
|
||||
if($option === undefined || $checkbox === undefined) {
|
||||
if ($option === undefined || $checkbox === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1271,8 +1271,8 @@
|
||||
* @param {Array} deselectValues
|
||||
* @param {Boolean} triggerOnChange
|
||||
*/
|
||||
deselect: function(deselectValues, triggerOnChange) {
|
||||
if(!$.isArray(deselectValues)) {
|
||||
deselect: function (deselectValues, triggerOnChange) {
|
||||
if (!$.isArray(deselectValues)) {
|
||||
deselectValues = [deselectValues];
|
||||
}
|
||||
|
||||
@@ -1286,7 +1286,7 @@
|
||||
var $option = this.getOptionByValue(value);
|
||||
var $checkbox = this.getInputByValue(value);
|
||||
|
||||
if($option === undefined || $checkbox === undefined) {
|
||||
if ($option === undefined || $checkbox === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1325,21 +1325,21 @@
|
||||
var allLis = $("li:not(.divider):not(.disabled):not(.multiselect-group)", this.$ul);
|
||||
var visibleLis = $("li:not(.divider):not(.disabled):not(.multiselect-group):not(.multiselect-filter-hidden):not(.multiselect-collapisble-hidden)", this.$ul).filter(':visible');
|
||||
|
||||
if(justVisible) {
|
||||
$('input:enabled' , visibleLis).prop('checked', true);
|
||||
if (justVisible) {
|
||||
$('input:enabled', visibleLis).prop('checked', true);
|
||||
visibleLis.addClass(this.options.selectedClass);
|
||||
|
||||
$('input:enabled' , visibleLis).each($.proxy(function(index, element) {
|
||||
$('input:enabled', visibleLis).each($.proxy(function (index, element) {
|
||||
var value = $(element).val();
|
||||
var option = this.getOptionByValue(value);
|
||||
$(option).prop('selected', true);
|
||||
}, this));
|
||||
}
|
||||
else {
|
||||
$('input:enabled' , allLis).prop('checked', true);
|
||||
$('input:enabled', allLis).prop('checked', true);
|
||||
allLis.addClass(this.options.selectedClass);
|
||||
|
||||
$('input:enabled' , allLis).each($.proxy(function(index, element) {
|
||||
$('input:enabled', allLis).each($.proxy(function (index, element) {
|
||||
var value = $(element).val();
|
||||
var option = this.getOptionByValue(value);
|
||||
$(option).prop('selected', true);
|
||||
@@ -1370,21 +1370,21 @@
|
||||
var allLis = $("li:not(.divider):not(.disabled):not(.multiselect-group)", this.$ul);
|
||||
var visibleLis = $("li:not(.divider):not(.disabled):not(.multiselect-group):not(.multiselect-filter-hidden):not(.multiselect-collapisble-hidden)", this.$ul).filter(':visible');
|
||||
|
||||
if(justVisible) {
|
||||
$('input[type="checkbox"]:enabled' , visibleLis).prop('checked', false);
|
||||
if (justVisible) {
|
||||
$('input[type="checkbox"]:enabled', visibleLis).prop('checked', false);
|
||||
visibleLis.removeClass(this.options.selectedClass);
|
||||
|
||||
$('input[type="checkbox"]:enabled' , visibleLis).each($.proxy(function(index, element) {
|
||||
$('input[type="checkbox"]:enabled', visibleLis).each($.proxy(function (index, element) {
|
||||
var value = $(element).val();
|
||||
var option = this.getOptionByValue(value);
|
||||
$(option).prop('selected', false);
|
||||
}, this));
|
||||
}
|
||||
else {
|
||||
$('input[type="checkbox"]:enabled' , allLis).prop('checked', false);
|
||||
$('input[type="checkbox"]:enabled', allLis).prop('checked', false);
|
||||
allLis.removeClass(this.options.selectedClass);
|
||||
|
||||
$('input[type="checkbox"]:enabled' , allLis).each($.proxy(function(index, element) {
|
||||
$('input[type="checkbox"]:enabled', allLis).each($.proxy(function (index, element) {
|
||||
var value = $(element).val();
|
||||
var option = this.getOptionByValue(value);
|
||||
$(option).prop('selected', false);
|
||||
@@ -1407,7 +1407,7 @@
|
||||
*
|
||||
* Rebuilds the dropdown, the filter and the select all option.
|
||||
*/
|
||||
rebuild: function() {
|
||||
rebuild: function () {
|
||||
this.$ul.html('');
|
||||
|
||||
// Important to distinguish between radios and checkboxes.
|
||||
@@ -1439,7 +1439,7 @@
|
||||
/**
|
||||
* The provided data will be used to build the dropdown.
|
||||
*/
|
||||
dataprovider: function(dataprovider) {
|
||||
dataprovider: function (dataprovider) {
|
||||
|
||||
var groupCounter = 0;
|
||||
var $select = this.$select.empty();
|
||||
@@ -1451,11 +1451,11 @@
|
||||
groupCounter++;
|
||||
|
||||
$tag = $('<optgroup/>').attr({
|
||||
label: option.label || 'Group ' + groupCounter,
|
||||
disabled: !!option.disabled
|
||||
});
|
||||
label: option.label || 'Group ' + groupCounter,
|
||||
disabled: !!option.disabled
|
||||
});
|
||||
|
||||
forEach(option.children, function(subOption) { // add children option tags
|
||||
forEach(option.children, function (subOption) { // add children option tags
|
||||
var attributes = {
|
||||
value: subOption.value,
|
||||
label: subOption.label || subOption.value,
|
||||
@@ -1465,10 +1465,10 @@
|
||||
};
|
||||
|
||||
//Loop through attributes object and add key-value for each attribute
|
||||
for (var key in subOption.attributes) {
|
||||
for (var key in subOption.attributes) {
|
||||
attributes['data-' + key] = subOption.attributes[key];
|
||||
}
|
||||
//Append original attributes + new data attributes to option
|
||||
}
|
||||
//Append original attributes + new data attributes to option
|
||||
$tag.append($('<option/>').attr(attributes));
|
||||
});
|
||||
}
|
||||
@@ -1484,7 +1484,7 @@
|
||||
};
|
||||
//Loop through attributes object and add key-value for each attribute
|
||||
for (var key in option.attributes) {
|
||||
attributes['data-' + key] = option.attributes[key];
|
||||
attributes['data-' + key] = option.attributes[key];
|
||||
}
|
||||
//Append original attributes + new data attributes to option
|
||||
$tag = $('<option/>').attr(attributes);
|
||||
@@ -1501,7 +1501,7 @@
|
||||
/**
|
||||
* Enable the multiselect.
|
||||
*/
|
||||
enable: function() {
|
||||
enable: function () {
|
||||
this.$select.prop('disabled', false);
|
||||
this.$button.prop('disabled', false)
|
||||
.removeClass('disabled');
|
||||
@@ -1510,7 +1510,7 @@
|
||||
/**
|
||||
* Disable the multiselect.
|
||||
*/
|
||||
disable: function() {
|
||||
disable: function () {
|
||||
this.$select.prop('disabled', true);
|
||||
this.$button.prop('disabled', true)
|
||||
.addClass('disabled');
|
||||
@@ -1521,7 +1521,7 @@
|
||||
*
|
||||
* @param {Array} options
|
||||
*/
|
||||
setOptions: function(options) {
|
||||
setOptions: function (options) {
|
||||
this.options = this.mergeOptions(options);
|
||||
},
|
||||
|
||||
@@ -1531,7 +1531,7 @@
|
||||
* @param {Array} options
|
||||
* @returns {Array}
|
||||
*/
|
||||
mergeOptions: function(options) {
|
||||
mergeOptions: function (options) {
|
||||
return $.extend(true, {}, this.defaults, this.options, options);
|
||||
},
|
||||
|
||||
@@ -1540,24 +1540,24 @@
|
||||
*
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
hasSelectAll: function() {
|
||||
hasSelectAll: function () {
|
||||
return $('li.multiselect-all', this.$ul).length > 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Update opt groups.
|
||||
*/
|
||||
updateOptGroups: function() {
|
||||
updateOptGroups: function () {
|
||||
var $groups = $('li.multiselect-group', this.$ul)
|
||||
var selectedClass = this.options.selectedClass;
|
||||
|
||||
$groups.each(function() {
|
||||
$groups.each(function () {
|
||||
var $options = $(this).nextUntil('li.multiselect-group')
|
||||
.not('.multiselect-filter-hidden')
|
||||
.not('.disabled');
|
||||
|
||||
var checked = true;
|
||||
$options.each(function() {
|
||||
$options.each(function () {
|
||||
var $input = $('input', this);
|
||||
|
||||
if (!$input.prop('checked')) {
|
||||
@@ -1581,12 +1581,12 @@
|
||||
/**
|
||||
* Updates the select all checkbox based on the currently displayed and selected checkboxes.
|
||||
*/
|
||||
updateSelectAll: function(notTriggerOnSelectAll) {
|
||||
updateSelectAll: function (notTriggerOnSelectAll) {
|
||||
if (this.hasSelectAll()) {
|
||||
var allBoxes = $("li:not(.multiselect-item):not(.multiselect-filter-hidden):not(.multiselect-group):not(.disabled) input:enabled", this.$ul);
|
||||
var allBoxesLength = allBoxes.length;
|
||||
var checkedBoxesLength = allBoxes.filter(":checked").length;
|
||||
var selectAllLi = $("li.multiselect-all", this.$ul);
|
||||
var selectAllLi = $("li.multiselect-all", this.$ul);
|
||||
var selectAllInput = selectAllLi.find("input");
|
||||
|
||||
if (checkedBoxesLength > 0 && checkedBoxesLength === allBoxesLength) {
|
||||
@@ -1603,7 +1603,7 @@
|
||||
/**
|
||||
* Update the button text and its title based on the currently selected options.
|
||||
*/
|
||||
updateButtonText: function() {
|
||||
updateButtonText: function () {
|
||||
var options = this.getSelected();
|
||||
|
||||
// First update the displayed button text.
|
||||
@@ -1623,7 +1623,7 @@
|
||||
*
|
||||
* @returns {jQUery}
|
||||
*/
|
||||
getSelected: function() {
|
||||
getSelected: function () {
|
||||
return $('option', this.$select).filter(":selected");
|
||||
},
|
||||
|
||||
@@ -1668,25 +1668,25 @@
|
||||
/**
|
||||
* Used for knockout integration.
|
||||
*/
|
||||
updateOriginalOptions: function() {
|
||||
updateOriginalOptions: function () {
|
||||
this.originalOptions = this.$select.clone()[0].options;
|
||||
},
|
||||
|
||||
asyncFunction: function(callback, timeout, self) {
|
||||
asyncFunction: function (callback, timeout, self) {
|
||||
var args = Array.prototype.slice.call(arguments, 3);
|
||||
return setTimeout(function() {
|
||||
return setTimeout(function () {
|
||||
callback.apply(self || window, args);
|
||||
}, timeout);
|
||||
},
|
||||
|
||||
setAllSelectedText: function(allSelectedText) {
|
||||
setAllSelectedText: function (allSelectedText) {
|
||||
this.options.allSelectedText = allSelectedText;
|
||||
this.updateButtonText();
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.multiselect = function(option, parameter, extraOptions) {
|
||||
return this.each(function() {
|
||||
$.fn.multiselect = function (option, parameter, extraOptions) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data('multiselect');
|
||||
var options = typeof option === 'object' && option;
|
||||
|
||||
@@ -1709,7 +1709,7 @@
|
||||
|
||||
$.fn.multiselect.Constructor = Multiselect;
|
||||
|
||||
$(function() {
|
||||
$(function () {
|
||||
$("select[data-role=multiselect]").multiselect();
|
||||
});
|
||||
|
||||
|
||||
24
public/js/lib/bootstrap-sortable.js
vendored
24
public/js/lib/bootstrap-sortable.js
vendored
@@ -31,7 +31,7 @@
|
||||
initialize({});
|
||||
}
|
||||
else if (options.constructor === Boolean) {
|
||||
initialize({ applyLast: options });
|
||||
initialize({applyLast: options});
|
||||
}
|
||||
else if (options.sortingHeader !== undefined) {
|
||||
sortByColumn(options.sortingHeader);
|
||||
@@ -128,7 +128,7 @@
|
||||
});
|
||||
|
||||
var context = lookupSortContext($this),
|
||||
bsSort = context.bsSort;
|
||||
bsSort = context.bsSort;
|
||||
|
||||
$this.find('thead th[data-defaultsort!="disabled"]').each(function (index) {
|
||||
var $header = $(this);
|
||||
@@ -164,7 +164,7 @@
|
||||
function lookupSortContext($table) {
|
||||
var context = $table.data("bootstrap-sortable-context");
|
||||
if (context === undefined) {
|
||||
context = { bsSort: [], lastSort: undefined };
|
||||
context = {bsSort: [], lastSort: undefined};
|
||||
$table.find('thead th[data-defaultsort!="disabled"]').each(function (index) {
|
||||
var $this = $(this);
|
||||
var sortKey = $this.attr('data-sortkey');
|
||||
@@ -185,8 +185,8 @@
|
||||
// Sorting mechanism separated
|
||||
function doSort($this, $table) {
|
||||
var sortColumn = parseFloat($this.attr('data-sortcolumn')),
|
||||
context = lookupSortContext($table),
|
||||
bsSort = context.bsSort;
|
||||
context = lookupSortContext($table),
|
||||
bsSort = context.bsSort;
|
||||
|
||||
var colspan = $this.attr('colspan');
|
||||
if (colspan) {
|
||||
@@ -246,7 +246,7 @@
|
||||
var fixedRows = [];
|
||||
$(rows.filter('[data-disablesort="true"]').get().reverse()).each(function (index, fixedRow) {
|
||||
var $fixedRow = $(fixedRow);
|
||||
fixedRows.push({ index: rows.index($fixedRow), row: $fixedRow });
|
||||
fixedRows.push({index: rows.index($fixedRow), row: $fixedRow});
|
||||
$fixedRow.remove();
|
||||
});
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
var rowsToSort = rows.not('[data-disablesort="true"]');
|
||||
if (rowsToSort.length != 0) {
|
||||
var emptySorting = bsSort[sortKey] === 'asc' ? emptyEnd : false;
|
||||
sortEngine(rowsToSort, { emptyEnd: emptySorting, selector: 'td:nth-child(' + (sortColumn + 1) + ')', order: bsSort[sortKey], data: 'value' });
|
||||
sortEngine(rowsToSort, {emptyEnd: emptySorting, selector: 'td:nth-child(' + (sortColumn + 1) + ')', order: bsSort[sortKey], data: 'value'});
|
||||
}
|
||||
|
||||
// add back the fixed rows
|
||||
@@ -274,12 +274,16 @@
|
||||
|
||||
// jQuery 1.9 removed this object
|
||||
if (!$.browser) {
|
||||
$.browser = { chrome: false, mozilla: false, opera: false, msie: false, safari: false };
|
||||
$.browser = {chrome: false, mozilla: false, opera: false, msie: false, safari: false};
|
||||
var ua = navigator.userAgent;
|
||||
$.each($.browser, function (c) {
|
||||
$.browser[c] = ((new RegExp(c, 'i').test(ua))) ? true : false;
|
||||
if ($.browser.mozilla && c === 'mozilla') { $.browser.mozilla = ((new RegExp('firefox', 'i').test(ua))) ? true : false; }
|
||||
if ($.browser.chrome && c === 'safari') { $.browser.safari = false; }
|
||||
if ($.browser.mozilla && c === 'mozilla') {
|
||||
$.browser.mozilla = ((new RegExp('firefox', 'i').test(ua))) ? true : false;
|
||||
}
|
||||
if ($.browser.chrome && c === 'safari') {
|
||||
$.browser.safari = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @version: 2.1.25
|
||||
* @author: Dan Grossman http://www.dangrossman.info/
|
||||
* @copyright: Copyright (c) 2012-2017 Dan Grossman. All rights reserved.
|
||||
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
|
||||
* @website: http://www.daterangepicker.com/
|
||||
*/
|
||||
* @version: 2.1.25
|
||||
* @author: Dan Grossman http://www.dangrossman.info/
|
||||
* @copyright: Copyright (c) 2012-2017 Dan Grossman. All rights reserved.
|
||||
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
|
||||
* @website: http://www.daterangepicker.com/
|
||||
*/
|
||||
// Follow the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@@ -27,8 +27,8 @@
|
||||
// Browser globals
|
||||
root.daterangepicker = factory(root.moment, root.jQuery);
|
||||
}
|
||||
}(this, function(moment, $) {
|
||||
var DateRangePicker = function(element, options, cb) {
|
||||
}(this, function (moment, $) {
|
||||
var DateRangePicker = function (element, options, cb) {
|
||||
|
||||
//default settings for options
|
||||
this.parentEl = 'body';
|
||||
@@ -78,7 +78,8 @@
|
||||
firstDay: moment.localeData().firstDayOfWeek()
|
||||
};
|
||||
|
||||
this.callback = function() { };
|
||||
this.callback = function () {
|
||||
};
|
||||
|
||||
//some state information
|
||||
this.isShowing = false;
|
||||
@@ -96,35 +97,35 @@
|
||||
//html template for the picker UI
|
||||
if (typeof options.template !== 'string' && !(options.template instanceof $))
|
||||
options.template = '<div class="daterangepicker dropdown-menu">' +
|
||||
'<div class="calendar left">' +
|
||||
'<div class="daterangepicker_input">' +
|
||||
'<input class="input-mini form-control" type="text" name="daterangepicker_start" value="" />' +
|
||||
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
||||
'<div class="calendar-time">' +
|
||||
'<div></div>' +
|
||||
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="calendar-table"></div>' +
|
||||
'</div>' +
|
||||
'<div class="calendar right">' +
|
||||
'<div class="daterangepicker_input">' +
|
||||
'<input class="input-mini form-control" type="text" name="daterangepicker_end" value="" />' +
|
||||
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
||||
'<div class="calendar-time">' +
|
||||
'<div></div>' +
|
||||
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="calendar-table"></div>' +
|
||||
'</div>' +
|
||||
'<div class="ranges">' +
|
||||
'<div class="range_inputs">' +
|
||||
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
|
||||
'<button class="cancelBtn" type="button"></button>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
'<div class="calendar left">' +
|
||||
'<div class="daterangepicker_input">' +
|
||||
'<input class="input-mini form-control" type="text" name="daterangepicker_start" value="" />' +
|
||||
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
||||
'<div class="calendar-time">' +
|
||||
'<div></div>' +
|
||||
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="calendar-table"></div>' +
|
||||
'</div>' +
|
||||
'<div class="calendar right">' +
|
||||
'<div class="daterangepicker_input">' +
|
||||
'<input class="input-mini form-control" type="text" name="daterangepicker_end" value="" />' +
|
||||
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
||||
'<div class="calendar-time">' +
|
||||
'<div></div>' +
|
||||
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="calendar-table"></div>' +
|
||||
'</div>' +
|
||||
'<div class="ranges">' +
|
||||
'<div class="range_inputs">' +
|
||||
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
|
||||
'<button class="cancelBtn" type="button"></button>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
|
||||
this.container = $(options.template).appendTo(this.parentEl);
|
||||
@@ -148,21 +149,21 @@
|
||||
this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
|
||||
|
||||
if (typeof options.locale.monthNames === 'object')
|
||||
this.locale.monthNames = options.locale.monthNames.slice();
|
||||
this.locale.monthNames = options.locale.monthNames.slice();
|
||||
|
||||
if (typeof options.locale.firstDay === 'number')
|
||||
this.locale.firstDay = options.locale.firstDay;
|
||||
this.locale.firstDay = options.locale.firstDay;
|
||||
|
||||
if (typeof options.locale.applyLabel === 'string')
|
||||
this.locale.applyLabel = options.locale.applyLabel;
|
||||
this.locale.applyLabel = options.locale.applyLabel;
|
||||
|
||||
if (typeof options.locale.cancelLabel === 'string')
|
||||
this.locale.cancelLabel = options.locale.cancelLabel;
|
||||
this.locale.cancelLabel = options.locale.cancelLabel;
|
||||
|
||||
if (typeof options.locale.weekLabel === 'string')
|
||||
this.locale.weekLabel = options.locale.weekLabel;
|
||||
this.locale.weekLabel = options.locale.weekLabel;
|
||||
|
||||
if (typeof options.locale.customRangeLabel === 'string'){
|
||||
if (typeof options.locale.customRangeLabel === 'string') {
|
||||
//Support unicode chars in the custom range name.
|
||||
var elem = document.createElement('textarea');
|
||||
elem.innerHTML = options.locale.customRangeLabel;
|
||||
@@ -287,7 +288,7 @@
|
||||
//if no start/end dates set, check if an input element contains initial values
|
||||
if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
|
||||
if ($(this.element).is('input[type=text]')) {
|
||||
var val = $(this.element).val(),
|
||||
var val = $(this.element).val(),
|
||||
split = val.split(this.locale.separator);
|
||||
|
||||
start = end = null;
|
||||
@@ -332,8 +333,8 @@
|
||||
|
||||
// If the end of the range is before the minimum or the start of the range is
|
||||
// after the maximum, don't display this range option at all.
|
||||
if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
|
||||
|| (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
|
||||
if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
|
||||
|| (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
|
||||
continue;
|
||||
|
||||
//Support unicode chars in the range names.
|
||||
@@ -396,7 +397,7 @@
|
||||
|
||||
//swap the position of the predefined ranges if opens right
|
||||
if (typeof options.ranges !== 'undefined' && this.opens == 'right') {
|
||||
this.container.find('.ranges').prependTo( this.container.find('.calendar.left').parent() );
|
||||
this.container.find('.ranges').prependTo(this.container.find('.calendar.left').parent());
|
||||
}
|
||||
|
||||
//apply CSS classes and labels to buttons
|
||||
@@ -435,11 +436,11 @@
|
||||
|
||||
if (this.element.is('input') || this.element.is('button')) {
|
||||
this.element.on({
|
||||
'click.daterangepicker': $.proxy(this.show, this),
|
||||
'focus.daterangepicker': $.proxy(this.show, this),
|
||||
'keyup.daterangepicker': $.proxy(this.elementChanged, this),
|
||||
'keydown.daterangepicker': $.proxy(this.keydown, this)
|
||||
});
|
||||
'click.daterangepicker': $.proxy(this.show, this),
|
||||
'focus.daterangepicker': $.proxy(this.show, this),
|
||||
'keyup.daterangepicker': $.proxy(this.elementChanged, this),
|
||||
'keydown.daterangepicker': $.proxy(this.keydown, this)
|
||||
});
|
||||
} else {
|
||||
this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
|
||||
}
|
||||
@@ -462,7 +463,7 @@
|
||||
|
||||
constructor: DateRangePicker,
|
||||
|
||||
setStartDate: function(startDate) {
|
||||
setStartDate: function (startDate) {
|
||||
if (typeof startDate === 'string')
|
||||
this.startDate = moment(startDate, this.locale.format);
|
||||
|
||||
@@ -493,7 +494,7 @@
|
||||
this.updateMonthsInView();
|
||||
},
|
||||
|
||||
setEndDate: function(endDate) {
|
||||
setEndDate: function (endDate) {
|
||||
if (typeof endDate === 'string')
|
||||
this.endDate = moment(endDate, this.locale.format);
|
||||
|
||||
@@ -523,15 +524,15 @@
|
||||
this.updateMonthsInView();
|
||||
},
|
||||
|
||||
isInvalidDate: function() {
|
||||
isInvalidDate: function () {
|
||||
return false;
|
||||
},
|
||||
|
||||
isCustomDate: function() {
|
||||
isCustomDate: function () {
|
||||
return false;
|
||||
},
|
||||
|
||||
updateView: function() {
|
||||
updateView: function () {
|
||||
if (this.timePicker) {
|
||||
this.renderTimePicker('left');
|
||||
this.renderTimePicker('right');
|
||||
@@ -553,7 +554,7 @@
|
||||
this.updateFormInputs();
|
||||
},
|
||||
|
||||
updateMonthsInView: function() {
|
||||
updateMonthsInView: function () {
|
||||
if (this.endDate) {
|
||||
|
||||
//if both dates are visible already, do nothing
|
||||
@@ -561,7 +562,7 @@
|
||||
(this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
|
||||
&&
|
||||
(this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
|
||||
) {
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -579,12 +580,12 @@
|
||||
}
|
||||
}
|
||||
if (this.maxDate && this.linkedCalendars && !this.singleDatePicker && this.rightCalendar.month > this.maxDate) {
|
||||
this.rightCalendar.month = this.maxDate.clone().date(2);
|
||||
this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month');
|
||||
this.rightCalendar.month = this.maxDate.clone().date(2);
|
||||
this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month');
|
||||
}
|
||||
},
|
||||
|
||||
updateCalendars: function() {
|
||||
updateCalendars: function () {
|
||||
|
||||
if (this.timePicker) {
|
||||
var hour, minute, second;
|
||||
@@ -625,7 +626,7 @@
|
||||
this.calculateChosenLabel();
|
||||
},
|
||||
|
||||
renderCalendar: function(side) {
|
||||
renderCalendar: function (side) {
|
||||
|
||||
//
|
||||
// Build the matrix of dates that will populate the calendar
|
||||
@@ -727,12 +728,12 @@
|
||||
for (var m = 0; m < 12; m++) {
|
||||
if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
|
||||
monthHtml += "<option value='" + m + "'" +
|
||||
(m === currentMonth ? " selected='selected'" : "") +
|
||||
">" + this.locale.monthNames[m] + "</option>";
|
||||
(m === currentMonth ? " selected='selected'" : "") +
|
||||
">" + this.locale.monthNames[m] + "</option>";
|
||||
} else {
|
||||
monthHtml += "<option value='" + m + "'" +
|
||||
(m === currentMonth ? " selected='selected'" : "") +
|
||||
" disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
|
||||
(m === currentMonth ? " selected='selected'" : "") +
|
||||
" disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
|
||||
}
|
||||
}
|
||||
monthHtml += "</select>";
|
||||
@@ -740,8 +741,8 @@
|
||||
var yearHtml = '<select class="yearselect">';
|
||||
for (var y = minYear; y <= maxYear; y++) {
|
||||
yearHtml += '<option value="' + y + '"' +
|
||||
(y === currentYear ? ' selected="selected"' : '') +
|
||||
'>' + y + '</option>';
|
||||
(y === currentYear ? ' selected="selected"' : '') +
|
||||
'>' + y + '</option>';
|
||||
}
|
||||
yearHtml += '</select>';
|
||||
|
||||
@@ -762,7 +763,7 @@
|
||||
if (this.showWeekNumbers || this.showISOWeekNumbers)
|
||||
html += '<th class="week">' + this.locale.weekLabel + '</th>';
|
||||
|
||||
$.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
|
||||
$.each(this.locale.daysOfWeek, function (index, dayOfWeek) {
|
||||
html += '<th>' + dayOfWeek + '</th>';
|
||||
});
|
||||
|
||||
@@ -859,7 +860,7 @@
|
||||
|
||||
},
|
||||
|
||||
renderTimePicker: function(side) {
|
||||
renderTimePicker: function (side) {
|
||||
|
||||
// Don't bother updating the time picker if it's currently disabled
|
||||
// because an end date hasn't been clicked yet
|
||||
@@ -1020,7 +1021,7 @@
|
||||
|
||||
},
|
||||
|
||||
updateFormInputs: function() {
|
||||
updateFormInputs: function () {
|
||||
|
||||
//ignore mouse movements while an above-calendar text input has focus
|
||||
if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
||||
@@ -1038,8 +1039,8 @@
|
||||
|
||||
},
|
||||
|
||||
move: function() {
|
||||
var parentOffset = { top: 0, left: 0 },
|
||||
move: function () {
|
||||
var parentOffset = {top: 0, left: 0},
|
||||
containerTop;
|
||||
var parentRightEdge = $(window).width();
|
||||
if (!this.parentEl.is('body')) {
|
||||
@@ -1058,62 +1059,66 @@
|
||||
|
||||
if (this.opens == 'left') {
|
||||
this.container.css({
|
||||
top: containerTop,
|
||||
right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
|
||||
left: 'auto'
|
||||
});
|
||||
top: containerTop,
|
||||
right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
|
||||
left: 'auto'
|
||||
});
|
||||
if (this.container.offset().left < 0) {
|
||||
this.container.css({
|
||||
right: 'auto',
|
||||
left: 9
|
||||
});
|
||||
right: 'auto',
|
||||
left: 9
|
||||
});
|
||||
}
|
||||
} else if (this.opens == 'center') {
|
||||
this.container.css({
|
||||
top: containerTop,
|
||||
left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
|
||||
- this.container.outerWidth() / 2,
|
||||
right: 'auto'
|
||||
});
|
||||
top: containerTop,
|
||||
left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
|
||||
- this.container.outerWidth() / 2,
|
||||
right: 'auto'
|
||||
});
|
||||
if (this.container.offset().left < 0) {
|
||||
this.container.css({
|
||||
right: 'auto',
|
||||
left: 9
|
||||
});
|
||||
right: 'auto',
|
||||
left: 9
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.container.css({
|
||||
top: containerTop,
|
||||
left: this.element.offset().left - parentOffset.left,
|
||||
right: 'auto'
|
||||
});
|
||||
top: containerTop,
|
||||
left: this.element.offset().left - parentOffset.left,
|
||||
right: 'auto'
|
||||
});
|
||||
if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
|
||||
this.container.css({
|
||||
left: 'auto',
|
||||
right: 0
|
||||
});
|
||||
left: 'auto',
|
||||
right: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
show: function(e) {
|
||||
show: function (e) {
|
||||
if (this.isShowing) return;
|
||||
|
||||
// Create a click proxy that is private to this instance of datepicker, for unbinding
|
||||
this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
|
||||
this._outsideClickProxy = $.proxy(function (e) {
|
||||
this.outsideClick(e);
|
||||
}, this);
|
||||
|
||||
// Bind global datepicker mousedown for hiding and
|
||||
$(document)
|
||||
.on('mousedown.daterangepicker', this._outsideClickProxy)
|
||||
// also support mobile devices
|
||||
.on('touchend.daterangepicker', this._outsideClickProxy)
|
||||
// also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
|
||||
.on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
|
||||
// and also close when focus changes to outside the picker (eg. tabbing between controls)
|
||||
.on('focusin.daterangepicker', this._outsideClickProxy);
|
||||
.on('mousedown.daterangepicker', this._outsideClickProxy)
|
||||
// also support mobile devices
|
||||
.on('touchend.daterangepicker', this._outsideClickProxy)
|
||||
// also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
|
||||
.on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
|
||||
// and also close when focus changes to outside the picker (eg. tabbing between controls)
|
||||
.on('focusin.daterangepicker', this._outsideClickProxy);
|
||||
|
||||
// Reposition the picker if the window is resized while it's open
|
||||
$(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
|
||||
$(window).on('resize.daterangepicker', $.proxy(function (e) {
|
||||
this.move(e);
|
||||
}, this));
|
||||
|
||||
this.oldStartDate = this.startDate.clone();
|
||||
this.oldEndDate = this.endDate.clone();
|
||||
@@ -1126,7 +1131,7 @@
|
||||
this.isShowing = true;
|
||||
},
|
||||
|
||||
hide: function(e) {
|
||||
hide: function (e) {
|
||||
if (!this.isShowing) return;
|
||||
|
||||
//incomplete date selection, revert to last values
|
||||
@@ -1149,7 +1154,7 @@
|
||||
this.isShowing = false;
|
||||
},
|
||||
|
||||
toggle: function(e) {
|
||||
toggle: function (e) {
|
||||
if (this.isShowing) {
|
||||
this.hide();
|
||||
} else {
|
||||
@@ -1157,33 +1162,33 @@
|
||||
}
|
||||
},
|
||||
|
||||
outsideClick: function(e) {
|
||||
outsideClick: function (e) {
|
||||
var target = $(e.target);
|
||||
// if the page is clicked anywhere except within the daterangerpicker/button
|
||||
// itself then call this.hide()
|
||||
if (
|
||||
// ie modal dialog fix
|
||||
e.type == "focusin" ||
|
||||
target.closest(this.element).length ||
|
||||
target.closest(this.container).length ||
|
||||
target.closest('.calendar-table').length
|
||||
) return;
|
||||
e.type == "focusin" ||
|
||||
target.closest(this.element).length ||
|
||||
target.closest(this.container).length ||
|
||||
target.closest('.calendar-table').length
|
||||
) return;
|
||||
this.hide();
|
||||
this.element.trigger('outsideClick.daterangepicker', this);
|
||||
},
|
||||
|
||||
showCalendars: function() {
|
||||
showCalendars: function () {
|
||||
this.container.addClass('show-calendar');
|
||||
this.move();
|
||||
this.element.trigger('showCalendar.daterangepicker', this);
|
||||
},
|
||||
|
||||
hideCalendars: function() {
|
||||
hideCalendars: function () {
|
||||
this.container.removeClass('show-calendar');
|
||||
this.element.trigger('hideCalendar.daterangepicker', this);
|
||||
},
|
||||
|
||||
hoverRange: function(e) {
|
||||
hoverRange: function (e) {
|
||||
|
||||
//ignore mouse movements while an above-calendar text input has focus
|
||||
if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
||||
@@ -1201,7 +1206,7 @@
|
||||
|
||||
},
|
||||
|
||||
clickRange: function(e) {
|
||||
clickRange: function (e) {
|
||||
var label = e.target.getAttribute('data-range-key');
|
||||
this.chosenLabel = label;
|
||||
if (label == this.locale.customRangeLabel) {
|
||||
@@ -1222,7 +1227,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
clickPrev: function(e) {
|
||||
clickPrev: function (e) {
|
||||
var cal = $(e.target).parents('.calendar');
|
||||
if (cal.hasClass('left')) {
|
||||
this.leftCalendar.month.subtract(1, 'month');
|
||||
@@ -1234,7 +1239,7 @@
|
||||
this.updateCalendars();
|
||||
},
|
||||
|
||||
clickNext: function(e) {
|
||||
clickNext: function (e) {
|
||||
var cal = $(e.target).parents('.calendar');
|
||||
if (cal.hasClass('left')) {
|
||||
this.leftCalendar.month.add(1, 'month');
|
||||
@@ -1246,7 +1251,7 @@
|
||||
this.updateCalendars();
|
||||
},
|
||||
|
||||
hoverDate: function(e) {
|
||||
hoverDate: function (e) {
|
||||
|
||||
//ignore mouse movements while an above-calendar text input has focus
|
||||
//if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
||||
@@ -1273,7 +1278,7 @@
|
||||
var rightCalendar = this.rightCalendar;
|
||||
var startDate = this.startDate;
|
||||
if (!this.endDate) {
|
||||
this.container.find('.calendar tbody td').each(function(index, el) {
|
||||
this.container.find('.calendar tbody td').each(function (index, el) {
|
||||
|
||||
//skip week numbers, only look at dates
|
||||
if ($(el).hasClass('week')) return;
|
||||
@@ -1295,7 +1300,7 @@
|
||||
|
||||
},
|
||||
|
||||
clickDate: function(e) {
|
||||
clickDate: function (e) {
|
||||
|
||||
if (!$(e.target).hasClass('available')) return;
|
||||
|
||||
@@ -1350,8 +1355,8 @@
|
||||
}
|
||||
this.setEndDate(date.clone());
|
||||
if (this.autoApply) {
|
||||
this.calculateChosenLabel();
|
||||
this.clickApply();
|
||||
this.calculateChosenLabel();
|
||||
this.clickApply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1398,22 +1403,22 @@
|
||||
}
|
||||
},
|
||||
|
||||
clickApply: function(e) {
|
||||
clickApply: function (e) {
|
||||
this.hide();
|
||||
this.element.trigger('apply.daterangepicker', this);
|
||||
},
|
||||
|
||||
clickCancel: function(e) {
|
||||
clickCancel: function (e) {
|
||||
this.startDate = this.oldStartDate;
|
||||
this.endDate = this.oldEndDate;
|
||||
this.hide();
|
||||
this.element.trigger('cancel.daterangepicker', this);
|
||||
},
|
||||
|
||||
monthOrYearChanged: function(e) {
|
||||
var isLeft = $(e.target).closest('.calendar').hasClass('left'),
|
||||
monthOrYearChanged: function (e) {
|
||||
var isLeft = $(e.target).closest('.calendar').hasClass('left'),
|
||||
leftOrRight = isLeft ? 'left' : 'right',
|
||||
cal = this.container.find('.calendar.'+leftOrRight);
|
||||
cal = this.container.find('.calendar.' + leftOrRight);
|
||||
|
||||
// Month must be Number for new moment versions
|
||||
var month = parseInt(cal.find('.monthselect').val(), 10);
|
||||
@@ -1452,9 +1457,9 @@
|
||||
this.updateCalendars();
|
||||
},
|
||||
|
||||
timeChanged: function(e) {
|
||||
timeChanged: function (e) {
|
||||
|
||||
var cal = $(e.target).closest('.calendar'),
|
||||
var cal = $(e.target).closest('.calendar'),
|
||||
isLeft = cal.hasClass('left');
|
||||
|
||||
var hour = parseInt(cal.find('.hourselect').val(), 10);
|
||||
@@ -1500,7 +1505,7 @@
|
||||
|
||||
},
|
||||
|
||||
formInputsChanged: function(e) {
|
||||
formInputsChanged: function (e) {
|
||||
var isRight = $(e.target).closest('.calendar').hasClass('right');
|
||||
var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format);
|
||||
var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format);
|
||||
@@ -1524,7 +1529,7 @@
|
||||
this.updateView();
|
||||
},
|
||||
|
||||
formInputsFocused: function(e) {
|
||||
formInputsFocused: function (e) {
|
||||
|
||||
// Highlight the focused input
|
||||
this.container.find('input[name="daterangepicker_start"], input[name="daterangepicker_end"]').removeClass('active');
|
||||
@@ -1544,7 +1549,7 @@
|
||||
|
||||
},
|
||||
|
||||
formInputsBlurred: function(e) {
|
||||
formInputsBlurred: function (e) {
|
||||
|
||||
// this function has one purpose right now: if you tab from the first
|
||||
// text input to the second in the UI, the endDate is nulled so that
|
||||
@@ -1562,14 +1567,14 @@
|
||||
|
||||
},
|
||||
|
||||
elementChanged: function() {
|
||||
elementChanged: function () {
|
||||
if (!this.element.is('input')) return;
|
||||
if (!this.element.val().length) return;
|
||||
if (this.element.val().length < this.locale.format.length) return;
|
||||
|
||||
var dateString = this.element.val().split(this.locale.separator),
|
||||
start = null,
|
||||
end = null;
|
||||
start = null,
|
||||
end = null;
|
||||
|
||||
if (dateString.length === 2) {
|
||||
start = moment(dateString[0], this.locale.format);
|
||||
@@ -1588,14 +1593,14 @@
|
||||
this.updateView();
|
||||
},
|
||||
|
||||
keydown: function(e) {
|
||||
keydown: function (e) {
|
||||
//hide on tab or enter
|
||||
if ((e.keyCode === 9) || (e.keyCode === 13)) {
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
updateElement: function() {
|
||||
updateElement: function () {
|
||||
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
|
||||
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
||||
this.element.trigger('change');
|
||||
@@ -1605,7 +1610,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
remove: function() {
|
||||
remove: function () {
|
||||
this.container.remove();
|
||||
this.element.off('.daterangepicker');
|
||||
this.element.removeData();
|
||||
@@ -1613,8 +1618,8 @@
|
||||
|
||||
};
|
||||
|
||||
$.fn.daterangepicker = function(options, callback) {
|
||||
this.each(function() {
|
||||
$.fn.daterangepicker = function (options, callback) {
|
||||
this.each(function () {
|
||||
var el = $(this);
|
||||
if (el.data('daterangepicker'))
|
||||
el.data('daterangepicker').remove();
|
||||
|
||||
Reference in New Issue
Block a user