PageSourceSearch

https://www.ipcc.ch/site/assets/themes/ipcc/resources/bower_components/pe-nav-overlay/nav-overlay.js

js ipcc.ch collected 2026-10-01 06:51:36 UTC 3,143 bytes, 151 lines download raw bytes

1// nav overlay
2// v1.0
3
4(function ($) {
5  
6  // custom select class
7
8  function nav_overlay(item, options) {
9
10    this.item = $(item);
11    
12    // options
13  
14    var defaults = {
15      elements: {
16        overlay: $('#nav-overlay'),
17        trigger: $('#nav-overlay-trigger'),
18        close_btn: $('#nav-overlay-close')
19      },
20      open_fn: null,
21      close_fn: null,
22      logging: false
23    };
24    
25    this.options = $.extend(true, defaults, options);
26    this.init();
27  }
28
29  nav_overlay.prototype = {
30
31    // init
32
33    init: function () {
34
35      var plugin_instance = this;
36      var plugin_settings = plugin_instance.options;
37      var plugin_elements = plugin_settings.elements;
38      
39      if (plugin_settings.logging == true) {
40        console.log('nav overlay init');
41      }
42      
43      //
44      // ELEMENTS
45      //
46      
47      
48      //
49      // ACTIONS
50      //
51      
52      plugin_elements.trigger.click(function(e) {
53        e.preventDefault();
54        
55        if ($('body').hasClass('nav-overlay-open')) {
56          plugin_instance.hide_overlay();
57        } else {
58          plugin_instance.show_overlay();
59        }
60      });
61      
62      plugin_elements.close_btn.click(function(e) {
63        e.preventDefault();
64        plugin_instance.hide_overlay();
65      });
66      
67      // 'esc' key
68      
69      $('body').keypress(function(e) {
70        if ($('body').hasClass('nav-overlay-open') && e.which == 27){
71          plugin_instance.hide_overlay();
72        }
73      });
74      
75    },
76    
77    show_overlay: function(fn_options) {
78
79      var plugin_instance = this;
80      var plugin_item = this.item;
81      var plugin_settings = plugin_instance.options;
82      var plugin_elements = plugin_settings.elements;
83      
84      // options
85
86      var defaults = {
87
88      };
89
90      var settings = $.extend(true, defaults, fn_options);
91      
92      $('body').addClass('nav-overlay-open');
93      
94      if (typeof(plugin_settings.open_fn) == 'function') {
95        plugin_settings.open_fn.call(this);
96      }
97      
98    },
99    
100    hide_overlay: function(fn_options) {
101
102      var plugin_instance = this;
103      var plugin_item = this.item;
104      var plugin_settings = plugin_instance.options;
105      var plugin_elements = plugin_settings.elements;
106      
107      // options
108
109      var defaults = {
110
111      };
112
113      var settings = $.extend(true, defaults, fn_options);
114      
115      $('body').removeClass('nav-overlay-open');
116      
117      if (typeof(plugin_settings.close_fn) == 'function') {
118        plugin_settings.close_fn.call(this);
119      }
120      
121    }
122    
123  }
124
125  // jQuery plugin interface
126
127  $.fn.nav_overlay = function (opt) {
128    var args = Array.prototype.slice.call(arguments, 1);
129
130    return this.each(function () {
131
132      var item = $(this);
133      var instance = item.data('nav_overlay');
134
135      if (!instance) {
136
137        // create plugin instance if not created
138        item.data('nav_overlay', new nav_overlay(this, opt));
139
140      } else {
141
142        // otherwise check arguments for method call
143        if (typeof opt === 'string') {
144          instance[opt].apply(instance, args);
145        }
146
147      }
148    });
149  }
150
151}(jQuery));

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.