Dotclear

Changeset 3706:170617361020 for themes


Ignore:
Timestamp:
02/16/18 16:01:59 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

use strict and no more linter warnings/errors as far as possible

Location:
themes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • themes/berlin/tpl/user_footer.html

    r3427 r3706  
    11<script type="text/javascript"> 
    2      $("html").addClass("js"); 
    3      // Show/Hide main menu 
    4      $(".header__nav"). 
    5      before('<button id="hamburger" type="button"><span class="visually-hidden">' + dotclear_berlin_navigation + '</span></button>'). 
    6      toggle(); 
    7      $("#hamburger").click(function() { 
    8           $(this).toggleClass("open"); 
    9           $(".header__nav").toggle('easing'); 
    10      }); 
    11      // Show/Hide sidebar on small screens 
    12      $("#main").prepend('<button id="offcanvas-on" type="button"><span class="visually-hidden">' + dotclear_berlin_show_menu + '</span></button>'); 
    13      $("#offcanvas-on").click(function() { 
    14           var btn = $('<button id="offcanvas-off" type="button"><span class="visually-hidden">' + dotclear_berlin_hide_menu + '</span></button>'); 
    15           $("#wrapper").addClass("off-canvas"); 
    16           $("#footer").addClass("off-canvas"); 
    17           $("#sidebar").prepend(btn); 
    18           btn.click(function(evt) { 
    19                $("#wrapper").removeClass("off-canvas"); 
    20                $("#footer").removeClass("off-canvas"); 
    21                evt.target.remove(); 
    22           }); 
    23      }); 
    24      $(document).ready(function() { 
    25           // totop scroll 
    26           $(window).scroll(function() { 
    27                if ($(this).scrollTop() != 0) { 
    28                     $('#gotop').fadeIn(); 
    29                } else { 
    30                     $('#gotop').fadeOut(); 
    31                } 
    32           }); 
    33           $('#gotop').click(function(e) { 
    34                $('body,html').animate({ 
    35                     scrollTop: 0 
    36                }, 800); 
    37                e.preventDefault(); 
    38           }); 
    39      }); 
     2  'use strict'; 
     3  $('html').addClass('js'); 
     4  // Show/Hide main menu 
     5  $('.header__nav'). 
     6  before('<button id="hamburger" type="button"><span class="visually-hidden">' + dotclear_berlin_navigation + '</span></button>'). 
     7  toggle(); 
     8  $('#hamburger').click(function() { 
     9    $(this).toggleClass('open'); 
     10    $('.header__nav').toggle('easing'); 
     11  }); 
     12  // Show/Hide sidebar on small screens 
     13  $('#main').prepend('<button id="offcanvas-on" type="button"><span class="visually-hidden">' + dotclear_berlin_show_menu + '</span></button>'); 
     14  $('#offcanvas-on').click(function() { 
     15    var btn = $('<button id="offcanvas-off" type="button"><span class="visually-hidden">' + dotclear_berlin_hide_menu + '</span></button>'); 
     16    $('#wrapper').addClass('off-canvas'); 
     17    $('#footer').addClass('off-canvas'); 
     18    $('#sidebar').prepend(btn); 
     19    btn.click(function(evt) { 
     20      $('#wrapper').removeClass('off-canvas'); 
     21      $('#footer').removeClass('off-canvas'); 
     22      evt.target.remove(); 
     23    }); 
     24  }); 
     25  $(document).ready(function() { 
     26    // totop scroll 
     27    $(window).scroll(function() { 
     28      if ($(this).scrollTop() != 0) { 
     29        $('#gotop').fadeIn(); 
     30      } else { 
     31        $('#gotop').fadeOut(); 
     32      } 
     33    }); 
     34    $('#gotop').click(function(e) { 
     35      $('body,html').animate({ 
     36        scrollTop: 0 
     37      }, 800); 
     38      e.preventDefault(); 
     39    }); 
     40  }); 
    4041</script> 
  • themes/default/js/post.js

    r2633 r3706  
     1/*global $, post_remember_str */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      $('#comment-form p:has(input[type=submit][name=preview],button[type=submit][name=preview])'). 
    3           before( 
    4                '<p class="remember"><input type="checkbox" id="c_remember" name="c_remember" /> ' + 
    5                '<label for="c_remember">' + post_remember_str + '</label>' + 
    6                '</p>' 
    7           ); 
     5  $('#comment-form p:has(input[type=submit][name=preview],button[type=submit][name=preview])'). 
     6  before( 
     7    '<p class="remember"><input type="checkbox" id="c_remember" name="c_remember" /> ' + 
     8    '<label for="c_remember">' + post_remember_str + '</label>' + 
     9    '</p>' 
     10  ); 
    811 
    9      var cookie = readCookie($.cookie('comment_info')); 
     12  var cookie = readCookie($.cookie('comment_info')); 
    1013 
     14  if (cookie != false) { 
     15    $('#c_name').val(cookie[0]); 
     16    $('#c_mail').val(cookie[1]); 
     17    $('#c_site').val(cookie[2]); 
     18    $('#c_remember').attr('checked', 'checked'); 
     19  } 
    1120 
    12      if (cookie != false) { 
    13           $('#c_name').val(cookie[0]); 
    14           $('#c_mail').val(cookie[1]); 
    15           $('#c_site').val(cookie[2]); 
    16           $('#c_remember').attr('checked','checked'); 
    17      } 
     21  $('#c_remember').click(function() { 
     22    if (this.checked) { 
     23      setCookie(); 
     24    } else { 
     25      dropCookie(); 
     26    } 
     27  }); 
    1828 
    19      $('#c_remember').click(function() { 
    20           if (this.checked) { 
    21                setCookie(); 
    22           } else { 
    23                dropCookie(); 
    24           } 
    25      }); 
     29  $('#c_name').change(function() { 
     30    if ($('#c_remember').get(0).checked) { 
     31      setCookie(); 
     32    } 
     33  }); 
    2634 
    27      $('#c_name').change(function() { 
    28           if ($('#c_remember').get(0).checked) { 
    29                setCookie(); 
    30           } 
    31      }); 
     35  $('#c_mail').change(function() { 
     36    if ($('#c_remember').get(0).checked) { 
     37      setCookie(); 
     38    } 
     39  }); 
    3240 
    33      $('#c_mail').change(function() { 
    34           if ($('#c_remember').get(0).checked) { 
    35                setCookie(); 
    36           } 
    37      }); 
     41  $('#c_site').change(function() { 
     42    if ($('#c_remember').get(0).checked) { 
     43      setCookie(); 
     44    } 
     45  }); 
    3846 
    39      $('#c_site').change(function() { 
    40           if ($('#c_remember').get(0).checked) { 
    41                setCookie(); 
    42           } 
    43      }); 
     47  function setCookie() { 
     48    var name = $('#c_name').val(); 
     49    var mail = $('#c_mail').val(); 
     50    var site = $('#c_site').val(); 
     51    var cpath = $('link[rel=top]').attr('href'); 
     52    if (!cpath) { 
     53      cpath = '/'; 
     54    } else { 
     55      cpath = cpath.replace(/.*:\/\/[^\/]*([^?]*).*/g, '$1'); 
     56    } 
    4457 
    45      function setCookie() { 
    46           var name = $('#c_name').val(); 
    47           var mail = $('#c_mail').val(); 
    48           var site = $('#c_site').val(); 
    49           var cpath = $('link[rel=top]').attr('href'); 
    50           if (!cpath) { 
    51                cpath = "/"; 
    52           } else { 
    53                cpath = cpath.replace(/.*:\/\/[^\/]*([^?]*).*/g,"$1"); 
    54           } 
     58    $.cookie('comment_info', name + '\n' + mail + '\n' + site, { 
     59      expires: 60, 
     60      path: cpath 
     61    }); 
     62  } 
    5563 
    56           $.cookie('comment_info', name + '\n' + mail + '\n' + site, {expires: 60, path: cpath}); 
    57      } 
     64  function dropCookie() { 
     65    $.cookie('comment_info', '', { 
     66      expires: -30, 
     67      path: '/' 
     68    }); 
     69  } 
    5870 
    59      function dropCookie() { 
    60           $.cookie('comment_info','',{expires: -30, path: '/'}); 
    61      } 
     71  function readCookie(c) { 
     72    if (!c) { 
     73      return false; 
     74    } 
    6275 
    63      function readCookie(c) { 
    64           if (!c) { 
    65                return false; 
    66           } 
     76    var s = c.split('\n'); 
    6777 
    68           var s = c.split('\n'); 
     78    if (s.length != 3) { 
     79      dropCookie(); 
     80      return false; 
     81    } 
    6982 
    70           if (s.length != 3) { 
    71                dropCookie(); 
    72                return false; 
    73           } 
    74  
    75           return s; 
    76      } 
     83    return s; 
     84  } 
    7785}); 
  • themes/ductile/ductile.js

    r2566 r3706  
     1/*global $ */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      var create_name = function(text) { 
     5  var create_name = function(text) { 
    36 
    4           // Convert text to lower case. 
    5           var name = text.toLowerCase(); 
     7    // Convert text to lower case. 
     8    var name = text.toLowerCase(); 
    69 
    7           // Remove leading and trailing spaces, and any non-alphanumeric 
    8           // characters except for ampersands, spaces and dashes. 
    9           name = name.replace(/^\s+|\s+$|[^a-z0-9&\s-]/g, ''); 
     10    // Remove leading and trailing spaces, and any non-alphanumeric 
     11    // characters except for ampersands, spaces and dashes. 
     12    name = name.replace(/^\s+|\s+$|[^a-z0-9&\s-]/g, ''); 
    1013 
    11           // Replace '&' with 'and'. 
    12           name = name.replace(/&/g, 'and'); 
     14    // Replace '&' with 'and'. 
     15    name = name.replace(/&/g, 'and'); 
    1316 
    14           // Replaces spaces with dashes. 
    15           name = name.replace(/\s/g, '-'); 
     17    // Replaces spaces with dashes. 
     18    name = name.replace(/\s/g, '-'); 
    1619 
    17           // Squash any duplicate dashes. 
    18           name = name.replace(/(-)+\1/g, "$1"); 
     20    // Squash any duplicate dashes. 
     21    name = name.replace(/(-)+\1/g, '$1'); 
    1922 
    20           return name; 
    21      }; 
     23    return name; 
     24  }; 
    2225 
    23      var add_link = function() { 
     26  var add_link = function() { 
    2427 
    25           // Convert the h2 element text into a value that 
    26           // is safe to use in a name attribute. 
    27           var name = create_name($(this).text()); 
     28    // Convert the h2 element text into a value that 
     29    // is safe to use in a name attribute. 
     30    var name = create_name($(this).text()); 
    2831 
    29           // Create a name attribute in the following sibling 
    30           // to act as a fragment anchor. 
    31           $(this).next().attr('name', name); 
     32    // Create a name attribute in the following sibling 
     33    // to act as a fragment anchor. 
     34    $(this).next().attr('name', name); 
    3235 
    33           // Replace the h2.toggle element with a link to the 
    34           // fragment anchor.  Use the h2 text to create the 
    35           // link title attribute. 
    36           $(this).html( 
    37                '<a href="#' + name + '" title="Reveal ' + 
    38                $(this).text() + ' content">' + 
    39                $(this).html() + '</a>'); 
    40      }; 
     36    // Replace the h2.toggle element with a link to the 
     37    // fragment anchor.  Use the h2 text to create the 
     38    // link title attribute. 
     39    $(this).html( 
     40      '<a href="#' + name + '" title="Reveal ' + 
     41      $(this).text() + ' content">' + 
     42      $(this).html() + '</a>'); 
     43  }; 
    4144 
    42      var toggle = function(event) { 
    43           event.preventDefault(); 
     45  var toggle = function(event) { 
     46    event.preventDefault(); 
    4447 
    45           // Toggle the 'expanded' class of the h2.toggle 
    46           // element, then apply the slideToggle effect 
    47           // to all siblings. 
    48           $(this).toggleClass('expanded'). 
    49                nextAll().slideToggle('fast'); 
    50      }; 
     48    // Toggle the 'expanded' class of the h2.toggle 
     49    // element, then apply the slideToggle effect 
     50    // to all siblings. 
     51    $(this).toggleClass('expanded'). 
     52    nextAll().slideToggle('fast'); 
     53  }; 
    5154 
    52      var remove_focus = function() { 
    53        // Use the blur() method to remove focus. 
    54        $(this).blur(); 
    55      }; 
     55  var remove_focus = function() { 
     56    // Use the blur() method to remove focus. 
     57    $(this).blur(); 
     58  }; 
    5659 
    57      $(document).ready (function () { 
    58           if ($(window).width() < 1024) { 
     60  $(document).ready(function() { 
     61    if ($(window).width() < 1024) { 
    5962 
    60                // Set toggle class to each #sidebar h2 
    61                $("#sidebar div div h2").addClass('toggle'); 
     63      // Set toggle class to each #sidebar h2 
     64      $('#sidebar div div h2').addClass('toggle'); 
    6265 
    63                // Hide all h2.toggle siblings 
    64                $('#sidebar div div h2').nextAll().hide(); 
     66      // Hide all h2.toggle siblings 
     67      $('#sidebar div div h2').nextAll().hide(); 
    6568 
    66                // Add a link to each h2.toggle element. 
    67                $('h2.toggle').each(add_link); 
     69      // Add a link to each h2.toggle element. 
     70      $('h2.toggle').each(add_link); 
    6871 
    69                // Add a click event handler to all h2.toggle elements. 
    70                $('h2.toggle').click(toggle); 
     72      // Add a click event handler to all h2.toggle elements. 
     73      $('h2.toggle').click(toggle); 
    7174 
    72                // Remove the focus from the link tag when accessed with a mouse. 
    73                $('h2.toggle a').mouseup(remove_focus); 
    74           } 
    75      }) 
     75      // Remove the focus from the link tag when accessed with a mouse. 
     76      $('h2.toggle a').mouseup(remove_focus); 
     77    } 
     78  }); 
    7679 
    7780}); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map