summaryrefslogtreecommitdiff
path: root/lib/scripts/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scripts/script.js')
-rw-r--r--lib/scripts/script.js56
1 files changed, 41 insertions, 15 deletions
diff --git a/lib/scripts/script.js b/lib/scripts/script.js
index d589aa0b4..a8c6fe3fd 100644
--- a/lib/scripts/script.js
+++ b/lib/scripts/script.js
@@ -17,6 +17,30 @@ if (clientPC.indexOf('opera')!=-1) {
}
/**
+ * Handy shortcut to document.getElementById
+ *
+ * This function was taken from the prototype library
+ *
+ * @link http://prototype.conio.net/
+ */
+function $() {
+ var elements = new Array();
+
+ for (var i = 0; i < arguments.length; i++) {
+ var element = arguments[i];
+ if (typeof element == 'string')
+ element = document.getElementById(element);
+
+ if (arguments.length == 1)
+ return element;
+
+ elements.push(element);
+ }
+
+ return elements;
+}
+
+/**
* Get the X offset of the top left corner of the given object
*
* @link http://www.quirksmode.org/index.html?/js/findpos.html
@@ -27,7 +51,7 @@ function findPosX(object){
if(typeof(object) == 'object'){
obj = object;
}else{
- obj = document.getElementById(object);
+ obj = $(object);
}
if (obj.offsetParent){
while (obj.offsetParent){
@@ -52,7 +76,7 @@ function findPosY(object){
if(typeof(object) == 'object'){
obj = object;
}else{
- obj = document.getElementById(object);
+ obj = $(object);
}
if (obj.offsetParent){
while (obj.offsetParent){
@@ -129,7 +153,7 @@ function showLoadBar(){
*/
function hideLoadBar(){
if(document.getElementById){
- document.getElementById('loading').style.display="none";
+ $('loading').style.display="none";
}
}
@@ -160,7 +184,7 @@ function suggestWikiname(){
*/
function addTocToggle() {
if(!document.getElementById) return;
- var header = document.getElementById('toc__header');
+ var header = $('toc__header');
if(!header) return;
var showimg = document.createElement('img');
@@ -184,9 +208,9 @@ function addTocToggle() {
* This toggles the visibility of the Table of Contents
*/
function toggleToc() {
- var toc = document.getElementById('toc__inside');
- var showimg = document.getElementById('toc__show');
- var hideimg = document.getElementById('toc__hide');
+ var toc = $('toc__inside');
+ var showimg = $('toc__show');
+ var hideimg = $('toc__hide');
if(toc.style.display == 'none') {
toc.style.display = '';
hideimg.style.display = '';
@@ -254,7 +278,7 @@ function fixDate(date) {
*/
function checkAclLevel(){
if(document.getElementById) {
- var scope = document.getElementById('acl_scope').value;
+ var scope = $('acl_scope').value;
//check for namespace
if( (scope.indexOf(":*") > 0) || (scope == "*") ){
@@ -270,7 +294,9 @@ function checkAclLevel(){
}
}
-/* insitu footnote addition
+/**
+ * insitu footnote addition
+ *
* provide a wrapper for domTT javascript library
* this function is placed in the onmouseover event of footnote references in the main page
*
@@ -280,17 +306,17 @@ var currentFootnote = 0;
function fnt(id, e, evt) {
if (currentFootnote && id != currentFootnote) {
- domTT_close(document.getElementById('insitu-fn'+currentFootnote));
+ domTT_close($('insitu-fn'+currentFootnote));
}
// does the footnote tooltip already exist?
- var fnote = document.getElementById('insitu-fn'+id);
+ var fnote = $('insitu-fn'+id);
var footnote;
if (!fnote) {
// if not create it...
// locate the footnote anchor element
- var a = document.getElementById( "fn"+id );
+ var a = $( "fn"+id );
if (!a){ return; }
// anchor parent is the footnote container, get its innerHTML
@@ -318,8 +344,8 @@ function fnt(id, e, evt) {
function initSizeCtl(ctlid,edid){
if(!document.getElementById){ return; }
- var ctl = document.getElementById(ctlid);
- var textarea = document.getElementById(edid);
+ var ctl = $(ctlid);
+ var textarea = $(edid);
var hgt = getCookie('DokuWikisizeCtl');
if(hgt === null || hgt === ''){
@@ -342,7 +368,7 @@ function initSizeCtl(ctlid,edid){
* This sets the vertical size of the editbox
*/
function sizeCtl(edid,val){
- var textarea = document.getElementById(edid);
+ var textarea = $(edid);
var height = parseInt(textarea.style.height.substr(0,textarea.style.height.length-2));
height += val;
textarea.style.height = height+'px';