You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2018/05/30 16:05:24 UTC
[myfaces-tobago] branch master updated: TOBAGO-1902: Migrate to
jQuery 3
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new 795bbcd TOBAGO-1902: Migrate to jQuery 3
795bbcd is described below
commit 795bbcdef5ea09213a1009af7aa68db56ef3d907
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Wed May 30 18:04:36 2018 +0200
TOBAGO-1902: Migrate to jQuery 3
Preparation: compatibel changes (resp. jQuery 2.2.4)
---
.../30-concept/70-dataAttribute/dataAttribute.js | 2 +-
.../100-id-markup/id-markup.test.js | 24 +++++++-------
.../40-test/90000-attic/object/object-full.xhtml | 2 +-
.../sheet/sheet-auto-height-header-footer.xhtml | 2 +-
.../src/main/webapp/script/tobago-test.js | 2 +-
.../src/main/webapp/script/tobago-testAll.js | 2 +-
.../tobago-bootstrap/_version/js/tobago-sheet.js | 18 +++++-----
.../tobago-bootstrap/_version/js/tobago-tree.js | 6 ++--
.../tobago-bootstrap/_version/js/tobago.js | 38 +++++++++++-----------
9 files changed, 48 insertions(+), 48 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/70-dataAttribute/dataAttribute.js b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/70-dataAttribute/dataAttribute.js
index f739d07..b9132d2 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/70-dataAttribute/dataAttribute.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/70-dataAttribute/dataAttribute.js
@@ -16,7 +16,7 @@
*/
/*
- jQuery(document).ready(function () {
+ jQuery(function () {
jQuery("[data-colored]")
.css("background-color", "#aaaaaa")
.click(function () {
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4800-labelLayout/100-id-markup/id-markup.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4800-labelLayout/100-id-markup/id-markup.test.js
index d45a7a2..55fd4f2 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4800-labelLayout/100-id-markup/id-markup.test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4800-labelLayout/100-id-markup/id-markup.test.js
@@ -28,7 +28,7 @@ QUnit.test("No label set", function (assert) {
assert.equal($input.attr('id'), "page:mainForm:inNoLabel::field");
assert.equal($input.attr('name'), "page:mainForm:inNoLabel");
- assert.equal(jQuery.parseJSON($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("labelLayout=none", function (assert) {
@@ -44,7 +44,7 @@ QUnit.test("labelLayout=none", function (assert) {
assert.equal($input.attr('id'), "page:mainForm:inNone::field");
assert.equal($input.attr('name'), "page:mainForm:inNone");
- assert.equal(jQuery.parseJSON($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("labelLayout=skip", function (assert) {
@@ -57,7 +57,7 @@ QUnit.test("labelLayout=skip", function (assert) {
assert.equal($label.length, 0);
assert.equal($rootInput.attr('id'), "page:mainForm:inSkip");
- assert.equal(jQuery.parseJSON($rootInput.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($rootInput.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("labelLayout=top", function (assert) {
@@ -73,7 +73,7 @@ QUnit.test("labelLayout=top", function (assert) {
assert.equal($input.attr('id'), "page:mainForm:inTop::field");
assert.equal($input.attr('name'), "page:mainForm:inTop");
- assert.equal(jQuery.parseJSON($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("labelLayout=flowLeft", function (assert) {
@@ -89,7 +89,7 @@ QUnit.test("labelLayout=flowLeft", function (assert) {
assert.equal($input.attr('id'), "page:mainForm:inFlowLeft::field");
assert.equal($input.attr('name'), "page:mainForm:inFlowLeft");
- assert.equal(jQuery.parseJSON($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("labelLayout=flowRight", function (assert) {
@@ -105,7 +105,7 @@ QUnit.test("labelLayout=flowRight", function (assert) {
assert.equal($input.attr('id'), "page:mainForm:inFlowRight::field");
assert.equal($input.attr('name'), "page:mainForm:inFlowRight");
- assert.equal(jQuery.parseJSON($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("labelLayout=flexLeft", function (assert) {
@@ -121,7 +121,7 @@ QUnit.test("labelLayout=flexLeft", function (assert) {
assert.equal($input.attr('id'), "page:mainForm:inFlexLeft::field");
assert.equal($input.attr('name'), "page:mainForm:inFlexLeft");
- assert.equal(jQuery.parseJSON($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("labelLayout=flexRight", function (assert) {
@@ -137,7 +137,7 @@ QUnit.test("labelLayout=flexRight", function (assert) {
assert.equal($input.attr('id'), "page:mainForm:inFlexRight::field");
assert.equal($input.attr('name'), "page:mainForm:inFlexRight");
- assert.equal(jQuery.parseJSON($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($rootDiv.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("labelLayout=segmentLeft", function (assert) {
@@ -156,8 +156,8 @@ QUnit.test("labelLayout=segmentLeft", function (assert) {
assert.equal($input.attr('id'), "page:mainForm:inSegmentLeft::field");
assert.equal($input.attr('name'), "page:mainForm:inSegmentLeft");
- assert.equal(jQuery.parseJSON($labelSegment.attr('data-tobago-markup'))[0], "testmarkup");
- assert.equal(jQuery.parseJSON($inputSegment.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($labelSegment.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($inputSegment.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("labelLayout=segmentRight", function (assert) {
@@ -176,8 +176,8 @@ QUnit.test("labelLayout=segmentRight", function (assert) {
assert.equal($input.attr('id'), "page:mainForm:inSegmentRight::field");
assert.equal($input.attr('name'), "page:mainForm:inSegmentRight");
- assert.equal(jQuery.parseJSON($labelSegment.attr('data-tobago-markup'))[0], "testmarkup");
- assert.equal(jQuery.parseJSON($inputSegment.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($labelSegment.attr('data-tobago-markup'))[0], "testmarkup");
+ assert.equal(JSON.parse($inputSegment.attr('data-tobago-markup'))[0], "testmarkup");
});
QUnit.test("Number of data-tobago-markup attributes", function (assert) {
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/object/object-full.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/object/object-full.xhtml
index a36cb7a..640d3fe 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/object/object-full.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/object/object-full.xhtml
@@ -31,7 +31,7 @@
* XXX We may find a better solution (e. g. partially switch off layout)
*/
- jQuery(document).ready(function () {
+ jQuery(function () {
jQuery("form").css("width", "100%");
jQuery("form").css("height", "100%");
jQuery(".tobago-page-content").css("width", "100%");
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/sheet/sheet-auto-height-header-footer.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/sheet/sheet-auto-height-header-footer.xhtml
index 2d1d7af..bf44a67 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/sheet/sheet-auto-height-header-footer.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/90000-attic/sheet/sheet-auto-height-header-footer.xhtml
@@ -91,7 +91,7 @@
<tc:script file="script/tobago-assert.js"/>
<tc:script>
- jQuery(document).ready(function () {
+ jQuery(function () {
jQuery("td>span").css("background-color", "white");
jQuery("td:odd").css("background-color", "#ffbbff");
jQuery("td:even").css("background-color", "#bbffbb");
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js b/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js
index 3974cfa..d688854 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js
@@ -158,7 +158,7 @@ TobagoTestTools.prototype = {
TobagoFrame().registerListener(detectAjaxResponse, TobagoFrame().Phase.AFTER_UPDATE);
- jQuery("#page\\:testframe").load(function () {
+ jQuery("#page\\:testframe").on("load", function () {
if (!isFinished() && !isTimeout()) {
responses++;
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-testAll.js b/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-testAll.js
index ce62d70..31bce5d 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-testAll.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/script/tobago-testAll.js
@@ -17,7 +17,7 @@
Tobago.registerListener(function() {
jQuery("iframe").each(function() {
- jQuery(this).load(function() {
+ jQuery(this).on("load", function() {
var idCount = jQuery(this).attr("id").substring(7);
var $thisFrame = jQuery("#page\\:tp" + idCount);
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-sheet.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-sheet.js
index 3936ca1..2b5f948 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-sheet.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-sheet.js
@@ -269,11 +269,11 @@ Tobago.Sheet.setup2 = function (sheets) {
// set to the body
bodyCols.eq(headerBodyColCount).attr("width", newWidth);
// reset the width inside of the cells (TD) if the value was changed.
- var tds = jQuery("td:nth-child(" + (headerBodyColCount + 1) + ")", bodyTable);
- if (tds.size() > 0) {
- var innerWidth = tds.children().eq(0).width() - oldWidthList[headerBodyColCount] + newWidth;
+ var $tds = jQuery("td:nth-child(" + (headerBodyColCount + 1) + ")", bodyTable);
+ if ($tds.length > 0) {
+ var innerWidth = $tds.children().eq(0).width() - oldWidthList[headerBodyColCount] + newWidth;
// setting all sizes of the inner cells to the same value
- tds.children().width(innerWidth);
+ $tds.children().width(innerWidth);
// XXX later, if we have box-sizing: border-box we can set the width to 100%
}
}
@@ -364,7 +364,7 @@ Tobago.Sheet.setup2 = function (sheets) {
var selectionMode = $sheet.data("tobago-selection-mode");
- if ((!event.ctrlKey && !event.metaKey && $selector.size() === 0)
+ if ((!event.ctrlKey && !event.metaKey && $selector.length === 0)
|| selectionMode === "single" || selectionMode === "singleOrNone") {
Tobago.Sheet.deselectAll($sheet);
Tobago.Sheet.resetSelected($sheet);
@@ -603,21 +603,21 @@ Tobago.Sheet.toggleSelection = function($sheet, $row, $checkbox) {
Tobago.Sheet.selectAll = function($sheet) {
var $rows = Tobago.Sheet.getRows($sheet);
- Tobago.Sheet.selectRange($sheet, $rows, 0, $rows.size() - 1, true, false);
+ Tobago.Sheet.selectRange($sheet, $rows, 0, $rows.length - 1, true, false);
};
Tobago.Sheet.deselectAll = function($sheet) {
var $rows = Tobago.Sheet.getRows($sheet);
- Tobago.Sheet.selectRange($sheet, $rows, 0, $rows.size() - 1, false, true);
+ Tobago.Sheet.selectRange($sheet, $rows, 0, $rows.length - 1, false, true);
};
Tobago.Sheet.toggleAll = function(sheet) {
var rows = Tobago.Sheet.getRows(sheet);
- Tobago.Sheet.selectRange(sheet, rows, 0, rows.size() - 1, true, true);
+ Tobago.Sheet.selectRange(sheet, rows, 0, rows.length - 1, true, true);
};
Tobago.Sheet.selectRange = function($sheet, $rows, first, last, selectDeselected, deselectSelected) {
- if ($rows.size() === 0) {
+ if ($rows.length === 0) {
return;
}
var selected = Tobago.Sheet.findHiddenSelected($sheet);
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-tree.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-tree.js
index 025fce1..ba0bba9 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-tree.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-tree.js
@@ -128,7 +128,7 @@ Tobago.Tree.init = function(elements) {
Tobago.Utils.selectWithJQuery(elements, ".tobago-treeMenuNode-markup-folder .tobago-treeMenuNode-toggle")
.parent().each(function() {
// if there is no command, than the whole node element should be the toggle
- var toggle = jQuery(this).children(".tobago-treeMenuCommand").size() == 0
+ var toggle = jQuery(this).children(".tobago-treeMenuCommand").length === 0
? jQuery(this)
: jQuery(this).find(".tobago-treeMenuNode-toggle");
toggle.click(function(event) {
@@ -159,7 +159,7 @@ Tobago.Tree.init = function(elements) {
var data = select.closest(".tobago-treeMenu, .tobago-tree, .tobago-sheet");
var hidden = data.children(".tobago-treeMenu-selected, .tobago-tree-selected, .tobago-sheet-selected");
var newValue;
- if (select.attr("type") == "radio") {
+ if (select.attr("type") === "radio") {
newValue = "," + Tobago.Tree.rowIndex(select) + ",";
} else if (selected) {
newValue = hidden.val() + Tobago.Tree.rowIndex(select) + ",";
@@ -241,7 +241,7 @@ Tobago.Tree.findChildren = function (node) {
};
Tobago.Tree.isInSheet = function(node) {
- return node.parent("td").size() == 1;
+ return node.parent("td").length === 1;
};
Tobago.registerListener(Tobago.Tree.init, Tobago.Phase.DOCUMENT_READY);
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago.js
index 8caad1b..e393034 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago.js
@@ -592,13 +592,13 @@ var Tobago = {
var $hasDanger = Tobago.Utils.selectWithJQuery(elements, '.has-danger');
var $dangerInput = $hasDanger.find("*").filter(":input:enabled:visible:first");
- if ($dangerInput.size() > 0) {
+ if ($dangerInput.length > 0) {
Tobago.setFocus($dangerInput);
return;
}
var $autoFocus = Tobago.Utils.selectWithJQuery(elements, '[autofocus]');
- var hasAutoFocus = $autoFocus.size() > 0;
+ var hasAutoFocus = $autoFocus.length > 0;
if (hasAutoFocus) {
// nothing to do, because the browser make the work.
@@ -622,7 +622,7 @@ var Tobago = {
}
var $firstInput = jQuery(":input:enabled:visible:not(button):not([tabindex='-1']):first");
- if ($firstInput.size() > 0) {
+ if ($firstInput.length > 0) {
Tobago.setFocus($firstInput);
return;
}
@@ -873,7 +873,7 @@ jQuery(document).ready(function() {
Tobago.init();
});
-jQuery(window).load(function() {
+jQuery(window).on("load", function() {
for (var order = 0; order < Tobago.listeners.windowLoad.length; order++) {
var list = Tobago.listeners.windowLoad[order];
for (var i = 0; i < list.length; i++) {
@@ -1074,7 +1074,7 @@ Tobago.Command.initEnter = function(elements) {
var id = target.name ? target.name : target.id;
while (id != null) {
var command = jQuery("[data-tobago-default='" + id + "']");
- if (command.size() > 0) {
+ if (command.length > 0) {
command.click();
break;
}
@@ -1119,27 +1119,27 @@ Tobago.SelectManyShuttle.init = function(elements) {
});
};
-Tobago.SelectManyShuttle.moveSelectedItems = function(shuttle, direction, all) {
- var unselected = shuttle.find(".tobago-selectManyShuttle-unselected");
- var selected = shuttle.find(".tobago-selectManyShuttle-selected");
- var count = selected.children().size();
- var source = direction ? unselected : selected;
- var target = direction ? selected : unselected;
- var shifted = source.find(all ? "option:not(:disabled)" : "option:selected").remove().appendTo(target);
+Tobago.SelectManyShuttle.moveSelectedItems = function($shuttle, direction, all) {
+ var $unselected = $shuttle.find(".tobago-selectManyShuttle-unselected");
+ var $selected = $shuttle.find(".tobago-selectManyShuttle-selected");
+ var count = $selected.children().length;
+ var $source = direction ? $unselected : $selected;
+ var $target = direction ? $selected : $unselected;
+ var $shifted = $source.find(all ? "option:not(:disabled)" : "option:selected").remove().appendTo($target);
// synchronize the hidden select
- var hidden = shuttle.find(".tobago-selectManyShuttle-hidden");
- var hiddenOptions = hidden.find("option");
+ var $hidden = $shuttle.find(".tobago-selectManyShuttle-hidden");
+ var $hiddenOptions = $hidden.find("option");
// todo: may be optimized: put values in a hash map?
- shifted.each(function() {
- var option = jQuery(this);
- hiddenOptions.filter("[value='" + option.val() + "']").prop("selected", direction);
+ $shifted.each(function() {
+ var $option = jQuery(this);
+ $hiddenOptions.filter("[value='" + $option.val() + "']").prop("selected", direction);
});
- if (count != selected.children().size()) {
+ if (count !== $selected.children().length) {
var e = jQuery.Event("change");
// trigger an change event for command facets
- hidden.trigger( e );
+ $hidden.trigger( e );
}
};
--
To stop receiving notification emails like this one, please contact
lofwyr@apache.org.