diff --git a/inc/config.class.php b/inc/config.class.php index 23512bb..e880234 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -3,7 +3,6 @@ class PluginButterflyConfig extends CommonDBTM { private static $_cache = null; - private static $_i = 1; static function getConfig($name, $defaultValue = null) { @@ -241,32 +240,13 @@ class PluginButterflyConfig extends CommonDBTM { Html::parseAttributes([ 'id' => $fullName . '_' . $rand, 'name' => $fullName, - 'class' => 'butterfly-codemirror', + 'class' => 'butterfly-css-editor', + 'rows' => 15, + 'spellcheck' => 'false', ]) ); echo rtrim($this->fields[$fullName]); - echo str_repeat("\n", 10); echo ''; - - echo Html::scriptBlock(' - $(function() { - var textarea = document.getElementById("' . $fullName . '_' . $rand . '"); - var editorCode = CodeMirror.fromTextArea(textarea, { - mode: "text/x-scss", - lineNumbers: true, - viewportMargin: Infinity, - extraKeys: { - "Ctrl-Space": "autocomplete" - }, - foldGutter: true, - gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"] - }); - $("#' . $fullName . '_' . $rand . '").data("CodeMirrorInstance", editorCode); - - // Fix bad display of gutter (see https://github.com/codemirror/CodeMirror/issues/3098 ) - setTimeout(function () {editorCode.refresh();}, ' . (500 + self::$_i++ * 100) . '); - }); - '); echo ""; echo "\n"; } @@ -311,9 +291,10 @@ class PluginButterflyConfig extends CommonDBTM { #tabs$rand .ui-tabs-panel { margin-left: 0; } - .CodeMirror { + .butterfly-css-editor { + width: 100%; border: 1px solid #eee; - height: auto; + font-family: monospace; } .butterfly-themeselect-container .select2-selection__rendered, .butterfly-themeselect-dropdown .select2-results__option { @@ -598,17 +579,6 @@ class PluginButterflyConfig extends CommonDBTM { // echo ""; - echo Html::scriptBlock("$('#tabs$rand').tabs({ - activate: function(event, ui) { - localStorage['butterfly_last_tab'] = $('#tabs$rand').tabs('option', 'active'); - var editor = ui.newPanel.find('.butterfly-codemirror').data('CodeMirrorInstance'); - if (editor) { - editor.refresh(); - } - }, - active: localStorage['butterfly_last_tab'] - });"); - if ($canedit) { echo ""; echo ""; diff --git a/inc/fileversion.class.php b/inc/fileversion.class.php deleted file mode 100644 index c4a694c..0000000 --- a/inc/fileversion.class.php +++ /dev/null @@ -1,25 +0,0 @@ -_file = $file; - } - - public function __toString() { - // First call is inside of "file_exists", so it is necessary to return a valid file - if (!$this->_initialized) { - $this->_initialized = true; - return $this->_file; - } - - // Second call is inside concatenation - - $timestamp = PluginButterflyToolbox::getTimestamp(); - - return $this->_file . "?_=" . $timestamp; - } -} diff --git a/setup.php b/setup.php index 560041c..ae7b207 100644 --- a/setup.php +++ b/setup.php @@ -67,11 +67,11 @@ function plugin_init_butterfly() $PLUGIN_HOOKS['display_login']['butterfly'] = "plugin_butterfly_display_login"; - // Tip Trick to add version in css output - $PLUGIN_HOOKS["add_css"]['butterfly'] = new PluginButterflyFileVersion('front/internal.css.php'); - $PLUGIN_HOOKS["add_javascript"]['butterfly'] = new PluginButterflyFileVersion('front/internal.js.php'); + // GLPI 11 appends ?v= itself; the endpoints + // handle config-change cache busting via their own timestamp redirect + $PLUGIN_HOOKS["add_css"]['butterfly'] = 'front/internal.css.php'; + $PLUGIN_HOOKS["add_javascript"]['butterfly'] = 'front/internal.js.php'; - $CFG_GLPI['javascript']['config']['config'][] = 'codemirror'; $CFG_GLPI['javascript']['config']['config'][] = 'tinymce'; } }