'use strict';

var router = require( '../router' );
var BaseView = require( './new-base-view' );

var WindowView = BaseView.extend({

  // Auto-wrapping of links with navigate method
  events: {
    'click a': 'navigate'
  },

  navigate: function( evt ) {
    var $el = this.$( evt.target );
    if ( ! $el.is( 'a' ) ) {
      $el = $el.closest( 'a' );
    }
    var targetUrl = $el.attr( 'href' );

    // Don't hijack any off-site links
    if ( /http/.test( targetUrl ) ) {
      return;
    }

    evt.preventDefault();

    router.nav( targetUrl );
  }

});

module.exports = new WindowView({
  el: document.body
});

'use strict';

var Backbone = require( 'backbone' );

var WindowView = Backbone.View.extend({
  el: 'body',

  // Auto-wrapping of links with navigate method
  events: {
    'click a': 'navigate'
  },

  navigate: function( evt ) {
    var $el = this.$( evt.target );
    if ( ! $el.is( 'a' ) ) {
      $el = $el.closest( 'a' );
    }
    var targetUrl = $el.attr( 'href' );

    // Don't hijack any off-site links
    if ( /http/.test( targetUrl ) ) {
      return;
    }

    evt.preventDefault();

    require( '../router' ).nav( targetUrl );
  }

});

module.exports = new WindowView();

--- 
+++ 
@@ -1,9 +1,9 @@
 'use strict';
 
-var router = require( '../router' );
-var BaseView = require( './new-base-view' );
+var Backbone = require( 'backbone' );
 
-var WindowView = BaseView.extend({
+var WindowView = Backbone.View.extend({
+  el: 'body',
 
   // Auto-wrapping of links with navigate method
   events: {
@@ -24,11 +24,9 @@
 
     evt.preventDefault();
 
-    router.nav( targetUrl );
+    require( '../router' ).nav( targetUrl );
   }
 
 });
 
-module.exports = new WindowView({
-  el: document.body
-});
+module.exports = new WindowView();
Convert WindowView to an ampersand-view

Uses the new base view to mix in jQuery functionality in the manner of
traditional backbone views
