Skip to content

Commit

Permalink
nsiPromptService
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Apr 10, 2024
1 parent 539abef commit 8690ea6
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 20 deletions.
11 changes: 6 additions & 5 deletions content/ErrorReport.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Components.utils.import('resource://gre/modules/Services.jsm')

import { PromptService } from './prompt'

import { Preference } from './prefs'
import { defaults } from '../gen/preferences/meta'
import { byId } from '../gen/translators'
Expand Down Expand Up @@ -100,11 +102,10 @@ export class ErrorReport {
}

public restartWithDebugEnabled(): void {
const ps = Components.classes['@mozilla.org/embedcomp/prompt-service;1'].getService(Components.interfaces.nsIPromptService)
const buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL
+ ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING
const index = ps.confirmEx(
const buttonFlags = PromptService.BUTTON_POS_0 * PromptService.BUTTON_TITLE_IS_STRING
+ PromptService.BUTTON_POS_1 * PromptService.BUTTON_TITLE_CANCEL
+ PromptService.BUTTON_POS_2 * PromptService.BUTTON_TITLE_IS_STRING
const index = PromptService.confirmEx(
null,
Zotero.getString('zotero.debugOutputLogging'),
Zotero.getString('zotero.debugOutputLogging.enabledAfterRestart', [Zotero.clientName]),
Expand Down
7 changes: 3 additions & 4 deletions content/key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { orchestrator } from './orchestrator'

import ETA from 'node-eta'

import { alert, prompt } from './prompt'
import { alert, prompt, PromptService } from './prompt'

import { kuroshiro } from './key-manager/japanese'
import { chinese } from './key-manager/chinese'
Expand Down Expand Up @@ -173,12 +173,11 @@ export const KeyManager = new class _KeyManager {
},
}).length
if (warnAt > 0 && affected > warnAt) {
const ps = Components.classes['@mozilla.org/embedcomp/prompt-service;1'].getService(Components.interfaces.nsIPromptService)
const index = ps.confirmEx(
const index = PromptService.confirmEx(
null, // no parent
'Better BibTeX for Zotero', // dialog title
l10n.localize('better-bibtex_bulk-keys-confirm_warning', { treshold: warnAt }),
ps.STD_OK_CANCEL_BUTTONS + ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING, // buttons
PromptService.STD_OK_CANCEL_BUTTONS + PromptService.BUTTON_POS_2 * PromptService.BUTTON_TITLE_IS_STRING, // buttons
null, null, l10n.localize('better-bibtex_bulk-keys-confirm_stop_asking'), // button labels
null, {} // no checkbox
)
Expand Down
1 change: 0 additions & 1 deletion content/path-search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { log } from './logger'
// import { OS } from '../typings/xpcom'

// https://searchfox.org/mozilla-central/source/toolkit/modules/subprocess/subprocess_win.jsm#135 doesn't seem to work on Windows.
export async function findBinary(bin: string, installationDirectory: { mac?: string[], win?: string[] } = {}): Promise<string> {
Expand Down
9 changes: 6 additions & 3 deletions content/prompt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const ps = Components.classes['@mozilla.org/embedcomp/prompt-service;1'].getService(Components.interfaces.nsIPromptService)
import { is7 } from './client'
export const PromptService = is7
? Services.prompt
: Components.classes['@mozilla.org/embedcomp/prompt-service;1'].getService(Components.interfaces.nsIPromptService)

export function alert({ title, text }: { title?: string, text: string }): void {
ps.alert(null, title || 'Alert', text)
PromptService.alert(null, title || 'Alert', text)
}

export function prompt({ title, text, value }: { title?: string, text: string, value?: string }): string {
const wrap = { value: value || '' }
if (ps.prompt(null, title || 'Enter text', text, wrap, null, {})) {
if (PromptService.prompt(null, title || 'Enter text', text, wrap, null, {})) {
return wrap.value
}
else {
Expand Down
2 changes: 1 addition & 1 deletion site/themes/relearn
Submodule relearn updated 76 files
+1 −1 assets/css/format-print.css
+12 −12 exampleSite/config/_default/hugo.toml
+42 −0 exampleSite/content/basics/CHANGELOG.md
+1 −1 exampleSite/content/basics/branding/_index.en.md
+23 −10 exampleSite/content/basics/customization/_index.en.md
+45 −23 exampleSite/content/basics/migration/_index.en.md
+1 −1 exampleSite/content/basics/requirements/_index.en.md
+1 −0 exampleSite/content/cont/i18n/_index.en.md
+1 −0 exampleSite/content/cont/i18n/_index.pir.md
+87 −48 exampleSite/content/cont/markdown.en.md
+17 −17 exampleSite/content/cont/menushortcuts.en.md
+2 −2 exampleSite/content/cont/taxonomy.en.md
+7 −11 exampleSite/content/shortcodes/attachments/index.en.md
+4 −4 exampleSite/content/shortcodes/badge.en.md
+2 −2 exampleSite/content/shortcodes/button.en.md
+1 −1 exampleSite/content/shortcodes/mermaid.en.md
+2 −2 exampleSite/content/shortcodes/notice.en.md
+1,131 −98 exampleSite/content/shortcodes/openapi/petstore.json
+1,548 −0 exampleSite/content/shortcodes/openapi/petstore.yaml
+2 −2 exampleSite/content/shortcodes/resources/index.en.md
+1 −1 exampleSite/layouts/partials/menu-footer.html
+1 −1 exampleSite/test-hugo.min.bat
+1 −4 hugo.toml
+2 −8 layouts/404.html
+1 −9 layouts/_default/index.json
+1 −9 layouts/_default/index.search.js
+6 −5 layouts/_default/rss.xml
+7 −19 layouts/_default/sitemap.xml
+1 −1 layouts/_default/taxonomy.html
+1 −3 layouts/_default/term.html
+16 −14 layouts/partials/body.searchpage.html
+2 −12 layouts/partials/breadcrumbs.html
+2 −2 layouts/partials/content-footer.html
+9 −4 layouts/partials/dependencies.html
+13 −10 layouts/partials/dependencies/mathjax.html
+14 −11 layouts/partials/dependencies/mermaid.html
+23 −16 layouts/partials/dependencies/openapi.html
+3 −18 layouts/partials/header.html
+2 −1 layouts/partials/heading.html
+3 −2 layouts/partials/initial.html
+10 −10 layouts/partials/menu.html
+50 −75 layouts/partials/opengraph.html
+12 −9 layouts/partials/page-meta.hugo
+1 −1 layouts/partials/pageHelper/depth.hugo
+42 −0 layouts/partials/pageHelper/title.hugo
+11 −0 layouts/partials/relBasePath.hugo
+10 −0 layouts/partials/relBaseUri.hugo
+8 −6 layouts/partials/search.html
+2 −13 layouts/partials/shortcodes/attachments.html
+2 −2 layouts/partials/shortcodes/expand.html
+2 −1 layouts/partials/shortcodes/image.html
+66 −1 layouts/partials/shortcodes/link.html
+7 −4 layouts/partials/shortcodes/openapi.html
+3 −2 layouts/partials/stylesheet.html
+9 −20 layouts/partials/topbar/button/next.html
+9 −22 layouts/partials/topbar/button/prev.html
+10 −37 layouts/partials/twitter_cards.html
+1 −1 layouts/partials/version.txt
+1 −0 static/css/auto-complete.css
+1 −1 static/css/fonts.css
+5 −5 static/css/ie.css
+1 −1 static/css/perfect-scrollbar.min.css
+2 −1 static/css/theme-neon.css
+1 −1 static/css/theme-relearn-bright.css
+1 −1 static/css/theme-relearn-dark.css
+1 −1 static/css/theme-relearn-light.css
+42 −3 static/css/theme.css
+11 −1 static/css/variant.css
+4 −3 static/js/auto-complete.js
+6 −6 static/js/perfect-scrollbar.min.js
+3 −3 static/js/search.js
+104 −36 static/js/theme.js
+12 −12 static/js/variant.js
+1 −1 theme.toml
+67 −67 vscode-frontmatter/snippets.de.json
+67 −67 vscode-frontmatter/snippets.en.json
2 changes: 1 addition & 1 deletion submodules/babel
2 changes: 1 addition & 1 deletion submodules/citation-style-language-locales
2 changes: 1 addition & 1 deletion submodules/zotero-utilities
Submodule zotero-utilities updated 1 files
+2 −2 date.js
2 changes: 1 addition & 1 deletion translators/lib/translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class Override {
}

public override(preference: string, extension: string): boolean {
const override = this.orig[`${preference}Override`]
const override: string = this.orig[`${preference}Override`]
if (!this.exportPath || !override) {
return false
}
Expand Down

0 comments on commit 8690ea6

Please sign in to comment.