Przeglądaj źródła

Clean up and improve tooltips, show the name

Scott Lahteine 10 lat temu
rodzic
commit
4228758f1d

+ 10
- 1
Marlin/configurator/css/configurator.css Wyświetl plik

@@ -24,7 +24,15 @@ input[type="text"], select { margin: 0.75em 0 0; }
24 24
 input[type="checkbox"], input[type="radio"], input[type="file"] { margin: 1em 0 0; }
25 25
 #config_form { display: block; background: #DDD; padding: 20px; color: #000; position: relative; }
26 26
 /*#config_text, #config_adv_text { font-family: "Andale mono", monospace; clear: both; }*/
27
-#config_text, #config_adv_text { height: 25em; overflow: auto; background-color: #FFF; color: #888; padding: 10px; }
27
+#config_text, #config_adv_text {
28
+	height: 25em;
29
+	padding: 10px;
30
+	border: 2px solid #888;
31
+	border-radius: 5px;
32
+	overflow: auto;
33
+	background-color: #FFF;
34
+	color: #000;
35
+	}
28 36
 input[type="checkbox"], input[type="radio"].enabler { margin-left: 1em; }
29 37
 input:disabled { color: #BBB; }
30 38
 .clear { clear: both; }
@@ -109,3 +117,4 @@ fieldset legend { display: none; }
109 117
 	bottom: -10px;
110 118
 	left: 20px;
111 119
 	}
120
+#tooltip>strong { color: #00B; }

+ 19
- 19
Marlin/configurator/js/configurator.js Wyświetl plik

@@ -27,6 +27,7 @@ String.prototype.lpad = function(len, chr) {
27 27
 };
28 28
 String.prototype.prePad = function(len, chr) { return len ? this.lpad(len, chr) : this; };
29 29
 String.prototype.zeroPad = function(len)     { return this.prePad(len, '0'); };
30
+String.prototype.toHTML = function()         { return jQuery('<div>').text(this).html(); };
30 31
 String.prototype.regEsc = function()         { return this.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); }
31 32
 String.prototype.lineCount = function()      { var len = this.split(/\r?\n|\r/).length; return len > 0 ? len - 1 : len; };
32 33
 
@@ -367,7 +368,7 @@ var configuratorApp = (function(){
367 368
             $tipme.hover(
368 369
               function() {
369 370
                 var pos = $tipme.position();
370
-                $tooltip.text(inf.comment)
371
+                $tooltip.html(inf.comment)
371 372
                   .append('<span>')
372 373
                   .css({bottom:($tooltip.parent().outerHeight()-pos.top)+'px',left:(pos.left+70)+'px'})
373 374
                   .show();
@@ -484,6 +485,7 @@ var configuratorApp = (function(){
484 485
      *   then update, highlight, and scroll to the line
485 486
      */
486 487
     setDefineLine: function(name, newline) {
488
+      this.log('setDefineLine:'+name+'\n'+newline,4);
487 489
       var $elm = $('#'+name), elm = $elm[0], inf = elm.defineInfo;
488 490
       var $c = $(inf.field), txt = $c.text();
489 491
 
@@ -492,10 +494,8 @@ var configuratorApp = (function(){
492 494
       txt = txt.replace(inf.line, hilite_token + newline);
493 495
       inf.line = newline;
494 496
 
495
-      this.log(newline, 2);
496
-
497 497
       // Convert txt into HTML before storing
498
-      var html = $('<div/>').text(txt).html().replace(hilite_token, '<span></span>');
498
+      var html = txt.toHTML().replace(hilite_token, '<span></span>');
499 499
 
500 500
       // Set the final text including the highlighter
501 501
       $c.html(html);
@@ -634,26 +634,26 @@ var configuratorApp = (function(){
634 634
         // Get the end-of-line comment, if there is one
635 635
         var comment = '';
636 636
         findDef = new RegExp('.*#define[ \\t].*/[/*]+[ \\t]*(.*)');
637
-        if (info.line.search(findDef) >= 0) {
637
+        if (info.line.search(findDef) >= 0)
638 638
           comment = info.line.replace(findDef, '$1');
639
-        }
640
-        else {
641
-          // Get all the comments immediately before the item
642
-          var r, s;
643
-          findDef = new RegExp('(([ \\t]*(//|#)[^\n]+\n){1,4})([ \\t]*\n){0,1}' + info.line, 'g');
644
-          if (r = findDef.exec(txt)) {
645
-            findDef = new RegExp('^[ \\t]*//+[ \\t]*(.*)[ \\t]*$', 'gm');
646
-            while((s = findDef.exec(r[1])) !== null) {
647
-              if (s[1].match(/^#define[ \\t]/) != null) {
648
-                comment = '';
649
-                break;
650
-              }
651
-              comment += s[1] + "\n";
639
+
640
+        // Get all the comments immediately before the item
641
+        var r, s;
642
+        findDef = new RegExp('(([ \\t]*(//|#)[^\n]+\n){1,4})([ \\t]*\n){0,1}' + info.line.regEsc(), 'g');
643
+        if (r = findDef.exec(txt)) {
644
+          findDef = new RegExp('^[ \\t]*//+[ \\t]*(.*)[ \\t]*$', 'gm');
645
+          while((s = findDef.exec(r[1])) !== null) {
646
+            if (s[1].match(/^#define[ \\t]/) != null) {
647
+              comment = '';
648
+              break;
652 649
             }
650
+            comment += ' ' + s[1] + "\n";
653 651
           }
654 652
         }
653
+
654
+        findDef = new RegExp('^[ \\t]*'+name+'[ \\t]*', 'm');
655 655
         $.extend(info, {
656
-          comment: comment.trim(),
656
+          comment: '<strong>'+name+'</strong> '+comment.replace(findDef,'').trim().toHTML(),
657 657
           lineNum: this.getLineNumberOfText(info.line, txt)
658 658
         });
659 659
       }

Ładowanie…
Anuluj
Zapisz