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