Skip to content

Instantly share code, notes, and snippets.

View brettbartylla's full-sized avatar

brettbartylla

View GitHub Profile
@brettbartylla
brettbartylla / mailer.php
Created September 6, 2017 02:05
PHP file that builds a message and then emails the data that comes from a form submission
<?php
// Only process POST reqeusts.
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the form fields and remove whitespace.
$name = strip_tags(trim($_POST["name"]));
$name = str_replace(array("\r","\n"),array(" "," "),$name);
$email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
$message = trim($_POST["message"]);
@brettbartylla
brettbartylla / navScroll.js
Created September 6, 2017 01:58
Snippet of jQuery that is triggered when the navigation link with corresponding id is clicked. This will result in scrolling to an anchor that is placed in the HTML.
//scroll from nav to anchor on page
$("#navLink").click(function() {
$('html, body').animate({
scrollTop: $("#anchor").offset().top
}, 1200);
});
@brettbartylla
brettbartylla / hexToRGBA.js
Last active September 6, 2017 00:11
This javascript/jQuery converts color and transparency options selected from a CMS configuration page and converts the values from hex to RGBA so the transparency option that was selected can work.
(function (context) {
'use strict';
var require = context.require;
var requirejs = context.requirejs;
var define = context.define;
define(function (require) {
//define any required libraries - see config.js for registered names
var $ = require('jquery'), //require jQuery
util = require('lib/Util'), //require util for $debug
@brettbartylla
brettbartylla / inlineVideoPlayer.js
Created September 6, 2017 00:03
jQuery I wrote that dynamically builds HTML5 players and inserts them inline on a page. Video content (IDs) came from Brightcove. I've removed the original videos and am using hardcoded values for this example.
(function (context) {
'use strict';
var require = context.require;
var requirejs = context.requirejs;
var define = context.define;
define(['require','jquery','lib/Util','GlobalEventDispatcher','GlobalResizeListener'],function (require) {
//define any required libraries - see config.js for registered names
var $ = require('jquery'), //require jQuery
util = require('lib/Util'), //require util for $debug