summaryrefslogtreecommitdiff
path: root/lib/scripts
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-08-03 02:20:59 -0700
committerAndreas Gohr <andi@splitbrain.org>2013-08-03 02:20:59 -0700
commit70de5432775e92164668192f8eacd49b8e2b5340 (patch)
tree2fb509145d718074d7cfde4e2f32cd909f8bec09 /lib/scripts
parentcab505616ec9b8ef3cd671e7337c91d065745932 (diff)
parent935ecb0ef751ac1d658932316e06410e70c483e0 (diff)
downloadrpg-70de5432775e92164668192f8eacd49b8e2b5340.tar.gz
rpg-70de5432775e92164668192f8eacd49b8e2b5340.tar.bz2
Merge pull request #235 from haobug/master
Improve Linkwizard, make it can be used more than once
Diffstat (limited to 'lib/scripts')
-rw-r--r--lib/scripts/linkwiz.js24
-rw-r--r--lib/scripts/toolbar.js5
2 files changed, 21 insertions, 8 deletions
diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js
index c55650d68..875d4a995 100644
--- a/lib/scripts/linkwiz.js
+++ b/lib/scripts/linkwiz.js
@@ -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
diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js
index 5fc4d835e..88cae1e8c 100644
--- a/lib/scripts/toolbar.js
+++ b/lib/scripts/toolbar.js
@@ -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 '';
});