1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-30 18:20:15 +02:00

script: fix the manual preview functionality. fixes #290

This commit is contained in:
Kushagra Gour
2018-04-23 00:30:45 +05:30
parent 9b4f6dfc33
commit 2f9322832c
2 changed files with 14 additions and 4 deletions

View File

@@ -70,7 +70,7 @@
<div class="main-header">
<input type="text" id="js-title-input" title="Click to edit" class="item-title-input" value="Untitled Work">
<div class="main-header__btn-wrap flex flex-v-center">
<a id="runBtn" class="hide flex flex-v-center hint--rounded hint--bottom-left" aria-label="Run preview (Ctrl/⌘ + Shift + 5)" d-click="setPreviewContent">
<a id="runBtn" class="hide flex flex-v-center hint--rounded hint--bottom-left" aria-label="Run preview (Ctrl/⌘ + Shift + 5)" d-click="onRunBtnClick">
<svg style="width: 14px; height: 14px;">
<use xlink:href="#play-icon"></use>
</svg>Run

View File

@@ -1187,8 +1187,13 @@ loginModal, profileModal, profileAvatarImg, profileUserName, openItemsBtn, askTo
}
}
scope.setPreviewContent = function(isForced) {
if (!prefs.autoPreview) {
/**
* Generates the preview from the current code.
* @param {boolean} isForced Should refresh everything without any check or not
* @param {boolean} isManual Is this a manual preview request from user?
*/
scope.setPreviewContent = function(isForced, isManual) {
if (!prefs.autoPreview && !isManual) {
return;
}
@@ -2022,6 +2027,11 @@ loginModal, profileModal, profileAvatarImg, profileUserName, openItemsBtn, askTo
});
}
scope.onRunBtnClick = function() {
scope.setPreviewContent(true, true);
trackEvent('ui', 'runBtnClick');
};
scope.openDetachedPreview = function() {
trackEvent('ui', 'detachPreviewBtnClick');
@@ -2345,7 +2355,7 @@ loginModal, profileModal, profileAvatarImg, profileUserName, openItemsBtn, askTo
event.keyCode === 53
) {
event.preventDefault();
scope.setPreviewContent(true);
scope.setPreviewContent(true, true);
trackEvent('ui', 'previewKeyboardShortcut');
} else if ((event.ctrlKey || event.metaKey) && event.keyCode === 79) {
// Ctrl/⌘ + O