관리-도구
편집 파일: api-keys.min.js
!function(c){new(Backbone.View.extend({el:c("#key-fields"),events:{"click input#update_api_key":"saveKey"},initialize:function(){_.bindAll(this,"saveKey")},block:function(){c(this.el).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){c(this.el).unblock()},initTipTip:function(i){c(document.body).on("click",i,function(e){e.preventDefault(),document.queryCommandSupported("copy")?(c("#copy-error").text(""),wcClearClipboard(),wcSetClipboard(c.trim(c(this).prev("input").val()),c(i))):(c(i).parent().find("input").focus().select(),c("#copy-error").text(kkart_admin_api_keys.clipboard_failed))}).on("aftercopy",i,function(){c("#copy-error").text(""),c(i).tipTip({attribute:"data-tip",activation:"focus",fadeIn:50,fadeOut:50,delay:0}).focus()}).on("aftercopyerror",i,function(){c(i).parent().find("input").focus().select(),c("#copy-error").text(kkart_admin_api_keys.clipboard_failed)})},createQRCode:function(e,i){c("#keys-qrcode").qrcode({text:e+"|"+i,width:120,height:120})},saveKey:function(e){e.preventDefault();var t=this;t.block(),Backbone.ajax({method:"POST",dataType:"json",url:kkart_admin_api_keys.ajax_url,data:{action:"kkart_update_api_key",security:kkart_admin_api_keys.update_api_nonce,key_id:c("#key_id",t.el).val(),description:c("#key_description",t.el).val(),user:c("#key_user",t.el).val(),permissions:c("#key_permissions",t.el).val()},success:function(e){var i,o;c(".kkart-api-message",t.el).remove(),e.success?(i=e.data,c("h2, h3",t.el).first().append('<div class="kkart-api-message updated"><p>'+i.message+"</p></div>"),0<i.consumer_key.length&&0<i.consumer_secret.length?(c("#api-keys-options",t.el).remove(),c("p.submit",t.el).empty().append(i.revoke_url),o=wp.template("api-keys-template"),c("p.submit",t.el).before(o({consumer_key:i.consumer_key,consumer_secret:i.consumer_secret})),t.createQRCode(i.consumer_key,i.consumer_secret),t.initTipTip(".copy-key"),t.initTipTip(".copy-secret")):(c("#key_description",t.el).val(i.description),c("#key_user",t.el).val(i.user_id),c("#key_permissions",t.el).val(i.permissions))):c("h2, h3",t.el).first().append('<div class="kkart-api-message error"><p>'+e.data.message+"</p></div>"),t.unblock()}})}}))}(jQuery);