aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--start.php6
-rw-r--r--views/default/js/photos/upload.php61
2 files changed, 62 insertions, 5 deletions
diff --git a/start.php b/start.php
index 51cf7fa60..0b9d709f3 100644
--- a/start.php
+++ b/start.php
@@ -41,16 +41,12 @@ function tidypics_init() {
$js_base = 'mod/lightpics/vendors/jquery-file-upload/js';
- elgg_register_js('jquery-tmpl', "http://blueimp.github.com/JavaScript-Templates/tmpl.js", 'footer');
+ elgg_register_js('jquery-tmpl', "$js_base/vendor/tmpl.min.js", 'footer');
elgg_register_js('jquery-load-image', "$js_base/vendor/load-image.min.js", 'footer');
elgg_register_js('jquery-canvas-to-blob', "$js_base/vendor/canvas-to-blob.min.js", 'footer');
- elgg_register_js('jquery-image-gallery', "$js_base/vendor/jquery.image-gallery.min.js", 'footer');
- elgg_register_js('jquery-iframe-transport', "$js_base/jquery.iframe-transport.js", 'footer');
elgg_register_js('jquery-fileupload', "$js_base/jquery.fileupload.js", 'footer');
- elgg_register_js('jquery-fileupload-fp', "$js_base/jquery.fileupload-fp.js", 'footer');
elgg_register_js('jquery-fileupload-ui', "$js_base/jquery.fileupload-ui.js", 'footer');
- elgg_register_js('jquery-fileupload-jui', "$js_base/jquery.fileupload-jui.js", 'footer');
// Add photos link to owner block/hover menus
elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'tidypics_owner_block_menu');
diff --git a/views/default/js/photos/upload.php b/views/default/js/photos/upload.php
new file mode 100644
index 000000000..82e2696bd
--- /dev/null
+++ b/views/default/js/photos/upload.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ *
+ */
+
+$maxfilesize = (int) elgg_get_plugin_setting('maxfilesize', 'tidypics');
+$maxfilesize *= 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);