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.js70
1 files changed, 58 insertions, 12 deletions
diff --git a/lib/scripts/script.js b/lib/scripts/script.js
index c79c9b683..2cc1246f9 100644
--- a/lib/scripts/script.js
+++ b/lib/scripts/script.js
@@ -114,6 +114,20 @@ function findPosY(object){
} //end findPosY function
/**
+ * Get the computed style of a node.
+ *
+ * @link https://acidmartin.wordpress.com/2008/08/26/style-get-any-css-property-value-of-an-object/
+ * @link http://svn.dojotoolkit.org/src/dojo/trunk/_base/html.js
+ */
+function gcs(node){
+ if(node.currentStyle){
+ return node.currentStyle;
+ }else{
+ return node.ownerDocument.defaultView.getComputedStyle(node, null);
+ }
+}
+
+/**
* Escape special chars in JavaScript
*
* @author Andreas Gohr <andi@splitbrain.org>
@@ -260,10 +274,32 @@ function insitu_popup(target, popup_id) {
getElementsByClass('dokuwiki', document.body, 'div')[0].appendChild(fndiv);
}
+ var non_static_parent = fndiv.parentNode;
+ while (non_static_parent != document && gcs(non_static_parent)['position'] == 'static') {
+ non_static_parent = non_static_parent.parentNode;
+ }
+
+ var fixed_target_parent = target;
+ while (fixed_target_parent != document && gcs(fixed_target_parent)['position'] != 'fixed') {
+ fixed_target_parent = fixed_target_parent.parentNode;
+ }
+
// position the div and make it visible
- fndiv.style.position = 'absolute';
- fndiv.style.left = findPosX(target)+'px';
- fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5) + 'px';
+ if (fixed_target_parent != document) {
+ // the target has position fixed, that means the footnote needs to be fixed, too
+ fndiv.style.position = 'fixed';
+ } else {
+ fndiv.style.position = 'absolute';
+ }
+
+ if (fixed_target_parent != document || non_static_parent == document) {
+ fndiv.style.left = findPosX(target)+'px';
+ fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5) + 'px';
+ } else {
+ fndiv.style.left = (findPosX(target) - findPosX(non_static_parent)) +'px';
+ fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5 - findPosY(non_static_parent)) + 'px';
+ }
+
fndiv.style.display = '';
return fndiv;
}
@@ -460,19 +496,29 @@ addInitEvent(function(){
});
/**
- * Add the event handler to the actiondropdown
+ * Autosubmit quick select forms
+ *
+ * When a <select> tag has the class "quickselect", this script will
+ * automatically submit its parent form when the select value changes.
+ * It also hides the submit button of the form.
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
addInitEvent(function(){
- var selector = $('action__selector');
- if(!selector) return;
-
- addEvent(selector,'change',function(e){
- this.form.submit();
- });
-
- $('action__selectorbtn').style.display = 'none';
+ var selects = getElementsByClass('quickselect',document,'select');
+ for(var i=0; i<selects.length; i++){
+ // auto submit on change
+ addEvent(selects[i],'change',function(e){
+ this.form.submit();
+ });
+ // hide submit buttons
+ var btns = selects[i].form.getElementsByTagName('input');
+ for(var j=0; j<btns.length; j++){
+ if(btns[j].type == 'submit'){
+ btns[j].style.display = 'none';
+ }
+ }
+ }
});
/**