| @@ 2200-2277 (lines=78) @@ | ||
| 2197 | wp.customize.controlConstructor['kirki-radio-buttonset'] = wp.customize.kirkiDynamicControl.extend({}); |
|
| 2198 | wp.customize.controlConstructor['kirki-radio-image'] = wp.customize.kirkiDynamicControl.extend({}); |
|
| 2199 | /* global kirkiControlLoader */ |
|
| 2200 | var RepeaterRow = function( rowIndex, container, label, control ) { |
|
| 2201 | ||
| 2202 | 'use strict'; |
|
| 2203 | ||
| 2204 | var self = this; |
|
| 2205 | this.rowIndex = rowIndex; |
|
| 2206 | this.container = container; |
|
| 2207 | this.label = label; |
|
| 2208 | this.header = this.container.find( '.repeater-row-header' ), |
|
| 2209 | ||
| 2210 | this.header.on( 'click', function() { |
|
| 2211 | self.toggleMinimize(); |
|
| 2212 | }); |
|
| 2213 | ||
| 2214 | this.container.on( 'click', '.repeater-row-remove', function() { |
|
| 2215 | self.remove(); |
|
| 2216 | }); |
|
| 2217 | ||
| 2218 | this.header.on( 'mousedown', function() { |
|
| 2219 | self.container.trigger( 'row:start-dragging' ); |
|
| 2220 | }); |
|
| 2221 | ||
| 2222 | this.container.on( 'keyup change', 'input, select, textarea', function( e ) { |
|
| 2223 | self.container.trigger( 'row:update', [ self.rowIndex, jQuery( e.target ).data( 'field' ), e.target ] ); |
|
| 2224 | }); |
|
| 2225 | ||
| 2226 | this.setRowIndex = function( rowIndex ) { |
|
| 2227 | this.rowIndex = rowIndex; |
|
| 2228 | this.container.attr( 'data-row', rowIndex ); |
|
| 2229 | this.container.data( 'row', rowIndex ); |
|
| 2230 | this.updateLabel(); |
|
| 2231 | }; |
|
| 2232 | ||
| 2233 | this.toggleMinimize = function() { |
|
| 2234 | ||
| 2235 | // Store the previous state. |
|
| 2236 | this.container.toggleClass( 'minimized' ); |
|
| 2237 | this.header.find( '.dashicons' ).toggleClass( 'dashicons-arrow-up' ).toggleClass( 'dashicons-arrow-down' ); |
|
| 2238 | }; |
|
| 2239 | ||
| 2240 | this.remove = function() { |
|
| 2241 | this.container.slideUp( 300, function() { |
|
| 2242 | jQuery( this ).detach(); |
|
| 2243 | }); |
|
| 2244 | this.container.trigger( 'row:remove', [ this.rowIndex ] ); |
|
| 2245 | }; |
|
| 2246 | ||
| 2247 | this.updateLabel = function() { |
|
| 2248 | var rowLabelField, |
|
| 2249 | rowLabel, |
|
| 2250 | rowLabelSelector; |
|
| 2251 | ||
| 2252 | if ( 'field' === this.label.type ) { |
|
| 2253 | rowLabelField = this.container.find( '.repeater-field [data-field="' + this.label.field + '"]' ); |
|
| 2254 | if ( _.isFunction( rowLabelField.val ) ) { |
|
| 2255 | rowLabel = rowLabelField.val(); |
|
| 2256 | if ( '' !== rowLabel ) { |
|
| 2257 | if ( ! _.isUndefined( control.params.fields[ this.label.field ] ) ) { |
|
| 2258 | if ( ! _.isUndefined( control.params.fields[ this.label.field ].type ) ) { |
|
| 2259 | if ( 'select' === control.params.fields[ this.label.field ].type ) { |
|
| 2260 | if ( ! _.isUndefined( control.params.fields[ this.label.field ].choices ) && ! _.isUndefined( control.params.fields[ this.label.field ].choices[ rowLabelField.val() ] ) ) { |
|
| 2261 | rowLabel = control.params.fields[ this.label.field ].choices[ rowLabelField.val() ]; |
|
| 2262 | } |
|
| 2263 | } else if ( 'radio' === control.params.fields[ this.label.field ].type || 'radio-image' === control.params.fields[ this.label.field ].type ) { |
|
| 2264 | rowLabelSelector = control.selector + ' [data-row="' + this.rowIndex + '"] .repeater-field [data-field="' + this.label.field + '"]:checked'; |
|
| 2265 | rowLabel = jQuery( rowLabelSelector ).val(); |
|
| 2266 | } |
|
| 2267 | } |
|
| 2268 | } |
|
| 2269 | this.header.find( '.repeater-row-label' ).text( rowLabel ); |
|
| 2270 | return; |
|
| 2271 | } |
|
| 2272 | } |
|
| 2273 | } |
|
| 2274 | this.header.find( '.repeater-row-label' ).text( this.label.value + ' ' + ( this.rowIndex + 1 ) ); |
|
| 2275 | }; |
|
| 2276 | this.updateLabel(); |
|
| 2277 | }; |
|
| 2278 | ||
| 2279 | wp.customize.controlConstructor.repeater = wp.customize.Control.extend({ |
|
| 2280 | ||
| @@ 2159-2236 (lines=78) @@ | ||
| 2156 | wp.customize.controlConstructor['kirki-radio-buttonset'] = wp.customize.kirkiDynamicControl.extend({}); |
|
| 2157 | wp.customize.controlConstructor['kirki-radio-image'] = wp.customize.kirkiDynamicControl.extend({}); |
|
| 2158 | /* global kirkiControlLoader */ |
|
| 2159 | var RepeaterRow = function( rowIndex, container, label, control ) { |
|
| 2160 | ||
| 2161 | 'use strict'; |
|
| 2162 | ||
| 2163 | var self = this; |
|
| 2164 | this.rowIndex = rowIndex; |
|
| 2165 | this.container = container; |
|
| 2166 | this.label = label; |
|
| 2167 | this.header = this.container.find( '.repeater-row-header' ), |
|
| 2168 | ||
| 2169 | this.header.on( 'click', function() { |
|
| 2170 | self.toggleMinimize(); |
|
| 2171 | }); |
|
| 2172 | ||
| 2173 | this.container.on( 'click', '.repeater-row-remove', function() { |
|
| 2174 | self.remove(); |
|
| 2175 | }); |
|
| 2176 | ||
| 2177 | this.header.on( 'mousedown', function() { |
|
| 2178 | self.container.trigger( 'row:start-dragging' ); |
|
| 2179 | }); |
|
| 2180 | ||
| 2181 | this.container.on( 'keyup change', 'input, select, textarea', function( e ) { |
|
| 2182 | self.container.trigger( 'row:update', [ self.rowIndex, jQuery( e.target ).data( 'field' ), e.target ] ); |
|
| 2183 | }); |
|
| 2184 | ||
| 2185 | this.setRowIndex = function( rowIndex ) { |
|
| 2186 | this.rowIndex = rowIndex; |
|
| 2187 | this.container.attr( 'data-row', rowIndex ); |
|
| 2188 | this.container.data( 'row', rowIndex ); |
|
| 2189 | this.updateLabel(); |
|
| 2190 | }; |
|
| 2191 | ||
| 2192 | this.toggleMinimize = function() { |
|
| 2193 | ||
| 2194 | // Store the previous state. |
|
| 2195 | this.container.toggleClass( 'minimized' ); |
|
| 2196 | this.header.find( '.dashicons' ).toggleClass( 'dashicons-arrow-up' ).toggleClass( 'dashicons-arrow-down' ); |
|
| 2197 | }; |
|
| 2198 | ||
| 2199 | this.remove = function() { |
|
| 2200 | this.container.slideUp( 300, function() { |
|
| 2201 | jQuery( this ).detach(); |
|
| 2202 | }); |
|
| 2203 | this.container.trigger( 'row:remove', [ this.rowIndex ] ); |
|
| 2204 | }; |
|
| 2205 | ||
| 2206 | this.updateLabel = function() { |
|
| 2207 | var rowLabelField, |
|
| 2208 | rowLabel, |
|
| 2209 | rowLabelSelector; |
|
| 2210 | ||
| 2211 | if ( 'field' === this.label.type ) { |
|
| 2212 | rowLabelField = this.container.find( '.repeater-field [data-field="' + this.label.field + '"]' ); |
|
| 2213 | if ( _.isFunction( rowLabelField.val ) ) { |
|
| 2214 | rowLabel = rowLabelField.val(); |
|
| 2215 | if ( '' !== rowLabel ) { |
|
| 2216 | if ( ! _.isUndefined( control.params.fields[ this.label.field ] ) ) { |
|
| 2217 | if ( ! _.isUndefined( control.params.fields[ this.label.field ].type ) ) { |
|
| 2218 | if ( 'select' === control.params.fields[ this.label.field ].type ) { |
|
| 2219 | if ( ! _.isUndefined( control.params.fields[ this.label.field ].choices ) && ! _.isUndefined( control.params.fields[ this.label.field ].choices[ rowLabelField.val() ] ) ) { |
|
| 2220 | rowLabel = control.params.fields[ this.label.field ].choices[ rowLabelField.val() ]; |
|
| 2221 | } |
|
| 2222 | } else if ( 'radio' === control.params.fields[ this.label.field ].type || 'radio-image' === control.params.fields[ this.label.field ].type ) { |
|
| 2223 | rowLabelSelector = control.selector + ' [data-row="' + this.rowIndex + '"] .repeater-field [data-field="' + this.label.field + '"]:checked'; |
|
| 2224 | rowLabel = jQuery( rowLabelSelector ).val(); |
|
| 2225 | } |
|
| 2226 | } |
|
| 2227 | } |
|
| 2228 | this.header.find( '.repeater-row-label' ).text( rowLabel ); |
|
| 2229 | return; |
|
| 2230 | } |
|
| 2231 | } |
|
| 2232 | } |
|
| 2233 | this.header.find( '.repeater-row-label' ).text( this.label.value + ' ' + ( this.rowIndex + 1 ) ); |
|
| 2234 | }; |
|
| 2235 | this.updateLabel(); |
|
| 2236 | }; |
|
| 2237 | ||
| 2238 | wp.customize.controlConstructor.repeater = wp.customize.Control.extend({ |
|
| 2239 | ||