Index: branches/RC/core/admin_templates/js/uploader/upload_manager.js =================================================================== diff -u -r10705 -r11281 --- branches/RC/core/admin_templates/js/uploader/upload_manager.js (.../upload_manager.js) (revision 10705) +++ branches/RC/core/admin_templates/js/uploader/upload_manager.js (.../upload_manager.js) (revision 11281) @@ -21,19 +21,40 @@ UploadsManager.uploadCancelled = false; /* ==== Private methods ==== */ +UploadsManager.setScrollEvents = function() { + var $scroll_container = this._getScrollContainer(); + + addEvent( + $scroll_container, + 'scroll', + function(ev) { + UploadsManager.iterate('syncBrowseButton'); + } + ) +} + UploadsManager._nextFlashId = function() { this._nextId++; return 'uploaderflash' + this._nextId; } -UploadsManager._getFromContainer = function() { +UploadsManager._getFormContainer = function() { if (UploadsManager.formContainerId) { return document.getElementById(UploadsManager.formContainerId); } return Form.Div; } + +UploadsManager._getScrollContainer = function() { + if (UploadsManager.formContainerId) { + return document.body; + } + + return document.getElementById(Form.Div.id + '_container'); +} + UploadsManager._initAll = function() { this._createHooks(); @@ -42,6 +63,15 @@ } } +UploadsManager.iterate = function($method) { + for (var i in this._Uploaders) { + var args = Array.prototype.slice.call(arguments); // convert to array + args.splice(0, 1); // remove method name + + this._Uploaders[i][$method].apply(this._Uploaders[i], args); + } +} + UploadsManager._hasQueue = function() { var has_queue = false; @@ -117,21 +147,13 @@ ); } -UploadsManager.Browse = function(id) { - this._Uploaders[id].queueEvent( - function() { - this.browse(); - } - ); -} - UploadsManager.StartUpload = function(id) { UploadsManager._singleUpload = true; this._Uploaders[id].startUpload(); } UploadsManager.CancelFile = function(id, file_id) { - this._Uploaders[id].flash.CancelUpload(file_id); + this._Uploaders[id].callFlash('CancelUpload', [file_id]); } UploadsManager.UploadAll = function(onAllUploaded) { @@ -161,8 +183,7 @@ } if ($queue_owner) { - // hide progress bar only of uploader, that completed it's queue - this._Uploaders[i].div.style.display = 'none'; + this._Uploaders[i].finalizeUpload(); } var $empty_queue = !this._Uploaders[i].hasQueue(); @@ -171,9 +192,14 @@ $all_processed = $all_processed && ($empty_queue || this._Uploaders[i].uploadCancelled); } + if ($all_processed) { + // enable all browse button, when upload is totally completed or cancelled + UploadsManager.iterate('disableBrowse', false); + } + if (UploadsManager.useTransparency && $all_processed) { // remove transparency, when all uploaders are done - Request.setOpacity(100, UploadsManager._getFromContainer()); + Request.setOpacity(100, UploadsManager._getFormContainer()); } if ($all_uploaded && isset(this.OnAllUploaded) && !this.uploadCancelled) { @@ -187,7 +213,7 @@ UploadsManager.setDebugMode = function ($enabled) { /*for (var $uploader_index in this._Uploaders) { - this._Uploaders[$uploader_index].flash.SetDebugEnabled($enabled); + this._Uploaders[$uploader_index].clallFlash('SetDebugEnabled', [$enabled]); }*/ this._debugMode = $enabled; @@ -233,19 +259,16 @@ UploadsManager.onFileQueued = function(file) { var $uploader = UploadsManager._getUploader(file); +// file = this.unescapeFilePostParams(file); $uploader.queueEvent( function() { - this.flash.AddFileParam(file.id, 'field', this.params.field); - this.flash.AddFileParam(file.id, 'id', file.id); - this.flash.AddFileParam(file.id, 'flashsid', this.params.flashsid); - if (this.files_count >= this.params.multiple) { // new file can exceed allowed file number if (this.params.multiple > 1) { // it definetly exceed it UploadsManager.onFileQueueError(file, -100, this.params.multiple); - this.flash.CancelUpload(file.id); + this.callFlash('CancelUpload', [file.id]); } else { // delete file added @@ -256,7 +279,7 @@ UploadsManager.DeleteFile(UploadsManager._getUploader(file).id, this.files[0].name, true); } else { - this.flash.CancelUpload(this.files[0].id); + this.callFlash('CancelUpload', [this.files[0].id]); } } } @@ -346,6 +369,10 @@ alert('Error [' + errorCode + ']: ' + message + "\n" + 'Occured on file ' + file.name); } +UploadsManager.onFlashReady = function ($uploader_id) { + this._Uploaders[$uploader_id].onFlashReady(); +} + UploadsManager.onDebug = function (message) { if (!UploadsManager._debugMode) { return ;