Skip to content

Instantly share code, notes, and snippets.

@Farmatique
Farmatique / gist:f011cf1b8961f9cae506225f7c39e77c
Created December 26, 2016 18:56
Select - option by default, then disabled
<option selected="true" disabled="disabled">Choose Tagging</option>
@Farmatique
Farmatique / gist:60f0d48a2e05f145456cd1b4feff34f7
Created December 27, 2016 15:12
Vendor prefixes for LESS
/*! Prefix flex for IE10 and Safari / iOS in LESS
* https://gist.github.com/codler/2148ba4ff096a19f08ea
* Copyright (c) 2014 Han Lin Yap http://yap.nu; MIT license */
.display(@value) when (@value = flex) {
display: -ms-flexbox; // IE10
display: -webkit-flex; // Safari / iOS
}
.display(@value) when (@value = inline-flex) {
@Farmatique
Farmatique / gist:3126c55123bb93e2b2277d445e3f55ca
Created December 27, 2016 16:35
Hide up/down arrows for input[type="number"]
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
/* display: none; <- Crashes Chrome on hover */
-webkit-appearance: none;
margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
}
@Farmatique
Farmatique / gist:5c48d1d9b5744117a94901f6ed84f7b5
Last active July 31, 2023 11:39
input[type="number"] plus/minus buttons
<div id="field1">
<button type="button" id="sub" class="sub">-</button>
<input type="text" id="1" value="0" class="field" />
<button type="button" id="add" class="add">+</button>
</div>
$('.add').click(function () {
$(this).prev().val(+$(this).prev().val() + 1);
});
$('.sub').click(function () {
@Farmatique
Farmatique / gist:3d97742109d92c075357db9252226c8e
Created December 30, 2016 16:04
jQuery scroll up scroll down detector
var lastScrollTop = 0;
$(window).scroll(function(event){
var st = $(this).scrollTop();
if (st > lastScrollTop){
// downscroll code
} else {
// upscroll code
}
lastScrollTop = st;
});
@Farmatique
Farmatique / gist:5524d7cf40162ca7a25a88ea2bb1047d
Created January 4, 2017 11:41
footer sticked to the bottom of the page
/* footer on bottom of the page */
html, body{
height: 100%;
}
.wrapper{
min-height: 100%;
position: relative;
section{
&:nth-last-child(2){
padding-bottom: @footerHeight + 75px !important;
jQuery(window).on('load', function () {
var $preloader = jQuery('#page-preloader'),
$spinner = $preloader.find('.spinner');
$spinner.fadeOut();
$preloader.delay(350).fadeOut('slow');
});
/* insert in the beggining of body or somewhere else */
<div id="page-preloader"><span class="spinner"></span></div>
@Farmatique
Farmatique / gist:c3879d453d3aab1ed74b2baa45b51f16
Created January 11, 2017 10:43
check if input is not empty
$('#your-input-selector').blur(function () {
var self = $(this);
if (self.val() != "") {
self.css('color','black'); // Set black fore color
}
else {
self.css('color','gray'); // Restore code
}
});
@Farmatique
Farmatique / gist:de60865d676f25a05567a9dc09a44cf9
Created January 11, 2017 12:31
Popover using bootstrap with custom html
<div id="myPopoverContent">
Custom html here
</div>
<a ng-href="" data-toggle="popover" data-placement="bottom" id="test"><span class="badge"></span>Click Here</a>
$('[data-toggle=popover]').popover({
content: $('#myPopoverContent').html(),
html: true
}).click(function() {
$(this).popover('show');
@Farmatique
Farmatique / gist:fd3af973313468462b246d86dd94718c
Created January 16, 2017 16:19
Right block stretch to remaining width, left block width depending on inner text
<div class="wrapper">
<div class="left">
here is thevery very very big text
</div>
<div class="right">one</div>
</div>
.wrapper{
background-color: green;
width: 100%;