summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Lang <mail@adrianlang.de>2011-09-04 15:32:41 +0200
committerAdrian Lang <mail@adrianlang.de>2011-09-04 15:33:26 +0200
commit1ffc211ddb46bfabe649bbacd1e36bc8e035afa3 (patch)
treedb38e999923c38efe5dab72c013ce0c985d9d4b5
parentba6c070edd92ca0fc8a6ee85d51769d64a19ee7c (diff)
downloadrpg-1ffc211ddb46bfabe649bbacd1e36bc8e035afa3.tar.gz
rpg-1ffc211ddb46bfabe649bbacd1e36bc8e035afa3.tar.bz2
Revert tmp commits
This reverts commit ba6c070edd92ca0fc8a6ee85d51769d64a19ee7c. This reverts commit 923510088dda99cb2790b15308593e47369d4f01.
-rw-r--r--inc/search.php19
-rw-r--r--lib/exe/js.php1
-rw-r--r--lib/scripts/compatibility.js2
-rw-r--r--lib/scripts/edit.js221
-rw-r--r--lib/scripts/index.js3
-rw-r--r--lib/scripts/linkwiz.js4
-rw-r--r--lib/scripts/media.js3
-rw-r--r--lib/scripts/qsearch.js3
-rw-r--r--lib/scripts/script.js5
-rw-r--r--lib/scripts/toolbar.js35
-rw-r--r--lib/scripts/tree.js3
-rw-r--r--lib/styles/screen.css5
12 files changed, 161 insertions, 143 deletions
diff --git a/inc/search.php b/inc/search.php
index 5ba28a1fc..bc7c35482 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 d52fe3607..e96d45ee6 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 3b027f016..39f703c71 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 fe8e4eb78..816568e92 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 4b67a0b12..96d4e2fb9 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 0cad86cc2..83653c9bb 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 b49454492..1402ad4bf 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 c7128b9e3..f83b7a5a1 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 709e7705a..8db223d61 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 7a113ecbf..2306ef5db 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 96763053d..98d3f55d4 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 461b3098f..80a161f19 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;
-}