diff --git a/.gitignore b/.gitignore index 2b652019a9..25010f6c2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Created by .ignore support plugin (hsz.mobi) # IntelliJ project files .idea +.github +*.icloud out gen bin/ @@ -21,3 +23,4 @@ build/reports/project-size.txt /.php_cs.cache !/package-lock.json media/css/site/biblestudy.css +/.composer.phar.icloud diff --git a/admin/addons/servers/legacy/includes/js/Moxie.swf b/admin/addons/servers/legacy/includes/js/Moxie.swf old mode 100755 new mode 100644 index e477cf9326..ca29775a50 Binary files a/admin/addons/servers/legacy/includes/js/Moxie.swf and b/admin/addons/servers/legacy/includes/js/Moxie.swf differ diff --git a/admin/addons/servers/legacy/includes/js/Moxie.xap b/admin/addons/servers/legacy/includes/js/Moxie.xap old mode 100755 new mode 100644 index fc7fbfe4b2..70ef069dad Binary files a/admin/addons/servers/legacy/includes/js/Moxie.xap and b/admin/addons/servers/legacy/includes/js/Moxie.xap differ diff --git a/admin/addons/servers/legacy/includes/js/moxie.js b/admin/addons/servers/legacy/includes/js/moxie.js old mode 100755 new mode 100644 index 34cb2bd3e6..65f33166c5 --- a/admin/addons/servers/legacy/includes/js/moxie.js +++ b/admin/addons/servers/legacy/includes/js/moxie.js @@ -1,7 +1,7 @@ ;var MXI_DEBUG = true; /** * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill - * v1.3.4 + * v1.5.7 * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -9,8 +9,23 @@ * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing * - * Date: 2015-07-18 + * Date: 2017-11-03 */ +;(function (global, factory) { + var extract = function() { + var ctx = {}; + factory.apply(ctx, arguments); + return ctx.moxie; + }; + + if (typeof define === "function" && define.amd) { + define("moxie", [], extract); + } else if (typeof module === "object" && module.exports) { + module.exports = extract(); + } else { + global.moxie = extract(); + } +}(this || window, function() { /** * Compiled inline version. (Library mode) */ @@ -105,18 +120,23 @@ * Contributing: http://www.plupload.com/contributing */ +/** +@class moxie/core/utils/Basic +@public +@static +*/ + define('moxie/core/utils/Basic', [], function() { /** Gets the true type of the built-in object (better version of typeof). @author Angus Croll (http://javascriptweblog.wordpress.com/) @method typeOf - @for Utils @static @param {Object} o Object to check. @return {String} Object [[Class]] */ - var typeOf = function(o) { + function typeOf(o) { var undef; if (o === undef) { @@ -129,10 +149,10 @@ define('moxie/core/utils/Basic', [], function() { // the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8 return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); - }; + } /** - Extends the specified object with another object. + Extends the specified object with another object(s). @method extend @static @@ -140,24 +160,130 @@ define('moxie/core/utils/Basic', [], function() { @param {Object} [obj]* Multiple objects to extend with. @return {Object} Same as target, the extended object. */ - var extend = function(target) { + function extend() { + return merge(false, false, arguments); + } + + + /** + Extends the specified object with another object(s), but only if the property exists in the target. + + @method extendIf + @static + @param {Object} target Object to extend. + @param {Object} [obj]* Multiple objects to extend with. + @return {Object} Same as target, the extended object. + */ + function extendIf() { + return merge(true, false, arguments); + } + + + function extendImmutable() { + return merge(false, true, arguments); + } + + + function extendImmutableIf() { + return merge(true, true, arguments); + } + + + function clone(value) { + switch (typeOf(value)) { + case 'array': + return merge(false, true, [[], value]); + + case 'object': + return merge(false, true, [{}, value]); + + default: + return value; + } + } + + + function shallowCopy(obj) { + switch (typeOf(obj)) { + case 'array': + return Array.prototype.slice.call(obj); + + case 'object': + return extend({}, obj); + } + return obj; + } + + + function merge(strict, immutable, args) { var undef; + var target = args[0]; - each(arguments, function(arg, i) { + each(args, function(arg, i) { if (i > 0) { each(arg, function(value, key) { - if (value !== undef) { - if (typeOf(target[key]) === typeOf(value) && !!~inArray(typeOf(value), ['array', 'object'])) { - extend(target[key], value); - } else { - target[key] = value; - } + var isComplex = inArray(typeOf(value), ['array', 'object']) !== -1; + + if (value === undef || strict && target[key] === undef) { + return true; + } + + if (isComplex && immutable) { + value = shallowCopy(value); + } + + if (typeOf(target[key]) === typeOf(value) && isComplex) { + merge(strict, immutable, [target[key], value]); + } else { + target[key] = value; } }); } }); + return target; - }; + } + + + /** + A way to inherit one `class` from another in a consisstent way (more or less) + + @method inherit + @static + @since >1.4.1 + @param {Function} child + @param {Function} parent + @return {Function} Prepared constructor + */ + function inherit(child, parent) { + // copy over all parent properties + for (var key in parent) { + if ({}.hasOwnProperty.call(parent, key)) { + child[key] = parent[key]; + } + } + + // give child `class` a place to define its own methods + function ctor() { + this.constructor = child; + + if (MXI_DEBUG) { + var getCtorName = function(fn) { + var m = fn.toString().match(/^function\s([^\(\s]+)/); + return m ? m[1] : false; + }; + + this.ctorName = getCtorName(child); + } + } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + + // keep a way to reference parent methods + child.parent = parent.prototype; + return child; + } + /** Executes the callback function for each item in array/object. If you return false in the @@ -168,18 +294,17 @@ define('moxie/core/utils/Basic', [], function() { @param {Object} obj Object to iterate. @param {function} callback Callback function to execute for each item. */ - var each = function(obj, callback) { + function each(obj, callback) { var length, key, i, undef; if (obj) { - if (typeOf(obj.length) === 'number') { // it might be Array, FileList or even arguments object - // Loop array items - for (i = 0, length = obj.length; i < length; i++) { - if (callback(obj[i], i) === false) { - return; - } - } - } else if (typeOf(obj) === 'object') { + try { + length = obj.length; + } catch(ex) { + length = undef; + } + + if (length === undef || typeof(length) !== 'number') { // Loop object items for (key in obj) { if (obj.hasOwnProperty(key)) { @@ -188,9 +313,16 @@ define('moxie/core/utils/Basic', [], function() { } } } + } else { + // Loop array items + for (i = 0; i < length; i++) { + if (callback(obj[i], i) === false) { + return; + } + } } } - }; + } /** Checks if object is empty. @@ -200,7 +332,7 @@ define('moxie/core/utils/Basic', [], function() { @param {Object} o Object to check. @return {Boolean} */ - var isEmptyObj = function(obj) { + function isEmptyObj(obj) { var prop; if (!obj || typeOf(obj) !== 'object') { @@ -212,7 +344,7 @@ define('moxie/core/utils/Basic', [], function() { } return true; - }; + } /** Recieve an array of functions (usually async) to call in sequence, each function @@ -226,7 +358,7 @@ define('moxie/core/utils/Basic', [], function() { @param {Array} queue Array of functions to call in sequence @param {Function} cb Main callback that is called in the end, or in case of error */ - var inSeries = function(queue, cb) { + function inSeries(queue, cb) { var i = 0, length = queue.length; if (typeOf(cb) !== 'function') { @@ -246,7 +378,7 @@ define('moxie/core/utils/Basic', [], function() { } } callNext(i); - }; + } /** @@ -259,9 +391,9 @@ define('moxie/core/utils/Basic', [], function() { @method inParallel @static @param {Array} queue Array of functions to call in sequence - @param {Function} cb Main callback that is called in the end, or in case of error + @param {Function} cb Main callback that is called in the end, or in case of erro */ - var inParallel = function(queue, cb) { + function inParallel(queue, cb) { var count = 0, num = queue.length, cbArgs = new Array(num); each(queue, function(fn, i) { @@ -282,7 +414,7 @@ define('moxie/core/utils/Basic', [], function() { } }); }); - }; + } /** @@ -294,7 +426,7 @@ define('moxie/core/utils/Basic', [], function() { @param {Array} array @return {Int} Index of the element, or -1 if not found */ - var inArray = function(needle, array) { + function inArray(needle, array) { if (array) { if (Array.prototype.indexOf) { return Array.prototype.indexOf.call(array, needle); @@ -307,7 +439,7 @@ define('moxie/core/utils/Basic', [], function() { } } return -1; - }; + } /** @@ -319,7 +451,7 @@ define('moxie/core/utils/Basic', [], function() { @param {Array} array @return {Array|Boolean} */ - var arrayDiff = function(needles, array) { + function arrayDiff(needles, array) { var diff = []; if (typeOf(needles) !== 'array') { @@ -336,7 +468,7 @@ define('moxie/core/utils/Basic', [], function() { } } return diff.length ? diff : false; - }; + } /** @@ -348,7 +480,7 @@ define('moxie/core/utils/Basic', [], function() { @param {Array} array2 @return {Array} Intersection of two arrays or null if there is none */ - var arrayIntersect = function(array1, array2) { + function arrayIntersect(array1, array2) { var result = []; each(array1, function(item) { if (inArray(item, array2) !== -1) { @@ -356,7 +488,7 @@ define('moxie/core/utils/Basic', [], function() { } }); return result.length ? result : null; - }; + } /** @@ -367,7 +499,7 @@ define('moxie/core/utils/Basic', [], function() { @param {Object} obj Object with length field. @return {Array} Array object containing all items. */ - var toArray = function(obj) { + function toArray(obj) { var i, arr = []; for (i = 0; i < obj.length; i++) { @@ -375,7 +507,7 @@ define('moxie/core/utils/Basic', [], function() { } return arr; - }; + } /** @@ -413,12 +545,12 @@ define('moxie/core/utils/Basic', [], function() { @param {String} str @return {String} */ - var trim = function(str) { + function trim(str) { if (!str) { return str; } return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, ''); - }; + } /** @@ -429,7 +561,7 @@ define('moxie/core/utils/Basic', [], function() { @param {String/Number} size String to parse or number to just pass through. @return {Number} Size in bytes. */ - var parseSizeStr = function(size) { + function parseSizeStr(size) { if (typeof(size) !== 'string') { return size; } @@ -442,7 +574,6 @@ define('moxie/core/utils/Basic', [], function() { }, mul; - size = /^([0-9\.]+)([tmgk]?)$/.exec(size.toLowerCase().replace(/[^0-9\.tmkg]/g, '')); mul = size[2]; size = +size[1]; @@ -451,7 +582,7 @@ define('moxie/core/utils/Basic', [], function() { size *= muls[mul]; } return Math.floor(size); - }; + } /** @@ -460,20 +591,50 @@ define('moxie/core/utils/Basic', [], function() { * @param {String} str String with tokens * @return {String} String with replaced tokens */ - var sprintf = function(str) { + function sprintf(str) { var args = [].slice.call(arguments, 1); - return str.replace(/%[a-z]/g, function() { + return str.replace(/%([a-z])/g, function($0, $1) { var value = args.shift(); - return typeOf(value) !== 'undefined' ? value : ''; + + switch ($1) { + case 's': + return value + ''; + + case 'd': + return parseInt(value, 10); + + case 'f': + return parseFloat(value); + + case 'c': + return ''; + + default: + return value; + } }); - }; + } + + + + function delay(cb, timeout) { + var self = this; + setTimeout(function() { + cb.call(self); + }, timeout || 1); + } return { guid: guid, typeOf: typeOf, extend: extend, + extendIf: extendIf, + extendImmutable: extendImmutable, + extendImmutableIf: extendImmutableIf, + clone: clone, + inherit: inherit, each: each, isEmptyObj: isEmptyObj, inSeries: inSeries, @@ -484,14 +645,15 @@ define('moxie/core/utils/Basic', [], function() { toArray: toArray, trim: trim, sprintf: sprintf, - parseSizeStr: parseSizeStr + parseSizeStr: parseSizeStr, + delay: delay }; }); -// Included from: src/javascript/core/utils/Env.js +// Included from: src/javascript/core/utils/Encode.js /** - * Env.js + * Encode.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -500,71 +662,262 @@ define('moxie/core/utils/Basic', [], function() { * Contributing: http://www.plupload.com/contributing */ -define("moxie/core/utils/Env", [ - "moxie/core/utils/Basic" -], function(Basic) { +/** +@class moxie/core/utils/Encode +@public +@static +*/ - /** - * UAParser.js v0.7.7 - * Lightweight JavaScript-based User-Agent string parser - * https://github.com/faisalman/ua-parser-js - * - * Copyright © 2012-2015 Faisal Salman - * Dual licensed under GPLv2 & MIT - */ - var UAParser = (function (undefined) { +define('moxie/core/utils/Encode', [], function() { - ////////////// - // Constants - ///////////// + /** + Encode string with UTF-8 + @method utf8_encode + @static + @param {String} str String to encode + @return {String} UTF-8 encoded string + */ + var utf8_encode = function(str) { + return unescape(encodeURIComponent(str)); + }; + + /** + Decode UTF-8 encoded string - var EMPTY = '', - UNKNOWN = '?', - FUNC_TYPE = 'function', - UNDEF_TYPE = 'undefined', - OBJ_TYPE = 'object', - MAJOR = 'major', - MODEL = 'model', - NAME = 'name', - TYPE = 'type', - VENDOR = 'vendor', - VERSION = 'version', - ARCHITECTURE= 'architecture', - CONSOLE = 'console', - MOBILE = 'mobile', - TABLET = 'tablet'; + @method utf8_decode + @static + @param {String} str String to decode + @return {String} Decoded string + */ + var utf8_decode = function(str_data) { + return decodeURIComponent(escape(str_data)); + }; + + /** + Decode Base64 encoded string (uses browser's default method if available), + from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js + @method atob + @static + @param {String} data String to decode + @return {String} Decoded string + */ + var atob = function(data, utf8) { + if (typeof(window.atob) === 'function') { + return utf8 ? utf8_decode(window.atob(data)) : window.atob(data); + } - /////////// - // Helper - ////////// + // http://kevin.vanzonneveld.net + // + original by: Tyler Akins (http://rumkin.com) + // + improved by: Thunder.m + // + input by: Aman Gupta + // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + bugfixed by: Onno Marsman + // + bugfixed by: Pellentesque Malesuada + // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + input by: Brett Zamir (http://brett-zamir.me) + // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA=='); + // * returns 1: 'Kevin van Zonneveld' + // mozilla has this native + // - but breaks in 2.0.0.12! + //if (typeof this.window.atob == 'function') { + // return atob(data); + //} + var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, + ac = 0, + dec = "", + tmp_arr = []; + if (!data) { + return data; + } - var util = { - has : function (str1, str2) { - return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; - }, - lowerize : function (str) { - return str.toLowerCase(); - } - }; + data += ''; + do { // unpack four hexets into three octets using index points in b64 + h1 = b64.indexOf(data.charAt(i++)); + h2 = b64.indexOf(data.charAt(i++)); + h3 = b64.indexOf(data.charAt(i++)); + h4 = b64.indexOf(data.charAt(i++)); - /////////////// - // Map helper - ////////////// + bits = h1 << 18 | h2 << 12 | h3 << 6 | h4; + o1 = bits >> 16 & 0xff; + o2 = bits >> 8 & 0xff; + o3 = bits & 0xff; - var mapper = { + if (h3 == 64) { + tmp_arr[ac++] = String.fromCharCode(o1); + } else if (h4 == 64) { + tmp_arr[ac++] = String.fromCharCode(o1, o2); + } else { + tmp_arr[ac++] = String.fromCharCode(o1, o2, o3); + } + } while (i < data.length); - rgx : function () { + dec = tmp_arr.join(''); - // loop through all regexes maps - for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) { + return utf8 ? utf8_decode(dec) : dec; + }; + + /** + Base64 encode string (uses browser's default method if available), + from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js - var regex = args[i], // even sequence (0,2,4,..) - props = args[i + 1]; // odd sequence (1,3,5,..) + @method btoa + @static + @param {String} data String to encode + @return {String} Base64 encoded string + */ + var btoa = function(data, utf8) { + if (utf8) { + data = utf8_encode(data); + } + + if (typeof(window.btoa) === 'function') { + return window.btoa(data); + } + + // http://kevin.vanzonneveld.net + // + original by: Tyler Akins (http://rumkin.com) + // + improved by: Bayron Guevara + // + improved by: Thunder.m + // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + bugfixed by: Pellentesque Malesuada + // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + improved by: Rafał Kukawski (http://kukawski.pl) + // * example 1: base64_encode('Kevin van Zonneveld'); + // * returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA==' + // mozilla has this native + // - but breaks in 2.0.0.12! + var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, + ac = 0, + enc = "", + tmp_arr = []; + + if (!data) { + return data; + } + + do { // pack three octets into four hexets + o1 = data.charCodeAt(i++); + o2 = data.charCodeAt(i++); + o3 = data.charCodeAt(i++); + + bits = o1 << 16 | o2 << 8 | o3; + + h1 = bits >> 18 & 0x3f; + h2 = bits >> 12 & 0x3f; + h3 = bits >> 6 & 0x3f; + h4 = bits & 0x3f; + + // use hexets to index into b64, and append result to encoded string + tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4); + } while (i < data.length); + + enc = tmp_arr.join(''); + + var r = data.length % 3; + + return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3); + }; + + + return { + utf8_encode: utf8_encode, + utf8_decode: utf8_decode, + atob: atob, + btoa: btoa + }; +}); + +// Included from: src/javascript/core/utils/Env.js + +/** + * Env.js + * + * Copyright 2013, Moxiecode Systems AB + * Released under GPL License. + * + * License: http://www.plupload.com/license + * Contributing: http://www.plupload.com/contributing + */ + +/** +@class moxie/core/utils/Env +@public +@static +*/ + +define("moxie/core/utils/Env", [ + "moxie/core/utils/Basic" +], function(Basic) { + + /** + * UAParser.js v0.7.7 + * Lightweight JavaScript-based User-Agent string parser + * https://github.com/faisalman/ua-parser-js + * + * Copyright © 2012-2015 Faisal Salman + * Dual licensed under GPLv2 & MIT + */ + var UAParser = (function (undefined) { + + ////////////// + // Constants + ///////////// + + + var EMPTY = '', + UNKNOWN = '?', + FUNC_TYPE = 'function', + UNDEF_TYPE = 'undefined', + OBJ_TYPE = 'object', + MAJOR = 'major', + MODEL = 'model', + NAME = 'name', + TYPE = 'type', + VENDOR = 'vendor', + VERSION = 'version', + ARCHITECTURE= 'architecture', + CONSOLE = 'console', + MOBILE = 'mobile', + TABLET = 'tablet'; + + + /////////// + // Helper + ////////// + + + var util = { + has : function (str1, str2) { + return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; + }, + lowerize : function (str) { + return str.toLowerCase(); + } + }; + + + /////////////// + // Map helper + ////////////// + + + var mapper = { + + rgx : function () { + + // loop through all regexes maps + for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) { + + var regex = args[i], // even sequence (0,2,4,..) + props = args[i + 1]; // odd sequence (1,3,5,..) // construct object barebones if (typeof(result) === UNDEF_TYPE) { @@ -1041,85 +1394,119 @@ define("moxie/core/utils/Env", [ var can = (function() { var caps = { - define_property: (function() { - /* // currently too much extra code required, not exactly worth it - try { // as of IE8, getters/setters are supported only on DOM elements - var obj = {}; - if (Object.defineProperty) { - Object.defineProperty(obj, 'prop', { - enumerable: true, - configurable: true - }); - return true; - } - } catch(ex) {} - - if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { + access_global_ns: function () { + return !!window.moxie; + }, + + define_property: (function() { + /* // currently too much extra code required, not exactly worth it + try { // as of IE8, getters/setters are supported only on DOM elements + var obj = {}; + if (Object.defineProperty) { + Object.defineProperty(obj, 'prop', { + enumerable: true, + configurable: true + }); return true; - }*/ - return false; - }()), + } + } catch(ex) {} - create_canvas: (function() { - // On the S60 and BB Storm, getContext exists, but always returns undefined - // so we actually have to call getContext() to verify - // github.com/Modernizr/Modernizr/issues/issue/97/ - var el = document.createElement('canvas'); - return !!(el.getContext && el.getContext('2d')); - }()), + if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { + return true; + }*/ + return false; + }()), - return_response_type: function(responseType) { - try { - if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) { - return true; - } else if (window.XMLHttpRequest) { - var xhr = new XMLHttpRequest(); - xhr.open('get', '/'); // otherwise Gecko throws an exception - if ('responseType' in xhr) { - xhr.responseType = responseType; - // as of 23.0.1271.64, Chrome switched from throwing exception to merely logging it to the console (why? o why?) - if (xhr.responseType !== responseType) { - return false; - } - return true; + create_canvas: function() { + // On the S60 and BB Storm, getContext exists, but always returns undefined + // so we actually have to call getContext() to verify + // github.com/Modernizr/Modernizr/issues/issue/97/ + var el = document.createElement('canvas'); + var isSupported = !!(el.getContext && el.getContext('2d')); + caps.create_canvas = isSupported; + return isSupported; + }, + + return_response_type: function(responseType) { + try { + if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) { + return true; + } else if (window.XMLHttpRequest) { + var xhr = new XMLHttpRequest(); + xhr.open('get', '/'); // otherwise Gecko throws an exception + if ('responseType' in xhr) { + xhr.responseType = responseType; + // as of 23.0.1271.64, Chrome switched from throwing exception to merely logging it to the console (why? o why?) + if (xhr.responseType !== responseType) { + return false; } + return true; } - } catch (ex) {} - return false; - }, + } + } catch (ex) {} + return false; + }, - // ideas for this heavily come from Modernizr (http://modernizr.com/) - use_data_uri: (function() { - var du = new Image(); + use_blob_uri: function() { + var URL = window.URL; + caps.use_blob_uri = (URL && + 'createObjectURL' in URL && + 'revokeObjectURL' in URL && + (Env.browser !== 'IE' || Env.verComp(Env.version, '11.0.46', '>=')) // IE supports createObjectURL, but not fully, for example it fails to use it as a src for the image + ); + return caps.use_blob_uri; + }, - du.onload = function() { - caps.use_data_uri = (du.width === 1 && du.height === 1); - }; + // ideas for this heavily come from Modernizr (http://modernizr.com/) + use_data_uri: (function() { + var du = new Image(); - setTimeout(function() { - du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="; - }, 1); - return false; - }()), + du.onload = function() { + caps.use_data_uri = (du.width === 1 && du.height === 1); + }; - use_data_uri_over32kb: function() { // IE8 - return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9); - }, + setTimeout(function() { + du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="; + }, 1); + return false; + }()), - use_data_uri_of: function(bytes) { - return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb()); - }, + use_data_uri_over32kb: function() { // IE8 + return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9); + }, - use_fileinput: function() { - if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) { - return false; - } + use_data_uri_of: function(bytes) { + return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb()); + }, - var el = document.createElement('input'); - el.setAttribute('type', 'file'); - return !el.disabled; + use_fileinput: function() { + if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) { + return false; } - }; + + var el = document.createElement('input'); + el.setAttribute('type', 'file'); + return caps.use_fileinput = !el.disabled; + }, + + use_webgl: function() { + var canvas = document.createElement('canvas'); + var gl = null, isSupported; + try { + gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); + } + catch(e) {} + + if (!gl) { // it seems that sometimes it doesn't throw exception, but still fails to get context + gl = null; + } + + isSupported = !!gl; + caps.use_webgl = isSupported; // save result of our check + canvas = undefined; + return isSupported; + } + }; return function(cap) { var args = [].slice.call(arguments); @@ -1162,17 +1549,13 @@ define("moxie/core/utils/Env", [ Env.log = function() { function logObj(data) { + // TODO: this should recursively print out the object in a pretty way console.appendChild(document.createTextNode(data + "\n")); } - var data = arguments[0]; - - if (Basic.typeOf(data) === 'string') { - data = Basic.sprintf.apply(this, arguments); - } - - if (window && window.console && window.console.log) { - window.console.log(data); + // if debugger present, IE8 might have window.console.log method, but not be able to apply on it (why...) + if (window && window.console && window.console.log && window.console.log.apply) { + window.console.log.apply(window.console, arguments); } else if (document) { var console = document.getElementById('moxie-console'); if (!console) { @@ -1182,11 +1565,15 @@ define("moxie/core/utils/Env", [ document.body.appendChild(console); } - if (Basic.inArray(Basic.typeOf(data), ['object', 'array']) !== -1) { + var data = arguments[0]; + if (Basic.typeOf(data) === 'string') { + data = Basic.sprintf.apply(this, arguments); + } else if (Basic.inArray(Basic.typeOf(data), ['object', 'array']) !== -1) { logObj(data); - } else { - console.appendChild(document.createTextNode(data + "\n")); + return; } + + console.appendChild(document.createTextNode(data + "\n")); } }; } @@ -1194,10 +1581,10 @@ define("moxie/core/utils/Env", [ return Env; }); -// Included from: src/javascript/core/I18n.js +// Included from: src/javascript/core/Exceptions.js /** - * I18n.js + * Exceptions.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -1206,252 +1593,156 @@ define("moxie/core/utils/Env", [ * Contributing: http://www.plupload.com/contributing */ -define("moxie/core/I18n", [ - "moxie/core/utils/Basic" +define('moxie/core/Exceptions', [ + 'moxie/core/utils/Basic' ], function(Basic) { - var i18n = {}; + + function _findKey(obj, value) { + var key; + for (key in obj) { + if (obj[key] === value) { + return key; + } + } + return null; + } + /** + @class moxie/core/Exception + */ return { - /** - * Extends the language pack object with new items. - * - * @param {Object} pack Language pack items to add. - * @return {Object} Extended language pack object. - */ - addI18n: function(pack) { - return Basic.extend(i18n, pack); - }, + RuntimeError: (function() { + var namecodes = { + NOT_INIT_ERR: 1, + EXCEPTION_ERR: 3, + NOT_SUPPORTED_ERR: 9, + JS_ERR: 4 + }; - /** - * Translates the specified string by checking for the english string in the language pack lookup. - * - * @param {String} str String to look for. - * @return {String} Translated string or the input string if it wasn't found. - */ - translate: function(str) { - return i18n[str] || str; - }, - - /** - * Shortcut for translate function - * - * @param {String} str String to look for. - * @return {String} Translated string or the input string if it wasn't found. - */ - _: function(str) { - return this.translate(str); - }, - - /** - * Pseudo sprintf implementation - simple way to replace tokens with specified values. - * - * @param {String} str String with tokens - * @return {String} String with replaced tokens - */ - sprintf: function(str) { - var args = [].slice.call(arguments, 1); - - return str.replace(/%[a-z]/g, function() { - var value = args.shift(); - return Basic.typeOf(value) !== 'undefined' ? value : ''; - }); - } - }; -}); - -// Included from: src/javascript/core/utils/Mime.js - -/** - * Mime.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -define("moxie/core/utils/Mime", [ - "moxie/core/utils/Basic", - "moxie/core/I18n" -], function(Basic, I18n) { - - var mimeData = "" + - "application/msword,doc dot," + - "application/pdf,pdf," + - "application/pgp-signature,pgp," + - "application/postscript,ps ai eps," + - "application/rtf,rtf," + - "application/vnd.ms-excel,xls xlb," + - "application/vnd.ms-powerpoint,ppt pps pot," + - "application/zip,zip," + - "application/x-shockwave-flash,swf swfl," + - "application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," + - "application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," + - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," + - "application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," + - "application/vnd.openxmlformats-officedocument.presentationml.template,potx," + - "application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," + - "application/x-javascript,js," + - "application/json,json," + - "audio/mpeg,mp3 mpga mpega mp2," + - "audio/x-wav,wav," + - "audio/x-m4a,m4a," + - "audio/ogg,oga ogg," + - "audio/aiff,aiff aif," + - "audio/flac,flac," + - "audio/aac,aac," + - "audio/ac3,ac3," + - "audio/x-ms-wma,wma," + - "image/bmp,bmp," + - "image/gif,gif," + - "image/jpeg,jpg jpeg jpe," + - "image/photoshop,psd," + - "image/png,png," + - "image/svg+xml,svg svgz," + - "image/tiff,tiff tif," + - "text/plain,asc txt text diff log," + - "text/html,htm html xhtml," + - "text/css,css," + - "text/csv,csv," + - "text/rtf,rtf," + - "video/mpeg,mpeg mpg mpe m2v," + - "video/quicktime,qt mov," + - "video/mp4,mp4," + - "video/x-m4v,m4v," + - "video/x-flv,flv," + - "video/x-ms-wmv,wmv," + - "video/avi,avi," + - "video/webm,webm," + - "video/3gpp,3gpp 3gp," + - "video/3gpp2,3g2," + - "video/vnd.rn-realvideo,rv," + - "video/ogg,ogv," + - "video/x-matroska,mkv," + - "application/vnd.oasis.opendocument.formula-template,otf," + - "application/octet-stream,exe"; - - - var Mime = { - - mimes: {}, - - extensions: {}, - - // Parses the default mime types string into a mimes and extensions lookup maps - addMimeType: function (mimeData) { - var items = mimeData.split(/,/), i, ii, ext; - - for (i = 0; i < items.length; i += 2) { - ext = items[i + 1].split(/ /); - - // extension to mime lookup - for (ii = 0; ii < ext.length; ii++) { - this.mimes[ext[ii]] = items[i]; - } - // mime to extension lookup - this.extensions[items[i]] = ext; + function RuntimeError(code, message) { + this.code = code; + this.name = _findKey(namecodes, code); + this.message = this.name + (message || ": RuntimeError " + this.code); } - }, - - - extList2mimes: function (filters, addMissingExtensions) { - var self = this, ext, i, ii, type, mimes = []; - - // convert extensions to mime types list - for (i = 0; i < filters.length; i++) { - ext = filters[i].extensions.split(/\s*,\s*/); - - for (ii = 0; ii < ext.length; ii++) { - - // if there's an asterisk in the list, then accept attribute is not required - if (ext[ii] === '*') { - return []; - } - - type = self.mimes[ext[ii]]; - if (type && Basic.inArray(type, mimes) === -1) { - mimes.push(type); - } - - // future browsers should filter by extension, finally - if (addMissingExtensions && /^\w+$/.test(ext[ii])) { - mimes.push('.' + ext[ii]); - } else if (!type) { - // if we have no type in our map, then accept all - return []; - } - } + + Basic.extend(RuntimeError, namecodes); + RuntimeError.prototype = Error.prototype; + return RuntimeError; + }()), + + OperationNotAllowedException: (function() { + + function OperationNotAllowedException(code) { + this.code = code; + this.name = 'OperationNotAllowedException'; } - return mimes; - }, - - - mimes2exts: function(mimes) { - var self = this, exts = []; - - Basic.each(mimes, function(mime) { - if (mime === '*') { - exts = []; - return false; - } - - // check if this thing looks like mime type - var m = mime.match(/^(\w+)\/(\*|\w+)$/); - if (m) { - if (m[2] === '*') { - // wildcard mime type detected - Basic.each(self.extensions, function(arr, mime) { - if ((new RegExp('^' + m[1] + '/')).test(mime)) { - [].push.apply(exts, self.extensions[mime]); - } - }); - } else if (self.extensions[mime]) { - [].push.apply(exts, self.extensions[mime]); - } - } + + Basic.extend(OperationNotAllowedException, { + NOT_ALLOWED_ERR: 1 }); - return exts; - }, - + + OperationNotAllowedException.prototype = Error.prototype; + + return OperationNotAllowedException; + }()), - mimes2extList: function(mimes) { - var accept = [], exts = []; + ImageError: (function() { + var namecodes = { + WRONG_FORMAT: 1, + MAX_RESOLUTION_ERR: 2, + INVALID_META_ERR: 3 + }; - if (Basic.typeOf(mimes) === 'string') { - mimes = Basic.trim(mimes).split(/\s*,\s*/); + function ImageError(code) { + this.code = code; + this.name = _findKey(namecodes, code); + this.message = this.name + ": ImageError " + this.code; } + + Basic.extend(ImageError, namecodes); + ImageError.prototype = Error.prototype; - exts = this.mimes2exts(mimes); - - accept.push({ - title: I18n.translate('Files'), - extensions: exts.length ? exts.join(',') : '*' - }); - - // save original mimes string - accept.mimes = mimes; - - return accept; - }, + return ImageError; + }()), + FileException: (function() { + var namecodes = { + NOT_FOUND_ERR: 1, + SECURITY_ERR: 2, + ABORT_ERR: 3, + NOT_READABLE_ERR: 4, + ENCODING_ERR: 5, + NO_MODIFICATION_ALLOWED_ERR: 6, + INVALID_STATE_ERR: 7, + SYNTAX_ERR: 8 + }; - getFileExtension: function(fileName) { - var matches = fileName && fileName.match(/\.([^.]+)$/); - if (matches) { - return matches[1].toLowerCase(); + function FileException(code) { + this.code = code; + this.name = _findKey(namecodes, code); + this.message = this.name + ": FileException " + this.code; } - return ''; - }, + + Basic.extend(FileException, namecodes); + FileException.prototype = Error.prototype; + return FileException; + }()), + + DOMException: (function() { + var namecodes = { + INDEX_SIZE_ERR: 1, + DOMSTRING_SIZE_ERR: 2, + HIERARCHY_REQUEST_ERR: 3, + WRONG_DOCUMENT_ERR: 4, + INVALID_CHARACTER_ERR: 5, + NO_DATA_ALLOWED_ERR: 6, + NO_MODIFICATION_ALLOWED_ERR: 7, + NOT_FOUND_ERR: 8, + NOT_SUPPORTED_ERR: 9, + INUSE_ATTRIBUTE_ERR: 10, + INVALID_STATE_ERR: 11, + SYNTAX_ERR: 12, + INVALID_MODIFICATION_ERR: 13, + NAMESPACE_ERR: 14, + INVALID_ACCESS_ERR: 15, + VALIDATION_ERR: 16, + TYPE_MISMATCH_ERR: 17, + SECURITY_ERR: 18, + NETWORK_ERR: 19, + ABORT_ERR: 20, + URL_MISMATCH_ERR: 21, + QUOTA_EXCEEDED_ERR: 22, + TIMEOUT_ERR: 23, + INVALID_NODE_TYPE_ERR: 24, + DATA_CLONE_ERR: 25 + }; - getFileMime: function(fileName) { - return this.mimes[this.getFileExtension(fileName)] || ''; - } + function DOMException(code) { + this.code = code; + this.name = _findKey(namecodes, code); + this.message = this.name + ": DOMException " + this.code; + } + + Basic.extend(DOMException, namecodes); + DOMException.prototype = Error.prototype; + return DOMException; + }()), + + EventException: (function() { + function EventException(code) { + this.code = code; + this.name = 'EventException'; + } + + Basic.extend(EventException, { + UNSPECIFIED_EVENT_TYPE_ERR: 0 + }); + + EventException.prototype = Error.prototype; + + return EventException; + }()) }; - - Mime.addMimeType(mimeData); - - return Mime; }); // Included from: src/javascript/core/utils/Dom.js @@ -1466,13 +1757,18 @@ define("moxie/core/utils/Mime", [ * Contributing: http://www.plupload.com/contributing */ +/** +@class moxie/core/utils/Dom +@public +@static +*/ + define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) { /** Get DOM Element by it's id. @method get - @for Utils @param {String} id Identifier of the DOM Element @return {DOMElement} */ @@ -1637,10 +1933,10 @@ define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) { }; }); -// Included from: src/javascript/core/Exceptions.js +// Included from: src/javascript/core/EventTarget.js /** - * Exceptions.js + * EventTarget.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -1649,456 +1945,334 @@ define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) { * Contributing: http://www.plupload.com/contributing */ -define('moxie/core/Exceptions', [ +define('moxie/core/EventTarget', [ + 'moxie/core/utils/Env', + 'moxie/core/Exceptions', 'moxie/core/utils/Basic' -], function(Basic) { - function _findKey(obj, value) { - var key; - for (key in obj) { - if (obj[key] === value) { - return key; - } - } - return null; +], function(Env, x, Basic) { + + // hash of event listeners by object uid + var eventpool = {}; + + /** + Parent object for all event dispatching components and objects + + @class moxie/core/EventTarget + @constructor EventTarget + */ + function EventTarget() { + /** + Unique id of the event dispatcher, usually overriden by children + + @property uid + @type String + */ + this.uid = Basic.guid(); } - return { - RuntimeError: (function() { - var namecodes = { - NOT_INIT_ERR: 1, - NOT_SUPPORTED_ERR: 9, - JS_ERR: 4 - }; - function RuntimeError(code) { - this.code = code; - this.name = _findKey(namecodes, code); - this.message = this.name + ": RuntimeError " + this.code; + Basic.extend(EventTarget.prototype, { + + /** + Can be called from within a child in order to acquire uniqie id in automated manner + + @method init + */ + init: function() { + if (!this.uid) { + this.uid = Basic.guid('uid_'); } + }, - Basic.extend(RuntimeError, namecodes); - RuntimeError.prototype = Error.prototype; - return RuntimeError; - }()), + /** + Register a handler to a specific event dispatched by the object - OperationNotAllowedException: (function() { + @method addEventListener + @param {String} type Type or basically a name of the event to subscribe to + @param {Function} fn Callback function that will be called when event happens + @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first + @param {Object} [scope=this] A scope to invoke event handler in + */ + addEventListener: function(type, fn, priority, scope) { + var self = this, list; - function OperationNotAllowedException(code) { - this.code = code; - this.name = 'OperationNotAllowedException'; + // without uid no event handlers can be added, so make sure we got one + if (!this.hasOwnProperty('uid')) { + this.uid = Basic.guid('uid_'); } - Basic.extend(OperationNotAllowedException, { - NOT_ALLOWED_ERR: 1 - }); + type = Basic.trim(type); - OperationNotAllowedException.prototype = Error.prototype; + if (/\s/.test(type)) { + // multiple event types were passed for one handler + Basic.each(type.split(/\s+/), function(type) { + self.addEventListener(type, fn, priority, scope); + }); + return; + } - return OperationNotAllowedException; - }()), + type = type.toLowerCase(); + priority = parseInt(priority, 10) || 0; - ImageError: (function() { - var namecodes = { - WRONG_FORMAT: 1, - MAX_RESOLUTION_ERR: 2, - INVALID_META_ERR: 3 - }; + list = eventpool[this.uid] && eventpool[this.uid][type] || []; + list.push({fn : fn, priority : priority, scope : scope || this}); - function ImageError(code) { - this.code = code; - this.name = _findKey(namecodes, code); - this.message = this.name + ": ImageError " + this.code; + if (!eventpool[this.uid]) { + eventpool[this.uid] = {}; } + eventpool[this.uid][type] = list; + }, - Basic.extend(ImageError, namecodes); - ImageError.prototype = Error.prototype; + /** + Check if any handlers were registered to the specified event - return ImageError; - }()), + @method hasEventListener + @param {String} [type] Type or basically a name of the event to check + @return {Mixed} Returns a handler if it was found and false, if - not + */ + hasEventListener: function(type) { + var list; + if (type) { + type = type.toLowerCase(); + list = eventpool[this.uid] && eventpool[this.uid][type]; + } else { + list = eventpool[this.uid]; + } + return list ? list : false; + }, - FileException: (function() { - var namecodes = { - NOT_FOUND_ERR: 1, - SECURITY_ERR: 2, - ABORT_ERR: 3, - NOT_READABLE_ERR: 4, - ENCODING_ERR: 5, - NO_MODIFICATION_ALLOWED_ERR: 6, - INVALID_STATE_ERR: 7, - SYNTAX_ERR: 8 - }; + /** + Unregister the handler from the event, or if former was not specified - unregister all handlers - function FileException(code) { - this.code = code; - this.name = _findKey(namecodes, code); - this.message = this.name + ": FileException " + this.code; + @method removeEventListener + @param {String} type Type or basically a name of the event + @param {Function} [fn] Handler to unregister + */ + removeEventListener: function(type, fn) { + var self = this, list, i; + + type = type.toLowerCase(); + + if (/\s/.test(type)) { + // multiple event types were passed for one handler + Basic.each(type.split(/\s+/), function(type) { + self.removeEventListener(type, fn); + }); + return; } - Basic.extend(FileException, namecodes); - FileException.prototype = Error.prototype; - return FileException; - }()), + list = eventpool[this.uid] && eventpool[this.uid][type]; - DOMException: (function() { - var namecodes = { - INDEX_SIZE_ERR: 1, - DOMSTRING_SIZE_ERR: 2, - HIERARCHY_REQUEST_ERR: 3, - WRONG_DOCUMENT_ERR: 4, - INVALID_CHARACTER_ERR: 5, - NO_DATA_ALLOWED_ERR: 6, - NO_MODIFICATION_ALLOWED_ERR: 7, - NOT_FOUND_ERR: 8, - NOT_SUPPORTED_ERR: 9, - INUSE_ATTRIBUTE_ERR: 10, - INVALID_STATE_ERR: 11, - SYNTAX_ERR: 12, - INVALID_MODIFICATION_ERR: 13, - NAMESPACE_ERR: 14, - INVALID_ACCESS_ERR: 15, - VALIDATION_ERR: 16, - TYPE_MISMATCH_ERR: 17, - SECURITY_ERR: 18, - NETWORK_ERR: 19, - ABORT_ERR: 20, - URL_MISMATCH_ERR: 21, - QUOTA_EXCEEDED_ERR: 22, - TIMEOUT_ERR: 23, - INVALID_NODE_TYPE_ERR: 24, - DATA_CLONE_ERR: 25 - }; + if (list) { + if (fn) { + for (i = list.length - 1; i >= 0; i--) { + if (list[i].fn === fn) { + list.splice(i, 1); + break; + } + } + } else { + list = []; + } - function DOMException(code) { - this.code = code; - this.name = _findKey(namecodes, code); - this.message = this.name + ": DOMException " + this.code; + // delete event list if it has become empty + if (!list.length) { + delete eventpool[this.uid][type]; + + // and object specific entry in a hash if it has no more listeners attached + if (Basic.isEmptyObj(eventpool[this.uid])) { + delete eventpool[this.uid]; + } + } } + }, - Basic.extend(DOMException, namecodes); - DOMException.prototype = Error.prototype; - return DOMException; - }()), + /** + Remove all event handlers from the object - EventException: (function() { - function EventException(code) { - this.code = code; - this.name = 'EventException'; + @method removeAllEventListeners + */ + removeAllEventListeners: function() { + if (eventpool[this.uid]) { + delete eventpool[this.uid]; } + }, - Basic.extend(EventException, { - UNSPECIFIED_EVENT_TYPE_ERR: 0 - }); + /** + Dispatch the event - EventException.prototype = Error.prototype; + @method dispatchEvent + @param {String/Object} Type of event or event object to dispatch + @param {Mixed} [...] Variable number of arguments to be passed to a handlers + @return {Boolean} true by default and false if any handler returned false + */ + dispatchEvent: function(type) { + var uid, list, args, tmpEvt, evt = {}, result = true, undef; - return EventException; - }()) - }; -}); + if (Basic.typeOf(type) !== 'string') { + // we can't use original object directly (because of Silverlight) + tmpEvt = type; -// Included from: src/javascript/core/EventTarget.js + if (Basic.typeOf(tmpEvt.type) === 'string') { + type = tmpEvt.type; -/** - * EventTarget.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ + if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event + evt.total = tmpEvt.total; + evt.loaded = tmpEvt.loaded; + } + evt.async = tmpEvt.async || false; + } else { + throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR); + } + } -define('moxie/core/EventTarget', [ - 'moxie/core/utils/Env', - 'moxie/core/Exceptions', - 'moxie/core/utils/Basic' -], function(Env, x, Basic) { - /** - Parent object for all event dispatching components and objects + // check if event is meant to be dispatched on an object having specific uid + if (type.indexOf('::') !== -1) { + (function(arr) { + uid = arr[0]; + type = arr[1]; + }(type.split('::'))); + } else { + uid = this.uid; + } - @class EventTarget - @constructor EventTarget - */ - function EventTarget() { - // hash of event listeners by object uid - var eventpool = {}; + type = type.toLowerCase(); - Basic.extend(this, { + list = eventpool[uid] && eventpool[uid][type]; - /** - Unique id of the event dispatcher, usually overriden by children + if (list) { + // sort event list by prority + list.sort(function(a, b) { return b.priority - a.priority; }); - @property uid - @type String - */ - uid: null, + args = [].slice.call(arguments); - /** - Can be called from within a child in order to acquire uniqie id in automated manner + // first argument will be pseudo-event object + args.shift(); + evt.type = type; + args.unshift(evt); - @method init - */ - init: function() { - if (!this.uid) { - this.uid = Basic.guid('uid_'); + if (MXI_DEBUG && Env.debug.events) { + Env.log("%cEvent '%s' fired on %s", 'color: #999;', evt.type, (this.ctorName ? this.ctorName + '::' : '') + uid); } - }, - - /** - Register a handler to a specific event dispatched by the object - @method addEventListener - @param {String} type Type or basically a name of the event to subscribe to - @param {Function} fn Callback function that will be called when event happens - @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first - @param {Object} [scope=this] A scope to invoke event handler in - */ - addEventListener: function(type, fn, priority, scope) { - var self = this, list; - - // without uid no event handlers can be added, so make sure we got one - if (!this.hasOwnProperty('uid')) { - this.uid = Basic.guid('uid_'); + // Dispatch event to all listeners + var queue = []; + Basic.each(list, function(handler) { + // explicitly set the target, otherwise events fired from shims do not get it + args[0].target = handler.scope; + // if event is marked as async, detach the handler + if (evt.async) { + queue.push(function(cb) { + setTimeout(function() { + cb(handler.fn.apply(handler.scope, args) === false); + }, 1); + }); + } else { + queue.push(function(cb) { + cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation + }); + } + }); + if (queue.length) { + Basic.inSeries(queue, function(err) { + result = !err; + }); } + } + return result; + }, - type = Basic.trim(type); + /** + Register a handler to the event type that will run only once + + @method bindOnce + @since >1.4.1 + @param {String} type Type or basically a name of the event to subscribe to + @param {Function} fn Callback function that will be called when event happens + @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first + @param {Object} [scope=this] A scope to invoke event handler in + */ + bindOnce: function(type, fn, priority, scope) { + var self = this; + self.bind.call(this, type, function cb() { + self.unbind(type, cb); + return fn.apply(this, arguments); + }, priority, scope); + }, - if (/\s/.test(type)) { - // multiple event types were passed for one handler - Basic.each(type.split(/\s+/), function(type) { - self.addEventListener(type, fn, priority, scope); - }); - return; - } + /** + Alias for addEventListener - type = type.toLowerCase(); - priority = parseInt(priority, 10) || 0; + @method bind + @protected + */ + bind: function() { + this.addEventListener.apply(this, arguments); + }, - list = eventpool[this.uid] && eventpool[this.uid][type] || []; - list.push({fn : fn, priority : priority, scope : scope || this}); + /** + Alias for removeEventListener - if (!eventpool[this.uid]) { - eventpool[this.uid] = {}; - } - eventpool[this.uid][type] = list; - }, + @method unbind + @protected + */ + unbind: function() { + this.removeEventListener.apply(this, arguments); + }, - /** - Check if any handlers were registered to the specified event + /** + Alias for removeAllEventListeners - @method hasEventListener - @param {String} type Type or basically a name of the event to check - @return {Mixed} Returns a handler if it was found and false, if - not - */ - hasEventListener: function(type) { - var list = type ? eventpool[this.uid] && eventpool[this.uid][type] : eventpool[this.uid]; - return list ? list : false; - }, + @method unbindAll + @protected + */ + unbindAll: function() { + this.removeAllEventListeners.apply(this, arguments); + }, - /** - Unregister the handler from the event, or if former was not specified - unregister all handlers + /** + Alias for dispatchEvent - @method removeEventListener - @param {String} type Type or basically a name of the event - @param {Function} [fn] Handler to unregister - */ - removeEventListener: function(type, fn) { - type = type.toLowerCase(); + @method trigger + @protected + */ + trigger: function() { + return this.dispatchEvent.apply(this, arguments); + }, - var list = eventpool[this.uid] && eventpool[this.uid][type], i; - if (list) { - if (fn) { - for (i = list.length - 1; i >= 0; i--) { - if (list[i].fn === fn) { - list.splice(i, 1); - break; - } - } - } else { - list = []; - } + /** + Handle properties of on[event] type. - // delete event list if it has become empty - if (!list.length) { - delete eventpool[this.uid][type]; + @method handleEventProps + @private + */ + handleEventProps: function(dispatches) { + var self = this; - // and object specific entry in a hash if it has no more listeners attached - if (Basic.isEmptyObj(eventpool[this.uid])) { - delete eventpool[this.uid]; - } - } + this.bind(dispatches.join(' '), function(e) { + var prop = 'on' + e.type.toLowerCase(); + if (Basic.typeOf(this[prop]) === 'function') { + this[prop].apply(this, arguments); } - }, - - /** - Remove all event handlers from the object + }); - @method removeAllEventListeners - */ - removeAllEventListeners: function() { - if (eventpool[this.uid]) { - delete eventpool[this.uid]; + // object must have defined event properties, even if it doesn't make use of them + Basic.each(dispatches, function(prop) { + prop = 'on' + prop.toLowerCase(prop); + if (Basic.typeOf(self[prop]) === 'undefined') { + self[prop] = null; } - }, + }); + } - /** - Dispatch the event + }); - @method dispatchEvent - @param {String/Object} Type of event or event object to dispatch - @param {Mixed} [...] Variable number of arguments to be passed to a handlers - @return {Boolean} true by default and false if any handler returned false - */ - dispatchEvent: function(type) { - var uid, list, args, tmpEvt, evt = {}, result = true, undef; - if (Basic.typeOf(type) !== 'string') { - // we can't use original object directly (because of Silverlight) - tmpEvt = type; + EventTarget.instance = new EventTarget(); - if (Basic.typeOf(tmpEvt.type) === 'string') { - type = tmpEvt.type; - - if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event - evt.total = tmpEvt.total; - evt.loaded = tmpEvt.loaded; - } - evt.async = tmpEvt.async || false; - } else { - throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR); - } - } - - // check if event is meant to be dispatched on an object having specific uid - if (type.indexOf('::') !== -1) { - (function(arr) { - uid = arr[0]; - type = arr[1]; - }(type.split('::'))); - } else { - uid = this.uid; - } - - type = type.toLowerCase(); - - list = eventpool[uid] && eventpool[uid][type]; - - if (list) { - // sort event list by prority - list.sort(function(a, b) { return b.priority - a.priority; }); - - args = [].slice.call(arguments); - - // first argument will be pseudo-event object - args.shift(); - evt.type = type; - args.unshift(evt); - - if (MXI_DEBUG && Env.debug.events) { - Env.log("Event '%s' fired on %u", evt.type, uid); - } - - // Dispatch event to all listeners - var queue = []; - Basic.each(list, function(handler) { - // explicitly set the target, otherwise events fired from shims do not get it - args[0].target = handler.scope; - // if event is marked as async, detach the handler - if (evt.async) { - queue.push(function(cb) { - setTimeout(function() { - cb(handler.fn.apply(handler.scope, args) === false); - }, 1); - }); - } else { - queue.push(function(cb) { - cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation - }); - } - }); - if (queue.length) { - Basic.inSeries(queue, function(err) { - result = !err; - }); - } - } - return result; - }, - - /** - Alias for addEventListener - - @method bind - @protected - */ - bind: function() { - this.addEventListener.apply(this, arguments); - }, - - /** - Alias for removeEventListener - - @method unbind - @protected - */ - unbind: function() { - this.removeEventListener.apply(this, arguments); - }, - - /** - Alias for removeAllEventListeners - - @method unbindAll - @protected - */ - unbindAll: function() { - this.removeAllEventListeners.apply(this, arguments); - }, - - /** - Alias for dispatchEvent - - @method trigger - @protected - */ - trigger: function() { - return this.dispatchEvent.apply(this, arguments); - }, - - - /** - Handle properties of on[event] type. - - @method handleEventProps - @private - */ - handleEventProps: function(dispatches) { - var self = this; - - this.bind(dispatches.join(' '), function(e) { - var prop = 'on' + e.type.toLowerCase(); - if (Basic.typeOf(this[prop]) === 'function') { - this[prop].apply(this, arguments); - } - }); - - // object must have defined event properties, even if it doesn't make use of them - Basic.each(dispatches, function(prop) { - prop = 'on' + prop.toLowerCase(prop); - if (Basic.typeOf(self[prop]) === 'undefined') { - self[prop] = null; - } - }); - } - - }); - } - - EventTarget.instance = new EventTarget(); - - return EventTarget; -}); + return EventTarget; +}); // Included from: src/javascript/runtime/Runtime.js @@ -2123,7 +2297,7 @@ define('moxie/runtime/Runtime', [ /** Common set of methods and properties for every runtime instance - @class Runtime + @class moxie/runtime/Runtime @param {Object} options @param {String} type Sanitized name of the runtime @@ -2165,10 +2339,10 @@ define('moxie/runtime/Runtime', [ @type Object */ caps = Basic.extend({ - // Runtime can: + // Runtime can: // provide access to raw binary data of the file access_binary: false, - // provide access to raw binary data of the image (image extension is optional) + // provide access to raw binary data of the image (image extension is optional) access_image_binary: false, // display binary data as thumbs for example display_media: false, @@ -2182,7 +2356,7 @@ define('moxie/runtime/Runtime', [ resize_image: false, // periodically report how many bytes of total in the file were uploaded (loaded) report_upload_progress: false, - // provide access to the headers of http response + // provide access to the headers of http response return_response_headers: false, // support response of specific type, which should be passed as an argument // e.g. runtime.can('return_response_type', 'blob') @@ -2216,17 +2390,17 @@ define('moxie/runtime/Runtime', [ // e.g. runtime.can('use_http_method', 'put') use_http_method: true }, caps); - - + + // default to the mode that is compatible with preferred caps if (options.preferred_caps) { defaultMode = Runtime.getMode(modeCaps, options.preferred_caps, defaultMode); } if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tdefault mode: %s", defaultMode); + Env.log("\tdefault mode: %s", defaultMode); } - + // small extension factory here (is meant to be extended with actual extensions constructors) _shim = (function() { var objpool = {}; @@ -2367,7 +2541,7 @@ define('moxie/runtime/Runtime', [ // if no container for shim, create one if (!shimContainer) { - container = this.options.container ? Dom.get(this.options.container) : document.body; + container = Dom.get(this.options.container) || document.body; // create shim container and insert it at an absolute position into the outer container shimContainer = document.createElement('div'); @@ -2460,7 +2634,7 @@ define('moxie/runtime/Runtime', [ // once we got the mode, test against all caps if (this.mode && options.required_caps && !this.can(options.required_caps)) { this.mode = false; - } + } } @@ -2615,7 +2789,7 @@ define('moxie/runtime/Runtime', [ @static @param {Object} modeCaps Set of capabilities that depend on particular runtime mode @param {Object} [requiredCaps] Supplied set of capabilities to find operational mode for - @param {String|Boolean} [defaultMode='browser'] Default mode to use + @param {String|Boolean} [defaultMode='browser'] Default mode to use @return {String|Boolean} Compatible operational mode */ Runtime.getMode = function(modeCaps, requiredCaps, defaultMode) { @@ -2635,22 +2809,22 @@ define('moxie/runtime/Runtime', [ if (typeof(capMode) === 'string') { capMode = [capMode]; } - + if (!mode) { - mode = capMode; + mode = capMode; } else if (!(mode = Basic.arrayIntersect(mode, capMode))) { // if cap requires conflicting mode - runtime cannot fulfill required caps if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\t\t%c: %v (conflicting mode requested: %s)", cap, value, capMode); + Env.log("\t\t%s: %s (conflicting mode requested: %s)", cap, value, capMode); } return (mode = false); - } + } } if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\t\t%c: %v (compatible modes: %s)", cap, value, mode); + Env.log("\t\t%s: %s (compatible modes: %s)", cap, value, mode); } }); @@ -2660,7 +2834,31 @@ define('moxie/runtime/Runtime', [ return false; } } - return defaultMode; + return defaultMode; + }; + + + /** + * Third party shims (Flash and Silverlight) require global event target against which they + * will fire their events. However when moxie is not loaded to global namespace, default + * event target is not accessible and we have to create artificial ones. + * + * @method getGlobalEventTarget + * @static + * @return {String} Name of the global event target + */ + Runtime.getGlobalEventTarget = function() { + if (/^moxie\./.test(Env.global_event_dispatcher) && !Env.can('access_global_ns')) { + var uniqueCallbackName = Basic.guid('moxie_event_target_'); + + window[uniqueCallbackName] = function(e, data) { + EventTarget.instance.dispatchEvent(e, data); + }; + + Env.global_event_dispatcher = uniqueCallbackName; + } + + return Env.global_event_dispatcher; }; @@ -2724,7 +2922,7 @@ define('moxie/runtime/RuntimeClient', [ /** Set of methods and properties, required by a component to acquire ability to connect to a runtime - @class RuntimeClient + @class moxie/runtime/RuntimeClient */ return function RuntimeClient() { var runtime; @@ -2754,6 +2952,9 @@ define('moxie/runtime/RuntimeClient', [ type = items.shift().toLowerCase(); constructor = Runtime.getConstructor(type); if (!constructor) { + if (MXI_DEBUG && Env.debug.runtime) { + Env.log("Constructor for '%s' runtime is not available.", type); + } initialize(items); return; } @@ -2777,6 +2978,7 @@ define('moxie/runtime/RuntimeClient', [ // jailbreak ... setTimeout(function() { runtime.clients++; + comp.ruid = runtime.uid; // this will be triggered on component comp.trigger('RuntimeInit', runtime); }, 1); @@ -2791,10 +2993,17 @@ define('moxie/runtime/RuntimeClient', [ initialize(items); }); - /*runtime.bind('Exception', function() { });*/ + runtime.bind('Exception', function(e, err) { + var message = err.name + "(#" + err.code + ")" + (err.message ? ", from: " + err.message : ''); + + if (MXI_DEBUG && Env.debug.runtime) { + Env.log("Runtime '%s' has thrown an exception: %s", this.type, message); + } + comp.trigger('RuntimeError', new x.RuntimeError(x.RuntimeError.EXCEPTION_ERR, message)); + }); if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tselected mode: %s", runtime.mode); + Env.log("\tselected mode: %s", runtime.mode); } // check if runtime managed to pick-up operational mode @@ -2816,6 +3025,7 @@ define('moxie/runtime/RuntimeClient', [ if (ruid) { runtime = Runtime.getRuntime(ruid); if (runtime) { + comp.ruid = ruid; runtime.clients++; return runtime; } else { @@ -2861,16 +3071,25 @@ define('moxie/runtime/RuntimeClient', [ /** Handy shortcut to safely invoke runtime extension methods. - + @private @method exec @return {Mixed} Whatever runtime extension method returns */ exec: function() { - if (runtime) { - return runtime.exec.apply(this, arguments); - } - return null; + return runtime ? runtime.exec.apply(this, arguments) : null; + }, + + + /** + Test runtime client for specific capability + + @method can + @param {String} cap + @return {Bool} + */ + can: function(cap) { + return runtime ? runtime.can(cap) : false; } }); @@ -2879,10 +3098,10 @@ define('moxie/runtime/RuntimeClient', [ }); -// Included from: src/javascript/file/FileInput.js +// Included from: src/javascript/file/Blob.js /** - * FileInput.js + * Blob.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -2891,327 +3110,176 @@ define('moxie/runtime/RuntimeClient', [ * Contributing: http://www.plupload.com/contributing */ -define('moxie/file/FileInput', [ +define('moxie/file/Blob', [ 'moxie/core/utils/Basic', - 'moxie/core/utils/Env', - 'moxie/core/utils/Mime', - 'moxie/core/utils/Dom', - 'moxie/core/Exceptions', - 'moxie/core/EventTarget', - 'moxie/core/I18n', - 'moxie/runtime/Runtime', + 'moxie/core/utils/Encode', 'moxie/runtime/RuntimeClient' -], function(Basic, Env, Mime, Dom, x, EventTarget, I18n, Runtime, RuntimeClient) { - /** - Provides a convenient way to create cross-browser file-picker. Generates file selection dialog on click, - converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory - with _FileReader_ or uploaded to a server through _XMLHttpRequest_. +], function(Basic, Encode, RuntimeClient) { + + var blobpool = {}; - @class FileInput + /** + @class moxie/file/Blob @constructor - @extends EventTarget - @uses RuntimeClient - @param {Object|String|DOMElement} options If options is string or node, argument is considered as _browse\_button_. - @param {String|DOMElement} options.browse_button DOM Element to turn into file picker. - @param {Array} [options.accept] Array of mime types to accept. By default accepts all. - @param {String} [options.file='file'] Name of the file field (not the filename). - @param {Boolean} [options.multiple=false] Enable selection of multiple files. - @param {Boolean} [options.directory=false] Turn file input into the folder input (cannot be both at the same time). - @param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode - for _browse\_button_. - @param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support. + @param {String} ruid Unique id of the runtime, to which this blob belongs to + @param {Object} blob Object "Native" blob object, as it is represented in the runtime + */ + function Blob(ruid, blob) { - @example -
- Browse... -
+ function _sliceDetached(start, end, type) { + var blob, data = blobpool[this.uid]; - - */ - var dispatches = [ - /** - Dispatched when runtime is connected and file-picker is ready to be used. + RuntimeClient.call(this); - @event ready - @param {Object} event - */ - 'ready', + if (ruid) { + this.connectRuntime(ruid); + } - /** - Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked. - Check [corresponding documentation entry](#method_refresh) for more info. + if (!blob) { + blob = {}; + } else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string + blob = { data: blob }; + } - @event refresh - @param {Object} event - */ + Basic.extend(this, { + + /** + Unique id of the component - /** - Dispatched when selection of files in the dialog is complete. + @property uid + @type {String} + */ + uid: blob.uid || Basic.guid('uid_'), + + /** + Unique id of the connected runtime, if falsy, then runtime will have to be initialized + before this Blob can be used, modified or sent - @event change - @param {Object} event - */ - 'change', + @property ruid + @type {String} + */ + ruid: ruid, + + /** + Size of blob - 'cancel', + @property size + @type {Number} + @default 0 + */ + size: blob.size || 0, + + /** + Mime type of blob - /** - Dispatched when mouse cursor enters file-picker area. Can be used to style element - accordingly. + @property type + @type {String} + @default '' + */ + type: blob.type || '', + + /** + @method slice + @param {Number} [start=0] + */ + slice: function(start, end, type) { + if (this.isDetached()) { + return _sliceDetached.apply(this, arguments); + } + return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type); + }, - @event mouseenter - @param {Object} event - */ - 'mouseenter', + /** + Returns "native" blob object (as it is represented in connected runtime) or null if not found - /** - Dispatched when mouse cursor leaves file-picker area. Can be used to style element - accordingly. + @method getSource + @return {Blob} Returns "native" blob object or null if not found + */ + getSource: function() { + if (!blobpool[this.uid]) { + return null; + } + return blobpool[this.uid]; + }, - @event mouseleave - @param {Object} event - */ - 'mouseleave', - - /** - Dispatched when functional mouse button is pressed on top of file-picker area. - - @event mousedown - @param {Object} event - */ - 'mousedown', - - /** - Dispatched when functional mouse button is released on top of file-picker area. - - @event mouseup - @param {Object} event - */ - 'mouseup' - ]; - - function FileInput(options) { - if (MXI_DEBUG) { - Env.log("Instantiating FileInput..."); - } - - var self = this, - container, browseButton, defaults; - - // if flat argument passed it should be browse_button id - if (Basic.inArray(Basic.typeOf(options), ['string', 'node']) !== -1) { - options = { browse_button : options }; - } - - // this will help us to find proper default container - browseButton = Dom.get(options.browse_button); - if (!browseButton) { - // browse button is required - throw new x.DOMException(x.DOMException.NOT_FOUND_ERR); - } - - // figure out the options - defaults = { - accept: [{ - title: I18n.translate('All Files'), - extensions: '*' - }], - name: 'file', - multiple: false, - required_caps: false, - container: browseButton.parentNode || document.body - }; - - options = Basic.extend({}, defaults, options); - - // convert to object representation - if (typeof(options.required_caps) === 'string') { - options.required_caps = Runtime.parseCaps(options.required_caps); - } - - // normalize accept option (could be list of mime types or array of title/extensions pairs) - if (typeof(options.accept) === 'string') { - options.accept = Mime.mimes2extList(options.accept); - } - - container = Dom.get(options.container); - // make sure we have container - if (!container) { - container = document.body; - } - - // make container relative, if it's not - if (Dom.getStyle(container, 'position') === 'static') { - container.style.position = 'relative'; - } - - container = browseButton = null; // IE - - RuntimeClient.call(self); - - Basic.extend(self, { - /** - Unique id of the component - - @property uid - @protected - @readOnly - @type {String} - @default UID - */ - uid: Basic.guid('uid_'), - - /** - Unique id of the connected runtime, if any. - - @property ruid - @protected - @type {String} - */ - ruid: null, - - /** - Unique id of the runtime container. Useful to get hold of it for various manipulations. + /** + Detaches blob from any runtime that it depends on and initialize with standalone value - @property shimid + @method detach @protected - @type {String} - */ - shimid: null, - - /** - Array of selected mOxie.File objects - - @property files - @type {Array} - @default null - */ - files: null, - - /** - Initializes the file-picker, connects it to runtime and dispatches event ready when done. - - @method init + @param {DOMString} [data=''] Standalone value */ - init: function() { - self.bind('RuntimeInit', function(e, runtime) { - self.ruid = runtime.uid; - self.shimid = runtime.shimid; - - self.bind("Ready", function() { - self.trigger("Refresh"); - }, 999); - - // re-position and resize shim container - self.bind('Refresh', function() { - var pos, size, browseButton, shimContainer; - - browseButton = Dom.get(options.browse_button); - shimContainer = Dom.get(runtime.shimid); // do not use runtime.getShimContainer(), since it will create container if it doesn't exist - - if (browseButton) { - pos = Dom.getPos(browseButton, Dom.get(options.container)); - size = Dom.getSize(browseButton); - - if (shimContainer) { - Basic.extend(shimContainer.style, { - top : pos.y + 'px', - left : pos.x + 'px', - width : size.w + 'px', - height : size.h + 'px' - }); - } - } - shimContainer = browseButton = null; - }); + detach: function(data) { + if (this.ruid) { + this.getRuntime().exec.call(this, 'Blob', 'destroy'); + this.disconnectRuntime(); + this.ruid = null; + } - runtime.exec.call(self, 'FileInput', 'init', options); - }); + data = data || ''; - // runtime needs: options.required_features, options.runtime_order and options.container - self.connectRuntime(Basic.extend({}, options, { - required_caps: { - select_file: true - } - })); - }, + // if dataUrl, convert to binary string + if (data.substr(0, 5) == 'data:') { + var base64Offset = data.indexOf(';base64,'); + this.type = data.substring(5, base64Offset); + data = Encode.atob(data.substring(base64Offset + 8)); + } - /** - Disables file-picker element, so that it doesn't react to mouse clicks. + this.size = data.length; - @method disable - @param {Boolean} [state=true] Disable component if - true, enable if - false - */ - disable: function(state) { - var runtime = this.getRuntime(); - if (runtime) { - runtime.exec.call(this, 'FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state); - } + blobpool[this.uid] = data; }, - /** - Reposition and resize dialog trigger to match the position and size of browse_button element. - - @method refresh + Checks if blob is standalone (detached of any runtime) + + @method isDetached + @protected + @return {Boolean} */ - refresh: function() { - self.trigger("Refresh"); + isDetached: function() { + return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string'; }, - - - /** - Destroy component. + + /** + Destroy Blob and free any resources it was using @method destroy */ destroy: function() { - var runtime = this.getRuntime(); - if (runtime) { - runtime.exec.call(this, 'FileInput', 'destroy'); - this.disconnectRuntime(); - } - - if (Basic.typeOf(this.files) === 'array') { - // no sense in leaving associated files behind - Basic.each(this.files, function(file) { - file.destroy(); - }); - } - this.files = null; - - this.unbindAll(); + this.detach(); + delete blobpool[this.uid]; } }); - this.handleEventProps(dispatches); + + if (blob.data) { + this.detach(blob.data); // auto-detach if payload has been passed + } else { + blobpool[this.uid] = blob; + } } - - FileInput.prototype = EventTarget.instance; - - return FileInput; + + return Blob; }); -// Included from: src/javascript/core/utils/Encode.js +// Included from: src/javascript/core/I18n.js /** - * Encode.js + * I18n.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -3220,178 +3288,313 @@ define('moxie/file/FileInput', [ * Contributing: http://www.plupload.com/contributing */ -define('moxie/core/utils/Encode', [], function() { +define("moxie/core/I18n", [ + "moxie/core/utils/Basic" +], function(Basic) { + var i18n = {}; /** - Encode string with UTF-8 - - @method utf8_encode - @for Utils - @static - @param {String} str String to encode - @return {String} UTF-8 encoded string + @class moxie/core/I18n */ - var utf8_encode = function(str) { - return unescape(encodeURIComponent(str)); - }; + return { + /** + * Extends the language pack object with new items. + * + * @param {Object} pack Language pack items to add. + * @return {Object} Extended language pack object. + */ + addI18n: function(pack) { + return Basic.extend(i18n, pack); + }, - /** - Decode UTF-8 encoded string + /** + * Translates the specified string by checking for the english string in the language pack lookup. + * + * @param {String} str String to look for. + * @return {String} Translated string or the input string if it wasn't found. + */ + translate: function(str) { + return i18n[str] || str; + }, - @method utf8_decode - @static - @param {String} str String to decode - @return {String} Decoded string - */ - var utf8_decode = function(str_data) { - return decodeURIComponent(escape(str_data)); + /** + * Shortcut for translate function + * + * @param {String} str String to look for. + * @return {String} Translated string or the input string if it wasn't found. + */ + _: function(str) { + return this.translate(str); + }, + + /** + * Pseudo sprintf implementation - simple way to replace tokens with specified values. + * + * @param {String} str String with tokens + * @return {String} String with replaced tokens + */ + sprintf: function(str) { + var args = [].slice.call(arguments, 1); + + return str.replace(/%[a-z]/g, function() { + var value = args.shift(); + return Basic.typeOf(value) !== 'undefined' ? value : ''; + }); + } }; +}); + +// Included from: src/javascript/core/utils/Mime.js + +/** + * Mime.js + * + * Copyright 2013, Moxiecode Systems AB + * Released under GPL License. + * + * License: http://www.plupload.com/license + * Contributing: http://www.plupload.com/contributing + */ + +/** +@class moxie/core/utils/Mime +@public +@static +*/ + +define("moxie/core/utils/Mime", [ + "moxie/core/utils/Basic", + "moxie/core/I18n" +], function(Basic, I18n) { + + var mimeData = "" + + "application/msword,doc dot," + + "application/pdf,pdf," + + "application/pgp-signature,pgp," + + "application/postscript,ps ai eps," + + "application/rtf,rtf," + + "application/vnd.ms-excel,xls xlb xlt xla," + + "application/vnd.ms-powerpoint,ppt pps pot ppa," + + "application/zip,zip," + + "application/x-shockwave-flash,swf swfl," + + "application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," + + "application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," + + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," + + "application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," + + "application/vnd.openxmlformats-officedocument.presentationml.template,potx," + + "application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," + + "application/x-javascript,js," + + "application/json,json," + + "audio/mpeg,mp3 mpga mpega mp2," + + "audio/x-wav,wav," + + "audio/x-m4a,m4a," + + "audio/ogg,oga ogg," + + "audio/aiff,aiff aif," + + "audio/flac,flac," + + "audio/aac,aac," + + "audio/ac3,ac3," + + "audio/x-ms-wma,wma," + + "image/bmp,bmp," + + "image/gif,gif," + + "image/jpeg,jpg jpeg jpe," + + "image/photoshop,psd," + + "image/png,png," + + "image/svg+xml,svg svgz," + + "image/tiff,tiff tif," + + "text/plain,asc txt text diff log," + + "text/html,htm html xhtml," + + "text/css,css," + + "text/csv,csv," + + "text/rtf,rtf," + + "video/mpeg,mpeg mpg mpe m2v," + + "video/quicktime,qt mov," + + "video/mp4,mp4," + + "video/x-m4v,m4v," + + "video/x-flv,flv," + + "video/x-ms-wmv,wmv," + + "video/avi,avi," + + "video/webm,webm," + + "video/3gpp,3gpp 3gp," + + "video/3gpp2,3g2," + + "video/vnd.rn-realvideo,rv," + + "video/ogg,ogv," + + "video/x-matroska,mkv," + + "application/vnd.oasis.opendocument.formula-template,otf," + + "application/octet-stream,exe"; + /** - Decode Base64 encoded string (uses browser's default method if available), - from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js + * Map of mimes to extensions + * + * @property mimes + * @type {Object} + */ + var mimes = {}; - @method atob - @static - @param {String} data String to decode - @return {String} Decoded string + /** + * Map of extensions to mimes + * + * @property extensions + * @type {Object} + */ + var extensions = {}; + + + /** + * Parses mimeData string into a mimes and extensions lookup maps. String should have the + * following format: + * + * application/msword,doc dot,application/pdf,pdf, ... + * + * so mime-type followed by comma and followed by space-separated list of associated extensions, + * then comma again and then another mime-type, etc. + * + * If invoked externally will replace override internal lookup maps with user-provided data. + * + * @method addMimeType + * @param {String} mimeData */ - var atob = function(data, utf8) { - if (typeof(window.atob) === 'function') { - return utf8 ? utf8_decode(window.atob(data)) : window.atob(data); - } + var addMimeType = function (mimeData) { + var items = mimeData.split(/,/), i, ii, ext; - // http://kevin.vanzonneveld.net - // + original by: Tyler Akins (http://rumkin.com) - // + improved by: Thunder.m - // + input by: Aman Gupta - // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // + bugfixed by: Onno Marsman - // + bugfixed by: Pellentesque Malesuada - // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // + input by: Brett Zamir (http://brett-zamir.me) - // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA=='); - // * returns 1: 'Kevin van Zonneveld' - // mozilla has this native - // - but breaks in 2.0.0.12! - //if (typeof this.window.atob == 'function') { - // return atob(data); - //} - var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, - ac = 0, - dec = "", - tmp_arr = []; + for (i = 0; i < items.length; i += 2) { + ext = items[i + 1].split(/ /); - if (!data) { - return data; + // extension to mime lookup + for (ii = 0; ii < ext.length; ii++) { + mimes[ext[ii]] = items[i]; + } + // mime to extension lookup + extensions[items[i]] = ext; } + }; - data += ''; - do { // unpack four hexets into three octets using index points in b64 - h1 = b64.indexOf(data.charAt(i++)); - h2 = b64.indexOf(data.charAt(i++)); - h3 = b64.indexOf(data.charAt(i++)); - h4 = b64.indexOf(data.charAt(i++)); + var extList2mimes = function (filters, addMissingExtensions) { + var ext, i, ii, type, mimes = []; - bits = h1 << 18 | h2 << 12 | h3 << 6 | h4; + // convert extensions to mime types list + for (i = 0; i < filters.length; i++) { + ext = filters[i].extensions.toLowerCase().split(/\s*,\s*/); - o1 = bits >> 16 & 0xff; - o2 = bits >> 8 & 0xff; - o3 = bits & 0xff; + for (ii = 0; ii < ext.length; ii++) { - if (h3 == 64) { - tmp_arr[ac++] = String.fromCharCode(o1); - } else if (h4 == 64) { - tmp_arr[ac++] = String.fromCharCode(o1, o2); - } else { - tmp_arr[ac++] = String.fromCharCode(o1, o2, o3); - } - } while (i < data.length); + // if there's an asterisk in the list, then accept attribute is not required + if (ext[ii] === '*') { + return []; + } - dec = tmp_arr.join(''); + type = mimes[ext[ii]]; - return utf8 ? utf8_decode(dec) : dec; + // future browsers should filter by extension, finally + if (addMissingExtensions && /^\w+$/.test(ext[ii])) { + mimes.push('.' + ext[ii]); + } else if (type && Basic.inArray(type, mimes) === -1) { + mimes.push(type); + } else if (!type) { + // if we have no type in our map, then accept all + return []; + } + } + } + return mimes; }; - /** - Base64 encode string (uses browser's default method if available), - from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js - @method btoa - @static - @param {String} data String to encode - @return {String} Base64 encoded string - */ - var btoa = function(data, utf8) { - if (utf8) { - data = utf8_encode(data); - } + var mimes2exts = function(mimes) { + var exts = []; - if (typeof(window.btoa) === 'function') { - return window.btoa(data); - } + Basic.each(mimes, function(mime) { + mime = mime.toLowerCase(); - // http://kevin.vanzonneveld.net - // + original by: Tyler Akins (http://rumkin.com) - // + improved by: Bayron Guevara - // + improved by: Thunder.m - // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // + bugfixed by: Pellentesque Malesuada - // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // + improved by: Rafał Kukawski (http://kukawski.pl) - // * example 1: base64_encode('Kevin van Zonneveld'); - // * returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA==' - // mozilla has this native - // - but breaks in 2.0.0.12! - var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, - ac = 0, - enc = "", - tmp_arr = []; + if (mime === '*') { + exts = []; + return false; + } - if (!data) { - return data; - } + // check if this thing looks like mime type + var m = mime.match(/^(\w+)\/(\*|\w+)$/); + if (m) { + if (m[2] === '*') { + // wildcard mime type detected + Basic.each(extensions, function(arr, mime) { + if ((new RegExp('^' + m[1] + '/')).test(mime)) { + [].push.apply(exts, extensions[mime]); + } + }); + } else if (extensions[mime]) { + [].push.apply(exts, extensions[mime]); + } + } + }); + return exts; + }; - do { // pack three octets into four hexets - o1 = data.charCodeAt(i++); - o2 = data.charCodeAt(i++); - o3 = data.charCodeAt(i++); - bits = o1 << 16 | o2 << 8 | o3; + var mimes2extList = function(mimes) { + var accept = [], exts = []; - h1 = bits >> 18 & 0x3f; - h2 = bits >> 12 & 0x3f; - h3 = bits >> 6 & 0x3f; - h4 = bits & 0x3f; + if (Basic.typeOf(mimes) === 'string') { + mimes = Basic.trim(mimes).split(/\s*,\s*/); + } - // use hexets to index into b64, and append result to encoded string - tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4); - } while (i < data.length); + exts = mimes2exts(mimes); - enc = tmp_arr.join(''); + accept.push({ + title: I18n.translate('Files'), + extensions: exts.length ? exts.join(',') : '*' + }); - var r = data.length % 3; + return accept; + }; - return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3); + /** + * Extract extension from the given filename + * + * @method getFileExtension + * @param {String} fileName + * @return {String} File extension + */ + var getFileExtension = function(fileName) { + var matches = fileName && fileName.match(/\.([^.]+)$/); + if (matches) { + return matches[1].toLowerCase(); + } + return ''; }; - return { - utf8_encode: utf8_encode, - utf8_decode: utf8_decode, - atob: atob, - btoa: btoa + /** + * Get file mime-type from it's filename - will try to match the extension + * against internal mime-type lookup map + * + * @method getFileMime + * @param {String} fileName + * @return File mime-type if found or an empty string if not + */ + var getFileMime = function(fileName) { + return mimes[getFileExtension(fileName)] || ''; }; + + + addMimeType(mimeData); + + return { + mimes: mimes, + extensions: extensions, + addMimeType: addMimeType, + extList2mimes: extList2mimes, + mimes2exts: mimes2exts, + mimes2extList: mimes2extList, + getFileExtension: getFileExtension, + getFileMime: getFileMime + } }); -// Included from: src/javascript/file/Blob.js +// Included from: src/javascript/file/FileInput.js /** - * Blob.js + * FileInput.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -3400,170 +3603,367 @@ define('moxie/core/utils/Encode', [], function() { * Contributing: http://www.plupload.com/contributing */ -define('moxie/file/Blob', [ +define('moxie/file/FileInput', [ 'moxie/core/utils/Basic', - 'moxie/core/utils/Encode', + 'moxie/core/utils/Env', + 'moxie/core/utils/Mime', + 'moxie/core/utils/Dom', + 'moxie/core/Exceptions', + 'moxie/core/EventTarget', + 'moxie/core/I18n', + 'moxie/runtime/Runtime', 'moxie/runtime/RuntimeClient' -], function(Basic, Encode, RuntimeClient) { - - var blobpool = {}; - +], function(Basic, Env, Mime, Dom, x, EventTarget, I18n, Runtime, RuntimeClient) { /** - @class Blob + Provides a convenient way to create cross-browser file-picker. Generates file selection dialog on click, + converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory + with _FileReader_ or uploaded to a server through _XMLHttpRequest_. + + @class moxie/file/FileInput @constructor - @param {String} ruid Unique id of the runtime, to which this blob belongs to - @param {Object} blob Object "Native" blob object, as it is represented in the runtime + @extends EventTarget + @uses RuntimeClient + @param {Object|String|DOMElement} options If options is string or node, argument is considered as _browse\_button_. + @param {String|DOMElement} options.browse_button DOM Element to turn into file picker. + @param {Array} [options.accept] Array of mime types to accept. By default accepts all. + @param {Boolean} [options.multiple=false] Enable selection of multiple files. + @param {Boolean} [options.directory=false] Turn file input into the folder input (cannot be both at the same time). + @param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode + for _browse\_button_. + @param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support. + + @example +
+ Browse... +
+ + */ - function Blob(ruid, blob) { + var dispatches = [ + /** + Dispatched when runtime is connected and file-picker is ready to be used. - function _sliceDetached(start, end, type) { - var blob, data = blobpool[this.uid]; + @event ready + @param {Object} event + */ + 'ready', - if (Basic.typeOf(data) !== 'string' || !data.length) { - return null; // or throw exception - } + /** + Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked. + Check [corresponding documentation entry](#method_refresh) for more info. + + @event refresh + @param {Object} event + */ + + /** + Dispatched when selection of files in the dialog is complete. + + @event change + @param {Object} event + */ + 'change', + + 'cancel', // TODO: might be useful + + /** + Dispatched when mouse cursor enters file-picker area. Can be used to style element + accordingly. + + @event mouseenter + @param {Object} event + */ + 'mouseenter', + + /** + Dispatched when mouse cursor leaves file-picker area. Can be used to style element + accordingly. + + @event mouseleave + @param {Object} event + */ + 'mouseleave', + + /** + Dispatched when functional mouse button is pressed on top of file-picker area. + + @event mousedown + @param {Object} event + */ + 'mousedown', + + /** + Dispatched when functional mouse button is released on top of file-picker area. + + @event mouseup + @param {Object} event + */ + 'mouseup' + ]; + + function FileInput(options) { + if (MXI_DEBUG) { + Env.log("Instantiating FileInput..."); + } + + var container, browseButton, defaults; + + // if flat argument passed it should be browse_button id + if (Basic.inArray(Basic.typeOf(options), ['string', 'node']) !== -1) { + options = { browse_button : options }; + } + + // this will help us to find proper default container + browseButton = Dom.get(options.browse_button); + if (!browseButton) { + // browse button is required + throw new x.DOMException(x.DOMException.NOT_FOUND_ERR); + } + + // figure out the options + defaults = { + accept: [{ + title: I18n.translate('All Files'), + extensions: '*' + }], + multiple: false, + required_caps: false, + container: browseButton.parentNode || document.body + }; - blob = new Blob(null, { - type: type, - size: end - start - }); - blob.detach(data.substr(start, blob.size)); + options = Basic.extend({}, defaults, options); - return blob; + // convert to object representation + if (typeof(options.required_caps) === 'string') { + options.required_caps = Runtime.parseCaps(options.required_caps); } - RuntimeClient.call(this); + // normalize accept option (could be list of mime types or array of title/extensions pairs) + if (typeof(options.accept) === 'string') { + options.accept = Mime.mimes2extList(options.accept); + } - if (ruid) { - this.connectRuntime(ruid); + container = Dom.get(options.container); + // make sure we have container + if (!container) { + container = document.body; } - if (!blob) { - blob = {}; - } else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string - blob = { data: blob }; + // make container relative, if it's not + if (Dom.getStyle(container, 'position') === 'static') { + container.style.position = 'relative'; } - Basic.extend(this, { + container = browseButton = null; // IE + + RuntimeClient.call(this); + Basic.extend(this, { /** Unique id of the component @property uid + @protected + @readOnly @type {String} + @default UID */ - uid: blob.uid || Basic.guid('uid_'), + uid: Basic.guid('uid_'), /** - Unique id of the connected runtime, if falsy, then runtime will have to be initialized - before this Blob can be used, modified or sent + Unique id of the connected runtime, if any. @property ruid + @protected @type {String} */ - ruid: ruid, + ruid: null, /** - Size of blob + Unique id of the runtime container. Useful to get hold of it for various manipulations. - @property size - @type {Number} - @default 0 + @property shimid + @protected + @type {String} */ - size: blob.size || 0, + shimid: null, /** - Mime type of blob + Array of selected moxie.file.File objects - @property type - @type {String} - @default '' + @property files + @type {Array} + @default null */ - type: blob.type || '', + files: null, /** - @method slice - @param {Number} [start=0] + Initializes the file-picker, connects it to runtime and dispatches event ready when done. + + @method init */ - slice: function(start, end, type) { - if (this.isDetached()) { - return _sliceDetached.apply(this, arguments); - } - return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type); - }, + init: function() { + var self = this; - /** - Returns "native" blob object (as it is represented in connected runtime) or null if not found + self.bind('RuntimeInit', function(e, runtime) { + self.ruid = runtime.uid; + self.shimid = runtime.shimid; - @method getSource - @return {Blob} Returns "native" blob object or null if not found - */ - getSource: function() { - if (!blobpool[this.uid]) { - return null; - } - return blobpool[this.uid]; + self.bind("Ready", function() { + self.trigger("Refresh"); + }, 999); + + // re-position and resize shim container + self.bind('Refresh', function() { + var pos, size, browseButton, shimContainer, zIndex; + + browseButton = Dom.get(options.browse_button); + shimContainer = Dom.get(runtime.shimid); // do not use runtime.getShimContainer(), since it will create container if it doesn't exist + + if (browseButton) { + pos = Dom.getPos(browseButton, Dom.get(options.container)); + size = Dom.getSize(browseButton); + zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 0; + + if (shimContainer) { + Basic.extend(shimContainer.style, { + top: pos.y + 'px', + left: pos.x + 'px', + width: size.w + 'px', + height: size.h + 'px', + zIndex: zIndex + 1 + }); + } + } + shimContainer = browseButton = null; + }); + + runtime.exec.call(self, 'FileInput', 'init', options); + }); + + // runtime needs: options.required_features, options.runtime_order and options.container + self.connectRuntime(Basic.extend({}, options, { + required_caps: { + select_file: true + } + })); }, + /** - Detaches blob from any runtime that it depends on and initialize with standalone value + * Get current option value by its name + * + * @method getOption + * @param name + * @return {Mixed} + */ + getOption: function(name) { + return options[name]; + }, - @method detach - @protected - @param {DOMString} [data=''] Standalone value - */ - detach: function(data) { - if (this.ruid) { - this.getRuntime().exec.call(this, 'Blob', 'destroy'); - this.disconnectRuntime(); - this.ruid = null; + + /** + * Sets a new value for the option specified by name + * + * @method setOption + * @param name + * @param value + */ + setOption: function(name, value) { + if (!options.hasOwnProperty(name)) { + return; } - data = data || ''; + var oldValue = options[name]; - // if dataUrl, convert to binary string - if (data.substr(0, 5) == 'data:') { - var base64Offset = data.indexOf(';base64,'); - this.type = data.substring(5, base64Offset); - data = Encode.atob(data.substring(base64Offset + 8)); + switch (name) { + case 'accept': + if (typeof(value) === 'string') { + value = Mime.mimes2extList(value); + } + break; + + case 'container': + case 'required_caps': + throw new x.FileException(x.FileException.NO_MODIFICATION_ALLOWED_ERR); } - this.size = data.length; + options[name] = value; + this.exec('FileInput', 'setOption', name, value); - blobpool[this.uid] = data; + this.trigger('OptionChanged', name, value, oldValue); }, /** - Checks if blob is standalone (detached of any runtime) + Disables file-picker element, so that it doesn't react to mouse clicks. - @method isDetached - @protected - @return {Boolean} + @method disable + @param {Boolean} [state=true] Disable component if - true, enable if - false */ - isDetached: function() { - return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string'; + disable: function(state) { + var runtime = this.getRuntime(); + if (runtime) { + this.exec('FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state); + } }, + /** - Destroy Blob and free any resources it was using + Reposition and resize dialog trigger to match the position and size of browse_button element. + + @method refresh + */ + refresh: function() { + this.trigger("Refresh"); + }, + + + /** + Destroy component. @method destroy */ destroy: function() { - this.detach(); - delete blobpool[this.uid]; + var runtime = this.getRuntime(); + if (runtime) { + runtime.exec.call(this, 'FileInput', 'destroy'); + this.disconnectRuntime(); + } + + if (Basic.typeOf(this.files) === 'array') { + // no sense in leaving associated files behind + Basic.each(this.files, function(file) { + file.destroy(); + }); + } + this.files = null; + + this.unbindAll(); } }); - - if (blob.data) { - this.detach(blob.data); // auto-detach if payload has been passed - } else { - blobpool[this.uid] = blob; - } + this.handleEventProps(dispatches); } - return Blob; + FileInput.prototype = EventTarget.instance; + + return FileInput; }); // Included from: src/javascript/file/File.js @@ -3584,7 +3984,7 @@ define('moxie/file/File', [ 'moxie/file/Blob' ], function(Basic, Mime, Blob) { /** - @class File + @class moxie/file/File @extends Blob @constructor @param {String} ruid Unique id of the runtime, to which this blob belongs to @@ -3609,13 +4009,13 @@ define('moxie/file/File', [ } else if (this.type) { var prefix = this.type.split('/')[0]; name = Basic.guid((prefix !== '' ? prefix : 'file') + '_'); - + if (Mime.extensions[this.type]) { name += '.' + Mime.extensions[this.type][0]; // append proper extension if possible } } - - + + Basic.extend(this, { /** File name @@ -3634,7 +4034,7 @@ define('moxie/file/File', [ @default '' */ relativePath: '', - + /** Date of last modification @@ -3675,8 +4075,8 @@ define('moxie/file/FileDrop', [ 'moxie/core/utils/Mime' ], function(I18n, Dom, x, Basic, Env, File, RuntimeClient, EventTarget, Mime) { /** - Turn arbitrary DOM element to a drop zone accepting files. Converts selected files to _File_ objects, to be used - in conjunction with _Image_, preloaded in memory with _FileReader_ or uploaded to a server through + Turn arbitrary DOM element to a drop zone accepting files. Converts selected files to _File_ objects, to be used + in conjunction with _Image_, preloaded in memory with _FileReader_ or uploaded to a server through _XMLHttpRequest_. @example @@ -3687,10 +4087,10 @@ define('moxie/file/FileDrop', [
- @class FileDrop + @class moxie/file/FileDrop @constructor @extends EventTarget @uses RuntimeClient @@ -3714,7 +4114,7 @@ define('moxie/file/FileDrop', [ @event ready @param {Object} event */ - 'ready', + 'ready', /** Dispatched when dragging cursor enters the drop zone. @@ -3730,7 +4130,7 @@ define('moxie/file/FileDrop', [ @event dragleave @param {Object} event */ - 'dragleave', + 'dragleave', /** Dispatched when file is dropped onto the drop zone. @@ -3738,7 +4138,7 @@ define('moxie/file/FileDrop', [ @event drop @param {Object} event */ - 'drop', + 'drop', /** Dispatched if error occurs. @@ -3751,7 +4151,7 @@ define('moxie/file/FileDrop', [ function FileDrop(options) { if (MXI_DEBUG) { - Env.log("Instantiating FileDrop..."); + Env.log("Instantiating FileDrop..."); } var self = this, defaults; @@ -3771,7 +4171,7 @@ define('moxie/file/FileDrop', [ drag_and_drop: true } }; - + options = typeof(options) === 'object' ? Basic.extend({}, defaults, options) : defaults; // this will help us to find proper default container @@ -3781,7 +4181,7 @@ define('moxie/file/FileDrop', [ if (Dom.getStyle(options.container, 'position') === 'static') { options.container.style.position = 'relative'; } - + // normalize accept option (could be list of mime types or array of title/extensions pairs) if (typeof(options.accept) === 'string') { options.accept = Mime.mimes2extList(options.accept); @@ -3796,13 +4196,13 @@ define('moxie/file/FileDrop', [ files: null, - init: function() { + init: function() { self.bind('RuntimeInit', function(e, runtime) { self.ruid = runtime.uid; runtime.exec.call(self, 'FileDrop', 'init', options); self.dispatchEvent('ready'); }); - + // runtime needs: options.required_features, options.runtime_order and options.container self.connectRuntime(options); // throws RuntimeError }, @@ -3814,7 +4214,7 @@ define('moxie/file/FileDrop', [ this.disconnectRuntime(); } this.files = null; - + this.unbindAll(); } }); @@ -3851,54 +4251,54 @@ define('moxie/file/FileReader', [ Utility for preloading o.Blob/o.File objects in memory. By design closely follows [W3C FileReader](http://www.w3.org/TR/FileAPI/#dfn-filereader) interface. Where possible uses native FileReader, where - not falls back to shims. - @class FileReader + @class moxie/file/FileReader @constructor FileReader @extends EventTarget @uses RuntimeClient */ var dispatches = [ - /** + /** Dispatched when the read starts. @event loadstart @param {Object} event */ - 'loadstart', + 'loadstart', - /** + /** Dispatched while reading (and decoding) blob, and reporting partial Blob data (progess.loaded/progress.total). @event progress @param {Object} event */ - 'progress', + 'progress', - /** + /** Dispatched when the read has successfully completed. @event load @param {Object} event */ - 'load', + 'load', - /** + /** Dispatched when the read has been aborted. For instance, by invoking the abort() method. @event abort @param {Object} event */ - 'abort', + 'abort', - /** + /** Dispatched when the read has failed. @event error @param {Object} event */ - 'error', + 'error', - /** + /** Dispatched when the request has completed (either in success or failure). @event loadend @@ -3906,7 +4306,7 @@ define('moxie/file/FileReader', [ */ 'loadend' ]; - + function FileReader() { RuntimeClient.call(this); @@ -3929,7 +4329,7 @@ define('moxie/file/FileReader', [ @default FileReader.EMPTY */ readyState: FileReader.EMPTY, - + /** Result of the successful read operation. @@ -3937,7 +4337,7 @@ define('moxie/file/FileReader', [ @type {String} */ result: null, - + /** Stores the error of failed asynchronous read operation. @@ -3945,7 +4345,7 @@ define('moxie/file/FileReader', [ @type {DOMError} */ error: null, - + /** Initiates reading of File/Blob object contents to binary string. @@ -3955,7 +4355,7 @@ define('moxie/file/FileReader', [ readAsBinaryString: function(blob) { _read.call(this, 'readAsBinaryString', blob); }, - + /** Initiates reading of File/Blob object contents to dataURL string. @@ -3965,7 +4365,7 @@ define('moxie/file/FileReader', [ readAsDataURL: function(blob) { _read.call(this, 'readAsDataURL', blob); }, - + /** Initiates reading of File/Blob object contents to string. @@ -3975,7 +4375,7 @@ define('moxie/file/FileReader', [ readAsText: function(blob) { _read.call(this, 'readAsText', blob); }, - + /** Aborts preloading process. @@ -3983,7 +4383,7 @@ define('moxie/file/FileReader', [ */ abort: function() { this.result = null; - + if (Basic.inArray(this.readyState, [FileReader.EMPTY, FileReader.DONE]) !== -1) { return; } else if (this.readyState === FileReader.LOADING) { @@ -3991,7 +4391,7 @@ define('moxie/file/FileReader', [ } this.exec('FileReader', 'abort'); - + this.trigger('abort'); this.trigger('loadend'); }, @@ -4016,14 +4416,14 @@ define('moxie/file/FileReader', [ this.readyState = FileReader.DONE; this.error = err; }, 999); - + this.bind('Load', function(e) { this.readyState = FileReader.DONE; }, 999); - + function _read(op, blob) { - var self = this; + var self = this; this.trigger('loadstart'); @@ -4042,7 +4442,7 @@ define('moxie/file/FileReader', [ this.result = null; this.readyState = FileReader.LOADING; - + if (blob.isDetached()) { var src = blob.getSource(); switch (op) { @@ -4063,7 +4463,7 @@ define('moxie/file/FileReader', [ } } } - + /** Initial FileReader state @@ -4114,13 +4514,20 @@ define('moxie/file/FileReader', [ * Contributing: http://www.plupload.com/contributing */ -define('moxie/core/utils/Url', [], function() { +/** +@class moxie/core/utils/Url +@public +@static +*/ + +define('moxie/core/utils/Url', [ + 'moxie/core/utils/Basic' +], function(Basic) { /** Parse url into separate components and fill in absent parts with parts from current url, based on https://raw.github.com/kvz/phpjs/master/functions/url/parse_url.js @method parseUrl - @for Utils @static @param {String} url Url to parse (defaults to empty string if undefined) @return {Object} Hash containing extracted uri components @@ -4133,24 +4540,36 @@ define('moxie/core/utils/Url', [], function() { https: 443 } , uri = {} - , regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/ + , regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@\/]*):?([^:@\/]*))?@)?(\[[\da-fA-F:]+\]|[^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/ , m = regex.exec(url || '') + , isRelative + , isSchemeLess = /^\/\/\w/.test(url) ; + switch (Basic.typeOf(currentUrl)) { + case 'undefined': + currentUrl = parseUrl(document.location.href, false); + break; + + case 'string': + currentUrl = parseUrl(currentUrl, false); + break; + } + while (i--) { if (m[i]) { uri[key[i]] = m[i]; } } - // when url is relative, we set the origin and the path ourselves - if (!uri.scheme) { - // come up with defaults - if (!currentUrl || typeof(currentUrl) === 'string') { - currentUrl = parseUrl(currentUrl || document.location.href); - } + isRelative = !isSchemeLess && !uri.scheme; + if (isSchemeLess || isRelative) { uri.scheme = currentUrl.scheme; + } + + // when url is relative, we set the origin and the path ourselves + if (isRelative) { uri.host = currentUrl.host; uri.port = currentUrl.port; @@ -4198,6 +4617,8 @@ define('moxie/core/utils/Url', [], function() { https: 443 } , urlp = typeof(url) === 'object' ? url : parseUrl(url); + ; + return urlp.scheme + '://' + urlp.host + (urlp.port !== ports[urlp.scheme] ? ':' + urlp.port : '') + urlp.path + (urlp.query ? urlp.query : ''); }; @@ -4205,6 +4626,7 @@ define('moxie/core/utils/Url', [], function() { Check if specified url has the same origin as the current document @method hasSameOrigin + @static @param {String|Object} url @return {Boolean} */ @@ -4248,14 +4670,14 @@ define('moxie/runtime/RuntimeTarget', [ Instance of this class can be used as a target for the events dispatched by shims, when allowing them onto components is for either reason inappropriate - @class RuntimeTarget + @class moxie/runtime/RuntimeTarget @constructor @protected @extends EventTarget */ function RuntimeTarget() { this.uid = Basic.guid('uid_'); - + RuntimeClient.call(this); this.destroy = function() { @@ -4291,7 +4713,7 @@ define('moxie/file/FileReaderSync', [ it can be used to read only preloaded blobs/files and only below certain size (not yet sure what that'd be, but probably < 1mb). Not meant to be used directly by user. - @class FileReaderSync + @class moxie/file/FileReaderSync @private @constructor */ @@ -4304,15 +4726,15 @@ define('moxie/file/FileReaderSync', [ readAsBinaryString: function(blob) { return _read.call(this, 'readAsBinaryString', blob); }, - + readAsDataURL: function(blob) { return _read.call(this, 'readAsDataURL', blob); }, - + /*readAsArrayBuffer: function(blob) { return _read.call(this, 'readAsArrayBuffer', blob); },*/ - + readAsText: function(blob) { return _read.call(this, 'readAsText', blob); } @@ -4362,7 +4784,7 @@ define("moxie/xhr/FormData", [ /** FormData - @class FormData + @class moxie/xhr/FormData @constructor */ function FormData() { @@ -4555,7 +4977,7 @@ define("moxie/xhr/XMLHttpRequest", [ /** Implementation of XMLHttpRequest - @class XMLHttpRequest + @class moxie/xhr/XMLHttpRequest @constructor @uses RuntimeClient @extends EventTarget @@ -4894,6 +5316,18 @@ define("moxie/xhr/XMLHttpRequest", [ return true; }, + /** + * Test if the specified header is already set on this request. + * Returns a header value or boolean false if it's not yet set. + * + * @method hasRequestHeader + * @param {String} header Name of the header to test + * @return {Boolean|String} + */ + hasRequestHeader: function(header) { + return header && _headers[header.toLowerCase()] || false; + }, + /** Returns all headers from the response, with the exception of those whose field name is Set-Cookie or Set-Cookie2. @@ -5262,6 +5696,14 @@ define("moxie/xhr/XMLHttpRequest", [ } } + /* + function _toASCII(str, AllowUnassigned, UseSTD3ASCIIRules) { + // TODO: http://tools.ietf.org/html/rfc3490#section-4.1 + return str.toLowerCase(); + } + */ + + function _doXHR(data) { var self = this; @@ -5442,6 +5884,12 @@ define("moxie/runtime/Transporter", [ "moxie/runtime/RuntimeClient", "moxie/core/EventTarget" ], function(Basic, Encode, RuntimeClient, EventTarget) { + + /** + @class moxie/runtime/Transporter + @private + @constructor + */ function Transporter() { var mod, _runtime, _data, _size, _pos, _chunk_size; @@ -5591,7 +6039,7 @@ define("moxie/image/Image", [ /** Image preloading and manipulation utility. Additionally it provides access to image meta info (Exif, GPS) and raw binary data. - @class Image + @class moxie/image/Image @constructor @extends EventTarget */ @@ -5702,7 +6150,7 @@ define("moxie/image/Image", [ meta: {}, /** - Alias for load method, that takes another mOxie.Image object as a source (see load). + Alias for load method, that takes another moxie.image.Image object as a source (see load). @method clone @param {Image} src Source for the image @@ -5713,19 +6161,20 @@ define("moxie/image/Image", [ }, /** - Loads image from various sources. Currently the source for new image can be: mOxie.Image, mOxie.Blob/mOxie.File, - native Blob/File, dataUrl or URL. Depending on the type of the source, arguments - differ. When source is URL, - Image will be downloaded from remote destination and loaded in memory. + Loads image from various sources. Currently the source for new image can be: moxie.image.Image, + moxie.file.Blob/moxie.file.File, native Blob/File, dataUrl or URL. Depending on the type of the + source, arguments - differ. When source is URL, Image will be downloaded from remote destination + and loaded in memory. @example - var img = new mOxie.Image(); + var img = new moxie.image.Image(); img.onload = function() { var blob = img.getAsBlob(); - var formData = new mOxie.FormData(); + var formData = new moxie.xhr.FormData(); formData.append('file', blob); - var xhr = new mOxie.XMLHttpRequest(); + var xhr = new moxie.xhr.XMLHttpRequest(); xhr.onload = function() { // upload complete }; @@ -5743,30 +6192,188 @@ define("moxie/image/Image", [ _load.apply(this, arguments); }, + + /** + Resizes the image to fit the specified width/height. If crop is specified, image will also be + cropped to the exact dimensions. + + @method resize + @since 3.0 + @param {Object} options + @param {Number} options.width Resulting width + @param {Number} [options.height=width] Resulting height (optional, if not supplied will default to width) + @param {String} [options.type='image/jpeg'] MIME type of the resulting image + @param {Number} [options.quality=90] In the case of JPEG, controls the quality of resulting image + @param {Boolean} [options.crop='cc'] If not falsy, image will be cropped, by default from center + @param {Boolean} [options.fit=true] Whether to upscale the image to fit the exact dimensions + @param {Boolean} [options.preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize) + @param {String} [options.resample='default'] Resampling algorithm to use during resize + @param {Boolean} [options.multipass=true] Whether to scale the image in steps (results in better quality) + */ + resize: function(options) { + var self = this; + var orientation; + var scale; + + var srcRect = { + x: 0, + y: 0, + width: self.width, + height: self.height + }; + + var opts = Basic.extendIf({ + width: self.width, + height: self.height, + type: self.type || 'image/jpeg', + quality: 90, + crop: false, + fit: true, + preserveHeaders: true, + resample: 'default', + multipass: true + }, options); + + try { + if (!self.size) { // only preloaded image objects can be used as source + throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); + } + + // no way to reliably intercept the crash due to high resolution, so we simply avoid it + if (self.width > Image.MAX_RESIZE_WIDTH || self.height > Image.MAX_RESIZE_HEIGHT) { + throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR); + } + + // take into account orientation tag + orientation = (self.meta && self.meta.tiff && self.meta.tiff.Orientation) || 1; + + if (Basic.inArray(orientation, [5,6,7,8]) !== -1) { // values that require 90 degree rotation + var tmp = opts.width; + opts.width = opts.height; + opts.height = tmp; + } + + if (opts.crop) { + scale = Math.max(opts.width/self.width, opts.height/self.height); + + if (options.fit) { + // first scale it up or down to fit the original image + srcRect.width = Math.min(Math.ceil(opts.width/scale), self.width); + srcRect.height = Math.min(Math.ceil(opts.height/scale), self.height); + + // recalculate the scale for adapted dimensions + scale = opts.width/srcRect.width; + } else { + srcRect.width = Math.min(opts.width, self.width); + srcRect.height = Math.min(opts.height, self.height); + + // now we do not need to scale it any further + scale = 1; + } + + if (typeof(opts.crop) === 'boolean') { + opts.crop = 'cc'; + } + + switch (opts.crop.toLowerCase().replace(/_/, '-')) { + case 'rb': + case 'right-bottom': + srcRect.x = self.width - srcRect.width; + srcRect.y = self.height - srcRect.height; + break; + + case 'cb': + case 'center-bottom': + srcRect.x = Math.floor((self.width - srcRect.width) / 2); + srcRect.y = self.height - srcRect.height; + break; + + case 'lb': + case 'left-bottom': + srcRect.x = 0; + srcRect.y = self.height - srcRect.height; + break; + + case 'lt': + case 'left-top': + srcRect.x = 0; + srcRect.y = 0; + break; + + case 'ct': + case 'center-top': + srcRect.x = Math.floor((self.width - srcRect.width) / 2); + srcRect.y = 0; + break; + + case 'rt': + case 'right-top': + srcRect.x = self.width - srcRect.width; + srcRect.y = 0; + break; + + case 'rc': + case 'right-center': + case 'right-middle': + srcRect.x = self.width - srcRect.width; + srcRect.y = Math.floor((self.height - srcRect.height) / 2); + break; + + + case 'lc': + case 'left-center': + case 'left-middle': + srcRect.x = 0; + srcRect.y = Math.floor((self.height - srcRect.height) / 2); + break; + + case 'cc': + case 'center-center': + case 'center-middle': + default: + srcRect.x = Math.floor((self.width - srcRect.width) / 2); + srcRect.y = Math.floor((self.height - srcRect.height) / 2); + } + + // original image might be smaller than requested crop, so - avoid negative values + srcRect.x = Math.max(srcRect.x, 0); + srcRect.y = Math.max(srcRect.y, 0); + } else { + scale = Math.min(opts.width/self.width, opts.height/self.height); + + // do not upscale if we were asked to not fit it + if (scale > 1 && !opts.fit) { + scale = 1; + } + } + + this.exec('Image', 'resize', srcRect, scale, opts); + } catch(ex) { + // for now simply trigger error event + self.trigger('error', ex.code); + } + }, + /** Downsizes the image to fit the specified width/height. If crop is supplied, image will be cropped to exact dimensions. @method downsize - @param {Object} opts - @param {Number} opts.width Resulting width - @param {Number} [opts.height=width] Resulting height (optional, if not supplied will default to width) - @param {Boolean} [opts.crop=false] Whether to crop the image to exact dimensions - @param {Boolean} [opts.preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize) - @param {String} [opts.resample=false] Resampling algorithm to use for resizing + @deprecated use resize() */ - downsize: function(opts) { + downsize: function(options) { var defaults = { width: this.width, height: this.height, type: this.type || 'image/jpeg', quality: 90, crop: false, + fit: false, preserveHeaders: true, - resample: false - }; + resample: 'default' + }, opts; - if (typeof(opts) === 'object') { - opts = Basic.extend(defaults, opts); + if (typeof(options) === 'object') { + opts = Basic.extend(defaults, options); } else { // for backward compatibility opts = Basic.extend(defaults, { @@ -5777,21 +6384,7 @@ define("moxie/image/Image", [ }); } - try { - if (!this.size) { // only preloaded image objects can be used as source - throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); - } - - // no way to reliably intercept the crash due to high resolution, so we simply avoid it - if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) { - throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR); - } - - this.exec('Image', 'downsize', opts.width, opts.height, opts.crop, opts.preserveHeaders); - } catch(ex) { - // for now simply trigger error event - this.trigger('error', ex.code); - } + this.resize(opts); }, /** @@ -5810,13 +6403,11 @@ define("moxie/image/Image", [ if (!Env.can('create_canvas')) { throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR); } - - var runtime = this.connectRuntime(this.ruid); - return runtime.exec.call(this, 'Image', 'getAsCanvas'); + return this.exec('Image', 'getAsCanvas'); }, /** - Retrieves image in it's current state as mOxie.Blob object. Cannot be run on empty or image in progress (throws + Retrieves image in it's current state as moxie.file.Blob object. Cannot be run on empty or image in progress (throws DOMException.INVALID_STATE_ERR). @method getAsBlob @@ -5868,24 +6459,27 @@ define("moxie/image/Image", [ @method embed @param {DOMElement} el DOM element to insert the image object into - @param {Object} [opts] - @param {Number} [opts.width] The width of an embed (defaults to the image width) - @param {Number} [opts.height] The height of an embed (defaults to the image height) - @param {String} [type="image/jpeg"] Mime type - @param {Number} [quality=90] Quality of an embed, if mime type is image/jpeg - @param {Boolean} [crop=false] Whether to crop an embed to the specified dimensions + @param {Object} [options] + @param {Number} [options.width] The width of an embed (defaults to the image width) + @param {Number} [options.height] The height of an embed (defaults to the image height) + @param {String} [options.type="image/jpeg"] Mime type + @param {Number} [options.quality=90] Quality of an embed, if mime type is image/jpeg + @param {Boolean} [options.crop=false] Whether to crop an embed to the specified dimensions + @param {Boolean} [options.fit=true] By default thumbs will be up- or downscaled as necessary to fit the dimensions */ - embed: function(el, opts) { + embed: function(el, options) { var self = this , runtime // this has to be outside of all the closures to contain proper runtime ; - opts = Basic.extend({ + var opts = Basic.extend({ width: this.width, height: this.height, type: this.type || 'image/jpeg', - quality: 90 - }, opts || {}); + quality: 90, + fit: true, + resample: 'nearest' + }, options); function render(type, quality) { @@ -5909,7 +6503,7 @@ define("moxie/image/Image", [ } if (Env.can('use_data_uri_of', dataUrl.length)) { - el.innerHTML = ''; + el.innerHTML = ''; img.destroy(); self.trigger('embedded'); } else { @@ -5975,7 +6569,7 @@ define("moxie/image/Image", [ }); imgCopy.bind("Load", function() { - imgCopy.downsize(opts); + this.downsize(opts); }); // if embedded thumb data is available and dimensions are big enough, use it @@ -5993,7 +6587,8 @@ define("moxie/image/Image", [ }, /** - Properly destroys the image and frees resources in use. If any. Recommended way to dispose mOxie.Image object. + Properly destroys the image and frees resources in use. If any. Recommended way to dispose + moxie.image.Image object. @method destroy */ @@ -6002,6 +6597,10 @@ define("moxie/image/Image", [ this.getRuntime().exec.call(this, 'Image', 'destroy'); this.disconnectRuntime(); } + if (this.meta && this.meta.thumb) { + // thumb is blob, make sure we destroy it first + this.meta.thumb.data.destroy(); + } this.unbindAll(); } }); @@ -6011,24 +6610,31 @@ define("moxie/image/Image", [ this.handleEventProps(dispatches); this.bind('Load Resize', function() { - _updateInfo.call(this); + return _updateInfo.call(this); // if operation fails (e.g. image is neither PNG nor JPEG) cancel all pending events }, 999); function _updateInfo(info) { - if (!info) { - info = this.exec('Image', 'getInfo'); - } + try { + if (!info) { + info = this.exec('Image', 'getInfo'); + } - this.size = info.size; - this.width = info.width; - this.height = info.height; - this.type = info.type; - this.meta = info.meta; + this.size = info.size; + this.width = info.width; + this.height = info.height; + this.type = info.type; + this.meta = info.meta; + + // update file name, only if empty + if (this.name === '') { + this.name = info.name; + } - // update file name, only if empty - if (this.name === '') { - this.name = info.name; + return true; + } catch(ex) { + this.trigger('error', ex.code); + return false; } } @@ -6186,9 +6792,9 @@ define("moxie/runtime/html5/Runtime", [ "moxie/runtime/Runtime", "moxie/core/utils/Env" ], function(Basic, x, Runtime, Env) { - + var type = "html5", extensions = {}; - + function Html5Runtime(options) { var I = this , Test = Runtime.capTest @@ -6200,25 +6806,31 @@ define("moxie/runtime/html5/Runtime", [ access_image_binary: function() { return I.can('access_binary') && !!extensions.Image; }, - display_media: Test(Env.can('create_canvas') || Env.can('use_data_uri_over32kb')), + display_media: Test( + (Env.can('create_canvas') || Env.can('use_data_uri_over32kb')) && + defined('moxie/image/Image') + ), do_cors: Test(window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()), drag_and_drop: Test(function() { // this comes directly from Modernizr: http://www.modernizr.com/ var div = document.createElement('div'); // IE has support for drag and drop since version 5, but doesn't support dropping files from desktop - return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && + return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && (Env.browser !== 'IE' || Env.verComp(Env.version, 9, '>')); }()), filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest - return (Env.browser === 'Chrome' && Env.verComp(Env.version, 28, '>=')) || - (Env.browser === 'IE' && Env.verComp(Env.version, 10, '>=')) || - (Env.browser === 'Safari' && Env.verComp(Env.version, 7, '>=')); + return !( + (Env.browser === 'Chrome' && Env.verComp(Env.version, 28, '<')) || + (Env.browser === 'IE' && Env.verComp(Env.version, 10, '<')) || + (Env.browser === 'Safari' && Env.verComp(Env.version, 7, '<')) || + (Env.browser === 'Firefox' && Env.verComp(Env.version, 37, '<')) + ); }()), return_response_headers: True, return_response_type: function(responseType) { if (responseType === 'json' && !!window.JSON) { // we can fake this one even if it's not supported return true; - } + } return Env.can('return_response_type', responseType); }, return_status_code: True, @@ -6230,7 +6842,10 @@ define("moxie/runtime/html5/Runtime", [ return Env.can('use_fileinput') && window.File; }, select_folder: function() { - return I.can('select_file') && Env.browser === 'Chrome' && Env.verComp(Env.version, 21, '>='); + return I.can('select_file') && ( + Env.browser === 'Chrome' && Env.verComp(Env.version, 21, '>=') || + Env.browser === 'Firefox' && Env.verComp(Env.version, 42, '>=') // https://developer.mozilla.org/en-US/Firefox/Releases/42 + ); }, select_multiple: function() { // it is buggy on Safari Windows and iOS @@ -6248,15 +6863,15 @@ define("moxie/runtime/html5/Runtime", [ return I.can('slice_blob') && I.can('send_multipart'); }, summon_file_dialog: function() { // yeah... some dirty sniffing here... - return I.can('select_file') && ( - (Env.browser === 'Firefox' && Env.verComp(Env.version, 4, '>=')) || - (Env.browser === 'Opera' && Env.verComp(Env.version, 12, '>=')) || - (Env.browser === 'IE' && Env.verComp(Env.version, 10, '>=')) || - !!~Basic.inArray(Env.browser, ['Chrome', 'Safari']) + return I.can('select_file') && !( + (Env.browser === 'Firefox' && Env.verComp(Env.version, 4, '<')) || + (Env.browser === 'Opera' && Env.verComp(Env.version, 12, '<')) || + (Env.browser === 'IE' && Env.verComp(Env.version, 10, '<')) ); }, - upload_filesize: True - }, + upload_filesize: True, + use_http_method: True + }, arguments[2] ); @@ -6285,6 +6900,59 @@ define("moxie/runtime/html5/Runtime", [ return extensions; }); +// Included from: src/javascript/runtime/html5/file/Blob.js + +/** + * Blob.js + * + * Copyright 2013, Moxiecode Systems AB + * Released under GPL License. + * + * License: http://www.plupload.com/license + * Contributing: http://www.plupload.com/contributing + */ + +/** +@class moxie/runtime/html5/file/Blob +@private +*/ +define("moxie/runtime/html5/file/Blob", [ + "moxie/runtime/html5/Runtime", + "moxie/file/Blob" +], function(extensions, Blob) { + + function HTML5Blob() { + function w3cBlobSlice(blob, start, end) { + var blobSlice; + + if (window.File.prototype.slice) { + try { + blob.slice(); // depricated version will throw WRONG_ARGUMENTS_ERR exception + return blob.slice(start, end); + } catch (e) { + // depricated slice method + return blob.slice(start, end - start); + } + // slice method got prefixed: https://bugzilla.mozilla.org/show_bug.cgi?id=649672 + } else if ((blobSlice = window.File.prototype.webkitSlice || window.File.prototype.mozSlice)) { + return blobSlice.call(blob, start, end); + } else { + return null; // or throw some exception + } + } + + this.slice = function() { + return new Blob(this.getRuntime().uid, w3cBlobSlice.apply(this, arguments)); + }; + + this.destroy = function() { + this.getRuntime().getShim().removeInstance(this.uid); + }; + } + + return (extensions.Blob = HTML5Blob); +}); + // Included from: src/javascript/core/utils/Events.js /** @@ -6297,11 +6965,17 @@ define("moxie/runtime/html5/Runtime", [ * Contributing: http://www.plupload.com/contributing */ +/** +@class moxie/core/utils/Events +@public +@static +*/ + define('moxie/core/utils/Events', [ 'moxie/core/utils/Basic' ], function(Basic) { var eventhash = {}, uid = 'moxie_' + Basic.guid(); - + // IE W3C like event funcs function preventDefault() { this.returnValue = false; @@ -6314,9 +6988,8 @@ define('moxie/core/utils/Events', [ /** Adds an event handler to the specified object and store reference to the handler in objects internal Plupload registry (@see removeEvent). - + @method addEvent - @for Utils @static @param {Object} obj DOM element like object to add handler to. @param {String} name Name to add event listener to. @@ -6325,13 +6998,13 @@ define('moxie/core/utils/Events', [ */ var addEvent = function(obj, name, callback, key) { var func, events; - + name = name.toLowerCase(); // Add event listener if (obj.addEventListener) { func = callback; - + obj.addEventListener(name, func, false); } else if (obj.attachEvent) { func = function() { @@ -6349,34 +7022,34 @@ define('moxie/core/utils/Events', [ obj.attachEvent('on' + name, func); } - + // Log event handler to objects internal mOxie registry if (!obj[uid]) { obj[uid] = Basic.guid(); } - + if (!eventhash.hasOwnProperty(obj[uid])) { eventhash[obj[uid]] = {}; } - + events = eventhash[obj[uid]]; - + if (!events.hasOwnProperty(name)) { events[name] = []; } - + events[name].push({ func: func, orig: callback, // store original callback for IE key: key }); }; - - + + /** Remove event handler from the specified object. If third argument (callback) is not specified remove all events with the specified name. - + @method removeEvent @static @param {Object} obj DOM element to remove event listener(s) from. @@ -6385,15 +7058,15 @@ define('moxie/core/utils/Events', [ */ var removeEvent = function(obj, name, callback) { var type, undef; - + name = name.toLowerCase(); - + if (obj[uid] && eventhash[obj[uid]] && eventhash[obj[uid]][name]) { type = eventhash[obj[uid]][name]; } else { return; } - + for (var i = type.length - 1; i >= 0; i--) { // undefined or not, key should match if (type[i].orig === callback || type[i].key === callback) { @@ -6402,27 +7075,27 @@ define('moxie/core/utils/Events', [ } else if (obj.detachEvent) { obj.detachEvent('on'+name, type[i].func); } - + type[i].orig = null; type[i].func = null; type.splice(i, 1); - + // If callback was passed we are done here, otherwise proceed if (callback !== undef) { break; } } } - + // If event array got empty, remove it if (!type.length) { delete eventhash[obj[uid]][name]; } - + // If mOxie registry has become empty, remove it if (Basic.isEmptyObj(eventhash[obj[uid]])) { delete eventhash[obj[uid]]; - + // IE doesn't let you remove DOM object property with - delete try { delete obj[uid]; @@ -6431,21 +7104,21 @@ define('moxie/core/utils/Events', [ } } }; - - + + /** Remove all kind of events from the specified object - + @method removeAllEvents @static @param {Object} obj DOM element to remove event listeners from. @param {String} [key] unique key to match, when removing events. */ - var removeAllEvents = function(obj, key) { + var removeAllEvents = function(obj, key) { if (!obj || !obj[uid]) { return; } - + Basic.each(eventhash[obj[uid]], function(events, name) { removeEvent(obj, name, key); }); @@ -6483,9 +7156,9 @@ define("moxie/runtime/html5/file/FileInput", [ "moxie/core/utils/Mime", "moxie/core/utils/Env" ], function(extensions, File, Basic, Dom, Events, Mime, Env) { - + function FileInput() { - var _options; + var _options, _browseBtnZIndex; // save original z-index Basic.extend(this, { init: function(options) { @@ -6494,12 +7167,12 @@ define("moxie/runtime/html5/file/FileInput", [ _options = options; // figure out accept string - mimes = _options.accept.mimes || Mime.extList2mimes(_options.accept, I.can('filter_by_extension')); + mimes = Mime.extList2mimes(_options.accept, I.can('filter_by_extension')); shimContainer = I.getShimContainer(); shimContainer.innerHTML = ''; @@ -6516,6 +7189,7 @@ define("moxie/runtime/html5/file/FileInput", [ browseButton = Dom.get(_options.browse_button); + _browseBtnZIndex = Dom.getStyle(browseButton, 'z-index') || 'auto'; // Route click event to the input[type=file] element for browsers that support such behavior if (I.can('summon_file_dialog')) { @@ -6523,11 +7197,6 @@ define("moxie/runtime/html5/file/FileInput", [ browseButton.style.position = 'relative'; } - zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 1; - - browseButton.style.zIndex = zIndex; - shimContainer.style.zIndex = zIndex - 1; - Events.addEvent(browseButton, 'click', function(e) { var input = Dom.get(I.uid); if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file] @@ -6535,6 +7204,13 @@ define("moxie/runtime/html5/file/FileInput", [ } e.preventDefault(); }, comp.uid); + + comp.bind('Refresh', function() { + zIndex = parseInt(_browseBtnZIndex, 10) || 1; + + Dom.get(_options.browse_button).style.zIndex = zIndex; + this.getRuntime().getShimContainer().style.zIndex = zIndex - 1; + }); } /* Since we have to place input[type=file] on top of the browse_button for some browsers, @@ -6557,8 +7233,10 @@ define("moxie/runtime/html5/file/FileInput", [ comp.trigger('mouseup'); }, comp.uid); + // it shouldn't be possible to tab into the hidden element + (I.can('summon_file_dialog') ? input : browseButton).setAttribute('tabindex', -1); - input.onchange = function onChange(e) { // there should be only one handler for this + input.onchange = function onChange() { // there should be only one handler for this comp.files = []; Basic.each(this.files, function(file) { @@ -6575,7 +7253,7 @@ define("moxie/runtime/html5/file/FileInput", [ if (file.webkitRelativePath) { relativePath = '/' + file.webkitRelativePath.replace(/^\//, ''); } - + file = new File(I.uid, file); file.relativePath = relativePath; @@ -6607,6 +7285,41 @@ define("moxie/runtime/html5/file/FileInput", [ }, + setOption: function(name, value) { + var I = this.getRuntime(); + var input = Dom.get(I.uid); + + switch (name) { + case 'accept': + if (value) { + var mimes = value.mimes || Mime.extList2mimes(value, I.can('filter_by_extension')); + input.setAttribute('accept', mimes.join(',')); + } else { + input.removeAttribute('accept'); + } + break; + + case 'directory': + if (value && I.can('select_folder')) { + input.setAttribute('directory', ''); + input.setAttribute('webkitdirectory', ''); + } else { + input.removeAttribute('directory'); + input.removeAttribute('webkitdirectory'); + } + break; + + case 'multiple': + if (value && I.can('select_multiple')) { + input.setAttribute('multiple', ''); + } else { + input.removeAttribute('multiple'); + } + + } + }, + + disable: function(state) { var I = this.getRuntime(), input; @@ -6619,73 +7332,32 @@ define("moxie/runtime/html5/file/FileInput", [ var I = this.getRuntime() , shim = I.getShim() , shimContainer = I.getShimContainer() + , container = _options && Dom.get(_options.container) + , browseButton = _options && Dom.get(_options.browse_button) ; - - Events.removeAllEvents(shimContainer, this.uid); - Events.removeAllEvents(_options && Dom.get(_options.container), this.uid); - Events.removeAllEvents(_options && Dom.get(_options.browse_button), this.uid); - - if (shimContainer) { - shimContainer.innerHTML = ''; + + if (container) { + Events.removeAllEvents(container, this.uid); } - - shim.removeInstance(this.uid); - - _options = shimContainer = shim = null; - } - }); - } - - return (extensions.FileInput = FileInput); -}); - -// Included from: src/javascript/runtime/html5/file/Blob.js - -/** - * Blob.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/html5/file/Blob -@private -*/ -define("moxie/runtime/html5/file/Blob", [ - "moxie/runtime/html5/Runtime", - "moxie/file/Blob" -], function(extensions, Blob) { - - function HTML5Blob() { - function w3cBlobSlice(blob, start, end) { - var blobSlice; - - if (window.File.prototype.slice) { - try { - blob.slice(); // depricated version will throw WRONG_ARGUMENTS_ERR exception - return blob.slice(start, end); - } catch (e) { - // depricated slice method - return blob.slice(start, end - start); + + if (browseButton) { + Events.removeAllEvents(browseButton, this.uid); + browseButton.style.zIndex = _browseBtnZIndex; // reset to original value + } + + if (shimContainer) { + Events.removeAllEvents(shimContainer, this.uid); + shimContainer.innerHTML = ''; } - // slice method got prefixed: https://bugzilla.mozilla.org/show_bug.cgi?id=649672 - } else if ((blobSlice = window.File.prototype.webkitSlice || window.File.prototype.mozSlice)) { - return blobSlice.call(blob, start, end); - } else { - return null; // or throw some exception - } - } - this.slice = function() { - return new Blob(this.getRuntime().uid, w3cBlobSlice.apply(this, arguments)); - }; + shim.removeInstance(this.uid); + + _options = shimContainer = container = browseButton = shim = null; + } + }); } - return (extensions.Blob = HTML5Blob); + return (extensions.FileInput = FileInput); }); // Included from: src/javascript/runtime/html5/file/FileDrop.js @@ -6712,7 +7384,7 @@ define("moxie/runtime/html5/file/FileDrop", [ "moxie/core/utils/Events", "moxie/core/utils/Mime" ], function(extensions, File, Basic, Dom, Events, Mime) { - + function FileDrop() { var _files = [], _allowedExts = [], _options, _ruid; @@ -6768,6 +7440,7 @@ define("moxie/runtime/html5/file/FileDrop", [ destroy: function() { Events.removeAllEvents(_options && Dom.get(_options.container), this.uid); _ruid = _files = _allowedExts = _options = null; + this.getRuntime().getShim().removeInstance(this.uid); } }); @@ -6794,7 +7467,7 @@ define("moxie/runtime/html5/file/FileDrop", [ } } - + function _extractExts(accept) { var exts = []; for (var i = 0; i < accept.length; i++) { @@ -6884,7 +7557,7 @@ define("moxie/runtime/html5/file/FileDrop", [ // ...and you thought FileReader was crazy... getEntries(function() { _readEntries(entries, cb); - }); + }); } } @@ -6912,7 +7585,7 @@ define("moxie/runtime/html5/file/FileReader", [ "moxie/core/utils/Encode", "moxie/core/utils/Basic" ], function(extensions, Encode, Basic) { - + function FileReader() { var _fr, _convertToBinary = false; @@ -6960,6 +7633,7 @@ define("moxie/runtime/html5/file/FileReader", [ destroy: function() { _fr = null; + this.getRuntime().getShim().removeInstance(this.uid); } }); @@ -7000,7 +7674,7 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ "moxie/core/Exceptions", "moxie/core/utils/Env" ], function(extensions, Basic, Mime, Url, File, Blob, FormData, x, Env) { - + function XMLHttpRequest() { var self = this , _xhr @@ -7039,7 +7713,7 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ // Android browsers (default one and Dolphin) seem to have the same issue, see: #613 _preloadAndSend.call(target, meta, data); return; // _preloadAndSend will reinvoke send() with transmutated FormData =%D - } + } } // transfer fields to real FormData @@ -7086,22 +7760,22 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ // ... otherwise simulate XHR L2 } else { _xhr.onreadystatechange = function onReadyStateChange() { - + // fake Level 2 events switch (_xhr.readyState) { - + case 1: // XMLHttpRequest.OPENED // readystatechanged is fired twice for OPENED state (in IE and Mozilla) - neu break; - + // looks like HEADERS_RECEIVED (state 2) is not reported in Opera (or it's old versions) - neu case 2: // XMLHttpRequest.HEADERS_RECEIVED break; - - case 3: // XMLHttpRequest.LOADING + + case 3: // XMLHttpRequest.LOADING // try to fire progress event for not XHR L2 var total, loaded; - + try { if (Url.hasSameOrigin(meta.url)) { // Content-Length not accessible for cross-domain on some browsers total = _xhr.getResponseHeader('Content-Length') || 0; // old Safari throws an exception here @@ -7121,22 +7795,25 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ loaded: loaded }); break; - + case 4: // XMLHttpRequest.DONE // release readystatechange handler (mostly for IE) _xhr.onreadystatechange = function() {}; // usually status 0 is returned when server is unreachable, but FF also fails to status 0 for 408 timeout - if (_xhr.status === 0) { - target.trigger('error'); - } else { - target.trigger('load'); - } + try { + if (_xhr.status >= 200 && _xhr.status < 400) { + target.trigger('load'); + break; + } + } catch(ex) {} + + target.trigger('error'); break; } }; } - + // set request headers if (!Basic.isEmptyObj(meta.headers)) { @@ -7192,8 +7869,8 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ switch (responseType) { case 'blob': var file = new File(I.uid, _xhr.response); - - // try to extract file name from content-disposition if possible (might be - not, if CORS for example) + + // try to extract file name from content-disposition if possible (might be - not, if CORS for example) var disposition = _xhr.getResponseHeader('Content-Disposition'); if (disposition) { // extract filename from response header if available @@ -7224,7 +7901,7 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ } } catch(ex) { return null; - } + } }, getAllResponseHeaders: function() { @@ -7242,6 +7919,7 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ destroy: function() { self = _filename = null; + this.getRuntime().getShim().removeInstance(this.uid); } }); @@ -7249,10 +7927,10 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ // here we go... ugly fix for ugly bug function _preloadAndSend(meta, data) { var target = this, blob, fr; - + // get original blob blob = data.getBlob().getSource(); - + // preload blob in memory to be sent as binary string fr = new window.FileReader(); fr.onload = function() { @@ -7267,7 +7945,7 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ fr.readAsBinaryString(blob); } - + function _getNativeXHR() { if (window.XMLHttpRequest && !(Env.browser === 'IE' && Env.verComp(Env.version, 8, '<'))) { // IE7 has native XHR but it's buggy return new window.XMLHttpRequest(); @@ -7282,12 +7960,12 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ })(); } } - + // @credits Sergey Ilinsky (http://www.ilinsky.com/) function _getDocument(xhr) { var rXML = xhr.responseXML; var rText = xhr.responseText; - + // Try parsing responseText (@see: http://www.ilinsky.com/articles/XMLHttpRequest/#bugs-ie-responseXML-content-type) if (Env.browser === 'IE' && rText && rXML && !rXML.documentElement && /[^\/]+\/[^\+]+\+xml/.test(xhr.getResponseHeader("Content-Type"))) { rXML = new window.ActiveXObject("Microsoft.XMLDOM"); @@ -7295,7 +7973,7 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ rXML.validateOnParse = false; rXML.loadXML(rText); } - + // Check if there is no error in document if (rXML) { if ((Env.browser === 'IE' && rXML.parseError !== 0) || !rXML.documentElement || rXML.documentElement.tagName === "parsererror") { @@ -7322,7 +8000,7 @@ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ // append multipart parameters fd.each(function(value, name) { - // Firefox 3.6 failed to convert multibyte characters to UTF-8 in sendAsBinary(), + // Firefox 3.6 failed to convert multibyte characters to UTF-8 in sendAsBinary(), // so we try it here ourselves with: unescape(encodeURIComponent(value)) if (value instanceof Blob) { // Build RFC2388 blob @@ -7366,7 +8044,7 @@ define("moxie/runtime/html5/utils/BinaryReader", [ "moxie/core/utils/Basic" ], function(Basic) { - + function BinaryReader(data) { if (data instanceof ArrayBuffer) { ArrayBufferReader.apply(this, arguments); @@ -7374,10 +8052,9 @@ define("moxie/runtime/html5/utils/BinaryReader", [ UTF16StringReader.apply(this, arguments); } } -   Basic.extend(BinaryReader.prototype, { - + littleEndian: false, @@ -7387,9 +8064,9 @@ define("moxie/runtime/html5/utils/BinaryReader", [ if (idx + size > this.length()) { throw new Error("You are trying to read outside the source boundaries."); } - - mv = this.littleEndian - ? 0 + + mv = this.littleEndian + ? 0 : -8 * (size - 1) ; @@ -7407,8 +8084,8 @@ define("moxie/runtime/html5/utils/BinaryReader", [ throw new Error("You are trying to write outside the source boundaries."); } - mv = this.littleEndian - ? 0 + mv = this.littleEndian + ? 0 : -8 * (size - 1) ; @@ -7464,7 +8141,7 @@ define("moxie/runtime/html5/utils/BinaryReader", [ var _dv = new DataView(data); Basic.extend(this, { - + readByteAt: function(idx) { return _dv.getUint8(idx); }, @@ -7473,7 +8150,7 @@ define("moxie/runtime/html5/utils/BinaryReader", [ writeByteAt: function(idx, value) { _dv.setUint8(idx, value); }, - + SEGMENT: function(idx, size, value) { switch (arguments.length) { @@ -7488,7 +8165,7 @@ define("moxie/runtime/html5/utils/BinaryReader", [ value = new ArrayBuffer(); } - if (value instanceof ArrayBuffer) { + if (value instanceof ArrayBuffer) { var arr = new Uint8Array(this.length() - size + value.byteLength); if (idx > 0) { arr.set(new Uint8Array(data.slice(0, idx)), 0); @@ -7521,7 +8198,7 @@ define("moxie/runtime/html5/utils/BinaryReader", [ function UTF16StringReader(data) { Basic.extend(this, { - + readByteAt: function(idx) { return data.charCodeAt(idx); }, @@ -7548,7 +8225,7 @@ define("moxie/runtime/html5/utils/BinaryReader", [ length: function() { return data ? data.length : 0; - }, + }, clear: function() { data = null; @@ -7577,7 +8254,7 @@ define("moxie/runtime/html5/utils/BinaryReader", [ * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ - + /** @class moxie/runtime/html5/image/JPEGHeaders @private @@ -7586,7 +8263,7 @@ define("moxie/runtime/html5/image/JPEGHeaders", [ "moxie/runtime/html5/utils/BinaryReader", "moxie/core/Exceptions" ], function(BinaryReader, x) { - + return function JPEGHeaders(data) { var headers = [], _br, idx, marker, length = 0; @@ -7665,7 +8342,7 @@ define("moxie/runtime/html5/image/JPEGHeaders", [ while (i--) { br.SEGMENT(headers[i].start, headers[i].length, ''); } - + data = br.SEGMENT(); br.clear(); return data; @@ -7731,10 +8408,10 @@ define("moxie/runtime/html5/image/ExifParser", [ "moxie/runtime/html5/utils/BinaryReader", "moxie/core/Exceptions" ], function(Basic, BinaryReader, x) { - + function ExifParser(data) { var __super__, tags, tagDescs, offsets, idx, Tiff; - + BinaryReader.call(this, data); tags = { @@ -7912,7 +8589,7 @@ define("moxie/runtime/html5/image/ExifParser", [ offsets = { tiffHeader: 10 }; - + idx = offsets.tiffHeader; __super__ = { @@ -7921,7 +8598,7 @@ define("moxie/runtime/html5/image/ExifParser", [ // Public functions Basic.extend(this, { - + read: function() { try { return ExifParser.prototype.read.apply(this, arguments); @@ -8010,7 +8687,7 @@ define("moxie/runtime/html5/image/ExifParser", [ if (offsets.IFD1) { try { var IFD1Tags = extractTags.call(this, offsets.IFD1, tags.thumb); - + if ('JPEGInterchangeFormat' in IFD1Tags) { return this.SEGMENT(offsets.tiffHeader + IFD1Tags.JPEGInterchangeFormat, IFD1Tags.JPEGInterchangeFormatLength); } @@ -8075,7 +8752,7 @@ define("moxie/runtime/html5/image/ExifParser", [ function extractTags(IFD_offset, tags2extract) { var data = this; var length, i, tag, type, count, size, offset, value, values = [], hash = {}; - + var types = { 1 : 'BYTE', 7 : 'UNDEFINED', @@ -8133,12 +8810,12 @@ define("moxie/runtime/html5/image/ExifParser", [ // in case we left the boundaries of data throw an early exception if (offset + size * count >= this.length()) { throw new x.ImageError(x.ImageError.INVALID_META_ERR); - } + } // special care for the string if (type === 'ASCII') { hash[tag] = Basic.trim(data.STRING(offset, count).replace(/\0$/, '')); // strip trailing NULL - + continue; } else { values = data.asArray(type, offset, count); value = (count == 1 ? values[0] : values); @@ -8222,7 +8899,7 @@ define("moxie/runtime/html5/image/JPEG", [ "moxie/runtime/html5/utils/BinaryReader", "moxie/runtime/html5/image/ExifParser" ], function(Basic, x, JPEGHeaders, BinaryReader, ExifParser) { - + function JPEG(data) { var _br, _hm, _ep, _info; @@ -8346,7 +9023,7 @@ define("moxie/runtime/html5/image/JPEG", [ function _purge() { - if (!_ep || !_hm || !_br) { + if (!_ep || !_hm || !_br) { return; // ignore any repeating purge requests } _ep.clear(); @@ -8380,7 +9057,7 @@ define("moxie/runtime/html5/image/PNG", [ "moxie/core/utils/Basic", "moxie/runtime/html5/utils/BinaryReader" ], function(x, Basic, BinaryReader) { - + function PNG(data) { var _br, _hm, _ep, _info; @@ -8474,8 +9151,16 @@ define("moxie/runtime/html5/image/PNG", [ */ /** +Optional image investigation tool for HTML5 runtime. Provides the following features: +- ability to distinguish image type (JPEG or PNG) by signature +- ability to extract image width/height directly from it's internals, without preloading in memory (fast) +- ability to extract APP headers from JPEGs (Exif, GPS, etc) +- ability to replace width/height tags in extracted JPEG headers +- ability to restore APP headers, that were for example stripped during image manipulation + @class moxie/runtime/html5/image/ImageInfo @private +@param {String} data Image source as binary string */ define("moxie/runtime/html5/image/ImageInfo", [ "moxie/core/utils/Basic", @@ -8483,18 +9168,7 @@ define("moxie/runtime/html5/image/ImageInfo", [ "moxie/runtime/html5/image/JPEG", "moxie/runtime/html5/image/PNG" ], function(Basic, x, JPEG, PNG) { - /** - Optional image investigation tool for HTML5 runtime. Provides the following features: - - ability to distinguish image type (JPEG or PNG) by signature - - ability to extract image width/height directly from it's internals, without preloading in memory (fast) - - ability to extract APP headers from JPEGs (Exif, GPS, etc) - - ability to replace width/height tags in extracted JPEG headers - - ability to restore APP headers, that were for example stripped during image manipulation - - @class ImageInfo - @constructor - @param {String} data Image source as binary string - */ + return function(data) { var _cs = [JPEG, PNG], _img; @@ -8597,141 +9271,62 @@ define("moxie/runtime/html5/image/ImageInfo", [ }; }); -// Included from: src/javascript/runtime/html5/image/MegaPixel.js +// Included from: src/javascript/runtime/html5/image/ResizerCanvas.js /** -(The MIT License) - -Copyright (c) 2012 Shinichi Tomita ; - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -/** - * Mega pixel image rendering library for iOS6 Safari + * ResizerCanvas.js * - * Fixes iOS6 Safari's image file rendering issue for large size image (over mega-pixel), - * which causes unexpected subsampling when drawing it in canvas. - * By using this library, you can safely render the image with proper stretching. + * Copyright 2013, Moxiecode Systems AB + * Released under GPL License. * - * Copyright (c) 2012 Shinichi Tomita - * Released under the MIT license + * License: http://www.plupload.com/license + * Contributing: http://www.plupload.com/contributing */ /** -@class moxie/runtime/html5/image/MegaPixel -@private -*/ -define("moxie/runtime/html5/image/MegaPixel", [], function() { + * Resizes image/canvas using canvas + */ +define("moxie/runtime/html5/image/ResizerCanvas", [], function() { - /** - * Rendering image element (with resizing) into the canvas element - */ - function renderImageToCanvas(img, canvas, options) { - var iw = img.naturalWidth, ih = img.naturalHeight; - var width = options.width, height = options.height; - var x = options.x || 0, y = options.y || 0; - var ctx = canvas.getContext('2d'); - if (detectSubsampling(img)) { - iw /= 2; - ih /= 2; - } - var d = 1024; // size of tiling canvas - var tmpCanvas = document.createElement('canvas'); - tmpCanvas.width = tmpCanvas.height = d; - var tmpCtx = tmpCanvas.getContext('2d'); - var vertSquashRatio = detectVerticalSquash(img, iw, ih); - var sy = 0; - while (sy < ih) { - var sh = sy + d > ih ? ih - sy : d; - var sx = 0; - while (sx < iw) { - var sw = sx + d > iw ? iw - sx : d; - tmpCtx.clearRect(0, 0, d, d); - tmpCtx.drawImage(img, -sx, -sy); - var dx = (sx * width / iw + x) << 0; - var dw = Math.ceil(sw * width / iw); - var dy = (sy * height / ih / vertSquashRatio + y) << 0; - var dh = Math.ceil(sh * height / ih / vertSquashRatio); - ctx.drawImage(tmpCanvas, 0, 0, sw, sh, dx, dy, dw, dh); - sx += d; - } - sy += d; - } - tmpCanvas = tmpCtx = null; - } + function scale(image, ratio, resample) { + var sD = image.width > image.height ? 'width' : 'height'; // take the largest side + var dD = Math.round(image[sD] * ratio); + var scaleCapped = false; - /** - * Detect subsampling in loaded image. - * In iOS, larger images than 2M pixels may be subsampled in rendering. - */ - function detectSubsampling(img) { - var iw = img.naturalWidth, ih = img.naturalHeight; - if (iw * ih > 1024 * 1024) { // subsampling may happen over megapixel image - var canvas = document.createElement('canvas'); - canvas.width = canvas.height = 1; - var ctx = canvas.getContext('2d'); - ctx.drawImage(img, -iw + 1, 0); - // subsampled image becomes half smaller in rendering size. - // check alpha channel value to confirm image is covering edge pixel or not. - // if alpha value is 0 image is not covering, hence subsampled. - return ctx.getImageData(0, 0, 1, 1).data[3] === 0; - } else { - return false; - } - } + if (resample !== 'nearest' && (ratio < 0.5 || ratio > 2)) { + ratio = ratio < 0.5 ? 0.5 : 2; + scaleCapped = true; + } + var tCanvas = _scale(image, ratio); - /** - * Detecting vertical squash in loaded image. - * Fixes a bug which squash image vertically while drawing into canvas for some images. - */ - function detectVerticalSquash(img, iw, ih) { - var canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = ih; - var ctx = canvas.getContext('2d'); - ctx.drawImage(img, 0, 0); - var data = ctx.getImageData(0, 0, 1, ih).data; - // search image edge pixel position in case it is squashed vertically. - var sy = 0; - var ey = ih; - var py = ih; - while (py > sy) { - var alpha = data[(py - 1) * 4 + 3]; - if (alpha === 0) { - ey = py; - } else { - sy = py; - } - py = (ey + sy) >> 1; - } - canvas = null; - var ratio = (py / ih); - return (ratio === 0) ? 1 : ratio; - } + if (scaleCapped) { + return scale(tCanvas, dD / tCanvas[sD], resample); + } else { + return tCanvas; + } + } + + + function _scale(image, ratio) { + var sW = image.width; + var sH = image.height; + var dW = Math.round(sW * ratio); + var dH = Math.round(sH * ratio); + + var canvas = document.createElement('canvas'); + canvas.width = dW; + canvas.height = dH; + canvas.getContext("2d").drawImage(image, 0, 0, sW, sH, 0, 0, dW, dH); + + image = null; // just in case + return canvas; + } + + return { + scale: scale + }; - return { - isSubsampled: detectSubsampling, - renderTo: renderImageToCanvas - }; }); // Included from: src/javascript/runtime/html5/image/Image.js @@ -8758,10 +9353,10 @@ define("moxie/runtime/html5/image/Image", [ "moxie/file/Blob", "moxie/file/File", "moxie/runtime/html5/image/ImageInfo", - "moxie/runtime/html5/image/MegaPixel", + "moxie/runtime/html5/image/ResizerCanvas", "moxie/core/utils/Mime", "moxie/core/utils/Env" -], function(extensions, Basic, x, Encode, Blob, File, ImageInfo, MegaPixel, Mime, Env) { +], function(extensions, Basic, x, Encode, Blob, File, ImageInfo, ResizerCanvas, Mime, Env) { function HTML5Image() { var me = this @@ -8772,7 +9367,7 @@ define("moxie/runtime/html5/image/Image", [ Basic.extend(this, { loadFromBlob: function(blob) { - var comp = this, I = comp.getRuntime() + var I = this.getRuntime() , asBinary = arguments.length > 1 ? arguments[1] : true ; @@ -8785,13 +9380,13 @@ define("moxie/runtime/html5/image/Image", [ if (blob.isDetached()) { _binStr = blob.getSource(); _preload.call(this, _binStr); - + return; } else { _readAsDataUrl.call(this, blob.getSource(), function(dataUrl) { if (asBinary) { _binStr = _toBinary(dataUrl); } - _preload.call(comp, dataUrl); + _preload.call(this, dataUrl); }); } }, @@ -8815,46 +9410,78 @@ define("moxie/runtime/html5/image/Image", [ _imgInfo = new ImageInfo(_binStr); } + // this stuff below is definitely having fun with itself info = { width: _getImg().width || 0, height: _getImg().height || 0, type: _blob.type || Mime.getFileMime(_blob.name), size: _binStr && _binStr.length || _blob.size || 0, name: _blob.name || '', - meta: _imgInfo && _imgInfo.meta || this.meta || {} + meta: null }; - // store thumbnail data as blob - if (info.meta && info.meta.thumb && !(info.meta.thumb.data instanceof Blob)) { - info.meta.thumb.data = new Blob(null, { - type: 'image/jpeg', - data: info.meta.thumb.data - }); + if (_preserveHeaders) { + info.meta = _imgInfo && _imgInfo.meta || this.meta || {}; + + // if data was taken from ImageInfo it will be a binary string, so we convert it to blob + if (info.meta && info.meta.thumb && !(info.meta.thumb.data instanceof Blob)) { + info.meta.thumb.data = new Blob(null, { + type: 'image/jpeg', + data: info.meta.thumb.data + }); + } } return info; }, - downsize: function() { - _downsize.apply(this, arguments); + + resize: function(rect, ratio, options) { + var canvas = document.createElement('canvas'); + canvas.width = rect.width; + canvas.height = rect.height; + + canvas.getContext("2d").drawImage(_getImg(), rect.x, rect.y, rect.width, rect.height, 0, 0, canvas.width, canvas.height); + + _canvas = ResizerCanvas.scale(canvas, ratio); + + _preserveHeaders = options.preserveHeaders; + + // rotate if required, according to orientation tag + if (!_preserveHeaders) { + var orientation = (this.meta && this.meta.tiff && this.meta.tiff.Orientation) || 1; + _canvas = _rotateToOrientaion(_canvas, orientation); + } + + this.width = _canvas.width; + this.height = _canvas.height; + + _modified = true; + + this.trigger('Resize'); }, getAsCanvas: function() { - if (_canvas) { - _canvas.id = this.uid + '_canvas'; + if (!_canvas) { + _canvas = _getCanvas(); } + _canvas.id = this.uid + '_canvas'; return _canvas; }, getAsBlob: function(type, quality) { if (type !== this.type) { - // if different mime type requested prepare image for conversion - _downsize.call(this, this.width, this.height, false); + _modified = true; // reconsider the state + return new File(null, { + name: _blob.name || '', + type: type, + data: me.getAsDataURL(type, quality) + }); } return new File(null, { name: _blob.name || '', type: type, - data: me.getAsBinaryString.call(this, type, quality) + data: me.getAsBinaryString(type, quality) }); }, @@ -8866,6 +9493,9 @@ define("moxie/runtime/html5/image/Image", [ return _img.src; } + // make sure we have a canvas to work with + _getCanvas(); + if ('image/jpeg' !== type) { return _canvas.toDataURL('image/png'); } else { @@ -8898,6 +9528,9 @@ define("moxie/runtime/html5/image/Image", [ quality = 90; } + // make sure we have a canvas to work with + _getCanvas(); + try { // older Geckos used to result in an exception on quality argument dataUrl = _canvas.toDataURL('image/jpeg', quality/100); @@ -8950,6 +9583,19 @@ define("moxie/runtime/html5/image/Image", [ } + function _getCanvas() { + var canvas = _getImg(); + if (canvas.nodeName.toLowerCase() == 'canvas') { + return canvas; + } + _canvas = document.createElement('canvas'); + _canvas.width = canvas.width; + _canvas.height = canvas.height; + _canvas.getContext("2d").drawImage(canvas, 0, 0); + return _canvas; + } + + function _toBinary(str) { return Encode.atob(str.substring(str.indexOf('base64,') + 7)); } @@ -8983,130 +9629,35 @@ define("moxie/runtime/html5/image/Image", [ if (window.FileReader) { fr = new FileReader(); fr.onload = function() { - callback(this.result); + callback.call(comp, this.result); }; fr.onerror = function() { comp.trigger('error', x.ImageError.WRONG_FORMAT); }; fr.readAsDataURL(file); } else { - return callback(file.getAsDataURL()); - } - } - - function _downsize(width, height, crop, preserveHeaders) { - var self = this - , scale - , mathFn - , x = 0 - , y = 0 - , img - , destWidth - , destHeight - , orientation - ; - - _preserveHeaders = preserveHeaders; // we will need to check this on export (see getAsBinaryString()) - - // take into account orientation tag - orientation = (this.meta && this.meta.tiff && this.meta.tiff.Orientation) || 1; - - if (Basic.inArray(orientation, [5,6,7,8]) !== -1) { // values that require 90 degree rotation - // swap dimensions - var tmp = width; - width = height; - height = tmp; - } - - img = _getImg(); - - // unify dimensions - if (!crop) { - scale = Math.min(width/img.width, height/img.height); - } else { - // one of the dimensions may exceed the actual image dimensions - we need to take the smallest value - width = Math.min(width, img.width); - height = Math.min(height, img.height); - - scale = Math.max(width/img.width, height/img.height); - } - - // we only downsize here - if (scale > 1 && !crop && preserveHeaders) { - this.trigger('Resize'); - return; - } - - // prepare canvas if necessary - if (!_canvas) { - _canvas = document.createElement("canvas"); - } - - // calculate dimensions of proportionally resized image - destWidth = Math.round(img.width * scale); - destHeight = Math.round(img.height * scale); - - // scale image and canvas - if (crop) { - _canvas.width = width; - _canvas.height = height; - - // if dimensions of the resulting image still larger than canvas, center it - if (destWidth > width) { - x = Math.round((destWidth - width) / 2); - } - - if (destHeight > height) { - y = Math.round((destHeight - height) / 2); - } - } else { - _canvas.width = destWidth; - _canvas.height = destHeight; - } - - // rotate if required, according to orientation tag - if (!_preserveHeaders) { - _rotateToOrientaion(_canvas.width, _canvas.height, orientation); - } - - _drawToCanvas.call(this, img, _canvas, -x, -y, destWidth, destHeight); - - this.width = _canvas.width; - this.height = _canvas.height; - - _modified = true; - self.trigger('Resize'); - } - - - function _drawToCanvas(img, canvas, x, y, w, h) { - if (Env.OS === 'iOS') { - // avoid squish bug in iOS6 - MegaPixel.renderTo(img, canvas, { width: w, height: h, x: x, y: y }); - } else { - var ctx = canvas.getContext('2d'); - ctx.drawImage(img, x, y, w, h); + return callback.call(this, file.getAsDataURL()); } } - /** * Transform canvas coordination according to specified frame size and orientation * Orientation value is from EXIF tag * @author Shinichi Tomita */ - function _rotateToOrientaion(width, height, orientation) { - switch (orientation) { - case 5: - case 6: - case 7: - case 8: - _canvas.width = height; - _canvas.height = width; - break; - default: - _canvas.width = width; - _canvas.height = height; + function _rotateToOrientaion(img, orientation) { + var RADIANS = Math.PI/180; + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + var width = img.width; + var height = img.height; + + if (Basic.inArray(orientation, [5,6,7,8]) > -1) { + canvas.width = height; + canvas.height = width; + } else { + canvas.width = width; + canvas.height = height; } /** @@ -9119,8 +9670,6 @@ define("moxie/runtime/html5/image/Image", [ 7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom. 8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom. */ - - var ctx = _canvas.getContext('2d'); switch (orientation) { case 2: // horizontal flip @@ -9130,7 +9679,7 @@ define("moxie/runtime/html5/image/Image", [ case 3: // 180 rotate left ctx.translate(width, height); - ctx.rotate(Math.PI); + ctx.rotate(180 * RADIANS); break; case 4: // vertical flip @@ -9139,26 +9688,29 @@ define("moxie/runtime/html5/image/Image", [ break; case 5: // vertical flip + 90 rotate right - ctx.rotate(0.5 * Math.PI); + ctx.rotate(90 * RADIANS); ctx.scale(1, -1); break; case 6: // 90 rotate right - ctx.rotate(0.5 * Math.PI); + ctx.rotate(90 * RADIANS); ctx.translate(0, -height); break; case 7: // horizontal flip + 90 rotate right - ctx.rotate(0.5 * Math.PI); + ctx.rotate(90 * RADIANS); ctx.translate(width, -height); ctx.scale(-1, 1); break; case 8: // 90 rotate left - ctx.rotate(-0.5 * Math.PI); + ctx.rotate(-90 * RADIANS); ctx.translate(-width, 0); break; } + + ctx.drawImage(img, 0, 0, width, height); + return canvas; } @@ -9167,6 +9719,7 @@ define("moxie/runtime/html5/image/Image", [ _imgInfo.purge(); _imgInfo = null; } + _binStr = _img = _canvas = _blob = null; _modified = false; } @@ -9202,7 +9755,7 @@ define("moxie/runtime/flash/Runtime", [ "moxie/core/Exceptions", "moxie/runtime/Runtime" ], function(Basic, Env, Dom, x, Runtime) { - + var type = 'flash', extensions = {}; /** @@ -9234,7 +9787,7 @@ define("moxie/runtime/flash/Runtime", [ Cross-browser SWF removal - Especially needed to safely and completely remove a SWF in Internet Explorer - Originated from SWFObject v2.2 + Originated from SWFObject v2.2 */ function removeSWF(id) { var obj = Dom.get(id); @@ -9272,9 +9825,6 @@ define("moxie/runtime/flash/Runtime", [ /** Constructor for the Flash Runtime - - @class FlashRuntime - @extends Runtime */ function FlashRuntime(options) { var I = this, initTimer; @@ -9288,7 +9838,7 @@ define("moxie/runtime/flash/Runtime", [ access_image_binary: function(value) { return value && I.mode === 'browser'; }, - display_media: Runtime.capTrue, + display_media: Runtime.capTest(defined('moxie/image/Image')), do_cors: Runtime.capTrue, drag_and_drop: false, report_upload_progress: function() { @@ -9299,7 +9849,7 @@ define("moxie/runtime/flash/Runtime", [ return_response_type: function(responseType) { if (responseType === 'json' && !!window.JSON) { return true; - } + } return !Basic.arrayDiff(responseType, ['', 'text', 'document']) || I.mode === 'browser'; }, return_status_code: function(code) { @@ -9330,7 +9880,7 @@ define("moxie/runtime/flash/Runtime", [ use_http_method: function(methods) { return !Basic.arrayDiff(methods, ['GET', 'POST']); } - }, { + }, { // capabilities that require specific mode access_binary: function(value) { return value ? 'browser' : 'client'; @@ -9356,6 +9906,9 @@ define("moxie/runtime/flash/Runtime", [ send_custom_headers: function(value) { return value ? 'browser' : 'client'; }, + slice_blob: function(value) { + return value ? 'browser' : 'client'; + }, stream_upload: function(value) { return value ? 'client' : 'browser'; }, @@ -9366,9 +9919,9 @@ define("moxie/runtime/flash/Runtime", [ // minimal requirement for Flash Player version - if (getShimVersion() < 10) { + if (getShimVersion() < 11.3) { if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tFlash didn't meet minimal version requirement (10)."); + Env.log("\tFlash didn't meet minimal version requirement (11.3)."); } this.mode = false; // with falsy mode, runtime won't operable, no matter what the mode was before @@ -9410,7 +9963,7 @@ define("moxie/runtime/flash/Runtime", [ html += 'width="100%" height="100%" style="outline:0">' + '' + - '' + + '' + '' + '' + ''; @@ -9430,7 +9983,7 @@ define("moxie/runtime/flash/Runtime", [ I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR)); if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tFlash failed to initialize within a specified period of time (typically 5s)."); + Env.log("\tFlash failed to initialize within a specified period of time (typically 5s)."); } } }, 5000); @@ -9454,10 +10007,10 @@ define("moxie/runtime/flash/Runtime", [ return extensions; }); -// Included from: src/javascript/runtime/flash/file/FileInput.js +// Included from: src/javascript/runtime/flash/file/Blob.js /** - * FileInput.js + * Blob.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -9467,44 +10020,46 @@ define("moxie/runtime/flash/Runtime", [ */ /** -@class moxie/runtime/flash/file/FileInput +@class moxie/runtime/flash/file/Blob @private */ -define("moxie/runtime/flash/file/FileInput", [ +define("moxie/runtime/flash/file/Blob", [ "moxie/runtime/flash/Runtime", - "moxie/file/File", - "moxie/core/utils/Basic" -], function(extensions, File, Basic) { + "moxie/file/Blob" +], function(extensions, Blob) { - var FileInput = { - init: function(options) { - var comp = this, I = this.getRuntime(); + var FlashBlob = { + slice: function(blob, start, end, type) { + var self = this.getRuntime(); - this.bind("Change", function() { - var files = I.shimExec.call(comp, 'FileInput', 'getFiles'); - comp.files = []; - Basic.each(files, function(file) { - comp.files.push(new File(I.uid, file)); - }); - }, 999); + if (start < 0) { + start = Math.max(blob.size + start, 0); + } else if (start > 0) { + start = Math.min(start, blob.size); + } - this.getRuntime().shimExec.call(this, 'FileInput', 'init', { - name: options.name, - accept: options.accept, - multiple: options.multiple - }); + if (end < 0) { + end = Math.max(blob.size + end, 0); + } else if (end > 0) { + end = Math.min(end, blob.size); + } - this.trigger('ready'); + blob = self.shimExec.call(this, 'Blob', 'slice', start, end, type || ''); + + if (blob) { + blob = new Blob(self.uid, blob); + } + return blob; } }; - return (extensions.FileInput = FileInput); + return (extensions.Blob = FlashBlob); }); -// Included from: src/javascript/runtime/flash/file/Blob.js +// Included from: src/javascript/runtime/flash/file/FileInput.js /** - * Blob.js + * FileInput.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -9514,40 +10069,44 @@ define("moxie/runtime/flash/file/FileInput", [ */ /** -@class moxie/runtime/flash/file/Blob +@class moxie/runtime/flash/file/FileInput @private */ -define("moxie/runtime/flash/file/Blob", [ +define("moxie/runtime/flash/file/FileInput", [ "moxie/runtime/flash/Runtime", - "moxie/file/Blob" -], function(extensions, Blob) { - - var FlashBlob = { - slice: function(blob, start, end, type) { - var self = this.getRuntime(); + "moxie/file/File", + "moxie/core/utils/Dom", + "moxie/core/utils/Basic" +], function(extensions, File, Dom, Basic) { - if (start < 0) { - start = Math.max(blob.size + start, 0); - } else if (start > 0) { - start = Math.min(start, blob.size); - } + var FileInput = { + init: function(options) { + var comp = this, I = this.getRuntime(); + var browseButton = Dom.get(options.browse_button); - if (end < 0) { - end = Math.max(blob.size + end, 0); - } else if (end > 0) { - end = Math.min(end, blob.size); + if (browseButton) { + browseButton.setAttribute('tabindex', -1); + browseButton = null; } - blob = self.shimExec.call(this, 'Blob', 'slice', start, end, type || ''); + this.bind("Change", function() { + var files = I.shimExec.call(comp, 'FileInput', 'getFiles'); + comp.files = []; + Basic.each(files, function(file) { + comp.files.push(new File(I.uid, file)); + }); + }, 999); - if (blob) { - blob = new Blob(self.uid, blob); - } - return blob; + this.getRuntime().shimExec.call(this, 'FileInput', 'init', { + accept: options.accept, + multiple: options.multiple + }); + + this.trigger('ready'); } }; - return (extensions.Blob = FlashBlob); + return (extensions.FileInput = FileInput); }); // Included from: src/javascript/runtime/flash/file/FileReader.js @@ -9627,7 +10186,7 @@ define("moxie/runtime/flash/file/FileReaderSync", [ "moxie/runtime/flash/Runtime", "moxie/core/utils/Encode" ], function(extensions, Encode) { - + function _formatData(data, op) { switch (op) { case 'readAsText': @@ -9661,6 +10220,42 @@ define("moxie/runtime/flash/file/FileReaderSync", [ return (extensions.FileReaderSync = FileReaderSync); }); +// Included from: src/javascript/runtime/flash/runtime/Transporter.js + +/** + * Transporter.js + * + * Copyright 2013, Moxiecode Systems AB + * Released under GPL License. + * + * License: http://www.plupload.com/license + * Contributing: http://www.plupload.com/contributing + */ + +/** +@class moxie/runtime/flash/runtime/Transporter +@private +*/ +define("moxie/runtime/flash/runtime/Transporter", [ + "moxie/runtime/flash/Runtime", + "moxie/file/Blob" +], function(extensions, Blob) { + + var Transporter = { + getAsBlob: function(type) { + var self = this.getRuntime() + , blob = self.shimExec.call(this, 'Transporter', 'getAsBlob', type) + ; + if (blob) { + return new Blob(self.uid, blob); + } + return null; + } + }; + + return (extensions.Transporter = Transporter); +}); + // Included from: src/javascript/runtime/flash/xhr/XMLHttpRequest.js /** @@ -9683,10 +10278,12 @@ define("moxie/runtime/flash/xhr/XMLHttpRequest", [ "moxie/file/Blob", "moxie/file/File", "moxie/file/FileReaderSync", + "moxie/runtime/flash/file/FileReaderSync", "moxie/xhr/FormData", - "moxie/runtime/Transporter" -], function(extensions, Basic, Blob, File, FileReaderSync, FormData, Transporter) { - + "moxie/runtime/Transporter", + "moxie/runtime/flash/runtime/Transporter" +], function(extensions, Basic, Blob, File, FileReaderSync, FileReaderSyncFlash, FormData, Transporter, TransporterFlash) { + var XMLHttpRequest = { send: function(meta, data) { @@ -9743,7 +10340,7 @@ define("moxie/runtime/flash/xhr/XMLHttpRequest", [ if (blob.isDetached()) { attachBlob(blob, function(attachedBlob) { blob.destroy(); - appendBlob(blobField, attachedBlob); + appendBlob(blobField, attachedBlob); }); } else { appendBlob(blobField, blob); @@ -9777,7 +10374,7 @@ define("moxie/runtime/flash/xhr/XMLHttpRequest", [ return blob; } - try { + try { frs = new FileReaderSync(); if (!!~Basic.inArray(responseType, ["", "text"])) { @@ -9810,42 +10407,6 @@ define("moxie/runtime/flash/xhr/XMLHttpRequest", [ return (extensions.XMLHttpRequest = XMLHttpRequest); }); -// Included from: src/javascript/runtime/flash/runtime/Transporter.js - -/** - * Transporter.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/flash/runtime/Transporter -@private -*/ -define("moxie/runtime/flash/runtime/Transporter", [ - "moxie/runtime/flash/Runtime", - "moxie/file/Blob" -], function(extensions, Blob) { - - var Transporter = { - getAsBlob: function(type) { - var self = this.getRuntime() - , blob = self.shimExec.call(this, 'Transporter', 'getAsBlob', type) - ; - if (blob) { - return new Blob(self.uid, blob); - } - return null; - } - }; - - return (extensions.Transporter = Transporter); -}); - // Included from: src/javascript/runtime/flash/image/Image.js /** @@ -9869,7 +10430,7 @@ define("moxie/runtime/flash/image/Image", [ "moxie/file/Blob", "moxie/file/FileReaderSync" ], function(extensions, Basic, Transporter, Blob, FileReaderSync) { - + var Image = { loadFromBlob: function(blob) { var comp = this, self = comp.getRuntime(); @@ -9900,7 +10461,7 @@ define("moxie/runtime/flash/image/Image", [ , info = self.shimExec.call(this, 'Image', 'getInfo') ; - if (info.meta && info.meta.thumb && !(info.meta.thumb.data instanceof Blob)) { + if (info.meta && info.meta.thumb && info.meta.thumb.data && !(self.meta.thumb.data instanceof Blob)) { info.meta.thumb.data = new Blob(self.uid, info.meta.thumb.data); } return info; @@ -9959,7 +10520,7 @@ define("moxie/runtime/silverlight/Runtime", [ "moxie/core/Exceptions", "moxie/runtime/Runtime" ], function(Basic, Env, Dom, x, Runtime) { - + var type = "silverlight", extensions = {}; function isInstalled(version) { @@ -10021,9 +10582,6 @@ define("moxie/runtime/silverlight/Runtime", [ /** Constructor for the Silverlight Runtime - - @class SilverlightRuntime - @extends Runtime */ function SilverlightRuntime(options) { var I = this, initTimer; @@ -10033,7 +10591,7 @@ define("moxie/runtime/silverlight/Runtime", [ Runtime.call(this, options, type, { access_binary: Runtime.capTrue, access_image_binary: Runtime.capTrue, - display_media: Runtime.capTrue, + display_media: Runtime.capTest(defined('moxie/image/Image')), do_cors: Runtime.capTrue, drag_and_drop: false, report_upload_progress: Runtime.capTrue, @@ -10068,7 +10626,7 @@ define("moxie/runtime/silverlight/Runtime", [ use_http_method: function(methods) { return I.mode === 'client' || !Basic.arrayDiff(methods, ['GET', 'POST']); } - }, { + }, { // capabilities that require specific mode return_response_headers: function(value) { return value ? 'client' : 'browser'; @@ -10091,7 +10649,7 @@ define("moxie/runtime/silverlight/Runtime", [ // minimal requirement if (!isInstalled('2.0.31005.0') || Env.browser === 'Opera') { if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\tSilverlight is not installed or minimal version (2.0.31005.0) requirement not met (not likely)."); + Env.log("\tSilverlight is not installed or minimal version (2.0.31005.0) requirement not met (not likely)."); } this.mode = false; @@ -10118,7 +10676,7 @@ define("moxie/runtime/silverlight/Runtime", [ '' + '' + '' + - '' + + '' + ''; // Init is dispatched by the shim @@ -10127,7 +10685,7 @@ define("moxie/runtime/silverlight/Runtime", [ I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR)); if (MXI_DEBUG && Env.debug.runtime) { - Env.log("\Silverlight failed to initialize within a specified period of time (5-10s)."); + Env.log("\Silverlight failed to initialize within a specified period of time (5-10s)."); } } }, Env.OS !== 'Windows'? 10000 : 5000); // give it more time to initialize in non Windows OS (like Mac) @@ -10144,11 +10702,35 @@ define("moxie/runtime/silverlight/Runtime", [ }, extensions); } - Runtime.addConstructor(type, SilverlightRuntime); + Runtime.addConstructor(type, SilverlightRuntime); return extensions; }); +// Included from: src/javascript/runtime/silverlight/file/Blob.js + +/** + * Blob.js + * + * Copyright 2013, Moxiecode Systems AB + * Released under GPL License. + * + * License: http://www.plupload.com/license + * Contributing: http://www.plupload.com/contributing + */ + +/** +@class moxie/runtime/silverlight/file/Blob +@private +*/ +define("moxie/runtime/silverlight/file/Blob", [ + "moxie/runtime/silverlight/Runtime", + "moxie/core/utils/Basic", + "moxie/runtime/flash/file/Blob" +], function(extensions, Basic, Blob) { + return (extensions.Blob = Basic.extend({}, Blob)); +}); + // Included from: src/javascript/runtime/silverlight/file/FileInput.js /** @@ -10168,19 +10750,27 @@ define("moxie/runtime/silverlight/Runtime", [ define("moxie/runtime/silverlight/file/FileInput", [ "moxie/runtime/silverlight/Runtime", "moxie/file/File", + "moxie/core/utils/Dom", "moxie/core/utils/Basic" -], function(extensions, File, Basic) { +], function(extensions, File, Dom, Basic) { + + function toFilters(accept) { + var filter = ''; + for (var i = 0; i < accept.length; i++) { + filter += (filter !== '' ? '|' : '') + accept[i].title + " | *." + accept[i].extensions.replace(/,/g, ';*.'); + } + return filter; + } + var FileInput = { init: function(options) { var comp = this, I = this.getRuntime(); + var browseButton = Dom.get(options.browse_button); - function toFilters(accept) { - var filter = ''; - for (var i = 0; i < accept.length; i++) { - filter += (filter !== '' ? '|' : '') + accept[i].title + " | *." + accept[i].extensions.replace(/,/g, ';*.'); - } - return filter; + if (browseButton) { + browseButton.setAttribute('tabindex', -1); + browseButton = null; } this.bind("Change", function() { @@ -10190,39 +10780,22 @@ define("moxie/runtime/silverlight/file/FileInput", [ comp.files.push(new File(I.uid, file)); }); }, 999); - - this.getRuntime().shimExec.call(this, 'FileInput', 'init', toFilters(options.accept), options.name, options.multiple); + + I.shimExec.call(this, 'FileInput', 'init', toFilters(options.accept), options.multiple); this.trigger('ready'); + }, + + setOption: function(name, value) { + if (name == 'accept') { + value = toFilters(value); + } + this.getRuntime().shimExec.call(this, 'FileInput', 'setOption', name, value); } }; return (extensions.FileInput = FileInput); }); -// Included from: src/javascript/runtime/silverlight/file/Blob.js - -/** - * Blob.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/** -@class moxie/runtime/silverlight/file/Blob -@private -*/ -define("moxie/runtime/silverlight/file/Blob", [ - "moxie/runtime/silverlight/Runtime", - "moxie/core/utils/Basic", - "moxie/runtime/flash/file/Blob" -], function(extensions, Basic, Blob) { - return (extensions.Blob = Basic.extend({}, Blob)); -}); - // Included from: src/javascript/runtime/silverlight/file/FileDrop.js /** @@ -10241,7 +10814,7 @@ define("moxie/runtime/silverlight/file/Blob", [ */ define("moxie/runtime/silverlight/file/FileDrop", [ "moxie/runtime/silverlight/Runtime", - "moxie/core/utils/Dom", + "moxie/core/utils/Dom", "moxie/core/utils/Events" ], function(extensions, Dom, Events) { @@ -10331,10 +10904,10 @@ define("moxie/runtime/silverlight/file/FileReaderSync", [ return (extensions.FileReaderSync = Basic.extend({}, FileReaderSync)); }); -// Included from: src/javascript/runtime/silverlight/xhr/XMLHttpRequest.js +// Included from: src/javascript/runtime/silverlight/runtime/Transporter.js /** - * XMLHttpRequest.js + * Transporter.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -10344,21 +10917,21 @@ define("moxie/runtime/silverlight/file/FileReaderSync", [ */ /** -@class moxie/runtime/silverlight/xhr/XMLHttpRequest +@class moxie/runtime/silverlight/runtime/Transporter @private */ -define("moxie/runtime/silverlight/xhr/XMLHttpRequest", [ +define("moxie/runtime/silverlight/runtime/Transporter", [ "moxie/runtime/silverlight/Runtime", "moxie/core/utils/Basic", - "moxie/runtime/flash/xhr/XMLHttpRequest" -], function(extensions, Basic, XMLHttpRequest) { - return (extensions.XMLHttpRequest = Basic.extend({}, XMLHttpRequest)); + "moxie/runtime/flash/runtime/Transporter" +], function(extensions, Basic, Transporter) { + return (extensions.Transporter = Basic.extend({}, Transporter)); }); -// Included from: src/javascript/runtime/silverlight/runtime/Transporter.js +// Included from: src/javascript/runtime/silverlight/xhr/XMLHttpRequest.js /** - * Transporter.js + * XMLHttpRequest.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -10368,15 +10941,17 @@ define("moxie/runtime/silverlight/xhr/XMLHttpRequest", [ */ /** -@class moxie/runtime/silverlight/runtime/Transporter +@class moxie/runtime/silverlight/xhr/XMLHttpRequest @private */ -define("moxie/runtime/silverlight/runtime/Transporter", [ +define("moxie/runtime/silverlight/xhr/XMLHttpRequest", [ "moxie/runtime/silverlight/Runtime", "moxie/core/utils/Basic", - "moxie/runtime/flash/runtime/Transporter" -], function(extensions, Basic, Transporter) { - return (extensions.Transporter = Basic.extend({}, Transporter)); + "moxie/runtime/flash/xhr/XMLHttpRequest", + "moxie/runtime/silverlight/file/FileReaderSync", + "moxie/runtime/silverlight/runtime/Transporter" +], function(extensions, Basic, XMLHttpRequest, FileReaderSyncSilverlight, TransporterSilverlight) { + return (extensions.XMLHttpRequest = Basic.extend({}, XMLHttpRequest)); }); // Included from: src/javascript/runtime/silverlight/image/Image.js @@ -10390,7 +10965,7 @@ define("moxie/runtime/silverlight/runtime/Transporter", [ * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ - + /** @class moxie/runtime/silverlight/image/Image @private @@ -10437,7 +11012,7 @@ define("moxie/runtime/silverlight/image/Image", [ }); // save thumb data as blob - if (info.meta && info.meta.thumb && !(info.meta.thumb.data instanceof Blob)) { + if (info.meta && info.meta.thumb && info.meta.thumb.data && !(self.meta.thumb.data instanceof Blob)) { info.meta.thumb.data = new Blob(self.uid, info.meta.thumb.data); } } @@ -10449,6 +11024,10 @@ define("moxie/runtime/silverlight/image/Image", [ info.name = rawInfo.name; return info; + }, + + resize: function(rect, ratio, opts) { + this.getRuntime().shimExec.call(this, 'Image', 'resize', rect.x, rect.y, rect.width, rect.height, ratio, opts.preserveHeaders, opts.resample); } })); }); @@ -10479,7 +11058,7 @@ define("moxie/runtime/html4/Runtime", [ "moxie/runtime/Runtime", "moxie/core/utils/Env" ], function(Basic, x, Runtime, Env) { - + var type = 'html4', extensions = {}; function Html4Runtime(options) { @@ -10491,13 +11070,19 @@ define("moxie/runtime/html4/Runtime", [ Runtime.call(this, options, type, { access_binary: Test(window.FileReader || window.File && File.getAsDataURL), access_image_binary: false, - display_media: Test(extensions.Image && (Env.can('create_canvas') || Env.can('use_data_uri_over32kb'))), + display_media: Test( + (Env.can('create_canvas') || Env.can('use_data_uri_over32kb')) && + defined('moxie/image/Image') + ), do_cors: false, drag_and_drop: false, filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest - return (Env.browser === 'Chrome' && Env.verComp(Env.version, 28, '>=')) || - (Env.browser === 'IE' && Env.verComp(Env.version, 10, '>=')) || - (Env.browser === 'Safari' && Env.verComp(Env.version, 7, '>=')); + return !( + (Env.browser === 'Chrome' && Env.verComp(Env.version, 28, '<')) || + (Env.browser === 'IE' && Env.verComp(Env.version, 10, '<')) || + (Env.browser === 'Safari' && Env.verComp(Env.version, 7, '<')) || + (Env.browser === 'Firefox' && Env.verComp(Env.version, 37, '<')) + ); }()), resize_image: function() { return extensions.Image && I.can('access_binary') && Env.can('create_canvas'); @@ -10507,7 +11092,7 @@ define("moxie/runtime/html4/Runtime", [ return_response_type: function(responseType) { if (responseType === 'json' && !!window.JSON) { return true; - } + } return !!~Basic.inArray(responseType, ['text', 'document', '']); }, return_status_code: function(code) { @@ -10525,11 +11110,10 @@ define("moxie/runtime/html4/Runtime", [ return I.can('select_file'); }, summon_file_dialog: function() { // yeah... some dirty sniffing here... - return I.can('select_file') && ( - (Env.browser === 'Firefox' && Env.verComp(Env.version, 4, '>=')) || - (Env.browser === 'Opera' && Env.verComp(Env.version, 12, '>=')) || - (Env.browser === 'IE' && Env.verComp(Env.version, 10, '>=')) || - !!~Basic.inArray(Env.browser, ['Chrome', 'Safari']) + return I.can('select_file') && !( + (Env.browser === 'Firefox' && Env.verComp(Env.version, 4, '<')) || + (Env.browser === 'Opera' && Env.verComp(Env.version, 12, '<')) || + (Env.browser === 'IE' && Env.verComp(Env.version, 10, '<')) ); }, upload_filesize: True, @@ -10585,21 +11169,23 @@ define("moxie/runtime/html4/file/FileInput", [ "moxie/core/utils/Mime", "moxie/core/utils/Env" ], function(extensions, File, Basic, Dom, Events, Mime, Env) { - + function FileInput() { - var _uid, _mimes = [], _options; + var _uid, _mimes = [], _options, _browseBtnZIndex; // save original z-index; function addInput() { var comp = this, I = comp.getRuntime(), shimContainer, browseButton, currForm, form, input, uid; uid = Basic.guid('uid_'); - shimContainer = I.getShimContainer(); // we get new ref everytime to avoid memory leaks in IE + shimContainer = I.getShimContainer(); // we get new ref every time to avoid memory leaks in IE if (_uid) { // move previous form out of the view currForm = Dom.get(_uid + '_form'); if (currForm) { Basic.extend(currForm.style, { top: '100%' }); + // it shouldn't be possible to tab into the hidden element + currForm.firstChild.setAttribute('tabindex', -1); } } @@ -10622,9 +11208,12 @@ define("moxie/runtime/html4/file/FileInput", [ input = document.createElement('input'); input.setAttribute('id', uid); input.setAttribute('type', 'file'); - input.setAttribute('name', _options.name || 'Filedata'); input.setAttribute('accept', _mimes.join(',')); + if (I.can('summon_file_dialog')) { + input.setAttribute('tabindex', -1); + } + Basic.extend(input.style, { fontSize: '999px', opacity: 0 @@ -10657,12 +11246,6 @@ define("moxie/runtime/html4/file/FileInput", [ if (this.files) { // check if browser is fresh enough file = this.files[0]; - - // ignore empty files (IE10 for example hangs if you try to send them via XHR) - if (file.size === 0) { - form.parentNode.removeChild(form); - return; - } } else { file = { name: this.value @@ -10672,15 +11255,15 @@ define("moxie/runtime/html4/file/FileInput", [ file = new File(I.uid, file); // clear event handler - this.onchange = function() {}; - addInput.call(comp); + this.onchange = function() {}; + addInput.call(comp); comp.files = [file]; // substitute all ids with file uids (consider file.uid read-only - we cannot do it the other way around) input.setAttribute('id', file.uid); form.setAttribute('id', file.uid + '_form'); - + comp.trigger('change'); input = form = null; @@ -10710,7 +11293,7 @@ define("moxie/runtime/html4/file/FileInput", [ // figure out accept string _options = options; - _mimes = options.accept.mimes || Mime.extList2mimes(options.accept, I.can('filter_by_extension')); + _mimes = Mime.extList2mimes(options.accept, I.can('filter_by_extension')); shimContainer = I.getShimContainer(); @@ -10718,17 +11301,23 @@ define("moxie/runtime/html4/file/FileInput", [ var browseButton, zIndex, top; browseButton = Dom.get(options.browse_button); + _browseBtnZIndex = Dom.getStyle(browseButton, 'z-index') || 'auto'; // Route click event to the input[type=file] element for browsers that support such behavior if (I.can('summon_file_dialog')) { if (Dom.getStyle(browseButton, 'position') === 'static') { browseButton.style.position = 'relative'; - } + } - zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 1; + comp.bind('Refresh', function() { + zIndex = parseInt(_browseBtnZIndex, 10) || 1; - browseButton.style.zIndex = zIndex; - shimContainer.style.zIndex = zIndex - 1; + Dom.get(_options.browse_button).style.zIndex = zIndex; + this.getRuntime().getShimContainer().style.zIndex = zIndex - 1; + }); + } else { + // it shouldn't be possible to tab into the hidden element + browseButton.setAttribute('tabindex', -1); } /* Since we have to place input[type=file] on top of the browse_button for some browsers, @@ -10765,6 +11354,21 @@ define("moxie/runtime/html4/file/FileInput", [ }); }, + setOption: function(name, value) { + var I = this.getRuntime(); + var input; + + if (name == 'accept') { + _mimes = value.mimes || Mime.extList2mimes(value, I.can('filter_by_extension')); + } + + // update current input + input = Dom.get(_uid) + if (input) { + input.setAttribute('accept', _mimes.join(',')); + } + }, + disable: function(state) { var input; @@ -10778,19 +11382,27 @@ define("moxie/runtime/html4/file/FileInput", [ var I = this.getRuntime() , shim = I.getShim() , shimContainer = I.getShimContainer() + , container = _options && Dom.get(_options.container) + , browseButton = _options && Dom.get(_options.browse_button) ; - - Events.removeAllEvents(shimContainer, this.uid); - Events.removeAllEvents(_options && Dom.get(_options.container), this.uid); - Events.removeAllEvents(_options && Dom.get(_options.browse_button), this.uid); - + + if (container) { + Events.removeAllEvents(container, this.uid); + } + + if (browseButton) { + Events.removeAllEvents(browseButton, this.uid); + browseButton.style.zIndex = _browseBtnZIndex; // reset to original value + } + if (shimContainer) { + Events.removeAllEvents(shimContainer, this.uid); shimContainer.innerHTML = ''; } shim.removeInstance(this.uid); - _uid = _mimes = _options = shimContainer = shim = null; + _uid = _mimes = _options = shimContainer = container = browseButton = shim = null; } }); } @@ -10847,7 +11459,7 @@ define("moxie/runtime/html4/xhr/XMLHttpRequest", [ "moxie/file/Blob", "moxie/xhr/FormData" ], function(extensions, Basic, Dom, Url, x, Events, Blob, FormData) { - + function XMLHttpRequest() { var _status, _response, _iframe; @@ -10913,7 +11525,7 @@ define("moxie/runtime/html4/xhr/XMLHttpRequest", [ ; // IE 6 won't be able to set the name using setAttribute or iframe.name - temp.innerHTML = ''; + temp.innerHTML = ''; _iframe = temp.firstChild; container.appendChild(_iframe); @@ -10952,7 +11564,7 @@ define("moxie/runtime/html4/xhr/XMLHttpRequest", [ } } catch (ex) { if (Url.hasSameOrigin(meta.url)) { - // if response is sent with error code, iframe in IE gets redirected to res://iframe.dll/http_x.htm + // if response is sent with error code, iframe in IE gets redirected to res://ieframe.dll/http_x.htm // which obviously results to cross domain error (wtf?) _status = 404; } else { @@ -10961,8 +11573,8 @@ define("moxie/runtime/html4/xhr/XMLHttpRequest", [ }); return; } - } - + } + cleanup.call(target, function() { target.trigger('load'); }); @@ -11039,7 +11651,7 @@ define("moxie/runtime/html4/xhr/XMLHttpRequest", [ } catch (ex) { return null; } - } + } } else if ('document' === responseType) { } @@ -11063,6 +11675,10 @@ define("moxie/runtime/html4/xhr/XMLHttpRequest", [ // target.dispatchEvent('readystatechange'); target.dispatchEvent('abort'); }); + }, + + destroy: function() { + this.getRuntime().getShim().removeInstance(this.uid); } }); } @@ -11093,55 +11709,6 @@ define("moxie/runtime/html4/image/Image", [ return (extensions.Image = Image); }); -expose(["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/I18n","moxie/core/utils/Mime","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/core/EventTarget","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/FileInput","moxie/core/utils/Encode","moxie/file/Blob","moxie/file/File","moxie/file/FileDrop","moxie/file/FileReader","moxie/core/utils/Url","moxie/runtime/RuntimeTarget","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/runtime/Transporter","moxie/image/Image","moxie/core/utils/Events"]); -})(this); -/** - * o.js - * - * Copyright 2013, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - */ - -/*global moxie:true */ - -/** -Globally exposed namespace with the most frequently used public classes and handy methods. - -@class o -@static -@private -*/ -(function(exports) { - "use strict"; - - var o = {}, inArray = exports.moxie.core.utils.Basic.inArray; - - // directly add some public classes - // (we do it dynamically here, since for custom builds we cannot know beforehand what modules were included) - (function addAlias(ns) { - var name, itemType; - for (name in ns) { - itemType = typeof(ns[name]); - if (itemType === 'object' && !~inArray(name, ['Exceptions', 'Env', 'Mime'])) { - addAlias(ns[name]); - } else if (itemType === 'function') { - o[name] = ns[name]; - } - } - })(exports.moxie); - - // add some manually - o.Env = exports.moxie.core.utils.Env; - o.Mime = exports.moxie.core.utils.Mime; - o.Exceptions = exports.moxie.core.Exceptions; - - // expose globally - exports.mOxie = o; - if (!exports.o) { - exports.o = o; - } - return o; +expose(["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Dom","moxie/core/EventTarget","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/core/I18n","moxie/core/utils/Mime","moxie/file/FileInput","moxie/file/File","moxie/file/FileDrop","moxie/file/FileReader","moxie/core/utils/Url","moxie/runtime/RuntimeTarget","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/image/Image","moxie/core/utils/Events","moxie/runtime/html5/image/ResizerCanvas"]); })(this); +})); \ No newline at end of file diff --git a/admin/addons/servers/legacy/includes/js/moxie.min.js b/admin/addons/servers/legacy/includes/js/moxie.min.js old mode 100755 new mode 100644 index dfd12b0ca5..efe1da7df1 --- a/admin/addons/servers/legacy/includes/js/moxie.min.js +++ b/admin/addons/servers/legacy/includes/js/moxie.min.js @@ -1,6 +1,6 @@ /** * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill - * v1.3.4 + * v1.5.7 * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. @@ -8,9 +8,9 @@ * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing * - * Date: 2015-07-18 + * Date: 2017-11-03 */ -!function(e,t){"use strict";function n(e,t){for(var n,i=[],r=0;r0&&n(o,function(n,o){n!==r&&(e(i[o])===e(n)&&~a(e(n),["array","object"])?t(i[o],n):i[o]=n)})}),i},n=function(t,n){var i,r,o,a;if(t)if("number"===e(t.length)){for(o=0,i=t.length;i>o;o++)if(n(t[o],o)===!1)return}else if("object"===e(t))for(r in t)if(t.hasOwnProperty(r)&&n(t[r],r)===!1)return},i=function(t){var n;if(!t||"object"!==e(t))return!0;for(n in t)return!1;return!0},r=function(t,n){function i(r){"function"===e(t[r])&&t[r](function(e){++rn;n++)if(t[n]===e)return n}return-1},s=function(t,n){var i=[];"array"!==e(t)&&(t=[t]),"array"!==e(n)&&(n=[n]);for(var r in t)-1===a(t[r],n)&&i.push(t[r]);return i.length?i:!1},u=function(e,t){var i=[];return n(e,function(e){-1!==a(e,t)&&i.push(e)}),i.length?i:null},c=function(e){var t,n=[];for(t=0;ti;i++)n+=Math.floor(65535*Math.random()).toString(32);return(t||"o_")+n+(e++).toString(32)}}(),d=function(e){return e?String.prototype.trim?String.prototype.trim.call(e):e.toString().replace(/^\s*/,"").replace(/\s*$/,""):e},h=function(e){if("string"!=typeof e)return e;var t={t:1099511627776,g:1073741824,m:1048576,k:1024},n;return e=/^([0-9\.]+)([tmgk]?)$/.exec(e.toLowerCase().replace(/[^0-9\.tmkg]/g,"")),n=e[2],e=+e[1],t.hasOwnProperty(n)&&(e*=t[n]),Math.floor(e)},f=function(t){var n=[].slice.call(arguments,1);return t.replace(/%[a-z]/g,function(){var t=n.shift();return"undefined"!==e(t)?t:""})};return{guid:l,typeOf:e,extend:t,each:n,isEmptyObj:i,inSeries:r,inParallel:o,inArray:a,arrayDiff:s,arrayIntersect:u,toArray:c,trim:d,sprintf:f,parseSizeStr:h}}),i(c,[u],function(e){function t(e,t,n){var i=0,r=0,o=0,a={dev:-6,alpha:-5,a:-5,beta:-4,b:-4,RC:-3,rc:-3,"#":-2,p:1,pl:1},s=function(e){return e=(""+e).replace(/[_\-+]/g,"."),e=e.replace(/([^.\d]+)/g,".$1.").replace(/\.{2,}/g,"."),e.length?e.split("."):[-8]},u=function(e){return e?isNaN(e)?a[e]||-7:parseInt(e,10):0};for(e=s(e),t=s(t),r=Math.max(e.length,t.length),i=0;r>i;i++)if(e[i]!=t[i]){if(e[i]=u(e[i]),t[i]=u(t[i]),e[i]t[i]){o=1;break}}if(!n)return o;switch(n){case">":case"gt":return o>0;case">=":case"ge":return o>=0;case"<=":case"le":return 0>=o;case"==":case"=":case"eq":return 0===o;case"<>":case"!=":case"ne":return 0!==o;case"":case"<":case"lt":return 0>o;default:return null}}var n=function(e){var t="",n="?",i="function",r="undefined",o="object",a="major",s="model",u="name",c="type",l="vendor",d="version",h="architecture",f="console",p="mobile",m="tablet",g={has:function(e,t){return-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()}},v={rgx:function(){for(var t,n=0,a,s,u,c,l,d,h=arguments;n0?2==c.length?typeof c[1]==i?t[c[0]]=c[1].call(this,d):t[c[0]]=c[1]:3==c.length?typeof c[1]!==i||c[1].exec&&c[1].test?t[c[0]]=d?d.replace(c[1],c[2]):e:t[c[0]]=d?c[1].call(this,d,c[2]):e:4==c.length&&(t[c[0]]=d?c[3].call(this,d.replace(c[1],c[2])):e):t[c]=d?d:e;break}if(l)break}return t},str:function(t,i){for(var r in i)if(typeof i[r]===o&&i[r].length>0){for(var a=0;a=9)},use_data_uri_of:function(e){return t.use_data_uri&&33e3>e||t.use_data_uri_over32kb()},use_fileinput:function(){if(navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/))return!1;var e=document.createElement("input");return e.setAttribute("type","file"),!e.disabled}};return function(n){var i=[].slice.call(arguments);return i.shift(),"function"===e.typeOf(t[n])?t[n].apply(this,i):!!t[n]}}(),r=(new n).getResult(),o={can:i,uaParser:n,browser:r.browser.name,version:r.browser.version,os:r.os.name,osVersion:r.os.version,verComp:t,swf_url:"../flash/Moxie.swf",xap_url:"../silverlight/Moxie.xap",global_event_dispatcher:"moxie.core.EventTarget.instance.dispatchEvent"};return o.OS=o.os,o}),i(l,[u],function(e){var t={};return{addI18n:function(n){return e.extend(t,n)},translate:function(e){return t[e]||e},_:function(e){return this.translate(e)},sprintf:function(t){var n=[].slice.call(arguments,1);return t.replace(/%[a-z]/g,function(){var t=n.shift();return"undefined"!==e.typeOf(t)?t:""})}}}),i(d,[u,l],function(e,t){var n="application/msword,doc dot,application/pdf,pdf,application/pgp-signature,pgp,application/postscript,ps ai eps,application/rtf,rtf,application/vnd.ms-excel,xls xlb,application/vnd.ms-powerpoint,ppt pps pot,application/zip,zip,application/x-shockwave-flash,swf swfl,application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx,application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx,application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx,application/vnd.openxmlformats-officedocument.presentationml.template,potx,application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx,application/x-javascript,js,application/json,json,audio/mpeg,mp3 mpga mpega mp2,audio/x-wav,wav,audio/x-m4a,m4a,audio/ogg,oga ogg,audio/aiff,aiff aif,audio/flac,flac,audio/aac,aac,audio/ac3,ac3,audio/x-ms-wma,wma,image/bmp,bmp,image/gif,gif,image/jpeg,jpg jpeg jpe,image/photoshop,psd,image/png,png,image/svg+xml,svg svgz,image/tiff,tiff tif,text/plain,asc txt text diff log,text/html,htm html xhtml,text/css,css,text/csv,csv,text/rtf,rtf,video/mpeg,mpeg mpg mpe m2v,video/quicktime,qt mov,video/mp4,mp4,video/x-m4v,m4v,video/x-flv,flv,video/x-ms-wmv,wmv,video/avi,avi,video/webm,webm,video/3gpp,3gpp 3gp,video/3gpp2,3g2,video/vnd.rn-realvideo,rv,video/ogg,ogv,video/x-matroska,mkv,application/vnd.oasis.opendocument.formula-template,otf,application/octet-stream,exe",i={mimes:{},extensions:{},addMimeType:function(e){var t=e.split(/,/),n,i,r;for(n=0;n=0;o--)if(r[o].fn===i){r.splice(o,1);break}}else r=[];r.length||(delete e[this.uid][t],n.isEmptyObj(e[this.uid])&&delete e[this.uid])}},removeAllEventListeners:function(){e[this.uid]&&delete e[this.uid]},dispatchEvent:function(i){var r,o,a,s,u={},c=!0,l;if("string"!==n.typeOf(i)){if(s=i,"string"!==n.typeOf(s.type))throw new t.EventException(t.EventException.UNSPECIFIED_EVENT_TYPE_ERR);i=s.type,s.total!==l&&s.loaded!==l&&(u.total=s.total,u.loaded=s.loaded),u.async=s.async||!1}if(-1!==i.indexOf("::")?!function(e){r=e[0],i=e[1]}(i.split("::")):r=this.uid,i=i.toLowerCase(),o=e[r]&&e[r][i]){o.sort(function(e,t){return t.priority-e.priority}),a=[].slice.call(arguments),a.shift(),u.type=i,a.unshift(u);var d=[];n.each(o,function(e){a[0].target=e.scope,d.push(u.async?function(t){setTimeout(function(){t(e.fn.apply(e.scope,a)===!1)},1)}:function(t){t(e.fn.apply(e.scope,a)===!1)})}),d.length&&n.inSeries(d,function(e){c=!e})}return c},bind:function(){this.addEventListener.apply(this,arguments)},unbind:function(){this.removeEventListener.apply(this,arguments)},unbindAll:function(){this.removeAllEventListeners.apply(this,arguments)},trigger:function(){return this.dispatchEvent.apply(this,arguments)},handleEventProps:function(e){var t=this;this.bind(e.join(" "),function(e){var t="on"+e.type.toLowerCase();"function"===n.typeOf(this[t])&&this[t].apply(this,arguments)}),n.each(e,function(e){e="on"+e.toLowerCase(e),"undefined"===n.typeOf(t[e])&&(t[e]=null)})}})}return i.instance=new i,i}),i(m,[c,u,h,p],function(e,t,n,i){function r(e,i,o,s,u){var c=this,l,d=t.guid(i+"_"),h=u||"browser";e=e||{},a[d]=this,o=t.extend({access_binary:!1,access_image_binary:!1,display_media:!1,do_cors:!1,drag_and_drop:!1,filter_by_extension:!0,resize_image:!1,report_upload_progress:!1,return_response_headers:!1,return_response_type:!1,return_status_code:!0,send_custom_headers:!1,select_file:!1,select_folder:!1,select_multiple:!0,send_binary_string:!1,send_browser_cookies:!0,send_multipart:!0,slice_blob:!1,stream_upload:!1,summon_file_dialog:!1,upload_filesize:!0,use_http_method:!0},o),e.preferred_caps&&(h=r.getMode(s,e.preferred_caps,h)),l=function(){var e={};return{exec:function(t,n,i,r){return l[n]&&(e[t]||(e[t]={context:this,instance:new l[n]}),e[t].instance[i])?e[t].instance[i].apply(this,r):void 0},removeInstance:function(t){delete e[t]},removeAllInstances:function(){var n=this;t.each(e,function(e,i){"function"===t.typeOf(e.instance.destroy)&&e.instance.destroy.call(e.context),n.removeInstance(i)})}}}(),t.extend(this,{initialized:!1,uid:d,type:i,mode:r.getMode(s,e.required_caps,h),shimid:d+"_container",clients:0,options:e,can:function(e,n){var i=arguments[2]||o;if("string"===t.typeOf(e)&&"undefined"===t.typeOf(n)&&(e=r.parseCaps(e)),"object"===t.typeOf(e)){for(var a in e)if(!this.can(a,e[a],i))return!1;return!0}return"function"===t.typeOf(i[e])?i[e].call(this,n):n===i[e]},getShimContainer:function(){var e,i=n.get(this.shimid);return i||(e=this.options.container?n.get(this.options.container):document.body,i=document.createElement("div"),i.id=this.shimid,i.className="moxie-shim moxie-shim-"+this.type,t.extend(i.style,{position:"absolute",top:"0px",left:"0px",width:"1px",height:"1px",overflow:"hidden"}),e.appendChild(i),e=null),i},getShim:function(){return l},shimExec:function(e,t){var n=[].slice.call(arguments,2);return c.getShim().exec.call(this,this.uid,e,t,n)},exec:function(e,t){var n=[].slice.call(arguments,2);return c[e]&&c[e][t]?c[e][t].apply(this,n):c.shimExec.apply(this,arguments)},destroy:function(){if(c){var e=n.get(this.shimid);e&&e.parentNode.removeChild(e),l&&l.removeAllInstances(),this.unbindAll(),delete a[this.uid],this.uid=null,d=c=l=e=null}}}),this.mode&&e.required_caps&&!this.can(e.required_caps)&&(this.mode=!1)}var o={},a={};return r.order="html5,flash,silverlight,html4",r.getRuntime=function(e){return a[e]?a[e]:!1},r.addConstructor=function(e,t){t.prototype=i.instance,o[e]=t},r.getConstructor=function(e){return o[e]||null},r.getInfo=function(e){var t=r.getRuntime(e);return t?{uid:t.uid,type:t.type,mode:t.mode,can:function(){return t.can.apply(t,arguments)}}:null},r.parseCaps=function(e){var n={};return"string"!==t.typeOf(e)?e||{}:(t.each(e.split(","),function(e){n[e]=!0}),n)},r.can=function(e,t){var n,i=r.getConstructor(e),o;return i?(n=new i({required_caps:t}),o=n.mode,n.destroy(),!!o):!1},r.thatCan=function(e,t){var n=(t||r.order).split(/\s*,\s*/);for(var i in n)if(r.can(n[i],e))return n[i];return null},r.getMode=function(e,n,i){var r=null;if("undefined"===t.typeOf(i)&&(i="browser"),n&&!t.isEmptyObj(e)){if(t.each(n,function(n,i){if(e.hasOwnProperty(i)){var o=e[i](n);if("string"==typeof o&&(o=[o]),r){if(!(r=t.arrayIntersect(r,o)))return r=!1}else r=o}}),r)return-1!==t.inArray(i,r)?i:r[0];if(r===!1)return!1}return i},r.capTrue=function(){return!0},r.capFalse=function(){return!1},r.capTest=function(e){return function(){return!!e}},r}),i(g,[c,f,u,m],function(e,t,n,i){return function r(){var e;n.extend(this,{connectRuntime:function(r){function o(n){var s,u;return n.length?(s=n.shift().toLowerCase(),(u=i.getConstructor(s))?(e=new u(r),e.bind("Init",function(){e.initialized=!0,setTimeout(function(){e.clients++,a.trigger("RuntimeInit",e)},1)}),e.bind("Error",function(){e.destroy(),o(n)}),e.mode?void e.init():void e.trigger("Error")):void o(n)):(a.trigger("RuntimeError",new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)),void(e=null))}var a=this,s;if("string"===n.typeOf(r)?s=r:"string"===n.typeOf(r.ruid)&&(s=r.ruid),s){if(e=i.getRuntime(s))return e.clients++,e;throw new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)}o((r.runtime_order||i.order).split(/\s*,\s*/))},disconnectRuntime:function(){e&&--e.clients<=0&&e.destroy(),e=null},getRuntime:function(){return e&&e.uid?e:e=null},exec:function(){return e?e.exec.apply(this,arguments):null}})}}),i(v,[u,c,d,h,f,p,l,m,g],function(e,t,n,i,r,o,a,s,u){function c(t){var o=this,c,d,h;if(-1!==e.inArray(e.typeOf(t),["string","node"])&&(t={browse_button:t}),d=i.get(t.browse_button),!d)throw new r.DOMException(r.DOMException.NOT_FOUND_ERR);h={accept:[{title:a.translate("All Files"),extensions:"*"}],name:"file",multiple:!1,required_caps:!1,container:d.parentNode||document.body},t=e.extend({},h,t),"string"==typeof t.required_caps&&(t.required_caps=s.parseCaps(t.required_caps)),"string"==typeof t.accept&&(t.accept=n.mimes2extList(t.accept)),c=i.get(t.container),c||(c=document.body),"static"===i.getStyle(c,"position")&&(c.style.position="relative"),c=d=null,u.call(o),e.extend(o,{uid:e.guid("uid_"),ruid:null,shimid:null,files:null,init:function(){o.bind("RuntimeInit",function(n,r){o.ruid=r.uid,o.shimid=r.shimid,o.bind("Ready",function(){o.trigger("Refresh")},999),o.bind("Refresh",function(){var n,o,a,s;a=i.get(t.browse_button),s=i.get(r.shimid),a&&(n=i.getPos(a,i.get(t.container)),o=i.getSize(a),s&&e.extend(s.style,{top:n.y+"px",left:n.x+"px",width:o.w+"px",height:o.h+"px"})),s=a=null}),r.exec.call(o,"FileInput","init",t)}),o.connectRuntime(e.extend({},t,{required_caps:{select_file:!0}}))},disable:function(t){var n=this.getRuntime();n&&n.exec.call(this,"FileInput","disable","undefined"===e.typeOf(t)?!0:t)},refresh:function(){o.trigger("Refresh")},destroy:function(){var t=this.getRuntime();t&&(t.exec.call(this,"FileInput","destroy"),this.disconnectRuntime()),"array"===e.typeOf(this.files)&&e.each(this.files,function(e){e.destroy()}),this.files=null,this.unbindAll()}}),this.handleEventProps(l)}var l=["ready","change","cancel","mouseenter","mouseleave","mousedown","mouseup"];return c.prototype=o.instance,c}),i(w,[],function(){var e=function(e){return unescape(encodeURIComponent(e))},t=function(e){return decodeURIComponent(escape(e))},n=function(e,n){if("function"==typeof window.atob)return n?t(window.atob(e)):window.atob(e);var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r,o,a,s,u,c,l,d,h=0,f=0,p="",m=[];if(!e)return e;e+="";do s=i.indexOf(e.charAt(h++)),u=i.indexOf(e.charAt(h++)),c=i.indexOf(e.charAt(h++)),l=i.indexOf(e.charAt(h++)),d=s<<18|u<<12|c<<6|l,r=d>>16&255,o=d>>8&255,a=255&d,64==c?m[f++]=String.fromCharCode(r):64==l?m[f++]=String.fromCharCode(r,o):m[f++]=String.fromCharCode(r,o,a);while(h>18&63,u=d>>12&63,c=d>>6&63,l=63&d,m[f++]=i.charAt(s)+i.charAt(u)+i.charAt(c)+i.charAt(l);while(ha;a++)o+=String.fromCharCode(r[a]);return o}}t.call(this),e.extend(this,{uid:e.guid("uid_"),readAsBinaryString:function(e){return i.call(this,"readAsBinaryString",e)},readAsDataURL:function(e){return i.call(this,"readAsDataURL",e)},readAsText:function(e){return i.call(this,"readAsText",e)}})}}),i(I,[f,u,y],function(e,t,n){function i(){var e,i=[];t.extend(this,{append:function(r,o){var a=this,s=t.typeOf(o);o instanceof n?e={name:r,value:o}:"array"===s?(r+="[]",t.each(o,function(e){a.append(r,e)})):"object"===s?t.each(o,function(e,t){a.append(r+"["+t+"]",e)}):"null"===s||"undefined"===s||"number"===s&&isNaN(o)?a.append(r,"false"):i.push({name:r,value:o.toString()})},hasBlob:function(){return!!this.getBlob()},getBlob:function(){return e&&e.value||null},getBlobName:function(){return e&&e.name||null},each:function(n){t.each(i,function(e){n(e.value,e.name)}),e&&n(e.value,e.name)},destroy:function(){e=null,i=[]}})}return i}),i(T,[u,f,p,w,x,m,R,y,A,I,c,d],function(e,t,n,i,r,o,a,s,u,c,l,d){function h(){this.uid=e.guid("uid_")}function f(){function n(e,t){return w.hasOwnProperty(e)?1===arguments.length?l.can("define_property")?w[e]:v[e]:void(l.can("define_property")?w[e]=t:v[e]=t):void 0}function u(t){function i(){B&&(B.destroy(),B=null),s.dispatchEvent("loadend"),s=null}function r(r){B.bind("LoadStart",function(e){n("readyState",f.LOADING),s.dispatchEvent("readystatechange"),s.dispatchEvent(e),O&&s.upload.dispatchEvent(e)}),B.bind("Progress",function(e){n("readyState")!==f.LOADING&&(n("readyState",f.LOADING),s.dispatchEvent("readystatechange")),s.dispatchEvent(e)}),B.bind("UploadProgress",function(e){O&&s.upload.dispatchEvent({type:"progress",lengthComputable:!1,total:e.total,loaded:e.loaded})}),B.bind("Load",function(t){n("readyState",f.DONE),n("status",Number(r.exec.call(B,"XMLHttpRequest","getStatus")||0)),n("statusText",p[n("status")]||""),n("response",r.exec.call(B,"XMLHttpRequest","getResponse",n("responseType"))),~e.inArray(n("responseType"),["text",""])?n("responseText",n("response")):"document"===n("responseType")&&n("responseXML",n("response")),k=r.exec.call(B,"XMLHttpRequest","getAllResponseHeaders"),s.dispatchEvent("readystatechange"),n("status")>0?(O&&s.upload.dispatchEvent(t),s.dispatchEvent(t)):(N=!0,s.dispatchEvent("error")),i()}),B.bind("Abort",function(e){s.dispatchEvent(e),i()}),B.bind("Error",function(e){N=!0,n("readyState",f.DONE),s.dispatchEvent("readystatechange"),D=!0,s.dispatchEvent(e),i()}),r.exec.call(B,"XMLHttpRequest","send",{url:E,method:_,async:y,user:x,password:R,headers:b,mimeType:I,encoding:A,responseType:s.responseType,withCredentials:s.withCredentials,options:H},t)}var s=this;C=(new Date).getTime(),B=new a,"string"==typeof H.required_caps&&(H.required_caps=o.parseCaps(H.required_caps)),H.required_caps=e.extend({},H.required_caps,{return_response_type:s.responseType}),t instanceof c&&(H.required_caps.send_multipart=!0),e.isEmptyObj(b)||(H.required_caps.send_custom_headers=!0),L||(H.required_caps.do_cors=!0),H.ruid?r(B.connectRuntime(H)):(B.bind("RuntimeInit",function(e,t){r(t)}),B.bind("RuntimeError",function(e,t){s.dispatchEvent("RuntimeError",t)}),B.connectRuntime(H))}function g(){n("responseText",""),n("responseXML",null),n("response",null),n("status",0),n("statusText",""),C=M=null}var v=this,w={timeout:0,readyState:f.UNSENT,withCredentials:!1,status:0,statusText:"",responseType:"",responseXML:null,responseText:null,response:null},y=!0,E,_,b={},x,R,A=null,I=null,T=!1,S=!1,O=!1,D=!1,N=!1,L=!1,C,M,F=null,P=null,H={},B,k="",U;e.extend(this,w,{uid:e.guid("uid_"),upload:new h,open:function(o,a,s,u,c){var l;if(!o||!a)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(/[\u0100-\uffff]/.test(o)||i.utf8_encode(o)!==o)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(~e.inArray(o.toUpperCase(),["CONNECT","DELETE","GET","HEAD","OPTIONS","POST","PUT","TRACE","TRACK"])&&(_=o.toUpperCase()),~e.inArray(_,["CONNECT","TRACE","TRACK"]))throw new t.DOMException(t.DOMException.SECURITY_ERR);if(a=i.utf8_encode(a),l=r.parseUrl(a),L=r.hasSameOrigin(l),E=r.resolveUrl(a),(u||c)&&!L)throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);if(x=u||l.user,R=c||l.pass,y=s||!0,y===!1&&(n("timeout")||n("withCredentials")||""!==n("responseType")))throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);T=!y,S=!1,b={},g.call(this),n("readyState",f.OPENED),this.dispatchEvent("readystatechange")},setRequestHeader:function(r,o){var a=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];if(n("readyState")!==f.OPENED||S)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(/[\u0100-\uffff]/.test(r)||i.utf8_encode(r)!==r)throw new t.DOMException(t.DOMException.SYNTAX_ERR);return r=e.trim(r).toLowerCase(),~e.inArray(r,a)||/^(proxy\-|sec\-)/.test(r)?!1:(b[r]?b[r]+=", "+o:b[r]=o,!0)},getAllResponseHeaders:function(){return k||""},getResponseHeader:function(t){return t=t.toLowerCase(),N||~e.inArray(t,["set-cookie","set-cookie2"])?null:k&&""!==k&&(U||(U={},e.each(k.split(/\r\n/),function(t){var n=t.split(/:\s+/);2===n.length&&(n[0]=e.trim(n[0]),U[n[0].toLowerCase()]={header:n[0],value:e.trim(n[1])})})),U.hasOwnProperty(t))?U[t].header+": "+U[t].value:null},overrideMimeType:function(i){var r,o;if(~e.inArray(n("readyState"),[f.LOADING,f.DONE]))throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(i=e.trim(i.toLowerCase()),/;/.test(i)&&(r=i.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))&&(i=r[1],r[2]&&(o=r[2])),!d.mimes[i])throw new t.DOMException(t.DOMException.SYNTAX_ERR);F=i,P=o},send:function(n,r){if(H="string"===e.typeOf(r)?{ruid:r}:r?r:{},this.readyState!==f.OPENED||S)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(n instanceof s)H.ruid=n.ruid,I=n.type||"application/octet-stream";else if(n instanceof c){if(n.hasBlob()){var o=n.getBlob();H.ruid=o.ruid,I=o.type||"application/octet-stream"}}else"string"==typeof n&&(A="UTF-8",I="text/plain;charset=UTF-8",n=i.utf8_encode(n));this.withCredentials||(this.withCredentials=H.required_caps&&H.required_caps.send_browser_cookies&&!L),O=!T&&this.upload.hasEventListener(),N=!1,D=!n,T||(S=!0),u.call(this,n)},abort:function(){if(N=!0,T=!1,~e.inArray(n("readyState"),[f.UNSENT,f.OPENED,f.DONE]))n("readyState",f.UNSENT);else{if(n("readyState",f.DONE),S=!1,!B)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);B.getRuntime().exec.call(B,"XMLHttpRequest","abort",D),D=!0}},destroy:function(){B&&("function"===e.typeOf(B.destroy)&&B.destroy(),B=null),this.unbindAll(),this.upload&&(this.upload.unbindAll(),this.upload=null)}}),this.handleEventProps(m.concat(["readystatechange"])),this.upload.handleEventProps(m)}var p={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Reserved",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",426:"Upgrade Required",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",510:"Not Extended"};h.prototype=n.instance;var m=["loadstart","progress","abort","error","load","timeout","loadend"],g=1,v=2;return f.UNSENT=0,f.OPENED=1,f.HEADERS_RECEIVED=2,f.LOADING=3,f.DONE=4,f.prototype=n.instance,f}),i(S,[u,w,g,p],function(e,t,n,i){function r(){function i(){l=d=0,c=this.result=null}function o(t,n){var i=this;u=n,i.bind("TransportingProgress",function(t){d=t.loaded,l>d&&-1===e.inArray(i.state,[r.IDLE,r.DONE])&&a.call(i)},999),i.bind("TransportingComplete",function(){d=l,i.state=r.DONE,c=null,i.result=u.exec.call(i,"Transporter","getAsBlob",t||"")},999),i.state=r.BUSY,i.trigger("TransportingStarted"),a.call(i)}function a(){var e=this,n,i=l-d;h>i&&(h=i),n=t.btoa(c.substr(d,h)),u.exec.call(e,"Transporter","receive",n,l)}var s,u,c,l,d,h;n.call(this),e.extend(this,{uid:e.guid("uid_"),state:r.IDLE,result:null,transport:function(t,n,r){var a=this;if(r=e.extend({chunk_size:204798},r),(s=r.chunk_size%3)&&(r.chunk_size+=3-s),h=r.chunk_size,i.call(this),c=t,l=t.length,"string"===e.typeOf(r)||r.ruid)o.call(a,n,this.connectRuntime(r));else{var u=function(e,t){a.unbind("RuntimeInit",u),o.call(a,n,t)};this.bind("RuntimeInit",u),this.connectRuntime(r)}},abort:function(){var e=this;e.state=r.IDLE,u&&(u.exec.call(e,"Transporter","clear"),e.trigger("TransportingAborted")),i.call(e)},destroy:function(){this.unbindAll(),u=null,this.disconnectRuntime(),i.call(this)}})}return r.IDLE=0,r.BUSY=1,r.DONE=2,r.prototype=i.instance,r}),i(O,[u,h,f,A,T,m,g,S,c,p,y,E,w],function(e,t,n,i,r,o,a,s,u,c,l,d,h){function f(){function i(e){e||(e=this.exec("Image","getInfo")),this.size=e.size,this.width=e.width,this.height=e.height,this.type=e.type,this.meta=e.meta,""===this.name&&(this.name=e.name)}function c(t){var i=e.typeOf(t);try{if(t instanceof f){if(!t.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);m.apply(this,arguments)}else if(t instanceof l){if(!~e.inArray(t.type,["image/jpeg","image/png"]))throw new n.ImageError(n.ImageError.WRONG_FORMAT);g.apply(this,arguments)}else if(-1!==e.inArray(i,["blob","file"]))c.call(this,new d(null,t),arguments[1]);else if("string"===i)"data:"===t.substr(0,5)?c.call(this,new l(null,{data:t}),arguments[1]):v.apply(this,arguments);else{if("node"!==i||"img"!==t.nodeName.toLowerCase())throw new n.DOMException(n.DOMException.TYPE_MISMATCH_ERR);c.call(this,t.src,arguments[1])}}catch(r){this.trigger("error",r.code)}}function m(t,n){var i=this.connectRuntime(t.ruid);this.ruid=i.uid,i.exec.call(this,"Image","loadFromImage",t,"undefined"===e.typeOf(n)?!0:n)}function g(t,n){function i(e){r.ruid=e.uid,e.exec.call(r,"Image","loadFromBlob",t)}var r=this;r.name=t.name||"",t.isDetached()?(this.bind("RuntimeInit",function(e,t){i(t)}),n&&"string"==typeof n.required_caps&&(n.required_caps=o.parseCaps(n.required_caps)),this.connectRuntime(e.extend({required_caps:{access_image_binary:!0,resize_image:!0}},n))):i(this.connectRuntime(t.ruid))}function v(e,t){var n=this,i;i=new r,i.open("get",e),i.responseType="blob",i.onprogress=function(e){n.trigger(e)},i.onload=function(){g.call(n,i.response,!0)},i.onerror=function(e){n.trigger(e)},i.onloadend=function(){i.destroy()},i.bind("RuntimeError",function(e,t){n.trigger("RuntimeError",t)}),i.send(null,t)}a.call(this),e.extend(this,{uid:e.guid("uid_"),ruid:null,name:"",size:0,width:0,height:0,type:"",meta:{},clone:function(){this.load.apply(this,arguments)},load:function(){c.apply(this,arguments)},downsize:function(t){var i={width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90,crop:!1,preserveHeaders:!0,resample:!1};t="object"==typeof t?e.extend(i,t):e.extend(i,{width:arguments[0],height:arguments[1],crop:arguments[2],preserveHeaders:arguments[3]});try{if(!this.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);if(this.width>f.MAX_RESIZE_WIDTH||this.height>f.MAX_RESIZE_HEIGHT)throw new n.ImageError(n.ImageError.MAX_RESOLUTION_ERR);this.exec("Image","downsize",t.width,t.height,t.crop,t.preserveHeaders)}catch(r){this.trigger("error",r.code)}},crop:function(e,t,n){this.downsize(e,t,!0,n)},getAsCanvas:function(){if(!u.can("create_canvas"))throw new n.RuntimeError(n.RuntimeError.NOT_SUPPORTED_ERR);var e=this.connectRuntime(this.ruid);return e.exec.call(this,"Image","getAsCanvas")},getAsBlob:function(e,t){if(!this.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsBlob",e||"image/jpeg",t||90)},getAsDataURL:function(e,t){if(!this.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsDataURL",e||"image/jpeg",t||90)},getAsBinaryString:function(e,t){var n=this.getAsDataURL(e,t);return h.atob(n.substring(n.indexOf("base64,")+7))},embed:function(i,r){function o(t,r){var o=this;if(u.can("create_canvas")){var l=o.getAsCanvas();if(l)return i.appendChild(l),l=null,o.destroy(),void a.trigger("embedded")}var d=o.getAsDataURL(t,r);if(!d)throw new n.ImageError(n.ImageError.WRONG_FORMAT);if(u.can("use_data_uri_of",d.length))i.innerHTML='',o.destroy(),a.trigger("embedded");else{var f=new s;f.bind("TransportingComplete",function(){c=a.connectRuntime(this.result.ruid),a.bind("Embedded",function(){e.extend(c.getShimContainer().style,{top:"0px",left:"0px",width:o.width+"px",height:o.height+"px"}),c=null},999),c.exec.call(a,"ImageView","display",this.result.uid,width,height),o.destroy()}),f.transport(h.atob(d.substring(d.indexOf("base64,")+7)),t,{required_caps:{display_media:!0},runtime_order:"flash,silverlight",container:i})}}var a=this,c;r=e.extend({width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90},r||{});try{if(!(i=t.get(i)))throw new n.DOMException(n.DOMException.INVALID_NODE_TYPE_ERR);if(!this.size)throw new n.DOMException(n.DOMException.INVALID_STATE_ERR);this.width>f.MAX_RESIZE_WIDTH||this.height>f.MAX_RESIZE_HEIGHT;var l=new f;return l.bind("Resize",function(){o.call(this,r.type,r.quality)}),l.bind("Load",function(){l.downsize(r)}),this.meta.thumb&&this.meta.thumb.width>=r.width&&this.meta.thumb.height>=r.height?l.load(this.meta.thumb.data):l.clone(this,!1),l}catch(d){this.trigger("error",d.code)}},destroy:function(){this.ruid&&(this.getRuntime().exec.call(this,"Image","destroy"),this.disconnectRuntime()),this.unbindAll()}}),this.handleEventProps(p),this.bind("Load Resize",function(){i.call(this)},999)}var p=["progress","load","error","resize","embedded"];return f.MAX_RESIZE_WIDTH=8192,f.MAX_RESIZE_HEIGHT=8192,f.prototype=c.instance,f}),i(D,[u,f,m,c],function(e,t,n,i){function r(t){var r=this,s=n.capTest,u=n.capTrue,c=e.extend({access_binary:s(window.FileReader||window.File&&window.File.getAsDataURL),access_image_binary:function(){return r.can("access_binary")&&!!a.Image},display_media:s(i.can("create_canvas")||i.can("use_data_uri_over32kb")),do_cors:s(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest),drag_and_drop:s(function(){var e=document.createElement("div");return("draggable"in e||"ondragstart"in e&&"ondrop"in e)&&("IE"!==i.browser||i.verComp(i.version,9,">"))}()),filter_by_extension:s(function(){return"Chrome"===i.browser&&i.verComp(i.version,28,">=")||"IE"===i.browser&&i.verComp(i.version,10,">=")||"Safari"===i.browser&&i.verComp(i.version,7,">=")}()),return_response_headers:u,return_response_type:function(e){return"json"===e&&window.JSON?!0:i.can("return_response_type",e)},return_status_code:u,report_upload_progress:s(window.XMLHttpRequest&&(new XMLHttpRequest).upload),resize_image:function(){return r.can("access_binary")&&i.can("create_canvas")},select_file:function(){return i.can("use_fileinput")&&window.File},select_folder:function(){return r.can("select_file")&&"Chrome"===i.browser&&i.verComp(i.version,21,">=")},select_multiple:function(){return!(!r.can("select_file")||"Safari"===i.browser&&"Windows"===i.os||"iOS"===i.os&&i.verComp(i.osVersion,"7.0.0",">")&&i.verComp(i.osVersion,"8.0.0","<"))},send_binary_string:s(window.XMLHttpRequest&&((new XMLHttpRequest).sendAsBinary||window.Uint8Array&&window.ArrayBuffer)),send_custom_headers:s(window.XMLHttpRequest),send_multipart:function(){return!!(window.XMLHttpRequest&&(new XMLHttpRequest).upload&&window.FormData)||r.can("send_binary_string")},slice_blob:s(window.File&&(File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice)),stream_upload:function(){return r.can("slice_blob")&&r.can("send_multipart")},summon_file_dialog:function(){return r.can("select_file")&&("Firefox"===i.browser&&i.verComp(i.version,4,">=")||"Opera"===i.browser&&i.verComp(i.version,12,">=")||"IE"===i.browser&&i.verComp(i.version,10,">=")||!!~e.inArray(i.browser,["Chrome","Safari"]))},upload_filesize:u},arguments[2]);n.call(this,t,arguments[1]||o,c),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(r),e=r=null}}(this.destroy)}),e.extend(this.getShim(),a)}var o="html5",a={};return n.addConstructor(o,r),a}),i(N,[u],function(e){function t(){this.returnValue=!1}function n(){this.cancelBubble=!0}var i={},r="moxie_"+e.guid(),o=function(o,a,s,u){var c,l;a=a.toLowerCase(),o.addEventListener?(c=s,o.addEventListener(a,c,!1)):o.attachEvent&&(c=function(){var e=window.event;e.target||(e.target=e.srcElement),e.preventDefault=t,e.stopPropagation=n,s(e)},o.attachEvent("on"+a,c)),o[r]||(o[r]=e.guid()),i.hasOwnProperty(o[r])||(i[o[r]]={}),l=i[o[r]],l.hasOwnProperty(a)||(l[a]=[]),l[a].push({func:c,orig:s,key:u})},a=function(t,n,o){var a,s;if(n=n.toLowerCase(),t[r]&&i[t[r]]&&i[t[r]][n]){a=i[t[r]][n];for(var u=a.length-1;u>=0&&(a[u].orig!==o&&a[u].key!==o||(t.removeEventListener?t.removeEventListener(n,a[u].func,!1):t.detachEvent&&t.detachEvent("on"+n,a[u].func),a[u].orig=null,a[u].func=null,a.splice(u,1),o===s));u--);if(a.length||delete i[t[r]][n],e.isEmptyObj(i[t[r]])){delete i[t[r]];try{delete t[r]}catch(c){t[r]=s}}}},s=function(t,n){t&&t[r]&&e.each(i[t[r]],function(e,i){a(t,i,n)})};return{addEvent:o,removeEvent:a,removeAllEvents:s}}),i(L,[D,E,u,h,N,d,c],function(e,t,n,i,r,o,a){function s(){var e;n.extend(this,{init:function(s){var u=this,c=u.getRuntime(),l,d,h,f,p,m;e=s,h=e.accept.mimes||o.extList2mimes(e.accept,c.can("filter_by_extension")),d=c.getShimContainer(),d.innerHTML='",l=i.get(c.uid),n.extend(l.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),f=i.get(e.browse_button),c.can("summon_file_dialog")&&("static"===i.getStyle(f,"position")&&(f.style.position="relative"),p=parseInt(i.getStyle(f,"z-index"),10)||1,f.style.zIndex=p,d.style.zIndex=p-1,r.addEvent(f,"click",function(e){var t=i.get(c.uid);t&&!t.disabled&&t.click(),e.preventDefault()},u.uid)),m=c.can("summon_file_dialog")?f:d,r.addEvent(m,"mouseover",function(){u.trigger("mouseenter")},u.uid),r.addEvent(m,"mouseout",function(){u.trigger("mouseleave")},u.uid),r.addEvent(m,"mousedown",function(){u.trigger("mousedown")},u.uid),r.addEvent(i.get(e.container),"mouseup",function(){u.trigger("mouseup")},u.uid),l.onchange=function g(i){if(u.files=[],n.each(this.files,function(n){var i="";return e.directory&&"."==n.name?!0:(n.webkitRelativePath&&(i="/"+n.webkitRelativePath.replace(/^\//,"")),n=new t(c.uid,n),n.relativePath=i,void u.files.push(n))}),"IE"!==a.browser&&"IEMobile"!==a.browser)this.value="";else{var r=this.cloneNode(!0);this.parentNode.replaceChild(r,this),r.onchange=g}u.files.length&&u.trigger("change")},u.trigger({type:"ready",async:!0}),d=null},disable:function(e){var t=this.getRuntime(),n;(n=i.get(t.uid))&&(n.disabled=!!e)},destroy:function(){var t=this.getRuntime(),n=t.getShim(),o=t.getShimContainer();r.removeAllEvents(o,this.uid),r.removeAllEvents(e&&i.get(e.container),this.uid),r.removeAllEvents(e&&i.get(e.browse_button),this.uid),o&&(o.innerHTML=""),n.removeInstance(this.uid),e=o=n=null}})}return e.FileInput=s}),i(C,[D,y],function(e,t){function n(){function e(e,t,n){var i;if(!window.File.prototype.slice)return(i=window.File.prototype.webkitSlice||window.File.prototype.mozSlice)?i.call(e,t,n):null;try{return e.slice(),e.slice(t,n)}catch(r){return e.slice(t,n-t)}}this.slice=function(){return new t(this.getRuntime().uid,e.apply(this,arguments))}}return e.Blob=n}),i(M,[D,E,u,h,N,d],function(e,t,n,i,r,o){function a(){function e(e){if(!e.dataTransfer||!e.dataTransfer.types)return!1;var t=n.toArray(e.dataTransfer.types||[]);return-1!==n.inArray("Files",t)||-1!==n.inArray("public.file-url",t)||-1!==n.inArray("application/x-moz-file",t)}function a(e,n){if(u(e)){var i=new t(g,e);i.relativePath=n||"",f.push(i)}}function s(e){for(var t=[],i=0;i=")&&u.verComp(u.version,7,"<"),h="Android Browser"===u.browser,m=!1;if(p=n.url.replace(/^.+?\/([\w\-\.]+)$/,"$1").toLowerCase(),f=c(),f.open(n.method,n.url,n.async,n.user,n.password),r instanceof o)r.isDetached()&&(m=!0),r=r.getSource();else if(r instanceof a){if(r.hasBlob())if(r.getBlob().isDetached())r=d.call(s,r),m=!0;else if((l||h)&&"blob"===t.typeOf(r.getBlob().getSource())&&window.FileReader)return void e.call(s,n,r);if(r instanceof a){var g=new window.FormData;r.each(function(e,t){e instanceof o?g.append(t,e.getSource()):g.append(t,e)}),r=g}}f.upload?(n.withCredentials&&(f.withCredentials=!0),f.addEventListener("load",function(e){s.trigger(e)}),f.addEventListener("error",function(e){s.trigger(e)}),f.addEventListener("progress",function(e){s.trigger(e)}),f.upload.addEventListener("progress",function(e){s.trigger({type:"UploadProgress",loaded:e.loaded,total:e.total})})):f.onreadystatechange=function v(){switch(f.readyState){case 1:break;case 2:break;case 3:var e,t;try{i.hasSameOrigin(n.url)&&(e=f.getResponseHeader("Content-Length")||0),f.responseText&&(t=f.responseText.length)}catch(r){e=t=0}s.trigger({type:"progress",lengthComputable:!!e,total:parseInt(e,10),loaded:t});break;case 4:f.onreadystatechange=function(){},s.trigger(0===f.status?"error":"load")}},t.isEmptyObj(n.headers)||t.each(n.headers,function(e,t){f.setRequestHeader(t,e)}),""!==n.responseType&&"responseType"in f&&("json"!==n.responseType||u.can("return_response_type","json")?f.responseType=n.responseType:f.responseType="text"),m?f.sendAsBinary?f.sendAsBinary(r):!function(){for(var e=new Uint8Array(r.length),t=0;t0&&o.set(new Uint8Array(t.slice(0,e)),0),o.set(new Uint8Array(r),e),o.set(new Uint8Array(t.slice(e+i)),e+r.byteLength),this.clear(),t=o.buffer,n=new DataView(t);break}default:return t}},length:function(){return t?t.byteLength:0},clear:function(){n=t=null}})}function i(t){function n(e,n,i){i=3===arguments.length?i:t.length-n-1,t=t.substr(0,n)+e+t.substr(i+n)}e.extend(this,{readByteAt:function(e){return t.charCodeAt(e)},writeByteAt:function(e,t){n(String.fromCharCode(t),e,1)},SEGMENT:function(e,i,r){switch(arguments.length){case 1:return t.substr(e);case 2:return t.substr(e,i);case 3:n(null!==r?r:"",e,i);break;default:return t}},length:function(){return t?t.length:0},clear:function(){t=null}})}return e.extend(t.prototype,{littleEndian:!1,read:function(e,t){var n,i,r;if(e+t>this.length())throw new Error("You are trying to read outside the source boundaries.");for(i=this.littleEndian?0:-8*(t-1),r=0,n=0;t>r;r++)n|=this.readByteAt(e+r)<this.length())throw new Error("You are trying to write outside the source boundaries.");for(i=this.littleEndian?0:-8*(n-1),r=0;n>r;r++)this.writeByteAt(e+r,t>>Math.abs(i+8*r)&255)},BYTE:function(e){return this.read(e,1)},SHORT:function(e){return this.read(e,2)},LONG:function(e){return this.read(e,4)},SLONG:function(e){var t=this.read(e,4);return t>2147483647?t-4294967296:t},CHAR:function(e){return String.fromCharCode(this.read(e,1))},STRING:function(e,t){return this.asArray("CHAR",e,t).join("")},asArray:function(e,t,n){for(var i=[],r=0;n>r;r++)i[r]=this[e](t+r);return i}}),t}),i(B,[H,f],function(e,t){return function n(i){var r=[],o,a,s,u=0;if(o=new e(i),65496!==o.SHORT(0))throw o.clear(),new t.ImageError(t.ImageError.WRONG_FORMAT);for(a=2;a<=o.length();)if(s=o.SHORT(a),s>=65488&&65495>=s)a+=2;else{if(65498===s||65497===s)break;u=o.SHORT(a+2)+2,s>=65505&&65519>=s&&r.push({hex:s,name:"APP"+(15&s),start:a,length:u,segment:o.SEGMENT(a,u)}),a+=u}return o.clear(),{headers:r,restore:function(t){var n,i,o;for(o=new e(t),a=65504==o.SHORT(2)?4+o.SHORT(4):2,i=0,n=r.length;n>i;i++)o.SEGMENT(a,0,r[i].segment),a+=r[i].length;return t=o.SEGMENT(),o.clear(),t},strip:function(t){var i,r,o,a;for(o=new n(t),r=o.headers,o.purge(),i=new e(t),a=r.length;a--;)i.SEGMENT(r[a].start,r[a].length,"");return t=i.SEGMENT(),i.clear(),t},get:function(e){for(var t=[],n=0,i=r.length;i>n;n++)r[n].name===e.toUpperCase()&&t.push(r[n].segment);return t}, -set:function(e,t){var n=[],i,o,a;for("string"==typeof t?n.push(t):n=t,i=o=0,a=r.length;a>i&&(r[i].name===e.toUpperCase()&&(r[i].segment=n[o],r[i].length=n[o].length,o++),!(o>=n.length));i++);},purge:function(){this.headers=r=[]}}}}),i(k,[u,H,f],function(e,n,i){function r(o){function a(n,r){var o=this,a,s,u,c,h,f,p,m,g=[],v={},w={1:"BYTE",7:"UNDEFINED",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",9:"SLONG",10:"SRATIONAL"},y={BYTE:1,UNDEFINED:1,ASCII:1,SHORT:2,LONG:4,RATIONAL:8,SLONG:4,SRATIONAL:8};for(a=o.SHORT(n),s=0;a>s;s++)if(g=[],p=n+2+12*s,u=r[o.SHORT(p)],u!==t){if(c=w[o.SHORT(p+=2)],h=o.LONG(p+=2),f=y[c],!f)throw new i.ImageError(i.ImageError.INVALID_META_ERR);if(p+=4,f*h>4&&(p=o.LONG(p)+d.tiffHeader),p+f*h>=this.length())throw new i.ImageError(i.ImageError.INVALID_META_ERR);"ASCII"!==c?(g=o.asArray(c,p,h),m=1==h?g[0]:g,l.hasOwnProperty(u)&&"object"!=typeof m?v[u]=l[u][m]:v[u]=m):v[u]=e.trim(o.STRING(p,h).replace(/\0$/,""))}return v}function s(e,t,n){var i,r,o,a=0;if("string"==typeof t){var s=c[e.toLowerCase()];for(var u in s)if(s[u]===t){t=u;break}}i=d[e.toLowerCase()+"IFD"],r=this.SHORT(i);for(var l=0;r>l;l++)if(o=i+12*l+2,this.SHORT(o)==t){a=o+8;break}if(!a)return!1;try{this.write(a,n,4)}catch(h){return!1}return!0}var u,c,l,d,h,f;if(n.call(this,o),c={tiff:{274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},exif:{36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"},thumb:{513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength"}},l={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}},d={tiffHeader:10},h=d.tiffHeader,u={clear:this.clear},e.extend(this,{read:function(){try{return r.prototype.read.apply(this,arguments)}catch(e){throw new i.ImageError(i.ImageError.INVALID_META_ERR)}},write:function(){try{return r.prototype.write.apply(this,arguments)}catch(e){throw new i.ImageError(i.ImageError.INVALID_META_ERR)}},UNDEFINED:function(){return this.BYTE.apply(this,arguments)},RATIONAL:function(e){return this.LONG(e)/this.LONG(e+4)},SRATIONAL:function(e){return this.SLONG(e)/this.SLONG(e+4)},ASCII:function(e){return this.CHAR(e)},TIFF:function(){return f||null},EXIF:function(){var t=null;if(d.exifIFD){try{t=a.call(this,d.exifIFD,c.exif)}catch(n){return null}if(t.ExifVersion&&"array"===e.typeOf(t.ExifVersion)){for(var i=0,r="";i=65472&&65475>=n)return t+=5,{height:e.SHORT(t),width:e.SHORT(t+=2)};i=e.SHORT(t+=2),t+=i-2}return null}function s(){var e=d.thumb(),t,n;return e&&(t=new i(e),n=a(t),t.clear(),n)?(n.data=e,n):null}function u(){d&&l&&c&&(d.clear(),l.purge(),c.clear(),h=l=d=c=null)}var c,l,d,h;if(c=new i(o),65496!==c.SHORT(0))throw new t.ImageError(t.ImageError.WRONG_FORMAT);l=new n(o);try{d=new r(l.get("app1")[0])}catch(f){}h=a.call(this),e.extend(this,{type:"image/jpeg",size:c.length(),width:h&&h.width||0,height:h&&h.height||0,setExif:function(t,n){return d?("object"===e.typeOf(t)?e.each(t,function(e,t){d.setExif(t,e)}):d.setExif(t,n),void l.set("app1",d.SEGMENT())):!1},writeHeaders:function(){return l.restore(arguments.length?arguments[0]:o)},stripHeaders:function(e){return l.strip(e)},purge:function(){u.call(this)}}),d&&(this.meta={tiff:d.TIFF(),exif:d.EXIF(),gps:d.GPS(),thumb:s()})}return o}),i(G,[f,u,H],function(e,t,n){function i(i){function r(){var e,t;return e=a.call(this,8),"IHDR"==e.type?(t=e.start,{width:s.LONG(t),height:s.LONG(t+=4)}):null}function o(){s&&(s.clear(),i=l=u=c=s=null)}function a(e){var t,n,i,r;return t=s.LONG(e),n=s.STRING(e+=4,4),i=e+=4,r=s.LONG(e+t),{length:t,type:n,start:i,CRC:r}}var s,u,c,l;s=new n(i),function(){var t=0,n=0,i=[35152,20039,3338,6666];for(n=0;ng;){for(var v=g+h>a?a-g:h,w=0;o>w;){var y=w+h>o?o-w:h;p.clearRect(0,0,h,h),p.drawImage(e,-w,-g);var E=w*s/o+c<<0,_=Math.ceil(y*s/o),b=g*u/a/m+l<<0,x=Math.ceil(v*u/a/m);d.drawImage(f,0,0,y,v,E,b,_,x),w+=h}g+=h}f=p=null}function t(e){var t=e.naturalWidth,n=e.naturalHeight;if(t*n>1048576){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");return r.drawImage(e,-t+1,0),0===r.getImageData(0,0,1,1).data[3]}return!1}function n(e,t,n){var i=document.createElement("canvas");i.width=1,i.height=n;var r=i.getContext("2d");r.drawImage(e,0,0);for(var o=r.getImageData(0,0,1,n).data,a=0,s=n,u=n;u>a;){var c=o[4*(u-1)+3];0===c?s=u:a=u,u=s+a>>1}i=null;var l=u/n;return 0===l?1:l}return{isSubsampled:t,renderTo:e}}),i(j,[D,u,f,w,y,E,z,q,d,c],function(e,t,n,i,r,o,a,s,u,c){function l(){function e(){if(!_&&!y)throw new n.ImageError(n.DOMException.INVALID_STATE_ERR);return _||y}function l(e){return i.atob(e.substring(e.indexOf("base64,")+7))}function d(e,t){return"data:"+(t||"")+";base64,"+i.btoa(e)}function h(e){var t=this;y=new Image,y.onerror=function(){v.call(this),t.trigger("error",n.ImageError.WRONG_FORMAT)},y.onload=function(){t.trigger("load")},y.src="data:"==e.substr(0,5)?e:d(e,x.type)}function f(e,t){var i=this,r;return window.FileReader?(r=new FileReader,r.onload=function(){t(this.result)},r.onerror=function(){i.trigger("error",n.ImageError.WRONG_FORMAT)},r.readAsDataURL(e),void 0):t(e.getAsDataURL())}function p(n,i,r,o){var a=this,s,u,c=0,l=0,d,h,f,p;if(A=o,p=this.meta&&this.meta.tiff&&this.meta.tiff.Orientation||1,-1!==t.inArray(p,[5,6,7,8])){var v=n;n=i,i=v}return d=e(),r?(n=Math.min(n,d.width),i=Math.min(i,d.height),s=Math.max(n/d.width,i/d.height)):s=Math.min(n/d.width,i/d.height),s>1&&!r&&o?void this.trigger("Resize"):(_||(_=document.createElement("canvas")),h=Math.round(d.width*s),f=Math.round(d.height*s),r?(_.width=n,_.height=i,h>n&&(c=Math.round((h-n)/2)),f>i&&(l=Math.round((f-i)/2))):(_.width=h,_.height=f),A||g(_.width,_.height,p),m.call(this,d,_,-c,-l,h,f),this.width=_.width,this.height=_.height,R=!0,void a.trigger("Resize"))}function m(e,t,n,i,r,o){if("iOS"===c.OS)s.renderTo(e,t,{width:r,height:o,x:n,y:i});else{var a=t.getContext("2d");a.drawImage(e,n,i,r,o)}}function g(e,t,n){switch(n){case 5:case 6:case 7:case 8:_.width=t,_.height=e;break;default:_.width=e,_.height=t}var i=_.getContext("2d");switch(n){case 2:i.translate(e,0),i.scale(-1,1);break;case 3:i.translate(e,t),i.rotate(Math.PI);break;case 4:i.translate(0,t),i.scale(1,-1);break;case 5:i.rotate(.5*Math.PI),i.scale(1,-1);break;case 6:i.rotate(.5*Math.PI),i.translate(0,-t);break;case 7:i.rotate(.5*Math.PI),i.translate(e,-t),i.scale(-1,1);break;case 8:i.rotate(-.5*Math.PI),i.translate(-e,0)}}function v(){E&&(E.purge(),E=null),b=y=_=x=null,R=!1}var w=this,y,E,_,b,x,R=!1,A=!0;t.extend(this,{loadFromBlob:function(e){var t=this,i=t.getRuntime(),r=arguments.length>1?arguments[1]:!0;if(!i.can("access_binary"))throw new n.RuntimeError(n.RuntimeError.NOT_SUPPORTED_ERR);return x=e,e.isDetached()?(b=e.getSource(),void h.call(this,b)):void f.call(this,e.getSource(),function(e){r&&(b=l(e)),h.call(t,e)})},loadFromImage:function(e,t){this.meta=e.meta,x=new o(null,{name:e.name,size:e.size,type:e.type}),h.call(this,t?b=e.getAsBinaryString():e.getAsDataURL())},getInfo:function(){var t=this.getRuntime(),n;return!E&&b&&t.can("access_image_binary")&&(E=new a(b)),n={width:e().width||0,height:e().height||0,type:x.type||u.getFileMime(x.name),size:b&&b.length||x.size||0,name:x.name||"",meta:E&&E.meta||this.meta||{}},!n.meta||!n.meta.thumb||n.meta.thumb.data instanceof r||(n.meta.thumb.data=new r(null,{type:"image/jpeg",data:n.meta.thumb.data})),n},downsize:function(){p.apply(this,arguments)},getAsCanvas:function(){return _&&(_.id=this.uid+"_canvas"),_},getAsBlob:function(e,t){return e!==this.type&&p.call(this,this.width,this.height,!1),new o(null,{name:x.name||"",type:e,data:w.getAsBinaryString.call(this,e,t)})},getAsDataURL:function(e){var t=arguments[1]||90;if(!R)return y.src;if("image/jpeg"!==e)return _.toDataURL("image/png");try{return _.toDataURL("image/jpeg",t/100)}catch(n){return _.toDataURL("image/jpeg")}},getAsBinaryString:function(e,t){if(!R)return b||(b=l(w.getAsDataURL(e,t))),b;if("image/jpeg"!==e)b=l(w.getAsDataURL(e,t));else{var n;t||(t=90);try{n=_.toDataURL("image/jpeg",t/100)}catch(i){n=_.toDataURL("image/jpeg")}b=l(n),E&&(b=E.stripHeaders(b),A&&(E.meta&&E.meta.exif&&E.setExif({PixelXDimension:this.width,PixelYDimension:this.height}),b=E.writeHeaders(b)),E.purge(),E=null)}return R=!1,b},destroy:function(){w=null,v.call(this),this.getRuntime().getShim().removeInstance(this.uid)}})}return e.Image=l}),i(X,[u,c,h,f,m],function(e,t,n,i,r){function o(){var e;try{e=navigator.plugins["Shockwave Flash"],e=e.description}catch(t){try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(n){e="0.0"}}return e=e.match(/\d+/g),parseFloat(e[0]+"."+e[1])}function a(e){var i=n.get(e);i&&"OBJECT"==i.nodeName&&("IE"===t.browser?(i.style.display="none",function r(){4==i.readyState?s(e):setTimeout(r,10)}()):i.parentNode.removeChild(i))}function s(e){var t=n.get(e);if(t){for(var i in t)"function"==typeof t[i]&&(t[i]=null);t.parentNode.removeChild(t)}}function u(s){var u=this,d;s=e.extend({swf_url:t.swf_url},s),r.call(this,s,c,{access_binary:function(e){return e&&"browser"===u.mode},access_image_binary:function(e){return e&&"browser"===u.mode},display_media:r.capTrue,do_cors:r.capTrue,drag_and_drop:!1,report_upload_progress:function(){return"client"===u.mode},resize_image:r.capTrue,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!e.arrayDiff(t,["","text","document"])||"browser"===u.mode},return_status_code:function(t){return"browser"===u.mode||!e.arrayDiff(t,[200,404])},select_file:r.capTrue,select_multiple:r.capTrue,send_binary_string:function(e){return e&&"browser"===u.mode},send_browser_cookies:function(e){return e&&"browser"===u.mode},send_custom_headers:function(e){return e&&"browser"===u.mode},send_multipart:r.capTrue,slice_blob:function(e){return e&&"browser"===u.mode},stream_upload:function(e){return e&&"browser"===u.mode},summon_file_dialog:!1,upload_filesize:function(t){return e.parseSizeStr(t)<=2097152||"client"===u.mode},use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}},{access_binary:function(e){return e?"browser":"client"},access_image_binary:function(e){return e?"browser":"client"},report_upload_progress:function(e){return e?"browser":"client"},return_response_type:function(t){return e.arrayDiff(t,["","text","json","document"])?"browser":["client","browser"]},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"browser":["client","browser"]},send_binary_string:function(e){return e?"browser":"client"},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"browser":"client"},stream_upload:function(e){return e?"client":"browser"},upload_filesize:function(t){return e.parseSizeStr(t)>=2097152?"client":"browser"}},"client"),o()<10&&(this.mode=!1),e.extend(this,{getShim:function(){return n.get(this.uid)},shimExec:function(e,t){var n=[].slice.call(arguments,2);return u.getShim().exec(this.uid,e,t,n)},init:function(){var n,r,o;o=this.getShimContainer(),e.extend(o.style,{position:"absolute",top:"-8px",left:"-8px",width:"9px",height:"9px",overflow:"hidden"}),n='',"IE"===t.browser?(r=document.createElement("div"),o.appendChild(r),r.outerHTML=n,r=o=null):o.innerHTML=n,d=setTimeout(function(){u&&!u.initialized&&u.trigger("Error",new i.RuntimeError(i.RuntimeError.NOT_INIT_ERR))},5e3)},destroy:function(e){return function(){a(u.uid),e.call(u),clearTimeout(d),s=d=e=u=null}}(this.destroy)},l)}var c="flash",l={};return r.addConstructor(c,u),l}),i(V,[X,E,u],function(e,t,n){var i={init:function(e){var i=this,r=this.getRuntime();this.bind("Change",function(){var e=r.shimExec.call(i,"FileInput","getFiles");i.files=[],n.each(e,function(e){i.files.push(new t(r.uid,e))})},999),this.getRuntime().shimExec.call(this,"FileInput","init",{name:e.name,accept:e.accept,multiple:e.multiple}),this.trigger("ready")}};return e.FileInput=i}),i(W,[X,y],function(e,t){var n={slice:function(e,n,i,r){var o=this.getRuntime();return 0>n?n=Math.max(e.size+n,0):n>0&&(n=Math.min(n,e.size)),0>i?i=Math.max(e.size+i,0):i>0&&(i=Math.min(i,e.size)),e=o.shimExec.call(this,"Blob","slice",n,i,r||""),e&&(e=new t(o.uid,e)),e}};return e.Blob=n}),i(Y,[X,w],function(e,t){function n(e,n){switch(n){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var i={read:function(e,t){var i=this;return i.result="","readAsDataURL"===e&&(i.result="data:"+(t.type||"")+";base64,"),i.bind("Progress",function(t,r){r&&(i.result+=n(r,e))},999),i.getRuntime().shimExec.call(this,"FileReader","readAsBase64",t.uid)}};return e.FileReader=i}),i($,[X,w],function(e,t){function n(e,n){switch(n){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var i={read:function(e,t){var i,r=this.getRuntime();return(i=r.shimExec.call(this,"FileReaderSync","readAsBase64",t.uid))?("readAsDataURL"===e&&(i="data:"+(t.type||"")+";base64,"+i),n(i,e,t.type)):null}};return e.FileReaderSync=i}),i(J,[X,u,y,E,A,I,S],function(e,t,n,i,r,o,a){var s={send:function(e,i){function r(){e.transport=l.mode,l.shimExec.call(c,"XMLHttpRequest","send",e,i)}function s(e,t){l.shimExec.call(c,"XMLHttpRequest","appendBlob",e,t.uid),i=null,r()}function u(e,t){var n=new a;n.bind("TransportingComplete",function(){t(this.result)}),n.transport(e.getSource(),e.type,{ruid:l.uid})}var c=this,l=c.getRuntime();if(t.isEmptyObj(e.headers)||t.each(e.headers,function(e,t){l.shimExec.call(c,"XMLHttpRequest","setRequestHeader",t,e.toString())}),i instanceof o){var d;if(i.each(function(e,t){e instanceof n?d=t:l.shimExec.call(c,"XMLHttpRequest","append",t,e)}),i.hasBlob()){var h=i.getBlob();h.isDetached()?u(h,function(e){h.destroy(),s(d,e)}):s(d,h)}else i=null,r()}else i instanceof n?i.isDetached()?u(i,function(e){i.destroy(),i=e.uid,r()}):(i=i.uid,r()):r()},getResponse:function(e){var n,o,a=this.getRuntime();if(o=a.shimExec.call(this,"XMLHttpRequest","getResponseAsBlob")){if(o=new i(a.uid,o),"blob"===e)return o;try{if(n=new r,~t.inArray(e,["","text"]))return n.readAsText(o);if("json"===e&&window.JSON)return JSON.parse(n.readAsText(o))}finally{o.destroy()}}return null},abort:function(e){var t=this.getRuntime();t.shimExec.call(this,"XMLHttpRequest","abort"),this.dispatchEvent("readystatechange"),this.dispatchEvent("abort")}};return e.XMLHttpRequest=s}),i(Z,[X,y],function(e,t){var n={getAsBlob:function(e){var n=this.getRuntime(),i=n.shimExec.call(this,"Transporter","getAsBlob",e);return i?new t(n.uid,i):null}};return e.Transporter=n}),i(K,[X,u,S,y,A],function(e,t,n,i,r){var o={loadFromBlob:function(e){function t(e){r.shimExec.call(i,"Image","loadFromBlob",e.uid),i=r=null}var i=this,r=i.getRuntime();if(e.isDetached()){var o=new n;o.bind("TransportingComplete",function(){t(o.result.getSource())}),o.transport(e.getSource(),e.type,{ruid:r.uid})}else t(e.getSource())},loadFromImage:function(e){var t=this.getRuntime();return t.shimExec.call(this,"Image","loadFromImage",e.uid)},getInfo:function(){var e=this.getRuntime(),t=e.shimExec.call(this,"Image","getInfo");return!t.meta||!t.meta.thumb||t.meta.thumb.data instanceof i||(t.meta.thumb.data=new i(e.uid,t.meta.thumb.data)),t},getAsBlob:function(e,t){var n=this.getRuntime(),r=n.shimExec.call(this,"Image","getAsBlob",e,t);return r?new i(n.uid,r):null},getAsDataURL:function(){var e=this.getRuntime(),t=e.Image.getAsBlob.apply(this,arguments),n;return t?(n=new r,n.readAsDataURL(t)):null}};return e.Image=o}),i(Q,[u,c,h,f,m],function(e,t,n,i,r){function o(e){var t=!1,n=null,i,r,o,a,s,u=0;try{try{n=new ActiveXObject("AgControl.AgControl"),n.IsVersionSupported(e)&&(t=!0),n=null}catch(c){var l=navigator.plugins["Silverlight Plug-In"];if(l){for(i=l.description,"1.0.30226.2"===i&&(i="2.0.30226.2"),r=i.split(".");r.length>3;)r.pop();for(;r.length<4;)r.push(0);for(o=e.split(".");o.length>4;)o.pop();do a=parseInt(o[u],10),s=parseInt(r[u],10),u++;while(u=a&&!isNaN(a)&&(t=!0)}}}catch(d){t=!1}return t}function a(a){var c=this,l;a=e.extend({xap_url:t.xap_url},a),r.call(this,a,s,{access_binary:r.capTrue,access_image_binary:r.capTrue,display_media:r.capTrue,do_cors:r.capTrue,drag_and_drop:!1,report_upload_progress:r.capTrue,resize_image:r.capTrue,return_response_headers:function(e){return e&&"client"===c.mode},return_response_type:function(e){return"json"!==e?!0:!!window.JSON},return_status_code:function(t){return"client"===c.mode||!e.arrayDiff(t,[200,404])},select_file:r.capTrue,select_multiple:r.capTrue,send_binary_string:r.capTrue,send_browser_cookies:function(e){return e&&"browser"===c.mode},send_custom_headers:function(e){return e&&"client"===c.mode},send_multipart:r.capTrue,slice_blob:r.capTrue,stream_upload:!0,summon_file_dialog:!1,upload_filesize:r.capTrue,use_http_method:function(t){return"client"===c.mode||!e.arrayDiff(t,["GET","POST"])}},{return_response_headers:function(e){return e?"client":"browser"},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"client":["client","browser"]},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"client":"browser"},use_http_method:function(t){return e.arrayDiff(t,["GET","POST"])?"client":["client","browser"]}}),o("2.0.31005.0")&&"Opera"!==t.browser||(this.mode=!1),e.extend(this,{getShim:function(){return n.get(this.uid).content.Moxie},shimExec:function(e,t){var n=[].slice.call(arguments,2);return c.getShim().exec(this.uid,e,t,n)},init:function(){var e;e=this.getShimContainer(),e.innerHTML='',l=setTimeout(function(){c&&!c.initialized&&c.trigger("Error",new i.RuntimeError(i.RuntimeError.NOT_INIT_ERR))},"Windows"!==t.OS?1e4:5e3)},destroy:function(e){return function(){e.call(c),clearTimeout(l),a=l=e=c=null}}(this.destroy)},u)}var s="silverlight",u={};return r.addConstructor(s,a),u}),i(ee,[Q,E,u],function(e,t,n){var i={init:function(e){function i(e){for(var t="",n=0;ni;i++)n=t.keys[i],s=t[n],s&&(/^(\d|[1-9]\d+)$/.test(s)?s=parseInt(s,10):/^\d*\.\d+$/.test(s)&&(s=parseFloat(s)),r.meta[e][n]=s)}),!r.meta||!r.meta.thumb||r.meta.thumb.data instanceof n||(r.meta.thumb.data=new n(e.uid,r.meta.thumb.data))),r.width=parseInt(o.width,10),r.height=parseInt(o.height,10),r.size=parseInt(o.size,10),r.type=o.type,r.name=o.name,r}})}),i(ue,[u,f,m,c],function(e,t,n,i){function r(t){var r=this,s=n.capTest,u=n.capTrue;n.call(this,t,o,{access_binary:s(window.FileReader||window.File&&File.getAsDataURL),access_image_binary:!1,display_media:s(a.Image&&(i.can("create_canvas")||i.can("use_data_uri_over32kb"))),do_cors:!1,drag_and_drop:!1,filter_by_extension:s(function(){return"Chrome"===i.browser&&i.verComp(i.version,28,">=")||"IE"===i.browser&&i.verComp(i.version,10,">=")||"Safari"===i.browser&&i.verComp(i.version,7,">=")}()),resize_image:function(){return a.Image&&r.can("access_binary")&&i.can("create_canvas")},report_upload_progress:!1,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!!~e.inArray(t,["text","document",""])},return_status_code:function(t){return!e.arrayDiff(t,[200,404])},select_file:function(){return i.can("use_fileinput")},select_multiple:!1,send_binary_string:!1,send_custom_headers:!1,send_multipart:!0,slice_blob:!1,stream_upload:function(){return r.can("select_file")},summon_file_dialog:function(){return r.can("select_file")&&("Firefox"===i.browser&&i.verComp(i.version,4,">=")||"Opera"===i.browser&&i.verComp(i.version,12,">=")||"IE"===i.browser&&i.verComp(i.version,10,">=")||!!~e.inArray(i.browser,["Chrome","Safari"]))},upload_filesize:u,use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}}),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(r),e=r=null}}(this.destroy)}),e.extend(this.getShim(),a)}var o="html4",a={};return n.addConstructor(o,r),a}),i(ce,[ue,E,u,h,N,d,c],function(e,t,n,i,r,o,a){function s(){function e(){var o=this,l=o.getRuntime(),d,h,f,p,m,g;g=n.guid("uid_"),d=l.getShimContainer(),s&&(f=i.get(s+"_form"),f&&n.extend(f.style,{top:"100%"})),p=document.createElement("form"),p.setAttribute("id",g+"_form"),p.setAttribute("method","post"),p.setAttribute("enctype","multipart/form-data"),p.setAttribute("encoding","multipart/form-data"),n.extend(p.style,{overflow:"hidden",position:"absolute",top:0,left:0,width:"100%",height:"100%"}),m=document.createElement("input"),m.setAttribute("id",g),m.setAttribute("type","file"),m.setAttribute("name",c.name||"Filedata"),m.setAttribute("accept",u.join(",")),n.extend(m.style,{fontSize:"999px",opacity:0}),p.appendChild(m),d.appendChild(p),n.extend(m.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),"IE"===a.browser&&a.verComp(a.version,10,"<")&&n.extend(m.style,{filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"}),m.onchange=function(){var n;if(this.value){if(this.files){if(n=this.files[0],0===n.size)return void p.parentNode.removeChild(p)}else n={name:this.value};n=new t(l.uid,n),this.onchange=function(){},e.call(o),o.files=[n],m.setAttribute("id",n.uid),p.setAttribute("id",n.uid+"_form"),o.trigger("change"),m=p=null}},l.can("summon_file_dialog")&&(h=i.get(c.browse_button),r.removeEvent(h,"click",o.uid),r.addEvent(h,"click",function(e){m&&!m.disabled&&m.click(),e.preventDefault()},o.uid)),s=g,d=f=h=null}var s,u=[],c;n.extend(this,{init:function(t){var n=this,a=n.getRuntime(),s;c=t,u=t.accept.mimes||o.extList2mimes(t.accept,a.can("filter_by_extension")),s=a.getShimContainer(),function(){var e,o,u;e=i.get(t.browse_button),a.can("summon_file_dialog")&&("static"===i.getStyle(e,"position")&&(e.style.position="relative"),o=parseInt(i.getStyle(e,"z-index"),10)||1,e.style.zIndex=o,s.style.zIndex=o-1),u=a.can("summon_file_dialog")?e:s,r.addEvent(u,"mouseover",function(){n.trigger("mouseenter")},n.uid),r.addEvent(u,"mouseout",function(){n.trigger("mouseleave")},n.uid),r.addEvent(u,"mousedown",function(){n.trigger("mousedown")},n.uid),r.addEvent(i.get(t.container),"mouseup",function(){n.trigger("mouseup")},n.uid),e=null}(),e.call(this),s=null,n.trigger({type:"ready",async:!0})},disable:function(e){var t;(t=i.get(s))&&(t.disabled=!!e)},destroy:function(){var e=this.getRuntime(),t=e.getShim(),n=e.getShimContainer();r.removeAllEvents(n,this.uid),r.removeAllEvents(c&&i.get(c.container),this.uid),r.removeAllEvents(c&&i.get(c.browse_button),this.uid),n&&(n.innerHTML=""),t.removeInstance(this.uid),s=u=c=n=t=null}})}return e.FileInput=s}),i(le,[ue,F],function(e,t){return e.FileReader=t}),i(de,[ue,u,h,x,f,N,y,I],function(e,t,n,i,r,o,a,s){function u(){function e(e){var t=this,i,r,a,s,u=!1;if(l){if(i=l.id.replace(/_iframe$/,""),r=n.get(i+"_form")){for(a=r.getElementsByTagName("input"),s=a.length;s--;)switch(a[s].getAttribute("type")){case"hidden":a[s].parentNode.removeChild(a[s]);break;case"file":u=!0}a=[],u||r.parentNode.removeChild(r),r=null}setTimeout(function(){o.removeEvent(l,"load",t.uid),l.parentNode&&l.parentNode.removeChild(l);var n=t.getRuntime().getShimContainer();n.children.length||n.parentNode.removeChild(n),n=l=null,e()},1)}}var u,c,l;t.extend(this,{send:function(d,h){function f(){var n=m.getShimContainer()||document.body,r=document.createElement("div");r.innerHTML='',l=r.firstChild,n.appendChild(l),o.addEvent(l,"load",function(){var n;try{n=l.contentWindow.document||l.contentDocument||window.frames[l.id].document,/^4(0[0-9]|1[0-7]|2[2346])\s/.test(n.title)?u=n.title.replace(/^(\d+).*$/,"$1"):(u=200,c=t.trim(n.body.innerHTML),p.trigger({type:"progress",loaded:c.length,total:c.length}),y&&p.trigger({type:"uploadprogress",loaded:y.size||1025,total:y.size||1025}))}catch(r){if(!i.hasSameOrigin(d.url))return void e.call(p,function(){p.trigger("error")});u=404}e.call(p,function(){p.trigger("load")})},p.uid)}var p=this,m=p.getRuntime(),g,v,w,y;if(u=c=null,h instanceof s&&h.hasBlob()){if(y=h.getBlob(),g=y.uid,w=n.get(g),v=n.get(g+"_form"),!v)throw new r.DOMException(r.DOMException.NOT_FOUND_ERR)}else g=t.guid("uid_"),v=document.createElement("form"),v.setAttribute("id",g+"_form"),v.setAttribute("method",d.method),v.setAttribute("enctype","multipart/form-data"),v.setAttribute("encoding","multipart/form-data"),m.getShimContainer().appendChild(v);v.setAttribute("target",g+"_iframe"),h instanceof s&&h.each(function(e,n){if(e instanceof a)w&&w.setAttribute("name",n);else{var i=document.createElement("input");t.extend(i,{type:"hidden",name:n,value:e}),w?v.insertBefore(i,w):v.appendChild(i)}}),v.setAttribute("action",d.url),f(),v.submit(),p.trigger("loadstart")},getStatus:function(){return u},getResponse:function(e){if("json"===e&&"string"===t.typeOf(c)&&window.JSON)try{ -return JSON.parse(c.replace(/^\s*]*>/,"").replace(/<\/pre>\s*$/,""))}catch(n){return null}return c},abort:function(){var t=this;l&&l.contentWindow&&(l.contentWindow.stop?l.contentWindow.stop():l.contentWindow.document.execCommand?l.contentWindow.document.execCommand("Stop"):l.src="about:blank"),e.call(this,function(){t.dispatchEvent("abort")})}})}return e.XMLHttpRequest=u}),i(he,[ue,j],function(e,t){return e.Image=t}),a([u,c,l,d,h,f,p,m,g,v,w,y,E,_,b,x,R,A,I,T,S,O,N])}(this);;(function(e){"use strict";var t={},n=e.moxie.core.utils.Basic.inArray;return function r(e){var i,s;for(i in e)s=typeof e[i],s==="object"&&!~n(i,["Exceptions","Env","Mime"])?r(e[i]):s==="function"&&(t[i]=e[i])}(e.moxie),t.Env=e.moxie.core.utils.Env,t.Mime=e.moxie.core.utils.Mime,t.Exceptions=e.moxie.core.Exceptions,e.mOxie=t,e.o||(e.o=t),t})(this); \ No newline at end of file +!function(e,t){var i=function(){var e={};return t.apply(e,arguments),e.moxie};"function"==typeof define&&define.amd?define("moxie",[],i):"object"==typeof module&&module.exports?module.exports=i():e.moxie=i()}(this||window,function(){!function(e,t){"use strict";function i(e,t){for(var i,n=[],r=0;r0&&c(n,function(n,u){var c=-1!==h(e(n),["array","object"]);return n===r||t&&o[u]===r?!0:(c&&i&&(n=a(n)),e(o[u])===e(n)&&c?s(t,i,[o[u],n]):o[u]=n,void 0)})}),o}function u(e,t){function i(){this.constructor=e}for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n]);return i.prototype=t.prototype,e.prototype=new i,e.parent=t.prototype,e}function c(e,t){var i,n,r,o;if(e){try{i=e.length}catch(a){i=o}if(i===o||"number"!=typeof i){for(n in e)if(e.hasOwnProperty(n)&&t(e[n],n)===!1)return}else for(r=0;i>r;r++)if(t(e[r],r)===!1)return}}function l(t){var i;if(!t||"object"!==e(t))return!0;for(i in t)return!1;return!0}function d(t,i){function n(r){"function"===e(t[r])&&t[r](function(e){++ri;i++)if(t[i]===e)return i}return-1}function f(t,i){var n=[];"array"!==e(t)&&(t=[t]),"array"!==e(i)&&(i=[i]);for(var r in t)-1===h(t[r],i)&&n.push(t[r]);return n.length?n:!1}function p(e,t){var i=[];return c(e,function(e){-1!==h(e,t)&&i.push(e)}),i.length?i:null}function g(e){var t,i=[];for(t=0;ti;i++)n+=Math.floor(65535*Math.random()).toString(32);return(t||"o_")+n+(e++).toString(32)}}();return{guid:E,typeOf:e,extend:t,extendIf:i,extendImmutable:n,extendImmutableIf:r,clone:o,inherit:u,each:c,isEmptyObj:l,inSeries:d,inParallel:m,inArray:h,arrayDiff:f,arrayIntersect:p,toArray:g,trim:x,sprintf:w,parseSizeStr:v,delay:y}}),n("moxie/core/utils/Encode",[],function(){var e=function(e){return unescape(encodeURIComponent(e))},t=function(e){return decodeURIComponent(escape(e))},i=function(e,i){if("function"==typeof window.atob)return i?t(window.atob(e)):window.atob(e);var n,r,o,a,s,u,c,l,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m=0,h=0,f="",p=[];if(!e)return e;e+="";do a=d.indexOf(e.charAt(m++)),s=d.indexOf(e.charAt(m++)),u=d.indexOf(e.charAt(m++)),c=d.indexOf(e.charAt(m++)),l=a<<18|s<<12|u<<6|c,n=255&l>>16,r=255&l>>8,o=255&l,p[h++]=64==u?String.fromCharCode(n):64==c?String.fromCharCode(n,r):String.fromCharCode(n,r,o);while(m>18,s=63&l>>12,u=63&l>>6,c=63&l,p[h++]=d.charAt(a)+d.charAt(s)+d.charAt(u)+d.charAt(c);while(mn;n++)if(e[n]!=t[n]){if(e[n]=u(e[n]),t[n]=u(t[n]),e[n]t[n]){o=1;break}}if(!i)return o;switch(i){case">":case"gt":return o>0;case">=":case"ge":return o>=0;case"<=":case"le":return 0>=o;case"==":case"=":case"eq":return 0===o;case"<>":case"!=":case"ne":return 0!==o;case"":case"<":case"lt":return 0>o;default:return null}}var n=function(e){var t="",i="?",n="function",r="undefined",o="object",a="name",s="version",u={has:function(e,t){return-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()}},c={rgx:function(){for(var t,i,a,s,u,c,l,d=0,m=arguments;d0?2==u.length?t[u[0]]=typeof u[1]==n?u[1].call(this,l):u[1]:3==u.length?t[u[0]]=typeof u[1]!==n||u[1].exec&&u[1].test?l?l.replace(u[1],u[2]):e:l?u[1].call(this,l,u[2]):e:4==u.length&&(t[u[0]]=l?u[3].call(this,l.replace(u[1],u[2])):e):t[u]=l?l:e;break}if(c)break}return t},str:function(t,n){for(var r in n)if(typeof n[r]===o&&n[r].length>0){for(var a=0;a=")),i.use_blob_uri},use_data_uri:function(){var e=new Image;return e.onload=function(){i.use_data_uri=1===e.width&&1===e.height},setTimeout(function(){e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="},1),!1}(),use_data_uri_over32kb:function(){return i.use_data_uri&&("IE"!==a.browser||a.version>=9)},use_data_uri_of:function(e){return i.use_data_uri&&33e3>e||i.use_data_uri_over32kb()},use_fileinput:function(){if(navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/))return!1;var e=document.createElement("input");return e.setAttribute("type","file"),i.use_fileinput=!e.disabled},use_webgl:function(){var e,n=document.createElement("canvas"),r=null;try{r=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(o){}return r||(r=null),e=!!r,i.use_webgl=e,n=t,e}};return function(t){var n=[].slice.call(arguments);return n.shift(),"function"===e.typeOf(i[t])?i[t].apply(this,n):!!i[t]}}(),o=(new n).getResult(),a={can:r,uaParser:n,browser:o.browser.name,version:o.browser.version,os:o.os.name,osVersion:o.os.version,verComp:i,swf_url:"../flash/Moxie.swf",xap_url:"../silverlight/Moxie.xap",global_event_dispatcher:"moxie.core.EventTarget.instance.dispatchEvent"};return a.OS=a.os,a}),n("moxie/core/Exceptions",["moxie/core/utils/Basic"],function(e){function t(e,t){var i;for(i in e)if(e[i]===t)return i;return null}return{RuntimeError:function(){function i(e,i){this.code=e,this.name=t(n,e),this.message=this.name+(i||": RuntimeError "+this.code)}var n={NOT_INIT_ERR:1,EXCEPTION_ERR:3,NOT_SUPPORTED_ERR:9,JS_ERR:4};return e.extend(i,n),i.prototype=Error.prototype,i}(),OperationNotAllowedException:function(){function t(e){this.code=e,this.name="OperationNotAllowedException"}return e.extend(t,{NOT_ALLOWED_ERR:1}),t.prototype=Error.prototype,t}(),ImageError:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": ImageError "+this.code}var n={WRONG_FORMAT:1,MAX_RESOLUTION_ERR:2,INVALID_META_ERR:3};return e.extend(i,n),i.prototype=Error.prototype,i}(),FileException:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": FileException "+this.code}var n={NOT_FOUND_ERR:1,SECURITY_ERR:2,ABORT_ERR:3,NOT_READABLE_ERR:4,ENCODING_ERR:5,NO_MODIFICATION_ALLOWED_ERR:6,INVALID_STATE_ERR:7,SYNTAX_ERR:8};return e.extend(i,n),i.prototype=Error.prototype,i}(),DOMException:function(){function i(e){this.code=e,this.name=t(n,e),this.message=this.name+": DOMException "+this.code}var n={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};return e.extend(i,n),i.prototype=Error.prototype,i}(),EventException:function(){function t(e){this.code=e,this.name="EventException"}return e.extend(t,{UNSPECIFIED_EVENT_TYPE_ERR:0}),t.prototype=Error.prototype,t}()}}),n("moxie/core/utils/Dom",["moxie/core/utils/Env"],function(e){var t=function(e){return"string"!=typeof e?e:document.getElementById(e)},i=function(e,t){if(!e.className)return!1;var i=new RegExp("(^|\\s+)"+t+"(\\s+|$)");return i.test(e.className)},n=function(e,t){i(e,t)||(e.className=e.className?e.className.replace(/\s+$/,"")+" "+t:t)},r=function(e,t){if(e.className){var i=new RegExp("(^|\\s+)"+t+"(\\s+|$)");e.className=e.className.replace(i,function(e,t,i){return" "===t&&" "===i?" ":""})}},o=function(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(e,null)[t]:void 0},a=function(t,i){function n(e){var t,i,n=0,r=0;return e&&(i=e.getBoundingClientRect(),t="CSS1Compat"===c.compatMode?c.documentElement:c.body,n=i.left+t.scrollLeft,r=i.top+t.scrollTop),{x:n,y:r}}var r,o,a,s=0,u=0,c=document;if(t=t,i=i||c.body,t&&t.getBoundingClientRect&&"IE"===e.browser&&(!c.documentMode||c.documentMode<8))return o=n(t),a=n(i),{x:o.x-a.x,y:o.y-a.y};for(r=t;r&&r!=i&&r.nodeType;)s+=r.offsetLeft||0,u+=r.offsetTop||0,r=r.offsetParent;for(r=t.parentNode;r&&r!=i&&r.nodeType;)s-=r.scrollLeft||0,u-=r.scrollTop||0,r=r.parentNode;return{x:s,y:u}},s=function(e){return{w:e.offsetWidth||e.clientWidth,h:e.offsetHeight||e.clientHeight}};return{get:t,hasClass:i,addClass:n,removeClass:r,getStyle:o,getPos:a,getSize:s}}),n("moxie/core/EventTarget",["moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Basic"],function(e,t,i){function n(){this.uid=i.guid()}var r={};return i.extend(n.prototype,{init:function(){this.uid||(this.uid=i.guid("uid_"))},addEventListener:function(e,t,n,o){var a,s=this;return this.hasOwnProperty("uid")||(this.uid=i.guid("uid_")),e=i.trim(e),/\s/.test(e)?(i.each(e.split(/\s+/),function(e){s.addEventListener(e,t,n,o)}),void 0):(e=e.toLowerCase(),n=parseInt(n,10)||0,a=r[this.uid]&&r[this.uid][e]||[],a.push({fn:t,priority:n,scope:o||this}),r[this.uid]||(r[this.uid]={}),r[this.uid][e]=a,void 0)},hasEventListener:function(e){var t;return e?(e=e.toLowerCase(),t=r[this.uid]&&r[this.uid][e]):t=r[this.uid],t?t:!1},removeEventListener:function(e,t){var n,o,a=this;if(e=e.toLowerCase(),/\s/.test(e))return i.each(e.split(/\s+/),function(e){a.removeEventListener(e,t)}),void 0;if(n=r[this.uid]&&r[this.uid][e]){if(t){for(o=n.length-1;o>=0;o--)if(n[o].fn===t){n.splice(o,1);break}}else n=[];n.length||(delete r[this.uid][e],i.isEmptyObj(r[this.uid])&&delete r[this.uid])}},removeAllEventListeners:function(){r[this.uid]&&delete r[this.uid]},dispatchEvent:function(e){var n,o,a,s,u,c={},l=!0;if("string"!==i.typeOf(e)){if(s=e,"string"!==i.typeOf(s.type))throw new t.EventException(t.EventException.UNSPECIFIED_EVENT_TYPE_ERR);e=s.type,s.total!==u&&s.loaded!==u&&(c.total=s.total,c.loaded=s.loaded),c.async=s.async||!1}if(-1!==e.indexOf("::")?function(t){n=t[0],e=t[1]}(e.split("::")):n=this.uid,e=e.toLowerCase(),o=r[n]&&r[n][e]){o.sort(function(e,t){return t.priority-e.priority}),a=[].slice.call(arguments),a.shift(),c.type=e,a.unshift(c);var d=[];i.each(o,function(e){a[0].target=e.scope,c.async?d.push(function(t){setTimeout(function(){t(e.fn.apply(e.scope,a)===!1)},1)}):d.push(function(t){t(e.fn.apply(e.scope,a)===!1)})}),d.length&&i.inSeries(d,function(e){l=!e})}return l},bindOnce:function(e,t,i,n){var r=this;r.bind.call(this,e,function o(){return r.unbind(e,o),t.apply(this,arguments)},i,n)},bind:function(){this.addEventListener.apply(this,arguments)},unbind:function(){this.removeEventListener.apply(this,arguments)},unbindAll:function(){this.removeAllEventListeners.apply(this,arguments)},trigger:function(){return this.dispatchEvent.apply(this,arguments)},handleEventProps:function(e){var t=this;this.bind(e.join(" "),function(e){var t="on"+e.type.toLowerCase();"function"===i.typeOf(this[t])&&this[t].apply(this,arguments)}),i.each(e,function(e){e="on"+e.toLowerCase(e),"undefined"===i.typeOf(t[e])&&(t[e]=null)})}}),n.instance=new n,n}),n("moxie/runtime/Runtime",["moxie/core/utils/Env","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/EventTarget"],function(e,t,i,n){function r(e,n,o,s,u){var c,l=this,d=t.guid(n+"_"),m=u||"browser";e=e||{},a[d]=this,o=t.extend({access_binary:!1,access_image_binary:!1,display_media:!1,do_cors:!1,drag_and_drop:!1,filter_by_extension:!0,resize_image:!1,report_upload_progress:!1,return_response_headers:!1,return_response_type:!1,return_status_code:!0,send_custom_headers:!1,select_file:!1,select_folder:!1,select_multiple:!0,send_binary_string:!1,send_browser_cookies:!0,send_multipart:!0,slice_blob:!1,stream_upload:!1,summon_file_dialog:!1,upload_filesize:!0,use_http_method:!0},o),e.preferred_caps&&(m=r.getMode(s,e.preferred_caps,m)),c=function(){var e={};return{exec:function(t,i,n,r){return c[i]&&(e[t]||(e[t]={context:this,instance:new c[i]}),e[t].instance[n])?e[t].instance[n].apply(this,r):void 0},removeInstance:function(t){delete e[t]},removeAllInstances:function(){var i=this;t.each(e,function(e,n){"function"===t.typeOf(e.instance.destroy)&&e.instance.destroy.call(e.context),i.removeInstance(n)})}}}(),t.extend(this,{initialized:!1,uid:d,type:n,mode:r.getMode(s,e.required_caps,m),shimid:d+"_container",clients:0,options:e,can:function(e,i){var n=arguments[2]||o;if("string"===t.typeOf(e)&&"undefined"===t.typeOf(i)&&(e=r.parseCaps(e)),"object"===t.typeOf(e)){for(var a in e)if(!this.can(a,e[a],n))return!1;return!0}return"function"===t.typeOf(n[e])?n[e].call(this,i):i===n[e]},getShimContainer:function(){var e,n=i.get(this.shimid);return n||(e=i.get(this.options.container)||document.body,n=document.createElement("div"),n.id=this.shimid,n.className="moxie-shim moxie-shim-"+this.type,t.extend(n.style,{position:"absolute",top:"0px",left:"0px",width:"1px",height:"1px",overflow:"hidden"}),e.appendChild(n),e=null),n},getShim:function(){return c},shimExec:function(e,t){var i=[].slice.call(arguments,2);return l.getShim().exec.call(this,this.uid,e,t,i)},exec:function(e,t){var i=[].slice.call(arguments,2);return l[e]&&l[e][t]?l[e][t].apply(this,i):l.shimExec.apply(this,arguments)},destroy:function(){if(l){var e=i.get(this.shimid);e&&e.parentNode.removeChild(e),c&&c.removeAllInstances(),this.unbindAll(),delete a[this.uid],this.uid=null,d=l=c=e=null}}}),this.mode&&e.required_caps&&!this.can(e.required_caps)&&(this.mode=!1)}var o={},a={};return r.order="html5,flash,silverlight,html4",r.getRuntime=function(e){return a[e]?a[e]:!1},r.addConstructor=function(e,t){t.prototype=n.instance,o[e]=t},r.getConstructor=function(e){return o[e]||null},r.getInfo=function(e){var t=r.getRuntime(e);return t?{uid:t.uid,type:t.type,mode:t.mode,can:function(){return t.can.apply(t,arguments)}}:null},r.parseCaps=function(e){var i={};return"string"!==t.typeOf(e)?e||{}:(t.each(e.split(","),function(e){i[e]=!0}),i)},r.can=function(e,t){var i,n,o=r.getConstructor(e);return o?(i=new o({required_caps:t}),n=i.mode,i.destroy(),!!n):!1},r.thatCan=function(e,t){var i=(t||r.order).split(/\s*,\s*/);for(var n in i)if(r.can(i[n],e))return i[n];return null},r.getMode=function(e,i,n){var r=null;if("undefined"===t.typeOf(n)&&(n="browser"),i&&!t.isEmptyObj(e)){if(t.each(i,function(i,n){if(e.hasOwnProperty(n)){var o=e[n](i);if("string"==typeof o&&(o=[o]),r){if(!(r=t.arrayIntersect(r,o)))return r=!1}else r=o}}),r)return-1!==t.inArray(n,r)?n:r[0];if(r===!1)return!1}return n},r.getGlobalEventTarget=function(){if(/^moxie\./.test(e.global_event_dispatcher)&&!e.can("access_global_ns")){var i=t.guid("moxie_event_target_");window[i]=function(e,t){n.instance.dispatchEvent(e,t)},e.global_event_dispatcher=i}return e.global_event_dispatcher},r.capTrue=function(){return!0},r.capFalse=function(){return!1},r.capTest=function(e){return function(){return!!e}},r}),n("moxie/runtime/RuntimeClient",["moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Basic","moxie/runtime/Runtime"],function(e,t,i,n){return function(){var e;i.extend(this,{connectRuntime:function(r){function o(i){var a,u;return i.length?(a=i.shift().toLowerCase(),(u=n.getConstructor(a))?(e=new u(r),e.bind("Init",function(){e.initialized=!0,setTimeout(function(){e.clients++,s.ruid=e.uid,s.trigger("RuntimeInit",e)},1)}),e.bind("Error",function(){e.destroy(),o(i)}),e.bind("Exception",function(e,i){var n=i.name+"(#"+i.code+")"+(i.message?", from: "+i.message:"");s.trigger("RuntimeError",new t.RuntimeError(t.RuntimeError.EXCEPTION_ERR,n))}),e.mode?(e.init(),void 0):(e.trigger("Error"),void 0)):(o(i),void 0)):(s.trigger("RuntimeError",new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)),e=null,void 0)}var a,s=this;if("string"===i.typeOf(r)?a=r:"string"===i.typeOf(r.ruid)&&(a=r.ruid),a){if(e=n.getRuntime(a))return s.ruid=a,e.clients++,e;throw new t.RuntimeError(t.RuntimeError.NOT_INIT_ERR)}o((r.runtime_order||n.order).split(/\s*,\s*/))},disconnectRuntime:function(){e&&--e.clients<=0&&e.destroy(),e=null},getRuntime:function(){return e&&e.uid?e:e=null},exec:function(){return e?e.exec.apply(this,arguments):null},can:function(t){return e?e.can(t):!1}})}}),n("moxie/file/Blob",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/runtime/RuntimeClient"],function(e,t,i){function n(o,a){function s(t,i,o){var a,s=r[this.uid];return"string"===e.typeOf(s)&&s.length?(a=new n(null,{type:o,size:i-t}),a.detach(s.substr(t,a.size)),a):null}i.call(this),o&&this.connectRuntime(o),a?"string"===e.typeOf(a)&&(a={data:a}):a={},e.extend(this,{uid:a.uid||e.guid("uid_"),ruid:o,size:a.size||0,type:a.type||"",slice:function(e,t,i){return this.isDetached()?s.apply(this,arguments):this.getRuntime().exec.call(this,"Blob","slice",this.getSource(),e,t,i)},getSource:function(){return r[this.uid]?r[this.uid]:null},detach:function(e){if(this.ruid&&(this.getRuntime().exec.call(this,"Blob","destroy"),this.disconnectRuntime(),this.ruid=null),e=e||"","data:"==e.substr(0,5)){var i=e.indexOf(";base64,");this.type=e.substring(5,i),e=t.atob(e.substring(i+8))}this.size=e.length,r[this.uid]=e},isDetached:function(){return!this.ruid&&"string"===e.typeOf(r[this.uid])},destroy:function(){this.detach(),delete r[this.uid]}}),a.data?this.detach(a.data):r[this.uid]=a}var r={};return n}),n("moxie/core/I18n",["moxie/core/utils/Basic"],function(e){var t={};return{addI18n:function(i){return e.extend(t,i)},translate:function(e){return t[e]||e},_:function(e){return this.translate(e)},sprintf:function(t){var i=[].slice.call(arguments,1);return t.replace(/%[a-z]/g,function(){var t=i.shift();return"undefined"!==e.typeOf(t)?t:""})}}}),n("moxie/core/utils/Mime",["moxie/core/utils/Basic","moxie/core/I18n"],function(e,t){var i="application/msword,doc dot,application/pdf,pdf,application/pgp-signature,pgp,application/postscript,ps ai eps,application/rtf,rtf,application/vnd.ms-excel,xls xlb xlt xla,application/vnd.ms-powerpoint,ppt pps pot ppa,application/zip,zip,application/x-shockwave-flash,swf swfl,application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx,application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx,application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx,application/vnd.openxmlformats-officedocument.presentationml.template,potx,application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx,application/x-javascript,js,application/json,json,audio/mpeg,mp3 mpga mpega mp2,audio/x-wav,wav,audio/x-m4a,m4a,audio/ogg,oga ogg,audio/aiff,aiff aif,audio/flac,flac,audio/aac,aac,audio/ac3,ac3,audio/x-ms-wma,wma,image/bmp,bmp,image/gif,gif,image/jpeg,jpg jpeg jpe,image/photoshop,psd,image/png,png,image/svg+xml,svg svgz,image/tiff,tiff tif,text/plain,asc txt text diff log,text/html,htm html xhtml,text/css,css,text/csv,csv,text/rtf,rtf,video/mpeg,mpeg mpg mpe m2v,video/quicktime,qt mov,video/mp4,mp4,video/x-m4v,m4v,video/x-flv,flv,video/x-ms-wmv,wmv,video/avi,avi,video/webm,webm,video/3gpp,3gpp 3gp,video/3gpp2,3g2,video/vnd.rn-realvideo,rv,video/ogg,ogv,video/x-matroska,mkv,application/vnd.oasis.opendocument.formula-template,otf,application/octet-stream,exe",n={},r={},o=function(e){var t,i,o,a=e.split(/,/);for(t=0;ta;a++)o+=String.fromCharCode(r[a]);return o}}t.call(this),e.extend(this,{uid:e.guid("uid_"),readAsBinaryString:function(e){return n.call(this,"readAsBinaryString",e)},readAsDataURL:function(e){return n.call(this,"readAsDataURL",e)},readAsText:function(e){return n.call(this,"readAsText",e)}})}}),n("moxie/xhr/FormData",["moxie/core/Exceptions","moxie/core/utils/Basic","moxie/file/Blob"],function(e,t,i){function n(){var e,n=[];t.extend(this,{append:function(r,o){var a=this,s=t.typeOf(o);o instanceof i?e={name:r,value:o}:"array"===s?(r+="[]",t.each(o,function(e){a.append(r,e)})):"object"===s?t.each(o,function(e,t){a.append(r+"["+t+"]",e)}):"null"===s||"undefined"===s||"number"===s&&isNaN(o)?a.append(r,"false"):n.push({name:r,value:o.toString()})},hasBlob:function(){return!!this.getBlob()},getBlob:function(){return e&&e.value||null},getBlobName:function(){return e&&e.name||null},each:function(i){t.each(n,function(e){i(e.value,e.name)}),e&&i(e.value,e.name)},destroy:function(){e=null,n=[]}})}return n}),n("moxie/xhr/XMLHttpRequest",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/core/utils/Url","moxie/runtime/Runtime","moxie/runtime/RuntimeTarget","moxie/file/Blob","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/core/utils/Env","moxie/core/utils/Mime"],function(e,t,i,n,r,o,a,s,u,c,l,d){function m(){this.uid=e.guid("uid_")}function h(){function i(e,t){return I.hasOwnProperty(e)?1===arguments.length?l.can("define_property")?I[e]:A[e]:(l.can("define_property")?I[e]=t:A[e]=t,void 0):void 0}function u(t){function n(){_&&(_.destroy(),_=null),s.dispatchEvent("loadend"),s=null}function r(r){_.bind("LoadStart",function(e){i("readyState",h.LOADING),s.dispatchEvent("readystatechange"),s.dispatchEvent(e),L&&s.upload.dispatchEvent(e)}),_.bind("Progress",function(e){i("readyState")!==h.LOADING&&(i("readyState",h.LOADING),s.dispatchEvent("readystatechange")),s.dispatchEvent(e)}),_.bind("UploadProgress",function(e){L&&s.upload.dispatchEvent({type:"progress",lengthComputable:!1,total:e.total,loaded:e.loaded})}),_.bind("Load",function(t){i("readyState",h.DONE),i("status",Number(r.exec.call(_,"XMLHttpRequest","getStatus")||0)),i("statusText",f[i("status")]||""),i("response",r.exec.call(_,"XMLHttpRequest","getResponse",i("responseType"))),~e.inArray(i("responseType"),["text",""])?i("responseText",i("response")):"document"===i("responseType")&&i("responseXML",i("response")),U=r.exec.call(_,"XMLHttpRequest","getAllResponseHeaders"),s.dispatchEvent("readystatechange"),i("status")>0?(L&&s.upload.dispatchEvent(t),s.dispatchEvent(t)):(F=!0,s.dispatchEvent("error")),n()}),_.bind("Abort",function(e){s.dispatchEvent(e),n()}),_.bind("Error",function(e){F=!0,i("readyState",h.DONE),s.dispatchEvent("readystatechange"),M=!0,s.dispatchEvent(e),n()}),r.exec.call(_,"XMLHttpRequest","send",{url:x,method:v,async:T,user:w,password:y,headers:S,mimeType:D,encoding:O,responseType:s.responseType,withCredentials:s.withCredentials,options:k},t)}var s=this;E=(new Date).getTime(),_=new a,"string"==typeof k.required_caps&&(k.required_caps=o.parseCaps(k.required_caps)),k.required_caps=e.extend({},k.required_caps,{return_response_type:s.responseType}),t instanceof c&&(k.required_caps.send_multipart=!0),e.isEmptyObj(S)||(k.required_caps.send_custom_headers=!0),B||(k.required_caps.do_cors=!0),k.ruid?r(_.connectRuntime(k)):(_.bind("RuntimeInit",function(e,t){r(t)}),_.bind("RuntimeError",function(e,t){s.dispatchEvent("RuntimeError",t)}),_.connectRuntime(k))}function g(){i("responseText",""),i("responseXML",null),i("response",null),i("status",0),i("statusText",""),E=b=null}var x,v,w,y,E,b,_,R,A=this,I={timeout:0,readyState:h.UNSENT,withCredentials:!1,status:0,statusText:"",responseType:"",responseXML:null,responseText:null,response:null},T=!0,S={},O=null,D=null,N=!1,C=!1,L=!1,M=!1,F=!1,B=!1,P=null,H=null,k={},U="";e.extend(this,I,{uid:e.guid("uid_"),upload:new m,open:function(o,a,s,u,c){var l;if(!o||!a)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(/[\u0100-\uffff]/.test(o)||n.utf8_encode(o)!==o)throw new t.DOMException(t.DOMException.SYNTAX_ERR);if(~e.inArray(o.toUpperCase(),["CONNECT","DELETE","GET","HEAD","OPTIONS","POST","PUT","TRACE","TRACK"])&&(v=o.toUpperCase()),~e.inArray(v,["CONNECT","TRACE","TRACK"]))throw new t.DOMException(t.DOMException.SECURITY_ERR);if(a=n.utf8_encode(a),l=r.parseUrl(a),B=r.hasSameOrigin(l),x=r.resolveUrl(a),(u||c)&&!B)throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);if(w=u||l.user,y=c||l.pass,T=s||!0,T===!1&&(i("timeout")||i("withCredentials")||""!==i("responseType")))throw new t.DOMException(t.DOMException.INVALID_ACCESS_ERR);N=!T,C=!1,S={},g.call(this),i("readyState",h.OPENED),this.dispatchEvent("readystatechange")},setRequestHeader:function(r,o){var a=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];if(i("readyState")!==h.OPENED||C)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(/[\u0100-\uffff]/.test(r)||n.utf8_encode(r)!==r)throw new t.DOMException(t.DOMException.SYNTAX_ERR);return r=e.trim(r).toLowerCase(),~e.inArray(r,a)||/^(proxy\-|sec\-)/.test(r)?!1:(S[r]?S[r]+=", "+o:S[r]=o,!0)},hasRequestHeader:function(e){return e&&S[e.toLowerCase()]||!1},getAllResponseHeaders:function(){return U||""},getResponseHeader:function(t){return t=t.toLowerCase(),F||~e.inArray(t,["set-cookie","set-cookie2"])?null:U&&""!==U&&(R||(R={},e.each(U.split(/\r\n/),function(t){var i=t.split(/:\s+/);2===i.length&&(i[0]=e.trim(i[0]),R[i[0].toLowerCase()]={header:i[0],value:e.trim(i[1])})})),R.hasOwnProperty(t))?R[t].header+": "+R[t].value:null},overrideMimeType:function(n){var r,o;if(~e.inArray(i("readyState"),[h.LOADING,h.DONE]))throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(n=e.trim(n.toLowerCase()),/;/.test(n)&&(r=n.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))&&(n=r[1],r[2]&&(o=r[2])),!d.mimes[n])throw new t.DOMException(t.DOMException.SYNTAX_ERR);P=n,H=o},send:function(i,r){if(k="string"===e.typeOf(r)?{ruid:r}:r?r:{},this.readyState!==h.OPENED||C)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);if(i instanceof s)k.ruid=i.ruid,D=i.type||"application/octet-stream";else if(i instanceof c){if(i.hasBlob()){var o=i.getBlob();k.ruid=o.ruid,D=o.type||"application/octet-stream"}}else"string"==typeof i&&(O="UTF-8",D="text/plain;charset=UTF-8",i=n.utf8_encode(i));this.withCredentials||(this.withCredentials=k.required_caps&&k.required_caps.send_browser_cookies&&!B),L=!N&&this.upload.hasEventListener(),F=!1,M=!i,N||(C=!0),u.call(this,i)},abort:function(){if(F=!0,N=!1,~e.inArray(i("readyState"),[h.UNSENT,h.OPENED,h.DONE]))i("readyState",h.UNSENT);else{if(i("readyState",h.DONE),C=!1,!_)throw new t.DOMException(t.DOMException.INVALID_STATE_ERR);_.getRuntime().exec.call(_,"XMLHttpRequest","abort",M),M=!0}},destroy:function(){_&&("function"===e.typeOf(_.destroy)&&_.destroy(),_=null),this.unbindAll(),this.upload&&(this.upload.unbindAll(),this.upload=null)}}),this.handleEventProps(p.concat(["readystatechange"])),this.upload.handleEventProps(p)}var f={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Reserved",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",426:"Upgrade Required",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",510:"Not Extended"};m.prototype=i.instance;var p=["loadstart","progress","abort","error","load","timeout","loadend"];return h.UNSENT=0,h.OPENED=1,h.HEADERS_RECEIVED=2,h.LOADING=3,h.DONE=4,h.prototype=i.instance,h}),n("moxie/runtime/Transporter",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/runtime/RuntimeClient","moxie/core/EventTarget"],function(e,t,i,n){function r(){function n(){l=d=0,c=this.result=null}function o(t,i){var n=this;u=i,n.bind("TransportingProgress",function(t){d=t.loaded,l>d&&-1===e.inArray(n.state,[r.IDLE,r.DONE])&&a.call(n)},999),n.bind("TransportingComplete",function(){d=l,n.state=r.DONE,c=null,n.result=u.exec.call(n,"Transporter","getAsBlob",t||"")},999),n.state=r.BUSY,n.trigger("TransportingStarted"),a.call(n)}function a(){var e,i=this,n=l-d;m>n&&(m=n),e=t.btoa(c.substr(d,m)),u.exec.call(i,"Transporter","receive",e,l)}var s,u,c,l,d,m;i.call(this),e.extend(this,{uid:e.guid("uid_"),state:r.IDLE,result:null,transport:function(t,i,r){var a=this;if(r=e.extend({chunk_size:204798},r),(s=r.chunk_size%3)&&(r.chunk_size+=3-s),m=r.chunk_size,n.call(this),c=t,l=t.length,"string"===e.typeOf(r)||r.ruid)o.call(a,i,this.connectRuntime(r));else{var u=function(e,t){a.unbind("RuntimeInit",u),o.call(a,i,t)};this.bind("RuntimeInit",u),this.connectRuntime(r)}},abort:function(){var e=this;e.state=r.IDLE,u&&(u.exec.call(e,"Transporter","clear"),e.trigger("TransportingAborted")),n.call(e)},destroy:function(){this.unbindAll(),u=null,this.disconnectRuntime(),n.call(this)}})}return r.IDLE=0,r.BUSY=1,r.DONE=2,r.prototype=n.instance,r}),n("moxie/image/Image",["moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/file/FileReaderSync","moxie/xhr/XMLHttpRequest","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/runtime/Transporter","moxie/core/utils/Env","moxie/core/EventTarget","moxie/file/Blob","moxie/file/File","moxie/core/utils/Encode"],function(e,t,i,n,r,o,a,s,u,c,l,d,m){function h(){function n(e){try{return e||(e=this.exec("Image","getInfo")),this.size=e.size,this.width=e.width,this.height=e.height,this.type=e.type,this.meta=e.meta,""===this.name&&(this.name=e.name),!0}catch(t){return this.trigger("error",t.code),!1}}function c(t){var n=e.typeOf(t);try{if(t instanceof h){if(!t.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);p.apply(this,arguments)}else if(t instanceof l){if(!~e.inArray(t.type,["image/jpeg","image/png"]))throw new i.ImageError(i.ImageError.WRONG_FORMAT);g.apply(this,arguments)}else if(-1!==e.inArray(n,["blob","file"]))c.call(this,new d(null,t),arguments[1]);else if("string"===n)"data:"===t.substr(0,5)?c.call(this,new l(null,{data:t}),arguments[1]):x.apply(this,arguments);else{if("node"!==n||"img"!==t.nodeName.toLowerCase())throw new i.DOMException(i.DOMException.TYPE_MISMATCH_ERR);c.call(this,t.src,arguments[1])}}catch(r){this.trigger("error",r.code)}}function p(t,i){var n=this.connectRuntime(t.ruid);this.ruid=n.uid,n.exec.call(this,"Image","loadFromImage",t,"undefined"===e.typeOf(i)?!0:i)}function g(t,i){function n(e){r.ruid=e.uid,e.exec.call(r,"Image","loadFromBlob",t)}var r=this;r.name=t.name||"",t.isDetached()?(this.bind("RuntimeInit",function(e,t){n(t)}),i&&"string"==typeof i.required_caps&&(i.required_caps=o.parseCaps(i.required_caps)),this.connectRuntime(e.extend({required_caps:{access_image_binary:!0,resize_image:!0}},i))):n(this.connectRuntime(t.ruid))}function x(e,t){var i,n=this;i=new r,i.open("get",e),i.responseType="blob",i.onprogress=function(e){n.trigger(e)},i.onload=function(){g.call(n,i.response,!0)},i.onerror=function(e){n.trigger(e)},i.onloadend=function(){i.destroy()},i.bind("RuntimeError",function(e,t){n.trigger("RuntimeError",t)}),i.send(null,t)}a.call(this),e.extend(this,{uid:e.guid("uid_"),ruid:null,name:"",size:0,width:0,height:0,type:"",meta:{},clone:function(){this.load.apply(this,arguments)},load:function(){c.apply(this,arguments)},resize:function(t){var n,r,o=this,a={x:0,y:0,width:o.width,height:o.height},s=e.extendIf({width:o.width,height:o.height,type:o.type||"image/jpeg",quality:90,crop:!1,fit:!0,preserveHeaders:!0,resample:"default",multipass:!0},t);try{if(!o.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);if(o.width>h.MAX_RESIZE_WIDTH||o.height>h.MAX_RESIZE_HEIGHT)throw new i.ImageError(i.ImageError.MAX_RESOLUTION_ERR);if(n=o.meta&&o.meta.tiff&&o.meta.tiff.Orientation||1,-1!==e.inArray(n,[5,6,7,8])){var u=s.width;s.width=s.height,s.height=u}if(s.crop){switch(r=Math.max(s.width/o.width,s.height/o.height),t.fit?(a.width=Math.min(Math.ceil(s.width/r),o.width),a.height=Math.min(Math.ceil(s.height/r),o.height),r=s.width/a.width):(a.width=Math.min(s.width,o.width),a.height=Math.min(s.height,o.height),r=1),"boolean"==typeof s.crop&&(s.crop="cc"),s.crop.toLowerCase().replace(/_/,"-")){case"rb":case"right-bottom":a.x=o.width-a.width,a.y=o.height-a.height;break;case"cb":case"center-bottom":a.x=Math.floor((o.width-a.width)/2),a.y=o.height-a.height;break;case"lb":case"left-bottom":a.x=0,a.y=o.height-a.height;break;case"lt":case"left-top":a.x=0,a.y=0;break;case"ct":case"center-top":a.x=Math.floor((o.width-a.width)/2),a.y=0;break;case"rt":case"right-top":a.x=o.width-a.width,a.y=0;break;case"rc":case"right-center":case"right-middle":a.x=o.width-a.width,a.y=Math.floor((o.height-a.height)/2);break;case"lc":case"left-center":case"left-middle":a.x=0,a.y=Math.floor((o.height-a.height)/2);break;case"cc":case"center-center":case"center-middle":default:a.x=Math.floor((o.width-a.width)/2),a.y=Math.floor((o.height-a.height)/2)}a.x=Math.max(a.x,0),a.y=Math.max(a.y,0)}else r=Math.min(s.width/o.width,s.height/o.height),r>1&&!s.fit&&(r=1);this.exec("Image","resize",a,r,s)}catch(c){o.trigger("error",c.code)}},downsize:function(t){var i,n={width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90,crop:!1,fit:!1,preserveHeaders:!0,resample:"default"};i="object"==typeof t?e.extend(n,t):e.extend(n,{width:arguments[0],height:arguments[1],crop:arguments[2],preserveHeaders:arguments[3]}),this.resize(i)},crop:function(e,t,i){this.downsize(e,t,!0,i)},getAsCanvas:function(){if(!u.can("create_canvas"))throw new i.RuntimeError(i.RuntimeError.NOT_SUPPORTED_ERR);return this.exec("Image","getAsCanvas")},getAsBlob:function(e,t){if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsBlob",e||"image/jpeg",t||90)},getAsDataURL:function(e,t){if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);return this.exec("Image","getAsDataURL",e||"image/jpeg",t||90)},getAsBinaryString:function(e,t){var i=this.getAsDataURL(e,t);return m.atob(i.substring(i.indexOf("base64,")+7))},embed:function(n,r){function o(t,r){var o=this;if(u.can("create_canvas")){var l=o.getAsCanvas();if(l)return n.appendChild(l),l=null,o.destroy(),c.trigger("embedded"),void 0}var d=o.getAsDataURL(t,r);if(!d)throw new i.ImageError(i.ImageError.WRONG_FORMAT);if(u.can("use_data_uri_of",d.length))n.innerHTML='',o.destroy(),c.trigger("embedded");else{var h=new s;h.bind("TransportingComplete",function(){a=c.connectRuntime(this.result.ruid),c.bind("Embedded",function(){e.extend(a.getShimContainer().style,{top:"0px",left:"0px",width:o.width+"px",height:o.height+"px"}),a=null},999),a.exec.call(c,"ImageView","display",this.result.uid,width,height),o.destroy()}),h.transport(m.atob(d.substring(d.indexOf("base64,")+7)),t,{required_caps:{display_media:!0},runtime_order:"flash,silverlight",container:n})}}var a,c=this,l=e.extend({width:this.width,height:this.height,type:this.type||"image/jpeg",quality:90,fit:!0,resample:"nearest"},r);try{if(!(n=t.get(n)))throw new i.DOMException(i.DOMException.INVALID_NODE_TYPE_ERR);if(!this.size)throw new i.DOMException(i.DOMException.INVALID_STATE_ERR);this.width>h.MAX_RESIZE_WIDTH||this.height>h.MAX_RESIZE_HEIGHT;var d=new h;return d.bind("Resize",function(){o.call(this,l.type,l.quality)}),d.bind("Load",function(){this.downsize(l)}),this.meta.thumb&&this.meta.thumb.width>=l.width&&this.meta.thumb.height>=l.height?d.load(this.meta.thumb.data):d.clone(this,!1),d}catch(f){this.trigger("error",f.code)}},destroy:function(){this.ruid&&(this.getRuntime().exec.call(this,"Image","destroy"),this.disconnectRuntime()),this.meta&&this.meta.thumb&&this.meta.thumb.data.destroy(),this.unbindAll()}}),this.handleEventProps(f),this.bind("Load Resize",function(){return n.call(this)},999)}var f=["progress","load","error","resize","embedded"];return h.MAX_RESIZE_WIDTH=8192,h.MAX_RESIZE_HEIGHT=8192,h.prototype=c.instance,h}),n("moxie/runtime/html5/Runtime",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/Runtime","moxie/core/utils/Env"],function(e,t,i,n){function o(t){var o=this,u=i.capTest,c=i.capTrue,l=e.extend({access_binary:u(window.FileReader||window.File&&window.File.getAsDataURL),access_image_binary:function(){return o.can("access_binary")&&!!s.Image},display_media:u((n.can("create_canvas")||n.can("use_data_uri_over32kb"))&&r("moxie/image/Image")),do_cors:u(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest),drag_and_drop:u(function(){var e=document.createElement("div");return("draggable"in e||"ondragstart"in e&&"ondrop"in e)&&("IE"!==n.browser||n.verComp(n.version,9,">"))}()),filter_by_extension:u(function(){return!("Chrome"===n.browser&&n.verComp(n.version,28,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<")||"Safari"===n.browser&&n.verComp(n.version,7,"<")||"Firefox"===n.browser&&n.verComp(n.version,37,"<"))}()),return_response_headers:c,return_response_type:function(e){return"json"===e&&window.JSON?!0:n.can("return_response_type",e)},return_status_code:c,report_upload_progress:u(window.XMLHttpRequest&&(new XMLHttpRequest).upload),resize_image:function(){return o.can("access_binary")&&n.can("create_canvas")},select_file:function(){return n.can("use_fileinput")&&window.File},select_folder:function(){return o.can("select_file")&&("Chrome"===n.browser&&n.verComp(n.version,21,">=")||"Firefox"===n.browser&&n.verComp(n.version,42,">="))},select_multiple:function(){return!(!o.can("select_file")||"Safari"===n.browser&&"Windows"===n.os||"iOS"===n.os&&n.verComp(n.osVersion,"7.0.0",">")&&n.verComp(n.osVersion,"8.0.0","<"))},send_binary_string:u(window.XMLHttpRequest&&((new XMLHttpRequest).sendAsBinary||window.Uint8Array&&window.ArrayBuffer)),send_custom_headers:u(window.XMLHttpRequest),send_multipart:function(){return!!(window.XMLHttpRequest&&(new XMLHttpRequest).upload&&window.FormData)||o.can("send_binary_string")},slice_blob:u(window.File&&(File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice)),stream_upload:function(){return o.can("slice_blob")&&o.can("send_multipart")},summon_file_dialog:function(){return o.can("select_file")&&!("Firefox"===n.browser&&n.verComp(n.version,4,"<")||"Opera"===n.browser&&n.verComp(n.version,12,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<"))},upload_filesize:c,use_http_method:c},arguments[2]);i.call(this,t,arguments[1]||a,l),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(o),e=o=null}}(this.destroy)}),e.extend(this.getShim(),s)}var a="html5",s={};return i.addConstructor(a,o),s}),n("moxie/runtime/html5/file/Blob",["moxie/runtime/html5/Runtime","moxie/file/Blob"],function(e,t){function i(){function e(e,t,i){var n;if(!window.File.prototype.slice)return(n=window.File.prototype.webkitSlice||window.File.prototype.mozSlice)?n.call(e,t,i):null;try{return e.slice(),e.slice(t,i)}catch(r){return e.slice(t,i-t)}}this.slice=function(){return new t(this.getRuntime().uid,e.apply(this,arguments))},this.destroy=function(){this.getRuntime().getShim().removeInstance(this.uid)}}return e.Blob=i}),n("moxie/core/utils/Events",["moxie/core/utils/Basic"],function(e){function t(){this.returnValue=!1}function i(){this.cancelBubble=!0}var n={},r="moxie_"+e.guid(),o=function(o,a,s,u){var c,l;a=a.toLowerCase(),o.addEventListener?(c=s,o.addEventListener(a,c,!1)):o.attachEvent&&(c=function(){var e=window.event;e.target||(e.target=e.srcElement),e.preventDefault=t,e.stopPropagation=i,s(e)},o.attachEvent("on"+a,c)),o[r]||(o[r]=e.guid()),n.hasOwnProperty(o[r])||(n[o[r]]={}),l=n[o[r]],l.hasOwnProperty(a)||(l[a]=[]),l[a].push({func:c,orig:s,key:u})},a=function(t,i,o){var a,s;if(i=i.toLowerCase(),t[r]&&n[t[r]]&&n[t[r]][i]){a=n[t[r]][i];for(var u=a.length-1;u>=0&&(a[u].orig!==o&&a[u].key!==o||(t.removeEventListener?t.removeEventListener(i,a[u].func,!1):t.detachEvent&&t.detachEvent("on"+i,a[u].func),a[u].orig=null,a[u].func=null,a.splice(u,1),o===s));u--);if(a.length||delete n[t[r]][i],e.isEmptyObj(n[t[r]])){delete n[t[r]];try{delete t[r]}catch(c){t[r]=s}}}},s=function(t,i){t&&t[r]&&e.each(n[t[r]],function(e,n){a(t,n,i)})};return{addEvent:o,removeEvent:a,removeAllEvents:s}}),n("moxie/runtime/html5/file/FileInput",["moxie/runtime/html5/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a){function s(){var e,s;i.extend(this,{init:function(u){var c,l,d,m,h,f,p=this,g=p.getRuntime();e=u,d=o.extList2mimes(e.accept,g.can("filter_by_extension")),l=g.getShimContainer(),l.innerHTML='",c=n.get(g.uid),i.extend(c.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),m=n.get(e.browse_button),s=n.getStyle(m,"z-index")||"auto",g.can("summon_file_dialog")&&("static"===n.getStyle(m,"position")&&(m.style.position="relative"),r.addEvent(m,"click",function(e){var t=n.get(g.uid);t&&!t.disabled&&t.click(),e.preventDefault()},p.uid),p.bind("Refresh",function(){h=parseInt(s,10)||1,n.get(e.browse_button).style.zIndex=h,this.getRuntime().getShimContainer().style.zIndex=h-1})),f=g.can("summon_file_dialog")?m:l,r.addEvent(f,"mouseover",function(){p.trigger("mouseenter")},p.uid),r.addEvent(f,"mouseout",function(){p.trigger("mouseleave")},p.uid),r.addEvent(f,"mousedown",function(){p.trigger("mousedown")},p.uid),r.addEvent(n.get(e.container),"mouseup",function(){p.trigger("mouseup")},p.uid),(g.can("summon_file_dialog")?c:m).setAttribute("tabindex",-1),c.onchange=function x(){if(p.files=[],i.each(this.files,function(i){var n="";return e.directory&&"."==i.name?!0:(i.webkitRelativePath&&(n="/"+i.webkitRelativePath.replace(/^\//,"")),i=new t(g.uid,i),i.relativePath=n,p.files.push(i),void 0)}),"IE"!==a.browser&&"IEMobile"!==a.browser)this.value="";else{var n=this.cloneNode(!0);this.parentNode.replaceChild(n,this),n.onchange=x}p.files.length&&p.trigger("change")},p.trigger({type:"ready",async:!0}),l=null},setOption:function(e,t){var i=this.getRuntime(),r=n.get(i.uid);switch(e){case"accept":if(t){var a=t.mimes||o.extList2mimes(t,i.can("filter_by_extension"));r.setAttribute("accept",a.join(","))}else r.removeAttribute("accept");break;case"directory":t&&i.can("select_folder")?(r.setAttribute("directory",""),r.setAttribute("webkitdirectory","")):(r.removeAttribute("directory"),r.removeAttribute("webkitdirectory"));break;case"multiple":t&&i.can("select_multiple")?r.setAttribute("multiple",""):r.removeAttribute("multiple")}},disable:function(e){var t,i=this.getRuntime();(t=n.get(i.uid))&&(t.disabled=!!e)},destroy:function(){var t=this.getRuntime(),i=t.getShim(),o=t.getShimContainer(),a=e&&n.get(e.container),u=e&&n.get(e.browse_button);a&&r.removeAllEvents(a,this.uid),u&&(r.removeAllEvents(u,this.uid),u.style.zIndex=s),o&&(r.removeAllEvents(o,this.uid),o.innerHTML=""),i.removeInstance(this.uid),e=o=a=u=i=null}})}return e.FileInput=s}),n("moxie/runtime/html5/file/FileDrop",["moxie/runtime/html5/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime"],function(e,t,i,n,r,o){function a(){function e(e){if(!e.dataTransfer||!e.dataTransfer.types)return!1;var t=i.toArray(e.dataTransfer.types||[]);return-1!==i.inArray("Files",t)||-1!==i.inArray("public.file-url",t)||-1!==i.inArray("application/x-moz-file",t)}function a(e,i){if(u(e)){var n=new t(f,e);n.relativePath=i||"",p.push(n)}}function s(e){for(var t=[],n=0;n=")&&u.verComp(u.version,7,"<"),f="Android Browser"===u.browser,p=!1;if(h=i.url.replace(/^.+?\/([\w\-\.]+)$/,"$1").toLowerCase(),m=c(),m.open(i.method,i.url,i.async,i.user,i.password),r instanceof o)r.isDetached()&&(p=!0),r=r.getSource();else if(r instanceof a){if(r.hasBlob())if(r.getBlob().isDetached())r=d.call(s,r),p=!0;else if((l||f)&&"blob"===t.typeOf(r.getBlob().getSource())&&window.FileReader)return e.call(s,i,r),void 0;if(r instanceof a){var g=new window.FormData;r.each(function(e,t){e instanceof o?g.append(t,e.getSource()):g.append(t,e)}),r=g}}m.upload?(i.withCredentials&&(m.withCredentials=!0),m.addEventListener("load",function(e){s.trigger(e)}),m.addEventListener("error",function(e){s.trigger(e)}),m.addEventListener("progress",function(e){s.trigger(e)}),m.upload.addEventListener("progress",function(e){s.trigger({type:"UploadProgress",loaded:e.loaded,total:e.total})})):m.onreadystatechange=function(){switch(m.readyState){case 1:break;case 2:break;case 3:var e,t;try{n.hasSameOrigin(i.url)&&(e=m.getResponseHeader("Content-Length")||0),m.responseText&&(t=m.responseText.length)}catch(r){e=t=0}s.trigger({type:"progress",lengthComputable:!!e,total:parseInt(e,10),loaded:t});break;case 4:m.onreadystatechange=function(){};try{if(m.status>=200&&m.status<400){s.trigger("load");break}}catch(r){}s.trigger("error")}},t.isEmptyObj(i.headers)||t.each(i.headers,function(e,t){m.setRequestHeader(t,e)}),""!==i.responseType&&"responseType"in m&&(m.responseType="json"!==i.responseType||u.can("return_response_type","json")?i.responseType:"text"),p?m.sendAsBinary?m.sendAsBinary(r):function(){for(var e=new Uint8Array(r.length),t=0;t0&&o.set(new Uint8Array(t.slice(0,e)),0),o.set(new Uint8Array(r),e),o.set(new Uint8Array(t.slice(e+n)),e+r.byteLength),this.clear(),t=o.buffer,i=new DataView(t);break}default:return t}},length:function(){return t?t.byteLength:0},clear:function(){i=t=null}})}function n(t){function i(e,i,n){n=3===arguments.length?n:t.length-i-1,t=t.substr(0,i)+e+t.substr(n+i)}e.extend(this,{readByteAt:function(e){return t.charCodeAt(e)},writeByteAt:function(e,t){i(String.fromCharCode(t),e,1)},SEGMENT:function(e,n,r){switch(arguments.length){case 1:return t.substr(e);case 2:return t.substr(e,n);case 3:i(null!==r?r:"",e,n);break;default:return t}},length:function(){return t?t.length:0},clear:function(){t=null}})}return e.extend(t.prototype,{littleEndian:!1,read:function(e,t){var i,n,r;if(e+t>this.length())throw new Error("You are trying to read outside the source boundaries.");for(n=this.littleEndian?0:-8*(t-1),r=0,i=0;t>r;r++)i|=this.readByteAt(e+r)<this.length())throw new Error("You are trying to write outside the source boundaries.");for(n=this.littleEndian?0:-8*(i-1),r=0;i>r;r++)this.writeByteAt(e+r,255&t>>Math.abs(n+8*r))},BYTE:function(e){return this.read(e,1)},SHORT:function(e){return this.read(e,2)},LONG:function(e){return this.read(e,4)},SLONG:function(e){var t=this.read(e,4);return t>2147483647?t-4294967296:t},CHAR:function(e){return String.fromCharCode(this.read(e,1))},STRING:function(e,t){return this.asArray("CHAR",e,t).join("")},asArray:function(e,t,i){for(var n=[],r=0;i>r;r++)n[r]=this[e](t+r);return n}}),t}),n("moxie/runtime/html5/image/JPEGHeaders",["moxie/runtime/html5/utils/BinaryReader","moxie/core/Exceptions"],function(e,t){return function i(n){var r,o,a,s=[],u=0;if(r=new e(n),65496!==r.SHORT(0))throw r.clear(),new t.ImageError(t.ImageError.WRONG_FORMAT);for(o=2;o<=r.length();)if(a=r.SHORT(o),a>=65488&&65495>=a)o+=2;else{if(65498===a||65497===a)break;u=r.SHORT(o+2)+2,a>=65505&&65519>=a&&s.push({hex:a,name:"APP"+(15&a),start:o,length:u,segment:r.SEGMENT(o,u)}),o+=u}return r.clear(),{headers:s,restore:function(t){var i,n,r;for(r=new e(t),o=65504==r.SHORT(2)?4+r.SHORT(4):2,n=0,i=s.length;i>n;n++)r.SEGMENT(o,0,s[n].segment),o+=s[n].length;return t=r.SEGMENT(),r.clear(),t},strip:function(t){var n,r,o,a;for(o=new i(t),r=o.headers,o.purge(),n=new e(t),a=r.length;a--;)n.SEGMENT(r[a].start,r[a].length,"");return t=n.SEGMENT(),n.clear(),t},get:function(e){for(var t=[],i=0,n=s.length;n>i;i++)s[i].name===e.toUpperCase()&&t.push(s[i].segment);return t},set:function(e,t){var i,n,r,o=[];for("string"==typeof t?o.push(t):o=t,i=n=0,r=s.length;r>i&&(s[i].name===e.toUpperCase()&&(s[i].segment=o[n],s[i].length=o[n].length,n++),!(n>=o.length));i++);},purge:function(){this.headers=s=[]}}}}),n("moxie/runtime/html5/image/ExifParser",["moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader","moxie/core/Exceptions"],function(e,i,n){function r(o){function a(i,r){var o,a,s,u,c,m,h,f,p=this,g=[],x={},v={1:"BYTE",7:"UNDEFINED",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",9:"SLONG",10:"SRATIONAL"},w={BYTE:1,UNDEFINED:1,ASCII:1,SHORT:2,LONG:4,RATIONAL:8,SLONG:4,SRATIONAL:8};for(o=p.SHORT(i),a=0;o>a;a++)if(g=[],h=i+2+12*a,s=r[p.SHORT(h)],s!==t){if(u=v[p.SHORT(h+=2)],c=p.LONG(h+=2),m=w[u],!m)throw new n.ImageError(n.ImageError.INVALID_META_ERR);if(h+=4,m*c>4&&(h=p.LONG(h)+d.tiffHeader),h+m*c>=this.length())throw new n.ImageError(n.ImageError.INVALID_META_ERR);"ASCII"!==u?(g=p.asArray(u,h,c),f=1==c?g[0]:g,x[s]=l.hasOwnProperty(s)&&"object"!=typeof f?l[s][f]:f):x[s]=e.trim(p.STRING(h,c).replace(/\0$/,""))}return x}function s(e,t,i){var n,r,o,a=0;if("string"==typeof t){var s=c[e.toLowerCase()];for(var u in s)if(s[u]===t){t=u;break}}n=d[e.toLowerCase()+"IFD"],r=this.SHORT(n);for(var l=0;r>l;l++)if(o=n+12*l+2,this.SHORT(o)==t){a=o+8;break}if(!a)return!1;try{this.write(a,i,4)}catch(m){return!1}return!0}var u,c,l,d,m,h;if(i.call(this,o),c={tiff:{274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},exif:{36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"},thumb:{513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength"}},l={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}},d={tiffHeader:10},m=d.tiffHeader,u={clear:this.clear},e.extend(this,{read:function(){try{return r.prototype.read.apply(this,arguments)}catch(e){throw new n.ImageError(n.ImageError.INVALID_META_ERR)}},write:function(){try{return r.prototype.write.apply(this,arguments)}catch(e){throw new n.ImageError(n.ImageError.INVALID_META_ERR)}},UNDEFINED:function(){return this.BYTE.apply(this,arguments)},RATIONAL:function(e){return this.LONG(e)/this.LONG(e+4)},SRATIONAL:function(e){return this.SLONG(e)/this.SLONG(e+4)},ASCII:function(e){return this.CHAR(e)},TIFF:function(){return h||null},EXIF:function(){var t=null;if(d.exifIFD){try{t=a.call(this,d.exifIFD,c.exif)}catch(i){return null}if(t.ExifVersion&&"array"===e.typeOf(t.ExifVersion)){for(var n=0,r="";n=65472&&65475>=t)return n+=5,{height:e.SHORT(n),width:e.SHORT(n+=2)};i=e.SHORT(n+=2),n+=i-2}return null}function s(){var e,t,i=d.thumb();return i&&(e=new n(i),t=a(e),e.clear(),t)?(t.data=i,t):null}function u(){d&&l&&c&&(d.clear(),l.purge(),c.clear(),m=l=d=c=null)}var c,l,d,m;if(c=new n(o),65496!==c.SHORT(0))throw new t.ImageError(t.ImageError.WRONG_FORMAT);l=new i(o);try{d=new r(l.get("app1")[0])}catch(h){}m=a.call(this),e.extend(this,{type:"image/jpeg",size:c.length(),width:m&&m.width||0,height:m&&m.height||0,setExif:function(t,i){return d?("object"===e.typeOf(t)?e.each(t,function(e,t){d.setExif(t,e)}):d.setExif(t,i),l.set("app1",d.SEGMENT()),void 0):!1},writeHeaders:function(){return arguments.length?l.restore(arguments[0]):l.restore(o)},stripHeaders:function(e){return l.strip(e)},purge:function(){u.call(this)}}),d&&(this.meta={tiff:d.TIFF(),exif:d.EXIF(),gps:d.GPS(),thumb:s()})}return o}),n("moxie/runtime/html5/image/PNG",["moxie/core/Exceptions","moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader"],function(e,t,i){function n(n){function r(){var e,t;return e=a.call(this,8),"IHDR"==e.type?(t=e.start,{width:s.LONG(t),height:s.LONG(t+=4)}):null}function o(){s&&(s.clear(),n=l=u=c=s=null)}function a(e){var t,i,n,r;return t=s.LONG(e),i=s.STRING(e+=4,4),n=e+=4,r=s.LONG(e+t),{length:t,type:i,start:n,CRC:r}}var s,u,c,l;s=new i(n),function(){var t=0,i=0,n=[35152,20039,3338,6666];for(i=0;ii.height?"width":"height",a=Math.round(i[o]*n),s=!1;"nearest"!==r&&(.5>n||n>2)&&(n=.5>n?.5:2,s=!0);var u=t(i,n);return s?e(u,a/u[o],r):u}function t(e,t){var i=e.width,n=e.height,r=Math.round(i*t),o=Math.round(n*t),a=document.createElement("canvas");return a.width=r,a.height=o,a.getContext("2d").drawImage(e,0,0,i,n,0,0,r,o),e=null,a}return{scale:e}}),n("moxie/runtime/html5/image/Image",["moxie/runtime/html5/Runtime","moxie/core/utils/Basic","moxie/core/Exceptions","moxie/core/utils/Encode","moxie/file/Blob","moxie/file/File","moxie/runtime/html5/image/ImageInfo","moxie/runtime/html5/image/ResizerCanvas","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a,s,u){function c(){function e(){if(!v&&!g)throw new i.ImageError(i.DOMException.INVALID_STATE_ERR);return v||g}function c(){var t=e();return"canvas"==t.nodeName.toLowerCase()?t:(v=document.createElement("canvas"),v.width=t.width,v.height=t.height,v.getContext("2d").drawImage(t,0,0),v)}function l(e){return n.atob(e.substring(e.indexOf("base64,")+7))}function d(e,t){return"data:"+(t||"")+";base64,"+n.btoa(e)}function m(e){var t=this;g=new Image,g.onerror=function(){p.call(this),t.trigger("error",i.ImageError.WRONG_FORMAT)},g.onload=function(){t.trigger("load")},g.src="data:"==e.substr(0,5)?e:d(e,y.type)}function h(e,t){var n,r=this;return window.FileReader?(n=new FileReader,n.onload=function(){t.call(r,this.result)},n.onerror=function(){r.trigger("error",i.ImageError.WRONG_FORMAT)},n.readAsDataURL(e),void 0):t.call(this,e.getAsDataURL())}function f(e,i){var n=Math.PI/180,r=document.createElement("canvas"),o=r.getContext("2d"),a=e.width,s=e.height;switch(t.inArray(i,[5,6,7,8])>-1?(r.width=s,r.height=a):(r.width=a,r.height=s),i){case 2:o.translate(a,0),o.scale(-1,1);break;case 3:o.translate(a,s),o.rotate(180*n);break;case 4:o.translate(0,s),o.scale(1,-1);break;case 5:o.rotate(90*n),o.scale(1,-1);break;case 6:o.rotate(90*n),o.translate(0,-s);break;case 7:o.rotate(90*n),o.translate(a,-s),o.scale(-1,1);break;case 8:o.rotate(-90*n),o.translate(-a,0)}return o.drawImage(e,0,0,a,s),r}function p(){x&&(x.purge(),x=null),w=g=v=y=null,b=!1}var g,x,v,w,y,E=this,b=!1,_=!0;t.extend(this,{loadFromBlob:function(e){var t=this.getRuntime(),n=arguments.length>1?arguments[1]:!0;if(!t.can("access_binary"))throw new i.RuntimeError(i.RuntimeError.NOT_SUPPORTED_ERR);return y=e,e.isDetached()?(w=e.getSource(),m.call(this,w),void 0):(h.call(this,e.getSource(),function(e){n&&(w=l(e)),m.call(this,e)}),void 0)},loadFromImage:function(e,t){this.meta=e.meta,y=new o(null,{name:e.name,size:e.size,type:e.type}),m.call(this,t?w=e.getAsBinaryString():e.getAsDataURL())},getInfo:function(){var t,i=this.getRuntime();return!x&&w&&i.can("access_image_binary")&&(x=new a(w)),t={width:e().width||0,height:e().height||0,type:y.type||u.getFileMime(y.name),size:w&&w.length||y.size||0,name:y.name||"",meta:null},_&&(t.meta=x&&x.meta||this.meta||{},!t.meta||!t.meta.thumb||t.meta.thumb.data instanceof r||(t.meta.thumb.data=new r(null,{type:"image/jpeg",data:t.meta.thumb.data}))),t},resize:function(t,i,n){var r=document.createElement("canvas");if(r.width=t.width,r.height=t.height,r.getContext("2d").drawImage(e(),t.x,t.y,t.width,t.height,0,0,r.width,r.height),v=s.scale(r,i),_=n.preserveHeaders,!_){var o=this.meta&&this.meta.tiff&&this.meta.tiff.Orientation||1;v=f(v,o)}this.width=v.width,this.height=v.height,b=!0,this.trigger("Resize")},getAsCanvas:function(){return v||(v=c()),v.id=this.uid+"_canvas",v},getAsBlob:function(e,t){return e!==this.type?(b=!0,new o(null,{name:y.name||"",type:e,data:E.getAsDataURL(e,t)})):new o(null,{name:y.name||"",type:e,data:E.getAsBinaryString(e,t)})},getAsDataURL:function(e){var t=arguments[1]||90;if(!b)return g.src;if(c(),"image/jpeg"!==e)return v.toDataURL("image/png");try{return v.toDataURL("image/jpeg",t/100)}catch(i){return v.toDataURL("image/jpeg")}},getAsBinaryString:function(e,t){if(!b)return w||(w=l(E.getAsDataURL(e,t))),w;if("image/jpeg"!==e)w=l(E.getAsDataURL(e,t));else{var i;t||(t=90),c();try{i=v.toDataURL("image/jpeg",t/100)}catch(n){i=v.toDataURL("image/jpeg")}w=l(i),x&&(w=x.stripHeaders(w),_&&(x.meta&&x.meta.exif&&x.setExif({PixelXDimension:this.width,PixelYDimension:this.height}),w=x.writeHeaders(w)),x.purge(),x=null)}return b=!1,w},destroy:function(){E=null,p.call(this),this.getRuntime().getShim().removeInstance(this.uid)}})}return e.Image=c}),n("moxie/runtime/flash/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(e,t,i,n,o){function a(){var e;try{e=navigator.plugins["Shockwave Flash"],e=e.description}catch(t){try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(i){e="0.0"}}return e=e.match(/\d+/g),parseFloat(e[0]+"."+e[1])}function s(e){var n=i.get(e);n&&"OBJECT"==n.nodeName&&("IE"===t.browser?(n.style.display="none",function r(){4==n.readyState?u(e):setTimeout(r,10)}()):n.parentNode.removeChild(n))}function u(e){var t=i.get(e);if(t){for(var n in t)"function"==typeof t[n]&&(t[n]=null);t.parentNode.removeChild(t)}}function c(u){var c,m=this;u=e.extend({swf_url:t.swf_url},u),o.call(this,u,l,{access_binary:function(e){return e&&"browser"===m.mode},access_image_binary:function(e){return e&&"browser"===m.mode},display_media:o.capTest(r("moxie/image/Image")),do_cors:o.capTrue,drag_and_drop:!1,report_upload_progress:function(){return"client"===m.mode},resize_image:o.capTrue,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!e.arrayDiff(t,["","text","document"])||"browser"===m.mode},return_status_code:function(t){return"browser"===m.mode||!e.arrayDiff(t,[200,404])},select_file:o.capTrue,select_multiple:o.capTrue,send_binary_string:function(e){return e&&"browser"===m.mode},send_browser_cookies:function(e){return e&&"browser"===m.mode},send_custom_headers:function(e){return e&&"browser"===m.mode},send_multipart:o.capTrue,slice_blob:function(e){return e&&"browser"===m.mode},stream_upload:function(e){return e&&"browser"===m.mode},summon_file_dialog:!1,upload_filesize:function(t){return e.parseSizeStr(t)<=2097152||"client"===m.mode},use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}},{access_binary:function(e){return e?"browser":"client"},access_image_binary:function(e){return e?"browser":"client"},report_upload_progress:function(e){return e?"browser":"client"},return_response_type:function(t){return e.arrayDiff(t,["","text","json","document"])?"browser":["client","browser"]},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"browser":["client","browser"]},send_binary_string:function(e){return e?"browser":"client"},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"browser":"client"},slice_blob:function(e){return e?"browser":"client"},stream_upload:function(e){return e?"client":"browser"},upload_filesize:function(t){return e.parseSizeStr(t)>=2097152?"client":"browser"}},"client"),a()<11.3&&(this.mode=!1),e.extend(this,{getShim:function(){return i.get(this.uid)},shimExec:function(e,t){var i=[].slice.call(arguments,2);return m.getShim().exec(this.uid,e,t,i)},init:function(){var i,r,a;a=this.getShimContainer(),e.extend(a.style,{position:"absolute",top:"-8px",left:"-8px",width:"9px",height:"9px",overflow:"hidden"}),i=''+''+''+''+"","IE"===t.browser?(r=document.createElement("div"),a.appendChild(r),r.outerHTML=i,r=a=null):a.innerHTML=i,c=setTimeout(function(){m&&!m.initialized&&m.trigger("Error",new n.RuntimeError(n.RuntimeError.NOT_INIT_ERR))},5e3)},destroy:function(e){return function(){s(m.uid),e.call(m),clearTimeout(c),u=c=e=m=null}}(this.destroy)},d)}var l="flash",d={};return o.addConstructor(l,c),d}),n("moxie/runtime/flash/file/Blob",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(e,t){var i={slice:function(e,i,n,r){var o=this.getRuntime();return 0>i?i=Math.max(e.size+i,0):i>0&&(i=Math.min(i,e.size)),0>n?n=Math.max(e.size+n,0):n>0&&(n=Math.min(n,e.size)),e=o.shimExec.call(this,"Blob","slice",i,n,r||""),e&&(e=new t(o.uid,e)),e}};return e.Blob=i}),n("moxie/runtime/flash/file/FileInput",["moxie/runtime/flash/Runtime","moxie/file/File","moxie/core/utils/Dom","moxie/core/utils/Basic"],function(e,t,i,n){var r={init:function(e){var r=this,o=this.getRuntime(),a=i.get(e.browse_button);a&&(a.setAttribute("tabindex",-1),a=null),this.bind("Change",function(){var e=o.shimExec.call(r,"FileInput","getFiles");r.files=[],n.each(e,function(e){r.files.push(new t(o.uid,e))})},999),this.getRuntime().shimExec.call(this,"FileInput","init",{accept:e.accept,multiple:e.multiple}),this.trigger("ready")}};return e.FileInput=r}),n("moxie/runtime/flash/file/FileReader",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(e,t){function i(e,i){switch(i){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var n={read:function(e,t){var n=this;return n.result="","readAsDataURL"===e&&(n.result="data:"+(t.type||"")+";base64,"),n.bind("Progress",function(t,r){r&&(n.result+=i(r,e))},999),n.getRuntime().shimExec.call(this,"FileReader","readAsBase64",t.uid)}};return e.FileReader=n}),n("moxie/runtime/flash/file/FileReaderSync",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(e,t){function i(e,i){switch(i){case"readAsText":return t.atob(e,"utf8");case"readAsBinaryString":return t.atob(e);case"readAsDataURL":return e}return null}var n={read:function(e,t){var n,r=this.getRuntime();return(n=r.shimExec.call(this,"FileReaderSync","readAsBase64",t.uid))?("readAsDataURL"===e&&(n="data:"+(t.type||"")+";base64,"+n),i(n,e,t.type)):null}};return e.FileReaderSync=n}),n("moxie/runtime/flash/runtime/Transporter",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(e,t){var i={getAsBlob:function(e){var i=this.getRuntime(),n=i.shimExec.call(this,"Transporter","getAsBlob",e);return n?new t(i.uid,n):null}};return e.Transporter=i}),n("moxie/runtime/flash/xhr/XMLHttpRequest",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/file/Blob","moxie/file/File","moxie/file/FileReaderSync","moxie/runtime/flash/file/FileReaderSync","moxie/xhr/FormData","moxie/runtime/Transporter","moxie/runtime/flash/runtime/Transporter"],function(e,t,i,n,r,o,a,s){var u={send:function(e,n){function r(){e.transport=l.mode,l.shimExec.call(c,"XMLHttpRequest","send",e,n)}function o(e,t){l.shimExec.call(c,"XMLHttpRequest","appendBlob",e,t.uid),n=null,r()}function u(e,t){var i=new s;i.bind("TransportingComplete",function(){t(this.result)}),i.transport(e.getSource(),e.type,{ruid:l.uid})}var c=this,l=c.getRuntime();if(t.isEmptyObj(e.headers)||t.each(e.headers,function(e,t){l.shimExec.call(c,"XMLHttpRequest","setRequestHeader",t,e.toString())}),n instanceof a){var d;if(n.each(function(e,t){e instanceof i?d=t:l.shimExec.call(c,"XMLHttpRequest","append",t,e)}),n.hasBlob()){var m=n.getBlob();m.isDetached()?u(m,function(e){m.destroy(),o(d,e)}):o(d,m)}else n=null,r()}else n instanceof i?n.isDetached()?u(n,function(e){n.destroy(),n=e.uid,r()}):(n=n.uid,r()):r()},getResponse:function(e){var i,o,a=this.getRuntime();if(o=a.shimExec.call(this,"XMLHttpRequest","getResponseAsBlob")){if(o=new n(a.uid,o),"blob"===e)return o;try{if(i=new r,~t.inArray(e,["","text"]))return i.readAsText(o);if("json"===e&&window.JSON)return JSON.parse(i.readAsText(o))}finally{o.destroy()}}return null},abort:function(){var e=this.getRuntime();e.shimExec.call(this,"XMLHttpRequest","abort"),this.dispatchEvent("readystatechange"),this.dispatchEvent("abort")}};return e.XMLHttpRequest=u}),n("moxie/runtime/flash/image/Image",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/runtime/Transporter","moxie/file/Blob","moxie/file/FileReaderSync"],function(e,t,i,n,r){var o={loadFromBlob:function(e){function t(e){r.shimExec.call(n,"Image","loadFromBlob",e.uid),n=r=null}var n=this,r=n.getRuntime();if(e.isDetached()){var o=new i;o.bind("TransportingComplete",function(){t(o.result.getSource())}),o.transport(e.getSource(),e.type,{ruid:r.uid})}else t(e.getSource())},loadFromImage:function(e){var t=this.getRuntime();return t.shimExec.call(this,"Image","loadFromImage",e.uid)},getInfo:function(){var e=this.getRuntime(),t=e.shimExec.call(this,"Image","getInfo");return t.meta&&t.meta.thumb&&t.meta.thumb.data&&!(e.meta.thumb.data instanceof n)&&(t.meta.thumb.data=new n(e.uid,t.meta.thumb.data)),t},getAsBlob:function(e,t){var i=this.getRuntime(),r=i.shimExec.call(this,"Image","getAsBlob",e,t);return r?new n(i.uid,r):null},getAsDataURL:function(){var e,t=this.getRuntime(),i=t.Image.getAsBlob.apply(this,arguments);return i?(e=new r,e.readAsDataURL(i)):null}};return e.Image=o}),n("moxie/runtime/silverlight/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(e,t,i,n,o){function a(e){var t,i,n,r,o,a=!1,s=null,u=0;try{try{s=new ActiveXObject("AgControl.AgControl"),s.IsVersionSupported(e)&&(a=!0),s=null}catch(c){var l=navigator.plugins["Silverlight Plug-In"];if(l){for(t=l.description,"1.0.30226.2"===t&&(t="2.0.30226.2"),i=t.split(".");i.length>3;)i.pop();for(;i.length<4;)i.push(0);for(n=e.split(".");n.length>4;)n.pop();do r=parseInt(n[u],10),o=parseInt(i[u],10),u++;while(u=r&&!isNaN(r)&&(a=!0)}}}catch(d){a=!1}return a}function s(s){var l,d=this;s=e.extend({xap_url:t.xap_url},s),o.call(this,s,u,{access_binary:o.capTrue,access_image_binary:o.capTrue,display_media:o.capTest(r("moxie/image/Image")),do_cors:o.capTrue,drag_and_drop:!1,report_upload_progress:o.capTrue,resize_image:o.capTrue,return_response_headers:function(e){return e&&"client"===d.mode},return_response_type:function(e){return"json"!==e?!0:!!window.JSON},return_status_code:function(t){return"client"===d.mode||!e.arrayDiff(t,[200,404])},select_file:o.capTrue,select_multiple:o.capTrue,send_binary_string:o.capTrue,send_browser_cookies:function(e){return e&&"browser"===d.mode},send_custom_headers:function(e){return e&&"client"===d.mode},send_multipart:o.capTrue,slice_blob:o.capTrue,stream_upload:!0,summon_file_dialog:!1,upload_filesize:o.capTrue,use_http_method:function(t){return"client"===d.mode||!e.arrayDiff(t,["GET","POST"])}},{return_response_headers:function(e){return e?"client":"browser"},return_status_code:function(t){return e.arrayDiff(t,[200,404])?"client":["client","browser"]},send_browser_cookies:function(e){return e?"browser":"client"},send_custom_headers:function(e){return e?"client":"browser"},use_http_method:function(t){return e.arrayDiff(t,["GET","POST"])?"client":["client","browser"]}}),a("2.0.31005.0")&&"Opera"!==t.browser||(this.mode=!1),e.extend(this,{getShim:function(){return i.get(this.uid).content.Moxie},shimExec:function(e,t){var i=[].slice.call(arguments,2);return d.getShim().exec(this.uid,e,t,i)},init:function(){var e;e=this.getShimContainer(),e.innerHTML=''+''+''+''+''+''+"",l=setTimeout(function(){d&&!d.initialized&&d.trigger("Error",new n.RuntimeError(n.RuntimeError.NOT_INIT_ERR))},"Windows"!==t.OS?1e4:5e3)},destroy:function(e){return function(){e.call(d),clearTimeout(l),s=l=e=d=null}}(this.destroy)},c)}var u="silverlight",c={};return o.addConstructor(u,s),c}),n("moxie/runtime/silverlight/file/Blob",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/runtime/flash/file/Blob"],function(e,t,i){return e.Blob=t.extend({},i)}),n("moxie/runtime/silverlight/file/FileInput",["moxie/runtime/silverlight/Runtime","moxie/file/File","moxie/core/utils/Dom","moxie/core/utils/Basic"],function(e,t,i,n){function r(e){for(var t="",i=0;ii;i++)t=s.keys[i],a=s[t],a&&(/^(\d|[1-9]\d+)$/.test(a)?a=parseInt(a,10):/^\d*\.\d+$/.test(a)&&(a=parseFloat(a)),r.meta[e][t]=a)}),r.meta&&r.meta.thumb&&r.meta.thumb.data&&!(e.meta.thumb.data instanceof i)&&(r.meta.thumb.data=new i(e.uid,r.meta.thumb.data))),r.width=parseInt(o.width,10),r.height=parseInt(o.height,10),r.size=parseInt(o.size,10),r.type=o.type,r.name=o.name,r},resize:function(e,t,i){this.getRuntime().shimExec.call(this,"Image","resize",e.x,e.y,e.width,e.height,t,i.preserveHeaders,i.resample)}})}),n("moxie/runtime/html4/Runtime",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/Runtime","moxie/core/utils/Env"],function(e,t,i,n){function o(t){var o=this,u=i.capTest,c=i.capTrue;i.call(this,t,a,{access_binary:u(window.FileReader||window.File&&File.getAsDataURL),access_image_binary:!1,display_media:u((n.can("create_canvas")||n.can("use_data_uri_over32kb"))&&r("moxie/image/Image")),do_cors:!1,drag_and_drop:!1,filter_by_extension:u(function(){return!("Chrome"===n.browser&&n.verComp(n.version,28,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<")||"Safari"===n.browser&&n.verComp(n.version,7,"<")||"Firefox"===n.browser&&n.verComp(n.version,37,"<"))}()),resize_image:function(){return s.Image&&o.can("access_binary")&&n.can("create_canvas")},report_upload_progress:!1,return_response_headers:!1,return_response_type:function(t){return"json"===t&&window.JSON?!0:!!~e.inArray(t,["text","document",""])},return_status_code:function(t){return!e.arrayDiff(t,[200,404])},select_file:function(){return n.can("use_fileinput")},select_multiple:!1,send_binary_string:!1,send_custom_headers:!1,send_multipart:!0,slice_blob:!1,stream_upload:function(){return o.can("select_file")},summon_file_dialog:function(){return o.can("select_file")&&!("Firefox"===n.browser&&n.verComp(n.version,4,"<")||"Opera"===n.browser&&n.verComp(n.version,12,"<")||"IE"===n.browser&&n.verComp(n.version,10,"<"))},upload_filesize:c,use_http_method:function(t){return!e.arrayDiff(t,["GET","POST"])}}),e.extend(this,{init:function(){this.trigger("Init")},destroy:function(e){return function(){e.call(o),e=o=null}}(this.destroy)}),e.extend(this.getShim(),s)}var a="html4",s={};return i.addConstructor(a,o),s}),n("moxie/runtime/html4/file/FileInput",["moxie/runtime/html4/Runtime","moxie/file/File","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(e,t,i,n,r,o,a){function s(){function e(){var o,c,d,m,h,f,p=this,g=p.getRuntime();f=i.guid("uid_"),o=g.getShimContainer(),s&&(d=n.get(s+"_form"),d&&(i.extend(d.style,{top:"100%"}),d.firstChild.setAttribute("tabindex",-1))),m=document.createElement("form"),m.setAttribute("id",f+"_form"),m.setAttribute("method","post"),m.setAttribute("enctype","multipart/form-data"),m.setAttribute("encoding","multipart/form-data"),i.extend(m.style,{overflow:"hidden",position:"absolute",top:0,left:0,width:"100%",height:"100%"}),h=document.createElement("input"),h.setAttribute("id",f),h.setAttribute("type","file"),h.setAttribute("accept",l.join(",")),g.can("summon_file_dialog")&&h.setAttribute("tabindex",-1),i.extend(h.style,{fontSize:"999px",opacity:0}),m.appendChild(h),o.appendChild(m),i.extend(h.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"}),"IE"===a.browser&&a.verComp(a.version,10,"<")&&i.extend(h.style,{filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"}),h.onchange=function(){var i;this.value&&(i=this.files?this.files[0]:{name:this.value},i=new t(g.uid,i),this.onchange=function(){},e.call(p),p.files=[i],h.setAttribute("id",i.uid),m.setAttribute("id",i.uid+"_form"),p.trigger("change"),h=m=null)},g.can("summon_file_dialog")&&(c=n.get(u.browse_button),r.removeEvent(c,"click",p.uid),r.addEvent(c,"click",function(e){h&&!h.disabled&&h.click(),e.preventDefault()},p.uid)),s=f,o=d=c=null}var s,u,c,l=[];i.extend(this,{init:function(t){var i,a=this,s=a.getRuntime();u=t,l=o.extList2mimes(t.accept,s.can("filter_by_extension")),i=s.getShimContainer(),function(){var e,o,l;e=n.get(t.browse_button),c=n.getStyle(e,"z-index")||"auto",s.can("summon_file_dialog")?("static"===n.getStyle(e,"position")&&(e.style.position="relative"),a.bind("Refresh",function(){o=parseInt(c,10)||1,n.get(u.browse_button).style.zIndex=o,this.getRuntime().getShimContainer().style.zIndex=o-1})):e.setAttribute("tabindex",-1),l=s.can("summon_file_dialog")?e:i,r.addEvent(l,"mouseover",function(){a.trigger("mouseenter")},a.uid),r.addEvent(l,"mouseout",function(){a.trigger("mouseleave")},a.uid),r.addEvent(l,"mousedown",function(){a.trigger("mousedown")},a.uid),r.addEvent(n.get(t.container),"mouseup",function(){a.trigger("mouseup")},a.uid),e=null}(),e.call(this),i=null,a.trigger({type:"ready",async:!0})},setOption:function(e,t){var i,r=this.getRuntime();"accept"==e&&(l=t.mimes||o.extList2mimes(t,r.can("filter_by_extension"))),i=n.get(s),i&&i.setAttribute("accept",l.join(","))},disable:function(e){var t;(t=n.get(s))&&(t.disabled=!!e)},destroy:function(){var e=this.getRuntime(),t=e.getShim(),i=e.getShimContainer(),o=u&&n.get(u.container),a=u&&n.get(u.browse_button);o&&r.removeAllEvents(o,this.uid),a&&(r.removeAllEvents(a,this.uid),a.style.zIndex=c),i&&(r.removeAllEvents(i,this.uid),i.innerHTML=""),t.removeInstance(this.uid),s=l=u=i=o=a=t=null}})}return e.FileInput=s}),n("moxie/runtime/html4/file/FileReader",["moxie/runtime/html4/Runtime","moxie/runtime/html5/file/FileReader"],function(e,t){return e.FileReader=t}),n("moxie/runtime/html4/xhr/XMLHttpRequest",["moxie/runtime/html4/Runtime","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Url","moxie/core/Exceptions","moxie/core/utils/Events","moxie/file/Blob","moxie/xhr/FormData"],function(e,t,i,n,r,o,a,s){function u(){function e(e){var t,n,r,a,s=this,u=!1;if(l){if(t=l.id.replace(/_iframe$/,""),n=i.get(t+"_form")){for(r=n.getElementsByTagName("input"),a=r.length;a--;)switch(r[a].getAttribute("type")){case"hidden":r[a].parentNode.removeChild(r[a]);break;case"file":u=!0}r=[],u||n.parentNode.removeChild(n),n=null}setTimeout(function(){o.removeEvent(l,"load",s.uid),l.parentNode&&l.parentNode.removeChild(l);var t=s.getRuntime().getShimContainer();t.children.length||t.parentNode.removeChild(t),t=l=null,e()},1)}}var u,c,l;t.extend(this,{send:function(d,m){function h(){var i=w.getShimContainer()||document.body,r=document.createElement("div");r.innerHTML='',l=r.firstChild,i.appendChild(l),o.addEvent(l,"load",function(){var i;try{i=l.contentWindow.document||l.contentDocument||window.frames[l.id].document,/^4(0[0-9]|1[0-7]|2[2346])\s/.test(i.title)?u=i.title.replace(/^(\d+).*$/,"$1"):(u=200,c=t.trim(i.body.innerHTML),v.trigger({type:"progress",loaded:c.length,total:c.length}),x&&v.trigger({type:"uploadprogress",loaded:x.size||1025,total:x.size||1025}))}catch(r){if(!n.hasSameOrigin(d.url))return e.call(v,function(){v.trigger("error")}),void 0;u=404}e.call(v,function(){v.trigger("load")})},v.uid)}var f,p,g,x,v=this,w=v.getRuntime();if(u=c=null,m instanceof s&&m.hasBlob()){if(x=m.getBlob(),f=x.uid,g=i.get(f),p=i.get(f+"_form"),!p)throw new r.DOMException(r.DOMException.NOT_FOUND_ERR)}else f=t.guid("uid_"),p=document.createElement("form"),p.setAttribute("id",f+"_form"),p.setAttribute("method",d.method),p.setAttribute("enctype","multipart/form-data"),p.setAttribute("encoding","multipart/form-data"),w.getShimContainer().appendChild(p);p.setAttribute("target",f+"_iframe"),m instanceof s&&m.each(function(e,i){if(e instanceof a)g&&g.setAttribute("name",i);else{var n=document.createElement("input");t.extend(n,{type:"hidden",name:i,value:e}),g?p.insertBefore(n,g):p.appendChild(n)}}),p.setAttribute("action",d.url),h(),p.submit(),v.trigger("loadstart")},getStatus:function(){return u},getResponse:function(e){if("json"===e&&"string"===t.typeOf(c)&&window.JSON)try{return JSON.parse(c.replace(/^\s*]*>/,"").replace(/<\/pre>\s*$/,""))}catch(i){return null}return c},abort:function(){var t=this;l&&l.contentWindow&&(l.contentWindow.stop?l.contentWindow.stop():l.contentWindow.document.execCommand?l.contentWindow.document.execCommand("Stop"):l.src="about:blank"),e.call(this,function(){t.dispatchEvent("abort")})},destroy:function(){this.getRuntime().getShim().removeInstance(this.uid)}})}return e.XMLHttpRequest=u}),n("moxie/runtime/html4/image/Image",["moxie/runtime/html4/Runtime","moxie/runtime/html5/image/Image"],function(e,t){return e.Image=t}),a(["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/core/utils/Env","moxie/core/Exceptions","moxie/core/utils/Dom","moxie/core/EventTarget","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/core/I18n","moxie/core/utils/Mime","moxie/file/FileInput","moxie/file/File","moxie/file/FileDrop","moxie/file/FileReader","moxie/core/utils/Url","moxie/runtime/RuntimeTarget","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/image/Image","moxie/core/utils/Events","moxie/runtime/html5/image/ResizerCanvas"])}(this)}); \ No newline at end of file diff --git a/admin/addons/servers/legacy/media.xml b/admin/addons/servers/legacy/media.xml index 949eeb6db7..8c47d5f33a 100644 --- a/admin/addons/servers/legacy/media.xml +++ b/admin/addons/servers/legacy/media.xml @@ -47,6 +47,12 @@ + + + + + +
upload($data); - } - - /** - * Render Fields for general view. - * - * @param object $media_form Midea files form - * @param bool $new If media is new - * - * @return string - * - * @since 9.1.3 - */ - public function renderGeneral($media_form, $new) - { - $html = ''; - $fields = $media_form->getFieldset('general'); - - if ($fields) - { - foreach ($media_form->getFieldset('general') as $field): - $html .= '
'; - $html .= '
'; - $html .= $field->label; - $html .= '
'; - $html .= '
'; - - // Way to set defaults on new media - if ($new) - { - $s_name = $field->fieldname; - - if (isset($media_form->s_params[$s_name])) - { - $field->setValue($media_form->s_params[$s_name]); - } - } - - $html .= $field->input; - $html .= '
'; - $html .= '
'; - endforeach; - } - - return $html; - } - - /** - * Render Layout and fields - * - * @param object $media_form Midea files form - * @param bool $new If media is new - * - * @return string - * - * @since 9.1.3 - */ - public function render($media_form, $new) - { - $html = ''; - - $html .= JHtml::_('bootstrap.addTab', 'myTab', 'options', JText::_('Options')); - - $html .= '
'; - - foreach ($media_form->getFieldsets('params') as $name => $fieldset) - { - if ($name !== 'general') - { - $html .= '
'; - - foreach ($media_form->getFieldset($name) as $field): - $html .= '
'; - $html .= '
'; - $html .= $field->label; - $html .= '
'; - $html .= '
'; - - // Way to set defaults on new media - if ($new) - { - $s_name = $field->fieldname; - - if (isset($media_form->s_params[$s_name])) - { - $field->setValue($media_form->s_params[$s_name]); - } - } - - $html .= $field->input; - $html .= '
'; - $html .= '
'; - endforeach; - - $html .= '
'; - } - } - - $html .= '
'; - $html .= JHtml::_('bootstrap.endTab'); - - return $html; - } -} diff --git a/admin/addons/servers/local/local.php b/admin/addons/servers/local/local.php index 6f98ea24fe..5d05b05991 100644 --- a/admin/addons/servers/local/local.php +++ b/admin/addons/servers/local/local.php @@ -107,8 +107,7 @@ public function renderGeneral($media_form, $new) */ public function render($media_form, $new) { - $html = ''; - $html .= JHtml::_('bootstrap.addTab', 'myTab', 'options', JText::_('Options')); + $html = JHtml::_('bootstrap.addTab', 'myTab', 'options', JText::_('Options')); $html .= '
'; diff --git a/admin/addons/servers/local/media.xml b/admin/addons/servers/local/media.xml index 931b717947..d5c995ade1 100644 --- a/admin/addons/servers/local/media.xml +++ b/admin/addons/servers/local/media.xml @@ -11,6 +11,12 @@ required="true"/> + + + + + +
getQuery(true); + $db = JFactory::getDbo(); + $query = $db->getQuery(true); $query->select('id, params') ->from('#__bsms_mediafiles'); $db->setQuery($query); - $images = $db->loadObjectList(); - $error = 0; - $added = 0; + $images = $db->loadObjectList(); + $error = 0; + $added = 0; $errortext = ''; - $msg = JText::_('JBS_RESULTS') . ': '; + $msg = JText::_('JBS_RESULTS') . ': '; switch ($decoded->media_use_button_icon) { @@ -124,7 +124,7 @@ public function mediaimages() ->set('params = ' . $db->q($reg->toString())) ->where('id = ' . (int) $media->id); $db->execute(); - $rows = $db->getAffectedRows(); + $rows = $db->getAffectedRows(); $added = $added + $rows; } catch (RuntimeException $e) @@ -136,12 +136,12 @@ public function mediaimages() } $msg .= JText::_('JBS_ERROR') . ': ' . $error . '
' . $errortext . '
' . JText::_('JBS_RESULTS') . - ': ' . $added . ' ' . JText::_('JBS_SUCCESS'); + ': ' . $added . ' ' . JText::_('JBS_SUCCESS'); $this->setRedirect('index.php?option=com_biblestudy&view=admin&layout=edit&id=1', $msg); break; case 2: $buttontype = $decoded->media_button_type; - $icontype = $decoded->media_icon_type; + $icontype = $decoded->media_icon_type; foreach ($images as $media) { @@ -171,7 +171,7 @@ public function mediaimages() ->set('params = ' . $db->q($reg->toString())) ->where('id = ' . (int) $media->id); $db->execute(); - $rows = $db->getAffectedRows(); + $rows = $db->getAffectedRows(); $added = $added + $rows; } catch (RuntimeException $e) @@ -183,7 +183,7 @@ public function mediaimages() } $msg .= JText::_('JBS_ERROR') . ': ' . $error . '
' . $errortext . '
' . JText::_('JBS_RESULTS') . - ': ' . $added . ' ' . JText::_('JBS_SUCCESS'); + ': ' . $added . ' ' . JText::_('JBS_SUCCESS'); $this->setRedirect('index.php?option=com_biblestudy&view=admin&layout=edit&id=1', $msg); break; case 3: @@ -223,7 +223,7 @@ public function mediaimages() ->set('params = ' . $db->q($reg->toString())) ->where('id = ' . (int) $media->id); $db->execute(); - $rows = $db->getAffectedRows(); + $rows = $db->getAffectedRows(); $added = $added + $rows; } catch (RuntimeException $e) @@ -235,7 +235,7 @@ public function mediaimages() } $msg .= JText::_('JBS_ERROR') . ': ' . $error . '
' . $errortext . '
' . JText::_('JBS_RESULTS') . - ': ' . $added . ' ' . JText::_('JBS_SUCCESS'); + ': ' . $added . ' ' . JText::_('JBS_SUCCESS'); $this->setRedirect('index.php?option=com_biblestudy&view=admin&layout=edit&id=1', $msg); break; case 0: @@ -276,7 +276,7 @@ public function mediaimages() ->set('params = ' . $db->q($reg->toString())) ->where('id = ' . (int) $media->id); $db->execute(); - $rows = $db->getAffectedRows(); + $rows = $db->getAffectedRows(); $added = $added + $rows; } catch (RuntimeException $e) @@ -288,7 +288,7 @@ public function mediaimages() } $msg .= JText::_('JBS_ERROR') . ': ' . $error . '
' . $errortext . '
' . JText::_('JBS_RESULTS') . - ': ' . $added . ' ' . JText::_('JBS_SUCCESS'); + ': ' . $added . ' ' . JText::_('JBS_SUCCESS'); $this->setRedirect('index.php?option=com_biblestudy&view=admin&layout=edit&id=1', $msg); break; default: @@ -368,16 +368,16 @@ public function changePopup() // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - $db = JFactory::getDbo(); - $msg = null; - $post = $_POST['jform']; - $reg = new Registry; + $db = JFactory::getDbo(); + $msg = null; + $post = $_POST['jform']; + $reg = new Registry; $reg->loadArray($post['params']); - $from = $reg->get('pFrom', 'x'); - $form2 = ''; - $to = $reg->get('pTo', 'x'); - $msg = JText::_('JBS_CMN_OPERATION_SUCCESSFUL'); - $query = $db->getQuery(true); + $from = $reg->get('pFrom', 'x'); + $form2 = ''; + $to = $reg->get('pTo', 'x'); + $msg = JText::_('JBS_CMN_OPERATION_SUCCESSFUL'); + $query = $db->getQuery(true); $query->select('id, params') ->from('#__bsms_mediafiles'); $db->setQuery($query); @@ -430,8 +430,8 @@ public function resetHits() // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - $db = JFactory::getDbo(); - $msg = null; + $db = JFactory::getDbo(); + $msg = null; $query = $db->getQuery(true); $query->update('#__bsms_mediafiles') ->set('hits = ' . 0) @@ -567,8 +567,8 @@ public function convertPreachIt() * * @return void * - * @since 7.1.0 * @throws Exception + * @since 7.1.0 */ public function fix() { @@ -811,10 +811,10 @@ public function export() /** * Get Thumbnail List XHR * - * @throws Exception - * * @return void * + * @throws Exception + * * @since 9.0.0 */ public function getThumbnailListXHR() @@ -848,10 +848,10 @@ public function getThumbnailListXHR() /** * Create Thumbnail XHR * - * @throws Exception - * * @return void * + * @throws Exception + * * @since 9.0.0 */ public function createThumbnailXHR() @@ -883,7 +883,60 @@ public function doArchive() /** @var BiblestudyModelArchive $model */ $model = $this->getModel('archive'); - $msg = $model->doArchive(); + $msg = $model->doArchive(); $this->setRedirect('index.php?option=com_biblestudy&view=cpanel', $msg); } + + public function submit($key = null, $urlVar = null) + { + $this->checkToken(); + + $app = JFactory::getApplication(); + $model = $this->getModel('form'); + $form = $model->getForm($data, false); + + if (!$form) + { + $app->enqueueMessage($model->getError(), 'error'); + + return false; + } + + // Name of array 'jform' must match 'control' => 'jform' line in the model code + $data = $this->input->post->get('jform', array(), 'array'); + + // This is validate() from the FormModel class, not the Form class + // FormModel::validate() calls both Form::filter() and Form::validate() methods + $validData = $model->validate($form, $data); + + if ($validData === false) + { + $errors = $model->getErrors(); + + foreach ($errors as $error) + { + if ($error instanceof \Exception) + { + $app->enqueueMessage($error->getMessage(), 'warning'); + } + else + { + $app->enqueueMessage($error, 'warning'); + } + } + + // Save the form data in the session, using a unique identifier + $app->setUserState('com_biblestudy.admin', $data); + } + else + { + $app->enqueueMessage("Data successfully validated", 'notice'); + + // Clear the form data in the session + $app->setUserState('com_biblestudy.admin', null); + } + + // Redirect back to the form in all cases + $this->setRedirect(JRoute::_('index.php?option=com_biblestudy&view=admin&layout=edit', false)); + } } diff --git a/admin/helpers/helper.php b/admin/helpers/helper.php index 623147449b..d158845425 100644 --- a/admin/helpers/helper.php +++ b/admin/helpers/helper.php @@ -153,7 +153,24 @@ public static function getRemoteFileSize($url) return 0; } - return $head['content-length'][1] ?? 0; + if (is_array($head['content-length'])) + { + if (count($head['content-length']) >= 1) + { + $dif = count($head['content-length']) - 1; + $size = $head['content-length'][$dif]; + } + else + { + $size = $head['content-length'][0]; + } + } + else + { + $size = $head['content-length']; + } + + return $size; } /** @@ -344,7 +361,7 @@ public static function getSimpleView($params = null) $params = JBSMParams::getAdmin(); } - $simple->mode = (integer) $params->params->get('simple_mode'); + $simple->mode = (integer) $params->params->get('simple_mode'); $simple->display = (integer) $params->params->get('simple_mode_display'); return $simple; diff --git a/admin/helpers/html/biblestudy.php b/admin/helpers/html/biblestudy.php index a9e1f56dc0..8ee242ca49 100644 --- a/admin/helpers/html/biblestudy.php +++ b/admin/helpers/html/biblestudy.php @@ -188,7 +188,7 @@ public static function link_type() /** * Method to get the field options. * - * @return Object The field option objects. + * @return object The field option objects. * * @since 1.6 */ diff --git a/admin/helpers/html/bsmedia.php b/admin/helpers/html/bsmedia.php index 6767af9abc..52dcbe2c6e 100644 --- a/admin/helpers/html/bsmedia.php +++ b/admin/helpers/html/bsmedia.php @@ -105,7 +105,7 @@ public static function loadCss($includeMainCss = true, $cssName = null, $cssSet JHtml::_('stylesheet', 'media/com_biblestudy/css/general.css', $attribs, true); } - if ($cssSet == 'lytebox') + if ($cssSet === 'lytebox') { JHtml::_('stylesheet', 'media/com_biblestudy/lytebox/lytebox.css', $attribs, true); } diff --git a/admin/install/sql/install-defaults.sql b/admin/install/sql/install-defaults.sql index cbc70c9bb2..e6b6ea0b8f 100644 --- a/admin/install/sql/install-defaults.sql +++ b/admin/install/sql/install-defaults.sql @@ -121,11 +121,11 @@ VALUES -- Dump of table #__bsms_podcast -- ------------------------------------------------------------ -INSERT INTO `#__bsms_podcast` (`id`, `title`, `website`, `description`, `image`, `imageh`, `imagew`, `author`, `podcastimage`, `podcastsearch`, `filename`, `language`, `editor_name`, `editor_email`, `podcastlimit`, `published`, `episodetitle`, `custom`, `detailstemplateid`, `asset_id`, `access`, `alternatelink`, `alternateimage`, `podcast_subscribe_show`, `podcast_image_subscribe`, `podcast_subscribe_desc`, `alternatewords`, `episodesubtitle`, `customsubtitle`, `linktype`) +INSERT IGNORE INTO `#__bsms_podcast` (`id`, `title`, `website`, `podcastlink`, `description`, `subtitle`, `image`, `imageh`, `imagew`, `author`, `podcastimage`, `podcastsearch`, `filename`, `language`, `editor_name`, `editor_email`, `podcastlimit`, `published`, `episodetitle`, `custom`, `detailstemplateid`, `asset_id`, `access`, `alternatelink`, `alternateimage`, `podcast_subscribe_show`, `podcast_image_subscribe`, `podcast_subscribe_desc`, `alternatewords`, `episodesubtitle`, `customsubtitle`, `linktype`) VALUES - (1, 'My Podcast', 'www.mywebsite.com', 'Podcast Description goes here', 'www.mywebsite.com/myimage.jpg', 30, 30, - 'Pastor Billy', 'www.mywebsite.com/myimage.jpg', 'jesus', 'mypodcast.xml', '*', 'Jim Editor', 'jim@mywebsite.com', - 50, 1, 0, '', 1, 7483, 1, '', '', 0, '', '', '', 0, '', 0); + (1, 'My Podcast', 'www.mywebsite.com', 'www.mywebsite.com/podcast.php', 'Podcast Description goes here', 'Short sentence about the podcast', 'www.mywebsite.com/myimage.jpg', 30, 30, + 'Pastor Billy', 'www.mywebsite.com/myimage.jpg', 'jesus', 'mypodcast.xml', '*', 'Jim Editor', 'jim@mywebsite.com', + 50, 1, 0, '', 1, 7483, 1, '', '', 0, '', '', '', 0, '', 0); -- Dump of table #__bsms_series -- ------------------------------------------------------------ diff --git a/admin/install/sql/install.sql b/admin/install/sql/install.sql index e8b465cc58..40ed60b53e 100644 --- a/admin/install/sql/install.sql +++ b/admin/install/sql/install.sql @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS `#__bsms_update` ( INSERT IGNORE INTO `#__bsms_update` (`id`, `version`) VALUES - (1, '9.3.6'); + (1, '9.3.7'); -- -------------------------------------------------------- @@ -191,7 +191,9 @@ CREATE TABLE IF NOT EXISTS `#__bsms_podcast` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `title` VARCHAR(100) DEFAULT NULL, `website` VARCHAR(100) DEFAULT NULL, + `podcastlink` VARCHAR(100) DEFAULT NULL, `description` TEXT, + `subtitle` TEXT, `image` VARCHAR(130) DEFAULT NULL, `imageh` INT(3) DEFAULT NULL, `imagew` INT(3) DEFAULT NULL, @@ -595,9 +597,9 @@ VALUES -- Dump of table #__bsms_podcast -- ------------------------------------------------------------ -INSERT IGNORE INTO `#__bsms_podcast` (`id`, `title`, `website`, `description`, `image`, `imageh`, `imagew`, `author`, `podcastimage`, `podcastsearch`, `filename`, `language`, `editor_name`, `editor_email`, `podcastlimit`, `published`, `episodetitle`, `custom`, `detailstemplateid`, `asset_id`, `access`, `alternatelink`, `alternateimage`, `podcast_subscribe_show`, `podcast_image_subscribe`, `podcast_subscribe_desc`, `alternatewords`, `episodesubtitle`, `customsubtitle`, `linktype`) +INSERT IGNORE INTO `#__bsms_podcast` (`id`, `title`, `website`, `podcastlink`, `description`, `subtitle`, `image`, `imageh`, `imagew`, `author`, `podcastimage`, `podcastsearch`, `filename`, `language`, `editor_name`, `editor_email`, `podcastlimit`, `published`, `episodetitle`, `custom`, `detailstemplateid`, `asset_id`, `access`, `alternatelink`, `alternateimage`, `podcast_subscribe_show`, `podcast_image_subscribe`, `podcast_subscribe_desc`, `alternatewords`, `episodesubtitle`, `customsubtitle`, `linktype`) VALUES -(1, 'My Podcast', 'www.mywebsite.com', 'Podcast Description goes here', 'www.mywebsite.com/myimage.jpg', 30, 30, +(1, 'My Podcast', 'www.mywebsite.com', 'www.mywebsite.com/podcast.php', 'Podcast Description goes here', 'Short sentence about the podcast', 'www.mywebsite.com/myimage.jpg', 30, 30, 'Pastor Billy', 'www.mywebsite.com/myimage.jpg', 'jesus', 'mypodcast.xml', '*', 'Jim Editor', 'jim@mywebsite.com', 50, 1, 0, '', 1, 7483, 1, '', '', 0, '', '', '', 0, '', 0); diff --git a/admin/install/sql/updates/mysql/9.2.7.sql b/admin/install/sql/updates/mysql/9.2.7.sql new file mode 100644 index 0000000000..936dd9c332 --- /dev/null +++ b/admin/install/sql/updates/mysql/9.2.7.sql @@ -0,0 +1,11 @@ +CREATE TABLE IF NOT EXISTS `#__bsms_update` ( + id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + version VARCHAR(255) DEFAULT NULL, + PRIMARY KEY (id) +) DEFAULT CHARSET=utf8; + +INSERT INTO `#__bsms_update` (id, version) VALUES ('37', '9.2.7') +ON DUPLICATE KEY UPDATE version = '9.2.7'; + +ALTER TABLE `#__bsms_podcast` ADD `podcastlink` VARCHAR(100) NOT NULL AFTER `website`; +ALTER TABLE `#__bsms_podcast` ADD `subtitle` TEXT NOT NULL AFTER `description`; \ No newline at end of file diff --git a/admin/install/updates/9.2.7.php b/admin/install/updates/9.2.7.php new file mode 100644 index 0000000000..487b631200 --- /dev/null +++ b/admin/install/updates/9.2.7.php @@ -0,0 +1,87 @@ +deleteUnexistingFiles(); + + return true; + } + + /** + * Remove Old Files and Folders + * + * @since 9.0.1 + * + * @return void + */ + protected function deleteUnexistingFiles() + { + // Import filesystem libraries. Perhaps not necessary, but does not hurt + jimport('joomla.filesystem.file'); + + $path = array( + '/administrator/components/com_biblestudy/addons/servers/local/local.php' + ); + + foreach ($path as $file) + { + if (JFile::exists($file)) + { + JFile::delete($file); + } + } + } +} diff --git a/admin/language/en-GB/en-GB.com_biblestudy.ini b/admin/language/en-GB/en-GB.com_biblestudy.ini index bf248439fb..20d948ad21 100644 --- a/admin/language/en-GB/en-GB.com_biblestudy.ini +++ b/admin/language/en-GB/en-GB.com_biblestudy.ini @@ -435,7 +435,7 @@ JBS_ADM_SHOW_LOCATION_MEDIA="Show Location with Study on Media drop down" JBS_ADM_SHOW_LOCATION_MEDIA_DESC="Choose Show if you want the location information to show up with the study and date on the drop down in the mediafile edit view on the backend" JBS_ADM_SIMPLE_MODE="Simple Mode" JBS_ADM_SIMPLE_MODE_DESC="This option turns off and on the CWM-Proclaim Simple Mode. Simple mode has fewer options and dedicated site views. This is a good choice for sites where simplicity of administering CWM-Proclaim is key" -JBS_ADM_SIMPLE_MODE_DISPLAY="Show/Hide Simple Mode Indicator" +JBS_ADM_SIMPLE_MODE_DISPLAY="Show Simple Mode Indicator" JBS_ADM_SIMPLE_MODE_DISPLAY_DESC="Decide whether the Simple Mode indicator appears at the top of admin menus. Warning - if Simple Mode is on and this indicator turned off, you may be in Simple Mode and not know it!" JBS_ADM_SOCIALNETWORKING="Use Social Media Links" JBS_ADM_SOCIALNETWORKING_DESC="Show or Hide links for users to post studydetails link on social media sites (configure on Social Media tab)" @@ -934,6 +934,8 @@ JBS_PDC_NUM_RECORDS_INCLUDE="Number of Records to include" JBS_PDC_NUM_RECORDS_INCLUDE_DESC="Max. number of records (blank or '0' for all)" JBS_PDC_PODCAST_AUTHOR="Podcast Author" JBS_PDC_PODCAST_DESCRIPTION="Description of Podcast (500 Max)" +JBS_PDC_PODCAST_SUBTITLE="Sub Title" +JBS_PDC_PODCAST_SUBTITLE_DESC="Short sentence about the podcast" JBS_PDC_PODCAST_IMAGES="Podcast Images" JBS_PDC_PODCAST_LANGUAGE="Podcast language" JBS_PDC_PODCAST_LOGO="Podcast Logo" @@ -955,6 +957,7 @@ JBS_PDC_SUBSCRIBE_WORDS="Label for podcast subscription" JBS_PDC_SUBSCRIBE_WORDS_DESC="A word or words to go under the image for the podcast subscription. Leave blank for none" JBS_PDC_TEMPLATE_FOR_DETAILS_VIEW_LINK="Template for Details View Link" JBS_PDC_WEBSITE_URL="Website url (NO http://)" +JBS_PDC_PODCAST_URL="Podcast Link url (NO http://)" JBS_PDC_WRITE_XML_FILES="Write XML Files" JBS_PDC_XML_FILES_ERROR="There were errors in publishing your podcasts. Please check the site file(s)." JBS_PDC_XML_FILES_WRITTEN="Podcast successfully published" @@ -1653,9 +1656,9 @@ JBS_TPL_SERIESDISPLAY_USE_HEADER="Display a header for the series" JBS_TPL_SERIESDISPLAY_USE_HEADER_DESC="Choose whether or not to show a header above the series information" JBS_TPL_SERIESIMAGE="Series Image" JBS_TPL_SERIESLIST="Series List" -JBS_TPL_SERIESDETAILSDISPLAY="Series List Display" +JBS_TPL_SERIESLISTDISPLAY="Series List Display" +JBS_TPL_SERIESDETAILSDISPLAY="Series Details List Display" JBS_TPL_SERIESTITLE="Series Title" -JBS_TPL_SERIESDETAILSDISPLAY="Series Title Display" JBS_TPL_SERIES_BRACE="Series {series_text}" JBS_TPL_SERIES_DESCRIPTION_BRACE="Series Description {series_description}" JBS_TPL_SERIES_LIST_TEMPLATE="Series List Template File" diff --git a/admin/models/admin.php b/admin/models/admin.php index 57ab8a6461..92993941ea 100644 --- a/admin/models/admin.php +++ b/admin/models/admin.php @@ -181,7 +181,7 @@ public function fix() /** * Gets the ChangeSet object * - * @return string JSchema ChangeSet + * @return boolean|Joomla\CMS\Schema\ChangeSet JSchema ChangeSet * * @throws \Exception * @since 7.0 @@ -319,9 +319,8 @@ public function getSchemaVersion() $query->select('version_id')->from($db->qn('#__schemas')) ->where('extension_id = ' . $db->q($extensionresult)); $db->setQuery($query); - $result = $db->loadResult(); - return $result; + return $db->loadResult(); } /** @@ -567,14 +566,14 @@ public function playerByMediaType() $extension = substr($filename, strrpos($filename, '.') + 1); - if (strpos($filename, 'http') !== false && $from == 'http') + if ($from === 'http' && strpos($filename, 'http') !== false) { $reg->set('mime_type', ' '); $isfrom = 'http'; $search = true; } - if (!empty($mediacode) && $from == 'mediacode') + if (!empty($mediacode) && $from === 'mediacode') { $reg->set('mime_type', ' '); $isfrom = 'mediacode'; diff --git a/admin/models/forms/admin.xml b/admin/models/forms/admin.xml index b1da2ab599..e285dcd43e 100644 --- a/admin/models/forms/admin.xml +++ b/admin/models/forms/admin.xml @@ -372,14 +372,15 @@
-
+
+ type="list" size="15" required="true" default="x" message="You must choose image, icon, button or button and icon"> + diff --git a/admin/models/forms/filter_mediafiles.xml b/admin/models/forms/filter_mediafiles.xml index 2f48b4f417..73c9c8fbb9 100644 --- a/admin/models/forms/filter_mediafiles.xml +++ b/admin/models/forms/filter_mediafiles.xml @@ -48,6 +48,27 @@
+ + + + + + + + + + + + +
- - - + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/admin/models/mediafile.php b/admin/models/mediafile.php index 6316342f9b..fc3febc0db 100644 --- a/admin/models/mediafile.php +++ b/admin/models/mediafile.php @@ -105,22 +105,22 @@ public function save($data) $params = new Registry; $params->loadArray($data['params']); - if (isset($params->toObject()->size) && $params->get('size', '0') == '0') - { - $jdb = JFactory::getDbo(); - $table = new TableServer($jdb); - $table->load($data['server_id']); + $jdb = JFactory::getDbo(); + $table = new TableServer($jdb); + $table->load($data['server_id']); - $path = new Registry; - $path->loadString($table->params); - $set_path = ''; + $path = new Registry; + $path->loadString($table->params); + $set_path = ''; - if ($path->get('path')) - { - $set_path = $path->get('path') . '/'; - } + if ($path->get('path')) + { + $set_path = $path->get('path') . '/'; + } - if (!$path->get('protocal') && $set_path) + if (isset($params->toObject()->size) && $params->get('size', '0') === '0') + { + if ($set_path && !$path->get('protocal')) { $path->set('protocal', 'http://'); } @@ -129,13 +129,41 @@ public function save($data) $path->set('protocal', rtrim(JUri::root(), '/')); } - if ($table->type == 'legacy' || $table->type == 'local') + if ($table->type === 'legacy' || $table->type === 'local') { - $params->set('size', JBSMHelper::getRemoteFileSize(JBSMHelper::MediaBuildUrl($set_path, $params->get('filename'), $params, true, true))); - $data['params'] = $params->toArray(); + $params->set('size', + JBSMHelper::getRemoteFileSize(JBSMHelper::MediaBuildUrl($set_path, $params->get('filename'), $params, true, true) + ) + ); } } + if (($params->toObject()->media_hours === '00' || empty($params->toObject()->media_hours)) + && ($params->toObject()->media_minutes === '00' || empty($params->toObject()->media_minutes)) + && ($params->toObject()->media_seconds === '00' || empty($params->toObject()->media_seconds)) + ) + { + $path = JBSMHelper::MediaBuildUrl($set_path, $params->get('filename'), $params, false, false, true); + $jbspodcast = new JBSMPodcast; + + // Make a duration build from Params of media. + $prefix = JUri::root(); + $nohttp = $jbspodcast->remove_http($prefix); + + if (strpos($path, $nohttp) === 0) + { + $filename = substr($path, strlen($nohttp)); + $filename = JPATH_SITE . '/' . $filename; + $duration = $jbspodcast->formatTime($jbspodcast->getDuration($filename)); + + $params->set('media_hours', $duration->hourse); + $params->set('media_minutes', $duration->minutes); + $params->set('media_seconds', $duration->seconds); + } + } + + $data['params'] = $params->toArray(); + if (parent::save($data)) { return true; @@ -165,8 +193,8 @@ public function getMediaForm() if ($server_id === null) { /** @var Joomla\Registry\Registry $admin */ - $admin = JBSMParams::getAdmin()->params; - $server_id = $admin->get('server'); + $admin = JBSMParams::getAdmin()->params; + $server_id = $admin->get('server'); if ($server_id !== '-1') { @@ -182,7 +210,7 @@ public function getMediaForm() /** @type BiblestudyModelServer $model */ $model = JModelLegacy::getInstance('Server', 'BibleStudyModel'); $server_type = $model->getType($server_id, true); - $s_item = $model->getItem($server_id); + $s_item = $model->getItem($server_id); $reg = new Registry; $reg->loadArray($s_item->params); @@ -233,8 +261,8 @@ public function getMediaForm() * * @return boolean|object * - * @since 7.0 * @throws Exception + * @since 7.0 */ public function getForm($data = array(), $loadData = true) { @@ -292,8 +320,8 @@ public function getForm($data = array(), $loadData = true) * * @return mixed * - * @since 9.0.0 * @throws Exception + * @since 9.0.0 */ public function getItem($pk = null) { @@ -452,7 +480,7 @@ public function batch($commands, $pks, $contexts) protected function batchPlayer($value, $pks, $contexts) { // Set the variables - $user = JFactory::getUser(); + $user = JFactory::getUser(); /** @type TableMediafile $table */ $table = $this->getTable(); @@ -517,7 +545,7 @@ protected function cleanCache($group = null, $client_id = 0) protected function batchlink_type($value, $pks, $contexts) { // Set the variables - $user = JFactory::getUser(); + $user = JFactory::getUser(); /** @type TableMediafile $table */ $table = $this->getTable(); @@ -567,7 +595,7 @@ protected function batchlink_type($value, $pks, $contexts) protected function batchMimetype($value, $pks, $contexts) { // Set the variables - $user = JFactory::getUser(); + $user = JFactory::getUser(); /** @type TableMediafile $table */ $table = $this->getTable(); @@ -732,8 +760,8 @@ protected function canDelete($record) * * @return array * - * @since 7.0 * @throws Exception + * @since 7.0 */ protected function loadFormData() { @@ -749,8 +777,8 @@ protected function loadFormData() * * @return void * - * @since 9.0.0 * @throws Exception + * @since 9.0.0 */ protected function populateState() { @@ -758,8 +786,8 @@ protected function populateState() $input = $app->input; // Load the Admin settings - $admin = JBSMParams::getAdmin(); - $registry = new Registry; + $admin = JBSMParams::getAdmin(); + $registry = new Registry; $registry->loadString($admin->params); $this->setState('admin', $registry); diff --git a/admin/models/mediafiles.php b/admin/models/mediafiles.php index 4c2acf6afc..23ad384447 100644 --- a/admin/models/mediafiles.php +++ b/admin/models/mediafiles.php @@ -32,7 +32,7 @@ class BiblestudyModelMediafiles extends JModelList /** * Number of Deletions * - * @var integer + * @var object * * @since 7.0 */ @@ -43,6 +43,7 @@ class BiblestudyModelMediafiles extends JModelList * * @param array $config An optional associative array of configuration settings. * + * @throws \Exception * @since 7.0 */ public function __construct($config = array()) @@ -241,7 +242,7 @@ protected function getStoreId($id = '') /** * Build an SQL query to load the list data * - * @return JDatabaseQuery + * @return \Joomla\Database\QueryInterface * * @since 7.0 */ diff --git a/admin/models/podcast.php b/admin/models/podcast.php index 068f75ced7..3d1e172bef 100644 --- a/admin/models/podcast.php +++ b/admin/models/podcast.php @@ -109,9 +109,7 @@ protected function loadFormData() */ public function getItem($pk = null) { - $item = parent::getItem($pk); - - return $item; + return parent::getItem($pk); } /** diff --git a/admin/models/rules/image.php b/admin/models/rules/image.php new file mode 100644 index 0000000000..c537fd6730 --- /dev/null +++ b/admin/models/rules/image.php @@ -0,0 +1,23 @@ +Proclaim Component Installed - status->modules)) : ?> + status->cwmmodules)) : ?> Module Client diff --git a/admin/views/install/view.html.php b/admin/views/install/view.html.php index f41537dfe9..1289f76736 100644 --- a/admin/views/install/view.html.php +++ b/admin/views/install/view.html.php @@ -102,7 +102,7 @@ class BiblestudyViewInstall extends JViewLegacy */ public function display($tpl = null) { - $input = new JInput; + $input = new Joomla\Input\Input; $input->set('hidemainmenu', true); $app = JFactory::getApplication(); $this->state = $app->input->get('scanstate', false); @@ -145,6 +145,7 @@ public function display($tpl = null) $document->setTitle(JText::_('JBS_MIG_TITLE')); // Install systems setup files + // @todo need to move to a helper as this is call do many times. $this->installsetup(); $this->addToolbar(); @@ -207,7 +208,7 @@ private function loadStack() /** * Add Toolbar to page * - * @return null + * @return void * * @throws Exception * @since 7.0.0 diff --git a/admin/views/mediafile/view.html.php b/admin/views/mediafile/view.html.php index a1b20fda61..6db25798dc 100644 --- a/admin/views/mediafile/view.html.php +++ b/admin/views/mediafile/view.html.php @@ -121,7 +121,7 @@ public function display($tpl = null) $this->addToolbar(); // Display the template - return parent::display($tpl); + parent::display($tpl); } /** @@ -137,7 +137,7 @@ protected function addToolbar() $input->set('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->get('id'); - $isNew = ($this->item->id === '0'); + $isNew = (empty($this->item->id)); $checkedOut = !($this->item->checked_out === '0' || $this->item->checked_out == $userId); $title = $isNew ? JText::_('JBS_CMN_NEW') : JText::_('JBS_CMN_EDIT'); JToolbarHelper::title(JText::_('JBS_CMN_MEDIA_FILES') . ': [' . $title . ']', 'video video'); @@ -146,24 +146,20 @@ protected function addToolbar() { JToolbarHelper::apply('mediafile.apply'); JToolbarHelper::save('mediafile.save'); - JToolbarHelper::save2new('mediafile.save2new'); JToolbarHelper::cancel('mediafile.cancel'); JToolbarHelper::checkin('mediafile.checkin'); } else { // Can't save the record if it's checked out. - if (!$checkedOut) + if (!$checkedOut && $this->canDo->get('core.edit', 'com_biblestudy')) { - if ($this->canDo->get('core.edit', 'com_biblestudy')) - { - JToolbarHelper::apply('mediafile.apply'); - JToolbarHelper::save('mediafile.save'); + JToolbarHelper::apply('mediafile.apply'); + JToolbarHelper::save('mediafile.save'); - if ($this->canDo->get('core.create', 'com_biblestudy')) - { - JToolbarHelper::save2new('mediafile.save2new'); - } + if ($this->canDo->get('core.create', 'com_biblestudy')) + { + JToolbarHelper::save2new('mediafile.save2new'); } } diff --git a/admin/views/mediafiles/tmpl/default.php b/admin/views/mediafiles/tmpl/default.php index 3ff1809908..c9552b6aeb 100644 --- a/admin/views/mediafiles/tmpl/default.php +++ b/admin/views/mediafiles/tmpl/default.php @@ -22,7 +22,7 @@ $listDirn = $this->escape($this->state->get('list.direction')); $archived = $this->state->get('filter.published') == 2 ? true : false; $trashed = $this->state->get('filter.published') == -2 ? true : false; -$saveOrder = $listOrder == 'mediafile.ordering'; +$saveOrder = $listOrder === 'mediafile.ordering'; $columns = 10; if ($saveOrder) @@ -79,7 +79,7 @@ - + @@ -97,7 +97,7 @@ items as $i => $item) : $item->max_ordering = 0; - $ordering = ($listOrder == 'mediafile.ordering'); + $ordering = ($listOrder === 'mediafile.ordering'); $canCreate = $user->authorise('core.create'); $canEdit = $user->authorise('core.edit', 'com_biblestudy.mediafile.' . $item->id); $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || $item->checked_out == 0; diff --git a/admin/views/mediafiles/view.html.php b/admin/views/mediafiles/view.html.php index 8e61f890c6..d770daa75a 100644 --- a/admin/views/mediafiles/view.html.php +++ b/admin/views/mediafiles/view.html.php @@ -134,7 +134,7 @@ public function display($tpl = null) $this->setDocument(); // Display the template - return parent::display($tpl); + parent::display($tpl); } /** @@ -195,8 +195,6 @@ protected function addToolbar() $dhtml = $layout->render(array('title' => $title)); $bar->appendButton('Custom', $dhtml, 'batch'); } - - include_once JPATH_COMPONENT . '/helpers/html/biblestudy.php'; } /** diff --git a/admin/views/podcast/tmpl/edit.php b/admin/views/podcast/tmpl/edit.php index 71042a5ac6..f641b333cb 100644 --- a/admin/views/podcast/tmpl/edit.php +++ b/admin/views/podcast/tmpl/edit.php @@ -74,6 +74,14 @@ form->getInput('website'); ?> +
+
+ form->getLabel('podcastlink'); ?> +
+
+ form->getInput('podcastlink'); ?> +
+
form->getLabel('author'); ?> diff --git a/admin/views/template/tmpl/edit.php b/admin/views/template/tmpl/edit.php index 846b70a59c..6c0d9f5a84 100644 --- a/admin/views/template/tmpl/edit.php +++ b/admin/views/template/tmpl/edit.php @@ -781,7 +781,7 @@
  • - +
  • diff --git a/biblestudy.script.php b/biblestudy.script.php index db7172033b..efae486255 100755 --- a/biblestudy.script.php +++ b/biblestudy.script.php @@ -51,11 +51,9 @@ class Com_BiblestudyInstallerScript */ static protected $versions = array( 'PHP' => array( - '5.6' => '5.6.30', - '7.0' => '7.0.13', '7.1' => '7.1.0', '7.2' => '7.2.1', - '0' => '7.2.11' // Preferred version + '0' => '7.4.1' // Preferred version ), 'MySQL' => array( '5.1' => '5.1', @@ -65,7 +63,7 @@ class Com_BiblestudyInstallerScript 'Joomla!' => array( '3.6' => '3.6.3', '3.7' => '3.7.0', - '0' => '3.8.3' // Preferred version + '0' => '3.9.3' // Preferred version ) ); diff --git a/biblestudy.xml b/biblestudy.xml index 1cf1cf0318..900a75a530 100644 --- a/biblestudy.xml +++ b/biblestudy.xml @@ -6,8 +6,8 @@ info@christianwebministries.org https://www.christianwebministries.org (C) 2007 - 2019 Proclaim All rights reserved. - 9.2.6 - April 6, 2021 + 9.2.7 + April 31, 2021 http://www.gnu.org/licenses/gpl.html JBS_INS_XML_DESCRIPTION diff --git a/build.xml b/build.xml index 56051b1683..abb8b6f59b 100644 --- a/build.xml +++ b/build.xml @@ -99,8 +99,8 @@ - - + + diff --git a/build/com_proclaim-9.2.6.zip b/build/com_proclaim-9.2.7.zip similarity index 80% rename from build/com_proclaim-9.2.6.zip rename to build/com_proclaim-9.2.7.zip index faf3f3c8a6..0df59a5800 100644 Binary files a/build/com_proclaim-9.2.6.zip and b/build/com_proclaim-9.2.7.zip differ diff --git a/composer.lock b/composer.lock index 375698f399..6a47982276 100644 --- a/composer.lock +++ b/composer.lock @@ -195,16 +195,16 @@ }, { "name": "phpmailer/phpmailer", - "version": "v6.4.0", + "version": "v6.4.1", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "050d430203105c27c30efd1dce7aa421ad882d01" + "reference": "9256f12d8fb0cd0500f93b19e18c356906cbed3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/050d430203105c27c30efd1dce7aa421ad882d01", - "reference": "050d430203105c27c30efd1dce7aa421ad882d01", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/9256f12d8fb0cd0500f93b19e18c356906cbed3d", + "reference": "9256f12d8fb0cd0500f93b19e18c356906cbed3d", "shasum": "" }, "require": { @@ -259,7 +259,7 @@ "description": "PHPMailer is a full-featured email creation and transfer class for PHP", "support": { "issues": "https://github.com/PHPMailer/PHPMailer/issues", - "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.4.0" + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.4.1" }, "funding": [ { @@ -267,7 +267,7 @@ "type": "github" } ], - "time": "2021-03-31T20:06:42+00:00" + "time": "2021-04-29T12:25:04+00:00" }, { "name": "simplepie/simplepie", @@ -699,16 +699,16 @@ "packages-dev": [ { "name": "composer/xdebug-handler", - "version": "1.4.6", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c" + "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", + "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", "shasum": "" }, "require": { @@ -743,7 +743,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4.6" + "source": "https://github.com/composer/xdebug-handler/tree/2.0.1" }, "funding": [ { @@ -759,7 +759,7 @@ "type": "tidelift" } ], - "time": "2021-03-25T17:01:18+00:00" + "time": "2021-05-05T19:37:51+00:00" }, { "name": "doctrine/instantiator", @@ -972,16 +972,16 @@ }, { "name": "pdepend/pdepend", - "version": "2.9.0", + "version": "2.9.1", "source": { "type": "git", "url": "https://github.com/pdepend/pdepend.git", - "reference": "b6452ce4b570f540be3a4f46276dd8d8f4fa5ead" + "reference": "1632f0cee84512ffd6dde71e58536b3b06528c41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdepend/pdepend/zipball/b6452ce4b570f540be3a4f46276dd8d8f4fa5ead", - "reference": "b6452ce4b570f540be3a4f46276dd8d8f4fa5ead", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/1632f0cee84512ffd6dde71e58536b3b06528c41", + "reference": "1632f0cee84512ffd6dde71e58536b3b06528c41", "shasum": "" }, "require": { @@ -1017,7 +1017,7 @@ "description": "Official version of pdepend to be handled with Composer", "support": { "issues": "https://github.com/pdepend/pdepend/issues", - "source": "https://github.com/pdepend/pdepend/tree/2.9.0" + "source": "https://github.com/pdepend/pdepend/tree/2.9.1" }, "funding": [ { @@ -1025,7 +1025,7 @@ "type": "tidelift" } ], - "time": "2021-03-11T09:20:40+00:00" + "time": "2021-04-15T21:36:28+00:00" }, { "name": "pear/cache_lite", @@ -1618,22 +1618,22 @@ }, { "name": "phpmd/phpmd", - "version": "2.9.1", + "version": "2.10.1", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", - "reference": "ce10831d4ddc2686c1348a98069771dd314534a8" + "reference": "bd5ef43d1dcaf7272605027c959c1c5ff3761f7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmd/phpmd/zipball/ce10831d4ddc2686c1348a98069771dd314534a8", - "reference": "ce10831d4ddc2686c1348a98069771dd314534a8", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/bd5ef43d1dcaf7272605027c959c1c5ff3761f7a", + "reference": "bd5ef43d1dcaf7272605027c959c1c5ff3761f7a", "shasum": "" }, "require": { - "composer/xdebug-handler": "^1.0", + "composer/xdebug-handler": "^1.0 || ^2.0", "ext-xml": "*", - "pdepend/pdepend": "^2.7.1", + "pdepend/pdepend": "^2.9.1", "php": ">=5.3.9" }, "require-dev": { @@ -1641,7 +1641,7 @@ "ext-json": "*", "ext-simplexml": "*", "gregwar/rst": "^1.0", - "mikey179/vfsstream": "^1.6.4", + "mikey179/vfsstream": "^1.6.8", "phpunit/phpunit": "^4.8.36 || ^5.7.27", "squizlabs/php_codesniffer": "^2.0" }, @@ -1689,7 +1689,7 @@ "support": { "irc": "irc://irc.freenode.org/phpmd", "issues": "https://github.com/phpmd/phpmd/issues", - "source": "https://github.com/phpmd/phpmd/tree/2.9.1" + "source": "https://github.com/phpmd/phpmd/tree/2.10.1" }, "funding": [ { @@ -1697,7 +1697,7 @@ "type": "tidelift" } ], - "time": "2020-09-23T22:06:32+00:00" + "time": "2021-05-11T17:16:16+00:00" }, { "name": "phpspec/prophecy", @@ -2290,16 +2290,16 @@ }, { "name": "psr/log", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", "shasum": "" }, "require": { @@ -2323,7 +2323,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for logging libraries", @@ -2334,9 +2334,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.3" + "source": "https://github.com/php-fig/log/tree/1.1.4" }, - "time": "2020-03-23T09:12:05+00:00" + "time": "2021-05-03T11:20:27+00:00" }, { "name": "roave/security-advisories", @@ -2344,12 +2344,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "e7a881e0d8b4f39e4a9c2d66cd696d08898acf54" + "reference": "5ffdb87f627ff16cc392e30515a1fe069cddc3e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/e7a881e0d8b4f39e4a9c2d66cd696d08898acf54", - "reference": "e7a881e0d8b4f39e4a9c2d66cd696d08898acf54", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/5ffdb87f627ff16cc392e30515a1fe069cddc3e2", + "reference": "5ffdb87f627ff16cc392e30515a1fe069cddc3e2", "shasum": "" }, "conflict": { @@ -2366,7 +2366,8 @@ "barrelstrength/sprout-base-email": "<1.2.7", "barrelstrength/sprout-forms": "<3.9", "baserproject/basercms": ">=4,<=4.3.6|>=4.4,<4.4.1", - "bolt/bolt": "<3.7.1", + "bk2k/bootstrap-package": ">=7.1,<7.1.2|>=8,<8.0.8|>=9,<9.0.4|>=9.1,<9.1.3|>=10,<10.0.10|>=11,<11.0.3", + "bolt/bolt": "<3.7.2", "bolt/core": "<4.1.13", "brightlocal/phpwhois": "<=4.2.5", "buddypress/buddypress": "<5.1.2", @@ -2377,7 +2378,7 @@ "centreon/centreon": "<18.10.8|>=19,<19.4.5", "cesnet/simplesamlphp-module-proxystatistics": "<3.1", "codeigniter/framework": "<=3.0.6", - "composer/composer": "<=1-alpha.11", + "composer/composer": "<1.10.22|>=2-alpha.1,<2.0.13", "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/core": ">=2,<3.5.39", "contao/core-bundle": ">=4,<4.4.52|>=4.5,<4.9.6|= 4.10.0", @@ -2396,8 +2397,9 @@ "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1|>=2.8.3,<2.8.4", "dolibarr/dolibarr": "<11.0.4", "dompdf/dompdf": ">=0.6,<0.6.2", - "drupal/core": ">=7,<7.74|>=8,<8.8.11|>=8.9,<8.9.9|>=9,<9.0.8", - "drupal/drupal": ">=7,<7.74|>=8,<8.8.11|>=8.9,<8.9.9|>=9,<9.0.8", + "drupal/core": ">=7,<7.80|>=8,<8.9.14|>=9,<9.0.12|>=9.1,<9.1.7", + "drupal/drupal": ">=7,<7.80|>=8,<8.9.14|>=9,<9.0.12|>=9.1,<9.1.7", + "dweeves/magmi": "<=0.7.24", "endroid/qr-code-bundle": "<3.4.2", "enshrined/svg-sanitize": "<0.13.1", "erusev/parsedown": "<1.7.2", @@ -2422,14 +2424,16 @@ "flarum/tags": "<=0.1-beta.13", "fluidtypo3/vhs": "<5.1.1", "fooman/tcpdf": "<6.2.22", + "forkcms/forkcms": "<5.8.3", "fossar/tcpdf-parser": "<6.2.22", + "francoisjacquet/rosariosis": "<6.5.1", "friendsofsymfony/oauth2-php": "<1.3", "friendsofsymfony/rest-bundle": ">=1.2,<1.2.2", "friendsofsymfony/user-bundle": ">=1.2,<1.3.5", "friendsoftypo3/mediace": ">=7.6.2,<7.6.5", "fuel/core": "<1.8.1", - "getgrav/grav": "<1.7-beta.8", - "getkirby/cms": ">=3,<3.4.5", + "getgrav/grav": "<1.7.11", + "getkirby/cms": "<3.5.4", "getkirby/panel": "<2.5.14", "gos/web-socket-bundle": "<1.10.4|>=2,<2.6.1|>=3,<3.3", "gree/jose": "<=2.2", @@ -2437,7 +2441,7 @@ "guzzlehttp/guzzle": ">=4-rc.2,<4.2.4|>=5,<5.3.1|>=6,<6.2.1", "illuminate/auth": ">=4,<4.0.99|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.10", "illuminate/cookie": ">=4,<=4.0.11|>=4.1,<=4.1.99999|>=4.2,<=4.2.99999|>=5,<=5.0.99999|>=5.1,<=5.1.99999|>=5.2,<=5.2.99999|>=5.3,<=5.3.99999|>=5.4,<=5.4.99999|>=5.5,<=5.5.49|>=5.6,<=5.6.99999|>=5.7,<=5.7.99999|>=5.8,<=5.8.99999|>=6,<6.18.31|>=7,<7.22.4", - "illuminate/database": "<6.20.14|>=7,<7.30.4|>=8,<8.24", + "illuminate/database": "<6.20.26|>=7,<8.40", "illuminate/encryption": ">=4,<=4.0.11|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.40|>=5.6,<5.6.15", "illuminate/view": ">=7,<7.1.2", "impresscms/impresscms": "<=1.4.2", @@ -2450,34 +2454,39 @@ "kitodo/presentation": "<3.1.2", "kreait/firebase-php": ">=3.2,<3.8.1", "la-haute-societe/tcpdf": "<6.2.22", - "laravel/framework": "<6.20.14|>=7,<7.30.4|>=8,<8.24", + "laravel/framework": "<6.20.26|>=7,<8.40", "laravel/socialite": ">=1,<1.0.99|>=2,<2.0.10", "league/commonmark": "<0.18.3", - "librenms/librenms": "<1.53", + "lexik/jwt-authentication-bundle": ">=2,<2.10.7|>=2.11,<2.11.3", + "librenms/librenms": "<21.1", "livewire/livewire": ">2.2.4,<2.2.6", "magento/community-edition": ">=2,<2.2.10|>=2.3,<2.3.3", "magento/magento1ce": "<1.9.4.3", "magento/magento1ee": ">=1,<1.14.4.3", "magento/product-community-edition": ">=2,<2.2.10|>=2.3,<2.3.2-p.2", "marcwillmann/turn": "<0.3.3", - "mautic/core": "<2.16.5|>=3,<3.2.4|= 2.13.1", + "mautic/core": "<3.3.2|= 2.13.1", "mediawiki/core": ">=1.27,<1.27.6|>=1.29,<1.29.3|>=1.30,<1.30.2|>=1.31,<1.31.9|>=1.32,<1.32.6|>=1.32.99,<1.33.3|>=1.33.99,<1.34.3|>=1.34.99,<1.35", "mittwald/typo3_forum": "<1.2.1", "monolog/monolog": ">=1.8,<1.12", "moodle/moodle": "<3.5.17|>=3.7,<3.7.9|>=3.8,<3.8.8|>=3.9,<3.9.5|>=3.10,<3.10.2", "namshi/jose": "<2.2", + "neos/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", + "neos/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<2.9.99|>=3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<3.3.23|>=4,<4.0.17|>=4.1,<4.1.16|>=4.2,<4.2.12|>=4.3,<4.3.3", + "neos/swiftmailer": ">=4.1,<4.1.99|>=5.4,<5.4.5", "nette/application": ">=2,<2.0.19|>=2.1,<2.1.13|>=2.2,<2.2.10|>=2.3,<2.3.14|>=2.4,<2.4.16|>=3,<3.0.6", "nette/nette": ">=2,<2.0.19|>=2.1,<2.1.13", "nystudio107/craft-seomatic": "<3.3", "nzo/url-encryptor-bundle": ">=4,<4.3.2|>=5,<5.0.1", "october/backend": "<1.1.2", - "october/cms": "= 1.0.469|>=1.0.319,<1.0.469", + "october/cms": "= 1.1.1|= 1.0.471|= 1.0.469|>=1.0.319,<1.0.469", "october/october": ">=1.0.319,<1.0.466", "october/rain": "<1.0.472|>=1.1,<1.1.2", "onelogin/php-saml": "<2.10.4", "oneup/uploader-bundle": "<1.9.3|>=2,<2.1.5", + "opencart/opencart": "<=3.0.3.2", "openid/php-openid": "<2.3", - "openmage/magento-lts": "<19.4.8|>=20,<20.0.4", + "openmage/magento-lts": "<=19.4.12|>=20,<=20.0.8", "orchid/platform": ">=9,<9.4.4", "oro/crm": ">=1.7,<1.7.4", "oro/platform": ">=1.7,<1.7.4", @@ -2489,11 +2498,12 @@ "pear/archive_tar": "<1.4.12", "personnummer/personnummer": "<3.0.2", "phpfastcache/phpfastcache": ">=5,<5.0.13", - "phpmailer/phpmailer": "<6.1.6", + "phpmailer/phpmailer": "<6.1.6|>=6.1.8,<6.4.1", "phpmussel/phpmussel": ">=1,<1.6", "phpmyadmin/phpmyadmin": "<4.9.6|>=5,<5.0.3", "phpoffice/phpexcel": "<1.8.2", "phpoffice/phpspreadsheet": "<1.16", + "phpseclib/phpseclib": "<2.0.31|>=3,<3.0.7", "phpunit/phpunit": ">=4.8.19,<4.8.28|>=5.0.10,<5.6.3", "phpwhois/phpwhois": "<=4.2.5", "phpxmlrpc/extras": "<0.6.1", @@ -2504,21 +2514,25 @@ "prestashop/contactform": ">1.0.1,<4.3", "prestashop/gamification": "<2.3.2", "prestashop/productcomments": ">=4,<4.2.1", + "prestashop/ps_emailsubscription": "<2.6.1", "prestashop/ps_facetedsearch": "<3.4.1", "privatebin/privatebin": "<1.2.2|>=1.3,<1.3.2", "propel/propel": ">=2-alpha.1,<=2-alpha.7", "propel/propel1": ">=1,<=1.7.1", "pterodactyl/panel": "<0.7.19|>=1-rc.0,<=1-rc.6", "pusher/pusher-php-server": "<2.2.1", + "pwweb/laravel-core": "<=0.3.6-beta", "rainlab/debugbar-plugin": "<3.1", + "rmccue/requests": ">=1.6,<1.8", "robrichards/xmlseclibs": "<3.0.4", "sabberworm/php-css-parser": ">=1,<1.0.1|>=2,<2.0.1|>=3,<3.0.1|>=4,<4.0.1|>=5,<5.0.9|>=5.1,<5.1.3|>=5.2,<5.2.1|>=6,<6.0.2|>=7,<7.0.4|>=8,<8.0.1|>=8.1,<8.1.1|>=8.2,<8.2.1|>=8.3,<8.3.1", "sabre/dav": ">=1.6,<1.6.99|>=1.7,<1.7.11|>=1.8,<1.8.9", "scheb/two-factor-bundle": ">=0,<3.26|>=4,<4.11", "sensiolabs/connect": "<4.2.3", "serluck/phpwhois": "<=4.2.6", - "shopware/core": "<=6.3.4", - "shopware/platform": "<=6.3.5.1", + "shopware/core": "<=6.3.5.2", + "shopware/platform": "<=6.3.5.2", + "shopware/production": "<=6.3.5.2", "shopware/shopware": "<5.6.9", "silverstripe/admin": ">=1.0.3,<1.0.4|>=1.1,<1.1.1", "silverstripe/assets": ">=1,<1.4.7|>=1.5,<1.5.2", @@ -2564,20 +2578,21 @@ "symfony/http-foundation": ">=2,<2.8.52|>=3,<3.4.35|>=4,<4.2.12|>=4.3,<4.3.8|>=4.4,<4.4.7|>=5,<5.0.7", "symfony/http-kernel": ">=2,<2.8.52|>=3,<3.4.35|>=4,<4.2.12|>=4.3,<4.4.13|>=5,<5.1.5", "symfony/intl": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", + "symfony/maker-bundle": ">=1.27,<1.31.1", "symfony/mime": ">=4.3,<4.3.8", "symfony/phpunit-bridge": ">=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.1.12|>=4.2,<4.2.7", "symfony/polyfill": ">=1,<1.10", "symfony/polyfill-php55": ">=1,<1.10", "symfony/proxy-manager-bridge": ">=2.7,<2.7.51|>=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.1.12|>=4.2,<4.2.7", "symfony/routing": ">=2,<2.0.19", - "symfony/security": ">=2,<2.7.51|>=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.1.12|>=4.2,<4.2.7|>=4.4,<4.4.7|>=5,<5.0.7", + "symfony/security": ">=2,<2.7.51|>=2.8,<3.4.48|>=4,<4.4.23|>=5,<5.2.8", "symfony/security-bundle": ">=2,<2.7.48|>=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11", - "symfony/security-core": ">=2.4,<2.6.13|>=2.7,<2.7.9|>=2.7.30,<2.7.32|>=2.8,<2.8.37|>=3,<3.3.17|>=3.4,<3.4.7|>=4,<4.0.7", + "symfony/security-core": ">=2.4,<2.6.13|>=2.7,<2.7.9|>=2.7.30,<2.7.32|>=2.8,<3.4.48|>=4,<4.4.23|>=5,<5.2.8", "symfony/security-csrf": ">=2.4,<2.7.48|>=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11", - "symfony/security-guard": ">=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11", - "symfony/security-http": ">=2.3,<2.3.41|>=2.4,<2.7.51|>=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.2.12|>=4.3,<4.3.8|>=4.4,<4.4.7|>=5,<5.0.7", + "symfony/security-guard": ">=2.8,<3.4.48|>=4,<4.4.23|>=5,<5.2.8", + "symfony/security-http": ">=2.3,<2.3.41|>=2.4,<2.7.51|>=2.8,<3.4.48|>=4,<4.4.23|>=5,<5.2.8", "symfony/serializer": ">=2,<2.0.11", - "symfony/symfony": ">=2,<2.8.52|>=3,<3.4.35|>=4,<4.2.12|>=4.3,<4.4.13|>=5,<5.1.5", + "symfony/symfony": ">=2,<3.4.48|>=4,<4.4.23|>=5,<5.2.8", "symfony/translation": ">=2,<2.0.17", "symfony/validator": ">=2,<2.0.24|>=2.1,<2.1.12|>=2.2,<2.2.5|>=2.3,<2.3.3", "symfony/var-exporter": ">=4.2,<4.2.12|>=4.3,<4.3.8", @@ -2595,15 +2610,17 @@ "typo3/cms-backend": ">=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", "typo3/cms-core": ">=6.2,<=6.2.56|>=7,<=7.6.50|>=8,<=8.7.39|>=9,<9.5.25|>=10,<10.4.14|>=11,<11.1.1", "typo3/cms-form": ">=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", - "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5", - "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4", + "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", + "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<2.3.99|>=3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<3.3.23|>=4,<4.0.17|>=4.1,<4.1.16|>=4.2,<4.2.12|>=4.3,<4.3.3", "typo3/phar-stream-wrapper": ">=1,<2.1.1|>=3,<3.1.1", + "typo3/swiftmailer": ">=4.1,<4.1.99|>=5.4,<5.4.5", "typo3fluid/fluid": ">=2,<2.0.8|>=2.1,<2.1.7|>=2.2,<2.2.4|>=2.3,<2.3.7|>=2.4,<2.4.4|>=2.5,<2.5.11|>=2.6,<2.6.10", "ua-parser/uap-php": "<3.8", "usmanhalalit/pixie": "<1.0.3|>=2,<2.0.2", "verot/class.upload.php": "<=1.0.3|>=2,<=2.0.4", "vrana/adminer": "<4.7.9", "wallabag/tcpdf": "<6.2.22", + "wikimedia/parsoid": "<0.12.2", "willdurand/js-translation-bundle": "<2.1.1", "yii2mod/yii2-cms": "<1.9.2", "yiisoft/yii": ">=1.1.14,<1.1.15", @@ -2615,6 +2632,7 @@ "yiisoft/yii2-jui": "<2.0.4", "yiisoft/yii2-redis": "<2.0.8", "yourls/yourls": "<1.7.4", + "zendesk/zendesk_api_client_php": "<2.2.11", "zendframework/zend-cache": ">=2.4,<2.4.8|>=2.5,<2.5.3", "zendframework/zend-captcha": ">=2,<2.4.9|>=2.5,<2.5.2", "zendframework/zend-crypt": ">=2,<2.4.9|>=2.5,<2.5.2", @@ -2639,7 +2657,8 @@ "zetacomponents/mail": "<1.8.2", "zf-commons/zfc-user": "<1.2.2", "zfcampus/zf-apigility-doctrine": ">=1,<1.0.3", - "zfr/zfr-oauth2-server-module": "<0.1.2" + "zfr/zfr-oauth2-server-module": "<0.1.2", + "zoujingli/thinkadmin": "<6.0.22" }, "default-branch": true, "type": "metapackage", @@ -2674,7 +2693,7 @@ "type": "tidelift" } ], - "time": "2021-04-06T13:08:34+00:00" + "time": "2021-05-13T21:03:10+00:00" }, { "name": "sebastian/comparator", @@ -3230,16 +3249,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.8", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", "shasum": "" }, "require": { @@ -3282,20 +3301,20 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2020-10-23T02:01:07+00:00" + "time": "2021-04-09T00:54:41+00:00" }, { "name": "symfony/config", - "version": "v4.4.20", + "version": "v4.4.23", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "98606c6fa1a8f55ff964ccdd704275bf5b9f71b3" + "reference": "be9e601f17fc684ddfd6c675fdfcd04bb51fa928" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/98606c6fa1a8f55ff964ccdd704275bf5b9f71b3", - "reference": "98606c6fa1a8f55ff964ccdd704275bf5b9f71b3", + "url": "https://api.github.com/repos/symfony/config/zipball/be9e601f17fc684ddfd6c675fdfcd04bb51fa928", + "reference": "be9e601f17fc684ddfd6c675fdfcd04bb51fa928", "shasum": "" }, "require": { @@ -3342,7 +3361,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v4.4.20" + "source": "https://github.com/symfony/config/tree/v4.4.23" }, "funding": [ { @@ -3358,7 +3377,7 @@ "type": "tidelift" } ], - "time": "2021-02-22T15:36:50+00:00" + "time": "2021-05-07T13:37:51+00:00" }, { "name": "symfony/console", @@ -3446,16 +3465,16 @@ }, { "name": "symfony/debug", - "version": "v4.4.20", + "version": "v4.4.22", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "157bbec4fd773bae53c5483c50951a5530a2cc16" + "reference": "45b2136377cca5f10af858968d6079a482bca473" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/157bbec4fd773bae53c5483c50951a5530a2cc16", - "reference": "157bbec4fd773bae53c5483c50951a5530a2cc16", + "url": "https://api.github.com/repos/symfony/debug/zipball/45b2136377cca5f10af858968d6079a482bca473", + "reference": "45b2136377cca5f10af858968d6079a482bca473", "shasum": "" }, "require": { @@ -3495,7 +3514,7 @@ "description": "Provides tools to ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/debug/tree/v4.4.20" + "source": "https://github.com/symfony/debug/tree/v4.4.22" }, "funding": [ { @@ -3511,20 +3530,20 @@ "type": "tidelift" } ], - "time": "2021-01-28T16:54:48+00:00" + "time": "2021-04-02T07:50:12+00:00" }, { "name": "symfony/dependency-injection", - "version": "v4.4.21", + "version": "v4.4.23", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "b5f97557faa48ead4671bc311cfca423d476e93e" + "reference": "c1d4b65852f22e19131dea626e236a8e07d64479" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/b5f97557faa48ead4671bc311cfca423d476e93e", - "reference": "b5f97557faa48ead4671bc311cfca423d476e93e", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/c1d4b65852f22e19131dea626e236a8e07d64479", + "reference": "c1d4b65852f22e19131dea626e236a8e07d64479", "shasum": "" }, "require": { @@ -3545,7 +3564,7 @@ "require-dev": { "symfony/config": "^4.3", "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0" + "symfony/yaml": "^4.4|^5.0" }, "suggest": { "symfony/config": "", @@ -3580,7 +3599,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v4.4.21" + "source": "https://github.com/symfony/dependency-injection/tree/v4.4.23" }, "funding": [ { @@ -3596,20 +3615,20 @@ "type": "tidelift" } ], - "time": "2021-03-05T18:16:26+00:00" + "time": "2021-05-11T15:55:42+00:00" }, { "name": "symfony/filesystem", - "version": "v5.2.6", + "version": "v5.2.7", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "8c86a82f51658188119e62cff0a050a12d09836f" + "reference": "056e92acc21d977c37e6ea8e97374b2a6c8551b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/8c86a82f51658188119e62cff0a050a12d09836f", - "reference": "8c86a82f51658188119e62cff0a050a12d09836f", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/056e92acc21d977c37e6ea8e97374b2a6c8551b0", + "reference": "056e92acc21d977c37e6ea8e97374b2a6c8551b0", "shasum": "" }, "require": { @@ -3642,7 +3661,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.2.6" + "source": "https://github.com/symfony/filesystem/tree/v5.2.7" }, "funding": [ { @@ -3658,20 +3677,20 @@ "type": "tidelift" } ], - "time": "2021-03-28T14:30:26+00:00" + "time": "2021-04-01T10:42:13+00:00" }, { "name": "symfony/finder", - "version": "v5.2.4", + "version": "v5.2.8", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "0d639a0943822626290d169965804f79400e6a04" + "reference": "eccb8be70d7a6a2230d05f6ecede40f3fdd9e252" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/0d639a0943822626290d169965804f79400e6a04", - "reference": "0d639a0943822626290d169965804f79400e6a04", + "url": "https://api.github.com/repos/symfony/finder/zipball/eccb8be70d7a6a2230d05f6ecede40f3fdd9e252", + "reference": "eccb8be70d7a6a2230d05f6ecede40f3fdd9e252", "shasum": "" }, "require": { @@ -3703,7 +3722,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.2.4" + "source": "https://github.com/symfony/finder/tree/v5.2.8" }, "funding": [ { @@ -3719,7 +3738,7 @@ "type": "tidelift" } ], - "time": "2021-02-15T18:55:04+00:00" + "time": "2021-05-10T14:39:23+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -3886,21 +3905,21 @@ }, { "name": "symfony/service-contracts", - "version": "v2.2.0", + "version": "v2.4.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1" + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1", - "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", "shasum": "" }, "require": { "php": ">=7.2.5", - "psr/container": "^1.0" + "psr/container": "^1.1" }, "suggest": { "symfony/service-implementation": "" @@ -3908,7 +3927,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-main": "2.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -3945,7 +3964,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/master" + "source": "https://github.com/symfony/service-contracts/tree/v2.4.0" }, "funding": [ { @@ -3961,7 +3980,7 @@ "type": "tidelift" } ], - "time": "2020-09-07T11:33:47+00:00" + "time": "2021-04-01T10:43:52+00:00" }, { "name": "theseer/fdomdocument", diff --git a/site/helpers/media.php b/site/helpers/media.php index f36214d304..c47237535b 100644 --- a/site/helpers/media.php +++ b/site/helpers/media.php @@ -19,11 +19,12 @@ */ class JBSMMedia { - /** @type int File Size + /** + * @var integer File Size * * @since 7.0 */ - private $fsize = 0; + private int $fsize = 0; /** * Return Fluid Media row @@ -80,24 +81,33 @@ public function getFluidMedia($media, $params, $template) } // New Podcast Playlist cast Player code override option. - $player = self::getPlayerAttributes($params, $media); - $playercode = self::getPlayerCode($params, $player, $image, $media); - $downloadlink = self::getFluidDownloadLink($media, $params, $template); + $player = $this->getPlayerAttributes($params, $media); + $playercode = $this->getPlayerCode($params, $player, $image, $media); + $downloadlink = $this->getFluidDownloadLink($media, $params, $template); - if ($params->get('pcplaylist')) + $link_type = 0; + + if ($media->params->get('link_type') === '0' || $media->params->get('link_type')) { - $link_type = 0; + $link_type = $media->params->get('link_type', 3); } - elseif ($media->params->get('link_type') === '0' || $media->params->get('link_type')) + elseif ($params->get('download_show') !== '0' && !$media->params->get('link_type')) { - $link_type = $media->params->get('link_type', 3); + $link_type = 3; } - else + + if ($params->get('simple_mode') === '1' || $params->get('sermonstemplate') === 'easy') + { + $link_type = 3; + } + + // Used to override everything if used for use of the Podcast playlist system.. + if ($params->get('pcplaylist')) { - $link_type = $media->smedia->get('link_type'); + $link_type = 0; } - if ($params->get('show_filesize') > 0 && isset($media) && $link_type < 2) + if (isset($media) && $link_type < 2 && $params->get('show_filesize') > 0) { $file_size = $media->params->get('size', '0'); @@ -109,6 +119,7 @@ public function getFluidMedia($media, $params, $template) JBSMHelper::SetFilesize($media->id, $file_size); } + // Todo may be able to run this through a functions as this looks like duplicate code of 849 switch ($file_size) { case $file_size < 1024 : @@ -154,11 +165,6 @@ public function getFluidMedia($media, $params, $template) $file_size . ''; } - if ($params->get('simple_mode') === '1' || $params->get('sermonstemplate') === 'easy') - { - $link_type = 3; - } - switch ($link_type) { case 0: @@ -242,9 +248,9 @@ public function getFluidDownloadLink($media, $params, $template) if ($link_type > 0) { - $compat_mode = $params->get('compat_mode'); + $compat_mode = (int) $params->get('compat_mode'); - if ($compat_mode == 0) + if ($compat_mode === 0) { $downloadlink = ''; @@ -273,7 +279,8 @@ public function getFluidDownloadLink($media, $params, $template) if ($params->get('useterms') > 0) { - $downloadlink = ''; } @@ -318,7 +325,7 @@ public function mediaButton($imageparams, $params, $media) break; case 2: // Button and icon - if ($imageparams->get('media_icon_type') == '1') + if ($imageparams->get('media_icon_type') === '1') { $icon = $imageparams->get('media_custom_icon'); } @@ -335,7 +342,7 @@ public function mediaButton($imageparams, $params, $media) break; case 3: // Icon only - if ($imageparams->get('media_icon_type') == 1) + if ($imageparams->get('media_icon_type') === '1') { $icon = $imageparams->get('media_custom_icon'); } @@ -351,21 +358,21 @@ public function mediaButton($imageparams, $params, $media) break; } - if ($params->get('simple_mode') == 1 || $params->get('sermonstemplate') == 'easy') + if ($params->get('simple_mode') === '1' || $params->get('sermonstemplate') === 'easy') { $filename = $media->get('filename'); if ((preg_match('(youtube.com|youtu.be)', $filename) === 1)) { - $mediaimage = ''; + $mediaimage = ''; } elseif ((preg_match('(pdf|PDF)', $filename) === 1)) { - $mediaimage = ''; + $mediaimage = ''; } else { - $mediaimage = ''; + $mediaimage = ''; } } @@ -405,7 +412,7 @@ public function downloadButton($download) break; case 3: // Button and icon - if ($download->get('download_icon_type') == '1') + if ($download->get('download_icon_type') === '1') { $icon = $download->get('download_custom_icon'); } @@ -419,7 +426,7 @@ public function downloadButton($download) break; case 4: // Icon only - if ($download->get('download_icon_type') == 1) + if ($download->get('download_icon_type') === '1') { $icon = $download->get('download_custom_icon'); } @@ -432,7 +439,7 @@ public function downloadButton($download) break; } - if ($download->get('simple_mode') == 1 || $download->get('sermonstemplate') == 'easy') + if ($download->get('simple_mode') === '1' || $download->get('sermonstemplate') === 'easy') { $downloadimage = ''; } @@ -466,9 +473,7 @@ public function useJImage($path, $alt) return $alt; } - $imagereturn = '' . $alt . 'attributes . ' >'; - - return $imagereturn; + return '' . $alt . 'attributes . ' >'; } /** @@ -512,10 +517,10 @@ public function getPlayerAttributes($params, $media) * In 6.2.3 we changed inline = 2 */ $player->player = 0; - $item_mediaplayer = $media->params->get('player'); + $item_mediaplayer = (int) $media->params->get('player'); // Check to see if the item player is set to 100 - that means use global settings which comes from $params - if ($item_mediaplayer == 100) + if ($item_mediaplayer === 100) { // Player is set from the $params $player->player = $params->get('media_player', '0'); @@ -523,28 +528,30 @@ public function getPlayerAttributes($params, $media) else { /* - In this case the item has a player set for it, so we use that instead. We also need to change the old player - type of 3 to 2 for all videos reloaded which we don't support */ + * In this case the item has a player set for it, so we use that instead. We also need to change the old player + * type of 3 to 2 for all videos reloaded which we don't support + */ + if ($params->get('pcplaylist')) { $player->player = 7; } elseif ($media->params->get('player', null) !== null) { - $player->player = $media->params->get('player'); + $player->player = (int) $media->params->get('player'); } else { - $player->player = $params->get('player', 0); + $player->player = (int) $params->get('player', 0); } } - if ($player->player == 3) + if ($player->player === 3) { $player->player = 2; } - if ($params->get('docMan_id') != 0) + if ((int) $params->get('docMan_id') !== 0) { $player->player = 4; } @@ -623,13 +630,14 @@ public function getPlayerCode($params, $player, $image, $media) $template = $input->getInt('t', '1'); // Here we get more information about the particular media file - $filesize = self::getFluidFilesize($media, $params); + $filesize = $this->getFluidFilesize($media, $params); $path = JBSMHelper::MediaBuildUrl($media->sparams->get('path'), $params->get('filename'), $params, true); switch ($player->player) { case 0: // Direct + $playercode = ''; switch ($player->type) { @@ -646,18 +654,20 @@ public function getPlayerCode($params, $player, $image, $media) break; case 1: // Popup window - $playercode = "toObject()->player . + $playercode = "toObject()->player . "&view=popup&t=" . $template . "&mediaid=" . $media->id . "&tmpl=component', 'newwindow','width=" . - $player->playerwidth . ",height=" . $player->playerheight . "'); return false\" class=\"jbsmplayerlink\">" . $image . ""; + $player->playerwidth . ",height=" . $player->playerheight . "'); return false\" class=\"jbsmplayerlink\">" + . $image . ""; break; } - /** @var $playercode string */ return $playercode; - break; case 7: case 1: // Internal + $playercode = ''; + switch ($player->type) { case 3: // Squeezebox view @@ -684,13 +694,13 @@ public function getPlayerCode($params, $player, $image, $media) { $playercode = ''; + '" allow="autoplay; encrypted-media" allowfullscreen style="border: none">'; } elseif (preg_match('(vimeo.com)', $path) === 1) { $playercode = ''; + '" webkitallowfullscreen mozallowfullscreen allowfullscreen style="border: none">'; } else { @@ -702,25 +712,27 @@ public function getPlayerCode($params, $player, $image, $media) case 1: // Popup // Add space for popup window $diff = $params->get('player_width') - $params->get('playerwidth'); - $player->playerwidth = $player->playerwidth + abs($diff) + 10; - $player->playerheight = $player->playerheight + $params->get('popupmargin', '50'); - $playercode = "player + $player->playerwidth += abs($diff) + 10; + $player->playerheight += $params->get('popupmargin', '50'); + $playercode = "player . "&view=popup&t=" . $template . "&mediaid=" . $media->id . "&tmpl=component', 'newwindow', 'width=" . $player->playerwidth . ", height=" . $player->playerheight . "'); return false\" class=\"jbsmplayerlink\">" . $image . ""; break; } - /** @var $playercode string */ return $playercode; - break; case 2: // All Videos Reloaded case 3: + $playercode = ''; + switch ($player->type) { case 1: // This goes to the popup view - $playercode = "" . $image . ""; break; @@ -731,36 +743,22 @@ public function getPlayerCode($params, $player, $image, $media) break; } - /** @var $playercode string */ - return $playercode; - break; case 4: // Docman - $playercode = $this->getDocman($media, $image); - - return $playercode; - break; + return $this->getDocman($media, $image); case 5: // Article - $playercode = $this->getArticle($media, $image); - - return $playercode; - break; + return $this->getArticle($media, $image); case 6: // Virtuemart - $playercode = $this->getVirtuemart($media, $image); - - return $playercode; - break; + return $this->getVirtuemart($media, $image); case 8: // Embed code - $playercode = "" . $image . ""; - - return $playercode; - break; } return false; @@ -828,75 +826,70 @@ public function rendersb($media, $params, $player, $image, $path, $direct = fals */ public function getFluidFilesize($media, $params) { - $filesize = ''; + $filesize = 0; // Check to see if we need to look up file size or not. By looking at if download like is set. if ($media->params->get('link_type') === '0') { - $this->fsize = $filesize; + $this->fsize = (int) $filesize; - return $filesize; + return $this->fsize; } - $file_size = $media->params->get('size', '0'); + $file_size = (int) $media->params->get('size', '0'); - if ($file_size == 0) + if ($file_size === 0) { $file_size = JBSMHelper::getRemoteFileSize(JBSMHelper::MediaBuildUrl($media->sparams->get('path'), $params->get('filename'), $params, true)); JBSMHelper::SetFilesize($media->id, $file_size); } - if ($file_size != 0) + if ($file_size !== 0) { switch ($file_size) { case $file_size < 1024 : - $file_size = ' ' . 'Bytes'; + $this->fsize = $file_size; + $file_size .= ' Bytes'; break; case $file_size < 1048576 : - $file_size = $file_size / 1024; + $file_size /= 1024; $file_size = number_format($file_size, 0); - $file_size = $file_size . ' ' . 'KB'; + $this->fsize = $file_size; + $file_size .= ' KB'; break; case $file_size < 1073741824 : - $file_size = $file_size / 1024; - $file_size = $file_size / 1024; + $file_size /= 1024; + $file_size /= 1024; $file_size = number_format($file_size, 1); - $file_size = $file_size . ' ' . 'MB'; + $this->fsize = $file_size; + $file_size .= ' MB'; break; case $file_size > 1073741824 : - $file_size = $file_size / 1024; - $file_size = $file_size / 1024; - $file_size = $file_size / 1024; + $file_size /= 1024; + $file_size /= 1024; + $file_size /= 1024; $file_size = number_format($file_size, 1); - $file_size = $file_size . ' ' . 'GB'; + $this->fsize = $file_size; + $file_size .= ' GB'; break; } switch ($params->get('show_filesize')) { - case 1: - $filesize = $file_size; - break; case 2: - $filesize = $media->comment; + $file_size = $media->comment; break; case 3: if ($media->comment) { - $filesize = $media->comment; - } - else - { - ($filesize = $file_size); + $file_size = $media->comment; } break; } } - $this->fsize = $filesize; - - return $filesize; + return $file_size; } /** @@ -905,9 +898,10 @@ public function getFluidFilesize($media, $params) * @param Object $row Table Row info * @param Joomla\Registry\Registry $params Params * - * @return null|string + * @return void * * @since 9.0.0 + * @deprecate 9.2.7 */ public function getFluidDuration($row, $params) { @@ -987,10 +981,8 @@ public function getMediaRows2($id) return $media; } - else - { - return false; - } + + return false; } /** @@ -1077,11 +1069,10 @@ public function getArticle($media, $image) */ public function getVirtuemart($media, $image) { - $vm = '' . $image . ''; - - return $vm; } /** @@ -1244,7 +1235,7 @@ public function convertVimeo($string) */ public function getIcons() { - $icons = [ + return [ 'JBS_MED_PLAY' => 'fas fa-play', 'JBS_MED_YOUTUBE' => 'fab fa-youtube', 'JBS_MED_VIDEO' => 'fas fa-video', @@ -1254,7 +1245,5 @@ public function getIcons() 'JBS_MED_VIMEO' => 'fab fa-vimeo', 'JBS_MED_CUSTOM' => '1' ]; - - return $icons; } } diff --git a/site/helpers/relatedstudies.php b/site/helpers/relatedstudies.php index 7771fdef53..b0886461b9 100644 --- a/site/helpers/relatedstudies.php +++ b/site/helpers/relatedstudies.php @@ -19,11 +19,14 @@ */ class JBSMRelatedStudies { - /** @var array Score + /** + * Remove array declaration for php 7.3.x + * + * @var array Score * * @since 7.2 */ - public array $score; + public $score; /** * Get Related @@ -70,7 +73,7 @@ public function getRelated(object $row, Registry $params) $studies = $this->getStudies(); - if (!empty($studies)) + if ($studies !== null) { foreach ($studies as $study) { @@ -979,6 +982,7 @@ public function getRelatedLinks() $related .= ' - ' . JText::_($studyrecord->bookname) . ' ' . $studyrecord->chapter_begin; } + $related .= ''; } diff --git a/site/helpers/route.php b/site/helpers/route.php index 0aafcbae21..b0ecc8e415 100644 --- a/site/helpers/route.php +++ b/site/helpers/route.php @@ -99,7 +99,7 @@ protected static function _findItem($needles = null) { self::$lookup = array(); - $component = JComponentHelper::getComponent('com_content'); + $component = JComponentHelper::getComponent('com_biblestudy'); $items = $menus->getItems('component_id', $component->id); foreach ($items as $item) @@ -141,7 +141,7 @@ protected static function _findItem($needles = null) { $active = $menus->getActive(); - if ($active && $active->component == 'com_content') + if ($active && $active->component == 'com_biblestudy') { return $active->id; } diff --git a/site/lib/listing.php b/site/lib/listing.php index ad44000e1e..2ec618ea2a 100644 --- a/site/lib/listing.php +++ b/site/lib/listing.php @@ -2143,7 +2143,7 @@ public function getScripture(Registry $params, $row, int $esv, int $scripturerow $v_e = ''; } - if ($v_b === '0') + if (empty($v_b) || $v_b === '0') { $v_b = ''; $v_e = ''; @@ -2151,13 +2151,13 @@ public function getScripture(Registry $params, $row, int $esv, int $scripturerow $b2 = ''; } - if ($v_e === '0') + if (empty($v_e) || $v_e === '0') { $v_e = ''; $b2a = ''; } - if ($ch_e === '0') + if (empty($ch_e) || $ch_e === '0') { $b2a = ''; $ch_e = ''; @@ -2197,7 +2197,7 @@ public function getScripture(Registry $params, $row, int $esv, int $scripturerow $b2a = ''; } - if ($v_b === '0') + if (empty($v_b) || $v_b === '0') { $v_b = ''; $v_e = ''; @@ -2205,18 +2205,18 @@ public function getScripture(Registry $params, $row, int $esv, int $scripturerow $b2 = ''; } - if ($v_e === '0') + if (empty($v_e) || $v_e === '0') { $v_e = ''; $b2a = ''; } - if ($ch_e === '0') + if (empty($ch_e) || $ch_e === '0') { $b2a = ''; $ch_e = ''; - if ($v_e === '0') + if (empty($v_e) || $v_e === '0') { $b3 = ''; } diff --git a/site/lib/podcast.php b/site/lib/podcast.php index 51b36a07ce..6947b8d08c 100644 --- a/site/lib/podcast.php +++ b/site/lib/podcast.php @@ -31,9 +31,18 @@ */ class JBSMPodcast { - private $templateid = 0; + /** + * @var int + * @since version + */ + private int $templateid = 0; + /** + * @var null + * @since version + */ private $template = null; + /** * @var string * @since version @@ -117,8 +126,6 @@ public function makePodcasts() $params = $registry; $params->set('show_verses', '1'); $protocol = $params->get('protocol', 'http://'); - - $description = $this->escapeHTML($podinfo->description); $detailstemplateid = $podinfo->detailstemplateid; if (!$detailstemplateid) @@ -126,40 +133,54 @@ public function makePodcasts() $detailstemplateid = 1; } - $detailstemplateid = '&t=' . $detailstemplateid; + if (empty($podinfo->podcastlink)) + { + $podinfo->podcastlink = $podinfo->website; + } + + if (!isset($podinfo->subtitle)) + { + $podinfo->subtitle = $podinfo->title; + } + $podhead = ' + Proclaim ' . $this->escapeHTML($podinfo->title) . ' - ' . $protocol . $podinfo->website . ' + ' . $protocol . $podinfo->podcastlink . ' + + ' . $protocol . $podinfo->website . '/' . $podinfo->podcastimage . ' + ' . $this->escapeHTML($podinfo->title) . ' + ' . $protocol . $podinfo->podcastlink . ' + + + ' . $this->escapeHTML($podinfo->description) . ' + ' . $podlanguage . ' + episodic © ' . $year . ' All rights reserved. - ' . $this->escapeHTML($podinfo->title) . ' + + ' . $date . ' + + ' . $this->escapeHTML($podinfo->description) . ' + + ' . $this->escapeHTML($podinfo->subtitle) . ' ' . $this->escapeHTML($podinfo->editor_name) . ' - ' . $this->escapeHTML($podinfo->description) . ' - ' . $this->escapeHTML($description) . ' ' . $this->escapeHTML($podinfo->editor_name) . ' ' . $podinfo->editor_email . ' - Religion &amp; Spirituality no ' . $date . ' - ' . $date . ' - Proclaim ' . $podinfo->editor_email . ' (' . $this->escapeHTML($podinfo->editor_name) . ') ' . $podinfo->editor_email . ' (' . $this->escapeHTML($podinfo->editor_name) . ') - - no - ' . $podinfo->podcastsearch . ' - episodic - 1 - '; + ' . $podinfo->podcastsearch . ''; if (!$episodes) @@ -247,7 +268,7 @@ public function makePodcasts() if ($this->templateid !== $detailstemplateid || is_null($this->template)) { $this->template = JBSMParams::getTemplateparams($detailstemplateid); - $this->templateid = $detailstemplateid; + $this->templateid = (int) $detailstemplateid; } $element = $JBSMlisting->getFluidCustom( @@ -262,7 +283,7 @@ public function makePodcasts() break; case 6: $query = $db->getQuery('true'); - $query->select('*'); + $query->select(' * '); $query->from('#__bsms_books'); $query->where('booknumber = ' . $episode->booknumber); $db->setQuery($query); @@ -328,7 +349,7 @@ public function makePodcasts() if ($this->templateid !== $detailstemplateid || is_null($this->template)) { $this->template = JBSMParams::getTemplateparams($detailstemplateid); - $this->templateid = $detailstemplateid; + $this->templateid = (int) $detailstemplateid; } $element = $JBSMlisting->getFluidCustom( @@ -336,7 +357,7 @@ public function makePodcasts() $episode, $params, $this->template, - $rowid = '24' + 'podcast' ); $subtitle = $element; @@ -344,7 +365,6 @@ public function makePodcasts() } $title = $this->escapeHTML($title); - $description = $this->escapeHTML($episode->studyintro); $episodedetailtemp = ' @@ -353,6 +373,9 @@ public function makePodcasts() $file = str_replace(' ', "%20", $episode->params->get('filename')); $path = JBSMHelper::MediaBuildUrl($episode->srparams->get('path'), $file, $params, false, false, true); + // Add router helpers. + $episode->slug = $episode->alias ? ($episode->id . ':' . $episode->alias) : $episode->id; + /* * Default is to episode * 1 = Direct Link. @@ -364,42 +387,39 @@ public function makePodcasts() } elseif ($podinfo->linktype == '2') { - $episodedetailtemp .= '' . $protocol . $podinfo->website . '/index.php?option=com_biblestudy&view=popup&player=1&id=' . - $episode->sid . $detailstemplateid . ''; + $episodedetailtemp .= '' . $protocol . $podinfo->website . '/index.php?option=com_biblestudy&view=popup&player=1&id=' . + $episode->slug . '&t=' . $detailstemplateid . ''; } else { $episodedetailtemp .= '' . $protocol . $podinfo->website . '/index.php?option=com_biblestudy&view=sermon&id=' - . $episode->sid . $detailstemplateid . ''; + . $episode->slug . '&t=' . $detailstemplateid . ''; } // Make a duration build from Params of media. - $prefix = JUri::root(); - $FullUrl = $protocol . $path; - - if (strpos($FullUrl, $prefix) === 0) + if (($params->toObject()->media_hours !== '00' && !empty($params->toObject()->media_hours)) + && ($params->toObject()->media_minutes !== '00' && !empty($params->toObject()->media_minutes)) + && ($params->toObject()->media_seconds !== '00' && !empty($params->toObject()->media_seconds)) + ) { - $this->filename = substr($FullUrl, strlen($prefix)); - $this->filename = JPATH_SITE . '/' . $this->filename; - $duration = $this->formatTime($this->getDuration()); + $duration = $episode->params->get('media_hours') . ':' . + $episode->params->get('media_minutes') . + ':' . $episode->params->get('media_seconds'); } else { - $duration = $episode->params->get('media_hours', '00') . ':' . - $episode->params->get('media_minutes', '00') . - ':' . $episode->params->get('media_seconds', '00'); + $duration = ''; } $episodedetailtemp .= '' . $protocol . $podinfo->website . '/index.php?option=com_biblestudy&view=sermon&id=' - . $episode->sid . $detailstemplateid . ' + . $episode->slug . '&t=' . $detailstemplateid . ' ' . $this->escapeHTML($episode->teachername) . ' ' . $this->escapeHTML($episode->teachername) . ' - - ' . $this->escapeHTML($description) . ' - + ' . $this->escapeHTML($episode->studyintro) . ' + studyintro . ']]> ' . $episodedate . ' ' . $this->escapeHTML($subtitle) . ' - ' . $this->escapeHTML($description) . ' + studyintro . ']]> ' . $podinfo->podcastsearch . ' ' . $duration . ''; @@ -506,11 +526,9 @@ protected function escapeHTML(?string $string) return $string; } - $string = mb_convert_encoding($string, "UTF-8", "HTML-ENTITIES"); $string = strip_tags($string); - $string = htmlspecialchars($string, ENT_XML1 | ENT_QUOTES, "UTF-8"); - return $string; + return htmlspecialchars($string, ENT_DISALLOWED, "UTF-8"); } /** @@ -526,7 +544,13 @@ protected function escapeHTML(?string $string) public function getEpisodes(int $id, string $limit) { preg_match_all('!\d+!', $limit, $set_limit); - $set_limit = implode(' ', $set_limit[0]); + $set_limit = (int) implode(' ', $set_limit[0]); + + // This is set do to the hard limit of Apple max episodes. + if ($set_limit >= 301) + { + $set_limit = 300; + } // Here's where we look at each mediafile to see if they are connected to this podcast $db = JFactory::getDbo(); @@ -536,7 +560,7 @@ public function getEpisodes(int $id, string $limit) . ' mf.published AS mfpub, mf.createdate, mf.params,' . ' s.id AS sid, s.studydate, s.teacher_id, s.booknumber, s.chapter_begin, s.verse_begin,' . ' s.chapter_end, s.verse_end, s.studytitle, s.studyintro, s.published AS spub,' - . ' se.series_text,' + . ' se.series_text, se.published,' . ' sr.id AS srid, sr.params as srparams,' . ' t.id AS tid, t.teachername,' . ' b.id AS bid, b.booknumber AS bnumber, b.bookname') @@ -549,6 +573,8 @@ public function getEpisodes(int $id, string $limit) ->leftJoin('#__bsms_podcast AS p ON (p.id = mf.podcast_id)') ->where('mf.podcast_id LIKE ' . $db->q('%' . $id . '%')) ->where('mf.published = ' . 1) + ->where('s.published = ' . 1) + ->where('(se.published = ' . 1 . ' OR s.series_id = ' . -1 . ')') ->order('createdate desc'); $db->setQuery($query, 0, $set_limit); @@ -589,81 +615,71 @@ public function getEpisodes(int $id, string $limit) * @throws Exception * @since 7.0.0 */ - public function writeFile($file, $filecontent) + public function writeFile(string $file, string $filecontent) { // Set FTP credentials, if given - $files[] = $file; - $podcastresults = ''; jimport('joomla.client.helper'); jimport('joomla.filesystem.file'); JClientHelper::setCredentialsFromRequest('ftp'); $ftp = JClientHelper::getCredentials('ftp'); // Try to make the template file writable - if (JFile::exists($file) && !$ftp['enabled'] && !JPath::setPermissions($file, '0755')) + if (!$ftp['enabled'] && JFile::exists($file) && !JPath::setPermissions($file, '0755')) { JFactory::getApplication()->enqueueMessage('Could not make the file writable', 'notice'); } - $fileit = JFile::write($file, $filecontent); + $fileIt = JFile::write($file, $filecontent); - if ($fileit) - { - return true; - } - - if (!$fileit) - { - $app = JFactory::getApplication(); - $app->enqueueMessage('Could not make the file unwritable', 'notice'); - - return false; - } - // Try to make the template file unwriteable - if (!$ftp['enabled'] && !JPath::setPermissions($file, '0555')) + // Try to make the template file un-writeable + // @todo not sure what we are doing here but looks like we need to rework this. + if (!$fileIt || (!$ftp['enabled'] && !JPath::setPermissions($file, '0555'))) { JFactory::getApplication() - ->enqueueMessage('Could not make the file unwritable', 'notice'); + ->enqueueMessage('Could not make the file un-writable', 'notice'); return false; } - return $podcastresults; + return true; } /** - * @param $duration + * Brake out time from seconds to (Array of hours, minutes, seconds). * - * @return string + * @param int $duration Time in seconds * - * @since version + * @return object Returns hours, minutes, seconds + * + * @since 9.2.4 */ - public function formatTime($duration) //as hh:mm:ss + public function formatTime(int $duration): object //as hh:mm:ss { - $hours = floor($duration / 3600); - $minutes = floor(($duration - ($hours * 3600)) / 60); - $seconds = $duration - ($hours * 3600) - ($minutes * 60); + $time = new StdClass(); + $time->hours = floor($duration / 3600); + $time->minutes = floor(($duration - ($time->hours * 3600)) / 60); + $time->seconds = $duration - ($time->hours * 3600) - ($time->minutes * 60); - return sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds); + return $time; } /** * Read entire file, frame by frame... ie: Variable Bit Rate (VBR) * - * @param false $use_cbr_estimate True: Use CBR to Estimate, False: Will ignore, + * @param string $filename File name of media. * - * @return float|int + * @return int * * @since 9.2.4 */ - public function getDuration($use_cbr_estimate = false) + public function getDuration(string $filename) { - $fd = fopen($this->filename, "rb"); + $fd = fopen($filename, 'rb'); $duration = 0; $block = fread($fd, 100); $offset = $this->skipID3v2Tag($block); - fseek($fd, $offset, SEEK_SET); + @fseek($fd, $offset, SEEK_SET); while (!feof($fd)) { $block = fread($fd, 10); @@ -676,68 +692,73 @@ public function getDuration($use_cbr_estimate = false) if ($block[0] === "\xff" && (ord($block[1]) & 0xe0)) { $info = $this->parseFrameHeader(substr($block, 0, 4)); + if (empty($info['Framesize'])) { - return $duration; + return (int) $duration; } //some corrupt mp3 files fseek($fd, $info['Framesize'] - 10, SEEK_CUR); $duration += ($info['Samples'] / $info['Sampling Rate']); } - else if (substr($block, 0, 3) === 'TAG') + else if (strpos($block, 'TAG') === 0) { fseek($fd, 128 - 10, SEEK_CUR);//skip over id3v1 tag size } else { - fseek($fd, -9, SEEK_CUR); - } - - if ($use_cbr_estimate && !empty($info)) - { - return $this->estimateDuration($info['Bitrate'], $offset); + @fseek($fd, -9, SEEK_CUR); } } - return $duration; + return (int) $duration; } /** - * Estimate Duration - * - * @param integer $bitrate Bitrate - * @param integer $offset Offset + * @param string $url * - * @return float + * @return string * - * @since 9.2.4 + * @since version */ - public function estimateDuration($bitrate, $offset) + public function remove_http(string $url): string { - $kbps = ($bitrate * 1000) / 8; - $datasize = filesize($this->filename) - $offset; + $disallowed = array('http://', 'https://'); + foreach ($disallowed as $d) + { + if (strpos($url, $d) === 0) + { + return str_replace($d, '', $url); + } + } - return round($datasize / $kbps); + return $url; } /** * Skip ID3v2 Tags * - * @param array $block ID3 info block + * @param array|string $block ID3 info block * - * @return float|int + * @return int * * @since 9.2.4 */ public function skipID3v2Tag(&$block) { - if (substr($block, 0, 3) === "ID3") + // Do not worry about string vs array work right. + if (strpos($block, "ID3") === 0) { - $id3v2_flags = ord($block[5]); - $flag_footer_present = ($id3v2_flags & 0x10) ? 1 : 0; - $z0 = ord($block[6]); - $z1 = ord($block[7]); - $z2 = ord($block[8]); - $z3 = ord($block[9]); + $id3v2_major_version = ord($block[3]); + $id3v2_minor_version = ord($block[4]); + $id3v2_flags = ord($block[5]); + $flag_unsynchronisation = $id3v2_flags & 0x80 ? 1 : 0; + $flag_extended_header = $id3v2_flags & 0x40 ? 1 : 0; + $flag_experimental_ind = $id3v2_flags & 0x20 ? 1 : 0; + $flag_footer_present = $id3v2_flags & 0x10 ? 1 : 0; + $z0 = ord($block[6]); + $z1 = ord($block[7]); + $z2 = ord($block[8]); + $z3 = ord($block[9]); if ((($z0 & 0x80) === 0) && (($z1 & 0x80) === 0) && (($z2 & 0x80) === 0) && (($z3 & 0x80) === 0)) { $header_size = 10; @@ -752,13 +773,15 @@ public function skipID3v2Tag(&$block) } /** - * @param array $fourbytes array with four bytes + * Get Frame Header of the ID3 file + * + * @param array|string $fourbytes array with four bytes * * @return array * * @since 9.2.4 */ - public function parseFrameHeader($fourbytes) + public function parseFrameHeader($fourbytes): array { static $versions = array( 0x0 => '2.5', 0x1 => 'x', 0x2 => '2', 0x3 => '1', // x=>'reserved' @@ -793,15 +816,15 @@ public function parseFrameHeader($fourbytes) $simple_version = ($version === '2.5' ? 2 : $version); $layer_bits = ($b1 & 0x06) >> 1; - $layer = $layers[$layer_bits]; + $layer = (int) $layers[$layer_bits]; $protection_bit = ($b1 & 0x01); $bitrate_key = sprintf('V%dL%d', $simple_version, $layer); $bitrate_idx = ($b2 & 0xf0) >> 4; - $bitrate = isset($bitrates[$bitrate_key][$bitrate_idx]) ? $bitrates[$bitrate_key][$bitrate_idx] : 0; + $bitrate = $bitrates[$bitrate_key][$bitrate_idx] ?? 0; $sample_rate_idx = ($b2 & 0x0c) >> 2;//0xc => b1100 - $sample_rate = isset($sample_rates[$version][$sample_rate_idx]) ? $sample_rates[$version][$sample_rate_idx] : 0; + $sample_rate = $sample_rates[$version][$sample_rate_idx] ?? 0; $padding_bit = ($b2 & 0x02) >> 1; $private_bit = ($b2 & 0x01); $channel_mode_bits = ($b3 & 0xc0) >> 6; @@ -824,7 +847,7 @@ public function parseFrameHeader($fourbytes) /** * Frame size setup * - * @param string $layer Layer + * @param integer $layer Layer * @param integer $bitrate Bit Rate * @param integer $sample_rate Sample rate * @param integer $padding_bit Padding @@ -833,7 +856,7 @@ public function parseFrameHeader($fourbytes) * * @since 9.2.4 */ - public function framesize($layer, $bitrate, $sample_rate, $padding_bit) + public function frameSize(int $layer, int $bitrate, int $sample_rate, int $padding_bit): int { if ($layer === 1) { diff --git a/site/views/sermon/view.html.php b/site/views/sermon/view.html.php index 5e8e17d296..636b4a4531 100644 --- a/site/views/sermon/view.html.php +++ b/site/views/sermon/view.html.php @@ -71,7 +71,7 @@ class BiblestudyViewSermon extends JViewLegacy */ protected $subscribe; - /** @var int Menu ID + /** @var integer Menu ID * * @since 7.0 */ @@ -284,8 +284,8 @@ public function display($tpl = null) JHtml::_('biblestudy.framework'); JHtml::_('biblestudy.loadCss', $this->params, null, 'font-awesome'); - // Only load pagebuilder if the default template is NOT being used - if ($this->item->params->get('useexpert_details') > 0 || is_string($this->params->get('sermontemplate'))) + // Only load page builder if the default template is NOT being used + if ($this->item->params->get('useexpert_details', '0') !== '0' || $this->params->get('sermontemplate', '0') !== '0') { $pagebuilder = new JBSMPageBuilder; $pelements = $pagebuilder->buildPage($this->item, $this->item->params, $template); diff --git a/site/views/sermons/tmpl/default_main.php b/site/views/sermons/tmpl/default_main.php index f305e19f5b..c26f331034 100644 --- a/site/views/sermons/tmpl/default_main.php +++ b/site/views/sermons/tmpl/default_main.php @@ -22,24 +22,22 @@ ?>
    -
    +
    params->get('showpodcastsubscribelist') == 1) + if ($this->params->get('showpodcastsubscribelist') === '1') { echo $this->subscribe; } ?> -
    +
    params->get('intro_show') > 0) { - ?> -
    - params->get('listteachers') && $this->params->get('list_teacher_show') > 0) - { - ?> -
    -
      + if ($this->params->get('listteachers') && $this->params->get('list_teacher_show') > 0) + { + ?> +
      '; +
      +
        params->get('teacherlink') > 0) { echo ' - '; + Teachers Image'; } else { @@ -65,35 +63,23 @@ echo ''; } ?> -
      -
      - -
      -
      - params->get('show_page_image') > 0) - { - ?> - - params->get('show_page_title') == 1) - { ?> - < style="params->get('list_title_align'); ?> - "> - params->get('list_page_title'); ?> - > +
    +
    +
    + +
    +
    params->get('list_intro')) + if (!empty($this->params->get('list_intro'))) { ?> -

    +

    params->get('list_intro'); ?> -

    +

    -
    -
    +
    +
  • @@ -102,7 +88,7 @@ // Search tools bar echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?> -
    +
    items) { @@ -111,22 +97,21 @@ ?> items)) : ?> - params->def('show_pagination', 2) == 1 - || ($this->params->get('show_pagination') == 2)) - && ($this->pagination->pagesTotal > 1)) : ?> - params->get('showpodcastsubscribelist') == 2) + if ($this->params->get('showpodcastsubscribelist') === '2') { echo $this->subscribe; } diff --git a/tests/test.html b/tests/test.html index 503ce173cd..378810f2b0 100644 --- a/tests/test.html +++ b/tests/test.html @@ -1 +1,6 @@ -application/annodex,application/mp4,application/ogg,application/vnd.rn-realmedia,application/x-matroska,video/3gpp,video/3gpp2,video/annodex,video/divx,video/flv,video/h264,video/mp4,video/mp4v-es,video/mpeg,video/mpeg-2,video/mpeg4,video/ogg,video/ogm,video/quicktime,video/ty,video/vdo,video/vivo,video/vnd.rn-realvideo,video/vnd.vivo,video/webm,video/x-bin,video/x-cdg,video/x-divx,video/x-dv,video/x-flv,video/x-la-asf,video/x-m4v,video/x-matroska,video/x-motion-jpeg,video/x-ms-asf,video/x-ms-dvr,video/x-ms-wm,video/x-ms-wmv,video/x-msvideo,video/x-sgi-movie,video/x-tivo,video/avi,video/x-ms-asx,video/x-ms-wvx,video/x-ms-wmx, \ No newline at end of file +application/annodex,application/mp4,application/ogg,application/vnd.rn-realmedia,application/x-matroska,video/3gpp,video/3gpp2,video/annodex,video/divx,video/flv,video/h264,video/mp4,video/mp4v-es,video/mpeg,video/mpeg-2,video/mpeg4,video/ogg,video/ogm,video/quicktime,video/ty,video/vdo,video/vivo,video/vnd.rn-realvideo,video/vnd.vivo,video/webm,video/x-bin,video/x-cdg,video/x-divx,video/x-dv,video/x-flv,video/x-la-asf,video/x-m4v,video/x-matroska,video/x-motion-jpeg,video/x-ms-asf,video/x-ms-dvr,video/x-ms-wm,video/x-ms-wmv,video/x-msvideo,video/x-sgi-movie,video/x-tivo,video/avi,video/x-ms-asx,video/x-ms-wvx,video/x-ms-wmx, + +SELECT CONCAT('ALTER TABLE ',TABLE_NAME,' ENGINE=InnoDB;') +FROM INFORMATION_SCHEMA.TABLES +WHERE ENGINE='MyISAM' +AND table_schema = 'mydb'; \ No newline at end of file