Skip to content

Instantly share code, notes, and snippets.

View glideranderson's full-sized avatar

Robin Hjelmeir glideranderson

View GitHub Profile
@glideranderson
glideranderson / jquery.counter-2.0-update.js
Created October 11, 2011 15:22
Update to jquery.counter-2.0.js
/*! jQuery.counter.js (jQuery Character and Word Counter plugin)
v2.0 (c) Wilkins Fernandez
MIT License
*/
(function($) {
$.fn.extend({
counter : function(options) {
var defaults = {
type : 'char', // {char || word}
count : 'down', // count {up || down} from or to the goal number
@glideranderson
glideranderson / specials-ajax-issue.js
Last active September 27, 2015 16:37
Specials page grrr
/*
Specials Page
*/
if($j('.specials-wrapper').length > 0 ) {
$j('.specials-cat-nav li:first-child').addClass('active');
$j('.specials-page').find('.cat-wrapper').not(':first-child').hide();
$j('.specials-page .cat-wrapper:first-child').addClass('active');
// opening new section on click
$j('.specials-cat-nav li a').live('click', function(e) {
@glideranderson
glideranderson / wordpress loop
Created October 28, 2011 16:49
Wordpress loop within template file
<?php
$args = array( 'pagename' => 'contact');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<h2><?= the_title();?></h2>
<p><?= the_content(); ?></p>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
@glideranderson
glideranderson / tactic_loop
Created March 13, 2012 18:03
Rails Sidebar Tactic Loop
.sidebar
.sidebar-top.hide-on-phones
%dl.nice.vertical.tabs
- current_workplan.objectives.each do |o|
%dd.active
= link_to o, workplan_objective_path(current_workplan, o)
%span.arrows.hide-on-phones
%span.loop
%ul.children
- o.tactics.each do |t|
@glideranderson
glideranderson / payments.html
Created May 16, 2012 21:45
Horrible rails controller method, need help
[{:active=>"no", :start=>Tue, 15 May 2012 20:42:17 UTC +00:00, :amount=>"10.00", :card_type=>"Visa", :card_number=>"0195"}]
<p>Get this output at the end of my .each</p>
@glideranderson
glideranderson / full_payments_controller.rb
Created May 17, 2012 13:34
Full Payments Controller
class PaymentsController < ApplicationController
before_filter :authenticate_member!
autocomplete :company, :name, :full => true, :extra_data => [:address1, :address2, :city, :state, :zip, :business_category_id, :revenue_id], :scopes => [:inactive]
respond_to :json, :only => [:dues]
def index
end
def new
@payment = Payments.new(:member_id => current_member)
@glideranderson
glideranderson / fileupload.js
Created June 14, 2012 18:17
Unsure what return does for QQ Uploader (errors in ie9)
_isValidFileDrag: function(e){
var dt = e.dataTransfer,
// do not check dt.types.contains in webkit, because it crashes safari 4
isWebkit = navigator.userAgent.indexOf("AppleWebKit") > -1;
console.log(dt);
// dt.effectAllowed is none in Safari 5
// dt.types.contains check is for firefox
return dt && dt.effectAllowed != 'none' &&
(dt.files || (!isWebkit && dt.types.contains && dt.types.contains('Files')));
@glideranderson
glideranderson / app_views_comments_create.js.rjs
Created July 17, 2012 19:01
Fat Free CRM Creat Comment js
if @comment.valid?
page.insert_html :after, :comment_new, :partial => "comment", :locals => { :comment => @comment }
page[dom_id(@comment)].visual_effect :highlight, :duration => 1.5
end
page[:shown_notes].value = @comment.commentable.comment_ids.join(',')
page[:comment_comment].clear
page[:comment_comment].focus
@glideranderson
glideranderson / pet_form.html.haml
Created August 22, 2012 17:38
html5 multiple file uploader js
.control-group.required.upload-photos
= f.label 'Upload files', required: false
.controls
.file-upload-wrapper
= link_to '#', class: 'file-upload red-btn' do
%i.icons.upload
Upload
= f.input :attachment,
as: :file,
wrapper_html: { class: 'hidden-upload' },
@glideranderson
glideranderson / petphotouploader.js.coffee
Created August 22, 2012 21:24
pet file uploader in more oop manor
class PetPhotoUploader
# html5 multiple uploader with fallback
dom =
parent_wrapper: '.controls' # wrapper that contains all parent elements
parent: '.file-upload-wrapper' # container/wrapper of the file uploader
hidden_upload: '.hidden-upload' # hidden file input
file_text: '.file-text' # hidden wrapper notice to user which files they (will) uploaded
delete_file: '.delete-upload-file' # link to delete uploaded files
uploaded_count = 0 # total files uploaded