Convert Discourse.ScrollTop to ES6

This commit is contained in:
Robin Ward 2015-05-19 12:51:03 -04:00
parent 8f0cd18d4b
commit 0a35b20933
15 changed files with 43 additions and 24 deletions

View file

@ -1,9 +1,10 @@
import BufferedContent from 'discourse/mixins/buffered-content';
import ScrollTop from 'discourse/mixins/scroll-top';
import SiteSetting from 'admin/models/site-setting';
const CustomTypes = ['bool', 'enum', 'list', 'url_list'];
export default Ember.Component.extend(BufferedContent, Discourse.ScrollTop, {
export default Ember.Component.extend(BufferedContent, ScrollTop, {
classNameBindings: [':row', ':setting', 'setting.overridden', 'typeClass'],
content: Ember.computed.alias('setting'),
dirty: Discourse.computed.propertyNotEqual('buffered.value', 'setting.value'),

View file

@ -1 +1,3 @@
export default Ember.View.extend(Discourse.ScrollTop);
import ScrollTop from 'discourse/mixins/scroll-top';
export default Ember.View.extend(ScrollTop);

View file

@ -1,4 +1,6 @@
export default Ember.View.extend(Discourse.ScrollTop, {
import ScrollTop from 'discourse/mixins/scroll-top';
export default Ember.View.extend(ScrollTop, {
_scrollOnModelChange: function() {
this._scrollTop();
}.observes('controller.model.id')

View file

@ -0,0 +1,12 @@
function scrollTop() {
if (Discourse.URL.isJumpScheduled()) { return; }
Ember.run.schedule('afterRender', function() {
$(document).scrollTop(0);
});
}
export default Ember.Mixin.create({
_scrollTop: scrollTop.on('didInsertElement')
});
export { scrollTop };

View file

@ -1,8 +0,0 @@
Discourse.ScrollTop = Em.Mixin.create({
_scrollTop: function() {
if (Discourse.URL.isJumpScheduled()) { return; }
Em.run.schedule('afterRender', function() {
$(document).scrollTop(0);
});
}.on('didInsertElement')
});

View file

@ -2,11 +2,11 @@
The parent route for all discovery routes.
Handles the logic for showing the loading spinners.
**/
import ShowFooter from "discourse/mixins/show-footer";
import OpenComposer from "discourse/mixins/open-composer";
import { scrollTop } from 'discourse/mixins/scroll-top';
const DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, OpenComposer, ShowFooter, {
const DiscoveryRoute = Discourse.Route.extend(OpenComposer, ShowFooter, {
redirect: function() { return this.redirectIfLoginRequired(); },
beforeModel: function(transition) {
@ -27,7 +27,7 @@ const DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, OpenComposer,
loadingComplete: function() {
this.controllerFor('discovery').set('loading', false);
if (!this.session.get('topicListScrollPosition')) {
this._scrollTop();
scrollTop();
}
},

View file

@ -1,2 +1,3 @@
export default Ember.View.extend(Discourse.ScrollTop);
import ScrollTop from 'discourse/mixins/scroll-top';
export default Ember.View.extend(ScrollTop);

View file

@ -1,6 +1,7 @@
import UrlRefresh from 'discourse/mixins/url-refresh';
import ScrollTop from 'discourse/mixins/scroll-top';
export default Discourse.View.extend(UrlRefresh, Discourse.ScrollTop, {
export default Discourse.View.extend(UrlRefresh, ScrollTop, {
_addBodyClass: function() {
$('body').addClass('categories-list');
}.on('didInsertElement'),

View file

@ -1,3 +1,4 @@
import UrlRefresh from 'discourse/mixins/url-refresh';
import ScrollTop from 'discourse/mixins/scroll-top';
export default Discourse.View.extend(Discourse.ScrollTop, UrlRefresh);
export default Discourse.View.extend(ScrollTop, UrlRefresh);

View file

@ -6,7 +6,7 @@ export default Discourse.View.extend(LoadMore, UrlRefresh, {
actions: {
loadMore() {
var self = this;
const self = this;
Discourse.notifyTitle(0);
this.get('controller').loadMoreTopics().then(function (hasMoreResults) {
Em.run.schedule('afterRender', function() {
@ -20,7 +20,7 @@ export default Discourse.View.extend(LoadMore, UrlRefresh, {
},
_readjustScrollPosition: function() {
var scrollTo = this.session.get('topicListScrollPosition');
const scrollTo = this.session.get('topicListScrollPosition');
if (typeof scrollTo !== "undefined") {
Em.run.schedule('afterRender', function() {

View file

@ -1,5 +1,6 @@
import ScrollTop from 'discourse/mixins/scroll-top';
import LoadMore from "discourse/mixins/load-more";
export default Discourse.View.extend(Discourse.ScrollTop, LoadMore, {
export default Discourse.View.extend(ScrollTop, LoadMore, {
eyelineSelector: '.user-stream .item',
});

View file

@ -1,5 +1,6 @@
import ScrollTop from 'discourse/mixins/scroll-top';
import LoadMore from "discourse/mixins/load-more";
export default Discourse.View.extend(Discourse.ScrollTop, LoadMore, {
export default Discourse.View.extend(ScrollTop, LoadMore, {
eyelineSelector: '.group-members tr',
});

View file

@ -1,8 +1,9 @@
import isElementInViewport from "discourse/lib/is-element-in-viewport";
import ScrollTop from 'discourse/mixins/scroll-top';
var readFaq = false;
export default Ember.View.extend(Discourse.ScrollTop, {
export default Ember.View.extend(ScrollTop, {
_checkRead: function() {
const path = this.get('controller.model.path');

View file

@ -1 +1,3 @@
export default Ember.View.extend(Discourse.ScrollTop);
import ScrollTop from 'discourse/mixins/scroll-top';
export default Ember.View.extend(ScrollTop);

View file

@ -1,4 +1,6 @@
export default Ember.View.extend(Discourse.ScrollTop, {
import ScrollTop from 'discourse/mixins/scroll-top';
export default Ember.View.extend(ScrollTop, {
templateName: 'user/user',
userBinding: 'controller.content'
});