summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/whatever_hover/csshover3-source.htc284
-rw-r--r--modules/whatever_hover/csshover3.htc12
-rw-r--r--templates/csshover2.htc121
-rw-r--r--themes/classic/templates/default.css10
-rw-r--r--themes/greysme/templates/default.css10
-rw-r--r--themes/penguin/templates/default.css10
6 files changed, 311 insertions, 136 deletions
diff --git a/modules/whatever_hover/csshover3-source.htc b/modules/whatever_hover/csshover3-source.htc
new file mode 100644
index 00000000..99251920
--- /dev/null
+++ b/modules/whatever_hover/csshover3-source.htc
@@ -0,0 +1,284 @@
+<public:attach event="ondocumentready" onevent="CSSHover()" />
+<script>
+/**
+ * Whatever:hover - V3.11
+ * ------------------------------------------------------------
+ * Author - Peter Nederlof, http://www.xs4all.nl/~peterned
+ * License - http://creativecommons.org/licenses/LGPL/2.1
+ *
+ * Special thanks to Sergiu Dumitriu, http://purl.org/net/sergiu,
+ * for fixing the expression loop.
+ *
+ * Whatever:hover is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Whatever:hover is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * howto: body { behavior:url("csshover3.htc"); }
+ * ------------------------------------------------------------
+ */
+
+window.CSSHover = (function(){
+
+ // regular expressions, used and explained later on.
+ var REG_INTERACTIVE = /(^|\s)((([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active|focus))/i;
+ var REG_AFFECTED = /(.*?)\:(hover|active|focus)/i;
+ var REG_PSEUDO = /[^:]+:([a-z\-]+).*/i;
+ var REG_SELECT = /(\.([a-z0-9_\-]+):[a-z]+)|(:[a-z]+)/gi;
+ var REG_CLASS = /\.([a-z0-9_\-]*on(hover|active|focus))/i;
+ var REG_MSIE = /msie (5|6|7)/i;
+ var REG_COMPAT = /backcompat/i;
+
+ // property mapping, real css properties must be used in order to clear expressions later on...
+ // Uses obscure css properties that no-one is likely to use. The properties are borrowed to
+ // set an expression, and are then restored to the most likely correct value.
+ var Properties = {
+ index: 0,
+ list: ['text-kashida', 'text-kashida-space', 'text-justify'],
+ get: function() {
+ return this.list[(this.index++)%this.list.length];
+ }
+ };
+
+ // camelize is used to convert css properties from (eg) text-kashida to textKashida
+ var camelize = function(str) {
+ return str.replace(/-(.)/mg, function(result, match){
+ return match.toUpperCase();
+ });
+ };
+
+ /**
+ * Local CSSHover object
+ * --------------------------
+ */
+
+ var CSSHover = {
+
+ // array of CSSHoverElements, used to unload created events
+ elements: [],
+
+ // buffer used for checking on duplicate expressions
+ callbacks: {},
+
+ // init, called once ondomcontentready via the exposed window.CSSHover function
+ init:function() {
+ // don't run in IE8 standards; expressions don't work in standards mode anyway,
+ // and the stuff we're trying to fix should already work properly
+ if(!REG_MSIE.test(navigator.userAgent) && !REG_COMPAT.test(window.document.compatMode)) {
+ return;
+ }
+
+ // start parsing the existing stylesheets
+ var sheets = window.document.styleSheets, l = sheets.length;
+ for(var i=0; i<l; i++) {
+ this.parseStylesheet(sheets[i]);
+ }
+ },
+
+ // called from init, parses individual stylesheets
+ parseStylesheet:function(sheet) {
+ // check sheet imports and parse those recursively
+ if(sheet.imports) {
+ try {
+ var imports = sheet.imports;
+ var l = imports.length;
+ for(var i=0; i<l; i++) {
+ this.parseStylesheet(sheet.imports[i]);
+ }
+ } catch(securityException){
+ // trycatch for various possible errors
+ }
+ }
+
+ // interate the sheet's rules and send them to the parser
+ try {
+ var rules = sheet.rules;
+ var r = rules.length;
+ for(var j=0; j<r; j++) {
+ this.parseCSSRule(rules[j], sheet);
+ }
+ } catch(someException){
+ // trycatch for various errors, most likely accessing the sheet's rules.
+ }
+ },
+
+ // magic starts here ...
+ parseCSSRule:function(rule, sheet) {
+
+ // The sheet is used to insert new rules into, this must be the same sheet the rule
+ // came from, to ensure that relative paths keep pointing to the right location.
+
+ // only parse a rule if it contains an interactive pseudo.
+ var select = rule.selectorText;
+ if(REG_INTERACTIVE.test(select)) {
+ var style = rule.style.cssText;
+
+ // affected elements are found by truncating the selector after the interactive pseudo,
+ // eg: "div li:hover" >> "div li"
+ var affected = REG_AFFECTED.exec(select)[1];
+
+ // that pseudo is needed for a classname, and defines the type of interaction (focus, hover, active)
+ // eg: "li:hover" >> "onhover"
+ var pseudo = select.replace(REG_PSEUDO, 'on$1');
+
+ // the new selector is going to use that classname in a new css rule,
+ // since IE6 doesn't support multiple classnames, this is merged into one classname
+ // eg: "li:hover" >> "li.onhover", "li.folder:hover" >> "li.folderonhover"
+ var newSelect = select.replace(REG_SELECT, '.$2' + pseudo);
+
+ // the classname is needed for the events that are going to be set on affected nodes
+ // eg: "li.folder:hover" >> "folderonhover"
+ var className = REG_CLASS.exec(newSelect)[1];
+
+ // no need to set the same callback more than once when the same selector uses the same classname
+ var hash = affected + className;
+ if(!this.callbacks[hash]) {
+
+ // affected elements are given an expression under a borrowed css property, because fake properties
+ // can't have their expressions cleared. Different properties are used per pseudo, to avoid
+ // expressions from overwriting eachother. The expression does a callback to CSSHover.patch,
+ // rerouted via the exposed window.CSSHover function.
+ var property = Properties.get();
+ var atRuntime = camelize(property);
+
+ // because the expression is added to the stylesheet, and styles are always applied to html that is
+ // dynamically added to the dom, the expression will also trigger for those new elements (provided
+ // they are selected by the affected selector).
+ sheet.addRule(affected, property + ':expression(CSSHover(this, "'+pseudo+'", "'+className+'", "'+atRuntime+'"))');
+
+ // hash it, so an identical selector/class combo does not duplicate the expression
+ this.callbacks[hash] = true;
+ }
+
+ // duplicate expressions need not be set, but the style could differ
+ sheet.addRule(newSelect, style);
+ }
+ },
+
+ // called via the expression, patches individual nodes
+ patch:function(node, type, className, property) {
+
+ // restores the borrowed css property to the value of its immediate parent, clearing
+ // the expression so that it's not repeatedly called.
+ try {
+ var value = node.parentNode.currentStyle[property];
+ node.style[property] = value;
+ } catch(e) {
+ // the above reset should never fail, but just in case, clear the runtimeStyle if it does.
+ // this will also stop the expression.
+ node.runtimeStyle[property] = '';
+ }
+
+ // just to make sure, also keep track of patched classnames locally on the node
+ if(!node.csshover) {
+ node.csshover = [];
+ }
+
+ // and check for it to prevent duplicate events with the same classname from being set
+ if(!node.csshover[className]) {
+ node.csshover[className] = true;
+
+ // create an instance for the given type and class
+ var element = new CSSHoverElement(node, type, className);
+
+ // and store that instance for unloading later on
+ this.elements.push(element);
+ }
+
+ // returns a dummy value to the expression
+ return type;
+ },
+
+ // unload stuff onbeforeunload
+ unload:function() {
+ try {
+
+ // remove events
+ var l = this.elements.length;
+ for(var i=0; i<l; i++) {
+ this.elements[i].unload();
+ }
+
+ // and set properties to null
+ this.elements = [];
+ this.callbacks = {};
+
+ } catch (e) {
+ }
+ }
+ };
+
+ /**
+ * CSSHoverElement
+ * --------------------------
+ */
+
+ // the event types associated with the interactive pseudos
+ var CSSEvents = {
+ onhover: { activator: 'onmouseenter', deactivator: 'onmouseleave' },
+ onactive: { activator: 'onmousedown', deactivator: 'onmouseup' },
+ onfocus: { activator: 'onfocus', deactivator: 'onblur' }
+ };
+
+ // CSSHoverElement constructor, called via CSSHover.patch
+ function CSSHoverElement(node, type, className) {
+
+ // the CSSHoverElement patches individual nodes by manually applying the events that should
+ // have fired by the css pseudoclasses, eg mouseenter and mouseleave for :hover.
+
+ this.node = node;
+ this.type = type;
+ var replacer = new RegExp('(^|\\s)'+className+'(\\s|$)', 'g');
+
+ // store event handlers for removal onunload
+ this.activator = function(){ node.className += ' ' + className; };
+ this.deactivator = function(){ node.className = node.className.replace(replacer, ' '); };
+
+ // add the events
+ node.attachEvent(CSSEvents[type].activator, this.activator);
+ node.attachEvent(CSSEvents[type].deactivator, this.deactivator);
+ }
+
+ CSSHoverElement.prototype = {
+ // onbeforeunload, called via CSSHover.unload
+ unload:function() {
+
+ // remove events
+ this.node.detachEvent(CSSEvents[this.type].activator, this.activator);
+ this.node.detachEvent(CSSEvents[this.type].deactivator, this.deactivator);
+
+ // and set properties to null
+ this.activator = null;
+ this.deactivator = null;
+ this.node = null;
+ this.type = null;
+ }
+ };
+
+ // add the unload to the onbeforeunload event
+ window.attachEvent('onbeforeunload', function(){
+ CSSHover.unload();
+ });
+
+ /**
+ * Public hook
+ * --------------------------
+ */
+
+ return function(node, type, className, property) {
+ if(node) {
+ // called via the css expression; patches individual nodes
+ return CSSHover.patch(node, type, className, property);
+ } else {
+ // called ondomcontentready via the public:attach node
+ CSSHover.init();
+ }
+ };
+
+})();
+</script> \ No newline at end of file
diff --git a/modules/whatever_hover/csshover3.htc b/modules/whatever_hover/csshover3.htc
new file mode 100644
index 00000000..4fa021f5
--- /dev/null
+++ b/modules/whatever_hover/csshover3.htc
@@ -0,0 +1,12 @@
+<public:attach event="ondocumentready" onevent="CSSHover()" />
+<script>
+/**
+ * Whatever:hover - V3.11
+ * http://www.xs4all.nl/~peterned/
+ *
+ * Copyright (c) 2009 Peter Nederlof
+ * Licensed under the LGPL license
+ * http://creativecommons.org/licenses/LGPL/2.1
+ */
+window.CSSHover=(function(){var m=/(^|\s)((([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active|focus))/i;var n=/(.*?)\:(hover|active|focus)/i;var o=/[^:]+:([a-z\-]+).*/i;var p=/(\.([a-z0-9_\-]+):[a-z]+)|(:[a-z]+)/gi;var q=/\.([a-z0-9_\-]*on(hover|active|focus))/i;var s=/msie (5|6|7)/i;var t=/backcompat/i;var u={index:0,list:['text-kashida','text-kashida-space','text-justify'],get:function(){return this.list[(this.index++)%this.list.length]}};var v=function(c){return c.replace(/-(.)/mg,function(a,b){return b.toUpperCase()})};var w={elements:[],callbacks:{},init:function(){if(!s.test(navigator.userAgent)&&!t.test(window.document.compatMode)){return}var a=window.document.styleSheets,l=a.length;for(var i=0;i<l;i++){this.parseStylesheet(a[i])}},parseStylesheet:function(a){if(a.imports){try{var b=a.imports;var l=b.length;for(var i=0;i<l;i++){this.parseStylesheet(a.imports[i])}}catch(securityException){}}try{var c=a.rules;var r=c.length;for(var j=0;j<r;j++){this.parseCSSRule(c[j],a)}}catch(someException){}},parseCSSRule:function(a,b){var c=a.selectorText;if(m.test(c)){var d=a.style.cssText;var e=n.exec(c)[1];var f=c.replace(o,'on$1');var g=c.replace(p,'.$2'+f);var h=q.exec(g)[1];var i=e+h;if(!this.callbacks[i]){var j=u.get();var k=v(j);b.addRule(e,j+':expression(CSSHover(this, "'+f+'", "'+h+'", "'+k+'"))');this.callbacks[i]=true}b.addRule(g,d)}},patch:function(a,b,c,d){try{var f=a.parentNode.currentStyle[d];a.style[d]=f}catch(e){a.runtimeStyle[d]=''}if(!a.csshover){a.csshover=[]}if(!a.csshover[c]){a.csshover[c]=true;var g=new CSSHoverElement(a,b,c);this.elements.push(g)}return b},unload:function(){try{var l=this.elements.length;for(var i=0;i<l;i++){this.elements[i].unload()}this.elements=[];this.callbacks={}}catch(e){}}};var x={onhover:{activator:'onmouseenter',deactivator:'onmouseleave'},onactive:{activator:'onmousedown',deactivator:'onmouseup'},onfocus:{activator:'onfocus',deactivator:'onblur'}};function CSSHoverElement(a,b,c){this.node=a;this.type=b;var d=new RegExp('(^|\\s)'+c+'(\\s|$)','g');this.activator=function(){a.className+=' '+c};this.deactivator=function(){a.className=a.className.replace(d,' ')};a.attachEvent(x[b].activator,this.activator);a.attachEvent(x[b].deactivator,this.deactivator)}CSSHoverElement.prototype={unload:function(){this.node.detachEvent(x[this.type].activator,this.activator);this.node.detachEvent(x[this.type].deactivator,this.deactivator);this.activator=null;this.deactivator=null;this.node=null;this.type=null}};window.attachEvent('onbeforeunload',function(){w.unload()});return function(a,b,c,d){if(a){return w.patch(a,b,c,d)}else{w.init()}}})();
+</script> \ No newline at end of file
diff --git a/templates/csshover2.htc b/templates/csshover2.htc
deleted file mode 100644
index e2dcced3..00000000
--- a/templates/csshover2.htc
+++ /dev/null
@@ -1,121 +0,0 @@
-<attach event="ondocumentready" handler="parseStylesheets" />
-<script>
-/**
- * Whatever:hover - V2.02.060206 - hover, active & focus
- * ------------------------------------------------------------
- * (c) 2005 - Peter Nederlof
- * Peterned - http://www.xs4all.nl/~peterned/
- * License - http://creativecommons.org/licenses/LGPL/2.1/
- *
- * Whatever:hover is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Whatever:hover is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Credits and thanks to:
- * Arnoud Berendsen, Martin Reurings, Robert Hanson
- *
- * howto: body { behavior:url("csshover.htc"); }
- * ------------------------------------------------------------
- */
-
-var csshoverReg = /(^|\s)((([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active))|((a|input|textarea)([#.][^ ]+)?:unknown)/i,
-currentSheet, doc = window.document, hoverEvents = [], activators = {
- onhover:{on:'onmouseover', off:'onmouseout'},
- onactive:{on:'onmousedown', off:'onmouseup'},
- onunknown:{on:'onfocus', off:'onblur'}
-}
-
-function parseStylesheets() {
- if(!/MSIE (5|6)/.test(navigator.userAgent)) return;
- window.attachEvent('onunload', unhookHoverEvents);
- var sheets = doc.styleSheets, l = sheets.length;
- for(var i=0; i<l; i++)
- parseStylesheet(sheets[i]);
-}
- function parseStylesheet(sheet) {
- if(sheet.imports) {
- try {
- var imports = sheet.imports, l = imports.length;
- for(var i=0; i<l; i++) parseStylesheet(sheet.imports[i]);
- } catch(securityException){}
- }
-
- try {
- var rules = (currentSheet = sheet).rules, l = rules.length;
- for(var j=0; j<l; j++) parseCSSRule(rules[j]);
- } catch(securityException){}
- }
-
- function parseCSSRule(rule) {
- var select = rule.selectorText, style = rule.style.cssText;
- if(!csshoverReg.test(select) || !style) return;
-
- var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, 'on$1');
- var newSelect = select.replace(/(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo);
- var className = (/\.([a-z0-9_-]*on(hover|active|unknown))/i).exec(newSelect)[1];
- var affected = select.replace(/:(hover|active|unknown).*$/, '');
- var elements = getElementsBySelect(affected);
- if(elements.length == 0) return;
-
- currentSheet.addRule(newSelect, style);
- for(var i=0; i<elements.length; i++)
- new HoverElement(elements[i], className, activators[pseudo]);
- }
-
-function HoverElement(node, className, events) {
- if(!node.hovers) node.hovers = {};
- if(node.hovers[className]) return;
- node.hovers[className] = true;
- hookHoverEvent(node, events.on, function() { node.className += ' ' + className; });
- hookHoverEvent(node, events.off, function() { node.className = node.className.replace(new RegExp('\\s+'+className, 'g'),''); });
-}
- function hookHoverEvent(node, type, handler) {
- node.attachEvent(type, handler);
- hoverEvents[hoverEvents.length] = {
- node:node, type:type, handler:handler
- };
- }
-
- function unhookHoverEvents() {
- for(var e,i=0; i<hoverEvents.length; i++) {
- e = hoverEvents[i];
- e.node.detachEvent(e.type, e.handler);
- }
- }
-
-function getElementsBySelect(rule) {
- var parts, nodes = [doc];
- parts = rule.split(' ');
- for(var i=0; i<parts.length; i++) {
- nodes = getSelectedNodes(parts[i], nodes);
- } return nodes;
-}
- function getSelectedNodes(select, elements) {
- var result, node, nodes = [];
- var identify = (/\#([a-z0-9_-]+)/i).exec(select);
- if(identify) {
- var element = doc.getElementById(identify[1]);
- return element? [element]:nodes;
- }
-
- var classname = (/\.([a-z0-9_-]+)/i).exec(select);
- var tagName = select.replace(/(\.|\#|\:)[a-z0-9_-]+/i, '');
- var classReg = classname? new RegExp('\\b' + classname[1] + '\\b'):false;
- for(var i=0; i<elements.length; i++) {
- result = tagName? elements[i].all.tags(tagName):elements[i].all;
- for(var j=0; j<result.length; j++) {
- node = result[j];
- if(classReg && !classReg.test(node.className)) continue;
- nodes[nodes.length] = node;
- }
- }
-
- return nodes;
- }
-</script> \ No newline at end of file
diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css
index 55d7dcae..dae5286d 100644
--- a/themes/classic/templates/default.css
+++ b/themes/classic/templates/default.css
@@ -66,11 +66,11 @@ input {
font-weight: bold;
}
-/************************************************/
-/* IE6 behaviors */
-/* - csshover2: :hover support on any element */
-/************************************************/
-body { behavior:url("templates/csshover2.htc"); }
+/***************************************************/
+/* IE6 behaviors */
+/* - Whatever:hover: :hover support on any element */
+/***************************************************/
+body { behavior:url("modules/whatever_hover/csshover3.htc"); }
/************************************************/
/* Float Clearer */
diff --git a/themes/greysme/templates/default.css b/themes/greysme/templates/default.css
index a2aff896..e22b6db8 100644
--- a/themes/greysme/templates/default.css
+++ b/themes/greysme/templates/default.css
@@ -82,11 +82,11 @@ input{ padding:0 2px; }
input:focus, select:focus { border-style: dotted; }
textarea { background-color: #111; color: #e9ad51; }
-/************************************************/
-/* IE6 behaviors */
-/* - csshover2: :hover support on any element */
-/************************************************/
-body { behavior:url("templates/csshover2.htc"); }
+/***************************************************/
+/* IE6 behaviors */
+/* - Whatever:hover: :hover support on any element */
+/***************************************************/
+body { behavior:url("modules/whatever_hover/csshover3.htc"); }
/************************************************/
/* Float Clearer */
diff --git a/themes/penguin/templates/default.css b/themes/penguin/templates/default.css
index e67396f0..501e78c5 100644
--- a/themes/penguin/templates/default.css
+++ b/themes/penguin/templates/default.css
@@ -101,12 +101,12 @@ select {
input[type=checkbox] {
border:0
}
-/************************************************/
-/* IE6 behaviors */
-/* - csshover2: :hover support on any element */
-/************************************************/
+/***************************************************/
+/* IE6 behaviors */
+/* - Whatever:hover: :hover support on any element */
+/***************************************************/
body {
- behavior:url("templates/csshover2.htc");
+ behavior:url("modules/whatever_hover/csshover3.htc");
}
/************************************************/
/* Float Clearer */