Skip to content

Instantly share code, notes, and snippets.

View riix's full-sized avatar

Park, Soon-Ghil riix

View GitHub Profile
@riix
riix / gist:3168255
Created July 24, 2012 05:44
마우스 커서 좌표 탐색, Get X, Y Coordinates of Mouse Within Box with jQuery
// 본문 마우스 커서 좌표 탐색
$(function(){
$(window).mousemove(function(event){
//display the x and y axis values inside the P element
$('p').html('X Axis : ' + event.pageX + ' | Y Axis ' + event.pageY);
});
});
<p>Ready...</p>
@riix
riix / simpleSticky.js
Created July 24, 2012 06:06
스카이스크래퍼, Sticky Menu
$(window).scroll(function() {
if ($(window).scrollTop() > 175 ) {
$('.sticky').css({'position' : 'fixed', 'top' : 0});
} else {
$('.sticky').css({'position' : 'relative', 'top' : 'none'});
}
});
jQuery(document).ready(function() {
// This will fire when document is ready:
jQuery(window).resize(function() {
// This will fire each time the window is resized:
if(jQuery(window).width() >= 800) {
// if larger or equal
var colHeight = Math.max(
// IFRAME 개체 셀렉트 sample - iframe ID
$('#Form_Body',window.frames["sample"].window.document);
@riix
riix / MoveDiv.js
Created July 24, 2012 06:39
객체 이동, Move Element
var mover = false;
var currx = 0;
var curry = 0;
$(".calculator .title").mousedown(function(eventObject){
mover = true;
currx = eventObject.pageX;
curry = eventObject.pageY;
});
$(window).bind('mousemove', function(eventObject) {
@riix
riix / verticalAlign.js
Created July 24, 2012 06:41
객체를 부모 엘리먼트 중앙에 세로 정렬, vertical centering the matched elements
//save this code as jquery.verticalAlign.js
(function ($) {
$.fn.extend({
verticalAlign: function () {
//Iterate over the current set of matched elements
return this.each(function () {
@riix
riix / validImageUrl.js
Created July 24, 2012 06:45
이미지 URL 체크, Check if an image url is valid with javascript/jquery
function imageTest(url) {
var imageTarget = $('#urlImageTester');
imageTarget.prop('src', url);
var props = ['naturalHeight', 'fileCreatedDate'];
var tests = [];
var answer;
for (i in props) {
tests.push(imageTarget.prop(props[i]));
}
if ($.browser.msie) {
@riix
riix / detect.demension.js
Created July 24, 2012 06:56
Detecting and logging browser dimensions
var winWidth = $(window).width();
var winHeight = $(window).height();
$('#log').append('<div><h1>' + winWidth + 'x' + winHeight + '@' + window.orientation + '</h1></div>');
$(window).resize(function() {
var winWidth = $(window).width();
var winHeight = $(window).height();
$('#log').append('<div><h1>' + winWidth + 'x' + winHeight + '@' + window.orientation + '</h1></div>');
@riix
riix / get.pageLoaded.js
Created July 24, 2012 06:58
페이지 로드 시간 얻기, Get Page Load Time
var beforeload = (new Date()).getTime(); // calculate the time before calling the function in window.onload
function getPageLoadTime() {
var afterload = (new Date()).getTime(); // calculate the current time in afterload
seconds = (afterload - beforeload) / 1000; // now use the beforeload and afterload to calculate the seconds
console.log('Page load time : ' + seconds + ' sec(s).'); // Place the seconds in the innerHTML to show the results
}
window.onload = getPageLoadTime;
@riix
riix / attach.jQuery.html
Created July 24, 2012 07:06
jQuery 버전이 낮거나 없을때 호출, Attach jQuery if it doesn’t exist or if an older version exists
<script type="text/javascript">
<!--
function version_compare(a,b){var c=a.split('.');var d=b.split('.');for(var i=0;i<c.length;++i){if(d.length==i){return"gt"}if(c[i]==d[i]){continue}else if(c[i]>d[i]){return"gt"}else{return"lt"}}if(c.length!=d.length){return"lt"}return"eq"}
var requiredJQueryVersion = '1.7';
if (!window.jQuery || version_compare(window.jQuery.fn.jquery, requiredJQueryVersion) == 'lt') {
document.write('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"><\/script>')
}
-->
</script>