• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala UndefOr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中scala.scalajs.js.UndefOr的典型用法代码示例。如果您正苦于以下问题:Scala UndefOr类的具体用法?Scala UndefOr怎么用?Scala UndefOr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UndefOr类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: identify

//设置package包名称以及导入依赖的类
package slate

import monix.eval.Task
import monix.execution.Cancelable
import slate.chrome._

import scala.scalajs.js
import scala.scalajs.js.UndefOr

object identify {

  def chromeCallbackToTask[T](callbackTaker: (T => Unit) => Unit): Task[T] = {
    Task.create[T] { (_, callback) =>
      callbackTaker { result =>
        ChromeRuntime.lastError.fold(callback.onSuccess(result)) { ex =>
          callback.onError(ChromeErrorException(ex.message))
        }
      }
      Cancelable.empty
    }
  }

  def getAuthToken(interactive: Boolean = false, accountInfo: UndefOr[String] = js.undefined, scopes: UndefOr[js.Array[String]] = js.undefined): Task[String] =
    chromeCallbackToTask(ChromeIdentity.fetchAuthToken(new GetAuthTokenOptions(interactive, accountInfo.map(new AccountInfo(_)), scopes), _))

  def launchWebAuthFlow(interactive: Boolean = false, url: String): Task[String] =
    chromeCallbackToTask(ChromeIdentity.launchWebAuthFlow(new LaunchWebAuthFlowOptions(url, interactive), _))

  def removeCachedAuthToken(token: String): Task[Unit] =
    chromeCallbackToTask(ChromeIdentity.removeCachedAuthToken(new RemoveCachedAuthTokenOptions(token), _))

  case class ChromeErrorException(message: UndefOr[String]) extends Exception(message.getOrElse("No error message"))

} 
开发者ID:edmundnoble,项目名称:slate,代码行数:35,代码来源:identify.scala


示例2: GetAuthTokenOptions

//设置package包名称以及导入依赖的类
package slate
package chrome

import scala.scalajs.js
import scala.scalajs.js.annotation.{JSName, ScalaJSDefined}
import scala.scalajs.js.{UndefOr, native, undefined}

@ScalaJSDefined
class GetAuthTokenOptions(val interactive: UndefOr[Boolean] = undefined,
                          val account: UndefOr[AccountInfo] = undefined,
                          val scopes: UndefOr[js.Array[String]] = undefined) extends js.Object

@ScalaJSDefined
class LaunchWebAuthFlowOptions(val url: String,
                               val interactive: UndefOr[Boolean] = undefined) extends js.Object

@ScalaJSDefined
class RemoveCachedAuthTokenOptions(val token: String) extends js.Object

@ScalaJSDefined
class AccountInfo(val id: String) extends js.Object

@native
@JSName("chrome.identity")
object ChromeIdentity extends js.Object {
  @JSName("getAuthToken")
  @native
  def fetchAuthToken(details: UndefOr[GetAuthTokenOptions] = undefined,
                     callback: js.Function1[String, Unit]): Unit = native

  @native
  def launchWebAuthFlow(details: LaunchWebAuthFlowOptions,
                        callback: js.Function1[String, Unit]): Unit = native

  @native
  def removeCachedAuthToken(details: RemoveCachedAuthTokenOptions,
                            callback: js.Function1[Unit, Unit]): Unit = native
}

@ScalaJSDefined
class LastError(val message: UndefOr[String]) extends js.Object

@native
@JSName("chrome.runtime")
object ChromeRuntime extends js.Object {
  @native
  def lastError: UndefOr[LastError] = native
} 
开发者ID:edmundnoble,项目名称:slate,代码行数:49,代码来源:ChromeIdentity.scala


示例3: MarkedOptions

//设置package包名称以及导入依赖的类
package com.karasiq.markedjs

import scala.scalajs.js
import scala.scalajs.js.annotation.ScalaJSDefined
import scala.scalajs.js.{Any, UndefOr}

@ScalaJSDefined
class MarkedOptions extends js.Object {
  
  def apply(highlight: UndefOr[(String, UndefOr[String], js.Function) ? String] = js.undefined, renderer: MarkedRenderer = new MarkedRenderer(), gfm: Boolean = true, tables: Boolean = true, breaks: Boolean = false, pedantic: Boolean = false, sanitize: Boolean = false, smartLists: Boolean = true, smartypants: Boolean = false): MarkedOptions = {
    val _highlight = highlight
    val _renderer = renderer
    val _gfm = gfm
    val _tables = tables
    val _breaks = breaks
    val _pedantic = pedantic
    val _sanitize = sanitize
    val _smartLists = smartLists
    val _smartypants = smartypants
    new MarkedOptions {
      override val highlight: Any = _highlight
      override val renderer: MarkedRenderer = _renderer
      override val gfm: Boolean = _gfm
      override val tables: Boolean = _tables
      override val breaks: Boolean = _breaks
      override val pedantic: Boolean = _pedantic
      override val sanitize: Boolean = _sanitize
      override val smartLists: Boolean = _smartLists
      override val smartypants: Boolean = _smartypants
    }
  }
} 
开发者ID:Karasiq,项目名称:scalajs-marked,代码行数:33,代码来源:MarkedOptions.scala


示例4: MarkedRenderer

//设置package包名称以及导入依赖的类
package com.karasiq.markedjs

import scala.scalajs.js
import scala.scalajs.js.UndefOr
import scala.scalajs.js.annotation.JSName

//noinspection SpellCheckingInspection
@js.native
@JSName("marked.Renderer")
class MarkedRenderer extends js.Object {
  // Block level renderer methods
  def code(code: String, language: String): String = js.native
  def blockquote(quote: String): String = js.native
  def html(html: String): String = js.native
  def heading(text: String, level: Int): String = js.native
  def hr(): String = js.native
  def list(body: String, ordered: Boolean): String = js.native
  def listitem(text: String): String = js.native
  def paragraph(text: String): String = js.native
  def table(header: String, body: String): String = js.native
  def tablerow(content: String): String = js.native

  
  def tablecell(content: String, flags: js.Object): String = js.native

  // Inline level renderer methods
  def strong(text: String): String = js.native
  def em(text: String): String = js.native
  def codespan(code: String): String = js.native
  def br(): String = js.native
  def del(text: String): String = js.native
  def link(href: String, title: String, text: String): String = js.native
  def image(href: String, title: String, text: String): String = js.native
}

object MarkedRenderer {
  def apply(code: UndefOr[(String, String) ? String] = js.undefined, blockquote: UndefOr[String ? String] = js.undefined, html: UndefOr[String ? String] = js.undefined, heading: UndefOr[(String, Int) ? String] = js.undefined, hr: UndefOr[() ? String] = js.undefined, list: UndefOr[(String, Boolean) ? String] = js.undefined, listitem: UndefOr[String ? String] = js.undefined, paragraph: UndefOr[String ? String] = js.undefined, table: UndefOr[(String, String) ? String] = js.undefined, tablerow: UndefOr[String ? String] = js.undefined, tablecell: UndefOr[(String, js.Object) ? String] = js.undefined, strong: UndefOr[String ? String] = js.undefined, em: UndefOr[String ? String] = js.undefined, codespan: UndefOr[String ? String] = js.undefined, br: UndefOr[() ? String] = js.undefined, del: UndefOr[String ? String] = js.undefined, link: UndefOr[(String, String, String) ? String] = js.undefined, image: UndefOr[(String, String, String) ? String] = js.undefined): MarkedRenderer = {
    val renderer = new MarkedRenderer().asInstanceOf[js.Dynamic]
    code.foreach(renderer.code = _)
    blockquote.foreach(renderer.blockquote = _)
    html.foreach(renderer.html = _)
    heading.foreach(renderer.heading = _)
    hr.foreach(renderer.hr = _)
    list.foreach(renderer.list = _)
    listitem.foreach(renderer.listitem = _)
    paragraph.foreach(renderer.paragraph = _)
    table.foreach(renderer.table = _)
    tablerow.foreach(renderer.tablerow = _)
    tablecell.foreach(renderer.tablecell = _)
    strong.foreach(renderer.strong = _)
    em.foreach(renderer.em = _)
    codespan.foreach(renderer.codespan = _)
    br.foreach(renderer.br = _)
    del.foreach(renderer.del = _)
    link.foreach(renderer.link = _)
    image.foreach(renderer.image = _)
    renderer.asInstanceOf[MarkedRenderer]
  }
} 
开发者ID:Karasiq,项目名称:scalajs-marked,代码行数:60,代码来源:MarkedRenderer.scala


示例5: AceEditor

//设置package包名称以及导入依赖的类
package spatutorial.client.components

import japgolly.scalajs.react.{React, ReactComponentU_, ReactNode}
import macros.JSMacro

import scala.scalajs.js
import scala.scalajs.js.annotation.JSName
import scala.scalajs.js.{UndefOr, _}

@js.native
@JSName("ReactAce")
object AceEditor extends js.Object

case class AceEditorGenerated(mode : UndefOr[String] = undefined,
                              theme : UndefOr[String] = undefined,
                              name : UndefOr[String] = undefined,
                              height : UndefOr[String] = undefined,
                              fontSize: UndefOr[Int] = undefined,
                              value: UndefOr[String] = undefined
                             ) {
  def toJS = {
    val p = js.Dynamic.literal()
    mode.foreach(v => p.updateDynamic("mode")(v))
    theme.foreach(v => p.updateDynamic("theme")(v))
    name.foreach(v => p.updateDynamic("name")(v))
    height.foreach(v => p.updateDynamic("height")(v))
    fontSize.foreach(v => p.updateDynamic("fontSize")(v))
    value.foreach(v => p.updateDynamic("value")(v))
    p
  }

  def apply(children: js.UndefOr[ReactNode] = js.undefined) = {

    val props = JSMacro[AceEditorGenerated](this)
    val f = React.asInstanceOf[js.Dynamic].createFactory(AceEditor)
    f(props, children).asInstanceOf[ReactComponentU_]
  }
} 
开发者ID:wrotki,项目名称:spacommander,代码行数:39,代码来源:AceEditorGenerated.scala


示例6: LeftNav

//设置package包名称以及导入依赖的类
package client.components

import client.routes.Item
import japgolly.scalajs.react._
import japgolly.scalajs.react.extra.Reusability
import japgolly.scalajs.react.extra.router.RouterCtl
import japgolly.scalajs.react.vdom.prefix_<^._

import scala.scalajs.js.{Any, UndefOr}
import scalacss.Defaults._
import scalacss.ScalaCssReact._

object LeftNav {

  object Style extends StyleSheet.Inline {

    import dsl._

    val container = style(display.flex,
                          flexDirection.column,
                          listStyle := "none",
                          padding.`0`)

    val menuItem = styleF.bool(
      selected =>
        styleS(
          lineHeight(48.px),
          padding :=! "0 25px",
          cursor.pointer,
          textDecoration := "none",
          mixinIfElse(selected)(color.red, fontWeight._500)(
            color.black,
            &.hover(color(c"#555555"), backgroundColor(c"#ecf0f1")))
      ))
  }

  case class Props(menus: Vector[Item],
                   selectedPage: Item,
                   ctrl: RouterCtl[Item])

  implicit val currentPageReuse = Reusability.by_==[Item]
  implicit val propsReuse = Reusability.by((_: Props).selectedPage)

  val component = ReactComponentB[Props]("LeftNav")
    .render_P { P =>
      <.ul(Style.container)(
        P.menus.map(
          item =>
            <.li(^.key := item.title,
                 Style.menuItem(item == P.selectedPage),
                 item.title,
                 P.ctrl setOnClick item))
      )
    }
    .configure(Reusability.shouldComponentUpdate)
    .build

  def apply(props: Props, ref: UndefOr[String] = "", key: Any = {}) =
    component.set(key, ref)(props)

} 
开发者ID:tomdom,项目名称:play-scalajs-react-template,代码行数:62,代码来源:LeftNav.scala


示例7: ColumnReader

//设置package包名称以及导入依赖的类
package com.criteo.vizatra.vizsql.js.json

import com.criteo.vizatra.vizsql._
import com.criteo.vizatra.vizsql.hive.TypeParser

import scala.scalajs.js.{Dynamic, UndefOr}

object ColumnReader extends Reader[Column] {
  lazy val hiveTypeParser = new TypeParser

  override def apply(dyn: Dynamic): Column = {
    val name = dyn.name.asInstanceOf[String]
    val nullable = dyn.nullable.asInstanceOf[UndefOr[Boolean]].getOrElse(false)
    val typ = parseType(dyn.`type`.asInstanceOf[String], nullable)
    Column(name, typ)
  }

  def parseType(input: String, nullable: Boolean): Type = Type.from(nullable).applyOrElse(input, (rest: String) =>
    hiveTypeParser.parseType(rest) match {
      case Left(err) => throw new IllegalArgumentException(err)
      case Right(t) => t
    }
  )
} 
开发者ID:criteo,项目名称:vizsql,代码行数:25,代码来源:ColumnReader.scala


示例8: SchemaReader

//设置package包名称以及导入依赖的类
package com.criteo.vizatra.vizsql.js.json

import com.criteo.vizatra.vizsql.{Schema, Table}
import scalajs.js.Array

import scala.scalajs.js.UndefOr
import scala.scalajs.js.Dynamic

object SchemaReader extends Reader[Schema] {
  override def apply(dyn: Dynamic): Schema = {
    val name = dyn.name.asInstanceOf[String]
    val tables: List[Table] = dyn.tables
      .asInstanceOf[UndefOr[Array[Dynamic]]]
      .getOrElse(Array())
      .toList map TableReader.apply
    Schema(name, tables)
  }
} 
开发者ID:criteo,项目名称:vizsql,代码行数:19,代码来源:SchemaReader.scala


示例9: TableReader

//设置package包名称以及导入依赖的类
package com.criteo.vizatra.vizsql.js.json

import com.criteo.vizatra.vizsql.{Column, Table}

import scala.scalajs.js.{Dynamic, UndefOr, Array}

object TableReader extends Reader[Table] {
  override def apply(dyn: Dynamic): Table = {
    val table = dyn.name.asInstanceOf[String]
    val columns: List[Column] = dyn.columns
      .asInstanceOf[UndefOr[Array[Dynamic]]]
      .getOrElse(Array())
      .toList map ColumnReader.apply
    Table(table, columns)
  }
} 
开发者ID:criteo,项目名称:vizsql,代码行数:17,代码来源:TableReader.scala


示例10: ParseResult

//设置package包名称以及导入依赖的类
package com.criteo.vizatra.vizsql.js.common

import scala.scalajs.js
import scala.scalajs.js.UndefOr
import scala.scalajs.js.annotation.ScalaJSDefined
import scala.scalajs.js.JSConverters._
import com.criteo.vizatra.vizsql

@ScalaJSDefined
class ParseResult(val error: UndefOr[ParseError] = js.undefined, val select: UndefOr[Select] = js.undefined) extends js.Object

@ScalaJSDefined
class ParseError(val msg: String, val pos: Int) extends js.Object

@ScalaJSDefined
class Select(val columns: js.Array[Column], val tables: js.Array[Table]) extends js.Object

@ScalaJSDefined
class Column(val name: String, val `type`: String, val nullable: Boolean) extends js.Object

object Column {
  def from(column: vizsql.Column): Column = new Column(column.name, column.typ.show, column.typ.nullable)
}

@ScalaJSDefined
class Table(val name: String, val columns: js.Array[Column], val schema: UndefOr[String] = js.undefined) extends js.Object

object Table {
  def from(table: vizsql.Table, schema: Option[String] = None): Table = new Table(table.name, table.columns.map(Column.from).toJSArray, schema.orUndefined)
} 
开发者ID:criteo,项目名称:vizsql,代码行数:31,代码来源:ParseResult.scala


示例11: LeftNav

//设置package包名称以及导入依赖的类
package components

import japgolly.scalajs.react._
import japgolly.scalajs.react.extra.Reusability
import japgolly.scalajs.react.extra.router.RouterCtl
import japgolly.scalajs.react.vdom.prefix_<^._

import scala.scalajs.js.{Any, UndefOr}
import scalacss.Defaults._
import scalacss.ScalaCssReact._
import routes.Item

object LeftNav {

  case class Props(menus: Vector[Item],
                   selectedPage: Item,
                   ctrl: RouterCtl[Item])

  implicit val currentPageReuse = Reusability.by_==[Item]
  implicit val propsReuse = Reusability.by((_: Props).selectedPage)

  val component = ReactComponentB[Props]("LeftNav").render_P { P =>
    <.ul(css.LeftNav.container)(
      P.menus.map(
        item =>
          <.li(^.key := item.title,
               css.LeftNav.menuItem(item == P.selectedPage),
               item.title,
               P.ctrl setOnClick item))
    )
  }.configure(Reusability.shouldComponentUpdate).build

  def apply(props: Props, ref: UndefOr[String] = "", key: Any = {}) =
    component.set(key, ref)(props)

} 
开发者ID:oswaldo,项目名称:react-scalajs-scalatags,代码行数:37,代码来源:LeftNav.scala


示例12: MobileWindow

//设置package包名称以及导入依赖的类
package com.mogproject.mogami.playground.api

import org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.UndefOr
import scala.scalajs.js.annotation.JSGlobal

@js.native
@JSGlobal("MobileWindow")
sealed class MobileWindow extends js.Object {
  @js.native
  def orientation: UndefOr[Int] = js.native
}

@js.native
@JSGlobal("MobileScreen")
sealed class MobileScreen extends js.Object {
  @js.native
  def orientation: UndefOr[Orientation] = js.native
}

@js.native
@JSGlobal("Orientation")
sealed class Orientation extends js.Object {
  @js.native
  def angle: UndefOr[Int] = js.native
}

object MobileScreen {
  private[this] def getAngle1: UndefOr[Int] = dom.window.asInstanceOf[MobileWindow].orientation

  private[this] def getAngle2: UndefOr[Int] = dom.window.screen.asInstanceOf[MobileScreen].orientation.flatMap(_.angle)

  
  def isLandscape: Boolean = math.abs(getAngle1.getOrElse(getAngle2.getOrElse(0))) == 90
} 
开发者ID:mogproject,项目名称:mog-playground,代码行数:38,代码来源:MobileScreen.scala


示例13: StatusFilter

//设置package包名称以及导入依赖的类
package todomvc.example

import scala.scalajs.js
import scala.scalajs.js.Any.jsArrayOps
import scala.scalajs.js.UndefOr
import scala.scalajs.js.UndefOr.{ any2undefOrA, undefOr2ops }

import com.greencatsoft.angularjs.Filter
import com.greencatsoft.angularjs.core.Location
import com.greencatsoft.angularjs.injectable

@injectable("statusFilter")
class StatusFilter(location: Location) extends Filter[js.Array[Task]] {

  override def filter(tasks: js.Array[Task]): js.Array[Task] = {
    val path: UndefOr[String] = location.path

    path.toOption match {
      case Some("/active") => tasks.filterNot(_.completed)
      case Some("/completed") => tasks.filter(_.completed)
      case _ => tasks
    }
  }
} 
开发者ID:pharmpress,项目名称:DmdBrowserScalaJs,代码行数:25,代码来源:StatusFilter.scala


示例14: RxLocation

//设置package包名称以及导入依赖的类
package com.karasiq.nanoboard.frontend.utils

import org.scalajs.dom
import org.scalajs.dom.window
import org.scalajs.jquery.jQuery
import rx._

import scala.scalajs.js.UndefOr

final class RxLocation(implicit ctx: Ctx.Owner) {
  private def readHash(hash: UndefOr[String]): Option[String] = {
    hash
      .filter(_.nonEmpty)
      .map(_.tail)
      .toOption
  }

  val hash: Var[Option[String]] = Var(readHash(window.location.hash))

  hash.triggerLater {
    window.location.hash = hash.now.fold("")("#" + _)
  }

  jQuery(dom.window).on("hashchange", () ? {
    hash() = readHash(window.location.hash)
  })
}

object RxLocation {
  def apply()(implicit ctx: Ctx.Owner): RxLocation = {
    new RxLocation()
  }
} 
开发者ID:Karasiq,项目名称:nanoboard,代码行数:34,代码来源:RxLocation.scala


示例15: customSheetName

//设置package包名称以及导入依赖的类
package com.karasiq.nanoboard.frontend.styles

import com.karasiq.bootstrap.BootstrapHtmlComponent
import com.karasiq.bootstrap.BootstrapImplicits._
import org.scalajs.dom
import org.scalajs.dom._
import rx._

import scala.scalajs.js.UndefOr
import scalatags.JsDom.all._
import scalatags.JsDom.tags2
import scalatags.stylesheet.{StyleSheet, _}

trait BoardStyle extends StyleSheet {
  override final def customSheetName: Option[String] = Some("nanoboard")

  def body: Cls
  def post: Cls
  def postInner: Cls
  def postId: Cls
  def postLink: Cls
  def input: Cls
  def submit: Cls

  def spoiler: Cls
  def greenText: Cls
}

object BoardStyle {
  val Common = Sheet[CommonStyles]
  val Makaba = Sheet[Makaba]
  val Futaba = Sheet[Futaba]
  val Burichan = Sheet[Burichan]
  val Muon = Sheet[Muon]
  val Neutron = Sheet[Neutron]
  val Gurochan = Sheet[Gurochan]

  def styles: Seq[BoardStyle] = Vector(Makaba, Futaba, Burichan, Muon, Neutron, Gurochan)

  def fromString(style: String): BoardStyle = styles.find(_.toString == style).getOrElse(Makaba)

  def selector(implicit ctx: Ctx.Owner): Selector = {
    new Selector()
  }

  final class Selector(implicit ctx: Ctx.Owner) extends BootstrapHtmlComponent[dom.html.Style] {
    val style: Var[BoardStyle] = Var {
      val styleName: UndefOr[String] = window.localStorage.getItem("nanoboard-style")
      styleName.map(fromString).getOrElse(Makaba)
    }

    style.foreach { style ?
      window.localStorage.setItem("nanoboard-style", style.toString)
    }

    override def renderTag(md: Modifier*) = {
      tags2.style(style.map(_.styleSheetText), Common.styleSheetText, md)
    }
  }
} 
开发者ID:Karasiq,项目名称:nanoboard,代码行数:61,代码来源:BoardStyle.scala


示例16: VideoJSBuilder

//设置package包名称以及导入依赖的类
package com.karasiq.videojs

import org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.UndefOr

case class VideoJSBuilder(sources: Seq[VideoSource] = Nil, controls: Boolean = true, autoplay: Boolean = false, loop: Boolean = false, fluid: Boolean = false, preload: String = "auto", poster: UndefOr[String] = js.undefined, width: UndefOr[Int] = js.undefined, height: UndefOr[Int] = js.undefined, techOrder: Seq[String] = Nil, readyHandlers: Seq[Player ? Unit] = Nil, additional: Map[String, js.Any] = Map.empty) {
  def sources(value: VideoSource*): VideoJSBuilder = copy(sources = value)
  def controls(value: Boolean): VideoJSBuilder = copy(controls = value)
  def autoplay(value: Boolean): VideoJSBuilder = copy(autoplay = value)
  def loop(value: Boolean): VideoJSBuilder = copy(loop = value)
  def fluid(value: Boolean): VideoJSBuilder = copy(fluid = value)
  def preload(value: String): VideoJSBuilder = copy(preload = value)
  def poster(value: String): VideoJSBuilder = copy(poster = value)
  def dimensions(width: Int, height: Int): VideoJSBuilder = copy(width = width, height = height)
  def width(value: Int): VideoJSBuilder = copy(width = value)
  def height(value: Int): VideoJSBuilder = copy(height = value)
  def techOrder(value: String*): VideoJSBuilder = copy(techOrder = value)
  def ready(value: Player ? Unit): VideoJSBuilder = copy(readyHandlers = readyHandlers :+ value)
  def options(opts: (String, js.Any)*): VideoJSBuilder = copy(additional = additional ++ opts)

  def build(): dom.Element = {
    val videoContainer = dom.document.createElement("video")
    videoContainer.setAttribute("class", "video-js")
    val wrapper = dom.document.createElement("div")
    wrapper.appendChild(videoContainer)

    val settings = VideoJSOptions(sources, controls, autoplay, loop, fluid, preload, poster, width, height, techOrder, additional.toSeq)
    VideoJS(videoContainer, settings, VjsUtils.ready(player ? readyHandlers.foreach(_(player))))
    wrapper
  }
} 
开发者ID:Karasiq,项目名称:scalajs-videojs,代码行数:34,代码来源:VideoJSBuilder.scala


示例17: VideoSource

//设置package包名称以及导入依赖的类
package com.karasiq.videojs

import scala.scalajs.js
import scala.scalajs.js.JSConverters._
import scala.scalajs.js.UndefOr
import scala.scalajs.js.annotation.ScalaJSDefined

@js.native
trait VideoSource extends js.Object {
  val `type`: String = js.native
  val src: String = js.native
}

object VideoSource {
  def apply(`type`: String, src: String): VideoSource = {
    js.Dynamic.literal(`type` = `type`, src = src).asInstanceOf[VideoSource]
  }
}

object VideoJSOptions {
  def apply(sources: Seq[VideoSource], controls: Boolean = true, autoplay: Boolean = false, loop: Boolean = false, fluid: Boolean = false, preload: String = "auto", poster: UndefOr[String] = js.undefined, width: UndefOr[Int] = js.undefined, height: UndefOr[Int] = js.undefined, techOrder: Seq[String] = Nil, additional: Seq[(String, js.Any)] = Nil): VideoJSOptions = {
    val obj = js.Object().asInstanceOf[js.Dynamic]
    obj.controls = controls
    obj.autoplay = autoplay
    obj.fluid = fluid
    obj.loop = loop
    obj.preload = preload
    if (poster.nonEmpty) obj.poster = poster
    if (width.nonEmpty) obj.width = width
    if (height.nonEmpty) obj.height = height
    if (sources.nonEmpty) obj.sources = sources.toJSArray
    if (techOrder.nonEmpty) obj.techOrder = techOrder.toJSArray
    additional.foreach { case (key, value) ? obj.updateDynamic(key)(value) }
    obj.asInstanceOf[VideoJSOptions]
  }
}

@ScalaJSDefined
class VideoJSOptions extends js.Object {
  
  val height: UndefOr[Int] = js.undefined

  val fluid: Boolean = false

  val techOrder: js.Array[String] = js.Array()

  val sources: js.Array[VideoSource] = js.Array()
} 
开发者ID:Karasiq,项目名称:scalajs-videojs,代码行数:49,代码来源:VideoJSOptions.scala


示例18: LeftNav

//设置package包名称以及导入依赖的类
package components

import japgolly.scalajs.react._
import japgolly.scalajs.react.extra.Reusability
import japgolly.scalajs.react.extra.router.RouterCtl
import japgolly.scalajs.react.vdom.prefix_<^._

import scala.scalajs.js.{Any, UndefOr}
import scalacss.Defaults._
import scalacss.ScalaCssReact._
import routes.Item

object LeftNav {

  case class Props(menus: Vector[Item],
                   selectedPage: Item,
                   ctrl: RouterCtl[Item])

  implicit val currentPageReuse = Reusability.by_==[Item]
  implicit val propsReuse = Reusability.by((_: Props).selectedPage)

  val component = ReactComponentB[Props]("LeftNav").render_P { P =>
    <.ul(css.LeftNav.container)(
        P.menus.map(
            item =>
              <.li(^.key := item.title,
                   css.LeftNav.menuItem(item == P.selectedPage),
                   item.title,
                   P.ctrl setOnClick item))
    )
  }.configure(Reusability.shouldComponentUpdate).build

  def apply(props: Props, ref: UndefOr[String] = "", key: Any = {}) =
    component.set(key, ref)(props)

} 
开发者ID:oswaldo,项目名称:react-quill,代码行数:37,代码来源:LeftNav.scala



注:本文中的scala.scalajs.js.UndefOr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala AvatarService类代码示例发布时间:2022-05-23
下一篇:
Scala ArgumentMatchers类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap