Skip to content
Snippets Groups Projects
Select Git revision
  • 76961ce0727d08ef3d12bd445798df221f5d2063
  • master default protected
2 results

files.js

Blame
  • user avatar
    Thomas Müller authored
    fixing javascript error where $(Files.breadcrumbs[1]).get(0) returns undefined - happens on resize to a very small width
    76961ce0
    History
    files.js 25.64 KiB
    /*
     * Copyright (c) 2014
     *
     * This file is licensed under the Affero General Public License version 3
     * or later.
     *
     * See the COPYING-README file.
     *
     */
    
    /* global OC, t, n, FileList, FileActions */
    /* global getURLParameter, isPublic */
    var Files = {
    	// file space size sync
    	_updateStorageStatistics: function() {
    		Files._updateStorageStatisticsTimeout = null;
    		var currentDir = FileList.getCurrentDirectory(),
    			state = Files.updateStorageStatistics;
    		if (state.dir){
    			if (state.dir === currentDir) {
    				return;
    			}
    			// cancel previous call, as it was for another dir
    			state.call.abort();
    		}
    		state.dir = currentDir;
    		state.call = $.getJSON(OC.filePath('files','ajax','getstoragestats.php') + '?dir=' + encodeURIComponent(currentDir),function(response) {
    			state.dir = null;
    			state.call = null;
    			Files.updateMaxUploadFilesize(response);
    		});
    	},
    	updateStorageStatistics: function(force) {
    		if (!OC.currentUser) {
    			return;
    		}
    
    		// debounce to prevent calling too often
    		if (Files._updateStorageStatisticsTimeout) {
    			clearTimeout(Files._updateStorageStatisticsTimeout);
    		}
    		if (force) {
    			Files._updateStorageStatistics();
    		}
    		else {
    			Files._updateStorageStatisticsTimeout = setTimeout(Files._updateStorageStatistics, 250);
    		}
    	},
    
    	updateMaxUploadFilesize:function(response) {
    		if (response === undefined) {
    			return;
    		}
    		if (response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
    			$('#max_upload').val(response.data.uploadMaxFilesize);
    			$('#free_space').val(response.data.freeSpace);
    			$('#upload.button').attr('original-title', response.data.maxHumanFilesize);
    			$('#usedSpacePercent').val(response.data.usedSpacePercent);
    			Files.displayStorageWarnings();
    		}
    		if (response[0] === undefined) {
    			return;
    		}
    		if (response[0].uploadMaxFilesize !== undefined) {
    			$('#max_upload').val(response[0].uploadMaxFilesize);
    			$('#upload.button').attr('original-title', response[0].maxHumanFilesize);
    			$('#usedSpacePercent').val(response[0].usedSpacePercent);
    			Files.displayStorageWarnings();
    		}