Ero sivun ”Widget:Form enabler X” versioiden välillä
Järvi-meriwikistä
p (Tekstin korvaus – ”src="http://www.jarviwiki.fi” muotoon ”src="//www.jarviwiki.fi”) |
|||
(68 välissä olevaa versiota 2 käyttäjän tekeminä ei näytetä) | |||
Rivi 1: | Rivi 1: | ||
− | <includeonly><script | + | <includeonly><script type="text/javascript"> |
+ | |||
+ | 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(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | setTimeout( function(){ <!--{$id|default:FormEnabler|escape:'html'}-->_jQueryTest() }, 300); | ||
+ | |||
+ | function <!--{$id|default:FormEnabler|escape:'html'}-->_funcX() { | ||
+ | |||
+ | |||
+ | jQuery('label.JwLocRadiobuttons').each(function() { | ||
+ | |||
+ | var label = jQuery( this ); | ||
+ | //console.log( label ); | ||
+ | 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(); | |
+ | |||
+ | var classes = jQuery( this ).attr('class').split(' '); | ||
+ | var val = input.val(); | ||
+ | |||
+ | for (var i in classes) { | ||
+ | |||
+ | strArr = classes[i].split('-'); | ||
− | jQuery('.JwDisabled').each(function() { | + | 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( 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('fieldset:visible .JwLocCheckboxes').each(function() { | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | var input = jQuery( this ).children('input').first(); | |
− | |||
− | |||
− | + | var classes = jQuery( this ).attr('class').split(' '); | |
− | + | var val = input.val(); | |
− | |||
− | jQuery( | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | 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 .multipleTemplateInstance').each(function() { | jQuery('fieldset:visible .multipleTemplateInstance').each(function() { | ||
var id = 'JwRandom_' + Math.random().toString().replace(".", "") + 'Id'; | var id = 'JwRandom_' + Math.random().toString().replace(".", "") + 'Id'; | ||
Rivi 211: | Rivi 213: | ||
jQuery( this ).parent().append('<span class="jwRemovePic" style="display: none;">| <a class="jwRemovePic" href="#">Poista kuva</a></span>'); | jQuery( this ).parent().append('<span class="jwRemovePic" style="display: none;">| <a class="jwRemovePic" href="#">Poista kuva</a></span>'); | ||
} | } | ||
+ | }); | ||
+ | |||
+ | jQuery(window).resize(function() { | ||
+ | setTimeout(function() { Jw_FormFieldResizer(); }, 500); | ||
}); | }); | ||
− | |||
setTimeout('Jw_FormFieldResizer()', 1000); | setTimeout('Jw_FormFieldResizer()', 1000); | ||
− | + | ||
− | + | jQuery( 'body' ).on('change.jw', 'input.jwFileNameHide', updatePic ); | |
− | jQuery( 'body' ).on('change.jw', 'input.jwFileNameHide', updatePic); | + | jQuery( 'body' ).on('click.jw', 'a.jwRemovePic', deletePic ); |
− | jQuery( 'body' ).on('click.jw', 'a.jwRemovePic', deletePic); | ||
setInterval(function() { | setInterval(function() { | ||
Jw_FormFieldResizer(); | Jw_FormFieldResizer(); | ||
}, 3000); | }, 3000); | ||
− | + | ||
− | function deletePic(a) { | + | |
+ | checkAgain(); | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | function Jw_MultipleForm_Toggler(id) { | ||
+ | if (jQuery('.' + id + '_more').is(':visible')) { | ||
+ | jQuery('#' + id + '_button').removeClass('open'); | ||
+ | jQuery('#' + id + '_button').addClass('locked'); | ||
+ | jQuery('.' + id).find('input ').not('.jwToArchive').attr('disabled', true); | ||
+ | jQuery('.' + id).find('select').attr('disabled', true); | ||
+ | jQuery('.' + id).find('button').attr('disabled', true); | ||
+ | } else { | ||
+ | jQuery('#' + id + '_button').removeClass('locked'); | ||
+ | jQuery('#' + id + '_button').addClass('open'); | ||
+ | jQuery('.' + id).find('input').attr('disabled', false); | ||
+ | jQuery('.' + id).find('select').attr('disabled', false); | ||
+ | jQuery('.' + id).find('button').attr('disabled', false); | ||
+ | //Jw_FormFieldResizer(); | ||
+ | setTimeout(function() { Jw_FormFieldResizer(); }, 100); | ||
+ | } | ||
+ | jQuery('.' + id + '_more').toggle(); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | function deletePic(a) { | ||
+ | |||
+ | jQuery( a.target ).parent().parent().parent().parent().find('div.sfImagePreviewWrapper').html(''); | ||
+ | jQuery( a.target ).parent().parent().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 { | ||
+ | newhref = newhref.substring(0, newhref.lastIndexOf('_')); | ||
+ | newhref = newhref + '_' + curdate.split('/').join('-') + newhref.substring(newhref.lastIndexOf('.')); | ||
+ | parent.find('a.sfImagePreview').attr('href', newhref); | ||
+ | } | ||
+ | } | ||
+ | */ | ||
+ | } | ||
− | + | function updatePic(a) { | |
− | jQuery( a.target ). | + | var filename = (jQuery(a.target).val()); |
− | + | if (filename == '') { | |
− | + | //jQuery(a.target).parents('.inputSpan').find('a.sfImagePreview').show(); | |
+ | jQuery(a.target).parents('.inputSpan').find('span.jwRemovePic').hide(); | ||
+ | } else { | ||
+ | //jQuery(a.target).parents('.inputSpan').find('a.sfImagePreview').hide(); | ||
+ | jQuery(a.target).parents('.inputSpan').find('span.jwRemovePic').show(); | ||
} | } | ||
+ | |||
+ | } | ||
+ | |||
+ | function Jw_FormFieldResizer() { | ||
− | + | jQuery('.jwResize').each(function() { | |
− | + | ||
− | + | jQuery(this).width(180); | |
− | + | jQuery( this ).css('resize', 'none'); | |
− | + | ||
− | var | + | var sizer = Math.round(jQuery(this).parents('.jwSizer').first().width()); |
− | if ( | + | if (sizer == 0) { |
− | + | setTimeout('Jw_FormFieldResizer', 1000); | |
− | + | } else { | |
− | if ( | + | if (sizer > (260)) { |
− | + | jQuery(this).width(sizer-100); | |
− | |||
− | |||
} else { | } else { | ||
− | + | jQuery(this).width(sizer); | |
− | |||
− | |||
} | } | ||
} | } | ||
− | + | }); | |
− | } | + | |
− | + | jQuery('.jwResizeToMax').each(function() { | |
− | function | + | |
− | var | + | jQuery( this ).width(50); |
− | if ( | + | jQuery( this ).css('resize', 'none'); |
− | + | ||
− | + | var sizer = jQuery(this).parents('.jwSizer').first().outerWidth(); | |
+ | if (sizer == 0) { | ||
+ | setTimeout('Jw_FormFieldResizer', 1000); | ||
+ | } else { | ||
+ | jQuery( this ).outerWidth(sizer); | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | jQuery('.jwResizeTo').each(function() { | ||
+ | |||
+ | jQuery( this ).width(50); | ||
+ | jQuery( this ).css('resize', 'none'); | ||
+ | |||
+ | var sizer = jQuery(this).parents('.jwSizerContainer').find('.jwSizer').first().outerWidth(); | ||
+ | if (sizer == 0) { | ||
+ | setTimeout('Jw_FormFieldResizer', 1000); | ||
} else { | } else { | ||
− | + | jQuery( this ).outerWidth(sizer); | |
− | |||
} | } | ||
− | + | }); | |
− | } | + | } |
− | |||
− | |||
− | |||
− | } | ||
function checkAgain() { | function checkAgain() { | ||
Rivi 302: | Rivi 375: | ||
lang = lang && (lang in labels) ? lang : 'en'; | lang = lang && (lang in labels) ? lang : 'en'; | ||
− | + | return labels[lang][labelId]; | |
} | } | ||