Fixed tree url handling

This commit is contained in:
Anton Dyudin 2015-03-25 13:40:07 -07:00
parent 7df2976304
commit 553f24970f
2 changed files with 34 additions and 32 deletions

View File

@ -35,7 +35,7 @@ module.exports = recl
dt = @ts - Number Date.now()
setPath: (href,hist) ->
if hist isnt false then history.pushState {}, "", "/docs/tree"+href
if hist isnt false then history.pushState {}, "", window.tree.basepath href
TreeActions.setCurr href
goTo: (path) ->
@ -47,7 +47,7 @@ module.exports = recl
checkURL: ->
if @state.url isnt window.location.pathname
@setPath window.location.pathname.replace("/docs/tree",""),false
@setPath (window.tree.fragpath window.location.pathname),false
setTitle: ->
title = $('#cont h1').first().text()
@ -86,7 +86,7 @@ module.exports = recl
@goTo @state.next
$('body').on 'click', 'a', (e) =>
href = $(e.target).closest('a').attr 'href'
href = $(e.target).closest('a').attr('href')
if href[0] is "/"
e.preventDefault()
e.stopPropagation()
@ -103,14 +103,15 @@ module.exports = recl
render: ->
parts = []
if @state.pare
parts.push (div {id:"up"},(a {key:"arow-up",href:@state.pare,className:"arow-up"},""))
href = window.tree.basepath @state.pare
parts.push (div {id:"up"},(a {key:"arow-up",href:href,className:"arow-up"},""))
if @state.prev or @state.next
_parts = []
if @state.prev
href = window.tree.basepath @state.prev
href = window.tree.basepath window.tree.basepath @state.prev
_parts.push (a {key:"arow-prev",href:href,className:"arow-prev"},"")
if @state.next
href = window.tree.basepath @state.next
href = window.tree.basepath window.tree.basepath @state.next
_parts.push (a {key:"arow-next",href:href,className:"arow-next"},"")
parts.push (div {id:"sides"}, _parts)
@ -128,7 +129,8 @@ module.exports = recl
c = "active"
ci = k
k++
(div {className:c}, (a {key:i+"-a",href:up+"/"+i,onClick:@_click}, i))
href = window.tree.basepath up+"/"+i
(div {className:c}, (a {key:i+"-a",href:href,onClick:@_click}, i))
offset = 0
if ci > 0 then offset = 0
s = {marginTop:((ci*-24)-offset)+"px"}

View File

@ -1,4 +1,4 @@
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee":[function(require,module,exports){
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var TreeDispatcher, TreePersistence;
TreeDispatcher = require('../dispatcher/Dispatcher.coffee');
@ -72,7 +72,7 @@ module.exports = {
},{"../dispatcher/Dispatcher.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/dispatcher/Dispatcher.coffee","../persistence/TreePersistence.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/persistence/TreePersistence.coffee"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/AnchorComponent.coffee":[function(require,module,exports){
},{"../dispatcher/Dispatcher.coffee":7,"../persistence/TreePersistence.coffee":12}],2:[function(require,module,exports){
var TreeActions, TreeStore, a, div, recl, ref;
TreeStore = require('../stores/TreeStore.coffee');
@ -122,7 +122,7 @@ module.exports = recl({
},
setPath: function(href, hist) {
if (hist !== false) {
history.pushState({}, "", "/docs/tree" + href);
history.pushState({}, "", window.tree.basepath(href));
}
return TreeActions.setCurr(href);
},
@ -138,7 +138,7 @@ module.exports = recl({
},
checkURL: function() {
if (this.state.url !== window.location.pathname) {
return this.setPath(window.location.pathname.replace("/docs/tree", ""), false);
return this.setPath(window.tree.fragpath(window.location.pathname), false);
}
},
setTitle: function() {
@ -206,17 +206,18 @@ module.exports = recl({
var _parts, ci, curr, href, k, obj, offset, p, parts, s, sibs, up;
parts = [];
if (this.state.pare) {
href = window.tree.basepath(this.state.pare);
parts.push(div({
id: "up"
}, a({
key: "arow-up",
href: this.state.pare,
href: href,
className: "arow-up"
}, "")));
if (this.state.prev || this.state.next) {
_parts = [];
if (this.state.prev) {
href = window.tree.basepath(this.state.prev);
href = window.tree.basepath(window.tree.basepath(this.state.prev));
_parts.push(a({
key: "arow-prev",
href: href,
@ -224,7 +225,7 @@ module.exports = recl({
}, ""));
}
if (this.state.next) {
href = window.tree.basepath(this.state.next);
href = window.tree.basepath(window.tree.basepath(this.state.next));
_parts.push(a({
key: "arow-next",
href: href,
@ -252,11 +253,12 @@ module.exports = recl({
ci = k;
}
k++;
href = window.tree.basepath(up + "/" + i);
return div({
className: c
}, a({
key: i + "-a",
href: up + "/" + i,
href: href,
onClick: _this._click
}, i));
};
@ -291,7 +293,7 @@ module.exports = recl({
},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","../stores/TreeStore.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/BodyComponent.coffee":[function(require,module,exports){
},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":13}],3:[function(require,module,exports){
var TreeActions, TreeStore, div, input, load, recl, ref, textarea;
TreeStore = require('../stores/TreeStore.coffee');
@ -356,7 +358,7 @@ module.exports = recl({
},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","../stores/TreeStore.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee","./LoadComponent.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/LoadComponent.coffee"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/KidsComponent.coffee":[function(require,module,exports){
},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":13,"./LoadComponent.coffee":6}],4:[function(require,module,exports){
var TreeActions, TreeStore, a, div, hr, li, recl, ref, ul;
TreeStore = require('../stores/TreeStore.coffee');
@ -423,7 +425,7 @@ module.exports = recl({
},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","../stores/TreeStore.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/ListComponent.coffee":[function(require,module,exports){
},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":13}],5:[function(require,module,exports){
var TreeActions, TreeStore, a, div, h1, li, load, recl, ref, ul;
TreeStore = require('../stores/TreeStore.coffee');
@ -514,7 +516,7 @@ module.exports = recl({
},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","../stores/TreeStore.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee","./LoadComponent.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/LoadComponent.coffee"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/LoadComponent.coffee":[function(require,module,exports){
},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":13,"./LoadComponent.coffee":6}],6:[function(require,module,exports){
var div, input, recl, ref, textarea;
recl = React.createClass;
@ -552,7 +554,7 @@ module.exports = recl({
},{}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/dispatcher/Dispatcher.coffee":[function(require,module,exports){
},{}],7:[function(require,module,exports){
var Dispatcher;
Dispatcher = require('flux').Dispatcher;
@ -574,7 +576,7 @@ module.exports = _.extend(new Dispatcher(), {
},{"flux":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/node_modules/flux/index.js"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/main.coffee":[function(require,module,exports){
},{"flux":9}],8:[function(require,module,exports){
var rend;
rend = React.render;
@ -732,7 +734,7 @@ $(function() {
},{"./actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","./components/AnchorComponent.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/AnchorComponent.coffee","./components/BodyComponent.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/BodyComponent.coffee","./components/KidsComponent.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/KidsComponent.coffee","./components/ListComponent.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/components/ListComponent.coffee","./persistence/TreePersistence.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/persistence/TreePersistence.coffee"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/node_modules/flux/index.js":[function(require,module,exports){
},{"./actions/TreeActions.coffee":1,"./components/AnchorComponent.coffee":2,"./components/BodyComponent.coffee":3,"./components/KidsComponent.coffee":4,"./components/ListComponent.coffee":5,"./persistence/TreePersistence.coffee":12}],9:[function(require,module,exports){
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
@ -744,7 +746,7 @@ $(function() {
module.exports.Dispatcher = require('./lib/Dispatcher')
},{"./lib/Dispatcher":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/node_modules/flux/lib/Dispatcher.js"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/node_modules/flux/lib/Dispatcher.js":[function(require,module,exports){
},{"./lib/Dispatcher":10}],10:[function(require,module,exports){
/*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
@ -996,7 +998,7 @@ var _prefix = 'ID_';
module.exports = Dispatcher;
},{"./invariant":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/node_modules/flux/lib/invariant.js"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/node_modules/flux/lib/invariant.js":[function(require,module,exports){
},{"./invariant":11}],11:[function(require,module,exports){
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
@ -1051,7 +1053,7 @@ var invariant = function(condition, format, a, b, c, d, e, f) {
module.exports = invariant;
},{}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/persistence/TreePersistence.coffee":[function(require,module,exports){
},{}],12:[function(require,module,exports){
var TreeActions;
TreeActions = require('../actions/TreeActions.coffee');
@ -1073,7 +1075,7 @@ module.exports = {
},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee"}],"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee":[function(require,module,exports){
},{"../actions/TreeActions.coffee":1}],13:[function(require,module,exports){
var EventEmitter, MessageDispatcher, TreeStore, _cont, _curr, _load, _snip, _tree;
EventEmitter = require('events').EventEmitter;
@ -1284,7 +1286,7 @@ module.exports = TreeStore;
},{"../dispatcher/Dispatcher.coffee":"/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/dispatcher/Dispatcher.coffee","events":"/usr/local/lib/node_modules/watchify/node_modules/browserify/node_modules/events/events.js"}],"/usr/local/lib/node_modules/watchify/node_modules/browserify/node_modules/events/events.js":[function(require,module,exports){
},{"../dispatcher/Dispatcher.coffee":7,"events":14}],14:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@ -1344,10 +1346,8 @@ EventEmitter.prototype.emit = function(type) {
er = arguments[1];
if (er instanceof Error) {
throw er; // Unhandled 'error' event
} else {
throw TypeError('Uncaught, unspecified "error" event.');
}
return false;
throw TypeError('Uncaught, unspecified "error" event.');
}
}
@ -1589,4 +1589,4 @@ function isUndefined(arg) {
return arg === void 0;
}
},{}]},{},["/Users/galen/Documents/src/urbit-dev/urb/zod/docs/pub/tree/src/js/main.coffee"]);
},{}]},{},[8]);