# HG changeset patch # User Tomas Zeman # Date 1513090962 -3600 # Node ID d2a0dfbb7dae4a58e610e13fa6ec2c513c052a0b # Parent 32b2c532065761c1e73d5c0b850678b087f6b6e1 Moved files into appropriate packages, fixed type annotations of public members diff -r 32b2c5320657 -r d2a0dfbb7dae js/src/main/scala/Nvd3Chart.scala --- a/js/src/main/scala/Nvd3Chart.scala Mon Nov 27 18:05:35 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,163 +0,0 @@ -/* - * Copyright 2015 Tomas Zeman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.tz.nvd3 - -import scala.scalajs.js -import scala.scalajs.js.annotation.{JSExport, JSExportAll} -import scala.scalajs.js.Dynamic.{global => g} -import scala.scalajs.js.JSConverters._ - -private[nvd3] abstract class Constructable[C <: Constructable[C]]( - b: Map[String, Any] -, cf: Map[String, Any] => C) { - protected def v[T](n: Symbol, v: T): C = cf(b + (n.name -> v)) - def toJs = b.toJSDictionary -} - -class Axis(b: Map[String, Any]) - extends Constructable[Axis](b, m => new Axis(m)) { - def axisLabel(l: String) = v('axisLabel, l) - def showMaxMin(b: Boolean) = v('showMaxMin, b) - def staggerLabels(b: Boolean) = v('staggerLabels, b) - def labelDistance(d: Int) = v('axisLabelDistance, d) - def tickFormat(f: js.Function1[Double, js.Any]) = v('tickFormat, f) - def rotateLabels(deg: Int) = v('rotateLabels, deg) -} - -class Margin(b: Map[String, Any]) - extends Constructable[Margin](b, m => new Margin(m)) { - def top(i: Int) = v('top, i) - def bottom(i: Int) = v('bottom, i) - def left(i: Int) = v('left, i) - def right(i: Int) = v('right, i) -} - -class Legend(b: Map[String, Any]) - extends Constructable[Legend](b, m => new Legend(m)) { - def margin(m: Margin) = v('margin, m) -} - -class Chart(b: Map[String, Any]) - extends Constructable[Chart](b, m => new Chart(m)) { - - def transitionDuration(ms: Int) = v('transitionDuration, ms) - def height(h: Int) = v('height, h) - def width(w: Int) = v('width, w) - def x[R](f: js.Function1[js.Dynamic, R]) = v('x, f) - def y[R](f: js.Function1[js.Dynamic, R]) = v('y, f) - def average(f: js.Function1[js.Dynamic, Any]) = v('average, f) - def forceY(min: Double, max: Double) = v('forceY, js.Array(min, max)) - def color(colors: js.Array[String]) = v('color, colors) - def color(colors: js.Any) = v('color, colors) - def useInteractiveGuideline(b: Boolean) = v('useInteractiveGuideline, b) - def clipVoronoi(b: Boolean) = v('clipVoronoi, b) - def useVoronoi(b: Boolean) = v('useVoronoi, b) - def xAxis(a: Axis) = v('xAxis, a.toJs) - def yAxis(a: Axis) = v('yAxis, a.toJs) - def margin(m: Margin) = v('margin, m.toJs) - def reduceXTicks(b: Boolean) = v('reduceXTicks, b) - def showValues(b: Boolean) = v('showValues, b) - def showControls(b: Boolean) = v('showControls, b) - def showLabels(b: Boolean) = v('showLabels, b) - def showLegend(b: Boolean) = v('showLegend, b) - def staggerLabels(b: Boolean) = v('staggerLabels, b) - def valueFormat[F, T](f: js.Function1[F, T]) = v('valueFormat, f) - def donut(b: Boolean) = v('donut, b) - def legend(l: Legend) = v('legend, l) - def labelThreshold(t: Double) = v('labelThreshold, t) - def clipEdge(b: Boolean) = v('clipEdge, b) - def noData(s: String) = v('noData, s) -} - -object Chart { - private def as(t: Symbol) = new Chart(Map("type" -> t.name)) - - def lineChart = as('lineChart) - def bulletChart = as('bulletChart) - def cumulativeLineChart = as('cumulativeLineChart) - def discreteBarChart = as('discreteBarChart) - def pieChart = as('pieChart) - def historicalBarChart = as('historicalBarChart) - def multiBarChart = as('multiBarChart) - def multiBarHorizontalChart = as('multiBarHorizontalChart) - def stackedAreaChart = as('stackedAreaChart) - - def axis(l: String) = new Axis(Map()) axisLabel l - def margin = new Margin(Map()) - def legend = new Legend(Map()) -} - -@JSExportAll -case class Options(var chart: js.Dictionary[Any]) - -class RadarChartConfig(b: Map[String, Any]) - extends Constructable[RadarChartConfig](b, m => new RadarChartConfig(m)) { - - def radius(r: Int) = v('radius, r) - def height(h: Int) = v('h, h) - def width(w: Int) = v('w, w) - def factor(f: Double) = v('factor, f) - def factorLegend(f: Double) = v('factorLegend, f) - def levels(l: Int) = v('levels, l) - def maxValue(m: Double) = v('maxValue, m) - def opacityArea(o: Double) = v('opacityArea, o) - def toRight(r: Int) = v('ToRight, r) - def translateX(t: Int) = v('TranslateX, t) - def translateY(t: Int) = v('TranslateY, t) - def extraWidthX(w: Int) = v('ExtraWidthX, w) - def extraWidthY(w: Int) = v('ExtraWidthY, w) - def color(c: js.Function1[Int, String]) = v('color, c) - def offset(d: Double) = v('offset, d) - def formatValue(f: js.Function1[Double, String]) = v('formatValue, f) - def formatAxis(f: js.Function1[Double, String]) = v('formatAxis, f) - def drawMaxLevel(b: Boolean) = v('drawMaxLevel, b) -} - -object RadarChartConfig { - def default = new RadarChartConfig(Map()) -} - -object RadarChart { - case class V(val n: String, val v: Double, val t: Option[() => String] = None) { - @JSExport - def axis = n - @JSExport - def value = v - @JSExport - def tooltip() = t.map(_()).getOrElse("") - } - - def apply(id: String, data: Seq[Seq[V]], cfg: RadarChartConfig) = - g.RadarChart.draw(id, data.map(_.toJSArray).toJSArray, cfg.toJs) -} - -object MultiBarChart { - case class V[X](_x: X, _y: Double) { - @JSExport - def x = _x - @JSExport - def y = _y - } - - case class Series[X](_key: String, _values: Seq[V[X]]) { - @JSExport - def key = _key - @JSExport - def values = _values.toJSArray - } -} - -// vim: set ts=2 sw=2 et: diff -r 32b2c5320657 -r d2a0dfbb7dae js/src/main/scala/net/tz/nvd3/Nvd3Chart.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/js/src/main/scala/net/tz/nvd3/Nvd3Chart.scala Tue Dec 12 16:02:42 2017 +0100 @@ -0,0 +1,163 @@ +/* + * Copyright 2015-2017 Tomas Zeman + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.tz.nvd3 + +import scala.scalajs.js +import scala.scalajs.js.Dynamic.{global => g} +import scala.scalajs.js.JSConverters._ +import scala.scalajs.js.annotation.{JSExport, JSExportAll} + +private[nvd3] abstract class Constructable[C <: Constructable[C]]( + b: Map[String, Any] +, cf: Map[String, Any] => C) { + protected def v[T](n: Symbol, v: T): C = cf(b + (n.name -> v)) + def toJs = b.toJSDictionary +} + +class Axis(b: Map[String, Any]) + extends Constructable[Axis](b, m => new Axis(m)) { + def axisLabel(l: String) = v('axisLabel, l) + def showMaxMin(b: Boolean) = v('showMaxMin, b) + def staggerLabels(b: Boolean) = v('staggerLabels, b) + def labelDistance(d: Int) = v('axisLabelDistance, d) + def tickFormat(f: js.Function1[Double, js.Any]) = v('tickFormat, f) + def rotateLabels(deg: Int) = v('rotateLabels, deg) +} + +class Margin(b: Map[String, Any]) + extends Constructable[Margin](b, m => new Margin(m)) { + def top(i: Int) = v('top, i) + def bottom(i: Int) = v('bottom, i) + def left(i: Int) = v('left, i) + def right(i: Int) = v('right, i) +} + +class Legend(b: Map[String, Any]) + extends Constructable[Legend](b, m => new Legend(m)) { + def margin(m: Margin) = v('margin, m) +} + +class Chart(b: Map[String, Any]) + extends Constructable[Chart](b, m => new Chart(m)) { + + def transitionDuration(ms: Int) = v('transitionDuration, ms) + def height(h: Int) = v('height, h) + def width(w: Int) = v('width, w) + def x[R](f: js.Function1[js.Dynamic, R]) = v('x, f) + def y[R](f: js.Function1[js.Dynamic, R]) = v('y, f) + def average(f: js.Function1[js.Dynamic, Any]) = v('average, f) + def forceY(min: Double, max: Double) = v('forceY, js.Array(min, max)) + def color(colors: js.Array[String]) = v('color, colors) + def color(colors: js.Any) = v('color, colors) + def useInteractiveGuideline(b: Boolean) = v('useInteractiveGuideline, b) + def clipVoronoi(b: Boolean) = v('clipVoronoi, b) + def useVoronoi(b: Boolean) = v('useVoronoi, b) + def xAxis(a: Axis) = v('xAxis, a.toJs) + def yAxis(a: Axis) = v('yAxis, a.toJs) + def margin(m: Margin) = v('margin, m.toJs) + def reduceXTicks(b: Boolean) = v('reduceXTicks, b) + def showValues(b: Boolean) = v('showValues, b) + def showControls(b: Boolean) = v('showControls, b) + def showLabels(b: Boolean) = v('showLabels, b) + def showLegend(b: Boolean) = v('showLegend, b) + def staggerLabels(b: Boolean) = v('staggerLabels, b) + def valueFormat[F, T](f: js.Function1[F, T]) = v('valueFormat, f) + def donut(b: Boolean) = v('donut, b) + def legend(l: Legend) = v('legend, l) + def labelThreshold(t: Double) = v('labelThreshold, t) + def clipEdge(b: Boolean) = v('clipEdge, b) + def noData(s: String) = v('noData, s) +} + +object Chart { + private def as(t: Symbol) = new Chart(Map("type" -> t.name)) + + def lineChart = as('lineChart) + def bulletChart = as('bulletChart) + def cumulativeLineChart = as('cumulativeLineChart) + def discreteBarChart = as('discreteBarChart) + def pieChart = as('pieChart) + def historicalBarChart = as('historicalBarChart) + def multiBarChart = as('multiBarChart) + def multiBarHorizontalChart = as('multiBarHorizontalChart) + def stackedAreaChart = as('stackedAreaChart) + + def axis(l: String) = new Axis(Map()) axisLabel l + def margin = new Margin(Map()) + def legend = new Legend(Map()) +} + +@JSExportAll +case class Options(var chart: js.Dictionary[Any]) + +class RadarChartConfig(b: Map[String, Any]) + extends Constructable[RadarChartConfig](b, m => new RadarChartConfig(m)) { + + def radius(r: Int) = v('radius, r) + def height(h: Int) = v('h, h) + def width(w: Int) = v('w, w) + def factor(f: Double) = v('factor, f) + def factorLegend(f: Double) = v('factorLegend, f) + def levels(l: Int) = v('levels, l) + def maxValue(m: Double) = v('maxValue, m) + def opacityArea(o: Double) = v('opacityArea, o) + def toRight(r: Int) = v('ToRight, r) + def translateX(t: Int) = v('TranslateX, t) + def translateY(t: Int) = v('TranslateY, t) + def extraWidthX(w: Int) = v('ExtraWidthX, w) + def extraWidthY(w: Int) = v('ExtraWidthY, w) + def color(c: js.Function1[Int, String]) = v('color, c) + def offset(d: Double) = v('offset, d) + def formatValue(f: js.Function1[Double, String]) = v('formatValue, f) + def formatAxis(f: js.Function1[Double, String]) = v('formatAxis, f) + def drawMaxLevel(b: Boolean) = v('drawMaxLevel, b) +} + +object RadarChartConfig { + def default = new RadarChartConfig(Map()) +} + +object RadarChart { + case class V(val n: String, val v: Double, val t: Option[() => String] = None) { + @JSExport + def axis = n + @JSExport + def value = v + @JSExport + def tooltip() = t.map(_()).getOrElse("") + } + + def apply(id: String, data: Seq[Seq[V]], cfg: RadarChartConfig) = + g.RadarChart.draw(id, data.map(_.toJSArray).toJSArray, cfg.toJs) +} + +object MultiBarChart { + case class V[X](_x: X, _y: Double) { + @JSExport + def x = _x + @JSExport + def y = _y + } + + case class Series[X](_key: String, _values: Seq[V[X]]) { + @JSExport + def key = _key + @JSExport + def values = _values.toJSArray + } +} + +// vim: set ts=2 sw=2 et: diff -r 32b2c5320657 -r d2a0dfbb7dae shared/src/main/scala/Nvd3.scala --- a/shared/src/main/scala/Nvd3.scala Mon Nov 27 18:05:35 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -/* - * Copyright 2015-2016 Tomas Zeman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.tz.nvd3 - -import scalatags.Text.all._ - -object Nvd3 { - val nvd3 = tag("nvd3") - def nvd3options(varName: String) = attr("options"):=varName - def nvd3data(varName: String) = attr("data"):=varName -} - -// vim: set ts=2 sw=2 et: diff -r 32b2c5320657 -r d2a0dfbb7dae shared/src/main/scala/Tags.scala --- a/shared/src/main/scala/Tags.scala Mon Nov 27 18:05:35 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright 2015-2016 Tomas Zeman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.tz.ngtags - -import scalatags.Text.all._ - -object Tags { - val closeAttr = attr("close") - val dataFramework: Attr = attr("data-framework") - val dataToggle: Attr = attr("data-toggle") - val dataTarget: Attr = attr("data-target") - - val html5 = "" - val nbsp = raw(" ") - val scope = attr("scope") - - val typeAttr = attr("type") -} - -// vim: set ts=2 sw=2 et: diff -r 32b2c5320657 -r d2a0dfbb7dae shared/src/main/scala/net/tz/ngtags/Tags.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shared/src/main/scala/net/tz/ngtags/Tags.scala Tue Dec 12 16:02:42 2017 +0100 @@ -0,0 +1,34 @@ +/* + * Copyright 2015-2017 Tomas Zeman + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.tz.ngtags + +import scalatags.Text +import scalatags.Text.all._ + +object Tags { + val closeAttr: Attr = attr("close") + val dataFramework: Attr = attr("data-framework") + val dataToggle: Attr = attr("data-toggle") + val dataTarget: Attr = attr("data-target") + + val html5 = "" + val nbsp: Text.RawFrag = raw(" ") + val scope: Attr = attr("scope") + + val typeAttr: Attr = attr("type") +} + +// vim: set ts=2 sw=2 et: diff -r 32b2c5320657 -r d2a0dfbb7dae shared/src/main/scala/net/tz/ngtags/ngTags.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shared/src/main/scala/net/tz/ngtags/ngTags.scala Tue Dec 12 16:02:42 2017 +0100 @@ -0,0 +1,83 @@ +/* + * Copyright 2015-2017 Tomas Zeman + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.tz.ngtags + +import scalatags.Text.TypedTag +import scalatags.Text.all._ + +object ngTags { + def i18n(s: String): String = s"{{'$s' | translate}}" + def interpolate(s: String) = s"{{$s}}" + def isOpen(expr: String): Modifier = attr("is-open"):=expr + + val ngAlert: TypedTag[String] = tag("alert") + val ngApp: Attr = attr("ng-app") + def ngBindHtml(safe: String): Modifier = attr("ng-bind-html"):=safe + def ngChange(expr: String): Modifier = attr("ng-change"):=expr + def ngClick(expr: String): Modifier = attr("ng-click"):=expr + val ngCloak: TypedTag[String] = tag("ng-cloak") + def ngCls(expr: String): Modifier = attr("ng-class"):=expr + def ngCtrl(c: String): Modifier = attr("ng-controller"):=c + def ngDisabled(expr: String): Modifier = attr("ng-disabled"):=expr + def ngHide(expr: String): Modifier = attr("ng-hide"):=expr + def ngHref(expr: String): Modifier = attr("ng-href"):=interpolate(expr) + def ngIf(expr: String): Modifier = attr("ng-if"):=expr + val ngInclude: Attr = attr("ng-include") + def ngInit(expr: String): Modifier = attr("ng-init"):=expr + + def ngKeyDown(expr: String): Modifier = attr("ng-keydown"):=expr + def ngKeyPress(expr: String): Modifier = attr("ng-keypress"):=expr + def ngKeyUp(expr: String): Modifier = attr("ng-keyup"):=expr + + def ngMessage(strVal: String): Modifier = attr("ng-message"):=strVal + def ngMessageExp(expr: String): Modifier = attr("ng-message-exp"):=expr + def ngMessages(expr: String): Modifier = attr("ng-messages"):=expr + + def ngModel(expr: String): Modifier = attr("ng-model"):=expr + def ngModelOptions(expr: String): Modifier = attr("ng-model-options"):=expr + + def ngOptions(expr: String): Modifier = attr("ng-options"):=expr + + def ngReadonly(expr: String): Modifier = attr("ng-readonly"):=expr + + def ngRepeat(name: String, list: String): Modifier = + attr("ng-repeat"):=s"$name in $list" + def ngRepeatStart(n: String, l: String): Modifier = + attr("ng-repeat-start"):=s"$n in $l" + val ngRepeatEnd: Modifier = attr("ng-repeat-end").empty + + def ngSrc(expr: String): Modifier = attr("ng-src"):=expr + def ngShow(expr: String): Modifier = attr("ng-show"):=expr + def ngStyle(s: String): Modifier = attr("ng-style"):=s + def ngValue(expr: String): Modifier = attr("ng-value"):=expr + val ngView: TypedTag[String] = tag("ng-view") + + val translateAttr: Attr = attr("translate") +} + +object uiSelect { + val uiSelect: TypedTag[String] = tag("ui-select") + val uiSelectMatch: TypedTag[String] = tag("ui-select-match") + val uiSelectChoices: TypedTag[String] = tag("ui-select-choices") + def theme(t: String): Modifier = attr("theme"):=t + def repeat(n: String, col: String): Modifier = attr("repeat"):=s"$n in $col" + def onSelect(fun: String): Modifier = attr("on-select"):=fun + def onRemove(fun: String): Modifier = attr("on-remove"):=fun + def allowClear(b: Boolean): Modifier = attr("allow-clear"):=b + def groupBy(groupFn: String): Modifier = attr("group-by"):=groupFn +} + +// vim: set ts=2 sw=2 et: diff -r 32b2c5320657 -r d2a0dfbb7dae shared/src/main/scala/net/tz/ngtags/twbsTags.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shared/src/main/scala/net/tz/ngtags/twbsTags.scala Tue Dec 12 16:02:42 2017 +0100 @@ -0,0 +1,73 @@ +/* + * Copyright 2015-2017 Tomas Zeman + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.tz.ngtags + +import scala.language.implicitConversions +import scalatags.Text.TypedTag +import scalatags.Text.all._ + +object uibAccordion { + val acMain: TypedTag[String] = tag("uib-accordion") + val acGroup: Modifier = attr("uib-accordion-group").empty + val acHeading: TypedTag[String] = tag("uib-accordion-heading") + val closeOthers: Attr = attr("close-others") +} + +object uibTags { + val dropdown: Attr = attr("uib-dropdown") + val dropdownToggle: Attr = attr("uib-dropdown-toggle") + val nav: TypedTag[String] = tag("nav") + val alert: Modifier = attr("uib-alert"):="" + def tooltip(content: String): Modifier = attr("uib-tooltip"):=content + def tooltipHtml(content: String): Modifier = attr("uib-tooltip-html"):=content + def tooltipAppendToBody(b: Boolean): Modifier = + attr("tooltip-append-to-body"):=b + def tooltipPlacement(where: String): Modifier = + attr("tooltip-placement"):=where + def tooltipTrigger(events: String): Modifier = attr("tooltip-trigger"):=events +} + +object uibTabs { + + implicit def ts2tag(x: Tabset): ConcreteHtmlTag[String] = x() + + case class Tab(heading: Seq[Modifier], content: Seq[Modifier]) + + case class Tabset(activeE: String, _tabs: Seq[Tab] = Nil, + _justified: Option[Boolean] = None) { + def justified(b: Boolean): Tabset = copy(_justified = Some(b)) + def justified: Tabset = justified(true) + def tab(heading: Modifier*) = new { + def content(xs: Modifier*): Tabset = + copy(_tabs = _tabs :+ Tab(heading, xs)) + } + def emptyTab(heading: Modifier*): Tabset = tab(heading).content() + + def apply(xs: Modifier*): TypedTag[String] = + tag("uib-tabset")(attr("active"):=activeE, + _justified.map(attr("justified"):=_), xs, + _tabs.map { t => + tag("uib-tab")(tag("uib-tab-heading")(t.heading), t.content) + }) + } + + def tabset(activeExpr: String) = Tabset(activeExpr) + val tab: TypedTag[String] = tag("uib-tab") + val tabHeading: TypedTag[String] = tag("uib-tab-heading") + val heading: Attr = attr("heading") +} + +// vim: set ts=2 sw=2 et: diff -r 32b2c5320657 -r d2a0dfbb7dae shared/src/main/scala/net/tz/nvd3/Nvd3.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shared/src/main/scala/net/tz/nvd3/Nvd3.scala Tue Dec 12 16:02:42 2017 +0100 @@ -0,0 +1,27 @@ +/* + * Copyright 2015-2017 Tomas Zeman + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.tz.nvd3 + +import scalatags.Text.TypedTag +import scalatags.Text.all._ + +object Nvd3 { + val nvd3: TypedTag[String] = tag("nvd3") + def nvd3options(varName: String): Modifier = attr("options"):=varName + def nvd3data(varName: String): Modifier = attr("data"):=varName +} + +// vim: set ts=2 sw=2 et: diff -r 32b2c5320657 -r d2a0dfbb7dae shared/src/main/scala/ngTags.scala --- a/shared/src/main/scala/ngTags.scala Mon Nov 27 18:05:35 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * Copyright 2015-2017 Tomas Zeman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.tz.ngtags - -import scalatags.Text.TypedTag -import scalatags.Text.all._ - -object ngTags { - def i18n(s: String): String = s"{{'$s' | translate}}" - def interpolate(s: String) = s"{{$s}}" - def isOpen(expr: String): Modifier = attr("is-open"):=expr - - val ngAlert: TypedTag[String] = tag("alert") - val ngApp: Attr = attr("ng-app") - def ngBindHtml(safe: String): Modifier = attr("ng-bind-html"):=safe - def ngChange(expr: String): Modifier = attr("ng-change"):=expr - def ngClick(expr: String): Modifier = attr("ng-click"):=expr - val ngCloak: TypedTag[String] = tag("ng-cloak") - def ngCls(expr: String): Modifier = attr("ng-class"):=expr - def ngCtrl(c: String): Modifier = attr("ng-controller"):=c - def ngDisabled(expr: String): Modifier = attr("ng-disabled"):=expr - def ngHide(expr: String): Modifier = attr("ng-hide"):=expr - def ngHref(expr: String): Modifier = attr("ng-href"):=interpolate(expr) - def ngIf(expr: String): Modifier = attr("ng-if"):=expr - val ngInclude: Attr = attr("ng-include") - def ngInit(expr: String): Modifier = attr("ng-init"):=expr - - def ngKeyDown(expr: String): Modifier = attr("ng-keydown"):=expr - def ngKeyPress(expr: String): Modifier = attr("ng-keypress"):=expr - def ngKeyUp(expr: String): Modifier = attr("ng-keyup"):=expr - - def ngMessage(strVal: String): Modifier = attr("ng-message"):=strVal - def ngMessageExp(expr: String): Modifier = attr("ng-message-exp"):=expr - def ngMessages(expr: String): Modifier = attr("ng-messages"):=expr - - def ngModel(expr: String): Modifier = attr("ng-model"):=expr - def ngModelOptions(expr: String): Modifier = attr("ng-model-options"):=expr - - def ngOptions(expr: String): Modifier = attr("ng-options"):=expr - - def ngReadonly(expr: String): Modifier = attr("ng-readonly"):=expr - - def ngRepeat(name: String, list: String): Modifier = - attr("ng-repeat"):=s"$name in $list" - def ngRepeatStart(n: String, l: String): Modifier = - attr("ng-repeat-start"):=s"$n in $l" - val ngRepeatEnd: Modifier = attr("ng-repeat-end").empty - - def ngSrc(expr: String): Modifier = attr("ng-src"):=expr - def ngShow(expr: String): Modifier = attr("ng-show"):=expr - def ngStyle(s: String): Modifier = attr("ng-style"):=s - def ngValue(expr: String): Modifier = attr("ng-value"):=expr - val ngView: TypedTag[String] = tag("ng-view") - - val translateAttr: Attr = attr("translate") -} - -object uiSelect { - val uiSelect: TypedTag[String] = tag("ui-select") - val uiSelectMatch: TypedTag[String] = tag("ui-select-match") - val uiSelectChoices: TypedTag[String] = tag("ui-select-choices") - def theme(t: String): Modifier = attr("theme"):=t - def repeat(n: String, col: String): Modifier = attr("repeat"):=s"$n in $col" - def onSelect(fun: String): Modifier = attr("on-select"):=fun - def onRemove(fun: String): Modifier = attr("on-remove"):=fun - def allowClear(b: Boolean): Modifier = attr("allow-clear"):=b - def groupBy(groupFn: String): Modifier = attr("group-by"):=groupFn -} - -// vim: set ts=2 sw=2 et: diff -r 32b2c5320657 -r d2a0dfbb7dae shared/src/main/scala/twbsTags.scala --- a/shared/src/main/scala/twbsTags.scala Mon Nov 27 18:05:35 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright 2015-2017 Tomas Zeman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.tz.ngtags - -import scala.language.implicitConversions -import scalatags.Text.all._ - -@deprecated("Use uibAccordion", "0.5") -object Accordion { - val acMain = tag("accordion") - val acGroup = tag("accordion-group") - val acHeading = tag("accordion-heading") - val closeOthers = attr("close-others") -} - -object uibAccordion { - val acMain = tag("uib-accordion") - val acGroup = attr("uib-accordion-group").empty - val acHeading = tag("uib-accordion-heading") - val closeOthers = attr("close-others") -} - -@deprecated("Use uibTags", "0.5") -object twbsTags { - val dropdown = attr("dropdown") - val dropdownToggle = attr("dropdown-toggle") - val nav = tag("nav") - def tooltip(content: String) = attr("tooltip"):=content - def tooltipAppendToBody(b: Boolean) = attr("tooltip-append-to-body"):=b - def tooltipPlacement(where: String) = attr("tooltip-placement"):=where - def tooltipTrigger(events: String) = attr("tooltip-trigger"):=events -} - -object uibTags { - val dropdown = attr("uib-dropdown") - val dropdownToggle = attr("uib-dropdown-toggle") - val nav = tag("nav") - val alert = attr("uib-alert"):="" - def tooltip(content: String) = attr("uib-tooltip"):=content - def tooltipHtml(content: String) = attr("uib-tooltip-html"):=content - def tooltipAppendToBody(b: Boolean) = attr("tooltip-append-to-body"):=b - def tooltipPlacement(where: String) = attr("tooltip-placement"):=where - def tooltipTrigger(events: String) = attr("tooltip-trigger"):=events -} - -@deprecated("Use uibTabs", "0.5") -object Tabs { - val tabset = tag("tabset") - val tab = tag("tab") - val tabHeading = tag("tab-heading") - val heading = attr("heading") -} - -object uibTabs { - - implicit def ts2tag(x: Tabset): ConcreteHtmlTag[String] = x() - - case class Tab(heading: Seq[Modifier], content: Seq[Modifier]) - - case class Tabset(activeE: String, _tabs: Seq[Tab] = Nil, _justified: Option[Boolean] = None) { - def justified(b: Boolean): Tabset = copy(_justified = Some(b)) - def justified: Tabset = justified(true) - def tab(heading: Modifier*) = new { - def content(xs: Modifier*): Tabset = copy(_tabs = _tabs :+ Tab(heading, xs)) - } - def emptyTab(heading: Modifier*): Tabset = tab(heading).content() - - def apply(xs: Modifier*) = - tag("uib-tabset")(attr("active"):=activeE, _justified.map(attr("justified"):=_), xs, - _tabs.map {t => tag("uib-tab")(tag("uib-tab-heading")(t.heading), t.content)}) - } - - def tabset(activeExpr: String) = Tabset(activeExpr) - val tab = tag("uib-tab") - val tabHeading = tag("uib-tab-heading") - val heading = attr("heading") -} - -// vim: set ts=2 sw=2 et: