common.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. $(document).ready(function() {
  2. /* Removed as this is now (hopefully) unnecessary */
  3. //$("#Panel").stickyPanel({
  4. // topPadding: 1,
  5. // afterDetachCSSClass: "floated-panel",
  6. // savePanelSpace: true
  7. //});
  8. //this statement tells the browser to fade out any success message after 5 seconds
  9. setTimeout(function(){$(".success").fadeOut("slow", function(){$(this).empty()});}, 5000);
  10. });
  11. /*
  12. * i18n_months and i18n_days_short are used in jquery datepickers
  13. * which we use in multiple places
  14. */
  15. var i18n_months = [
  16. $.i18n._("January"),
  17. $.i18n._("February"),
  18. $.i18n._("March"),
  19. $.i18n._("April"),
  20. $.i18n._("May"),
  21. $.i18n._("June"),
  22. $.i18n._("July"),
  23. $.i18n._("August"),
  24. $.i18n._("September"),
  25. $.i18n._("October"),
  26. $.i18n._("November"),
  27. $.i18n._("December")
  28. ];
  29. var i18n_months_short = [
  30. $.i18n._("Jan"),
  31. $.i18n._("Feb"),
  32. $.i18n._("Mar"),
  33. $.i18n._("Apr"),
  34. $.i18n._("May"),
  35. $.i18n._("Jun"),
  36. $.i18n._("Jul"),
  37. $.i18n._("Aug"),
  38. $.i18n._("Sep"),
  39. $.i18n._("Oct"),
  40. $.i18n._("Nov"),
  41. $.i18n._("Dec")
  42. ];
  43. var i18n_days_short = [
  44. $.i18n._("Su"),
  45. $.i18n._("Mo"),
  46. $.i18n._("Tu"),
  47. $.i18n._("We"),
  48. $.i18n._("Th"),
  49. $.i18n._("Fr"),
  50. $.i18n._("Sa")
  51. ];
  52. function adjustDateToServerDate(date, serverTimezoneOffset){
  53. //date object stores time in the browser's localtime. We need to artificially shift
  54. //it to
  55. var timezoneOffset = date.getTimezoneOffset()*60*1000;
  56. date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset*1000);
  57. /* date object has been shifted to artificial UTC time. Now let's
  58. * shift it to the server's timezone */
  59. return date;
  60. }
  61. /**
  62. *handle to the jplayer window
  63. */
  64. var _preview_window = null;
  65. /**
  66. *Gets the info from the view when menu action play choosen and opens the jplayer window.
  67. */
  68. function openAudioPreview(p_event) {
  69. p_event.stopPropagation();
  70. var audioFileID = $(this).attr('audioFile');
  71. var objId = $('#obj_id:first').attr('value');
  72. var objType = $('#obj_type:first').attr('value');
  73. var playIndex = $(this).parent().parent().attr('id');
  74. playIndex = playIndex.substring(4); //remove the spl_
  75. if (objType == "playlist") {
  76. open_playlist_preview(objId, playIndex);
  77. } else if (objType == "block") {
  78. open_block_preview(objId, playIndex);
  79. }
  80. }
  81. function open_audio_preview(type, id, audioFileTitle, audioFileArtist) {
  82. // we need to remove soundcloud icon from audioFileTitle
  83. var index = audioFileTitle.indexOf("<span class=");
  84. if(index != -1){
  85. audioFileTitle = audioFileTitle.substring(0,index);
  86. }
  87. // The reason that we need to encode artist and title string is that
  88. // sometime they contain '/' or '\' and apache reject %2f or %5f
  89. // so the work around is to encode it twice.
  90. openPreviewWindow(baseUrl+'audiopreview/audio-preview/audioFileID/'+id+'/audioFileArtist/'+encodeURIComponent(encodeURIComponent(audioFileArtist))+'/audioFileTitle/'+encodeURIComponent(encodeURIComponent(audioFileTitle))+'/type/'+type);
  91. _preview_window.focus();
  92. }
  93. /**
  94. *Opens a jPlayer window for the specified info, for either an audio file or playlist.
  95. *If audioFile, audioFileTitle, audioFileArtist is supplied the jplayer opens for one file
  96. *Otherwise the playlistID and playlistIndex was supplied and a playlist is played starting with the
  97. *given index.
  98. */
  99. function open_playlist_preview(p_playlistID, p_playlistIndex) {
  100. if (p_playlistIndex == undefined) //Use a resonable default.
  101. p_playlistIndex = 0;
  102. if (_preview_window != null && !_preview_window.closed)
  103. _preview_window.playAllPlaylist(p_playlistID, p_playlistIndex);
  104. else
  105. openPreviewWindow(baseUrl+'audiopreview/playlist-preview/playlistIndex/'+p_playlistIndex+'/playlistID/'+p_playlistID);
  106. _preview_window.focus();
  107. }
  108. function open_block_preview(p_blockId, p_blockIndex) {
  109. if (p_blockIndex == undefined) //Use a resonable default.
  110. p_blockIndex = 0;
  111. if (_preview_window != null && !_preview_window.closed)
  112. _preview_window.playBlock(p_blockId, p_blockIndex);
  113. else
  114. openPreviewWindow(baseUrl+'audiopreview/block-preview/blockIndex/'+p_blockIndex+'/blockId/'+p_blockId);
  115. _preview_window.focus();
  116. }
  117. /**
  118. *Opens a jPlayer window for the specified info, for either an audio file or playlist.
  119. *If audioFile, audioFileTitle, audioFileArtist is supplied the jplayer opens for one file
  120. *Otherwise the playlistID and playlistIndex was supplied and a playlist is played starting with the
  121. *given index.
  122. */
  123. function open_show_preview(p_showID, p_showIndex) {
  124. if (_preview_window != null && !_preview_window.closed)
  125. _preview_window.playAllShow(p_showID, p_showIndex);
  126. else
  127. openPreviewWindow(baseUrl+'audiopreview/show-preview/showID/'+p_showID+'/showIndex/'+p_showIndex);
  128. _preview_window.focus();
  129. }
  130. function openPreviewWindow(url) {
  131. _preview_window = window.open(url, $.i18n._('Audio Player'), 'width=450,height=100,scrollbars=yes');
  132. return false;
  133. }
  134. function pad(number, length) {
  135. return sprintf("%'0"+length+"d", number);
  136. }
  137. function removeSuccessMsg() {
  138. var $status = $('.success');
  139. $status.fadeOut("slow", function(){$status.empty()});
  140. }