Changeset 3880:e6d1f6d9d7df for themes
- Timestamp:
- 09/18/18 20:22:10 (7 years ago)
- Branch:
- default
- Location:
- themes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
themes/berlin/js/berlin.js
r3709 r3880 5 5 // Show/Hide main menu 6 6 $('.header__nav'). 7 before( '<button id="hamburger" type="button"><span class="visually-hidden">' + dotclear_berlin_navigation + '</span></button>').7 before(`<button id="hamburger" type="button"><span class="visually-hidden">${dotclear_berlin_navigation}</span></button>`). 8 8 toggle(); 9 9 $('#hamburger').click(function() { … … 12 12 }); 13 13 // Show/Hide sidebar on small screens 14 $('#main').prepend( '<button id="offcanvas-on" type="button"><span class="visually-hidden">' + dotclear_berlin_show_menu + '</span></button>');14 $('#main').prepend(`<button id="offcanvas-on" type="button"><span class="visually-hidden">${dotclear_berlin_show_menu}</span></button>`); 15 15 $('#offcanvas-on').click(function() { 16 var btn = $('<button id="offcanvas-off" type="button"><span class="visually-hidden">' + dotclear_berlin_hide_menu + '</span></button>');16 const btn = $(`<button id="offcanvas-off" type="button"><span class="visually-hidden">${dotclear_berlin_hide_menu}</span></button>`); 17 17 $('#wrapper').addClass('off-canvas'); 18 18 $('#footer').addClass('off-canvas'); -
themes/default/js/post.js
r3706 r3880 5 5 $('#comment-form p:has(input[type=submit][name=preview],button[type=submit][name=preview])'). 6 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>' 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 10 ); 11 11 … … 46 46 47 47 function setCookie() { 48 varname = $('#c_name').val();49 varmail = $('#c_mail').val();50 varsite = $('#c_site').val();51 varcpath = $('link[rel=top]').attr('href');48 const name = $('#c_name').val(); 49 const mail = $('#c_mail').val(); 50 const site = $('#c_site').val(); 51 let cpath = $('link[rel=top]').attr('href'); 52 52 if (!cpath) { 53 53 cpath = '/'; … … 73 73 return false; 74 74 } 75 76 var s = c.split('\n'); 77 75 const s = c.split('\n'); 78 76 if (s.length != 3) { 79 77 dropCookie(); 80 78 return false; 81 79 } 82 83 80 return s; 84 81 } -
themes/ductile/ductile.js
r3706 r3880 2 2 'use strict'; 3 3 4 $( function() {5 var create_name = function(text) {4 $(document).ready(function() { 5 if ($(window).width() < 1024) { 6 6 7 // Convert text to lower case. 8 var name = text.toLowerCase(); 7 const create_name = function(text) { 9 8 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, ''); 9 // Convert text to lower case. 10 let name = text.toLowerCase(); 13 11 14 // Replace '&' with 'and'. 15 name = name.replace(/&/g, 'and'); 12 // Remove leading and trailing spaces, and any non-alphanumeric 13 // characters except for ampersands, spaces and dashes. 14 name = name.replace(/^\s+|\s+$|[^a-z0-9&\s-]/g, ''); 16 15 17 // Replaces spaces with dashes.18 name = name.replace(/\s/g, '-');16 // Replace '&' with 'and'. 17 name = name.replace(/&/g, 'and'); 19 18 20 // Squash any duplicatedashes.21 name = name.replace(/(-)+\1/g, '$1');19 // Replaces spaces with dashes. 20 name = name.replace(/\s/g, '-'); 22 21 23 return name;24 };22 // Squash any duplicate dashes. 23 name = name.replace(/(-)+\1/g, '$1'); 25 24 26 var add_link = function() { 25 return name; 26 }; 27 27 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()); 28 // Set toggle class to each #sidebar h2 29 $('#sidebar div div h2').addClass('toggle'); 31 30 32 // Create a name attribute in the following sibling 33 // to act as a fragment anchor. 34 $(this).next().attr('name', name); 31 // Hide all h2.toggle siblings 32 $('#sidebar div div h2').nextAll().hide(); 35 33 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 }; 34 // Add a link to each h2.toggle element. 35 $('h2.toggle').each(function() { 44 36 45 var toggle = function(event) { 46 event.preventDefault(); 37 // Convert the h2 element text into a value that 38 // is safe to use in a name attribute. 39 const name = create_name($(this).text()); 47 40 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 }; 41 // Create a name attribute in the following sibling 42 // to act as a fragment anchor. 43 $(this).next().attr('name', name); 54 44 55 var remove_focus = function() { 56 // Use the blur() method to remove focus. 57 $(this).blur(); 58 }; 45 // Replace the h2.toggle element with a link to the 46 // fragment anchor. Use the h2 text to create the 47 // link title attribute. 48 $(this).html( 49 '<a href="#' + name + '" title="Reveal ' + 50 $(this).text() + ' content">' + 51 $(this).html() + '</a>'); 52 }); 59 53 60 $(document).ready(function() { 61 if ($(window).width() < 1024) { 54 // Add a click event handler to all h2.toggle elements. 55 $('h2.toggle').click(function(event) { 56 event.preventDefault(); 57 // Toggle the 'expanded' class of the h2.toggle 58 // element, then apply the slideToggle effect 59 // to all siblings. 60 $(this).toggleClass('expanded'). 61 nextAll().slideToggle('fast'); 62 }); 62 63 63 // Set toggle class to each #sidebar h2 64 $('#sidebar div div h2').addClass('toggle'); 65 66 // Hide all h2.toggle siblings 67 $('#sidebar div div h2').nextAll().hide(); 68 69 // Add a link to each h2.toggle element. 70 $('h2.toggle').each(add_link); 71 72 // Add a click event handler to all h2.toggle elements. 73 $('h2.toggle').click(toggle); 74 75 // Remove the focus from the link tag when accessed with a mouse. 76 $('h2.toggle a').mouseup(remove_focus); 77 } 78 }); 79 64 // Remove the focus from the link tag when accessed with a mouse. 65 $('h2.toggle a').mouseup(function() { 66 // Use the blur() method to remove focus. 67 $(this).blur(); 68 }); 69 } 80 70 });
Note: See TracChangeset
for help on using the changeset viewer.