Skip to content

Instantly share code, notes, and snippets.

@FrankMeijer
Created June 30, 2018 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrankMeijer/694c374ff25eeaa682f4bb7130e10075 to your computer and use it in GitHub Desktop.
Save FrankMeijer/694c374ff25eeaa682f4bb7130e10075 to your computer and use it in GitHub Desktop.
Fix for duplicate ids in Magic Liquidizer Responsive Table WordPress plugin
!function(e){e.fn.responsiveTable=function(t){var l=e.extend({headerSelector:"thead td, thead th, tr th",bodyRowSelector:"tbody tr, tr",rowElement:"<dl></dl>",columnTitleElement:"<dt></dt>",columnValueElement:"<dd></dd>",enable:!0},t),a="",i="",n=new Array,d=0,r=0,o="",h="",m="";return this.each(function(t,s){a=e(this),i=e('<div class="ml-responsive-table ml-responsive-table-'+t+'" />'),a.find(l.headerSelector).each(function(t,l){n[t]=e(l).html()}),a.find(l.bodyRowSelector).each(function(){e(this).children("td").each(function(e){r+=e})}),a.find(l.bodyRowSelector).each(function(t,a){(o=e(l.rowElement)).addClass("ml-grid ml-clearfix ml-row-"+t),e(this).children("td").each(function(a,i){d=0==r?t:a,h=e(l.columnTitleElement),m=e(l.columnValueElement),h.addClass("ml-title ml-table"),h.html(n[d]),m.addClass("ml-value ml-table"),m.html(e(this).html()),""==e.trim(e(this).html())&&(m.addClass("ml-empty"),h.addClass("ml-empty")),o.append(h).append(m)}),i.append(o)}),l.enable?(a.hide(),void 0!==a.attr("id")&&a.attr("id","temp-"+a.attr("id")),e("*",a).each(function(){void 0!==e(this).attr("id")&&e(this).attr("id","temp-"+e(this).attr("id"))}),a.after(i)):(e(".ml-responsive-table").remove(),void 0!==a.attr("id")&&a.attr("id",a.attr("id").replace("temp-")),e("*",a).each(function(){var t=e(this).attr("id");if(void 0!==t){var l=t.replace("temp-","");e(this).attr("id",l)}}),a.show())})}}(jQuery),function(e){e.fn.MagicLiquidizerTable=function(t){var l=e.extend({table:"1",breakpoint:"720",whichelement:"table"},t);return this.each(function(){function t(){e(window).width()<l.breakpoint?(!e("html.rwd-table").length>0&&e("html").addClass("rwd-table"),"1"==l.table&&!e(".ml-responsive-table").length>0&&e(l.whichelement).responsiveTable({enable:!0})):(e("html.rwd-table").length>0&&e("html").removeClass("rwd-table"),"1"==l.table&&e(l.whichelement).responsiveTable({enable:!1}))}e(window).resize(t).ready(t)})}}(jQuery);
@FrankMeijer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment