本文整理汇总了TypeScript中@ephox/dom-globals.navigator.userAgent类的典型用法代码示例。如果您正苦于以下问题:TypeScript navigator.userAgent类的具体用法?TypeScript navigator.userAgent怎么用?TypeScript navigator.userAgent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了navigator.userAgent类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: rgb
(editor, onSuccess, onFailure) => {
const doc = Element.fromDom(document);
Pipeline.async({ }, Logger.ts(
'Check structure of grid collection menu',
[
TestHelpers.GuiSetup.mAddStyles(doc, [
':focus { background-color: rgb(222, 224, 226); }'
]),
Mouse.sClickOn(Body.body(), '.tox-split-button__chevron'),
UiFinder.sWaitForVisible('Waiting for menu', Body.body(), '[role="menu"]'),
Chain.asStep(Body.body(), [
UiFinder.cFindIn('[role="menu"]'),
Assertions.cAssertStructure(
'Checking structure',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-menu'), arr.has('tox-collection'), arr.has('tox-collection--grid') ],
children: [
s.element('div', {
classes: [ arr.has('tox-collection__group') ],
children: Arr.map([ '1', '2', '3', '4', '5', '6', '7', '8' ], (num) => {
return s.element('div', {
classes: [ arr.has('tox-collection__item') ],
attrs: {
title: str.is(num)
},
children: [
// NOTE: The oxide demo page has div, but I think that's just a mistake
s.element('div', {
classes: [ arr.has('tox-collection__item-icon') ],
children: [
s.element('svg', {})
]
})
]
});
})
})
]
});
})
)
]),
// Without layout, the flatgrid cannot be calculated on phantom
navigator.userAgent.indexOf('PhantomJS') > -1 ? Step.pass : GeneralSteps.sequence([
FocusTools.sTryOnSelector('Focus should be on 1', doc, '.tox-collection__item[title="1"]'),
Keyboard.sKeydown(doc, Keys.right(), { }),
FocusTools.sTryOnSelector('Focus should be on 2', doc, '.tox-collection__item[title="2"]'),
Keyboard.sKeydown(doc, Keys.right(), { }),
FocusTools.sTryOnSelector('Focus should be on 3', doc, '.tox-collection__item[title="3"]')
]),
TestHelpers.GuiSetup.mRemoveStyles
]
), onSuccess, onFailure);
},
示例2: TinyApis
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
const eDoc = Element.fromDom(editor.getDoc());
Pipeline.async({},
Log.steps('TBA', 'Charmap: Autocomplete, trigger an autocomplete and check it appears', [
tinyApis.sFocus,
tinyApis.sSetContent('<p>:co</p>'),
tinyApis.sSetCursor([ 0, 0 ], 3),
Keyboard.sKeypress(eDoc, 'o'.charCodeAt(0), { }),
UiFinder.sWaitForVisible('Waiting for autocomplete menu', Body.body(), '.tox-autocompleter'),
Keyboard.sKeydown(eDoc, Keys.enter(), { }),
// This assertion does not pass on Phantom. The editor content
// is empty. Not sure if it's an encoding issue for entities.
navigator.userAgent.indexOf('PhantomJS') > -1 ? Step.pass : tinyApis.sAssertContent('<p>âĄ</p>')
])
, onSuccess, onFailure);
}, {
示例3: function
editor.on('keydown', function (e) {
function removePasteBinOnKeyUp(e) {
// Ctrl+V or Shift+Insert
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
pasteBin.remove();
}
}
// Ctrl+V or Shift+Insert
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86;
// Edge case on Safari on Mac where it doesn't handle Cmd+Shift+V correctly
// it fires the keydown but no paste or keyup so we are left with a paste bin
if (keyboardPastePlainTextState && Env.webkit && navigator.userAgent.indexOf('Version/') !== -1) {
return;
}
// Prevent undoManager keydown handler from making an undo level with the pastebin in it
e.stopImmediatePropagation();
keyboardPasteTimeStamp = new Date().getTime();
// IE doesn't support Ctrl+Shift+V and it doesn't even produce a paste event
// so lets fake a paste event and let IE use the execCommand/dataTransfer methods
if (Env.ie && keyboardPastePlainTextState) {
e.preventDefault();
Events.firePaste(editor, true);
return;
}
pasteBin.remove();
pasteBin.create();
// Remove pastebin if we get a keyup and no paste event
// For example pasting a file in IE 11 will not produce a paste event
editor.once('keyup', removePasteBinOnKeyUp);
editor.once('paste', function () {
editor.off('keyup', removePasteBinOnKeyUp);
});
}
});
示例4: TinyApis
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
Pipeline.async({}, Arr.flatten([
[
Logger.t('Fullscreen toggle scroll state', GeneralSteps.sequence([
tinyApis.sExecCommand('mceFullScreen'),
sAssertScroll(editor, true),
tinyApis.sExecCommand('mceFullScreen'),
sAssertScroll(editor, false)
])),
Logger.t('Editor size increase based on content size', GeneralSteps.sequence([
tinyApis.sSetContent('<div style="height: 5000px;">a</div>'),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightAbove(editor, 5000), 10, 3000)
])),
Logger.t('Editor size decrease based on content size', GeneralSteps.sequence([
tinyApis.sSetContent('<div style="height: 1000px;">a</div>'),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightBelow(editor, 2000), 10, 3000)
]))
],
// These tests doesn't work on phantom since measuring things seems broken there
navigator.userAgent.indexOf('PhantomJS') === -1 ? [
Logger.t('Editor size decrease content to 1000 based and restrict by max height', GeneralSteps.sequence([
tinyApis.sSetSetting('autoresize_max_height', 200),
tinyApis.sSetContent('<div style="height: 1000px;">a</div>'),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightBelow(editor, 500), 10, 3000),
tinyApis.sSetSetting('autoresize_max_height', 0)
])),
Logger.t('Editor size decrease content to 10 and set min height to 500', GeneralSteps.sequence([
tinyApis.sSetSetting('autoresize_min_height', 500),
tinyApis.sSetContent('<div style="height: 10px;">a</div>'),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightAbove(editor, 300), 10, 3000),
tinyApis.sSetSetting('autoresize_min_height', 0)
]))
] : []
]), onSuccess, onFailure);
}, {
示例5: TinyApis
TinyLoader.setup((editor, onSuccess, onFailure) => {
const tinyApis = TinyApis(editor);
Pipeline.async({},
// These tests doesn't work on phantom since measuring things seems broken there
navigator.userAgent.indexOf('PhantomJS') === -1 ?
[
Log.stepsAsStep('TBA', 'AutoResize: Fullscreen toggle scroll state', [
tinyApis.sExecCommand('mceFullScreen'),
sAssertScroll(editor, true),
tinyApis.sExecCommand('mceFullScreen'),
sAssertScroll(editor, false)
]),
Log.stepsAsStep('TBA', 'AutoResize: Editor size increase based on content size', [
tinyApis.sSetContent('<div style="height: 5000px;">a</div>'),
// Content height + bottom margin = 5050
Waiter.sTryUntil('wait for editor height', sAssertEditorContentApproxHeight(editor, 5050), 10, 3000),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightAbove(editor, 5050), 10, 3000)
]),
Log.stepsAsStep('TBA', 'AutoResize: Editor size increase with floated content', [
tinyApis.sSetContent('<div style="height: 5500px; float: right;">a</div>'),
// Content height + bottom margin = 5550
Waiter.sTryUntil('wait for editor height', sAssertEditorContentApproxHeight(editor, 5550), 10, 3000),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightAbove(editor, 5550), 10, 3000)
]),
Log.stepsAsStep('TBA', 'AutoResize: Editor size increase with async loaded content', [
// Note: Use a min-height here to account for different browsers rendering broken images differently
tinyApis.sSetContent('<div style="min-height: 35px;"><img src="#" /></div><div style="height: 5500px;"></div>'),
Waiter.sTryUntil('wait for editor height', sAssertEditorContentApproxHeight(editor, 5585), 10, 3000),
Step.sync(() => {
// Update the img element to load an image
editor.$('img').attr('src', 'http://moxiecode.cachefly.net/tinymce/v9/images/logo.png');
}),
// Content height + div image height (84px) + bottom margin = 5634
Waiter.sTryUntil('wait for editor height', sAssertEditorContentApproxHeight(editor, 5634), 10, 3000),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightAbove(editor, 5634), 10, 3000)
]),
Log.stepsAsStep('TBA', 'AutoResize: Editor size decrease based on content size', [
tinyApis.sSetContent('<div style="height: 1000px;">a</div>'),
Waiter.sTryUntil('wait for editor height', sAssertEditorContentApproxHeight(editor, 1050), 10, 3000),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightBelow(editor, 1200), 10, 3000)
]),
Log.stepsAsStep('TBA', 'AutoResize: Editor size content set to 10 and autoresize_bottom_margin set to 100', [
tinyApis.sSetSetting('autoresize_bottom_margin', 100),
tinyApis.sSetContent('<div style="height: 10px;">a</div>'),
Waiter.sTryUntil('wait for editor height', sAssertEditorContentApproxHeight(editor, 110), 10, 3000),
tinyApis.sSetSetting('autoresize_bottom_margin', 50)
]),
Log.stepsAsStep('TBA', 'AutoResize: Editor size increase content to 1000 based and restrict by max height', [
tinyApis.sSetSetting('max_height', 200),
tinyApis.sSetContent('<div style="height: 1000px;">a</div>'),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightBelow(editor, 200), 10, 3000),
tinyApis.sSetSetting('max_height', 0)
]),
Log.stepsAsStep('TBA', 'AutoResize: Editor size decrease content to 10 and set min height to 500', [
tinyApis.sSetSetting('min_height', 500),
tinyApis.sSetContent('<div style="height: 10px;">a</div>'),
Waiter.sTryUntil('wait for editor height', sAssertEditorHeightAbove(editor, 500), 10, 3000),
tinyApis.sSetSetting('min_height', 0)
])
] : []
, onSuccess, onFailure);
}, {
示例6: function
const isOldWebKit = function () {
const webKitChunks = navigator.userAgent.match(/WebKit\/(\d*)/);
return !!(webKitChunks && parseInt(webKitChunks[1], 10) < 536);
};
示例7:
const isBrokenAndroidClipboardEvent = (e: ClipboardEvent) => {
const clipboardData = e.clipboardData;
return navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
};
示例8: function
const isMsEdge = function () {
return navigator.userAgent.indexOf(' Edge/') !== -1;
};
示例9:
Chain.op(function (toolstrip) {
if (navigator.userAgent.indexOf('PhantomJS') === -1) {
Assertions.assertEq('Checking toolstrip is flex', 'flex', Css.get(toolstrip, 'display'));
}
})