2012-03-08 18:30:56 +01:00
var AIRTIME = ( function ( AIRTIME ) {
var mod ;
if ( AIRTIME . history === undefined ) {
AIRTIME . history = { } ;
}
mod = AIRTIME . history ;
2013-07-18 07:31:20 +02:00
var $historyContentDiv ;
var oTableTools = {
2013-08-13 00:18:33 +02:00
"sSwfPath" : baseUrl + "js/datatables/plugin/TableTools-2.1.5/swf/copy_csv_xls_pdf.swf" ,
2013-07-18 07:31:20 +02:00
"aButtons" : [
{
"sExtends" : "copy" ,
"fnComplete" : function ( nButton , oConfig , oFlash , text ) {
var lines = text . split ( '\n' ) . length ,
len = this . s . dt . nTFoot === null ? lines - 1 : lines - 2 ,
plural = ( len == 1 ) ? "" : "s" ;
alert ( sprintf ( $ . i18n . _ ( 'Copied %s row%s to the clipboard' ) , len , plural ) ) ;
2013-08-22 21:19:38 +02:00
} ,
//set because only the checkbox row is not sortable.
"mColumns" : "sortable"
2013-07-18 07:31:20 +02:00
} ,
{
"sExtends" : "csv" ,
2013-08-22 21:19:38 +02:00
"fnClick" : setFlashFileName ,
//set because only the checkbox row is not sortable.
"mColumns" : "sortable"
2013-07-18 07:31:20 +02:00
} ,
{
"sExtends" : "pdf" ,
2013-08-22 21:19:38 +02:00
"fnClick" : setFlashFileName ,
"sPdfOrientation" : "landscape" ,
//set because only the checkbox row is not sortable.
"mColumns" : "sortable"
2013-07-18 07:31:20 +02:00
} ,
{
"sExtends" : "print" ,
2013-08-22 21:19:38 +02:00
"sInfo" : sprintf ( $ . i18n . _ ( "%sPrint view%sPlease use your browser's print function to print this table. Press escape when finished." ) , "<h6>" , "</h6><p>" ) ,
//set because only the checkbox row is not sortable.
"mColumns" : "sortable"
2013-07-18 07:31:20 +02:00
}
]
} ;
2013-07-24 00:01:43 +02:00
var lengthMenu = [ [ 10 , 25 , 50 , 100 , 500 , - 1 ] , [ 10 , 25 , 50 , 100 , 500 , $ . i18n . _ ( "All" ) ] ] ;
2013-07-18 07:31:20 +02:00
2013-07-24 00:01:43 +02:00
var sDom = 'l<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>' ;
2013-07-18 07:31:20 +02:00
2013-08-20 23:23:15 +02:00
var selectedLogItems = { } ;
2013-08-29 01:37:46 +02:00
var dateStartId = "#his_date_start" ,
timeStartId = "#his_time_start" ,
dateEndId = "#his_date_end" ,
timeEndId = "#his_time_end" ;
2013-08-20 23:23:15 +02:00
function getSelectedLogItems ( ) {
var items = Object . keys ( selectedLogItems ) ;
return items ;
}
2013-08-23 19:31:37 +02:00
function addSelectedLogItem ( $el ) {
var id ;
$el . addClass ( "his-selected" ) ;
id = $el . data ( "his-id" ) ;
2013-08-20 23:23:15 +02:00
selectedLogItems [ id ] = "" ;
}
2013-08-23 19:31:37 +02:00
function removeSelectedLogItem ( $el ) {
var id ;
$el . removeClass ( "his-selected" ) ;
id = $el . data ( "his-id" ) ;
2013-08-20 23:23:15 +02:00
delete selectedLogItems [ id ] ;
}
function emptySelectedLogItems ( ) {
2013-08-28 19:42:33 +02:00
var $inputs = $historyContentDiv . find ( ".his_checkbox" ) . find ( "input" ) ;
2013-08-23 19:31:37 +02:00
$inputs . prop ( 'checked' , false ) ;
$inputs . parents ( "tr" ) . removeClass ( "his-selected" ) ;
2013-08-23 19:18:17 +02:00
2013-08-20 23:23:15 +02:00
selectedLogItems = { } ;
}
2013-08-23 19:18:17 +02:00
function selectCurrentPage ( ) {
var $inputs = $historyContentDiv . find ( ".his_checkbox" ) . find ( "input" ) ,
2013-08-28 19:42:33 +02:00
$tr ,
$input ;
2013-08-23 19:18:17 +02:00
$ . each ( $inputs , function ( index , input ) {
$input = $ ( input ) ;
$input . prop ( 'checked' , true ) ;
$tr = $input . parents ( "tr" ) ;
2013-08-23 19:31:37 +02:00
addSelectedLogItem ( $tr ) ;
2013-08-23 19:18:17 +02:00
} ) ;
}
function deselectCurrentPage ( ) {
var $inputs = $historyContentDiv . find ( ".his_checkbox" ) . find ( "input" ) ,
2013-08-28 19:42:33 +02:00
$tr ,
$input ;
2013-08-23 19:18:17 +02:00
$ . each ( $inputs , function ( index , input ) {
$input = $ ( input ) ;
$input . prop ( 'checked' , false ) ;
$tr = $input . parents ( "tr" ) ;
2013-08-23 19:31:37 +02:00
removeSelectedLogItem ( $tr ) ;
2013-08-23 19:18:17 +02:00
} ) ;
}
2013-07-18 07:31:20 +02:00
function getFileName ( ext ) {
var filename = $ ( "#his_date_start" ) . val ( ) + "_" + $ ( "#his_time_start" ) . val ( ) + "m--" + $ ( "#his_date_end" ) . val ( ) + "_" + $ ( "#his_time_end" ) . val ( ) + "m" ;
filename = filename . replace ( /:/g , "h" ) ;
2013-07-09 00:00:02 +02:00
2013-07-18 07:31:20 +02:00
if ( ext == "pdf" ) {
filename = filename + ".pdf" ;
}
else {
filename = filename + ".csv" ;
}
return filename ;
}
function setFlashFileName ( nButton , oConfig , oFlash ) {
var filename = getFileName ( oConfig . sExtends ) ;
oFlash . setFileName ( filename ) ;
if ( oConfig . sExtends == "pdf" ) {
this . fnSetText ( oFlash ,
2013-08-22 21:19:38 +02:00
"title:" + this . fnGetTitle ( oConfig ) + "\n" +
2013-07-18 07:31:20 +02:00
"message:" + oConfig . sPdfMessage + "\n" +
"colWidth:" + this . fnCalcColRatios ( oConfig ) + "\n" +
"orientation:" + oConfig . sPdfOrientation + "\n" +
"size:" + oConfig . sPdfSize + "\n" +
"--/TableToolsOpts--\n" +
this . fnGetTableData ( oConfig ) ) ;
}
else {
this . fnSetText ( oFlash , this . fnGetTableData ( oConfig ) ) ;
}
}
/* This callback can be used for all history tables */
function fnServerData ( sSource , aoData , fnCallback ) {
if ( fnServerData . hasOwnProperty ( "start" ) ) {
aoData . push ( { name : "start" , value : fnServerData . start } ) ;
}
if ( fnServerData . hasOwnProperty ( "end" ) ) {
aoData . push ( { name : "end" , value : fnServerData . end } ) ;
}
aoData . push ( { name : "format" , value : "json" } ) ;
$ . ajax ( {
"dataType" : 'json' ,
"type" : "GET" ,
"url" : sSource ,
"data" : aoData ,
"success" : fnCallback
} ) ;
}
2013-08-20 05:19:13 +02:00
function createToolbarButtons ( $el ) {
var $menu = $ ( "<div class='btn-toolbar' />" ) ;
$menu . append ( "<div class='btn-group'>" +
"<button class='btn btn-small dropdown-toggle' data-toggle='dropdown'>" +
$ . i18n . _ ( "Select" ) + " <span class='caret'></span>" +
"</button>" +
"<ul class='dropdown-menu'>" +
2013-08-23 19:18:17 +02:00
"<li id='his-select-page'><a href='#'>" + $ . i18n . _ ( "Select this page" ) + "</a></li>" +
"<li id='his-dselect-page'><a href='#'>" + $ . i18n . _ ( "Deselect this page" ) + "</a></li>" +
"<li id='his-dselect-all'><a href='#'>" + $ . i18n . _ ( "Deselect all" ) + "</a></li>" +
2013-08-20 05:19:13 +02:00
"</ul>" +
"</div>" ) ;
$menu . append ( "<div class='btn-group'>" +
"<button class='btn btn-small' id='his_create'>" +
"<i class='icon-white icon-plus'></i>" +
$ . i18n . _ ( "Create Entry" ) +
"</button>" +
"</div>" ) ;
$menu . append ( "<div class='btn-group'>" +
"<button class='btn btn-small' id='his_trash'>" +
"<i class='icon-white icon-trash'></i>" +
"</button>" +
"</div>" ) ;
$el . append ( $menu ) ;
}
2013-07-18 07:31:20 +02:00
function aggregateHistoryTable ( ) {
var oTable ,
$historyTableDiv = $historyContentDiv . find ( "#history_table_aggregate" ) ,
2013-08-14 22:38:59 +02:00
columns ,
2013-07-18 07:31:20 +02:00
fnRowCallback ;
2013-07-09 00:00:02 +02:00
fnRowCallback = function ( nRow , aData , iDisplayIndex , iDisplayIndexFull ) {
2013-08-20 20:58:22 +02:00
var editUrl = baseUrl + "playouthistory/edit-file-item/id/" + aData . file _id ,
$nRow = $ ( nRow ) ;
2013-07-24 00:01:43 +02:00
2013-08-20 20:58:22 +02:00
$nRow . data ( 'url-edit' , editUrl ) ;
2012-03-12 11:47:25 +01:00
} ;
2012-03-08 18:30:56 +01:00
2013-08-14 22:38:59 +02:00
columns = JSON . parse ( localStorage . getItem ( 'datatables-historyfile-aoColumns' ) ) ;
2013-08-02 21:29:39 +02:00
2013-07-18 07:31:20 +02:00
oTable = $historyTableDiv . dataTable ( {
2012-03-08 18:30:56 +01:00
2013-08-02 21:29:39 +02:00
"aoColumns" : columns ,
2012-03-08 18:30:56 +01:00
"bProcessing" : true ,
"bServerSide" : true ,
2013-08-12 21:06:26 +02:00
"sAjaxSource" : baseUrl + "playouthistory/file-history-feed" ,
2012-03-08 18:30:56 +01:00
"sAjaxDataProp" : "history" ,
2012-03-12 11:47:25 +01:00
"fnServerData" : fnServerData ,
2013-07-09 00:00:02 +02:00
"fnRowCallback" : fnRowCallback ,
2012-11-27 18:17:59 +01:00
"oLanguage" : datatables _dict ,
2013-07-18 07:31:20 +02:00
"aLengthMenu" : lengthMenu ,
2013-08-22 21:45:09 +02:00
"iDisplayLength" : 25 ,
2012-03-08 18:30:56 +01:00
"sPaginationType" : "full_numbers" ,
"bJQueryUI" : true ,
2012-03-12 11:47:25 +01:00
"bAutoWidth" : true ,
2013-07-18 07:31:20 +02:00
"sDom" : sDom ,
"oTableTools" : oTableTools
2012-03-08 18:30:56 +01:00
} ) ;
2012-03-09 11:13:32 +01:00
oTable . fnSetFilteringDelay ( 350 ) ;
2013-07-18 07:31:20 +02:00
return oTable ;
}
function itemHistoryTable ( ) {
var oTable ,
$historyTableDiv = $historyContentDiv . find ( "#history_table_list" ) ,
2013-08-20 05:19:13 +02:00
$toolbar ,
2013-08-14 22:38:59 +02:00
columns ,
fnRowCallback ,
booleans = { } ,
i , c ;
columns = JSON . parse ( localStorage . getItem ( 'datatables-historyitem-aoColumns' ) ) ;
2013-07-31 23:38:48 +02:00
2013-08-14 22:38:59 +02:00
for ( i in columns ) {
c = columns [ i ] ;
if ( c [ "sDataType" ] === "boolean" ) {
booleans [ c [ "mDataProp" ] ] = c [ "sTitle" ] ;
}
}
2013-07-18 07:31:20 +02:00
fnRowCallback = function ( nRow , aData , iDisplayIndex , iDisplayIndexFull ) {
2013-08-20 20:58:22 +02:00
var editUrl = baseUrl + "playouthistory/edit-list-item/id/" + aData . history _id ,
deleteUrl = baseUrl + "playouthistory/delete-list-item/id/" + aData . history _id ,
2013-08-14 22:38:59 +02:00
emptyCheckBox = String . fromCharCode ( parseInt ( 2610 , 16 ) ) ,
checkedCheckBox = String . fromCharCode ( parseInt ( 2612 , 16 ) ) ,
b ,
text ,
$nRow = $ ( nRow ) ;
2013-08-20 05:19:13 +02:00
// add checkbox
$nRow . find ( 'td.his_checkbox' ) . html ( "<input type='checkbox' name='cb_" + aData . history _id + "'>" ) ;
2013-07-24 00:01:43 +02:00
2013-08-20 20:58:22 +02:00
$nRow . data ( 'his-id' , aData . history _id ) ;
$nRow . data ( 'url-edit' , editUrl ) ;
$nRow . data ( 'url-delete' , deleteUrl ) ;
2013-08-14 22:38:59 +02:00
for ( b in booleans ) {
text = aData [ b ] ? checkedCheckBox : emptyCheckBox ;
text = text + " " + booleans [ b ] ;
$nRow . find ( ".his_" + b ) . html ( text ) ;
}
2013-07-18 07:31:20 +02:00
} ;
2013-08-14 22:38:59 +02:00
2013-07-18 07:31:20 +02:00
oTable = $historyTableDiv . dataTable ( {
2013-07-31 23:38:48 +02:00
"aoColumns" : columns ,
2013-07-18 07:31:20 +02:00
"bProcessing" : true ,
"bServerSide" : true ,
"sAjaxSource" : baseUrl + "playouthistory/item-history-feed" ,
"sAjaxDataProp" : "history" ,
"fnServerData" : fnServerData ,
"fnRowCallback" : fnRowCallback ,
"oLanguage" : datatables _dict ,
"aLengthMenu" : lengthMenu ,
2013-08-22 21:45:09 +02:00
"iDisplayLength" : 25 ,
2013-07-18 07:31:20 +02:00
"sPaginationType" : "full_numbers" ,
"bJQueryUI" : true ,
"bAutoWidth" : true ,
"sDom" : sDom ,
"oTableTools" : oTableTools
} ) ;
oTable . fnSetFilteringDelay ( 350 ) ;
2013-08-20 05:19:13 +02:00
$toolbar = $historyTableDiv . parents ( ".dataTables_wrapper" ) . find ( ".fg-toolbar:first" ) ;
createToolbarButtons ( $toolbar ) ;
2013-08-23 19:18:17 +02:00
$ ( "#his-select-page" ) . click ( selectCurrentPage ) ;
$ ( "#his-dselect-page" ) . click ( deselectCurrentPage ) ;
$ ( "#his-dselect-all" ) . click ( emptySelectedLogItems ) ;
2012-03-12 11:47:25 +01:00
return oTable ;
2013-07-18 07:31:20 +02:00
}
2013-08-29 01:37:46 +02:00
function showSummaryList ( ) {
var url = baseUrl + "playouthistory/show-history-feed" ,
oRange = AIRTIME . utilities . fnGetScheduleRange ( dateStartId , timeStartId , dateEndId , timeEndId ) ,
data = {
format : "json" ,
start : oRange . start ,
end : oRange . end
} ;
$ . post ( url , data , function ( ) {
var x ;
} ) ;
}
2013-07-18 07:31:20 +02:00
mod . onReady = function ( ) {
2013-08-22 20:50:58 +02:00
var oBaseDatePickerSettings ,
2013-07-18 07:31:20 +02:00
oBaseTimePickerSettings ,
2013-07-24 00:01:43 +02:00
oTableAgg ,
oTableItem ,
2013-08-23 18:28:37 +02:00
$hisDialogEl ,
tabsInit = [
{
initialized : false ,
initialize : function ( ) {
oTableItem = itemHistoryTable ( ) ;
}
} ,
{
initialized : false ,
initialize : function ( ) {
oTableAgg = aggregateHistoryTable ( ) ;
}
2013-08-29 01:37:46 +02:00
} ,
{
initialized : false ,
initialize : function ( ) {
showSummaryList ( ) ;
}
2013-08-23 18:28:37 +02:00
}
] ;
2013-07-18 07:31:20 +02:00
$historyContentDiv = $ ( "#history_content" ) ;
2013-08-20 23:23:15 +02:00
function redrawTables ( ) {
2013-08-23 18:28:37 +02:00
oTableAgg && oTableAgg . fnDraw ( ) ;
oTableItem && oTableItem . fnDraw ( ) ;
2013-08-20 23:23:15 +02:00
}
2013-07-18 07:31:20 +02:00
function removeHistoryDialog ( ) {
$hisDialogEl . dialog ( "destroy" ) ;
$hisDialogEl . remove ( ) ;
}
2013-08-28 19:42:33 +02:00
function initializeDialog ( ) {
var $startPicker = $hisDialogEl . find ( '#his_item_starts_datetimepicker' ) ,
$endPicker = $hisDialogEl . find ( '#his_item_ends_datetimepicker' ) ;
$startPicker . datetimepicker ( ) ;
$endPicker . datetimepicker ( {
showTimeFirst : true
} ) ;
$startPicker . on ( 'changeDate' , function ( e ) {
$endPicker . data ( 'datetimepicker' ) . setLocalDate ( e . localDate ) ;
} ) ;
}
2013-07-18 07:31:20 +02:00
function makeHistoryDialog ( html ) {
$hisDialogEl = $ ( html ) ;
2013-07-26 23:33:17 +02:00
2013-07-18 07:31:20 +02:00
$hisDialogEl . dialog ( {
title : $ . i18n . _ ( "Edit History Record" ) ,
2013-08-16 21:12:00 +02:00
modal : false ,
2013-07-26 23:33:17 +02:00
open : function ( event , ui ) {
2013-08-28 19:42:33 +02:00
initializeDialog ( ) ;
2013-07-26 23:33:17 +02:00
} ,
2013-07-18 07:31:20 +02:00
close : function ( ) {
removeHistoryDialog ( ) ;
}
} ) ;
}
/ *
* Icon hover states for search .
* /
$historyContentDiv . on ( "mouseenter" , ".his-timerange .ui-button" , function ( ev ) {
$ ( this ) . addClass ( "ui-state-hover" ) ;
} ) ;
$historyContentDiv . on ( "mouseleave" , ".his-timerange .ui-button" , function ( ev ) {
$ ( this ) . removeClass ( "ui-state-hover" ) ;
} ) ;
oBaseDatePickerSettings = {
dateFormat : 'yy-mm-dd' ,
//i18n_months, i18n_days_short are in common.js
monthNames : i18n _months ,
dayNamesMin : i18n _days _short ,
onSelect : function ( sDate , oDatePicker ) {
$ ( this ) . datepicker ( "setDate" , sDate ) ;
}
} ;
oBaseTimePickerSettings = {
showPeriodLabels : false ,
showCloseButton : true ,
closeButtonText : $ . i18n . _ ( "Done" ) ,
showLeadingZero : false ,
defaultTime : '0:00' ,
hourText : $ . i18n . _ ( "Hour" ) ,
minuteText : $ . i18n . _ ( "Minute" )
} ;
2013-08-23 18:28:37 +02:00
2013-07-18 07:31:20 +02:00
$historyContentDiv . find ( dateStartId ) . datepicker ( oBaseDatePickerSettings ) ;
$historyContentDiv . find ( timeStartId ) . timepicker ( oBaseTimePickerSettings ) ;
$historyContentDiv . find ( dateEndId ) . datepicker ( oBaseDatePickerSettings ) ;
$historyContentDiv . find ( timeEndId ) . timepicker ( oBaseTimePickerSettings ) ;
2013-08-23 19:38:20 +02:00
$historyContentDiv . on ( "click" , "#his_create" , function ( e ) {
2013-07-24 00:01:43 +02:00
var url = baseUrl + "playouthistory/edit-list-item/format/json" ;
e . preventDefault ( ) ;
$ . get ( url , function ( json ) {
makeHistoryDialog ( json . dialog ) ;
} , "json" ) ;
} ) ;
$ ( 'body' ) . on ( "click" , ".his_file_cancel, .his_item_cancel" , function ( e ) {
removeHistoryDialog ( ) ;
} ) ;
2013-07-18 07:31:20 +02:00
$ ( 'body' ) . on ( "click" , ".his_file_save" , function ( e ) {
e . preventDefault ( ) ;
var $form = $ ( this ) . parents ( "form" ) ;
var data = $form . serializeArray ( ) ;
2013-08-12 21:06:26 +02:00
var url = baseUrl + "Playouthistory/update-file-item/format/json" ;
2013-07-18 07:31:20 +02:00
$ . post ( url , data , function ( json ) {
//TODO put errors on form.
2013-08-12 21:06:26 +02:00
if ( json . error !== undefined ) {
2013-07-18 07:31:20 +02:00
//makeHistoryDialog(json.dialog);
}
else {
removeHistoryDialog ( ) ;
2013-08-20 23:23:15 +02:00
redrawTables ( ) ;
2013-07-18 07:31:20 +02:00
}
} , "json" ) ;
} ) ;
2013-07-23 00:11:44 +02:00
$ ( 'body' ) . on ( "click" , ".his_item_save" , function ( e ) {
e . preventDefault ( ) ;
2013-07-24 00:01:43 +02:00
var $form = $ ( this ) . parents ( "form" ) ,
data = $form . serializeArray ( ) ,
id = data [ 0 ] . value ,
createUrl = baseUrl + "Playouthistory/create-list-item/format/json" ,
updateUrl = baseUrl + "Playouthistory/update-list-item/format/json" ,
url ;
2013-07-23 00:11:44 +02:00
2013-07-24 00:01:43 +02:00
url = ( id === "" ) ? createUrl : updateUrl ;
2013-07-23 00:11:44 +02:00
$ . post ( url , data , function ( json ) {
2013-08-23 21:52:49 +02:00
if ( json . form !== undefined ) {
var $newForm = $ ( json . form ) ;
$hisDialogEl . html ( $newForm . html ( ) ) ;
2013-08-28 19:42:33 +02:00
initializeDialog ( ) ;
2013-07-23 00:11:44 +02:00
}
else {
removeHistoryDialog ( ) ;
2013-08-20 23:23:15 +02:00
redrawTables ( ) ;
2013-07-23 00:11:44 +02:00
}
} , "json" ) ;
2013-08-20 23:23:15 +02:00
} ) ;
$historyContentDiv . on ( "click" , ".his_checkbox input" , function ( e ) {
var checked = e . currentTarget . checked ,
2013-08-23 19:31:37 +02:00
$tr = $ ( e . currentTarget ) . parents ( "tr" ) ;
2013-08-20 23:23:15 +02:00
if ( checked ) {
2013-08-23 19:31:37 +02:00
addSelectedLogItem ( $tr ) ;
2013-08-20 23:23:15 +02:00
}
else {
2013-08-23 19:31:37 +02:00
removeSelectedLogItem ( $tr ) ;
2013-08-20 23:23:15 +02:00
}
} ) ;
2013-07-23 00:11:44 +02:00
2013-07-18 07:31:20 +02:00
$historyContentDiv . find ( "#his_submit" ) . click ( function ( ev ) {
var fn ,
oRange ;
oRange = AIRTIME . utilities . fnGetScheduleRange ( dateStartId , timeStartId , dateEndId , timeEndId ) ;
2013-07-24 00:01:43 +02:00
fn = fnServerData ;
2013-07-18 07:31:20 +02:00
fn . start = oRange . start ;
fn . end = oRange . end ;
2013-08-20 23:23:15 +02:00
redrawTables ( ) ;
} ) ;
2013-08-23 19:18:17 +02:00
$historyContentDiv . on ( "click" , "#his_trash" , function ( ev ) {
2013-08-20 23:23:15 +02:00
var items = getSelectedLogItems ( ) ,
url = baseUrl + "playouthistory/delete-list-items" ;
$ . post ( url , { ids : items , format : "json" } , function ( ) {
redrawTables ( ) ;
} ) ;
2013-07-18 07:31:20 +02:00
} ) ;
2013-08-23 18:28:37 +02:00
$historyContentDiv . find ( "#his-tabs" ) . tabs ( {
show : function ( event , ui ) {
2013-08-29 01:37:46 +02:00
var href = $ ( ui . tab ) . attr ( "href" ) ;
var index = href . split ( '-' ) . pop ( ) ;
var tab = tabsInit [ index - 1 ] ;
2013-08-23 18:28:37 +02:00
if ( ! tab . initialized ) {
tab . initialize ( ) ;
tab . initialized = true ;
}
}
} ) ;
2013-07-18 07:31:20 +02:00
2013-08-20 05:19:13 +02:00
// begin context menu initialization.
$ . contextMenu ( {
2013-08-20 20:58:22 +02:00
selector : '#history_content td:not(.his_checkbox)' ,
2013-08-20 05:19:13 +02:00
trigger : "left" ,
ignoreRightClick : true ,
build : function ( $el , e ) {
2013-08-20 20:58:22 +02:00
var items = { } ,
2013-08-20 05:19:13 +02:00
callback ,
2013-08-20 21:18:05 +02:00
$tr ,
editUrl ,
deleteUrl ;
2013-08-20 05:19:13 +02:00
$tr = $el . parents ( "tr" ) ;
2013-08-20 21:18:05 +02:00
editUrl = $tr . data ( "url-edit" ) ;
deleteUrl = $tr . data ( "url-delete" ) ;
2013-08-20 20:58:22 +02:00
if ( editUrl !== undefined ) {
callback = function ( ) {
$ . post ( editUrl , { format : "json" } , function ( json ) {
makeHistoryDialog ( json . dialog ) ;
} , "json" ) ;
} ;
2013-08-20 05:19:13 +02:00
2013-08-20 20:58:22 +02:00
items [ "edit" ] = {
"name" : $ . i18n . _ ( "Edit" ) ,
"icon" : "edit" ,
"callback" : callback
} ;
}
if ( deleteUrl !== undefined ) {
callback = function ( ) {
var c = confirm ( "Delete this entry?" ) ;
if ( c ) {
$ . post ( deleteUrl , { format : "json" } , function ( json ) {
2013-08-23 18:28:37 +02:00
redrawTables ( ) ;
2013-08-20 20:58:22 +02:00
} ) ;
}
} ;
2013-08-20 05:19:13 +02:00
2013-08-20 20:58:22 +02:00
items [ "del" ] = {
"name" : $ . i18n . _ ( "Delete" ) ,
"icon" : "delete" ,
"callback" : callback
} ;
2013-08-20 05:19:13 +02:00
}
return {
items : items
} ;
}
} ) ;
2012-03-08 18:30:56 +01:00
} ;
return AIRTIME ;
} ( AIRTIME || { } ) ) ;
2013-07-18 07:31:20 +02:00
$ ( document ) . ready ( AIRTIME . history . onReady ) ;