summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-10-15 22:52:41 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-10-15 22:52:41 +0000
commita6979e984ccbe4ab31897cd55a04a438709f2a8a (patch)
tree301750e8701107e9895529d251e30c1a920ae9b7
parent424f461e584ccc8ef5be9cd0e92c6b5023131e8f (diff)
* luci/themes/openwrt.org:
- remove duplicate contents in js files - implement workaround for IE6 overlapping select box issue
-rw-r--r--themes/openwrt.org/htdocs/luci-static/openwrt.org/Dropdowns.js98
-rw-r--r--themes/openwrt.org/htdocs/luci-static/openwrt.org/VarType.js91
-rw-r--r--themes/openwrt.org/htdocs/luci-static/openwrt.org/XHTML1.js271
-rw-r--r--themes/openwrt.org/htdocs/luci-static/openwrt.org/ie6.css5
4 files changed, 34 insertions, 431 deletions
diff --git a/themes/openwrt.org/htdocs/luci-static/openwrt.org/Dropdowns.js b/themes/openwrt.org/htdocs/luci-static/openwrt.org/Dropdowns.js
index 7d800f07b..ff2f0e665 100644
--- a/themes/openwrt.org/htdocs/luci-static/openwrt.org/Dropdowns.js
+++ b/themes/openwrt.org/htdocs/luci-static/openwrt.org/Dropdowns.js
@@ -24,92 +24,50 @@ SUCH DAMAGE.
*/
function initDropdowns() {
- function onmouseover(evt) {
- XHTML1.addClass(evt.currentTarget, "over");
- }
+ var aSelects = XHTML1.getElementsByTagName("select");
+ var isIE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
+
+ function showPlaceholder(sel) {
+ if( ! sel._ph ) {
+ var box = sel.getBoundingClientRect();
+ sel._dm = sel.currentStyle.display;
+ sel._ph = document.createElement('input');
+ sel.parentNode.insertBefore(sel._ph, sel);
+ sel._ph.style.width = ( box.right - box.left ) + 'px';
+ sel._ph.style.height = ( box.bottom - box.top ) + 'px';
+ sel._ph.style.margin = sel.currentStyle.margin;
+ }
- function onmouseout(evt) {
- XHTML1.removeClass(evt.currentTarget, "over");
+ sel._ph.value = sel.options[sel.selectedIndex].text;
+ sel._ph.style.display = sel._dm;
+ sel.style.display = 'none';
}
- function onfocus(evt) {
- for(var element = evt.currentTarget; element; element = element.parentNode) {
- if(XHTML1.isElement(element, "li")) {
- XHTML1.addClass(element, "focus");
- }
- }
+ function hidePlaceholder(sel) {
+ if( sel._ph ) sel._ph.style.display = 'none';
+ sel.style.display = sel._dm;
}
- function onblur(evt) {
- for(var element = evt.currentTarget; element; element = element.parentNode) {
- if(XHTML1.isElement(element, "li")) {
- XHTML1.removeClass(element, "focus");
- }
+ function hideSelects() {
+ for(var i = 0; i < aSelects.length; i++) {
+ showPlaceholder(aSelects[i]);
}
}
- if(document.all) {
- var liElements = XHTML1.getElementsByTagName("li");
- for(var i = 0; i < liElements.length; i++) {
- var li = liElements[i];
- for(var element = li.parentNode; element; element = element.parentNode) {
- if(XHTML1.isElement(element, "ul") && XHTML1.containsClass(element, "dropdowns")) {
- XHTML1.addEventListener(li, "mouseover", onmouseover);
- XHTML1.addEventListener(li, "mouseout", onmouseout);
- break;
- }
- }
- }
- }
-
- var aElements = XHTML1.getElementsByTagName("a");
- for(var i = 0; i < aElements.length; i++) {
- var a = aElements[i];
- for(var element = a.parentNode; element; element = element.parentNode) {
- if(XHTML1.isElement(element, "ul") && XHTML1.containsClass(element, "dropdowns")) {
- XHTML1.addEventListener(a, "focus", onfocus);
- XHTML1.addEventListener(a, "blur", onblur);
- break;
- }
+ function showSelects() {
+ for(var i = 0; i < aSelects.length; i++) {
+ hidePlaceholder(aSelects[i]);
}
}
-}
-
-if(XHTML1.isDOMSupported()) {
- XHTML1.addEventListener(window, "load", initDropdowns);
-}
-/*
-Copyright (C) 2008 Alina Friedrichsen <x-alina@gmx.net>
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-*/
-
-function initDropdowns() {
function onmouseover(evt) {
XHTML1.addClass(evt.currentTarget, "over");
+ if( isIE6 ) hideSelects();
}
function onmouseout(evt) {
XHTML1.removeClass(evt.currentTarget, "over");
+ if( isIE6 ) showSelects();
}
function onfocus(evt) {
@@ -118,6 +76,7 @@ function initDropdowns() {
XHTML1.addClass(element, "focus");
}
}
+ if( isIE6 ) hideSelects();
}
function onblur(evt) {
@@ -126,6 +85,7 @@ function initDropdowns() {
XHTML1.removeClass(element, "focus");
}
}
+ if( isIE6 ) showSelects();
}
if(document.all) {
diff --git a/themes/openwrt.org/htdocs/luci-static/openwrt.org/VarType.js b/themes/openwrt.org/htdocs/luci-static/openwrt.org/VarType.js
index 12811dd4f..d4668109d 100644
--- a/themes/openwrt.org/htdocs/luci-static/openwrt.org/VarType.js
+++ b/themes/openwrt.org/htdocs/luci-static/openwrt.org/VarType.js
@@ -89,94 +89,3 @@ VarType.needNode = function(obj, type) {
if(obj.nodeType != type) throw new TypeError();
}
};
-/*
-Copyright (C) 2008 Alina Friedrichsen <x-alina@gmx.net>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-*/
-
-function VarType() {
-}
-
-VarType.isNull = function(obj) {
- if(typeof obj == "undefined") return true;
- if(typeof obj == "object" && (!obj)) return true;
- return false;
-};
-
-VarType.toFloat = function(value) {
- value = Number(value);
- return value;
-};
-
-VarType.toDecimal = function(value) {
- value = Number(value);
- if(!isFinite(value)) value = 0.0;
- return value;
-};
-
-VarType.toInt = function(value) {
- value = Number(value);
- if(!isFinite(value)) value = 0.0;
- value = Math.floor(value);
- return value;
-};
-
-VarType.toUInt = function(value) {
- value = Number(value);
- if(!isFinite(value)) value = 0.0;
- else if(value < 0.0) value = 0.0;
- value = Math.floor(value);
- return value;
-};
-
-VarType.toStr = function(value) {
- if(VarType.isNull(value)) value = "";
- value = String(value);
- return value;
-};
-
-VarType.toBool = function(value) {
- value = Boolean(value);
- return value;
-};
-
-VarType.needObject = function(obj) {
- if(typeof obj != "object" || (!obj)) throw new TypeError();
-};
-
-VarType.needInstanceOf = function(obj, type) {
- if(!(obj instanceof type)) throw new TypeError();
-};
-
-VarType.needFunction = function(obj) {
- if(typeof obj != "function") throw new TypeError();
-};
-
-VarType.needNode = function(obj, type) {
- VarType.needObject(obj);
- if(VarType.isNull(obj.nodeType)) throw new TypeError();
- if(!VarType.isNull(type)) {
- type = VarType.toInt(type);
- if(obj.nodeType != type) throw new TypeError();
- }
-};
diff --git a/themes/openwrt.org/htdocs/luci-static/openwrt.org/XHTML1.js b/themes/openwrt.org/htdocs/luci-static/openwrt.org/XHTML1.js
index b196f5313..a7d4f7ddd 100644
--- a/themes/openwrt.org/htdocs/luci-static/openwrt.org/XHTML1.js
+++ b/themes/openwrt.org/htdocs/luci-static/openwrt.org/XHTML1.js
@@ -269,274 +269,3 @@ XHTML1.setTextContent = function(node, value) {
break;
}
};
-/*
-Copyright (C) 2007, 2008 Alina Friedrichsen <x-alina@gmx.net>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-*/
-
-var XMLNS_XMLNS = "http://www.w3.org/2000/xmlns/";
-var XMLNS_XML = "http://www.w3.org/XML/1998/namespace";
-var XMLNS_XHTML = "http://www.w3.org/1999/xhtml";
-
-function W3CDOM_Event(currentTarget) {
- VarType.needObject(currentTarget);
- this.currentTarget = currentTarget;
- this.preventDefault = function() { window.event.returnValue = false; };
- return this;
-}
-
-function XHTML1() {
-}
-
-XHTML1.isDOMSupported = function() {
- if(!document.getElementById) return false;
- if(!(window.addEventListener || window.attachEvent)) return false;
- return true;
-};
-
-XHTML1.isXHTML = function() {
- if(document.documentElement.nodeName == "HTML") return false;
- return true;
-};
-
-XHTML1.addEventListener = function(target, type, listener) {
- VarType.needObject(target);
- type = VarType.toStr(type);
- VarType.needFunction(listener);
-
- if(target.addEventListener) {
- target.addEventListener(type, listener, false);
- }
- else if(target.attachEvent) {
- target.attachEvent("on" + type, function() { listener(new W3CDOM_Event(target)); } );
- }
-};
-
-XHTML1.createElement = function(tagName) {
- tagName = VarType.toStr(tagName);
-
- if(XHTML1.isXHTML()) {
- return document.createElementNS(XMLNS_XHTML, tagName.toLowerCase());
- }
-
- return document.createElement(tagName.toUpperCase());
-};
-
-XHTML1.getElementsByTagName = function(tagName) {
- tagName = VarType.toStr(tagName);
-
- if(XHTML1.isXHTML()) {
- return document.getElementsByTagNameNS(XMLNS_XHTML, tagName.toLowerCase());
- }
-
- return document.getElementsByTagName(tagName.toUpperCase());
-};
-
-XHTML1.isElement = function(node, tagName) {
- VarType.needNode(node);
- tagName = VarType.toStr(tagName);
-
- if(node.nodeType == 1) {
- if(XHTML1.isXHTML()) {
- if(node.namespaceURI == XMLNS_XHTML) {
- if(node.localName == tagName.toLowerCase()) return true;
- }
- } else {
- if(node.nodeName == tagName.toUpperCase()) return true;
- }
- }
-
- return false;
-};
-
-XHTML1.getAttribute = function(element, name) {
- VarType.needNode(element, 1);
- name = VarType.toStr(name);
-
- name = name.toLowerCase();
-
- if(XHTML1.isXHTML()) {
- return element.getAttributeNS(null, name);
- }
-
- if(name == "class") {
- return element.className;
- }
-
- return element.getAttribute(name);
-};
-
-XHTML1.setAttribute = function(element, name, value) {
- VarType.needNode(element, 1);
- name = VarType.toStr(name);
- value = VarType.toStr(value);
-
- name = name.toLowerCase();
-
- if(XHTML1.isXHTML()) {
- element.setAttributeNS(null, name, value);
- return;
- }
-
- if(name == "class") {
- element.className = value;
- return;
- }
-
- element.setAttribute(name, value);
-};
-
-XHTML1.removeAttribute = function(element, name) {
- VarType.needNode(element, 1);
- name = VarType.toStr(name);
-
- name = name.toLowerCase();
-
- if(XHTML1.isXHTML()) {
- element.removeAttributeNS(null, name);
- return;
- }
-
- if(name == "class") {
- element.className = "";
- return;
- }
-
- element.removeAttribute(name);
-};
-
-XHTML1.containsClass = function(element, className) {
- VarType.needNode(element, 1);
- className = VarType.toStr(className).replace(/^\s+/g, "").replace(/\s+$/g, "");
-
- var classString = XHTML1.getAttribute(element, "class").replace(/\s+/g, " ").replace(/^\s+/g, "").replace(/\s+$/g, "");
- var classArray = classString.split(" ");
- for(var i = 0; i < classArray.length; i++) {
- if(classArray[i] == className) return true;
- }
-
- return false;
-};
-
-XHTML1.addClass = function(element, className) {
- VarType.needNode(element, 1);
- className = VarType.toStr(className).replace(/^\s+/g, "").replace(/\s+$/g, "");
-
- var classString = XHTML1.getAttribute(element, "class").replace(/\s+/g, " ").replace(/^\s+/g, "").replace(/\s+$/g, "");
- var classArray = classString.split(" ");
- classString = "";
- for(var i = 0; i < classArray.length; i++) {
- if(classArray[i] != className) {
- if(classString == "") classString = classArray[i];
- else classString += " " + classArray[i];
- }
- }
-
- if(classString == "") classString = className;
- else classString += " " + className;
-
- XHTML1.setAttribute(element, "class", classString);
-};
-
-XHTML1.removeClass = function(element, className) {
- VarType.needNode(element, 1);
- className = VarType.toStr(className).replace(/^\s+/g, "").replace(/\s+$/g, "");
-
- var classString = XHTML1.getAttribute(element, "class").replace(/\s+/g, " ").replace(/^\s+/g, "").replace(/\s+$/g, "");
- var classArray = classString.split(" ");
- classString = "";
- for(var i = 0; i < classArray.length; i++) {
- if(classArray[i] != className) {
- if(classString == "") classString = classArray[i];
- else classString += " " + classArray[i];
- }
- }
-
- XHTML1.setAttribute(element, "class", classString);
-};
-
-XHTML1.removeAllChildren = function(node) {
- VarType.needNode(node);
-
- while(node.lastChild) {
- node.removeChild(node.lastChild);
- }
-};
-
-XHTML1.getTextContent = function(node) {
- VarType.needNode(node);
-
- if(typeof node.textContent != "undefined") {
- return node.textContent;
- }
-
- switch(node.nodeType) {
- case 1:
- case 2:
- case 5:
- case 6:
- case 11:
- var textContent = "";
- for(node = node.firstChild; node; node = node.nextSibling) {
- if(node.nodeType == 7) continue;
- if(node.nodeType == 8) continue;
- textContent += VarType.toStr(XHTML1.getTextContent(node));
- }
- return textContent;
- case 3:
- case 4:
- case 7:
- case 8:
- return node.nodeValue;
- }
-
- return null;
-};
-
-XHTML1.setTextContent = function(node, value) {
- VarType.needNode(node);
- value = VarType.toStr(value);
-
- if(typeof node.textContent != "undefined") {
- node.textContent = value;
- }
-
- switch(node.nodeType) {
- case 1:
- case 2:
- case 5:
- case 6:
- case 11:
- XHTML1.removeAllChildren(node);
- if(value != "") {
- node.appendChild(document.createTextNode(value));
- }
- break;
- case 3:
- case 4:
- case 7:
- case 8:
- node.nodeValue = value;
- break;
- }
-};
diff --git a/themes/openwrt.org/htdocs/luci-static/openwrt.org/ie6.css b/themes/openwrt.org/htdocs/luci-static/openwrt.org/ie6.css
index d65da4a19..1d4245c4a 100644
--- a/themes/openwrt.org/htdocs/luci-static/openwrt.org/ie6.css
+++ b/themes/openwrt.org/htdocs/luci-static/openwrt.org/ie6.css
@@ -69,3 +69,8 @@
* html div.cbi-value-field select {
font-size: 90% !important;
}
+
+ul.dropdowns,
+ul.dropdowns ul {
+ z-index: 1000;
+}