1$.fn.extend({ 2 expandCategory: function() { 3 4 this.each(function() { 5 $(this).click(function(e){ 6 $a = $(this); 7 $expand = $a.children("span.expand"); 8 $li = $(this).closest("li"); 9 $ul = $li.children("ul"); 10 if($ul.length > 0) { 11 e.preventDefault(); 12 $ul.slideToggle(800, 'swing', function(){ 13 var reltag = $expand.text(); 14 $expand.text($expand.attr("rel")); 15 $expand.attr("rel", reltag); 16 }); 17 } 18 }); 19 }); 20 21 }, 22 pkdDataSignup: function (feedback) { 23 this.each(function() { 24 if($(this).length > 0) { 25 $(this).submit(function (e) { 26 e.preventDefault(); 27 28 //set some form html objects 29 var $form = $(this); //this form 30 var $fields = $(this).find(".form-control"); //this form's fields, minus the lists 31 var $submit_btn = $form.find('button[type="submit"]'); //this form's submit button 32 var $lists_wrapper = $form.find('.widget-signup-lists'); 33 var $lists = $lists_wrapper.find('input,select'); //this form's lists, checkbox, select, or hidden input 34 35 //feedback for signup 36 var $feedback = (typeof feedback != "undefined" ? $form.parent().find(feedback) : $("#widget_cc_email_box_message1")); 37 38 //get the selected list(s) 39 var selected_list = '1'; 40 if($lists_wrapper.length > 0) { 41 selected_list = ''; 42 $lists.each(function(idx, list){ 43 this_list = $(list); 44 if(this_list.is(":checked") || this_list.is(":selected")) { 45 if(selected_list != '') 46 selected_list += ", "; 47 selected_list += this_list.val(); 48 } else if(this_list.attr("type") == 'hidden') { 49 selected_list = this_list.val(); 50 } 51 }); 52 } 53 54 //reset error and feedback states 55 $feedback.html("").hide(); 56 $(".has-error").removeClass("has-error"); 57 var errors = {}; 58 59 //reset form parameters 60 var emailparams = ""; 61 62 //set button into loading state 63 $submit_btn.button('loading'); 64 65 $fields.each(function(idx, val){ 66 $fld = $(val); 67 var fld_isRequired = $fld.hasClass('required'); 68 var fld_val = $fld.val(); 69 70 if( fld_isRequired && $.trim(fld_val) == "" ) { 71 if($.isEmptyObject(errors)) 72 errors = new Array(); 73 74 $fld.parent().addClass("has-error"); 75 errors.push($fld); 76 } 77 }); 78 79 //handle error case if no lists are selected 80 if(selected_list == '' && $lists_wrapper.length > 0 ) { 81 if($.isEmptyObject(errors)) 82 errors = new Array(); 83 errors.push($lists_wrapper); 84 $lists_wrapper.addClass('has-error'); 85 } else { 86 $lists_wrapper.removeClass('has-error'); 87 } 88 89 //If email address or required fields are empty don't bother calling ajax 90 //instead print out a not so nice message to enter all required fields 91 if($.isEmptyObject(errors)) { 92 93 var gcaptcha = ''; 94 if(typeof grecaptcha !== 'undefined') { 95 gcaptcha = grecaptcha.getResponse(); 96 } 97 98 emailparams = ($form.find('input[name*="address"]').length > 0 ? encodeURIComponent( $form.serialize() ) : $form.find('#widget_cc_email').val()); 99 var widget_id = $form.data('widget-id'); 100 var func = (widget_id.search('constantcontact') != -1 ? 'widget_constantcontact_subscribe':'widget_subscribe'); 101 var fname = ($('#signup_firstname').length > 0) ? $('#signup_firstname').val() : ""; 102 var lname = ($('#signup_lastname').length > 0) ? $('#signup_lastname').val() : ""; 103 var name = fname + " " + lname; 104 $.ajax({
105 type: "POST", 106 url: "/manager/include/ajax_call.php", 107 data: "a_func="+func+"&a_params=" + emailparams +'|'+selected_list+'|'+widget_id+'|'+name+'|'+gcaptcha, 108 success: function (data) { 109 //Returns an array(success=>true/false, msg) 110 var response = jQuery.parseJSON(data); 111 112 $(".has-error").removeClass("has-error"); 113 114 //If the email was successfully added then hide form and print out nice message 115 //Otherwise, print out a not so nice message telling them they signed up wrong 116 if(response.success) { 117 $form.fadeOut(function () { 118 $feedback.html('<div class="alert alert-success">'+response.msg+'</div>').fadeIn("fast"); 119 }); 120 } else { 121 if( $.trim(response.fields) != "" ) { 122 var new_errors = []; 123 $.each(response.fields, function(idx,val) { 124 $fld = $("#"+val); 125 new_errors.push($fld); 126 $fld.parent().addClass("has-error"); 127 }); 128 new_errors[0].focus(); 129 } 130 $feedback.html('<div class="alert alert-danger">'+response.msg+'</div>').fadeIn("fast"); 131 } 132 }, 133 complete: function() { 134 $submit_btn.button('reset'); 135 $('html, body').animate({ 136 scrollTop: $feedback.offset().top - 20 137 }, 600); 138 } 139 }); 140 } else { 141 $feedback.html('<div class="alert alert-danger">Please fill in required fields.</div>').fadeIn("fast", function(){ 142 $submit_btn.button('reset'); 143 errors[0].focus(); 144 $('html, body').animate({ 145 scrollTop: $feedback.offset().top - 20 146 }, 600); 147 }); 148 return false; 149 } 150 }); 151 } 152 }); 153 } 154});
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.