From b0792a5c548c600443edbeaa3c4b0612e0eb4045 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 24 Sep 2010 09:25:26 +0200 Subject: Doc: Implementing new search display --- doc/src/template/scripts/functions.js | 223 ++++++++++++++++------------ tools/qdoc3/test/qt-html-templates.qdocconf | 9 +- 2 files changed, 138 insertions(+), 94 deletions(-) diff --git a/doc/src/template/scripts/functions.js b/doc/src/template/scripts/functions.js index faa4ca4..5bf8323 100755 --- a/doc/src/template/scripts/functions.js +++ b/doc/src/template/scripts/functions.js @@ -1,38 +1,57 @@ +// Removing search results +function hideSearchResults() { + $('#resultdialog').removeClass('active'); + $("#resultlist").removeClass().addClass('all'); + $("#resultlinks").removeClass().addClass('all'); + $("#searchcount").removeClass().addClass('all'); +} +// Closing search result box +$('#resultclose').click(function(e) { + e.preventDefault(); + hideSearchResults(); +}); + +$(document.body).click(function() { +}); + /* START non link areas where cursor should change to pointing hand */ $('.t_button').mouseover(function() { $('.t_button').css('cursor','pointer'); - /*document.getElementById(this.id).style.cursor='pointer';*/ }); /* END non link areas */ +// Font size small $('#smallA').click(function() { - $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','smaller'); + $('.mainContent .heading,.mainContent h1, .mainContent h2, .mainContent h3, .mainContent p, .mainContent li, .mainContent table').css('font-size','smaller'); $('.t_button').removeClass('active') $(this).addClass('active') }); +// Font size reset $('#medA').click(function() { - $('.content .heading').css('font','600 16px/1 Arial'); - $('.content h1').css('font','600 18px/1.2 Arial'); - $('.content h2').css('font','600 16px/1.2 Arial'); - $('.content h3').css('font','600 14px/1.2 Arial'); - $('.content p').css('font','13px/20px Verdana'); - $('.content li').css('font','400 13px/1 Verdana'); - $('.content li').css('line-height','14px'); - $('.content .toc li').css('font', 'normal 10px/1.2 Verdana'); - $('.content table').css('font','13px/1.2 Verdana'); - $('.content .heading').css('font','600 16px/1 Arial'); - $('.content .indexboxcont li').css('font','600 13px/1 Verdana'); + $('.mainContent .heading').css('font','600 16px/1 Arial'); + $('.mainContent h1').css('font','600 18px/1.2 Arial'); + $('.mainContent h2').css('font','600 16px/1.2 Arial'); + $('.mainContent h3').css('font','600 14px/1.2 Arial'); + $('.mainContent p').css('font','13px/20px Verdana'); + $('.mainContent li').css('font','400 13px/1 Verdana'); + $('.mainContent li').css('line-height','14px'); + $('.mainContent .toc li').css('font', 'normal 10px/1.2 Verdana'); + $('.mainContent table').css('font','13px/1.2 Verdana'); + $('.mainContent .heading').css('font','600 16px/1 Arial'); + $('.mainContent .indexboxcont li').css('font','600 13px/1 Verdana'); $('.t_button').removeClass('active') $(this).addClass('active') }); +// Font size large $('#bigA').click(function() { - $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','large'); - $('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('line-height','25px'); + $('.mainContent .heading,.mainContent h1, .mainContent h2, .mainContent h3, .mainContent p, .mainContent li, .mainContent table').css('font-size','large'); + $('.mainContent .heading,.mainContent h1, .mainContent h2, .mainContent h3, .mainContent p, .mainContent li, .mainContent table').css('line-height','25px'); $('.t_button').removeClass('active') $(this).addClass('active') }); +// Show page content after closing feedback box $('.feedclose').click(function() { $('.bd').show(); $('.hd').show(); @@ -41,6 +60,7 @@ $('.feedclose').click(function() { $('#blurpage').hide(); }); +// Hide page content and show feedback box $('.feedback').click(function() { $('.bd').hide(); $('.hd').hide(); @@ -48,71 +68,93 @@ $('.feedback').click(function() { $('#feedbackBox').show(); $('#blurpage').show(); }); -var lookupCount = 0; -var articleCount = 0; -var exampleCount = 0; -var qturl = ""; // change from "http://doc.qt.nokia.com/4.6/" to 0 so we can have relative links +// Setting URL - in this case relative to root +var qturl = ""; + +// Process data sent back from the server. The data is structured as a XML. +/* +XML structure handled by function processNokiaData() + - container for each page returned + - contains keywords + - contains page title/header content + - contains page URL - URL relative to root + - contains page type - APIPage/Article/Example + +*/ + function processNokiaData(response){ var propertyTags = response.getElementsByTagName('page'); - for (var i=0; i< propertyTags.length; i++) { - var linkStart = "
  • " + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd; - $('#ul001').append(full_li_element); - $('#ul001 .defaultLink').css('display','none'); - - } - } - - if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Article'){ - articleCount++; - - for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ - full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; - full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ; - - $('#ul002').append(full_li_element); - $('#ul002 .defaultLink').css('display','none'); - - } - } - if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Example'){ - exampleCount++; - - - for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){ - full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue; - full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ; - - $('#ul003').append(full_li_element); - $('#ul003 .defaultLink').css('display','none'); - - } - } - if(i==propertyTags.length){$('#pageType').removeClass('loading');} - - } - if(lookupCount > 0){$('#ul001 .menuAlert').remove();$('#ul001').prepend('
  • Found ' + lookupCount + ' hits
  • ');$('#ul001 li').css('display','block');$('.sidebar .search form input').removeClass('loading');} - if(articleCount > 0){$('#ul002 .menuAlert').remove();$('#ul002').prepend('
  • Found ' + articleCount + ' hits
  • ');$('#ul002 li').css('display','block');} - if(exampleCount > 0){$('#ul003 .menuAlert').remove();$('#ul003').prepend('
  • Found ' + articleCount + ' hits
  • ');$('#ul003 li').css('display','block');} - - if(lookupCount == 0){$('#ul001 .menuAlert').remove();$('#ul001').prepend('
  • Found no result
  • ');$('#ul001 li').css('display','block');$('.sidebar .search form input').removeClass('loading');} - if(articleCount == 0){$('#ul002 .menuAlert').remove();$('#ul002').prepend('
  • Found no result
  • ');$('#ul002 li').css('display','block');} - if(exampleCount == 0){$('#ul003 .menuAlert').remove();$('#ul003').prepend('
  • Found no result
  • ');$('#ul003 li').css('display','block');} - // reset count variables; - lookupCount=0; - articleCount = 0; - exampleCount = 0; + var apiCount = 0; + var articleCount = 0; + var exampleCount = 0; + var full_li_element; + + $('#resultlist li').remove(); + + + for (var i=0; i'; + $('#resultlist').append(full_li_element); + } + } + + if (propertyTags.length > 0) { + $('#resultdialog').addClass('active'); + $('#resultcount').html(propertyTags.length); + $('#apicount').html(apiCount); + $('#articlecount').html(articleCount); + $('#examplecount').html(exampleCount); + } + + // Filtering results in display + $('p#resultlinks a').click(function(e) { + e.preventDefault(); + // Displays API ref pages + if (this.id == "showapiresults") { + $("#resultlist").removeClass().addClass('api'); + $("#resultlinks").removeClass().addClass('api'); + $("#searchcount").removeClass().addClass('api'); + } + // Displays Articles + else if (this.id == "showarticleresults") { + $("#resultlist").removeClass().addClass('article'); + $("#resultlinks").removeClass().addClass('article'); + $("#searchcount").removeClass().addClass('article'); + } + // Displays Examples + if (this.id == "showexampleresults") { + $("#resultlist").removeClass().addClass('example'); + $("#resultlinks").removeClass().addClass('example'); + $("#searchcount").removeClass().addClass('example'); + } + // Displays All + if (this.id == "showallresults") { + $("#resultlist").removeClass().addClass('all'); + $("#resultlinks").removeClass().addClass('all'); + $("#searchcount").removeClass().addClass('all'); + } + }); } + //build regular expression object to find empty string or any number of blank var blankRE=/^\s*$/; function CheckEmptyAndLoadList() @@ -129,27 +171,22 @@ function CheckEmptyAndLoadList() var value = document.getElementById('pageType').value; if((blankRE.test(value)) || (value.length < 3)) { - //empty inputbox - // load default li elements into the ul if empty - // loadAllList(); // replaced + + + $('.defaultLink').css('display','block'); - // $('.liveResult').css('display','none'); + + $('#resultdialog').removeClass('active'); + $('#resultlist li').remove(); }else{ - $('.defaultLink').css('display','none'); + } } -/* -$(window).resize(function(){ -if($(window).width()<400) - $('body').addClass('offline'); -else - $('body').removeClass('offline'); - }); - */ -// Loads on doc ready + +// Loads on doc ready - prepares search $(document).ready(function () { - //alert(pageUrl); - //$('#pageUrl').attr('foo',pageUrl); + + var pageTitle = $('title').html(); var currentString = $('#pageType').val() ; if(currentString.length < 1){ @@ -165,14 +202,14 @@ else $('.searching').remove(); CheckEmptyAndLoadList(); $('.report').remove(); - // debug$('.content').prepend('
  • too short or blank
  • '); // debug + return; } if (this.timer) clearTimeout(this.timer); this.timer = setTimeout(function () { $('#pageType').addClass('loading'); $('.searching').remove(); - $('.list ul').prepend(''); + $.ajax({ contentType: "application/x-www-form-urlencoded", url: 'http://' + location.host + '/nokiasearch/GetDataServlet', @@ -184,7 +221,7 @@ else $('.liveResult').remove(); $('.searching').remove(); $('#pageType').removeClass('loading'); - $('.list ul').prepend(''); + processNokiaData(response); } diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 44aa918..0d6cb8d 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -71,6 +71,13 @@ HTML.postheader = "
    \n" \ "
    \n" \ "
    \n" \ " \n" \ + "
    \n" \ + " Close \n" \ + "

    All | API | Articles | Examples

    \n" \ + "

     results:

    \n" \ + "
      \n" \ + "
    \n" \ + "
    \n" \ "
    \n" \ "
    \n" \ "
    \n" \ @@ -135,7 +142,7 @@ HTML.postpostheader = " \n" \ " \n" \ " \n" \ " \n" \ - "
    \n" + "
    \n" HTML.footer = "" \ "
    \n" \ -- cgit v0.12