mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Convert Discourse.ScrollTop
to ES6
This commit is contained in:
parent
8f0cd18d4b
commit
0a35b20933
15 changed files with 43 additions and 24 deletions
|
@ -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'),
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
export default Ember.View.extend(Discourse.ScrollTop);
|
||||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
|
||||
export default Ember.View.extend(ScrollTop);
|
||||
|
|
|
@ -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')
|
||||
|
|
12
app/assets/javascripts/discourse/mixins/scroll-top.js.es6
Normal file
12
app/assets/javascripts/discourse/mixins/scroll-top.js.es6
Normal 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 };
|
|
@ -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')
|
||||
});
|
|
@ -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();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
export default Ember.View.extend(Discourse.ScrollTop);
|
||||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
|
||||
export default Ember.View.extend(ScrollTop);
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
export default Ember.View.extend(Discourse.ScrollTop);
|
||||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
|
||||
export default Ember.View.extend(ScrollTop);
|
||||
|
|
|
@ -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'
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue