').append(that.ul).on(MOUSEDOWN, preventDefault);
- if (id) {
- that._timeViewID = id + '_timeview';
- that._optionID = id + '_option_selected';
- that.ul.attr(ID, that._timeViewID);
- }
- that._popup();
- that._heightHandler = proxy(that._height, that);
- that.template = kendo.template('
', { useWithBlock: false });
- };
- TimeView.prototype = {
- current: function (candidate) {
- var that = this, active = that.options.active;
- if (candidate !== undefined) {
- if (that._current) {
- that._current.removeClass(SELECTED).removeAttr(ARIA_SELECTED).removeAttr(ID);
- }
- if (candidate) {
- candidate = $(candidate).addClass(SELECTED).attr(ID, that._optionID).attr(ARIA_SELECTED, true);
- that.scroll(candidate[0]);
- }
- that._current = candidate;
- if (active) {
- active(candidate);
- }
- } else {
- return that._current;
- }
- },
- close: function () {
- this.popup.close();
- },
- destroy: function () {
- var that = this;
- that.ul.off(ns);
- that.list.off(ns);
- that.popup.destroy();
- },
- open: function () {
- var that = this;
- var popupHovered;
- if (!that.ul[0].firstChild) {
- that.bind();
- }
- popupHovered = that.popup._hovered;
- that.popup._hovered = true;
- that.popup.open();
- setTimeout(function () {
- that.popup._hovered = popupHovered;
- }, 1);
- if (that._current) {
- that.scroll(that._current[0]);
- }
- },
- dataBind: function (dates) {
- var that = this, options = that.options, format = options.format, toString = kendo.toString, template = that.template, length = dates.length, idx = 0, date, html = '';
- for (; idx < length; idx++) {
- date = dates[idx];
- if (isInRange(date, options.min, options.max)) {
- html += template(toString(date, format, options.culture));
- }
- }
- that._html(html);
- },
- refresh: function () {
- var that = this, options = that.options, format = options.format, offset = dst(), ignoreDST = offset < 0, min = options.min, max = options.max, msMin = getMilliseconds(min), msMax = getMilliseconds(max), msLastTime = getMilliseconds(lastTimeOption(options.interval)), msInterval = options.interval * MS_PER_MINUTE, toString = kendo.toString, template = that.template, start = new DATE(+min), startDate = new DATE(start), msStart, lastIdx, idx = 0, length, html = '';
- if (ignoreDST) {
- length = (MS_PER_DAY + offset * MS_PER_MINUTE) / msInterval;
- } else {
- length = MS_PER_DAY / msInterval;
- }
- if (msMin != msMax || msLastTime === msMax) {
- if (msMin > msMax) {
- msMax += MS_PER_DAY;
- }
- length = (msMax - msMin) / msInterval + 1;
- }
- lastIdx = parseInt(length, 10);
- for (; idx < length; idx++) {
- if (idx) {
- setTime(start, msInterval, ignoreDST);
- }
- if (msMax && lastIdx == idx) {
- msStart = getMilliseconds(start);
- if (startDate < start) {
- msStart += MS_PER_DAY;
- }
- if (msStart > msMax) {
- start = new DATE(+max);
- }
- }
- that._dates.push(getMilliseconds(start));
- html += template(toString(start, format, options.culture));
- }
- that._html(html);
- },
- bind: function () {
- var that = this, dates = that.options.dates;
- if (dates && dates[0]) {
- that.dataBind(dates);
- } else {
- that.refresh();
- }
- },
- _html: function (html) {
- var that = this;
- that.ul[0].innerHTML = html;
- that.popup.unbind(OPEN, that._heightHandler);
- that.popup.one(OPEN, that._heightHandler);
- that.current(null);
- that.select(that._value);
- },
- scroll: function (item) {
- if (!item) {
- return;
- }
- var content = this.list[0], itemOffsetTop = item.offsetTop, itemOffsetHeight = item.offsetHeight, contentScrollTop = content.scrollTop, contentOffsetHeight = content.clientHeight, bottomDistance = itemOffsetTop + itemOffsetHeight;
- if (contentScrollTop > itemOffsetTop) {
- contentScrollTop = itemOffsetTop;
- } else if (bottomDistance > contentScrollTop + contentOffsetHeight) {
- contentScrollTop = bottomDistance - contentOffsetHeight;
- }
- content.scrollTop = contentScrollTop;
- },
- select: function (li) {
- var that = this, options = that.options, current = that._current, selection;
- if (li instanceof Date) {
- li = kendo.toString(li, options.format, options.culture);
- }
- if (typeof li === 'string') {
- if (!current || current.text() !== li) {
- li = $.grep(that.ul[0].childNodes, function (node) {
- return (node.textContent || node.innerText) == li;
- });
- li = li[0] ? li : null;
- } else {
- li = current;
- }
- }
- selection = that._distinctSelection(li);
- that.current(selection);
- },
- _distinctSelection: function (selection) {
- var that = this, currentValue, selectionIndex;
- if (selection && selection.length > 1) {
- currentValue = getMilliseconds(that._value);
- selectionIndex = $.inArray(currentValue, that._dates);
- selection = that.ul.children()[selectionIndex];
- }
- return selection;
- },
- setOptions: function (options) {
- var old = this.options;
- options.min = parse(options.min);
- options.max = parse(options.max);
- this.options = extend(old, options, {
- active: old.active,
- change: old.change,
- close: old.close,
- open: old.open
- });
- this.bind();
- },
- toggle: function () {
- var that = this;
- if (that.popup.visible()) {
- that.close();
- } else {
- that.open();
- }
- },
- value: function (value) {
- var that = this;
- that._value = value;
- if (that.ul[0].firstChild) {
- that.select(value);
- }
- },
- _click: function (e) {
- var that = this, li = $(e.currentTarget), date = li.text(), dates = that.options.dates;
- if (dates && dates.length > 0) {
- date = dates[li.index()];
- }
- if (!e.isDefaultPrevented()) {
- that.select(li);
- that.options.change(date, true);
- that.close();
- }
- },
- _height: function () {
- var that = this;
- var list = that.list;
- var parent = list.parent('.k-animation-container');
- var height = that.options.height;
- if (that.ul[0].children.length) {
- list.add(parent).show().height(that.ul[0].scrollHeight > height ? height : 'auto').hide();
- }
- },
- _parse: function (value) {
- var that = this, options = that.options, min = getMilliseconds(options.min) != getMilliseconds(TODAY) ? options.min : null, max = getMilliseconds(options.max) != getMilliseconds(TODAY) ? options.max : null, current = that._value || min || max || TODAY;
- if (value instanceof DATE) {
- return value;
- }
- value = parse(value, options.parseFormats, options.culture);
- if (value) {
- value = new DATE(current.getFullYear(), current.getMonth(), current.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), value.getMilliseconds());
- }
- return value;
- },
- _adjustListWidth: function () {
- var list = this.list, width = list[0].style.width, wrapper = this.options.anchor, computedStyle, computedWidth, outerWidth = kendo._outerWidth;
- if (!list.data('width') && width) {
- return;
- }
- computedStyle = window.getComputedStyle ? window.getComputedStyle(wrapper[0], null) : 0;
- computedWidth = computedStyle ? parseFloat(computedStyle.width) : outerWidth(wrapper);
- if (computedStyle && (browser.mozilla || browser.msie)) {
- computedWidth += parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight) + parseFloat(computedStyle.borderLeftWidth) + parseFloat(computedStyle.borderRightWidth);
- }
- width = computedWidth - (outerWidth(list) - list.width());
- list.css({
- fontFamily: wrapper.css('font-family'),
- width: width
- }).data('width', width);
- },
- _popup: function () {
- var that = this, list = that.list, options = that.options, anchor = options.anchor;
- that.popup = new ui.Popup(list, extend(options.popup, {
- anchor: anchor,
- open: options.open,
- close: options.close,
- animation: options.animation,
- isRtl: support.isRtl(options.anchor)
- }));
- },
- move: function (e) {
- var that = this, key = e.keyCode, ul = that.ul[0], current = that._current, down = key === keys.DOWN;
- if (key === keys.UP || down) {
- if (e.altKey) {
- that.toggle(down);
- return;
- } else if (down) {
- current = current ? current[0].nextSibling : ul.firstChild;
- } else {
- current = current ? current[0].previousSibling : ul.lastChild;
- }
- if (current) {
- that.select(current);
- }
- that.options.change(that._current.text());
- e.preventDefault();
- } else if (key === keys.ENTER || key === keys.TAB || key === keys.ESC) {
- e.preventDefault();
- if (current) {
- that.options.change(current.text(), true);
- }
- that.close();
- }
- }
- };
- function setTime(date, time, ignoreDST) {
- var offset = date.getTimezoneOffset(), offsetDiff;
- date.setTime(date.getTime() + time);
- if (!ignoreDST) {
- offsetDiff = date.getTimezoneOffset() - offset;
- date.setTime(date.getTime() + offsetDiff * MS_PER_MINUTE);
- }
- }
- function dst() {
- var today = new DATE(), midnight = new DATE(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0), noon = new DATE(today.getFullYear(), today.getMonth(), today.getDate(), 12, 0, 0);
- return -1 * (midnight.getTimezoneOffset() - noon.getTimezoneOffset());
- }
- function getMilliseconds(date) {
- return date.getHours() * 60 * MS_PER_MINUTE + date.getMinutes() * MS_PER_MINUTE + date.getSeconds() * 1000 + date.getMilliseconds();
- }
- function lastTimeOption(interval) {
- var date = new Date(2100, 0, 1);
- date.setMinutes(-interval);
- return date;
- }
- function isInRange(value, min, max) {
- var msMin = getMilliseconds(min), msMax = getMilliseconds(max), msValue;
- if (!value || msMin == msMax) {
- return true;
- }
- msValue = getMilliseconds(value);
- if (msMin > msValue) {
- msValue += MS_PER_DAY;
- }
- if (msMax < msMin) {
- msMax += MS_PER_DAY;
- }
- return msValue >= msMin && msValue <= msMax;
- }
- TimeView.getMilliseconds = getMilliseconds;
- kendo.TimeView = TimeView;
- var TimePicker = Widget.extend({
- init: function (element, options) {
- var that = this, ul, timeView, disabled;
- Widget.fn.init.call(that, element, options);
- element = that.element;
- options = that.options;
- options.min = parse(element.attr('min')) || parse(options.min);
- options.max = parse(element.attr('max')) || parse(options.max);
- normalize(options);
- that._initialOptions = extend({}, options);
- that._wrapper();
- that.timeView = timeView = new TimeView(extend({}, options, {
- id: element.attr(ID),
- anchor: that.wrapper,
- format: options.format,
- change: function (value, trigger) {
- if (trigger) {
- that._change(value);
- } else {
- element.val(value);
- }
- },
- open: function (e) {
- that.timeView._adjustListWidth();
- if (that.trigger(OPEN)) {
- e.preventDefault();
- } else {
- element.attr(ARIA_EXPANDED, true);
- ul.attr(ARIA_HIDDEN, false);
- }
- },
- close: function (e) {
- if (that.trigger(CLOSE)) {
- e.preventDefault();
- } else {
- element.attr(ARIA_EXPANDED, false);
- ul.attr(ARIA_HIDDEN, true);
- }
- },
- active: function (current) {
- element.removeAttr(ARIA_ACTIVEDESCENDANT);
- if (current) {
- element.attr(ARIA_ACTIVEDESCENDANT, timeView._optionID);
- }
- }
- }));
- ul = timeView.ul;
- that._icon();
- that._reset();
- try {
- element[0].setAttribute('type', 'text');
- } catch (e) {
- element[0].type = 'text';
- }
- element.addClass('k-input').attr({
- 'role': 'combobox',
- 'aria-expanded': false,
- 'aria-owns': timeView._timeViewID,
- 'autocomplete': 'off'
- });
- disabled = element.is('[disabled]') || $(that.element).parents('fieldset').is(':disabled');
- if (disabled) {
- that.enable(false);
- } else {
- that.readonly(element.is('[readonly]'));
- }
- if (options.dateInput) {
- var min = options.min;
- var max = options.max;
- var today = new DATE();
- if (getMilliseconds(min) == getMilliseconds(max)) {
- min = new DATE(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
- max = new DATE(today.getFullYear(), today.getMonth(), today.getDate(), 24, 0, 0);
- }
- that._dateInput = new ui.DateInput(element, {
- culture: options.culture,
- format: options.format,
- min: min,
- max: max,
- value: options.value
- });
- }
- that._old = that._update(options.value || that.element.val());
- that._oldText = element.val();
- kendo.notify(that);
- },
- options: {
- name: 'TimePicker',
- min: TODAY,
- max: TODAY,
- format: '',
- dates: [],
- parseFormats: [],
- value: null,
- interval: 30,
- height: 200,
- animation: {},
- dateInput: false
- },
- events: [
- OPEN,
- CLOSE,
- CHANGE
- ],
- setOptions: function (options) {
- var that = this;
- var value = that._value;
- Widget.fn.setOptions.call(that, options);
- options = that.options;
- normalize(options);
- that.timeView.setOptions(options);
- if (value) {
- that.element.val(kendo.toString(value, options.format, options.culture));
- }
- },
- dataBind: function (dates) {
- if (isArray(dates)) {
- this.timeView.dataBind(dates);
- }
- },
- _editable: function (options) {
- var that = this, disable = options.disable, readonly = options.readonly, arrow = that._arrow.off(ns), element = that.element.off(ns), wrapper = that._inputWrapper.off(ns);
- if (!readonly && !disable) {
- wrapper.addClass(DEFAULT).removeClass(STATEDISABLED).on(HOVEREVENTS, that._toggleHover);
- element.removeAttr(DISABLED).removeAttr(READONLY).attr(ARIA_DISABLED, false).on('keydown' + ns, proxy(that._keydown, that)).on('focusout' + ns, proxy(that._blur, that)).on('focus' + ns, function () {
- that._inputWrapper.addClass(FOCUSED);
- });
- arrow.on(CLICK, proxy(that._click, that)).on(MOUSEDOWN, preventDefault);
- } else {
- wrapper.addClass(disable ? STATEDISABLED : DEFAULT).removeClass(disable ? DEFAULT : STATEDISABLED);
- element.attr(DISABLED, disable).attr(READONLY, readonly).attr(ARIA_DISABLED, disable);
- }
- },
- readonly: function (readonly) {
- this._editable({
- readonly: readonly === undefined ? true : readonly,
- disable: false
- });
- },
- enable: function (enable) {
- this._editable({
- readonly: false,
- disable: !(enable = enable === undefined ? true : enable)
- });
- },
- destroy: function () {
- var that = this;
- Widget.fn.destroy.call(that);
- that.timeView.destroy();
- that.element.off(ns);
- that._arrow.off(ns);
- that._inputWrapper.off(ns);
- if (that._form) {
- that._form.off('reset', that._resetHandler);
- }
- },
- close: function () {
- this.timeView.close();
- },
- open: function () {
- this.timeView.open();
- },
- min: function (value) {
- return this._option('min', value);
- },
- max: function (value) {
- return this._option('max', value);
- },
- value: function (value) {
- var that = this;
- if (value === undefined) {
- return that._value;
- }
- that._old = that._update(value);
- if (that._old === null) {
- that.element.val('');
- }
- that._oldText = that.element.val();
- },
- _blur: function () {
- var that = this, value = that.element.val();
- that.close();
- if (value !== that._oldText) {
- that._change(value);
- }
- that._inputWrapper.removeClass(FOCUSED);
- },
- _click: function () {
- var that = this, element = that.element;
- that.timeView.toggle();
- if (!support.touch && element[0] !== activeElement()) {
- element.focus();
- }
- },
- _change: function (value) {
- var that = this, oldValue = that.element.val(), dateChanged;
- value = that._update(value);
- dateChanged = !kendo.calendar.isEqualDate(that._old, value);
- var valueUpdated = dateChanged && !that._typing;
- var textFormatted = oldValue !== that.element.val();
- if (valueUpdated || textFormatted) {
- that.element.trigger(CHANGE);
- }
- if (dateChanged) {
- that._old = value;
- that._oldText = that.element.val();
- that.trigger(CHANGE);
- }
- that._typing = false;
- },
- _icon: function () {
- var that = this, element = that.element, arrow;
- arrow = element.next('span.k-select');
- if (!arrow[0]) {
- arrow = $('
').insertAfter(element);
- }
- that._arrow = arrow.attr({
- 'role': 'button',
- 'aria-controls': that.timeView._timeViewID
- });
- },
- _keydown: function (e) {
- var that = this, key = e.keyCode, timeView = that.timeView, value = that.element.val();
- if (timeView.popup.visible() || e.altKey) {
- timeView.move(e);
- if (that._dateInput && e.stopImmediatePropagation) {
- e.stopImmediatePropagation();
- }
- } else if (key === keys.ENTER && value !== that._oldText) {
- that._change(value);
- } else {
- that._typing = true;
- }
- },
- _option: function (option, value) {
- var that = this, options = that.options;
- if (value === undefined) {
- return options[option];
- }
- value = that.timeView._parse(value);
- if (!value) {
- return;
- }
- value = new DATE(+value);
- options[option] = value;
- that.timeView.options[option] = value;
- that.timeView.bind();
- },
- _toggleHover: function (e) {
- $(e.currentTarget).toggleClass(HOVER, e.type === 'mouseenter');
- },
- _update: function (value) {
- var that = this, options = that.options, timeView = that.timeView, date = timeView._parse(value);
- if (!isInRange(date, options.min, options.max)) {
- date = null;
- }
- that._value = date;
- if (that._dateInput && date) {
- that._dateInput.value(date || value);
- } else {
- that.element.val(kendo.toString(date || value, options.format, options.culture));
- }
- timeView.value(date);
- return date;
- },
- _wrapper: function () {
- var that = this, element = that.element, wrapper;
- wrapper = element.parents('.k-timepicker');
- if (!wrapper[0]) {
- wrapper = element.wrap(SPAN).parent().addClass('k-picker-wrap k-state-default');
- wrapper = wrapper.wrap(SPAN).parent();
- }
- wrapper[0].style.cssText = element[0].style.cssText;
- that.wrapper = wrapper.addClass('k-widget k-timepicker').addClass(element[0].className);
- element.css({
- width: '100%',
- height: element[0].style.height
- });
- that._inputWrapper = $(wrapper[0].firstChild);
- },
- _reset: function () {
- var that = this, element = that.element, formId = element.attr('form'), form = formId ? $('#' + formId) : element.closest('form');
- if (form[0]) {
- that._resetHandler = function () {
- that.value(element[0].defaultValue);
- that.max(that._initialOptions.max);
- that.min(that._initialOptions.min);
- };
- that._form = form.on('reset', that._resetHandler);
- }
- }
- });
- function normalize(options) {
- var parseFormats = options.parseFormats;
- options.format = extractFormat(options.format || kendo.getCulture(options.culture).calendars.standard.patterns.t);
- parseFormats = isArray(parseFormats) ? parseFormats : [parseFormats];
- parseFormats.splice(0, 0, options.format);
- options.parseFormats = parseFormats;
- }
- function preventDefault(e) {
- e.preventDefault();
- }
- ui.plugin(TimePicker);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.datetimepicker', [
- 'kendo.datepicker',
- 'kendo.timepicker'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'datetimepicker',
- name: 'DateTimePicker',
- category: 'web',
- description: 'The DateTimePicker allows the end user to select a value from a calendar or a time drop-down list.',
- depends: [
- 'datepicker',
- 'timepicker'
- ]
- };
- (function ($, undefined) {
- var kendo = window.kendo, TimeView = kendo.TimeView, parse = kendo.parseDate, support = kendo.support, activeElement = kendo._activeElement, extractFormat = kendo._extractFormat, calendar = kendo.calendar, isInRange = calendar.isInRange, restrictValue = calendar.restrictValue, isEqualDatePart = calendar.isEqualDatePart, getMilliseconds = TimeView.getMilliseconds, ui = kendo.ui, Widget = ui.Widget, OPEN = 'open', CLOSE = 'close', CHANGE = 'change', ns = '.kendoDateTimePicker', CLICK = 'click' + ns, UP = support.mouseAndTouchPresent ? kendo.applyEventMap('up', ns.slice(1)) : CLICK, DISABLED = 'disabled', READONLY = 'readonly', DEFAULT = 'k-state-default', FOCUSED = 'k-state-focused', HOVER = 'k-state-hover', STATEDISABLED = 'k-state-disabled', HOVEREVENTS = 'mouseenter' + ns + ' mouseleave' + ns, MOUSEDOWN = 'mousedown' + ns, MONTH = 'month', SPAN = '
', ARIA_ACTIVEDESCENDANT = 'aria-activedescendant', ARIA_EXPANDED = 'aria-expanded', ARIA_HIDDEN = 'aria-hidden', ARIA_OWNS = 'aria-owns', ARIA_DISABLED = 'aria-disabled', DATE = Date, MIN = new DATE(1800, 0, 1), MAX = new DATE(2099, 11, 31), dateViewParams = { view: 'date' }, timeViewParams = { view: 'time' }, extend = $.extend;
- var DateTimePicker = Widget.extend({
- init: function (element, options) {
- var that = this, disabled;
- Widget.fn.init.call(that, element, options);
- element = that.element;
- options = that.options;
- options.disableDates = kendo.calendar.disabled(options.disableDates);
- options.min = parse(element.attr('min')) || parse(options.min);
- options.max = parse(element.attr('max')) || parse(options.max);
- normalize(options);
- that._initialOptions = extend({}, options);
- that._wrapper();
- that._views();
- that._icons();
- that._reset();
- that._template();
- try {
- element[0].setAttribute('type', 'text');
- } catch (e) {
- element[0].type = 'text';
- }
- element.addClass('k-input').attr({
- 'role': 'combobox',
- 'aria-expanded': false,
- 'autocomplete': 'off'
- });
- that._midnight = that._calculateMidnight(options.min, options.max);
- disabled = element.is('[disabled]') || $(that.element).parents('fieldset').is(':disabled');
- if (disabled) {
- that.enable(false);
- } else {
- that.readonly(element.is('[readonly]'));
- }
- that._createDateInput(options);
- that._old = that._update(options.value || that.element.val());
- that._oldText = element.val();
- kendo.notify(that);
- },
- options: {
- name: 'DateTimePicker',
- value: null,
- format: '',
- timeFormat: '',
- culture: '',
- parseFormats: [],
- dates: [],
- disableDates: null,
- min: new DATE(MIN),
- max: new DATE(MAX),
- interval: 30,
- height: 200,
- footer: '',
- start: MONTH,
- depth: MONTH,
- animation: {},
- month: {},
- ARIATemplate: 'Current focused date is #=kendo.toString(data.current, "d")#',
- dateButtonText: 'Open the date view',
- timeButtonText: 'Open the time view',
- dateInput: false,
- weekNumber: false
- },
- events: [
- OPEN,
- CLOSE,
- CHANGE
- ],
- setOptions: function (options) {
- var that = this, value = that._value, min, max, currentValue;
- Widget.fn.setOptions.call(that, options);
- options = that.options;
- options.min = min = parse(options.min);
- options.max = max = parse(options.max);
- normalize(options);
- that._midnight = that._calculateMidnight(options.min, options.max);
- currentValue = options.value || that._value || that.dateView._current;
- if (min && !isEqualDatePart(min, currentValue)) {
- min = new DATE(MIN);
- }
- if (max && !isEqualDatePart(max, currentValue)) {
- max = new DATE(MAX);
- }
- that.dateView.setOptions(options);
- that.timeView.setOptions(extend({}, options, {
- format: options.timeFormat,
- min: min,
- max: max
- }));
- that._createDateInput(options);
- if (!that._dateInput) {
- that.element.val(kendo.toString(value, options.format, options.culture));
- }
- if (value) {
- that._updateARIA(value);
- }
- },
- _editable: function (options) {
- var that = this, element = that.element.off(ns), dateIcon = that._dateIcon.off(ns), timeIcon = that._timeIcon.off(ns), wrapper = that._inputWrapper.off(ns), readonly = options.readonly, disable = options.disable;
- if (!readonly && !disable) {
- wrapper.addClass(DEFAULT).removeClass(STATEDISABLED).on(HOVEREVENTS, that._toggleHover);
- element.removeAttr(DISABLED).removeAttr(READONLY).attr(ARIA_DISABLED, false).on('keydown' + ns, $.proxy(that._keydown, that)).on('focus' + ns, function () {
- that._inputWrapper.addClass(FOCUSED);
- }).on('focusout' + ns, function () {
- that._inputWrapper.removeClass(FOCUSED);
- if (element.val() !== that._oldText) {
- that._change(element.val());
- }
- that.close('date');
- that.close('time');
- });
- dateIcon.on(MOUSEDOWN, preventDefault).on(UP, function (e) {
- that.toggle('date');
- that._focusElement(e.type);
- });
- timeIcon.on(MOUSEDOWN, preventDefault).on(UP, function (e) {
- that.toggle('time');
- that._focusElement(e.type);
- });
- } else {
- wrapper.addClass(disable ? STATEDISABLED : DEFAULT).removeClass(disable ? DEFAULT : STATEDISABLED);
- element.attr(DISABLED, disable).attr(READONLY, readonly).attr(ARIA_DISABLED, disable);
- }
- },
- _focusElement: function (eventType) {
- var element = this.element;
- if ((!support.touch || support.mouseAndTouchPresent && !(eventType || '').match(/touch/i)) && element[0] !== activeElement()) {
- element.focus();
- }
- },
- readonly: function (readonly) {
- this._editable({
- readonly: readonly === undefined ? true : readonly,
- disable: false
- });
- },
- enable: function (enable) {
- this._editable({
- readonly: false,
- disable: !(enable = enable === undefined ? true : enable)
- });
- },
- destroy: function () {
- var that = this;
- Widget.fn.destroy.call(that);
- that.dateView.destroy();
- that.timeView.destroy();
- that.element.off(ns);
- that._dateIcon.off(ns);
- that._timeIcon.off(ns);
- that._inputWrapper.off(ns);
- if (that._form) {
- that._form.off('reset', that._resetHandler);
- }
- },
- close: function (view) {
- if (view !== 'time') {
- view = 'date';
- }
- this[view + 'View'].close();
- },
- open: function (view) {
- if (view !== 'time') {
- view = 'date';
- }
- this[view + 'View'].open();
- },
- min: function (value) {
- return this._option('min', value);
- },
- max: function (value) {
- return this._option('max', value);
- },
- toggle: function (view) {
- var secondView = 'timeView';
- if (view !== 'time') {
- view = 'date';
- } else {
- secondView = 'dateView';
- }
- this[view + 'View'].toggle();
- this[secondView].close();
- },
- value: function (value) {
- var that = this;
- if (value === undefined) {
- return that._value;
- }
- that._old = that._update(value);
- if (that._old === null) {
- that.element.val('');
- }
- that._oldText = that.element.val();
- },
- _change: function (value) {
- var that = this, oldValue = that.element.val(), dateChanged;
- value = that._update(value);
- dateChanged = +that._old != +value;
- var valueUpdated = dateChanged && !that._typing;
- var textFormatted = oldValue !== that.element.val();
- if (valueUpdated || textFormatted) {
- that.element.trigger(CHANGE);
- }
- if (dateChanged) {
- that._old = value;
- that._oldText = that.element.val();
- that.trigger(CHANGE);
- }
- that._typing = false;
- },
- _option: function (option, value) {
- var that = this;
- var options = that.options;
- var timeView = that.timeView;
- var timeViewOptions = timeView.options;
- var current = that._value || that._old;
- var minDateEqual;
- var maxDateEqual;
- if (value === undefined) {
- return options[option];
- }
- value = parse(value, options.parseFormats, options.culture);
- if (!value) {
- return;
- }
- if (options.min.getTime() === options.max.getTime()) {
- timeViewOptions.dates = [];
- }
- options[option] = new DATE(value.getTime());
- that.dateView[option](value);
- that._midnight = that._calculateMidnight(options.min, options.max);
- if (current) {
- minDateEqual = isEqualDatePart(options.min, current);
- maxDateEqual = isEqualDatePart(options.max, current);
- }
- if (minDateEqual || maxDateEqual) {
- timeViewOptions[option] = value;
- if (minDateEqual && !maxDateEqual) {
- timeViewOptions.max = lastTimeOption(options.interval);
- }
- if (maxDateEqual) {
- if (that._midnight) {
- timeView.dataBind([MAX]);
- return;
- } else if (!minDateEqual) {
- timeViewOptions.min = MIN;
- }
- }
- } else {
- timeViewOptions.max = MAX;
- timeViewOptions.min = MIN;
- }
- timeView.bind();
- },
- _toggleHover: function (e) {
- $(e.currentTarget).toggleClass(HOVER, e.type === 'mouseenter');
- },
- _update: function (value) {
- var that = this, options = that.options, min = options.min, max = options.max, dates = options.dates, timeView = that.timeView, current = that._value, date = parse(value, options.parseFormats, options.culture), isSameType = date === null && current === null || date instanceof Date && current instanceof Date, rebind, timeViewOptions, old, skip, formattedValue;
- if (options.disableDates && options.disableDates(date)) {
- date = null;
- if (!that._old && !that.element.val()) {
- value = null;
- }
- }
- if (+date === +current && isSameType) {
- formattedValue = kendo.toString(date, options.format, options.culture);
- if (formattedValue !== value) {
- that.element.val(date === null ? value : formattedValue);
- if (value instanceof String) {
- that.element.trigger(CHANGE);
- }
- }
- return date;
- }
- if (date !== null && isEqualDatePart(date, min)) {
- date = restrictValue(date, min, max);
- } else if (!isInRange(date, min, max)) {
- date = null;
- }
- that._value = date;
- timeView.value(date);
- that.dateView.value(date);
- if (date) {
- old = that._old;
- timeViewOptions = timeView.options;
- if (dates[0]) {
- dates = $.grep(dates, function (d) {
- return isEqualDatePart(date, d);
- });
- if (dates[0]) {
- timeView.dataBind(dates);
- skip = true;
- }
- }
- if (!skip) {
- if (isEqualDatePart(date, min)) {
- timeViewOptions.min = min;
- timeViewOptions.max = lastTimeOption(options.interval);
- rebind = true;
- }
- if (isEqualDatePart(date, max)) {
- if (that._midnight) {
- timeView.dataBind([MAX]);
- skip = true;
- } else {
- timeViewOptions.max = max;
- if (!rebind) {
- timeViewOptions.min = MIN;
- }
- rebind = true;
- }
- }
- }
- if (!skip && (!old && rebind || old && !isEqualDatePart(old, date))) {
- if (!rebind) {
- timeViewOptions.max = MAX;
- timeViewOptions.min = MIN;
- }
- timeView.bind();
- }
- }
- if (that._dateInput && date) {
- that._dateInput.value(date || value);
- } else {
- that.element.val(kendo.toString(date || value, options.format, options.culture));
- }
- that._updateARIA(date);
- return date;
- },
- _keydown: function (e) {
- var that = this, dateView = that.dateView, timeView = that.timeView, value = that.element.val(), isDateViewVisible = dateView.popup.visible();
- var stopPropagation = that._dateInput && e.stopImmediatePropagation;
- if (e.altKey && e.keyCode === kendo.keys.DOWN) {
- that.toggle(isDateViewVisible ? 'time' : 'date');
- } else if (isDateViewVisible) {
- dateView.move(e);
- that._updateARIA(dateView._current);
- } else if (timeView.popup.visible()) {
- timeView.move(e);
- } else if (e.keyCode === kendo.keys.ENTER && value !== that._oldText) {
- that._change(value);
- } else {
- that._typing = true;
- stopPropagation = false;
- }
- if (stopPropagation) {
- e.stopImmediatePropagation();
- }
- },
- _views: function () {
- var that = this, element = that.element, options = that.options, id = element.attr('id'), dateView, timeView, div, ul, msMin, date;
- that.dateView = dateView = new kendo.DateView(extend({}, options, {
- id: id,
- anchor: that.wrapper,
- change: function () {
- var value = dateView.calendar.value(), msValue = +value, msMin = +options.min, msMax = +options.max, current, adjustedDate;
- if (msValue === msMin || msValue === msMax) {
- current = msValue === msMin ? msMin : msMax;
- current = new DATE(that._value || current);
- current.setFullYear(value.getFullYear(), value.getMonth(), value.getDate());
- if (isInRange(current, msMin, msMax)) {
- value = current;
- }
- }
- if (that._value) {
- adjustedDate = kendo.date.setHours(new Date(value), that._value);
- if (isInRange(adjustedDate, msMin, msMax)) {
- value = adjustedDate;
- }
- }
- that._change(value);
- that.close('date');
- },
- close: function (e) {
- if (that.trigger(CLOSE, dateViewParams)) {
- e.preventDefault();
- } else {
- element.attr(ARIA_EXPANDED, false);
- div.attr(ARIA_HIDDEN, true);
- if (!timeView.popup.visible()) {
- element.removeAttr(ARIA_OWNS);
- }
- }
- },
- open: function (e) {
- if (that.trigger(OPEN, dateViewParams)) {
- e.preventDefault();
- } else {
- if (element.val() !== that._oldText) {
- date = parse(element.val(), options.parseFormats, options.culture);
- that.dateView[date ? 'current' : 'value'](date);
- }
- div.attr(ARIA_HIDDEN, false);
- element.attr(ARIA_EXPANDED, true).attr(ARIA_OWNS, dateView._dateViewID);
- that._updateARIA(date);
- }
- }
- }));
- div = dateView.div;
- msMin = options.min.getTime();
- that.timeView = timeView = new TimeView({
- id: id,
- value: options.value,
- anchor: that.wrapper,
- animation: options.animation,
- format: options.timeFormat,
- culture: options.culture,
- height: options.height,
- interval: options.interval,
- min: new DATE(MIN),
- max: new DATE(MAX),
- dates: msMin === options.max.getTime() ? [new Date(msMin)] : [],
- parseFormats: options.parseFormats,
- change: function (value, trigger) {
- value = timeView._parse(value);
- if (value < options.min) {
- value = new DATE(+options.min);
- timeView.options.min = value;
- } else if (value > options.max) {
- value = new DATE(+options.max);
- timeView.options.max = value;
- }
- if (trigger) {
- that._timeSelected = true;
- that._change(value);
- } else {
- element.val(kendo.toString(value, options.format, options.culture));
- dateView.value(value);
- that._updateARIA(value);
- }
- },
- close: function (e) {
- if (that.trigger(CLOSE, timeViewParams)) {
- e.preventDefault();
- } else {
- ul.attr(ARIA_HIDDEN, true);
- element.attr(ARIA_EXPANDED, false);
- if (!dateView.popup.visible()) {
- element.removeAttr(ARIA_OWNS);
- }
- }
- },
- open: function (e) {
- timeView._adjustListWidth();
- if (that.trigger(OPEN, timeViewParams)) {
- e.preventDefault();
- } else {
- if (element.val() !== that._oldText) {
- date = parse(element.val(), options.parseFormats, options.culture);
- that.timeView.value(date);
- }
- ul.attr(ARIA_HIDDEN, false);
- element.attr(ARIA_EXPANDED, true).attr(ARIA_OWNS, timeView._timeViewID);
- timeView.options.active(timeView.current());
- }
- },
- active: function (current) {
- element.removeAttr(ARIA_ACTIVEDESCENDANT);
- if (current) {
- element.attr(ARIA_ACTIVEDESCENDANT, timeView._optionID);
- }
- }
- });
- ul = timeView.ul;
- },
- _icons: function () {
- var that = this;
- var element = that.element;
- var options = that.options;
- var icons;
- icons = element.next('span.k-select');
- if (!icons[0]) {
- icons = $('
').insertAfter(element);
- }
- icons = icons.children();
- that._dateIcon = icons.eq(0).attr('aria-controls', that.dateView._dateViewID);
- that._timeIcon = icons.eq(1).attr('aria-controls', that.timeView._timeViewID);
- },
- _wrapper: function () {
- var that = this, element = that.element, wrapper;
- wrapper = element.parents('.k-datetimepicker');
- if (!wrapper[0]) {
- wrapper = element.wrap(SPAN).parent().addClass('k-picker-wrap k-state-default');
- wrapper = wrapper.wrap(SPAN).parent();
- }
- wrapper[0].style.cssText = element[0].style.cssText;
- element.css({
- width: '100%',
- height: element[0].style.height
- });
- that.wrapper = wrapper.addClass('k-widget k-datetimepicker').addClass(element[0].className);
- that._inputWrapper = $(wrapper[0].firstChild);
- },
- _reset: function () {
- var that = this, element = that.element, formId = element.attr('form'), form = formId ? $('#' + formId) : element.closest('form');
- if (form[0]) {
- that._resetHandler = function () {
- that.value(element[0].defaultValue);
- that.max(that._initialOptions.max);
- that.min(that._initialOptions.min);
- };
- that._form = form.on('reset', that._resetHandler);
- }
- },
- _template: function () {
- this._ariaTemplate = kendo.template(this.options.ARIATemplate);
- },
- _createDateInput: function (options) {
- if (this._dateInput) {
- this._dateInput.destroy();
- this._dateInput = null;
- }
- if (options.dateInput) {
- this._dateInput = new ui.DateInput(this.element, {
- culture: options.culture,
- format: options.format,
- min: options.min,
- max: options.max
- });
- }
- },
- _calculateMidnight: function (min, max) {
- return getMilliseconds(min) + getMilliseconds(max) === 0;
- },
- _updateARIA: function (date) {
- var cell;
- var that = this;
- var calendar = that.dateView.calendar;
- that.element.removeAttr(ARIA_ACTIVEDESCENDANT);
- if (calendar) {
- cell = calendar._cell;
- cell.attr('aria-label', that._ariaTemplate({ current: date || calendar.current() }));
- that.element.attr(ARIA_ACTIVEDESCENDANT, cell.attr('id'));
- }
- }
- });
- function lastTimeOption(interval) {
- var date = new Date(2100, 0, 1);
- date.setMinutes(-interval);
- return date;
- }
- function preventDefault(e) {
- e.preventDefault();
- }
- function normalize(options) {
- var patterns = kendo.getCulture(options.culture).calendars.standard.patterns, parseFormats = !options.parseFormats.length, timeFormat;
- options.format = extractFormat(options.format || patterns.g);
- options.timeFormat = timeFormat = extractFormat(options.timeFormat || patterns.t);
- kendo.DateView.normalize(options);
- if (parseFormats) {
- options.parseFormats.unshift('yyyy-MM-ddTHH:mm:ss');
- }
- if ($.inArray(timeFormat, options.parseFormats) === -1) {
- options.parseFormats.push(timeFormat);
- }
- }
- ui.plugin(DateTimePicker);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.list', [
- 'kendo.data',
- 'kendo.popup'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'list',
- name: 'List',
- category: 'framework',
- depends: [
- 'data',
- 'popup'
- ],
- hidden: true
- };
- (function ($, undefined) {
- var kendo = window.kendo, ui = kendo.ui, outerHeight = kendo._outerHeight, percentageUnitsRegex = /^\d+(\.\d+)?%$/i, Widget = ui.Widget, keys = kendo.keys, support = kendo.support, htmlEncode = kendo.htmlEncode, activeElement = kendo._activeElement, outerWidth = kendo._outerWidth, ObservableArray = kendo.data.ObservableArray, ID = 'id', CHANGE = 'change', FOCUSED = 'k-state-focused', HOVER = 'k-state-hover', LOADING = 'k-i-loading', GROUPHEADER = '.k-group-header', ITEMSELECTOR = '.k-item', LABELIDPART = '_label', OPEN = 'open', CLOSE = 'close', CASCADE = 'cascade', SELECT = 'select', SELECTED = 'selected', REQUESTSTART = 'requestStart', REQUESTEND = 'requestEnd', extend = $.extend, proxy = $.proxy, isArray = $.isArray, browser = support.browser, HIDDENCLASS = 'k-hidden', WIDTH = 'width', isIE = browser.msie, isIE8 = isIE && browser.version < 9, quotRegExp = /"/g, alternativeNames = {
- 'ComboBox': 'DropDownList',
- 'DropDownList': 'ComboBox'
- };
- var List = kendo.ui.DataBoundWidget.extend({
- init: function (element, options) {
- var that = this, ns = that.ns, id;
- Widget.fn.init.call(that, element, options);
- element = that.element;
- options = that.options;
- that._isSelect = element.is(SELECT);
- if (that._isSelect && that.element[0].length) {
- if (!options.dataSource) {
- options.dataTextField = options.dataTextField || 'text';
- options.dataValueField = options.dataValueField || 'value';
- }
- }
- that.ul = $('
').attr({
- tabIndex: -1,
- 'aria-hidden': true
- });
- that.list = $('
').append(that.ul).on('mousedown' + ns, proxy(that._listMousedown, that));
- id = element.attr(ID);
- if (!id) {
- id = kendo.guid();
- }
- that.list.attr(ID, id + '-list');
- that.ul.attr(ID, id + '_listbox');
- if (options.columns && options.columns.length) {
- that.ul.removeClass('k-list').addClass('k-grid-list');
- that._columnsHeader();
- }
- that._header();
- that._noData();
- that._footer();
- that._accessors();
- that._initValue();
- },
- options: {
- valuePrimitive: false,
- footerTemplate: '',
- headerTemplate: '',
- noDataTemplate: 'No data found.'
- },
- setOptions: function (options) {
- Widget.fn.setOptions.call(this, options);
- if (options && options.enable !== undefined) {
- options.enabled = options.enable;
- }
- if (options.columns && options.columns.length) {
- this._columnsHeader();
- }
- this._header();
- this._noData();
- this._footer();
- this._renderFooter();
- this._renderNoData();
- },
- focus: function () {
- this._focused.focus();
- },
- readonly: function (readonly) {
- this._editable({
- readonly: readonly === undefined ? true : readonly,
- disable: false
- });
- },
- enable: function (enable) {
- this._editable({
- readonly: false,
- disable: !(enable = enable === undefined ? true : enable)
- });
- },
- _header: function () {
- var list = this;
- var header = $(list.header);
- var template = list.options.headerTemplate;
- this._angularElement(header, 'cleanup');
- kendo.destroy(header);
- header.remove();
- if (!template) {
- list.header = null;
- return;
- }
- var headerTemplate = typeof template !== 'function' ? kendo.template(template) : template;
- header = $(headerTemplate({}));
- list.header = header[0] ? header : null;
- list.list.prepend(header);
- this._angularElement(list.header, 'compile');
- },
- _columnsHeader: function () {
- var list = this;
- var columnsHeader = $(list.columnsHeader);
- this._angularElement(columnsHeader, 'cleanup');
- kendo.destroy(columnsHeader);
- columnsHeader.remove();
- var header = '';
- list.columnsHeader = columnsHeader = $(header);
- list.list.prepend(columnsHeader);
- this._angularElement(list.columnsHeader, 'compile');
- },
- _noData: function () {
- var list = this;
- var noData = $(list.noData);
- var template = list.options.noDataTemplate;
- list.angular('cleanup', function () {
- return { elements: noData };
- });
- kendo.destroy(noData);
- noData.remove();
- if (!template) {
- list.noData = null;
- return;
- }
- list.noData = $('
').appendTo(list.list);
- list.noDataTemplate = typeof template !== 'function' ? kendo.template(template) : template;
- },
- _footer: function () {
- var list = this;
- var footer = $(list.footer);
- var template = list.options.footerTemplate;
- this._angularElement(footer, 'cleanup');
- kendo.destroy(footer);
- footer.remove();
- if (!template) {
- list.footer = null;
- return;
- }
- list.footer = $('').appendTo(list.list);
- list.footerTemplate = typeof template !== 'function' ? kendo.template(template) : template;
- },
- _listOptions: function (options) {
- var that = this;
- var currentOptions = that.options;
- var virtual = currentOptions.virtual;
- var changeEventOption = { change: proxy(that._listChange, that) };
- var listBoundHandler = proxy(that._listBound, that);
- virtual = typeof virtual === 'object' ? virtual : {};
- options = $.extend({
- autoBind: false,
- selectable: true,
- dataSource: that.dataSource,
- click: proxy(that._click, that),
- activate: proxy(that._activateItem, that),
- columns: currentOptions.columns,
- deactivate: proxy(that._deactivateItem, that),
- dataBinding: function () {
- that.trigger('dataBinding');
- },
- dataBound: listBoundHandler,
- height: currentOptions.height,
- dataValueField: currentOptions.dataValueField,
- dataTextField: currentOptions.dataTextField,
- groupTemplate: currentOptions.groupTemplate,
- fixedGroupTemplate: currentOptions.fixedGroupTemplate,
- template: currentOptions.template
- }, options, virtual, changeEventOption);
- if (!options.template) {
- options.template = '#:' + kendo.expr(options.dataTextField, 'data') + '#';
- }
- if (currentOptions.$angular) {
- options.$angular = currentOptions.$angular;
- }
- return options;
- },
- _initList: function () {
- var that = this;
- var listOptions = that._listOptions({ selectedItemChange: proxy(that._listChange, that) });
- if (!that.options.virtual) {
- that.listView = new kendo.ui.StaticList(that.ul, listOptions);
- } else {
- that.listView = new kendo.ui.VirtualList(that.ul, listOptions);
- }
- that.listView.bind('listBound', proxy(that._listBound, that));
- that._setListValue();
- },
- _setListValue: function (value) {
- value = value || this.options.value;
- if (value !== undefined) {
- this.listView.value(value).done(proxy(this._updateSelectionState, this));
- }
- },
- _updateSelectionState: $.noop,
- _listMousedown: function (e) {
- if (!this.filterInput || this.filterInput[0] !== e.target) {
- e.preventDefault();
- }
- },
- _isFilterEnabled: function () {
- var filter = this.options.filter;
- return filter && filter !== 'none';
- },
- _hideClear: function () {
- var list = this;
- if (list._clear) {
- list._clear.addClass(HIDDENCLASS);
- }
- },
- _showClear: function () {
- if (this._clear) {
- this._clear.removeClass(HIDDENCLASS);
- }
- },
- _clearValue: function () {
- this._clearText();
- this._accessor('');
- this.listView.value([]);
- if (this._isSelect) {
- this._customOption = undefined;
- }
- if (this._isFilterEnabled() && !this.options.enforceMinLength) {
- this._filter({
- word: '',
- open: false
- });
- if (this.options.highlightFirst) {
- this.listView.focus(0);
- }
- }
- this._change();
- },
- _clearText: function () {
- this.text('');
- },
- _clearFilter: function () {
- if (!this.options.virtual) {
- this.listView.bound(false);
- }
- this._filterSource();
- },
- _filterSource: function (filter, force) {
- var that = this;
- var options = that.options;
- var isMultiColumnFiltering = options.filterFields && filter && filter.logic && filter.filters && filter.filters.length;
- var dataSource = that.dataSource;
- var expression = extend({}, dataSource.filter() || {});
- var resetPageSettings = filter || expression.filters && expression.filters.length && !filter;
- var removed = removeFiltersForField(expression, options.dataTextField);
- this._clearFilterExpressions(expression);
- if ((filter || removed) && that.trigger('filtering', { filter: filter })) {
- return;
- }
- var newExpression = {
- filters: [],
- logic: 'and'
- };
- if (isMultiColumnFiltering) {
- newExpression.filters.push(filter);
- } else {
- this._pushFilterExpression(newExpression, filter);
- }
- if (isValidFilterExpr(expression)) {
- if (newExpression.logic === expression.logic) {
- newExpression.filters = newExpression.filters.concat(expression.filters);
- } else {
- newExpression.filters.push(expression);
- }
- }
- if (that._cascading) {
- this.listView.setDSFilter(newExpression);
- }
- var dataSourceState = extend({}, {
- page: resetPageSettings ? 1 : dataSource.page(),
- pageSize: resetPageSettings ? dataSource.options.pageSize : dataSource.pageSize(),
- sort: dataSource.sort(),
- filter: dataSource.filter(),
- group: dataSource.group(),
- aggregate: dataSource.aggregate()
- }, { filter: newExpression });
- return dataSource[force ? 'read' : 'query'](dataSource._mergeState(dataSourceState));
- },
- _pushFilterExpression: function (newExpression, filter) {
- if (isValidFilterExpr(filter) && filter.value !== '') {
- newExpression.filters.push(filter);
- }
- },
- _clearFilterExpressions: function (expression) {
- if (!expression.filters) {
- return;
- }
- var filtersToRemove;
- for (var i = 0; i < expression.filters.length; i++) {
- if ('fromFilter' in expression.filters[i]) {
- filtersToRemove = i;
- }
- }
- if (!isNaN(filtersToRemove)) {
- expression.filters.splice(filtersToRemove, 1);
- }
- },
- _angularElement: function (element, action) {
- if (!element) {
- return;
- }
- this.angular(action, function () {
- return { elements: element };
- });
- },
- _renderNoData: function () {
- var list = this;
- var noData = list.noData;
- if (!noData) {
- return;
- }
- this._angularElement(noData, 'cleanup');
- noData.children(':first').html(list.noDataTemplate({ instance: list }));
- this._angularElement(noData, 'compile');
- },
- _toggleNoData: function (show) {
- $(this.noData).toggle(show);
- },
- _toggleHeader: function (show) {
- var groupHeader = this.listView.content.prev(GROUPHEADER);
- groupHeader.toggle(show);
- },
- _renderFooter: function () {
- var list = this;
- var footer = list.footer;
- if (!footer) {
- return;
- }
- this._angularElement(footer, 'cleanup');
- footer.html(list.footerTemplate({ instance: list }));
- this._angularElement(footer, 'compile');
- },
- _allowOpening: function () {
- return this.options.noDataTemplate || this.dataSource.flatView().length;
- },
- _initValue: function () {
- var that = this, value = that.options.value;
- if (value !== null) {
- that.element.val(value);
- } else {
- value = that._accessor();
- that.options.value = value;
- }
- that._old = value;
- },
- _ignoreCase: function () {
- var that = this, model = that.dataSource.reader.model, field;
- if (model && model.fields) {
- field = model.fields[that.options.dataTextField];
- if (field && field.type && field.type !== 'string') {
- that.options.ignoreCase = false;
- }
- }
- },
- _focus: function (candidate) {
- return this.listView.focus(candidate);
- },
- _filter: function (options) {
- var that = this;
- var widgetOptions = that.options;
- var word = options.word;
- var filterFields = widgetOptions.filterFields;
- var field = widgetOptions.dataTextField;
- var expression;
- if (filterFields && filterFields.length) {
- expression = {
- logic: 'or',
- filters: [],
- fromFilter: true
- };
- for (var i = 0; i < filterFields.length; i++) {
- this._pushFilterExpression(expression, that._buildExpression(word, filterFields[i]));
- }
- } else {
- expression = that._buildExpression(word, field);
- }
- that._open = options.open;
- that._filterSource(expression);
- },
- _buildExpression: function (value, field) {
- var that = this;
- var widgetOptions = that.options;
- var ignoreCase = widgetOptions.ignoreCase;
- return {
- value: ignoreCase ? value.toLowerCase() : value,
- field: field,
- operator: widgetOptions.filter,
- ignoreCase: ignoreCase
- };
- },
- _clearButton: function () {
- var list = this;
- var clearTitle = list.options.messages && list.options.messages.clear ? list.options.messages.clear : 'clear';
- if (!list._clear) {
- list._clear = $('
').attr({
- 'role': 'button',
- 'tabIndex': -1
- });
- }
- if (!list.options.clearButton) {
- list._clear.remove();
- }
- this._hideClear();
- },
- search: function (word) {
- var options = this.options;
- word = typeof word === 'string' ? word : this._inputValue();
- clearTimeout(this._typingTimeout);
- if (!options.enforceMinLength && !word.length || word.length >= options.minLength) {
- this._state = 'filter';
- if (this.listView) {
- this.listView._emptySearch = !$.trim(word).length;
- }
- if (!this._isFilterEnabled()) {
- this._searchByWord(word);
- } else {
- this._filter({
- word: word,
- open: true
- });
- }
- }
- },
- current: function (candidate) {
- return this._focus(candidate);
- },
- items: function () {
- return this.ul[0].children;
- },
- destroy: function () {
- var that = this;
- var ns = that.ns;
- Widget.fn.destroy.call(that);
- that._unbindDataSource();
- that.listView.destroy();
- that.list.off(ns);
- that.popup.destroy();
- if (that._form) {
- that._form.off('reset', that._resetHandler);
- }
- },
- dataItem: function (index) {
- var that = this;
- if (index === undefined) {
- return that.listView.selectedDataItems()[0];
- }
- if (typeof index !== 'number') {
- if (that.options.virtual) {
- return that.dataSource.getByUid($(index).data('uid'));
- }
- index = $(that.items()).index(index);
- }
- return that.dataSource.flatView()[index];
- },
- _activateItem: function () {
- var current = this.listView.focus();
- if (current) {
- this._focused.add(this.filterInput).attr('aria-activedescendant', current.attr('id'));
- }
- },
- _deactivateItem: function () {
- this._focused.add(this.filterInput).removeAttr('aria-activedescendant');
- },
- _accessors: function () {
- var that = this;
- var element = that.element;
- var options = that.options;
- var getter = kendo.getter;
- var textField = element.attr(kendo.attr('text-field'));
- var valueField = element.attr(kendo.attr('value-field'));
- if (!options.dataTextField && textField) {
- options.dataTextField = textField;
- }
- if (!options.dataValueField && valueField) {
- options.dataValueField = valueField;
- }
- that._text = getter(options.dataTextField);
- that._value = getter(options.dataValueField);
- },
- _aria: function (id) {
- var that = this, options = that.options, element = that._focused.add(that.filterInput);
- if (options.suggest !== undefined) {
- element.attr('aria-autocomplete', options.suggest ? 'both' : 'list');
- }
- id = id ? id + ' ' + that.ul[0].id : that.ul[0].id;
- element.attr('aria-owns', id);
- that.ul.attr('aria-live', !that._isFilterEnabled() ? 'off' : 'polite');
- that._ariaLabel();
- },
- _ariaLabel: function () {
- var that = this;
- var focusedElm = that._focused;
- var inputElm = that.element;
- var inputId = inputElm.attr('id');
- var labelElm = $('label[for="' + inputId + '"]');
- var ariaLabel = inputElm.attr('aria-label');
- var ariaLabelledBy = inputElm.attr('aria-labelledby');
- if (focusedElm === inputElm) {
- return;
- }
- if (ariaLabel) {
- focusedElm.attr('aria-label', ariaLabel);
- } else if (ariaLabelledBy) {
- focusedElm.attr('aria-labelledby', ariaLabelledBy);
- } else if (labelElm.length) {
- var labelId = labelElm.attr('id') || that._generateLabelId(labelElm, inputId || kendo.guid());
- focusedElm.attr('aria-labelledby', labelId);
- }
- },
- _generateLabelId: function (label, inputId) {
- var labelId = inputId + LABELIDPART;
- label.attr('id', labelId);
- return labelId;
- },
- _blur: function () {
- var that = this;
- that._change();
- that.close();
- },
- _change: function () {
- var that = this;
- var index = that.selectedIndex;
- var optionValue = that.options.value;
- var value = that.value();
- var trigger;
- if (that._isSelect && !that.listView.bound() && optionValue) {
- value = optionValue;
- }
- if (value !== unifyType(that._old, typeof value) && value !== unifyType(that._oldText, typeof value)) {
- trigger = true;
- } else if (that._valueBeforeCascade !== undefined && that._valueBeforeCascade !== unifyType(that._old, typeof that._valueBeforeCascade) && that._userTriggered) {
- trigger = true;
- } else if (index !== undefined && index !== that._oldIndex && !that.listView.isFiltered()) {
- trigger = true;
- }
- if (trigger) {
- if (that._old === null || that._old === '' || value === '') {
- that._valueBeforeCascade = that._old = value;
- } else {
- if (that.dataItem()) {
- that._valueBeforeCascade = that._old = that.options.dataValueField ? that.dataItem()[that.options.dataValueField] : that.dataItem();
- } else {
- that._valueBeforeCascade = that._old = null;
- }
- }
- that._oldIndex = index;
- that._oldText = that.text && that.text();
- if (!that._typing) {
- that.element.trigger(CHANGE);
- }
- that.trigger(CHANGE);
- }
- that.typing = false;
- },
- _data: function () {
- return this.dataSource.view();
- },
- _enable: function () {
- var that = this, options = that.options, disabled = that.element.is('[disabled]');
- if (options.enable !== undefined) {
- options.enabled = options.enable;
- }
- if (!options.enabled || disabled) {
- that.enable(false);
- } else {
- that.readonly(that.element.is('[readonly]'));
- }
- },
- _dataValue: function (dataItem) {
- var value = this._value(dataItem);
- if (value === undefined) {
- value = this._text(dataItem);
- }
- return value;
- },
- _offsetHeight: function () {
- var offsetHeight = 0;
- var siblings = this.listView.content.prevAll(':visible');
- siblings.each(function () {
- var element = $(this);
- offsetHeight += outerHeight(element, true);
- });
- return offsetHeight;
- },
- _height: function (length) {
- var that = this;
- var list = that.list;
- var height = that.options.height;
- var visible = that.popup.visible();
- var offsetTop;
- var popups;
- var footerHeight;
- if (length || that.options.noDataTemplate) {
- popups = list.add(list.parent('.k-animation-container')).show();
- if (!list.is(':visible')) {
- popups.hide();
- return;
- }
- height = that.listView.content[0].scrollHeight > height ? height : 'auto';
- popups.height(height);
- if (height !== 'auto') {
- offsetTop = that._offsetHeight();
- footerHeight = outerHeight($(that.footer)) || 0;
- height = height - offsetTop - footerHeight;
- }
- that.listView.content.height(height);
- if (!visible) {
- popups.hide();
- }
- }
- return height;
- },
- _openHandler: function (e) {
- this._adjustListWidth();
- if (this.trigger(OPEN)) {
- e.preventDefault();
- } else {
- this._focused.attr('aria-expanded', true);
- this.ul.attr('aria-hidden', false);
- }
- },
- _adjustListWidth: function () {
- var that = this, list = that.list, width = list[0].style.width, wrapper = that.wrapper, computedStyle, computedWidth;
- if (!list.data(WIDTH) && width) {
- return;
- }
- computedStyle = window.getComputedStyle ? window.getComputedStyle(wrapper[0], null) : 0;
- computedWidth = parseFloat(computedStyle && computedStyle.width) || outerWidth(wrapper);
- if (computedStyle && browser.msie) {
- computedWidth += parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight) + parseFloat(computedStyle.borderLeftWidth) + parseFloat(computedStyle.borderRightWidth);
- }
- if (list.css('box-sizing') !== 'border-box') {
- width = computedWidth - (outerWidth(list) - list.width());
- } else {
- width = computedWidth;
- }
- list.css({
- fontFamily: wrapper.css('font-family'),
- width: that.options.autoWidth ? 'auto' : width,
- minWidth: width,
- whiteSpace: that.options.autoWidth ? 'nowrap' : 'normal'
- }).data(WIDTH, width);
- return true;
- },
- _closeHandler: function (e) {
- if (this.trigger(CLOSE)) {
- e.preventDefault();
- } else {
- this._focused.attr('aria-expanded', false);
- this.ul.attr('aria-hidden', true);
- }
- },
- _focusItem: function () {
- var listView = this.listView;
- var noFocusedItem = !listView.focus();
- var index = last(listView.select());
- if (index === undefined && this.options.highlightFirst && noFocusedItem) {
- index = 0;
- }
- if (index !== undefined) {
- listView.focus(index);
- } else if (noFocusedItem) {
- listView.scrollToIndex(0);
- }
- },
- _calculateGroupPadding: function (height) {
- var li = this.ul.children('.k-first:first');
- var groupHeader = this.listView.content.prev(GROUPHEADER);
- var padding = 0;
- var direction = 'right';
- if (groupHeader[0] && groupHeader[0].style.display !== 'none') {
- if (height !== 'auto') {
- padding = kendo.support.scrollbar();
- }
- if (this.element.parents('.k-rtl').length) {
- direction = 'left';
- }
- padding += parseFloat(li.css('border-' + direction + '-width'), 10) + parseFloat(li.children('.k-group').css('padding-' + direction), 10);
- groupHeader.css('padding-' + direction, padding);
- }
- },
- _calculatePopupHeight: function (force) {
- var height = this._height(this.dataSource.flatView().length || force);
- this._calculateGroupPadding(height);
- this._calculateColumnsHeaderPadding(height);
- },
- _calculateColumnsHeaderPadding: function (height) {
- if (this.options.columns && this.options.columns.length) {
- var list = this;
- var isRtl = support.isRtl(list.wrapper);
- var scrollbar = kendo.support.scrollbar();
- list.columnsHeader.css(isRtl ? 'padding-left' : 'padding-right', height !== 'auto' ? scrollbar : 0);
- }
- },
- _resizePopup: function (force) {
- if (this.options.virtual) {
- return;
- }
- if (!this.popup.element.is(':visible')) {
- this.popup.one('open', function (force) {
- return proxy(function () {
- this._calculatePopupHeight(force);
- }, this);
- }.call(this, force));
- } else {
- this._calculatePopupHeight(force);
- }
- },
- _popup: function () {
- var list = this;
- list.popup = new ui.Popup(list.list, extend({}, list.options.popup, {
- anchor: list.wrapper,
- open: proxy(list._openHandler, list),
- close: proxy(list._closeHandler, list),
- animation: list.options.animation,
- isRtl: support.isRtl(list.wrapper),
- autosize: list.options.autoWidth
- }));
- },
- _makeUnselectable: function () {
- if (isIE8) {
- this.list.find('*').not('.k-textbox').attr('unselectable', 'on');
- }
- },
- _toggleHover: function (e) {
- $(e.currentTarget).toggleClass(HOVER, e.type === 'mouseenter');
- },
- _toggle: function (open, preventFocus) {
- var that = this;
- var touchEnabled = support.mobileOS && (support.touch || support.MSPointers || support.pointers);
- open = open !== undefined ? open : !that.popup.visible();
- if (!preventFocus && !touchEnabled && that._focused[0] !== activeElement()) {
- that._prevent = true;
- that._focused.focus();
- that._prevent = false;
- }
- that[open ? OPEN : CLOSE]();
- },
- _triggerCascade: function () {
- var that = this;
- if (!that._cascadeTriggered || that.value() !== unifyType(that._cascadedValue, typeof that.value())) {
- that._cascadedValue = that.value();
- that._cascadeTriggered = true;
- that.trigger(CASCADE, { userTriggered: that._userTriggered });
- }
- },
- _triggerChange: function () {
- if (this._valueBeforeCascade !== this.value()) {
- this.trigger(CHANGE);
- }
- },
- _unbindDataSource: function () {
- var that = this;
- that.dataSource.unbind(REQUESTSTART, that._requestStartHandler).unbind(REQUESTEND, that._requestEndHandler).unbind('error', that._errorHandler);
- },
- requireValueMapper: function (options, value) {
- var hasValue = (options.value instanceof Array ? options.value.length : options.value) || (value instanceof Array ? value.length : value);
- if (hasValue && options.virtual && typeof options.virtual.valueMapper !== 'function') {
- throw new Error('ValueMapper is not provided while the value is being set. See http://docs.telerik.com/kendo-ui/controls/editors/combobox/virtualization#the-valuemapper-function');
- }
- }
- });
- function unifyType(value, type) {
- if (value !== undefined && value !== '' && value !== null) {
- if (type === 'boolean') {
- value = Boolean(value);
- } else if (type === 'number') {
- value = Number(value);
- } else if (type === 'string') {
- value = value.toString();
- }
- }
- return value;
- }
- extend(List, {
- inArray: function (node, parentNode) {
- var idx, length, siblings = parentNode.children;
- if (!node || node.parentNode !== parentNode) {
- return -1;
- }
- for (idx = 0, length = siblings.length; idx < length; idx++) {
- if (node === siblings[idx]) {
- return idx;
- }
- }
- return -1;
- },
- unifyType: unifyType
- });
- kendo.ui.List = List;
- ui.Select = List.extend({
- init: function (element, options) {
- List.fn.init.call(this, element, options);
- this._initial = this.element.val();
- },
- setDataSource: function (dataSource) {
- var that = this;
- var parent;
- that.options.dataSource = dataSource;
- that._dataSource();
- if (that.listView.bound()) {
- that._initialIndex = null;
- that.listView._current = null;
- }
- that.listView.setDataSource(that.dataSource);
- if (that.options.autoBind) {
- that.dataSource.fetch();
- }
- parent = that._parentWidget();
- if (parent) {
- that._cascadeSelect(parent);
- }
- },
- close: function () {
- this.popup.close();
- },
- select: function (candidate) {
- var that = this;
- if (candidate === undefined) {
- return that.selectedIndex;
- } else {
- return that._select(candidate).done(function () {
- that._cascadeValue = that._old = that._accessor();
- that._oldIndex = that.selectedIndex;
- });
- }
- },
- _accessor: function (value, idx) {
- return this[this._isSelect ? '_accessorSelect' : '_accessorInput'](value, idx);
- },
- _accessorInput: function (value) {
- var element = this.element[0];
- if (value === undefined) {
- return element.value;
- } else {
- if (value === null) {
- value = '';
- }
- element.value = value;
- }
- },
- _accessorSelect: function (value, idx) {
- var element = this.element[0];
- var hasValue;
- if (value === undefined) {
- return getSelectedOption(element).value || '';
- }
- getSelectedOption(element).selected = false;
- if (idx === undefined) {
- idx = -1;
- }
- hasValue = value !== null && value !== '';
- if (hasValue && idx == -1) {
- this._custom(value);
- } else {
- if (value) {
- element.value = value;
- } else {
- element.selectedIndex = idx;
- }
- }
- },
- _syncValueAndText: function () {
- return true;
- },
- _custom: function (value) {
- var that = this;
- var element = that.element;
- var custom = that._customOption;
- if (!custom) {
- custom = $('
');
- that._customOption = custom;
- element.append(custom);
- }
- custom.text(value);
- custom[0].selected = true;
- },
- _hideBusy: function () {
- var that = this;
- clearTimeout(that._busy);
- that._arrowIcon.removeClass(LOADING);
- that._focused.attr('aria-busy', false);
- that._busy = null;
- that._showClear();
- },
- _showBusy: function (e) {
- var that = this;
- if (e.isDefaultPrevented()) {
- return;
- }
- that._request = true;
- if (that._busy) {
- return;
- }
- that._busy = setTimeout(function () {
- if (that._arrowIcon) {
- that._focused.attr('aria-busy', true);
- that._arrowIcon.addClass(LOADING);
- that._hideClear();
- }
- }, 100);
- },
- _requestEnd: function () {
- this._request = false;
- this._hideBusy();
- },
- _dataSource: function () {
- var that = this, element = that.element, options = that.options, dataSource = options.dataSource || {}, idx;
- dataSource = $.isArray(dataSource) ? { data: dataSource } : dataSource;
- if (that._isSelect) {
- idx = element[0].selectedIndex;
- if (idx > -1) {
- options.index = idx;
- }
- dataSource.select = element;
- dataSource.fields = [
- { field: options.dataTextField },
- { field: options.dataValueField }
- ];
- }
- if (that.dataSource) {
- that._unbindDataSource();
- } else {
- that._requestStartHandler = proxy(that._showBusy, that);
- that._requestEndHandler = proxy(that._requestEnd, that);
- that._errorHandler = proxy(that._hideBusy, that);
- }
- that.dataSource = kendo.data.DataSource.create(dataSource).bind(REQUESTSTART, that._requestStartHandler).bind(REQUESTEND, that._requestEndHandler).bind('error', that._errorHandler);
- },
- _firstItem: function () {
- this.listView.focusFirst();
- },
- _lastItem: function () {
- this.listView.focusLast();
- },
- _nextItem: function () {
- this.listView.focusNext();
- },
- _prevItem: function () {
- this.listView.focusPrev();
- },
- _move: function (e) {
- var that = this;
- var listView = that.listView;
- var key = e.keyCode;
- var down = key === keys.DOWN;
- var dataItem;
- var pressed;
- var current;
- if (key === keys.UP || down) {
- if (e.altKey) {
- that.toggle(down);
- } else {
- if (!listView.bound() && !that.ul[0].firstChild) {
- if (!that._fetch) {
- that.dataSource.one(CHANGE, function () {
- that._fetch = false;
- that._move(e);
- });
- that._fetch = true;
- that._filterSource();
- }
- e.preventDefault();
- return true;
- }
- current = that._focus();
- if (!that._fetch && (!current || current.hasClass('k-state-selected'))) {
- if (down) {
- that._nextItem();
- if (!that._focus()) {
- that._lastItem();
- }
- } else {
- that._prevItem();
- if (!that._focus()) {
- that._firstItem();
- }
- }
- }
- dataItem = listView.dataItemByIndex(listView.getElementIndex(that._focus()));
- if (that.trigger(SELECT, {
- dataItem: dataItem,
- item: that._focus()
- })) {
- that._focus(current);
- return;
- }
- that._select(that._focus(), true).done(function () {
- if (!that.popup.visible()) {
- that._blur();
- }
- if (that._cascadedValue === null) {
- that._cascadedValue = that.value();
- } else {
- that._cascadedValue = that.dataItem() ? that.dataItem()[that.options.dataValueField] || that.dataItem() : null;
- }
- });
- }
- e.preventDefault();
- pressed = true;
- } else if (key === keys.ENTER || key === keys.TAB) {
- if (that.popup.visible()) {
- e.preventDefault();
- }
- current = that._focus();
- dataItem = that.dataItem();
- if (!that.popup.visible() && (!dataItem || that.text() !== that._text(dataItem))) {
- current = null;
- }
- var activeFilter = that.filterInput && that.filterInput[0] === activeElement();
- var selection;
- if (current) {
- dataItem = listView.dataItemByIndex(listView.getElementIndex(current));
- var shouldTrigger = true;
- if (dataItem) {
- shouldTrigger = that._value(dataItem) !== List.unifyType(that.value(), typeof that._value(dataItem));
- }
- if (shouldTrigger && that.trigger(SELECT, {
- dataItem: dataItem,
- item: current
- })) {
- return;
- }
- selection = that._select(current);
- } else if (that.input) {
- if (that._syncValueAndText() || that._isSelect) {
- that._accessor(that.input.val());
- }
- that.listView.value(that.input.val());
- }
- if (that._focusElement) {
- that._focusElement(that.wrapper);
- }
- if (activeFilter && key === keys.TAB) {
- that.wrapper.focusout();
- } else {
- if (selection && typeof selection.done === 'function') {
- selection.done(function () {
- that._blur();
- });
- } else {
- that._blur();
- }
- }
- that.close();
- pressed = true;
- } else if (key === keys.ESC) {
- if (that.popup.visible()) {
- e.preventDefault();
- }
- that.close();
- pressed = true;
- } else if (that.popup.visible() && (key === keys.PAGEDOWN || key === keys.PAGEUP)) {
- e.preventDefault();
- var direction = key === keys.PAGEDOWN ? 1 : -1;
- listView.scrollWith(direction * listView.screenHeight());
- pressed = true;
- }
- return pressed;
- },
- _fetchData: function () {
- var that = this;
- var hasItems = !!that.dataSource.view().length;
- if (that._request || that.options.cascadeFrom) {
- return;
- }
- if (!that.listView.bound() && !that._fetch && !hasItems) {
- that._fetch = true;
- that.dataSource.fetch().done(function () {
- that._fetch = false;
- });
- }
- },
- _options: function (data, optionLabel, value) {
- var that = this, element = that.element, htmlElement = element[0], length = data.length, options = '', option, dataItem, dataText, dataValue, idx = 0;
- if (optionLabel) {
- options = optionLabel;
- }
- for (; idx < length; idx++) {
- option = '
';
- options += option;
- }
- element.html(options);
- if (value !== undefined) {
- htmlElement.value = value;
- if (htmlElement.value && !value) {
- htmlElement.selectedIndex = -1;
- }
- }
- if (htmlElement.selectedIndex !== -1) {
- option = getSelectedOption(htmlElement);
- if (option) {
- option.setAttribute(SELECTED, SELECTED);
- }
- }
- },
- _reset: function () {
- var that = this, element = that.element, formId = element.attr('form'), form = formId ? $('#' + formId) : element.closest('form');
- if (form[0]) {
- that._resetHandler = function () {
- setTimeout(function () {
- that.value(that._initial);
- });
- };
- that._form = form.on('reset', that._resetHandler);
- }
- },
- _parentWidget: function () {
- var name = this.options.name;
- if (!this.options.cascadeFrom) {
- return;
- }
- var parentElement = $('#' + this.options.cascadeFrom);
- var parent = parentElement.data('kendo' + name);
- if (!parent) {
- parent = parentElement.data('kendo' + alternativeNames[name]);
- }
- return parent;
- },
- _cascade: function () {
- var that = this;
- var options = that.options;
- var cascade = options.cascadeFrom;
- var parent;
- if (cascade) {
- parent = that._parentWidget();
- if (!parent) {
- return;
- }
- that._cascadeHandlerProxy = proxy(that._cascadeHandler, that);
- that._cascadeFilterRequests = [];
- options.autoBind = false;
- parent.bind('set', function () {
- that.one('set', function (e) {
- that._selectedValue = e.value || that._accessor();
- });
- });
- parent.first(CASCADE, that._cascadeHandlerProxy);
- if (parent.listView.bound()) {
- that._toggleCascadeOnFocus();
- that._cascadeSelect(parent);
- } else {
- parent.one('dataBound', function () {
- that._toggleCascadeOnFocus();
- if (parent.popup.visible()) {
- parent._focused.focus();
- }
- });
- if (!parent.value()) {
- that.enable(false);
- }
- }
- }
- },
- _toggleCascadeOnFocus: function () {
- var that = this;
- var parent = that._parentWidget();
- var focusout = isIE ? 'blur' : 'focusout';
- parent._focused.add(parent.filterInput).bind('focus', function () {
- parent.unbind(CASCADE, that._cascadeHandlerProxy);
- parent.first(CHANGE, that._cascadeHandlerProxy);
- });
- parent._focused.add(parent.filterInput).bind(focusout, function () {
- parent.unbind(CHANGE, that._cascadeHandlerProxy);
- parent.first(CASCADE, that._cascadeHandlerProxy);
- });
- },
- _cascadeHandler: function (e) {
- var parent = this._parentWidget();
- var valueBeforeCascade = this.value();
- this._userTriggered = e.userTriggered;
- if (this.listView.bound()) {
- this._clearSelection(parent, true);
- }
- this._cascadeSelect(parent, valueBeforeCascade);
- },
- _cascadeChange: function (parent) {
- var that = this;
- var value = that._accessor() || that._selectedValue;
- if (!that._cascadeFilterRequests.length) {
- that._selectedValue = null;
- }
- if (that._userTriggered) {
- that._clearSelection(parent, true);
- } else if (value) {
- if (value !== unifyType(that.listView.value()[0], typeof value)) {
- that.value(value);
- }
- if (!that.dataSource.view()[0] || that.selectedIndex === -1) {
- that._clearSelection(parent, true);
- }
- } else if (that.dataSource.flatView().length) {
- that.select(that.options.index);
- }
- that.enable();
- that._triggerCascade();
- that._triggerChange();
- that._userTriggered = false;
- },
- _cascadeSelect: function (parent, valueBeforeCascade) {
- var that = this;
- var dataItem = parent.dataItem();
- var filterValue = dataItem ? dataItem[that.options.cascadeFromParentField] || parent._value(dataItem) : null;
- var valueField = that.options.cascadeFromField || parent.options.dataValueField;
- var expressions;
- that._valueBeforeCascade = valueBeforeCascade !== undefined ? valueBeforeCascade : that.value();
- if (filterValue || filterValue === 0) {
- expressions = that.dataSource.filter() || {};
- removeFiltersForField(expressions, valueField);
- var handler = function () {
- var currentHandler = that._cascadeFilterRequests.shift();
- if (currentHandler) {
- that.unbind('dataBound', currentHandler);
- }
- currentHandler = that._cascadeFilterRequests[0];
- if (currentHandler) {
- that.first('dataBound', currentHandler);
- }
- that._cascadeChange(parent);
- };
- that._cascadeFilterRequests.push(handler);
- if (that._cascadeFilterRequests.length === 1) {
- that.first('dataBound', handler);
- }
- that._cascading = true;
- that._filterSource({
- field: valueField,
- operator: 'eq',
- value: filterValue
- });
- that._cascading = false;
- } else {
- that.enable(false);
- that._clearSelection(parent);
- that._triggerCascade();
- that._triggerChange();
- that._userTriggered = false;
- }
- }
- });
- var STATIC_LIST_NS = '.StaticList';
- var StaticList = kendo.ui.DataBoundWidget.extend({
- init: function (element, options) {
- Widget.fn.init.call(this, element, options);
- this.element.attr('role', 'listbox').on('click' + STATIC_LIST_NS, 'li', proxy(this._click, this)).on('mouseenter' + STATIC_LIST_NS, 'li', function () {
- $(this).addClass(HOVER);
- }).on('mouseleave' + STATIC_LIST_NS, 'li', function () {
- $(this).removeClass(HOVER);
- });
- if (support.touch) {
- this._touchHandlers();
- }
- if (this.options.selectable === 'multiple') {
- this.element.attr('aria-multiselectable', true);
- }
- this.content = this.element.wrap('
').parent();
- this.header = this.content.before('').prev();
- this.bound(false);
- this._optionID = kendo.guid();
- this._selectedIndices = [];
- this._view = [];
- this._dataItems = [];
- this._values = [];
- var value = this.options.value;
- if (value) {
- this._values = $.isArray(value) ? value.slice(0) : [value];
- }
- this._getter();
- this._templates();
- this.setDataSource(this.options.dataSource);
- this._onScroll = proxy(function () {
- var that = this;
- clearTimeout(that._scrollId);
- that._scrollId = setTimeout(function () {
- that._renderHeader();
- }, 50);
- }, this);
- },
- options: {
- name: 'StaticList',
- dataValueField: null,
- valuePrimitive: false,
- selectable: true,
- template: null,
- groupTemplate: null,
- fixedGroupTemplate: null
- },
- events: [
- 'click',
- CHANGE,
- 'activate',
- 'deactivate',
- 'dataBinding',
- 'dataBound',
- 'selectedItemChange'
- ],
- setDataSource: function (source) {
- var that = this;
- var dataSource = source || {};
- var value;
- dataSource = $.isArray(dataSource) ? { data: dataSource } : dataSource;
- dataSource = kendo.data.DataSource.create(dataSource);
- if (that.dataSource) {
- that.dataSource.unbind(CHANGE, that._refreshHandler);
- value = that.value();
- that.value([]);
- that.bound(false);
- that.value(value);
- } else {
- that._refreshHandler = proxy(that.refresh, that);
- }
- that.setDSFilter(dataSource.filter());
- that.dataSource = dataSource.bind(CHANGE, that._refreshHandler);
- that._fixedHeader();
- },
- _touchHandlers: function () {
- var that = this;
- var startY;
- var endY;
- var tapPosition = function (event) {
- return (event.originalEvent || event).changedTouches[0].pageY;
- };
- that.element.on('touchstart' + STATIC_LIST_NS, function (e) {
- startY = tapPosition(e);
- });
- that.element.on('touchend' + STATIC_LIST_NS, function (e) {
- if (e.isDefaultPrevented()) {
- return;
- }
- endY = tapPosition(e);
- if (Math.abs(endY - startY) < 10) {
- that._touchTriggered = true;
- that._triggerClick($(e.target).closest(ITEMSELECTOR).get(0));
- }
- });
- },
- skip: function () {
- return this.dataSource.skip();
- },
- setOptions: function (options) {
- Widget.fn.setOptions.call(this, options);
- this._getter();
- this._templates();
- this._render();
- },
- destroy: function () {
- this.element.off(STATIC_LIST_NS);
- if (this._refreshHandler) {
- this.dataSource.unbind(CHANGE, this._refreshHandler);
- }
- clearTimeout(this._scrollId);
- Widget.fn.destroy.call(this);
- },
- dataItemByIndex: function (index) {
- return this.dataSource.flatView()[index];
- },
- screenHeight: function () {
- return this.content[0].clientHeight;
- },
- scrollToIndex: function (index) {
- var item = this.element[0].children[index];
- if (item) {
- this.scroll(item);
- }
- },
- scrollWith: function (value) {
- this.content.scrollTop(this.content.scrollTop() + value);
- },
- scroll: function (item) {
- if (!item) {
- return;
- }
- if (item[0]) {
- item = item[0];
- }
- var content = this.content[0], itemOffsetTop = item.offsetTop, itemOffsetHeight = item.offsetHeight, contentScrollTop = content.scrollTop, contentOffsetHeight = content.clientHeight, bottomDistance = itemOffsetTop + itemOffsetHeight;
- if (contentScrollTop > itemOffsetTop) {
- contentScrollTop = itemOffsetTop;
- } else if (bottomDistance > contentScrollTop + contentOffsetHeight) {
- contentScrollTop = bottomDistance - contentOffsetHeight;
- }
- content.scrollTop = contentScrollTop;
- },
- selectedDataItems: function (dataItems) {
- if (dataItems === undefined) {
- return this._dataItems.slice();
- }
- this._dataItems = dataItems;
- this._values = this._getValues(dataItems);
- },
- _getValues: function (dataItems) {
- var getter = this._valueGetter;
- return $.map(dataItems, function (dataItem) {
- return getter(dataItem);
- });
- },
- focusNext: function () {
- var current = this.focus();
- if (!current) {
- current = 0;
- } else {
- current = current.next();
- }
- this.focus(current);
- },
- focusPrev: function () {
- var current = this.focus();
- if (!current) {
- current = this.element[0].children.length - 1;
- } else {
- current = current.prev();
- }
- this.focus(current);
- },
- focusFirst: function () {
- this.focus(this.element[0].children[0]);
- },
- focusLast: function () {
- this.focus(last(this.element[0].children));
- },
- focus: function (candidate) {
- var that = this;
- var id = that._optionID;
- var hasCandidate;
- if (candidate === undefined) {
- return that._current;
- }
- candidate = last(that._get(candidate));
- candidate = $(this.element[0].children[candidate]);
- if (that._current) {
- that._current.removeClass(FOCUSED).removeAttr(ID);
- that.trigger('deactivate');
- }
- hasCandidate = !!candidate[0];
- if (hasCandidate) {
- candidate.addClass(FOCUSED);
- that.scroll(candidate);
- candidate.attr('id', id);
- }
- that._current = hasCandidate ? candidate : null;
- that.trigger('activate');
- },
- focusIndex: function () {
- return this.focus() ? this.focus().index() : undefined;
- },
- skipUpdate: function (skipUpdate) {
- this._skipUpdate = skipUpdate;
- },
- select: function (indices) {
- var that = this;
- var selectable = that.options.selectable;
- var singleSelection = selectable !== 'multiple' && selectable !== false;
- var selectedIndices = that._selectedIndices;
- var added = [];
- var removed = [];
- var result;
- if (indices === undefined) {
- return selectedIndices.slice();
- }
- indices = that._get(indices);
- if (indices.length === 1 && indices[0] === -1) {
- indices = [];
- }
- var deferred = $.Deferred().resolve();
- var filtered = that.isFiltered();
- if (filtered && !singleSelection && that._deselectFiltered(indices)) {
- return deferred;
- }
- if (singleSelection && !filtered && $.inArray(last(indices), selectedIndices) !== -1) {
- if (that._dataItems.length && that._view.length) {
- that._dataItems = [that._view[selectedIndices[0]].item];
- }
- return deferred;
- }
- result = that._deselect(indices);
- removed = result.removed;
- indices = result.indices;
- if (indices.length) {
- if (singleSelection) {
- indices = [last(indices)];
- }
- added = that._select(indices);
- }
- if (added.length || removed.length) {
- that._valueComparer = null;
- that.trigger(CHANGE, {
- added: added,
- removed: removed
- });
- }
- return deferred;
- },
- removeAt: function (position) {
- this._selectedIndices.splice(position, 1);
- this._values.splice(position, 1);
- this._valueComparer = null;
- return {
- position: position,
- dataItem: this._dataItems.splice(position, 1)[0]
- };
- },
- setValue: function (value) {
- value = $.isArray(value) || value instanceof ObservableArray ? value.slice(0) : [value];
- this._values = value;
- this._valueComparer = null;
- },
- value: function (value) {
- var that = this;
- var deferred = that._valueDeferred;
- var indices;
- if (value === undefined) {
- return that._values.slice();
- }
- that.setValue(value);
- if (!deferred || deferred.state() === 'resolved') {
- that._valueDeferred = deferred = $.Deferred();
- }
- if (that.bound()) {
- indices = that._valueIndices(that._values);
- if (that.options.selectable === 'multiple') {
- that.select(-1);
- }
- that.select(indices);
- deferred.resolve();
- }
- that._skipUpdate = false;
- return deferred;
- },
- items: function () {
- return this.element.children(ITEMSELECTOR);
- },
- _click: function (e) {
- if (this._touchTriggered) {
- this._touchTriggered = false;
- return;
- }
- if (!e.isDefaultPrevented()) {
- this._triggerClick(e.currentTarget);
- }
- },
- _triggerClick: function (item) {
- if (!this.trigger('click', { item: $(item) })) {
- this.select(item);
- }
- },
- _valueExpr: function (type, values) {
- var that = this;
- var idx = 0;
- var body;
- var comparer;
- var normalized = [];
- if (!that._valueComparer || that._valueType !== type) {
- that._valueType = type;
- for (; idx < values.length; idx++) {
- normalized.push(unifyType(values[idx], type));
- }
- body = 'for (var idx = 0; idx < ' + normalized.length + '; idx++) {' + ' if (current === values[idx]) {' + ' return idx;' + ' }' + '} ' + 'return -1;';
- comparer = new Function('current', 'values', body);
- that._valueComparer = function (current) {
- return comparer(current, normalized);
- };
- }
- return that._valueComparer;
- },
- _dataItemPosition: function (dataItem, values) {
- var value = this._valueGetter(dataItem);
- var valueExpr = this._valueExpr(typeof value, values);
- return valueExpr(value);
- },
- _getter: function () {
- this._valueGetter = kendo.getter(this.options.dataValueField);
- },
- _deselect: function (indices) {
- var that = this;
- var children = that.element[0].children;
- var selectable = that.options.selectable;
- var selectedIndices = that._selectedIndices;
- var dataItems = that._dataItems;
- var values = that._values;
- var removed = [];
- var i = 0;
- var j;
- var index, selectedIndex;
- var removedIndices = 0;
- indices = indices.slice();
- if (selectable === true || !indices.length) {
- for (; i < selectedIndices.length; i++) {
- $(children[selectedIndices[i]]).removeClass('k-state-selected').attr('aria-selected', false);
- removed.push({
- position: i,
- dataItem: dataItems[i]
- });
- }
- that._values = [];
- that._dataItems = [];
- that._selectedIndices = [];
- } else if (selectable === 'multiple') {
- for (; i < indices.length; i++) {
- index = indices[i];
- if (!$(children[index]).hasClass('k-state-selected')) {
- continue;
- }
- for (j = 0; j < selectedIndices.length; j++) {
- selectedIndex = selectedIndices[j];
- if (selectedIndex === index) {
- $(children[selectedIndex]).removeClass('k-state-selected').attr('aria-selected', false);
- removed.push({
- position: j + removedIndices,
- dataItem: dataItems.splice(j, 1)[0]
- });
- selectedIndices.splice(j, 1);
- indices.splice(i, 1);
- values.splice(j, 1);
- removedIndices += 1;
- i -= 1;
- j -= 1;
- break;
- }
- }
- }
- }
- return {
- indices: indices,
- removed: removed
- };
- },
- _deselectFiltered: function (indices) {
- var children = this.element[0].children;
- var dataItem, index, position;
- var removed = [];
- var idx = 0;
- for (; idx < indices.length; idx++) {
- index = indices[idx];
- dataItem = this._view[index].item;
- position = this._dataItemPosition(dataItem, this._values);
- if (position > -1) {
- removed.push(this.removeAt(position));
- $(children[index]).removeClass('k-state-selected');
- }
- }
- if (removed.length) {
- this.trigger(CHANGE, {
- added: [],
- removed: removed
- });
- return true;
- }
- return false;
- },
- _select: function (indices) {
- var that = this;
- var children = that.element[0].children;
- var data = that._view;
- var dataItem, index;
- var added = [];
- var idx = 0;
- if (last(indices) !== -1) {
- that.focus(indices);
- }
- for (; idx < indices.length; idx++) {
- index = indices[idx];
- dataItem = data[index];
- if (index === -1 || !dataItem) {
- continue;
- }
- dataItem = dataItem.item;
- that._selectedIndices.push(index);
- that._dataItems.push(dataItem);
- that._values.push(that._valueGetter(dataItem));
- $(children[index]).addClass('k-state-selected').attr('aria-selected', true);
- added.push({ dataItem: dataItem });
- }
- return added;
- },
- getElementIndex: function (element) {
- return $(element).data('offset-index');
- },
- _get: function (candidate) {
- if (typeof candidate === 'number') {
- candidate = [candidate];
- } else if (!isArray(candidate)) {
- candidate = this.getElementIndex(candidate);
- candidate = [candidate !== undefined ? candidate : -1];
- }
- return candidate;
- },
- _template: function () {
- var that = this;
- var options = that.options;
- var template = options.template;
- if (!template) {
- template = kendo.template('
${' + kendo.expr(options.dataTextField, 'data') + '}', { useWithBlock: false });
- } else {
- template = kendo.template(template);
- template = function (data) {
- return '
' + template(data) + '';
- };
- }
- return template;
- },
- _templates: function () {
- var template;
- var options = this.options;
- var templates = {
- template: options.template,
- groupTemplate: options.groupTemplate,
- fixedGroupTemplate: options.fixedGroupTemplate
- };
- if (options.columns) {
- for (var i = 0; i < options.columns.length; i++) {
- var currentColumn = options.columns[i];
- var templateText = currentColumn.field ? currentColumn.field.toString() : 'text';
- templates['column' + i] = currentColumn.template || '#: ' + templateText + '#';
- }
- }
- for (var key in templates) {
- template = templates[key];
- if (template && typeof template !== 'function') {
- templates[key] = kendo.template(template);
- }
- }
- this.templates = templates;
- },
- _normalizeIndices: function (indices) {
- var newIndices = [];
- var idx = 0;
- for (; idx < indices.length; idx++) {
- if (indices[idx] !== undefined) {
- newIndices.push(indices[idx]);
- }
- }
- return newIndices;
- },
- _valueIndices: function (values, indices) {
- var data = this._view;
- var idx = 0;
- var index;
- indices = indices ? indices.slice() : [];
- if (!values.length) {
- return [];
- }
- for (; idx < data.length; idx++) {
- index = this._dataItemPosition(data[idx].item, values);
- if (index !== -1) {
- indices[index] = idx;
- }
- }
- return this._normalizeIndices(indices);
- },
- _firstVisibleItem: function () {
- var element = this.element[0];
- var content = this.content[0];
- var scrollTop = content.scrollTop;
- var itemHeight = $(element.children[0]).height();
- var itemIndex = Math.floor(scrollTop / itemHeight) || 0;
- var item = element.children[itemIndex] || element.lastChild;
- var forward = item.offsetTop < scrollTop;
- while (item) {
- if (forward) {
- if (item.offsetTop + itemHeight > scrollTop || !item.nextSibling) {
- break;
- }
- item = item.nextSibling;
- } else {
- if (item.offsetTop <= scrollTop || !item.previousSibling) {
- break;
- }
- item = item.previousSibling;
- }
- }
- return this._view[$(item).data('offset-index')];
- },
- _fixedHeader: function () {
- if (this.isGrouped() && this.templates.fixedGroupTemplate) {
- this.header.show();
- this.content.scroll(this._onScroll);
- } else {
- this.header.hide();
- this.content.off('scroll', this._onScroll);
- }
- },
- _renderHeader: function () {
- var template = this.templates.fixedGroupTemplate;
- if (!template) {
- return;
- }
- var visibleItem = this._firstVisibleItem();
- if (visibleItem && visibleItem.group) {
- this.header.html(template(visibleItem.group));
- }
- },
- _renderItem: function (context) {
- var item = '
';
- if (hasColumns) {
- item += this._renderColumns(dataItem);
- } else {
- item += this.templates.template(dataItem);
- }
- if (notFirstItem && context.newGroup) {
- if (hasColumns) {
- item += '' + this.templates.groupTemplate(context.group) + '
';
- } else {
- item += '' + this.templates.groupTemplate(context.group) + '
';
- }
- } else if (isGrouped && hasColumns) {
- item += '';
- }
- return item + '';
- },
- _renderColumns: function (dataItem) {
- var item = '';
- for (var i = 0; i < this.options.columns.length; i++) {
- var currentWidth = this.options.columns[i].width;
- var currentWidthInt = parseInt(currentWidth, 10);
- var widthStyle = '';
- if (currentWidth && !isNaN(currentWidthInt)) {
- widthStyle += 'style=\'width:';
- widthStyle += currentWidthInt;
- widthStyle += percentageUnitsRegex.test(currentWidth) ? '%' : 'px';
- widthStyle += ';\'';
- }
- item += '
';
- item += this.templates['column' + i](dataItem);
- item += '';
- }
- return item;
- },
- _render: function () {
- var html = '';
- var i = 0;
- var idx = 0;
- var context;
- var dataContext = [];
- var view = this.dataSource.view();
- var values = this.value();
- var group, newGroup, j;
- var isGrouped = this.isGrouped();
- if (isGrouped) {
- for (i = 0; i < view.length; i++) {
- group = view[i];
- newGroup = true;
- for (j = 0; j < group.items.length; j++) {
- context = {
- selected: this._selected(group.items[j], values),
- item: group.items[j],
- group: group.value,
- newGroup: newGroup,
- isLastGroupedItem: j === group.items.length - 1,
- index: idx
- };
- dataContext[idx] = context;
- idx += 1;
- html += this._renderItem(context);
- newGroup = false;
- }
- }
- } else {
- for (i = 0; i < view.length; i++) {
- context = {
- selected: this._selected(view[i], values),
- item: view[i],
- index: i
- };
- dataContext[i] = context;
- html += this._renderItem(context);
- }
- }
- this._view = dataContext;
- this.element[0].innerHTML = html;
- if (isGrouped && dataContext.length) {
- this._renderHeader();
- }
- },
- _selected: function (dataItem, values) {
- var select = !this.isFiltered() || this.options.selectable === 'multiple';
- return select && this._dataItemPosition(dataItem, values) !== -1;
- },
- setDSFilter: function (filter) {
- this._lastDSFilter = extend({}, filter);
- },
- isFiltered: function () {
- if (!this._lastDSFilter) {
- this.setDSFilter(this.dataSource.filter());
- }
- return !kendo.data.Query.compareFilters(this.dataSource.filter(), this._lastDSFilter);
- },
- refresh: function (e) {
- var that = this;
- var action = e && e.action;
- var skipUpdateOnBind = that.options.skipUpdateOnBind;
- var isItemChange = action === 'itemchange';
- var result;
- that.trigger('dataBinding');
- that._angularItems('cleanup');
- that._fixedHeader();
- that._render();
- that.bound(true);
- if (isItemChange || action === 'remove') {
- result = mapChangedItems(that._dataItems, e.items);
- if (result.changed.length) {
- if (isItemChange) {
- that.trigger('selectedItemChange', { items: result.changed });
- } else {
- that.value(that._getValues(result.unchanged));
- }
- }
- } else if (that.isFiltered() || that._skipUpdate || that._emptySearch) {
- that.focus(0);
- if (that._skipUpdate) {
- that._skipUpdate = false;
- that._selectedIndices = that._valueIndices(that._values, that._selectedIndices);
- }
- } else if (!skipUpdateOnBind && (!action || action === 'add')) {
- that.value(that._values);
- }
- if (that._valueDeferred) {
- that._valueDeferred.resolve();
- }
- that._angularItems('compile');
- that.trigger('dataBound');
- },
- bound: function (bound) {
- if (bound === undefined) {
- return this._bound;
- }
- this._bound = bound;
- },
- isGrouped: function () {
- return (this.dataSource.group() || []).length;
- }
- });
- ui.plugin(StaticList);
- function last(list) {
- return list[list.length - 1];
- }
- function getSelectedOption(select) {
- var index = select.selectedIndex;
- return index > -1 ? select.options[index] : {};
- }
- function mapChangedItems(selected, itemsToMatch) {
- var itemsLength = itemsToMatch.length;
- var selectedLength = selected.length;
- var dataItem;
- var found;
- var i, j;
- var changed = [];
- var unchanged = [];
- if (selectedLength) {
- for (i = 0; i < selectedLength; i++) {
- dataItem = selected[i];
- found = false;
- for (j = 0; j < itemsLength; j++) {
- if (dataItem === itemsToMatch[j]) {
- found = true;
- changed.push({
- index: i,
- item: dataItem
- });
- break;
- }
- }
- if (!found) {
- unchanged.push(dataItem);
- }
- }
- }
- return {
- changed: changed,
- unchanged: unchanged
- };
- }
- function isValidFilterExpr(expression) {
- if (!expression || $.isEmptyObject(expression)) {
- return false;
- }
- if (expression.filters && !expression.filters.length) {
- return false;
- }
- return true;
- }
- function removeFiltersForField(expression, field) {
- var filters;
- var found = false;
- if (expression.filters) {
- filters = $.grep(expression.filters, function (filter) {
- found = removeFiltersForField(filter, field);
- if (filter.filters) {
- return filter.filters.length;
- } else {
- return filter.field != field;
- }
- });
- if (!found && expression.filters.length !== filters.length) {
- found = true;
- }
- expression.filters = filters;
- }
- return found;
- }
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.fx', ['kendo.core'], f);
-}(function () {
- var __meta__ = {
- id: 'fx',
- name: 'Effects',
- category: 'framework',
- description: 'Required for animation effects in all Kendo UI widgets.',
- depends: ['core']
- };
- (function ($, undefined) {
- var kendo = window.kendo, fx = kendo.effects, each = $.each, extend = $.extend, proxy = $.proxy, support = kendo.support, browser = support.browser, transforms = support.transforms, transitions = support.transitions, scaleProperties = {
- scale: 0,
- scalex: 0,
- scaley: 0,
- scale3d: 0
- }, translateProperties = {
- translate: 0,
- translatex: 0,
- translatey: 0,
- translate3d: 0
- }, hasZoom = typeof document.documentElement.style.zoom !== 'undefined' && !transforms, matrix3dRegExp = /matrix3?d?\s*\(.*,\s*([\d\.\-]+)\w*?,\s*([\d\.\-]+)\w*?,\s*([\d\.\-]+)\w*?,\s*([\d\.\-]+)\w*?/i, cssParamsRegExp = /^(-?[\d\.\-]+)?[\w\s]*,?\s*(-?[\d\.\-]+)?[\w\s]*/i, translateXRegExp = /translatex?$/i, oldEffectsRegExp = /(zoom|fade|expand)(\w+)/, singleEffectRegExp = /(zoom|fade|expand)/, unitRegExp = /[xy]$/i, transformProps = [
- 'perspective',
- 'rotate',
- 'rotatex',
- 'rotatey',
- 'rotatez',
- 'rotate3d',
- 'scale',
- 'scalex',
- 'scaley',
- 'scalez',
- 'scale3d',
- 'skew',
- 'skewx',
- 'skewy',
- 'translate',
- 'translatex',
- 'translatey',
- 'translatez',
- 'translate3d',
- 'matrix',
- 'matrix3d'
- ], transform2d = [
- 'rotate',
- 'scale',
- 'scalex',
- 'scaley',
- 'skew',
- 'skewx',
- 'skewy',
- 'translate',
- 'translatex',
- 'translatey',
- 'matrix'
- ], transform2units = {
- 'rotate': 'deg',
- scale: '',
- skew: 'px',
- translate: 'px'
- }, cssPrefix = transforms.css, round = Math.round, BLANK = '', PX = 'px', NONE = 'none', AUTO = 'auto', WIDTH = 'width', HEIGHT = 'height', HIDDEN = 'hidden', ORIGIN = 'origin', ABORT_ID = 'abortId', OVERFLOW = 'overflow', TRANSLATE = 'translate', POSITION = 'position', COMPLETE_CALLBACK = 'completeCallback', TRANSITION = cssPrefix + 'transition', TRANSFORM = cssPrefix + 'transform', BACKFACE = cssPrefix + 'backface-visibility', PERSPECTIVE = cssPrefix + 'perspective', DEFAULT_PERSPECTIVE = '1500px', TRANSFORM_PERSPECTIVE = 'perspective(' + DEFAULT_PERSPECTIVE + ')', directions = {
- left: {
- reverse: 'right',
- property: 'left',
- transition: 'translatex',
- vertical: false,
- modifier: -1
- },
- right: {
- reverse: 'left',
- property: 'left',
- transition: 'translatex',
- vertical: false,
- modifier: 1
- },
- down: {
- reverse: 'up',
- property: 'top',
- transition: 'translatey',
- vertical: true,
- modifier: 1
- },
- up: {
- reverse: 'down',
- property: 'top',
- transition: 'translatey',
- vertical: true,
- modifier: -1
- },
- top: { reverse: 'bottom' },
- bottom: { reverse: 'top' },
- 'in': {
- reverse: 'out',
- modifier: -1
- },
- out: {
- reverse: 'in',
- modifier: 1
- },
- vertical: { reverse: 'vertical' },
- horizontal: { reverse: 'horizontal' }
- };
- kendo.directions = directions;
- extend($.fn, {
- kendoStop: function (clearQueue, gotoEnd) {
- if (transitions) {
- return fx.stopQueue(this, clearQueue || false, gotoEnd || false);
- } else {
- return this.stop(clearQueue, gotoEnd);
- }
- }
- });
- if (transforms && !transitions) {
- each(transform2d, function (idx, value) {
- $.fn[value] = function (val) {
- if (typeof val == 'undefined') {
- return animationProperty(this, value);
- } else {
- var that = $(this)[0], transformValue = value + '(' + val + transform2units[value.replace(unitRegExp, '')] + ')';
- if (that.style.cssText.indexOf(TRANSFORM) == -1) {
- $(this).css(TRANSFORM, transformValue);
- } else {
- that.style.cssText = that.style.cssText.replace(new RegExp(value + '\\(.*?\\)', 'i'), transformValue);
- }
- }
- return this;
- };
- $.fx.step[value] = function (fx) {
- $(fx.elem)[value](fx.now);
- };
- });
- var curProxy = $.fx.prototype.cur;
- $.fx.prototype.cur = function () {
- if (transform2d.indexOf(this.prop) != -1) {
- return parseFloat($(this.elem)[this.prop]());
- }
- return curProxy.apply(this, arguments);
- };
- }
- kendo.toggleClass = function (element, classes, options, add) {
- if (classes) {
- classes = classes.split(' ');
- if (transitions) {
- options = extend({
- exclusive: 'all',
- duration: 400,
- ease: 'ease-out'
- }, options);
- element.css(TRANSITION, options.exclusive + ' ' + options.duration + 'ms ' + options.ease);
- setTimeout(function () {
- element.css(TRANSITION, '').css(HEIGHT);
- }, options.duration);
- }
- each(classes, function (idx, value) {
- element.toggleClass(value, add);
- });
- }
- return element;
- };
- kendo.parseEffects = function (input, mirror) {
- var effects = {};
- if (typeof input === 'string') {
- each(input.split(' '), function (idx, value) {
- var redirectedEffect = !singleEffectRegExp.test(value), resolved = value.replace(oldEffectsRegExp, function (match, $1, $2) {
- return $1 + ':' + $2.toLowerCase();
- }), effect = resolved.split(':'), direction = effect[1], effectBody = {};
- if (effect.length > 1) {
- effectBody.direction = mirror && redirectedEffect ? directions[direction].reverse : direction;
- }
- effects[effect[0]] = effectBody;
- });
- } else {
- each(input, function (idx) {
- var direction = this.direction;
- if (direction && mirror && !singleEffectRegExp.test(idx)) {
- this.direction = directions[direction].reverse;
- }
- effects[idx] = this;
- });
- }
- return effects;
- };
- function parseInteger(value) {
- return parseInt(value, 10);
- }
- function parseCSS(element, property) {
- return parseInteger(element.css(property));
- }
- function keys(obj) {
- var acc = [];
- for (var propertyName in obj) {
- acc.push(propertyName);
- }
- return acc;
- }
- function strip3DTransforms(properties) {
- for (var key in properties) {
- if (transformProps.indexOf(key) != -1 && transform2d.indexOf(key) == -1) {
- delete properties[key];
- }
- }
- return properties;
- }
- function normalizeCSS(element, properties) {
- var transformation = [], cssValues = {}, lowerKey, key, value, isTransformed;
- for (key in properties) {
- lowerKey = key.toLowerCase();
- isTransformed = transforms && transformProps.indexOf(lowerKey) != -1;
- if (!support.hasHW3D && isTransformed && transform2d.indexOf(lowerKey) == -1) {
- delete properties[key];
- } else {
- value = properties[key];
- if (isTransformed) {
- transformation.push(key + '(' + value + ')');
- } else {
- cssValues[key] = value;
- }
- }
- }
- if (transformation.length) {
- cssValues[TRANSFORM] = transformation.join(' ');
- }
- return cssValues;
- }
- if (transitions) {
- extend(fx, {
- transition: function (element, properties, options) {
- var css, delay = 0, oldKeys = element.data('keys') || [], timeoutID;
- options = extend({
- duration: 200,
- ease: 'ease-out',
- complete: null,
- exclusive: 'all'
- }, options);
- var stopTransitionCalled = false;
- var stopTransition = function () {
- if (!stopTransitionCalled) {
- stopTransitionCalled = true;
- if (timeoutID) {
- clearTimeout(timeoutID);
- timeoutID = null;
- }
- element.removeData(ABORT_ID).dequeue().css(TRANSITION, '').css(TRANSITION);
- options.complete.call(element);
- }
- };
- options.duration = $.fx ? $.fx.speeds[options.duration] || options.duration : options.duration;
- css = normalizeCSS(element, properties);
- $.merge(oldKeys, keys(css));
- element.data('keys', $.unique(oldKeys)).height();
- element.css(TRANSITION, options.exclusive + ' ' + options.duration + 'ms ' + options.ease).css(TRANSITION);
- element.css(css).css(TRANSFORM);
- if (transitions.event) {
- element.one(transitions.event, stopTransition);
- if (options.duration !== 0) {
- delay = 500;
- }
- }
- timeoutID = setTimeout(stopTransition, options.duration + delay);
- element.data(ABORT_ID, timeoutID);
- element.data(COMPLETE_CALLBACK, stopTransition);
- },
- stopQueue: function (element, clearQueue, gotoEnd) {
- var cssValues, taskKeys = element.data('keys'), retainPosition = !gotoEnd && taskKeys, completeCallback = element.data(COMPLETE_CALLBACK);
- if (retainPosition) {
- cssValues = kendo.getComputedStyles(element[0], taskKeys);
- }
- if (completeCallback) {
- completeCallback();
- }
- if (retainPosition) {
- element.css(cssValues);
- }
- return element.removeData('keys').stop(clearQueue);
- }
- });
- }
- function animationProperty(element, property) {
- if (transforms) {
- var transform = element.css(TRANSFORM);
- if (transform == NONE) {
- return property == 'scale' ? 1 : 0;
- }
- var match = transform.match(new RegExp(property + '\\s*\\(([\\d\\w\\.]+)')), computed = 0;
- if (match) {
- computed = parseInteger(match[1]);
- } else {
- match = transform.match(matrix3dRegExp) || [
- 0,
- 0,
- 0,
- 0,
- 0
- ];
- property = property.toLowerCase();
- if (translateXRegExp.test(property)) {
- computed = parseFloat(match[3] / match[2]);
- } else if (property == 'translatey') {
- computed = parseFloat(match[4] / match[2]);
- } else if (property == 'scale') {
- computed = parseFloat(match[2]);
- } else if (property == 'rotate') {
- computed = parseFloat(Math.atan2(match[2], match[1]));
- }
- }
- return computed;
- } else {
- return parseFloat(element.css(property));
- }
- }
- var EffectSet = kendo.Class.extend({
- init: function (element, options) {
- var that = this;
- that.element = element;
- that.effects = [];
- that.options = options;
- that.restore = [];
- },
- run: function (effects) {
- var that = this, effect, idx, jdx, length = effects.length, element = that.element, options = that.options, deferred = $.Deferred(), start = {}, end = {}, target, children, childrenLength;
- that.effects = effects;
- deferred.done($.proxy(that, 'complete'));
- element.data('animating', true);
- for (idx = 0; idx < length; idx++) {
- effect = effects[idx];
- effect.setReverse(options.reverse);
- effect.setOptions(options);
- that.addRestoreProperties(effect.restore);
- effect.prepare(start, end);
- children = effect.children();
- for (jdx = 0, childrenLength = children.length; jdx < childrenLength; jdx++) {
- children[jdx].duration(options.duration).run();
- }
- }
- for (var effectName in options.effects) {
- extend(end, options.effects[effectName].properties);
- }
- if (!element.is(':visible')) {
- extend(start, { display: element.data('olddisplay') || 'block' });
- }
- if (transforms && !options.reset) {
- target = element.data('targetTransform');
- if (target) {
- start = extend(target, start);
- }
- }
- start = normalizeCSS(element, start);
- if (transforms && !transitions) {
- start = strip3DTransforms(start);
- }
- element.css(start).css(TRANSFORM);
- for (idx = 0; idx < length; idx++) {
- effects[idx].setup();
- }
- if (options.init) {
- options.init();
- }
- element.data('targetTransform', end);
- fx.animate(element, end, extend({}, options, { complete: deferred.resolve }));
- return deferred.promise();
- },
- stop: function () {
- $(this.element).kendoStop(true, true);
- },
- addRestoreProperties: function (restore) {
- var element = this.element, value, i = 0, length = restore.length;
- for (; i < length; i++) {
- value = restore[i];
- this.restore.push(value);
- if (!element.data(value)) {
- element.data(value, element.css(value));
- }
- }
- },
- restoreCallback: function () {
- var element = this.element;
- for (var i = 0, length = this.restore.length; i < length; i++) {
- var value = this.restore[i];
- element.css(value, element.data(value));
- }
- },
- complete: function () {
- var that = this, idx = 0, element = that.element, options = that.options, effects = that.effects, length = effects.length;
- element.removeData('animating').dequeue();
- if (options.hide) {
- element.data('olddisplay', element.css('display')).hide();
- }
- this.restoreCallback();
- if (hasZoom && !transforms) {
- setTimeout($.proxy(this, 'restoreCallback'), 0);
- }
- for (; idx < length; idx++) {
- effects[idx].teardown();
- }
- if (options.completeCallback) {
- options.completeCallback(element);
- }
- }
- });
- fx.promise = function (element, options) {
- var effects = [], effectClass, effectSet = new EffectSet(element, options), parsedEffects = kendo.parseEffects(options.effects), effect;
- options.effects = parsedEffects;
- for (var effectName in parsedEffects) {
- effectClass = fx[capitalize(effectName)];
- if (effectClass) {
- effect = new effectClass(element, parsedEffects[effectName].direction);
- effects.push(effect);
- }
- }
- if (effects[0]) {
- effectSet.run(effects);
- } else {
- if (!element.is(':visible')) {
- element.css({ display: element.data('olddisplay') || 'block' }).css('display');
- }
- if (options.init) {
- options.init();
- }
- element.dequeue();
- effectSet.complete();
- }
- };
- extend(fx, {
- animate: function (elements, properties, options) {
- var useTransition = options.transition !== false;
- delete options.transition;
- if (transitions && 'transition' in fx && useTransition) {
- fx.transition(elements, properties, options);
- } else {
- if (transforms) {
- elements.animate(strip3DTransforms(properties), {
- queue: false,
- show: false,
- hide: false,
- duration: options.duration,
- complete: options.complete
- });
- } else {
- elements.each(function () {
- var element = $(this), multiple = {};
- each(transformProps, function (idx, value) {
- var params, currentValue = properties ? properties[value] + ' ' : null;
- if (currentValue) {
- var single = properties;
- if (value in scaleProperties && properties[value] !== undefined) {
- params = currentValue.match(cssParamsRegExp);
- if (transforms) {
- extend(single, { scale: +params[0] });
- }
- } else {
- if (value in translateProperties && properties[value] !== undefined) {
- var position = element.css(POSITION), isFixed = position == 'absolute' || position == 'fixed';
- if (!element.data(TRANSLATE)) {
- if (isFixed) {
- element.data(TRANSLATE, {
- top: parseCSS(element, 'top') || 0,
- left: parseCSS(element, 'left') || 0,
- bottom: parseCSS(element, 'bottom'),
- right: parseCSS(element, 'right')
- });
- } else {
- element.data(TRANSLATE, {
- top: parseCSS(element, 'marginTop') || 0,
- left: parseCSS(element, 'marginLeft') || 0
- });
- }
- }
- var originalPosition = element.data(TRANSLATE);
- params = currentValue.match(cssParamsRegExp);
- if (params) {
- var dX = value == TRANSLATE + 'y' ? +null : +params[1], dY = value == TRANSLATE + 'y' ? +params[1] : +params[2];
- if (isFixed) {
- if (!isNaN(originalPosition.right)) {
- if (!isNaN(dX)) {
- extend(single, { right: originalPosition.right - dX });
- }
- } else {
- if (!isNaN(dX)) {
- extend(single, { left: originalPosition.left + dX });
- }
- }
- if (!isNaN(originalPosition.bottom)) {
- if (!isNaN(dY)) {
- extend(single, { bottom: originalPosition.bottom - dY });
- }
- } else {
- if (!isNaN(dY)) {
- extend(single, { top: originalPosition.top + dY });
- }
- }
- } else {
- if (!isNaN(dX)) {
- extend(single, { marginLeft: originalPosition.left + dX });
- }
- if (!isNaN(dY)) {
- extend(single, { marginTop: originalPosition.top + dY });
- }
- }
- }
- }
- }
- if (!transforms && value != 'scale' && value in single) {
- delete single[value];
- }
- if (single) {
- extend(multiple, single);
- }
- }
- });
- if (browser.msie) {
- delete multiple.scale;
- }
- element.animate(multiple, {
- queue: false,
- show: false,
- hide: false,
- duration: options.duration,
- complete: options.complete
- });
- });
- }
- }
- }
- });
- fx.animatedPromise = fx.promise;
- var Effect = kendo.Class.extend({
- init: function (element, direction) {
- var that = this;
- that.element = element;
- that._direction = direction;
- that.options = {};
- that._additionalEffects = [];
- if (!that.restore) {
- that.restore = [];
- }
- },
- reverse: function () {
- this._reverse = true;
- return this.run();
- },
- play: function () {
- this._reverse = false;
- return this.run();
- },
- add: function (additional) {
- this._additionalEffects.push(additional);
- return this;
- },
- direction: function (value) {
- this._direction = value;
- return this;
- },
- duration: function (duration) {
- this._duration = duration;
- return this;
- },
- compositeRun: function () {
- var that = this, effectSet = new EffectSet(that.element, {
- reverse: that._reverse,
- duration: that._duration
- }), effects = that._additionalEffects.concat([that]);
- return effectSet.run(effects);
- },
- run: function () {
- if (this._additionalEffects && this._additionalEffects[0]) {
- return this.compositeRun();
- }
- var that = this, element = that.element, idx = 0, restore = that.restore, length = restore.length, value, deferred = $.Deferred(), start = {}, end = {}, target, children = that.children(), childrenLength = children.length;
- deferred.done($.proxy(that, '_complete'));
- element.data('animating', true);
- for (idx = 0; idx < length; idx++) {
- value = restore[idx];
- if (!element.data(value)) {
- element.data(value, element.css(value));
- }
- }
- for (idx = 0; idx < childrenLength; idx++) {
- children[idx].duration(that._duration).run();
- }
- that.prepare(start, end);
- if (!element.is(':visible')) {
- extend(start, { display: element.data('olddisplay') || 'block' });
- }
- if (transforms) {
- target = element.data('targetTransform');
- if (target) {
- start = extend(target, start);
- }
- }
- start = normalizeCSS(element, start);
- if (transforms && !transitions) {
- start = strip3DTransforms(start);
- }
- element.css(start).css(TRANSFORM);
- that.setup();
- element.data('targetTransform', end);
- fx.animate(element, end, {
- duration: that._duration,
- complete: deferred.resolve
- });
- return deferred.promise();
- },
- stop: function () {
- var idx = 0, children = this.children(), childrenLength = children.length;
- for (idx = 0; idx < childrenLength; idx++) {
- children[idx].stop();
- }
- $(this.element).kendoStop(true, true);
- return this;
- },
- restoreCallback: function () {
- var element = this.element;
- for (var i = 0, length = this.restore.length; i < length; i++) {
- var value = this.restore[i];
- element.css(value, element.data(value));
- }
- },
- _complete: function () {
- var that = this, element = that.element;
- element.removeData('animating').dequeue();
- that.restoreCallback();
- if (that.shouldHide()) {
- element.data('olddisplay', element.css('display')).hide();
- }
- if (hasZoom && !transforms) {
- setTimeout($.proxy(that, 'restoreCallback'), 0);
- }
- that.teardown();
- },
- setOptions: function (options) {
- extend(true, this.options, options);
- },
- children: function () {
- return [];
- },
- shouldHide: $.noop,
- setup: $.noop,
- prepare: $.noop,
- teardown: $.noop,
- directions: [],
- setReverse: function (reverse) {
- this._reverse = reverse;
- return this;
- }
- });
- function capitalize(word) {
- return word.charAt(0).toUpperCase() + word.substring(1);
- }
- function createEffect(name, definition) {
- var effectClass = Effect.extend(definition), directions = effectClass.prototype.directions;
- fx[capitalize(name)] = effectClass;
- fx.Element.prototype[name] = function (direction, opt1, opt2, opt3) {
- return new effectClass(this.element, direction, opt1, opt2, opt3);
- };
- each(directions, function (idx, theDirection) {
- fx.Element.prototype[name + capitalize(theDirection)] = function (opt1, opt2, opt3) {
- return new effectClass(this.element, theDirection, opt1, opt2, opt3);
- };
- });
- }
- var FOUR_DIRECTIONS = [
- 'left',
- 'right',
- 'up',
- 'down'
- ], IN_OUT = [
- 'in',
- 'out'
- ];
- createEffect('slideIn', {
- directions: FOUR_DIRECTIONS,
- divisor: function (value) {
- this.options.divisor = value;
- return this;
- },
- prepare: function (start, end) {
- var that = this, tmp, element = that.element, outerWidth = kendo._outerWidth, outerHeight = kendo._outerHeight, direction = directions[that._direction], offset = -direction.modifier * (direction.vertical ? outerHeight(element) : outerWidth(element)), startValue = offset / (that.options && that.options.divisor || 1) + PX, endValue = '0px';
- if (that._reverse) {
- tmp = start;
- start = end;
- end = tmp;
- }
- if (transforms) {
- start[direction.transition] = startValue;
- end[direction.transition] = endValue;
- } else {
- start[direction.property] = startValue;
- end[direction.property] = endValue;
- }
- }
- });
- createEffect('tile', {
- directions: FOUR_DIRECTIONS,
- init: function (element, direction, previous) {
- Effect.prototype.init.call(this, element, direction);
- this.options = { previous: previous };
- },
- previousDivisor: function (value) {
- this.options.previousDivisor = value;
- return this;
- },
- children: function () {
- var that = this, reverse = that._reverse, previous = that.options.previous, divisor = that.options.previousDivisor || 1, dir = that._direction;
- var children = [kendo.fx(that.element).slideIn(dir).setReverse(reverse)];
- if (previous) {
- children.push(kendo.fx(previous).slideIn(directions[dir].reverse).divisor(divisor).setReverse(!reverse));
- }
- return children;
- }
- });
- function createToggleEffect(name, property, defaultStart, defaultEnd) {
- createEffect(name, {
- directions: IN_OUT,
- startValue: function (value) {
- this._startValue = value;
- return this;
- },
- endValue: function (value) {
- this._endValue = value;
- return this;
- },
- shouldHide: function () {
- return this._shouldHide;
- },
- prepare: function (start, end) {
- var that = this, startValue, endValue, out = this._direction === 'out', startDataValue = that.element.data(property), startDataValueIsSet = !(isNaN(startDataValue) || startDataValue == defaultStart);
- if (startDataValueIsSet) {
- startValue = startDataValue;
- } else if (typeof this._startValue !== 'undefined') {
- startValue = this._startValue;
- } else {
- startValue = out ? defaultStart : defaultEnd;
- }
- if (typeof this._endValue !== 'undefined') {
- endValue = this._endValue;
- } else {
- endValue = out ? defaultEnd : defaultStart;
- }
- if (this._reverse) {
- start[property] = endValue;
- end[property] = startValue;
- } else {
- start[property] = startValue;
- end[property] = endValue;
- }
- that._shouldHide = end[property] === defaultEnd;
- }
- });
- }
- createToggleEffect('fade', 'opacity', 1, 0);
- createToggleEffect('zoom', 'scale', 1, 0.01);
- createEffect('slideMargin', {
- prepare: function (start, end) {
- var that = this, element = that.element, options = that.options, origin = element.data(ORIGIN), offset = options.offset, margin, reverse = that._reverse;
- if (!reverse && origin === null) {
- element.data(ORIGIN, parseFloat(element.css('margin-' + options.axis)));
- }
- margin = element.data(ORIGIN) || 0;
- end['margin-' + options.axis] = !reverse ? margin + offset : margin;
- }
- });
- createEffect('slideTo', {
- prepare: function (start, end) {
- var that = this, element = that.element, options = that.options, offset = options.offset.split(','), reverse = that._reverse;
- if (transforms) {
- end.translatex = !reverse ? offset[0] : 0;
- end.translatey = !reverse ? offset[1] : 0;
- } else {
- end.left = !reverse ? offset[0] : 0;
- end.top = !reverse ? offset[1] : 0;
- }
- element.css('left');
- }
- });
- createEffect('expand', {
- directions: [
- 'horizontal',
- 'vertical'
- ],
- restore: [OVERFLOW],
- prepare: function (start, end) {
- var that = this, element = that.element, options = that.options, reverse = that._reverse, property = that._direction === 'vertical' ? HEIGHT : WIDTH, setLength = element[0].style[property], oldLength = element.data(property), length = parseFloat(oldLength || setLength), realLength = round(element.css(property, AUTO)[property]());
- start.overflow = HIDDEN;
- length = options && options.reset ? realLength || length : length || realLength;
- end[property] = (reverse ? 0 : length) + PX;
- start[property] = (reverse ? length : 0) + PX;
- if (oldLength === undefined) {
- element.data(property, setLength);
- }
- },
- shouldHide: function () {
- return this._reverse;
- },
- teardown: function () {
- var that = this, element = that.element, property = that._direction === 'vertical' ? HEIGHT : WIDTH, length = element.data(property);
- if (length == AUTO || length === BLANK) {
- setTimeout(function () {
- element.css(property, AUTO).css(property);
- }, 0);
- }
- }
- });
- var TRANSFER_START_STATE = {
- position: 'absolute',
- marginLeft: 0,
- marginTop: 0,
- scale: 1
- };
- createEffect('transfer', {
- init: function (element, target) {
- this.element = element;
- this.options = { target: target };
- this.restore = [];
- },
- setup: function () {
- this.element.appendTo(document.body);
- },
- prepare: function (start, end) {
- var that = this, element = that.element, outerBox = fx.box(element), innerBox = fx.box(that.options.target), currentScale = animationProperty(element, 'scale'), scale = fx.fillScale(innerBox, outerBox), transformOrigin = fx.transformOrigin(innerBox, outerBox);
- extend(start, TRANSFER_START_STATE);
- end.scale = 1;
- element.css(TRANSFORM, 'scale(1)').css(TRANSFORM);
- element.css(TRANSFORM, 'scale(' + currentScale + ')');
- start.top = outerBox.top;
- start.left = outerBox.left;
- start.transformOrigin = transformOrigin.x + PX + ' ' + transformOrigin.y + PX;
- if (that._reverse) {
- start.scale = scale;
- } else {
- end.scale = scale;
- }
- }
- });
- var CLIPS = {
- top: 'rect(auto auto $size auto)',
- bottom: 'rect($size auto auto auto)',
- left: 'rect(auto $size auto auto)',
- right: 'rect(auto auto auto $size)'
- };
- var ROTATIONS = {
- top: {
- start: 'rotatex(0deg)',
- end: 'rotatex(180deg)'
- },
- bottom: {
- start: 'rotatex(-180deg)',
- end: 'rotatex(0deg)'
- },
- left: {
- start: 'rotatey(0deg)',
- end: 'rotatey(-180deg)'
- },
- right: {
- start: 'rotatey(180deg)',
- end: 'rotatey(0deg)'
- }
- };
- function clipInHalf(container, direction) {
- var vertical = kendo.directions[direction].vertical, size = container[vertical ? HEIGHT : WIDTH]() / 2 + 'px';
- return CLIPS[direction].replace('$size', size);
- }
- createEffect('turningPage', {
- directions: FOUR_DIRECTIONS,
- init: function (element, direction, container) {
- Effect.prototype.init.call(this, element, direction);
- this._container = container;
- },
- prepare: function (start, end) {
- var that = this, reverse = that._reverse, direction = reverse ? directions[that._direction].reverse : that._direction, rotation = ROTATIONS[direction];
- start.zIndex = 1;
- if (that._clipInHalf) {
- start.clip = clipInHalf(that._container, kendo.directions[direction].reverse);
- }
- start[BACKFACE] = HIDDEN;
- end[TRANSFORM] = TRANSFORM_PERSPECTIVE + (reverse ? rotation.start : rotation.end);
- start[TRANSFORM] = TRANSFORM_PERSPECTIVE + (reverse ? rotation.end : rotation.start);
- },
- setup: function () {
- this._container.append(this.element);
- },
- face: function (value) {
- this._face = value;
- return this;
- },
- shouldHide: function () {
- var that = this, reverse = that._reverse, face = that._face;
- return reverse && !face || !reverse && face;
- },
- clipInHalf: function (value) {
- this._clipInHalf = value;
- return this;
- },
- temporary: function () {
- this.element.addClass('temp-page');
- return this;
- }
- });
- createEffect('staticPage', {
- directions: FOUR_DIRECTIONS,
- init: function (element, direction, container) {
- Effect.prototype.init.call(this, element, direction);
- this._container = container;
- },
- restore: ['clip'],
- prepare: function (start, end) {
- var that = this, direction = that._reverse ? directions[that._direction].reverse : that._direction;
- start.clip = clipInHalf(that._container, direction);
- start.opacity = 0.999;
- end.opacity = 1;
- },
- shouldHide: function () {
- var that = this, reverse = that._reverse, face = that._face;
- return reverse && !face || !reverse && face;
- },
- face: function (value) {
- this._face = value;
- return this;
- }
- });
- createEffect('pageturn', {
- directions: [
- 'horizontal',
- 'vertical'
- ],
- init: function (element, direction, face, back) {
- Effect.prototype.init.call(this, element, direction);
- this.options = {};
- this.options.face = face;
- this.options.back = back;
- },
- children: function () {
- var that = this, options = that.options, direction = that._direction === 'horizontal' ? 'left' : 'top', reverseDirection = kendo.directions[direction].reverse, reverse = that._reverse, temp, faceClone = options.face.clone(true).removeAttr('id'), backClone = options.back.clone(true).removeAttr('id'), element = that.element;
- if (reverse) {
- temp = direction;
- direction = reverseDirection;
- reverseDirection = temp;
- }
- return [
- kendo.fx(options.face).staticPage(direction, element).face(true).setReverse(reverse),
- kendo.fx(options.back).staticPage(reverseDirection, element).setReverse(reverse),
- kendo.fx(faceClone).turningPage(direction, element).face(true).clipInHalf(true).temporary().setReverse(reverse),
- kendo.fx(backClone).turningPage(reverseDirection, element).clipInHalf(true).temporary().setReverse(reverse)
- ];
- },
- prepare: function (start, end) {
- start[PERSPECTIVE] = DEFAULT_PERSPECTIVE;
- start.transformStyle = 'preserve-3d';
- start.opacity = 0.999;
- end.opacity = 1;
- },
- teardown: function () {
- this.element.find('.temp-page').remove();
- }
- });
- createEffect('flip', {
- directions: [
- 'horizontal',
- 'vertical'
- ],
- init: function (element, direction, face, back) {
- Effect.prototype.init.call(this, element, direction);
- this.options = {};
- this.options.face = face;
- this.options.back = back;
- },
- children: function () {
- var that = this, options = that.options, direction = that._direction === 'horizontal' ? 'left' : 'top', reverseDirection = kendo.directions[direction].reverse, reverse = that._reverse, temp, element = that.element;
- if (reverse) {
- temp = direction;
- direction = reverseDirection;
- reverseDirection = temp;
- }
- return [
- kendo.fx(options.face).turningPage(direction, element).face(true).setReverse(reverse),
- kendo.fx(options.back).turningPage(reverseDirection, element).setReverse(reverse)
- ];
- },
- prepare: function (start) {
- start[PERSPECTIVE] = DEFAULT_PERSPECTIVE;
- start.transformStyle = 'preserve-3d';
- }
- });
- var RESTORE_OVERFLOW = !support.mobileOS.android;
- var IGNORE_TRANSITION_EVENT_SELECTOR = '.km-touch-scrollbar, .km-actionsheet-wrapper';
- createEffect('replace', {
- _before: $.noop,
- _after: $.noop,
- init: function (element, previous, transitionClass) {
- Effect.prototype.init.call(this, element);
- this._previous = $(previous);
- this._transitionClass = transitionClass;
- },
- duration: function () {
- throw new Error('The replace effect does not support duration setting; the effect duration may be customized through the transition class rule');
- },
- beforeTransition: function (callback) {
- this._before = callback;
- return this;
- },
- afterTransition: function (callback) {
- this._after = callback;
- return this;
- },
- _both: function () {
- return $().add(this._element).add(this._previous);
- },
- _containerClass: function () {
- var direction = this._direction, containerClass = 'k-fx k-fx-start k-fx-' + this._transitionClass;
- if (direction) {
- containerClass += ' k-fx-' + direction;
- }
- if (this._reverse) {
- containerClass += ' k-fx-reverse';
- }
- return containerClass;
- },
- complete: function (e) {
- if (!this.deferred || e && $(e.target).is(IGNORE_TRANSITION_EVENT_SELECTOR)) {
- return;
- }
- var container = this.container;
- container.removeClass('k-fx-end').removeClass(this._containerClass()).off(transitions.event, this.completeProxy);
- this._previous.hide().removeClass('k-fx-current');
- this.element.removeClass('k-fx-next');
- if (RESTORE_OVERFLOW) {
- container.css(OVERFLOW, '');
- }
- if (!this.isAbsolute) {
- this._both().css(POSITION, '');
- }
- this.deferred.resolve();
- delete this.deferred;
- },
- run: function () {
- if (this._additionalEffects && this._additionalEffects[0]) {
- return this.compositeRun();
- }
- var that = this, element = that.element, previous = that._previous, container = element.parents().filter(previous.parents()).first(), both = that._both(), deferred = $.Deferred(), originalPosition = element.css(POSITION), originalOverflow;
- if (!container.length) {
- container = element.parent();
- }
- this.container = container;
- this.deferred = deferred;
- this.isAbsolute = originalPosition == 'absolute';
- if (!this.isAbsolute) {
- both.css(POSITION, 'absolute');
- }
- if (RESTORE_OVERFLOW) {
- originalOverflow = container.css(OVERFLOW);
- container.css(OVERFLOW, 'hidden');
- }
- if (!transitions) {
- this.complete();
- } else {
- element.addClass('k-fx-hidden');
- container.addClass(this._containerClass());
- this.completeProxy = $.proxy(this, 'complete');
- container.on(transitions.event, this.completeProxy);
- kendo.animationFrame(function () {
- element.removeClass('k-fx-hidden').addClass('k-fx-next');
- previous.css('display', '').addClass('k-fx-current');
- that._before(previous, element);
- kendo.animationFrame(function () {
- container.removeClass('k-fx-start').addClass('k-fx-end');
- that._after(previous, element);
- });
- });
- }
- return deferred.promise();
- },
- stop: function () {
- this.complete();
- }
- });
- var Animation = kendo.Class.extend({
- init: function () {
- var that = this;
- that._tickProxy = proxy(that._tick, that);
- that._started = false;
- },
- tick: $.noop,
- done: $.noop,
- onEnd: $.noop,
- onCancel: $.noop,
- start: function () {
- if (!this.enabled()) {
- return;
- }
- if (!this.done()) {
- this._started = true;
- kendo.animationFrame(this._tickProxy);
- } else {
- this.onEnd();
- }
- },
- enabled: function () {
- return true;
- },
- cancel: function () {
- this._started = false;
- this.onCancel();
- },
- _tick: function () {
- var that = this;
- if (!that._started) {
- return;
- }
- that.tick();
- if (!that.done()) {
- kendo.animationFrame(that._tickProxy);
- } else {
- that._started = false;
- that.onEnd();
- }
- }
- });
- var Transition = Animation.extend({
- init: function (options) {
- var that = this;
- extend(that, options);
- Animation.fn.init.call(that);
- },
- done: function () {
- return this.timePassed() >= this.duration;
- },
- timePassed: function () {
- return Math.min(this.duration, new Date() - this.startDate);
- },
- moveTo: function (options) {
- var that = this, movable = that.movable;
- that.initial = movable[that.axis];
- that.delta = options.location - that.initial;
- that.duration = typeof options.duration == 'number' ? options.duration : 300;
- that.tick = that._easeProxy(options.ease);
- that.startDate = new Date();
- that.start();
- },
- _easeProxy: function (ease) {
- var that = this;
- return function () {
- that.movable.moveAxis(that.axis, ease(that.timePassed(), that.initial, that.delta, that.duration));
- };
- }
- });
- extend(Transition, {
- easeOutExpo: function (t, b, c, d) {
- return t == d ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
- },
- easeOutBack: function (t, b, c, d, s) {
- s = 1.70158;
- return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
- }
- });
- fx.Animation = Animation;
- fx.Transition = Transition;
- fx.createEffect = createEffect;
- fx.box = function (element) {
- element = $(element);
- var result = element.offset();
- result.width = kendo._outerWidth(element);
- result.height = kendo._outerHeight(element);
- return result;
- };
- fx.transformOrigin = function (inner, outer) {
- var x = (inner.left - outer.left) * outer.width / (outer.width - inner.width), y = (inner.top - outer.top) * outer.height / (outer.height - inner.height);
- return {
- x: isNaN(x) ? 0 : x,
- y: isNaN(y) ? 0 : y
- };
- };
- fx.fillScale = function (inner, outer) {
- return Math.min(inner.width / outer.width, inner.height / outer.height);
- };
- fx.fitScale = function (inner, outer) {
- return Math.max(inner.width / outer.width, inner.height / outer.height);
- };
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.userevents', ['kendo.core'], f);
-}(function () {
- var __meta__ = {
- id: 'userevents',
- name: 'User Events',
- category: 'framework',
- depends: ['core'],
- hidden: true
- };
- (function ($, undefined) {
- var kendo = window.kendo, support = kendo.support, Class = kendo.Class, Observable = kendo.Observable, now = $.now, extend = $.extend, OS = support.mobileOS, invalidZeroEvents = OS && OS.android, DEFAULT_MIN_HOLD = 800, CLICK_DELAY = 300, DEFAULT_THRESHOLD = support.browser.msie ? 5 : 0, PRESS = 'press', HOLD = 'hold', SELECT = 'select', START = 'start', MOVE = 'move', END = 'end', CANCEL = 'cancel', TAP = 'tap', DOUBLETAP = 'doubleTap', RELEASE = 'release', GESTURESTART = 'gesturestart', GESTURECHANGE = 'gesturechange', GESTUREEND = 'gestureend', GESTURETAP = 'gesturetap';
- var THRESHOLD = {
- 'api': 0,
- 'touch': 0,
- 'mouse': 9,
- 'pointer': 9
- };
- var ENABLE_GLOBAL_SURFACE = !support.touch || support.mouseAndTouchPresent;
- function touchDelta(touch1, touch2) {
- var x1 = touch1.x.location, y1 = touch1.y.location, x2 = touch2.x.location, y2 = touch2.y.location, dx = x1 - x2, dy = y1 - y2;
- return {
- center: {
- x: (x1 + x2) / 2,
- y: (y1 + y2) / 2
- },
- distance: Math.sqrt(dx * dx + dy * dy)
- };
- }
- function getTouches(e) {
- var touches = [], originalEvent = e.originalEvent, currentTarget = e.currentTarget, idx = 0, length, changedTouches, touch;
- if (e.api) {
- touches.push({
- id: 2,
- event: e,
- target: e.target,
- currentTarget: e.target,
- location: e,
- type: 'api'
- });
- } else if (e.type.match(/touch/)) {
- changedTouches = originalEvent ? originalEvent.changedTouches : [];
- for (length = changedTouches.length; idx < length; idx++) {
- touch = changedTouches[idx];
- touches.push({
- location: touch,
- event: e,
- target: touch.target,
- currentTarget: currentTarget,
- id: touch.identifier,
- type: 'touch'
- });
- }
- } else if (support.pointers || support.msPointers) {
- touches.push({
- location: originalEvent,
- event: e,
- target: e.target,
- currentTarget: currentTarget,
- id: originalEvent.pointerId,
- type: 'pointer'
- });
- } else {
- touches.push({
- id: 1,
- event: e,
- target: e.target,
- currentTarget: currentTarget,
- location: e,
- type: 'mouse'
- });
- }
- return touches;
- }
- var TouchAxis = Class.extend({
- init: function (axis, location) {
- var that = this;
- that.axis = axis;
- that._updateLocationData(location);
- that.startLocation = that.location;
- that.velocity = that.delta = 0;
- that.timeStamp = now();
- },
- move: function (location) {
- var that = this, offset = location['page' + that.axis], timeStamp = now(), timeDelta = timeStamp - that.timeStamp || 1;
- if (!offset && invalidZeroEvents) {
- return;
- }
- that.delta = offset - that.location;
- that._updateLocationData(location);
- that.initialDelta = offset - that.startLocation;
- that.velocity = that.delta / timeDelta;
- that.timeStamp = timeStamp;
- },
- _updateLocationData: function (location) {
- var that = this, axis = that.axis;
- that.location = location['page' + axis];
- that.client = location['client' + axis];
- that.screen = location['screen' + axis];
- }
- });
- var Touch = Class.extend({
- init: function (userEvents, target, touchInfo) {
- extend(this, {
- x: new TouchAxis('X', touchInfo.location),
- y: new TouchAxis('Y', touchInfo.location),
- type: touchInfo.type,
- useClickAsTap: userEvents.useClickAsTap,
- threshold: userEvents.threshold || THRESHOLD[touchInfo.type],
- userEvents: userEvents,
- target: target,
- currentTarget: touchInfo.currentTarget,
- initialTouch: touchInfo.target,
- id: touchInfo.id,
- pressEvent: touchInfo,
- _clicks: userEvents._clicks,
- supportDoubleTap: userEvents.supportDoubleTap,
- _moved: false,
- _finished: false
- });
- },
- press: function () {
- this._holdTimeout = setTimeout($.proxy(this, '_hold'), this.userEvents.minHold);
- this._trigger(PRESS, this.pressEvent);
- },
- _tap: function (touchInfo) {
- var that = this;
- that.userEvents._clicks++;
- if (that.userEvents._clicks == 1) {
- that._clickTimeout = setTimeout(function () {
- if (that.userEvents._clicks == 1) {
- that._trigger(TAP, touchInfo);
- } else {
- that._trigger(DOUBLETAP, touchInfo);
- }
- that.userEvents._clicks = 0;
- }, CLICK_DELAY);
- }
- },
- _hold: function () {
- this._trigger(HOLD, this.pressEvent);
- },
- move: function (touchInfo) {
- var that = this;
- if (that._finished) {
- return;
- }
- that.x.move(touchInfo.location);
- that.y.move(touchInfo.location);
- if (!that._moved) {
- if (that._withinIgnoreThreshold()) {
- return;
- }
- if (!UserEvents.current || UserEvents.current === that.userEvents) {
- that._start(touchInfo);
- } else {
- return that.dispose();
- }
- }
- if (!that._finished) {
- that._trigger(MOVE, touchInfo);
- }
- },
- end: function (touchInfo) {
- this.endTime = now();
- if (this._finished) {
- return;
- }
- this._finished = true;
- this._trigger(RELEASE, touchInfo);
- if (this._moved) {
- this._trigger(END, touchInfo);
- } else {
- if (!this.useClickAsTap) {
- if (this.supportDoubleTap) {
- this._tap(touchInfo);
- } else {
- this._trigger(TAP, touchInfo);
- }
- }
- }
- clearTimeout(this._holdTimeout);
- this.dispose();
- },
- dispose: function () {
- var userEvents = this.userEvents, activeTouches = userEvents.touches;
- this._finished = true;
- this.pressEvent = null;
- clearTimeout(this._holdTimeout);
- activeTouches.splice($.inArray(this, activeTouches), 1);
- },
- skip: function () {
- this.dispose();
- },
- cancel: function () {
- this.dispose();
- },
- isMoved: function () {
- return this._moved;
- },
- _start: function (touchInfo) {
- clearTimeout(this._holdTimeout);
- this.startTime = now();
- this._moved = true;
- this._trigger(START, touchInfo);
- },
- _trigger: function (name, touchInfo) {
- var that = this, jQueryEvent = touchInfo.event, data = {
- touch: that,
- x: that.x,
- y: that.y,
- target: that.target,
- event: jQueryEvent
- };
- if (that.userEvents.notify(name, data)) {
- jQueryEvent.preventDefault();
- }
- },
- _withinIgnoreThreshold: function () {
- var xDelta = this.x.initialDelta, yDelta = this.y.initialDelta;
- return Math.sqrt(xDelta * xDelta + yDelta * yDelta) <= this.threshold;
- }
- });
- function withEachUpEvent(callback) {
- var downEvents = kendo.eventMap.up.split(' '), idx = 0, length = downEvents.length;
- for (; idx < length; idx++) {
- callback(downEvents[idx]);
- }
- }
- var UserEvents = Observable.extend({
- init: function (element, options) {
- var that = this, filter, ns = kendo.guid();
- options = options || {};
- filter = that.filter = options.filter;
- that.threshold = options.threshold || DEFAULT_THRESHOLD;
- that.minHold = options.minHold || DEFAULT_MIN_HOLD;
- that.touches = [];
- that._maxTouches = options.multiTouch ? 2 : 1;
- that.allowSelection = options.allowSelection;
- that.captureUpIfMoved = options.captureUpIfMoved;
- that.useClickAsTap = !options.fastTap && !support.delayedClick();
- that.eventNS = ns;
- that._clicks = 0;
- that.supportDoubleTap = options.supportDoubleTap;
- element = $(element).handler(that);
- Observable.fn.init.call(that);
- extend(that, {
- element: element,
- surface: options.global && ENABLE_GLOBAL_SURFACE ? $(element[0].ownerDocument.documentElement) : $(options.surface || element),
- stopPropagation: options.stopPropagation,
- pressed: false
- });
- that.surface.handler(that).on(kendo.applyEventMap('move', ns), '_move').on(kendo.applyEventMap('up cancel', ns), '_end');
- element.on(kendo.applyEventMap('down', ns), filter, '_start');
- if (that.useClickAsTap) {
- element.on(kendo.applyEventMap('click', ns), filter, '_click');
- }
- if (support.pointers || support.msPointers) {
- if (support.browser.version < 11) {
- var defaultAction = 'pinch-zoom double-tap-zoom';
- element.css('-ms-touch-action', options.touchAction && options.touchAction != 'none' ? defaultAction + ' ' + options.touchAction : defaultAction);
- } else {
- element.css('touch-action', options.touchAction || 'none');
- }
- }
- if (options.preventDragEvent) {
- element.on(kendo.applyEventMap('dragstart', ns), kendo.preventDefault);
- }
- element.on(kendo.applyEventMap('mousedown', ns), filter, { root: element }, '_select');
- if (that.captureUpIfMoved && support.eventCapture) {
- var surfaceElement = that.surface[0], preventIfMovingProxy = $.proxy(that.preventIfMoving, that);
- withEachUpEvent(function (eventName) {
- surfaceElement.addEventListener(eventName, preventIfMovingProxy, true);
- });
- }
- that.bind([
- PRESS,
- HOLD,
- TAP,
- DOUBLETAP,
- START,
- MOVE,
- END,
- RELEASE,
- CANCEL,
- GESTURESTART,
- GESTURECHANGE,
- GESTUREEND,
- GESTURETAP,
- SELECT
- ], options);
- },
- preventIfMoving: function (e) {
- if (this._isMoved()) {
- e.preventDefault();
- }
- },
- destroy: function () {
- var that = this;
- if (that._destroyed) {
- return;
- }
- that._destroyed = true;
- if (that.captureUpIfMoved && support.eventCapture) {
- var surfaceElement = that.surface[0];
- withEachUpEvent(function (eventName) {
- surfaceElement.removeEventListener(eventName, that.preventIfMoving);
- });
- }
- that.element.kendoDestroy(that.eventNS);
- that.surface.kendoDestroy(that.eventNS);
- that.element.removeData('handler');
- that.surface.removeData('handler');
- that._disposeAll();
- that.unbind();
- delete that.surface;
- delete that.element;
- delete that.currentTarget;
- },
- capture: function () {
- UserEvents.current = this;
- },
- cancel: function () {
- this._disposeAll();
- this.trigger(CANCEL);
- },
- notify: function (eventName, data) {
- var that = this, touches = that.touches;
- if (this._isMultiTouch()) {
- switch (eventName) {
- case MOVE:
- eventName = GESTURECHANGE;
- break;
- case END:
- eventName = GESTUREEND;
- break;
- case TAP:
- eventName = GESTURETAP;
- break;
- }
- extend(data, { touches: touches }, touchDelta(touches[0], touches[1]));
- }
- return this.trigger(eventName, extend(data, { type: eventName }));
- },
- press: function (x, y, target) {
- this._apiCall('_start', x, y, target);
- },
- move: function (x, y) {
- this._apiCall('_move', x, y);
- },
- end: function (x, y) {
- this._apiCall('_end', x, y);
- },
- _isMultiTouch: function () {
- return this.touches.length > 1;
- },
- _maxTouchesReached: function () {
- return this.touches.length >= this._maxTouches;
- },
- _disposeAll: function () {
- var touches = this.touches;
- while (touches.length > 0) {
- touches.pop().dispose();
- }
- },
- _isMoved: function () {
- return $.grep(this.touches, function (touch) {
- return touch.isMoved();
- }).length;
- },
- _select: function (e) {
- if (!this.allowSelection || this.trigger(SELECT, { event: e })) {
- e.preventDefault();
- }
- },
- _start: function (e) {
- var that = this, idx = 0, filter = that.filter, target, touches = getTouches(e), length = touches.length, touch, which = e.which;
- if (which && which > 1 || that._maxTouchesReached()) {
- return;
- }
- UserEvents.current = null;
- that.currentTarget = e.currentTarget;
- if (that.stopPropagation) {
- e.stopPropagation();
- }
- for (; idx < length; idx++) {
- if (that._maxTouchesReached()) {
- break;
- }
- touch = touches[idx];
- if (filter) {
- target = $(touch.currentTarget);
- } else {
- target = that.element;
- }
- if (!target.length) {
- continue;
- }
- touch = new Touch(that, target, touch);
- that.touches.push(touch);
- touch.press();
- if (that._isMultiTouch()) {
- that.notify('gesturestart', {});
- }
- }
- },
- _move: function (e) {
- this._eachTouch('move', e);
- },
- _end: function (e) {
- this._eachTouch('end', e);
- },
- _click: function (e) {
- var data = {
- touch: {
- initialTouch: e.target,
- target: $(e.currentTarget),
- endTime: now(),
- x: {
- location: e.pageX,
- client: e.clientX
- },
- y: {
- location: e.pageY,
- client: e.clientY
- }
- },
- x: e.pageX,
- y: e.pageY,
- target: $(e.currentTarget),
- event: e,
- type: 'tap'
- };
- if (this.trigger('tap', data)) {
- e.preventDefault();
- }
- },
- _eachTouch: function (methodName, e) {
- var that = this, dict = {}, touches = getTouches(e), activeTouches = that.touches, idx, touch, touchInfo, matchingTouch;
- for (idx = 0; idx < activeTouches.length; idx++) {
- touch = activeTouches[idx];
- dict[touch.id] = touch;
- }
- for (idx = 0; idx < touches.length; idx++) {
- touchInfo = touches[idx];
- matchingTouch = dict[touchInfo.id];
- if (matchingTouch) {
- matchingTouch[methodName](touchInfo);
- }
- }
- },
- _apiCall: function (type, x, y, target) {
- this[type]({
- api: true,
- pageX: x,
- pageY: y,
- clientX: x,
- clientY: y,
- target: $(target || this.element)[0],
- stopPropagation: $.noop,
- preventDefault: $.noop
- });
- }
- });
- UserEvents.defaultThreshold = function (value) {
- DEFAULT_THRESHOLD = value;
- };
- UserEvents.minHold = function (value) {
- DEFAULT_MIN_HOLD = value;
- };
- kendo.getTouches = getTouches;
- kendo.touchDelta = touchDelta;
- kendo.UserEvents = UserEvents;
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.menu', ['kendo.popup'], f);
-}(function () {
- var __meta__ = {
- id: 'menu',
- name: 'Menu',
- category: 'web',
- description: 'The Menu widget displays hierarchical data as a multi-level menu.',
- depends: ['popup']
- };
- (function ($, undefined) {
- var kendo = window.kendo, ui = kendo.ui, activeElement = kendo._activeElement, touch = kendo.support.touch && kendo.support.mobileOS, MOUSEDOWN = 'mousedown', CLICK = 'click', DELAY = 30, SCROLLSPEED = 50, extend = $.extend, proxy = $.proxy, each = $.each, template = kendo.template, keys = kendo.keys, Widget = ui.Widget, excludedNodesRegExp = /^(ul|a|div)$/i, NS = '.kendoMenu', IMG = 'img', OPEN = 'open', MENU = 'k-menu', LINK = 'k-link k-menu-link', LINK_SELECTOR = '.k-link', LAST = 'k-last', CLOSE = 'close', TIMER = 'timer', FIRST = 'k-first', IMAGE = 'k-image', SELECT = 'select', ZINDEX = 'zIndex', ACTIVATE = 'activate', DEACTIVATE = 'deactivate', POINTERDOWN = 'touchstart' + NS + ' MSPointerDown' + NS + ' pointerdown' + NS, pointers = kendo.support.pointers, msPointers = kendo.support.msPointers, allPointers = msPointers || pointers, TOUCHSTART = kendo.support.touch ? 'touchstart' : '', MOUSEENTER = pointers ? 'pointerover' : msPointers ? 'MSPointerOver' : 'mouseenter', MOUSELEAVE = pointers ? 'pointerout' : msPointers ? 'MSPointerOut' : 'mouseleave', MOUSEWHEEL = 'DOMMouseScroll' + NS + ' mousewheel' + NS, RESIZE = kendo.support.resize + NS, SCROLLWIDTH = 'scrollWidth', SCROLLHEIGHT = 'scrollHeight', OFFSETWIDTH = 'offsetWidth', OFFSETHEIGHT = 'offsetHeight', POPUP_ID_ATTR = 'group', POPUP_OPENER_ATTR = 'groupparent', DOCUMENT_ELEMENT = $(document.documentElement), KENDOPOPUP = 'kendoPopup', DEFAULTSTATE = 'k-state-default', HOVERSTATE = 'k-state-hover', FOCUSEDSTATE = 'k-state-focused', DISABLEDSTATE = 'k-state-disabled', SELECTEDSTATE = 'k-state-selected', menuSelector = '.k-menu', groupSelector = '.k-menu-group', animationContainerSelector = '.k-animation-container', popupSelector = groupSelector + ',' + animationContainerSelector, allItemsSelector = ':not(.k-list) > .k-item', disabledSelector = '.k-item.k-state-disabled', itemSelector = '.k-item', availableItemsSelector = '.k-item:not(.k-state-disabled)', linkSelector = '.k-item:not(.k-state-disabled) > .k-link', exclusionSelector = ':not(.k-item.k-separator)', nextSelector = itemSelector + exclusionSelector + ':eq(0)', lastSelector = itemSelector + exclusionSelector + ':last', templateSelector = 'div:not(.k-animation-container,.k-list-container)', scrollButtonSelector = '.k-menu-scroll-button', touchPointerTypes = {
- '2': 1,
- 'touch': 1
- }, templates = {
- content: template('
#= content(item) #
'),
- group: template('
' + '#= renderItems(data) #' + '
'),
- itemWrapper: template('<#= tag(item) # class=\'#= textClass(item) #\'#= textAttributes(item) #>' + '#= image(data) ##= sprite(item) ##= text(item) #' + '#= arrow(data) #' + '#= tag(item) #>'),
- item: template('
' + '#= itemWrapper(data) #' + '# if (item.items) { #' + '#= subGroup({ items: item.items, menu: menu, group: { expanded: item.expanded } }) #' + '# } else if (item.content || item.contentUrl) { #' + '#= renderContent(data) #' + '# } #' + ''),
- scrollButton: template('
' + ''),
- image: template('
'),
- arrow: template('
'),
- sprite: template('
'),
- empty: template('')
- }, rendering = {
- wrapperCssClass: function (group, item) {
- var result = 'k-item', index = item.index;
- if (item.enabled === false) {
- result += ' k-state-disabled';
- } else {
- result += ' k-state-default';
- }
- if (group.firstLevel && index === 0) {
- result += ' k-first';
- }
- if (index == group.length - 1) {
- result += ' k-last';
- }
- if (item.cssClass) {
- result += ' ' + item.cssClass;
- }
- if (item.attr && item.attr.hasOwnProperty('class')) {
- result += ' ' + item.attr['class'];
- }
- if (item.selected) {
- result += ' ' + SELECTEDSTATE;
- }
- return result;
- },
- itemCssAttributes: function (item) {
- var result = '';
- var attributes = item.attr || {};
- for (var attr in attributes) {
- if (attributes.hasOwnProperty(attr) && attr !== 'class') {
- result += attr + '="' + attributes[attr] + '" ';
- }
- }
- return result;
- },
- imageCssAttributes: function (item) {
- var result = '';
- var attributes = item.imageAttr || {};
- if (!attributes['class']) {
- attributes['class'] = IMAGE;
- } else {
- attributes['class'] += ' ' + IMAGE;
- }
- for (var attr in attributes) {
- if (attributes.hasOwnProperty(attr)) {
- result += attr + '="' + attributes[attr] + '" ';
- }
- }
- return result;
- },
- contentCssAttributes: function (item) {
- var result = '';
- var attributes = item.contentAttr || {};
- var defaultClasses = 'k-content k-group k-menu-group';
- if (!attributes['class']) {
- attributes['class'] = defaultClasses;
- } else {
- attributes['class'] += ' ' + defaultClasses;
- }
- for (var attr in attributes) {
- if (attributes.hasOwnProperty(attr)) {
- result += attr + '="' + attributes[attr] + '" ';
- }
- }
- return result;
- },
- textClass: function () {
- return LINK;
- },
- textAttributes: function (item) {
- return item.url ? ' href=\'' + item.url + '\'' : '';
- },
- arrowClass: function (item, group) {
- var result = 'k-icon';
- if (group.horizontal) {
- result += ' k-i-arrow-60-down';
- } else {
- result += ' k-i-arrow-60-right';
- }
- return result;
- },
- text: function (item) {
- return item.encoded === false ? item.text : kendo.htmlEncode(item.text);
- },
- tag: function (item) {
- return item.url ? 'a' : 'span';
- },
- groupAttributes: function (group) {
- return group.expanded !== true ? ' style=\'display:none\'' : '';
- },
- groupCssClass: function () {
- return 'k-group k-menu-group';
- },
- content: function (item) {
- return item.content ? item.content : ' ';
- }
- };
- function getEffectDirection(direction, root) {
- direction = direction.split(' ')[!root + 0] || direction;
- return direction.replace('top', 'up').replace('bottom', 'down');
- }
- function parseDirection(direction, root, isRtl) {
- direction = direction.split(' ')[!root + 0] || direction;
- var output = {
- origin: [
- 'bottom',
- isRtl ? 'right' : 'left'
- ],
- position: [
- 'top',
- isRtl ? 'right' : 'left'
- ]
- }, horizontal = /left|right/.test(direction);
- if (horizontal) {
- output.origin = [
- 'top',
- direction
- ];
- output.position[1] = kendo.directions[direction].reverse;
- } else {
- output.origin[0] = direction;
- output.position[0] = kendo.directions[direction].reverse;
- }
- output.origin = output.origin.join(' ');
- output.position = output.position.join(' ');
- return output;
- }
- function contains(parent, child) {
- try {
- return $.contains(parent, child);
- } catch (e) {
- return false;
- }
- }
- function updateItemClasses(item) {
- item = $(item);
- item.addClass('k-item').children(IMG).addClass(IMAGE);
- item.children('a').addClass(LINK).children(IMG).addClass(IMAGE);
- item.filter(':not([disabled])').addClass(DEFAULTSTATE);
- item.filter('.k-separator').empty().append(' ');
- item.filter('li[disabled]').addClass(DISABLEDSTATE).removeAttr('disabled').attr('aria-disabled', true);
- if (!item.filter('[role]').length) {
- item.attr('role', 'menuitem');
- }
- if (!item.children(LINK_SELECTOR).length) {
- item.contents().filter(function () {
- return !this.nodeName.match(excludedNodesRegExp) && !(this.nodeType == 3 && !$.trim(this.nodeValue));
- }).wrapAll('
');
- }
- updateArrow(item);
- updateFirstLast(item);
- }
- function updateArrow(item) {
- item = $(item);
- item.find('> .k-link > [class*=k-i-arrow-60]:not(.k-sprite)').remove();
- item.filter(':has(.k-menu-group)').children('.k-link:not(:has([class*=k-i-arrow]:not(.k-sprite)))').each(function () {
- var item = $(this), arrowCssClass = getArrowCssClass(item);
- item.append('
');
- });
- }
- function getArrowCssClass(item) {
- var arrowCssClass, parent = item.parent().parent(), isRtl = kendo.support.isRtl(parent);
- if (parent.hasClass(MENU + '-horizontal')) {
- arrowCssClass = ' k-i-arrow-60-down';
- } else {
- if (isRtl) {
- arrowCssClass = ' k-i-arrow-60-left';
- } else {
- arrowCssClass = ' k-i-arrow-60-right';
- }
- }
- return arrowCssClass;
- }
- function updateFirstLast(item) {
- item = $(item);
- item.filter('.k-first:not(:first-child)').removeClass(FIRST);
- item.filter('.k-last:not(:last-child)').removeClass(LAST);
- item.filter(':first-child').addClass(FIRST);
- item.filter(':last-child').addClass(LAST);
- }
- function updateHasAriaPopup(parents) {
- if (parents && parents.length) {
- for (var index in parents) {
- var parentLi = parents.eq(index);
- if (parentLi.find('ul').length) {
- parentLi.attr('aria-haspopup', true);
- } else {
- parentLi.removeAttr('aria-haspopup');
- }
- }
- }
- }
- function getParentLiItems(group) {
- if (!group.hasClass(MENU)) {
- return group.parentsUntil('.' + MENU, 'li');
- }
- }
- function storeItemSelectEventHandler(element, options) {
- var selectHandler = getItemSelectEventHandler(options);
- if (selectHandler) {
- setItemData(element, selectHandler);
- }
- if (options.items) {
- $(element).children('ul').children('li').each(function (i) {
- storeItemSelectEventHandler(this, options.items[i]);
- });
- }
- }
- function setItemData(element, selectHandler) {
- $(element).children('.k-link').data({ selectHandler: selectHandler });
- }
- function getItemSelectEventHandler(options) {
- var selectHandler = options.select, isFunction = kendo.isFunction;
- if (selectHandler && isFunction(selectHandler)) {
- return selectHandler;
- }
- return null;
- }
- function popupOpenerSelector(id) {
- return id ? 'li[data-groupparent=\'' + id + '\']' : 'li[data-groupparent]';
- }
- function popupGroupSelector(id) {
- return id ? 'ul[data-group=\'' + id + '\']' : 'ul[data-group]';
- }
- function getChildPopups(currentPopup, overflowWrapper) {
- var childPopupOpener = currentPopup.find(popupOpenerSelector());
- var result = [];
- childPopupOpener.each(function (i, opener) {
- opener = $(opener);
- var popupId = opener.data(POPUP_OPENER_ATTR);
- var popup = currentPopup;
- while (popupId) {
- popup = overflowWrapper.find(popupGroupSelector(popupId) + ':visible');
- if (popup.length) {
- result.push(popup);
- }
- opener = popup.find(popupOpenerSelector());
- popupId = opener.data(POPUP_OPENER_ATTR);
- }
- });
- return result;
- }
- function popupParentItem(popupElement, overflowWrapper) {
- var popupId = popupElement.data(POPUP_ID_ATTR);
- return popupId ? overflowWrapper.find(popupOpenerSelector(popupId)) : $([]);
- }
- function itemPopup(item, overflowWrapper) {
- var popupId = item.data(POPUP_OPENER_ATTR);
- return popupId ? overflowWrapper.children(animationContainerSelector).children(popupGroupSelector(popupId)) : $([]);
- }
- function overflowMenuParents(current, overflowWrapper) {
- var parents = [];
- var getParents = function (item) {
- while (item.parentNode && !overflowWrapper.is(item.parentNode)) {
- parents.push(item.parentNode);
- item = item.parentNode;
- }
- };
- var elem = current[0] || current;
- getParents(elem);
- var last = parents[parents.length - 1];
- while ($(last).is(animationContainerSelector)) {
- var popupElement = $(last).children('ul');
- elem = popupParentItem(popupElement, overflowWrapper)[0];
- if (!elem) {
- break;
- }
- parents.push(elem);
- getParents(elem);
- last = parents[parents.length - 1];
- }
- return parents;
- }
- function mousewheelDelta(e) {
- var delta = 0;
- if (e.wheelDelta) {
- delta = -e.wheelDelta / 120;
- delta = delta > 0 ? Math.ceil(delta) : Math.floor(delta);
- }
- if (e.detail) {
- delta = Math.round(e.detail / 3);
- }
- return delta;
- }
- function parentsScroll(current, scrollDirection) {
- var scroll = 0;
- var parent = current.parentNode;
- while (parent && !isNaN(parent[scrollDirection])) {
- scroll += parent[scrollDirection];
- parent = parent.parentNode;
- }
- return scroll;
- }
- function isPointerTouch(e) {
- return allPointers && e.originalEvent && e.originalEvent.pointerType in touchPointerTypes;
- }
- function isTouch(e) {
- var ev = e.originalEvent;
- return touch && /touch/i.test(ev.type || '');
- }
- function removeSpacesBetweenItems(ul) {
- ul.contents().filter(function () {
- return this.nodeName != 'LI';
- }).remove();
- }
- var Menu = Widget.extend({
- init: function (element, options) {
- var that = this;
- Widget.fn.init.call(that, element, options);
- element = that.wrapper = that.element;
- options = that.options;
- that._initData(options);
- that._updateClasses();
- that._animations(options);
- that.nextItemZIndex = 100;
- that._tabindex();
- that._initOverflow(options);
- that._attachMenuEventsHandlers();
- if (options.openOnClick) {
- that.clicked = false;
- }
- element.attr('role', 'menubar');
- if (element[0].id) {
- that._ariaId = kendo.format('{0}_mn_active', element[0].id);
- }
- kendo.notify(that);
- },
- events: [
- OPEN,
- CLOSE,
- ACTIVATE,
- DEACTIVATE,
- SELECT
- ],
- options: {
- name: 'Menu',
- animation: {
- open: { duration: 200 },
- close: { duration: 100 }
- },
- orientation: 'horizontal',
- direction: 'default',
- openOnClick: false,
- closeOnClick: true,
- hoverDelay: 100,
- scrollable: false,
- popupCollision: undefined
- },
- _initData: function (options) {
- var that = this;
- if (options.dataSource) {
- that.angular('cleanup', function () {
- return { elements: that.element.children() };
- });
- that.element.empty();
- that.append(options.dataSource, that.element);
- that.angular('compile', function () {
- return { elements: that.element.children() };
- });
- }
- },
- _attachMenuEventsHandlers: function () {
- var that = this;
- var element = that.element;
- var options = that.options;
- var overflowWrapper = that._overflowWrapper();
- (overflowWrapper || element).on(POINTERDOWN, itemSelector, proxy(that._focusHandler, that)).on(CLICK + NS, disabledSelector, false).on(CLICK + NS, itemSelector, proxy(that._click, that)).on(POINTERDOWN + ' ' + MOUSEDOWN + NS, '.k-content', proxy(that._preventClose, that)).on(MOUSEENTER + NS, availableItemsSelector, proxy(that._mouseenter, that)).on(MOUSELEAVE + NS, availableItemsSelector, proxy(that._mouseleave, that)).on(MOUSEDOWN + NS, availableItemsSelector, proxy(that._mousedown, that)).on(TOUCHSTART + NS + ' ' + MOUSEENTER + NS + ' ' + MOUSELEAVE + NS + ' ' + MOUSEDOWN + NS + ' ' + CLICK + NS, linkSelector, proxy(that._toggleHover, that));
- element.on('keydown' + NS, proxy(that._keydown, that)).on('focus' + NS, proxy(that._focus, that)).on('focus' + NS, '.k-content', proxy(that._focus, that)).on('blur' + NS, proxy(that._removeHoverItem, that)).on('blur' + NS, '[tabindex]', proxy(that._checkActiveElement, that));
- if (overflowWrapper) {
- overflowWrapper.on(MOUSELEAVE + NS, popupSelector, proxy(that._mouseleavePopup, that)).on(MOUSEENTER + NS, popupSelector, proxy(that._mouseenterPopup, that));
- }
- if (options.openOnClick) {
- that._documentClickHandler = proxy(that._documentClick, that);
- $(document).click(that._documentClickHandler);
- }
- },
- _detachMenuEventsHandlers: function () {
- var that = this;
- var overflowWrapper = that._overflowWrapper();
- if (overflowWrapper) {
- overflowWrapper.off(NS);
- }
- that.element.off(NS);
- if (that._documentClickHandler) {
- $(document).unbind('click', that._documentClickHandler);
- }
- },
- _initOverflow: function (options) {
- var that = this;
- var isHorizontal = options.orientation == 'horizontal';
- var backwardBtn, forwardBtn;
- if (options.scrollable) {
- that._openedPopups = {};
- that._scrollWrapper = that.element.wrap('').parent();
- if (isHorizontal) {
- removeSpacesBetweenItems(that.element);
- }
- backwardBtn = $(templates.scrollButton({ direction: isHorizontal ? 'left' : 'up' }));
- forwardBtn = $(templates.scrollButton({ direction: isHorizontal ? 'right' : 'down' }));
- backwardBtn.add(forwardBtn).appendTo(that._scrollWrapper);
- that._initScrolling(that.element, backwardBtn, forwardBtn, isHorizontal);
- var initialWidth = that.element.outerWidth();
- var initialCssWidth = that.element[0].style.width;
- initialCssWidth = initialCssWidth === 'auto' ? '' : initialCssWidth;
- if (isHorizontal) {
- $(window).on(RESIZE, kendo.throttle(function () {
- that._setOverflowWrapperWidth(initialWidth, initialCssWidth);
- that._toggleScrollButtons(that.element, backwardBtn, forwardBtn, isHorizontal);
- }, 100));
- }
- that._setOverflowWrapperWidth(initialWidth, initialCssWidth);
- that._toggleScrollButtons(that.element, backwardBtn, forwardBtn, isHorizontal);
- }
- },
- _overflowWrapper: function () {
- return this._scrollWrapper || this._popupsWrapper;
- },
- _setOverflowWrapperWidth: function (initialWidth, initialCssWidth) {
- var that = this;
- var wrapperCssWidth = that._scrollWrapper.css('width');
- that._scrollWrapper.css({ width: '' });
- var wrapperWidth = that._scrollWrapper.outerWidth();
- that._scrollWrapper.css({ width: wrapperCssWidth });
- var menuWidth = that.element.outerWidth();
- var borders = that.element[0].offsetWidth - that.element[0].clientWidth;
- if (menuWidth != wrapperWidth && wrapperWidth > 0) {
- var width = initialCssWidth ? Math.min(initialWidth, wrapperWidth) : wrapperWidth;
- that.element.width(width - borders);
- that._scrollWrapper.width(width);
- }
- },
- _reinitOverflow: function (options) {
- var that = this;
- var overflowChanged = options.scrollable && !that.options.scrollable || !options.scrollable && that.options.scrollable || options.scrollable && that.options.scrollable && options.scrollable.distance != that.options.scrollable.distance || options.orientation != that.options.orientation;
- if (overflowChanged) {
- that._detachMenuEventsHandlers();
- that._destroyOverflow();
- that._initOverflow(options);
- that._attachMenuEventsHandlers();
- }
- },
- _destroyOverflow: function () {
- var that = this;
- var overflowWrapper = that._overflowWrapper();
- if (overflowWrapper) {
- overflowWrapper.off(NS);
- overflowWrapper.find(scrollButtonSelector).off(NS).remove();
- overflowWrapper.children(animationContainerSelector).each(function (i, popupWrapper) {
- var ul = $(popupWrapper).children(groupSelector);
- ul.off(MOUSEWHEEL);
- var popupParentLi = popupParentItem(ul, overflowWrapper);
- if (popupParentLi.length) {
- popupParentLi.append(popupWrapper);
- }
- });
- overflowWrapper.find(popupOpenerSelector()).removeAttr('data-groupparent');
- overflowWrapper.find(popupGroupSelector()).removeAttr('data-group');
- that.element.off(MOUSEWHEEL);
- $(window).off(RESIZE);
- overflowWrapper.contents().unwrap();
- that._scrollWrapper = that._popupsWrapper = that._openedPopups = undefined;
- }
- },
- _initScrolling: function (scrollElement, backwardBtn, forwardBtn, isHorizontal) {
- var that = this;
- var scrollable = that.options.scrollable;
- var distance = $.isNumeric(scrollable.distance) ? scrollable.distance : SCROLLSPEED;
- var mouseWheelDistance = distance / 2;
- var backward = '-=' + distance;
- var forward = '+=' + distance;
- var backwardDouble = '-=' + distance * 2;
- var forwardDouble = '+=' + distance * 2;
- var scrolling = false;
- var touchEvents = false;
- var scroll = function (value) {
- var scrollValue = isHorizontal ? { 'scrollLeft': value } : { 'scrollTop': value };
- scrollElement.finish().animate(scrollValue, 'fast', 'linear', function () {
- if (scrolling) {
- scroll(value);
- }
- });
- that._toggleScrollButtons(scrollElement, backwardBtn, forwardBtn, isHorizontal);
- };
- var mouseenterHandler = function (e) {
- if (!scrolling && !touchEvents) {
- scroll(e.data.direction);
- scrolling = true;
- }
- };
- var mousedownHandler = function (e) {
- var scrollValue = isHorizontal ? { 'scrollLeft': e.data.direction } : { 'scrollTop': e.data.direction };
- touchEvents = isTouch(e) || isPointerTouch(e);
- scrollElement.stop().animate(scrollValue, 'fast', 'linear', function () {
- if (!touchEvents) {
- $(e.currentTarget).trigger(MOUSEENTER);
- } else {
- that._toggleScrollButtons(scrollElement, backwardBtn, forwardBtn, isHorizontal);
- scrolling = true;
- }
- });
- scrolling = false;
- e.stopPropagation();
- e.preventDefault();
- };
- backwardBtn.on(MOUSEENTER + NS, { direction: backward }, mouseenterHandler).on(kendo.eventMap.down + NS, { direction: backwardDouble }, mousedownHandler);
- forwardBtn.on(MOUSEENTER + NS, { direction: forward }, mouseenterHandler).on(kendo.eventMap.down + NS, { direction: forwardDouble }, mousedownHandler);
- backwardBtn.add(forwardBtn).on(MOUSELEAVE + NS, function () {
- scrollElement.stop();
- scrolling = false;
- that._toggleScrollButtons(scrollElement, backwardBtn, forwardBtn, isHorizontal);
- });
- scrollElement.on(MOUSEWHEEL, function (e) {
- if (!e.ctrlKey && !e.shiftKey && !e.altKey) {
- var wheelDelta = mousewheelDelta(e.originalEvent);
- var scrollSpeed = Math.abs(wheelDelta) * mouseWheelDistance;
- var value = (wheelDelta > 0 ? '+=' : '-=') + scrollSpeed;
- var scrollValue = isHorizontal ? { 'scrollLeft': value } : { 'scrollTop': value };
- that._closeChildPopups(scrollElement);
- scrollElement.finish().animate(scrollValue, 'fast', 'linear', function () {
- that._toggleScrollButtons(scrollElement, backwardBtn, forwardBtn, isHorizontal);
- });
- e.preventDefault();
- }
- });
- },
- _toggleScrollButtons: function (scrollElement, backwardBtn, forwardBtn, horizontal) {
- var currentScroll = horizontal ? scrollElement.scrollLeft() : scrollElement.scrollTop();
- var scrollSize = horizontal ? SCROLLWIDTH : SCROLLHEIGHT;
- var offset = horizontal ? OFFSETWIDTH : OFFSETHEIGHT;
- backwardBtn.toggle(currentScroll !== 0);
- forwardBtn.toggle(currentScroll < scrollElement[0][scrollSize] - scrollElement[0][offset] - 1);
- },
- setOptions: function (options) {
- var animation = this.options.animation;
- this._animations(options);
- options.animation = extend(true, animation, options.animation);
- if ('dataSource' in options) {
- this._initData(options);
- }
- this._updateClasses();
- this._reinitOverflow(options);
- Widget.fn.setOptions.call(this, options);
- },
- destroy: function () {
- var that = this;
- Widget.fn.destroy.call(that);
- that._detachMenuEventsHandlers();
- that._destroyOverflow();
- kendo.destroy(that.element);
- },
- enable: function (element, enable) {
- this._toggleDisabled(element, enable !== false);
- return this;
- },
- disable: function (element) {
- this._toggleDisabled(element, false);
- return this;
- },
- append: function (item, referenceItem) {
- referenceItem = this.element.find(referenceItem);
- var inserted = this._insert(item, referenceItem, referenceItem.length ? referenceItem.find('> .k-menu-group, > .k-animation-container > .k-menu-group') : null);
- each(inserted.items, function (i) {
- inserted.group.append(this);
- updateArrow(this);
- storeItemSelectEventHandler(this, item[i] || item);
- });
- updateArrow(referenceItem);
- updateFirstLast(inserted.group.find('.k-first, .k-last').add(inserted.items));
- updateHasAriaPopup(getParentLiItems(inserted.group));
- return this;
- },
- insertBefore: function (item, referenceItem) {
- referenceItem = this.element.find(referenceItem);
- var inserted = this._insert(item, referenceItem, referenceItem.parent());
- each(inserted.items, function (i) {
- referenceItem.before(this);
- updateArrow(this);
- updateFirstLast(this);
- storeItemSelectEventHandler(this, item[i] || item);
- });
- updateFirstLast(referenceItem);
- return this;
- },
- insertAfter: function (item, referenceItem) {
- referenceItem = this.element.find(referenceItem);
- var inserted = this._insert(item, referenceItem, referenceItem.parent());
- each(inserted.items, function (i) {
- referenceItem.after(this);
- updateArrow(this);
- updateFirstLast(this);
- storeItemSelectEventHandler(this, item[i] || item);
- });
- updateFirstLast(referenceItem);
- return this;
- },
- _insert: function (item, referenceItem, parent) {
- var that = this, items, groups;
- if (!referenceItem || !referenceItem.length) {
- parent = that.element;
- }
- var plain = $.isPlainObject(item), groupData = {
- firstLevel: parent.hasClass(MENU),
- horizontal: parent.hasClass(MENU + '-horizontal'),
- expanded: true,
- length: parent.children().length
- };
- if (referenceItem && !parent.length) {
- parent = $(Menu.renderGroup({ group: groupData })).appendTo(referenceItem);
- }
- if (plain || $.isArray(item)) {
- items = $($.map(plain ? [item] : item, function (value, idx) {
- if (typeof value === 'string') {
- return $(value).get();
- } else {
- return $(Menu.renderItem({
- group: groupData,
- item: extend(value, { index: idx })
- })).get();
- }
- }));
- } else {
- if (typeof item == 'string' && item.charAt(0) != '<') {
- items = that.element.find(item);
- } else {
- items = $(item);
- }
- groups = items.find('> ul').addClass('k-menu-group').attr('role', 'menu');
- items = items.filter('li');
- items.add(groups.find('> li')).each(function () {
- updateItemClasses(this);
- });
- }
- return {
- items: items,
- group: parent
- };
- },
- remove: function (element) {
- element = this.element.find(element);
- var that = this, parent = element.parentsUntil(that.element, allItemsSelector), group = element.parent('ul:not(.k-menu)');
- element.remove();
- if (group && !group.children(allItemsSelector).length) {
- var parentItems = getParentLiItems(group);
- var container = group.parent(animationContainerSelector);
- if (container.length) {
- container.remove();
- } else {
- group.remove();
- }
- updateHasAriaPopup(parentItems);
- }
- if (parent.length) {
- parent = parent.eq(0);
- updateArrow(parent);
- updateFirstLast(parent);
- }
- return that;
- },
- open: function (element) {
- var that = this;
- var options = that.options;
- var horizontal = options.orientation == 'horizontal';
- var direction = options.direction;
- var isRtl = kendo.support.isRtl(that.wrapper);
- var overflowWrapper = that._overflowWrapper();
- element = (overflowWrapper || that.element).find(element);
- if (/^(top|bottom|default)$/.test(direction)) {
- if (isRtl) {
- direction = horizontal ? (direction + ' left').replace('default', 'bottom') : 'left';
- } else {
- direction = horizontal ? (direction + ' right').replace('default', 'bottom') : 'right';
- }
- }
- var visiblePopups = '>.k-popup:visible,>.k-animation-container>.k-popup:visible';
- var closePopup = function () {
- var popup = $(this).data(KENDOPOPUP);
- if (popup) {
- that.close($(this).closest('li.k-item'), true);
- }
- };
- element.siblings().find(visiblePopups).each(closePopup);
- if (overflowWrapper) {
- element.find(visiblePopups).each(closePopup);
- }
- if (that.options.openOnClick) {
- that.clicked = true;
- }
- element.each(function () {
- var li = $(this);
- clearTimeout(li.data(TIMER));
- li.data(TIMER, setTimeout(function () {
- var ul = li.find('.k-menu-group:first:hidden');
- var popup;
- var overflowPopup;
- if (!ul[0] && overflowWrapper) {
- overflowPopup = that._getPopup(li);
- ul = overflowPopup && overflowPopup.element;
- }
- if (ul.is(':visible')) {
- return;
- }
- if (ul[0] && that._triggerEvent({
- item: li[0],
- type: OPEN
- }) === false) {
- if (!ul.find('.k-menu-group')[0] && ul.children('.k-item').length > 1) {
- var windowHeight = $(window).height(), setScrolling = function () {
- ul.css({
- maxHeight: windowHeight - (kendo._outerHeight(ul) - ul.height()) - kendo.getShadows(ul).bottom,
- overflow: 'auto'
- });
- };
- if (kendo.support.browser.msie && kendo.support.browser.version <= 7) {
- setTimeout(setScrolling, 0);
- } else {
- setScrolling();
- }
- } else {
- ul.css({
- maxHeight: '',
- overflow: ''
- });
- }
- li.data(ZINDEX, li.css(ZINDEX));
- var nextZindex = that.nextItemZIndex++;
- li.css(ZINDEX, nextZindex);
- if (that.options.scrollable) {
- li.parent().siblings(scrollButtonSelector).css({ zIndex: ++nextZindex });
- }
- popup = ul.data(KENDOPOPUP);
- var root = li.parent().hasClass(MENU), parentHorizontal = root && horizontal, directions = parseDirection(direction, root, isRtl), effects = options.animation.open.effects, openEffects = effects !== undefined ? effects : 'slideIn:' + getEffectDirection(direction, root);
- if (!popup) {
- popup = ul.kendoPopup({
- activate: function () {
- that._triggerEvent({
- item: this.wrapper.parent(),
- type: ACTIVATE
- });
- },
- deactivate: function (e) {
- e.sender.element.removeData('targetTransform').css({ opacity: '' });
- that._triggerEvent({
- item: this.wrapper.parent(),
- type: DEACTIVATE
- });
- },
- origin: directions.origin,
- position: directions.position,
- collision: options.popupCollision !== undefined ? options.popupCollision : parentHorizontal ? 'fit' : 'fit flip',
- anchor: li,
- appendTo: overflowWrapper || li,
- animation: {
- open: extend(true, { effects: openEffects }, options.animation.open),
- close: options.animation.close
- },
- open: proxy(that._popupOpen, that),
- close: function (e) {
- var li = e.sender.wrapper.parent();
- if (overflowWrapper) {
- var popupId = e.sender.element.data(POPUP_ID_ATTR);
- if (popupId) {
- li = (overflowWrapper || that.element).find(popupOpenerSelector(popupId));
- }
- e.sender.wrapper.children(scrollButtonSelector).hide();
- }
- if (!that._triggerEvent({
- item: li[0],
- type: CLOSE
- })) {
- li.css(ZINDEX, li.data(ZINDEX));
- li.removeData(ZINDEX);
- if (that.options.scrollable) {
- li.parent().siblings(scrollButtonSelector).css({ zIndex: '' });
- }
- if (touch || allPointers || kendo.support.mouseAndTouchPresent) {
- li.removeClass(HOVERSTATE);
- that._removeHoverItem();
- }
- } else {
- e.preventDefault();
- }
- }
- }).data(KENDOPOPUP);
- } else {
- popup = ul.data(KENDOPOPUP);
- popup.options.origin = directions.origin;
- popup.options.position = directions.position;
- popup.options.animation.open.effects = openEffects;
- }
- ul.removeAttr('aria-hidden');
- that._configurePopupOverflow(popup, li);
- popup._hovered = true;
- popup.open();
- that._initPopupScrolling(popup);
- }
- }, that.options.hoverDelay));
- });
- return that;
- },
- _configurePopupOverflow: function (popup, popupOpener) {
- var that = this;
- if (that.options.scrollable) {
- that._wrapPopupElement(popup);
- if (!popupOpener.attr('data-groupparent')) {
- var groupId = new Date().getTime();
- popupOpener.attr('data-groupparent', groupId);
- popup.element.attr('data-group', groupId);
- }
- }
- },
- _wrapPopupElement: function (popup) {
- if (!popup.element.parent().is(animationContainerSelector)) {
- popup.wrapper = kendo.wrap(popup.element, popup.options.autosize).css({
- overflow: 'hidden',
- display: 'block',
- position: 'absolute'
- });
- }
- },
- _initPopupScrolling: function (popup, isHorizontal, skipMouseEvents) {
- var that = this;
- if (that.options.scrollable && popup.element[0].scrollHeight > popup.element[0].offsetHeight) {
- that._initPopupScrollButtons(popup, isHorizontal, skipMouseEvents);
- }
- },
- _initPopupScrollButtons: function (popup, isHorizontal, skipMouseEvents) {
- var that = this;
- var scrollButtons = popup.wrapper.children(scrollButtonSelector);
- var animation = that.options.animation;
- var timeout = (animation && animation.open && animation.open.duration || 0) + DELAY;
- setTimeout(function () {
- if (!scrollButtons.length) {
- var backwardBtn = $(templates.scrollButton({ direction: isHorizontal ? 'left' : 'up' }));
- var forwardBtn = $(templates.scrollButton({ direction: isHorizontal ? 'right' : 'down' }));
- scrollButtons = backwardBtn.add(forwardBtn).appendTo(popup.wrapper);
- that._initScrolling(popup.element, backwardBtn, forwardBtn, isHorizontal);
- if (!skipMouseEvents) {
- scrollButtons.on(MOUSEENTER + NS, function () {
- var overflowWrapper = that._overflowWrapper();
- $(getChildPopups(popup.element, overflowWrapper)).each(function (i, p) {
- var popupOpener = overflowWrapper.find(popupOpenerSelector(p.data(POPUP_ID_ATTR)));
- that.close(popupOpener);
- });
- }).on(MOUSELEAVE + NS, function () {
- setTimeout(function () {
- if ($.isEmptyObject(that._openedPopups)) {
- that._closeParentPopups(popup.element);
- }
- }, DELAY);
- });
- }
- }
- that._toggleScrollButtons(popup.element, scrollButtons.first(), scrollButtons.last(), isHorizontal);
- }, timeout);
- },
- _popupOpen: function (e) {
- if (!this._keyTriggered) {
- e.sender.element.children('.' + FOCUSEDSTATE).removeClass(FOCUSEDSTATE);
- }
- if (this.options.scrollable) {
- this._setPopupHeight(e.sender);
- }
- },
- _setPopupHeight: function (popup, isFixed) {
- var popupElement = popup.element;
- var popups = popupElement.add(popupElement.parent(animationContainerSelector));
- popups.height(popupElement.hasClass(MENU) && this._initialHeight || '');
- var location = popup._location(isFixed);
- var windowHeight = $(window).height();
- var popupOuterHeight = location.height;
- var popupOffsetTop = isFixed ? 0 : Math.max(location.top, 0);
- var scrollTop = isFixed ? 0 : parentsScroll(this._overflowWrapper()[0], 'scrollTop');
- var bottomScrollbar = window.innerHeight - windowHeight;
- var maxHeight = windowHeight - kendo.getShadows(popupElement).bottom + bottomScrollbar;
- var canFit = maxHeight + scrollTop > popupOuterHeight + popupOffsetTop;
- if (!canFit) {
- var height = Math.min(maxHeight, maxHeight - popupOffsetTop + scrollTop);
- popups.css({
- overflow: 'hidden',
- height: height + 'px'
- });
- }
- },
- close: function (items, dontClearClose) {
- var that = this;
- var overflowWrapper = that._overflowWrapper();
- var element = overflowWrapper || that.element;
- items = element.find(items);
- if (!items.length) {
- items = element.find('>.k-item');
- }
- var hasChildPopupsHovered = function (currentPopup) {
- var result = false;
- if ($.isEmptyObject(that._openedPopups)) {
- return result;
- }
- $(getChildPopups(currentPopup, overflowWrapper)).each(function (i, popup) {
- result = !!that._openedPopups[popup.data(POPUP_ID_ATTR).toString()];
- return !result;
- });
- return result;
- };
- var isPopupMouseLeaved = function (opener) {
- var groupId = opener.data(POPUP_OPENER_ATTR);
- return !overflowWrapper || !groupId || !that._openedPopups[groupId.toString()];
- };
- items.each(function () {
- var li = $(this);
- if (!dontClearClose && that._isRootItem(li)) {
- that.clicked = false;
- }
- clearTimeout(li.data(TIMER));
- li.data(TIMER, setTimeout(function () {
- var popup = that._getPopup(li);
- if (popup && (isPopupMouseLeaved(li) || that._forceClose)) {
- if (!that._forceClose && hasChildPopupsHovered(popup.element)) {
- return;
- }
- popup.close();
- popup.element.attr('aria-hidden', true);
- if (overflowWrapper) {
- if (that._forceClose && items.last().is(li[0])) {
- delete that._forceClose;
- }
- }
- }
- }, that.options.hoverDelay));
- });
- return that;
- },
- _getPopup: function (li) {
- var that = this;
- var popup = li.find('.k-menu-group:not(.k-list-container):not(.k-calendar-container):first:visible').data(KENDOPOPUP);
- var overflowWrapper = that._overflowWrapper();
- if (!popup && overflowWrapper) {
- var groupId = li.data(POPUP_OPENER_ATTR);
- if (groupId) {
- var popupElement = overflowWrapper.find(popupGroupSelector(groupId));
- popup = popupElement.data(KENDOPOPUP);
- }
- }
- return popup;
- },
- _toggleDisabled: function (items, enable) {
- this.element.find(items).each(function () {
- $(this).toggleClass(DEFAULTSTATE, enable).toggleClass(DISABLEDSTATE, !enable).attr('aria-disabled', !enable);
- });
- },
- _toggleHover: function (e) {
- var target = $(kendo.eventTarget(e) || e.target).closest(allItemsSelector), isEnter = e.type == MOUSEENTER || MOUSEDOWN.indexOf(e.type) !== -1;
- target.siblings().removeClass(HOVERSTATE);
- if (!target.parents('li.' + DISABLEDSTATE).length) {
- target.toggleClass(HOVERSTATE, isEnter || e.type == 'mousedown' || e.type == 'pointerover' || e.type == TOUCHSTART);
- }
- this._removeHoverItem();
- },
- _preventClose: function () {
- if (!this.options.closeOnClick) {
- this._closurePrevented = true;
- }
- },
- _checkActiveElement: function (e) {
- var that = this, hoverItem = $(e ? e.currentTarget : this._hoverItem()), target = that._findRootParent(hoverItem)[0];
- if (!this._closurePrevented) {
- setTimeout(function () {
- if (!document.hasFocus() || !contains(target, kendo._activeElement()) && e && !contains(target, e.currentTarget)) {
- that.close(target);
- }
- }, 0);
- }
- this._closurePrevented = false;
- },
- _removeHoverItem: function () {
- var oldHoverItem = this._hoverItem();
- if (oldHoverItem && oldHoverItem.hasClass(FOCUSEDSTATE)) {
- oldHoverItem.removeClass(FOCUSEDSTATE);
- this._oldHoverItem = null;
- }
- },
- _updateClasses: function () {
- var element = this.element, nonContentGroupsSelector = '.k-menu-init div ul', items;
- element.removeClass('k-menu-horizontal k-menu-vertical');
- element.addClass('k-widget k-reset k-header k-menu-init ' + MENU).addClass(MENU + '-' + this.options.orientation);
- element.find('li > ul').filter(function () {
- return !kendo.support.matchesSelector.call(this, nonContentGroupsSelector);
- }).addClass('k-group k-menu-group').attr('role', 'menu').attr('aria-hidden', element.is(':visible')).parent('li').attr('aria-haspopup', 'true').end().find('li > div').addClass('k-content').attr('tabindex', '-1');
- items = element.find('> li,.k-menu-group > li');
- element.removeClass('k-menu-init');
- items.each(function () {
- updateItemClasses(this);
- });
- },
- _mouseenter: function (e) {
- var that = this;
- var element = $(e.currentTarget);
- var hasChildren = that._itemHasChildren(element);
- var popupId = element.data(POPUP_OPENER_ATTR) || element.parent().data(POPUP_ID_ATTR);
- var pointerTouch = isPointerTouch(e);
- if (popupId) {
- that._openedPopups[popupId.toString()] = true;
- }
- if (e.delegateTarget != element.parents(menuSelector)[0] && e.delegateTarget != element.parents('.k-menu-scroll-wrapper,.k-popups-wrapper')[0]) {
- return;
- }
- that._keyTriggered = false;
- if (that.options.openOnClick.rootMenuItems && that._isRootItem(element.closest(allItemsSelector)) || that.options.openOnClick.subMenuItems && !that._isRootItem(element.closest(allItemsSelector))) {
- return;
- }
- if ((that.options.openOnClick === false || that.options.openOnClick.rootMenuItems === false && that._isRootItem(element.closest(allItemsSelector)) || that.options.openOnClick.subMenuItems === false && !that._isRootItem(element.closest(allItemsSelector)) || that.clicked) && !touch && !(pointerTouch && that._isRootItem(element.closest(allItemsSelector)))) {
- if (!contains(e.currentTarget, e.relatedTarget) && hasChildren) {
- that.open(element);
- }
- }
- if (that.options.openOnClick === true && that.clicked || touch) {
- element.siblings().each(proxy(function (_, sibling) {
- that.close(sibling, true);
- }, that));
- }
- },
- _mousedown: function (e) {
- var that = this;
- var element = $(e.currentTarget);
- if (that.options.openOnClick.subMenuItems && !that._isRootItem(element) || touch) {
- element.siblings().each(proxy(function (_, sibling) {
- that.close(sibling, true);
- }, that));
- }
- },
- _mouseleave: function (e) {
- var that = this;
- var element = $(e.currentTarget);
- var popupOpener = element.data(POPUP_OPENER_ATTR);
- var hasChildren = element.children(animationContainerSelector).length || element.children(groupSelector).length || popupOpener;
- var $window = $(window);
- if (popupOpener) {
- delete that._openedPopups[popupOpener.toString()];
- }
- if (element.parentsUntil(animationContainerSelector, '.k-list-container,.k-calendar-container')[0]) {
- e.stopImmediatePropagation();
- return;
- }
- if ((that.options.openOnClick === false || !that.options.openOnClick.rootMenuItems && that._isRootItem(element) || !that.options.openOnClick.subMenuItems && !that._isRootItem(element)) && !touch && !isPointerTouch(e) && !contains(e.currentTarget, e.relatedTarget || e.target) && hasChildren && !contains(e.currentTarget, kendo._activeElement())) {
- that.close(element, true);
- return;
- }
- if (kendo.support.browser.msie && !e.toElement && !e.relatedTarget && !isPointerTouch(e) || e.clientX < 0 || e.clientY < 0 || e.clientY > $window.height() || e.clientX > $window.width()) {
- that.close(element);
- }
- },
- _mouseenterPopup: function (e) {
- var that = this;
- var popupElement = $(e.currentTarget);
- if (popupElement.parent().is(animationContainerSelector)) {
- return;
- }
- popupElement = popupElement.children('ul');
- var popupId = popupElement.data(POPUP_ID_ATTR);
- if (popupId) {
- that._openedPopups[popupId.toString()] = true;
- }
- },
- _mouseleavePopup: function (e) {
- var that = this;
- var popupElement = $(e.currentTarget);
- if (!isPointerTouch(e) && popupElement.is(animationContainerSelector)) {
- that._closePopups(popupElement.children('ul'));
- }
- },
- _closePopups: function (rootPopup) {
- var that = this;
- var overflowWrapper = that._overflowWrapper();
- var popupId = rootPopup.data(POPUP_ID_ATTR);
- if (popupId) {
- delete that._openedPopups[popupId.toString()];
- var groupParent = overflowWrapper.find(popupOpenerSelector(popupId));
- setTimeout(function () {
- if (that.options.openOnClick) {
- that._closeChildPopups(rootPopup);
- } else {
- if ($.isEmptyObject(that._openedPopups)) {
- var innerPopup = that._innerPopup(rootPopup);
- that._closeParentPopups(innerPopup);
- } else {
- that.close(groupParent, true);
- }
- }
- }, 0);
- }
- },
- _closeChildPopups: function (current) {
- var that = this;
- var overflowWrapper = that._overflowWrapper();
- $(getChildPopups(current, overflowWrapper)).each(function () {
- var popupOpener = overflowWrapper.find(popupOpenerSelector(this.data(POPUP_ID_ATTR)));
- that.close(popupOpener, true);
- });
- },
- _innerPopup: function (current) {
- var overflowWrapper = this._overflowWrapper();
- var popups = getChildPopups(current, overflowWrapper);
- return popups[popups.length - 1] || current;
- },
- _closeParentPopups: function (current) {
- var that = this;
- var overflowWrapper = that._overflowWrapper();
- var popupId = current.data(POPUP_ID_ATTR);
- var popupOpener = overflowWrapper.find(popupOpenerSelector(popupId));
- popupId = popupOpener.parent().data(POPUP_ID_ATTR);
- that.close(popupOpener, true);
- while (popupId && !that._openedPopups[popupId]) {
- if (popupOpener.parent().is(menuSelector)) {
- break;
- }
- popupOpener = overflowWrapper.find(popupOpenerSelector(popupId));
- that.close(popupOpener, true);
- popupId = popupOpener.parent().data(POPUP_ID_ATTR);
- }
- },
- _click: function (e) {
- var that = this, openHandle, options = that.options, target = $(kendo.eventTarget(e)), targetElement = target[0], nodeName = target[0] ? target[0].nodeName.toUpperCase() : '', formNode = nodeName == 'INPUT' || nodeName == 'SELECT' || nodeName == 'BUTTON' || nodeName == 'LABEL', link = target.closest(LINK_SELECTOR), element = target.closest(allItemsSelector), itemElement = element[0], href = link.attr('href'), childGroup, childGroupVisible, targetHref = target.attr('href'), sampleHref = $('
').attr('href'), isLink = !!href && href !== sampleHref, isLocalLink = isLink && !!href.match(/^#/), isTargetLink = !!targetHref && targetHref !== sampleHref, overflowWrapper = that._overflowWrapper(), shouldCloseTheRootItem;
- while (targetElement && targetElement.parentNode != itemElement) {
- targetElement = targetElement.parentNode;
- }
- if ($(targetElement).is(templateSelector)) {
- return;
- }
- if (element.hasClass(DISABLEDSTATE)) {
- e.preventDefault();
- return;
- }
- if (!e.handled && that._triggerSelect(target, itemElement) && !formNode) {
- e.preventDefault();
- }
- e.handled = true;
- childGroup = element.children(popupSelector);
- if (overflowWrapper) {
- var childPopupId = element.data(POPUP_OPENER_ATTR);
- if (childPopupId) {
- childGroup = overflowWrapper.find(popupGroupSelector(childPopupId));
- }
- }
- childGroupVisible = childGroup.is(':visible');
- shouldCloseTheRootItem = options.openOnClick && childGroupVisible && that._isRootItem(element);
- if (options.closeOnClick && (!isLink || isLocalLink) && (!childGroup.length || shouldCloseTheRootItem)) {
- element.removeClass(HOVERSTATE).css('height');
- that._oldHoverItem = that._findRootParent(element);
- var item = that._parentsUntil(link, that.element, allItemsSelector);
- that._forceClose = !!overflowWrapper;
- that.close(item);
- that.clicked = false;
- if ('MSPointerUp'.indexOf(e.type) != -1) {
- e.preventDefault();
- }
- return;
- }
- if (isLink && e.enterKey) {
- link[0].click();
- }
- if ((!that._isRootItem(element) || options.openOnClick === false) && !options.openOnClick.subMenuItems && !kendo.support.touch && !(isPointerTouch(e) && that._isRootItem(element.closest(allItemsSelector)))) {
- return;
- }
- if (!isLink && !formNode && !isTargetLink) {
- e.preventDefault();
- }
- that.clicked = true;
- openHandle = childGroup.is(':visible') ? CLOSE : OPEN;
- if (!options.closeOnClick && openHandle == CLOSE) {
- return;
- }
- that[openHandle](element);
- },
- _parentsUntil: function (context, top, selector) {
- var overflowWrapper = this._overflowWrapper();
- if (!overflowWrapper) {
- return context.parentsUntil(top, selector);
- } else {
- var parents = overflowMenuParents(context, overflowWrapper);
- var result = [];
- $(parents).each(function () {
- var parent = $(this);
- if (parent.is(top)) {
- return false;
- }
- if (parent.is(selector)) {
- result.push(this);
- }
- });
- return $(result);
- }
- },
- _triggerSelect: function (target, itemElement) {
- target = target.is('.k-link') ? target : target.closest('.k-link');
- var selectHandler = target.data('selectHandler'), itemSelectEventData;
- if (selectHandler) {
- itemSelectEventData = this._getEventData(target);
- selectHandler.call(this, itemSelectEventData);
- }
- var isSelectItemDefaultPrevented = itemSelectEventData && itemSelectEventData.isDefaultPrevented();
- var isSelectDefaultPrevented = this._triggerEvent({
- item: itemElement,
- type: SELECT
- });
- return isSelectItemDefaultPrevented || isSelectDefaultPrevented;
- },
- _getEventData: function (target) {
- var eventData = {
- sender: this,
- target: target,
- _defaultPrevented: false,
- preventDefault: function () {
- this._defaultPrevented = true;
- },
- isDefaultPrevented: function () {
- return this._defaultPrevented;
- }
- };
- return eventData;
- },
- _documentClick: function (e) {
- var that = this;
- if (contains((that._overflowWrapper() || that.element)[0], e.target)) {
- return;
- }
- that.clicked = false;
- },
- _focus: function (e) {
- var that = this, target = e.target, hoverItem = that._hoverItem(), active = activeElement();
- if (target != that.wrapper[0] && !$(target).is(':kendoFocusable')) {
- e.stopPropagation();
- $(target).closest('.k-content').closest('.k-menu-group').closest('.k-item').addClass(FOCUSEDSTATE);
- that.wrapper.focus();
- return;
- }
- if (active === e.currentTarget) {
- if (hoverItem.length) {
- that._moveHover([], hoverItem);
- } else if (!that._oldHoverItem) {
- that._moveHover([], that.wrapper.children().first());
- }
- }
- },
- _keydown: function (e) {
- var that = this, key = e.keyCode, hoverItem = that._oldHoverItem, target, belongsToVertical, hasChildren, isRtl = kendo.support.isRtl(that.wrapper);
- if (e.target != e.currentTarget && key != keys.ESC) {
- return;
- }
- if (!hoverItem) {
- hoverItem = that._oldHoverItem = that._hoverItem();
- }
- belongsToVertical = that._itemBelongsToVertival(hoverItem);
- hasChildren = that._itemHasChildren(hoverItem);
- that._keyTriggered = true;
- if (key == keys.RIGHT) {
- target = that[isRtl ? '_itemLeft' : '_itemRight'](hoverItem, belongsToVertical, hasChildren);
- } else if (key == keys.LEFT) {
- target = that[isRtl ? '_itemRight' : '_itemLeft'](hoverItem, belongsToVertical, hasChildren);
- } else if (key == keys.DOWN) {
- target = that._itemDown(hoverItem, belongsToVertical, hasChildren);
- } else if (key == keys.UP) {
- target = that._itemUp(hoverItem, belongsToVertical, hasChildren);
- } else if (key == keys.HOME) {
- that._moveHover(hoverItem, hoverItem.parent().children().first());
- e.preventDefault();
- } else if (key == keys.END) {
- that._moveHover(hoverItem, hoverItem.parent().children().last());
- e.preventDefault();
- } else if (key == keys.ESC) {
- target = that._itemEsc(hoverItem, belongsToVertical);
- } else if (key == keys.ENTER || key == keys.SPACEBAR) {
- target = hoverItem.children('.k-link');
- if (target.length > 0) {
- that._click({
- target: target[0],
- preventDefault: function () {
- },
- enterKey: true
- });
- if (hasChildren && !hoverItem.hasClass(DISABLEDSTATE)) {
- that.open(hoverItem);
- that._moveHover(hoverItem, that._childPopupElement(hoverItem).children().first());
- } else {
- that._moveHover(hoverItem, that._findRootParent(hoverItem));
- }
- }
- } else if (key == keys.TAB) {
- target = that._findRootParent(hoverItem);
- that._moveHover(hoverItem, target);
- that._checkActiveElement();
- return;
- }
- if (target && target[0]) {
- e.preventDefault();
- e.stopPropagation();
- }
- },
- _hoverItem: function () {
- return this.wrapper.find('.k-item.k-state-hover,.k-item.k-state-focused').filter(':visible');
- },
- _itemBelongsToVertival: function (item) {
- var menuIsVertical = this.wrapper.hasClass('k-menu-vertical');
- if (!item.length) {
- return menuIsVertical;
- }
- return item.parent().hasClass('k-menu-group') || menuIsVertical;
- },
- _itemHasChildren: function (item) {
- if (!item || !item.length || !item[0].nodeType) {
- return false;
- }
- return item.children('.k-menu-group, div.k-animation-container').length > 0 || !!item.data(POPUP_OPENER_ATTR) && !!this._overflowWrapper().children(popupGroupSelector(item.data(POPUP_OPENER_ATTR)));
- },
- _moveHover: function (item, nextItem) {
- var that = this, id = that._ariaId;
- if (item.length && nextItem.length) {
- item.removeClass(FOCUSEDSTATE);
- }
- if (nextItem.length) {
- if (nextItem[0].id) {
- id = nextItem[0].id;
- }
- nextItem.addClass(FOCUSEDSTATE);
- that._oldHoverItem = nextItem;
- if (id) {
- that.element.removeAttr('aria-activedescendant');
- $('#' + id).removeAttr('id');
- nextItem.attr('id', id);
- that.element.attr('aria-activedescendant', id);
- }
- that._scrollToItem(nextItem);
- }
- },
- _findRootParent: function (item) {
- if (this._isRootItem(item)) {
- return item;
- } else {
- return this._parentsUntil(item, menuSelector, 'li.k-item').last();
- }
- },
- _isRootItem: function (item) {
- return item.parent().hasClass(MENU);
- },
- _itemRight: function (item, belongsToVertical, hasChildren) {
- var that = this, nextItem, parentItem, overflowWrapper;
- if (!belongsToVertical) {
- nextItem = item.nextAll(nextSelector);
- if (!nextItem.length) {
- nextItem = item.prevAll(lastSelector);
- }
- that.close(item);
- } else if (hasChildren && !item.hasClass(DISABLEDSTATE)) {
- that.open(item);
- nextItem = that._childPopupElement(item).children().first();
- } else if (that.options.orientation == 'horizontal') {
- parentItem = that._findRootParent(item);
- overflowWrapper = that._overflowWrapper();
- if (overflowWrapper) {
- var rootPopup = itemPopup(parentItem, overflowWrapper);
- that._closeChildPopups(rootPopup);
- }
- that.close(parentItem);
- nextItem = parentItem.nextAll(nextSelector);
- }
- if (nextItem && !nextItem.length) {
- nextItem = that.wrapper.children('.k-item').first();
- } else if (!nextItem) {
- nextItem = [];
- }
- that._moveHover(item, nextItem);
- return nextItem;
- },
- _itemLeft: function (item, belongsToVertical) {
- var that = this, nextItem, overflowWrapper;
- if (!belongsToVertical) {
- nextItem = item.prevAll(nextSelector);
- if (!nextItem.length) {
- nextItem = item.nextAll(lastSelector);
- }
- that.close(item);
- } else {
- nextItem = item.parent().closest('.k-item');
- overflowWrapper = that._overflowWrapper();
- if (!nextItem.length && overflowWrapper) {
- nextItem = popupParentItem(item.parent(), overflowWrapper);
- }
- that.close(nextItem);
- if (that._isRootItem(nextItem) && that.options.orientation == 'horizontal') {
- nextItem = nextItem.prevAll(nextSelector);
- }
- }
- if (!nextItem.length) {
- nextItem = that.wrapper.children('.k-item').last();
- }
- that._moveHover(item, nextItem);
- return nextItem;
- },
- _itemDown: function (item, belongsToVertical, hasChildren) {
- var that = this, nextItem;
- if (!belongsToVertical) {
- if (!hasChildren || item.hasClass(DISABLEDSTATE)) {
- return;
- } else {
- that.open(item);
- nextItem = that._childPopupElement(item).children().first();
- }
- } else {
- nextItem = item.nextAll(nextSelector);
- }
- if (!nextItem.length && item.length) {
- nextItem = item.parent().children().first();
- } else if (!item.length) {
- nextItem = that.wrapper.children('.k-item').first();
- }
- that._moveHover(item, nextItem);
- return nextItem;
- },
- _itemUp: function (item, belongsToVertical) {
- var that = this, nextItem;
- if (!belongsToVertical) {
- return;
- } else {
- nextItem = item.prevAll(nextSelector);
- }
- if (!nextItem.length && item.length) {
- nextItem = item.parent().children().last();
- } else if (!item.length) {
- nextItem = that.wrapper.children('.k-item').last();
- }
- that._moveHover(item, nextItem);
- return nextItem;
- },
- _scrollToItem: function (item) {
- var that = this;
- if (that.options.scrollable && item && item.length) {
- var ul = item.parent();
- var isHorizontal = ul.hasClass(MENU) ? that.options.orientation == 'horizontal' : false;
- var scrollDir = isHorizontal ? 'scrollLeft' : 'scrollTop';
- var getSize = isHorizontal ? kendo._outerWidth : kendo._outerHeight;
- var currentScrollOffset = ul[scrollDir]();
- var itemSize = getSize(item);
- var itemOffset = item[0][isHorizontal ? 'offsetLeft' : 'offsetTop'];
- var ulSize = getSize(ul);
- var scrollButtons = ul.siblings(scrollButtonSelector);
- var scrollButtonSize = scrollButtons.length ? getSize(scrollButtons.first()) : 0;
- var itemPosition;
- if (currentScrollOffset + ulSize < itemOffset + itemSize + scrollButtonSize) {
- itemPosition = itemOffset + itemSize - ulSize + scrollButtonSize;
- } else if (currentScrollOffset > itemOffset - scrollButtonSize) {
- itemPosition = itemOffset - scrollButtonSize;
- }
- if (!isNaN(itemPosition)) {
- var scrolling = {};
- scrolling[scrollDir] = itemPosition;
- ul.finish().animate(scrolling, 'fast', 'linear', function () {
- that._toggleScrollButtons(ul, scrollButtons.first(), scrollButtons.last(), isHorizontal);
- });
- }
- }
- },
- _itemEsc: function (item, belongsToVertical) {
- var that = this, nextItem;
- if (!belongsToVertical) {
- return item;
- } else {
- nextItem = item.parent().closest('.k-item');
- that.close(nextItem);
- that._moveHover(item, nextItem);
- }
- return nextItem;
- },
- _childPopupElement: function (item) {
- var popupElement = item.find('.k-menu-group');
- var wrapper = this._overflowWrapper();
- if (!popupElement.length && wrapper) {
- popupElement = itemPopup(item, wrapper);
- }
- return popupElement;
- },
- _triggerEvent: function (e) {
- var that = this;
- return that.trigger(e.type, {
- type: e.type,
- item: e.item
- });
- },
- _focusHandler: function (e) {
- var that = this, item = $(kendo.eventTarget(e)).closest(allItemsSelector);
- if (item.hasClass(DISABLEDSTATE)) {
- return;
- }
- setTimeout(function () {
- that._moveHover([], item);
- if (item.children('.k-content')[0]) {
- item.parent().closest('.k-item').removeClass(FOCUSEDSTATE);
- }
- }, 200);
- },
- _animations: function (options) {
- if (options && 'animation' in options && !options.animation) {
- options.animation = {
- open: { effects: {} },
- close: {
- hide: true,
- effects: {}
- }
- };
- }
- }
- });
- extend(Menu, {
- renderItem: function (options) {
- options = extend({
- menu: {},
- group: {}
- }, options);
- var empty = templates.empty, item = options.item;
- return templates.item(extend(options, {
- image: item.imageUrl ? templates.image : empty,
- sprite: item.spriteCssClass ? templates.sprite : empty,
- itemWrapper: templates.itemWrapper,
- renderContent: Menu.renderContent,
- arrow: item.items || item.content ? templates.arrow : empty,
- subGroup: Menu.renderGroup
- }, rendering));
- },
- renderGroup: function (options) {
- return templates.group(extend({
- renderItems: function (options) {
- var html = '', i = 0, items = options.items, len = items ? items.length : 0, group = extend({ length: len }, options.group);
- for (; i < len; i++) {
- html += Menu.renderItem(extend(options, {
- group: group,
- item: extend({ index: i }, items[i])
- }));
- }
- return html;
- }
- }, options, rendering));
- },
- renderContent: function (options) {
- return templates.content(extend(options, rendering));
- }
- });
- var ContextMenu = Menu.extend({
- init: function (element, options) {
- var that = this;
- Menu.fn.init.call(that, element, options);
- that._marker = kendo.guid().substring(0, 8);
- that.target = $(that.options.target);
- that._popup();
- that._wire();
- },
- _initOverflow: function (options) {
- var that = this;
- if (options.scrollable && !that._overflowWrapper()) {
- that._openedPopups = {};
- that._popupsWrapper = (that.element.parent().is(animationContainerSelector) ? that.element.parent() : that.element).wrap('').parent();
- if (that.options.orientation == 'horizontal') {
- removeSpacesBetweenItems(that.element);
- }
- if (options.appendTo) {
- options.appendTo.append(that._popupsWrapper);
- }
- that._initialHeight = that.element[0].style.height;
- that._initialWidth = that.element[0].style.width;
- }
- },
- options: {
- name: 'ContextMenu',
- filter: null,
- showOn: 'contextmenu',
- orientation: 'vertical',
- alignToAnchor: false,
- target: 'body'
- },
- events: [
- OPEN,
- CLOSE,
- ACTIVATE,
- DEACTIVATE,
- SELECT
- ],
- setOptions: function (options) {
- var that = this;
- Menu.fn.setOptions.call(that, options);
- that.target.off(that.showOn + NS + that._marker, that._showProxy);
- if (that.userEvents) {
- that.userEvents.destroy();
- }
- that.target = $(that.options.target);
- if (options.orientation && that.popup.wrapper[0]) {
- that.popup.element.unwrap();
- }
- that._wire();
- Menu.fn.setOptions.call(this, options);
- },
- destroy: function () {
- var that = this;
- that.target.off(that.options.showOn + NS + that._marker);
- DOCUMENT_ELEMENT.off(kendo.support.mousedown + NS + that._marker, that._closeProxy);
- if (that.userEvents) {
- that.userEvents.destroy();
- }
- Menu.fn.destroy.call(that);
- },
- open: function (x, y) {
- var that = this;
- x = $(x)[0];
- if (contains(that.element[0], $(x)[0]) || that._itemHasChildren($(x))) {
- Menu.fn.open.call(that, x);
- } else {
- if (that._triggerEvent({
- item: that.element,
- type: OPEN
- }) === false) {
- if (that.popup.visible() && that.options.filter) {
- that.popup.close(true);
- that.popup.element.kendoStop(true);
- }
- if (y !== undefined) {
- var overflowWrapper = that._overflowWrapper();
- if (overflowWrapper) {
- var offset = overflowWrapper.offset();
- x -= offset.left;
- y -= offset.top;
- }
- that.popup.wrapper.hide();
- that._configurePopupScrolling(x, y);
- that.popup.open(x, y);
- } else {
- that.popup.options.anchor = (x ? x : that.popup.anchor) || that.target;
- that.popup.element.kendoStop(true);
- that._configurePopupScrolling();
- that.popup.open();
- }
- DOCUMENT_ELEMENT.off(that.popup.downEvent, that.popup._mousedownProxy);
- DOCUMENT_ELEMENT.on(kendo.support.mousedown + NS + that._marker, that._closeProxy);
- }
- }
- return that;
- },
- _configurePopupScrolling: function (x, y) {
- var that = this;
- var popup = that.popup;
- var isHorizontal = that.options.orientation == 'horizontal';
- if (that.options.scrollable) {
- that._wrapPopupElement(popup);
- popup.element.parent().css({
- position: '',
- height: ''
- });
- popup.element.css({
- visibility: 'hidden',
- display: '',
- position: ''
- });
- if (isHorizontal) {
- that._setPopupWidth(popup, isNaN(x) ? undefined : {
- isFixed: true,
- x: x,
- y: y
- });
- } else {
- that._setPopupHeight(popup, isNaN(x) ? undefined : {
- isFixed: true,
- x: x,
- y: y
- });
- }
- popup.element.css({
- visibility: '',
- display: 'none',
- position: 'absolute'
- });
- that._initPopupScrollButtons(popup, isHorizontal, true);
- popup.element.siblings(scrollButtonSelector).hide();
- }
- },
- _setPopupWidth: function (popup, isFixed) {
- var popupElement = popup.element;
- var popups = popupElement.add(popupElement.parent(animationContainerSelector));
- popups.width(this._initialWidth || '');
- var location = popup._location(isFixed);
- var windowWidth = $(window).width();
- var popupOuterWidth = location.width;
- var popupOffsetLeft = Math.max(location.left, 0);
- var scrollLeft = isFixed ? 0 : parentsScroll(this._overflowWrapper()[0], 'scrollLeft');
- var shadow = kendo.getShadows(popupElement);
- var maxWidth = windowWidth - shadow.left - shadow.right;
- var canFit = maxWidth + scrollLeft > popupOuterWidth + popupOffsetLeft;
- if (!canFit) {
- popups.css({
- overflow: 'hidden',
- width: maxWidth - popupOffsetLeft + scrollLeft + 'px'
- });
- }
- },
- close: function () {
- var that = this;
- if (contains(that.element[0], $(arguments[0])[0]) || that._itemHasChildren(arguments[0])) {
- Menu.fn.close.call(that, arguments[0]);
- } else {
- if (that.popup.visible()) {
- if (that._triggerEvent({
- item: that.element,
- type: CLOSE
- }) === false) {
- that.popup.close();
- DOCUMENT_ELEMENT.off(kendo.support.mousedown + NS + that._marker, that._closeProxy);
- that.unbind(SELECT, that._closeTimeoutProxy);
- }
- }
- }
- },
- _showHandler: function (e) {
- var ev = e, offset, that = this, options = that.options, target = $(ev.currentTarget);
- if (e.event) {
- ev = e.event;
- ev.pageX = e.x.location;
- ev.pageY = e.y.location;
- }
- if (contains(that.element[0], e.relatedTarget || e.target)) {
- return;
- }
- that._eventOrigin = ev;
- ev.preventDefault();
- ev.stopImmediatePropagation();
- that.element.find('.' + FOCUSEDSTATE).removeClass(FOCUSEDSTATE);
- if (options.filter && target.is(options.filter) || !options.filter) {
- if (options.alignToAnchor) {
- that.popup.options.anchor = ev.currentTarget;
- that.open(ev.currentTarget);
- } else {
- that.popup.options.anchor = ev.currentTarget;
- if (that._targetChild) {
- offset = that.target.offset();
- that.open(ev.pageX - offset.left, ev.pageY - offset.top);
- } else {
- that.open(ev.pageX, ev.pageY);
- }
- }
- }
- },
- _closeHandler: function (e) {
- var that = this, target = $(e.relatedTarget || e.target), sameTarget = target.closest(that.target.selector)[0] == that.target[0], item = target.closest(itemSelector), children = that._itemHasChildren(item), overflowWrapper = that._overflowWrapper(), containment = contains(that.element[0], target[0]) || overflowWrapper && contains(overflowWrapper[0], target[0]);
- that._eventOrigin = e;
- var normalClick = e.which !== 3;
- if (that.popup.visible() && (normalClick && sameTarget || !sameTarget) && (that.options.closeOnClick && !children && containment || !containment)) {
- if (containment) {
- this.unbind(SELECT, this._closeTimeoutProxy);
- that.bind(SELECT, that._closeTimeoutProxy);
- } else {
- that.close();
- }
- }
- },
- _wire: function () {
- var that = this, options = that.options, target = that.target;
- that._showProxy = proxy(that._showHandler, that);
- that._closeProxy = proxy(that._closeHandler, that);
- that._closeTimeoutProxy = proxy(that.close, that);
- if (target[0]) {
- if (kendo.support.mobileOS && options.showOn == 'contextmenu') {
- that.userEvents = new kendo.UserEvents(target, {
- filter: options.filter,
- allowSelection: false
- });
- target.on(options.showOn + NS + that._marker, false);
- that.userEvents.bind('hold', that._showProxy);
- } else {
- if (options.filter) {
- target.on(options.showOn + NS + that._marker, options.filter, that._showProxy);
- } else {
- target.on(options.showOn + NS + that._marker, that._showProxy);
- }
- }
- }
- },
- _triggerEvent: function (e) {
- var that = this, anchor = $(that.popup.options.anchor)[0], origin = that._eventOrigin;
- that._eventOrigin = undefined;
- return that.trigger(e.type, extend({
- type: e.type,
- item: e.item || this.element[0],
- target: anchor
- }, origin ? { event: origin } : {}));
- },
- _popup: function () {
- var that = this;
- var overflowWrapper = that._overflowWrapper();
- that._triggerProxy = proxy(that._triggerEvent, that);
- that.popup = that.element.addClass('k-context-menu').kendoPopup({
- autosize: true,
- anchor: that.target || 'body',
- copyAnchorStyles: that.options.copyAnchorStyles,
- collision: that.options.popupCollision || 'fit',
- animation: that.options.animation,
- activate: that._triggerProxy,
- deactivate: that._triggerProxy,
- appendTo: overflowWrapper || that.options.appendTo,
- close: !overflowWrapper ? $.noop : function (e) {
- $(getChildPopups(e.sender.element, overflowWrapper)).each(function (i, p) {
- var popup = p.data(KENDOPOPUP);
- if (popup) {
- popup.close(true);
- }
- });
- }
- }).data(KENDOPOPUP);
- that._targetChild = contains(that.target[0], that.popup.element[0]);
- }
- });
- ui.plugin(Menu);
- ui.plugin(ContextMenu);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.draganddrop', [
- 'kendo.core',
- 'kendo.userevents'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'draganddrop',
- name: 'Drag & drop',
- category: 'framework',
- description: 'Drag & drop functionality for any DOM element.',
- depends: [
- 'core',
- 'userevents'
- ]
- };
- (function ($, undefined) {
- var kendo = window.kendo, support = kendo.support, document = window.document, $window = $(window), Class = kendo.Class, Widget = kendo.ui.Widget, Observable = kendo.Observable, UserEvents = kendo.UserEvents, proxy = $.proxy, extend = $.extend, getOffset = kendo.getOffset, draggables = {}, dropTargets = {}, dropAreas = {}, lastDropTarget, elementUnderCursor = kendo.elementUnderCursor, KEYUP = 'keyup', CHANGE = 'change', DRAGSTART = 'dragstart', HOLD = 'hold', DRAG = 'drag', DRAGEND = 'dragend', DRAGCANCEL = 'dragcancel', HINTDESTROYED = 'hintDestroyed', DRAGENTER = 'dragenter', DRAGLEAVE = 'dragleave', DROP = 'drop';
- function contains(parent, child) {
- try {
- return $.contains(parent, child) || parent == child;
- } catch (e) {
- return false;
- }
- }
- function numericCssPropery(element, property) {
- return parseInt(element.css(property), 10) || 0;
- }
- function within(value, range) {
- return Math.min(Math.max(value, range.min), range.max);
- }
- function containerBoundaries(container, element) {
- var offset = getOffset(container), outerWidth = kendo._outerWidth, outerHeight = kendo._outerHeight, minX = offset.left + numericCssPropery(container, 'borderLeftWidth') + numericCssPropery(container, 'paddingLeft'), minY = offset.top + numericCssPropery(container, 'borderTopWidth') + numericCssPropery(container, 'paddingTop'), maxX = minX + container.width() - outerWidth(element, true), maxY = minY + container.height() - outerHeight(element, true);
- return {
- x: {
- min: minX,
- max: maxX
- },
- y: {
- min: minY,
- max: maxY
- }
- };
- }
- function checkTarget(target, targets, areas) {
- var theTarget, theFilter, i = 0, targetLen = targets && targets.length, areaLen = areas && areas.length;
- while (target && target.parentNode) {
- for (i = 0; i < targetLen; i++) {
- theTarget = targets[i];
- if (theTarget.element[0] === target) {
- return {
- target: theTarget,
- targetElement: target
- };
- }
- }
- for (i = 0; i < areaLen; i++) {
- theFilter = areas[i];
- if ($.contains(theFilter.element[0], target) && support.matchesSelector.call(target, theFilter.options.filter)) {
- return {
- target: theFilter,
- targetElement: target
- };
- }
- }
- target = target.parentNode;
- }
- return undefined;
- }
- var TapCapture = Observable.extend({
- init: function (element, options) {
- var that = this, domElement = element[0];
- that.capture = false;
- if (domElement.addEventListener) {
- $.each(kendo.eventMap.down.split(' '), function () {
- domElement.addEventListener(this, proxy(that._press, that), true);
- });
- $.each(kendo.eventMap.up.split(' '), function () {
- domElement.addEventListener(this, proxy(that._release, that), true);
- });
- } else {
- $.each(kendo.eventMap.down.split(' '), function () {
- domElement.attachEvent(this, proxy(that._press, that));
- });
- $.each(kendo.eventMap.up.split(' '), function () {
- domElement.attachEvent(this, proxy(that._release, that));
- });
- }
- Observable.fn.init.call(that);
- that.bind([
- 'press',
- 'release'
- ], options || {});
- },
- captureNext: function () {
- this.capture = true;
- },
- cancelCapture: function () {
- this.capture = false;
- },
- _press: function (e) {
- var that = this;
- that.trigger('press');
- if (that.capture) {
- e.preventDefault();
- }
- },
- _release: function (e) {
- var that = this;
- that.trigger('release');
- if (that.capture) {
- e.preventDefault();
- that.cancelCapture();
- }
- }
- });
- var PaneDimension = Observable.extend({
- init: function (options) {
- var that = this;
- Observable.fn.init.call(that);
- that.forcedEnabled = false;
- $.extend(that, options);
- that.scale = 1;
- if (that.horizontal) {
- that.measure = 'offsetWidth';
- that.scrollSize = 'scrollWidth';
- that.axis = 'x';
- } else {
- that.measure = 'offsetHeight';
- that.scrollSize = 'scrollHeight';
- that.axis = 'y';
- }
- },
- makeVirtual: function () {
- $.extend(this, {
- virtual: true,
- forcedEnabled: true,
- _virtualMin: 0,
- _virtualMax: 0
- });
- },
- virtualSize: function (min, max) {
- if (this._virtualMin !== min || this._virtualMax !== max) {
- this._virtualMin = min;
- this._virtualMax = max;
- this.update();
- }
- },
- outOfBounds: function (offset) {
- return offset > this.max || offset < this.min;
- },
- forceEnabled: function () {
- this.forcedEnabled = true;
- },
- getSize: function () {
- return this.container[0][this.measure];
- },
- getTotal: function () {
- return this.element[0][this.scrollSize];
- },
- rescale: function (scale) {
- this.scale = scale;
- },
- update: function (silent) {
- var that = this, total = that.virtual ? that._virtualMax : that.getTotal(), scaledTotal = total * that.scale, size = that.getSize();
- if (total === 0 && !that.forcedEnabled) {
- return;
- }
- that.max = that.virtual ? -that._virtualMin : 0;
- that.size = size;
- that.total = scaledTotal;
- that.min = Math.min(that.max, size - scaledTotal);
- that.minScale = size / total;
- that.centerOffset = (scaledTotal - size) / 2;
- that.enabled = that.forcedEnabled || scaledTotal > size;
- if (!silent) {
- that.trigger(CHANGE, that);
- }
- }
- });
- var PaneDimensions = Observable.extend({
- init: function (options) {
- var that = this;
- Observable.fn.init.call(that);
- that.x = new PaneDimension(extend({ horizontal: true }, options));
- that.y = new PaneDimension(extend({ horizontal: false }, options));
- that.container = options.container;
- that.forcedMinScale = options.minScale;
- that.maxScale = options.maxScale || 100;
- that.bind(CHANGE, options);
- },
- rescale: function (newScale) {
- this.x.rescale(newScale);
- this.y.rescale(newScale);
- this.refresh();
- },
- centerCoordinates: function () {
- return {
- x: Math.min(0, -this.x.centerOffset),
- y: Math.min(0, -this.y.centerOffset)
- };
- },
- refresh: function () {
- var that = this;
- that.x.update();
- that.y.update();
- that.enabled = that.x.enabled || that.y.enabled;
- that.minScale = that.forcedMinScale || Math.min(that.x.minScale, that.y.minScale);
- that.fitScale = Math.max(that.x.minScale, that.y.minScale);
- that.trigger(CHANGE);
- }
- });
- var PaneAxis = Observable.extend({
- init: function (options) {
- var that = this;
- extend(that, options);
- Observable.fn.init.call(that);
- },
- outOfBounds: function () {
- return this.dimension.outOfBounds(this.movable[this.axis]);
- },
- dragMove: function (delta) {
- var that = this, dimension = that.dimension, axis = that.axis, movable = that.movable, position = movable[axis] + delta;
- if (!dimension.enabled) {
- return;
- }
- if (position < dimension.min && delta < 0 || position > dimension.max && delta > 0) {
- delta *= that.resistance;
- }
- movable.translateAxis(axis, delta);
- that.trigger(CHANGE, that);
- }
- });
- var Pane = Class.extend({
- init: function (options) {
- var that = this, x, y, resistance, movable;
- extend(that, { elastic: true }, options);
- resistance = that.elastic ? 0.5 : 0;
- movable = that.movable;
- that.x = x = new PaneAxis({
- axis: 'x',
- dimension: that.dimensions.x,
- resistance: resistance,
- movable: movable
- });
- that.y = y = new PaneAxis({
- axis: 'y',
- dimension: that.dimensions.y,
- resistance: resistance,
- movable: movable
- });
- that.userEvents.bind([
- 'press',
- 'move',
- 'end',
- 'gesturestart',
- 'gesturechange'
- ], {
- gesturestart: function (e) {
- that.gesture = e;
- that.offset = that.dimensions.container.offset();
- },
- press: function (e) {
- if ($(e.event.target).closest('a').is('[data-navigate-on-press=true]')) {
- e.sender.cancel();
- }
- },
- gesturechange: function (e) {
- var previousGesture = that.gesture, previousCenter = previousGesture.center, center = e.center, scaleDelta = e.distance / previousGesture.distance, minScale = that.dimensions.minScale, maxScale = that.dimensions.maxScale, coordinates;
- if (movable.scale <= minScale && scaleDelta < 1) {
- scaleDelta += (1 - scaleDelta) * 0.8;
- }
- if (movable.scale * scaleDelta >= maxScale) {
- scaleDelta = maxScale / movable.scale;
- }
- var offsetX = movable.x + that.offset.left, offsetY = movable.y + that.offset.top;
- coordinates = {
- x: (offsetX - previousCenter.x) * scaleDelta + center.x - offsetX,
- y: (offsetY - previousCenter.y) * scaleDelta + center.y - offsetY
- };
- movable.scaleWith(scaleDelta);
- x.dragMove(coordinates.x);
- y.dragMove(coordinates.y);
- that.dimensions.rescale(movable.scale);
- that.gesture = e;
- e.preventDefault();
- },
- move: function (e) {
- if (e.event.target.tagName.match(/textarea|input/i)) {
- return;
- }
- if (x.dimension.enabled || y.dimension.enabled) {
- x.dragMove(e.x.delta);
- y.dragMove(e.y.delta);
- e.preventDefault();
- } else {
- e.touch.skip();
- }
- },
- end: function (e) {
- e.preventDefault();
- }
- });
- }
- });
- var TRANSFORM_STYLE = support.transitions.prefix + 'Transform', translate;
- if (support.hasHW3D) {
- translate = function (x, y, scale) {
- return 'translate3d(' + x + 'px,' + y + 'px,0) scale(' + scale + ')';
- };
- } else {
- translate = function (x, y, scale) {
- return 'translate(' + x + 'px,' + y + 'px) scale(' + scale + ')';
- };
- }
- var Movable = Observable.extend({
- init: function (element) {
- var that = this;
- Observable.fn.init.call(that);
- that.element = $(element);
- that.element[0].style.webkitTransformOrigin = 'left top';
- that.x = 0;
- that.y = 0;
- that.scale = 1;
- that._saveCoordinates(translate(that.x, that.y, that.scale));
- },
- translateAxis: function (axis, by) {
- this[axis] += by;
- this.refresh();
- },
- scaleTo: function (scale) {
- this.scale = scale;
- this.refresh();
- },
- scaleWith: function (scaleDelta) {
- this.scale *= scaleDelta;
- this.refresh();
- },
- translate: function (coordinates) {
- this.x += coordinates.x;
- this.y += coordinates.y;
- this.refresh();
- },
- moveAxis: function (axis, value) {
- this[axis] = value;
- this.refresh();
- },
- moveTo: function (coordinates) {
- extend(this, coordinates);
- this.refresh();
- },
- refresh: function () {
- var that = this, x = that.x, y = that.y, newCoordinates;
- if (that.round) {
- x = Math.round(x);
- y = Math.round(y);
- }
- newCoordinates = translate(x, y, that.scale);
- if (newCoordinates != that.coordinates) {
- if (kendo.support.browser.msie && kendo.support.browser.version < 10) {
- that.element[0].style.position = 'absolute';
- that.element[0].style.left = that.x + 'px';
- that.element[0].style.top = that.y + 'px';
- } else {
- that.element[0].style[TRANSFORM_STYLE] = newCoordinates;
- }
- that._saveCoordinates(newCoordinates);
- that.trigger(CHANGE);
- }
- },
- _saveCoordinates: function (coordinates) {
- this.coordinates = coordinates;
- }
- });
- function destroyDroppable(collection, widget) {
- var groupName = widget.options.group, droppables = collection[groupName], i;
- Widget.fn.destroy.call(widget);
- if (droppables.length > 1) {
- for (i = 0; i < droppables.length; i++) {
- if (droppables[i] == widget) {
- droppables.splice(i, 1);
- break;
- }
- }
- } else {
- droppables.length = 0;
- delete collection[groupName];
- }
- }
- var DropTarget = Widget.extend({
- init: function (element, options) {
- var that = this;
- Widget.fn.init.call(that, element, options);
- var group = that.options.group;
- if (!(group in dropTargets)) {
- dropTargets[group] = [that];
- } else {
- dropTargets[group].push(that);
- }
- },
- events: [
- DRAGENTER,
- DRAGLEAVE,
- DROP
- ],
- options: {
- name: 'DropTarget',
- group: 'default'
- },
- destroy: function () {
- destroyDroppable(dropTargets, this);
- },
- _trigger: function (eventName, e) {
- var that = this, draggable = draggables[that.options.group];
- if (draggable) {
- return that.trigger(eventName, extend({}, e.event, {
- draggable: draggable,
- dropTarget: e.dropTarget
- }));
- }
- },
- _over: function (e) {
- this._trigger(DRAGENTER, e);
- },
- _out: function (e) {
- this._trigger(DRAGLEAVE, e);
- },
- _drop: function (e) {
- var that = this, draggable = draggables[that.options.group];
- if (draggable) {
- draggable.dropped = !that._trigger(DROP, e);
- }
- }
- });
- DropTarget.destroyGroup = function (groupName) {
- var group = dropTargets[groupName] || dropAreas[groupName], i;
- if (group) {
- for (i = 0; i < group.length; i++) {
- Widget.fn.destroy.call(group[i]);
- }
- group.length = 0;
- delete dropTargets[groupName];
- delete dropAreas[groupName];
- }
- };
- DropTarget._cache = dropTargets;
- var DropTargetArea = DropTarget.extend({
- init: function (element, options) {
- var that = this;
- Widget.fn.init.call(that, element, options);
- var group = that.options.group;
- if (!(group in dropAreas)) {
- dropAreas[group] = [that];
- } else {
- dropAreas[group].push(that);
- }
- },
- destroy: function () {
- destroyDroppable(dropAreas, this);
- },
- options: {
- name: 'DropTargetArea',
- group: 'default',
- filter: null
- }
- });
- var Draggable = Widget.extend({
- init: function (element, options) {
- var that = this;
- Widget.fn.init.call(that, element, options);
- that._activated = false;
- that.userEvents = new UserEvents(that.element, {
- global: true,
- allowSelection: true,
- filter: that.options.filter,
- threshold: that.options.distance,
- start: proxy(that._start, that),
- hold: proxy(that._hold, that),
- move: proxy(that._drag, that),
- end: proxy(that._end, that),
- cancel: proxy(that._cancel, that),
- select: proxy(that._select, that)
- });
- that._afterEndHandler = proxy(that._afterEnd, that);
- that._captureEscape = proxy(that._captureEscape, that);
- },
- events: [
- HOLD,
- DRAGSTART,
- DRAG,
- DRAGEND,
- DRAGCANCEL,
- HINTDESTROYED
- ],
- options: {
- name: 'Draggable',
- distance: kendo.support.touch ? 0 : 5,
- group: 'default',
- cursorOffset: null,
- axis: null,
- container: null,
- filter: null,
- ignore: null,
- holdToDrag: false,
- autoScroll: false,
- dropped: false
- },
- cancelHold: function () {
- this._activated = false;
- },
- _captureEscape: function (e) {
- var that = this;
- if (e.keyCode === kendo.keys.ESC) {
- that._trigger(DRAGCANCEL, { event: e });
- that.userEvents.cancel();
- }
- },
- _updateHint: function (e) {
- var that = this, coordinates, options = that.options, boundaries = that.boundaries, axis = options.axis, cursorOffset = that.options.cursorOffset;
- if (cursorOffset) {
- coordinates = {
- left: e.x.location + cursorOffset.left,
- top: e.y.location + cursorOffset.top
- };
- } else {
- that.hintOffset.left += e.x.delta;
- that.hintOffset.top += e.y.delta;
- coordinates = $.extend({}, that.hintOffset);
- }
- if (boundaries) {
- coordinates.top = within(coordinates.top, boundaries.y);
- coordinates.left = within(coordinates.left, boundaries.x);
- }
- if (axis === 'x') {
- delete coordinates.top;
- } else if (axis === 'y') {
- delete coordinates.left;
- }
- that.hint.css(coordinates);
- },
- _shouldIgnoreTarget: function (target) {
- var ignoreSelector = this.options.ignore;
- return ignoreSelector && $(target).is(ignoreSelector);
- },
- _select: function (e) {
- if (!this._shouldIgnoreTarget(e.event.target)) {
- e.preventDefault();
- }
- },
- _start: function (e) {
- var that = this, options = that.options, container = options.container ? $(options.container) : null, hint = options.hint;
- if (this._shouldIgnoreTarget(e.touch.initialTouch) || options.holdToDrag && !that._activated) {
- that.userEvents.cancel();
- return;
- }
- that.currentTarget = e.target;
- that.currentTargetOffset = getOffset(that.currentTarget);
- if (hint) {
- if (that.hint) {
- that.hint.stop(true, true).remove();
- }
- that.hint = kendo.isFunction(hint) ? $(hint.call(that, that.currentTarget)) : hint;
- var offset = getOffset(that.currentTarget);
- that.hintOffset = offset;
- that.hint.css({
- position: 'absolute',
- zIndex: 20000,
- left: offset.left,
- top: offset.top
- }).appendTo(document.body);
- that.angular('compile', function () {
- that.hint.removeAttr('ng-repeat');
- var scopeTarget = $(e.target);
- while (!scopeTarget.data('$$kendoScope') && scopeTarget.length) {
- scopeTarget = scopeTarget.parent();
- }
- return {
- elements: that.hint.get(),
- scopeFrom: scopeTarget.data('$$kendoScope')
- };
- });
- }
- draggables[options.group] = that;
- that.dropped = false;
- if (container) {
- that.boundaries = containerBoundaries(container, that.hint);
- }
- $(document).on(KEYUP, that._captureEscape);
- if (that._trigger(DRAGSTART, e)) {
- that.userEvents.cancel();
- that._afterEnd();
- }
- that.userEvents.capture();
- },
- _hold: function (e) {
- this.currentTarget = e.target;
- if (this._trigger(HOLD, e)) {
- this.userEvents.cancel();
- } else {
- this._activated = true;
- }
- },
- _drag: function (e) {
- e.preventDefault();
- var cursorElement = this._elementUnderCursor(e);
- if (this.options.autoScroll && this._cursorElement !== cursorElement) {
- this._scrollableParent = findScrollableParent(cursorElement);
- this._cursorElement = cursorElement;
- }
- this._lastEvent = e;
- this._processMovement(e, cursorElement);
- if (this.options.autoScroll) {
- if (this._scrollableParent[0]) {
- var velocity = autoScrollVelocity(e.x.location, e.y.location, scrollableViewPort(this._scrollableParent));
- this._scrollCompenstation = $.extend({}, this.hintOffset);
- this._scrollVelocity = velocity;
- if (velocity.y === 0 && velocity.x === 0) {
- clearInterval(this._scrollInterval);
- this._scrollInterval = null;
- } else if (!this._scrollInterval) {
- this._scrollInterval = setInterval($.proxy(this, '_autoScroll'), 50);
- }
- }
- }
- if (this.hint) {
- this._updateHint(e);
- }
- },
- _processMovement: function (e, cursorElement) {
- this._withDropTarget(cursorElement, function (target, targetElement) {
- if (!target) {
- if (lastDropTarget) {
- lastDropTarget._trigger(DRAGLEAVE, extend(e, { dropTarget: $(lastDropTarget.targetElement) }));
- lastDropTarget = null;
- }
- return;
- }
- if (lastDropTarget) {
- if (targetElement === lastDropTarget.targetElement) {
- return;
- }
- lastDropTarget._trigger(DRAGLEAVE, extend(e, { dropTarget: $(lastDropTarget.targetElement) }));
- }
- target._trigger(DRAGENTER, extend(e, { dropTarget: $(targetElement) }));
- lastDropTarget = extend(target, { targetElement: targetElement });
- });
- this._trigger(DRAG, extend(e, {
- dropTarget: lastDropTarget,
- elementUnderCursor: cursorElement
- }));
- },
- _autoScroll: function () {
- var parent = this._scrollableParent[0], velocity = this._scrollVelocity, compensation = this._scrollCompenstation;
- if (!parent) {
- return;
- }
- var cursorElement = this._elementUnderCursor(this._lastEvent);
- this._processMovement(this._lastEvent, cursorElement);
- var yIsScrollable, xIsScrollable;
- var isRootNode = parent === scrollableRoot()[0];
- if (isRootNode) {
- yIsScrollable = document.body.scrollHeight > $window.height();
- xIsScrollable = document.body.scrollWidth > $window.width();
- } else {
- yIsScrollable = parent.offsetHeight <= parent.scrollHeight;
- xIsScrollable = parent.offsetWidth <= parent.scrollWidth;
- }
- var yDelta = parent.scrollTop + velocity.y;
- var yInBounds = yIsScrollable && yDelta > 0 && yDelta < parent.scrollHeight;
- var xDelta = parent.scrollLeft + velocity.x;
- var xInBounds = xIsScrollable && xDelta > 0 && xDelta < parent.scrollWidth;
- if (yInBounds) {
- parent.scrollTop += velocity.y;
- }
- if (xInBounds) {
- parent.scrollLeft += velocity.x;
- }
- if (this.hint && isRootNode && (xInBounds || yInBounds)) {
- if (yInBounds) {
- compensation.top += velocity.y;
- }
- if (xInBounds) {
- compensation.left += velocity.x;
- }
- this.hint.css(compensation);
- }
- },
- _end: function (e) {
- this._withDropTarget(this._elementUnderCursor(e), function (target, targetElement) {
- if (target) {
- target._drop(extend({}, e, { dropTarget: $(targetElement) }));
- lastDropTarget = null;
- }
- });
- this._cancel(this._trigger(DRAGEND, e));
- },
- _cancel: function (isDefaultPrevented) {
- var that = this;
- that._scrollableParent = null;
- this._cursorElement = null;
- clearInterval(this._scrollInterval);
- that._activated = false;
- if (that.hint && !that.dropped) {
- setTimeout(function () {
- that.hint.stop(true, true);
- if (isDefaultPrevented) {
- that._afterEndHandler();
- } else {
- that.hint.animate(that.currentTargetOffset, 'fast', that._afterEndHandler);
- }
- }, 0);
- } else {
- that._afterEnd();
- }
- },
- _trigger: function (eventName, e) {
- var that = this;
- return that.trigger(eventName, extend({}, e.event, {
- x: e.x,
- y: e.y,
- currentTarget: that.currentTarget,
- initialTarget: e.touch ? e.touch.initialTouch : null,
- dropTarget: e.dropTarget,
- elementUnderCursor: e.elementUnderCursor
- }));
- },
- _elementUnderCursor: function (e) {
- var target = elementUnderCursor(e), hint = this.hint;
- if (hint && contains(hint[0], target)) {
- hint.hide();
- target = elementUnderCursor(e);
- if (!target) {
- target = elementUnderCursor(e);
- }
- hint.show();
- }
- return target;
- },
- _withDropTarget: function (element, callback) {
- var result, group = this.options.group, targets = dropTargets[group], areas = dropAreas[group];
- if (targets && targets.length || areas && areas.length) {
- result = checkTarget(element, targets, areas);
- if (result) {
- callback(result.target, result.targetElement);
- } else {
- callback();
- }
- }
- },
- destroy: function () {
- var that = this;
- Widget.fn.destroy.call(that);
- that._afterEnd();
- that.userEvents.destroy();
- this._scrollableParent = null;
- this._cursorElement = null;
- clearInterval(this._scrollInterval);
- that.currentTarget = null;
- },
- _afterEnd: function () {
- var that = this;
- if (that.hint) {
- that.hint.remove();
- }
- delete draggables[that.options.group];
- that.trigger('destroy');
- that.trigger(HINTDESTROYED);
- $(document).off(KEYUP, that._captureEscape);
- }
- });
- kendo.ui.plugin(DropTarget);
- kendo.ui.plugin(DropTargetArea);
- kendo.ui.plugin(Draggable);
- kendo.TapCapture = TapCapture;
- kendo.containerBoundaries = containerBoundaries;
- extend(kendo.ui, {
- Pane: Pane,
- PaneDimensions: PaneDimensions,
- Movable: Movable
- });
- function scrollableViewPort(element) {
- var root = scrollableRoot()[0], offset, top, left;
- if (element[0] === root) {
- top = root.scrollTop;
- left = root.scrollLeft;
- return {
- top: top,
- left: left,
- bottom: top + $window.height(),
- right: left + $window.width()
- };
- } else {
- offset = element.offset();
- offset.bottom = offset.top + element.height();
- offset.right = offset.left + element.width();
- return offset;
- }
- }
- function scrollableRoot() {
- return $(kendo.support.browser.edge || kendo.support.browser.safari ? document.body : document.documentElement);
- }
- function findScrollableParent(element) {
- var root = scrollableRoot();
- if (!element || element === document.body || element === document.documentElement) {
- return root;
- }
- var parent = $(element)[0];
- while (parent && !kendo.isScrollable(parent) && parent !== document.body) {
- parent = parent.parentNode;
- }
- if (parent === document.body) {
- return root;
- }
- return $(parent);
- }
- function autoScrollVelocity(mouseX, mouseY, rect) {
- var velocity = {
- x: 0,
- y: 0
- };
- var AUTO_SCROLL_AREA = 50;
- if (mouseX - rect.left < AUTO_SCROLL_AREA) {
- velocity.x = -(AUTO_SCROLL_AREA - (mouseX - rect.left));
- } else if (rect.right - mouseX < AUTO_SCROLL_AREA) {
- velocity.x = AUTO_SCROLL_AREA - (rect.right - mouseX);
- }
- if (mouseY - rect.top < AUTO_SCROLL_AREA) {
- velocity.y = -(AUTO_SCROLL_AREA - (mouseY - rect.top));
- } else if (rect.bottom - mouseY < AUTO_SCROLL_AREA) {
- velocity.y = AUTO_SCROLL_AREA - (rect.bottom - mouseY);
- }
- return velocity;
- }
- kendo.ui.Draggable.utils = {
- autoScrollVelocity: autoScrollVelocity,
- scrollableViewPort: scrollableViewPort,
- findScrollableParent: findScrollableParent
- };
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.slider', ['kendo.draganddrop'], f);
-}(function () {
- var __meta__ = {
- id: 'slider',
- name: 'Slider',
- category: 'web',
- description: 'The Slider widget provides a rich input for selecting values or ranges of values.',
- depends: ['draganddrop']
- };
- (function ($, undefined) {
- var kendo = window.kendo, Widget = kendo.ui.Widget, Draggable = kendo.ui.Draggable, outerWidth = kendo._outerWidth, outerHeight = kendo._outerHeight, extend = $.extend, format = kendo.format, parse = kendo.parseFloat, proxy = $.proxy, isArray = $.isArray, math = Math, support = kendo.support, pointers = support.pointers, msPointers = support.msPointers, CHANGE = 'change', SLIDE = 'slide', NS = '.slider', MOUSE_DOWN = 'touchstart' + NS + ' mousedown' + NS, TRACK_MOUSE_DOWN = pointers ? 'pointerdown' + NS : msPointers ? 'MSPointerDown' + NS : MOUSE_DOWN, MOUSE_UP = 'touchend' + NS + ' mouseup' + NS, TRACK_MOUSE_UP = pointers ? 'pointerup' : msPointers ? 'MSPointerUp' + NS : MOUSE_UP, MOVE_SELECTION = 'moveSelection', KEY_DOWN = 'keydown' + NS, CLICK = 'click' + NS, MOUSE_OVER = 'mouseover' + NS, FOCUS = 'focus' + NS, BLUR = 'blur' + NS, DRAG_HANDLE = '.k-draghandle', TRACK_SELECTOR = '.k-slider-track', TICK_SELECTOR = '.k-tick', STATE_SELECTED = 'k-state-selected', STATE_FOCUSED = 'k-state-focused', STATE_DEFAULT = 'k-state-default', STATE_DISABLED = 'k-state-disabled', DISABLED = 'disabled', UNDEFINED = 'undefined', TABINDEX = 'tabindex', getTouches = kendo.getTouches;
- var SliderBase = Widget.extend({
- init: function (element, options) {
- var that = this;
- Widget.fn.init.call(that, element, options);
- options = that.options;
- that._isHorizontal = options.orientation == 'horizontal';
- that._isRtl = that._isHorizontal && kendo.support.isRtl(element);
- that._position = that._isHorizontal ? 'left' : 'bottom';
- that._sizeFn = that._isHorizontal ? 'width' : 'height';
- that._outerSize = that._isHorizontal ? outerWidth : outerHeight;
- options.tooltip.format = options.tooltip.enabled ? options.tooltip.format || '{0}' : '{0}';
- if (options.smallStep <= 0) {
- throw new Error('Kendo UI Slider smallStep must be a positive number.');
- }
- that._createHtml();
- that.wrapper = that.element.closest('.k-slider');
- that._trackDiv = that.wrapper.find(TRACK_SELECTOR);
- that._setTrackDivWidth();
- that._maxSelection = that._trackDiv[that._sizeFn]();
- that._sliderItemsInit();
- that._reset();
- that._tabindex(that.wrapper.find(DRAG_HANDLE));
- that[options.enabled ? 'enable' : 'disable']();
- var rtlDirectionSign = kendo.support.isRtl(that.wrapper) ? -1 : 1;
- that._keyMap = {
- 37: step(-1 * rtlDirectionSign * options.smallStep),
- 40: step(-options.smallStep),
- 39: step(+1 * rtlDirectionSign * options.smallStep),
- 38: step(+options.smallStep),
- 35: setValue(options.max),
- 36: setValue(options.min),
- 33: step(+options.largeStep),
- 34: step(-options.largeStep)
- };
- kendo.notify(that);
- },
- events: [
- CHANGE,
- SLIDE
- ],
- options: {
- enabled: true,
- min: 0,
- max: 10,
- smallStep: 1,
- largeStep: 5,
- orientation: 'horizontal',
- tickPlacement: 'both',
- tooltip: {
- enabled: true,
- format: '{0}'
- }
- },
- _distance: function () {
- return round(this.options.max - this.options.min);
- },
- _resize: function () {
- this._setTrackDivWidth();
- this.wrapper.find('.k-slider-items').remove();
- this._maxSelection = this._trackDiv[this._sizeFn]();
- this._sliderItemsInit();
- this._refresh();
- if (this.options.enabled) {
- this.enable(true);
- }
- },
- _sliderItemsInit: function () {
- var that = this, options = that.options;
- var sizeBetweenTicks = that._maxSelection / ((options.max - options.min) / options.smallStep);
- var pixelWidths = that._calculateItemsWidth(math.floor(that._distance() / options.smallStep));
- if (options.tickPlacement != 'none' && sizeBetweenTicks >= 2) {
- $(this.element).parent().find('.k-slider-items').remove();
- that._trackDiv.before(createSliderItems(options, that._distance()));
- that._setItemsWidth(pixelWidths);
- that._setItemsTitle();
- }
- that._calculateSteps(pixelWidths);
- if (options.tickPlacement != 'none' && sizeBetweenTicks >= 2 && options.largeStep >= options.smallStep) {
- that._setItemsLargeTick();
- }
- },
- getSize: function () {
- return kendo.dimensions(this.wrapper);
- },
- _setTrackDivWidth: function () {
- var that = this, trackDivPosition = parseFloat(that._trackDiv.css(that._isRtl ? 'right' : that._position), 10) * 2;
- that._trackDiv[that._sizeFn](that.wrapper[that._sizeFn]() - 2 - trackDivPosition);
- },
- _setItemsWidth: function (pixelWidths) {
- var that = this, options = that.options, first = 0, last = pixelWidths.length - 1, items = that.wrapper.find(TICK_SELECTOR), i, paddingTop = 0, bordersWidth = 2, count = items.length, selection = 0;
- for (i = 0; i < count - 2; i++) {
- $(items[i + 1])[that._sizeFn](pixelWidths[i]);
- }
- if (that._isHorizontal) {
- $(items[first]).addClass('k-first')[that._sizeFn](pixelWidths[last - 1]);
- $(items[last]).addClass('k-last')[that._sizeFn](pixelWidths[last]);
- } else {
- $(items[last]).addClass('k-first')[that._sizeFn](pixelWidths[last]);
- $(items[first]).addClass('k-last')[that._sizeFn](pixelWidths[last - 1]);
- }
- if (that._distance() % options.smallStep !== 0 && !that._isHorizontal) {
- for (i = 0; i < pixelWidths.length; i++) {
- selection += pixelWidths[i];
- }
- paddingTop = that._maxSelection - selection;
- paddingTop += parseFloat(that._trackDiv.css(that._position), 10) + bordersWidth;
- that.wrapper.find('.k-slider-items').css('padding-top', paddingTop);
- }
- },
- _setItemsTitle: function () {
- var that = this, options = that.options, items = that.wrapper.find(TICK_SELECTOR), titleNumber = options.min, count = items.length, i = that._isHorizontal && !that._isRtl ? 0 : count - 1, limit = that._isHorizontal && !that._isRtl ? count : -1, increment = that._isHorizontal && !that._isRtl ? 1 : -1;
- for (; i - limit !== 0; i += increment) {
- $(items[i]).attr('title', format(options.tooltip.format, round(titleNumber)));
- titleNumber += options.smallStep;
- }
- },
- _setItemsLargeTick: function () {
- var that = this, options = that.options, items = that.wrapper.find(TICK_SELECTOR), i = 0, item, value;
- if (removeFraction(options.largeStep) % removeFraction(options.smallStep) === 0 || that._distance() / options.largeStep >= 3) {
- if (!that._isHorizontal && !that._isRtl) {
- items = $.makeArray(items).reverse();
- }
- for (i = 0; i < items.length; i++) {
- item = $(items[i]);
- value = that._values[i];
- var valueWithoutFraction = round(removeFraction(value - this.options.min));
- if (valueWithoutFraction % removeFraction(options.smallStep) === 0 && valueWithoutFraction % removeFraction(options.largeStep) === 0) {
- item.addClass('k-tick-large').html('
' + item.attr('title') + '');
- if (i !== 0 && i !== items.length - 1) {
- item.css('line-height', item[that._sizeFn]() + 'px');
- }
- }
- }
- }
- },
- _calculateItemsWidth: function (itemsCount) {
- var that = this, options = that.options, trackDivSize = parseFloat(that._trackDiv.css(that._sizeFn)) + 1, distance = that._distance(), pixelStep = trackDivSize / distance, itemWidth, pixelWidths, i;
- if (distance / options.smallStep - math.floor(distance / options.smallStep) > 0) {
- trackDivSize -= distance % options.smallStep * pixelStep;
- }
- itemWidth = trackDivSize / itemsCount;
- pixelWidths = [];
- for (i = 0; i < itemsCount - 1; i++) {
- pixelWidths[i] = itemWidth;
- }
- pixelWidths[itemsCount - 1] = pixelWidths[itemsCount] = itemWidth / 2;
- return that._roundWidths(pixelWidths);
- },
- _roundWidths: function (pixelWidthsArray) {
- var balance = 0, count = pixelWidthsArray.length, i;
- for (i = 0; i < count; i++) {
- balance += pixelWidthsArray[i] - math.floor(pixelWidthsArray[i]);
- pixelWidthsArray[i] = math.floor(pixelWidthsArray[i]);
- }
- balance = math.round(balance);
- return this._addAdditionalSize(balance, pixelWidthsArray);
- },
- _addAdditionalSize: function (additionalSize, pixelWidthsArray) {
- if (additionalSize === 0) {
- return pixelWidthsArray;
- }
- var step = parseFloat(pixelWidthsArray.length - 1) / parseFloat(additionalSize == 1 ? additionalSize : additionalSize - 1), i;
- for (i = 0; i < additionalSize; i++) {
- pixelWidthsArray[parseInt(math.round(step * i), 10)] += 1;
- }
- return pixelWidthsArray;
- },
- _calculateSteps: function (pixelWidths) {
- var that = this, options = that.options, val = options.min, selection = 0, distance = that._distance(), itemsCount = math.ceil(distance / options.smallStep), i = 1, lastItem;
- itemsCount += distance / options.smallStep % 1 === 0 ? 1 : 0;
- pixelWidths.splice(0, 0, pixelWidths[itemsCount - 2] * 2);
- pixelWidths.splice(itemsCount - 1, 1, pixelWidths.pop() * 2);
- that._pixelSteps = [selection];
- that._values = [val];
- if (itemsCount === 0) {
- return;
- }
- while (i < itemsCount) {
- selection += (pixelWidths[i - 1] + pixelWidths[i]) / 2;
- that._pixelSteps[i] = selection;
- val += options.smallStep;
- that._values[i] = round(val);
- i++;
- }
- lastItem = distance % options.smallStep === 0 ? itemsCount - 1 : itemsCount;
- that._pixelSteps[lastItem] = that._maxSelection;
- that._values[lastItem] = options.max;
- if (that._isRtl) {
- that._pixelSteps.reverse();
- that._values.reverse();
- }
- },
- _getValueFromPosition: function (mousePosition, dragableArea) {
- var that = this, options = that.options, step = math.max(options.smallStep * (that._maxSelection / that._distance()), 0), position = 0, halfStep = step / 2, i;
- if (that._isHorizontal) {
- position = mousePosition - dragableArea.startPoint;
- if (that._isRtl) {
- position = that._maxSelection - position;
- }
- } else {
- position = dragableArea.startPoint - mousePosition;
- }
- if (that._maxSelection - (parseInt(that._maxSelection % step, 10) - 3) / 2 < position) {
- return options.max;
- }
- for (i = 0; i < that._pixelSteps.length; i++) {
- if (math.abs(that._pixelSteps[i] - position) - 1 <= halfStep) {
- return round(that._values[i]);
- }
- }
- },
- _getFormattedValue: function (val, drag) {
- var that = this, html = '', tooltip = that.options.tooltip, tooltipTemplate, selectionStart, selectionEnd;
- if (isArray(val)) {
- selectionStart = val[0];
- selectionEnd = val[1];
- } else if (drag && drag.type) {
- selectionStart = drag.selectionStart;
- selectionEnd = drag.selectionEnd;
- }
- if (drag) {
- tooltipTemplate = drag.tooltipTemplate;
- }
- if (!tooltipTemplate && tooltip.template) {
- tooltipTemplate = kendo.template(tooltip.template);
- }
- if (isArray(val) || drag && drag.type) {
- if (tooltipTemplate) {
- html = tooltipTemplate({
- selectionStart: selectionStart,
- selectionEnd: selectionEnd
- });
- } else {
- selectionStart = format(tooltip.format, selectionStart);
- selectionEnd = format(tooltip.format, selectionEnd);
- html = selectionStart + ' - ' + selectionEnd;
- }
- } else {
- if (drag) {
- drag.val = val;
- }
- if (tooltipTemplate) {
- html = tooltipTemplate({ value: val });
- } else {
- html = format(tooltip.format, val);
- }
- }
- return html;
- },
- _getDraggableArea: function () {
- var that = this, offset = kendo.getOffset(that._trackDiv);
- return {
- startPoint: that._isHorizontal ? offset.left : offset.top + that._maxSelection,
- endPoint: that._isHorizontal ? offset.left + that._maxSelection : offset.top
- };
- },
- _createHtml: function () {
- var that = this, element = that.element, options = that.options, inputs = element.find('input');
- if (inputs.length == 2) {
- inputs.eq(0).prop('value', formatValue(options.selectionStart));
- inputs.eq(1).prop('value', formatValue(options.selectionEnd));
- } else {
- element.prop('value', formatValue(options.value));
- }
- element.wrap(createWrapper(options, element, that._isHorizontal)).hide();
- if (options.showButtons) {
- element.before(createButton(options, 'increase', that._isHorizontal, that._isRtl)).before(createButton(options, 'decrease', that._isHorizontal, that._isRtl));
- }
- element.before(createTrack(options, element));
- },
- _focus: function (e) {
- var that = this, target = e.target, val = that.value(), drag = that._drag;
- if (!drag) {
- if (target == that.wrapper.find(DRAG_HANDLE).eq(0)[0]) {
- drag = that._firstHandleDrag;
- that._activeHandle = 0;
- } else {
- drag = that._lastHandleDrag;
- that._activeHandle = 1;
- }
- val = val[that._activeHandle];
- }
- $(target).addClass(STATE_FOCUSED + ' ' + STATE_SELECTED);
- if (drag) {
- that._activeHandleDrag = drag;
- drag.selectionStart = that.options.selectionStart;
- drag.selectionEnd = that.options.selectionEnd;
- drag._updateTooltip(val);
- }
- },
- _focusWithMouse: function (target) {
- target = $(target);
- var that = this, idx = target.is(DRAG_HANDLE) ? target.index() : 0;
- window.setTimeout(function () {
- that.wrapper.find(DRAG_HANDLE)[idx == 2 ? 1 : 0].focus();
- }, 1);
- that._setTooltipTimeout();
- },
- _blur: function (e) {
- var that = this, drag = that._activeHandleDrag;
- $(e.target).removeClass(STATE_FOCUSED + ' ' + STATE_SELECTED);
- if (drag) {
- drag._removeTooltip();
- delete that._activeHandleDrag;
- delete that._activeHandle;
- }
- },
- _setTooltipTimeout: function () {
- var that = this;
- that._tooltipTimeout = window.setTimeout(function () {
- var drag = that._drag || that._activeHandleDrag;
- if (drag) {
- drag._removeTooltip();
- }
- }, 300);
- },
- _clearTooltipTimeout: function () {
- var that = this;
- window.clearTimeout(this._tooltipTimeout);
- var drag = that._drag || that._activeHandleDrag;
- if (drag && drag.tooltipDiv) {
- drag.tooltipDiv.stop(true, false).css('opacity', 1);
- }
- },
- _reset: function () {
- var that = this, element = that.element, formId = element.attr('form'), form = formId ? $('#' + formId) : element.closest('form');
- if (form[0]) {
- that._form = form.on('reset', proxy(that._formResetHandler, that));
- }
- },
- min: function (value) {
- if (!value) {
- return this.options.min;
- }
- this.setOptions({ 'min': value });
- },
- max: function (value) {
- if (!value) {
- return this.options.max;
- }
- this.setOptions({ 'max': value });
- },
- setOptions: function (options) {
- Widget.fn.setOptions.call(this, options);
- this._sliderItemsInit();
- this._refresh();
- },
- destroy: function () {
- if (this._form) {
- this._form.off('reset', this._formResetHandler);
- }
- Widget.fn.destroy.call(this);
- }
- });
- function createWrapper(options, element, isHorizontal) {
- var orientationCssClass = isHorizontal ? ' k-slider-horizontal' : ' k-slider-vertical', style = options.style ? options.style : element.attr('style'), cssClasses = element.attr('class') ? ' ' + element.attr('class') : '', tickPlacementCssClass = '';
- if (options.tickPlacement == 'bottomRight') {
- tickPlacementCssClass = ' k-slider-bottomright';
- } else if (options.tickPlacement == 'topLeft') {
- tickPlacementCssClass = ' k-slider-topleft';
- }
- style = style ? ' style=\'' + style + '\'' : '';
- return '
';
- }
- function createButton(options, type, isHorizontal, isRtl) {
- var buttonCssClass = '';
- if (isHorizontal) {
- if (!isRtl && type == 'increase' || isRtl && type != 'increase') {
- buttonCssClass = 'k-i-arrow-60-right';
- } else {
- buttonCssClass = 'k-i-arrow-60-left';
- }
- } else {
- if (type == 'increase') {
- buttonCssClass = 'k-i-arrow-60-up';
- } else {
- buttonCssClass = 'k-i-arrow-60-down';
- }
- }
- return '
' + '';
- }
- function createSliderItems(options, distance) {
- var result = '
', count = math.floor(round(distance / options.smallStep)) + 1, i;
- for (i = 0; i < count; i++) {
- result += '-
';
- }
- result += '
';
- return result;
- }
- function createTrack(options, element) {
- var dragHandleCount = element.is('input') ? 1 : 2, firstDragHandleTitle = dragHandleCount == 2 ? options.leftDragHandleTitle : options.dragHandleTitle;
- return '
';
- }
- function step(stepValue) {
- return function (value) {
- return value + stepValue;
- };
- }
- function setValue(value) {
- return function () {
- return value;
- };
- }
- function formatValue(value) {
- return (value + '').replace('.', kendo.cultures.current.numberFormat['.']);
- }
- function calculatePrecision(value) {
- var number = value.toString();
- var precision = 0;
- number = number.split('.');
- if (number[1]) {
- precision = number[1].length;
- }
- precision = precision > 10 ? 10 : precision;
- return precision;
- }
- function round(value) {
- var precision, power;
- value = parseFloat(value, 10);
- precision = calculatePrecision(value);
- power = math.pow(10, precision || 0);
- return math.round(value * power) / power;
- }
- function parseAttr(element, name) {
- var value = parse(element.getAttribute(name));
- if (value === null) {
- value = undefined;
- }
- return value;
- }
- function defined(value) {
- return typeof value !== UNDEFINED;
- }
- function removeFraction(value) {
- return value * 10000;
- }
- var Slider = SliderBase.extend({
- init: function (element, options) {
- var that = this, dragHandle;
- element.type = 'text';
- options = extend({}, {
- value: parseAttr(element, 'value'),
- min: parseAttr(element, 'min'),
- max: parseAttr(element, 'max'),
- smallStep: parseAttr(element, 'step')
- }, options);
- element = $(element);
- if (options && options.enabled === undefined) {
- options.enabled = !element.is('[disabled]');
- }
- SliderBase.fn.init.call(that, element, options);
- options = that.options;
- if (!defined(options.value) || options.value === null) {
- options.value = options.min;
- element.prop('value', formatValue(options.min));
- }
- options.value = math.max(math.min(options.value, options.max), options.min);
- dragHandle = that.wrapper.find(DRAG_HANDLE);
- this._selection = new Slider.Selection(dragHandle, that, options);
- that._drag = new Slider.Drag(dragHandle, '', that, options);
- },
- options: {
- name: 'Slider',
- showButtons: true,
- increaseButtonTitle: 'Increase',
- decreaseButtonTitle: 'Decrease',
- dragHandleTitle: 'drag',
- tooltip: { format: '{0:#,#.##}' },
- value: null
- },
- enable: function (enable) {
- var that = this, options = that.options, clickHandler, move;
- that.disable();
- if (enable === false) {
- return;
- }
- that.wrapper.removeClass(STATE_DISABLED).addClass(STATE_DEFAULT);
- that.wrapper.find('input').removeAttr(DISABLED);
- clickHandler = function (e) {
- var touch = getTouches(e)[0];
- if (!touch) {
- return;
- }
- var mousePosition = that._isHorizontal ? touch.location.pageX : touch.location.pageY, dragableArea = that._getDraggableArea(), target = $(e.target);
- if (target.hasClass('k-draghandle')) {
- target.addClass(STATE_FOCUSED + ' ' + STATE_SELECTED);
- return;
- }
- that._update(that._getValueFromPosition(mousePosition, dragableArea));
- that._focusWithMouse(e.target);
- that._drag.dragstart(e);
- e.preventDefault();
- };
- that.wrapper.find(TICK_SELECTOR + ', ' + TRACK_SELECTOR).on(TRACK_MOUSE_DOWN, clickHandler).end().on(TRACK_MOUSE_DOWN, function () {
- $(document.documentElement).one('selectstart', kendo.preventDefault);
- }).on(TRACK_MOUSE_UP, function () {
- that._drag._end();
- });
- that.wrapper.find(DRAG_HANDLE).attr(TABINDEX, 0).on(MOUSE_UP, function () {
- that._setTooltipTimeout();
- }).on(CLICK, function (e) {
- that._focusWithMouse(e.target);
- e.preventDefault();
- }).on(FOCUS, proxy(that._focus, that)).on(BLUR, proxy(that._blur, that));
- move = proxy(function (sign) {
- var newVal = that._nextValueByIndex(that._valueIndex + sign * 1);
- that._setValueInRange(newVal);
- that._drag._updateTooltip(newVal);
- }, that);
- if (options.showButtons) {
- var mouseDownHandler = proxy(function (e, sign) {
- this._clearTooltipTimeout();
- if (e.which === 1 || support.touch && e.which === 0) {
- move(sign);
- this.timeout = setTimeout(proxy(function () {
- this.timer = setInterval(function () {
- move(sign);
- }, 60);
- }, this), 200);
- }
- }, that);
- that.wrapper.find('.k-button').on(MOUSE_UP, proxy(function (e) {
- this._clearTimer();
- that._focusWithMouse(e.target);
- }, that)).on(MOUSE_OVER, function (e) {
- $(e.currentTarget).addClass('k-state-hover');
- }).on('mouseout' + NS, proxy(function (e) {
- $(e.currentTarget).removeClass('k-state-hover');
- this._clearTimer();
- }, that)).eq(0).on(MOUSE_DOWN, proxy(function (e) {
- mouseDownHandler(e, 1);
- }, that)).click(false).end().eq(1).on(MOUSE_DOWN, proxy(function (e) {
- mouseDownHandler(e, -1);
- }, that)).click(kendo.preventDefault);
- }
- that.wrapper.find(DRAG_HANDLE).off(KEY_DOWN, false).on(KEY_DOWN, proxy(this._keydown, that));
- options.enabled = true;
- },
- disable: function () {
- var that = this;
- that.wrapper.removeClass(STATE_DEFAULT).addClass(STATE_DISABLED);
- $(that.element).prop(DISABLED, DISABLED);
- that.wrapper.find('.k-button').off(MOUSE_DOWN).on(MOUSE_DOWN, function (e) {
- e.preventDefault();
- $(this).addClass('k-state-active');
- }).off(MOUSE_UP).on(MOUSE_UP, function (e) {
- e.preventDefault();
- $(this).removeClass('k-state-active');
- }).off('mouseleave' + NS).on('mouseleave' + NS, kendo.preventDefault).off(MOUSE_OVER).on(MOUSE_OVER, kendo.preventDefault);
- that.wrapper.find(TICK_SELECTOR + ', ' + TRACK_SELECTOR).off(TRACK_MOUSE_DOWN).off(TRACK_MOUSE_UP);
- that.wrapper.find(DRAG_HANDLE).attr(TABINDEX, -1).off(MOUSE_UP).off(KEY_DOWN).off(CLICK).off(FOCUS).off(BLUR);
- that.options.enabled = false;
- },
- _update: function (val) {
- var that = this, change = that.value() != val;
- that.value(val);
- if (change) {
- that.trigger(CHANGE, { value: that.options.value });
- }
- },
- value: function (value) {
- var that = this, options = that.options;
- value = round(value);
- if (isNaN(value)) {
- return options.value;
- }
- if (value >= options.min && value <= options.max) {
- if (options.value != value) {
- that.element.prop('value', formatValue(value));
- options.value = value;
- that._refreshAriaAttr(value);
- that._refresh();
- }
- }
- },
- _refresh: function () {
- this.trigger(MOVE_SELECTION, { value: this.options.value });
- },
- _refreshAriaAttr: function (value) {
- var that = this, drag = that._drag, formattedValue;
- if (drag && drag._tooltipDiv) {
- formattedValue = drag._tooltipDiv.text();
- } else {
- formattedValue = that._getFormattedValue(value, null);
- }
- this.wrapper.find(DRAG_HANDLE).attr('aria-valuenow', value).attr('aria-valuetext', formattedValue);
- },
- _clearTimer: function () {
- clearTimeout(this.timeout);
- clearInterval(this.timer);
- },
- _keydown: function (e) {
- var that = this;
- if (e.keyCode in that._keyMap) {
- that._clearTooltipTimeout();
- that._setValueInRange(that._keyMap[e.keyCode](that.options.value));
- that._drag._updateTooltip(that.value());
- e.preventDefault();
- }
- },
- _setValueInRange: function (val) {
- var that = this, options = that.options;
- val = round(val);
- if (isNaN(val)) {
- that._update(options.min);
- return;
- }
- val = math.max(math.min(val, options.max), options.min);
- that._update(val);
- },
- _nextValueByIndex: function (index) {
- var count = this._values.length;
- if (this._isRtl) {
- index = count - 1 - index;
- }
- return this._values[math.max(0, math.min(index, count - 1))];
- },
- _formResetHandler: function () {
- var that = this, min = that.options.min;
- setTimeout(function () {
- var value = that.element[0].value;
- that.value(value === '' || isNaN(value) ? min : value);
- });
- },
- destroy: function () {
- var that = this;
- SliderBase.fn.destroy.call(that);
- that.wrapper.off(NS).find('.k-button').off(NS).end().find(DRAG_HANDLE).off(NS).end().find(TICK_SELECTOR + ', ' + TRACK_SELECTOR).off(NS).end();
- that._drag.draggable.destroy();
- that._drag._removeTooltip(true);
- }
- });
- Slider.Selection = function (dragHandle, that, options) {
- function moveSelection(val) {
- var selectionValue = val - options.min, index = that._valueIndex = math.ceil(round(selectionValue / options.smallStep)), selection = parseInt(that._pixelSteps[index], 10), selectionDiv = that._trackDiv.find('.k-slider-selection'), halfDragHanndle = parseInt(that._outerSize(dragHandle) / 2, 10), rtlCorrection = that._isRtl ? 2 : 0;
- selectionDiv[that._sizeFn](that._isRtl ? that._maxSelection - selection : selection);
- dragHandle.css(that._position, selection - halfDragHanndle - rtlCorrection);
- }
- moveSelection(options.value);
- that.bind([
- SLIDE,
- MOVE_SELECTION
- ], function (e) {
- moveSelection(parseFloat(e.value, 10));
- });
- that.bind(CHANGE, function (e) {
- moveSelection(parseFloat(e.sender.value(), 10));
- });
- };
- Slider.Drag = function (element, type, owner, options) {
- var that = this;
- that.owner = owner;
- that.options = options;
- that.element = element;
- that.type = type;
- that.draggable = new Draggable(element, {
- distance: 0,
- dragstart: proxy(that._dragstart, that),
- drag: proxy(that.drag, that),
- dragend: proxy(that.dragend, that),
- dragcancel: proxy(that.dragcancel, that)
- });
- element.click(false);
- element.on('dragstart', function (e) {
- e.preventDefault();
- });
- };
- Slider.Drag.prototype = {
- dragstart: function (e) {
- this.owner._activeDragHandle = this;
- this.draggable.userEvents.cancel();
- this._dragstart(e);
- this.dragend();
- },
- _dragstart: function (e) {
- var that = this, owner = that.owner, options = that.options;
- if (!options.enabled) {
- e.preventDefault();
- return;
- }
- this.owner._activeDragHandle = this;
- owner.element.off(MOUSE_OVER);
- owner.wrapper.find('.' + STATE_FOCUSED).removeClass(STATE_FOCUSED + ' ' + STATE_SELECTED);
- that.element.addClass(STATE_FOCUSED + ' ' + STATE_SELECTED);
- $(document.documentElement).css('cursor', 'pointer');
- that.dragableArea = owner._getDraggableArea();
- that.step = math.max(options.smallStep * (owner._maxSelection / owner._distance()), 0);
- if (that.type) {
- that.selectionStart = options.selectionStart;
- that.selectionEnd = options.selectionEnd;
- owner._setZIndex(that.type);
- } else {
- that.oldVal = that.val = options.value;
- }
- that._removeTooltip(true);
- that._createTooltip();
- },
- _createTooltip: function () {
- var that = this, owner = that.owner, tooltip = that.options.tooltip, html = '', wnd = $(window), tooltipTemplate, colloutCssClass;
- if (!tooltip.enabled) {
- return;
- }
- if (tooltip.template) {
- tooltipTemplate = that.tooltipTemplate = kendo.template(tooltip.template);
- }
- $('.k-slider-tooltip').remove();
- that.tooltipDiv = $('
').appendTo(document.body);
- html = owner._getFormattedValue(that.val || owner.value(), that);
- if (!that.type) {
- colloutCssClass = 'k-callout-' + (owner._isHorizontal ? 's' : 'e');
- that.tooltipInnerDiv = '
';
- html += that.tooltipInnerDiv;
- }
- that.tooltipDiv.html(html);
- that._scrollOffset = {
- top: wnd.scrollTop(),
- left: wnd.scrollLeft()
- };
- that.moveTooltip();
- },
- drag: function (e) {
- var that = this, owner = that.owner, x = e.x.location, y = e.y.location, startPoint = that.dragableArea.startPoint, endPoint = that.dragableArea.endPoint, slideParams;
- e.preventDefault();
- if (owner._isHorizontal) {
- if (owner._isRtl) {
- that.val = that.constrainValue(x, startPoint, endPoint, x < endPoint);
- } else {
- that.val = that.constrainValue(x, startPoint, endPoint, x >= endPoint);
- }
- } else {
- that.val = that.constrainValue(y, endPoint, startPoint, y <= endPoint);
- }
- if (that.oldVal != that.val) {
- that.oldVal = that.val;
- if (that.type) {
- if (that.type == 'firstHandle') {
- if (that.val < that.selectionEnd) {
- that.selectionStart = that.val;
- } else {
- that.selectionStart = that.selectionEnd = that.val;
- }
- } else {
- if (that.val > that.selectionStart) {
- that.selectionEnd = that.val;
- } else {
- that.selectionStart = that.selectionEnd = that.val;
- }
- }
- slideParams = {
- values: [
- that.selectionStart,
- that.selectionEnd
- ],
- value: [
- that.selectionStart,
- that.selectionEnd
- ]
- };
- } else {
- slideParams = { value: that.val };
- }
- owner.trigger(SLIDE, slideParams);
- }
- that._updateTooltip(that.val);
- },
- _updateTooltip: function (val) {
- var that = this, options = that.options, tooltip = options.tooltip, html = '';
- if (!tooltip.enabled) {
- return;
- }
- if (!that.tooltipDiv) {
- that._createTooltip();
- }
- html = that.owner._getFormattedValue(round(val), that);
- if (!that.type) {
- html += that.tooltipInnerDiv;
- }
- that.tooltipDiv.html(html);
- that.moveTooltip();
- },
- dragcancel: function () {
- this.owner._refresh();
- $(document.documentElement).css('cursor', '');
- return this._end();
- },
- dragend: function () {
- var that = this, owner = that.owner;
- $(document.documentElement).css('cursor', '');
- if (that.type) {
- owner._update(that.selectionStart, that.selectionEnd);
- } else {
- owner._update(that.val);
- that.draggable.userEvents._disposeAll();
- }
- that.draggable.userEvents.cancel();
- return that._end();
- },
- _end: function () {
- var that = this, owner = that.owner;
- owner._focusWithMouse(that.element);
- owner.element.on(MOUSE_OVER);
- return false;
- },
- _removeTooltip: function (noAnimation) {
- var that = this, owner = that.owner;
- if (that.tooltipDiv && owner.options.tooltip.enabled && owner.options.enabled) {
- if (noAnimation) {
- that.tooltipDiv.remove();
- that.tooltipDiv = null;
- } else {
- that.tooltipDiv.fadeOut('slow', function () {
- $(this).remove();
- that.tooltipDiv = null;
- });
- }
- }
- },
- moveTooltip: function () {
- var that = this, owner = that.owner, top = 0, left = 0, element = that.element, offset = kendo.getOffset(element), margin = 8, viewport = $(window), callout = that.tooltipDiv.find('.k-callout'), width = outerWidth(that.tooltipDiv), height = outerHeight(that.tooltipDiv), dragHandles, sdhOffset, diff, anchorSize;
- if (that.type) {
- dragHandles = owner.wrapper.find(DRAG_HANDLE);
- offset = kendo.getOffset(dragHandles.eq(0));
- sdhOffset = kendo.getOffset(dragHandles.eq(1));
- if (owner._isHorizontal) {
- top = sdhOffset.top;
- left = offset.left + (sdhOffset.left - offset.left) / 2;
- } else {
- top = offset.top + (sdhOffset.top - offset.top) / 2;
- left = sdhOffset.left;
- }
- anchorSize = outerWidth(dragHandles.eq(0)) + 2 * margin;
- } else {
- top = offset.top;
- left = offset.left;
- anchorSize = outerWidth(element) + 2 * margin;
- }
- if (owner._isHorizontal) {
- left -= parseInt((width - owner._outerSize(element)) / 2, 10);
- top -= height + margin + (callout.length ? callout.height() : 0);
- } else {
- top -= parseInt((height - owner._outerSize(element)) / 2, 10);
- left -= width + margin + (callout.length ? callout.width() : 0);
- }
- if (owner._isHorizontal) {
- diff = that._flip(top, height, anchorSize, outerHeight(viewport) + that._scrollOffset.top);
- top += diff;
- left += that._fit(left, width, outerWidth(viewport) + that._scrollOffset.left);
- } else {
- diff = that._flip(left, width, anchorSize, outerWidth(viewport) + that._scrollOffset.left);
- top += that._fit(top, height, outerHeight(viewport) + that._scrollOffset.top);
- left += diff;
- }
- if (diff > 0 && callout) {
- callout.removeClass();
- callout.addClass('k-callout k-callout-' + (owner._isHorizontal ? 'n' : 'w'));
- }
- that.tooltipDiv.css({
- top: top,
- left: left
- });
- },
- _fit: function (position, size, viewPortEnd) {
- var output = 0;
- if (position + size > viewPortEnd) {
- output = viewPortEnd - (position + size);
- }
- if (position < 0) {
- output = -position;
- }
- return output;
- },
- _flip: function (offset, size, anchorSize, viewPortEnd) {
- var output = 0;
- if (offset + size > viewPortEnd) {
- output += -(anchorSize + size);
- }
- if (offset + output < 0) {
- output += anchorSize + size;
- }
- return output;
- },
- constrainValue: function (position, min, max, maxOverflow) {
- var that = this, val = 0;
- if (min < position && position < max) {
- val = that.owner._getValueFromPosition(position, that.dragableArea);
- } else {
- if (maxOverflow) {
- val = that.options.max;
- } else {
- val = that.options.min;
- }
- }
- return val;
- }
- };
- kendo.ui.plugin(Slider);
- var RangeSlider = SliderBase.extend({
- init: function (element, options) {
- var that = this, inputs = $(element).find('input'), firstInput = inputs.eq(0)[0], secondInput = inputs.eq(1)[0];
- firstInput.type = 'text';
- secondInput.type = 'text';
- if (options && options.showButtons) {
- if (window.console) {
- window.console.warn('showbuttons option is not supported for the range slider, ignoring');
- }
- options.showButtons = false;
- }
- options = extend({}, {
- selectionStart: parseAttr(firstInput, 'value'),
- min: parseAttr(firstInput, 'min'),
- max: parseAttr(firstInput, 'max'),
- smallStep: parseAttr(firstInput, 'step')
- }, {
- selectionEnd: parseAttr(secondInput, 'value'),
- min: parseAttr(secondInput, 'min'),
- max: parseAttr(secondInput, 'max'),
- smallStep: parseAttr(secondInput, 'step')
- }, options);
- if (options && options.enabled === undefined) {
- options.enabled = !inputs.is('[disabled]');
- }
- SliderBase.fn.init.call(that, element, options);
- options = that.options;
- if (!defined(options.selectionStart) || options.selectionStart === null) {
- options.selectionStart = options.min;
- inputs.eq(0).prop('value', formatValue(options.min));
- }
- if (!defined(options.selectionEnd) || options.selectionEnd === null) {
- options.selectionEnd = options.max;
- inputs.eq(1).prop('value', formatValue(options.max));
- }
- var dragHandles = that.wrapper.find(DRAG_HANDLE);
- this._selection = new RangeSlider.Selection(dragHandles, that, options);
- that._firstHandleDrag = new Slider.Drag(dragHandles.eq(0), 'firstHandle', that, options);
- that._lastHandleDrag = new Slider.Drag(dragHandles.eq(1), 'lastHandle', that, options);
- },
- options: {
- name: 'RangeSlider',
- leftDragHandleTitle: 'drag',
- rightDragHandleTitle: 'drag',
- tooltip: { format: '{0:#,#.##}' },
- selectionStart: null,
- selectionEnd: null
- },
- enable: function (enable) {
- var that = this, options = that.options, clickHandler;
- that.disable();
- if (enable === false) {
- return;
- }
- that.wrapper.removeClass(STATE_DISABLED).addClass(STATE_DEFAULT);
- that.wrapper.find('input').removeAttr(DISABLED);
- clickHandler = function (e) {
- var touch = getTouches(e)[0];
- if (!touch) {
- return;
- }
- var mousePosition = that._isHorizontal ? touch.location.pageX : touch.location.pageY, dragableArea = that._getDraggableArea(), val = that._getValueFromPosition(mousePosition, dragableArea), target = $(e.target), from, to, drag;
- if (target.hasClass('k-draghandle')) {
- that.wrapper.find('.' + STATE_FOCUSED).removeClass(STATE_FOCUSED + ' ' + STATE_SELECTED);
- target.addClass(STATE_FOCUSED + ' ' + STATE_SELECTED);
- return;
- }
- if (val < options.selectionStart) {
- from = val;
- to = options.selectionEnd;
- drag = that._firstHandleDrag;
- } else if (val > that.selectionEnd) {
- from = options.selectionStart;
- to = val;
- drag = that._lastHandleDrag;
- } else {
- if (val - options.selectionStart <= options.selectionEnd - val) {
- from = val;
- to = options.selectionEnd;
- drag = that._firstHandleDrag;
- } else {
- from = options.selectionStart;
- to = val;
- drag = that._lastHandleDrag;
- }
- }
- drag.dragstart(e);
- that._setValueInRange(from, to);
- that._focusWithMouse(drag.element);
- };
- that.wrapper.find(TICK_SELECTOR + ', ' + TRACK_SELECTOR).on(TRACK_MOUSE_DOWN, clickHandler).end().on(TRACK_MOUSE_DOWN, function () {
- $(document.documentElement).one('selectstart', kendo.preventDefault);
- }).on(TRACK_MOUSE_UP, function () {
- if (that._activeDragHandle) {
- that._activeDragHandle._end();
- }
- });
- that.wrapper.find(DRAG_HANDLE).attr(TABINDEX, 0).on(MOUSE_UP, function () {
- that._setTooltipTimeout();
- }).on(CLICK, function (e) {
- that._focusWithMouse(e.target);
- e.preventDefault();
- }).on(FOCUS, proxy(that._focus, that)).on(BLUR, proxy(that._blur, that));
- that.wrapper.find(DRAG_HANDLE).off(KEY_DOWN, kendo.preventDefault).eq(0).on(KEY_DOWN, proxy(function (e) {
- this._keydown(e, 'firstHandle');
- }, that)).end().eq(1).on(KEY_DOWN, proxy(function (e) {
- this._keydown(e, 'lastHandle');
- }, that));
- that.options.enabled = true;
- },
- disable: function () {
- var that = this;
- that.wrapper.removeClass(STATE_DEFAULT).addClass(STATE_DISABLED);
- that.wrapper.find('input').prop(DISABLED, DISABLED);
- that.wrapper.find(TICK_SELECTOR + ', ' + TRACK_SELECTOR).off(TRACK_MOUSE_DOWN).off(TRACK_MOUSE_UP);
- that.wrapper.find(DRAG_HANDLE).attr(TABINDEX, -1).off(MOUSE_UP).off(KEY_DOWN).off(CLICK).off(FOCUS).off(BLUR);
- that.options.enabled = false;
- },
- _keydown: function (e, handle) {
- var that = this, selectionStartValue = that.options.selectionStart, selectionEndValue = that.options.selectionEnd, dragSelectionStart, dragSelectionEnd, activeHandleDrag;
- if (e.keyCode in that._keyMap) {
- that._clearTooltipTimeout();
- if (handle == 'firstHandle') {
- activeHandleDrag = that._activeHandleDrag = that._firstHandleDrag;
- selectionStartValue = that._keyMap[e.keyCode](selectionStartValue);
- if (selectionStartValue > selectionEndValue) {
- selectionEndValue = selectionStartValue;
- }
- } else {
- activeHandleDrag = that._activeHandleDrag = that._lastHandleDrag;
- selectionEndValue = that._keyMap[e.keyCode](selectionEndValue);
- if (selectionStartValue > selectionEndValue) {
- selectionStartValue = selectionEndValue;
- }
- }
- that._setValueInRange(round(selectionStartValue), round(selectionEndValue));
- dragSelectionStart = Math.max(selectionStartValue, that.options.selectionStart);
- dragSelectionEnd = Math.min(selectionEndValue, that.options.selectionEnd);
- activeHandleDrag.selectionEnd = Math.max(dragSelectionEnd, that.options.selectionStart);
- activeHandleDrag.selectionStart = Math.min(dragSelectionStart, that.options.selectionEnd);
- activeHandleDrag._updateTooltip(that.value()[that._activeHandle]);
- e.preventDefault();
- }
- },
- _update: function (selectionStart, selectionEnd) {
- var that = this, values = that.value();
- var change = values[0] != selectionStart || values[1] != selectionEnd;
- that.value([
- selectionStart,
- selectionEnd
- ]);
- if (change) {
- that.trigger(CHANGE, {
- values: [
- selectionStart,
- selectionEnd
- ],
- value: [
- selectionStart,
- selectionEnd
- ]
- });
- }
- },
- value: function (value) {
- if (value && value.length) {
- return this._value(value[0], value[1]);
- } else {
- return this._value();
- }
- },
- _value: function (start, end) {
- var that = this, options = that.options, selectionStart = options.selectionStart, selectionEnd = options.selectionEnd;
- if (isNaN(start) && isNaN(end)) {
- return [
- selectionStart,
- selectionEnd
- ];
- } else {
- start = round(start);
- end = round(end);
- }
- if (start >= options.min && start <= options.max && end >= options.min && end <= options.max && start <= end) {
- if (selectionStart != start || selectionEnd != end) {
- that.element.find('input').eq(0).prop('value', formatValue(start)).end().eq(1).prop('value', formatValue(end));
- options.selectionStart = start;
- options.selectionEnd = end;
- that._refresh();
- that._refreshAriaAttr(start, end);
- }
- }
- },
- values: function (start, end) {
- if (isArray(start)) {
- return this._value(start[0], start[1]);
- } else {
- return this._value(start, end);
- }
- },
- _refresh: function () {
- var that = this, options = that.options;
- that.trigger(MOVE_SELECTION, {
- values: [
- options.selectionStart,
- options.selectionEnd
- ],
- value: [
- options.selectionStart,
- options.selectionEnd
- ]
- });
- if (options.selectionStart == options.max && options.selectionEnd == options.max) {
- that._setZIndex('firstHandle');
- }
- },
- _refreshAriaAttr: function (start, end) {
- var that = this, dragHandles = that.wrapper.find(DRAG_HANDLE), drag = that._activeHandleDrag, formattedValue;
- formattedValue = that._getFormattedValue([
- start,
- end
- ], drag);
- dragHandles.eq(0).attr('aria-valuenow', start);
- dragHandles.eq(1).attr('aria-valuenow', end);
- dragHandles.attr('aria-valuetext', formattedValue);
- },
- _setValueInRange: function (selectionStart, selectionEnd) {
- var options = this.options;
- selectionStart = math.max(math.min(selectionStart, options.max), options.min);
- selectionEnd = math.max(math.min(selectionEnd, options.max), options.min);
- if (selectionStart == options.max && selectionEnd == options.max) {
- this._setZIndex('firstHandle');
- }
- this._update(math.min(selectionStart, selectionEnd), math.max(selectionStart, selectionEnd));
- },
- _setZIndex: function (type) {
- this.wrapper.find(DRAG_HANDLE).each(function (index) {
- $(this).css('z-index', type == 'firstHandle' ? 1 - index : index);
- });
- },
- _formResetHandler: function () {
- var that = this, options = that.options;
- setTimeout(function () {
- var inputs = that.element.find('input');
- var start = inputs[0].value;
- var end = inputs[1].value;
- that.values(start === '' || isNaN(start) ? options.min : start, end === '' || isNaN(end) ? options.max : end);
- });
- },
- destroy: function () {
- var that = this;
- SliderBase.fn.destroy.call(that);
- that.wrapper.off(NS).find(TICK_SELECTOR + ', ' + TRACK_SELECTOR).off(NS).end().find(DRAG_HANDLE).off(NS);
- that._firstHandleDrag.draggable.destroy();
- that._lastHandleDrag.draggable.destroy();
- }
- });
- RangeSlider.Selection = function (dragHandles, that, options) {
- function moveSelection(value) {
- value = value || [];
- var selectionStartValue = value[0] - options.min, selectionEndValue = value[1] - options.min, selectionStartIndex = math.ceil(round(selectionStartValue / options.smallStep)), selectionEndIndex = math.ceil(round(selectionEndValue / options.smallStep)), selectionStart = that._pixelSteps[selectionStartIndex], selectionEnd = that._pixelSteps[selectionEndIndex], halfHandle = parseInt(that._outerSize(dragHandles.eq(0)) / 2, 10), rtlCorrection = that._isRtl ? 2 : 0;
- dragHandles.eq(0).css(that._position, selectionStart - halfHandle - rtlCorrection).end().eq(1).css(that._position, selectionEnd - halfHandle - rtlCorrection);
- makeSelection(selectionStart, selectionEnd);
- }
- function makeSelection(selectionStart, selectionEnd) {
- var selection, selectionPosition, selectionDiv = that._trackDiv.find('.k-slider-selection');
- selection = math.abs(selectionStart - selectionEnd);
- selectionDiv[that._sizeFn](selection);
- if (that._isRtl) {
- selectionPosition = math.max(selectionStart, selectionEnd);
- selectionDiv.css('right', that._maxSelection - selectionPosition - 1);
- } else {
- selectionPosition = math.min(selectionStart, selectionEnd);
- selectionDiv.css(that._position, selectionPosition - 1);
- }
- }
- moveSelection(that.value());
- that.bind([
- CHANGE,
- SLIDE,
- MOVE_SELECTION
- ], function (e) {
- moveSelection(e.values);
- });
- };
- kendo.ui.plugin(RangeSlider);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.mobile.scroller', [
- 'kendo.fx',
- 'kendo.draganddrop'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'mobile.scroller',
- name: 'Scroller',
- category: 'mobile',
- description: 'The Kendo Mobile Scroller widget enables touch friendly kinetic scrolling for the contents of a given DOM element.',
- depends: [
- 'fx',
- 'draganddrop'
- ]
- };
- (function ($, undefined) {
- var kendo = window.kendo, mobile = kendo.mobile, fx = kendo.effects, ui = mobile.ui, proxy = $.proxy, extend = $.extend, Widget = ui.Widget, Class = kendo.Class, Movable = kendo.ui.Movable, Pane = kendo.ui.Pane, PaneDimensions = kendo.ui.PaneDimensions, Transition = fx.Transition, Animation = fx.Animation, abs = Math.abs, SNAPBACK_DURATION = 500, SCROLLBAR_OPACITY = 0.7, FRICTION = 0.96, VELOCITY_MULTIPLIER = 10, MAX_VELOCITY = 55, OUT_OF_BOUNDS_FRICTION = 0.5, ANIMATED_SCROLLER_PRECISION = 5, RELEASECLASS = 'km-scroller-release', REFRESHCLASS = 'km-scroller-refresh', PULL = 'pull', CHANGE = 'change', RESIZE = 'resize', SCROLL = 'scroll', MOUSE_WHEEL_ID = 2;
- var ZoomSnapBack = Animation.extend({
- init: function (options) {
- var that = this;
- Animation.fn.init.call(that);
- extend(that, options);
- that.userEvents.bind('gestureend', proxy(that.start, that));
- that.tapCapture.bind('press', proxy(that.cancel, that));
- },
- enabled: function () {
- return this.movable.scale < this.dimensions.minScale;
- },
- done: function () {
- return this.dimensions.minScale - this.movable.scale < 0.01;
- },
- tick: function () {
- var movable = this.movable;
- movable.scaleWith(1.1);
- this.dimensions.rescale(movable.scale);
- },
- onEnd: function () {
- var movable = this.movable;
- movable.scaleTo(this.dimensions.minScale);
- this.dimensions.rescale(movable.scale);
- }
- });
- var DragInertia = Animation.extend({
- init: function (options) {
- var that = this;
- Animation.fn.init.call(that);
- extend(that, options, {
- transition: new Transition({
- axis: options.axis,
- movable: options.movable,
- onEnd: function () {
- that._end();
- }
- })
- });
- that.tapCapture.bind('press', function () {
- that.cancel();
- });
- that.userEvents.bind('end', proxy(that.start, that));
- that.userEvents.bind('gestureend', proxy(that.start, that));
- that.userEvents.bind('tap', proxy(that.onEnd, that));
- },
- onCancel: function () {
- this.transition.cancel();
- },
- freeze: function (location) {
- var that = this;
- that.cancel();
- that._moveTo(location);
- },
- onEnd: function () {
- var that = this;
- if (that.paneAxis.outOfBounds()) {
- that._snapBack();
- } else {
- that._end();
- }
- },
- done: function () {
- return abs(this.velocity) < 1;
- },
- start: function (e) {
- var that = this, velocity;
- if (!that.dimension.enabled) {
- return;
- }
- if (that.paneAxis.outOfBounds()) {
- that._snapBack();
- } else {
- velocity = e.touch.id === MOUSE_WHEEL_ID ? 0 : e.touch[that.axis].velocity;
- that.velocity = Math.max(Math.min(velocity * that.velocityMultiplier, MAX_VELOCITY), -MAX_VELOCITY);
- that.tapCapture.captureNext();
- Animation.fn.start.call(that);
- }
- },
- tick: function () {
- var that = this, dimension = that.dimension, friction = that.paneAxis.outOfBounds() ? OUT_OF_BOUNDS_FRICTION : that.friction, delta = that.velocity *= friction, location = that.movable[that.axis] + delta;
- if (!that.elastic && dimension.outOfBounds(location)) {
- location = Math.max(Math.min(location, dimension.max), dimension.min);
- that.velocity = 0;
- }
- that.movable.moveAxis(that.axis, location);
- },
- _end: function () {
- this.tapCapture.cancelCapture();
- this.end();
- },
- _snapBack: function () {
- var that = this, dimension = that.dimension, snapBack = that.movable[that.axis] > dimension.max ? dimension.max : dimension.min;
- that._moveTo(snapBack);
- },
- _moveTo: function (location) {
- this.transition.moveTo({
- location: location,
- duration: SNAPBACK_DURATION,
- ease: Transition.easeOutExpo
- });
- }
- });
- var AnimatedScroller = Animation.extend({
- init: function (options) {
- var that = this;
- kendo.effects.Animation.fn.init.call(this);
- extend(that, options, {
- origin: {},
- destination: {},
- offset: {}
- });
- },
- tick: function () {
- this._updateCoordinates();
- this.moveTo(this.origin);
- },
- done: function () {
- return abs(this.offset.y) < ANIMATED_SCROLLER_PRECISION && abs(this.offset.x) < ANIMATED_SCROLLER_PRECISION;
- },
- onEnd: function () {
- this.moveTo(this.destination);
- if (this.callback) {
- this.callback.call();
- }
- },
- setCoordinates: function (from, to) {
- this.offset = {};
- this.origin = from;
- this.destination = to;
- },
- setCallback: function (callback) {
- if (callback && kendo.isFunction(callback)) {
- this.callback = callback;
- } else {
- callback = undefined;
- }
- },
- _updateCoordinates: function () {
- this.offset = {
- x: (this.destination.x - this.origin.x) / 4,
- y: (this.destination.y - this.origin.y) / 4
- };
- this.origin = {
- y: this.origin.y + this.offset.y,
- x: this.origin.x + this.offset.x
- };
- }
- });
- var ScrollBar = Class.extend({
- init: function (options) {
- var that = this, horizontal = options.axis === 'x', element = $('
');
- extend(that, options, {
- element: element,
- elementSize: 0,
- movable: new Movable(element),
- scrollMovable: options.movable,
- alwaysVisible: options.alwaysVisible,
- size: horizontal ? 'width' : 'height'
- });
- that.scrollMovable.bind(CHANGE, proxy(that.refresh, that));
- that.container.append(element);
- if (options.alwaysVisible) {
- that.show();
- }
- },
- refresh: function () {
- var that = this, axis = that.axis, dimension = that.dimension, paneSize = dimension.size, scrollMovable = that.scrollMovable, sizeRatio = paneSize / dimension.total, position = Math.round(-scrollMovable[axis] * sizeRatio), size = Math.round(paneSize * sizeRatio);
- if (sizeRatio >= 1) {
- this.element.css('display', 'none');
- } else {
- this.element.css('display', '');
- }
- if (position + size > paneSize) {
- size = paneSize - position;
- } else if (position < 0) {
- size += position;
- position = 0;
- }
- if (that.elementSize != size) {
- that.element.css(that.size, size + 'px');
- that.elementSize = size;
- }
- that.movable.moveAxis(axis, position);
- },
- show: function () {
- this.element.css({
- opacity: SCROLLBAR_OPACITY,
- visibility: 'visible'
- });
- },
- hide: function () {
- if (!this.alwaysVisible) {
- this.element.css({ opacity: 0 });
- }
- }
- });
- var Scroller = Widget.extend({
- init: function (element, options) {
- var that = this;
- Widget.fn.init.call(that, element, options);
- element = that.element;
- that._native = that.options.useNative && kendo.support.hasNativeScrolling;
- if (that._native) {
- element.addClass('km-native-scroller').prepend('');
- extend(that, {
- scrollElement: element,
- fixedContainer: element.children().first()
- });
- return;
- }
- element.css('overflow', 'hidden').addClass('km-scroll-wrapper').wrapInner('
').prepend('');
- var inner = element.children().eq(1), tapCapture = new kendo.TapCapture(element), movable = new Movable(inner), dimensions = new PaneDimensions({
- element: inner,
- container: element,
- forcedEnabled: that.options.zoom
- }), avoidScrolling = this.options.avoidScrolling, userEvents = new kendo.UserEvents(element, {
- touchAction: 'pan-y',
- fastTap: true,
- allowSelection: true,
- preventDragEvent: true,
- captureUpIfMoved: true,
- multiTouch: that.options.zoom,
- supportDoubleTap: that.options.supportDoubleTap,
- start: function (e) {
- dimensions.refresh();
- var velocityX = abs(e.x.velocity), velocityY = abs(e.y.velocity), horizontalSwipe = velocityX * 2 >= velocityY, originatedFromFixedContainer = $.contains(that.fixedContainer[0], e.event.target), verticalSwipe = velocityY * 2 >= velocityX;
- if (!originatedFromFixedContainer && !avoidScrolling(e) && that.enabled && (dimensions.x.enabled && horizontalSwipe || dimensions.y.enabled && verticalSwipe)) {
- userEvents.capture();
- } else {
- userEvents.cancel();
- }
- }
- }), pane = new Pane({
- movable: movable,
- dimensions: dimensions,
- userEvents: userEvents,
- elastic: that.options.elastic
- }), zoomSnapBack = new ZoomSnapBack({
- movable: movable,
- dimensions: dimensions,
- userEvents: userEvents,
- tapCapture: tapCapture
- }), animatedScroller = new AnimatedScroller({
- moveTo: function (coordinates) {
- that.scrollTo(coordinates.x, coordinates.y);
- }
- });
- movable.bind(CHANGE, function () {
- that.scrollTop = -movable.y;
- that.scrollLeft = -movable.x;
- that.trigger(SCROLL, {
- scrollTop: that.scrollTop,
- scrollLeft: that.scrollLeft
- });
- });
- if (that.options.mousewheelScrolling) {
- element.on('DOMMouseScroll mousewheel', proxy(this, '_wheelScroll'));
- }
- extend(that, {
- movable: movable,
- dimensions: dimensions,
- zoomSnapBack: zoomSnapBack,
- animatedScroller: animatedScroller,
- userEvents: userEvents,
- pane: pane,
- tapCapture: tapCapture,
- pulled: false,
- enabled: true,
- scrollElement: inner,
- scrollTop: 0,
- scrollLeft: 0,
- fixedContainer: element.children().first()
- });
- that._initAxis('x');
- that._initAxis('y');
- that._wheelEnd = function () {
- that._wheel = false;
- that.userEvents.end(0, that._wheelY);
- };
- dimensions.refresh();
- if (that.options.pullToRefresh) {
- that._initPullToRefresh();
- }
- },
- _wheelScroll: function (e) {
- if (!this._wheel) {
- this._wheel = true;
- this._wheelY = 0;
- this.userEvents.press(0, this._wheelY);
- }
- clearTimeout(this._wheelTimeout);
- this._wheelTimeout = setTimeout(this._wheelEnd, 50);
- var delta = kendo.wheelDeltaY(e);
- if (delta) {
- this._wheelY += delta;
- this.userEvents.move(0, this._wheelY);
- }
- e.preventDefault();
- },
- makeVirtual: function () {
- this.dimensions.y.makeVirtual();
- },
- virtualSize: function (min, max) {
- this.dimensions.y.virtualSize(min, max);
- },
- height: function () {
- return this.dimensions.y.size;
- },
- scrollHeight: function () {
- return this.scrollElement[0].scrollHeight;
- },
- scrollWidth: function () {
- return this.scrollElement[0].scrollWidth;
- },
- options: {
- name: 'Scroller',
- zoom: false,
- pullOffset: 140,
- visibleScrollHints: false,
- elastic: true,
- useNative: false,
- mousewheelScrolling: true,
- avoidScrolling: function () {
- return false;
- },
- pullToRefresh: false,
- messages: {
- pullTemplate: 'Pull to refresh',
- releaseTemplate: 'Release to refresh',
- refreshTemplate: 'Refreshing'
- }
- },
- events: [
- PULL,
- SCROLL,
- RESIZE
- ],
- _resize: function () {
- if (!this._native) {
- this.contentResized();
- }
- },
- setOptions: function (options) {
- var that = this;
- Widget.fn.setOptions.call(that, options);
- if (options.pullToRefresh) {
- that._initPullToRefresh();
- }
- },
- reset: function () {
- if (this._native) {
- this.scrollElement.scrollTop(0);
- } else {
- this.movable.moveTo({
- x: 0,
- y: 0
- });
- this._scale(1);
- }
- },
- contentResized: function () {
- this.dimensions.refresh();
- if (this.pane.x.outOfBounds()) {
- this.movable.moveAxis('x', this.dimensions.x.min);
- }
- if (this.pane.y.outOfBounds()) {
- this.movable.moveAxis('y', this.dimensions.y.min);
- }
- },
- zoomOut: function () {
- var dimensions = this.dimensions;
- dimensions.refresh();
- this._scale(dimensions.fitScale);
- this.movable.moveTo(dimensions.centerCoordinates());
- },
- enable: function () {
- this.enabled = true;
- },
- disable: function () {
- this.enabled = false;
- },
- scrollTo: function (x, y) {
- if (this._native) {
- this.scrollElement.scrollLeft(abs(x));
- this.scrollElement.scrollTop(abs(y));
- } else {
- this.dimensions.refresh();
- this.movable.moveTo({
- x: x,
- y: y
- });
- }
- },
- animatedScrollTo: function (x, y, callback) {
- var from, to;
- if (this._native) {
- this.scrollTo(x, y);
- } else {
- from = {
- x: this.movable.x,
- y: this.movable.y
- };
- to = {
- x: x,
- y: y
- };
- this.animatedScroller.setCoordinates(from, to);
- this.animatedScroller.setCallback(callback);
- this.animatedScroller.start();
- }
- },
- pullHandled: function () {
- var that = this;
- that.refreshHint.removeClass(REFRESHCLASS);
- that.hintContainer.html(that.pullTemplate({}));
- that.yinertia.onEnd();
- that.xinertia.onEnd();
- that.userEvents.cancel();
- },
- destroy: function () {
- Widget.fn.destroy.call(this);
- if (this.userEvents) {
- this.userEvents.destroy();
- }
- },
- _scale: function (scale) {
- this.dimensions.rescale(scale);
- this.movable.scaleTo(scale);
- },
- _initPullToRefresh: function () {
- var that = this;
- that.dimensions.y.forceEnabled();
- that.pullTemplate = kendo.template(that.options.messages.pullTemplate);
- that.releaseTemplate = kendo.template(that.options.messages.releaseTemplate);
- that.refreshTemplate = kendo.template(that.options.messages.refreshTemplate);
- that.scrollElement.prepend('
' + that.pullTemplate({}) + '');
- that.refreshHint = that.scrollElement.children().first();
- that.hintContainer = that.refreshHint.children('.km-template');
- that.pane.y.bind('change', proxy(that._paneChange, that));
- that.userEvents.bind('end', proxy(that._dragEnd, that));
- },
- _dragEnd: function () {
- var that = this;
- if (!that.pulled) {
- return;
- }
- that.pulled = false;
- that.refreshHint.removeClass(RELEASECLASS).addClass(REFRESHCLASS);
- that.hintContainer.html(that.refreshTemplate({}));
- that.yinertia.freeze(that.options.pullOffset / 2);
- that.trigger('pull');
- },
- _paneChange: function () {
- var that = this;
- if (that.movable.y / OUT_OF_BOUNDS_FRICTION > that.options.pullOffset) {
- if (!that.pulled) {
- that.pulled = true;
- that.refreshHint.removeClass(REFRESHCLASS).addClass(RELEASECLASS);
- that.hintContainer.html(that.releaseTemplate({}));
- }
- } else if (that.pulled) {
- that.pulled = false;
- that.refreshHint.removeClass(RELEASECLASS);
- that.hintContainer.html(that.pullTemplate({}));
- }
- },
- _initAxis: function (axis) {
- var that = this, movable = that.movable, dimension = that.dimensions[axis], tapCapture = that.tapCapture, paneAxis = that.pane[axis], scrollBar = new ScrollBar({
- axis: axis,
- movable: movable,
- dimension: dimension,
- container: that.element,
- alwaysVisible: that.options.visibleScrollHints
- });
- dimension.bind(CHANGE, function () {
- scrollBar.refresh();
- });
- paneAxis.bind(CHANGE, function () {
- scrollBar.show();
- });
- that[axis + 'inertia'] = new DragInertia({
- axis: axis,
- paneAxis: paneAxis,
- movable: movable,
- tapCapture: tapCapture,
- userEvents: that.userEvents,
- dimension: dimension,
- elastic: that.options.elastic,
- friction: that.options.friction || FRICTION,
- velocityMultiplier: that.options.velocityMultiplier || VELOCITY_MULTIPLIER,
- end: function () {
- scrollBar.hide();
- that.trigger('scrollEnd', {
- axis: axis,
- scrollTop: that.scrollTop,
- scrollLeft: that.scrollLeft
- });
- }
- });
- }
- });
- ui.plugin(Scroller);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.autocomplete', [
- 'kendo.list',
- 'kendo.mobile.scroller',
- 'kendo.virtuallist'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'autocomplete',
- name: 'AutoComplete',
- category: 'web',
- description: 'The AutoComplete widget provides suggestions depending on the typed text.It also allows multiple value entries.',
- depends: ['list'],
- features: [
- {
- id: 'mobile-scroller',
- name: 'Mobile scroller',
- description: 'Support for kinetic scrolling in mobile device',
- depends: ['mobile.scroller']
- },
- {
- id: 'virtualization',
- name: 'VirtualList',
- description: 'Support for virtualization',
- depends: ['virtuallist']
- }
- ]
- };
- (function ($, undefined) {
- var kendo = window.kendo, support = kendo.support, caret = kendo.caret, activeElement = kendo._activeElement, placeholderSupported = support.placeholder, ui = kendo.ui, List = ui.List, keys = kendo.keys, DataSource = kendo.data.DataSource, ARIA_DISABLED = 'aria-disabled', ARIA_READONLY = 'aria-readonly', CHANGE = 'change', DEFAULT = 'k-state-default', DISABLED = 'disabled', READONLY = 'readonly', FOCUSED = 'k-state-focused', SELECTED = 'k-state-selected', STATEDISABLED = 'k-state-disabled', HOVER = 'k-state-hover', ns = '.kendoAutoComplete', HOVEREVENTS = 'mouseenter' + ns + ' mouseleave' + ns, proxy = $.proxy;
- function indexOfWordAtCaret(caretIdx, text, separator) {
- return separator ? text.substring(0, caretIdx).split(separator).length - 1 : 0;
- }
- function wordAtCaret(caretIdx, text, separator) {
- return text.split(separator)[indexOfWordAtCaret(caretIdx, text, separator)];
- }
- function replaceWordAtCaret(caretIdx, text, word, separator, defaultSeparator) {
- var words = text.split(separator);
- words.splice(indexOfWordAtCaret(caretIdx, text, separator), 1, word);
- if (separator && words[words.length - 1] !== '') {
- words.push('');
- }
- return words.join(defaultSeparator);
- }
- var AutoComplete = List.extend({
- init: function (element, options) {
- var that = this, wrapper, disabled;
- that.ns = ns;
- options = $.isArray(options) ? { dataSource: options } : options;
- List.fn.init.call(that, element, options);
- element = that.element;
- options = that.options;
- options.placeholder = options.placeholder || element.attr('placeholder');
- if (placeholderSupported) {
- element.attr('placeholder', options.placeholder);
- }
- that._wrapper();
- that._loader();
- that._clearButton();
- that._dataSource();
- that._ignoreCase();
- element[0].type = 'text';
- wrapper = that.wrapper;
- that._popup();
- element.addClass('k-input').on('keydown' + ns, proxy(that._keydown, that)).on('keypress' + ns, proxy(that._keypress, that)).on('input' + ns, proxy(that._search, that)).on('paste' + ns, proxy(that._search, that)).on('focus' + ns, function () {
- that._prev = that._accessor();
- that._oldText = that._prev;
- that._placeholder(false);
- wrapper.addClass(FOCUSED);
- }).on('focusout' + ns, function () {
- that._change();
- that._placeholder();
- that.close();
- wrapper.removeClass(FOCUSED);
- }).attr({
- autocomplete: 'off',
- role: 'textbox',
- 'aria-haspopup': true
- });
- that._clear.on('click' + ns + ' touchend' + ns, proxy(that._clearValue, that));
- that._enable();
- that._old = that._accessor();
- if (element[0].id) {
- element.attr('aria-owns', that.ul[0].id);
- }
- that._aria();
- that._placeholder();
- that._initList();
- disabled = $(that.element).parents('fieldset').is(':disabled');
- if (disabled) {
- that.enable(false);
- }
- that.listView.bind('click', function (e) {
- e.preventDefault();
- });
- that._resetFocusItemHandler = $.proxy(that._resetFocusItem, that);
- kendo.notify(that);
- that._toggleCloseVisibility();
- },
- options: {
- name: 'AutoComplete',
- enabled: true,
- suggest: false,
- template: '',
- groupTemplate: '#:data#',
- fixedGroupTemplate: '#:data#',
- dataTextField: '',
- minLength: 1,
- enforceMinLength: false,
- delay: 200,
- height: 200,
- filter: 'startswith',
- ignoreCase: true,
- highlightFirst: false,
- separator: null,
- placeholder: '',
- animation: {},
- virtual: false,
- value: null,
- clearButton: true,
- autoWidth: false
- },
- _dataSource: function () {
- var that = this;
- if (that.dataSource && that._refreshHandler) {
- that._unbindDataSource();
- } else {
- that._progressHandler = proxy(that._showBusy, that);
- that._errorHandler = proxy(that._hideBusy, that);
- }
- that.dataSource = DataSource.create(that.options.dataSource).bind('progress', that._progressHandler).bind('error', that._errorHandler);
- },
- setDataSource: function (dataSource) {
- this.options.dataSource = dataSource;
- this._dataSource();
- this.listView.setDataSource(this.dataSource);
- },
- events: [
- 'open',
- 'close',
- CHANGE,
- 'select',
- 'filtering',
- 'dataBinding',
- 'dataBound'
- ],
- setOptions: function (options) {
- var listOptions = this._listOptions(options);
- List.fn.setOptions.call(this, options);
- this.listView.setOptions(listOptions);
- this._accessors();
- this._aria();
- this._clearButton();
- },
- _listOptions: function (options) {
- var listOptions = List.fn._listOptions.call(this, $.extend(options, { skipUpdateOnBind: true }));
- listOptions.dataValueField = listOptions.dataTextField;
- listOptions.selectedItemChange = null;
- return listOptions;
- },
- _editable: function (options) {
- var that = this, element = that.element, wrapper = that.wrapper.off(ns), readonly = options.readonly, disable = options.disable;
- if (!readonly && !disable) {
- wrapper.addClass(DEFAULT).removeClass(STATEDISABLED).on(HOVEREVENTS, that._toggleHover);
- element.removeAttr(DISABLED).removeAttr(READONLY).attr(ARIA_DISABLED, false).attr(ARIA_READONLY, false);
- } else {
- wrapper.addClass(disable ? STATEDISABLED : DEFAULT).removeClass(disable ? DEFAULT : STATEDISABLED);
- element.attr(DISABLED, disable).attr(READONLY, readonly).attr(ARIA_DISABLED, disable).attr(ARIA_READONLY, readonly);
- }
- },
- close: function () {
- var that = this;
- var current = that.listView.focus();
- if (current) {
- current.removeClass(SELECTED);
- }
- that.popup.close();
- },
- destroy: function () {
- var that = this;
- that.element.off(ns);
- that._clear.off(ns);
- that.wrapper.off(ns);
- List.fn.destroy.call(that);
- },
- refresh: function () {
- this.listView.refresh();
- },
- select: function (li) {
- this._select(li);
- },
- search: function (word) {
- var that = this, options = that.options, ignoreCase = options.ignoreCase, separator = that._separator(), length;
- word = word || that._accessor();
- clearTimeout(that._typingTimeout);
- if (separator) {
- word = wordAtCaret(caret(that.element)[0], word, separator);
- }
- length = word.length;
- if (!options.enforceMinLength && !length || length >= options.minLength) {
- that._open = true;
- that._mute(function () {
- this.listView.value([]);
- });
- that._filterSource({
- value: ignoreCase ? word.toLowerCase() : word,
- operator: options.filter,
- field: options.dataTextField,
- ignoreCase: ignoreCase
- });
- that.one('close', $.proxy(that._unifySeparators, that));
- }
- that._toggleCloseVisibility();
- },
- suggest: function (word) {
- var that = this, key = that._last, value = that._accessor(), element = that.element[0], caretIdx = caret(element)[0], separator = that._separator(), words = value.split(separator), wordIndex = indexOfWordAtCaret(caretIdx, value, separator), selectionEnd = caretIdx, idx;
- if (key == keys.BACKSPACE || key == keys.DELETE) {
- that._last = undefined;
- return;
- }
- word = word || '';
- if (typeof word !== 'string') {
- if (word[0]) {
- word = that.dataSource.view()[List.inArray(word[0], that.ul[0])];
- }
- word = word ? that._text(word) : '';
- }
- if (caretIdx <= 0) {
- caretIdx = value.toLowerCase().indexOf(word.toLowerCase()) + 1;
- }
- idx = value.substring(0, caretIdx).lastIndexOf(separator);
- idx = idx > -1 ? caretIdx - (idx + separator.length) : caretIdx;
- value = words[wordIndex].substring(0, idx);
- if (word) {
- word = word.toString();
- idx = word.toLowerCase().indexOf(value.toLowerCase());
- if (idx > -1) {
- word = word.substring(idx + value.length);
- selectionEnd = caretIdx + word.length;
- value += word;
- }
- if (separator && words[words.length - 1] !== '') {
- words.push('');
- }
- }
- words[wordIndex] = value;
- that._accessor(words.join(separator || ''));
- if (element === activeElement()) {
- caret(element, caretIdx, selectionEnd);
- }
- },
- value: function (value) {
- if (value !== undefined) {
- this.listView.value(value);
- this._accessor(value);
- this._old = this._accessor();
- this._oldText = this._accessor();
- } else {
- return this._accessor();
- }
- this._toggleCloseVisibility();
- },
- _click: function (e) {
- var item = e.item;
- var that = this;
- var element = that.element;
- var dataItem = that.listView.dataItemByIndex(that.listView.getElementIndex(item));
- e.preventDefault();
- that._active = true;
- if (that.trigger('select', {
- dataItem: dataItem,
- item: item
- })) {
- that.close();
- return;
- }
- that._oldText = element.val();
- that._select(item).done(function () {
- that._blur();
- caret(element, element.val().length);
- });
- },
- _clearText: $.noop,
- _resetFocusItem: function () {
- var index = this.options.highlightFirst ? 0 : -1;
- if (this.options.virtual) {
- this.listView.scrollTo(0);
- }
- this.listView.focus(index);
- },
- _listBound: function () {
- var that = this;
- var popup = that.popup;
- var options = that.options;
- var data = that.dataSource.flatView();
- var length = data.length;
- var groupsLength = that.dataSource._group.length;
- var isActive = that.element[0] === activeElement();
- var action;
- that._renderFooter();
- that._renderNoData();
- that._toggleNoData(!length);
- that._toggleHeader(!!groupsLength && !!length);
- that._resizePopup();
- popup.position();
- if (length) {
- if (options.suggest && isActive) {
- that.suggest(data[0]);
- }
- }
- if (that._open) {
- that._open = false;
- action = that._allowOpening() ? 'open' : 'close';
- if (that._typingTimeout && !isActive) {
- action = 'close';
- }
- if (length) {
- that._resetFocusItem();
- if (options.virtual) {
- that.popup.unbind('activate', that._resetFocusItemHandler).one('activate', that._resetFocusItemHandler);
- }
- }
- popup[action]();
- that._typingTimeout = undefined;
- }
- if (that._touchScroller) {
- that._touchScroller.reset();
- }
- that._hideBusy();
- that._makeUnselectable();
- that.trigger('dataBound');
- },
- _mute: function (callback) {
- this._muted = true;
- callback.call(this);
- this._muted = false;
- },
- _listChange: function () {
- var isActive = this._active || this.element[0] === activeElement();
- if (isActive && !this._muted) {
- this._selectValue(this.listView.selectedDataItems()[0]);
- }
- },
- _selectValue: function (dataItem) {
- var separator = this._separator();
- var text = '';
- if (dataItem) {
- text = this._text(dataItem);
- }
- if (text === null) {
- text = '';
- }
- if (separator) {
- text = replaceWordAtCaret(caret(this.element)[0], this._accessor(), text, separator, this._defaultSeparator());
- }
- this._prev = text;
- this._accessor(text);
- this._placeholder();
- },
- _unifySeparators: function () {
- this._accessor(this.value().split(this._separator()).join(this._defaultSeparator()));
- return this;
- },
- _preselect: function (value, text) {
- this._inputValue(text);
- this._accessor(value);
- this._old = this.oldText = this._accessor();
- this.listView.setValue(value);
- this._placeholder();
- },
- _change: function () {
- var that = this;
- var value = that._unifySeparators().value();
- var trigger = value !== List.unifyType(that._old, typeof value);
- var valueUpdated = trigger && !that._typing;
- var itemSelected = that._oldText !== value;
- that._old = value;
- that._oldText = value;
- if (valueUpdated || itemSelected) {
- that.element.trigger(CHANGE);
- }
- if (trigger) {
- that.trigger(CHANGE);
- }
- that.typing = false;
- that._toggleCloseVisibility();
- },
- _accessor: function (value) {
- var that = this, element = that.element[0];
- if (value !== undefined) {
- element.value = value === null ? '' : value;
- that._placeholder();
- } else {
- value = element.value;
- if (element.className.indexOf('k-readonly') > -1) {
- if (value === that.options.placeholder) {
- return '';
- } else {
- return value;
- }
- }
- return value;
- }
- },
- _keydown: function (e) {
- var that = this;
- var key = e.keyCode;
- var listView = that.listView;
- var visible = that.popup.visible();
- var current = listView.focus();
- that._last = key;
- if (key === keys.DOWN) {
- if (visible) {
- this._move(current ? 'focusNext' : 'focusFirst');
- } else if (that.value()) {
- that._filterSource({
- value: that.ignoreCase ? that.value().toLowerCase() : that.value(),
- operator: that.options.filter,
- field: that.options.dataTextField,
- ignoreCase: that.ignoreCase
- }).done(function () {
- if (that._allowOpening()) {
- that._resetFocusItem();
- that.popup.open();
- }
- });
- }
- e.preventDefault();
- } else if (key === keys.UP) {
- if (visible) {
- this._move(current ? 'focusPrev' : 'focusLast');
- }
- e.preventDefault();
- } else if (key === keys.HOME) {
- this._move('focusFirst');
- } else if (key === keys.END) {
- this._move('focusLast');
- } else if (key === keys.ENTER || key === keys.TAB) {
- if (key === keys.ENTER && visible) {
- e.preventDefault();
- }
- if (visible && current) {
- var dataItem = listView.dataItemByIndex(listView.getElementIndex(current));
- if (that.trigger('select', {
- dataItem: dataItem,
- item: current
- })) {
- return;
- }
- this._select(current);
- }
- this._blur();
- } else if (key === keys.ESC) {
- if (visible) {
- e.preventDefault();
- } else {
- that._clearValue();
- }
- that.close();
- } else if (that.popup.visible() && (key === keys.PAGEDOWN || key === keys.PAGEUP)) {
- e.preventDefault();
- var direction = key === keys.PAGEDOWN ? 1 : -1;
- listView.scrollWith(direction * listView.screenHeight());
- } else {
- that.popup._hovered = true;
- that._search();
- }
- },
- _keypress: function () {
- this._oldText = this.element.val();
- this._typing = true;
- },
- _move: function (action) {
- this.listView[action]();
- if (this.options.suggest) {
- this.suggest(this.listView.focus());
- }
- },
- _hideBusy: function () {
- var that = this;
- clearTimeout(that._busy);
- that._loading.hide();
- that.element.attr('aria-busy', false);
- that._busy = null;
- that._showClear();
- },
- _showBusy: function () {
- var that = this;
- if (that._busy) {
- return;
- }
- that._busy = setTimeout(function () {
- that.element.attr('aria-busy', true);
- that._loading.show();
- that._hideClear();
- }, 100);
- },
- _placeholder: function (show) {
- if (placeholderSupported) {
- return;
- }
- var that = this, element = that.element, placeholder = that.options.placeholder, value;
- if (placeholder) {
- value = element.val();
- if (show === undefined) {
- show = !value;
- }
- if (!show) {
- if (value !== placeholder) {
- placeholder = value;
- } else {
- placeholder = '';
- }
- }
- if (value === that._old && !show) {
- return;
- }
- element.toggleClass('k-readonly', show).val(placeholder);
- if (!placeholder && element[0] === document.activeElement) {
- caret(element[0], 0, 0);
- }
- }
- },
- _separator: function () {
- var separator = this.options.separator;
- if (separator instanceof Array) {
- return new RegExp(separator.join('|'), 'gi');
- }
- return separator;
- },
- _defaultSeparator: function () {
- var separator = this.options.separator;
- if (separator instanceof Array) {
- return separator[0];
- }
- return separator;
- },
- _inputValue: function () {
- return this.element.val();
- },
- _search: function () {
- var that = this;
- clearTimeout(that._typingTimeout);
- that._typingTimeout = setTimeout(function () {
- if (that._prev !== that._accessor()) {
- that._prev = that._accessor();
- that.search();
- }
- }, that.options.delay);
- },
- _select: function (candidate) {
- var that = this;
- that._active = true;
- return that.listView.select(candidate).done(function () {
- that._active = false;
- });
- },
- _loader: function () {
- this._loading = $('
').insertAfter(this.element);
- },
- _clearButton: function () {
- List.fn._clearButton.call(this);
- if (this.options.clearButton) {
- this._clear.insertAfter(this.element);
- this.wrapper.addClass('k-autocomplete-clearable');
- }
- },
- _toggleHover: function (e) {
- $(e.currentTarget).toggleClass(HOVER, e.type === 'mouseenter');
- },
- _toggleCloseVisibility: function () {
- if (this.value()) {
- this._showClear();
- } else {
- this._hideClear();
- }
- },
- _wrapper: function () {
- var that = this, element = that.element, DOMelement = element[0], wrapper;
- wrapper = element.parent();
- if (!wrapper.is('span.k-widget')) {
- wrapper = element.wrap('
').parent();
- }
- wrapper.attr('tabindex', -1);
- wrapper.attr('role', 'presentation');
- wrapper[0].style.cssText = DOMelement.style.cssText;
- element.css({
- width: '',
- height: DOMelement.style.height
- });
- that._focused = that.element;
- that.wrapper = wrapper.addClass('k-widget k-autocomplete').addClass(DOMelement.className);
- that._inputWrapper = $(wrapper[0]);
- }
- });
- ui.plugin(AutoComplete);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.combobox', [
- 'kendo.list',
- 'kendo.mobile.scroller',
- 'kendo.virtuallist'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'combobox',
- name: 'ComboBox',
- category: 'web',
- description: 'The ComboBox widget allows the selection from pre-defined values or entering a new value.',
- depends: ['list'],
- features: [
- {
- id: 'mobile-scroller',
- name: 'Mobile scroller',
- description: 'Support for kinetic scrolling in mobile device',
- depends: ['mobile.scroller']
- },
- {
- id: 'virtualization',
- name: 'VirtualList',
- description: 'Support for virtualization',
- depends: ['virtuallist']
- }
- ]
- };
- (function ($, undefined) {
- var kendo = window.kendo, ui = kendo.ui, List = ui.List, Select = ui.Select, caret = kendo.caret, support = kendo.support, placeholderSupported = support.placeholder, activeElement = kendo._activeElement, keys = kendo.keys, ns = '.kendoComboBox', nsFocusEvent = ns + 'FocusEvent', CLICK = 'click' + ns, MOUSEDOWN = 'mousedown' + ns, DISABLED = 'disabled', READONLY = 'readonly', CHANGE = 'change', LOADING = 'k-i-loading', DEFAULT = 'k-state-default', FOCUSED = 'k-state-focused', STATEDISABLED = 'k-state-disabled', ARIA_DISABLED = 'aria-disabled', STATE_FILTER = 'filter', STATE_ACCEPT = 'accept', STATE_REBIND = 'rebind', HOVEREVENTS = 'mouseenter' + ns + ' mouseleave' + ns, proxy = $.proxy, newLineRegEx = /(\r\n|\n|\r)/gm;
- var ComboBox = Select.extend({
- init: function (element, options) {
- var that = this, text, disabled;
- that.ns = ns;
- options = $.isArray(options) ? { dataSource: options } : options;
- Select.fn.init.call(that, element, options);
- options = that.options;
- element = that.element.on('focus' + ns, proxy(that._focusHandler, that));
- options.placeholder = options.placeholder || element.attr('placeholder');
- that._reset();
- that._wrapper();
- that._input();
- that._clearButton();
- that._tabindex(that.input);
- that._popup();
- that._dataSource();
- that._ignoreCase();
- that._enable();
- that._attachFocusEvents();
- that._oldIndex = that.selectedIndex = -1;
- that._aria();
- that._initialIndex = options.index;
- that.requireValueMapper(that.options);
- that._initList();
- that._cascade();
- if (options.autoBind) {
- that._filterSource();
- } else {
- text = options.text;
- if (!text && that._isSelect) {
- text = element.children(':selected').text();
- }
- if (text) {
- that._setText(text);
- }
- }
- if (!text) {
- that._placeholder();
- }
- disabled = $(that.element).parents('fieldset').is(':disabled');
- if (disabled) {
- that.enable(false);
- }
- kendo.notify(that);
- that._toggleCloseVisibility();
- },
- options: {
- name: 'ComboBox',
- enabled: true,
- index: -1,
- text: null,
- value: null,
- autoBind: true,
- delay: 200,
- dataTextField: '',
- dataValueField: '',
- minLength: 1,
- enforceMinLength: false,
- height: 200,
- highlightFirst: true,
- filter: 'none',
- placeholder: '',
- suggest: false,
- cascadeFrom: '',
- cascadeFromField: '',
- cascadeFromParentField: '',
- ignoreCase: true,
- animation: {},
- virtual: false,
- template: null,
- groupTemplate: '#:data#',
- fixedGroupTemplate: '#:data#',
- clearButton: true,
- syncValueAndText: true,
- autoWidth: false
- },
- events: [
- 'open',
- 'close',
- CHANGE,
- 'select',
- 'filtering',
- 'dataBinding',
- 'dataBound',
- 'cascade',
- 'set'
- ],
- setOptions: function (options) {
- var listOptions = this._listOptions(options);
- Select.fn.setOptions.call(this, options);
- this.listView.setOptions(listOptions);
- this._accessors();
- this._aria();
- this._clearButton();
- },
- destroy: function () {
- var that = this;
- that.input.off(ns);
- that.input.off(nsFocusEvent);
- that.element.off(ns);
- that._inputWrapper.off(ns);
- clearTimeout(that._pasteTimeout);
- that._arrow.off(CLICK + ' ' + MOUSEDOWN);
- that._clear.off(CLICK + ' ' + MOUSEDOWN);
- Select.fn.destroy.call(that);
- },
- _change: function () {
- var that = this;
- var text = that.text();
- var hasText = text && text !== that._oldText && text !== that.options.placeholder;
- var index = that.selectedIndex;
- var isCustom = index === -1;
- if (!that.options.syncValueAndText && !that.value() && isCustom && hasText) {
- that._old = '';
- that._oldIndex = index;
- that._oldText = text;
- if (!that._typing) {
- that.element.trigger(CHANGE);
- }
- that.trigger(CHANGE);
- that._typing = false;
- return;
- }
- Select.fn._change.call(that);
- that._toggleCloseVisibility();
- },
- _attachFocusEvents: function () {
- var that = this;
- that.input.on('focus' + nsFocusEvent, proxy(that._inputFocus, that)).on('focusout' + nsFocusEvent, proxy(that._inputFocusout, that));
- },
- _focusHandler: function () {
- this.input.focus();
- },
- _arrowClick: function () {
- this._toggle();
- },
- _inputFocus: function () {
- this._inputWrapper.addClass(FOCUSED);
- this._placeholder(false);
- },
- _inputFocusout: function () {
- var that = this;
- var value = that.value();
- that._userTriggered = true;
- that._inputWrapper.removeClass(FOCUSED);
- clearTimeout(that._typingTimeout);
- that._typingTimeout = null;
- that.text(that.text());
- var item = that._focus();
- var dataItem = this.listView.dataItemByIndex(this.listView.getElementIndex(item));
- if (value !== that.value() && that.trigger('select', {
- dataItem: dataItem,
- item: item
- })) {
- that.value(value);
- return;
- }
- that._placeholder();
- that._blur();
- that.element.blur();
- },
- _inputPaste: function () {
- var that = this;
- clearTimeout(that._pasteTimeout);
- that._pasteTimeout = null;
- that._pasteTimeout = setTimeout(function () {
- that.search();
- });
- },
- _editable: function (options) {
- var that = this, disable = options.disable, readonly = options.readonly, wrapper = that._inputWrapper.off(ns), input = that.element.add(that.input.off(ns)), arrow = that._arrow.off(CLICK + ' ' + MOUSEDOWN), clear = that._clear;
- if (!readonly && !disable) {
- wrapper.addClass(DEFAULT).removeClass(STATEDISABLED).on(HOVEREVENTS, that._toggleHover);
- input.removeAttr(DISABLED).removeAttr(READONLY).attr(ARIA_DISABLED, false);
- arrow.on(CLICK, proxy(that._arrowClick, that)).on(MOUSEDOWN, function (e) {
- e.preventDefault();
- });
- clear.on(CLICK + ' touchend' + ns, proxy(that._clearValue, that)).on(MOUSEDOWN, function (e) {
- e.preventDefault();
- });
- that.input.on('keydown' + ns, proxy(that._keydown, that)).on('input' + ns, proxy(that._search, that)).on('paste' + ns, proxy(that._inputPaste, that));
- } else {
- wrapper.addClass(disable ? STATEDISABLED : DEFAULT).removeClass(disable ? DEFAULT : STATEDISABLED);
- input.attr(DISABLED, disable).attr(READONLY, readonly).attr(ARIA_DISABLED, disable);
- }
- that._toggleCloseVisibility();
- },
- open: function () {
- var that = this;
- var state = that._state;
- var isFiltered = that.dataSource.filter() ? that.dataSource.filter().filters.length > 0 : false;
- var reinitialized = !that.ul.find(that.listView.focus()).length;
- if (that.popup.visible()) {
- return;
- }
- if (!that.listView.bound() && state !== STATE_FILTER || state === STATE_ACCEPT) {
- that._open = true;
- that._state = STATE_REBIND;
- if (that.options.minLength !== 1 && !isFiltered || isFiltered && that.value() && that.selectedIndex === -1) {
- that.refresh();
- that._openPopup();
- if (!this.options.virtual) {
- that.listView.bound(false);
- }
- } else {
- that._filterSource();
- }
- } else if (that._allowOpening()) {
- that.popup._hovered = true;
- that._openPopup();
- if (that.options.virtual) {
- that._focusItem();
- } else if (reinitialized && that.options.highlightFirst) {
- that.listView.focus(0);
- }
- }
- },
- _scrollToFocusedItem: function () {
- var listView = this.listView;
- listView.scrollToIndex(listView.getElementIndex(listView.focus()));
- },
- _openPopup: function () {
- this.popup.one('activate', proxy(this._scrollToFocusedItem, this));
- this.popup.open();
- },
- _updateSelectionState: function () {
- var that = this;
- var text = that.options.text;
- var value = that.options.value;
- if (that.listView.isFiltered()) {
- return;
- }
- if (that.selectedIndex === -1) {
- if (text === undefined || text === null) {
- text = value;
- }
- that._accessor(value);
- that.input.val(text || that.input.val());
- that._placeholder();
- } else if (that._oldIndex === -1) {
- that._oldIndex = that.selectedIndex;
- }
- },
- _buildOptions: function (data) {
- var that = this;
- if (!that._isSelect) {
- return;
- }
- var custom = that._customOption;
- if (that._state === STATE_REBIND) {
- that._state = '';
- }
- that._customOption = undefined;
- that._options(data, '', that.value());
- if (custom && custom[0].selected && !that.listView._emptySearch) {
- that._custom(custom.val());
- }
- },
- _updateSelection: function () {
- var that = this;
- var listView = that.listView;
- var initialIndex = that._initialIndex;
- var hasInitialIndex = initialIndex !== null && initialIndex > -1;
- var filtered = that._state === STATE_FILTER;
- if (filtered) {
- $(listView.focus()).removeClass('k-state-selected');
- return;
- }
- if (that._fetch) {
- return;
- }
- if (!listView.value().length) {
- if (hasInitialIndex) {
- that.select(initialIndex);
- } else if (that._accessor()) {
- listView.value(that._accessor());
- }
- }
- that._initialIndex = null;
- var dataItem = listView.selectedDataItems()[0];
- if (!dataItem) {
- return;
- }
- if (that._value(dataItem) !== that.value()) {
- that._custom(that._value(dataItem));
- } else if (that._value(dataItem) !== that.element[0].value) {
- that._accessor(that._value(dataItem));
- }
- if (that.text() && that.text() !== that._text(dataItem)) {
- that._selectValue(dataItem);
- }
- },
- _updateItemFocus: function () {
- var listView = this.listView;
- if (!this.options.highlightFirst) {
- listView.focus(-1);
- } else if (!listView.focus() && !listView.focusIndex()) {
- listView.focus(0);
- }
- },
- _listBound: function () {
- var that = this;
- var isActive = that.input[0] === activeElement();
- var data = that.dataSource.flatView();
- var skip = that.listView.skip();
- var length = data.length;
- var groupsLength = that.dataSource._group ? that.dataSource._group.length : 0;
- var isFirstPage = skip === undefined || skip === 0;
- that._presetValue = false;
- that._renderFooter();
- that._renderNoData();
- that._toggleNoData(!length);
- that._toggleHeader(!!groupsLength && !!length);
- that._resizePopup();
- that.popup.position();
- that._buildOptions(data);
- that._makeUnselectable();
- that._updateSelection();
- if (data.length && isFirstPage) {
- that._updateItemFocus();
- if (that.options.suggest && isActive && that.input.val()) {
- that.suggest(data[0]);
- }
- }
- if (that._open) {
- that._open = false;
- if (that._typingTimeout && !isActive) {
- that.popup.close();
- } else {
- that.toggle(that._allowOpening());
- }
- that._typingTimeout = null;
- }
- that._hideBusy();
- that.trigger('dataBound');
- },
- _listChange: function () {
- this._selectValue(this.listView.selectedDataItems()[0]);
- if (this._presetValue) {
- this._oldIndex = this.selectedIndex;
- }
- },
- _get: function (candidate) {
- var data, found, idx;
- if (typeof candidate === 'function') {
- data = this.dataSource.flatView();
- for (idx = 0; idx < data.length; idx++) {
- if (candidate(data[idx])) {
- candidate = idx;
- found = true;
- break;
- }
- }
- if (!found) {
- candidate = -1;
- }
- }
- return candidate;
- },
- _select: function (candidate, keepState) {
- var that = this;
- candidate = that._get(candidate);
- if (candidate === -1) {
- that.input[0].value = '';
- that._accessor('');
- }
- return that.listView.select(candidate).done(function () {
- if (!keepState && that._state === STATE_FILTER) {
- that._state = STATE_ACCEPT;
- }
- that._toggleCloseVisibility();
- });
- },
- _selectValue: function (dataItem) {
- var idx = this.listView.select();
- var value = '';
- var text = '';
- idx = idx[idx.length - 1];
- if (idx === undefined) {
- idx = -1;
- }
- this.selectedIndex = idx;
- if (this.listView.isFiltered() && idx !== -1) {
- this._valueBeforeCascade = this._old;
- }
- if (idx === -1 && !dataItem) {
- if (this.options.syncValueAndText) {
- if (this.options.dataTextField === this.options.dataValueField) {
- text = this._accessor();
- } else {
- text = this.input[0].value;
- }
- value = text;
- } else {
- text = this.text();
- }
- this.listView.focus(-1);
- } else {
- if (dataItem || dataItem === 0) {
- value = this._dataValue(dataItem);
- text = this._text(dataItem);
- }
- if (value === null) {
- value = '';
- }
- }
- this._setDomInputValue(text);
- this._accessor(value !== undefined ? value : text, idx);
- this._placeholder();
- this._triggerCascade();
- },
- _setDomInputValue: function (text) {
- var that = this;
- var currentCaret = caret(this.input);
- var caretStart;
- if (currentCaret && currentCaret.length) {
- caretStart = currentCaret[0];
- }
- this._prev = this.input[0].value = text;
- if (caretStart && this.selectedIndex === -1) {
- var mobile = support.mobileOS;
- if (mobile.wp || mobile.android) {
- setTimeout(function () {
- that.input[0].setSelectionRange(caretStart, caretStart);
- }, 0);
- } else {
- this.input[0].setSelectionRange(caretStart, caretStart);
- }
- }
- },
- refresh: function () {
- this.listView.refresh();
- },
- _toggleCloseVisibility: function () {
- var preventShow = this.element.is(':disabled') || this.element.is('[readonly]');
- if (this.text() && !preventShow) {
- this._showClear();
- } else {
- this._hideClear();
- }
- },
- suggest: function (word) {
- var that = this;
- var element = that.input[0];
- var value = that.text();
- var caretIdx = caret(element)[0];
- var key = that._last;
- var idx;
- if (key == keys.BACKSPACE || key == keys.DELETE) {
- that._last = undefined;
- return;
- }
- word = word || '';
- if (typeof word !== 'string') {
- if (word[0]) {
- word = that.dataSource.view()[List.inArray(word[0], that.ul[0])];
- }
- word = word ? that._text(word) : '';
- }
- if (caretIdx <= 0) {
- caretIdx = value.toLowerCase().indexOf(word.toLowerCase()) + 1;
- }
- if (word) {
- word = word.toString();
- idx = word.toLowerCase().indexOf(value.toLowerCase());
- if (idx > -1) {
- value += word.substring(idx + value.length);
- }
- } else {
- value = value.substring(0, caretIdx);
- }
- if (value.length !== caretIdx || !word) {
- element.value = value;
- if (element === activeElement()) {
- caret(element, caretIdx, value.length);
- }
- }
- },
- text: function (text) {
- text = text === null ? '' : text;
- var that = this;
- var input = that.input[0];
- var ignoreCase = that.options.ignoreCase;
- var loweredText = text;
- var dataItem;
- var value;
- if (text === undefined) {
- return input.value;
- }
- if (that.options.autoBind === false && !that.listView.bound()) {
- that._setText(text);
- return;
- }
- dataItem = that.dataItem();
- if (dataItem && that._text(dataItem).replace && that._text(dataItem).replace(newLineRegEx, '') === text) {
- value = that._value(dataItem);
- if (value === List.unifyType(that._old, typeof value)) {
- that._triggerCascade();
- return;
- }
- }
- if (ignoreCase) {
- loweredText = loweredText.toLowerCase();
- }
- that._select(function (data) {
- data = that._text(data);
- if (ignoreCase) {
- data = (data + '').toLowerCase();
- }
- return data === loweredText;
- }).done(function () {
- if (that.selectedIndex < 0) {
- input.value = text;
- if (that.options.syncValueAndText) {
- that._accessor(text);
- }
- that._cascadeTriggered = true;
- that._triggerCascade();
- }
- that._prev = input.value;
- });
- that._toggleCloseVisibility();
- },
- toggle: function (toggle) {
- this._toggle(toggle, true);
- },
- value: function (value) {
- var that = this;
- var options = that.options;
- var listView = that.listView;
- if (value === undefined) {
- value = that._accessor() || that.listView.value()[0];
- return value === undefined || value === null ? '' : value;
- }
- that.requireValueMapper(that.options, value);
- that.trigger('set', { value: value });
- if (value === options.value && that.input.val() === options.text) {
- return;
- }
- that._accessor(value);
- if (that._isFilterEnabled() && listView.bound() && listView.isFiltered()) {
- that._clearFilter();
- } else {
- that._fetchData();
- }
- listView.value(value).done(function () {
- if (that.selectedIndex === -1 && (!listView._selectedDataItems || !listView._selectedDataItems.length)) {
- that._accessor(value);
- that.input.val(value);
- that._placeholder(true);
- }
- that._old = that._valueBeforeCascade = that._accessor();
- that._oldIndex = that.selectedIndex;
- that._prev = that.input.val();
- if (that._state === STATE_FILTER) {
- that._state = STATE_ACCEPT;
- }
- that._toggleCloseVisibility();
- });
- },
- _hideBusy: function () {
- var that = this;
- clearTimeout(that._busy);
- that._arrowIcon.removeClass(LOADING);
- that._focused.attr('aria-busy', false);
- that._busy = null;
- that._toggleCloseVisibility();
- },
- _click: function (e) {
- var that = this;
- var item = e.item;
- var dataItem = that.listView.dataItemByIndex(that.listView.getElementIndex(item));
- var shouldTrigger = true;
- e.preventDefault();
- if (dataItem) {
- shouldTrigger = that._value(dataItem) !== List.unifyType(that.value(), typeof that._value(dataItem));
- if (!shouldTrigger) {
- that.input.val(that._text(dataItem));
- }
- }
- if (shouldTrigger && that.trigger('select', {
- dataItem: dataItem,
- item: item
- })) {
- that.close();
- return;
- }
- that._userTriggered = true;
- that._select(item).done(function () {
- that._blur();
- });
- },
- _syncValueAndText: function () {
- return this.options.syncValueAndText;
- },
- _inputValue: function () {
- return this.text();
- },
- _searchByWord: function (word) {
- var that = this;
- var options = that.options;
- var dataSource = that.dataSource;
- var ignoreCase = options.ignoreCase;
- var predicate = function (dataItem) {
- var text = that._text(dataItem);
- if (text !== undefined) {
- text = text + '';
- if (text !== '' && word === '') {
- return false;
- }
- if (ignoreCase) {
- text = text.toLowerCase();
- }
- return text.indexOf(word) === 0;
- }
- };
- if (ignoreCase) {
- word = word.toLowerCase();
- }
- if (!that.ul[0].firstChild) {
- dataSource.one(CHANGE, function () {
- if (dataSource.view()[0]) {
- that.search(word);
- }
- }).fetch();
- return;
- }
- this.listView.focus(this._get(predicate));
- var current = this.listView.focus();
- if (current) {
- if (options.suggest) {
- that.suggest(current);
- }
- this.open();
- }
- if (this.options.highlightFirst && !word) {
- this.listView.focusFirst();
- }
- },
- _input: function () {
- var that = this, element = that.element.removeClass('k-input')[0], accessKey = element.accessKey, wrapper = that.wrapper, SELECTOR = 'input.k-input', name = element.name || '', input, maxLength;
- if (name) {
- name = 'name="' + name + '_input" ';
- }
- input = wrapper.find(SELECTOR);
- if (!input[0]) {
- wrapper.append('
').append(that.element);
- input = wrapper.find(SELECTOR);
- }
- input[0].style.cssText = element.style.cssText;
- input[0].title = element.title;
- maxLength = parseInt(this.element.prop('maxlength') || this.element.attr('maxlength'), 10);
- if (maxLength > -1) {
- input[0].maxLength = maxLength;
- }
- input.addClass(element.className).css({
- width: '',
- height: element.style.height
- }).attr({
- 'role': 'combobox',
- 'aria-expanded': false
- }).show();
- if (placeholderSupported) {
- input.attr('placeholder', that.options.placeholder);
- }
- if (accessKey) {
- element.accessKey = '';
- input[0].accessKey = accessKey;
- }
- that._focused = that.input = input;
- that._inputWrapper = $(wrapper[0].firstChild);
- that._arrow = wrapper.find('.k-select').attr({
- 'role': 'button',
- 'tabIndex': -1
- });
- that._arrowIcon = that._arrow.find('.k-icon');
- if (element.id) {
- that._arrow.attr('aria-controls', that.ul[0].id);
- }
- },
- _clearButton: function () {
- List.fn._clearButton.call(this);
- if (this.options.clearButton) {
- this._clear.insertAfter(this.input);
- this.wrapper.addClass('k-combobox-clearable');
- }
- },
- _keydown: function (e) {
- var that = this, key = e.keyCode;
- that._last = key;
- clearTimeout(that._typingTimeout);
- that._typingTimeout = null;
- if (key === keys.HOME) {
- that._firstItem();
- } else if (key === keys.END) {
- that._lastItem();
- } else if (key === keys.ENTER || key === keys.TAB && that.popup.visible()) {
- var current = that.listView.focus();
- var dataItem = that.dataItem();
- var shouldTrigger = true;
- if (!that.popup.visible() && (!dataItem || that.text() !== that._text(dataItem))) {
- current = null;
- }
- if (current) {
- if (that.popup.visible()) {
- e.preventDefault();
- }
- dataItem = that.listView.dataItemByIndex(that.listView.getElementIndex(current));
- if (dataItem) {
- shouldTrigger = that._value(dataItem) !== List.unifyType(that.value(), typeof that._value(dataItem));
- }
- if (shouldTrigger && that.trigger('select', {
- dataItem: dataItem,
- item: current
- })) {
- return;
- }
- that._userTriggered = true;
- that._select(current).done(function () {
- that._blur();
- that._valueBeforeCascade = that._old = that.value();
- });
- } else {
- if (that._syncValueAndText() || that._isSelect) {
- that._accessor(that.input.val());
- }
- that.listView.value(that.input.val());
- that._blur();
- }
- } else if (key != keys.TAB && !that._move(e)) {
- that._search();
- } else if (key === keys.ESC && !that.popup.visible() && that.text()) {
- that._clearValue();
- }
- },
- _placeholder: function (show) {
- if (placeholderSupported) {
- return;
- }
- var that = this, input = that.input, placeholder = that.options.placeholder, value;
- if (placeholder) {
- value = that.value();
- if (show === undefined) {
- show = !value;
- }
- input.toggleClass('k-readonly', show);
- if (!show) {
- if (!value) {
- placeholder = '';
- } else {
- return;
- }
- }
- input.val(placeholder);
- if (!placeholder && input[0] === activeElement()) {
- caret(input[0], 0, 0);
- }
- }
- },
- _search: function () {
- var that = this;
- clearTimeout(that._typingTimeout);
- that._typingTimeout = setTimeout(function () {
- var value = that.text();
- if (that._prev !== value) {
- that._prev = value;
- if (that.options.filter === 'none' && that.options.virtual) {
- that.listView.select(-1);
- }
- that.search(value);
- that._toggleCloseVisibility();
- }
- that._typingTimeout = null;
- }, that.options.delay);
- },
- _setText: function (text) {
- this.input.val(text);
- this._prev = text;
- },
- _wrapper: function () {
- var that = this, element = that.element, wrapper = element.parent();
- if (!wrapper.is('span.k-widget')) {
- wrapper = element.hide().wrap('
').parent();
- wrapper[0].style.cssText = element[0].style.cssText;
- }
- that.wrapper = wrapper.addClass('k-widget k-combobox').addClass(element[0].className).css('display', '');
- },
- _clearSelection: function (parent, isFiltered) {
- var that = this;
- var hasValue = parent.value();
- var custom = hasValue && parent.selectedIndex === -1;
- if (this.selectedIndex == -1 && this.value()) {
- return;
- }
- if (isFiltered || !hasValue || custom) {
- that.options.value = '';
- that.value('');
- that._selectedValue = null;
- }
- },
- _preselect: function (value, text) {
- this.input.val(text);
- this._accessor(value);
- this._old = this._accessor();
- this._oldIndex = this.selectedIndex;
- this.listView.setValue(value);
- this._placeholder();
- this._initialIndex = null;
- this._presetValue = true;
- this._toggleCloseVisibility();
- }
- });
- ui.plugin(ComboBox);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.dropdownlist', [
- 'kendo.list',
- 'kendo.mobile.scroller',
- 'kendo.virtuallist'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'dropdownlist',
- name: 'DropDownList',
- category: 'web',
- description: 'The DropDownList widget displays a list of values and allows the selection of a single value from the list.',
- depends: ['list'],
- features: [
- {
- id: 'mobile-scroller',
- name: 'Mobile scroller',
- description: 'Support for kinetic scrolling in mobile device',
- depends: ['mobile.scroller']
- },
- {
- id: 'virtualization',
- name: 'VirtualList',
- description: 'Support for virtualization',
- depends: ['virtuallist']
- }
- ]
- };
- (function ($, undefined) {
- var kendo = window.kendo, ui = kendo.ui, List = ui.List, Select = ui.Select, support = kendo.support, activeElement = kendo._activeElement, ObservableObject = kendo.data.ObservableObject, keys = kendo.keys, ns = '.kendoDropDownList', nsFocusEvent = ns + 'FocusEvent', DISABLED = 'disabled', READONLY = 'readonly', CHANGE = 'change', FOCUSED = 'k-state-focused', DEFAULT = 'k-state-default', STATEDISABLED = 'k-state-disabled', ARIA_DISABLED = 'aria-disabled', CLICKEVENTS = 'click' + ns + ' touchend' + ns, HOVEREVENTS = 'mouseenter' + ns + ' mouseleave' + ns, TABINDEX = 'tabindex', STATE_FILTER = 'filter', STATE_ACCEPT = 'accept', MSG_INVALID_OPTION_LABEL = 'The `optionLabel` option is not valid due to missing fields. Define a custom optionLabel as shown here http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#configuration-optionLabel', proxy = $.proxy;
- var DropDownList = Select.extend({
- init: function (element, options) {
- var that = this;
- var index = options && options.index;
- var optionLabel, text, disabled;
- that.ns = ns;
- options = $.isArray(options) ? { dataSource: options } : options;
- Select.fn.init.call(that, element, options);
- options = that.options;
- element = that.element.on('focus' + ns, proxy(that._focusHandler, that));
- that._focusInputHandler = $.proxy(that._focusInput, that);
- that.optionLabel = $();
- that._optionLabel();
- that._inputTemplate();
- that._reset();
- that._prev = '';
- that._word = '';
- that._wrapper();
- that._tabindex();
- that.wrapper.data(TABINDEX, that.wrapper.attr(TABINDEX));
- that._span();
- that._popup();
- that._mobile();
- that._dataSource();
- that._ignoreCase();
- that._filterHeader();
- that._aria();
- that.wrapper.attr('aria-live', 'polite');
- that._enable();
- that._attachFocusHandlers();
- that._oldIndex = that.selectedIndex = -1;
- if (index !== undefined) {
- options.index = index;
- }
- that._initialIndex = options.index;
- that.requireValueMapper(that.options);
- that._initList();
- that._cascade();
- that.one('set', function (e) {
- if (!e.sender.listView.bound() && that.hasOptionLabel()) {
- that._textAccessor(that._optionLabelText());
- }
- });
- if (options.autoBind) {
- that.dataSource.fetch();
- } else if (that.selectedIndex === -1) {
- text = options.text || '';
- if (!text) {
- optionLabel = options.optionLabel;
- if (optionLabel && options.index === 0) {
- text = optionLabel;
- } else if (that._isSelect) {
- text = element.children(':selected').text();
- }
- }
- that._textAccessor(text);
- }
- disabled = $(that.element).parents('fieldset').is(':disabled');
- if (disabled) {
- that.enable(false);
- }
- that.listView.bind('click', function (e) {
- e.preventDefault();
- });
- kendo.notify(that);
- },
- options: {
- name: 'DropDownList',
- enabled: true,
- autoBind: true,
- index: 0,
- text: null,
- value: null,
- delay: 500,
- height: 200,
- dataTextField: '',
- dataValueField: '',
- optionLabel: '',
- cascadeFrom: '',
- cascadeFromField: '',
- cascadeFromParentField: '',
- ignoreCase: true,
- animation: {},
- filter: 'none',
- minLength: 1,
- enforceMinLength: false,
- virtual: false,
- template: null,
- valueTemplate: null,
- optionLabelTemplate: null,
- groupTemplate: '#:data#',
- fixedGroupTemplate: '#:data#',
- autoWidth: false
- },
- events: [
- 'open',
- 'close',
- CHANGE,
- 'select',
- 'filtering',
- 'dataBinding',
- 'dataBound',
- 'cascade',
- 'set'
- ],
- setOptions: function (options) {
- Select.fn.setOptions.call(this, options);
- this.listView.setOptions(this._listOptions(options));
- this._optionLabel();
- this._inputTemplate();
- this._accessors();
- this._filterHeader();
- this._enable();
- this._aria();
- if (!this.value() && this.hasOptionLabel()) {
- this.select(0);
- }
- },
- destroy: function () {
- var that = this;
- Select.fn.destroy.call(that);
- that.wrapper.off(ns);
- that.wrapper.off(nsFocusEvent);
- that.element.off(ns);
- that._inputWrapper.off(ns);
- that._arrow.off();
- that._arrow = null;
- that._arrowIcon = null;
- that.optionLabel.off();
- if (that.filterInput) {
- that.filterInput.off(nsFocusEvent);
- }
- },
- open: function () {
- var that = this;
- var isFiltered = that.dataSource.filter() ? that.dataSource.filter().filters.length > 0 : false;
- if (that.popup.visible()) {
- return;
- }
- if (!that.listView.bound() || that._state === STATE_ACCEPT) {
- that._open = true;
- that._state = 'rebind';
- if (that.filterInput) {
- that.filterInput.val('');
- that._prev = '';
- }
- if (that.filterInput && that.options.minLength !== 1 && !isFiltered) {
- that.refresh();
- that.popup.one('activate', that._focusInputHandler);
- that.popup.open();
- that._resizeFilterInput();
- } else {
- that._filterSource();
- }
- } else if (that._allowOpening()) {
- that._focusFilter = true;
- that.popup.one('activate', that._focusInputHandler);
- that.popup._hovered = true;
- that.popup.open();
- that._resizeFilterInput();
- that._focusItem();
- }
- },
- _focusInput: function () {
- this._focusElement(this.filterInput);
- },
- _resizeFilterInput: function () {
- var filterInput = this.filterInput;
- var originalPrevent = this._prevent;
- if (!filterInput) {
- return;
- }
- var isInputActive = this.filterInput[0] === activeElement();
- var caret = kendo.caret(this.filterInput[0])[0];
- this._prevent = true;
- filterInput.css('display', 'none').css('width', this.popup.element.css('width')).css('display', 'inline-block');
- if (isInputActive) {
- filterInput.focus();
- kendo.caret(filterInput[0], caret);
- }
- this._prevent = originalPrevent;
- },
- _allowOpening: function () {
- return this.hasOptionLabel() || this.filterInput || Select.fn._allowOpening.call(this);
- },
- toggle: function (toggle) {
- this._toggle(toggle, true);
- },
- current: function (candidate) {
- var current;
- if (candidate === undefined) {
- current = this.listView.focus();
- if (!current && this.selectedIndex === 0 && this.hasOptionLabel()) {
- return this.optionLabel;
- }
- return current;
- }
- this._focus(candidate);
- },
- dataItem: function (index) {
- var that = this;
- var dataItem = null;
- if (index === null) {
- return index;
- }
- if (index === undefined) {
- dataItem = that.listView.selectedDataItems()[0];
- } else {
- if (typeof index !== 'number') {
- if (that.options.virtual) {
- return that.dataSource.getByUid($(index).data('uid'));
- }
- if (index.hasClass('k-list-optionlabel')) {
- index = -1;
- } else {
- index = $(that.items()).index(index);
- }
- } else if (that.hasOptionLabel()) {
- index -= 1;
- }
- dataItem = that.dataSource.flatView()[index];
- }
- if (!dataItem) {
- dataItem = that._optionLabelDataItem();
- }
- return dataItem;
- },
- refresh: function () {
- this.listView.refresh();
- },
- text: function (text) {
- var that = this;
- var loweredText;
- var ignoreCase = that.options.ignoreCase;
- text = text === null ? '' : text;
- if (text !== undefined) {
- if (typeof text !== 'string') {
- that._textAccessor(text);
- return;
- }
- loweredText = ignoreCase ? text.toLowerCase() : text;
- that._select(function (data) {
- data = that._text(data);
- if (ignoreCase) {
- data = (data + '').toLowerCase();
- }
- return data === loweredText;
- }).done(function () {
- that._textAccessor(that.dataItem() || text);
- });
- } else {
- return that._textAccessor();
- }
- },
- _clearFilter: function () {
- $(this.filterInput).val('');
- Select.fn._clearFilter.call(this);
- },
- value: function (value) {
- var that = this;
- var listView = that.listView;
- var dataSource = that.dataSource;
- if (value === undefined) {
- value = that._accessor() || that.listView.value()[0];
- return value === undefined || value === null ? '' : value;
- }
- that.requireValueMapper(that.options, value);
- if (value || !that.hasOptionLabel()) {
- that._initialIndex = null;
- }
- this.trigger('set', { value: value });
- if (that._request && that.options.cascadeFrom && that.listView.bound()) {
- if (that._valueSetter) {
- dataSource.unbind(CHANGE, that._valueSetter);
- }
- that._valueSetter = proxy(function () {
- that.value(value);
- }, that);
- dataSource.one(CHANGE, that._valueSetter);
- return;
- }
- if (that._isFilterEnabled() && listView.bound() && listView.isFiltered()) {
- that._clearFilter();
- } else {
- that._fetchData();
- }
- listView.value(value).done(function () {
- that._old = that._valueBeforeCascade = that._accessor();
- that._oldIndex = that.selectedIndex;
- });
- },
- hasOptionLabel: function () {
- return this.optionLabel && !!this.optionLabel[0];
- },
- _optionLabel: function () {
- var that = this;
- var options = that.options;
- var optionLabel = options.optionLabel;
- var template = options.optionLabelTemplate;
- if (!optionLabel) {
- that.optionLabel.off().remove();
- that.optionLabel = $();
- return;
- }
- if (!template) {
- template = '#:';
- if (typeof optionLabel === 'string') {
- template += 'data';
- } else {
- template += kendo.expr(options.dataTextField, 'data');
- }
- template += '#';
- }
- if (typeof template !== 'function') {
- template = kendo.template(template);
- }
- that.optionLabelTemplate = template;
- if (!that.hasOptionLabel()) {
- that.optionLabel = $('
').prependTo(that.list);
- }
- that.optionLabel.html(template(optionLabel)).off().on(CLICKEVENTS, proxy(that._click, that)).on(HOVEREVENTS, that._toggleHover);
- that.angular('compile', function () {
- return {
- elements: that.optionLabel,
- data: [{ dataItem: that._optionLabelDataItem() }]
- };
- });
- },
- _optionLabelText: function () {
- var optionLabel = this.options.optionLabel;
- return typeof optionLabel === 'string' ? optionLabel : this._text(optionLabel);
- },
- _optionLabelDataItem: function () {
- var that = this;
- var optionLabel = that.options.optionLabel;
- if (that.hasOptionLabel()) {
- return $.isPlainObject(optionLabel) ? new ObservableObject(optionLabel) : that._assignInstance(that._optionLabelText(), '');
- }
- return undefined;
- },
- _buildOptions: function (data) {
- var that = this;
- if (!that._isSelect) {
- return;
- }
- var value = that.listView.value()[0];
- var optionLabel = that._optionLabelDataItem();
- var optionLabelValue = optionLabel && that._value(optionLabel);
- if (value === undefined || value === null) {
- value = '';
- }
- if (optionLabel) {
- if (optionLabelValue === undefined || optionLabelValue === null) {
- optionLabelValue = '';
- }
- optionLabel = '
';
- }
- that._options(data, optionLabel, value);
- if (value !== List.unifyType(that._accessor(), typeof value)) {
- that._customOption = null;
- that._custom(value);
- }
- },
- _listBound: function () {
- var that = this;
- var initialIndex = that._initialIndex;
- var filtered = that._state === STATE_FILTER;
- var data = that.dataSource.flatView();
- var dataItem;
- that._presetValue = false;
- that._renderFooter();
- that._renderNoData();
- that._toggleNoData(!data.length);
- that._resizePopup(true);
- that.popup.position();
- that._buildOptions(data);
- that._makeUnselectable();
- if (!filtered) {
- if (that._open) {
- that.toggle(that._allowOpening());
- }
- that._open = false;
- if (!that._fetch) {
- if (data.length) {
- if (!that.listView.value().length && initialIndex > -1 && initialIndex !== null) {
- that.select(initialIndex);
- }
- that._initialIndex = null;
- dataItem = that.listView.selectedDataItems()[0];
- if (dataItem && that.text() !== that._text(dataItem)) {
- that._selectValue(dataItem);
- }
- } else if (that._textAccessor() !== that._optionLabelText()) {
- that.listView.value('');
- that._selectValue(null);
- that._oldIndex = that.selectedIndex;
- }
- }
- }
- that._hideBusy();
- that.trigger('dataBound');
- },
- _listChange: function () {
- this._selectValue(this.listView.selectedDataItems()[0]);
- if (this._presetValue || this._old && this._oldIndex === -1) {
- this._oldIndex = this.selectedIndex;
- }
- },
- _filterPaste: function () {
- this._search();
- },
- _attachFocusHandlers: function () {
- var that = this;
- var wrapper = that.wrapper;
- wrapper.on('focusin' + nsFocusEvent, proxy(that._focusinHandler, that)).on('focusout' + nsFocusEvent, proxy(that._focusoutHandler, that));
- if (that.filterInput) {
- that.filterInput.on('focusin' + nsFocusEvent, proxy(that._focusinHandler, that)).on('focusout' + nsFocusEvent, proxy(that._focusoutHandler, that));
- }
- },
- _focusHandler: function () {
- this.wrapper.focus();
- },
- _focusinHandler: function () {
- this._inputWrapper.addClass(FOCUSED);
- this._prevent = false;
- },
- _focusoutHandler: function () {
- var that = this;
- var isIFrame = window.self !== window.top;
- if (!that._prevent) {
- clearTimeout(that._typingTimeout);
- if (support.mobileOS.ios && isIFrame) {
- that._change();
- } else {
- that._blur();
- }
- that._inputWrapper.removeClass(FOCUSED);
- that._prevent = true;
- that._open = false;
- that.element.blur();
- }
- },
- _wrapperMousedown: function () {
- this._prevent = !!this.filterInput;
- },
- _wrapperClick: function (e) {
- e.preventDefault();
- this.popup.unbind('activate', this._focusInputHandler);
- this._focused = this.wrapper;
- this._prevent = false;
- this._toggle();
- },
- _editable: function (options) {
- var that = this;
- var element = that.element;
- var disable = options.disable;
- var readonly = options.readonly;
- var wrapper = that.wrapper.add(that.filterInput).off(ns);
- var dropDownWrapper = that._inputWrapper.off(HOVEREVENTS);
- if (!readonly && !disable) {
- element.removeAttr(DISABLED).removeAttr(READONLY);
- dropDownWrapper.addClass(DEFAULT).removeClass(STATEDISABLED).on(HOVEREVENTS, that._toggleHover);
- wrapper.attr(TABINDEX, wrapper.data(TABINDEX)).attr(ARIA_DISABLED, false).on('keydown' + ns, proxy(that._keydown, that)).on(kendo.support.mousedown + ns, proxy(that._wrapperMousedown, that)).on('paste' + ns, proxy(that._filterPaste, that));
- that.wrapper.on('click' + ns, proxy(that._wrapperClick, that));
- if (!that.filterInput) {
- wrapper.on('keypress' + ns, proxy(that._keypress, that));
- } else {
- wrapper.on('input' + ns, proxy(that._search, that));
- }
- } else if (disable) {
- wrapper.removeAttr(TABINDEX);
- dropDownWrapper.addClass(STATEDISABLED).removeClass(DEFAULT);
- } else {
- dropDownWrapper.addClass(DEFAULT).removeClass(STATEDISABLED);
- }
- element.attr(DISABLED, disable).attr(READONLY, readonly);
- wrapper.attr(ARIA_DISABLED, disable);
- },
- _keydown: function (e) {
- var that = this;
- var key = e.keyCode;
- var altKey = e.altKey;
- var isInputActive;
- var handled;
- var isPopupVisible = that.popup.visible();
- if (that.filterInput) {
- isInputActive = that.filterInput[0] === activeElement();
- }
- if (key === keys.LEFT) {
- key = keys.UP;
- handled = true;
- } else if (key === keys.RIGHT) {
- key = keys.DOWN;
- handled = true;
- }
- if (handled && isInputActive) {
- return;
- }
- e.keyCode = key;
- if (altKey && key === keys.UP || key === keys.ESC) {
- that._focusElement(that.wrapper);
- }
- if (that._state === STATE_FILTER && key === keys.ESC) {
- that._clearFilter();
- that._open = false;
- that._state = STATE_ACCEPT;
- }
- if (key === keys.ENTER && that._typingTimeout && that.filterInput && isPopupVisible) {
- e.preventDefault();
- return;
- }
- if (key === keys.SPACEBAR && !isInputActive) {
- that.toggle(!isPopupVisible);
- e.preventDefault();
- }
- handled = that._move(e);
- if (handled) {
- return;
- }
- if (!isPopupVisible || !that.filterInput) {
- var current = that._focus();
- if (key === keys.HOME) {
- handled = true;
- that._firstItem();
- } else if (key === keys.END) {
- handled = true;
- that._lastItem();
- }
- if (handled) {
- if (that.trigger('select', {
- dataItem: that._getElementDataItem(that._focus()),
- item: that._focus()
- })) {
- that._focus(current);
- return;
- }
- that._select(that._focus(), true).done(function () {
- if (!isPopupVisible) {
- that._blur();
- }
- });
- e.preventDefault();
- }
- }
- if (!altKey && !handled && that.filterInput) {
- that._search();
- }
- },
- _matchText: function (text, word) {
- var ignoreCase = this.options.ignoreCase;
- if (text === undefined || text === null) {
- return false;
- }
- text = text + '';
- if (ignoreCase) {
- text = text.toLowerCase();
- }
- return text.indexOf(word) === 0;
- },
- _shuffleData: function (data, splitIndex) {
- var optionDataItem = this._optionLabelDataItem();
- if (optionDataItem) {
- data = [optionDataItem].concat(data);
- }
- return data.slice(splitIndex).concat(data.slice(0, splitIndex));
- },
- _selectNext: function () {
- var that = this;
- var data = that.dataSource.flatView();
- var dataLength = data.length + (that.hasOptionLabel() ? 1 : 0);
- var isInLoop = sameCharsOnly(that._word, that._last);
- var startIndex = that.selectedIndex;
- var oldFocusedItem;
- var text;
- if (startIndex === -1) {
- startIndex = 0;
- } else {
- startIndex += isInLoop ? 1 : 0;
- startIndex = normalizeIndex(startIndex, dataLength);
- }
- data = data.toJSON ? data.toJSON() : data.slice();
- data = that._shuffleData(data, startIndex);
- for (var idx = 0; idx < dataLength; idx++) {
- text = that._text(data[idx]);
- if (isInLoop && that._matchText(text, that._last)) {
- break;
- } else if (that._matchText(text, that._word)) {
- break;
- }
- }
- if (idx !== dataLength) {
- oldFocusedItem = that._focus();
- that._select(normalizeIndex(startIndex + idx, dataLength)).done(function () {
- var done = function () {
- if (!that.popup.visible()) {
- that._change();
- }
- };
- if (that.trigger('select', {
- dataItem: that._getElementDataItem(that._focus()),
- item: that._focus()
- })) {
- that._select(oldFocusedItem).done(done);
- } else {
- done();
- }
- });
- }
- },
- _keypress: function (e) {
- var that = this;
- if (e.which === 0 || e.keyCode === kendo.keys.ENTER) {
- return;
- }
- var character = String.fromCharCode(e.charCode || e.keyCode);
- if (that.options.ignoreCase) {
- character = character.toLowerCase();
- }
- if (character === ' ') {
- e.preventDefault();
- }
- that._word += character;
- that._last = character;
- that._search();
- },
- _popupOpen: function () {
- var popup = this.popup;
- popup.wrapper = kendo.wrap(popup.element);
- if (popup.element.closest('.km-root')[0]) {
- popup.wrapper.addClass('km-popup km-widget');
- this.wrapper.addClass('km-widget');
- }
- },
- _popup: function () {
- Select.fn._popup.call(this);
- this.popup.one('open', proxy(this._popupOpen, this));
- },
- _getElementDataItem: function (element) {
- if (!element || !element[0]) {
- return null;
- }
- if (element[0] === this.optionLabel[0]) {
- return this._optionLabelDataItem();
- }
- return this.listView.dataItemByIndex(this.listView.getElementIndex(element));
- },
- _click: function (e) {
- var that = this;
- var item = e.item || $(e.currentTarget);
- e.preventDefault();
- if (that.trigger('select', {
- dataItem: that._getElementDataItem(item),
- item: item
- })) {
- that.close();
- return;
- }
- that._userTriggered = true;
- that._select(item).done(function () {
- that._focusElement(that.wrapper);
- that._blur();
- });
- },
- _focusElement: function (element) {
- var active = activeElement();
- var wrapper = this.wrapper;
- var filterInput = this.filterInput;
- var compareElement = element === filterInput ? wrapper : filterInput;
- var touchEnabled = support.mobileOS && (support.touch || support.MSPointers || support.pointers);
- if (filterInput && filterInput[0] === element[0] && touchEnabled) {
- return;
- }
- if (filterInput && (compareElement[0] === active || this._focusFilter)) {
- this._focusFilter = false;
- this._prevent = true;
- this._focused = element.focus();
- }
- },
- _searchByWord: function (word) {
- if (!word) {
- return;
- }
- var that = this;
- var ignoreCase = that.options.ignoreCase;
- if (ignoreCase) {
- word = word.toLowerCase();
- }
- that._select(function (dataItem) {
- return that._matchText(that._text(dataItem), word);
- });
- },
- _inputValue: function () {
- return this.text();
- },
- _search: function () {
- var that = this;
- var dataSource = that.dataSource;
- clearTimeout(that._typingTimeout);
- if (that._isFilterEnabled()) {
- that._typingTimeout = setTimeout(function () {
- var value = that.filterInput.val();
- if (that._prev !== value) {
- that._prev = value;
- that.search(value);
- that._resizeFilterInput();
- }
- that._typingTimeout = null;
- }, that.options.delay);
- } else {
- that._typingTimeout = setTimeout(function () {
- that._word = '';
- }, that.options.delay);
- if (!that.listView.bound()) {
- dataSource.fetch().done(function () {
- that._selectNext();
- });
- return;
- }
- that._selectNext();
- }
- },
- _get: function (candidate) {
- var data, found, idx;
- var isFunction = typeof candidate === 'function';
- var jQueryCandidate = !isFunction ? $(candidate) : $();
- if (this.hasOptionLabel()) {
- if (typeof candidate === 'number') {
- if (candidate > -1) {
- candidate -= 1;
- }
- } else if (jQueryCandidate.hasClass('k-list-optionlabel')) {
- candidate = -1;
- }
- }
- if (isFunction) {
- data = this.dataSource.flatView();
- for (idx = 0; idx < data.length; idx++) {
- if (candidate(data[idx])) {
- candidate = idx;
- found = true;
- break;
- }
- }
- if (!found) {
- candidate = -1;
- }
- }
- return candidate;
- },
- _firstItem: function () {
- if (this.hasOptionLabel()) {
- this._focus(this.optionLabel);
- } else {
- this.listView.focusFirst();
- }
- },
- _lastItem: function () {
- this._resetOptionLabel();
- this.listView.focusLast();
- },
- _nextItem: function () {
- if (this.optionLabel.hasClass('k-state-focused')) {
- this._resetOptionLabel();
- this.listView.focusFirst();
- } else {
- this.listView.focusNext();
- }
- },
- _prevItem: function () {
- if (this.optionLabel.hasClass('k-state-focused')) {
- return;
- }
- this.listView.focusPrev();
- if (!this.listView.focus()) {
- this._focus(this.optionLabel);
- }
- },
- _focusItem: function () {
- var options = this.options;
- var listView = this.listView;
- var focusedItem = listView.focus();
- var index = listView.select();
- index = index[index.length - 1];
- if (index === undefined && options.highlightFirst && !focusedItem) {
- index = 0;
- }
- if (index !== undefined) {
- listView.focus(index);
- } else {
- if (options.optionLabel && (!options.virtual || options.virtual.mapValueTo !== 'dataItem')) {
- this._focus(this.optionLabel);
- this._select(this.optionLabel);
- this.listView.content.scrollTop(0);
- } else {
- listView.scrollToIndex(0);
- }
- }
- },
- _resetOptionLabel: function (additionalClass) {
- this.optionLabel.removeClass('k-state-focused' + (additionalClass || '')).removeAttr('id');
- },
- _focus: function (candidate) {
- var listView = this.listView;
- var optionLabel = this.optionLabel;
- if (candidate === undefined) {
- candidate = listView.focus();
- if (!candidate && optionLabel.hasClass('k-state-focused')) {
- candidate = optionLabel;
- }
- return candidate;
- }
- this._resetOptionLabel();
- candidate = this._get(candidate);
- listView.focus(candidate);
- if (candidate === -1) {
- optionLabel.addClass('k-state-focused').attr('id', listView._optionID);
- this._focused.add(this.filterInput).removeAttr('aria-activedescendant').attr('aria-activedescendant', listView._optionID);
- }
- },
- _select: function (candidate, keepState) {
- var that = this;
- candidate = that._get(candidate);
- return that.listView.select(candidate).done(function () {
- if (!keepState && that._state === STATE_FILTER) {
- that._state = STATE_ACCEPT;
- }
- if (candidate === -1) {
- that._selectValue(null);
- }
- });
- },
- _selectValue: function (dataItem) {
- var that = this;
- var optionLabel = that.options.optionLabel;
- var idx = that.listView.select();
- var value = '';
- var text = '';
- idx = idx[idx.length - 1];
- if (idx === undefined) {
- idx = -1;
- }
- this._resetOptionLabel(' k-state-selected');
- if (dataItem || dataItem === 0) {
- text = dataItem;
- value = that._dataValue(dataItem);
- if (optionLabel) {
- idx += 1;
- }
- } else if (optionLabel) {
- that._focus(that.optionLabel.addClass('k-state-selected'));
- text = that._optionLabelText();
- if (typeof optionLabel === 'string') {
- value = '';
- } else {
- value = that._value(optionLabel);
- }
- idx = 0;
- }
- that.selectedIndex = idx;
- if (value === null) {
- value = '';
- }
- that._textAccessor(text);
- that._accessor(value, idx);
- that._triggerCascade();
- },
- _mobile: function () {
- var that = this, popup = that.popup, mobileOS = support.mobileOS, root = popup.element.parents('.km-root').eq(0);
- if (root.length && mobileOS) {
- popup.options.animation.open.effects = mobileOS.android || mobileOS.meego ? 'fadeIn' : mobileOS.ios || mobileOS.wp ? 'slideIn:up' : popup.options.animation.open.effects;
- }
- },
- _filterHeader: function () {
- var icon;
- if (this.filterInput) {
- this.filterInput.off(ns).parent().remove();
- this.filterInput = null;
- }
- if (this._isFilterEnabled()) {
- icon = '
';
- this.filterInput = $('
').attr({
- placeholder: this.element.attr('placeholder'),
- title: this.element.attr('title'),
- role: 'listbox',
- 'aria-haspopup': true,
- 'aria-expanded': false
- });
- this.list.prepend($('
').append(this.filterInput.add(icon)));
- }
- },
- _span: function () {
- var that = this, wrapper = that.wrapper, SELECTOR = 'span.k-input', span;
- span = wrapper.find(SELECTOR);
- if (!span[0]) {
- wrapper.append('
').append(that.element);
- span = wrapper.find(SELECTOR);
- }
- that.span = span;
- that._inputWrapper = $(wrapper[0].firstChild);
- that._arrow = wrapper.find('.k-select');
- that._arrowIcon = that._arrow.find('.k-icon');
- },
- _wrapper: function () {
- var that = this, element = that.element, DOMelement = element[0], wrapper;
- wrapper = element.parent();
- if (!wrapper.is('span.k-widget')) {
- wrapper = element.wrap('
').parent();
- wrapper[0].style.cssText = DOMelement.style.cssText;
- wrapper[0].title = DOMelement.title;
- }
- that._focused = that.wrapper = wrapper.addClass('k-widget k-dropdown').addClass(DOMelement.className).css('display', '').attr({
- accesskey: element.attr('accesskey'),
- unselectable: 'on',
- role: 'listbox',
- 'aria-haspopup': true,
- 'aria-expanded': false
- });
- element.hide().removeAttr('accesskey');
- },
- _clearSelection: function (parent) {
- this.select(parent.value() ? 0 : -1);
- },
- _inputTemplate: function () {
- var that = this, template = that.options.valueTemplate;
- if (!template) {
- template = $.proxy(kendo.template('#:this._text(data)#', { useWithBlock: false }), that);
- } else {
- template = kendo.template(template);
- }
- that.valueTemplate = template;
- if (that.hasOptionLabel() && !that.options.optionLabelTemplate) {
- try {
- that.valueTemplate(that._optionLabelDataItem());
- } catch (e) {
- throw new Error(MSG_INVALID_OPTION_LABEL);
- }
- }
- },
- _textAccessor: function (text) {
- var dataItem = null;
- var template = this.valueTemplate;
- var optionLabelText = this._optionLabelText();
- var span = this.span;
- if (text === undefined) {
- return span.text();
- }
- if ($.isPlainObject(text) || text instanceof ObservableObject) {
- dataItem = text;
- } else if (optionLabelText && optionLabelText === text) {
- dataItem = this.options.optionLabel;
- }
- if (!dataItem) {
- dataItem = this._assignInstance(text, this._accessor());
- }
- if (this.hasOptionLabel()) {
- if (dataItem === optionLabelText || this._text(dataItem) === optionLabelText) {
- template = this.optionLabelTemplate;
- if (typeof this.options.optionLabel === 'string' && !this.options.optionLabelTemplate) {
- dataItem = optionLabelText;
- }
- }
- }
- var getElements = function () {
- return {
- elements: span.get(),
- data: [{ dataItem: dataItem }]
- };
- };
- this.angular('cleanup', getElements);
- try {
- span.html(template(dataItem));
- } catch (e) {
- span.html('');
- }
- this.angular('compile', getElements);
- },
- _preselect: function (value, text) {
- if (!value && !text) {
- text = this._optionLabelText();
- }
- this._accessor(value);
- this._textAccessor(text);
- this._old = this._accessor();
- this._oldIndex = this.selectedIndex;
- this.listView.setValue(value);
- this._initialIndex = null;
- this._presetValue = true;
- },
- _assignInstance: function (text, value) {
- var dataTextField = this.options.dataTextField;
- var dataItem = {};
- if (dataTextField) {
- assign(dataItem, dataTextField.split('.'), text);
- assign(dataItem, this.options.dataValueField.split('.'), value);
- dataItem = new ObservableObject(dataItem);
- } else {
- dataItem = text;
- }
- return dataItem;
- }
- });
- function assign(instance, fields, value) {
- var idx = 0, lastIndex = fields.length - 1, field;
- for (; idx < lastIndex; ++idx) {
- field = fields[idx];
- if (!(field in instance)) {
- instance[field] = {};
- }
- instance = instance[field];
- }
- instance[fields[lastIndex]] = value;
- }
- function normalizeIndex(index, length) {
- if (index >= length) {
- index -= length;
- }
- return index;
- }
- function sameCharsOnly(word, character) {
- for (var idx = 0; idx < word.length; idx++) {
- if (word.charAt(idx) !== character) {
- return false;
- }
- }
- return true;
- }
- ui.plugin(DropDownList);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.colorpicker', [
- 'kendo.core',
- 'kendo.color',
- 'kendo.popup',
- 'kendo.slider',
- 'kendo.userevents',
- 'kendo.button'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'colorpicker',
- name: 'Color tools',
- category: 'web',
- description: 'Color selection widgets',
- depends: [
- 'core',
- 'color',
- 'popup',
- 'slider',
- 'userevents',
- 'button'
- ]
- };
- (function ($, parseInt, undefined) {
- var kendo = window.kendo, ui = kendo.ui, Widget = ui.Widget, parseColor = kendo.parseColor, Color = kendo.Color, KEYS = kendo.keys, BACKGROUNDCOLOR = 'background-color', ITEMSELECTEDCLASS = 'k-state-selected', SIMPLEPALETTE = '000000,7f7f7f,880015,ed1c24,ff7f27,fff200,22b14c,00a2e8,3f48cc,a349a4,ffffff,c3c3c3,b97a57,ffaec9,ffc90e,efe4b0,b5e61d,99d9ea,7092be,c8bfe7', WEBPALETTE = 'FFFFFF,FFCCFF,FF99FF,FF66FF,FF33FF,FF00FF,CCFFFF,CCCCFF,CC99FF,CC66FF,CC33FF,CC00FF,99FFFF,99CCFF,9999FF,9966FF,9933FF,9900FF,FFFFCC,FFCCCC,FF99CC,FF66CC,FF33CC,FF00CC,CCFFCC,CCCCCC,CC99CC,CC66CC,CC33CC,CC00CC,99FFCC,99CCCC,9999CC,9966CC,9933CC,9900CC,FFFF99,FFCC99,FF9999,FF6699,FF3399,FF0099,CCFF99,CCCC99,CC9999,CC6699,CC3399,CC0099,99FF99,99CC99,999999,996699,993399,990099,FFFF66,FFCC66,FF9966,FF6666,FF3366,FF0066,CCFF66,CCCC66,CC9966,CC6666,CC3366,CC0066,99FF66,99CC66,999966,996666,993366,990066,FFFF33,FFCC33,FF9933,FF6633,FF3333,FF0033,CCFF33,CCCC33,CC9933,CC6633,CC3333,CC0033,99FF33,99CC33,999933,996633,993333,990033,FFFF00,FFCC00,FF9900,FF6600,FF3300,FF0000,CCFF00,CCCC00,CC9900,CC6600,CC3300,CC0000,99FF00,99CC00,999900,996600,993300,990000,66FFFF,66CCFF,6699FF,6666FF,6633FF,6600FF,33FFFF,33CCFF,3399FF,3366FF,3333FF,3300FF,00FFFF,00CCFF,0099FF,0066FF,0033FF,0000FF,66FFCC,66CCCC,6699CC,6666CC,6633CC,6600CC,33FFCC,33CCCC,3399CC,3366CC,3333CC,3300CC,00FFCC,00CCCC,0099CC,0066CC,0033CC,0000CC,66FF99,66CC99,669999,666699,663399,660099,33FF99,33CC99,339999,336699,333399,330099,00FF99,00CC99,009999,006699,003399,000099,66FF66,66CC66,669966,666666,663366,660066,33FF66,33CC66,339966,336666,333366,330066,00FF66,00CC66,009966,006666,003366,000066,66FF33,66CC33,669933,666633,663333,660033,33FF33,33CC33,339933,336633,333333,330033,00FF33,00CC33,009933,006633,003333,000033,66FF00,66CC00,669900,666600,663300,660000,33FF00,33CC00,339900,336600,333300,330000,00FF00,00CC00,009900,006600,003300,000000', WHITE = '#ffffff', MESSAGES = {
- apply: 'Apply',
- cancel: 'Cancel',
- noColor: 'no color',
- clearColor: 'Clear color',
- previewInput: 'Color Hexadecimal Code'
- }, NS = '.kendoColorTools', CLICK_NS = 'click' + NS, KEYDOWN_NS = 'keydown' + NS, browser = kendo.support.browser, isIE8 = browser.msie && browser.version < 9;
- var ColorSelector = Widget.extend({
- init: function (element, options) {
- var that = this, ariaId;
- Widget.fn.init.call(that, element, options);
- element = that.element;
- options = that.options;
- that._value = options.value = parseColor(options.value);
- that._tabIndex = element.attr('tabIndex') || 0;
- ariaId = that._ariaId = options.ariaId;
- if (ariaId) {
- element.attr('aria-labelledby', ariaId);
- }
- if (options._standalone) {
- that._triggerSelect = that._triggerChange;
- }
- },
- options: {
- name: 'ColorSelector',
- value: null,
- _standalone: true
- },
- events: [
- 'change',
- 'select',
- 'cancel'
- ],
- color: function (value) {
- if (value !== undefined) {
- this._value = parseColor(value);
- this._updateUI(this._value);
- }
- return this._value;
- },
- value: function (color) {
- color = this.color(color);
- if (color) {
- if (this.options.opacity) {
- color = color.toCssRgba();
- } else {
- color = color.toCss();
- }
- }
- return color || null;
- },
- enable: function (enable) {
- if (arguments.length === 0) {
- enable = true;
- }
- $('.k-disabled-overlay', this.wrapper).remove();
- if (!enable) {
- this.wrapper.append('
');
- }
- this._onEnable(enable);
- },
- _select: function (color, nohooks) {
- var prev = this._value;
- color = this.color(color);
- if (!nohooks) {
- this.element.trigger('change');
- if (!color.equals(prev)) {
- this.trigger('change', { value: this.value() });
- } else if (!this._standalone) {
- this.trigger('cancel');
- }
- }
- },
- _triggerSelect: function (color) {
- triggerEvent(this, 'select', color);
- },
- _triggerChange: function (color) {
- triggerEvent(this, 'change', color);
- },
- destroy: function () {
- if (this.element) {
- this.element.off(NS);
- }
- if (this.wrapper) {
- this.wrapper.off(NS).find('*').off(NS);
- }
- this.wrapper = null;
- Widget.fn.destroy.call(this);
- },
- _updateUI: $.noop,
- _selectOnHide: function () {
- return null;
- },
- _cancel: function () {
- this.trigger('cancel');
- }
- });
- function triggerEvent(self, type, color) {
- color = parseColor(color);
- if (color && !color.equals(self.color())) {
- if (type == 'change') {
- self._value = color;
- }
- if (color.a != 1) {
- color = color.toCssRgba();
- } else {
- color = color.toCss();
- }
- self.trigger(type, { value: color });
- }
- }
- var ColorPalette = ColorSelector.extend({
- init: function (element, options) {
- var that = this;
- ColorSelector.fn.init.call(that, element, options);
- element = that.wrapper = that.element;
- options = that.options;
- var colors = options.palette;
- if (colors == 'websafe') {
- colors = WEBPALETTE;
- options.columns = 18;
- } else if (colors == 'basic') {
- colors = SIMPLEPALETTE;
- }
- if (typeof colors == 'string') {
- colors = colors.split(',');
- }
- if ($.isArray(colors)) {
- colors = $.map(colors, function (x) {
- return parseColor(x);
- });
- }
- that._selectedID = (options.ariaId || kendo.guid()) + '_selected';
- element.addClass('k-widget k-colorpalette').attr('role', 'grid').attr('aria-readonly', 'true').append($(that._template({
- colors: colors,
- columns: options.columns,
- tileSize: options.tileSize,
- value: that._value,
- id: options.ariaId
- }))).on(CLICK_NS, '.k-item', function (ev) {
- that._select($(ev.currentTarget).css(BACKGROUNDCOLOR));
- }).attr('tabIndex', that._tabIndex).on(KEYDOWN_NS, bind(that._keydown, that));
- var tileSize = options.tileSize, width, height;
- if (tileSize) {
- if (/number|string/.test(typeof tileSize)) {
- width = height = parseFloat(tileSize);
- } else if (typeof tileSize == 'object') {
- width = parseFloat(tileSize.width);
- height = parseFloat(tileSize.height);
- } else {
- throw new Error('Unsupported value for the \'tileSize\' argument');
- }
- element.find('.k-item').css({
- width: width,
- height: height
- });
- }
- },
- focus: function () {
- if (this.wrapper && !this.wrapper.is('[unselectable=\'on\']')) {
- this.wrapper.focus();
- }
- },
- options: {
- name: 'ColorPalette',
- columns: 10,
- tileSize: null,
- palette: 'basic'
- },
- _onEnable: function (enable) {
- if (enable) {
- this.wrapper.attr('tabIndex', this._tabIndex);
- } else {
- this.wrapper.removeAttr('tabIndex');
- }
- },
- _keydown: function (e) {
- var selected, wrapper = this.wrapper, items = wrapper.find('.k-item'), current = items.filter('.' + ITEMSELECTEDCLASS).get(0), keyCode = e.keyCode;
- if (keyCode == KEYS.LEFT) {
- selected = relative(items, current, -1);
- } else if (keyCode == KEYS.RIGHT) {
- selected = relative(items, current, 1);
- } else if (keyCode == KEYS.DOWN) {
- selected = relative(items, current, this.options.columns);
- } else if (keyCode == KEYS.UP) {
- selected = relative(items, current, -this.options.columns);
- } else if (keyCode == KEYS.ENTER) {
- preventDefault(e);
- if (current) {
- this._select($(current).css(BACKGROUNDCOLOR));
- }
- } else if (keyCode == KEYS.ESC) {
- this._cancel();
- }
- if (selected) {
- preventDefault(e);
- this._current(selected);
- try {
- var color = parseColor(selected.css(BACKGROUNDCOLOR));
- this._triggerSelect(color);
- } catch (ex) {
- }
- }
- },
- _current: function (item) {
- this.wrapper.find('.' + ITEMSELECTEDCLASS).removeClass(ITEMSELECTEDCLASS).attr('aria-selected', false).removeAttr('id');
- $(item).addClass(ITEMSELECTEDCLASS).attr('aria-selected', true).attr('id', this._selectedID);
- this.element.removeAttr('aria-activedescendant').attr('aria-activedescendant', this._selectedID);
- },
- _updateUI: function (color) {
- var item = null;
- this.wrapper.find('.k-item').each(function () {
- var c = parseColor($(this).css(BACKGROUNDCOLOR));
- if (c && c.equals(color)) {
- item = this;
- return false;
- }
- });
- this._current(item);
- },
- _template: kendo.template('
' + '# for (var i = 0; i < colors.length; ++i) { #' + '# var selected = colors[i].equals(value); #' + '# if (i && i % columns == 0) { #
# } #' + ' | ' + '# } #' + '
')
- });
- var FlatColorPicker = ColorSelector.extend({
- init: function (element, options) {
- var that = this;
- ColorSelector.fn.init.call(that, element, options);
- options = that.options;
- options.messages = options.options ? $.extend(that.options.messages, options.options.messages) : that.options.messages;
- element = that.element;
- that.wrapper = element.addClass('k-widget k-flatcolorpicker').append(that._template(options));
- that._hueElements = $('.k-hsv-rectangle, .k-transparency-slider .k-slider-track', element);
- that._selectedColor = $('.k-selected-color-display', element);
- that._colorAsText = $('input.k-color-value', element);
- that._sliders();
- that._hsvArea();
- that._updateUI(that._value || parseColor('#f00'));
- element.find('input.k-color-value').on(KEYDOWN_NS, function (ev) {
- var input = this;
- if (ev.keyCode == KEYS.ENTER) {
- try {
- var color = parseColor(input.value);
- var val = that.color();
- that._select(color, color.equals(val));
- } catch (ex) {
- $(input).addClass('k-state-error');
- }
- } else if (that.options.autoupdate) {
- setTimeout(function () {
- var color = parseColor(input.value, true);
- if (color) {
- that._updateUI(color, true);
- }
- }, 10);
- }
- }).end().on(CLICK_NS, '.k-controls button.apply', function () {
- if (that.options._clearedColor) {
- that.trigger('change');
- } else {
- that._select(that._getHSV());
- }
- }).on(CLICK_NS, '.k-controls button.cancel', function () {
- that._updateUI(that.color());
- that._cancel();
- });
- if (isIE8) {
- that._applyIEFilter();
- }
- },
- destroy: function () {
- this._hueSlider.destroy();
- if (this._opacitySlider) {
- this._opacitySlider.destroy();
- }
- this._hueSlider = this._opacitySlider = this._hsvRect = this._hsvHandle = this._hueElements = this._selectedColor = this._colorAsText = null;
- ColorSelector.fn.destroy.call(this);
- },
- options: {
- name: 'FlatColorPicker',
- opacity: false,
- buttons: false,
- input: true,
- preview: true,
- clearButton: false,
- autoupdate: true,
- messages: MESSAGES
- },
- _applyIEFilter: function () {
- var track = this.element.find('.k-hue-slider .k-slider-track')[0], url = track.currentStyle.backgroundImage;
- url = url.replace(/^url\([\'\"]?|[\'\"]?\)$/g, '');
- track.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + url + '\', sizingMethod=\'scale\')';
- },
- _sliders: function () {
- var that = this, element = that.element, hueSlider = element.find('.k-hue-slider'), opacitySlider = element.find('.k-transparency-slider');
- function hueChange(e) {
- that._updateUI(that._getHSV(e.value, null, null, null));
- }
- hueSlider.attr('aria-label', 'hue saturation');
- that._hueSlider = hueSlider.kendoSlider({
- min: 0,
- max: 360,
- tickPlacement: 'none',
- showButtons: false,
- slide: hueChange,
- change: hueChange
- }).data('kendoSlider');
- function opacityChange(e) {
- that._updateUI(that._getHSV(null, null, null, e.value / 100));
- }
- opacitySlider.attr('aria-label', 'opacity');
- that._opacitySlider = opacitySlider.kendoSlider({
- min: 0,
- max: 100,
- tickPlacement: 'none',
- showButtons: false,
- slide: opacityChange,
- change: opacityChange
- }).data('kendoSlider');
- },
- _hsvArea: function () {
- var that = this, element = that.element, hsvRect = element.find('.k-hsv-rectangle'), hsvHandle = hsvRect.find('.k-draghandle').attr('tabIndex', 0).on(KEYDOWN_NS, bind(that._keydown, that));
- function update(x, y) {
- var offset = this.offset, dx = x - offset.left, dy = y - offset.top, rw = this.width, rh = this.height;
- dx = dx < 0 ? 0 : dx > rw ? rw : dx;
- dy = dy < 0 ? 0 : dy > rh ? rh : dy;
- that._svChange(dx / rw, 1 - dy / rh);
- }
- that._hsvEvents = new kendo.UserEvents(hsvRect, {
- global: true,
- press: function (e) {
- this.offset = kendo.getOffset(hsvRect);
- this.width = hsvRect.width();
- this.height = hsvRect.height();
- hsvHandle.focus();
- update.call(this, e.x.location, e.y.location);
- },
- start: function () {
- hsvRect.addClass('k-dragging');
- hsvHandle.focus();
- },
- move: function (e) {
- e.preventDefault();
- update.call(this, e.x.location, e.y.location);
- },
- end: function () {
- hsvRect.removeClass('k-dragging');
- }
- });
- that._hsvRect = hsvRect;
- that._hsvHandle = hsvHandle;
- },
- _onEnable: function (enable) {
- this._hueSlider.enable(enable);
- if (this._opacitySlider) {
- this._opacitySlider.enable(enable);
- }
- this.wrapper.find('input').attr('disabled', !enable);
- var handle = this._hsvRect.find('.k-draghandle');
- if (enable) {
- handle.attr('tabIndex', this._tabIndex);
- } else {
- handle.removeAttr('tabIndex');
- }
- },
- _keydown: function (ev) {
- var that = this;
- function move(prop, d) {
- var c = that._getHSV();
- c[prop] += d * (ev.shiftKey ? 0.01 : 0.05);
- if (c[prop] < 0) {
- c[prop] = 0;
- }
- if (c[prop] > 1) {
- c[prop] = 1;
- }
- that._updateUI(c);
- preventDefault(ev);
- }
- function hue(d) {
- var c = that._getHSV();
- c.h += d * (ev.shiftKey ? 1 : 5);
- if (c.h < 0) {
- c.h = 0;
- }
- if (c.h > 359) {
- c.h = 359;
- }
- that._updateUI(c);
- preventDefault(ev);
- }
- switch (ev.keyCode) {
- case KEYS.LEFT:
- if (ev.ctrlKey) {
- hue(-1);
- } else {
- move('s', -1);
- }
- break;
- case KEYS.RIGHT:
- if (ev.ctrlKey) {
- hue(1);
- } else {
- move('s', 1);
- }
- break;
- case KEYS.UP:
- move(ev.ctrlKey && that._opacitySlider ? 'a' : 'v', 1);
- break;
- case KEYS.DOWN:
- move(ev.ctrlKey && that._opacitySlider ? 'a' : 'v', -1);
- break;
- case KEYS.ENTER:
- that._select(that._getHSV());
- break;
- case KEYS.F2:
- that.wrapper.find('input.k-color-value').focus().select();
- break;
- case KEYS.ESC:
- that._cancel();
- break;
- }
- },
- focus: function () {
- this._hsvHandle.focus();
- },
- _getHSV: function (h, s, v, a) {
- var rect = this._hsvRect, width = rect.width(), height = rect.height(), handlePosition = this._hsvHandle.position();
- if (h == null) {
- h = this._hueSlider.value();
- }
- if (s == null) {
- s = handlePosition.left / width;
- }
- if (v == null) {
- v = 1 - handlePosition.top / height;
- }
- if (a == null) {
- a = this._opacitySlider ? this._opacitySlider.value() / 100 : 1;
- }
- return Color.fromHSV(h, s, v, a);
- },
- _svChange: function (s, v) {
- var color = this._getHSV(null, s, v, null);
- this._updateUI(color);
- },
- _updateUI: function (color, dontChangeInput) {
- var that = this, rect = that._hsvRect;
- if (!color) {
- return;
- }
- this._colorAsText.attr('title', that.options.messages.previewInput);
- this._colorAsText.removeClass('k-state-error');
- that._selectedColor.css(BACKGROUNDCOLOR, color.toDisplay());
- if (!dontChangeInput) {
- that._colorAsText.val(that._opacitySlider ? color.toCssRgba() : color.toCss());
- }
- that._triggerSelect(color);
- color = color.toHSV();
- that._hsvHandle.css({
- left: color.s * rect.width() + 'px',
- top: (1 - color.v) * rect.height() + 'px'
- });
- that._hueElements.css(BACKGROUNDCOLOR, Color.fromHSV(color.h, 1, 1, 1).toCss());
- that._hueSlider.value(color.h);
- if (that._opacitySlider) {
- that._opacitySlider.value(100 * color.a);
- }
- },
- _selectOnHide: function () {
- return this.options.buttons ? null : this._getHSV();
- },
- _template: kendo.template('# if (preview) { #' + '
' + '# } #' + '# if (clearButton && !_standalone && !preview) { #' + '
#: messages.clearColor #
' + '# } #' + '
' + '
' + '# if (opacity) { #' + '
' + '# } #' + '# if (buttons) { #' + '
' + '# } #')
- });
- function relative(array, element, delta) {
- array = Array.prototype.slice.call(array);
- var n = array.length;
- var pos = array.indexOf(element);
- if (pos < 0) {
- return delta < 0 ? array[n - 1] : array[0];
- }
- pos += delta;
- if (pos < 0) {
- pos += n;
- } else {
- pos %= n;
- }
- return array[pos];
- }
- var ColorPicker = Widget.extend({
- init: function (element, options) {
- var that = this;
- Widget.fn.init.call(that, element, options);
- options = that.options;
- element = that.element;
- var value = element.attr('value') || element.val();
- if (value) {
- value = parseColor(value, true);
- } else {
- value = parseColor(options.value, true);
- }
- that._value = options.value = value;
- var content = that.wrapper = $(that._template(options));
- element.hide().after(content);
- if (element.is('input')) {
- element.appendTo(content);
- var label = element.closest('label');
- var id = element.attr('id');
- if (id) {
- label = label.add('label[for="' + id + '"]');
- }
- label.click(function (ev) {
- that.open();
- ev.preventDefault();
- });
- }
- that._tabIndex = element.attr('tabIndex') || 0;
- that.enable(!element.attr('disabled'));
- var accesskey = element.attr('accesskey');
- if (accesskey) {
- element.attr('accesskey', null);
- content.attr('accesskey', accesskey);
- }
- that.bind('activate', function (ev) {
- if (!ev.isDefaultPrevented()) {
- that.toggle();
- }
- });
- that._updateUI(value);
- },
- destroy: function () {
- this.wrapper.off(NS).find('*').off(NS);
- if (this._popup) {
- this._selector.destroy();
- this._popup.destroy();
- }
- this._selector = this._popup = this.wrapper = null;
- Widget.fn.destroy.call(this);
- },
- enable: function (enable) {
- var that = this, wrapper = that.wrapper, innerWrapper = wrapper.children('.k-picker-wrap'), arrow = innerWrapper.find('.k-select');
- if (arguments.length === 0) {
- enable = true;
- }
- that.element.attr('disabled', !enable);
- wrapper.attr('aria-disabled', !enable);
- arrow.off(NS).on('mousedown' + NS, preventDefault);
- wrapper.addClass('k-state-disabled').removeAttr('tabIndex').add('*', wrapper).off(NS);
- if (enable) {
- wrapper.removeClass('k-state-disabled').attr('tabIndex', that._tabIndex).on('mouseenter' + NS, function () {
- innerWrapper.addClass('k-state-hover');
- }).on('mouseleave' + NS, function () {
- innerWrapper.removeClass('k-state-hover');
- }).on('focus' + NS, function () {
- innerWrapper.addClass('k-state-focused');
- }).on('blur' + NS, function () {
- innerWrapper.removeClass('k-state-focused');
- }).on(KEYDOWN_NS, bind(that._keydown, that)).on(CLICK_NS, '.k-select', bind(that.toggle, that)).on(CLICK_NS, that.options.toolIcon ? '.k-tool-icon' : '.k-selected-color', function () {
- that.trigger('activate');
- });
- } else {
- that.close();
- }
- },
- _template: kendo.template('
' + '' + '# if (toolIcon) { #' + '' + '' + '' + '# } else { #' + '' + '# } #' + '' + '' + '' + '' + ''),
- options: {
- name: 'ColorPicker',
- palette: null,
- columns: 10,
- toolIcon: null,
- value: null,
- messages: MESSAGES,
- opacity: false,
- buttons: true,
- preview: true,
- clearButton: false,
- ARIATemplate: 'Current selected color is #=data || ""#'
- },
- events: [
- 'activate',
- 'change',
- 'select',
- 'open',
- 'close'
- ],
- open: function () {
- if (!this.element.prop('disabled')) {
- this._getPopup().open();
- }
- },
- close: function () {
- var selOptions = this._selector && this._selector.options || {};
- selOptions._closing = true;
- this._getPopup().close();
- delete selOptions._closing;
- },
- toggle: function () {
- if (!this.element.prop('disabled')) {
- this._getPopup().toggle();
- }
- },
- _noColorIcon: function () {
- return this.wrapper.find('.k-picker-wrap > .k-selected-color > .k-icon.k-i-line');
- },
- color: ColorSelector.fn.color,
- value: ColorSelector.fn.value,
- _select: ColorSelector.fn._select,
- _triggerSelect: ColorSelector.fn._triggerSelect,
- _isInputTypeColor: function () {
- var el = this.element[0];
- return /^input$/i.test(el.tagName) && /^color$/i.test(el.type);
- },
- _updateUI: function (value) {
- var formattedValue = '';
- if (value) {
- if (this._isInputTypeColor() || value.a == 1) {
- formattedValue = value.toCss();
- } else {
- formattedValue = value.toCssRgba();
- }
- this.element.val(formattedValue);
- }
- if (!this._ariaTemplate) {
- this._ariaTemplate = kendo.template(this.options.ARIATemplate);
- }
- this.wrapper.attr('aria-label', this._ariaTemplate(formattedValue));
- this._triggerSelect(value);
- this.wrapper.find('.k-selected-color').css(BACKGROUNDCOLOR, value ? value.toDisplay() : WHITE);
- this._noColorIcon()[formattedValue ? 'hide' : 'show']();
- },
- _keydown: function (ev) {
- var key = ev.keyCode;
- if (this._getPopup().visible()) {
- if (key == KEYS.ESC) {
- this._selector._cancel();
- } else {
- this._selector._keydown(ev);
- }
- preventDefault(ev);
- } else if (key == KEYS.ENTER || key == KEYS.DOWN) {
- this.open();
- preventDefault(ev);
- }
- },
- _getPopup: function () {
- var that = this, popup = that._popup;
- if (!popup) {
- var options = that.options;
- var selectorType;
- if (options.palette) {
- selectorType = ColorPalette;
- } else {
- selectorType = FlatColorPicker;
- }
- options._standalone = false;
- delete options.select;
- delete options.change;
- delete options.cancel;
- var id = kendo.guid();
- var selector = that._selector = new selectorType($('
').appendTo(document.body), options);
- that.wrapper.attr('aria-owns', id);
- that._popup = popup = selector.wrapper.kendoPopup({
- anchor: that.wrapper,
- adjustSize: {
- width: 5,
- height: 0
- }
- }).data('kendoPopup');
- selector.element.find('.k-clear-color').kendoButton({
- icon: 'reset-color',
- click: function (e) {
- selector.options._clearedColor = true;
- that.value(null);
- that.element.val(null);
- that._updateUI(null);
- selector._colorAsText.val('');
- selector._hsvHandle.css({
- top: '0px',
- left: '0px'
- });
- selector._selectedColor.css(BACKGROUNDCOLOR, WHITE);
- that.trigger('change', { value: that.value() });
- e.preventDefault();
- }
- });
- selector.bind({
- select: function (ev) {
- that._updateUI(parseColor(ev.value));
- delete selector.options._clearedColor;
- },
- change: function () {
- if (!selector.options._clearedColor) {
- that._select(selector.color());
- }
- that.close();
- },
- cancel: function () {
- if (selector.options._clearedColor && !that.value() && selector.value()) {
- that._select(selector.color(), true);
- }
- that.close();
- }
- });
- popup.bind({
- close: function (ev) {
- if (that.trigger('close')) {
- ev.preventDefault();
- return;
- }
- that.wrapper.children('.k-picker-wrap').removeClass('k-state-focused');
- var color = selector._selectOnHide();
- var selectorColor = selector.value();
- var value = that.value();
- var options = selector.options;
- if (!color) {
- setTimeout(function () {
- if (that.wrapper && !that.wrapper.is('[unselectable=\'on\']')) {
- that.wrapper.focus();
- }
- });
- if (!options._closing && options._clearedColor && !value && selectorColor) {
- that._select(selectorColor, true);
- } else {
- that._updateUI(that.color());
- }
- } else if (!(options._clearedColor && !value)) {
- that._select(color);
- }
- },
- open: function (ev) {
- if (that.trigger('open')) {
- ev.preventDefault();
- } else {
- that.wrapper.children('.k-picker-wrap').addClass('k-state-focused');
- }
- },
- activate: function () {
- selector._select(that.color(), true);
- selector.focus();
- that.wrapper.children('.k-picker-wrap').addClass('k-state-focused');
- }
- });
- }
- return popup;
- }
- });
- function preventDefault(ev) {
- ev.preventDefault();
- }
- function bind(callback, obj) {
- return function () {
- return callback.apply(obj, arguments);
- };
- }
- ui.plugin(ColorPalette);
- ui.plugin(FlatColorPicker);
- ui.plugin(ColorPicker);
- }(jQuery, parseInt));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.maskedtextbox', ['kendo.core'], f);
-}(function () {
- var __meta__ = {
- id: 'maskedtextbox',
- name: 'MaskedTextBox',
- category: 'web',
- description: 'The MaskedTextBox widget allows to specify a mask type on an input field.',
- depends: ['core']
- };
- (function ($, undefined) {
- var global = window;
- var min = global.Math.min;
- var kendo = global.kendo;
- var caret = kendo.caret;
- var keys = kendo.keys;
- var ui = kendo.ui;
- var Widget = ui.Widget;
- var NS = '.kendoMaskedTextBox';
- var proxy = $.proxy;
- var setTimeout = window.setTimeout;
- var STATEDISABLED = 'k-state-disabled';
- var STATEINVALID = 'k-state-invalid';
- var DISABLED = 'disabled';
- var READONLY = 'readonly';
- var CHANGE = 'change';
- var MOUSEUP = 'mouseup';
- var DROP = 'drop';
- var KEYDOWN = 'keydown';
- var PASTE = 'paste';
- var INPUT = 'input';
- function ns(name) {
- return name + NS;
- }
- var INPUT_EVENT_NAME = ns(kendo.support.propertyChangeEvent ? 'propertychange' : INPUT);
- function stringDiffStart(str1, str2) {
- var i = 0;
- while (i < str2.length) {
- if (str1[i] !== str2[i]) {
- break;
- }
- i++;
- }
- return i;
- }
- var MaskedTextBox = Widget.extend({
- init: function (element, options) {
- var that = this;
- var DOMElement;
- Widget.fn.init.call(that, element, options);
- that._rules = $.extend({}, that.rules, that.options.rules);
- element = that.element;
- DOMElement = element[0];
- that._wrapper();
- that._tokenize();
- that._form();
- that.element.addClass('k-textbox').attr('autocomplete', 'off').on('focus' + NS, function () {
- var value = DOMElement.value;
- if (!value) {
- DOMElement.value = that._old = that._emptyMask;
- } else {
- that._togglePrompt(true);
- }
- that._oldValue = value;
- that._timeoutId = setTimeout(function () {
- caret(element, 0, value ? that._maskLength : 0);
- });
- }).on('focusout' + NS, function () {
- var value = element.val();
- clearTimeout(that._timeoutId);
- DOMElement.value = that._old = '';
- if (value !== that._emptyMask) {
- DOMElement.value = that._old = value;
- }
- that._change();
- that._togglePrompt();
- });
- var disabled = element.is('[disabled]') || $(that.element).parents('fieldset').is(':disabled');
- if (disabled) {
- that.enable(false);
- } else {
- that.readonly(element.is('[readonly]'));
- }
- that.value(that.options.value || element.val());
- that._validationIcon = $('
').insertAfter(element);
- kendo.notify(that);
- },
- options: {
- name: 'MaskedTextBox',
- clearPromptChar: false,
- unmaskOnPost: false,
- promptChar: '_',
- culture: '',
- rules: {},
- value: '',
- mask: ''
- },
- events: [CHANGE],
- rules: {
- '0': /\d/,
- '9': /\d|\s/,
- '#': /\d|\s|\+|\-/,
- 'L': /[a-zA-Z]/,
- '?': /[a-zA-Z]|\s/,
- '&': /\S/,
- 'C': /./,
- 'A': /[a-zA-Z0-9]/,
- 'a': /[a-zA-Z0-9]|\s/
- },
- setOptions: function (options) {
- var that = this;
- Widget.fn.setOptions.call(that, options);
- that._rules = $.extend({}, that.rules, that.options.rules);
- that._tokenize();
- this._unbindInput();
- this._bindInput();
- that.value(that.element.val());
- },
- destroy: function () {
- var that = this;
- that.element.off(NS);
- if (that._formElement) {
- that._formElement.off('reset', that._resetHandler);
- that._formElement.off('submit', that._submitHandler);
- }
- Widget.fn.destroy.call(that);
- },
- raw: function () {
- var unmasked = this._unmask(this.element.val(), 0);
- return unmasked.replace(new RegExp(escapeRegExp(this.options.promptChar), 'g'), '');
- },
- value: function (value) {
- var element = this.element;
- var emptyMask = this._emptyMask;
- if (value === undefined) {
- return this.element.val();
- }
- if (value === null) {
- value = '';
- }
- if (!emptyMask) {
- this._oldValue = value;
- element.val(value);
- return;
- }
- value = this._unmask(value + '');
- element.val(value ? emptyMask : '');
- this._mask(0, this._maskLength, value);
- this._unmaskedValue = null;
- value = element.val();
- this._oldValue = value;
- if (kendo._activeElement() !== element) {
- if (value === emptyMask) {
- element.val('');
- } else {
- this._togglePrompt();
- }
- }
- },
- _togglePrompt: function (show) {
- var DOMElement = this.element[0];
- var value = DOMElement.value;
- if (this.options.clearPromptChar) {
- if (!show) {
- value = value.replace(new RegExp(escapeRegExp(this.options.promptChar), 'g'), ' ');
- } else {
- value = this._oldValue;
- }
- DOMElement.value = this._old = value;
- }
- },
- readonly: function (readonly) {
- this._editable({
- readonly: readonly === undefined ? true : readonly,
- disable: false
- });
- },
- enable: function (enable) {
- this._editable({
- readonly: false,
- disable: !(enable = enable === undefined ? true : enable)
- });
- },
- _bindInput: function () {
- var that = this;
- if (that._maskLength) {
- if (that.options.$angular) {
- that.element.off(INPUT);
- }
- that.element.on(ns(KEYDOWN), proxy(that._keydown, that)).on(ns(DROP), proxy(that._drop, that)).on(ns(CHANGE), proxy(that._trackChange, that)).on(INPUT_EVENT_NAME, proxy(that._inputHandler, that));
- if (kendo.support.browser.msie) {
- var version = kendo.support.browser.version;
- if (version > 8 && version < 11) {
- var events = [
- ns(MOUSEUP),
- ns(DROP),
- ns(KEYDOWN),
- ns(PASTE)
- ].join(' ');
- that.element.on(events, proxy(that._legacyIEInputHandler, that));
- }
- }
- }
- },
- _unbindInput: function () {
- var events = [
- INPUT_EVENT_NAME,
- ns(KEYDOWN),
- ns(MOUSEUP),
- ns(DROP),
- ns(PASTE)
- ].join(' ');
- this.element.off(events);
- },
- _editable: function (options) {
- var that = this;
- var element = that.element;
- var wrapper = that.wrapper;
- var disable = options.disable;
- var readonly = options.readonly;
- that._unbindInput();
- if (!readonly && !disable) {
- element.removeAttr(DISABLED).removeAttr(READONLY);
- wrapper.removeClass(STATEDISABLED);
- that._bindInput();
- } else {
- element.attr(DISABLED, disable).attr(READONLY, readonly);
- wrapper.toggleClass(STATEDISABLED, disable);
- }
- },
- _change: function () {
- var that = this;
- var value = that.value();
- if (value !== that._oldValue) {
- that._oldValue = value;
- that.trigger(CHANGE);
- that.element.trigger(CHANGE);
- } else if (value === '' && that.__changing) {
- that.element.trigger(CHANGE);
- }
- },
- inputChange: function (backward) {
- var that = this;
- var old = that._old;
- var element = that.element[0];
- var value = element.value;
- var selection = caret(element);
- var cursor = selection[1];
- var lengthDiff = value.length - old.length;
- var mobile = kendo.support.mobileOS;
- if (that.__dropping && lengthDiff < 0) {
- return;
- }
- if (lengthDiff === -1 && mobile.android && mobile.browser === 'chrome') {
- backward = true;
- }
- var contentStart = min(cursor, stringDiffStart(value, old));
- var content = value.substring(contentStart, cursor);
- element.value = value.substring(0, contentStart) + that._emptyMask.substring(contentStart);
- var caretPos = that._mask(contentStart, cursor, content);
- var endContent = that._trimStartPromptChars(value.substring(cursor), min(lengthDiff, caretPos - contentStart));
- var unmasked = that._unmask(endContent, old.length - endContent.length);
- that._mask(caretPos, caretPos, unmasked);
- if (backward) {
- caretPos = that._findCaretPosBackwards(contentStart);
- }
- caret(element, caretPos);
- that.__dropping = false;
- },
- _trimStartPromptChars: function (content, count) {
- var promptChar = this.options.promptChar;
- while (count-- > 0 && content.indexOf(promptChar) === 0) {
- content = content.substring(1);
- }
- return content;
- },
- _findCaretPosBackwards: function (pos) {
- var caretStart = this._find(pos, true);
- if (caretStart < pos) {
- caretStart += 1;
- }
- return caretStart;
- },
- _inputHandler: function () {
- if (kendo._activeElement() !== this.element[0]) {
- return;
- }
- this.inputChange(this.__backward);
- },
- _legacyIEInputHandler: function (e) {
- var that = this;
- var input = that.element[0];
- var value = input.value;
- var type = e.type;
- that.__pasting = type === 'paste';
- setTimeout(function () {
- if (type === 'mouseup' && that.__pasting) {
- return;
- }
- if (input.value && input.value !== value) {
- that.inputChange(that.__backward);
- }
- });
- },
- _trackChange: function () {
- var that = this;
- that.__changing = true;
- setTimeout(function () {
- that.__changing = false;
- });
- },
- _form: function () {
- var that = this;
- var element = that.element;
- var formId = element.attr('form');
- var form = formId ? $('#' + formId) : element.closest('form');
- if (form[0]) {
- that._resetHandler = function () {
- setTimeout(function () {
- that.value(element[0].value);
- });
- };
- that._submitHandler = function () {
- that.element[0].value = that._old = that.raw();
- };
- if (that.options.unmaskOnPost) {
- form.on('submit', that._submitHandler);
- }
- that._formElement = form.on('reset', that._resetHandler);
- }
- },
- _keydown: function (e) {
- var key = e.keyCode;
- this.__backward = key === keys.BACKSPACE;
- if (key === keys.ENTER) {
- this._change();
- }
- },
- _drop: function () {
- this.__dropping = true;
- },
- _find: function (idx, backward) {
- var value = this.element.val() || this._emptyMask;
- var step = 1;
- if (backward === true) {
- step = -1;
- }
- while (idx > -1 || idx <= this._maskLength) {
- if (value.charAt(idx) !== this.tokens[idx]) {
- return idx;
- }
- idx += step;
- }
- return -1;
- },
- _mask: function (start, end, value, backward) {
- var element = this.element[0];
- var current = element.value || this._emptyMask;
- var empty = this.options.promptChar;
- var valueLength;
- var chrIdx = 0;
- var unmasked;
- var chr;
- var idx;
- start = this._find(start, backward);
- if (start > end) {
- end = start;
- }
- unmasked = this._unmask(current.substring(end), end);
- value = this._unmask(value, start);
- valueLength = value.length;
- if (value) {
- unmasked = unmasked.replace(new RegExp('^_{0,' + valueLength + '}'), '');
- }
- value += unmasked;
- current = current.split('');
- chr = value.charAt(chrIdx);
- while (start < this._maskLength) {
- current[start] = chr || empty;
- chr = value.charAt(++chrIdx);
- if (idx === undefined && chrIdx > valueLength) {
- idx = start;
- }
- start = this._find(start + 1);
- }
- element.value = this._old = current.join('');
- if (kendo._activeElement() === element) {
- if (idx === undefined) {
- idx = this._maskLength;
- }
- caret(element, idx);
- }
- return idx;
- },
- _unmask: function (value, idx) {
- if (!value) {
- return '';
- }
- if (this._unmaskedValue === value) {
- return this._unmaskedValue;
- }
- value = (value + '').split('');
- var chr;
- var token;
- var chrIdx = 0;
- var tokenIdx = idx || 0;
- var empty = this.options.promptChar;
- var valueLength = value.length;
- var tokensLength = this.tokens.length;
- var result = '';
- while (tokenIdx < tokensLength) {
- chr = value[chrIdx];
- token = this.tokens[tokenIdx];
- if (chr === token || chr === empty) {
- result += chr === empty ? empty : '';
- chrIdx += 1;
- tokenIdx += 1;
- } else if (typeof token !== 'string') {
- if (token && token.test && token.test(chr) || $.isFunction(token) && token(chr)) {
- result += chr;
- tokenIdx += 1;
- } else {
- if (valueLength === 1) {
- this._blinkInvalidState();
- }
- }
- chrIdx += 1;
- } else {
- tokenIdx += 1;
- }
- if (chrIdx >= valueLength) {
- break;
- }
- }
- this._unmaskedValue = result;
- return result;
- },
- _wrapper: function () {
- var that = this;
- var element = that.element;
- var DOMElement = element[0];
- var wrapper = element.wrap('
').parent();
- wrapper[0].style.cssText = DOMElement.style.cssText;
- DOMElement.style.width = '100%';
- that.wrapper = wrapper.addClass(DOMElement.className);
- },
- _blinkInvalidState: function () {
- var that = this;
- that.wrapper.addClass(STATEINVALID);
- clearTimeout(that._invalidStateTimeout);
- that._invalidStateTimeout = setTimeout(proxy(that._removeInvalidState, that), 100);
- },
- _removeInvalidState: function () {
- var that = this;
- that.wrapper.removeClass(STATEINVALID);
- that._invalidStateTimeout = null;
- },
- _tokenize: function () {
- var tokens = [];
- var tokenIdx = 0;
- var mask = this.options.mask || '';
- var maskChars = mask.split('');
- var length = maskChars.length;
- var idx = 0;
- var chr;
- var rule;
- var emptyMask = '';
- var promptChar = this.options.promptChar;
- var numberFormat = kendo.getCulture(this.options.culture).numberFormat;
- var rules = this._rules;
- for (; idx < length; idx++) {
- chr = maskChars[idx];
- rule = rules[chr];
- if (rule) {
- tokens[tokenIdx] = rule;
- emptyMask += promptChar;
- tokenIdx += 1;
- } else {
- if (chr === '.' || chr === ',') {
- chr = numberFormat[chr];
- } else if (chr === '$') {
- chr = numberFormat.currency.symbol;
- } else if (chr === '\\') {
- idx += 1;
- chr = maskChars[idx];
- }
- chr = chr.split('');
- for (var i = 0, l = chr.length; i < l; i++) {
- tokens[tokenIdx] = chr[i];
- emptyMask += chr[i];
- tokenIdx += 1;
- }
- }
- }
- this.tokens = tokens;
- this._emptyMask = emptyMask;
- this._maskLength = emptyMask.length;
- }
- });
- function escapeRegExp(text) {
- return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
- }
- ui.plugin(MaskedTextBox);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.multiselect', [
- 'kendo.list',
- 'kendo.mobile.scroller',
- 'kendo.virtuallist'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'multiselect',
- name: 'MultiSelect',
- category: 'web',
- description: 'The MultiSelect widget allows the selection from pre-defined values.',
- depends: ['list'],
- features: [
- {
- id: 'mobile-scroller',
- name: 'Mobile scroller',
- description: 'Support for kinetic scrolling in mobile device',
- depends: ['mobile.scroller']
- },
- {
- id: 'virtualization',
- name: 'VirtualList',
- description: 'Support for virtualization',
- depends: ['virtuallist']
- }
- ]
- };
- (function ($, undefined) {
- var kendo = window.kendo, ui = kendo.ui, List = ui.List, keys = $.extend({ A: 65 }, kendo.keys), activeElement = kendo._activeElement, ObservableArray = kendo.data.ObservableArray, proxy = $.proxy, ID = 'id', LI = 'li', ACCEPT = 'accept', FILTER = 'filter', REBIND = 'rebind', OPEN = 'open', CLOSE = 'close', CHANGE = 'change', PROGRESS = 'progress', SELECT = 'select', DESELECT = 'deselect', ARIA_DISABLED = 'aria-disabled', FOCUSEDCLASS = 'k-state-focused', SELECTEDCLASS = 'k-state-selected', HIDDENCLASS = 'k-hidden', HOVERCLASS = 'k-state-hover', STATEDISABLED = 'k-state-disabled', DISABLED = 'disabled', READONLY = 'readonly', ns = '.kendoMultiSelect', CLICK = 'click' + ns, KEYDOWN = 'keydown' + ns, MOUSEENTER = 'mouseenter' + ns, MOUSELEAVE = 'mouseleave' + ns, HOVEREVENTS = MOUSEENTER + ' ' + MOUSELEAVE, quotRegExp = /"/g, isArray = $.isArray, styles = [
- 'font-family',
- 'font-size',
- 'font-stretch',
- 'font-style',
- 'font-weight',
- 'letter-spacing',
- 'text-transform',
- 'line-height'
- ];
- var MultiSelect = List.extend({
- init: function (element, options) {
- var that = this, id, disabled;
- that.ns = ns;
- List.fn.init.call(that, element, options);
- that._optionsMap = {};
- that._customOptions = {};
- that._wrapper();
- that._tagList();
- that._input();
- that._textContainer();
- that._loader();
- that._clearButton();
- that._tabindex(that.input);
- element = that.element.attr('multiple', 'multiple').hide();
- options = that.options;
- if (!options.placeholder) {
- options.placeholder = element.data('placeholder');
- }
- id = element.attr(ID);
- if (id) {
- that._tagID = id + '_tag_active';
- id = id + '_taglist';
- that.tagList.attr(ID, id);
- that.input.attr('aria-describedby', id);
- }
- that._initialOpen = true;
- that._aria(id);
- that._dataSource();
- that._ignoreCase();
- that._popup();
- that._tagTemplate();
- that.requireValueMapper(that.options);
- that._initList();
- that._reset();
- that._enable();
- that._placeholder();
- if (options.autoBind) {
- that.dataSource.fetch();
- } else if (options.value) {
- that._preselect(options.value);
- }
- disabled = $(that.element).parents('fieldset').is(':disabled');
- if (disabled) {
- that.enable(false);
- }
- kendo.notify(that);
- that._toggleCloseVisibility();
- },
- options: {
- name: 'MultiSelect',
- tagMode: 'multiple',
- enabled: true,
- autoBind: true,
- autoClose: true,
- highlightFirst: true,
- dataTextField: '',
- dataValueField: '',
- filter: 'startswith',
- ignoreCase: true,
- minLength: 1,
- enforceMinLength: false,
- delay: 100,
- value: null,
- maxSelectedItems: null,
- placeholder: '',
- height: 200,
- animation: {},
- virtual: false,
- itemTemplate: '',
- tagTemplate: '',
- groupTemplate: '#:data#',
- fixedGroupTemplate: '#:data#',
- clearButton: true,
- autoWidth: false
- },
- events: [
- OPEN,
- CLOSE,
- CHANGE,
- SELECT,
- DESELECT,
- 'filtering',
- 'dataBinding',
- 'dataBound'
- ],
- setDataSource: function (dataSource) {
- this.options.dataSource = dataSource;
- this._state = '';
- this._dataSource();
- this.persistTagList = false;
- this.listView.setDataSource(this.dataSource);
- if (this.options.autoBind) {
- this.dataSource.fetch();
- }
- },
- setOptions: function (options) {
- var listOptions = this._listOptions(options);
- List.fn.setOptions.call(this, options);
- this.listView.setOptions(listOptions);
- this._accessors();
- this._aria(this.tagList.attr(ID));
- this._tagTemplate();
- this._placeholder();
- this._clearButton();
- },
- currentTag: function (candidate) {
- var that = this;
- if (candidate !== undefined) {
- if (that._currentTag) {
- that._currentTag.removeClass(FOCUSEDCLASS).removeAttr(ID);
- that.input.removeAttr('aria-activedescendant');
- }
- if (candidate) {
- candidate.addClass(FOCUSEDCLASS).attr(ID, that._tagID);
- that.input.attr('aria-activedescendant', that._tagID);
- }
- that._currentTag = candidate;
- } else {
- return that._currentTag;
- }
- },
- dataItems: function () {
- return this.listView.selectedDataItems();
- },
- destroy: function () {
- var that = this, ns = that.ns;
- clearTimeout(that._busy);
- clearTimeout(that._typingTimeout);
- that.wrapper.off(ns);
- that.tagList.off(ns);
- that.input.off(ns);
- that._clear.off(ns);
- List.fn.destroy.call(that);
- },
- _activateItem: function () {
- if (this.popup.visible()) {
- List.fn._activateItem.call(this);
- }
- this.currentTag(null);
- },
- _listOptions: function (options) {
- var that = this;
- var listOptions = List.fn._listOptions.call(that, $.extend(options, {
- selectedItemChange: proxy(that._selectedItemChange, that),
- selectable: 'multiple'
- }));
- var itemTemplate = this.options.itemTemplate || this.options.template;
- var template = listOptions.itemTemplate || itemTemplate || listOptions.template;
- if (!template) {
- template = '#:' + kendo.expr(listOptions.dataTextField, 'data') + '#';
- }
- listOptions.template = template;
- return listOptions;
- },
- _setListValue: function () {
- List.fn._setListValue.call(this, this._initialValues.slice(0));
- },
- _listChange: function (e) {
- var data = this.dataSource.flatView();
- var optionsMap = this._optionsMap;
- var valueGetter = this._value;
- if (this._state === REBIND) {
- this._state = '';
- }
- for (var i = 0; i < e.added.length; i++) {
- if (optionsMap[valueGetter(e.added[i].dataItem)] === undefined) {
- this._render(data);
- break;
- }
- }
- this._selectValue(e.added, e.removed);
- },
- _selectedItemChange: function (e) {
- var items = e.items;
- var context;
- var idx;
- for (idx = 0; idx < items.length; idx++) {
- context = items[idx];
- this.tagList.children().eq(context.index).children('span:first').html(this.tagTextTemplate(context.item));
- }
- },
- _wrapperMousedown: function (e) {
- var that = this;
- var notInput = e.target.nodeName.toLowerCase() !== 'input';
- var target = $(e.target);
- var closeButton = target.hasClass('k-select') || target.hasClass('k-icon');
- if (closeButton) {
- closeButton = !target.closest('.k-select').children('.k-i-arrow-60-down').length;
- }
- if (notInput && !(closeButton && kendo.support.mobileOS)) {
- e.preventDefault();
- }
- if (!closeButton) {
- if (that.input[0] !== activeElement() && notInput) {
- that.input.focus();
- }
- if (that.options.minLength === 1) {
- that.open();
- }
- }
- },
- _inputFocus: function () {
- this._placeholder(false);
- this.wrapper.addClass(FOCUSEDCLASS);
- },
- _inputFocusout: function () {
- var that = this;
- clearTimeout(that._typingTimeout);
- that.wrapper.removeClass(FOCUSEDCLASS);
- that._placeholder(!that.listView.selectedDataItems()[0], true);
- that.close();
- if (that._state === FILTER) {
- that._state = ACCEPT;
- that.listView.skipUpdate(true);
- }
- if (that.listView.bound() && that.listView.isFiltered()) {
- that.persistTagList = true;
- that._clearFilter();
- }
- that.element.blur();
- },
- _removeTag: function (tag, shouldTrigger) {
- var that = this;
- var state = that._state;
- var position = tag.index();
- var listView = that.listView;
- var value = listView.value()[position];
- var dataItem = that.listView.selectedDataItems()[position];
- var customIndex = that._customOptions[value];
- var option;
- if (that.trigger(DESELECT, {
- dataItem: dataItem,
- item: tag
- })) {
- that._close();
- return;
- }
- if (customIndex === undefined && (state === ACCEPT || state === FILTER)) {
- customIndex = that._optionsMap[value];
- }
- var done = function () {
- that.currentTag(null);
- if (shouldTrigger) {
- that._change();
- }
- that._close();
- };
- if (customIndex === undefined) {
- that.persistTagList = false;
- listView.select(listView.select()[position]).done(done);
- } else {
- option = that.element[0].children[customIndex];
- option.selected = false;
- listView.removeAt(position);
- tag.remove();
- done();
- }
- },
- _tagListClick: function (e) {
- var target = $(e.currentTarget);
- if (!target.children('.k-i-arrow-60-down').length) {
- this._removeTag(target.closest(LI), true);
- }
- },
- _clearClick: function () {
- var that = this;
- if (that.options.tagMode === 'single') {
- that.listView.value([]);
- } else {
- that.tagList.children().each(function (index, tag) {
- that._removeTag($(tag), false);
- });
- }
- that.input.val('');
- that._search();
- that._change();
- that.focus();
- that._hideClear();
- if (that._state === FILTER) {
- that._state = ACCEPT;
- }
- },
- _editable: function (options) {
- var that = this, disable = options.disable, readonly = options.readonly, wrapper = that.wrapper.off(ns), tagList = that.tagList.off(ns), input = that.element.add(that.input.off(ns));
- if (!readonly && !disable) {
- wrapper.removeClass(STATEDISABLED).on(HOVEREVENTS, that._toggleHover).on('mousedown' + ns + ' touchend' + ns, proxy(that._wrapperMousedown, that));
- that.input.on(KEYDOWN, proxy(that._keydown, that)).on('paste' + ns, proxy(that._search, that)).on('input' + ns, proxy(that._search, that)).on('focus' + ns, proxy(that._inputFocus, that)).on('focusout' + ns, proxy(that._inputFocusout, that));
- that._clear.on(CLICK + ns + ' touchend' + ns, proxy(that._clearClick, that));
- input.removeAttr(DISABLED).removeAttr(READONLY).attr(ARIA_DISABLED, false);
- tagList.on(MOUSEENTER, LI, function () {
- $(this).addClass(HOVERCLASS);
- }).on(MOUSELEAVE, LI, function () {
- $(this).removeClass(HOVERCLASS);
- }).on(CLICK, 'li.k-button .k-select', proxy(that._tagListClick, that));
- } else {
- if (disable) {
- wrapper.addClass(STATEDISABLED);
- } else {
- wrapper.removeClass(STATEDISABLED);
- }
- input.attr(DISABLED, disable).attr(READONLY, readonly).attr(ARIA_DISABLED, disable);
- }
- },
- _close: function () {
- var that = this;
- if (that.options.autoClose) {
- that.close();
- } else {
- that.popup.position();
- }
- },
- _filterSource: function (filter, force) {
- if (!force) {
- force = this._retrieveData;
- }
- this._retrieveData = false;
- List.fn._filterSource.call(this, filter, force);
- },
- close: function () {
- this._activeItem = null;
- this.input.removeAttr('aria-activedescendant');
- this.popup.close();
- },
- open: function () {
- var that = this;
- if (that._request) {
- that._retrieveData = false;
- }
- if (that._retrieveData || !that.listView.bound() || that._state === ACCEPT) {
- that._open = true;
- that._state = REBIND;
- that.listView.skipUpdate(true);
- that.persistTagList = that._initialOpen && !that.listView.bound() ? false : true;
- that._filterSource();
- that._focusItem();
- } else if (that._allowOpening()) {
- if (that._initialOpen && !that.options.autoBind && !that.options.virtual && that.options.value && !$.isPlainObject(that.options.value[0])) {
- that.value(that._initialValues);
- }
- that.popup._hovered = true;
- that._initialOpen = false;
- that.popup.open();
- that._focusItem();
- }
- },
- toggle: function (toggle) {
- toggle = toggle !== undefined ? toggle : !this.popup.visible();
- this[toggle ? OPEN : CLOSE]();
- },
- refresh: function () {
- this.listView.refresh();
- },
- _listBound: function () {
- var that = this;
- var data = that.dataSource.flatView();
- var skip = that.listView.skip();
- that._render(data);
- that._renderFooter();
- that._renderNoData();
- that._toggleNoData(!data.length);
- that._resizePopup();
- if (that._open) {
- that._open = false;
- that.toggle(that._allowOpening());
- }
- that.popup.position();
- if (that.options.highlightFirst && (skip === undefined || skip === 0)) {
- that.listView.focusFirst();
- }
- if (that._touchScroller) {
- that._touchScroller.reset();
- }
- that._hideBusy();
- that._makeUnselectable();
- that.trigger('dataBound');
- },
- _inputValue: function () {
- var that = this;
- var inputValue = that.input.val();
- if (that.options.placeholder === inputValue) {
- inputValue = '';
- }
- return inputValue;
- },
- value: function (value) {
- var that = this;
- var listView = that.listView;
- var oldValue = listView.value().slice();
- var maxSelectedItems = that.options.maxSelectedItems;
- var clearFilters = listView.bound() && listView.isFiltered();
- if (value === undefined) {
- return oldValue;
- }
- that.persistTagList = false;
- that.requireValueMapper(that.options, value);
- value = that._normalizeValues(value);
- if (maxSelectedItems !== null && value.length > maxSelectedItems) {
- value = value.slice(0, maxSelectedItems);
- }
- if (clearFilters) {
- that._clearFilter();
- }
- listView.value(value);
- that._old = that._valueBeforeCascade = listView.value();
- if (!clearFilters) {
- that._fetchData();
- }
- that._toggleCloseVisibility();
- },
- _preselect: function (data, value) {
- var that = this;
- if (!isArray(data) && !(data instanceof kendo.data.ObservableArray)) {
- data = [data];
- }
- if ($.isPlainObject(data[0]) || data[0] instanceof kendo.data.ObservableObject || !that.options.dataValueField) {
- that.dataSource.data(data);
- that.value(value || that._initialValues);
- that._retrieveData = true;
- }
- },
- _setOption: function (value, selected) {
- var option = this.element[0].children[this._optionsMap[value]];
- if (option) {
- option.selected = selected;
- }
- },
- _fetchData: function () {
- var that = this;
- var hasItems = !!that.dataSource.view().length;
- var isEmptyArray = that.listView.value().length === 0;
- if (isEmptyArray || that._request) {
- return;
- }
- if (that._retrieveData || !that._fetch && !hasItems) {
- that._fetch = true;
- that._retrieveData = false;
- that.dataSource.read().done(function () {
- that._fetch = false;
- });
- }
- },
- _isBound: function () {
- return this.listView.bound() && !this._retrieveData;
- },
- _dataSource: function () {
- var that = this, element = that.element, options = that.options, dataSource = options.dataSource || {};
- dataSource = isArray(dataSource) ? { data: dataSource } : dataSource;
- dataSource.select = element;
- dataSource.fields = [
- { field: options.dataTextField },
- { field: options.dataValueField }
- ];
- if (that.dataSource && that._refreshHandler) {
- that._unbindDataSource();
- } else {
- that._progressHandler = proxy(that._showBusy, that);
- that._errorHandler = proxy(that._hideBusy, that);
- }
- that.dataSource = kendo.data.DataSource.create(dataSource).bind(PROGRESS, that._progressHandler).bind('error', that._errorHandler);
- },
- _reset: function () {
- var that = this, element = that.element, formId = element.attr('form'), form = formId ? $('#' + formId) : element.closest('form');
- if (form[0]) {
- that._resetHandler = function () {
- setTimeout(function () {
- that.value(that._initialValues);
- that._placeholder();
- });
- };
- that._form = form.on('reset', that._resetHandler);
- }
- },
- _initValue: function () {
- var value = this.options.value || this.element.val();
- this._old = this._initialValues = this._normalizeValues(value);
- },
- _normalizeValues: function (value) {
- var that = this;
- if (value === null) {
- value = [];
- } else if (value && $.isPlainObject(value)) {
- value = [that._value(value)];
- } else if (value && $.isPlainObject(value[0])) {
- value = $.map(value, function (dataItem) {
- return that._value(dataItem);
- });
- } else if (!isArray(value) && !(value instanceof ObservableArray)) {
- value = [value];
- } else if (isArray(value)) {
- value = value.slice();
- }
- return value;
- },
- _change: function () {
- var that = this, value = that.value();
- if (!compare(value, that._old)) {
- that._old = value.slice();
- that.trigger(CHANGE);
- that.element.trigger(CHANGE);
- }
- that.popup.position();
- that._toggleCloseVisibility();
- },
- _click: function (e) {
- var that = this;
- var item = e.item;
- e.preventDefault();
- that._select(item).done(function () {
- that._activeItem = item;
- that._change();
- that._close();
- });
- },
- _getActiveItem: function () {
- return this._activeItem || $(this.listView.items()[this._getSelectedIndices().length - 1]) || this.listView.focus();
- },
- _getSelectedIndices: function () {
- return this.listView._selectedIndices || this.listView._selectedIndexes;
- },
- _keydown: function (e) {
- var that = this;
- var key = e.keyCode;
- var tag = that._currentTag;
- var listView = that.listView;
- var hasValue = that.input.val();
- var isRtl = kendo.support.isRtl(that.wrapper);
- var visible = that.popup.visible();
- var dir = 0;
- var activeItemIdx;
- var persistTagList;
- if (key !== keys.ENTER) {
- this._multipleSelection = false;
- }
- if (key === keys.DOWN) {
- e.preventDefault();
- if (!visible) {
- that.open();
- if (!listView.focus()) {
- listView.focusFirst();
- }
- return;
- }
- if (listView.focus()) {
- if (!that._activeItem && e.shiftKey) {
- that._activeItem = listView.focus();
- dir = -1;
- }
- activeItemIdx = listView.getElementIndex(that._getActiveItem().first());
- listView.focusNext();
- if (!listView.focus()) {
- listView.focusLast();
- } else {
- if (e.shiftKey) {
- this._multipleSelection = true;
- that._selectRange(activeItemIdx, listView.getElementIndex(listView.focus().first()) + dir);
- }
- }
- } else {
- listView.focusFirst();
- }
- } else if (key === keys.UP) {
- if (visible) {
- if (!that._activeItem && e.shiftKey) {
- that._activeItem = listView.focus();
- dir = 1;
- }
- activeItemIdx = listView.getElementIndex(that._getActiveItem().first());
- listView.focusPrev();
- if (!listView.focus()) {
- that.close();
- } else {
- if (e.shiftKey) {
- this._multipleSelection = true;
- that._selectRange(activeItemIdx, listView.getElementIndex(listView.focus().first()) + dir);
- }
- }
- }
- e.preventDefault();
- } else if (key === keys.LEFT && !isRtl || key === keys.RIGHT && isRtl) {
- if (!hasValue) {
- tag = tag ? tag.prev() : $(that.tagList[0].lastChild);
- if (tag[0]) {
- that.currentTag(tag);
- }
- }
- } else if (key === keys.RIGHT && !isRtl || key === keys.LEFT && isRtl) {
- if (!hasValue && tag) {
- tag = tag.next();
- that.currentTag(tag[0] ? tag : null);
- }
- } else if (e.ctrlKey && !e.altKey && key === keys.A && visible && !that.options.virtual) {
- this._multipleSelection = true;
- if (this._getSelectedIndices().length === listView.items().length) {
- that._activeItem = null;
- }
- if (listView.items().length) {
- that._selectRange(0, listView.items().length - 1);
- }
- } else if (key === keys.ENTER && visible) {
- if (!listView.focus()) {
- return;
- }
- e.preventDefault();
- if (this._multipleSelection) {
- this._multipleSelection = false;
- if (listView.focus().hasClass(SELECTEDCLASS)) {
- that._close();
- return;
- }
- }
- that._select(listView.focus()).done(function () {
- that._change();
- that._close();
- });
- } else if (key === keys.SPACEBAR && e.ctrlKey && visible) {
- if (that._activeItem && listView.focus() && listView.focus()[0] === that._activeItem[0]) {
- that._activeItem = null;
- }
- if (!$(listView.focus()).hasClass(SELECTEDCLASS)) {
- that._activeItem = listView.focus();
- }
- that._select(listView.focus()).done(function () {
- that._change();
- });
- e.preventDefault();
- } else if (key === keys.SPACEBAR && e.shiftKey && visible) {
- var activeIndex = listView.getElementIndex(that._getActiveItem());
- var currentIndex = listView.getElementIndex(listView.focus());
- if (activeIndex !== undefined && currentIndex !== undefined) {
- that._selectRange(activeIndex, currentIndex);
- }
- e.preventDefault();
- } else if (key === keys.ESC) {
- if (visible) {
- e.preventDefault();
- } else {
- that.tagList.children().each(function (index, tag) {
- that._removeTag($(tag), false);
- });
- that._change();
- }
- that.close();
- } else if (key === keys.HOME) {
- if (visible) {
- if (!listView.focus()) {
- that.close();
- } else {
- if (e.ctrlKey && e.shiftKey && !that.options.virtual) {
- that._selectRange(listView.getElementIndex(listView.focus()[0]), 0);
- }
- listView.focusFirst();
- }
- } else if (!hasValue) {
- tag = that.tagList[0].firstChild;
- if (tag) {
- that.currentTag($(tag));
- }
- }
- } else if (key === keys.END) {
- if (visible) {
- if (!listView.focus()) {
- that.close();
- } else {
- if (e.ctrlKey && e.shiftKey && !that.options.virtual) {
- that._selectRange(listView.getElementIndex(listView.focus()[0]), listView.element.children().length - 1);
- }
- listView.focusLast();
- }
- } else if (!hasValue) {
- tag = that.tagList[0].lastChild;
- if (tag) {
- that.currentTag($(tag));
- }
- }
- } else if ((key === keys.DELETE || key === keys.BACKSPACE) && !hasValue) {
- that._state = ACCEPT;
- if (that.options.tagMode === 'single') {
- persistTagList = that.persistTagList;
- if (persistTagList) {
- that.persistTagList = false;
- }
- listView.value([]);
- that._change();
- that._close();
- that.persistTagList = persistTagList;
- return;
- }
- if (key === keys.BACKSPACE && !tag) {
- tag = $(that.tagList[0].lastChild);
- }
- if (tag && tag[0]) {
- that._removeTag(tag, true);
- }
- } else if (that.popup.visible() && (key === keys.PAGEDOWN || key === keys.PAGEUP)) {
- e.preventDefault();
- var direction = key === keys.PAGEDOWN ? 1 : -1;
- listView.scrollWith(direction * listView.screenHeight());
- } else {
- clearTimeout(that._typingTimeout);
- setTimeout(function () {
- that._scale();
- });
- that._search();
- }
- },
- _hideBusy: function () {
- var that = this;
- clearTimeout(that._busy);
- that.input.attr('aria-busy', false);
- that._loading.addClass(HIDDENCLASS);
- that._request = false;
- that._busy = null;
- that._toggleCloseVisibility();
- },
- _showBusyHandler: function () {
- this.input.attr('aria-busy', true);
- this._loading.removeClass(HIDDENCLASS);
- this._hideClear();
- },
- _showBusy: function () {
- var that = this;
- that._request = true;
- if (that._busy) {
- return;
- }
- that._busy = setTimeout(proxy(that._showBusyHandler, that), 100);
- },
- _placeholder: function (show, skipCaret) {
- var that = this;
- var input = that.input;
- var active = activeElement();
- var placeholder = that.options.placeholder;
- var inputValue = input.val();
- var isActive = input[0] === active;
- var caretPos = inputValue.length;
- if (!isActive || that.options.autoClose || inputValue === placeholder) {
- caretPos = 0;
- inputValue = '';
- }
- if (show === undefined) {
- show = false;
- if (input[0] !== active) {
- show = !that.listView.selectedDataItems()[0];
- }
- }
- that._prev = inputValue;
- input.toggleClass('k-readonly', show).val(show ? placeholder : inputValue);
- if (isActive && !skipCaret) {
- kendo.caret(input[0], caretPos, caretPos);
- }
- that._scale();
- },
- _scale: function () {
- var that = this, wrapper = that.wrapper.find('.k-multiselect-wrap'), wrapperWidth = wrapper.width(), span = that._span.text(that.input.val()), textWidth;
- if (!wrapper.is(':visible')) {
- span.appendTo(document.documentElement);
- wrapperWidth = textWidth = span.width() + 25;
- span.appendTo(wrapper);
- } else {
- textWidth = span.width() + 25;
- }
- that.input.width(textWidth > wrapperWidth ? wrapperWidth : textWidth);
- },
- _option: function (dataValue, dataText, selected) {
- var option = '
';
- },
- _render: function (data) {
- var selectedItems = this.listView.selectedDataItems();
- var values = this.listView.value();
- var length = data.length;
- var selectedIndex;
- var options = '';
- var dataItem;
- var value;
- var idx;
- if (values.length !== selectedItems.length) {
- selectedItems = this._buildSelectedItems(values);
- }
- var custom = {};
- var optionsMap = {};
- for (idx = 0; idx < length; idx++) {
- dataItem = data[idx];
- value = this._value(dataItem);
- selectedIndex = this._selectedItemIndex(value, selectedItems);
- if (selectedIndex !== -1) {
- selectedItems.splice(selectedIndex, 1);
- }
- optionsMap[value] = idx;
- options += this._option(value, this._text(dataItem), selectedIndex !== -1);
- }
- if (selectedItems.length) {
- for (idx = 0; idx < selectedItems.length; idx++) {
- dataItem = selectedItems[idx];
- value = this._value(dataItem);
- custom[value] = length;
- optionsMap[value] = length;
- length += 1;
- options += this._option(value, this._text(dataItem), true);
- }
- }
- this._customOptions = custom;
- this._optionsMap = optionsMap;
- this.element.html(options);
- },
- _buildSelectedItems: function (values) {
- var valueField = this.options.dataValueField;
- var textField = this.options.dataTextField;
- var result = [];
- var item;
- for (var idx = 0; idx < values.length; idx++) {
- item = {};
- item[valueField] = values[idx];
- item[textField] = values[idx];
- result.push(item);
- }
- return result;
- },
- _selectedItemIndex: function (value, selectedItems) {
- var valueGetter = this._value;
- var idx = 0;
- for (; idx < selectedItems.length; idx++) {
- if (value === valueGetter(selectedItems[idx])) {
- return idx;
- }
- }
- return -1;
- },
- _search: function () {
- var that = this;
- clearTimeout(that._typingTimeout);
- that._typingTimeout = setTimeout(function () {
- var value = that._inputValue();
- if (that._prev !== value) {
- that._prev = value;
- that.search(value);
- that._toggleCloseVisibility();
- }
- }, that.options.delay);
- },
- _toggleCloseVisibility: function () {
- if (this.value().length || this.input.val() && this.input.val() !== this.options.placeholder) {
- this._showClear();
- } else {
- this._hideClear();
- }
- },
- _allowOpening: function () {
- return this._allowSelection() && List.fn._allowOpening.call(this);
- },
- _allowSelection: function () {
- var max = this.options.maxSelectedItems;
- return max === null || max > this.listView.value().length;
- },
- _angularTagItems: function (cmd) {
- var that = this;
- that.angular(cmd, function () {
- return {
- elements: that.tagList[0].children,
- data: $.map(that.dataItems(), function (dataItem) {
- return { dataItem: dataItem };
- })
- };
- });
- },
- updatePersistTagList: function (added, removed) {
- if (this.persistTagList.added && this.persistTagList.added.length === removed.length && this.persistTagList.removed && this.persistTagList.removed.length === added.length) {
- this.persistTagList = false;
- } else {
- this.listView._removedAddedIndexes = this._old.slice();
- this.persistTagList = {
- added: added,
- removed: removed
- };
- }
- },
- _selectValue: function (added, removed) {
- var that = this;
- var values = that.value();
- var total = that.dataSource.total();
- var tagList = that.tagList;
- var getter = that._value;
- var removedItem;
- var addedItem;
- var idx;
- if (this.persistTagList) {
- this.updatePersistTagList(added, removed);
- return;
- }
- that._angularTagItems('cleanup');
- if (that.options.tagMode === 'multiple') {
- for (idx = removed.length - 1; idx > -1; idx--) {
- removedItem = removed[idx];
- if (tagList.children().length) {
- tagList[0].removeChild(tagList[0].children[removedItem.position]);
- that._setOption(getter(removedItem.dataItem), false);
- }
- }
- for (idx = 0; idx < added.length; idx++) {
- addedItem = added[idx];
- tagList.append(that.tagTemplate(addedItem.dataItem));
- that._setOption(getter(addedItem.dataItem), true);
- }
- } else {
- if (!that._maxTotal || that._maxTotal < total) {
- that._maxTotal = total;
- }
- tagList.html('');
- if (values.length) {
- tagList.append(that.tagTemplate({
- values: values,
- dataItems: that.dataItems(),
- maxTotal: that._maxTotal,
- currentTotal: total
- }));
- }
- for (idx = removed.length - 1; idx > -1; idx--) {
- that._setOption(getter(removed[idx].dataItem), false);
- }
- for (idx = 0; idx < added.length; idx++) {
- that._setOption(getter(added[idx].dataItem), true);
- }
- }
- that._angularTagItems('compile');
- that._placeholder();
- },
- _select: function (candidate) {
- var resolved = $.Deferred().resolve();
- if (!candidate) {
- return resolved;
- }
- var that = this;
- var listView = that.listView;
- var dataItem = listView.dataItemByIndex(listView.getElementIndex(candidate));
- var isSelected = candidate.hasClass('k-state-selected');
- if (that._state === REBIND) {
- that._state = '';
- }
- if (!that._allowSelection() && !isSelected) {
- return resolved;
- }
- if (that.trigger(isSelected ? DESELECT : SELECT, {
- dataItem: dataItem,
- item: candidate
- })) {
- that._close();
- return resolved;
- }
- that.persistTagList = false;
- return listView.select(candidate).done(function () {
- that._placeholder();
- if (that._state === FILTER) {
- that._state = ACCEPT;
- listView.skipUpdate(true);
- }
- });
- },
- _selectRange: function (startIndex, endIndex) {
- var that = this;
- var listView = this.listView;
- var maxSelectedItems = this.options.maxSelectedItems;
- var indices = this._getSelectedIndices().slice();
- var indicesToSelect = [];
- var i;
- var selectIndices = function (indices) {
- listView.select(indices).done(function () {
- indices.forEach(function (index) {
- var dataItem = listView.dataItemByIndex(index);
- var candidate = listView.element.children()[index];
- var isSelected = $(candidate).hasClass('k-state-selected');
- that.trigger(isSelected ? SELECT : DESELECT, {
- dataItem: dataItem,
- item: $(candidate)
- });
- });
- that._change();
- });
- };
- if (indices.length - 1 === endIndex - startIndex) {
- return selectIndices(indices);
- }
- if (startIndex < endIndex) {
- for (i = startIndex; i <= endIndex; i++) {
- indicesToSelect.push(i);
- }
- } else {
- for (i = startIndex; i >= endIndex; i--) {
- indicesToSelect.push(i);
- }
- }
- if (maxSelectedItems !== null && indicesToSelect.length > maxSelectedItems) {
- indicesToSelect = indicesToSelect.slice(0, maxSelectedItems);
- }
- for (i = 0; i < indicesToSelect.length; i++) {
- var index = indicesToSelect[i];
- if (this._getSelectedIndices().indexOf(index) == -1) {
- indices.push(index);
- } else {
- indices.splice(indices.indexOf(index), 1);
- }
- }
- if (!indices.length) {
- return;
- }
- that.persistTagList = false;
- return selectIndices(indices);
- },
- _input: function () {
- var that = this;
- var element = that.element;
- var accessKey = element[0].accessKey;
- var input = that._innerWrapper.children('input.k-input');
- if (!input[0]) {
- input = $('
').appendTo(that._innerWrapper);
- }
- element.removeAttr('accesskey');
- that._focused = that.input = input.attr({
- 'accesskey': accessKey,
- 'autocomplete': 'off',
- 'role': 'listbox',
- 'title': element[0].title,
- 'aria-expanded': false
- });
- },
- _tagList: function () {
- var that = this, tagList = that._innerWrapper.children('ul');
- if (!tagList[0]) {
- tagList = $('
').appendTo(that._innerWrapper);
- }
- that.tagList = tagList;
- },
- _tagTemplate: function () {
- var that = this;
- var options = that.options;
- var tagTemplate = options.tagTemplate;
- var hasDataSource = options.dataSource;
- var isMultiple = options.tagMode === 'multiple';
- var defaultTemplate;
- if (that.element[0].length && !hasDataSource) {
- options.dataTextField = options.dataTextField || 'text';
- options.dataValueField = options.dataValueField || 'value';
- }
- defaultTemplate = isMultiple ? kendo.template('#:' + kendo.expr(options.dataTextField, 'data') + '#', { useWithBlock: false }) : kendo.template('#:values.length# item(s) selected');
- that.tagTextTemplate = tagTemplate = tagTemplate ? kendo.template(tagTemplate) : defaultTemplate;
- that.tagTemplate = function (data) {
- return '
' + tagTemplate(data) + '' + '';
- };
- },
- _loader: function () {
- this._loading = $('
').insertAfter(this.input);
- },
- _clearButton: function () {
- List.fn._clearButton.call(this);
- if (this.options.clearButton) {
- this._clear.insertAfter(this.input);
- this.wrapper.addClass('k-multiselect-clearable');
- }
- },
- _textContainer: function () {
- var computedStyles = kendo.getComputedStyles(this.input[0], styles);
- computedStyles.position = 'absolute';
- computedStyles.visibility = 'hidden';
- computedStyles.top = -3333;
- computedStyles.left = -3333;
- this._span = $('
').css(computedStyles).appendTo(this.wrapper);
- },
- _wrapper: function () {
- var that = this, element = that.element, wrapper = element.parent('span.k-multiselect');
- if (!wrapper[0]) {
- wrapper = element.wrap('
').parent();
- wrapper[0].style.cssText = element[0].style.cssText;
- wrapper[0].title = element[0].title;
- $('
').insertBefore(element);
- }
- that.wrapper = wrapper.addClass(element[0].className).css('display', '');
- that._innerWrapper = $(wrapper[0].firstChild);
- }
- });
- function compare(a, b) {
- var length;
- if (a === null && b !== null || a !== null && b === null) {
- return false;
- }
- length = a.length;
- if (length !== b.length) {
- return false;
- }
- while (length--) {
- if (a[length] !== b[length]) {
- return false;
- }
- }
- return true;
- }
- ui.plugin(MultiSelect);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.numerictextbox', [
- 'kendo.core',
- 'kendo.userevents'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'numerictextbox',
- name: 'NumericTextBox',
- category: 'web',
- description: 'The NumericTextBox widget can format and display numeric, percentage or currency textbox.',
- depends: [
- 'core',
- 'userevents'
- ]
- };
- (function ($, undefined) {
- var kendo = window.kendo, caret = kendo.caret, keys = kendo.keys, ui = kendo.ui, Widget = ui.Widget, activeElement = kendo._activeElement, extractFormat = kendo._extractFormat, parse = kendo.parseFloat, placeholderSupported = kendo.support.placeholder, getCulture = kendo.getCulture, CHANGE = 'change', DISABLED = 'disabled', READONLY = 'readonly', INPUT = 'k-input', SPIN = 'spin', ns = '.kendoNumericTextBox', TOUCHEND = 'touchend', MOUSELEAVE = 'mouseleave' + ns, HOVEREVENTS = 'mouseenter' + ns + ' ' + MOUSELEAVE, DEFAULT = 'k-state-default', FOCUSED = 'k-state-focused', HOVER = 'k-state-hover', FOCUS = 'focus', POINT = '.', CLASS_ICON = 'k-icon', SELECTED = 'k-state-selected', STATEDISABLED = 'k-state-disabled', STATE_INVALID = 'k-state-invalid', ARIA_DISABLED = 'aria-disabled', INTEGER_REGEXP = /^(-)?(\d*)$/, NULL = null, proxy = $.proxy, extend = $.extend;
- var NumericTextBox = Widget.extend({
- init: function (element, options) {
- var that = this, isStep = options && options.step !== undefined, min, max, step, value, disabled;
- var inputType;
- Widget.fn.init.call(that, element, options);
- options = that.options;
- element = that.element.on('focusout' + ns, proxy(that._focusout, that)).attr('role', 'spinbutton');
- options.placeholder = options.placeholder || element.attr('placeholder');
- min = that.min(element.attr('min'));
- max = that.max(element.attr('max'));
- step = that._parse(element.attr('step'));
- if (options.min === NULL && min !== NULL) {
- options.min = min;
- }
- if (options.max === NULL && max !== NULL) {
- options.max = max;
- }
- if (!isStep && step !== NULL) {
- options.step = step;
- }
- that._initialOptions = extend({}, options);
- inputType = element.attr('type');
- that._reset();
- that._wrapper();
- that._arrows();
- that._validation();
- that._input();
- if (!kendo.support.mobileOS) {
- that._text.on(FOCUS + ns, proxy(that._click, that));
- } else {
- that._text.on(TOUCHEND + ns + ' ' + FOCUS + ns, function () {
- if (kendo.support.browser.edge) {
- that._text.one(FOCUS + ns, function () {
- that._toggleText(false);
- element.focus();
- });
- } else {
- that._toggleText(false);
- element.focus();
- }
- });
- }
- element.attr('aria-valuemin', options.min !== NULL ? options.min * options.factor : options.min).attr('aria-valuemax', options.max !== NULL ? options.max * options.factor : options.max);
- options.format = extractFormat(options.format);
- value = options.value;
- if (value == NULL) {
- if (inputType == 'number') {
- value = parseFloat(element.val());
- } else {
- value = element.val();
- }
- }
- that.value(value);
- disabled = element.is('[disabled]') || $(that.element).parents('fieldset').is(':disabled');
- if (disabled) {
- that.enable(false);
- } else {
- that.readonly(element.is('[readonly]'));
- }
- that.angular('compile', function () {
- return { elements: that._text.get() };
- });
- kendo.notify(that);
- },
- options: {
- name: 'NumericTextBox',
- decimals: NULL,
- restrictDecimals: false,
- min: NULL,
- max: NULL,
- value: NULL,
- step: 1,
- round: true,
- culture: '',
- format: 'n',
- spinners: true,
- placeholder: '',
- factor: 1,
- upArrowText: 'Increase value',
- downArrowText: 'Decrease value'
- },
- events: [
- CHANGE,
- SPIN
- ],
- _editable: function (options) {
- var that = this, element = that.element, disable = options.disable, readonly = options.readonly, text = that._text.add(element), wrapper = that._inputWrapper.off(HOVEREVENTS);
- that._toggleText(true);
- that._upArrowEventHandler.unbind('press');
- that._downArrowEventHandler.unbind('press');
- element.off('keydown' + ns).off('keypress' + ns).off('keyup' + ns).off('paste' + ns);
- if (!readonly && !disable) {
- wrapper.addClass(DEFAULT).removeClass(STATEDISABLED).on(HOVEREVENTS, that._toggleHover);
- text.removeAttr(DISABLED).removeAttr(READONLY).attr(ARIA_DISABLED, false);
- that._upArrowEventHandler.bind('press', function (e) {
- e.preventDefault();
- that._spin(1);
- that._upArrow.addClass(SELECTED);
- });
- that._downArrowEventHandler.bind('press', function (e) {
- e.preventDefault();
- that._spin(-1);
- that._downArrow.addClass(SELECTED);
- });
- that.element.on('keydown' + ns, proxy(that._keydown, that)).on('keypress' + ns, proxy(that._keypress, that)).on('keyup' + ns, proxy(that._keyup, that)).on('paste' + ns, proxy(that._paste, that));
- } else {
- wrapper.addClass(disable ? STATEDISABLED : DEFAULT).removeClass(disable ? DEFAULT : STATEDISABLED);
- text.attr(DISABLED, disable).attr(READONLY, readonly).attr(ARIA_DISABLED, disable);
- }
- },
- readonly: function (readonly) {
- this._editable({
- readonly: readonly === undefined ? true : readonly,
- disable: false
- });
- },
- enable: function (enable) {
- this._editable({
- readonly: false,
- disable: !(enable = enable === undefined ? true : enable)
- });
- },
- setOptions: function (options) {
- var that = this;
- Widget.fn.setOptions.call(that, options);
- that._arrowsWrap.toggle(that.options.spinners);
- that._inputWrapper.toggleClass('k-expand-padding', !that.options.spinners);
- that._text.prop('placeholder', that.options.placeholder);
- that._placeholder(that.options.placeholder);
- that.element.attr({
- 'aria-valuemin': that.options.min !== NULL ? that.options.min * that.options.factor : that.options.min,
- 'aria-valuemax': that.options.max !== NULL ? that.options.max * that.options.factor : that.options.max
- });
- that.options.format = extractFormat(that.options.format);
- if (options.value !== undefined) {
- that.value(options.value);
- }
- },
- destroy: function () {
- var that = this;
- that.element.add(that._text).add(that._upArrow).add(that._downArrow).add(that._inputWrapper).off(ns);
- that._upArrowEventHandler.destroy();
- that._downArrowEventHandler.destroy();
- if (that._form) {
- that._form.off('reset', that._resetHandler);
- }
- Widget.fn.destroy.call(that);
- },
- min: function (value) {
- return this._option('min', value);
- },
- max: function (value) {
- return this._option('max', value);
- },
- step: function (value) {
- return this._option('step', value);
- },
- value: function (value) {
- var that = this, adjusted;
- if (value === undefined) {
- return that._value;
- }
- value = that._parse(value);
- adjusted = that._adjust(value);
- if (value !== adjusted) {
- return;
- }
- that._update(value);
- that._old = that._value;
- },
- focus: function () {
- this._focusin();
- },
- _adjust: function (value) {
- var that = this, options = that.options, min = options.min, max = options.max;
- if (value === NULL) {
- return value;
- }
- if (min !== NULL && value < min) {
- value = min;
- } else if (max !== NULL && value > max) {
- value = max;
- }
- return value;
- },
- _arrows: function () {
- var that = this, arrows, _release = function () {
- clearTimeout(that._spinning);
- arrows.removeClass(SELECTED);
- }, options = that.options, spinners = options.spinners, element = that.element;
- arrows = element.siblings('.' + CLASS_ICON);
- if (!arrows[0]) {
- arrows = $(buttonHtml('increase', options.upArrowText) + buttonHtml('decrease', options.downArrowText)).insertAfter(element);
- that._arrowsWrap = arrows.wrapAll('
').parent();
- }
- if (!spinners) {
- arrows.parent().toggle(spinners);
- that._inputWrapper.addClass('k-expand-padding');
- }
- that._upArrow = arrows.eq(0);
- that._upArrowEventHandler = new kendo.UserEvents(that._upArrow, { release: _release });
- that._downArrow = arrows.eq(1);
- that._downArrowEventHandler = new kendo.UserEvents(that._downArrow, { release: _release });
- },
- _validation: function () {
- var that = this;
- var element = that.element;
- that._validationIcon = $('
').hide().insertAfter(element);
- },
- _blur: function () {
- var that = this;
- that._toggleText(true);
- that._change(that.element.val());
- },
- _click: function (e) {
- var that = this;
- clearTimeout(that._focusing);
- that._focusing = setTimeout(function () {
- var input = e.target, idx = caret(input)[0], value = input.value.substring(0, idx), format = that._format(that.options.format), group = format[','], result, groupRegExp, extractRegExp, caretPosition = 0;
- if (group) {
- groupRegExp = new RegExp('\\' + group, 'g');
- extractRegExp = new RegExp('([\\d\\' + group + ']+)(\\' + format[POINT] + ')?(\\d+)?');
- }
- if (extractRegExp) {
- result = extractRegExp.exec(value);
- }
- if (result) {
- caretPosition = result[0].replace(groupRegExp, '').length;
- if (value.indexOf('(') != -1 && that._value < 0) {
- caretPosition++;
- }
- }
- that._focusin();
- caret(that.element[0], caretPosition);
- });
- },
- _change: function (value) {
- var that = this, factor = that.options.factor;
- if (factor && factor !== 1) {
- value = kendo.parseFloat(value);
- if (value !== null) {
- value = value / factor;
- }
- }
- that._update(value);
- value = that._value;
- if (that._old != value) {
- that._old = value;
- if (!that._typing) {
- that.element.trigger(CHANGE);
- }
- that.trigger(CHANGE);
- }
- that._typing = false;
- },
- _culture: function (culture) {
- return culture || getCulture(this.options.culture);
- },
- _focusin: function () {
- var that = this;
- that._inputWrapper.addClass(FOCUSED);
- that._toggleText(false);
- that.element[0].focus();
- },
- _focusout: function () {
- var that = this;
- clearTimeout(that._focusing);
- that._inputWrapper.removeClass(FOCUSED).removeClass(HOVER);
- that._blur();
- that._removeInvalidState();
- },
- _format: function (format, culture) {
- var numberFormat = this._culture(culture).numberFormat;
- format = format.toLowerCase();
- if (format.indexOf('c') > -1) {
- numberFormat = numberFormat.currency;
- } else if (format.indexOf('p') > -1) {
- numberFormat = numberFormat.percent;
- }
- return numberFormat;
- },
- _input: function () {
- var that = this, options = that.options, CLASSNAME = 'k-formatted-value', element = that.element.addClass(INPUT).show()[0], accessKey = element.accessKey, wrapper = that.wrapper, text;
- text = wrapper.find(POINT + CLASSNAME);
- if (!text[0]) {
- text = $('
').insertBefore(element).addClass(CLASSNAME);
- }
- try {
- element.setAttribute('type', 'text');
- } catch (e) {
- element.type = 'text';
- }
- text[0].title = element.title;
- text[0].tabIndex = element.tabIndex;
- text[0].style.cssText = element.style.cssText;
- text.prop('placeholder', options.placeholder);
- if (accessKey) {
- text.attr('accesskey', accessKey);
- element.accessKey = '';
- }
- that._text = text.addClass(element.className).attr({
- 'role': 'spinbutton',
- 'aria-valuemin': options.min !== NULL ? options.min * options.factor : options.min,
- 'aria-valuemax': options.max !== NULL ? options.max * options.factor : options.max,
- 'autocomplete': 'off'
- });
- },
- _keydown: function (e) {
- var that = this, key = e.keyCode;
- that._key = key;
- if (key == keys.DOWN) {
- that._step(-1);
- } else if (key == keys.UP) {
- that._step(1);
- } else if (key == keys.ENTER) {
- that._change(that.element.val());
- } else if (key != keys.TAB) {
- that._typing = true;
- }
- },
- _keypress: function (e) {
- if (e.which === 0 || e.metaKey || e.ctrlKey || e.keyCode === keys.BACKSPACE || e.keyCode === keys.ENTER) {
- return;
- }
- var that = this;
- var min = that.options.min;
- var element = that.element;
- var selection = caret(element);
- var selectionStart = selection[0];
- var selectionEnd = selection[1];
- var character = String.fromCharCode(e.which);
- var numberFormat = that._format(that.options.format);
- var isNumPadDecimal = that._key === keys.NUMPAD_DOT;
- var value = element.val();
- var isValid;
- if (isNumPadDecimal) {
- character = numberFormat[POINT];
- }
- value = value.substring(0, selectionStart) + character + value.substring(selectionEnd);
- isValid = that._numericRegex(numberFormat).test(value);
- if (isValid && isNumPadDecimal) {
- element.val(value);
- caret(element, selectionStart + character.length);
- e.preventDefault();
- } else if (min !== null && min >= 0 && value.charAt(0) === '-' || !isValid) {
- that._addInvalidState();
- e.preventDefault();
- }
- that._key = 0;
- },
- _keyup: function () {
- this._removeInvalidState();
- },
- _addInvalidState: function () {
- var that = this;
- that._inputWrapper.addClass(STATE_INVALID);
- that._validationIcon.show();
- },
- _removeInvalidState: function () {
- var that = this;
- that._inputWrapper.removeClass(STATE_INVALID);
- that._validationIcon.hide();
- },
- _numericRegex: function (numberFormat) {
- var that = this;
- var separator = numberFormat[POINT];
- var precision = that.options.decimals;
- var fractionRule = '*';
- if (separator === POINT) {
- separator = '\\' + separator;
- }
- if (precision === NULL) {
- precision = numberFormat.decimals;
- }
- if (precision === 0 && that.options.restrictDecimals) {
- return INTEGER_REGEXP;
- }
- if (that.options.restrictDecimals) {
- fractionRule = '{0,' + precision + '}';
- }
- if (that._separator !== separator) {
- that._separator = separator;
- that._floatRegExp = new RegExp('^(-)?(((\\d+(' + separator + '\\d' + fractionRule + ')?)|(' + separator + '\\d' + fractionRule + ')))?$');
- }
- return that._floatRegExp;
- },
- _paste: function (e) {
- var that = this;
- var element = e.target;
- var value = element.value;
- var numberFormat = that._format(that.options.format);
- setTimeout(function () {
- var result = that._parse(element.value);
- if (result === NULL) {
- that._update(value);
- } else {
- element.value = result.toString().replace(POINT, numberFormat[POINT]);
- if (that._adjust(result) !== result || !that._numericRegex(numberFormat).test(element.value)) {
- that._update(value);
- }
- }
- });
- },
- _option: function (option, value) {
- var that = this, element = that.element, options = that.options;
- if (value === undefined) {
- return options[option];
- }
- value = that._parse(value);
- if (!value && option === 'step') {
- return;
- }
- options[option] = value;
- element.add(that._text).attr('aria-value' + option, value);
- element.attr(option, value);
- },
- _spin: function (step, timeout) {
- var that = this;
- timeout = timeout || 500;
- clearTimeout(that._spinning);
- that._spinning = setTimeout(function () {
- that._spin(step, 50);
- }, timeout);
- that._step(step);
- },
- _step: function (step) {
- var that = this, element = that.element, originalValue = that._value, value = that._parse(element.val()) || 0, precision = that.options.decimals || 2;
- if (activeElement() != element[0]) {
- that._focusin();
- }
- if (that.options.factor && value) {
- value = value / that.options.factor;
- }
- value = +(value + that.options.step * step).toFixed(precision);
- value = that._adjust(value);
- that._update(value);
- that._typing = false;
- if (originalValue !== value) {
- that.trigger(SPIN);
- }
- },
- _toggleHover: function (e) {
- $(e.currentTarget).toggleClass(HOVER, e.type === 'mouseenter');
- },
- _toggleText: function (toggle) {
- var that = this;
- that._text.toggle(toggle);
- that.element.toggle(!toggle);
- },
- _parse: function (value, culture) {
- return parse(value, this._culture(culture), this.options.format);
- },
- _round: function (value, precision) {
- var rounder = this.options.round ? kendo._round : truncate;
- return rounder(value, precision);
- },
- _update: function (value) {
- var that = this, options = that.options, factor = options.factor, format = options.format, decimals = options.decimals, culture = that._culture(), numberFormat = that._format(format, culture), isNotNull;
- if (decimals === NULL) {
- decimals = numberFormat.decimals;
- }
- value = that._parse(value, culture);
- isNotNull = value !== NULL;
- if (isNotNull) {
- value = parseFloat(that._round(value, decimals), 10);
- }
- that._value = value = that._adjust(value);
- that._placeholder(kendo.toString(value, format, culture));
- if (isNotNull) {
- if (factor) {
- value = parseFloat(that._round(value * factor, decimals), 10);
- }
- value = value.toString();
- if (value.indexOf('e') !== -1) {
- value = that._round(+value, decimals);
- }
- value = value.replace(POINT, numberFormat[POINT]);
- } else {
- value = null;
- }
- that.element.val(value);
- that.element.add(that._text).attr('aria-valuenow', value);
- },
- _placeholder: function (value) {
- var input = this._text;
- input.val(value);
- if (!placeholderSupported && !value) {
- input.val(this.options.placeholder);
- }
- input.attr('title', this.element.attr('title') || input.val());
- },
- _wrapper: function () {
- var that = this, element = that.element, DOMElement = element[0], wrapper;
- wrapper = element.parents('.k-numerictextbox');
- if (!wrapper.is('span.k-numerictextbox')) {
- wrapper = element.hide().wrap('
').parent();
- wrapper = wrapper.wrap('
').parent();
- }
- wrapper[0].style.cssText = DOMElement.style.cssText;
- DOMElement.style.width = '';
- that.wrapper = wrapper.addClass('k-widget k-numerictextbox').addClass(DOMElement.className).css('display', '');
- that._inputWrapper = $(wrapper[0].firstChild);
- },
- _reset: function () {
- var that = this, element = that.element, formId = element.attr('form'), form = formId ? $('#' + formId) : element.closest('form');
- if (form[0]) {
- that._resetHandler = function () {
- setTimeout(function () {
- that.value(element[0].value);
- that.max(that._initialOptions.max);
- that.min(that._initialOptions.min);
- });
- };
- that._form = form.on('reset', that._resetHandler);
- }
- }
- });
- function buttonHtml(direction, text) {
- var className = 'k-i-arrow-' + (direction === 'increase' ? '60-up' : '60-down');
- return '
' + '' + '';
- }
- function truncate(value, precision) {
- var parts = parseFloat(value, 10).toString().split(POINT);
- if (parts[1]) {
- parts[1] = parts[1].substring(0, precision);
- }
- return parts.join(POINT);
- }
- ui.plugin(NumericTextBox);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.toolbar', [
- 'kendo.core',
- 'kendo.userevents',
- 'kendo.popup'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'toolbar',
- name: 'ToolBar',
- category: 'web',
- description: 'The ToolBar widget displays one or more command buttons divided into groups.',
- depends: ['core']
- };
- (function ($, undefined) {
- var kendo = window.kendo, Class = kendo.Class, Widget = kendo.ui.Widget, proxy = $.proxy, isFunction = kendo.isFunction, keys = kendo.keys, outerWidth = kendo._outerWidth, TOOLBAR = 'k-toolbar', BUTTON = 'k-button', OVERFLOW_BUTTON = 'k-overflow-button', TOGGLE_BUTTON = 'k-toggle-button', BUTTON_GROUP = 'k-button-group', SPLIT_BUTTON = 'k-split-button', SEPARATOR = 'k-separator', POPUP = 'k-popup', RESIZABLE_TOOLBAR = 'k-toolbar-resizable', STATE_ACTIVE = 'k-state-active', STATE_DISABLED = 'k-state-disabled', STATE_HIDDEN = 'k-state-hidden', GROUP_START = 'k-group-start', GROUP_END = 'k-group-end', PRIMARY = 'k-primary', ICON = 'k-icon', ICON_PREFIX = 'k-i-', BUTTON_ICON = 'k-button-icon', BUTTON_ICON_TEXT = 'k-button-icontext', LIST_CONTAINER = 'k-list-container k-split-container', SPLIT_BUTTON_ARROW = 'k-split-button-arrow', OVERFLOW_ANCHOR = 'k-overflow-anchor', OVERFLOW_CONTAINER = 'k-overflow-container', FIRST_TOOLBAR_VISIBLE = 'k-toolbar-first-visible', LAST_TOOLBAR_VISIBLE = 'k-toolbar-last-visible', CLICK = 'click', TOGGLE = 'toggle', OPEN = 'open', CLOSE = 'close', OVERFLOW_OPEN = 'overflowOpen', OVERFLOW_CLOSE = 'overflowClose', OVERFLOW_NEVER = 'never', OVERFLOW_AUTO = 'auto', OVERFLOW_ALWAYS = 'always', OVERFLOW_HIDDEN = 'k-overflow-hidden', OPTION_LIST_SUFFIX = '_optionlist', KENDO_UID_ATTR = kendo.attr('uid');
- kendo.toolbar = {};
- var components = {
- overflowAnchor: '
',
- overflowContainer: '
'
- };
- kendo.toolbar.registerComponent = function (name, toolbar, overflow) {
- components[name] = {
- toolbar: toolbar,
- overflow: overflow
- };
- };
- var Item = kendo.Class.extend({
- addOverflowAttr: function () {
- this.element.attr(kendo.attr('overflow'), this.options.overflow || OVERFLOW_AUTO);
- },
- addUidAttr: function () {
- this.element.attr(KENDO_UID_ATTR, this.options.uid);
- },
- addIdAttr: function () {
- if (this.options.id) {
- this.element.attr('id', this.options.id);
- }
- },
- addOverflowIdAttr: function () {
- if (this.options.id) {
- this.element.attr('id', this.options.id + '_overflow');
- }
- },
- attributes: function () {
- if (this.options.attributes) {
- this.element.attr(this.options.attributes);
- }
- },
- show: function () {
- this.element.removeClass(STATE_HIDDEN).show();
- this.options.hidden = false;
- },
- hide: function () {
- this.element.addClass(STATE_HIDDEN).hide();
- if (this.overflow && this.overflowHidden) {
- this.overflowHidden();
- }
- this.options.hidden = true;
- },
- remove: function () {
- this.element.remove();
- },
- enable: function (isEnabled) {
- if (isEnabled === undefined) {
- isEnabled = true;
- }
- this.element.toggleClass(STATE_DISABLED, !isEnabled);
- this.options.enable = isEnabled;
- },
- twin: function () {
- var uid = this.element.attr(KENDO_UID_ATTR);
- if (this.overflow && this.options.splitContainerId) {
- return $('#' + this.options.splitContainerId).find('[' + KENDO_UID_ATTR + '=\'' + uid + '\']').data(this.options.type);
- } else if (this.overflow) {
- return this.toolbar.element.find('[' + KENDO_UID_ATTR + '=\'' + uid + '\']').data(this.options.type);
- } else if (this.toolbar.options.resizable) {
- return this.toolbar.popup.element.find('[' + KENDO_UID_ATTR + '=\'' + uid + '\']').data(this.options.type);
- }
- }
- });
- kendo.toolbar.Item = Item;
- var Button = Item.extend({
- init: function (options, toolbar) {
- var element = options.useButtonTag ? $('
') : $('
');
- this.element = element;
- this.options = options;
- this.toolbar = toolbar;
- this.attributes();
- if (options.primary) {
- element.addClass(PRIMARY);
- }
- if (options.togglable) {
- element.addClass(TOGGLE_BUTTON);
- this.toggle(options.selected);
- }
- if (options.url !== undefined && !options.useButtonTag) {
- element.attr('href', options.url);
- if (options.mobile) {
- element.attr(kendo.attr('role'), 'button');
- }
- }
- if (options.group) {
- element.attr(kendo.attr('group'), options.group);
- this.group = this.toolbar.addToGroup(this, options.group);
- }
- if (!options.togglable && options.click && isFunction(options.click)) {
- this.clickHandler = options.click;
- }
- if (options.togglable && options.toggle && isFunction(options.toggle)) {
- this.toggleHandler = options.toggle;
- }
- },
- toggle: function (state, propagate) {
- state = !!state;
- if (this.group && state) {
- this.group.select(this);
- } else if (!this.group) {
- this.select(state);
- }
- if (propagate && this.twin()) {
- this.twin().toggle(state);
- }
- },
- getParentGroup: function () {
- if (this.options.isChild) {
- return this.element.closest('.' + BUTTON_GROUP).data('buttonGroup');
- }
- },
- _addGraphics: function () {
- var element = this.element, icon = this.options.icon, spriteCssClass = this.options.spriteCssClass, imageUrl = this.options.imageUrl, isEmpty, span, img;
- if (spriteCssClass || imageUrl || icon) {
- isEmpty = true;
- element.contents().filter(function () {
- return !$(this).hasClass('k-sprite') && !$(this).hasClass(ICON) && !$(this).hasClass('k-image');
- }).each(function (idx, el) {
- if (el.nodeType == 1 || el.nodeType == 3 && $.trim(el.nodeValue).length > 0) {
- isEmpty = false;
- }
- });
- if (isEmpty) {
- element.addClass(BUTTON_ICON);
- } else {
- element.addClass(BUTTON_ICON_TEXT);
- }
- }
- if (icon) {
- span = element.children('span.' + ICON).first();
- if (!span[0]) {
- span = $('
').prependTo(element);
- }
- span.addClass(ICON_PREFIX + icon);
- } else if (spriteCssClass) {
- span = element.children('span.k-sprite').first();
- if (!span[0]) {
- span = $('
').prependTo(element);
- }
- span.addClass(spriteCssClass);
- } else if (imageUrl) {
- img = element.children('img.k-image').first();
- if (!img[0]) {
- img = $('
').prependTo(element);
- }
- img.attr('src', imageUrl);
- }
- }
- });
- kendo.toolbar.Button = Button;
- var ToolBarButton = Button.extend({
- init: function (options, toolbar) {
- Button.fn.init.call(this, options, toolbar);
- var element = this.element;
- element.addClass(BUTTON);
- this.addIdAttr();
- if (options.align) {
- element.addClass('k-align-' + options.align);
- }
- if (options.showText != 'overflow' && options.text) {
- if (options.mobile) {
- element.html('
' + options.text + '');
- } else {
- element.html(options.text);
- }
- }
- options.hasIcon = options.showIcon != 'overflow' && (options.icon || options.spriteCssClass || options.imageUrl);
- if (options.hasIcon) {
- this._addGraphics();
- }
- this.addUidAttr();
- this.addOverflowAttr();
- this.enable(options.enable);
- if (options.hidden) {
- this.hide();
- }
- this.element.data({
- type: 'button',
- button: this
- });
- },
- select: function (selected) {
- if (selected === undefined) {
- selected = false;
- }
- this.element.toggleClass(STATE_ACTIVE, selected);
- this.options.selected = selected;
- }
- });
- kendo.toolbar.ToolBarButton = ToolBarButton;
- var OverflowButton = Button.extend({
- init: function (options, toolbar) {
- this.overflow = true;
- Button.fn.init.call(this, $.extend({}, options), toolbar);
- var element = this.element;
- if (options.showText != 'toolbar' && options.text) {
- if (options.mobile) {
- element.html('
' + options.text + '');
- } else {
- element.html('
' + options.text + '');
- }
- }
- options.hasIcon = options.showIcon != 'toolbar' && (options.icon || options.spriteCssClass || options.imageUrl);
- if (options.hasIcon) {
- this._addGraphics();
- }
- if (!options.isChild) {
- this._wrap();
- }
- this.addOverflowIdAttr();
- this.attributes();
- this.addUidAttr();
- this.addOverflowAttr();
- this.enable(options.enable);
- element.addClass(OVERFLOW_BUTTON + ' ' + BUTTON);
- if (options.hidden) {
- this.hide();
- }
- if (options.togglable) {
- this.toggle(options.selected);
- }
- this.element.data({
- type: 'button',
- button: this
- });
- },
- _wrap: function () {
- this.element = this.element.wrap('
').parent();
- },
- overflowHidden: function () {
- this.element.addClass(OVERFLOW_HIDDEN);
- },
- select: function (selected) {
- if (selected === undefined) {
- selected = false;
- }
- if (this.options.isChild) {
- this.element.toggleClass(STATE_ACTIVE, selected);
- } else {
- this.element.find('.k-button').toggleClass(STATE_ACTIVE, selected);
- }
- this.options.selected = selected;
- }
- });
- kendo.toolbar.OverflowButton = OverflowButton;
- kendo.toolbar.registerComponent('button', ToolBarButton, OverflowButton);
- var ButtonGroup = Item.extend({
- createButtons: function (buttonConstructor) {
- var options = this.options;
- var items = options.buttons || [];
- var item;
- for (var i = 0; i < items.length; i++) {
- if (!items[i].uid) {
- items[i].uid = kendo.guid();
- }
- item = new buttonConstructor($.extend({
- mobile: options.mobile,
- isChild: true,
- type: 'button'
- }, items[i]), this.toolbar);
- item.element.appendTo(this.element);
- }
- },
- refresh: function () {
- this.element.children().filter(':not(\'.' + STATE_HIDDEN + '\'):first').addClass(GROUP_START);
- this.element.children().filter(':not(\'.' + STATE_HIDDEN + '\'):last').addClass(GROUP_END);
- }
- });
- kendo.toolbar.ButtonGroup = ButtonGroup;
- var ToolBarButtonGroup = ButtonGroup.extend({
- init: function (options, toolbar) {
- var element = this.element = $('
');
- this.options = options;
- this.toolbar = toolbar;
- this.addIdAttr();
- if (options.align) {
- element.addClass('k-align-' + options.align);
- }
- this.createButtons(ToolBarButton);
- this.attributes();
- this.addUidAttr();
- this.addOverflowAttr();
- this.refresh();
- element.addClass(BUTTON_GROUP);
- this.element.data({
- type: 'buttonGroup',
- buttonGroup: this
- });
- }
- });
- kendo.toolbar.ToolBarButtonGroup = ToolBarButtonGroup;
- var OverflowButtonGroup = ButtonGroup.extend({
- init: function (options, toolbar) {
- var element = this.element = $('
');
- this.options = options;
- this.toolbar = toolbar;
- this.overflow = true;
- this.addOverflowIdAttr();
- this.createButtons(OverflowButton);
- this.attributes();
- this.addUidAttr();
- this.addOverflowAttr();
- this.refresh();
- element.addClass((options.mobile ? '' : BUTTON_GROUP) + ' k-overflow-group');
- this.element.data({
- type: 'buttonGroup',
- buttonGroup: this
- });
- },
- overflowHidden: function () {
- this.element.addClass(OVERFLOW_HIDDEN);
- }
- });
- kendo.toolbar.OverflowButtonGroup = OverflowButtonGroup;
- kendo.toolbar.registerComponent('buttonGroup', ToolBarButtonGroup, OverflowButtonGroup);
- var ToolBarSplitButton = Item.extend({
- init: function (options, toolbar) {
- var element = this.element = $('
');
- this.options = options;
- this.toolbar = toolbar;
- this.mainButton = new ToolBarButton($.extend({}, options, { hidden: false }), toolbar);
- this.arrowButton = $('
');
- this.popupElement = $('
');
- this.mainButton.element.removeAttr('href tabindex').appendTo(element);
- this.arrowButton.appendTo(element);
- this.popupElement.appendTo(element);
- if (options.align) {
- element.addClass('k-align-' + options.align);
- }
- if (!options.id) {
- options.id = options.uid;
- }
- element.attr('id', options.id + '_wrapper');
- this.addOverflowAttr();
- this.addUidAttr();
- this.createMenuButtons();
- this.createPopup();
- this._navigatable();
- this.mainButton.main = true;
- this.enable(options.enable);
- if (options.hidden) {
- this.hide();
- }
- element.data({
- type: 'splitButton',
- splitButton: this,
- kendoPopup: this.popup
- });
- },
- _navigatable: function () {
- var that = this;
- that.popupElement.on('keydown', '.' + BUTTON, function (e) {
- var li = $(e.target).parent();
- e.preventDefault();
- if (e.keyCode === keys.ESC || e.keyCode === keys.TAB || e.altKey && e.keyCode === keys.UP) {
- that.toggle();
- that.focus();
- } else if (e.keyCode === keys.DOWN) {
- findFocusableSibling(li, 'next').focus();
- } else if (e.keyCode === keys.UP) {
- findFocusableSibling(li, 'prev').focus();
- } else if (e.keyCode === keys.SPACEBAR || e.keyCode === keys.ENTER) {
- that.toolbar.userEvents.trigger('tap', { target: $(e.target) });
- } else if (e.keyCode === keys.HOME) {
- li.parent().find(':kendoFocusable').first().focus();
- } else if (e.keyCode === keys.END) {
- li.parent().find(':kendoFocusable').last().focus();
- }
- });
- },
- createMenuButtons: function () {
- var options = this.options;
- var items = options.menuButtons;
- var item;
- for (var i = 0; i < items.length; i++) {
- item = new ToolBarButton($.extend({
- mobile: options.mobile,
- type: 'button',
- click: options.click
- }, items[i]), this.toolbar);
- item.element.wrap('
').parent().appendTo(this.popupElement);
- }
- },
- createPopup: function () {
- var that = this;
- var options = this.options;
- var element = this.element;
- this.popupElement.attr('id', options.id + OPTION_LIST_SUFFIX).attr(KENDO_UID_ATTR, options.rootUid);
- if (options.mobile) {
- this.popupElement = actionSheetWrap(this.popupElement);
- }
- this.popup = this.popupElement.kendoPopup({
- appendTo: options.mobile ? $(options.mobile).children('.km-pane') : null,
- anchor: element,
- isRtl: this.toolbar._isRtl,
- copyAnchorStyles: false,
- animation: options.animation,
- open: function (e) {
- var isDefaultPrevented = that.toolbar.trigger(OPEN, { target: element });
- if (isDefaultPrevented) {
- e.preventDefault();
- return;
- }
- that.adjustPopupWidth(e.sender);
- },
- activate: function () {
- this.element.find(':kendoFocusable').first().focus();
- },
- close: function (e) {
- var isDefaultPrevented = that.toolbar.trigger(CLOSE, { target: element });
- if (isDefaultPrevented) {
- e.preventDefault();
- }
- element.focus();
- }
- }).data('kendoPopup');
- this.popup.element.on(CLICK, 'a.k-button', preventClick);
- },
- adjustPopupWidth: function (popup) {
- var anchor = popup.options.anchor, computedWidth = outerWidth(anchor), width;
- kendo.wrap(popup.element).addClass('k-split-wrapper');
- if (popup.element.css('box-sizing') !== 'border-box') {
- width = computedWidth - (outerWidth(popup.element) - popup.element.width());
- } else {
- width = computedWidth;
- }
- popup.element.css({
- fontFamily: anchor.css('font-family'),
- 'min-width': width
- });
- },
- remove: function () {
- this.popup.element.off(CLICK, 'a.k-button');
- this.popup.destroy();
- this.element.remove();
- },
- toggle: function () {
- if (this.options.enable || this.popup.visible()) {
- this.popup.toggle();
- }
- },
- enable: function (isEnabled) {
- if (isEnabled === undefined) {
- isEnabled = true;
- }
- this.mainButton.enable(isEnabled);
- this.element.toggleClass(STATE_DISABLED, !isEnabled);
- this.options.enable = isEnabled;
- },
- focus: function () {
- this.element.focus();
- },
- hide: function () {
- if (this.popup) {
- this.popup.close();
- }
- this.element.addClass(STATE_HIDDEN).hide();
- this.options.hidden = true;
- },
- show: function () {
- this.element.removeClass(STATE_HIDDEN).hide();
- this.options.hidden = false;
- }
- });
- kendo.toolbar.ToolBarSplitButton = ToolBarSplitButton;
- var OverflowSplitButton = Item.extend({
- init: function (options, toolbar) {
- var element = this.element = $('
'), items = options.menuButtons, item, splitContainerId;
- this.options = options;
- this.toolbar = toolbar;
- this.overflow = true;
- splitContainerId = (options.id || options.uid) + OPTION_LIST_SUFFIX;
- this.mainButton = new OverflowButton($.extend({}, options));
- this.mainButton.element.appendTo(element);
- for (var i = 0; i < items.length; i++) {
- item = new OverflowButton($.extend({
- mobile: options.mobile,
- type: 'button',
- splitContainerId: splitContainerId
- }, items[i]), this.toolbar);
- item.element.appendTo(element);
- }
- this.addUidAttr();
- this.addOverflowAttr();
- this.mainButton.main = true;
- element.data({
- type: 'splitButton',
- splitButton: this
- });
- },
- overflowHidden: function () {
- this.element.addClass(OVERFLOW_HIDDEN);
- }
- });
- kendo.toolbar.OverflowSplitButton = OverflowSplitButton;
- kendo.toolbar.registerComponent('splitButton', ToolBarSplitButton, OverflowSplitButton);
- var ToolBarSeparator = Item.extend({
- init: function (options, toolbar) {
- var element = this.element = $('
');
- this.element = element;
- this.options = options;
- this.toolbar = toolbar;
- this.attributes();
- this.addIdAttr();
- this.addUidAttr();
- this.addOverflowAttr();
- element.addClass(SEPARATOR);
- element.data({
- type: 'separator',
- separator: this
- });
- }
- });
- var OverflowSeparator = Item.extend({
- init: function (options, toolbar) {
- var element = this.element = $('
');
- this.element = element;
- this.options = options;
- this.toolbar = toolbar;
- this.overflow = true;
- this.attributes();
- this.addUidAttr();
- this.addOverflowIdAttr();
- element.addClass(SEPARATOR);
- element.data({
- type: 'separator',
- separator: this
- });
- },
- overflowHidden: function () {
- this.element.addClass(OVERFLOW_HIDDEN);
- }
- });
- kendo.toolbar.registerComponent('separator', ToolBarSeparator, OverflowSeparator);
- var TemplateItem = Item.extend({
- init: function (template, options, toolbar) {
- var element = isFunction(template) ? template(options) : template;
- if (!(element instanceof jQuery)) {
- element = $('
').html(element);
- } else {
- element = element.wrap('
').parent();
- }
- this.element = element;
- this.options = options;
- this.options.type = 'template';
- this.toolbar = toolbar;
- this.attributes();
- this.addUidAttr();
- this.addIdAttr();
- this.addOverflowAttr();
- element.data({
- type: 'template',
- template: this
- });
- }
- });
- kendo.toolbar.TemplateItem = TemplateItem;
- var OverflowTemplateItem = Item.extend({
- init: function (template, options, toolbar) {
- var element = isFunction(template) ? $(template(options)) : $(template);
- if (!(element instanceof jQuery)) {
- element = $('
').html(element);
- } else {
- element = element.wrap('
').parent();
- }
- this.element = element;
- this.options = options;
- this.options.type = 'template';
- this.toolbar = toolbar;
- this.overflow = true;
- this.attributes();
- this.addUidAttr();
- this.addOverflowIdAttr();
- this.addOverflowAttr();
- element.data({
- type: 'template',
- template: this
- });
- },
- overflowHidden: function () {
- this.element.addClass(OVERFLOW_HIDDEN);
- }
- });
- kendo.toolbar.OverflowTemplateItem = OverflowTemplateItem;
- function toggleActive(e) {
- if (!e.target.is('.k-toggle-button')) {
- e.target.toggleClass(STATE_ACTIVE, e.type == 'press');
- }
- }
- function actionSheetWrap(element) {
- element = $(element);
- return element.hasClass('km-actionsheet') ? element.closest('.km-popup-wrapper') : element.addClass('km-widget km-actionsheet').wrap('').parent().wrap('').parent();
- }
- function preventClick(e) {
- if ($(e.target).closest('a.k-button').length) {
- e.preventDefault();
- }
- }
- function findFocusableSibling(element, dir) {
- var getSibling = dir === 'next' ? $.fn.next : $.fn.prev;
- var getter = dir === 'next' ? $.fn.first : $.fn.last;
- var candidate = getSibling.call(element);
- if (!candidate.length && element.is('.' + OVERFLOW_ANCHOR)) {
- return element;
- }
- if (candidate.is(':kendoFocusable') || !candidate.length) {
- return candidate;
- }
- if (candidate.find(':kendoFocusable').length) {
- return getter.call(candidate.find(':kendoFocusable'));
- }
- return findFocusableSibling(candidate, dir);
- }
- var Group = Class.extend({
- init: function (name) {
- this.name = name;
- this.buttons = [];
- },
- add: function (button) {
- this.buttons[this.buttons.length] = button;
- },
- remove: function (button) {
- var index = $.inArray(button, this.buttons);
- this.buttons.splice(index, 1);
- },
- select: function (button) {
- var tmp;
- for (var i = 0; i < this.buttons.length; i++) {
- tmp = this.buttons[i];
- tmp.select(false);
- }
- button.select(true);
- if (button.twin()) {
- button.twin().select(true);
- }
- }
- });
- var ToolBar = Widget.extend({
- init: function (element, options) {
- var that = this;
- Widget.fn.init.call(that, element, options);
- options = that.options;
- element = that.wrapper = that.element;
- element.addClass(TOOLBAR + ' k-widget');
- this.uid = kendo.guid();
- this._isRtl = kendo.support.isRtl(element);
- this._groups = {};
- element.attr(KENDO_UID_ATTR, this.uid);
- that.isMobile = typeof options.mobile === 'boolean' ? options.mobile : that.element.closest('.km-root')[0];
- that.animation = that.isMobile ? { open: { effects: 'fade' } } : {};
- if (that.isMobile) {
- element.addClass('km-widget');
- ICON = 'km-icon';
- ICON_PREFIX = 'km-';
- BUTTON = 'km-button';
- BUTTON_GROUP = 'km-buttongroup';
- STATE_ACTIVE = 'km-state-active';
- STATE_DISABLED = 'km-state-disabled';
- }
- if (options.resizable) {
- that._renderOverflow();
- element.addClass(RESIZABLE_TOOLBAR);
- that.overflowUserEvents = new kendo.UserEvents(that.element, {
- threshold: 5,
- allowSelection: true,
- filter: '.' + OVERFLOW_ANCHOR,
- tap: proxy(that._toggleOverflow, that)
- });
- that._resizeHandler = kendo.onResize(function () {
- that.resize();
- });
- } else {
- that.popup = { element: $([]) };
- }
- if (options.items && options.items.length) {
- for (var i = 0; i < options.items.length; i++) {
- that.add(options.items[i]);
- }
- if (options.resizable) {
- that._shrink(that.element.innerWidth());
- }
- }
- that.userEvents = new kendo.UserEvents(document, {
- threshold: 5,
- allowSelection: true,
- filter: '[' + KENDO_UID_ATTR + '=' + this.uid + '] a.' + BUTTON + ', ' + '[' + KENDO_UID_ATTR + '=' + this.uid + '] .' + OVERFLOW_BUTTON,
- tap: proxy(that._buttonClick, that),
- press: toggleActive,
- release: toggleActive
- });
- that.element.on(CLICK, 'a.k-button', preventClick);
- that._navigatable();
- if (options.resizable) {
- that.popup.element.on(CLICK, +'a.k-button', preventClick);
- }
- if (options.resizable) {
- this._toggleOverflowAnchor();
- }
- kendo.notify(that);
- },
- events: [
- CLICK,
- TOGGLE,
- OPEN,
- CLOSE,
- OVERFLOW_OPEN,
- OVERFLOW_CLOSE
- ],
- options: {
- name: 'ToolBar',
- items: [],
- resizable: true,
- mobile: null
- },
- addToGroup: function (button, groupName) {
- var group;
- if (!this._groups[groupName]) {
- group = this._groups[groupName] = new Group();
- } else {
- group = this._groups[groupName];
- }
- group.add(button);
- return group;
- },
- destroy: function () {
- var that = this;
- that.element.find('.' + SPLIT_BUTTON).each(function (idx, element) {
- $(element).data('kendoPopup').destroy();
- });
- that.element.off(CLICK, 'a.k-button');
- that.userEvents.destroy();
- if (that.options.resizable) {
- kendo.unbindResize(that._resizeHandler);
- that.overflowUserEvents.destroy();
- that.popup.element.off(CLICK, 'a.k-button');
- that.popup.destroy();
- }
- Widget.fn.destroy.call(that);
- },
- add: function (options) {
- var component = components[options.type], template = options.template, tool, that = this, itemClasses = that.isMobile ? '' : 'k-item k-state-default', overflowTemplate = options.overflowTemplate, overflowTool;
- $.extend(options, {
- uid: kendo.guid(),
- animation: that.animation,
- mobile: that.isMobile,
- rootUid: that.uid
- });
- if (options.menuButtons) {
- for (var i = 0; i < options.menuButtons.length; i++) {
- $.extend(options.menuButtons[i], { uid: kendo.guid() });
- }
- }
- if (template && !overflowTemplate) {
- options.overflow = OVERFLOW_NEVER;
- } else if (!options.overflow) {
- options.overflow = OVERFLOW_AUTO;
- }
- if (options.overflow !== OVERFLOW_NEVER && that.options.resizable) {
- if (overflowTemplate) {
- overflowTool = new OverflowTemplateItem(overflowTemplate, options, that);
- } else if (component) {
- overflowTool = new component.overflow(options, that);
- overflowTool.element.addClass(itemClasses);
- }
- if (overflowTool) {
- if (options.overflow === OVERFLOW_AUTO) {
- overflowTool.overflowHidden();
- }
- overflowTool.element.appendTo(that.popup.container);
- that.angular('compile', function () {
- return { elements: overflowTool.element.get() };
- });
- }
- }
- if (options.overflow !== OVERFLOW_ALWAYS) {
- if (template) {
- tool = new TemplateItem(template, options, that);
- } else if (component) {
- tool = new component.toolbar(options, that);
- }
- if (tool) {
- tool.element.appendTo(that.element);
- that.angular('compile', function () {
- return { elements: tool.element.get() };
- });
- }
- }
- },
- _getItem: function (candidate) {
- var element, toolbarItem, overflowItem, isResizable = this.options.resizable, type;
- element = this.element.find(candidate);
- if (!element.length) {
- element = $('.k-split-container[data-uid=' + this.uid + ']').find(candidate);
- }
- type = element.length ? element.data('type') : '';
- toolbarItem = element.data(type);
- if (toolbarItem) {
- if (toolbarItem.main) {
- element = element.parent('.' + SPLIT_BUTTON);
- type = 'splitButton';
- toolbarItem = element.data(type);
- }
- if (isResizable) {
- overflowItem = toolbarItem.twin();
- }
- } else if (isResizable) {
- element = this.popup.element.find(candidate);
- type = element.length ? element.data('type') : '';
- overflowItem = element.data(type);
- if (overflowItem && overflowItem.main) {
- element = element.parent('.' + SPLIT_BUTTON);
- type = 'splitButton';
- overflowItem = element.data(type);
- }
- }
- return {
- type: type,
- toolbar: toolbarItem,
- overflow: overflowItem
- };
- },
- remove: function (candidate) {
- var item = this._getItem(candidate);
- if (item.toolbar) {
- item.toolbar.remove();
- }
- if (item.overflow) {
- item.overflow.remove();
- }
- this.resize(true);
- },
- hide: function (candidate) {
- var item = this._getItem(candidate);
- var buttonGroupInstance;
- if (item.toolbar) {
- if (item.toolbar.options.type === 'button' && item.toolbar.options.isChild) {
- buttonGroupInstance = item.toolbar.getParentGroup();
- item.toolbar.hide();
- if (buttonGroupInstance) {
- buttonGroupInstance.refresh();
- }
- } else if (!item.toolbar.options.hidden) {
- item.toolbar.hide();
- }
- }
- if (item.overflow) {
- if (item.overflow.options.type === 'button' && item.overflow.options.isChild) {
- buttonGroupInstance = item.overflow.getParentGroup();
- item.overflow.hide();
- if (buttonGroupInstance) {
- buttonGroupInstance.refresh();
- }
- } else if (!item.overflow.options.hidden) {
- item.overflow.hide();
- }
- }
- this.resize(true);
- },
- show: function (candidate) {
- var item = this._getItem(candidate);
- if (item.toolbar) {
- if (item.toolbar.options.type === 'button' && item.toolbar.options.isChild) {
- item.toolbar.show();
- item.toolbar.getParentGroup().refresh();
- } else if (item.toolbar.options.hidden) {
- item.toolbar.show();
- }
- }
- if (item.overflow) {
- if (item.overflow.options.type === 'button' && item.overflow.options.isChild) {
- item.toolbar.show();
- item.overflow.getParentGroup().refresh();
- } else if (item.overflow.options.hidden) {
- item.overflow.show();
- }
- }
- this.resize(true);
- },
- enable: function (element, enable) {
- var item = this._getItem(element);
- if (typeof enable == 'undefined') {
- enable = true;
- }
- if (item.toolbar) {
- item.toolbar.enable(enable);
- }
- if (item.overflow) {
- item.overflow.enable(enable);
- }
- },
- getSelectedFromGroup: function (groupName) {
- return this.element.find('.' + TOGGLE_BUTTON + '[data-group=\'' + groupName + '\']').filter('.' + STATE_ACTIVE);
- },
- toggle: function (button, checked) {
- var element = $(button), item = element.data('button');
- if (item.options.togglable) {
- if (checked === undefined) {
- checked = true;
- }
- item.toggle(checked, true);
- }
- },
- _renderOverflow: function () {
- var that = this, overflowContainer = components.overflowContainer, isRtl = that._isRtl, horizontalDirection = isRtl ? 'left' : 'right';
- that.overflowAnchor = $(components.overflowAnchor).addClass(BUTTON);
- that.element.append(that.overflowAnchor);
- if (that.isMobile) {
- that.overflowAnchor.append('
');
- overflowContainer = actionSheetWrap(overflowContainer);
- } else {
- that.overflowAnchor.append('
');
- }
- that.popup = new kendo.ui.Popup(overflowContainer, {
- origin: 'bottom ' + horizontalDirection,
- position: 'top ' + horizontalDirection,
- anchor: that.overflowAnchor,
- isRtl: isRtl,
- animation: that.animation,
- appendTo: that.isMobile ? $(that.isMobile).children('.km-pane') : null,
- copyAnchorStyles: false,
- open: function (e) {
- var wrapper = kendo.wrap(that.popup.element).addClass('k-overflow-wrapper');
- if (!that.isMobile) {
- wrapper.css('margin-left', (isRtl ? -1 : 1) * ((outerWidth(wrapper) - wrapper.width()) / 2 + 1));
- } else {
- that.popup.container.css('max-height', parseFloat($('.km-content:visible').innerHeight()) - 15 + 'px');
- }
- if (that.trigger(OVERFLOW_OPEN)) {
- e.preventDefault();
- }
- },
- activate: function () {
- this.element.find(':kendoFocusable').first().focus();
- },
- close: function (e) {
- if (that.trigger(OVERFLOW_CLOSE)) {
- e.preventDefault();
- }
- this.element.focus();
- }
- });
- that.popup.element.on('keydown', '.' + BUTTON, function (e) {
- var target = $(e.target), li = target.parent(), isComplexTool = li.is('.' + BUTTON_GROUP) || li.is('.' + SPLIT_BUTTON), element;
- e.preventDefault();
- if (e.keyCode === keys.ESC || e.keyCode === keys.TAB || e.altKey && e.keyCode === keys.UP) {
- that._toggleOverflow();
- that.overflowAnchor.focus();
- } else if (e.keyCode === keys.DOWN) {
- element = !isComplexTool || isComplexTool && target.is(':last-child') ? li : target;
- findFocusableSibling(element, 'next').focus();
- } else if (e.keyCode === keys.UP) {
- element = !isComplexTool || isComplexTool && target.is(':first-child') ? li : target;
- findFocusableSibling(element, 'prev').focus();
- } else if (e.keyCode === keys.SPACEBAR || e.keyCode === keys.ENTER) {
- that.userEvents.trigger('tap', { target: $(e.target) });
- that.overflowAnchor.focus();
- } else if (e.keyCode === keys.HOME) {
- li.parent().find(':kendoFocusable').first().focus();
- } else if (e.keyCode === keys.END) {
- li.parent().find(':kendoFocusable').last().focus();
- }
- });
- if (that.isMobile) {
- that.popup.container = that.popup.element.find('.' + OVERFLOW_CONTAINER);
- } else {
- that.popup.container = that.popup.element;
- }
- that.popup.container.attr(KENDO_UID_ATTR, this.uid);
- },
- _toggleOverflowAnchor: function () {
- var hasVisibleChildren = false;
- if (this.options.mobile) {
- hasVisibleChildren = this.popup.element.find('.' + OVERFLOW_CONTAINER).children(':not(.' + OVERFLOW_HIDDEN + ', .' + POPUP + ')').length > 0;
- } else {
- hasVisibleChildren = this.popup.element.children(':not(.' + OVERFLOW_HIDDEN + ', .' + POPUP + ')').length > 0;
- }
- if (hasVisibleChildren) {
- this.overflowAnchor.css({
- visibility: 'visible',
- width: ''
- });
- } else {
- this.overflowAnchor.css({
- visibility: 'hidden',
- width: '1px'
- });
- }
- },
- _buttonClick: function (e) {
- var that = this, popup, target, item, splitContainer, isSplitButtonArrow = e.target.closest('.' + SPLIT_BUTTON_ARROW).length, handler, eventData, urlTarget;
- e.preventDefault();
- if (isSplitButtonArrow) {
- that._toggle(e);
- return;
- }
- target = $(e.target).closest('.' + BUTTON, that.element);
- if (target.hasClass(OVERFLOW_ANCHOR)) {
- return;
- }
- item = target.data('button');
- if (!item && that.popup) {
- target = $(e.target).closest('.' + OVERFLOW_BUTTON, that.popup.container);
- item = target.parent('li').data('button');
- }
- if (!item || !item.options.enable) {
- return;
- }
- if (item.options.togglable) {
- handler = isFunction(item.toggleHandler) ? item.toggleHandler : null;
- item.toggle(!item.options.selected, true);
- eventData = {
- target: target,
- group: item.options.group,
- checked: item.options.selected,
- id: item.options.id,
- item: item
- };
- if (handler) {
- handler.call(that, eventData);
- }
- that.trigger(TOGGLE, eventData);
- } else {
- handler = isFunction(item.clickHandler) ? item.clickHandler : null;
- eventData = {
- sender: that,
- target: target,
- id: item.options.id,
- item: item
- };
- if (handler) {
- handler.call(that, eventData);
- }
- that.trigger(CLICK, eventData);
- }
- if (item.options.url) {
- if (item.options.attributes && item.options.attributes.target) {
- urlTarget = item.options.attributes.target;
- }
- window.open(item.options.url, urlTarget || '_self');
- }
- if (target.hasClass(OVERFLOW_BUTTON)) {
- that.popup.close();
- }
- splitContainer = target.closest('.k-split-container');
- if (splitContainer[0]) {
- popup = splitContainer.data('kendoPopup');
- (popup ? popup : splitContainer.parents('.km-popup-wrapper').data('kendoPopup')).close();
- }
- },
- _navigatable: function () {
- var that = this;
- that.element.attr('tabindex', 0).on('focusin', function (ev) {
- var target = $(ev.target);
- var element = $(this).find(':kendoFocusable:first');
- if (!target.is('.' + TOOLBAR) || element.length === 0) {
- return;
- }
- if (element.is('.' + OVERFLOW_ANCHOR)) {
- element = findFocusableSibling(element, 'next');
- }
- if (element.length) {
- element[0].focus();
- }
- }).on('keydown', proxy(that._keydown, that));
- },
- _keydown: function (e) {
- var target = $(e.target), keyCode = e.keyCode, items = this.element.children(':not(.k-separator):visible'), direction = this._isRtl ? -1 : 1;
- if (keyCode === keys.TAB) {
- var element = target.parentsUntil(this.element).last(), lastHasFocus = false, firstHasFocus = false, isOnlyOverflowAnchor = false;
- if (!items.not('.' + OVERFLOW_ANCHOR).length) {
- isOnlyOverflowAnchor = true;
- }
- if (!element.length) {
- element = target;
- }
- if (element.is('.' + OVERFLOW_ANCHOR) && !isOnlyOverflowAnchor) {
- var lastItemNotOverflowAnchor = items.last();
- if (e.shiftKey) {
- e.preventDefault();
- }
- if (lastItemNotOverflowAnchor.is(':kendoFocusable')) {
- items.last().focus();
- } else {
- items.last().find(':kendoFocusable').last().focus();
- }
- }
- if (!e.shiftKey && items.index(element) === items.length - 1) {
- if (element.is('.' + BUTTON_GROUP)) {
- lastHasFocus = target.is(':last-child');
- } else {
- lastHasFocus = true;
- }
- }
- var isFirstTool = items.index(element) === items.not('.k-overflow-anchor').first().index();
- if (e.shiftKey && isFirstTool) {
- if (element.is('.' + BUTTON_GROUP)) {
- firstHasFocus = target.is(':first-child');
- } else {
- firstHasFocus = true;
- }
- }
- if (lastHasFocus && this.overflowAnchor && this.overflowAnchor.css('visibility') !== 'hidden' && !isOnlyOverflowAnchor) {
- e.preventDefault();
- this.overflowAnchor.focus();
- }
- if (firstHasFocus || isOnlyOverflowAnchor && e.shiftKey) {
- e.preventDefault();
- var prevFocusable = this._getPrevFocusable(this.wrapper);
- if (prevFocusable) {
- prevFocusable.focus();
- }
- }
- this._preventNextFocus = false;
- }
- if (e.altKey && keyCode === keys.DOWN) {
- var splitButton = $(document.activeElement).data('splitButton');
- var isOverflowAnchor = $(document.activeElement).is('.' + OVERFLOW_ANCHOR);
- if (splitButton) {
- splitButton.toggle();
- } else if (isOverflowAnchor) {
- this._toggleOverflow();
- }
- return;
- }
- if ((keyCode === keys.SPACEBAR || keyCode === keys.ENTER) && !target.is('input, checkbox')) {
- if (keyCode === keys.SPACEBAR) {
- e.preventDefault();
- }
- if (target.is('.' + SPLIT_BUTTON)) {
- target = target.children().first();
- this.userEvents.trigger('tap', { target: target });
- } else if (keyCode === keys.SPACEBAR) {
- this.userEvents.trigger('tap', { target: target });
- }
- return;
- }
- if (keyCode === keys.HOME) {
- if (target.is('.k-dropdown') || target.is('input')) {
- return;
- }
- if (this.overflowAnchor) {
- items.eq(1).focus();
- } else {
- items.first().focus();
- }
- e.preventDefault();
- } else if (keyCode === keys.END) {
- if (target.is('.k-dropdown') || target.is('input')) {
- return;
- }
- if (this.overflowAnchor && $(this.overflowAnchor).css('visibility') != 'hidden') {
- this.overflowAnchor.focus();
- } else {
- items.last().focus();
- }
- e.preventDefault();
- } else if (keyCode === keys.RIGHT && !this._preventNextFocus && !target.is('input, select, .k-dropdown, .k-colorpicker') && this._getNextElement(e.target, 1 * direction)) {
- this._getNextElement(e.target, 1 * direction).focus();
- e.preventDefault();
- } else if (keyCode === keys.LEFT && !this._preventNextFocus && !target.is('input, select, .k-dropdown, .k-colorpicker') && this._getNextElement(e.target, -1 * direction)) {
- this._getNextElement(e.target, -1 * direction).focus();
- e.preventDefault();
- }
- },
- _getNextElement: function (item, direction) {
- var items = this.element.children(':not(.k-separator):visible');
- var itemIndex = items.index(item) === -1 ? items.index(item.parentElement) : items.index(item);
- var startIndex = this.overflowAnchor ? 1 : 0;
- var directionNumber = direction;
- var searchIndex = direction === 1 ? items.length - 1 : startIndex;
- var index = direction === 1 ? startIndex : items.length - 1;
- var focusableItem = items[itemIndex + direction];
- this._preventNextFocus = false;
- if ($(item).closest('.' + BUTTON_GROUP).length && !$(item).is(direction === 1 ? ':last-child' : ':first-child')) {
- return $(item).closest('.' + BUTTON_GROUP).children()[$(item).closest('.' + BUTTON_GROUP).children().index(item) + direction];
- }
- if (this.overflowAnchor && item === this.overflowAnchor[0] && direction === -1) {
- focusableItem = items[items.length - 1];
- }
- if (itemIndex === searchIndex) {
- focusableItem = !this.overflowAnchor || this.overflowAnchor && $(this.overflowAnchor).css('visibility') === 'hidden' ? items[index] : this.overflowAnchor;
- }
- while (!$(focusableItem).is(':kendoFocusable')) {
- if (direction === -1 && $(focusableItem).closest('.' + BUTTON_GROUP).length) {
- focusableItem = $(focusableItem).children(':not(label, div)').last();
- } else {
- focusableItem = $(focusableItem).children(':not(label, div)').first();
- }
- if (!focusableItem.length) {
- directionNumber = directionNumber + direction;
- focusableItem = items[itemIndex + directionNumber];
- if (!focusableItem) {
- return this.overflowAnchor;
- }
- }
- this._preventNextFocus = $(focusableItem).closest('.' + BUTTON_GROUP).length ? false : true;
- }
- return focusableItem;
- },
- _getPrevFocusable: function (element) {
- if (element.is('html')) {
- return element;
- }
- var elementToFocus, prevElement, prevElements = element.prevAll();
- prevElements.each(function () {
- prevElement = $(this);
- if (prevElement.is(':kendoFocusable')) {
- elementToFocus = prevElement;
- return false;
- } else if (prevElement.find(':kendoFocusable').length > 0) {
- elementToFocus = prevElement.find(':kendoFocusable').last();
- return false;
- }
- });
- if (elementToFocus) {
- return elementToFocus;
- } else {
- return this._getPrevFocusable(element.parent());
- }
- },
- _toggle: function (e) {
- var splitButton = $(e.target).closest('.' + SPLIT_BUTTON).data('splitButton');
- e.preventDefault();
- if (!splitButton.options.enable) {
- return;
- }
- splitButton.toggle();
- },
- _toggleOverflow: function () {
- this.popup.toggle();
- },
- _resize: function (e) {
- var containerWidth = e.width;
- if (!this.options.resizable) {
- return;
- }
- this.popup.close();
- this._shrink(containerWidth);
- this._stretch(containerWidth);
- this._markVisibles();
- this._toggleOverflowAnchor();
- },
- _childrenWidth: function () {
- var childrenWidth = 0;
- this.element.children(':visible:not(\'.' + STATE_HIDDEN + '\')').each(function () {
- childrenWidth += outerWidth($(this), true);
- });
- return Math.ceil(childrenWidth);
- },
- _shrink: function (containerWidth) {
- var commandElement, visibleCommands;
- if (containerWidth < this._childrenWidth()) {
- visibleCommands = this.element.children(':visible:not([data-overflow=\'never\'], .' + OVERFLOW_ANCHOR + ')');
- for (var i = visibleCommands.length - 1; i >= 0; i--) {
- commandElement = visibleCommands.eq(i);
- if (containerWidth > this._childrenWidth()) {
- break;
- } else {
- this._hideItem(commandElement);
- }
- }
- }
- },
- _stretch: function (containerWidth) {
- var commandElement, hiddenCommands;
- if (containerWidth > this._childrenWidth()) {
- hiddenCommands = this.element.children(':hidden:not(\'.' + STATE_HIDDEN + '\')');
- for (var i = 0; i < hiddenCommands.length; i++) {
- commandElement = hiddenCommands.eq(i);
- if (containerWidth < this._childrenWidth() || !this._showItem(commandElement, containerWidth)) {
- break;
- }
- }
- }
- },
- _hideItem: function (item) {
- item.hide();
- if (this.popup) {
- this.popup.container.find('>li[data-uid=\'' + item.data('uid') + '\']').removeClass(OVERFLOW_HIDDEN);
- }
- },
- _showItem: function (item, containerWidth) {
- if (item.length && containerWidth > this._childrenWidth() + outerWidth(item, true)) {
- item.show();
- if (this.popup) {
- this.popup.container.find('>li[data-uid=\'' + item.data('uid') + '\']').addClass(OVERFLOW_HIDDEN);
- }
- return true;
- }
- return false;
- },
- _markVisibles: function () {
- var overflowItems = this.popup.container.children(), toolbarItems = this.element.children(':not(.k-overflow-anchor)'), visibleOverflowItems = overflowItems.filter(':not(.k-overflow-hidden)'), visibleToolbarItems = toolbarItems.filter(':visible');
- overflowItems.add(toolbarItems).removeClass(FIRST_TOOLBAR_VISIBLE + ' ' + LAST_TOOLBAR_VISIBLE);
- visibleOverflowItems.first().add(visibleToolbarItems.first()).addClass(FIRST_TOOLBAR_VISIBLE);
- visibleOverflowItems.last().add(visibleToolbarItems.last()).addClass(LAST_TOOLBAR_VISIBLE);
- }
- });
- kendo.ui.plugin(ToolBar);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.panelbar', ['kendo.data'], f);
-}(function () {
- var __meta__ = {
- id: 'panelbar',
- name: 'PanelBar',
- category: 'web',
- description: 'The PanelBar widget displays hierarchical data as a multi-level expandable panel bar.',
- depends: [
- 'core',
- 'data',
- 'data.odata'
- ]
- };
- (function ($, undefined) {
- var kendo = window.kendo, ui = kendo.ui, keys = kendo.keys, extend = $.extend, proxy = $.proxy, each = $.each, isArray = $.isArray, template = kendo.template, Widget = ui.Widget, HierarchicalDataSource = kendo.data.HierarchicalDataSource, excludedNodesRegExp = /^(ul|a|div)$/i, NS = '.kendoPanelBar', IMG = 'img', HREF = 'href', LAST = 'k-last', LINK = 'k-link', LINKSELECTOR = '.' + LINK, ERROR = 'error', ITEM = '.k-item', GROUP = '.k-group', VISIBLEGROUP = GROUP + ':visible', IMAGE = 'k-image', FIRST = 'k-first', CHANGE = 'change', EXPAND = 'expand', SELECT = 'select', CONTENT = 'k-content', ACTIVATE = 'activate', COLLAPSE = 'collapse', DATABOUND = 'dataBound', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', CONTENTLOAD = 'contentLoad', UNDEFINED = 'undefined', ACTIVECLASS = 'k-state-active', GROUPS = '> .k-panel', CONTENTS = '> .k-content', STRING = 'string', FOCUSEDCLASS = 'k-state-focused', DISABLEDCLASS = 'k-state-disabled', SELECTEDCLASS = 'k-state-selected', SELECTEDSELECTOR = '.' + SELECTEDCLASS, HIGHLIGHTCLASS = 'k-state-highlight', ACTIVEITEMSELECTOR = ITEM + ':not(.k-state-disabled)', clickableItems = '> ' + ACTIVEITEMSELECTOR + ' > ' + LINKSELECTOR + ', .k-panel > ' + ACTIVEITEMSELECTOR + ' > ' + LINKSELECTOR, disabledItems = ITEM + '.k-state-disabled > .k-link', selectableItems = '> li > ' + SELECTEDSELECTOR + ', .k-panel > li > ' + SELECTEDSELECTOR, defaultState = 'k-state-default', ARIA_DISABLED = 'aria-disabled', ARIA_EXPANDED = 'aria-expanded', ARIA_HIDDEN = 'aria-hidden', ARIA_SELECTED = 'aria-selected', VISIBLE = ':visible', EMPTY = ':empty', SINGLE = 'single', bindings = {
- text: 'dataTextField',
- url: 'dataUrlField',
- spriteCssClass: 'dataSpriteCssClassField',
- imageUrl: 'dataImageUrlField'
- }, itemIcon, rendering = {
- aria: function (item) {
- var attr = '';
- if (item.items || item.content || item.contentUrl || item.expanded) {
- attr += ARIA_EXPANDED + '=\'' + (item.expanded ? 'true' : 'false') + '\' ';
- }
- if (item.enabled === false) {
- attr += ARIA_DISABLED + '=\'true\'';
- }
- return attr;
- },
- wrapperCssClass: function (group, item) {
- var result = 'k-item', index = item.index;
- if (item.enabled === false) {
- result += ' ' + DISABLEDCLASS;
- } else if (item.expanded === true) {
- result += ' ' + ACTIVECLASS;
- } else {
- result += ' k-state-default';
- }
- if (index === 0) {
- result += ' k-first';
- }
- if (index == group.length - 1) {
- result += ' k-last';
- }
- if (item.cssClass) {
- result += ' ' + item.cssClass;
- }
- return result;
- },
- textClass: function (item, group) {
- var result = LINK;
- if (group.firstLevel) {
- result += ' k-header';
- }
- if (item.selected) {
- result += ' ' + SELECTEDCLASS;
- }
- return result;
- },
- textAttributes: function (url) {
- return url ? ' href=\'' + url + '\'' : '';
- },
- arrowClass: function (item) {
- var result = 'k-icon';
- result += item.expanded ? ' k-panelbar-collapse k-i-arrow-60-up' : ' k-panelbar-expand k-i-arrow-60-down';
- return result;
- },
- text: function (item) {
- return item.encoded === false ? item.text : kendo.htmlEncode(item.text);
- },
- groupAttributes: function (group) {
- return group.expanded !== true ? ' style=\'display:none\'' : '';
- },
- ariaHidden: function (group) {
- return group.expanded !== true;
- },
- groupCssClass: function () {
- return 'k-group k-panel';
- },
- contentAttributes: function (content) {
- return content.item.expanded !== true ? ' style=\'display:none\'' : '';
- },
- content: function (item) {
- return item.content ? item.content : item.contentUrl ? '' : ' ';
- },
- contentUrl: function (item) {
- return item.contentUrl ? 'href="' + item.contentUrl + '"' : '';
- }
- };
- function updateFirstLast(items) {
- items = $(items);
- items.filter('.k-first:not(:first-child)').removeClass(FIRST);
- items.filter('.k-last:not(:last-child)').removeClass(LAST);
- items.filter(':first-child').addClass(FIRST);
- items.filter(':last-child').addClass(LAST);
- }
- function updateItemHtml(item) {
- var wrapper = item, group = item.children('ul'), toggleButton = wrapper.children('.k-link').children('.k-icon');
- if (item.hasClass('k-panelbar')) {
- return;
- }
- if (!toggleButton.length && group.length) {
- toggleButton = $('
').appendTo(wrapper);
- } else if (!group.length || !group.children().length) {
- toggleButton.remove();
- group.remove();
- }
- }
- itemIcon = function (item) {
- return item.children('span').children('.k-icon');
- };
- var PanelBar = kendo.ui.DataBoundWidget.extend({
- init: function (element, options) {
- var that = this, content, hasDataSource;
- if (isArray(options)) {
- options = { dataSource: options };
- }
- hasDataSource = options && !!options.dataSource;
- Widget.fn.init.call(that, element, options);
- element = that.wrapper = that.element.addClass('k-widget k-reset k-header k-panelbar');
- options = that.options;
- if (element[0].id) {
- that._itemId = element[0].id + '_pb_active';
- }
- that._tabindex();
- that._accessors();
- that._dataSource();
- that._templates();
- that._initData(hasDataSource);
- that._updateClasses();
- that._animations(options);
- element.on('click' + NS, clickableItems, function (e) {
- if (that._click($(e.currentTarget))) {
- e.preventDefault();
- }
- }).on(MOUSEENTER + NS + ' ' + MOUSELEAVE + NS, clickableItems, that._toggleHover).on('click' + NS, disabledItems, false).on('click' + NS, '.k-request-retry', proxy(that._retryRequest, that)).on('keydown' + NS, $.proxy(that._keydown, that)).on('focus' + NS, function () {
- var item = that.select();
- that._current(item[0] ? item : that._first());
- }).on('blur' + NS, function () {
- that._current(null);
- }).attr('role', 'menu');
- content = element.find('li.' + ACTIVECLASS + ' > .' + CONTENT);
- if (content[0]) {
- that.expand(content.parent(), false);
- }
- if (!options.dataSource) {
- that._angularCompile();
- }
- kendo.notify(that);
- },
- events: [
- EXPAND,
- COLLAPSE,
- SELECT,
- ACTIVATE,
- CHANGE,
- ERROR,
- DATABOUND,
- CONTENTLOAD
- ],
- options: {
- name: 'PanelBar',
- dataSource: {},
- animation: {
- expand: {
- effects: 'expand:vertical',
- duration: 200
- },
- collapse: { duration: 200 }
- },
- messages: {
- loading: 'Loading...',
- requestFailed: 'Request failed.',
- retry: 'Retry'
- },
- autoBind: true,
- loadOnDemand: true,
- expandMode: 'multiple',
- template: '',
- dataTextField: null
- },
- _angularCompile: function () {
- var that = this;
- that.angular('compile', function () {
- return {
- elements: that.element.children('li'),
- data: [{ dataItem: that.options.$angular }]
- };
- });
- },
- _angularCompileElements: function (html, items) {
- var that = this;
- that.angular('compile', function () {
- return {
- elements: html,
- data: $.map(items, function (item) {
- return [{ dataItem: item }];
- })
- };
- });
- },
- _angularCleanup: function () {
- var that = this;
- that.angular('cleanup', function () {
- return { elements: that.element.children('li') };
- });
- },
- destroy: function () {
- Widget.fn.destroy.call(this);
- this.element.off(NS);
- this._angularCleanup();
- kendo.destroy(this.element);
- },
- _initData: function (hasDataSource) {
- var that = this;
- if (hasDataSource) {
- that.element.empty();
- if (that.options.autoBind) {
- that._progress(true);
- that.dataSource.fetch();
- }
- }
- },
- _templates: function () {
- var that = this, options = that.options, fieldAccessor = proxy(that._fieldAccessor, that);
- if (options.template && typeof options.template == STRING) {
- options.template = template(options.template);
- } else if (!options.template) {
- options.template = template('# var text = ' + fieldAccessor('text') + '(data.item); #' + '# if (typeof data.item.encoded != \'undefined\' && data.item.encoded === false) {#' + '#= text #' + '# } else { #' + '#: text #' + '# } #');
- }
- that.templates = {
- content: template('
#= content(item) #
'),
- group: template('
' + '#= renderItems(data) #' + '
'),
- itemWrapper: template('# var url = ' + fieldAccessor('url') + '(item); #' + '# var imageUrl = ' + fieldAccessor('imageUrl') + '(item); #' + '# var spriteCssClass = ' + fieldAccessor('spriteCssClass') + '(item); #' + '# var contentUrl = contentUrl(item); #' + '# var tag = url||contentUrl ? \'a\' : \'span\'; #' + '<#= tag # class=\'#= textClass(item, group) #\' #= contentUrl ##= textAttributes(url) #>' + '# if (imageUrl) { #' + '
' + '# } #' + '# if (spriteCssClass) { #' + '
' + '# } #' + '#= data.panelBar.options.template(data) #' + '#= arrow(data) #' + '#= tag #>'),
- item: template('
' + '#= itemWrapper(data) #' + '# if (item.items && item.items.length > 0) { #' + '#= subGroup({ items: item.items, panelBar: panelBar, group: { expanded: item.expanded } }) #' + '# } else if (item.content || item.contentUrl) { #' + '#= renderContent(data) #' + '# } #' + ''),
- loading: template('
#: data.messages.loading #
'),
- retry: template('#: data.messages.requestFailed # ' + '
'),
- arrow: template('
'),
- empty: template('')
- };
- },
- setOptions: function (options) {
- var animation = this.options.animation;
- this._animations(options);
- options.animation = extend(true, animation, options.animation);
- if ('dataSource' in options) {
- this.setDataSource(options.dataSource);
- }
- Widget.fn.setOptions.call(this, options);
- },
- expand: function (element, useAnimation) {
- var that = this, animBackup = {};
- element = this.element.find(element);
- if (that._animating && element.find('ul').is(':visible')) {
- that.one('complete', function () {
- setTimeout(function () {
- that.expand(element);
- });
- });
- return;
- }
- that._animating = true;
- useAnimation = useAnimation !== false;
- element.each(function (index, item) {
- item = $(item);
- var wrapper = element.children('.k-group,.k-content');
- if (!wrapper.length) {
- wrapper = that._addGroupElement(element);
- }
- var groups = wrapper.add(item.find(CONTENTS));
- if (!item.hasClass(DISABLEDCLASS) && groups.length > 0) {
- if (that.options.expandMode == SINGLE && that._collapseAllExpanded(item)) {
- return that;
- }
- element.find('.' + HIGHLIGHTCLASS).removeClass(HIGHLIGHTCLASS);
- item.addClass(HIGHLIGHTCLASS);
- if (!useAnimation) {
- animBackup = that.options.animation;
- that.options.animation = {
- expand: { effects: {} },
- collapse: {
- hide: true,
- effects: {}
- }
- };
- }
- if (!that._triggerEvent(EXPAND, item)) {
- that._toggleItem(item, false, false);
- }
- if (!useAnimation) {
- that.options.animation = animBackup;
- }
- }
- });
- return that;
- },
- collapse: function (element, useAnimation) {
- var that = this, animBackup = {};
- that._animating = true;
- useAnimation = useAnimation !== false;
- element = that.element.find(element);
- element.each(function (index, item) {
- item = $(item);
- var groups = item.find(GROUPS).add(item.find(CONTENTS));
- if (!item.hasClass(DISABLEDCLASS) && groups.is(VISIBLE)) {
- item.removeClass(HIGHLIGHTCLASS);
- if (!useAnimation) {
- animBackup = that.options.animation;
- that.options.animation = {
- expand: { effects: {} },
- collapse: {
- hide: true,
- effects: {}
- }
- };
- }
- if (!that._triggerEvent(COLLAPSE, item)) {
- that._toggleItem(item, true);
- }
- if (!useAnimation) {
- that.options.animation = animBackup;
- }
- }
- });
- return that;
- },
- updateArrow: function (items) {
- var that = this;
- items = $(items);
- items.children(LINKSELECTOR).children('.k-panelbar-collapse, .k-panelbar-expand').remove();
- items.filter(function () {
- var dataItem = that.dataItem(this);
- if (!dataItem) {
- return $(this).find('.k-panel').length > 0 || $(this).find('.k-content').length > 0;
- }
- return dataItem.hasChildren || dataItem.content || dataItem.contentUrl;
- }).children('.k-link:not(:has([class*=k-i-arrow]))').each(function () {
- var item = $(this), parent = item.parent();
- item.append('
');
- });
- },
- _accessors: function () {
- var that = this, options = that.options, i, field, textField, element = that.element;
- for (i in bindings) {
- field = options[bindings[i]];
- textField = element.attr(kendo.attr(i + '-field'));
- if (!field && textField) {
- field = textField;
- }
- if (!field) {
- field = i;
- }
- if (!isArray(field)) {
- field = [field];
- }
- options[bindings[i]] = field;
- }
- },
- _progress: function (item, showProgress) {
- var element = this.element;
- var loadingText = this.templates.loading({ messages: this.options.messages });
- if (arguments.length == 1) {
- showProgress = item;
- if (showProgress) {
- element.html(loadingText);
- } else {
- element.empty();
- }
- } else {
- itemIcon(item).toggleClass('k-i-loading', showProgress).removeClass('k-i-refresh');
- }
- },
- _refreshRoot: function (items) {
- var that = this;
- var parent = that.element;
- var groupData = {
- firstLevel: true,
- expanded: true,
- length: parent.children().length
- };
- this.element.empty();
- var rootItemsHtml = $.map(items, function (value, idx) {
- if (typeof value === 'string') {
- return $(value);
- } else {
- value.items = [];
- return $(that.renderItem({
- group: groupData,
- item: extend(value, { index: idx })
- }));
- }
- });
- this.element.append(rootItemsHtml);
- this._angularCompileElements(rootItemsHtml, items);
- },
- _refreshChildren: function (item, parentNode) {
- var i, children, child;
- parentNode.children('.k-group').empty();
- var items = item.children.data();
- if (!items.length) {
- updateItemHtml(parentNode);
- children = parentNode.children('.k-group').children('li');
- this._angularCompileElements(children, items);
- } else {
- this.append(item.children, parentNode);
- if (this.options.loadOnDemand) {
- this._toggleGroup(parentNode.children('.k-group'), false);
- }
- children = parentNode.children('.k-group').children('li');
- for (i = 0; i < children.length; i++) {
- child = children.eq(i);
- this.trigger('itemChange', {
- item: child,
- data: this.dataItem(child),
- ns: ui
- });
- }
- }
- },
- findByUid: function (uid) {
- var items = this.element.find('.k-item');
- var uidAttr = kendo.attr('uid');
- var result;
- for (var i = 0; i < items.length; i++) {
- if (items[i].getAttribute(uidAttr) == uid) {
- result = items[i];
- break;
- }
- }
- return $(result);
- },
- refresh: function (e) {
- var options = this.options;
- var node = e.node;
- var action = e.action;
- var items = e.items;
- var parentNode = this.wrapper;
- var loadOnDemand = options.loadOnDemand;
- if (e.field) {
- if (!items[0] || !items[0].level) {
- return;
- }
- return this._updateItems(items, e.field);
- }
- if (node) {
- parentNode = this.findByUid(node.uid);
- this._progress(parentNode, false);
- }
- if (action == 'add') {
- this._appendItems(e.index, items, parentNode);
- } else if (action == 'remove') {
- this.remove(this.findByUid(items[0].uid));
- } else if (action == 'itemchange') {
- this._updateItems(items);
- } else if (action == 'itemloaded') {
- this._refreshChildren(node, parentNode);
- } else {
- this._refreshRoot(items);
- }
- if (action != 'remove') {
- for (var k = 0; k < items.length; k++) {
- if (!loadOnDemand || items[k].expanded) {
- var tempItem = items[k];
- if (this._hasChildItems(tempItem)) {
- tempItem.load();
- }
- }
- }
- }
- this.trigger(DATABOUND, { node: node ? parentNode : undefined });
- },
- _error: function (e) {
- var node = e.node && this.findByUid(e.node.uid);
- var retryHtml = this.templates.retry({ messages: this.options.messages });
- if (node) {
- this._progress(node, false);
- this._expanded(node, false);
- itemIcon(node).addClass('k-i-refresh');
- e.node.loaded(false);
- } else {
- this._progress(false);
- this.element.html(retryHtml);
- }
- },
- _retryRequest: function (e) {
- e.preventDefault();
- this.dataSource.fetch();
- },
- items: function () {
- return this.element.find('.k-item > span:first-child');
- },
- setDataSource: function (dataSource) {
- var options = this.options;
- options.dataSource = dataSource;
- this._dataSource();
- if (this.options.autoBind) {
- this._progress(true);
- this.dataSource.fetch();
- }
- },
- _bindDataSource: function () {
- this._refreshHandler = proxy(this.refresh, this);
- this._errorHandler = proxy(this._error, this);
- this.dataSource.bind(CHANGE, this._refreshHandler);
- this.dataSource.bind(ERROR, this._errorHandler);
- },
- _unbindDataSource: function () {
- var dataSource = this.dataSource;
- if (dataSource) {
- dataSource.unbind(CHANGE, this._refreshHandler);
- dataSource.unbind(ERROR, this._errorHandler);
- }
- },
- _fieldAccessor: function (fieldName) {
- var fieldBindings = this.options[bindings[fieldName]] || [], count = fieldBindings.length, result = '(function(item) {';
- if (count === 0) {
- result += 'return item[\'' + fieldName + '\'];';
- } else {
- result += 'var levels = [' + $.map(fieldBindings, function (x) {
- return 'function(d){ return ' + kendo.expr(x) + '}';
- }).join(',') + '];';
- result += 'if(item.level){return levels[Math.min(item.level(), ' + count + '-1)](item);}else';
- result += '{return levels[' + count + '-1](item)}';
- }
- result += '})';
- return result;
- },
- _dataSource: function () {
- var that = this, options = that.options, dataSource = options.dataSource;
- if (!dataSource) {
- return;
- }
- dataSource = isArray(dataSource) ? { data: dataSource } : dataSource;
- that._unbindDataSource();
- if (!dataSource.fields) {
- dataSource.fields = [
- { field: 'text' },
- { field: 'url' },
- { field: 'spriteCssClass' },
- { field: 'imageUrl' }
- ];
- }
- that.dataSource = HierarchicalDataSource.create(dataSource);
- that._bindDataSource();
- },
- _appendItems: function (index, items, parentNode) {
- var that = this, children, wrapper;
- if (parentNode.hasClass('k-panelbar')) {
- children = parentNode.children('li');
- wrapper = parentNode;
- } else {
- wrapper = parentNode.children('.k-group');
- if (!wrapper.length) {
- wrapper = that._addGroupElement(parentNode);
- }
- children = wrapper.children('li');
- }
- var groupData = {
- firstLevel: parentNode.hasClass('k-panelbar'),
- expanded: true,
- length: children.length
- };
- var itemsHtml = $.map(items, function (value, idx) {
- if (typeof value === 'string') {
- return $(value);
- } else {
- return $(that.renderItem({
- group: groupData,
- item: extend(value, { index: idx })
- }));
- }
- });
- if (typeof index == UNDEFINED) {
- index = children.length;
- }
- for (var i = 0; i < itemsHtml.length; i++) {
- if (children.length === 0 || index === 0) {
- wrapper.append(itemsHtml[i]);
- } else {
- itemsHtml[i].insertAfter(children[index - 1]);
- }
- }
- that._angularCompileElements(itemsHtml, items);
- if (that.dataItem(parentNode)) {
- that.dataItem(parentNode).hasChildren = true;
- that.updateArrow(parentNode);
- }
- },
- _updateItems: function (items, field) {
- var that = this;
- var i, node, nodeWrapper, item;
- var context = {
- panelBar: that.options,
- item: item,
- group: {}
- };
- var render = field != 'expanded';
- if (field == 'selected') {
- if (items[0][field]) {
- var currentNode = that.findByUid(items[0].uid);
- if (!currentNode.hasClass(DISABLEDCLASS)) {
- that.select(currentNode, true);
- }
- } else {
- that.clearSelection();
- }
- } else {
- var elements = $.map(items, function (item) {
- return that.findByUid(item.uid);
- });
- if (render) {
- that.angular('cleanup', function () {
- return { elements: elements };
- });
- }
- for (i = 0; i < items.length; i++) {
- context.item = item = items[i];
- context.panelBar = that;
- nodeWrapper = elements[i];
- node = nodeWrapper.parent();
- if (render) {
- context.group = {
- firstLevel: node.hasClass('k-panelbar'),
- expanded: nodeWrapper.parent().hasClass(ACTIVECLASS),
- length: nodeWrapper.children().length
- };
- nodeWrapper.children('.k-link').remove();
- nodeWrapper.prepend(that.templates.itemWrapper(extend(context, { arrow: item.hasChildren || item.content || item.contentUrl ? that.templates.arrow : that.templates.empty }, rendering)));
- }
- if (field == 'expanded') {
- that._toggleItem(nodeWrapper, !item[field], item[field] ? 'true' : true);
- } else if (field == 'enabled') {
- that.enable(nodeWrapper, item[field]);
- if (!item[field]) {
- if (item.selected) {
- item.set('selected', false);
- }
- }
- }
- if (nodeWrapper.length) {
- this.trigger('itemChange', {
- item: nodeWrapper,
- data: item,
- ns: ui
- });
- }
- }
- if (render) {
- that.angular('compile', function () {
- return {
- elements: elements,
- data: $.map(items, function (item) {
- return [{ dataItem: item }];
- })
- };
- });
- }
- }
- },
- _toggleDisabled: function (element, enable) {
- element = this.element.find(element);
- element.toggleClass(defaultState, enable).toggleClass(DISABLEDCLASS, !enable).attr(ARIA_DISABLED, !enable);
- },
- dataItem: function (item) {
- var uid = $(item).closest(ITEM).attr(kendo.attr('uid')), dataSource = this.dataSource;
- return dataSource && dataSource.getByUid(uid);
- },
- select: function (element, skipChange) {
- var that = this;
- if (element === undefined) {
- return that.element.find(selectableItems).parent();
- }
- element = that.element.find(element);
- if (!element.length) {
- this._updateSelected(element);
- } else {
- element.each(function () {
- var item = $(this), link = item.children(LINKSELECTOR);
- if (item.hasClass(DISABLEDCLASS)) {
- return that;
- }
- that._updateSelected(link, skipChange);
- });
- }
- return that;
- },
- clearSelection: function () {
- this.select($());
- },
- enable: function (element, state) {
- this._toggleDisabled(element, state !== false);
- return this;
- },
- disable: function (element) {
- this._toggleDisabled(element, false);
- return this;
- },
- append: function (item, referenceItem) {
- referenceItem = this.element.find(referenceItem);
- var inserted = this._insert(item, referenceItem, referenceItem.length ? referenceItem.find(GROUPS) : null);
- each(inserted.items, function () {
- inserted.group.append(this);
- updateFirstLast(this);
- });
- this.updateArrow(referenceItem);
- updateFirstLast(inserted.group.find('.k-first, .k-last'));
- inserted.group.height('auto');
- return this;
- },
- insertBefore: function (item, referenceItem) {
- referenceItem = this.element.find(referenceItem);
- var inserted = this._insert(item, referenceItem, referenceItem.parent());
- each(inserted.items, function () {
- referenceItem.before(this);
- updateFirstLast(this);
- });
- updateFirstLast(referenceItem);
- inserted.group.height('auto');
- return this;
- },
- insertAfter: function (item, referenceItem) {
- referenceItem = this.element.find(referenceItem);
- var inserted = this._insert(item, referenceItem, referenceItem.parent());
- each(inserted.items, function () {
- referenceItem.after(this);
- updateFirstLast(this);
- });
- updateFirstLast(referenceItem);
- inserted.group.height('auto');
- return this;
- },
- remove: function (element) {
- element = this.element.find(element);
- var that = this, parent = element.parentsUntil(that.element, ITEM), group = element.parent('ul');
- element.remove();
- if (group && !group.hasClass('k-panelbar') && !group.children(ITEM).length) {
- group.remove();
- }
- if (parent.length) {
- parent = parent.eq(0);
- that.updateArrow(parent);
- updateFirstLast(parent);
- }
- return that;
- },
- reload: function (element) {
- var that = this;
- element = that.element.find(element);
- element.each(function () {
- var item = $(this);
- that._ajaxRequest(item, item.children('.' + CONTENT), !item.is(VISIBLE));
- });
- },
- _first: function () {
- return this.element.children(ACTIVEITEMSELECTOR).first();
- },
- _last: function () {
- var item = this.element.children(ACTIVEITEMSELECTOR).last(), group = item.children(VISIBLEGROUP);
- if (group[0]) {
- return group.children(ACTIVEITEMSELECTOR).last();
- }
- return item;
- },
- _current: function (candidate) {
- var that = this, focused = that._focused, id = that._itemId;
- if (candidate === undefined) {
- return focused;
- }
- that.element.removeAttr('aria-activedescendant');
- if (focused && focused.length) {
- if (focused[0].id === id) {
- focused.removeAttr('id');
- }
- focused.children(LINKSELECTOR).removeClass(FOCUSEDCLASS);
- }
- if ($(candidate).length) {
- id = candidate[0].id || id;
- candidate.attr('id', id).children(LINKSELECTOR).addClass(FOCUSEDCLASS);
- that.element.attr('aria-activedescendant', id);
- }
- that._focused = candidate;
- },
- _keydown: function (e) {
- var that = this, key = e.keyCode, current = that._current();
- if (e.target != e.currentTarget) {
- return;
- }
- if (key == keys.DOWN || key == keys.RIGHT) {
- that._current(that._nextItem(current));
- e.preventDefault();
- } else if (key == keys.UP || key == keys.LEFT) {
- that._current(that._prevItem(current));
- e.preventDefault();
- } else if (key == keys.ENTER || key == keys.SPACEBAR) {
- that._click(current.children(LINKSELECTOR));
- e.preventDefault();
- } else if (key == keys.HOME) {
- that._current(that._first());
- e.preventDefault();
- } else if (key == keys.END) {
- that._current(that._last());
- e.preventDefault();
- }
- },
- _nextItem: function (item) {
- if (!item) {
- return this._first();
- }
- var group = item.children(VISIBLEGROUP), next = item.nextAll(':visible').first();
- if (group[0]) {
- next = group.children('.' + FIRST);
- }
- if (!next[0]) {
- next = item.parent(VISIBLEGROUP).parent(ITEM).next();
- }
- if (!next[0]) {
- next = this._first();
- }
- if (next.hasClass(DISABLEDCLASS)) {
- next = this._nextItem(next);
- }
- return next;
- },
- _prevItem: function (item) {
- if (!item) {
- return this._last();
- }
- var prev = item.prevAll(':visible').first(), result;
- if (!prev[0]) {
- prev = item.parent(VISIBLEGROUP).parent(ITEM);
- if (!prev[0]) {
- prev = this._last();
- }
- } else {
- result = prev;
- while (result[0]) {
- result = result.children(VISIBLEGROUP).children('.' + LAST);
- if (result[0]) {
- prev = result;
- }
- }
- }
- if (prev.hasClass(DISABLEDCLASS)) {
- prev = this._prevItem(prev);
- }
- return prev;
- },
- _insert: function (item, referenceItem, parent) {
- var that = this, items, plain = $.isPlainObject(item), isReferenceItem = referenceItem && referenceItem[0], groupData;
- if (!isReferenceItem) {
- parent = that.element;
- }
- groupData = {
- firstLevel: parent.hasClass('k-panelbar'),
- expanded: $(referenceItem).hasClass(ACTIVECLASS),
- length: parent.children().length
- };
- if (isReferenceItem && !parent.length) {
- parent = $(that.renderGroup({
- group: groupData,
- options: that.options
- })).appendTo(referenceItem);
- }
- if (plain || $.isArray(item) || item instanceof HierarchicalDataSource) {
- if (item instanceof HierarchicalDataSource) {
- item = item.data();
- }
- items = $.map(plain ? [item] : item, function (value, idx) {
- if (typeof value === 'string') {
- return $(value);
- } else {
- return $(that.renderItem({
- group: groupData,
- item: extend(value, { index: idx })
- }));
- }
- });
- if (isReferenceItem) {
- var dataItem = that.dataItem(referenceItem);
- if (dataItem) {
- dataItem.hasChildren = true;
- referenceItem.attr(ARIA_EXPANDED, dataItem.expanded).not('.' + ACTIVECLASS).children('ul').attr(ARIA_HIDDEN, !dataItem.expanded);
- } else {
- referenceItem.attr(ARIA_EXPANDED, false);
- }
- }
- } else {
- if (typeof item == 'string' && item.charAt(0) != '<') {
- items = that.element.find(item);
- } else {
- items = $(item);
- }
- that._updateItemsClasses(items);
- }
- if (!item.length) {
- item = [item];
- }
- that._angularCompileElements(items, item);
- return {
- items: items,
- group: parent
- };
- },
- _toggleHover: function (e) {
- var target = $(e.currentTarget);
- if (!target.parents('li.' + DISABLEDCLASS).length) {
- target.toggleClass('k-state-hover', e.type == MOUSEENTER);
- }
- },
- _updateClasses: function () {
- var that = this, panels, items, expanded, panelsParent, dataItem;
- panels = that.element.find('li > ul').not(function () {
- return $(this).parentsUntil('.k-panelbar', 'div').length;
- }).addClass('k-group k-panel').attr('role', 'group');
- panelsParent = panels.parent();
- dataItem = that.dataItem(panelsParent);
- expanded = dataItem && dataItem.expanded || false;
- panels.parent().attr(ARIA_EXPANDED, expanded).not('.' + ACTIVECLASS).children('ul').attr(ARIA_HIDDEN, !expanded).hide();
- items = that.element.add(panels).children();
- that._updateItemsClasses(items);
- that.updateArrow(items);
- updateFirstLast(items);
- },
- _updateItemsClasses: function (items) {
- var length = items.length, idx = 0;
- for (; idx < length; idx++) {
- this._updateItemClasses(items[idx], idx);
- }
- },
- _updateItemClasses: function (item, index) {
- var selected = this._selected, contentUrls = this.options.contentUrls, url = contentUrls && contentUrls[index], root = this.element[0], wrapElement, link;
- item = $(item).addClass('k-item').attr('role', 'menuitem');
- if (kendo.support.browser.msie) {
- item.css('list-style-position', 'inside').css('list-style-position', '');
- }
- item.children(IMG).addClass(IMAGE);
- link = item.children('a').addClass(LINK);
- if (link[0]) {
- link.attr('href', url);
- link.children(IMG).addClass(IMAGE);
- }
- item.filter(':not([disabled]):not([class*=k-state])').addClass('k-state-default');
- item.filter('li[disabled]').addClass('k-state-disabled').attr(ARIA_DISABLED, true).removeAttr('disabled');
- item.children('div').addClass(CONTENT).attr('role', 'region').attr(ARIA_HIDDEN, true).hide().parent().attr(ARIA_EXPANDED, false);
- link = item.children(SELECTEDSELECTOR);
- if (link[0]) {
- if (selected) {
- selected.removeAttr(ARIA_SELECTED).children(SELECTEDSELECTOR).removeClass(SELECTEDCLASS);
- }
- link.addClass(SELECTEDCLASS);
- this._selected = item.attr(ARIA_SELECTED, true);
- }
- if (!item.children(LINKSELECTOR)[0]) {
- wrapElement = '
';
- if (contentUrls && contentUrls[index] && item[0].parentNode == root) {
- wrapElement = '';
- }
- item.contents().filter(function () {
- return !this.nodeName.match(excludedNodesRegExp) && !(this.nodeType == 3 && !$.trim(this.nodeValue));
- }).wrapAll(wrapElement);
- }
- if (item.parent('.k-panelbar')[0]) {
- item.children(LINKSELECTOR).addClass('k-header');
- }
- },
- _click: function (target) {
- var that = this, element = that.element, prevent, contents, href, isAnchor;
- if (target.parents('li.' + DISABLEDCLASS).length) {
- return;
- }
- if (target.closest('.k-widget')[0] != element[0]) {
- return;
- }
- var link = target.closest(LINKSELECTOR), item = link.closest(ITEM);
- that._updateSelected(link);
- var wrapper = item.children('.k-group,.k-content');
- var dataItem = this.dataItem(item);
- if (!wrapper.length && (that.options.loadOnDemand && dataItem && dataItem.hasChildren || this._hasChildItems(item) || item.content || item.contentUrl)) {
- wrapper = that._addGroupElement(item);
- }
- contents = item.find(GROUPS).add(item.find(CONTENTS));
- href = link.attr(HREF);
- isAnchor = href && (href.charAt(href.length - 1) == '#' || href.indexOf('#' + that.element[0].id + '-') != -1);
- prevent = !!(isAnchor || contents.length);
- if (contents.data('animating')) {
- return prevent;
- }
- if (that._triggerEvent(SELECT, item)) {
- prevent = true;
- }
- if (prevent === false) {
- return;
- }
- if (that.options.expandMode == SINGLE) {
- if (that._collapseAllExpanded(item)) {
- return prevent;
- }
- }
- if (contents.length) {
- var visibility = contents.is(VISIBLE);
- if (!that._triggerEvent(!visibility ? EXPAND : COLLAPSE, item)) {
- prevent = that._toggleItem(item, visibility);
- }
- }
- return prevent;
- },
- _hasChildItems: function (item) {
- return item.items && item.items.length > 0 || item.hasChildren;
- },
- _toggleItem: function (element, isVisible, expanded) {
- var that = this, childGroup = element.find(GROUPS), link = element.find(LINKSELECTOR), url = link.attr(HREF), prevent, content, dataItem = that.dataItem(element), notVisible = !isVisible;
- var loaded = dataItem && dataItem.loaded();
- if (dataItem && !expanded && dataItem.expanded !== notVisible) {
- dataItem.set('expanded', notVisible);
- prevent = dataItem.hasChildren || !!dataItem.content || !!dataItem.contentUrl;
- return prevent;
- }
- if (dataItem && (!expanded || expanded === 'true') && !loaded && !dataItem.content && !dataItem.contentUrl) {
- if (that.options.loadOnDemand) {
- this._progress(element, true);
- }
- element.children('.k-group,.k-content').remove();
- prevent = dataItem.hasChildren;
- dataItem.load();
- } else {
- if (childGroup.length) {
- this._toggleGroup(childGroup, isVisible);
- prevent = true;
- } else {
- content = element.children('.' + CONTENT);
- if (content.length) {
- prevent = true;
- if (!content.is(EMPTY) || url === undefined) {
- that._toggleGroup(content, isVisible);
- } else {
- that._ajaxRequest(element, content, isVisible);
- }
- }
- }
- }
- return prevent;
- },
- _toggleGroup: function (element, visibility) {
- var that = this, animationSettings = that.options.animation, animation = animationSettings.expand, hasCollapseAnimation = animationSettings.collapse && 'effects' in animationSettings.collapse, collapse = extend({}, animationSettings.expand, animationSettings.collapse);
- if (!hasCollapseAnimation) {
- collapse = extend(collapse, { reverse: true });
- }
- if (element.is(VISIBLE) != visibility) {
- that._animating = false;
- return;
- }
- element.attr(ARIA_HIDDEN, !!visibility);
- element.parent().attr(ARIA_EXPANDED, !visibility).toggleClass(ACTIVECLASS, !visibility).find('> .k-link > .k-panelbar-collapse,> .k-link > .k-panelbar-expand').toggleClass('k-i-arrow-60-up', !visibility).toggleClass('k-panelbar-collapse', !visibility).toggleClass('k-i-arrow-60-down', visibility).toggleClass('k-panelbar-expand', visibility);
- if (visibility) {
- animation = extend(collapse, { hide: true });
- animation.complete = function () {
- that._animationCallback();
- };
- } else {
- animation = extend({
- complete: function (element) {
- that._triggerEvent(ACTIVATE, element.closest(ITEM));
- that._animationCallback();
- }
- }, animation);
- }
- element.kendoStop(true, true).kendoAnimate(animation);
- },
- _animationCallback: function () {
- var that = this;
- that.trigger('complete');
- that._animating = false;
- },
- _addGroupElement: function (element) {
- var group = $('
');
- element.append(group);
- return group;
- },
- _collapseAllExpanded: function (item) {
- var that = this, children, stopExpand = false;
- var groups = item.find(GROUPS).add(item.find(CONTENTS));
- if (groups.is(VISIBLE)) {
- stopExpand = true;
- }
- if (!(groups.is(VISIBLE) || groups.length === 0)) {
- children = item.siblings();
- children.find(GROUPS).add(children.find(CONTENTS)).filter(function () {
- return $(this).is(VISIBLE);
- }).each(function (index, content) {
- content = $(content);
- stopExpand = that._triggerEvent(COLLAPSE, content.closest(ITEM));
- if (!stopExpand) {
- that._toggleGroup(content, true);
- }
- });
- that.one('complete', function () {
- setTimeout(function () {
- children.each(function (index, child) {
- var dataItem = that.dataItem(child);
- if (dataItem) {
- dataItem.set('expanded', false);
- }
- });
- });
- });
- }
- return stopExpand;
- },
- _ajaxRequest: function (element, contentElement, isVisible) {
- var that = this, statusIcon = element.find('.k-panelbar-collapse, .k-panelbar-expand'), link = element.find(LINKSELECTOR), loadingIconTimeout = setTimeout(function () {
- statusIcon.addClass('k-i-loading');
- }, 100), data = {}, url = link.attr(HREF);
- $.ajax({
- type: 'GET',
- cache: false,
- url: url,
- dataType: 'html',
- data: data,
- error: function (xhr, status) {
- statusIcon.removeClass('k-i-loading');
- if (that.trigger(ERROR, {
- xhr: xhr,
- status: status
- })) {
- this.complete();
- }
- },
- complete: function () {
- clearTimeout(loadingIconTimeout);
- statusIcon.removeClass('k-i-loading');
- },
- success: function (data) {
- function getElements() {
- return { elements: contentElement.get() };
- }
- try {
- that.angular('cleanup', getElements);
- contentElement.html(data);
- that.angular('compile', getElements);
- } catch (e) {
- var console = window.console;
- if (console && console.error) {
- console.error(e.name + ': ' + e.message + ' in ' + url);
- }
- this.error(this.xhr, 'error');
- }
- that._toggleGroup(contentElement, isVisible);
- that.trigger(CONTENTLOAD, {
- item: element[0],
- contentElement: contentElement[0]
- });
- }
- });
- },
- _triggerEvent: function (eventName, element) {
- var that = this;
- return that.trigger(eventName, { item: element[0] });
- },
- _updateSelected: function (link, skipChange) {
- var that = this, element = that.element, item = link.parent(ITEM), selected = that._selected, dataItem = that.dataItem(item);
- if (selected) {
- selected.removeAttr(ARIA_SELECTED);
- }
- that._selected = item.attr(ARIA_SELECTED, true);
- element.find(selectableItems).removeClass(SELECTEDCLASS);
- element.find('> .' + HIGHLIGHTCLASS + ', .k-panel > .' + HIGHLIGHTCLASS).removeClass(HIGHLIGHTCLASS);
- link.addClass(SELECTEDCLASS);
- link.parentsUntil(element, ITEM).filter(':has(.k-header)').addClass(HIGHLIGHTCLASS);
- that._current(item[0] ? item : null);
- if (dataItem) {
- dataItem.set('selected', true);
- }
- if (!skipChange) {
- that.trigger(CHANGE);
- }
- },
- _animations: function (options) {
- if (options && 'animation' in options && !options.animation) {
- options.animation = {
- expand: { effects: {} },
- collapse: {
- hide: true,
- effects: {}
- }
- };
- }
- },
- renderItem: function (options) {
- var that = this;
- options = extend({
- panelBar: that,
- group: {}
- }, options);
- var empty = that.templates.empty, item = options.item;
- return that.templates.item(extend(options, {
- itemWrapper: that.templates.itemWrapper,
- renderContent: that.renderContent,
- arrow: that._hasChildItems(item) || item.content || item.contentUrl ? that.templates.arrow : empty,
- subGroup: !options.loadOnDemand || item.expanded ? that.renderGroup : empty
- }, rendering));
- },
- renderGroup: function (options) {
- var that = this;
- var templates = that.templates || options.panelBar.templates;
- return templates.group(extend({
- renderItems: function (options) {
- var html = '', i = 0, items = options.items, len = items ? items.length : 0, group = extend({ length: len }, options.group);
- for (; i < len; i++) {
- html += options.panelBar.renderItem(extend(options, {
- group: group,
- item: extend({ index: i }, items[i])
- }));
- }
- return html;
- }
- }, options, rendering));
- },
- renderContent: function (options) {
- return options.panelBar.templates.content(extend(options, rendering));
- }
- });
- kendo.ui.plugin(PanelBar);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
-/**
- * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-
-
-
-
-
-
-
-*/
-(function (f, define) {
- define('kendo.window', [
- 'kendo.draganddrop',
- 'kendo.popup'
- ], f);
-}(function () {
- var __meta__ = {
- id: 'window',
- name: 'Window',
- category: 'web',
- description: 'The Window widget displays content in a modal or non-modal HTML window.',
- depends: [
- 'draganddrop',
- 'popup'
- ],
- features: [{
- id: 'window-fx',
- name: 'Animation',
- description: 'Support for animation',
- depends: ['fx']
- }]
- };
- (function ($, undefined) {
- var kendo = window.kendo, Widget = kendo.ui.Widget, TabKeyTrap = kendo.ui.Popup.TabKeyTrap, Draggable = kendo.ui.Draggable, isPlainObject = $.isPlainObject, activeElement = kendo._activeElement, outerWidth = kendo._outerWidth, outerHeight = kendo._outerHeight, proxy = $.proxy, extend = $.extend, each = $.each, template = kendo.template, BODY = 'body', templates, NS = '.kendoWindow', MODAL_NS = '.kendoWindowModal', KWINDOW = '.k-window', KWINDOWTITLE = '.k-window-title', KWINDOWTITLEBAR = KWINDOWTITLE + 'bar', KWINDOWCONTENT = '.k-window-content', KDIALOGCONTENT = '.k-dialog-content', KWINDOWRESIZEHANDLES = '.k-resize-handle', KOVERLAY = '.k-overlay', KCONTENTFRAME = 'k-content-frame', LOADING = 'k-i-loading', KHOVERSTATE = 'k-state-hover', KFOCUSEDSTATE = 'k-state-focused', MAXIMIZEDSTATE = 'k-window-maximized', VISIBLE = ':visible', HIDDEN = 'hidden', CURSOR = 'cursor', OPEN = 'open', ACTIVATE = 'activate', DEACTIVATE = 'deactivate', CLOSE = 'close', REFRESH = 'refresh', MINIMIZE = 'minimize', MAXIMIZE = 'maximize', RESIZESTART = 'resizeStart', RESIZE = 'resize', RESIZEEND = 'resizeEnd', DRAGSTART = 'dragstart', DRAGEND = 'dragend', ERROR = 'error', OVERFLOW = 'overflow', DATADOCOVERFLOWRULE = 'original-overflow-rule', ZINDEX = 'zIndex', MINIMIZE_MAXIMIZE = '.k-window-actions .k-i-window-minimize,.k-window-actions .k-i-window-maximize', KPIN = '.k-i-pin', KUNPIN = '.k-i-unpin', PIN_UNPIN = KPIN + ',' + KUNPIN, TITLEBAR_BUTTONS = '.k-window-titlebar .k-window-action', REFRESHICON = '.k-window-titlebar .k-i-refresh', WINDOWEVENTSHANDLED = 'WindowEventsHandled', zero = /^0[a-z]*$/i, isLocalUrl = kendo.isLocalUrl, SIZE = {
- small: 'k-window-sm',
- medium: 'k-window-md',
- large: 'k-window-lg'
- };
- function defined(x) {
- return typeof x != 'undefined';
- }
- function toInt(element, property) {
- return parseInt(element.css(property), 10) || 0;
- }
- function constrain(value, low, high) {
- return Math.max(Math.min(parseInt(value, 10), high === Infinity ? high : parseInt(high, 10)), low === -Infinity ? low : parseInt(low, 10));
- }
- function executableScript() {
- return !this.type || this.type.toLowerCase().indexOf('script') >= 0;
- }
- function getPosition(elem) {
- var result = {
- top: elem.offsetTop,
- left: elem.offsetLeft
- }, parent = elem.offsetParent;
- while (parent) {
- result.top += parent.offsetTop;
- result.left += parent.offsetLeft;
- var parentOverflowX = $(parent).css('overflowX');
- var parentOverflowY = $(parent).css('overflowY');
- if (parentOverflowY === 'auto' || parentOverflowY === 'scroll') {
- result.top -= parent.scrollTop;
- }
- if (parentOverflowX === 'auto' || parentOverflowX === 'scroll') {
- result.left -= parent.scrollLeft;
- }
- parent = parent.offsetParent;
- }
- return result;
- }
- var Window = Widget.extend({
- init: function (element, options) {
- var that = this, wrapper, offset = {}, visibility, display, position, isVisible = false, content, windowContent, windowFrame, globalWindow, suppressActions = options && options.actions && !options.actions.length, id;
- Widget.fn.init.call(that, element, options);
- options = that.options;
- position = options.position;
- element = that.element;
- content = options.content;
- globalWindow = $(window);
- if (suppressActions) {
- options.actions = [];
- }
- that.appendTo = $(options.appendTo);
- that.containment = options.draggable.containment ? $(options.draggable.containment).first() : null;
- if (content && !isPlainObject(content)) {
- content = options.content = { url: content };
- }
- element.find('script').filter(executableScript).remove();
- if (!element.parent().is(that.appendTo) && !that.containment && (position.top === undefined || position.left === undefined)) {
- if (element.is(VISIBLE)) {
- offset = element.offset();
- isVisible = true;
- } else {
- visibility = element.css('visibility');
- display = element.css('display');
- element.css({
- visibility: HIDDEN,
- display: ''
- });
- offset = element.offset();
- element.css({
- visibility: visibility,
- display: display
- });
- }
- if (position.top === undefined) {
- position.top = offset.top;
- }
- if (position.left === undefined) {
- position.left = offset.left;
- }
- }
- if (!defined(options.visible) || options.visible === null) {
- options.visible = element.is(VISIBLE);
- }
- wrapper = that.wrapper = element.closest(KWINDOW);
- if (!element.is('.k-content') || !wrapper[0]) {
- element.addClass('k-window-content k-content');
- that._createWindow(element, options);
- wrapper = that.wrapper = element.closest(KWINDOW);
- that.title(that.options.title);
- that._dimensions();
- }
- that.minTop = that.minLeft = -Infinity;
- that.maxTop = that.maxLeft = Infinity;
- that._position();
- if (content) {
- that.refresh(content);
- }
- if (options.visible) {
- that.toFront();
- }
- windowContent = wrapper.children(KWINDOWCONTENT);
- that._tabindex(windowContent);
- if (options.visible && options.modal) {
- that._overlay(wrapper.is(VISIBLE)).css({ opacity: 0.5 });
- }
- wrapper.on('mouseenter' + NS, TITLEBAR_BUTTONS, proxy(that._buttonEnter, that)).on('mouseleave' + NS, TITLEBAR_BUTTONS, proxy(that._buttonLeave, that)).on('click' + NS, '> ' + TITLEBAR_BUTTONS, proxy(that._windowActionHandler, that)).on('keydown' + NS, proxy(that._keydown, that)).on('focus' + NS, proxy(that._focus, that)).on('blur' + NS, proxy(that._blur, that));
- windowContent.on('keydown' + NS, proxy(that._keydown, that)).on('focus' + NS, proxy(that._focus, that)).on('blur' + NS, proxy(that._blur, that));
- windowFrame = windowContent.find('.' + KCONTENTFRAME)[0];
- if (windowFrame && !globalWindow.data(WINDOWEVENTSHANDLED)) {
- globalWindow.on('blur' + NS, function () {
- var element = $(document.activeElement).parent(KWINDOWCONTENT);
- if (element.length) {
- var windowInstance = kendo.widgetInstance(element);
- windowInstance._focus();
- }
- });
- globalWindow.on('focus' + NS, function () {
- $(KWINDOWCONTENT).not(KDIALOGCONTENT).each(function (i, element) {
- kendo.widgetInstance($(element))._blur();
- });
- });
- globalWindow.data(WINDOWEVENTSHANDLED, true);
- }
- this._resizable();
- this._draggable();
- if (options.pinned && this.wrapper.is(':visible')) {
- that.pin();
- }
- id = element.attr('id');
- if (id) {
- id = id + '_wnd_title';
- wrapper.children(KWINDOWTITLEBAR).children(KWINDOWTITLE).attr('id', id);
- windowContent.attr({
- 'role': 'dialog',
- 'aria-labelledby': id
- });
- }
- wrapper.add(wrapper.children('.k-resize-handle,' + KWINDOWTITLEBAR)).on('mousedown' + NS, proxy(that.toFront, that));
- that.touchScroller = kendo.touchScroller(element);
- that._resizeHandler = proxy(that._onDocumentResize, that);
- that._marker = kendo.guid().substring(0, 8);
- $(window).on('resize' + NS + that._marker, that._resizeHandler);
- if (options.visible) {
- that.trigger(OPEN);
- that.trigger(ACTIVATE);
- }
- kendo.notify(that);
- if (this.options.modal) {
- this._tabKeyTrap = new TabKeyTrap(wrapper);
- this._tabKeyTrap.trap();
- this._tabKeyTrap.shouldTrap = function () {
- return windowContent.data('isFront');
- };
- }
- },
- _buttonEnter: function (e) {
- $(e.currentTarget).addClass(KHOVERSTATE);
- },
- _buttonLeave: function (e) {
- $(e.currentTarget).removeClass(KHOVERSTATE);
- },
- _focus: function () {
- this.wrapper.addClass(KFOCUSEDSTATE);
- },
- _blur: function () {
- this.wrapper.removeClass(KFOCUSEDSTATE);
- },
- _dimensions: function () {
- var wrapper = this.wrapper;
- var options = this.options;
- var width = options.width;
- var height = options.height;
- var maxHeight = options.maxHeight;
- var sizeClass = options.size;
- var dimensions = [
- 'minWidth',
- 'minHeight',
- 'maxWidth',
- 'maxHeight'
- ];
- var contentBoxSizing = wrapper.css('box-sizing') == 'content-box';
- var lrBorderWidth = contentBoxSizing ? toInt(wrapper, 'border-left-width') + toInt(wrapper, 'border-right-width') : 0;
- var tbBorderWidth = contentBoxSizing ? toInt(wrapper, 'border-top-width') + toInt(wrapper, 'border-bottom-width') : 0;
- var paddingTop = contentBoxSizing ? toInt(wrapper, 'padding-top') : 0;
- if (this.containment && !this._isPinned) {
- this._updateBoundaries();
- options.maxHeight = Math.min(this.containment.height - (tbBorderWidth + paddingTop), maxHeight);
- options.maxWidth = Math.min(this.containment.width - lrBorderWidth, options.maxWidth);
- }
- for (var i = 0; i < dimensions.length; i++) {
- var value = options[dimensions[i]] || '';
- if (value != Infinity) {
- wrapper.css(dimensions[i], value);
- }
- }
- if (maxHeight != Infinity) {
- this.element.css('maxHeight', maxHeight);
- }
- if (width) {
- if (isNaN(width) && width.toString().indexOf('px') < 0) {
- wrapper.width(width);
- } else {
- wrapper.width(constrain(width, options.minWidth, options.maxWidth));
- }
- } else {
- wrapper.width('');
- }
- if (height) {
- if (isNaN(height) && height.toString().indexOf('px') < 0) {
- wrapper.height(height);
- } else {
- wrapper.height(constrain(height, options.minHeight, options.maxHeight));
- }
- } else {
- wrapper.height('');
- }
- if (!options.visible) {
- wrapper.hide();
- }
- if (sizeClass && SIZE[sizeClass]) {
- wrapper.addClass(SIZE[sizeClass]);
- }
- },
- _position: function () {
- var wrapper = this.wrapper, position = this.options.position;
- this._updateBoundaries();
- if (this.containment) {
- position.top = Math.min(this.minTop + (position.top || 0), this.maxTop);
- position.left = Math.min(this.minLeft + (position.left || 0), this.maxLeft);
- }
- if (position.top === 0) {
- position.top = position.top.toString();
- }
- if (position.left === 0) {
- position.left = position.left.toString();
- }
- wrapper.css({
- top: position.top || '',
- left: position.left || ''
- });
- },
- _updateBoundaries: function () {
- var containment = this.containment;
- if (!containment) {
- return null;
- }
- containment.width = containment.innerWidth();
- containment.height = containment.innerHeight();
- if (parseInt(containment.width, 10) > containment[0].clientWidth) {
- containment.width -= kendo.support.scrollbar();
- }
- if (parseInt(containment.height, 10) > containment[0].clientHeight) {
- containment.height -= kendo.support.scrollbar();
- }
- containment.position = getPosition(containment[0]);
- if (this._isPinned) {
- this.minTop = this.minLeft = -Infinity;
- this.maxTop = this.maxLeft = Infinity;
- } else {
- this.minTop = containment.scrollTop();
- this.minLeft = containment.scrollLeft();
- this.maxLeft = this.minLeft + containment.width - outerWidth(this.wrapper, true);
- this.maxTop = this.minTop + containment.height - outerHeight(this.wrapper, true);
- }
- },
- _animationOptions: function (id) {
- var animation = this.options.animation;
- var basicAnimation = {
- open: { effects: {} },
- close: {
- hide: true,
- effects: {}
- }
- };
- return animation && animation[id] || basicAnimation[id];
- },
- _resize: function () {
- kendo.resize(this.element.children());
- },
- _resizable: function () {
- var resizable = this.options.resizable;
- var wrapper = this.wrapper;
- if (this.resizing) {
- wrapper.off('dblclick' + NS).children(KWINDOWRESIZEHANDLES).remove();
- this.resizing.destroy();
- this.resizing = null;
- }
- if (resizable) {
- wrapper.on('dblclick' + NS, KWINDOWTITLEBAR, proxy(function (e) {
- if (!$(e.target).closest('.k-window-action').length) {
- this.toggleMaximization();
- }
- }, this));
- each('n e s w se sw ne nw'.split(' '), function (index, handler) {
- wrapper.append(templates.resizeHandle(handler));
- });
- this.resizing = new WindowResizing(this);
- }
- wrapper = null;
- },
- _draggable: function () {
- var draggable = this.options.draggable;
- if (this.dragging) {
- this.dragging.destroy();
- this.dragging = null;
- }
- if (draggable) {
- this.dragging = new WindowDragging(this, draggable.dragHandle || KWINDOWTITLEBAR);
- }
- },
- _actions: function () {
- var options = this.options;
- var actions = options.actions;
- var pinned = options.pinned;
- var titlebar = this.wrapper.children(KWINDOWTITLEBAR);
- var container = titlebar.find('.k-window-actions');
- var windowSpecificCommands = [
- 'maximize',
- 'minimize'
- ];
- actions = $.map(actions, function (action) {
- action = pinned && action.toLowerCase() === 'pin' ? 'unpin' : action;
- return { name: windowSpecificCommands.indexOf(action.toLowerCase()) > -1 ? 'window-' + action : action };
- });
- container.html(kendo.render(templates.action, actions));
- },
- setOptions: function (options) {
- var that = this;
- var sizeClass = that.options.size;
- var cachedOptions = JSON.parse(JSON.stringify(options));
- extend(options.position, that.options.position);
- extend(options.position, cachedOptions.position);
- Widget.fn.setOptions.call(that, options);
- var scrollable = that.options.scrollable !== false;
- that.restore();
- if (typeof options.title !== 'undefined') {
- that.title(options.title);
- }
- that.wrapper.removeClass(SIZE[sizeClass]);
- that._dimensions();
- that._position();
- that._resizable();
- that._draggable();
- that._actions();
- if (typeof options.modal !== 'undefined') {
- var visible = that.options.visible !== false;
- that._enableDocumentScrolling();
- that._overlay(options.modal && visible);
- }
- that.element.css(OVERFLOW, scrollable ? '' : 'hidden');
- },
- events: [
- OPEN,
- ACTIVATE,
- DEACTIVATE,
- CLOSE,
- MINIMIZE,
- MAXIMIZE,
- REFRESH,
- RESIZESTART,
- RESIZE,
- RESIZEEND,
- DRAGSTART,
- DRAGEND,
- ERROR
- ],
- options: {
- name: 'Window',
- animation: {
- open: {
- effects: {
- zoom: { direction: 'in' },
- fade: { direction: 'in' }
- },
- duration: 350
- },
- close: {
- effects: {
- zoom: {
- direction: 'out',
- properties: { scale: 0.7 }
- },
- fade: { direction: 'out' }
- },
- duration: 350,
- hide: true
- }
- },
- title: '',
- actions: ['Close'],
- autoFocus: true,
- modal: false,
- size: 'auto',
- resizable: true,
- draggable: true,
- minWidth: 90,
- minHeight: 50,
- maxWidth: Infinity,
- maxHeight: Infinity,
- pinned: false,
- scrollable: true,
- position: {},
- content: null,
- visible: null,
- height: null,
- width: null,
- appendTo: 'body',
- isMaximized: false,
- isMinimized: false
- },
- _closable: function () {
- return $.inArray('close', $.map(this.options.actions, function (x) {
- return x.toLowerCase();
- })) > -1;
- },
- _keydown: function (e) {
- var that = this, options = that.options, keys = kendo.keys, keyCode = e.keyCode, wrapper = that.wrapper, offset, handled, distance = 10, isMaximized = options.isMaximized, isMinimized = options.isMinimized, newWidth, newHeight, w, h;
- if (keyCode == keys.ESC && that._closable()) {
- e.stopPropagation();
- that._close(false);
- }
- if (e.target != e.currentTarget || that._closing) {
- return;
- }
- if (e.altKey && keyCode == 82) {
- that.refresh();
- }
- if (e.altKey && keyCode == 80) {
- if (that.options.pinned) {
- that.unpin();
- } else {
- that.pin();
- }
- }
- if (e.altKey && keyCode == keys.UP) {
- if (isMinimized) {
- that.restore();
- that.element.focus();
- } else if (!isMaximized) {
- that.maximize();
- that.element.focus();
- }
- } else if (e.altKey && keyCode == keys.DOWN) {
- if (!isMinimized && !isMaximized) {
- that.minimize();
- that.wrapper.focus();
- } else if (isMaximized) {
- that.restore();
- that.element.focus();
- }
- }
- offset = kendo.getOffset(wrapper);
- if (that.containment && !that._isPinned) {
- offset = that.options.position;
- }
- if (options.draggable && !e.ctrlKey && !e.altKey && !isMaximized) {
- that._updateBoundaries();
- if (keyCode == keys.UP) {
- offset.top = constrain(offset.top - distance, that.minTop, that.maxTop);
- handled = wrapper.css('top', offset.top);
- } else if (keyCode == keys.DOWN) {
- offset.top = constrain(offset.top + distance, that.minTop, that.maxTop);
- handled = wrapper.css('top', offset.top);
- } else if (keyCode == keys.LEFT) {
- offset.left = constrain(offset.left - distance, that.minLeft, that.maxLeft);
- handled = wrapper.css('left', offset.left);
- } else if (keyCode == keys.RIGHT) {
- offset.left = constrain(offset.left + distance, that.minLeft, that.maxLeft);
- handled = wrapper.css('left', offset.left);
- }
- }
- if (options.resizable && e.ctrlKey && !isMaximized && !isMinimized) {
- if (keyCode == keys.UP) {
- handled = true;
- newHeight = wrapper.height() - distance;
- } else if (keyCode == keys.DOWN) {
- handled = true;
- if (that.containment && !that._isPinned) {
- newHeight = Math.min(wrapper.height() + distance, that.containment.height - offset.top - toInt(wrapper, 'padding-top') - toInt(wrapper, 'borderBottomWidth') - toInt(wrapper, 'borderTopWidth'));
- } else {
- newHeight = wrapper.height() + distance;
- }
- }
- if (keyCode == keys.LEFT) {
- handled = true;
- newWidth = wrapper.width() - distance;
- } else if (keyCode == keys.RIGHT) {
- handled = true;
- if (that.containment && !that._isPinned) {
- newWidth = Math.min(wrapper.width() + distance, that.containment.width - offset.left - toInt(wrapper, 'borderLeftWidth') - toInt(wrapper, 'borderRightWidth'));
- } else {
- newWidth = wrapper.width() + distance;
- }
- }
- if (handled) {
- w = constrain(newWidth, options.minWidth, options.maxWidth);
- h = constrain(newHeight, options.minHeight, options.maxHeight);
- if (!isNaN(w)) {
- wrapper.width(w);
- that.options.width = w + 'px';
- }
- if (!isNaN(h)) {
- wrapper.height(h);
- that.options.height = h + 'px';
- }
- that.resize();
- }
- }
- if (handled) {
- e.preventDefault();
- }
- },
- _overlay: function (visible) {
- var overlay = this.containment ? this.containment.children(KOVERLAY) : this.appendTo.children(KOVERLAY), wrapper = this.wrapper;
- if (!overlay.length) {
- overlay = $('
');
- }
- overlay.insertBefore(wrapper[0]).toggle(visible).css(ZINDEX, parseInt(wrapper.css(ZINDEX), 10) - 1);
- if (this.options.modal.preventScroll && !this.containment) {
- this._stopDocumentScrolling();
- }
- return overlay;
- },
- _actionForIcon: function (icon) {
- var iconClass = /\bk-i(-\w+)+\b/.exec(icon[0].className)[0];
- return {
- 'k-i-close': '_close',
- 'k-i-window-maximize': 'maximize',
- 'k-i-window-minimize': 'minimize',
- 'k-i-window-restore': 'restore',
- 'k-i-refresh': 'refresh',
- 'k-i-pin': 'pin',
- 'k-i-unpin': 'unpin'
- }[iconClass];
- },
- _windowActionHandler: function (e) {
- if (this._closing) {
- return;
- }
- var icon = $(e.target).closest('.k-window-action').find('.k-icon');
- var action = this._actionForIcon(icon);
- if (action) {
- e.preventDefault();
- this[action]();
- return false;
- }
- },
- _modals: function () {
- var that = this;
- var zStack = $(KWINDOW).filter(function () {
- var dom = $(this);
- var object = that._object(dom);
- var options = object && object.options;
- return options && options.modal && options.visible && options.appendTo === that.options.appendTo && dom.is(VISIBLE);
- }).sort(function (a, b) {
- return +$(a).css('zIndex') - +$(b).css('zIndex');
- });
- that = null;
- return zStack;
- },
- _object: function (element) {
- var content = element.children(KWINDOWCONTENT);
- var widget = kendo.widgetInstance(content);
- if (widget) {
- return widget;
- }
- return undefined;
- },
- center: function () {
- var that = this, position = that.options.position, wrapper = that.wrapper, documentWindow = $(window), scrollTop = 0, scrollLeft = 0, newTop, newLeft;
- if (that.options.isMaximized) {
- return that;
- }
- if (that.options.pinned && !that._isPinned) {
- that.pin();
- }
- if (!that.options.pinned) {
- scrollTop = documentWindow.scrollTop();
- scrollLeft = documentWindow.scrollLeft();
- }
- if (this.containment && !that.options.pinned) {
- newTop = this.minTop + (this.maxTop - this.minTop) / 2;
- newLeft = this.minLeft + (this.maxLeft - this.minLeft) / 2;
- } else {
- newLeft = scrollLeft + Math.max(0, (documentWindow.width() - wrapper.width()) / 2);
- newTop = scrollTop + Math.max(0, (documentWindow.height() - wrapper.height() - toInt(wrapper, 'paddingTop')) / 2);
- }
- wrapper.css({
- left: newLeft,
- top: newTop
- });
- position.top = newTop;
- position.left = newLeft;
- return that;
- },
- title: function (title) {
- var that = this, value, encoded = true, wrapper = that.wrapper, titleBar = wrapper.children(KWINDOWTITLEBAR), titleElement = titleBar.children(KWINDOWTITLE), titleBarHeight, display, visibility;
- if (!arguments.length) {
- return titleElement.html();
- }
- if ($.isPlainObject(title)) {
- value = typeof title.text !== 'undefined' ? title.text : '';
- encoded = title.encoded !== false;
- } else {
- value = title;
- }
- if (value === false) {
- wrapper.addClass('k-window-titleless');
- titleBar.remove();
- } else {
- if (!titleBar.length) {
- wrapper.prepend(templates.titlebar({ title: encoded ? kendo.htmlEncode(value) : value }));
- that._actions();
- titleBar = wrapper.children(KWINDOWTITLEBAR);
- } else {
- titleElement.html(encoded ? kendo.htmlEncode(value) : value);
- }
- visibility = wrapper.css('visibility');
- display = wrapper.css('display');
- if (visibility === HIDDEN) {
- wrapper.css({ display: '' });
- titleBarHeight = parseInt(outerHeight(titleBar), 10);
- wrapper.css({ display: display });
- } else {
- wrapper.css({
- visibility: HIDDEN,
- display: ''
- });
- titleBarHeight = parseInt(outerHeight(titleBar), 10);
- wrapper.css({
- visibility: visibility,
- display: display
- });
- }
- wrapper.css('padding-top', titleBarHeight);
- titleBar.css('margin-top', -titleBarHeight);
- }
- that.options.title = value;
- return that;
- },
- content: function (html, data) {
- var content = this.wrapper.children(KWINDOWCONTENT), scrollContainer = content.children('.km-scroll-container');
- content = scrollContainer[0] ? scrollContainer : content;
- if (!defined(html)) {
- return content.html();
- }
- this.angular('cleanup', function () {
- return { elements: content.children() };
- });
- kendo.destroy(this.element.children());
- content.empty().html(html);
- this.angular('compile', function () {
- var a = [];
- for (var i = content.length; --i >= 0;) {
- a.push({ dataItem: data });
- }
- return {
- elements: content.children(),
- data: a
- };
- });
- return this;
- },
- open: function () {
- var that = this, wrapper = that.wrapper, options = that.options, showOptions = this._animationOptions('open'), contentElement = wrapper.children(KWINDOWCONTENT), overlay, otherModalsVisible, containmentContext = this.containment && !that._isPinned, doc = containmentContext ? this.containment : $(document);
- if (!that.trigger(OPEN)) {
- if (that._closing) {
- wrapper.kendoStop(true, true);
- }
- that._closing = false;
- that.toFront();
- if (options.autoFocus) {
- that.element.focus();
- }
- options.visible = true;
- if (options.modal) {
- otherModalsVisible = !!that._modals().length;
- overlay = that._overlay(otherModalsVisible);
- overlay.kendoStop(true, true);
- if (showOptions.duration && kendo.effects.Fade && !otherModalsVisible) {
- var overlayFx = kendo.fx(overlay).fadeIn();
- overlayFx.duration(showOptions.duration || 0);
- overlayFx.endValue(0.5);
- overlayFx.play();
- } else {
- overlay.css('opacity', 0.5);
- }
- overlay.show();
- $(window).on('focus' + MODAL_NS, function () {
- if (contentElement.data('isFront') && !$(document.activeElement).closest(contentElement).length) {
- that.element.focus();
- }
- });
- }
- if (!wrapper.is(VISIBLE)) {
- contentElement.css(OVERFLOW, HIDDEN);
- wrapper.show().kendoStop().kendoAnimate({
- effects: showOptions.effects,
- duration: showOptions.duration,
- complete: proxy(this._activate, this)
- });
- }
- }
- if (options.isMaximized) {
- that._containerScrollTop = doc.scrollTop();
- that._containerScrollLeft = doc.scrollLeft();
- that._stopDocumentScrolling();
- }
- if (options.pinned && !that._isPinned) {
- that.pin();
- }
- return that;
- },
- _activate: function () {
- var scrollable = this.options.scrollable !== false;
- if (this.options.autoFocus) {
- this.element.focus();
- }
- this.element.css(OVERFLOW, scrollable ? '' : 'hidden');
- kendo.resize(this.element.children());
- this.trigger(ACTIVATE);
- },
- _removeOverlay: function (suppressAnimation) {
- var modals = this._modals();
- var options = this.options;
- var hideOverlay = options.modal && !modals.length;
- var overlay = options.modal ? this._overlay(true) : $(undefined);
- var hideOptions = this._animationOptions('close');
- if (hideOverlay) {
- if (!suppressAnimation && hideOptions.duration && kendo.effects.Fade) {
- var overlayFx = kendo.fx(overlay).fadeOut();
- overlayFx.duration(hideOptions.duration || 0);
- overlayFx.startValue(0.5);
- overlayFx.play();
- } else {
- this._overlay(false).remove();
- }
- if (options.modal.preventScroll) {
- this._enableDocumentScrolling();
- }
- } else if (modals.length) {
- this._object(modals.last())._overlay(true);
- if (options.modal.preventScroll) {
- this._stopDocumentScrolling();
- }
- }
- },
- _close: function (systemTriggered) {
- var that = this, wrapper = that.wrapper, options = that.options, showOptions = this._animationOptions('open'), hideOptions = this._animationOptions('close'), containmentContext = this.containment && !that._isPinned, doc = containmentContext ? this.containment : $(document), defaultPrevented;
- if (that._closing) {
- return;
- }
- defaultPrevented = that.trigger(CLOSE, { userTriggered: !systemTriggered });
- that._closing = !defaultPrevented;
- if (wrapper.is(VISIBLE) && !defaultPrevented) {
- options.visible = false;
- $(KWINDOW).each(function (i, element) {
- var contentElement = $(element).children(KWINDOWCONTENT);
- if (element != wrapper && contentElement.find('> .' + KCONTENTFRAME).length > 0) {
- contentElement.children(KOVERLAY).remove();
- }
- });
- this._removeOverlay();
- wrapper.kendoStop().kendoAnimate({
- effects: hideOptions.effects || showOptions.effects,
- reverse: hideOptions.reverse === true,
- duration: hideOptions.duration,
- complete: proxy(this._deactivate, this)
- });
- $(window).off(MODAL_NS);
- }
- if (that.options.isMaximized) {
- that._enableDocumentScrolling();
- if (that._containerScrollTop && that._containerScrollTop > 0) {
- doc.scrollTop(that._containerScrollTop);
- }
- if (that._containerScrollLeft && that._containerScrollLeft > 0) {
- doc.scrollLeft(that._containerScrollLeft);
- }
- }
- },
- _deactivate: function () {
- var that = this;
- that.wrapper.hide().css('opacity', '');
- that.trigger(DEACTIVATE);
- if (that.options.modal) {
- var lastModal = that._object(that._modals().last());
- if (lastModal) {
- lastModal.toFront();
- }
- }
- },
- close: function () {
- this._close(true);
- return this;
- },
- _actionable: function (element) {
- return $(element).is(TITLEBAR_BUTTONS + ',' + TITLEBAR_BUTTONS + ' .k-icon,:input,a');
- },
- _shouldFocus: function (target) {
- var active = activeElement(), element = this.element;
- return this.options.autoFocus && !$(active).is(element) && !this._actionable(target) && (!element.find(active).length || !element.find(target).length);
- },
- toFront: function (e) {
- var that = this, wrapper = that.wrapper, currentWindow = wrapper[0], containmentContext = that.containment && !that._isPinned, zIndex = +wrapper.css(ZINDEX), originalZIndex = zIndex, target = e && e.target || null;
- $(KWINDOW).each(function (i, element) {
- var windowObject = $(element), zIndexNew = windowObject.css(ZINDEX), contentElement = windowObject.children(KWINDOWCONTENT);
- if (!isNaN(zIndexNew)) {
- zIndex = Math.max(+zIndexNew, zIndex);
- }
- contentElement.data('isFront', element == currentWindow);
- if (element != currentWindow && contentElement.find('> .' + KCONTENTFRAME).length > 0) {
- contentElement.append(templates.overlay);
- }
- });
- if (!wrapper[0].style.zIndex || originalZIndex < zIndex) {
- wrapper.css(ZINDEX, zIndex + 2);
- }
- that.element.find('> .k-overlay').remove();
- if (that._shouldFocus(target)) {
- if (that.isMinimized()) {
- that.wrapper.focus();
- } else if ($(target).is(KOVERLAY)) {
- setTimeout(function () {
- that.element.focus();
- });
- } else {
- that.element.focus();
- }
- var scrollTop = containmentContext ? that.containment.scrollTop() : $(window).scrollTop(), windowTop = parseInt(wrapper.position().top, 10);
- if (!that.options.pinned && windowTop > 0 && windowTop < scrollTop) {
- if (scrollTop > 0) {
- $(window).scrollTop(windowTop);
- } else {
- wrapper.css('top', scrollTop);
- }
- }
- }
- wrapper = null;
- return that;
- },
- toggleMaximization: function () {
- if (this._closing) {
- return this;
- }
- return this[this.options.isMaximized ? 'restore' : 'maximize']();
- },
- restore: function () {
- var that = this;
- var options = that.options;
- var minHeight = options.minHeight;
- var restoreOptions = that.restoreOptions;
- var shouldRestrictTop;
- var container = that.containment && !that._isPinned ? that.containment : $(document);
- if (!options.isMaximized && !options.isMinimized) {
- return that;
- }
- if (minHeight && minHeight != Infinity) {
- that.wrapper.css('min-height', minHeight);
- }
- if (restoreOptions && !options.isMaximized) {
- restoreOptions.height = constrain(restoreOptions.height, that.options.minHeight, that.options.maxHeight);
- shouldRestrictTop = options.position.top + parseInt(restoreOptions.height, 10) > that.maxTop;
- if (shouldRestrictTop) {
- options.position.top = constrain(options.position.top, that.minTop, that.maxTop - parseInt(restoreOptions.height, 10));
- extend(restoreOptions, {
- left: options.position.left,
- top: options.position.top
- });
- }
- }
- that.wrapper.css({
- position: options.pinned ? 'fixed' : 'absolute',
- left: restoreOptions.left,
- top: restoreOptions.top,
- width: restoreOptions.width,
- height: restoreOptions.height
- }).removeClass(MAXIMIZEDSTATE).find('.k-window-content,.k-resize-handle').show().end().find('.k-window-titlebar .k-i-window-restore').parent().remove().end().end().find(MINIMIZE_MAXIMIZE).parent().show().end().end().find(PIN_UNPIN).parent().show();
- if (options.isMaximized) {
- that.wrapper.find('.k-i-window-maximize').parent().focus();
- } else if (options.isMinimized) {
- that.wrapper.find('.k-i-window-minimize').parent().focus();
- }
- that.options.width = restoreOptions.width;
- that.options.height = restoreOptions.height;
- if (!that.options.modal.preventScroll) {
- that._enableDocumentScrolling();
- }
- if (that._containerScrollTop && that._containerScrollTop > 0) {
- container.scrollTop(that._containerScrollTop);
- }
- if (that._containerScrollLeft && that._containerScrollLeft > 0) {
- container.scrollLeft(that._containerScrollLeft);
- }
- options.isMaximized = options.isMinimized = false;
- that.wrapper.removeAttr('tabindex');
- that.wrapper.removeAttr('aria-labelled-by');
- that.resize();
- return that;
- },
- _sizingAction: function (actionId, callback) {
- var that = this, wrapper = that.wrapper, style = wrapper[0].style, options = that.options;
- if (options.isMaximized || options.isMinimized) {
- return that;
- }
- that.restoreOptions = {
- width: style.width,
- height: style.height
- };
- wrapper.children(KWINDOWRESIZEHANDLES).hide().end().children(KWINDOWTITLEBAR).find(MINIMIZE_MAXIMIZE).parent().hide().eq(0).before(templates.action({ name: 'window-restore' }));
- callback.call(that);
- that.wrapper.children(KWINDOWTITLEBAR).find(PIN_UNPIN).parent().toggle(actionId !== 'maximize');
- that.trigger(actionId);
- wrapper.find('.k-i-window-restore').parent().focus();
- return that;
- },
- maximize: function () {
- this._sizingAction('maximize', function () {
- var that = this, wrapper = that.wrapper, containmentContext = this.containment && !that._isPinned, position = wrapper.position(), doc = $(document);
- extend(that.restoreOptions, {
- left: position.left + (containmentContext ? this.containment.scrollLeft() : 0),
- top: position.top + (containmentContext ? this.containment.scrollTop() : 0)
- });
- this._containerScrollTop = containmentContext ? this.containment.scrollTop() : doc.scrollTop();
- this._containerScrollLeft = containmentContext ? this.containment.scrollLeft() : doc.scrollLeft();
- that._stopDocumentScrolling();
- wrapper.css({
- top: containmentContext ? this.containment.scrollTop() : 0,
- left: containmentContext ? this.containment.scrollLeft() : 0,
- position: containmentContext ? 'absolute' : 'fixed'
- }).addClass(MAXIMIZEDSTATE);
- that.options.isMaximized = true;
- that._onDocumentResize();
- });
- return this;
- },
- _stopDocumentScrolling: function () {
- var that = this;
- var containment = that.containment;
- if (containment && !that._isPinned) {
- that._storeOverflowRule(containment);
- containment.css(OVERFLOW, HIDDEN);
- that.wrapper.css({
- maxWidth: containment.innerWidth(),
- maxHeight: containment.innerHeight()
- });
- return;
- }
- var $body = $('body');
- that._storeOverflowRule($body);
- $body.css(OVERFLOW, HIDDEN);
- var $html = $('html');
- that._storeOverflowRule($html);
- $html.css(OVERFLOW, HIDDEN);
- },
- _enableDocumentScrolling: function () {
- var that = this;
- var containment = that.containment;
- if (containment && !that._isPinned) {
- that._restoreOverflowRule(containment);
- that.wrapper.css({
- maxWidth: containment.width,
- maxHeight: containment.height
- });
- return;
- }
- that._restoreOverflowRule($(document.body));
- that._restoreOverflowRule($('html'));
- },
- _storeOverflowRule: function ($element) {
- if (this._isOverflowStored($element)) {
- return;
- }
- var overflowRule = $element.get(0).style.overflow;
- if (typeof overflowRule === 'string') {
- $element.data(DATADOCOVERFLOWRULE, overflowRule);
- }
- },
- _isOverflowStored: function ($element) {
- return typeof $element.data(DATADOCOVERFLOWRULE) === 'string';
- },
- _restoreOverflowRule: function ($element) {
- var overflowRule = $element.data(DATADOCOVERFLOWRULE);
- if (overflowRule !== null && overflowRule !== undefined) {
- $element.css(OVERFLOW, overflowRule);
- $element.removeData(DATADOCOVERFLOWRULE);
- } else {
- $element.css(OVERFLOW, '');
- }
- },
- isMaximized: function () {
- return this.options.isMaximized;
- },
- minimize: function () {
- this._sizingAction('minimize', function () {
- var that = this;
- that.wrapper.css({
- height: '',
- minHeight: ''
- });
- that.element.hide();
- that.options.isMinimized = true;
- });
- this.wrapper.attr('tabindex', 0);
- this.wrapper.attr('aria-labelled-by', this.element.attr('aria-labelled-by'));
- this._updateBoundaries();
- return this;
- },
- isMinimized: function () {
- return this.options.isMinimized;
- },
- pin: function () {
- var that = this, win = $(window), wrapper = that.wrapper, options = that.options, position = options.position, top = this.containment ? getPosition(wrapper[0]).top + toInt(this.containment, 'borderTopWidth') : toInt(wrapper, 'top'), left = this.containment ? getPosition(wrapper[0]).left + toInt(this.containment, 'borderLeftWidth') : toInt(wrapper, 'left');
- if (!that.options.isMaximized) {
- position.top = top;
- position.left = left;
- if (!this.containment || this.containment.css('position') !== 'fixed') {
- position.top -= win.scrollTop();
- position.left -= win.scrollLeft();
- }
- wrapper.css(extend(position, { position: 'fixed' }));
- wrapper.children(KWINDOWTITLEBAR).find(KPIN).addClass('k-i-unpin').removeClass('k-i-pin');
- that._isPinned = true;
- that.options.pinned = true;
- if (this.containment) {
- options.maxWidth = options.maxHeight = Infinity;
- wrapper.css({
- maxWidth: '',
- maxHeight: ''
- });
- }
- }
- },
- unpin: function () {
- var that = this, win = $(window), wrapper = that.wrapper, options = that.options, position = that.options.position, containment = that.containment, top = parseInt(wrapper.css('top'), 10) + win.scrollTop(), left = parseInt(wrapper.css('left'), 10) + win.scrollLeft();
- if (!that.options.isMaximized) {
- that._isPinned = false;
- that.options.pinned = false;
- if (containment) {
- that._updateBoundaries();
- options.maxWidth = Math.min(containment.width, options.maxWidth);
- options.maxHeight = Math.min(containment.height - toInt(wrapper, 'padding-top'), options.maxHeight);
- wrapper.css({
- maxWidth: options.maxWidth,
- maxHeight: options.maxHeight
- });
- if (top < containment.position.top) {
- top = that.minTop;
- } else if (top > containment.position.top + containment.height) {
- top = that.maxTop;
- } else {
- top = top + containment.scrollTop() - (containment.position.top + toInt(containment, 'border-top-width'));
- }
- if (left < containment.position.left) {
- left = that.minLeft;
- } else if (left > containment.position.left + containment.width) {
- left = that.maxLeft;
- } else {
- left = left + containment.scrollLeft() - (containment.position.left + toInt(containment, 'border-left-width'));
- }
- }
- position.top = constrain(top, that.minTop, that.maxTop);
- position.left = constrain(left, that.minLeft, that.maxLeft);
- wrapper.css(extend(position, { position: '' }));
- wrapper.children(KWINDOWTITLEBAR).find(KUNPIN).addClass('k-i-pin').removeClass('k-i-unpin');
- }
- },
- _onDocumentResize: function () {
- var that = this, wrapper = that.wrapper, wnd = $(window), zoomLevel = kendo.support.zoomLevel(), contentBoxSizing = wrapper.css('box-sizing') == 'content-box', w, h;
- if (!that.options.isMaximized) {
- return;
- }
- var lrBorderWidth = contentBoxSizing ? toInt(wrapper, 'border-left-width') + toInt(wrapper, 'border-right-width') : 0;
- var tbBorderWidth = contentBoxSizing ? toInt(wrapper, 'border-top-width') + toInt(wrapper, 'border-bottom-width') : 0;
- var paddingTop = contentBoxSizing ? toInt(wrapper, 'padding-top') : 0;
- if (that.containment && !that._isPinned) {
- w = that.containment.innerWidth() - lrBorderWidth;
- h = that.containment.innerHeight() - (tbBorderWidth + paddingTop);
- } else {
- w = wnd.width() / zoomLevel - lrBorderWidth;
- h = wnd.height() / zoomLevel - (tbBorderWidth + paddingTop);
- }
- wrapper.css({
- width: w,
- height: h
- });
- that.options.width = w;
- that.options.height = h;
- that.resize();
- },
- refresh: function (options) {
- var that = this, initOptions = that.options, element = $(that.element), iframe, showIframe, url;
- if (!isPlainObject(options)) {
- options = { url: options };
- }
- options = extend({}, initOptions.content, options);
- showIframe = defined(initOptions.iframe) ? initOptions.iframe : options.iframe;
- url = options.url;
- if (url) {
- if (!defined(showIframe)) {
- showIframe = !isLocalUrl(url);
- }
- if (!showIframe) {
- that._ajaxRequest(options);
- } else {
- iframe = element.find('.' + KCONTENTFRAME)[0];
- if (iframe) {
- iframe.src = url || iframe.src;
- } else {
- element.html(templates.contentFrame(extend({}, initOptions, { content: options })));
- }
- element.find('.' + KCONTENTFRAME).unbind('load' + NS).on('load' + NS, proxy(this._triggerRefresh, this));
- }
- } else {
- if (options.template) {
- that.content(template(options.template)({}));
- }
- that.trigger(REFRESH);
- }
- element.toggleClass('k-window-iframecontent', !!showIframe);
- return that;
- },
- _triggerRefresh: function () {
- this.trigger(REFRESH);
- },
- _ajaxComplete: function () {
- clearTimeout(this._loadingIconTimeout);
- this.wrapper.find(REFRESHICON).removeClass(LOADING);
- },
- _ajaxError: function (xhr, status) {
- this.trigger(ERROR, {
- status: status,
- xhr: xhr
- });
- },
- _ajaxSuccess: function (contentTemplate) {
- return function (data) {
- var html = data;
- if (contentTemplate) {
- html = template(contentTemplate)(data || {});
- }
- this.content(html, data);
- this.element.prop('scrollTop', 0);
- this.trigger(REFRESH);
- };
- },
- _showLoading: function () {
- this.wrapper.find(REFRESHICON).addClass(LOADING);
- },
- _ajaxRequest: function (options) {
- this._loadingIconTimeout = setTimeout(proxy(this._showLoading, this), 100);
- $.ajax(extend({
- type: 'GET',
- dataType: 'html',
- cache: false,
- error: proxy(this._ajaxError, this),
- complete: proxy(this._ajaxComplete, this),
- success: proxy(this._ajaxSuccess(options.template), this)
- }, options));
- },
- _destroy: function () {
- if (this.resizing) {
- this.resizing.destroy();
- }
- if (this.dragging) {
- this.dragging.destroy();
- }
- this.wrapper.off(NS).children(KWINDOWCONTENT).off(NS).end().find('.k-resize-handle,.k-window-titlebar').off(NS);
- $(window).off('resize' + NS + this._marker);
- $(window).off(MODAL_NS);
- $(window).off(NS);
- clearTimeout(this._loadingIconTimeout);
- Widget.fn.destroy.call(this);
- this.unbind(undefined);
- kendo.destroy(this.wrapper);
- this._removeOverlay(true);
- },
- destroy: function () {
- this._destroy();
- this.wrapper.empty().remove();
- this.wrapper = this.appendTo = this.element = $();
- },
- _createWindow: function () {
- var contentHtml = this.element, options = this.options, iframeSrcAttributes, wrapper, isRtl = kendo.support.isRtl(contentHtml);
- if (options.scrollable === false) {
- contentHtml.css('overflow', 'hidden');
- }
- wrapper = $(templates.wrapper(options));
- iframeSrcAttributes = contentHtml.find('iframe:not(.k-content)').map(function () {
- var src = this.getAttribute('src');
- this.src = '';
- return src;
- });
- wrapper.toggleClass('k-rtl', isRtl).append(contentHtml).find('iframe:not(.k-content)').each(function (index) {
- this.src = iframeSrcAttributes[index];
- });
- if (this.containment) {
- this.containment.prepend(wrapper);
- } else if (this.appendTo) {
- wrapper.appendTo(this.appendTo);
- }
- wrapper.find('.k-window-title').css(isRtl ? 'left' : 'right', outerWidth(wrapper.find('.k-window-actions')) + 10);
- contentHtml.css('visibility', '').show();
- contentHtml.find('[data-role=editor]').each(function () {
- var editor = $(this).data('kendoEditor');
- if (editor) {
- editor.refresh();
- }
- });
- wrapper = contentHtml = null;
- }
- });
- templates = {
- wrapper: template('
'),
- action: template('
' + '' + ''),
- titlebar: template('
' + '
#= title #' + '
' + '
'),
- overlay: '
',
- contentFrame: template('
'),
- resizeHandle: template('
')
- };
- function WindowResizing(wnd) {
- var that = this;
- that.owner = wnd;
- that._preventDragging = false;
- that._draggable = new Draggable(wnd.wrapper, {
- filter: '>' + KWINDOWRESIZEHANDLES,
- group: wnd.wrapper.id + '-resizing',
- dragstart: proxy(that.dragstart, that),
- drag: proxy(that.drag, that),
- dragend: proxy(that.dragend, that)
- });
- that._draggable.userEvents.bind('press', proxy(that.addOverlay, that));
- that._draggable.userEvents.bind('release', proxy(that.removeOverlay, that));
- }
- WindowResizing.prototype = {
- addOverlay: function () {
- this.owner.wrapper.append(templates.overlay);
- },
- removeOverlay: function () {
- this.owner.wrapper.find(KOVERLAY).remove();
- },
- dragstart: function (e) {
- var that = this;
- var wnd = that.owner;
- var wrapper = wnd.wrapper;
- that._preventDragging = wnd.trigger(RESIZESTART);
- if (that._preventDragging) {
- return;
- }
- that.elementPadding = parseInt(wrapper.css('padding-top'), 10);
- that.initialPosition = kendo.getOffset(wrapper, 'position');
- that.resizeDirection = e.currentTarget.prop('className').replace('k-resize-handle k-resize-', '');
- that.initialSize = {
- width: wrapper.width(),
- height: wrapper.height()
- };
- wnd._updateBoundaries();
- that.containerOffset = wnd.containment ? wnd.containment.position : kendo.getOffset(wnd.appendTo, 'position');
- var offsetParent = wrapper.offsetParent();
- if (offsetParent.is('html')) {
- that.containerOffset.top = that.containerOffset.left = 0;
- } else {
- var marginTop = offsetParent.css('margin-top');
- var marginLeft = offsetParent.css('margin-left');
- var hasMargin = !zero.test(marginTop) || !zero.test(marginLeft);
- if (hasMargin) {
- var wrapperPosition = getPosition(wrapper[0]);
- var relativeElMarginLeft = wrapperPosition.left - that.containerOffset.left - that.initialPosition.left;
- var relativeElMarginTop = wrapperPosition.top - that.containerOffset.top - that.initialPosition.top;
- that._relativeElMarginLeft = relativeElMarginLeft > 1 ? relativeElMarginLeft : 0;
- that._relativeElMarginTop = relativeElMarginTop > 1 ? relativeElMarginTop : 0;
- that.initialPosition.left += that._relativeElMarginLeft;
- that.initialPosition.top += that._relativeElMarginTop;
- }
- }
- wrapper.children(KWINDOWRESIZEHANDLES).not(e.currentTarget).hide();
- $(BODY).css(CURSOR, e.currentTarget.css(CURSOR));
- },
- drag: function (e) {
- if (this._preventDragging) {
- return;
- }
- var that = this, wnd = that.owner, wrapper = wnd.wrapper, options = wnd.options, position = options.position, direction = that.resizeDirection, containerOffset = that.containerOffset, initialPosition = that.initialPosition, initialSize = that.initialSize, containmentContext = wnd.containment && !wnd._isPinned, rtl = kendo.support.isRtl(wnd.containment), leftRtlOffset = containmentContext && rtl && wnd.containment.innerWidth() > wnd.containment.width ? kendo.support.scrollbar() : 0, scrollOffset = containmentContext ? {
- top: wnd.containment.scrollTop(),
- left: wnd.containment.scrollLeft()
- } : {
- top: 0,
- left: 0
- }, newWidth, newHeight, windowBottom, windowRight, x = Math.max(e.x.location, 0), y = Math.max(e.y.location, 0);
- if (direction.indexOf('e') >= 0) {
- if (wnd.containment && x - initialSize.width >= wnd.maxLeft - scrollOffset.left + containerOffset.left + leftRtlOffset) {
- newWidth = wnd.maxLeft + leftRtlOffset - initialPosition.left + initialSize.width - scrollOffset.left;
- } else {
- newWidth = x - initialPosition.left - containerOffset.left;
- }
- wrapper.width(constrain(newWidth, options.minWidth, options.maxWidth));
- } else if (direction.indexOf('w') >= 0) {
- windowRight = initialPosition.left + initialSize.width + containerOffset.left;
- newWidth = constrain(windowRight - x, options.minWidth, options.maxWidth);
- position.left = windowRight - newWidth - containerOffset.left - leftRtlOffset - (that._relativeElMarginLeft || 0) + scrollOffset.left;
- if (wnd.containment && position.left <= wnd.minLeft) {
- position.left = wnd.minLeft;
- newWidth = constrain(windowRight - leftRtlOffset - position.left - containerOffset.left + scrollOffset.left, options.minWidth, options.maxWidth);
- }
- wrapper.css({
- left: position.left,
- width: newWidth
- });
- }
- var newWindowTop = y;
- if (wnd.options.pinned) {
- newWindowTop -= $(window).scrollTop();
- }
- if (direction.indexOf('s') >= 0) {
- newHeight = newWindowTop - initialPosition.top - that.elementPadding - containerOffset.top;
- if (newWindowTop - initialSize.height - that.elementPadding >= wnd.maxTop + containerOffset.top - scrollOffset.top) {
- newHeight = wnd.maxTop - initialPosition.top + initialSize.height - scrollOffset.top;
- }
- wrapper.height(constrain(newHeight, options.minHeight, options.maxHeight));
- } else if (direction.indexOf('n') >= 0) {
- windowBottom = initialPosition.top + initialSize.height + containerOffset.top;
- newHeight = constrain(windowBottom - newWindowTop, options.minHeight, options.maxHeight);
- position.top = windowBottom - newHeight - containerOffset.top - (that._relativeElMarginTop || 0) + scrollOffset.top;
- if (position.top <= wnd.minTop && wnd.containment) {
- position.top = wnd.minTop;
- newHeight = constrain(windowBottom - position.top - containerOffset.top + scrollOffset.top, options.minHeight, options.maxHeight);
- }
- wrapper.css({
- top: position.top,
- height: newHeight
- });
- }
- if (newWidth) {
- wnd.options.width = newWidth + 'px';
- }
- if (newHeight) {
- wnd.options.height = newHeight + 'px';
- }
- wnd.resize();
- },
- dragend: function (e) {
- if (this._preventDragging) {
- return;
- }
- var that = this, wnd = that.owner, wrapper = wnd.wrapper;
- wrapper.children(KWINDOWRESIZEHANDLES).not(e.currentTarget).show();
- $(BODY).css(CURSOR, '');
- if (wnd.touchScroller) {
- wnd.touchScroller.reset();
- }
- if (e.keyCode == 27) {
- wrapper.css(that.initialPosition).css(that.initialSize);
- }
- wnd.trigger(RESIZEEND);
- return false;
- },
- destroy: function () {
- if (this._draggable) {
- this._draggable.destroy();
- }
- this._draggable = this.owner = null;
- }
- };
- function WindowDragging(wnd, dragHandle) {
- var that = this;
- that.owner = wnd;
- that._preventDragging = false;
- that._draggable = new Draggable(wnd.wrapper, {
- filter: dragHandle,
- group: wnd.wrapper.id + '-moving',
- dragstart: proxy(that.dragstart, that),
- drag: proxy(that.drag, that),
- dragend: proxy(that.dragend, that),
- dragcancel: proxy(that.dragcancel, that)
- });
- that._draggable.userEvents.stopPropagation = false;
- }
- WindowDragging.prototype = {
- dragstart: function (e) {
- var wnd = this.owner, draggable = wnd.options.draggable, element = wnd.element, actions = element.find('.k-window-actions'), containerOffset = kendo.getOffset(wnd.appendTo);
- this._preventDragging = wnd.trigger(DRAGSTART) || !draggable;
- if (this._preventDragging || wnd.isMaximized()) {
- return;
- }
- wnd.initialWindowPosition = kendo.getOffset(wnd.wrapper, 'position');
- wnd.initialPointerPosition = {
- left: wnd.options.position.left,
- top: wnd.options.position.top
- };
- wnd.startPosition = {
- left: e.x.client - wnd.initialWindowPosition.left,
- top: e.y.client - wnd.initialWindowPosition.top
- };
- wnd._updateBoundaries();
- if (!wnd.containment) {
- if (actions.length > 0) {
- wnd.minLeft = outerWidth(actions) + parseInt(actions.css('right'), 10) - outerWidth(element);
- } else {
- wnd.minLeft = 20 - outerWidth(element);
- }
- wnd.minLeft -= containerOffset.left;
- wnd.minTop = -containerOffset.top;
- }
- wnd.wrapper.append(templates.overlay).children(KWINDOWRESIZEHANDLES).hide();
- $(BODY).css(CURSOR, e.currentTarget.css(CURSOR));
- },
- drag: function (e) {
- var wnd = this.owner;
- var position = wnd.options.position;
- var axis = wnd.options.draggable.axis;
- var left;
- var top;
- if (this._preventDragging || wnd.isMaximized()) {
- return;
- }
- if (!axis || axis.toLowerCase() === 'x') {
- left = e.x.client - wnd.startPosition.left;
- if (wnd.containment && !wnd._isPinned) {
- left += wnd.containment.scrollLeft();
- }
- position.left = constrain(left, wnd.minLeft, wnd.maxLeft);
- }
- if (!axis || axis.toLowerCase() === 'y') {
- top = e.y.client - wnd.startPosition.top;
- if (wnd.containment && !wnd._isPinned) {
- top += wnd.containment.scrollTop();
- }
- position.top = constrain(top, wnd.minTop, wnd.maxTop);
- }
- if (kendo.support.transforms) {
- $(wnd.wrapper).css('transform', 'translate(' + (position.left - wnd.initialPointerPosition.left) + 'px, ' + (position.top - wnd.initialPointerPosition.top) + 'px)');
- } else {
- $(wnd.wrapper).css(position);
- }
- },
- _finishDrag: function () {
- var wnd = this.owner;
- wnd.wrapper.children(KWINDOWRESIZEHANDLES).toggle(!wnd.options.isMinimized).end().find(KOVERLAY).remove();
- $(BODY).css(CURSOR, '');
- },
- dragcancel: function (e) {
- if (this._preventDragging) {
- return;
- }
- this._finishDrag();
- e.currentTarget.closest(KWINDOW).css(this.owner.initialWindowPosition);
- },
- dragend: function () {
- var wnd = this.owner;
- if (this._preventDragging || wnd.isMaximized()) {
- return;
- }
- $(wnd.wrapper).css(wnd.options.position).css('transform', '');
- this._finishDrag();
- wnd.trigger(DRAGEND);
- return false;
- },
- destroy: function () {
- if (this._draggable) {
- this._draggable.destroy();
- }
- this._draggable = this.owner = null;
- }
- };
- kendo.ui.plugin(Window);
- }(window.kendo.jQuery));
- return window.kendo;
-}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
- (a3 || a2)();
-}));
\ No newline at end of file
diff --git a/src/assets/theme-assets/js/kendoui_custom.min.js b/src/assets/theme-assets/js/kendoui_custom.min.js
deleted file mode 100644
index 8b9ed85..0000000
--- a/src/assets/theme-assets/js/kendoui_custom.min.js
+++ /dev/null
@@ -1 +0,0 @@
-("function"==typeof define&&define.amd?define:function(e,t,i){(i||t)()})("kendo.core",["jquery"],function(){return function(v,g,N){var e,W=g.kendo=g.kendo||{cultures:{}},c=v.extend,f=v.each,w=v.isArray,t=v.proxy,u=v.noop,b=Math,n=g.JSON||{},m={},h=/%/,i=/\{(\d+)(:[^\}]+)?\}/g,s=/(\d+(?:\.?)\d*)px\s*(\d+(?:\.?)\d*)px\s*(\d+(?:\.?)\d*)px\s*(\d+)?/i,r=/^(\+|-?)\d+(\.?)\d*$/,_="function",y="string",k="number",x="object",C="null",T="boolean",S="undefined",a={},o={},l=[].slice;function d(){}W.version="2019.1.306".replace(/^\s+|\s+$/g,""),d.extend=function(e){var t,i,n=function(){},s=this,r=e&&e.init?e.init:function(){s.apply(this,arguments)};for(t in n.prototype=s.prototype,i=r.fn=r.prototype=new n,e)null!=e[t]&&e[t].constructor===Object?i[t]=c(!0,{},n.prototype[t],e[t]):i[t]=e[t];return(i.constructor=r).extend=s.extend,r},d.prototype._initOptions=function(e){this.options=L({},this.options,e)};var p=W.isFunction=function(e){return"function"==typeof e},I=function(){this._defaultPrevented=!0},D=function(){return!0===this._defaultPrevented},F=d.extend({init:function(){this._events={}},bind:function(e,t,i){var n,s,r,a,o=this,l=typeof e===y?[e]:e,u=typeof t===_;if(t===N){for(n in e)o.bind(n,e[n]);return o}for(n=0,s=l.length;n
|