[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/assets/js/ -> glossary.min.js (source)

   1  $gp.glossary=function(n){return{current:null,init:function(e){$gp.init(),""!==$gp_glossary_options.can_edit&&($gp.glossary.table=e,$gp.glossary.install_hooks())},install_hooks:function(){n($gp.glossary.table).on("click","a.edit",$gp.glossary.hooks.show).on("dblclick","tr td",$gp.glossary.hooks.show).on("click","button.cancel",$gp.glossary.hooks.hide).on("click","button.delete",$gp.glossary.hooks.del).on("click","button.save",$gp.glossary.hooks.ok)},show:function(e,s){var r;e.preventDefault(),e=(r=s.closest("tr")).data("id"),(s=n("#editor-"+e)).length&&($gp.glossary.current&&$gp.glossary.hide(),s.preview=r,s.row_id=e,($gp.glossary.current=s).addClass("active"),s.show(),s.preview.hide(),n("a.add-entry").hasClass("open")&&n("a.add-entry").click(),n("input:first",s).focus())},hide:function(e){(e=e||$gp.glossary.current)&&(e.hide(),e.preview.show(),e.removeClass("active"),$gp.glossary.current=null)},save:function(r){var e,s;$gp.glossary.current&&(r.prop("disabled",!0),$gp.notices.notice("Saving…"),e=$gp.glossary.current,s={_gp_route_nonce:r.data("nonce")},n("#editor-"+e.row_id).find("input, select, textarea").each(function(){s[n(this).attr("name")]=this.value}),n.ajax({type:"POST",url:$gp_glossary_options.url,data:s,dataType:"json",success:function(e){r.prop("disabled",!1),$gp.notices.success("Saved!"),$gp.glossary.replace_current(e)},error:function(e,s){r.prop("disabled",!1),s=e.responseText?"Error: "+e.responseText:"Error saving the glossary item!",$gp.notices.error(s)}}))},del:function(e,s){var r,o,t;e.preventDefault(),confirm($gp_glossary_options.ge_delete_ays)&&(r=s.closest("tr"),t=r.prev("tr"),o={_gp_route_nonce:s.data("nonce")},r.find("input, select, textarea").each(function(){o[n(this).attr("name")]=this.value}),n.ajax({type:"POST",url:$gp_glossary_options.delete_url,data:o,success:function(){$gp.notices.success("Deleted!"),r.fadeOut("fast",function(){this.remove()}),t.remove(),1===n("tr",$gp.glossary.table).length&&$gp.glossary.table.remove()},error:function(e,s){s=e.responseText?"Error: "+e.responseText:"Error deleting the glossary item!",$gp.notices.error(s)}}))},replace_current:function(e){$gp.glossary.current&&($gp.glossary.current.after(e),(e=$gp.glossary.current).preview.remove(),e.remove(),$gp.glossary.current.preview.fadeIn(800))},hooks:{show:function(e){$gp.glossary.show(e,n(this))},del:function(e){$gp.glossary.del(e,n(this))},hide:function(){return $gp.glossary.hide(),!1},ok:function(){return $gp.glossary.save(n(this)),!1}}}}(jQuery),jQuery(function(e){$gp.glossary.init(e("#glossary"))});


Generated: Sat Dec 7 01:01:07 2024 Cross-referenced by PHPXref 0.7.1