Skip to content

Commit

Permalink
update error & urlTransform logic
Browse files Browse the repository at this point in the history
  • Loading branch information
samsep committed Nov 18, 2015
1 parent 5fef9d3 commit 76b8c08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions src/scripts/controllers/visual.controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ SubmitWorkVisualController = ($scope, $rootScope, $state, SubmitWorkService, Sub
vm.urlAdded = false
vm.styleModals = ['fonts', 'colors', 'icons']
vm.urlRegEx = /^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/
vm.urlError = false

vm.showChooseStyles = ->
vm.showPaths = false
Expand Down Expand Up @@ -73,15 +72,11 @@ SubmitWorkVisualController = ($scope, $rootScope, $state, SubmitWorkService, Sub
else if vm.showChooseStylesModal
vm.hideChooseStyles()
else if vm.showUrlStylesModal
unless vm.urlError
unless $scope.urlForm.addressInput.$error.pattern
vm.hideUrlStyles()

vm.checkAddressValidity = ->
urlValid = vm.urlRegEx.test vm.url
vm.urlError = !urlValid

transformToUrl = (address) ->
if address.substr(0, 5) != 'http'
if address.substr(0, 4) != 'http'
"http://#{address}"

getUpdates = ->
Expand All @@ -92,7 +87,7 @@ SubmitWorkVisualController = ($scope, $rootScope, $state, SubmitWorkService, Sub
fontIds: if vm.font then [ vm.font ] else null
colorSwatchIds: vm.colors.filter(isSelected).map(getId)
iconsetIds: if vm.icon then [ vm.icon ] else null
designUrls: if vm.url && !vm.urlError then [ transformToUrl(vm.url) ] else null
designUrls: if vm.url && !$scope.urlForm.addressInput.$error.pattern then [ transformToUrl(vm.url) ] else null

updates

Expand Down
4 changes: 2 additions & 2 deletions src/views/submit-work-visuals.directive.jade
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ header
button.action.wide(ng-click="vm.showUploadStyles()") select

li
img.icon.big.biggest(ng-if="!vm.urlAdded || vm.urlError" src="/images/url-styles.svg")
img.icon.big.biggest(ng-if="!vm.urlAdded || urlForm.addressInput.$error.pattern" src="/images/url-styles.svg")

img.icon.big.biggest(ng-if="vm.urlAdded && !vm.urlError" src="/images/url-styles-selected.svg")
img.icon.big.biggest(ng-if="vm.urlAdded && !urlForm.addressInput.$error.pattern" src="/images/url-styles-selected.svg")

h4 Get style from url

Expand Down

0 comments on commit 76b8c08

Please sign in to comment.