-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from szachara/enhance_ux_browser_action
Enhance UX for the browser action, possibility to disable popup
- Loading branch information
Showing
5 changed files
with
233 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.DS_Store | ||
.DS_Store | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,103 @@ | ||
function save_options() | ||
{ | ||
localStorage["xdebugIdeKey"] = document.getElementById("idekey").value; | ||
localStorage["xdebugTraceTrigger"] = document.getElementById("tracetrigger").value; | ||
localStorage["xdebugProfileTrigger"] = document.getElementById("profiletrigger").value; | ||
} | ||
|
||
function restore_options() | ||
{ | ||
// Restore IDE Key | ||
idekey = localStorage["xdebugIdeKey"]; | ||
|
||
if (!idekey) | ||
{ | ||
idekey = "XDEBUG_ECLIPSE"; | ||
} | ||
(function () { | ||
|
||
if (idekey == "XDEBUG_ECLIPSE" || idekey == "netbeans-xdebug" || idekey == "macgdbp" || idekey == "PHPSTORM") | ||
// setTimeout() return value | ||
let disablePopupTimeout; | ||
|
||
function save_options() | ||
{ | ||
$("#ide").val(idekey); | ||
$("#idekey").prop('disabled', true); | ||
localStorage["xdebugIdeKey"] = document.getElementById("idekey").value; | ||
localStorage["xdebugTraceTrigger"] = document.getElementById("tracetrigger").value; | ||
localStorage["xdebugProfileTrigger"] = document.getElementById("profiletrigger").value; | ||
localStorage.xdebugDisablePopup = document.getElementById('disable-popup').checked ? '1' : '0'; | ||
} | ||
else | ||
|
||
function restore_options() | ||
{ | ||
$("#ide").val("null"); | ||
$("#idekey").prop('disabled', false); | ||
} | ||
$('#idekey').val(idekey); | ||
|
||
// Restore Trace Triggers | ||
var traceTrigger = localStorage["xdebugTraceTrigger"]; | ||
if (traceTrigger !== null) { | ||
$("#tracetrigger").val(traceTrigger); | ||
} else { | ||
$("#tracetrigger").val(null); | ||
} | ||
// Restore IDE Key | ||
idekey = localStorage["xdebugIdeKey"]; | ||
|
||
// Restore Profile Triggers | ||
var profileTrigger = localStorage["xdebugProfileTrigger"]; | ||
if (profileTrigger !== null) { | ||
$("#profiletrigger").val(profileTrigger); | ||
} else { | ||
$("#profiletrigger").val(null); | ||
} | ||
} | ||
if (!idekey) | ||
{ | ||
idekey = "XDEBUG_ECLIPSE"; | ||
} | ||
|
||
$(function() | ||
{ | ||
$("#ide").change(function () | ||
{ | ||
if ($("#ide").val() != "null") | ||
if (idekey == "XDEBUG_ECLIPSE" || idekey == "netbeans-xdebug" || idekey == "macgdbp" || idekey == "PHPSTORM") | ||
{ | ||
$("#ide").val(idekey); | ||
$("#idekey").prop('disabled', true); | ||
$("#idekey").val($("#ide").val()); | ||
|
||
save_options(); | ||
} | ||
else | ||
{ | ||
$("#ide").val("null"); | ||
$("#idekey").prop('disabled', false); | ||
} | ||
$('#idekey').val(idekey); | ||
|
||
// Restore Trace Triggers | ||
var traceTrigger = localStorage["xdebugTraceTrigger"]; | ||
if (traceTrigger !== null) { | ||
$("#tracetrigger").val(traceTrigger); | ||
} else { | ||
$("#tracetrigger").val(null); | ||
} | ||
|
||
// Restore Profile Triggers | ||
var profileTrigger = localStorage["xdebugProfileTrigger"]; | ||
if (profileTrigger !== null) { | ||
$("#profiletrigger").val(profileTrigger); | ||
} else { | ||
$("#profiletrigger").val(null); | ||
} | ||
|
||
// Restore Disable Popup | ||
document.getElementById('disable-popup').checked = (localStorage.xdebugDisablePopup === '1') ? true : false; | ||
} | ||
|
||
$(function() | ||
{ | ||
$("#ide").change(function () | ||
{ | ||
if ($("#ide").val() != "null") | ||
{ | ||
$("#idekey").prop('disabled', true); | ||
$("#idekey").val($("#ide").val()); | ||
|
||
save_options(); | ||
} | ||
else | ||
{ | ||
$("#idekey").prop('disabled', false); | ||
} | ||
}); | ||
|
||
$("#idekey").change(save_options); | ||
|
||
// Persist Disable Popup on onChange event | ||
$('#disable-popup').change(disablePopupChanged); | ||
|
||
$('.save-button').click(save_options); | ||
|
||
restore_options(); | ||
}); | ||
|
||
$("#idekey").change(save_options); | ||
/** | ||
* Disable Popup checkbox changed, persist it. | ||
*/ | ||
function disablePopupChanged() { | ||
const $disablePopupSaved = $('.disable-popup-saved'); | ||
|
||
$disablePopupSaved.addClass('show'); | ||
|
||
$('.save-button').click(save_options); | ||
// First clear interval | ||
clearInterval(disablePopupTimeout); | ||
// Hide after 2 seconds | ||
disablePopupTimeout = setTimeout(() => $disablePopupSaved.removeClass('show'), 2000); | ||
|
||
// Persist | ||
save_options(); | ||
|
||
// We need to reload the extension, because to hide the popup | ||
chrome.extension.getBackgroundPage().window.location.reload(true); | ||
} | ||
|
||
restore_options(); | ||
}); | ||
})(); |