locales: './locales/locale',
lodash: './vendor/lodash.custom.min',
pathToRegexp: './vendor/path-to-regexp/index',
- prettify: './vendor/prettify/prettify',
+ prismjs: './vendor/prism',
semver: './vendor/semver.min',
utilsSampleRequest: './utils/send_sample_request',
webfontloader: './vendor/webfontloader',
- list: './vendor/list.min'
+ list: './vendor/list.min',
+ apiData: './api_data',
+ apiProject: './api_project',
},
shim: {
bootstrap: {
deps: ['jquery', 'handlebars'],
exports: 'Handlebars'
},
- prettify: {
- exports: 'prettyPrint'
- }
+ prismjs: {
+ exports: 'Prism'
+ },
},
urlArgs: 'v=' + (new Date()).getTime(),
- waitSeconds: 15
+ waitSeconds: 150
});
require([
'lodash',
'locales',
'handlebarsExtended',
- './api_project.js',
- './api_data.js',
- 'prettify',
+ 'apiProject',
+ 'apiData',
+ 'prismjs',
'utilsSampleRequest',
'semver',
'webfontloader',
'bootstrap',
'pathToRegexp',
'list'
-], function($, _, locale, Handlebars, apiProject, apiData, prettyPrint, sampleRequest, semver, WebFont) {
+], function($, _, locale, Handlebars, apiProject, apiData, Prism, sampleRequest, semver, WebFont) {
- // load google web fonts
- loadGoogleFontCss();
+ // Load google web fonts.
+ WebFont.load({
+ active: function() {
+ // Only init after fonts are loaded.
+ init($, _, locale, Handlebars, apiProject, apiData, Prism, sampleRequest, semver);
+ },
+ inactive: function() {
+ // Run init, even if loading fonts fails
+ init($, _, locale, Handlebars, apiProject, apiData, Prism, sampleRequest, semver);
+ },
+ google: {
+ families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7']
+ }
+ });
+});
+function init($, _, locale, Handlebars, apiProject, apiData, Prism, sampleRequest, semver) {
var api = apiData.api;
//
$('#sections').append( content );
// Bootstrap Scrollspy
- $(this).scrollspy({ target: '#scrollingNav', offset: 18 });
+ $(this).scrollspy({ target: '#scrollingNav' });
// Content-Scroll on Navigation click.
$('.sidenav').find('a').on('click', function(e) {
window.location.hash = $(this).attr('href');
});
- // Quickjump on Pageload to hash position.
- if(window.location.hash) {
- var id = window.location.hash;
- if ($(id).length > 0)
- $('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 0);
- }
-
/**
* Check if Parameter (sub) List has a type Field.
* Example: @apiSuccess varname1 No type.
// init modules
sampleRequest.initDynamic();
+ Prism.highlightAll()
}
initDynamic();
}
}
- // Pre- / Code-Format
- prettyPrint();
-
//
// HTML-Template specific jQuery-Functions
//
// Change Main Version
- $('#versions li.version a').on('click', function(e) {
- e.preventDefault();
-
- var selectedVersion = $(this).html();
- $('#version strong').html(selectedVersion);
+ function setMainVersion(selectedVersion) {
+ if (typeof(selectedVersion) === 'undefined') {
+ selectedVersion = $('#version strong').html();
+ }
+ else {
+ $('#version strong').html(selectedVersion);
+ }
// hide all
$('article').addClass('hide');
initDynamic();
return;
+ }
+ setMainVersion();
+
+ $('#versions li.version a').on('click', function(e) {
+ e.preventDefault();
+
+ setMainVersion($(this).html());
});
// compare all article with their predecessor
if ($.urlParam('compare')) {
// URL Paramter ?compare=1 is set
$('#compareAllWithPredecessor').trigger('click');
+ }
- if (window.location.hash) {
- var id = window.location.hash;
- $('html,body').animate({ scrollTop: parseInt($(id).offset().top) - 18 }, 0);
- }
+ // Quick jump on page load to hash position.
+ // Should happen after setting the main version
+ // and after triggering the click on the compare button,
+ // as these actions modify the content
+ // and would make it jump to the wrong position or not jump at all.
+ if (window.location.hash) {
+ var id = window.location.hash;
+ if ($(id).length > 0)
+ $('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 0);
}
/**
}
/**
- * Load google fonts.
- */
- function loadGoogleFontCss() {
- WebFont.load({
- active: function() {
- // Update scrollspy
- $(window).scrollspy('refresh')
- },
- google: {
- families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7']
- }
- });
- }
-
- /**
* Return ordered entries by custom order and append not defined entries to the end.
* @param {String[]} elements
* @param {String[]} order
});
return results;
}
-
-});
+ Prism.highlightAll()
+}