aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl/default/js
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/default/js')
-rw-r--r--tpl/default/js/shaarli.js63
1 files changed, 33 insertions, 30 deletions
diff --git a/tpl/default/js/shaarli.js b/tpl/default/js/shaarli.js
index 24d11cdb..01e22022 100644
--- a/tpl/default/js/shaarli.js
+++ b/tpl/default/js/shaarli.js
@@ -138,27 +138,6 @@ if (newVersionDismiss != null) {
138 }); 138 });
139} 139}
140 140
141/**
142 * Login button
143 */
144var loginButton = document.getElementById('login-button');
145var loginBlock = document.getElementById('header-login-form');
146
147if (loginButton != null) {
148 loginButton.addEventListener('click', function(event) {
149 event.preventDefault();
150 loginBlock.classList.toggle('open');
151 document.getElementById('content').style.boxShadow = 'none';
152 });
153}
154
155// Focus on login field.
156if (loginBlock != null) {
157 loginBlock.addEventListener('transitionend', function () {
158 loginBlock.firstElementChild.focus();
159 });
160}
161
162var hiddenReturnurl = document.getElementsByName('returnurl'); 141var hiddenReturnurl = document.getElementsByName('returnurl');
163if (hiddenReturnurl != null) { 142if (hiddenReturnurl != null) {
164 hiddenReturnurl.value = window.location.href; 143 hiddenReturnurl.value = window.location.href;
@@ -173,15 +152,39 @@ if (autofocusElements != null) {
173} 152}
174 153
175/** 154/**
176 * Hide search bar, and display it on search click. 155 * Hide search bar
177 */ 156 */
178var searchBar = document.getElementById('search'); 157var search = document.getElementById('search');
179var searchButton = document.getElementById('search-button'); 158if (search != null) {
180if (searchBar != null && searchButton != null) { 159 removeClass(search, 'open');
181 searchBar.classList.toggle('closed'); 160}
182 searchButton.addEventListener('click', function(event) { 161
183 event.preventDefault(); 162/**
184 searchBar.classList.toggle('closed'); 163 * Handle sub menus/forms
185 searchBar.classList.toggle('open'); 164 */
165var openers = document.getElementsByClassName('subheader-opener');
166if (openers != null) {
167 console.log(openers);
168 [].forEach.call(openers, function(opener) {
169 opener.addEventListener('click', function(event) {
170 event.preventDefault();
171
172 var id = opener.getAttribute('data-open-id');
173 var sub = document.getElementById(id);
174
175 if (sub != null) {
176 [].forEach.call(document.getElementsByClassName('subheader-form'), function (element) {
177 if (element != sub) {
178 removeClass(element, 'open')
179 }
180 });
181
182 sub.classList.toggle('open');
183 }
184 });
186 }); 185 });
187} 186}
187
188function removeClass(element, classname) {
189 element.className = element.className.replace(new RegExp('(?:^|\\s)'+ classname + '(?:\\s|$)'), ' ');
190} \ No newline at end of file