-
Notifications
You must be signed in to change notification settings - Fork 3
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 #10 from trendyminds/update/3.0.0
3.0.0
- Loading branch information
Showing
17 changed files
with
1,478 additions
and
1,939 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,19 +1,21 @@ | ||
{ | ||
"name": "visor", | ||
"version": "1.0.0", | ||
"version": "3.0.0", | ||
"description": "A simple admin overlay to get to the relevant areas of the Craft CMS control panel", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "parcel watch resources/visor.js --out-dir src/resources", | ||
"build": "parcel build resources/visor.js --out-dir src/resources" | ||
"start": "parcel watch resources/visor.js --out-dir src/resources --no-source-maps", | ||
"build": "parcel build resources/visor.js --out-dir src/resources --no-source-maps --no-content-hash" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"prettier": {}, | ||
"devDependencies": { | ||
"parcel-bundler": "^1.12.4" | ||
"parcel-bundler": "^1.12.4", | ||
"prettier": "2.0.5" | ||
}, | ||
"dependencies": { | ||
"hotkeys-js": "^3.4.3" | ||
"hotkeys-js": "^3.8.1" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import hotkeys from "hotkeys-js"; | ||
import "./visor.css"; | ||
|
||
export default class Visor { | ||
constructor() { | ||
this.isOpen = false; | ||
this.$toggle = document.querySelectorAll("[data-visor-toggle]"); | ||
this.$modal = document.querySelector("[data-visor]"); | ||
|
||
this.handleToggle = this.handleToggle.bind(this); | ||
this.open = this.open.bind(this); | ||
this.close = this.close.bind(this); | ||
|
||
// Change the initial display: none to display: block after DOM element added. | ||
// This prevents a "flash" of an animation that would've fired if a user clicked the Visor element | ||
this.$modal.querySelector(".Visor__modal").style.display = "block"; | ||
|
||
this.events(); | ||
} | ||
|
||
events() { | ||
this.$toggle.forEach(($toggle) => | ||
$toggle.addEventListener("click", this.handleToggle) | ||
); | ||
|
||
hotkeys("`", this.handleToggle); | ||
hotkeys("esc", this.close); | ||
} | ||
|
||
handleToggle() { | ||
if (this.isOpen) { | ||
return this.close(); | ||
} | ||
|
||
return this.open(); | ||
} | ||
|
||
close() { | ||
this.isOpen = false; | ||
this.$modal.classList.remove("is-open"); | ||
|
||
return true; | ||
} | ||
|
||
open() { | ||
this.isOpen = true; | ||
this.$modal.classList.add("is-open"); | ||
|
||
return true; | ||
} | ||
} |
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,49 +1,19 @@ | ||
import hotkeys from "hotkeys-js"; | ||
import "./visor.css"; | ||
|
||
class Visor { | ||
constructor() { | ||
this.isOpen = false; | ||
this.$toggle = document.querySelectorAll("[data-visor-toggle]"); | ||
this.$modal = document.querySelector("[data-visor]"); | ||
|
||
this.handleToggle = this.handleToggle.bind(this); | ||
this.open = this.open.bind(this); | ||
this.close = this.close.bind(this); | ||
|
||
this.events(); | ||
} | ||
|
||
events() { | ||
this.$toggle.forEach($toggle => { | ||
$toggle.addEventListener("click", this.handleToggle) | ||
(() => { | ||
fetch("/actions/visor/default/access") | ||
.then((res) => { | ||
// Did we encounter a non 200 status code? If so, exit | ||
if (res.status !== 200) { | ||
return false; | ||
} | ||
|
||
// Proceed if the page ran | ||
return res.text(); | ||
}) | ||
.then((data) => { | ||
// Only output something to the page if we received data | ||
if (data) { | ||
document.body.insertAdjacentHTML("beforeend", data); | ||
import("./init").then((module) => new module.default()); | ||
} | ||
}); | ||
|
||
hotkeys("`", this.handleToggle); | ||
hotkeys("esc", this.close); | ||
} | ||
|
||
handleToggle() { | ||
if (this.isOpen) { | ||
return this.close(); | ||
} | ||
|
||
return this.open(); | ||
} | ||
|
||
close() { | ||
this.isOpen = false; | ||
this.$modal.classList.remove("is-open"); | ||
|
||
return true; | ||
} | ||
|
||
open() { | ||
this.isOpen = true; | ||
this.$modal.classList.add("is-open"); | ||
|
||
return true; | ||
} | ||
} | ||
|
||
new Visor(); | ||
})(); |
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
Oops, something went wrong.