Skip to content

Commit 74593fa

Browse files
committed
removed save button for disable popup checkbox
1 parent 6aafdac commit 74593fa

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

source/options.css

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* Base styles */
12
html,
23
body {
34
font-family: 'Roboto', sans-serif;
@@ -17,6 +18,17 @@ a {
1718
color: #4285f4;
1819
}
1920

21+
/* Fade transition */
22+
.fade {
23+
opacity: 0;
24+
transition: opacity .15s linear;
25+
}
26+
27+
.fade.show {
28+
opacity: 1;
29+
}
30+
31+
/* Page styles */
2032
.contentTxt {
2133
margin-bottom: 5px;
2234
}
@@ -104,4 +116,11 @@ a {
104116
position: relative;
105117
top: 4px;
106118
margin-right: 5px;
107-
}
119+
}
120+
121+
/* Disable Popup */
122+
.disable-popup-saved {
123+
color: #5cb85c;
124+
font-weight: bold;
125+
margin-left: 5px;
126+
}

source/options.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ <h3>Disable Popup</h3>
6767
xdebug helper icon, xdebug helper's popup will be disabled.
6868
</p>
6969
<p>
70-
<input type="checkbox" id="disable-popup" value="1">
71-
<span>Disable Popup</span>
72-
<button class="save-button">Save</button>
70+
<label>
71+
<input type="checkbox" id="disable-popup" value="1">
72+
<span>Disable Popup</span>
73+
</label>
74+
<span class="disable-popup-saved fade">Saved</span>
7375
</p>
7476

7577
<footer id="footer">

source/options.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
// setTimeout() return value
2+
let disablePopupTimeout;
3+
14
function save_options()
25
{
36
localStorage["xdebugIdeKey"] = document.getElementById("idekey").value;
47
localStorage["xdebugTraceTrigger"] = document.getElementById("tracetrigger").value;
58
localStorage["xdebugProfileTrigger"] = document.getElementById("profiletrigger").value;
6-
localStorage.xdebugDisablePopup = document.getElementById('disable-popup').checked ? '1' : '0';
9+
localStorage.xdebugDisablePopup = document.getElementById('disable-popup').checked ? '1' : '0';
710
}
811

912
function restore_options()
@@ -45,7 +48,7 @@ function restore_options()
4548
}
4649

4750
// Restore Disable Popup
48-
document.getElementById('disable-popup').checked = (localStorage.xdebugDisablePopup === '1') ? true : false;
51+
document.getElementById('disable-popup').checked = (localStorage.xdebugDisablePopup === '1') ? true : false;
4952
}
5053

5154
$(function()
@@ -67,10 +70,27 @@ $(function()
6770

6871
$("#idekey").change(save_options);
6972

70-
// Save Disable Popup on change event
71-
$('#disable-popup').change(save_options);
73+
// Persist Disable Popup on onChange event
74+
$('#disable-popup').change(disablePopupChanged);
7275

7376
$('.save-button').click(save_options);
7477

7578
restore_options();
7679
});
80+
81+
/**
82+
* Disable Popup checkbox changed, persist it.
83+
*/
84+
function disablePopupChanged() {
85+
const $disablePopupSaved = $('.disable-popup-saved');
86+
87+
$disablePopupSaved.addClass('show');
88+
89+
// First clear interval
90+
clearInterval(disablePopupTimeout);
91+
// Hide after 2 seconds
92+
disablePopupTimeout = setTimeout(() => $disablePopupSaved.removeClass('show'), 2000);
93+
94+
// Persist
95+
save_options();
96+
}

0 commit comments

Comments
 (0)