Skip to content

Commit b43727a

Browse files
committed
Changed Favourites/Community details to show only the currently selected tool.
1 parent 031efc6 commit b43727a

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

index.html

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

108-
<div class="tool-wrap-replace">
109-
<h1>Replace</h1>
108+
<div class="tool-wrap">
109+
<h1 class="tool-label"></h1>
110110
<hr/>
111-
<div class='load icon tool-replace'></div>
112-
<code class="tool tool-replace-content"></code>
111+
<div class='load icon tool'></div>
112+
<code class="tool tool-content"></code>
113113
</div>
114-
115-
<div class="tool-wrap-list">
116-
<h1>List</h1>
117-
<hr/>
118-
<div class='load icon tool-list'></div>
119-
<code class="tool tool-list-content"></code>
120-
</div>
121114
</div>
122115
</div>
123116
</div>

js/views/Favorites.js

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

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);
60+
this.toolWrap = $.el(".tool-wrap", this.contentTemplate);
61+
this.toolContent = $.el(".tool-content", this.contentTemplate);
62+
this.toolTitle = $.el(".tool-label", this.contentTemplate);
6463

6564
this.favoriteBtn = $.el(".favorite", this.contentTemplate);
6665
this.favoriteBtn.addEventListener("mouseover", $.bind(this, this.handleFavoriteOver));
@@ -219,17 +218,14 @@ p.handleFavoritesLoad = function (data) {
219218
p.onLoadClick = function (evt) {
220219
var el = evt.target;
221220
var type = '';
222-
223221
if ($.hasClass(el, ".expr")) {
224222
type = "expr";
225223
} else if ($.hasClass(el, ".source")) {
226224
type = "source";
227225
} else if ($.hasClass(el, ".all")) {
228226
type = "all";
229-
} else if ($.hasClass(el, ".tool-list")) {
230-
type = "list";
231-
}else if ($.hasClass(el, ".tool-replace")) {
232-
type = "replace";
227+
} else if ($.hasClass(el, ".tool")) {
228+
type = this.list.selectedItem.state.tool;
233229
}
234230
this.insertContent(type);
235231
};
@@ -338,20 +334,13 @@ p.onListChange = function (evt) {
338334

339335
this.updateFavorite(data.id);
340336

341-
if (data.state && data.state.replace) {
342-
this.toolReplace.innerHTML = TextUtils.htmlSafe(data.state["replace"]);
343-
344-
$.removeClass(this.toolWrapReplace, "hidden");
345-
} else {
346-
$.addClass(this.toolWrapReplace, "hidden");
347-
}
348-
349-
if (data.state && data.state.list) {
350-
this.toolList.innerHTML = TextUtils.htmlSafe(data.state["list"]);
337+
if (data.state && data.state.tool && data.state[data.state.tool]) {
338+
this.toolContent.innerHTML = TextUtils.htmlSafe(data.state[data.state.tool]);
339+
this.toolTitle.innerText = data.state.tool.substr(0, 1).toUpperCase() + data.state.tool.substr(1);
351340

352-
$.removeClass(this.toolWrapList, "hidden");
341+
$.removeClass(this.toolWrap, "hidden");
353342
} else {
354-
$.addClass(this.toolWrapList, "hidden");
343+
$.addClass(this.toolWrap, "hidden");
355344
}
356345

357346

0 commit comments

Comments
 (0)