1;(function ($) { 2 $(document).ready(function () { 3 /*------------------------------ Form Submission ---------*/ 4 5 // Create Random Number For Captcha. 6 7 function randomNum(maxNum) { 8 return Math.floor(Math.random() * maxNum + 1) //return a number between 1 - 10 9 } 10 11 // Convert Hex Color to RGBA. 12 13 function baf_hex_to_rgba(hex, opacity) { 14 var c 15 if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)) { 16 c = hex.substring(1).split("") 17 if (c.length == 3) { 18 c = [c[0], c[0], c[1], c[1], c[2], c[2]] 19 } 20 c = "0x" + c.join("") 21 return "rgba(" + [(c >> 16) & 255, (c >> 8) & 255, c & 255].join(",") + "," + opacity + ")" 22 } else { 23 return 'rgba("0,0,0,' + opacity + '")' 24 } 25 } 26 27 // Custom scripts to generate dynamic css. 28 29 function generate_baf_custom_style() { 30 if ($(".baf_custom_style").length > 0) { 31 var baf_custom_style_string = "" 32 33 $(".baf_custom_style").each(function () { 34 var container_id = $(this).attr("container_id"), 35 $section_faq_unique_class = ".section_baf_" + container_id, 36 first_color = $(this).data("first_color"), 37 second_color = $(this).data("second_color"), 38 label_text_color = $(this).data("label_text_color"), 39 accordion_arrow = $(this).data("accordion_arrow") 40 41 baf_custom_style_string += $section_faq_unique_class + "{clear:both;}" 42 baf_custom_style_string += $section_faq_unique_class + " label{ background: linear-gradient( " + baf_hex_to_rgba(first_color, 1) + ", " + baf_hex_to_rgba(second_color, 1) + ") !important; color: " + label_text_color + " !important;}" 43 baf_custom_style_string += $section_faq_unique_class + " label.opened-label{ background: linear-gradient( " + baf_hex_to_rgba(first_color, 1) + ", " + baf_hex_to_rgba(first_color, 1) + ") !important;}" 44 baf_custom_style_string += $section_faq_unique_class + ' label.opened-label:after{ font-family: "FontAwesome"; content: "' + "\\" + accordion_arrow + '" !important; color: ' + label_text_color + " !important;}" 45 baf_custom_style_string += $section_faq_unique_class + ' label.closed-label:after{ font-family: "FontAwesome"; content: "' + "\\" + accordion_arrow + '" !important; color: ' + label_text_color + " !important;}" 46 baf_custom_style_string += $section_faq_unique_class + " .baf-expand-all { background: " + first_color + " !important; color: " + label_text_color + " !important;}" 47 baf_custom_style_string += $section_faq_unique_class + " .baf-expand-all:hover { background: " + second_color + " !important; color: " + label_text_color + " !important;}" 48 baf_custom_style_string += $section_faq_unique_class + " .baf-collapsible-all{ background: " + first_color + " !important; color: " + label_text_color + " !important;}" 49 baf_custom_style_string += $section_faq_unique_class + " .baf-collapsible-all:hover{ background: " + second_color + " !important; color: " + label_text_color + " !important;}" 50 baf_custom_style_string += $section_faq_unique_class + " .active_page{ background: " + first_color + " !important;}" 51 52 // Custom Theme. 53 baf_custom_style_string += $section_faq_unique_class + ".baf_layout_semi_round .bwl-faq-container{ background: linear-gradient( " + baf_hex_to_rgba(first_color, 1) + ", " + baf_hex_to_rgba(second_color, 1) + ") !important;}" 54 baf_custom_style_string += $section_faq_unique_class + ".baf_layout_round .bwl-faq-container{ background: linear-gradient( " + baf_hex_to_rgba(first_color, 1) + ", " + baf_hex_to_rgba(second_color, 1) + ") !important;}" 55 }) 56 57 $("<style data-type='baf_custom_style-custom-css'>" + baf_custom_style_string + "</style>").appendTo("head") 58 } 59 } 60 61 /*@ Start Collapsable Accordion 62 * @Since 1.4.4 63 */ 64 65 var accordion_container = $(".ac-container"), 66 accordion_single_faq_post_container = $(".single-faq-post") 67 68 /* 69 * @ Force all the checkbox inside accordion hidden. 70 * @Since- 1.4.4 71 */ 72 73 accordion_container.find("input[type=checkbox]").css({ 74 display: "none", // block (Keep it none) 75 }) 76 77 if (typeof bwl_advanced_faq_collapsible_accordion_status != "undefined" && bwl_advanced_faq_collapsible_accordion_status == 2) { 78 /* 79 * Show All FAQs Opened 80 * @Since 1.4.4 81 */ 82 83 accordion_container.find("article").removeAttr("style").addClass("baf-show-article baf-article-padding article-box-shadow") 84 85 accordion_container.find("input[type=checkbox]").prop("checked", true) 86 87 accordion_container.find("label").addClass("opened-label") 88 89 accordion_container.find("label").on("click", function () { 90 var label_id = $(this).attr("label_id"), 91 parent_container_id = $(this).attr("parent_container_id") 92 93 // Modify Accordion Container. 94 95 accordion_container = $(".ac-container[container_id=" + parent_container_id + "]") 96 97 /*------------------------------ LABEL SECTION ---------*/ 98 99 var current_faq_label_container = $(this), 100 current_faq_checkbox = current_faq_label_container.next("input[type=checkbox]"), // here we need to keep squence. First Label, then checkbox , then article. It's releated with shortcode output. 101 current_article_faq_container = current_faq_checkbox.next("article") 102 103 /*------------------------------ ARTICLE SECTION------------------------ ---------*/ 104 105 if (current_faq_checkbox.is(":checked")) { 106 current_article_faq_container.removeAttr("style").removeClass("baf-show-article").addClass("baf-hide-article baf-article-padding") 107 current_faq_label_container.removeAttr("class").addClass("closed-label") 108 } else { 109 current_article_faq_container.removeAttr("style").removeClass("baf-hide-article baf-article-padding").addClass("baf-show-article") 110 current_faq_label_container.removeAttr("class").addClass("opened-label") 111 } 112 }) 113 } else { 114 // Regular Collapsable Accordion 115 116 //New Code. 117 accordion_container.find("article").removeAttr("style").addClass("baf-hide-article article-box-shadow") 118 119 // Now we set all checkbox checked. 120 121 accordion_container.find("input[type=checkbox]").prop("checked", true) 122 123 accordion_container.find("label").addClass("closed-label") 124 125 accordion_container.find("label").on("click", function () { 126 var label_id = $(this).attr("label_id"), 127 parent_container_id = $(this).attr("parent_container_id") 128 // Modify Accordion Container. 129 130 accordion_container = $(".ac-container[container_id=" + parent_container_id + "]") 131 132 /*------------------------------ LABEL SECTION ---------*/ 133 134 var current_faq_label_container = $(this), 135 current_faq_checkbox = current_faq_label_container.next("input[type=checkbox]"), // here we need to keep squence. First Label, then checkbox , then article. It's releated with shortcode output. 136 current_article_faq_container = current_faq_checkbox.next("article") 137 138 /*------------------------------ ARTICLE SECTION------------------------ ---------*/ 139 140 if (current_faq_checkbox.is(":checked")) { 141 //New Code. 142 accordion_container.find("article").removeAttr("style").removeClass("baf-show-article baf-article-padding").addClass("baf-hide-article article-box-shadow") 143 144 // Now we set all checkbox checked. 145 146 accordion_container.find("input[type=checkbox]").prop("checked", true) // 147 accordion_container.find("label").removeAttr("class").addClass("closed-label") 148 149 // Checked 150 current_faq_checkbox.prop("checked", true) // Uncheck it 151 current_article_faq_container.removeAttr("style").removeClass("baf-hide-article").addClass("baf-show-article baf-article-padding") 152 current_faq_label_container.removeAttr("class").addClass("opened-label") 153 } else { 154 // For Unchecked. 155 current_faq_label_container.parent().find("input[type=checkbox]").prop("checked", false) // Uncheck it 156 current_faq_label_container.parent().find("article").removeAttr("style").removeClass("baf-show-article baf-article-padding").addClass("baf-hide-article article-box-shadow") 157 current_faq_label_container.parent().find("label").removeAttr("class").addClass("closed-label") 158 } 159 }) 160 } 161 162 // Display Specific Row Opened. 163 164 if ($(".baf_row_open").length) { 165 $(".baf_row_open").each(function () { 166 var $this = $(this), 167 $baf_row_open = $this.data("row_open") - parseInt(1),
168 $bwl_faq_container = $this.find("div.bwl-faq-container:eq(" + $baf_row_open + ")") 169 170 if ($bwl_faq_container.length) { 171 $bwl_faq_container.find("label").trigger("click") 172 } 173 }) 174 } 175 176 /* 177 * Introduced: Version - 1.4.9 178 * Create Date: 04-04-2014 179 * Last Update: 04-04-2014 180 */ 181 182 if (accordion_single_faq_post_container.length > 0) { 183 if ($(".baf-single-collapse").length == 0) { 184 accordion_single_faq_post_container.find("label").trigger("click") 185 } 186 } 187 188 // Custom FAQ Category Tab. 189 190 function switch_tabs(obj) { 191 obj.parent().parent().find(".bwl-faq-tab-content").slideUp("fast") 192 193 obj.parent().find("li").removeClass("active") 194 195 var id = obj.find("a", 0).attr("rel") 196 197 $("#" + id).slideDown("slow") 198 199 obj.addClass("active") 200 } 201 202 if ($(".bwl-faq-tabs").length) { 203 $(".bwl-faq-tabs li").on("click", function () { 204 if ($(this).find(".bwl-faq-link").attr("class") != "bwl-faq-link") { 205 switch_tabs($(this)) 206 } 207 }) 208 } 209 210 /*----- FAQ LIST SEARCH ----*/ 211 212 if ($(".baf_filter_list").length) { 213 $(".baf_filter_list").each(function () { 214 var $this = $(this), 215 $filter_form = $this.closest("form"), 216 $faq_container_id = $("#" + $this.attr("id")) 217 $faq_container_id.bwlFaqFilter({ 218 unique_id: $filter_form.data("unique_id"), 219 paginate: $filter_form.data("paginate"), 220 pag_limit: $filter_form.data("pag_limit"), 221 search_only_title: $filter_form.data("search_only_title"), 222 }) 223 }) 224 } 225 226 /*-- Rating --*/ 227 228 $(document).on("click", ".post-like-container a", function () { 229 var $icon_container = jQuery(this) 230 231 var $thumb_icon_class = $icon_container.find("i") 232 var $info_icon = $icon_container.data("info_icon") 233 var $loading_msg = $icon_container.data("loading_msg") 234 235 if ($thumb_icon_class.attr("class") === $info_icon) { 236 return false 237 } 238 239 $thumb_icon_class.attr("class", $info_icon) 240 241 $icon_container.siblings(".count").text($loading_msg) 242 243 // Retrieve post ID from data attribute 244 var $post_id = $icon_container.data("post_id") 245 246 $.ajax({ 247 url: ajaxurl, 248 type: "POST", 249 dataType: "JSON", 250 data: { 251 action: "bwl_advanced_faq_apply_rating", // action will be the function name 252 post_like: true, 253 post_id: $post_id, 254 }, 255 success: function (data) { 256 // If vote successful 257 if (data.status == 0) { 258 $icon_container.addClass("voted") 259 $icon_container.siblings(".count").text("").append(data.msg) 260 } 261 if (data.status == 1) { 262 $icon_container.addClass("voted") 263 $icon_container.siblings(".count").text("").append(data.msg) 264 } 265 }, 266 error: function (xhr, textStatus, e) { 267 console.log("There was an error saving the update.") 268 return 269 }, 270 }) 271 272 return false 273 }) 274 /*-- FAQ Submission --*/ 275 276 $(".bwl_advanced_faq_form").each(function () { 277 // Since: version 1.6.6 278 // Check Pre selection status. 279 280 var $this = $(this), 281 reset_cat_field = 1 282 283 if ($this.is("[data-sel_cat]")) { 284 reset_cat_field = 0 285 } 286 287 $this.find("input#title").val("") 288 289 if (reset_cat_field === 1) { 290 $this.find("select#cat").val("-1") 291 } 292 }) 293 294 $(".bwl_advanced_faq_form") 295 .find("input[type=submit]") 296 .on("click", function () { 297 var form_submit_button = $(this), 298 bwl_advanced_faq_form_id = form_submit_button.attr("bwl_advanced_faq_form_id"), 299 form_box_container = $("#" + bwl_advanced_faq_form_id), 300 form_field_container = $("#" + bwl_advanced_faq_form_id + " .bwl_advanced_faq_form"), 301 reset_cat_field = 1 302 303 if (form_field_container.is("[data-sel_cat]")) { 304 reset_cat_field = 0 305 } 306 307 var message_box = form_box_container.find(".bwl-faq-form-message-box"), 308 title = form_field_container.find("#title"), 309 cat = form_field_container.find("#cat"), 310 captcha_status = form_field_container.find("#captcha_status") 311 312 if (captcha_status.val() == 1) { 313 var num1 = form_field_container.find("#num1") 314 var num2 = form_field_container.find("#num2") 315 var captcha = form_field_container.find("#captcha") 316 var all_fields = $([]).add(title).add(cat).add(captcha) 317 } else { 318 var all_fields = $([]).add(title).add(cat) 319 } 320 321 var bValid = true, 322 required_field_msg = "", 323 ok_border = "border: 1px solid #EEEEEE", 324 error_border = "border: 1px solid #E63F37" 325 326 if ($.trim(title.val()).length < title.data("min_length") || $.trim(title.val()).length > title.data("max_length")) { 327 title_bValid = false 328 title.attr("style", error_border) 329 required_field_msg += " " + title.data("error_msg") + "<br />" 330 } else { 331 title_bValid = true 332 title.attr("style", ok_border) 333 required_field_msg += "" 334 } 335 336 bValid = bValid && title_bValid 337 338 if ($.trim(cat.val()) == -1) { 339 cat_bValid = false 340 cat.attr("style", error_border) 341 required_field_msg += " " + err_faq_category + "<br />" 342 } else { 343 cat_bValid = true 344 cat.attr("style", ok_border) 345 required_field_msg += "" 346 } 347
348 bValid = bValid && cat_bValid 349 350 if (captcha_status.val() == 1) { 351 if (parseInt($.trim(num1.val())) + parseInt($.trim(num2.val())) != parseInt($.trim(captcha.val()))) { 352 captcha_bValid = false 353 captcha.attr("style", error_border) 354 required_field_msg += " " + err_faq_captcha 355 } else { 356 captcha_bValid = true 357 captcha.attr("style", ok_border) 358 required_field_msg += "" 359 } 360 361 bValid = bValid && captcha_bValid 362 } 363 364 //Alert Message Box For Required Fields. 365 366 if (bValid == false) { 367 message_box.html("").addClass("bwl-form-error-box").html(required_field_msg).slideDown("slow") 368 } 369 370 if (bValid == true) { 371 all_fields.attr("style", ok_border) 372 all_fields.addClass("bwl_advanced_faq_disabled_field").attr("disabled", "disabled") 373 form_submit_button.addClass("bwl_advanced_faq_disabled_field").attr("disabled", "disabled") 374 message_box.html("").removeClass("bwl-form-error-box").addClass("bwl-form-wait-box").html(string_please_wait).slideDown("slow") 375 376 $.ajax({ 377 url: ajaxurl, 378 type: "POST", 379 dataType: "JSON", 380 data: { 381 action: "bwl_advanced_faq_save_post_data", // action will be the function name, 382 title: title.val(), 383 cat: cat.val(), 384 _baf_form_nonce: form_field_container.find("#_baf_form_nonce").val(), 385 }, 386 success: function (data) { 387 if (data.bwl_faq_add_status == 1) { 388 //Reload For New Number. 389 390 if (captcha_status.val() == 1) { 391 num1.val(randomNum(5)) 392 num2.val(randomNum(9)) 393 } 394 395 message_box.removeClass("bwl-form-wait-box").html("").html(string_ques_added).addClass("bwl-form-success-box").delay(3000).slideUp("slow") 396 all_fields.val("").removeAttr("disabled").removeClass("bwl_advanced_faq_disabled_field") 397 398 if (reset_cat_field === 1) { 399 cat.val("-1") //fixed in version 1.6.2 // Update in version 1.6.6 400 } 401 402 form_submit_button.removeAttr("disabled").removeClass("bwl_advanced_faq_disabled_field") 403 } else { 404 message_box.removeClass("bwl-form-wait-box").html("").html(string_ques_unable_add).addClass("bwl-form-error-box").delay(3000).slideUp("slow") 405 all_fields.removeAttr("disabled").removeClass("bwl_advanced_faq_disabled_field") 406 form_submit_button.removeAttr("disabled").removeClass("bwl_advanced_faq_disabled_field") 407 } 408 }, 409 error: function (xhr, textStatus, e) { 410 message_box.removeClass("bwl-form-wait-box").html("").html(string_ques_unable_add).addClass("bwl-form-error-box").delay(3000).slideUp("slow") 411 all_fields.removeAttr("disabled").removeClass("bwl_advanced_faq_disabled_field") 412 form_submit_button.removeAttr("disabled").removeClass("bwl_advanced_faq_disabled_field") 413 return 414 }, 415 }) 416 } 417 418 return false 419 }) 420 421 // Finally generate Custom CSS. 422 423 generate_baf_custom_style() 424 }) 425})(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.