NIFI-27: - Upgrading jQuery and jQuery UI. - Replacing all instances of Deferred.then with Deferred.done/fail due to API change introduced in 1.8. - Restoring line returns between public methods. - Upgrading jquery.form and jquery.minicolors.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/2965258e Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/2965258e Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/2965258e Branch: refs/heads/NIFI-169 Commit: 2965258e5da192b8a54dc36f84089be90bc0f1f7 Parents: fc78752 Author: Matt Gilman <matt.c.gil...@gmail.com> Authored: Tue Dec 16 08:42:13 2014 -0500 Committer: Matt Gilman <matt.c.gil...@gmail.com> Committed: Tue Dec 16 08:42:13 2014 -0500 ---------------------------------------------------------------------- .../webapp/WEB-INF/pages/bulletin-board.jsp | 3 +- .../src/main/webapp/WEB-INF/pages/canvas.jsp | 3 +- .../src/main/webapp/WEB-INF/pages/cluster.jsp | 1 - .../src/main/webapp/WEB-INF/pages/counters.jsp | 1 - .../src/main/webapp/WEB-INF/pages/history.jsp | 1 - .../main/webapp/WEB-INF/pages/provenance.jsp | 1 - .../src/main/webapp/WEB-INF/pages/summary.jsp | 1 - .../src/main/webapp/WEB-INF/pages/templates.jsp | 3 +- .../src/main/webapp/WEB-INF/pages/users.jsp | 1 - .../src/main/webapp/js/jquery/jquery.form.js | 1118 -- .../main/webapp/js/jquery/jquery.form.min.js | 11 + .../js/jquery/minicolors/jquery.minicolors.css | 40 +- .../jquery/minicolors/jquery.minicolors.min.js | 421 +- .../jquery/ui-smoothness/jquery-ui-1.10.4.css | 1178 -- .../js/jquery/ui-smoothness/jquery-ui-1.10.4.js | 15008 ----------------- .../js/nf/bulletin-board/nf-bulletin-board.js | 16 +- .../src/main/webapp/js/nf/canvas/nf-actions.js | 65 +- .../src/main/webapp/js/nf/canvas/nf-birdseye.js | 1 + .../webapp/js/nf/canvas/nf-canvas-header.js | 12 +- .../webapp/js/nf/canvas/nf-canvas-toolbar.js | 1 + .../webapp/js/nf/canvas/nf-canvas-toolbox.js | 45 +- .../main/webapp/js/nf/canvas/nf-canvas-utils.js | 73 +- .../src/main/webapp/js/nf/canvas/nf-canvas.js | 59 +- .../main/webapp/js/nf/canvas/nf-clipboard.js | 4 + .../main/webapp/js/nf/canvas/nf-connectable.js | 1 + .../js/nf/canvas/nf-connection-configuration.js | 43 +- .../main/webapp/js/nf/canvas/nf-connection.js | 20 +- .../main/webapp/js/nf/canvas/nf-context-menu.js | 2 + .../main/webapp/js/nf/canvas/nf-draggable.js | 9 +- .../src/main/webapp/js/nf/canvas/nf-funnel.js | 8 + .../src/main/webapp/js/nf/canvas/nf-go-to.js | 50 +- .../src/main/webapp/js/nf/canvas/nf-graph.js | 6 + .../js/nf/canvas/nf-label-configuration.js | 5 +- .../src/main/webapp/js/nf/canvas/nf-label.js | 14 +- .../js/nf/canvas/nf-port-configuration.js | 5 +- .../main/webapp/js/nf/canvas/nf-port-details.js | 1 + .../src/main/webapp/js/nf/canvas/nf-port.js | 10 + .../nf/canvas/nf-process-group-configuration.js | 5 +- .../js/nf/canvas/nf-process-group-details.js | 1 + .../webapp/js/nf/canvas/nf-process-group.js | 10 + .../js/nf/canvas/nf-processor-configuration.js | 13 +- .../js/nf/canvas/nf-processor-property-table.js | 14 + .../main/webapp/js/nf/canvas/nf-processor.js | 11 + .../main/webapp/js/nf/canvas/nf-registration.js | 4 +- .../nf-remote-process-group-configuration.js | 5 +- .../canvas/nf-remote-process-group-details.js | 1 + .../nf/canvas/nf-remote-process-group-ports.js | 13 +- .../js/nf/canvas/nf-remote-process-group.js | 10 + .../nf/canvas/nf-secure-port-configuration.js | 5 +- .../js/nf/canvas/nf-secure-port-details.js | 1 + .../main/webapp/js/nf/canvas/nf-selectable.js | 2 + .../src/main/webapp/js/nf/canvas/nf-settings.js | 13 +- .../src/main/webapp/js/nf/canvas/nf-snippet.js | 6 + .../src/main/webapp/js/nf/canvas/nf-storage.js | 3 + .../webapp/js/nf/cluster/nf-cluster-table.js | 31 +- .../src/main/webapp/js/nf/cluster/nf-cluster.js | 12 +- .../webapp/js/nf/counters/nf-counters-table.js | 11 +- .../main/webapp/js/nf/counters/nf-counters.js | 12 +- .../webapp/js/nf/history/nf-history-model.js | 4 +- .../webapp/js/nf/history/nf-history-table.js | 7 +- .../src/main/webapp/js/nf/history/nf-history.js | 12 +- .../src/main/webapp/js/nf/nf-common.js | 40 + .../main/webapp/js/nf/nf-connection-details.js | 19 +- .../src/main/webapp/js/nf/nf-dialog.js | 1 + .../main/webapp/js/nf/nf-processor-details.js | 5 +- .../src/main/webapp/js/nf/nf-shell.js | 1 + .../src/main/webapp/js/nf/nf-status-history.js | 40 +- .../js/nf/provenance/nf-provenance-lineage.js | 17 +- .../js/nf/provenance/nf-provenance-table.js | 37 +- .../webapp/js/nf/provenance/nf-provenance.js | 20 +- .../webapp/js/nf/summary/nf-summary-table.js | 62 +- .../src/main/webapp/js/nf/summary/nf-summary.js | 20 +- .../js/nf/templates/nf-templates-table.js | 12 +- .../main/webapp/js/nf/templates/nf-templates.js | 12 +- .../main/webapp/js/nf/users/nf-users-table.js | 46 +- .../src/main/webapp/js/nf/users/nf-users.js | 12 +- 76 files changed, 719 insertions(+), 18072 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp index 297a331..62569ef 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp @@ -25,9 +25,8 @@ <link rel="stylesheet" href="js/jquery/combo/jquery.combo.css?${project.version}" type="text/css" /> <link rel="stylesheet" href="js/jquery/modal/jquery.modal.css?${project.version}" type="text/css" /> <link rel="stylesheet" href="js/jquery/qtip2/jquery.qtip.min.css?" type="text/css" /> - <link rel="stylesheet" href="js/jquery/ui-smoothness/jquery-ui-1.10.4.css" type="text/css" /> + <link rel="stylesheet" href="js/jquery/ui-smoothness/jquery-ui-1.10.4.min.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> - <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp index 5dc2b87..8f50c1f 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp @@ -35,8 +35,7 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/codemirror/lib/codemirror-compressed.js"></script> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> - <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> - <script type="text/javascript" src="js/jquery/ui-smoothness/jquery-ui-1.10.4.js"></script> + <script type="text/javascript" src="js/jquery/ui-smoothness/jquery-ui-1.10.4.min.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/jquery.count.js"></script> <script type="text/javascript" src="js/jquery/jquery.ellipsis.js"></script> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp index 121aebc..867ea3f 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp @@ -29,7 +29,6 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> - <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp index 0d0c527..2d3576d 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp @@ -29,7 +29,6 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> - <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp index 7d588fe..db064ff 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp @@ -29,7 +29,6 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> - <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp index e014b93..59e8512 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp @@ -30,7 +30,6 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> - <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/tabbs/jquery.tabbs.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp index fca5506..0c57e65 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp @@ -30,7 +30,6 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> - <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> <script type="text/javascript" src="js/jquery/ui-smoothness/jquery-ui-1.10.4.min.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/tabbs/jquery.tabbs.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp index e2eb7e1..da479d6 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp @@ -29,9 +29,8 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> - <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> - <script type="text/javascript" src="js/jquery/jquery.form.js"></script> + <script type="text/javascript" src="js/jquery/jquery.form.min.js"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/jquery.ellipsis.js"></script> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp index 39b7e15..ff2bbf1 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp @@ -30,7 +30,6 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> - <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/tabbs/jquery.tabbs.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery.form.js ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery.form.js b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery.form.js deleted file mode 100755 index 4604aa9..0000000 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery.form.js +++ /dev/null @@ -1,1118 +0,0 @@ -/*! - * jQuery Form Plugin - * version: 3.15 (09-SEP-2012) - * @requires jQuery v1.3.2 or later - * - * Examples and documentation at: http://malsup.com/jquery/form/ - * Project repository: https://github.com/malsup/form - * Dual licensed under the MIT and GPL licenses: - * http://malsup.github.com/mit-license.txt - * http://malsup.github.com/gpl-license-v2.txt - */ -/*global ActiveXObject alert */ -; -(function ($) { - "use strict"; - - /* - Usage Note: - ----------- - Do not use both ajaxSubmit and ajaxForm on the same form. These - functions are mutually exclusive. Use ajaxSubmit if you want - to bind your own submit handler to the form. For example, - - $(document).ready(function() { - $('#myForm').on('submit', function(e) { - e.preventDefault(); // <-- important - $(this).ajaxSubmit({ - target: '#output' - }); - }); - }); - - Use ajaxForm when you want the plugin to manage all the event binding - for you. For example, - - $(document).ready(function() { - $('#myForm').ajaxForm({ - target: '#output' - }); - }); - - You can also use ajaxForm with delegation (requires jQuery v1.7+), so the - form does not have to exist when you invoke ajaxForm: - - $('#myForm').ajaxForm({ - delegation: true, - target: '#output' - }); - - When using ajaxForm, the ajaxSubmit function will be invoked for you - at the appropriate time. - */ - - /** - * Feature detection - */ - var feature = {}; - feature.fileapi = $("<input type='file'/>").get(0).files !== undefined; - feature.formdata = window.FormData !== undefined; - - /** - * 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}; - } - - method = this.attr('method'); - action = this.attr('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]; - } - - options = $.extend(true, { - url: url, - success: $.ajaxSettings.success, - type: method || 'GET', - 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; - } - - // 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; - } - - var traditional = options.traditional; - if (traditional === undefined) { - traditional = $.ajaxSettings.traditional; - } - - var elements = []; - var qx, a = this.formToArray(options.semantic, elements); - if (options.data) { - options.extraData = options.data; - qx = $.param(options.data, traditional); - } - - // 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; - } - - // 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' - } - - var callbacks = []; - if (options.resetForm) { - callbacks.push(function () { - $form.resetForm(); - }); - } - if (options.clearForm) { - callbacks.push(function () { - $form.clearForm(options.includeHidden); - }); - } - - // 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); - } - - 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]); - } - }; - - // are there files to upload? - var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113) - var hasFileInputs = fileInputs.length > 0; - var mp = 'multipart/form-data'; - var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); - - var fileAPI = feature.fileapi && feature.formdata; - log("fileAPI :" + fileAPI); - var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; - - // 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 () { - fileUploadIframe(a); - }); - } - else { - fileUploadIframe(a); - } - } - else if ((hasFileInputs || multipart) && fileAPI) { - fileUploadXhr(a); - } - else { - $.ajax(options); - } - - // clear element array - for (var k = 0; k < elements.length; k++) - elements[k] = null; - - // fire 'notify' event - this.trigger('form-submit-notify', [this, options]); - return this; - - // utility fn for deep serialization - function deepSerialize(extraData) { - var serialized = $.param(extraData).split('&'); - var len = serialized.length; - var result = {}; - var i, part; - for (i = 0; i < len; i++) { - part = serialized[i].split('='); - result[decodeURIComponent(part[0])] = decodeURIComponent(part[1]); - } - return result; - } - - // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) - function fileUploadXhr(a) { - var formdata = new FormData(); - - for (var i = 0; i < a.length; i++) { - formdata.append(a[i].name, a[i].value); - } - - if (options.extraData) { - var serializedData = deepSerialize(options.extraData); - for (var p in serializedData) - if (serializedData.hasOwnProperty(p)) - formdata.append(p, serializedData[p]); - } - - options.data = null; - - var s = $.extend(true, {}, $.ajaxSettings, options, { - contentType: false, - processData: false, - cache: false, - type: 'POST' - }); - - if (options.uploadProgress) { - // workaround because jqXHR does not expose upload property - s.xhr = function () { - var xhr = jQuery.ajaxSettings.xhr(); - if (xhr.upload) { - xhr.upload.onprogress = 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); - }; - } - return xhr; - }; - } - - s.data = null; - var beforeSend = s.beforeSend; - s.beforeSend = function (xhr, o) { - o.data = formdata; - if (beforeSend) - beforeSend.call(this, xhr, o); - }; - $.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 useProp = !!$.fn.prop; - - if ($(':input[name=submit],:input[id=submit]', form).length) { - // if there is an input with a name or id of 'submit' then we won't be - // able to invoke the submit fn on the form (at least not x-browser) - alert('Error: Form elements must not have name or id of "submit".'); - return; - } - - if (a) { - // ensure that every serialized input is still enabled - for (i = 0; i < elements.length; i++) { - el = $(elements[i]); - if (useProp) - 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.attr('name'); - if (!n) - $io.attr('name', id); - else - id = n; - } - else { - $io = $('<iframe name="' + id + '" src="' + s.iframeSrc + '" />'); - $io.css({position: 'absolute', top: '-1000px', left: '-1000px'}); - } - io = $io[0]; - - - xhr = {// mock object - aborted: 0, - responseText: null, - responseXML: null, - status: 0, - statusText: 'n/a', - getAllResponseHeaders: function () { - }, - getResponseHeader: function () { - }, - setRequestHeader: function () { - }, - abort: function (status) { - var e = (status === 'timeout' ? 'timeout' : 'aborted'); - log('aborting upload... ' + e); - this.aborted = 1; - // #214 - if (io.contentWindow.document.execCommand) { - try { // #214 - io.contentWindow.document.execCommand('Stop'); - } catch (ignore) { - } - } - $io.attr('src', s.iframeSrc); // abort op in progress - xhr.error = e; - if (s.error) - s.error.call(s.context, xhr, e, status); - if (g) - $.event.trigger("ajaxError", [xhr, s, e]); - if (s.complete) - s.complete.call(s.context, xhr, e); - } - }; - - g = s.global; - // trigger ajax global events so that activity/block indicators work like normal - if (g && 0 === $.active++) { - $.event.trigger("ajaxStart"); - } - if (g) { - $.event.trigger("ajaxSend", [xhr, s]); - } - - if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) { - if (s.global) { - $.active--; - } - return; - } - if (xhr.aborted) { - return; - } - - // add submitting element to data if we know it - sub = form.clk; - if (sub) { - n = sub.name; - if (n && !sub.disabled) { - s.extraData = s.extraData || {}; - s.extraData[n] = sub.value; - if (sub.type == "image") { - s.extraData[n + '.x'] = form.clk_x; - s.extraData[n + '.y'] = form.clk_y; - } - } - } - - var CLIENT_TIMEOUT_ABORT = 1; - var SERVER_ABORT = 2; - - function getDoc(frame) { - var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document; - return doc; - } - - // Rails CSRF hack (thanks to Yvan Barthelemy) - var csrf_token = $('meta[name=csrf-token]').attr('content'); - var csrf_param = $('meta[name=csrf-param]').attr('content'); - if (csrf_param && csrf_token) { - s.extraData = s.extraData || {}; - s.extraData[csrf_param] = csrf_token; - } - - // take a breath so that pending repaints get some cpu time before the upload starts - function doSubmit() { - // make sure form attrs are set - var t = $form.attr('target'), a = $form.attr('action'); - - // update form attrs in IE friendly way - form.setAttribute('target', id); - if (!method) { - form.setAttribute('method', 'POST'); - } - if (a != s.url) { - form.setAttribute('action', s.url); - } - - // ie borks in some cases when setting encoding - if (!s.skipEncodingOverride && (!method || /post/i.test(method))) { - $form.attr({ - encoding: 'multipart/form-data', - enctype: 'multipart/form-data' - }); - } - - // support timout - if (s.timeout) { - timeoutHandle = setTimeout(function () { - timedOut = true; - cb(CLIENT_TIMEOUT_ABORT); - }, s.timeout); - } - - // look for server aborts - function checkState() { - try { - var state = getDoc(io).readyState; - log('state = ' + state); - if (state && state.toLowerCase() == 'uninitialized') - setTimeout(checkState, 50); - } - catch (e) { - log('Server abort: ', e, ' (', e.name, ')'); - cb(SERVER_ABORT); - if (timeoutHandle) - clearTimeout(timeoutHandle); - timeoutHandle = undefined; - } - } - - // add "extra" data to form if provided in options - var extraInputs = []; - try { - if (s.extraData) { - for (var n in s.extraData) { - if (s.extraData.hasOwnProperty(n)) { - // if using the $.param format that allows for multiple values with the same name - if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) { - extraInputs.push( - $('<input type="hidden" name="' + s.extraData[n].name + '">').attr('value', s.extraData[n].value) - .appendTo(form)[0]); - } else { - extraInputs.push( - $('<input type="hidden" name="' + n + '">').attr('value', s.extraData[n]) - .appendTo(form)[0]); - } - } - } - } - - if (!s.iframeTarget) { - // add iframe to doc and submit the form - $io.appendTo('body'); - if (io.attachEvent) - io.attachEvent('onload', cb); - else - io.addEventListener('load', cb, false); - } - setTimeout(checkState, 15); - form.submit(); - } - finally { - // reset attrs and remove "extra" input elements - form.setAttribute('action', a); - if (t) { - form.setAttribute('target', t); - } else { - $form.removeAttr('target'); - } - $(extraInputs).remove(); - } - } - - if (s.forceSync) { - doSubmit(); - } - else { - setTimeout(doSubmit, 10); // this lets dom updates render - } - - var data, doc, domCheckCount = 50, callbackProcessed; - - function cb(e) { - if (xhr.aborted || callbackProcessed) { - return; - } - try { - doc = getDoc(io); - } - catch (ex) { - log('cannot access response document: ', ex); - e = SERVER_ABORT; - } - if (e === CLIENT_TIMEOUT_ABORT && xhr) { - xhr.abort('timeout'); - return; - } - else if (e == SERVER_ABORT && xhr) { - xhr.abort('server abort'); - return; - } - - if (!doc || doc.location.href == s.iframeSrc) { - // response not received yet - if (!timedOut) - return; - } - if (io.detachEvent) - io.detachEvent('onload', cb); - else - io.removeEventListener('load', cb, false); - - var status = 'success', errMsg; - try { - if (timedOut) { - throw 'timeout'; - } - - var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc); - log('isXml=' + isXml); - if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) { - if (--domCheckCount) { - // in some browsers (Opera) the iframe DOM is not always traversable when - // the onload callback fires, so we loop a bit to accommodate - log('requeing onLoad callback, DOM not available'); - setTimeout(cb, 250); - return; - } - // let this fall through because server response could be an empty document - //log('Could not access iframe DOM after mutiple tries.'); - //throw 'DOMException: not available'; - } - - //log('response detected'); - var docRoot = doc.body ? doc.body : doc.documentElement; - xhr.responseText = docRoot ? docRoot.innerHTML : null; - xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; - if (isXml) - s.dataType = 'xml'; - xhr.getResponseHeader = function (header) { - var headers = {'content-type': s.dataType}; - return headers[header]; - }; - // support for XHR 'status' & 'statusText' emulation : - if (docRoot) { - xhr.status = Number(docRoot.getAttribute('status')) || xhr.status; - xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText; - } - - var dt = (s.dataType || '').toLowerCase(); - var scr = /(json|script|text)/.test(dt); - if (scr || s.textarea) { - // see if user embedded response in textarea - var ta = doc.getElementsByTagName('textarea')[0]; - if (ta) { - xhr.responseText = ta.value; - // support for XHR 'status' & 'statusText' emulation : - xhr.status = Number(ta.getAttribute('status')) || xhr.status; - xhr.statusText = ta.getAttribute('statusText') || xhr.statusText; - } - else if (scr) { - // account for browsers injecting pre around json response - var pre = doc.getElementsByTagName('pre')[0]; - var b = doc.getElementsByTagName('body')[0]; - if (pre) { - xhr.responseText = pre.textContent ? pre.textContent : pre.innerText; - } - else if (b) { - xhr.responseText = b.textContent ? b.textContent : b.innerText; - } - } - } - else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) { - xhr.responseXML = toXml(xhr.responseText); - } - - try { - data = httpData(xhr, dt, s); - } - catch (e) { - status = 'parsererror'; - xhr.error = errMsg = (e || status); - } - } - catch (e) { - log('error caught: ', e); - status = 'error'; - xhr.error = errMsg = (e || status); - } - - if (xhr.aborted) { - log('upload aborted'); - status = null; - } - - if (xhr.status) { // we've set xhr.status - status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error'; - } - - // ordering of these callbacks/triggers is odd, but that's how $.ajax does it - if (status === 'success') { - if (s.success) - s.success.call(s.context, data, 'success', xhr); - if (g) - $.event.trigger("ajaxSuccess", [xhr, s]); - } - else if (status) { - if (errMsg === undefined) - errMsg = xhr.statusText; - if (s.error) - s.error.call(s.context, xhr, status, errMsg); - if (g) - $.event.trigger("ajaxError", [xhr, s, errMsg]); - } - - if (g) - $.event.trigger("ajaxComplete", [xhr, s]); - - if (g && !--$.active) { - $.event.trigger("ajaxStop"); - } - - if (s.complete) - s.complete.call(s.context, xhr, status); - - callbackProcessed = true; - if (s.timeout) - clearTimeout(timeoutHandle); - - // clean up - setTimeout(function () { - if (!s.iframeTarget) - $io.remove(); - xhr.responseXML = null; - }, 100); - } - - var toXml = $.parseXML || function (s, doc) { // use parseXML if available (jQuery 1.5+) - if (window.ActiveXObject) { - doc = new ActiveXObject('Microsoft.XMLDOM'); - doc.async = 'false'; - doc.loadXML(s); - } - else { - doc = (new DOMParser()).parseFromString(s, 'text/xml'); - } - return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null; - }; - var parseJSON = $.parseJSON || function (s) { - /*jslint evil:true */ - return window['eval']('(' + s + ')'); - }; - - var httpData = function (xhr, type, s) { // mostly lifted from jq1.4.4 - - var ct = xhr.getResponseHeader('content-type') || '', - xml = type === 'xml' || !type && ct.indexOf('xml') >= 0, - data = xml ? xhr.responseXML : xhr.responseText; - - if (xml && data.documentElement.nodeName === 'parsererror') { - if ($.error) - $.error('parsererror'); - } - if (s && s.dataFilter) { - data = s.dataFilter(data, type); - } - if (typeof data === 'string') { - if (type === 'json' || !type && ct.indexOf('json') >= 0) { - data = parseJSON(data); - } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) { - $.globalEval(data); - } - } - return data; - }; - } - }; - - /** - * ajaxForm() provides a mechanism for fully automating form submission. - * - * The advantages of using this method instead of ajaxSubmit() are: - * - * 1: This method will include coordinates for <input type="image" /> elements (if the element - * is used to submit the form). - * 2. This method will include the submit element's name/value data (for the element that was - * used to submit the form). - * 3. This method binds the submit() method to the form for you. - * - * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely - * passes the options argument along after properly binding events for submit elements and - * the form itself. - */ - $.fn.ajaxForm = function (options) { - options = options || {}; - options.delegation = options.delegation && $.isFunction($.fn.on); - - // in jQuery 1.3+ we can fix mistakes with the ready state - if (!options.delegation && this.length === 0) { - var o = {s: this.selector, c: this.context}; - if (!$.isReady && o.s) { - log('DOM not ready, queuing ajaxForm'); - $(function () { - $(o.s, o.c).ajaxForm(options); - }); - return this; - } - // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() - log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); - return this; - } - - if (options.delegation) { - $(document) - .off('submit.form-plugin', this.selector, doAjaxSubmit) - .off('click.form-plugin', this.selector, captureSubmittingElement) - .on('submit.form-plugin', this.selector, options, doAjaxSubmit) - .on('click.form-plugin', this.selector, options, captureSubmittingElement); - return this; - } - - return this.ajaxFormUnbind() - .bind('submit.form-plugin', options, doAjaxSubmit) - .bind('click.form-plugin', options, captureSubmittingElement); - }; - -// private event handlers - function doAjaxSubmit(e) { - /*jshint validthis:true */ - var options = e.data; - if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed - e.preventDefault(); - $(this).ajaxSubmit(options); - } - } - - function captureSubmittingElement(e) { - /*jshint validthis:true */ - var target = e.target; - var $el = $(target); - if (!($el.is(":submit,input:image"))) { - // is this a child element of the submit el? (ex: a span within a button) - var t = $el.closest(':submit'); - if (t.length === 0) { - return; - } - target = t[0]; - } - var form = this; - form.clk = target; - if (target.type == 'image') { - if (e.offsetX !== undefined) { - form.clk_x = e.offsetX; - form.clk_y = e.offsetY; - } else if (typeof $.fn.offset == 'function') { - var offset = $el.offset(); - form.clk_x = e.pageX - offset.left; - form.clk_y = e.pageY - offset.top; - } else { - form.clk_x = e.pageX - target.offsetLeft; - form.clk_y = e.pageY - target.offsetTop; - } - } - // clear form vars - setTimeout(function () { - form.clk = form.clk_x = form.clk_y = null; - }, 100); - } - - -// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm - $.fn.ajaxFormUnbind = function () { - return this.unbind('submit.form-plugin click.form-plugin'); - }; - - /** - * formToArray() gathers form element data into an array of objects that can - * be passed to any of the following ajax functions: $.get, $.post, or load. - * Each object in the array has both a 'name' and 'value' property. An example of - * an array for a simple login form might be: - * - * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] - * - * It is this array that is passed to pre-submit callback functions provided to the - * ajaxSubmit() and ajaxForm() methods. - */ - $.fn.formToArray = function (semantic, elements) { - var a = []; - if (this.length === 0) { - return a; - } - - var form = this[0]; - var els = semantic ? form.getElementsByTagName('*') : form.elements; - if (!els) { - return a; - } - - var i, j, n, v, el, max, jmax; - for (i = 0, max = els.length; i < max; i++) { - el = els[i]; - n = el.name; - if (!n) { - continue; - } - - if (semantic && form.clk && el.type == "image") { - // handle image inputs on the fly when semantic == true - if (!el.disabled && form.clk == el) { - a.push({name: n, value: $(el).val(), type: el.type}); - a.push({name: n + '.x', value: form.clk_x}, {name: n + '.y', value: form.clk_y}); - } - continue; - } - - v = $.fieldValue(el, true); - if (v && v.constructor == Array) { - if (elements) - elements.push(el); - for (j = 0, jmax = v.length; j < jmax; j++) { - a.push({name: n, value: v[j]}); - } - } - else if (feature.fileapi && el.type == 'file' && !el.disabled) { - if (elements) - elements.push(el); - var files = el.files; - if (files.length) { - for (j = 0; j < files.length; j++) { - a.push({name: n, value: files[j], type: el.type}); - } - } - else { - // #180 - a.push({name: n, value: '', type: el.type}); - } - } - else if (v !== null && typeof v != 'undefined') { - if (elements) - elements.push(el); - a.push({name: n, value: v, type: el.type, required: el.required}); - } - } - - if (!semantic && form.clk) { - // input type=='image' are not found in elements array! handle it here - var $input = $(form.clk), input = $input[0]; - n = input.name; - if (n && !input.disabled && input.type == 'image') { - a.push({name: n, value: $input.val()}); - a.push({name: n + '.x', value: form.clk_x}, {name: n + '.y', value: form.clk_y}); - } - } - return a; - }; - - /** - * Serializes form data into a 'submittable' string. This method will return a string - * in the format: name1=value1&name2=value2 - */ - $.fn.formSerialize = function (semantic) { - //hand off to jQuery.param for proper encoding - return $.param(this.formToArray(semantic)); - }; - - /** - * Serializes all field elements in the jQuery object into a query string. - * This method will return a string in the format: name1=value1&name2=value2 - */ - $.fn.fieldSerialize = function (successful) { - var a = []; - this.each(function () { - var n = this.name; - if (!n) { - return; - } - var v = $.fieldValue(this, successful); - if (v && v.constructor == Array) { - for (var i = 0, max = v.length; i < max; i++) { - a.push({name: n, value: v[i]}); - } - } - else if (v !== null && typeof v != 'undefined') { - a.push({name: this.name, value: v}); - } - }); - //hand off to jQuery.param for proper encoding - return $.param(a); - }; - - /** - * Returns the value(s) of the element in the matched set. For example, consider the following form: - * - * <form><fieldset> - * <input name="A" type="text" /> - * <input name="A" type="text" /> - * <input name="B" type="checkbox" value="B1" /> - * <input name="B" type="checkbox" value="B2"/> - * <input name="C" type="radio" value="C1" /> - * <input name="C" type="radio" value="C2" /> - * </fieldset></form> - * - * var v = $(':text').fieldValue(); - * // if no values are entered into the text inputs - * v == ['',''] - * // if values entered into the text inputs are 'foo' and 'bar' - * v == ['foo','bar'] - * - * var v = $(':checkbox').fieldValue(); - * // if neither checkbox is checked - * v === undefined - * // if both checkboxes are checked - * v == ['B1', 'B2'] - * - * var v = $(':radio').fieldValue(); - * // if neither radio is checked - * v === undefined - * // if first radio is checked - * v == ['C1'] - * - * The successful argument controls whether or not the field element must be 'successful' - * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). - * The default value of the successful argument is true. If this value is false the value(s) - * for each element is returned. - * - * Note: This method *always* returns an array. If no valid value can be determined the - * array will be empty, otherwise it will contain one or more values. - */ - $.fn.fieldValue = function (successful) { - for (var val = [], i = 0, max = this.length; i < max; i++) { - var el = this[i]; - var v = $.fieldValue(el, successful); - if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) { - continue; - } - if (v.constructor == Array) - $.merge(val, v); - else - val.push(v); - } - return val; - }; - - /** - * Returns the value of the field element. - */ - $.fieldValue = function (el, successful) { - var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); - if (successful === undefined) { - successful = true; - } - - if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || - (t == 'checkbox' || t == 'radio') && !el.checked || - (t == 'submit' || t == 'image') && el.form && el.form.clk != el || - tag == 'select' && el.selectedIndex == -1)) { - return null; - } - - if (tag == 'select') { - var index = el.selectedIndex; - if (index < 0) { - return null; - } - var a = [], ops = el.options; - var one = (t == 'select-one'); - var max = (one ? index + 1 : ops.length); - for (var i = (one ? index : 0); i < max; i++) { - var op = ops[i]; - if (op.selected) { - var v = op.value; - if (!v) { // extra pain for IE... - v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value; - } - if (one) { - return v; - } - a.push(v); - } - } - return a; - } - return $(el).val(); - }; - - /** - * Clears the form data. Takes the following actions on the form's input fields: - * - input text fields will have their 'value' property set to the empty string - * - select elements will have their 'selectedIndex' property set to -1 - * - checkbox and radio inputs will have their 'checked' property set to false - * - inputs of type submit, button, reset, and hidden will *not* be effected - * - button elements will *not* be effected - */ - $.fn.clearForm = function (includeHidden) { - return this.each(function () { - $('input,select,textarea', this).clearFields(includeHidden); - }); - }; - - /** - * Clears the selected form elements. - */ - $.fn.clearFields = $.fn.clearInputs = function (includeHidden) { - var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list - return this.each(function () { - var t = this.type, tag = this.tagName.toLowerCase(); - if (re.test(t) || tag == 'textarea') { - this.value = ''; - } - else if (t == 'checkbox' || t == 'radio') { - this.checked = false; - } - else if (tag == 'select') { - this.selectedIndex = -1; - } - else if (includeHidden) { - // includeHidden can be the value true, or it can be a selector string - // indicating a special test; for example: - // $('#myForm').clearForm('.special:hidden') - // the above would clean hidden inputs that have the class of 'special' - if ((includeHidden === true && /hidden/.test(t)) || - (typeof includeHidden == 'string' && $(this).is(includeHidden))) - this.value = ''; - } - }); - }; - - /** - * Resets the form data. Causes all form elements to be reset to their original value. - */ - $.fn.resetForm = function () { - return this.each(function () { - // guard against an input with the name of 'reset' - // note that IE reports the reset function as an 'object' - if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) { - this.reset(); - } - }); - }; - - /** - * Enables or disables any matching elements. - */ - $.fn.enable = function (b) { - if (b === undefined) { - b = true; - } - return this.each(function () { - this.disabled = !b; - }); - }; - - /** - * Checks/unchecks any matching checkboxes or radio buttons and - * selects/deselects and matching option elements. - */ - $.fn.selected = function (select) { - if (select === undefined) { - select = true; - } - return this.each(function () { - var t = this.type; - if (t == 'checkbox' || t == 'radio') { - this.checked = select; - } - else if (this.tagName.toLowerCase() == 'option') { - var $sel = $(this).parent('select'); - if (select && $sel[0] && $sel[0].type == 'select-one') { - // deselect all other options - $sel.find('option').selected(false); - } - this.selected = select; - } - }); - }; - -// expose debug var - $.fn.ajaxSubmit.debug = false; - -// helper fn for console logging - function log() { - if (!$.fn.ajaxSubmit.debug) - return; - var msg = '[jquery.form] ' + Array.prototype.join.call(arguments, ''); - if (window.console && window.console.log) { - window.console.log(msg); - } - else if (window.opera && window.opera.postError) { - window.opera.postError(msg); - } - } - -})(jQuery); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2965258e/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery.form.min.js ---------------------------------------------------------------------- diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery.form.min.js b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery.form.min.js new file mode 100644 index 0000000..7321a3b --- /dev/null +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery.form.min.js @@ -0,0 +1,11 @@ +/*! + * jQuery Form Plugin + * version: 3.51.0-2014.06.20 + * Requires jQuery v1.5 or later + * Copyright (c) 2014 M. Alsup + * Examples and documentation at: http://malsup.com/jquery/form/ + * Project repository: https://github.com/malsup/form + * Dual licensed under the MIT and GPL licenses. + * https://github.com/malsup/form#copyright-and-license + */ +!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("undefined"!=typeof jQuery?jQuery:window.Zepto)}(function(e){"use strict";function t(t){var r=t.data;t.isDefaultPrevented()||(t.preventDefault(),e(t.target).ajaxSubmit(r))}function r(t){var r=t.target,a=e(r);if(!a.is("[type=submit],[type=image]")){var n=a.closest("[type=submit]");if(0===n.length)return;r=n[0]}var i=this;if(i.clk=r,"image"==r.type)if(void 0!==t.offsetX)i.clk_x=t.offsetX,i.clk_y=t.offsetY;else if("function"==typeof e.fn.offset){var o=a.offset();i.clk_x=t.pageX-o.left,i.clk_y=t.pageY-o.top}else i.clk_x=t.pageX-r.offsetLeft,i.clk_y=t.pageY-r.offsetTop;setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)}function a(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}var n={};n.fileapi=void 0!==e("<input type='file'/>").get(0) .files,n.formdata=void 0!==window.FormData;var i=!!e.fn.prop;e.fn.attr2=function(){if(!i)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t){function r(r){var a,n,i=e.param(r,t.traditional).split("&"),o=i.length,s=[];for(a=0;o>a;a++)i[a]=i[a].replace(/\+/g," "),n=i[a].split("="),s.push([decodeURIComponent(n[0]),decodeURIComponent(n[1])]);return s}function o(a){for(var n=new FormData,i=0;i<a.length;i++)n.append(a[i].name,a[i].value);if(t.extraData){var o=r(t.extraData);for(i=0;i<o.length;i++)o[i]&&n.append(o[i][0],o[i][1])}t.data=null;var s=e.extend(!0,{},e.ajaxSettings,t,{contentType:!1,processData:!1,cache:!1,type:u||"POST"});t.uploadProgress&&(s.xhr=function(){var r=e.ajaxSettings.xhr();return r.upload&&r.upload.addEventListener("progress",function(e){var r=0,a=e.loaded||e.position,n=e.total;e.lengthComputable&&(r=Math.ceil(a/n*100)),t.uploadProgress(e,a,n ,r)},!1),r}),s.data=null;var c=s.beforeSend;return s.beforeSend=function(e,r){r.data=t.formData?t.formData:n,c&&c.call(this,e,r)},e.ajax(s)}function s(r){function n(e){var t=null;try{e.contentWindow&&(t=e.contentWindow.document)}catch(r){a("cannot get iframe.contentWindow document: "+r)}if(t)return t;try{t=e.contentDocument?e.contentDocument:e.document}catch(r){a("cannot get iframe.contentDocument: "+r),t=e.document}return t}function o(){function t(){try{var e=n(g).readyState;a("state = "+e),e&&"uninitialized"==e.toLowerCase()&&setTimeout(t,50)}catch(r){a("Server abort: ",r," (",r.name,")"),s(k),j&&clearTimeout(j),j=void 0}}var r=f.attr2("target"),i=f.attr2("action"),o="multipart/form-data",c=f.attr("enctype")||f.attr("encoding")||o;w.setAttribute("target",p),(!u||/post/i.test(u))&&w.setAttribute("method","POST"),i!=m.url&&w.setAttribute("action",m.url),m.skipEncodingOverride||u&&!/post/i.test(u)||f.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),m.timeout&&(j=s etTimeout(function(){T=!0,s(D)},m.timeout));var l=[];try{if(m.extraData)for(var d in m.extraData)m.extraData.hasOwnProperty(d)&&l.push(e.isPlainObject(m.extraData[d])&&m.extraData[d].hasOwnProperty("name")&&m.extraData[d].hasOwnProperty("value")?e('<input type="hidden" name="'+m.extraData[d].name+'">').val(m.extraData[d].value).appendTo(w)[0]:e('<input type="hidden" name="'+d+'">').val(m.extraData[d]).appendTo(w)[0]);m.iframeTarget||v.appendTo("body"),g.attachEvent?g.attachEvent("onload",s):g.addEventListener("load",s,!1),setTimeout(t,15);try{w.submit()}catch(h){var x=document.createElement("form").submit;x.apply(w)}}finally{w.setAttribute("action",i),w.setAttribute("enctype",c),r?w.setAttribute("target",r):f.removeAttr("target"),e(l).remove()}}function s(t){if(!x.aborted&&!F){if(M=n(g),M||(a("cannot access response document"),t=k),t===D&&x)return x.abort("timeout"),void S.reject(x,"timeout");if(t==k&&x)return x.abort("server abort"),void S.reject(x,"error","server abort");if(M&&M.l ocation.href!=m.iframeSrc||T){g.detachEvent?g.detachEvent("onload",s):g.removeEventListener("load",s,!1);var r,i="success";try{if(T)throw"timeout";var o="xml"==m.dataType||M.XMLDocument||e.isXMLDoc(M);if(a("isXml="+o),!o&&window.opera&&(null===M.body||!M.body.innerHTML)&&--O)return a("requeing onLoad callback, DOM not available"),void setTimeout(s,250);var u=M.body?M.body:M.documentElement;x.responseText=u?u.innerHTML:null,x.responseXML=M.XMLDocument?M.XMLDocument:M,o&&(m.dataType="xml"),x.getResponseHeader=function(e){var t={"content-type":m.dataType};return t[e.toLowerCase()]},u&&(x.status=Number(u.getAttribute("status"))||x.status,x.statusText=u.getAttribute("statusText")||x.statusText);var c=(m.dataType||"").toLowerCase(),l=/(json|script|text)/.test(c);if(l||m.textarea){var f=M.getElementsByTagName("textarea")[0];if(f)x.responseText=f.value,x.status=Number(f.getAttribute("status"))||x.status,x.statusText=f.getAttribute("statusText")||x.statusText;else if(l){var p=M.getElementsBy TagName("pre")[0],h=M.getElementsByTagName("body")[0];p?x.responseText=p.textContent?p.textContent:p.innerText:h&&(x.responseText=h.textContent?h.textContent:h.innerText)}}else"xml"==c&&!x.responseXML&&x.responseText&&(x.responseXML=X(x.responseText));try{E=_(x,c,m)}catch(y){i="parsererror",x.error=r=y||i}}catch(y){a("error caught: ",y),i="error",x.error=r=y||i}x.aborted&&(a("upload aborted"),i=null),x.status&&(i=x.status>=200&&x.status<300||304===x.status?"success":"error"),"success"===i?(m.success&&m.success.call(m.context,E,"success",x),S.resolve(x.responseText,"success",x),d&&e.event.trigger("ajaxSuccess",[x,m])):i&&(void 0===r&&(r=x.statusText),m.error&&m.error.call(m.context,x,i,r),S.reject(x,"error",r),d&&e.event.trigger("ajaxError",[x,m,r])),d&&e.event.trigger("ajaxComplete",[x,m]),d&&!--e.active&&e.event.trigger("ajaxStop"),m.complete&&m.complete.call(m.context,x,i),F=!0,m.timeout&&clearTimeout(j),setTimeout(function(){m.iframeTarget?v.attr("src",m.iframeSrc):v.remove(),x.r esponseXML=null},100)}}}var c,l,m,d,p,v,g,x,y,b,T,j,w=f[0],S=e.Deferred();if(S.abort=function(e){x.abort(e)},r)for(l=0;l<h.length;l++)c=e(h[l]),i?c.prop("disabled",!1):c.removeAttr("disabled");if(m=e.extend(!0,{},e.ajaxSettings,t),m.context=m.context||m,p="jqFormIO"+(new Date).getTime(),m.iframeTarget?(v=e(m.iframeTarget),b=v.attr2("name"),b?p=b:v.attr2("name",p)):(v=e('<iframe name="'+p+'" src="'+m.iframeSrc+'" />'),v.css({position:"absolute",top:"-1000px",left:"-1000px"})),g=v[0],x={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(t){var r="timeout"===t?"timeout":"aborted";a("aborting upload... "+r),this.aborted=1;try{g.contentWindow.document.execCommand&&g.contentWindow.document.execCommand("Stop")}catch(n){}v.attr("src",m.iframeSrc),x.error=r,m.error&&m.error.call(m.context,x,r,t),d&&e.event.trigger("ajaxError",[x,m,r]),m.complete&&m.complete.call( m.context,x,r)}},d=m.global,d&&0===e.active++&&e.event.trigger("ajaxStart"),d&&e.event.trigger("ajaxSend",[x,m]),m.beforeSend&&m.beforeSend.call(m.context,x,m)===!1)return m.global&&e.active--,S.reject(),S;if(x.aborted)return S.reject(),S;y=w.clk,y&&(b=y.name,b&&!y.disabled&&(m.extraData=m.extraData||{},m.extraData[b]=y.value,"image"==y.type&&(m.extraData[b+".x"]=w.clk_x,m.extraData[b+".y"]=w.clk_y)));var D=1,k=2,A=e("meta[name=csrf-token]").attr("content"),L=e("meta[name=csrf-param]").attr("content");L&&A&&(m.extraData=m.extraData||{},m.extraData[L]=A),m.forceSync?o():setTimeout(o,10);var E,M,F,O=50,X=e.parseXML||function(e,t){return window.ActiveXObject?(t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!=t.documentElement.nodeName?t:null},C=e.parseJSON||function(e){return window.eval("("+e+")")},_=function(t,r,a){var n=t.getResponseHeader("content-type")||"",i="xml"===r||!r&&n.i ndexOf("xml")>=0,o=i?t.responseXML:t.responseText;return i&&"parsererror"===o.documentElement.nodeName&&e.error&&e.error("parsererror"),a&&a.dataFilter&&(o=a.dataFilter(o,r)),"string"==typeof o&&("json"===r||!r&&n.indexOf("json")>=0?o=C(o):("script"===r||!r&&n.indexOf("javascript")>=0)&&e.globalEval(o)),o};return S}if(!this.length)return a("ajaxSubmit: skipping submit process - no element selected"),this;var u,c,l,f=this;"function"==typeof t?t={success:t}:void 0===t&&(t={}),u=t.type||this.attr2("method"),c=t.url||this.attr2("action"),l="string"==typeof c?e.trim(c):"",l=l||window.location.href||"",l&&(l=(l.match(/^([^#]+)/)||[])[1]),t=e.extend(!0,{url:l,success:e.ajaxSettings.success,type:u||e.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},t);var m={};if(this.trigger("form-pre-serialize",[this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(t.beforeSerialize&&t.beforeSerialize(this,t)=== !1)return a("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var d=t.traditional;void 0===d&&(d=e.ajaxSettings.traditional);var p,h=[],v=this.formToArray(t.semantic,h);if(t.data&&(t.extraData=t.data,p=e.param(t.data,d)),t.beforeSubmit&&t.beforeSubmit(v,this,t)===!1)return a("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[v,this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;var g=e.param(v,d);p&&(g=g?g+"&"+p:p),"GET"==t.type.toUpperCase()?(t.url+=(t.url.indexOf("?")>=0?"&":"?")+g,t.data=null):t.data=g;var x=[];if(t.resetForm&&x.push(function(){f.resetForm()}),t.clearForm&&x.push(function(){f.clearForm(t.includeHidden)}),!t.dataType&&t.target){var y=t.success||function(){};x.push(function(r){var a=t.replaceTarget?"replaceWith":"html";e(t.target)[a](r).each(y,arguments)})}else t.success&&x.push(t.success);if(t.success=function(e,r,a){for(var n=t.context||this,i=0,o=x.length;o> i;i++)x[i].apply(n,[e,r,a||f,f])},t.error){var b=t.error;t.error=function(e,r,a){var n=t.context||this;b.apply(n,[e,r,a,f])}}if(t.complete){var T=t.complete;t.complete=function(e,r){var a=t.context||this;T.apply(a,[e,r,f])}}var j=e("input[type=file]:enabled",this).filter(function(){return""!==e(this).val()}),w=j.length>0,S="multipart/form-data",D=f.attr("enctype")==S||f.attr("encoding")==S,k=n.fileapi&&n.formdata;a("fileAPI :"+k);var A,L=(w||D)&&!k;t.iframe!==!1&&(t.iframe||L)?t.closeKeepAlive?e.get(t.closeKeepAlive,function(){A=s(v)}):A=s(v):A=(w||D)&&k?o(v):e.ajax(t),f.removeData("jqxhr").data("jqxhr",A);for(var E=0;E<h.length;E++)h[E]=null;return this.trigger("form-submit-notify",[this,t]),this},e.fn.ajaxForm=function(n){if(n=n||{},n.delegation=n.delegation&&e.isFunction(e.fn.on),!n.delegation&&0===this.length){var i={s:this.selector,c:this.context};return!e.isReady&&i.s?(a("DOM not ready, queuing ajaxForm"),e(function(){e(i.s,i.c).ajaxForm(n)}),this):(a("terminating; zero elemen ts found by selector"+(e.isReady?"":" (DOM not ready)")),this)}return n.delegation?(e(document).off("submit.form-plugin",this.selector,t).off("click.form-plugin",this.selector,r).on("submit.form-plugin",this.selector,n,t).on("click.form-plugin",this.selector,n,r),this):this.ajaxFormUnbind().bind("submit.form-plugin",n,t).bind("click.form-plugin",n,r)},e.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")},e.fn.formToArray=function(t,r){var a=[];if(0===this.length)return a;var i,o=this[0],s=this.attr("id"),u=t?o.getElementsByTagName("*"):o.elements;if(u&&!/MSIE [678]/.test(navigator.userAgent)&&(u=e(u).get()),s&&(i=e(':input[form="'+s+'"]').get(),i.length&&(u=(u||[]).concat(i))),!u||!u.length)return a;var c,l,f,m,d,p,h;for(c=0,p=u.length;p>c;c++)if(d=u[c],f=d.name,f&&!d.disabled)if(t&&o.clk&&"image"==d.type)o.clk==d&&(a.push({name:f,value:e(d).val(),type:d.type}),a.push({name:f+".x",value:o.clk_x},{name:f+".y",value:o.clk_y}));else if(m=e.fieldValu e(d,!0),m&&m.constructor==Array)for(r&&r.push(d),l=0,h=m.length;h>l;l++)a.push({name:f,value:m[l]});else if(n.fileapi&&"file"==d.type){r&&r.push(d);var v=d.files;if(v.length)for(l=0;l<v.length;l++)a.push({name:f,value:v[l],type:d.type});else a.push({name:f,value:"",type:d.type})}else null!==m&&"undefined"!=typeof m&&(r&&r.push(d),a.push({name:f,value:m,type:d.type,required:d.required}));if(!t&&o.clk){var g=e(o.clk),x=g[0];f=x.name,f&&!x.disabled&&"image"==x.type&&(a.push({name:f,value:g.val()}),a.push({name:f+".x",value:o.clk_x},{name:f+".y",value:o.clk_y}))}return a},e.fn.formSerialize=function(t){return e.param(this.formToArray(t))},e.fn.fieldSerialize=function(t){var r=[];return this.each(function(){var a=this.name;if(a){var n=e.fieldValue(this,t);if(n&&n.constructor==Array)for(var i=0,o=n.length;o>i;i++)r.push({name:a,value:n[i]});else null!==n&&"undefined"!=typeof n&&r.push({name:this.name,value:n})}}),e.param(r)},e.fn.fieldValue=function(t){for(var r=[],a=0,n=this.length;n>a;a ++){var i=this[a],o=e.fieldValue(i,t);null===o||"undefined"==typeof o||o.constructor==Array&&!o.length||(o.constructor==Array?e.merge(r,o):r.push(o))}return r},e.fieldValue=function(t,r){var a=t.name,n=t.type,i=t.tagName.toLowerCase();if(void 0===r&&(r=!0),r&&(!a||t.disabled||"reset"==n||"button"==n||("checkbox"==n||"radio"==n)&&!t.checked||("submit"==n||"image"==n)&&t.form&&t.form.clk!=t||"select"==i&&-1==t.selectedIndex))return null;if("select"==i){var o=t.selectedIndex;if(0>o)return null;for(var s=[],u=t.options,c="select-one"==n,l=c?o+1:u.length,f=c?o:0;l>f;f++){var m=u[f];if(m.selected){var d=m.value;if(d||(d=m.attributes&&m.attributes.value&&!m.attributes.value.specified?m.text:m.value),c)return d;s.push(d)}}return s}return e(t).val()},e.fn.clearForm=function(t){return this.each(function(){e("input,select,textarea",this).clearFields(t)})},e.fn.clearFields=e.fn.clearInputs=function(t){var r=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week )$/i;return this.each(function(){var a=this.type,n=this.tagName.toLowerCase();r.test(a)||"textarea"==n?this.value="":"checkbox"==a||"radio"==a?this.checked=!1:"select"==n?this.selectedIndex=-1:"file"==a?/MSIE/.test(navigator.userAgent)?e(this).replaceWith(e(this).clone(!0)):e(this).val(""):t&&(t===!0&&/hidden/.test(a)||"string"==typeof t&&e(this).is(t))&&(this.value="")})},e.fn.resetForm=function(){return this.each(function(){("function"==typeof this.reset||"object"==typeof this.reset&&!this.reset.nodeType)&&this.reset()})},e.fn.enable=function(e){return void 0===e&&(e=!0),this.each(function(){this.disabled=!e})},e.fn.selected=function(t){return void 0===t&&(t=!0),this.each(function(){var r=this.type;if("checkbox"==r||"radio"==r)this.checked=t;else if("option"==this.tagName.toLowerCase()){var a=e(this).parent("select");t&&a[0]&&"select-one"==a[0].type&&a.find("option").selected(!1),this.selected=t}})},e.fn.ajaxSubmit.debug=!1}); \ No newline at end of file