MediaWiki:Common.js
From dataZoa Wiki
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
/* Any JavaScript here will be loaded for all users on every page load. */ /* Global overrides for styling */ $('body').addClass('GbcWIKI'); $('#mw-head').addClass('GbcWIKI'); $('#mw-head').height('80px'); // horrible temporary kludge for chrome $('#mw-page-base').addClass('GbcWIKI') $('#mw-head-base').addClass('GbcWIKI') /* stop wasting space */ $('#editpage-copywarn').hide(); $('.mw-editinginterface').hide(); $('.mw-translateinterface').hide(); $('#wpSummaryLabel').hide(); $('#wpSummary').hide(); $('#editCheckBoxes').hide(); // js for changing the image if($('.changeimage').length > 0) { var image = $('.changeimage'); image = image[0]; image.style.background = "url(https://www.datazoa.com/img/vert_data_table.png)"; image.style.backgroundPosition = "0px 0px"; //change the first number for horizontal positioning, the second number for vertical image.style.backgroundRepeat = "no-repeat"; image.style.width = "600px"; image.style.height = "200px"; } // Load images from OUTSIDE the wiki -- needs some kludges... // js for imgSnippet (show a shifted part of a foreign image) // Model: <div class="imgSnippetWrap1"><div class="imgSnippet " data-styler="{ view: nnn, styler: '...stylestr...' }"></div></div> // Copy the View string from Decorator.asp //var g_althost = ''; // set to e.g. https://www.datahydra.com var g_althost = 'http://www.datahydra.com'; $('.imgSnippet').each( function() { var elem = $(this); eval( "var styler = " + elem.data('styler')); elem.attr('style', styler.style.replace(/SQ/g,"'").replace('/img/DocSamples',g_althost+'/img/DocSamples')); elem.addClass( 'decoratorView' + styler.view); // watermark reminder when under development if ( g_althost.toLowerCase().indexOf('datazoa.com') < 0 ) { elem.text(' ' + g_althost); elem.css('color','orange'); elem.css('font-weight','bold'); elem.css('font-size','xx-small'); } }); // workhorse for imgWhole, loads a foreign image (after page load, to avoid MediaWiki limitation) // for elem, takes an attr called data-guts, which is a string that evals to an object, slaps it into the elem itself imgWholeFunc = function( elem, scrollOpt ) { if ( undefined === elem.attr('style') ) { elem.attr('style',''); } // assert a style attr eval( "var guts = " + elem.data('guts')); // get the string for attr data-guts if ( undefined !== guts ) { elem.attr('title', guts.title); elem.attr('style', elem.attr('style') + ' ' + 'background: transparent url(' + g_imgWholeHost + guts.url + ') scroll 0 0; background-repeat: no-repeat; '); elem.attr('style', elem.attr('style') + ' ' + guts.xtraStyle); } } // Model: <div class="imgWholeWrap1"><div class="imgWhole " data-guts="{ url: '...', xtraStyle: '...stylestr...' }"></div></div> // example to insert an icon from dataZoa.com: // <div class="imgWholeWrap1"><div class="imgWhole " data-guts="{ url: '/img/Hint.png', title: 'Hint example', xtraStyle: ' min-height: 16px; min-width: 16px;' }"></div></div> var g_imgWholeHost = "https://www.datazoa.com" // where are the images from? // generic $('.imgWhole').each( function() { imgWholeFunc($(this)); }); $('.pageSnippet').each( function() { pageSnippetFunc($(this)); }); // for imgGlyph24 class // e.g. <div class="imgGlyph24 imgIdea"></div> to insert a lightbulb // $('.imgIdea').each( function() { $(this).attr("data-guts","{ url: '/img/3_idea24.png', title: 'A tip for you...', xtraStyle: '' }"); imgWholeFunc( $(this) ); }); $('.imgWarning').each( function() { $(this).attr("data-guts","{ url: '/img/58_warn24.png', title: 'Warning!', xtraStyle: '' }"); imgWholeFunc( $(this) ); }); $('.imgConcept').each( function() { $(this).attr("data-guts","{ url: '/img/81_BlueFlag24.png', title: 'Important Concept...', xtraStyle: '' }"); imgWholeFunc( $(this) ); }); $('.imgDisambiguate').each( function() { $(this).attr("data-guts","{ url: '/img/80_YellowFlag24.png', title: 'Disambiguate...', xtraStyle: '' }"); imgWholeFunc( $(this) ); }); $('.imgNote').each( function() { $(this).attr("data-guts","{ url: '/img/80_YellowFlag24.png', title: 'Note...', xtraStyle: '' }"); imgWholeFunc( $(this) ); }); $('.imgCellYes').each( function() { $(this).attr("data-guts","{ url: '/img/Apply.png', title: 'Yes', xtraStyle: ' background-position: center; ' }"); imgWholeFunc( $(this) ); }); $('.imgCellNo').each( function() { $(this).attr("data-guts","{ url: '/img/Erase.png', title: 'No', xtraStyle: ' background-position: center; ' }"); imgWholeFunc( $(this) ); }); $('.imgCellMaybe').each( function() { $(this).attr("data-guts","{ url: '/img/Apply_grey.png', title: 'Maybe', xtraStyle: ' background-position: center; ' }"); imgWholeFunc( $(this) ); }); $('.imgKeyTip').each( function() { $(this).attr("data-guts","{ url: '/img/Key24.png', title: 'Key Tip', xtraStyle: ' background-position: center; ' }"); imgWholeFunc( $(this) ); }); /* button to return to dz if we came from there */ $('#firstHeading').append('<div style="display: inline-block; position: relative; float: right;"><div class="backToOpener HPButton2 DZGreenBut2" style="display: inline-block;font-style: normal;">Back to dataZoa</div></div>'); $('.backToOpener').each( function() { if( !window.opener || window.opener.closed ) { $(this).hide(); } else { $(this).attr("onclick","window.opener.postMessage('pleaseAlert','*');"); } }); /* formatting for tooltips on individual data source pages */ .dataToolTip { background-color: f9f9f9; border-width:1px; border-style: solid; border-color: aaa; padding:5px; width:540px }