| 1 |
<!DOCTYPE HTML> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta http-equiv="x-ua-compatible" content="IE=Edge"/> |
| 5 |
<title>At.js</title> |
| 6 |
<link rel="stylesheet" href="dist/css/jquery.atwho.css" /> |
| 7 |
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.0.min.js"></script> |
| 8 |
<script type="text/javascript" src="https://ichord.github.io/Caret.js/src/jquery.caret.js"></script> |
| 9 |
<!-- <script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script> --> |
| 10 |
<!-- <script type="text/javascript" src="bower_components/Caret.js/dist/jquery.caret.js"></script> --> |
| 11 |
<script type="text/javascript" src="dist/js/jquery.atwho.js"></script> |
| 12 |
<script type="text/javascript"> |
| 13 |
$(function(){ |
| 14 |
$.fn.atwho.debug = true |
| 15 |
var emojis = [ |
| 16 |
"smile", "iphone", "girl", "smiley", "heart", "kiss", "copyright", "coffee", |
| 17 |
"a", "ab", "airplane", "alien", "ambulance", "angel", "anger", "angry", |
| 18 |
"arrow_forward", "arrow_left", "arrow_lower_left", "arrow_lower_right", |
| 19 |
"arrow_right", "arrow_up", "arrow_upper_left", "arrow_upper_right", |
| 20 |
"art", "astonished", "atm", "b", "baby", "baby_chick", "baby_symbol", |
| 21 |
"balloon", "bamboo", "bank", "barber", "baseball", "basketball", "bath", |
| 22 |
"bear", "beer", "beers", "beginner", "bell", "bento", "bike", "bikini", |
| 23 |
"bird", "birthday", "black_square", "blue_car", "blue_heart", "blush", |
| 24 |
"boar", "boat", "bomb", "book", "boot", "bouquet", "bow", "bowtie", |
| 25 |
"boy", "bread", "briefcase", "broken_heart", "bug", "bulb", |
| 26 |
"person_with_blond_hair", "phone", "pig", "pill", "pisces", "plus1", |
| 27 |
"point_down", "point_left", "point_right", "point_up", "point_up_2", |
| 28 |
"police_car", "poop", "post_office", "postbox", "pray", "princess", |
| 29 |
"punch", "purple_heart", "question", "rabbit", "racehorse", "radio", |
| 30 |
"up", "us", "v", "vhs", "vibration_mode", "virgo", "vs", "walking", |
| 31 |
"warning", "watermelon", "wave", "wc", "wedding", "whale", "wheelchair", |
| 32 |
"white_square", "wind_chime", "wink", "wink2", "wolf", "woman", |
| 33 |
"womans_hat", "womens", "x", "yellow_heart", "zap", "zzz", "+1", |
| 34 |
"-1" |
| 35 |
] |
| 36 |
var jeremy = decodeURI("J%C3%A9r%C3%A9my") // Jérémy |
| 37 |
var names = ["Jacob","Isabella","Ethan","Emma","Michael","Olivia","Alexander","Sophia","William","Ava","Joshua","Emily","Daniel","Madison","Jayden","Abigail","Noah","Chloe","你好","你你你", jeremy, "가"]; |
| 38 |
|
| 39 |
var names = $.map(names,function(value,i) { |
| 40 |
return {'id':i,'name':value,'email':value+"@email.com"}; |
| 41 |
}); |
| 42 |
var emojis = $.map(emojis, function(value, i) {return {key: value, name:value}}); |
| 43 |
|
| 44 |
var at_config = { |
| 45 |
at: "@", |
| 46 |
data: names, |
| 47 |
headerTpl: '<div class="atwho-header">Member List<small>↑ ↓ </small></div>', |
| 48 |
insertTpl: '${name}', |
| 49 |
displayTpl: "<li>${name} <small>${email}</small></li>", |
| 50 |
limit: 200 |
| 51 |
} |
| 52 |
var emoji_config = { |
| 53 |
at: ":", |
| 54 |
data: emojis, |
| 55 |
displayTpl: "<li>${name} <img src='https://assets-cdn.github.com/images/icons/emoji/${key}.png' height='20' width='20' /></li>", |
| 56 |
insertTpl: ':${key}:', |
| 57 |
delay: 400 |
| 58 |
} |
| 59 |
$inputor = $('#inputor').atwho(at_config).atwho(emoji_config); |
| 60 |
$inputor.caret('pos', 47); |
| 61 |
$inputor.focus().atwho('run'); |
| 62 |
|
| 63 |
emoji_config.insertTpl = "<img src='https://assets-cdn.github.com/images/icons/emoji/${name}.png' height='20' width='20' />" |
| 64 |
$('#editable').atwho(at_config).atwho(emoji_config); |
| 65 |
|
| 66 |
ifr = $('#iframe1')[0] |
| 67 |
doc = ifr.contentDocument || iframe.contentWindow.document |
| 68 |
if ((ifrBody = doc.body) == null) { |
| 69 |
// For IE |
| 70 |
doc.write("<body></body>") |
| 71 |
ifrBody = doc.body |
| 72 |
} |
| 73 |
ifrBody.contentEditable = true |
| 74 |
ifrBody.id = 'ifrBody' |
| 75 |
ifrBody.innerHTML = 'For <strong>WYSIWYG</strong> which using <strong>iframe</strong> such as <strong>ckeditor</strong>' |
| 76 |
$(ifrBody).atwho('setIframe', ifr).atwho(at_config) |
| 77 |
}); |
| 78 |
|
| 79 |
</script> |
| 80 |
<!--link href='http://fonts.googleapis.com/css?family=Dosis:400,700|Bubblegum+Sans|Overlock:400,900|PT+Sans:400,700|PT+Sans+Narrow:400,700|Magra|Asap:400,700|Share:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css' --> |
| 81 |
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'> |
| 82 |
|
| 83 |
<style type="text/css"> |
| 84 |
html, body { |
| 85 |
background:#F9F9F9; |
| 86 |
padding: 0; |
| 87 |
margin: 0; |
| 88 |
font: 14px/1.6 "Lucida Grande", "Helvetica", sans-serif; |
| 89 |
color: #333; |
| 90 |
} |
| 91 |
h1,h2,h3,h4 { |
| 92 |
font-family: 'PT Sans', sans-serif; |
| 93 |
line-height: 40px; |
| 94 |
color: inherit; |
| 95 |
font-weight: bold; |
| 96 |
margin: 10px 0; |
| 97 |
text-rendering: optimizelegibility; |
| 98 |
} |
| 99 |
h2,h3 { |
| 100 |
color: gray; |
| 101 |
} |
| 102 |
strong { |
| 103 |
color: #424242; |
| 104 |
} |
| 105 |
|
| 106 |
a { |
| 107 |
color: #4183C4; |
| 108 |
text-decoration: none; |
| 109 |
} |
| 110 |
a:hover { |
| 111 |
text-decoration: underline; |
| 112 |
} |
| 113 |
.wrapper { |
| 114 |
width: 750px; |
| 115 |
padding: 20px; |
| 116 |
margin: 0 auto; |
| 117 |
} |
| 118 |
header { |
| 119 |
margin-top:70px; |
| 120 |
margin-bottom: 50px; |
| 121 |
} |
| 122 |
header h1 { |
| 123 |
text-align: center; |
| 124 |
font-size: 75px; |
| 125 |
} |
| 126 |
h1 i { |
| 127 |
color: rgb(182, 180, 180); |
| 128 |
font-style: normal; |
| 129 |
font-weight: normal; |
| 130 |
} |
| 131 |
|
| 132 |
.inputor { |
| 133 |
height: 160px; |
| 134 |
width: 90%; |
| 135 |
border: 1px solid #dadada; |
| 136 |
border-radius: 4px; |
| 137 |
padding: 5px 8px; |
| 138 |
outline: 0 none; |
| 139 |
margin: 10px 0; |
| 140 |
background: white; |
| 141 |
font-size: inherit; |
| 142 |
overflow-y: scroll; |
| 143 |
} |
| 144 |
.inputor:focus { |
| 145 |
border: 1px solid rgb(6, 150, 247); |
| 146 |
} |
| 147 |
|
| 148 |
ul.doc { |
| 149 |
list-style:none; |
| 150 |
} |
| 151 |
ul.doc li { |
| 152 |
display:inline-block; |
| 153 |
margin: 0 10px; |
| 154 |
} |
| 155 |
|
| 156 |
footer { |
| 157 |
margin: 30px 0; |
| 158 |
} |
| 159 |
|
| 160 |
.github { |
| 161 |
text-align: center; |
| 162 |
} |
| 163 |
|
| 164 |
</style> |
| 165 |
|
| 166 |
</head> |
| 167 |
<body> |
| 168 |
<div class="container wrapper"> |
| 169 |
<!-- <a id="github" href="https://github.com/ichord/At.js" target="_blank"><img style="position: absolute; top: 0; right: 0; border: 0; z-index:999" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> --> |
| 170 |
|
| 171 |
<header> |
| 172 |
<h1>At<i>.js</i></h1> |
| 173 |
</header> |
| 174 |
<div id="main"> |
| 175 |
<div> |
| 176 |
<textarea id="inputor" class="inputor">At.js, a github-like autocomplete library :s</textarea> |
| 177 |
</div> |
| 178 |
|
| 179 |
<div id="editable" class="inputor" contentEditable="true"> |
| 180 |
<p> |
| 181 |
<b>And!!</b> it support <b style="font-size: 20px">ContentEditable</b> mode too!! |
| 182 |
<img src="https://assets-cdn.github.com/images/icons/emoji/smile.png" height="20" width="20"> |
| 183 |
<img src="https://assets-cdn.github.com/images/icons/emoji/smiley.png" height="20" width="20"> |
| 184 |
<img src="https://assets-cdn.github.com/images/icons/emoji/coffee.png" height="20" width="20"> |
| 185 |
</p> |
| 186 |
<p> |
| 187 |
<b>Try here now!</b><img src="https://assets-cdn.github.com/images/icons/emoji/point_right.png" height="20" width="20"> |
| 188 |
<b>:h</b> |
| 189 |
</p> |
| 190 |
</div> |
| 191 |
|
| 192 |
<div class="inputor" style="overflow: hidden"> |
| 193 |
<iframe src="" id="iframe1" style="width: 100%; height: 100%; border: 0px;"></iframe> |
| 194 |
</div> |
| 195 |
|
| 196 |
<footer> |
| 197 |
<h2> |
| 198 |
-> <a class="github" href="https://github.com/ichord/At.js">Fork me on GitHub!</a> |
| 199 |
</h2> |
| 200 |
</footer> |
| 201 |
|
| 202 |
</div> |
| 203 |
</div> |
| 204 |
</body> |
| 205 |
</html> |