example for repeatable or non-repeatable values
[MojoFacets.git] / public / js / eval_console.js
1 $(document).ready( function(){
2
3         var $form = $('form#eval');
4
5         $form.find('textarea').each( function() {
6                 console.debug('grow',this);
7
8                 var rows = this.rows;
9                 console.debug( 'textarea_grow', rows, this );
10                 var grow = function(ta) {
11                 var lines = ta.value.split('\n').length;
12                         if ( lines != rows ) {
13                                 ta.rows = lines;
14                                 rows    = lines;
15                                 console.debug('keyup', lines, rows, ta );
16                         }
17                 };
18                 grow(this);
19                 this.onkeyup = function() { grow(this) };
20         });
21
22         if ( $form.is(':visible') ) {
23                 $('body').css({ 'margin-bottom': $form.height() });
24         }
25
26         $('input#close').click( function(){
27                 console.debug( 'close console' );
28                 $.post( document.location, { code: '' } );
29                 $(this).parent().hide();
30         });
31
32         var $out = $('pre#out');
33         if ( $out.height() > ( $(window).height() / 3 * 2 ) ) {
34                 $out.height( $(window).height() / 3 * 2 ).css({ overflow: 'auto' });
35         }
36
37         $('a#console').click( function() {
38                 console.debug('open console');
39                 var $f = $('form#eval');
40                 if ( $f.is(':visible') ) {
41                         $f.hide();
42                         $('body').css({ 'margin-bottom': 0 });
43                 } else {
44                         $f.show();
45                         $('body').css({ 'margin-bottom': $form.height() });
46                 }
47                 return false;
48         }).show();
49
50 });
51