1;(function ( $, window, undefined ) { 2 3 var user_role_update_close_button = function(wrapper) { 4 5 type = wrapper.closest('.ast-user-role-wrapper').attr('data-type'); 6 rules = wrapper.find('.zozo-user-role-condition'); 7 show_close = false; 8 9 if ( rules.length > 1 ) { 10 show_close = true; 11 } 12 13 rules.each(function() { 14 if ( show_close ) { 15 jQuery(this).find('.user_role-condition-delete').removeClass('ast-hidden'); 16 }else{ 17 jQuery(this).find('.user_role-condition-delete').addClass('ast-hidden'); 18 } 19 }); 20 }; 21 22 $(document).ready(function($) { 23 24 jQuery('.ast-user-role-selector-wrapper').each(function() { 25 user_role_update_close_button( jQuery(this) ); 26 }) 27 28 jQuery( '.ast-user-role-selector-wrapper' ).on( 'click', '.user_role-add-rule-wrap a', function(e) { 29 e.preventDefault(); 30 e.stopPropagation(); 31 var $this = jQuery( this ), 32 id = $this.attr( 'data-rule-id' ), 33 new_id = parseInt(id) + 1, 34 rule_wrap = $this.closest('.ast-user-role-selector-wrapper').find('.user_role-builder-wrap'), 35 template = wp.template( 'zozo-user-role-condition' ), 36 field_wrap = $this.closest('.ast-user-role-wrapper'); 37 38 rule_wrap.append( template( { id : new_id } ) ); 39 40 $this.attr( 'data-rule-id', new_id ); 41 42 user_role_update_close_button( field_wrap ); 43 }); 44 45 jQuery( '.ast-user-role-selector-wrapper' ).on( 'click', '.user_role-condition-delete', function(e) { 46 var $this = jQuery( this ), 47 rule_condition = $this.closest('.zozo-user-role-condition'), 48 field_wrap = $this.closest('.ast-user-role-wrapper'); 49 cnt = 0, 50 data_type = field_wrap.attr( 'data-type' ), 51 optionVal = $this.siblings('.user_role-condition-wrap').children('.user_role-condition').val(); 52 53 rule_condition.remove(); 54 55 field_wrap.find('.zozo-user-role-condition').each(function(i) { 56 var condition = jQuery( this ), 57 old_rule_id = condition.attr('data-rule'), 58 select_location = condition.find('.user_role-condition'), 59 location_name = select_location.attr( 'name' ); 60 61 condition.attr( 'data-rule', i ); 62 63 select_location.attr( 'name', location_name.replace('['+old_rule_id+']', '['+i+']') ); 64 65 condition.removeClass('ast-user-role-'+old_rule_id).addClass('ast-user-role-'+i); 66 67 cnt = i; 68 }); 69 70 field_wrap.find('.user_role-add-rule-wrap a').attr( 'data-rule-id', cnt ) 71 72 user_role_update_close_button( field_wrap ); 73 }); 74 }); 75}(jQuery, window));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.