Skip to content

Commit 381a7b4

Browse files
committed
Fix issue #18 by making buttons actually buttons in Spaces and Popup. Handle when the user blurs the space name edit box.
1 parent c25ff6e commit 381a7b4

File tree

5 files changed

+40
-16
lines changed

5 files changed

+40
-16
lines changed

css/popup.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ a {
4949
white-space: nowrap;
5050
cursor: pointer;
5151
padding: 0 10px;
52+
display: block;
53+
width: 100%;
54+
text-align: left;
55+
background: transparent;
56+
border: none;
57+
font-family: 'Open Sans', sans-serif;
58+
font-size: 14px;
59+
font-weight: 200;
5260
}
5361
.menuOption .optionText:hover {
5462
text-decoration: underline;

css/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ a.active {
195195
display: none;
196196
padding: 21px 14px;
197197
font-size: 25px;
198+
background: transparent;
199+
border: none;
200+
color: #000;
198201
}
199202
.header .button:hover {
200203
cursor: pointer;

js/popup.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,18 @@ async function renderMainCard() {
144144
}
145145

146146
document
147-
.querySelector('#allSpacesLink .optionText')
147+
.getElementById('allSpacesLink')
148148
.addEventListener('click', () => {
149149
chrome.runtime.sendMessage({
150150
action: 'requestShowSpaces',
151151
});
152152
window.close();
153153
});
154154
document
155-
.querySelector('#switcherLink .optionText')
155+
.getElementById('switcherLink')
156156
.addEventListener('click', () => handlePopupMenuClick('switch'));
157157
document
158-
.querySelector('#moverLink .optionText')
158+
.getElementById('moverLink')
159159
.addEventListener('click', () => handlePopupMenuClick('move'));
160160
}
161161

@@ -194,6 +194,12 @@ async function handleNameSave() {
194194
const inputEl = document.getElementById('activeSpaceTitle');
195195
const newName = inputEl.value;
196196

197+
// If the input is empty and the space was previously unnamed, restore the placeholder.
198+
if (newName.trim() === '' && !globalCurrentSpace.name) {
199+
inputEl.value = UNSAVED_SESSION;
200+
return;
201+
}
202+
197203
if (
198204
newName === UNSAVED_SESSION ||
199205
newName === globalCurrentSpace.name
@@ -209,19 +215,26 @@ async function handleNameSave() {
209215
}
210216

211217
if (globalCurrentSpace.sessionId) {
212-
chrome.runtime.sendMessage({
218+
const updatedSession = await chrome.runtime.sendMessage({
213219
action: 'updateSessionName',
214220
deleteOld: true,
215221
sessionName: newName,
216222
sessionId: globalCurrentSpace.sessionId,
217223
});
224+
if (updatedSession) {
225+
globalCurrentSpace.name = updatedSession.name;
226+
}
218227
} else {
219-
chrome.runtime.sendMessage({
228+
const newSession = await chrome.runtime.sendMessage({
220229
action: 'saveNewSession',
221230
deleteOld: true,
222231
sessionName: newName,
223232
windowId: globalCurrentSpace.windowId,
224233
});
234+
if (newSession) {
235+
globalCurrentSpace.name = newSession.name;
236+
globalCurrentSpace.sessionId = newSession.id;
237+
}
225238
}
226239
}
227240

popup.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,21 @@
6363
<div id="popupContainer">
6464

6565
<div class="group optsAll">
66-
<div class="menuOption" href="#" id="allSpacesLink">
66+
<button class="menuOption" id="allSpacesLink">
6767
<i class="fa fa-th-large"></i>
6868
<span class="optionText">Manage spaces</span>
6969
<span class="hotkey"></span>
70-
</div>
71-
<div class="menuOption" href="#" id="switcherLink">
70+
</button>
71+
<button class="menuOption" id="switcherLink">
7272
<i class="fa fa-exchange"></i>
7373
<span class="optionText">Quick switch spaces</span>
7474
<span class="hotkey"></span>
75-
</div>
76-
<div class="menuOption" href="#" id="moverLink">
75+
</button>
76+
<button class="menuOption" id="moverLink">
7777
<i class="fa fa-arrow-circle-right"></i>
7878
<span class="optionText">Move active tab</span>
7979
<span class="hotkey"></span>
80-
</div>
80+
</button>
8181
</div>
8282
</div>
8383
</body>

spaces.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ <h2>Import / Export:</h2>
4444
<span id="nameDisplay"></span>
4545
<input type="text" placeholder="Name this space" />
4646
</form>
47-
<span id='actionSwitch' title="Switch to this space" class="button fa fa-arrow-circle-right"></span>
48-
<span id='actionOpen' title="Open this space" class="button fa fa-external-link"></span>
47+
<button id='actionSwitch' title="Switch to this space" class="button fa fa-arrow-circle-right"></button>
48+
<button id='actionOpen' title="Open this space" class="button fa fa-external-link"></button>
4949
<div class="buttonNav">
50-
<span id='actionEdit' title="Rename space" class="button fa fa-pencil"></span>
51-
<span id='actionExport' title="Export space" class="button fa fa-download"></span>
52-
<span id='actionDelete' title="Delete space" class="button fa fa-trash"></span>
50+
<button id='actionEdit' title="Rename space" class="button fa fa-pencil"></button>
51+
<button id='actionExport' title="Export space" class="button fa fa-download"></button>
52+
<button id='actionDelete' title="Delete space" class="button fa fa-trash"></button>
5353
</div>
5454
</div>
5555

0 commit comments

Comments
 (0)