Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Link with target #215

Merged
merged 2 commits into from
Apr 29, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/bootstrap-wysihtml5.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"</div>" +
"<div class='modal-body'>" +
"<input value='http://' class='bootstrap-wysihtml5-insert-link-url input-xlarge'>" +
"<label class='checkbox'> <input type='checkbox' class='bootstrap-wysihtml5-insert-link-target' checked>" + locale.link.target + "</label>" +
"</div>" +
"<div class='modal-footer'>" +
"<a href='#' class='btn' data-dismiss='modal'>" + locale.link.cancel + "</a>" +
Expand Down Expand Up @@ -282,6 +283,7 @@
var self = this;
var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');
var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
var targetInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-target');
var insertButton = insertLinkModal.find('a.btn-primary');
var initialValue = urlInput.val();
var caretBookmark;
Expand All @@ -294,10 +296,12 @@
self.editor.composer.selection.setBookmark(caretBookmark);
caretBookmark = null;
}

var newWindow = targetInput.prop("checked");
self.editor.composer.commands.exec("createLink", {
href: url,
target: "_blank",
rel: "nofollow"
'href' : url,
'target' : (newWindow ? '_blank' : '_self'),
'rel' : (newWindow ? 'nofollow' : '')
});
};
var pressedEnter = false;
Expand Down Expand Up @@ -427,12 +431,10 @@
}
},
"a": {
set_attributes: {
target: "_blank",
rel: "nofollow"
},
check_attributes: {
href: "url" // important to avoid XSS
'href': "url", // important to avoid XSS
'target': 'alt',
'rel': 'alt'
}
},
"span": 1,
Expand Down Expand Up @@ -471,7 +473,8 @@
},
link: {
insert: "Insert link",
cancel: "Cancel"
cancel: "Cancel",
target: "Open link in new window"
},
image: {
insert: "Insert image",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/bootstrap-wysihtml5.de-DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
},
link: {
insert: "Link einfügen",
cancel: "Abbrechen"
cancel: "Abbrechen",
target: "Link in neuen Fenster öffnen"
},
image: {
insert: "Bild einfügen",
Expand Down