diff --git a/inc/search.php b/inc/search.php index 5ba28a1fc837e566ca23501a9441c632e3e12c3c..bc7c35482ce74e35f8e7b4760a8f199baf022da2 100644 --- a/inc/search.php +++ b/inc/search.php @@ -596,25 +596,6 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ if($opts['firsthead']) $item['title'] = p_get_first_heading($item['id'],METADATA_DONT_RENDER); } - if($type == 'd' && !$opts['skipacl'] && $opts['sneakyacl'] && $item['perm'] < AUTH_READ) { - if ($opts['sneakyacl'] === 2) { - // Perform shy sneaking, i. e. just show the ns if it contains - // something accessible - $old_data_count = count($data); - search($data,$base,'search_universal',$opts,$file,$lvl+1); - if (count($data) > $old_data_count) { - // Contains something visible - array_splice($data, $old_data_count, $return ? 0 : count($data), - array($item)); - } else { - // Contains nothing visible, so hide - $data = array_slice($data, 0, $old_data_count); - } - } - // Stop recursing in any case since we did it ourself - return false; - } - // finally add the item $data[] = $item; return $return; diff --git a/lib/exe/js.php b/lib/exe/js.php index d52fe3607da560f626aab64a4523702fb5fc9f41..e96d45ee6607e56084f3558fa75ce590924cb2dd 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -86,7 +86,6 @@ function js_out(){ // add some global variables print "var DOKU_BASE = '".DOKU_BASE."';"; print "var DOKU_TPL = '".DOKU_TPL."';"; - // FIXME: Move those to JSINFO print "var DOKU_UHN = ".((int) useHeading('navigation')).";"; print "var DOKU_UHC = ".((int) useHeading('content')).";"; diff --git a/lib/scripts/compatibility.js b/lib/scripts/compatibility.js index 3b027f0161573a37f4d34b17230a7f8b277a44e9..39f703c7104c0492aedd47ee383f94e68ffb1b33 100644 --- a/lib/scripts/compatibility.js +++ b/lib/scripts/compatibility.js @@ -38,7 +38,7 @@ function DEPRECATED_WRAP(func, context) { return function () { DEPRECATED(); return func.apply(context || this, arguments); - }; + } } /** diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index fe8e4eb7849266e0639226cad0a5dab6e57f1a27..816568e9239395d928bd5b97b3059c38e436e9e2 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -14,36 +14,38 @@ * @author Michal Rezler <m.rezler@centrum.cz> */ function createToolButton(icon,label,key,id,classname){ - var $btn = jQuery(document.createElement('button')), - $ico = jQuery(document.createElement('img')); + var $ = jQuery; + var btn = $('<button>'); + var ico = $('<img />'); - // prepare the basic button stuff - $btn.addClass('toolbutton'); + // preapare the basic button stuff + btn.attr('class', 'toolbutton'); if(classname){ - $btn.addClass(classname); + btn.attr('class', 'toolbutton '+classname); } - $btn.attr('title', label); + btn.attr('title', label); if(key){ - $btn.attr('title', label + ' ['+key.toUpperCase()+']') + btn.attr('title', label + ' ['+key.toUpperCase()+']') .attr('accessKey', key); } // set IDs if given if(id){ - $btn.attr('id', id); - $ico.attr('id', id+'_ico'); + btn.attr('id', id); + ico.attr('id', id+'_ico'); } // create the icon and add it to the button - if(icon.substr(0,1) !== '/'){ - icon = DOKU_BASE + 'lib/images/toolbar/' + icon; + if(icon.substr(0,1) == '/'){ + ico.attr('src', icon); + }else{ + ico.attr('src', DOKU_BASE+'lib/images/toolbar/'+icon); } - $ico.attr('src', icon); - $btn.append($ico); + btn.append(ico); - // we have to return a DOM object (for compatibility reasons) - return $btn[0]; + // we have to return a javascript object (for compatibility reasons) + return btn[0]; } /** @@ -61,51 +63,69 @@ function createToolButton(icon,label,key,id,classname){ * @author Andreas Gohr <andi@splitbrain.org> */ function createPicker(id,props,edid){ + var icobase = props['icobase']; + var list = props['list']; + var $ = jQuery; + // create the wrapping div - var $picker = jQuery(document.createElement('div')); + var picker = $('<div></div>'); - $picker.addClass('picker hiddenpicker'); + var className = 'picker'; if(props['class']){ - $picker.addClass(props['class']); + className += ' '+props['class']; } - $picker.attr('id', id).css('position', 'absolute'); - - function $makebutton(title) { - var $btn = jQuery(document.createElement('button')) - .addClass('pickerbutton').attr('title', title) - .bind('click', bind(pickerInsert, title, edid)) - .appendTo($picker); - return $btn; - } + picker.attr('class', className) + .attr('id', id) + .css('position', 'absolute') + .css('marginLeft', '-10000px') // no display:none, to keep access keys working + .css('marginTop', '-10000px'); - jQuery.each(props.list, function (key, item) { - if (!props.list.hasOwnProperty(key)) { - return; - } + for(var key in list){ + if (!list.hasOwnProperty(key)) continue; if(isNaN(key)){ - // associative array -> treat as text => image pairs - if (item.substr(0,1) !== '/') { - item = DOKU_BASE+'lib/images/'+props.icobase+'/'+item; + // associative array -> treat as image/value pairs + var btn = $('<button>'); + btn.attr('class', 'pickerbutton') + .attr('title', key); + + var ico = $('<img>'); + if (list[key].substr(0,1) == '/') { + var src = list[key]; + } else { + var src = DOKU_BASE+'lib/images/'+icobase+'/'+list[key]; } - jQuery(document.createElement('img')) - .attr('src', item) - .appendTo($makebutton(key)); - }else if (typeof item == 'string'){ + + ico.attr('src', src); + btn.append(ico); + + btn.bind('click', bind(pickerInsert, key, edid)); + picker.append(btn); + }else if (typeof (list[key]) == 'string'){ // a list of text -> treat as text picker - $makebutton(item).text(item); + var btn = $('<button>'); + btn.attr('class', 'pickerbutton') + .attr('title', list[key]); + + var txt = $(document.createTextNode(list[key])); + btn.append(txt); + + btn.bind('click', bind(pickerInsert, list[key], edid)); + + picker.append(btn); }else{ // a list of lists -> treat it as subtoolbar - initToolbar($picker,edid,props.list); - return false; // all buttons handled already + initToolbar(picker,edid,list); + break; // all buttons handled already } - }); - jQuery('body').append($picker); + } + var body = $('body'); + body.append(picker); - // we have to return a DOM object (for compatibility reasons) - return $picker[0]; + // we have to return a javascript object (for compatibility reasons) + return picker[0]; } /** @@ -127,9 +147,9 @@ function pickerInsert(text,edid){ * @return boolean If button should be appended * @author Gabriel Birke <birke@d-scribe.de> */ -function addBtnActionSignature($btn, props, edid) { - if(typeof SIG != 'undefined' && SIG != ''){ - $btn.bind('click', bind(insertAtCarret,edid,SIG)); +function addBtnActionSignature(btn, props, edid) { + if(typeof(SIG) != 'undefined' && SIG != ''){ + btn.bind('click', bind(insertAtCarret,edid,SIG)); return true; } return false; @@ -141,27 +161,24 @@ function addBtnActionSignature($btn, props, edid) { * @author Andreas Gohr <gohr@cosmocode.de> */ function currentHeadlineLevel(textboxId){ - var field = jQuery('#' + textboxId)[0], - s = false, - opts = [field.value.substr(0,getSelection(field).start)]; - if (field.form.prefix) { + var field = $(textboxId); + var selection = getSelection(field); + var search = "\n"+field.value.substr(0,selection.start); + var lasthl = search.lastIndexOf("\n=="); + if(lasthl == -1 && field.form.prefix){ // we need to look in prefix context - opts.push(field.form.prefix.value); + search = field.form.prefix.value; + lasthl = search.lastIndexOf("\n=="); } + search = search.substr(lasthl+1,6); - jQuery.each(opts, function (_, opt) { - // Check whether there is a headline in the given string - var str = "\n" + opt, - lasthl = str.lastIndexOf("\n=="); - if (lasthl !== -1) { - s = str.substr(lasthl+1,6); - return false; - } - }); - if (s === false) { - return 0; - } - return 7 - s.match(/^={2,6}/)[0].length; + if(search == '======') return 1; + if(search.substr(0,5) == '=====') return 2; + if(search.substr(0,4) == '====') return 3; + if(search.substr(0,3) == '===') return 4; + if(search.substr(0,2) == '==') return 5; + + return 0; } @@ -174,23 +191,21 @@ window.textChanged = false; * Delete the draft before leaving the page */ function deleteDraft() { - if (is_opera || window.keepDraft) { - return; - } - - var $dwform = jQuery('#dw__editform'); - - if($dwform.length === 0) { - return; - } + if (is_opera) return; + if (window.keepDraft) return; // remove a possibly saved draft using ajax - jQuery.post(DOKU_BASE + 'lib/exe/ajax.php', - { - call: 'draftdel', - id: $dwform.find('input[name=id]').val() - } - ); + var dwform = jQuery('#dw__editform'); + if(dwform.length != 0) { + + jQuery.post( + DOKU_BASE + 'lib/exe/ajax.php', + { + call: 'draftdel', + id: jQuery('#dw__editform input[name=id]').val() + } + ); + } } /** @@ -199,24 +214,21 @@ function deleteDraft() { * * Sets focus to the editbox as well */ -jQuery(function () { - var $editform = jQuery('#dw__editform'); - if ($editform.length == 0) { - return; - } +addInitEvent(function () { + var $ = jQuery; + var editform = $('#dw__editform'); + if (editform.length == 0) return; - var $edit_text = jQuery('#wiki__text'); - if ($edit_text.length > 0) { - if($edit_text.attr('readOnly')) { - return; - } + var edit_text = $('#wiki__text'); + if (edit_text.length > 0) { + if(edit_text.attr('readOnly')) return; // set focus and place cursor at the start - var sel = getSelection($edit_text[0]); + var sel = getSelection(edit_text.get(0)); sel.start = 0; sel.end = 0; setSelection(sel); - $edit_text.focus(); + edit_text.focus(); } var checkfunc = function() { @@ -224,8 +236,8 @@ jQuery(function () { summaryCheck(); }; - $editform.change(checkfunc); - $editform.keydown(checkfunc); + editform.change(checkfunc); + editform.keydown(checkfunc); window.onbeforeunload = function(){ if(window.textChanged) { @@ -235,13 +247,13 @@ jQuery(function () { window.onunload = deleteDraft; // reset change memory var on submit - jQuery('#edbtn__save').click( + $('#edbtn__save').click( function() { window.onbeforeunload = ''; textChanged = false; } ); - jQuery('#edbtn__preview').click( + $('#edbtn__preview').click( function() { window.onbeforeunload = ''; textChanged = false; @@ -249,9 +261,9 @@ jQuery(function () { } ); - var $summary = jQuery('#edit__summary'); - $summary.change(summaryCheck); - $summary.keyup(summaryCheck); + var summary = $('#edit__summary'); + summary.change(summaryCheck); + summary.keyup(summaryCheck); if (textChanged) summaryCheck(); }); @@ -262,6 +274,11 @@ jQuery(function () { * @author Andreas Gohr <andi@splitbrain.org> */ function summaryCheck(){ - var $sum = jQuery('#edit__summary'); - $sum.toggleClass('missing', $sum.val() === ''); + var sum = jQuery('#edit__summary'); + + if (sum.val() === '') { + sum.attr('class', 'missing'); + } else{ + sum.attr('class', 'edit'); + } } diff --git a/lib/scripts/index.js b/lib/scripts/index.js index 4b67a0b12d7736d17187d4612fe2650fd19a1bfb..96d4e2fb97e10eba907839cb5e71a8df409b839b 100644 --- a/lib/scripts/index.js +++ b/lib/scripts/index.js @@ -1,3 +1,6 @@ +/*jslint white: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: false, newcap: true, immed: true */ +/*global jQuery, window, DOKU_BASE, DEPRECATED, bind*/ + var dw_index = jQuery('#index__tree').dw_tree({deferInit: true, load_data: function (show_sublist, $clicky) { jQuery.post( diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index 0cad86cc29d6bd6dc642c87d9d69cf6ae7dc1a00..83653c9bb09db5f4b8ff956cebb76b4855e03e31 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -1,3 +1,7 @@ +/*jslint sloppy: true, indent: 4, white: true, browser: true, eqeq: true */ +/*global jQuery, DOKU_BASE, LANG, DOKU_UHC, getSelection, pasteText */ + + /** * The Link Wizard * diff --git a/lib/scripts/media.js b/lib/scripts/media.js index b4945449296b8d3ebafbee0dd876b4f4f75c93a8..1402ad4bf569e7217de0f840bda5555d30faed55 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -1,3 +1,6 @@ +/*jslint white: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: false, strict: true, newcap: true, immed: true, sloppy: true, browser: true */ +/*global jQuery, DOKU_BASE, LANG, bind, DokuCookie, opener, confirm*/ + /** * JavaScript functionality for the media management popup * diff --git a/lib/scripts/qsearch.js b/lib/scripts/qsearch.js index c7128b9e34f07dfb1fe6b5241bd835c4a5082483..f83b7a5a118267583deace6fa5dfb1786ea19e1d 100644 --- a/lib/scripts/qsearch.js +++ b/lib/scripts/qsearch.js @@ -1,3 +1,6 @@ +/*jslint sloppy: true, plusplus: true, continue: true */ +/*global jQuery, DOKU_BASE, window, document, substr_replace */ + /** * AJAX functions for the pagename quicksearch * diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 709e7705a0254f135ec613c092c5533550023749..8db223d612019bc7e9d710ab54b7cd006457cbd3 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -48,7 +48,8 @@ function showLoadBar(){ * @author Andreas Gohr <andi@splitbrain.org> */ function hideLoadBar(id){ - jQuery('#' + id).hide(); + obj = $(id); + if(obj) obj.style.display="none"; } /** @@ -57,3 +58,5 @@ function hideLoadBar(id){ function closePopups(){ jQuery('div.JSpopup').hide(); } + + diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 7a113ecbfa57d413ddb3f4149f78c412a6e073c7..2306ef5db6a7b8f0e9694d605eafdccb308c5d65 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -1,3 +1,4 @@ + // used to identify pickers var pickercounter=0; @@ -201,13 +202,13 @@ function tb_autohead(btn, props, edid){ * @return boolean If button should be appended * @author Gabriel Birke <birke@d-scribe.de> */ -function addBtnActionPicker($btn, props, edid) { +function addBtnActionPicker(btn, props, edid) { var pickerid = 'picker'+(pickercounter++); createPicker(pickerid, props, edid); - $btn.click( + btn.click( function() { - pickerToggle(pickerid,$btn); + pickerToggle(pickerid,btn); return false; } ); @@ -239,17 +240,19 @@ function addBtnActionLinkwiz(btn, props, edid) { * * @author Andreas Gohr <andi@splitbrain.org> */ -function pickerToggle(pickerid,$btn){ - var $picker = jQuery('#' + pickerid); - if ($picker.hasClass('hiddenpicker')) { - var pos = $btn.offset(); - $picker.hide().removeClass('hiddenpicker') - .dw_show() - .offset({left: pos.left+3, top: pos.top+$btn[0].offsetHeight+3}) +function pickerToggle(pickerid,btn){ + var picker = jQuery('#' + pickerid); + if (picker.css('marginLeft') == '-10000px'){ + var x = findPosX(btn[0]); + var y = findPosY(btn[0]); + + picker.css('left',(x+3)+'px') + .css('top', (y+btn[0].offsetHeight+3)+'px') + .css('marginLeft', '0px') + .css('marginTop', '0px'); } else { - $picker.dw_hide(function () { - jQuery(this).addClass('hiddenpicker').show(); - }); + picker.css('marginLeft', '-10000px') + .css('marginTop', '-10000px'); } } @@ -259,7 +262,11 @@ function pickerToggle(pickerid,$btn){ * @author Andreas Gohr <andi@splitbrain.org> */ function pickerClose(){ - jQuery('.picker').addClass('hiddenpicker'); + var pobjs = jQuery('#picker'); + for(var i=0; i<pobjs.length; i++){ + pobjs[i].css('marginLeft', '-10000px') + .css('marginTop', '-10000px'); + } } diff --git a/lib/scripts/tree.js b/lib/scripts/tree.js index 96763053d87d04d52a87be74c3c748a8a915963a..98d3f55d4c22baca99693847c65a8b843a4d1f23 100644 --- a/lib/scripts/tree.js +++ b/lib/scripts/tree.js @@ -1,3 +1,6 @@ +/*jslint white: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: false, newcap: true, immed: true, sloppy: true */ +/*global jQuery, window, DOKU_BASE, DEPRECATED, bind*/ + jQuery.fn.dw_tree = function(overrides) { var dw_tree = { diff --git a/lib/styles/screen.css b/lib/styles/screen.css index 461b3098fd3ff178382086ec563961648fb82458..80a161f1911bbc4a0d3a699912d92637e226fc80 100644 --- a/lib/styles/screen.css +++ b/lib/styles/screen.css @@ -87,8 +87,3 @@ div.notify { .code .st0 { color: #ff0000; } .code .sy0 { color: #66cc66; } -div.hiddenpicker { - /* No display: none to keep accesskeys working */ - margin-left: -10000px; - margin-top: -10000px; -}