When doing a Cordova project, the responsiveness of the application is far from the native application, and a major problem is the efficiency of pop-up dialogs such as loading layers, progress bars, and so on. After all, the bullets in the project are all made up of Dom, and the rendering efficiency of the DOM is normal compared to the native controls. In order to be able to make the application as close as possible to the original application of the effect, I do in my spare time a set of dialog box plug-in, the use of the application after the use of the experience immediately has a great boost. Compatible with iOS and Android platforms. Plug-ins include the loading layer, progress bar, file selection. The project has been put on GitHub, and interested partners can download it for a try.
The plugin only supports cordova5.0 and above, and is initialized as follows:
Cordova Plugin Add https://github.com/laden666666/cordovadialogsplus
This is a Cordova plug-in project, is an extension of the official plug-in Cordova-plugin-dialogs Cordova, on the iOS and Android platform, provides a progress bar, loading layer, File Selection dialog box, message prompts and other functions. The code for the Android platform refers to some of the cordova-plugin-dialogs sources.
API and Examples:
1. Open the display load layer, you can set the loading layer title and content
Window.navigator.dialogsPlus.showLoading (title, loadingmassage);
Hide the load layer
Window.navigator.dialogsPlus.hideLoading ();
2. Display the Progress Bar dialog box, you can set the title and content of the progress bar, and the plugin supports a Cancel button.
Window.navigator.dialogsPlus.progressStart (title, Loadingmassage, Errorcallback, Cancancel, Cancelbuttonname, Cancelcallback);
This function returns a JSON object that can be used to open a progress bar operation for this function, such as setting progress or hiding a progress bar.
var progress = Window.navigator.dialogsPlus.progressStart ("title", "Loading ....");p Rogress.setvalue ( (rogress.hide);p (Successcallback, errorcallback);
3. Select file, on Android you can use the System dialog box to select the file, select the absolute path of the selected file. But on iOS, you can only use this plugin to rely on the Cordova-plugin-camera plug-in, to select Pictures in the album, mainly because of the iOS file sandbox mechanism, I can not get to Android as the other application directory images.
Window.navigator.dialogsPlus.chooseFile (title, Successcallback, Errorcallback);
4. Display notifications in the form of an Android toast message. The unit of the continuous event is milliseconds.
Window.navigator.dialogsPlus.showNotice (notice,duration);
Cordova loading layer, progress bar, file selection plugin