From aa5d3d8e43bc72ed30ab9279f6160d0d4fe2df49 Mon Sep 17 00:00:00 2001 From: Pierre Spring Date: Sun, 10 Oct 2010 20:57:08 +0200 Subject: minimaly jQueryfied link wizard --- lib/scripts/linkwiz.js | 581 +++++++++++++++++++++++++------------------------ 1 file changed, 301 insertions(+), 280 deletions(-) (limited to 'lib/scripts/linkwiz.js') diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index e4e92cdd2..fe880728a 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -2,293 +2,314 @@ * The Link Wizard * * @author Andreas Gohr + * @author Pierre Spring */ -var linkwiz = { - wiz: null, - entry: null, - result: null, - timer: null, - sack: null, - textArea: null, - selected: -1, - selection: null, - - /** - * Initialize the linkwizard by creating the needed HTML - * and attaching the eventhandlers - */ - init: function(textArea){ - // prepare AJAX object - linkwiz.sack = new sack(DOKU_BASE + 'lib/exe/ajax.php'); - linkwiz.sack.AjaxFailedAlert = ''; - linkwiz.sack.encodeURIString = false; - - // create HTML Structure - linkwiz.wiz = document.createElement('div'); - linkwiz.wiz.id = 'link__wiz'; - linkwiz.wiz.className = 'picker'; - linkwiz.wiz.style.top = (findPosY(textArea)+20)+'px'; - linkwiz.wiz.style.left = (findPosX(textArea)+80)+'px'; - linkwiz.wiz.style.marginLeft = '-10000px'; - linkwiz.wiz.style.marginTop = '-10000px'; - - linkwiz.wiz.innerHTML = - ''+ - '
'+LANG['linkto']+'
'+ - ''; - $('dw__editform').parentNode.appendChild(linkwiz.wiz); - linkwiz.textArea = textArea; - linkwiz.result = $('link__wiz_result'); - linkwiz.entry = $('link__wiz_entry'); - - // attach event handlers - var obj; - obj = $('link__wiz_close'); - obj.onclick = linkwiz.hide; - - linkwiz.sack.elementObj = linkwiz.result; - addEvent(linkwiz.entry,'keyup',linkwiz.onEntry); - addEvent(linkwiz.result,'click',linkwiz.onResultClick); - drag.attach(linkwiz.wiz,$('link__wiz_header')); - }, - - /** - * handle all keyup events in the entry field - */ - onEntry: function(e){ - if(e.keyCode == 37 || e.keyCode == 39){ //left/right - return true; //ignore - } - if(e.keyCode == 27){ - linkwiz.hide(); - e.preventDefault(); - e.stopPropagation(); - return false; - } - if(e.keyCode == 38){ //Up - linkwiz.select(linkwiz.selected -1); - e.preventDefault(); - e.stopPropagation(); - return false; - } - if(e.keyCode == 40){ //Down - linkwiz.select(linkwiz.selected +1); - e.preventDefault(); - e.stopPropagation(); - return false; - } - if(e.keyCode == 13){ //Enter - if(linkwiz.selected > -1){ - var obj = linkwiz.getResult(linkwiz.selected); +(function($){ + $.fn.extend({ + linkwiz: function(editor) { + + var wiz; + var entry; + var result + var timer; + var textArea; + var selected; + var selection; + + /** + * Initialize the linkwizard by creating the needed HTML + * and attaching the eventhandlers + */ + var init = function(textAreaElement){ + + // create HTML Structure + wiz = document.createElement('div'); + wiz.id = 'link__wiz'; + wiz.className = 'picker'; + wiz.style.top = (findPosY(textAreaElement)+20)+'px'; + wiz.style.left = (findPosX(textAreaElement)+80)+'px'; + wiz.style.marginLeft = '-10000px'; + wiz.style.marginTop = '-10000px'; + + wiz.innerHTML = + ''+ + '
'+LANG['linkto']+'
'+ + ''; + $('#dw__editform')[0].parentNode.appendChild(wiz); + textArea = textAreaElement; + result = $('#link__wiz_result')[0]; + entry = $('#link__wiz_entry')[0]; + + // attach event handlers + var obj; + var obj = $('#link__wiz_close')[0]; + obj.onclick = hide; + + addEvent(entry,'keyup',onEntry); + addEvent(result,'click',onResultClick); + drag.attach(wiz,$('#link__wiz_header')[0]); + }; + + /** + * handle all keyup events in the entry field + */ + var onEntry = function(e){ + if(e.keyCode == 37 || e.keyCode == 39){ //left/right + return true; //ignore + } + if(e.keyCode == 27){ + hide(); + e.preventDefault(); + e.stopPropagation(); + return false; + } + if(e.keyCode == 38){ //Up + select(selected -1); + e.preventDefault(); + e.stopPropagation(); + return false; + } + if(e.keyCode == 40){ //Down + select(selected +1); + e.preventDefault(); + e.stopPropagation(); + return false; + } + if(e.keyCode == 13){ //Enter + if(selected > -1){ + var obj = getResult(selected); + if(obj){ + var a = $(obj).find('a')[0]; + resultClick(a); + } + }else if(entry.value){ + insertLink(entry.value); + } + + e.preventDefault(); + e.stopPropagation(); + return false; + } + autocomplete(); + }; + + /** + * Get one of the result by index + * + * @param int result div to return + * @returns DOMObject or null + */ + var getResult = function(num){ + var obj; + var childs = $(result).find('div'); + var obj = childs[num]; if(obj){ - var a = obj.getElementsByTagName('A')[0]; - linkwiz.resultClick(a); + return obj; + }else{ + return null; + } + }; + + /** + * Select the given result + */ + var select = function(num){ + if(num < 0){ + deselect(); + return; } - }else if(linkwiz.entry.value){ - linkwiz.insertLink(linkwiz.entry.value); - } - e.preventDefault(); - e.stopPropagation(); - return false; - } - linkwiz.autocomplete(); - }, - - /** - * Get one of the result by index - * - * @param int result div to return - * @returns DOMObject or null - */ - getResult: function(num){ - var obj; - var childs = linkwiz.result.getElementsByTagName('DIV'); - obj = childs[num]; - if(obj){ - return obj; - }else{ - return null; - } - }, - - /** - * Select the given result - */ - select: function(num){ - if(num < 0){ - linkwiz.deselect(); - return; - } + var obj = getResult(num); + if(obj){ + deselect(); + obj.className += ' selected'; + + // make sure the item is viewable in the scroll view + // FIXME check IE compatibility + if(obj.offsetTop > result.scrollTop + result.clientHeight){ + result.scrollTop += obj.clientHeight; + }else if(obj.offsetTop - result.clientHeight < result.scrollTop){ // this works but isn't quite right, fixes welcome + result.scrollTop -= obj.clientHeight; + } + // now recheck - if still not in view, the user used the mouse to scroll + if( (obj.offsetTop > result.scrollTop + result.clientHeight) || + (obj.offsetTop < result.scrollTop) ){ + obj.scrollIntoView(); + } + + selected = num; + } + }; + + /** + * deselect a result if any is selected + */ + var deselect = function(){ + if(selected > -1){ + var obj = getResult(selected); + if(obj){ + obj.className = obj.className.replace(/ ?selected/,''); + } + } + selected = -1; + }; + + /** + * Handle clicks in the result set an dispatch them to + * resultClick() + */ + var onResultClick = function(e){ + if(e.target.tagName != 'A') return; + e.stopPropagation(); + e.preventDefault(); + resultClick(e.target); + return false; + }; + + /** + * Handles the "click" on a given result anchor + */ + var resultClick = function(a){ + var id = a.title; + if(id == '' || id.substr(id.length-1) == ':'){ + entry.value = id; + autocomplete_exec(); + }else{ + entry.value = id; + if(a.nextSibling && a.nextSibling.tagName == 'SPAN'){ + insertLink(a.nextSibling.innerHTML); + }else{ + insertLink(''); + } + } + }; + + /** + * Insert the id currently in the entry box to the textarea, + * replacing the current selection or at the curso postion. + * When no selection is available the given title will be used + * as link title instead + */ + var insertLink = function(title){ + if(!entry.value) return; + + var sel = getSelection(textArea); + if(sel.start == 0 && sel.end == 0) sel = selection; + + var stxt = sel.getText(); + + // don't include trailing space in selection + if(stxt.charAt(stxt.length - 1) == ' '){ + sel.end--; + var stxt = sel.getText(); + } - var obj = linkwiz.getResult(num); - if(obj){ - linkwiz.deselect(); - obj.className += ' selected'; - - // make sure the item is viewable in the scroll view - // FIXME check IE compatibility - if(obj.offsetTop > linkwiz.result.scrollTop + linkwiz.result.clientHeight){ - linkwiz.result.scrollTop += obj.clientHeight; - }else if(obj.offsetTop - linkwiz.result.clientHeight < linkwiz.result.scrollTop){ // this works but isn't quite right, fixes welcome - linkwiz.result.scrollTop -= obj.clientHeight; - } - // now recheck - if still not in view, the user used the mouse to scroll - if( (obj.offsetTop > linkwiz.result.scrollTop + linkwiz.result.clientHeight) || - (obj.offsetTop < linkwiz.result.scrollTop) ){ - obj.scrollIntoView(); - } - - linkwiz.selected = num; - } - }, - - /** - * deselect a result if any is selected - */ - deselect: function(){ - if(linkwiz.selected > -1){ - var obj = linkwiz.getResult(linkwiz.selected); - if(obj){ - obj.className = obj.className.replace(/ ?selected/,''); - } - } - linkwiz.selected = -1; - }, - - /** - * Handle clicks in the result set an dispatch them to - * resultClick() - */ - onResultClick: function(e){ - if(e.target.tagName != 'A') return; - e.stopPropagation(); - e.preventDefault(); - linkwiz.resultClick(e.target); - return false; - }, - - /** - * Handles the "click" on a given result anchor - */ - resultClick: function(a){ - var id = a.title; - if(id == '' || id.substr(id.length-1) == ':'){ - linkwiz.entry.value = id; - linkwiz.autocomplete_exec(); - }else{ - linkwiz.entry.value = id; - if(a.nextSibling && a.nextSibling.tagName == 'SPAN'){ - linkwiz.insertLink(a.nextSibling.innerHTML); - }else{ - linkwiz.insertLink(''); - } - } - }, - - /** - * Insert the id currently in the entry box to the textarea, - * replacing the current selection or at the curso postion. - * When no selection is available the given title will be used - * as link title instead - */ - insertLink: function(title){ - if(!linkwiz.entry.value) return; - - var sel = getSelection(linkwiz.textArea); - if(sel.start == 0 && sel.end == 0) sel = linkwiz.selection; - - var stxt = sel.getText(); - - // don't include trailing space in selection - if(stxt.charAt(stxt.length - 1) == ' '){ - sel.end--; - stxt = sel.getText(); - } + if(!stxt && !DOKU_UHC) stxt=title; - if(!stxt && !DOKU_UHC) stxt=title; + // prepend colon inside namespaces for non namespace pages + if(textArea.form['id'].value.indexOf(':') != -1 && + entry.value.indexOf(':') == -1){ + entry.value = ':'+entry.value; + } - // prepend colon inside namespaces for non namespace pages - if(linkwiz.textArea.form['id'].value.indexOf(':') != -1 && - linkwiz.entry.value.indexOf(':') == -1){ - linkwiz.entry.value = ':'+linkwiz.entry.value; - } + var link = '[['+entry.value+'|'; + if(stxt) link += stxt; + link += ']]'; + + var so = entry.value.length+3; + var eo = 2; + + pasteText(sel,link,{startofs: so, endofs: eo}); + hide(); + // reset the entry to the parent namespace and remove : at the beginning + entry.value = entry.value.replace(/(^:)?[^:]*$/, ''); + }; + + /** + * Start the page/namespace lookup timer + * + * Calls autocomplete_exec when the timer runs out + */ + var autocomplete = function(){ + if(timer !== null){ + window.clearTimeout(timer); + timer = null; + } - var link = '[['+linkwiz.entry.value+'|'; - if(stxt) link += stxt; - link += ']]'; - - var so = linkwiz.entry.value.length+3; - var eo = 2; - - pasteText(sel,link,{startofs: so, endofs: eo}); - linkwiz.hide(); - // reset the entry to the parent namespace and remove : at the beginning - linkwiz.entry.value = linkwiz.entry.value.replace(/(^:)?[^:]*$/, ''); - }, - - /** - * Start the page/namespace lookup timer - * - * Calls autocomplete_exec when the timer runs out - */ - autocomplete: function(){ - if(linkwiz.timer !== null){ - window.clearTimeout(linkwiz.timer); - linkwiz.timer = null; - } + timer = window.setTimeout(autocomplete_exec,350); + }; + + /** + * Executes the AJAX call for the page/namespace lookup + */ + var autocomplete_exec = function(){ + deselect(); + result.innerHTML = ''; + + // because we need to use POST, we + // can not use the .load() function. + $.post( + DOKU_BASE + 'lib/exe/ajax.php', + { + call: 'linkwiz', + q: entry.value + }, + function (data) { + result.innerHTML = data; + }, + 'html' + ); + }; + + /** + * Clears the result area + */ + var clear = function(){ + result.innerHTML = 'Search for a matching page name above, or browse through the pages on the right'; + entry.value = ''; + }; + + /** + * Show the linkwizard + */ + var show = function(){ + selection = getSelection(textArea); + wiz.style.marginLeft = '0px'; + wiz.style.marginTop = '0px'; + entry.focus(); + autocomplete(); + }; + + /** + * Hide the link wizard + */ + var hide = function(){ + wiz.style.marginLeft = '-10000px'; + wiz.style.marginTop = '-10000px'; + textArea.focus(); + }; + + /** + * Toggle the link wizard + */ + var toggle = function(){ + if(wiz.style.marginLeft == '-10000px'){ + show(); + }else{ + hide(); + } + }; - linkwiz.timer = window.setTimeout(linkwiz.autocomplete_exec,350); - }, - - /** - * Executes the AJAX call for the page/namespace lookup - */ - autocomplete_exec: function(){ - linkwiz.deselect(); - linkwiz.result.innerHTML = ''; - linkwiz.sack.runAJAX('call=linkwiz&q='+encodeURI(linkwiz.entry.value)); - }, - - /** - * Clears the result area - */ - clear: function(){ - linkwiz.result.innerHTML = 'Search for a matching page name above, or browse through the pages on the right'; - linkwiz.entry.value = ''; - }, - - /** - * Show the linkwizard - */ - show: function(){ - linkwiz.selection = getSelection(linkwiz.textArea); - linkwiz.wiz.style.marginLeft = '0px'; - linkwiz.wiz.style.marginTop = '0px'; - linkwiz.entry.focus(); - linkwiz.autocomplete(); - }, - - /** - * Hide the link wizard - */ - hide: function(){ - linkwiz.wiz.style.marginLeft = '-10000px'; - linkwiz.wiz.style.marginTop = '-10000px'; - linkwiz.textArea.focus(); - }, - - /** - * Toggle the link wizard - */ - toggle: function(){ - if(linkwiz.wiz.style.marginLeft == '-10000px'){ - linkwiz.show(); - }else{ - linkwiz.hide(); - } - } -}; + init($(editor)[0]); + return this.each(function() { + $(this).click(function (e) { + e.preventDefault(); + toggle(); + }); + }); + } + }); +})(jQuery); \ No newline at end of file -- cgit v1.2.3 From c4bb7947fcb2d4a5e5f8a15d9e3bbec333e44e13 Mon Sep 17 00:00:00 2001 From: Pierre Spring Date: Sun, 10 Oct 2010 23:42:56 +0200 Subject: Got rid of drag.js and added jQuery UI instead. --- lib/scripts/linkwiz.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/scripts/linkwiz.js') diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index fe880728a..6130bbf4c 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -49,7 +49,9 @@ addEvent(entry,'keyup',onEntry); addEvent(result,'click',onResultClick); - drag.attach(wiz,$('#link__wiz_header')[0]); + + $(wiz).draggable({handle: '#link__wiz_header'}); + }; /** -- cgit v1.2.3 From 2bcca88a344ad5112322fb2533dceefb8757619a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 8 Jul 2011 00:22:27 +0200 Subject: some initial refactoring of the linkwizard --- lib/scripts/linkwiz.js | 601 ++++++++++++++++++++++++------------------------- 1 file changed, 297 insertions(+), 304 deletions(-) (limited to 'lib/scripts/linkwiz.js') diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index e9a1d71b3..9ad72626d 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -1,319 +1,312 @@ +/*jslint sloppy: true, indent: 4, white: true, browser: true, eqeq: true */ +/*global jQuery, DOKU_BASE, LANG, DOKU_UHC, getSelection, pasteText */ + + /** * The Link Wizard * * @author Andreas Gohr * @author Pierre Spring */ -(function($){ - $.fn.extend({ - linkwiz: function(editor) { - - var wiz; - var entry; - var result; - var timer; - var textArea; - var selected; - var selection; - - /** - * Initialize the linkwizard by creating the needed HTML - * and attaching the eventhandlers - */ - var init = function(textAreaElement){ - - - // create HTML Structure - wiz = document.createElement('div'); - wiz.style.position = 'absolute'; - wiz.id = 'link__wiz'; - wiz.className = 'picker'; - wiz.style.top = (findPosY(textAreaElement)+20)+'px'; - wiz.style.left = (findPosX(textAreaElement)+80)+'px'; - wiz.style.marginLeft = '-10000px'; - wiz.style.marginTop = '-10000px'; - - wiz.innerHTML = - ''+ - '
'+LANG['linkto']+'
'+ - ''; - $('#dw__editform')[0].parentNode.appendChild(wiz); - textArea = textAreaElement; - result = $('#link__wiz_result')[0]; - entry = $('#link__wiz_entry')[0]; - - // attach event handlers - var obj; - var obj = $('#link__wiz_close')[0]; - obj.onclick = hide; - - addEvent(entry,'keyup',onEntry); - addEvent(result,'click',onResultClick); - - $(wiz).draggable({handle: '#link__wiz_header'}); - - }; - - /** - * handle all keyup events in the entry field - */ - var onEntry = function(e){ - if(e.keyCode == 37 || e.keyCode == 39){ //left/right - return true; //ignore - } - if(e.keyCode == 27){ - hide(); - e.preventDefault(); - e.stopPropagation(); - return false; - } - if(e.keyCode == 38){ //Up - select(selected -1); - e.preventDefault(); - e.stopPropagation(); - return false; - } - if(e.keyCode == 40){ //Down - select(selected +1); - e.preventDefault(); - e.stopPropagation(); - return false; - } - if(e.keyCode == 13){ //Enter - if(selected > -1){ - var obj = getResult(selected); - if(obj){ - var a = $(obj).find('a')[0]; - resultClick(a); - } - }else if(entry.value){ - insertLink(entry.value); - } - - e.preventDefault(); - e.stopPropagation(); - return false; - } - autocomplete(); - }; - - /** - * Get one of the result by index - * - * @param int result div to return - * @returns DOMObject or null - */ - var getResult = function(num){ - var obj; - var childs = $(result).find('div'); - var obj = childs[num]; +var linkwiz = { + $wiz: null, + entry: null, + result: null, + timer: null, + textArea: null, + selected: null, + selection: null, + + /** + * Initialize the linkwizard by creating the needed HTML + * and attaching the eventhandlers + */ + init: function($editor){ + // position relative to the text area + var pos = $editor.position(); + pos.left += 20; + pos.right += 80; + + // create HTML Structure + linkwiz.$wiz = jQuery(document.createElement('div')) + .attr('id','link__wiz') + .css({ + 'position': 'absolute', + 'top': pos.left+'px', + 'left': pos.top+'px', + 'margin-left': '-10000px', + 'margin-top': '-10000px' + }) + .html( + ''+ + '
'+LANG.linkto+'
'+ + '' + ) + .addClass('picker'); + + $editor[0].form.parentNode.appendChild(linkwiz.$wiz[0]); + linkwiz.textArea = $editor[0]; + linkwiz.result = jQuery('#link__wiz_result')[0]; + linkwiz.entry = jQuery('#link__wiz_entry')[0]; + + // attach event handlers + jQuery('#link__wiz_close').click(linkwiz.hide); + jQuery(linkwiz.entry).keyup(linkwiz.onEntry); + jQuery(linkwiz.result).click(linkwiz.onResultClick); + + linkwiz.$wiz.draggable({handle: '#link__wiz_header'}); + }, + + /** + * handle all keyup events in the entry field + */ + onEntry: function(e){ + if(e.keyCode == 37 || e.keyCode == 39){ //left/right + return true; //ignore + } + if(e.keyCode == 27){ + linkwiz.hide(); + e.preventDefault(); + e.stopPropagation(); + return false; + } + if(e.keyCode == 38){ //Up + linkwiz.select(linkwiz.selected -1); + e.preventDefault(); + e.stopPropagation(); + return false; + } + if(e.keyCode == 40){ //Down + linkwiz.select(linkwiz.selected +1); + e.preventDefault(); + e.stopPropagation(); + return false; + } + if(e.keyCode == 13){ //Enter + if(linkwiz.selected > -1){ + var obj = linkwiz.getResult(linkwiz.selected); if(obj){ - return obj; - }else{ - return null; - } - }; - - /** - * Select the given result - */ - var select = function(num){ - if(num < 0){ - deselect(); - return; + var a = jQuery(obj).find('a')[0]; + linkwiz.resultClick(a); } + }else if(linkwiz.entry.value){ + linkwiz.insertLink(linkwiz.entry.value); + } - var obj = getResult(num); - if(obj){ - deselect(); - obj.className += ' selected'; - - // make sure the item is viewable in the scroll view - // FIXME check IE compatibility - if(obj.offsetTop > result.scrollTop + result.clientHeight){ - result.scrollTop += obj.clientHeight; - }else if(obj.offsetTop - result.clientHeight < result.scrollTop){ // this works but isn't quite right, fixes welcome - result.scrollTop -= obj.clientHeight; - } - // now recheck - if still not in view, the user used the mouse to scroll - if( (obj.offsetTop > result.scrollTop + result.clientHeight) || - (obj.offsetTop < result.scrollTop) ){ - obj.scrollIntoView(); - } - - selected = num; - } - }; - - /** - * deselect a result if any is selected - */ - var deselect = function(){ - if(selected > -1){ - var obj = getResult(selected); - if(obj){ - obj.className = obj.className.replace(/ ?selected/,''); - } - } - selected = -1; - }; - - /** - * Handle clicks in the result set an dispatch them to - * resultClick() - */ - var onResultClick = function(e){ - if(e.target.tagName != 'A') return; - e.stopPropagation(); - e.preventDefault(); - resultClick(e.target); - return false; - }; - - /** - * Handles the "click" on a given result anchor - */ - var resultClick = function(a){ - var id = a.title; - if(id == '' || id.substr(id.length-1) == ':'){ - entry.value = id; - autocomplete_exec(); - }else{ - entry.value = id; - if(a.nextSibling && a.nextSibling.tagName == 'SPAN'){ - insertLink(a.nextSibling.innerHTML); - }else{ - insertLink(''); - } - } - }; - - /** - * Insert the id currently in the entry box to the textarea, - * replacing the current selection or at the curso postion. - * When no selection is available the given title will be used - * as link title instead - */ - var insertLink = function(title){ - if(!entry.value) return; - - var sel = getSelection(textArea); - if(sel.start == 0 && sel.end == 0) sel = selection; - - var stxt = sel.getText(); - - // don't include trailing space in selection - if(stxt.charAt(stxt.length - 1) == ' '){ - sel.end--; - var stxt = sel.getText(); - } - - if(!stxt && !DOKU_UHC) stxt=title; + e.preventDefault(); + e.stopPropagation(); + return false; + } + linkwiz.autocomplete(); + }, + + /** + * Get one of the results by index + * + * @param int result div to return + * @returns DOMObject or null + */ + getResult: function(num){ + var childs = jQuery(linkwiz.result).find('div'); + var obj = childs[num]; + if(obj){ + return obj; + }else{ + return null; + } + }, + + /** + * Select the given result + */ + select: function(num){ + if(num < 0){ + linkwiz.deselect(); + return; + } - // prepend colon inside namespaces for non namespace pages - if(textArea.form['id'].value.indexOf(':') != -1 && - entry.value.indexOf(':') == -1){ - entry.value = ':'+entry.value; - } + var obj = linkwiz.getResult(num); + if(obj){ + linkwiz.deselect(); + obj.className += ' selected'; + + // make sure the item is viewable in the scroll view + // FIXME check IE compatibility + if(obj.offsetTop > linkwiz.result.scrollTop + linkwiz.result.clientHeight){ + linkwiz.result.scrollTop += obj.clientHeight; + }else if(obj.offsetTop - linkwiz.result.clientHeight < linkwiz.result.scrollTop){ // this works but isn't quite right, fixes welcome + linkwiz.result.scrollTop -= obj.clientHeight; + } + // now recheck - if still not in view, the user used the mouse to scroll + if( (obj.offsetTop > linkwiz.result.scrollTop + linkwiz.result.clientHeight) || + (obj.offsetTop < linkwiz.result.scrollTop) ){ + obj.scrollIntoView(); + } + + linkwiz.selected = num; + } + }, + + /** + * deselect a result if any is selected + */ + deselect: function(){ + if(linkwiz.selected > -1){ + var obj = linkwiz.getResult(linkwiz.selected); + if(obj){ + obj.className = obj.className.replace(/ ?selected/,''); + } + } + linkwiz.selected = -1; + }, + + /** + * Handle clicks in the result set an dispatch them to + * resultClick() + */ + onResultClick: function(e){ + if(e.target.tagName != 'A') return; + e.stopPropagation(); + e.preventDefault(); + linkwiz.resultClick(e.target); + return false; + }, + + /** + * Handles the "click" on a given result anchor + */ + resultClick: function(a){ + var id = a.title; + if(id == '' || id.substr(id.length-1) == ':'){ + linkwiz.entry.value = id; + linkwiz.autocomplete_exec(); + }else{ + linkwiz.entry.value = id; + if(a.nextSibling && a.nextSibling.tagName == 'SPAN'){ + linkwiz.insertLink(a.nextSibling.innerHTML); + }else{ + linkwiz.insertLink(''); + } + } + }, + + /** + * Insert the id currently in the entry box to the textarea, + * replacing the current selection or at the cursor position. + * When no selection is available the given title will be used + * as link title instead + */ + insertLink: function(title){ + if(!linkwiz.entry.value) return; + + var sel = getSelection(linkwiz.textArea); + if(sel.start == 0 && sel.end == 0) sel = linkwiz.selection; + + var stxt = sel.getText(); + + // don't include trailing space in selection + if(stxt.charAt(stxt.length - 1) == ' '){ + sel.end--; + stxt = sel.getText(); + } - var link = '[['+entry.value+'|'; - if(stxt) link += stxt; - link += ']]'; - - var so = entry.value.length+3; - var eo = 2; - - pasteText(sel,link,{startofs: so, endofs: eo}); - hide(); - // reset the entry to the parent namespace and remove : at the beginning - entry.value = entry.value.replace(/(^:)?[^:]*$/, ''); - }; - - /** - * Start the page/namespace lookup timer - * - * Calls autocomplete_exec when the timer runs out - */ - var autocomplete = function(){ - if(timer !== null){ - window.clearTimeout(timer); - timer = null; - } + if(!stxt && !DOKU_UHC) stxt=title; - timer = window.setTimeout(autocomplete_exec,350); - }; - - /** - * Executes the AJAX call for the page/namespace lookup - */ - var autocomplete_exec = function(){ - deselect(); - result.innerHTML = ''; - - // because we need to use POST, we - // can not use the .load() function. - $.post( - DOKU_BASE + 'lib/exe/ajax.php', - { - call: 'linkwiz', - q: entry.value - }, - function (data) { - result.innerHTML = data; - }, - 'html' - ); - }; - - /** - * Clears the result area - */ - var clear = function(){ - result.innerHTML = 'Search for a matching page name above, or browse through the pages on the right'; - entry.value = ''; - }; - - /** - * Show the linkwizard - */ - var show = function(){ - selection = getSelection(textArea); - wiz.style.marginLeft = '0px'; - wiz.style.marginTop = '0px'; - entry.focus(); - autocomplete(); - }; - - /** - * Hide the link wizard - */ - var hide = function(){ - wiz.style.marginLeft = '-10000px'; - wiz.style.marginTop = '-10000px'; - textArea.focus(); - }; - - /** - * Toggle the link wizard - */ - var toggle = function(){ - if(wiz.style.marginLeft == '-10000px'){ - show(); - }else{ - hide(); - } - }; + // prepend colon inside namespaces for non namespace pages + if(linkwiz.textArea.form['id'].value.indexOf(':') != -1 && + linkwiz.entry.value.indexOf(':') == -1){ + linkwiz.entry.value = ':'+linkwiz.entry.value; + } - init($(editor)[0]); + var link = '[['+linkwiz.entry.value+'|'; + if(stxt) link += stxt; + link += ']]'; + + var so = linkwiz.entry.value.length+3; + var eo = 2; + + pasteText(sel,link,{startofs: so, endofs: eo}); + linkwiz.hide(); + // reset the entry to the parent namespace and remove : at the beginning + linkwiz.entry.value = linkwiz.entry.value.replace(/(^:)?[^:]*$/, ''); + }, + + /** + * Start the page/namespace lookup timer + * + * Calls autocomplete_exec when the timer runs out + */ + autocomplete: function(){ + if(linkwiz.timer !== null){ + window.clearTimeout(linkwiz.timer); + linkwiz.timer = null; + } - return this.each(function() { - $(this).click(function (e) { - e.preventDefault(); - toggle(); - }); - }); + linkwiz.timer = window.setTimeout(linkwiz.autocomplete_exec,350); + }, + + /** + * Executes the AJAX call for the page/namespace lookup + */ + autocomplete_exec: function(){ + linkwiz.deselect(); + linkwiz.result.innerHTML = ''; + + // because we need to use POST, we + // can not use the .load() function. + jQuery.post( + DOKU_BASE + 'lib/exe/ajax.php', + { + call: 'linkwiz', + q: linkwiz.entry.value + }, + function (data) { + linkwiz.result.innerHTML = data; + }, + 'html' + ); + }, + + /** + * Clears the result area + * @fixme localize + */ + clear: function(){ + linkwiz.result.innerHTML = 'Search for a matching page name above, or browse through the pages on the right'; + linkwiz.entry.value = ''; + }, + + /** + * Show the linkwizard + */ + show: function(){ + linkwiz.selection = getSelection(linkwiz.textArea); + linkwiz.$wiz.css('marginLeft', '0'); + linkwiz.$wiz.css('marginTop', '0'); + linkwiz.entry.focus(); + linkwiz.autocomplete(); + }, + + /** + * Hide the link wizard + */ + hide: function(){ + linkwiz.$wiz.css('marginLeft', '-10000px'); + linkwiz.$wiz.css('marginTop', '-10000px'); + linkwiz.textArea.focus(); + }, + + /** + * Toggle the link wizard + */ + toggle: function(){ + if(linkwiz.$wiz.css('marginLeft') == '-10000px'){ + linkwiz.show(); + }else{ + linkwiz.hide(); } - }); -})(jQuery); + } + +}; -- cgit v1.2.3 From d57b00771430e5ae76d25920e2a49d8a0adda651 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 8 Jul 2011 11:39:45 +0200 Subject: renamed linkwiz object --- lib/scripts/linkwiz.js | 144 ++++++++++++++++++++++++------------------------- 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'lib/scripts/linkwiz.js') diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index 9ad72626d..14fa33795 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -8,7 +8,7 @@ * @author Andreas Gohr * @author Pierre Spring */ -var linkwiz = { +var dw_linkwiz = { $wiz: null, entry: null, result: null, @@ -18,7 +18,7 @@ var linkwiz = { selection: null, /** - * Initialize the linkwizard by creating the needed HTML + * Initialize the dw_linkwizard by creating the needed HTML * and attaching the eventhandlers */ init: function($editor){ @@ -28,7 +28,7 @@ var linkwiz = { pos.right += 80; // create HTML Structure - linkwiz.$wiz = jQuery(document.createElement('div')) + dw_linkwiz.$wiz = jQuery(document.createElement('div')) .attr('id','link__wiz') .css({ 'position': 'absolute', @@ -46,17 +46,17 @@ var linkwiz = { ) .addClass('picker'); - $editor[0].form.parentNode.appendChild(linkwiz.$wiz[0]); - linkwiz.textArea = $editor[0]; - linkwiz.result = jQuery('#link__wiz_result')[0]; - linkwiz.entry = jQuery('#link__wiz_entry')[0]; + $editor[0].form.parentNode.appendChild(dw_linkwiz.$wiz[0]); + dw_linkwiz.textArea = $editor[0]; + dw_linkwiz.result = jQuery('#link__wiz_result')[0]; + dw_linkwiz.entry = jQuery('#link__wiz_entry')[0]; // attach event handlers - jQuery('#link__wiz_close').click(linkwiz.hide); - jQuery(linkwiz.entry).keyup(linkwiz.onEntry); - jQuery(linkwiz.result).click(linkwiz.onResultClick); + jQuery('#link__wiz_close').click(dw_linkwiz.hide); + jQuery(dw_linkwiz.entry).keyup(dw_linkwiz.onEntry); + jQuery(dw_linkwiz.result).click(dw_linkwiz.onResultClick); - linkwiz.$wiz.draggable({handle: '#link__wiz_header'}); + dw_linkwiz.$wiz.draggable({handle: '#link__wiz_header'}); }, /** @@ -67,39 +67,39 @@ var linkwiz = { return true; //ignore } if(e.keyCode == 27){ - linkwiz.hide(); + dw_linkwiz.hide(); e.preventDefault(); e.stopPropagation(); return false; } if(e.keyCode == 38){ //Up - linkwiz.select(linkwiz.selected -1); + dw_linkwiz.select(dw_linkwiz.selected -1); e.preventDefault(); e.stopPropagation(); return false; } if(e.keyCode == 40){ //Down - linkwiz.select(linkwiz.selected +1); + dw_linkwiz.select(dw_linkwiz.selected +1); e.preventDefault(); e.stopPropagation(); return false; } if(e.keyCode == 13){ //Enter - if(linkwiz.selected > -1){ - var obj = linkwiz.getResult(linkwiz.selected); + if(dw_linkwiz.selected > -1){ + var obj = dw_linkwiz.getResult(dw_linkwiz.selected); if(obj){ var a = jQuery(obj).find('a')[0]; - linkwiz.resultClick(a); + dw_linkwiz.resultClick(a); } - }else if(linkwiz.entry.value){ - linkwiz.insertLink(linkwiz.entry.value); + }else if(dw_linkwiz.entry.value){ + dw_linkwiz.insertLink(dw_linkwiz.entry.value); } e.preventDefault(); e.stopPropagation(); return false; } - linkwiz.autocomplete(); + dw_linkwiz.autocomplete(); }, /** @@ -109,7 +109,7 @@ var linkwiz = { * @returns DOMObject or null */ getResult: function(num){ - var childs = jQuery(linkwiz.result).find('div'); + var childs = jQuery(dw_linkwiz.result).find('div'); var obj = childs[num]; if(obj){ return obj; @@ -123,29 +123,29 @@ var linkwiz = { */ select: function(num){ if(num < 0){ - linkwiz.deselect(); + dw_linkwiz.deselect(); return; } - var obj = linkwiz.getResult(num); + var obj = dw_linkwiz.getResult(num); if(obj){ - linkwiz.deselect(); + dw_linkwiz.deselect(); obj.className += ' selected'; // make sure the item is viewable in the scroll view // FIXME check IE compatibility - if(obj.offsetTop > linkwiz.result.scrollTop + linkwiz.result.clientHeight){ - linkwiz.result.scrollTop += obj.clientHeight; - }else if(obj.offsetTop - linkwiz.result.clientHeight < linkwiz.result.scrollTop){ // this works but isn't quite right, fixes welcome - linkwiz.result.scrollTop -= obj.clientHeight; + if(obj.offsetTop > dw_linkwiz.result.scrollTop + dw_linkwiz.result.clientHeight){ + dw_linkwiz.result.scrollTop += obj.clientHeight; + }else if(obj.offsetTop - dw_linkwiz.result.clientHeight < dw_linkwiz.result.scrollTop){ // this works but isn't quite right, fixes welcome + dw_linkwiz.result.scrollTop -= obj.clientHeight; } // now recheck - if still not in view, the user used the mouse to scroll - if( (obj.offsetTop > linkwiz.result.scrollTop + linkwiz.result.clientHeight) || - (obj.offsetTop < linkwiz.result.scrollTop) ){ + if( (obj.offsetTop > dw_linkwiz.result.scrollTop + dw_linkwiz.result.clientHeight) || + (obj.offsetTop < dw_linkwiz.result.scrollTop) ){ obj.scrollIntoView(); } - linkwiz.selected = num; + dw_linkwiz.selected = num; } }, @@ -153,13 +153,13 @@ var linkwiz = { * deselect a result if any is selected */ deselect: function(){ - if(linkwiz.selected > -1){ - var obj = linkwiz.getResult(linkwiz.selected); + if(dw_linkwiz.selected > -1){ + var obj = dw_linkwiz.getResult(dw_linkwiz.selected); if(obj){ obj.className = obj.className.replace(/ ?selected/,''); } } - linkwiz.selected = -1; + dw_linkwiz.selected = -1; }, /** @@ -170,7 +170,7 @@ var linkwiz = { if(e.target.tagName != 'A') return; e.stopPropagation(); e.preventDefault(); - linkwiz.resultClick(e.target); + dw_linkwiz.resultClick(e.target); return false; }, @@ -180,14 +180,14 @@ var linkwiz = { resultClick: function(a){ var id = a.title; if(id == '' || id.substr(id.length-1) == ':'){ - linkwiz.entry.value = id; - linkwiz.autocomplete_exec(); + dw_linkwiz.entry.value = id; + dw_linkwiz.autocomplete_exec(); }else{ - linkwiz.entry.value = id; + dw_linkwiz.entry.value = id; if(a.nextSibling && a.nextSibling.tagName == 'SPAN'){ - linkwiz.insertLink(a.nextSibling.innerHTML); + dw_linkwiz.insertLink(a.nextSibling.innerHTML); }else{ - linkwiz.insertLink(''); + dw_linkwiz.insertLink(''); } } }, @@ -199,10 +199,10 @@ var linkwiz = { * as link title instead */ insertLink: function(title){ - if(!linkwiz.entry.value) return; + if(!dw_linkwiz.entry.value) return; - var sel = getSelection(linkwiz.textArea); - if(sel.start == 0 && sel.end == 0) sel = linkwiz.selection; + var sel = getSelection(dw_linkwiz.textArea); + if(sel.start == 0 && sel.end == 0) sel = dw_linkwiz.selection; var stxt = sel.getText(); @@ -215,22 +215,22 @@ var linkwiz = { if(!stxt && !DOKU_UHC) stxt=title; // prepend colon inside namespaces for non namespace pages - if(linkwiz.textArea.form['id'].value.indexOf(':') != -1 && - linkwiz.entry.value.indexOf(':') == -1){ - linkwiz.entry.value = ':'+linkwiz.entry.value; + if(dw_linkwiz.textArea.form['id'].value.indexOf(':') != -1 && + dw_linkwiz.entry.value.indexOf(':') == -1){ + dw_linkwiz.entry.value = ':'+dw_linkwiz.entry.value; } - var link = '[['+linkwiz.entry.value+'|'; + var link = '[['+dw_linkwiz.entry.value+'|'; if(stxt) link += stxt; link += ']]'; - var so = linkwiz.entry.value.length+3; + var so = dw_linkwiz.entry.value.length+3; var eo = 2; pasteText(sel,link,{startofs: so, endofs: eo}); - linkwiz.hide(); + dw_linkwiz.hide(); // reset the entry to the parent namespace and remove : at the beginning - linkwiz.entry.value = linkwiz.entry.value.replace(/(^:)?[^:]*$/, ''); + dw_linkwiz.entry.value = dw_linkwiz.entry.value.replace(/(^:)?[^:]*$/, ''); }, /** @@ -239,20 +239,20 @@ var linkwiz = { * Calls autocomplete_exec when the timer runs out */ autocomplete: function(){ - if(linkwiz.timer !== null){ - window.clearTimeout(linkwiz.timer); - linkwiz.timer = null; + if(dw_linkwiz.timer !== null){ + window.clearTimeout(dw_linkwiz.timer); + dw_linkwiz.timer = null; } - linkwiz.timer = window.setTimeout(linkwiz.autocomplete_exec,350); + dw_linkwiz.timer = window.setTimeout(dw_linkwiz.autocomplete_exec,350); }, /** * Executes the AJAX call for the page/namespace lookup */ autocomplete_exec: function(){ - linkwiz.deselect(); - linkwiz.result.innerHTML = ''; + dw_linkwiz.deselect(); + dw_linkwiz.result.innerHTML = ''; // because we need to use POST, we // can not use the .load() function. @@ -260,10 +260,10 @@ var linkwiz = { DOKU_BASE + 'lib/exe/ajax.php', { call: 'linkwiz', - q: linkwiz.entry.value + q: dw_linkwiz.entry.value }, function (data) { - linkwiz.result.innerHTML = data; + dw_linkwiz.result.innerHTML = data; }, 'html' ); @@ -274,38 +274,38 @@ var linkwiz = { * @fixme localize */ clear: function(){ - linkwiz.result.innerHTML = 'Search for a matching page name above, or browse through the pages on the right'; - linkwiz.entry.value = ''; + 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 linkwizard + * Show the dw_linkwizard */ show: function(){ - linkwiz.selection = getSelection(linkwiz.textArea); - linkwiz.$wiz.css('marginLeft', '0'); - linkwiz.$wiz.css('marginTop', '0'); - linkwiz.entry.focus(); - linkwiz.autocomplete(); + 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(); }, /** * Hide the link wizard */ hide: function(){ - linkwiz.$wiz.css('marginLeft', '-10000px'); - linkwiz.$wiz.css('marginTop', '-10000px'); - linkwiz.textArea.focus(); + dw_linkwiz.$wiz.css('marginLeft', '-10000px'); + dw_linkwiz.$wiz.css('marginTop', '-10000px'); + dw_linkwiz.textArea.focus(); }, /** * Toggle the link wizard */ toggle: function(){ - if(linkwiz.$wiz.css('marginLeft') == '-10000px'){ - linkwiz.show(); + if(dw_linkwiz.$wiz.css('marginLeft') == '-10000px'){ + dw_linkwiz.show(); }else{ - linkwiz.hide(); + dw_linkwiz.hide(); } } -- cgit v1.2.3 From 6d23f6ac8b2f04af9a78315a31c70193e672999b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 8 Jul 2011 11:59:59 +0200 Subject: fixed linkwiz position --- lib/scripts/linkwiz.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/scripts/linkwiz.js') diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index 14fa33795..110533a81 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -24,16 +24,14 @@ var dw_linkwiz = { init: function($editor){ // position relative to the text area var pos = $editor.position(); - pos.left += 20; - pos.right += 80; // create HTML Structure dw_linkwiz.$wiz = jQuery(document.createElement('div')) .attr('id','link__wiz') .css({ 'position': 'absolute', - 'top': pos.left+'px', - 'left': pos.top+'px', + 'top': (pos.top+20)+'px', + 'left': (pos.left+80)+'px', 'margin-left': '-10000px', 'margin-top': '-10000px' }) -- cgit v1.2.3 From 5382ed1a4ff750b46cb047231e8785d2a69976d4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 8 Jul 2011 12:00:23 +0200 Subject: aliased some vars in linkwiz for brevity --- lib/scripts/linkwiz.js | 62 +++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) (limited to 'lib/scripts/linkwiz.js') diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index 110533a81..83653c9bb 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -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(); }, /** -- cgit v1.2.3 From ba6c070edd92ca0fc8a6ee85d51769d64a19ee7c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 4 Sep 2011 13:52:43 +0200 Subject: tmp --- lib/scripts/linkwiz.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/scripts/linkwiz.js') diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index 83653c9bb..0cad86cc2 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -1,7 +1,3 @@ -/*jslint sloppy: true, indent: 4, white: true, browser: true, eqeq: true */ -/*global jQuery, DOKU_BASE, LANG, DOKU_UHC, getSelection, pasteText */ - - /** * The Link Wizard * -- cgit v1.2.3 From 1ffc211ddb46bfabe649bbacd1e36bc8e035afa3 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 4 Sep 2011 15:32:41 +0200 Subject: Revert tmp commits This reverts commit ba6c070edd92ca0fc8a6ee85d51769d64a19ee7c. This reverts commit 923510088dda99cb2790b15308593e47369d4f01. --- lib/scripts/linkwiz.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/scripts/linkwiz.js') 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 * -- cgit v1.2.3 From 5e7a292691951a0fa0a18f06c8b9bcfb509a032d Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 9 Sep 2011 22:26:16 +0200 Subject: Various JavaScript improvements, JSLint, jQuery --- lib/scripts/linkwiz.js | 199 +++++++++++++++++++++++++------------------------ 1 file changed, 100 insertions(+), 99 deletions(-) (limited to 'lib/scripts/linkwiz.js') diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index 83653c9bb..6e0a00183 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -1,7 +1,3 @@ -/*jslint sloppy: true, indent: 4, white: true, browser: true, eqeq: true */ -/*global jQuery, DOKU_BASE, LANG, DOKU_UHC, getSelection, pasteText */ - - /** * The Link Wizard * @@ -10,7 +6,7 @@ */ var dw_linkwiz = { $wiz: null, - entry: null, + $entry: null, result: null, timer: null, textArea: null, @@ -28,12 +24,11 @@ var dw_linkwiz = { // create HTML Structure dw_linkwiz.$wiz = jQuery(document.createElement('div')) .attr('id','link__wiz') + .addClass('hidden_with_access_keys') .css({ 'position': 'absolute', 'top': (pos.top+20)+'px', - 'left': (pos.left+80)+'px', - 'margin-left': '-10000px', - 'margin-top': '-10000px' + 'left': (pos.left+80)+'px' }) .html( '