Skip to content
Snippets Groups Projects
Commit 5382ed1a authored by Andreas Gohr's avatar Andreas Gohr
Browse files

aliased some vars in linkwiz for brevity

parent 6d23f6ac
No related branches found
No related tags found
No related merge requests found
......@@ -176,16 +176,17 @@ var dw_linkwiz = {
* Handles the "click" on a given result anchor
*/
resultClick: function(a){
var L = dw_linkwiz;
var id = a.title;
if(id == '' || id.substr(id.length-1) == ':'){
dw_linkwiz.entry.value = id;
dw_linkwiz.autocomplete_exec();
L.entry.value = id;
L.autocomplete_exec();
}else{
dw_linkwiz.entry.value = id;
L.entry.value = id;
if(a.nextSibling && a.nextSibling.tagName == 'SPAN'){
dw_linkwiz.insertLink(a.nextSibling.innerHTML);
L.insertLink(a.nextSibling.innerHTML);
}else{
dw_linkwiz.insertLink('');
L.insertLink('');
}
}
},
......@@ -197,10 +198,12 @@ var dw_linkwiz = {
* as link title instead
*/
insertLink: function(title){
if(!dw_linkwiz.entry.value) return;
var L = dw_linkwiz;
var E = L.entry;
if(!E.value) return;
var sel = getSelection(dw_linkwiz.textArea);
if(sel.start == 0 && sel.end == 0) sel = dw_linkwiz.selection;
var sel = getSelection(L.textArea);
if(sel.start == 0 && sel.end == 0) sel = L.selection;
var stxt = sel.getText();
......@@ -213,22 +216,22 @@ var dw_linkwiz = {
if(!stxt && !DOKU_UHC) stxt=title;
// prepend colon inside namespaces for non namespace pages
if(dw_linkwiz.textArea.form['id'].value.indexOf(':') != -1 &&
dw_linkwiz.entry.value.indexOf(':') == -1){
dw_linkwiz.entry.value = ':'+dw_linkwiz.entry.value;
if(L.textArea.form['id'].value.indexOf(':') != -1 &&
E.value.indexOf(':') == -1){
E.value = ':'+E.value;
}
var link = '[['+dw_linkwiz.entry.value+'|';
var link = '[['+E.value+'|';
if(stxt) link += stxt;
link += ']]';
var so = dw_linkwiz.entry.value.length+3;
var so = E.value.length+3;
var eo = 2;
pasteText(sel,link,{startofs: so, endofs: eo});
dw_linkwiz.hide();
L.hide();
// reset the entry to the parent namespace and remove : at the beginning
dw_linkwiz.entry.value = dw_linkwiz.entry.value.replace(/(^:)?[^:]*$/, '');
E.value = E.value.replace(/(^:)?[^:]*$/, '');
},
/**
......@@ -268,32 +271,25 @@ var dw_linkwiz = {
},
/**
* Clears the result area
* @fixme localize
*/
clear: function(){
dw_linkwiz.result.innerHTML = 'Search for a matching page name above, or browse through the pages on the right';
dw_linkwiz.entry.value = '';
},
/**
* Show the dw_linkwizard
* Show the link wizard
*/
show: function(){
dw_linkwiz.selection = getSelection(dw_linkwiz.textArea);
dw_linkwiz.$wiz.css('marginLeft', '0');
dw_linkwiz.$wiz.css('marginTop', '0');
dw_linkwiz.entry.focus();
dw_linkwiz.autocomplete();
var L = dw_linkwiz;
L.selection = getSelection(dw_linkwiz.textArea);
L.$wiz.css('marginLeft', '0');
L.$wiz.css('marginTop', '0');
L.entry.focus();
L.autocomplete();
},
/**
* Hide the link wizard
*/
hide: function(){
dw_linkwiz.$wiz.css('marginLeft', '-10000px');
dw_linkwiz.$wiz.css('marginTop', '-10000px');
dw_linkwiz.textArea.focus();
var L = dw_linkwiz;
L.$wiz.css('marginLeft', '-10000px');
L.$wiz.css('marginTop', '-10000px');
L.textArea.focus();
},
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment