# Copyright (c) 2010 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: CopyListValueHandler.pm,v 2.1 2010/10/22 22:51:08 moeller Exp $ package Bivio::UI::HTML::Widget::CopyListValueHandler; use strict; use Bivio::Base 'UI.Widget'; my($_JS) = b_use('HTMLWidget.JavaScript'); our($VERSION) = sprintf('%d.%02d', q$Revision: 2.1 $ =~ /\d+/g); sub get_html_field_attributes { my($self, $field_name, $source) = @_; return ' onfocus="cr_focus(this)"'; } sub render { my($self, $source, $buffer) = @_; $_JS->render($source, $buffer, $self->package_name, <<'EOF'); function cr_focus(c) { if (c.value) return; var match = ner_match_name(c.name); var prev = document.getElementsByName(match[1] + (parseInt(match[2]) - 1)); if (prev.length) c.value = prev[0].value; return; } EOF return; } 1;