Skip to content

Commit

Permalink
Added label icons
Browse files Browse the repository at this point in the history
  • Loading branch information
standup75 committed May 29, 2014
1 parent 85b9876 commit f19a6a1
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 90 deletions.
45 changes: 28 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,34 @@ And don't forget to add the module to your application
Options
-------

thickness: "@?"
centerColor: "@?"
labelColors: "=?"
labelIcons: "=?"
fontSize: "@?"
fontFamily: "@?"
colors: "=?"
snap: "=?"

- thickness: Thickness of the wheel. Could in % or in pixel. Exemple: thickness: "25%" or thickness: "100px". Default: 25%
- centerColor: The color in the middle of the wheel. Defaults to white
- labelColors: Labels color for each section. Array of n strings, where n == number of sections. Defaults to white
- labelIcons: Icon url for each section. Array of n strings, where n == number of sections. Defaults to empty
- fontSize: font size of the labels in pixels. defaults to 18
- fontFamily: font family to be used for the labels. Defaults to helvetica
- colors: Background color for each section. Array of n strings, where n == number of sections. Defaults to #666 and #999 alternatively
- snap: false | true. When turning the wheel, set this to true (default) if you want the wheel to snap to the nearest section
- `thickness`: Thickness of the wheel. Could in % or in pixel. Exemple: thickness: "25%" or thickness: "100px". Default: 25%
- `centerColor`: The color in the middle of the wheel. Defaults to white
- `labelColors`: Labels color for each section. Array of n strings, where n == number of sections. Defaults to white
- `labelIcons`: (Coming soon!) Icon url for each section. Array of n strings, where n == number of sections. Defaults to empty
- `fontSize`: font size of the labels in pixels. defaults to 18
- `fontFamily`: font family to be used for the labels. Defaults to helvetica
- `colors`: Background color for each section. Array of n strings, where n == number of sections. Defaults to #666 and #999 alternatively
- `snap`: false | true. When turning the wheel, set this to true (default) if you want the wheel to snap to the nearest section
- `iconsRatio`: How much smaller should be the icon displayed compared to their actual size. Defaults to 0.5 (good for retina displays)

Events broadcast
---------------

2 events are broadcasted on the $rootScope:
- `roulette:turned`: When you have turned the wheel. Sends the section on top
- `roulette:select`: When you have clicked (or touched) a section of the wheel (without turning it). Sends the selected section

Both events are broadcast with label, color, labelColor, and icon url of the section

label: "Section 1"
color: "#555500"
labelColor: "#ffffff"
icon: "/images/cog.png"

So, you can listen to this event like this:

$scope.$on("roulette:turned", function(e, info){ console.log("Event: roulette:turned - Params: " + JSON.stringify info); });
$scope.$on("roulette:select", function(e, info){ console.log("Event: roulette:turned - Params: " + JSON.stringify info); });

Demo
----
Expand Down
Binary file added demo/images/abc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/images/benafro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/images/cog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/images/envelop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/images/group.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/images/wrench.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions demo/scripts/controllers/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
angular.module("rouletteDemo").controller "MainCtrl", ($scope) ->
$scope.colors ||= ["#da355a", "#5da44d", "#ef7b54", "#4284a6", "#f1bd62", "#7d5aa2"]
$scope.labels = ["section 1", "section 2", "section 3", "section 4", "section 5", "section 6"]
$scope.labelColors = ["#ffff00", "#ffffff", "#ffffff", "#ffffff", "#ffffff", "#ffffff"]
$scope.labelIcons = ["/images/benafro.png", "/images/cog.png", "/images/abc.png", "/images/envelop.png", "/images/group.png", "/images/wrench.png"]
$scope.eventInfo = "Turn the wheel or click on a section to see the event displayed here"
$scope.$on "roulette:turned", (e, info) ->
$scope.$apply ->
$scope.eventInfo = "Event: roulette:turned - Params: #{JSON.stringify info}"
$scope.$on "roulette:click", (e, info) ->
$scope.$on "roulette:select", (e, info) ->
$scope.$apply ->
$scope.eventInfo = "Event: roulette:click - Params: #{JSON.stringify info}"
$scope.eventInfo = "Event: roulette:select - Params: #{JSON.stringify info}"
4 changes: 3 additions & 1 deletion demo/styles/main.css
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/* Will be compiled down to a single stylesheet with your sass files */
body { background-color: #eee; }
roulette { margin: 40px; }
.info { padding:10px; margin: 10px; background: #ddd; }
6 changes: 3 additions & 3 deletions demo/views/main.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="info" style="padding:10px; margin: 10px; background: #ddd;">{{eventInfo}}&nbsp;</div>
<roulette
colors="colors"
labels="labels"
label-colors="label-colors"
label-icons="label-icons"></roulette>
label-colors="labelColors"
label-icons="labelIcons"></roulette>
<div class="info">{{eventInfo}}&nbsp;</div>
170 changes: 127 additions & 43 deletions roulette.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f19a6a1

Please sign in to comment.