Skip to content

Commit

Permalink
vimeo embed setting on homepage, homepage content and styles
Browse files Browse the repository at this point in the history
  • Loading branch information
bak11004 committed Apr 3, 2016
1 parent 4139bae commit bb15993
Show file tree
Hide file tree
Showing 19 changed files with 610 additions and 61 deletions.
3 changes: 2 additions & 1 deletion www/wp-content/themes/ation2016/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function loadScripts() {
wp_enqueue_script( 'imagesloaded', get_template_directory_uri() . '/static/scripts/imagesLoaded.min.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'isotope', get_template_directory_uri() . '/static/scripts/isotope.min.js', array('jquery', 'imagesloaded'), '1.0.0', true );
wp_enqueue_script( 'cells-by-row', get_template_directory_uri() . '/static/scripts/cells-by-row.min.js', array('jquery', 'isotope'), '1.0.0', true );
wp_enqueue_script( 'main', get_template_directory_uri() . '/static/scripts/main.min.js', array('jquery','isotope','cells-by-row', 'imagesloaded'), '1.0.0', true );
wp_enqueue_script( 'froogaloop', get_template_directory_uri() . '/static/scripts/froogaloop.min.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'main', get_template_directory_uri() . '/static/scripts/main.min.js', array('jquery','isotope','cells-by-row', 'imagesloaded', 'froogaloop' ), '1.0.0', true );
}

}
Expand Down
3 changes: 3 additions & 0 deletions www/wp-content/themes/ation2016/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
$context['work'] = Timber::get_posts( $work_args );
} else if ( $post->post_name === 'services' ) {
$context['services'] = Timber::get_terms('service');
} else if ( is_front_page() ) {
// Grab vimeo URL and it's ID to pass to embed.
$context['vimeo_id'] = substr( parse_url( $post->vimeo_url, PHP_URL_PATH ), 1 );
}

Timber::render( array( 'page-' . $post->post_name . '.twig', 'page.twig' ), $context );
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
260 changes: 260 additions & 0 deletions www/wp-content/themes/ation2016/src/scripts/froogaloop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
// Init style shamelessly stolen from jQuery http://jquery.com
var Froogaloop = (function(){
// Define a local copy of Froogaloop
function Froogaloop(iframe) {
// The Froogaloop object is actually just the init constructor
return new Froogaloop.fn.init(iframe);
}

var eventCallbacks = {},
hasWindowEvent = false,
isReady = false,
slice = Array.prototype.slice,
playerOrigin = '*';

Froogaloop.fn = Froogaloop.prototype = {
element: null,

init: function(iframe) {
if (typeof iframe === "string") {
iframe = document.getElementById(iframe);
}

this.element = iframe;

return this;
},

/*
* Calls a function to act upon the player.
*
* @param {string} method The name of the Javascript API method to call. Eg: 'play'.
* @param {Array|Function} valueOrCallback params Array of parameters to pass when calling an API method
* or callback function when the method returns a value.
*/
api: function(method, valueOrCallback) {
if (!this.element || !method) {
return false;
}

var self = this,
element = self.element,
target_id = element.id !== '' ? element.id : null,
params = !isFunction(valueOrCallback) ? valueOrCallback : null,
callback = isFunction(valueOrCallback) ? valueOrCallback : null;

// Store the callback for get functions
if (callback) {
storeCallback(method, callback, target_id);
}

postMessage(method, params, element);
return self;
},

/*
* Registers an event listener and a callback function that gets called when the event fires.
*
* @param eventName (String): Name of the event to listen for.
* @param callback (Function): Function that should be called when the event fires.
*/
addEvent: function(eventName, callback) {
if (!this.element) {
return false;
}

var self = this,
element = self.element,
target_id = element.id !== '' ? element.id : null;


storeCallback(eventName, callback, target_id);

// The ready event is not registered via postMessage. It fires regardless.
if (eventName != 'ready') {
postMessage('addEventListener', eventName, element);
}
else if (eventName == 'ready' && isReady) {
callback.call(null, target_id);
}

return self;
},

/*
* Unregisters an event listener that gets called when the event fires.
*
* @param eventName (String): Name of the event to stop listening for.
*/
removeEvent: function(eventName) {
if (!this.element) {
return false;
}

var self = this,
element = self.element,
target_id = element.id !== '' ? element.id : null,
removed = removeCallback(eventName, target_id);

// The ready event is not registered
if (eventName != 'ready' && removed) {
postMessage('removeEventListener', eventName, element);
}
}
};

/**
* Handles posting a message to the parent window.
*
* @param method (String): name of the method to call inside the player. For api calls
* this is the name of the api method (api_play or api_pause) while for events this method
* is api_addEventListener.
* @param params (Object or Array): List of parameters to submit to the method. Can be either
* a single param or an array list of parameters.
* @param target (HTMLElement): Target iframe to post the message to.
*/
function postMessage(method, params, target) {
if (!target.contentWindow.postMessage) {
return false;
}

var data = JSON.stringify({
method: method,
value: params
});

target.contentWindow.postMessage(data, playerOrigin);
}

/**
* Event that fires whenever the window receives a message from its parent
* via window.postMessage.
*/
function onMessageReceived(event) {
var data, method;

try {
data = JSON.parse(event.data);
method = data.event || data.method;
}
catch(e) {
//fail silently... like a ninja!
}

if (method == 'ready' && !isReady) {
isReady = true;
}

// Handles messages from the vimeo player only
if (!(/^https?:\/\/player.vimeo.com/).test(event.origin)) {
return false;
}

if (playerOrigin === '*') {
playerOrigin = event.origin;
}

var value = data.value,
eventData = data.data,
target_id = target_id === '' ? null : data.player_id,

callback = getCallback(method, target_id),
params = [];

if (!callback) {
return false;
}

if (value !== undefined) {
params.push(value);
}

if (eventData) {
params.push(eventData);
}

if (target_id) {
params.push(target_id);
}

return params.length > 0 ? callback.apply(null, params) : callback.call();
}


/**
* Stores submitted callbacks for each iframe being tracked and each
* event for that iframe.
*
* @param eventName (String): Name of the event. Eg. api_onPlay
* @param callback (Function): Function that should get executed when the
* event is fired.
* @param target_id (String) [Optional]: If handling more than one iframe then
* it stores the different callbacks for different iframes based on the iframe's
* id.
*/
function storeCallback(eventName, callback, target_id) {
if (target_id) {
if (!eventCallbacks[target_id]) {
eventCallbacks[target_id] = {};
}
eventCallbacks[target_id][eventName] = callback;
}
else {
eventCallbacks[eventName] = callback;
}
}

/**
* Retrieves stored callbacks.
*/
function getCallback(eventName, target_id) {
if (target_id) {
return eventCallbacks[target_id][eventName];
}
else {
return eventCallbacks[eventName];
}
}

function removeCallback(eventName, target_id) {
if (target_id && eventCallbacks[target_id]) {
if (!eventCallbacks[target_id][eventName]) {
return false;
}
eventCallbacks[target_id][eventName] = null;
}
else {
if (!eventCallbacks[eventName]) {
return false;
}
eventCallbacks[eventName] = null;
}

return true;
}

function isFunction(obj) {
return !!(obj && obj.constructor && obj.call && obj.apply);
}

function isArray(obj) {
return toString.call(obj) === '[object Array]';
}

// Give the init function the Froogaloop prototype for later instantiation
Froogaloop.fn.init.prototype = Froogaloop.fn;

// Listens for the message event.
// W3C
if (window.addEventListener) {
window.addEventListener('message', onMessageReceived, false);
}
// IE
else {
window.attachEvent('onmessage', onMessageReceived);
}

// Expose froogaloop to the global object
return (window.Froogaloop = window.$f = Froogaloop);

})();
33 changes: 7 additions & 26 deletions www/wp-content/themes/ation2016/src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,12 @@ jQuery( document ).ready( function( $ ) {
console.log('Filtered by', filter);
});

// Make service items same height
// var $list = $( '.services .row' ),
// $items = $list.find( '.service' ),
// setHeights = function()
// {
// $items.css( 'height', 'auto' );

// var perRow = Math.floor( $list.width() / $items.width() );
// if( perRow == null || perRow < 2 ) return true;

// for( var i = 0, j = $items.length; i < j; i += perRow )
// {
// var maxHeight = 0,
// $row = $items.slice( i, i + perRow );

// $row.each( function()
// {
// var itemHeight = parseInt( $( this ).outerHeight() );
// if ( itemHeight > maxHeight ) maxHeight = itemHeight;
// });
// $row.css( 'height', maxHeight );
// }
// };

// setHeights();
// $( window ).on( 'resize', setHeights );
// Mute autoplay vimeo embed
var video_iframe= $("#vimeo_player")[0];
var player = $f(video_iframe);
player.addEvent('ready', function() {
console.log('muting vimeo');
player.api('setVolume', 0);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ html, body {
.home-bg {
height: 100%;
width: 100%;
margin-bottom: 40px;
}

$video-height: $header-height;
Expand Down
2 changes: 2 additions & 0 deletions www/wp-content/themes/ation2016/src/styles/site.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ $header-height-sticky: 70px;
@import 'components/services';
@import 'components/footer';

@import 'utility/buttons';
@import 'utility/images';
@import 'utility/embeds';
@import 'utility/utility';

body {
background-color: $white;
Expand Down
18 changes: 18 additions & 0 deletions www/wp-content/themes/ation2016/src/styles/utility/_buttons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.ation-btn {
border: 3px solid $white;
color: $white;
background-color: $orange;
transition: 0.2s;
text-transform: uppercase;
padding: 10px;
font-size: 20px;
font-family: $header-font;
margin-bottom: 20px;
text-align: center;
&:hover {
color: $orange;
background-color: $white;
border-color: $orange;
text-decoration: none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ img {
max-width: 100%;
display: block;
height: auto;
&.aligncenter {
margin: auto;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.marg-bot-40 {
margin-bottom: 40px;
}
Loading

0 comments on commit bb15993

Please sign in to comment.