aboutsummaryrefslogtreecommitdiff
path: root/mod/lightpics/views/default/js/photos/upload.php
blob: e3922c8c8d495c56ec569a9dc29b225c793676f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
 *
 */

if ($maxfilesize = (int) elgg_get_plugin_setting('maxfilesize', 'lightpics')) {
	$maxfilesize *= 1024 * 1024;
} else {
	$maxfilesize = 5 * 1024 * 1024;
}
?>

elgg.provide('elgg.tidypics.upload');

elgg.tidypics.upload.init = function() {
	
	window.locale = {
		"fileupload": {
			"error": elgg.echo('tidypics:upload:error'),
			"errors": {
				"maxFileSize": elgg.echo('tidypics:upload:maxfilesize'),
				"minFileSize": elgg.echo('tidypics:upload:minfilesize'),
				"acceptFileTypes": elgg.echo('tidypics:upload:acceptfiletypes'),
				"maxNumberOfFiles": elgg.echo('tidypics:upload:maxnumberoffiles'),
			},
		}
	};
	
	$.widget('blueimpJUI.fileupload', $.blueimpUI.fileupload, {
		_transition: function (node) {
			var that = this,
				deferred = $.Deferred();
			if (node.hasClass('fade')) {
				node.fadeToggle(function () {
					deferred.resolveWith(node);
				});
			} else {
				deferred.resolveWith(node);
			}
			return deferred;
		},
	});

	// Initialize the jQuery File Upload widget:
	$('#fileupload').fileupload();

	// Settings
	$('#fileupload').fileupload('option', {
		maxFileSize: <?php echo $maxfilesize; ?>,
		acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
		change: function() {
			elgg.tidypics.upload.fileinput.hide().appendTo($('#fileupload'));
			elgg.tidypics.upload.fileinput = $('#fileupload .elgg-input-file');
		},
		drop: function () {
			return false;
		}
	});
	
	elgg.tidypics.upload.fileinput = $('#fileupload .elgg-input-file');
};

elgg.register_hook_handler('init', 'system', elgg.tidypics.upload.init);