diff --git a/cpanfile b/cpanfile index 265bb40..93b7cf7 100644 --- a/cpanfile +++ b/cpanfile @@ -1,4 +1,4 @@ -requires 'Mojolicious'; +requires 'Mojolicious', '>= 7.88'; requires 'Mojolicious::Plugin::Authentication'; requires 'Imager'; requires 'File::Basename'; diff --git a/fotostore.pl b/fotostore.pl index e2c7abe..96da165 100755 --- a/fotostore.pl +++ b/fotostore.pl @@ -4,11 +4,14 @@ use warnings; use lib 'lib'; use Mojolicious::Lite; # app, get, post is exported. +use Mojo::Promise; +use Mojo::IOLoop; -use File::Basename 'basename'; +use File::Basename qw/basename fileparse/; use File::Path 'mkpath'; use File::Spec 'catfile'; use Cwd; +use POSIX; use Imager; use DBI; @@ -43,6 +46,8 @@ my $sha = Digest::SHA->new('sha256'); # Directory to save image files my $IMAGE_DIR = File::Spec->catfile( getcwd(), 'public', $IMAGE_BASE ); +my $log = Mojo::Log->new(); + plugin 'authentication', { autoload_user => 1, load_user => sub { @@ -92,10 +97,10 @@ get '/register' => ( authenticated => 0 ) => sub { post '/register' => ( authenticated => 0 ) => sub { my $self = shift; - my $username = $self->req->param('username'); - my $password = $self->req->param('password'); - my $fullname = $self->req->param('fullname'); - my $invite = $self->req->param('invite'); + my $username = $self->req->param('username') || ""; + my $password = $self->req->param('password') || ""; + my $fullname = $self->req->param('fullname') || ""; + my $invite = $self->req->param('invite') || ""; if ( $invite eq $config->{'invite_code'} ) { @@ -141,10 +146,21 @@ get '/' => sub { get '/get_images' => ( authenticated => 1 ) => sub { my $self = shift; + #Getting current user my $current_user = $self->current_user; my $user_id = $current_user->{'user_id'}; - my $files_list = $db->get_files( $current_user->{'user_id'}, 20 ); + #Getting images list with paging + my $page = $self->param('page') || 1; + my $items = $self->param('per-page') || 20; + + if (($page !~ /^\d+$/) || ($page <= 1)) { $page = 1} + if (($items !~ /^\d+$/) || ($items <= 0)) { $items = 20} + + # process images list + my $req_result = $db->get_files( $current_user->{'user_id'}, $items , $page); + my $files_list = $req_result->{'images_list'}; + my $pages_count = ceil($req_result->{'total_rows'}/$items); my $thumbs_dir = File::Spec->catfile( $IMAGE_DIR, $current_user->{'user_id'}, @@ -157,6 +173,7 @@ get '/get_images' => ( authenticated => 1 ) => sub { for my $img_item (@$files_list) { my $file = $img_item->{'file_name'}; my $img_hash = {}; + $img_hash->{'id'} = $img_item->{'file_id'}; $img_hash->{'filename'} = $img_item->{'original_filename'}; $img_hash->{'original_url'} = File::Spec->catfile( '/', $IMAGE_BASE, $current_user->{'user_id'}, @@ -185,10 +202,14 @@ get '/get_images' => ( authenticated => 1 ) => sub { $img_hash->{'scales'} = \@scaled; push( @$images, $img_hash ); + + } + my $reply_data = { current_page => $page, items_per_page => $items, pages_count => $pages_count, images_list => $images }; + # Render - return $self->render( json => $images ); + return $self->render( json => $reply_data ); }; # Upload image file @@ -201,7 +222,6 @@ post '/upload' => ( authenticated => 1 ) => sub { my $user = $self->current_user(); my $user_id = $user->{'user_id'}; - $self->app->log->debug( "user:" . Dumper($user) ); # Not upload unless ($image) { @@ -213,7 +233,11 @@ post '/upload' => ( authenticated => 1 ) => sub { # Check file type my $image_type = $image->headers->content_type; - my %valid_types = map { $_ => 1 } qw(image/gif image/jpeg image/png); + my %valid_types = ( + 'image/gif' => 'gif', + 'image/jpeg' => 'jpg', + 'image/png' => 'png' + ); # Content type is wrong unless ( $valid_types{$image_type} ) { @@ -223,13 +247,7 @@ post '/upload' => ( authenticated => 1 ) => sub { ); } - # Extention - my $exts = { - 'image/gif' => 'gif', - 'image/jpeg' => 'jpg', - 'image/png' => 'png' - }; - my $ext = $exts->{$image_type}; + my $ext = $valid_types{$image_type}; # Image file my $filename = sprintf( '%s.%s', create_hash( $image->slurp() ), $ext ); @@ -239,58 +257,24 @@ post '/upload' => ( authenticated => 1 ) => sub { # Save to file $image->move_to($image_file); - my $imager = Imager->new(); - $imager->read( file => $image_file ) or die $imager->errstr; - - #http://sylvana.net/jpegcrop/exif_orientation.html - #http://myjaphoo.de/docs/exifidentifiers.html - my $rotation_angle = $imager->tags( name => "exif_orientation" ) || 1; - $self->app->log->info( - "Rotation angle [" . $rotation_angle . "] [" . $image->filename . "]" ); - - if ( $rotation_angle == 3 ) { - $imager = $imager->rotate( degrees => 180 ); - } - elsif ( $rotation_angle == 6 ) { - $imager = $imager->rotate( degrees => 90 ); - } - - my $original_width = $imager->getwidth(); - - for my $scale (@scale_width) { - - #Skip sizes which more than original image - if ( $scale >= $original_width ) { - next; - } - - my $scaled = $imager->scale( xpixels => $scale ); - - $scaled->write( file => - File::Spec->catfile( get_path( $user_id, $scale ), $filename ) ) - or die $scaled->errstr; - } - - if ( !$db->add_file( $user->{'user_id'}, $filename, $image->filename ) ) { - - #TODO: Send error msg - } - - $self->render( - json => { - files => [ - { - name => $image->filename, - size => $image->size, - url => sprintf( '/images/orig/%s', $filename ), - thumbnailUrl => sprintf( '/images/200/%s', $filename ), + + my $promise = store_image($image_file, $image->filename, $user_id); + + #TODO: add errors handling + Mojo::Promise->all($promise)->then(sub { + $self->render( + json => { + files => [ + { + name => $image->filename, + size => $image->size, + url => sprintf( '/images/orig/%s', $filename ), + thumbnailUrl => sprintf( '/images/200/%s', $filename ), + } + ] } - ] - } - ); - - # Redirect to top page - # $self->redirect_to('index'); + ); + })->wait; } => 'upload'; @@ -310,4 +294,68 @@ sub get_path { return $path; } +sub store_image { + my $image_file = shift; + my $original_filename = shift; + my $user_id = shift; + + my $promise = Mojo::Promise->new; + # Process and store uploaded file in a separate process + Mojo::IOLoop->subprocess( + sub { + my $subprocess = shift; + + my $filename = fileparse($image_file); + my $imager = Imager->new(); + $imager->read( file => $image_file ) or die $imager->errstr; + + #http://sylvana.net/jpegcrop/exif_orientation.html + #http://myjaphoo.de/docs/exifidentifiers.html + my $rotation_angle = $imager->tags( name => "exif_orientation" ) || 1; + $log->debug( + "Rotation angle [" . $rotation_angle . "]" ); + + if ( $rotation_angle == 3 ) { + $imager = $imager->rotate( degrees => 180 ); + } + elsif ( $rotation_angle == 6 ) { + $imager = $imager->rotate( degrees => 90 ); + } + + my $original_width = $imager->getwidth(); + + for my $scale (@scale_width) { + + #Skip sizes which more than original image + if ( $scale >= $original_width ) { + next; + } + + my $scaled = $imager->scale( xpixels => $scale ); + + $scaled->write( file => + File::Spec->catfile( get_path( $user_id, $scale ), $filename ) ) + or die $scaled->errstr; + } + + if ( !$db->add_file( $user_id, $filename, $original_filename ) ) { + + $log->error(sprintf('Can\'t save file %s', $filename)); + die sprintf('Can\'t save file %s', $filename); + } + + return $filename; + }, + sub { + my ($subprocess, $err, @results) = @_; + $log->error("Subprocess error: $err") and return if $err; + $promise->reject("Subprocess error: $err @results") if $err; + $promise->resolve(1, @results); + } + ); + + return $promise; +} + +Mojo::IOLoop->start; app->start; diff --git a/lib/FotoStore/DB.pm b/lib/FotoStore/DB.pm index 49dea87..4951676 100644 --- a/lib/FotoStore/DB.pm +++ b/lib/FotoStore/DB.pm @@ -1,5 +1,6 @@ package FotoStore::DB; +use v5.20; use strict; use warnings; @@ -59,8 +60,17 @@ sub add_file($self, $user_id, $filename, $original_filename) { return $rows; } -sub get_files($self, $user_id, $count=20, $start_at=0) { - return $self->{'dbh'}->selectall_arrayref(q~select * from images where owner_id=? order by created_time desc~, { Slice => {} }, $user_id ); +sub get_files($self, $user_id, $items_count=20, $page=1) { + + # Calculate offset + # Pages in UI starts from 1, but here we need it to start from 0 + $page = 1 if ($page < 1); + my $start_at = --$page * $items_count; + + my ($rows_count) = $self->{'dbh'}->selectrow_array(q~select count(*) from images where owner_id=? ~, undef , $user_id); + my $images_list = $self->{'dbh'}->selectall_arrayref(q~select * from images where owner_id=? order by created_time desc LIMIT ? OFFSET ? ~, { Slice => {} }, $user_id, $items_count, $start_at ); + + return { total_rows => $rows_count, images_list => $images_list }; } 1; \ No newline at end of file diff --git a/public/css/main.css b/public/css/main.css index aaeba2a..17b16a1 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -15,6 +15,15 @@ padding: 5px; } +.copy-img:before { + content: url(/img/copy_icon.png); + width: 32px; + height: 32px; + overflow: hidden; + cursor: pointer; + position: relative; +} + .copy-img { content: url(/img/copy_icon.png); width: 32px; @@ -24,6 +33,15 @@ position: relative; } +.copy-bb-more:before { + content: url(/img/more_icon.png); + width: 32px; + height: 32px; + overflow: hidden; + cursor: pointer; + position: relative; +} + .copy-bb-more { content: url(/img/more_icon.png); width: 32px; @@ -37,4 +55,9 @@ float: left; padding-right: 5px; position: relative; +} + +.upload-form { + height: 100px; + padding: 10px; } \ No newline at end of file diff --git a/public/file_uploader/.gitignore b/public/file_uploader/.gitignore deleted file mode 100755 index 29a41a8..0000000 --- a/public/file_uploader/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -*.pyc -node_modules diff --git a/public/file_uploader/.jshintrc b/public/file_uploader/.jshintrc deleted file mode 100755 index 4ad82e6..0000000 --- a/public/file_uploader/.jshintrc +++ /dev/null @@ -1,81 +0,0 @@ -{ - "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) - "camelcase" : true, // true: Identifiers must be in camelCase - "curly" : true, // true: Require {} for every new block or scope - "eqeqeq" : true, // true: Require triple equals (===) for comparison - "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() - "immed" : true, // true: Require immediate invocations to be wrapped in parens - // e.g. `(function () { } ());` - "indent" : 4, // {int} Number of spaces to use for indentation - "latedef" : true, // true: Require variables/functions to be defined before being used - "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` - "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : true, // true: Prohibit use of empty blocks - "nonew" : true, // true: Prohibit use of constructors for side-effects (without assignment) - "plusplus" : false, // true: Prohibit use of `++` & `--` - "quotmark" : "single", // Quotation mark consistency: - // false : do nothing (default) - // true : ensure whatever is used is consistent - // "single" : require single quotes - // "double" : require double quotes - "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : true, // true: Require all defined variables be used - "strict" : true, // true: Requires all functions run in ES5 Strict Mode - "trailing" : true, // true: Prohibit trailing whitespaces - "maxparams" : false, // {int} Max number of formal params allowed per function - "maxdepth" : false, // {int} Max depth of nested blocks (within functions) - "maxstatements" : false, // {int} Max number statements per function - "maxcomplexity" : false, // {int} Max cyclomatic complexity per function - "maxlen" : false, // {int} Max number of characters per line - - // Relaxing - "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) - "boss" : false, // true: Tolerate assignments where comparisons would be expected - "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. - "eqnull" : false, // true: Tolerate use of `== null` - "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) - "esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`) - "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) - // (ex: `for each`, multiple try/catch, function expression…) - "evil" : false, // true: Tolerate use of `eval` and `new Function()` - "expr" : false, // true: Tolerate `ExpressionStatement` as Programs - "funcscope" : false, // true: Tolerate defining variables inside control statements" - "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') - "iterator" : false, // true: Tolerate using the `__iterator__` property - "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block - "laxbreak" : false, // true: Tolerate possibly unsafe line breakings - "laxcomma" : false, // true: Tolerate comma-first style coding - "loopfunc" : false, // true: Tolerate functions being defined in loops - "multistr" : false, // true: Tolerate multi-line strings - "proto" : false, // true: Tolerate using the `__proto__` property - "scripturl" : false, // true: Tolerate script-targeted URLs - "smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment - "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` - "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation - "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` - "validthis" : false, // true: Tolerate using this in a non-constructor function - - // Environments - "browser" : false, // Web Browser (window, document, etc) - "couch" : false, // CouchDB - "devel" : false, // Development/debugging (alert, confirm, etc) - "dojo" : false, // Dojo Toolkit - "jquery" : false, // jQuery - "mootools" : false, // MooTools - "node" : false, // Node.js - "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) - "prototypejs" : false, // Prototype and Scriptaculous - "rhino" : false, // Rhino - "worker" : false, // Web Workers - "wsh" : false, // Windows Scripting Host - "yui" : false, // Yahoo User Interface - - // Legacy - "nomen" : true, // true: Prohibit dangling `_` in variables - "onevar" : true, // true: Allow only one `var` statement per function - "passfail" : false, // true: Stop on first error - "white" : true, // true: Check against strict whitespace and indentation rules - - // Custom Globals - "globals" : {} // additional predefined global variables -} diff --git a/public/file_uploader/.npmignore b/public/file_uploader/.npmignore deleted file mode 100755 index 0530f5d..0000000 --- a/public/file_uploader/.npmignore +++ /dev/null @@ -1,20 +0,0 @@ -* -!css/jquery.fileupload-noscript.css -!css/jquery.fileupload-ui-noscript.css -!css/jquery.fileupload-ui.css -!css/jquery.fileupload.css -!img/loading.gif -!img/progressbar.gif -!js/cors/jquery.postmessage-transport.js -!js/cors/jquery.xdr-transport.js -!js/vendor/jquery.ui.widget.js -!js/jquery.fileupload-angular.js -!js/jquery.fileupload-audio.js -!js/jquery.fileupload-image.js -!js/jquery.fileupload-jquery-ui.js -!js/jquery.fileupload-process.js -!js/jquery.fileupload-ui.js -!js/jquery.fileupload-validate.js -!js/jquery.fileupload-video.js -!js/jquery.fileupload.js -!js/jquery.iframe-transport.js diff --git a/public/file_uploader/CONTRIBUTING.md b/public/file_uploader/CONTRIBUTING.md deleted file mode 100755 index e182f9b..0000000 --- a/public/file_uploader/CONTRIBUTING.md +++ /dev/null @@ -1,15 +0,0 @@ -Please follow these pull request guidelines: - -1. Update your fork to the latest upstream version. - -2. Follow the coding conventions of the original source files (indentation, spaces, brackets layout). - -3. Code changes must pass JSHint validation with the `.jshintrc` settings of this project. - -4. Code changes must pass the QUnit tests defined in the `test` folder. - -5. New features should be covered by accompanying QUnit tests. - -6. Keep your commits as atomic as possible, i.e. create a new commit for every single bug fix or feature added. - -7. Always add meaningful commit messages. diff --git a/public/file_uploader/LICENSE b/public/file_uploader/LICENSE deleted file mode 100755 index 0ecca3e..0000000 --- a/public/file_uploader/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017 jQuery-File-Upload Authors - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/public/file_uploader/README.md b/public/file_uploader/README.md deleted file mode 100755 index 56785b8..0000000 --- a/public/file_uploader/README.md +++ /dev/null @@ -1,107 +0,0 @@ -# jQuery File Upload Plugin - -## Demo -[Demo File Upload](https://blueimp.github.io/jQuery-File-Upload/) - -## Description -File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for jQuery. -Supports cross-domain, chunked and resumable file uploads and client-side image resizing. Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads. - -## Setup -* [How to setup the plugin on your website](https://github.com/blueimp/jQuery-File-Upload/wiki/Setup) -* [How to use only the basic plugin (minimal setup guide).](https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin) - -## Features -* **Multiple file upload:** - Allows to select multiple files at once and upload them simultaneously. -* **Drag & Drop support:** - Allows to upload files by dragging them from your desktop or filemanager and dropping them on your browser window. -* **Upload progress bar:** - Shows a progress bar indicating the upload progress for individual files and for all uploads combined. -* **Cancelable uploads:** - Individual file uploads can be canceled to stop the upload progress. -* **Resumable uploads:** - Aborted uploads can be resumed with browsers supporting the Blob API. -* **Chunked uploads:** - Large files can be uploaded in smaller chunks with browsers supporting the Blob API. -* **Client-side image resizing:** - Images can be automatically resized on client-side with browsers supporting the required JS APIs. -* **Preview images, audio and video:** - A preview of image, audio and video files can be displayed before uploading with browsers supporting the required APIs. -* **No browser plugins (e.g. Adobe Flash) required:** - The implementation is based on open standards like HTML5 and JavaScript and requires no additional browser plugins. -* **Graceful fallback for legacy browsers:** - Uploads files via XMLHttpRequests if supported and uses iframes as fallback for legacy browsers. -* **HTML file upload form fallback:** - Allows progressive enhancement by using a standard HTML file upload form as widget element. -* **Cross-site file uploads:** - Supports uploading files to a different domain with cross-site XMLHttpRequests or iframe redirects. -* **Multiple plugin instances:** - Allows to use multiple plugin instances on the same webpage. -* **Customizable and extensible:** - Provides an API to set individual options and define callBack methods for various upload events. -* **Multipart and file contents stream uploads:** - Files can be uploaded as standard "multipart/form-data" or file contents stream (HTTP PUT file upload). -* **Compatible with any server-side application platform:** - Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads. - -## Requirements - -### Mandatory requirements -* [jQuery](https://jquery.com/) v. 1.6+ -* [jQuery UI widget factory](https://api.jqueryui.com/jQuery.widget/) v. 1.9+ (included): Required for the basic File Upload plugin, but very lightweight without any other dependencies from the jQuery UI suite. -* [jQuery Iframe Transport plugin](https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.iframe-transport.js) (included): Required for [browsers without XHR file upload support](https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support). - -### Optional requirements -* [JavaScript Templates engine](https://github.com/blueimp/JavaScript-Templates) v. 2.5.4+: Used to render the selected and uploaded files for the Basic Plus UI and jQuery UI versions. -* [JavaScript Load Image library](https://github.com/blueimp/JavaScript-Load-Image) v. 1.13.0+: Required for the image previews and resizing functionality. -* [JavaScript Canvas to Blob polyfill](https://github.com/blueimp/JavaScript-Canvas-to-Blob) v. 2.1.1+:Required for the image previews and resizing functionality. -* [blueimp Gallery](https://github.com/blueimp/Gallery) v. 2.15.1+: Used to display the uploaded images in a lightbox. -* [Bootstrap](http://getbootstrap.com/) v. 3.2.0+ -* [Glyphicons](http://glyphicons.com/) - -The user interface of all versions except the jQuery UI version is built with [Bootstrap](http://getbootstrap.com/) and icons from [Glyphicons](http://glyphicons.com/). - -### Cross-domain requirements -[Cross-domain File Uploads](https://github.com/blueimp/jQuery-File-Upload/wiki/Cross-domain-uploads) using the [Iframe Transport plugin](https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.iframe-transport.js) require a redirect back to the origin server to retrieve the upload results. The [example implementation](https://github.com/blueimp/jQuery-File-Upload/blob/master/js/main.js) makes use of [result.html](https://github.com/blueimp/jQuery-File-Upload/blob/master/cors/result.html) as a static redirect page for the origin server. - -The repository also includes the [jQuery XDomainRequest Transport plugin](https://github.com/blueimp/jQuery-File-Upload/blob/master/js/cors/jquery.xdr-transport.js), which enables limited cross-domain AJAX requests in Microsoft Internet Explorer 8 and 9 (IE 10 supports cross-domain XHR requests). -The XDomainRequest object allows GET and POST requests only and doesn't support file uploads. It is used on the [Demo](https://blueimp.github.io/jQuery-File-Upload/) to delete uploaded files from the cross-domain demo file upload service. - -### Custom Backends - -You can add support for various backends by adhering to the specification [outlined here](https://github.com/blueimp/jQuery-File-Upload/wiki/JSON-Response). - -## Browsers - -### Desktop browsers -The File Upload plugin is regularly tested with the latest browser versions and supports the following minimal versions: - -* Google Chrome -* Apple Safari 4.0+ -* Mozilla Firefox 3.0+ -* Opera 11.0+ -* Microsoft Internet Explorer 6.0+ - -### Mobile browsers -The File Upload plugin has been tested with and supports the following mobile browsers: - -* Apple Safari on iOS 6.0+ -* Google Chrome on iOS 6.0+ -* Google Chrome on Android 4.0+ -* Default Browser on Android 2.3+ -* Opera Mobile 12.0+ - -### Supported features -For a detailed overview of the features supported by each browser version, please have a look at the [Extended browser support information](https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support). - -## Contributing -**Bug fixes** and **new features** can be proposed using [pull requests](https://github.com/blueimp/jQuery-File-Upload/pulls). -Please read the [contribution guidelines](https://github.com/blueimp/jQuery-File-Upload/blob/master/CONTRIBUTING.md) before submitting a pull request. - -## Support -This project is actively maintained, but there is no official support channel. -If you have a question that another developer might help you with, please post to [Stack Overflow](http://stackoverflow.com/questions/tagged/blueimp+jquery+file-upload) and tag your question with `blueimp jquery file upload`. - -## License -Released under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/public/file_uploader/angularjs.html b/public/file_uploader/angularjs.html deleted file mode 100755 index 4858c86..0000000 --- a/public/file_uploader/angularjs.html +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - -jQuery File Upload Demo - AngularJS version - - - - - - - - - - - - - - - - - - -
-

jQuery File Upload Demo

-

AngularJS version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for AngularJS.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.
- Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads.

-
-
- -
- - - -
-
- - - - Add files... - - - - - - -
- -
- -
- -
 
-
-
- - - - - - - - -
-
- -
-
-
-

- - {{file.name}} - {{file.name}} - - {{file.name}} -

- {{file.error}} -
-

{{file.size | formatFileSize}}

-
-
- - - -
-
-
-
-
-

Demo Notes

-
-
-
    -
  • The maximum file size for uploads in this demo is 999 KB (default file size is unlimited).
  • -
  • Only image files (JPG, GIF, PNG) are allowed in this demo (by default there is no file type restriction).
  • -
  • Uploaded files will be deleted automatically after 5 minutes or less (demo files are stored in memory).
  • -
  • You can drag & drop files from your desktop on this webpage (see Browser support).
  • -
  • Please refer to the project website and documentation for more information.
  • -
  • Built with the Bootstrap CSS framework and Icons from Glyphicons.
  • -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/file_uploader/basic-plus.html b/public/file_uploader/basic-plus.html deleted file mode 100755 index 9e5c232..0000000 --- a/public/file_uploader/basic-plus.html +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - -jQuery File Upload Demo - Basic Plus version - - - - - - - - - - - -
-

jQuery File Upload Demo

-

Basic Plus version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.
- Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads.

-
-
- - - - Add files... - - - -
-
- -
-
-
- -
-
-
-
-

Demo Notes

-
-
-
    -
  • The maximum file size for uploads in this demo is 999 KB (default file size is unlimited).
  • -
  • Only image files (JPG, GIF, PNG) are allowed in this demo (by default there is no file type restriction).
  • -
  • Uploaded files will be deleted automatically after 5 minutes or less (demo files are stored in memory).
  • -
  • You can drag & drop files from your desktop on this webpage (see Browser support).
  • -
  • Please refer to the project website and documentation for more information.
  • -
  • Built with the Bootstrap CSS framework and Icons from Glyphicons.
  • -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/file_uploader/basic.html b/public/file_uploader/basic.html deleted file mode 100755 index c0df639..0000000 --- a/public/file_uploader/basic.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - -jQuery File Upload Demo - Basic version - - - - - - - - - - - -
-

jQuery File Upload Demo

-

Basic version

- -
-
-

File Upload widget with multiple file selection, drag&drop support and progress bar for jQuery.
- Supports cross-domain, chunked and resumable file uploads.
- Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads.

-
-
- - - - Select files... - - - -
-
- -
-
-
- -
-
-
-
-

Demo Notes

-
-
-
    -
  • The maximum file size for uploads in this demo is 999 KB (default file size is unlimited).
  • -
  • Only image files (JPG, GIF, PNG) are allowed in this demo (by default there is no file type restriction).
  • -
  • Uploaded files will be deleted automatically after 5 minutes or less (demo files are stored in memory).
  • -
  • You can drag & drop files from your desktop on this webpage (see Browser support).
  • -
  • Please refer to the project website and documentation for more information.
  • -
  • Built with the Bootstrap CSS framework and Icons from Glyphicons.
  • -
-
-
-
- - - - - - - - - - - - diff --git a/public/file_uploader/bower-version-update.js b/public/file_uploader/bower-version-update.js deleted file mode 100755 index 09ce392..0000000 --- a/public/file_uploader/bower-version-update.js +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -var path = require('path'); -var packageJSON = require(path.join(__dirname, 'package.json')); -var bowerFile = path.join(__dirname, 'bower.json'); -var bowerJSON = require('bower-json').parse( - require(bowerFile), - {normalize: true} -); -bowerJSON.version = packageJSON.version; -require('fs').writeFileSync( - bowerFile, - JSON.stringify(bowerJSON, null, 2) + '\n' -); diff --git a/public/file_uploader/bower.json b/public/file_uploader/bower.json deleted file mode 100755 index 90c74c7..0000000 --- a/public/file_uploader/bower.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "blueimp-file-upload", - "version": "9.18.0", - "title": "jQuery File Upload", - "description": "File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images.", - "keywords": [ - "jquery", - "file", - "upload", - "widget", - "multiple", - "selection", - "drag", - "drop", - "progress", - "preview", - "cross-domain", - "cross-site", - "chunk", - "resume", - "gae", - "go", - "python", - "php", - "bootstrap" - ], - "homepage": "https://github.com/blueimp/jQuery-File-Upload", - "author": { - "name": "Sebastian Tschan", - "url": "https://blueimp.net" - }, - "maintainers": [ - { - "name": "Sebastian Tschan", - "url": "https://blueimp.net" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/blueimp/jQuery-File-Upload.git" - }, - "bugs": "https://github.com/blueimp/jQuery-File-Upload/issues", - "license": "MIT", - "dependencies": { - "jquery": ">=1.6", - "blueimp-tmpl": ">=2.5.4", - "blueimp-load-image": ">=1.13.0", - "blueimp-canvas-to-blob": ">=2.1.1" - }, - "main": [ - "js/jquery.fileupload.js" - ], - "ignore": [ - "/*.*", - "/cors", - "css/demo-ie8.css", - "css/demo.css", - "css/style.css", - "js/app.js", - "js/main.js", - "server", - "test" - ] -} diff --git a/public/file_uploader/cors/postmessage.html b/public/file_uploader/cors/postmessage.html deleted file mode 100755 index 6db288c..0000000 --- a/public/file_uploader/cors/postmessage.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - -jQuery File Upload Plugin postMessage API - - - - - - diff --git a/public/file_uploader/cors/result.html b/public/file_uploader/cors/result.html deleted file mode 100755 index e3d6298..0000000 --- a/public/file_uploader/cors/result.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - -jQuery Iframe Transport Plugin Redirect Page - - - - - diff --git a/public/file_uploader/css/demo-ie8.css b/public/file_uploader/css/jquery-ui-demo-ie8.css old mode 100755 new mode 100644 similarity index 100% rename from public/file_uploader/css/demo-ie8.css rename to public/file_uploader/css/jquery-ui-demo-ie8.css diff --git a/public/file_uploader/css/demo.css b/public/file_uploader/css/jquery-ui-demo.css old mode 100755 new mode 100644 similarity index 100% rename from public/file_uploader/css/demo.css rename to public/file_uploader/css/jquery-ui-demo.css diff --git a/public/file_uploader/css/jquery.fileupload-noscript.css b/public/file_uploader/css/jquery.fileupload-noscript.css old mode 100755 new mode 100644 diff --git a/public/file_uploader/css/jquery.fileupload-ui-noscript.css b/public/file_uploader/css/jquery.fileupload-ui-noscript.css old mode 100755 new mode 100644 diff --git a/public/file_uploader/css/jquery.fileupload-ui.css b/public/file_uploader/css/jquery.fileupload-ui.css old mode 100755 new mode 100644 diff --git a/public/file_uploader/css/jquery.fileupload.css b/public/file_uploader/css/jquery.fileupload.css old mode 100755 new mode 100644 diff --git a/public/file_uploader/css/style.css b/public/file_uploader/css/style.css old mode 100755 new mode 100644 diff --git a/public/file_uploader/img/loading.gif b/public/file_uploader/img/loading.gif old mode 100755 new mode 100644 diff --git a/public/file_uploader/img/progressbar.gif b/public/file_uploader/img/progressbar.gif old mode 100755 new mode 100644 diff --git a/public/file_uploader/index.html b/public/file_uploader/index.html deleted file mode 100755 index 2a8dc15..0000000 --- a/public/file_uploader/index.html +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - - -jQuery File Upload Demo - - - - - - - - - - - - - - - - - -
-

jQuery File Upload Demo

-

Basic Plus UI version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for jQuery.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.
- Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads.

-
-
- -
- - - -
-
- - - - Add files... - - - - - - - - -
- -
- -
-
-
- -
 
-
-
- - -
-
-
-
-

Demo Notes

-
-
-
    -
  • The maximum file size for uploads in this demo is 999 KB (default file size is unlimited).
  • -
  • Only image files (JPG, GIF, PNG) are allowed in this demo (by default there is no file type restriction).
  • -
  • Uploaded files will be deleted automatically after 5 minutes or less (demo files are stored in memory).
  • -
  • You can drag & drop files from your desktop on this webpage (see Browser support).
  • -
  • Please refer to the project website and documentation for more information.
  • -
  • Built with the Bootstrap CSS framework and Icons from Glyphicons.
  • -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/file_uploader/jquery-ui.html b/public/file_uploader/jquery-ui.html deleted file mode 100755 index 83fe9ac..0000000 --- a/public/file_uploader/jquery-ui.html +++ /dev/null @@ -1,250 +0,0 @@ - - - - - - - -jQuery File Upload Demo - jQuery UI version - - - - - - - - - - - - - - - - - - - -

jQuery File Upload Demo

-

jQuery UI version

-
- - -
- -
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for jQuery UI.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.
- Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads.

-
- -
- - - -
-
- - - Add files... - - - - - - - - -
- - -
- -
-
-
-

Demo Notes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/file_uploader/js/app.js b/public/file_uploader/js/app.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/cors/jquery.postmessage-transport.js b/public/file_uploader/js/cors/jquery.postmessage-transport.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/cors/jquery.xdr-transport.js b/public/file_uploader/js/cors/jquery.xdr-transport.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/jquery.fileupload-angular.js b/public/file_uploader/js/jquery.fileupload-angular.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/jquery.fileupload-audio.js b/public/file_uploader/js/jquery.fileupload-audio.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/jquery.fileupload-image.js b/public/file_uploader/js/jquery.fileupload-image.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/jquery.fileupload-jquery-ui.js b/public/file_uploader/js/jquery.fileupload-jquery-ui.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/jquery.fileupload-process.js b/public/file_uploader/js/jquery.fileupload-process.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/jquery.fileupload-ui.js b/public/file_uploader/js/jquery.fileupload-ui.js old mode 100755 new mode 100644 index 83e7449..5058084 --- a/public/file_uploader/js/jquery.fileupload-ui.js +++ b/public/file_uploader/js/jquery.fileupload-ui.js @@ -30,6 +30,7 @@ require('jquery'), require('blueimp-tmpl'), require('./jquery.fileupload-image'), + require('./jquery.fileupload-audio'), require('./jquery.fileupload-video'), require('./jquery.fileupload-validate') ); diff --git a/public/file_uploader/js/jquery.fileupload-validate.js b/public/file_uploader/js/jquery.fileupload-validate.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/jquery.fileupload-video.js b/public/file_uploader/js/jquery.fileupload-video.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/jquery.fileupload.js b/public/file_uploader/js/jquery.fileupload.js old mode 100755 new mode 100644 index 5ff151b..629f57a --- a/public/file_uploader/js/jquery.fileupload.js +++ b/public/file_uploader/js/jquery.fileupload.js @@ -43,7 +43,7 @@ '|(Kindle/(1\\.0|2\\.[05]|3\\.0))' ).test(window.navigator.userAgent) || // Feature detection for all other devices: - $('').prop('disabled')); + $('').prop('disabled')); // The FileReader API is not actually used, but works as feature detection, // as some Safari versions (5?) support XHR file uploads via the FormData API, @@ -453,7 +453,7 @@ } if (!multipart || options.blob || !this._isInstanceOf('File', file)) { options.headers['Content-Disposition'] = 'attachment; filename="' + - encodeURI(file.name) + '"'; + encodeURI(file.uploadName || file.name) + '"'; } if (!multipart) { options.contentType = file.type || 'application/octet-stream'; @@ -489,7 +489,11 @@ }); } if (options.blob) { - formData.append(paramName, options.blob, file.name); + formData.append( + paramName, + options.blob, + file.uploadName || file.name + ); } else { $.each(options.files, function (index, file) { // This check allows the tests to run with @@ -730,7 +734,7 @@ promise = dfd.promise(), jqXHR, upload; - if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) || + if (!(this._isXHRUpload(options) && slice && (ub || ($.type(mcs) === 'function' ? mcs(options) : mcs) < fs)) || options.data) { return false; } @@ -753,7 +757,7 @@ o.blob = slice.call( file, ub, - ub + mcs, + ub + ($.type(mcs) === 'function' ? mcs(o) : mcs), file.type ); // Store the current chunk size, as the blob itself @@ -1126,7 +1130,7 @@ dirReader = entry.createReader(); readEntries(); } else { - // Return an empy list for file system items + // Return an empty list for file system items // other than files or directories: dfd.resolve([]); } diff --git a/public/file_uploader/js/jquery.iframe-transport.js b/public/file_uploader/js/jquery.iframe-transport.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/main.js b/public/file_uploader/js/main.js old mode 100755 new mode 100644 diff --git a/public/file_uploader/js/vendor/jquery.ui.widget.js b/public/file_uploader/js/vendor/jquery.ui.widget.js old mode 100755 new mode 100644 index e08df3f..914b8ff --- a/public/file_uploader/js/vendor/jquery.ui.widget.js +++ b/public/file_uploader/js/vendor/jquery.ui.widget.js @@ -1,571 +1,751 @@ -/*! jQuery UI - v1.11.4+CommonJS - 2015-08-28 -* http://jqueryui.com -* Includes: widget.js -* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ +/*! jQuery UI - v1.12.1+CommonJS - 2018-02-10 + * http://jqueryui.com + * Includes: widget.js + * Copyright jQuery Foundation and other contributors; Licensed MIT */ (function( factory ) { - if ( typeof define === "function" && define.amd ) { + if ( typeof define === "function" && define.amd ) { - // AMD. Register as an anonymous module. - define([ "jquery" ], factory ); + // AMD. Register as an anonymous module. + define([ "jquery" ], factory ); + } else if ( typeof exports === "object" ) { - } else if ( typeof exports === "object" ) { + // Node/CommonJS + factory( require( "jquery" ) ); + } else { - // Node/CommonJS - factory( require( "jquery" ) ); - - } else { - - // Browser globals - factory( jQuery ); - } + // Browser globals + factory( jQuery ); + } }(function( $ ) { -/*! - * jQuery UI Widget 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/jQuery.widget/ - */ + + $.ui = $.ui || {}; + + var version = $.ui.version = "1.12.1"; -var widget_uuid = 0, - widget_slice = Array.prototype.slice; + /*! + * jQuery UI Widget 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ -$.cleanData = (function( orig ) { - return function( elems ) { - var events, elem, i; - for ( i = 0; (elem = elems[i]) != null; i++ ) { - try { + //>>label: Widget + //>>group: Core + //>>description: Provides a factory for creating stateful widgets with a common API. + //>>docs: http://api.jqueryui.com/jQuery.widget/ + //>>demos: http://jqueryui.com/widget/ - // Only trigger remove when necessary to save time - events = $._data( elem, "events" ); - if ( events && events.remove ) { - $( elem ).triggerHandler( "remove" ); - } - // http://bugs.jquery.com/ticket/8235 - } catch ( e ) {} - } - orig( elems ); - }; -})( $.cleanData ); -$.widget = function( name, base, prototype ) { - var fullName, existingConstructor, constructor, basePrototype, - // proxiedPrototype allows the provided prototype to remain unmodified - // so that it can be used as a mixin for multiple widgets (#8876) - proxiedPrototype = {}, - namespace = name.split( "." )[ 0 ]; + var widgetUuid = 0; + var widgetSlice = Array.prototype.slice; - name = name.split( "." )[ 1 ]; - fullName = namespace + "-" + name; + $.cleanData = ( function( orig ) { + return function( elems ) { + var events, elem, i; + for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { + try { - if ( !prototype ) { - prototype = base; - base = $.Widget; - } + // Only trigger remove when necessary to save time + events = $._data( elem, "events" ); + if ( events && events.remove ) { + $( elem ).triggerHandler( "remove" ); + } - // create selector for plugin - $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { - return !!$.data( elem, fullName ); - }; + // Http://bugs.jquery.com/ticket/8235 + } catch ( e ) {} + } + orig( elems ); + }; + } )( $.cleanData ); - $[ namespace ] = $[ namespace ] || {}; - existingConstructor = $[ namespace ][ name ]; - constructor = $[ namespace ][ name ] = function( options, element ) { - // allow instantiation without "new" keyword - if ( !this._createWidget ) { - return new constructor( options, element ); - } + $.widget = function( name, base, prototype ) { + var existingConstructor, constructor, basePrototype; - // allow instantiation without initializing for simple inheritance - // must use "new" keyword (the code above always passes args) - if ( arguments.length ) { - this._createWidget( options, element ); - } - }; - // extend with the existing constructor to carry over any static properties - $.extend( constructor, existingConstructor, { - version: prototype.version, - // copy the object used to create the prototype in case we need to - // redefine the widget later - _proto: $.extend( {}, prototype ), - // track widgets that inherit from this widget in case this widget is - // redefined after a widget inherits from it - _childConstructors: [] - }); + // ProxiedPrototype allows the provided prototype to remain unmodified + // so that it can be used as a mixin for multiple widgets (#8876) + var proxiedPrototype = {}; - basePrototype = new base(); - // we need to make the options hash a property directly on the new instance - // otherwise we'll modify the options hash on the prototype that we're - // inheriting from - basePrototype.options = $.widget.extend( {}, basePrototype.options ); - $.each( prototype, function( prop, value ) { - if ( !$.isFunction( value ) ) { - proxiedPrototype[ prop ] = value; - return; - } - proxiedPrototype[ prop ] = (function() { - var _super = function() { - return base.prototype[ prop ].apply( this, arguments ); - }, - _superApply = function( args ) { - return base.prototype[ prop ].apply( this, args ); - }; - return function() { - var __super = this._super, - __superApply = this._superApply, - returnValue; + var namespace = name.split( "." )[ 0 ]; + name = name.split( "." )[ 1 ]; + var fullName = namespace + "-" + name; - this._super = _super; - this._superApply = _superApply; + if ( !prototype ) { + prototype = base; + base = $.Widget; + } - returnValue = value.apply( this, arguments ); + if ( $.isArray( prototype ) ) { + prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); + } - this._super = __super; - this._superApply = __superApply; + // Create selector for plugin + $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { + return !!$.data( elem, fullName ); + }; - return returnValue; - }; - })(); - }); - constructor.prototype = $.widget.extend( basePrototype, { - // TODO: remove support for widgetEventPrefix - // always use the name + a colon as the prefix, e.g., draggable:start - // don't prefix for widgets that aren't DOM-based - widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name - }, proxiedPrototype, { - constructor: constructor, - namespace: namespace, - widgetName: name, - widgetFullName: fullName - }); + $[ namespace ] = $[ namespace ] || {}; + existingConstructor = $[ namespace ][ name ]; + constructor = $[ namespace ][ name ] = function( options, element ) { - // If this widget is being redefined then we need to find all widgets that - // are inheriting from it and redefine all of them so that they inherit from - // the new version of this widget. We're essentially trying to replace one - // level in the prototype chain. - if ( existingConstructor ) { - $.each( existingConstructor._childConstructors, function( i, child ) { - var childPrototype = child.prototype; + // Allow instantiation without "new" keyword + if ( !this._createWidget ) { + return new constructor( options, element ); + } - // redefine the child widget using the same prototype that was - // originally used, but inherit from the new version of the base - $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto ); - }); - // remove the list of existing child constructors from the old constructor - // so the old child constructors can be garbage collected - delete existingConstructor._childConstructors; - } else { - base._childConstructors.push( constructor ); - } + // Allow instantiation without initializing for simple inheritance + // must use "new" keyword (the code above always passes args) + if ( arguments.length ) { + this._createWidget( options, element ); + } + }; - $.widget.bridge( name, constructor ); + // Extend with the existing constructor to carry over any static properties + $.extend( constructor, existingConstructor, { + version: prototype.version, - return constructor; -}; + // Copy the object used to create the prototype in case we need to + // redefine the widget later + _proto: $.extend( {}, prototype ), -$.widget.extend = function( target ) { - var input = widget_slice.call( arguments, 1 ), - inputIndex = 0, - inputLength = input.length, - key, - value; - for ( ; inputIndex < inputLength; inputIndex++ ) { - for ( key in input[ inputIndex ] ) { - value = input[ inputIndex ][ key ]; - if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { - // Clone objects - if ( $.isPlainObject( value ) ) { - target[ key ] = $.isPlainObject( target[ key ] ) ? - $.widget.extend( {}, target[ key ], value ) : - // Don't extend strings, arrays, etc. with objects - $.widget.extend( {}, value ); - // Copy everything else by reference - } else { - target[ key ] = value; - } - } - } - } - return target; -}; + // Track widgets that inherit from this widget in case this widget is + // redefined after a widget inherits from it + _childConstructors: [] + } ); -$.widget.bridge = function( name, object ) { - var fullName = object.prototype.widgetFullName || name; - $.fn[ name ] = function( options ) { - var isMethodCall = typeof options === "string", - args = widget_slice.call( arguments, 1 ), - returnValue = this; + basePrototype = new base(); - if ( isMethodCall ) { - this.each(function() { - var methodValue, - instance = $.data( this, fullName ); - if ( options === "instance" ) { - returnValue = instance; - return false; - } - if ( !instance ) { - return $.error( "cannot call methods on " + name + " prior to initialization; " + - "attempted to call method '" + options + "'" ); - } - if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) { - return $.error( "no such method '" + options + "' for " + name + " widget instance" ); - } - methodValue = instance[ options ].apply( instance, args ); - if ( methodValue !== instance && methodValue !== undefined ) { - returnValue = methodValue && methodValue.jquery ? - returnValue.pushStack( methodValue.get() ) : - methodValue; - return false; - } - }); - } else { + // We need to make the options hash a property directly on the new instance + // otherwise we'll modify the options hash on the prototype that we're + // inheriting from + basePrototype.options = $.widget.extend( {}, basePrototype.options ); + $.each( prototype, function( prop, value ) { + if ( !$.isFunction( value ) ) { + proxiedPrototype[ prop ] = value; + return; + } + proxiedPrototype[ prop ] = ( function() { + function _super() { + return base.prototype[ prop ].apply( this, arguments ); + } - // Allow multiple hashes to be passed on init - if ( args.length ) { - options = $.widget.extend.apply( null, [ options ].concat(args) ); - } + function _superApply( args ) { + return base.prototype[ prop ].apply( this, args ); + } - this.each(function() { - var instance = $.data( this, fullName ); - if ( instance ) { - instance.option( options || {} ); - if ( instance._init ) { - instance._init(); - } - } else { - $.data( this, fullName, new object( options, this ) ); - } - }); - } + return function() { + var __super = this._super; + var __superApply = this._superApply; + var returnValue; - return returnValue; - }; -}; + this._super = _super; + this._superApply = _superApply; -$.Widget = function( /* options, element */ ) {}; -$.Widget._childConstructors = []; + returnValue = value.apply( this, arguments ); -$.Widget.prototype = { - widgetName: "widget", - widgetEventPrefix: "", - defaultElement: "
", - options: { - disabled: false, + this._super = __super; + this._superApply = __superApply; - // callbacks - create: null - }, - _createWidget: function( options, element ) { - element = $( element || this.defaultElement || this )[ 0 ]; - this.element = $( element ); - this.uuid = widget_uuid++; - this.eventNamespace = "." + this.widgetName + this.uuid; + return returnValue; + }; + } )(); + } ); + constructor.prototype = $.widget.extend( basePrototype, { - this.bindings = $(); - this.hoverable = $(); - this.focusable = $(); + // TODO: remove support for widgetEventPrefix + // always use the name + a colon as the prefix, e.g., draggable:start + // don't prefix for widgets that aren't DOM-based + widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name + }, proxiedPrototype, { + constructor: constructor, + namespace: namespace, + widgetName: name, + widgetFullName: fullName + } ); - if ( element !== this ) { - $.data( element, this.widgetFullName, this ); - this._on( true, this.element, { - remove: function( event ) { - if ( event.target === element ) { - this.destroy(); - } - } - }); - this.document = $( element.style ? - // element within the document - element.ownerDocument : - // element is window or document - element.document || element ); - this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); - } + // If this widget is being redefined then we need to find all widgets that + // are inheriting from it and redefine all of them so that they inherit from + // the new version of this widget. We're essentially trying to replace one + // level in the prototype chain. + if ( existingConstructor ) { + $.each( existingConstructor._childConstructors, function( i, child ) { + var childPrototype = child.prototype; - this.options = $.widget.extend( {}, - this.options, - this._getCreateOptions(), - options ); + // Redefine the child widget using the same prototype that was + // originally used, but inherit from the new version of the base + $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, + child._proto ); + } ); - this._create(); - this._trigger( "create", null, this._getCreateEventData() ); - this._init(); - }, - _getCreateOptions: $.noop, - _getCreateEventData: $.noop, - _create: $.noop, - _init: $.noop, + // Remove the list of existing child constructors from the old constructor + // so the old child constructors can be garbage collected + delete existingConstructor._childConstructors; + } else { + base._childConstructors.push( constructor ); + } - destroy: function() { - this._destroy(); - // we can probably remove the unbind calls in 2.0 - // all event bindings should go through this._on() - this.element - .unbind( this.eventNamespace ) - .removeData( this.widgetFullName ) - // support: jquery <1.6.3 - // http://bugs.jquery.com/ticket/9413 - .removeData( $.camelCase( this.widgetFullName ) ); - this.widget() - .unbind( this.eventNamespace ) - .removeAttr( "aria-disabled" ) - .removeClass( - this.widgetFullName + "-disabled " + - "ui-state-disabled" ); + $.widget.bridge( name, constructor ); - // clean up events and states - this.bindings.unbind( this.eventNamespace ); - this.hoverable.removeClass( "ui-state-hover" ); - this.focusable.removeClass( "ui-state-focus" ); - }, - _destroy: $.noop, + return constructor; + }; - widget: function() { - return this.element; - }, + $.widget.extend = function( target ) { + var input = widgetSlice.call( arguments, 1 ); + var inputIndex = 0; + var inputLength = input.length; + var key; + var value; - option: function( key, value ) { - var options = key, - parts, - curOption, - i; + for ( ; inputIndex < inputLength; inputIndex++ ) { + for ( key in input[ inputIndex ] ) { + value = input[ inputIndex ][ key ]; + if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { - if ( arguments.length === 0 ) { - // don't return a reference to the internal hash - return $.widget.extend( {}, this.options ); - } + // Clone objects + if ( $.isPlainObject( value ) ) { + target[ key ] = $.isPlainObject( target[ key ] ) ? + $.widget.extend( {}, target[ key ], value ) : - if ( typeof key === "string" ) { - // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } - options = {}; - parts = key.split( "." ); - key = parts.shift(); - if ( parts.length ) { - curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); - for ( i = 0; i < parts.length - 1; i++ ) { - curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; - curOption = curOption[ parts[ i ] ]; - } - key = parts.pop(); - if ( arguments.length === 1 ) { - return curOption[ key ] === undefined ? null : curOption[ key ]; - } - curOption[ key ] = value; - } else { - if ( arguments.length === 1 ) { - return this.options[ key ] === undefined ? null : this.options[ key ]; - } - options[ key ] = value; - } - } + // Don't extend strings, arrays, etc. with objects + $.widget.extend( {}, value ); - this._setOptions( options ); + // Copy everything else by reference + } else { + target[ key ] = value; + } + } + } + } + return target; + }; - return this; - }, - _setOptions: function( options ) { - var key; + $.widget.bridge = function( name, object ) { + var fullName = object.prototype.widgetFullName || name; + $.fn[ name ] = function( options ) { + var isMethodCall = typeof options === "string"; + var args = widgetSlice.call( arguments, 1 ); + var returnValue = this; - for ( key in options ) { - this._setOption( key, options[ key ] ); - } + if ( isMethodCall ) { - return this; - }, - _setOption: function( key, value ) { - this.options[ key ] = value; + // If this is an empty collection, we need to have the instance method + // return undefined instead of the jQuery instance + if ( !this.length && options === "instance" ) { + returnValue = undefined; + } else { + this.each( function() { + var methodValue; + var instance = $.data( this, fullName ); - if ( key === "disabled" ) { - this.widget() - .toggleClass( this.widgetFullName + "-disabled", !!value ); + if ( options === "instance" ) { + returnValue = instance; + return false; + } - // If the widget is becoming disabled, then nothing is interactive - if ( value ) { - this.hoverable.removeClass( "ui-state-hover" ); - this.focusable.removeClass( "ui-state-focus" ); - } - } + if ( !instance ) { + return $.error( "cannot call methods on " + name + + " prior to initialization; " + + "attempted to call method '" + options + "'" ); + } - return this; - }, + if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) { + return $.error( "no such method '" + options + "' for " + name + + " widget instance" ); + } - enable: function() { - return this._setOptions({ disabled: false }); - }, - disable: function() { - return this._setOptions({ disabled: true }); - }, + methodValue = instance[ options ].apply( instance, args ); - _on: function( suppressDisabledCheck, element, handlers ) { - var delegateElement, - instance = this; + if ( methodValue !== instance && methodValue !== undefined ) { + returnValue = methodValue && methodValue.jquery ? + returnValue.pushStack( methodValue.get() ) : + methodValue; + return false; + } + } ); + } + } else { - // no suppressDisabledCheck flag, shuffle arguments - if ( typeof suppressDisabledCheck !== "boolean" ) { - handlers = element; - element = suppressDisabledCheck; - suppressDisabledCheck = false; - } + // Allow multiple hashes to be passed on init + if ( args.length ) { + options = $.widget.extend.apply( null, [ options ].concat( args ) ); + } - // no element argument, shuffle and use this.element - if ( !handlers ) { - handlers = element; - element = this.element; - delegateElement = this.widget(); - } else { - element = delegateElement = $( element ); - this.bindings = this.bindings.add( element ); - } + this.each( function() { + var instance = $.data( this, fullName ); + if ( instance ) { + instance.option( options || {} ); + if ( instance._init ) { + instance._init(); + } + } else { + $.data( this, fullName, new object( options, this ) ); + } + } ); + } - $.each( handlers, function( event, handler ) { - function handlerProxy() { - // allow widgets to customize the disabled handling - // - disabled as an array instead of boolean - // - disabled class as method for disabling individual parts - if ( !suppressDisabledCheck && - ( instance.options.disabled === true || - $( this ).hasClass( "ui-state-disabled" ) ) ) { - return; - } - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } + return returnValue; + }; + }; - // copy the guid so direct unbinding works - if ( typeof handler !== "string" ) { - handlerProxy.guid = handler.guid = - handler.guid || handlerProxy.guid || $.guid++; - } + $.Widget = function( /* options, element */ ) {}; + $.Widget._childConstructors = []; - var match = event.match( /^([\w:-]*)\s*(.*)$/ ), - eventName = match[1] + instance.eventNamespace, - selector = match[2]; - if ( selector ) { - delegateElement.delegate( selector, eventName, handlerProxy ); - } else { - element.bind( eventName, handlerProxy ); - } - }); - }, + $.Widget.prototype = { + widgetName: "widget", + widgetEventPrefix: "", + defaultElement: "
", - _off: function( element, eventName ) { - eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + - this.eventNamespace; - element.unbind( eventName ).undelegate( eventName ); + options: { + classes: {}, + disabled: false, - // Clear the stack to avoid memory leaks (#10056) - this.bindings = $( this.bindings.not( element ).get() ); - this.focusable = $( this.focusable.not( element ).get() ); - this.hoverable = $( this.hoverable.not( element ).get() ); - }, + // Callbacks + create: null + }, - _delay: function( handler, delay ) { - function handlerProxy() { - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } - var instance = this; - return setTimeout( handlerProxy, delay || 0 ); - }, + _createWidget: function( options, element ) { + element = $( element || this.defaultElement || this )[ 0 ]; + this.element = $( element ); + this.uuid = widgetUuid++; + this.eventNamespace = "." + this.widgetName + this.uuid; - _hoverable: function( element ) { - this.hoverable = this.hoverable.add( element ); - this._on( element, { - mouseenter: function( event ) { - $( event.currentTarget ).addClass( "ui-state-hover" ); - }, - mouseleave: function( event ) { - $( event.currentTarget ).removeClass( "ui-state-hover" ); - } - }); - }, + this.bindings = $(); + this.hoverable = $(); + this.focusable = $(); + this.classesElementLookup = {}; - _focusable: function( element ) { - this.focusable = this.focusable.add( element ); - this._on( element, { - focusin: function( event ) { - $( event.currentTarget ).addClass( "ui-state-focus" ); - }, - focusout: function( event ) { - $( event.currentTarget ).removeClass( "ui-state-focus" ); - } - }); - }, + if ( element !== this ) { + $.data( element, this.widgetFullName, this ); + this._on( true, this.element, { + remove: function( event ) { + if ( event.target === element ) { + this.destroy(); + } + } + } ); + this.document = $( element.style ? - _trigger: function( type, event, data ) { - var prop, orig, - callback = this.options[ type ]; + // Element within the document + element.ownerDocument : - data = data || {}; - event = $.Event( event ); - event.type = ( type === this.widgetEventPrefix ? - type : - this.widgetEventPrefix + type ).toLowerCase(); - // the original event may come from any element - // so we need to reset the target on the new event - event.target = this.element[ 0 ]; + // Element is window or document + element.document || element ); + this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); + } - // copy original event properties over to the new event - orig = event.originalEvent; - if ( orig ) { - for ( prop in orig ) { - if ( !( prop in event ) ) { - event[ prop ] = orig[ prop ]; - } - } - } + this.options = $.widget.extend( {}, + this.options, + this._getCreateOptions(), + options ); - this.element.trigger( event, data ); - return !( $.isFunction( callback ) && - callback.apply( this.element[0], [ event ].concat( data ) ) === false || - event.isDefaultPrevented() ); - } -}; + this._create(); -$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { - $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { - if ( typeof options === "string" ) { - options = { effect: options }; - } - var hasOptions, - effectName = !options ? - method : - options === true || typeof options === "number" ? - defaultEffect : - options.effect || defaultEffect; - options = options || {}; - if ( typeof options === "number" ) { - options = { duration: options }; - } - hasOptions = !$.isEmptyObject( options ); - options.complete = callback; - if ( options.delay ) { - element.delay( options.delay ); - } - if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { - element[ method ]( options ); - } else if ( effectName !== method && element[ effectName ] ) { - element[ effectName ]( options.duration, options.easing, callback ); - } else { - element.queue(function( next ) { - $( this )[ method ](); - if ( callback ) { - callback.call( element[ 0 ] ); - } - next(); - }); - } - }; -}); + if ( this.options.disabled ) { + this._setOptionDisabled( this.options.disabled ); + } + + this._trigger( "create", null, this._getCreateEventData() ); + this._init(); + }, + + _getCreateOptions: function() { + return {}; + }, + + _getCreateEventData: $.noop, + + _create: $.noop, + + _init: $.noop, + + destroy: function() { + var that = this; + + this._destroy(); + $.each( this.classesElementLookup, function( key, value ) { + that._removeClass( value, key ); + } ); + + // We can probably remove the unbind calls in 2.0 + // all event bindings should go through this._on() + this.element + .off( this.eventNamespace ) + .removeData( this.widgetFullName ); + this.widget() + .off( this.eventNamespace ) + .removeAttr( "aria-disabled" ); + + // Clean up events and states + this.bindings.off( this.eventNamespace ); + }, + + _destroy: $.noop, + + widget: function() { + return this.element; + }, + + option: function( key, value ) { + var options = key; + var parts; + var curOption; + var i; + + if ( arguments.length === 0 ) { + + // Don't return a reference to the internal hash + return $.widget.extend( {}, this.options ); + } + + if ( typeof key === "string" ) { + + // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } + options = {}; + parts = key.split( "." ); + key = parts.shift(); + if ( parts.length ) { + curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); + for ( i = 0; i < parts.length - 1; i++ ) { + curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; + curOption = curOption[ parts[ i ] ]; + } + key = parts.pop(); + if ( arguments.length === 1 ) { + return curOption[ key ] === undefined ? null : curOption[ key ]; + } + curOption[ key ] = value; + } else { + if ( arguments.length === 1 ) { + return this.options[ key ] === undefined ? null : this.options[ key ]; + } + options[ key ] = value; + } + } + + this._setOptions( options ); + + return this; + }, + + _setOptions: function( options ) { + var key; + + for ( key in options ) { + this._setOption( key, options[ key ] ); + } + + return this; + }, + + _setOption: function( key, value ) { + if ( key === "classes" ) { + this._setOptionClasses( value ); + } + + this.options[ key ] = value; + + if ( key === "disabled" ) { + this._setOptionDisabled( value ); + } + + return this; + }, + + _setOptionClasses: function( value ) { + var classKey, elements, currentElements; + + for ( classKey in value ) { + currentElements = this.classesElementLookup[ classKey ]; + if ( value[ classKey ] === this.options.classes[ classKey ] || + !currentElements || + !currentElements.length ) { + continue; + } + + // We are doing this to create a new jQuery object because the _removeClass() call + // on the next line is going to destroy the reference to the current elements being + // tracked. We need to save a copy of this collection so that we can add the new classes + // below. + elements = $( currentElements.get() ); + this._removeClass( currentElements, classKey ); + + // We don't use _addClass() here, because that uses this.options.classes + // for generating the string of classes. We want to use the value passed in from + // _setOption(), this is the new value of the classes option which was passed to + // _setOption(). We pass this value directly to _classes(). + elements.addClass( this._classes( { + element: elements, + keys: classKey, + classes: value, + add: true + } ) ); + } + }, + + _setOptionDisabled: function( value ) { + this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); + + // If the widget is becoming disabled, then nothing is interactive + if ( value ) { + this._removeClass( this.hoverable, null, "ui-state-hover" ); + this._removeClass( this.focusable, null, "ui-state-focus" ); + } + }, + + enable: function() { + return this._setOptions( { disabled: false } ); + }, + + disable: function() { + return this._setOptions( { disabled: true } ); + }, + + _classes: function( options ) { + var full = []; + var that = this; + + options = $.extend( { + element: this.element, + classes: this.options.classes || {} + }, options ); + + function processClassString( classes, checkOption ) { + var current, i; + for ( i = 0; i < classes.length; i++ ) { + current = that.classesElementLookup[ classes[ i ] ] || $(); + if ( options.add ) { + current = $( $.unique( current.get().concat( options.element.get() ) ) ); + } else { + current = $( current.not( options.element ).get() ); + } + that.classesElementLookup[ classes[ i ] ] = current; + full.push( classes[ i ] ); + if ( checkOption && options.classes[ classes[ i ] ] ) { + full.push( options.classes[ classes[ i ] ] ); + } + } + } + + this._on( options.element, { + "remove": "_untrackClassesElement" + } ); + + if ( options.keys ) { + processClassString( options.keys.match( /\S+/g ) || [], true ); + } + if ( options.extra ) { + processClassString( options.extra.match( /\S+/g ) || [] ); + } + + return full.join( " " ); + }, + + _untrackClassesElement: function( event ) { + var that = this; + $.each( that.classesElementLookup, function( key, value ) { + if ( $.inArray( event.target, value ) !== -1 ) { + that.classesElementLookup[ key ] = $( value.not( event.target ).get() ); + } + } ); + }, + + _removeClass: function( element, keys, extra ) { + return this._toggleClass( element, keys, extra, false ); + }, + + _addClass: function( element, keys, extra ) { + return this._toggleClass( element, keys, extra, true ); + }, + + _toggleClass: function( element, keys, extra, add ) { + add = ( typeof add === "boolean" ) ? add : extra; + var shift = ( typeof element === "string" || element === null ), + options = { + extra: shift ? keys : extra, + keys: shift ? element : keys, + element: shift ? this.element : element, + add: add + }; + options.element.toggleClass( this._classes( options ), add ); + return this; + }, + + _on: function( suppressDisabledCheck, element, handlers ) { + var delegateElement; + var instance = this; + + // No suppressDisabledCheck flag, shuffle arguments + if ( typeof suppressDisabledCheck !== "boolean" ) { + handlers = element; + element = suppressDisabledCheck; + suppressDisabledCheck = false; + } + + // No element argument, shuffle and use this.element + if ( !handlers ) { + handlers = element; + element = this.element; + delegateElement = this.widget(); + } else { + element = delegateElement = $( element ); + this.bindings = this.bindings.add( element ); + } + + $.each( handlers, function( event, handler ) { + function handlerProxy() { + + // Allow widgets to customize the disabled handling + // - disabled as an array instead of boolean + // - disabled class as method for disabling individual parts + if ( !suppressDisabledCheck && + ( instance.options.disabled === true || + $( this ).hasClass( "ui-state-disabled" ) ) ) { + return; + } + return ( typeof handler === "string" ? instance[ handler ] : handler ) + .apply( instance, arguments ); + } + + // Copy the guid so direct unbinding works + if ( typeof handler !== "string" ) { + handlerProxy.guid = handler.guid = + handler.guid || handlerProxy.guid || $.guid++; + } + + var match = event.match( /^([\w:-]*)\s*(.*)$/ ); + var eventName = match[ 1 ] + instance.eventNamespace; + var selector = match[ 2 ]; + + if ( selector ) { + delegateElement.on( eventName, selector, handlerProxy ); + } else { + element.on( eventName, handlerProxy ); + } + } ); + }, + + _off: function( element, eventName ) { + eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + + this.eventNamespace; + element.off( eventName ).off( eventName ); + + // Clear the stack to avoid memory leaks (#10056) + this.bindings = $( this.bindings.not( element ).get() ); + this.focusable = $( this.focusable.not( element ).get() ); + this.hoverable = $( this.hoverable.not( element ).get() ); + }, + + _delay: function( handler, delay ) { + function handlerProxy() { + return ( typeof handler === "string" ? instance[ handler ] : handler ) + .apply( instance, arguments ); + } + var instance = this; + return setTimeout( handlerProxy, delay || 0 ); + }, + + _hoverable: function( element ) { + this.hoverable = this.hoverable.add( element ); + this._on( element, { + mouseenter: function( event ) { + this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); + }, + mouseleave: function( event ) { + this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); + } + } ); + }, + + _focusable: function( element ) { + this.focusable = this.focusable.add( element ); + this._on( element, { + focusin: function( event ) { + this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); + }, + focusout: function( event ) { + this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); + } + } ); + }, + + _trigger: function( type, event, data ) { + var prop, orig; + var callback = this.options[ type ]; + + data = data || {}; + event = $.Event( event ); + event.type = ( type === this.widgetEventPrefix ? + type : + this.widgetEventPrefix + type ).toLowerCase(); + + // The original event may come from any element + // so we need to reset the target on the new event + event.target = this.element[ 0 ]; + + // Copy original event properties over to the new event + orig = event.originalEvent; + if ( orig ) { + for ( prop in orig ) { + if ( !( prop in event ) ) { + event[ prop ] = orig[ prop ]; + } + } + } + + this.element.trigger( event, data ); + return !( $.isFunction( callback ) && + callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || + event.isDefaultPrevented() ); + } + }; + + $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { + $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { + if ( typeof options === "string" ) { + options = { effect: options }; + } + + var hasOptions; + var effectName = !options ? + method : + options === true || typeof options === "number" ? + defaultEffect : + options.effect || defaultEffect; + + options = options || {}; + if ( typeof options === "number" ) { + options = { duration: options }; + } + + hasOptions = !$.isEmptyObject( options ); + options.complete = callback; + + if ( options.delay ) { + element.delay( options.delay ); + } + + if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { + element[ method ]( options ); + } else if ( effectName !== method && element[ effectName ] ) { + element[ effectName ]( options.duration, options.easing, callback ); + } else { + element.queue( function( next ) { + $( this )[ method ](); + if ( callback ) { + callback.call( element[ 0 ] ); + } + next(); + } ); + } + }; + } ); + + var widget = $.widget; -var widget = $.widget; diff --git a/public/file_uploader/package.json b/public/file_uploader/package.json deleted file mode 100755 index ed4d336..0000000 --- a/public/file_uploader/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "blueimp-file-upload", - "version": "9.18.0", - "title": "jQuery File Upload", - "description": "File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.", - "keywords": [ - "jquery", - "file", - "upload", - "widget", - "multiple", - "selection", - "drag", - "drop", - "progress", - "preview", - "cross-domain", - "cross-site", - "chunk", - "resume", - "gae", - "go", - "python", - "php", - "bootstrap" - ], - "homepage": "https://github.com/blueimp/jQuery-File-Upload", - "author": { - "name": "Sebastian Tschan", - "url": "https://blueimp.net" - }, - "repository": { - "type": "git", - "url": "git://github.com/blueimp/jQuery-File-Upload.git" - }, - "license": "MIT", - "optionalDependencies": { - "blueimp-canvas-to-blob": "3.5.0", - "blueimp-load-image": "2.12.2", - "blueimp-tmpl": "3.6.0" - }, - "devDependencies": { - "bower-json": "0.8.1", - "jshint": "2.9.3" - }, - "scripts": { - "bower-version-update": "./bower-version-update.js", - "lint": "jshint *.js js/*.js js/cors/*.js", - "test": "npm run lint", - "preversion": "npm test", - "version": "npm run bower-version-update && git add bower.json", - "postversion": "git push --tags origin master && npm publish" - }, - "main": "js/jquery.fileupload.js" -} diff --git a/public/file_uploader/test/index.html b/public/file_uploader/test/index.html deleted file mode 100755 index 4a9a6f3..0000000 --- a/public/file_uploader/test/index.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - -jQuery File Upload Plugin Test - - - - -

jQuery File Upload Plugin Test

-

-
-

-
    -
    - -
    - -
    -
    - - - - Add files... - - - - - - - - -
    - -
    - -
    -
    -
    - -
     
    -
    -
    - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/file_uploader/test/test.js b/public/file_uploader/test/test.js deleted file mode 100755 index 4521275..0000000 --- a/public/file_uploader/test/test.js +++ /dev/null @@ -1,1292 +0,0 @@ -/* - * jQuery File Upload Plugin Test - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2010, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global $, QUnit, window, document, expect, module, test, asyncTest, start, ok, strictEqual, notStrictEqual */ - -$(function () { - // jshint nomen:false - 'use strict'; - - QUnit.done = function () { - // Delete all uploaded files: - var url = $('#fileupload').prop('action'); - $.getJSON(url, function (result) { - $.each(result.files, function (index, file) { - $.ajax({ - url: url + '?file=' + encodeURIComponent(file.name), - type: 'DELETE' - }); - }); - }); - }; - - var lifecycle = { - setup: function () { - // Set the .fileupload method to the basic widget method: - $.widget('blueimp.fileupload', window.testBasicWidget, {}); - }, - teardown: function () { - // Remove all remaining event listeners: - $(document).unbind(); - } - }, - lifecycleUI = { - setup: function () { - // Set the .fileupload method to the UI widget method: - $.widget('blueimp.fileupload', window.testUIWidget, {}); - }, - teardown: function () { - // Remove all remaining event listeners: - $(document).unbind(); - } - }; - - module('Initialization', lifecycle); - - test('Widget initialization', function () { - var fu = $('#fileupload').fileupload(); - ok(fu.data('blueimp-fileupload') || fu.data('fileupload')); - }); - - test('Data attribute options', function () { - $('#fileupload').attr('data-url', 'http://example.org'); - $('#fileupload').fileupload(); - strictEqual( - $('#fileupload').fileupload('option', 'url'), - 'http://example.org' - ); - }); - - test('File input initialization', function () { - var fu = $('#fileupload').fileupload(); - ok( - fu.fileupload('option', 'fileInput').length, - 'File input field inside of the widget' - ); - ok( - fu.fileupload('option', 'fileInput').length, - 'Widget element as file input field' - ); - }); - - test('Drop zone initialization', function () { - ok($('#fileupload').fileupload() - .fileupload('option', 'dropZone').length); - }); - - test('Paste zone initialization', function () { - ok($('#fileupload').fileupload({pasteZone: document}) - .fileupload('option', 'pasteZone').length); - }); - - test('Event listeners initialization', function () { - expect( - $.support.xhrFormDataFileUpload ? 4 : 1 - ); - var eo = { - originalEvent: { - dataTransfer: {files: [{}], types: ['Files']}, - clipboardData: {items: [{}]} - } - }, - fu = $('#fileupload').fileupload({ - pasteZone: document, - dragover: function () { - ok(true, 'Triggers dragover callback'); - return false; - }, - drop: function () { - ok(true, 'Triggers drop callback'); - return false; - }, - paste: function () { - ok(true, 'Triggers paste callback'); - return false; - }, - change: function () { - ok(true, 'Triggers change callback'); - return false; - } - }), - fileInput = fu.fileupload('option', 'fileInput'), - dropZone = fu.fileupload('option', 'dropZone'), - pasteZone = fu.fileupload('option', 'pasteZone'); - fileInput.trigger($.Event('change', eo)); - dropZone.trigger($.Event('dragover', eo)); - dropZone.trigger($.Event('drop', eo)); - pasteZone.trigger($.Event('paste', eo)); - }); - - module('API', lifecycle); - - test('destroy', function () { - expect(4); - var eo = { - originalEvent: { - dataTransfer: {files: [{}], types: ['Files']}, - clipboardData: {items: [{}]} - } - }, - options = { - pasteZone: document, - dragover: function () { - ok(true, 'Triggers dragover callback'); - return false; - }, - drop: function () { - ok(true, 'Triggers drop callback'); - return false; - }, - paste: function () { - ok(true, 'Triggers paste callback'); - return false; - }, - change: function () { - ok(true, 'Triggers change callback'); - return false; - } - }, - fu = $('#fileupload').fileupload(options), - fileInput = fu.fileupload('option', 'fileInput'), - dropZone = fu.fileupload('option', 'dropZone'), - pasteZone = fu.fileupload('option', 'pasteZone'); - dropZone.bind('dragover', options.dragover); - dropZone.bind('drop', options.drop); - pasteZone.bind('paste', options.paste); - fileInput.bind('change', options.change); - fu.fileupload('destroy'); - fileInput.trigger($.Event('change', eo)); - dropZone.trigger($.Event('dragover', eo)); - dropZone.trigger($.Event('drop', eo)); - pasteZone.trigger($.Event('paste', eo)); - }); - - test('disable/enable', function () { - expect( - $.support.xhrFormDataFileUpload ? 4 : 1 - ); - var eo = { - originalEvent: { - dataTransfer: {files: [{}], types: ['Files']}, - clipboardData: {items: [{}]} - } - }, - fu = $('#fileupload').fileupload({ - pasteZone: document, - dragover: function () { - ok(true, 'Triggers dragover callback'); - return false; - }, - drop: function () { - ok(true, 'Triggers drop callback'); - return false; - }, - paste: function () { - ok(true, 'Triggers paste callback'); - return false; - }, - change: function () { - ok(true, 'Triggers change callback'); - return false; - } - }), - fileInput = fu.fileupload('option', 'fileInput'), - dropZone = fu.fileupload('option', 'dropZone'), - pasteZone = fu.fileupload('option', 'pasteZone'); - fu.fileupload('disable'); - fileInput.trigger($.Event('change', eo)); - dropZone.trigger($.Event('dragover', eo)); - dropZone.trigger($.Event('drop', eo)); - pasteZone.trigger($.Event('paste', eo)); - fu.fileupload('enable'); - fileInput.trigger($.Event('change', eo)); - dropZone.trigger($.Event('dragover', eo)); - dropZone.trigger($.Event('drop', eo)); - pasteZone.trigger($.Event('paste', eo)); - }); - - test('option', function () { - expect( - $.support.xhrFormDataFileUpload ? 10 : 7 - ); - var eo = { - originalEvent: { - dataTransfer: {files: [{}], types: ['Files']}, - clipboardData: {items: [{}]} - } - }, - fu = $('#fileupload').fileupload({ - pasteZone: document, - dragover: function () { - ok(true, 'Triggers dragover callback'); - return false; - }, - drop: function () { - ok(true, 'Triggers drop callback'); - return false; - }, - paste: function () { - ok(true, 'Triggers paste callback'); - return false; - }, - change: function () { - ok(true, 'Triggers change callback'); - return false; - } - }), - fileInput = fu.fileupload('option', 'fileInput'), - dropZone = fu.fileupload('option', 'dropZone'), - pasteZone = fu.fileupload('option', 'pasteZone'); - fu.fileupload('option', 'fileInput', null); - fu.fileupload('option', 'dropZone', null); - fu.fileupload('option', 'pasteZone', null); - fileInput.trigger($.Event('change', eo)); - dropZone.trigger($.Event('dragover', eo)); - dropZone.trigger($.Event('drop', eo)); - pasteZone.trigger($.Event('paste', eo)); - fu.fileupload('option', 'dropZone', 'body'); - strictEqual( - fu.fileupload('option', 'dropZone')[0], - document.body, - 'Allow a query string as parameter for the dropZone option' - ); - fu.fileupload('option', 'dropZone', document); - strictEqual( - fu.fileupload('option', 'dropZone')[0], - document, - 'Allow a document element as parameter for the dropZone option' - ); - fu.fileupload('option', 'pasteZone', 'body'); - strictEqual( - fu.fileupload('option', 'pasteZone')[0], - document.body, - 'Allow a query string as parameter for the pasteZone option' - ); - fu.fileupload('option', 'pasteZone', document); - strictEqual( - fu.fileupload('option', 'pasteZone')[0], - document, - 'Allow a document element as parameter for the pasteZone option' - ); - fu.fileupload('option', 'fileInput', ':file'); - strictEqual( - fu.fileupload('option', 'fileInput')[0], - $(':file')[0], - 'Allow a query string as parameter for the fileInput option' - ); - fu.fileupload('option', 'fileInput', $(':file')[0]); - strictEqual( - fu.fileupload('option', 'fileInput')[0], - $(':file')[0], - 'Allow a document element as parameter for the fileInput option' - ); - fu.fileupload('option', 'fileInput', fileInput); - fu.fileupload('option', 'dropZone', dropZone); - fu.fileupload('option', 'pasteZone', pasteZone); - fileInput.trigger($.Event('change', eo)); - dropZone.trigger($.Event('dragover', eo)); - dropZone.trigger($.Event('drop', eo)); - pasteZone.trigger($.Event('paste', eo)); - }); - - asyncTest('add', function () { - expect(2); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - add: function (e, data) { - strictEqual( - data.files[0].name, - param.files[0].name, - 'Triggers add callback' - ); - } - }).fileupload('add', param).fileupload( - 'option', - 'add', - function (e, data) { - data.submit().complete(function () { - ok(true, 'data.submit() Returns a jqXHR object'); - start(); - }); - } - ).fileupload('add', param); - }); - - asyncTest('send', function () { - expect(3); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - send: function (e, data) { - strictEqual( - data.files[0].name, - 'test', - 'Triggers send callback' - ); - } - }).fileupload('send', param).fail(function () { - ok(true, 'Allows to abort the request'); - }).complete(function () { - ok(true, 'Returns a jqXHR object'); - start(); - }).abort(); - }); - - module('Callbacks', lifecycle); - - asyncTest('add', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - add: function () { - ok(true, 'Triggers add callback'); - start(); - } - }).fileupload('add', param); - }); - - asyncTest('submit', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - submit: function () { - ok(true, 'Triggers submit callback'); - start(); - return false; - } - }).fileupload('add', param); - }); - - asyncTest('send', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - send: function () { - ok(true, 'Triggers send callback'); - start(); - return false; - } - }).fileupload('send', param); - }); - - asyncTest('done', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - done: function () { - ok(true, 'Triggers done callback'); - start(); - } - }).fileupload('send', param); - }); - - asyncTest('fail', function () { - expect(1); - var param = {files: [{name: 'test'}]}, - fu = $('#fileupload').fileupload({ - url: '404', - fail: function () { - ok(true, 'Triggers fail callback'); - start(); - } - }); - (fu.data('blueimp-fileupload') || fu.data('fileupload')) - ._isXHRUpload = function () { - return true; - }; - fu.fileupload('send', param); - }); - - asyncTest('always', function () { - expect(2); - var param = {files: [{name: 'test'}]}, - counter = 0, - fu = $('#fileupload').fileupload({ - always: function () { - ok(true, 'Triggers always callback'); - if (counter === 1) { - start(); - } else { - counter += 1; - } - } - }); - (fu.data('blueimp-fileupload') || fu.data('fileupload')) - ._isXHRUpload = function () { - return true; - }; - fu.fileupload('add', param).fileupload( - 'option', - 'url', - '404' - ).fileupload('add', param); - }); - - asyncTest('progress', function () { - expect(1); - var param = {files: [{name: 'test'}]}, - counter = 0; - $('#fileupload').fileupload({ - forceIframeTransport: true, - progress: function () { - ok(true, 'Triggers progress callback'); - if (counter === 0) { - start(); - } else { - counter += 1; - } - } - }).fileupload('send', param); - }); - - asyncTest('progressall', function () { - expect(1); - var param = {files: [{name: 'test'}]}, - counter = 0; - $('#fileupload').fileupload({ - forceIframeTransport: true, - progressall: function () { - ok(true, 'Triggers progressall callback'); - if (counter === 0) { - start(); - } else { - counter += 1; - } - } - }).fileupload('send', param); - }); - - asyncTest('start', function () { - expect(1); - var param = {files: [{name: '1'}, {name: '2'}]}, - active = 0; - $('#fileupload').fileupload({ - send: function () { - active += 1; - }, - start: function () { - ok(!active, 'Triggers start callback before uploads'); - start(); - } - }).fileupload('send', param); - }); - - asyncTest('stop', function () { - expect(1); - var param = {files: [{name: '1'}, {name: '2'}]}, - active = 0; - $('#fileupload').fileupload({ - send: function () { - active += 1; - }, - always: function () { - active -= 1; - }, - stop: function () { - ok(!active, 'Triggers stop callback after uploads'); - start(); - } - }).fileupload('send', param); - }); - - test('change', function () { - var fu = $('#fileupload').fileupload(), - fuo = fu.data('blueimp-fileupload') || fu.data('fileupload'), - fileInput = fu.fileupload('option', 'fileInput'); - expect(2); - fu.fileupload({ - change: function (e, data) { - ok(true, 'Triggers change callback'); - strictEqual( - data.files.length, - 0, - 'Returns empty files list' - ); - }, - add: $.noop - }); - fuo._onChange({ - data: {fileupload: fuo}, - target: fileInput[0] - }); - }); - - test('paste', function () { - var fu = $('#fileupload').fileupload(), - fuo = fu.data('blueimp-fileupload') || fu.data('fileupload'); - expect(1); - fu.fileupload({ - paste: function () { - ok(true, 'Triggers paste callback'); - }, - add: $.noop - }); - fuo._onPaste({ - data: {fileupload: fuo}, - originalEvent: { - dataTransfer: {files: [{}]}, - clipboardData: {items: [{}]} - }, - preventDefault: $.noop - }); - }); - - test('drop', function () { - var fu = $('#fileupload').fileupload(), - fuo = fu.data('blueimp-fileupload') || fu.data('fileupload'); - expect(1); - fu.fileupload({ - drop: function () { - ok(true, 'Triggers drop callback'); - }, - add: $.noop - }); - fuo._onDrop({ - data: {fileupload: fuo}, - originalEvent: { - dataTransfer: {files: [{}]}, - clipboardData: {items: [{}]} - }, - preventDefault: $.noop - }); - }); - - test('dragover', function () { - var fu = $('#fileupload').fileupload(), - fuo = fu.data('blueimp-fileupload') || fu.data('fileupload'); - expect(1); - fu.fileupload({ - dragover: function () { - ok(true, 'Triggers dragover callback'); - }, - add: $.noop - }); - fuo._onDragOver({ - data: {fileupload: fuo}, - originalEvent: {dataTransfer: {types: ['Files']}}, - preventDefault: $.noop - }); - }); - - module('Options', lifecycle); - - test('paramName', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - paramName: null, - send: function (e, data) { - strictEqual( - data.paramName[0], - data.fileInput.prop('name'), - 'Takes paramName from file input field if not set' - ); - return false; - } - }).fileupload('send', param); - }); - - test('url', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - url: null, - send: function (e, data) { - strictEqual( - data.url, - $(data.fileInput.prop('form')).prop('action'), - 'Takes url from form action if not set' - ); - return false; - } - }).fileupload('send', param); - }); - - test('type', function () { - expect(2); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - type: null, - send: function (e, data) { - strictEqual( - data.type, - 'POST', - 'Request type is "POST" if not set to "PUT"' - ); - return false; - } - }).fileupload('send', param); - $('#fileupload').fileupload({ - type: 'PUT', - send: function (e, data) { - strictEqual( - data.type, - 'PUT', - 'Request type is "PUT" if set to "PUT"' - ); - return false; - } - }).fileupload('send', param); - }); - - test('replaceFileInput', function () { - var fu = $('#fileupload').fileupload(), - fuo = fu.data('blueimp-fileupload') || fu.data('fileupload'), - fileInput = fu.fileupload('option', 'fileInput'), - fileInputElement = fileInput[0]; - expect(2); - fu.fileupload({ - replaceFileInput: false, - change: function () { - strictEqual( - fu.fileupload('option', 'fileInput')[0], - fileInputElement, - 'Keeps file input with replaceFileInput: false' - ); - }, - add: $.noop - }); - fuo._onChange({ - data: {fileupload: fuo}, - target: fileInput[0] - }); - fu.fileupload({ - replaceFileInput: true, - change: function () { - notStrictEqual( - fu.fileupload('option', 'fileInput')[0], - fileInputElement, - 'Replaces file input with replaceFileInput: true' - ); - }, - add: $.noop - }); - fuo._onChange({ - data: {fileupload: fuo}, - target: fileInput[0] - }); - }); - - asyncTest('forceIframeTransport', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - forceIframeTransport: true, - done: function (e, data) { - strictEqual( - data.dataType.substr(0, 6), - 'iframe', - 'Iframe Transport is used' - ); - start(); - } - }).fileupload('send', param); - }); - - test('singleFileUploads', function () { - expect(3); - var fu = $('#fileupload').fileupload(), - param = {files: [{name: '1'}, {name: '2'}]}, - index = 1; - (fu.data('blueimp-fileupload') || fu.data('fileupload')) - ._isXHRUpload = function () { - return true; - }; - $('#fileupload').fileupload({ - singleFileUploads: true, - add: function () { - ok(true, 'Triggers callback number ' + index.toString()); - index += 1; - } - }).fileupload('add', param).fileupload( - 'option', - 'singleFileUploads', - false - ).fileupload('add', param); - }); - - test('limitMultiFileUploads', function () { - expect(3); - var fu = $('#fileupload').fileupload(), - param = {files: [ - {name: '1'}, - {name: '2'}, - {name: '3'}, - {name: '4'}, - {name: '5'} - ]}, - index = 1; - (fu.data('blueimp-fileupload') || fu.data('fileupload')) - ._isXHRUpload = function () { - return true; - }; - $('#fileupload').fileupload({ - singleFileUploads: false, - limitMultiFileUploads: 2, - add: function () { - ok(true, 'Triggers callback number ' + index.toString()); - index += 1; - } - }).fileupload('add', param); - }); - - test('limitMultiFileUploadSize', function () { - expect(7); - var fu = $('#fileupload').fileupload(), - param = {files: [ - {name: '1-1', size: 100000}, - {name: '1-2', size: 40000}, - {name: '2-1', size: 100000}, - {name: '3-1', size: 50000}, - {name: '3-2', size: 40000}, - {name: '4-1', size: 45000} // New request due to limitMultiFileUploads - ]}, - param2 = {files: [ - {name: '5-1'}, - {name: '5-2'}, - {name: '6-1'}, - {name: '6-2'}, - {name: '7-1'} - ]}, - index = 1; - (fu.data('blueimp-fileupload') || fu.data('fileupload')) - ._isXHRUpload = function () { - return true; - }; - $('#fileupload').fileupload({ - singleFileUploads: false, - limitMultiFileUploads: 2, - limitMultiFileUploadSize: 150000, - limitMultiFileUploadSizeOverhead: 5000, - add: function () { - ok(true, 'Triggers callback number ' + index.toString()); - index += 1; - } - }).fileupload('add', param).fileupload('add', param2); - }); - - asyncTest('sequentialUploads', function () { - expect(6); - var param = {files: [ - {name: '1'}, - {name: '2'}, - {name: '3'}, - {name: '4'}, - {name: '5'}, - {name: '6'} - ]}, - addIndex = 0, - sendIndex = 0, - loadIndex = 0, - fu = $('#fileupload').fileupload({ - sequentialUploads: true, - add: function (e, data) { - addIndex += 1; - if (addIndex === 4) { - data.submit().abort(); - } else { - data.submit(); - } - }, - send: function () { - sendIndex += 1; - }, - done: function () { - loadIndex += 1; - strictEqual(sendIndex, loadIndex, 'upload in order'); - }, - fail: function (e, data) { - strictEqual(data.errorThrown, 'abort', 'upload aborted'); - }, - stop: function () { - start(); - } - }); - (fu.data('blueimp-fileupload') || fu.data('fileupload')) - ._isXHRUpload = function () { - return true; - }; - fu.fileupload('add', param); - }); - - asyncTest('limitConcurrentUploads', function () { - expect(12); - var param = {files: [ - {name: '1'}, - {name: '2'}, - {name: '3'}, - {name: '4'}, - {name: '5'}, - {name: '6'}, - {name: '7'}, - {name: '8'}, - {name: '9'}, - {name: '10'}, - {name: '11'}, - {name: '12'} - ]}, - addIndex = 0, - sendIndex = 0, - loadIndex = 0, - fu = $('#fileupload').fileupload({ - limitConcurrentUploads: 3, - add: function (e, data) { - addIndex += 1; - if (addIndex === 4) { - data.submit().abort(); - } else { - data.submit(); - } - }, - send: function () { - sendIndex += 1; - }, - done: function () { - loadIndex += 1; - ok(sendIndex - loadIndex < 3); - }, - fail: function (e, data) { - strictEqual(data.errorThrown, 'abort', 'upload aborted'); - }, - stop: function () { - start(); - } - }); - (fu.data('blueimp-fileupload') || fu.data('fileupload')) - ._isXHRUpload = function () { - return true; - }; - fu.fileupload('add', param); - }); - - if ($.support.xhrFileUpload) { - asyncTest('multipart', function () { - expect(2); - var param = {files: [{ - name: 'test.png', - size: 123, - type: 'image/png' - }]}, - fu = $('#fileupload').fileupload({ - multipart: false, - always: function (e, data) { - strictEqual( - data.contentType, - param.files[0].type, - 'non-multipart upload sets file type as contentType' - ); - strictEqual( - data.headers['Content-Disposition'], - 'attachment; filename="' + param.files[0].name + '"', - 'non-multipart upload sets Content-Disposition header' - ); - start(); - } - }); - fu.fileupload('send', param); - }); - } - - module('UI Initialization', lifecycleUI); - - test('Widget initialization', function () { - var fu = $('#fileupload').fileupload(); - ok(fu.data('blueimp-fileupload') || fu.data('fileupload')); - ok( - $('#fileupload').fileupload('option', 'uploadTemplate').length, - 'Initialized upload template' - ); - ok( - $('#fileupload').fileupload('option', 'downloadTemplate').length, - 'Initialized download template' - ); - }); - - test('Buttonbar event listeners', function () { - var buttonbar = $('#fileupload .fileupload-buttonbar'), - files = [{name: 'test'}]; - expect(4); - $('#fileupload').fileupload({ - send: function () { - ok(true, 'Started file upload via global start button'); - }, - fail: function (e, data) { - ok(true, 'Canceled file upload via global cancel button'); - data.context.remove(); - }, - destroy: function () { - ok(true, 'Delete action called via global delete button'); - } - }); - $('#fileupload').fileupload('add', {files: files}); - buttonbar.find('.cancel').click(); - $('#fileupload').fileupload('add', {files: files}); - buttonbar.find('.start').click(); - buttonbar.find('.cancel').click(); - files[0].deleteUrl = 'http://example.org/banana.jpg'; - ($('#fileupload').data('blueimp-fileupload') || - $('#fileupload').data('fileupload')) - ._renderDownload(files) - .appendTo($('#fileupload .files')).show() - .find('.toggle').click(); - buttonbar.find('.delete').click(); - }); - - module('UI API', lifecycleUI); - - test('destroy', function () { - var buttonbar = $('#fileupload .fileupload-buttonbar'), - files = [{name: 'test'}]; - expect(1); - $('#fileupload').fileupload({ - send: function () { - ok(true, 'This test should not run'); - return false; - } - }) - .fileupload('add', {files: files}) - .fileupload('destroy'); - buttonbar.find('.start').click(function () { - ok(true, 'Clicked global start button'); - return false; - }).click(); - }); - - test('disable/enable', function () { - var buttonbar = $('#fileupload .fileupload-buttonbar'); - $('#fileupload').fileupload(); - $('#fileupload').fileupload('disable'); - strictEqual( - buttonbar.find('input[type=file], button').not(':disabled').length, - 0, - 'Disables the buttonbar buttons' - ); - $('#fileupload').fileupload('enable'); - strictEqual( - buttonbar.find('input[type=file], button').not(':disabled').length, - 4, - 'Enables the buttonbar buttons' - ); - }); - - module('UI Callbacks', lifecycleUI); - - test('destroy', function () { - expect(3); - $('#fileupload').fileupload({ - destroy: function (e, data) { - ok(true, 'Triggers destroy callback'); - strictEqual( - data.url, - 'test', - 'Passes over deletion url parameter' - ); - strictEqual( - data.type, - 'DELETE', - 'Passes over deletion request type parameter' - ); - } - }); - ($('#fileupload').data('blueimp-fileupload') || - $('#fileupload').data('fileupload')) - ._renderDownload([{ - name: 'test', - deleteUrl: 'test', - deleteType: 'DELETE' - }]) - .appendTo($('#fileupload .files')) - .show() - .find('.toggle').click(); - $('#fileupload .fileupload-buttonbar .delete').click(); - }); - - asyncTest('added', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - added: function (e, data) { - start(); - strictEqual( - data.files[0].name, - param.files[0].name, - 'Triggers added callback' - ); - }, - send: function () { - return false; - } - }).fileupload('add', param); - }); - - asyncTest('started', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - started: function () { - start(); - ok('Triggers started callback'); - return false; - }, - sent: function () { - return false; - } - }).fileupload('send', param); - }); - - asyncTest('sent', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - sent: function (e, data) { - start(); - strictEqual( - data.files[0].name, - param.files[0].name, - 'Triggers sent callback' - ); - return false; - } - }).fileupload('send', param); - }); - - asyncTest('completed', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - completed: function () { - start(); - ok('Triggers completed callback'); - return false; - } - }).fileupload('send', param); - }); - - asyncTest('failed', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - failed: function () { - start(); - ok('Triggers failed callback'); - return false; - } - }).fileupload('send', param).abort(); - }); - - asyncTest('stopped', function () { - expect(1); - var param = {files: [{name: 'test'}]}; - $('#fileupload').fileupload({ - stopped: function () { - start(); - ok('Triggers stopped callback'); - return false; - } - }).fileupload('send', param); - }); - - asyncTest('destroyed', function () { - expect(1); - $('#fileupload').fileupload({ - dataType: 'html', - destroyed: function () { - start(); - ok(true, 'Triggers destroyed callback'); - } - }); - ($('#fileupload').data('blueimp-fileupload') || - $('#fileupload').data('fileupload')) - ._renderDownload([{ - name: 'test', - deleteUrl: '.', - deleteType: 'GET' - }]) - .appendTo($('#fileupload .files')) - .show() - .find('.toggle').click(); - $('#fileupload .fileupload-buttonbar .delete').click(); - }); - - module('UI Options', lifecycleUI); - - test('autoUpload', function () { - expect(1); - $('#fileupload') - .fileupload({ - autoUpload: true, - send: function () { - ok(true, 'Started file upload automatically'); - return false; - } - }) - .fileupload('add', {files: [{name: 'test'}]}) - .fileupload('option', 'autoUpload', false) - .fileupload('add', {files: [{name: 'test'}]}); - }); - - test('maxNumberOfFiles', function () { - expect(3); - var addIndex = 0, - sendIndex = 0; - $('#fileupload') - .fileupload({ - autoUpload: true, - maxNumberOfFiles: 3, - singleFileUploads: false, - send: function () { - strictEqual( - sendIndex += 1, - addIndex - ); - }, - progress: $.noop, - progressall: $.noop, - done: $.noop, - stop: $.noop - }) - .fileupload('add', {files: [{name: (addIndex += 1)}]}) - .fileupload('add', {files: [{name: (addIndex += 1)}]}) - .fileupload('add', {files: [{name: (addIndex += 1)}]}) - .fileupload('add', {files: [{name: 'test'}]}); - }); - - test('maxFileSize', function () { - expect(2); - var addIndex = 0, - sendIndex = 0; - $('#fileupload') - .fileupload({ - autoUpload: true, - maxFileSize: 1000, - send: function () { - strictEqual( - sendIndex += 1, - addIndex - ); - return false; - } - }) - .fileupload('add', {files: [{ - name: (addIndex += 1) - }]}) - .fileupload('add', {files: [{ - name: (addIndex += 1), - size: 999 - }]}) - .fileupload('add', {files: [{ - name: 'test', - size: 1001 - }]}) - .fileupload({ - send: function (e, data) { - ok( - !$.blueimp.fileupload.prototype.options - .send.call(this, e, data) - ); - return false; - } - }); - }); - - test('minFileSize', function () { - expect(2); - var addIndex = 0, - sendIndex = 0; - $('#fileupload') - .fileupload({ - autoUpload: true, - minFileSize: 1000, - send: function () { - strictEqual( - sendIndex += 1, - addIndex - ); - return false; - } - }) - .fileupload('add', {files: [{ - name: (addIndex += 1) - }]}) - .fileupload('add', {files: [{ - name: (addIndex += 1), - size: 1001 - }]}) - .fileupload('add', {files: [{ - name: 'test', - size: 999 - }]}) - .fileupload({ - send: function (e, data) { - ok( - !$.blueimp.fileupload.prototype.options - .send.call(this, e, data) - ); - return false; - } - }); - }); - - test('acceptFileTypes', function () { - expect(2); - var addIndex = 0, - sendIndex = 0; - $('#fileupload') - .fileupload({ - autoUpload: true, - acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, - disableImageMetaDataLoad: true, - send: function () { - strictEqual( - sendIndex += 1, - addIndex - ); - return false; - } - }) - .fileupload('add', {files: [{ - name: (addIndex += 1) + '.jpg' - }]}) - .fileupload('add', {files: [{ - name: (addIndex += 1), - type: 'image/jpeg' - }]}) - .fileupload('add', {files: [{ - name: 'test.txt', - type: 'text/plain' - }]}) - .fileupload({ - send: function (e, data) { - ok( - !$.blueimp.fileupload.prototype.options - .send.call(this, e, data) - ); - return false; - } - }); - }); - - test('acceptFileTypes as HTML5 data attribute', function () { - expect(2); - var regExp = /(\.|\/)(gif|jpe?g|png)$/i; - $('#fileupload') - .attr('data-accept-file-types', regExp.toString()) - .fileupload(); - strictEqual( - $.type($('#fileupload').fileupload('option', 'acceptFileTypes')), - $.type(regExp) - ); - strictEqual( - $('#fileupload').fileupload('option', 'acceptFileTypes').toString(), - regExp.toString() - ); - }); - -}); diff --git a/public/img/copy_icon.png b/public/img/copy_icon.png index d7a64e0..b3a0a8f 100644 Binary files a/public/img/copy_icon.png and b/public/img/copy_icon.png differ diff --git a/public/img/more_icon.png b/public/img/more_icon.png index 191cf73..a9e6975 100644 Binary files a/public/img/more_icon.png and b/public/img/more_icon.png differ diff --git a/templates/includes/images_list.html.ep b/templates/includes/images_list.html.ep index 97c32b8..cece072 100644 --- a/templates/includes/images_list.html.ep +++ b/templates/includes/images_list.html.ep @@ -1,5 +1,5 @@ -
    -
    +
    + @@ -17,7 +17,7 @@ sequentialUploads: true, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); - $('#progress .bar').css( + $('#progress .progress-bar').css( 'width', progress + '%' ); @@ -26,11 +26,10 @@ }); -
    -
    +
    -
    +
    @@ -68,7 +67,20 @@
    +
    +
    + + + +
    +
    +
    Fotos per page: + +
    +
    +
    + \ No newline at end of file diff --git a/templates/layouts/base.html.ep b/templates/layouts/base.html.ep index 5e99f76..b978e6a 100644 --- a/templates/layouts/base.html.ep +++ b/templates/layouts/base.html.ep @@ -14,7 +14,7 @@ - +