mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 14:37:02 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
import $ from '$';
|
||||
import _ from '_';
|
||||
import key from 'key';
|
||||
import ko from 'ko';
|
||||
import {EventKeyCode} from 'Common/Enums';
|
||||
import {isArray, inArray, noop, noopTrue} from 'Common/Utils';
|
||||
import { EventKeyCode } from 'Common/Enums';
|
||||
import { isArray, inArray, noop, noopTrue } from 'Common/Utils';
|
||||
|
||||
class Selector
|
||||
{
|
||||
class Selector {
|
||||
list;
|
||||
listChecked;
|
||||
isListChecked;
|
||||
|
|
@ -41,12 +39,18 @@ class Selector
|
|||
* @param {string} sItemCheckedSelector
|
||||
* @param {string} sItemFocusedSelector
|
||||
*/
|
||||
constructor(koList, koSelectedItem, koFocusedItem,
|
||||
sItemSelector, sItemSelectedSelector, sItemCheckedSelector, sItemFocusedSelector)
|
||||
{
|
||||
constructor(
|
||||
koList,
|
||||
koSelectedItem,
|
||||
koFocusedItem,
|
||||
sItemSelector,
|
||||
sItemSelectedSelector,
|
||||
sItemCheckedSelector,
|
||||
sItemFocusedSelector
|
||||
) {
|
||||
this.list = koList;
|
||||
|
||||
this.listChecked = ko.computed(() => _.filter(this.list(), (item) => item.checked())).extend({rateLimit: 0});
|
||||
this.listChecked = ko.computed(() => _.filter(this.list(), (item) => item.checked())).extend({ rateLimit: 0 });
|
||||
this.isListChecked = ko.computed(() => 0 < this.listChecked().length);
|
||||
|
||||
this.focusedItem = koFocusedItem || ko.observable(null);
|
||||
|
|
@ -55,51 +59,37 @@ class Selector
|
|||
this.itemSelectedThrottle = _.debounce(_.bind(this.itemSelected, this), 300);
|
||||
|
||||
this.listChecked.subscribe((items) => {
|
||||
if (0 < items.length)
|
||||
{
|
||||
if (null === this.selectedItem())
|
||||
{
|
||||
if (this.selectedItem.valueHasMutated)
|
||||
{
|
||||
if (0 < items.length) {
|
||||
if (null === this.selectedItem()) {
|
||||
if (this.selectedItem.valueHasMutated) {
|
||||
this.selectedItem.valueHasMutated();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.selectedItem(null);
|
||||
}
|
||||
}
|
||||
else if (this.autoSelect() && this.focusedItem())
|
||||
{
|
||||
} else if (this.autoSelect() && this.focusedItem()) {
|
||||
this.selectedItem(this.focusedItem());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.selectedItem.subscribe((item) => {
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (this.isListChecked())
|
||||
{
|
||||
if (item) {
|
||||
if (this.isListChecked()) {
|
||||
_.each(this.listChecked(), (subItem) => {
|
||||
subItem.checked(false);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.selectedItemUseCallback)
|
||||
{
|
||||
if (this.selectedItemUseCallback) {
|
||||
this.itemSelectedThrottle(item);
|
||||
}
|
||||
}
|
||||
else if (this.selectedItemUseCallback)
|
||||
{
|
||||
} else if (this.selectedItemUseCallback) {
|
||||
this.itemSelected(null);
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
||||
this.selectedItem = this.selectedItem.extend({toggleSubscribeProperty: [this, 'selected']});
|
||||
this.focusedItem = this.focusedItem.extend({toggleSubscribeProperty: [null, 'focused']});
|
||||
this.selectedItem = this.selectedItem.extend({ toggleSubscribeProperty: [this, 'selected'] });
|
||||
this.focusedItem = this.focusedItem.extend({ toggleSubscribeProperty: [null, 'focused'] });
|
||||
|
||||
this.sItemSelector = sItemSelector;
|
||||
this.sItemSelectedSelector = sItemSelectedSelector;
|
||||
|
|
@ -107,87 +97,75 @@ class Selector
|
|||
this.sItemFocusedSelector = sItemFocusedSelector;
|
||||
|
||||
this.focusedItem.subscribe((item) => {
|
||||
if (item)
|
||||
{
|
||||
if (item) {
|
||||
this.sLastUid = this.getItemUid(item);
|
||||
}
|
||||
}, this);
|
||||
|
||||
let
|
||||
aCache = [],
|
||||
let aCache = [],
|
||||
aCheckedCache = [],
|
||||
mFocused = null,
|
||||
mSelected = null;
|
||||
|
||||
this.list.subscribe((items) => {
|
||||
this.list.subscribe(
|
||||
(items) => {
|
||||
if (isArray(items)) {
|
||||
_.each(items, (item) => {
|
||||
if (item) {
|
||||
const uid = this.getItemUid(item);
|
||||
|
||||
if (isArray(items))
|
||||
{
|
||||
_.each(items, (item) => {
|
||||
if (item)
|
||||
{
|
||||
const uid = this.getItemUid(item);
|
||||
|
||||
aCache.push(uid);
|
||||
if (item.checked())
|
||||
{
|
||||
aCheckedCache.push(uid);
|
||||
aCache.push(uid);
|
||||
if (item.checked()) {
|
||||
aCheckedCache.push(uid);
|
||||
}
|
||||
if (null === mFocused && item.focused()) {
|
||||
mFocused = uid;
|
||||
}
|
||||
if (null === mSelected && item.selected()) {
|
||||
mSelected = uid;
|
||||
}
|
||||
}
|
||||
if (null === mFocused && item.focused())
|
||||
{
|
||||
mFocused = uid;
|
||||
}
|
||||
if (null === mSelected && item.selected())
|
||||
{
|
||||
mSelected = uid;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, this, 'beforeChange');
|
||||
});
|
||||
}
|
||||
},
|
||||
this,
|
||||
'beforeChange'
|
||||
);
|
||||
|
||||
this.list.subscribe((aItems) => {
|
||||
|
||||
let
|
||||
temp = null,
|
||||
let temp = null,
|
||||
getNext = false,
|
||||
isNextFocused = mFocused,
|
||||
isChecked = false,
|
||||
isSelected = false,
|
||||
len = 0;
|
||||
|
||||
const
|
||||
uids = [];
|
||||
const uids = [];
|
||||
|
||||
this.selectedItemUseCallback = false;
|
||||
|
||||
this.focusedItem(null);
|
||||
this.selectedItem(null);
|
||||
|
||||
if (isArray(aItems))
|
||||
{
|
||||
if (isArray(aItems)) {
|
||||
len = aCheckedCache.length;
|
||||
|
||||
_.each(aItems, (item) => {
|
||||
|
||||
const uid = this.getItemUid(item);
|
||||
uids.push(uid);
|
||||
|
||||
if (null !== mFocused && mFocused === uid)
|
||||
{
|
||||
if (null !== mFocused && mFocused === uid) {
|
||||
this.focusedItem(item);
|
||||
mFocused = null;
|
||||
}
|
||||
|
||||
if (0 < len && -1 < inArray(uid, aCheckedCache))
|
||||
{
|
||||
if (0 < len && -1 < inArray(uid, aCheckedCache)) {
|
||||
isChecked = true;
|
||||
item.checked(true);
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
if (!isChecked && null !== mSelected && mSelected === uid)
|
||||
{
|
||||
if (!isChecked && null !== mSelected && mSelected === uid) {
|
||||
isSelected = true;
|
||||
this.selectedItem(item);
|
||||
mSelected = null;
|
||||
|
|
@ -196,31 +174,22 @@ class Selector
|
|||
|
||||
this.selectedItemUseCallback = true;
|
||||
|
||||
if (!isChecked && !isSelected && this.autoSelect())
|
||||
{
|
||||
if (this.focusedItem())
|
||||
{
|
||||
if (!isChecked && !isSelected && this.autoSelect()) {
|
||||
if (this.focusedItem()) {
|
||||
this.selectedItem(this.focusedItem());
|
||||
}
|
||||
else if (0 < aItems.length)
|
||||
{
|
||||
if (null !== isNextFocused)
|
||||
{
|
||||
} else if (0 < aItems.length) {
|
||||
if (null !== isNextFocused) {
|
||||
getNext = false;
|
||||
isNextFocused = _.find(aCache, (sUid) => {
|
||||
if (getNext && -1 < inArray(sUid, uids))
|
||||
{
|
||||
if (getNext && -1 < inArray(sUid, uids)) {
|
||||
return sUid;
|
||||
}
|
||||
else if (isNextFocused === sUid)
|
||||
{
|
||||
} else if (isNextFocused === sUid) {
|
||||
getNext = true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (isNextFocused)
|
||||
{
|
||||
if (isNextFocused) {
|
||||
temp = _.find(aItems, (oItem) => isNextFocused === this.getItemUid(oItem));
|
||||
}
|
||||
}
|
||||
|
|
@ -230,23 +199,22 @@ class Selector
|
|||
}
|
||||
}
|
||||
|
||||
if ((0 !== this.iSelectNextHelper || 0 !== this.iFocusedNextHelper) && 0 < aItems.length && !this.focusedItem())
|
||||
{
|
||||
if (
|
||||
(0 !== this.iSelectNextHelper || 0 !== this.iFocusedNextHelper) &&
|
||||
0 < aItems.length &&
|
||||
!this.focusedItem()
|
||||
) {
|
||||
temp = null;
|
||||
if (0 !== this.iFocusedNextHelper)
|
||||
{
|
||||
if (0 !== this.iFocusedNextHelper) {
|
||||
temp = aItems[-1 === this.iFocusedNextHelper ? aItems.length - 1 : 0] || null;
|
||||
}
|
||||
|
||||
if (!temp && 0 !== this.iSelectNextHelper)
|
||||
{
|
||||
if (!temp && 0 !== this.iSelectNextHelper) {
|
||||
temp = aItems[-1 === this.iSelectNextHelper ? aItems.length - 1 : 0] || null;
|
||||
}
|
||||
|
||||
if (temp)
|
||||
{
|
||||
if (0 !== this.iSelectNextHelper)
|
||||
{
|
||||
if (temp) {
|
||||
if (0 !== this.iSelectNextHelper) {
|
||||
this.selectedItem(temp || null);
|
||||
}
|
||||
|
||||
|
|
@ -266,21 +234,15 @@ class Selector
|
|||
aCheckedCache = [];
|
||||
mFocused = null;
|
||||
mSelected = null;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
itemSelected(item) {
|
||||
|
||||
if (this.isListChecked())
|
||||
{
|
||||
if (!item)
|
||||
{
|
||||
if (this.isListChecked()) {
|
||||
if (!item) {
|
||||
(this.oCallbacks.onItemSelect || noop)(item || null);
|
||||
}
|
||||
}
|
||||
else if (item)
|
||||
{
|
||||
} else if (item) {
|
||||
(this.oCallbacks.onItemSelect || noop)(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -305,16 +267,13 @@ class Selector
|
|||
}
|
||||
|
||||
init(contentVisible, contentScrollable, keyScope = 'all') {
|
||||
|
||||
this.oContentVisible = contentVisible;
|
||||
this.oContentScrollable = contentScrollable;
|
||||
|
||||
if (this.oContentVisible && this.oContentScrollable)
|
||||
{
|
||||
if (this.oContentVisible && this.oContentScrollable) {
|
||||
$(this.oContentVisible)
|
||||
.on('selectstart', (event) => {
|
||||
if (event && event.preventDefault)
|
||||
{
|
||||
if (event && event.preventDefault) {
|
||||
event.preventDefault();
|
||||
}
|
||||
})
|
||||
|
|
@ -323,14 +282,10 @@ class Selector
|
|||
})
|
||||
.on('click', this.sItemCheckedSelector, (event) => {
|
||||
const item = ko.dataFor(event.currentTarget);
|
||||
if (item)
|
||||
{
|
||||
if (event && event.shiftKey)
|
||||
{
|
||||
if (item) {
|
||||
if (event && event.shiftKey) {
|
||||
this.actionClick(item, event);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.focusedItem(item);
|
||||
item.checked(!item.checked());
|
||||
}
|
||||
|
|
@ -338,8 +293,7 @@ class Selector
|
|||
});
|
||||
|
||||
key('enter', keyScope, () => {
|
||||
if (this.focusedItem() && !this.focusedItem().selected())
|
||||
{
|
||||
if (this.focusedItem() && !this.focusedItem().selected()) {
|
||||
this.actionClick(this.focusedItem());
|
||||
return false;
|
||||
}
|
||||
|
|
@ -350,11 +304,9 @@ class Selector
|
|||
key('ctrl+up, command+up, ctrl+down, command+down', keyScope, () => false);
|
||||
|
||||
key('up, shift+up, down, shift+down, home, end, pageup, pagedown, insert, space', keyScope, (event, handler) => {
|
||||
if (event && handler && handler.shortcut)
|
||||
{
|
||||
if (event && handler && handler.shortcut) {
|
||||
let eventKey = 0;
|
||||
switch (handler.shortcut)
|
||||
{
|
||||
switch (handler.shortcut) {
|
||||
case 'up':
|
||||
case 'shift+up':
|
||||
eventKey = EventKeyCode.Up;
|
||||
|
|
@ -384,8 +336,7 @@ class Selector
|
|||
// no default
|
||||
}
|
||||
|
||||
if (0 < eventKey)
|
||||
{
|
||||
if (0 < eventKey) {
|
||||
this.newSelectPosition(eventKey, key.shift);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -415,12 +366,10 @@ class Selector
|
|||
* @returns {string}
|
||||
*/
|
||||
getItemUid(item) {
|
||||
|
||||
let uid = '';
|
||||
|
||||
const getItemUidCallback = this.oCallbacks.onItemGetUid || null;
|
||||
if (getItemUidCallback && item)
|
||||
{
|
||||
if (getItemUidCallback && item) {
|
||||
uid = getItemUidCallback(item);
|
||||
}
|
||||
|
||||
|
|
@ -433,64 +382,56 @@ class Selector
|
|||
* @param {boolean=} bForceSelect = false
|
||||
*/
|
||||
newSelectPosition(iEventKeyCode, bShiftKey, bForceSelect) {
|
||||
|
||||
let
|
||||
index = 0,
|
||||
let index = 0,
|
||||
isNext = false,
|
||||
isStop = false,
|
||||
result = null;
|
||||
|
||||
const
|
||||
pageStep = 10,
|
||||
const pageStep = 10,
|
||||
list = this.list(),
|
||||
listLen = list ? list.length : 0,
|
||||
focused = this.focusedItem();
|
||||
|
||||
if (0 < listLen)
|
||||
{
|
||||
if (!focused)
|
||||
{
|
||||
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Insert === iEventKeyCode ||
|
||||
EventKeyCode.Space === iEventKeyCode || EventKeyCode.Home === iEventKeyCode ||
|
||||
EventKeyCode.PageUp === iEventKeyCode)
|
||||
{
|
||||
if (0 < listLen) {
|
||||
if (!focused) {
|
||||
if (
|
||||
EventKeyCode.Down === iEventKeyCode ||
|
||||
EventKeyCode.Insert === iEventKeyCode ||
|
||||
EventKeyCode.Space === iEventKeyCode ||
|
||||
EventKeyCode.Home === iEventKeyCode ||
|
||||
EventKeyCode.PageUp === iEventKeyCode
|
||||
) {
|
||||
result = list[0];
|
||||
}
|
||||
else if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.End === iEventKeyCode ||
|
||||
EventKeyCode.PageDown === iEventKeyCode)
|
||||
{
|
||||
} else if (
|
||||
EventKeyCode.Up === iEventKeyCode ||
|
||||
EventKeyCode.End === iEventKeyCode ||
|
||||
EventKeyCode.PageDown === iEventKeyCode
|
||||
) {
|
||||
result = list[list.length - 1];
|
||||
}
|
||||
}
|
||||
else if (focused)
|
||||
{
|
||||
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode ||
|
||||
EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||
{
|
||||
} else if (focused) {
|
||||
if (
|
||||
EventKeyCode.Down === iEventKeyCode ||
|
||||
EventKeyCode.Up === iEventKeyCode ||
|
||||
EventKeyCode.Insert === iEventKeyCode ||
|
||||
EventKeyCode.Space === iEventKeyCode
|
||||
) {
|
||||
_.each(list, (item) => {
|
||||
if (!isStop)
|
||||
{
|
||||
switch (iEventKeyCode)
|
||||
{
|
||||
if (!isStop) {
|
||||
switch (iEventKeyCode) {
|
||||
case EventKeyCode.Up:
|
||||
if (focused === item)
|
||||
{
|
||||
if (focused === item) {
|
||||
isStop = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
result = item;
|
||||
}
|
||||
break;
|
||||
case EventKeyCode.Down:
|
||||
case EventKeyCode.Insert:
|
||||
if (isNext)
|
||||
{
|
||||
if (isNext) {
|
||||
result = item;
|
||||
isStop = true;
|
||||
}
|
||||
else if (focused === item)
|
||||
{
|
||||
} else if (focused === item) {
|
||||
isNext = true;
|
||||
}
|
||||
break;
|
||||
|
|
@ -499,41 +440,27 @@ class Selector
|
|||
}
|
||||
});
|
||||
|
||||
if (!result && (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode))
|
||||
{
|
||||
if (!result && (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode)) {
|
||||
this.doUpUpOrDownDown(EventKeyCode.Up === iEventKeyCode);
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.Home === iEventKeyCode || EventKeyCode.End === iEventKeyCode)
|
||||
{
|
||||
if (EventKeyCode.Home === iEventKeyCode)
|
||||
{
|
||||
} else if (EventKeyCode.Home === iEventKeyCode || EventKeyCode.End === iEventKeyCode) {
|
||||
if (EventKeyCode.Home === iEventKeyCode) {
|
||||
result = list[0];
|
||||
}
|
||||
else if (EventKeyCode.End === iEventKeyCode)
|
||||
{
|
||||
} else if (EventKeyCode.End === iEventKeyCode) {
|
||||
result = list[list.length - 1];
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.PageDown === iEventKeyCode)
|
||||
{
|
||||
for (; index < listLen; index++)
|
||||
{
|
||||
if (focused === list[index])
|
||||
{
|
||||
} else if (EventKeyCode.PageDown === iEventKeyCode) {
|
||||
for (; index < listLen; index++) {
|
||||
if (focused === list[index]) {
|
||||
index += pageStep;
|
||||
index = listLen - 1 < index ? listLen - 1 : index;
|
||||
result = list[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.PageUp === iEventKeyCode)
|
||||
{
|
||||
for (index = listLen; 0 <= index; index--)
|
||||
{
|
||||
if (focused === list[index])
|
||||
{
|
||||
} else if (EventKeyCode.PageUp === iEventKeyCode) {
|
||||
for (index = listLen; 0 <= index; index--) {
|
||||
if (focused === list[index]) {
|
||||
index -= pageStep;
|
||||
index = 0 > index ? 0 : index;
|
||||
result = list[index];
|
||||
|
|
@ -544,41 +471,28 @@ class Selector
|
|||
}
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
if (result) {
|
||||
this.focusedItem(result);
|
||||
|
||||
if (focused)
|
||||
{
|
||||
if (bShiftKey)
|
||||
{
|
||||
if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode)
|
||||
{
|
||||
if (focused) {
|
||||
if (bShiftKey) {
|
||||
if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode) {
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||
{
|
||||
} else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode) {
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
}
|
||||
|
||||
if ((this.autoSelect() || !!bForceSelect) &&
|
||||
!this.isListChecked() && EventKeyCode.Space !== iEventKeyCode)
|
||||
{
|
||||
if ((this.autoSelect() || !!bForceSelect) && !this.isListChecked() && EventKeyCode.Space !== iEventKeyCode) {
|
||||
this.selectedItem(result);
|
||||
}
|
||||
|
||||
this.scrollToFocused();
|
||||
}
|
||||
else if (focused)
|
||||
{
|
||||
if (bShiftKey && (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode))
|
||||
{
|
||||
} else if (focused) {
|
||||
if (bShiftKey && (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode)) {
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||
{
|
||||
} else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode) {
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
|
||||
|
|
@ -590,30 +504,25 @@ class Selector
|
|||
* @returns {boolean}
|
||||
*/
|
||||
scrollToFocused() {
|
||||
|
||||
if (!this.oContentVisible || !this.oContentScrollable)
|
||||
{
|
||||
if (!this.oContentVisible || !this.oContentScrollable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const
|
||||
offset = 20,
|
||||
const offset = 20,
|
||||
list = this.list(),
|
||||
$focused = $(this.sItemFocusedSelector, this.oContentScrollable),
|
||||
pos = $focused.position(),
|
||||
visibleHeight = this.oContentVisible.height(),
|
||||
focusedHeight = $focused.outerHeight();
|
||||
|
||||
if (list && list[0] && list[0].focused())
|
||||
{
|
||||
if (list && list[0] && list[0].focused()) {
|
||||
this.oContentScrollable.scrollTop(0);
|
||||
return true;
|
||||
}
|
||||
else if (pos && (0 > pos.top || pos.top + focusedHeight > visibleHeight))
|
||||
{
|
||||
this.oContentScrollable.scrollTop(0 > pos.top ?
|
||||
this.oContentScrollable.scrollTop() + pos.top - offset :
|
||||
this.oContentScrollable.scrollTop() + pos.top - visibleHeight + focusedHeight + offset
|
||||
} else if (pos && (0 > pos.top || pos.top + focusedHeight > visibleHeight)) {
|
||||
this.oContentScrollable.scrollTop(
|
||||
0 > pos.top
|
||||
? this.oContentScrollable.scrollTop() + pos.top - offset
|
||||
: this.oContentScrollable.scrollTop() + pos.top - visibleHeight + focusedHeight + offset
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
@ -627,28 +536,21 @@ class Selector
|
|||
* @returns {boolean}
|
||||
*/
|
||||
scrollToTop(fast = false) {
|
||||
|
||||
if (!this.oContentVisible || !this.oContentScrollable)
|
||||
{
|
||||
if (!this.oContentVisible || !this.oContentScrollable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fast || 50 > this.oContentScrollable.scrollTop())
|
||||
{
|
||||
if (fast || 50 > this.oContentScrollable.scrollTop()) {
|
||||
this.oContentScrollable.scrollTop(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.oContentScrollable.stop().animate({scrollTop: 0}, 200);
|
||||
} else {
|
||||
this.oContentScrollable.stop().animate({ scrollTop: 0 }, 200);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
eventClickFunction(item, event) {
|
||||
|
||||
let
|
||||
index = 0,
|
||||
let index = 0,
|
||||
length = 0,
|
||||
changeRange = false,
|
||||
isInRange = false,
|
||||
|
|
@ -658,31 +560,25 @@ class Selector
|
|||
lineUid = '';
|
||||
|
||||
const uid = this.getItemUid(item);
|
||||
if (event && event.shiftKey)
|
||||
{
|
||||
if ('' !== uid && '' !== this.sLastUid && uid !== this.sLastUid)
|
||||
{
|
||||
if (event && event.shiftKey) {
|
||||
if ('' !== uid && '' !== this.sLastUid && uid !== this.sLastUid) {
|
||||
list = this.list();
|
||||
checked = item.checked();
|
||||
|
||||
for (index = 0, length = list.length; index < length; index++)
|
||||
{
|
||||
for (index = 0, length = list.length; index < length; index++) {
|
||||
listItem = list[index];
|
||||
lineUid = this.getItemUid(listItem);
|
||||
|
||||
changeRange = false;
|
||||
if (lineUid === this.sLastUid || lineUid === uid)
|
||||
{
|
||||
if (lineUid === this.sLastUid || lineUid === uid) {
|
||||
changeRange = true;
|
||||
}
|
||||
|
||||
if (changeRange)
|
||||
{
|
||||
if (changeRange) {
|
||||
isInRange = !isInRange;
|
||||
}
|
||||
|
||||
if (isInRange || changeRange)
|
||||
{
|
||||
if (isInRange || changeRange) {
|
||||
listItem.checked(checked);
|
||||
}
|
||||
}
|
||||
|
|
@ -697,17 +593,12 @@ class Selector
|
|||
* @param {Object=} event
|
||||
*/
|
||||
actionClick(item, event = null) {
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (item) {
|
||||
let click = true;
|
||||
if (event)
|
||||
{
|
||||
if (event.shiftKey && !(event.ctrlKey || event.metaKey) && !event.altKey)
|
||||
{
|
||||
if (event) {
|
||||
if (event.shiftKey && !(event.ctrlKey || event.metaKey) && !event.altKey) {
|
||||
click = false;
|
||||
if ('' === this.sLastUid)
|
||||
{
|
||||
if ('' === this.sLastUid) {
|
||||
this.sLastUid = this.getItemUid(item);
|
||||
}
|
||||
|
||||
|
|
@ -715,14 +606,11 @@ class Selector
|
|||
this.eventClickFunction(item, event);
|
||||
|
||||
this.focusedItem(item);
|
||||
}
|
||||
else if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey)
|
||||
{
|
||||
} else if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey) {
|
||||
click = false;
|
||||
this.focusedItem(item);
|
||||
|
||||
if (this.selectedItem() && item !== this.selectedItem())
|
||||
{
|
||||
if (this.selectedItem() && item !== this.selectedItem()) {
|
||||
this.selectedItem().checked(true);
|
||||
}
|
||||
|
||||
|
|
@ -730,8 +618,7 @@ class Selector
|
|||
}
|
||||
}
|
||||
|
||||
if (click)
|
||||
{
|
||||
if (click) {
|
||||
this.selectMessageItem(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -748,4 +635,4 @@ class Selector
|
|||
}
|
||||
}
|
||||
|
||||
export {Selector, Selector as default};
|
||||
export { Selector, Selector as default };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue