live-server /public
babel src/app.js --out-file=public/scripts/app.js --presets=env,react
(function($) { | |
Drupal.behaviors.myModule = { | |
'attach': function(context) { | |
$('#edit-field', context).click(function(e) { | |
$.ajax({ | |
url: 'http://www.example.com', | |
success: function(data) { | |
console.log(data); | |
}, | |
error: function(data) { |
<?php | |
/** | |
* Loops through string to detect multiple encoding to be able to decode all levels. | |
* | |
* @param String $string | |
* The string you want to detect encoding on to be able to decode all its levels. | |
* | |
* @return String $string | |
* Clean decoded string. | |
*/ |
<?php | |
/** | |
* Helper function to hide group and sub groups from a form. | |
* | |
* @param $form | |
* Reference to a nested array of form elements that comprise the form. | |
* @param $group_names | |
* Array containing the names of the groups you want to hide. | |
*/ | |
function field_group_hide_field_groups(&$form, $group_names) { |
<?php | |
class FieldChangeHelper { | |
/** | |
* Change a field's type, even if it has data. | |
* | |
* @param $field_name | |
* The name of the field to change. | |
* @param $type |
This will enable an additional view mode for use on the specified entity type(s). Many examples will show the custom settings
here being set to TRUE. If TRUE is used then that view mode is added to all entities of the specified type regardless of if it should be on the bundle or not.
/**
* Implements hook_entity_info_alter().
*/
function HOOK_entity_info_alter(&$entity_info) {
<?php | |
/** | |
* @file | |
* Drush commands for displaying info on fields and field instances. | |
* | |
* To use, save this file as drush_field_config.drush.inc in your home directory's .drush/ folder. | |
*/ | |
/** | |
* Implements hook_drush_command(). |
<?php | |
/* | |
* Utility to change the max length of a text field | |
*/ | |
function change_text_field_max_length($field_name, $new_length) { | |
$field_table = 'field_data_' . $field_name; | |
$field_revision_table = 'field_revision_' . $field_name; | |
$field_column = $field_name . '_value'; | |
// Alter value field length in fields table |
function determineIfSmallSize(redirect_url) { | |
// Detect pixel ratio for true resolution | |
window.dpr = 1; | |
if(window.devicePixelRatio !== undefined) { | |
window.dpr = window.devicePixelRatio; | |
} | |
// Screen orientation - innerWidth and innerHeight works for any device and its orientation, including desktops |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |