Ero sivun ”Widget:Form enabler” versioiden välillä
Järvi-meriwikistä
Rivi 1: | Rivi 1: | ||
<includeonly><script src="/scripts/jquery.autosize-min.js" ></script><script type="text/javascript"> | <includeonly><script src="/scripts/jquery.autosize-min.js" ></script><script type="text/javascript"> | ||
− | var lang = '<!--{$lang|default:fi|escape:'urlpathinfo'}-->'; | + | 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'}-->_func(); | ||
+ | } | ||
+ | } | ||
+ | setTimeout( function(){ <!--{$id|default:FormEnabler|escape:'html'}-->_jQueryTest() }, 300); | ||
+ | |||
+ | 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( this ).attr('disabled', true); | ||
jQuery( this ).attr('disabled', true); | jQuery( this ).attr('disabled', true); | ||
− | + | }); | |
+ | |||
+ | jQuery('.JwLocCheckboxes').each(function() { | ||
+ | |||
+ | 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( '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(); | |
+ | }); | ||
− | if ( | + | jQuery('.XmultipleTemplateInstance').each(function() { |
− | + | var id = 'JwRandom_' + Math.random().toString().replace(".", "") + 'Id'; | |
− | + | jQuery( this ).addClass(id); | |
− | jQuery( this ). | + | jQuery( this ).find('.Jw_form_more').addClass(id + '_more'); |
− | + | jQuery( this ).find('tr').first().prepend('<td><a href="javascript: Jw_MultipleForm_Toggler(\'' + id + '\');"><div id="' + id + '_button" class="JW_formlock_button locked"></div></a></td>'); | |
+ | Jw_MultipleForm_Toggler(id); | ||
+ | var curdate = jQuery( this ).find('input.JwDateField').val(); | ||
+ | if (curdate == undefined) { curdate = ''; } | ||
+ | var curfile = jQuery( this ).find('input.jwFileNameHide').val(); | ||
+ | if (curfile == undefined) { curfile = ''; } | ||
+ | var newhref = jQuery( this ).find('a.sfImagePreview').attr('href'); | ||
+ | if (curfile != "") { | ||
+ | newhref = newhref.substring(0, newhref.indexOf('&wpDestFile=')); | ||
+ | newhref += '&wpDestFile=' + curfile; | ||
+ | jQuery( this ).find('a.sfImagePreview').attr('href', newhref); | ||
+ | } else { | ||
+ | newhref = newhref + curdate.split('/').join('-'); | ||
+ | jQuery( this ).find('a.sfImagePreview').attr('href', newhref); | ||
} | } | ||
− | + | }); | |
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | jQuery('.multipleTemplateStarter .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(' '); | ||
+ | jQuery( this ).html(str); | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | }); | ||
+ | |||
+ | jQuery('.JwLocDropdowns:visible > 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(' '); | |
− | + | jQuery( this ).html(str); | |
− | + | break; | |
− | + | } | |
− | + | } | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | }); | |
− | + | ||
− | + | jQuery(window).resize(function() { setTimeout(function() { Jw_FormFieldResizer(); }, 500); }); | |
− | jQuery( | + | |
− | + | setTimeout('Jw_FormFieldResizer()', 1000); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | jQuery( 'body' ).on('change.jw', 'input.JwDateField', updateLink); | ||
+ | |||
+ | jQuery( 'body' ).on('change.jw', 'input.jwFileNameHide', updatePic); | ||
+ | |||
+ | setInterval(function() { Jw_FormFieldResizer(); }, 3000); | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
function Jw_MultipleForm_Toggler(id) { | function Jw_MultipleForm_Toggler(id) { | ||
if (jQuery('.' + id + '_more').is(':visible')) { | if (jQuery('.' + id + '_more').is(':visible')) { | ||
Rivi 151: | Rivi 212: | ||
} | } | ||
− | |||
− | |||
− | |||
− | + | ||
+ | function deletePic(a) { | ||
− | + | //var retVal = confirm("Haluatko varmasti poistaa lataamasi kuvan tästä havainnosta?"); | |
− | + | //if ( retVal == true ) { | |
− | var | + | jQuery( a.target ).parent('.inputSpan').find('div.sfImagePreviewWrapper').html(''); |
− | var | + | jQuery( a.target ).parent('.inputSpan').find('input.jwFileNameHide').val(''); |
− | + | updatePic(a); | |
− | + | updateLink(a); | |
− | + | //} | |
− | + | } | |
− | + | function updateLink(a) { | |
− | + | var parent = jQuery(a.target).parents('div.multipleTemplateInstance').first(); | |
− | + | var curdate = parent.find('input.JwDateField').val(); | |
− | + | if (curdate == undefined) { curdate = ''; } | |
− | + | var curfile = parent.find('input.jwFileNameHide').val(); | |
− | + | if (curfile == undefined) { curfile = ''; } | |
+ | var newhref = parent.find('a.sfImagePreview').attr('href'); | ||
+ | if (newhref != undefined) { | ||
+ | if (curfile != "") { | ||
+ | newhref = newhref.substring(0, newhref.indexOf('&wpDestFile=')); | ||
+ | newhref += '&wpDestFile=' + curfile; | ||
+ | parent.find('a.sfImagePreview').attr('href', newhref); | ||
+ | } else { | ||
+ | ////www.jarviwiki.fi/w/index.php?title=Toiminnot:UploadWindow&sfInputID=input_8&wpDestFile=Tiedosto:001.JPG | ||
+ | ////www.jarviwiki.fi/w/index.php?title=Toiminnot:UploadWindow&sfInputID=input_03.04.2006 | ||
+ | //console.log(jQuery( document ).attr('title')); | ||
+ | newhref = newhref.substring(0, newhref.lastIndexOf('_')); | ||
+ | newhref = newhref + '_' + curdate.split('/').join('-'); | ||
+ | parent.find('a.sfImagePreview').attr('href', newhref); | ||
+ | } | ||
} | } | ||
− | + | } | |
− | + | ||
+ | function updatePic(a) { | ||
− | + | var filename = (jQuery(a.target).val()); | |
− | + | if (filename == '') { | |
− | + | jQuery(a.target).parent('.inputSpan').find('a.sfImagePreview').show(); | |
− | + | jQuery(a.target).parent('.inputSpan').find('a.jwRemovePic').hide(); | |
− | + | } else { | |
− | + | jQuery(a.target).parent('.inputSpan').find('a.sfImagePreview').hide(); | |
− | + | jQuery(a.target).parent('.inputSpan').find('a.jwRemovePic').show(); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | |||
− | |||
− | + | } | |
− | + | checkAgain(); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function checkAgain() { | function checkAgain() { | ||
Rivi 289: | Rivi 298: | ||
} | } | ||
− | |||
</script></includeonly> | </script></includeonly> |