Skip to content

Instantly share code, notes, and snippets.

View mach3's full-sized avatar
🏠
Working from home

まっは mach3

🏠
Working from home
View GitHub Profile
@mach3
mach3 / mixin.js
Created August 6, 2019 10:24
vnodeRender
export const vnodeRender = {
methods: {
vnodeRender(vnode) {
if (process.browser) {
if (!vnode.tag) {
return document.createTextNode(vnode.text)
}
const el = document.createElement(vnode.tag)
if (vnode.data) {
if (vnode.data.staticClass) {
@mach3
mach3 / delegate.js
Created January 23, 2017 06:10
$.fn.on(eventType, selector, selector, handler) みたいな物を。挙動はちょっと異なります。
var _delegate = function(elms, type, selector, callback){
elms = (_type(elms) === "string") ? document.querySelectorAll(elms)
: (! elms.length) ? [elms]
: elms;
Array.from(elms).forEach(function(elm){
elm.addEventListener(type, function(e){
var valid = !! Array.from(this.querySelectorAll(selector))
.filter(function(el){
return el === e.target;
}).length;
var lottery = function(data, rate, times){
var source = [];
rate = rate || (function(){
var i, rate;
i = data.length;
rate = [];
while(i--){
rate.push(1);
}
return rate;
@mach3
mach3 / grunt-resolve-json.js
Created July 25, 2014 08:03
grunt-resolve-json.js: Load map.json and resolve paths
module.exports = function(grunt){
var path = require("path"),
_ = grunt.util._;
/**
* Resolve dest and src files' path
* @param {String} file
* @returns {Object}
*/
@mach3
mach3 / jquery.togglbuttons.js
Last active August 29, 2015 14:00
Polyfill to implement the toggle button by hidden radio input
/**
* Polyfill to implement the toggle button by hidden radio input
* Add "active" class to the buttonized element, for ":checked + el" expression
* @param {Object} options
*/
$.support.toggleButtons = "opacity" in document.createElement("div").style;
$.fn.toggleButtons = function(options){
var my = {};
if($.support.toggleButtons){
@mach3
mach3 / example.html
Last active August 29, 2015 13:59
jquery-multiline-overflow.js
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.demo {
height: 3em;
line-height: 1.5em;
overflow: hidden;
@mach3
mach3 / grunt-phps.js
Created March 26, 2014 17:00
Grunt task to run php built-in server
/**
* Grunt Task : phps
* -----------------
* Run php built-in server
*/
module.exports = function(grunt) {
grunt.registerMultiTask("phps", "", function() {
var exec, cmd, options;
@mach3
mach3 / jquery-lineup.js
Last active August 29, 2015 13:56
test jquery-lineup update
(function($){
/**
* LineUp
* ------
* Fix heights of the cols in the same row
*
* @class
* @param String selector
* @param Object option
@mach3
mach3 / test.html
Created February 6, 2014 08:05
Test jQuery.EqualRowHeights
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./jquery-1.10.2.min.js"></script>
<script src="../dest/jquery.equalrowheights.js"></script>
<script>
$(function() {
/*
* jquery.xgradient.js
* http://blog.mach3.jp/
*
* Publish Date : 2010/5/13
* Requirement : jQuery 1.4 or later
* http://jquery.com/
*
* Copyright 2010, Mach3
*/