Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| (86 välissä olevaa versiota samalta käyttäjältä ei näytetä) | |||
| Rivi 1: | Rivi 1: | ||
<includeonly><script type="text/javascript"> | <includeonly><script type="text/javascript"> | ||
console.log( 1 ); | |||
if ( !window.formenabler ) { | if ( !window.formenabler ) { | ||
| Rivi 7: | Rivi 9: | ||
function <!--{$id|default:FormEnabler|escape:'html'}-->_jQueryTest() { | function <!--{$id|default:FormEnabler|escape:'html'}-->_jQueryTest() { | ||
if ( typeof window.jQuery == 'undefined' ) { | if ( typeof window.jQuery == 'undefined' ) { | ||
setTimeout( function(){ <!--{$id|default:FormEnabler|escape:'html'}-->_jQueryTest() }, 300); | |||
} else { | } else { | ||
<!--{$id|default:FormEnabler|escape:'html'}-->_funcX(); | |||
<!--{$id|default:FormEnabler|escape:'html'}-->_func(); | |||
} | |||
} | } | ||
| Rivi 16: | Rivi 19: | ||
function <!--{$id|default:FormEnabler|escape:'html'}-->_funcX() { | function <!--{$id|default:FormEnabler|escape:'html'}-->_funcX() { | ||
jQuery( document ).on( 'change', '.jwImageSelect_focalpointX', function() { | |||
var me = jQuery( this ); | |||
if ( !me.val() ) { me.val( '50' ); } | |||
var val = me.val(); | |||
if ( val >= 0 && val <= 100 ) { | |||
jQuery( '.focalpoint' ).css( 'left', me.val() + '%' ); | |||
jQuery( '.focalpoint' ).show(); | |||
} else { | |||
jQuery( '.focalpoint' ).hide(); | |||
} | |||
}); | |||
jQuery( document ).on( 'change', '.jwImageSelect_focalpointY', function() { | |||
var me = jQuery( this ); | |||
if ( !me.val() ) { me.val( '50' ); } | |||
var val = me.val(); | |||
if ( val >= 0 && val <= 100 ) { | |||
jQuery( '.focalpoint' ).css( 'top', me.val() + '%' ); | |||
jQuery( '.focalpoint' ).show(); | |||
} else { | |||
jQuery( '.focalpoint' ).hide(); | |||
} | |||
}); | |||
jQuery( document ).on( 'click', '.jwImageSelect_images .card', function() { | jQuery( document ).on( 'click', '.jwImageSelect_images .card', function() { | ||
| Rivi 28: | Rivi 56: | ||
} | } | ||
}); | }); | ||
jQuery( document ).on( 'click', '.jwImageSelectShowMore', function() { | |||
var me = jQuery( this ); | |||
var images = me.closest( '.inputSpan' ).find( '.jwImageSelect_images' ); | |||
addImages( images, iAdded, 4 ); | |||
}); | |||
var imageA = []; | |||
var imageO = {}; | |||
var iAdded = 0; | |||
function addImages( images, start, limit ) { | |||
var i=start; | |||
do { | |||
images.append( imageO[ imageA[ i ] ] ); | |||
iAdded++; | |||
i++; | |||
} while ( i < ( start + limit ) && i < imageA.length ); | |||
var button = images.closest( '.inputSpan' ).find( '.jwImageSelectShowMore' ); | |||
if ( imageA.length <= iAdded ) { | |||
button.attr( 'disabled', 'disabled' ); | |||
} | |||
} | |||
jQuery('.jwImageSelect').each(function() { | jQuery('.jwImageSelect').each(function() { | ||
| Rivi 36: | Rivi 89: | ||
var classes = jQuery( this ).attr('class').split(' '); | var classes = jQuery( this ).attr('class').split(' '); | ||
var images = jQuery( '<div class="card-columns jwImageSelect_images"></div>' ); | var images = jQuery( '<div class="card-columns jwImageSelect_images"></div>' ); | ||
select.after( images ); | var more = jQuery( '<div class="row"><div class="col d-flex justify-content-center"><button type="button" class="btn btn-link jwImageSelectShowMore">+ Näytä lisää kuvia</button></div></div>' ); | ||
var info = jQuery( '<p class="JwImageSelect_info">Valitse kuva hiirellä klikkaamalla. Saat näkyviin valitsemaasi vesialueeseen tai paikkaan liitettyjä kuvia, jotka on tallennettu Järvi-meriwikiin vähintään 1500 pikseliä leveinä ja 500 pikseliä korkeina.</p>' ); | |||
select.after( info ); | |||
info.after( images ); | |||
images.after( more ); | |||
var values = []; | var values = []; | ||
if ( !jQuery( '.jwImageSelect_focalpointX' ).first().val() ) { jQuery( '.jwImageSelect_focalpointX' ).first().val( '50' ); } | |||
if ( !jQuery( '.jwImageSelect_focalpointY' ).first().val() ) { jQuery( '.jwImageSelect_focalpointY' ).first().val( '50' ); } | |||
var focalX = jQuery( '.jwImageSelect_focalpointX' ).first().val(); | |||
var focalY = jQuery( '.jwImageSelect_focalpointY' ).first().val(); | |||
select.find( 'option' ).each( function() { | select.find( 'option' ).each( function() { | ||
var val = jQuery( this ).val(); | var val = jQuery( this ).val(); | ||
if ( val == current ) { | if ( val != '' ) { | ||
values.unshift( | if ( val == current ) { | ||
values.unshift( val ); | |||
} else { | |||
values.push( val ); | |||
} | |||
} | |||
}); | |||
function imagesReady() { | |||
const index = imageA.findIndex( item => item === current ); | |||
if (index > -1) { | |||
const [currentItem] = imageA.splice( index, 1); | |||
imageA.unshift( currentItem ); | |||
} | |||
if ( imageA.length > 0 ) { | |||
addImages( images, 0, 4 ); | |||
} else { | } else { | ||
jQuery( '.JwImageSelect_info' ).html( 'Valitsemallasi vesialueella tai paikalla on valokuvia, mutta yksikään niistä ei ole tarpeeksi iso kansikuvaksi. Vähimmäisvaatimus on 1500 pikseliä leveysuunnassa ja 500 pikseliä pystysuunnassa.' ); | |||
more.hide(); | |||
} | } | ||
} | } | ||
var apicounter = 0; | |||
for ( var vi in values ) { | for ( var vi in values ) { | ||
| Rivi 60: | Rivi 141: | ||
image: value, | image: value, | ||
success: function( reqImg ) { | success: function( reqImg ) { | ||
apicounter++; | |||
if ( typeof reqImg.query != 'undefined' ) { | if ( typeof reqImg.query != 'undefined' ) { | ||
for ( var i in reqImg.query.pages ) { | for ( var i in reqImg.query.pages ) { | ||
if ( typeof reqImg.query.pages[i].imageinfo != 'undefined' | if ( typeof reqImg.query.pages[i].imageinfo != 'undefined' ) { | ||
reqImg.query.pages[i].imageinfo[0].width >= | if ( reqImg.query.pages[i].imageinfo[0].width >= 1500 && | ||
reqImg.query.pages[i].imageinfo[0].height >= 500 ) { | |||
if ( this.image == current ) { | |||
imgout = '<div class="card selected" data-select-id="' + select.prop( 'id' ) + | |||
'" data-value="' + this.image + '"><img class="card-img-top" style="width: 100%;" src="' + | '" data-value="' + this.image + '"><div class="focalpoint" style="left: ' + focalX + '%; top: ' + focalY + '%;"></div><img class="card-img-top" style="width: 100%;" src="' + | ||
reqImg.query.pages[i].imageinfo[0].url + '"></div>' | reqImg.query.pages[i].imageinfo[0].url + '"></div>'; | ||
} else { | |||
imgout = '<div class="card" data-select-id="' + select.prop( 'id' ) + | |||
'" data-value="' + this.image + '"><img class="card-img-top" style="width: 100%;" src="' + | '" data-value="' + this.image + '"><div class="focalpoint" style="left: ' + focalX + '%; top: ' + focalY + '%;"></div><img class="card-img-top" style="width: 100%;" src="' + | ||
reqImg.query.pages[i].imageinfo[0].url + '"></div>'); | reqImg.query.pages[i].imageinfo[0].url + '"></div>'; | ||
} | |||
imageA.push( this.image ); | |||
imageO[ this.image ] = imgout; | |||
} | } | ||
} | } | ||
| Rivi 78: | Rivi 163: | ||
} | } | ||
} | } | ||
if ( apicounter >= values.length) { imagesReady(); } | |||
}, | }, | ||
error: function(err) { | error: function(err) { | ||
apicounter++; | |||
console.log(err); | console.log(err); | ||
if ( apicounter >= values.length) { imagesReady(); } | |||
} | } | ||
}) | }); | ||
} | } | ||
}); | }); | ||
| Rivi 118: | Rivi 203: | ||
var input = jQuery( this ).children('input').first(); | var input = jQuery( this ).children('input').first(); | ||
if ( input.length > 0 ) { | if ( input.length > 0 ) { | ||
var classes = jQuery( this ).attr('class').split(' '); | |||
var val = input.val(); | |||
for (var i in classes) { | |||
strArr = classes[i].split('-'); | |||
if (strArr[1] == val) { | |||
old = input.parent().html(); | |||
newLabel = old.substr(0, old.lastIndexOf(";")) + strArr[2].split('_').join(' '); | |||
jQuery( this ).html(newLabel); | |||
break; | |||
} | |||
} | } | ||
} | } | ||
}); | }); | ||
| Rivi 200: | Rivi 285: | ||
target.mouseenter(); | target.mouseenter(); | ||
}); | }); | ||
jQuery(window).resize(function() { | jQuery(window).resize(function() { | ||
setTimeout(function() { Jw_FormFieldResizer(); }, 500); | setTimeout(function() { Jw_FormFieldResizer(); }, 500); | ||
}); | }); | ||
setTimeout('Jw_FormFieldResizer()', 1000); | setTimeout('Jw_FormFieldResizer()', 1000); | ||
setInterval(function() { | setInterval(function() { | ||
Jw_FormFieldResizer(); | Jw_FormFieldResizer(); | ||
}, 3000); | }, 3000); | ||
checkAgain(); | checkAgain(); | ||
} | } | ||
function Jw_FormFieldResizer() { | |||
function | |||
if ( jQuery( '.simpleupload_prv' ).length > 0 ) { | |||
jQuery( '.choose-img-container' ).hide(); | |||
jQuery( '.simpleupload_prv' ).each( function() { | |||
var el = jQuery( this ); | |||
if ( el.prev().hasClass( 'focalpoint' ) ) { | |||
// do nothing | |||
} else { | |||
if ( el.next().hasClass( 'showCenterPos' ) ) { | |||
el.wrap('<div class="img-upload-wrapper" style="position: relative; display: inline-block; border: 5px solid var(--syke-red);"></div>'); | |||
el.before( '<div class="focalpoint" style="left: 50%; top: 50%;"></div>' ); | |||
} | |||
jQuery( this ).prop( 'src', jQuery( this ).prop( 'src' ).replace( 'width=100', 'width=244' ) ); | |||
} | |||
}); | |||
} else { | } else { | ||
jQuery( '.img-upload-wrapper' ).remove(); | |||
jQuery | jQuery( '.choose-img-container' ).show(); | ||
} | } | ||
jQuery('.jwResize').each(function() { | jQuery('.jwResize').each(function() { | ||
| Rivi 464: | Rivi 401: | ||
} | } | ||
</script></includeonly> | </script></includeonly> | ||


