gutenberg
3 years ago
gutenbergComponents
3 years ago
autoupdate_banner.js
3 years ago
banner_main.js
3 years ago
circle-progress.js
3 years ago
datatables.min.js
4 years ago
jquery.multi-select.js
4 years ago
jquery.tagsinput.min.js
4 years ago
referral_program.js
3 years ago
sidebar-plugin.js
3 years ago
speed.js
3 years ago
two_admin.js
1 year ago
two_admin_bar.js
4 years ago
two_bf_countdown.js
3 years ago
two_deactivate_plugin.js
3 years ago
two_elementor_editor.js
2 years ago
two_preview.js
3 years ago
two_update_white_label.js
1 year ago
two_white_label.js
2 years ago
two_admin_bar.js
193 lines
| 1 | jQuery("document").ready(function () { |
| 2 | var sheets = document.styleSheets; |
| 3 | var two_styles_list = ""; |
| 4 | var exclude_css = ["dashicons-css", "admin-bar-css", "two_admin_bar_css-css"]; |
| 5 | var two_async_css = JSON.parse(two_admin_vars.two_async_css); |
| 6 | var two_disable_css = JSON.parse(two_admin_vars.two_disable_css); |
| 7 | var two_disable_page_css = JSON.parse(two_admin_vars.two_disable_css_page); |
| 8 | var two_async_page_css = JSON.parse(two_admin_vars.two_async_css_page); |
| 9 | var two_async_all = two_admin_vars.two_async_all; |
| 10 | //var two_exclude_css = two_admin_vars.two_exclude_css; |
| 11 | |
| 12 | |
| 13 | var two_disabled_option = ""; |
| 14 | if(two_async_all === "on"){ |
| 15 | two_disabled_option = "two_disabled_option"; |
| 16 | } |
| 17 | |
| 18 | jQuery('body').on('click', ".two_el_id", function () { |
| 19 | var two_css_options_list = jQuery(this).closest("li").find(".two_css_options_list"); |
| 20 | if(two_css_options_list.hasClass("two_hidden")){ |
| 21 | two_css_options_list.removeClass("two_hidden"); |
| 22 | jQuery(this).addClass("two_down_arrow"); |
| 23 | }else { |
| 24 | two_css_options_list.addClass("two_hidden"); |
| 25 | jQuery(this).removeClass("two_down_arrow"); |
| 26 | } |
| 27 | }); |
| 28 | |
| 29 | jQuery.each(sheets, function (index, value) { |
| 30 | var uid = two_uid(); |
| 31 | var two_async_check = ""; |
| 32 | var two_async_page_check = ""; |
| 33 | var two_disabled_check = ""; |
| 34 | var two_disabled_page_check = ""; |
| 35 | var two_disabled_class = "class='two_disable'"; |
| 36 | var two_disabled_page_class = "class='two_disable_page'"; |
| 37 | var two_async_page_class = "class='two_async_page'"; |
| 38 | var two_async_class = "class='two_async'"; |
| 39 | var two_exclude_class = "class='two_exclude'"; |
| 40 | var el_flag = ""; |
| 41 | var el_id = ""; |
| 42 | var el_href = ""; |
| 43 | if(value.href !== null && value.href !=="" && typeof value.href !== "undefined") { |
| 44 | el_href = value.href; |
| 45 | el_id = stringToHash(value.href); |
| 46 | jQuery(this).attr('id', el_id); |
| 47 | el_flag = value.href; |
| 48 | if (value.ownerNode.id !== null && value.ownerNode.id !== "" && typeof value.ownerNode.id!=="undefined") { |
| 49 | el_flag = value.ownerNode.id; |
| 50 | } |
| 51 | if (two_async_css.includes(el_flag)) { |
| 52 | two_async_check = "checked"; |
| 53 | two_async_class = "class='two_async two_checked'"; |
| 54 | } |
| 55 | if (two_disable_css.includes(el_flag)) { |
| 56 | two_disabled_check = "checked"; |
| 57 | two_disabled_class = "class='two_disable two_checked'"; |
| 58 | } |
| 59 | if (two_disable_page_css.includes(el_flag)) { |
| 60 | two_disabled_page_check = "checked"; |
| 61 | two_disabled_page_class = "class='two_disable_page two_checked'"; |
| 62 | } |
| 63 | if (two_async_page_css.includes(el_flag)) { |
| 64 | two_async_page_check = "checked"; |
| 65 | two_async_page_class = "class='two_async_page two_checked'"; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | |
| 70 | |
| 71 | var two_style_options = "<div class='two_css_options_list two_hidden'>" + |
| 72 | "<div class='two_option_group "+two_disabled_option+"'>" + |
| 73 | "<label class='two_option_container'>Add to async for all pages" + |
| 74 | "<input "+two_async_check+" name='"+uid+"' data-two_action='two_async' "+two_async_class+" type='radio'>" + |
| 75 | "<span class='wxao_checkmark'></span>" + |
| 76 | "</label>" + |
| 77 | "</div>"+ |
| 78 | |
| 79 | "<div class='two_option_group "+two_disabled_option+"'>" + |
| 80 | "<label class='two_option_container'>Add to async for this page" + |
| 81 | "<input "+two_async_page_check+" name='"+uid+"' data-two_action='two_async_page' "+two_async_page_class+" type='radio'>" + |
| 82 | "<span class='wxao_checkmark'></span>" + |
| 83 | "</label>" + |
| 84 | "</div>" + |
| 85 | "<div class='two_option_group'>" + |
| 86 | "<label class='two_option_container'>Disable for all pages" + |
| 87 | "<input "+two_disabled_check+" name='"+uid+"' data-two_action='two_disable' "+two_disabled_class+" type='radio'>" + |
| 88 | "<span class='wxao_checkmark'></span>" + |
| 89 | "</label>"+ |
| 90 | "</div>" + |
| 91 | "<div class='two_option_group'>" + |
| 92 | "<label class='two_option_container'>Disable for this page" + |
| 93 | "<input "+two_disabled_page_check+" name='"+uid+"' data-two_action='two_disable_page' "+two_disabled_page_class+" type='radio'>" + |
| 94 | "<span class='wxao_checkmark'></span>" + |
| 95 | "</label>" + |
| 96 | "</div>"; |
| 97 | |
| 98 | var flag = exclude_css.includes(el_flag); |
| 99 | if(!flag && el_flag !== null && el_flag!== ""){ |
| 100 | two_styles_list+="<li class='two_options_section' title='"+el_flag+"' data-el_href='"+el_href+"' data-el_data_id='"+el_flag+"' data-el_id='"+el_id+"'><span class='two_el_id'><span>"+el_flag+"</span></span>"+two_style_options+"</li>"; |
| 101 | } |
| 102 | }); |
| 103 | jQuery("#wp-admin-bar-two_options").append( |
| 104 | '<div id="two_styles_list"><ul>'+two_styles_list+'</ul></div>' |
| 105 | ); |
| 106 | jQuery(".two_checked").each(function () { |
| 107 | if(jQuery(this).data("two_action") === "two_disable_page" || jQuery(this).data("two_action") === "two_disable"){ |
| 108 | var el_id = jQuery(this).closest("li").data("el_id"); |
| 109 | jQuery("#"+el_id).attr("rel" , "preload"); |
| 110 | } |
| 111 | }); |
| 112 | |
| 113 | |
| 114 | jQuery('body').on('click', '.two_css_options_list input', function (){ |
| 115 | var two_action = jQuery(this).data("two_action"); |
| 116 | var el_id = jQuery(this).closest("li").data("el_id"); |
| 117 | var el_data_id = jQuery(this).closest("li").data("el_data_id"); |
| 118 | var el_href = jQuery(this).closest("li").data("el_href"); |
| 119 | var css_el = jQuery('link[href^="'+el_href+'"]'); |
| 120 | if(jQuery(this).hasClass("two_checked")){ |
| 121 | jQuery(this).removeClass("two_checked"); |
| 122 | jQuery(this).closest(".two_options_section").removeClass("two_check_section"); |
| 123 | jQuery(this).prop( "checked", false ); |
| 124 | //jQuery("#"+el_id).attr("rel" , "stylesheet"); |
| 125 | css_el.attr("rel" , "stylesheet"); |
| 126 | two_ajax_save(el_data_id , 0, two_action); |
| 127 | return; |
| 128 | } |
| 129 | if(jQuery(this).is(":checked")) { |
| 130 | jQuery(this).closest(".two_css_options_list").find("input").removeClass("two_checked"); |
| 131 | jQuery(this).addClass("two_checked"); |
| 132 | jQuery(this).closest(".two_options_section").addClass("two_check_section"); |
| 133 | |
| 134 | if(two_action === "two_disable" || two_action === "two_disable_page"){ |
| 135 | css_el.attr("rel" , "preload"); |
| 136 | }else{ |
| 137 | css_el.attr("rel" , "stylesheet"); |
| 138 | } |
| 139 | two_ajax_save(el_data_id , 1, two_action); |
| 140 | } |
| 141 | }); |
| 142 | jQuery(".two_checked").closest(".two_options_section").addClass("two_check_section"); |
| 143 | }); |
| 144 | |
| 145 | function two_ajax_save(el_id, state,task) { |
| 146 | var page_url = window.location.href; |
| 147 | var two_async_data = ""; |
| 148 | var two_disable_data = ""; |
| 149 | var two_async_page = jQuery(".two_async_page"); |
| 150 | var two_disable_page = jQuery(".two_disable_page"); |
| 151 | two_async_page.each(function () { |
| 152 | if(jQuery(this).is(":checked")) { |
| 153 | two_async_data+=jQuery(this).closest("li").data("el_data_id")+","; |
| 154 | } |
| 155 | }); |
| 156 | two_disable_page.each(function () { |
| 157 | if(jQuery(this).is(":checked")) { |
| 158 | two_disable_data+=jQuery(this).closest("li").data("el_data_id")+","; |
| 159 | } |
| 160 | }); |
| 161 | |
| 162 | jQuery.ajax({ |
| 163 | type: "POST", |
| 164 | url: two_admin_vars.ajaxurl, |
| 165 | dataType: 'json', |
| 166 | data: { |
| 167 | action: "two_css_options", |
| 168 | task:task, |
| 169 | el_id:el_id, |
| 170 | state:state, |
| 171 | two_async_page:two_async_data, |
| 172 | two_disable_page:two_disable_data, |
| 173 | page_url:page_url, |
| 174 | nonce: two_admin_vars.ajaxnonce, |
| 175 | } |
| 176 | }).done(function (data) { |
| 177 | |
| 178 | }); |
| 179 | } |
| 180 | |
| 181 | function two_uid() { |
| 182 | return 'two_' + Math.random().toString(36).substr(2, 9); |
| 183 | } |
| 184 | function stringToHash(string) { |
| 185 | var hash = 0; |
| 186 | if (string.length == 0) return hash; |
| 187 | for (i = 0; i < string.length; i++) { |
| 188 | char = string.charCodeAt(i); |
| 189 | hash = ((hash << 5) - hash) + char; |
| 190 | hash = hash & hash; |
| 191 | } |
| 192 | return "two"+hash; |
| 193 | } |