cdn
4 years ago
lang
6 years ago
button.js
11 years ago
column.js
6 years ago
db.js
9 years ago
dialog.js
8 years ago
dialog_new.js
4 years ago
index.html
11 years ago
language.js
8 years ago
schedule.js
11 years ago
toolbar.js
5 years ago
toolbar.js
123 lines
| 1 | var WPFC_TOOLBAR = { |
| 2 | ajax_url: false, |
| 3 | init: function(){ |
| 4 | var self = this; |
| 5 | |
| 6 | if(typeof ajaxurl != "undefined" || typeof wpfc_ajaxurl != "undefined"){ |
| 7 | self.ajax_url = (typeof ajaxurl != "undefined") ? ajaxurl : wpfc_ajaxurl; |
| 8 | }else{ |
| 9 | alert("AjaxURL has NOT been defined"); |
| 10 | } |
| 11 | |
| 12 | jQuery("body").append('<div id="revert-loader-toolbar"></div>'); |
| 13 | |
| 14 | jQuery("#wp-admin-bar-wpfc-toolbar-parent-default li").click(function(e){ |
| 15 | var id = (typeof e.target.id != "undefined" && e.target.id) ? e.target.id : jQuery(e.target).parent("li").attr("id"); |
| 16 | var action = ""; |
| 17 | |
| 18 | if(id == "wp-admin-bar-wpfc-toolbar-parent-settings"){ |
| 19 | if(jQuery("div[id^='wpfc-modal-toolbarsettings-']").length === 0){ |
| 20 | self.open_settings(); |
| 21 | } |
| 22 | }else{ |
| 23 | if(id == "wp-admin-bar-wpfc-toolbar-parent-delete-cache"){ |
| 24 | action = "wpfc_delete_cache"; |
| 25 | }else if(id == "wp-admin-bar-wpfc-toolbar-parent-delete-cache-and-minified"){ |
| 26 | action = "wpfc_delete_cache_and_minified"; |
| 27 | }else if(id == "wp-admin-bar-wpfc-toolbar-parent-clear-cache-of-this-page"){ |
| 28 | action = "wpfc_delete_current_page_cache"; |
| 29 | }else if(id == "wp-admin-bar-wpfc-toolbar-parent-clear-cache-of-allsites"){ |
| 30 | action = "wpfc_clear_cache_of_allsites"; |
| 31 | } |
| 32 | |
| 33 | WPFC_TOOLBAR.send({"action": action, "path" : window.location.pathname}); |
| 34 | } |
| 35 | }); |
| 36 | }, |
| 37 | open_settings: function(){ |
| 38 | var self = this; |
| 39 | |
| 40 | jQuery("#revert-loader-toolbar").show(); |
| 41 | jQuery.ajax({ |
| 42 | type: 'GET', |
| 43 | url: self.ajax_url, |
| 44 | data : {"action": "wpfc_toolbar_get_settings", "path" : window.location.pathname}, |
| 45 | dataType : "json", |
| 46 | cache: false, |
| 47 | success: function(data){ |
| 48 | if(data.success){ |
| 49 | var data_json = {"action": "wpfc_toolbar_save_settings", "path" : window.location.pathname, "roles" : {}}; |
| 50 | |
| 51 | Wpfc_New_Dialog.dialog("wpfc-modal-toolbarsettings", { |
| 52 | close: function(){ |
| 53 | Wpfc_New_Dialog.clone.remove(); |
| 54 | }, |
| 55 | finish: function(){ |
| 56 | jQuery("#" + Wpfc_New_Dialog.id).find("input[type='checkbox']:checked").each(function(i, e){ |
| 57 | data_json.roles[jQuery(e).attr("name")] = 1; |
| 58 | }); |
| 59 | |
| 60 | WPFC_TOOLBAR.send(data_json); |
| 61 | |
| 62 | Wpfc_New_Dialog.clone.remove(); |
| 63 | }}, function(dialog){ |
| 64 | jQuery("#" + Wpfc_New_Dialog.id).find("input[type='checkbox']").each(function(i, e){ |
| 65 | if(typeof data.roles[jQuery(e).attr("name")] != "undefined"){ |
| 66 | jQuery(e).attr('checked', true); |
| 67 | } |
| 68 | }); |
| 69 | |
| 70 | Wpfc_New_Dialog.show_button("close"); |
| 71 | Wpfc_New_Dialog.show_button("finish"); |
| 72 | |
| 73 | setTimeout(function(){ |
| 74 | jQuery("#revert-loader-toolbar").hide(); |
| 75 | }, 500); |
| 76 | }); |
| 77 | }else{ |
| 78 | alert("Toolbar Settings Error!") |
| 79 | } |
| 80 | } |
| 81 | }); |
| 82 | }, |
| 83 | send: function(data_json){ |
| 84 | var self = this; |
| 85 | |
| 86 | if(typeof wpfc_nonce != "undefined" && wpfc_nonce){ |
| 87 | data_json.nonce = wpfc_nonce; |
| 88 | } |
| 89 | |
| 90 | jQuery("#revert-loader-toolbar").show(); |
| 91 | jQuery.ajax({ |
| 92 | type: 'GET', |
| 93 | url: self.ajax_url, |
| 94 | data : data_json, |
| 95 | dataType : "json", |
| 96 | cache: false, |
| 97 | success: function(data){ |
| 98 | if(data[1] == "error"){ |
| 99 | if(typeof data[2] != "undefined" && data[2] == "alert"){ |
| 100 | alert(data[0]); |
| 101 | }else{ |
| 102 | Wpfc_New_Dialog.dialog("wpfc-modal-permission", {close: "default"}); |
| 103 | Wpfc_New_Dialog.show_button("close"); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | if(typeof WpFcCacheStatics != "undefined"){ |
| 108 | WpFcCacheStatics.update(); |
| 109 | }else{ |
| 110 | jQuery("#revert-loader-toolbar").hide(); |
| 111 | } |
| 112 | } |
| 113 | }); |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | window.addEventListener('load', function(){ |
| 118 | jQuery(document).ready(function(){ |
| 119 | WPFC_TOOLBAR.init(); |
| 120 | }); |
| 121 | }); |
| 122 | |
| 123 |