Ero sivun ”Widget:Fullscreen” versioiden välillä
Järvi-meriwikistä
Rivi 1: | Rivi 1: | ||
<includeonly> | <includeonly> | ||
− | |||
<script type="text/javascript"> | <script type="text/javascript"> | ||
− | + | ||
(function() { | (function() { | ||
− | + | var id = 'fs_' + Math.random().toString(16).slice(2); | |
− | + | document.write( '<div id="' + id + '_container" style="float: right;"></div>' ); | |
+ | |||
+ | jQueryTest = function() { | ||
if ( typeof window.jQuery == 'undefined' ) { | if ( typeof window.jQuery == 'undefined' ) { | ||
− | setTimeout( function(){ | + | setTimeout( function() { jQueryTest() }, 300); |
} else { | } else { | ||
− | if ( jQuery( "# | + | if ( jQuery( "#" + id + "_container" ).length > 0 ) { |
− | + | func(); | |
} else { | } else { | ||
− | setTimeout( function(){ | + | setTimeout( function() { jQueryTest() }, 300); |
} | } | ||
} | } | ||
} | } | ||
− | setTimeout( function(){ | + | setTimeout( function() { jQueryTest() }, 300); |
− | function | + | function func() { |
− | var output = '<div class="fullscreen-button" style="margin-left: 10px; float: right; border-radius: 50%;"><button id=" | + | var output = '<div class="fullscreen-button" style="margin-left: 10px; float: right; border-radius: 50%;"><button id="' + id + '_button" title="fullscreen" style="width: 24px; height: 24px; padding: 0; margin: 0; color: #1B599B; background: none; border: none;"><i class="fas fa-expand"></i></button></div>'; |
− | jQuery( "# | + | jQuery( "#" + id + "_container" ).html( output ); |
− | jQuery( "# | + | jQuery( "#" + id + "_button" ).on( 'click', function() { |
var cardEl = jQuery( this ).parents( '.JwCard' ); | var cardEl = jQuery( this ).parents( '.JwCard' ); |