fileinput support

This commit is contained in:
Federico Zivolo 2014-09-18 10:43:28 +02:00
parent 96880e59db
commit 8671429577
3 changed files with 125 additions and 38 deletions

View File

@ -1285,6 +1285,13 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group">
<label for="inputFile" class="col-lg-2 control-label">File</label>
<div class="col-lg-10">
<input type="text" readonly class="form-control floating-label" placeholder="Browse...">
<input type="file" id="inputFile" multiple>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="textArea" class="col-lg-2 control-label">Textarea</label> <label for="textArea" class="col-lg-2 control-label">Textarea</label>
<div class="col-lg-10"> <div class="col-lg-10">

View File

@ -1,5 +1,5 @@
/* Generated by less 1.7.5 */ /* Generated by less 1.7.5 */
@import url(http://fonts.googleapis.com/css?family=Roboto+Condensed:300italic,400italic,700italic,400,700,300|Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic); @import url(//fonts.googleapis.com/css?family=Roboto+Condensed:300italic,400italic,700italic,400,700,300|Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic);
@-webkit-keyframes input-highlight { @-webkit-keyframes input-highlight {
0% { 0% {
left: 20%; left: 20%;
@ -427,11 +427,14 @@ h6,
.checkbox label span { .checkbox label span {
display: block; display: block;
position: absolute; position: absolute;
left: 10px; left: 0px;
-webkit-transition-duration: 0.2s; -webkit-transition-duration: 0.2s;
transition-duration: 0.2s; transition-duration: 0.2s;
} }
.checkbox label .ripple { .checkbox label .check:after {
display: block;
position: absolute;
content: "";
background-color: rgba(0, 0, 0, 0.84); background-color: rgba(0, 0, 0, 0.84);
left: -5px; left: -5px;
top: -15px; top: -15px;
@ -442,7 +445,9 @@ h6,
opacity: 0; opacity: 0;
margin: 0; margin: 0;
} }
.checkbox label .check { .checkbox label .check:before {
display: block;
content: "";
border: 2px solid rgba(0, 0, 0, 0.84); border: 2px solid rgba(0, 0, 0, 0.84);
height: 20px; height: 20px;
width: 20px; width: 20px;
@ -522,7 +527,7 @@ h6,
.checkbox input[type=checkbox] { .checkbox input[type=checkbox] {
display: none; display: none;
} }
.checkbox input[type=checkbox] ~ .check { .checkbox input[type=checkbox] ~ .check:before {
position: absolute; position: absolute;
top: 2px; top: 2px;
left: 11px; left: 11px;
@ -534,95 +539,98 @@ h6,
-ms-animation: uncheck 300ms ease-out forwards; -ms-animation: uncheck 300ms ease-out forwards;
animation: uncheck 300ms ease-out forwards; animation: uncheck 300ms ease-out forwards;
} }
.checkbox input[type=checkbox]:checked ~ .check { .checkbox input[type=checkbox]:checked ~ .check:before {
-webkit-animation: check 300ms ease-out forwards; -webkit-animation: check 300ms ease-out forwards;
-ms-animation: check 300ms ease-out forwards; -ms-animation: check 300ms ease-out forwards;
animation: check 300ms ease-out forwards; animation: check 300ms ease-out forwards;
} }
.checkbox input[type=checkbox]:not(:checked) ~ .ripple { .checkbox input[type=checkbox]:not(:checked) ~ .check:after {
-webkit-animation: rippleOff 500ms; -webkit-animation: rippleOff 500ms;
-ms-animation: rippleOff 500ms; -ms-animation: rippleOff 500ms;
animation: rippleOff 500ms; animation: rippleOff 500ms;
} }
.checkbox input[type=checkbox]:checked ~ .ripple { .checkbox input[type=checkbox]:checked ~ .check:after {
-webkit-animation: rippleOn 500ms; -webkit-animation: rippleOn 500ms;
-ms-animation: rippleOn 500ms; -ms-animation: rippleOn 500ms;
animation: rippleOn 500ms; animation: rippleOn 500ms;
} }
.checkbox input[type=checkbox][disabled]:not(:checked) ~ .check { .checkbox input[type=checkbox][disabled]:not(:checked) ~ .check:before {
opacity: 0.5; opacity: 0.5;
} }
.checkbox input[type=checkbox][disabled] ~ .ripple { .checkbox input[type=checkbox][disabled] ~ .check:after {
background-color: rgba(0, 0, 0, 0.84); background-color: rgba(0, 0, 0, 0.84);
-webkit-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg);
} }
.checkbox input[type=checkbox]:checked ~ .ripple, .checkbox input[type=checkbox]:checked ~ .check:after,
.checkbox-default input[type=checkbox]:checked ~ .ripple { .checkbox-default input[type=checkbox]:checked ~ .check:after {
background-color: #0f9d58; background-color: #0f9d58;
} }
.checkbox-primary input[type=checkbox]:checked ~ .ripple { .checkbox-primary input[type=checkbox]:checked ~ .check:after {
background-color: #4285f4; background-color: #4285f4;
} }
.checkbox-success input[type=checkbox]:checked ~ .ripple { .checkbox-success input[type=checkbox]:checked ~ .check:after {
background-color: #0f9d58; background-color: #0f9d58;
} }
.checkbox-info input[type=checkbox]:checked ~ .ripple { .checkbox-info input[type=checkbox]:checked ~ .check:after {
background-color: #03a9f4; background-color: #03a9f4;
} }
.checkbox-warning input[type=checkbox]:checked ~ .ripple { .checkbox-warning input[type=checkbox]:checked ~ .check:after {
background-color: #ff5722; background-color: #ff5722;
} }
.checkbox-danger input[type=checkbox]:checked ~ .ripple { .checkbox-danger input[type=checkbox]:checked ~ .check:after {
background-color: #f44336; background-color: #f44336;
} }
.checkbox-material-red input[type=checkbox]:checked ~ .ripple { .checkbox-material-red input[type=checkbox]:checked ~ .check:after {
background-color: #f44336; background-color: #f44336;
} }
.checkbox-material-pink input[type=checkbox]:checked ~ .ripple { .checkbox-material-pink input[type=checkbox]:checked ~ .check:after {
background-color: #e91e63; background-color: #e91e63;
} }
.checkbox-material-purple input[type=checkbox]:checked ~ .ripple { .checkbox-material-purple input[type=checkbox]:checked ~ .check:after {
background-color: #9c27b0; background-color: #9c27b0;
} }
.checkbox-material-deeppurple input[type=checkbox]:checked ~ .ripple { .checkbox-material-deeppurple input[type=checkbox]:checked ~ .check:after {
background-color: #673ab7; background-color: #673ab7;
} }
.checkbox-material-indigo input[type=checkbox]:checked ~ .ripple { .checkbox-material-indigo input[type=checkbox]:checked ~ .check:after {
background-color: #3f51b5; background-color: #3f51b5;
} }
.checkbox-material-lightblue input[type=checkbox]:checked ~ .ripple { .checkbox-material-lightblue input[type=checkbox]:checked ~ .check:after {
background-color: #03a9f4; background-color: #03a9f4;
} }
.checkbox-material-cyan input[type=checkbox]:checked ~ .ripple { .checkbox-material-cyan input[type=checkbox]:checked ~ .check:after {
background-color: #00bcd4; background-color: #00bcd4;
} }
.checkbox-material-teal input[type=checkbox]:checked ~ .ripple { .checkbox-material-teal input[type=checkbox]:checked ~ .check:after {
background-color: #009688; background-color: #009688;
} }
.checkbox-material-lightgreen input[type=checkbox]:checked ~ .ripple { .checkbox-material-lightgreen input[type=checkbox]:checked ~ .check:after {
background-color: #8bc34a; background-color: #8bc34a;
} }
.checkbox-material-lime input[type=checkbox]:checked ~ .ripple { .checkbox-material-lime input[type=checkbox]:checked ~ .check:after {
background-color: #cddc39; background-color: #cddc39;
} }
.checkbox-material-lightyellow input[type=checkbox]:checked ~ .ripple { .checkbox-material-lightyellow input[type=checkbox]:checked ~ .check:after {
background-color: #ffeb3b; background-color: #ffeb3b;
} }
.checkbox-material-orange input[type=checkbox]:checked ~ .ripple { .checkbox-material-orange input[type=checkbox]:checked ~ .check:after {
background-color: #ff9800; background-color: #ff9800;
} }
.checkbox-material-deeporange input[type=checkbox]:checked ~ .ripple { .checkbox-material-deeporange input[type=checkbox]:checked ~ .check:after {
background-color: #ff5722; background-color: #ff5722;
} }
.checkbox-material-grey input[type=checkbox]:checked ~ .ripple { .checkbox-material-grey input[type=checkbox]:checked ~ .check:after {
background-color: #9e9e9e; background-color: #9e9e9e;
} }
.checkbox-material-bluegrey input[type=checkbox]:checked ~ .ripple { .checkbox-material-bluegrey input[type=checkbox]:checked ~ .check:after {
background-color: #607d8b; background-color: #607d8b;
} }
.checkbox-material-brown input[type=checkbox]:checked ~ .ripple { .checkbox-material-brown input[type=checkbox]:checked ~ .check:after {
background-color: #795548; background-color: #795548;
} }
.checkbox-material-lightgrey input[type=checkbox]:checked ~ .ripple { .checkbox-material-lightgrey input[type=checkbox]:checked ~ .check:after {
background-color: #ececec; background-color: #ececec;
} }
@-webkit-keyframes uncheck { @-webkit-keyframes uncheck {
@ -1175,7 +1183,7 @@ select[multiple].form-control.focus {
height: 18px; height: 18px;
width: 100px; width: 100px;
margin-top: -1px; margin-top: -1px;
top: 25%; top: 7px;
left: 0; left: 0;
pointer-events: none; pointer-events: none;
opacity: 0.9; opacity: 0.9;
@ -1665,6 +1673,17 @@ select.form-control.focus {
opacity: 0; opacity: 0;
} }
} }
.form-control-wrapper input[type=file] {
opacity: 0;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100;
}
legend { legend {
border-bottom: 0; border-bottom: 0;
} }
@ -2377,6 +2396,40 @@ fieldset[disabled] .navbar .btn-link:focus {
.navbar-inverse { .navbar-inverse {
background-color: #3f51b5; background-color: #3f51b5;
} }
.navbar-material-white {
background-color: #FFF;
}
.navbar-material-white .navbar-brand,
.navbar-material-white .navbar-brand:hover,
.navbar-material-white .navbar-brand:focus {
color: rgba(0, 0, 0, 0.84);
}
.navbar-material-white .navbar-nav > li > a {
color: rgba(0, 0, 0, 0.84);
}
.navbar-material-white .navbar-nav > li > a:hover,
.navbar-material-white .navbar-nav > li > a:focus {
color: rgba(0, 0, 0, 0.84);
background-color: transparent;
}
.navbar-material-white .navbar-nav > .active > a,
.navbar-material-white .navbar-nav > .active > a:hover,
.navbar-material-white .navbar-nav > .active > a:focus {
color: rgba(0, 0, 0, 0.84);
background-color: rgba(0, 0, 0, 0.05);
}
.navbar-material-white .navbar-nav > .disabled > a,
.navbar-material-white .navbar-nav > .disabled > a:hover,
.navbar-material-white .navbar-nav > .disabled > a:focus {
color: rgba(0, 0, 0, 0.84);
background-color: transparent;
}
.navbar-material-white .navbar-nav > .open > a,
.navbar-material-white .navbar-nav > .open > a:hover,
.navbar-material-white .navbar-nav > .open > a:focus {
background-color: rgba(0, 0, 0, 0.05);
color: rgba(0, 0, 0, 0.84);
}
.dropdown-menu { .dropdown-menu {
border: 0; border: 0;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26); box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);

View File

@ -5,10 +5,10 @@ $(function (){
ripples.init(".btn:not(.btn-link), .navbar a, .nav-tabs a, .withripple"); ripples.init(".btn:not(.btn-link), .navbar a, .nav-tabs a, .withripple");
// Add fake-checkbox to material checkboxes // Add fake-checkbox to material checkboxes
$(".checkbox label input").after("<span class=ripple></span><span class=check></span>"); $(".checkbox > label > input").after("<span class=check></span>");
// Add fake-radio to material radios // Add fake-radio to material radios
$(".radio label input").after("<span class=ripple></span><span class=circle></span><span class=check></span>"); $(".radio > label > input").after("<span class=ripple></span><span class=circle></span><span class=check></span>");
// Add elements for material inputs // Add elements for material inputs
$("input.form-control, textarea.form-control, select.form-control").each( function() { $("input.form-control, textarea.form-control, select.form-control").each( function() {
@ -22,6 +22,12 @@ $(function (){
if ($(this).val() === "") { if ($(this).val() === "") {
$(this).addClass("empty"); $(this).addClass("empty");
} }
if ($(this).parent().next().is("[type=file]")) {
$(this).parent().addClass("fileinput");
var $input = $(this).parent().next().detach();
$(this).after($input);
}
}); });
$(document).on("keyup change", ".form-control", function() { $(document).on("keyup change", ".form-control", function() {
@ -31,7 +37,28 @@ $(function (){
$(this).addClass("empty"); $(this).addClass("empty");
} }
}); });
$(document).on("keydown", ".form-control", function() { $(document).on("keydown change", ".form-control", function() {
$(this).removeClass("empty"); $(this).removeClass("empty");
}); });
$(document)
.on("focus", ".form-control-wrapper.fileinput", function() {
$(this).find("input").addClass("focus");
})
.on("blur", ".form-control-wrapper.fileinput", function() {
$(this).find("input").removeClass("focus");
})
.on("change", ".form-control-wrapper.fileinput [type=file]", function() {
var value = "";
$.each($(this)[0].files, function(i, file) {
console.log(file);
value += file.name + ", ";
});
value = value.substring(0, value.length - 2);
if (value) {
$(this).prev().removeClass("empty");
} else {
$(this).prev().addClass("empty");
}
$(this).prev().val(value);
});
}); });