Dotclear


Ignore:
Timestamp:
06/24/19 14:29:57 (6 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Switching from inline JS variables to JSON script, theme editor plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/themeEditor/_admin.php

    r3874 r3980  
    7070            form::combo('colorsyntax_theme', $themes_combo, 
    7171                [ 
    72                     'default'    => $core->auth->user_prefs->interface->colorsyntax_theme, 
    73                     'extra_html' => 'onchange="selectTheme()"']) . 
     72                    'default' => $core->auth->user_prefs->interface->colorsyntax_theme 
     73                ]) . 
    7474                '</p>'; 
    7575        } else { 
     
    9797}</textarea>'; 
    9898        echo 
    99             '<script> 
    100             var input = document.getElementById("colorsyntax_theme"); 
    101             var theme = input.options[input.selectedIndex].textContent; 
    102             var editor = CodeMirror.fromTextArea(document.getElementById("codemirror"), { 
    103                 mode: "javascript", 
    104                 tabMode: "indent", 
    105                 lineWrapping: 1, 
    106                 lineNumbers: 1, 
    107                 matchBrackets: 1, 
    108                 autoCloseBrackets: 1, 
    109                 theme: "' . ($core->auth->user_prefs->interface->colorsyntax_theme != '' ? $core->auth->user_prefs->interface->colorsyntax_theme : 'default') . '" 
    110             }); 
    111             function selectTheme() { 
    112                 var input = document.getElementById("colorsyntax_theme"); 
    113                 var theme = input.options[input.selectedIndex].value; 
    114                 if (theme == "") theme = "default"; 
    115                 editor.setOption("theme", theme); 
    116                 editor.refresh(); 
    117             } 
    118         </script>'; 
     99        dcPage::jsJson('theme_editor_current', ['theme' => $core->auth->user_prefs->interface->colorsyntax_theme != '' ? $core->auth->user_prefs->interface->colorsyntax_theme : 'default']) . 
     100        dcPage::jsLoad(dcPage::getPF('themeEditor/js/theme.js')); 
    119101        echo '</div>'; 
    120102        echo '</div>'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map