diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-07 07:08:51 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-07 07:08:51 (GMT) |
commit | 62a2fe9092d3b6038a08f5c5a7faa4a863b84fdc (patch) | |
tree | 2fe7b9ec43c86ca7bdac72978347120ed3390384 /doc/src/template/scripts/narrow.js | |
parent | c78f753d544f87e06903b2b6250a32e6f8147c3c (diff) | |
parent | eae8c143428128a4bea4c06cff93b38189da267d (diff) | |
download | Qt-62a2fe9092d3b6038a08f5c5a7faa4a863b84fdc.zip Qt-62a2fe9092d3b6038a08f5c5a7faa4a863b84fdc.tar.gz Qt-62a2fe9092d3b6038a08f5c5a7faa4a863b84fdc.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (36 commits)
Fix failure on Windows after commit ccd3f66
tst_qtcpserver: Another attempt to reproduce QTBUG-14268
Fix crash when constructing QThreadStorage after global destructors have run
tst_qtcpsocket: Attempt to reproduce QTBUG-14268
Fixed a buffer overrun when pasting large data from non-Qt apps
Fix copying large data to non-Qt applications
fix regexp in "make custom command handling in vc(x)proj files sane"
qmake: Include -pthread when reducing duplicate library arguments
qmake: Ensure right library order when reducing duplicate libraries
rebuild configure.exe
make QMAKE_POST_LINK handling in nmake generator sane
make custom command handling in vc(x)proj files sane
Revert "QWorkspace: fix hardcoded min size overwriting the real min size"
QtScript/JavaScriptCore: Backport random number generator seeding fix
Fix performance regression in QUuid::createUuid()
Update japanese translations.
Ensure that the underline is only drawn when expected for an accel
Small improvement in the textedit demo
My changes for 4.7.1
QWorkspace: fix hardcoded min size overwriting the real min size
...
Diffstat (limited to 'doc/src/template/scripts/narrow.js')
-rw-r--r-- | doc/src/template/scripts/narrow.js | 108 |
1 files changed, 76 insertions, 32 deletions
diff --git a/doc/src/template/scripts/narrow.js b/doc/src/template/scripts/narrow.js index 35c81bf..a5e8b97 100644 --- a/doc/src/template/scripts/narrow.js +++ b/doc/src/template/scripts/narrow.js @@ -1,17 +1,15 @@ +/* This function generates menus and search box in narrow/slim fit mode */ var narrowInit = function() { - /* TODO: - Could probably be more efficient, not hardcoding each element to be created - */ - // 1: Create search form + /* 1: Create search form */ var narrowSearch = $('<div id="narrowsearch"></div>'); var searchform = $("#qtdocsearch"); narrowSearch.append(searchform); $("#qtdocheader .content .qtref").after(narrowSearch); - // 2: Create dropdowns + /* 2: Create dropdowns */ var narrowmenu = $('<ul id="narrowmenu" class="sf-menu"></ul>'); - // Lookup + /* Lookup */ var lookuptext = $("#lookup h2").attr("title"); $("#lookup ul").removeAttr("id"); $("#lookup ul li").removeAttr("class"); @@ -24,7 +22,7 @@ var narrowInit = function() { lookuplist.append(lookupul); narrowmenu.append(lookuplist); - // Topics + /* Topics */ var topicstext = $("#topics h2").attr("title"); $("#topics ul").removeAttr("id"); $("#topics ul li").removeAttr("class"); @@ -37,7 +35,7 @@ var narrowInit = function() { topicslist.append(topicsul); narrowmenu.append(topicslist); - // Examples + /* Examples */ var examplestext = $("#examples h2").attr("title"); $("#examples ul").removeAttr("id"); $("#examples ul li").removeAttr("class"); @@ -58,32 +56,78 @@ var narrowInit = function() { }); } +/* Executes on doc ready */ $(document).ready(function(){ -/* if ($('body').hasClass('narrow')) { - narrowInit(); - } - */ - if($(window).width()<600) { - $('body').addClass('narrow'); - - if ($("#narrowsearch").length == 0) { - narrowInit(); - } - } - else { - $('body').removeClass('narrow'); + /* check if body has the narrow class */ + if ($('body').hasClass('narrow')) { + /* run narrowInit */ + narrowInit(); + } + + /* messure window width and add class if it is smaller than 600 px */ + if($(window).width()<600) { + $('body').addClass('narrow'); + /* if the search box contains */ + if ($("#narrowsearch").length == 0) { + /* run narrowInit */ + narrowInit(); + } + } + else { /* if the window is wider than 600 px, narrow is removed */ + $('body').removeClass('narrow'); + if ($("#narrowsearch").length == 0) { + } + } +}); +/* binding resize event to this funciton */ +$(window).bind('resize', function () { + /* if the window is wider than 600 px, narrow class is added */ + if($(window).width()<600) { + $('body').addClass('narrow'); + if ($("#narrowsearch").length == 0) { + narrowInit(); + } + } + else { + /* else we remove the narrow class */ + $('body').removeClass('narrow'); } }); -$(window).bind('resize', function () { - if($(window).width()<600) { - $('body').addClass('narrow'); + $('#narrowsearch').keyup(function () { + /* extract the search box content */ + var searchString = $('#narrowsearch').val(); + /* if the string is less than three characters */ + if ((searchString == null) || (searchString.length < 3)) { + /* remove classes and elements*/ + $('#narrowsearch').removeClass('loading'); + $('.searching').remove(); + /* run CheckEmptyAndLoadList */ + CheckEmptyAndLoadList(); + + $('.report').remove(); + return; + } + /* if timer checks out */ + if (this.timer) clearTimeout(this.timer); + this.timer = setTimeout(function () { + /* add loading image by adding loading class */ + $('#narrowsearch').addClass('loading'); + $('.searching').remove(); - if ($("#narrowsearch").length == 0) { - narrowInit(); - } - } - else { - $('body').removeClass('narrow'); - } -});
\ No newline at end of file + /* run the actual search */ + $.ajax({ + contentType: "application/x-www-form-urlencoded", + url: 'http://' + location.host + '/nokiasearch/GetDataServlet', + data: 'searchString='+searchString, + dataType:'xml', + type: 'post', + success: function (response, textStatus) { + /* on success remove loading img */ + $('.searching').remove(); + $('#narrowsearch').removeClass('loading'); + processNokiaData(response); + } + }); + }, 500); /* timer set to 500 ms */ + });
\ No newline at end of file |