From eb22d4a5dcc1febb966cce52039a8699954abdc0 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 17 Feb 2013 23:13:22 -0800 Subject: [PATCH] Ticket #268: Pagination support object. --- .../images/action-icons/guac-first-page.png | Bin 0 -> 690 bytes .../images/action-icons/guac-last-page.png | Bin 0 -> 707 bytes .../images/action-icons/guac-next-page.png | Bin 0 -> 626 bytes .../images/action-icons/guac-prev-page.png | Bin 0 -> 648 bytes guacamole/src/main/webapp/scripts/admin-ui.js | 153 ++++++++++++++++++ guacamole/src/main/webapp/styles/ui.css | 42 ++++- 6 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 guacamole/src/main/webapp/images/action-icons/guac-first-page.png create mode 100644 guacamole/src/main/webapp/images/action-icons/guac-last-page.png create mode 100644 guacamole/src/main/webapp/images/action-icons/guac-next-page.png create mode 100644 guacamole/src/main/webapp/images/action-icons/guac-prev-page.png diff --git a/guacamole/src/main/webapp/images/action-icons/guac-first-page.png b/guacamole/src/main/webapp/images/action-icons/guac-first-page.png new file mode 100644 index 0000000000000000000000000000000000000000..86c7a97cc721070ce77696df0f7948b778ec545f GIT binary patch literal 690 zcmV;j0!{siP)9vxQ1whgj zunYW79Gd(`M{2Tt22=>235JmMTR_q!!4R^a2Sh_~ITLIk%o2w#9Kr2cphDQi8Nu~x zFv5}G{(FF=3mg&L0l*g_1OWIUgaH5_girwRh_FW{gm3@=lFrG55E20LA%q2hCkTHM zhrXUgQez{82LO6CVa z@)t?xi=aHM;Lv;Y7A07*qoM6N<$f(yJK00000 literal 0 HcmV?d00001 diff --git a/guacamole/src/main/webapp/images/action-icons/guac-last-page.png b/guacamole/src/main/webapp/images/action-icons/guac-last-page.png new file mode 100644 index 0000000000000000000000000000000000000000..b03932c82d59c02391ba205a9eb9e7faac32201e GIT binary patch literal 707 zcmV;!0zCbRP)LaHoqODK58-CZ@)Q|okL#6XeP$}W32MJ4m z25XlPbs|)=gy>UY0|`5c>jp{E-{Bf1B=-Xp65caH30V!1nj~a*gbXC?=03M&R4p;3 zgdby&pzaBJmtfKq^(?`xE9_N*XCdYfJZDB<^qf`=Xi7{LFvuBj`g0=&V4p#TN^BZc6> zNPrT4uM|8O2=MyKho}S?!2i)azeTbI)Bq2e0&0PW3;{L4L!tmB{K44ZAwhrv{O`nd zgG4hV6_ZiJgMLV=D^H9Z9&CoB7R3cT*bPa&PJq8q)HPTvhorz6JlGCNxq}D0At{&e zU^6831RQ#V2mO##fIqh`Y^Z34q};2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4u?*!==k7JrvHL(6rt9@{5HH#^u_k-Cok3*X}Qp^(=YM3@H>TR6oHa}{u z+8%FC&FAL>yk2rtu$5igQ^GW->qPeJb5kd6W$QS>UBFngwlZ_G+LxkV;hs-T6E^x9 z)X99|Vx77mT4w>v-=?>!Hc=iL!6p-0idvgJG@@<%4>?va3aVV0nFf@aIxWDpA)WIo zOU2ZH&<1zTtE?516OO?htG3oBm1iL zjQkcezU`lVYT1g87{=#+?1kM9%$#j)-+yb}2QE(DKeNN?qXO@W#VaND1Xn1$4^POv zIDhiv;56=e-W3`u3~BSvFa)3f5D?%n1?c!`bNw3Nv9phH(PXRhnSC|!!1Tf3>FVdQ I&MBb@01Q|4MF0Q* literal 0 HcmV?d00001 diff --git a/guacamole/src/main/webapp/images/action-icons/guac-prev-page.png b/guacamole/src/main/webapp/images/action-icons/guac-prev-page.png new file mode 100644 index 0000000000000000000000000000000000000000..6f6819dee966231443fcfde4c9127610446290d1 GIT binary patch literal 648 zcmV;30(bq1P)3hz{mVFF{qq9Ka%Q3FtS+Gq7tirZ@C2;7uh+gfBxPvPiSweb)A0M z;SYhe2`?Q1`+eX6-$#I^?XUQG+y9+4AOgIbfGF@T0$TX%2=LVfM1!v?AR>G<0l-p3 z_$mS-!xtCO!rw%NFDf7dd@%u8;EM>z1aB@N8@#E27XCI9yqSQk@FoI)<*e|%1!TVS zuSefsg-5_+&lo zsd<`BQkxTA+Iy2!h>en}`T%SL7ZY5Tf0NXh$KjlcYe0w&cum_0JAB; 0) { + first.onclick = function() { + guac_pager.setPage(0); + }; + + prev.onclick = function() { + guac_pager.setPage(guac_pager.current_page - 1); + }; + } + else { + GuacUI.addClass(first, "disabled"); + GuacUI.addClass(prev, "disabled"); + } + + // Calculate page jump window start/end + var window_start = guac_pager.current_page - (guac_pager.window_size - 1) / 2; + var window_end = window_start + guac_pager.window_size - 1; + + // Shift window as necessary + if (window_start < 0) { + window_end = Math.min(guac_pager.last_page, window_end - window_start); + window_start = 0; + } + else if (window_end > guac_pager.last_page) { + window_start = Math.max(0, window_start - window_end + guac_pager.last_page); + window_end = guac_pager.last_page; + } + + // Add page jumps + for (i=window_start; i<=window_end; i++) { + + var jump = GuacUI.createChildElement(element, "div", "set-page"); + jump.textContent = i+1; + (function(page_number) { + jump.onclick = function() { + guac_pager.setPage(page_number); + }; + })(i); + + } + + // Create next and last buttons + var next = GuacUI.createChildElement(element, "div", "next-page icon"); + var last = GuacUI.createChildElement(element, "div", "last-page icon"); + + // Handle next/last + if (guac_pager.current_page < guac_pager.last_page) { + next.onclick = function() { + guac_pager.setPage(guac_pager.current_page + 1); + }; + + last.onclick = function() { + guac_pager.setPage(guac_pager.last_page); + }; + } + else { + GuacUI.addClass(next, "disabled"); + GuacUI.addClass(last, "disabled"); + } + + } + + /** + * Adds the given element to the set of displayable elements. + */ + this.addElement = function(element) { + elements.push(element); + guac_pager.last_page = Math.max(0, + Math.floor((elements.length - 1) / guac_pager.page_capacity)); + }; + + /** + * Sets the current page, where 0 is the first page. + */ + this.setPage = function(number) { + guac_pager.current_page = number; + update_display(); + }; + + /** + * Returns the element representing the buttons of this pager. + */ + this.getElement = function() { + return element; + }; + +}; + /* * Set handler for logout */ diff --git a/guacamole/src/main/webapp/styles/ui.css b/guacamole/src/main/webapp/styles/ui.css index 2defbbde4..a229565dd 100644 --- a/guacamole/src/main/webapp/styles/ui.css +++ b/guacamole/src/main/webapp/styles/ui.css @@ -368,4 +368,44 @@ div#logout-panel { .history td { padding-left: 1em; padding-right: 1em; -} \ No newline at end of file +} + +.first-page, +.prev-page, +.set-page, +.next-page, +.last-page { + cursor: pointer; + vertical-align: middle; +} + +.first-page.disabled, +.prev-page.disabled, +.set-page.disabled, +.next-page.disabled, +.last-page.disabled { + cursor: auto; + opacity: 0.25; +} + +.set-page { + text-decoration: underline; + display: inline-block; + padding: 0.25em; +} + +.icon.first-page { + background-image: url('../images/action-icons/guac-first-page.png'); +} + +.icon.prev-page { + background-image: url('../images/action-icons/guac-prev-page.png'); +} + +.icon.next-page { + background-image: url('../images/action-icons/guac-next-page.png'); +} + +.icon.last-page { + background-image: url('../images/action-icons/guac-last-page.png'); +}