git ssb

30+

cel / git-ssb-web



Commit 4d165189ac4cfd3c396afe97358fbdae916391f7

Factor out petname form

Charles Lehner committed on 3/26/2016, 8:19:11 PM
Parent: 395710809e2bb0e4cb1e7414e98bf061cb119c11

Files changed

index.jschanged
static/styles.csschanged
index.jsView
@@ -107,8 +107,23 @@
107107 ])
108108 }
109109 }
110110
111+function nameForm(isPublic, id, name, inputId, title, header) {
112+ return '<form class="petname" action="" method="post">' +
113+ (isPublic ? '' :
114+ '<input name="name" id="' + inputId + '" class="name" value="' +
115+ escapeHTML(name) + '" />' +
116+ '<input type="hidden" name="action" value="name">' +
117+ '<input type="hidden" name="id" value="' +
118+ escapeHTML(id) + '">' +
119+ '<label class="name-toggle" for="' + inputId + '" ' +
120+ 'title="' + title + '"><i>โœ</i></label>' +
121+ '<input class="name-btn" type="submit" value="Rename">') +
122+ header +
123+ '</form>'
124+}
125+
111126 function readNext(fn) {
112127 var next
113128 return function (end, cb) {
114129 if (next) return next(end, cb)
@@ -644,21 +659,12 @@
644659 (upvoted ? 'Undig' : 'Dig') +
645660 '</button>') + ' ' +
646661 '<strong>' + link(digsPath, votes.upvotes) + '</strong>' +
647662 '</form>' +
648- '<form class="petname" action="" method="post">' +
649- (isPublic ? '' :
650- '<input name="name" id="repo-name" value="' +
651- escapeHTML(repoName) + '" />' +
652- '<input type="hidden" name="action" value="name">' +
653- '<input type="hidden" name="id" value="' +
654- escapeHTML(repo.id) + '">' +
655- '<label class="repo-name-toggle" for="repo-name" ' +
656- 'title="Rename the repo"><i>โœ</i></label>' +
657- '<input class="repo-name-btn" type="submit" value="Rename">') +
658- '<h2>' + link([repo.feed], authorName) + ' / ' +
659- link([repo.id], repoName) + '</h2>' +
660- '</form>' +
663+ nameForm(isPublic, repo.id, repoName, 'repo-name',
664+ 'Rename the repo',
665+ '<h2>' + link([repo.feed], authorName) + ' / ' +
666+ link([repo.id], repoName) + '</h2>') +
661667 '</div><div class="repo-nav">' + link([repo.id], 'Code') +
662668 link([repo.id, 'activity'], 'Activity') +
663669 link([repo.id, 'commits', branch || ''], 'Commits') +
664670 link([repo.id, 'issues'], 'Issues') +
static/styles.cssView
@@ -74,8 +74,11 @@
7474 }
7575
7676 .repo-title h2 {
7777 color: #888;
78+}
79+
80+.petname h2 {
7881 float: left;
7982 }
8083
8184 .right-bar {
@@ -100,26 +103,26 @@
100103 .right-bar button:hover {
101104 background-color: #f6f6f6;
102105 }
103106
104-#repo-name {
107+.name {
105108 font-size: inherit;
106109 width: 0;
107110 opacity: 0;
108111 }
109112
110-#repo-name:focus {
113+.name:focus {
111114 margin-left: 1ex;
112115 width: 20em;
113116 opacity: 1;
114117 }
115118
116-#repo-name:focus ~ h2 :last-child,
117-#repo-name:not(:focus) ~ .repo-name-btn:not(:active) {
119+.name:focus ~ h2 :last-child,
120+.name:not(:focus) ~ .name-btn:not(:active) {
118121 display: none;
119122 }
120123
121-.repo-name-toggle {
124+.name-toggle {
122125 font-size: 1.3em;
123126 cursor: pointer;
124127 }
125128

Built with git-ssb-web