aboutsummaryrefslogtreecommitdiffstats
path: root/library/jqupload/js/jquery.fileupload-video.js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-19 14:08:21 -0800
committerfriendica <info@friendica.com>2014-01-19 14:08:21 -0800
commitf3a7bf913f3bb03c1601b105271daf77df4e3bbb (patch)
treeb7a2c2ddcf1440f2df61c5bace571a76e13e3e18 /library/jqupload/js/jquery.fileupload-video.js
parent724ad4505628d493b43b4f585512d67dc0b4ee76 (diff)
downloadvolse-hubzilla-f3a7bf913f3bb03c1601b105271daf77df4e3bbb.tar.gz
volse-hubzilla-f3a7bf913f3bb03c1601b105271daf77df4e3bbb.tar.bz2
volse-hubzilla-f3a7bf913f3bb03c1601b105271daf77df4e3bbb.zip
add the jquery file uploader. Have been suggesting this as a replacement for the valum uploaders for quite some time - as there is client resize ability and no license incompatibilities. It still requires integration.
Diffstat (limited to 'library/jqupload/js/jquery.fileupload-video.js')
-rw-r--r--library/jqupload/js/jquery.fileupload-video.js106
1 files changed, 106 insertions, 0 deletions
diff --git a/library/jqupload/js/jquery.fileupload-video.js b/library/jqupload/js/jquery.fileupload-video.js
new file mode 100644
index 000000000..3764b27a2
--- /dev/null
+++ b/library/jqupload/js/jquery.fileupload-video.js
@@ -0,0 +1,106 @@
+/*
+ * jQuery File Upload Video Preview Plugin 1.0.3
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2013, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/* jshint nomen:false */
+/* global define, window, document */
+
+(function (factory) {
+ 'use strict';
+ if (typeof define === 'function' && define.amd) {
+ // Register as an anonymous AMD module:
+ define([
+ 'jquery',
+ 'load-image',
+ './jquery.fileupload-process'
+ ], factory);
+ } else {
+ // Browser globals:
+ factory(
+ window.jQuery,
+ window.loadImage
+ );
+ }
+}(function ($, loadImage) {
+ 'use strict';
+
+ // Prepend to the default processQueue:
+ $.blueimp.fileupload.prototype.options.processQueue.unshift(
+ {
+ action: 'loadVideo',
+ // Use the action as prefix for the "@" options:
+ prefix: true,
+ fileTypes: '@',
+ maxFileSize: '@',
+ disabled: '@disableVideoPreview'
+ },
+ {
+ action: 'setVideo',
+ name: '@videoPreviewName',
+ disabled: '@disableVideoPreview'
+ }
+ );
+
+ // The File Upload Video Preview plugin extends the fileupload widget
+ // with video preview functionality:
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
+
+ options: {
+ // The regular expression for the types of video files to load,
+ // matched against the file type:
+ loadVideoFileTypes: /^video\/.*$/
+ },
+
+ _videoElement: document.createElement('video'),
+
+ processActions: {
+
+ // Loads the video file given via data.files and data.index
+ // as video element if the browser supports playing it.
+ // Accepts the options fileTypes (regular expression)
+ // and maxFileSize (integer) to limit the files to load:
+ loadVideo: function (data, options) {
+ if (options.disabled) {
+ return data;
+ }
+ var file = data.files[data.index],
+ url,
+ video;
+ if (this._videoElement.canPlayType &&
+ this._videoElement.canPlayType(file.type) &&
+ ($.type(options.maxFileSize) !== 'number' ||
+ file.size <= options.maxFileSize) &&
+ (!options.fileTypes ||
+ options.fileTypes.test(file.type))) {
+ url = loadImage.createObjectURL(file);
+ if (url) {
+ video = this._videoElement.cloneNode(false);
+ video.src = url;
+ video.controls = true;
+ data.video = video;
+ return data;
+ }
+ }
+ return data;
+ },
+
+ // Sets the video element as a property of the file object:
+ setVideo: function (data, options) {
+ if (data.video && !options.disabled) {
+ data.files[data.index][options.name || 'preview'] = data.video;
+ }
+ return data;
+ }
+
+ }
+
+ });
+
+}));