[Jifty-commit] r7369 - jifty/trunk/lib/Jifty/Web/Form

Jifty commits jifty-commit at lists.jifty.org
Thu Aug 13 21:34:19 EDT 2009


Author: sartak
Date: Thu Aug 13 21:34:18 2009
New Revision: 7369

Modified:
   jifty/trunk/lib/Jifty/Web/Form/Field.pm

Log:
render_preload_javascript

Modified: jifty/trunk/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field.pm	Thu Aug 13 21:34:18 2009
@@ -395,6 +395,7 @@
         $self->render_canonicalization_notes();
     } elsif ($self->render_mode eq 'read'){ 
         $self->render_value();
+        $self->render_preload_javascript();
     }
     $self->render_wrapper_end();
     return ('');
@@ -402,9 +403,9 @@
 
 =head2 render_inline_javascript
 
-Render a <script> tag (if neceesary) containing any inline javascript
-that should follow this form field. This is used to add an
-autocompleter, placeholder, or keybinding to form fields where needed.
+Render a <script> tag (if necessary) containing any inline javascript that
+should follow this form field. This is used to add an autocompleter,
+placeholder, keybinding, or preloading to form fields where needed.
 
 =cut
 
@@ -430,6 +431,24 @@
     }
 }
 
+=head2 render_preload_javascript
+
+Render a <script> tag (if necessary) containing any inline preload javascript
+that should follow this form field.
+
+=cut
+
+sub render_preload_javascript {
+    my $self = shift;
+
+    my $javascript = $self->preload_javascript;
+
+    if($javascript =~ /\S/) {
+        Jifty->web->out(qq{<script type="text/javascript">$javascript</script>
+});
+    }
+}
+
 =head2 classes
 
 Renders a default CSS class for each part of our widget.


More information about the Jifty-commit mailing list