Skip to content

Commit

Permalink
Remove legacy mobile view logic
Browse files Browse the repository at this point in the history
No issue
- Move editor-base-view mixin into editor/edit view
- Also deletes mobile views and modifies files that were using it
- Helps pave the way for Ember 2.0, where views do not exist
  • Loading branch information
novaugust committed Jun 14, 2015
1 parent a873456 commit df1c04b
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 178 deletions.
60 changes: 0 additions & 60 deletions core/client/app/mixins/editor-base-view.js

This file was deleted.

8 changes: 0 additions & 8 deletions core/client/app/styles/layouts/content.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
/* Content /ghost/
/* ---------------------------------------------------------- */

.content-view-container {
position: relative;
flex-grow: 1;
display: flex;
flex-direction: column;
}
/* Show/Hide on Mobile // TODO: What the fuck does that mean?
/* ---------------------------------------------------------- */
Expand Down
2 changes: 2 additions & 0 deletions core/client/app/templates/posts.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<section class="gh-view content-view-container">
<header class="view-header">
<h2 class="view-title">Content</h2>
<section class="view-actions">
Expand Down Expand Up @@ -40,3 +41,4 @@
{{outlet}}
</section>
</div>
</section>
61 changes: 57 additions & 4 deletions core/client/app/views/editor/edit.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,62 @@
import Ember from 'ember';
import EditorViewMixin from 'ghost/mixins/editor-base-view';
import setScrollClassName from 'ghost/utils/set-scroll-classname';

var EditorView = Ember.View.extend(EditorViewMixin, {
var EditorViewMixin = Ember.View.extend({
tagName: 'section',
classNames: ['gh-view']
classNames: ['gh-view'],
// create a hook for jQuery logic that will run after
// a view and all child views have been rendered,
// since didInsertElement runs only when the view's el
// has rendered, and not necessarily all child views.
//
// http://mavilein.github.io/javascript/2013/08/01/Ember-JS-After-Render-Event/
// http://emberjs.com/api/classes/Ember.run.html#method_next
scheduleAfterRender: function () {
Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent);
}.on('didInsertElement'),

// all child views will have rendered when this fires
afterRenderEvent: function () {
var $previewViewPort = this.$('.js-entry-preview-content');

// cache these elements for use in other methods
this.set('$previewViewPort', $previewViewPort);
this.set('$previewContent', this.$('.js-rendered-markdown'));

$previewViewPort.on('scroll', Ember.run.bind($previewViewPort, setScrollClassName, {
target: this.$('.js-entry-preview'),
offset: 10
}));
},

removeScrollHandlers: function () {
this.get('$previewViewPort').off('scroll');
}.on('willDestroyElement'),

// updated when gh-ed-editor component scrolls
editorScrollInfo: null,
// updated when markdown is rendered
height: null,

// HTML Preview listens to scrollPosition and updates its scrollTop value
// This property receives scrollInfo from the textEditor, and height from the preview pane, and will update the
// scrollPosition value such that when either scrolling or typing-at-the-end of the text editor the preview pane
// stays in sync
scrollPosition: Ember.computed('editorScrollInfo', 'height', function () {
if (!this.get('editorScrollInfo')) {
return 0;
}

var scrollInfo = this.get('editorScrollInfo'),
previewHeight = this.get('$previewContent').height() - this.get('$previewViewPort').height(),
previewPosition,
ratio;

ratio = previewHeight / scrollInfo.diff;
previewPosition = scrollInfo.top * ratio;

return previewPosition;
})
});

export default EditorView;
export default EditorViewMixin;
9 changes: 3 additions & 6 deletions core/client/app/views/editor/new.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import Ember from 'ember';
import EditorViewMixin from 'ghost/mixins/editor-base-view';
import EditorView from 'ghost/views/editor/edit';

var EditorNewView = Ember.View.extend(EditorViewMixin, {
tagName: 'section',
templateName: 'editor/edit',
classNames: ['gh-view']
var EditorNewView = EditorView.extend({
templateName: 'editor/edit'
});

export default EditorNewView;
16 changes: 0 additions & 16 deletions core/client/app/views/mobile/content-view.js

This file was deleted.

13 changes: 0 additions & 13 deletions core/client/app/views/mobile/index-view.js

This file was deleted.

34 changes: 0 additions & 34 deletions core/client/app/views/mobile/parent-view.js

This file was deleted.

19 changes: 0 additions & 19 deletions core/client/app/views/posts.js

This file was deleted.

4 changes: 2 additions & 2 deletions core/client/app/views/posts/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MobileIndexView from 'ghost/views/mobile/index-view';
import Ember from 'ember';

var PostsIndexView = MobileIndexView.extend({
var PostsIndexView = Ember.View.extend({
classNames: ['no-posts-box']
});

Expand Down
5 changes: 0 additions & 5 deletions core/client/app/views/posts/post.js

This file was deleted.

13 changes: 4 additions & 9 deletions core/client/app/views/settings/content-base.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import MobileContentView from 'ghost/views/mobile/content-view';
/**
* All settings views other than the index should inherit from this base class.
* It ensures that the correct screen is showing when a mobile user navigates
* to a `settings.someRouteThatIsntIndex` route.
*/
import Ember from 'ember';

var SettingsContentBaseView = MobileContentView.extend({
var SettingsView = Ember.View.extend({
tagName: 'section',
classNames: ['gh-view', 'js-settings-content']
classNames: ['gh-view']
});

export default SettingsContentBaseView;
export default SettingsView;
2 changes: 1 addition & 1 deletion core/test/functional/client/content_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CasperTest.begin('Content screen is correct', 15, function suite(test) {
});

casper.then(function testViews() {
test.assertExists('.content-view-container', 'Content main view is present');
test.assertExists('.gh-main .gh-view', 'Content main view is present');
test.assertExists('.content-list-content', 'Content list view is present');
test.assertExists('.gh-nav-main-editor', 'add new post button exists');
test.assertEquals(
Expand Down
2 changes: 1 addition & 1 deletion core/test/functional/client/settings_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CasperTest.begin('Settings screen is correct', 9, function suite(test) {
});

casper.then(function testViews() {
test.assertExists('.js-settings-content', 'Settings content view is present');
test.assertExists('.gh-main .gh-view', 'Settings content view is present');
test.assertExists(generalTabDetector, 'Form is present');
test.assertSelectorHasText('.view-title', 'General', 'Title is "General"');
});
Expand Down

0 comments on commit df1c04b

Please sign in to comment.