summaryrefslogtreecommitdiff
path: root/js/catalog-link.js
diff options
context:
space:
mode:
authorMatěj Grabovský <mgrabovsky@yahoo.com>2015-06-02 15:28:06 +0200
committerMatěj Grabovský <mgrabovsky@yahoo.com>2015-06-05 23:15:54 +0200
commit1c641eb46b850055a64f18493aa851242d464dc5 (patch)
tree08b6e7304518f88a6bafa09a9de857d14d8f3aa3 /js/catalog-link.js
parent1f409a6f4dc6eb5f52df1a0b1041ff7d607dffcd (diff)
Add catalog for Ukko
Diffstat (limited to 'js/catalog-link.js')
-rw-r--r--js/catalog-link.js72
1 files changed, 38 insertions, 34 deletions
diff --git a/js/catalog-link.js b/js/catalog-link.js
index 05ee9efb..a98078f7 100644
--- a/js/catalog-link.js
+++ b/js/catalog-link.js
@@ -12,47 +12,51 @@
* $config['additional_javascript'][] = 'js/catalog-link.js';
*/
-function catalog() {
-var board = $("input[name='board']");
+(function($) {
+var catalog = function() {
+ var board = $('input[name="board"]');
-var catalog_url = configRoot + board.first().val() + "/catalog.html";
+ if (!board.length) {
+ return;
+ }
-var pages = document.getElementsByClassName('pages')[0];
-var bottom = document.getElementsByClassName('boardlist bottom')[0]
-var subtitle = document.getElementsByClassName('subtitle')[0];
+ var catalog_url = configRoot + board.first().val() + '/catalog.html';
-var link = document.createElement('a');
-link.href = catalog_url;
+ var pages = $('.pages');
+ var bottom = $('.boardlist.bottom');
+ var subtitle = $('.subtitle');
-if (pages) {
- link.textContent = _('Catalog');
- link.style.color = '#F10000';
- link.style.padding = '4px';
- link.style.paddingLeft = '9px';
- link.style.borderLeft = '1px solid'
- link.style.borderLeftColor = '#A8A8A8';
- link.style.textDecoration = "underline";
+ var link = $('<a class="catalog" />')
+ .attr('href', catalog_url);
- pages.appendChild(link)
-}
-else {
- link.textContent = '['+_('Catalog')+']';
- link.style.paddingLeft = '10px';
- link.style.textDecoration = "underline";
- document.body.insertBefore(link, bottom);
-}
+ if (pages.length) {
+ link.text(_('Catalog'))
+ .css({
+ color: '#F10000',
+ padding: '4px',
+ textDecoration: 'underline',
+ display: 'table-cell'
+ });
+ link.insertAfter(pages);
+ } else if (bottom.length) {
+ link.text('['+_('Catalog')+']')
+ .css({
+ paddingLeft: '10px',
+ textDecoration: 'underline'
+ });
+ link.insertBefore(bottom);
+ }
-if (subtitle) {
- var link2 = document.createElement('a');
- link2.textContent = _('Catalog');
- link2.href = catalog_url;
-
- var br = document.createElement('br');
- subtitle.appendChild(br);
- subtitle.appendChild(link2);
-}
+ if (subtitle.length) {
+ subtitle.append('<br />');
+ $('<a class="catalog" />')
+ .text(_('Catalog'))
+ .attr('href', catalog_url)
+ .appendTo(subtitle);
+ }
}
-if (active_page == 'thread' || active_page == 'index') {
+if (active_page == 'thread' || active_page == 'index' || active_page == 'ukko') {
$(document).ready(catalog);
}
+})(jQuery);