]> source.dussan.org Git - nextcloud-server.git/commitdiff
Prevent showing the file picker twice
authorVincent Petry <pvince81@owncloud.com>
Fri, 20 Jun 2014 11:39:46 +0000 (13:39 +0200)
committerVincent Petry <pvince81@owncloud.com>
Fri, 20 Jun 2014 11:39:46 +0000 (13:39 +0200)
In case the filepicker function is called twice, only show it once.

core/js/oc-dialogs.js

index 0e4c346e8cc95e39694a6eaed039af9fd782ba4b..a76f9170dc8b345a5d02b71a091a1f492bb0b668 100644 (file)
@@ -144,7 +144,13 @@ var OCdialogs = {
        */
        filepicker:function(title, callback, multiselect, mimetypeFilter, modal) {
                var self = this;
+               // avoid opening the picker twice
+               if (this.filepicker.loading) {
+                       return;
+               }
+               this.filepicker.loading = true;
                $.when(this._getFilePickerTemplate()).then(function($tmpl) {
+                       self.filepicker.loading = false;
                        var dialogName = 'oc-dialog-filepicker-content';
                        if(self.$filePicker) {
                                self.$filePicker.ocdialog('close');
@@ -220,6 +226,7 @@ var OCdialogs = {
                .fail(function(status, error) {
                        // If the method is called while navigating away
                        // from the page, it is probably not needed ;)
+                       self.filepicker.loading = false;
                        if(status !== 0) {
                                alert(t('core', 'Error loading file picker template: {error}', {error: error}));
                        }