Index: /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/fluid-components/js/fluid/uploader/gears_init.js =================================================================== --- /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/fluid-components/js/fluid/uploader/gears_init.js (revision 6498) +++ /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/fluid-components/js/fluid/uploader/gears_init.js (working copy) @@ -1,86 +0,0 @@ -// Copyright 2007, Google Inc. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// 3. Neither the name of Google Inc. nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Sets up google.gears.*, which is *the only* supported way to access Gears. -// -// Circumvent this file at your own risk! -// -// In the future, Gears may automatically define google.gears.* without this -// file. Gears may use these objects to transparently fix bugs and compatibility -// issues. Applications that use the code below will continue to work seamlessly -// when that happens. - -(function() { - // We are already defined. Hooray! - if (window.google && google.gears) { - return; - } - - var factory = null; - - // Firefox - if (typeof GearsFactory != 'undefined') { - factory = new GearsFactory(); - } else { - // IE - try { - factory = new ActiveXObject('Gears.Factory'); - // privateSetGlobalObject is only required and supported on WinCE. - if (factory.getBuildInfo().indexOf('ie_mobile') != -1) { - factory.privateSetGlobalObject(this); - } - } catch (e) { - // Safari - if ((typeof navigator.mimeTypes != 'undefined') - && navigator.mimeTypes["application/x-googlegears"]) { - factory = document.createElement("object"); - factory.style.display = "none"; - factory.width = 0; - factory.height = 0; - factory.type = "application/x-googlegears"; - document.documentElement.appendChild(factory); - } - } - } - - // *Do not* define any objects if Gears is not installed. This mimics the - // behavior of Gears defining the objects in the future. - if (!factory) { - return; - } - - // Now set up the objects, being careful not to overwrite anything. - // - // Note: In Internet Explorer for Windows Mobile, you can't add properties to - // the window object. However, global objects are automatically added as - // properties of the window object in all browsers. - if (!window.google) { - google = {}; - } - - if (!google.gears) { - google.gears = {factory: factory}; - } -})(); Index: /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/fluid-components/js/fluid/uploader/GearsUploadManager.js =================================================================== --- /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/fluid-components/js/fluid/uploader/GearsUploadManager.js (revision 6498) +++ /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/fluid-components/js/fluid/uploader/GearsUploadManager.js (working copy) @@ -1,136 +0,0 @@ -/*global google*/ -/*global jQuery*/ -/*global fluid_0_7*/ - -fluid_0_8 = fluid_0_8 || {}; - -(function ($, fluid) { - - var browseForFiles = function (that) { - that.events.onFileDialog.fire(); - - var openFileOptions = { - singleFile: (that.options.fileQueueLimit === 1) ? true : false, - filter: that.options.fileTypes - }; - - that.gearsDesktop.openFiles(function (files) { - that.addFiles(files); - that.events.afterFileDialog.fire(files.length, files.length, that.queue.files.length); - }, openFileOptions); - }; - - var addFiles = function (that, files) { - // Add the files to our queue and tell the world about it. - $.each(files, function (idx, file) { - file.filestatus = fluid.uploader.fileStatusConstants.QUEUED; - file.size = file.blob.length; - fluid.allocateSimpleId(file); - - that.queue.addFile(file); - that.events.afterFileQueued.fire(file); - }); - }; - - var updateProgress = function (that, progressEvent) { - that.events.fire.onFileProgress(that.queue.currentBatch.files[that.queue.currentBatch.fileIdx], - progressEvent.loaded, - progressEvent.total); // Fix me; gears returns an accumated loaded - // Whereas our event semantics assume a block value - // since the last event. - - // Need the queue management code from the various event listeners in SWFUploadManager here and in other places! - }; - - var completeFile = function (that, file) { - that.events.afterFileComplete.fire(file); - }; - - var createReadyStateChangedHandler = function (that, file, uploadRequest) { - return function () { - if (uploadRequest.readyState === 4) { - completeFile(that, file); - } - }; - }; - - var postFile = function (that, file) { - if (!file) { - return; - } - - var uploadRequest = google.gears.factory.create('beta.httprequest'); - uploadRequest.open("POST", that.options.uploadURL); - uploadRequest.onreadystatechange = createReadyStateChangedHandler(that, file, uploadRequest); - uploadRequest.onprogress = that.updateProgress; - uploadRequest.send(file.blob); - }; - - var startUploadingFiles = function (that) { - that.queueManager.start(); - that.queueManager.startFile(); - var file = that.queue.currentBatch.files[that.queue.currentBatch.fileIdx]; - postFile(that, file); - }; - - var setupGearsUploadManager = function (that, events) { - that.queue = fluid.fileQueue(); - that.events = events; - that.queueManager = fluid.fileQueue.manager(that.queue, that.events); - that.gearsDesktop = google.gears.factory.create("beta.desktop"); - that.events.afterReady.fire(); - }; - - fluid.gearsUploadManager = function (events, options) { - var that = {}; - fluid.mergeComponentOptions(that, "fluid.gearsUploadManager", options); - fluid.mergeListeners(that.events, that.options.listeners); - - /** - * Starts uploading all queued files to the server. - */ - that.start = function () { - startUploadingFiles(that); - }; - - /** - * Adds new files to the queue. - * @param {Array} files an array of files to add - */ - that.addFiles = function (files) { - addFiles(that, files); - }; - - /** - * Removes a file from the queue. - * @param {File} the file to remove - */ - that.removeFile = function (file) { - that.queue.removeFile(); - that.events.afterFileRemoved.fire(file); - }; - - /** - * Opens the native OS browse file dialog using Gears. - */ - that.browseForFiles = function () { - browseForFiles(that); - }; - - that.updateProgress = function (progressEvent) { - updateProgress(that, progressEvent); - }; - - setupGearsUploadManager(that, events); - return that; - }; - - fluid.defaults("fluid.gearsUploadManager", { - uploadURL: "", - fileSizeLimit: "20480", - fileTypes: undefined, - fileUploadLimit: 0, - fileQueueLimit: 0 - }); - -})(jQuery, fluid_0_8); Index: /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/tests/fluid-tests/uploader/DemoUploadManager-test.html =================================================================== --- /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/tests/fluid-tests/uploader/DemoUploadManager-test.html (revision 6498) +++ /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/tests/fluid-tests/uploader/DemoUploadManager-test.html (working copy) @@ -13,8 +13,6 @@ - - @@ -29,6 +27,7 @@
    Index: /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/tests/fluid-tests/uploader/js/DemoUploadManagerTests.js =================================================================== --- /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/tests/fluid-tests/uploader/js/DemoUploadManagerTests.js (revision 6498) +++ /Users/justin/Documents/Aptana Studio/fluid-components/src/webapp/tests/fluid-tests/uploader/js/DemoUploadManagerTests.js (working copy) @@ -111,8 +111,9 @@ demoManager.options.flashURL); // Test an alternative option. simulateDelay should be false. - demoManager = fluid.demoUploadManager(fluid.gearsUploadManager(events, { - simulateDelay: false + demoManager = fluid.demoUploadManager(fluid.swfUploadManager(events, { + simulateDelay: false, + flashButtonPeerId: "otherPlaceholder" })); jqUnit.assertFalse("simulateDelay should be false.", demoManager.options.simulateDelay); });