var $hilighted,
$hilightedMenuItem,
optionDictionary = {},
names = [],
buildApiOffline,
initOffline,
offline = {},
API = {},
buildPage;
function loadScript(url, callback) {
//http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/
var script = document.createElement("script");
script.type = "text/javascript";
if (script.readyState){ //IE
script.onreadystatechange = function(){
if (script.readyState == "loaded" ||
script.readyState == "complete"){
script.onreadystatechange = null;
callback();
}
};
} else { //Others
script.onload = function() {
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
function toDot (id){
return id.replace(/[-]+/g,'.');
};
function escapeHTML(html) {
if (typeof html === 'string') {
html = html
.replace('\u25CF', '\\u25CF')
.replace(//g, '>');
}
return html;
}
function escapeSelector (name) {
return name.replace('<', '\\<').replace('>', '\\>');
}
function activateInternalLinks($parent) {
$('a[href^="#"]', $parent).each(function (i, anchor) {
$(anchor).click(function () {
gotoSection(anchor.href.split('#')[1], true);
return false;
});
});
}
/**
* Highligth a specific option by coloring it in the menu view and section view
*/
function hilight (id) {
var linkId, $el, $detailsWrap = $('#details-wrap');
$el = $('div.member#' + escapeSelector(id));
// clear old
if ($hilighted) {
$hilighted.removeClass('hilighted');
}
if ($hilightedMenuItem) {
$hilightedMenuItem.removeClass('hilighted');
}
if ($el.length === 0) {
$detailsWrap.scrollTop(0);
} else {
// hilight new
$hilighted = $el;
$hilighted.addClass('hilighted');
$detailsWrap.scrollTop($hilighted.offset().top + $detailsWrap.scrollTop() - 160);
}
linkId = id.replace(/[^a-z0-9<>\\]+/gi,'.');
$hilightedMenuItem = $('a[href="#'+ linkId +'"]').not('.plus');
$hilightedMenuItem.addClass('hilighted');
}
/**
* Expand and load children when necessary of current level
*/
function toggleExpand($elem, callback) {
var $_menu = $elem.find('div[id$="-menu"]').first(),
_id = $_menu.attr('id').replace("-menu",""),
displayChildrenCallback = function () {
$('.dots', $elem).removeClass('loading');
$elem.removeClass("collapsed");
$elem.addClass("expanded");
$_menu.slideDown();
// show relevant section
if (/[A-Z]/.test(_id[0])) {
_id = 'object-' + _id;
}
toggleSection(_id);
if (callback) {
callback();
}
};
if ($elem.hasClass('collapsed')) {
/* if not loaded, load children, standard we have three children */
if ($_menu.children().size() == 1) {
$('.dots', $elem).addClass('loading');
loadChildren(_id, false, displayChildrenCallback);
} else {
displayChildrenCallback();
}
} else {
// hide children
$_menu.slideUp('normal',function(){
$elem.removeClass("expanded");
$elem.addClass("collapsed");
});
}
};
function toggleSection(sectionId) {
$section = $("#details > div.section:visible");
// hide current section
if($section){
$section.hide();
}
if (/[^\\]', '\\>');
}
$('#details > div.section#' + sectionId).show();
}
function addSectionOption(val){
$section = $('
').appendTo('#details');
$('' + val.fullname.replace('<', '<').replace('>', '>') + '
'
+ (val.description ? '' + val.description + '
': '')
+ (val.demo ? 'Try it:
' + val.demo + '': '' )).appendTo($section);
activateInternalLinks($section);
$(document).triggerHandler({ type:"xtra.btn.section.event",id: optionDictionary[val.fullname], table: 'option' });
}
function addSectionObject(val){
$section = $('').appendTo('#details');
$('' + val.title + '
').appendTo($section);
$('' + val.description + '
').appendTo($section);
activateInternalLinks($section);
$(document).triggerHandler({ type:"xtra.btn.section.event",id: 'object-'+ val.name, table: 'object'});
}
function markupReturnType(s) {
s = s.replace(/[<>]/g, function (a) {
return {
'<': '<',
'>': '>'
}[a];
});
s = s.replace(/(Axis|Chart|Element|Highcharts|Point|Renderer|Series)/g, '$1');
return s;
}
function loadOptionMemberInSection(obj, isParent){
//add member to section in div#details
var $_section = $('div#' + obj.parent.replace('<', '\\<').replace('>', '\\>') + '.section'),
$_inheritedLink,
$memberDiv,
contextClass = obj.description && obj.description.indexOf('') > -1 ? '' : ' context';
$memberDiv = $('
' + obj.title + ''
+ (obj.returnType ? '
: ' + markupReturnType(obj.returnType) + '' : '')
+ (obj.deprecated ? '
' : '' )
+ (obj.since ? '
Since ' + obj.since + '
' : '' )
+ (obj.description ? '
' + obj.description
+ (obj.defaults ? ' Defaults to ' + escapeHTML(obj.defaults) + '
.' : '')
+ '
' : '')
+ (obj.context ? '
The this
keyword refers to the '+ markupReturnType(obj.context) +' object.
' : '')
+ (obj.demo ? '
Try it:
' + obj.demo + '': '' )
+ (obj.seeAlso ? '
See also: ' + obj.seeAlso + '
': '' )
+ '
').appendTo($_section);
activateInternalLinks($memberDiv);
if (isParent) {
$('div#' + escapeSelector(obj.name) + '.member span.title').html(function() {
var title = $.trim($(this).text());
return $('' + title + '').click(function(){
gotoSection(obj.fullname, true);
});
});
}
}
function loadObjectMemberInSection(obj) {
$memberDiv = $(''
+ '
' + obj.title + ' '
+ (obj.params ? '
' + obj.params + '' : '')
+ (obj.since ? '
Since ' + obj.since + '
' : '' )
+ (obj.deprecated ? '
' : '' )
+ '
' + obj.description + '
'
+ (obj.paramsDescription ? '
Parameters
- ' +
obj.paramsDescription.replace(/\|\|/g,'
- ') + '
' : '')
+ (obj.returnType ? '
Returns
- ' + markupReturnType(obj.returnType) + '
' : '')
+ '
'
+ (obj.demo ? '
Try it:
' + obj.demo + '': '' )
+ '
').appendTo('div#object-' + obj.parent + '.section');
activateInternalLinks($memberDiv);
}
function loadChildren(name, silent, callback) {
var isObject = /[A-Z]/.test(name[0]),
url = isObject ?
'object/'+ PRODUCTNAME + '-obj/child/' + name :
'option/'+ PRODUCTNAME + '/child/' + name;
$.ajax({
type: "GET",
url: url,
dataType: "json",
error: function () {
var $menu;
$menu = $('div#' + escapeSelector(name) + '-menu');
$('.dots', $menu.parent()).removeClass('loading').addClass('error').html('Error');
},
success: function (data) {
var display = 'block',
display, $menu, $menuItem;
if (silent){
display = 'none';
}
name = name.replace('<', '\\<').replace('>', '\\>');
$menu = $('div#' + name + '-menu');
$.each(data, function (key, val) {
var $div = $('').appendTo($menu), $plus, $menuLink, parts,
tie, dottedName, internalName,
name,
title,
defaults,
cls;
/*if (val.type === 'method') {
name = val.name.replace('--', '.') + '()';
} else if (val.type === 'property') {
name = val.name.replace('--', '.');
} else {
name = val.fullname;
}*/
name = val.fullname;
if (val.isParent) {
var preBracket = '{',
postBracket = '}';
if (val.returnType && val.returnType.indexOf('Array') === 0 ) {
preBracket = '[{';
postBracket = '}]';
}
$menuItem = $('');
$menuLink = $('' + val.title + '').appendTo($menuItem);
$menuLink.click(function(){
gotoSection(val.fullname, true);
});
$plus = $('').appendTo($menuItem);
$plus.click(function () {
toggleExpand($plus.parent());
});
$menuItem.append(': '+ preBracket +'…');
// add empty submenu
$subMenu = $('