common.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. function mediaPlay(id,src,btn,w,h,classN){
  2. $(id).jPlayer({
  3. ready: function () {
  4. $(this).jPlayer("setMedia", {
  5. m4v: src
  6. });
  7. },
  8. swfPath: "jplayer",
  9. supplied: "m4v",
  10. cssSelectorAncestor: btn,
  11. size: {
  12. width: w,
  13. height: h,
  14. cssClass: classN
  15. },
  16. useStateClassSkin: true,
  17. autoBlur: false,
  18. smoothPlayBar: true,
  19. keyEnabled: true,
  20. remainingDuration: true,
  21. toggleDuration: true
  22. });
  23. };
  24. function jplayerp(id,src,btn){
  25. $(id).jPlayer({
  26. ready: function (event) {
  27. $(this).jPlayer("setMedia", {
  28. title: "Bubble",
  29. mp3: src
  30. });
  31. },
  32. swfPath: "jplayer",
  33. supplied: "mp3, oga",
  34. cssSelectorAncestor: btn,
  35. wmode: "window",
  36. useStateClassSkin: true,
  37. autoBlur: false,
  38. smoothPlayBar: true,
  39. keyEnabled: true,
  40. remainingDuration: true,
  41. toggleDuration: true
  42. });
  43. };
  44. $(function(){
  45. $(".jp-play").click(function(){
  46. var prCl = $(this).parents(".audioDiv").find(".soundBox");
  47. $(".soundBox").addClass("soundBoxUn");
  48. prCl.removeClass("soundBoxUn");
  49. $(".soundBoxUn .jp-stop").click();
  50. });
  51. });
  52. //图片按比例放大缩小
  53. function DrawImage(ImgD, FitWidth, FitHeight) {
  54. var image = new Image();
  55. image.src = ImgD.src;
  56. if (image.width > 0 && image.height > 0)
  57. {
  58. if (image.width / image.height >= FitWidth / FitHeight){
  59. if (image.width > FitWidth) {
  60. //ImgD.width = FitWidth;
  61. ImgD.height = FitHeight;
  62. var ml = ((image.width * FitHeight) / image.height - FitWidth)/2;
  63. ImgD.style.marginLeft = -ml + "px";
  64. }else{
  65. //ImgD.width = FitWidth;
  66. ImgD.height = FitHeight;
  67. }
  68. }else {
  69. if (image.height > FitHeight) {
  70. //ImgD.height = FitHeight;
  71. ImgD.width = FitWidth;
  72. }else {
  73. ImgD.width = FitWidth;
  74. //ImgD.height = FitHeight;
  75. }
  76. }
  77. }
  78. }