/** Onpage Help. You can use this to provide help dialogs on your application pages. See docs for more info. */ window.Onpage_Help = function(options) { var $ = window.jQuery || null; if($ == null) return; options = options || {} var defaults = { include_all: true, icon_1: 'fa fa-question', icon_2: 'fa fa-lightbulb-o', base: '', code_highlight: (!!window.Rainbow ? 'rainbow' : (!!window.Prism ? 'prism' : null)), add_panels: true, panel_content_selector: '.info-section', panel_content_title: '.info-title' } this.settings = $.extend({}, defaults, options); var $base = this.settings['base']; var ie_fix = document.all && !window.atob;//ie9 and below need a little fix var section_start = {}; var section_end = {}; var section_rect = {}; var section_count = 0; var created = false; var active = false; var self = this, _ = this; var ovfx = ''; var help_container = null; var body_h, body_w; var captureFocus = function() { if(!help_container) return; var scroll = -1; //like bootstrap modal $(document) .off('focusin.ace.help') //remove any previously attached handler .on('focusin.ace.help', function (e) { if (!( help_container[0] == e.target || $.contains(help_container[0], e.target) )) { help_container.focus(); } if(e.target == document && scroll > -1) { //when window regains focus and container is focused, it scrolls to bottom //so we put it back to its place $('body,html').scrollTop(scroll); scroll = -1; } }) $(window).on('blur.ace.help', function(){ scroll = $(window).scrollTop(); }); } var releaseFocus = function() { $(document).off('focusin.ace.help'); $(window).off('blur.ace.help'); } this.toggle = function() { if(active) { self.disable(); } else { self.enable(); } } this.enable = function() { if(active) return; if(typeof _.settings.before_enable === 'function' && _.settings.before_enable.call(self) === false) return; //// //if( !created ) this.init(); active = true; $('.onpage-help-backdrop, .onpage-help-section').removeClass('hidden'); ovfx = document.body.style.overflowX; document.body.style.overflowX = 'hidden';//hide body:overflow-x display_help_sections(); captureFocus(); //// if(typeof _.settings.after_enable === 'function') _.settings.after_enable.call(self); } this.disable = function() { if(!active) return; if(typeof _.settings.before_disable === 'function' && _.settings.before_disable.call(self)) return; //// active = false; $('.onpage-help-backdrop, .onpage-help-section').addClass('hidden'); document.body.style.overflowX = ovfx;//restore body:overflow-x releaseFocus(); //// if(typeof _.settings.after_disable === 'function') _.settings.after_disable.call(self); } this.is_active = function() { return active; } this.show_section_help = function(section) { launch_help_modal(section, true); } this.init = function() { if( created ) return; help_container = $('
') .appendTo('body'); help_container.append('