/** * Creates an es.SurfaceView object. * * @class * @constructor * @param {jQuery} $container DOM Container to render surface into * @param {es.SurfaceModel} model Surface model to view */ es.SurfaceView = function( $container, model ) { this.$ = $container.addClass( 'es-surfaceView' ); this.$window = $( window ); this.model = model; // Initialize document view this.documentView = new es.DocumentView( this.model.getDocument(), this ); this.$.append( this.documentView.$ ); // Interaction state this.mouse = { selectingMode: null, selectedRange: null }; this.cursor = { $: $( '
' ).appendTo( this.$ ), interval: null, initialLeft: null, initialBias: false }; this.keyboard = { selecting: false, cursorAnchor: null, keydownTimeout: null, keys: { shift: false, control: false, command: false, alt: false } }; this.selection = new es.Range(); // References for use in closures var surfaceView = this, $document = $( document ); // MouseDown and DoubleClick on surface this.$.on( { 'mousedown' : function(e) { return surfaceView.onMouseDown( e ); } } ); // Hidden input this.$input = $( '