diff options
-rw-r--r-- | inc/html.php | 61 | ||||
-rw-r--r-- | inc/parser/handler.php | 5 | ||||
-rw-r--r-- | inc/parser/renderer.php | 2 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 3 | ||||
-rw-r--r-- | lib/scripts/drag.js | 55 | ||||
-rw-r--r-- | lib/scripts/edit.js | 5 | ||||
-rw-r--r-- | lib/scripts/script.js | 41 | ||||
-rw-r--r-- | lib/scripts/toolbar.js | 4 | ||||
-rw-r--r-- | lib/tpl/default/design.css | 4 |
9 files changed, 117 insertions, 63 deletions
diff --git a/inc/html.php b/inc/html.php index 29dddbe74..8a215f440 100644 --- a/inc/html.php +++ b/inc/html.php @@ -91,14 +91,18 @@ function html_secedit_button($matches){ global $ID; global $INFO; - $section = $matches[2]; - $name = $matches[1]; + $edittarget = ($matches[1] === 'SECTION') ? 'plain' : + strtolower($matches[1]); + + $section = $matches[3]; + $name = $matches[2]; $secedit = ''; - $secedit .= '<div class="secedit">'; + $secedit .= '<div class="secedit editbutton_' . $edittarget . '">'; $secedit .= html_btn('secedit',$ID,'', array('do' => 'edit', - 'lines' => "$section", + 'lines' => $section, + 'edittarget' => $edittarget, 'rev' => $INFO['lastmod']), 'post', $name); $secedit .= '</div>'; @@ -113,11 +117,13 @@ function html_secedit_button($matches){ function html_secedit($text,$show=true){ global $INFO; + $regexp = '#<!-- ([A-Z]+) (?:"(.*)" )?\[(\d+-\d*)\] -->#'; + if($INFO['writable'] && $show && !$INFO['rev']){ - $text = preg_replace_callback('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#', + $text = preg_replace_callback($regexp, 'html_secedit_button', $text); }else{ - $text = preg_replace('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#','',$text); + $text = preg_replace($regexp,'',$text); } return $text; @@ -181,7 +187,7 @@ function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ $tip = htmlspecialchars($label); } - $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; + $ret .= '<input type="submit" value="'.hsc($label).'" class="button" '; if($akey){ $tip .= ' ['.strtoupper($akey).']'; $ret .= 'accesskey="'.$akey.'" '; @@ -1104,11 +1110,9 @@ function html_updateprofile(){ } /** - * This displays the edit form (lots of logic included) + * Preprocess edit form data * - * @fixme this is a huge lump of code and should be modularized * @triggers HTML_PAGE_FROMTEMPLATE - * @triggers HTML_EDITFORM_INJECTION * @author Andreas Gohr <andi@splitbrain.org> */ function html_edit($text=null,$include='edit'){ //FIXME: include needed? @@ -1122,7 +1126,6 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? global $SUM; global $lang; global $conf; - global $license; //set summary default if(!$SUM){ @@ -1176,20 +1179,44 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? print p_locale_xhtml('read'); } if(!$DATE) $DATE = $INFO['lastmod']; - ?> - <div style="width:99%;"> - <div class="toolbar"> - <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.dformat();?></div> - <div id="tool__bar"><?php if($wr){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" - target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> + $data = compact('wr', 'text', 'mod', 'check'); + trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); +} +/** + * Display the default edit form + * + * Is the default action for HTML_EDIT_FORMSELECTION. + * + * @triggers HTML_EDITFORM_OUTPUT + */ +function html_edit_form($param) { + extract($param); + global $conf; + global $license; + global $lang; + global $REV; + global $DATE; + global $PRE; + global $SUF; + global $INFO; + global $SUM; + global $ID; + ?> <?php if($wr){?> <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!-- <?php /* sets changed to true when previewed */?> textChanged = <?php ($mod) ? print 'true' : print 'false' ?>; //--><!]]></script> <?php } ?> + <div style="width:99%;"> + + <div class="toolbar"> + <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.dformat();?></div> + <div id="tool__bar"><?php if($wr){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" + target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> + </div> <?php $form = new Doku_Form(array('id' => 'dw__editform')); diff --git a/inc/parser/handler.php b/inc/parser/handler.php index eaa42f9bf..ea5a69b35 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -589,10 +589,11 @@ class Doku_Handler { } else { $this->_addCall('tablecell', array(), $pos); } + $this->status['table_begin'] = $pos; break; case DOKU_LEXER_EXIT: - $this->_addCall('table_end', array(), $pos); + $this->_addCall('table_end', array($this->status['table_begin']+1, $pos), $pos); $this->CallWriter->process(); $ReWriter = & $this->CallWriter; $this->CallWriter = & $ReWriter->CallWriter; @@ -1222,7 +1223,7 @@ class Doku_Handler_Table { } function tableEnd($call) { - $this->tableCalls[] = array('table_close',array(),$call[2]); + $this->tableCalls[] = array('table_close',$call[1],$call[2]); $this->finalizeTable(); } diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 6082e935d..65dcaf8a1 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -233,7 +233,7 @@ class Doku_Renderer extends DokuWiki_Plugin { function table_open($maxcols = NULL, $numrows = NULL){} - function table_close(){} + function table_close($begin, $end){} function tablerow_open(){} diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 20acf4281..4e848ec1d 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -851,8 +851,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= '<table class="inline">'.DOKU_LF; } - function table_close(){ + function table_close($begin, $end){ $this->doc .= '</table>'.DOKU_LF; + $this->doc .= '<!-- TABLE ['. $begin .'-'.$end.'] -->'; } function tablerow_open(){ diff --git a/lib/scripts/drag.js b/lib/scripts/drag.js index 4726b77de..fa249a996 100644 --- a/lib/scripts/drag.js +++ b/lib/scripts/drag.js @@ -1,8 +1,9 @@ /** * Makes a DOM object draggable * - * This is currently for movable DOM dialogs only. If needed it could be - * extended to execute callbacks on special events... + * If you just want to move objects around, use drag.attach. For full + * customization, drag can be used as a javascript prototype, it is + * inheritance-aware. * * @link http://nofunc.org/Drag_Drop/ */ @@ -26,33 +27,36 @@ var drag = { attach: function (obj,handle) { if(handle){ handle.dragobject = obj; - addEvent($(handle),'mousedown',drag.start); }else{ - addEvent($(obj),'mousedown',drag.start); + handle = obj; } + var _this = this; + addEvent($(handle),'mousedown',function (e) {return _this.start(e); }); }, /** * Starts the dragging operation */ start: function (e){ - drag.handle = e.target; - if(drag.handle.dragobject){ - drag.obj = drag.handle.dragobject; + this.handle = e.target; + if(this.handle.dragobject){ + this.obj = this.handle.dragobject; }else{ - drag.obj = drag.handle; + this.obj = this.handle; } - drag.handle.className += ' ondrag'; - drag.obj.className += ' ondrag'; + this.handle.className += ' ondrag'; + this.obj.className += ' ondrag'; - drag.oX = parseInt(drag.obj.style.left); - drag.oY = parseInt(drag.obj.style.top); - drag.eX = drag.evX(e); - drag.eY = drag.evY(e); + this.oX = parseInt(this.obj.style.left); + this.oY = parseInt(this.obj.style.top); + this.eX = drag.evX(e); + this.eY = drag.evY(e); - addEvent(document,'mousemove',drag.drag); - addEvent(document,'mouseup',drag.stop); + var _this = this; + this.mousehandlers = [function (e) {return _this.drag(e);}, function (e) {return _this.stop(e);}]; + addEvent(document,'mousemove', this.mousehandlers[0]); + addEvent(document,'mouseup', this.mousehandlers[1]); e.preventDefault(); e.stopPropagation(); @@ -63,21 +67,21 @@ var drag = { * Ends the dragging operation */ stop: function(){ - drag.handle.className = drag.handle.className.replace(/ ?ondrag/,''); - drag.obj.className = drag.obj.className.replace(/ ?ondrag/,''); - removeEvent(document,'mousemove',drag.drag); - removeEvent(document,'mouseup',drag.stop); - drag.obj = null; - drag.handle = null; + this.handle.className = this.handle.className.replace(/ ?ondrag/,''); + this.obj.className = this.obj.className.replace(/ ?ondrag/,''); + removeEvent(document,'mousemove', this.mousehandlers[0]); + removeEvent(document,'mouseup', this.mousehandlers[1]); + this.obj = null; + this.handle = null; }, /** * Moves the object during the dragging operation */ drag: function(e) { - if(drag.obj) { - drag.obj.style.top = (drag.evY(e)+drag.oY-drag.eY+'px'); - drag.obj.style.left = (drag.evX(e)+drag.oX-drag.eX+'px'); + if(this.obj) { + this.obj.style.top = (this.evY(e)+this.oY-this.eY+'px'); + this.obj.style.left = (this.evX(e)+this.oX-this.eX+'px'); } }, @@ -96,4 +100,3 @@ var drag = { } }; - diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index a80c8a06e..7b30ddca4 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -12,12 +12,15 @@ * * @author Andreas Gohr <andi@splitbrain.org> */ -function createToolButton(icon,label,key,id){ +function createToolButton(icon,label,key,id,classname){ var btn = document.createElement('button'); var ico = document.createElement('img'); // preapare the basic button stuff btn.className = 'toolbutton'; + if(classname){ + btn.className += ' '+classname; + } btn.title = label; if(key){ btn.title += ' ['+key.toUpperCase()+']'; diff --git a/lib/scripts/script.js b/lib/scripts/script.js index ccba82144..b611f980a 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -538,24 +538,41 @@ addInitEvent(function(){ var break_classes = new RegExp('secedit|toc|page'); var btns = getElementsByClass('btn_secedit',document,'form'); for(var i=0; i<btns.length; i++){ - addEvent(btns[i],'mouseover',function(e){ - var tgt = e.target; - if(tgt.form) tgt = tgt.form; - tgt = tgt.parentNode.previousSibling; - if(tgt.nodeName != "DIV") tgt = tgt.previousSibling; - while(!break_classes.test(tgt.className)) { - tgt.className += ' section_highlight'; - if (tgt.tagName == 'H1') break; - tgt = (tgt.previousSibling != null) ? tgt.previousSibling : tgt.parentNode; - } - }); + switch(btns[i].parentNode.className.match(/editbutton_(\w+)/)[1]) { + case 'plain': + addEvent(btns[i],'mouseover',function(e){ + var tgt = e.target.form.parentNode; + do { + tgt = tgt.previousSibling; + } while (tgt && !tgt.tagName); + if (!tgt) return; + if(tgt.nodeName != "DIV") tgt = tgt.previousSibling; + while(!break_classes.test(tgt.className)) { + tgt.className += ' section_highlight'; + if (tgt.tagName == 'H1') break; + tgt = (tgt.previousSibling != null) ? tgt.previousSibling : tgt.parentNode; + } + }); + break; + + case 'table': + addEvent(btns[i],'mouseover',function(e){ + var tgt = e.target.form.parentNode; + do { + tgt = tgt.previousSibling; + } while (tgt && !tgt.tagName); + if (tgt && tgt.tagName === 'TABLE') { + tgt.className += ' section_highlight'; + } + }); + break; + } addEvent(btns[i],'mouseout',function(e){ var secs = getElementsByClass('section_highlight'); for(var j=0; j<secs.length; j++){ secs[j].className = secs[j].className.replace(/section_highlight/,''); } - var secs = getElementsByClass('section_highlight'); }); } }); diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 1e4a91864..99ad1bb9c 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -27,7 +27,9 @@ function initToolbar(tbid,edid,tb){ // create new button var btn = createToolButton(tb[i]['icon'], tb[i]['title'], - tb[i]['key']); + tb[i]['key'], + tb[i]['id'], + tb[i]['class']); // type is a tb function -> assign it as onclick diff --git a/lib/tpl/default/design.css b/lib/tpl/default/design.css index 9c3e7b119..cd4d03e43 100644 --- a/lib/tpl/default/design.css +++ b/lib/tpl/default/design.css @@ -741,8 +741,8 @@ div.dokuwiki ul.search_quickhits li { width: 30%; } -div.dokuwiki div.section_highlight { - background-color: __background_alt__; +div.dokuwiki .section_highlight { + background-color: __background_alt__ !important; } /* ------------------ Additional ---------------------- */ |