gitprep / templates / include / branch_select.html.ep /
Newer Older
195 lines | 6.111kb
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
1
<%
2
  my $api = gitprep_api;
3
  
improve branch select design
Yuki Kimoto authored on 2016-01-06
4
  my $user = param('user');
5
  my $project = param('project');
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
6
  my $display = stash('display') || '';
7
  my $rev = stash('rev');
8
  $rev = '' unless defined $rev;
9
  my $branches = stash('branches');
improve branch select design
Yuki Kimoto authored on 2016-01-06
10
  my $ssh_rep_url = stash('ssh_rep_url');
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
11

            
12
  my $logined = $api->logined;
improve branch select design
Yuki Kimoto authored on 2015-12-19
13

            
14
  my $type
cleanup branch select
Yuki Kimoto authored on 2015-12-19
15
    = $display eq 'tree' || $display eq 'tree_top' || $display eq 'blob'
improve branch select design
Yuki Kimoto authored on 2015-12-19
16
    ? 'tree' : 'commits';
fix tree bug and improve tre...
Yuki Kimoto authored on 2015-12-19
17
  
improve blog page page path
Yuki Kimoto authored on 2015-12-19
18
  my $path = stash('Path');
improve branch select design
Yuki Kimoto authored on 2016-01-04
19

            
20
  my $title;
21
  my $rev_short;
22
  if (defined $rev && length $rev == 40) {
improve tree design
Yuki Kimoto authored on 2016-01-07
23
    $title = 'Tree';
improve branch select design
Yuki Kimoto authored on 2016-01-04
24
    $rev_short = substr($rev, 0, 10);
25
  }
26
  else {
improve tree design
Yuki Kimoto authored on 2016-01-07
27
    $title = 'Branch';
improve branch select design
Yuki Kimoto authored on 2016-01-04
28
    $rev_short = $rev;
29
  }
improve branch select design
Yuki Kimoto authored on 2016-01-06
30
  
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
31
%>
32

            
33
%= javascript begin
34
  $(document).ready(function () {
35
  
cleanup
Yuki Kimoto authored on 2015-12-19
36
    // Switch branches and tags
37
    var revs_init = false;
38
    $('#rev-btn').on('click', function () {
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
39
      
cleanup
Yuki Kimoto authored on 2015-12-19
40
      if (!revs_init) {
41
        $.get('<%= url_for("/$user/$project/api/revs") %>', function (result) {
42
          var branch_names = result.branch_names;
43
          var tag_names = result.tag_names;
44
          var style = 'style="border-top-left-radius:0px;border-top-right-radius:0px;"';
45
          
46
          if (branch_names.length === 0) {
47
            $('#branch-names-list').append(
48
              '<li><a ' + style + ' href="#">No branches</a></li>'
49
            );
50
          }
51
          else {
52
            for (var i = 0; i < branch_names.length; i++) {
53
              var branch_name = branch_names[i];
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
54
              $('#branch-names-list').append(
cleanup
Yuki Kimoto authored on 2015-12-19
55
                '<li><a ' + style + ' href="<%= url_for("/$user/$project/$type/") %>' + branch_name + '">' + branch_name + '</a></li>'
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
56
              );
57
            }
cleanup
Yuki Kimoto authored on 2015-12-19
58
          }
59
          
60
          if (tag_names.length === 0) {
61
            $('#tag-names-list').append(
62
              '<li><a ' + style + ' href="#">No tags</a></li>'
63
            );
64
          }
65
          else {
66
            for (var i = 0; i < tag_names.length; i++) {
67
              var tag_name = tag_names[i];
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
68
              $('#tag-names-list').append(
cleanup
Yuki Kimoto authored on 2015-12-19
69
                '<li><a ' + style + ' href="<%= url_for("/$user/$project/$type/") %>' + tag_name + '">' + tag_name + '</a></li>'
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
70
              );
71
            }
cleanup
Yuki Kimoto authored on 2015-12-19
72
          }
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
73
          $('#rev-popup')
74
            .css('display', 'block')
75
            .css('top', '5px')
76
            .css('left', '0px')
77
          ;
cleanup
Yuki Kimoto authored on 2015-12-19
78
        });
79
        revs_init = true;
80
      }
81
      else {
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
82
        $('#rev-popup')
83
          .css('display', 'block')
84
          .css('top', '5px')
85
          .css('left', '0px')
86
        ;
cleanup
Yuki Kimoto authored on 2015-12-19
87
      }
88
    });
89

            
90
    $('#revs-tab a').click(function (e) {
91
      e.preventDefault();
92
      $(this).tab('show');
93
    })
94
    
95
    $('#rev-close').on('click', function () {
96
      $('#rev-popup').css('display', 'none');
97
    });
improve branch select design
Yuki Kimoto authored on 2016-01-06
98
    
99
    
100
    // Repository URL buttons
101
    var http_rep_url = '<%= url_for("$user/$project.git")->to_abs %>';
102
    
103
    var logined = <%= $logined ? 'true' : 'false' %>;
104
    var ssh_rep_url = '<%= $ssh_rep_url %>';
105
    
106
    // Click HTTP button
107
    $('#btn_http').on('click', function () {
108
      $('#rep_url').val(http_rep_url);
109
      $('#btn_http').addClass('btn-info');
110
      $('#btn_ssh').removeClass('btn-info');
111
    });
112

            
113
    // Click SSH button
114
    $('#btn_ssh').on('click', function () {
115
      $('#rep_url').val(ssh_rep_url);
116
      $('#btn_http').removeClass('btn-info');
117
      $('#btn_ssh').addClass('btn-info');
118
    });
119

            
120
    // Initialize
121
    if (logined) {
122
      $('#btn_ssh').trigger('click');
123
    }
124
    else {
125
      $('#btn_http').trigger('click');
126
    }
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
127
  });
128
% end
129

            
improve branch select design
Yuki Kimoto authored on 2016-01-04
130
<div class="branch-select-container">
fix branch select design bug
Yuki Kimoto authored on 2016-01-06
131
  <div class="branch-select-left-container <%= $display eq 'tree' || $display eq 'blob' ? 'branch-select-left-container-page-path' : '' %>">
improve branch header design
Yuki Kimoto authored on 2016-11-29
132
    <button id="rev-btn" class="btn" style="padding-top:6px">
133
      <span><%= $title %>:</span> <b><%= $rev_short %></b> <i class="icon-arrow-down" style="position: relative;top:-1px;left:2px;"></i>
cleanup
Yuki Kimoto authored on 2015-12-19
134
    </button>
complete branch select desig...
Yuki Kimoto authored on 2016-01-06
135
    % if ($display eq 'tree' || $display eq 'blob') {
136
        %= include '/include/page_path', Path => $path;
137
    % }
cleanup
Yuki Kimoto authored on 2015-12-19
138
  </div>
improve branch select design
Yuki Kimoto authored on 2016-01-04
139
    % if ($display eq 'tree_top') {
complete branch select desig...
Yuki Kimoto authored on 2016-01-06
140
      <div class="branch-select-right-container">
141
        <ul class="git-url-container">
142
          % if ($logined) {
143
            <li>
improve branch header design
Yuki Kimoto authored on 2016-11-29
144
              <button class="btn btn-primary" id="btn_ssh">SSH</button>
complete branch select desig...
Yuki Kimoto authored on 2016-01-06
145
            </li>
146
          % }
improve branch select design
Yuki Kimoto authored on 2016-01-04
147
          <li>
improve branch header design
Yuki Kimoto authored on 2016-11-29
148
            <button class="btn <%= !$logined ? 'btn-info' : '' %>" id="btn_http"><%= $self->req->is_secure ? 'HTTPS' : 'HTTP' %></button>
improve branch select design
Yuki Kimoto authored on 2016-01-04
149
          </li>
complete branch select desig...
Yuki Kimoto authored on 2016-01-06
150
          <li>
151
            <input id="rep_url" type="text">
152
          </li>
153
          <li>
154
            <div class="donwload-zip">
improve branch header design
Yuki Kimoto authored on 2016-11-29
155
              <a title="Download ZIP" class="btn" href="<%= url_for("/$user/$project/archive/$rev.zip") %>">
add tar.gz donwload button
Yuki Kimoto authored on 2016-08-17
156
                ZIP
157
              </a>
improve branch header design
Yuki Kimoto authored on 2016-11-29
158
              <a title="Download tar.gz" class="btn" href="<%= url_for("/$user/$project/archive/$rev.tar.gz") %>">
add tar.gz donwload button
Yuki Kimoto authored on 2016-08-17
159
                tar.gz
complete branch select desig...
Yuki Kimoto authored on 2016-01-06
160
              </a>
161
            </div>
162
          </li>
163
        </ul>
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
164
      </div>
improve branch select design
Yuki Kimoto authored on 2016-01-04
165
    % }
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
166
</div>
167

            
168
<div style="position:relative">
cleanup
Yuki Kimoto authored on 2015-12-19
169
  <div id="rev-popup" style="display:none;width:330px;position:absolute">
170
    <div class="radius-top border-gray" style="background:#E6E6FA;padding:10px">
improve tag select design
Yuki Kimoto authored on 2016-02-01
171
      <div style="overflow:hidden">
172
        <div style="float:left;width:90%">
cleanup
Yuki Kimoto authored on 2015-12-19
173
          <b>Switch branches/tags</b>
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
174
        </div>
improve tag select design
Yuki Kimoto authored on 2016-02-01
175
        <div style="width:10%;float:right;text-align:right">
cleanup
Yuki Kimoto authored on 2015-12-19
176
          <i id="rev-close" class="icon-remove-circle"></i>
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
177
        </div>
178
      </div>
179
    </div>
cleanup
Yuki Kimoto authored on 2015-12-19
180
    <ul class="nav nav-tabs" id="revs-tab" style="background:#F5F5F5;margin-bottom:0">
181
      <li class="active"><a href="#branches">Branches</a></li>
182
      <li><a href="#tags">Tags</a></li>
183
    </ul>
184
    <div class="tab-content">
185
      <div class="tab-pane active" id="branches" style="background:white;max-height:300px;overflow:auto;margin-top:0">
186
        <ul id="branch-names-list" class="nav nav-tabs nav-stacked">
187
        </ul>
188
      </div>
189
      <div class="tab-pane" id="tags" style="background:white;max-height:300px;overflow:auto;margin-top:0">
190
        <ul id="tag-names-list" class="nav nav-tabs nav-stacked">
191
        </ul>
improve commits header desig...
Yuki Kimoto authored on 2015-12-19
192
      </div>
193
    </div>
cleanup
Yuki Kimoto authored on 2015-12-19
194
  </div>
simplify commits page
Yuki Kimoto authored on 2015-12-18
195
</div>