Skip to content

Commit

Permalink
wordcloud resizing on window.resize
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasn committed Aug 8, 2013
1 parent 07383a9 commit 2926a90
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions app/assets/javascripts/controllers.js
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@ angular.module('birdwatch.controllers', ['birdwatch.services', 'charts.barchart'

/** Last update timestamp for WordCLoud */
$scope.lastCloudUpdate = new Date().getTime() - 10000;

var wordCloudDiv = $("#wordCloud");

/** Return paginated selection of Tweets array */
$scope.tweetPage = function () {
@@ -79,20 +81,20 @@ angular.module('birdwatch.controllers', ['birdwatch.services', 'charts.barchart'

/** charts */
$scope.barchart = barchart.BarChart($scope.addSearchString, $("#wordBars").width() - 150);
$scope.wordCloud = wordcloud.WordCloud($("#wordCloud").width() * 1.1, $("#wordCloud").width() * 0.75, 250,
$scope.wordCloud = wordcloud.WordCloud(wordCloudDiv.width() * 1.1, wordCloudDiv.width() * 0.75, 250,
$scope.addSearchString);

/** resize charts on window resize (currently only working for wordcloud) */
function resizeCharts() {
$("#wordCloud").empty();
$scope.wordCloud = wordcloud.WordCloud($("#wordCloud").width() * 1.1, $("#wordCloud").width() * 0.75,
$scope.wordCloud = wordcloud.WordCloud(wordCloudDiv.width() * 1.1, wordCloudDiv.width() * 0.75,
250, $scope.addSearchString);
}
var TO = false;
$(window).resize(function(){
if(TO !== false)
clearTimeout(TO);
TO = setTimeout(resizeCharts, 2000); //200 is time in miliseconds
TO = setTimeout(resizeCharts, 2000); //200 is time in milliseconds
});

/** Load previous Tweets, paginated. Recursive function, calls itself with the next chunk to load until
2 changes: 1 addition & 1 deletion app/assets/javascripts/services.js
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ angular.module('birdwatch.services', []).service('utils', function () {

var legalStuff = function () {
alert("Simple. Project is delivered as is. Use it in whichever way you see fit. The author, Matthias Nehlsen, does not make claims of any kind and cannot be held responsible for anything.\n\nHere in more legal terms, adapted from \nhttps://github.com/mbostock/d3/blob/master/LICENSE. Thanks, Michael Bostock!\n\nTHIS SOFTWARE AND ITS ONLINE DEMO IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS NEHLSEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.");
}
};

return { formatTweet: formatTweet, wordCount: wordCount, buildQuery: buildQuery, legalStuff: legalStuff };
});
4 changes: 2 additions & 2 deletions app/assets/javascripts/ui-bootstrap-custom.js
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ angular.module('ui.bootstrap.dropdownToggle', []).directive('dropdownToggle', ['
closeMenu = angular.noop;
return {
restrict: 'CA',
link: function(scope, element, attrs) {
link: function(scope, element) {
scope.$watch('$location.path', function() { closeMenu(); });
element.parent().bind('click', function() { closeMenu(); });
element.bind('click', function (event) {
@@ -161,7 +161,7 @@ angular.module('ui.bootstrap.pagination', [])
startPage = ((Math.ceil(paginationCtrl.currentPage / scope.maxSize) - 1) * scope.maxSize) + 1;

// Adjust last page if limit is exceeded
endPage = Math.min(startPage + scope.maxSize - 1, scope.numPages);
endPage = Math.min(startPage + scope.maxSize - 1, +scope.numPages);
}
}

0 comments on commit 2926a90

Please sign in to comment.