Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| Rivi 17: | Rivi 17: | ||
function <!--{$id|default:FormEnabler|escape:'html'}-->_funcX() { | function <!--{$id|default:FormEnabler|escape:'html'}-->_funcX() { | ||
var focalpoint = ( "<!--{$focalpoint|default:false|escape:'html'}-->" == "true" ); | |||
jQuery( document ).on( 'change', '.jwImageSelect_focalpointX', function() { | jQuery( document ).on( 'change', '.jwImageSelect_focalpointX', function() { | ||
| Rivi 133: | Rivi 135: | ||
jQuery.ajax({ | jQuery.ajax({ | ||
type: 'POST', | |||
url: 'https://www.jarviwiki.fi/w/api.php', | |||
data: searchImg, | |||
dataType: 'jsonp', | |||
image: value, | image: value, | ||
success: function( reqImg ) { | |||
apicounter++; | 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 && | 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 + '">'; | |||
imgout = '<div class="card selected" data-select-id="' + select.prop( 'id' ) + | if ( focalpoint ) { imgOut += '<div class="focalpoint" style="left: ' + focalX + '%; top: ' + focalY + '%;"></div>'; } | ||
imgOut += '<img class="card-img-top" style="width: 100%;" src="' + reqImg.query.pages[i].imageinfo[0].url + '"></div>'; | |||
} else { | } else { | ||
imgout = '<div class="card" data-select-id="' + select.prop( 'id' ) + '" data-value="' + this.image + '">'; | |||
if ( focalpoint ) { imgOut += '<div class="focalpoint" style="left: ' + focalX + '%; top: ' + focalY + '%;"></div>'; } | |||
imgOut += '<img class="card-img-top" style="width: 100%;" src="' + reqImg.query.pages[i].imageinfo[0].url + '"></div>'; | |||
} | } | ||
imageA.push( this.image ); | imageA.push( this.image ); | ||
imageO[ this.image ] = imgout; | imageO[ this.image ] = imgout; | ||
} | } | ||
} | |||
break; | |||
} | |||
} | } | ||
if ( apicounter >= values.length) { imagesReady(); } | if ( apicounter >= values.length) { imagesReady(); } | ||
}, | |||
error: function(err) { | |||
apicounter++; | apicounter++; | ||
console.log(err); | |||
if ( apicounter >= values.length) { imagesReady(); } | if ( apicounter >= values.length) { | ||
imagesReady(); | |||
} | |||
} | |||
}); | |||
} | } | ||


