Skip to content

Commit aa28123

Browse files
committed
- Fixed Community/favourite preview
- Updated ServerModel state to new format.
1 parent 52f45d3 commit aa28123

File tree

3 files changed

+40
-30
lines changed

3 files changed

+40
-30
lines changed

index.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,19 @@ <h1 class="icon regexr-logo">&#xE600;</h1><h1 class="regexr-text">RegExr</h1><sp
103103
<hr/>
104104
</div>
105105

106-
<div class="tool-wrap">
107-
<h1 class="tool-title"></h1>
106+
<div class="tool-wrap-replace">
107+
<h1>Replace</h1>
108108
<hr/>
109-
<div class='load icon subst'></div>
110-
<code class="tool"></code>
109+
<div class='load icon tool-replace'></div>
110+
<code class="tool tool-replace-content"></code>
111111
</div>
112+
113+
<div class="tool-wrap-list">
114+
<h1>List</h1>
115+
<hr/>
116+
<div class='load icon tool-list'></div>
117+
<code class="tool tool-list-content"></code>
118+
</div>
112119
</div>
113120
</div>
114121
</div>

js/net/ServerModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ s.formatPattern = function(data) {
9797
for (var i=0;i<results.length;i++) {
9898
var result =results[i];
9999
if (result.replace != "") {
100-
result.state = {tool:"replace", toolValue:result.replace};
100+
result.state = {tool:"replace", replace:result.replace};
101101
}
102102
}
103103
return data;

js/views/Favorites.js

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ p.init = function (element, content) {
5757
this.previewWrap = $.el(".preview-wrap", this.contentTemplate);
5858
this.preview = $.el(".preview", this.contentTemplate);
5959

60-
this.toolWrap = $.el(".tool-wrap", this.contentTemplate);
61-
this.toolTitle = $.el(".tool-title", this.contentTemplate);
62-
this.tool = $.el(".tool", this.contentTemplate);
60+
this.toolWrapReplace = $.el(".tool-wrap-replace", this.contentTemplate);
61+
this.toolWrapList = $.el(".tool-wrap-list", this.contentTemplate);
62+
this.toolReplace = $.el(".tool-replace-content", this.contentTemplate);
63+
this.toolList = $.el(".tool-list-content", this.contentTemplate);
6364

6465
this.favoriteBtn = $.el(".favorite", this.contentTemplate);
6566
this.favoriteBtn.addEventListener("mouseover", $.bind(this, this.handleFavoriteOver));
@@ -225,8 +226,10 @@ p.onLoadClick = function (evt) {
225226
type = "source";
226227
} else if ($.hasClass(el, ".all")) {
227228
type = "all";
228-
} else if ($.hasClass(el, ".subst")) {
229-
type = "subst";
229+
} else if ($.hasClass(el, ".tool-list")) {
230+
type = "list";
231+
}else if ($.hasClass(el, ".tool-replace")) {
232+
type = "replace";
230233
}
231234
this.insertContent(type);
232235
};
@@ -265,8 +268,12 @@ p.insertContent = function (type) {
265268
this.docView.setFlags(flags);
266269
} else if (type == "source") {
267270
this.docView.setText(data.content);
268-
} else if (type == "subst") {
269-
this.docView.showTool(data.state.tool, data.state.toolValue);
271+
} else if (type == "list") {
272+
this.docView.setState(data.state);
273+
this.docView.showTool("list");
274+
} else if (type == "replace") {
275+
this.docView.setState(data.state);
276+
this.docView.showTool("replace");
270277
} else if (type == "all") {
271278
if (ExpressionModel.id != data.id) {
272279
ExpressionModel.setID(data.id);
@@ -331,27 +338,23 @@ p.onListChange = function (evt) {
331338

332339
this.updateFavorite(data.id);
333340

334-
if (data.state) {
335-
// TODO: Pull into a strings file.
336-
// Also update index.html
337-
var toolText = "";
338-
switch(data.state.tool) {
339-
case "replace":
340-
toolText = "Replace"; break;
341-
case "list":
342-
toolText = "List"; break;
343-
case "details":
344-
toolText = "Details"; break;
345-
case "graph":
346-
toolText = "Graph"; break;
347-
}
348-
this.toolTitle.innerText = toolText;
349-
this.tool.innerHTML = TextUtils.htmlSafe(data.state.toolValue);
350-
$.removeClass(this.toolWrap, "hidden");
341+
if (data.state && data.state.replace) {
342+
this.toolReplace.innerHTML = TextUtils.htmlSafe(data.state["replace"]);
343+
344+
$.removeClass(this.toolWrapReplace, "hidden");
351345
} else {
352-
$.addClass(this.toolWrap, "hidden");
346+
$.addClass(this.toolWrapReplace, "hidden");
353347
}
354348

349+
if (data.state && data.state.list) {
350+
this.toolList.innerHTML = TextUtils.htmlSafe(data.state["list"]);
351+
352+
$.removeClass(this.toolWrapList, "hidden");
353+
} else {
354+
$.addClass(this.toolWrapList, "hidden");
355+
}
356+
357+
355358
if (this._visible) {
356359
$.removeClass(this.element, "hidden");
357360
this.showLoading(false);

0 commit comments

Comments
 (0)