Skip to content

Commit

Permalink
- documentation and showcase tweaks, release is close
Browse files Browse the repository at this point in the history
 - smashed smaller bugs
  • Loading branch information
Harald Kirschner committed Apr 30, 2009
1 parent d412191 commit 2a40a5f
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 59 deletions.
55 changes: 39 additions & 16 deletions meta.md
Expand Up @@ -22,9 +22,10 @@ Features {#features}
* Set the filename for the upload request
* New in 3.0 (Completely rewritten API)
* Fully Flash 9 and 10 compatible and an additional IFrame-based uploader
* Browse-button can be an invisible overlay or an image sprite (for the different states)
* Event based Flash communication, future-proof und more stable
* File-specific options for setting url, data, method
* Browse-button can be an invisible overlay or an interactive image sprite
* Event based Flash communication, future-proof und more stable
* File-specific options for setting url, data and method, intelligently merged
* Append cookies automatically to the request data
* Relative URLs are converted automatically


Expand Down Expand Up @@ -59,7 +60,7 @@ Documentation {#docs}

### Returns:

* (*object|false*) - New Swiff.Uploader instance or false if detected Flash version is smaller than 9.
* (*object|false*) - New Swiff.Uploader instance.

#### Options:

Expand Down Expand Up @@ -178,7 +179,13 @@ The overall loaded percentage of running and completed files in the list.

The overall rate of running files in the list in *bytes/second*.

FAQ: Tips, Tricks, Quirks {#faq}
### Class: Swiff.Uploader.File

Mirrors several methods and events from the documentation above. Custom
file classes usually extends it and are given to `Swiff.Uploader` via the
*fileClass* option.

FAQ, Tips, Tricks, Quirks {#faq}
-------------------

How do I access the uploaded files?
Expand All @@ -194,7 +201,7 @@ How do I access the uploaded files?

Flash-request forgets cookies and session ID

: Flash FileReference is not an intelligent upload class, the request will not have the browser cookies, Flash saves his own cookies. When you have sessions, append them as get-data to the the URL (e.g. "upload.php?SESSID=123456789abcdef"). Of course your session-name can be different.
: See option `appendCookieData`. Flash FileReference is not an intelligent upload class, the request will not have the browser cookies, Flash saves his own cookies. When you have sessions, append them as get-data to the the URL (e.g. "upload.php?SESSID=123456789abcdef"). Of course your session-name can be different.

Are cross-domain uploads possible?

Expand Down Expand Up @@ -235,31 +242,47 @@ Uploads and Basic Authentication
Requirements {#requirements}
-------------------

*It does not depend on any server-side architecture or language.*
**It does not depend on any server-side architecture or language.**

### MooTools JavaScript Framework 1.2

[__Download MooTools 1.2__](http://mootools.net/core).
You can include MooTools via [Google AJAX Libraries API](http://code.google.com/apis/ajaxlibs/documentation/#mootools),
follow the link for more information and why it can be good for your site.

#### [Required MooTools Core components](http://mootools.net/core/):

- Element.Events
- Element.Dimensions
- Fx.Tween
- Fx.Transitions
- Selectors
- Json
- JSON
- Swiff
- _DomReady (facultative)_
- DomReady (_facultative_)

**Don't use compressed code during development to simplify debugging.**

Download {#download}
-------------------

* [FancyUpload2.js](source/FancyUpload2.js)
* [Swiff.Uploader.js](source/Swiff.Uploader.js)
* [Fx.ProgressBar.js](source/Fx.ProgressBar.js "Will get his own project page later")
* [Swiff.Uploader.swf](source/Swiff.Uploader.swf "It is a hidden, 1px movie and only contains ActionScript!") (*Use right-click/save-as!*)
* Complete ActionScript/JavaScript source, documentation and showcases are available at [github](http://github.com/): [digitarald-fancyupload repository](https://github.com/digitarald/digitarald-fancyupload)
* The [images](http://github.com/digitarald/digitarald-fancyupload/tree/master/assets) from the [showcases](/project/fancyupload/2-0/showcase/photoqueue/) are also [downloadable](http://github.com/digitarald/digitarald-fancyupload/tree/master/assets).
Complete ActionScript/JavaScript source, documentation and showcases are available at [github](http://github.com/), in my [fancyupload repository](https://github.com/digitarald/digitarald-fancyupload).

### Packages

* [**Working FancyUpload Installation**]() - The package that everybody waited for, a working FancyUpload to unpack and start play.
* [**Sources including Showcases**]() - The source and all showcases from this page in one package, the package for *web craftsmen* ;).

### Single Files

* [Swiff.Uploader.js](source/Swiff.Uploader.js) - Flash based uploader, energizer for all possible upload interfaces
* [Swiff.Uploader.swf](source/Swiff.Uploader.swf) - The movie used by the uploader class. *Use right-click/save-as!*
* [FancyUpload2.js](source/FancyUpload2.js) - The famous & fancy interface, converted to the new 3.0 API.
* [Uploader.js](source/Swiff.Uploader.js) - IFrame based class with the same API, but without progress.
* [Fx.ProgressBar.js](source/Fx.ProgressBar.js) - Class to create and animate progress-bars.

* The [images](http://github.com/digitarald/digitarald-fancyupload/tree/master/assets) from the [showcases](#showcases) are also [downloadable](http://github.com/digitarald/digitarald-fancyupload/tree/master/assets).

**You** can contribute by reporting problems and bugs in the [issue tracker](http://github.com/digitarald/digitarald-fancyupload/issues) on github or in the [support forum](/forums/) to discuss it.

References {#references}
-------------------
Expand Down
1 change: 1 addition & 0 deletions showcase/all-inclusive/meta.json
@@ -1,5 +1,6 @@
{
"title": "All Inclusive",
"script_php": "../script.php",
"files": [
"http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js",
"../../source/Swiff.Uploader.js"
Expand Down
1 change: 1 addition & 0 deletions showcase/attach-a-file/meta.json
@@ -1,5 +1,6 @@
{
"title": "Attach a File",
"script_php": "../script.php",
"files": [
"http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js",
"../../source/Fx.ProgressBar.js",
Expand Down
1 change: 1 addition & 0 deletions showcase/iframe-queue/meta.json
@@ -1,5 +1,6 @@
{
"title": "Attach a File with IFrames",
"script_php": "../script.php",
"files": [
"http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js",
"../../source/Fx.ProgressBar.js",
Expand Down
7 changes: 5 additions & 2 deletions showcase/iframe-queue/script.js
Expand Up @@ -35,8 +35,8 @@ window.addEvent('domready', function() {

this.addEvents({
'start': this.onStart,
'remove': this.onRemove,
'stop': this.onStop,
'remove': this.onRemove,
'complete': this.onComplete
});

Expand Down Expand Up @@ -68,9 +68,12 @@ window.addEvent('domready', function() {
},

onStop: function() {
this.remove();
},

onRemove: function() {
// stop removes the file entry
this.ui = this.ui.element.destroy();
this.remove();
},

onComplete: function() {
Expand Down
2 changes: 1 addition & 1 deletion showcase/photoqueue/docs.md
@@ -1,7 +1,7 @@
What happens?
----------------

Check the automated [**log**](script.log) file after upload. The PHP script does not save the files but logs every request.
Check the automated [**log**](../script.log) file after upload. The PHP script does not save the files but logs every request.

Check the Firebug console for event debugging logs. *Filesize is limited to 2Mb (client- and serverside).*

Expand Down
5 changes: 3 additions & 2 deletions showcase/photoqueue/meta.json
@@ -1,11 +1,12 @@
{
"title": "Queued Photo Uploader",
"description": "Showcase with converted FancyUpload.",
"script_php": "../script.php",
"files": [
"http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js",
"../../source/Swiff.Uploader.js",
"../../source/Fx.ProgressBar.js",
"http://github.com/mootools/mootools-more/raw/master/Source/Core/Lang.js",
"FancyUpload2.js"
"../../source/FancyUpload2.js",
"http://github.com/mootools/mootools-more/raw/master/Source/Core/Lang.js"
]
}
1 change: 1 addition & 0 deletions showcase/simple-button/meta.json
@@ -1,5 +1,6 @@
{
"title": "Simple Button",
"script_php": "../script.php",
"files": [
"http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js",
"../../source/Fx.ProgressBar.js",
Expand Down
14 changes: 11 additions & 3 deletions showcase/single-file-button/docs.md
@@ -1,4 +1,12 @@
**What will happen?**
### What happens?

* Selecting one image
* Instant upload
1. Select an image smaller than 2 Mb.
* If the file is too big, the uploader gives you a warning.
* After selecting a file, the browse button gets disabled.
2. The image is uploaded, the button changes its text to the progress info.
3. The server-side [PHP script](../script.php) logs the upload (**see [.log](../script.log)**).
* This demo appends the browsers cookie data automatically (option `appendCookieData`), therefore the POST values contain the `SID`.
4. A JSON response is returned, including a *MD5 hash*, [generated](http://docs.php.net/manual/en/function.md5-file.php) from the file content.
5. The hash is used to get a [monsterid](http://scott.sherrillmix.com/blog/blogger/wp_monsterid/) from [gravatar](http://en.gravatar.com/site/implement/url), so every file has an unique gravatar (nothing actually useful, just to show off the server-side processing, since we don't save the file)

Update messages are presented by [Roar Notifications](http://digitarald.de/project/roar/).
2 changes: 2 additions & 0 deletions showcase/single-file-button/meta.json
@@ -1,5 +1,7 @@
{
"title": "Single File Button",
"description": "A simple implementation of the Swiff.Uploader class",
"script_php": "../script.php",
"files": [
"http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js",
"../../source/Fx.ProgressBar.js",
Expand Down
14 changes: 6 additions & 8 deletions showcase/single-file-button/script.js
Expand Up @@ -8,13 +8,13 @@

window.addEvent('domready', function() {

// One Roar instance for our notofications, positioned in the top-right corner of our demo.
var log = new Roar({
container: $('demo'),
position: 'topRight',
duration: 5000
});


var link = $('select-0');
var linkIdle = link.get('html');

Expand All @@ -24,9 +24,7 @@ window.addEvent('domready', function() {
link.set('html', '<span class="small">' + swf.percentLoaded + '% of ' + size + '</span>');
}

/**
* Uploader instance
*/
// Uploader instance
var swf = new Swiff.Uploader({
path: '../../source/Swiff.Uploader.swf',
url: '../script.php',
Expand All @@ -41,14 +39,16 @@ window.addEvent('domready', function() {
fileSizeMax: 2 * 1024 * 1024,
onSelectSuccess: function(files) {
if (Browser.Platform.linux) window.alert('Warning: Due to a misbehaviour of Adobe Flash Player on Linux,\nthe browser will probably freeze during the upload process.\nSince you are prepared now, the upload will start right away ...');
this.setEnabled(false);
log.alert('Starting Upload', 'Uploading <em>' + files[0].name + '</em> (' + Swiff.Uploader.formatUnit(files[0].size, 'b') + ')');
this.setEnabled(false);
},
onSelectFail: function(files) {
log.alert('<em>' + files[0].name + '</em> was not added!', 'Please select an image smaller than 2 Mb. (Error: #' + files[0].validationError + ')');
},
appendCookieData: true,
onQueue: linkUpdate,
onFileComplete: function(file) {

// We *don't* save the uploaded images, we only take the md5 value and create a monsterid ;)
if (file.response.error) {
log.alert('Failed Upload', 'Uploading <em>' + this.fileList[0].name + '</em> failed, please try again. (Error: #' + this.fileList[0].response.code + ' ' + this.fileList[0].response.error + ')');
Expand All @@ -70,9 +70,7 @@ window.addEvent('domready', function() {
}
});

/**
* Button state
*/
// Button state
link.addEvents({
click: function() {
return false;
Expand Down
49 changes: 27 additions & 22 deletions showcase/photoqueue/FancyUpload2.js → source/FancyUpload2.js
Expand Up @@ -205,25 +205,30 @@ FancyUpload2.File = new Class({

});

MooTools.lang.set('en-US', 'FancyUpload', {
'progressOverall': 'Overall Progress ({total})',
'currentTitle': 'File Progress',
'currentFile': 'Uploading "{name}"',
'currentProgress': 'Upload: {bytesLoaded} with {rate}, {timeRemaining} remaining.',
'fileName': '{name}',
'remove': 'Remove',
'removeTitle': 'Click to remove this entry.',
'fileError': 'File was not uploaded',
'validationErrors': {
'duplicate': 'File <em>{name}</em> is already added, duplicates are not allowed.',
'sizeLimitMin': 'File <em>{name}</em> is too small, please check the minimal file size.',
'sizeLimitMax': 'File <em>{name}</em> is too big, please check the maximal file size.',
'fileListMax': 'File <em>{name}</em> could not be added, amount of files exceeded limit.',
'fileListSizeMax': 'File <em>{name}</em> is too big, overall filesize exceeded limit.'
},
'errors': {
'httpError': 'Server returned HTTP-Status #{code}',
'securityError': 'Security error occured ({text})',
'ioError': 'Error caused a send or load operation to fail ({text})'
}
});
(function() {
var phrases = {
'progressOverall': 'Overall Progress ({total})',
'currentTitle': 'File Progress',
'currentFile': 'Uploading "{name}"',
'currentProgress': 'Upload: {bytesLoaded} with {rate}, {timeRemaining} remaining.',
'fileName': '{name}',
'remove': 'Remove',
'removeTitle': 'Click to remove this entry.',
'fileError': 'File was not uploaded',
'validationErrors': {
'duplicate': 'File <em>{name}</em> is already added, duplicates are not allowed.',
'sizeLimitMin': 'File <em>{name}</em> is too small, please check the minimal file size.',
'sizeLimitMax': 'File <em>{name}</em> is too big, please check the maximal file size.',
'fileListMax': 'File <em>{name}</em> could not be added, amount of files exceeded limit.',
'fileListSizeMax': 'File <em>{name}</em> is too big, overall filesize exceeded limit.'
},
'errors': {
'httpError': 'Server returned HTTP-Status #{code}',
'securityError': 'Security error occured ({text})',
'ioError': 'Error caused a send or load operation to fail ({text})'
}
};

if (MooTools.lang) MooTools.lang.set('en-US', 'FancyUpload', phrases);
else MooTools.lang = new Hash({'FancyUpload': phrases});
})();
8 changes: 3 additions & 5 deletions source/Uploader.js
Expand Up @@ -279,8 +279,6 @@ Uploader.File = new Class({
document: doc,
text: doc.innerHTML || ''
};

console.log(doc.childNodes);

this.base.uploading--;
this.dates.complete = new Date();
Expand Down Expand Up @@ -362,9 +360,9 @@ Uploader.File = new Class({
this.base.uploading--;
this.base.start();
if (!soft) {
this.iframe.contentWindow.history.back();
this.fireEvent('stop');
}
this.iframe.contentWindow.history.back();
this.fireEvent('stop');
}
}
return this;
},
Expand Down

0 comments on commit 2a40a5f

Please sign in to comment.