From d83e246c4ee7625f03b902a195e445139731ed24 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 11 Nov 2012 03:52:06 +0100 Subject: [PATCH] Adds an overlay for 'jump to page' --- com.woltlab.wcf/template/headInclude.tpl | 4 + wcfsetup/install/files/js/WCF.js | 121 ++++++++++++++++++ .../PagesFunctionTemplatePlugin.class.php | 4 +- wcfsetup/install/lang/de.xml | 2 + 4 files changed, 129 insertions(+), 2 deletions(-) diff --git a/com.woltlab.wcf/template/headInclude.tpl b/com.woltlab.wcf/template/headInclude.tpl index e967f3cd30..42f29967df 100644 --- a/com.woltlab.wcf/template/headInclude.tpl +++ b/com.woltlab.wcf/template/headInclude.tpl @@ -61,6 +61,9 @@ '__days': [ '{lang}wcf.date.day.sunday{/lang}', '{lang}wcf.date.day.monday{/lang}', '{lang}wcf.date.day.tuesday{/lang}', '{lang}wcf.date.day.wednesday{/lang}', '{lang}wcf.date.day.thursday{/lang}', '{lang}wcf.date.day.friday{/lang}', '{lang}wcf.date.day.saturday{/lang}' ], 'wcf.global.thousandsSeparator': '{capture assign=thousandsSeparator}{lang}wcf.global.thousandsSeparator{/lang}{/capture}{@$thousandsSeparator|encodeJS}', 'wcf.global.decimalPoint': '{capture assign=decimalPoint}{lang}wcf.global.decimalPoint{/lang}{/capture}{$decimalPoint|encodeJS}', + 'wcf.global.page.jumpTo': '{lang}wcf.global.page.jumpTo{/lang}', + 'wcf.global.page.jumpTo.description': '{lang}wcf.global.page.jumpTo.description{/lang}', + 'wcf.global.page.pageNavigation': '{lang}wcf.global.page.pageNavigation{/lang}', 'wcf.global.page.next': '{capture assign=pageNext}{lang}wcf.global.page.next{/lang}{/capture}{@$pageNext|encodeJS}', 'wcf.global.page.previous': '{capture assign=pagePrevious}{lang}wcf.global.page.previous{/lang}{/capture}{@$pagePrevious|encodeJS}', 'wcf.global.confirmation.cancel': '{lang}wcf.global.confirmation.cancel{/lang}', @@ -98,6 +101,7 @@ new WCF.Sitemap(); new WCF.Style.Chooser(); WCF.Dropdown.init(); + WCF.System.PageNavigation.init('.pageNavigation'); {event name='javascriptInit'} diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 03da80c741..1fff647b14 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -5059,6 +5059,127 @@ WCF.System.Confirmation = { } }; +/** + * Provides the 'jump to page' overlay. + */ +WCF.System.PageNavigation = { + /** + * submit button + * @var jQuery + */ + _button: null, + + /** + * page No description + * @var jQuery + */ + _description: null, + + /** + * dialog overlay + * @var jQuery + */ + _dialog: null, + + /** + * active element id + * @var string + */ + _elementID: '', + + /** + * list of tracked navigation bars + * @var object + */ + _elements: { }, + + /** + * page No input + * @var jQuery + */ + _pageNo: null, + + /** + * Initializes the 'jump to page' overlay for given selector. + * + * @param string selector + */ + init: function(selector) { + var $elements = $(selector); + if (!$elements.length) { + return; + } + + this._initElements($elements); + }, + + /** + * Initializes the 'jump to page' overlay for given elements. + * + * @param jQuery elements + */ + _initElements: function(elements) { + var self = this; + elements.each(function(index, element) { + var $element = $(element); + var $elementID = $element.wcfIdentify(); + if (self._elements[$elementID] === undefined) { + self._elements[$elementID] = $element; + $element.find('li.jumpTo').data('elementID', $elementID).click($.proxy(self._click, self)); + } + }); + }, + + /** + * Shows the 'jump to page' overlay. + * + * @param object event + */ + _click: function(event) { + this._elementID = $(event.currentTarget).data('elementID'); + + if (this._dialog === null) { + this._dialog = $('