diff --git a/repository/BaselineOfSeaside3.package/BaselineOfSeaside3.class/instance/baselinejavascript..st b/repository/BaselineOfSeaside3.package/BaselineOfSeaside3.class/instance/baselinejavascript..st index 8de01f269..2d353935c 100644 --- a/repository/BaselineOfSeaside3.package/BaselineOfSeaside3.class/instance/baselinejavascript..st +++ b/repository/BaselineOfSeaside3.package/BaselineOfSeaside3.class/instance/baselinejavascript..st @@ -7,11 +7,14 @@ baselinejavascript: spec package: 'Javascript-Core' with: [ spec requires: #('Seaside-Core' 'Seaside-Canvas' ) ]; package: 'Javascript-Tests-Core' with: [ - spec requires: #('Javascript-Core' 'Seaside-Tests-Core' ) ]. + spec requires: #('Javascript-Core' 'Seaside-Tests-Core' ) ]; + package: 'Seaside-Ajaxifier-Core' with: [ + spec requires: #('Seaside-Core') ]. spec group: 'Javascript' with: #('Javascript-Core'); group: 'Javascript Tests' with: #('Javascript-Tests-Core' ); - group: 'Tests' with: #( 'Javascript Tests' ) ]. + group: 'Tests' with: #( 'Javascript Tests' ); + group: 'Ajaxifier' with: #( 'Seaside-Ajaxifier-Core' ) ]. spec for: #squeak do: [ spec @@ -47,4 +50,4 @@ baselinejavascript: spec package: 'Javascript-Core' with: [ spec includes: #('Javascript-GemStone-Core') ]; package: 'Javascript-GemStone-Core' - with: [ spec requires: #('Javascript-Core') ] ]. \ No newline at end of file + with: [ spec requires: #('Javascript-Core') ] ]. diff --git a/repository/BaselineOfSeaside3.package/BaselineOfSeaside3.class/instance/baselinejquery..st b/repository/BaselineOfSeaside3.package/BaselineOfSeaside3.class/instance/baselinejquery..st index ad9b9bd09..ddc8c3b40 100644 --- a/repository/BaselineOfSeaside3.package/BaselineOfSeaside3.class/instance/baselinejquery..st +++ b/repository/BaselineOfSeaside3.package/BaselineOfSeaside3.class/instance/baselinejquery..st @@ -7,7 +7,7 @@ baselinejquery: spec package: 'JQuery-Core' with: [ spec requires: #('Javascript-Core' ) ]; package: 'JQuery-Tests-Core' with: [ - spec requires: #('JQuery-Core' 'Javascript-Tests-Core' 'Seaside-Development' 'Seaside-Tests-Functional') ]; + spec requires: #('JQuery-Core' 'Javascript-Tests-Core' 'Seaside-Development' 'Seaside-Tests-Functional' 'Seaside-Ajaxifier-Core') ]; package: 'JQuery-JSON' with: [ spec requires: #('JQuery-Core' 'Seaside-JSON-Core') ]; package: 'JQuery-Tests-JSON' with: [ diff --git a/repository/JQuery-Core.package/JQAjaxifierLibrary.class/instance/ajaxifierJs.st b/repository/JQuery-Core.package/JQAjaxifierLibrary.class/instance/ajaxifierJs.st deleted file mode 100644 index d87ae7198..000000000 --- a/repository/JQuery-Core.package/JQAjaxifierLibrary.class/instance/ajaxifierJs.st +++ /dev/null @@ -1,84 +0,0 @@ -uploads -ajaxifierJs - ^ '/* jQuery based Ajaxifier - * Copyright (c) 2008 Lukas Renggli, renggli@gmail.com - * - * For additional documentation see: - * - http://www.lukas-renggli.ch/blog/ajaxification - * - http://www.lukas-renggli.ch/blog/ajaxification-faq - */ - -$(function () { - - // constants - var HEAD_EXTRACTOR = /]*>((.|\s)*?)<\/head>/im; - var BODY_EXTRACTOR = /]*>((.|\s)*?)<\/body>/im; - var SCRIPT_EXTRACTOR = //ig; - var PARAM_EXTRACTOR = /\?(.*)$/i; - - // variables - var activeHash = ""; - - // ajax action - function load(type, url, data, modifyHistory) { - $.ajax({ - type: type, url: url, data: data, - beforeSend: function (xhr) { - // WAActionCallback per default are disabled for AJAX requests - // Detection happens with X-Requested-With so we override it - xhr.setRequestHeader("X-Requested-With", "Ajaxifier"); - }, - success: function (data, textStatus, jqXHR) { - $("head").html(HEAD_EXTRACTOR - .exec(data)[1] - .replace(SCRIPT_EXTRACTOR, "")); - $("body").html(BODY_EXTRACTOR - .exec(data)[1]); - - if (modifyHistory) { - var path = jqXHR.getResponseHeader("X-RedirectedTo"); - if (typeof(window.history.pushState) == "function") { - window.history.pushState(path, null, path); - } else { - window.location.hash = activeHash = PARAM_EXTRACTOR.exec(path)[1]; - } - } - } - }); - } - - // click handler - $(document).click(function (event) { - - // links - var anchor = $(event.target).closest("a"); - if (anchor.length == 1) { - load("GET", anchor.attr("href"), null, true); - event.preventDefault(); - } - - // submit - var submit = $(event.target).closest("input[type=submit], button[type=submit]"); - if (submit.length == 1) { - var form = submit.closest("form"); - if (form.length == 1) { - load("POST", form.attr("action"), form.find(":input").serialize() + "&" + submit.attr("name"), true); - event.preventDefault(); - } - } - - }); - - // check for changes in the hash - setInterval(function () { - var currentHash = window.location.hash.substr(1); - if (currentHash != activeHash) - load("GET", "?" + (activeHash = currentHash), null, true); - }, 250); - - // We assume nobody else will override onpopstate... since we are LIKELY the only ones to use pushstate etc. - window.onpopstate = function(event) { - load("GET", event.state, null, false); - } - -});' \ No newline at end of file diff --git a/repository/JQuery-Tests-Core.package/JQAllFunctionalTests.class/class/initialize.st b/repository/JQuery-Tests-Core.package/JQAllFunctionalTests.class/class/initialize.st index c80094500..81f5dfb5f 100644 --- a/repository/JQuery-Tests-Core.package/JQAllFunctionalTests.class/class/initialize.st +++ b/repository/JQuery-Tests-Core.package/JQAllFunctionalTests.class/class/initialize.st @@ -12,4 +12,4 @@ initialize application preferenceAt: #sessionClass put: WAExpirySession; addLibrary: JQDeploymentLibrary; - addLibrary: JQAjaxifierLibrary \ No newline at end of file + addLibrary: WAAjaxifierLibrary \ No newline at end of file diff --git a/repository/Seaside-Ajaxifier-Core.package/.filetree b/repository/Seaside-Ajaxifier-Core.package/.filetree new file mode 100644 index 000000000..57a679737 --- /dev/null +++ b/repository/Seaside-Ajaxifier-Core.package/.filetree @@ -0,0 +1,5 @@ +{ + "separateMethodMetaAndSource" : false, + "noMethodMetaData" : true, + "useCypressPropertiesFile" : true +} \ No newline at end of file diff --git a/repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/README.md b/repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/README.md new file mode 100644 index 000000000..4f43824e2 --- /dev/null +++ b/repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/README.md @@ -0,0 +1 @@ +I ajaxify a web application by turning full page requests into background AJAX requests. \ No newline at end of file diff --git a/repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/instance/ajaxifierJs.st b/repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/instance/ajaxifierJs.st new file mode 100644 index 000000000..49758ebb4 --- /dev/null +++ b/repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/instance/ajaxifierJs.st @@ -0,0 +1,80 @@ +uploads +ajaxifierJs + ^ '/* JavaScript based Ajaxifier + * Copyright (c) 2008 Lukas Renggli, renggli@gmail.com + * Copyright (c) 2022 Philippe Marschall, philippe.marschall@gmail.com + */ +"use strict"; +window.addEventListener("DOMContentLoaded", (loadEvent) => { + + // variables + let activeHash = ""; + + // ajax action + function load(type, url, data, modifyHistory) { + const xhr = new XMLHttpRequest(); + + xhr.responseType = "document" + xhr.addEventListener("load", (event) => { + if (xhr.status === 200) { + Array.from(xhr.response.head.children).forEach((child) => { + if (child.nodeType === Node.ELEMENT_NODE && child.nodeName === "SCRIPT") { + child.remove(); + } + }); + document.head.innerHTML = xhr.response.head.innerHTML; + document.body = xhr.response.body; + + if (modifyHistory) { + const path = xhr.responseURL; + window.history.pushState(path, null, path); + } + } + }); + + xhr.open(type, url); + + // WAActionCallback per default are disabled for AJAX requests + // Detection happens with X-Requested-With so we override it + xhr.setRequestHeader("X-Requested-With", "Ajaxifier"); + xhr.send(data); + } + + // click handler + document.addEventListener("click", (event) => { + + // links + const anchor = event.target.closest("a"); + if (anchor !== null) { + load("GET", anchor.getAttribute("href"), null, true); + event.preventDefault(); + return; + } + + // submit + const submit = event.target.closest("input[type=submit], button[type=submit]"); + if (submit !== null) { + const form = submit.closest("form"); + if (form !== null) { + const formData = new FormData(form); + formData.append(submit.getAttribute("name"), ""); + load("POST", form.getAttribute("action"), formData, true); + event.preventDefault(); + } + } + + }); + + // check for changes in the hash + setInterval(() => { + const currentHash = window.location.hash.substr(1); + if (currentHash !== activeHash) + load("GET", "?" + (activeHash = currentHash), null, true); + }, 250); + + // We assume nobody else will override onpopstate... since we are LIKELY the only ones to use pushstate etc. + window.onpopstate = (event) => { + load("GET", event.state, null, false); + } + +});' \ No newline at end of file diff --git a/repository/JQuery-Core.package/JQAjaxifierLibrary.class/instance/selectorsToInclude.st b/repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/instance/selectorsToInclude.st similarity index 100% rename from repository/JQuery-Core.package/JQAjaxifierLibrary.class/instance/selectorsToInclude.st rename to repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/instance/selectorsToInclude.st diff --git a/repository/JQuery-Core.package/JQAjaxifierLibrary.class/properties.json b/repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/properties.json similarity index 53% rename from repository/JQuery-Core.package/JQAjaxifierLibrary.class/properties.json rename to repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/properties.json index c0b419d27..cbcda70d0 100644 --- a/repository/JQuery-Core.package/JQAjaxifierLibrary.class/properties.json +++ b/repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/properties.json @@ -1,11 +1,11 @@ { - "commentStamp" : "", + "commentStamp" : "pmm 8/25/2022 15:03", "super" : "WAFileLibrary", - "category" : "JQuery-Core-Libraries", + "category" : "Seaside-Ajaxifier-Core", "classinstvars" : [ ], "pools" : [ ], "classvars" : [ ], "instvars" : [ ], - "name" : "JQAjaxifierLibrary", + "name" : "WAAjaxifierLibrary", "type" : "normal" } \ No newline at end of file diff --git a/repository/Seaside-Ajaxifier-Core.package/monticello.meta/categories.st b/repository/Seaside-Ajaxifier-Core.package/monticello.meta/categories.st new file mode 100644 index 000000000..2492bba15 --- /dev/null +++ b/repository/Seaside-Ajaxifier-Core.package/monticello.meta/categories.st @@ -0,0 +1 @@ +SystemOrganization addCategory: #'Seaside-Ajaxifier-Core'! diff --git a/repository/JQuery-Core.package/JQAjaxifierLibrary.class/README.md b/repository/Seaside-Ajaxifier-Core.package/monticello.meta/initializers.st similarity index 100% rename from repository/JQuery-Core.package/JQAjaxifierLibrary.class/README.md rename to repository/Seaside-Ajaxifier-Core.package/monticello.meta/initializers.st diff --git a/repository/Seaside-Ajaxifier-Core.package/monticello.meta/package b/repository/Seaside-Ajaxifier-Core.package/monticello.meta/package new file mode 100644 index 000000000..2fa226473 --- /dev/null +++ b/repository/Seaside-Ajaxifier-Core.package/monticello.meta/package @@ -0,0 +1 @@ +(name 'Seaside-Ajaxifier-Core') \ No newline at end of file diff --git a/repository/Seaside-Ajaxifier-Core.package/properties.json b/repository/Seaside-Ajaxifier-Core.package/properties.json new file mode 100644 index 000000000..6f31cf5a2 --- /dev/null +++ b/repository/Seaside-Ajaxifier-Core.package/properties.json @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/repository/Seaside-RenderLoop.package/WARenderPhaseContinuation.class/instance/addRedirectedToHeader..st b/repository/Seaside-RenderLoop.package/WARenderPhaseContinuation.class/instance/addRedirectedToHeader..st deleted file mode 100644 index 964d80625..000000000 --- a/repository/Seaside-RenderLoop.package/WARenderPhaseContinuation.class/instance/addRedirectedToHeader..st +++ /dev/null @@ -1,7 +0,0 @@ -processing -addRedirectedToHeader: aRequestContext - "The Ajaxifier needs to know the URL of the render continuation (in order to save it). - Unfortunately the redirect from the action to the render continuation happens totally transparently to the JavaScript. - So we add a custom header to the response so that the JavaScript can find out the URL of the render continuation." - (aRequestContext request headerAt: 'x-requested-with') = 'Ajaxifier' ifTrue: [ - aRequestContext response headerAt: 'X-RedirectedTo' put: aRequestContext request url greaseString ] \ No newline at end of file diff --git a/repository/Seaside-RenderLoop.package/WARenderPhaseContinuation.class/instance/handleFiltered..st b/repository/Seaside-RenderLoop.package/WARenderPhaseContinuation.class/instance/handleFiltered..st index 425cf16da..ce5e89436 100644 --- a/repository/Seaside-RenderLoop.package/WARenderPhaseContinuation.class/instance/handleFiltered..st +++ b/repository/Seaside-RenderLoop.package/WARenderPhaseContinuation.class/instance/handleFiltered..st @@ -1,6 +1,5 @@ handling handleFiltered: aRequestContext - self addRedirectedToHeader: aRequestContext. self respond: [ :response | self processRendering: response ]. "The render phase should have returned a response"