topBar.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <style>
  2. .CoverPiece{position: absolute; let: 0px; top: 0px; width: 85px; height: 25px; overflow: hidden;}
  3. .CoverInput{display: none;}
  4. .CoverLabel{height: 25px; width: 85px; float: left; cursor: pointer;}
  5. </style>
  6. <div id="tabs-container">
  7. <ul class="tabs-menu">
  8. <a href="/broadcast/cover/auditing"><li class="Auditing"><span>UNDER REVIEW</span></li></a><!--待审核-->
  9. <a href="/broadcast/cover/pass"><li class="Pass"><span>APPROVED</span></li></a><!--审核通过-->
  10. <a href="/broadcast/cover/failed"><li class="Failed"><span>REJECTED</span></li></a><!--审核否决-->
  11. </ul>
  12. <ul class="plusBtn">
  13. <li>
  14. <a href="javascript:;">
  15. <div class="plusPhoto redButton">+ Photo</div>
  16. <div class="CoverPiece">
  17. <label class="CoverLabel">
  18. <input class="CoverInput" type="file" name="file" accept="image/jpg,image/jpeg,image/png">
  19. </label>
  20. </div>
  21. </a>
  22. </li>
  23. </ul>
  24. </div>
  25. <script>
  26. var change_status = 0;//防止多次点击
  27. var coverCount = '<%=coverCount%>';
  28. window.parent.originalImg = '';
  29. $(document).on('change', 'input[name="file"]', function(){
  30. if(coverCount > 29){
  31. myParentAlert('Can not upload more than 30 broadcast covers.');
  32. emptiedFile();
  33. return false;
  34. }
  35. if(this.files[0].type != 'image/jpg' && this.files[0].type != 'image/jpeg' && this.files[0].type != 'image/png'){
  36. myParentAlert('Incorrect format. Only JPG and PNG format allowed. File size must be 3M or less.');
  37. emptiedFile();
  38. return false;
  39. }
  40. window.parent.originalImg = this.files[0];
  41. var objUrl = getObjectURL(this.files[0]);
  42. var type = this.files[0].type;
  43. if(this.files[0].size > 3 * 1024 * 1024){
  44. myParentAlert('Incorrect format. Only JPG and PNG format allowed. File size must be 3M or less.');
  45. emptiedFile();
  46. return false;
  47. }
  48. var image = new Image();
  49. image.src = objUrl;
  50. image.onload = function(){
  51. var width = image.width;
  52. var height = image.height;
  53. if(width<1024 || height<1024){
  54. myParentAlert('PNG and JPG format only, less than 3MB. Size: 1024px * 1024px to 2400px * 2400px.');
  55. emptiedFile();
  56. return false;
  57. }
  58. if(width>2400 || height>2400){
  59. myParentAlert('PNG and JPG format only, less than 3MB. Size: 1024px * 1024px to 2400px * 2400px.');
  60. emptiedFile();
  61. return false;
  62. }
  63. var windowHeigth = $(parent).height();
  64. var windowWidth = $(parent).width();
  65. var imgHeigth = '';
  66. var imgWidth = '';
  67. if(windowHeigth < (height+120) || windowWidth < (width+50)){
  68. windowHeigth = parseInt(windowHeigth * 0.6);
  69. windowWidth = parseInt(windowWidth * 0.6);
  70. height = windowHeigth;
  71. width = windowWidth;
  72. imgHeigth = windowHeigth;
  73. imgWidth = windowWidth;
  74. }else{
  75. imgHeigth = height;
  76. imgWidth = width;
  77. }
  78. width = width + 50 + 'px';
  79. height = (height * (imgHeigth/imgWidth)) + 120 + 'px';
  80. if(change_status){
  81. return false;
  82. }
  83. change_status = 1;
  84. parent.layer.open({
  85. type: 2,
  86. title: '',
  87. closeBtn: 0,
  88. resize: false,
  89. area : [width, height],
  90. content: '/broadcast/coverLayer/addCover?blobImg='+objUrl+'&type='+type+'&width='+imgWidth+'&height='+imgHeigth,
  91. end:function(){
  92. change_status = 0;//防止多次点击
  93. var status = Cookies.getJSON('add_success_cover');
  94. Cookies.remove('add_success_cover');
  95. if(status && status.status == 1){
  96. window.location.href='/broadcast/cover/auditing';
  97. }
  98. emptiedFile();
  99. }
  100. });
  101. }
  102. //关闭窗口清空表单数据,解决重复选择同一张图片的问题。
  103. function emptiedFile(){
  104. $("input[name='file']").val('');
  105. }
  106. })
  107. </script>