Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
| Download
Sage Reference Manual
Project: SageManifolds
Views: 717109/*1* doctools.js2* ~~~~~~~~~~~3*4* Sphinx JavaScript utilities for all documentation.5*6* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.7* :license: BSD, see LICENSE for details.8*9*/1011/**12* select a different prefix for underscore13*/14$u = _.noConflict();1516/**17* make the code below compatible with browsers without18* an installed firebug like debugger19if (!window.console || !console.firebug) {20var names = ["log", "debug", "info", "warn", "error", "assert", "dir",21"dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",22"profile", "profileEnd"];23window.console = {};24for (var i = 0; i < names.length; ++i)25window.console[names[i]] = function() {};26}27*/2829/**30* small helper function to urldecode strings31*/32jQuery.urldecode = function(x) {33return decodeURIComponent(x).replace(/\+/g, ' ');34};3536/**37* small helper function to urlencode strings38*/39jQuery.urlencode = encodeURIComponent;4041/**42* This function returns the parsed url parameters of the43* current request. Multiple values per key are supported,44* it will always return arrays of strings for the value parts.45*/46jQuery.getQueryParameters = function(s) {47if (typeof s == 'undefined')48s = document.location.search;49var parts = s.substr(s.indexOf('?') + 1).split('&');50var result = {};51for (var i = 0; i < parts.length; i++) {52var tmp = parts[i].split('=', 2);53var key = jQuery.urldecode(tmp[0]);54var value = jQuery.urldecode(tmp[1]);55if (key in result)56result[key].push(value);57else58result[key] = [value];59}60return result;61};6263/**64* highlight a given string on a jquery object by wrapping it in65* span elements with the given class name.66*/67jQuery.fn.highlightText = function(text, className) {68function highlight(node) {69if (node.nodeType == 3) {70var val = node.nodeValue;71var pos = val.toLowerCase().indexOf(text);72if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {73var span = document.createElement("span");74span.className = className;75span.appendChild(document.createTextNode(val.substr(pos, text.length)));76node.parentNode.insertBefore(span, node.parentNode.insertBefore(77document.createTextNode(val.substr(pos + text.length)),78node.nextSibling));79node.nodeValue = val.substr(0, pos);80}81}82else if (!jQuery(node).is("button, select, textarea")) {83jQuery.each(node.childNodes, function() {84highlight(this);85});86}87}88return this.each(function() {89highlight(this);90});91};9293/**94* Small JavaScript module for the documentation.95*/96var Documentation = {9798init : function() {99this.fixFirefoxAnchorBug();100this.highlightSearchWords();101this.initIndexTable();102},103104/**105* i18n support106*/107TRANSLATIONS : {},108PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },109LOCALE : 'unknown',110111// gettext and ngettext don't access this so that the functions112// can safely bound to a different name (_ = Documentation.gettext)113gettext : function(string) {114var translated = Documentation.TRANSLATIONS[string];115if (typeof translated == 'undefined')116return string;117return (typeof translated == 'string') ? translated : translated[0];118},119120ngettext : function(singular, plural, n) {121var translated = Documentation.TRANSLATIONS[singular];122if (typeof translated == 'undefined')123return (n == 1) ? singular : plural;124return translated[Documentation.PLURALEXPR(n)];125},126127addTranslations : function(catalog) {128for (var key in catalog.messages)129this.TRANSLATIONS[key] = catalog.messages[key];130this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');131this.LOCALE = catalog.locale;132},133134/**135* add context elements like header anchor links136*/137addContextElements : function() {138$('div[id] > :header:first').each(function() {139$('<a class="headerlink">\u00B6</a>').140attr('href', '#' + this.id).141attr('title', _('Permalink to this headline')).142appendTo(this);143});144$('dt[id]').each(function() {145$('<a class="headerlink">\u00B6</a>').146attr('href', '#' + this.id).147attr('title', _('Permalink to this definition')).148appendTo(this);149});150},151152/**153* workaround a firefox stupidity154*/155fixFirefoxAnchorBug : function() {156if (document.location.hash && $.browser.mozilla)157window.setTimeout(function() {158document.location.href += '';159}, 10);160},161162/**163* highlight the search words provided in the url in the text164*/165highlightSearchWords : function() {166var params = $.getQueryParameters();167var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];168if (terms.length) {169var body = $('div.body');170if (!body.length) {171body = $('body');172}173window.setTimeout(function() {174$.each(terms, function() {175body.highlightText(this.toLowerCase(), 'highlighted');176});177}, 10);178$('<p class="highlight-link"><a href="javascript:Documentation.' +179'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')180.appendTo($('#searchbox'));181}182},183184/**185* init the domain index toggle buttons186*/187initIndexTable : function() {188var togglers = $('img.toggler').click(function() {189var src = $(this).attr('src');190var idnum = $(this).attr('id').substr(7);191$('tr.cg-' + idnum).toggle();192if (src.substr(-9) == 'minus.png')193$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');194else195$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');196}).css('display', '');197if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {198togglers.click();199}200},201202/**203* helper function to hide the search marks again204*/205hideSearchWords : function() {206$('#searchbox .highlight-link').fadeOut(300);207$('span.highlighted').removeClass('highlighted');208},209210/**211* make the url absolute212*/213makeURL : function(relativeURL) {214return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;215},216217/**218* get the current relative url219*/220getCurrentURL : function() {221var path = document.location.pathname;222var parts = path.split(/\//);223$.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {224if (this == '..')225parts.pop();226});227var url = parts.join('/');228return path.substring(url.lastIndexOf('/') + 1, path.length - 1);229}230};231232// quick alias for translations233_ = Documentation.gettext;234235$(document).ready(function() {236Documentation.init();237});238239240