2010-12-22 05:33:58 +01:00
//--------------------------------------------------------------------------------------------------------------------------------
2012-02-04 19:27:26 +01:00
// Playlist Functions
2010-12-22 05:33:58 +01:00
//--------------------------------------------------------------------------------------------------------------------------------
2012-02-04 15:52:31 +01:00
var AIRTIME = ( function ( AIRTIME ) {
2012-02-04 19:27:26 +01:00
2012-03-30 16:04:00 +02:00
if ( AIRTIME . playlist === undefined ) {
AIRTIME . playlist = { } ;
2012-08-21 00:35:10 +02:00
}
2012-03-14 17:50:48 +01:00
2012-03-30 16:04:00 +02:00
var mod = AIRTIME . playlist ,
viewport ,
$lib ,
$pl ,
widgetHeight ,
2012-05-04 18:13:01 +02:00
resizeTimeout ,
2012-03-30 16:04:00 +02:00
width ;
2012-02-04 15:52:31 +01:00
2012-02-06 11:07:10 +01:00
function isTimeValid ( time ) {
2012-08-16 23:11:48 +02:00
//var regExpr = new RegExp("^\\d{2}[:]\\d{2}[:]\\d{2}([.]\\d{1,6})?$");
2012-10-11 17:49:04 +02:00
var regExpr = new RegExp ( "^\\d{2}[:]([0-5]){1}([0-9]){1}[:]([0-5]){1}([0-9]){1}([.]\\d{1})?$" ) ;
2012-02-06 11:07:10 +01:00
return regExpr . test ( time ) ;
}
function isFadeValid ( fade ) {
2012-10-11 17:49:04 +02:00
var regExpr = new RegExp ( "^\\d{1}(\\d{1})?([.]\\d{1})?$" ) ;
2012-02-02 21:59:35 +01:00
return regExpr . test ( fade ) ;
2011-01-17 19:55:43 +01:00
}
2012-02-06 11:07:10 +01:00
2012-02-20 18:24:04 +01:00
function playlistError ( json ) {
alert ( json . error ) ;
openPlaylist ( json ) ;
}
2012-02-06 11:07:10 +01:00
2012-02-04 15:52:31 +01:00
function stopAudioPreview ( ) {
// stop any preview playing
$ ( '#jquery_jplayer_1' ) . jPlayer ( 'stop' ) ;
2011-01-17 19:55:43 +01:00
}
2012-02-04 15:52:31 +01:00
function highlightActive ( el ) {
2011-01-17 19:55:43 +01:00
2012-02-04 15:52:31 +01:00
$ ( el ) . addClass ( "ui-state-active" ) ;
2011-01-17 19:55:43 +01:00
}
2012-02-04 15:52:31 +01:00
function unHighlightActive ( el ) {
2011-01-17 19:55:43 +01:00
2012-02-04 15:52:31 +01:00
$ ( el ) . removeClass ( "ui-state-active" ) ;
2011-01-17 19:55:43 +01:00
}
2012-02-04 19:27:26 +01:00
function showError ( el , error ) {
$ ( el ) . parent ( ) . next ( )
. empty ( )
. append ( error )
. show ( ) ;
}
2011-05-17 23:30:17 +02:00
2012-02-04 19:27:26 +01:00
function hideError ( el ) {
$ ( el ) . parent ( ) . next ( )
. empty ( )
. hide ( ) ;
2011-01-18 20:57:54 +01:00
}
2012-08-14 23:10:31 +02:00
function changeCueIn ( event ) {
event . stopPropagation ( ) ;
var span = $ ( this ) ,
id = span . parent ( ) . attr ( "id" ) . split ( "_" ) . pop ( ) ,
2013-01-14 22:00:38 +01:00
url = baseUrl + "Playlist/set-cue" ,
2012-08-13 18:46:17 +02:00
cueIn = $ . trim ( span . text ( ) ) ,
li = span . parents ( "li" ) ,
unqid = li . attr ( "unqid" ) ,
lastMod = getModified ( ) ,
type = $ ( '#obj_type' ) . val ( ) ;
2012-10-19 17:09:34 +02:00
if ( ! isTimeValid ( cueIn ) ) {
2013-01-14 20:49:06 +01:00
showError ( span , $ . i18n . _ ( "please put in a time '00:00:00 (.0)'" ) ) ;
2012-10-19 17:09:34 +02:00
return ;
}
$ . post ( url ,
{ format : "json" , cueIn : cueIn , id : id , modified : lastMod , type : type } ,
function ( json ) {
if ( json . error !== undefined ) {
playlistError ( json ) ;
2012-02-20 18:24:04 +01:00
return ;
}
2012-10-19 17:09:34 +02:00
if ( json . cue _error !== undefined ) {
showError ( span , json . cue _error ) ;
return ;
}
setPlaylistContent ( json ) ;
li = $ ( '#side_playlist li[unqid=' + unqid + ']' ) ;
li . find ( ".cue-edit" ) . toggle ( ) ;
highlightActive ( li ) ;
highlightActive ( li . find ( '.spl_cue' ) ) ;
} ) ;
}
2011-05-17 23:30:17 +02:00
2012-08-14 23:10:31 +02:00
function changeCueOut ( event ) {
event . stopPropagation ( ) ;
var span = $ ( this ) ,
id = span . parent ( ) . attr ( "id" ) . split ( "_" ) . pop ( ) ,
2013-01-14 22:00:38 +01:00
url = baseUrl + "Playlist/set-cue" ,
2012-08-13 18:46:17 +02:00
cueOut = $ . trim ( span . text ( ) ) ,
li = span . parents ( "li" ) ,
unqid = li . attr ( "unqid" ) ,
lastMod = getModified ( ) ,
2012-07-25 17:00:46 +02:00
type = $ ( '#obj_type' ) . val ( ) ;
2011-01-17 00:37:02 +01:00
2012-10-19 17:09:34 +02:00
if ( ! isTimeValid ( cueOut ) ) {
2013-01-14 20:49:06 +01:00
showError ( span , $ . i18n . _ ( "please put in a time '00:00:00 (.0)'" ) ) ;
2012-10-19 17:09:34 +02:00
return ;
}
$ . post ( url ,
{ format : "json" , cueOut : cueOut , id : id , modified : lastMod , type : type } ,
function ( json ) {
2011-02-08 00:44:42 +01:00
2012-10-19 17:09:34 +02:00
if ( json . error !== undefined ) {
playlistError ( json ) ;
return ;
}
if ( json . cue _error !== undefined ) {
showError ( span , json . cue _error ) ;
return ;
2012-02-20 18:24:04 +01:00
}
2010-12-22 05:33:58 +01:00
2012-10-19 17:09:34 +02:00
setPlaylistContent ( json ) ;
2011-05-17 23:30:17 +02:00
2012-10-19 17:09:34 +02:00
li = $ ( '#side_playlist li[unqid=' + unqid + ']' ) ;
li . find ( ".cue-edit" ) . toggle ( ) ;
highlightActive ( li ) ;
highlightActive ( li . find ( '.spl_cue' ) ) ;
} ) ;
}
function changeFadeIn ( event ) {
event . preventDefault ( ) ;
var span = $ ( this ) ,
id = span . parent ( ) . attr ( "id" ) . split ( "_" ) . pop ( ) ,
2013-01-14 22:00:38 +01:00
url = baseUrl + "Playlist/set-fade" ,
2012-10-19 17:09:34 +02:00
fadeIn = $ . trim ( span . text ( ) ) ,
li = span . parents ( "li" ) ,
unqid = li . attr ( "unqid" ) ,
lastMod = getModified ( ) ,
2012-07-25 17:00:46 +02:00
type = $ ( '#obj_type' ) . val ( ) ;
2010-12-22 05:33:58 +01:00
2012-10-19 17:09:34 +02:00
if ( ! isFadeValid ( fadeIn ) ) {
2012-11-20 17:16:10 +01:00
showError ( span , $ . i18n . _ ( "please put in a time in seconds '00 (.0)'" ) ) ;
2012-10-19 17:09:34 +02:00
return ;
}
2011-05-17 23:30:17 +02:00
2012-10-19 17:09:34 +02:00
$ . post ( url ,
{ format : "json" , fadeIn : fadeIn , id : id , modified : lastMod , type : type } ,
function ( json ) {
if ( json . error !== undefined ) {
playlistError ( json ) ;
return ;
2012-02-20 18:24:04 +01:00
}
2012-10-19 17:09:34 +02:00
if ( json . fade _error !== undefined ) {
showError ( span , json . fade _error ) ;
return ;
}
setPlaylistContent ( json ) ;
li = $ ( '#side_playlist li[unqid=' + unqid + ']' ) ;
li . find ( '.crossfade' ) . toggle ( ) ;
highlightActive ( li . find ( '.spl_fade_control' ) ) ;
} ) ;
}
2011-01-27 21:11:19 +01:00
2012-02-04 19:27:26 +01:00
function changeFadeOut ( event ) {
event . stopPropagation ( ) ;
2011-01-27 21:11:19 +01:00
2012-02-20 18:24:04 +01:00
var span = $ ( this ) ,
id = span . parent ( ) . attr ( "id" ) . split ( "_" ) . pop ( ) ,
2013-01-14 22:00:38 +01:00
url = baseUrl + "Playlist/set-fade" ,
2012-02-20 18:24:04 +01:00
fadeOut = $ . trim ( span . text ( ) ) ,
li = span . parents ( "li" ) ,
unqid = li . attr ( "unqid" ) ,
2012-07-25 17:00:46 +02:00
lastMod = getModified ( ) ,
type = $ ( '#obj_type' ) . val ( ) ;
2011-01-27 21:11:19 +01:00
2012-02-20 18:24:04 +01:00
if ( ! isFadeValid ( fadeOut ) ) {
2012-11-20 17:16:10 +01:00
showError ( span , $ . i18n . _ ( "please put in a time in seconds '00 (.0)'" ) ) ;
2012-02-04 19:27:26 +01:00
return ;
2011-01-27 21:11:19 +01:00
}
2011-05-17 23:30:17 +02:00
2012-02-20 18:24:04 +01:00
$ . post ( url ,
2012-07-25 17:00:46 +02:00
{ format : "json" , fadeOut : fadeOut , id : id , modified : lastMod , type : type } ,
2012-02-20 18:24:04 +01:00
function ( json ) {
if ( json . error !== undefined ) {
playlistError ( json ) ;
return ;
}
if ( json . fade _error !== undefined ) {
showError ( span , json . fade _error ) ;
return ;
}
setPlaylistContent ( json ) ;
li = $ ( '#side_playlist li[unqid=' + unqid + ']' ) ;
li . find ( '.crossfade' ) . toggle ( ) ;
highlightActive ( li . find ( '.spl_fade_control' ) ) ;
} ) ;
2012-02-04 19:27:26 +01:00
}
2010-12-22 05:33:58 +01:00
2012-02-04 19:27:26 +01:00
function submitOnEnter ( event ) {
//enter was pressed
if ( event . keyCode === 13 ) {
event . preventDefault ( ) ;
$ ( this ) . blur ( ) ;
}
}
2010-12-22 05:33:58 +01:00
2012-02-04 19:27:26 +01:00
function openFadeEditor ( event ) {
2012-03-19 14:09:05 +01:00
var li ;
2012-02-04 19:27:26 +01:00
event . stopPropagation ( ) ;
2010-12-22 05:33:58 +01:00
2012-03-19 14:09:05 +01:00
li = $ ( this ) . parents ( "li" ) ;
2012-02-04 19:27:26 +01:00
li . find ( ".crossfade" ) . toggle ( ) ;
2011-01-17 00:37:02 +01:00
2012-03-19 14:09:05 +01:00
if ( $ ( this ) . hasClass ( "ui-state-active" ) ) {
2012-02-04 19:27:26 +01:00
unHighlightActive ( this ) ;
}
else {
highlightActive ( this ) ;
}
}
2010-12-22 05:33:58 +01:00
2012-02-04 19:27:26 +01:00
function openCueEditor ( event ) {
2012-03-19 14:09:05 +01:00
var li , icon ;
2012-02-04 19:27:26 +01:00
event . stopPropagation ( ) ;
2010-12-22 05:33:58 +01:00
2012-02-04 19:27:26 +01:00
icon = $ ( this ) ;
2012-03-19 14:09:05 +01:00
li = $ ( this ) . parents ( "li" ) ;
2012-02-04 19:27:26 +01:00
li . find ( ".cue-edit" ) . toggle ( ) ;
2010-12-22 05:33:58 +01:00
2012-02-04 19:27:26 +01:00
if ( li . hasClass ( "ui-state-active" ) ) {
unHighlightActive ( li ) ;
unHighlightActive ( icon ) ;
}
else {
highlightActive ( li ) ;
highlightActive ( icon ) ;
}
}
2012-03-06 00:59:31 +01:00
2012-02-04 19:27:26 +01:00
function editName ( ) {
2012-02-20 18:24:04 +01:00
var nameElement = $ ( this ) ,
2012-07-25 17:00:46 +02:00
lastMod = getModified ( ) ,
type = $ ( '#obj_type' ) . val ( ) ;
2012-08-08 02:48:58 +02:00
//remove any newlines if user somehow snuck them in (easy to do if dragging/dropping text)
nameElement . text ( nameElement . text ( ) . replace ( "\n" , "" ) ) ;
/ * - - u n t i l w e d e c i d e w h e t h e r P l a y l i s t n a m e s h o u l d a u t o s a v e o r n o t
2012-10-19 17:09:34 +02:00
2013-01-14 22:00:38 +01:00
url = baseUrl + 'Playlist/set-playlist-name' ;
2012-03-19 14:09:05 +01:00
$ . post ( url ,
2012-07-25 17:00:46 +02:00
{ format : "json" , name : nameElement . text ( ) , modified : lastMod , type : type } ,
2012-03-19 14:09:05 +01:00
function ( json ) {
if ( json . error !== undefined ) {
playlistError ( json ) ;
}
else {
setModified ( json . modified ) ;
nameElement . text ( json . playlistName ) ;
redrawLib ( ) ;
}
} ) ;
2012-08-08 02:48:58 +02:00
* /
2012-02-04 19:27:26 +01:00
}
2012-02-04 15:52:31 +01:00
function redrawLib ( ) {
2012-04-27 11:22:44 +02:00
var dt = $lib . find ( "#library_display" ) . dataTable ( ) ;
2012-02-07 14:58:16 +01:00
2012-05-10 14:19:36 +02:00
dt . fnStandingRedraw ( ) ;
AIRTIME . library . redrawChosen ( ) ;
2012-02-04 15:52:31 +01:00
}
function setPlaylistContent ( json ) {
$ ( '#spl_name > a' )
. empty ( )
. append ( json . name ) ;
2012-08-09 20:12:30 +02:00
$ ( '#obj_length' )
2012-02-04 15:52:31 +01:00
. empty ( )
. append ( json . length ) ;
$ ( '#fieldset-metadate_change textarea' )
. empty ( )
. val ( json . description ) ;
2012-08-14 23:10:31 +02:00
2012-08-22 19:58:13 +02:00
$ ( '#spl_sortable' ) . off ( 'focusout keydown' ) ;
2012-08-14 23:10:31 +02:00
$ ( '#spl_sortable' )
. empty ( )
. append ( json . html ) ;
setCueEvents ( ) ;
setFadeEvents ( ) ;
2012-02-20 18:24:04 +01:00
setModified ( json . modified ) ;
2012-09-13 23:09:10 +02:00
AIRTIME . playlist . validatePlaylistElements ( ) ;
2012-02-04 15:52:31 +01:00
redrawLib ( ) ;
}
2012-08-08 21:29:09 +02:00
function setFadeIcon ( ) {
2012-08-17 18:56:45 +02:00
var contents = $ ( "#spl_sortable" ) ;
var show = contents . is ( ":visible" ) ;
2012-08-08 21:29:09 +02:00
var empty = $ ( ".spl_empty" ) ;
2012-08-17 18:56:45 +02:00
if ( ! show || empty . length > 0 ) {
2012-08-08 21:29:09 +02:00
$ ( "#spl_crossfade" ) . hide ( ) ;
} else {
2012-08-17 18:56:45 +02:00
//get list of playlist contents
var list = contents . children ( ) ;
//if first and last items are blocks, hide the fade icon
var first = list . first ( ) ;
var last = list . last ( ) ;
if ( first . find ( ':first-child' ) . children ( ) . attr ( 'blockid' ) !== undefined &&
last . find ( ':first-child' ) . children ( ) . attr ( 'blockid' ) !== undefined ) {
$ ( "#spl_crossfade" ) . hide ( ) ;
} else {
$ ( "#spl_crossfade" ) . show ( ) ;
}
2012-08-08 21:29:09 +02:00
}
}
2012-02-04 15:52:31 +01:00
function getId ( ) {
2012-07-25 18:44:37 +02:00
return parseInt ( $ ( "#obj_id" ) . val ( ) , 10 ) ;
2012-02-04 15:52:31 +01:00
}
function getModified ( ) {
2012-07-25 18:44:37 +02:00
return parseInt ( $ ( "#obj_lastMod" ) . val ( ) , 10 ) ;
2012-02-04 15:52:31 +01:00
}
2012-02-20 18:24:04 +01:00
function setModified ( modified ) {
2012-07-25 18:44:37 +02:00
$ ( "#obj_lastMod" ) . val ( modified ) ;
2012-02-20 18:24:04 +01:00
}
2012-02-04 15:52:31 +01:00
function openPlaylist ( json ) {
$ ( "#side_playlist" )
. empty ( )
. append ( json . html ) ;
2012-07-16 17:01:34 +02:00
2012-02-04 21:26:21 +01:00
setUpPlaylist ( ) ;
2012-08-16 19:02:48 +02:00
setCueEvents ( ) ;
setFadeEvents ( ) ;
2012-07-17 20:40:52 +02:00
2012-08-20 23:17:48 +02:00
// functions in smart_blockbuilder.js
2012-07-17 20:40:52 +02:00
setupUI ( ) ;
appendAddButton ( ) ;
2012-08-08 19:16:02 +02:00
appendModAddButton ( ) ;
2012-07-17 20:40:52 +02:00
removeButtonCheck ( ) ;
2012-02-04 19:27:26 +01:00
}
2012-09-12 23:32:19 +02:00
//Purpose of this function is to iterate over all playlist elements
//and verify whether they can be previewed by the browser or not. If not
//then the playlist element is greyed out
mod . validatePlaylistElements = function ( ) {
2012-10-16 18:06:47 +02:00
$ . each ( $ ( "div .big_play" ) , function ( index , value ) {
2012-09-14 22:38:26 +02:00
if ( $ ( value ) . attr ( 'blockId' ) === undefined ) {
var mime = $ ( value ) . attr ( "data-mime-type" ) ;
2012-11-02 21:54:49 +01:00
//If mime is undefined it is likely because the file was
//deleted from the library. This case is handled in mod.onReady()
if ( mime !== undefined ) {
if ( isAudioSupported ( mime ) ) {
$ ( value ) . bind ( "click" , openAudioPreview ) ;
} else {
$ ( value ) . attr ( "class" , "big_play_disabled dark_class" ) ;
$ ( value ) . qtip ( {
2012-11-20 17:16:10 +01:00
content : $ . i18n . _ ( "Your browser does not support playing this file type: " ) + mime ,
2012-11-02 21:54:49 +01:00
show : 'mouseover' ,
hide : {
delay : 500 ,
fixed : true
2012-09-14 22:38:26 +02:00
} ,
2012-11-02 21:54:49 +01:00
style : {
border : {
width : 0 ,
radius : 4
} ,
classes : "ui-tooltip-dark ui-tooltip-rounded"
} ,
position : {
my : "left bottom" ,
at : "right center"
2012-09-14 22:38:26 +02:00
} ,
2012-11-02 21:54:49 +01:00
} )
}
2012-09-14 22:38:26 +02:00
}
2012-10-16 20:09:34 +02:00
} else {
if ( $ ( value ) . attr ( 'blocktype' ) === 'dynamic' ) {
$ ( value ) . attr ( "class" , "big_play_disabled dark_class" ) ;
$ ( value ) . qtip ( {
2012-11-20 17:16:10 +01:00
content : $ . i18n . _ ( 'Dynamic block is not previewable' ) ,
2012-10-16 20:09:34 +02:00
show : 'mouseover' ,
hide : {
delay : 500 ,
fixed : true
} ,
style : {
border : {
width : 0 ,
radius : 4
} ,
classes : "ui-tooltip-dark ui-tooltip-rounded"
} ,
position : {
my : "left bottom" ,
at : "right center"
} ,
} )
} else {
$ ( value ) . bind ( "click" , openAudioPreview ) ;
}
2012-09-12 21:43:50 +02:00
}
} ) ;
2012-09-12 23:32:19 +02:00
}
//sets events dynamically for playlist entries (each row in the playlist)
function setPlaylistEntryEvents ( ) {
$pl . delegate ( "#spl_sortable .ui-icon-closethick" ,
{ "click" : function ( ev ) {
var id ;
id = parseInt ( $ ( this ) . attr ( "id" ) . split ( "_" ) . pop ( ) , 10 ) ;
AIRTIME . playlist . fnDeleteItems ( [ id ] ) ;
} } ) ;
$pl . delegate ( ".spl_fade_control" ,
{ "click" : openFadeEditor } ) ;
$pl . delegate ( ".spl_cue" ,
{ "click" : openCueEditor } ) ;
2012-09-12 21:43:50 +02:00
2012-07-30 23:18:33 +02:00
$pl . delegate ( ".spl_block_expand" ,
{ "click" : function ( ev ) {
var id = parseInt ( $ ( this ) . attr ( "id" ) . split ( "_" ) . pop ( ) , 10 ) ;
2012-08-02 22:36:12 +02:00
var blockId = parseInt ( $ ( this ) . attr ( "blockId" ) , 10 ) ;
2012-07-30 23:18:33 +02:00
if ( $ ( this ) . hasClass ( 'close' ) ) {
2013-01-14 22:00:38 +01:00
var sUrl = baseUrl + "playlist/get-block-info" ;
2012-07-30 23:18:33 +02:00
mod . disableUI ( ) ;
2012-08-02 22:36:12 +02:00
$ . post ( sUrl , { format : "json" , id : blockId } , function ( json ) {
2012-07-30 23:18:33 +02:00
$html = "" ;
var data = $ . parseJSON ( json ) ;
var isStatic = data . isStatic ;
delete data . type ;
if ( isStatic ) {
$ . each ( data , function ( index , ele ) {
2012-08-02 23:02:24 +02:00
if ( ele . track _title !== undefined ) {
2012-09-19 17:05:17 +02:00
if ( ele . creator === null ) {
ele . creator = "" ;
}
if ( ele . track _title === null ) {
ele . track _title = "" ;
}
2012-09-17 21:41:22 +02:00
$html += "<li>" +
2012-09-19 16:49:17 +02:00
"<span class='block-item-title'>" + ele . track _title + " - </span>" +
2012-09-17 21:41:22 +02:00
"<span class='block-item-author'>" + ele . creator + "</span>" +
"<span class='block-item-time'>" + ele . length + "</span>" +
"</li>" ;
2012-08-02 23:02:24 +02:00
}
2012-07-30 23:18:33 +02:00
} )
} else {
for ( var key in data . crit ) {
$ . each ( data . crit [ key ] , function ( index , ele ) {
2012-09-17 21:41:22 +02:00
var extra = ( ele [ 'extra' ] == null ) ? "" : "- " + ele [ 'extra' ] ;
$html += "<li>" +
"<span class='block-item-title'>" + ele [ 'display_name' ] + "</span>" +
"<span class='block-item-criteria'>" + ele [ 'modifier' ] + "</span>" +
"<span class='block-item-criteria'>" + ele [ 'value' ] + "</span>" +
"<span class='block-item-criteria'>" + extra + "</span>" +
"</li>" ;
2012-07-30 23:18:33 +02:00
} ) ;
}
2012-11-20 17:16:10 +01:00
$html += "<li><br /><span class='block-item-title'>" + $ . i18n . _ ( "Limit to: " ) + data . limit . value + " " + data . limit . modifier + "</span></li>" ;
2012-07-30 23:18:33 +02:00
}
2012-09-17 21:41:22 +02:00
$pl . find ( "#block_" + id + "_info" ) . html ( $html ) . show ( ) ;
2012-07-30 23:18:33 +02:00
mod . enableUI ( ) ;
} ) ;
$ ( this ) . removeClass ( 'close' ) ;
} else {
2012-09-17 21:41:22 +02:00
$pl . find ( "#block_" + id + "_info" ) . html ( "" ) . hide ( ) ;
2012-07-30 23:18:33 +02:00
$ ( this ) . addClass ( 'close' ) ;
}
} } ) ;
2011-01-18 20:57:54 +01:00
}
2011-11-29 15:30:05 +01:00
2012-02-04 19:27:26 +01:00
//sets events dynamically for the cue editor.
2012-03-30 16:04:00 +02:00
function setCueEvents ( ) {
2012-08-14 23:10:31 +02:00
var temp = $ ( '#spl_sortable' ) ;
2012-08-22 19:58:13 +02:00
temp . on ( "focusout" , ".spl_cue_in span" , changeCueIn ) ;
2012-08-14 23:10:31 +02:00
temp . on ( "keydown" , ".spl_cue_in span" , submitOnEnter ) ;
2012-08-22 19:58:13 +02:00
temp . on ( "focusout" , ".spl_cue_out span" , changeCueOut ) ;
2012-08-14 23:10:31 +02:00
temp . on ( "keydown" , ".spl_cue_out span" , submitOnEnter ) ;
2011-11-29 15:30:05 +01:00
}
2012-02-04 19:27:26 +01:00
//sets events dynamically for the fade editor.
2012-03-30 16:04:00 +02:00
function setFadeEvents ( ) {
2012-08-14 23:10:31 +02:00
var temp = $ ( '#spl_sortable' ) ;
2012-08-22 19:58:13 +02:00
temp . on ( "focusout" , ".spl_fade_in span" , changeFadeIn ) ;
2012-08-14 23:10:31 +02:00
temp . on ( "keydown" , ".spl_fade_in span" , submitOnEnter ) ;
2012-08-22 19:58:13 +02:00
temp . on ( "focusout" , ".spl_fade_out span" , changeFadeOut ) ;
2012-08-14 23:10:31 +02:00
temp . on ( "keydown" , ".spl_fade_out span" , submitOnEnter ) ;
2011-01-27 00:31:59 +01:00
}
2012-02-04 15:52:31 +01:00
2012-03-19 14:09:05 +01:00
function initialEvents ( ) {
2012-03-30 16:04:00 +02:00
var cachedDescription ;
2012-03-19 14:09:05 +01:00
//main playlist fades events
2012-03-30 16:04:00 +02:00
$pl . on ( "click" , "#spl_crossfade" , function ( ) {
2012-07-25 17:00:46 +02:00
var lastMod = getModified ( ) ,
2012-07-30 23:18:33 +02:00
type = $ ( '#obj_type' ) . val ( ) ;
2012-02-04 15:52:31 +01:00
if ( $ ( this ) . hasClass ( "ui-state-active" ) ) {
$ ( this ) . removeClass ( "ui-state-active" ) ;
2012-03-30 16:04:00 +02:00
$pl . find ( "#crossfade_main" ) . hide ( ) ;
2012-02-04 15:52:31 +01:00
}
else {
$ ( this ) . addClass ( "ui-state-active" ) ;
2013-01-14 22:00:38 +01:00
var url = baseUrl + 'Playlist/get-playlist-fades' ;
2012-07-30 23:18:33 +02:00
$ . post ( url ,
2012-10-19 17:09:34 +02:00
{ format : "json" , modified : lastMod , type : type } ,
2012-02-20 18:24:04 +01:00
function ( json ) {
if ( json . error !== undefined ) {
playlistError ( json ) ;
}
else {
2012-08-09 17:03:57 +02:00
var fadeIn = $pl . find ( "span.spl_main_fade_in" ) ;
var fadeOut = $pl . find ( "span.spl_main_fade_out" ) ;
if ( json . fadeIn == null ) {
fadeIn . parent ( ) . prev ( ) . hide ( ) ;
fadeIn . hide ( ) ;
} else {
fadeIn . parent ( ) . prev ( ) . show ( ) ;
fadeIn . show ( ) ;
fadeIn . empty ( ) . append ( json . fadeIn ) ;
}
if ( json . fadeOut == null ) {
fadeOut . parent ( ) . prev ( ) . hide ( ) ;
fadeOut . hide ( ) ;
} else {
fadeOut . parent ( ) . prev ( ) . show ( ) ;
fadeOut . show ( ) ;
fadeOut . empty ( ) . append ( json . fadeOut ) ;
}
2012-08-17 18:56:45 +02:00
if ( json . fadeIn != null || json . fadeOut != null ) {
$pl . find ( "#crossfade_main" ) . show ( ) ;
}
2012-02-20 18:24:04 +01:00
}
} ) ;
2012-02-04 15:52:31 +01:00
}
} ) ;
2012-03-19 14:09:05 +01:00
2012-03-30 16:04:00 +02:00
$pl . on ( "blur" , "span.spl_main_fade_in" , function ( event ) {
2012-02-04 15:52:31 +01:00
event . stopPropagation ( ) ;
2011-02-09 22:53:11 +01:00
2013-01-14 22:00:38 +01:00
var url = baseUrl + "Playlist/set-playlist-fades" ,
2012-02-20 18:24:04 +01:00
span = $ ( this ) ,
fadeIn = $ . trim ( span . text ( ) ) ,
2012-07-25 17:00:46 +02:00
lastMod = getModified ( ) ,
type = $ ( '#obj_type' ) . val ( ) ;
2012-02-20 18:24:04 +01:00
if ( ! isFadeValid ( fadeIn ) ) {
2012-11-20 17:16:10 +01:00
showError ( span , $ . i18n . _ ( "please put in a time in seconds '00 (.0)'" ) ) ;
2011-02-08 22:10:48 +01:00
return ;
}
2012-02-20 18:24:04 +01:00
$ . post ( url ,
2012-07-25 17:00:46 +02:00
{ format : "json" , fadeIn : fadeIn , modified : lastMod , type : type } ,
2012-02-20 18:24:04 +01:00
function ( json ) {
hideError ( span ) ;
2012-03-19 14:09:05 +01:00
if ( json . modified !== undefined ) {
setModified ( json . modified ) ;
}
2012-02-20 18:24:04 +01:00
} ) ;
2011-02-08 22:10:48 +01:00
} ) ;
2012-03-30 16:04:00 +02:00
$pl . on ( "blur" , "span.spl_main_fade_out" , function ( event ) {
2012-02-04 15:52:31 +01:00
event . stopPropagation ( ) ;
2011-02-08 22:10:48 +01:00
2013-01-14 22:00:38 +01:00
var url = baseUrl + "Playlist/set-playlist-fades" ,
2012-02-20 18:24:04 +01:00
span = $ ( this ) ,
fadeOut = $ . trim ( span . text ( ) ) ,
2012-07-25 17:00:46 +02:00
lastMod = getModified ( ) ,
type = $ ( '#obj_type' ) . val ( ) ;
2011-02-08 22:10:48 +01:00
2012-03-19 14:09:05 +01:00
if ( ! isFadeValid ( fadeOut ) ) {
2012-11-20 17:16:10 +01:00
showError ( span , $ . i18n . _ ( "please put in a time in seconds '00 (.0)'" ) ) ;
2011-02-08 22:10:48 +01:00
return ;
}
2012-02-20 18:24:04 +01:00
$ . post ( url ,
2012-07-25 17:00:46 +02:00
{ format : "json" , fadeOut : fadeOut , modified : lastMod , type : type } ,
2012-02-20 18:24:04 +01:00
function ( json ) {
hideError ( span ) ;
2012-03-19 14:09:05 +01:00
if ( json . modified !== undefined ) {
setModified ( json . modified ) ;
}
2012-02-20 18:24:04 +01:00
} ) ;
2011-02-08 22:10:48 +01:00
} ) ;
2012-03-30 16:04:00 +02:00
$pl . on ( "keydown" , "span.spl_main_fade_in, span.spl_main_fade_out" , submitOnEnter ) ;
2011-02-08 00:44:42 +01:00
2012-03-30 16:04:00 +02:00
$pl . on ( "click" , "#crossfade_main > .ui-icon-closethick" , function ( ) {
$pl . find ( "#spl_crossfade" ) . removeClass ( "ui-state-active" ) ;
$pl . find ( "#crossfade_main" ) . hide ( ) ;
2012-02-04 15:52:31 +01:00
} ) ;
2012-03-19 14:09:05 +01:00
//end main playlist fades.
//edit playlist name event
2012-03-30 16:04:00 +02:00
$pl . on ( "keydown" , "#playlist_name_display" , submitOnEnter ) ;
$pl . on ( "blur" , "#playlist_name_display" , editName ) ;
2012-03-19 14:09:05 +01:00
//edit playlist description events
2012-03-30 16:04:00 +02:00
$pl . on ( "click" , "legend" , function ( ) {
2012-03-19 14:21:34 +01:00
var $fs = $ ( this ) . parents ( "fieldset" ) ;
2012-03-19 14:09:05 +01:00
if ( $fs . hasClass ( "closed" ) ) {
cachedDescription = $fs . find ( "textarea" ) . val ( ) ;
$fs . removeClass ( "closed" ) ;
}
else {
$fs . addClass ( "closed" ) ;
}
} ) ;
2012-11-13 23:31:30 +01:00
$pl . on ( "click" , 'button[id="playlist_shuffle_button"]' , function ( ) {
obj _id = $ ( 'input[id="obj_id"]' ) . val ( ) ;
2013-01-14 22:00:38 +01:00
url = baseUrl + "Playlist/shuffle" ;
2012-11-13 23:31:30 +01:00
enableLoadingIcon ( ) ;
$ . post ( url , { format : "json" , obj _id : obj _id } , function ( data ) {
var json = $ . parseJSON ( data )
if ( json . error !== undefined ) {
alert ( json . error ) ;
}
AIRTIME . playlist . fnOpenPlaylist ( json ) ;
if ( json . result == "0" ) {
2013-01-10 20:22:25 +01:00
$pl . find ( '.success' ) . text ( $ . i18n . _ ( 'Playlist shuffled' ) ) ;
2012-11-13 23:31:30 +01:00
$pl . find ( '.success' ) . show ( ) ;
}
disableLoadingIcon ( ) ;
2012-11-20 21:05:09 +01:00
setTimeout ( removeSuccessMsg , 5000 ) ;
2012-11-13 23:31:30 +01:00
} ) ;
} )
2012-08-01 21:37:50 +02:00
2012-07-19 00:27:39 +02:00
$pl . on ( "click" , "#webstream_save" , function ( ) {
//get all fields and POST to server
//description
//stream url
//default_length
//playlist name
2012-08-21 16:33:36 +02:00
var id = $pl . find ( "#obj_id" ) . attr ( "value" ) ;
2012-07-19 00:27:39 +02:00
var description = $pl . find ( "#description" ) . val ( ) ;
var streamurl = $pl . find ( "#streamurl-element input" ) . val ( ) ;
var length = $pl . find ( "#streamlength-element input" ) . val ( ) ;
var name = $pl . find ( "#playlist_name_display" ) . text ( ) ;
2012-08-02 21:45:15 +02:00
//hide any previous errors (if any)
$ ( "#side_playlist .errors" ) . empty ( ) . hide ( ) ;
2012-07-19 00:27:39 +02:00
2013-01-14 22:00:38 +01:00
var url = baseUrl + 'Webstream/save' ;
2012-07-19 00:27:39 +02:00
$ . post ( url ,
2012-08-03 21:59:34 +02:00
{ format : "json" , id : id , description : description , url : streamurl , length : length , name : name } ,
2012-08-01 21:37:50 +02:00
function ( json ) {
2012-08-02 21:45:15 +02:00
if ( json . analysis ) {
for ( var s in json . analysis ) {
var field = json . analysis [ s ] ;
if ( ! field [ 0 ] ) {
2012-11-27 17:59:55 +01:00
var elemId = "#" + s + "-error" ;
2012-08-02 21:45:15 +02:00
var $div = $ ( "#side_playlist " + elemId ) . text ( field [ 1 ] ) . show ( ) ;
}
}
} else {
var $status = $ ( "#side_playlist .status" ) ;
$status . html ( json . statusMessage ) ;
$status . show ( ) ;
setTimeout ( function ( ) { $status . fadeOut ( "slow" , function ( ) { $status . empty ( ) } ) } , 5000 ) ;
2012-08-16 23:49:07 +02:00
2012-08-21 16:33:36 +02:00
var $ws _id = $ ( "#obj_id" ) ;
2012-08-16 23:49:07 +02:00
$ws _id . attr ( "value" , json . streamId ) ;
2012-08-17 23:29:17 +02:00
var $ws _id = $ ( "#ws_delete" ) ;
$ws _id . show ( ) ;
2012-08-31 19:01:22 +02:00
var length = $ ( "#side_playlist #ws_length" ) ;
length . text ( json . length ) ;
2012-08-08 01:49:26 +02:00
//redraw the library to show the new webstream
redrawLib ( ) ;
2012-08-02 21:45:15 +02:00
}
2012-08-01 21:37:50 +02:00
} ) ;
2012-07-19 00:27:39 +02:00
2012-08-09 23:23:52 +02:00
} ) ;
$ ( '#save_button' ) . live ( "click" , function ( event ) {
/ * S m a r t b l o c k s : g e t n a m e , d e s c r i p t i o n , a n d c r i t e r i a
* Playlists : get name , description
* /
var criteria = $ ( 'form' ) . serializeArray ( ) ,
block _name = $ ( '#playlist_name_display' ) . text ( ) ,
block _desc = $ ( 'textarea[name="description"]' ) . val ( ) ,
2013-01-14 22:00:38 +01:00
save _action = baseUrl + 'Playlist/save' ,
2012-08-09 23:23:52 +02:00
obj _id = $ ( 'input[id="obj_id"]' ) . val ( ) ,
obj _type = $ ( '#obj_type' ) . val ( ) ,
lastMod = getModified ( ) ,
dt = $ ( 'table[id="library_display"]' ) . dataTable ( ) ;
enableLoadingIcon ( ) ;
$ . post ( save _action ,
2012-08-15 17:36:41 +02:00
{ format : "json" , data : criteria , name : block _name , description : block _desc , obj _id : obj _id , type : obj _type , modified : lastMod } ,
2012-08-09 23:23:52 +02:00
function ( data ) {
var json = $ . parseJSON ( data ) ;
2012-09-06 17:48:00 +02:00
if ( json . error !== undefined ) {
alert ( json . error ) ;
}
2012-09-10 23:53:55 +02:00
if ( json . html !== undefined ) {
AIRTIME . playlist . fnOpenPlaylist ( json ) ;
}
2012-08-09 23:23:52 +02:00
setModified ( json . modified ) ;
if ( obj _type == "block" ) {
callback ( data , "save" ) ;
} else {
2012-11-20 17:16:10 +01:00
$ ( '.success' ) . text ( $ . i18n . _ ( 'Playlist saved' ) ) ;
2012-08-09 23:23:52 +02:00
$ ( '.success' ) . show ( ) ;
setTimeout ( removeSuccessMsg , 5000 ) ;
dt . fnStandingRedraw ( ) ;
}
setFadeIcon ( ) ;
disableLoadingIcon ( ) ;
}
) ;
} ) ;
2013-01-23 18:09:21 +01:00
$ ( "#pl-bl-clear-content" ) . live ( "click" , function ( event ) {
var sUrl = baseUrl + "playlist/empty-content" ,
oData = { } ;
playlistRequest ( sUrl , oData ) ;
} ) ;
2012-03-19 14:09:05 +01:00
}
2012-03-30 16:04:00 +02:00
function setUpPlaylist ( ) {
var sortableConf ;
2011-11-29 15:30:05 +01:00
2012-02-04 19:27:26 +01:00
sortableConf = ( function ( ) {
2012-02-28 13:13:40 +01:00
var aReceiveItems ,
2012-02-20 20:44:35 +01:00
html ,
2012-02-04 19:27:26 +01:00
fnReceive ,
fnUpdate ;
fnReceive = function ( event , ui ) {
2012-02-28 23:52:20 +01:00
var aItems = [ ] ,
aSelected ,
i ,
length ;
2012-05-11 11:04:16 +02:00
AIRTIME . library . addToChosen ( ui . item ) ;
2012-02-28 23:52:20 +01:00
//filter out anything that isn't an audiofile.
2012-04-02 19:03:11 +02:00
aSelected = AIRTIME . library . getSelectedData ( ) ;
2012-02-28 13:13:40 +01:00
2012-02-28 23:52:20 +01:00
for ( i = 0 , length = aSelected . length ; i < length ; i ++ ) {
2012-07-26 22:16:07 +02:00
aItems . push ( new Array ( aSelected [ i ] . id , aSelected [ i ] . ftype ) ) ;
2012-02-28 23:52:20 +01:00
}
2012-02-28 13:13:40 +01:00
aReceiveItems = aItems ;
2012-02-20 20:44:35 +01:00
html = ui . helper . html ( ) ;
2012-05-10 14:19:36 +02:00
AIRTIME . library . removeFromChosen ( ui . item ) ;
2012-02-04 19:27:26 +01:00
} ;
fnUpdate = function ( event , ui ) {
var prev ,
2012-02-20 20:44:35 +01:00
aItems = [ ] ,
2012-02-04 19:27:26 +01:00
iAfter ,
sAddType ;
prev = ui . item . prev ( ) ;
if ( prev . hasClass ( "spl_empty" ) || prev . length === 0 ) {
iAfter = undefined ;
sAddType = 'before' ;
}
else {
iAfter = parseInt ( prev . attr ( "id" ) . split ( "_" ) . pop ( ) , 10 ) ;
sAddType = 'after' ;
}
//item was dragged in from library datatable
2012-02-28 13:13:40 +01:00
if ( aReceiveItems !== undefined ) {
2012-02-20 20:44:35 +01:00
2012-03-30 16:04:00 +02:00
$pl . find ( "tr.ui-draggable" )
2012-02-20 20:44:35 +01:00
. after ( html )
. empty ( ) ;
2012-02-28 13:13:40 +01:00
aItems = aReceiveItems ;
aReceiveItems = undefined ;
2012-02-20 20:44:35 +01:00
AIRTIME . playlist . fnAddItems ( aItems , iAfter , sAddType ) ;
2012-02-04 19:27:26 +01:00
}
//item was reordered.
else {
2012-02-20 20:44:35 +01:00
aItems . push ( parseInt ( ui . item . attr ( "id" ) . split ( "_" ) . pop ( ) , 10 ) ) ;
AIRTIME . playlist . fnMoveItems ( aItems , iAfter ) ;
2012-02-04 19:27:26 +01:00
}
} ;
return {
items : 'li' ,
2012-02-27 23:58:08 +01:00
//hack taken from
//http://stackoverflow.com/questions/2150002/jquery-ui-sortable-how-can-i-change-the-appearance-of-the-placeholder-object
placeholder : {
element : function ( currentItem ) {
2012-02-28 13:13:40 +01:00
2012-02-27 23:58:08 +01:00
return $ ( '<li class="placeholder ui-state-highlight"></li>' ) [ 0 ] ;
} ,
update : function ( container , p ) {
return ;
}
} ,
2012-02-04 19:27:26 +01:00
forcePlaceholderSize : true ,
handle : 'div.list-item-container' ,
start : function ( event , ui ) {
2012-02-27 23:58:08 +01:00
ui . placeholder . height ( 56 ) ;
2012-02-04 19:27:26 +01:00
} ,
receive : fnReceive ,
update : fnUpdate
} ;
} ( ) ) ;
2012-03-30 16:04:00 +02:00
$pl . find ( "#spl_sortable" ) . sortable ( sortableConf ) ;
2012-09-13 23:09:10 +02:00
AIRTIME . playlist . validatePlaylistElements ( ) ;
2012-02-04 19:27:26 +01:00
}
2011-09-08 21:09:12 +02:00
2012-02-04 19:27:26 +01:00
mod . fnNew = function ( ) {
2013-01-14 22:00:38 +01:00
var url = baseUrl + 'Playlist/new' ;
2010-12-22 05:33:58 +01:00
2012-02-04 19:27:26 +01:00
stopAudioPreview ( ) ;
2012-02-20 18:24:04 +01:00
$ . post ( url ,
2012-07-25 17:00:46 +02:00
{ format : "json" , type : 'playlist' } ,
2012-02-20 18:24:04 +01:00
function ( json ) {
openPlaylist ( json ) ;
redrawLib ( ) ;
} ) ;
2012-02-07 14:58:16 +01:00
} ;
2012-07-25 04:24:08 +02:00
mod . fnWsNew = function ( ) {
2013-01-14 22:00:38 +01:00
var url = baseUrl + 'Webstream/new' ;
2012-07-25 04:24:08 +02:00
stopAudioPreview ( ) ;
$ . post ( url ,
{ format : "json" } ,
function ( json ) {
openPlaylist ( json ) ;
redrawLib ( ) ;
} ) ;
} ;
2011-11-29 15:30:05 +01:00
2012-10-19 17:09:34 +02:00
2012-07-25 17:00:46 +02:00
mod . fnNewBlock = function ( ) {
2013-01-14 22:00:38 +01:00
var url = baseUrl + 'Playlist/new' ;
2012-07-25 17:00:46 +02:00
stopAudioPreview ( ) ;
$ . post ( url ,
{ format : "json" , type : 'block' } ,
function ( json ) {
openPlaylist ( json ) ;
redrawLib ( ) ;
} ) ;
} ;
2012-08-03 21:59:34 +02:00
mod . fnEdit = function ( id , type , url ) {
2012-02-05 18:19:22 +01:00
stopAudioPreview ( ) ;
2012-02-04 15:52:31 +01:00
2012-02-05 18:19:22 +01:00
$ . post ( url ,
2012-07-25 23:08:22 +02:00
{ format : "json" , id : id , type : type } ,
2012-02-05 18:19:22 +01:00
function ( json ) {
openPlaylist ( json ) ;
2012-02-20 18:24:04 +01:00
} ) ;
2012-02-07 14:58:16 +01:00
} ;
2012-08-03 21:59:34 +02:00
2011-11-29 15:30:05 +01:00
2012-02-05 18:19:22 +01:00
mod . fnDelete = function ( plid ) {
2012-02-04 19:27:26 +01:00
var url , id , lastMod ;
2012-02-04 15:52:31 +01:00
2012-02-04 19:27:26 +01:00
stopAudioPreview ( ) ;
2012-02-05 18:19:22 +01:00
id = ( plid === undefined ) ? getId ( ) : plid ;
2012-07-25 17:00:46 +02:00
lastMod = getModified ( ) ;
type = $ ( '#obj_type' ) . val ( ) ;
2013-01-14 22:00:38 +01:00
url = baseUrl + 'Playlist/delete' ;
2012-02-04 19:27:26 +01:00
$ . post ( url ,
2012-07-25 17:00:46 +02:00
{ format : "json" , ids : id , modified : lastMod , type : type } ,
2012-02-04 19:27:26 +01:00
function ( json ) {
openPlaylist ( json ) ;
redrawLib ( ) ;
2012-02-20 18:24:04 +01:00
} ) ;
2012-02-07 14:58:16 +01:00
} ;
2012-08-21 00:35:10 +02:00
mod . fnWsDelete = function ( wsid ) {
var url , id , lastMod ;
stopAudioPreview ( ) ;
id = ( wsid === undefined ) ? getId ( ) : wsid ;
lastMod = getModified ( ) ;
type = $ ( '#obj_type' ) . val ( ) ;
2013-01-14 22:00:38 +01:00
url = baseUrl + 'Webstream/delete' ;
2012-08-21 00:35:10 +02:00
$ . post ( url ,
{ format : "json" , ids : id , modified : lastMod , type : type } ,
function ( json ) {
openPlaylist ( json ) ;
redrawLib ( ) ;
} ) ;
} ;
2011-11-29 15:30:05 +01:00
2012-05-04 15:00:18 +02:00
mod . disableUI = function ( ) {
$lib . block ( {
message : "" ,
theme : true ,
applyPlatformOpacityRules : false
} ) ;
$pl . block ( {
message : "" ,
theme : true ,
applyPlatformOpacityRules : false
} ) ;
} ;
2012-07-16 23:18:37 +02:00
mod . fnOpenPlaylist = function ( json ) {
openPlaylist ( json ) ;
} ;
2012-05-04 15:00:18 +02:00
mod . enableUI = function ( ) {
$lib . unblock ( ) ;
$pl . unblock ( ) ;
//Block UI changes the postion to relative to display the messages.
$lib . css ( "position" , "static" ) ;
$pl . css ( "position" , "static" ) ;
2012-07-18 17:52:09 +02:00
setupUI ( ) ;
2012-05-04 15:00:18 +02:00
} ;
function playlistResponse ( json ) {
if ( json . error !== undefined ) {
playlistError ( json ) ;
}
else {
setPlaylistContent ( json ) ;
2012-08-08 21:29:09 +02:00
setFadeIcon ( ) ;
2012-05-04 15:00:18 +02:00
}
mod . enableUI ( ) ;
}
2012-03-14 17:50:48 +01:00
function playlistRequest ( sUrl , oData ) {
2012-07-25 17:00:46 +02:00
var lastMod ,
obj _type = $ ( '#obj_type' ) . val ( ) ;
2012-02-04 19:27:26 +01:00
2012-05-04 15:00:18 +02:00
mod . disableUI ( ) ;
2012-03-14 17:50:48 +01:00
2012-05-04 15:00:18 +02:00
lastMod = getModified ( ) ;
2012-03-14 17:50:48 +01:00
2012-05-04 15:00:18 +02:00
oData [ "modified" ] = lastMod ;
2012-07-25 17:00:46 +02:00
oData [ "obj_type" ] = obj _type ;
2012-05-04 15:00:18 +02:00
oData [ "format" ] = "json" ;
2012-03-14 17:50:48 +01:00
$ . post (
sUrl ,
oData ,
2012-05-04 15:00:18 +02:00
playlistResponse
2012-03-14 17:50:48 +01:00
) ;
}
mod . fnAddItems = function ( aItems , iAfter , sAddType ) {
2013-01-14 22:00:38 +01:00
var sUrl = baseUrl + "playlist/add-items" ;
2012-07-20 23:38:11 +02:00
oData = { "aItems" : aItems , "afterItem" : iAfter , "type" : sAddType } ;
2012-03-14 17:50:48 +01:00
playlistRequest ( sUrl , oData ) ;
2012-02-04 19:27:26 +01:00
} ;
2011-11-29 16:24:41 +01:00
2012-02-04 19:27:26 +01:00
mod . fnMoveItems = function ( aIds , iAfter ) {
2013-01-14 22:00:38 +01:00
var sUrl = baseUrl + "playlist/move-items" ,
2012-03-14 17:50:48 +01:00
oData = { "ids" : aIds , "afterItem" : iAfter } ;
2012-02-04 19:27:26 +01:00
2012-03-14 17:50:48 +01:00
playlistRequest ( sUrl , oData ) ;
2012-02-04 19:27:26 +01:00
} ;
2012-02-04 15:52:31 +01:00
2012-02-04 19:27:26 +01:00
mod . fnDeleteItems = function ( aItems ) {
2013-01-14 22:00:38 +01:00
var sUrl = baseUrl + "playlist/delete-items" ,
2012-03-14 17:50:48 +01:00
oData = { "ids" : aItems } ;
2012-02-04 19:27:26 +01:00
2012-03-14 17:50:48 +01:00
playlistRequest ( sUrl , oData ) ;
2012-02-04 19:27:26 +01:00
} ;
2012-02-04 15:52:31 +01:00
2012-02-04 21:26:21 +01:00
mod . init = function ( ) {
2012-09-14 21:49:39 +02:00
/ *
2012-07-25 17:00:46 +02:00
$ . contextMenu ( {
2012-07-26 23:51:47 +02:00
selector : '#spl_new, #ws_new' ,
2012-07-25 17:00:46 +02:00
trigger : "left" ,
ignoreRightClick : true ,
items : {
"sp" : { name : "New Playlist" , callback : AIRTIME . playlist . fnNew } ,
2012-08-20 23:17:48 +02:00
"sb" : { name : "New Smart Block" , callback : AIRTIME . playlist . fnNewBlock } ,
2012-07-26 23:51:47 +02:00
"ws" : { name : "New Webstream" , callback : AIRTIME . playlist . fnWsNew }
2012-07-25 17:00:46 +02:00
}
} ) ;
2012-09-14 21:49:39 +02:00
* /
$ ( '#lib-new-pl' ) . live ( 'click' , function ( ) { AIRTIME . playlist . fnNew ( ) ; } ) ;
$ ( '#lib-new-bl' ) . live ( 'click' , function ( ) { AIRTIME . playlist . fnNewBlock ( ) ; } ) ;
$ ( '#lib-new-ws' ) . live ( 'click' , function ( ) { AIRTIME . playlist . fnWsNew ( ) ; } ) ;
2012-07-25 17:00:46 +02:00
/ *
2012-03-30 16:04:00 +02:00
$pl . delegate ( "#spl_new" ,
2012-07-25 17:00:46 +02:00
{ "click" : AIRTIME . playlist . fnNew } ) ; * /
2011-11-10 21:35:27 +01:00
2012-03-30 16:04:00 +02:00
$pl . delegate ( "#spl_delete" , { "click" : function ( ev ) {
2012-02-07 18:42:34 +01:00
AIRTIME . playlist . fnDelete ( ) ;
} } ) ;
2012-08-21 00:35:10 +02:00
$pl . delegate ( "#ws_delete" , { "click" : function ( ev ) {
AIRTIME . playlist . fnWsDelete ( ) ;
} } ) ;
2012-02-04 21:26:21 +01:00
2012-03-30 16:04:00 +02:00
setPlaylistEntryEvents ( ) ;
setCueEvents ( ) ;
setFadeEvents ( ) ;
2012-08-17 20:30:46 +02:00
setFadeIcon ( ) ;
2012-02-04 21:26:21 +01:00
2012-03-19 14:09:05 +01:00
initialEvents ( ) ;
2012-03-30 16:04:00 +02:00
setUpPlaylist ( ) ;
} ;
function setWidgetSize ( ) {
viewport = AIRTIME . utilities . findViewportDimensions ( ) ;
widgetHeight = viewport . height - 185 ;
2012-04-03 14:58:10 +02:00
width = Math . floor ( viewport . width - 80 ) ;
2012-03-30 16:33:43 +02:00
var libTableHeight = widgetHeight - 130 ;
2012-03-30 16:04:00 +02:00
$lib . height ( widgetHeight )
2012-03-30 16:33:43 +02:00
. find ( ".dataTables_scrolling" )
. css ( "max-height" , libTableHeight )
. end ( )
2012-03-30 16:04:00 +02:00
. width ( Math . floor ( width * 0.55 ) ) ;
$pl . height ( widgetHeight )
. width ( Math . floor ( width * 0.45 ) ) ;
}
mod . onReady = function ( ) {
$lib = $ ( "#library_content" ) ;
$pl = $ ( "#side_playlist" ) ;
setWidgetSize ( ) ;
AIRTIME . library . libraryInit ( ) ;
AIRTIME . playlist . init ( ) ;
$pl . find ( ".ui-icon-alert" ) . qtip ( {
content : {
2012-11-20 17:16:10 +01:00
text : $ . i18n . _ ( "Airtime is unsure about the status of this file. This can happen when the file is on a remote drive that is unaccessible or the file is in a directory that isn't 'watched' anymore." )
2012-03-30 16:04:00 +02:00
} ,
position : {
adjust : {
resize : true ,
method : "flip flip"
} ,
at : "right center" ,
my : "left top" ,
viewport : $ ( window )
} ,
style : {
classes : "ui-tooltip-dark"
} ,
show : 'mouseover' ,
hide : 'mouseout'
} ) ;
} ;
mod . onResize = function ( ) {
2012-05-04 18:13:01 +02:00
clearTimeout ( resizeTimeout ) ;
resizeTimeout = setTimeout ( setWidgetSize , 100 ) ;
2012-02-07 14:58:16 +01:00
} ;
2011-11-29 15:30:05 +01:00
2012-02-04 19:27:26 +01:00
return AIRTIME ;
2011-11-29 15:30:05 +01:00
2012-02-04 19:27:26 +01:00
} ( AIRTIME || { } ) ) ;
2011-12-02 17:49:48 +01:00
2011-05-17 23:30:17 +02:00
2012-03-30 16:04:00 +02:00
$ ( document ) . ready ( AIRTIME . playlist . onReady ) ;
$ ( window ) . resize ( AIRTIME . playlist . onResize ) ;