+ },
+
+ /**
+ * Add logic to any file upload forms to handle file size limits,
+ * on browsers that support basic FileAPI.
+ */
+ UploadForms: function () {
+ $('input[type=file]').change(function(event) {
+ if (typeof this.files == "object" && this.files.length > 0) {
+ var size = 0;
+ for (var i = 0; i < this.files.length; i++) {
+ size += this.files[i].size;
+ }
+
+ var max = SN.U.maxFileSize($(this.form));
+ if (max > 0 && size > max) {
+ var msg = 'File too large: maximum upload size is %d bytes.';
+ alert(msg.replace('%d', max));
+
+ // Clear the files.
+ $(this).val('');
+ event.preventDefault();
+ return false;
+ }
+ }
+ });