1function gmpUploadNewIconStart(param){ 2 jQuery('.gmpFileUpRes img').attr('src',GMP_DATA.loader); 3} 4var seletcObj; 5function drawNewIcon(icon){ 6 if(typeof(icon.data)==undefined){ 7 return; 8 } 9 console.log(icon); 10 var newElem = '<a class="markerIconItem active" data_name="'+icon.title+'" data_desc="'+icon.description+'" ' 11 newElem +='title="'+icon.title+'" data_val="'+icon.id+'">'; 12 newElem +='<img src="'+icon.url+'" class="gmpMarkerIconFile">'; 13 newElem +='</a>'; 14 jQuery(".markerIconItem").removeClass('active'); 15 gmpCurrentMarkerForm.find(".gmpIconsList").append(newElem); 16 jQuery('.gmpIconsList').scrollTop(jQuery('.gmpIconsList')[0].scrollHeight); 17 if(gmpExistsIcons==undefined){ 18 gmpExistsIcons=[]; 19 } 20 gmpExistsIcons[icon.id] = icon; 21 gmpExistsIcons[icon.id].path = icon.url; 22 gmpCurrentIcon=icon.id; 23} 24 25function setcurrentIconToForm(iconId,markerForm){ 26 markerForm.find("#gmpSelectedIcon").val(iconId); 27 markerForm.find(".markerIconItem.active").removeClass('active'); 28 29 var currItm = markerForm.find(".markerIconItem[data_val='"+iconId+"']"); 30 try{ 31 currItm.addClass('active'); 32 markerForm.find('.gmpIconsList').scrollTo(currItm); 33 }catch(e){ 34 console.log(e); 35 } 36 gmpCurrentIcon=iconId; 37} 38 39var custom_uploader; 40jQuery(document).ready(function(){ 41 gmpCurrentIcon = jQuery("#gmpAddMarkerToNewForm").find("#gmpSelectedIcon").val() 42 jQuery("body").on("change","#gmpSelectedIcon",function(){ 43 gmpCurrentIcon=jQuery(this).val(); 44 }) 45 jQuery("body").on("change","#gmpSelectedIcon_edit",function(){ 46 gmpCurrentIcon=jQuery(this).val(); 47 }) 48 /* 49 * wp media upload 50 * 51 */ 52 jQuery('.gmpUploadIcon').click(function(e) { 53 e.preventDefault(); 54 //If the uploader object has already been created, reopen the dialog 55 if (custom_uploader) { 56 custom_uploader.open(); 57 return; 58 } 59 //Extend the wp.media object 60 custom_uploader = wp.media.frames.file_frame = wp.media({ 61 title: 'Choose Image', 62 button: { 63 text: 'Choose Image' 64 }, 65 multiple: false 66 }); 67 //When a file is selected, grab the URL and set it as the text field's value 68 var currentForm = jQuery(this).parents("form"); 69 custom_uploader.on('select', function() { 70 var attachment = custom_uploader.state().get('selection').first().toJSON(); 71 var respElem = jQuery('.gmpUplRes'); 72 73 var sendData={ 74 page :'icons', 75 action :"saveNewIcon", 76 reqType :"ajax", 77 icon :{ 78 url:attachment.url, 79 } 80 } 81 if(attachment.title!=undefined){ 82 sendData.icon.title=attachment.title; 83 } 84 if(attachment.description !=undefined){ 85 sendData.icon.description = attachment.description; 86 } 87 jQuery.sendFormGmp({ 88 msgElID:respElem, 89 data:sendData, 90 onSuccess:function(res){ 91 if(!res.error){ 92 var newItem =drawNewIcon(res.data); 93 }else{ 94 respElem.html(data.error.join(',')); 95 } 96 } 97 }) 98 }); 99 //Open the uploader dialog 100 custom_uploader.open(); 101 }); 102 103 jQuery(".gmpIconsList").on("click",".markerIconItem",function(){ 104 jQuery(".markerIconItem").removeClass('active'); 105 jQuery(this).addClass('active'); 106 var value = jQuery(this).attr("data_val"); 107 jQuery(this).parents(".gmpFormRow").find("#gmpSelectedIcon").val(value); 108 gmpCurrentIcon = value; 109 }) 110 jQuery(".gmpSearchIconField").keyup(function(e){ 111 var search_word = jQuery(this).val(); 112 if(search_word==""){ 113 jQuery(".markerIconItem").show(); 114 return; 115 } 116 if(search_word.length<2){ 117 return false; 118 } 119 jQuery(".markerIconItem").each(function(){ 120 var itmDesc=jQuery(this).attr("data_desc"); 121 var name=jQuery(this).attr("data_name"); 122 if(itmDesc.indexOf(search_word) == -1){ 123 jQuery(this).hide(); 124 } 125 }) 126 }) 127 128 129}) 130function clearIconSearch(){ 131 jQuery(".gmpSearchIconField").val(""); 132 jQuery(".markerIconItem").show(); 133}
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.