diff options
author | Guy Brand <gb@unistra.fr> | 2012-09-10 17:04:45 +0200 |
---|---|---|
committer | Guy Brand <gb@unistra.fr> | 2012-09-10 17:04:45 +0200 |
commit | 0f8ac4e8c5872a6b68b350f96a9ecde0291edefa (patch) | |
tree | ad7938bb4143d5e5a38fd7a8d131e4171aec657d /lib/scripts | |
parent | 58ec8fa9128e4581749955de87530f432e387588 (diff) | |
parent | b31fcef02fd24b3e746c9618e77152c7b84c2f2a (diff) | |
download | rpg-0f8ac4e8c5872a6b68b350f96a9ecde0291edefa.tar.gz rpg-0f8ac4e8c5872a6b68b350f96a9ecde0291edefa.tar.bz2 |
Merge branch 'master' into stable
Diffstat (limited to 'lib/scripts')
-rw-r--r-- | lib/scripts/edit.js | 2 | ||||
-rw-r--r-- | lib/scripts/index.html | 5 | ||||
-rw-r--r-- | lib/scripts/media.js | 15 | ||||
-rw-r--r-- | lib/scripts/page.js | 96 |
4 files changed, 78 insertions, 40 deletions
diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 33a8f61b5..5a5e829bd 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -40,6 +40,8 @@ function createToolButton(icon,label,key,id,classname){ icon = DOKU_BASE + 'lib/images/toolbar/' + icon; } $ico.attr('src', icon); + $ico.attr('width', 16); + $ico.attr('height', 16); $btn.append($ico); // we have to return a DOM object (for compatibility reasons) diff --git a/lib/scripts/index.html b/lib/scripts/index.html index d614603ac..977f90e10 100644 --- a/lib/scripts/index.html +++ b/lib/scripts/index.html @@ -1,6 +1,5 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> +<!DOCTYPE html> +<html> <head> <meta http-equiv="refresh" content="0; URL=../../" /> <meta name="robots" content="noindex" /> diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 841baa93f..182d5fefe 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -31,6 +31,7 @@ var dw_mediamanager = { var $content, $tree; $content = jQuery('#media__content'); $tree = jQuery('#media__tree'); + if(!$tree.length) return; dw_mediamanager.prepare_content($content); @@ -434,7 +435,7 @@ var dw_mediamanager = { dw_mediamanager.$resizables().resizable('destroy'); if (update_list) { - dw_mediamanager.list.call(jQuery('input[value="Apply"]')[0]); + dw_mediamanager.list.call(jQuery('#mediamanager__page form.options input[type="submit"]')[0]); } $content.html(data); @@ -494,12 +495,12 @@ var dw_mediamanager = { // set max width of resizable column var widthOtherResizable = widthResizables - jQuery(this).width(); var minWidthNonResizable = parseFloat($filePanel.css("min-width")); - var maxWidth = widthFull - (widthOtherResizable + minWidthNonResizable); + var maxWidth = widthFull - (widthOtherResizable + minWidthNonResizable) - 1; $resizables.resizable( "option", "maxWidth", maxWidth ); - // width of file panel in % = 100% - width of resizables in % - // this calculates with 99.99 and not 100 to overcome rounding errors - var relWidthNonResizable = 99.99 - (100 * widthResizables / widthFull); + // width of file panel in % = 100% - width of resizables in % + // this calculates with 99.9 and not 100 to overcome rounding errors + var relWidthNonResizable = 99.9 - (100 * widthResizables / widthFull); // set width of file panel $filePanel.width(relWidthNonResizable+'%'); @@ -513,6 +514,8 @@ var dw_mediamanager = { }); } + dw_mediamanager.resize(); + dw_mediamanager.opacity_slider(); dw_mediamanager.portions_slider(); } @@ -699,7 +702,7 @@ var dw_mediamanager = { event.preventDefault(); $link = jQuery(this); - id = $link.attr('name').substr(2); + id = $link.attr('id').substr(2); if(!opener){ // if we don't run in popup display example diff --git a/lib/scripts/page.js b/lib/scripts/page.js index 5da4a9cc0..b8e83cb0c 100644 --- a/lib/scripts/page.js +++ b/lib/scripts/page.js @@ -10,7 +10,7 @@ dw_page = { init: function(){ dw_page.sectionHighlight(); jQuery('a.fn_top').mouseover(dw_page.footnoteDisplay); - dw_page.initTocToggle(); + dw_page.makeToggle('#dw__toc h3','#dw__toc > div'); }, /** @@ -27,9 +27,14 @@ dw_page = { // Walk the DOM tree up (first previous siblings, then parents) // until boundary element while($tgt.length > 0 && !$tgt.hasClass('sectionedit' + nr)) { - // $.last gives the DOM-ordered last element: - // prev if present, else parent. - $tgt = $tgt.prev().add($tgt.parent()).last(); + // go down when the sectionedit begin marker is below $tgt + if ($tgt.find('.sectionedit' + nr).length > 0) { + $tgt = $tgt.children().last(); + } else { + // $.last gives the DOM-ordered last element: + // prev if present, else parent. + $tgt = $tgt.prev().add($tgt.parent()).last(); + } $tgt.addClass('section_highlight'); } }) @@ -93,48 +98,77 @@ dw_page = { }, /** - * Adds the toggle switch to the TOC + * Makes an element foldable by clicking its handle + * + * This is used for the TOC toggling, but can be used for other elements + * as well. A state indicator is inserted into the handle and can be styled + * by CSS. + * + * @param selector handle What should be clicked to toggle + * @param selector content This element will be toggled */ - initTocToggle: function() { - var $header, $clicky, $toc, $tocul, setClicky; - $header = jQuery('#toc__header'); - if(!$header.length) { - return; - } - $toc = jQuery('#toc__inside'); - $tocul = $toc.children('ul.toc'); + makeToggle: function(handle, content, state){ + var $handle, $content, $clicky, $child, setClicky; + $handle = jQuery(handle); + if(!$handle.length) return; + $content = jQuery(content); + if(!$content.length) return; + + // we animate the children + $child = $content.children(); + // class/display toggling setClicky = function(hiding){ if(hiding){ $clicky.html('<span>+</span>'); - $clicky[0].className = 'toc_open'; + $handle.addClass('closed'); + $handle.removeClass('open'); }else{ - $clicky.html('<span>−</span>'); - $clicky[0].className = 'toc_close'; + $clicky.html('<span>−</span>'); + $handle.addClass('open'); + $handle.removeClass('closed'); } }; - $clicky = jQuery(document.createElement('span')) - .attr('id','toc__toggle'); - $header.css('cursor','pointer') - .click(function () { - var hidden; + $handle[0].setState = function(state){ + var hidden; + if(!state) state = 1; + + // Assert that content instantly takes the whole space + $content.css('min-height', $content.height()).show(); - // Assert that $toc instantly takes the whole TOC space - $toc.css('height', $toc.height()).show(); + // stop any running animation + $child.stop(true, true); - hidden = $tocul.stop(true, true).is(':hidden'); + // was a state given or do we toggle? + if(state === -1) { + hidden = false; + } else if(state === 1) { + hidden = true; + } else { + hidden = $child.is(':hidden'); + } + + // update the state + setClicky(!hidden); + + // Start animation and assure that $toc is hidden/visible + $child.dw_toggle(hidden, function () { + $content.toggle(hidden); + $content.css('min-height',''); // remove min-height again + }); + }; - setClicky(!hidden); + // the state indicator + $clicky = jQuery(document.createElement('strong')); - // Start animation and assure that $toc is hidden/visible - $tocul.dw_toggle(hidden, function () { - $toc.toggle(hidden); - }); - }) + // click function + $handle.css('cursor','pointer') + .click($handle[0].setState) .prepend($clicky); - setClicky(); + // initial state + $handle[0].setState(state); } }; |