Skip to content

Instantly share code, notes, and snippets.

@11111000000
11111000000 / colorpicker.ls
Created March 15, 2014 01:47
Angular colorpicker service (LiveScript)
angular.module \app.services .factory \Colorpicker, [
\$templateCache
\$rootScope
\$appScope
\$compile
\$timeout
\$log
($templateCache, $rootScope, $appScope, $compile, $timeout, $log)->
->
@11111000000
11111000000 / colorpicker.jade
Created March 15, 2014 01:48
Angular colorpicker template (jade)
script(type='text/ng-template', id='colorpicker-template')
.color-container.animation(draggable, ng-show='shown', ng-style='elStyle', ng-keydown='keyDown($event)')
ul.color-palette(ng-show='palette')
li(class='color-preview')
.preview-box(ng-style='{backgroundColor: currentColor}', ng-click='select(currentColor)')
li.pal-pre(ng-repeat='color in palette')
.preview-box(ng-style='{backgroundColor: color}', ng-click='select(color)')
.color-sat-val(ng-style='{backgroundColor : baseColor}')
.color-sat
.color-val(drag='satValDrag($event,drag)', ng-mousedown='satValMousedown($event)')
@11111000000
11111000000 / myrange.ls
Created March 15, 2014 01:55
Angular range directive (LiveScript)
angular.module \app.directives .directive \myrange, [
\$compile
\$timeout
\$parse
\$log
($compile, $timeout, $parse, $log)->
restrict: \A
require: \ngModel
templateUrl: \myrange-template
@11111000000
11111000000 / myrange.jade
Created March 15, 2014 01:56
Angular range directive template (jade)
script(type='text/ng-template', id='myrange-template')
.rangenum.myrange(ng-class="{ 'undefined' : item == null }")
.range(ng-click='rangeClick($event)')
.dragger(drag='draggerDrag( $event, drag )', dragstart='draggerDragStart( $event, drag )', dragend='draggerDragEnd( $event, drag )')
.fly-value(ng-bind='text')
input.i_bw2(ng-if="!noInput", ng-model = 'text', ng-keyup = 'keyup( $event )' )
@11111000000
11111000000 / selector.ls
Created March 15, 2014 01:59
Angular selector directive (LiveScript)
angular.module \app.directives .directive \selector, [
\$compile
\$parse
\$templateCache
\$appScope
\$timeout
($compile, $parse, $templateCache, $appScope, $timeout)->
restrict: \A
templateUrl: \selector-template
replace: true
@11111000000
11111000000 / group-padma.ls
Created March 15, 2014 02:02
Angular directive example (LiveScript)
angular.module \app.directives .directive \groupPadma, [
\$templateCache
\Lang
\$log
($templateCache, Lang,$log)->
restrict: \EA
replace: yes
transclude: no
templateUrl: \group-padma-template
priority: 10
@11111000000
11111000000 / _colorpicker.styl
Created March 15, 2014 02:05
Angular colorpicker style (stylus)
colorpickerContainerWidth = 192px
paletteColorSize = 24px
.color-container
position fixed
width colorpickerContainerWidth
z-index 10000
padding 5px
background: #f9f9f9
border 1px solid gray
@11111000000
11111000000 / logDecorator.ls
Created March 15, 2014 02:06
Angular.js log decorator (LiveScript). Support for "@ |> log" watches with diff (functions.ls)
# -*- mode: livescript -*-
#
# Log decorator
# author: Peter
#
do ->
module = angular.module \logDecorator, []
module.config [
\$provide
@11111000000
11111000000 / functions.ls
Created March 15, 2014 02:10
Some livescript functions
window <<<<
isGradient: -> (it |> /^\s*([a-z]+)\-gradient\(\s*(.*)\s*\)\s*$/gmi.exec)?[1] in <[ linear radial ]>
toFixedOrInt: (precision, value)-->
a={}
power = 10 `Math.pow` (precision or 0)
value = Math.round(value * power) / power
rounded = value |> Math.round
if rounded is value then value = rounded