|
1 | | -/* global redux, redux_change */ |
| 1 | +/* global redux, redux_change, jQuery */ |
2 | 2 |
|
3 | 3 | (function( $ ) { |
4 | 4 | 'use strict'; |
5 | 5 |
|
6 | | - redux.field_objects = redux.field_objects || {}; |
| 6 | + redux.field_objects = redux.field_objects || {}; |
7 | 7 | redux.field_objects.image_select = redux.field_objects.image_select || {}; |
8 | 8 |
|
9 | 9 | redux.field_objects.image_select.init = function( selector ) { |
10 | 10 | selector = $.redux.getSelector( selector, 'image_select' ); |
11 | 11 |
|
12 | 12 | $( selector ).each( |
13 | 13 | function() { |
14 | | - var el = $( this ); |
| 14 | + var el = $( this ); |
15 | 15 | var parent = el; |
16 | 16 |
|
17 | 17 | if ( ! el.hasClass( 'redux-field-container' ) ) { |
|
29 | 29 | } |
30 | 30 |
|
31 | 31 | // On label click, change the input and class. |
32 | | - el.find( '.redux-image-select label img, .redux-image-select label .tiles' ).click( |
| 32 | + el.find( '.redux-image-select label img, .redux-image-select label .tiles' ).on( |
| 33 | + 'click', |
33 | 34 | function( e ) { |
34 | 35 | var presets; |
35 | 36 | var data; |
|
38 | 39 |
|
39 | 40 | var id = $( this ).closest( 'label' ).attr( 'for' ); |
40 | 41 |
|
41 | | - $( this ).parents( 'fieldset:first' ).find( '.redux-image-select-selected' ).removeClass( |
42 | | - 'redux-image-select-selected' ).find( 'input[type="radio"]' ).prop( 'checked', false ); |
| 42 | + $( this ).parents( 'fieldset:first' ).find( '.redux-image-select-selected' ) |
| 43 | + .removeClass( 'redux-image-select-selected' ).find( 'input[type="radio"]' ).prop( 'checked', false ); |
43 | 44 |
|
44 | 45 | $( this ).closest( 'label' ).find( 'input[type="radio"]' ).prop( 'checked' ); |
45 | 46 |
|
46 | 47 | if ( $( this ).closest( 'label' ).hasClass( 'redux-image-select-preset-' + id ) ) { // If they clicked on a preset, import! |
47 | 48 | e.preventDefault(); |
48 | 49 |
|
49 | 50 | presets = $( this ).closest( 'label' ).find( 'input' ); |
50 | | - data = presets.data( 'presets' ); |
51 | | - merge = presets.data( 'merge' ); |
| 51 | + data = presets.data( 'presets' ); |
| 52 | + merge = presets.data( 'merge' ); |
52 | 53 |
|
53 | 54 | if ( undefined !== merge && null !== merge ) { |
54 | 55 | if ( 'string' === $.type( merge ) ) { |
|
68 | 69 | } |
69 | 70 |
|
70 | 71 | if ( undefined !== presets && null !== presets ) { |
71 | | - el.find( 'label[for="' + id + '"]' ).addClass( 'redux-image-select-selected' ).find( |
72 | | - 'input[type="radio"]' ).attr( 'checked', true ); |
| 72 | + el.find( 'label[for="' + id + '"]' ).addClass( 'redux-image-select-selected' ) |
| 73 | + .find( 'input[type="radio"]' ).attr( 'checked', true ); |
| 74 | + |
73 | 75 | window.onbeforeunload = null; |
74 | 76 |
|
75 | | - importCodeValue = $( |
76 | | - 'textarea[name="' + redux.optName.args.opt_name + '[import_code]"' ); |
| 77 | + importCodeValue = $( 'textarea[name="' + redux.optName.args.opt_name + '[import_code]"' ); |
77 | 78 |
|
78 | 79 | if ( 0 === importCodeValue.length ) { |
79 | | - $( this ).append( |
80 | | - '<textarea id="import-code-value" style="display:none;" name="' + redux.optName.args.opt_name + '[import_code]">' + JSON.stringify( |
81 | | - data ) + '</textarea>' ); |
| 80 | + $( this ).append( '<textarea id="import-code-value" style="display:none;" name="' + redux.optName.args.opt_name + '[import_code]">' + JSON.stringify( data ) + '</textarea>' ); |
82 | 81 | } else { |
83 | 82 | importCodeValue.val( JSON.stringify( data ) ); |
84 | 83 | } |
|
92 | 91 |
|
93 | 92 | return false; |
94 | 93 | } else { |
95 | | - el.find( 'label[for="' + id + '"]' ).addClass( 'redux-image-select-selected' ).find( |
96 | | - 'input[type="radio"]' ).prop( 'checked', true ).trigger( 'change' ); |
| 94 | + el.find( 'label[for="' + id + '"]' ).addClass( 'redux-image-select-selected' ).find( 'input[type="radio"]' ).prop( 'checked', true ).trigger( 'change' ); |
97 | 95 |
|
98 | 96 | redux_change( $( this ).closest( 'label' ).find( 'input[type="radio"]' ) ); |
99 | 97 | } |
|
0 commit comments