Moved default hint css from js to config.def.h file (#199).
authorDaniel Carl <danielcarl@gmx.de>
Sat, 18 Apr 2015 21:52:04 +0000 (23:52 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 18 Apr 2015 21:52:04 +0000 (23:52 +0200)
This makes it easier for user to adapt the hinting theme without the need to
overrule the style by style.css file or to patch the hints.js file.

src/config.def.h
src/hints.js
src/js2h.sh

index fe9a2df..a74ce73 100644 (file)
 #define PROGRESS_BAR_LEN            20
 #endif
 
+/* CSS style use on creating hints. This might also be averrules by css out of
+ * $XDG_CONFIG_HOME/vimb/style.css file. */
+#define HINT_CSS "._hintLabel{\
+-webkit-transform:translate(-4px,-4px);\
+position:absolute;\
+z-index:100000;\
+font:bold .8em monospace;\
+color:#000;\
+background-color:#fff;\
+margin:0;\
+padding:0px 1px;\
+border:1px solid #444;\
+opacity:0.7\
+}\
+._hintElem{\
+background-color:#ff0 !important;\
+color:#000 !important\
+}\
+._hintElem._hintFocus{\
+background-color:#8f0 !important\
+}\
+._hintLabel._hintFocus{\
+z-index:100001;\
+opacity:1\
+}"
+
 #endif /* end of include guard: _CONFIG_H */
index c7db2ec..075af23 100644 (file)
@@ -14,32 +14,7 @@ Object.freeze((function(){
         lClass   = "_hintLabel",       /* class used on the hint labels with the hint numbers */
         hClass   = "_hintElem",        /* marks hinted elements */
         fClass   = "_hintFocus",       /* marks focused element and focussed hint */
-        config,
-        style    = "." + lClass + "{" +
-            "-webkit-transform:translate(-4px,-4px);" +
-            "position:absolute;" +
-            "z-index:100000;" +
-            "font:bold\x20.8em\x20monospace;" +
-            "color:#000;" +
-            "background-color:#fff;" +
-            "margin:0;" +
-            "padding:0px 1px;" +
-            "border:1px solid #444;" +
-            "opacity:0.7" +
-            "}" +
-            "." + hClass + "{" +
-            "background-color:#ff0 !important;" +
-            "color:#000 !important" +
-            "}" +
-            "." + hClass + "." + fClass + "{" +
-            "background-color:#8f0 !important" +
-            "}" +
-            "." + lClass + "." + fClass + "{" +
-            /* use higher z-index to show the active label if it's overlapped by other labels */
-            "z-index:100001;" +
-            "opacity:1" +
-            "}";
-
+        config;
     /* the hint class used to maintain hinted element and labels */
     function Hint() {
         /* hide hint label and remove coloring from hinted element */
@@ -330,7 +305,8 @@ Object.freeze((function(){
             return;
         }
         var e = doc.createElement("style");
-        e.innerHTML = style;
+        /* HINT_CSS is replaces by the contents of the HINT_CSS constant from config.h */
+        e.innerHTML = "HINT_CSS";
         doc.head.appendChild(e);
         /* prevent us from adding the style multiple times */
         doc.hasStyle = true;
index 871401e..d4d1f1a 100755 (executable)
@@ -10,5 +10,6 @@ cat $1 | \
     -e 's|\\x20| |g' \
     -e 's|\\|\\\\|g' \
     -e 's|"|\\"|g' \
+    -e 's|HINT_CSS|" HINT_CSS "|' \
     -e '$s/$/"/'
 echo ""