Current File : /home/itiffy/public_html/blog/wp-content/plugins/wp-invoice/static/scripts/wpi-events.js |
jQuery.noConflict(),jQuery(document).ready(function(){jQuery(".wpi_show_advanced").each(function(){wpi_toggle_advanced_options(this)}),jQuery(".wpi_show_advanced").on("click",function(){wpi_toggle_advanced_options(this)}),jQuery(".wpi_add_row").on("click",function(){wpi_add_row(this)}),jQuery("#currency-list").on("change",".wpi_dynamic_table_row[new_row=true] input.names_changer",function(){var this_row=jQuery(this).parents("tr.wpi_dynamic_table_row"),old_slug=jQuery(this_row).attr("slug"),new_slug=jQuery(this).val();""!=new_slug&&(jQuery(".slug",this_row).val(new_slug),jQuery(this_row).attr("slug",new_slug),jQuery("input,select,textarea",this_row).each(function(element){var old_name=jQuery(this).attr("name");if("undefined"!=typeof old_name){var new_name=old_name.replace(old_slug,new_slug);jQuery(this).attr("name",new_name)}var old_id=jQuery(this).attr("id");if("undefined"!=typeof old_id){var new_id=old_id.replace(old_slug,new_slug);jQuery(this).attr("id",new_id)}}),jQuery("label",this_row).each(function(element){var old_for=jQuery(this).attr("for");if("undefined"!=typeof old_for){var new_for=old_for.replace(old_slug,new_slug);jQuery(this).attr("for",new_for)}}))}),jQuery("#currency-list :input[required]").each(function(){jQuery(this).removeAttr("required").attr("validation_required",!0)}),jQuery("#minor-publishing table.form-table").find("tbody").toggle(),jQuery("#wpi_button_show_advanced").on("click",function(){jQuery(this).parents("#minor-publishing table.form-table").find("tbody").toggle()});jQuery("#first_time_setup_accordion").accordion({heightStyle:"content",header:"h3",animated:!1,autoHeight:!1,icons:{header:"ui-icon-plus",headerSelected:"ui-icon-minus"}}),jQuery(".wp_invoice_accordion").accordion({heightStyle:"content",header:"h3",animated:!1,autoHeight:!1,icons:{header:"ui-icon-plus",headerSelected:"ui-icon-minus"}});wpi_init_payment_method(),jQuery(".ui-state-error").dblclick(function(){jQuery(this).remove()}),jQuery(".wp_invoice_qc_report").dblclick(function(){jQuery(this).remove()}),jQuery("#contextual-help-link-wrap, #screen-options-link-wrap, #screen-functions-link-wrap").show(),tooltip(),jQuery("#wpi_wpi_invoice_deposit_").is(":checked")?wpi_enable_deposit():jQuery("#wpi_wpi_invoice_meta_recurring_active_").is(":checked")?wpi_enable_recurring():jQuery("#wpi_wpi_invoice_quote_").is(":checked")&&(wpi_enable_quote(),wpi_hide_deposit_option(),wpi_hide_recurring_option()),jQuery("#wpi_wpi_invoice_deposit_").on("click",function(event){jQuery(this).is(":checked")?wpi_enable_deposit():wpi_disable_deposit()}),jQuery(".wpi_wpi_invoice_recurring_active_").is(":checked")?wpi_enable_recurring():wpi_disable_recurring(),jQuery(".wpi_wpi_invoice_recurring_active_").on("click",function(event){jQuery(this).is(":checked")?wpi_enable_recurring():(wpi_disable_recurring(),wpi_show_deposit_option(),wpi_show_quote_option())}),jQuery(".wpi_wpi_invoice_recurring_send_invoice_automatically").on("click",function(event){jQuery(this).is(":checked")?wpi_disable_recurring_start_date(jQuery(this).data("type")):wpi_enable_recurring_start_date(jQuery(this).data("type"))}),jQuery(".wpi_wpi_invoice_quote_").click(function(){jQuery(this).is(":checked")?(wpi_disable_recurring(),wpi_disable_deposit(),wpi_hide_deposit_option(),jQuery(".wpi_turn_off_recurring").hide()):(wpi_show_deposit_option(),jQuery(".wpi_turn_off_recurring").show())}),jQuery("#wpi_process_manual_event").on("click",function(event){wpi_process_manual_event()}),jQuery("#postbox_publish #wp_invoice_tax").on("keyup",function(event){jQuery(".line_tax_item").val(jQuery(this).val()),jQuery(".item_charge_tax").val(jQuery(this).val()),wpi_recalc_totals()}),jQuery("#charges_list .fixed_width_holder input").on("keyup",function(){wpi_recalc_totals()}),jQuery("#wpi_tax_method").on("change",function(){wpi_recalc_totals()}),jQuery(".wp_invoice_discount_row").keyup(function(){jQuery.trim(jQuery(".item_name",this).val()).length&&!empty(jQuery(".item_amount",this).val())?(jQuery(".item_name",this).removeClass("wpi_error"),jQuery(".item_amount",this).removeClass("wpi_error")):jQuery.trim(jQuery(".item_name",this).val()).length&&empty(jQuery(".item_amount",this).val())?jQuery(".item_amount",this).addClass("wpi_error"):!jQuery.trim(jQuery(".item_name",this).val()).length&&empty(jQuery(".item_amount",this).val())?(jQuery(".item_name",this).removeClass("wpi_error"),jQuery(".item_amount",this).removeClass("wpi_error")):jQuery.trim(jQuery(".item_name",this).val()).length||empty(jQuery(".item_amount",this).val())||jQuery(".item_name",this).addClass("wpi_error")}),jQuery("#wpi_invoice_form, #wpi_predefined_services_div").change(jQuery.delegate({".item_type select":function(){wpi_recalc_totals()}})),jQuery(document).on("blur",".item_name, .item_quantity, .item_price, .item_price input, .item_amount, .line_tax_item, .item_charge_tax",function(){wpi_recalc_totals();var name=jQuery(this).parents(".wp_invoice_itemized_list_row").find(".item_name"),price=jQuery(this).parents(".wp_invoice_itemized_list_row").find(".item_price"),quantity=jQuery(this).parents(".wp_invoice_itemized_list_row").find(".item_quantity");jQuery.trim(name.val()).length||empty(price.val())||empty(quantity.val())?name.removeClass("wpi_error"):name.addClass("wpi_error")}),jQuery("#wpi_invoice_form, #wpi_predefined_services_div").keyup(jQuery.delegate({".line_tax_item, .item_charge_tax":function(){jQuery("#wp_invoice_tax").val("")}})),jQuery("#wpi_change_notification").change(function(){wpi_load_email_notification()}),jQuery("#wpi_send_notification").on("click",function(event){event.preventDefault(),wpi_send_notification()}),jQuery(".wpi_add_description_text .content").on("click",function(event){console.log(this),jQuery(this).parents(".wp_invoice_itemized_list_row").find(".item_description").toggle()}),jQuery("#wpi_predefined_services_select").click(function(){add_itemized_list_row("invoice_list")}),jQuery("#wpi_add_discount").click(function(){jQuery(".wp_invoice_discount_row:visible").size()>0||add_itemized_list_row_discount()}),jQuery("#wpi_predefined_services").change(function(){wpi_insert_predefined_service()}),jQuery("#wp_invoice_payment_method").on("change",function(event){jQuery(".wpi_client_change_payment_method").is(":not(:checked)")&&wpi_disable_all_payment_methods(),wpi_select_payment_method(jQuery("option:selected",this).val(),!0),wpi_can_client_change_payment_method()}),jQuery(".wpi_client_change_payment_method").on("click",function(event){wpi_can_client_change_payment_method()}),jQuery(".wpi_billing_section_show").on("click",function(event){wpi_select_payment_method(jQuery(this).attr("id"))}),jQuery("#wpi_invoice_form").on("submit",function(event){return wpi_validate_invoice()?(setTimeout(wpi_save_invoice,100),!1):!1}),jQuery("#invoice_list").on("click",".wp_invoice_itemized_list_row .row_delete",function(event){jQuery(".wp_invoice_itemized_list_row").size()>1?jQuery(this).parents(".wp_invoice_itemized_list_row").remove():jQuery("#invoice_list .wp_invoice_itemized_list_row .input_field").val(""),wpi_recalc_totals()}),jQuery("#charges_list").on("click",".wp_invoice_itemized_charge_row .row_delete",function(event){jQuery(this).parents(".wp_invoice_itemized_charge_row").remove(),wpi_recalc_totals()}),jQuery(document).on("click",".wpi_dynamic_table_row .row_delete",function(event){var table=jQuery(this).parents(".ud_ui_dynamic_table"),current_row=jQuery(this).parents(".wpi_dynamic_table_row");jQuery(".wpi_dynamic_table_row",table).size()>1?current_row.remove():jQuery("input, textarea",current_row).val(""),"itemized_list"==table.attr("id")&&wpi_recalc_totals()}),jQuery(".wp_invoice_discount_row .row_delete").on("click",function(event){jQuery(".wp_invoice_discount_row").size()>1?jQuery(this).parents(".wp_invoice_discount_row").remove():jQuery(this).parents(".wp_invoice_discount_row").hide(),jQuery(".wp_invoice_discount_row:hidden input").val(""),wpi_recalc_totals()}),jQuery("#wpi_screen_meta .non-metabox-option").click(function(){var action=jQuery(this).is(":checked")?!0:!1;jQuery.cookie("wpi_display_"+jQuery(this).attr("name"),action)}),jQuery("#wpi_screen_meta #wpi-show-settings-link").click(function(){return jQuery("#screen-options-wrap").hasClass("screen-options-open")||(jQuery("#contextual-help-link-wrap").css("visibility","hidden"),jQuery("#screen-functions-link-wrap").css("visibility","hidden")),jQuery("#screen-options-wrap").slideToggle("fast",function(){jQuery(this).hasClass("screen-options-open")?(jQuery("#wpi-show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'}),jQuery("#contextual-help-link-wrap").css("visibility",""),jQuery("#screen-functions-link-wrap").css("visibility",""),jQuery(this).removeClass("screen-options-open")):(jQuery("#wpi-show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'}),jQuery(this).addClass("screen-options-open"))}),!1}),jQuery("#wpi_screen_meta #wpi-contextual-help-link").click(function(){return jQuery("#contextual-help-wrap").hasClass("contextual-help-open")||(jQuery("#screen-options-link-wrap").css("visibility","hidden"),jQuery("#screen-functions-link-wrap").css("visibility","hidden")),jQuery("#contextual-help-wrap").slideToggle("fast",function(){jQuery(this).hasClass("contextual-help-open")?(jQuery("#wpi-contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'}),jQuery("#screen-options-link-wrap").css("visibility",""),jQuery("#screen-functions-link-wrap").css("visibility",""),jQuery(this).removeClass("contextual-help-open")):(jQuery("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'}),jQuery(this).addClass("contextual-help-open"))}),!1}),jQuery("#wpi_screen_meta #wpi-show-functions-link").click(function(){return jQuery("#screen-functions-wrap").hasClass("screen-functions-open")||(jQuery("#contextual-help-link-wrap").css("visibility","hidden"),jQuery("#screen-options-link-wrap").css("visibility","hidden")),jQuery("#screen-functions-wrap").slideToggle("fast",function(){jQuery(this).hasClass("screen-functions-open")?(jQuery("#wpi-show-functions-link").css({backgroundImage:'url("images/screen-options-right.gif")'}),jQuery("#contextual-help-link-wrap").css("visibility",""),jQuery("#screen-options-link-wrap").css("visibility",""),jQuery(this).removeClass("screen-functions-open")):(jQuery("#wpi-show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'}),jQuery(this).addClass("screen-functions-open"))}),!1}),jQuery("#wpi_new_invoice_form").submit(function(){return wpi_validate_email(jQuery("#wp_invoice_userlookup").val())?(wpi_remove_errors(),!0):(wpi_show_error("Please enter a valid email address."),!1)}),jQuery("#wp_invoice_copy_invoice").click(function(){jQuery(".wp_invoice_copy_invoice").toggle(),jQuery("#wp_invoice_create_new_invoice").toggle(),jQuery("#wp_invoice_copy_invoice").toggle()}),jQuery("#wp_invoice_copy_invoice_cancel").click(function(){jQuery(".wp_invoice_copy_invoice").toggle(),jQuery("#wp_invoice_create_new_invoice").toggle(),jQuery("#wp_invoice_copy_invoice").toggle()}),jQuery("#wpi_new_invoice_form").submit(function(){return""==jQuery("#wp_invoice_userlookup").val()?!1:void 0}),jQuery(".wpi_wpi_settings_use_custom_templates_").on("click",function(event){jQuery(this).is(":checked")?jQuery(".wpi_use_custom_template_settings").show():jQuery(".wpi_use_custom_template_settings").hide()}),jQuery("input.wpi_install_custom_templates").on("click",function(){var answer=confirm("This will overwrite any theme files you currently have in your /wpi/ folder.");answer&&jQuery.post(ajaxurl,{action:"wpi_install_custom_templates"},function(response){jQuery(".wpi_install_custom_templates_result").html(response.join()).show()},"json")}),jQuery(".wpi_settings_client_change_payment_method").on("change",function(event){wpi_can_client_change_payment_method()});jQuery("#currency-list").accordion({header:"h3",animated:!1,autoHeight:!1,collapsible:!0,icons:{header:"ui-icon-plus",headerSelected:"ui-icon-minus"},active:!1});jQuery("#wpi_settings_form").submit(function(){var validation_ok=!0;return jQuery(".wpi_dynamic_table_row :input[validation_required=true]").each(function(){jQuery(this).val()||(wpi_show_error("This is a required field."),error_field=this,validation_ok=!1)}),jQuery(".wpi_dynamic_table_row[new_row=true] .code").each(function(){jQuery(this).val().match("[A-Z]{3}")||(wpi_show_error("Please enter a valid currency code."),error_field=this,validation_ok=!1)}),jQuery("input[name='wpi_settings[globals][favorite_countries]']").val(jQuery("#wpi_favorite_countries option").attrList("value",",")),validation_ok?void 0:(jQuery("#wp_invoice_settings_page").tabs("select",2),jQuery("#currency-list").accordion("option","active")===!1&&jQuery("#currency-list").accordion("option","active",0),jQuery(error_field).focus(),!1)}),jQuery("#delete_all_wp_invoice_databases").click(function(){var txt="Are you sure you want to delete all the databases? All your invoice and log data will be lost forever. ";return jQuery.prompt(txt,{buttons:{Delete:!0,Cancel:!1},callback:function(v,m){v&&(document.location="admin.php?page=new_invoice&wp_invoice_action=complete_removal")}}),!1});var tog=!1;jQuery("#invoice_sorter_table #CheckAll").click(function(){jQuery("#invoice_sorter_table input[type=checkbox]").attr("checked",!tog),tog=!tog}),jQuery("#invoice_sorter_table tr:has(td)").each(function(){var t=jQuery(this).text().toLowerCase();jQuery("<td class='indexColumn'></td>").hide().text(t).appendTo(this)}),jQuery(".invoice-search-input").keyup(function(){var s=jQuery(this).val().toLowerCase().split(" ");jQuery("#invoice_sorter_table tr:hidden").show(),jQuery.each(s,function(){jQuery("#invoice_sorter_table tr:visible .indexColumn:not(:contains('"+this+"'))").parent().hide()})}),jQuery("#wpi_filter_overview_by_recipient").change(function(){var target_url=jQuery("#wpi_target_url").val();window.location=target_url+"&recipient_filter="+jQuery(this).val()}),jQuery("#wp_invoice_show_archived").click(function(){return jQuery(".wp_invoice_archived").toggle(),wp_invoice_calculate_owed(),!1}),jQuery("#submit_bulk_action").click(function(){if("Delete"==jQuery("#wp_invoice_action :selected").text()){var r=confirm("Are you sure you want to delete the selected invoice(s)?");return 1==r?!0:!1}}),jQuery("#invoices-filter").submit(function(){return"-1"==jQuery("#invoices-filter select").val()?!1:void 0});var curDate=new Date,m=curDate.getMonth()+1;jQuery(".wpi_event_date").val((10>m?"0"+m:m)+"/"+(curDate.getDate()<10?"0"+curDate.getDate():curDate.getDate())+"/"+curDate.getFullYear()).datepicker();var h=curDate.getHours()<10?"0"+curDate.getHours():curDate.getHours(),minutes=curDate.getMinutes()<10?"0"+curDate.getMinutes():curDate.getMinutes();jQuery(".wpi_event_time").val(h+":"+minutes),jQuery("#edit-slug-box.wpi-edit-slug-box").click(function(){jQuery(this).css({height:function(){return 18==jQuery(this).height()?"auto":18}})}),jQuery("#wpi_event_type").change(function(){"add_charge"==jQuery(this).val()?jQuery("#event_tax_holder").show():jQuery("#event_tax_holder").hide()}),jQuery("#wp-list-table").on("click","a.submitdelete.permanently",function(){return confirm("Remove this invoice permanently?")}),jQuery("#doaction").on("click",function(){var action=jQuery("select[name=action]").val();if("delete"==action){var answer=confirm("Remove selected invoices permanently?");return answer?!0:!1}return!0}),jQuery("#wp-list-table th a").on("click",function(){return!1}),jQuery("input.check-all","#wp-list-table").click(function(e){e.target.checked?jQuery("#the-list td.cb input:checkbox").attr("checked","checked"):jQuery("#the-list td.cb input:checkbox").removeAttr("checked")}),jQuery("#wpi_wpi_settings_ga_event_tracking_enabled_").click(function(e){jQuery(this).parents("ul").find("li.wpi_ga_events_list").toggle()}),jQuery(document).bind("wpi_enable_recurring",function(){jQuery("#wpi_wpi_invoice_client_change_payment_method_").is(":checked")&&jQuery("#wpi_wpi_invoice_client_change_payment_method_").click(),jQuery("#wpi_wpi_invoice_client_change_payment_method_").parent().hide()}),jQuery(document).bind("wpi_disable_recurring",function(){jQuery("#wpi_wpi_invoice_client_change_payment_method_").parent().show()}),jQuery.fn.business_logo_select=function(options){var file_frame,settings=jQuery.extend({url_input:".url_input",image:".image_input",disable:".disable_button"},options),that=this;jQuery(settings.disable).on("click",function(e){return jQuery(settings.url_input).val(""),jQuery(settings.image).hide(),jQuery(e.target).hide(),!1}),this.on("click",function(event){return event.preventDefault(),file_frame?void file_frame.open():(file_frame=wp.media.frames.file_frame=wp.media({title:that.data("uploader_title"),button:{text:that.data("uploader_button_text")},multiple:!1}),file_frame.on("select",function(){jQuery(settings.url_input).val(file_frame.state().get("selection").first().toJSON().url),jQuery(settings.image).show().attr("src",file_frame.state().get("selection").first().toJSON().url)}),void file_frame.open())})}});