Skip to content

Commit

Permalink
Converted jquery-js to jquery-coffee
Browse files Browse the repository at this point in the history
  • Loading branch information
tUrG0n committed Jan 5, 2014
1 parent 22b1a14 commit c52b4d1
Show file tree
Hide file tree
Showing 3 changed files with 749 additions and 0 deletions.
116 changes: 116 additions & 0 deletions snippets/coffee/angular_coffee.snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
## Global Snippets
# Define a new Angular Controller;
# You can change the controller name and parameters
snippet ngc
${1:controllerName} = (${2:scope}, ${3:injectables}) ->
${4}
# angular.foreach loop
snippet ngfor
angular.forEach ${1:iterateOver}, (value, key) ->
${2}
## Module Based Snippets
# A new angular module without a config function
snippet ngm
angular.module '${1:moduleName}', [${2:moduleDependencies}]
${3}
# A new angular module without a config function and a variable assignment
snippet ngma
${1:moduleName} = angular.module '$1', [${2:moduleDeps}]
${3}
# A new angular module with a config function
snippet ngmc
${1:moduleName} = angular.module('$1', [${2:moduleDeps}], (${3:configDeps}) ->
${4}
)
# A factory in a module
snippet ngmfa
factory '${1:factoryName}', (${2:dependencies}) ->
${3}
# Define an Angular Module Service to be attached to a previously defined module
# You can change the service name and service injectables
snippet ngms
service '${1:serviceName}', (${2:injectables}) ->
${3}
# Define an Angular Module Filter to be attached to a previously defined module
# You can change the filter name
snippet ngmfi
filter '${1:filterName}', (${2:injectables}) ->
(input, ${3:args}) ->
${4}
## Route Based Snippets
# Defines a when condition of an AngularJS route
snippet ngrw
$routeProvider.when '${1:url}',
templateUrl: '${2:templateUrl}'
controller: '${3:controller}'
${4}
# Defines a when condition of an AngularJS route with the resolve block
snippet ngrwr
$routeProvider.when '${1:url}',
templateUrl: '${2:templateUrl}'
controller: '${3:controller}'
resolve:
${4}
${5}
# Defines an otherwise condition of an AngularJS route
snippet ngro
$routeProvider.otherwise redirectTo: '${1:url}'
${2}
## Scope Related Snippets
# Define a new $scope'd function (usually inside an AngularJS Controller)
# You can change the function name and arguments
snippet $f
$scope.${1:functionName} = (${2:args}) ->
${3}
# Defines a new $scope'd variable inside an AngularJS controller
snippet $v
$scope.${1:variable} = ${2:value}
${3}
# Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a constructor arguments
snippet $va
$scope.${1:variable} = ${2:variable}
${3}
# Define a $watch for an expression
# You can change the expression to be watched
snippet $w
$scope.$watch '${1:watchExpr}', (newValue, oldValue) ->
${2}
# Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller
# You can change the event name to listen on
snippet $on
$scope.$on '${1:eventName}', (event, ${2:args}) ->
${3}
# Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $b
$scope.$broadcast '${1:eventName}', ${2:eventArgs}
${3}
# Define an $emit for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $e
$scope.$emit '${1:eventName}', ${2:eventArgs}
${3}
## Directive related snippets
# A compile function
snippet ngdcf
compile = (tElement, tAttrs, transclude) ->
(scope, element, attrs) ->
${1}
# A linking function in a directive
snippet ngdlf
(scope, element, attrs${1:ctrl}) ->
${2}
# A directive with a compile function
snippet ngdc
directive '${1:directiveName}', factory = (${2:injectables}) ->
directiveDefinitionObject =
${3:directiveAttrs}
compile: compile = (tElement, tAttrs, transclude) ->
(scope, element, attrs) ->
directiveDefinitionObject
# A directive with a linking function only
snippet ngdl
.directive('${1:directiveName}', (${2:directiveDeps}) ->
(scope, element, attrs${3:ctrl}) ->
${4}
)
109 changes: 109 additions & 0 deletions snippets/coffee/coffee.snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Closure loop
snippet forindo
for ${1:name} in ${2:array}
do ($1) ->
${0:// body}
# Array comprehension
snippet fora
for ${1:name} in ${2:array}
${0:# body...}
# Object comprehension
snippet foro
for ${1:key}, ${2:value} of ${3:object}
${0:# body...}
# Range comprehension (inclusive)
snippet forr
for ${1:name} in [${2:start}..${3:finish}]
${0:# body...}
snippet forrb
for ${1:name} in [${2:start}..${3:finish}] by ${4:step}
${0:# body...}
# Range comprehension (exclusive)
snippet forrex
for ${1:name} in [${2:start}...${3:finish}]
${0:# body...}
snippet forrexb
for ${1:name} in [${2:start}...${3:finish}] by ${4:step}
${0:# body...}
# Function
snippet fun
(${1:args}) ->
${0:# body...}
# Function (bound)
snippet bfun
(${1:args}) =>
${0:# body...}
# Class
snippet cla class ..
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
${0}
snippet cla class .. constructor: ..
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
constructor: (${2:args}) ->
${3}

${0}
snippet cla class .. extends ..
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
${0}
snippet cla class .. extends .. constructor: ..
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
constructor: (${3:args}) ->
${4}

${0}
# If
snippet if
if ${1:condition}
${0:# body...}
# If __ Else
snippet ife
if ${1:condition}
${2:# body...}
else
${0:# body...}
# Else if
snippet eif
else if ${1:condition}
${0:# body...}
# Ternary If
snippet ifte
if ${1:condition} then ${2:value} else ${0:other}
# Unless
snippet unl
${1:action} unless ${0:condition}
# Switch
snippet swi
switch ${1:object}
when ${2:value}
${0:# body...}

# Log
snippet log
console.log ${0}
# Try __ Catch
snippet try
try
${1}
catch ${2:error}
${0}
# Require
snippet req
${2:$1} = require '${1:sys}'
# Export
snippet exp
${0:root} = exports ? this


snippet ajax
$.ajax
url: "${1:mydomain.com/url}"
type: "${2:POST}"
dataType: "${3:xml/html/script/json}"
data: ${4:data}
complete: (jqXHR, textStatus) ->
${5:// callback}
success: (data, textStatus, jqXHR) ->
${6:// success callback}
error: (jqXHR, textStatus, errorThrown) ->
${0:// error callback}
Loading

0 comments on commit c52b4d1

Please sign in to comment.