Solstice::OnloadService - Allows applications to attach Javascript events to the page's onload event.


Solstice documentation Contained in the Solstice distribution.

Index


Code Index:

NAME

Top

Solstice::OnloadService - Allows applications to attach Javascript events to the page's onload event.

SYNOPSIS

Top

  use Solstice::OnloadService;

DESCRIPTION

Top

Superclass

Solstice::Service

Export

No symbols exported.

Methods

new()

Creates a new Solstice::OnloadService object.

addEvent($str)
getEvents()
setFocusTarget($id)
getFocusTarget()
setScrollTarget($id)
getScrollTarget()

Private Methods

_getClassName()

Return the class name. Overridden to avoid a ref() in the superclass.

Modules Used

Solstice::Service, StringLibrary (StringLibrary).

AUTHOR

Top

Catalyst Group, <catalyst@u.washington.edu>

VERSION

Top

$Revision: 3364 $

COPYRIGHT

Top


Solstice documentation Contained in the Solstice distribution.
package Solstice::OnloadService;

# $Id: OnloadService.pm 3364 2006-05-05 07:18:21Z mcrawfor $

use 5.006_000;
use strict;
use warnings;

use base qw(Solstice::Service);

use Solstice::StringLibrary qw(strtojavascript);

our ($VERSION) = ('$Revision: 3364 $' =~ /^\$Revision:\s*([\d.]*)/);

sub new {
    my $obj  = shift;
    return $obj->SUPER::new(@_);
}

sub addEvent {
    my $self  = shift;
    my $event = shift;
    return unless defined $event;

    # strip off trailing semicolons on incoming events
    $event =~ s/;+$//g;
    
    my $events = $self->get('onload_events') || [];
    push @$events, $event;
    $self->set('onload_events', $events)
}

sub getEvents {
    my $self = shift;
    
    my $events = $self->get('onload_events') || [];
    
    if (my $focus_id = $self->getFocusTarget()) {
        push @$events, qq|Solstice.Element.focus('$focus_id')|;    
    }
    if (my $scroll_id = $self->getScrollTarget()) {
        push @$events, qq|Solstice.Element.scrollTo('$scroll_id')|;
    }
    return $events;
}

sub setFocusTarget {
    my $self = shift;
    $self->set('focus_target_id', shift);
}

sub getFocusTarget {
    my $self = shift;
    return $self->get('focus_target_id');
}

sub setScrollTarget {
    my $self = shift;
    $self->set('scroll_target_id', shift);
}

sub getScrollTarget {
    my $self = shift;
    return $self->get('scroll_target_id');
}

sub _getClassName {
    return 'Solstice::OnloadService';
}


1;
__END__