Skip to content

Commit 015fae9

Browse files
committed
Remove stuff from ext.* that do not make sense anymore.
1 parent 94deb22 commit 015fae9

File tree

2 files changed

+1
-197
lines changed

2 files changed

+1
-197
lines changed

src/main/scala/org/scalajs/dom/ext/Extensions.scala

Lines changed: 1 addition & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import scala.scalajs.js.typedarray._
1010
import scala.scalajs.js.typedarray.TypedArrayBufferOps._
1111

1212
import org.scalajs.dom
13-
import org.scalajs.dom.{Blob, FormData, KeyboardEvent, html}
13+
import org.scalajs.dom.{Blob, FormData, KeyboardEvent}
1414

1515
/**
1616
* Used to extend out javascript *Collections to make them usable as normal
@@ -36,66 +36,6 @@ class EasySeq[T](jsLength: Int, jsApply: Int => T)
3636
}
3737
}
3838

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-
9939
/**
10040
* A list of the codes returned by KeyEvents.
10141
*/
@@ -280,81 +220,3 @@ object Ajax {
280220
promise.future
281221
}
282222
}
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-
}

src/main/scala/org/scalajs/dom/ext/package.scala

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,64 +18,6 @@ package object ext {
1818
implicit class PimpedSVGTransformList(coll: svg.TransformList)
1919
extends EasySeq[svg.Transform](coll.numberOfItems, coll.getItem)
2020

21-
implicit class Castable(x: Any) {
22-
def cast[T] = x.asInstanceOf[T]
23-
}
24-
25-
implicit def pimpAnimatedNumber(x: svg.AnimatedNumber): Double = x.baseVal
26-
27-
implicit def pimpRichAnimatedNumber(
28-
x: svg.AnimatedNumber): runtime.RichDouble =
29-
x.baseVal: runtime.RichDouble
30-
31-
implicit def pimpAnimatedLength(x: svg.AnimatedLength): Double =
32-
x.baseVal.value
33-
34-
implicit def pimpRichAnimatedLength(
35-
x: svg.AnimatedLength): runtime.RichDouble =
36-
x.baseVal.value: runtime.RichDouble
37-
38-
implicit def color2String(c: Color): String = c.toString
39-
implicit class pimpedContext(val ctx: CanvasRenderingContext2D) {
40-
def prepCircle(x: Double, y: Double, r: Double) = {
41-
ctx.beginPath()
42-
ctx.arc(x, y, r, 0, math.Pi * 2)
43-
}
44-
45-
def fillCircle(x: Double, y: Double, r: Double) = {
46-
prepCircle(x, y, r)
47-
ctx.fill()
48-
}
49-
50-
def strokeCircle(x: Double, y: Double, r: Double) = {
51-
prepCircle(x, y, r)
52-
ctx.stroke()
53-
}
54-
55-
def prepPath(points: Seq[(Double, Double)], closed: Boolean = true) = {
56-
ctx.beginPath()
57-
if (closed) ctx.moveTo(points.last._1, points.last._2)
58-
for (p <- points) {
59-
ctx.lineTo(p._1, p._2)
60-
}
61-
}
62-
63-
def fillPath(points: (Double, Double)*) = {
64-
prepPath(points)
65-
ctx.fill()
66-
}
67-
68-
def strokePath(points: (Double, Double)*) = {
69-
prepPath(points)
70-
ctx.stroke()
71-
}
72-
73-
def strokePathOpen(points: (Double, Double)*) = {
74-
prepPath(points, closed = false)
75-
ctx.stroke()
76-
}
77-
}
78-
7921
implicit def pimpNamedNodeMap(namedNodeMap: NamedNodeMap): NamedNodeMapMap =
8022
new NamedNodeMapMap(namedNodeMap)
8123
}

0 commit comments

Comments
 (0)