Skip to content
Open
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
50 changes: 40 additions & 10 deletions js/bootstrap-markdown.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
handler = this.$handler,
callback = this.$callback,
handlerName = target.attr('data-handler'),
callbackIndex = handler.indexOf(handlerName),
callbackIndex = $.inArray(handlerName,handler),
callbackHandler = callback[callbackIndex]

// Trigger the focusin
Expand Down Expand Up @@ -461,7 +461,7 @@
this.disableButtons('all').enableButtons('cmdPreview')

content = this.parseContent()

console.log("content: "+content);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay for IE8 support!

Shouldn't this debug be removed ?

// Build preview element
replacementContainer.html(content)

Expand Down Expand Up @@ -552,22 +552,51 @@

, getSelection: function() {

var e = this.$textarea[0]

return (

var e = this.$textarea[0];
if (typeof(e.selectionStart) != "undefined") {
return (
('selectionStart' in e && function() {
var l = e.selectionEnd - e.selectionStart
return { start: e.selectionStart, end: e.selectionEnd, length: l, text: e.value.substr(e.selectionStart, l) }
})
)()
}
else if (typeof(document.selection) != "undefined") { /* browser not supported e.selectionStart and e.selectionEnd*/
e.focus();

var r = document.selection.createRange();
if (r == null) {
return 0;
}

var re = e.createTextRange(),
rc = re.duplicate();
re.moveToBookmark(r.getBookmark());
rc.setEndPoint('EndToEnd', re);
var selectionStart = rc.text.length - re.text.length;
var selectionEnd = selectionStart + re.text.length;

var l = re.text.length;
return { start: selectionStart, end: selectionEnd, length: l, text: e.value.substr(selectionStart, l) };

}


/*return (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't comment code, but remove it if it's not used. You can still check the git history if you want to cehck for old code


('selectionStart' in e && function() {
var l = e.selectionEnd - e.selectionStart
console.log("l:"+l+", e.selectionStart:"+e.selectionStart)
return { start: e.selectionStart, end: e.selectionEnd, length: l, text: e.value.substr(e.selectionStart, l) }
}) ||

/* browser not supported */
browser not supported
function() {
return null
}

)()

)()*/
}

, setSelection: function(start,end) {
Expand All @@ -576,6 +605,7 @@

return (


('selectionStart' in e && function() {
e.selectionStart = start
e.selectionEnd = end
Expand Down Expand Up @@ -899,8 +929,8 @@
callback: function(e){
// Give/remove ** surround the selection
var chunk, cursor, selected = e.getSelection(), content = e.getContent()

if (selected.length == 0) {

// Give extra word
chunk = e.__localize('strong text')
} else {
Expand Down