theme.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'clipboard'], function ($, undefined, Backend, Table, Form, ClipboardJS) {
  2. var Controller = {
  3. index: function () {
  4. var previewUrl = $("#previewiframe").attr("src");
  5. require(['jquery-colorpicker'], function () {
  6. $('.colorpicker').colorpicker({
  7. color: function (btn) {
  8. var color = "#000000";
  9. var rgb = $(this.eve).val().match(/^rgb\(((\d+),\s*(\d+),\s*(\d+))\)$/);
  10. if (rgb) {
  11. color = rgb[1];
  12. }
  13. return color;
  14. }
  15. }, function (btn, obj) {
  16. $(btn).closest(".input-group").find("input").val('#' + obj.hex).css('backgroundColor', '#' + obj.hex);
  17. }, function (btn, obj) {
  18. $(btn).closest(".input-group").find("input").val('').css('backgroundColor', '#' + obj.hex);
  19. });
  20. });
  21. Form.api.bindevent($("form[role=form]"), function () {
  22. $("#previewiframe").attr("src", previewUrl + ($("#config-form input[name='preview']").val() == 1 ? "?mode=preview" : ""));
  23. });
  24. $(document).on("fa.event.appendfieldlist", ".tabbarlist .btn-append", function (e, obj) {
  25. if ($(".tabbarlist table tr.tabbarlist-item").length > 5) {
  26. $(".tabbarlist table tr.tabbarlist-item:last").remove();
  27. Layer.msg("最多允许添加5个");
  28. }
  29. Form.events.faselect(obj);
  30. });
  31. $(document).on("change", ".tabbarlist .tabbar-img-value", function (e, obj) {
  32. $(this).next().attr("src", Fast.api.cdnurl($(this).val(), true));
  33. });
  34. $(document).on("change", ".tabbarlist .c-tabbar-list-midbutton", function (e, obj) {
  35. $(".tabbarlist .c-tabbar-list-midbutton").not(this).prop("checked", false);
  36. });
  37. $(document).on("click", ".btn-preview", function (e, obj) {
  38. $("#config-form input[name='preview']").val(1);
  39. });
  40. $(document).on("click", ".btn-preview,.btn-save", function (e, obj) {
  41. $("#config-form input[name='preview']").val($(this).data("preview"));
  42. $("#config-form").submit();
  43. });
  44. $(document).on("click", ".btn-select-page", function (e, obj) {
  45. var that = this;
  46. Fast.api.open("cms/ajax/get_page_list", "选择路径", {
  47. callback: function (data) {
  48. $(that).parent().prev().val(data);
  49. }
  50. })
  51. });
  52. },
  53. };
  54. return Controller;
  55. });