1. Takumi IINO
  2. kallithea

Commits

Takumi IINO  committed 61c6dbc Draft

[WIP] replace YUI to jquery

  • Participants
  • Parent commits 7aee161
  • Branches default

Comments (0)

Files changed (2)

File kallithea/templates/changelog/changelog.html

View file
  • Ignore whitespace
 
         <script type="text/javascript" src="${h.url('/js/graph.js')}"></script>
         <script type="text/javascript">
-            YAHOO.util.Event.onDOMReady(function(){
+            $(document).ready(function(){
 
                 //Monitor range checkboxes and build a link to changesets
                 //ranges
-                var checkboxes = YUD.getElementsByClassName('changeset_range');
+                var checkboxes = $('.changeset_range');
                 // register our routes needed for this view
                 pyroutes.register('changeset_home', "${h.url('changeset_home', repo_name='%(repo_name)s', revision='%(revision)s')}", ['repo_name', 'revision']);
 
                 var checkbox_checker = function(e){
-                    var checked_checkboxes = [];
-                    for (pos in checkboxes){
-                        if(checkboxes[pos].checked){
-                            checked_checkboxes.push(checkboxes[pos]);
-                        }
-                    }
-                    if(YUD.get('open_new_pr')){
+                    var checked_checkboxes = $('.changeset_range:checked');
+                    $('#open_new_pr').each(function(){
+                        var target = $(this);
                         if(checked_checkboxes.length>1){
-                            YUD.setStyle('open_new_pr','display','none');
-                        } else {
-                            YUD.setStyle('open_new_pr','display','');
+                            target.css('display','none');
+                        }else{
+                            target.css('display','');
                             if(checked_checkboxes.length>0){
-                                YUD.get('open_new_pr').innerHTML = _TM['Open new pull request for selected changesets'];
+                                target.html(_TM['Open new pull request for selected changesets']);
                             }else{
-                                YUD.get('open_new_pr').innerHTML = _TM['Open new pull request'];
+                                target.html(_TM['Open new pull request']);
                             }
                         }
-                    }
+                    });
 
                     if(checked_checkboxes.length>0){
-                        var rev_end = checked_checkboxes[0].name;
-                        var rev_start = checked_checkboxes[checked_checkboxes.length-1].name;
+                        var rev_end = checked_checkboxes.first().attr('name');
+                        var rev_start = checked_checkboxes.last().attr('name');
                         var url = pyroutes.url('changeset_home', {'repo_name': '${c.repo_name}',
                                                                   'revision': rev_start+'...'+rev_end});
 
 
                         link = link.replace('__S',rev_start.substr(0,6));
                         link = link.replace('__E',rev_end.substr(0,6));
-                        YUD.get('rev_range_container').href = url;
-                        YUD.get('rev_range_container').innerHTML = link;
-                        YUD.setStyle('rev_range_container','display','');
-                        YUD.setStyle('rev_range_clear','display','');
+                        $('#rev_range_container').attr('href', url);
+                        $('#rev_range_container').html(link);
+                        $('#rev_range_container').css('display','');
+                        $('#rev_range_clear').css('display','');
 
-                        YUD.get('open_new_pr').href = pyroutes.url('pullrequest_home',
-                                                                   {'repo_name': '${c.repo_name}',
-                                                                    'rev_start': rev_start,
-                                                                    'rev_end': rev_end})
+                        $('#open_new_pr').attr('href', pyroutes.url('pullrequest_home',
+                                                                    {'repo_name': '${c.repo_name}',
+                                                                     'rev_start': rev_start,
+                                                                     'rev_end': rev_end}));
 
-                        YUD.setStyle('compare_fork','display','none');
+                        $('#compare_fork').css('display', 'none');
                     }else{
-                        YUD.setStyle('rev_range_container','display','none');
-                        YUD.setStyle('rev_range_clear','display','none');
+                        $('#rev_range_container').css('display','none');
+                        $('#rev_range_clear').css('display','none');
                         %if c.revision:
-                            YUD.get('open_new_pr').href = pyroutes.url('pullrequest_home',
-                                                                       {'repo_name': '${c.repo_name}',
-                                                                        'rev_end':'${c.first_revision.raw_id}'});
+                            $('#open_new_pr').attr('href', pyroutes.url('pullrequest_home',
+                                                                        {'repo_name': '${c.repo_name}',
+                                                                         'rev_end':'${c.first_revision.raw_id}'}));
                         %else:
-                            YUD.get('open_new_pr').href = pyroutes.url('pullrequest_home',
-                                                                       {'repo_name': '${c.repo_name}',
-                                                                        'branch':'${c.first_revision.branch}'});
+                            $('#open_new_pr').attr('href', pyroutes.url('pullrequest_home',
+                                                                        {'repo_name': '${c.repo_name}',
+                                                                         'branch':'${c.first_revision.branch}'}));
                         %endif
-                        YUD.setStyle('compare_fork','display','');
+                        $('#compare_fork').css('display', '');
                     }
                 };
-                YUE.onDOMReady(checkbox_checker);
-                YUE.on(checkboxes,'click', checkbox_checker);
+                $(document).ready(checkbox_checker);
+                checkboxes.on('click', checkbox_checker);
 
-                YUE.on('rev_range_clear','click',function(e){
-                    for (var i=0; i<checkboxes.length; i++){
-                        var cb = checkboxes[i];
-                        cb.checked = false;
-                    }
+                $('#rev_range_clear').on('click', function(e){
+                    checkboxes.each(function(){
+                        $(this).removeAttr('checked');
+                    });
                     checkbox_checker();
-                    YUE.preventDefault(e);
+                    e.preventDefault();
                 });
 
-                var msgs = YUQ('.message');
                 // get first element height
-                var el = YUQ('#graph_content .container')[0];
-                var row_h = el.clientHeight;
-                for(var i=0;i<msgs.length;i++){
-                    var m = msgs[i];
-
-                    var h = m.clientHeight;
-                    var pad = YUD.getStyle(m,'padding');
-                    if(h > row_h){
-                        var offset = row_h - (h+12);
-                        YUD.setStyle(m.nextElementSibling,'display','block');
-                        YUD.setStyle(m.nextElementSibling,'margin-top',offset+'px');
-                    };
-                }
+                var el = $('#graph_content .container').first();
+                var row_h = el.attr('clientHeight');
+                $('.message').each(function(){
+                    var m = $(this);
+                    var h = m.attr('clientHeight');
+                    var pad = m.css('padding');
+                    if (h > row_h){
+                      var offset = row_h - (h+12);
+                      m.nextElementSibling.css('display','block');
+                      m.nextElementSibling.css('mergin-top',offset+'px');
+                    }
+                })
 
                 $('.expand_commit').on('click',function(e){
                     var cid = $(this).attr('commit_id');

File kallithea/templates/summary/summary.html

View file
  • Ignore whitespace
 %endif
 
 <script type="text/javascript">
-var clone_url = 'clone_url';
-YUE.on(clone_url,'click',function(e){
-    if(YUD.hasClass(clone_url,'selected')){
+$('#clone_url').on('click', function(e){
+    var target = $(e.currentTarget)
+    if(target.hasClass('selected')){
         return
+    }else{
+        target.addClass('selected');
+        target.select();
     }
-    else{
-        YUD.addClass(clone_url,'selected');
-        YUD.get(clone_url).select();
-    }
-})
+});
 
-YUE.on('clone_by_name','click',function(e){
+$('#clone_by_name').on('click',function(e){
     // show url by name and hide name button
-    YUD.setStyle('clone_url','display','');
-    YUD.setStyle('clone_by_name','display','none');
+    $('#clone_url').css('display','');
+    $('#clone_by_name').css('display','none');
 
     // hide url by id and show name button
-    YUD.setStyle('clone_by_id','display','');
-    YUD.setStyle('clone_url_id','display','none');
+    $('#clone_by_id').css('display','');
+    $('#clone_url_id').css('display','none');
+});
 
-})
-YUE.on('clone_by_id','click',function(e){
-
+$('#clone_by_id').on('click',function(e){
     // show url by id and hide id button
-    YUD.setStyle('clone_by_id','display','none');
-    YUD.setStyle('clone_url_id','display','');
+    $('#clone_by_id').css('display','none');
+    $('#clone_url_id').css('display','');
 
     // hide url by name and show id button
-    YUD.setStyle('clone_by_name','display','');
-    YUD.setStyle('clone_url','display','none');
-})
+    $('#clone_by_name').css('display','');
+    $('#clone_url').css('display','none');
+});
 
 $(document).ready(function(){
     var cache = {}
 
 }
 
-YUD.get('lang_stats').appendChild(tbl);
-YUE.on('code_stats_show_more','click',function(){
-    l = YUD.getElementsByClassName('stats_hidden')
-    for (e in l){
-        YUD.setStyle(l[e],'display','');
-    };
-    YUD.setStyle(YUD.get('code_stats_show_more'),
-            'display','none');
+$('#lang_stats').appendChild(tbl);
+$('#code_status_show_more').on('click',function(){
+    $('.stats_hidden').each(function(){
+      $(this).css('display','');
+    });
+    $('#code_status_show_more').css('display','none');
 });
 </script>
 %endif