1// jqueryã®ã»ã¬ã¯ã¿ç¨ã«æååãã¨ã¹ã±ã¼ããã 2function ez_mf_selector_escape(val) { 3 return val.replace(/[ !"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&'); 4} 5 6// ãã£ã¼ã«ãã«å¤ãã»ãããã 7function ez_mf_set_value($form, controller, value, base_key, key) { 8 9 var full_key; 10 if (base_key === "") { 11 full_key = key; 12 } else { 13 full_key = base_key + '[' + key + ']'; 14 } 15 16// console.log("â " + full_key); 17// console.log(value); 18// console.log(" "); 19 20 // ãã£ã¼ã«ãã«å¤ãã»ããããï¼å®å¦çé¨ 21 var set_value = function (key, value) { 22 var is_no_specific = (key.slice(-2) === '[]'); 23 24 if (!is_no_specific) { // ãã¼ãç¹å®ã§ãã 25 var $word = $form.find('input[type="text"][name="' + ez_mf_selector_escape(key) + '"]'); 26 if ($word.length > 0) { 27 $word.val(value).trigger('input'); 28 return; 29 } 30 31 var $word = $form.find('input[type="email"][name="' + ez_mf_selector_escape(key) + '"]'); 32 if ($word.length > 0) { 33 $word.val(value).trigger('input'); 34 return; 35 } 36 37 var $word = $form.find('input[type="number"][name="' + ez_mf_selector_escape(key) + '"]'); 38 if ($word.length > 0) { 39 $word.val(value).trigger('input'); 40 return; 41 } 42 43 var $word = $form.find('input[type="tel"][name="' + ez_mf_selector_escape(key) + '"]'); 44 if ($word.length > 0) { 45 $word.val(value).trigger('input'); 46 return; 47 } 48 49 var $word = $form.find('input[type="color"][name="' + ez_mf_selector_escape(key) + '"]'); 50 if ($word.length > 0) { 51 $word.val(value).trigger('input'); 52 return; 53 } 54 55 var $text = $form.find('textarea[name="' + ez_mf_selector_escape(key) + '"]'); 56 if ($text.length > 0) { 57 $text.val(value).trigger('input'); 58 return; 59 } 60 61 var $select = $form.find('select[name="' + ez_mf_selector_escape(key) + '"]'); 62 if ($select.length > 0) { 63 $select.val(value).trigger('change'); 64 return; 65 } 66 67 var $checkbox = $form.find('input[type="checkbox"][name="' + ez_mf_selector_escape(key) + '"][value="' + ez_mf_selector_escape(value) + '"]'); 68 if ($checkbox.length > 0) { 69 $checkbox.prop("checked", true); 70 $checkbox.attr("checked", "checked"); 71 $checkbox.triggerHandler("click"); 72 return; 73 } 74 75 var $radio = $form.find('input[type="radio"][name="' + ez_mf_selector_escape(key) + '"][value="' + ez_mf_selector_escape(value) + '"]'); 76 if ($radio.length > 0) { 77 $radio.prop("checked", true); 78 $radio.attr("checked", "checked"); 79 $radio.triggerHandler("click"); 80 return; 81 } 82 83 } else { // ãã¼ãç¹å®ã§ãããvalueå¤ã¾ã§è¦ãå¿ è¦ããã 84 var $checkbox = $form.find('input[type="checkbox"][name="' + ez_mf_selector_escape(key) + '"][value="' + ez_mf_selector_escape(value) + '"]'); 85 if ($checkbox.length > 0) { 86 $checkbox.prop("checked", true); 87 $checkbox.attr("checked", "checked"); 88 $checkbox.triggerHandler("click"); 89 return; 90 } 91 92 var $radio = $form.find('input[type="radio"][name="' + ez_mf_selector_escape(key) + '"][value="' + ez_mf_selector_escape(value) + '"]'); 93 if ($radio.length > 0) { 94 $radio.prop("checked", true); 95 $radio.attr("checked", "checked"); 96 $radio.triggerHandler("click"); 97 return; 98 } 99 100 } 101 }; 102 103 104 if (base_key === "") { // é åã§ãªãè¦ç´ 105 set_value(key, value); 106 } else { 107 if (key.toString().match(/^[0-9]+$/)) { // é åå ã®æ°åã¤ã³ããã¯ã¹ã®è¦ç´ 108 if ($('[name="' + ez_mf_selector_escape(full_key) + '"]').length === 0) { // é åå ã®æ°åã¤ã³ããã¯ã¹ã®è¦ç´ ã§ãç´æ¥ãã®nameãæã¤formè¦ç´ ãåå¨ããªãæ 109 set_value(base_key + '[]', value); 110 } else { // é åå ã®æ°åã¤ã³ããã¯ã¹ã®è¦ç´ ã§ãç´æ¥ãã®nameãæã¤formè¦ç´ ãåå¨ããæ 111 set_value(full_key, value); 112 } 113 } else { // é åå ã®æååã¤ã³ããã¯ã¹ã®è¦ç´ 114 set_value(full_key, value); 115 } 116 } 117} 118 119// ãã¡ã¤ã«ãã£ã¼ã«ãã«éä¿¡æ¸ã¿ãã¡ã¤ã«ã®æ å ±ãä»å ãã 120function ez_mf_set_file($form, controller, base_url, value, base_key, value_key) { 121 var obj = value; 122 var obj_base_key = base_key;
123 var obj_key = value_key; 124 125 var obj_full_key; 126 if (obj_base_key === "") { 127 obj_full_key = obj_key; 128 } else { 129 obj_full_key = obj_base_key + '[' + obj_key + ']'; 130 } 131 132// console.log("â " + obj_full_key); 133// console.log(obj); 134// console.log(" "); 135 136 var domain = base_url.replace(controller+'/',''); 137 138 if (obj['id'] && $form.find('input[type="file"][name="' + ez_mf_selector_escape(obj_full_key) + '"]').length > 0) { 139 $('input[type="file"][name="' + ez_mf_selector_escape(obj_full_key) + '"]').hide().after( 140 "<span class=\"ez_mf_file_description " + obj_full_key + "\">ç¾å¨ã®ãã¡ã¤ã«ï¼ <a href=\"" + domain + "data_files/view/"+obj['id']+"/mode:attachment/download:1\" target=\"_blank\">" + obj['file_full_value'] + "</a>" + 141 " <span><button class=\"ez_mf_clear_before_file_button\" type=\"button\" onclick=\"ez_mf_clear_before_file(\'" + controller + "\',\'" + base_url + "remove_file_from_before_data/" + obj_full_key + '?' + (new Date()).getTime() + "\',\'" + obj_full_key + "\')\">ãã¡ã¤ã«é¸æãè§£é¤</button></span></span>" 142 ); 143 } 144} 145 146// éä¿¡æ¸ã¿ãã¡ã¤ã«ã®æ å ±ãåé¤ãã 147function ez_mf_clear_before_file(controller, url, key) { 148 var field = key; 149 var $form = $('form[action$="' + controller + '/postmail"]'); 150 $.ajax({ 151 //type: ãªãã·ã§ã³ã¯$.ajaxã®åæå¤ã§"GET"ã§ãã 152 url: url, 153 dataType: 'json', 154 data: null, 155 success: function (data) { 156 $form.find('.ez_mf_file_description.' + field).remove(); 157 $form.find('input[type="file"][name="' + ez_mf_selector_escape(field) + '"]').show(); 158 }, 159 }); 160} 161 162// éä¿¡æ¸ã¿ãã¡ã¤ã«ã®æ å ±ãåé¤ãã 163function ez_mf_clear_file(key) { 164 var field = key; 165// console.log($(field).parent()); 166 var button = $(field).parent().find(".ez_mf_clear_before_file_button"); 167// console.log(button); 168 if (button.length > 0) { 169 button.click(); 170 } 171 $(field).val("").trigger("input").trigger("change"); 172} 173 174function ez_mf_set_values($form, controller, base_url, value, base_key, value_key) { 175 var obj = value; 176 var obj_base_key = base_key; 177 var obj_key = value_key; 178 if (obj instanceof Object) { // é åãã¼ã¿ 179 if (obj['isfile']) { // ãã¡ã¤ã«ãã£ã¼ã«ãã®é å 180 ez_mf_set_file($form, controller, base_url, obj, obj_base_key, obj_key); 181 } else { // ãã¡ã¤ã«ä»¥å¤ã®é å 182 if (obj_base_key === "") { 183 obj_base_key = obj_key; 184 } else { 185 obj_base_key = obj_base_key + '[' + obj_key + ']'; 186 } 187 Object.keys(obj).forEach(function (key) { 188 ez_mf_set_values($form, controller, base_url, obj[key], obj_base_key, key); 189 }); 190 } 191 } else { // åé ç® 192 ez_mf_set_value($form, controller, obj, obj_base_key, obj_key); 193 } 194} 195 196function ez_mf_initialize(controller) { 197// var $form = $('form[action$="' + controller + '/postmail"]'); 198 var $forms = $('form'); 199 var $form = null; 200 var action = ''; 201 $forms.each(function(){ 202 if ($form === null) { 203 var $a_form = $(this); 204 action = $a_form.attr('action'); 205// if (action.match(new RegExp(controller + '/postmail(/?)(\\?.*)(#.*)'))) { 206 if (action.match(new RegExp(controller + '/postmail'))) { 207 $form = $a_form; 208 } 209 } 210 }); 211// if ($form.length > 0) { 212 if ($form !== null) { 213// var action = $form.attr('action'); 214// if (action === controller + '/postmail') { 215 if (action.match(new RegExp('^' + controller + '/postmail'))) { 216 action = '/' + action; 217 } 218// var base_url = action.replace('postmail', ''); 219 var base_url = action.replace(/postmail(.*)$/, ''); 220 var url = base_url + 'get_before_data?' + (new Date()).getTime(); 221 222 $form.find('select').each(function(){ 223 var $selected_option = $(this).find('option').eq(0); 224 225 $(this).find('option').each(function(){ 226 if ($(this).attr('selected') !== undefined) { 227 $selected_option = $(this); 228 } 229 }); 230 231 $selected_option.prop('selected', true).closest('select').trigger('change'); 232 }); 233 234 $form.find('input[type="text"],input[type="password"],input[type="file"],textarea').val("").trigger('input'); 235 236 $form.find('input[type="checkbox"],input[type="radio"]').each(function(){ 237 if ($(this).attr('checked') === undefined) { 238 $(this).prop('checked', false); 239 } else { 240 $(this).removeAttr('checked'); 241 $(this).prop('checked', true); 242 } 243 }); 244 245 $form.find('.ez_mf_file_description').remove(); 246 247 $.ajax({ 248 //type: ãªãã·ã§ã³ã¯$.ajaxã®åæå¤ã§"GET"ã§ãã 249 url: url, 250 dataType: 'json', 251 data: null, 252 success: function (data) { 253 if (data instanceof Object) { 254 if (data['MailSend'] && data['MailSend'] instanceof Object) { 255 ez_mf_set_values($form, controller, base_url, data['MailSend'], "", ""); 256 }else if (data['MemberAdd'] && data['MemberAdd'] instanceof Object) { 257 ez_mf_set_values($form, controller, base_url, data['MemberAdd'], "", ""); 258 } 259 } 260 if (typeof ez_mf_custom_init == 'function') { 261 ez_mf_custom_init($form); 262 } 263 }, 264 }); 265 } 266} 267 268function ez_mf_all_clear(controller) { 269 var $form = $('form[action$="' + controller + '/postmail"]'); 270 if ($form.length > 0) { 271 $form.find('select').val("").trigger('change'); 272 $form.find('input[type="text"],input[type="password"],input[type="file"],textarea').val("").trigger('input'); 273 $form.find('input[type="checkbox"],input[type="radio"]').prop('checked', false); 274 $form.find('input[type="checkbox"],input[type="radio"]').removeAttr('checked'); 275 $form.find('.ez_mf_file_description').remove(); 276 } 277}
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.