v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Difference between revisions of "User:Lethosor/css apply.js"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
(Created page with "// Allows enabling/disabling custom css (requires the ".mw-css" class on a "pre" element) $('pre.mw-css').each(function(i,e){ e=$(e); $('<div style="clear:both">').insertA...")
 
(workaround for pre class check)
 
Line 1: Line 1:
// Allows enabling/disabling custom css (requires the ".mw-css" class on a "pre" element)
+
// Allows enabling/disabling custom css
$('pre.mw-css').each(function(i,e){
+
$('body[class*="_css"] pre').each(function(i,e){
 
   e=$(e);
 
   e=$(e);
 
   $('<div style="clear:both">').insertAfter(e);
 
   $('<div style="clear:both">').insertAfter(e);

Latest revision as of 15:32, 20 July 2019

// Allows enabling/disabling custom css
$('body[class*="_css"] pre').each(function(i,e){
  e=$(e);
  $('<div style="clear:both">').insertAfter(e);
  var s=$('<style>').text(e.text()).attr('type', 'text/css');
  $('<button>').text('Disable this CSS').insertAfter(e).click(function(_){
    _.preventDefault();
    s.remove();
  });
  $('<button>').text('Apply this CSS').insertAfter(e).click(function(_){
    _.preventDefault();
    s.appendTo('head');
  });
});