WP Offload S3 Lite - Version 0.9

Version Description

  • 2015-07-08 =
  • New: Plugin rebranded to WP Offload S3
  • New: Support tab added to Offload S3 screen containing diagnostic information
  • New: Compatibility with the Media Replace plugin
  • New: Select bucket region when creating a new bucket
  • New: Toggle switches redesigned
  • Improvement: Compatibility with release candidate of Pro plugin
  • Improvement: Example IAM policy more secure
  • Improvement: Set default bucket region using the AS3CF_REGION constant
  • Improvement: Added as3cf_object_meta filter for developers
  • Improvement: Bucket selection moved to modal window
  • Improvement: Don't allow bucket names to contain invalid characters on creation
  • Improvement: More verbose error messages on bucket selection
  • Improvement: Settings link added to plugin row on Plugins screen
  • Improvement: Object versioning enabled by default
  • Improvement: Uninstall routines added
  • Improvement: JavaScript coding standards
  • Improvement: Cache result when checking S3 bucket permissions
  • Bug fix: Bucket region errors result in blank WP Offload S3 screen
  • Bug fix: Editing an image when Remove Files From Server option is enabled results in error
  • Bug fix: Metadata upgrade procedure triggered on new installs
  • Bug fix: File URLs when uploaded to a subdirectory result in incorrect S3 URLs
  • Bug fix: Errors logged when trying to delete non-existent HiDPI images
  • Bug fix: SignatureDoesNotMatch errors on regions with v4 authentication
  • Bug fix: Customizer background image not editable
  • Bug fix: Error when creating buckets with US Standard region
  • Bug fix: Notices appearing incorrectly on some admin screens
  • Bug fix: Subsite upload paths repeated on multisite installs
  • Bug fix: Handle multisite installs where BLOG_ID_CURRENT_SITE is not 1
Download this release

Release Info

Developer bradt
Plugin Icon 128x128 WP Offload S3 Lite
Version 0.9
Comparing to
See all releases

Code changes from version 0.8.2 to 0.9

README.md ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # WP Offload S3 #
2
+ **Contributors:** bradt
3
+ **Donate link:** https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5VPMGLLK94XJC
4
+ **Tags:** uploads, amazon, s3, mirror, admin, media, cdn, cloudfront
5
+ **Requires at least:** 3.5
6
+ **Tested up to:** 4.2.2
7
+ **Stable tag:** 0.9
8
+ **License:** GPLv3
9
+
10
+ Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery.
11
+
12
+ ## Description ##
13
+
14
+ This plugin automatically copies images, videos, documents, and any other media added through WordPress' media uploader to [Amazon Simple Storage Service](http://aws.amazon.com/s3/) (S3). It then automatically replaces the URL to each media file with their respective S3 URL or, if you have configured [Amazon CloudFront](http://aws.amazon.com/cloudfront/), the respective CloudFront URL. Image thumbnails are also copied to S3 and delivered through S3/CloudFront.
15
+
16
+ Uploading files *directly* to your S3 account is not currently supported by this plugin. They are uploaded to your server first, then copied to S3. There is an option to automatically remove the files from your server once they are copied to S3 however.
17
+
18
+ If you're adding this plugin to a site that's been around for a while, your existing media files will not be copied or served from S3. Only newly uploaded files will be copied and served from S3.
19
+
20
+ **Pro Version**
21
+
22
+ We’re working on a pro version that will include the following features:
23
+
24
+ * Copy existing Media Library to S3
25
+ * Serve theme JS & CSS from S3/CloudFront
26
+ * WooCommerce & EDD integration
27
+ * Awesome email support
28
+
29
+ [Sign up for news about the pro version](https://confirmsubscription.com/h/t/295CA85AEB94E879)
30
+
31
+ [Request features, report bugs, and submit pull requests on Github](https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront/issues)
32
+
33
+ *This plugin has been completely rewritten, but was originally a fork of
34
+ [Amazon S3 for WordPress with CloudFront](http://wordpress.org/extend/plugins/tantan-s3-cloudfront/)
35
+ which is a fork of [Amazon S3 for WordPress](http://wordpress.org/extend/plugins/tantan-s3/), also known as tantan-s3.*
36
+
37
+ ## Installation ##
38
+
39
+ 1. Install the required [Amazon Web Services plugin](http://wordpress.org/extend/plugins/amazon-web-services/) using WordPress' built-in installer
40
+ 2. Follow the instructions to setup your AWS access keys
41
+ 3. Install this plugin using WordPress' built-in installer
42
+ 4. Access the *S3 and CloudFront* option under *AWS* and configure
43
+
44
+ ## Screenshots ##
45
+
46
+ ### 1. Choosing/creating a bucket ###
47
+ ![Choosing/creating a bucket](https://raw.githubusercontent.com/deliciousbrains/wp-wp-offload-s3/assets/screenshot-1.png)
48
+
49
+ ### 2. Settings screen ###
50
+ ![Settings screen](https://raw.githubusercontent.com/deliciousbrains/wp-wp-offload-s3/assets/screenshot-2.png)
51
+
52
+
53
+ ## Upgrade Notice ##
54
+
55
+ ### 0.6 ###
56
+ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
57
+
58
+ ### 0.6.1 ###
59
+ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
60
+
61
+ ### 0.6.2 ###
62
+ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
63
+
64
+ ## Changelog ##
65
+
66
+ ### 0.9 - 2015-07-08 ###
67
+ * New: Plugin rebranded to WP Offload S3
68
+ * New: Support tab added to _Offload S3_ screen containing diagnostic information
69
+ * New: Compatibility with the [Media Replace](https://wordpress.org/plugins/enable-media-replace/) plugin
70
+ * New: Select bucket region when creating a new bucket
71
+ * New: Toggle switches redesigned
72
+ * Improvement: Compatibility with release candidate of Pro plugin
73
+ * Improvement: Example IAM policy more secure
74
+ * Improvement: Set default bucket region using the `AS3CF_REGION` constant
75
+ * Improvement: Added `as3cf_object_meta` filter for developers
76
+ * Improvement: Bucket selection moved to modal window
77
+ * Improvement: Don't allow bucket names to contain invalid characters on creation
78
+ * Improvement: More verbose error messages on bucket selection
79
+ * Improvement: Settings link added to plugin row on _Plugins_ screen
80
+ * Improvement: Object versioning enabled by default
81
+ * Improvement: Uninstall routines added
82
+ * Improvement: JavaScript coding standards
83
+ * Improvement: Cache result when checking S3 bucket permissions
84
+ * Bug fix: Bucket region errors result in blank WP Offload S3 screen
85
+ * Bug fix: Editing an image when _Remove Files From Server_ option is enabled results in error
86
+ * Bug fix: Metadata upgrade procedure triggered on new installs
87
+ * Bug fix: File URLs when uploaded to a subdirectory result in incorrect S3 URLs
88
+ * Bug fix: Errors logged when trying to delete non-existent HiDPI images
89
+ * Bug fix: SignatureDoesNotMatch errors on regions with v4 authentication
90
+ * Bug fix: Customizer background image not editable
91
+ * Bug fix: Error when creating buckets with US Standard region
92
+ * Bug fix: Notices appearing incorrectly on some admin screens
93
+ * Bug fix: Subsite upload paths repeated on multisite installs
94
+ * Bug fix: Handle multisite installs where `BLOG_ID_CURRENT_SITE` is not 1
95
+
96
+ ### 0.8.2 - 2015-01-31 ###
97
+ * New: Input bucket in settings to avoid listing all buckets
98
+ * New: Specify bucket with 'AS3CF_BUCKET' constant
99
+ * Improvement: Compatibility with beta release of Pro plugin
100
+ * Bug Fix: Incorrect file prefix in S3 permission check
101
+
102
+ ### 0.8.1 - 2015-01-19 ###
103
+ * Bug Fix: Permission problems on installs running on EC2s
104
+ * Bug Fix: Blank settings page due to WP_Error on S3 permission check
105
+ * Bug Fix: Warning: strtolower() expects parameter 1 to be string, object given
106
+ * Bug Fix: Region post meta update running on subsites of Multisite installs
107
+
108
+ ### 0.8 - 2015-01-10 ###
109
+ * New: Redesigned settings UI
110
+ * Improvement: SSL setting can be fully controlled, HTTPS for urls always, based on request or never
111
+ * Improvement: Download files from S3 that are not found on server when running Regenerate Thumbnails plugin
112
+ * Improvement: When calling `get_attached_file()` and file is missing from server, return S3 URL
113
+ * Improvement: Code cleanup to WordPress coding standards
114
+ * Bug Fix: Files for all subsites going into the same S3 folder on multisite installs setup prior to WP 3.5
115
+ * Bug Fix: 'attempting to access local file system' error for some installs
116
+
117
+ ### 0.7.2 - 2014-12-11 ###
118
+ * Bug: Some buckets in the EU region causing permission and HTTP errors
119
+ * Bug: Undefined variable: message in view/error.php also causing white screens
120
+
121
+ ### 0.7.1 - 2014-12-05 ###
122
+ * Bug: Read-only error on settings page sometimes false positive
123
+
124
+ ### 0.7 - 2014-12-04 ###
125
+ * New: Proper S3 region subdomain in URLs for buckets not in the US Standard region (e.g. https://s3-us-west-2.amazonaws.com/...)
126
+ * New: Update all existing attachment meta with bucket region (automatically runs in the background)
127
+ * New: Get secure URL for different image sizes (iamzozo)
128
+ * New: S3 bucket can be set with constant in wp-config.php (dberube)
129
+ * New: Filter for allowing/disallowing file types: `as3cf_allowed_mime_types`
130
+ * New: Filter to cancel upload to S3 for any reason: `as3cf_pre_update_attachment_metadata`
131
+ * New: Sidebar with email opt-in
132
+ * Improvement: Show warning when S3 policy is read-only
133
+ * Improvement: Tooltip added to clarify option
134
+ * Improvement: Move object versioning option to make it clear it does not require CloudFront
135
+ * Improvement: By default only allow file types in `get_allowed_mime_types()` to be uploaded to S3
136
+ * Improvement: Compatibility with WPML Media plugin
137
+ * Bug Fix: Edited images not removed on S3 when restoring image and IMAGE_EDIT_OVERWRITE true
138
+ * Bug Fix: File names with certain characters broken not working
139
+ * Bug Fix: Edited image uploaded to incorrect month folder
140
+ * Bug Fix: When creating a new bucket the bucket select box appears empty on success
141
+ * Bug Fix: SSL not working in regions other than US Standard
142
+ * Bug Fix: 'Error uploading' and 'Error removing local file' messages when editing an image
143
+ * Bug Fix: Upload and delete failing when bucket is non-US-region and bucket name contains dot
144
+ * Bug Fix: S3 file overwritten when file with same name uploaded and local file removed (dataferret)
145
+ * Bug Fix: Manually resized images not uploaded (gmauricio)
146
+
147
+ ### 0.6.1 - 2013-09-21 ###
148
+ * WP.org download of Amazon Web Services plugin is giving a 404 Not Found, so directing people to download from Github instead
149
+
150
+ ### 0.6 - 2013-09-20 ###
151
+ * Complete rewrite
152
+ * Now requires PHP 5.3.3+
153
+ * Now requires the [Amazon Web Services plugin](http://wordpress.org/extend/plugins/amazon-web-services/) which contains the latest PHP libraries from Amazon
154
+ * Now works with multisite
155
+ * New Option: Custom S3 object path
156
+ * New Option: Always serve files over https (SSL)
157
+ * New Option: Enable object versioning by appending a timestamp to the S3 file path
158
+ * New Option: Remove uploaded file from local filesystem once it has been copied to S3
159
+ * New Option: Copy any HiDPI (@2x) images to S3 (works with WP Retina 2x plugin)
160
+
161
+ ### 0.5 - 2013-01-29 ###
162
+ * Forked [Amazon S3 for WordPress with CloudFront](http://wordpress.org/extend/plugins/tantan-s3-cloudfront/)
163
+ * Cleaned up the UI to fit with today's WP UI
164
+ * Fixed issues causing error messages when WP_DEBUG is on
165
+ * [Delete files on S3 when deleting WP attachment](https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront/commit/e777cd49a4b6999f999bd969241fb24cbbcece60)
166
+ * [Added filter to the get_attachment_url function](https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront/commit/bbe1aed5c2ae900e9ba1b16ba6806c28ab8e2f1c)
167
+ * [Added function to get a temporary, secure download URL for private files](https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront/commit/11f46ec2714d34907009e37ad3b97f4421aefed3)
assets/.jshintrc DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "boss": true,
3
- "browser": true,
4
- "curly": true,
5
- "devel": true,
6
- "eqeqeq": true,
7
- "eqnull": true,
8
- "es3": false,
9
- "immed": true,
10
- "jquery": true,
11
- "latedef": true,
12
- "maxerr": 10000,
13
- "newcap": true,
14
- "noarg": true,
15
- "sub": true,
16
- "undef": true,
17
- "globals": {
18
- "ajaxurl": true,
19
- "as3cf_i18n": true
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/Gruntfile.js DELETED
@@ -1,47 +0,0 @@
1
- module.exports = function(grunt) {
2
-
3
- grunt.initConfig({
4
- pkg: grunt.file.readJSON('package.json'),
5
- jshint: {
6
- all: [
7
- 'js/*.js',
8
- '!js/*.min.js'
9
- ],
10
- options: {
11
- jshintrc: '.jshintrc',
12
- force: true
13
- }
14
- },
15
- uglify: {
16
- build: {
17
- files: {
18
- 'js/script.min.js': 'js/script.js'
19
- }
20
- }
21
- },
22
- compass: {
23
- dist: {
24
- options: {
25
- }
26
- }
27
- },
28
- watch: {
29
- js: {
30
- files: ['js/*.js', '!js/*.min.js'],
31
- tasks: ['uglify']
32
- },
33
- sass: {
34
- files: ['sass/*'],
35
- tasks: ['compass']
36
- }
37
- }
38
- });
39
-
40
- grunt.loadNpmTasks('grunt-contrib-jshint');
41
- grunt.loadNpmTasks('grunt-contrib-uglify');
42
- grunt.loadNpmTasks('grunt-contrib-watch');
43
- grunt.loadNpmTasks('grunt-contrib-compass');
44
-
45
- grunt.registerTask('default', ['jshint','uglify','compass']);
46
-
47
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/config.rb DELETED
@@ -1,25 +0,0 @@
1
- # Require any additional compass plugins here.
2
-
3
- # Set this to the root of your project when deployed:
4
- http_path = "/"
5
- css_dir = "css"
6
- sass_dir = "sass"
7
- images_dir = "img"
8
- javascripts_dir = "js"
9
-
10
- # You can select your preferred output style here (can be overridden via the command line):
11
- # output_style = :expanded or :nested or :compact or :compressed
12
- output_style = :compressed
13
-
14
- # To enable relative paths to assets via compass helper functions. Uncomment:
15
- # relative_assets = true
16
-
17
- # To disable debugging comments that display the original location of your selectors. Uncomment:
18
- line_comments = false
19
-
20
-
21
- # If you prefer the indented syntax, you might want to regenerate this
22
- # project again passing --syntax sass, or you can uncomment this:
23
- # preferred_syntax = :sass
24
- # and then run:
25
- # sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/modal.css ADDED
@@ -0,0 +1 @@
 
1
+ #as3cf-overlay{display:none;position:fixed;top:0;right:0;bottom:0;left:0;background-color:rgba(0,0,0,0.5);overflow:hidden;overflow-y:auto;z-index:999999}#as3cf-modal{display:none;position:relative;width:600px;margin:100px auto;padding:30px;background-color:#eee;box-shadow:0 0 10px rgba(0,0,0,0.5);font-size:14px;overflow:hidden;z-index:100000}#as3cf-modal .close-as3cf-modal{color:#999;cursor:pointer;font-family:"Times New Roman", serif;font-size:26px;font-weight:200;position:absolute;right:18px;top:18px}#as3cf-modal .close-as3cf-modal:hover{color:#666}#as3cf-modal h3{margin:0 0 20px;font-weight:normal;line-height:1}#as3cf-modal .error,#as3cf-modal .notice,#as3cf-modal .updated{margin:0 0 20px}#as3cf-modal .actions{margin:20px -30px -30px;padding:20px 30px;border-top:none;background-color:#e3e3e3;overflow:hidden}#as3cf-modal .actions .right{margin-left:15px}#as3cf-modal .actions .right:last-of-type{margin-left:0}#as3cf-modal .actions button{min-width:90px}body.as3cf-modal-open{overflow:hidden;padding-right:15px}
assets/css/styles.css CHANGED
@@ -1 +1 @@
1
- .aws-main .error pre{background:#eaeaea;background:rgba(0,0,0,0.07);display:block;padding:10px 15px}.aws-main .error pre code{padding:0;background:none}.aws-main .as3cf-notice,.aws-main .error{max-width:935px}.aws-main .updated{display:none}.aws-main .updated.as3cf-notice,.aws-main .updated.show{display:block}.as3cf-settings{position:relative;width:650px;min-height:800px}.as3cf-settings .as3cf-main-settings{display:none}.as3cf-settings .as3cf-main-settings p{font-size:13px}.as3cf-settings .as3cf-main-settings p a{color:#444}.as3cf-settings.as3cf-has-bucket .as3cf-bucket-select{display:none}.as3cf-settings.as3cf-has-bucket .as3cf-main-settings{display:block}.as3cf-settings .object-prefix-desc em{white-space:nowrap}.as3cf-settings .as3cf-url-preview-wrap{background:#ffffff;text-align:center;padding:20px 20px 10px;max-width:610px;width:100%}.as3cf-settings .as3cf-url-preview-wrap .as3cf-url-preview{margin-top:5px;overflow-x:scroll;padding-bottom:15px}.as3cf-settings .as3cf-url-preview-wrap span{color:#aaa;text-transform:uppercase;font-weight:bold}.as3cf-settings .as3cf-ssl p.info{margin-top:10px;padding:0}.as3cf-settings .as3cf-radio-group label{display:block;margin-bottom:10px}.as3cf-settings .as3cf-radio-group label.disabled,.as3cf-settings .as3cf-radio-group label.disabled p{color:#bbbbbb;cursor:default}.as3cf-settings .as3cf-radio-group p{padding-left:25px;color:#6b6b6b;margin:0;font-size:12px}.as3cf-settings .as3cf-radio-group p.as3cf-setting{margin-top:5px}.as3cf-settings .as3cf-switch{position:relative}.as3cf-settings .as3cf-switch.disabled span{cursor:default;margin:1px 0 0 0}.as3cf-settings .as3cf-switch.disabled span.checked{background:#F1F1F1;border:1px solid #dddddd;color:#a3a3a3}.as3cf-settings .as3cf-switch span{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;cursor:pointer;float:left;display:inline-block;height:100%;font-size:12px;line-height:20px;border-radius:2px;-webkit-border-radius:2px;font-weight:bold;padding:4px 8px;background:#F1F1F1;border:1px solid #dddddd;color:#CCCCCC;margin:1px -1px 0;z-index:1}.as3cf-settings .as3cf-switch span.checked{background:#ffffff;border-color:#E4E4E4;color:#373737;padding:5px 10px;margin:0;z-index:2}.as3cf-settings .as3cf-switch input[type="checkbox"]{position:absolute !important;top:0;left:0;opacity:0;filter:alpha(opacity=0);z-index:-1}.as3cf-settings .as3cf-setting.hide{display:none}.as3cf-settings .as3cf-bucket-actions{position:absolute;right:0;top:2px}.as3cf-settings .as3cf-bucket-actions .as3cf-cancel-bucket-select-wrap{display:none}.as3cf-settings .as3cf-bucket-actions .as3cf-cancel-bucket-select-wrap:after{content:" | "}.as3cf-settings .as3cf-bucket-select.manual .as3cf-manual-bucket-toggle,.as3cf-settings .as3cf-bucket-select.manual .as3cf-refresh-buckets,.as3cf-settings .as3cf-bucket-select.manual .as3cf-bucket-list-wrapper{display:none}.as3cf-settings .as3cf-bucket-select.manual .as3cf-bucket-list-toggle,.as3cf-settings .as3cf-bucket-select.manual .as3cf-manual-save-bucket-wrapper{display:block}.as3cf-settings .as3cf-bucket-select.manual .as3cf-cancel-bucket-select-wrap:after{content:""}.as3cf-settings .as3cf-bucket-select .as3cf-manual-bucket-toggle,.as3cf-settings .as3cf-bucket-select .as3cf-bucket-list-wrapper{display:block}.as3cf-settings .as3cf-bucket-select .as3cf-refresh-buckets{display:inline}.as3cf-settings .as3cf-bucket-select .as3cf-bucket-list-toggle,.as3cf-settings .as3cf-bucket-select .as3cf-manual-save-bucket-wrapper{display:none}.as3cf-settings .as3cf-bucket-list-wrapper{background:#fff;padding:15px 20px;margin-bottom:2em}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list{max-height:300px;overflow:auto;margin:0}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list li{font-size:14px;padding:10px 0}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a{color:#444;text-decoration:none}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a:hover,.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a.selected{color:#0074A2}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a.selected{font-weight:bold}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a .bucket{float:left;clear:both}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a .bucket .dashicons{margin-right:5px}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a .spinner{float:left;background-size:15px 15px}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list.saving{opacity:0.5}.as3cf-settings input[type="text"].as3cf-bucket-name{width:80%}.as3cf-settings select.bucket{margin-bottom:5px;width:380px}.as3cf-settings .form-table td{padding-left:0;padding-right:0}.as3cf-settings .form-table td:first-child{vertical-align:top;min-width:120px}.as3cf-settings .form-table h3{font-weight:normal;text-transform:uppercase;margin:0}.as3cf-settings .form-table h4{margin:0}.as3cf-settings .form-table .as3cf-border-bottom td{border-bottom:1px solid #ddd}.as3cf-settings .as3cf-active-bucket{font-weight:bold;margin-right:10px}.as3cf-settings .tooltip{position:relative;z-index:2;cursor:pointer}.as3cf-settings .tooltip:before,.as3cf-settings .tooltip:after{visibility:hidden;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);opacity:0;pointer-events:none}.as3cf-settings .tooltip:before{position:absolute;bottom:150%;left:50%;margin-bottom:5px;margin-left:-250px;padding:10px;width:500px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;background-color:#000;background-color:rgba(51,51,51,0.9);color:#fff;content:attr(data-tooltip);text-align:center;font-size:14px;line-height:1.3}.as3cf-settings .tooltip:after{position:absolute;bottom:150%;left:50%;margin-left:-5px;width:0;border-top:5px solid #000;border-top:5px solid rgba(51,51,51,0.9);border-right:5px solid transparent;border-left:5px solid transparent;content:" ";font-size:0;line-height:0}.as3cf-settings .tooltip:hover:before,.as3cf-settings .tooltip:hover:after{visibility:visible;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);opacity:1}.as3cf-banner img{display:block}.as3cf-sidebar{position:absolute;top:17px;right:-312px;width:292px}.as3cf-sidebar .block{padding:20px;border:1px solid #ccc}.as3cf-sidebar .subscribe{border-top:none}.as3cf-sidebar .subscribe h2{padding:0;margin:0;margin-bottom:0.5em;color:#666;font-size:20px;line-height:1.2em;float:none}.as3cf-sidebar .subscribe h3{font-size:16px;margin:0}.as3cf-sidebar .subscribe p{margin:0}.as3cf-sidebar .subscribe .intro{margin-bottom:1em;line-height:1.4}.as3cf-sidebar .subscribe ul{margin-left:20px;list-style-type:disc}.as3cf-sidebar .subscribe li{line-height:1.4}.as3cf-sidebar .subscribe .links{margin-bottom:2em}.as3cf-sidebar .subscribe .links a{text-decoration:none}.as3cf-sidebar .subscribe .promise{color:#999;font-size:12px;line-height:1.4em}.as3cf-sidebar .subscribe .field{margin-bottom:0.5em}.as3cf-sidebar .subscribe .field p{margin-bottom:0.3em}.as3cf-sidebar .subscribe .field.submit-button{margin-bottom:1em}.as3cf-sidebar .credits{border-top:0}.as3cf-sidebar .credits h4{font-size:16px;margin-top:0;margin-bottom:10px}.as3cf-sidebar .credits ul{margin:0}.as3cf-sidebar .credits li{overflow:hidden}.as3cf-sidebar .credits li:last-child{margin-bottom:0}.as3cf-sidebar .credits img{float:left;margin-right:10px}.as3cf-sidebar .credits span{float:left;display:block;line-height:32px}.as3cf-sidebar .credits a{display:block;text-decoration:none;color:#444;font-size:16px;text-align:center}.as3cf-sidebar .credits a:hover{color:#888}@media (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 2.6 / 2), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx){.as3cf-sidebar .as3cf-banner{background-image:url(../img/snail@2x.jpg);background-size:292px 165px;width:292px;height:165px;display:block}.as3cf-sidebar .as3cf-banner img{display:none}}@media screen and (max-width: 1052px){.as3cf-sidebar{position:relative;top:auto;right:auto;margin-top:50px}}
1
+ .aws-main.wrap>h2{float:left}.aws-main.wrap .as3cf-notice,.aws-main.wrap .as3cf-updated,.aws-main.wrap .as3cf-error{margin-bottom:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.aws-main.wrap .as3cf-error.fatal{clear:both;float:left}.aws-main.wrap h2.nav-tab-wrapper{float:none;margin-bottom:0;width:650px;margin-top:10px;padding-left:5px;padding-right:0}.aws-main.wrap h2.nav-tab-wrapper a.nav-tab-active{color:#464646;cursor:default}.aws-main.wrap h2.nav-tab-wrapper a:focus{-webkit-box-shadow:none;box-shadow:none}.aws-main.wrap .error pre{background:#eaeaea;background:rgba(0,0,0,0.07);display:block;padding:10px 15px}.aws-main.wrap .error pre code{padding:0;background:none}.aws-main.wrap[data-tab="support"] .as3cf-notice,.aws-main.wrap[data-tab="support"] .error,.aws-main.wrap[data-tab="support"] .updated,.aws-main.wrap[data-tab="support"] .updated.show{display:none}.aws-main.wrap[data-tab="support"] .fatal .error,.aws-main.wrap[data-tab="support"] .dbrains-api-down{display:block}.aws-main.wrap .as3cf-notice,.aws-main.wrap .error,.aws-main.wrap .updated{max-width:650px;margin-top:15px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.aws-main.wrap .as3cf-updated{display:none}.aws-main.wrap .as3cf-updated.as3cf-notice,.aws-main.wrap .as3cf-updated.show{display:block}.as3cf-tab .as3cf-main-settings{display:none}.as3cf-tab .as3cf-bucket-container{display:block}.as3cf-tab.as3cf-has-bucket .as3cf-main-settings{display:block}.as3cf-tab.as3cf-has-bucket .as3cf-bucket-container{display:none}.as3cf-tab{display:none;position:relative;width:650px}.as3cf-tab .as3cf-main-settings p{font-size:13px}.as3cf-tab .as3cf-main-settings p a{color:#444}.as3cf-tab .object-prefix-desc em{white-space:nowrap}.as3cf-tab .as3cf-url-preview-wrap{background:#fff;text-align:center;padding:20px 0 0;max-width:650px;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.as3cf-tab .as3cf-url-preview-wrap .as3cf-url-preview{margin-top:10px;padding:0 20px 10px;overflow-x:scroll}.as3cf-tab .as3cf-url-preview-wrap span{color:#aaa;text-transform:uppercase;font-weight:bold}.as3cf-tab .as3cf-ssl p.info{margin-top:10px;padding:0}.as3cf-tab .as3cf-radio-group label{display:block;margin-bottom:10px}.as3cf-tab .as3cf-radio-group label.disabled,.as3cf-tab .as3cf-radio-group label.disabled p{color:#bbbbbb;cursor:default}.as3cf-tab .as3cf-radio-group p{padding-left:25px;color:#6b6b6b;margin:0;font-size:12px}.as3cf-tab .as3cf-radio-group p.as3cf-setting{margin-top:5px}.as3cf-tab .as3cf-switch{position:relative;display:inline-block;padding:2px;overflow:hidden;border-radius:2px;-webkit-border-radius:2px;background-color:#d4d3d3;cursor:pointer}.as3cf-tab .as3cf-switch.on{background-color:#ade7b5}.as3cf-tab .as3cf-switch span{visibility:hidden;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;float:left;display:inline-block;height:100%;font-size:12px;line-height:20px;border-radius:2px;-webkit-border-radius:2px;font-weight:bold;padding:4px 8px;background:#fff;color:#8d8d8d;z-index:1}.as3cf-tab .as3cf-switch span.on{color:#82d78b}.as3cf-tab .as3cf-switch span.checked{visibility:visible}.as3cf-tab .as3cf-switch.disabled{cursor:default;background:#e6e6e6}.as3cf-tab .as3cf-switch.disabled span{background:#f1f1f1;color:#d6d6d6}.as3cf-tab .as3cf-switch input[type="checkbox"]{position:absolute !important;top:0;left:0;opacity:0;filter:alpha(opacity=0);z-index:-1}.as3cf-tab .as3cf-setting.hide{display:none}.as3cf-tab h3{font-weight:normal;text-transform:uppercase;margin:15px 0}.as3cf-tab .form-table{margin:0}.as3cf-tab .form-table tr.as3cf-border-bottom td{border-bottom:1px solid #ddd;padding:20px 0px}.as3cf-tab .form-table tr.as3cf-setting-title td{padding-bottom:0}.as3cf-tab .form-table tr.as3cf-setting-title:first-child td{padding-top:20px}.as3cf-tab .form-table tr td{padding:15px 0}.as3cf-tab .form-table tr td:first-child{vertical-align:top;min-width:120px}.as3cf-tab .form-table h3{padding:0;margin:0}.as3cf-tab .form-table h4{margin:0}.as3cf-tab .as3cf-active-bucket{font-weight:bold;margin-right:10px}.as3cf-tab .tooltip{position:relative;z-index:2;cursor:pointer}.as3cf-tab .tooltip:before,.as3cf-tab .tooltip:after{visibility:hidden;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);opacity:0;pointer-events:none}.as3cf-tab .tooltip:before{position:absolute;bottom:150%;left:50%;margin-bottom:5px;margin-left:-250px;padding:10px;width:500px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;background-color:#000;background-color:rgba(51,51,51,0.9);color:#fff;content:attr(data-tooltip);text-align:center;font-size:14px;line-height:1.3}.as3cf-tab .tooltip:after{position:absolute;bottom:150%;left:50%;margin-left:-5px;width:0;border-top:5px solid #000;border-top:5px solid rgba(51,51,51,0.9);border-right:5px solid transparent;border-left:5px solid transparent;content:" ";font-size:0;line-height:0}.as3cf-tab .tooltip:hover:before,.as3cf-tab .tooltip:hover:after{visibility:visible;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);opacity:1}#tab-media{display:block}#tab-media .as3cf-main-settings{display:none}#tab-media .as3cf-bucket-container{display:block}#tab-media.as3cf-has-bucket .as3cf-main-settings{display:block}#tab-media.as3cf-has-bucket .as3cf-bucket-container{display:none}.as3cf-bucket-container h3{line-height:1.3;text-transform:none}.as3cf-bucket-container a:focus{-webkit-box-shadow:none;box-shadow:none;outline:none}.as3cf-bucket-container input[type=text]{box-sizing:border-box;width:100%}.as3cf-bucket-container select{box-sizing:border-box;width:50%}.as3cf-bucket-container .form-table td{padding:5px 0}.as3cf-bucket-container .form-table td:first-child{width:100px;line-height:30px;vertical-align:top}.as3cf-bucket-container .as3cf-invalid-bucket-name{font-size:12px;color:#a00}.as3cf-bucket-container .bucket-actions{margin:15px 0;border-top:1px solid #ccc;padding-top:15px;overflow:hidden}.as3cf-bucket-container .bucket-actions button,.as3cf-bucket-container .bucket-actions .right{float:right;margin-right:0}.as3cf-bucket-container .bucket-actions span{display:inline-block;margin-right:20px;line-height:28px}.as3cf-bucket-container .bucket-actions .bucket-action-cancel{color:#a00;text-decoration:none}.as3cf-bucket-container .bucket-actions .bucket-action-cancel:hover{color:red}.as3cf-bucket-container .as3cf-bucket-list{padding:15px;max-height:200px;overflow-x:hidden;overflow-y:auto;background-color:#fff;font-size:14px}.as3cf-bucket-container .as3cf-bucket-list li:last-of-type{margin-bottom:0}.as3cf-bucket-container .as3cf-bucket-list a{color:#444;text-decoration:none}.as3cf-bucket-container .as3cf-bucket-list a:hover{color:#0074A2}.as3cf-bucket-container .as3cf-bucket-list a.selected{font-weight:bold;color:#0074A2}.as3cf-bucket-container .as3cf-bucket-list a .dashicons{margin-right:5px}.as3cf-bucket-container .as3cf-bucket-select,.as3cf-bucket-container .as3cf-bucket-create{display:none}.as3cf-bucket-container .bucket-actions.select{display:none}.as3cf-tab{display:none}#tab-media{display:block}#tab-support .as3cf-sidebar{top:11px}#tab-support .support-section{border-bottom:1px solid #ccc;padding-bottom:20px;margin-bottom:20px}#tab-support .debug textarea{width:100%;min-height:200px;font-family:Consolas, Monaco, monospace;margin-bottom:5px}.as3cf-sidebar{position:absolute;top:25px;left:670px;width:292px}.as3cf-sidebar .block{padding:20px;border:1px solid #ccc}.as3cf-sidebar .subscribe{border-top:none}.as3cf-sidebar .subscribe h2{padding:0;margin:0;margin-bottom:0.5em;color:#666;font-size:20px;line-height:1.2em;float:none}.as3cf-sidebar .subscribe h3{font-size:16px;margin:0}.as3cf-sidebar .subscribe p{margin:0}.as3cf-sidebar .subscribe .intro{margin-bottom:1em;line-height:1.4}.as3cf-sidebar .subscribe ul{margin-left:20px;list-style-type:disc}.as3cf-sidebar .subscribe li{line-height:1.4}.as3cf-sidebar .subscribe .links{margin-bottom:2em}.as3cf-sidebar .subscribe .links a{text-decoration:none}.as3cf-sidebar .subscribe .promise{color:#999;font-size:12px;line-height:1.4em}.as3cf-sidebar .subscribe .field{margin-bottom:0.5em}.as3cf-sidebar .subscribe .field p{margin-bottom:0.3em}.as3cf-sidebar .subscribe .field.submit-button{margin-bottom:1em}.as3cf-sidebar .credits{border-top:0}.as3cf-sidebar .credits h4{font-size:16px;margin-top:0;margin-bottom:10px}.as3cf-sidebar .credits ul{margin:0}.as3cf-sidebar .credits li{overflow:hidden}.as3cf-sidebar .credits li:last-child{margin-bottom:0}.as3cf-sidebar .credits img{float:left;margin-right:10px}.as3cf-sidebar .credits span{float:left;display:block;line-height:32px}.as3cf-sidebar .credits a{display:block;text-decoration:none;color:#444;font-size:16px;text-align:center}.as3cf-sidebar .credits a:hover{color:#888}@media (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 2.6 / 2), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx){.as3cf-sidebar .as3cf-banner{background-image:url(../img/snail@2x.jpg);background-size:292px 165px;width:292px;height:165px;display:block}.as3cf-sidebar .as3cf-banner img{display:none}}@media screen and (max-width: 1052px){.as3cf-sidebar{position:relative;top:auto;right:auto;margin-top:50px}}.as3cf-banner img{display:block}.aws-compatibility-notice.error{clear:both;margin:5px 20px 5px 0}
assets/js/modal.js ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var as3cfModal = (function ( $ ) {
2
+
3
+ var modal = {
4
+ prefix: 'as3cf'
5
+ };
6
+
7
+ var modals = {};
8
+
9
+ /**
10
+ * Target to key
11
+ *
12
+ * @param string target
13
+ *
14
+ * @return string
15
+ */
16
+ function targetToKey( target ) {
17
+ return target.replace( /[^a-z]/g, '' );
18
+ }
19
+
20
+ /**
21
+ * Open modal
22
+ *
23
+ * @param string target
24
+ * @param function callback
25
+ */
26
+ modal.open = function ( target, callback ) {
27
+ var key = targetToKey( target );
28
+
29
+ // Overlay
30
+ $( 'body' ).append( '<div id="as3cf-overlay"></div>' );
31
+ var $overlay = $( '#as3cf-overlay' );
32
+
33
+ // Modal container
34
+ $overlay.append( '<div id="as3cf-modal"><span class="close-as3cf-modal">×</span></div>' );
35
+ var $modal = $( '#as3cf-modal' );
36
+
37
+ if ( undefined === modals[ key ] ) {
38
+ var content = $( target );
39
+ modals[ key ] = content.clone( true ).css( 'display', 'block' );
40
+ content.remove();
41
+ }
42
+ $modal.data( 'as3cf-modal-target', target ).append( modals[ key ] );
43
+
44
+ if ( 'function' === typeof callback ) {
45
+ callback( target );
46
+ }
47
+
48
+ // Handle modals taller than window height,
49
+ // overflow & padding-right remove duplicate scrollbars.
50
+ $( 'body' ).addClass( 'as3cf-modal-open' );
51
+
52
+ $overlay.fadeIn( 150 );
53
+ $modal.fadeIn( 150 );
54
+
55
+ $( 'body' ).trigger( 'as3cf-modal-open', [ target ] );
56
+ };
57
+
58
+ /**
59
+ * Close modal
60
+ *
61
+ * @param function callback
62
+ */
63
+ modal.close = function ( callback ) {
64
+ var target = $( '#as3cf-modal' ).data( 'as3cf-modal-target' );
65
+
66
+ $( '#as3cf-overlay' ).fadeOut( 150, function () {
67
+ if ( 'function' === typeof callback ) {
68
+ callback( target );
69
+ }
70
+
71
+ $( 'body' ).removeClass( 'as3cf-modal-open' );
72
+
73
+ $( this ).remove();
74
+ } );
75
+
76
+ $( 'body' ).trigger( 'as3cf-modal-close', [ target ] );
77
+ };
78
+
79
+ // Setup click handlers
80
+ $( document ).ready( function () {
81
+
82
+ $( 'body' ).on( 'click', '[data-as3cf-modal]', function ( e ) {
83
+ e.preventDefault();
84
+ modal.open( $( this ).data( 'as3cf-modal' ) + '.' + modal.prefix );
85
+ } );
86
+
87
+ $( 'body' ).on( 'click', '#as3cf-overlay, .close-as3cf-modal', function ( e ) {
88
+ e.preventDefault();
89
+
90
+ // Don't allow children to bubble up click event
91
+ if ( e.target !== this ) {
92
+ return false;
93
+ }
94
+
95
+ modal.close();
96
+ } );
97
+
98
+ } );
99
+
100
+ return modal;
101
+
102
+ })( jQuery );
103
+
104
+ var as3cfFindAndReplaceModal = (function ( $, as3cfModal ) {
105
+
106
+ var modal = {
107
+ selector: '.as3cf-find-replace-container',
108
+ isBulk: false,
109
+ link: null,
110
+ payload: {}
111
+ };
112
+
113
+ /**
114
+ * Open modal
115
+ *
116
+ * @param string link
117
+ * @param mixed payload
118
+ */
119
+ modal.open = function ( link, payload ) {
120
+ if ( typeof link !== 'undefined' ) {
121
+ modal.link = link;
122
+ }
123
+ if ( typeof payload !== 'undefined' ) {
124
+ modal.payload = payload;
125
+ }
126
+
127
+ as3cfModal.open( modal.selector );
128
+
129
+ $( modal.selector ).find( '.single-file' ).show();
130
+ $( modal.selector ).find( '.multiple-files' ).hide();
131
+ if ( modal.isBulk ) {
132
+ $( modal.selector ).find( '.single-file' ).hide();
133
+ $( modal.selector ).find( '.multiple-files' ).show();
134
+ }
135
+ };
136
+
137
+ /**
138
+ * Close modal
139
+ */
140
+ modal.close = function () {
141
+ as3cfModal.close( modal.selector );
142
+ };
143
+
144
+ /**
145
+ * Set the isBulk flag
146
+ */
147
+ modal.setBulk = function ( isBulk ) {
148
+ modal.isBulk = isBulk;
149
+ };
150
+
151
+ /**
152
+ * Create the loading state
153
+ */
154
+ modal.startLoading = function () {
155
+ $( modal.selector + ' [data-find-replace]' ).prop( 'disabled', true ).siblings( '.spinner' ).css( 'visibility', 'visible' ).show();
156
+ };
157
+
158
+ /**
159
+ * Remove the loading state
160
+ */
161
+ modal.stopLoading = function () {
162
+ $( modal.selector + ' [data-find-replace]' ).prop( 'disabled', false ).siblings( '.spinner' ).css( 'visibility', 'hidden' ).hide();
163
+ };
164
+
165
+ // Setup click handlers
166
+ $( document ).ready( function () {
167
+
168
+ $( 'body' ).on( 'click', modal.selector + ' [data-find-replace]', function ( e ) {
169
+ var findAndReplace = $( this ).data( 'find-replace' );
170
+
171
+ if ( !modal.link ) {
172
+ // If there is no link set then this must be an AJAX
173
+ // request so trigger an event instead
174
+ $( modal.selector ).trigger( 'as3cf-find-and-replace', [ findAndReplace, modal.payload ] );
175
+ return;
176
+ }
177
+
178
+ if ( findAndReplace ) {
179
+ modal.link += '&find_and_replace=1';
180
+ }
181
+
182
+ modal.startLoading();
183
+
184
+ window.location = modal.link;
185
+ } );
186
+
187
+ $( 'body' ).on( 'as3cf-modal-close', function ( e ) {
188
+ modal.isBulk = false;
189
+ modal.link = null;
190
+ modal.payload = {};
191
+ } );
192
+
193
+ } );
194
+
195
+ return modal;
196
+
197
+ })( jQuery, as3cfModal );
198
+
199
+
assets/js/modal.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var as3cfModal=function(a){function b(a){return a.replace(/[^a-z]/g,"")}var c={prefix:"as3cf"},d={};return c.open=function(c,e){var f=b(c);a("body").append('<div id="as3cf-overlay"></div>');var g=a("#as3cf-overlay");g.append('<div id="as3cf-modal"><span class="close-as3cf-modal">×</span></div>');var h=a("#as3cf-modal");if(void 0===d[f]){var i=a(c);d[f]=i.clone(!0).css("display","block"),i.remove()}h.data("as3cf-modal-target",c).append(d[f]),"function"==typeof e&&e(c),a("body").addClass("as3cf-modal-open"),g.fadeIn(150),h.fadeIn(150),a("body").trigger("as3cf-modal-open",[c])},c.close=function(b){var c=a("#as3cf-modal").data("as3cf-modal-target");a("#as3cf-overlay").fadeOut(150,function(){"function"==typeof b&&b(c),a("body").removeClass("as3cf-modal-open"),a(this).remove()}),a("body").trigger("as3cf-modal-close",[c])},a(document).ready(function(){a("body").on("click","[data-as3cf-modal]",function(b){b.preventDefault(),c.open(a(this).data("as3cf-modal")+"."+c.prefix)}),a("body").on("click","#as3cf-overlay, .close-as3cf-modal",function(a){return a.preventDefault(),a.target!==this?!1:void c.close()})}),c}(jQuery),as3cfFindAndReplaceModal=function(a,b){var c={selector:".as3cf-find-replace-container",isBulk:!1,link:null,payload:{}};return c.open=function(d,e){"undefined"!=typeof d&&(c.link=d),"undefined"!=typeof e&&(c.payload=e),b.open(c.selector),a(c.selector).find(".single-file").show(),a(c.selector).find(".multiple-files").hide(),c.isBulk&&(a(c.selector).find(".single-file").hide(),a(c.selector).find(".multiple-files").show())},c.close=function(){b.close(c.selector)},c.setBulk=function(a){c.isBulk=a},c.startLoading=function(){a(c.selector+" [data-find-replace]").prop("disabled",!0).siblings(".spinner").css("visibility","visible").show()},c.stopLoading=function(){a(c.selector+" [data-find-replace]").prop("disabled",!1).siblings(".spinner").css("visibility","hidden").hide()},a(document).ready(function(){a("body").on("click",c.selector+" [data-find-replace]",function(){var b=a(this).data("find-replace");return c.link?(b&&(c.link+="&find_and_replace=1"),c.startLoading(),void(window.location=c.link)):void a(c.selector).trigger("as3cf-find-and-replace",[b,c.payload])}),a("body").on("as3cf-modal-close",function(){c.isBulk=!1,c.link=null,c.payload={}})}),c}(jQuery,as3cfModal);
assets/js/script.js CHANGED
@@ -1,311 +1,560 @@
1
- (function($) {
2
- var saved_settings;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- $( document ).ready( function() {
 
5
 
6
- $( '.as3cf-settings' ).each( function() {
7
- var $container = $( this );
8
- var $bucketList = $( '.as3cf-bucket-list' );
9
- var $createBucketForm = $container.find( '.as3cf-create-bucket-form' );
10
- var $manualBucketForm = $container.find( '.as3cf-manual-save-bucket-form' );
11
 
12
- if ( $createBucketForm.length ) {
13
- var $createBucketButton = $createBucketForm.find( 'button' );
14
- var origButtonText = $createBucketButton.text();
15
 
16
- $createBucketForm.on( 'submit', function( e ) {
17
- e.preventDefault();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  $( '.as3cf-bucket-error' ).hide();
19
- $bucketList.addClass( 'saving' );
20
- $createBucketButton.text( $createBucketButton.attr( 'data-working' ) );
21
- $createBucketButton.prop( 'disabled', true );
22
- var bucketName = $createBucketForm.find( 'input[name="bucket_name"]' ).val();
23
-
24
- var data = {
25
- action : 'as3cf-create-bucket',
26
- bucket_name: bucketName,
27
- _nonce : as3cf_i18n.create_bucket_nonce
28
- };
29
-
30
- $.ajax( {
31
- url : ajaxurl,
32
- type : 'POST',
33
- dataType: 'JSON',
34
- data : data,
35
- error : function( jqXHR, textStatus, errorThrown ) {
36
- $createBucketButton.text( origButtonText );
37
- show_bucket_error( as3cf_i18n.create_bucket_error, errorThrown );
38
- },
39
- success : function( data, textStatus, jqXHR ) {
40
- $createBucketButton.text( origButtonText );
41
- $createBucketButton.prop( 'disabled', false );
42
- if ( typeof data[ 'success' ] !== 'undefined' ) {
43
- bucket_select( bucketName, data[ 'region' ], data[ 'can_write' ] );
44
- // tidy up create bucket form
45
- $createBucketForm.find( 'input[name="bucket_name"]' ).val( '' );
46
- if ( $( '.as3cf-bucket-list-wrapper' ).is( ':visible' ) ) {
47
- loadBuckets();
48
- }
49
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
50
- $bucketList.removeClass( 'saving' );
51
- $manualBucketForm.find( 'input[name="bucket_name"]' ).val( bucketName );
52
- } else {
53
- show_bucket_error( as3cf_i18n.create_bucket_error, data[ 'error' ] );
54
- }
55
- }
56
- } );
57
- } );
58
- }
59
 
60
- if ( $manualBucketForm.length ) {
61
- var $manualBucketButton = $manualBucketForm.find( 'button' );
62
- var origManualButtonText = $manualBucketButton.text();
63
-
64
- $manualBucketForm.on( 'submit', function( e ) {
65
- e.preventDefault();
66
- var bucketName = $manualBucketForm.find( 'input[name="bucket_name"]' ).val();
67
- if ( bucketName === $( '.as3cf-active-bucket' ).text() ) {
68
- $( '.as3cf-bucket-error' ).hide();
69
- $( '.as3cf-settings' ).addClass( 'as3cf-has-bucket' );
70
- return;
71
- }
72
- $( '.as3cf-bucket-error' ).hide();
73
- $manualBucketButton.text( $manualBucketButton.attr( 'data-working' ) );
74
- $manualBucketButton.prop( 'disabled', true );
75
-
76
- var data = {
77
- action : 'as3cf-manual-save-bucket',
78
- bucket_name: bucketName,
79
- _nonce : as3cf_i18n.manual_bucket_nonce
80
- };
81
-
82
- $.ajax( {
83
- url : ajaxurl,
84
- type : 'POST',
85
- dataType: 'JSON',
86
- data : data,
87
- error : function( jqXHR, textStatus, errorThrown ) {
88
- $manualBucketButton.text( origManualButtonText );
89
- show_bucket_error( as3cf_i18n.save_bucket_error, errorThrown );
90
- },
91
- success : function( data, textStatus, jqXHR ) {
92
- $manualBucketButton.text( origManualButtonText );
93
- $manualBucketButton.prop( 'disabled', false );
94
- if ( typeof data[ 'success' ] !== 'undefined' ) {
95
- bucket_select( bucketName, data[ 'region' ], data[ 'can_write' ] );
96
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
97
- } else {
98
- show_bucket_error( as3cf_i18n.save_bucket_error, data[ 'error' ] );
99
- }
100
- }
101
  } );
102
- } );
103
- }
104
-
105
- var $changeBucket = $container.find( '.as3cf-change-bucket' );
106
- if ( $changeBucket.length ) {
107
- $changeBucket.on( 'click', function( e ) {
108
- e.preventDefault();
109
- $( '.updated' ).not( '.as3cf-notice' ).hide();
110
- $( '.as3cf-can-write-error' ).hide();
111
- $( '.as3cf-settings' ).removeClass( 'as3cf-has-bucket' );
112
- if ( $( '.as3cf-bucket-list-wrapper' ).is( ':visible' ) ) {
113
- loadBuckets();
114
- if ( $( '.as3cf-active-bucket' ).html ) {
115
- $( '.as3cf-cancel-bucket-select-wrap' ).show();
116
- }
117
- }
118
- } );
119
- }
120
 
121
- var $refreshBuckets = $container.find( '.as3cf-refresh-buckets' );
122
- if ( $refreshBuckets.length ) {
123
- $refreshBuckets.on( 'click', function( e ) {
124
- e.preventDefault();
125
- loadBuckets();
126
- } );
127
  }
 
 
 
 
 
 
 
 
 
 
128
 
129
- var $cancelChangeBucket = $container.find( '.as3cf-cancel-bucket-select' );
130
- if ( $cancelChangeBucket.length ) {
131
- $cancelChangeBucket.on( 'click', function( e ) {
132
- e.preventDefault();
133
- $( '.as3cf-bucket-error' ).hide();
134
- $( '.as3cf-settings' ).addClass( 'as3cf-has-bucket' );
135
- } );
136
- }
137
 
 
 
138
  } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
- var $bucketList = $( '.as3cf-bucket-list' );
141
 
142
- function loadBuckets() {
143
- $( '.as3cf-bucket-error' ).hide();
144
- $bucketList.html( '<li class="loading">' + $bucketList.attr( 'data-working' ) + '</li>' );
145
-
146
- var data = {
147
- action: 'as3cf-get-buckets',
148
- _nonce: as3cf_i18n.get_buckets_nonce
149
- };
150
-
151
- $.ajax( {
152
- url : ajaxurl,
153
- type : 'POST',
154
- dataType: 'JSON',
155
- data : data,
156
- error : function( jqXHR, textStatus, errorThrown ) {
157
- $bucketList.html( '' );
158
- show_bucket_error( as3cf_i18n.get_buckets_error, errorThrown );
159
- },
160
- success : function( data, textStatus, jqXHR ) {
161
- $bucketList.html( '' );
162
- if ( typeof data[ 'success' ] !== 'undefined' ) {
163
- $( data[ 'buckets' ] ).each( function( idx, bucket ) {
164
- var bucket_class = (
165
- bucket.Name === data[ 'selected' ]
166
- ) ? 'selected' : '';
167
- $bucketList.append( '<li><a class="' + bucket_class + '" href="#" data-bucket="' + bucket.Name + '"><span class="bucket"><span class="dashicons dashicons-portfolio"></span> ' + bucket.Name + '</span><span class="spinner"></span></span></a></li>' );
168
- } );
169
- scroll_to_selected_bucket();
170
- } else {
171
- show_bucket_error( as3cf_i18n.get_buckets_error, data[ 'error' ] );
172
- }
173
- }
174
- } );
175
- }
176
 
177
- $bucketList.on( 'click', 'a', function( e ) {
178
- e.preventDefault();
 
 
 
 
 
 
 
179
 
180
- if ( $( this ).hasClass( 'selected' ) ) {
181
- $( '.as3cf-settings' ).addClass( 'as3cf-has-bucket' );
182
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  }
 
 
 
 
 
 
 
 
 
 
184
 
185
- var bucket = this;
186
- var previous_bucket = $( '.as3cf-bucket-list a.selected' ).attr( 'data-bucket' );
 
 
 
187
 
188
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
189
- $( bucket ).addClass( 'selected' );
190
-
191
- $bucketList.addClass( 'saving' );
192
- $( bucket ).find( '.spinner' ).show();
193
- var bucketName = $( bucket ).attr( 'data-bucket' );
194
-
195
- var data = {
196
- action : 'as3cf-save-bucket',
197
- bucket_name: bucketName,
198
- _nonce : as3cf_i18n.save_bucket_nonce
199
- };
200
-
201
- $.ajax( {
202
- url : ajaxurl,
203
- type : 'POST',
204
- dataType: 'JSON',
205
- data : data,
206
- error : function( jqXHR, textStatus, errorThrown ) {
207
- $bucketList.removeClass( 'saving' );
208
- show_bucket_error( as3cf_i18n.save_bucket_error, errorThrown );
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
210
- $( '.as3cf-bucket-list a[data-bucket="' + previous_bucket + '"]' ).addClass( 'selected' );
211
- },
212
- success : function( data, textStatus, jqXHR ) {
213
- $( bucket ).find( '.spinner' ).hide();
214
- $bucketList.removeClass( 'saving' );
215
- if ( typeof data[ 'success' ] !== 'undefined' ) {
216
- bucket_select( bucketName, data[ 'region' ], data[ 'can_write' ] );
217
- } else {
218
- show_bucket_error( as3cf_i18n.save_bucket_error, data[ 'error' ] );
219
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
220
- $( '.as3cf-bucket-list a[data-bucket="' + previous_bucket + '"]' ).addClass( 'selected' );
221
- }
222
  }
223
- } );
224
  } );
 
 
 
 
 
 
 
 
 
225
 
226
- function scroll_to_selected_bucket() {
227
- if ( ! $( '.as3cf-bucket-list a.selected' ).length ) {
228
- return;
229
- }
230
 
231
- var offset = $( 'ul.as3cf-bucket-list li' ).first().position().top + 150;
 
 
 
 
 
232
 
233
- $( 'ul.as3cf-bucket-list' ).animate( {
234
- scrollTop: $( 'ul.as3cf-bucket-list li a.selected' ).position().top - offset
235
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  }
237
 
238
- function show_bucket_error( title, error ) {
239
- $( '.as3cf-bucket-error span.title' ).html( title );
240
- $( '.as3cf-bucket-error span.message' ).html( error );
241
- $( '.as3cf-bucket-error' ).show();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  }
243
 
244
- function bucket_select( bucket, region, can_write ) {
245
- if ( '' === $( '.as3cf-active-bucket' ).text() ) {
246
- // first time bucket select - enable main options by default
247
- set_checkbox( 'copy-to-s3-wrap' );
248
- set_checkbox( 'serve-from-s3-wrap' );
249
- }
250
- $( '.as3cf-active-bucket' ).text( bucket );
251
- $( 'form.as3cf-manual-save-bucket-form .as3cf-bucket-name' ).val( bucket );
252
- $( '#as3cf-bucket' ).val( bucket );
253
- $( '#as3cf-region' ).val( region );
254
- $( '.updated' ).not( '.as3cf-notice' ).show();
255
- // check permission on bucket
256
- if ( can_write === false ) {
257
- $( '.as3cf-can-write-error' ).show();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  }
259
- $( '.as3cf-settings' ).addClass( 'as3cf-has-bucket' );
260
- generate_url_preview();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  }
262
 
263
- $( '.as3cf-switch' ).on( 'click', 'span', function( e ) {
264
- if ( ! $( this ).parent().hasClass( 'disabled' ) ) {
265
- var parent_id = $( this ).parent().attr( 'id' );
266
- set_checkbox( parent_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  }
268
  } );
 
 
 
269
 
270
- function set_checkbox( checkbox_wrap ) {
271
- $( '#' + checkbox_wrap + ' span' ).toggleClass( 'checked' );
272
- var switch_on = $( '#' + checkbox_wrap + ' span.on' ).hasClass( 'checked' );
273
- var checkbox_name = $( '#' + checkbox_wrap ).data( 'checkbox' );
274
- var $checkbox = $( 'input#' + checkbox_name );
275
- $checkbox.attr( "checked", switch_on );
276
- $checkbox.trigger( "change" );
 
 
 
 
 
 
 
 
 
277
  }
278
 
279
- if ( $( '.as3cf-settings' ).length && ! $( '.as3cf-settings' ).hasClass( 'as3cf-has-bucket' ) ) {
280
- if ( $( '.as3cf-bucket-list-wrapper' ).is( ':visible' ) ) {
281
- loadBuckets();
 
282
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  }
284
 
285
- $( '.as3cf-settings' ).on( 'change', '.sub-toggle', function( e ) {
286
- var setting = $( this ).attr( 'id' );
287
- $( '.as3cf-setting.' + setting ).toggleClass( 'hide' );
 
 
 
 
 
 
 
 
288
  } );
289
 
290
- $( '.as3cf-settings' ).on( 'click', '.as3cf-manual-bucket-toggle', function( e ) {
291
- e.preventDefault();
292
- $( '.as3cf-bucket-select' ).addClass( 'manual' );
 
293
  } );
294
 
295
- $( '.as3cf-settings' ).on( 'click', '.as3cf-bucket-list-toggle', function( e ) {
296
- e.preventDefault();
297
- loadBuckets();
298
- $( '.as3cf-bucket-select' ).removeClass( 'manual' );
299
- $( '.as3cf-cancel-bucket-select-wrap' ).show();
 
 
 
 
300
  } );
301
 
302
  $( '.as3cf-domain' ).on( 'change', 'input[type="radio"]', function( e ) {
303
- var domain = $( 'input:radio[name="domain"]:checked' ).val();
304
- if ( 'cloudfront' === domain && $( '.as3cf-setting.cloudfront' ).hasClass( 'hide' ) ) {
305
- $( '.as3cf-setting.cloudfront' ).removeClass( 'hide' );
306
- } else {
307
- $( '.as3cf-setting.cloudfront' ).addClass( 'hide' );
308
- }
309
  } );
310
 
311
  $( '.as3cf-ssl' ).on( 'change', 'input[type="radio"]', function( e ) {
@@ -324,72 +573,98 @@
324
  } );
325
 
326
  $( '.url-preview' ).on( 'change', 'input', function( e ) {
327
- generate_url_preview();
328
  } );
329
 
330
- function generate_url_preview() {
331
- $( '.as3cf-url-preview' ).html( 'Generating...' );
332
 
333
- var data = {
334
- _nonce: as3cf_i18n.get_url_preview_nonce
335
- };
336
 
337
- $.each( $( ".as3cf-main-settings form" ).serializeArray(), function( i, o ) {
338
- var n = o.name,
339
- v = o.value;
340
- n = n.replace( '[]', '' );
341
- data[ n ] = data[ n ] === undefined ? v
342
- : $.isArray( data[ n ] ) ? data[ n ].concat( v )
343
- : [ data[ n ], v ];
344
- } );
345
 
346
- // overwrite the save action stored in the form
347
- data[ 'action' ] = 'as3cf-get-url-preview';
348
-
349
- $.ajax( {
350
- url : ajaxurl,
351
- type : 'POST',
352
- dataType: 'JSON',
353
- data : data,
354
- error : function( jqXHR, textStatus, errorThrown ) {
355
- alert( as3cf_i18n.get_url_preview_error + errorThrown );
356
- },
357
- success : function( data, textStatus, jqXHR ) {
358
- if ( typeof data[ 'success' ] !== 'undefined' ) {
359
- $( '.as3cf-url-preview' ).html( data[ 'url' ] );
360
- } else {
361
- alert( as3cf_i18n.get_url_preview_error + data[ 'error' ] );
362
- }
363
- }
364
- } );
365
- }
366
 
367
- /**
368
- * Return the serialized string of the settings form
369
- * excluding the bucket and region inputs as they get saved via AJAX
370
- *
371
- * @returns {string}
372
- */
373
- function serialized_form() {
374
- return $( '.as3cf-main-settings form' ).find( 'input:not(.no-compare)' ).serialize();
375
- }
376
 
377
- // save the original state of the form for comparison later
378
- saved_settings = serialized_form();
 
 
 
 
 
 
 
 
 
 
 
 
379
 
380
- // let the save settings submit happen as normal
381
- $( document ).on( 'submit', '.as3cf-main-settings form', function( event ) {
382
- // disable unload warning
383
- $( window ).off( 'beforeunload.as3cf-settings' );
384
  } );
385
 
386
- // prompt user with dialog if leaving the settings page with unsaved changes
387
- $( window ).on( 'beforeunload.as3cf-settings', function() {
388
- if ( serialized_form() !== saved_settings ) {
389
- return as3cf_i18n.save_alert;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
  }
391
  } );
392
 
393
  } );
394
 
395
- })(jQuery);
1
+ (function( $, as3cfModal ) {
2
+
3
+ var savedSettings = {};
4
+ var bucketNamePattern = /[^a-z0-9.-]/;
5
+
6
+ var $tabs = $( '.as3cf-tab' );
7
+ var $activeTab;
8
+
9
+ /**
10
+ * Return the serialized string of the settings form
11
+ * excluding the bucket and region inputs as they get saved via AJAX
12
+ *
13
+ * @param string tab
14
+ *
15
+ * @returns {string}
16
+ */
17
+ function serializedForm( tab ) {
18
+ return $( '#' + tab + ' .as3cf-main-settings form' ).find( 'input:not(.no-compare)' ).serialize();
19
+ }
20
+
21
+ /**
22
+ * Set checkbox
23
+ *
24
+ * @param string checkbox_wrap
25
+ */
26
+ function setCheckbox( checkbox_wrap ) {
27
+ var $switch = $( '#' + checkbox_wrap );
28
+ var $checkbox = $switch.find( 'input[type=checkbox]' );
29
+
30
+ $switch.toggleClass( 'on' ).find( 'span' ).toggleClass( 'checked' );
31
+ var switchOn = $switch.find( 'span.on' ).hasClass( 'checked' );
32
+ $checkbox.attr( 'checked', switchOn ).trigger( 'change' );
33
+ }
34
+
35
+ as3cf.tabs = {
36
+ /**
37
+ * Toggle settings tab
38
+ *
39
+ * @param string hash
40
+ * @param bool persist_updated_notice
41
+ */
42
+ toggle: function( hash, persist_updated_notice ) {
43
+ $tabs.hide();
44
+ $activeTab = $( '#tab-' + hash );
45
+ $activeTab.show();
46
+ $( '.nav-tab' ).removeClass( 'nav-tab-active' );
47
+ $( 'a.nav-tab[data-tab="' + hash + '"]' ).addClass( 'nav-tab-active' );
48
+ $( '.aws-main' ).attr( 'data-tab', hash );
49
+ if ( $activeTab.attr( 'data-prefix' ) ) {
50
+ as3cfModal.prefix = $activeTab.attr( 'data-prefix' );
51
+ }
52
+ if ( !persist_updated_notice ) {
53
+ $( '.as3cf-updated' ).removeClass( 'show' );
54
+ }
55
+ }
56
+ };
57
+
58
+ /**
59
+ * Load bucket list
60
+ *
61
+ * @param bool forceUpdate
62
+ */
63
+ function loadBucketList( forceUpdate ) {
64
+ if ( 'undefined' === typeof forceUpdate ) {
65
+ forceUpdate = false;
66
+ }
67
 
68
+ var $bucketList = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-list' );
69
+ var selectedBucket = $( '#' + as3cfModal.prefix + '-bucket' ).val();
70
 
71
+ if ( false === forceUpdate && $bucketList.find( 'li' ).length > 1 ) {
72
+ $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
73
+ $( '.as3cf-bucket-list a[data-bucket="' + selectedBucket + '"]' ).addClass( 'selected' );
 
 
74
 
75
+ scrollToSelectedBucket();
76
+ return;
77
+ }
78
 
79
+ $bucketList.html( '<li class="loading">' + $bucketList.attr( 'data-working' ) + '</li>' );
80
+
81
+ var data = {
82
+ action: as3cfModal.prefix + '-get-buckets',
83
+ _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.get_buckets
84
+ };
85
+
86
+ $.ajax( {
87
+ url: ajaxurl,
88
+ type: 'POST',
89
+ dataType: 'JSON',
90
+ data: data,
91
+ error: function( jqXHR, textStatus, errorThrown ) {
92
+ $bucketList.html( '' );
93
+ showBucketError( as3cf.strings.get_buckets_error, errorThrown, 'as3cf-bucket-select' );
94
+ },
95
+ success: function( data, textStatus, jqXHR ) {
96
+ $bucketList.html( '' );
97
+
98
+ if ( typeof data[ 'success' ] !== 'undefined' ) {
99
  $( '.as3cf-bucket-error' ).hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
+ $( data[ 'buckets' ] ).each( function( idx, bucket ) {
102
+ var bucketClass = bucket.Name === selectedBucket ? 'selected' : '';
103
+ $bucketList.append( '<li><a class="' + bucketClass + '" href="#" data-bucket="' + bucket.Name + '"><span class="bucket"><span class="dashicons dashicons-portfolio"></span> ' + bucket.Name + '</span><span class="spinner"></span></span></a></li>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
+ scrollToSelectedBucket();
107
+ } else {
108
+ showBucketError( as3cf.strings.get_buckets_error, data[ 'error' ], 'as3cf-bucket-select' );
109
+ }
 
 
110
  }
111
+ } );
112
+ }
113
+
114
+ /**
115
+ * Scroll to selected bucket
116
+ */
117
+ function scrollToSelectedBucket() {
118
+ if ( !$( '.as3cf-bucket-list a.selected' ).length ) {
119
+ return;
120
+ }
121
 
122
+ var offset = $( 'ul.as3cf-bucket-list li' ).first().position().top + 150;
 
 
 
 
 
 
 
123
 
124
+ $( '.as3cf-bucket-list' ).animate( {
125
+ scrollTop: $( 'ul.as3cf-bucket-list li a.selected' ).position().top - offset
126
  } );
127
+ }
128
+
129
+ /**
130
+ * Reset bucket modal
131
+ */
132
+ function resetBucketModal() {
133
+ var $bucketContainer = $( '.as3cf-bucket-container.' + as3cfModal.prefix );
134
+
135
+ if ( false === $activeTab.hasClass( 'as3cf-has-bucket' ) || 'manual' === $( '#' + as3cfModal.prefix + '-bucket-select' ).val() ) {
136
+ $bucketContainer.find( '.as3cf-bucket-manual' ).show().siblings().hide();
137
+ $bucketContainer.find( '.bucket-actions.manual' ).show().siblings( '.bucket-actions' ).hide();
138
+ } else {
139
+ $bucketContainer.find( '.as3cf-bucket-select' ).show().siblings().hide();
140
+ $bucketContainer.find( '.bucket-actions.select' ).show().siblings( '.bucket-actions' ).hide();
141
+
142
+ loadBucketList();
143
+ }
144
 
145
+ $bucketContainer.find( '.as3cf-bucket-error' ).hide();
146
 
147
+ // Reset manual select value
148
+ var bucket = $( '#' + as3cfModal.prefix + '-bucket' ).val();
149
+ $bucketContainer.find( '.as3cf-bucket-manual .as3cf-bucket-name' ).val( bucket );
150
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
+ /**
153
+ * Save manual bucket
154
+ */
155
+ function saveManualBucket() {
156
+ var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
157
+ var $manualBucketInput = $manualBucketForm.find( '.as3cf-bucket-name' );
158
+ var $manualBucketButton = $manualBucketForm.find( 'button[type=submit]' );
159
+ var bucketName = $manualBucketInput.val();
160
+ var originalBucketText = $manualBucketButton.first().text();
161
 
162
+ if ( bucketName === $( '#' + as3cfModal.prefix + '-active-bucket' ).text() ) {
163
+ $( '.as3cf-bucket-error' ).hide();
164
+ $activeTab.addClass( 'as3cf-has-bucket' );
165
+ as3cfModal.close();
166
+ return;
167
+ }
168
+ $( '.as3cf-bucket-error' ).hide();
169
+ $manualBucketButton.text( $manualBucketButton.attr( 'data-working' ) );
170
+ $manualBucketButton.prop( 'disabled', true );
171
+
172
+ var data = {
173
+ action: as3cfModal.prefix + '-manual-save-bucket',
174
+ bucket_name: bucketName,
175
+ _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.manual_bucket
176
+ };
177
+
178
+ $.ajax( {
179
+ url: ajaxurl,
180
+ type: 'POST',
181
+ dataType: 'JSON',
182
+ data: data,
183
+ error: function( jqXHR, textStatus, errorThrown ) {
184
+ $manualBucketButton.text( originalBucketText );
185
+ showBucketError( as3cf.strings.save_bucket_error, errorThrown, 'as3cf-bucket-manual' );
186
+ },
187
+ success: function( data, textStatus, jqXHR ) {
188
+ $manualBucketButton.text( originalBucketText );
189
+ $manualBucketButton.prop( 'disabled', false );
190
+ if ( typeof data[ 'success' ] !== 'undefined' ) {
191
+ bucketSelect( bucketName, data[ 'region' ], data[ 'can_write' ] );
192
+ $( '#' + as3cfModal.prefix + '-bucket-select' ).val( 'manual' );
193
+ $( '.as3cf-bucket-list a' ).removeClass( 'selected' ).filter( '[data-bucket=' + bucketName + ']' ).addClass( 'selected' );
194
+ } else {
195
+ showBucketError( as3cf.strings.save_bucket_error, data[ 'error' ], 'as3cf-bucket-manual' );
196
+ }
197
  }
198
+ } );
199
+ }
200
+
201
+ /**
202
+ * Save select bucket
203
+ *
204
+ * @param object $link
205
+ */
206
+ function saveSelectBucket( $link ) {
207
+ var $bucketList = $( '.as3cf-bucket-list' );
208
 
209
+ if ( $link.hasClass( 'selected' ) ) {
210
+ $activeTab.addClass( 'as3cf-has-bucket' );
211
+ as3cfModal.close();
212
+ return;
213
+ }
214
 
215
+ var previousBucket = $( '.as3cf-bucket-list a.selected' ).attr( 'data-bucket' );
216
+
217
+ $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
218
+ $link.addClass( 'selected' );
219
+
220
+ $bucketList.addClass( 'saving' );
221
+ $link.find( '.spinner' ).show().css( 'visibility', 'visible' );
222
+ var bucketName = $link.attr( 'data-bucket' );
223
+
224
+ var data = {
225
+ action: as3cfModal.prefix + '-save-bucket',
226
+ bucket_name: bucketName,
227
+ _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.save_bucket
228
+ };
229
+
230
+ $.ajax( {
231
+ url: ajaxurl,
232
+ type: 'POST',
233
+ dataType: 'JSON',
234
+ data: data,
235
+ error: function( jqXHR, textStatus, errorThrown ) {
236
+ $bucketList.removeClass( 'saving' );
237
+ showBucketError( as3cf.strings.save_bucket_error, errorThrown, 'as3cf-bucket-select' );
238
+ $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
239
+ $( '.as3cf-bucket-list a[data-bucket="' + previousBucket + '"]' ).addClass( 'selected' );
240
+ },
241
+ success: function( data, textStatus, jqXHR ) {
242
+ $link.find( '.spinner' ).hide().css( 'visibility', 'hidden' );
243
+ $bucketList.removeClass( 'saving' );
244
+ if ( typeof data[ 'success' ] !== 'undefined' ) {
245
+ bucketSelect( bucketName, data[ 'region' ], data[ 'can_write' ] );
246
+ $( '#' + as3cfModal.prefix + '-bucket-select' ).val( '' );
247
+ } else {
248
+ showBucketError( as3cf.strings.save_bucket_error, data[ 'error' ], 'as3cf-bucket-select' );
249
  $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
250
+ $( '.as3cf-bucket-list a[data-bucket="' + previousBucket + '"]' ).addClass( 'selected' );
 
 
 
 
 
 
 
 
 
 
 
251
  }
252
+ }
253
  } );
254
+ }
255
+
256
+ /**
257
+ * Disable bucket buttons
258
+ */
259
+ function disableBucketButtons() {
260
+ if ( 0 === $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' ).length ) {
261
+ return;
262
+ }
263
 
264
+ var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' );
265
+ var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
 
 
266
 
267
+ if ( $createBucketForm.find( '.as3cf-bucket-name' ).val().length < 3 ) {
268
+ $createBucketForm.find( 'button[type=submit]' ).attr( 'disabled', true );
269
+ }
270
+ else {
271
+ $createBucketForm.find( 'button[type=submit]' ).attr( 'disabled', false );
272
+ }
273
 
274
+ if ( $manualBucketForm.find( '.as3cf-bucket-name' ).val().length < 3 ) {
275
+ $manualBucketForm.find( 'button[type=submit]' ).attr( 'disabled', true );
276
+ }
277
+ else {
278
+ $manualBucketForm.find( 'button[type=submit]' ).attr( 'disabled', false );
279
+ }
280
+ }
281
+
282
+ /**
283
+ * Show bucket error
284
+ *
285
+ * @param title
286
+ * @param error
287
+ * @param context
288
+ */
289
+ function showBucketError( title, error, context ) {
290
+ var $activeView = $( '.as3cf-bucket-container' ).children( ':visible' );
291
+ var $bucketError = $activeView.find( '.as3cf-bucket-error' );
292
+
293
+ context = ( 'undefined' === typeof context ) ? null : context;
294
+
295
+ if ( context && ! $activeView.hasClass( context ) ) {
296
+ return;
297
  }
298
 
299
+ $bucketError.find( 'span.title' ).html( title );
300
+ $bucketError.find( 'span.message' ).html( error );
301
+ $bucketError.show();
302
+ }
303
+
304
+ /**
305
+ * Select bucket
306
+ *
307
+ * @param string title
308
+ * @param string error
309
+ * @param bool canWrite
310
+ */
311
+ function bucketSelect( bucket, region, canWrite ) {
312
+ var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
313
+ var $activeBucket = $( '#' + as3cfModal.prefix + '-active-bucket' );
314
+
315
+ if ( 'as3cf' === as3cfModal.prefix && '' === $activeBucket.text() ) {
316
+ // first time bucket select - enable main options by default
317
+ setCheckbox( 'copy-to-s3-wrap' );
318
+ setCheckbox( 'serve-from-s3-wrap' );
319
  }
320
 
321
+ $activeBucket.text( bucket );
322
+ $manualBucketForm.find( '.as3cf-bucket-name' ).val( bucket );
323
+ $( '#' + as3cfModal.prefix + '-bucket' ).val( bucket );
324
+ $( '#' + as3cfModal.prefix + '-region' ).val( region );
325
+ $( '.updated' ).not( '.as3cf-notice' ).show();
326
+
327
+ $activeTab.addClass( 'as3cf-has-bucket' );
328
+ // check permission on bucket
329
+ $activeTab.find( '.as3cf-can-write-error' ).toggle( !canWrite );
330
+ $activeTab.find( '.as3cf-bucket-error' ).hide();
331
+
332
+ if ( 'as3cf' === as3cfModal.prefix ) {
333
+ generateUrlPreview();
334
+ }
335
+
336
+ as3cfModal.close();
337
+ }
338
+
339
+ /**
340
+ * Generate URL preview
341
+ */
342
+ function generateUrlPreview() {
343
+ $( '.as3cf-url-preview' ).html( 'Generating...' );
344
+
345
+ var data = {
346
+ _nonce: as3cf.nonces.get_url_preview
347
+ };
348
+
349
+ $.each( $( '#tab-media .as3cf-main-settings form' ).serializeArray(), function( i, o ) {
350
+ var n = o.name,
351
+ v = o.value;
352
+ n = n.replace( '[]', '' );
353
+ data[ n ] = data[ n ] === undefined ? v : $.isArray( data[ n ] ) ? data[ n ].concat( v ) : [ data[ n ], v ];
354
+ } );
355
+
356
+ // overwrite the save action stored in the form
357
+ data[ 'action' ] = 'as3cf-get-url-preview';
358
+
359
+ $.ajax( {
360
+ url: ajaxurl,
361
+ type: 'POST',
362
+ dataType: 'JSON',
363
+ data: data,
364
+ error: function( jqXHR, textStatus, errorThrown ) {
365
+ alert( as3cf.strings.get_url_preview_error + errorThrown );
366
+ },
367
+ success: function( data, textStatus, jqXHR ) {
368
+ if ( typeof data[ 'success' ] !== 'undefined' ) {
369
+ $( '.as3cf-url-preview' ).html( data[ 'url' ] );
370
+ } else {
371
+ alert( as3cf.strings.get_url_preview_error + data[ 'error' ] );
372
+ }
373
  }
374
+ } );
375
+ }
376
+
377
+ /**
378
+ * Check for a valid bucket name
379
+ *
380
+ * Bucket names must be at least 3 and no more than 63 characters long.
381
+ * They can contain lowercase letters, numbers, periods and hyphens.
382
+ *
383
+ * @param string bucketName
384
+ *
385
+ * @return bool
386
+ */
387
+ function isValidBucketName( bucketName ) {
388
+ if ( bucketName.length < 3 || bucketName.length > 63 ) {
389
+ return false;
390
+ }
391
+ if ( true === bucketNamePattern.test( bucketName ) ) {
392
+ return false;
393
  }
394
 
395
+ return true;
396
+ }
397
+
398
+ /**
399
+ * Update invalid bucket name notice
400
+ *
401
+ * @param string bucketName
402
+ */
403
+ function updateBucketNameNotice( bucketName ) {
404
+ var message = null;
405
+
406
+ if ( true === bucketNamePattern.test( bucketName ) ) {
407
+ message = as3cf.strings.create_bucket_invalid_chars;
408
+ } else if ( bucketName.length < 3 ) {
409
+ message = as3cf.strings.create_bucket_name_short;
410
+ } else if ( bucketName.length > 63 ) {
411
+ message = as3cf.strings.create_bucket_name_long;
412
+ }
413
+
414
+ if ( message && bucketName.length > 0 ) {
415
+ $( '.as3cf-invalid-bucket-name' ).html( message );
416
+ } else {
417
+ $( '.as3cf-invalid-bucket-name' ).html( '' );
418
+ }
419
+ }
420
+
421
+ /**
422
+ * Save create bucket
423
+ */
424
+ function saveCreateBucket() {
425
+ var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' );
426
+ var $createBucketInput = $createBucketForm.find( '.as3cf-bucket-name' );
427
+ var $createBucketSelect = $createBucketForm.find( '.bucket-create-region' );
428
+ var $createBucketButton = $createBucketForm.find( 'button[type=submit]' );
429
+
430
+ var bucketName = $createBucketInput.val();
431
+ var origButtonText = $createBucketButton.text();
432
+
433
+ $( '.as3cf-bucket-error' ).hide();
434
+ $createBucketButton.text( $createBucketButton.attr( 'data-working' ) );
435
+ $createBucketButton.prop( 'disabled', true );
436
+
437
+ var data = {
438
+ action: as3cfModal.prefix + '-create-bucket',
439
+ bucket_name: bucketName,
440
+ _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.create_bucket
441
+ };
442
+
443
+ if ( $createBucketSelect.val() ) {
444
+ data[ 'region' ] = $createBucketSelect.val();
445
+ }
446
+
447
+ $.ajax( {
448
+ url: ajaxurl,
449
+ type: 'POST',
450
+ dataType: 'JSON',
451
+ data: data,
452
+ error: function( jqXHR, textStatus, errorThrown ) {
453
+ $createBucketButton.text( origButtonText );
454
+ showBucketError( as3cf.strings.create_bucket_error, errorThrown, 'as3cf-bucket-create' );
455
+ },
456
+ success: function( data, textStatus, jqXHR ) {
457
+ $createBucketButton.text( origButtonText );
458
+ $createBucketButton.prop( 'disabled', false );
459
+ if ( typeof data[ 'success' ] !== 'undefined' ) {
460
+ bucketSelect( bucketName, data[ 'region' ], data[ 'can_write' ] );
461
+ // tidy up create bucket form
462
+ $( '.as3cf-bucket-select-region' ).hide();
463
+ $( '.as3cf-bucket-select-region' ).removeAttr( 'selected' );
464
+ $createBucketInput.val( '' );
465
+ $createBucketButton.attr( 'disabled', true );
466
+ } else {
467
+ showBucketError( as3cf.strings.create_bucket_error, data[ 'error' ], 'as3cf-bucket-create' );
468
+ }
469
  }
470
  } );
471
+ }
472
+
473
+ $( document ).ready( function() {
474
 
475
+ // Tabs
476
+ // --------------------
477
+
478
+ // Move any compatibility errors below the nav tabs
479
+ var $navTabs = $( '.wrap.aws-main .nav-tab-wrapper' );
480
+ $( '.aws-compatibility-notice, div.updated, div.error, div.notice' ).not( '.below-h2, .inline' ).insertAfter( $navTabs );
481
+
482
+ // check for hash in url and switch tabs accordingly
483
+ if ( window.location.hash ) {
484
+ var hash = window.location.hash.substring( 1 );
485
+ as3cf.tabs.toggle( hash, true );
486
+ } else {
487
+ // default settings tab
488
+ var defaultTab = 'media';
489
+ $activeTab = $( '#tab-' + defaultTab );
490
+ $( '.aws-main' ).attr( 'data-tab', defaultTab );
491
  }
492
 
493
+ $( '.aws-main' ).on( 'click', '.nav-tab', function( e ) {
494
+ e.preventDefault();
495
+ if ( $( this ).hasClass( 'nav-tab-active' ) ) {
496
+ return;
497
  }
498
+ var nextTab = $( this ).attr( 'data-tab' );
499
+ as3cf.tabs.toggle( nextTab );
500
+ if ( 'media' === nextTab ) {
501
+ // As it's the default remove the hash
502
+ window.location.hash = '';
503
+ if ( typeof window.history.replaceState === 'function' && '#' === window.location.href.slice( -1 ) ) {
504
+ // Strip the # if still on the end of the URL
505
+ history.replaceState( {}, '', window.location.href.slice( 0, -1 ) );
506
+ }
507
+ } else {
508
+ window.location.hash = nextTab;
509
+ }
510
+ } );
511
+
512
+ // Settings
513
+ // --------------------
514
+
515
+ // save the original state of the forms for comparison later
516
+ if ( $tabs.length ) {
517
+ $tabs.each( function( i, tab ) {
518
+ savedSettings[ tab.id ] = serializedForm( tab.id );
519
+ } );
520
  }
521
 
522
+ // prompt user with dialog if leaving the settings page with unsaved changes
523
+ $( window ).on( 'beforeunload.as3cf-settings', function() {
524
+ if ( $.isEmptyObject( savedSettings ) ) {
525
+ return;
526
+ }
527
+
528
+ var tab = $activeTab.attr( 'id' );
529
+
530
+ if ( serializedForm( tab ) !== savedSettings[ tab ] ) {
531
+ return as3cf.strings.save_alert;
532
+ }
533
  } );
534
 
535
+ // let the save settings submit happen as normal
536
+ $( document ).on( 'submit', '.as3cf-main-settings form', function( e ) {
537
+ // disable unload warning
538
+ $( window ).off( 'beforeunload.as3cf-settings' );
539
  } );
540
 
541
+ $( '.as3cf-switch' ).on( 'click', function( e ) {
542
+ if ( !$( this ).hasClass( 'disabled' ) ) {
543
+ setCheckbox( $( this ).attr( 'id' ) );
544
+ }
545
+ } );
546
+
547
+ $tabs.on( 'change', '.sub-toggle', function( e ) {
548
+ var setting = $( this ).attr( 'id' );
549
+ $( '.as3cf-setting.' + setting ).toggleClass( 'hide' );
550
  } );
551
 
552
  $( '.as3cf-domain' ).on( 'change', 'input[type="radio"]', function( e ) {
553
+ var $selected = $( this ).closest( 'input:radio[name="domain"]:checked' );
554
+ var domain = $selected.val();
555
+ var $cloudfront = $( this ).parents( '.as3cf-domain' ).find( '.as3cf-setting.cloudfront' );
556
+ var cloudfrontSelected = ( 'cloudfront' === domain );
557
+ $cloudfront.toggleClass( 'hide', !cloudfrontSelected );
 
558
  } );
559
 
560
  $( '.as3cf-ssl' ).on( 'change', 'input[type="radio"]', function( e ) {
573
  } );
574
 
575
  $( '.url-preview' ).on( 'change', 'input', function( e ) {
576
+ generateUrlPreview();
577
  } );
578
 
579
+ // Bucket select
580
+ // --------------------
581
 
582
+ // Move bucket errors
583
+ $( '#tab-media > .as3cf-bucket-error' ).detach().insertAfter( '.as3cf-bucket-container h3' );
 
584
 
585
+ // Action click handlers
586
+ $( 'body' ).on( 'click', '.bucket-action-manual', function( e ) {
587
+ e.preventDefault();
588
+ $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-manual' ).show().siblings().hide();
589
+ } );
590
+ $( 'body' ).on( 'click', '.bucket-action-browse', function( e ) {
591
+ e.preventDefault();
592
+ $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' ).show().siblings().hide();
593
 
594
+ loadBucketList();
595
+ } );
596
+ $( 'body' ).on( 'click', '.bucket-action-create', function( e ) {
597
+ e.preventDefault();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
598
 
599
+ // Reset create bucket modal
600
+ $( '.as3cf-bucket-name' ).val( '' );
601
+ $( '.as3cf-invalid-bucket-name' ).html( '' );
 
 
 
 
 
 
602
 
603
+ $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-create' ).show().siblings().hide();
604
+ } );
605
+ $( 'body' ).on( 'click', '.bucket-action-cancel', function( e ) {
606
+ e.preventDefault();
607
+ resetBucketModal();
608
+ } );
609
+ $( 'body' ).on( 'click', '.bucket-action-save', function( e ) {
610
+ e.preventDefault();
611
+ saveManualBucket();
612
+ } );
613
+ $( 'body' ).on( 'click', '.as3cf-create-bucket-form button[type="submit"]', function( e ) {
614
+ e.preventDefault();
615
+ saveCreateBucket();
616
+ } );
617
 
618
+ // Bucket list refresh handler
619
+ $( 'body' ).on( 'click', '.bucket-action-refresh', function( e ) {
620
+ e.preventDefault();
621
+ loadBucketList( true );
622
  } );
623
 
624
+ // Bucket list click handler
625
+ $( 'body' ).on( 'click', '.as3cf-bucket-list a', function( e ) {
626
+ e.preventDefault();
627
+ saveSelectBucket( $( this ) );
628
+ } );
629
+
630
+ // Modal open
631
+ $( 'body' ).on( 'as3cf-modal-open', function( e, target ) {
632
+ if ( '.as3cf-bucket-container.' + as3cfModal.prefix === target ) {
633
+ // Reset modal
634
+ resetBucketModal();
635
+ // Change manual title text
636
+ var title = $( '.as3cf-bucket-manual h3' ).data( 'modal-title' );
637
+ $( '.as3cf-bucket-manual h3' ).text( title );
638
+ // Hide buttons
639
+ disableBucketButtons();
640
+ }
641
+ } );
642
+ disableBucketButtons();
643
+
644
+ // Validate bucket name on create
645
+ $( 'body' ).on( 'input keyup', '.as3cf-create-bucket-form .as3cf-bucket-name', function( e ) {
646
+ var bucketName = $( this ).val();
647
+ var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' );
648
+
649
+ if ( isValidBucketName( bucketName ) ) {
650
+ $createBucketForm.find( 'button[type=submit]' ).removeAttr( 'disabled' );
651
+ } else {
652
+ $createBucketForm.find( 'button[type=submit]' ).attr( 'disabled', true );
653
+ }
654
+ updateBucketNameNotice( bucketName );
655
+ } );
656
+
657
+ // Check bucket name length on manual
658
+ $( 'body' ).on( 'input keyup', '.as3cf-manual-save-bucket-form .as3cf-bucket-name', function( e ) {
659
+ var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
660
+
661
+ if ( $manualBucketForm.find( '.as3cf-bucket-name' ).val().length < 3 ) {
662
+ $manualBucketForm.find( 'button[type=submit]' ).attr( 'disabled', true );
663
+ } else {
664
+ $manualBucketForm.find( 'button[type=submit]' ).removeAttr( 'disabled' );
665
  }
666
  } );
667
 
668
  } );
669
 
670
+ })( jQuery, as3cfModal );
assets/js/script.min.js CHANGED
@@ -1 +1 @@
1
- !function(a){var b;a(document).ready(function(){function c(){a(".as3cf-bucket-error").hide(),j.html('<li class="loading">'+j.attr("data-working")+"</li>");var b={action:"as3cf-get-buckets",_nonce:as3cf_i18n.get_buckets_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:b,error:function(a,b,c){j.html(""),e(as3cf_i18n.get_buckets_error,c)},success:function(b){j.html(""),"undefined"!=typeof b.success?(a(b.buckets).each(function(a,c){var d=c.Name===b.selected?"selected":"";j.append('<li><a class="'+d+'" href="#" data-bucket="'+c.Name+'"><span class="bucket"><span class="dashicons dashicons-portfolio"></span> '+c.Name+'</span><span class="spinner"></span></span></a></li>')}),d()):e(as3cf_i18n.get_buckets_error,b.error)}})}function d(){if(a(".as3cf-bucket-list a.selected").length){var b=a("ul.as3cf-bucket-list li").first().position().top+150;a("ul.as3cf-bucket-list").animate({scrollTop:a("ul.as3cf-bucket-list li a.selected").position().top-b})}}function e(b,c){a(".as3cf-bucket-error span.title").html(b),a(".as3cf-bucket-error span.message").html(c),a(".as3cf-bucket-error").show()}function f(b,c,d){""===a(".as3cf-active-bucket").text()&&(g("copy-to-s3-wrap"),g("serve-from-s3-wrap")),a(".as3cf-active-bucket").text(b),a("form.as3cf-manual-save-bucket-form .as3cf-bucket-name").val(b),a("#as3cf-bucket").val(b),a("#as3cf-region").val(c),a(".updated").not(".as3cf-notice").show(),d===!1&&a(".as3cf-can-write-error").show(),a(".as3cf-settings").addClass("as3cf-has-bucket"),h()}function g(b){a("#"+b+" span").toggleClass("checked");var c=a("#"+b+" span.on").hasClass("checked"),d=a("#"+b).data("checkbox"),e=a("input#"+d);e.attr("checked",c),e.trigger("change")}function h(){a(".as3cf-url-preview").html("Generating...");var b={_nonce:as3cf_i18n.get_url_preview_nonce};a.each(a(".as3cf-main-settings form").serializeArray(),function(c,d){var e=d.name,f=d.value;e=e.replace("[]",""),b[e]=void 0===b[e]?f:a.isArray(b[e])?b[e].concat(f):[b[e],f]}),b.action="as3cf-get-url-preview",a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:b,error:function(a,b,c){alert(as3cf_i18n.get_url_preview_error+c)},success:function(b){"undefined"!=typeof b.success?a(".as3cf-url-preview").html(b.url):alert(as3cf_i18n.get_url_preview_error+b.error)}})}function i(){return a(".as3cf-main-settings form").find("input:not(.no-compare)").serialize()}a(".as3cf-settings").each(function(){var b=a(this),d=a(".as3cf-bucket-list"),g=b.find(".as3cf-create-bucket-form"),h=b.find(".as3cf-manual-save-bucket-form");if(g.length){var i=g.find("button"),j=i.text();g.on("submit",function(b){b.preventDefault(),a(".as3cf-bucket-error").hide(),d.addClass("saving"),i.text(i.attr("data-working")),i.prop("disabled",!0);var k=g.find('input[name="bucket_name"]').val(),l={action:"as3cf-create-bucket",bucket_name:k,_nonce:as3cf_i18n.create_bucket_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:l,error:function(a,b,c){i.text(j),e(as3cf_i18n.create_bucket_error,c)},success:function(b){i.text(j),i.prop("disabled",!1),"undefined"!=typeof b.success?(f(k,b.region,b.can_write),g.find('input[name="bucket_name"]').val(""),a(".as3cf-bucket-list-wrapper").is(":visible")&&c(),a(".as3cf-bucket-list a").removeClass("selected"),d.removeClass("saving"),h.find('input[name="bucket_name"]').val(k)):e(as3cf_i18n.create_bucket_error,b.error)}})})}if(h.length){var k=h.find("button"),l=k.text();h.on("submit",function(b){b.preventDefault();var c=h.find('input[name="bucket_name"]').val();if(c===a(".as3cf-active-bucket").text())return a(".as3cf-bucket-error").hide(),void a(".as3cf-settings").addClass("as3cf-has-bucket");a(".as3cf-bucket-error").hide(),k.text(k.attr("data-working")),k.prop("disabled",!0);var d={action:"as3cf-manual-save-bucket",bucket_name:c,_nonce:as3cf_i18n.manual_bucket_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",da