p (Tekstin korvaus – ”http://” muotoon ”//”) |
Ei muokkausyhteenvetoa |
||
| (143 välissä olevaa versiota samalta käyttäjältä ei näytetä) | |||
| Rivi 1: | Rivi 1: | ||
<includeonly><script | <includeonly><script type="text/javascript"> | ||
console.log( 1 ); | |||
if ( !window.formenabler ) { | |||
window.formenabler = true; | |||
function <!--{$id|default:FormEnabler|escape:'html'}-->_jQueryTest() { | |||
if ( typeof window.jQuery == 'undefined' ) { | |||
setTimeout( function(){ <!--{$id|default:FormEnabler|escape:'html'}-->_jQueryTest() }, 300); | |||
} else { | |||
<!--{$id|default:FormEnabler|escape:'html'}-->_funcX(); | |||
<!--{$id|default:FormEnabler|escape:'html'}-->_func(); | |||
} | |||
} | |||
setTimeout( function(){ <!--{$id|default:FormEnabler|escape:'html'}-->_jQueryTest() }, 300); | |||
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() { | |||
jQuery( this ). | var me = jQuery( this ); | ||
jQuery( | 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() { | |||
var me = jQuery( this ); | |||
if ( me.hasClass( 'selected' ) ) { | |||
me.removeClass( 'selected' ); | |||
me.closest( '.inputSpan' ).find( 'select' ).val( '' ); | |||
} else { | |||
me.closest( '.jwImageSelect_images' ).find( '.card' ).removeClass( 'selected' ); | |||
me.addClass( 'selected' ); | |||
me.closest( '.inputSpan' ).find( 'select' ).val( me.attr('data-value' ) ); | |||
} | |||
}); | |||
var | 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() { | |||
var select = jQuery( this ); | |||
select.hide(); | |||
var current = select.val(); | |||
var classes = jQuery( this ).attr('class').split(' '); | |||
var images = jQuery( '<div class="card-columns jwImageSelect_images"></div>' ); | |||
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 = []; | |||
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() { | |||
var val = jQuery( this ).val(); | |||
if ( val != '' ) { | |||
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 { | |||
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 ) { | |||
var value = values[ vi ]; | |||
searchImg = "action=query&prop=imageinfo&iiprop=url|size&format=json&titles=" + encodeURIComponent( value ); | |||
jQuery.ajax({ | |||
type: 'POST', | |||
url: 'https://www.jarviwiki.fi/w/api.php', | |||
data: searchImg, | |||
dataType: 'jsonp', | |||
image: value, | |||
success: function( reqImg ) { | |||
apicounter++; | |||
if ( typeof reqImg.query != 'undefined' ) { | |||
for ( var i in reqImg.query.pages ) { | |||
if ( typeof reqImg.query.pages[i].imageinfo != 'undefined' ) { | |||
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 + '"><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>'; | |||
} else { | |||
imgout = '<div class="card" data-select-id="' + select.prop( 'id' ) + | |||
'" 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>'; | |||
} | |||
imageA.push( this.image ); | |||
imageO[ this.image ] = imgout; | |||
} | |||
} | |||
break; | |||
} | |||
} | |||
if ( apicounter >= values.length) { imagesReady(); } | |||
}, | |||
error: function(err) { | |||
apicounter++; | |||
console.log(err); | |||
if ( apicounter >= values.length) { imagesReady(); } | |||
} | |||
}); | |||
} | |||
}); | |||
jQuery('label.JwLocRadiobuttons').each(function() { | |||
var label = jQuery( this ); | |||
}); | var input = jQuery( this ).children( 'input' ).first(); | ||
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; | |||
} | |||
} | |||
}); | |||
jQuery('fieldset:visible .JwLocCheckboxes').each(function() { | |||
var input = jQuery( this ).children('input').first(); | |||
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; | |||
} | |||
} | |||
} | |||
}); | |||
jQuery('fieldset:visible .JwLocDropdowns > option').each(function() { | |||
var classes = jQuery( this ).parent().attr('class').split(' '); | |||
var val = jQuery( this ).val(); | |||
for (var i in classes) { | |||
strArr = classes[i].split('-'); | |||
if (strArr[1] == val) { | |||
str = strArr[2].split('_').join(' ').split('~').join('-'); | |||
jQuery( this ).html(str); | |||
break; | |||
} | |||
} | |||
}); | |||
} | |||
function <!--{$id|default:FormEnabler|escape:'html'}-->_func() { | |||
var lang = '<!--{$lang|default:fi|escape:'urlpathinfo'}-->'; | |||
jQuery('.JwDisabled').each(function() { | |||
jQuery( this ).attr('disabled', true); | |||
jQuery( this ).attr('disabled', true); | |||
jQuery( this ).attr('disabled', true); | |||
}); | |||
jQuery( 'body' ).on( "mouseenter", ".JwMultipleTemplateInfo", null, function( event ) { | |||
var target = jQuery( this ); | |||
target.removeClass('JwMultipleTemplateInfo'); | |||
target.qtip({ | |||
content: { | |||
title: { | |||
text: target.find( '.smwtttitle' ), | |||
button: FormEnablerLabels(0, lang) | |||
}, | |||
text: target.find( '.smwttcontent' ), //target.attr('data-content'), | |||
button: 'X' | |||
}, | |||
position: { | |||
my: 'left center', | |||
at: 'center', | |||
target: target, | |||
adjust: { x: 5, y: -2 } | |||
}, | |||
show: { | |||
solo: true | |||
}, | |||
hide: { | |||
event: false | |||
}, | |||
style: { | |||
classes: "jwqtip qtip qtip-default qtip-shadow qtip-bootstrap qtip-pos-bc qtip-focus" | |||
} | |||
}); | |||
target.mouseenter(); | |||
}); | |||
jQuery(window).resize(function() { | |||
setTimeout(function() { Jw_FormFieldResizer(); }, 500); | |||
}); | |||
setTimeout('Jw_FormFieldResizer()', 1000); | |||
setInterval(function() { | |||
Jw_FormFieldResizer(); | |||
}, 3000); | |||
checkAgain(); | |||
} | |||
function Jw_FormFieldResizer() { | |||
if ( jQuery( '.simpleupload_prv' ).length > 0 ) { | |||
if (jQuery('. | jQuery( '.choose-img-container' ).hide(); | ||
jQuery(' | jQuery( '.simpleupload_prv' ).each( function() { | ||
jQuery(' | 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( '.choose-img-container' ).show(); | |||
jQuery('. | |||
jQuery('.' | |||
} | } | ||
jQuery('.jwResize').each(function() { | jQuery('.jwResize').each(function() { | ||
jQuery(this).width(180); | jQuery(this).width(180); | ||
jQuery( this ).css('resize', 'none'); | jQuery( this ).css('resize', 'none'); | ||
var sizer = Math.round(jQuery(this).parents('.jwSizer').first().width()); | var sizer = Math.round(jQuery(this).parents('.jwSizer').first().width()); | ||
if (sizer == 0) { | if (sizer == 0) { | ||
| Rivi 123: | Rivi 337: | ||
} | } | ||
}); | }); | ||
jQuery('.jwResizeToMax').each(function() { | jQuery('.jwResizeToMax').each(function() { | ||
jQuery( this ).width(50); | jQuery( this ).width(50); | ||
jQuery( this ).css('resize', 'none'); | jQuery( this ).css('resize', 'none'); | ||
var sizer = jQuery(this).parents('.jwSizer').first().outerWidth(); | var sizer = jQuery(this).parents('.jwSizer').first().outerWidth(); | ||
if (sizer == 0) { | if (sizer == 0) { | ||
| Rivi 136: | Rivi 350: | ||
} | } | ||
}); | }); | ||
jQuery('.jwResizeTo').each(function() { | jQuery('.jwResizeTo').each(function() { | ||
jQuery( this ).width(50); | jQuery( this ).width(50); | ||
jQuery( this ).css('resize', 'none'); | jQuery( this ).css('resize', 'none'); | ||
var sizer = jQuery(this).parents('.jwSizerContainer').find('.jwSizer').first().outerWidth(); | var sizer = jQuery(this).parents('.jwSizerContainer').find('.jwSizer').first().outerWidth(); | ||
if (sizer == 0) { | if (sizer == 0) { | ||
| Rivi 150: | Rivi 364: | ||
}); | }); | ||
} | } | ||
function checkAgain() { | function checkAgain() { | ||
| Rivi 286: | Rivi 397: | ||
lang = lang && (lang in labels) ? lang : 'en'; | lang = lang && (lang in labels) ? lang : 'en'; | ||
return labels[lang][labelId]; | |||
} | } | ||
} | |||
</script></includeonly> | </script></includeonly> | ||


