(function() {
var hasProp = {}.hasOwnProperty;
(function() {
var MAIN_UL, createSubNavItems, docsMap, getTitle, pageUrl;
MAIN_UL = $('#terraform-docs');
docsMap = {};
pageUrl = PAGE_URL;
getTitle = function(raw) {
if (/\:\s/.test(raw)) {
return raw.split(': ').pop();
} else {
return raw;
}
};
createSubNavItems = function(doc, parent, prop) {
var i, index, isActive, key, len, sortedKeys, ul, value;
if (index = doc.index) {
isActive = pageUrl === index.url;
parent.append("
" + (getTitle(index.title)) + "");
} else if (prop === 'd') {
parent.append("Data Sources");
} else if (prop === 'r') {
parent.append("Resources");
}
if (doc.title) {
if (!/index\.html\/?/.test(doc.url)) {
isActive = pageUrl === doc.url;
parent.append("" + (getTitle(doc.title)) + "");
}
} else {
ul = $('');
sortedKeys = ((function() {
var results;
results = [];
for (key in doc) {
if (!hasProp.call(doc, key)) continue;
value = doc[key];
results.push(key);
}
return results;
})()).sort();
for (i = 0, len = sortedKeys.length; i < len; i++) {
key = sortedKeys[i];
createSubNavItems(doc[key], ul, key);
}
parent.find('li').last().append(ul);
}
return ul;
};
if (!TERRAFORM_DOCS) {
return;
}
TERRAFORM_DOCS.forEach(function(doc) {
var id, path;
id = doc.url.replace('/docs/terraform/', '').split('/');
id.pop();
path = id.join('.');
path = path.replace(/\.html?/, '');
return lodash_set(docsMap, path, doc);
});
docsMap.index.title = 'Stack Documentation';
window.TERRAFORM_DOCS_MAP = docsMap;
createSubNavItems(docsMap, MAIN_UL);
if (pageUrl === '/docs/home') {
$('aside li ul ul ul').hide();
} else {
$('aside li ul').hide();
}
$('li.active > ul').show();
$('li.active > ul > li.separator > ul').show();
$('li.active').parents('ul').show();
return $('li a[href="#"]').on('click', function(event) {
event.preventDefault();
return $(this).parent().find('> ul').show();
});
})();
}).call(this);