JSWindows (a JavaScript Inheritance Demo) Button_close Class

© 15 Feb., 2013, Martin Rinehart


The Button_close class provides the window-closing buttons for Window instances. It was designed for the JSWindows (a JavaScript Inheritance Demo) system's Window and Window-based objects. It's supplied with constants you can customize by editing the DEFAULTS object. It's "X" is an actual text "X", avoiding an extra graphic.

The Button_close Constructor

There should be no need to create closing buttons in your own code. Create Windows and this button will be there. This class is based on Button. It supplies most of the extras you need to create a closing button from a generic Button.

The constructor arguments are the same as a Button except that it does not accept hover_styles, label_func nor click_func arguments. It supplies its own. (If you want to provide custom arguments, use a plain Button.)

This button, when clicked, calls its container's onclose() method, if one has been defined. If container.onclose() returns false this button's logic halts. Otherwise (no onclose() or onclose() returns undefined or anything other than false) it continues to delete the container and all the containers' content.

Deleting includes DOM elements and JavaScript objects. DOM elements are recursively removed from the DOM and their references set to null. JavaScript's garbage collector is left to deal with the wrapper objects. If JSWindows (a JavaScript Inheritance Demo) has memory leaks, you'll probably find them in here.

If your container's onclose() returns false (for example, after setting display: 'none') nothing will be deleted. (Setting display: none will work for temporary window closing.)

Feedback: MartinRinehart at gmail dot com

# # #