aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/coffeescript/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'imports/codemirror/mode/coffeescript/index.html')
-rwxr-xr-ximports/codemirror/mode/coffeescript/index.html721
1 files changed, 721 insertions, 0 deletions
diff --git a/imports/codemirror/mode/coffeescript/index.html b/imports/codemirror/mode/coffeescript/index.html
new file mode 100755
index 00000000..127c4bf9
--- /dev/null
+++ b/imports/codemirror/mode/coffeescript/index.html
@@ -0,0 +1,721 @@
1<!doctype html>
2<html>
3 <head>
4 <title>CodeMirror: CoffeeScript mode</title>
5 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <script src="../../lib/codemirror.js"></script>
7 <script src="coffeescript.js"></script>
8 <style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
9 <link rel="stylesheet" href="../../doc/docs.css">
10 </head>
11 <body>
12 <h1>CodeMirror: CoffeeScript mode</h1>
13 <form><textarea id="code" name="code">
14# CoffeeScript mode for CodeMirror
15# Copyright (c) 2011 Jeff Pickhardt, released under
16# the MIT License.
17#
18# Modified from the Python CodeMirror mode, which also is
19# under the MIT License Copyright (c) 2010 Timothy Farrell.
20#
21# The following script, Underscore.coffee, is used to
22# demonstrate CoffeeScript mode for CodeMirror.
23#
24# To download CoffeeScript mode for CodeMirror, go to:
25# https://github.com/pickhardt/coffeescript-codemirror-mode
26
27# **Underscore.coffee
28# (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.**
29# Underscore is freely distributable under the terms of the
30# [MIT license](http://en.wikipedia.org/wiki/MIT_License).
31# Portions of Underscore are inspired by or borrowed from
32# [Prototype.js](http://prototypejs.org/api), Oliver Steele's
33# [Functional](http://osteele.com), and John Resig's
34# [Micro-Templating](http://ejohn.org).
35# For all details and documentation:
36# http://documentcloud.github.com/underscore/
37
38
39# Baseline setup
40# --------------
41
42# Establish the root object, `window` in the browser, or `global` on the server.
43root = this
44
45
46# Save the previous value of the `_` variable.
47previousUnderscore = root._
48
49
50# Establish the object that gets thrown to break out of a loop iteration.
51# `StopIteration` is SOP on Mozilla.
52breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration
53
54
55# Helper function to escape **RegExp** contents, because JS doesn't have one.
56escapeRegExp = (string) -> string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1')
57
58
59# Save bytes in the minified (but not gzipped) version:
60ArrayProto = Array.prototype
61ObjProto = Object.prototype
62
63
64# Create quick reference variables for speed access to core prototypes.
65slice = ArrayProto.slice
66unshift = ArrayProto.unshift
67toString = ObjProto.toString
68hasOwnProperty = ObjProto.hasOwnProperty
69propertyIsEnumerable = ObjProto.propertyIsEnumerable
70
71
72# All **ECMA5** native implementations we hope to use are declared here.
73nativeForEach = ArrayProto.forEach
74nativeMap = ArrayProto.map
75nativeReduce = ArrayProto.reduce
76nativeReduceRight = ArrayProto.reduceRight
77nativeFilter = ArrayProto.filter
78nativeEvery = ArrayProto.every
79nativeSome = ArrayProto.some
80nativeIndexOf = ArrayProto.indexOf
81nativeLastIndexOf = ArrayProto.lastIndexOf
82nativeIsArray = Array.isArray
83nativeKeys = Object.keys
84
85
86# Create a safe reference to the Underscore object for use below.
87_ = (obj) -> new wrapper(obj)
88
89
90# Export the Underscore object for **CommonJS**.
91if typeof(exports) != 'undefined' then exports._ = _
92
93
94# Export Underscore to global scope.
95root._ = _
96
97
98# Current version.
99_.VERSION = '1.1.0'
100
101
102# Collection Functions
103# --------------------
104
105# The cornerstone, an **each** implementation.
106# Handles objects implementing **forEach**, arrays, and raw objects.
107_.each = (obj, iterator, context) ->
108 try
109 if nativeForEach and obj.forEach is nativeForEach
110 obj.forEach iterator, context
111 else if _.isNumber obj.length
112 iterator.call context, obj[i], i, obj for i in [0...obj.length]
113 else
114 iterator.call context, val, key, obj for own key, val of obj
115 catch e
116 throw e if e isnt breaker
117 obj
118
119
120# Return the results of applying the iterator to each element. Use JavaScript
121# 1.6's version of **map**, if possible.
122_.map = (obj, iterator, context) ->
123 return obj.map(iterator, context) if nativeMap and obj.map is nativeMap
124 results = []
125 _.each obj, (value, index, list) ->
126 results.push iterator.call context, value, index, list
127 results
128
129
130# **Reduce** builds up a single result from a list of values. Also known as
131# **inject**, or **foldl**. Uses JavaScript 1.8's version of **reduce**, if possible.
132_.reduce = (obj, iterator, memo, context) ->
133 if nativeReduce and obj.reduce is nativeReduce
134 iterator = _.bind iterator, context if context
135 return obj.reduce iterator, memo
136 _.each obj, (value, index, list) ->
137 memo = iterator.call context, memo, value, index, list
138 memo
139
140
141# The right-associative version of **reduce**, also known as **foldr**. Uses
142# JavaScript 1.8's version of **reduceRight**, if available.
143_.reduceRight = (obj, iterator, memo, context) ->
144 if nativeReduceRight and obj.reduceRight is nativeReduceRight
145 iterator = _.bind iterator, context if context
146 return obj.reduceRight iterator, memo
147 reversed = _.clone(_.toArray(obj)).reverse()
148 _.reduce reversed, iterator, memo, context
149
150
151# Return the first value which passes a truth test.
152_.detect = (obj, iterator, context) ->
153 result = null
154 _.each obj, (value, index, list) ->
155 if iterator.call context, value, index, list
156 result = value
157 _.breakLoop()
158 result
159
160
161# Return all the elements that pass a truth test. Use JavaScript 1.6's
162# **filter**, if it exists.
163_.filter = (obj, iterator, context) ->
164 return obj.filter iterator, context if nativeFilter and obj.filter is nativeFilter
165 results = []
166 _.each obj, (value, index, list) ->
167 results.push value if iterator.call context, value, index, list
168 results
169
170
171# Return all the elements for which a truth test fails.
172_.reject = (obj, iterator, context) ->
173 results = []
174 _.each obj, (value, index, list) ->
175 results.push value if not iterator.call context, value, index, list
176 results
177
178
179# Determine whether all of the elements match a truth test. Delegate to
180# JavaScript 1.6's **every**, if it is present.
181_.every = (obj, iterator, context) ->
182 iterator ||= _.identity
183 return obj.every iterator, context if nativeEvery and obj.every is nativeEvery
184 result = true
185 _.each obj, (value, index, list) ->
186 _.breakLoop() unless (result = result and iterator.call(context, value, index, list))
187 result
188
189
190# Determine if at least one element in the object matches a truth test. Use
191# JavaScript 1.6's **some**, if it exists.
192_.some = (obj, iterator, context) ->
193 iterator ||= _.identity
194 return obj.some iterator, context if nativeSome and obj.some is nativeSome
195 result = false
196 _.each obj, (value, index, list) ->
197 _.breakLoop() if (result = iterator.call(context, value, index, list))
198 result
199
200
201# Determine if a given value is included in the array or object,
202# based on `===`.
203_.include = (obj, target) ->
204 return _.indexOf(obj, target) isnt -1 if nativeIndexOf and obj.indexOf is nativeIndexOf
205 return true for own key, val of obj when val is target
206 false
207
208
209# Invoke a method with arguments on every item in a collection.
210_.invoke = (obj, method) ->
211 args = _.rest arguments, 2
212 (if method then val[method] else val).apply(val, args) for val in obj
213
214
215# Convenience version of a common use case of **map**: fetching a property.
216_.pluck = (obj, key) ->
217 _.map(obj, (val) -> val[key])
218
219
220# Return the maximum item or (item-based computation).
221_.max = (obj, iterator, context) ->
222 return Math.max.apply(Math, obj) if not iterator and _.isArray(obj)
223 result = computed: -Infinity
224 _.each obj, (value, index, list) ->
225 computed = if iterator then iterator.call(context, value, index, list) else value
2