Preview Functionality
This commit is contained in:
73
public/js/admin.js
vendored
73
public/js/admin.js
vendored
@@ -93,21 +93,68 @@
|
||||
/*! no static exports found */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
posts_edit_regexp = new RegExp("/admin/posts/\\d+/edit");
|
||||
now_edit_regexp = new RegExp("/admin/now/\\d+/edit");
|
||||
projects_edit_regexp = new RegExp("/admin/projects/\\d+/edit");
|
||||
setups_edit_regexp = new RegExp("/admin/setups/\\d+/edit");
|
||||
|
||||
if (window.location.pathname === "/admin/posts" || window.location.pathname === "/admin/posts/create" || window.location.pathname.match(posts_edit_regexp)) {
|
||||
document.getElementById("posts-link").classList.add("menu-highlight");
|
||||
} else if (window.location.pathname === "/admin/now" || window.location.pathname === "/admin/now/create" || window.location.pathname.match(now_edit_regexp)) {
|
||||
document.getElementById("now-link").classList.add("menu-highlight");
|
||||
} else if (window.location.pathname === "/admin/projects" || window.location.pathname === "/admin/projects/create" || window.location.pathname.match(projects_edit_regexp)) {
|
||||
document.getElementById("projects-link").classList.add("menu-highlight");
|
||||
} else if (window.location.pathname === "/admin/setups" || window.location.pathname === "/admin/setups/create" || window.location.pathname.match(setups_edit_regexp)) {
|
||||
document.getElementById("setup-link").classList.add("menu-highlight");
|
||||
function is_admin_post_route() {
|
||||
var posts_edit_regexp = new RegExp("/admin/posts/\\d+/edit");
|
||||
return window.location.pathname === "/admin/posts" || window.location.pathname === "/admin/posts/create" || window.location.pathname.match(posts_edit_regexp);
|
||||
}
|
||||
|
||||
function is_admin_now_route() {
|
||||
var now_edit_regexp = new RegExp("/admin/now/\\d+/edit");
|
||||
return window.location.pathname === "/admin/now" || window.location.pathname === "/admin/now/create" || window.location.pathname.match(now_edit_regexp);
|
||||
}
|
||||
|
||||
function is_admin_projects_route() {
|
||||
var projects_edit_regexp = new RegExp("/admin/projects/\\d+/edit");
|
||||
return window.location.pathname === "/admin/projects" || window.location.pathname === "/admin/projects/create" || window.location.pathname.match(projects_edit_regexp);
|
||||
}
|
||||
|
||||
function is_admin_setups_route() {
|
||||
var setups_edit_regexp = new RegExp("/admin/setups/\\d+/edit");
|
||||
return window.location.pathname === "/admin/setups" || window.location.pathname === "/admin/setups/create" || window.location.pathname.match(setups_edit_regexp);
|
||||
}
|
||||
|
||||
function admin_highlight() {
|
||||
if (is_admin_post_route()) {
|
||||
document.getElementById("posts-link").classList.add("menu-highlight");
|
||||
}
|
||||
|
||||
if (is_admin_now_route()) {
|
||||
document.getElementById("now-link").classList.add("menu-highlight");
|
||||
}
|
||||
|
||||
if (is_admin_projects_route()) {
|
||||
document.getElementById("projects-link").classList.add("menu-highlight");
|
||||
}
|
||||
|
||||
if (is_admin_setups_route()) {
|
||||
document.getElementById("setup-link").classList.add("menu-highlight");
|
||||
}
|
||||
}
|
||||
|
||||
function preview() {
|
||||
var previewButton = document.getElementById("preview");
|
||||
var mainButton = document.getElementById("main");
|
||||
|
||||
if (previewButton == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var form = document.getElementsByTagName("form")[0];
|
||||
previewButton.addEventListener("click", function (e) {
|
||||
form.setAttribute("target", "_blank");
|
||||
});
|
||||
mainButton.addEventListener("click", function (e) {
|
||||
form.removeAttribute("target");
|
||||
});
|
||||
}
|
||||
|
||||
function main() {
|
||||
admin_highlight();
|
||||
preview();
|
||||
}
|
||||
|
||||
window.onload = main;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1:
|
||||
|
||||
Reference in New Issue
Block a user