open-vault/website/source/assets/javascripts/demo/views/demo.js

57 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-03-16 06:05:27 +00:00
Demo.DemoView = Ember.View.extend({
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
return;
}
var element = this.$();
2016-05-15 16:58:36 +00:00
// Record scroll position
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.$();
$('body').addClass('demo-active');
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);
$('body').removeClass('demo-active');
// reset scroll to top after closing demo
window.scrollTo(0, 0);
},
2015-03-16 06:05:27 +00:00
});