[dw-free] Widget need_res unable to switch active groups
[commit: http://hg.dwscoalition.org/dw-free/rev/26ab134880c3]
http://bugs.dwscoalition.org/show_bug.cgi?id=1304
Add ability to specify options to need_res for widgets.
Patch by
afuna.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1304
Add ability to specify options to need_res for widgets.
Patch by
Files modified:
- cgi-bin/LJ/Widget.pm
--------------------------------------------------------------------------------
diff -r c71ff2482cdf -r 26ab134880c3 cgi-bin/LJ/Widget.pm
--- a/cgi-bin/LJ/Widget.pm Sun Jun 14 20:16:19 2009 +0000
+++ b/cgi-bin/LJ/Widget.pm Sun Jun 14 20:18:49 2009 +0000
@@ -22,6 +22,10 @@ sub new {
}
sub need_res {
+ return ();
+}
+
+sub need_res_opts {
return ();
}
@@ -99,6 +103,8 @@ sub render {
my $rv = eval {
my $widget = $class;
+ my $opts = { $widget->need_res_opts };
+
# include any resources that this widget declares
if (defined $opt_hash{stylesheet_override}) {
LJ::need_res($opt_hash{stylesheet_override}) if $opt_hash{stylesheet_override};
@@ -107,19 +113,19 @@ sub render {
foreach my $file ($widget->need_res) {
if ($file =~ m!^[^/]+\.(js|css)$!i) {
next if $1 eq 'css';
- LJ::need_res("js/widgets/$subclass/$file");
+ LJ::need_res( $opts, "js/widgets/$subclass/$file" );
next;
}
- LJ::need_res($file) unless $file =~ /\.css$/i;
+ LJ::need_res( $opts, $file ) unless $file =~ /\.css$/i;
}
} else {
foreach my $file ($widget->need_res) {
if ($file =~ m!^[^/]+\.(js|css)$!i) {
my $prefix = $1 eq 'js' ? "js" : "stc";
- LJ::need_res("$prefix/widgets/$subclass/$file");
+ LJ::need_res( $opts, "$prefix/widgets/$subclass/$file" );
next;
}
- LJ::need_res($file);
+ LJ::need_res( $opts, $file );
}
}
LJ::need_res($opt_hash{stylesheet}) if $opt_hash{stylesheet};
@@ -742,6 +748,10 @@ Returns a list of paths to static files
Returns a list of paths to static files that should be included on the page that
the widget is called on (i.e. CSS and JS). Can be subclassed.
+=item C<need_res_opts>
+
+Returns a hash of opts that can be passed to need_res -- for example, ( group => 'jquery' ). Can be subclassed.
+
=item C<post_fields_by_widget>
Returns a hashref of the POST fields for each widget that was handled via
--------------------------------------------------------------------------------
