Skip to content

Commit

Permalink
Merge pull request #124 from 4ndreaSt4gi/refact
Browse files Browse the repository at this point in the history
Initial refactoring for spinner
  • Loading branch information
flyingclimber committed Feb 2, 2012
2 parents f3d28c9 + 191b1c1 commit 4c0b52c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion assets/www/js/app.js
Expand Up @@ -100,7 +100,6 @@ window.app = function() {
function navigateToPage(url, options) {
var options = $.extend({cache: false, updateHistory: true}, options || {});
$('#searchParam').val('');
$('#search').addClass('inProgress');
chrome.showSpinner();

if (options.cache) {
Expand Down
13 changes: 9 additions & 4 deletions assets/www/js/chrome.js
Expand Up @@ -24,10 +24,15 @@ window.chrome = function() {
}

function hideSpinner() {
$('#search').removeClass('inProgress');
$('.titlebar .spinner').css({display:'none'});
$('#clearSearch').css({height:30});
}


function isSpinning() {
$('#search').hasClass('inProgress');
}

/**
* Import page components from HTML string and display them in #main
*
Expand Down Expand Up @@ -186,7 +191,7 @@ window.chrome = function() {
if ($('#content').css('display') == "block") {
// We're showing the main view
currentHistoryIndex -= 1;
$('#search').addClass('inProgress');
chrome.showSpinner();
// Jumping through history is unsafe with the current urlCache system
// sometimes we get loaded without the fixups, and everything esplodes.
//window.history.go(-1);
Expand All @@ -206,7 +211,7 @@ window.chrome = function() {
}

function goForward() {
$('#search').addClass('inProgress');
chrome.showSpinner();
if (currentHistoryIndex < pageHistory.length) {
app.navigateToPage(pageHistory[++currentHistoryIndex], {
updateHistory: false
Expand Down Expand Up @@ -287,7 +292,6 @@ window.chrome = function() {
toggleForward();
updateMenuState(menu_handlers);
geo.addShowNearbyLinks();
$('#search').removeClass('inProgress');
chrome.hideSpinner();
console.log('currentHistoryIndex '+currentHistoryIndex + ' history length '+pageHistory.length);
}
Expand All @@ -307,6 +311,7 @@ window.chrome = function() {
loadFirstPage: loadFirstPage,
showSpinner: showSpinner,
hideSpinner: hideSpinner,
isSpinning: isSpinning,
showNotification: showNotification,
goBack: goBack,
goForward: goForward,
Expand Down
6 changes: 2 additions & 4 deletions assets/www/js/search.js
@@ -1,8 +1,8 @@
window.search = function() {
function performSearch(term, isSuggestion) {
if($('#search').hasClass('inProgress')) {
if(chrome.isSpinning()) {
network.stopCurrentRequest();
$('#search').removeClass('inProgress');
chrome.hideSpinner();
return;
}
if (network.isConnected()) {
Expand All @@ -12,7 +12,6 @@ window.search = function() {
}

chrome.showSpinner();
$('#search').addClass('inProgress');

if(!isSuggestion) {
console.log('for term: ' + term);
Expand Down Expand Up @@ -163,7 +162,6 @@ window.search = function() {
});
});

$('#search').removeClass('inProgress');
chrome.hideSpinner();
chrome.hideOverlays();

Expand Down

0 comments on commit 4c0b52c

Please sign in to comment.