Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Exclusive jQuery components :
- based on [https://github.com/woothemes/FlexSlider](https://github.com/woothemes/FlexSlider)
- **InPlaceEditor**
- based on [http://www.appelsiini.net/projects/jeditable](http://www.appelsiini.net/projects/jeditable)
- **PageScroller**
- Infinite Scrolling Pagination. Example on how to use it: [TML](/src/test/resources/org/got5/tapestry5/jquery/pages/PageScroll.tml) & [Java](/src/test/java/org/got5/tapestry5/jquery/pages/PageScroll.java)
- **RangeSlider**
- based on [http://jqueryui.com/demos/slider/#range](http://jqueryui.com/demos/slider/#range)
- **Slider**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.tapestry5.internal.util.CaptureResultCallback;
import org.apache.tapestry5.ioc.services.TypeCoercer;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import org.got5.tapestry5.jquery.JQueryEventConstants;

Expand Down Expand Up @@ -107,9 +106,6 @@ public class PageScroll implements ClientElement {
@Inject
private TypeCoercer typeCoercer;

@Inject
private Request request;

private EventContext eventContext;

@BeginRender
Expand All @@ -124,6 +120,7 @@ void addJavaScript() {
.put("scroller", scroller)
.put("scrollURI", getScrollURI())
.put("zoneId", zone)
.put("firstPageNumber", pageNumber)
.put("params", params);

javaScriptSupport.require("tjq/PageScroll").with(specs);
Expand Down
12 changes: 10 additions & 2 deletions src/main/resources/META-INF/modules/tjq/PageScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@ define([ "t5/core/dom", "t5/core/zone", "t5/core/events", "tjq/vendor/components
activeZone;

if (typeof (this.pageIndex) == "undefined") {
this.pageIndex = 0;
this.pageIndex = specs.firstPageNumber >= 0 ? specs.firstPageNumber : 0;
}

if (this.pageIndex === -1 || this.disable) {
return;
}

var pageZoneId = specs.zoneId + pageIndex;
element = dom.wrap(specs.scroller);
element.attr("data-update-zone", specs.zoneId);
element.attr("data-update-zone", pageZoneId);
activeZone = zone.findZone(element);

var newPageZone = dom.wrap(activeZone.$.clone());
var nextPageIndex = pageIndex + 1;
var nextPageZoneId = specs.zoneId + nextPageIndex;
newPageZone.attr("id", nextPageZoneId);
activeZone.insertAfter(newPageZone);
element.attr("data-update-zone", nextPageZoneId);

this.disable = true;
scroller.addClass("scrollExtend-loading");
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/got5/tapestry5/jquery/PageScrollTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ public void page_scroll_works(){

assertTrue(isTextPresent("Element#300"));
assertTrue(isTextPresent("Element#302"));

assertFalse(isTextPresent("Element#500"));
assertFalse(isTextPresent("Element#502"));

this.runScript("window.scrollTo(0,Math.max(document.documentElement.scrollHeight," +
"document.body.scrollHeight,document.documentElement.clientHeight));");

sleep(1500);

assertTrue(isTextPresent("Element#500"));
assertTrue(isTextPresent("Element#502"));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.got5.tapestry5.jquery.JQueryEventConstants;

public class PageScroll {

Expand All @@ -15,7 +17,7 @@ public class PageScroll {

private static final int PAGE_SIZE = 100;

@OnEvent("nextPage")
@OnEvent(JQueryEventConstants.NEXT_PAGE)
List<Integer> moreValues(int multiplyBy) throws InterruptedException {
List<Integer> values = new ArrayList<Integer>();
for (int i = pageNumber * PAGE_SIZE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void contributeApplicationDefaults(MappedConfiguration<String, Obj
configuration.add(SymbolConstants.ASSET_PATH_PREFIX, "assets");
configuration.add("demo-src-dir", "");

//configuration.add(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER, "jquery");
configuration.add(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER, "jquery");

configuration.add(SymbolConstants.HMAC_PASSPHRASE, "testing, testing, 1... 2... 3...");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
scroller='scroller' zone='zone'>
<li>Element#${value}</li>
</li>
<li class='zone' t:type='zone' t:id='zone'/>
<li class='zone' t:type='zone' t:id='zone0'/>
</ul>

<div id='scroller'></div>
Expand Down