Skip to content

Commit

Permalink
Merge pull request #2209 from IgniteUI/deprecated-delegate
Browse files Browse the repository at this point in the history
chore(*): removing deprecated $.delegate()
  • Loading branch information
ChronosSF authored Oct 5, 2022
2 parents 8489eb2 + 993a009 commit 8eaa8f6
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 94 deletions.
2 changes: 1 addition & 1 deletion src/js/modules/infragistics.ui.colorpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
},
_bindEvents: function () {
var self = this;
this._colorTable.delegate("." + this.css.colorpickerColor, "click", function (e) {
this._colorTable.on("click", "." + this.css.colorpickerColor, function (e) {
var target = $(e.target);
e.preventDefault();

Expand Down
6 changes: 3 additions & 3 deletions src/js/modules/infragistics.ui.htmleditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@
igtoolbarexpanded: this.events.toolbarExpanded
};

this._toolbars.delegate(":ui-igToolbar", events,
this._toolbars.on(events, ":ui-igToolbar",
function _onToolbarItemClick(e, ui) {
var scope = ui.scope,
handler = ui.handler,
Expand Down Expand Up @@ -2852,7 +2852,7 @@
rows = tablePreview.find("tr"),
self = this;

tablePreview.delegate("td", "mouseover", function (e) {
tablePreview.on("mouseover", "td", function (e) {
var target = $(e.target),
currentRowNumber = target.parent().index() + 1,
currentColumnNumber = $(this).index() + 1,
Expand All @@ -2868,7 +2868,7 @@
self.columnsNumField.val(currentColumnNumber);
});

tablePreview.delegate("td", "click", function (e) {
tablePreview.on("click", "td", function (e) {
var target = $(e.target),
currentRowNumber = target.parent().index() + 1,
currentColumnNumber = $(this).index() + 1;
Expand Down
100 changes: 46 additions & 54 deletions src/js/modules/infragistics.ui.tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@
}
},
_setOption: function (option, value) {
var css = this.css, elements, prevValue = this.options[ option ];
var elements, css = this.css, prevValue = this.options[ option ];
this._super(option, value);

switch (option) {
Expand Down Expand Up @@ -1872,22 +1872,20 @@
if (value) {

// K.D. August 16th, 2013 Bug #149438 Switching to delegated events
this.element.delegate("a", {
"mouseover": function (event) {
$(event.target).addClass(css.nodeHovered);
},
"mouseout": function (event) {
$(event.target).removeClass(css.nodeHovered);
}
this.element.on("mouseover", "a", function (event) {
$(event.target).addClass(css.nodeHovered);
});
this.element.on("mouseout", "a", function (event) {
$(event.target).removeClass(css.nodeHovered);
});
} else {

// K.D. August 16th, 2013 Bug #149438 Switching to delegated events
this.element.undelegate("a", "mouseover");
this.element.undelegate("a", "mouseout");
this.element.off("mouseover", "a");
this.element.off("mouseout", "a");
}
break;
case "checkboxMode":
case "checkboxMode":

// K.D. February 10th, 2014 Bug #163522 When the igTree is initialized with checkboxMode = off setting its value to biState is not possible
if (value.toLowerCase() === "off") {
Expand Down Expand Up @@ -2519,7 +2517,7 @@
this.element.droppable(dropOptions);

// K.D. August 16th, 2013 Bug #149438 Switching to delegated events
this.element.delegate("a", "mousedown", function () {
this.element.on("mousedown", "a", function () {
$(this).focus();
});
} else {
Expand All @@ -2530,7 +2528,7 @@
_destroyDragAndDrop: function () {
this.element.find("li[data-role=node]").draggable("destroy");
this.element.droppable("destroy");
this.element.undelegate("a", "mousedown");
this.element.off( "mousedown", "a");
},
_constructFromData: function () {
var ul, data = this.options.dataSource.root().data();
Expand Down Expand Up @@ -2576,64 +2574,58 @@

// Bind expander
// K.D. August 16th, 2013 Bug #149438 Switching to delegated events
this.element.delegate("span[data-role=expander]", "click", function (event) {
this.element.on("click", "span[data-role=expander]", function (event) {
self.toggle($(event.target).closest("li[data-role=node]"), event);
});

// Bind anchor
// K.D. August 16th, 2013 Bug #149438 Switching to delegated events
this.element.delegate("a", {
"click": function (event) {
target = $(event.target).closest("a");
noCancel = self._triggerNodeClick(event, target.parent());
this.element.on("click", "a", function (event) {
target = $(event.target).closest("a");
noCancel = self._triggerNodeClick(event, target.parent());

if (noCancel) {
self.select(target.parent(), event);
if ($.ig.util.isWebKit) {
target.focus();
}
} else {
event.preventDefault();
if (noCancel) {
self.select(target.parent(), event);
if ($.ig.util.isWebKit) {
target.focus();
}
},
"dblclick": function (event) {
} else {
event.preventDefault();
self._triggerNodeDoubleClick(event, $(event.target.parentNode));
},
"keydown": function (event) {
self._kbNavigation(event);
},
"focus": function (event) {
self._focusNode(event);
},
"blur": function (event) {
self._blurNode(event);
}
});
this.element.on("dblclick", "a", function (event) {
event.preventDefault();
self._triggerNodeDoubleClick(event, $(event.target.parentNode));
});
this.element.on("keydown", "a", function (event) {
self._kbNavigation(event);
});
this.element.on("focus", "a", function (event) {
self._focusNode(event);
});
this.element.on("blur", "a", function (event) {
self._blurNode(event);
});

if (this.options.hotTracking) {
this.element.delegate("a", {
"mouseover": function (event) {
$(event.target).addClass(css.nodeHovered);
},
"mouseout": function (event) {
$(event.target).removeClass(css.nodeHovered);
}
this.element.on("mouseover", "a", function (event) {
$(event.target).addClass(css.nodeHovered);
});
this.element.on("mouseout", "a", function (event) {
$(event.target).removeClass(css.nodeHovered);
});
}

// Bind checkbox
// K.D. August 16th, 2013 Bug #149438 Switching to delegated events
this.element.delegate("span[data-role=checkbox] > span", {
"click": function (event) {
self.toggleCheckstate($(event.target).closest("li[data-role=node]"), event);
},
"mouseover": function (event) {
$(event.target).closest("span[data-role=checkbox]").addClass(css.nodeHovered);
},
"mouseout": function (event) {
$(event.target).closest("span[data-role=checkbox]").removeClass(css.nodeHovered);
}
this.element.on("click", "span[data-role=checkbox] > span", function (event) {
self.toggleCheckstate($(event.target).closest("li[data-role=node]"), event);
});
this.element.on("mouseover", "span[data-role=checkbox] > span", function (event) {
$(event.target).closest("span[data-role=checkbox]").addClass(css.nodeHovered);
});
this.element.on("mouseout", "span[data-role=checkbox] > span", function (event) {
$(event.target).closest("span[data-role=checkbox]").removeClass(css.nodeHovered);
});
},
_initChildrenRecursively: function (path, data, depth, indexFeed) {
Expand Down
4 changes: 2 additions & 2 deletions src/js/modules/infragistics.ui.videoplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5137,7 +5137,7 @@
"data-localeattr": "title"
});
}
videoElem.play();
return videoElem.play();
} else {
// K.D. June 3rd, 2011 Bug #75771 The title of the play/pause button has to be updated
if (!this.options.browserControls) {
Expand Down Expand Up @@ -5170,7 +5170,7 @@
"data-localeattr": "title"
});
}
videoElem.play();
return videoElem.play();
}
},

Expand Down
28 changes: 17 additions & 11 deletions tests/unit/combo/selection/selection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ QUnit.test('[ID1] Item selection', function (assert) {

QUnit.test('[ID2] Drop down mode', function (assert) {
assert.expect(6);
var done = assert.async();

var $input, $item,
$combo = $.ig.TestUtil.appendToFixture(this.divTag, { id: "combo-ddmode" }),
Expand All @@ -178,20 +179,25 @@ QUnit.test('[ID2] Drop down mode', function (assert) {
assert.strictEqual($input.attr('readonly'), 'readonly', 'Readonly attribute was not applied');
assert.strictEqual($input.hasClass('ui-unselectable'), true, 'Unselectable class was not applied');

$.ig.TestUtil.click($input);
// Adding tolerance for inconsistencies between the running engine and real browsers
assert.ok(dropDownExpHeight - 10 <= $dropDown.outerHeight() && dropDownExpHeight + 10 >= $dropDown.outerHeight(),
`Drop down height is incorrect: ${$dropDown.outerHeight()}, exp: ${dropDownExpHeight}`);
//strictEqual($dropDown.outerHeight(), dropDownExpHeight, 'Drop down height is incorrect');
$.ig.TestUtil.click($input)
$.ig.TestUtil.wait(16).then(() => {
// Adding tolerance for inconsistencies between the running engine and real browsers
assert.ok(dropDownExpHeight - 10 <= $dropDown.outerHeight() && dropDownExpHeight + 10 >= $dropDown.outerHeight(),
`Drop down height is incorrect: ${$dropDown.outerHeight()}, exp: ${dropDownExpHeight}`);
//strictEqual($dropDown.outerHeight(), dropDownExpHeight, 'Drop down height is incorrect');

$.ig.TestUtil.mouseEvent($item, "mouseover"); // Hover item
assert.ok($item.hasClass('ui-state-hover'), 'Class ui-state-hover was not applied to list item 0');
$.ig.TestUtil.mouseEvent($item, "mouseover"); // Hover item
assert.ok($item.hasClass('ui-state-hover'), 'Class ui-state-hover was not applied to list item 0');

$.ig.TestUtil.mouseEvent($item, "mouseout");
assert.notOk($item.hasClass('ui-state-hover'), 'Class ui-state-hover was not applied to list item 0');
$.ig.TestUtil.mouseEvent($item, "mouseout");
assert.notOk($item.hasClass('ui-state-hover'), 'Class ui-state-hover was not applied to list item 0');

$.ig.TestUtil.mouseEvent($input, "click"); // click on input
assert.strictEqual($dropDown.outerHeight(), 0, 'Drop down height is incorrect');
$.ig.TestUtil.mouseEvent($input, "click"); // click on input
return $.ig.TestUtil.wait(16);
}).then(() => {
assert.strictEqual($dropDown.outerHeight(), 0, 'Drop down height is incorrect');
done();
});
});

QUnit.test('[ID3] Readonly mode', function (assert) {
Expand Down
46 changes: 23 additions & 23 deletions tests/unit/videoplayer/videoplayer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ QUnit.test('Test seeking, ended and duration methods return correct values test
let checkElementClass = this.checkElementClass;
let checkElementNotClass = this.checkElementNotClass;

var video = $("#player11").igVideoPlayerUnitTesting({
var video = $("#player11").igVideoPlayer({
sources: ["https://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/Infragistics_Presentation_lowRes_1.h264.mp4",
"https://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/Infragistics_Presentation_lowRes_1.webmvp8.webm",
"https://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/Infragistics_Presentation_lowRes_1.theora.ogv"],
Expand All @@ -1428,21 +1428,21 @@ QUnit.test('Test seeking, ended and duration methods return correct values test
linkedCommercials: [
{
sources: [
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.h264.mp4",
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.webmvp8.webm",
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.theora.ogv"
],
startTime: 0,
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.h264.mp4",
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.webmvp8.webm",
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.theora.ogv"
],
startTime: 1,
endTime: 5,
title: "Quince Presentation p1",
link: "http://quince.infragistics.com/"
},
{
sources: [
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.h264.mp4",
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.webmvp8.webm",
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.theora.ogv"
],
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.h264.mp4",
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.webmvp8.webm",
"http://dl.infragistics.com/pg/2011-1/web/shared/videoplayer/videos/QuinceIntro_Part3_1.theora.ogv"
],
startTime: 10,
title: "Quince Presentation p3",
link: "http://quince.infragistics.com/"
Expand All @@ -1457,16 +1457,16 @@ QUnit.test('Test seeking, ended and duration methods return correct values test
counter++;
});

video.data('igVideoPlayerUnitTesting').togglePlay();

assert.equal(video.igVideoPlayerUnitTesting("seeking"), false);
assert.equal(video.igVideoPlayerUnitTesting("duration"), 260);

var ended = video.igVideoPlayerUnitTesting("ended");
assert.notOk(ended);

$.ig.TestUtil.wait(300).then(() => {
video.igVideoPlayerUnitTesting("changeLocale");
video.data('igVideoPlayer').play().then(() => {
assert.equal(video.igVideoPlayer("seeking"), false);
assert.equal(video.igVideoPlayer("duration"), 111.745);

var ended = video.igVideoPlayer("ended");
assert.notOk(ended);

return $.ig.TestUtil.wait(2000);
}).then(() => {
video.igVideoPlayer("changeLocale");
assert.ok($('#player11_ad_msg_c').is(':visible'));
checkElementClass($('#player11_ad_msg_c'), 'ui-igplayer-ad-msg-container', assert);

Expand All @@ -1486,12 +1486,12 @@ QUnit.test('Test seeking, ended and duration methods return correct values test

return $.ig.TestUtil.wait(500);
}).then(() => {
assert.equal(video.igVideoPlayerUnitTesting("paused"), true);
assert.equal(video.igVideoPlayer("paused"), true);

assert.ok($('#player11_ad_msg_c').is(':visible'));

$("#player11").igVideoPlayerUnitTesting("resetCommercialsShow");
return $.ig.TestUtil.wait(10);
$("#player11").igVideoPlayer("resetCommercialsShow");
return $.ig.TestUtil.wait(16);
}).then(() => done());
});

Expand Down

0 comments on commit 8eaa8f6

Please sign in to comment.