Author: echatellier Date: 2014-07-02 17:53:40 +0200 (Wed, 02 Jul 2014) New Revision: 326 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/326 Log: Restore current tab using jquery Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-07-02 15:29:26 UTC (rev 325) +++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-07-02 15:53:40 UTC (rev 326) @@ -1224,3 +1224,34 @@ } }; }]); + + + + +function isLocalStorageAvailable() { + var result; + try { + result = 'localStorage' in window && window['localStorage'] !== null; + } catch (e) { + // can happen with IE 11 in desktop mode + result = false; + } + return result; +} + +$(function() { + if (isLocalStorageAvailable()) { + + // save tab hash in local storage + $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { + var hash = e.target.hash; + localStorage.setItem("configuration-tab", hash); + }); + + // restore tab if present + var current = localStorage.getItem("configuration-tab"); + if (current) { + $('#tabs a[href="' + current + '"]').tab('show'); + } + } +}) \ No newline at end of file
participants (1)
-
echatellier@users.forge.codelutin.com