@@ -1560,6 +1560,7 @@ $(document).ready(function () {
1560
1560
initWebhook ( ) ;
1561
1561
initAdmin ( ) ;
1562
1562
initCodeView ( ) ;
1563
+ initDashboardSearch ( ) ;
1563
1564
1564
1565
// Repo clone url.
1565
1566
if ( $ ( '#repo-clone-url' ) . length > 0 ) {
@@ -1635,13 +1636,6 @@ $(function () {
1635
1636
if ( $ ( '.user.signin' ) . length > 0 ) return ;
1636
1637
$ ( 'form' ) . areYouSure ( ) ;
1637
1638
1638
- $ ( "#search_repo" ) . on ( 'change paste keyup' , function ( ) {
1639
- var value = $ ( this ) . val ( ) ;
1640
- $ . map ( $ ( '.search-list li' ) , function ( i ) {
1641
- $ ( i ) . css ( "display" , ( value . trim ( ) . length == 0 || $ ( i ) . attr ( "data-title" ) . trim ( ) . toLowerCase ( ) . indexOf ( value . trim ( ) . toLowerCase ( ) ) > - 1 ) ? "" : "none" ) ;
1642
- } ) ;
1643
- } ) ;
1644
-
1645
1639
// Parse SSH Key
1646
1640
$ ( "#ssh-key-content" ) . on ( 'change paste keyup' , function ( ) {
1647
1641
var arrays = $ ( this ) . val ( ) . split ( " " ) ;
@@ -1651,3 +1645,64 @@ $(function () {
1651
1645
}
1652
1646
} ) ;
1653
1647
} ) ;
1648
+
1649
+ function initDashboardSearch ( ) {
1650
+ var el = document . getElementById ( 'dashboard-repo-search' ) ;
1651
+ if ( ! el ) {
1652
+ return ;
1653
+ }
1654
+
1655
+ new Vue ( {
1656
+ delimiters : [ '<%' , '%>' ] ,
1657
+ el : el ,
1658
+
1659
+ data : {
1660
+ tab : 'repos' ,
1661
+ repos : [ ] ,
1662
+ searchQuery : '' ,
1663
+ suburl : document . querySelector ( 'meta[name=_suburl]' ) . content ,
1664
+ uid : document . querySelector ( 'meta[name=_uid]' ) . content
1665
+ } ,
1666
+
1667
+ mounted : function ( ) {
1668
+ this . searchRepos ( ) ;
1669
+
1670
+ Vue . nextTick ( function ( ) {
1671
+ document . querySelector ( '#search_repo' ) . focus ( ) ;
1672
+ } ) ;
1673
+ } ,
1674
+
1675
+ methods : {
1676
+ changeTab : function ( t ) {
1677
+ this . tab = t ;
1678
+ } ,
1679
+
1680
+ searchKeyUp : function ( ) {
1681
+ this . searchRepos ( ) ;
1682
+ } ,
1683
+
1684
+ searchRepos : function ( ) {
1685
+ var self = this ;
1686
+ $ . getJSON ( this . searchURL ( ) , function ( result ) {
1687
+ self . repos = result . data ;
1688
+ } ) ;
1689
+ } ,
1690
+
1691
+ searchURL : function ( ) {
1692
+ return this . suburl + '/api/v1/repos/search?uid=' + this . uid + '&q=' + this . searchQuery ;
1693
+ } ,
1694
+
1695
+ repoClass : function ( repo ) {
1696
+ if ( repo . fork ) {
1697
+ return 'octicon octicon-repo-forked' ;
1698
+ } else if ( repo . mirror ) {
1699
+ return 'octicon octicon-repo-clone' ;
1700
+ } else if ( repo . private ) {
1701
+ return 'octicon octicon-repo-forked' ;
1702
+ } else {
1703
+ return 'octicon octicon-repo' ;
1704
+ }
1705
+ }
1706
+ }
1707
+ } ) ;
1708
+ }
0 commit comments