[Bio] / WebApplication / WebComponent / AjaxQueue.pm Repository:
ViewVC logotype

View of /WebApplication/WebComponent/AjaxQueue.pm

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.1 - (download) (as text) (annotate)
Sun Jan 2 22:00:23 2011 UTC (9 years ago) by chenry
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, mgrast_dev_03052011, mobedac_release_05302012, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Checking in accumulated changes to ModelSEED web components

package WebComponent::AjaxQueue;

use strict;
use warnings;
use base qw( WebComponent );

use JSON;



=head1 NAME

AjaxQueue - Add ajax calls to be run when page loads


WebComponent for ajax calls

=head1 METHODS

=over 4

=item * B<new> ()

Called when the object is initialized. Expands SUPER::new.


sub new {

    my $self = shift->SUPER::new(@_);

    $self->application->register_component('CustomAlert', 'controlPanel');
    $self->application->register_component('JSCaller', 'ajaxQueueJSCaller');
    $self->application->register_component('Ajax', 'ajaxqueue_ajax');

    $self->{singleton} = 1;

    return $self;

    # set up control panel
#    my $control_panel = $self->application->component('controlPanel');
#    $control_panel->name("control_panel");
#    $control_panel->title("Control Panel");
#    $control_panel->content("<div id='controlPanel'></div>");
#    $control_panel->width(800);
#    $control_panel->onclick(['hideControlPanel()']);

=item * B<add_ajax> (I<ajax_name>, I<wait>)

Adds an ajax call to the queue, wait is a boolean which tells whether
the queue should wait until the onfinish functions are done before continuing


sub add_ajax {
    my ($self, $ajax_name, $wait) = @_;

    # make sure ajax call exists
    my $ajax = $self->application->component('ajaxqueue_ajax');
    unless (defined($ajax->{requests}->{$ajax_name})) {
	die "Ajax request must be created before adding to AjaxQueue\n";

    if (!defined($wait)) {
	$wait = 1;

    my $jscaller = $self->application->component('ajaxQueueJSCaller');
    $jscaller->call_function_args("AjaxQueue.add", [$ajax_name, $wait]);

sub require_javascript {
  return ["$FIG_Config::cgi_url/Html/AjaxQueue.js"];

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3