summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2019-01-12 21:19:46 -0500
committerMalf Furious <m@lfurio.us>2019-01-12 21:19:46 -0500
commit9d8613d827dd6e99e36a24c4b37012b93b5e316c (patch)
tree19c6535524980844f697628941b0f91cbdfd2e01
parentbbb93fb3059af61514699da3fd5fad2fffc05cfa (diff)
downloadscrott-9d8613d827dd6e99e36a24c4b37012b93b5e316c.tar.gz
scrott-9d8613d827dd6e99e36a24c4b37012b93b5e316c.zip
Add rudimentary system for launching a modal on page load
If the $_SCROTT['AUTO_MODAL'] global is defined, it will refer to a modal's DOM ID to be shown once the page loads. Currently, an error state will supersede this and display the notice modal instead. Signed-off-by: Malf Furious <m@lfurio.us>
-rw-r--r--app/class/globals.php24
-rw-r--r--app/view/stdpage.php6
2 files changed, 30 insertions, 0 deletions
diff --git a/app/class/globals.php b/app/class/globals.php
index e71ebc6..468ad6d 100644
--- a/app/class/globals.php
+++ b/app/class/globals.php
@@ -50,6 +50,12 @@ $_SCROTT['PAGE_OBJECT'] = NULL;
$_SCROTT['PAGE_NAME'] = "";
/*
+ * The auto modal variable holds the name (DOM ID) of a modal to automatically
+ * open on page load. The `stdpage` footer will reference this.
+ */
+$_SCROTT['AUTO_MODAL'] = "";
+
+/*
* Get the application root path. This is an absolute path on the server.
*/
function ar() : string
@@ -182,6 +188,24 @@ function getPageName() : string
}
/*
+ * Set the auto modal.
+ */
+function setAutoModal(string $autoModal) : void
+{
+ global $_SCROTT;
+ $_SCROTT['AUTO_MODAL'] = $autoModal;
+}
+
+/*
+ * Get the auto modal.
+ */
+function getAutoModal() : string
+{
+ global $_SCROTT;
+ return $_SCROTT['AUTO_MODAL'];
+}
+
+/*
* Produce a string, but only once. This function is useful
* when dealing with some variable collection of markup and
* you want to affect only the first one with a modifier.
diff --git a/app/view/stdpage.php b/app/view/stdpage.php
index c57a156..90e25d8 100644
--- a/app/view/stdpage.php
+++ b/app/view/stdpage.php
@@ -145,6 +145,12 @@ require_once "view/settings.php";
$("#noticeModal").modal("show");
});
</script>
+ <?php } else if (getAutoModal() != "") { ?>
+ <script type="text/javascript">
+ $(window).on('load', function () {
+ $("<?=getAutoModal()?>").modal("show");
+ });
+ </script>
<?php } ?>
<script type="text/javascript">