-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathfiddle.html
172 lines (160 loc) · 8.69 KB
/
fiddle.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fiddling with Cards JS</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<link href="cards.css" rel="stylesheet" type="text/css">
<link href="site/bootstrap-slider.min.css" rel="stylesheet" type="text/css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style type="text/css">
div.option
{
padding-bottom: 1.8em;
padding-left: 2em;
}
input.option
{
width: 4em;
}
label.btn > input[type='radio']
{
display: none;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="jumbotron">
<div class="container">
<h1>
Fiddling a Hand</h1>
</div>
</div>
<!-- issues with KO and bootstrap, see http://volaresystems.com/blog/post/2013/12/09/Using-Bootstrap-3-radio-button-groups-with-Knockout-3-data-bindings -->
<div class="btn-group">
<label class="btn btn-default" data-bind="css: { 'active': layout() === 'fan' }">
<input type="radio" name="options" id="option1" data-bind="checked: layout, checkedValue: 'fan'">Fan
</label>
<label class="btn btn-default" data-bind="css: { 'active': layout() === 'hand' }">
<input type="radio" name="options" id="option2" data-bind="checked: layout, checkedValue: 'hand'">Standard
</label>
</div>
<div data-bind="visible: layout() == 'fan'">
<h2>
Fan layout</h2>
<div class="row">
<div class="col-md-6">
<p>
A 3D look and feel to hand. Each card is rotated and overlapped. Suitable for displaying
the player's hand. Hovering over the card will make it jump up.
</p>
<div class="hand active-hand" id="fan-cards" data-bind="fan: {spacing: spacing, radius: radius, width: width, cards: cards}">
</div>
</div>
<div class="col-md-4" id='options'>
<p>
The <code>radius</code> of the circle under the fan of cards. Controls the overall
curvature of the fan. Small values means higher curvature.</p>
<div class="option">
<input type="text" class="option" data-bind="value: radius" />
<input type="text" class="slider form-control" data-bind="sliderValue: {value: radius, min: 0, max: 800, selection: 'none'}" />
</div>
<p>
The <code>spacing</code> is a percentage of the card that is shown.</p>
<div class="option">
<input type="text" class="option" data-bind="value: spacing" />
<input type="text" class="slider form-control" data-bind="sliderValue: {value: spacing, min: 0, max: 1, step: 0.01, selection: 'none', formatter: function(v) { return (v * 10) / 10;} }" />
</div>
<p>
The <code>width</code> is the pixel width of the card image. The height is automatically calculated
to maintain the aspect ratio.</p>
<div class="option">
<input type="text" class="option" data-bind="value: width" />
<input type="text" class="slider form-control" data-bind="sliderValue: {value: width, min: 0, max: 300, step: 1, selection: 'none'}" />
</div>
</div>
</div>
</div>
<div data-bind="visible: layout() == 'hand'">
<h2>
Standard layout</h2>
<div class="row">
<div class="col-md-6">
<p>
A horizontal or vertical layout where cards can overlap. Hovering over the card will make
it jump.</p>
<div class="hand active-hand" data-bind="hand: {spacing: spacing, flow: flow, width: width, cards: cards}">
</div>
</div>
<div class="col-md-4">
<p>
The <code>flow</code> determines the direction of the cards (left to right or top to bottom).</p>
<div class="btn-group option">
<label class="btn btn-default btn-sm" data-bind="css: { 'active': flow() === 'horizontal' }">
<input type="radio" data-bind="checked: flow, checkedValue: 'horizontal'">Horizontal
</label>
<label class="btn btn-default btn-sm" data-bind="css: { 'active': flow() === 'vertical' }">
<input type="radio" data-bind="checked: flow, checkedValue: 'vertical'">Vertical
</label>
</div>
<p>
The <code>spacing</code> is a percentage of the card that is shown. A value of '1'
indicates no overlap.</p>
<div class="option">
<input type="text" class="option" data-bind="value: spacing" />
<input type="text" class="slider form-control" data-bind="sliderValue: {value: spacing, min: 0, max: 1, step: 0.01, selection: 'none', formatter: function(v) { return (v * 10) / 10;} }" />
</div>
<p>
The <code>width</code> is the pixel width of the card image. The height is automatically calculated
to maintain the aspect ratio.</p>
<div class="option">
<input type="text" class="option" data-bind="value: width" />
<input type="text" class="slider form-control" data-bind="sliderValue: {value: width, min: 0, max: 300, step: 1, selection: 'none'}" />
</div>
</div>
</div>
</div>
<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type='text/javascript' src='http://cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-min.js'></script>
<script src="cards.js" type="text/javascript"></script>
<script src="cards-ko.js" type="text/javascript"></script>
<script type='text/javascript' src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script type='text/javascript' src="site/bootstrap-slider.min.js"></script>
<script type='text/javascript' src="site/bootstrap-slider-knockout-binding.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var fiddle = {
radius: ko.observable(80),
spacing: ko.observable(0.1),
layout: ko.observable('fan'),
flow: ko.observable('horizontal'),
width: ko.observable(90),
cards: ko.observable("AS KS QS JS 10S 9H 3H 2H 10D 4D 8C 7C 6C"),
fixed: function (v) {
return (v * 10) / 10;
}
};
ko.applyBindings(fiddle);
});
</script>
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-60043592-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>