diff options
Diffstat (limited to 'bootstrap/comments/admin/admin.js')
-rw-r--r-- | bootstrap/comments/admin/admin.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bootstrap/comments/admin/admin.js b/bootstrap/comments/admin/admin.js new file mode 100644 index 0000000..046735b --- /dev/null +++ b/bootstrap/comments/admin/admin.js @@ -0,0 +1,41 @@ +// Wait for the page HTML to be parsed +document.addEventListener ('DOMContentLoaded', function () { + // Get view links + var viewLinks = document.getElementsByClassName ('view-link'); + + // Get content frame + var content = document.getElementById ('content'); + + // Execute a given function for each view link + function eachViewLink (callback) + { + for (var i = 0, il = viewLinks.length; i < il; i++) { + callback (viewLinks[i]); + } + } + + // Remove active class from all view links + function clearViewTabs () + { + eachViewLink (function (link) { + link.className = 'view-link'; + }); + } + + // Automatically select the proper view tab on page load + content.onload = function () + { + // Remove active class from all view links + clearViewTabs (); + + // Select active proper tab for currently loaded view + eachViewLink (function (link) { + var regex = new RegExp (link.getAttribute ('href')); + var frameUrl = content.contentDocument.location.href; + + if (regex.test (decodeURIComponent (frameUrl))) { + link.className += ' active'; + } + }); + }; +}, false); |