diff --git a/core-play25/app/views/bs/Args.scala b/core-play25/app/views/bs/Args.scala
deleted file mode 100644
index c308613..0000000
--- a/core-play25/app/views/bs/Args.scala
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.bs
-
-object Args {
-
- import play.api.i18n.Messages
-
- /**
- * Adds some default arguments to the parameter 'args'
- */
- def withDefault(args: Seq[(Symbol, Any)], default: (Symbol, Any)*) = default ++: args
-
- /**
- * Adds a string value to a selected arg. For example, to add "form-control" to 'class, even if there is already other extra class
- */
- def withAddingStringValue(args: Seq[(Symbol, Any)], arg: Symbol, value: String): Seq[(Symbol, Any)] = {
- val (withArg, withoutArg) = args.partition(_._1 == arg)
- (arg, withArg.headOption.map(v => s"$value ${v._2.toString}").getOrElse(value)) +: withoutArg
- }
- def withAddingStringValue(args: Seq[(Symbol, Any)], arg: Symbol, maybeValue: Option[String]): Seq[(Symbol, Any)] =
- maybeValue.map(value => withAddingStringValue(args, arg, value)).getOrElse(args)
-
- /**
- * Removes those arguments which its value is None. It lets you omit those arguments that satisfy some criteria.
- * It also lets you add some default arguments to the parameter 'args'.
- */
- def withoutNones(args: Seq[(Symbol, Any)], default: (Symbol, Any)*) = (default ++: args).filter(_._2 != None)
-
- /**
- * Returns only the inner arguments (those that are exclusive for an input and not for the field constructor).
- * Removes every argument with a prefixed underscore (_) and those whose value is false.
- * It also lets you add some default arguments to the parameter 'args'.
- */
- def inner(args: Seq[(Symbol, Any)], default: (Symbol, Any)*) =
- (default ++: args).filter(arg => !arg._1.name.startsWith("_") && arg._2 != false)
-
- /**
- * Gets the value for the selected key
- */
- def get(args: Seq[(Symbol, Any)], key: Symbol) = args.find(_._1 == key).map(_._2)
-
- /**
- * Removes those arguments with these keys
- */
- def remove(args: Seq[(Symbol, Any)], keys: Symbol*) = args.filter(arg => !keys.contains(arg._1))
-
- /**
- * Returns true only if exists a pair with that key and its value is true.
- */
- def isTrue(args: Seq[(Symbol, Any)], key: Symbol) = args.exists(_ == (key, true))
-
- /**
- * Localizes an argument
- */
- def msg(arg: (Symbol, Any))(implicit msgs: Messages): (Symbol, Any) = arg match {
- case (sym, str: String) => (sym, msgs(str))
- case _ => arg
- }
-
- /**
- * Localizes a value
- */
- def msg(a: Any)(implicit msgs: Messages): Any = a match {
- case str: String => msgs(str)
- case _ => a
- }
-}
-
-object ArgsMap {
- /**
- * Adds a string value to a selected arg. For example, to add "form-control" to 'class, even if there is already other extra class
- */
- def withAddingStringValue(argsMap: Map[Symbol, Any], arg: Symbol, value: String): Map[Symbol, Any] = {
- val newValue = argsMap.get(arg).map(v => s"$value ${v.toString}").getOrElse(value)
- argsMap + (arg -> newValue)
- }
- def withAddingStringValue(argsMap: Map[Symbol, Any], arg: Symbol, maybeValue: Option[String]): Map[Symbol, Any] =
- maybeValue.map(value => withAddingStringValue(argsMap, arg, value)).getOrElse(argsMap)
- /**
- * Returns true only if the map contains an argument with that key and its value is true.
- */
- def isTrue(argsMap: Map[Symbol, Any], key: Symbol) = argsMap.get(key).map(_ == true).getOrElse(false)
- /**
- * Returns true only if the map contains an argument with that key and its value is any value but false.
- */
- def isNotFalse(argsMap: Map[Symbol, Any], key: Symbol) = argsMap.get(key).map(_ != false).getOrElse(false)
-}
\ No newline at end of file
diff --git a/core-play25/app/views/bs/package.scala b/core-play25/app/views/bs/package.scala
deleted file mode 100644
index 3eb3f2f..0000000
--- a/core-play25/app/views/bs/package.scala
+++ /dev/null
@@ -1,216 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html
-
-package object bs {
-
- import play.api.data.{ Field, FormError }
- import play.twirl.api.Html
- import play.api.i18n.{ Lang, Messages }
- import bs.ArgsMap.isTrue
- import play.api.mvc.Call
-
- /**
- * Class with relevant variables for a field to pass it to the helper and field constructor
- * - args: list of available arguments for the helper and field constructor
- */
- class BSFieldInfo(field: Field, args: Seq[(Symbol, Any)], val messages: Messages) {
-
- /* A map with the args to work easily with them */
- val argsMap: Map[Symbol, Any] = Args.withoutNones(args).toMap
-
- /* Id of the input */
- val id: String = argsMap.get('id).map(_.toString).getOrElse(field.id)
-
- /* Id of the form-group */
- val idFormField: String = argsMap.get('_id).map(_.toString).getOrElse(id + "_field")
-
- /* The optional label */
- val labelOpt: Option[Any] = argsMap.get('_label).orElse(argsMap.get('_hiddenLabel))
-
- /* Indicates if the label must be hidden */
- val hideLabel: Boolean = isTrue(argsMap, '_hideLabel) || argsMap.contains('_hiddenLabel)
-
- /* Name of the input */
- def name: String = field.name
-
- /* Value of the input */
- val value: Option[String] = field.value.orElse(argsMap.get('value).map(_.toString))
-
- /* List with every error and its corresponding ARIA id. Ex: ("foo_error_0" -> "foo error") */
- val errors: Seq[(String, String)] = BSFieldInfo.errors(Some(field), argsMap, messages).zipWithIndex.map {
- case (error, i) => (id + "_error_" + i, error)
- }
-
- /* Indicates if there is any error */
- val hasErrors: Boolean = !errors.isEmpty || ArgsMap.isNotFalse(argsMap, '_error)
-
- /* The optional validation state ("success", "warning" or "error") */
- lazy val status: Option[String] = BSFieldInfo.status(hasErrors, argsMap)
-
- }
-
- /**
- * Companion object for class BSFieldInfo
- */
- object BSFieldInfo {
-
- def apply(field: Field, args: Seq[(Symbol, Any)], messages: Messages): BSFieldInfo = {
- new BSFieldInfo(field, args, messages)
- }
-
- /* List with every error */
- def errors(maybeField: Option[Field], argsMap: Map[Symbol, Any], messages: Messages): Seq[String] = {
- argsMap.get('_error).filter(!_.isInstanceOf[Boolean]).map {
- _ match {
- case Some(FormError(_, message, args)) => Seq(messages(message, args.map(a => translateMsgArg(a, messages)): _*))
- case message => Seq(messages(message.toString))
- }
- }.getOrElse {
- maybeField.filter(_ => argsMap.get('_showErrors) != Some(false)).map { field =>
- field.errors.map { e => messages(e.message, e.args.map(a => translateMsgArg(a, messages)): _*) }
- }.getOrElse(Nil)
- }
- }
-
- /* List with every "feedback info" except "errors" */
- def feedbackInfosButErrors(argsMap: Map[Symbol, Any], messages: Messages): Seq[String] = {
- argsMap.get('_warning).filter(!_.isInstanceOf[Boolean]).map(m => Seq(messages(m.toString))).getOrElse(
- argsMap.get('_success).filter(!_.isInstanceOf[Boolean]).map(m => Seq(messages(m.toString))).getOrElse(Nil)
- )
- }
-
- /* List with every "help info", i.e. a help text or constraints */
- def helpInfos(maybeField: Option[Field], argsMap: Map[Symbol, Any], messages: Messages): Seq[String] = {
- argsMap.get('_help).map(m => Seq(messages(m.toString))).getOrElse {
- maybeField.filter(_ => argsMap.get('_showConstraints) == Some(true)).map { field =>
- field.constraints.map(c => messages(c._1, c._2.map(a => translateMsgArg(a, messages)): _*)) ++ field.format.map(f => messages(f._1, f._2.map(a => translateMsgArg(a, messages)): _*))
- }.getOrElse(Nil)
- }
- }
-
- /* The optional validation state ("success", "warning" or "error") */
- def status(hasErrors: Boolean, argsMap: Map[Symbol, Any]): Option[String] = {
- if (hasErrors)
- Some("error")
- else if (ArgsMap.isNotFalse(argsMap, '_warning))
- Some("warning")
- else if (ArgsMap.isNotFalse(argsMap, '_success))
- Some("success")
- else
- None
- }
-
- /* Generates automatically the input attributes for the constraints of a field */
- def constraintsArgs(field: Field, messages: Messages): Seq[(Symbol, Any)] = field.constraints.map {
- case ("constraint.required", params) => Some(('required -> true))
- case ("constraint.min", params: Seq[Any]) => Some(('min -> messages(params.head.toString)))
- case ("constraint.max", params: Seq[Any]) => Some(('max -> messages(params.head.toString)))
- case ("constraint.minLength", params: Seq[Any]) => Some(('minlength -> messages(params.head.toString)))
- case ("constraint.maxLength", params: Seq[Any]) => Some(('maxlength -> messages(params.head.toString)))
- case ("constraint.pattern", params: Seq[Any]) => params.head match {
- case str: String => Some(('pattern -> messages(str)))
- case func: Function0[_] => Some(('pattern -> messages(func.asInstanceOf[() => scala.util.matching.Regex]().toString)))
- case _ => None
- }
- case _ => None
- }.flatten
-
- private def translateMsgArg(msgArg: Any, messages: Messages) = msgArg match {
- case key: String => messages(key)
- case keys: Seq[_] => keys.map(key => messages(key.toString))
- case _ => msgArg
- }
- }
-
- /**
- * Class with relevant variables for the global information of a multifield
- * - fields: list of Fields
- * - globalArguments: list of available arguments for the global helper
- * - fieldsArguments: list of available arguments for every specific field
- */
- class BSMultifieldInfo(fields: Seq[Field], globalArguments: Seq[(Symbol, Any)], fieldsArguments: Seq[(Symbol, Any)], val messages: Messages) {
-
- /* A map with the args to work easily with them. The '_help is removed because the helper freeFormFieldormField will add it */
- val argsMap: Map[Symbol, Any] = Args.withoutNones(fieldsArguments ++ globalArguments).toMap
-
- /* List with every error */
- val errors: Seq[String] = {
- val globalErrors = BSFieldInfo.errors(None, argsMap, messages)
- if (globalErrors.size > 0)
- globalErrors
- else
- fields.flatMap { field =>
- BSFieldInfo.errors(Some(field), argsMap, messages)
- }
- }
-
- /* Indicates if there is any error */
- val hasErrors: Boolean = !errors.isEmpty || ArgsMap.isNotFalse(argsMap, '_error)
-
- /* The optional validation state ("success", "warning" or "error") */
- lazy val status: Option[String] = BSFieldInfo.status(hasErrors, argsMap)
-
- lazy val globalArgs = globalArguments
-
- lazy val fieldsArgs = fieldsArguments
- }
-
- /**
- * Companion object for class BSMultifieldInfo
- */
- object BSMultifieldInfo {
- def apply(fields: Seq[Field], globalArguments: Seq[(Symbol, Any)], fieldsArguments: Seq[(Symbol, Any)], messages: Messages): BSMultifieldInfo = {
- new BSMultifieldInfo(fields, globalArguments, fieldsArguments, messages)
- }
- }
-
- /**
- * Custom BSFieldConstructor for the library. Every BSFieldConstructor must extend this functionality.
- */
- trait BSFieldConstructor[F <: BSFieldInfo] {
- /* Renders the corresponding template of the field constructor */
- def apply(fieldInfo: F, inputHtml: Html)(implicit messages: Messages): Html
- /* Renders the corresponding template of a fake field constructor (i.e. with the same structure but without the field) */
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages): Html
- }
-
- /**
- * Renders an input field with its corresponding wrapper using the BSFieldConstructor.
- * - fieldInfo: a BSFieldInfo with all the information about the field.
- * - inputDef: function that returns a Html from the BSFieldInfo.
- */
- def inputFormField[F <: BSFieldInfo](fieldInfo: F)(inputDef: F => Html)(implicit fc: BSFieldConstructor[F]) =
- fc(fieldInfo, inputDef(fieldInfo))(fieldInfo.messages)
-
- /**
- * Renders a fake field constructor using the BSFieldConstructor.
- * - args: list of available arguments for the helper and the form-group
- * - contentDef: function that returns a Html from a map of arguments
- */
- def freeFormField[F <: BSFieldInfo](args: Seq[(Symbol, Any)])(contentDef: Map[Symbol, Any] => Html)(implicit fc: BSFieldConstructor[F], messages: Messages) = {
- val argsWithoutNones = Args.withoutNones(args)
- fc(contentDef(Args.inner(argsWithoutNones).toMap), argsWithoutNones.toMap)(messages)
- }
-
- /**
- * Renders a multi-field constructor using the BSFieldConstructor.
- * - fieldInfo: a BSMultifieldInfo with all the information about the fields.
- * - contentDef: function that returns a Html from the BSMultifieldInfo
- */
- def multifieldFormField[F <: BSFieldInfo, M <: BSMultifieldInfo](multifieldInfo: M)(contentDef: M => Html)(implicit fc: BSFieldConstructor[F]) =
- freeFormField(multifieldInfo.globalArgs)(_ => contentDef(multifieldInfo))(fc, multifieldInfo.messages)
-}
\ No newline at end of file
diff --git a/core-play25/build.sbt b/core-play25/build.sbt
deleted file mode 100644
index 43405af..0000000
--- a/core-play25/build.sbt
+++ /dev/null
@@ -1,62 +0,0 @@
-name := """play-bootstrap-core"""
-
-version := "1.4-P25-SNAPSHOT"
-
-scalaVersion := "2.11.11"
-
-crossScalaVersions := Seq("2.11.11")
-
-resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
-
-
-lazy val root = (project in file(".")).enablePlugins(PlayScala)
-
-
-
-scalariformSettings
-
-//*******************************
-// Maven settings
-//*******************************
-
-sonatypeSettings
-
-publishMavenStyle := true
-
-organization := "com.adrianhurt"
-
-description := "This is a collection of input helpers and field constructors for Play Framework to render Bootstrap HTML code."
-
-homepage := Some(url("http://adrianhurt.github.io/play-bootstrap"))
-
-licenses := Seq("Apache License" -> url("https://github.com/adrianhurt/play-bootstrap/blob/master/LICENSE"))
-
-startYear := Some(2014)
-
-publishTo := {
- val nexus = "https://oss.sonatype.org/"
- if (isSnapshot.value)
- Some("snapshots" at nexus + "content/repositories/snapshots")
- else
- Some("releases" at nexus + "service/local/staging/deploy/maven2")
-}
-
-publishArtifact in Test := false
-
-pomIncludeRepository := { _ => false }
-
-pomExtra := (
-
- git@github.com:adrianhurt/play-bootstrap.git
- scm:git:git@github.com:adrianhurt/play-bootstrap.git
-
-
-
- adrianhurt
- Adrian Hurtado
- https://github.com/adrianhurt
-
-
-)
-
-credentials += Credentials(Path.userHome / ".sbt" / "sonatype.credentials")
diff --git a/core-play25/project/build.properties b/core-play25/project/build.properties
deleted file mode 100644
index c364161..0000000
--- a/core-play25/project/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-#Activator-generated Properties
-#Mon Aug 11 18:06:16 BST 2014
-template.uuid=688014f0-0585-43e3-a9fa-d62f7d12f1ab
-sbt.version=0.13.11
diff --git a/core-play25/project/plugins.sbt b/core-play25/project/plugins.sbt
deleted file mode 100644
index 63f4ec9..0000000
--- a/core-play25/project/plugins.sbt
+++ /dev/null
@@ -1,12 +0,0 @@
-resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
-
-// The Play plugin
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.18")
-
-// web plugins
-
-addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
-
-addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.2")
-
-addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
diff --git a/core-play26/build.sbt b/core-play26/build.sbt
index 13cf4f0..32219ff 100644
--- a/core-play26/build.sbt
+++ b/core-play26/build.sbt
@@ -1,10 +1,10 @@
name := """play-bootstrap-core"""
-version := "1.4-P26-SNAPSHOT"
+version := "1.5-P26-SNAPSHOT"
-scalaVersion := "2.12.4"
+scalaVersion := "2.12.8"
-crossScalaVersions := Seq("2.12.4", "2.11.12")
+crossScalaVersions := Seq("2.12.8", "2.11.12")
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
diff --git a/core-play26/project/plugins.sbt b/core-play26/project/plugins.sbt
index 69d2bb6..070c0e5 100644
--- a/core-play26/project/plugins.sbt
+++ b/core-play26/project/plugins.sbt
@@ -1,7 +1,7 @@
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// The Play plugin
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.12")
+addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.21")
// web plugins
diff --git a/play25-bootstrap3/module/app/views/b3/bsFieldConstructorCommon.scala.html b/play25-bootstrap3/module/app/views/b3/bsFieldConstructorCommon.scala.html
deleted file mode 100644
index 7056c03..0000000
--- a/play25-bootstrap3/module/app/views/b3/bsFieldConstructorCommon.scala.html
+++ /dev/null
@@ -1,9 +0,0 @@
-@(fieldInfo: b3.B3FieldInfo, inputHtml: Html)(wrap: Html => Html)(implicit fc: b3.B3FieldConstructor)
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/buttonType.scala.html b/play25-bootstrap3/module/app/views/b3/buttonType.scala.html
deleted file mode 100644
index c33f8c5..0000000
--- a/play25-bootstrap3/module/app/views/b3/buttonType.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(buttonType: String, args: (Symbol,Any)*)(text: => Html)(implicit fc: b3.B3FieldConstructor, messages: Messages)
-@freeFormGroup(args) { innerArgsMap =>
-
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/checkbox.scala.html b/play25-bootstrap3/module/app/views/b3/checkbox.scala.html
deleted file mode 100644
index d8e8bc4..0000000
--- a/play25-bootstrap3/module/app/views/b3/checkbox.scala.html
+++ /dev/null
@@ -1,22 +0,0 @@
-@(field: Field, args: (Symbol,Any)*)(implicit fc: b3.B3FieldConstructor, messages: Messages)
-@defining({
- val argsMap = args.toMap
- val value = argsMap.get('value).getOrElse("true").toString
- val checked = argsMap.get('checked).orElse(field.value.map(_ == value).orElse(argsMap.get('_default))).map(_.toString == "true").getOrElse(false)
- val containsReadonly = argsMap.contains('readonly)
- val readonly = bs.ArgsMap.isTrue(argsMap, 'readonly)
- val disabled = readonly || bs.ArgsMap.isTrue(argsMap, 'disabled)
- (argsMap, value, checked, containsReadonly, readonly, disabled)
-}){ case (argsMap, value, checked, containsReadonly, readonly, disabled) =>
- @inputFormGroup(field, withFeedback = false, withLabelFor = false, bs.Args.withDefault(args.filterNot(_._1 == 'checked), 'checked -> checked, 'disabled -> disabled)) { fieldInfo =>
-
-
- @if(containsReadonly) {
-
- }
-
- }(fc, messages)
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/clear/package.scala b/play25-bootstrap3/module/app/views/b3/clear/package.scala
deleted file mode 100644
index 875d6c4..0000000
--- a/play25-bootstrap3/module/app/views/b3/clear/package.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b3
-
-package object clear {
-
- import play.twirl.api.Html
- import play.api.mvc.{ Call, RequestHeader }
- import play.api.i18n.Messages
- import views.html.helper._
- import views.html.bs.Args.{ inner, isTrue }
-
- /**
- * Declares the class for the Clear FieldConstructor.
- */
- class ClearFieldConstructor(val withFeedbackIcons: Boolean = false) extends B3FieldConstructor {
- /* Define the class of the corresponding form */
- val formClass = "form-clear"
- /* Renders the corresponding template of the field constructor */
- def apply(fieldInfo: B3FieldInfo, inputHtml: Html)(implicit messages: Messages) = inputHtml
- /* Renders the corresponding template of the form group */
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages) = contentHtml
- }
-
- /**
- * Creates a new ClearFieldConstructor to use for specific forms or scopes (don't use it as a default one).
- * If a default B3FieldConstructor and a specific ClearFieldConstructor are within the same scope, the more
- * specific will be chosen.
- */
- def fieldConstructorSpecific(withFeedbackIcons: Boolean = false): ClearFieldConstructor =
- new ClearFieldConstructor(withFeedbackIcons)
-
- /**
- * Returns it as a B3FieldConstructor to use it as default within a template
- */
- def fieldConstructor(withFeedbackIcons: Boolean = false): B3FieldConstructor =
- fieldConstructorSpecific(withFeedbackIcons)
-
- /**
- * **********************************************************************************************************************************
- * SHORTCUT HELPERS
- * *********************************************************************************************************************************
- */
- def form(action: Call, args: (Symbol, Any)*)(body: ClearFieldConstructor => Html) = {
- val cfc = fieldConstructorSpecific(withFeedbackIcons = isTrue(args, '_feedbackIcons))
- views.html.b3.form(action, inner(args): _*)(body(cfc))(cfc)
- }
- def formCSRF(action: Call, args: (Symbol, Any)*)(body: ClearFieldConstructor => Html)(implicit request: RequestHeader) = {
- val cfc = fieldConstructorSpecific(withFeedbackIcons = isTrue(args, '_feedbackIcons))
- views.html.b3.formCSRF(action, inner(args): _*)(body(cfc))(cfc, request)
- }
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/file.scala.html b/play25-bootstrap3/module/app/views/b3/file.scala.html
deleted file mode 100644
index a4252e2..0000000
--- a/play25-bootstrap3/module/app/views/b3/file.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(field: Field, args: (Symbol,Any)*)(implicit fc: b3.B3FieldConstructor, messages: Messages)
-@inputFormGroup(field, withFeedback = true, withLabelFor = true, args) { fieldInfo =>
-
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/form.scala.html b/play25-bootstrap3/module/app/views/b3/form.scala.html
deleted file mode 100644
index 53d938c..0000000
--- a/play25-bootstrap3/module/app/views/b3/form.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(action: Call, args: (Symbol, Any)*)(body: => Html)(implicit fc: b3.B3FieldConstructor)
-
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/formCSRF.scala.html b/play25-bootstrap3/module/app/views/b3/formCSRF.scala.html
deleted file mode 100644
index e85f92f..0000000
--- a/play25-bootstrap3/module/app/views/b3/formCSRF.scala.html
+++ /dev/null
@@ -1,5 +0,0 @@
-@(action: Call, args: (Symbol, Any)*)(body: => Html)(implicit fc: b3.B3FieldConstructor, request: RequestHeader)
-@form(action, args:_*) {
- @helper.CSRF.formField
- @body
-}(fc)
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/hiddenInput.scala.html b/play25-bootstrap3/module/app/views/b3/hiddenInput.scala.html
deleted file mode 100644
index 5ae08f3..0000000
--- a/play25-bootstrap3/module/app/views/b3/hiddenInput.scala.html
+++ /dev/null
@@ -1,2 +0,0 @@
-@(name: Any, value: Any, args: (Symbol, Any)*)
-
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/hiddens.scala.html b/play25-bootstrap3/module/app/views/b3/hiddens.scala.html
deleted file mode 100644
index 6c7d022..0000000
--- a/play25-bootstrap3/module/app/views/b3/hiddens.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(namesAndValues: (Any, Any)*)
-@namesAndValues.map { case (name, value) =>
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/horizontal/bsFieldConstructor.scala.html b/play25-bootstrap3/module/app/views/b3/horizontal/bsFieldConstructor.scala.html
deleted file mode 100644
index aa9fcd3..0000000
--- a/play25-bootstrap3/module/app/views/b3/horizontal/bsFieldConstructor.scala.html
+++ /dev/null
@@ -1,13 +0,0 @@
-@(fieldInfo: b3.B3FieldInfo, inputHtml: Html, colLabel: String, colOffset: String, colInput: String)(implicit fc: b3.B3FieldConstructor, messages: Messages)
-@b3.bsFieldConstructorCommon(fieldInfo, inputHtml) { content =>
- @fieldInfo.labelOpt.map { label =>
-
-
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/textarea.scala.html b/play25-bootstrap3/module/app/views/b3/textarea.scala.html
deleted file mode 100644
index 8c2604e..0000000
--- a/play25-bootstrap3/module/app/views/b3/textarea.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(field: Field, args: (Symbol,Any)*)(implicit fc: b3.B3FieldConstructor, messages: Messages)
-@inputFormGroup(field, withFeedback = false, withLabelFor = true, bs.Args.withAddingStringValue(args, 'class, "form-control")) { fieldInfo =>
-
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/vertical/bsFieldConstructor.scala.html b/play25-bootstrap3/module/app/views/b3/vertical/bsFieldConstructor.scala.html
deleted file mode 100644
index 3d2aa0a..0000000
--- a/play25-bootstrap3/module/app/views/b3/vertical/bsFieldConstructor.scala.html
+++ /dev/null
@@ -1,7 +0,0 @@
-@(fieldInfo: b3.B3FieldInfo, inputHtml: Html)(implicit fc: b3.B3FieldConstructor, messages: Messages)
-@b3.bsFieldConstructorCommon(fieldInfo, inputHtml) { content =>
- @fieldInfo.labelOpt.map { label =>
-
- }
- @content
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/vertical/bsFormGroup.scala.html b/play25-bootstrap3/module/app/views/b3/vertical/bsFormGroup.scala.html
deleted file mode 100644
index 064e7fd..0000000
--- a/play25-bootstrap3/module/app/views/b3/vertical/bsFormGroup.scala.html
+++ /dev/null
@@ -1,7 +0,0 @@
-@(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages)
-@b3.bsFormGroupCommon(contentHtml, argsMap) { content =>
- @argsMap.get('_label).map { label =>
-
- }
- @content
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/app/views/b3/vertical/package.scala b/play25-bootstrap3/module/app/views/b3/vertical/package.scala
deleted file mode 100644
index 3924516..0000000
--- a/play25-bootstrap3/module/app/views/b3/vertical/package.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b3
-
-package object vertical {
-
- import play.twirl.api.Html
- import play.api.mvc.{ Call, RequestHeader }
- import play.api.i18n.Messages
- import views.html.helper._
- import views.html.bs.Args.{ inner, isTrue }
-
- /**
- * Declares the class for the Vertical FieldConstructor.
- */
- class VerticalFieldConstructor(val withFeedbackIcons: Boolean = false) extends B3FieldConstructor {
- /* Define the class of the corresponding form */
- val formClass = "form-vertical"
- /* Renders the corresponding template of the field constructor */
- def apply(fieldInfo: B3FieldInfo, inputHtml: Html)(implicit messages: Messages) = bsFieldConstructor(fieldInfo, inputHtml)(this, messages)
- /* Renders the corresponding template of the form group */
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages) = bsFormGroup(contentHtml, argsMap)(messages)
- }
-
- /**
- * Creates a new VerticalFieldConstructor to use for specific forms or scopes (don't use it as a default one).
- * If a default B3FieldConstructor and a specific VerticalFieldConstructor are within the same scope, the more
- * specific will be chosen.
- */
- def fieldConstructorSpecific(withFeedbackIcons: Boolean = false): VerticalFieldConstructor =
- new VerticalFieldConstructor(withFeedbackIcons)
-
- /**
- * Returns it as a B3FieldConstructor to use it as default within a template
- */
- def fieldConstructor(withFeedbackIcons: Boolean = false): B3FieldConstructor =
- fieldConstructorSpecific(withFeedbackIcons)
-
- /**
- * **********************************************************************************************************************************
- * SHORTCUT HELPERS
- * *********************************************************************************************************************************
- */
- def form(action: Call, args: (Symbol, Any)*)(body: VerticalFieldConstructor => Html) = {
- val vfc = fieldConstructorSpecific(withFeedbackIcons = isTrue(args, '_feedbackIcons))
- views.html.b3.form(action, args: _*)(body(vfc))(vfc)
- }
- def formCSRF(action: Call, args: (Symbol, Any)*)(body: VerticalFieldConstructor => Html)(implicit request: RequestHeader) = {
- val vfc = fieldConstructorSpecific(withFeedbackIcons = isTrue(args, '_feedbackIcons))
- views.html.b3.formCSRF(action, args: _*)(body(vfc))(vfc, request)
- }
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/build.sbt b/play25-bootstrap3/module/build.sbt
deleted file mode 100644
index 5903829..0000000
--- a/play25-bootstrap3/module/build.sbt
+++ /dev/null
@@ -1,70 +0,0 @@
-name := """play-bootstrap"""
-
-version := "1.4-P25-B3-SNAPSHOT"
-
-scalaVersion := "2.11.11"
-
-crossScalaVersions := Seq("2.11.11")
-
-resolvers ++= Seq(
- "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
- "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
-)
-
-libraryDependencies ++= Seq(
- filters % "provided",
- "com.adrianhurt" %% "play-bootstrap-core" % "1.4-P25-SNAPSHOT",
- specs2 % Test
-)
-
-lazy val root = (project in file(".")).enablePlugins(PlayScala)
-
-
-
-scalariformSettings
-
-//*******************************
-// Maven settings
-//*******************************
-
-sonatypeSettings
-
-publishMavenStyle := true
-
-organization := "com.adrianhurt"
-
-description := "This is a collection of input helpers and field constructors for Play Framework to render Bootstrap HTML code."
-
-homepage := Some(url("https://adrianhurt.github.io/play-bootstrap"))
-
-licenses := Seq("Apache License" -> url("https://github.com/adrianhurt/play-bootstrap/blob/master/LICENSE"))
-
-startYear := Some(2014)
-
-publishTo := {
- val nexus = "https://oss.sonatype.org/"
- if (isSnapshot.value)
- Some("snapshots" at nexus + "content/repositories/snapshots")
- else
- Some("releases" at nexus + "service/local/staging/deploy/maven2")
-}
-
-publishArtifact in Test := false
-
-pomIncludeRepository := { _ => false }
-
-pomExtra := (
-
- git@github.com:adrianhurt/play-bootstrap.git
- scm:git:git@github.com:adrianhurt/play-bootstrap.git
-
-
-
- adrianhurt
- Adrian Hurtado
- https://github.com/adrianhurt
-
-
-)
-
-credentials += Credentials(Path.userHome / ".sbt" / "sonatype.credentials")
diff --git a/play25-bootstrap3/module/project/build.properties b/play25-bootstrap3/module/project/build.properties
deleted file mode 100644
index c364161..0000000
--- a/play25-bootstrap3/module/project/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-#Activator-generated Properties
-#Mon Aug 11 18:06:16 BST 2014
-template.uuid=688014f0-0585-43e3-a9fa-d62f7d12f1ab
-sbt.version=0.13.11
diff --git a/play25-bootstrap3/module/project/plugins.sbt b/play25-bootstrap3/module/project/plugins.sbt
deleted file mode 100644
index 63f4ec9..0000000
--- a/play25-bootstrap3/module/project/plugins.sbt
+++ /dev/null
@@ -1,12 +0,0 @@
-resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
-
-// The Play plugin
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.18")
-
-// web plugins
-
-addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
-
-addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.2")
-
-addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
diff --git a/play25-bootstrap3/module/test/FieldConstructorsSpec.scala b/play25-bootstrap3/module/test/FieldConstructorsSpec.scala
deleted file mode 100644
index 61d6ed2..0000000
--- a/play25-bootstrap3/module/test/FieldConstructorsSpec.scala
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b3
-
-import views.html.b3
-import TestUtils._
-import org.specs2.mutable.Specification
-import views.html.helper.FieldConstructor
-import play.api.data.Forms._
-import play.api.data._
-import play.api.{ Configuration, Environment }
-import play.api.i18n.{ DefaultLangs, DefaultMessagesApi }
-import play.twirl.api.Html
-import play.api.mvc.Call
-
-object FieldConstructorsSpec extends Specification {
-
- val messagesApi = new DefaultMessagesApi(Environment.simple(), Configuration.reference, new DefaultLangs(Configuration.reference))
- implicit val messages = messagesApi.preferred(Seq.empty)
-
- def testFielConstructor(fcDefault: B3FieldConstructor, fcWithFeedbackIcons: B3FieldConstructor) = {
- implicit val fc = fcDefault
- val testInputString = ""
- def testInput(field: Field, args: (Symbol, Any)*) =
- b3.inputFormGroup(field, false, true, args) { _ => Html(testInputString) }
-
- val fooForm = Form(single("foo" -> Forms.nonEmptyText(maxLength = 8)))
- val fooField = fooForm("foo")
-
- val simpleInput = testInput(fooField).body
- def simpleInputWithArgs(args: (Symbol, Any)*)(implicit fc: B3FieldConstructor) = b3.text(fooField, args: _*).body
- def simpleInputWithError(args: (Symbol, Any)*)(implicit fc: B3FieldConstructor) = b3.text(fooForm.withError("foo", "test-error-0").withError("foo", "test-error-1")("foo"), args: _*).body
-
- val labelExtraClasses = fc match {
- case hfc: b3.horizontal.HorizontalFieldConstructor => " " + hfc.colLabel
- case _ => ""
- }
-
- "have the basic structure" in {
- simpleInput must contain("class=\"form-group")
- simpleInput must not contain ("has-error")
- simpleInput must not contain ("aria-invalid")
- simpleInput must contain(testInputString)
- simpleInput must not contain ("class=\"help-block\"")
- }
-
- "have a default id" in {
- simpleInput must contain("id=\"foo_field\"")
- }
-
- "allow setting a custom id" in {
- simpleInputWithArgs('_id -> "customid") must contain("id=\"customid\"")
- }
-
- "allow setting extra classes form-group" in {
- clean(simpleInputWithArgs('_class -> "extra_class another_class")) must contain(s"""
"theLabel")) must contain(s"""""")
- }
-
- "allow hide the label" in {
- val labelString = s""""""
- clean(simpleInputWithArgs('_label -> "theLabel", '_hideLabel -> true)) must contain(labelString)
- clean(simpleInputWithArgs('_hiddenLabel -> "theLabel")) must contain(labelString)
- }
-
- "allow render without label" in {
- simpleInputWithArgs() must not contain ("label")
- }
-
- "allow rendering errors" in {
- val test = simpleInputWithError()
- test must contain("has-error")
- test must contain("test-error-0")
- test must contain("test-error-1")
- }
-
- "allow showing constraints" in {
- val test = simpleInputWithArgs('_showConstraints -> true)
- test must contain("")
- test must contain("")
- test must contain("class=\"help-block\">" + messages("constraint.required") + "")
- test must contain("class=\"help-block\">" + messages("constraint.maxLength", 8) + "")
- }
-
- "allow showing help info" in {
- simpleInputWithArgs('_help -> "test-help") must contain("test-help")
- simpleInputWithArgs('_success -> "test-help") must contain("test-help")
- simpleInputWithArgs('_warning -> "test-help") must contain("test-help")
- simpleInputWithArgs('_error -> "test-help") must contain("test-help")
- }
-
- "allow rendering erros and hide constraints when help info is present" in {
- val test = simpleInputWithError('_showConstraints -> true, '_help -> "test-help")
- test must contain("test-error-0")
- test must contain("test-error-1")
- test must contain("test-help")
- test must not contain (" "ok"
- case "warning" => "warning-sign"
- case "error" => "remove"
- }
-
- def withFeedbackIcon(status: String) = contain(clean(s"""
-
- ($status)"""
- ))
- def testStatus(status: String, withIcon: Boolean, args: (Symbol, Any)*)(implicit fc: B3FieldConstructor) = {
- val test = clean(simpleInputWithArgs(args: _*))
- test must withStatus(status, withIcon)
- if (withIcon) {
- test must withFeedbackIcon(status)
- } else {
- test must not(withFeedbackIcon(status))
- }
- }
-
- testStatus("success", withIcon = false, '_success -> true)
- testStatus("success", withIcon = false, '_success -> "test-help")
- testStatus("warning", withIcon = false, '_warning -> true)
- testStatus("warning", withIcon = false, '_warning -> "test-help")
- testStatus("error", withIcon = false, '_error -> true)
- testStatus("error", withIcon = false, '_error -> "test-help")
-
- "with feedback icons" in {
- testStatus("success", withIcon = true, '_showIconValid -> true)
- testStatus("success", withIcon = true, '_success -> "test-help", '_showIconValid -> true)
- testStatus("warning", withIcon = true, '_showIconWarning -> true)
- testStatus("warning", withIcon = true, '_warning -> "test-help", '_showIconWarning -> true)
- testStatus("error", withIcon = true, '_error -> true, '_showIconOnError -> true)
- testStatus("error", withIcon = true, '_error -> "test-help", '_showIconOnError -> true)
- }
-
- "with automatic feedback icons" in {
- testStatus("success", withIcon = true, '_success -> "test-help")(fcWithFeedbackIcons)
- testStatus("warning", withIcon = true, '_warning -> "test-help")(fcWithFeedbackIcons)
- testStatus("error", withIcon = true, '_error -> true)(fcWithFeedbackIcons)
- testStatus("error", withIcon = true, '_error -> "test-help")(fcWithFeedbackIcons)
- }
- }
-
- "render aria attributes" in {
- val test0 = simpleInputWithArgs()
- test0 must not contain ("aria-invalid")
- test0 must not contain ("aria-describedby")
- test0 must not contain (" true, '_showIconOnError -> true)
- test1 must contain("aria-invalid=\"true\"")
- test1 must contain("aria-describedby=\"foo_status foo_info_0 foo_info_1 foo_error_0 foo_error_1\"")
- test1 must contain(" "test-help", '_showIconValid -> true)
- test2 must not contain ("aria-invalid")
- test2 must contain("aria-describedby=\"foo_status foo_info_0\"")
- test2 must contain(" Forms.text))("foo"), '_label -> "theLabel").body
- body must contain(colLabel)
- body must contain(colInput)
- }
- }
-
- "vertical field constructor" should {
- implicit val verticalFieldConstructor = new b3.vertical.VerticalFieldConstructor()
- val fcWithFeedbackIcons = new b3.vertical.VerticalFieldConstructor(withFeedbackIcons = true)
- testFielConstructor(verticalFieldConstructor, fcWithFeedbackIcons)
- }
-
- "inline field constructor" should {
- implicit val inlineFieldConstructor = new b3.inline.InlineFieldConstructor()
- val fcWithFeedbackIcons = new b3.inline.InlineFieldConstructor(withFeedbackIcons = true)
- testFielConstructor(inlineFieldConstructor, fcWithFeedbackIcons)
- }
-
- "clear field constructor" should {
- implicit val clearFieldConstructor = b3.clear.fieldConstructor()
-
- "simply render the input" in {
- val simpleInput = b3.text(Form(single("foo" -> Forms.text))("foo")).body.trim
- simpleInput must startWith("")
- // Make sure it doesn't have it twice
- simpleInput.substring(simpleInput.indexOf(">") + 1) must not contain (">")
- }
- }
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/test/FormsSpec.scala b/play25-bootstrap3/module/test/FormsSpec.scala
deleted file mode 100644
index 173dac5..0000000
--- a/play25-bootstrap3/module/test/FormsSpec.scala
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b3
-
-import views.html.b3
-import TestUtils._
-import org.specs2.mutable.Specification
-import play.api.data.Forms._
-import play.api.data._
-import play.api.{ Configuration, Environment }
-import play.api.i18n.{ DefaultLangs, DefaultMessagesApi }
-import play.twirl.api.Html
-import play.api.mvc.Call
-
-object FormsSpec extends Specification {
-
- val messagesApi = new DefaultMessagesApi(Environment.simple(), Configuration.reference, new DefaultLangs(Configuration.reference))
- implicit val messages = messagesApi.preferred(Seq.empty)
-
- val vfc = b3.vertical.fieldConstructor()
- val (colLabel, colInput) = ("col-md-2", "col-md-10")
- val hfc = b3.horizontal.fieldConstructor(colLabel, colInput)
- val ifc = b3.inline.fieldConstructor()
- val cfc = b3.clear.fieldConstructor()
-
- val testContentString = ""
-
- val (method, action) = ("POST", "/handleRequest")
- val fooCall = Call(method, action)
- def fooFormBody(args: (Symbol, Any)*)(fc: b3.B3FieldConstructor) = b3.form(fooCall, args: _*)(Html(testContentString))(fc).body
-
- "@form" should {
-
- val simple = fooFormBody()(vfc)
-
- "have action and method" in {
- simple must contain("action=\"" + action + "\"")
- simple must contain("method=\"" + method + "\"")
- }
-
- "add default class for each field constructor" in {
- fooFormBody()(vfc) must contain("class=\"form-vertical")
- fooFormBody()(hfc) must contain("class=\"form-horizontal")
- fooFormBody()(ifc) must contain("class=\"form-inline")
- fooFormBody()(cfc) must contain("class=\"form-clear")
- }
-
- "allow setting custom class" in {
- fooFormBody('class -> "customClass")(vfc) must contain("class=\"form-vertical customClass\"")
- }
-
- "add form role as default" in {
- simple must contain("role=\"form\"")
- }
-
- "allow setting extra arguments and remove those arguments with false values or with underscored names" in {
- val body = fooFormBody('extra_attr -> "test", 'true_attr -> true, 'fase_attr -> false, '_underscored_attr -> "test")(vfc)
- body must contain("extra_attr=\"test\"")
- body must contain("true_attr=\"true\"")
- body must not contain ("false_attr=\"false\"")
- body must not contain ("_underscored_attr=\"test\"")
- }
-
- "render the content body" in {
- simple must contain("")
- }
- }
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/test/HelpersSpec.scala b/play25-bootstrap3/module/test/HelpersSpec.scala
deleted file mode 100644
index faf3955..0000000
--- a/play25-bootstrap3/module/test/HelpersSpec.scala
+++ /dev/null
@@ -1,735 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b3
-
-import views.html.b3
-import TestUtils._
-import org.specs2.mutable.Specification
-import views.html.helper._
-import play.api.data.Forms._
-import play.api.data._
-import play.api.{ Configuration, Environment }
-import play.api.i18n.{ DefaultLangs, DefaultMessagesApi, Messages }
-import play.twirl.api.{ Html, HtmlFormat }
-import play.api.mvc.Call
-
-object HelpersSpec extends Specification {
-
- val messagesApi = new DefaultMessagesApi(Environment.simple(), Configuration.reference, new DefaultLangs(Configuration.reference))
- implicit val messages = messagesApi.preferred(Seq.empty)
-
- val vfc = b3.vertical.fieldConstructor()
- val (colLabel, colInput) = ("col-md-2", "col-md-10")
- val hfc = b3.horizontal.fieldConstructor(colLabel, colInput)
- val ifc = b3.inline.fieldConstructor()
- val cfc = b3.clear.fieldConstructor()
-
- /**
- * A test field constructor that simply renders the input
- */
- implicit val testFieldConstructor = new B3FieldConstructor {
- val formClass = ""
- val withFeedbackIcons = false
- def apply(fieldInfo: B3FieldInfo, inputHtml: Html)(implicit messages: Messages) = inputHtml
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages) = contentHtml
- }
-
- val fooField = Form(single("foo" -> Forms.text))("foo")
- def fooFieldFilled(v: String) = Form(single("foo" -> Forms.text)).fill(v)("foo")
-
- "@inputType" should {
-
- "allow setting a custom id" in {
- val body = b3.inputType("text", fooField, 'id -> "someid").body
- val idAttr = "id=\"someid\""
- body must contain(idAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(idAttr) + idAttr.length) must not contain (idAttr)
- }
-
- "allow setting a custom type" in {
- val body = b3.inputType("email", fooField).body
- val typeAttr = "type=\"email\""
- body must contain(typeAttr)
- // Make sure it doesn't contain it twice
- body.substring(body.indexOf(typeAttr) + typeAttr.length) must not contain (typeAttr)
- }
-
- "add form-control class as default" in {
- b3.inputType("text", fooField).body must contain("class=\"form-control\"")
- }
-
- "allow setting additional classes" in {
- b3.inputType("text", fooField, 'class -> "extra_class").body must contain("class=\"form-control extra_class\"")
- }
-
- "allow setting a default value" in {
- val body = b3.inputType("text", fooField, 'value -> "defaultvalue").body
- val valueAttr = "value=\"defaultvalue\""
- body must contain(valueAttr)
- // Make sure it doesn't contain it twice
- body.substring(body.indexOf(valueAttr) + valueAttr.length) must not contain (valueAttr)
- }
-
- "allow being filled with a value" in {
- val body = b3.inputType("text", fooFieldFilled("filledvalue"), 'value -> "defaultvalue").body
- val valueAttr = "value=\"filledvalue\""
- body must contain(valueAttr)
- // Make sure it doesn't contain it twice
- body.substring(body.indexOf(valueAttr) + valueAttr.length) must not contain (valueAttr)
- // Make sure it doesn't contain the default value
- body must not contain ("value=\"defaultvalue\"")
- }
-
- "allow setting extra arguments and remove those arguments with false values or with underscored names" in {
- val body = b3.inputType("text", fooField, 'extra_attr -> "test", 'true_attr -> true, 'fase_attr -> false, '_underscored_attr -> "test").body
- body must contain("extra_attr=\"test\"")
- body must contain("true_attr=\"true\"")
- body must not contain ("false_attr=\"false\"")
- body must not contain ("_underscored_attr=\"test\"")
- }
- }
-
- val sampleArgs = Seq[(Symbol, Any)]('id -> "someid", 'foo -> "fooValue")
- def sampleInputTypeBody(theType: String) = b3.inputType(theType, fooField, sampleArgs: _*).body.trim
-
- "@text" should {
- "be equivalent to inputType with text type" in {
- b3.text(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("text")
- }
- }
- "@password" should {
- "be equivalent to inputType with password type" in {
- b3.password(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("password")
- }
- "not display its value" in {
- b3.password(fooFieldFilled("barValue"), sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("password")
- }
- }
- "@file" should {
- "be equivalent to inputType with file type" in {
- b3.file(fooField, (('class -> "form-control") +: sampleArgs): _*).body.trim must be equalTo sampleInputTypeBody("file")
- }
- }
-
- "@textarea" should {
-
- "allow setting a custom id" in {
- val body = b3.textarea(fooField, 'id -> "someid").body
- val idAttr = "id=\"someid\""
- body must contain(idAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(idAttr) + idAttr.length) must not contain (idAttr)
- }
-
- "add form-control class as default" in {
- b3.textarea(fooField).body must contain("class=\"form-control\"")
- }
-
- "allow setting additional classes" in {
- b3.textarea(fooField, 'class -> "extra_class").body must contain("class=\"form-control extra_class\"")
- }
-
- "allow setting a default value" in {
- val body = b3.textarea(fooField, 'value -> "defaultvalue").body
- body must contain(">defaultvalue")
- body must not contain ("value=\"defaultvalue\"")
- }
- }
-
- "@checkbox" should {
-
- val boolField = Form(single("foo" -> Forms.boolean))("foo")
- def boolFieldFilled(v: Boolean) = Form(single("foo" -> Forms.boolean)).fill(v)("foo")
- def stringFieldFilled(v: String) = Form(single("foo" -> Forms.text)).fill(v)("foo")
-
- "allow setting a custom id" in {
- val body = b3.checkbox(boolField, 'id -> "someid").body
- val idAttr = "id=\"someid\""
- body must contain(idAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(idAttr) + idAttr.length) must not contain (idAttr)
- }
-
- "be unchecked by default" in {
- val body = b3.checkbox(boolField).body
- body must not contain ("checked")
- body must contain("value=\"true\"")
- }
-
- "allow setting a default custom value" in {
- val body = b3.checkbox(boolField, 'value -> "bar").body
- body must not contain ("checked")
- body must contain("value=\"bar\"")
- }
-
- "allow setting a default value for checked attribute" in {
- val body = b3.checkbox(boolField, '_default -> true).body
- body must contain("checked")
- body must contain("value=\"true\"")
- }
-
- "allow setting a default value for checked attribute with a custom value" in {
- val body = b3.checkbox(boolField, 'value -> "bar", '_default -> true).body
- body must contain("checked")
- body must contain("value=\"bar\"")
- }
-
- "allow being filled with a value" in {
- val body = b3.checkbox(boolFieldFilled(true)).body
- body must contain("checked")
- body must contain("value=\"true\"")
- }
-
- "allow being filled with a custom value" in {
- val body = b3.checkbox(stringFieldFilled("bar"), 'value -> "bar").body
- body must contain("checked")
- body must contain("value=\"bar\"")
- }
-
- "ignore default checked value if it is filled" in {
- val body1 = b3.checkbox(boolFieldFilled(false), '_default -> true).body
- body1 must not contain ("checked")
- body1 must contain("value=\"true\"")
- val body2 = b3.checkbox(stringFieldFilled(""), 'value -> "bar", '_default -> true).body
- body2 must not contain ("checked")
- body2 must contain("value=\"bar\"")
- }
-
- "allow setting a forced value for checked attribute (always true)" in {
- val body = b3.checkbox(boolField, 'checked -> true).body
- body must contain("checked")
- body must contain("value=\"true\"")
- }
- "allow setting a forced value for checked attribute (always false)" in {
- val body = b3.checkbox(boolField, 'checked -> false).body
- body must not contain ("checked")
- body must contain("value=\"true\"")
- }
-
- "add support to readonly attribute" in {
- val bodyWithoutReadonly = b3.checkbox(boolField, 'value -> true).body
- bodyWithoutReadonly must contain("
false, 'value -> true).body
- bodyReadonlyFalse must contain("")
-
- val bodyReadonlyTrue = b3.checkbox(boolField, 'readonly -> true, 'value -> true).body
- bodyReadonlyTrue must contain("
")
- bodyReadonlyTrue must contain("disabled=\"true\"")
- bodyReadonlyTrue must contain("")
- }
- }
-
- "@radio" should {
-
- val fruits = Seq("A" -> "Apples", "P" -> "Pears", "B" -> "Bananas")
-
- "allow setting a custom id" in {
- val body = b3.radio(fooField, fruits, 'id -> "someid").body
- body must contain("id=\"someid_A\"")
- body must contain("id=\"someid_P\"")
- body must contain("id=\"someid_B\"")
- }
-
- "be unchecked by default" in {
- b3.radio(fooField, fruits).body must not contain ("checked")
- }
-
- "allow setting a default value" in {
- val body = b3.radio(fooField, fruits, 'value -> "B").body
- val checkedAttr = "checked"
- body must contain(checkedAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(checkedAttr) + checkedAttr.length) must not contain (checkedAttr)
- }
-
- "allow being filled with a value" in {
- val body = b3.radio(fooFieldFilled("B"), fruits).body
- val checkedAttr = "checked"
- body must contain(checkedAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(checkedAttr) + checkedAttr.length) must not contain (checkedAttr)
- }
-
- "not be inline by default" in {
- b3.radio(fooField, fruits).body must not contain ("radio-inline")
- }
-
- "allow be inline" in {
- b3.radio(fooField, fruits, '_inline -> true).body must contain("radio-inline")
- }
-
- "add support to readonly attribute" in {
- val bodyWithoutReadonly = b3.radio(fooField, fruits, 'value -> "B").body
- bodyWithoutReadonly must not contain ("radio-group")
- bodyWithoutReadonly must not contain ("disabled")
- bodyWithoutReadonly must not contain (" false, 'value -> "B").body
- bodyReadonlyFalse must contain("
")
- bodyReadonlyFalse must not contain ("disabled=\"true\"")
- bodyReadonlyFalse must contain("")
-
- val bodyReadonlyTrue = b3.radio(fooField, fruits, 'readonly -> true, 'value -> "B").body
- bodyReadonlyTrue must contain("
")
- bodyReadonlyTrue must contain("disabled=\"true\"")
- bodyReadonlyTrue must contain("
")
- }
- }
-
- "@select" should {
-
- val fruits = Seq("A" -> "Apples", "P" -> "Pears", "B" -> "Bananas")
-
- "allow setting a custom id" in {
- val body = b3.select(fooField, fruits, 'id -> "someid").body
- body must contain("id=\"someid\"")
- }
-
- "add form-control class as default" in {
- b3.select(fooField, fruits).body must contain("class=\"form-control\"")
- }
-
- "allow setting additional classes" in {
- b3.select(fooField, fruits, 'class -> "extra_class").body must contain("class=\"form-control extra_class\"")
- }
-
- "be unselected by default" in {
- b3.select(fooField, fruits).body must not contain ("selected")
- }
-
- "allow setting a default value" in {
- val body = b3.select(fooField, fruits, 'value -> "B").body
- val selectedAttr = "selected"
- body must contain(selectedAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(selectedAttr) + selectedAttr.length) must not contain (selectedAttr)
- }
-
- "allow being filled with a value" in {
- val body = b3.select(fooFieldFilled("B"), fruits).body
- val selectedAttr = "selected"
- body must contain(selectedAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(selectedAttr) + selectedAttr.length) must not contain (selectedAttr)
- }
-
- "add support to readonly attribute" in {
- val bodyWithoutReadonly = b3.select(fooField, fruits, 'value -> "B").body
- bodyWithoutReadonly must not contain ("
")
- bodyWithoutReadonly must not contain ("disabled")
- bodyWithoutReadonly must not contain (" false, 'value -> "B").body
- bodyReadonlyFalse must contain("
")
- bodyReadonlyFalse must not contain ("disabled=\"true\"")
- bodyReadonlyFalse must contain("")
-
- val bodyReadonlyTrue = b3.select(fooField, fruits, 'readonly -> true, 'value -> "B").body
- bodyReadonlyTrue must contain("
")
- bodyReadonlyTrue must contain("disabled=\"true\"")
- bodyReadonlyTrue must contain("")
- }
-
- "allow multiple" in {
- val body = b3.select(fooField, fruits, 'multiple -> true, 'value -> "P,B").body
- body must contain("multiple=\"true\"")
- val selectedAttr = "selected"
- body must contain(selectedAttr)
- // Make sure it has it twice, but not more.
- val restBody = body.substring(body.indexOf(selectedAttr) + selectedAttr.length)
- restBody must contain(selectedAttr)
- restBody.substring(restBody.indexOf(selectedAttr) + selectedAttr.length) must not contain (selectedAttr)
- }
- }
-
- "@hidden" should {
- "be rendered correctly" in {
- val body = clean(b3.hidden("testName", "testValue", 'foo -> "bar").body)
- body must be equalTo """"""
- }
- "with Field object" in {
- val body = clean(b3.hidden(fooField, 'value -> "testValue", 'foo -> "bar").body)
- body must be equalTo """"""
- }
- "with filled Field object" in {
- val body = clean(b3.hidden(fooFieldFilled("filledValue"), 'value -> "testValue", 'foo -> "bar").body)
- body must be equalTo """"""
- }
- }
- "@hiddens" should {
- "be rendered correctly" in {
- val body = clean(b3.hiddens("fooId" -> 1L, "barId" -> 2L).body)
- body must be equalTo """"""
- }
- }
-
- "@color" should {
- "be equivalent to inputType with date type" in {
- b3.color(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("color")
- }
- }
- "@date" should {
- "be equivalent to inputType with date type" in {
- b3.date(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("date")
- }
- }
- "@datetime" should {
- "be equivalent to inputType with date type" in {
- b3.datetime(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("datetime")
- }
- }
- "@datetimeLocal" should {
- "be equivalent to inputType with date type" in {
- b3.datetimeLocal(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("datetime-local")
- }
- }
- "@email" should {
- "be equivalent to inputType with email type" in {
- b3.email(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("email")
- }
- }
- "@month" should {
- "be equivalent to inputType with date type" in {
- b3.month(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("month")
- }
- }
- "@number" should {
- "be equivalent to inputType with date type" in {
- b3.number(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("number")
- }
- }
- "@range" should {
- "be equivalent to inputType with date type" in {
- b3.range(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("range")
- }
- }
- "@search" should {
- "be equivalent to inputType with date type" in {
- b3.search(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("search")
- }
- }
- "@tel" should {
- "be equivalent to inputType with date type" in {
- b3.tel(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("tel")
- }
- }
- "@time" should {
- "be equivalent to inputType with date type" in {
- b3.time(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("time")
- }
- }
- "@url" should {
- "be equivalent to inputType with date type" in {
- b3.url(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("url")
- }
- }
- "@week" should {
- "be equivalent to inputType with date type" in {
- b3.week(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("week")
- }
- }
-
- "@formGroup" should {
-
- def testFormGroup(args: (Symbol, Any)*)(fc: b3.B3FieldConstructor, msgs: Messages) =
- clean(b3.freeFormGroup(args)(innerArgs => Html(""))(fc, msgs).body)
-
- "vertical: show label" in {
- testFormGroup('_class -> "theClass", '_id -> "theId", '_label -> "theLabel")(vfc, messages) must be equalTo clean("""
-
-
-
-
- """)
- }
- "vertical: without label" in {
- testFormGroup('_class -> "theClass", '_id -> "theId")(vfc, messages) must be equalTo clean("""
-
-
-
- """)
- }
- "horizontal: show label" in {
- testFormGroup('_class -> "theClass", '_id -> "theId", '_label -> "theLabel")(hfc, messages) must be equalTo clean("""
-
-
-
-
-
-
- """)
- }
- "horizontal: without label" in {
- testFormGroup('_class -> "theClass", '_id -> "theId")(hfc, messages) must be equalTo clean("""
-
-
-
-
-
- """)
- }
- "inline: show label" in {
- testFormGroup('_class -> "theClass", '_id -> "theId", '_label -> "theLabel")(ifc, messages) must be equalTo clean("""
-
-
-
-
- """)
- }
- "inline: without label" in {
- testFormGroup('_class -> "theClass", '_id -> "theId")(ifc, messages) must be equalTo clean("""
-
-
-
- """)
- }
-
- "get the inner arguments for the content" in {
- val body = b3.freeFormGroup(Seq('_class -> "theClass", '_underscored -> "underscored", 'foo -> "foo"))(innerArgsMap => Html(innerArgsMap.toSeq.map(a => s"""${a._1.name}="${a._2.toString}"""").mkString("")))(vfc, messages).body
- body must not contain "_class=\"theClass\""
- body must not contain "_underscored=\"underscored\""
- body must contain("foo=\"foo\"")
- }
- }
-
- "@free" should {
- "be rendered correctly" in {
- clean(b3.free('foo -> "fooValue")(Html(""))(vfc, messages).body) must be equalTo clean(b3.freeFormGroup(Seq('foo -> "fooValue"))(_ => Html(""))(vfc, messages).body)
- }
- }
-
- "@static" should {
-
- "render with form-control-static class as default" in {
- b3.static("theLabel")(Html("theText"))(vfc, messages).body must contain("
theText
")
- }
-
- "allow setting additional classes" in {
- b3.static("theLabel", 'class -> "extra_class")(Html("theText"))(vfc, messages).body must contain("
theText
")
- }
-
- "allow setting extra arguments and remove those arguments with false values or with underscored names" in {
- val body = b3.static("theLabel", 'extra_attr -> "test", 'true_attr -> true, 'fase_attr -> false, '_underscored_attr -> "test")(Html("theText"))(vfc, messages).body
- body must contain("extra_attr=\"test\"")
- body must contain("true_attr=\"true\"")
- body must not contain ("false_attr=\"false\"")
- body must not contain ("_underscored_attr=\"test\"")
- }
- }
-
- "@buttonType" should {
-
- val sampleType = "myButtonType"
- val sampleContent = "sample-content"
- def buttonTypeBody(args: (Symbol, Any)*) = b3.buttonType(sampleType, args: _*)(Html(sampleContent))(vfc, messages).body
-
- "allow setting a custom type" in {
- val body = buttonTypeBody()
- val typeAttr = "type=\"" + sampleType + "\""
- body must contain(typeAttr)
- // Make sure it doesn't contain it twice
- body.substring(body.indexOf(typeAttr) + typeAttr.length) must not contain (typeAttr)
- }
- "render content" in {
- buttonTypeBody() must contain(sampleContent)
- }
-
- "allow setting extra arguments and remove those arguments with false values or with underscored names" in {
- val body = buttonTypeBody('extra_attr -> "test", 'true_attr -> true, 'fase_attr -> false, '_underscored_attr -> "test")
- body must contain("extra_attr=\"test\"")
- body must contain("true_attr=\"true\"")
- body must not contain ("false_attr=\"false\"")
- body must not contain ("_underscored_attr=\"test\"")
- }
-
- "be rendered correctly" in {
- val body = buttonTypeBody('id -> "someid", 'class -> "btn btn-default")
- body must contain("")
- }
- }
-
- def sampleButtonTypeBody(theType: String) = b3.buttonType(theType, sampleArgs: _*)(Html("content"))(vfc, messages).body.trim
-
- "@submit" should {
- "be equivalent to buttonType with submit type" in {
- b3.submit(sampleArgs: _*)(Html("content"))(vfc, messages).body.trim must be equalTo sampleButtonTypeBody("submit")
- }
- }
- "@reset" should {
- "be equivalent to buttonType with reset type" in {
- b3.reset(sampleArgs: _*)(Html("content"))(vfc, messages).body.trim must be equalTo sampleButtonTypeBody("reset")
- }
- }
- "@button" should {
- "be equivalent to buttonType with button type" in {
- b3.button(sampleArgs: _*)(Html("content"))(vfc, messages).body.trim must be equalTo sampleButtonTypeBody("button")
- }
- }
-
- "@inputWrapped" should {
-
- "be equivalent to inputType for an empty wrapper" in {
- val bodyInputType = clean(b3.inputType("text", fooField, 'id -> "someid").body)
- val body = clean(b3.inputWrapped("text", fooField, 'id -> "someid")(x => x).body)
- body must be equalTo bodyInputType
- }
-
- "wrap the input" in {
- val bodyInputType = clean(b3.inputType("text", fooField, 'id -> "someid").body)
- val (wrapperPre, wrapperPost) = ("", "")
- def wrap(input: Html) = HtmlFormat.fill(scala.collection.immutable.Seq(Html(wrapperPre), input, Html(wrapperPost)))
- val body = clean(b3.inputWrapped("text", fooField, 'id -> "someid")(input => wrap(input)).body)
-
- val (indexOfWrapperPre, indexOfWrapperPost) = (body.indexOf(wrapperPre), body.indexOf(wrapperPost))
-
- body.substring(0, indexOfWrapperPre) must be equalTo bodyInputType.substring(0, indexOfWrapperPre)
- body.substring(indexOfWrapperPre, indexOfWrapperPre + wrapperPre.length) must be equalTo wrapperPre
- body.substring(indexOfWrapperPre + wrapperPre.length, indexOfWrapperPost) must be equalTo bodyInputType.substring(indexOfWrapperPre, indexOfWrapperPost - wrapperPre.length)
- body.substring(indexOfWrapperPost, indexOfWrapperPost + wrapperPost.length) must be equalTo wrapperPost
- body.substring(indexOfWrapperPost + wrapperPost.length) must be equalTo bodyInputType.substring(indexOfWrapperPost - wrapperPre.length)
- }
- }
-
- "@multifield" should {
-
- val testInputsString = ""
- val fooForm = Form(tuple("foo" -> Forms.nonEmptyText, "bar" -> Forms.nonEmptyText))
- val fooFormWithError = fooForm.withError("foo", "test-error")
-
- def multifield(form: Form[(String, String)], globalArgs: Seq[(Symbol, Any)] = Seq(), fieldsArgs: Seq[(Symbol, Any)] = Seq())(fc: b3.B3FieldConstructor, messages: Messages) =
- clean(b3.multifield(form("foo"), form("bar"))(globalArgs, fieldsArgs)(cfc => Html(testInputsString))(fc, messages).body)
- def fooMultifield(globalArgs: (Symbol, Any)*) = multifield(fooForm, globalArgs)(vfc, messages)
- def fooMultifieldWithFielsArgs(fieldsArgs: (Symbol, Any)*) = multifield(fooForm, fieldsArgs = fieldsArgs)(vfc, messages)
-
- "have the basic structure" in {
- val body = fooMultifield('_label -> "theLabel")
- body must contain("class=\"form-group")
- body must not contain ("has-error")
- body must contain("")
- body must contain(testInputsString)
- body must not contain ("class=\"help-block\"")
- }
-
- "behave as a horizontal field constructor" in {
- val body = multifield(fooForm, Seq('_label -> "theLabel"))(hfc, messages)
- body must contain("")
- body must contain("
")
- }
-
- "allow setting a custom id" in {
- fooMultifield('_id -> "customid") must contain("id=\"customid\"")
- }
-
- "allow setting extra classes form-group" in {
- fooMultifield('_class -> "extra_class another_class") must contain("class=\"form-group extra_class another_class")
- }
-
- "show label" in {
- multifield(fooForm, Seq('_label -> "fooLabel"))(vfc, messages) must contain("")
- multifield(fooForm, Seq('_label -> "fooLabel"))(hfc, messages) must contain("")
- }
-
- "without label" in {
- multifield(fooForm)(vfc, messages) must not contain ("label")
- multifield(fooForm)(hfc, messages) must not contain ("label")
- }
-
- "allow rendering errors" in {
- val body = multifield(fooFormWithError)(vfc, messages)
- body must contain("has-error")
- body must contain("test-error")
- }
-
- "allow showing constraints" in {
- multifield(fooForm, fieldsArgs = Seq('_showConstraints -> true))(vfc, messages) must contain("" + messages("constraint.required") + "")
- }
-
- "allow showing help info" in {
- fooMultifield('_help -> "test-help") must contain("""test-help""")
- fooMultifield('_success -> "test-help") must contain("""test-help""")
- fooMultifieldWithFielsArgs('_success -> "test-help") must contain("""test-help""")
- fooMultifield('_warning -> "test-help") must contain("""test-help""")
- fooMultifieldWithFielsArgs('_warning -> "test-help") must contain("""test-help""")
- fooMultifield('_error -> "test-help") must contain("""test-help""")
- fooMultifieldWithFielsArgs('_error -> "test-help") must contain("""test-help""")
- }
-
- "render validation states" in {
- def withStatus(status: String, withFeedback: Boolean) = contain(s"""
"ok"
- case "warning" => "warning-sign"
- case "error" => "remove"
- }
-
- def withFeedbackIcon(status: String) = contain(clean(s"""
-
- ($status)"""
- ))
- def testStatus(status: String, withIcon: Boolean, withFieldsArgs: Boolean, args: (Symbol, Any)*) = {
- val test = if (withFieldsArgs)
- clean(b3.multifield(fooForm("foo"))(globalArgs = if (withIcon) Seq('_hasFeedback -> true) else Seq(), fieldsArgs = args)(cfc => b3.text(fooForm("foo"), args: _*))(vfc, messages).body)
- else
- clean(b3.multifield(fooForm("foo"))(globalArgs = if (withIcon) (('_hasFeedback -> true) +: args) else args, fieldsArgs = Seq())(cfc => b3.text(fooForm("foo"), args: _*))(vfc, messages).body)
- test must withStatus(status, withIcon)
- if (withIcon) {
- test must withFeedbackIcon(status)
- } else {
- test must not(withFeedbackIcon(status))
- }
- }
-
- testStatus("success", withIcon = false, withFieldsArgs = false, '_success -> true)
- testStatus("success", withIcon = false, withFieldsArgs = true, '_success -> true)
- testStatus("success", withIcon = false, withFieldsArgs = false, '_success -> "test-help")
- testStatus("success", withIcon = false, withFieldsArgs = true, '_success -> "test-help")
- testStatus("warning", withIcon = false, withFieldsArgs = false, '_warning -> true)
- testStatus("warning", withIcon = false, withFieldsArgs = true, '_warning -> true)
- testStatus("warning", withIcon = false, withFieldsArgs = false, '_warning -> "test-help")
- testStatus("warning", withIcon = false, withFieldsArgs = true, '_warning -> "test-help")
- testStatus("error", withIcon = false, withFieldsArgs = false, '_error -> true)
- testStatus("error", withIcon = false, withFieldsArgs = true, '_error -> true)
- testStatus("error", withIcon = false, withFieldsArgs = false, '_error -> "test-help")
- testStatus("error", withIcon = false, withFieldsArgs = true, '_error -> "test-help")
-
- "with feedback icons" in {
- testStatus("success", withIcon = true, withFieldsArgs = false, '_showIconValid -> true)
- testStatus("success", withIcon = true, withFieldsArgs = true, '_showIconValid -> true)
- testStatus("success", withIcon = true, withFieldsArgs = false, '_success -> "test-help", '_showIconValid -> true)
- testStatus("success", withIcon = true, withFieldsArgs = true, '_success -> "test-help", '_showIconValid -> true)
- testStatus("warning", withIcon = true, withFieldsArgs = false, '_showIconWarning -> true)
- testStatus("warning", withIcon = true, withFieldsArgs = true, '_showIconWarning -> true)
- testStatus("warning", withIcon = true, withFieldsArgs = false, '_warning -> "test-help", '_showIconWarning -> true)
- testStatus("warning", withIcon = true, withFieldsArgs = true, '_warning -> "test-help", '_showIconWarning -> true)
- testStatus("error", withIcon = true, withFieldsArgs = false, '_error -> true, '_showIconOnError -> true)
- testStatus("error", withIcon = true, withFieldsArgs = true, '_error -> true, '_showIconOnError -> true)
- testStatus("error", withIcon = true, withFieldsArgs = false, '_error -> "test-help", '_showIconOnError -> true)
- testStatus("error", withIcon = true, withFieldsArgs = true, '_error -> "test-help", '_showIconOnError -> true)
- }
- }
-
- }
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/module/test/TestUtils.scala b/play25-bootstrap3/module/test/TestUtils.scala
deleted file mode 100644
index f189d89..0000000
--- a/play25-bootstrap3/module/test/TestUtils.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b3
-
-object TestUtils {
-
- // clean a string removing control characters and extra whitespaces to compare equivalent rendered codes
- def clean(str: String) = str.filter(_ >= ' ').replaceAll("\\s+", " ").trim.replaceAll(">\\s+<", "><").replaceAll("\\s+\"", "\"").replaceAll("=\"\\s+", "=\"")
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/Filters.scala b/play25-bootstrap3/sample/app/Filters.scala
deleted file mode 100644
index 578e98d..0000000
--- a/play25-bootstrap3/sample/app/Filters.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-import play.api.http.HttpFilters
-import play.filters.csrf.CSRFFilter
-import javax.inject.Inject
-
-class Filters @Inject() (csrfFilter: CSRFFilter) extends HttpFilters {
- def filters = Seq(csrfFilter)
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/assets/javascripts/main.coffee b/play25-bootstrap3/sample/app/assets/javascripts/main.coffee
deleted file mode 100644
index 7a9c2a7..0000000
--- a/play25-bootstrap3/sample/app/assets/javascripts/main.coffee
+++ /dev/null
@@ -1,104 +0,0 @@
-
-############################################################################################################
-## Smoth scroll for docs
-
-scrollWithAnimation = ($id, duration) ->
- $('html,body').animate({scrollTop: $id.offset().top - 55}, duration)
-
-############################################################################################################
-## For readonly example
-
-disableForm = ($form) ->
- $formGroups = $form.find('.form-group:not(.always-editable)')
- $formGroups.find('input:not([type="file"], [type="checkbox"], [type="radio"], [type="hidden"])').removeAttr('disabled').attr('readonly', true)
- $formGroups.find('input[type="file"], input[type="checkbox"], input[type="radio"], select').attr('disabled', true)
- $formGroups.find('.checkbox, .radio, .radio-inline').addClass('disabled')
- $formGroups.find('.checkbox-group, .radio-group, .select-group').find('input[type="hidden"]').removeAttr('disabled readonly')
-
-enableForm = ($form) ->
- $formGroups = $form.find('.form-group:not(.always-editable)')
- $formGroups.find('input:not([type="file"], [type="checkbox"], [type="radio"], [type="hidden"])').removeAttr('disabled readonly')
- $formGroups.find('input[type="file"], input[type="checkbox"], input[type="radio"], select').removeAttr('disabled readonly')
- $formGroups.find('.checkbox, .radio, .radio-inline').removeClass('disabled')
- $formGroups.find('.checkbox-group, .radio-group, .select-group').find('input[type="hidden"]').removeAttr('readonly').attr('disabled', true)
-
-############################################################################################################
-## DOCUMENT IS READY - INIT APP
-############################################################################################################
-$ ->
-
- ## For readonly example
- $('.btn-readonly-unlock').click (e) ->
- if $(this).hasClass('locked')
- $(this).removeClass('locked btn-primary').addClass('btn-danger').text('Lock readonly fields')
- enableForm($('#form-readonly'))
- else
- $(this).removeClass('btn-danger').addClass('locked btn-primary').text('Unlock readonly fields')
- disableForm($('#form-readonly'))
- if /\/readonly\/?\?\w/.test(window.location.href)
- params = window.location.href.split('?')[1].split('&')
- params = (p.split('=') for p in params)
- getParam = (name, params) ->
- foundParams = (p for p in params when p[0] == name)
- if foundParams.length > 0 then foundParams[0][1] else undefined
- text = getParam "text", params
- checkbox = getParam "checkbox", params
- radio = getParam "radio", params
- select = getParam "select", params
- if text? or checkbox? or radio? or select?
- $data = $('#bound-data')
- $data.find('#data-text').text text
- $data.find('#data-checkbox').text checkbox
- $data.find('#data-radio').text radio
- $data.find('#data-select').text select
- $data.removeAttr('hidden')
-
- # Change also the value of its companion input
- $('.checkbox-group input[type="checkbox"]').change ->
- $(this).parents('.checkbox-group').find('input[type="hidden"]').val $(this).prop('checked')
- $('.radio-group input[type="radio"]').change ->
- $radioGroup = $(this).parents('.radio-group')
- $radioGroup.find('input[type="hidden"]').val $radioGroup.find('input[type="radio"]:checked').val()
- $('.select-group select').change ->
- $(this).parents('.select-group').find('input[type="hidden"]').val $(this).val()
-
- $('.input-daterange').datepicker
- format: "dd-mm-yyyy"
- todayBtn: "linked"
- todayHighlight: true
-
- $('body[tab="docs"]').scrollspy
- target: '#sidebar'
- offset: 60
-
- $('a[href*="#"]:not([href="#"], [href*="#collapse"], [data-toggle])').click (e) ->
- if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname)
- target = $(this.hash)
- target = if target.length then target else $('[name=' + this.hash.slice(1) +']')
- if (target.length)
- scrollWithAnimation(target, 500)
-
- hash = location.hash
- if hash.length > 0
- scrollWithAnimation($(hash), 10)
-
-
- $('.apply-tweak').click (e) ->
- if $(this).hasClass('active')
- $('.form-inline').removeClass('align-top')
- $(this).removeClass('btn-danger').addClass('btn-info')
- else
- $('.form-inline').addClass('align-top')
- $(this).removeClass('btn-info').addClass('btn-danger')
-
-
-
- $('.input-number-plus').click (e) ->
- $input = $(this).parent().find('input')
- current = parseInt $input.val(), 10
- $input.val current+1
-
- $('.input-number-minus').click (e) ->
- $input = $(this).parent().find('input')
- current = parseInt $input.val(), 10
- $input.val current-1
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/assets/stylesheets/main.less b/play25-bootstrap3/sample/app/assets/stylesheets/main.less
deleted file mode 100644
index a791d0c..0000000
--- a/play25-bootstrap3/sample/app/assets/stylesheets/main.less
+++ /dev/null
@@ -1,286 +0,0 @@
-
-@nav-bg-color: #3264C8;
-@nav-bg-color-hover: lighten(@nav-bg-color, 5%);
-@nav-bg-color-active: lighten(@nav-bg-color, 15%);
-@nav-color: #eeeeee;
-@nav-color-hover: white;
-@nav-color-active: white;
-@bg-color: #fbfcfe;
-@footer-bg-color: lighten(@nav-bg-color, 45%);
-
-@code-bg-color: #FFFFF8;
-
-@play-color: #93D53A;
-@boostrap-color: #5C3F83;
-
-body {
- padding-top: 60px;
- background-color: @bg-color;
-}
-.navbar-mixin-active() {
- background-color: @nav-bg-color-active;
- color: @nav-color-active;
-}
-.navbar-mixin-hover() {
- background-color: @nav-bg-color-hover;
- color: white;
-}
-.navbar-default {
- background-color: @nav-bg-color;
- .navbar-brand {
- color: @nav-color;
- &:hover, &:focus {
- .navbar-mixin-hover();
- }
- &.active {
- .navbar-mixin-active();
- }
- }
- .navbar-nav {
- & > li > a {
- color: @nav-color;
- &:hover, &:focus {
- .navbar-mixin-hover();
- }
- }
- & > .active > a {
- &, &:hover, &:focus {
- .navbar-mixin-active();
- }
- }
- & > .open > a {
- &, &:hover, &:focus {
- .navbar-mixin-active();
- }
- }
- }
- .dropdown-menu {
- background-color: @nav-bg-color-active;
- & > li > a {
- color: @nav-color-active;
- &:hover {
- .navbar-mixin-hover();
- }
- }
- }
- .github a {
- padding-top: 10px;
- padding-bottom: 10px;
- }
- .version-badge .code {
- color: white;
- }
-
- a[version] {
- padding: 5px 20px;
- }
- a.legacy {
- font-style: italic;
- color: #ddd !important;
- }
-}
-.container {
- max-width: 960px;
-}
-.version-badge {
- .code {
- font-size: 1.1em;
- font-weight: bold;
- color: @nav-bg-color;
- }
- .play-bootstrap {
- & > span {
- font-size: 0.9em;
- font-weight: bold;
- border: 1px solid @boostrap-color;
- padding: 5px;
- }
- .play {
- background-color: white;
- color: @play-color;
- border-top-left-radius: 5px;
- border-bottom-left-radius: 5px;
- }
- .bootstrap {
- background-color: @boostrap-color;
- color: white;
- border-top-right-radius: 5px;
- border-bottom-right-radius: 5px;
- }
- }
- a[version] {
- padding: 5px 20px;
- }
-}
-.header-with-logo {
- & > div {
- display: inline-block;
- vertical-align: middle;
- margin-right: 15px;
- }
-}
-#github-buttons {
- margin-top: 25px;
- margin-bottom: 25px;
- position: relative;
- img {
- position: absolute;
- top: -5px;
- left: 120px;
- }
-}
-i.fa-github {
- vertical-align: middle;
-}
-.footer {
- background-color: @footer-bg-color;
- margin-top: 20px;
- padding: 20px 0;
- line-height: 15px;
-}
-
-h3, h4 { margin-top: 35px; }
-h1 + h2, h2 + h3, h3 + h4 { margin-top: 15px; }
-
-input:invalid { color: red !important; }
-.example-html5-validation input:valid { color: green !important; }
-
-.highlight {
- background-color: @code-bg-color;
-}
-pre code {
- white-space: pre;
-}
-span.def {
- color: #888;
- font-size: 0.75em;
- font-style: italic;
- margin-left: 20px;
-}
-
-.tab-pane > .bs-example {
- border-top: 0;
- border-top-left-radius: 0;
- border-top-right-radius: 0;
-}
-
-.form-inline {
- button.apply-tweak {
- width: 100%;
- border-bottom-left-radius: 0;
- border-bottom-right-radius: 0;
- }
- .tweak .highlight {
- border-top-left-radius: 0;
- border-top-right-radius: 0;
- pre code {
- color: #aaa;
- }
- }
- &.align-top {
- .form-group {
- vertical-align: top;
- }
- .tweak .highlight pre code {
- color: #d9534f;
- }
- }
-}
-
-[data-toggle="collapse"] {
- .fa.fa-caret {
- float: right;
- margin-left: 15px;
- &:before { content: "\f0d7" }
- }
- &[aria-expanded="true"] .fa.fa-caret:before { content: "\f0d8" }
-}
-
-.bs-docs-sidebar {
- .nav > .active > a, .nav > .active:hover > a, .nav > .active:focus > a, .nav > li > a:hover {
- color: @nav-bg-color;
- border-color: @nav-bg-color;
- }
-}
-.bs-docs-sidenav {
- min-width: 210px;
-}
-
-.changelog {
- h2 {
- font-size: 24px;
- }
- .lead {
- font-size: 18px;
- font-style: italic;
- }
- ul {
- list-style-type: none;
- padding-left: 20px;
- & > li {
- font-size: 15px;
- }
- }
- .panel ul { list-style-type: square; }
-}
-
-
-// For the examples:
-
-.multi-checkbox-list.inline > div {
- display: inline-block;
- margin-right: 20px;
-}
-
-.input-text-checkbox > .input-group-addon {
- .checkbox { display: inline; }
- label {
- display: inline;
- padding: 0;
- input {
- position: relative;
- margin-left: 0;
- }
- }
-}
-
-.input-daterange {
- #dateStart + .form-control-feedback { right: 395px; }
- #dateEnd + .form-control-feedback { right: 0px; }
-}
-.input-text-checkbox #foo + .form-control-feedback { right: 0px; }
-
-.input-number-plus, .input-number-minus { cursor: pointer; }
-
-.input-number {
- width: 150px;
- input {
- text-align: center;
- & + .form-control-feedback {
- right: 40px;
- }
- }
-}
-
-.my-form-group {
- white-space: nowrap;
- & > div.field-container {
- width: 50%;
- }
- & > div {
- display: inline-block;
- white-space: normal;
- vertical-align: middle;
- margin: 0;
- ul {
- padding-left: 0;
- list-style-type: none;
- }
- .help-error {
- color: #a94442
- }
- .help-info {
- color: #8a6d3b;
- }
- }
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/controllers/Application.scala b/play25-bootstrap3/sample/app/controllers/Application.scala
deleted file mode 100644
index 16aff33..0000000
--- a/play25-bootstrap3/sample/app/controllers/Application.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 controllers
-
-import javax.inject.Inject
-import play.api.i18n.{ MessagesApi, I18nSupport }
-import play.api._
-import play.api.mvc._
-import play.api.data._
-import play.api.data.Forms._
-import play.api.data.validation.Constraints._
-
-class Application @Inject() (val messagesApi: MessagesApi) extends Controller with I18nSupport {
-
- val fooForm = Form(single("foo" -> text(maxLength = 20)))
-
- val validationForm = Form(tuple(
- "username" -> nonEmptyText(maxLength = 20),
- "email" -> email,
- "age" -> number(min = 18, max = 99),
- "color" -> nonEmptyText.verifying(pattern("^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$".r))
- ))
-
- def index = Action { implicit request => Ok(views.html.index(fooForm, validationForm)) }
- def vertical = Action { implicit request => Ok(views.html.vertical(fooForm)) }
- def horizontal = Action { implicit request => Ok(views.html.horizontal(fooForm)) }
- def inline = Action { implicit request => Ok(views.html.inline(fooForm)) }
- def mixed = Action { implicit request => Ok(views.html.mixed(fooForm)) }
- def readonly = Action { implicit request => Ok(views.html.readonly(fooForm)) }
- def multifield = Action { implicit request => Ok(views.html.multifield(fooForm)) }
- def extendIt = Action { implicit request => Ok(views.html.extendIt(fooForm)) }
- def docs = Action { implicit request => Ok(views.html.docs(fooForm, validationForm)) }
-
-}
diff --git a/play25-bootstrap3/sample/app/models/Fruit.scala b/play25-bootstrap3/sample/app/models/Fruit.scala
deleted file mode 100644
index b3f2df2..0000000
--- a/play25-bootstrap3/sample/app/models/Fruit.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-package models
-
-case class Fruit(id: Long, name: String, isCitrus: Boolean)
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/utils/BSVersion.scala b/play25-bootstrap3/sample/app/utils/BSVersion.scala
deleted file mode 100644
index 63bdc96..0000000
--- a/play25-bootstrap3/sample/app/utils/BSVersion.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 utils
-
-object BSVersion {
- final val code = "1.1.2-P25-B3"
- final val library = "1.1"
- final val play = "Play 2.5"
- final val play_code = "2.5"
- final val bootstrap = "Bootstrap 3"
- final val bootstrap_code = "3"
-
- final val repositoryBase = "master/play25-bootstrap3/module"
-
- final val repository = "https://github.com/adrianhurt/play-bootstrap"
- def repositoryPath(path: String) = s"$repository/$path"
- def repositoryFile(file: String) = s"$repository/blob/$repositoryBase/$file"
- def repositoryFolder(folder: String) = s"$repository/tree/$repositoryBase/$folder"
-
- final val msgsName = "messages"
- final val msgsClass = "Messages"
- final val msgsArg = s"$msgsName: $msgsClass"
-}
diff --git a/play25-bootstrap3/sample/app/utils/SimplePrettifier.scala b/play25-bootstrap3/sample/app/utils/SimplePrettifier.scala
deleted file mode 100644
index f5b93db..0000000
--- a/play25-bootstrap3/sample/app/utils/SimplePrettifier.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 utils
-
-object SimplePrettifier {
-
- /**
- * Counts how many tabs there are at the begining of the first line and
- * removes this number of tabs at the begining of every line. After, it
- * replaces all tabs by two spaces.
- */
- def prettify(str: String): String = {
- val i = str.indexOf('\n') + 1
- var n = 0
- while (str.charAt(i + n) == '\t') n += 1
- str.replaceAll(s"\n\t{$n}", "\n").replaceAll("\t", " ").trim
- }
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/b3/datepicker.scala.html b/play25-bootstrap3/sample/app/views/b3/datepicker.scala.html
deleted file mode 100644
index 258953d..0000000
--- a/play25-bootstrap3/sample/app/views/b3/datepicker.scala.html
+++ /dev/null
@@ -1,8 +0,0 @@
-@(startField: Field, startArgs: (Symbol,Any)*)(endField: Field, endArgs: (Symbol,Any)*)(globalArgs: (Symbol,Any)*)(implicit fc: b3.B3FieldConstructor, messages: Messages)
-@b3.multifield( startField, endField )(globalArgs, startArgs ++ endArgs) { implicit cfc =>
-
- @b3.text(startField, startArgs:_*)
- to
- @b3.text(endField, endArgs:_*)
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/b3/multiCheckbox.scala.html b/play25-bootstrap3/sample/app/views/b3/multiCheckbox.scala.html
deleted file mode 100644
index 17513b8..0000000
--- a/play25-bootstrap3/sample/app/views/b3/multiCheckbox.scala.html
+++ /dev/null
@@ -1,8 +0,0 @@
-@(fieldsWithArgs: (Field, Seq[(Symbol,Any)])*)(globalArgs: (Symbol,Any)*)(implicit fc: b3.B3FieldConstructor, messages: Messages)
-@b3.multifield( fieldsWithArgs.map(_._1):_* )(globalArgs, fieldsWithArgs.map(_._2).flatten) { implicit cfc =>
-
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/b3/my/vertical/package.scala b/play25-bootstrap3/sample/app/views/b3/my/vertical/package.scala
deleted file mode 100644
index 4636ce9..0000000
--- a/play25-bootstrap3/sample/app/views/b3/my/vertical/package.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-package views.html.b3.my
-
-package object vertical {
-
- import views.html.b3._
- import play.twirl.api.Html
- import play.api.mvc.Call
- import play.api.i18n.Messages
- import views.html.helper._
-
- /**
- * Declares the class for the Vertical FieldConstructor.
- */
- class VerticalFieldConstructor(val withFeedbackIcons: Boolean = false) extends B3FieldConstructor {
- /* Define the default class of the corresponding form */
- val formClass = "form-my-vertical"
- /* Renders the corresponding template of the field constructor */
- def apply(fieldInfo: B3FieldInfo, inputHtml: Html)(implicit messages: Messages) = bsFieldConstructor(fieldInfo, inputHtml)(this, messages)
- /* Renders the corresponding template of the form group */
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages) = bsFormGroup(contentHtml, argsMap)(messages)
- }
-
- /**
- * Creates a new VerticalFieldConstructor to use for specific forms or scopes (don't use it as a default one).
- * If a default B3FieldConstructor and a specific VerticalFieldConstructor are within the same scope, the more
- * specific will be chosen.
- */
- val fieldConstructorSpecific: VerticalFieldConstructor = new VerticalFieldConstructor()
-
- /**
- * Returns it as a B3FieldConstructor to use it as default within a template
- */
- val fieldConstructor: B3FieldConstructor = fieldConstructorSpecific
-
- /**
- * **********************************************************************************************************************************
- * SHORTCUT HELPERS
- * *********************************************************************************************************************************
- */
- def form(action: Call, args: (Symbol, Any)*)(body: VerticalFieldConstructor => Html) =
- views.html.b3.form(action, args: _*)(body(fieldConstructorSpecific))(fieldConstructorSpecific)
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/b3/package.scala b/play25-bootstrap3/sample/app/views/b3/package.scala
deleted file mode 100644
index 663105c..0000000
--- a/play25-bootstrap3/sample/app/views/b3/package.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-package views.html.b4
-
-package object fc {
- /**
- * Returns it as a B4FieldConstructor to use it as default within a template
- */
- implicit val verticalFieldConstructor: B4FieldConstructor = my.vertical.fieldConstructor
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/b3/textWithCheckbox.scala.html b/play25-bootstrap3/sample/app/views/b3/textWithCheckbox.scala.html
deleted file mode 100644
index db5aebd..0000000
--- a/play25-bootstrap3/sample/app/views/b3/textWithCheckbox.scala.html
+++ /dev/null
@@ -1,9 +0,0 @@
-@(textField: Field, textArgs: (Symbol,Any)*)(checkboxField: Field, checkboxArgs: (Symbol,Any)*)(globalArgs: (Symbol,Any)*)(implicit fc: b3.B3FieldConstructor, messages: Messages)
-@b3.multifield(textField, checkboxField)(globalArgs, textArgs ++ checkboxArgs) { implicit cfc =>
-
- It renders a simple input with a specific type attribute and it adds class="form-control" by default, but you can add an extra class with 'class -> "extra_class".
-
- It is a short version of b3.inputType for type="password".
-
-
- For security reasons, this helper doesn't display the possible value the field could have (for example when the form is reloaded after a validation failure).
-
- @bsExampleWithCode {
- @b3.password( fooForm("password"), '_label -> "Password", '_help -> "With at least 8 characters" )
- }{
- @@b3.password( fooForm("password"), '_label -> "Password", '_help -> "With at least 8 characters" )
- }
-
-
-
- It renders a checkbox. It has the attribute value set to true by default,
- but you can use another one using the 'value argument.
-
-
- The special '_text argument lets you put a text after the checkbox.
-
-
- Regarding to the checked attribute, if you want to set it to true as default, use '_default -> true.
- And if you need to force its value use directly the 'checked argument.
-
-
- It supports readonly attribute adding an additional disabled one and a
- <input type="hidden">.
-
- @bsExampleWithCode {
- @b3.checkbox( fooForm("foo"), '_text -> "Remember me" )
- }{
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me" )
-
- // uses "bar" as value for the checkbox
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", 'value -> "bar" )
-
- // checked by default (if the form is filled, this value will be taken)
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", '_default -> true )
-
- // always checked (even if the form has been filled with a false)
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", 'checked -> true )
-
- // disabled -> it will NOT be sent within the POST request
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", 'disabled -> true )
-
- // readonly -> it will be sent within the POST request
- @@b3.checkbox( fooForm("foo"), '_text -> "Remember me", 'readonly -> true )
- }
-
- Note you can use any value for the _text argument.
-
- @bsExampleWithCode {
- @b3.checkbox( fooForm("foo"), '_text -> Html("""Do you want a beer? """) )
- }{
- @@b3.checkbox( fooForm("foo"), '_text -> Html("Do you want a beer? ") )
- }
-
-
-
- It renders a radio. It supports readonly attribute adding an additional disabled
- one and a <input type="hidden">.
-
-
- It has an additional special _inline argument to make it an inline radio (for vertical and horizontal forms).
-
- @bsExampleWithCode {
- @b3.radio( fooForm("foo_radio1"), options = Seq("M"->"Male","F"->"Female"), '_label -> "Radio Group" )
- }{
- @@opts = @@{ Seq("M"->"Male","F"->"Female") }
-
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group" )
-
- // an inline radio within a vertical or horizontal form
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group", '_inline -> true )
-
- // with value "F" by default (if the form is filled, this value will be taken)
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group", 'value -> "F" )
-
- // disabled -> it will NOT be sent within the POST request
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group", 'disabled -> true )
-
- // readonly -> it will be sent within the POST request
- @@b3.radio( fooForm("foo"), options = opts, '_label -> "Radio Group", 'readonly -> true )
- }
-
- Note you can use any value for the options argument.
-
- It renders a select. It supports readonly attribute adding an additional disabled
- one and a <input type="hidden">.
-
- @bsExampleWithCode {
- @b3.select( fooForm("foo"), options = fruits, '_label -> "Select" )
- @b3.select( fooForm("foo"), options = fruits, '_label -> "Disabled", 'disabled -> true )
- @b3.select( fooForm("foo"), options = fruits, '_label -> "Readonly", 'readonly -> true )
- }{
- @@fruits = @@{ Seq("A"->"Apples","P"->"Pears","B"->"Bananas") }
-
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "Select" )
-
- // disabled -> it will NOT be sent within the POST request
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "Select", 'disabled -> true )
-
- // readonly -> it will be sent within the POST request
- @@b3.select( fooForm("foo"), options = fruits, '_label -> "Select", 'readonly -> true )
- }
-
- You can add a default first value using the argument '_default with a string.
- It will add a first option to the select with an empty string value. So you could add a
- required constraint to the field to force the user to select one
- other option. In addition, this default option is always disable to avoid the user to select it,
- and if any other option is selected this default one will not appear at all.
-
- You can also render a hidden input directly with a Field as you could do with a b3.text helper, for example.
- It lets you be able to simply change a b3.text for a b3.hidden to hide it.
-
-
- It will automatically take the name of the Field and it's value if present. You can set a default value using the argument
- 'value. Finally, take into account that every "underscored" argument (with "_" as preffix) will be removed.
-
- Important note: the new HTML5 input types are not fully supported for web browsers. Those not supported by old web browsers, will behave as input type text.
-
- It renders a static control to place within your form. It takes a HTML as parameter, so you can
- render whatever you want. Actually, it is like a wrapper for a static HTML.
-
- @bsExampleWithCode {
- @b3.static("Static HTML"){ This is a link }
- }{
- @@b3.static("Static HTML"){ This is a link }
- }
-
- There are two equivalent more versions of b3.static helper: one for labels with HTML, and another one to omit the label. Note that you can also have a hidden label using '_hideLabel' argument.
-
- This is the same as b3.inputType but specifying a custom wrapper for the input tag.
- It is useful for input groups and inputs with validation states and feedback icons.
-
- This library tries to be an out-of-the-box plugin. You simply need to install the library and you can
- start to write your forms. However, although it is a very versatile library, you may have different
- necessities. Thus, let's see some examples to know how you could extend it.
-
- Sometimes you may need two or more fields within the same line in a horizontal or vertical form (for a set of
- checkboxes, a date range, ...). That is the purpose of the helper b3.multifield.
-
-
-
Let's see a couple of examples
-
-
A date range
- @bsExampleWithCode {
- @b3.datepicker( fooForm("dateStart"), 'value -> "15-11-2014" )(
- fooForm("dateEnd"), 'value -> "31-12-2014" )(
- '_label -> "Date range", "data-date-start-date" -> "10-11-2014", '_help -> "Select a date range from 10-11-2014" )
- }{
- @@b3.datepicker( fooForm("dateStart"), 'value -> "31-10-2014" )(
- fooForm("dateEnd"), 'value -> "31-12-2014" )(
- '_label -> "Date range", "data-date-start-date" -> "01-01-2014", '_help -> "Select a date range from 10-11-2014" )
- }
-
-
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/tags/bsExampleWithCode.scala.html b/play25-bootstrap3/sample/app/views/tags/bsExampleWithCode.scala.html
deleted file mode 100644
index f9cebc8..0000000
--- a/play25-bootstrap3/sample/app/views/tags/bsExampleWithCode.scala.html
+++ /dev/null
@@ -1,3 +0,0 @@
-@(theExample: Html)(theCode: Html)
-@bsExample(theExample)
-@code(theCode)
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/tags/code.scala.html b/play25-bootstrap3/sample/app/views/tags/code.scala.html
deleted file mode 100644
index a814ab5..0000000
--- a/play25-bootstrap3/sample/app/views/tags/code.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(code: Html)
-
-
@utils.SimplePrettifier.prettify(code.toString)
-
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/tags/docsReadonlyAttributes.scala.html b/play25-bootstrap3/sample/app/views/tags/docsReadonlyAttributes.scala.html
deleted file mode 100644
index 7d38686..0000000
--- a/play25-bootstrap3/sample/app/views/tags/docsReadonlyAttributes.scala.html
+++ /dev/null
@@ -1,18 +0,0 @@
-@()
-
- Both the disabled and readonly attributes for an input prevent the user from modify it.
- However, the disabled attribute means this input will NOT be sent within the POST request, whereas
- the readonly one means it will.
-
-
- Nevertheless, for checkbox, radio and select tags it doesn't happen. To
- support the readonly attribute for these tags, the corresponding helpers have been adapted to behave
- as would be expected. To do that, when the readonly attribute appears the helper will:
-
-
add an additional disabled attribute
-
add an additional <input type="hidden"> with the desired value
-
wraps them with in a div (with class checkbox-group, radio-group or select-group)
-
- Note it only happens when the readonly attribute is present, even with a false value.
- It is done to make it easier to modify its readonly behaviour using javascript.
-
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/tags/javaMessagesWarning.scala.html b/play25-bootstrap3/sample/app/views/tags/javaMessagesWarning.scala.html
deleted file mode 100644
index ecf656e..0000000
--- a/play25-bootstrap3/sample/app/views/tags/javaMessagesWarning.scala.html
+++ /dev/null
@@ -1,19 +0,0 @@
-@(id: String = "")
-@if(utils.BSVersion.play_code == "2.4") {
-
- From Play 2.4, the implicit Messages argument defined in your custom template collides with the implicit one taken from PlayMagicForJava object, and it raises
- a compilation error. So you only need to remove this implicit argument from your custom template.
-
-
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/tags/repository/file.scala.html b/play25-bootstrap3/sample/app/views/tags/repository/file.scala.html
deleted file mode 100644
index 3264bde..0000000
--- a/play25-bootstrap3/sample/app/views/tags/repository/file.scala.html
+++ /dev/null
@@ -1,2 +0,0 @@
-@(file: String, text: String = "")
-@resource(utils.BSVersion.repositoryFile(file), text)
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/tags/repository/folder.scala.html b/play25-bootstrap3/sample/app/views/tags/repository/folder.scala.html
deleted file mode 100644
index 70698e3..0000000
--- a/play25-bootstrap3/sample/app/views/tags/repository/folder.scala.html
+++ /dev/null
@@ -1,2 +0,0 @@
-@(folder: String, text: String = "")
-@resource(utils.BSVersion.repositoryFile(folder), text)
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/tags/repository/home.scala.html b/play25-bootstrap3/sample/app/views/tags/repository/home.scala.html
deleted file mode 100644
index 57fed4d..0000000
--- a/play25-bootstrap3/sample/app/views/tags/repository/home.scala.html
+++ /dev/null
@@ -1,2 +0,0 @@
-@(text: String = "Github", theClass: String = "")
-@resource(utils.BSVersion.repository, text, theClass)
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/tags/repository/resource.scala.html b/play25-bootstrap3/sample/app/views/tags/repository/resource.scala.html
deleted file mode 100644
index 30ca245..0000000
--- a/play25-bootstrap3/sample/app/views/tags/repository/resource.scala.html
+++ /dev/null
@@ -1,2 +0,0 @@
-@(resource: String, text: String = "", theClass: String = "")
-@Html(if (text != "") text else resource.replaceAll("^.*/", ""))
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/tags/versionBadge.scala.html b/play25-bootstrap3/sample/app/views/tags/versionBadge.scala.html
deleted file mode 100644
index 5d87ba7..0000000
--- a/play25-bootstrap3/sample/app/views/tags/versionBadge.scala.html
+++ /dev/null
@@ -1,12 +0,0 @@
-@(explicit: Boolean = false)
-@import utils.BSVersion._
-
- @code
-
- @if(explicit) {
- @play @bootstrap
- } else {
- @play_code @bootstrap_code
- }
-
-
\ No newline at end of file
diff --git a/play25-bootstrap3/sample/app/views/vertical.scala.html b/play25-bootstrap3/sample/app/views/vertical.scala.html
deleted file mode 100644
index 97cc54b..0000000
--- a/play25-bootstrap3/sample/app/views/vertical.scala.html
+++ /dev/null
@@ -1,218 +0,0 @@
-@(fooForm: Form[String])(implicit messages: Messages, request: RequestHeader)
-@import utils.BSVersion
-@import tags._
-@implicitFieldConstructor = @{ b3.vertical.fieldConstructor() }
-
-@fruits = @{ Seq("A"->"Apples","P"->"Pears","B"->"Bananas") }
-
-
-@main("Vertical Form", tab = "styles") {
-
-
- }
- }(fc, messages)
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/clear/package.scala b/play25-bootstrap4/module/app/views/b4/clear/package.scala
deleted file mode 100644
index 1f58b0d..0000000
--- a/play25-bootstrap4/module/app/views/b4/clear/package.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b4
-
-package object clear {
-
- import play.twirl.api.Html
- import play.api.i18n.Messages
- import play.api.mvc.{ Call, RequestHeader }
- import views.html.helper._
- import views.html.bs.Args.{ inner, isTrue }
-
- /**
- * Declares the class for the Clear FieldConstructor.
- */
- class ClearFieldConstructor(val isCustom: Boolean = false, val withFeedbackTooltip: Boolean = false) extends B4FieldConstructor {
- /* Define the class of the corresponding form */
- val formClass = "form-clear"
- /* Renders the corresponding template of the field constructor */
- def apply(fieldInfo: B4FieldInfo, inputHtml: Html)(implicit messages: Messages) = inputHtml
- /* Renders the corresponding template of the form group */
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages) = contentHtml
- }
-
- /**
- * Creates a new ClearFieldConstructor to use for specific forms or scopes (don't use it as a default one).
- * If a default B4FieldConstructor and a specific ClearFieldConstructor are within the same scope, the more
- * specific will be chosen.
- */
- def fieldConstructorSpecific(isCustom: Boolean = false, withFeedbackTooltip: Boolean = false): ClearFieldConstructor =
- new ClearFieldConstructor(isCustom, withFeedbackTooltip)
-
- /**
- * Returns it as a B4FieldConstructor to use it as default within a template
- */
- def fieldConstructor(isCustom: Boolean = false, withFeedbackTooltip: Boolean = false): B4FieldConstructor =
- fieldConstructorSpecific(isCustom, withFeedbackTooltip)
-
- /**
- * **********************************************************************************************************************************
- * SHORTCUT HELPERS
- * *********************************************************************************************************************************
- */
- def form(action: Call, args: (Symbol, Any)*)(body: ClearFieldConstructor => Html) = {
- val cfc = fieldConstructorSpecific(isCustom = isTrue(args, '_custom), withFeedbackTooltip = isTrue(args, '_feedbackTooltip))
- views.html.b4.form(action, inner(args): _*)(body(cfc))(cfc)
- }
- def formCSRF(action: Call, args: (Symbol, Any)*)(body: ClearFieldConstructor => Html)(implicit request: RequestHeader) = {
- val cfc = fieldConstructorSpecific(isCustom = isTrue(args, '_custom), withFeedbackTooltip = isTrue(args, '_feedbackTooltip))
- views.html.b4.formCSRF(action, inner(args): _*)(body(cfc))(cfc, request)
- }
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/file.scala.html b/play25-bootstrap4/module/app/views/b4/file.scala.html
deleted file mode 100644
index 9431726..0000000
--- a/play25-bootstrap4/module/app/views/b4/file.scala.html
+++ /dev/null
@@ -1,11 +0,0 @@
-@(field: Field, args: (Symbol,Any)*)(implicit fc: b4.B4FieldConstructor, messages: Messages)
-@inputFormGroup(field, withLabelFor = true, args) { fieldInfo =>
- @if(fieldInfo.isCustom) {
-
-
-
-
- } else {
-
- }
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/form.scala.html b/play25-bootstrap4/module/app/views/b4/form.scala.html
deleted file mode 100644
index aa940b5..0000000
--- a/play25-bootstrap4/module/app/views/b4/form.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(action: Call, args: (Symbol, Any)*)(body: => Html)(implicit fc: b4.B4FieldConstructor)
-
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/formCSRF.scala.html b/play25-bootstrap4/module/app/views/b4/formCSRF.scala.html
deleted file mode 100644
index 80f8b59..0000000
--- a/play25-bootstrap4/module/app/views/b4/formCSRF.scala.html
+++ /dev/null
@@ -1,5 +0,0 @@
-@(action: Call, args: (Symbol, Any)*)(body: => Html)(implicit fc: b4.B4FieldConstructor, request: RequestHeader)
-@form(action, args:_*) {
- @helper.CSRF.formField
- @body
-}(fc)
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/hiddenInput.scala.html b/play25-bootstrap4/module/app/views/b4/hiddenInput.scala.html
deleted file mode 100644
index 5ae08f3..0000000
--- a/play25-bootstrap4/module/app/views/b4/hiddenInput.scala.html
+++ /dev/null
@@ -1,2 +0,0 @@
-@(name: Any, value: Any, args: (Symbol, Any)*)
-
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/hiddens.scala.html b/play25-bootstrap4/module/app/views/b4/hiddens.scala.html
deleted file mode 100644
index 6c7d022..0000000
--- a/play25-bootstrap4/module/app/views/b4/hiddens.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(namesAndValues: (Any, Any)*)
-@namesAndValues.map { case (name, value) =>
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/horizontal/bsFieldConstructor.scala.html b/play25-bootstrap4/module/app/views/b4/horizontal/bsFieldConstructor.scala.html
deleted file mode 100644
index b32aaa5..0000000
--- a/play25-bootstrap4/module/app/views/b4/horizontal/bsFieldConstructor.scala.html
+++ /dev/null
@@ -1,13 +0,0 @@
-@(fieldInfo: b4.B4FieldInfo, inputHtml: Html, colLabel: String, colOffset: String, colInput: String)(implicit fc: b4.B4FieldConstructor, messages: Messages)
-@b4.bsFieldConstructorCommon(fieldInfo, inputHtml, extraClasses = Some("row")) { content =>
- @fieldInfo.labelOpt.map { label =>
-
-
- }
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/horizontal/package.scala b/play25-bootstrap4/module/app/views/b4/horizontal/package.scala
deleted file mode 100644
index b7e9b22..0000000
--- a/play25-bootstrap4/module/app/views/b4/horizontal/package.scala
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b4
-
-package object horizontal {
-
- import play.twirl.api.Html
- import play.api.mvc.{ Call, RequestHeader }
- import play.api.i18n.Messages
- import views.html.helper._
- import views.html.bs.Args.{ inner, isTrue }
-
- /**
- * Declares the class for the Horizontal FieldConstructor.
- * It needs the column widths for the corresponding Bootstrap3 form-group
- */
- case class HorizontalFieldConstructor(colLabel: String, colInput: String, val isCustom: Boolean = false, val withFeedbackTooltip: Boolean = false) extends B4FieldConstructor {
- /* The equivalent offset if label is not present (ex: colLabel = "col-md-2" => colOffset = "offset-md-2") */
- val colOffset: String = colLabel.replace("col", "offset")
- /* Define the class of the corresponding form */
- val formClass = "form-horizontal"
- /* Renders the corresponding template of the field constructor */
- def apply(fieldInfo: B4FieldInfo, inputHtml: Html)(implicit messages: Messages) = bsFieldConstructor(fieldInfo, inputHtml, colLabel, colOffset, colInput)(this, messages)
- /* Renders the corresponding template of the form group */
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages) = bsFormGroup(contentHtml, argsMap, colLabel, colOffset, colInput)(messages)
- }
-
- /**
- * Returns a new HorizontalFieldConstructor to use for specific forms or scopes (don't use it as a default one).
- * If a default B4FieldConstructor and a specific HorizontalFieldConstructor are within the same scope, the more
- * specific will be chosen.
- */
- def fieldConstructorSpecific(colLabel: String, colInput: String, isCustom: Boolean = false, withFeedbackTooltip: Boolean = false): HorizontalFieldConstructor =
- new HorizontalFieldConstructor(colLabel, colInput, isCustom, withFeedbackTooltip)
-
- /**
- * Returns it as a B4FieldConstructor to use it as default within a template
- */
- def fieldConstructor(colLabel: String, colInput: String, isCustom: Boolean = false, withFeedbackTooltip: Boolean = false): B4FieldConstructor =
- fieldConstructorSpecific(colLabel, colInput, isCustom, withFeedbackTooltip)
-
- /**
- * **********************************************************************************************************************************
- * SHORTCUT HELPERS
- * *********************************************************************************************************************************
- */
- def form(action: Call, colLabel: String, colInput: String, args: (Symbol, Any)*)(body: HorizontalFieldConstructor => Html) = {
- val hfc = fieldConstructorSpecific(colLabel, colInput, isCustom = isTrue(args, '_custom), withFeedbackTooltip = isTrue(args, '_feedbackTooltip))
- views.html.b4.form(action, inner(args): _*)(body(hfc))(hfc)
- }
- def formCSRF(action: Call, colLabel: String, colInput: String, args: (Symbol, Any)*)(body: HorizontalFieldConstructor => Html)(implicit request: RequestHeader) = {
- val hfc = fieldConstructorSpecific(colLabel, colInput, isCustom = isTrue(args, '_custom), withFeedbackTooltip = isTrue(args, '_feedbackTooltip))
- views.html.b4.formCSRF(action, inner(args): _*)(body(hfc))(hfc, request)
- }
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/inline/bsFieldConstructor.scala.html b/play25-bootstrap4/module/app/views/b4/inline/bsFieldConstructor.scala.html
deleted file mode 100644
index ff64695..0000000
--- a/play25-bootstrap4/module/app/views/b4/inline/bsFieldConstructor.scala.html
+++ /dev/null
@@ -1,7 +0,0 @@
-@(fieldInfo: b4.B4FieldInfo, inputHtml: Html)(implicit fc: b4.B4FieldConstructor, messages: Messages)
-@b4.bsFieldConstructorCommon(fieldInfo, inputHtml) { content =>
- @fieldInfo.labelOpt.map { label =>
-
- }
- @content
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/inline/bsFormGroup.scala.html b/play25-bootstrap4/module/app/views/b4/inline/bsFormGroup.scala.html
deleted file mode 100644
index 789f636..0000000
--- a/play25-bootstrap4/module/app/views/b4/inline/bsFormGroup.scala.html
+++ /dev/null
@@ -1,7 +0,0 @@
-@(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages)
-@b4.bsFormGroupCommon(contentHtml, argsMap) { content =>
- @argsMap.get('_label).map { label =>
-
- }
- @content
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/inline/package.scala b/play25-bootstrap4/module/app/views/b4/inline/package.scala
deleted file mode 100644
index 00720fc..0000000
--- a/play25-bootstrap4/module/app/views/b4/inline/package.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b4
-
-package object inline {
-
- import play.twirl.api.Html
- import play.api.mvc.{ Call, RequestHeader }
- import play.api.i18n.Messages
- import views.html.helper._
- import views.html.bs.Args.{ inner, isTrue }
-
- /**
- * Declares the class for the Inline FieldConstructor.
- */
- class InlineFieldConstructor(val isCustom: Boolean = false, val withFeedbackTooltip: Boolean = false) extends B4FieldConstructor {
- /* Define the class of the corresponding form */
- val formClass = "form-inline"
- /* Renders the corresponding template of the field constructor */
- def apply(fieldInfo: B4FieldInfo, inputHtml: Html)(implicit messages: Messages) = bsFieldConstructor(fieldInfo, inputHtml)(this, messages)
- /* Renders the corresponding template of the form group */
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages) = bsFormGroup(contentHtml, argsMap)(messages)
- }
-
- /**
- * Creates a new InlineFieldConstructor to use for specific forms or scopes (don't use it as a default one).
- * If a default B4FieldConstructor and a specific InlineFieldConstructor are within the same scope, the more
- * specific will be chosen.
- */
- def fieldConstructorSpecific(isCustom: Boolean = false, withFeedbackTooltip: Boolean = false): InlineFieldConstructor =
- new InlineFieldConstructor(isCustom, withFeedbackTooltip)
-
- /**
- * Returns it as a B4FieldConstructor to use it as default within a template
- */
- def fieldConstructor(isCustom: Boolean = false, withFeedbackTooltip: Boolean = false): B4FieldConstructor =
- fieldConstructorSpecific(isCustom, withFeedbackTooltip)
-
- /**
- * **********************************************************************************************************************************
- * SHORTCUT HELPERS
- * *********************************************************************************************************************************
- */
- def form(action: Call, args: (Symbol, Any)*)(body: InlineFieldConstructor => Html) = {
- val ifc = fieldConstructorSpecific(isCustom = isTrue(args, '_custom), withFeedbackTooltip = isTrue(args, '_feedbackTooltip))
- views.html.b4.form(action, inner(args): _*)(body(ifc))(ifc)
- }
- def formCSRF(action: Call, args: (Symbol, Any)*)(body: InlineFieldConstructor => Html)(implicit request: RequestHeader) = {
- val ifc = fieldConstructorSpecific(isCustom = isTrue(args, '_custom), withFeedbackTooltip = isTrue(args, '_feedbackTooltip))
- views.html.b4.formCSRF(action, inner(args): _*)(body(ifc))(ifc, request)
- }
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/inputWrapped.scala.html b/play25-bootstrap4/module/app/views/b4/inputWrapped.scala.html
deleted file mode 100644
index d23e3cf..0000000
--- a/play25-bootstrap4/module/app/views/b4/inputWrapped.scala.html
+++ /dev/null
@@ -1,6 +0,0 @@
-@(inputType: String, field: Field, args: (Symbol,Any)*)(inputGroup: Html => Html)(implicit fc: b4.B4FieldConstructor, messages: Messages)
-@inputFormGroup(field, withLabelFor = true, bs.Args.withAddingStringValue(args, 'class, "form-control")) { fieldInfo =>
- @inputGroup {
-
- }
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/multifield.scala.html b/play25-bootstrap4/module/app/views/b4/multifield.scala.html
deleted file mode 100644
index 5c251cf..0000000
--- a/play25-bootstrap4/module/app/views/b4/multifield.scala.html
+++ /dev/null
@@ -1,16 +0,0 @@
-@(fields: Field*)(globalArgs: Seq[(Symbol,Any)], fieldsArgs: Seq[(Symbol,Any)])(inputsHtml: b4.clear.ClearFieldConstructor => Html)(implicit fc: b4.B4FieldConstructor, messages: Messages)
-@multifieldFormGroup(fields, globalArgs, fieldsArgs) { multifieldInfo =>
- @inputsHtml(b4.clear.fieldConstructorSpecific(isCustom = fc.isCustom))
- @* renders a hidden form-control only to force visibility of the next feedback *@
- @multifieldInfo.status.collect {
- case "danger" => {}
- case "success" => {}
- case "warning" => {}
- }
- @multifieldInfo.feedbackInfos.map { text =>
-
@text
- }
- @multifieldInfo.helpInfos.map { text =>
- @text
- }
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/package.scala b/play25-bootstrap4/module/app/views/b4/package.scala
deleted file mode 100644
index 813db2c..0000000
--- a/play25-bootstrap4/module/app/views/b4/package.scala
+++ /dev/null
@@ -1,216 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html
-
-package object b4 {
-
- import play.api.data.{ Field, FormError }
- import play.twirl.api.Html
- import play.api.i18n.{ Lang, Messages }
- import bs._
- import bs.ArgsMap.isTrue
- import play.api.mvc.Call
-
- /**
- * Class with relevant variables for a field to pass it to the helper and field constructor
- * - withLabelFor: indicates if the label's "for" attribute should be shown
- * - args: list of available arguments for the helper and field constructor
- */
- case class B4FieldInfo(field: Field, withLabelFor: Boolean, args: Seq[(Symbol, Any)], override val messages: Messages) extends BSFieldInfo(field, args, messages) {
-
- /* List with every "feedback info" and its corresponding ARIA id. Ex: ("foo_info_0" -> "foo constraint") */
- val feedbackInfos: Seq[(String, String)] =
- if (errors.size > 0)
- errors
- else
- BSFieldInfo.feedbackInfosButErrors(argsMap, messages).zipWithIndex.map {
- case (info, i) => (id + "_feedback_" + i, info)
- }
-
- /* List with every "help info" (i.e. a help text or constraints) and its corresponding ARIA id. Ex: ("foo_info_0" -> "foo constraint") */
- val helpInfos: Seq[(String, String)] = BSFieldInfo.helpInfos(Some(field), argsMap, messages).zipWithIndex.map {
- case (info, i) => (id + "_info_" + i, info)
- }
-
- /* Indicates if it's a custom element */
- def isCustom(implicit fc: b4.B4FieldConstructor): Boolean = fc.isCustom || isTrue(argsMap, '_custom)
-
- /* The optional validation state ("success", "warning" or "danger") */
- override lazy val status: Option[String] = B4FieldInfo.status(hasErrors, argsMap)
-
- /* The corresponding optional validation feedback for B4 ("valid-feedback", "warning-feedback" or "invalid-feedback") */
- def statusB4Feedback(implicit fc: b4.B4FieldConstructor): Option[String] = B4FieldInfo.statusB4Feedback(status, fc.withFeedbackTooltip)
-
- /* List of every ARIA id */
- val ariaIds: Seq[String] = feedbackInfos.map(_._1) ++ helpInfos.map(_._1)
-
- /*
- * Map with the inner args, i.e. those args for the helper itself removing those ones reserved for the field constructor.
- * It adds the ARIA attributes and removes the underscored reserved for the field constructor and the `id and `value ones that are
- * managed independently.
- */
- lazy val innerArgsMap: Map[Symbol, Any] = (
- (if (ariaIds.size > 0) Seq(Symbol("aria-describedby") -> ariaIds.mkString(" ")) else Nil) ++
- (if (hasErrors) Seq(Symbol("aria-invalid") -> "true") else Nil) ++
- BSFieldInfo.constraintsArgs(field, messages) ++
- Args.inner(
- Args.remove(
- status.map(s => Args.withAddingStringValue(args, 'class, if (s == "danger") "is-invalid" else if (s == "success") "is-valid" else if (s == "warning") "is-warning" else "")).getOrElse(args),
- 'id, 'value
- ).map {
- case arg if arg._1 == 'placeholder => Args.msg(arg)(messages)
- case other => other
- }
- )
- ).toMap
- }
-
- /**
- * Companion object for class B4FieldInfo
- */
- object B4FieldInfo {
- /* The optional validation state ("success", "warning" or "danger") */
- def status(hasErrors: Boolean, argsMap: Map[Symbol, Any]): Option[String] = {
- if (hasErrors)
- Some("danger")
- else if (ArgsMap.isNotFalse(argsMap, '_warning) || isTrue(argsMap, '_showIconWarning))
- Some("warning")
- else if (ArgsMap.isNotFalse(argsMap, '_success) || isTrue(argsMap, '_showIconValid))
- Some("success")
- else
- None
- }
- /* The corresponding feedback class for helpers */
- def statusB4Feedback(status: Option[String], withFeedbackTooltip: Boolean = false): Option[String] = status.map {
- case "success" => "valid"
- case "warning" => "warning"
- case _ => "invalid"
- }.map(_ + (if (withFeedbackTooltip) "-tooltip" else "-feedback"))
- }
-
- /**
- * Class with relevant variables for the global information of a multifield
- * - fields: list of Fields
- * - args: list of available arguments for the helper and the form-group
- */
- case class B4MultifieldInfo(fields: Seq[Field], globalArguments: Seq[(Symbol, Any)], fieldsArguments: Seq[(Symbol, Any)], override val messages: Messages) extends BSMultifieldInfo(fields, globalArguments, fieldsArguments, messages) {
-
- /* List with every "feedback info" */
- val feedbackInfos: Seq[String] = {
- if (errors.size > 0)
- errors
- else
- BSFieldInfo.feedbackInfosButErrors(argsMap, messages)
- }
-
- /* List with every "help info" (i.e. a help text or constraints) */
- val helpInfos: Seq[String] = {
- val globalHelpInfos = BSFieldInfo.helpInfos(None, argsMap, messages)
- if (globalHelpInfos.size > 0)
- globalHelpInfos
- else
- fields.flatMap { field =>
- BSFieldInfo.helpInfos(Some(field), argsMap, messages)
- }
- }
-
- /* The optional validation state ("success", "warning" or "danger") */
- override lazy val status: Option[String] = B4FieldInfo.status(hasErrors, argsMap)
-
- /* The corresponding optional validation feedback for B4 ("valid-feedback", "warning-feedback" or "invalid-feedback") */
- def statusB4Feedback(implicit fc: b4.B4FieldConstructor): Option[String] = B4FieldInfo.statusB4Feedback(status, fc.withFeedbackTooltip)
-
- override lazy val globalArgs = {
- val withoutHelp = Args.remove(globalArguments, '_help)
- val withStatus = status.map(s => Args.withDefault(withoutHelp, '_class -> s"has-$s")).getOrElse(withoutHelp)
- withStatus
- }
- }
-
- /**
- * Custom FieldConstructor for the library. Every FieldConstructor must extend this functionality.
- */
- trait B4FieldConstructor extends BSFieldConstructor[B4FieldInfo] {
- /* Define the class of the corresponding form (ex: "form-horizontal", "form-inline", ...) */
- val formClass: String
- val isCustom: Boolean
- val withFeedbackTooltip: Boolean
- }
-
- /**
- * Renders an input form-group using the B4FieldConstructor.
- * - withFeedbak: indicates if the feedback icons are allowed
- * - withLabelFor: indicates if the label's "for" attribute should be shown
- * - args: list of available arguments for the helper and field constructor
- * - inputDef: function that returns a Html from a B4FieldInfo that contains all the information about the field
- */
- def inputFormGroup(field: Field, withLabelFor: Boolean, args: Seq[(Symbol, Any)])(inputDef: B4FieldInfo => Html)(implicit fc: B4FieldConstructor, messages: Messages) =
- inputFormField(B4FieldInfo(field, withLabelFor, Args.withoutNones(args), messages))(inputDef)(fc)
-
- /**
- * Renders a form-group using the B4FieldConstructor.
- * - args: list of available arguments for the helper and the form-group
- * - contentDef: function that returns a Html from a map of arguments
- */
- def freeFormGroup(args: Seq[(Symbol, Any)])(contentDef: Map[Symbol, Any] => Html)(implicit fc: B4FieldConstructor, messages: Messages) =
- freeFormField(args)(contentDef)(fc, messages)
-
- def multifieldFormGroup(fields: Seq[Field], globalArgs: Seq[(Symbol, Any)], fieldsArgs: Seq[(Symbol, Any)])(contentDef: B4MultifieldInfo => Html)(implicit fc: B4FieldConstructor, messages: Messages) =
- multifieldFormField(B4MultifieldInfo(fields, globalArgs, fieldsArgs, messages))(contentDef)(fc)
-
- /**
- * **********************************************************************************************************************************
- * SHORTCUT HELPERS
- * *********************************************************************************************************************************
- */
- def inputType(inputType: String, field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputWrapped(inputType, field, args: _*)(html => html)(fc, messages)
-
- def text(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("text", field, args: _*)(fc, messages)
- def password(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("password", field.copy(value = Some("")), args: _*)(fc, messages)
- def color(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("color", field, args: _*)(fc, messages)
- def date(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("date", field, args: _*)(fc, messages)
- def datetime(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("datetime", field, args: _*)(fc, messages)
- def datetimeLocal(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("datetime-local", field, args: _*)(fc, messages)
- def email(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("email", field, args: _*)(fc, messages)
- def month(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("month", field, args: _*)(fc, messages)
- def number(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("number", field, args: _*)(fc, messages)
- def range(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("range", field, args: _*)(fc, messages)
- def search(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("search", field, args: _*)(fc, messages)
- def tel(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("tel", field, args: _*)(fc, messages)
- def time(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("time", field, args: _*)(fc, messages)
- def url(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("url", field, args: _*)(fc, messages)
- def week(field: Field, args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = inputType("week", field, args: _*)(fc, messages)
-
- def hidden(name: String, value: Any, args: (Symbol, Any)*) = hiddenInput(name, value, args: _*)
- def hidden(field: Field, args: (Symbol, Any)*) = hiddenInput(name = field.name, value = field.value.orElse(bs.Args.get(args, 'value)), (bs.Args.inner(bs.Args.remove(args, 'value))): _*)
-
- def radio(field: Field, args: (Symbol, Any)*)(content: Tuple3[Boolean, Boolean, B4FieldInfo] => Html)(implicit fc: B4FieldConstructor, messages: Messages) = radioWithContent(field, args: _*)(content)(fc, messages)
- def radio(field: Field, options: Seq[(String, Any)], args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = radioWithOptions(field, options, args: _*)(fc, messages)
-
- def select(field: Field, args: (Symbol, Any)*)(content: Set[String] => Html)(implicit fc: B4FieldConstructor, messages: Messages) = selectWithContent(field, args: _*)(content)(fc, messages)
- def select(field: Field, options: Seq[(String, String)], args: (Symbol, Any)*)(implicit fc: B4FieldConstructor, messages: Messages) = selectWithOptions(field, options, args: _*)(fc, messages)
-
- def submit(args: (Symbol, Any)*)(text: => Html)(implicit fc: B4FieldConstructor, messages: Messages) = buttonType("submit", args: _*)(text)(fc, messages)
- def reset(args: (Symbol, Any)*)(text: => Html)(implicit fc: B4FieldConstructor, messages: Messages) = buttonType("reset", args: _*)(text)(fc, messages)
- def button(args: (Symbol, Any)*)(text: => Html)(implicit fc: B4FieldConstructor, messages: Messages) = buttonType("button", args: _*)(text)(fc, messages)
-
- def static(args: (Symbol, Any)*)(text: => Html)(implicit fc: B4FieldConstructor, messages: Messages) = staticBasic(args: _*)(text)(fc, messages)
- def static(label: String, args: (Symbol, Any)*)(text: => Html)(implicit fc: B4FieldConstructor, messages: Messages) = staticBasic(Args.withDefault(args, '_label -> label): _*)(text)(fc, messages)
- def static(label: Html, args: (Symbol, Any)*)(text: => Html)(implicit fc: B4FieldConstructor, messages: Messages) = staticBasic(Args.withDefault(args, '_label -> label): _*)(text)(fc, messages)
-
- def free(args: (Symbol, Any)*)(content: => Html)(implicit fc: B4FieldConstructor, messages: Messages) = freeFormGroup(args)(_ => content)(fc, messages)
-
-}
diff --git a/play25-bootstrap4/module/app/views/b4/radioOption.scala.html b/play25-bootstrap4/module/app/views/b4/radioOption.scala.html
deleted file mode 100644
index 7ab6a5a..0000000
--- a/play25-bootstrap4/module/app/views/b4/radioOption.scala.html
+++ /dev/null
@@ -1,18 +0,0 @@
-@(inputValue: Any, label: Any, args: (Symbol, Any)*)(implicit extraInfo: (Boolean, Boolean, B4FieldInfo), fc: B4FieldConstructor, messages: Messages)
-@displayLabelWithInput(inputClass: String, labelClass: String, fieldInfo: b4.B4FieldInfo) = {
-
-
-}
-@defining(extraInfo) { case (inline, disabled, fieldInfo) =>
- @if(fieldInfo.isCustom) {
-
- } else { @contentWrapped }
-}
-@defining({
- val argsMap = args.toMap
- val readonly = bs.ArgsMap.isTrue(argsMap, 'readonly)
- val disabled = readonly || bs.ArgsMap.isTrue(argsMap, 'disabled)
- val multiple = bs.ArgsMap.isTrue(argsMap, 'multiple)
- (argsMap, disabled, multiple)
-}) { case (argsMap, disabled, multiple) =>
- @inputFormGroup(field, withLabelFor = true, bs.Args.withDefault(args, 'disabled -> disabled)) { fieldInfo =>
- @defining( if(multiple) "%s[]".format(fieldInfo.name) else fieldInfo.name ) { selectName =>
- @defining( ( !field.indexes.isEmpty && multiple ) match {
- case true => field.indexes.map( i => field("[%s]".format(i)).value ).flatten.toSet
- case _ if multiple && fieldInfo.value.isDefined => fieldInfo.value.get.split(",").toSet
- case _ => fieldInfo.value.toSet
- }){ implicit values =>
- @readonlyWrapper(selectName, fieldInfo.value, disabled, argsMap) {
-
- }
- }
- }
- }(fc, messages)
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/selectWithOptions.scala.html b/play25-bootstrap4/module/app/views/b4/selectWithOptions.scala.html
deleted file mode 100644
index 391ad81..0000000
--- a/play25-bootstrap4/module/app/views/b4/selectWithOptions.scala.html
+++ /dev/null
@@ -1,6 +0,0 @@
-@(field: Field, options: Seq[(String,String)], args: (Symbol,Any)*)(implicit fc: b4.B4FieldConstructor, messages: Messages)
-@selectWithContent(field, bs.Args.withDefault(args, '_hiddenValue -> bs.Args.get(args, '_default).map(bs.Args.msg(_)(messages)).orElse(options.headOption.map(_._1))):_*) { implicit values =>
- @options.map { v =>
- @selectOption(v._1, bs.Args.msg(v._2)(messages))
- }
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/staticBasic.scala.html b/play25-bootstrap4/module/app/views/b4/staticBasic.scala.html
deleted file mode 100644
index 946f70b..0000000
--- a/play25-bootstrap4/module/app/views/b4/staticBasic.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(args: (Symbol,Any)*)(text: => Html)(implicit fc: b4.B4FieldConstructor, messages: Messages)
-@freeFormGroup(bs.Args.withAddingStringValue(args, 'class, "form-control-static")) { innerArgsMap =>
-
@text
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/textarea.scala.html b/play25-bootstrap4/module/app/views/b4/textarea.scala.html
deleted file mode 100644
index 1b5b279..0000000
--- a/play25-bootstrap4/module/app/views/b4/textarea.scala.html
+++ /dev/null
@@ -1,4 +0,0 @@
-@(field: Field, args: (Symbol,Any)*)(implicit fc: b4.B4FieldConstructor, messages: Messages)
-@inputFormGroup(field, withLabelFor = true, bs.Args.withAddingStringValue(args, 'class, "form-control")) { fieldInfo =>
-
-}(fc, messages)
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/vertical/bsFieldConstructor.scala.html b/play25-bootstrap4/module/app/views/b4/vertical/bsFieldConstructor.scala.html
deleted file mode 100644
index ff64695..0000000
--- a/play25-bootstrap4/module/app/views/b4/vertical/bsFieldConstructor.scala.html
+++ /dev/null
@@ -1,7 +0,0 @@
-@(fieldInfo: b4.B4FieldInfo, inputHtml: Html)(implicit fc: b4.B4FieldConstructor, messages: Messages)
-@b4.bsFieldConstructorCommon(fieldInfo, inputHtml) { content =>
- @fieldInfo.labelOpt.map { label =>
-
- }
- @content
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/vertical/bsFormGroup.scala.html b/play25-bootstrap4/module/app/views/b4/vertical/bsFormGroup.scala.html
deleted file mode 100644
index 789f636..0000000
--- a/play25-bootstrap4/module/app/views/b4/vertical/bsFormGroup.scala.html
+++ /dev/null
@@ -1,7 +0,0 @@
-@(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages)
-@b4.bsFormGroupCommon(contentHtml, argsMap) { content =>
- @argsMap.get('_label).map { label =>
-
- }
- @content
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/app/views/b4/vertical/package.scala b/play25-bootstrap4/module/app/views/b4/vertical/package.scala
deleted file mode 100644
index da3fef9..0000000
--- a/play25-bootstrap4/module/app/views/b4/vertical/package.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b4
-
-package object vertical {
-
- import play.twirl.api.Html
- import play.api.mvc.{ Call, RequestHeader }
- import play.api.i18n.Messages
- import views.html.helper._
- import views.html.bs.Args.{ inner, isTrue }
-
- /**
- * Declares the class for the Vertical FieldConstructor.
- */
- class VerticalFieldConstructor(val isCustom: Boolean = false, val withFeedbackTooltip: Boolean = false) extends B4FieldConstructor {
- /* Define the class of the corresponding form */
- val formClass = "form-vertical"
- /* Renders the corresponding template of the field constructor */
- def apply(fieldInfo: B4FieldInfo, inputHtml: Html)(implicit messages: Messages) = bsFieldConstructor(fieldInfo, inputHtml)(this, messages)
- /* Renders the corresponding template of the form group */
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages) = bsFormGroup(contentHtml, argsMap)(messages)
- }
-
- /**
- * Creates a new VerticalFieldConstructor to use for specific forms or scopes (don't use it as a default one).
- * If a default B4FieldConstructor and a specific VerticalFieldConstructor are within the same scope, the more
- * specific will be chosen.
- */
- def fieldConstructorSpecific(isCustom: Boolean = false, withFeedbackTooltip: Boolean = false): VerticalFieldConstructor =
- new VerticalFieldConstructor(isCustom, withFeedbackTooltip)
-
- /**
- * Returns it as a B4FieldConstructor to use it as default within a template
- */
- def fieldConstructor(isCustom: Boolean = false, withFeedbackTooltip: Boolean = false): B4FieldConstructor =
- fieldConstructorSpecific(isCustom, withFeedbackTooltip)
-
- /**
- * **********************************************************************************************************************************
- * SHORTCUT HELPERS
- * *********************************************************************************************************************************
- */
- def form(action: Call, args: (Symbol, Any)*)(body: VerticalFieldConstructor => Html) = {
- val vfc = fieldConstructorSpecific(isCustom = isTrue(args, '_custom), withFeedbackTooltip = isTrue(args, '_feedbackTooltip))
- views.html.b4.form(action, args: _*)(body(vfc))(vfc)
- }
- def formCSRF(action: Call, args: (Symbol, Any)*)(body: VerticalFieldConstructor => Html)(implicit request: RequestHeader) = {
- val vfc = fieldConstructorSpecific(isCustom = isTrue(args, '_custom), withFeedbackTooltip = isTrue(args, '_feedbackTooltip))
- views.html.b4.formCSRF(action, args: _*)(body(vfc))(vfc, request)
- }
-
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/build.sbt b/play25-bootstrap4/module/build.sbt
deleted file mode 100644
index 9e97b6f..0000000
--- a/play25-bootstrap4/module/build.sbt
+++ /dev/null
@@ -1,70 +0,0 @@
-name := """play-bootstrap"""
-
-version := "1.4-P25-B4-SNAPSHOT"
-
-scalaVersion := "2.11.11"
-
-crossScalaVersions := Seq("2.11.11")
-
-resolvers ++= Seq(
- "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
- "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
-)
-
-libraryDependencies ++= Seq(
- filters % "provided",
- "com.adrianhurt" %% "play-bootstrap-core" % "1.4-P25-SNAPSHOT",
- specs2 % Test
-)
-
-lazy val root = (project in file(".")).enablePlugins(PlayScala)
-
-
-
-scalariformSettings
-
-//*******************************
-// Maven settings
-//*******************************
-
-sonatypeSettings
-
-publishMavenStyle := true
-
-organization := "com.adrianhurt"
-
-description := "This is a collection of input helpers and field constructors for Play Framework to render Bootstrap HTML code."
-
-homepage := Some(url("https://adrianhurt.github.io/play-bootstrap"))
-
-licenses := Seq("Apache License" -> url("https://github.com/adrianhurt/play-bootstrap/blob/master/LICENSE"))
-
-startYear := Some(2014)
-
-publishTo := {
- val nexus = "https://oss.sonatype.org/"
- if (isSnapshot.value)
- Some("snapshots" at nexus + "content/repositories/snapshots")
- else
- Some("releases" at nexus + "service/local/staging/deploy/maven2")
-}
-
-publishArtifact in Test := false
-
-pomIncludeRepository := { _ => false }
-
-pomExtra := (
-
- git@github.com:adrianhurt/play-bootstrap.git
- scm:git:git@github.com:adrianhurt/play-bootstrap.git
-
-
-
- adrianhurt
- Adrian Hurtado
- https://github.com/adrianhurt
-
-
-)
-
-credentials += Credentials(Path.userHome / ".sbt" / "sonatype.credentials")
diff --git a/play25-bootstrap4/module/project/build.properties b/play25-bootstrap4/module/project/build.properties
deleted file mode 100644
index c364161..0000000
--- a/play25-bootstrap4/module/project/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-#Activator-generated Properties
-#Mon Aug 11 18:06:16 BST 2014
-template.uuid=688014f0-0585-43e3-a9fa-d62f7d12f1ab
-sbt.version=0.13.11
diff --git a/play25-bootstrap4/module/project/plugins.sbt b/play25-bootstrap4/module/project/plugins.sbt
deleted file mode 100644
index 63f4ec9..0000000
--- a/play25-bootstrap4/module/project/plugins.sbt
+++ /dev/null
@@ -1,12 +0,0 @@
-resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
-
-// The Play plugin
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.18")
-
-// web plugins
-
-addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
-
-addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.2")
-
-addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
diff --git a/play25-bootstrap4/module/test/FieldConstructorsSpec.scala b/play25-bootstrap4/module/test/FieldConstructorsSpec.scala
deleted file mode 100644
index 067eb27..0000000
--- a/play25-bootstrap4/module/test/FieldConstructorsSpec.scala
+++ /dev/null
@@ -1,248 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b4
-
-import views.html.b4
-import TestUtils._
-import org.specs2.mutable.Specification
-import views.html.helper.FieldConstructor
-import play.api.data.Forms._
-import play.api.data._
-import play.api.{ Configuration, Environment }
-import play.api.i18n.{ DefaultLangs, DefaultMessagesApi }
-import play.twirl.api.Html
-import play.api.mvc.Call
-
-object FieldConstructorsSpec extends Specification {
-
- val messagesApi = new DefaultMessagesApi(Environment.simple(), Configuration.reference, new DefaultLangs(Configuration.reference))
- implicit val messages = messagesApi.preferred(Seq.empty)
-
- def testFielConstructor(fcDefault: B4FieldConstructor, fcWithCustomFields: B4FieldConstructor, fcWithFeedbackTooltip: B4FieldConstructor) = {
- implicit val fc = fcDefault
- val testInputString = ""
- def testInput(field: Field, args: (Symbol, Any)*) =
- b4.inputFormGroup(field, true, args) { _ => Html(testInputString) }
-
- val fooForm = Form(single("foo" -> Forms.nonEmptyText(maxLength = 8)))
- val fooField = fooForm("foo")
-
- val simpleInput = testInput(fooField).body
- def simpleInputWithArgs(args: (Symbol, Any)*)(implicit fc: B4FieldConstructor) = b4.text(fooField, args: _*).body
- def simpleInputWithError(args: (Symbol, Any)*)(implicit fc: B4FieldConstructor) = b4.text(fooForm.withError("foo", "test-error-0").withError("foo", "test-error-1")("foo"), args: _*).body
-
- val fieldsetExtraClasses = fc match {
- case hfc: b4.horizontal.HorizontalFieldConstructor => " row"
- case _ => ""
- }
- val labelExtraClasses = fc match {
- case hfc: b4.horizontal.HorizontalFieldConstructor => "col-form-label " + hfc.colLabel
- case _ => ""
- }
-
- "have the basic structure" in {
- simpleInput must contain("class=\"form-group")
- simpleInput must not contain ("has-danger")
- simpleInput must not contain ("aria-invalid")
- simpleInput must contain(testInputString)
- simpleInput must not contain ("class=\"-feedback\"")
- simpleInput must not contain ("class=\"-tooltip\"")
- simpleInput must not contain ("class=\"form-text text-muted\"")
- }
-
- "have a default id" in {
- simpleInput must contain("id=\"foo_field\"")
- }
-
- "allow setting a custom id" in {
- simpleInputWithArgs('_id -> "customid") must contain("id=\"customid\"")
- }
-
- "allow setting extra classes form-group" in {
- clean(simpleInputWithArgs('_class -> "extra_class another_class")) must contain(s"""
"theLabel")) must contain(if (labelExtraClasses == "") """""" else s"""""")
- }
-
- "allow hide the label" in {
- val labelString = if (labelExtraClasses == "") """""" else s""""""
- clean(simpleInputWithArgs('_label -> "theLabel", '_hideLabel -> true)) must contain(labelString)
- clean(simpleInputWithArgs('_hiddenLabel -> "theLabel")) must contain(labelString)
- }
-
- "allow render without label" in {
- simpleInputWithArgs() must not contain ("label")
- }
-
- "allow rendering errors" in {
- val test = simpleInputWithError()
- test must contain("has-danger")
- test must contain("
test-error-0
")
- test must contain("
test-error-1
")
- }
-
- "allow showing constraints" in {
- val test = simpleInputWithArgs('_showConstraints -> true)
- test must contain("")
- test must contain("")
- test must contain("class=\"form-text text-muted\">" + messages("constraint.required") + "")
- test must contain("class=\"form-text text-muted\">" + messages("constraint.maxLength", 8) + "")
- }
-
- "localize placeholder property" in {
- val test = simpleInputWithArgs('placeholder -> "simpleInputWithArgs.placeholder.value")
- test must contain("placeholder=\"Placeholder value\"")
- }
-
- "allow showing help info" in {
- simpleInputWithArgs('_help -> "test-help") must contain("test-help")
- simpleInputWithArgs('_success -> "test-help") must contain("
test-help
")
- simpleInputWithArgs('_warning -> "test-help") must contain("
test-help
")
- simpleInputWithArgs('_error -> "test-help") must contain("
test-help
")
- }
-
- "allow rendering erros and hide constraints when help info is present" in {
- val test = simpleInputWithError('_showConstraints -> true, '_help -> "test-help")
- test must contain("
test-error-0
")
- test must contain("
test-error-1
")
- test must contain("test-help")
- test must not contain (" true)
- testStatus("success", '_success -> "test-help")
- testStatus("warning", '_warning -> true)
- testStatus("warning", '_warning -> "test-help")
- testStatus("danger", '_error -> true)
- testStatus("danger", '_error -> "test-help")
-
- "with feedback icons" in {
- testStatus("success", '_showIconValid -> true)
- testStatus("success", '_success -> "test-help", '_showIconValid -> true)
- testStatus("warning", '_showIconWarning -> true)
- testStatus("warning", '_warning -> "test-help", '_showIconWarning -> true)
- testStatus("danger", '_error -> true, '_showIconOnError -> true)
- testStatus("danger", '_error -> "test-help", '_showIconOnError -> true)
- }
- }
-
- "render aria attributes" in {
- val test0 = simpleInputWithArgs()
- test0 must not contain ("aria-invalid")
- test0 must not contain ("aria-describedby")
- test0 must not contain (" true)
- test1 must contain("aria-invalid=\"true\"")
- test1 must contain("aria-describedby=\"foo_error_0 foo_error_1 foo_info_0 foo_info_1\"")
- test1 must contain(" "test-help")
- test2 must contain("aria-describedby=\"foo_info_0\"")
- test2 must contain(" true).body.trim
- val customFile2 = b4.file(fooField)(fcWithCustomFields, messages).body.trim
- customFile1 must be equalTo customFile2
-
- val boolField = Form(single("foo" -> Forms.boolean))("foo")
- val customCheckbox1 = b4.checkbox(boolField, '_custom -> true, '_text -> "theText").body.trim
- val customCheckbox2 = b4.checkbox(boolField, '_text -> "theText")(fcWithCustomFields, messages).body.trim
- customCheckbox1 must be equalTo customCheckbox2
-
- val fruits = Seq("A" -> "Apples", "P" -> "Pears", "B" -> "Bananas")
- val customRadio1 = b4.radio(fooField, fruits, '_custom -> true).body.trim
- val customRadio2 = b4.radio(fooField, fruits)(fcWithCustomFields, messages).body.trim
- customRadio1 must be equalTo customRadio2
-
- val customSelect1 = b4.select(fooField, fruits, '_custom -> true).body.trim
- val customSelect2 = b4.select(fooField, fruits)(fcWithCustomFields, messages).body.trim
- customSelect1 must be equalTo customSelect2
- }
-
- "allow rendering with feedback tooltips" in {
- val test1 = simpleInputWithError()(fc)
- val test2 = simpleInputWithError()(fcWithFeedbackTooltip)
- test1.replaceAll("-feedback", "-tooltip") must be equalTo test2
-
- val test3 = simpleInputWithArgs('_success -> "test-help")(fc)
- val test4 = simpleInputWithArgs('_success -> "test-help")(fcWithFeedbackTooltip)
- test3.replaceAll("-feedback", "-tooltip") must be equalTo test4
-
- val test5 = simpleInputWithArgs('_warning -> "test-help")(fc)
- val test6 = simpleInputWithArgs('_warning -> "test-help")(fcWithFeedbackTooltip)
- test6.replaceAll("-feedback", "-tooltip") must be equalTo test6
- }
- }
-
- "horizontal field constructor" should {
- val (colLabel, colInput) = ("col-md-2", "col-md-10")
- implicit val horizontalFieldConstructor = new b4.horizontal.HorizontalFieldConstructor(colLabel, colInput)
- val fcWithCustomFields = new b4.horizontal.HorizontalFieldConstructor(colLabel, colInput, isCustom = true)
- val fcWithFeedbackTooltip = new b4.horizontal.HorizontalFieldConstructor(colLabel, colInput, withFeedbackTooltip = true)
-
- testFielConstructor(horizontalFieldConstructor, fcWithCustomFields, fcWithFeedbackTooltip)
-
- "render columns for horizontal form" in {
- val body = b4.text(Form(single("foo" -> Forms.text))("foo"), '_label -> "theLabel").body
- body must contain(colLabel)
- body must contain(colInput)
- }
- }
-
- "vertical field constructor" should {
- implicit val verticalFieldConstructor = new b4.vertical.VerticalFieldConstructor()
- val fcWithCustomFields = new b4.vertical.VerticalFieldConstructor(isCustom = true)
- val fcWithFeedbackTooltip = new b4.vertical.VerticalFieldConstructor(withFeedbackTooltip = true)
- testFielConstructor(verticalFieldConstructor, fcWithCustomFields, fcWithFeedbackTooltip)
- }
-
- "inline field constructor" should {
- implicit val inlineFieldConstructor = new b4.inline.InlineFieldConstructor()
- val fcWithCustomFields = new b4.inline.InlineFieldConstructor(isCustom = true)
- val fcWithFeedbackTooltip = new b4.inline.InlineFieldConstructor(withFeedbackTooltip = true)
- testFielConstructor(inlineFieldConstructor, fcWithCustomFields, fcWithFeedbackTooltip)
- }
-
- "clear field constructor" should {
- implicit val clearFieldConstructor = b4.clear.fieldConstructor()
-
- "simply render the input" in {
- val simpleInput = b4.text(Form(single("foo" -> Forms.text))("foo")).body.trim
- simpleInput must startWith("")
- // Make sure it doesn't have it twice
- simpleInput.substring(simpleInput.indexOf(">") + 1) must not contain (">")
- }
- }
-}
diff --git a/play25-bootstrap4/module/test/FormsSpec.scala b/play25-bootstrap4/module/test/FormsSpec.scala
deleted file mode 100644
index 1796d46..0000000
--- a/play25-bootstrap4/module/test/FormsSpec.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b4
-
-import views.html.b4
-import TestUtils._
-import org.specs2.mutable.Specification
-import play.api.data.Forms._
-import play.api.data._
-import play.api.{ Configuration, Environment }
-import play.api.i18n.{ DefaultLangs, DefaultMessagesApi }
-import play.twirl.api.Html
-import play.api.mvc.Call
-
-object FormsSpec extends Specification {
-
- val messagesApi = new DefaultMessagesApi(Environment.simple(), Configuration.reference, new DefaultLangs(Configuration.reference))
- implicit val messages = messagesApi.preferred(Seq.empty)
-
- val vfc = b4.vertical.fieldConstructor()
- val (colLabel, colInput) = ("col-md-2", "col-md-10")
- val hfc = b4.horizontal.fieldConstructor(colLabel, colInput)
- val ifc = b4.inline.fieldConstructor()
- val cfc = b4.clear.fieldConstructor()
-
- val testContentString = ""
-
- val (method, action) = ("POST", "/handleRequest")
- val fooCall = Call(method, action)
- def fooFormBody(args: (Symbol, Any)*)(fc: b4.B4FieldConstructor) = b4.form(fooCall, args: _*)(Html(testContentString))(fc).body
-
- "@form" should {
-
- val simple = fooFormBody()(vfc)
-
- "have action and method" in {
- simple must contain("action=\"" + action + "\"")
- simple must contain("method=\"" + method + "\"")
- }
-
- "add default class for each field constructor" in {
- fooFormBody()(vfc) must contain("class=\"form-vertical")
- fooFormBody()(hfc) must contain("class=\"form-horizontal")
- fooFormBody()(ifc) must contain("class=\"form-inline")
- fooFormBody()(cfc) must contain("class=\"form-clear")
- }
-
- "allow setting custom class" in {
- fooFormBody('class -> "customClass")(vfc) must contain("class=\"form-vertical customClass\"")
- }
-
- "allow disabling default class" in {
- fooFormBody('_disableDefaultClass -> true)(vfc) must not contain ("form-vertical")
- fooFormBody('_disableDefaultClass -> true, 'class -> "customClass")(vfc) must contain("class=\"customClass\"")
- }
-
- "add form role as default" in {
- simple must contain("role=\"form\"")
- }
-
- "allow setting extra arguments and remove those arguments with false values or with underscored names" in {
- val body = fooFormBody('extra_attr -> "test", 'true_attr -> true, 'fase_attr -> false, '_underscored_attr -> "test")(vfc)
- body must contain("extra_attr=\"test\"")
- body must contain("true_attr=\"true\"")
- body must not contain ("false_attr=\"false\"")
- body must not contain ("_underscored_attr=\"test\"")
- }
-
- "render the content body" in {
- simple must contain("")
- }
- }
-}
\ No newline at end of file
diff --git a/play25-bootstrap4/module/test/HelpersSpec.scala b/play25-bootstrap4/module/test/HelpersSpec.scala
deleted file mode 100644
index cec1725..0000000
--- a/play25-bootstrap4/module/test/HelpersSpec.scala
+++ /dev/null
@@ -1,767 +0,0 @@
-/**
- * Copyright 2015 Adrian Hurtado (adrianhurt)
- *
- * 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 views.html.b4
-
-import views.html.b4
-import TestUtils._
-import org.specs2.mutable.Specification
-import views.html.helper._
-import play.api.data.Forms._
-import play.api.data._
-import play.api.{ Configuration, Environment }
-import play.api.i18n.{ DefaultLangs, DefaultMessagesApi, Messages }
-import play.twirl.api.{ Html, HtmlFormat }
-import play.api.mvc.Call
-
-object HelpersSpec extends Specification {
-
- val messagesApi = new DefaultMessagesApi(Environment.simple(), Configuration.reference, new DefaultLangs(Configuration.reference))
- implicit val messages = messagesApi.preferred(Seq.empty)
-
- val vfc = b4.vertical.fieldConstructor()
- val (colLabel, colInput) = ("col-md-2", "col-md-10")
- val hfc = b4.horizontal.fieldConstructor(colLabel, colInput)
- val ifc = b4.inline.fieldConstructor()
- val cfc = b4.clear.fieldConstructor()
-
- /**
- * A test field constructor that simply renders the input
- */
- implicit val testFieldConstructor = new B4FieldConstructor {
- val formClass = ""
- val isCustom = false
- val withFeedbackTooltip = false
- def apply(fieldInfo: B4FieldInfo, inputHtml: Html)(implicit messages: Messages) = inputHtml
- def apply(contentHtml: Html, argsMap: Map[Symbol, Any])(implicit messages: Messages) = contentHtml
- }
-
- val fooField = Form(single("foo" -> Forms.text))("foo")
- def fooFieldFilled(v: String) = Form(single("foo" -> Forms.text)).fill(v)("foo")
-
- "@inputType" should {
-
- "allow setting a custom id" in {
- val body = b4.inputType("text", fooField, 'id -> "someid").body
- val idAttr = "id=\"someid\""
- body must contain(idAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(idAttr) + idAttr.length) must not contain (idAttr)
- }
-
- "allow setting a custom type" in {
- val body = b4.inputType("email", fooField).body
- val typeAttr = "type=\"email\""
- body must contain(typeAttr)
- // Make sure it doesn't contain it twice
- body.substring(body.indexOf(typeAttr) + typeAttr.length) must not contain (typeAttr)
- }
-
- "add form-control class as default" in {
- b4.inputType("text", fooField).body must contain("class=\"form-control\"")
- }
-
- "allow setting additional classes" in {
- b4.inputType("text", fooField, 'class -> "extra_class").body must contain("class=\"form-control extra_class\"")
- }
-
- "allow setting a default value" in {
- val body = b4.inputType("text", fooField, 'value -> "defaultvalue").body
- val valueAttr = "value=\"defaultvalue\""
- body must contain(valueAttr)
- // Make sure it doesn't contain it twice
- body.substring(body.indexOf(valueAttr) + valueAttr.length) must not contain (valueAttr)
- }
-
- "allow being filled with a value" in {
- val body = b4.inputType("text", fooFieldFilled("filledvalue"), 'value -> "defaultvalue").body
- val valueAttr = "value=\"filledvalue\""
- body must contain(valueAttr)
- // Make sure it doesn't contain it twice
- body.substring(body.indexOf(valueAttr) + valueAttr.length) must not contain (valueAttr)
- // Make sure it doesn't contain the default value
- body must not contain ("value=\"defaultvalue\"")
- }
-
- "allow setting extra arguments and remove those arguments with false values or with underscored names" in {
- val body = b4.inputType("text", fooField, 'extra_attr -> "test", 'true_attr -> true, 'fase_attr -> false, '_underscored_attr -> "test").body
- body must contain("extra_attr=\"test\"")
- body must contain("true_attr=\"true\"")
- body must not contain ("false_attr=\"false\"")
- body must not contain ("_underscored_attr=\"test\"")
- }
- }
-
- val sampleArgs = Seq[(Symbol, Any)]('id -> "someid", 'foo -> "fooValue")
- def sampleInputTypeBody(theType: String) = b4.inputType(theType, fooField, sampleArgs: _*).body.trim
-
- "@text" should {
- "be equivalent to inputType with text type" in {
- b4.text(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("text")
- }
- }
- "@password" should {
- "be equivalent to inputType with password type" in {
- b4.password(fooField, sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("password")
- }
- "not display its value" in {
- b4.password(fooFieldFilled("barValue"), sampleArgs: _*).body.trim must be equalTo sampleInputTypeBody("password")
- }
- }
- "@file" should {
- "be equivalent to inputType with file type" in {
- val file = b4.file(fooField, sampleArgs: _*).body.trim
- file must contain(""" true) +: sampleArgs): _*).body.trim
- customFile must contain("""
""")
- customFile must contain(""" "someid").body
- val idAttr = "id=\"someid\""
- body must contain(idAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(idAttr) + idAttr.length) must not contain (idAttr)
- }
-
- "add form-control class as default" in {
- b4.textarea(fooField).body must contain("class=\"form-control\"")
- }
-
- "allow setting additional classes" in {
- b4.textarea(fooField, 'class -> "extra_class").body must contain("class=\"form-control extra_class\"")
- }
-
- "allow setting a default value" in {
- val body = b4.textarea(fooField, 'value -> "defaultvalue").body
- body must contain(">defaultvalue")
- body must not contain ("value=\"defaultvalue\"")
- }
- }
-
- "@checkbox" should {
-
- val boolField = Form(single("foo" -> Forms.boolean))("foo")
- def boolFieldFilled(v: Boolean) = Form(single("foo" -> Forms.boolean)).fill(v)("foo")
- def stringFieldFilled(v: String) = Form(single("foo" -> Forms.text)).fill(v)("foo")
-
- "allow setting a custom id" in {
- val body = b4.checkbox(boolField, 'id -> "someid").body
- val idAttr = "id=\"someid\""
- body must contain(idAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(idAttr) + idAttr.length) must not contain (idAttr)
- }
-
- "be unchecked by default" in {
- val body = b4.checkbox(boolField).body
- body must not contain ("checked")
- body must contain("value=\"true\"")
- }
-
- "allow setting a default custom value" in {
- val body = b4.checkbox(boolField, 'value -> "bar").body
- body must not contain ("checked")
- body must contain("value=\"bar\"")
- }
-
- "allow setting a default value for checked attribute" in {
- val body = b4.checkbox(boolField, '_default -> true).body
- body must contain("checked")
- body must contain("value=\"true\"")
- }
-
- "allow setting a default value for checked attribute with a custom value" in {
- val body = b4.checkbox(boolField, 'value -> "bar", '_default -> true).body
- body must contain("checked")
- body must contain("value=\"bar\"")
- }
-
- "allow being filled with a value" in {
- val body = b4.checkbox(boolFieldFilled(true)).body
- body must contain("checked")
- body must contain("value=\"true\"")
- }
-
- "allow being filled with a custom value" in {
- val body = b4.checkbox(stringFieldFilled("bar"), 'value -> "bar").body
- body must contain("checked")
- body must contain("value=\"bar\"")
- }
-
- "ignore default checked value if it is filled" in {
- val body1 = b4.checkbox(boolFieldFilled(false), '_default -> true).body
- body1 must not contain ("checked")
- body1 must contain("value=\"true\"")
- val body2 = b4.checkbox(stringFieldFilled(""), 'value -> "bar", '_default -> true).body
- body2 must not contain ("checked")
- body2 must contain("value=\"bar\"")
- }
-
- "allow setting a forced value for checked attribute (always true)" in {
- val body = b4.checkbox(boolField, 'checked -> true).body
- body must contain("checked")
- body must contain("value=\"true\"")
- }
- "allow setting a forced value for checked attribute (always false)" in {
- val body = b4.checkbox(boolField, 'checked -> false).body
- body must not contain ("checked")
- body must contain("value=\"true\"")
- }
-
- "ignore default and filled checked value if it has forced checked" in {
- val body1 = b4.checkbox(boolFieldFilled(false), '_default -> false, 'checked -> true).body
- body1 must contain("checked")
- body1 must contain("value=\"true\"")
- val body2 = b4.checkbox(boolFieldFilled(true), '_default -> true, 'checked -> false).body
- body2 must not contain ("checked")
- body2 must contain("value=\"true\"")
- val body3 = b4.checkbox(stringFieldFilled(""), 'value -> "bar", '_default -> false, 'checked -> true).body
- body3 must contain("checked")
- body3 must contain("value=\"bar\"")
- val body4 = b4.checkbox(stringFieldFilled("bar"), 'value -> "bar", '_default -> true, 'checked -> false).body
- body4 must not contain ("checked")
- body4 must contain("value=\"bar\"")
- }
-
- "add support to readonly attribute" in {
- val bodyWithoutReadonly = b4.checkbox(boolField, 'value -> true).body
- bodyWithoutReadonly must contain("
false, 'value -> true).body
- bodyReadonlyFalse must contain("")
-
- val bodyReadonlyTrue = b4.checkbox(boolField, 'readonly -> true, 'value -> true).body
- bodyReadonlyTrue must contain("
")
- bodyReadonlyTrue must contain("disabled=\"true\"")
- bodyReadonlyTrue must contain("")
- }
-
- "render custom checkbox properly" in {
- val body = clean(b4.checkbox(boolField, '_custom -> true, '_text -> "theText").body)
- body must contain("""
""")
- body must contain("""""")
- body must contain("""""")
- }
- }
-
- "@radio" should {
-
- val fruits = Seq("A" -> "Apples", "P" -> "Pears", "B" -> "Bananas")
-
- "allow setting a custom id" in {
- val body = b4.radio(fooField, fruits, 'id -> "someid").body
- body must contain("id=\"someid_A\"")
- body must contain("id=\"someid_P\"")
- body must contain("id=\"someid_B\"")
- }
-
- "be unchecked by default" in {
- b4.radio(fooField, fruits).body must not contain ("checked")
- }
-
- "allow setting a default value" in {
- val body = b4.radio(fooField, fruits, 'value -> "B").body
- val checkedAttr = "checked"
- body must contain(checkedAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(checkedAttr) + checkedAttr.length) must not contain (checkedAttr)
- }
-
- "allow being filled with a value" in {
- val body = b4.radio(fooFieldFilled("B"), fruits).body
- val checkedAttr = "checked"
- body must contain(checkedAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(checkedAttr) + checkedAttr.length) must not contain (checkedAttr)
- }
-
- "not be inline by default" in {
- b4.radio(fooField, fruits).body must not contain ("form-check-inline")
- }
-
- "allow be inline" in {
- b4.radio(fooField, fruits, '_inline -> true).body must contain("form-check-inline")
- }
-
- "add support to readonly attribute" in {
- val bodyWithoutReadonly = b4.radio(fooField, fruits, 'value -> "B").body
- bodyWithoutReadonly must not contain ("radio-group")
- bodyWithoutReadonly must not contain ("disabled")
- bodyWithoutReadonly must not contain (" false, 'value -> "B").body
- bodyReadonlyFalse must contain("
")
- bodyReadonlyFalse must not contain ("disabled=\"true\"")
- bodyReadonlyFalse must contain("")
-
- val bodyReadonlyTrue = b4.radio(fooField, fruits, 'readonly -> true, 'value -> "B").body
- bodyReadonlyTrue must contain("
")
- bodyReadonlyTrue must contain("disabled=\"true\"")
- bodyReadonlyTrue must contain("
")
- }
-
- "render custom radio properly" in {
- val body = clean(b4.radio(fooField, fruits, '_custom -> true).body)
- body must contain("""
""")
- body must contain(""" "Apples", "P" -> "Pears", "B" -> "Bananas")
-
- "allow setting a custom id" in {
- val body = b4.select(fooField, fruits, 'id -> "someid").body
- body must contain("id=\"someid\"")
- }
-
- "add form-control class as default" in {
- b4.select(fooField, fruits).body must contain("class=\"form-control\"")
- }
-
- "allow setting additional classes" in {
- b4.select(fooField, fruits, 'class -> "extra_class").body must contain("class=\"form-control extra_class\"")
- }
-
- "be unselected by default" in {
- b4.select(fooField, fruits).body must not contain ("selected")
- }
-
- "allow setting a default value" in {
- val body = b4.select(fooField, fruits, 'value -> "B").body
- val selectedAttr = "selected"
- body must contain(selectedAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(selectedAttr) + selectedAttr.length) must not contain (selectedAttr)
- }
-
- "allow being filled with a value" in {
- val body = b4.select(fooFieldFilled("B"), fruits).body
- val selectedAttr = "selected"
- body must contain(selectedAttr)
- // Make sure it doesn't have it twice
- body.substring(body.indexOf(selectedAttr) + selectedAttr.length) must not contain (selectedAttr)
- }
-
- "add support to readonly attribute" in {
- val bodyWithoutReadonly = b4.select(fooField, fruits, 'value -> "B").body
- bodyWithoutReadonly must not contain ("
")
- bodyWithoutReadonly must not contain ("disabled")
- bodyWithoutReadonly must not contain (" false, 'value -> "B").body
- bodyReadonlyFalse must contain("
")
- bodyReadonlyFalse must not contain ("disabled=\"true\"")
- bodyReadonlyFalse must contain("")
-
- val bodyReadonlyTrue = b4.select(fooField, fruits, 'readonly -> true, 'value -> "B").body
- bodyReadonlyTrue must contain("
")
- bodyReadonlyTrue must contain("disabled=\"true\"")
- bodyReadonlyTrue must contain("")
- }
-
- "allow multiple" in {
- val body = b4.select(fooField, fruits, 'multiple -> true, 'value -> "P,B").body
- body must contain("multiple=\"true\"")
- val selectedAttr = "selected"
- body must contain(selectedAttr)
- // Make sure it has it twice, but not more.
- val restBody = body.substring(body.indexOf(selectedAttr) + selectedAttr.length)
- restBody must contain(selectedAttr)
- restBody.substring(restBody.indexOf(selectedAttr) + selectedAttr.length) must not contain (selectedAttr)
- }
-
- "render custom select properly" in {
- val body = b4.select(fooField, fruits, '_custom -> true).body
- body must contain("""