# Copyright (c) 2001 bivio Software, Inc. All rights reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: ScriptOnly.pm,v 2.5 2010/02/11 00:09:24 moeller Exp $ package Bivio::UI::HTML::Widget::ScriptOnly; use strict; use Bivio::Base 'Bivio::UI::Widget'; # C java script only widget rendering. # # # # widget : Bivio::UI::Widget (required) # # The widget to render when javascript is present. # # alt_widget : Bivio::UI::Widget [] # # The widget which is rendered if javascript is not present. our($VERSION) = sprintf('%d.%02d', q$Revision: 2.5 $ =~ /\d+/g); my($_IDI) = __PACKAGE__->instance_data_index; sub initialize { # (self) : undef # Preparse the widget during startup. my($self) = @_; $self->get('widget')->put(parent => $self)->initialize; $self->get('alt_widget')->put(parent => $self)->initialize if $self->unsafe_get('alt_widget'); return; } sub new { # (proto) : Widget.ScriptOnly # Creates a new ScriptOnly widget. my($self) = shift->SUPER::new(@_); $self->[$_IDI] = {}; return $self; } sub render { # (self, any, string_ref) : undef # Draws the widget on the buffer so that it will only be rendered if # javascript is present. my($self, $source, $buffer) = @_; $$buffer .= <<'EOF'; "; if ($self->unsafe_get('alt_widget')) { $$buffer .= "\n\n"; } return; } 1;