@@ -7,7 +7,77 @@ semantic.icon.ready = function() {
77 var
88 $grid = $ ( '.ui.five.column.doubling.grid' ) ,
99 // alias
10- handler
10+ handler = {
11+ getIconList : function ( ) {
12+ var
13+ $examples = $ ( '.icon .example' )
14+ icons = [ ]
15+ ;
16+ $examples . each ( function ( ) {
17+ var
18+ $header = $ ( this ) . children ( '.ui.header' ) ,
19+ $icons = $ ( this ) . find ( '.grid > .column' ) ,
20+ category = $header . text ( )
21+ ;
22+ $icons . each ( function ( ) {
23+ var
24+ $icon = $ ( this ) . find ( '.icon' ) ,
25+ icon = $icon . attr ( 'class' ) . replace ( ' icon' , '' )
26+ title = '<i class="' + icon + ' icon"></i> ' + icon
27+ ;
28+ icons . push ( {
29+ category : category ,
30+ title : title ,
31+ icon : icon
32+ } )
33+ } ) ;
34+ } ) ;
35+ return icons ;
36+ }
37+ }
38+ ;
39+
40+ $ ( 'iconSearch.ui.search' )
41+ . search ( {
42+ type : 'category' ,
43+ minCharacters : 1 ,
44+ maxResults : 10 ,
45+ source : handler . getIconList ( ) ,
46+ onResults : function ( result ) {
47+ setTimeout ( function ( ) {
48+ var
49+ $results = $ ( 'iconSearch.ui.search .result' )
50+ ;
51+ $results . each ( function ( ) {
52+ var
53+ $result = $ ( this )
54+ ;
55+ new Clipboard ( this , {
56+ text : function ( ) {
57+ var
58+ iconHTML = $result . find ( 'i' ) . get ( 0 ) . outerHTML
59+ ;
60+ return iconHTML ;
61+ }
62+ } ) ;
63+ } ) ;
64+ } , 0 ) ;
65+ } ,
66+ onSelect : function ( ) {
67+ var
68+ $search = $ ( 'iconSearch .input > input' )
69+ ;
70+ $search . blur ( ) ;
71+ setTimeout ( function ( ) {
72+ $ ( 'iconSearch' ) . transition ( 'bounce' ) ;
73+ $search . val ( 'HTML Copied to clipboard!' ) ;
74+ } , 50 )
75+ setTimeout ( function ( ) {
76+ $search . val ( '' ) ;
77+ } , 1500 )
78+ return false ;
79+ }
80+ } )
1181 ;
1282
1383
@@ -17,4 +87,4 @@ semantic.icon.ready = function() {
1787// attach ready event
1888$ ( document )
1989 . ready ( semantic . icon . ready )
20- ;
90+ ;
0 commit comments