Class: UrlChooser

sync.api.UrlChooser

new UrlChooser()

A base class for URL choosers.
Source:

Classes

Context

Members

(static) Purpose :string

The type of the URL to be chosen.
Type:
  • string
Properties:
Name Type Description
SAVE string The purpose of the chooser is to help the user save the specified resource.
CHOOSE_SAVE_LOCATION string The purpose of the chooser is to choose a location where to save the given file.
CHOOSE string The purpose of the chooser is to choose the location of a resource.
Source:

(static) SaveResult :string

Information about the save operation result.
Type:
  • string
Properties:
Name Type Description
SAVED_AVAILABLE_URL string The save operation was successful and the file url is available.
SAVED_UNAVAILABLE_URL string The save operation was successful but the file url is not available, or cannot be determined by the urlChoser.
FAILED string The save operation failed for some reason.
CANCELED string
Source:

(static) Type :string

The type of the URL to be chosen.
Type:
  • string
Properties:
Name Type Description
IMAGE string The URL corresponds to an image resource.
EXTERNAL_REF string The URL corresponds to an XML file that is referred from the currently edited one.
GENERIC string The URL corresponds to another type of resource.
Source:

Methods

chooseUrl(context, chosen, purpose)

Invokes the URL chooser.
Parameters:
Name Type Description
context sync.api.UrlChooser.Context The context in which the chooser is invoked - it contains information like the type of the resource that we want the user to choose: image, external xml file, etc.
chosen sync.api.UrlChooser~urlChosen The function to be called with the result of the choice.
purpose sync.api.UrlChooser.Purpose The purpose the chooser is invoked with.
Source:

saveFile(fileURL, suggestedFileName, callback)

Saves the file given file. IMPORTANT: Please consider overriding sync.api.UrlChooser#chooseUrl instead of this one. The default implementation for this method uses sync.api.UrlChooser#chooseUrl to determine the save location. An use-case for this method is to re-use a 'saver' widget which already takes care of the saving itself.
Parameters:
Name Type Description
fileURL string the URL of the file to be saved.
suggestedFileName string the proposed name for the new file.
callback sync.api.UrlChooser~fileSaved the callback to be called with the saved file url.
Source:

supports(type) → {boolean}

Checks whether the URL chooser supports choosing a given type of resource sync.api.UrlChooser.Type. If not supported, the default UI (which is usually a text-field) will be presented to the user.
Parameters:
Name Type Description
type sync.api.UrlChooser.Type The type of the URL to be chosen.
Source:
Returns:
true if the chooser supports the given type.
Type
boolean

supportsOperation(purpose) → {boolean}

Needs to be implemented to reflect whether the chooser suports the given operation: save or choose.
Parameters:
Name Type Description
purpose sync.api.UrlChooser.Purpose The operation.
Source:
Returns:
true if the given operation is supported.
Type
boolean

Type Definitions

fileSaved(urlopt, resultInfo, errorMessageopt)

A callback invoked when the file is saved.
Parameters:
Name Type Attributes Description
url string <optional>
The URL where the file was saved, or null if the location is not available.
resultInfo sync.api.UrlChooser.SaveResult information about the save operation result.
errorMessage string <optional>
The error message in case the resultInfo is sync.api.UrlChooser.SaveResult.FAILED.
Source:

urlChosen(urlopt)

A callback invoked when the user choice is available.
Parameters:
Name Type Attributes Description
url string <optional>
The URL chosen by the user, or null if the user failed to choose anything.
Source: