Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. /*Button*/
  2. .inputfile-6 + label {
  3. color: #d3394c;
  4. }
  5.  
  6. .inputfile-6 + label {
  7. border: 1px solid #d3394c;
  8. background-color: #f1e5e6;
  9. padding: 0;
  10. }
  11.  
  12. .inputfile-6:focus + label,
  13. .inputfile-6.has-focus + label,
  14. .inputfile-6 + label:hover {
  15. border-color: #722040;
  16. }
  17.  
  18. .inputfile-6 + label span,
  19. .inputfile-6 + label strong {
  20. padding: 0.625rem 1.25rem;
  21. /* 10px 20px */
  22. }
  23.  
  24. .inputfile-6 + label span {
  25. width: 200px;
  26. min-height: 2em;
  27. display: inline-block;
  28. text-overflow: ellipsis;
  29. white-space: nowrap;
  30. overflow: hidden;
  31. vertical-align: top;
  32. }
  33.  
  34. .inputfile-6 + label strong {
  35. height: 100%;
  36. color: #f1e5e6;
  37. background-color: #d3394c;
  38. display: inline-block;
  39. }
  40.  
  41. .inputfile-6:focus + label strong,
  42. .inputfile-6.has-focus + label strong,
  43. .inputfile-6 + label:hover strong {
  44. background-color: #722040;
  45. }
  46.  
  47. @media screen and (max-width: 50em) {
  48. .inputfile-6 + label strong {
  49. display: block;
  50. }
  51.  
  52. input[type='file']{
  53. display:none;
  54. }
  55. /*HTML*/
  56. <div class="box">
  57. <input type="file" name="file1" id="file1" class="inputfile inputfile-6" multiple="multiple"/>
  58. <label for="file1"> <strong><svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"/></svg> Wybierz pliki&hellip;</strong></label>
  59. </div>
  60.  
  61. /*JS*/
  62.  
  63. 'use strict';
  64.  
  65. ;( function ( document, window, index )
  66. {
  67. var inputs = document.querySelectorAll( '.inputfile' );
  68. Array.prototype.forEach.call( inputs, function( input )
  69. {
  70. var label = input.nextElementSibling,
  71. labelVal = label.innerHTML;
  72.  
  73. input.addEventListener( 'change', function( e )
  74. {
  75. var fileName = '';
  76. if( this.files && this.files.length > 1 )
  77. fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length );
  78. else
  79. fileName = e.target.value.split( '\\' ).pop();
  80.  
  81. if( fileName )
  82. label.querySelector( 'span' ).innerHTML = fileName;
  83. else
  84. label.innerHTML = labelVal;
  85. });
  86.  
  87. // Firefox bug fix
  88. input.addEventListener( 'focus', function(){ input.classList.add( 'has-focus' ); });
  89. input.addEventListener( 'blur', function(){ input.classList.remove( 'has-focus' ); });
  90. });
  91. }( document, window, 0 ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement