carte-server 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99769a564e742a16255fc44868be47a9261426b8
4
- data.tar.gz: 0ac68e8f661307f16bfa56304458172a88d61d76
3
+ metadata.gz: a988b4ffc64e624ab4703f6978e40eaec2d3e32d
4
+ data.tar.gz: 5e4a4519d061bf29a4b89006430812b7a7a446b9
5
5
  SHA512:
6
- metadata.gz: b693433479183047c08235018ba8b458a2034e60ff86ef25c5810ebf968d78b989d5727c13db32aa8d12ce95b4bfc43f23591d226a66cde3caaf3c1dea2cb03a
7
- data.tar.gz: 6991424bc9053579af6c18c5f06362581de4d021924e03fdb3a79337609c818a30f2818b0682ffeb2c981a2c26ee57dff5671609aea56a1833d0d8f8be23a9f3
6
+ metadata.gz: 9979a1dc96578eead74536780ad69eeea39e2a529438ce6164c790d9ea582ef5ed3adccee58dcbbaca1a695578b60fb74194a71d6543890ce9f6fe911dcff586
7
+ data.tar.gz: e136696b82768ec243296ee587f905c46dbc111f7bccfed643670aab2faafe2a212bb0b3c7094e25a992ebf2a60919c34a67bdf53457e6fa38c5b4a650b60e69
@@ -11,12 +11,14 @@ MenuItem = require('react-bootstrap').MenuItem
11
11
  ButtonGroup = require('react-bootstrap').ButtonGroup
12
12
  Button = require('react-bootstrap').Button
13
13
 
14
- #window.onerror = (error, url, line) -> alert error
14
+ window.onerror = (error, url, line) -> alert error
15
15
 
16
16
  Flash = React.createClass
17
17
  componentDidMount: ->
18
18
  console.log '[views/flash] componentDidMount', @props
19
19
  $(document).on 'keydown', @onKeyDown
20
+ #for eventName in ['touchstart', 'touchmove', 'touchend', 'gesturestart', 'gesturechange', 'gestureend']
21
+ # $(document).on eventName, (event)-> event.preventDefault(); event.stopPropagation()
20
22
 
21
23
  @setState currCards: @props.cards
22
24
 
@@ -33,6 +35,7 @@ Flash = React.createClass
33
35
  @forceUpdate.bind(@, null)
34
36
 
35
37
  componentWillUnmount: ->
38
+ console.log '[views/flash] FlashMain componentWillUnmount'
36
39
  $(document).off 'keydown', @onKeyDown
37
40
 
38
41
  onKeyDown: (event)->
@@ -101,16 +104,38 @@ Flash = React.createClass
101
104
  @setState prevCards: prevCards
102
105
 
103
106
  onTouchStart: (event)->
104
- @touchStartX = event.changedTouches[0].pageX
107
+ touchStart =
108
+ x: event.touches[0].pageX
109
+ y: event.touches[0].pageY
110
+ time: new Date
111
+ if !@tapped
112
+ @tapped = setTimeout =>
113
+ @touchStart = touchStart
114
+ @touchDelta = {}
115
+ @tapped = null
116
+ , 300
117
+ else
118
+ clearTimeout @tapped
119
+ @tapped = null
120
+ @setState showTools: !@state.showTools
121
+
122
+ onTouchMove: (event)->
123
+ return if !@touchStart
124
+ return if ( event.touches.length > 1 || event.scale && event.scale != 1)
125
+
126
+ @touchDelta =
127
+ x: event.touches[0].pageX - @touchStart.x
128
+ y: event.touches[0].pageY - @touchStart.y
105
129
 
106
130
  onTouchEnd: (event)->
107
- touchEndX = event.changedTouches[0].pageX
108
- distance = touchEndX - @touchStartX
109
- if Math.abs(distance) > 100
110
- if distance > 0
111
- @onClickNext()
112
- else
113
- @onClickPrev()
131
+ return if !@touchStart
132
+ duration = new Date - @touchStart.time
133
+ isValid = Number(duration) < 250 && Math.abs(@touchDelta.x) > 20
134
+ if @touchDelta.x < 0
135
+ @onClickNext()
136
+ else
137
+ @onClickPrev()
138
+ @touchStart = null
114
139
 
115
140
  onClickNext: ->
116
141
  if @props.cards.query.hide != 'none' && @state.hiding
@@ -154,28 +179,37 @@ Flash = React.createClass
154
179
  onMouseLeaveTools: ()->
155
180
  @setState showTools: false
156
181
 
157
- onClick: ->
158
- @setState showTools: !@state.showTools
159
-
160
182
  queryParam: (query)->
161
183
  query = $.extend {}, @props.cards.query, query
162
184
  $.param(query)
163
185
 
186
+ onClickMenuItem: (params)->
187
+ ()=> window.location.hash = '#/?' + @queryParam(params)
188
+
164
189
  render: ->
165
- <div onClick={@onClick} onTouchStart={@onTouchStart} onTouchEnd={@onTouchEnd} style={overflow:'hidden'}>
190
+ clearInterval @interval if @interval
191
+ if @props.cards.query.auto != 'off'
192
+ bpm = null
193
+ switch @props.cards.query.auto
194
+ when 'fast' then bpm = 90
195
+ when 'normal' then bpm = 60
196
+ when 'slow' then bpm = 30
197
+ console.log 'bpm!!!!!!!!!!!!!!!!!!!!!!!!!!', bpm
198
+ @interval = setInterval @onClickNext, 1000 * 60 / bpm
199
+ <div onTouchStart={@onTouchStart} onTouchMove={@onTouchMove} onTouchEnd={@onTouchEnd} style={overflow:'hidden',width:'100%',height:'100%'}>
166
200
  <div style={position:'absolute',bottom:0,width:'100%',padding:'47px 0px 0px 0px'} onMouseOver={@onMouseOverTools} onMouseLeave={@onMouseLeaveTools}>
167
201
  <span className={classnames("pull-right":true, 'carte-hidden': !@state.showTools)}>
168
202
  <ButtonGroup>
169
203
  <DropdownButton bsSize='large' bsStyle='default' title={'Auto: ' + @props.cards.query.auto} dropup pullRight className={classnames('open': @state.menuOpen)}>
170
- <MenuItem href={'#/?' + @queryParam(auto: "off")} eventKey='1'>off</MenuItem>
171
- <MenuItem href={'#/?' + @queryParam(auto: "fast")} eventKey='2'>fast</MenuItem>
172
- <MenuItem href={'#/?' + @queryParam(auto: "normal")} eventKey='3'>normal</MenuItem>
173
- <MenuItem href={'#/?' + @queryParam(auto: "slow")} eventKey='4'>slow</MenuItem>
204
+ <MenuItem href={"#/?" + @queryParam(auto: "off")} eventKey='1'>off</MenuItem>
205
+ <MenuItem href={"#/?" + @queryParam(auto: "fast")} eventKey='2'>fast</MenuItem>
206
+ <MenuItem href={"#/?" + @queryParam(auto: "normal")} eventKey='3'>normal</MenuItem>
207
+ <MenuItem href={"#/?" + @queryParam(auto: "slow")} eventKey='4'>slow</MenuItem>
174
208
  </DropdownButton>
175
209
  <DropdownButton bsSize='large' bsStyle='default' title={'Hide: ' + @props.cards.query.hide} dropup pullRight className={classnames('open': @state.menuOpen)}>
176
- <MenuItem href={'#/?' + @queryParam(hide: "none")} eventKey='1'>none</MenuItem>
177
- <MenuItem href={'#/?' + @queryParam(hide: "title")} eventKey='2'>title</MenuItem>
178
- <MenuItem href={'#/?' + @queryParam(hide: "content")} eventKey='3'>content</MenuItem>
210
+ <MenuItem href={"#/?" + @queryParam(hide: "none")} eventKey='1'>none</MenuItem>
211
+ <MenuItem href={"#/?" + @queryParam(hide: "title")} eventKey='2'>title</MenuItem>
212
+ <MenuItem href={"#/?" + @queryParam(hide: "content")} eventKey='3'>content</MenuItem>
179
213
  </DropdownButton>
180
214
  <Button bsSize='large' href={@closeLink()}><strong>&times;</strong></Button>
181
215
  </ButtonGroup>
data/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "carte-client",
3
3
  "description": "something like dictionary, wiki, or information card",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "main": "lib/carte.coffee",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carte-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - tily
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-16 00:00:00.000000000 Z
11
+ date: 2015-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler