From bc1c8bd7c2b220fbfa26fe5b70df7ca98f49b88c Mon Sep 17 00:00:00 2001 From: Bruno Cichon Date: Sun, 2 Apr 2023 17:57:37 +0200 Subject: [PATCH] Add set-on-pop-state and url-push-state --- source/clog-window.lisp | 21 +++++++++++++++++++++ source/clog.lisp | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/source/clog-window.lisp b/source/clog-window.lisp index 4488740..203c361 100644 --- a/source/clog-window.lisp +++ b/source/clog-window.lisp @@ -497,6 +497,27 @@ ON-ANIMATION-FRAME-HANDLER is nil unbind the event.")) (defmethod set-on-animation-frame ((obj clog-window) handler) (set-on-event-with-data obj "clog-animate" handler)) +;;;;;;;;;;;;;;;;;;;;;; +;; set-on-pop-state ;; +;;;;;;;;;;;;;;;;;;;;;; + +(defgeneric set-on-pop-state (clog-window on-pop-state-handler) + (:documentation "Set the ON-POP-STATE-HANDLER for CLOG-WINDOW. If ON-POP-STATE-HANDLER +is nil unbind the event.")) + +(defmethod set-on-pop-state ((obj clog-window) handler) + (set-on-event obj "popstate" handler)) + +;;;;;;;;;;;;;;;;;;;; +;; url-push-state ;; +;;;;;;;;;;;;;;;;;;;; + +(defgeneric url-push-state (clog-window rewrite-url) + (:documentation "Method adds an entry to the browser's session history stack.")) + +(defmethod url-push-state ((obj clog-window) rewrite-url) + (execute obj (format nil "history.pushState({},'','~A')" rewrite-url))) + ;;;;;;;;;;;;;;;;;;;; ;; set-on-storage ;; ;;;;;;;;;;;;;;;;;;;; diff --git a/source/clog.lisp b/source/clog.lisp index 7b9628b..e17da89 100644 --- a/source/clog.lisp +++ b/source/clog.lisp @@ -971,6 +971,10 @@ embedded in a native template application.)" (resize-by generic-function) (resize-to generic-function) + "CLOG-Window - History" + (set-on-pop-state generic-function) + (url-push-state generic-function) + "CLOG-Window - Storage Methods" (storage-type type) (storage-length generic-function)