Skip to content

Commit

Permalink
Merge branch 'master' into 2955-update-recline
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Oct 4, 2012
2 parents 499552e + b5332a1 commit fa8e0a7
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions ckan/public/base/javascript/modules/data-viewer.js
Expand Up @@ -5,7 +5,7 @@ this.ckan.module('data-viewer', function (jQuery) {
options: {
timeout: 200,
minHeight: 400,
padding: 42
padding: 30
},

initialize: function () {
Expand All @@ -21,37 +21,17 @@ this.ckan.module('data-viewer', function (jQuery) {
if (this.el.attr('src').substring(0, loc.length) === loc) {
this._recalibrate();
setInterval(function() {
if (!self.el.is(':animated')) {
self._recalibrate();
}
self._recalibrate();
}, this.options.timeout);
} else {
this.el.animate({height: 600}, 600);
this.el.css('height', 600);
}
},

_showDebugInfo: function() {
var iframe = this.el;
console.log('=================');
console.log($(iframe.get(0), window.top.document).contents().find('body')[0].scrollHeight);
console.log($(iframe.get(0).contentWindow.document).height());
console.log($(iframe.get(0).contentWindow.document.body).height());
console.log($(iframe.contents().height()));
console.log($(iframe.contents().innerHeight()));
console.log($(iframe.contents().find('html').height()));
console.log($(iframe.contents().find('body').height()));
console.log($(iframe.contents().find('body').innerHeight()));
},

_recalibrate: function() {
// save reference to this to use in timeout
var self = this;
var height = self.el.contents().find('body').height();
height = Math.max(height, self.options.minHeight);
var deltaHeight = height - (self.el.height() - self.options.padding);
if (deltaHeight > 1 || deltaHeight < -10) {
self.el.animate({height: height+self.options.padding}, Math.min(700, height*2));
}
var height = this.el.contents().find('body').outerHeight(true);
height = Math.max(height, this.options.minHeight);
this.el.css('height', height + this.options.padding);
},

// firefox caches iframes so force it to get fresh content
Expand Down

0 comments on commit fa8e0a7

Please sign in to comment.