_fouc.scss 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /* ------------------------------------------------------------------------------
  2. *
  3. * # Flash of unstyled content (FOUC)
  4. *
  5. * CSS fix for FOUC issue, which pops up in latest jQuery version. These styles
  6. * are optional, but enabled by default. Feel free to turn them off in configuration.
  7. *
  8. * ---------------------------------------------------------------------------- */
  9. // Check if component is enabled
  10. @if $enable-fouc-fix {
  11. //
  12. // Checkboxes and Radios
  13. //
  14. // for Uniform inputs
  15. // requires [data-fouc] data attribute
  16. //
  17. input[type=checkbox][data-fouc],
  18. input[type=radio][data-fouc] {
  19. visibility: hidden;
  20. @include size($checkbox-size);
  21. // Inside .form-check container
  22. .form-check & {
  23. position: absolute;
  24. }
  25. // Inline list
  26. .form-check-inline:not(.form-check-switchery) & {
  27. position: relative;
  28. margin-top: (($line-height-computed - $checkbox-size) / 2);
  29. margin-right: $form-check-inline-input-margin-x;
  30. // Right aligned
  31. .form-check-inline.form-check-right & {
  32. margin-right: 0;
  33. margin-left: $form-check-inline-input-margin-x;
  34. }
  35. }
  36. }
  37. //
  38. // Switchery
  39. //
  40. // for Switchery inputs
  41. // requires wrapper with .form-check-switchery class
  42. //
  43. // Left and right alignment
  44. .form-check-switchery {
  45. input[data-fouc] {
  46. width: ($switchery-size * 2) + rem-calc($switchery-border-width * 2);
  47. height: $switchery-size + rem-calc($switchery-border-width * 2);
  48. }
  49. }
  50. // Centered
  51. .form-check-switchery-double {
  52. &.form-check input[data-fouc] {
  53. position: static;
  54. }
  55. }
  56. //
  57. // Bootstrap switch
  58. //
  59. // for Bootstrap switch inputs
  60. // requires wrapper with .form-check-switch class
  61. //
  62. .form-check-switch {
  63. input {
  64. height: $input-height;
  65. visibility: hidden;
  66. display: inline-block;
  67. vertical-align: middle;
  68. margin: 0;
  69. // Large size
  70. &[data-size=large] {
  71. height: $input-height-lg;
  72. }
  73. // Small size
  74. &[data-size=small] {
  75. height: $input-height-sm;
  76. }
  77. }
  78. }
  79. //
  80. // Text input
  81. //
  82. // for tags, Uniform etc.
  83. // includes optional sizes
  84. //
  85. input {
  86. // Base
  87. &[type=text][data-fouc] {
  88. height: $input-height;
  89. opacity: 0;
  90. }
  91. // Large size
  92. &[type=text].form-control-lg[data-fouc] {
  93. height: $input-height-lg;
  94. }
  95. // Small size
  96. &[type=text].form-control-sm[data-fouc] {
  97. height: $input-height-sm;
  98. }
  99. }
  100. //
  101. // Selects
  102. //
  103. // for Select2 and Uniform selects
  104. // single and multiple
  105. //
  106. select {
  107. // Base
  108. &[data-fouc]:not([aria-hidden=false]) {
  109. height: $input-height;
  110. opacity: 0;
  111. }
  112. // Large size
  113. &.form-control-lg[data-fouc]:not([aria-hidden=false]) {
  114. height: $input-height-lg;
  115. }
  116. // Small size
  117. &.form-control-sm[data-fouc]:not([aria-hidden=false]) {
  118. height: $input-height-sm;
  119. }
  120. }
  121. //
  122. // File input
  123. //
  124. // for Uniform file input
  125. // includes optional sizes
  126. //
  127. input {
  128. // Base
  129. &[type=file][data-fouc] {
  130. height: $input-height;
  131. opacity: 0;
  132. }
  133. // Large size
  134. &[type=file].form-control-lg[data-fouc] {
  135. height: $input-height-lg;
  136. }
  137. // Small size
  138. &[type=file].form-control-sm[data-fouc] {
  139. height: $input-height-sm;
  140. }
  141. }
  142. //
  143. // Form wizard
  144. //
  145. // for Steps wizard
  146. // only hides main container
  147. //
  148. .wizard-form[data-fouc] {
  149. opacity: 0;
  150. // Show wizard
  151. &.wizard {
  152. opacity: 1;
  153. }
  154. // Calculate approximate container height
  155. &:not(.wizard) {
  156. padding-top: ($wizard-step-number-size + ($spacer / 2) + $line-height-computed) + ($spacer * 2);
  157. padding-bottom: (($input-padding-y * 2) + $line-height-computed + $spacer + rem-calc($input-border-width * 2));
  158. // Hide certain elements
  159. fieldset:not(:first-of-type),
  160. h6 {
  161. display: none;
  162. }
  163. }
  164. }
  165. //
  166. // Color picker
  167. //
  168. // for Spectrum color picker
  169. // hard coded height
  170. //
  171. input[type=text].colorpicker-flat-full[data-fouc] {
  172. height: 285px;
  173. }
  174. //
  175. // Ace editor
  176. //
  177. // for code editor containers
  178. // only hides main wrapper
  179. //
  180. pre[data-fouc] {
  181. &:not(.ace_editor) {
  182. height: $pre-scrollable-max-height;
  183. }
  184. &.ace_editor {
  185. visibility: visible;
  186. }
  187. }
  188. //
  189. // Sliders
  190. //
  191. // for NoUI and ION sliders
  192. // both require .noui-pips-height-helper and .ion-height-helper classes
  193. //
  194. // NoUI slider
  195. .noui-pips-height-helper:not(.noUi-target)[data-fouc] {
  196. height: $slider-pips-spacer-y + $line-height-computed + $slider-height;
  197. }
  198. .noui-pips-height-helper.noui-slider-lg:not(.noUi-target)[data-fouc] {
  199. height: $slider-pips-spacer-y + $line-height-computed + $slider-height-lg;
  200. }
  201. .noui-pips-height-helper.noui-slider-sm:not(.noUi-target)[data-fouc] {
  202. height: $slider-pips-spacer-y + $line-height-computed + $slider-height-sm;
  203. }
  204. .noui-vertical-height-helper:not(.noUi-target)[data-fouc] {
  205. display: inline-block;
  206. height: $slider-vertical-height;
  207. }
  208. // ION range slider
  209. input[type=text].ion-height-helper[data-fouc] {
  210. height: $tooltip-arrow-height + ($tooltip-padding-y * 2) + $slider-pips-font-size + ($slider-height * 4);
  211. }
  212. input[type=text].ion-pips-height-helper[data-fouc] {
  213. height: $tooltip-arrow-height + ($tooltip-padding-y * 2) + $slider-pips-font-size + ($slider-height * 7) + $slider-pips-spacer-y;
  214. }
  215. input[type=text].noui-height-helper:not(.noUi-target)[data-fouc] {
  216. height: $slider-height;
  217. }
  218. }