Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
2 |
|
3 |
|
4 |
# Copyright 2010 Frédérick Capovilla - Libéo |
5 |
# |
6 |
# This file is part of Koha. |
7 |
# |
8 |
# Koha is free software; you can redistribute it and/or modify it under the |
9 |
# terms of the GNU General Public License as published by the Free Software |
10 |
# Foundation; |
11 |
# |
12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
13 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
14 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License along |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
20 |
use Modern::Perl; |
21 |
|
22 |
use C4::Context; |
23 |
use Regexp::Common qw( URI ); |
24 |
|
25 |
|
26 |
=head1 DESCRIPTION |
27 |
|
28 |
plugin_javascript : the javascript function called when the user enters the subfield. |
29 |
contain 3 javascript functions : |
30 |
* one called when the field is entered (OnFocus). Named FocusXXX |
31 |
* one called when the field is leaved (onBlur). Named BlurXXX |
32 |
* one called when the ... link is clicked (<a href="javascript:function">) named ClicXXX |
33 |
|
34 |
returns : |
35 |
* XXX |
36 |
* a variable containing the 3 scripts. |
37 |
the 3 scripts are inserted after the <input> in the html code |
38 |
|
39 |
=cut |
40 |
|
41 |
sub plugin_javascript { |
42 |
my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; |
43 |
my $function_name = $field_number; |
44 |
my @split_field_name = split(/_/, $field_number); |
45 |
my $field_name = $split_field_name[1] . '$' . $split_field_name[3]; |
46 |
my $regex = $RE{URI}; |
47 |
$regex =~ s/\//\\\//g; |
48 |
|
49 |
my $res = <<END_OF_JS; |
50 |
<script type="text/javascript"> |
51 |
//<![CDATA[ |
52 |
|
53 |
function isUrl(s) { |
54 |
var regexp = /$regex/; |
55 |
return regexp.test(s); |
56 |
} |
57 |
|
58 |
function Blur$function_name(index) { |
59 |
var fieldValue = document.getElementById("$field_number").value; |
60 |
if(fieldValue != '') { |
61 |
if(!isUrl(fieldValue)) { |
62 |
invalid_url_alert('$field_name'); |
63 |
} |
64 |
} |
65 |
return 0; |
66 |
} |
67 |
|
68 |
function Focus$function_name(subfield_managed) { |
69 |
// Do Nothing |
70 |
} |
71 |
|
72 |
function Clic$function_name(subfield_managed) { |
73 |
// Do Nothing |
74 |
} |
75 |
//]]> |
76 |
</script> |
77 |
END_OF_JS |
78 |
return ($function_name,$res); |
79 |
} |
80 |
|
81 |
=head1 DESCRIPTION |
82 |
|
83 |
plugin : the true value_builded. The screen that is open in the popup window. |
84 |
|
85 |
=cut |
86 |
|
87 |
sub plugin { |
88 |
return ""; |
89 |
} |
90 |
|
91 |
1; |