@inboxsdk/core 0.2.28-alpha.2 → 0.2.28-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/inboxsdk.js +1 -1
- package/inboxsdk.js.map +1 -1
- package/package.json +1 -1
- package/src/build/exec.js +26 -0
- package/src/build/spawn.js +17 -0
- package/src/common/ajax.js +90 -0
- package/src/common/cachebust-url.js +10 -0
- package/src/common/censorHTMLstring.js +37 -0
- package/src/common/censorHTMLtree.js +28 -0
- package/src/common/censorJSONTree.js +15 -0
- package/src/common/connectivity-test.js +21 -0
- package/src/common/defer.js +11 -0
- package/src/common/find-parent.js +10 -0
- package/src/common/get-extension-id.js +7 -0
- package/src/common/get-or-fail.js +8 -0
- package/src/common/get-session-id.js +14 -0
- package/src/common/get-stack-trace.js +6 -0
- package/src/common/html-to-text.js +7 -0
- package/src/common/isElementVisible.js +6 -0
- package/src/common/load-script.js +127 -0
- package/src/common/log-error.js +191 -0
- package/src/common/quoted-split.js +18 -0
- package/src/common/rate-limit-queuer.js +57 -0
- package/src/common/rate-limit.js +14 -0
- package/src/common/version.js +6 -0
- package/src/inboxsdk-js/loading/platform-implementation-loader.js +27 -0
- package/src/inboxsdk.d.ts +2 -0
- package/src/injected-js/gmail/constants.js +2 -0
- package/src/injected-js/gmail/modify-suggestions.js +106 -0
- package/src/injected-js/gmail/setup-gmonkey-handler.js +49 -0
- package/src/injected-js/gmail/sync-compose-processor-20220909.js +298 -0
- package/src/injected-js/gmail/sync-compose-processor.js +55 -0
- package/src/injected-js/gmail/sync-compose-request-processor.js +110 -0
- package/src/injected-js/injected-logger.js +50 -0
- package/src/injected-js/setupCustomViewEventAssassin.js +90 -0
- package/src/platform-implementation-js/constants/nav-item-types.js +19 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-app-menu-item.js +21 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-collapsible-panel.js +28 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-nav-item.js +98 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-support-item.js +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/encodeDraftUrlId.js +8 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-rfc-message-id-for-gmail-message-id.js +12 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-rfc-message-id-for-gmail-thread-id.js +33 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/isIntegratedViewGmail.js +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-draft-by-message-id.js +44 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-gmail-styles.js +95 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter/get-main-content-element-changed-stream.js +38 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter/wait-for-gmail-mode-to-settle.js +12 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter.js +253 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-page-communicator.js +200 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-response-processor.js +533 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-sync-response-processor.js +289 -0
- package/src/platform-implementation-js/dom-driver/gmail/is-compose-titlebar-light-color.js +21 -0
- package/src/platform-implementation-js/dom-driver/gmail/makePageParserTree.js +28 -0
- package/src/platform-implementation-js/dom-driver/gmail/pageParserOptions.js +19 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-menu-item-view.js +126 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-status-bar.js +101 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/detectClassicRecipientsArea.js +38 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-address-information-extractor.js +28 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-recipients.js +22 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/gmail-compose-button-view.js +233 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/page-parser.js +223 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/set-recipients.js +157 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/setupLinkPopovers.js +109 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view/attachment-icon.js +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-nav-item-view.js +759 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-support-item-view.js +84 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/button-color-classes.js +33 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/button-view.js +325 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/create-accessory-button-view.js +58 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/create-parent-accessory-button-view.js +55 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/modal-button-view.js +96 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/more-dropdown-button-view.js +30 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/more-parent-accessory-button-view.js +10 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-dropdown-view.js +22 -0
- package/src/platform-implementation-js/driver-common/getAccountUrlPart.js +17 -0
- package/src/platform-implementation-js/driver-common/getOriginalMessagePage.js +33 -0
- package/src/platform-implementation-js/driver-common/getSyncThreadsForSearch.js +49 -0
- package/src/platform-implementation-js/driver-common/gmailAjax.js +65 -0
- package/src/platform-implementation-js/driver-common/render-custom-icon.js +16 -0
- package/src/platform-implementation-js/driver-common/update-icon.js +90 -0
- package/src/platform-implementation-js/lib/ErrorCollector.js +47 -0
- package/src/platform-implementation-js/lib/Membrane.js +22 -0
- package/src/platform-implementation-js/lib/ScrollableContainByScreen.js +30 -0
- package/src/platform-implementation-js/lib/attemptWithRetries.js +16 -0
- package/src/platform-implementation-js/lib/common-page-communicator.js +137 -0
- package/src/platform-implementation-js/lib/delay-asap.js +12 -0
- package/src/platform-implementation-js/lib/delay-idle.js +16 -0
- package/src/platform-implementation-js/lib/dom/block-and-reemit-keyboard-events.js +36 -0
- package/src/platform-implementation-js/lib/dom/generic-button-view.js +39 -0
- package/src/platform-implementation-js/lib/dom/get-insert-before-element.js +39 -0
- package/src/platform-implementation-js/lib/dom/insert-element-in-order.js +38 -0
- package/src/platform-implementation-js/lib/dom/keyboard-shortcut-stream.js +12 -0
- package/src/platform-implementation-js/lib/dom/make-element-child-stream.js +79 -0
- package/src/platform-implementation-js/lib/dom/make-element-stream-merger.js +28 -0
- package/src/platform-implementation-js/lib/dom/make-element-view-stream.js +15 -0
- package/src/platform-implementation-js/lib/dom/make-mutation-observer-chunked-stream.js +15 -0
- package/src/platform-implementation-js/lib/dom/make-mutation-observer-stream.js +5 -0
- package/src/platform-implementation-js/lib/dom/outsideClicksAndEscape.js +39 -0
- package/src/platform-implementation-js/lib/dom/parentNodes.js +8 -0
- package/src/platform-implementation-js/lib/dom/querySelectorOrFail.js +6 -0
- package/src/platform-implementation-js/lib/dom/reemitClickEventForReact.js +22 -0
- package/src/platform-implementation-js/lib/dom/simulate-key.js +46 -0
- package/src/platform-implementation-js/lib/dom/simulate-mouse-event.js +16 -0
- package/src/platform-implementation-js/lib/dom/trigger-relay-event.js +7 -0
- package/src/platform-implementation-js/lib/extract-contact-from-email-contact-string.js +25 -0
- package/src/platform-implementation-js/lib/fake-window-resize.js +5 -0
- package/src/platform-implementation-js/lib/from-event-target-capture.js +12 -0
- package/src/platform-implementation-js/lib/fromEventsWithOptions.js +10 -0
- package/src/platform-implementation-js/lib/handler-registry.js +67 -0
- package/src/platform-implementation-js/lib/idMap.js +45 -0
- package/src/platform-implementation-js/lib/imageRequest.js +8 -0
- package/src/platform-implementation-js/lib/incrementName.js +7 -0
- package/src/platform-implementation-js/lib/inject-script-EMBEDDED.js +14 -0
- package/src/platform-implementation-js/lib/inject-script.js +33 -0
- package/src/platform-implementation-js/lib/is-valid-app-id.js +27 -0
- package/src/platform-implementation-js/lib/is-valid-email.js +14 -0
- package/src/platform-implementation-js/lib/isNotNil.js +5 -0
- package/src/platform-implementation-js/lib/isStreakAppId.js +11 -0
- package/src/platform-implementation-js/lib/logger.js +441 -0
- package/src/platform-implementation-js/lib/persistent-queue.js +107 -0
- package/src/platform-implementation-js/lib/safe-event-emitter.js +17 -0
- package/src/platform-implementation-js/lib/stopper-pool.js +41 -0
- package/src/platform-implementation-js/lib/stream-wait-for.js +30 -0
- package/src/platform-implementation-js/lib/wait-for.js +28 -0
- package/src/platform-implementation-js/lib/waitForAsync.js +19 -0
- package/src/platform-implementation-js/namespaces/app-menu.d.ts.map +1 -1
- package/src/platform-implementation-js/namespaces/app-menu.js +31 -0
- package/src/platform-implementation-js/namespaces/butter-bar.js +163 -0
- package/src/platform-implementation-js/views/SimpleElementView.js +16 -0
- package/src/platform-implementation-js/views/app-menu-item-view.js +257 -0
- package/src/platform-implementation-js/views/collapsible-panel-view.js +222 -0
- package/src/platform-implementation-js/views/compose-button-view.js +45 -0
- package/src/platform-implementation-js/views/compose-view.js +312 -0
- package/src/platform-implementation-js/views/keyboard-shortcut-handle.js +14 -0
- package/src/platform-implementation-js/widgets/buttons/basic-button-view-controller.js +39 -0
- package/src/platform-implementation-js/widgets/buttons/dropdown-button-view-controller.js +98 -0
- package/src/platform-implementation-js/widgets/buttons/dropdown-view.js +122 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import kefirStopper from 'kefir-stopper';
|
|
2
|
+
export default class GmailSupportItemView {
|
|
3
|
+
_stopper = kefirStopper();
|
|
4
|
+
_driver;
|
|
5
|
+
_insertElementContainer = null;
|
|
6
|
+
constructor(driver, supportItemDescriptor) {
|
|
7
|
+
this._driver = driver;
|
|
8
|
+
this._setup(supportItemDescriptor);
|
|
9
|
+
}
|
|
10
|
+
destroy() {
|
|
11
|
+
this._stopper.destroy();
|
|
12
|
+
if (this._insertElementContainer) {
|
|
13
|
+
this._insertElementContainer.remove();
|
|
14
|
+
this._insertElementContainer = null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
_setup(supportItemDescriptor) {
|
|
18
|
+
const supportMenuNodes = this._driver
|
|
19
|
+
.getTagTree()
|
|
20
|
+
.getAllByTag('supportMenu');
|
|
21
|
+
const subscription = supportMenuNodes.subscribe((changes) => {
|
|
22
|
+
changes.forEach((change) => {
|
|
23
|
+
if (change.type === 'add') {
|
|
24
|
+
this._addSupportElement(change.value.getValue(), supportItemDescriptor);
|
|
25
|
+
}
|
|
26
|
+
else if (change.type === 'remove') {
|
|
27
|
+
if (this._insertElementContainer) {
|
|
28
|
+
this._insertElementContainer.remove();
|
|
29
|
+
this._insertElementContainer = null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
this._stopper.onValue(() => subscription.unsubscribe());
|
|
35
|
+
}
|
|
36
|
+
_addSupportElement(supportElement, supportItemDescriptor) {
|
|
37
|
+
const insertElementContainer = document.createElement('div');
|
|
38
|
+
const menuItemAttributes = supportElement.children.item(0).attributes;
|
|
39
|
+
for (const attribute of menuItemAttributes) {
|
|
40
|
+
if (attribute.name === 'aria-label') {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (attribute.name === 'class') {
|
|
44
|
+
const classes = `${attribute.value} inboxsdk__support_menuItem`;
|
|
45
|
+
insertElementContainer.setAttribute(attribute.name, classes);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
insertElementContainer.setAttribute(attribute.name, attribute.value);
|
|
49
|
+
}
|
|
50
|
+
// Append to-be-inserted element
|
|
51
|
+
insertElementContainer.append(supportItemDescriptor.element);
|
|
52
|
+
// Adjust insert position to always be the last one before separator
|
|
53
|
+
let lastSeparatorItem = null;
|
|
54
|
+
for (const item of supportElement.children) {
|
|
55
|
+
if (item.getAttribute('role') === 'separator') {
|
|
56
|
+
lastSeparatorItem = item;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (lastSeparatorItem) {
|
|
60
|
+
lastSeparatorItem.insertAdjacentElement('beforebegin', insertElementContainer);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
supportElement.append(insertElementContainer);
|
|
64
|
+
}
|
|
65
|
+
insertElementContainer.onclick = (event) => {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
supportItemDescriptor.onClick();
|
|
69
|
+
this._closeSupportMenu(supportElement);
|
|
70
|
+
};
|
|
71
|
+
insertElementContainer.onkeypress = (event) => {
|
|
72
|
+
if (event.key === 'Enter') {
|
|
73
|
+
supportItemDescriptor.onClick();
|
|
74
|
+
this._closeSupportMenu(supportElement);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
_closeSupportMenu(supportElement) {
|
|
79
|
+
if (supportElement.getAttribute('aria-hidden') != 'true') {
|
|
80
|
+
const button = supportElement.previousElementSibling;
|
|
81
|
+
button && button.click();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/button-color-classes.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const ButtonColorClasses = {
|
|
2
|
+
default: {
|
|
3
|
+
INACTIVE_CLASS: 'T-I-ax7',
|
|
4
|
+
HOVER_CLASS: 'T-I-JW',
|
|
5
|
+
ACTIVE_CLASS: 'T-I-Kq',
|
|
6
|
+
},
|
|
7
|
+
flatIcon: {
|
|
8
|
+
INACTIVE_CLASS: 'J-Z-I',
|
|
9
|
+
HOVER_CLASS: 'J-Z-I-JW',
|
|
10
|
+
ACTIVE_CLASS: 'J-Z-I-KO',
|
|
11
|
+
},
|
|
12
|
+
pureIcon: {
|
|
13
|
+
INACTIVE_CLASS: 'inboxsdk__button_pureIcon_inactive',
|
|
14
|
+
HOVER_CLASS: 'inboxsdk__button_pureIcon_hover',
|
|
15
|
+
ACTIVE_CLASS: 'inboxsdk__button_pureIcon_active',
|
|
16
|
+
},
|
|
17
|
+
blue: {
|
|
18
|
+
INACTIVE_CLASS: 'T-I-atl',
|
|
19
|
+
HOVER_CLASS: 'T-I-JW',
|
|
20
|
+
ACTIVE_CLASS: 'T-I-JO',
|
|
21
|
+
},
|
|
22
|
+
red: {
|
|
23
|
+
INACTIVE_CLASS: 'T-I-KE',
|
|
24
|
+
HOVER_CLASS: 'T-I-JW',
|
|
25
|
+
ACTIVE_CLASS: 'T-I-JO',
|
|
26
|
+
},
|
|
27
|
+
green: {
|
|
28
|
+
INACTIVE_CLASS: 'inboxsdk__button_green_inactive',
|
|
29
|
+
HOVER_CLASS: 'inboxsdk__button_green_hover',
|
|
30
|
+
ACTIVE_CLASS: 'inboxsdk__button_green_active',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export default ButtonColorClasses;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import includes from 'lodash/includes';
|
|
2
|
+
import * as Kefir from 'kefir';
|
|
3
|
+
import kefirBus from 'kefir-bus';
|
|
4
|
+
import Logger from '../../../../lib/logger';
|
|
5
|
+
import { simulateHover } from '../../../../lib/dom/simulate-mouse-event';
|
|
6
|
+
import keyboardShortcutStream from '../../../../lib/dom/keyboard-shortcut-stream';
|
|
7
|
+
import BUTTON_COLOR_CLASSES from './button-color-classes';
|
|
8
|
+
export default class ButtonView {
|
|
9
|
+
_element = document.createElement('div');
|
|
10
|
+
_innerElement = document.createElement('div');
|
|
11
|
+
_textElement;
|
|
12
|
+
_iconElement;
|
|
13
|
+
_iconImgElement;
|
|
14
|
+
_iconClass;
|
|
15
|
+
_iconUrl;
|
|
16
|
+
_title;
|
|
17
|
+
_tooltip;
|
|
18
|
+
_hasDropdown;
|
|
19
|
+
_buttonColor;
|
|
20
|
+
_isEnabled;
|
|
21
|
+
_keyboardShortcutHandle;
|
|
22
|
+
_eventStream;
|
|
23
|
+
constructor(options) {
|
|
24
|
+
this._hasDropdown = false;
|
|
25
|
+
this._isEnabled = options.enabled !== false;
|
|
26
|
+
this._iconClass = options.iconClass;
|
|
27
|
+
this._iconUrl = options.iconUrl;
|
|
28
|
+
this._title = options.text || options.title;
|
|
29
|
+
this._tooltip = options.tooltip || options.title;
|
|
30
|
+
this._hasDropdown = !!options.hasDropdown;
|
|
31
|
+
this._buttonColor = options.buttonColor || 'default';
|
|
32
|
+
this._keyboardShortcutHandle = options.keyboardShortcutHandle;
|
|
33
|
+
this._createElement(options);
|
|
34
|
+
this._eventStream = kefirBus();
|
|
35
|
+
this._setupEventStream();
|
|
36
|
+
this._setupAestheticEvents();
|
|
37
|
+
if (options.enabled !== false) {
|
|
38
|
+
this._setupKeyboardShortcutEvent();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
destroy() {
|
|
42
|
+
this._element.remove();
|
|
43
|
+
this._eventStream.end();
|
|
44
|
+
}
|
|
45
|
+
getElement() {
|
|
46
|
+
return this._element;
|
|
47
|
+
}
|
|
48
|
+
getEventStream() {
|
|
49
|
+
return this._eventStream;
|
|
50
|
+
}
|
|
51
|
+
activate() {
|
|
52
|
+
this.addClass(BUTTON_COLOR_CLASSES[this._buttonColor].ACTIVE_CLASS);
|
|
53
|
+
this.addClass(BUTTON_COLOR_CLASSES[this._buttonColor].HOVER_CLASS);
|
|
54
|
+
}
|
|
55
|
+
deactivate() {
|
|
56
|
+
this.removeClass(BUTTON_COLOR_CLASSES[this._buttonColor].ACTIVE_CLASS);
|
|
57
|
+
this.removeClass(BUTTON_COLOR_CLASSES[this._buttonColor].HOVER_CLASS);
|
|
58
|
+
}
|
|
59
|
+
addClass(className) {
|
|
60
|
+
this._element.classList.add(className);
|
|
61
|
+
}
|
|
62
|
+
removeClass(className) {
|
|
63
|
+
this._element.classList.remove(className);
|
|
64
|
+
}
|
|
65
|
+
simulateHover() {
|
|
66
|
+
simulateHover(this._element);
|
|
67
|
+
}
|
|
68
|
+
setEnabled(value) {
|
|
69
|
+
this._setEnabled(value);
|
|
70
|
+
}
|
|
71
|
+
isEnabled() {
|
|
72
|
+
return this._isEnabled;
|
|
73
|
+
}
|
|
74
|
+
update(options) {
|
|
75
|
+
if (!options) {
|
|
76
|
+
this._element.style.display = 'none';
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
else if (this._element.style.display === 'none') {
|
|
80
|
+
this._element.style.display = '';
|
|
81
|
+
}
|
|
82
|
+
if (options.buttonColor != this._buttonColor && this._buttonColor) {
|
|
83
|
+
this._updateButtonColor(options.buttonColor);
|
|
84
|
+
}
|
|
85
|
+
if (options.title != this._title) {
|
|
86
|
+
this._updateTitle(options.title);
|
|
87
|
+
}
|
|
88
|
+
if (options.tooltip != this._tooltip) {
|
|
89
|
+
this._updateTooltip(options.tooltip);
|
|
90
|
+
}
|
|
91
|
+
if (options.iconUrl != this._iconUrl) {
|
|
92
|
+
this._updateIconUrl(options.iconUrl);
|
|
93
|
+
}
|
|
94
|
+
if (options.iconClass != this._iconClass) {
|
|
95
|
+
this._updateIconClass(options.iconClass);
|
|
96
|
+
}
|
|
97
|
+
if (options.enabled === false || options.enabled === true) {
|
|
98
|
+
this._setEnabled(options.enabled);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
_createElement(options) {
|
|
102
|
+
this._setupMainElement(options);
|
|
103
|
+
this._setupInnerElement(options);
|
|
104
|
+
this._createTextElement();
|
|
105
|
+
this._createIconElement();
|
|
106
|
+
}
|
|
107
|
+
_setupMainElement(options) {
|
|
108
|
+
this._element.setAttribute('class', 'T-I J-J5-Ji ar7 inboxsdk__button ' +
|
|
109
|
+
BUTTON_COLOR_CLASSES[this._buttonColor].INACTIVE_CLASS);
|
|
110
|
+
if (options.tooltip) {
|
|
111
|
+
this._element.setAttribute('aria-label', options.tooltip);
|
|
112
|
+
}
|
|
113
|
+
this._element.setAttribute('role', 'button');
|
|
114
|
+
this._element.setAttribute('tabindex', '0');
|
|
115
|
+
if (options.hasButtonToRight) {
|
|
116
|
+
this._element.classList.add('T-I-Js-IF');
|
|
117
|
+
}
|
|
118
|
+
if (options.hasButtonToLeft) {
|
|
119
|
+
this._element.classList.add('T-I-Js-Gs');
|
|
120
|
+
}
|
|
121
|
+
if (options.tooltip || options.title) {
|
|
122
|
+
this._element.setAttribute('data-tooltip', String(options.tooltip || options.title));
|
|
123
|
+
}
|
|
124
|
+
if (options.enabled === false) {
|
|
125
|
+
this._element.classList.add('inboxsdk__button_disabled');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
_setupInnerElement(options) {
|
|
129
|
+
this._innerElement.classList.add('asa');
|
|
130
|
+
if (this._hasDropdown && !options.noArrow) {
|
|
131
|
+
this._innerElement.innerHTML =
|
|
132
|
+
'<div class="G-asx T-I-J3 - J-J5-Ji"> </div>';
|
|
133
|
+
}
|
|
134
|
+
this._element.appendChild(this._innerElement);
|
|
135
|
+
}
|
|
136
|
+
_createTextElement() {
|
|
137
|
+
if (!this._title) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this._textElement = document.createElement('span');
|
|
141
|
+
this._textElement.setAttribute('class', 'inboxsdk__button_text');
|
|
142
|
+
this._textElement.textContent = this._title;
|
|
143
|
+
if (this._iconElement) {
|
|
144
|
+
const parent = this._iconElement.parentElement;
|
|
145
|
+
if (!parent)
|
|
146
|
+
throw new Error('Could not find parent');
|
|
147
|
+
parent.insertBefore(this._textElement, this._iconElement.nextSibling);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this._innerElement.insertBefore(this._textElement, this._innerElement.firstElementChild);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
_createIconElement() {
|
|
154
|
+
if (!this._iconClass && !this._iconUrl) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const iconElement = (this._iconElement = document.createElement('div'));
|
|
158
|
+
iconElement.classList.add('inboxsdk__button_icon');
|
|
159
|
+
if (this._iconClass) {
|
|
160
|
+
iconElement.innerHTML = ' ';
|
|
161
|
+
iconElement.setAttribute('class', 'inboxsdk__button_icon ' + this._iconClass);
|
|
162
|
+
}
|
|
163
|
+
if (this._iconUrl) {
|
|
164
|
+
this._createIconImgElement();
|
|
165
|
+
}
|
|
166
|
+
this._innerElement.insertBefore(iconElement, this._innerElement.firstElementChild);
|
|
167
|
+
}
|
|
168
|
+
_createIconImgElement() {
|
|
169
|
+
if (!this._iconElement) {
|
|
170
|
+
this._createIconElement();
|
|
171
|
+
}
|
|
172
|
+
const iconElement = this._iconElement;
|
|
173
|
+
if (!iconElement)
|
|
174
|
+
throw new Error('Should not happen');
|
|
175
|
+
if (iconElement.innerHTML !== '') {
|
|
176
|
+
iconElement.innerHTML = '';
|
|
177
|
+
}
|
|
178
|
+
const iconImgElement = (this._iconImgElement =
|
|
179
|
+
document.createElement('img'));
|
|
180
|
+
iconImgElement.classList.add('inboxsdk__button_iconImg');
|
|
181
|
+
if (this._iconUrl) {
|
|
182
|
+
iconImgElement.src = this._iconUrl;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
Logger.error(new Error('_createIconImgElement should not be called with null _iconUrl'));
|
|
186
|
+
}
|
|
187
|
+
iconElement.appendChild(iconImgElement);
|
|
188
|
+
}
|
|
189
|
+
_updateButtonColor(newButtonColor) {
|
|
190
|
+
this._element.classList.remove(BUTTON_COLOR_CLASSES[this._buttonColor].INACTIVE_CLASS);
|
|
191
|
+
this._buttonColor = newButtonColor;
|
|
192
|
+
this._element.classList.add(BUTTON_COLOR_CLASSES[this._buttonColor].INACTIVE_CLASS);
|
|
193
|
+
}
|
|
194
|
+
_updateTitle(newTitle) {
|
|
195
|
+
if (!this._title && newTitle) {
|
|
196
|
+
this._title = newTitle;
|
|
197
|
+
this._createTextElement();
|
|
198
|
+
}
|
|
199
|
+
else if (this._title && !newTitle && this._textElement) {
|
|
200
|
+
this._textElement.remove();
|
|
201
|
+
this._textElement = undefined;
|
|
202
|
+
this._title = newTitle;
|
|
203
|
+
}
|
|
204
|
+
else if (this._textElement) {
|
|
205
|
+
this._textElement.textContent = newTitle;
|
|
206
|
+
this._title = newTitle;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
_updateTooltip(newTooltip) {
|
|
210
|
+
this._tooltip = newTooltip;
|
|
211
|
+
if (newTooltip) {
|
|
212
|
+
this._element.setAttribute('data-tooltip', newTooltip);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
this._element.removeAttribute('data-tooltip');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
_updateIconUrl(newIconUrl) {
|
|
219
|
+
this._iconUrl = newIconUrl;
|
|
220
|
+
if (this._iconImgElement && !newIconUrl) {
|
|
221
|
+
this._iconImgElement.remove();
|
|
222
|
+
this._iconImgElement = undefined;
|
|
223
|
+
}
|
|
224
|
+
else if (!this._iconImgElement && newIconUrl) {
|
|
225
|
+
this._createIconImgElement();
|
|
226
|
+
}
|
|
227
|
+
if (this._iconImgElement && newIconUrl) {
|
|
228
|
+
this._iconImgElement.src = newIconUrl;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
_updateIconClass(newIconClass) {
|
|
232
|
+
if (this._iconElement && !newIconClass && !this._iconUrl) {
|
|
233
|
+
this._iconElement.remove();
|
|
234
|
+
this._iconElement = undefined;
|
|
235
|
+
}
|
|
236
|
+
else if (!this._iconElement && newIconClass) {
|
|
237
|
+
this._createIconElement();
|
|
238
|
+
}
|
|
239
|
+
this._iconClass = newIconClass;
|
|
240
|
+
if (this._iconElement) {
|
|
241
|
+
this._iconElement.setAttribute('class', 'inboxsdk__button_icon ' + (newIconClass || ''));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
_setEnabled(value) {
|
|
245
|
+
if (this._isEnabled === value) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this._isEnabled = value;
|
|
249
|
+
if (this._isEnabled) {
|
|
250
|
+
this._element.classList.remove('inboxsdk__button_disabled');
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
this._element.classList.add('inboxsdk__button_disabled');
|
|
254
|
+
}
|
|
255
|
+
this._eventStream.emit({
|
|
256
|
+
eventName: 'enabledChanged',
|
|
257
|
+
isEnabled: this._isEnabled,
|
|
258
|
+
});
|
|
259
|
+
if (this._isEnabled) {
|
|
260
|
+
this._setupKeyboardShortcutEvent();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
_setupEventStream() {
|
|
264
|
+
const clickEventStream = Kefir.fromEvents(this._element, 'click');
|
|
265
|
+
clickEventStream.onValue(function (event) {
|
|
266
|
+
event.stopPropagation();
|
|
267
|
+
event.preventDefault();
|
|
268
|
+
});
|
|
269
|
+
this._eventStream.plug(clickEventStream
|
|
270
|
+
.filter(() => this.isEnabled())
|
|
271
|
+
.map(function (event) {
|
|
272
|
+
return {
|
|
273
|
+
eventName: 'click',
|
|
274
|
+
domEvent: event,
|
|
275
|
+
};
|
|
276
|
+
}));
|
|
277
|
+
const isEnterOrSpace = (event) => includes([32 /* space */, 13 /* enter */], event.which);
|
|
278
|
+
const keydownEventStream = Kefir.fromEvents(this._element, 'keydown').filter(() => this.isEnabled());
|
|
279
|
+
const enterEventStream = keydownEventStream.filter(isEnterOrSpace);
|
|
280
|
+
this._eventStream.plug(enterEventStream.map(function (event) {
|
|
281
|
+
return {
|
|
282
|
+
eventName: 'click',
|
|
283
|
+
domEvent: event,
|
|
284
|
+
};
|
|
285
|
+
}));
|
|
286
|
+
enterEventStream.onValue(function (event) {
|
|
287
|
+
event.stopPropagation();
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
_setupKeyboardShortcutEvent() {
|
|
292
|
+
const keyboardShortcutHandle = this._keyboardShortcutHandle;
|
|
293
|
+
if (keyboardShortcutHandle) {
|
|
294
|
+
this._eventStream.plug(keyboardShortcutStream(keyboardShortcutHandle.chord)
|
|
295
|
+
.takeUntilBy(this._eventStream.filter(function (event) {
|
|
296
|
+
return (event.eventName === 'enabledChanged' &&
|
|
297
|
+
event.isEnabled === false);
|
|
298
|
+
}))
|
|
299
|
+
.map(function (domEvent) {
|
|
300
|
+
return {
|
|
301
|
+
eventName: 'click',
|
|
302
|
+
domEvent: domEvent,
|
|
303
|
+
};
|
|
304
|
+
}));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
_setupAestheticEvents() {
|
|
308
|
+
Kefir.fromEvents(this._element, 'mouseenter')
|
|
309
|
+
.filter(() => this.isEnabled())
|
|
310
|
+
.onValue(() => {
|
|
311
|
+
this._element.classList.add(BUTTON_COLOR_CLASSES[this._buttonColor].HOVER_CLASS);
|
|
312
|
+
this._element.classList.add('inboxsdk__button_hover');
|
|
313
|
+
});
|
|
314
|
+
Kefir.fromEvents(this._element, 'mouseleave').onValue(() => {
|
|
315
|
+
this._element.classList.remove(BUTTON_COLOR_CLASSES[this._buttonColor].HOVER_CLASS);
|
|
316
|
+
this._element.classList.remove('inboxsdk__button_hover');
|
|
317
|
+
});
|
|
318
|
+
Kefir.fromEvents(this._element, 'focus').onValue(() => {
|
|
319
|
+
this._element.classList.add('T-I-JO');
|
|
320
|
+
});
|
|
321
|
+
Kefir.fromEvents(this._element, 'blur').onValue(() => {
|
|
322
|
+
this._element.classList.remove('T-I-JO');
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as Kefir from 'kefir';
|
|
2
|
+
import kefirBus from 'kefir-bus';
|
|
3
|
+
import kefirStopper from 'kefir-stopper';
|
|
4
|
+
export default class CreateAccessoryButtonView {
|
|
5
|
+
_element = document.createElement('div');
|
|
6
|
+
_eventStream = kefirBus();
|
|
7
|
+
_stopper = kefirStopper();
|
|
8
|
+
constructor() {
|
|
9
|
+
this._setupElement();
|
|
10
|
+
this._setupEventStream();
|
|
11
|
+
}
|
|
12
|
+
update() {
|
|
13
|
+
// noop
|
|
14
|
+
}
|
|
15
|
+
setEnabled() {
|
|
16
|
+
throw new Error('not implemented');
|
|
17
|
+
}
|
|
18
|
+
destroy() {
|
|
19
|
+
this._eventStream.end();
|
|
20
|
+
this._stopper.destroy();
|
|
21
|
+
this._element.remove();
|
|
22
|
+
}
|
|
23
|
+
getElement() {
|
|
24
|
+
return this._element;
|
|
25
|
+
}
|
|
26
|
+
getEventStream() {
|
|
27
|
+
return this._eventStream;
|
|
28
|
+
}
|
|
29
|
+
activate() {
|
|
30
|
+
const innerButtonElement = this._element.firstElementChild;
|
|
31
|
+
if (innerButtonElement)
|
|
32
|
+
innerButtonElement.classList.add('aj1');
|
|
33
|
+
}
|
|
34
|
+
deactivate() {
|
|
35
|
+
const innerButtonElement = this._element.firstElementChild;
|
|
36
|
+
if (innerButtonElement)
|
|
37
|
+
innerButtonElement.classList.remove('aj1');
|
|
38
|
+
}
|
|
39
|
+
_setupElement() {
|
|
40
|
+
this._element.setAttribute('class', 'nL aig');
|
|
41
|
+
this._element.setAttribute('style', 'left: 7px');
|
|
42
|
+
this._element.innerHTML = [
|
|
43
|
+
'<div class="pM aRw" style="display: inline-flex; margin-left: 16px;" role="button">',
|
|
44
|
+
'<div class="p6">',
|
|
45
|
+
'<div class="p8">▼</div>',
|
|
46
|
+
'</div>',
|
|
47
|
+
'</div>',
|
|
48
|
+
].join('');
|
|
49
|
+
}
|
|
50
|
+
_setupEventStream() {
|
|
51
|
+
const clickEventStream = Kefir.fromEvents(this._element, 'click');
|
|
52
|
+
clickEventStream.onValue((event) => {
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
});
|
|
56
|
+
this._eventStream.plug(clickEventStream.map((event) => ({ eventName: 'click', domEvent: event })));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as Kefir from 'kefir';
|
|
2
|
+
import kefirBus from 'kefir-bus';
|
|
3
|
+
import kefirStopper from 'kefir-stopper';
|
|
4
|
+
export default class CreateParentAccessoryButtonView {
|
|
5
|
+
_element = document.createElement('div');
|
|
6
|
+
_eventStream = kefirBus();
|
|
7
|
+
_stopper = kefirStopper();
|
|
8
|
+
constructor() {
|
|
9
|
+
this._setupElement();
|
|
10
|
+
this._setupEventStream();
|
|
11
|
+
}
|
|
12
|
+
activate() {
|
|
13
|
+
const innerButtonElement = this._element.firstElementChild;
|
|
14
|
+
if (innerButtonElement) {
|
|
15
|
+
innerButtonElement.classList.add('aj1');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
deactivate() {
|
|
19
|
+
const innerButtonElement = this._element.firstElementChild;
|
|
20
|
+
if (innerButtonElement) {
|
|
21
|
+
innerButtonElement.classList.remove('aj1');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
destroy() {
|
|
25
|
+
this._element.remove();
|
|
26
|
+
this._eventStream.end();
|
|
27
|
+
this._stopper.destroy();
|
|
28
|
+
}
|
|
29
|
+
getElement() {
|
|
30
|
+
return this._element;
|
|
31
|
+
}
|
|
32
|
+
getEventStream() {
|
|
33
|
+
return this._eventStream;
|
|
34
|
+
}
|
|
35
|
+
setEnabled() {
|
|
36
|
+
throw new Error('not implemented');
|
|
37
|
+
}
|
|
38
|
+
update() {
|
|
39
|
+
// noop
|
|
40
|
+
}
|
|
41
|
+
_setupElement() {
|
|
42
|
+
this._element.setAttribute('class', 'Yh inboxsdk__navItem_parent_accessory_button');
|
|
43
|
+
this._element.setAttribute('role', 'button');
|
|
44
|
+
this._element.setAttribute('tabindex', '0');
|
|
45
|
+
this._element.setAttribute('type', 'button');
|
|
46
|
+
}
|
|
47
|
+
_setupEventStream() {
|
|
48
|
+
const clickEventStream = Kefir.fromEvents(this._element, 'click');
|
|
49
|
+
clickEventStream.onValue((event) => {
|
|
50
|
+
event.stopPropagation();
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
});
|
|
53
|
+
this._eventStream.plug(clickEventStream.map((event) => ({ eventName: 'click', domEvent: event })));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import includes from 'lodash/includes';
|
|
2
|
+
import * as Kefir from 'kefir';
|
|
3
|
+
import kefirBus from 'kefir-bus';
|
|
4
|
+
export default class ModalButtonView {
|
|
5
|
+
_element = document.createElement('button');
|
|
6
|
+
_title;
|
|
7
|
+
_tooltip;
|
|
8
|
+
_buttonColor;
|
|
9
|
+
_eventStream = kefirBus();
|
|
10
|
+
_isEnabled;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this._isEnabled = options.enabled !== false;
|
|
13
|
+
this._title = options.text || options.title;
|
|
14
|
+
this._tooltip = options.tooltip || options.title;
|
|
15
|
+
this._buttonColor = options.buttonColor || 'default';
|
|
16
|
+
this._createElement(options);
|
|
17
|
+
this._eventStream = kefirBus();
|
|
18
|
+
this._setupEventStream();
|
|
19
|
+
}
|
|
20
|
+
destroy() {
|
|
21
|
+
this._element.remove();
|
|
22
|
+
this._eventStream.end();
|
|
23
|
+
}
|
|
24
|
+
getElement() {
|
|
25
|
+
return this._element;
|
|
26
|
+
}
|
|
27
|
+
getEventStream() {
|
|
28
|
+
return this._eventStream;
|
|
29
|
+
}
|
|
30
|
+
setEnabled(value) {
|
|
31
|
+
this._setEnabled(value);
|
|
32
|
+
}
|
|
33
|
+
update() {
|
|
34
|
+
throw new Error('not implemented');
|
|
35
|
+
}
|
|
36
|
+
isEnabled() {
|
|
37
|
+
return this._isEnabled;
|
|
38
|
+
}
|
|
39
|
+
_createElement(options) {
|
|
40
|
+
if (options.isPrimary)
|
|
41
|
+
this._element.classList.add('J-at1-auR');
|
|
42
|
+
this._element.innerText = options.text || options.title || '';
|
|
43
|
+
if (options.tooltip) {
|
|
44
|
+
this._element.setAttribute('aria-label', options.tooltip);
|
|
45
|
+
}
|
|
46
|
+
this._element.setAttribute('role', 'button');
|
|
47
|
+
this._element.setAttribute('tabindex', '0');
|
|
48
|
+
if (options.tooltip || options.title) {
|
|
49
|
+
this._element.setAttribute('data-tooltip', String(options.tooltip || options.title));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
_setEnabled(value) {
|
|
53
|
+
if (this._isEnabled === value) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this._isEnabled = value;
|
|
57
|
+
if (this._isEnabled) {
|
|
58
|
+
this._element.classList.remove('inboxsdk__button_disabled');
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this._element.classList.add('inboxsdk__button_disabled');
|
|
62
|
+
}
|
|
63
|
+
this._eventStream.emit({
|
|
64
|
+
eventName: 'enabledChanged',
|
|
65
|
+
isEnabled: this._isEnabled,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
_setupEventStream() {
|
|
69
|
+
const clickEventStream = Kefir.fromEvents(this._element, 'click');
|
|
70
|
+
clickEventStream.onValue(function (event) {
|
|
71
|
+
event.stopPropagation();
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
});
|
|
74
|
+
this._eventStream.plug(clickEventStream
|
|
75
|
+
.filter(() => this.isEnabled())
|
|
76
|
+
.map(function (event) {
|
|
77
|
+
return {
|
|
78
|
+
eventName: 'click',
|
|
79
|
+
domEvent: event,
|
|
80
|
+
};
|
|
81
|
+
}));
|
|
82
|
+
const isEnterOrSpace = (event) => includes([32 /* space */, 13 /* enter */], event.which);
|
|
83
|
+
const keydownEventStream = Kefir.fromEvents(this._element, 'keydown').filter(() => this.isEnabled());
|
|
84
|
+
const enterEventStream = keydownEventStream.filter(isEnterOrSpace);
|
|
85
|
+
this._eventStream.plug(enterEventStream.map(function (event) {
|
|
86
|
+
return {
|
|
87
|
+
eventName: 'click',
|
|
88
|
+
domEvent: event,
|
|
89
|
+
};
|
|
90
|
+
}));
|
|
91
|
+
enterEventStream.onValue(function (event) {
|
|
92
|
+
event.stopPropagation();
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/more-dropdown-button-view.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import GenericButtonView from '../../../../lib/dom/generic-button-view';
|
|
2
|
+
export default class MoreDropdownButtonView extends GenericButtonView {
|
|
3
|
+
_isActive = false;
|
|
4
|
+
constructor() {
|
|
5
|
+
super(document.createElement('div'));
|
|
6
|
+
const element = this._element;
|
|
7
|
+
element.setAttribute('class', 'nL aig');
|
|
8
|
+
const child = document.createElement('div');
|
|
9
|
+
child.setAttribute('class', 'pM aj0');
|
|
10
|
+
element.appendChild(child);
|
|
11
|
+
element.addEventListener('click', () => {
|
|
12
|
+
this._isActive = true;
|
|
13
|
+
});
|
|
14
|
+
element.addEventListener('mouseenter', () => {
|
|
15
|
+
child.classList.add('aj1');
|
|
16
|
+
});
|
|
17
|
+
element.addEventListener('mouseleave', () => {
|
|
18
|
+
if (!this._isActive) {
|
|
19
|
+
child.classList.remove('aj1');
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
activate() {
|
|
24
|
+
this.getElement().children[0].classList.add('aj1');
|
|
25
|
+
}
|
|
26
|
+
deactivate() {
|
|
27
|
+
this.getElement().children[0].classList.remove('aj1');
|
|
28
|
+
this._isActive = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import CreateParentAccessoryButtonView from './create-parent-accessory-button-view';
|
|
2
|
+
export default class MoreParentAccessoryButtonView extends CreateParentAccessoryButtonView {
|
|
3
|
+
constructor() {
|
|
4
|
+
super();
|
|
5
|
+
// New Gmail left nav does not have a "more" parent level accessory icon (only "create").
|
|
6
|
+
// So we extend the CreateParentAccessoryButtonView and manually change the background-image.
|
|
7
|
+
this.getElement().style.backgroundImage =
|
|
8
|
+
'url(https://www.gstatic.com/images/icons/material/system_gm/2x/more_vert_black_20dp.png)';
|
|
9
|
+
}
|
|
10
|
+
}
|