}, this).on('g:upload.progress', function (info) { var currentProgress = info.startByte + info.loaded; this.$('.g-markdown-upload-progress>.progress-bar').css('width', Math.ceil(100 * currentProgress / info.total) + '%'); this.$('.g-markdown-upload-progress-message').text( 'Uploading ' + info.file.name + ' - ' + formatSize(currentProgress) + ' / ' + formatSize(info.total) ); }, this).on('g:upload.error', function (info) {
capacityChart: function (el) { var assetstore = this.collection.get($(el).attr('cid')); var capacity = assetstore.get('capacity'); var used = capacity.total - capacity.free; var data = [ ['Used (' + formatSize(used) + ')', used], ['Free (' + formatSize(capacity.free) + ')', capacity.free] ]; var plot = $(el).jqplot([data], { seriesDefaults: { renderer: $.jqplot.PieRenderer, rendererOptions: { sliceMargin: 2, shadow: false, highlightMouseOver: false, showDataLabels: true, padding: 5, startAngle: 180 } }, legend: { show: true, location: 'e', background: 'transparent', border: 'none' }, grid: { background: 'transparent', border: 'none', borderWidth: 0, shadow: false }, gridPadding: {top: 10, right: 10, bottom: 10, left: 10} }); this.plots.push(plot); },
validateFiles: function (files) { files = files || this.files; if (this.files.length !== 1) { throw new Error('Please add only one file at a time.'); } var file = files[0], ext = file.name.split('.').pop().toLowerCase(); if (this.maxUploadSize && file.size > this.maxUploadSize) { throw new Error( 'That file is too large. You may only attach files ' + 'up to ' + formatSize(this.maxUploadSize) + '.' ); } if (this.allowedExtensions && !_.contains(this.allowedExtensions, ext)) { throw new Error( 'Only files with the following extensions are allowed: ' + this.allowedExtensions.join(', ') + '.' ); } },