From 83e16a5c12f1de16a989efb2a8c4db43ac71f9ef Mon Sep 17 00:00:00 2001 From: Jason Skomorowski Date: Wed, 1 Dec 2010 07:21:14 +0100 Subject: [PATCH] Split template, rearrange some markup --- mkdru-form.tpl.php | 21 +++++++++++++++++++++ mkdru-page.css | 29 ----------------------------- mkdru-page.tpl.php | 31 ------------------------------- mkdru-results.tpl.php | 6 ++++++ mkdru.client.js | 30 +++++++++++++++--------------- mkdru.css | 38 ++++++++++++++++++++++++++++++++++++++ mkdru.module | 35 ++++++++++++++++++++--------------- mkdru.theme.js | 25 +++++++++++++------------ 8 files changed, 113 insertions(+), 102 deletions(-) create mode 100644 mkdru-form.tpl.php delete mode 100644 mkdru-page.css delete mode 100644 mkdru-page.tpl.php create mode 100644 mkdru-results.tpl.php create mode 100644 mkdru.css diff --git a/mkdru-form.tpl.php b/mkdru-form.tpl.php new file mode 100644 index 0000000..12e0480 --- /dev/null +++ b/mkdru-form.tpl.php @@ -0,0 +1,21 @@ + +
+ Sort by + + and show + + per page. +
diff --git a/mkdru-page.css b/mkdru-page.css deleted file mode 100644 index 17ac6db..0000000 --- a/mkdru-page.css +++ /dev/null @@ -1,29 +0,0 @@ -.mkdru-results ul { - margin: 0; - padding: 0; -} - -.mkdru-results ul li { - list-style-type: none; - list-style-image: none; - background: none; - margin: 0; - padding: 0; -} - -.mkdru-above-below { - border-style: solid none; - border-width: 1px; -} - -.mkdru-post-search { - display: none; -} - -.mkdru-search { - text-align:center; -} - -.mkdru-search input[type='text'] { - width: 80%; -} diff --git a/mkdru-page.tpl.php b/mkdru-page.tpl.php deleted file mode 100644 index 34d836b..0000000 --- a/mkdru-page.tpl.php +++ /dev/null @@ -1,31 +0,0 @@ -
- -
-
- Sort by - - and show - - per page. -
-
-
-
-
-
    -
    -
    -
    diff --git a/mkdru-results.tpl.php b/mkdru-results.tpl.php new file mode 100644 index 0000000..eb90d2b --- /dev/null +++ b/mkdru-results.tpl.php @@ -0,0 +1,6 @@ +
    +
    +
    + +
    +
    diff --git a/mkdru.client.js b/mkdru.client.js index 6ee3163..5b0ce75 100644 --- a/mkdru.client.js +++ b/mkdru.client.js @@ -44,7 +44,8 @@ mkdru.pz2Show = function (data) { i + 1 + mkdru.recPerPage * (mkdru.curPage - 1)); } - $('#mkdru-results').html(html); + $('.mkdru-result-list').html(html); + $('.mkdru-results').show(); }; mkdru.pz2Status = function (data) { @@ -54,35 +55,35 @@ mkdru.pz2Term = function (data) { var html = ""; for (var i = 0; i < data.xtargets.length && i < mkdru.sourceMax; i++ ) { html += Drupal.theme('mkdruTerm', data.xtargets[i].name, data.xtargets[i].freq, - 'mkdru-facet-link-source', data.xtargets[i].id); + 'mkdru-facet-source', data.xtargets[i].id); } - $('#mkdru-sources').html(html); + $('.mkdru-facet-sources').html(html); html = ""; for (var i = 0; i < data.subject.length && i < mkdru.subjectMax; i++ ) { html += Drupal.theme('mkdruTerm', data.subject[i].name, data.subject[i].freq, - 'mkdru-facet-link-subject', data.subject[i].id); + 'mkdru-facet-subject', data.subject[i].id); } - $('#mkdru-subjects').html(html); + $('.mkdru-facet-subjects').html(html); html = ""; for (var i = 0; i < data.author.length && i < mkdru.authorMax; i++ ) { html += Drupal.theme('mkdruTerm', data.author[i].name, data.author[i].freq, - 'mkdru-facet-link-author', data.author[i].id); + 'mkdru-facet-author', data.author[i].id); } - $('#mkdru-authors').html(html); + $('.mkdru-facet-authors').html(html); - $('.mkdru-facet-link-source').bind('click', function (e) { + $('.mkdru-facet-source').bind('click', function (e) { mkdru.limitTarget(this.getAttribute('target_id'), this.firstChild.nodeValue); return false; }); - $('.mkdru-facet-link-subject').bind('click', function (e) { + $('.mkdru-facet-subject').bind('click', function (e) { mkdru.limitQuery('su', this.firstChild.nodeValue); return false; }); - $('.mkdru-facet-link-author').bind('click', function (e) { + $('.mkdru-facet-author').bind('click', function (e) { mkdru.limitQuery('au', this.firstChild.nodeValue); return false; }); @@ -100,7 +101,6 @@ mkdru.submitQuery = function () { mkdru.pollDropDowns(); mkdru.search(); mkdru.submitted = true; - $('.mkdru-post-search').show(); return false; }; @@ -110,8 +110,8 @@ mkdru.search = function () { }; mkdru.pollDropDowns = function () { - mkdru.recPerPage = $('#mkdru-perpage').attr('value'); - mkdru.curSort = $('#mkdru-sort').attr('value'); + mkdru.recPerPage = $('.mkdru-perpage').attr('value'); + mkdru.curSort = $('.mkdru-sort').attr('value'); if (!mkdru.submitted) return false; mkdru.resetPage(); mkdru.pz2.show(0, mkdru.recPerPage, mkdru.curSort); @@ -167,8 +167,8 @@ mkdru.prevPage = function () { $(document).ready(function () { $('.mkdru-search').bind('submit', mkdru.submitQuery); $('.mkdru-search input:text').attr('value', ''); - $('#mkdru-perpage').bind('change', function () { mkdru.pollDropDowns() }); - $('#mkdru-sort').bind('change', function () { mkdru.pollDropDowns() }); + $('.mkdru-perpage').bind('change', function () { mkdru.pollDropDowns() }); + $('.mkdru-sort').bind('change', function () { mkdru.pollDropDowns() }); mkdru.pz2 = new pz2( { "onshow": mkdru.pz2Show, "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way "pazpar2path": mkdru.pazpar2path, diff --git a/mkdru.css b/mkdru.css new file mode 100644 index 0000000..8b1f398 --- /dev/null +++ b/mkdru.css @@ -0,0 +1,38 @@ +.mkdru-search { + text-align:center; +} + +.mkdru-search input[type='text'] { + width: 80%; +} + +.mkdru-results { + display: none; +} + +.mkdru-result-list { + margin: 0; + padding: 0; +} + +.mkdru-result-list li { + list-style-type: none; + list-style-image: none; + background: none; + margin: 0; + padding: 0; +} + +.mkdru-above-below { + float: clear; + border-style: solid none; + border-width: 1px; +} + +.mkdru-counts { + float: right; +} + +.mkdru-result a { + font-weight: bold; +} diff --git a/mkdru.module b/mkdru.module index 1644223..8633149 100644 --- a/mkdru.module +++ b/mkdru.module @@ -13,7 +13,6 @@ function mkdru_node_info() { 'name' => t("Z39.50/SRU metasearch interface"), 'module' => 'mkdru', 'description' => t("Metasearch interface for Z39.50/SRU and other targets via a Pazpar2/Service Proxy backend"), - ) ); } @@ -70,7 +69,7 @@ function mkdru_init(){ // Applies our module specific CSS to all pages. This works best because // all CSS is aggregated and cached so we reduce the number of HTTP // requests and the size is negligible. - drupal_add_css(drupal_get_path('module', 'mkdru') .'/mkdru-page.css'); + drupal_add_css(drupal_get_path('module', 'mkdru') .'/mkdru.css'); } @@ -197,8 +196,6 @@ function mkdru_nodeapi(&$node, $op, $teaser, $page) { /** * Implementation of hook_delete(). - * - * When a node is deleted, we need to remove all related records from our table. */ function mkdru_delete($node) { // Deleting by nid covers all revisions. @@ -221,11 +218,15 @@ function mkdru_load($node) { */ function mkdru_theme() { return array( - 'mkdru_page' => array( - 'template' => 'mkdru-page', + 'mkdru_form' => array( + 'template' => 'mkdru-form', 'arguments' => array(), ), - 'mkdru_page_js' => array( + 'mkdru_results' => array( + 'template' => 'mkdru-results', + 'arguments' => array(), + ), + 'mkdru_js' => array( 'arguments' => array('node' => NULL), ), // 'mkdru_block_facet' => array( @@ -238,7 +239,7 @@ function mkdru_theme() { /** * Theme function to include Javascript search client and deps */ -function theme_mkdru_page_js($node) { +function theme_mkdru_js($node) { $path = drupal_get_path('module', 'mkdru'); // Include client library. drupal_add_js(variable_get('pz2_js_path', 'pazpar2/js') . '/pz2.js', 'module', 'footer'); @@ -251,14 +252,18 @@ function theme_mkdru_page_js($node) { * Implementation of hook_view() */ function mkdru_view($node, $teaser = FALSE, $page = FALSE) { - $node->content['mkdru_page_js'] = array( - '#value' => theme('mkdru_page_js', $node), + $node->content['mkdru_js'] = array( + '#value' => theme('mkdru_js', $node), '#weight' => 0, ); - $node->content['mkdru_page'] = array( - '#value' => theme('mkdru_page'), + $node->content['mkdru_form'] = array( + '#value' => theme('mkdru_form'), '#weight' => 1, ); + $node->content['mkdru_results'] = array( + '#value' => theme('mkdru_results'), + '#weight' => 2, + ); return $node; } @@ -293,15 +298,15 @@ function mkdru_block($op='list', $delta='sources', $edit=array()) { // return $block; case 'mkdru_sources': $block['subject'] = t('Source'); - $block['content'] = '
    '; + $block['content'] = '
    '; return $block; case 'mkdru_subjects': $block['subject'] = t('Subject'); - $block['content'] = '
    '; + $block['content'] = '
    '; return $block; case 'mkdru_authors': $block['subject'] = t('Author'); - $block['content'] = '
    '; + $block['content'] = '
    '; return $block; } } diff --git a/mkdru.theme.js b/mkdru.theme.js index df09df4..782c935 100644 --- a/mkdru.theme.js +++ b/mkdru.theme.js @@ -1,18 +1,19 @@ Drupal.theme.prototype.mkdruResult = function(hit, num) { - var html = []; - html.push('
  • ' - + '' + num + '. ' - + '' - + hit["md-title"] + ' '); + var html = ""; + html += '
  • ' + + '' + num + '. ' + + '' + + hit["md-title"] + ' '; if (hit["md-title-remainder"] !== undefined) { - html.push('' + hit["md-title-remainder"] + ' '); + html += '' + hit["md-title-remainder"] + ' '; } if (hit["md-title-responsibility"] !== undefined) { - html.push(''+hit["md-title-responsibility"]+''); + html += '' + + hit["md-title-responsibility"] + + ''; } - html.push('
  • '); - return (html.join('')); + html += ''; + return (html); }; Drupal.theme.prototype.mkdruPager = function (data, curPage, pages) { @@ -26,10 +27,10 @@ Drupal.theme.prototype.mkdruPager = function (data, curPage, pages) { ? firstClkbl + 2*onsides : pages; - var prev = '<< Prev | '; + var prev = '<< Prev | '; if (curPage > 1) var prev = '' - +'<< Prev | '; + +'<< Prev | '; var middle = ''; for(var i = firstClkbl; i <= lastClkbl; i++) { -- 1.7.10.4