Skip to content

Instantly share code, notes, and snippets.

View culttm's full-sized avatar
🇺🇦

Dmytro Kozlov culttm

🇺🇦
View GitHub Profile
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->
BrowserDetect = {
init:->
this.browser = this.searchString(this.dataBrowser) || "Other"
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown"
searchString: (data) ->
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;
this.versionSearchString = data[i].subString;
@culttm
culttm / jquery.alterclass.js
Last active August 29, 2015 14:26 — forked from peteboere/jquery.alterclass.js
jQuery alterClass plugin: Remove element classes with wildcard matching. Optionally add classes.
/**
* jQuery alterClass plugin
*
* Remove element classes with wildcard matching. Optionally add classes:
* $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
*
* Copyright (c) 2011 Pete Boere (the-echoplex.net)
* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
*
*/
@culttm
culttm / trimSerialize.jquery.js
Last active August 29, 2015 14:26 — forked from darrennolan/trimSerialize.jquery.js
jQuery Trim Serialize form function. Leaves previous form intact, allows for giving selector for trim to run on. Defaults to only input[type=text] inputs.
(function($) {
/**
* Trim Form Elements before returning Serialize()
* @param {string} selector Defaults to 'input[type=text]'
* @return {serialized()} Returned jQuery serialize() string
*/
$.fn.trimSerialize = function(selector) {
// Deep clone form (to get all nested elements), then unbind everything off the clone
var clonedObject = $(this).clone(true).off();
@culttm
culttm / gulpfile.js
Last active August 29, 2015 14:26
My web development gulpfile
var browserSync = require('browser-sync');
var del = require('del');
var gulp = require('gulp');
var pageSpeed = require('psi');
var plugins = require('gulp-load-plugins')();
var runSequence = require('run-sequence');
// Optimize images
gulp.task('images', function () {
return gulp.src('app"<%= asset_path('$1') %>"**/*')
@culttm
culttm / gist:6937eff1ae65601324a7
Created September 28, 2015 09:45
POLYFILL for requestAnimationFrame
//=========================================================================
// POLYFILL for requestAnimationFrame
//=========================================================================
if (!window.requestAnimationFrame) { // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
window.requestAnimationFrame = window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback, element) {
@culttm
culttm / CustomOwlCarousel.coffee
Last active October 12, 2015 22:23
Init owlCarousel with custom DOM options
###
Init owlCarousel with custom DOM options
http://www.owlcarousel.owlgraphic.com/docs/api-options.html
@plugin-options
@responsive-options
@nav-text
https://github.com/smashingboxes/OwlCarousel2
###
@culttm
culttm / repeatable-fields-metabox.php
Created December 14, 2015 19:15 — forked from helen/repeatable-fields-metabox.php
Repeating Custom Fields in a Metabox
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
@culttm
culttm / custom-nav-walker-usage.php
Created January 27, 2016 21:07 — forked from kosinix/custom-nav-walker-usage.php
WordPress: Using a custom nav walker to create navigation menus in plain <a> tags. That is the <ul> and <li> tags are not present. Very useful if you want to create simple links that can be centered with a simple text-align:center on the containing element.
<?php
// In your template files like footer.php
// The items_wrap value ('%3$s') removes the wrapping <ul>, while the custom walker (Nav_Footer_Walker) removes the <li>'s.
wp_nav_menu(array('items_wrap'=> '%3$s', 'walker' => new Nav_Footer_Walker(), 'container'=>false, 'menu_class' => '', 'theme_location'=>'footer', 'fallback_cb'=>false ));
?>