dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12332
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3769: made paging pluing not use paging by default..
------------------------------------------------------------
revno: 3769
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-05-27 12:43:09 +0200
message:
made paging pluing not use paging by default..
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js 2011-05-27 08:48:57 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js 2011-05-27 10:43:09 +0000
@@ -170,10 +170,25 @@
$select.empty();
$select_page.empty();
- params.currentPage = json.paging.currentPage == 0 ? 1 : json.paging.currentPage;
- params.numberOfPages = json.paging.numberOfPages == 0 ? 1 : json.paging.numberOfPages;
- params.pageSize = json.paging.pageSize;
- params.startPage = json.paging.startPage;
+ if (params.usePaging === true) {
+ params.currentPage = json.paging.currentPage == 0 ? 1 : json.paging.currentPage;
+ params.numberOfPages = json.paging.numberOfPages == 0 ? 1 : json.paging.numberOfPages;
+ params.pageSize = json.paging.pageSize;
+ params.startPage = json.paging.startPage;
+
+ $("#" + pagesize_input_id).val(params.pageSize);
+
+ $previous_button.removeAttr("disabled");
+ $next_button.removeAttr("disabled");
+
+ if (params.currentPage == params.startPage) {
+ $previous_button.attr("disabled", "disabled");
+ }
+
+ if (params.currentPage == params.numberOfPages) {
+ $next_button.attr("disabled", "disabled");
+ }
+ }
$.each(json[settings.iterator], function(i, item)
{
@@ -181,40 +196,30 @@
$select.append(option);
});
- for ( var j = 1; j <= params.numberOfPages; j++) {
- if (params.currentPage == j) {
- $select_page.append($.tmpl(templates.option_selected, {
- "text" : j
- }));
- } else {
- $select_page.append($.tmpl(templates.option, {
- "text" : j
- }));
+ if (params.usePaging === true) {
+ for ( var j = 1; j <= params.numberOfPages; j++) {
+ if (params.currentPage == j) {
+ $select_page.append($.tmpl(templates.option_selected, {
+ "text" : j
+ }));
+ } else {
+ $select_page.append($.tmpl(templates.option, {
+ "text" : j
+ }));
+ }
}
}
-
- $("#" + pagesize_input_id).val(params.pageSize);
-
- $previous_button.removeAttr("disabled");
- $next_button.removeAttr("disabled");
-
- if (params.currentPage == params.startPage) {
- $previous_button.attr("disabled", "disabled");
- }
-
- if (params.currentPage == params.numberOfPages) {
- $next_button.attr("disabled", "disabled");
- }
});
},
init : function(options)
{
var settings = {}
- var params = {}
+ var params = {
+ usePaging : false
+ }
$.extend(settings, options);
$.extend(params, options.params);
- params.usePaging = true;
var $select = $(this);
$select.css("border", "none");
@@ -231,11 +236,8 @@
$select.wrap($.tmpl(templates.wrapper, {
"id" : wrapper_id
}));
- $select.css({
- "border-bottom" : "1px solid gray",
- "border-top" : "1px solid gray",
- "margin-bottom" : "1px"
- });
+
+ $select.css("border-top", "1px solid gray");
var $wrapper = $("#" + wrapper_id);
@@ -320,44 +322,68 @@
$wrapper.prepend($filter_table);
- $wrapper.append($.tmpl(templates.select_page, {
- "id" : select_page_id
- }))
- $wrapper.append($.tmpl(templates.button, {
- "id" : previous_button_id,
- "text" : "previous"
- }));
- $wrapper.append($.tmpl(templates.button, {
- "id" : next_button_id,
- "text" : "next"
- }));
- $wrapper.append($.tmpl(templates.pagesize_input, {
- "id" : pagesize_input_id
- }));
-
var $filter_input = $("#" + filter_input_id);
var $filter_button = $("#" + filter_button_id);
- var $select_page = $("#" + select_page_id);
- var $previous_button = $("#" + previous_button_id);
- var $next_button = $("#" + next_button_id);
- var $pagesize_input = $("#" + pagesize_input_id);
+
+ if (params.usePaging === true) {
+ $select.css({
+ "border-bottom" : "1px solid gray",
+ "margin-bottom" : "1px"
+ });
+
+ $wrapper.append($.tmpl(templates.select_page, {
+ "id" : select_page_id
+ }));
+
+ $wrapper.append($.tmpl(templates.button, {
+ "id" : previous_button_id,
+ "text" : "previous"
+ }));
+
+ $wrapper.append($.tmpl(templates.button, {
+ "id" : next_button_id,
+ "text" : "next"
+ }));
+
+ $wrapper.append($.tmpl(templates.pagesize_input, {
+ "id" : pagesize_input_id
+ }));
+
+ var $select_page = $("#" + select_page_id);
+ var $previous_button = $("#" + previous_button_id);
+ var $next_button = $("#" + next_button_id);
+ var $pagesize_input = $("#" + pagesize_input_id);
+
+ $select_page.change(function()
+ {
+ params.currentPage = +$(this).find(":selected").val();
+ methods.load("" + id);
+ });
+
+ $next_button.click(function()
+ {
+ params.currentPage = +params.currentPage + 1;
+ methods.load("" + id);
+ });
+
+ $previous_button.click(function()
+ {
+ params.currentPage = +params.currentPage - 1;
+ methods.load("" + id);
+ });
+
+ $pagesize_input.change(function()
+ {
+ params.pageSize = +$(this).val();
+ params.currentPage = 1;
+ methods.load("" + id);
+ });
+ }
settings.params = params;
$select.data("settings", settings);
methods.load("" + id);
- $next_button.click(function()
- {
- params.currentPage = +params.currentPage + 1;
- methods.load("" + id);
- });
-
- $previous_button.click(function()
- {
- params.currentPage = +params.currentPage - 1;
- methods.load("" + id);
- });
-
$filter_button.click(function()
{
params.key = $filter_input.val();
@@ -377,19 +403,6 @@
e.preventDefault();
}
});
-
- $select_page.change(function()
- {
- params.currentPage = +$(this).find(":selected").val();
- methods.load("" + id);
- });
-
- $pagesize_input.change(function()
- {
- params.pageSize = +$(this).val();
- params.currentPage = 1;
- methods.load("" + id);
- });
}
}