本文整理汇总了TypeScript中@ephox/dom-globals.navigator.userAgent.indexOf方法的典型用法代码示例。如果您正苦于以下问题:TypeScript navigator.userAgent.indexOf方法的具体用法?TypeScript navigator.userAgent.indexOf怎么用?TypeScript navigator.userAgent.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/dom-globals.navigator.userAgent
的用法示例。
在下文中一共展示了navigator.userAgent.indexOf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
//.........这里部分代码省略.........
while (i--) {
styleSheet = styleSheets[i];
owner = styleSheet.ownerNode ? styleSheet.ownerNode : styleSheet.owningElement;
if (owner && owner.id === link.id) {
passed();
return true;
}
}
}, waitForWebKitLinkLoaded);
};
// Workaround for older Geckos that doesn't have any onload event for StyleSheets
const waitForGeckoLinkLoaded = function () {
wait(function () {
try {
// Accessing the cssRules will throw an exception until the CSS file is loaded
const cssRules = style.sheet.cssRules;
passed();
return !!cssRules;
} catch (ex) {
// Ignore
}
}, waitForGeckoLinkLoaded);
};
url = Tools._addCacheSuffix(url);
if (!loadedStates[url]) {
state = {
passed: [],
failed: []
};
loadedStates[url] = state;
} else {
state = loadedStates[url];
}
if (loadedCallback) {
state.passed.push(loadedCallback);
}
if (errorCallback) {
state.failed.push(errorCallback);
}
// Is loading wait for it to pass
if (state.status === 1) {
return;
}
// Has finished loading and was success
if (state.status === 2) {
passed();
return;
}
// Has finished loading and was a failure
if (state.status === 3) {
failed();
return;
}
// Start loading
state.status = 1;
link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.id = 'u' + (idCount++);
link.async = false;
link.defer = false;
startTime = new Date().getTime();
if (settings.contentCssCors) {
link.crossOrigin = 'anonymous';
}
// Feature detect onload on link element and sniff older webkits since it has an broken onload event
if ('onload' in link && !isOldWebKit()) {
link.onload = waitForWebKitLinkLoaded;
link.onerror = failed;
} else {
// Sniff for old Firefox that doesn't support the onload event on link elements
// TODO: Remove this in the future when everyone uses modern browsers
if (navigator.userAgent.indexOf('Firefox') > 0) {
style = document.createElement('style');
style.textContent = '@import "' + url + '"';
waitForGeckoLinkLoaded();
appendToHead(style);
return;
}
// Use the id owner on older webkits
waitForWebKitLinkLoaded();
}
appendToHead(link);
link.href = url;
};
示例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'));
}
})
示例10: cFindNthIn
(editor, onSuccess, onFailure) => {
const doc = Element.fromDom(document);
const structureItem = (optText: Option<string>, optIcon: Option<string>) => (s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-collection__item') ],
children: Options.cat([
optIcon.map((icon) => s.element('div', {
classes: [ arr.has('tox-collection__item-icon') ],
html: str.is(icon)
})),
optText.map((text) => s.element('div', {
classes: [ arr.has('tox-collection__item-label') ],
html: str.is(text)
}))
])
});
};
const cFindNthIn = (selector, n) => Chain.binder((elem: Element) => {
const matches = UiFinder.findAllIn(elem, selector);
return matches.length > 0 && n < matches.length ? Result.value(matches[n]) :
Result.error(`Could not find match ${n} of selector: ${selector}`);
});
Pipeline.async({ }, Logger.ts(
'Check structure of collection in a dialog',
[
TestHelpers.GuiSetup.mAddStyles(doc, [
':focus { outline: 2px solid green; }'
]),
Mouse.sClickOn(Body.body(), '.tox-toolbar button'),
UiFinder.sWaitForVisible('Waiting for dialog', Body.body(), '[role="dialog"]'),
FocusTools.sTryOnSelector('Focus should start on input', doc, 'input'),
Keyboard.sKeydown(doc, Keys.tab(), { }),
Logger.t(
'Checking the first collection: columns = 1, list',
GeneralSteps.sequence([
Chain.asStep(Body.body(), [
cFindNthIn('[role="dialog"] .tox-form__group .tox-collection', 0),
Assertions.cAssertStructure(
'Checking structure',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-collection'), arr.has('tox-collection--list'), arr.not('tox-menu') ],
children: [
s.element('div', {
classes: [ arr.has('tox-collection__group') ],
children: Arr.map([ 'A', 'B', 'C' ], (letter) =>
structureItem(Option.some('text-' + letter), Option.some('icon-' + letter))(s, str, arr)
)
})
]
});
})
)
]),
FocusTools.sTryOnSelector('Focus should be on A', doc, '.tox-collection__item:contains(A).tox-collection__item--active'),
Keyboard.sKeydown(doc, Keys.down(), { }),
FocusTools.sTryOnSelector('Focus should be on B', doc, '.tox-collection__item:contains(B)'),
Keyboard.sKeydown(doc, Keys.down(), { }),
FocusTools.sTryOnSelector('Focus should be on C', doc, '.tox-collection__item:contains(C)'),
])
),
// NOTE: We need a layout engine to use flex-wrap navigation.
navigator.userAgent.indexOf('PhantomJS') > -1 ?
FocusTools.sSetFocus('Force focus to F on phantom', Body.body(), '.tox-collection__item:contains("F")')
: Logger.t(
'Checking the second collection: columns = auto',
GeneralSteps.sequence([
Chain.asStep(Body.body(), [
cFindNthIn('[role="dialog"] .tox-form__group .tox-collection', 1),
Assertions.cAssertStructure(
'Checking structure',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-collection'), arr.has('tox-collection--grid'), arr.not('tox-menu') ],
children: [
s.element('div', {
classes: [ arr.has('tox-collection__group') ],
children: Arr.map([ 'D', 'E', 'F' ], (letter) =>
structureItem(Option.none(), Option.some('icon-' + letter))(s, str, arr)
)
})
]
});
})
)
]),
FocusTools.sTryOnSelector('Focus should be on C', doc, '.tox-collection__item:contains(C)'),
Keyboard.sKeydown(doc, Keys.tab(), { }),
FocusTools.sTryOnSelector('Focus should be on D', doc, '.tox-collection__item:contains(D)'),
Keyboard.sKeydown(doc, Keys.right(), { }),
FocusTools.sTryOnSelector('Focus should be on E', doc, '.tox-collection__item:contains(E)'),
Keyboard.sKeydown(doc, Keys.right(), { }),
FocusTools.sTryOnSelector('Focus should be on F', doc, '.tox-collection__item:contains(F)'),
//.........这里部分代码省略.........