Skip to content

Instantly share code, notes, and snippets.

@brunocarvalhodearaujo
Created November 9, 2016 17:49
Show Gist options
  • Save brunocarvalhodearaujo/c3666c6a63ca071a09043358899dd001 to your computer and use it in GitHub Desktop.
Save brunocarvalhodearaujo/c3666c6a63ca071a09043358899dd001 to your computer and use it in GitHub Desktop.
export default {
bindings: {
colors: '<',
selector: '@'
},
templateUrl: 'views/color-picker.html',
controller: class {
//@ngInject
constructor($window, $timeout) {
this.$ = $window.$
this.display = true
}
$doCheck() {
this.$('.pallete > [data-color]').draggable({
appendTo: 'body',
revert: 'invalid',
helper: 'clone',
containment: 'window',
start: event => {
this.color = $(event.toElement).attr('data-color')
}
})
this.$(this.selector).droppable({
tolerance: 'pointer',
greedy: true,
accept: '[data-color]',
drop: event => this.$(event.target).css({ [ $(event.target).attr('wf-custom') ]: this.color })
})
}
}
}
.color-pick(ng-if='$ctrl.display')
ul.pallete
li(ng-repeat='(name, color) in $ctrl.colors', data-color='{{ color }}', ng-style="{ background: color }", ng-click='$ctrl.color = color')
button.btn-color-picker(ng-style='{ color: "#1565C0" }', ng-click='$ctrl.display = !$ctrl.display') !{'\uf1fc'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment