Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃
working ...

Dimas Begunoff farinspace

🙃
working ...
View GitHub Profile
@farinspace
farinspace / color_picker
Created Sep 27, 2014
Using a color picker with WPAlchemy
View color_picker
jQuery(function($){
var picker_config = {
onSubmit: function(hsb, hex, rgb, el) {
$(el).val(hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
},
onChange: function (hsb, hex, rgb) {
@farinspace
farinspace / isPositionFixed
Created Sep 29, 2014
Javascript function to check if an element and/or its parents position is set to fixed
View isPositionFixed
isPositionFixed = function (selector, traverseAncestors) {
var el = $(selector);
if (el.length) {
if (!traverseAncestors) {
return 'fixed' === el.css('position') ? true : false ;
}
var isFixed = false;
var els = el.add(el.parents());
els.each(function() {
if ('fixed' === $(this).css('position')) {
@farinspace
farinspace / SassMeister-input.scss
Created Oct 31, 2014
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// Sass (v3.4.6)
// Compass (v1.0.1)
// ----
@mixin size($size) {
$height: nth($size, 1);
$width: $height;
@if length($size) > 1 {
$height: nth($size, 2);
View wpalchemy_time_ago
<?php
// src: http://www.sajithmr.me/php-time-ago-calculation/
function wpalchemy_time_ago($datefrom,$dateto=-1)
{
// Defaults and assume if 0 is passed in that
// its an error rather than the epoch
if($datefrom<=0) { return "A long time ago"; }
if($dateto==-1) { $dateto = time(); }
View Links metabox code
View functions.php
<?php
define('_TEMPLATEURL', WP_CONTENT_URL . '/themes/' . basename(TEMPLATEPATH));
include_once 'WPAlchemy/MetaBox.php';
if (is_admin()) wp_enqueue_style('custom_meta_css', _TEMPLATEURL . '/custom/meta.css');
$repeating_mb = new WPAlchemy_MetaBox(array
(
View repeating_fields_meta.php
<div class="my_meta_control">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras orci lorem, bibendum in pharetra ac, luctus ut mauris.</p>
<p><a href="#" class="dodelete-docs button">Remove All</a></p>
<?php while($mb->have_fields_and_multi('docs')): ?>
<?php $mb->the_group_open(); ?>
<a href="#" class="dodelete button">Remove</a>
View gist:822101
<?php $pages = get_pages(); ?>
<?php while( $mb->have_fields_and_multi( 'buttons' ) ) : ?>
<?php $mb->the_group_open(); ?>
<div class="button">
<a href="#" class="dodelete button">Remove</a>
<?php $mb->the_field('s_field'); ?>
<select name="<?php $mb->the_name(); ?>">
<option></option>
@farinspace
farinspace / repeating_fields.js
Created May 27, 2011
Repeating fields Javascript
View repeating_fields.js
// disable all fields in a template (so they do not get submitted)
$('.template').find('input, textarea, select, button').each(function()
{
$(this).attr('disabled', 'disabled');
});
function doRepeat(replace)
{
var container = $(this).closest('.container');
View repeating_fields_setup.html
<div class="container">
<div class="collection">
<div class="template" style="display:none;">
<input type="text" name="questions[%][question]" value="qq"/>
<input type="text" name="questions[%][type]" value="qt"/>
You can’t perform that action at this time.