Moved JS into its own file.
[catagits/Gitalist.git] / root / wrapper.tt2
index 3cef238..8426d65 100755 (executable)
   [% INCLUDE '_header_feeds.tt2' %]
    
        <link rel="stylesheet" type="text/css" href="[% c.uri_for('/core.css') %]" />
-       <link rel="shortcut icon" href="[% c.uri_for('/static/git-favicon.png') %]" type="image/png" />
-       <script type="text/javascript">
-       // FIXME: this should be in an external js file once c.uri_for works in js files
-       function compareDiffs(repo, path){
-               var f = document.theform;
-               if(!repo){
-                       var repo = "";
-               }
-               if(!path){
-                       var path = "";
-               }
-               var sha1,sha2;
-               for(var i=0,len=f.length;i<len;i++){
-                       if(f[i].name == "sha1_a"){
-                               if(f[i].checked){
-                                       sha1 = f[i].value;
-                               }
-                       }
-                       if(f[i].name == "sha1_b"){
-                               if(f[i].checked){
-                                       sha2 = f[i].value;
-                               }
-                       }
-               }
-               document.location.href = "[% c.uri_for("/") %]" + repo + "/"+ sha1 + "/diff/" + sha2 + "/" + path;
-       }
-       // handles hover sub menus in IE
-       startList = function() {
-               if (document.getElementById && document.getElementById("actions_nav_link")) {
-                       var navList = document.getElementById("actions_nav_list");
-                       var navLink = document.getElementById("actions_nav_link");
-                       // assign event handlers to each element
-                       navLink.onmouseover=function() {
-                               setNavClass(navList);
-                       }
-                       navList.onmouseover=function() {
-                               setNavClass(navList);
-                       }
-                       navList.onmouseout=function() {
-                               navList.className=navList.className.replace(" actions_nav_list_over", "");
-                       }
-                       navLink.onmouseout=function() {
-                               navList.className=navList.className.replace(" actions_nav_list_over", "");
-                       }
-               }
-               
-       }
-       function setNavClass(el){
-               var link_el = document.getElementById("actions_nav_link");
-               var offsetAry = findPos(link_el);
-               // set position of list
-               el.style.left = offsetAry[0]+"px";
-               el.style.top = offsetAry[1]+30 +"px";
-               el.className+=" actions_nav_list_over";
-       }
-       
-       function addLoadListener(fn){ 
-               if (typeof window.addEventListener != 'undefined') { 
-                       window.addEventListener('load', fn, false); 
-               }else if (typeof document.addEventListener != 'undefined'){ 
-                       document.addEventListener('load', fn, false); 
-               }else if (typeof window.attachEvent != 'undefined'){ 
-                       window.attachEvent('onload', fn); 
-               }else{ 
-                       var oldfn = window.onload; 
-                       if (typeof window.onload != 'function'){ 
-                               window.onload = fn; 
-                       }else{ 
-                               window.onload = function(){
-                                       oldfn();
-                                       fn();
-                               }; 
-                       }
-               }
-       }
-       function findPos(obj) {
-               var curleft = curtop = 0;
-               if (obj.offsetParent) {
-               do {
-                       curleft += obj.offsetLeft;
-                       curtop += obj.offsetTop;
-               } 
-               while (obj = obj.offsetParent);
-               return [curleft,curtop];
-               }
-       }
-       addLoadListener(startList);
-       </script>
+       <link rel="shortcut icon" href="[% c.uri_for('/static/favicon.ico') %]" />
+       <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+       <script src="[% c.uri_for('/static/js/site.js') %]"></script>
 </head>
 
 <body>
 
                                
                                <li id="branch_selector">
-                                       [%# FIXME: convert to c.uri_for_action  #%]
-                                       
                                        Branches 
-                                       <select onchange="document.location.href='/[% Repository.name %]/'+this.options[this.selectedIndex].text + '/shortlog';">
+                                       <select id='branch-list'>
                                                <option value="">HEAD</option>
-                                       
-                                       [% FOREACH branch_head IN Repository.heads %]
-                                               <option [% "selected" IF c.req.path.search(branch_head.name) %]>[% branch_head.name %]</option>
+                                       [% FOREACH branch IN Repository.heads %]
+                                               <option value="[% branch.name %]">[% branch.name %]</option>
                                        [% END %]
                                        
                                        </select>
                        
                        
                        [%- 
+                               
+                               #FIXME on a history view of a folder, don't show extra actions in dropdown
+                               SET on_file_page = 1;
+                               
                                SET actions_list = {
                                                "blob"          => 1,
                                                "raw"           => 1,
                                                                        .replace("fancy","")
                                                                        .replace("index","Repositories");
                                action_name_ucfirst = action_name FILTER ucfirst;
-                               IF actions_list.$action_name;
+                               IF actions_list.$action_name && on_file_page;
                                        '<a href="#" id="actions_nav_link"><span>' _ action_name_ucfirst _ '</span></a>';
                                ELSE;
                                        action_name_ucfirst;
                                                action_output = action.key FILTER ucfirst;
                                                NEXT IF action_output == action_name_ucfirst;   
                                                action = action.key;
-                                               '<li><a href="/' _ c.req.path.replace(action_name, action) _ '">' _ action_output _ '</a></li>';
+                                               '<li><a href="' _ c.uri_for("/")  _ c.req.path.replace(action_name, action) _ '">' _ action_output _ '</a></li>';
                                        END;                    
                                '</ul>';
                                END;
        [% USE Dumper %]
        <pre>
        [% Repository.path %]
-       [%# Dumper.dump(c.req.path) %]
+       [% Dumper.dump(c.req.args) %]
        </pre>
        
        </div>
 </div>
 
+<span id="current-uri">[%
+      # A bit of smoke and mirrors to get the /repository/shortlog URIs working
+      cur_act = '' _ c.action;
+      cur_uri = cur_act.match("log") || cur_act.match("^ref")
+              ? '/ref/' _ cur_act.replace("^(repository|ref)/", '')
+             : cur_act;
+      # XXX I just want an empty list!
+      IF c.req.args.size > 0;
+          c.uri_for_action(cur_uri, [Repository.name, 'HEAD'], c.req.args);
+      ELSE;
+          c.uri_for_action(cur_uri, [Repository.name, 'HEAD']);
+      END;
+%]</span>
+
 </body>
 </html>
 [%- END -%]