@@ -10,7 +10,7 @@ import scala.scalajs.js.typedarray._
10
10
import scala .scalajs .js .typedarray .TypedArrayBufferOps ._
11
11
12
12
import org .scalajs .dom
13
- import org .scalajs .dom .{Blob , FormData , KeyboardEvent , html }
13
+ import org .scalajs .dom .{Blob , FormData , KeyboardEvent }
14
14
15
15
/**
16
16
* Used to extend out javascript *Collections to make them usable as normal
@@ -36,66 +36,6 @@ class EasySeq[T](jsLength: Int, jsApply: Int => T)
36
36
}
37
37
}
38
38
39
- /**
40
- * Encapsulates a Color, allowing you to do useful work with it
41
- * before serializing it to a String
42
- */
43
- case class Color (r : Int , g : Int , b : Int ) {
44
- override def toString () = s " rgb( $r, $g, $b) "
45
-
46
- def toHex : String = f " # $r%02x $g%02x $b%02x "
47
-
48
- def * (c : Color ) = Color (r * c.r, g * c.g, b * c.b)
49
-
50
- def + (c : Color ) = Color (r + c.r, g + c.g, b + c.b)
51
- }
52
-
53
- object Color {
54
-
55
- val d = " [0-9a-zA-Z]"
56
- val RGB = " rgb\\ ((\\ d+), (\\ d+), (\\ d+)\\ )" .r
57
- val ShortHex = s " #( $d)( $d)( $d) " .r
58
- val LongHex = s " #( $d$d)( $d$d)( $d$d) " .r
59
-
60
- def hex (x : String ) = Integer .parseInt(x, 16 )
61
-
62
- def apply (s : String ): Color = {
63
- s match {
64
- case RGB (r, g, b) => Color (r.toInt, g.toInt, b.toInt)
65
- case ShortHex (r, g, b) => Color (hex(r) * 16 , hex(g) * 16 , hex(b) * 16 )
66
- case LongHex (r, g, b) => Color (hex(r), hex(g), hex(b))
67
- }
68
- }
69
-
70
- val White = Color (255 , 255 , 255 )
71
- val Red = Color (255 , 0 , 0 )
72
- val Green = Color (0 , 255 , 0 )
73
- val Blue = Color (0 , 0 , 255 )
74
- val Cyan = Color (0 , 255 , 255 )
75
- val Magenta = Color (255 , 0 , 255 )
76
- val Yellow = Color (255 , 255 , 0 )
77
- val Black = Color (0 , 0 , 0 )
78
- val all = Seq (
79
- White ,
80
- Red ,
81
- Green ,
82
- Blue ,
83
- Cyan ,
84
- Magenta ,
85
- Yellow ,
86
- Black
87
- )
88
- }
89
-
90
- object Image {
91
- def createBase64Svg (s : String ) = {
92
- val img = dom.document.createElement(" img" ).asInstanceOf [html.Image ]
93
-
94
- img.src = " data:image/svg+xml;base64," + s
95
- img
96
- }
97
- }
98
-
99
39
/**
100
40
* A list of the codes returned by KeyEvents.
101
41
*/
@@ -280,81 +220,3 @@ object Ajax {
280
220
promise.future
281
221
}
282
222
}
283
-
284
- /**
285
- * Wraps [[dom.Storage ]] replacing null-returning methods with option-returning ones
286
- */
287
- sealed class Storage (domStorage : dom.Storage ) {
288
- def length : Int = domStorage.length
289
-
290
- def apply (key : String ): Option [String ] = Option (domStorage.getItem(key))
291
-
292
- def update (key : String , data : String ): Unit = domStorage.setItem(key, data)
293
-
294
- def clear (): Unit = domStorage.clear()
295
-
296
- def remove (key : String ): Unit = domStorage.removeItem(key)
297
-
298
- def key (index : Int ): Option [String ] = Option (domStorage.key(index))
299
- }
300
-
301
- object SessionStorage extends Storage (dom.window.sessionStorage)
302
-
303
- object LocalStorage extends Storage (dom.window.localStorage)
304
-
305
- /**
306
- * W3C recommendation for touch events
307
- *
308
- * @see http://www.w3.org/TR/touch-events/
309
- */
310
- @ js.native
311
- trait TouchEvents extends js.Object {
312
-
313
- /**
314
- * The touchstart event is fired when a touch point is placed on the touch
315
- * surface.
316
- *
317
- * MDN
318
- */
319
- var ontouchstart : js.Function1 [dom.TouchEvent , _] = js.native
320
-
321
- /**
322
- * The touchmove event is fired when a touch point is moved along the touch
323
- * surface.
324
- *
325
- * MDN
326
- */
327
- var ontouchmove : js.Function1 [dom.TouchEvent , _] = js.native
328
-
329
- /**
330
- * The touchend event is fired when a touch point is removed from the touch
331
- * surface.
332
- *
333
- * MDN
334
- */
335
- var ontouchend : js.Function1 [dom.TouchEvent , _] = js.native
336
-
337
- /**
338
- * The touchcancel event is fired when a touch point has been disrupted in an
339
- * implementation-specific manner (too many touch points for example).
340
- *
341
- * MDN
342
- */
343
- var ontouchcancel : js.Function1 [dom.TouchEvent , _] = js.native
344
- }
345
-
346
- /**
347
- * Implicits to add touch event handlers to [[dom.HTMLDocument ]] and
348
- * [[dom.Window ]].
349
- *
350
- * @note Touch events may not be available on all modern browsers. See
351
- * http://www.quirksmode.org/mobile/tableTouch.html#t00 for a compatibility
352
- * table.
353
- */
354
- object TouchEvents {
355
- implicit def HTMLDocumentToTouchEvents (html : dom.HTMLDocument ): TouchEvents =
356
- html.asInstanceOf [TouchEvents ]
357
-
358
- implicit def WindowToTouchEvents (window : dom.Window ): TouchEvents =
359
- window.asInstanceOf [TouchEvents ]
360
- }
0 commit comments