1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-28 09:10:17 +02:00
This commit is contained in:
Kushagra Gour
2018-01-13 10:11:00 +05:30
parent 4bd1d6f358
commit 4ae954813f
4 changed files with 72 additions and 38 deletions

View File

@@ -229,7 +229,7 @@
</div>
<a href="https://webmakerapp.com/" target="_blank"><div class="logo"></div></a>
&copy; Web Maker &nbsp;&nbsp;
&copy;<span class="web-maker-with-tag">Web Maker</span> &nbsp;&nbsp;
<a d-open-modal="helpModal" data-event-category="ui" data-event-action="helpButtonClick" class="footer__link hint--rounded hint--top-right" aria-label="Help">
<svg style="width:20px; height:20px; vertical-align:text-bottom" viewBox="0 0 24 24">
<path d="M15.07,11.25L14.17,12.17C13.45,12.89 13,13.5 13,15H11V14.5C11,13.39 11.45,12.39 12.17,11.67L13.41,10.41C13.78,10.05 14,9.55 14,9C14,7.89 13.1,7 12,7A2,2 0 0,0 10,9H8A4,4 0 0,1 12,5A4,4 0 0,1 16,9C16,9.88 15.64,10.67 15.07,11.25M13,19H11V17H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z" />

View File

@@ -238,14 +238,44 @@ if ('serviceWorker' in navigator) {
});
}
function downloadFile(fileName, blob) {
function downloadWithAnchor() {
var a = document.createElement('a');
a.href = window.URL.createObjectURL(blob);
a.download = fileName;
a.style.display = 'none';
document.body.appendChild(a);
a.click();
a.remove();
}
if (window.IS_EXTENSION) {
chrome.downloads.download(
{
url: window.URL.createObjectURL(blob),
filename: fileName,
saveAs: true
},
() => {
// If there was an error, just download the file using ANCHOR method.
if (chrome.runtime.lastError) {
downloadWithAnchor();
}
}
);
} else {
downloadWithAnchor();
}
}
window.utils = {
semverCompare: semverCompare,
generateRandomId: generateRandomId,
onButtonClick: onButtonClick,
addInfiniteLoopProtection: addInfiniteLoopProtection,
getHumanDate: getHumanDate,
log: log,
once: once
semverCompare,
generateRandomId,
onButtonClick,
addInfiniteLoopProtection,
getHumanDate,
log,
once,
downloadFile
};
window.chrome = window.chrome || {};
@@ -1466,6 +1496,12 @@ loginModal
utils.log('saving key', key || currentItem.id, currentItem);
saveSetting(key || currentItem.id, currentItem);
// If key is `code`, this is a call on unloadbefore to save the last open thing.
// Do not presist that on remote.
if (key === 'code') {
// No deferred required here as this gets called on unloadbefore
return false;
}
return itemService.setItem(key || currentItem.id, currentItem).then(() => {
alertsService.add('Item saved.');
unsavedEditCount = 0;
@@ -2247,14 +2283,9 @@ loginModal
fileName = currentItem.title;
}
var a = document.createElement('a');
var blob = new Blob([fileContent], { type: 'text/html;charset=UTF-8' });
a.href = window.URL.createObjectURL(blob);
a.download = fileName;
a.style.display = 'none';
document.body.appendChild(a);
a.click();
a.remove();
utils.downloadFile(fileName, blob);
trackEvent('fn', 'saveFileComplete');
});
}
@@ -2451,25 +2482,7 @@ loginModal
type: 'application/json;charset=UTF-8'
});
chrome.downloads.download(
{
url: window.URL.createObjectURL(blob),
filename: fileName,
saveAs: true
},
function() {
// If there was an error, just download the file using ANCHOR method.
if (chrome.runtime.lastError) {
var a = document.createElement('a');
a.href = window.URL.createObjectURL(blob);
a.download = fileName;
a.style.display = 'none';
document.body.appendChild(a);
a.click();
a.remove();
}
}
);
utils.downloadFile(fileName, blob);
trackEvent('ui', 'exportBtnClicked');
});
@@ -2633,6 +2646,10 @@ loginModal
function handleDownloadsPermission() {
var d = deferred();
if (!window.IS_EXTENSION) {
d.resolve();
return d.promise;
}
chrome.permissions.contains(
{
permissions: ['downloads']

File diff suppressed because one or more lines are too long

View File

@@ -473,7 +473,8 @@ transition: 0.25s ease;
max-height: 90vh;
box-sizing: border-box;
overflow-y: auto;
transition: all 0.19s;
transition-property: transform, opacity;
transition-duration: 0.19s;
transform: translateY(-50px) scale(0.7);
}
.is-modal-visible {
@@ -495,13 +496,13 @@ transition: 0.25s ease;
opacity: 0;
will-change: opacity;
background: rgba(0,0,0,0.6);
transition: all 0.3s;
transition: opacity 0.3s;
}
/* Make settings modal smaller */
@media screen and (min-width: 600px) {
.modal--settings {
/* width: 600px; */
/* margin-left: -300px; */
/* margin-lef.t: -300px; */
}
}
.saved-items-pane {
@@ -958,6 +959,22 @@ transition: 0.25s ease;
.kbd-shortcut__details {
display: inline-block;
}
.web-maker-with-tag {
position: relative;
display: inline-block;
}
.web-maker-with-tag:after {
content: 'BETA';
position: relative;
left: 3px;
top: -10px;
border-radius: 4px;
background: #b76b29;
color: white;
letter-spacing: 0.6px;
padding: 2px;
font-size: 10px;
}
body.is-logged-in .hide-on-login,
body:not(.is-logged-in) .hide-on-logout {