From ec88003c30a590ba91327e390485026313e2db23 Mon Sep 17 00:00:00 2001
From: j <0x006A@0x2620.org>
Date: Mon, 4 Mar 2013 12:00:00 +0000
Subject: [PATCH] add anchors to api
---
static/js/pandora/apiDialog.js | 39 ++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/static/js/pandora/apiDialog.js b/static/js/pandora/apiDialog.js
index 83b44725..11bfcc66 100644
--- a/static/js/pandora/apiDialog.js
+++ b/static/js/pandora/apiDialog.js
@@ -3,7 +3,9 @@
pandora.ui.apiDialog = function() {
- var actions,
+ var selected = pandora.user.ui.hash && pandora.user.ui.hash.anchor
+ ? pandora.user.ui.hash.anchor : '',
+ actions,
$loading = Ox.Element()
.append(
$('')
@@ -40,31 +42,37 @@ pandora.ui.apiDialog = function() {
maximizeButton: true,
minHeight: 256,
minWidth: 576,
+ removeOnClose: true,
title: 'API Documentation',
width: Math.round(window.innerWidth * 0.75)
})
.bindEvent({
close: function() {
- pandora.UI.set({page: ''});
+ pandora.UI.set({page: '', 'hash.anchor': ''});
},
resize: function() {
$list.size();
+ },
+ 'pandora_hash.anchor': function(data) {
+ pandora.user.ui.page == 'api' && that.select(data.value);
}
}),
overview = '
';
pandora.api.api({docs: true, code: true}, function(results) {
- var items = [];
+ var items = [{
+ id: '',
+ title: pandora.site.site.name + ' API',
+ sort: 'aaa'
+ }];
actions = results.data.actions;
Ox.forEach(results.data.actions, function(v, k) {
items.push({
'id': k,
- 'title': k
+ 'title': k,
+ 'sort': k
});
});
- items.sort(function (a, b) {
- return a.name > b.name ? 1 : a.name == b.name ? 0 : -1;
- });
$list = Ox.TableList({
_tree: true,
@@ -80,11 +88,14 @@ pandora.ui.apiDialog = function() {
min: 1,
scrollbarVisible: true,
selected: [],
- sort: [{key: 'title', operator: '+'}],
+ sort: [{key: 'sort', operator: '+'}],
unique: 'id'
})
.bindEvent({
- select: selectSection
+ select: function(data) {
+ var id = data.ids[0];
+ pandora.UI.set({'hash.anchor': id});
+ }
});
$text = Ox.Element()
@@ -107,10 +118,9 @@ pandora.ui.apiDialog = function() {
});
- function selectSection(data) {
- if (data.ids.length) {
- $text.html('');
- data.ids.forEach(function(id) {
+ that.select = function(id) {
+ if (id) {
+ $text.html('');
$text.append(
$('')
.html(id)
@@ -148,11 +158,12 @@ pandora.ui.apiDialog = function() {
.css({
borderWidth: '1px',
}).appendTo($text).hide();
- });
} else {
$text.html(overview);
}
+ return that;
}
+
return that;
};