From ed3871906ee7c0127192268e3eb832010f367ebb Mon Sep 17 00:00:00 2001 From: Alexander Pilz Date: Fri, 5 Apr 2019 16:26:13 +0200 Subject: [PATCH 1/4] initial and very rudimentary scroll: support --- src/pat/inject/index.html | 18 +++++++----- src/pat/inject/inject-sources.html | 1 - src/pat/inject/inject-text.html | 45 ++++++++++++++++++++++++++++++ src/pat/inject/inject.js | 4 +++ 4 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 src/pat/inject/inject-text.html diff --git a/src/pat/inject/index.html b/src/pat/inject/index.html index a0762e8af..2b72d0c1c 100644 --- a/src/pat/inject/index.html +++ b/src/pat/inject/index.html @@ -53,18 +53,22 @@ Trigger an inject that fails. <a href="page-that-doesnt-exist" class="pat-inject"> -
  • - Place "Wilde in column 2 when - -
  • +
  • + Place "Wilde in column 2 when + +
  • +
  • + Load text into column 1 and scoll to #scroll-target + <a href="inject-text.html" class="pat-inject" data-pat-inject="scroll: #scroll-target"> +
  • -
    +

    ?

    diff --git a/src/pat/inject/inject-sources.html b/src/pat/inject/inject-sources.html index 99b956301..5eaaa0a65 100644 --- a/src/pat/inject/inject-sources.html +++ b/src/pat/inject/inject-sources.html @@ -3,7 +3,6 @@ Demo page - diff --git a/src/pat/inject/inject-text.html b/src/pat/inject/inject-text.html new file mode 100644 index 000000000..99255003b --- /dev/null +++ b/src/pat/inject/inject-text.html @@ -0,0 +1,45 @@ + + + + + Demo page + + +
    +

    Immer wieder

    +

    + Immer wieder, ob wir der Liebe Landschaft auch kennen
    und den kleinen Kirchhof mit seinen klagenden Namen
    + und die furchtbar verschweigende Schlucht, in welcher die anderen
    + enden: immer wieder gehn wir zu zweien hinaus
    unter die alten Bäume, lagern uns immer wieder
    + zwischen die Blumen, gegenüber dem Himmel. +

    +

    + — Rainer Maria Rilke +

    +

    A vision

    +

    + Two crowned Kings, and One that stood alone
    With no green weight of laurels round his head,
    But with sad eyes as one uncomforted,
    And wearied with man's never-ceasing moan
    For sins no bleating victim can atone,
    And sweet long lips with tears and kisses fed.
    Girt was he in a garment black and red,
    And at his feet I marked a broken stone
    Which sent up lilies, dove-like, to his knees.
    Now at their sight, my heart being lit with flame,
    I cried to Beatrice, 'Who are these? '
    And she made answer, knowing well each name,
    'AEschylos first, the second Sophokles,
    And last (wide stream of tears!) Euripides.' + +

    +

    + — Oscar Wilde +

    +

    Le dieu nu

    +

    + Il allait en silence au milieu des risées –
    + Il feignait d’être sourd à l’unanime affront –
    + Il souriait avec des lèvres défrisées –
    + Un bandeau noir ceignait les boucles de son front – +

    +

    + Et je lui demandai : « Jeune homme aux membres frêles
    + Es-tu l’amour ? » -- Alors il me répondit : Non !
    + Je marche en me cachant à l’ombre de ses ailes,
    + Et je suis le dieu nu qui ne dit pas son nom. +

    +

    + — Jean Cocteau +

    +
    + + diff --git a/src/pat/inject/inject.js b/src/pat/inject/inject.js index 886b7aa77..3faba30e2 100644 --- a/src/pat/inject/inject.js +++ b/src/pat/inject/inject.js @@ -34,6 +34,7 @@ define([ // XXX: this should not be here but the parser would bail on // unknown parameters and expand/collapsible need to pass the url // to us + parser.addArgument("scroll"); parser.addArgument("url"); var inject = { @@ -483,6 +484,9 @@ define([ } }); } + if (cfg.scroll) { + $(cfg['target'])[0].scrollTop = $(cfg['scroll'])[0].offsetTop; + } $el.trigger("pat-inject-success"); }, From 9284e6abb89bc7859fa122fb5ec323290dd1be79 Mon Sep 17 00:00:00 2001 From: "Cornelis G. A. Kolbach" Date: Fri, 5 Apr 2019 18:53:51 +0200 Subject: [PATCH 2/4] Added one extra example --- src/pat/inject/index.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pat/inject/index.html b/src/pat/inject/index.html index 2b72d0c1c..4ea2db8ff 100644 --- a/src/pat/inject/index.html +++ b/src/pat/inject/index.html @@ -63,6 +63,10 @@ Load text into column 1 and scoll to #scroll-target <a href="inject-text.html" class="pat-inject" data-pat-inject="scroll: #scroll-target"> +
  • + Re-inject this entire page and scroll to the demo area + <a href="index.html" class="pat-inject" data-pat-inject="scroll: #poems"> +
  • From 9e59654b5c847697904c3eb8923dd2285ea4c62b Mon Sep 17 00:00:00 2001 From: Alexander Pilz Date: Fri, 5 Apr 2019 21:01:50 +0200 Subject: [PATCH 3/4] support for scroll: top --- src/pat/inject/index.html | 2 +- src/pat/inject/inject.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pat/inject/index.html b/src/pat/inject/index.html index 4ea2db8ff..a1b15abc4 100644 --- a/src/pat/inject/index.html +++ b/src/pat/inject/index.html @@ -60,7 +60,7 @@
  • - Load text into column 1 and scoll to #scroll-target + Load text into column 1 and scoll to #scroll-target <a href="inject-text.html" class="pat-inject" data-pat-inject="scroll: #scroll-target">
  • diff --git a/src/pat/inject/inject.js b/src/pat/inject/inject.js index 3faba30e2..cb050fc80 100644 --- a/src/pat/inject/inject.js +++ b/src/pat/inject/inject.js @@ -485,7 +485,16 @@ define([ }); } if (cfg.scroll) { - $(cfg['target'])[0].scrollTop = $(cfg['scroll'])[0].offsetTop; + if (cfg['scroll'] == 'top') { + $(cfg['target'])[0].scrollTop = 0; + } else if (cfg['scroll'] == 'target') + /* scrollable: target Target indicates the target in the URL fragment the URL + that's in the href or action in the case of a form. After injection, the + page or scroll container will scroll to bring the element with that ID into view. */ + //$(cfg['target'])[0].scrollTop = $(cfg['scroll'])[0].offsetTop; + } else { + $(cfg['target'])[0].scrollTop = $(cfg['scroll'])[0].offsetTop; + } } $el.trigger("pat-inject-success"); }, From 1d06296a2671368d64f47e3a9d75379884b8a46c Mon Sep 17 00:00:00 2001 From: Alexander Pilz Date: Sun, 7 Apr 2019 07:31:59 +0200 Subject: [PATCH 4/4] syntax fix --- src/pat/inject/index.html | 2 +- src/pat/inject/inject.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pat/inject/index.html b/src/pat/inject/index.html index a1b15abc4..3c808dd5a 100644 --- a/src/pat/inject/index.html +++ b/src/pat/inject/index.html @@ -60,7 +60,7 @@
  • - Load text into column 1 and scoll to #scroll-target + Load text into column 1 and scoll to #scroll-target <a href="inject-text.html" class="pat-inject" data-pat-inject="scroll: #scroll-target">
  • diff --git a/src/pat/inject/inject.js b/src/pat/inject/inject.js index cb050fc80..a877ed17b 100644 --- a/src/pat/inject/inject.js +++ b/src/pat/inject/inject.js @@ -487,11 +487,11 @@ define([ if (cfg.scroll) { if (cfg['scroll'] == 'top') { $(cfg['target'])[0].scrollTop = 0; - } else if (cfg['scroll'] == 'target') + } else if (cfg['scroll'] == 'target') { /* scrollable: target Target indicates the target in the URL fragment the URL that's in the href or action in the case of a form. After injection, the page or scroll container will scroll to bring the element with that ID into view. */ - //$(cfg['target'])[0].scrollTop = $(cfg['scroll'])[0].offsetTop; + /*$(cfg['target'])[0].scrollTop = $(cfg['selector'])[0].offsetTop;*/ } else { $(cfg['target'])[0].scrollTop = $(cfg['scroll'])[0].offsetTop; }