This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
// | |
// Automatically calls all functions in APP.init | |
// | |
jQuery(document).ready(function() { | |
APP.go(); | |
}); | |
// | |
// Module pattern: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Helper function; removes all required element flags on a section of a form. | |
* | |
* @param array $element | |
* A form or section of a form. | |
* | |
* @return array | |
* A section of a form tree with #required = 0 everyehere. | |
*/ | |
function example_remove_required($element) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkPlain(str) { | |
var length, | |
r = new RegExp('(&)|(\")|(<)|(>)|([^&\"<>]*)', 'g') | |
replacements = ["&", """, "<", ">"], | |
retval = '', | |
match = r.exec(str); | |
while (match[0] != "") { | |
length = match.length; | |
for (var i = 1; i < length; ++i) { | |
if (match[i] != undefined) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_form_alter(). | |
* | |
* Courtesy of JohnAlbin | |
*/ | |
function THEMENAME_form_search_block_form_alter(&$form, &$form_state) { | |
$form['actions']['submit']['#type'] = 'image_button'; | |
$form['actions']['submit']['#src'] = drupal_get_path('theme', 'THEMENAME') . '/images/button-search.png'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here we use a similar set of variables passed in as jQuery. The lone difference is | |
// the inclusion of the Drupal variable. We pass in the global variables we use which | |
// provides proper dependency injection and for compressors to have names that can be | |
// more easily shrunk. | |
(function($, Drupal, window, document, undefined) { | |
Drupal.sitetheme = Drupal.sitetheme || {}; | |
/* | |
* Initialize placeholder functionality on a text based input element. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.support.positionFixed = (function () { | |
var el, support, | |
body = document.body || document.getElementsByTagName("body")[0] || document.documentElement; | |
// Boolean indicating whether or not "position: fixed" is supported. | |
// Using the DOM to create an element is much faster than using jQuery. | |
el = document.createElement("div"); | |
el.style.position = "fixed"; | |
el.style.top = "10px"; | |
el.style.visibility = "hidden"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_tokens_alter(array &$replacements, array $context) { | |
$options = $context['options']; | |
$sanitize = !empty($options['sanitize']); | |
if ($context['type'] == 'node' && !empty($context['data']['node'])) { | |
$node = $context['data']['node']; | |
foreach ($context['tokens'] as $name => $original) { | |
switch ($name) { | |
case 'title': | |
$title = !empty($options['pathauto']) ? strip_tags($node->title) : $node->title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implementation of hook_preprocess_image(). | |
* | |
* Make images that use a full url be protocol relative. | |
*/ | |
function custom_preprocess_image(&$variables) { | |
// If the image URL starts with a protocol remove it and use a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_file_url_alter(). | |
* | |
* Make all URLs be protocol relative. | |
* Note: protocol relatice URLs will cause IE7/8 to download stylesheets twice. | |
* @see http://www.stevesouders.com/blog/2010/02/10/5a-missing-schema-double-download/ | |
*/ | |
function custom_file_url_alter(&$url) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sequel' | |
require 'fileutils' | |
require 'yaml' | |
# NOTE: This converter requires Sequel and the MySQL gems. | |
# The MySQL gem can be difficult to install on OS X. Once you have MySQL | |
# installed, running the following commands should work: | |
# $ sudo gem install sequel | |
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config |
OlderNewer