Skip to content

Instantly share code, notes, and snippets.

View s-hiroshi's full-sized avatar

Hiroshi Sawai s-hiroshi

View GitHub Profile
QUnit.module( "getOffsetのテスト" );
QUnit.test( "jQueryオブジェクトを渡したとき親要素の中央へ配置するためのオフセット値を返す ", function ( assert ) {
var target, parent;
target = $( '<div style="width: 100px; height: 100px">' );
parent = $( '<div style="width: 200px; height: 300px">' );
target.appendTo( parent );
parent.appendTo( $( 'body' ) );
var point = InfoTown.Center.getOffset( target, parent );
assert.ok( point.x == "50", "Passed!" );
assert.ok( point.y == "100", "Passed!" )
@s-hiroshi
s-hiroshi / js-center.js
Last active April 1, 2016 00:16
JavaScriptで中央配置するサンプルです。
/**
* @module InfoTown
*/
jQuery( function ( $ ) {
/**
* Centerオブジェクト
*
* 親要素に対し要素を中央へ配置するための各種メソッドを提供します。
*
* @class Center
/**
* 中央配置用オフセット取得
*
* target要素をparent要素の中央へ配置するために
* CSSのtop, leftプロパティへ設定すべき値を取得します。
*
* @method getOffset
* @public
* @param {jQuery} target 中央配置するjQueryオブジェクトです。
* @param {jQuery} parent 親のjQueryオブジェクトです。
<?php
/**
* Get archives markup.
* Customize wp-includes/general-template.php -> wp_get_archives
* @param string|array $args Optional. Override defaults.
* @return string|null String when retrieving, null when displaying.
*/
function shintotsushin_wp_get_archives( $args = '' ) {
global $wp_query;
global $wpdb;
// 全角数字を半角数字に変換(toHalfNum)は下記のサイトのスクリプトを利用。
// http://ameblo.jp/pclindesk/entry-10110151969.html
function myError(str) {
$('#error').text(str);
}
$('#date').blur(function () {
var i;
@s-hiroshi
s-hiroshi / menu.css
Last active December 11, 2015 17:29
CSS > menu
/*
horizonal menu template
example
<ul id="menu-global" class="menu">
<li>item1
<ul class="children>
<li>children item1</li>
</ul>
</li>
@s-hiroshi
s-hiroshi / clearfix.css
Created January 25, 2013 14:37
CSS > clearfix
/* -------------------------------------------------------------------
Clearfix
------------------------------------------------------------------- */
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
@s-hiroshi
s-hiroshi / index.html
Last active December 11, 2015 07:09
JavaScript > snippets > jQuery plugin template
<!DOCTYPE html>
<html lang="ja" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="utf-8">
<title>JQuery plugin template</title>
<meta name="description" content="jquery plugin template">
<meta name="keywords" content="dorpdown">
<link rel="stylesheet" href="style.css" media="all">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="template.js"></script>
@s-hiroshi
s-hiroshi / style.css
Last active December 11, 2015 05:48
CSS > snippets > wordpress style template
@charset "utf-8";
/*
Theme Name:
Theme URI:
Description:
Tags: two-columns, left-sidebar, custom-background, custom-header, custom-menu, editor-style
Author:
Author URI:
Version:
License: GNU GPL
@s-hiroshi
s-hiroshi / 478x640.jpg
Last active December 11, 2015 05:48
JavaScript > snippets > modal window
478x640.jpg