forked from yairEO/fancyInput
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
157 lines (135 loc) · 10.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE HTML>
<!-------------------------------------------/*
* Fancy Input
*
* Copyright 2013, Yair Even Or
* https://dropthebit.com
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/------------------------------------------>
<html lang="en">
<head>
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
<meta charset="utf-8">
<title>Fancy Input - CSS3 text typing effects for input fields</title>
<meta name="description" content="Makes HTML input field typing fun with some CSS3 effects">
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="fancyInput.css">
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<div id='wrap'>
<header>
<div class='social'></div>
<menu>
<button class='active'>Effect 1</button>
<button>Effect 2</button>
<button>Effect 3</button>
<button>Effect 4</button>
<button>Effect 5</button>
</menu>
<menu class='radio'>
<label><input type='radio' value='input' name='type' /><span>input</span></label>
<label><input type='radio' value='textarea' name='type' /><span>textarea</span></label>
<div></div>
</menu>
</header>
<div id='content'>
<section class='input'>
<div>
<input type='text' placeholder='type something...'>
</div>
</section>
<section class='textarea'>
<div>
<textarea cols='1'></textarea>
</div>
</section>
</div>
<a class='by' href='http://dropthebit.com'>dropthebit.com ⋆ Yair Even Or ⋆ 2012</a>
<a class='git' title='Check it out on Github' href='https://github.com/yairEO/fancyInput'><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAAA5CAYAAAD++yN2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QjREREVBOUQ3OUUwMTFFMkJENTJGNDU2OTRDRjFGQ0QiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QjREREVBOUU3OUUwMTFFMkJENTJGNDU2OTRDRjF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vODLfR78kanKUBv9hw0s7isb3ExXMQ3yaGKBj6MgJ0CQ86oK0jbQbsNgW8TgEoJsBpl9pqtONEMQqQ3s4IhhwAH6zhPwchK+eDoGUaSPhQWwMhQRzZ4mB4nLGCaEshNvUlLiFbQkEwmOCUTsgjWfruENrS5qoU0WhYeWLuGyhig7ER7lD3JJmvCWsG655Kw6t1C5bUJoaNEVLz5L/MJHmelxIYbIn9DfUM8uQlm0Ft+H3JHxd+oULHqYhjgdpiKGs6Za29Lfs4rUTs8Eay61hUipfbkizGv2gfOwA6Vqduoi4RkI13Gy5fOKyscn2n0bxWjwUu0ssVdbAvn8K1pnz2MU7gTVlrvK7kLBoDfwu1ig+n/+ZIQ3LBH2wLrNW4DriPABpuT7vqPDllWzq7QxTM6/1jeBUclbLWw1C7RHsqrUVQlqqMC3baAgE4hwItvr/Q9Qd0npl7I4uUFe6ubeGtH4J4ftRD0mtYBrfiD77JmSATQYPpKGQPaapKw+r9EU/cfoluqZVlv9rWIJikP4nwABUwlBXgupuwAAAAABJRU5ErkJggg=="></a>
</div>
<script src='fancyInput.js'></script>
<script>
// Capture TAB to switch between the Demo page views (input/textarea)
(function(){
var viewTogglers = $('menu.radio input');
$(document).on('keydown', function(e){
if( e.key == 'tab' || e.keyCode == 9 ){
var $checked = viewTogglers.filter(':checked');
var $next = viewTogglers.eq(viewTogglers.index($checked) + 1);
if(!$next.length){
$next = viewTogglers.first();
}
$next.prop("checked", true).change();
return false;
}
});
})();
$('section :input').val('').fancyInput()[0].focus();
// Everything below is only for the DEMO
function init(str){
var input = $('section input').val('')[0],
s = 'type something... ✌'.split('').reverse(),
len = s.length-1,
e = $.Event('keypress');
input.nextElementSibling.className = '';
var initInterval = setInterval(function(){
if( s.length ){
var c = s.pop();
fancyInput.writer(c, input, len-s.length).setCaret(input);
input.value += c;
//e.charCode = c.charCodeAt(0);
//input.trigger(e);
}
else clearInterval(initInterval);
},150);
}
init();
$('menu').on('click', 'button', toggleEffect);
$('menu.radio').on('change', 'input', changeForm).find('input:first').prop('checked',true).trigger('change');
// change effects
function toggleEffect(num){
var className = '';
idx = $(this).index() + 1,
$fancyInput = $('.fancyInput');
if( idx > 1 )
className = 'effect' + idx;
$('#content').prop('class', className);
$fancyInput.find(':input')[0].focus();
$(this).addClass('active').siblings().removeClass('active');
}
function changeForm(e){
// radio buttons stuff
var page = this.value,
highlight = $(e.delegateTarget).find('> div'),
label = $(this.parentNode),
marginLeft = parseInt( label.css('margin-left') , 10 ),
xPos;
highlight.css({'left':label.position().left + marginLeft, 'width':label.width() });
// page change stuff
xPos = '-' + label.index() * 50;
$('#content').css( 'transform', 'translateX(' + xPos + '%)' );
setTimeout(function(){
$('#content').find('.' + page + ' :input')[0].focus();
}, 100);
}
// social sharing stuff
setTimeout(addSocial,500);
function addSocial(){
// tweet button
var tweeter = $('<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>');
// facebook 'like' button
var fbLike = $('<iframe class="fbLike" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdropthebit.com%2Fdemos%2Ffancy_input%2FfancyInput.html&send=false&layout=standard&width=450&show_faces=false&font=arial&action=like&height=35&colorscheme=light&layout=button_count&appId=2398652648"></iframe>');
$('.social').append(fbLike, tweeter);
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
window.getComputedStyle(fbLike[0]).getPropertyValue('top');
$('.social').addClass('show');
};
</script>
</body>
</html>