Commit eb0c163c authored by RawKStar77's avatar RawKStar77

Rename things, fix embarassing spelling error.

parent bd2fb13e
...@@ -12,19 +12,20 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) -> ...@@ -12,19 +12,20 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
return unless ctrl? return unless ctrl?
input = elem.find('textarea') input = elem.find('textarea')
output = elem.find('div') output = elem.find('div')[1]
textarea = input[0]
returnSelection = -> returnSelection = ->
ourIframeSelection = $window.getSelection().toString() ourIframeSelection = $window.getSelection().toString()
if input[0].selectionStart != undefined if textarea.selectionStart != undefined
startPos = input[0].selectionStart startPos = textarea.selectionStart
endPos = input[0].selectionEnd endPos = textarea.selectionEnd
if ourIframeSelection if ourIframeSelection
selectedText = ourIframeSelection selectedText = ourIframeSelection
else else
selectedText = input[0].value.substring(startPos, endPos) selectedText = textarea.value.substring(startPos, endPos)
textBefore = input[0].value.substring(0, (startPos)) textBefore = textarea.value.substring(0, (startPos))
textAfter = input[0].value.substring(endPos) textAfter = textarea.value.substring(endPos)
selection = { selection = {
before: textBefore before: textBefore
after: textAfter after: textAfter
...@@ -37,10 +38,10 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) -> ...@@ -37,10 +38,10 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
insertMarkup = (value, selectionStart, selectionEnd) -> insertMarkup = (value, selectionStart, selectionEnd) ->
# New value is set for the textarea # New value is set for the textarea
input[0].value = value textarea.value = value
# A new selection is set, or the cursur is positioned inside the textarea. # A new selection is set, or the cursur is positioned inside the textarea.
input[0].selectionStart = selectionStart textarea.selectionStart = selectionStart
input[0].selectionEnd = selectionEnd textarea.selectionEnd = selectionEnd
applyInlineMarkup = (markup, innertext)-> applyInlineMarkup = (markup, innertext)->
text = returnSelection() text = returnSelection()
...@@ -124,7 +125,7 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) -> ...@@ -124,7 +125,7 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
index += 1 index += 1
else else
newlinedetected = false newlinedetected = false
if input[0].value.substring(index - 1).charAt(0) == "\n" if textarea.value.substring(index - 1).charAt(0) == "\n"
# Look to see if the selection falls at the beginning of a new line. # Look to see if the selection falls at the beginning of a new line.
newstring = newstring + markup newstring = newstring + markup
newlinedetected = true newlinedetected = true
...@@ -162,7 +163,7 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) -> ...@@ -162,7 +163,7 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
start = (text.before + newstring).length start = (text.before + newstring).length
end = (text.before + newstring).length end = (text.before + newstring).length
insertMarkup(value, start, end) insertMarkup(value, start, end)
else if input[0].value.substring((text.start - 1 ), text.start) == "\n" else if textarea.value.substring((text.start - 1 ), text.start) == "\n"
# Edge case, no selection, the cursor is on a new line. # Edge case, no selection, the cursor is on a new line.
value = text.before + markup + text.selection + text.after value = text.before + markup + text.selection + text.after
start = (text.before + markup).length start = (text.before + markup).length
...@@ -232,10 +233,10 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) -> ...@@ -232,10 +233,10 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
if !scope.readonly if !scope.readonly
scope.preview = !scope.preview scope.preview = !scope.preview
if scope.preview if scope.preview
output[2].style.height = input[0].style.height output.style.height = textarea.style.height
ctrl.$render() ctrl.$render()
else else
input[0].style.height = output[2].style.height textarea.style.height = output.style.height
$timeout -> input.focus() $timeout -> input.focus()
# Re-render the markdown when the view needs updating. # Re-render the markdown when the view needs updating.
...@@ -253,7 +254,7 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) -> ...@@ -253,7 +254,7 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
# Auto-focus the input box when the widget becomes editable. # Auto-focus the input box when the widget becomes editable.
scope.$watch 'readonly', (readonly) -> scope.$watch 'readonly', (readonly) ->
scope.preview = false scope.preview = false
output[2].style.height = "" output.style.height = ""
ctrl.$render() ctrl.$render()
unless readonly then $timeout -> input.focus() unless readonly then $timeout -> input.focus()
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
} }
// Markdown Editor Controls //////////////////////// //MARKDOWN EDITOR CONTROLS//////////////////////////
[markdown] { [markdown] {
.preview { .preview {
overflow: auto; overflow: auto;
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
} }
// Privacy Controll ///////////////////////// //PRIVACY CONTROL////////////////////////////
privacy { privacy {
position: relative; position: relative;
top: 2px; top: 2px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment