SwarmPlayer is now detected; CIS-LB random load balancer created
[living-lab-site.git] / application / views / video / comments_view.php
index 80f56fd..f93c653 100644 (file)
@@ -1,7 +1,11 @@
 <h4><?php echo $this->lang->line('video_title_comment') ?>: </h4>
 
 <?php echo form_open("video/comment/$video_id") ?>
-       <textarea name="comment" id="comment" rows="4" cols="56"><?php echo set_value('comment', '') ?></textarea>
+       <textarea name="comment" id="comment" rows="4" cols="56"><?php 
+               if (validation_errors()):
+                       echo set_value('comment', '');
+               endif;
+       ?></textarea>
        
        <div><input type="button" id="button-post" value="<?php echo $this->lang->line('video_submit_post_comment') ?>" />
                <span id="comment-chars-left">512</span> <?php echo $this->lang->line('ui_chars_left') ?>
 <?php endif ?>
 
 <script type="text/javascript">
-
-       function updateCommentCharsLeft($textarea) 
-       {
-               $('#comment-chars-left').html('' + (512 - $textarea.val().length));
-       }
-       
        $(function() {
                $('#button-post')
                        .click(function() {
                        });
                
                $('#comment')
-                       .keydown(function(event) {
-                               updateCommentCharsLeft($(this));
+                       .bind('keyup paste drop change', function(event) {
+                               $textarea = $(this);
                                
-                               if ($(this).val().length == 513)
-                                       $(this).val($(this).val().substring(0, 512));
-                       })
-                       .change(function() {
-                               updateCommentCharsLeft($(this));
+                               if ($textarea.val().length >= 513)
+                                       $textarea.val($textarea.val().substring(0, 512));
+
+                               $('#comment-chars-left').html('' + (512 - $textarea.val().length));
                        });
        });
 </script>
\ No newline at end of file