Skip to content

Commit c52b4d1

Browse files
author
tUrG0n
committed
Converted jquery-js to jquery-coffee
1 parent 22b1a14 commit c52b4d1

File tree

3 files changed

+749
-0
lines changed

3 files changed

+749
-0
lines changed
+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
## Global Snippets
2+
# Define a new Angular Controller;
3+
# You can change the controller name and parameters
4+
snippet ngc
5+
${1:controllerName} = (${2:scope}, ${3:injectables}) ->
6+
${4}
7+
# angular.foreach loop
8+
snippet ngfor
9+
angular.forEach ${1:iterateOver}, (value, key) ->
10+
${2}
11+
## Module Based Snippets
12+
# A new angular module without a config function
13+
snippet ngm
14+
angular.module '${1:moduleName}', [${2:moduleDependencies}]
15+
${3}
16+
# A new angular module without a config function and a variable assignment
17+
snippet ngma
18+
${1:moduleName} = angular.module '$1', [${2:moduleDeps}]
19+
${3}
20+
# A new angular module with a config function
21+
snippet ngmc
22+
${1:moduleName} = angular.module('$1', [${2:moduleDeps}], (${3:configDeps}) ->
23+
${4}
24+
)
25+
# A factory in a module
26+
snippet ngmfa
27+
factory '${1:factoryName}', (${2:dependencies}) ->
28+
${3}
29+
# Define an Angular Module Service to be attached to a previously defined module
30+
# You can change the service name and service injectables
31+
snippet ngms
32+
service '${1:serviceName}', (${2:injectables}) ->
33+
${3}
34+
# Define an Angular Module Filter to be attached to a previously defined module
35+
# You can change the filter name
36+
snippet ngmfi
37+
filter '${1:filterName}', (${2:injectables}) ->
38+
(input, ${3:args}) ->
39+
${4}
40+
## Route Based Snippets
41+
# Defines a when condition of an AngularJS route
42+
snippet ngrw
43+
$routeProvider.when '${1:url}',
44+
templateUrl: '${2:templateUrl}'
45+
controller: '${3:controller}'
46+
${4}
47+
# Defines a when condition of an AngularJS route with the resolve block
48+
snippet ngrwr
49+
$routeProvider.when '${1:url}',
50+
templateUrl: '${2:templateUrl}'
51+
controller: '${3:controller}'
52+
resolve:
53+
${4}
54+
${5}
55+
# Defines an otherwise condition of an AngularJS route
56+
snippet ngro
57+
$routeProvider.otherwise redirectTo: '${1:url}'
58+
${2}
59+
## Scope Related Snippets
60+
# Define a new $scope'd function (usually inside an AngularJS Controller)
61+
# You can change the function name and arguments
62+
snippet $f
63+
$scope.${1:functionName} = (${2:args}) ->
64+
${3}
65+
# Defines a new $scope'd variable inside an AngularJS controller
66+
snippet $v
67+
$scope.${1:variable} = ${2:value}
68+
${3}
69+
# Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a constructor arguments
70+
snippet $va
71+
$scope.${1:variable} = ${2:variable}
72+
${3}
73+
# Define a $watch for an expression
74+
# You can change the expression to be watched
75+
snippet $w
76+
$scope.$watch '${1:watchExpr}', (newValue, oldValue) ->
77+
${2}
78+
# Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller
79+
# You can change the event name to listen on
80+
snippet $on
81+
$scope.$on '${1:eventName}', (event, ${2:args}) ->
82+
${3}
83+
# Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function
84+
# You can change the event name and optional event arguments
85+
snippet $b
86+
$scope.$broadcast '${1:eventName}', ${2:eventArgs}
87+
${3}
88+
# Define an $emit for a $scope inside an Angular Controller / Angular Controller Function
89+
# You can change the event name and optional event arguments
90+
snippet $e
91+
$scope.$emit '${1:eventName}', ${2:eventArgs}
92+
${3}
93+
## Directive related snippets
94+
# A compile function
95+
snippet ngdcf
96+
compile = (tElement, tAttrs, transclude) ->
97+
(scope, element, attrs) ->
98+
${1}
99+
# A linking function in a directive
100+
snippet ngdlf
101+
(scope, element, attrs${1:ctrl}) ->
102+
${2}
103+
# A directive with a compile function
104+
snippet ngdc
105+
directive '${1:directiveName}', factory = (${2:injectables}) ->
106+
directiveDefinitionObject =
107+
${3:directiveAttrs}
108+
compile: compile = (tElement, tAttrs, transclude) ->
109+
(scope, element, attrs) ->
110+
directiveDefinitionObject
111+
# A directive with a linking function only
112+
snippet ngdl
113+
.directive('${1:directiveName}', (${2:directiveDeps}) ->
114+
(scope, element, attrs${3:ctrl}) ->
115+
${4}
116+
)

snippets/coffee/coffee.snippets

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Closure loop
2+
snippet forindo
3+
for ${1:name} in ${2:array}
4+
do ($1) ->
5+
${0:// body}
6+
# Array comprehension
7+
snippet fora
8+
for ${1:name} in ${2:array}
9+
${0:# body...}
10+
# Object comprehension
11+
snippet foro
12+
for ${1:key}, ${2:value} of ${3:object}
13+
${0:# body...}
14+
# Range comprehension (inclusive)
15+
snippet forr
16+
for ${1:name} in [${2:start}..${3:finish}]
17+
${0:# body...}
18+
snippet forrb
19+
for ${1:name} in [${2:start}..${3:finish}] by ${4:step}
20+
${0:# body...}
21+
# Range comprehension (exclusive)
22+
snippet forrex
23+
for ${1:name} in [${2:start}...${3:finish}]
24+
${0:# body...}
25+
snippet forrexb
26+
for ${1:name} in [${2:start}...${3:finish}] by ${4:step}
27+
${0:# body...}
28+
# Function
29+
snippet fun
30+
(${1:args}) ->
31+
${0:# body...}
32+
# Function (bound)
33+
snippet bfun
34+
(${1:args}) =>
35+
${0:# body...}
36+
# Class
37+
snippet cla class ..
38+
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
39+
${0}
40+
snippet cla class .. constructor: ..
41+
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
42+
constructor: (${2:args}) ->
43+
${3}
44+
45+
${0}
46+
snippet cla class .. extends ..
47+
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
48+
${0}
49+
snippet cla class .. extends .. constructor: ..
50+
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
51+
constructor: (${3:args}) ->
52+
${4}
53+
54+
${0}
55+
# If
56+
snippet if
57+
if ${1:condition}
58+
${0:# body...}
59+
# If __ Else
60+
snippet ife
61+
if ${1:condition}
62+
${2:# body...}
63+
else
64+
${0:# body...}
65+
# Else if
66+
snippet eif
67+
else if ${1:condition}
68+
${0:# body...}
69+
# Ternary If
70+
snippet ifte
71+
if ${1:condition} then ${2:value} else ${0:other}
72+
# Unless
73+
snippet unl
74+
${1:action} unless ${0:condition}
75+
# Switch
76+
snippet swi
77+
switch ${1:object}
78+
when ${2:value}
79+
${0:# body...}
80+
81+
# Log
82+
snippet log
83+
console.log ${0}
84+
# Try __ Catch
85+
snippet try
86+
try
87+
${1}
88+
catch ${2:error}
89+
${0}
90+
# Require
91+
snippet req
92+
${2:$1} = require '${1:sys}'
93+
# Export
94+
snippet exp
95+
${0:root} = exports ? this
96+
97+
98+
snippet ajax
99+
$.ajax
100+
url: "${1:mydomain.com/url}"
101+
type: "${2:POST}"
102+
dataType: "${3:xml/html/script/json}"
103+
data: ${4:data}
104+
complete: (jqXHR, textStatus) ->
105+
${5:// callback}
106+
success: (data, textStatus, jqXHR) ->
107+
${6:// success callback}
108+
error: (jqXHR, textStatus, errorThrown) ->
109+
${0:// error callback}

0 commit comments

Comments
 (0)