Adam Kennedy - Display-0.06

Documentation | Source

NAME

Display - Provides common primitives for Display modules

SYNOPSIS

  // Showing
  Display.showElement(element);
  Display.showElementById(id);
  
  // Hiding
  Display.hideElement(element);
  Display.hideElementById(id);
  
  // Checking state
  Display.isElementHidden(element);
  Display.isIdHidden(id);

DESCRIPTION

Display provides a collection of utility functions for showing and and hiding elements. These are implemented in a simple, correct, and fast way, and the intent is that Display will act as a central location for handling special and weird cases in the various browsers, and greatly simplify the code required for higher level modules such as Display.Hide and Display.Swap.

However, the functions listed below do no param checking, and as such are not really suitable for casual use in ordinary code. They are intended for other module authors who will have already checked that what they are passing is ok, and don't need or want the functions to protect them or provide DWIM functions.

Ordinary users should consider using a specific Display.Something module, or consider the use of Element from the Prototype collection.

Functions

void showElement element

The showElement method takes a HTMLElement parameter and displays it by setting its display style property to its default.

void showElementById id

The showElementById method takes a String parameter containing a HTML id value in the current document and shows the element that the id represents.

void hideElement element

The hideElement method takes a HTMLElement parameter and hides it by setting its display style property to "none"

void hideElementById id

The hideElementById method takes a String parameter containing a HTML id value in the current document and shows the element that the id represents.

bool elementIsHidden element

The elementIsHidden method checks to see if a HTMLElement is hidden.

Returns true if the elements display style propery is set to "none", or false otherwise.

bool idIsHidden element

The idIsHidden method checks to see if a HTMLElement is hidden.

Returns true if the elements display style propery is set to "none", or false if not, or null if the element with that id does not exist.

SUPPORT

Bugs should be filed via the the jsan-authors mailing list.

See http://openjsan.org/community/lists.html#jsan-authors for details.

For non-support issues or questions, contact the author.

AUTHOR

Adam Kennedy <jsan@ali.as>, http://ali.as/

COPYRIGHT

Copyright (c) 2005 Adam Kennedy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the the terms of the Perl dual GPL/Artistic license.

The full text of the license can be found in the LICENSE file included with this package

/*

=pod

=head1 NAME

Display - Provides common primitives for Display modules

=head1 SYNOPSIS

  // Showing
  Display.showElement(element);
  Display.showElementById(id);
  
  // Hiding
  Display.hideElement(element);
  Display.hideElementById(id);
  
  // Checking state
  Display.isElementHidden(element);
  Display.isIdHidden(id);

=head1 DESCRIPTION

C<Display> provides a collection of utility functions for showing and
and hiding elements. These are implemented in a simple, correct, and fast
way, and the intent is that C<Display> will act as a central location for
handling special and weird cases in the various browsers, and greatly
simplify the code required for higher level modules such as L<Display.Hide>
and L<Display.Swap>.

However, the functions listed below do B<no> param checking, and as such
are not really suitable for casual use in ordinary code. They are intended
for other module authors who will have already checked that what they are
passing is ok, and don't need or want the functions to protect them or
provide DWIM functions.

Ordinary users should consider using a specific C<Display.Something> module,
or consider the use of L<Element> from the Prototype collection.

=head1 Functions

=cut

*/

// Set up the namespace if needed
if ( typeof Display == "undefined" ) Display = {};

Display.VERSION = 0.06;

/*

=pod

=head2 void showElement element

The C<showElement> method takes a C<HTMLElement> parameter and displays
it by setting its C<display> style property to its default.

=cut

*/

Display.showElement = function (el) {
	el.style.display = "";
}


/*

=pod

=head2 void showElementById id

The C<showElementById> method takes a C<String> parameter containing
a HTML id value in the current document and shows the element that
the id represents.

=cut

*/

Display.showElementById = function(id) {
	var el = document.getElementById(id);
	if ( el ) Display.showElement(el);
}

/*

=pod

=head2 void hideElement element

The C<hideElement> method takes a C<HTMLElement> parameter and hides
it by setting its C<display> style property to "none"

=cut

*/

Display.hideElement = function (el) {
	el.style.display = "none";
}


/*

=pod

=head2 void hideElementById id

The C<hideElementById> method takes a C<String> parameter containing
a HTML id value in the current document and shows the element that
the id represents.

=cut

*/

Display.hideElementById = function(id) {
	var el = document.getElementById(id);
	if ( el ) Display.hideElement(el);
}

/*

=pod

=head2 bool elementIsHidden element

The C<elementIsHidden> method checks to see if a C<HTMLElement> is hidden.

Returns C<true> if the elements C<display> style propery is set to C<"none">,
or C<false> otherwise.

=cut

*/

Display.isElementHidden = function(el) {
	return (el.style.display == "none");
}

/*

=pod

=head2 bool idIsHidden element

The C<idIsHidden> method checks to see if a C<HTMLElement> is hidden.

Returns C<true> if the elements C<display> style propery is set to C<"none">,
or C<false> if not, or C<null> if the element with that id does not exist.

=cut

*/

Display.idIsHidden = function(id) {
	var el = document.getElementById(id);
	if ( el ) return Display.isElementHidden(el);
	return null;
}

/*

=pod

=head1 SUPPORT

Bugs should be filed via the the C<jsan-authors> mailing list.

See L<http://openjsan.org/community/lists.html#jsan-authors> for details.

For B<non-support> issues or questions, contact the author.

=head1 AUTHOR

Adam Kennedy E<lt>jsan@ali.asE<gt>, L<http://ali.as/>

=head1 COPYRIGHT

Copyright (c) 2005 Adam Kennedy. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the the terms of the Perl dual GPL/Artistic license.

The full text of the license can be found in the
LICENSE file included with this package

=cut

*/