PageSourceSearch

https://www.iusprivacy.eu/assets/js/ace/ace.onpage-help.js

js iusprivacy.eu collected 2026-09-26 07:52:11 UTC 5,752 bytes, 157 lines download raw bytes

1jQuery(function($) {
2	var help = null;//Onpage_Help instance
3
4	
5	//for ace demo pages, we temporarily disable fixed navbar, etc ... when help is enabled
6	//because when an element is fixed, its highlighted help section should also become fixed?!
7	var page_settings = {}
8	var before_enable_help = function() {
9		$('#btn-scroll-up').css('z-index', 1000000);//bring btn-scroll-up  higher , to be over our help area
10
11		//save our current state of navbar, sidebar and breadcrumbs before enabling help
12		page_settings['navbar'] = ace.settings.is('navbar', 'fixed')
13		page_settings['sidebar'] = ace.settings.is('sidebar', 'fixed')
14		page_settings['breadcrumbs'] = ace.settings.is('breadcrumbs', 'fixed')
15		
16		ace.settings.navbar_fixed(false , false);//now disable fixed navbar, which automatically disabled fixed sidebar and breadcrumbs
17	}
18	var after_disable_help = function() {
19		$('#btn-scroll-up').css('z-index', '');
20
21		//restore fixed state of navbar, sidebar, etc
22		if( page_settings['breadcrumbs'] ) ace.settings.breadcrumbs_fixed(true, false, false);
23		if( page_settings['sidebar'] ) ace.settings.sidebar_fixed(true, false, false);
24		if( page_settings['navbar'] ) ace.settings.navbar_fixed(true, false, false);
25	}
26	
27	var get_file_url = function(url, language) {
28		//function that return the real path to a file which is being loaded
29		return this.settings.base + '/' + url;
30	}
31	var get_section_url = function(section_name) {
32		//according to a section_name such as `basics/navbar.toggle` return the file url which contains help content
33		section_name = section_name || '';
34
35		//for example convert `basic/navbar.layout.brand` to `basic/navbar`
36		//because 'layout.brand' section is inside `basic/navbar.html` file
37		var url = section_name.replace(/\..*$/g, '');
38
39		var parts = url.split('/');
40		if(parts.length == 1) {
41			//for example convert `changes` to `changes/index.html`
42			if(url.length == 0) url = 'intro';//or convert `empty string` to `intro/index.html`
43			url = url + '/index.html';
44		}
45		else if(parts.length > 1) {
46			//for example convert `basics/navbar.layout` to `basics/navbar.html`
47			url = url + '.html';
48		}
49		return this.settings.base + '/docs/sections/' + url;
50	}
51	var get_img_url = function(src) {
52		return this.settings.base + '/docs/' +src;
53	}
54
55	/**
56	var code_highlight = function(e, language) {
57		//'this' refers to 'Onpage_Help' object invoking this function
58		if(typeof e === 'string') {
59			if(typeof language === 'string') {
60				//called when a file (html,css,etc) is loaded
61				//'e' is a piece of code
62				//maybe highlight the syntax it according to `language` and return result
63			}
64			else {
65				//called before new help content is being displayed
66				//'e' is a string which may contain <pre>...</pre> code sections
67				//which you may want to highlight the code, or for example convert them < to &lt; and > to &gt;
68				//and return the result
69			}
70		}
71		else if(typeof e === 'object') {
72			//called when new help content is displayed
73			//'e' is an html element which may have "pre" children that you can syntax-highlight
74		}
75	}
76	*/
77
78
79	function startHelp() {
80		if(help !== null) return;//already created?
81
82		help = new Onpage_Help({
83			'include_all': false,
84			'base': ace.vars['base'] || '../..',
85			'file_url': get_file_url,
86			'section_url': get_section_url,
87			
88			'img_url': get_img_url,
89			
90			'before_enable': before_enable_help,
91			'after_disable': after_disable_help
92			
93			//,'code_highlight': code_highlight
94		})
95
96		
97		
98		var help_container = $('#onpage-help-container');
99		//add a custom button to enable/disable help
100		help_container.append('<div class="ace-settings-container onpage-help-toggle-container">\
101			<div id="onpage-help-toggle-btn" class="btn btn-app btn-xs btn-info ace-settings-btn onpage-help-toggle-btn">\
102				<i class="onpage-help-toggle-text ace-icon fa fa-question bigger-150"></i>\
103			</div>\
104		</div>');
105
106		$('#onpage-help-toggle-btn').on('click', function(e) {
107			e.preventDefault();
108			toggleHelp();
109		})
110		
111		//add .container class to help container div when our content is put inside a ".container"
112		$(document).on('settings.ace.help', function(ev, event_name, fixed) {
113		   if(event_name == 'main_container_fixed') {
114			  if(fixed) help_container.addClass('container');
115			  else help_container.removeClass('container');
116		   }
117		}).triggerHandler('settings.ace.help', ['main_container_fixed', $('.main-container').hasClass('container')])
118		
119		//in ajax mode when a content is loaded via ajax, we may want to update help sections
120		$(document).on('ajaxloadcomplete.ace.help', function() {
121			help.update_sections();
122		});
123	}
124	
125	function toggleHelp() {
126		help.toggle();
127		
128		var toggle_btn = $('#onpage-help-toggle-btn');
129		toggle_btn.find('.onpage-help-toggle-text').removeClass('onpage-help-toggle-text');
130		toggle_btn.toggleClass('btn-grey btn-info').parent().toggleClass('active');
131	}
132
133
134	$(window).on('hashchange.start_help', function(e) {
135		if(help == null && window.location.hash == '#help') {
136			startHelp();
137
138			//add #help tag to sidebar links to enable help when navigating to the page
139			$(document).on('click.start_help', '.sidebar .nav-list a', function() {
140				var href = $(this).attr('href');
141				if( !href.match(/\#help$/) ) $(this).attr('href', href+'#help');
142			});
143		}
144	}).triggerHandler('hashchange.start_help');
145
146
147	//some buttons inside demo pages that launch a help section
148	$(document).on('click', '.btn-display-help', function(e) {
149		e.preventDefault();
150
151		startHelp();
152		if( !help.is_active() ) toggleHelp();
153
154		var section = $(this).attr('href');
155		help.show_section_help(section);
156	});
157});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.