Remove the `ScrollTop` Mixin
This commit is contained in:
parent
0904ad5537
commit
a94f06ff78
|
@ -1,12 +1,11 @@
|
|||
import BufferedContent from 'discourse/mixins/buffered-content';
|
||||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
import SiteSetting from 'admin/models/site-setting';
|
||||
import { propertyNotEqual } from 'discourse/lib/computed';
|
||||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
const CustomTypes = ['bool', 'enum', 'list', 'url_list', 'host_list', 'category_list', 'value_list'];
|
||||
|
||||
export default Ember.Component.extend(BufferedContent, ScrollTop, {
|
||||
export default Ember.Component.extend(BufferedContent, {
|
||||
classNameBindings: [':row', ':setting', 'setting.overridden', 'typeClass'],
|
||||
content: Ember.computed.alias('setting'),
|
||||
dirty: propertyNotEqual('buffered.value', 'setting.value'),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class='current-badge span13'>
|
||||
{{#d-section class="current-badge span13"}}
|
||||
<p>{{i18n 'admin.badges.none_selected'}}</p>
|
||||
|
||||
<div>
|
||||
|
@ -6,4 +6,4 @@
|
|||
{{fa-icon "plus"}} {{i18n 'admin.badges.new'}}
|
||||
{{/link-to}}
|
||||
</div>
|
||||
</div>
|
||||
{{/d-section}}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class='current-badge span13'>
|
||||
{{#d-section class="current-badge span13"}}
|
||||
<form class="form-horizontal">
|
||||
<div>
|
||||
<label for="name">{{i18n 'admin.badges.name'}}</label>
|
||||
|
@ -143,7 +143,7 @@
|
|||
{{/unless}}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{/d-section}}
|
||||
|
||||
{{#if grant_count}}
|
||||
<div class="span13 current-badge-actions">
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{{#if filteredContent}}
|
||||
<div class='form-horizontal settings'>
|
||||
{{#d-section class="form-horizontal settings"}}
|
||||
{{#each filteredContent as |setting|}}
|
||||
{{site-setting setting=setting saveAction="saveSetting"}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/d-section}}
|
||||
{{else}}
|
||||
<br/>
|
||||
{{i18n 'admin.site_settings.no_results'}}
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
{{outlet}}
|
||||
{{#d-section}}
|
||||
{{outlet}}
|
||||
{{/d-section}}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
|
||||
export default Ember.View.extend(ScrollTop);
|
|
@ -1,7 +0,0 @@
|
|||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
|
||||
export default Ember.View.extend(ScrollTop, {
|
||||
_scrollOnModelChange: function() {
|
||||
this._scrollTop();
|
||||
}.observes('controller.model.id')
|
||||
});
|
|
@ -1 +0,0 @@
|
|||
export default Ember.View.extend(Discourse.ScrollTop);
|
|
@ -1,14 +1,9 @@
|
|||
import DiscourseURL from 'discourse/lib/url';
|
||||
import { scrollTop } from 'discourse/mixins/scroll-top';
|
||||
|
||||
// Can add a body class from within a component, also will scroll to the top automatically.
|
||||
export default Ember.Component.extend({
|
||||
tagName: 'section',
|
||||
|
||||
_scrollTop() {
|
||||
if (Ember.testing) { return; }
|
||||
$(document).scrollTop(0);
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
|
||||
|
@ -26,8 +21,7 @@ export default Ember.Component.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
if (DiscourseURL.isJumpScheduled()) { return; }
|
||||
Ember.run.scheduleOnce('afterRender', this, this._scrollTop);
|
||||
scrollTop();
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
import isElementInViewport from "discourse/lib/is-element-in-viewport";
|
||||
|
||||
export default Ember.Component.extend({
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
const currentUser = this.currentUser;
|
||||
if (!currentUser) { return; }
|
||||
|
||||
const path = this.get('path');
|
||||
if (path === "faq" || path === "guidelines") {
|
||||
$(window).on('load.faq resize.faq scroll.faq', () => {
|
||||
const faqUnread = !currentUser.get('read_faq');
|
||||
if (faqUnread && isElementInViewport($(".contents p").last())) {
|
||||
this.sendAction();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super();
|
||||
$(window).off('load.faq resize.faq scroll.faq');
|
||||
}
|
||||
});
|
|
@ -6,6 +6,9 @@ export default Ember.Controller.extend({
|
|||
|
||||
showLoginButton: Em.computed.equal("model.path", "login"),
|
||||
|
||||
@computed('model.path')
|
||||
bodyClass: path => `static-${path}`,
|
||||
|
||||
@computed("model.path")
|
||||
showSignupButton() {
|
||||
return this.get("model.path") === "login" && this.get('application.canSignUp');
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
import DiscourseURL from 'discourse/lib/url';
|
||||
import { deprecated } from 'discourse/mixins/scroll-top';
|
||||
|
||||
const context = {
|
||||
_scrollTop() {
|
||||
if (Ember.testing) { return; }
|
||||
$(document).scrollTop(0);
|
||||
}
|
||||
};
|
||||
|
||||
function scrollTop() {
|
||||
if (DiscourseURL.isJumpScheduled()) { return; }
|
||||
Ember.run.schedule('afterRender', function() {
|
||||
$(document).scrollTop(0);
|
||||
});
|
||||
Ember.run.scheduleOnce('afterRender', context, context._scrollTop);
|
||||
}
|
||||
|
||||
export default Ember.Mixin.create({
|
||||
_scrollTop: scrollTop.on('didInsertElement')
|
||||
didInsertElement() {
|
||||
deprecated('The `ScrollTop` mixin is deprecated. Replace it with a `{{d-section}}` component');
|
||||
this._super();
|
||||
scrollTop();
|
||||
}
|
||||
});
|
||||
|
||||
export { scrollTop };
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
<div class='container'>
|
||||
<div class='contents clearfix body-page'>
|
||||
{{plugin-outlet "above-static"}}
|
||||
{{{model.html}}}
|
||||
{{#d-section bodyClass=bodyClass class="container"}}
|
||||
{{#watch-read action="markFaqRead" path=model.path}}
|
||||
<div class='contents clearfix body-page'>
|
||||
{{plugin-outlet "above-static"}}
|
||||
{{{model.html}}}
|
||||
|
||||
{{#if showSignupButton}}
|
||||
{{d-button action="showCreateAccount" class="btn-primary sign-up-button" label="sign_up"}}
|
||||
{{/if}}
|
||||
{{#if showSignupButton}}
|
||||
{{d-button action="showCreateAccount" class="btn-primary sign-up-button" label="sign_up"}}
|
||||
{{/if}}
|
||||
|
||||
{{#if showLoginButton}}
|
||||
{{d-button action="showLogin" class="btn-primary login-button" icon="user" label="log_in"}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
{{#if showLoginButton}}
|
||||
{{d-button action="showLogin" class="btn-primary login-button" icon="user" label="log_in"}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/watch-read}}
|
||||
{{/d-section}}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="container{{if viewingSelf ' viewing-self'}}">
|
||||
<section class='user-main'>
|
||||
<div class="container {{if viewingSelf 'viewing-self'}}">
|
||||
{{#d-section class="user-main"}}
|
||||
|
||||
<section class="{{if collapsedInfo 'collapsed-info'}} about {{if hasProfileBackground 'has-background' 'no-background'}}" style={{model.profileBackground}}>
|
||||
{{#unless collapsedInfo}}
|
||||
|
@ -186,5 +186,5 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
{{/d-section}}
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{#d-section pageClass="user-activity" class="user-nagivation" scrollTop="false"}}
|
||||
{{#d-section pageClass="user-activity" class="user-navigation" scrollTop="false"}}
|
||||
{{#mobile-nav class='activity-nav' desktopClass='action-list activity-list nav-stacked' currentPath=currentPath}}
|
||||
<li class='no-glyph'>
|
||||
{{#link-to 'userActivity.index'}}{{i18n 'user.filters.all'}}{{/link-to}}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
import isElementInViewport from "discourse/lib/is-element-in-viewport";
|
||||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
import { on } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
export default Ember.View.extend(ScrollTop, {
|
||||
|
||||
@on('didInsertElement')
|
||||
_addBodyClass() {
|
||||
const path = this.get('controller.model.path');
|
||||
$('body').addClass(`static-${path}`);
|
||||
},
|
||||
|
||||
@on('willDestroyElement')
|
||||
_removeBodyClass() {
|
||||
const path = this.get('controller.model.path');
|
||||
$('body').removeClass(`static-${path}`);
|
||||
},
|
||||
|
||||
@on('didInsertElement')
|
||||
_checkRead() {
|
||||
const currentUser = this.get('controller.currentUser');
|
||||
if (currentUser) {
|
||||
const path = this.get('controller.model.path');
|
||||
if (path === "faq" || path === "guidelines") {
|
||||
const controller = this.get('controller');
|
||||
$(window).on('load.faq resize.faq scroll.faq', function() {
|
||||
const faqUnread = !currentUser.get('read_faq');
|
||||
if (faqUnread && isElementInViewport($(".contents p").last())) {
|
||||
controller.send('markFaqRead');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@on('willDestroyElement')
|
||||
_stopChecking() {
|
||||
$(window).off('load.faq resize.faq scroll.faq');
|
||||
}
|
||||
});
|
|
@ -1,4 +0,0 @@
|
|||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
|
||||
export default Ember.View.extend(ScrollTop, {
|
||||
});
|
|
@ -4,21 +4,25 @@ acceptance("Static");
|
|||
test("Static Pages", () => {
|
||||
visit("/faq");
|
||||
andThen(() => {
|
||||
ok($('body.static-faq').length, "has the body class");
|
||||
ok(exists(".body-page"), "The content is present");
|
||||
});
|
||||
|
||||
visit("/guidelines");
|
||||
andThen(() => {
|
||||
ok($('body.static-guidelines').length, "has the body class");
|
||||
ok(exists(".body-page"), "The content is present");
|
||||
});
|
||||
|
||||
visit("/tos");
|
||||
andThen(() => {
|
||||
ok($('body.static-tos').length, "has the body class");
|
||||
ok(exists(".body-page"), "The content is present");
|
||||
});
|
||||
|
||||
visit("/privacy");
|
||||
andThen(() => {
|
||||
ok($('body.static-privacy').length, "has the body class");
|
||||
ok(exists(".body-page"), "The content is present");
|
||||
});
|
||||
|
||||
|
|
|
@ -28,5 +28,6 @@ test("Root URL - Viewing Self", () => {
|
|||
andThen(() => {
|
||||
ok($('body.user-summary-page').length, "has the body class");
|
||||
equal(currentPath(), 'user.summary', "it defaults to summary");
|
||||
ok(exists('.container.viewing-self'), "has the viewing-self class");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -65,9 +65,7 @@ export default function() {
|
|||
|
||||
this.get('/users/eviltrout.json', () => {
|
||||
const json = fixturesByUrl['/users/eviltrout.json'];
|
||||
if (loggedIn()) {
|
||||
json.user.can_edit = true;
|
||||
}
|
||||
json.user.can_edit = loggedIn();
|
||||
return response(json);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue