Browse Source

Clean up and improve tooltips, show the name

Scott Lahteine 10 years ago
parent
commit
4228758f1d
2 changed files with 29 additions and 20 deletions
  1. 10
    1
      Marlin/configurator/css/configurator.css
  2. 19
    19
      Marlin/configurator/js/configurator.js

+ 10
- 1
Marlin/configurator/css/configurator.css View File

24
 input[type="checkbox"], input[type="radio"], input[type="file"] { margin: 1em 0 0; }
24
 input[type="checkbox"], input[type="radio"], input[type="file"] { margin: 1em 0 0; }
25
 #config_form { display: block; background: #DDD; padding: 20px; color: #000; position: relative; }
25
 #config_form { display: block; background: #DDD; padding: 20px; color: #000; position: relative; }
26
 /*#config_text, #config_adv_text { font-family: "Andale mono", monospace; clear: both; }*/
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
 input[type="checkbox"], input[type="radio"].enabler { margin-left: 1em; }
36
 input[type="checkbox"], input[type="radio"].enabler { margin-left: 1em; }
29
 input:disabled { color: #BBB; }
37
 input:disabled { color: #BBB; }
30
 .clear { clear: both; }
38
 .clear { clear: both; }
109
 	bottom: -10px;
117
 	bottom: -10px;
110
 	left: 20px;
118
 	left: 20px;
111
 	}
119
 	}
120
+#tooltip>strong { color: #00B; }

+ 19
- 19
Marlin/configurator/js/configurator.js View File

27
 };
27
 };
28
 String.prototype.prePad = function(len, chr) { return len ? this.lpad(len, chr) : this; };
28
 String.prototype.prePad = function(len, chr) { return len ? this.lpad(len, chr) : this; };
29
 String.prototype.zeroPad = function(len)     { return this.prePad(len, '0'); };
29
 String.prototype.zeroPad = function(len)     { return this.prePad(len, '0'); };
30
+String.prototype.toHTML = function()         { return jQuery('<div>').text(this).html(); };
30
 String.prototype.regEsc = function()         { return this.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); }
31
 String.prototype.regEsc = function()         { return this.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); }
31
 String.prototype.lineCount = function()      { var len = this.split(/\r?\n|\r/).length; return len > 0 ? len - 1 : len; };
32
 String.prototype.lineCount = function()      { var len = this.split(/\r?\n|\r/).length; return len > 0 ? len - 1 : len; };
32
 
33
 
367
             $tipme.hover(
368
             $tipme.hover(
368
               function() {
369
               function() {
369
                 var pos = $tipme.position();
370
                 var pos = $tipme.position();
370
-                $tooltip.text(inf.comment)
371
+                $tooltip.html(inf.comment)
371
                   .append('<span>')
372
                   .append('<span>')
372
                   .css({bottom:($tooltip.parent().outerHeight()-pos.top)+'px',left:(pos.left+70)+'px'})
373
                   .css({bottom:($tooltip.parent().outerHeight()-pos.top)+'px',left:(pos.left+70)+'px'})
373
                   .show();
374
                   .show();
484
      *   then update, highlight, and scroll to the line
485
      *   then update, highlight, and scroll to the line
485
      */
486
      */
486
     setDefineLine: function(name, newline) {
487
     setDefineLine: function(name, newline) {
488
+      this.log('setDefineLine:'+name+'\n'+newline,4);
487
       var $elm = $('#'+name), elm = $elm[0], inf = elm.defineInfo;
489
       var $elm = $('#'+name), elm = $elm[0], inf = elm.defineInfo;
488
       var $c = $(inf.field), txt = $c.text();
490
       var $c = $(inf.field), txt = $c.text();
489
 
491
 
492
       txt = txt.replace(inf.line, hilite_token + newline);
494
       txt = txt.replace(inf.line, hilite_token + newline);
493
       inf.line = newline;
495
       inf.line = newline;
494
 
496
 
495
-      this.log(newline, 2);
496
-
497
       // Convert txt into HTML before storing
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
       // Set the final text including the highlighter
500
       // Set the final text including the highlighter
501
       $c.html(html);
501
       $c.html(html);
634
         // Get the end-of-line comment, if there is one
634
         // Get the end-of-line comment, if there is one
635
         var comment = '';
635
         var comment = '';
636
         findDef = new RegExp('.*#define[ \\t].*/[/*]+[ \\t]*(.*)');
636
         findDef = new RegExp('.*#define[ \\t].*/[/*]+[ \\t]*(.*)');
637
-        if (info.line.search(findDef) >= 0) {
637
+        if (info.line.search(findDef) >= 0)
638
           comment = info.line.replace(findDef, '$1');
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
         $.extend(info, {
655
         $.extend(info, {
656
-          comment: comment.trim(),
656
+          comment: '<strong>'+name+'</strong> '+comment.replace(findDef,'').trim().toHTML(),
657
           lineNum: this.getLineNumberOfText(info.line, txt)
657
           lineNum: this.getLineNumberOfText(info.line, txt)
658
         });
658
         });
659
       }
659
       }

Loading…
Cancel
Save