Projet

Général

Profil

Paste
Télécharger (937 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / css_injector / syntax_highlighter.js @ 87dbc3bf

1
(function($) {
2

    
3
  /**
4
   * Add syntext highlighter for textarea.
5
   */
6
  Drupal.behaviors.slideUpDown = {
7
    attach: function(context, settings) {
8
      $('body').addClass('has-js');
9
      var editor = ace.edit("editor");
10
      editor.getSession().setUseWorker(false);
11
      editor.setTheme("ace/theme/chrome");
12
      editor.getSession().setMode("ace/mode/css");
13

    
14
      editor.getSession().on('change', function(e) {
15
        setTextareaValue();
16
      });
17

    
18
      var setTextareaValue = function() {
19
        $('#edit-css-text').val(editor.getValue());
20
      }
21

    
22
      $('.disable-ace').click(function() {
23
        var $this = $(this);
24
        $this.toggleClass('ace-disabled');
25
        $text = $this.text() == 'Disable syntax highlighter' ? 'Enable syntax highlighter' : 'Disable syntax highlighter';
26
        $this.text($text);
27
        $('.form-item-css-text .form-textarea-wrapper, .ace-editor').toggle();
28
      });
29

    
30
    }
31
  }
32

    
33
})(jQuery)