Skip to content

Instantly share code, notes, and snippets.

@alatzl
alatzl / theme-settings.php
Created June 20, 2013 21:00
Adds theme setting for enabling livereload.
/**
* Implements hook_form_system_theme_settings_alter()
*/
function drupal_theme_template_form_system_theme_settings_alter(&$form, $form_state) {
$form['dtt_enable_livereload'] = array(
'#type' => 'checkbox',
'#title' => t('Enable livereload'),
'#default_value' => theme_get_setting('dtt_enable_livereload'),
'#description' => t("For development use only."),
);
@alatzl
alatzl / template.php
Created June 20, 2013 21:04
Adds livereload js file based on theme setting.
/**
* Adds the livereload javascript so we don't need the browser extension.
*/
if (theme_get_setting('dtt_enable_livereload')==true) {
global $base_url;
$output = $base_url . '/';
$output .= drupal_get_path('theme', 'drupal_theme_template') . '/assets/javascripts/vendor/livereload.js?';
// $output .= 'host=' . parse_url($base_url, PHP_URL_HOST);
@alatzl
alatzl / PhoneGapBlogPost_Ex2.css
Last active December 30, 2015 22:08
Adding hardware-accelerated slide transitions.
.nav-drawer, .inner-wrap {
-webkit-transform: translate3d(0,0,0);
-moz-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
-o-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
-webkit-transition: transform 400ms ease
-moz-transition: transform 400ms ease
-o-transition: transform 400ms ease
transition: transform 400ms ease;
@alatzl
alatzl / PhoneGapBlogPost_Ex3.css
Last active December 30, 2015 22:09
Smoothing hardware-accelerated transitions
.nav-drawer, .inner-wrap {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
@alatzl
alatzl / PhoneGapBlogPost_Ex4.css
Last active December 30, 2015 22:08
Adding momentum scrolling via CSS.
.nav-drawer, .inner-wrap {
-webkit-overflow-scrolling: touch;
overflow-y: scroll;
}
@alatzl
alatzl / PhoneGapBlogPost_Ex1.css
Created December 10, 2013 22:05
CSS3 3d Transform
-webkit-transform: translate3d(0,0,0);
-moz-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
-o-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
@alatzl
alatzl / ServiceExample1.js
Last active August 29, 2015 14:19
Writing Angular with Migration in Mind: Ex. 1
angular.module('myModule')
.service('addresses', ['addressService', '$q', function(addressService, $q) {
this.prefix = 'My Address: ';
this.printAddress = function() {
var deferred = $q.defer(),
self = this;
addressService.getFullAddress(function(addr) {
deferred.resolve(self.prefix + addr);
@alatzl
alatzl / ServiceExample2.js
Last active August 29, 2015 14:19
Writing Angular with Migration in Mind: Ex. 1
angular.module('myModule')
.service('addresses', ['addressService', '$q', Addresses]);
class Addresses {
constructor(addressService, $q) {
this.$q = $q;
this.addressService = addressService;
this.prefix = "My Address: "
}
printAddress() {
@alatzl
alatzl / DirectiveExample1.js
Last active August 29, 2015 14:19
Writing Angular with Migration in Mind: Ex. 3
angular.module('myModule')
.directive('roar', function() {
return {
restrict: 'E',
scope: {
dinoType: '@'
},
template: '<p>I am a {{ getType }}, hear me ROAR!</p>',
link: function(scope) {
scope.getType = function() {
@alatzl
alatzl / DirectiveExample2.js
Last active August 29, 2015 14:19
Writing Angular with Migration in Mind: Ex. 4
angular.module('myModule')
.directive('roar', function() {
return {
restrict: 'E',
scope: {},
controller: roarCtrl,
controllerAs: dinoRoar,
bindToController: {
dinoType: '@'
}