Merge pull request #2907 from appleYaks/shadows

Add shadows to PostsListView and the adjacent HTML Preview; Fix preview
This commit is contained in:
Hannah Wolfe 2014-06-09 09:38:10 +02:00
commit 4e6024094f
4 changed files with 54 additions and 9 deletions

View File

@ -1,13 +1,13 @@
{{#if title}} {{#if title}}
{{partial "floating-header"}} {{partial "floating-header"}}
<section class="content-preview-content"> {{#view "content-preview-content-view" tagName="section"}}
<div class="wrapper"> <div class="wrapper">
<h1>{{{title}}}</h1> <h1>{{{title}}}</h1>
{{{html}}} {{{html}}}
</div> </div>
</section> {{/view}}
{{else}} {{else}}

View File

@ -0,0 +1,19 @@
// ## scrollShadow
// This adds a 'scroll' class to the targeted element when the element is scrolled
// `this` is expected to be a jQuery-wrapped element
// **target:** The element in which the class is applied. Defaults to scrolled element.
// **class-name:** The class which is applied.
// **offset:** How far the user has to scroll before the class is applied.
var setScrollClassName = function (options) {
var $target = options.target || this,
offset = options.offset,
className = options.className || 'scrolling';
if (this.scrollTop() > offset) {
$target.addClass(className);
} else {
$target.removeClass(className);
}
};
export default setScrollClassName;

View File

@ -1,3 +1,5 @@
import setScrollClassName from 'ghost/utils/set-scroll-classname';
var PostsListView = Ember.View.extend({ var PostsListView = Ember.View.extend({
classNames: ['content-list-content'], classNames: ['content-list-content'],
@ -17,12 +19,16 @@ var PostsListView = Ember.View.extend({
didInsertElement: function () { didInsertElement: function () {
var el = this.$(); var el = this.$();
el.bind('scroll', Ember.run.bind(this, this.checkScroll)); el.on('scroll', Ember.run.bind(this, this.checkScroll));
el.on('scroll', Ember.run.bind(el, setScrollClassName, {
target: el.closest('.content-list'),
offset: 10
}));
}, },
willDestroyElement: function () { willDestroyElement: function () {
var el = this.$(); var el = this.$();
el.unbind('scroll'); el.off('scroll');
} }
}); });

View File

@ -0,0 +1,20 @@
import setScrollClassName from 'ghost/utils/set-scroll-classname';
var PostContentView = Ember.View.extend({
classNames: ['content-preview-content'],
didInsertElement: function () {
var el = this.$();
el.on('scroll', Ember.run.bind(el, setScrollClassName, {
target: el.closest('.content-preview'),
offset: 10
}));
},
willDestroyElement: function () {
var el = this.$();
el.off('scroll');
}
});
export default PostContentView;