scripts.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. /**
  87. * 单个图片上传
  88. * @param dialog_title 上传对话框标题
  89. * @param input_selector 图片容器
  90. * @param extra_params 额外参数,object
  91. * @param app 应用名,CMF的应用名
  92. */
  93. function doUploadOneImage(dialog_title, input_selector, extra_params, app) {
  94. parent.openUploadDialog(dialog_title, function (dialog, files) {
  95. $(input_selector).val(files[0].filepath);
  96. $(input_selector + '-preview').attr('src', files[0].preview_url);
  97. $(input_selector + '-name').val(files[0].name);
  98. $(input_selector + '-name-text').text(files[0].name);
  99. }, extra_params, 0, 'image', app);
  100. }
  101. /**
  102. * 单个文件上传
  103. * @param dialog_title 上传对话框标题
  104. * @param input_selector 图片容器
  105. * @param filetype 文件类型,image,video,audio,file
  106. * @param extra_params 额外参数,object
  107. * @param app 应用名,CMF的应用名
  108. */
  109. function doUploadOne(dialog_title, input_selector, filetype, extra_params, app) {
  110. filetype = filetype ? filetype : 'file';
  111. parent.openUploadDialog(dialog_title, function (dialog, files) {
  112. $(input_selector).val(files[0].filepath);
  113. $(input_selector + '-preview').attr('href', files[0].preview_url);
  114. $(input_selector + '-name').val(files[0].name);
  115. $(input_selector + '-name-text').text(files[0].name);
  116. }, extra_params, 0, filetype, app);
  117. }
  118. function confirm() {
  119. $('#submit-btn').click();
  120. }
  121. function removeImage(wigetVarName) {
  122. //需要定位input和image
  123. //清空Input
  124. $('#js-' + wigetVarName + '-input').val('');
  125. //修改Image为原图。
  126. var defaultImage = $('#js-' + wigetVarName + '-button-remove').attr('defaultImage');
  127. $('#js-' + wigetVarName + '-input-preview').attr('src', defaultImage);
  128. //移除自身
  129. $('#js-' + wigetVarName + '-button-remove').remove();
  130. }
  131. </script>