From 2538e85780dc14cb92b4aa41a86924ba2a6e3820 Mon Sep 17 00:00:00 2001 From: nightwing Date: Mon, 23 Apr 2012 19:15:18 +0400 Subject: [PATCH] live preview of themes in demo --- demo/kitchen-sink/demo.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js index bf22cb4c..0ef1610f 100644 --- a/demo/kitchen-sink/demo.js +++ b/demo/kitchen-sink/demo.js @@ -390,10 +390,28 @@ function saveOption(el, val) { } } +themeEl.addEventListener("mouseover", function(e){ + this.desiredValue = e.target.value; + if (!this.$timer) + this.$timer = setTimeout(this.updateTheme); +}) + +themeEl.addEventListener("mouseout", function(e){ + this.desiredValue = null; + if (!this.$timer) + this.$timer = setTimeout(this.updateTheme, 20); +}) + +themeEl.updateTheme = function(){ + env.split.setTheme(themeEl.desiredValue || themeEl.selectedValue); + themeEl.$timer = null; +} + bindDropdown("theme", function(value) { if (!value) return; env.editor.setTheme(value); + themeEl.selectedValue = value; }); bindDropdown("keybinding", function(value) {