scripts.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <script src="__STATIC__/js/admin.js"></script>
  2. <script>
  3. Wind.use('colorpicker', function () {
  4. $('.js-color').each(function () {
  5. var $this = $(this);
  6. $this.ColorPicker({
  7. livePreview: true,
  8. onChange: function (hsb, hex, rgb) {
  9. $this.val('#' + hex);
  10. },
  11. onBeforeShow: function () {
  12. $(this).ColorPickerSetColor(this.value);
  13. }
  14. });
  15. });
  16. });
  17. function doSelectData(obj) {
  18. var $obj = $(obj);
  19. var $realInput = $obj.next();
  20. var selectedObjectsId = $realInput.val();
  21. var dataSource = $obj.data('source');
  22. var title = $obj.data('title');
  23. parent.openIframeLayer("{:url('theme/dataSource')}?ids=" + selectedObjectsId + '&data_source=' + dataSource, title, {
  24. area: ['95%', '90%'],
  25. btn: ['确定', '取消'],
  26. yes: function (index, layero) {
  27. var iframeWin = parent.window[layero.find('iframe')[0]['name']];
  28. var selectedObjects = iframeWin.confirm();
  29. if (selectedObjects.selectedObjectsId.length == 0) {
  30. layer.msg('您没有选择任何数据!');
  31. return;
  32. }
  33. $realInput.val(selectedObjects.selectedObjectsId.join(','));
  34. $obj.val(selectedObjects.selectedObjectsName.join(','));
  35. parent.layer.close(index); //如果设定了yes回调,需进行手工关闭
  36. }
  37. });
  38. }
  39. function doEditArrayData(obj) {
  40. var $obj = $(obj);
  41. var mVar = $obj.data('var');
  42. var title = $obj.data('title');
  43. var widget = $obj.data('widget');
  44. widget = widget ? '&widget=' + widget : '';
  45. var fileId = $obj.data('file_id');
  46. if (!fileId) {
  47. fileId = '{$file_id}';
  48. }
  49. parent.openIframeLayer(
  50. "{:url('theme/fileArrayData')}?tab={$tab}&file_id="+fileId+"&" + 'var=' + mVar + widget,
  51. title,
  52. {
  53. area: ['95%', '90%'],
  54. btn: ['确定', '取消'],
  55. yes: function (index, layero) {
  56. var iframeWin = parent.window[layero.find('iframe')[0]['name']];
  57. var result = iframeWin.confirm();
  58. if (result) {
  59. parent.layer.close(index); //如果设定了yes回调,需进行手工关闭
  60. }
  61. }
  62. }
  63. );
  64. }
  65. function doSelectLocation(obj) {
  66. var $obj = $(obj);
  67. var title = $obj.data('title');
  68. var $realInput = $obj.next();
  69. var location = $realInput.val();
  70. parent.openIframeLayer(
  71. "{:url('dialog/map')}?location=" + location,
  72. title,
  73. {
  74. area: ['95%', '90%'],
  75. btn: ['确定', '取消'],
  76. yes: function (index, layero) {
  77. var iframeWin = parent.window[layero.find('iframe')[0]['name']];
  78. var location = iframeWin.confirm();
  79. $realInput.val(location.lng + ',' + location.lat);
  80. $obj.val(location.address);
  81. parent.layer.close(index); //如果设定了yes回调,需进行手工关闭
  82. }
  83. }
  84. );
  85. }
  86. function confirm() {
  87. $('#submit-btn').click();
  88. }
  89. function removeImage(wigetVarName) {
  90. //需要定位input和image
  91. //清空Input
  92. $('#js-' + wigetVarName + '-input').val('');
  93. //修改Image为原图。
  94. var defaultImage = $('#js-' + wigetVarName + '-button-remove').attr('defaultImage');
  95. $('#js-' + wigetVarName + '-input-preview').attr('src', defaultImage);
  96. //移除自身
  97. $('#js-' + wigetVarName + '-button-remove').remove();
  98. }
  99. </script>