Skip to content

Instantly share code, notes, and snippets.

View bratsun's full-sized avatar

Max Bratsun bratsun

View GitHub Profile
@bratsun
bratsun / get_view_rows.php
Last active December 26, 2015 20:58
Embed view with args
$view = views_get_view('opengraph');
$display_id = 'default';
$view->set_display($display_id);
//$view->set_arguments(array($element['#object']->nid));
$view->execute();
//print dpr($view->result);
print $view->result[0]->node_title;
@bratsun
bratsun / center_align.js
Created November 1, 2013 17:41
Center align with top margin.
$('img').each(function () {
var $this = $(this);
var parentH = $this.parent().height();
var H = parentH - $this.height();
$this.css('margin-top',H / 2);
});
@bratsun
bratsun / responsive-video.css
Created November 19, 2013 11:24
Responsive video in iframe
/* parent */
.youtube-url .field-item {
height: 0;
padding-bottom: 53.25%;
padding-top: 25px;
position: relative;
}
/* video iframe */
.youtube-url iframe {
@bratsun
bratsun / remove_2nd_pass_on_registration.php
Created November 26, 2013 18:58
Remove second password field (Confirm password) on registration page
// remove second password field (Confirm password) on registration page
function tmplt_form_user_register_form_alter(&$form, &$form_state, $form_id) {
$form['account']['pass']['#type'] = 'password';
$form['account']['pass']['#title'] = 'Password';
}
@bratsun
bratsun / form_placeholder.css
Created November 26, 2013 19:13
Form placeholder styling
.form-control::-webkit-input-placeholder {
color: #000;
}
.form-control:-moz-placeholder {
color: #000;
}
.form-control::-moz-placeholder {
color: #000;
}
.form-control:-ms-input-placeholder {
@bratsun
bratsun / chrome_fix
Created November 30, 2013 09:20
Chrome fix for fixed elements (distortion on scroll, enable hardware acceleration to get rid of it)
.sticky-nav {
-webkit-transform: translateZ(0);
}
@bratsun
bratsun / navigate.js
Created November 30, 2013 18:43
Navigate to URL
window.location = window.location.protocol + '//' + window.location.hostname + '/path';
@bratsun
bratsun / h2_from_field.php
Last active October 11, 2016 08:31
Formatter: H2 from text or computed field (exported custom formatter)
$formatter = new stdClass();
$formatter->disabled = FALSE; /* Edit this to true to make a default formatter disabled initially */
$formatter->api_version = 2;
$formatter->name = 'h2_from_field';
$formatter->label = 'H2 from field';
$formatter->description = '';
$formatter->mode = 'php';
$formatter->field_types = 'text, computed';
$formatter->code = '$output = \'\';
foreach ($variables[\'#items\'] as $item) {
@bratsun
bratsun / scroller.js
Created January 29, 2014 08:03
Smooth scroller with hash
// scroller for h2 titles
$('.f-faqs h2').each(function() {
$this = $(this);
$this.attr('id',$this.text().split(' ').join('').toLowerCase());
});
var curUrl = window.location.pathname;
$('a.mm-scroll').each(function() {
@bratsun
bratsun / bootstrap_tab_bind.js
Created January 29, 2014 11:31
Bind on click event to bootstrap tab nav
$(document).on( 'shown.bs.tab', 'a[data-toggle="tab"]', function (e) {
//do.stuff
document.getElementById('yt-vid-1').stopVideo();
});