1(function($){ 2 'use strict'; 3 4 $(function(){ 5 6 var $root = $('#section_purpose'); 7 var $parent = $root.find('#list_select_purpose_01'); 8 var $child = $root.find('#list_select_purpose_02'); 9 10 var $before = $root.find('.select_before'); 11 var $after = $root.find('.select_after'); 12 var $cards = $root.find('.card_item'); 13 14 var $beforeText = $before.find('.title'); 15 16 // åæç¶æ ã® option ãè¤è£½ãã¦ä¿æãã¦ããï¼å ã®ä¸¦ã³é ãä¿åï¼ 17 var $placeholderOption = $child.find('option').first(); // ã鏿ãã¦ãã ããã 18 var $allChildOptions = $child.find('option[data-parent]').clone(true); 19 20 function showDefault(msg){ 21 $cards.hide(); 22 $beforeText.text(msg); 23 $before.show(); 24 $after.hide(); 25 } 26 27 function showChoose(){ 28 $before.hide(); 29 $after.show(); 30 } 31 32 // data-category ã«å«ã¾ãããå¤å® 33 function hasCategory($card, code){ 34 var raw = $card.attr('data-category') || ''; 35 raw = $.trim(raw); 36 if (!raw) return false; 37 38 var list = raw.split(/\s+/); 39 return $.inArray(code, list) !== -1; 40 } 41 42 // è¦ªå¤æ´ 43 $parent.on('change', function(){ 44 var parentVal = $(this).val(); 45 46 $child.val(''); 47 48 if (!parentVal) { 49 $child.prop('disabled', true); 50 showDefault('ããªãã¸ã®ããããæ å ±ã表示ããã¾ãã'); 51 return; 52 } 53 54 $child.prop('disabled', false); 55 56 $child.empty().append($placeholderOption); 57 $allChildOptions.each(function(){ 58 var $opt = $(this); 59 if ($opt.data('parent') === parentVal) { 60 $child.append($opt.clone(true)); 61 } 62 }); 63 64 showDefault('ããªãã¸ã®ããããæ å ±ã表示ããã¾ãã'); 65 }); 66 67 // å夿´ â ã«ã¼ãçµãè¾¼ã¿ï¼è¤æ°ã«ãã´ãªå¯¾å¿ï¼â»ããã¯å¤æ´ãªã 68 $child.on('change', function(){ 69 var code = $(this).val(); 70 71 if (!code) { 72 showDefault('ããªãã¸ã®ããããæ å ±ã表示ããã¾ãã'); 73 return; 74 } 75 76 var visibleCount = 0; 77 78 $cards.each(function(){ 79 var $card = $(this); 80 var match = hasCategory($card, code); 81 $card.toggle(match); 82 if (match) visibleCount++; 83 }); 84 85 if (visibleCount === 0) { 86 showDefault('ããªãã¸ã®ããããæ å ±ãããã¾ããã'); 87 } else { 88 showChoose(); 89 } 90 }); 91 92 // åæç¶æ 93 $child.prop('disabled', true); 94 showDefault('ããªãã¸ã®ããããæ å ±ã表示ããã¾ãã'); 95 96 }); 97 98})(jQuery);
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.