Fixing color selection

stable
Alejandro Alonso 2014-07-23 15:03:25 +02:00
parent ef364a43ac
commit 1608c42678
2 changed files with 7 additions and 2 deletions

View File

@ -252,6 +252,9 @@ ColorSelectionDirective = () ->
link = ($scope, $el, $attrs, $model) -> link = ($scope, $el, $attrs, $model) ->
$ctrl = $el.controller() $ctrl = $el.controller()
$scope.$watch $attrs.ngModel, (element) ->
$scope.color = element.color
$el.on "click", ".current-color", (event) -> $el.on "click", ".current-color", (event) ->
# Showing the color selector # Showing the color selector
event.preventDefault() event.preventDefault()
@ -276,6 +279,8 @@ ColorSelectionDirective = () ->
$el.on "click", ".select-color .selected-color", (event) -> $el.on "click", ".select-color .selected-color", (event) ->
event.preventDefault() event.preventDefault()
$scope.$apply ->
$model.$modelValue.color = $scope.color
$el.find(".select-color").hide() $el.find(".select-color").hide()
$scope.$on "$destroy", -> $scope.$on "$destroy", ->

View File

@ -22,5 +22,5 @@ div.popover.select-color
li.color(style="background: #a40000", data-color="#a40000") li.color(style="background: #a40000", data-color="#a40000")
li.color(style="background: #2e3436", data-color="#2e3436") li.color(style="background: #2e3436", data-color="#2e3436")
input(type="text", placeholder="personalized colors", ng-model="status.color") input(type="text", placeholder="personalized colors", ng-model="color")
div.selected-color(style="background-color: {{ status.color }}") div.selected-color(style="background-color: {{ color }}")