Skip to content

Instantly share code, notes, and snippets.

@nowri
nowri / mithrilutil.js
Last active August 28, 2015 03:54
mithrilでredux使う
define(["lodash"], function(_){
return {
bindActionsMithril: function(actions, store, m) {
var newActions = {};
store.subscribe(function() {
m.endComputation();
});
_.each(actions, function(action, key){
newActions[key] = function() {
var act;
@nowri
nowri / gist:8821243
Last active August 29, 2015 13:56
先頭(前方)と末尾(後方)にある空白文字を一括削除
//@see http://www.nishishi.com/javascript/2013/trim-space-chars.html
TargetString = TargetString.replace(/(^\s+)|(\s+$)/g, "");
@nowri
nowri / gist:8822666
Created February 5, 2014 12:33
JSによるスタイルの動的追加
/**
* Add style tag
*
* @param css ex.<code>"h1 { background: red; }"</code>
* @see http://stackoverflow.com/questions/524696/how-to-create-a-style-tag-with-javascript#answer-524721
*/
function addStyle(css) {
var head = document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
@nowri
nowri / minmax.js
Created March 19, 2014 04:05
リサイズ時にチラツキとレイアウト崩れが起こる現象などを改善
/**
* @license
* Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE
* Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js`
*/
;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++t<e;)if(n[t]===r)return t;return-1}function r(n,r){for(var t=n.m,e=r.m,u=-1,o=t.length;++u<o;){var i=t[u],f=e[u];if(i!==f){if(i>f||typeof i=="undefined")return 1;if(i<f||typeof f=="undefined")return-1}}return n.n-r.n}function t(n){return"\\"+yr[n]}function e(n,r,t){r||(r=0),typeof t=="undefined"&&(t=n?n.length:0);var e=-1;t=t-r||0;for(var u=Array(0>t?0:t);++e<t;)u[e]=n[r+e];return u}function u(n){return n instanceof u?n:new o(n)}function o(n,r){this.__chain__=!!r,this.__wrapped__=n
}function i(n){function r(){if(u){var n=e(u);Rr.apply(n,arguments)}if(this instanceof r){var i=f(t.prototype),n=t.apply(i,n||arguments);return O(n)?n:i}return t.apply(o,n||arguments)}var t=n[0],u=n[2],o=n[4];return r}function f(n){return O(n)?Br(n):{}}func
☆○○○について
2011/xx/xx isora1988
■ このプログラムは?
//< 概要を書く-----
■ 必要なもの
@nowri
nowri / FLAutoKerning.js
Last active August 29, 2015 13:59
FLAutoKerningを使いやすく拡張
/*
* @update 2014/03/07
* */
// ORIGINAL LICENCE
/*
* @class FLAutoKerning
* @version 0.0.3 (2011/02/28)
* @author Takayuki Fukatsu, artandmobile.com, fladdict.net
* @requires jQuery
*/
@nowri
nowri / posfixed.js
Created May 9, 2014 07:23
body min-width以下になった時に、position:fixed;width:100%;のコンテナの表示に対応させる
function runPosFixed(){
$(".js-pos-fixed").css("left", - Math.floor($(window).scrollLeft()) + "px");
}
$win.on("load scroll resize", function () {
runPosFixed();
});
// img elems
if(typeof window.addEventListener == 'undefined' && typeof document.getElementsByClassName == 'undefined') {
$('img').each(function() {
var $this = $(this),
src = $this.attr('src');
if(src.indexOf('.png') != -1) {
$this.css({
'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '", sizingMethod="scale");'
});
}
@nowri
nowri / stopMouseWheel.js
Last active August 29, 2015 14:04
マウスホイールを無効にするスニペット、レガシーブラウザ対応
/*global $, Modernizr */
/*
* @require jquery.mousewheel.js
*/
function stopMouseWheel(enabled){
if(Modernizr.touch){
return;
}
if(enabled) {
var wheel = function(event) {
@nowri
nowri / font.css
Last active August 29, 2015 14:07
.sans-serif {
font-family: Verdana, "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3", Meiryo, "メイリオ", sans-serif;
}
.serif {
font-family: font-family: "Times New Roman", "游明朝", YuMincho, "ヒラギノ明朝 ProN W3", "Hiragino Mincho ProN", "メイリオ", Meiryo, serif;
}