From 7a2238fbad63c46f83993c7ca9dadd46eea4e710 Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 5 Feb 2014 18:18:21 -0500 Subject: [PATCH] CC-5450 : Refactor Media Management (Classes/DB) in Airtime working on setting up advanced search --- .../controllers/LibraryController.php | 4 +- .../controllers/MediaController.php | 4 +- .../controllers/ShowbuilderController.php | 6 +- .../application/services/MediaService.php | 103 +- .../datatables/css/dataTables.colReorder.css | 14 + .../css/datatables/css/dataTables.colVis.css | 184 +++ .../js/airtime/library/lib_separate_table.js | 71 +- .../js/datatables/js/jquery.dataTables.js | 1 - .../plugin/AIRTIME_DEV_README_COLUMN_FILTER | 152 --- .../plugin/dataTables.ColReorder.js | 1080 +++++++++------ .../js/datatables/plugin/dataTables.ColVis.js | 1156 +++++++++-------- .../plugin/dataTables.ColVis_orig.js | 995 -------------- .../plugin/dataTables.columnFilter.js | 339 ++--- .../plugin/dataTables.columnFilter_orig.js | 799 ------------ 14 files changed, 1849 insertions(+), 3059 deletions(-) create mode 100644 airtime_mvc/public/css/datatables/css/dataTables.colReorder.css create mode 100755 airtime_mvc/public/css/datatables/css/dataTables.colVis.css delete mode 100644 airtime_mvc/public/js/datatables/plugin/AIRTIME_DEV_README_COLUMN_FILTER delete mode 100644 airtime_mvc/public/js/datatables/plugin/dataTables.ColVis_orig.js delete mode 100644 airtime_mvc/public/js/datatables/plugin/dataTables.columnFilter_orig.js diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index d957ea334..a99b2804a 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -46,8 +46,8 @@ class LibraryController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'css/media_library.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); - $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); - $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); + $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/dataTables.colVis.css?'.$CC_CONFIG['airtime_version']); + $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/dataTables.colReorder.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/waveform.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/playlist_builder.css?'.$CC_CONFIG['airtime_version']); diff --git a/airtime_mvc/application/controllers/MediaController.php b/airtime_mvc/application/controllers/MediaController.php index 385ac6bad..811bfae75 100644 --- a/airtime_mvc/application/controllers/MediaController.php +++ b/airtime_mvc/application/controllers/MediaController.php @@ -7,14 +7,14 @@ class MediaController extends Zend_Controller_Action { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext - ->addActionContext('audio-file-feed', 'json') + ->addActionContext('audio-feed', 'json') ->addActionContext('webstream-feed', 'json') ->addActionContext('playlist-feed', 'json') ->initContext(); } - public function audioFileFeedAction() + public function audioFeedAction() { $params = $this->getRequest()->getParams(); diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index 8c0cf4927..6833bfb8f 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -47,9 +47,9 @@ class ShowbuilderController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'css/media_library.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); - $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); - $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); - + $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/dataTables.colVis.css?'.$CC_CONFIG['airtime_version']); + $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/dataTables.colReorder.css?'.$CC_CONFIG['airtime_version']); + $refer_sses = new Zend_Session_Namespace('referrer'); if ($request->isPost()) { diff --git a/airtime_mvc/application/services/MediaService.php b/airtime_mvc/application/services/MediaService.php index f43afbd91..209e44640 100644 --- a/airtime_mvc/application/services/MediaService.php +++ b/airtime_mvc/application/services/MediaService.php @@ -44,7 +44,10 @@ class Application_Service_MediaService return array( "Id" => array( - "isColumn" => false + "isColumn" => false, + "advancedSearch" => array( + "type" => null + ) ), "IsScheduled" => array( "isColumn" => true, @@ -52,6 +55,9 @@ class Application_Service_MediaService "width" => "90px", "class" => "library_is_scheduled", "searchable" => false, + "advancedSearch" => array( + "type" => "checkbox" + ) ), "IsPlaylist" => array( "isColumn" => true, @@ -59,24 +65,36 @@ class Application_Service_MediaService "width" => "90px", "class" => "library_is_playlist", "searchable" => false, + "advancedSearch" => array( + "type" => "checkbox" + ) ), "TrackTitle" => array( "isColumn" => true, "title" => _("Title"), "width" => "170px", - "class" => "library_title" + "class" => "library_title", + "advancedSearch" => array( + "type" => "text" + ) ), "ArtistName" => array( "isColumn" => true, "title" => _("Creator"), "width" => "160px", - "class" => "library_creator" + "class" => "library_creator", + "advancedSearch" => array( + "type" => "text" + ) ), "AlbumTitle" => array( "isColumn" => true, "title" => _("Album"), "width" => "150px", - "class" => "library_album" + "class" => "library_album", + "advancedSearch" => array( + "type" => "text" + ) ), "BitRate" => array( "isColumn" => true, @@ -85,6 +103,9 @@ class Application_Service_MediaService "class" => "library_bitrate", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => "number-range" + ) ), "Bpm" => array( "isColumn" => true, @@ -93,6 +114,9 @@ class Application_Service_MediaService "class" => "library_bpm", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => "number-range" + ) ), "Composer" => array( "isColumn" => true, @@ -100,6 +124,9 @@ class Application_Service_MediaService "width" => "150px", "class" => "library_composer", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "Conductor" => array( "isColumn" => true, @@ -107,6 +134,9 @@ class Application_Service_MediaService "width" => "125px", "class" => "library_conductor", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "Copyright" => array( "isColumn" => true, @@ -114,6 +144,9 @@ class Application_Service_MediaService "width" => "125px", "class" => "library_copyright", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "Cuein" => array( "isColumn" => true, @@ -122,6 +155,9 @@ class Application_Service_MediaService "class" => "library_length", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => null + ) ), "Cueout" => array( "isColumn" => true, @@ -130,6 +166,9 @@ class Application_Service_MediaService "class" => "library_length", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => null + ) ), "EncodedBy" => array( "isColumn" => true, @@ -137,6 +176,9 @@ class Application_Service_MediaService "width" => "150px", "class" => "library_encoded", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "Genre" => array( "isColumn" => true, @@ -144,6 +186,9 @@ class Application_Service_MediaService "width" => "100px", "class" => "library_genre", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "IsrcNumber" => array( "isColumn" => true, @@ -151,6 +196,9 @@ class Application_Service_MediaService "width" => "150px", "class" => "library_isrc", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "Label" => array( "isColumn" => true, @@ -158,6 +206,9 @@ class Application_Service_MediaService "width" => "125px", "class" => "library_label", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "Language" => array( "isColumn" => true, @@ -165,6 +216,9 @@ class Application_Service_MediaService "width" => "125px", "class" => "library_language", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "UpdatedAt" => array( "isColumn" => true, @@ -173,6 +227,9 @@ class Application_Service_MediaService "class" => "library_modified_time", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => "date-range" + ) ), "LastPlayedTime" => array( "isColumn" => true, @@ -181,6 +238,9 @@ class Application_Service_MediaService "class" => "library_modified_time", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => "date-range" + ) ), "CueLength" => array( "isColumn" => true, @@ -188,6 +248,9 @@ class Application_Service_MediaService "width" => "80px", "class" => "library_length", "searchable" => false, + "advancedSearch" => array( + "type" => null + ) ), "Mime" => array( "isColumn" => true, @@ -195,6 +258,9 @@ class Application_Service_MediaService "width" => "80px", "class" => "library_mime", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "Mood" => array( "isColumn" => true, @@ -202,13 +268,19 @@ class Application_Service_MediaService "width" => "70px", "class" => "library_mood", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "CcSubjs.DbLogin" => array( "isColumn" => true, "title" => _("Owner"), "width" => "125px", "class" => "library_owner", - "visible" => false + "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) ), "ReplayGain" => array( "isColumn" => true, @@ -217,6 +289,9 @@ class Application_Service_MediaService "class" => "library_replay_gain", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => "number-range" + ) ), "SampleRate" => array( "isColumn" => true, @@ -225,6 +300,9 @@ class Application_Service_MediaService "class" => "library_sr", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => "number-range" + ) ), "TrackNumber" => array( "isColumn" => true, @@ -233,6 +311,9 @@ class Application_Service_MediaService "class" => "library_track", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => "number-range" + ) ), "CreatedAt" => array( "isColumn" => true, @@ -241,6 +322,9 @@ class Application_Service_MediaService "class" => "library_upload_time", "visible" => false, "searchable" => false, + "advancedSearch" => array( + "type" => "date-range" + ) ), "InfoUrl" => array( "isColumn" => true, @@ -248,6 +332,10 @@ class Application_Service_MediaService "width" => "150px", "class" => "library_url", "visible" => false, + "advancedSearch" => array( + "type" => "text" + ) + ), "Year" => array( "isColumn" => true, @@ -255,6 +343,9 @@ class Application_Service_MediaService "width" => "60px", "class" => "library_year", "visible" => false, + "advancedSearch" => array( + "type" => "number-range" + ) ), ); } @@ -707,7 +798,7 @@ class Application_Service_MediaService //set audio columns for display of data. $columns = json_encode(self::makeDatatablesColumns('AudioFile')); - $script = "localStorage.setItem( 'datatables-audiofile-aoColumns', JSON.stringify($columns) ); "; + $script = "localStorage.setItem( 'datatables-audio-aoColumns', JSON.stringify($columns) ); "; //set webstream columns for display of data. $columns = json_encode(self::makeDatatablesColumns('Webstream')); diff --git a/airtime_mvc/public/css/datatables/css/dataTables.colReorder.css b/airtime_mvc/public/css/datatables/css/dataTables.colReorder.css new file mode 100644 index 000000000..bdd6aa0b9 --- /dev/null +++ b/airtime_mvc/public/css/datatables/css/dataTables.colReorder.css @@ -0,0 +1,14 @@ +/* + * Namespace DTCR - "DataTables ColReorder" plug-in + */ + +table.DTCR_clonedTable { + background-color: rgba(255, 255, 255, 0.7); + z-index: 202; +} + +div.DTCR_pointer { + width: 1px; + background-color: #0259C4; + z-index: 201; +} \ No newline at end of file diff --git a/airtime_mvc/public/css/datatables/css/dataTables.colVis.css b/airtime_mvc/public/css/datatables/css/dataTables.colVis.css new file mode 100755 index 000000000..e21cb9559 --- /dev/null +++ b/airtime_mvc/public/css/datatables/css/dataTables.colVis.css @@ -0,0 +1,184 @@ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ColVis styles + */ +div.ColVis { + float: right; + margin-bottom: 1em; +} + +button.ColVis_Button, +ul.ColVis_collection li { + position: relative; + float: left; + margin-right: 3px; + padding: 5px 8px; + border: 1px solid #999; + cursor: pointer; + *cursor: hand; + font-size: 0.88em; + color: black !important; + white-space: nowrap; + + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + -ms-border-radius: 2px; + -o-border-radius: 2px; + border-radius: 2px; + + -webkit-box-shadow: 1px 1px 3px #ccc; + -moz-box-shadow: 1px 1px 3px #ccc; + -ms-box-shadow: 1px 1px 3px #ccc; + -o-box-shadow: 1px 1px 3px #ccc; + box-shadow: 1px 1px 3px #ccc; + + /* Generated by http://www.colorzilla.com/gradient-editor/ */ + background: #ffffff; /* Old browsers */ + background: -webkit-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* Chrome10+,Safari5.1+ */ + background: -moz-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* FF3.6+ */ + background: -ms-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* IE10+ */ + background: -o-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* Opera 11.10+ */ + background: linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f9f9f9',GradientType=0 ); /* IE6-9 */ +} + +.ColVis_Button:hover, +ul.ColVis_collection li:hover { + border: 1px solid #666; + text-decoration: none !important; + + -webkit-box-shadow: 1px 1px 3px #999; + -moz-box-shadow: 1px 1px 3px #999; + -ms-box-shadow: 1px 1px 3px #999; + -o-box-shadow: 1px 1px 3px #999; + box-shadow: 1px 1px 3px #999; + + background: #f3f3f3; /* Old browsers */ + background: -webkit-linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* Chrome10+,Safari5.1+ */ + background: -moz-linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* FF3.6+ */ + background: -ms-linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* IE10+ */ + background: -o-linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* Opera 11.10+ */ + background: linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f3f3f3', endColorstr='#f4f4f4',GradientType=0 ); /* IE6-9 */ +} + +button.ColVis_Button { + height: 30px; + padding: 3px 8px; +} + +button.ColVis_Button::-moz-focus-inner { + border: none !important; + padding: 0; +} + +button.ColVis_Button:active { + outline: none; +} + + +div.ColVis_collectionBackground { + position: fixed; + top: 0; + left: 0; + height: 100%; + width: 100%; + background-color: black; + z-index: 1100; +} + +ul.ColVis_collection { + width: 150px; + padding: 8px 8px 4px 8px; + margin: 0; + border: 1px solid #ccc; + border: 1px solid rgba( 0, 0, 0, 0.4 ); + background-color: #f3f3f3; + background-color: rgba( 255, 255, 255, 0.3 ); + overflow: hidden; + z-index: 2002; + + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + -ms-border-radius: 5px; + -o-border-radius: 5px; + border-radius: 5px; + + -webkit-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); + -moz-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); + -ms-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); + -o-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); + box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); +} + +ul.ColVis_collection li { + position: relative; + height: auto; + left: 0; + right: 0; + padding: 0.5em; + + display: block; + float: none; + margin-bottom: 4px; + + -webkit-box-shadow: 1px 1px 3px #999; + -moz-box-shadow: 1px 1px 3px #999; + -ms-box-shadow: 1px 1px 3px #999; + -o-box-shadow: 1px 1px 3px #999; + box-shadow: 1px 1px 3px #999; +} + +ul.ColVis_collection li { + text-align: left; +} + +ul.ColVis_collection li.ColVis_Button:hover { + border: 1px solid #999; + background-color: #f0f0f0; +} + +ul.ColVis_collection li span { + display: inline-block; + padding-left: 0.5em; + cursor: pointer; +} + + +ul.ColVis_collection li.ColVis_Special { + border-color: #555; + background: rgb(237,237,237); /* Old browsers */ + background: -webkit-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(214,214,214,1) 77%,rgba(232,232,232,1) 100%); /* Chrome10+,Safari5.1+ */ + background: -moz-linear-gradient(top, rgba(237,237,237,1) 0%, rgba(214,214,214,1) 77%, rgba(232,232,232,1) 100%); /* FF3.6+ */ + background: -ms-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(214,214,214,1) 77%,rgba(232,232,232,1) 100%); /* IE10+ */ + background: -o-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(214,214,214,1) 77%,rgba(232,232,232,1) 100%); /* Opera 11.10+ */ + background: linear-gradient(to bottom, rgba(237,237,237,1) 0%,rgba(214,214,214,1) 77%,rgba(232,232,232,1) 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ededed', endColorstr='#e8e8e8',GradientType=0 ); /* IE6-9 */ +} + +ul.ColVis_collection li.ColVis_Special:hover { + background: #e2e2e2; /* Old browsers */ + background: -webkit-linear-gradient(top, #d0d0d0 0%,#d5d5d5 89%,#e2e2e2 100%); /* Chrome10+,Safari5.1+ */ + background: -moz-linear-gradient(top, #d0d0d0 0%,#d5d5d5 89%,#e2e2e2 100%); /* FF3.6+ */ + background: -ms-linear-gradient(top, #d0d0d0 0%,#d5d5d5 89%,#e2e2e2 100%); /* IE10+ */ + background: -o-linear-gradient(top, #d0d0d0 0%,#d5d5d5 89%,#e2e2e2 100%); /* Opera 11.10+ */ + background: linear-gradient(top, #d0d0d0 0%,#d5d5d5 89%,#e2e2e2 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f3f3f3', endColorstr='#e2e2e2',GradientType=0 ); /* IE6-9 */ +} + + +span.ColVis_radio { + display: inline-block; + width: 20px; +} + +div.ColVis_catcher { + position: absolute; + z-index: 1101; +} + +.disabled { + color: #999; +} + + diff --git a/airtime_mvc/public/js/airtime/library/lib_separate_table.js b/airtime_mvc/public/js/airtime/library/lib_separate_table.js index 20399db63..ddf34814f 100644 --- a/airtime_mvc/public/js/airtime/library/lib_separate_table.js +++ b/airtime_mvc/public/js/airtime/library/lib_separate_table.js @@ -99,14 +99,38 @@ var AIRTIME = (function(AIRTIME) { close: removeDialog }); } + + function createAdvancedSearchField(config) { + var template, + $el, + display = config.display ? "" : "style='display:none;'"; + + template = + "
>" + + "" + + "
" + + "
"; + + template = _.template(template); + $el = $(template(config)); + + return $el; + } + + function setUpAdvancedSearch() { + + } function createDatatable(config) { + var key = "datatables-"+config.type+"-aoColumns", + columns = JSON.parse(localStorage.getItem(key)); + var table = $("#"+config.type + "_table").dataTable({ - "aoColumns": config.columns, + "aoColumns": columns, "bProcessing": true, "bServerSide": true, - "sAjaxSource": config.source, + "sAjaxSource": baseUrl+"media/"+config.type+"-feed", "sAjaxDataProp": "media", "fnServerData": function ( sSource, aoData, fnCallback ) { @@ -135,9 +159,7 @@ var AIRTIME = (function(AIRTIME) { type: "POST", data: {settings : oData, format: "json"}, dataType: "json" - }); - - colReorderMap = oData.ColReorder; + }); }, "fnStateLoad": function fnLibStateLoad(oSettings) { var settings = localStorage.getItem('datatables-'+ config.type); @@ -191,7 +213,14 @@ var AIRTIME = (function(AIRTIME) { "aiExclude": [ 0 ], "buttonText": $.i18n._("Show / hide columns"), //use this to show/hide advanced search fields. - //"fnStateChange": setFilterElement + "fnStateChange": function ( iColumn, bVisible ) { + var c = table.fnSettings().aoColumns, + origIndex = c[iColumn]._ColReorder_iOrigCol; + col = columns[origIndex]; + + console.log(col); + + } }, "oColReorder": { @@ -402,8 +431,6 @@ var AIRTIME = (function(AIRTIME) { always: function() { }, - localColumns: "datatables-audiofile-aoColumns", - source: baseUrl+"media/audio-file-feed", type: "audio" }, "lib_webstreams": { @@ -417,8 +444,6 @@ var AIRTIME = (function(AIRTIME) { always: function() { }, - localColumns: "datatables-webstream-aoColumns", - source: baseUrl+"media/webstream-feed", type: "webstream" }, "lib_playlists": { @@ -432,8 +457,6 @@ var AIRTIME = (function(AIRTIME) { always: function() { }, - localColumns: "datatables-playlist-aoColumns", - source: baseUrl+"media/playlist-feed", type: "playlist" } }; @@ -447,10 +470,7 @@ var AIRTIME = (function(AIRTIME) { } else { - var columns = JSON.parse(localStorage.getItem(tab.localColumns)); createDatatable({ - columns: columns, - prop: tab.dataprop, source: tab.source, type: tab.type }); @@ -531,27 +551,6 @@ var AIRTIME = (function(AIRTIME) { }); //events for the edit metadata dialog - $body.on("click", "#editmdsave", function() { - var file_id = $('#file_id').val(), - data = $("#edit-md-dialog form").serializeArray(); - - $.post(baseUrl+'library/edit-file-md', - {format: "json", id: file_id, data: data}, - function() { - $("#edit-md-dialog").dialog().remove(); - - // don't redraw the library table if we are on calendar page - // we would be on calendar if viewing recorded file metadata - if ($("#schedule_calendar").length === 0) { - oTable.fnStandingRedraw(); - } - }); - }); - - $('#editmdcancel').live("click", function() { - $("#edit-md-dialog").dialog().remove(); - }); - $('#edit-md-dialog').live("keyup", function(event) { if (event.keyCode === 13) { $('#editmdsave').click(); diff --git a/airtime_mvc/public/js/datatables/js/jquery.dataTables.js b/airtime_mvc/public/js/datatables/js/jquery.dataTables.js index 1d8a220ba..3f6e4db81 100644 --- a/airtime_mvc/public/js/datatables/js/jquery.dataTables.js +++ b/airtime_mvc/public/js/datatables/js/jquery.dataTables.js @@ -12096,4 +12096,3 @@ })); }(window, document)); - diff --git a/airtime_mvc/public/js/datatables/plugin/AIRTIME_DEV_README_COLUMN_FILTER b/airtime_mvc/public/js/datatables/plugin/AIRTIME_DEV_README_COLUMN_FILTER deleted file mode 100644 index d62d5ecb1..000000000 --- a/airtime_mvc/public/js/datatables/plugin/AIRTIME_DEV_README_COLUMN_FILTER +++ /dev/null @@ -1,152 +0,0 @@ -Before you overwrite dataTables.columnFilter.js, note that we have changed a few lines -in this file. - -Running a diff between the original column filter plugin (dataTables.columnFilter_orig.js) and -our modified one (dataTables.columnFilter.js): - -denise@denise-DX4860:~/airtime/airtime_mvc/public/js/datatables/plugin$ diff -u dataTables.columnFilter_orig.js dataTables.columnFilter.js ---- dataTables.columnFilter_orig.js 2012-10-17 11:41:05.000000000 -0400 -+++ dataTables.columnFilter.js 2012-11-22 12:20:03.997107451 -0500 -@@ -103,7 +103,8 @@ - label = label.replace(/(^\s*)|(\s*$)/g, ""); - var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch; - var search_init = 'search_init '; -- var inputvalue = label; -+ //var inputvalue = label; -+ var inputvalue = ''; - if (currentFilter != '' && currentFilter != '^') { - if (bIsNumber && currentFilter.charAt(0) == '^') - inputvalue = currentFilter.substr(1); //ignore trailing ^ -@@ -133,29 +134,32 @@ - }); - } else { - input.keyup(function () { -- if (oTable.fnSettings().oFeatures.bServerSide && iFilterLength != 0) { -- //If filter length is set in the server-side processing mode -- //Check has the user entered at least iFilterLength new characters -- -- var currentFilter = oTable.fnSettings().aoPreSearchCols[index].sSearch; -- var iLastFilterLength = $(this).data("dt-iLastFilterLength"); -- if (typeof iLastFilterLength == "undefined") -- iLastFilterLength = 0; -- var iCurrentFilterLength = this.value.length; -- if (Math.abs(iCurrentFilterLength - iLastFilterLength) < iFilterLength -- //&& currentFilter.length == 0 //Why this? -- ) { -- //Cancel the filtering -- return; -- } -- else { -- //Remember the current filter length -- $(this).data("dt-iLastFilterLength", iCurrentFilterLength); -+ var advSearchFields = $("div#advanced_search").children(':visible'); -+ if(validateAdvancedSearch(advSearchFields)){ -+ if (oTable.fnSettings().oFeatures.bServerSide && iFilterLength != 0) { -+ //If filter length is set in the server-side processing mode -+ //Check has the user entered at least iFilterLength new characters -+ -+ var currentFilter = oTable.fnSettings().aoPreSearchCols[index].sSearch; -+ var iLastFilterLength = $(this).data("dt-iLastFilterLength"); -+ if (typeof iLastFilterLength == "undefined") -+ iLastFilterLength = 0; -+ var iCurrentFilterLength = this.value.length; -+ if (Math.abs(iCurrentFilterLength - iLastFilterLength) < iFilterLength -+ //&& currentFilter.length == 0 //Why this? -+ ) { -+ //Cancel the filtering -+ return; -+ } -+ else { -+ //Remember the current filter length -+ $(this).data("dt-iLastFilterLength", iCurrentFilterLength); -+ } - } -+ /* Filter on the column (the index) of this element */ -+ oTable.fnFilter(this.value, _fnColumnIndex(index), regex, smart); //Issue 37 -+ fnOnFiltered(); - } -- /* Filter on the column (the index) of this element */ -- oTable.fnFilter(this.value, _fnColumnIndex(index), regex, smart); //Issue 37 -- fnOnFiltered(); - }); - } - -@@ -168,7 +172,8 @@ - input.blur(function () { - if (this.value == "") { - $(this).addClass("search_init"); -- this.value = asInitVals[index]; -+ //this.value = asInitVals[index]; -+ this.value = ""; - } - }); - } -@@ -176,13 +181,25 @@ - function fnCreateRangeInput(oTable) { - - //var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch; -+ -+ var label = ""; -+ if (th.attr('id') == "bit_rate") { -+ label = $.i18n._("kbps"); -+ } else if (th.attr('id') == "utime" || th.attr('id') == "mtime" || th.attr('id') == "lptime") { -+ label = $.i18n._("yyyy-mm-dd"); -+ } else if (th.attr('id') == "length") { -+ label = $.i18n._("hh:mm:ss.t"); -+ } else if (th.attr('id') == "sample_rate") { -+ label = $.i18n._("kHz"); -+ } -+ - th.html(_fnRangeLabelPart(0)); - var sFromId = oTable.attr("id") + '_range_from_' + i; -- var from = $(''); -+ var from = $(''); - th.append(from); - th.append(_fnRangeLabelPart(1)); - var sToId = oTable.attr("id") + '_range_to_' + i; -- var to = $(''); -+ var to = $(''); - th.append(to); - th.append(_fnRangeLabelPart(2)); - th.wrapInner(''); -@@ -228,14 +245,16 @@ - - - $('#' + sFromId + ',#' + sToId, th).keyup(function () { -- -- var iMin = document.getElementById(sFromId).value * 1; -- var iMax = document.getElementById(sToId).value * 1; -- if (iMin != 0 && iMax != 0 && iMin > iMax) -- return; -- -- oTable.fnDraw(); -- fnOnFiltered(); -+ var advSearchFields = $("div#advanced_search").children(':visible'); -+ if(validateAdvancedSearch(advSearchFields)){ -+ var iMin = document.getElementById(sFromId).value * 1; -+ var iMax = document.getElementById(sToId).value * 1; -+ if (iMin != 0 && iMax != 0 && iMin > iMax) -+ return; -+ -+ oTable.fnDraw(); -+ fnOnFiltered(); -+ } - }); - - -@@ -566,7 +585,7 @@ - sRangeSeparator: "~", - iFilteringDelay: 500, - aoColumns: null, -- sRangeFormat: "From {from} to {to}" -+ sRangeFormat: $.i18n._("From {from} to {to}") - }; - - properties = $.extend(defaults, options); -@@ -730,4 +749,4 @@ - - - --})(jQuery); -\ No newline at end of file -+})(jQuery); \ No newline at end of file diff --git a/airtime_mvc/public/js/datatables/plugin/dataTables.ColReorder.js b/airtime_mvc/public/js/datatables/plugin/dataTables.ColReorder.js index 35b96594f..c3ca57c0b 100644 --- a/airtime_mvc/public/js/datatables/plugin/dataTables.ColReorder.js +++ b/airtime_mvc/public/js/datatables/plugin/dataTables.ColReorder.js @@ -1,27 +1,27 @@ -/* - * File: ColReorder.js - * Version: 1.0.8 - * CVS: $Id$ - * Description: Allow columns to be reordered in a DataTable - * Author: Allan Jardine (www.sprymedia.co.uk) - * Created: Wed Sep 15 18:23:29 BST 2010 - * Modified: $Date$ by $Author$ - * Language: Javascript - * License: GPL v2 or BSD 3 point style - * Project: DataTables - * Contact: www.sprymedia.co.uk/contact - * - * Copyright 2010-2011 Allan Jardine, all rights reserved. - * - * This source file is free software, under either the GPL v2 license or a - * BSD style license, available at: - * http://datatables.net/license_gpl2 - * http://datatables.net/license_bsd - * +/*! ColReorder 1.1.0 + * ©2010-2014 SpryMedia Ltd - datatables.net/license */ +/** + * @summary ColReorder + * @description Provide the ability to reorder columns in a DataTable + * @version 1.1.0 + * @file dataTables.colReorder.js + * @author SpryMedia Ltd (www.sprymedia.co.uk) + * @contact www.sprymedia.co.uk/contact + * @copyright Copyright 2010-2014 SpryMedia Ltd. + * + * This source file is free software, available under the following license: + * MIT license - http://datatables.net/license/mit + * + * This source file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. + * + * For details please refer to: http://www.datatables.net + */ -(function($, window, document) { +(function(window, document, undefined) { /** @@ -58,7 +58,7 @@ function fnArraySwitch( aArray, iFrom, iTo ) /** - * Switch the positions of nodes in a parent node (note this is specifically designed for + * Switch the positions of nodes in a parent node (note this is specifically designed for * table rows). Note this function considers all element nodes under the parent! * @method fnDomSwitch * @param string sTag Tag to consider @@ -77,7 +77,7 @@ function fnDomSwitch( nParent, iFrom, iTo ) } } var nStore = anTags[ iFrom ]; - + if ( iTo !== null ) { nParent.insertBefore( nStore, anTags[iTo] ); @@ -102,34 +102,35 @@ function fnDomSwitch( nParent, iFrom, iTo ) * Plug-in for DataTables which will reorder the internal column structure by taking the column * from one position (iFrom) and insert it into a given point (iTo). * @method $.fn.dataTableExt.oApi.fnColReorder - * @param object oSettings DataTables settings object - automatically added by DataTables! + * @param object oSettings DataTables settings object - automatically added by DataTables! * @param int iFrom Take the column to be repositioned from this point * @param int iTo and insert it into this point * @returns void */ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo ) { + var v110 = $.fn.dataTable.Api ? true : false; var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol; - + /* Sanity check in the input */ if ( iFrom == iTo ) { /* Pointless reorder */ return; } - + if ( iFrom < 0 || iFrom >= iCols ) { this.oApi._fnLog( oSettings, 1, "ColReorder 'from' index is out of bounds: "+iFrom ); return; } - + if ( iTo < 0 || iTo >= iCols ) { this.oApi._fnLog( oSettings, 1, "ColReorder 'to' index is out of bounds: "+iTo ); return; } - + /* * Calculate the new column array index, so we have a mapping between the old and new */ @@ -140,8 +141,8 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo ) } fnArraySwitch( aiMapping, iFrom, iTo ); var aiInvertMapping = fnInvertKeyValues( aiMapping ); - - + + /* * Convert all internal indexing to the new column order indexes */ @@ -150,7 +151,7 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo ) { oSettings.aaSorting[i][0] = aiInvertMapping[ oSettings.aaSorting[i][0] ]; } - + /* Fixed sorting */ if ( oSettings.aaSortingFixed !== null ) { @@ -159,7 +160,7 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo ) oSettings.aaSortingFixed[i][0] = aiInvertMapping[ oSettings.aaSortingFixed[i][0] ]; } } - + /* Data column sorting (the column which the sort for a given column should take place on) */ for ( i=0, iLen=iCols ; i this.s.fixed-1 ) + if ( i > this.s.fixed-1 && i < iLen - this.s.fixedRight ) { this._fnMouseListener( i, this.s.dt.aoColumns[i].nTh ); } - + /* Mark the original column order for later reference */ this.s.dt.aoColumns[i]._ColReorder_iOrigCol = i; } - + /* State saving */ this.s.dt.oApi._fnCallbackReg( this.s.dt, 'aoStateSaveParams', function (oS, oData) { that._fnStateSave.call( that, oData ); }, "ColReorder_State" ); - + /* An initial column order has been specified */ var aiOrder = null; - if ( typeof this.s.init.aiOrder != 'undefined' ) + if ( this.s.init.aiOrder ) { aiOrder = this.s.init.aiOrder.slice(); } - + /* State loading, overrides the column order given */ if ( this.s.dt.oLoadedState && typeof this.s.dt.oLoadedState.ColReorder != 'undefined' && this.s.dt.oLoadedState.ColReorder.length == this.s.dt.aoColumns.length ) { aiOrder = this.s.dt.oLoadedState.ColReorder; } - + /* If we have an order to apply - do so */ if ( aiOrder ) { @@ -515,25 +660,28 @@ ColReorder.prototype = { that._fnOrderColumns.call( that, resort ); } } + else { + this._fnSetColumnIndexes(); + } }, - - + + /** * Set the column order from an array * @method _fnOrderColumns * @param array a An array of integers which dictate the column order that should be applied * @returns void - * @private + * @private */ "_fnOrderColumns": function ( a ) { if ( a.length != this.s.dt.aoColumns.length ) { this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+ - "match known number of columns. Skipping." ); + "match known number of columns. Skipping." ); return; } - + for ( var i=0, iLen=a.length ; i 0 ) - { - this.dom.drag.removeChild( this.dom.drag.getElementsByTagName('caption')[0] ); - } - while ( this.dom.drag.getElementsByTagName('tbody').length > 0 ) - { - this.dom.drag.removeChild( this.dom.drag.getElementsByTagName('tbody')[0] ); - } - while ( this.dom.drag.getElementsByTagName('tfoot').length > 0 ) - { - this.dom.drag.removeChild( this.dom.drag.getElementsByTagName('tfoot')[0] ); - } - - $('thead tr:eq(0)', this.dom.drag).each( function () { - $('th', this).eq(that.s.mouse.targetIndex).siblings().remove(); - } ); - $('tr', this.dom.drag).height( $('tr:eq(0)', that.s.dt.nTHead).height() ); - - $('thead tr:gt(0)', this.dom.drag).remove(); - - $('thead th:eq(0)', this.dom.drag).each( function (i) { - this.style.width = $('th:eq('+that.s.mouse.targetIndex+')', that.s.dt.nTHead).width()+"px"; - } ); - - this.dom.drag.style.position = "absolute"; - this.dom.drag.style.top = "0px"; - this.dom.drag.style.left = "0px"; - this.dom.drag.style.width = $('th:eq('+that.s.mouse.targetIndex+')', that.s.dt.nTHead).outerWidth()+"px"; - - - this.dom.pointer = document.createElement( 'div' ); - this.dom.pointer.className = "DTCR_pointer"; - this.dom.pointer.style.position = "absolute"; - - if ( this.s.dt.oScroll.sX === "" && this.s.dt.oScroll.sY === "" ) - { - this.dom.pointer.style.top = $(this.s.dt.nTable).offset().top+"px"; - this.dom.pointer.style.height = $(this.s.dt.nTable).height()+"px"; - } - else - { - this.dom.pointer.style.top = $('div.dataTables_scroll', this.s.dt.nTableWrapper).offset().top+"px"; - this.dom.pointer.style.height = $('div.dataTables_scroll', this.s.dt.nTableWrapper).height()+"px"; - } - - document.body.appendChild( this.dom.pointer ); - document.body.appendChild( this.dom.drag ); + var scrolling = this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== ""; + + var origCell = this.s.dt.aoColumns[ this.s.mouse.targetIndex ].nTh; + var origTr = origCell.parentNode; + var origThead = origTr.parentNode; + var origTable = origThead.parentNode; + var cloneCell = $(origCell).clone(); + + // This is a slightly odd combination of jQuery and DOM, but it is the + // fastest and least resource intensive way I could think of cloning + // the table with just a single header cell in it. + this.dom.drag = $(origTable.cloneNode(false)) + .addClass( 'DTCR_clonedTable' ) + .append( + origThead.cloneNode(false).appendChild( + origTr.cloneNode(false).appendChild( + cloneCell[0] + ) + ) + ) + .css( { + position: 'absolute', + top: 0, + left: 0, + width: $(origCell).outerWidth(), + height: $(origCell).outerHeight() + } ) + .appendTo( 'body' ); + + this.dom.pointer = $('
') + .addClass( 'DTCR_pointer' ) + .css( { + position: 'absolute', + top: scrolling ? + $('div.dataTables_scroll', this.s.dt.nTableWrapper).offset().top : + $(this.s.dt.nTable).offset().top, + height : scrolling ? + $('div.dataTables_scroll', this.s.dt.nTableWrapper).height() : + $(this.s.dt.nTable).height() + } ) + .appendTo( 'body' ); }, /** @@ -857,19 +1030,39 @@ ColReorder.prototype = { */ "_fnDestroy": function () { - for ( var i=0, iLen=ColReorder.aoInstances.length ; i