id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | # wrapping query with .atwho-query
if $query.length == 0 and isString \
and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 5374211c21e7080d8bb8c5fffaf9e5e33384f944 | 5,250 | https://github.com/ichord/At.js/blob/5374211c21e7080d8bb8c5fffaf9e5e33384f944/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | # wrapping query with .atwho-query
if $query.length == 0 and isString \
and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query... | @view.hide()
@query = el: $query
if $query.text().indexOf(this.at) >= 0
if @_movingEvent(e) and $query.hasClass 'atwho-inserted'
$query.removeClass('atwho-query')
else if false != @callbacks('afterMatchFailed').call this, @at, $query
@_setRange "after", @_unwrap $query.te... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 5374211c21e7080d8bb8c5fffaf9e5e33384f944 | 5,250 | https://github.com/ichord/At.js/blob/5374211c21e7080d8bb8c5fffaf9e5e33384f944/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | @$inputor.focus() unless @$inputor.is ':focus'
suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 5374211c21e7080d8bb8c5fffaf9e5e33384f944 | 5,250 | https://github.com/ichord/At.js/blob/5374211c21e7080d8bb8c5fffaf9e5e33384f944/src/editableController.coffee | 151 | 166 | ||
ichord/At.js:src/editableController.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@$inputor.focus() unless @$inputor.is ':focus'
suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html conte... | var data, range, suffix, suffixNode;
this.$inputor.focus()(!this.$inputor.is(':focus') ? (suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || "\u00A0", data = $li.data('item-data'), this.query.el.removeClass('atwho-query').addClass('atwho-inserted').html(content).attr('data-atwho-at-query', "" + data... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | 5374211c21e7080d8bb8c5fffaf9e5e33384f944 | 5,250 | https://github.com/ichord/At.js/blob/5374211c21e7080d8bb8c5fffaf9e5e33384f944/src/editableController.coffee | 151 | 166 |
ichord/At.js:src/editableController.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var data, range, suffix, suffixNode;
this.$inputor.focus()(!this.$inputor.is(':focus') ? (suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || "\u00A0", data = $li.data('item-data'), this.query.el.removeClass('atwho-query').addClass('atwho-inserte... | @$inputor.focus() unless @$inputor.is ':focus'
suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 5374211c21e7080d8bb8c5fffaf9e5e33384f944 | 5,250 | https://github.com/ichord/At.js/blob/5374211c21e7080d8bb8c5fffaf9e5e33384f944/src/editableController.coffee | 151 | 166 |
ichord/At.js:src/editableController.coffee:4:completion | completion | @$inputor.focus() unless @$inputor.is ':focus'
suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at... | .attr 'contenteditable', "false"
if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextNode "" + suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 5374211c21e7080d8bb8c5fffaf9e5e33384f944 | 5,250 | https://github.com/ichord/At.js/blob/5374211c21e7080d8bb8c5fffaf9e5e33384f944/src/editableController.coffee | 151 | 166 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | @$inputor.focus() unless @$inputor.is ':focus'
suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | dff09c0b84679fb0294dd938e745a7f371e3f48d | 5,250 | https://github.com/ichord/At.js/blob/dff09c0b84679fb0294dd938e745a7f371e3f48d/src/editableController.coffee | 151 | 165 | ||
ichord/At.js:src/editableController.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@$inputor.focus() unless @$inputor.is ':focus'
suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html conte... | var data, range, suffix, suffixNode;
this.$inputor.focus()(!this.$inputor.is(':focus') ? (suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || "\u00A0", data = $li.data('item-data'), this.query.el.removeClass('atwho-query').addClass('atwho-inserted').html(content).attr('data-atwho-at-query', "" + data... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | dff09c0b84679fb0294dd938e745a7f371e3f48d | 5,250 | https://github.com/ichord/At.js/blob/dff09c0b84679fb0294dd938e745a7f371e3f48d/src/editableController.coffee | 151 | 165 |
ichord/At.js:src/editableController.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var data, range, suffix, suffixNode;
this.$inputor.focus()(!this.$inputor.is(':focus') ? (suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || "\u00A0", data = $li.data('item-data'), this.query.el.removeClass('atwho-query').addClass('atwho-inserte... | @$inputor.focus() unless @$inputor.is ':focus'
suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | dff09c0b84679fb0294dd938e745a7f371e3f48d | 5,250 | https://github.com/ichord/At.js/blob/dff09c0b84679fb0294dd938e745a7f371e3f48d/src/editableController.coffee | 151 | 165 |
ichord/At.js:src/editableController.coffee:4:completion | completion | @$inputor.focus() unless @$inputor.is ':focus'
suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content | .attr 'data-atwho-at-query', "" + data['atwho-at'] + @query.text
if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextNode "\u200D" + suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$input... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | dff09c0b84679fb0294dd938e745a7f371e3f48d | 5,250 | https://github.com/ichord/At.js/blob/dff09c0b84679fb0294dd938e745a7f371e3f48d/src/editableController.coffee | 151 | 165 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | # The range at the end of an element is not inside in firefox but not others browsers including IE.
# To normolize them, we have to move the range inside the element while deleting content or moving caret right after .atwho-inserted
if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$i... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | e24b563e4d85681d683b8c1f7e345c98f2da3cb2 | 5,250 | https://github.com/ichord/At.js/blob/e24b563e4d85681d683b8c1f7e345c98f2da3cb2/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# The range at the end of an element is not inside in firefox but not others browsers including IE.
# To normolize them, we have to move the range inside the element while deleting content or moving caret right after .atwho-inserted
if /firefox/i.test(nav... | // The range at the end of an element is not inside in firefox but not others browsers including IE.
// To normolize them, we have to move the range inside the element while deleting content or moving caret right after .atwho-inserted
var $inserted, $query, _range, inserted, isString, matched, offset, query_content;
i... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | e24b563e4d85681d683b8c1f7e345c98f2da3cb2 | 5,250 | https://github.com/ichord/At.js/blob/e24b563e4d85681d683b8c1f7e345c98f2da3cb2/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// The range at the end of an element is not inside in firefox but not others browsers including IE.
// To normolize them, we have to move the range inside the element while deleting content or moving caret right after .atwho-inserted
var $inserted, $query, _range,... | # The range at the end of an element is not inside in firefox but not others browsers including IE.
# To normolize them, we have to move the range inside the element while deleting content or moving caret right after .atwho-inserted
if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$i... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | e24b563e4d85681d683b8c1f7e345c98f2da3cb2 | 5,250 | https://github.com/ichord/At.js/blob/e24b563e4d85681d683b8c1f7e345c98f2da3cb2/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:2:completion | completion | # The range at the end of an element is not inside in firefox but not others browsers including IE.
# To normolize them, we have to move the range inside the element while deleting content or moving caret right after .atwho-inserted
if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$i... | and $query.is(':empty') and $query.text().length == 0
$query.remove()
if not @_movingEvent e
$query.removeClass 'atwho-inserted'
if $query.length > 0
switch e.which
when KEY_CODE.LEFT
@_setRange 'before', $query.get(0), range
$query.removeClass 'atwho-query'
... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | e24b563e4d85681d683b8c1f7e345c98f2da3cb2 | 5,250 | https://github.com/ichord/At.js/blob/e24b563e4d85681d683b8c1f7e345c98f2da3cb2/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at'] + @query.text
if range = @_getRange()
... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | e8206033b3c1b86ae4d4b607b6b961bbe65c8b03 | 5,250 | https://github.com/ichord/At.js/blob/e8206033b3c1b86ae4d4b607b6b961bbe65c8b03/src/editableController.coffee | 151 | 164 | ||
ichord/At.js:src/editableController.coffee:4:completion | completion | suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at'] + @query.text | if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextNode "\u200D" + suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | e8206033b3c1b86ae4d4b607b6b961bbe65c8b03 | 5,250 | https://github.com/ichord/At.js/blob/e8206033b3c1b86ae4d4b607b6b961bbe65c8b03/src/editableController.coffee | 151 | 164 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at'] + @query.text
if range = @_getRange()
... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 84edc9f41f7f6b4379e1a37835b155ddf5c778b7 | 5,250 | https://github.com/ichord/At.js/blob/84edc9f41f7f6b4379e1a37835b155ddf5c778b7/src/editableController.coffee | 151 | 164 | ||
ichord/At.js:src/editableController.coffee:4:completion | completion | suffix = if (suffix = @getOpt 'suffix') == "" then suffix else suffix or "\u00A0"
data = $li.data('item-data')
@query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at'] + @query.text | if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextNode "\u2060" + suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 84edc9f41f7f6b4379e1a37835b155ddf5c778b7 | 5,250 | https://github.com/ichord/At.js/blob/84edc9f41f7f6b4379e1a37835b155ddf5c778b7/src/editableController.coffee | 151 | 164 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | # The range at the end of an element is not inside in firefox but not others browsers including IE.
# To normolize them, we have to move the range inside the element while deleting content or moving caret right after .atwho-inserted
if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$i... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c39939750f08e74ae75ff4382207023606ec4244 | 5,250 | https://github.com/ichord/At.js/blob/c39939750f08e74ae75ff4382207023606ec4244/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:completion | completion | # The range at the end of an element is not inside in firefox but not others browsers including IE.
# To normolize them, we have to move the range inside the element while deleting content or moving caret right after .atwho-inserted
if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$i... | and $query.is(':empty') and $query.text().length == 0
$query.remove()
if not @_movingEvent e
$query.removeClass 'atwho-inserted'
# matching
if $query.length > 0 && query_content = $query.attr('data-atwho-at-query')
$query.empty().html(query_content).attr('data-atwho-at-query', null)
... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c39939750f08e74ae75ff4382207023606ec4244 | 5,250 | https://github.com/ichord/At.js/blob/c39939750f08e74ae75ff4382207023606ec4244/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | range.setStart lastNode, lastNode.length
range.setEnd lastNode, lastNode.length
@_clearRange range
else
@_setRange 'after', lastNode, range
return if isString and matched.length < @getOpt('minLen', 0)
# handle the matched result
if isString and matched.length <= @getOpt('maxL... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c39939750f08e74ae75ff4382207023606ec4244 | 5,250 | https://github.com/ichord/At.js/blob/c39939750f08e74ae75ff4382207023606ec4244/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | range.setStart lastNode, lastNode.length
range.setEnd lastNode, lastNode.length
@_clearRange range
else
@_setRange 'after', lastNode, range
return if isString and matched.length < @getOpt('minLen', 0)
# handle the matched result
if isString and matched.length <= @getOpt('maxL... | # @return [Hash] the offset which look likes this: {top: y, left: x, bottom: bottom}
rect: ->
rect = @query.el.offset()
if @app.iframe and not @app.iframeAsRoot
iframeOffset = ($iframe = $ @app.iframe).offset()
rect.left += iframeOffset.left - @$inputor.scrollLeft()
rect.top += iframeOffset.... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c39939750f08e74ae75ff4382207023606ec4244 | 5,250 | https://github.com/ichord/At.js/blob/c39939750f08e74ae75ff4382207023606ec4244/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | @_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c39939750f08e74ae75ff4382207023606ec4244 | 5,250 | https://github.com/ichord/At.js/blob/c39939750f08e74ae75ff4382207023606ec4244/src/editableController.coffee | 151 | 153 | ||
ichord/At.js:src/editableController.coffee:1:raw_corpus | raw_corpus | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartAf... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 1 | 50 | ||
ichord/At.js:src/editableController.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'a... | var EditableController;
EditableController = class EditableController extends Controller {
_getRange() {
var sel;
sel = this.app.window.getSelection();
if (sel.rangeCount > 0) {
return sel.getRangeAt(0);
}
}
_setRange(position, node, range = this._getRange()) {
if (!range) {
retu... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var EditableController;
EditableController = class EditableController extends Controller {
_getRange() {
var sel;
sel = this.app.window.getSelection();
if (sel.rangeCount > 0) {
return sel.getRangeAt(0);
}
}
_setRange(position, node, r... | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartAf... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:1:completion | completion | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartAf... | _movingEvent: (e) ->
e.type == 'click' or e.which in [KEY_CODE.RIGHT, KEY_CODE.LEFT, KEY_CODE.UP, KEY_CODE.DOWN]
_unwrap: (node) ->
node = $(node).unwrap().get 0
if (next = node.nextSibling) and next.nodeValue
node.nodeValue += next.nodeValue
$(next).remove()
node
catchQuery: (e) ->
... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | .contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# absorb range
# The range at the end of an element is not inside in firefox but not others browser... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:completion | completion | .contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# absorb range
# The range at the end of an element is not inside in firefox but not others browser... | @_setRange 'after', $inserted.contents().last()
# modifying inserted element
$(range.startContainer)
.closest '.atwho-inserted'
.addClass 'atwho-query'
.siblings().removeClass 'atwho-query'
if ($query = $ ".atwho-query", @app.document).length > 0 \
and $query.is(':empty') and $qu... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | if $query.length == 0 and isString \
and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.g... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
if $query.length == 0 and isString \
and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.add... | var $query, index, lastNode, query;
if ($query.length === 0 && isString && (index = range.startOffset - this.at.length - matched.length) >= 0) {
range.setStart(range.startContainer, index);
$query = $('<span/>', this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass('atwho-query');
range.surrou... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var $query, index, lastNode, query;
if ($query.length === 0 && isString && (index = range.startOffset - this.at.length - matched.length) >= 0) {
range.setStart(range.startContainer, index);
$query = $('<span/>', this.app.document).attr(this.getOpt("editableAtw... | if $query.length == 0 and isString \
and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.g... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:3:completion | completion | if $query.length == 0 and isString \
and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.g... | if $query.text().indexOf(this.at) >= 0
if @_movingEvent(e) and $query.hasClass 'atwho-inserted'
$query.removeClass('atwho-query')
else if false != @callbacks('afterMatchFailed').call this, @at, $query
@_setRange "after", @_unwrap $query.text($query.text()).contents().first()
nu... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | @query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at'] + @query.text
if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextN... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 151 | 162 | ||
ichord/At.js:src/editableController.coffee:4:completion | completion | @query.el
.removeClass 'atwho-query'
.addClass 'atwho-inserted'
.html content
.attr 'data-atwho-at-query', "" + data['atwho-at'] + @query.text
if range = @_getRange() | range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f4295a9f8962fee8867a9d5006e22fe01ef19b5 | 5,250 | https://github.com/ichord/At.js/blob/7f4295a9f8962fee8867a9d5006e22fe01ef19b5/src/editableController.coffee | 151 | 162 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | .contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# absorb range
# The range at the end of an element is not inside in firefox but not others browser... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8 | 5,250 | https://github.com/ichord/At.js/blob/c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:completion | completion | .contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# absorb range
# The range at the end of an element is not inside in firefox but not others browser... | @_setRange 'after', $inserted.contents().last()
# modifying inserted element
$(range.startContainer)
.closest '.atwho-inserted'
.addClass 'atwho-query'
.siblings().removeClass 'atwho-query'
if ($query = $ ".atwho-query", @app.document).length > 0 \
and $query.is(':empty') and $qu... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8 | 5,250 | https://github.com/ichord/At.js/blob/c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | $query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEn... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8 | 5,250 | https://github.com/ichord/At.js/blob/c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | $query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEn... | else if false != @callbacks('afterMatchFailed').call this, @at, $query
@_setRange "after", @_unwrap $query.text($query.text()).contents().first()
null
# Get offset of current at char(`flag`)
#
# @return [Hash] the offset which look likes this: {top: y, left: x, bottom: bottom}
rect: ->
rect... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8 | 5,250 | https://github.com/ichord/At.js/blob/c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8 | 5,250 | https://github.com/ichord/At.js/blob/c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8/src/editableController.coffee | 151 | 157 | ||
ichord/At.js:src/editableController.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$in... | var range, suffixNode;
if (range = this._getRange()) {
range.setEndAfter(this.query.el[0]);
range.collapse(false);
range.insertNode(suffixNode = this.app.document.createTextNode(suffix));
this._setRange('after', suffixNode, range);
}
if (!this.$inputor.is(':focus')) {
this.$inputor.focus();
}
this.$inputor... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8 | 5,250 | https://github.com/ichord/At.js/blob/c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8/src/editableController.coffee | 151 | 157 |
ichord/At.js:src/editableController.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var range, suffixNode;
if (range = this._getRange()) {
range.setEndAfter(this.query.el[0]);
range.collapse(false);
range.insertNode(suffixNode = this.app.document.createTextNode(suffix));
this._setRange('after', suffixNode, range);
}
if (!this.$inputor.is... | if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8 | 5,250 | https://github.com/ichord/At.js/blob/c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8/src/editableController.coffee | 151 | 157 |
ichord/At.js:src/editableController.coffee:4:completion | completion | if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false | range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8 | 5,250 | https://github.com/ichord/At.js/blob/c9b7609aa6ddfe2adea9f05cc2a289e9e6dc55f8/src/editableController.coffee | 151 | 157 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | .contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# absorb range
# The range at the end of an element is not inside in firefox but not others browser... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | f8692dc89f56d0925511cf9b7715113d49a00fef | 5,250 | https://github.com/ichord/At.js/blob/f8692dc89f56d0925511cf9b7715113d49a00fef/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:completion | completion | .contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# absorb range
# The range at the end of an element is not inside in firefox but not others browser... | @_setRange 'after', $inserted.contents().last()
# modifying inserted element
$(range.startContainer)
.closest '.atwho-inserted'
.addClass 'atwho-query'
.siblings().removeClass 'atwho-query'
if ($query = $ ".atwho-query", @app.document).length > 0 \
and $query.is(':empty') and $qu... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | f8692dc89f56d0925511cf9b7715113d49a00fef | 5,250 | https://github.com/ichord/At.js/blob/f8692dc89f56d0925511cf9b7715113d49a00fef/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | .attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEnd lastNode, lastNode.length
@_clearR... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | f8692dc89f56d0925511cf9b7715113d49a00fef | 5,250 | https://github.com/ichord/At.js/blob/f8692dc89f56d0925511cf9b7715113d49a00fef/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | .attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEnd lastNode, lastNode.length
@_clearR... | null
# Get offset of current at char(`flag`)
#
# @return [Hash] the offset which look likes this: {top: y, left: x, bottom: bottom}
rect: ->
rect = @query.el.offset()
if @app.iframe and not @app.iframeAsRoot
iframeOffset = ($iframe = $ @app.iframe).offset()
rect.left += iframeOffset.left - ... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | f8692dc89f56d0925511cf9b7715113d49a00fef | 5,250 | https://github.com/ichord/At.js/blob/f8692dc89f56d0925511cf9b7715113d49a00fef/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | range.collapse false
range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | f8692dc89f56d0925511cf9b7715113d49a00fef | 5,250 | https://github.com/ichord/At.js/blob/f8692dc89f56d0925511cf9b7715113d49a00fef/src/editableController.coffee | 151 | 155 | ||
ichord/At.js:src/editableController.coffee:4:completion | completion | range.collapse false
range.insertNode suffixNode = @app.document.createTextNode suffix | @_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | f8692dc89f56d0925511cf9b7715113d49a00fef | 5,250 | https://github.com/ichord/At.js/blob/f8692dc89f56d0925511cf9b7715113d49a00fef/src/editableController.coffee | 151 | 155 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | .attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEnd lastNode, lastNode.length
@_clearR... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c374c9335f761b66ecb3dec4770a3f630e5bcb4e | 5,250 | https://github.com/ichord/At.js/blob/c374c9335f761b66ecb3dec4770a3f630e5bcb4e/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | .attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEnd lastNode, lastNode.length
@_clearR... | # Get offset of current at char(`flag`)
#
# @return [Hash] the offset which look likes this: {top: y, left: x, bottom: bottom}
rect: ->
rect = @query.el.offset()
if @app.iframe and not @app.iframeAsRoot
iframeOffset = ($iframe = $ @app.iframe).offset()
rect.left += iframeOffset.left - @$inputo... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c374c9335f761b66ecb3dec4770a3f630e5bcb4e | 5,250 | https://github.com/ichord/At.js/blob/c374c9335f761b66ecb3dec4770a3f630e5bcb4e/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c374c9335f761b66ecb3dec4770a3f630e5bcb4e | 5,250 | https://github.com/ichord/At.js/blob/c374c9335f761b66ecb3dec4770a3f630e5bcb4e/src/editableController.coffee | 151 | 154 | ||
ichord/At.js:src/editableController.coffee:4:completion | completion | range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range | @$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c374c9335f761b66ecb3dec4770a3f630e5bcb4e | 5,250 | https://github.com/ichord/At.js/blob/c374c9335f761b66ecb3dec4770a3f630e5bcb4e/src/editableController.coffee | 151 | 154 |
ichord/At.js:src/editableController.coffee:1:raw_corpus | raw_corpus | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartAf... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f2189d49521e3e9a83dffc321a9ac4b9905a8e2 | 5,250 | https://github.com/ichord/At.js/blob/7f2189d49521e3e9a83dffc321a9ac4b9905a8e2/src/editableController.coffee | 1 | 50 | ||
ichord/At.js:src/editableController.coffee:1:completion | completion | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartAf... | _movingEvent: (e) ->
e.type == 'click' or e.which in [KEY_CODE.RIGHT, KEY_CODE.LEFT, KEY_CODE.UP, KEY_CODE.DOWN]
_unwrap: (node) ->
node = $(node).unwrap().get 0
if (next = node.nextSibling) and next.nodeValue
node.nodeValue += next.nodeValue
$(next).remove()
node
catchQuery: (e) ->
... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f2189d49521e3e9a83dffc321a9ac4b9905a8e2 | 5,250 | https://github.com/ichord/At.js/blob/7f2189d49521e3e9a83dffc321a9ac4b9905a8e2/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | ($query = $(range.startContainer).closest '.atwho-query')
.contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# absorb range
# The range at the... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f2189d49521e3e9a83dffc321a9ac4b9905a8e2 | 5,250 | https://github.com/ichord/At.js/blob/7f2189d49521e3e9a83dffc321a9ac4b9905a8e2/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:completion | completion | ($query = $(range.startContainer).closest '.atwho-query')
.contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# absorb range
# The range at the... | if $inserted.is('.atwho-inserted') and range.startOffset == 0
@_setRange 'after', $inserted.contents().last()
# modifying inserted element
$(range.startContainer)
.closest '.atwho-inserted'
.addClass 'atwho-query'
.siblings().removeClass 'atwho-query'
if ($query = $ ".atwho-que... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f2189d49521e3e9a83dffc321a9ac4b9905a8e2 | 5,250 | https://github.com/ichord/At.js/blob/7f2189d49521e3e9a83dffc321a9ac4b9905a8e2/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | $query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEn... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f2189d49521e3e9a83dffc321a9ac4b9905a8e2 | 5,250 | https://github.com/ichord/At.js/blob/7f2189d49521e3e9a83dffc321a9ac4b9905a8e2/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | $query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEn... | null
# Get offset of current at char(`flag`)
#
# @return [Hash] the offset which look likes this: {top: y, left: x, bottom: bottom}
rect: ->
rect = @query.el.offset()
if @app.iframe and not @app.iframeAsRoot
iframeOffset = ($iframe = $ @app.iframe).offset()
rect.left += iframeOffset.left - ... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 7f2189d49521e3e9a83dffc321a9ac4b9905a8e2 | 5,250 | https://github.com/ichord/At.js/blob/7f2189d49521e3e9a83dffc321a9ac4b9905a8e2/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | $query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEn... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 38cfc7c48e46ec73f11a02c1e88d99932ec103c8 | 5,250 | https://github.com/ichord/At.js/blob/38cfc7c48e46ec73f11a02c1e88d99932ec103c8/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | $query = $ '<span/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEn... | null
# Get offset of current at char(`flag`)
#
# @return [Hash] the offset which look likes this: {top: y, left: x, bottom: bottom}
rect: ->
rect = @query.el.offset()
if @app.iframe and not @app.iframeAsRoot
iframeOffset = ($iframe = $ @app.iframe).offset()
rect.left += iframeOffset.left - ... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 38cfc7c48e46ec73f11a02c1e88d99932ec103c8 | 5,250 | https://github.com/ichord/At.js/blob/38cfc7c48e46ec73f11a02c1e88d99932ec103c8/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | $query = $ '<span contenteditable="false"/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.le... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 454b83518d132c90fb42c29dbab4ecc8024b11c5 | 5,250 | https://github.com/ichord/At.js/blob/454b83518d132c90fb42c29dbab4ecc8024b11c5/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | $query = $ '<span contenteditable="false"/>', @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.le... | null
# Get offset of current at char(`flag`)
#
# @return [Hash] the offset which look likes this: {top: y, left: x, bottom: bottom}
rect: ->
rect = @query.el.offset()
if @app.iframe and not @app.iframeAsRoot
iframeOffset = ($iframe = $ @app.iframe).offset()
rect.left += iframeOffset.left - ... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 454b83518d132c90fb42c29dbab4ecc8024b11c5 | 5,250 | https://github.com/ichord/At.js/blob/454b83518d132c90fb42c29dbab4ecc8024b11c5/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | $query = $ "<span/>", @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEn... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 8bae103b6dd019e351ce7d078b61c6cfe48397e2 | 5,250 | https://github.com/ichord/At.js/blob/8bae103b6dd019e351ce7d078b61c6cfe48397e2/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | $query = $ "<span/>", @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last().get(0)
if /firefox/i.test navigator.userAgent
range.setStart lastNode, lastNode.length
range.setEn... | null
# Get offset of current at char(`flag`)
#
# @return [Hash] the offset which look likes this: {top: y, left: x, bottom: bottom}
rect: ->
rect = @query.el.offset()
if @app.iframe and not @app.iframeAsRoot
iframeOffset = ($iframe = $ @app.iframe).offset()
rect.left += iframeOffset.left - ... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 8bae103b6dd019e351ce7d078b61c6cfe48397e2 | 5,250 | https://github.com/ichord/At.js/blob/8bae103b6dd019e351ce7d078b61c6cfe48397e2/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:1:raw_corpus | raw_corpus | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartA... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd | 5,250 | https://github.com/ichord/At.js/blob/8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd/src/editableController.coffee | 1 | 50 | ||
ichord/At.js:src/editableController.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == '... | var EditableController;
EditableController = class EditableController extends Controller {
_getRange() {
var sel;
sel = this.app.window.getSelection();
if (sel.rangeCount > 0) {
return sel.getRangeAt(0);
}
}
_setRange(position, node, range = this._getRange()) {
if (!range) {
retu... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | 8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd | 5,250 | https://github.com/ichord/At.js/blob/8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var EditableController;
EditableController = class EditableController extends Controller {
_getRange() {
var sel;
sel = this.app.window.getSelection();
if (sel.rangeCount > 0) {
return sel.getRangeAt(0);
}
}
_setRange(position, node, r... | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartA... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd | 5,250 | https://github.com/ichord/At.js/blob/8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:1:completion | completion | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartA... | sel.addRange range
_movingEvent: (e) ->
e.type == 'click' or e.which in [KEY_CODE.RIGHT, KEY_CODE.LEFT, KEY_CODE.UP, KEY_CODE.DOWN]
_unwrap: (node) ->
node = $(node).unwrap().get 0
if (next = node.nextSibling) and next.nodeValue
node.nodeValue += next.nodeValue
$(next).remove()
node
... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd | 5,250 | https://github.com/ichord/At.js/blob/8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | if e.which == KEY_CODE.ENTER
($query = $(range.startContainer).closest '.atwho-query')
.contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# ... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd | 5,250 | https://github.com/ichord/At.js/blob/8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:completion | completion | if e.which == KEY_CODE.ENTER
($query = $(range.startContainer).closest '.atwho-query')
.contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearRange()
return
# ... | else if e.which == KEY_CODE.LEFT and range.startContainer.nodeType == document.TEXT_NODE
$inserted = $ range.startContainer.previousSibling
if $inserted.is('.atwho-inserted') and range.startOffset == 0
@_setRange 'after', $inserted.contents().last()
# modifying inserted element
$(rang... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd | 5,250 | https://github.com/ichord/At.js/blob/8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ "<span/>", @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last(... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd | 5,250 | https://github.com/ichord/At.js/blob/8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ "<span/>", @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.addClass 'atwho-query'
range.surroundContents $query.get 0
lastNode = $query.contents().last(... | else if false != @callbacks('afterMatchFailed').call this, @at, $query
@_setRange "after", @_unwrap $query.text($query.text()).contents().first()
null
# Get offset of current at char(`flag`)
#
# @return [Hash] the offset which look likes this: {top: y, left: x, bottom: bottom}
rect: ->
rect... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd | 5,250 | https://github.com/ichord/At.js/blob/8078f2738d2b18bbeb0e8cae93d67a1ddfa032dd/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:1:raw_corpus | raw_corpus | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStar... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 1 | 50 | ||
ichord/At.js:src/editableController.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position ==... | var EditableController;
EditableController = class EditableController extends Controller {
_getRange() {
var sel;
sel = this.app.window.getSelection();
if (sel.rangeCount > 0) {
return sel.getRangeAt(0);
}
}
_setRange(position, node, range = this._getRange()) {
if (!range) {
retu... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var EditableController;
EditableController = class EditableController extends Controller {
_getRange() {
var sel;
sel = this.app.window.getSelection();
if (sel.rangeCount > 0) {
return sel.getRangeAt(0);
}
}
_setRange(position, node, r... | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStar... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:1:completion | completion | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStar... | sel.removeAllRanges()
sel.addRange range
_movingEvent: (e) ->
e.type == 'click' or e.which in [KEY_CODE.RIGHT, KEY_CODE.LEFT, KEY_CODE.UP, KEY_CODE.DOWN]
_unwrap: (node) ->
node = $(node).unwrap().get 0
if (next = node.nextSibling) and next.nodeValue
node.nodeValue += next.nodeValue
... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | delete @ctrl_pressed
if e.which == KEY_CODE.ENTER
($query = $(range.startContainer).closest '.atwho-query')
.contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearR... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:completion | completion | delete @ctrl_pressed
if e.which == KEY_CODE.ENTER
($query = $(range.startContainer).closest '.atwho-query')
.contents().unwrap()
$query.remove() if $query.is ':empty'
($query = $ ".atwho-query", @app.document)
.text $query.text()
.contents().last().unwrap()
@_clearR... | if $(_range.cloneContents()).contents().last().is '.atwho-inserted'
inserted = $(range.startContainer).contents().get(offset)
@_setRange 'after', $(inserted).contents().last()
else if e.which == KEY_CODE.LEFT and range.startContainer.nodeType == document.TEXT_NODE
$inserted = $ range.s... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | # wrapping query with .atwho-query
if $query.length == 0 and typeof matched is 'string' \
and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ "<span/>", @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.add... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 101 | 150 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | # wrapping query with .atwho-query
if $query.length == 0 and typeof matched is 'string' \
and (index = range.startOffset - @at.length - matched.length) >= 0
range.setStart range.startContainer, index
$query = $ "<span/>", @app.document
.attr @getOpt "editableAtwhoQueryAttrs"
.add... | if @_movingEvent(e) and $query.hasClass 'atwho-inserted'
$query.removeClass('atwho-query')
else if false != @callbacks('afterMatchFailed').call this, @at, $query
@_setRange "after", @_unwrap $query.text($query.text()).contents().first()
null
# Get offset of current at char(`flag`)
... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 101 | 150 |
ichord/At.js:src/editableController.coffee:4:raw_corpus | raw_corpus | .addClass 'atwho-inserted'
.html content
if range = @_getRange()
range.setEndAfter @query.el[0]
range.collapse false
range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 151 | 159 | ||
ichord/At.js:src/editableController.coffee:4:completion | completion | .addClass 'atwho-inserted'
.html content
if range = @_getRange()
range.setEndAfter @query.el[0] | range.collapse false
range.insertNode suffixNode = @app.document.createTextNode suffix
@_setRange 'after', suffixNode, range
@$inputor.focus() unless @$inputor.is ':focus'
@$inputor.change() | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7 | 5,250 | https://github.com/ichord/At.js/blob/c2920e38dba1f39c550bc2b3ff386e8c3d6b29d7/src/editableController.coffee | 151 | 159 |
ichord/At.js:src/editableController.coffee:1:raw_corpus | raw_corpus | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartAf... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 1 | 50 | ||
ichord/At.js:src/editableController.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'a... | var EditableController;
EditableController = class EditableController extends Controller {
_getRange() {
var sel;
sel = this.app.window.getSelection();
if (sel.rangeCount > 0) {
return sel.getRangeAt(0);
}
}
_setRange(position, node, range = this._getRange()) {
if (!range) {
retu... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var EditableController;
EditableController = class EditableController extends Controller {
_getRange() {
var sel;
sel = this.app.window.getSelection();
if (sel.rangeCount > 0) {
return sel.getRangeAt(0);
}
}
_setRange(position, node, r... | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartAf... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:1:completion | completion | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartAf... | _unwrap: (node) ->
node = $(node).unwrap().get 0
if (next = node.nextSibling) and next.nodeValue
node.nodeValue += next.nodeValue
$(next).remove()
node
catchQuery: (e) ->
return if @app.isComposing
return unless range = @_getRange()
if e.which == KEY_CODE.ENTER
($query = $(... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 1 | 50 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$inputor
@_clearRange()
return
if e.which == KEY_CODE.BACKSPACE and range.startContainer.nodeType == document.ELEMENT_NODE \
and (offset = range.startOffset - 1) >= 0
_range = range.cloneRange()
... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$inputor
@_clearRange()
return
if e.which == KEY_CODE.BACKSPACE and range.startContainer.nodeType == document.ELEMENT_NODE \
and (offset = range.startOffs... | var $inserted, $query, _range, index, inserted, lastNode, matched, offset;
if (/firefox/i.test(navigator.userAgent)) {
if ($(range.startContainer).is(this.$inputor)) {
this._clearRange();
return;
}
if (e.which === KEY_CODE.BACKSPACE && range.startContainer.nodeType === document.ELEMENT_NODE && (offset = ... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var $inserted, $query, _range, index, inserted, lastNode, matched, offset;
if (/firefox/i.test(navigator.userAgent)) {
if ($(range.startContainer).is(this.$inputor)) {
this._clearRange();
return;
}
if (e.which === KEY_CODE.BACKSPACE && range.startCon... | if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$inputor
@_clearRange()
return
if e.which == KEY_CODE.BACKSPACE and range.startContainer.nodeType == document.ELEMENT_NODE \
and (offset = range.startOffset - 1) >= 0
_range = range.cloneRange()
... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:2:completion | completion | if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$inputor
@_clearRange()
return
if e.which == KEY_CODE.BACKSPACE and range.startContainer.nodeType == document.ELEMENT_NODE \
and (offset = range.startOffset - 1) >= 0
_range = range.cloneRange()
... | $query.remove()
if not @_movingEvent e
$query.removeClass 'atwho-inserted'
# matching
_range = range.cloneRange()
_range.setStart range.startContainer, 0
matched = @callbacks("matcher").call(this, @at, _range.toString(), @getOpt 'startWithSpace')
# wrapping query with .atwho-query
i... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | # handle the matched result
if typeof matched is 'string' and matched.length <= @getOpt 'maxLen', 20
query = text: matched, el: $query
@trigger "matched", [@at, query.text]
@query = query
else
@view.hide()
@query = el: $query
if $query.text().indexOf(this.at) >= 0
if ... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 101 | 143 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | # handle the matched result
if typeof matched is 'string' and matched.length <= @getOpt 'maxLen', 20
query = text: matched, el: $query
@trigger "matched", [@at, query.text]
@query = query
else
@view.hide()
@query = el: $query
if $query.text().indexOf(this.at) >= 0
if ... | iframeOffset = ($iframe = $ @app.iframe).offset()
rect.left += iframeOffset.left - @$inputor.scrollLeft()
rect.top += iframeOffset.top - @$inputor.scrollTop()
rect.bottom = rect.top + @query.el.height()
rect
# Insert value of `data-value` attribute of chosen item into inputor
#
# @param conte... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 64ab00d4b86f12b2860963fd99aa91677419ee0f | 5,250 | https://github.com/ichord/At.js/blob/64ab00d4b86f12b2860963fd99aa91677419ee0f/src/editableController.coffee | 101 | 143 |
ichord/At.js:src/editableController.coffee:2:raw_corpus | raw_corpus | if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$inputor
@_clearRange()
return
if e.which == KEY_CODE.BACKSPACE and range.startContainer.nodeType == document.ELEMENT_NODE \
and (offset = range.startOffset - 1) >= 0
_range = range.cloneRange()
... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 4c1048b7673b48ca6d458aea1f916c1acf29a72b | 5,250 | https://github.com/ichord/At.js/blob/4c1048b7673b48ca6d458aea1f916c1acf29a72b/src/editableController.coffee | 51 | 100 | ||
ichord/At.js:src/editableController.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$inputor
@_clearRange()
return
if e.which == KEY_CODE.BACKSPACE and range.startContainer.nodeType == document.ELEMENT_NODE \
and (offset = range.startOffs... | var $inserted, $query, _range, index, inserted, lastNode, matched, offset, query;
if (/firefox/i.test(navigator.userAgent)) {
if ($(range.startContainer).is(this.$inputor)) {
this._clearRange();
return;
}
if (e.which === KEY_CODE.BACKSPACE && range.startContainer.nodeType === document.ELEMENT_NODE && (of... | CoffeeScript | JavaScript | ichord/At.js | src/editableController.coffee | MIT | 4c1048b7673b48ca6d458aea1f916c1acf29a72b | 5,250 | https://github.com/ichord/At.js/blob/4c1048b7673b48ca6d458aea1f916c1acf29a72b/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var $inserted, $query, _range, index, inserted, lastNode, matched, offset, query;
if (/firefox/i.test(navigator.userAgent)) {
if ($(range.startContainer).is(this.$inputor)) {
this._clearRange();
return;
}
if (e.which === KEY_CODE.BACKSPACE && range.s... | if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$inputor
@_clearRange()
return
if e.which == KEY_CODE.BACKSPACE and range.startContainer.nodeType == document.ELEMENT_NODE \
and (offset = range.startOffset - 1) >= 0
_range = range.cloneRange()
... | JavaScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 4c1048b7673b48ca6d458aea1f916c1acf29a72b | 5,250 | https://github.com/ichord/At.js/blob/4c1048b7673b48ca6d458aea1f916c1acf29a72b/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:2:completion | completion | if /firefox/i.test(navigator.userAgent)
if $(range.startContainer).is @$inputor
@_clearRange()
return
if e.which == KEY_CODE.BACKSPACE and range.startContainer.nodeType == document.ELEMENT_NODE \
and (offset = range.startOffset - 1) >= 0
_range = range.cloneRange()
... | if not @_movingEvent e
$query.removeClass 'atwho-inserted'
# matching
_range = range.cloneRange()
_range.setStart range.startContainer, 0
matched = @callbacks("matcher").call(this, @at, _range.toString(), @getOpt 'startWithSpace')
# wrapping query with .atwho-query
if $query.length == 0 ... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 4c1048b7673b48ca6d458aea1f916c1acf29a72b | 5,250 | https://github.com/ichord/At.js/blob/4c1048b7673b48ca6d458aea1f916c1acf29a72b/src/editableController.coffee | 51 | 100 |
ichord/At.js:src/editableController.coffee:3:raw_corpus | raw_corpus | @trigger "matched", [@at, query.text]
@query = query
else
@view.hide()
@query = el: $query
if $query.text().indexOf(this.at) >= 0
if @_movingEvent(e) and $query.hasClass 'atwho-inserted'
$query.removeClass('atwho-query')
else if false != @callbacks('afterMatchFailed... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 4c1048b7673b48ca6d458aea1f916c1acf29a72b | 5,250 | https://github.com/ichord/At.js/blob/4c1048b7673b48ca6d458aea1f916c1acf29a72b/src/editableController.coffee | 101 | 140 | ||
ichord/At.js:src/editableController.coffee:3:completion | completion | @trigger "matched", [@at, query.text]
@query = query
else
@view.hide()
@query = el: $query
if $query.text().indexOf(this.at) >= 0
if @_movingEvent(e) and $query.hasClass 'atwho-inserted'
$query.removeClass('atwho-query')
else if false != @callbacks('afterMatchFailed... | rect.top += iframeOffset.top - @$inputor.scrollTop()
rect.bottom = rect.top + @query.el.height()
rect
# Insert value of `data-value` attribute of chosen item into inputor
#
# @param content [String] string to insert
insert: (content, $li) ->
suffix = if suffix = @getOpt 'suffix' then suffix else su... | CoffeeScript | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | 4c1048b7673b48ca6d458aea1f916c1acf29a72b | 5,250 | https://github.com/ichord/At.js/blob/4c1048b7673b48ca6d458aea1f916c1acf29a72b/src/editableController.coffee | 101 | 140 |
ichord/At.js:src/editableController.coffee:1:raw_corpus | raw_corpus | class EditableController extends Controller
_getRange: ->
sel = @app.window.getSelection()
sel.getRangeAt(0) if sel.rangeCount > 0
_setRange: (position, node, range=@_getRange()) ->
return unless range
node = $(node)[0]
if position == 'after'
range.setEndAfter node
range.setStartAf... | CoffeeScript | ichord/At.js | src/editableController.coffee | MIT | dc17f2fd71bd966800d5c692852b12a456965912 | 5,250 | https://github.com/ichord/At.js/blob/dc17f2fd71bd966800d5c692852b12a456965912/src/editableController.coffee | 1 | 50 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.