Skip to content

Instantly share code, notes, and snippets.

@Farmatique
Farmatique / gist:eb342bd79af331bb256d19055bf13f7d
Created January 26, 2017 17:01
Bootstrap 3.3.6 close popver by clicking outside of it
$(document).on('click', function (e) {
$('[data-toggle="popover"],[data-original-title]').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
(($(this).popover('hide').data('bs.popover')||{}).inState||{}).click = false // fix for BS 3.3.6
}
});
});
@Farmatique
Farmatique / gist:e21f8e9be7ffc2669008ae93f715792e
Created January 31, 2017 13:29
Wordpress back to homepage
<a href="<?php echo home_url(); ?>">Home</a>
$(document).ready(function() {
$('.hover').bind('touchstart touchend', function(e) {
e.preventDefault();
$(this).toggleClass('hover_effect');
});
});
element:hover, element.hover_effect {
rule:properties;
}
@Farmatique
Farmatique / gist:cbbaf45d2c73fdb6af760ac452a05ac6
Created February 9, 2017 12:20
submit button instead input in contact form 7
<button id='submit' class='wpcf7-form-control wpcf7-submit'>SUBMIT <span class='glyphicon glyphicon-menu-right'></span></button>
@Farmatique
Farmatique / gist:ac539e32ac75594fe7c6b145cd689d15
Created February 15, 2017 12:55
Big clickable Play button overlay for video
<div class="wrapper">
<video class="video">
<source src="http://e14aaeb709f7cde1ae68-a1d0a134a31b545b257b15f8a8ba5726.r70.cf3.rackcdn.com/projects/31432/1427815464209-bf74131a7528d0ea5ce8c0710f530bb5/1280x720.mp4" type="video/mp4" />
</video>
<div class="playpause"></div>
</div>
$('.video').parent().click(function () {
if($(this).children(".video").get(0).paused){
$(this).children(".video").get(0).play();
@Farmatique
Farmatique / gist:500a770fee048bdd7c41357b34c411b5
Created February 21, 2017 13:58
show/hide controls on hover for video element
jQuery("video").hover(function(event) {
if(event.type === "mouseenter") {
jQuery(this).attr("controls", "");
} else if(event.type === "mouseleave") {
jQuery(this).removeAttr("controls");
}
});
@Farmatique
Farmatique / gist:b713b23a1bba3595c15399c830971d60
Last active February 24, 2017 16:52
mobile ios fix - prevent hover on first click
jQuery('a').on('click touchend', function(e) {
var el = jQuery(this);
var link = el.attr('href');
window.location = link;
});
Нужно помнить, что это повлияет на все ссылки <a>, в частности те что открываются в новом окне будут тоже открываться в том же
@Farmatique
Farmatique / gist:47b3d912f8d798df76b2d8823d6e601c
Created February 27, 2017 16:48
forced word breaks or word wrap
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
@Farmatique
Farmatique / gist:e589ceef0153b2b9c1ad14225e71c762
Created March 3, 2017 11:50
Phone format disable in mobile safari ios
<meta name = "format-detection" content = "telephone=no">
@Farmatique
Farmatique / gist:d6aa1fe9e5d6b15052ec17a9afa0cf6f
Last active March 3, 2017 18:46
Center image <img> inside block
/* doesnt work on ios */
<div class="container">
<img />
</div>
.container{
width: 70px;
height: 70px;
-webkit-display: flex;