-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
14 changed files
with
70 additions
and
178 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters