mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
FIX: Coudln't scroll while on Qunit page due to browser bindings
This commit is contained in:
parent
4cd71972be
commit
a8b5716421
@ -158,10 +158,7 @@ Discourse.Utilities = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
validateFilesForUpload
|
||||
|
||||
**/
|
||||
/**
|
||||
Validate a list of files to be uploaded
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
This mixin adds support for being notified every time the browser window
|
||||
is scrolled.
|
||||
|
||||
@class Discourse.Scrolling
|
||||
@class Scrolling
|
||||
@extends Ember.Mixin
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
@ -16,19 +16,22 @@ Discourse.Scrolling = Em.Mixin.create({
|
||||
@method bindScrolling
|
||||
*/
|
||||
bindScrolling: function(opts) {
|
||||
var onScroll,
|
||||
_this = this;
|
||||
|
||||
opts = opts || {debounce: 100};
|
||||
|
||||
var scrollingMixin = this;
|
||||
var onScrollMethod;
|
||||
|
||||
if (opts.debounce) {
|
||||
onScroll = Discourse.debounce(function() { return _this.scrolled(); }, 100);
|
||||
onScrollMethod = Discourse.debounce(function() {
|
||||
return scrollingMixin.scrolled();
|
||||
}, 100);
|
||||
} else {
|
||||
onScroll = function(){ return _this.scrolled(); };
|
||||
onScrollMethod = function() {
|
||||
return scrollingMixin.scrolled();
|
||||
};
|
||||
}
|
||||
|
||||
$(document).bind('touchmove.discourse', onScroll);
|
||||
$(window).bind('scroll.discourse', onScroll);
|
||||
Discourse.ScrollingDOMMethods.bindOnScroll(onScrollMethod);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -37,10 +40,32 @@ Discourse.Scrolling = Em.Mixin.create({
|
||||
@method unbindScrolling
|
||||
*/
|
||||
unbindScrolling: function() {
|
||||
$(window).unbind('scroll.discourse');
|
||||
$(document).unbind('touchmove.discourse');
|
||||
Discourse.ScrollingDOMMethods.unbindOnScroll();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
This object provides the DOM methods we need for our Mixin to bind to scrolling
|
||||
methods in the browser. By removing them from the Mixin we can test them
|
||||
easier.
|
||||
|
||||
@class ScrollingDOMMethods
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.ScrollingDOMMethods = {
|
||||
|
||||
bindOnScroll: function(onScrollMethod) {
|
||||
console.log("BOUND");
|
||||
$(document).bind('touchmove.discourse', onScrollMethod);
|
||||
$(window).bind('scroll.discourse', onScrollMethod);
|
||||
},
|
||||
|
||||
unbindOnScroll: function() {
|
||||
console.log("UNBOUND");
|
||||
$(window).unbind('scroll.discourse');
|
||||
$(document).unbind('touchmove.discourse');
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,15 @@
|
||||
function integration(name) {
|
||||
module(name, {
|
||||
setup: function() {
|
||||
sinon.stub(Discourse.ScrollingDOMMethods, "bindOnScroll");
|
||||
sinon.stub(Discourse.ScrollingDOMMethods, "unbindOnScroll");
|
||||
Ember.run(Discourse, Discourse.advanceReadiness);
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
Discourse.reset();
|
||||
Discourse.ScrollingDOMMethods.bindOnScroll.restore();
|
||||
Discourse.ScrollingDOMMethods.unbindOnScroll.restore();
|
||||
}
|
||||
});
|
||||
}
|
@ -31,13 +31,13 @@
|
||||
//= require admin
|
||||
//= require_tree ../../app/assets/javascripts/defer
|
||||
|
||||
//= require main_include
|
||||
|
||||
//= require sinon-1.7.1.js
|
||||
//= require sinon-qunit-1.0.0.js
|
||||
|
||||
//= require helpers/qunit_helpers
|
||||
//= require helpers/assertions
|
||||
|
||||
//= require_tree ./fixtures
|
||||
//= require_tree .
|
||||
//= require_self
|
||||
|
Loading…
Reference in New Issue
Block a user