mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Coudln't scroll while on Qunit page due to browser bindings
This commit is contained in:
parent
4cd71972be
commit
a8b5716421
4 changed files with 40 additions and 14 deletions
|
@ -158,10 +158,7 @@ Discourse.Utilities = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
validateFilesForUpload
|
|
||||||
|
|
||||||
**/
|
|
||||||
/**
|
/**
|
||||||
Validate a list of files to be uploaded
|
Validate a list of files to be uploaded
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
This mixin adds support for being notified every time the browser window
|
This mixin adds support for being notified every time the browser window
|
||||||
is scrolled.
|
is scrolled.
|
||||||
|
|
||||||
@class Discourse.Scrolling
|
@class Scrolling
|
||||||
@extends Ember.Mixin
|
@extends Ember.Mixin
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
|
@ -16,19 +16,22 @@ Discourse.Scrolling = Em.Mixin.create({
|
||||||
@method bindScrolling
|
@method bindScrolling
|
||||||
*/
|
*/
|
||||||
bindScrolling: function(opts) {
|
bindScrolling: function(opts) {
|
||||||
var onScroll,
|
|
||||||
_this = this;
|
|
||||||
|
|
||||||
opts = opts || {debounce: 100};
|
opts = opts || {debounce: 100};
|
||||||
|
|
||||||
|
var scrollingMixin = this;
|
||||||
|
var onScrollMethod;
|
||||||
|
|
||||||
if (opts.debounce) {
|
if (opts.debounce) {
|
||||||
onScroll = Discourse.debounce(function() { return _this.scrolled(); }, 100);
|
onScrollMethod = Discourse.debounce(function() {
|
||||||
|
return scrollingMixin.scrolled();
|
||||||
|
}, 100);
|
||||||
} else {
|
} else {
|
||||||
onScroll = function(){ return _this.scrolled(); };
|
onScrollMethod = function() {
|
||||||
|
return scrollingMixin.scrolled();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).bind('touchmove.discourse', onScroll);
|
Discourse.ScrollingDOMMethods.bindOnScroll(onScrollMethod);
|
||||||
$(window).bind('scroll.discourse', onScroll);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,10 +40,32 @@ Discourse.Scrolling = Em.Mixin.create({
|
||||||
@method unbindScrolling
|
@method unbindScrolling
|
||||||
*/
|
*/
|
||||||
unbindScrolling: function() {
|
unbindScrolling: function() {
|
||||||
$(window).unbind('scroll.discourse');
|
Discourse.ScrollingDOMMethods.unbindOnScroll();
|
||||||
$(document).unbind('touchmove.discourse');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
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) {
|
function integration(name) {
|
||||||
module(name, {
|
module(name, {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
|
sinon.stub(Discourse.ScrollingDOMMethods, "bindOnScroll");
|
||||||
|
sinon.stub(Discourse.ScrollingDOMMethods, "unbindOnScroll");
|
||||||
Ember.run(Discourse, Discourse.advanceReadiness);
|
Ember.run(Discourse, Discourse.advanceReadiness);
|
||||||
},
|
},
|
||||||
|
|
||||||
teardown: function() {
|
teardown: function() {
|
||||||
Discourse.reset();
|
Discourse.reset();
|
||||||
|
Discourse.ScrollingDOMMethods.bindOnScroll.restore();
|
||||||
|
Discourse.ScrollingDOMMethods.unbindOnScroll.restore();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -31,13 +31,13 @@
|
||||||
//= require admin
|
//= require admin
|
||||||
//= require_tree ../../app/assets/javascripts/defer
|
//= require_tree ../../app/assets/javascripts/defer
|
||||||
|
|
||||||
//= require main_include
|
|
||||||
|
|
||||||
//= require sinon-1.7.1.js
|
//= require sinon-1.7.1.js
|
||||||
//= require sinon-qunit-1.0.0.js
|
//= require sinon-qunit-1.0.0.js
|
||||||
|
|
||||||
//= require helpers/qunit_helpers
|
//= require helpers/qunit_helpers
|
||||||
//= require helpers/assertions
|
//= require helpers/assertions
|
||||||
|
|
||||||
//= require_tree ./fixtures
|
//= require_tree ./fixtures
|
||||||
//= require_tree .
|
//= require_tree .
|
||||||
//= require_self
|
//= require_self
|
||||||
|
|
Loading…
Reference in a new issue