Example #1
0
			$(win.document).on("click", "a[href]:not([data-bypass])", function(evt) {
				var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
				var root = win.location.protocol + "//" + win.location.host;

				if (href.prop.slice(0, root.length) === root) {
					evt.preventDefault();
					Backbone.history.navigate(href.attr, true);
				}
			});
Example #2
0
Router.init();

Router.getRouteModel().on('change:currentRoute', function (routeModel) {
  var route = routeModel.get('currentRoute');
  if (!route) return;
  if (route[0] !== 'modal') {
    modals.destroy();
  }

  editorModel.set('edition', false);
});

var rootLocation = (/(\/builder\/[0-z\.\-]+\/?)/).exec(location.pathname)[1];
var baseUrl = userModel.isInsideOrg() ? '/u/' + userModel.get('username') : '';
Backbone.history.start({ pushState: true, hashChange: false, root: baseUrl + rootLocation });

var editorTabPaneView = createEditorMenuTabPane([
  {
    icon: 'pencilMenu',
    name: 'editor',
    tooltip: 'edit-map',
    selected: true,
    onClick: function () { Router.goToLayerList(); },
    createContentView: function () {
      editorModel.set({settingsView: false});
      return new EditorMapView({
        basemaps: basemaps,
        userActions: userActions,
        configModel: configModel,
        userModel: userModel,
 }).always(function(data) {
   that.options.userModel.set({
     newCommentId: data.id
   });
   Backbone.history.loadUrl(Backbone.history.fragment);
 });
Example #4
0
 getCurrentUrl() {
     return history.getFragment();
 }
 goToBacheca: function(e){
   console.log(this.model);
   Backbone.history.navigate("bacheca/"+e.currentTarget.id, {
     trigger: true
   });
 },
Example #6
0
 initialize: function() {
   Backbone.history.start();
 },
Example #7
0
  initialize: function() {
    "use strict";

    Backbone.history.start();
  },
 goToConferma : function () {
     //TODO something
     Backbone.history.navigate('chiudiModal',{
         trigger: true
     });
 },
Example #9
0
 error: function() {
     Backbone.history.navigate('auto_logout',
                               {'trigger':true});
 }
Example #10
0
$(() => {
    
    // Begin monitoring hashchange events
    // dispatching routes
    Backbone.history.start();
});
 start: function() {
     console.log('In the app, now.');
     var appRouter = new AppRouter();
     Backbone.history.start();
 }
Example #12
0
$(document).ready(function() {
  var router = new AppRouter();
  Backbone.history.start();
});
			_.defer(function () {		
				var navId = "#/id/" + Adapt.location._lastVisitedPage;
				Backbone.history.navigate(navId, true);
			});
Example #14
0
$(document).ready(function () {
    app.router = new Router();
    Backbone.history.start({ pushState: false, root: app.root });
});
Example #15
0
File: app.js Project: bozz/hexago
$(function() {
    console.log("000000000000", Workspace);
    Workspace.init();
    Backbone.history.start();
});
Example #16
0
File: index.js Project: aino/quiz
  Router.on('route', function(name, paths) {

    var query = paths.pop()
    query = query && window.location.search ? Qs.parse(query) : {}

    var params = {
      paths: paths,
      query: query
    }

    var route = $.extend({}, routeApi)

    // call the route
    if ( Routes.hasOwnProperty(name) )
      Routes[name].call(route, params)

    // detect backbutton and save crumbs
    var fragment = Backbone.history.getFragment()
    var backbutton = Backbone.history.backbutton = !clicked && crumbs.length > 1 && fragment == crumbs[crumbs.length-2]
    var proceed = function() {

      if(!history.length || detect.touch)
        route.isModal = false

      history.push({
        name: name,
        params: params,
        path: window.location.pathname,
        modal: route.isModal
      })

      var wasModal = ( history.length > 2 && history[history.length-2].modal )

      if ( route.isModal ) {
        App.setState({ modal: true, wasmodal: false })
      } else {
        if (!wasModal)
          scrollBack()
        node.className = name
        App.setState({
          modal: route.isModal,
          wasmodal: wasModal,
          route: {
            name: name,
            params: params
          }
        })
      }

      clicked = false
      if ( backbutton )
        crumbs.splice(-2,2)
      crumbs.push(fragment)
    }

    var msg = globals.getUnloadMessage()
    if ( backbutton && msg && !goingBack ) {
      if ( window.confirm(msg) ) {
        proceed()
      }
      else {
        Backbone.history.history.go(1)
        crumbs.splice(-1,1)
        goingBack = true
      }
    } else {
      goingBack = false
      proceed()
    }
  })
Example #17
0
File: index.js Project: aino/quiz
window.Run = function() {

  var node = document.getElementById('app')

  // render the app
  var App = React.renderComponent(AppComponent({ 
    models: models,
    clickHandler: clickHandler,
    downHandler: function(e) {
      $(e.target).closest('a, button').addClass('down')
    },
    upHandler: function(e) {
      $(e.target).closest('a, button').removeClass('down')
    },
    setBodyClass: function(cl) {
      document.body.className = cl
    }
  }), node)

  $(document).on('keydown', function(e) {
    if (e.ctrlKey || e.which === 91)
      openLinkInTab = true
  }).on('keyup', function(e) {
    openLinkInTab = false
  })

  // start router
  Router.on('route', function(name, paths) {

    var query = paths.pop()
    query = query && window.location.search ? Qs.parse(query) : {}

    var params = {
      paths: paths,
      query: query
    }

    var route = $.extend({}, routeApi)

    // call the route
    if ( Routes.hasOwnProperty(name) )
      Routes[name].call(route, params)

    // detect backbutton and save crumbs
    var fragment = Backbone.history.getFragment()
    var backbutton = Backbone.history.backbutton = !clicked && crumbs.length > 1 && fragment == crumbs[crumbs.length-2]
    var proceed = function() {

      if(!history.length || detect.touch)
        route.isModal = false

      history.push({
        name: name,
        params: params,
        path: window.location.pathname,
        modal: route.isModal
      })

      var wasModal = ( history.length > 2 && history[history.length-2].modal )

      if ( route.isModal ) {
        App.setState({ modal: true, wasmodal: false })
      } else {
        if (!wasModal)
          scrollBack()
        node.className = name
        App.setState({
          modal: route.isModal,
          wasmodal: wasModal,
          route: {
            name: name,
            params: params
          }
        })
      }

      clicked = false
      if ( backbutton )
        crumbs.splice(-2,2)
      crumbs.push(fragment)
    }

    var msg = globals.getUnloadMessage()
    if ( backbutton && msg && !goingBack ) {
      if ( window.confirm(msg) ) {
        proceed()
      }
      else {
        Backbone.history.history.go(1)
        crumbs.splice(-1,1)
        goingBack = true
      }
    } else {
      goingBack = false
      proceed()
    }
  })

  Backbone.history.start({pushState: true})

}
Example #18
0
	$(function(){
		new MainRouter();
		Backbone.history.start({pushState: false});
	});
 goBack: function () {
     //TODO
     Backbone.history.navigate('chiudiModal',{
         trigger: true
     });
 }
Example #20
0
$(function () {
  new ViewRouter();
  Backbone.history.start();
});
Example #21
0
 turtles.fetch().then(function() {
   Backbone.history.start();
 });
 .always(() => {
     // Refresh page
     Backbone.history.loadUrl();
 });
Example #23
0
 getCurrentRoute: function () {
   return Backbone.history.getPath();
 },
Example #24
0
 load: function (url) {
     Backbone.history.loadUrl(url);
 },
Example #25
0
  goToContacts: function(e) {
   Backbone.history.navigate("contacts", {
     trigger: true
   });
 }
Example #26
0
 Origin.trigger('editor:refreshData', function() {
   // TODO: HACK - I think this should probably pass a callback in
   // and return it with the new item - this way the individual views
   // can handle the new views and models
   Backbone.history.loadUrl();
 }, this);
Example #27
0
$(function(){
  Backbone.history.start();
});
Example #28
0
  })).always(function () {
    if (Backbone.history)
      Backbone.history.start();

    app.triggerMethod('initialize:asyncComplete');
  });
Example #29
0
  router.navigate('cart', {trigger: true});
});





var Router =Backbone.Router.extend({
  routes: {
    '': 'index',
    'cart': "cart"
  },
  index: function (){
    ReactDOM.render(
      <Tshirts collection={tshirtCollection} />,
      $('.container')[0]
    );
  },
  cart: function(){
    ReactDOM.render(
      <ListItem  />,
      $('.list')[0]
    );
  }
});


var router = new Router();

Backbone.history.start();
Example #30
0
$(document).ready(function() {

    // set up the leafet map object
	var map = L.map('map').setView(OTP.config.initLatLng, (OTP.config.initZoom || 13));
    map.attributionControl.setPrefix('');

	// create OpenStreetMap tile layers for streets and aerial imagery
	var osmLayer = L.tileLayer('http://{s}.tiles.mapbox.com/v3/' + OTP.config.osmMapKey + '/{z}/{x}/{y}.png', {
        subdomains : ['a','b','c','d'],
	    attribution: 'Street Map: <a href="http://mapbox.com/about/maps">Terms & Feedback</a>'
	});
    var aerialLayer = L.tileLayer('http://{s}.tiles.mapbox.com/v3/' + OTP.config.aerialMapKey + '/{z}/{x}/{y}.png', {
        subdomains : ['a','b','c','d'],
        attribution : 'Satellite Map: <a href="http://mapbox.com/about/maps">Terms & Feedback</a>'
    });

    // create a leaflet layer control and add it to the map
    var baseLayers = {
        "Street Map" : osmLayer,
        "Satellite Map" : aerialLayer
    };
    L.control.layers(baseLayers).addTo(map);

    // display the OSM street layer by default
    osmLayer.addTo(map);

    // create the trip topography widget and add it to the map
    var topoControl = new OTP.topo_views.LeafletTopoGraphControl();
    topoControl.addTo(map);
    
    // create a data model for the currently visible stops, and point it
    // to the corresponding API method
    var stopsRequestModel = new OTP.models.OtpStopsInRectangleRequest();
    stopsRequestModel.urlRoot = OTP.config.otpApi + '/transit/stopsInRectangle';

    // create the stops request view, which monitors the map and updates the
    // bounds of the visible stops request as the viewable area changes
    var stopsRequestMapView = new OTP.map_views.OtpStopsRequestMapView({
        model: stopsRequestModel,
        map: map
    });

    // create the stops response view, which refreshes the stop markers on the
    // map whenever the underlying visible stops model changes
    var stopsResponseMapView = new OTP.map_views.OtpStopsResponseMapView({
        map: map
    });
    stopsRequestModel.on('success', function(response) {
        stopsResponseMapView.newResponse(response);
    });

    // create the main OTP trip plan request model and point it to the API
    var requestModel = new OTP.models.OtpPlanRequest();
    requestModel.urlRoot = OTP.config.otpApi + '/plan';

    // create and render the main request view, which displays the trip
    // preference form
    var requestView = new OTP.request_views.OtpRequestFormView({
        model: requestModel,
        el: $('#request')
    });
    requestView.render();

    // create and render the request map view, which handles the map-specific
    // trip request elements( e.g. the start and end markers)
    var requestMapView = new OTP.map_views.OtpRequestMapView({
    	model: requestModel,
    	map: map
    });
    requestMapView.render();

    // create the main response view, which refreshes the trip narrative display
    // and map elements as the underlying OTP response changes
    var responseView = new OTP.views.OtpPlanResponseView({
        narrative: $('#narrative'),
        map: map,
        topo: topoControl.getGraphElement()
    });

    // instruct the response view to listen to relevant request model events
    requestModel.on('success', function(response) {
        responseView.newResponse(response); 
    });
    requestModel.on('failure', function(response) {
        responseView.newResponse(false); 
    });

    requestModel.request();



    var Router = Backbone.Router.extend({
      routes: {
        'plan(?*querystring)': 'plan'
      },
      plan: function (querystring) {
        requestModel.fromQueryString(querystring);
      }
    });

    router = new Router();
    Backbone.history.start();

    requestModel.on('change', function() {
        router.navigate('plan' + requestModel.toQueryString());
    });

    // make the UI responsive to resizing of the containing window
    var resize = function() {
        var height = $(window).height() - 30;
        $('#map').height(height);
        $('#sidebar').height(height);
        map.invalidateSize();
    };
    $(window).resize(resize);
    resize.call();
});