You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/assets/javascripts/models/entry.coffee

47 lines
928 B

11 years ago
class app.models.Entry extends app.Model
# Attributes: name, type, path
SEPARATORS_REGEXP = /\:?\ |#|::|->/g
11 years ago
PARANTHESES_REGEXP = /\(.*?\)$/
constructor: ->
super
@text = @searchValue()
searchValue: ->
@name
.toLowerCase()
11 years ago
.replace '...', ' '
.replace ' event', ''
.replace SEPARATORS_REGEXP, '.'
.replace /\.+/g, '.'
.replace PARANTHESES_REGEXP, ''
11 years ago
.trim()
fullPath: ->
@doc.fullPath if @isIndex() then '' else @path
filePath: ->
@doc.fullPath @_filePath()
fileUrl: ->
@doc.fileUrl @_filePath()
_filePath: ->
result = @path.replace /#.*/, ''
result += '.html' unless result[-5..-1] is '.html'
result
isIndex: ->
@path is 'index'
getType: ->
@doc.types.findBy 'name', @type
loadFile: (onSuccess, onError) ->
ajax
url: @fileUrl()
dataType: 'html'
success: onSuccess
error: onError