1(function($){ 2 3 var userMeta = userMeta || {}; 4 5 userMeta.common = { 6 init: function() {} 7 } 8 9 userMeta.front = { 10 11 init: function() { 12 $('.um_generated_form').each(function(){ 13 userMeta.front.initForm( this ); 14 }); 15 }, 16 17 initForm: function( editor ) { 18 this.editor = $(editor); 19 this.load(); 20 this.events(); 21 }, 22 23 load: function() { 24 $('.um_user_form').validationEngine(); 25 $('.um_rich_text').wysiwyg({initialContent:' '}); 26 $('input, textarea').placeholder(); 27 umFileUploader(); 28 }, 29 30 events: function() { 31 this.editor.on('change', '.um_parent', this.chekConditions); 32 }, 33 34 chekConditions: function() { 35 var editor = userMeta.front.editor; 36 37 editor.find('script[type="text/json"].um_condition').each(function() { 38 try { 39 var condition = JSON.parse($(this).text()); 40 var evals = []; 41 42 $.each( condition.rules, function() { 43 44 var target = []; 45 $.each(editor.find('.um_field_' + this.field_id), function() { 46 var parentField = $(this) 47 var tagName = parentField.prop("tagName").toLowerCase(); 48 if (tagName == 'input' && $.inArray(parentField.attr('type'), ['checkbox', 'radio']) > -1) { 49 if (parentField.is(":checked")) { 50 target.push(parentField.val()); 51 } 52 } else if (tagName == 'select' && parentField.attr('multiple')) { 53 target = parentField.val(); 54 } else { 55 target.push(parentField.val()); 56 } 57 }); 58 59 switch ( this.condition ) { 60 case 'is' : 61 evals.push($.inArray(this.value, target) > -1 ? true : false); 62 break; 63 64 case 'is_not' : 65 evals.push($.inArray(this.value, target) > -1 ? true : false); 66 break; 67 } 68 }) 69 70 var result = evals[0]; 71 72 if ( evals.length > 1 ) { 73 for ( var i = 1; i < evals.length; i++ ) { 74 if ( 'and' == condition.relation ) { 75 result = result && evals[ i ]; 76 } else { 77 result = result || evals[ i ]; 78 } 79 } 80 } 81 82 if ( ( ( 'show' == condition.visibility ) && ! result ) || ( ( 'hide' == condition.visibility ) && result ) ) { 83 $(this).closest('.um_field_container').hide('slow'); 84 } else { 85 $(this).closest('.um_field_container').show('slow'); 86 } 87 88 } catch (err) {} 89 }); 90 } 91 }; 92 93 $(function() { 94 userMeta.common.init(); 95 userMeta.front.init(); 96 }); 97 98 $('.um_generated_form :first *:input:enabled:visible:first').focus(); 99 100})(jQuery); 101 102var umAjaxRequest; 103 104function pfAjaxCall(element, action, arg, handle) { 105 if ( typeof arg == 'object' ) { 106 data = arg; 107 if (action) data.action = action; 108 //if (!data.pf_nonce) data.pf_nonce = pf_nonce; 109 } else if ( typeof arg == 'string' ) { 110 if (action) data = "action=" + action; 111 if (arg) data = arg + "&action=" + action; 112 if (arg && !action) data = arg; 113 114 var n = data.search("pf_nonce"); 115 if (n<0) { 116 data = data + "&pf_nonce=" + pf_nonce; 117 } 118 data = data + "&is_ajax=true"; 119 } 120 121 //if( typeof(ajaxurl) == 'undefined' ) ajaxurl = front.ajaxurl; 122 123 umAjaxRequest = jQuery.ajax({ 124 type: "post", 125 url: ajaxurl, 126 data: data,
127 beforeSend: function() { jQuery("<span class='pf_loading'> </span>").insertAfter(element); }, 128 success: function( data ){ 129 jQuery(".pf_loading").remove(); 130 handle(data); 131 } 132 }); 133} 134 135function pfAjaxRequest(element) { 136 bindElement = jQuery(element); 137 bindElement.parent().children(".pf_ajax_result").remove(); 138 arg = jQuery( element ).serialize(); 139 pfAjaxCall( bindElement, 'pf_ajax_request', arg, function(data) { 140 bindElement.after("<div class='pf_ajax_result'>"+data+"</div>"); 141 }); 142 143} 144 145function umInsertUser(element) { 146 if (typeof(tinyMCE) !== 'undefined') tinyMCE.triggerSave(); 147 if (!jQuery(element).validationEngine("validate")) return; 148 149 bindElement = jQuery(element); 150 bindElement.children(".pf_ajax_result").remove(); 151 arg = jQuery( element ).serialize(); 152 pfAjaxCall( bindElement, 'pf_ajax_request', arg, function(data) { 153 if (jQuery(data).attr('action_type') == 'registration') 154 jQuery(element).replaceWith(data); 155 else 156 bindElement.append("<div class='pf_ajax_result'>"+data+"</div>"); 157 }); 158} 159 160function umLogin(element) { 161 //if( !jQuery(element).validationEngine("validate") ) return; 162 163 arg = jQuery( element ).serialize(); 164 bindElement = jQuery(element); 165 bindElement.children(".pf_ajax_result").remove(); 166 pfAjaxCall(bindElement, 'pf_ajax_request', arg, function(data) { 167 if ( jQuery(data).attr('status') == 'success' ) { 168 //jQuery(element).replaceWith(data); //Commented from 1.1.5rc2, not showing anything while redirecting 169 redirection = jQuery(data).attr('redirect_to'); 170 if ( redirection ) 171 window.location.href = redirection; 172 } 173 else 174 bindElement.append("<div class='pf_ajax_result'>"+data+"</div>"); 175 }); 176} 177 178function umLogout(element) { 179 arg = 'action_type=logout'; 180 181 pfAjaxCall(element, 'um_login', arg, function(data) { 182 //alert(data); 183 //jQuery("#" + jQuery() ) 184 jQuery(element).after(data); 185 //jQuery(element).parents(".error").remove(); 186 }); 187} 188 189function umPageNavi(pageID, isNext, element) { 190 var hasError = false; 191 var hasHtml5Error = false; 192 193 if (typeof element == "object") 194 formID = "#" + jQuery(element).parents("form").attr("id"); 195 else 196 formID = "#" + element; 197 198 if (isNext) { 199 checkingPage = parseInt(pageID) - 1; 200 201 jQuery(formID + " #um_page_segment_" + checkingPage + " .um_input").each(function() { 202 fieldID = jQuery(this).attr("id"); 203 204 if (fieldID !== undefined) { 205 validateHtml5 = jQuery("#" + fieldID)[0].checkValidity(); 206 if (! validateHtml5) { 207 hasHtml5Error = true; 208 hasError = true; 209 } 210 211 error = ! jQuery("#" + fieldID).validationEngine("validate"); 212 if (error) hasError = true; 213 } 214 }); 215 216 if (hasHtml5Error) { 217 jQuery(formID).find(":submit").click(); 218 } 219 } else 220 jQuery(formID).validationEngine("hide"); 221 222 if (hasError) return false; 223 224 jQuery(formID).children(".um_page_segment").hide(); 225 jQuery(formID).children("#um_page_segment_" + pageID).fadeIn("slow"); 226 jQuery("html, body").animate({ 227 scrollTop: jQuery("#um_page_segment_" + pageID).offset().top 228 }); 229} 230 231function umFileUploader() { 232 jQuery(".um_file_uploader_field").each(function(index) { 233 234 var divID = jQuery(this).attr("id"); 235 var fieldID = jQuery(this).attr("um_field_id"); 236 var formKey = jQuery(this).attr("um_form_key") || ""; 237 238 allowedExtensions = jQuery(this).attr("extension"); 239 allowedExtensions = allowedExtensions.replace(/\s+/g,""); 240 maxSize = jQuery(this).attr("maxsize") 241 if ( !allowedExtensions ) 242 allowedExtensions = "jpg,jpeg,png,gif"; 243 if ( !maxSize ) 244 maxSize = 1 * 1024 * 1024; 245 246 var uploader = new qq.FileUploader({ 247 // pass the dom node (ex. $(selector)[0] for jQuery users) 248 element: document.getElementById(divID), 249 // path to server-side upload script 250 action: ajaxurl, 251 params: {"action":"um_file_uploader", "field_name":jQuery(this).attr("name"), field_id:fieldID, form_key:formKey, "pf_nonce":pf_nonce }, 252 allowedExtensions: allowedExtensions.split(","), 253 sizeLimit: maxSize, 254 onComplete: function(id, fileName, responseJSON){ 255 if( !responseJSON.success ) return; 256 257 // responseJSON comes from uploader.php return 258 handle = jQuery('#'+fieldID); 259 arg = 'field_name=' + responseJSON.field_name + '&filepath=' + responseJSON.filepath + '&field_id=' + fieldID + '&form_key='
259+ formKey; 260 261 // Check if it is used by User Import Upload 262 if ( responseJSON.field_name == 'txt_upload_ump_import' ) { 263 arg = arg + '&method_name=ImportUmp'; 264 pfAjaxCall( handle, 'pf_ajax_request', arg, function(data){ 265 jQuery('#'+fieldID+'_result').empty().append( data ); 266 }); 267 } else if ( responseJSON.field_name == 'csv_upload_user_import' ) { 268 arg = arg + '&step=one'; 269 pfAjaxCall( handle, 'um_user_import', arg, function(data){ 270 jQuery("#csv_upload_user_import_result").html(data); 271 //jQuery(handle).parents(".meta-box-sortables").replaceWith(data); 272 }); 273 } else { 274 pfAjaxCall( handle, 'um_show_uploaded_file', arg, function(data) { 275 jQuery('#'+divID+'_result').empty().append( data ); 276 }); 277 } 278 } 279 }); 280 }); 281} 282 283function umShowImage(element) { 284 url = jQuery(element).val(); 285 if (!url) { 286 jQuery(element).parents(".um_field_container").children(".um_field_result").empty(); 287 return; 288 } 289 290 arg = 'showimage=true&imageurl=' + url; 291 pfAjaxCall( element, 'um_show_uploaded_file', arg, function(data){ 292 jQuery(element).parents(".um_field_container").children(".um_field_result").empty().append(data); 293 }); 294} 295 296function umRemoveFile(element) { 297 if (confirm(fileuploader.confirm_remove)) { 298 fieldName = jQuery(element).attr("data-field_name"); 299 jQuery(element).parents(".um_field_container").find(".qq-upload-success").remove(); 300 jQuery(element).parents(".um_field_result").empty().append("<input type='hidden' name='"+fieldName+"' value='' />"); 301 } 302} 303 304function umUpgradeFromPrevious(element) { 305 arg = 'typess=xx'; 306 pfAjaxCall( element, 'um_common_request', arg, function(data) { 307 jQuery(element).parents(".error").remove(); 308 }); 309} 310 311function umRedirection(element) { 312 var arg = jQuery( element ).parent("form").serialize(); 313 document.location.href = ajaxurl + "?action=pf_ajax_request&" + arg; 314} 315 316function umConditionalRequired(field, rules, i, options) { 317 var baseField = field.attr('id').split('_'); 318 baseField.pop(); 319 baseField = baseField.join('_'); 320 321 if (jQuery('#' + baseField).val().length > 0 && field.val().length == 0) 322 rules.push('required'); 323} 324 325function umShowVideo(element, type, width, height){ 326 url = jQuery(element).val(); 327 if (!url) { 328 jQuery(element).parents(".um_field_container").children(".um_field_result").empty(); 329 return; 330 } 331 332 if (type == "youtube_video") { 333 regex = /^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&"'>]+)/; 334 id = (url.match(regex) != null && url.match(regex)[1]) ? url.match(regex)[1] : null; 335 336 if( !id || id.length != 11) { 337 jQuery(element).parents(".um_field_container").children(".um_field_result").empty(); 338 return; 339 } else { 340 src = 'https://www.youtube.com/embed/' + id; 341 embed = '<iframe width=' + width + ' height=' + height + ' src=' + src + '></iframe>'; 342 jQuery(element).parents(".um_field_container").children(".um_field_result").empty().append(embed); 343 return; 344 } 345 } else if (type == "vimeo_video") { 346 regex = /https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/; 347 id = (url.match(regex) != null && url.match(regex)[3]) ? url.match(regex)[3] : null; 348 349 if( !id ) { 350 jQuery(element).parents(".um_field_container").children(".um_field_result").empty(); 351 return; 352 } else { 353 src = 'https://player.vimeo.com/video/' + id; 354 embed = '<iframe src='+ src + ' width=' + width + ' height=' + height + '></iframe>'; 355 jQuery(element).parents(".um_field_container").children(".um_field_result").empty().append(embed); 356 return; 357 } 358 } 359} 360 361function umShowHidePass(element){ 362 //alert('here'); 363 select = jQuery(element).closest('.um_password_icon').children('input.um_input'); 364 if (jQuery(select).attr("type") == "password") { 365 jQuery(element).removeClass('dashicons-visibility').addClass('dashicons-hidden'); 366 jQuery(select).attr("type", "text"); 367 } 368 else { 369 jQuery(element).removeClass('dashicons-hidden').addClass('dashicons-visibility'); 370 jQuery(select).attr("type", "password"); 371 } 372}
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.