Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit a977e0c

Browse files
committed
Styling change and inclusion of doc on hover.
1 parent e0ae9fd commit a977e0c

File tree

2 files changed

+146
-79
lines changed

2 files changed

+146
-79
lines changed

src/extensions/default/JavaScriptCodeHints/main.js

+31-24
Original file line numberDiff line numberDiff line change
@@ -161,49 +161,49 @@ define(function (require, exports, module) {
161161
};
162162
}
163163

164-
function inferArrayType(typeExpr) {
165-
var type = "[?]";
164+
function inferArrayTypeClass(typeExpr) {
165+
var type = "type-array";
166166
var types = typeExpr.split('[')[1].split(']')[0].split(',');
167167

168168
_infered = true;
169169

170170
types.every(getInferHelper('string'));
171171
if (_infered) {
172-
type = '[S]';
172+
type = 'type-string-array';
173173
} else {
174174
_infered = true;
175175
types.every(getInferHelper('number'));
176176
if (_infered) {
177-
type = '[N]';
177+
type = 'type-num-array';
178178
} else {
179179
_infered = true;
180180
types.every(getInferHelper('Object'));
181181
if (_infered) {
182-
type = '[O]';
182+
type = 'type-object-array';
183183
}
184184
}
185185
}
186186
return type;
187187
}
188188

189-
function getRenderType(type) {
190-
var typeString = " ";
189+
function getRenderTypeClass(type) {
190+
var typeClass = 'type-undetermined';
191191
if (type) {
192192
if (type.indexOf('Object') === 0) {
193-
typeString = 'O';
193+
typeClass = 'type-object';
194194
} else if (type.indexOf('[') === 0) {
195-
typeString = inferArrayType(type);
195+
typeClass = inferArrayTypeClass(type);
196196
} else if (type.indexOf('fn') === 0) {
197-
typeString = 'fn';
197+
typeClass = 'type-function';
198198
} else if (type.indexOf('string') === 0) {
199-
typeString = "S";
199+
typeClass = "type-string";
200200
} else if (type.indexOf('number') === 0) {
201-
typeString = 'N';
201+
typeClass = 'type-number';
202202
} else if (type.indexOf('bool') === 0) {
203-
typeString = 'B';
203+
typeClass = 'type-boolean';
204204
}
205205
}
206-
return typeString;
206+
return typeClass;
207207
}
208208

209209
/*
@@ -222,7 +222,8 @@ define(function (require, exports, module) {
222222
function formatHints(hints, query) {
223223
return hints.map(function (token) {
224224
var $hintObj = $("<span>").addClass("brackets-js-hints");
225-
$('<span>' + getRenderType(token.type) + '</span>').appendTo($hintObj).addClass("brackets-js-hints-type");
225+
($hintObj).addClass(getRenderTypeClass(token.type));
226+
//$('<span>' + getRenderType(token.type) + '</span>').appendTo($hintObj).addClass("brackets-js-hints-type");
226227
// level indicates either variable scope or property confidence
227228
if (!type.property && !token.builtin && token.depth !== undefined) {
228229
switch (token.depth) {
@@ -268,24 +269,30 @@ define(function (require, exports, module) {
268269
} else {
269270
$hintObj.text(token.value);
270271
}
271-
272+
272273
$hintObj.data("token", token);
273274

274-
if (token.url) {
275-
$('<a href=' + token.url + '>ooo</a>').appendTo($hintObj).addClass("jshint-description-url");
276-
}
277-
278275
if (token.type) {
279-
//$('<span>' + " " + token.type.split('->').join(':') + '</span>').appendTo($hintObj).addClass("brackets-js-hints-type-details");
280-
$('<span>' + " " + token.type.split('->').join(':') + '</span>').appendTo($hintObj).addClass("jshint-description");
276+
if (token.type.length > 40) {
277+
if (token.url) {
278+
$('<a>' + " " + token.type.split('->').join(':').trim() + '</a>').appendTo($hintObj).addClass("jshint-description").attr('href', token.url);
279+
} else {
280+
$('<span>' + " " + token.type.split('->').join(':').trim() + '</span>').appendTo($hintObj).addClass("jshint-description");
281+
}
282+
} else {
283+
if (token.url) {
284+
$('<a>' + " " + token.type.split('->').join(':').trim() + '</a>').appendTo($hintObj).addClass("brackets-js-hints-type-details").attr('href', token.url);
285+
} else {
286+
$('<span>' + " " + token.type.split('->').join(':').trim() + '</span>').appendTo($hintObj).addClass("brackets-js-hints-type-details");
287+
}
288+
}
281289
} else {
282290
if (token.keyword) {
283291
$('<span>' + " " + "keyword" + '</span>').appendTo($hintObj).addClass("brackets-js-hints-type-details").addClass("keyword");
284292
}
285293
}
286294

287295
if (token.doc) {
288-
//$('<span>' + " " + token.doc + '</span>').appendTo($hintObj).addClass("jshint-description");
289296
$hintObj.attr('title', token.doc);
290297
}
291298

@@ -311,7 +318,7 @@ define(function (require, exports, module) {
311318
handleWideResults: hints.handleWideResults
312319
};
313320
}
314-
321+
315322
/**
316323
* @constructor
317324
*/

src/extensions/default/JavaScriptCodeHints/styles/brackets-js-hints.css

+115-55
Original file line numberDiff line numberDiff line change
@@ -25,71 +25,131 @@
2525
width:450px;
2626
}
2727

28-
.brackets-js-hints-type {
29-
font-size: 10px;
28+
.brackets-js-hints.type-undetermined:before {
29+
color: cornflowerblue;
30+
content: '12';
31+
border: 1px cornflowerblue solid;
32+
float:left;
3033
width:25px;
31-
color: white;
32-
font-weight: 900;
3334
text-align: center;
34-
box-sizing: border-box;
35-
font-style:normal;
36-
padding:0px 0px 0px 6px;
37-
float: left;
38-
text-shadow:
39-
-1px -1px 0 #8d8d8d,
40-
1px -1px 0 #8d8d8d,
41-
-1px 1px 0 #8d8d8d,
42-
1px 1px 0 #8d8d8d;
43-
font-stretch: expanded;
44-
}
45-
46-
.dark .brackets-js-hints-type {
47-
text-shadow:
48-
-1px -1px 0 #696969,
49-
1px -1px 0 #696969,
50-
-1px 1px 0 #696969,
51-
1px 1px 0 #696969;
52-
}
53-
54-
.highlight .brackets-js-hints-type {
55-
font-size: 13px;
56-
text-shadow:
57-
-1px -1px 0 #6495ed,
58-
1px -1px 0 #6495ed,
59-
-1px 1px 0 #6495ed,
60-
1px 1px 0 #6495ed;
35+
margin-left:5px;
36+
visibility: hidden;
37+
margin-top:-1px;
38+
line-height: 1.2em;
39+
}
40+
41+
.brackets-js-hints.type-number:before {
42+
color: cornflowerblue;
43+
content: '12';
44+
border: 1px cornflowerblue solid;
45+
float:left;
46+
width:25px;
47+
text-align: center;
48+
margin-left:5px;
49+
margin-top:-1px;
50+
line-height: 1.2em;
51+
}
52+
53+
.brackets-js-hints.type-string:before {
54+
color: cornflowerblue;
55+
content: 'ab';
56+
border: 1px cornflowerblue solid;
57+
float:left;
58+
width:25px;
59+
text-align: center;
60+
margin-left:5px;
61+
margin-top:-1px;
62+
line-height: 1.2em;
63+
}
64+
65+
.brackets-js-hints.type-function:before {
66+
color: cornflowerblue;
67+
content: 'fn( )';
68+
border: 1px cornflowerblue solid;
69+
float:left;
70+
width:25px;
71+
text-align: center;
72+
margin-left:5px;
73+
margin-top:-1px;
74+
line-height: 1.2em;
75+
}
76+
77+
.brackets-js-hints.type-array:before {
78+
color: cornflowerblue;
79+
content: '[ ]';
80+
border: 1px cornflowerblue solid;
81+
float:left;
82+
width:25px;
83+
text-align: center;
84+
margin-left:5px;
85+
margin-top:-1px;
86+
line-height: 1.2em;
87+
}
88+
89+
.brackets-js-hints.type-object:before {
90+
color: cornflowerblue;
91+
content: '{ :}';
92+
border: 1px cornflowerblue solid;
93+
float:left;
94+
width:25px;
95+
text-align: center;
96+
margin-left:5px;
97+
margin-top:-1px;
98+
line-height: 1.2em;
99+
}
100+
101+
.brackets-js-hints.type-num-array:before {
102+
color: cornflowerblue;
103+
content: '[12]';
104+
border: 1px cornflowerblue solid;
105+
float:left;
106+
width:25px;
107+
text-align: center;
108+
margin-left:5px;
109+
margin-top:-1px;
110+
line-height: 1.2em;
111+
}
112+
113+
.brackets-js-hints.type-string-array:before {
114+
color: cornflowerblue;
115+
content: '[ab]';
116+
border: 1px cornflowerblue solid;
117+
float:left;
118+
width:25px;
119+
text-align: center;
120+
margin-left:5px;
121+
margin-top:-1px;
122+
line-height: 1.2em;
123+
}
124+
125+
.brackets-js-hints.type-boolean:before {
126+
color: cornflowerblue;
127+
content: 't/f';
128+
border: 1px cornflowerblue solid;
129+
float:left;
130+
width:25px;
131+
text-align: center;
132+
margin-left:5px;
133+
margin-top:-1px;
134+
line-height: 1.2em;
61135
}
62136

63137
.brackets-js-hints-type-details {
64-
color: #d3d3d3;
138+
color: #d3d3d3 !important;
65139
font-weight: 100;
66-
font-style: italic!important;
67-
padding-left: 20px;
68-
display:none;
140+
font-style: italic !important;
141+
padding-left: 25px;
69142
}
70143

71144
.jshint-description {
72-
line-height: 1.3;
73145
display: none;
74-
padding-bottom: 3px;
75-
padding-left: 37px;
76-
padding-right: 37px;
146+
padding-left: 45px !important;
147+
padding-right:10px !important;
77148
color: #d3d3d3;
78-
box-sizing: border-box;
79-
word-wrap: break-word;
149+
word-wrap: break-word;
80150
white-space: normal;
81151
width:450px;
82-
}
83-
84-
.jshint-description-url {
85-
color: #6495ed;
86-
float : right;
87-
background : transparent !important;
88-
display:none;
89-
}
90-
91-
.highlight .jshint-description-url {
92-
display:inline-block;
152+
box-sizing: border-box;
93153
}
94154

95155
.dark .jshint-description {
@@ -98,15 +158,15 @@
98158

99159
.highlight .jshint-description {
100160
display: block;
101-
color:#6495ed;
161+
color:#6495ed !important;
102162
}
103163

104164
.dark .brackets-js-hints-type-details {
105-
color: #696969;
165+
color: #696969 !important;
106166
}
107167

108168
.highlight .brackets-js-hints-type-details {
109-
color: #6495ed;
169+
color: #6495ed !important;
110170
display: inline-block;
111171
}
112172

0 commit comments

Comments
 (0)