2015-03-16 06:05:27 +00:00
|
|
|
Demo.DemoView = Ember.View.extend({
|
2015-04-23 01:48:24 +00:00
|
|
|
classNames: ['demo-overlay'],
|
|
|
|
|
2015-04-23 03:21:15 +00:00
|
|
|
mouseUp: function(ev) {
|
|
|
|
var selection = window.getSelection().toString();
|
|
|
|
|
|
|
|
if (selection.length > 0) {
|
|
|
|
// Ignore clicks when they are trying to select something
|
2015-04-23 01:48:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var element = this.$();
|
|
|
|
|
2016-05-15 16:58:36 +00:00
|
|
|
// Record scroll position
|
2015-04-23 01:48:24 +00:00
|
|
|
var x = element.scrollX, y = element.scrollY;
|
|
|
|
// Focus
|
|
|
|
element.find('input.shell')[0].focus();
|
|
|
|
// Scroll back to where you were
|
|
|
|
element.scrollTop(x, y);
|
|
|
|
},
|
|
|
|
|
|
|
|
didInsertElement: function() {
|
|
|
|
var controller = this.get('controller'),
|
|
|
|
overlay = $('.sidebar-overlay'),
|
|
|
|
element = this.$();
|
|
|
|
|
2015-04-23 21:20:08 +00:00
|
|
|
$('body').addClass('demo-active');
|
|
|
|
|
2015-04-23 01:48:24 +00:00
|
|
|
overlay.addClass('active');
|
|
|
|
|
|
|
|
overlay.on('click', function() {
|
|
|
|
controller.transitionTo('index');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Scroll to the bottom of the element
|
|
|
|
element.scrollTop(element[0].scrollHeight);
|
|
|
|
|
|
|
|
// Focus
|
|
|
|
element.find('input.shell')[0].focus();
|
|
|
|
},
|
|
|
|
|
|
|
|
willDestroyElement: function() {
|
|
|
|
// Remove overlay
|
|
|
|
$('.sidebar-overlay').removeClass('active');
|
|
|
|
|
|
|
|
var element = this.$();
|
|
|
|
|
|
|
|
element.fadeOut(400);
|
|
|
|
|
2015-04-23 21:20:08 +00:00
|
|
|
$('body').removeClass('demo-active');
|
|
|
|
|
|
|
|
// reset scroll to top after closing demo
|
|
|
|
window.scrollTo(0, 0);
|
2015-04-23 01:48:24 +00:00
|
|
|
},
|
|
|
|
|
2015-03-16 06:05:27 +00:00
|
|
|
});
|