Skip to content

Commit

Permalink
Merge pull request #43 from earvinpiamonte/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
earvinpiamonte authored Oct 4, 2020
2 parents 75c87c3 + 5a5613f commit 04b85fb
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 24 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

1 change: 1 addition & 0 deletions app.css
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ dialog {
background-color: var(--component-background);
border-radius: calc(var(--radius) / 2);
line-height: 1.5;
font-size: 0.95rem;
color: var(--text-color);
}

Expand Down
1 change: 0 additions & 1 deletion app.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
</footer>
<!-- /.footer -->

<script src="libs/autosize/autosize.min.js"></script>
<script type="module" src="app.js"></script>
</body>
<!-- /.h-100 w-100 py-2 -->
Expand Down
17 changes: 8 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
decodeVariable,
downloadAsTextFile,
dialog,
autoResizeTextarea,
} from "./helper.js";
import { chromeGetData, chromeSetData } from "./chrome.js";

Expand Down Expand Up @@ -32,8 +33,6 @@ function loadEventListeners() {
const saveTimeout = 500;
let typingTimer;

autosize($notes);

$copyToClipboard.addEventListener("click", function () {
if ($notes.value.length < 1) {
dialog({
Expand All @@ -45,7 +44,8 @@ function loadEventListeners() {
}
copyToClipboard($notes, function () {
dialog({
content: "Copied, you're all set to send it anywhere you want!",
content:
"Copied to clipboard, you're all set to send it anywhere you want.",
type: "alert",
});
console.log("Copied!");
Expand All @@ -70,7 +70,7 @@ function loadEventListeners() {

dialog({
content: `
Are you sure you want to use your template for your notes now? This will override your current notes.
Are you sure you want to use your Notes template now? This will override your current notes.
`,
confirmCallback: () => {
loadNotesTemplate();
Expand Down Expand Up @@ -103,8 +103,7 @@ async function loadNotesTemplate() {
if (notesTemplate) {
$notes.value = decodeVariable(notesTemplate);

autosize.update($notes);

autoResizeTextarea($notes);
saveNotes();

console.log("I won't feel a thing");
Expand Down Expand Up @@ -188,7 +187,7 @@ async function restoreSettings() {
$notes.value = notesTemplate;
$notesCurrentChars.innerHTML = maxNotesChars - $notes.value.length;

autosize.update($notes);
autoResizeTextarea($notes);
saveNotes(); // Save currently loaded template as notes
return;
}
Expand All @@ -197,7 +196,7 @@ async function restoreSettings() {
$notes.value = notes;
$notesCurrentChars.innerHTML = maxNotesChars - $notes.value.length;

autosize.update($notes);
autoResizeTextarea($notes);
return;
}

Expand All @@ -207,5 +206,5 @@ async function restoreSettings() {
$notes.value = notes;
$notesCurrentChars.innerHTML = maxNotesChars - $notes.value.length;

autosize.update($notes);
autoResizeTextarea($notes);
}
15 changes: 15 additions & 0 deletions helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ const showElement = ($element) => {
$element.style.display = "";
};

const resizeTextareaHandler = (e) => {
const $this = e.target ?? e;

$this.style.height = `auto`;
$this.style.height = `${$this.scrollHeight}px`;
$this.style.resize = `none`;
};

const autoResizeTextarea = ($textarea) => {
resizeTextareaHandler($textarea);

$textarea.addEventListener("input", resizeTextareaHandler, false);
};

export {
copyToClipboard,
getCurrentFullDate,
Expand All @@ -198,4 +212,5 @@ export {
decodeVariable,
downloadAsTextFile,
dialog,
autoResizeTextarea,
};
6 changes: 0 additions & 6 deletions libs/autosize/autosize.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "daylight",
"version": "0.1.0",
"version": "0.4.0",
"manifest_version": 2,
"description": "Write down notes directly on the new tab page of your Google Chrome browser.",
"author": "Noel Earvin Piamonte",
Expand Down
3 changes: 1 addition & 2 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h1 class="mb-1">Settings</h1>
</div>
<!-- /.mb-1 -->
<div class="textarea-with-toolbar pt-0">
<label for="app-notes-template">Template</label>
<label for="app-notes-template">Notes template</label>
<textarea
name="app-notes-template"
id="app-notes-template"
Expand Down Expand Up @@ -110,7 +110,6 @@ <h1 class="mb-1">Settings</h1>
</footer>
<!-- /.footer -->

<script src="libs/autosize/autosize.min.js"></script>
<script type="module" src="settings.js"></script>
</body>
<!-- /.h-100 w-100 py-2 -->
Expand Down
8 changes: 4 additions & 4 deletions settings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { goBack, dialog } from "./helper.js";
import { goBack, dialog, autoResizeTextarea } from "./helper.js";
import { chromeGetData, chromeSetData } from "./chrome.js";

const maxNotesChars = 999;
Expand All @@ -19,7 +19,7 @@ function loadEventListeners() {
const $darkModeToggle = document.querySelector("#app-dark-mode");
const $html = document.querySelector("html");

autosize($notesTemplate);
autoResizeTextarea($notesTemplate);

$submitSettingsBtn.addEventListener("click", submitSettings);

Expand Down Expand Up @@ -48,7 +48,7 @@ async function submitSettings() {
chromeSetData("enableDarkMode", $darkModeToggle.checked);

dialog({
content: "Settings successfully saved.",
content: "Your settings have been saved.",
type: "alert",
confirmCallback: () => {
goBack();
Expand All @@ -75,7 +75,7 @@ async function restoreSettings() {

$notesCurrentChars.innerHTML = maxNotesChars - $notesTemplate.value.length;

autosize.update($notesTemplate);
autoResizeTextarea($notesTemplate);

// If dark mode is enabled
$html.dataset.theme = enableDarkMode ? "dark" : "light";
Expand Down

0 comments on commit 04b85fb

Please sign in to comment.