]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixed JS issues in public page
authorVincent Petry <pvince81@owncloud.com>
Tue, 20 May 2014 11:37:58 +0000 (13:37 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 20 May 2014 11:37:58 +0000 (13:37 +0200)
- fixed subdir detection when uploading into subdir
- add class detection before overriding to avoid JS errors

apps/files_sharing/js/public.js
apps/files_sharing/js/share.js

index d3d4479215efa77e93c2726a7f9e34d7142b1cf1..ce9a212499a8ae5b0acb24214b6e80dca52479d3 100644 (file)
@@ -18,12 +18,15 @@ OCA.Sharing.PublicApp = {
        _initialized: false,
 
        initialize: function($el) {
+               var self = this;
                if (this._initialized) {
                        return;
                }
                this._initialized = true;
+               this.initialDir = $('#dir').val();
+
                // file list mode ?
-               if ($el.find('#filestable')) {
+               if ($el.find('#filestable').length) {
                        this.fileList = new OCA.Files.FileList(
                                $el,
                                {
@@ -55,7 +58,7 @@ OCA.Sharing.PublicApp = {
                        var params = {
                                x: $(document).width() * window.devicePixelRatio,
                                a: 'true',
-                               file: encodeURIComponent($('#dir').val() + $('#filename').val()),
+                               file: encodeURIComponent(this.initialDir + $('#filename').val()),
                                t: $('#sharingToken').val()
                        };
 
@@ -112,7 +115,7 @@ OCA.Sharing.PublicApp = {
                                data.formData = {
                                        requesttoken: $('#publicUploadRequestToken').val(),
                                        dirToken: $('#dirToken').val(),
-                                       subdir: $('input#dir').val(),
+                                       subdir: self.fileList.getCurrentDirectory(),
                                        file_directory: fileDirectory
                                };
                        });
@@ -122,7 +125,7 @@ OCA.Sharing.PublicApp = {
                        delete this.fileActions.actions.all.Share;
                        this.fileList.setFileActions(this.fileActions);
 
-                       this.fileList.changeDirectory($('#dir').val() || '/', false, true);
+                       this.fileList.changeDirectory(this.initialDir || '/', false, true);
 
                        // URL history handling
                        this.fileList.$el.on('changeDirectory', _.bind(this._onDirectoryChanged, this));
@@ -156,16 +159,18 @@ $(document).ready(function() {
        var App = OCA.Sharing.PublicApp;
        App.initialize($('#preview'));
 
-       // HACK: for oc-dialogs previews that depends on Files:
-       Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) {
-               return App.fileList.lazyLoadPreview({
-                       path: path,
-                       mime: mime,
-                       callback: ready,
-                       width: width,
-                       height: height,
-                       etag: etag
-               });
-       };
+       if (window.Files) {
+               // HACK: for oc-dialogs previews that depends on Files:
+               Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) {
+                       return App.fileList.lazyLoadPreview({
+                               path: path,
+                               mime: mime,
+                               callback: ready,
+                               width: width,
+                               height: height,
+                               etag: etag
+                       });
+               };
+       }
 });
 
index 973c63c5d7e332e1c13559f7402111ddb7a29476..7d68a8d88605c941976a0c06c193da072e16789a 100644 (file)
@@ -15,14 +15,16 @@ $(document).ready(function() {
 
        if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined') {
                // TODO: make a separate class for this or a hook or jQuery event ?
-               var oldCreateRow = OCA.Files.FileList.prototype._createRow;
-               OCA.Files.FileList.prototype._createRow = function(fileData) {
-                       var tr = oldCreateRow.apply(this, arguments);
-                       if (fileData.shareOwner) {
-                               tr.attr('data-share-owner', fileData.shareOwner);
-                       }
-                       return tr;
-               };
+               if (OCA.Files.FileList) {
+                       var oldCreateRow = OCA.Files.FileList.prototype._createRow;
+                       OCA.Files.FileList.prototype._createRow = function(fileData) {
+                               var tr = oldCreateRow.apply(this, arguments);
+                               if (fileData.shareOwner) {
+                                       tr.attr('data-share-owner', fileData.shareOwner);
+                               }
+                               return tr;
+                       };
+               }
 
                $('#fileList').on('fileActionsReady',function(){
                        var $fileList = $(this);