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

Merge pull request #235 from haobug/master

Improve Linkwizard, make it can be used more than once
parents cab50561 935ecb0e
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,8 @@ var dw_linkwiz = {
var pos = $editor.position();
// create HTML Structure
if(dw_linkwiz.$wiz)
return;
dw_linkwiz.$wiz = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
......@@ -235,15 +237,25 @@ var dw_linkwiz = {
link = ':' + link;
}
var so = link.length+3;
link = '[['+link+'|';
if(stxt) {
link += stxt;
var so = link.length;
var eo = 0;
if(dw_linkwiz.val){
if(dw_linkwiz.val.open) {
so += dw_linkwiz.val.open.length;
link = dw_linkwiz.val.open+link;
}
if(stxt) {
link += '|'+stxt;
so += 1;
}
if(dw_linkwiz.val.close) {
link += dw_linkwiz.val.close;
eo = dw_linkwiz.val.close.length;
}
}
link += ']]';
pasteText(sel,link,{startofs: so, endofs: 2});
pasteText(sel,link,{startofs: so, endofs: eo});
dw_linkwiz.hide();
// reset the entry to the parent namespace
......
......@@ -217,9 +217,10 @@ function addBtnActionPicker($btn, props, edid) {
* @return boolean If button should be appended
* @author Andreas Gohr <gohr@cosmocode.de>
*/
function addBtnActionLinkwiz(btn, props, edid) {
function addBtnActionLinkwiz($btn, props, edid) {
dw_linkwiz.init(jQuery('#'+edid));
jQuery(btn).click(function(){
jQuery($btn).click(function(){
dw_linkwiz.val = props;
dw_linkwiz.toggle();
return '';
});
......
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