Skip to content

Remove YUI event code - #184

Open
cviebrock wants to merge 11 commits into
silverorange:masterfrom
cviebrock:remove-yui-code
Open

Remove YUI event code#184
cviebrock wants to merge 11 commits into
silverorange:masterfrom
cviebrock:remove-yui-code

Conversation

@cviebrock

@cviebrock cviebrock commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Refactors and removes any event-based code that relied on YUI to set up ... and replaces it with vanilla JS EventTarget-based code.

There are also some other changes that got looped in as well, mostly because this started out as a PR to remove YUI entirely. I also cleaned up the demo that ships with the package a bit, so that all of these changes can be tested via http://localhost:8888/ (see the README.md for details).

}
}
// increase value on mouse movement
const handleMouseMove = (e, progress_bar) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need multiple params as download_progress_obj will be available in the outer scope. It could be inline in the addEventListener using a standard arrow function. The other even handlers are also only used once and could be declared inline inside addEventListener.

upload_progress_obj.setText(value + '% complete');
}
// set random value on mouse click
const handleClick = (e, progress_bar) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need multiple params and can be declared inline.

});

this.changeValueEvent.fire(this.value);
this.dispatchEvent(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good. Because we use dispatchEvent we should also be able to use e.target inside an event handler to access the progress bar instance.

upload_progress_obj.setText(value + '% complete');
}
// set random value on mouse click
const handleClick = (e, progress_bar) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.target should also be the progress bar instance and could be a better pattern to use than relying on the shared variable scope.

@cviebrock cviebrock changed the title Remove YUI code Remove YUI event code Aug 10, 2026
@cviebrock
cviebrock marked this pull request as ready for review August 10, 2026 17:18
Comment thread demo/include/DemoApplication.php
Comment thread demo/include/layout.php
Comment thread Swat/SwatButton.php
Comment thread Swat/SwatEntry.php
Comment thread Swat/SwatEntry.php
Comment thread demo/include/demos/simplecolorentry.xml Outdated
simple_color_entry_obj.colorChangeEvent.subscribe(
handleColorChange);
</script>
simple_color_entry_obj.addEventListener('colorChange', (e) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change

Comment thread Swat/SwatActions.php Outdated
parent::__construct($id);

$yui = new SwatYUI(['dom', 'event', 'animation']);
$yui = new SwatYUI(['dom', 'animation']);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can drop all of these.

Comment thread Swat/SwatAccordion.php Outdated
$this->requires_id = true;

$yui = new SwatYUI(['yahoo', 'dom', 'event', 'animation']);
$yui = new SwatYUI(['animation']);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can drop animations util. It uses DOM animations.

Comment thread Swat/SwatButton.php
{
parent::__construct($id);

$yui = new SwatYUI(['dom', 'event', 'animation']);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can drop all YUI utils.

Comment thread Swat/SwatRadioNoteBook.php Outdated
$this->requires_id = true;

$yui = new SwatYUI(['dom', 'event', 'animation', 'selector']);
$yui = new SwatYUI(['animation']);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can drop animation as well. It uses DOM animations.

Comment thread www/javascript/swat-change-order.js Outdated
if (temp != hidden_field.value) {
this.orderChangeEvent.fire(temp);
this.dispatchEvent(
new CustomEvent('orderChange', {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change-order

Comment thread www/javascript/swat-progress-bar.js Outdated

if (
this.pulse_direction == 1 &&
this.pulse_direction === 1 &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be moved to a static property DIRECTION_FORWARD

Comment thread www/javascript/swat-progress-bar.js Outdated

if (
this.pulse_direction == -1 &&
this.pulse_direction === -1 &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be moved to a static property DIRECTION_BACKWARD

const event_color = color === null ? null : '#' + color;

this.dispatchEvent(
new CustomEvent('colorChange', {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change

* This is the base class used for recordset views. It is primarily
* responsible for providing helper methods for dynamically highlighting
* selecgted items in the view.
* selected items in the view.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tahngks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants