code.dev.js 1.4 KB

12345678910111213141516171819202122
  1. "use strict";
  2. /** layui-v2.5.6 MIT License By https://www.layui.com */
  3. ;
  4. layui.define("jquery", function (e) {
  5. "use strict";
  6. var a = layui.$,
  7. l = "http://www.layui.com/doc/modules/code.html";
  8. e("code", function (e) {
  9. var t = [];
  10. e = e || {}, e.elem = a(e.elem || ".layui-code"), e.about = !("about" in e) || e.about, e.elem.each(function () {
  11. t.push(this);
  12. }), layui.each(t.reverse(), function (t, i) {
  13. var c = a(i),
  14. o = c.html();
  15. (c.attr("lay-encode") || e.encode) && (o = o.replace(/&(?!#?[a-zA-Z0-9]+;)/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&#39;").replace(/"/g, "&quot;")), c.html('<ol class="layui-code-ol"><li>' + o.replace(/[\r\t\n]+/g, "</li><li>") + "</li></ol>"), c.find(">.layui-code-h3")[0] || c.prepend('<h3 class="layui-code-h3">' + (c.attr("lay-title") || e.title || "code") + (e.about ? '<a href="' + l + '" target="_blank">layui.code</a>' : "") + "</h3>");
  16. var d = c.find(">.layui-code-ol");
  17. c.addClass("layui-box layui-code-view"), (c.attr("lay-skin") || e.skin) && c.addClass("layui-code-" + (c.attr("lay-skin") || e.skin)), (d.find("li").length / 100 | 0) > 0 && d.css("margin-left", (d.find("li").length / 100 | 0) + "px"), (c.attr("lay-height") || e.height) && d.css("max-height", c.attr("lay-height") || e.height);
  18. });
  19. });
  20. }).addcss("modules/code.css", "skincodecss");