Skip to content

Instantly share code, notes, and snippets.

View bratsun's full-sized avatar

Max Bratsun bratsun

View GitHub Profile
@bratsun
bratsun / callbacks-views.js
Created October 18, 2013 23:23
AJAX callbacks
Drupal.behaviors.AjaxChecker = {
attach: function(context, settings) {
$('#views-exposed-form-prods-page').ajaxComplete(function(event, xhr, settings) {
$('.loader').hide(0);
});
}
}
@bratsun
bratsun / messages.php
Created October 19, 2013 00:38
Messages hook - one message is also a list (ul)
function theme_status_messages($variables) {
$display = $variables['display'];
$output = '';
$status_heading = array(
'status' => t('Status message'),
'error' => t('Error message'),
'warning' => t('Warning message'),
);
foreach (drupal_get_messages($display) as $type => $messages) {
@bratsun
bratsun / webformSelect.js
Created October 19, 2013 01:29
Alter selects to grey out on default value and to light up on change
function webformSelect() {
$('.webform-component-select').each(function() {
var t = $(this);
var text = t.find('label').text().replace(' *','');
t.find('option:first').addClass('first').text('Select ' + text);
t.find('select').live('change', function () {
if($(this).find('option:selected').hasClass('first')) $(this).addClass('idle');
else $(this).removeClass('idle');
});
t.find('select').change();
@bratsun
bratsun / seven_format_type.css
Created October 24, 2013 16:45
Hide annoying text format tips and ckeditor switch link.
.ckeditor_links,
.filter-guidelines,
.filter-help,
.filter-wrapper .form-type-select label {
display: none !important;
}
@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);
}