Show More
@@ -27,17 +27,17 b' import logging' | |||||
27 |
|
27 | |||
28 | from pylons import request, tmpl_context as c, url |
|
28 | from pylons import request, tmpl_context as c, url | |
29 | from sqlalchemy.orm import joinedload |
|
29 | from sqlalchemy.orm import joinedload | |
30 | from webhelpers.paginate import Page |
|
|||
31 | from whoosh.qparser.default import QueryParser |
|
30 | from whoosh.qparser.default import QueryParser | |
|
31 | from whoosh.qparser.dateparse import DateParserPlugin | |||
32 | from whoosh import query |
|
32 | from whoosh import query | |
33 | from sqlalchemy.sql.expression import or_, and_, func |
|
33 | from sqlalchemy.sql.expression import or_, and_, func | |
34 |
|
34 | |||
|
35 | from rhodecode.model.db import UserLog, User | |||
35 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator |
|
36 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator | |
36 | from rhodecode.lib.base import BaseController, render |
|
37 | from rhodecode.lib.base import BaseController, render | |
37 | from rhodecode.model.db import UserLog, User |
|
|||
38 | from rhodecode.lib.utils2 import safe_int, remove_prefix, remove_suffix |
|
38 | from rhodecode.lib.utils2 import safe_int, remove_prefix, remove_suffix | |
39 | from rhodecode.lib.indexers import JOURNAL_SCHEMA |
|
39 | from rhodecode.lib.indexers import JOURNAL_SCHEMA | |
40 | from whoosh.qparser.dateparse import DateParserPlugin |
|
40 | from rhodecode.lib.helpers import Page | |
41 |
|
41 | |||
42 |
|
42 | |||
43 | log = logging.getLogger(__name__) |
|
43 | log = logging.getLogger(__name__) |
@@ -30,15 +30,13 b' from pylons import request' | |||||
30 | from pylons import tmpl_context as c, url |
|
30 | from pylons import tmpl_context as c, url | |
31 | from pylons.controllers.util import redirect, abort |
|
31 | from pylons.controllers.util import redirect, abort | |
32 |
|
32 | |||
33 | from webhelpers.paginate import Page |
|
33 | from rhodecode.model.db import Notification | |
34 |
|
34 | from rhodecode.model.notification import NotificationModel | ||
|
35 | from rhodecode.model.meta import Session | |||
|
36 | from rhodecode.lib.auth import LoginRequired, NotAnonymous | |||
35 | from rhodecode.lib.base import BaseController, render |
|
37 | from rhodecode.lib.base import BaseController, render | |
36 | from rhodecode.model.db import Notification |
|
|||
37 |
|
||||
38 | from rhodecode.model.notification import NotificationModel |
|
|||
39 | from rhodecode.lib.auth import LoginRequired, NotAnonymous |
|
|||
40 | from rhodecode.lib import helpers as h |
|
38 | from rhodecode.lib import helpers as h | |
41 |
from rhodecode. |
|
39 | from rhodecode.lib.helpers import Page | |
42 | from rhodecode.lib.utils2 import safe_int |
|
40 | from rhodecode.lib.utils2 import safe_int | |
43 |
|
41 | |||
44 |
|
42 |
@@ -29,21 +29,21 b' from sqlalchemy import or_' | |||||
29 | from sqlalchemy.orm import joinedload |
|
29 | from sqlalchemy.orm import joinedload | |
30 | from sqlalchemy.sql.expression import func |
|
30 | from sqlalchemy.sql.expression import func | |
31 |
|
31 | |||
32 | from webhelpers.paginate import Page |
|
|||
33 | from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed |
|
32 | from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed | |
34 |
|
33 | |||
35 | from webob.exc import HTTPBadRequest |
|
34 | from webob.exc import HTTPBadRequest | |
36 | from pylons import request, tmpl_context as c, response, url |
|
35 | from pylons import request, tmpl_context as c, response, url | |
37 | from pylons.i18n.translation import _ |
|
36 | from pylons.i18n.translation import _ | |
38 |
|
37 | |||
|
38 | from rhodecode.controllers.admin.admin import _journal_filter | |||
|
39 | from rhodecode.model.db import UserLog, UserFollowing, Repository, User | |||
|
40 | from rhodecode.model.meta import Session | |||
|
41 | from rhodecode.model.repo import RepoModel | |||
39 | import rhodecode.lib.helpers as h |
|
42 | import rhodecode.lib.helpers as h | |
|
43 | from rhodecode.lib.helpers import Page | |||
40 | from rhodecode.lib.auth import LoginRequired, NotAnonymous |
|
44 | from rhodecode.lib.auth import LoginRequired, NotAnonymous | |
41 | from rhodecode.lib.base import BaseController, render |
|
45 | from rhodecode.lib.base import BaseController, render | |
42 | from rhodecode.model.db import UserLog, UserFollowing, Repository, User |
|
|||
43 | from rhodecode.model.meta import Session |
|
|||
44 | from rhodecode.lib.utils2 import safe_int, AttributeDict |
|
46 | from rhodecode.lib.utils2 import safe_int, AttributeDict | |
45 | from rhodecode.controllers.admin.admin import _journal_filter |
|
|||
46 | from rhodecode.model.repo import RepoModel |
|
|||
47 | from rhodecode.lib.compat import json |
|
47 | from rhodecode.lib.compat import json | |
48 |
|
48 | |||
49 | log = logging.getLogger(__name__) |
|
49 | log = logging.getLogger(__name__) |
@@ -28,20 +28,18 b' import urllib' | |||||
28 | from pylons.i18n.translation import _ |
|
28 | from pylons.i18n.translation import _ | |
29 | from pylons import request, config, tmpl_context as c |
|
29 | from pylons import request, config, tmpl_context as c | |
30 |
|
30 | |||
|
31 | from whoosh.index import open_dir, EmptyIndexError | |||
|
32 | from whoosh.qparser import QueryParser, QueryParserError | |||
|
33 | from whoosh.query import Phrase, Wildcard, Term, Prefix | |||
|
34 | from webhelpers.util import update_params | |||
|
35 | ||||
31 | from rhodecode.lib.auth import LoginRequired |
|
36 | from rhodecode.lib.auth import LoginRequired | |
32 | from rhodecode.lib.base import BaseRepoController, render |
|
37 | from rhodecode.lib.base import BaseRepoController, render | |
33 | from rhodecode.lib.indexers import CHGSETS_SCHEMA, SCHEMA, CHGSET_IDX_NAME, \ |
|
38 | from rhodecode.lib.indexers import CHGSETS_SCHEMA, SCHEMA, CHGSET_IDX_NAME, \ | |
34 | IDX_NAME, WhooshResultWrapper |
|
39 | IDX_NAME, WhooshResultWrapper | |
35 |
|
||||
36 | from webhelpers.paginate import Page |
|
|||
37 | from webhelpers.util import update_params |
|
|||
38 |
|
||||
39 | from whoosh.index import open_dir, EmptyIndexError |
|
|||
40 | from whoosh.qparser import QueryParser, QueryParserError |
|
|||
41 | from whoosh.query import Phrase, Wildcard, Term, Prefix |
|
|||
42 | from rhodecode.model.repo import RepoModel |
|
40 | from rhodecode.model.repo import RepoModel | |
43 | from rhodecode.lib.utils2 import safe_str, safe_int |
|
41 | from rhodecode.lib.utils2 import safe_str, safe_int | |
44 |
|
42 | from rhodecode.lib.helpers import Page | ||
45 |
|
43 | |||
46 | log = logging.getLogger(__name__) |
|
44 | log = logging.getLogger(__name__) | |
47 |
|
45 |
@@ -36,7 +36,7 b' from webhelpers.text import chop_at, col' | |||||
36 | convert_misc_entities, lchop, plural, rchop, remove_formatting, \ |
|
36 | convert_misc_entities, lchop, plural, rchop, remove_formatting, \ | |
37 | replace_whitespace, urlify, truncate, wrap_paragraphs |
|
37 | replace_whitespace, urlify, truncate, wrap_paragraphs | |
38 | from webhelpers.date import time_ago_in_words |
|
38 | from webhelpers.date import time_ago_in_words | |
39 | from webhelpers.paginate import Page |
|
39 | from webhelpers.paginate import Page as _Page | |
40 | from webhelpers.html.tags import _set_input_attrs, _set_id_attr, \ |
|
40 | from webhelpers.html.tags import _set_input_attrs, _set_id_attr, \ | |
41 | convert_boolean_attrs, NotGiven, _make_safe_id_component |
|
41 | convert_boolean_attrs, NotGiven, _make_safe_id_component | |
42 |
|
42 | |||
@@ -809,6 +809,143 b' def gravatar_url(email_address, size=30)' | |||||
809 | return gravatar_url |
|
809 | return gravatar_url | |
810 |
|
810 | |||
811 |
|
811 | |||
|
812 | class Page(_Page): | |||
|
813 | """ | |||
|
814 | Custom pager to match rendering style with YUI paginator | |||
|
815 | """ | |||
|
816 | ||||
|
817 | def _get_pos(self, cur_page, max_page, items): | |||
|
818 | edge = (items / 2) + 1 | |||
|
819 | if (cur_page <= edge): | |||
|
820 | radius = max(items / 2, items - cur_page) | |||
|
821 | elif (max_page - cur_page) < edge: | |||
|
822 | radius = (items - 1) - (max_page - cur_page) | |||
|
823 | else: | |||
|
824 | radius = items / 2 | |||
|
825 | ||||
|
826 | left = max(1, (cur_page - (radius))) | |||
|
827 | right = min(max_page, cur_page + (radius)) | |||
|
828 | return left, cur_page, right | |||
|
829 | ||||
|
830 | def _range(self, regexp_match): | |||
|
831 | """ | |||
|
832 | Return range of linked pages (e.g. '1 2 [3] 4 5 6 7 8'). | |||
|
833 | ||||
|
834 | Arguments: | |||
|
835 | ||||
|
836 | regexp_match | |||
|
837 | A "re" (regular expressions) match object containing the | |||
|
838 | radius of linked pages around the current page in | |||
|
839 | regexp_match.group(1) as a string | |||
|
840 | ||||
|
841 | This function is supposed to be called as a callable in | |||
|
842 | re.sub. | |||
|
843 | ||||
|
844 | """ | |||
|
845 | radius = int(regexp_match.group(1)) | |||
|
846 | ||||
|
847 | # Compute the first and last page number within the radius | |||
|
848 | # e.g. '1 .. 5 6 [7] 8 9 .. 12' | |||
|
849 | # -> leftmost_page = 5 | |||
|
850 | # -> rightmost_page = 9 | |||
|
851 | leftmost_page, _cur, rightmost_page = self._get_pos(self.page, | |||
|
852 | self.last_page, | |||
|
853 | (radius * 2) + 1) | |||
|
854 | nav_items = [] | |||
|
855 | ||||
|
856 | # Create a link to the first page (unless we are on the first page | |||
|
857 | # or there would be no need to insert '..' spacers) | |||
|
858 | if self.page != self.first_page and self.first_page < leftmost_page: | |||
|
859 | nav_items.append(self._pagerlink(self.first_page, self.first_page)) | |||
|
860 | ||||
|
861 | # Insert dots if there are pages between the first page | |||
|
862 | # and the currently displayed page range | |||
|
863 | if leftmost_page - self.first_page > 1: | |||
|
864 | # Wrap in a SPAN tag if nolink_attr is set | |||
|
865 | text = '..' | |||
|
866 | if self.dotdot_attr: | |||
|
867 | text = HTML.span(c=text, **self.dotdot_attr) | |||
|
868 | nav_items.append(text) | |||
|
869 | ||||
|
870 | for thispage in xrange(leftmost_page, rightmost_page + 1): | |||
|
871 | # Hilight the current page number and do not use a link | |||
|
872 | if thispage == self.page: | |||
|
873 | text = '%s' % (thispage,) | |||
|
874 | # Wrap in a SPAN tag if nolink_attr is set | |||
|
875 | if self.curpage_attr: | |||
|
876 | text = HTML.span(c=text, **self.curpage_attr) | |||
|
877 | nav_items.append(text) | |||
|
878 | # Otherwise create just a link to that page | |||
|
879 | else: | |||
|
880 | text = '%s' % (thispage,) | |||
|
881 | nav_items.append(self._pagerlink(thispage, text)) | |||
|
882 | ||||
|
883 | # Insert dots if there are pages between the displayed | |||
|
884 | # page numbers and the end of the page range | |||
|
885 | if self.last_page - rightmost_page > 1: | |||
|
886 | text = '..' | |||
|
887 | # Wrap in a SPAN tag if nolink_attr is set | |||
|
888 | if self.dotdot_attr: | |||
|
889 | text = HTML.span(c=text, **self.dotdot_attr) | |||
|
890 | nav_items.append(text) | |||
|
891 | ||||
|
892 | # Create a link to the very last page (unless we are on the last | |||
|
893 | # page or there would be no need to insert '..' spacers) | |||
|
894 | if self.page != self.last_page and rightmost_page < self.last_page: | |||
|
895 | nav_items.append(self._pagerlink(self.last_page, self.last_page)) | |||
|
896 | ||||
|
897 | return self.separator.join(nav_items) | |||
|
898 | ||||
|
899 | def pager(self, format='~2~', page_param='page', partial_param='partial', | |||
|
900 | show_if_single_page=False, separator=' ', onclick=None, | |||
|
901 | symbol_first='<<', symbol_last='>>', | |||
|
902 | symbol_previous='<', symbol_next='>', | |||
|
903 | link_attr={'class': 'pager_link'}, | |||
|
904 | curpage_attr={'class': 'pager_curpage'}, | |||
|
905 | dotdot_attr={'class': 'pager_dotdot'}, **kwargs): | |||
|
906 | ||||
|
907 | self.curpage_attr = curpage_attr | |||
|
908 | self.separator = separator | |||
|
909 | self.pager_kwargs = kwargs | |||
|
910 | self.page_param = page_param | |||
|
911 | self.partial_param = partial_param | |||
|
912 | self.onclick = onclick | |||
|
913 | self.link_attr = link_attr | |||
|
914 | self.dotdot_attr = dotdot_attr | |||
|
915 | ||||
|
916 | # Don't show navigator if there is no more than one page | |||
|
917 | if self.page_count == 0 or (self.page_count == 1 and not show_if_single_page): | |||
|
918 | return '' | |||
|
919 | ||||
|
920 | from string import Template | |||
|
921 | # Replace ~...~ in token format by range of pages | |||
|
922 | result = re.sub(r'~(\d+)~', self._range, format) | |||
|
923 | ||||
|
924 | # Interpolate '%' variables | |||
|
925 | result = Template(result).safe_substitute({ | |||
|
926 | 'first_page': self.first_page, | |||
|
927 | 'last_page': self.last_page, | |||
|
928 | 'page': self.page, | |||
|
929 | 'page_count': self.page_count, | |||
|
930 | 'items_per_page': self.items_per_page, | |||
|
931 | 'first_item': self.first_item, | |||
|
932 | 'last_item': self.last_item, | |||
|
933 | 'item_count': self.item_count, | |||
|
934 | 'link_first': self.page > self.first_page and \ | |||
|
935 | self._pagerlink(self.first_page, symbol_first) or '', | |||
|
936 | 'link_last': self.page < self.last_page and \ | |||
|
937 | self._pagerlink(self.last_page, symbol_last) or '', | |||
|
938 | 'link_previous': self.previous_page and \ | |||
|
939 | self._pagerlink(self.previous_page, symbol_previous) \ | |||
|
940 | or HTML.span(symbol_previous, class_="yui-pg-previous"), | |||
|
941 | 'link_next': self.next_page and \ | |||
|
942 | self._pagerlink(self.next_page, symbol_next) \ | |||
|
943 | or HTML.span(symbol_next, class_="yui-pg-next") | |||
|
944 | }) | |||
|
945 | ||||
|
946 | return literal(result) | |||
|
947 | ||||
|
948 | ||||
812 | #============================================================================== |
|
949 | #============================================================================== | |
813 | # REPO PAGER, PAGER FOR REPOSITORY |
|
950 | # REPO PAGER, PAGER FOR REPOSITORY | |
814 | #============================================================================== |
|
951 | #============================================================================== |
@@ -1591,7 +1591,7 b' div.form div.fields div.field div.button' | |||||
1591 | border-radius: 4px 0px 0px 4px; |
|
1591 | border-radius: 4px 0px 0px 4px; | |
1592 | } |
|
1592 | } | |
1593 |
|
1593 | |||
1594 | #content div.box div.pagination-wh > :last-child{ |
|
1594 | #content div.box div.pagination-wh > :last-child { | |
1595 | border-radius: 0px 4px 4px 0px; |
|
1595 | border-radius: 0px 4px 4px 0px; | |
1596 | border-right: 1px solid #cfcfcf; |
|
1596 | border-right: 1px solid #cfcfcf; | |
1597 | } |
|
1597 | } |
@@ -2207,6 +2207,289 b' var MultiSelectWidget = function(selecte' | |||||
2207 | } |
|
2207 | } | |
2208 |
|
2208 | |||
2209 |
|
2209 | |||
|
2210 | ||||
|
2211 | ||||
|
2212 | var YUI_paginator = function(links_per_page, containers){ | |||
|
2213 | // my custom paginator | |||
|
2214 | (function () { | |||
|
2215 | ||||
|
2216 | var Paginator = YAHOO.widget.Paginator, | |||
|
2217 | l = YAHOO.lang, | |||
|
2218 | setId = YAHOO.util.Dom.generateId; | |||
|
2219 | ||||
|
2220 | Paginator.ui.MyFirstPageLink = function (p) { | |||
|
2221 | this.paginator = p; | |||
|
2222 | ||||
|
2223 | p.subscribe('recordOffsetChange',this.update,this,true); | |||
|
2224 | p.subscribe('rowsPerPageChange',this.update,this,true); | |||
|
2225 | p.subscribe('totalRecordsChange',this.update,this,true); | |||
|
2226 | p.subscribe('destroy',this.destroy,this,true); | |||
|
2227 | ||||
|
2228 | // TODO: make this work | |||
|
2229 | p.subscribe('firstPageLinkLabelChange',this.update,this,true); | |||
|
2230 | p.subscribe('firstPageLinkClassChange',this.update,this,true); | |||
|
2231 | }; | |||
|
2232 | ||||
|
2233 | Paginator.ui.MyFirstPageLink.init = function (p) { | |||
|
2234 | p.setAttributeConfig('firstPageLinkLabel', { | |||
|
2235 | value : 1, | |||
|
2236 | validator : l.isString | |||
|
2237 | }); | |||
|
2238 | p.setAttributeConfig('firstPageLinkClass', { | |||
|
2239 | value : 'yui-pg-first', | |||
|
2240 | validator : l.isString | |||
|
2241 | }); | |||
|
2242 | p.setAttributeConfig('firstPageLinkTitle', { | |||
|
2243 | value : 'First Page', | |||
|
2244 | validator : l.isString | |||
|
2245 | }); | |||
|
2246 | }; | |||
|
2247 | ||||
|
2248 | // Instance members and methods | |||
|
2249 | Paginator.ui.MyFirstPageLink.prototype = { | |||
|
2250 | current : null, | |||
|
2251 | leftmost_page: null, | |||
|
2252 | rightmost_page: null, | |||
|
2253 | link : null, | |||
|
2254 | span : null, | |||
|
2255 | dotdot : null, | |||
|
2256 | getPos : function(cur_page, max_page, items){ | |||
|
2257 | var edge = parseInt(items / 2) + 1; | |||
|
2258 | if (cur_page <= edge){ | |||
|
2259 | var radius = Math.max(parseInt(items / 2), items - cur_page); | |||
|
2260 | } | |||
|
2261 | else if ((max_page - cur_page) < edge) { | |||
|
2262 | var radius = (items - 1) - (max_page - cur_page); | |||
|
2263 | } | |||
|
2264 | else{ | |||
|
2265 | var radius = parseInt(items / 2); | |||
|
2266 | } | |||
|
2267 | ||||
|
2268 | var left = Math.max(1, (cur_page - (radius))) | |||
|
2269 | var right = Math.min(max_page, cur_page + (radius)) | |||
|
2270 | return [left, cur_page, right] | |||
|
2271 | }, | |||
|
2272 | render : function (id_base) { | |||
|
2273 | var p = this.paginator, | |||
|
2274 | c = p.get('firstPageLinkClass'), | |||
|
2275 | label = p.get('firstPageLinkLabel'), | |||
|
2276 | title = p.get('firstPageLinkTitle'); | |||
|
2277 | ||||
|
2278 | this.link = document.createElement('a'); | |||
|
2279 | this.span = document.createElement(); | |||
|
2280 | ||||
|
2281 | var _pos = this.getPos(p.getCurrentPage(), p.getTotalPages(), 5); | |||
|
2282 | this.leftmost_page = _pos[0]; | |||
|
2283 | this.rightmost_page = _pos[2]; | |||
|
2284 | ||||
|
2285 | setId(this.link, id_base + '-first-link'); | |||
|
2286 | this.link.href = '#'; | |||
|
2287 | this.link.className = c; | |||
|
2288 | this.link.innerHTML = label; | |||
|
2289 | this.link.title = title; | |||
|
2290 | YAHOO.util.Event.on(this.link,'click',this.onClick,this,true); | |||
|
2291 | ||||
|
2292 | setId(this.span, id_base + '-first-span'); | |||
|
2293 | this.span.className = c; | |||
|
2294 | this.span.innerHTML = label; | |||
|
2295 | ||||
|
2296 | this.current = p.getCurrentPage() > 1 ? this.link : this.span; | |||
|
2297 | return this.current; | |||
|
2298 | }, | |||
|
2299 | update : function (e) { | |||
|
2300 | var p = this.paginator; | |||
|
2301 | var _pos = this.getPos(p.getCurrentPage(), p.getTotalPages(), 5); | |||
|
2302 | this.leftmost_page = _pos[0]; | |||
|
2303 | this.rightmost_page = _pos[2]; | |||
|
2304 | ||||
|
2305 | if (e && e.prevValue === e.newValue) { | |||
|
2306 | return; | |||
|
2307 | } | |||
|
2308 | ||||
|
2309 | var par = this.current ? this.current.parentNode : null; | |||
|
2310 | if (this.leftmost_page > 1) { | |||
|
2311 | if (par && this.current === this.span) { | |||
|
2312 | par.replaceChild(this.link,this.current); | |||
|
2313 | this.current = this.link; | |||
|
2314 | } | |||
|
2315 | } else { | |||
|
2316 | if (par && this.current === this.link) { | |||
|
2317 | par.replaceChild(this.span,this.current); | |||
|
2318 | this.current = this.span; | |||
|
2319 | } | |||
|
2320 | } | |||
|
2321 | }, | |||
|
2322 | destroy : function () { | |||
|
2323 | YAHOO.util.Event.purgeElement(this.link); | |||
|
2324 | this.current.parentNode.removeChild(this.current); | |||
|
2325 | this.link = this.span = null; | |||
|
2326 | }, | |||
|
2327 | onClick : function (e) { | |||
|
2328 | YAHOO.util.Event.stopEvent(e); | |||
|
2329 | this.paginator.setPage(1); | |||
|
2330 | } | |||
|
2331 | }; | |||
|
2332 | ||||
|
2333 | })(); | |||
|
2334 | (function () { | |||
|
2335 | ||||
|
2336 | var Paginator = YAHOO.widget.Paginator, | |||
|
2337 | l = YAHOO.lang, | |||
|
2338 | setId = YAHOO.util.Dom.generateId; | |||
|
2339 | ||||
|
2340 | Paginator.ui.MyLastPageLink = function (p) { | |||
|
2341 | this.paginator = p; | |||
|
2342 | ||||
|
2343 | p.subscribe('recordOffsetChange',this.update,this,true); | |||
|
2344 | p.subscribe('rowsPerPageChange',this.update,this,true); | |||
|
2345 | p.subscribe('totalRecordsChange',this.update,this,true); | |||
|
2346 | p.subscribe('destroy',this.destroy,this,true); | |||
|
2347 | ||||
|
2348 | // TODO: make this work | |||
|
2349 | p.subscribe('lastPageLinkLabelChange',this.update,this,true); | |||
|
2350 | p.subscribe('lastPageLinkClassChange', this.update,this,true); | |||
|
2351 | }; | |||
|
2352 | ||||
|
2353 | Paginator.ui.MyLastPageLink.init = function (p) { | |||
|
2354 | p.setAttributeConfig('lastPageLinkLabel', { | |||
|
2355 | value : -1, | |||
|
2356 | validator : l.isString | |||
|
2357 | }); | |||
|
2358 | p.setAttributeConfig('lastPageLinkClass', { | |||
|
2359 | value : 'yui-pg-last', | |||
|
2360 | validator : l.isString | |||
|
2361 | }); | |||
|
2362 | p.setAttributeConfig('lastPageLinkTitle', { | |||
|
2363 | value : 'Last Page', | |||
|
2364 | validator : l.isString | |||
|
2365 | }); | |||
|
2366 | ||||
|
2367 | }; | |||
|
2368 | ||||
|
2369 | Paginator.ui.MyLastPageLink.prototype = { | |||
|
2370 | ||||
|
2371 | current : null, | |||
|
2372 | leftmost_page: null, | |||
|
2373 | rightmost_page: null, | |||
|
2374 | link : null, | |||
|
2375 | span : null, | |||
|
2376 | dotdot : null, | |||
|
2377 | na : null, | |||
|
2378 | getPos : function(cur_page, max_page, items){ | |||
|
2379 | var edge = parseInt(items / 2) + 1; | |||
|
2380 | if (cur_page <= edge){ | |||
|
2381 | var radius = Math.max(parseInt(items / 2), items - cur_page); | |||
|
2382 | } | |||
|
2383 | else if ((max_page - cur_page) < edge) { | |||
|
2384 | var radius = (items - 1) - (max_page - cur_page); | |||
|
2385 | } | |||
|
2386 | else{ | |||
|
2387 | var radius = parseInt(items / 2); | |||
|
2388 | } | |||
|
2389 | ||||
|
2390 | var left = Math.max(1, (cur_page - (radius))) | |||
|
2391 | var right = Math.min(max_page, cur_page + (radius)) | |||
|
2392 | return [left, cur_page, right] | |||
|
2393 | }, | |||
|
2394 | render : function (id_base) { | |||
|
2395 | var p = this.paginator, | |||
|
2396 | c = p.get('lastPageLinkClass'), | |||
|
2397 | label = p.get('lastPageLinkLabel'), | |||
|
2398 | last = p.getTotalPages(), | |||
|
2399 | title = p.get('lastPageLinkTitle'); | |||
|
2400 | ||||
|
2401 | var _pos = this.getPos(p.getCurrentPage(), p.getTotalPages(), 5); | |||
|
2402 | this.leftmost_page = _pos[0]; | |||
|
2403 | this.rightmost_page = _pos[2]; | |||
|
2404 | ||||
|
2405 | this.link = document.createElement('a'); | |||
|
2406 | this.span = document.createElement(); | |||
|
2407 | this.na = this.span.cloneNode(false); | |||
|
2408 | ||||
|
2409 | setId(this.link, id_base + '-last-link'); | |||
|
2410 | this.link.href = '#'; | |||
|
2411 | this.link.className = c; | |||
|
2412 | this.link.innerHTML = label; | |||
|
2413 | this.link.title = title; | |||
|
2414 | YAHOO.util.Event.on(this.link,'click',this.onClick,this,true); | |||
|
2415 | ||||
|
2416 | setId(this.span, id_base + '-last-span'); | |||
|
2417 | this.span.className = c; | |||
|
2418 | this.span.innerHTML = label; | |||
|
2419 | ||||
|
2420 | setId(this.na, id_base + '-last-na'); | |||
|
2421 | ||||
|
2422 | if (this.rightmost_page < p.getTotalPages()){ | |||
|
2423 | this.current = this.link; | |||
|
2424 | } | |||
|
2425 | else{ | |||
|
2426 | this.current = this.span; | |||
|
2427 | } | |||
|
2428 | ||||
|
2429 | this.current.innerHTML = p.getTotalPages(); | |||
|
2430 | return this.current; | |||
|
2431 | }, | |||
|
2432 | ||||
|
2433 | update : function (e) { | |||
|
2434 | var p = this.paginator; | |||
|
2435 | ||||
|
2436 | var _pos = this.getPos(p.getCurrentPage(), p.getTotalPages(), 5); | |||
|
2437 | this.leftmost_page = _pos[0]; | |||
|
2438 | this.rightmost_page = _pos[2]; | |||
|
2439 | ||||
|
2440 | if (e && e.prevValue === e.newValue) { | |||
|
2441 | return; | |||
|
2442 | } | |||
|
2443 | ||||
|
2444 | var par = this.current ? this.current.parentNode : null, | |||
|
2445 | after = this.link; | |||
|
2446 | if (par) { | |||
|
2447 | ||||
|
2448 | // only show the last page if the rightmost one is | |||
|
2449 | // lower, so we don't have doubled entries at the end | |||
|
2450 | if (!(this.rightmost_page < p.getTotalPages())){ | |||
|
2451 | after = this.span | |||
|
2452 | } | |||
|
2453 | ||||
|
2454 | if (this.current !== after) { | |||
|
2455 | par.replaceChild(after,this.current); | |||
|
2456 | this.current = after; | |||
|
2457 | } | |||
|
2458 | } | |||
|
2459 | this.current.innerHTML = this.paginator.getTotalPages(); | |||
|
2460 | ||||
|
2461 | }, | |||
|
2462 | destroy : function () { | |||
|
2463 | YAHOO.util.Event.purgeElement(this.link); | |||
|
2464 | this.current.parentNode.removeChild(this.current); | |||
|
2465 | this.link = this.span = null; | |||
|
2466 | }, | |||
|
2467 | onClick : function (e) { | |||
|
2468 | YAHOO.util.Event.stopEvent(e); | |||
|
2469 | this.paginator.setPage(this.paginator.getTotalPages()); | |||
|
2470 | } | |||
|
2471 | }; | |||
|
2472 | ||||
|
2473 | })(); | |||
|
2474 | ||||
|
2475 | var pagi = new YAHOO.widget.Paginator({ | |||
|
2476 | rowsPerPage: links_per_page, | |||
|
2477 | alwaysVisible: false, | |||
|
2478 | template : "{PreviousPageLink} {MyFirstPageLink} {PageLinks} {MyLastPageLink} {NextPageLink}", | |||
|
2479 | pageLinks: 5, | |||
|
2480 | containerClass: 'pagination-wh', | |||
|
2481 | currentPageClass: 'pager_curpage', | |||
|
2482 | pageLinkClass: 'pager_link', | |||
|
2483 | nextPageLinkLabel: '>', | |||
|
2484 | previousPageLinkLabel: '<', | |||
|
2485 | containers:containers | |||
|
2486 | }) | |||
|
2487 | ||||
|
2488 | return pagi | |||
|
2489 | } | |||
|
2490 | ||||
|
2491 | ||||
|
2492 | ||||
2210 | // global hooks after DOM is loaded |
|
2493 | // global hooks after DOM is loaded | |
2211 |
|
2494 | |||
2212 | YUE.onDOMReady(function(){ |
|
2495 | YUE.onDOMReady(function(){ |
@@ -79,20 +79,7 b'' | |||||
79 |
|
79 | |||
80 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ |
|
80 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ | |
81 | sortedBy:{key:"name",dir:"asc"}, |
|
81 | sortedBy:{key:"name",dir:"asc"}, | |
82 | paginator: new YAHOO.widget.Paginator({ |
|
82 | paginator: YUI_paginator(25, ['user-paginator']), | |
83 | rowsPerPage: 25, |
|
|||
84 | alwaysVisible: false, |
|
|||
85 | template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}", |
|
|||
86 | pageLinks: 5, |
|
|||
87 | containerClass: 'pagination-wh', |
|
|||
88 | currentPageClass: 'pager_curpage', |
|
|||
89 | pageLinkClass: 'pager_link', |
|
|||
90 | nextPageLinkLabel: '>', |
|
|||
91 | previousPageLinkLabel: '<', |
|
|||
92 | firstPageLinkLabel: '<<', |
|
|||
93 | lastPageLinkLabel: '>>', |
|
|||
94 | containers:['user-paginator'] |
|
|||
95 | }), |
|
|||
96 |
|
83 | |||
97 | MSG_SORTASC:"${_('Click to sort ascending')}", |
|
84 | MSG_SORTASC:"${_('Click to sort ascending')}", | |
98 | MSG_SORTDESC:"${_('Click to sort descending')}", |
|
85 | MSG_SORTDESC:"${_('Click to sort descending')}", |
@@ -178,20 +178,7 b' function table_renderer(data){' | |||||
178 |
|
178 | |||
179 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ |
|
179 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ | |
180 | sortedBy:{key:"name",dir:"asc"}, |
|
180 | sortedBy:{key:"name",dir:"asc"}, | |
181 | paginator: new YAHOO.widget.Paginator({ |
|
181 | paginator: YUI_paginator(50, ['user-paginator']), | |
182 | rowsPerPage: 50, |
|
|||
183 | alwaysVisible: false, |
|
|||
184 | template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}", |
|
|||
185 | pageLinks: 5, |
|
|||
186 | containerClass: 'pagination-wh', |
|
|||
187 | currentPageClass: 'pager_curpage', |
|
|||
188 | pageLinkClass: 'pager_link', |
|
|||
189 | nextPageLinkLabel: '>', |
|
|||
190 | previousPageLinkLabel: '<', |
|
|||
191 | firstPageLinkLabel: '<<', |
|
|||
192 | lastPageLinkLabel: '>>', |
|
|||
193 | containers:['user-paginator'] |
|
|||
194 | }), |
|
|||
195 |
|
182 | |||
196 | MSG_SORTASC:"${_('Click to sort ascending')}", |
|
183 | MSG_SORTASC:"${_('Click to sort ascending')}", | |
197 | MSG_SORTDESC:"${_('Click to sort descending')}", |
|
184 | MSG_SORTDESC:"${_('Click to sort descending')}", |
@@ -131,20 +131,7 b'' | |||||
131 |
|
131 | |||
132 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ |
|
132 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ | |
133 | sortedBy:{key:"name",dir:"asc"}, |
|
133 | sortedBy:{key:"name",dir:"asc"}, | |
134 | paginator: new YAHOO.widget.Paginator({ |
|
134 | paginator: YUI_paginator(${c.visual.dashboard_items},['user-paginator']), | |
135 | rowsPerPage: ${c.visual.dashboard_items}, |
|
|||
136 | alwaysVisible: false, |
|
|||
137 | template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}", |
|
|||
138 | pageLinks: 5, |
|
|||
139 | containerClass: 'pagination-wh', |
|
|||
140 | currentPageClass: 'pager_curpage', |
|
|||
141 | pageLinkClass: 'pager_link', |
|
|||
142 | nextPageLinkLabel: '>', |
|
|||
143 | previousPageLinkLabel: '<', |
|
|||
144 | firstPageLinkLabel: '<<', |
|
|||
145 | lastPageLinkLabel: '>>', |
|
|||
146 | containers:['user-paginator'] |
|
|||
147 | }), |
|
|||
148 |
|
135 | |||
149 | MSG_SORTASC:"${_('Click to sort ascending')}", |
|
136 | MSG_SORTASC:"${_('Click to sort ascending')}", | |
150 | MSG_SORTDESC:"${_('Click to sort descending')}", |
|
137 | MSG_SORTDESC:"${_('Click to sort descending')}", |
@@ -199,20 +199,7 b'' | |||||
199 |
|
199 | |||
200 | var myDataTable = new YAHOO.widget.DataTable("watched_repos_list_wrap", myColumnDefs, myDataSource,{ |
|
200 | var myDataTable = new YAHOO.widget.DataTable("watched_repos_list_wrap", myColumnDefs, myDataSource,{ | |
201 | sortedBy:{key:"name",dir:"asc"}, |
|
201 | sortedBy:{key:"name",dir:"asc"}, | |
202 | paginator: new YAHOO.widget.Paginator({ |
|
202 | paginator: YUI_paginator(25, ['watched-user-paginator']), | |
203 | rowsPerPage: 25, |
|
|||
204 | alwaysVisible: false, |
|
|||
205 | template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}", |
|
|||
206 | pageLinks: 5, |
|
|||
207 | containerClass: 'pagination-wh', |
|
|||
208 | currentPageClass: 'pager_curpage', |
|
|||
209 | pageLinkClass: 'pager_link', |
|
|||
210 | nextPageLinkLabel: '>', |
|
|||
211 | previousPageLinkLabel: '<', |
|
|||
212 | firstPageLinkLabel: '<<', |
|
|||
213 | lastPageLinkLabel: '>>', |
|
|||
214 | containers:['watched-user-paginator'] |
|
|||
215 | }), |
|
|||
216 |
|
203 | |||
217 | MSG_SORTASC:"${_('Click to sort ascending')}", |
|
204 | MSG_SORTASC:"${_('Click to sort ascending')}", | |
218 | MSG_SORTDESC:"${_('Click to sort descending')}", |
|
205 | MSG_SORTDESC:"${_('Click to sort descending')}", | |
@@ -302,20 +289,7 b'' | |||||
302 |
|
289 | |||
303 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ |
|
290 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ | |
304 | sortedBy:{key:"name",dir:"asc"}, |
|
291 | sortedBy:{key:"name",dir:"asc"}, | |
305 | paginator: new YAHOO.widget.Paginator({ |
|
292 | paginator: YUI_paginator(25, ['user-paginator']), | |
306 | rowsPerPage: 25, |
|
|||
307 | alwaysVisible: false, |
|
|||
308 | template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}", |
|
|||
309 | pageLinks: 5, |
|
|||
310 | containerClass: 'pagination-wh', |
|
|||
311 | currentPageClass: 'pager_curpage', |
|
|||
312 | pageLinkClass: 'pager_link', |
|
|||
313 | nextPageLinkLabel: '>', |
|
|||
314 | previousPageLinkLabel: '<', |
|
|||
315 | firstPageLinkLabel: '<<', |
|
|||
316 | lastPageLinkLabel: '>>', |
|
|||
317 | containers:['user-paginator'] |
|
|||
318 | }), |
|
|||
319 |
|
293 | |||
320 | MSG_SORTASC:"${_('Click to sort ascending')}", |
|
294 | MSG_SORTASC:"${_('Click to sort ascending')}", | |
321 | MSG_SORTDESC:"${_('Click to sort descending')}", |
|
295 | MSG_SORTDESC:"${_('Click to sort descending')}", |
@@ -34,9 +34,9 b'' | |||||
34 | </div> |
|
34 | </div> | |
35 | %endfor |
|
35 | %endfor | |
36 | %endfor |
|
36 | %endfor | |
37 |
|
37 | |||
38 | <div class="pagination-wh pagination-left" style="padding: 0px 0px 0px 10px;"> |
|
38 | <div class="pagination-wh pagination-left" style="padding: 0px 0px 0px 10px;"> | |
39 |
${c.journal_pager.pager('$link_previous ~2~ $link_next')} |
|
39 | ${c.journal_pager.pager('$link_previous ~2~ $link_next')} | |
40 | </div> |
|
40 | </div> | |
41 | <script type="text/javascript"> |
|
41 | <script type="text/javascript"> | |
42 | YUE.onDOMReady(function(){ |
|
42 | YUE.onDOMReady(function(){ | |
@@ -49,7 +49,7 b'' | |||||
49 | YUE.preventDefault(e); |
|
49 | YUE.preventDefault(e); | |
50 | },'.pager_link'); |
|
50 | },'.pager_link'); | |
51 | }); |
|
51 | }); | |
52 |
</script> |
|
52 | </script> | |
53 | %else: |
|
53 | %else: | |
54 | <div style="padding:5px 0px 10px 10px;"> |
|
54 | <div style="padding:5px 0px 10px 10px;"> | |
55 | ${_('No entries yet')} |
|
55 | ${_('No entries yet')} |
General Comments 0
You need to be logged in to leave comments.
Login now