Skip to content

Instantly share code, notes, and snippets.

View bratsun's full-sized avatar

Max Bratsun bratsun

View GitHub Profile
@bratsun
bratsun / vimeo_youtube_embed.js
Created November 11, 2014 12:55
Turn Vimeo or YouTube URL into embedded video
// vimeo links
$('a[href*="vimeo.com"]').each(function() {
$this = $(this);
var href = '//player.vimeo.com/video/' + $this.attr('href').split('/').pop();
$this.before('<div class="video-embed"><iframe src="//player.vimeo.com/video/'+$this.attr('href').split('/').pop()+'?autoplay=0&amp;title=0&amp;byline=0&amp;color=1A9691&amp;portrait=0&amp;hd_off=0" width="600" height="337.5" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>');
});
@bratsun
bratsun / svg_background_replace.js
Created November 16, 2014 11:07
Replace background image with inline SVG
$(window).load(function() {
$('.shareme a, .social-link').each(function() {
var t = $(this);
var url = t.css('background-image').replace('url("','').replace('")','');
t.load(url,function() {
t.addClass('loaded');
});
});
});
@bratsun
bratsun / al_ext_links_new_window.js
Created November 17, 2014 08:10
Open all external links in new window
@bratsun
bratsun / youtube_by_id.js
Created May 19, 2015 08:04
Embed, start and control youtube video by ID
// init player, set vars
var player = {
playVideo: function(container, videoId) {
if (typeof(YT) == 'undefined' || typeof(YT.Player) == 'undefined') {
window.onYouTubePlayerAPIReady = function() {
player.loadPlayer(container, videoId);
};
$.getScript('//www.youtube.com/player_api');
} else {
@bratsun
bratsun / bootstrap_clearfix.css
Created July 16, 2015 17:21
Bootstrap clearfix
/* Bootstrap Clearfix */
/* Tablet */
@media (min-width:767px){
/* Column clear fix */
.col-lg-1:nth-child(12n+1),
.col-lg-2:nth-child(6n+1),
.col-lg-3:nth-child(4n+1),
.col-lg-4:nth-child(3n+1),
$button = field_view_field('node', $node, 'field_author');
$button['#title'] = '';
print render($button);
$block = module_invoke('module', 'block_view', 'delta');
print render($block['content']);
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-webkit-transition: all 0.3s;
-o-transition: all 0.3;
transition: all 0.3s;
background: -webkit-gradient(linear, left top, right top, from(#000000), to(#000000));
background: -webkit-linear-gradient(top, #000000, #000000);
background: -moz-linear-gradient(top, #000000, #000000);
background: -o-linear-gradient(top, #000000, #000000);
background: -ms-linear-gradient(top, #000000, #000000);
background: linear-gradient(top, #000000, #000000);
background-color: #000000;
@bratsun
bratsun / Get image URL from URI.php
Created October 5, 2013 07:35
Print image / image URL
file_create_url($image[0]['uri']);