diff --git a/bundle.js b/bundle.js index 3995b6a30..e74ee9ac3 100644 --- a/bundle.js +++ b/bundle.js @@ -1,5 +1,5 @@ /** - * @license almond 0.2.9 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved. + * @license almond 0.3.0 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/jrburke/almond for details */ @@ -150,7 +150,15 @@ var requirejs, require, define; //A version of a require function that passes a moduleName //value for items that may need to //look up paths relative to the moduleName - return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync])); + var args = aps.call(arguments, 0); + + //If first arg is not require('string'), and there is only + //one arg, it is the array form without a callback. Insert + //a null so that the following concat is correct. + if (typeof args[0] !== 'string' && args.length === 1) { + args.push(null); + } + return req.apply(undef, args.concat([relName, forceSync])); }; } @@ -10095,10 +10103,11 @@ if ( typeof define === "function" && define.amd && define.amd.jQuery ) { writer=w; } - if (window.console && window.console.log && window.console.log.apply!==undefined) - setWriter(new ConsoleWriter()); - else + if (!window.console || !window.console.log || typeof window.console.log.apply !== "function") { setWriter(new IEConsoleWriter()); + } else { + setWriter(new ConsoleWriter()); + } root=new Logger(); @@ -10151,29 +10160,76 @@ define('pat-logger',[ define('pat-utils',[ "jquery" ], function($) { - var jquery_plugin = function(pattern) { - var plugin = function(method) { - var $this = this; - if ($this.length === 0) - return $this; - if (!method || typeof method === "object") { - pattern.init.apply( - $this, - [$this].concat(Array.prototype.slice.call(arguments))); - } else if (pattern[method]) { - return pattern[method].apply( - $this, - [$this].concat(Array.prototype.slice.call(arguments, 1)) - ); + + var singleBoundJQueryPlugin = function (pattern, method, options) { + /* This is a jQuery plugin for patterns which are invoked ONCE FOR EACH + * matched element in the DOM. + * + * This is how the Mockup-type patterns behave. They are constructor + * functions which need to be invoked once per jQuery-wrapped DOM node + * for all DOM nodes on which the pattern applies. + */ + var $this = this; + $this.each(function() { + var pat, $el = $(this); + pat = pattern.init($el, options); + if (method) { + if (pat[method] === undefined) { + $.error("Method " + method + + " does not exist on jQuery." + pattern.name); + return false; + } + if (method.charAt(0) === '_') { + $.error("Method " + method + + " is private on jQuery." + pattern.name); + return false; + } + pat[method].apply(pat, [options]); + } + }); + return $this; + }; + + var pluralBoundJQueryPlugin = function (pattern, method, options) { + /* This is a jQuery plugin for patterns which are invoked ONCE FOR ALL + * matched elements in the DOM. + * + * This is how the vanilla Patternslib-type patterns behave. They are + * simple objects with an init method and this method gets called once + * with a list of jQuery-wrapped DOM nodes on which the pattern + * applies. + */ + var $this = this; + if (method) { + if (pattern[method]) { + return pattern[method].apply($this, [$this].concat([options])); } else { $.error("Method " + method + " does not exist on jQuery." + pattern.name); } - return $this; - }; - return plugin; + } else { + pattern.init.apply($this, [$this].concat([options])); + } + return $this; }; + var jqueryPlugin = function(pattern) { + return function(method, options) { + var $this = this; + if ($this.length === 0) { + return $this; + } + if (typeof method === 'object') { + options = method; + method = undefined; + } + if (typeof pattern === "function") { + return singleBoundJQueryPlugin.call(this, pattern, method, options); + } else { + return pluralBoundJQueryPlugin.call(this, pattern, method, options); + } + }; + }; // Underscore.js 1.3.1 // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. @@ -10353,7 +10409,7 @@ define('pat-utils',[ var utils = { // pattern pimping - own module? - jquery_plugin: jquery_plugin, + jqueryPlugin: jqueryPlugin, debounce: debounce, escapeRegExp: escapeRegExp, isObject: isObject, @@ -11156,8 +11212,7 @@ define('pat-registry',[ "pat-compat", "pat-jquery-ext" ], function($, logger, utils) { - var log = logger.getLogger("registry"), - jquery_plugin = utils.jquery_plugin; + var log = logger.getLogger("registry"); var disable_re = /patterns-disable=([^&]+)/g, dont_catch_re = /patterns-dont-catch/g, @@ -11190,13 +11245,12 @@ define('pat-registry',[ }); }, - scan: function registry_scan(content, patterns, trigger, do_not_catch_init_exception) { + scan: function registry_scan(content, patterns, trigger) { var $content = $(content), all = [], allsel, - pattern, $match, plog; + $match, plog; - // If no list of patterns was specified, we scan for all - // patterns + // If no list of patterns was specified, we scan for all patterns patterns = patterns || Object.keys(registry.patterns); // selector for all patterns @@ -11205,57 +11259,40 @@ define('pat-registry',[ log.debug('Skipping disabled pattern:', name); return; } - pattern = registry.patterns[name]; + var pattern = registry.patterns[name]; if (pattern.transform) { - if (do_not_catch_init_exception || dont_catch) { + try { pattern.transform($content); - } else { - try { - pattern.transform($content); - } catch (e) { - log.error("Transform error for pattern" + name, e); - } + } catch (e) { + if (dont_catch) { throw(e); } + log.error("Transform error for pattern" + name, e); } } if (pattern.trigger) { all.push(pattern.trigger); } }); - allsel = all.join(","); - // Find all elements that belong to any pattern. + allsel = all.join(","); $match = $content.findInclusive(allsel); $match = $match.filter(function() { return $(this).parents('pre').length === 0; }); $match = $match.filter(":not(.cant-touch-this)"); // walk list backwards and initialize patterns inside-out. - // - // XXX: If patterns would only trigger via classes, we - // could iterate over an element classes and trigger - // patterns in order. - // - // Advantages: Order of pattern initialization controled - // via order of pat-classes and more efficient. $match.toArray().reduceRight(function registry_pattern_init(acc, el) { - var $el = $(el); - + var pattern, $el = $(el); for (var name in registry.patterns) { pattern = registry.patterns[name]; if (pattern.init) { plog = logger.getLogger("pat." + name); - if ($el.is(pattern.trigger)) { plog.debug("Initialising:", $el); - if (do_not_catch_init_exception || dont_catch) { + try { pattern.init($el, null, trigger); plog.debug("done."); - } else { - try { - pattern.init($el, null, trigger); - plog.debug("done."); - } catch (e) { - plog.error("Caught error:", e); - } + } catch (e) { + if (dont_catch) { throw(e); } + plog.error("Caught error:", e); } } } @@ -11263,37 +11300,34 @@ define('pat-registry',[ }, null); }, - // XXX: differentiate between internal and custom patterns - // _register vs register - register: function registry_register(pattern) { - if (!pattern.name) { - log.error("Pattern lacks name:", pattern); + register: function registry_register(pattern, name) { + var plugin_name, jquery_plugin; + name = name || pattern.name; + if (!name) { + log.error("Pattern lacks a name:", pattern); return false; } - - if (registry.patterns[pattern.name]) { - log.error("Already have a pattern called: " + pattern.name); + if (registry.patterns[name]) { + log.error("Already have a pattern called: " + name); return false; } // register pattern to be used for scanning new content - registry.patterns[pattern.name] = pattern; + registry.patterns[name] = pattern; // register pattern as jquery plugin if (pattern.jquery_plugin) { - var pluginName = ("pat-" + pattern.name) + plugin_name = ("pat-" + name) .replace(/-([a-zA-Z])/g, function(match, p1) { return p1.toUpperCase(); }); - $.fn[pluginName] = jquery_plugin(pattern); - // BBB 2012-12-10 - $.fn[pluginName.replace(/^pat/, "pattern")] = jquery_plugin(pattern); + $.fn[plugin_name] = utils.jqueryPlugin(pattern); + // BBB 2012-12-10 and also for Mockup patterns. + $.fn[plugin_name.replace(/^pat/, "pattern")] = utils.jqueryPlugin(pattern); } - - log.debug("Registered pattern:", pattern.name, pattern); - + log.debug("Registered pattern:", name, pattern); if (registry.initialized) { - registry.scan(document.body, [pattern.name], undefined, false); + registry.scan(document.body, [name]); } return true; } @@ -11310,40170 +11344,15102 @@ define('pat-registry',[ // jshint indent: 4, browser: true, jquery: true, quotmark: double // vim: sw=4 expandtab ; -/** - * Patterns parser - Argument parser - * - * Copyright 2012-2013 Florian Friesdorf - * Copyright 2012-2013 Simplon B.V. - Wichert Akkerman - */ -define('pat-parser',[ - "jquery", - "pat-logger" -], function($, logger) { - function ArgumentParser(name, opts) { - opts = opts || {}; - this.order = []; - this.parameters = {}; - this.attribute = "data-pat-" + name; - this.enum_values = {}; - this.enum_conflicts = []; - this.groups = {}; - this.possible_groups = {}; - this.log = logger.getLogger(name + ".parser"); - } - - ArgumentParser.prototype = { - group_pattern: /([a-z][a-z0-9]*)-([A-Z][a-z0-0\-]*)/i, - named_param_pattern: /^\s*([a-z][a-z0-9\-]*)\s*:(.*)/i, - token_pattern: /((["']).*?(?!\\)\2)|\s*(\S+)\s*/g, +/*! + * LESS - Leaner CSS v1.6.2 + * http://lesscss.org + * + * Copyright (c) 2009-2014, Alexis Sellier + * Licensed under the Apache v2 License. + * + */ - _camelCase: function(str) { - return str.replace(/\-([a-z])/g, function(_, p1){ - return p1.toUpperCase(); - }); - }, + /** * @license Apache v2 + */ - add_argument: function ArgumentParser_add_argument(name, default_value, choices, multiple) { - var spec, m; - if (multiple && !Array.isArray(default_value)) - default_value=[default_value]; - spec={name: name, - value: default_value, - multiple: multiple, - dest: name, - group: null}; - if (choices && Array.isArray(choices) && choices.length) { - spec.choices=choices; - spec.type=this._typeof(choices[0]); - for (var i=0; i currentPos) { + current = current.slice(i - currentPos); + currentPos = i; + } + } + function isWhitespace(str, pos) { + var code = str.charCodeAt(pos | 0); + return (code <= 32) && (code === 32 || code === 10 || code === 9); + } + // + // Parse from a token, regexp or string, and move forward if match + // + function $(tok) { + var tokType = typeof tok, + match, length; - i++; - if (i>=this.order.length) - break; + // Either match a single character in the input, + // or match a regexp in the current chunk (`current`). + // + if (tokType === "string") { + if (input.charAt(i) !== tok) { + return null; } - if (parts.length) - this.log.warn("Ignore extra arguments: " + parts.join(" ")); - return opts; - }, - - _parse: function ArgumentParser_parse(parameter) { - var opts, extended, sep; + skipWhitespace(1); + return tok; + } - if (!parameter) - return {}; + // regexp + sync (); + if (! (match = tok.exec(current))) { + return null; + } - if (parameter.match(this.named_param_pattern)) - return this._parseExtendedNotation(parameter); + length = match[0].length; - sep=parameter.indexOf(";"); - if (sep===-1) - return this._parseShorthandNotation(parameter); + // The match is confirmed, add the match length to `i`, + // and consume any extra white-space characters (' ' || '\n') + // which come after that. The reason for this is that LeSS's + // grammar is mostly white-space insensitive. + // + skipWhitespace(length); - opts=this._parseShorthandNotation(parameter.slice(0, sep)); - extended=this._parseExtendedNotation(parameter.slice(sep+1)); - for (var name in extended) - opts[name]=extended[name]; - return opts; - }, + if(typeof(match) === 'string') { + return match; + } else { + return match.length === 1 ? match[0] : match; + } + } - _defaults: function ArgumentParser_defaults($el) { - var result = {}; - for (var name in this.parameters) - if (typeof this.parameters[name].value==="function") - try { - result[name]=this.parameters[name].value($el, name); - this.parameters[name].type=typeof result[name]; - } catch(e) { - this.log.error("Default function for " + name + " failed."); - } - else - result[name]=this.parameters[name].value; - return result; - }, + // Specialization of $(tok) + function $re(tok) { + if (i > currentPos) { + current = current.slice(i - currentPos); + currentPos = i; + } + var m = tok.exec(current); + if (!m) { + return null; + } - _cleanupOptions: function ArgumentParser_cleanupOptions(options) { - var keys = Object.keys(options), - i, spec, name, target; + skipWhitespace(m[0].length); + if(typeof m === "string") { + return m; + } - // Resolve references - for (i=0; i 32) { + break; } - if (!multiple) - final_length=1; - - var results=[], frame_length, x, xf; - for (i=0; iframe_length) ? frame_length : x; - results[x]=$.extend(results[x], frame[xf]); - } + if ((c !== 32) && (c !== 10) && (c !== 9) && (c !== 13)) { + break; } + } - for (i=0; i").get(0).files !== undefined; -feature.formdata = window.FormData !== undefined; - -var hasProp = !!$.fn.prop; - -// attr2 uses prop when it can but checks the return type for -// an expected string. this accounts for the case where a form -// contains inputs with names like "action" or "method"; in those -// cases "prop" returns the element -$.fn.attr2 = function() { - if ( ! hasProp ) - return this.attr.apply(this, arguments); - var val = this.prop.apply(this, arguments); - if ( ( val && val.jquery ) || typeof val === 'string' ) - return val; - return this.attr.apply(this, arguments); -}; - -/** - * ajaxSubmit() provides a mechanism for immediately submitting - * an HTML form using AJAX. - */ -$.fn.ajaxSubmit = function(options) { - /*jshint scripturl:true */ - - // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) - if (!this.length) { - log('ajaxSubmit: skipping submit process - no element selected'); - return this; - } - - var method, action, url, $form = this; - - if (typeof options == 'function') { - options = { success: options }; - } - else if ( options === undefined ) { - options = {}; - } - - method = options.type || this.attr2('method'); - action = options.url || this.attr2('action'); - url = (typeof action === 'string') ? $.trim(action) : ''; - url = url || window.location.href || ''; - if (url) { - // clean url (don't include hash vaue) - url = (url.match(/^([^#]+)/)||[])[1]; + return oldi !== i || oldj !== j; } - options = $.extend(true, { - url: url, - success: $.ajaxSettings.success, - type: method || $.ajaxSettings.type, - iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' - }, options); - - // hook for manipulating the form data before it is extracted; - // convenient for use with rich editors like tinyMCE or FCKEditor - var veto = {}; - this.trigger('form-pre-serialize', [this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); - return this; + function expect(arg, msg) { + // some older browsers return typeof 'function' for RegExp + var result = (Object.prototype.toString.call(arg) === '[object Function]') ? arg.call(parsers) : $(arg); + if (result) { + return result; + } + error(msg || (typeof(arg) === 'string' ? "expected '" + arg + "' got '" + input.charAt(i) + "'" + : "unexpected token")); } - // provide opportunity to alter form data before it is serialized - if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSerialize callback'); - return this; + // Specialization of expect() + function expectChar(arg, msg) { + if (input.charAt(i) === arg) { + skipWhitespace(1); + return arg; + } + error(msg || "expected '" + arg + "' got '" + input.charAt(i) + "'"); } - var traditional = options.traditional; - if ( traditional === undefined ) { - traditional = $.ajaxSettings.traditional; + function error(msg, type) { + var e = new Error(msg); + e.index = i; + e.type = type || 'Syntax'; + throw e; } - var elements = []; - var qx, a = this.formToArray(options.semantic, elements); - if (options.data) { - options.extraData = options.data; - qx = $.param(options.data, traditional); + // Same as $(), but don't change the state of the parser, + // just return the match. + function peek(tok) { + if (typeof(tok) === 'string') { + return input.charAt(i) === tok; + } else { + return tok.test(current); + } } - // give pre-submit callback an opportunity to abort the submit - if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSubmit callback'); - return this; + // Specialization of peek() + function peekChar(tok) { + return input.charAt(i) === tok; } - // fire vetoable 'validate' event - this.trigger('form-submit-validate', [a, this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); - return this; - } - var q = $.param(a, traditional); - if (qx) { - q = ( q ? (q + '&' + qx) : qx ); - } - if (options.type.toUpperCase() == 'GET') { - options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; - options.data = null; // data is null for 'get' - } - else { - options.data = q; // data is the query string for 'post' + function getInput(e, env) { + if (e.filename && env.currentFileInfo.filename && (e.filename !== env.currentFileInfo.filename)) { + return parser.imports.contents[e.filename]; + } else { + return input; + } } - var callbacks = []; - if (options.resetForm) { - callbacks.push(function() { $form.resetForm(); }); - } - if (options.clearForm) { - callbacks.push(function() { $form.clearForm(options.includeHidden); }); - } + function getLocation(index, inputStream) { + var n = index + 1, + line = null, + column = -1; - // perform a load on the target only if dataType is not provided - if (!options.dataType && options.target) { - var oldSuccess = options.success || function(){}; - callbacks.push(function(data) { - var fn = options.replaceTarget ? 'replaceWith' : 'html'; - $(options.target)[fn](data).each(oldSuccess, arguments); - }); - } - else if (options.success) { - callbacks.push(options.success); - } + while (--n >= 0 && inputStream.charAt(n) !== '\n') { + column++; + } - options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg - var context = options.context || this ; // jQuery 1.4+ supports scope context - for (var i=0, max=callbacks.length; i < max; i++) { - callbacks[i].apply(context, [data, status, xhr || $form, $form]); + if (typeof index === 'number') { + line = (inputStream.slice(0, index).match(/\n/g) || "").length; } - }; - if (options.error) { - var oldError = options.error; - options.error = function(xhr, status, error) { - var context = options.context || this; - oldError.apply(context, [xhr, status, error, $form]); + return { + line: line, + column: column }; } - if (options.complete) { - var oldComplete = options.complete; - options.complete = function(xhr, status) { - var context = options.context || this; - oldComplete.apply(context, [xhr, status, $form]); + function getDebugInfo(index, inputStream, env) { + var filename = env.currentFileInfo.filename; + if(less.mode !== 'browser' && less.mode !== 'rhino') { + filename = require('path').resolve(filename); + } + + return { + lineNumber: getLocation(index, inputStream).line + 1, + fileName: filename }; } - // are there files to upload? - - // [value] (issue #113), also see comment: - // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219 - var fileInputs = $('input[type=file]:enabled', this).filter(function() { return $(this).val() !== ''; }); - - var hasFileInputs = fileInputs.length > 0; - var mp = 'multipart/form-data'; - var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); + function LessError(e, env) { + var input = getInput(e, env), + loc = getLocation(e.index, input), + line = loc.line, + col = loc.column, + callLine = e.call && getLocation(e.call, input).line, + lines = input.split('\n'); - var fileAPI = feature.fileapi && feature.formdata; - log("fileAPI :" + fileAPI); - var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; + this.type = e.type || 'Syntax'; + this.message = e.message; + this.filename = e.filename || env.currentFileInfo.filename; + this.index = e.index; + this.line = typeof(line) === 'number' ? line + 1 : null; + this.callLine = callLine + 1; + this.callExtract = lines[callLine]; + this.stack = e.stack; + this.column = col; + this.extract = [ + lines[line - 1], + lines[line], + lines[line + 1] + ]; + } - var jqxhr; + LessError.prototype = new Error(); + LessError.prototype.constructor = LessError; - // options.iframe allows user to force iframe mode - // 06-NOV-09: now defaulting to iframe mode if file input is detected - if (options.iframe !== false && (options.iframe || shouldUseFrame)) { - // hack to fix Safari hang (thanks to Tim Molendijk for this) - // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d - if (options.closeKeepAlive) { - $.get(options.closeKeepAlive, function() { - jqxhr = fileUploadIframe(a); - }); - } - else { - jqxhr = fileUploadIframe(a); - } - } - else if ((hasFileInputs || multipart) && fileAPI) { - jqxhr = fileUploadXhr(a); - } - else { - jqxhr = $.ajax(options); - } + this.env = env = env || {}; - $form.removeData('jqxhr').data('jqxhr', jqxhr); + // The optimization level dictates the thoroughness of the parser, + // the lower the number, the less nodes it will create in the tree. + // This could matter for debugging, or if you want to access + // the individual nodes in the tree. + this.optimization = ('optimization' in this.env) ? this.env.optimization : 1; - // clear element array - for (var k=0; k < elements.length; k++) - elements[k] = null; + // + // The Parser + // + parser = { - // fire 'notify' event - this.trigger('form-submit-notify', [this, options]); - return this; + imports: imports, + // + // Parse an input string into an abstract syntax tree, + // @param str A string containing 'less' markup + // @param callback call `callback` when done. + // @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply + // + parse: function (str, callback, additionalData) { + var root, line, lines, error = null, globalVars, modifyVars, preText = ""; - // utility fn for deep serialization - function deepSerialize(extraData){ - var serialized = $.param(extraData, options.traditional).split('&'); - var len = serialized.length; - var result = []; - var i, part; - for (i=0; i < len; i++) { - // #252; undo param space replacement - serialized[i] = serialized[i].replace(/\+/g,' '); - part = serialized[i].split('='); - // #278; use array instead of object storage, favoring array serializations - result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]); - } - return result; - } + i = j = currentPos = furthest = 0; - // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) - function fileUploadXhr(a) { - var formdata = new FormData(); + globalVars = (additionalData && additionalData.globalVars) ? less.Parser.serializeVars(additionalData.globalVars) + '\n' : ''; + modifyVars = (additionalData && additionalData.modifyVars) ? '\n' + less.Parser.serializeVars(additionalData.modifyVars) : ''; - for (var i=0; i < a.length; i++) { - formdata.append(a[i].name, a[i].value); - } + if (globalVars || (additionalData && additionalData.banner)) { + preText = ((additionalData && additionalData.banner) ? additionalData.banner : "") + globalVars; + parser.imports.contentsIgnoredChars[env.currentFileInfo.filename] = preText.length; + } - if (options.extraData) { - var serializedData = deepSerialize(options.extraData); - for (i=0; i < serializedData.length; i++) - if (serializedData[i]) - formdata.append(serializedData[i][0], serializedData[i][1]); - } + str = str.replace(/\r\n/g, '\n'); + // Remove potential UTF Byte Order Mark + input = str = preText + str.replace(/^\uFEFF/, '') + modifyVars; + parser.imports.contents[env.currentFileInfo.filename] = str; - options.data = null; + // Split the input into chunks. + chunks = (function (input) { + var len = input.length, level = 0, parenLevel = 0, + lastOpening, lastOpeningParen, lastMultiComment, lastMultiCommentEndBrace, + chunks = [], emitFrom = 0, + parserCurrentIndex, currentChunkStartIndex, cc, cc2, matched; - var s = $.extend(true, {}, $.ajaxSettings, options, { - contentType: false, - processData: false, - cache: false, - type: method || 'POST' - }); + function fail(msg, index) { + error = new(LessError)({ + index: index || parserCurrentIndex, + type: 'Parse', + message: msg, + filename: env.currentFileInfo.filename + }, env); + } - if (options.uploadProgress) { - // workaround because jqXHR does not expose upload property - s.xhr = function() { - var xhr = $.ajaxSettings.xhr(); - if (xhr.upload) { - xhr.upload.addEventListener('progress', function(event) { - var percent = 0; - var position = event.loaded || event.position; /*event.position is deprecated*/ - var total = event.total; - if (event.lengthComputable) { - percent = Math.ceil(position / total * 100); - } - options.uploadProgress(event, position, total, percent); - }, false); + function emitChunk(force) { + var len = parserCurrentIndex - emitFrom; + if (((len < 512) && !force) || !len) { + return; + } + chunks.push(input.slice(emitFrom, parserCurrentIndex + 1)); + emitFrom = parserCurrentIndex + 1; } - return xhr; - }; - } - s.data = null; - var beforeSend = s.beforeSend; - s.beforeSend = function(xhr, o) { - //Send FormData() provided by user - if (options.formData) - o.data = options.formData; - else - o.data = formdata; - if(beforeSend) - beforeSend.call(this, xhr, o); - }; - return $.ajax(s); - } - - // private function for handling file uploads (hat tip to YAHOO!) - function fileUploadIframe(a) { - var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; - var deferred = $.Deferred(); - - // #341 - deferred.abort = function(status) { - xhr.abort(status); - }; - - if (a) { - // ensure that every serialized input is still enabled - for (i=0; i < elements.length; i++) { - el = $(elements[i]); - if ( hasProp ) - el.prop('disabled', false); - else - el.removeAttr('disabled'); - } - } - - s = $.extend(true, {}, $.ajaxSettings, options); - s.context = s.context || s; - id = 'jqFormIO' + (new Date().getTime()); - if (s.iframeTarget) { - $io = $(s.iframeTarget); - n = $io.attr2('name'); - if (!n) - $io.attr2('name', id); - else - id = n; - } - else { - $io = $('