diff --git a/ScratchWikiSkin.php b/ScratchWikiSkin.php index b9850d4..f1d61de 100644 --- a/ScratchWikiSkin.php +++ b/ScratchWikiSkin.php @@ -19,14 +19,19 @@ class SkinScratchWikiSkin extends SkinTemplate{ $template = 'ScratchWikiSkinTemplate'; function initPage(OutputPage $out) { - parent::initpage($out); + + + parent::initPage( $out ); + + } function setupSkinUserCss(OutputPage $out) { + global $wgLocalStylePath; parent::setupSkinUserCss($out); $out->addStyle('scratchwikiskin/main.css', 'screen'); - $out->addHeadItem('skinscript', "<script type='text/javascript' src='../skins/scratchwikiskin/skin.js'></script>"); + $out->addHeadItem('skinscript', "<script type='text/javascript' src='$wgLocalStylePath/scratchwikiskin/skin.js'></script>"); } } @@ -62,6 +67,7 @@ class ScratchWikiSkinTemplate extends BaseTemplate{ <!-- user links --> <?php if (!$wgUser->isLoggedIn()) { ?> + <!--<li class = last><a href=" Special:Userlogin">Log in to the Wiki</a></li>--> <li class = last><a href="<?php if (isset($this->data['personal_urls']['anonlogin'])){echo $this->data['personal_urls']['anonlogin']['href'];}else{echo $this->data['personal_urls']['login']['href'];}?>">Log in to the Wiki</a></li> <?php } else { ?> <li id=userfcttoggle class="user-name dropdown-toggle"><a><?=htmlspecialchars($wgUser->mName)?></a></li> diff --git a/main.css b/main.css index 3425fa7..32213e9 100644 --- a/main.css +++ b/main.css @@ -18,7 +18,7 @@ header { -moz-box-shadow: 0 1px 1px #ccc; -o-box-shadow: 0 1px 1px #ccc; box-shadow: 0 1px 1px #ccc; - z-index: 1; + z-index: 3; } @@ -268,7 +268,7 @@ opacity: .8; overflow: hidden; border-radius: 5px; border-top-right-radius: 0; - box-shadow: 0px 0px 5px #888a85; + box-shadow: 0px 1px 1px #888a85; } .dropdownmenu li { float: none; @@ -313,7 +313,7 @@ opacity: .8; } #pagefctdropdown{ - margin-left: 554px; //temporary solution + margin-left: 555px; //temporary solution } #pagefctdropdown li a { color: #888; diff --git a/skin.js b/skin.js index 40108db..ce4aa95 100644 --- a/skin.js +++ b/skin.js @@ -4,17 +4,29 @@ Scratch Wiki Skin script */ +//get the element from an id, with functions to write, add, show, hide, addclass, delclass function el(id) { var h = document.getElementById(id); + + //if no element exists with that id, return null + if(!h){ + return h; + } + h.write = function(o) {this.innerHTML = o;}; h.add = function(o) {this.innerHTML += o;}; h.show = function(o) {this.style.display = 'block';}; h.hide = function(o) {this.style.display = 'none';}; h.addclass = function(c) {this.className+=' '+c;this.className=this.className.trim();}; h.delclass = function(c) {this.className=this.className.replace(c,'').replace(' ',' ').trim();}; + return h; } + + window.onload = function() { + + //when pencil icon clicked, display dropdown el('pagefctbtn').onclick = function() { if (el('pagefctdropdown').style.display!='block') { el('pagefctbtn').addclass('open'); @@ -24,6 +36,8 @@ window.onload = function() { el('pagefctdropdown').hide(); } } + + //when mouse moved away, hide dropdown el('pagefctdropdown').onmouseout = function(e) { if (!e) var e = window.event; if (!e.toElement) e.toElement = e.relatedTarget; @@ -32,23 +46,36 @@ window.onload = function() { el('pagefctdropdown').hide(); } } - el('userfcttoggle').onclick = function() { - if (el('userfctdropdown').style.display!='block') { - el('userfcttoggle').addclass('open'); - el('userfctdropdown').show(); - } else { - el('userfcttoggle').delclass('open'); - el('userfctdropdown').hide(); - } - } - el('userfctdropdown').onmouseout = function(e) { - if (!e) var e = window.event; - if (!e.toElement) e.toElement = e.relatedTarget; - if (' ul li img a'.indexOf(e.toElement.tagName.toLowerCase())<0) { + + //if user is logged in and toggle is showing, add dropdown functions + if(el('userfcttoggle')){ + //if username toggle clicked, display dropdown + el('userfcttoggle').onclick = function() { + + if (el('userfctdropdown').style.display!='block') { + el('userfcttoggle').addclass('open'); + el('userfctdropdown').show(); + } else { + el('userfcttoggle').delclass('open'); + el('userfctdropdown').hide(); + } + } + + //when mouse moved away, hide dropdown + el('userfctdropdown').onmouseout = function(e) { + if (!e) var e = window.event; + if (!e.toElement) e.toElement = e.relatedTarget; + if (' ul li img a'.indexOf(e.toElement.tagName.toLowerCase())<0) { el('userfcttoggle').delclass('open'); el('userfctdropdown').hide(); } + }; + } + + + + } /* function showpersonallinks() {