CC-5450 : Refactor Media Management (Classes/DB) in Airtime
working on setting up advanced search
This commit is contained in:
parent
0ce0371e6d
commit
7a2238fbad
|
@ -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']);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -99,14 +99,38 @@ var AIRTIME = (function(AIRTIME) {
|
|||
close: removeDialog
|
||||
});
|
||||
}
|
||||
|
||||
function createAdvancedSearchField(config) {
|
||||
var template,
|
||||
$el,
|
||||
display = config.display ? "" : "style='display:none;'";
|
||||
|
||||
template =
|
||||
"<div id='advanced_search_col_<%= index %>' class='control-group' <%= style %>>" +
|
||||
"<label class='control-label'><%= title %></label>" +
|
||||
"<div id='adv-search-<%= id %>' class='controls'></div>" +
|
||||
"</div>";
|
||||
|
||||
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();
|
||||
|
|
|
@ -12096,4 +12096,3 @@
|
|||
}));
|
||||
|
||||
}(window, document));
|
||||
|
||||
|
|
|
@ -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 = $('<input type="text" class="number_range_filter" id="' + sFromId + '" rel="' + i + '"/>');
|
||||
+ var from = $('<input type="text" class="number_range_filter" id="' + sFromId + '" rel="' + i + '" placeholder="' + label + '"/>');
|
||||
th.append(from);
|
||||
th.append(_fnRangeLabelPart(1));
|
||||
var sToId = oTable.attr("id") + '_range_to_' + i;
|
||||
- var to = $('<input type="text" class="number_range_filter" id="' + sToId + '" rel="' + i + '"/>');
|
||||
+ var to = $('<input type="text" class="number_range_filter" id="' + sToId + '" rel="' + i + '" placeholder="' + label + '"/>');
|
||||
th.append(to);
|
||||
th.append(_fnRangeLabelPart(2));
|
||||
th.wrapInner('<span class="filterColumn filter_number_range" />');
|
||||
@@ -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);
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,995 +0,0 @@
|
|||
/*
|
||||
* File: ColVis.js
|
||||
* Version: 1.0.7
|
||||
* CVS: $Id$
|
||||
* Description: Controls for column visiblity in DataTables
|
||||
* 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: Just a little bit of fun :-)
|
||||
* 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
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
/**
|
||||
* ColVis provides column visiblity control for DataTables
|
||||
* @class ColVis
|
||||
* @constructor
|
||||
* @param {object} DataTables settings object
|
||||
*/
|
||||
ColVis = function( oDTSettings, oInit )
|
||||
{
|
||||
/* Santiy check that we are a new instance */
|
||||
if ( !this.CLASS || this.CLASS != "ColVis" )
|
||||
{
|
||||
alert( "Warning: ColVis must be initialised with the keyword 'new'" );
|
||||
}
|
||||
|
||||
if ( typeof oInit == 'undefined' )
|
||||
{
|
||||
oInit = {};
|
||||
}
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public class variables
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/**
|
||||
* @namespace Settings object which contains customisable information for ColVis instance
|
||||
*/
|
||||
this.s = {
|
||||
/**
|
||||
* DataTables settings object
|
||||
* @property dt
|
||||
* @type Object
|
||||
* @default null
|
||||
*/
|
||||
"dt": null,
|
||||
|
||||
/**
|
||||
* Customisation object
|
||||
* @property oInit
|
||||
* @type Object
|
||||
* @default passed in
|
||||
*/
|
||||
"oInit": oInit,
|
||||
|
||||
/**
|
||||
* Callback function to tell the user when the state has changed
|
||||
* @property fnStateChange
|
||||
* @type function
|
||||
* @default null
|
||||
*/
|
||||
"fnStateChange": null,
|
||||
|
||||
/**
|
||||
* Mode of activation. Can be 'click' or 'mouseover'
|
||||
* @property activate
|
||||
* @type String
|
||||
* @default click
|
||||
*/
|
||||
"activate": "click",
|
||||
|
||||
/**
|
||||
* Position of the collection menu when shown - align "left" or "right"
|
||||
* @property sAlign
|
||||
* @type String
|
||||
* @default right
|
||||
*/
|
||||
"sAlign": "left",
|
||||
|
||||
/**
|
||||
* Text used for the button
|
||||
* @property buttonText
|
||||
* @type String
|
||||
* @default Show / hide columns
|
||||
*/
|
||||
"buttonText": "Show / hide columns",
|
||||
|
||||
/**
|
||||
* Flag to say if the collection is hidden
|
||||
* @property hidden
|
||||
* @type boolean
|
||||
* @default true
|
||||
*/
|
||||
"hidden": true,
|
||||
|
||||
/**
|
||||
* List of columns (integers) which should be excluded from the list
|
||||
* @property aiExclude
|
||||
* @type Array
|
||||
* @default []
|
||||
*/
|
||||
"aiExclude": [],
|
||||
|
||||
/**
|
||||
* Store the original viisbility settings so they could be restored
|
||||
* @property abOriginal
|
||||
* @type Array
|
||||
* @default []
|
||||
*/
|
||||
"abOriginal": [],
|
||||
|
||||
/**
|
||||
* Show Show-All button
|
||||
* @property bShowAll
|
||||
* @type Array
|
||||
* @default []
|
||||
*/
|
||||
"bShowAll": false,
|
||||
|
||||
/**
|
||||
* Show All button text
|
||||
* @property sShowAll
|
||||
* @type String
|
||||
* @default Restore original
|
||||
*/
|
||||
"sShowAll": "Show All",
|
||||
|
||||
/**
|
||||
* Show restore button
|
||||
* @property bRestore
|
||||
* @type Array
|
||||
* @default []
|
||||
*/
|
||||
"bRestore": false,
|
||||
|
||||
/**
|
||||
* Restore button text
|
||||
* @property sRestore
|
||||
* @type String
|
||||
* @default Restore original
|
||||
*/
|
||||
"sRestore": "Restore original",
|
||||
|
||||
/**
|
||||
* Overlay animation duration in mS
|
||||
* @property iOverlayFade
|
||||
* @type Integer
|
||||
* @default 500
|
||||
*/
|
||||
"iOverlayFade": 500,
|
||||
|
||||
/**
|
||||
* Label callback for column names. Takes three parameters: 1. the column index, 2. the column
|
||||
* title detected by DataTables and 3. the TH node for the column
|
||||
* @property fnLabel
|
||||
* @type Function
|
||||
* @default null
|
||||
*/
|
||||
"fnLabel": null,
|
||||
|
||||
/**
|
||||
* Indicate if ColVis should automatically calculate the size of buttons or not. The default
|
||||
* is for it to do so. Set to "css" to disable the automatic sizing
|
||||
* @property sSize
|
||||
* @type String
|
||||
* @default auto
|
||||
*/
|
||||
"sSize": "auto",
|
||||
|
||||
/**
|
||||
* Indicate if the column list should be positioned by Javascript, visually below the button
|
||||
* or allow CSS to do the positioning
|
||||
* @property bCssPosition
|
||||
* @type boolean
|
||||
* @default false
|
||||
*/
|
||||
"bCssPosition": false
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @namespace Common and useful DOM elements for the class instance
|
||||
*/
|
||||
this.dom = {
|
||||
/**
|
||||
* Wrapper for the button - given back to DataTables as the node to insert
|
||||
* @property wrapper
|
||||
* @type Node
|
||||
* @default null
|
||||
*/
|
||||
"wrapper": null,
|
||||
|
||||
/**
|
||||
* Activation button
|
||||
* @property button
|
||||
* @type Node
|
||||
* @default null
|
||||
*/
|
||||
"button": null,
|
||||
|
||||
/**
|
||||
* Collection list node
|
||||
* @property collection
|
||||
* @type Node
|
||||
* @default null
|
||||
*/
|
||||
"collection": null,
|
||||
|
||||
/**
|
||||
* Background node used for shading the display and event capturing
|
||||
* @property background
|
||||
* @type Node
|
||||
* @default null
|
||||
*/
|
||||
"background": null,
|
||||
|
||||
/**
|
||||
* Element to position over the activation button to catch mouse events when using mouseover
|
||||
* @property catcher
|
||||
* @type Node
|
||||
* @default null
|
||||
*/
|
||||
"catcher": null,
|
||||
|
||||
/**
|
||||
* List of button elements
|
||||
* @property buttons
|
||||
* @type Array
|
||||
* @default []
|
||||
*/
|
||||
"buttons": [],
|
||||
|
||||
/**
|
||||
* Restore button
|
||||
* @property restore
|
||||
* @type Node
|
||||
* @default null
|
||||
*/
|
||||
"restore": null
|
||||
};
|
||||
|
||||
/* Store global reference */
|
||||
ColVis.aInstances.push( this );
|
||||
|
||||
/* Constructor logic */
|
||||
this.s.dt = oDTSettings;
|
||||
this._fnConstruct();
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
ColVis.prototype = {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/**
|
||||
* Rebuild the list of buttons for this instance (i.e. if there is a column header update)
|
||||
* @method fnRebuild
|
||||
* @returns void
|
||||
*/
|
||||
"fnRebuild": function ()
|
||||
{
|
||||
/* Remove the old buttons */
|
||||
for ( var i=this.dom.buttons.length-1 ; i>=0 ; i-- )
|
||||
{
|
||||
if ( this.dom.buttons[i] !== null )
|
||||
{
|
||||
this.dom.collection.removeChild( this.dom.buttons[i] );
|
||||
}
|
||||
}
|
||||
this.dom.buttons.splice( 0, this.dom.buttons.length );
|
||||
|
||||
if ( this.dom.restore )
|
||||
{
|
||||
this.dom.restore.parentNode( this.dom.restore );
|
||||
}
|
||||
|
||||
/* Re-add them (this is not the optimal way of doing this, it is fast and effective) */
|
||||
this._fnAddButtons();
|
||||
|
||||
/* Update the checkboxes */
|
||||
this._fnDrawCallback();
|
||||
},
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private methods (they are of course public in JS, but recommended as private)
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/**
|
||||
* Constructor logic
|
||||
* @method _fnConstruct
|
||||
* @returns void
|
||||
* @private
|
||||
*/
|
||||
"_fnConstruct": function ()
|
||||
{
|
||||
this._fnApplyCustomisation();
|
||||
|
||||
var that = this;
|
||||
this.dom.wrapper = document.createElement('div');
|
||||
this.dom.wrapper.className = "ColVis TableTools";
|
||||
|
||||
this.dom.button = this._fnDomBaseButton( this.s.buttonText );
|
||||
this.dom.button.className += " ColVis_MasterButton";
|
||||
this.dom.wrapper.appendChild( this.dom.button );
|
||||
|
||||
this.dom.catcher = this._fnDomCatcher();
|
||||
this.dom.collection = this._fnDomCollection();
|
||||
this.dom.background = this._fnDomBackground();
|
||||
|
||||
this._fnAddButtons();
|
||||
|
||||
/* Store the original visbility information */
|
||||
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
|
||||
{
|
||||
this.s.abOriginal.push( this.s.dt.aoColumns[i].bVisible );
|
||||
}
|
||||
|
||||
/* Update on each draw */
|
||||
this.s.dt.aoDrawCallback.push( {
|
||||
"fn": function () {
|
||||
that._fnDrawCallback.call( that );
|
||||
},
|
||||
"sName": "ColVis"
|
||||
} );
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Apply any customisation to the settings from the DataTables initialisation
|
||||
* @method _fnApplyCustomisation
|
||||
* @returns void
|
||||
* @private
|
||||
*/
|
||||
"_fnApplyCustomisation": function ()
|
||||
{
|
||||
var oConfig = this.s.oInit;
|
||||
|
||||
if ( typeof oConfig.activate != 'undefined' )
|
||||
{
|
||||
this.s.activate = oConfig.activate;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.buttonText != 'undefined' )
|
||||
{
|
||||
this.s.buttonText = oConfig.buttonText;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.aiExclude != 'undefined' )
|
||||
{
|
||||
this.s.aiExclude = oConfig.aiExclude;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.bRestore != 'undefined' )
|
||||
{
|
||||
this.s.bRestore = oConfig.bRestore;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.sRestore != 'undefined' )
|
||||
{
|
||||
this.s.sRestore = oConfig.sRestore;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.bShowAll != 'undefined' )
|
||||
{
|
||||
this.s.bShowAll = oConfig.bShowAll;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.sShowAll != 'undefined' )
|
||||
{
|
||||
this.s.sShowAll = oConfig.sShowAll;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.sAlign != 'undefined' )
|
||||
{
|
||||
this.s.sAlign = oConfig.sAlign;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.fnStateChange != 'undefined' )
|
||||
{
|
||||
this.s.fnStateChange = oConfig.fnStateChange;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.iOverlayFade != 'undefined' )
|
||||
{
|
||||
this.s.iOverlayFade = oConfig.iOverlayFade;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.fnLabel != 'undefined' )
|
||||
{
|
||||
this.s.fnLabel = oConfig.fnLabel;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.sSize != 'undefined' )
|
||||
{
|
||||
this.s.sSize = oConfig.sSize;
|
||||
}
|
||||
|
||||
if ( typeof oConfig.bCssPosition != 'undefined' )
|
||||
{
|
||||
this.s.bCssPosition = oConfig.bCssPosition;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* On each table draw, check the visiblity checkboxes as needed. This allows any process to
|
||||
* update the table's column visiblity and ColVis will still be accurate.
|
||||
* @method _fnDrawCallback
|
||||
* @returns void
|
||||
* @private
|
||||
*/
|
||||
"_fnDrawCallback": function ()
|
||||
{
|
||||
var aoColumns = this.s.dt.aoColumns;
|
||||
|
||||
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
|
||||
{
|
||||
if ( this.dom.buttons[i] !== null )
|
||||
{
|
||||
if ( aoColumns[i].bVisible )
|
||||
{
|
||||
$('input', this.dom.buttons[i]).attr('checked','checked');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('input', this.dom.buttons[i]).removeAttr('checked');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Loop through the columns in the table and as a new button for each one.
|
||||
* @method _fnAddButtons
|
||||
* @returns void
|
||||
* @private
|
||||
*/
|
||||
"_fnAddButtons": function ()
|
||||
{
|
||||
var
|
||||
nButton,
|
||||
sExclude = ","+this.s.aiExclude.join(',')+",";
|
||||
|
||||
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
|
||||
{
|
||||
if ( sExclude.indexOf( ","+i+"," ) == -1 )
|
||||
{
|
||||
nButton = this._fnDomColumnButton( i );
|
||||
this.dom.buttons.push( nButton );
|
||||
this.dom.collection.appendChild( nButton );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dom.buttons.push( null );
|
||||
}
|
||||
}
|
||||
|
||||
if ( this.s.bRestore )
|
||||
{
|
||||
nButton = this._fnDomRestoreButton();
|
||||
nButton.className += " ColVis_Restore";
|
||||
this.dom.buttons.push( nButton );
|
||||
this.dom.collection.appendChild( nButton );
|
||||
}
|
||||
|
||||
if ( this.s.bShowAll )
|
||||
{
|
||||
nButton = this._fnDomShowAllButton();
|
||||
nButton.className += " ColVis_ShowAll";
|
||||
this.dom.buttons.push( nButton );
|
||||
this.dom.collection.appendChild( nButton );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Create a button which allows a "restore" action
|
||||
* @method _fnDomRestoreButton
|
||||
* @returns {Node} Created button
|
||||
* @private
|
||||
*/
|
||||
"_fnDomRestoreButton": function ()
|
||||
{
|
||||
var
|
||||
that = this,
|
||||
nButton = document.createElement('button'),
|
||||
nSpan = document.createElement('span');
|
||||
|
||||
nButton.className = !this.s.dt.bJUI ? "ColVis_Button TableTools_Button" :
|
||||
"ColVis_Button TableTools_Button ui-button ui-state-default";
|
||||
nButton.appendChild( nSpan );
|
||||
$(nSpan).html( '<span class="ColVis_title">'+this.s.sRestore+'</span>' );
|
||||
|
||||
$(nButton).click( function (e) {
|
||||
for ( var i=0, iLen=that.s.abOriginal.length ; i<iLen ; i++ )
|
||||
{
|
||||
that.s.dt.oInstance.fnSetColumnVis( i, that.s.abOriginal[i], false );
|
||||
}
|
||||
that._fnAdjustOpenRows();
|
||||
that.s.dt.oInstance.fnDraw( false );
|
||||
} );
|
||||
|
||||
return nButton;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Create a button which allows a "show all" action
|
||||
* @method _fnDomShowAllButton
|
||||
* @returns {Node} Created button
|
||||
* @private
|
||||
*/
|
||||
"_fnDomShowAllButton": function ()
|
||||
{
|
||||
var
|
||||
that = this,
|
||||
nButton = document.createElement('button'),
|
||||
nSpan = document.createElement('span');
|
||||
|
||||
nButton.className = !this.s.dt.bJUI ? "ColVis_Button TableTools_Button" :
|
||||
"ColVis_Button TableTools_Button ui-button ui-state-default";
|
||||
nButton.appendChild( nSpan );
|
||||
$(nSpan).html( '<span class="ColVis_title">'+this.s.sShowAll+'</span>' );
|
||||
|
||||
$(nButton).click( function (e) {
|
||||
for ( var i=0, iLen=that.s.abOriginal.length ; i<iLen ; i++ )
|
||||
{
|
||||
if (that.s.aiExclude.indexOf(i) === -1)
|
||||
{
|
||||
that.s.dt.oInstance.fnSetColumnVis( i, true, false );
|
||||
}
|
||||
}
|
||||
that._fnAdjustOpenRows();
|
||||
that.s.dt.oInstance.fnDraw( false );
|
||||
} );
|
||||
|
||||
return nButton;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Create the DOM for a show / hide button
|
||||
* @method _fnDomColumnButton
|
||||
* @param {int} i Column in question
|
||||
* @returns {Node} Created button
|
||||
* @private
|
||||
*/
|
||||
"_fnDomColumnButton": function ( i )
|
||||
{
|
||||
var
|
||||
that = this,
|
||||
oColumn = this.s.dt.aoColumns[i],
|
||||
nButton = document.createElement('button'),
|
||||
nSpan = document.createElement('span'),
|
||||
dt = this.s.dt;
|
||||
|
||||
nButton.className = !dt.bJUI ? "ColVis_Button TableTools_Button" :
|
||||
"ColVis_Button TableTools_Button ui-button ui-state-default";
|
||||
nButton.appendChild( nSpan );
|
||||
var sTitle = this.s.fnLabel===null ? oColumn.sTitle : this.s.fnLabel( i, oColumn.sTitle, oColumn.nTh );
|
||||
$(nSpan).html(
|
||||
'<span class="ColVis_radio"><input type="checkbox"/></span>'+
|
||||
'<span class="ColVis_title">'+sTitle+'</span>' );
|
||||
|
||||
$(nButton).click( function (e) {
|
||||
var showHide = !$('input', this).is(":checked");
|
||||
if ( e.target.nodeName.toLowerCase() == "input" )
|
||||
{
|
||||
showHide = $('input', this).is(":checked");
|
||||
}
|
||||
|
||||
/* Need to consider the case where the initialiser created more than one table - change the
|
||||
* API index that DataTables is using
|
||||
*/
|
||||
var oldIndex = $.fn.dataTableExt.iApiIndex;
|
||||
$.fn.dataTableExt.iApiIndex = that._fnDataTablesApiIndex.call(that);
|
||||
|
||||
// Optimisation for server-side processing when scrolling - don't do a full redraw
|
||||
if ( dt.oFeatures.bServerSide && (dt.oScroll.sX !== "" || dt.oScroll.sY !== "" ) )
|
||||
{
|
||||
that.s.dt.oInstance.fnSetColumnVis( i, showHide, false );
|
||||
that.s.dt.oInstance.oApi._fnScrollDraw( that.s.dt );
|
||||
that._fnDrawCallback();
|
||||
}
|
||||
else
|
||||
{
|
||||
that.s.dt.oInstance.fnSetColumnVis( i, showHide );
|
||||
}
|
||||
|
||||
$.fn.dataTableExt.iApiIndex = oldIndex; /* Restore */
|
||||
|
||||
if ( that.s.fnStateChange !== null )
|
||||
{
|
||||
that.s.fnStateChange.call( that, i, showHide );
|
||||
}
|
||||
} );
|
||||
|
||||
return nButton;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Get the position in the DataTables instance array of the table for this instance of ColVis
|
||||
* @method _fnDataTablesApiIndex
|
||||
* @returns {int} Index
|
||||
* @private
|
||||
*/
|
||||
"_fnDataTablesApiIndex": function ()
|
||||
{
|
||||
for ( var i=0, iLen=this.s.dt.oInstance.length ; i<iLen ; i++ )
|
||||
{
|
||||
if ( this.s.dt.oInstance[i] == this.s.dt.nTable )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Create the DOM needed for the button and apply some base properties. All buttons start here
|
||||
* @method _fnDomBaseButton
|
||||
* @param {String} text Button text
|
||||
* @returns {Node} DIV element for the button
|
||||
* @private
|
||||
*/
|
||||
"_fnDomBaseButton": function ( text )
|
||||
{
|
||||
var
|
||||
that = this,
|
||||
nButton = document.createElement('button'),
|
||||
nSpan = document.createElement('span'),
|
||||
sEvent = this.s.activate=="mouseover" ? "mouseover" : "click";
|
||||
|
||||
nButton.className = !this.s.dt.bJUI ? "ColVis_Button TableTools_Button" :
|
||||
"ColVis_Button TableTools_Button ui-button ui-state-default";
|
||||
nButton.appendChild( nSpan );
|
||||
nSpan.innerHTML = text;
|
||||
|
||||
$(nButton).bind( sEvent, function (e) {
|
||||
that._fnCollectionShow();
|
||||
e.preventDefault();
|
||||
} );
|
||||
|
||||
return nButton;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Create the element used to contain list the columns (it is shown and hidden as needed)
|
||||
* @method _fnDomCollection
|
||||
* @returns {Node} div container for the collection
|
||||
* @private
|
||||
*/
|
||||
"_fnDomCollection": function ()
|
||||
{
|
||||
var that = this;
|
||||
var nHidden = document.createElement('div');
|
||||
nHidden.style.display = "none";
|
||||
nHidden.className = !this.s.dt.bJUI ? "ColVis_collection TableTools_collection" :
|
||||
"ColVis_collection TableTools_collection ui-buttonset ui-buttonset-multi";
|
||||
|
||||
if ( !this.s.bCssPosition )
|
||||
{
|
||||
nHidden.style.position = "absolute";
|
||||
}
|
||||
$(nHidden).css('opacity', 0);
|
||||
|
||||
return nHidden;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* An element to be placed on top of the activate button to catch events
|
||||
* @method _fnDomCatcher
|
||||
* @returns {Node} div container for the collection
|
||||
* @private
|
||||
*/
|
||||
"_fnDomCatcher": function ()
|
||||
{
|
||||
var
|
||||
that = this,
|
||||
nCatcher = document.createElement('div');
|
||||
nCatcher.className = "ColVis_catcher TableTools_catcher";
|
||||
|
||||
$(nCatcher).click( function () {
|
||||
that._fnCollectionHide.call( that, null, null );
|
||||
} );
|
||||
|
||||
return nCatcher;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Create the element used to shade the background, and capture hide events (it is shown and
|
||||
* hidden as needed)
|
||||
* @method _fnDomBackground
|
||||
* @returns {Node} div container for the background
|
||||
* @private
|
||||
*/
|
||||
"_fnDomBackground": function ()
|
||||
{
|
||||
var that = this;
|
||||
|
||||
var nBackground = document.createElement('div');
|
||||
nBackground.style.position = "absolute";
|
||||
nBackground.style.left = "0px";
|
||||
nBackground.style.top = "0px";
|
||||
nBackground.className = "ColVis_collectionBackground TableTools_collectionBackground";
|
||||
$(nBackground).css('opacity', 0);
|
||||
|
||||
$(nBackground).click( function () {
|
||||
that._fnCollectionHide.call( that, null, null );
|
||||
} );
|
||||
|
||||
/* When considering a mouse over action for the activation, we also consider a mouse out
|
||||
* which is the same as a mouse over the background - without all the messing around of
|
||||
* bubbling events. Use the catcher element to avoid messing around with bubbling
|
||||
*/
|
||||
if ( this.s.activate == "mouseover" )
|
||||
{
|
||||
$(nBackground).mouseover( function () {
|
||||
that.s.overcollection = false;
|
||||
that._fnCollectionHide.call( that, null, null );
|
||||
} );
|
||||
}
|
||||
|
||||
return nBackground;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Show the show / hide list and the background
|
||||
* @method _fnCollectionShow
|
||||
* @returns void
|
||||
* @private
|
||||
*/
|
||||
"_fnCollectionShow": function ()
|
||||
{
|
||||
var that = this, i, iLen;
|
||||
var oPos = $(this.dom.button).offset();
|
||||
var nHidden = this.dom.collection;
|
||||
var nBackground = this.dom.background;
|
||||
var iDivX = parseInt(oPos.left, 10);
|
||||
var iDivY = parseInt(oPos.top + $(this.dom.button).outerHeight(), 10);
|
||||
|
||||
if ( !this.s.bCssPosition )
|
||||
{
|
||||
nHidden.style.top = iDivY+"px";
|
||||
nHidden.style.left = iDivX+"px";
|
||||
}
|
||||
nHidden.style.display = "block";
|
||||
$(nHidden).css('opacity',0);
|
||||
|
||||
var iWinHeight = $(window).height(), iDocHeight = $(document).height(),
|
||||
iWinWidth = $(window).width(), iDocWidth = $(document).width();
|
||||
|
||||
nBackground.style.height = ((iWinHeight>iDocHeight)? iWinHeight : iDocHeight) +"px";
|
||||
nBackground.style.width = ((iWinWidth<iDocWidth)? iWinWidth : iDocWidth) +"px";
|
||||
|
||||
var oStyle = this.dom.catcher.style;
|
||||
oStyle.height = $(this.dom.button).outerHeight()+"px";
|
||||
oStyle.width = $(this.dom.button).outerWidth()+"px";
|
||||
oStyle.top = oPos.top+"px";
|
||||
oStyle.left = iDivX+"px";
|
||||
|
||||
document.body.appendChild( nBackground );
|
||||
document.body.appendChild( nHidden );
|
||||
document.body.appendChild( this.dom.catcher );
|
||||
|
||||
/* Resize the buttons */
|
||||
if ( this.s.sSize == "auto" )
|
||||
{
|
||||
var aiSizes = [];
|
||||
this.dom.collection.style.width = "auto";
|
||||
for ( i=0, iLen=this.dom.buttons.length ; i<iLen ; i++ )
|
||||
{
|
||||
if ( this.dom.buttons[i] !== null )
|
||||
{
|
||||
this.dom.buttons[i].style.width = "auto";
|
||||
aiSizes.push( $(this.dom.buttons[i]).outerWidth() );
|
||||
}
|
||||
}
|
||||
iMax = Math.max.apply(window, aiSizes);
|
||||
for ( i=0, iLen=this.dom.buttons.length ; i<iLen ; i++ )
|
||||
{
|
||||
if ( this.dom.buttons[i] !== null )
|
||||
{
|
||||
this.dom.buttons[i].style.width = iMax+"px";
|
||||
}
|
||||
}
|
||||
this.dom.collection.style.width = iMax+"px";
|
||||
}
|
||||
|
||||
/* Visual corrections to try and keep the collection visible */
|
||||
if ( !this.s.bCssPosition )
|
||||
{
|
||||
nHidden.style.left = this.s.sAlign=="left" ?
|
||||
iDivX+"px" : (iDivX-$(nHidden).outerWidth()+$(this.dom.button).outerWidth())+"px";
|
||||
|
||||
var iDivWidth = $(nHidden).outerWidth();
|
||||
var iDivHeight = $(nHidden).outerHeight();
|
||||
|
||||
if ( iDivX + iDivWidth > iDocWidth )
|
||||
{
|
||||
nHidden.style.left = (iDocWidth-iDivWidth)+"px";
|
||||
}
|
||||
}
|
||||
|
||||
/* This results in a very small delay for the end user but it allows the animation to be
|
||||
* much smoother. If you don't want the animation, then the setTimeout can be removed
|
||||
*/
|
||||
setTimeout( function () {
|
||||
$(nHidden).animate({"opacity": 1}, that.s.iOverlayFade);
|
||||
$(nBackground).animate({"opacity": 0.1}, that.s.iOverlayFade, 'linear', function () {
|
||||
/* In IE6 if you set the checked attribute of a hidden checkbox, then this is not visually
|
||||
* reflected. As such, we need to do it here, once it is visible. Unbelievable.
|
||||
*/
|
||||
if ( jQuery.browser.msie && jQuery.browser.version == "6.0" )
|
||||
{
|
||||
that._fnDrawCallback();
|
||||
}
|
||||
});
|
||||
}, 10 );
|
||||
|
||||
this.s.hidden = false;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Hide the show / hide list and the background
|
||||
* @method _fnCollectionHide
|
||||
* @returns void
|
||||
* @private
|
||||
*/
|
||||
"_fnCollectionHide": function ( )
|
||||
{
|
||||
var that = this;
|
||||
|
||||
if ( !this.s.hidden && this.dom.collection !== null )
|
||||
{
|
||||
this.s.hidden = true;
|
||||
|
||||
$(this.dom.collection).animate({"opacity": 0}, that.s.iOverlayFade, function (e) {
|
||||
this.style.display = "none";
|
||||
} );
|
||||
|
||||
$(this.dom.background).animate({"opacity": 0}, that.s.iOverlayFade, function (e) {
|
||||
document.body.removeChild( that.dom.background );
|
||||
document.body.removeChild( that.dom.catcher );
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Alter the colspan on any fnOpen rows
|
||||
*/
|
||||
"_fnAdjustOpenRows": function ()
|
||||
{
|
||||
var aoOpen = this.s.dt.aoOpenRows;
|
||||
var iVisible = this.s.dt.oApi._fnVisbleColumns( this.s.dt );
|
||||
|
||||
for ( var i=0, iLen=aoOpen.length ; i<iLen ; i++ ) {
|
||||
aoOpen[i].nTr.getElementsByTagName('td')[0].colSpan = iVisible;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Static object methods
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/**
|
||||
* Rebuild the collection for a given table, or all tables if no parameter given
|
||||
* @method ColVis.fnRebuild
|
||||
* @static
|
||||
* @param object oTable DataTable instance to consider - optional
|
||||
* @returns void
|
||||
*/
|
||||
ColVis.fnRebuild = function ( oTable )
|
||||
{
|
||||
var nTable = null;
|
||||
if ( typeof oTable != 'undefined' )
|
||||
{
|
||||
nTable = oTable.fnSettings().nTable;
|
||||
}
|
||||
|
||||
for ( var i=0, iLen=ColVis.aInstances.length ; i<iLen ; i++ )
|
||||
{
|
||||
if ( typeof oTable == 'undefined' || nTable == ColVis.aInstances[i].s.dt.nTable )
|
||||
{
|
||||
ColVis.aInstances[i].fnRebuild();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Static object propterties
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/**
|
||||
* Collection of all ColVis instances
|
||||
* @property ColVis.aInstances
|
||||
* @static
|
||||
* @type Array
|
||||
* @default []
|
||||
*/
|
||||
ColVis.aInstances = [];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constants
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/**
|
||||
* Name of this class
|
||||
* @constant CLASS
|
||||
* @type String
|
||||
* @default ColVis
|
||||
*/
|
||||
ColVis.prototype.CLASS = "ColVis";
|
||||
|
||||
|
||||
/**
|
||||
* ColVis version
|
||||
* @constant VERSION
|
||||
* @type String
|
||||
* @default See code
|
||||
*/
|
||||
ColVis.VERSION = "1.0.7";
|
||||
ColVis.prototype.VERSION = ColVis.VERSION;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Initialisation
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* Register a new feature with DataTables
|
||||
*/
|
||||
if ( typeof $.fn.dataTable == "function" &&
|
||||
typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
|
||||
$.fn.dataTableExt.fnVersionCheck('1.7.0') )
|
||||
{
|
||||
$.fn.dataTableExt.aoFeatures.push( {
|
||||
"fnInit": function( oDTSettings ) {
|
||||
var init = (typeof oDTSettings.oInit.oColVis == 'undefined') ?
|
||||
{} : oDTSettings.oInit.oColVis;
|
||||
var oColvis = new ColVis( oDTSettings, init );
|
||||
return oColvis.dom.wrapper;
|
||||
},
|
||||
"cFeature": "C",
|
||||
"sFeature": "ColVis"
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
alert( "Warning: ColVis requires DataTables 1.7 or greater - www.datatables.net/download");
|
||||
}
|
||||
|
||||
})(jQuery);
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* File: jquery.dataTables.columnFilter.js
|
||||
* Version: 1.4.8.
|
||||
* Version: 1.5.3.
|
||||
* Author: Jovan Popovic
|
||||
*
|
||||
* Copyright 2011-2012 Jovan Popovic, all rights reserved.
|
||||
* Copyright 2011-2014 Jovan Popovic, all rights reserved.
|
||||
*
|
||||
* This source file is free software, under either the GPL v2 license or a
|
||||
* BSD style license, as supplied with this software.
|
||||
|
@ -65,11 +65,11 @@
|
|||
// use all rows
|
||||
else aiRows = oSettings.aiDisplayMaster; // all row numbers
|
||||
|
||||
// set up data array
|
||||
// set up data array
|
||||
var asResultData = new Array();
|
||||
|
||||
for (var i = 0, c = aiRows.length; i < c; i++) {
|
||||
iRow = aiRows[i];
|
||||
var iRow = aiRows[i];
|
||||
var aData = oTable.fnGetData(iRow);
|
||||
var sValue = aData[iColumn];
|
||||
|
||||
|
@ -103,8 +103,7 @@
|
|||
label = label.replace(/(^\s*)|(\s*$)/g, "");
|
||||
var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
|
||||
var search_init = 'search_init ';
|
||||
//var inputvalue = label;
|
||||
var inputvalue = '';
|
||||
var inputvalue = label;
|
||||
if (currentFilter != '' && currentFilter != '^') {
|
||||
if (bIsNumber && currentFilter.charAt(0) == '^')
|
||||
inputvalue = currentFilter.substr(1); //ignore trailing ^
|
||||
|
@ -113,7 +112,7 @@
|
|||
search_init = '';
|
||||
}
|
||||
|
||||
var input = $('<input type="text" class="' + search_init + sCSSClass + '" value="' + inputvalue + '"/>');
|
||||
var input = $('<input type="text" class="' + search_init + sCSSClass + '" value="' + inputvalue + '" rel="' + i + '"/>');
|
||||
if (iMaxLenght != undefined && iMaxLenght != -1) {
|
||||
input.attr('maxlength', iMaxLenght);
|
||||
}
|
||||
|
@ -134,32 +133,29 @@
|
|||
});
|
||||
} else {
|
||||
input.keyup(function () {
|
||||
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);
|
||||
}
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -172,37 +168,24 @@
|
|||
input.blur(function () {
|
||||
if (this.value == "") {
|
||||
$(this).addClass("search_init");
|
||||
//this.value = asInitVals[index];
|
||||
this.value = "";
|
||||
this.value = asInitVals[index];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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" || th.attr('id') == "cuein" || th.attr('id') == "cueout") {
|
||||
label = $.i18n._("hh:mm:ss.t");
|
||||
} else if (th.attr('id') == "sample_rate") {
|
||||
label = $.i18n._("kHz");
|
||||
}
|
||||
|
||||
//var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
|
||||
th.html(_fnRangeLabelPart(0));
|
||||
var sFromId = oTable.attr("id") + '_range_from_' + i;
|
||||
var from = $('<input type="text" class="number_range_filter" id="' + sFromId + '" rel="' + i + '" placeholder="' + label + '"/>');
|
||||
var from = $('<input type="text" class="number_range_filter" id="' + sFromId + '" rel="' + i + '"/>');
|
||||
th.append(from);
|
||||
th.append(_fnRangeLabelPart(1));
|
||||
var sToId = oTable.attr("id") + '_range_to_' + i;
|
||||
var to = $('<input type="text" class="number_range_filter" id="' + sToId + '" rel="' + i + '" placeholder="' + label + '"/>');
|
||||
var to = $('<input type="text" class="number_range_filter" id="' + sToId + '" rel="' + i + '"/>');
|
||||
th.append(to);
|
||||
th.append(_fnRangeLabelPart(2));
|
||||
th.wrapInner('<span class="filterColumn filter_number_range" />');
|
||||
th.wrapInner('<span class="filter_column filter_number_range" />');
|
||||
var index = i;
|
||||
aiCustomSearch_Indexes.push(i);
|
||||
|
||||
|
@ -211,50 +194,48 @@
|
|||
//------------start range filtering function
|
||||
|
||||
|
||||
/* Custom filtering function which will filter data in column four between two values
|
||||
* Author: Allan Jardine, Modified by Jovan Popovic
|
||||
/* Custom filtering function which will filter data in column four between two values
|
||||
* Author: Allan Jardine, Modified by Jovan Popovic
|
||||
*/
|
||||
//$.fn.dataTableExt.afnFiltering.push(
|
||||
oTable.dataTableExt.afnFiltering.push(
|
||||
function (oSettings, aData, iDataIndex) {
|
||||
if (oTable.attr("id") != oSettings.sTableId)
|
||||
return true;
|
||||
// Try to handle missing nodes more gracefully
|
||||
if (document.getElementById(sFromId) == null)
|
||||
return true;
|
||||
var iMin = document.getElementById(sFromId).value * 1;
|
||||
var iMax = document.getElementById(sToId).value * 1;
|
||||
var iValue = aData[_fnColumnIndex(index)] == "-" ? 0 : aData[_fnColumnIndex(index)] * 1;
|
||||
if (iMin == "" && iMax == "") {
|
||||
return true;
|
||||
}
|
||||
else if (iMin == "" && iValue <= iMax) {
|
||||
return true;
|
||||
}
|
||||
else if (iMin <= iValue && "" == iMax) {
|
||||
return true;
|
||||
}
|
||||
else if (iMin <= iValue && iValue <= iMax) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function (oSettings, aData, iDataIndex) {
|
||||
if (oTable.attr("id") != oSettings.sTableId)
|
||||
return true;
|
||||
// Try to handle missing nodes more gracefully
|
||||
if (document.getElementById(sFromId) == null)
|
||||
return true;
|
||||
var iMin = document.getElementById(sFromId).value * 1;
|
||||
var iMax = document.getElementById(sToId).value * 1;
|
||||
var iValue = aData[_fnColumnIndex(index)] == "-" ? 0 : aData[_fnColumnIndex(index)] * 1;
|
||||
if (iMin == "" && iMax == "") {
|
||||
return true;
|
||||
}
|
||||
else if (iMin == "" && iValue <= iMax) {
|
||||
return true;
|
||||
}
|
||||
else if (iMin <= iValue && "" == iMax) {
|
||||
return true;
|
||||
}
|
||||
else if (iMin <= iValue && iValue <= iMax) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
//------------end range filtering function
|
||||
|
||||
|
||||
|
||||
$('#' + sFromId + ',#' + sToId, th).keyup(function () {
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
|
||||
|
@ -262,17 +243,38 @@
|
|||
|
||||
|
||||
function fnCreateDateRangeInput(oTable) {
|
||||
th.html(_fnRangeLabelPart(0));
|
||||
|
||||
var aoFragments = sRangeFormat.split(/[}{]/);
|
||||
|
||||
th.html("");
|
||||
//th.html(_fnRangeLabelPart(0));
|
||||
var sFromId = oTable.attr("id") + '_range_from_' + i;
|
||||
var from = $('<input type="text" class="date_range_filter" id="' + sFromId + '" rel="' + i + '"/>');
|
||||
from.datepicker();
|
||||
th.append(from);
|
||||
th.append(_fnRangeLabelPart(1));
|
||||
//th.append(from);
|
||||
//th.append(_fnRangeLabelPart(1));
|
||||
var sToId = oTable.attr("id") + '_range_to_' + i;
|
||||
var to = $('<input type="text" class="date_range_filter" id="' + sToId + '" rel="' + i + '"/>');
|
||||
th.append(to);
|
||||
th.append(_fnRangeLabelPart(2));
|
||||
th.wrapInner('<span class="filterColumn filter_date_range" />');
|
||||
//th.append(to);
|
||||
//th.append(_fnRangeLabelPart(2));
|
||||
|
||||
for (ti = 0; ti < aoFragments.length; ti++) {
|
||||
|
||||
if (aoFragments[ti] == properties.sDateFromToken) {
|
||||
th.append(from);
|
||||
} else {
|
||||
if (aoFragments[ti] == properties.sDateToToken) {
|
||||
th.append(to);
|
||||
} else {
|
||||
th.append(aoFragments[ti]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
th.wrapInner('<span class="filter_column filter_date_range" />');
|
||||
to.datepicker();
|
||||
var index = i;
|
||||
aiCustomSearch_Indexes.push(i);
|
||||
|
@ -282,41 +284,41 @@
|
|||
|
||||
//$.fn.dataTableExt.afnFiltering.push(
|
||||
oTable.dataTableExt.afnFiltering.push(
|
||||
function (oSettings, aData, iDataIndex) {
|
||||
if (oTable.attr("id") != oSettings.sTableId)
|
||||
return true;
|
||||
function (oSettings, aData, iDataIndex) {
|
||||
if (oTable.attr("id") != oSettings.sTableId)
|
||||
return true;
|
||||
|
||||
var dStartDate = from.datepicker("getDate");
|
||||
var dStartDate = from.datepicker("getDate");
|
||||
|
||||
var dEndDate = to.datepicker("getDate");
|
||||
var dEndDate = to.datepicker("getDate");
|
||||
|
||||
if (dStartDate == null && dEndDate == null) {
|
||||
return true;
|
||||
}
|
||||
if (dStartDate == null && dEndDate == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var dCellDate = null;
|
||||
try {
|
||||
if (aData[_fnColumnIndex(index)] == null || aData[_fnColumnIndex(index)] == "")
|
||||
return false;
|
||||
dCellDate = $.datepicker.parseDate($.datepicker.regional[""].dateFormat, aData[_fnColumnIndex(index)]);
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
if (dCellDate == null)
|
||||
return false;
|
||||
var dCellDate = null;
|
||||
try {
|
||||
if (aData[_fnColumnIndex(index)] == null || aData[_fnColumnIndex(index)] == "")
|
||||
return false;
|
||||
dCellDate = $.datepicker.parseDate($.datepicker.regional[""].dateFormat, aData[_fnColumnIndex(index)]);
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
if (dCellDate == null)
|
||||
return false;
|
||||
|
||||
|
||||
if (dStartDate == null && dCellDate <= dEndDate) {
|
||||
return true;
|
||||
}
|
||||
else if (dStartDate <= dCellDate && dEndDate == null) {
|
||||
return true;
|
||||
}
|
||||
else if (dStartDate <= dCellDate && dCellDate <= dEndDate) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (dStartDate == null && dCellDate <= dEndDate) {
|
||||
return true;
|
||||
}
|
||||
else if (dStartDate <= dCellDate && dEndDate == null) {
|
||||
return true;
|
||||
}
|
||||
else if (dStartDate <= dCellDate && dCellDate <= dEndDate) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
//------------end date range filtering function
|
||||
|
||||
|
@ -328,19 +330,24 @@
|
|||
|
||||
}
|
||||
|
||||
function fnCreateColumnSelect(oTable, aData, iColumn, nTh, sLabel, bRegex) {
|
||||
function fnCreateColumnSelect(oTable, aData, iColumn, nTh, sLabel, bRegex, oSelected) {
|
||||
if (aData == null)
|
||||
aData = _fnGetColumnValues(oTable.fnSettings(), iColumn, true, false, true);
|
||||
var index = iColumn;
|
||||
var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
|
||||
if (currentFilter == null || currentFilter == "")//Issue 81
|
||||
currentFilter = oSelected;
|
||||
|
||||
var r = '<select class="search_init select_filter"><option value="" class="search_init">' + sLabel + '</option>';
|
||||
var r = '<select class="search_init select_filter" rel="' + i + '"><option value="" class="search_init">' + sLabel + '</option>';
|
||||
var j = 0;
|
||||
var iLen = aData.length;
|
||||
for (j = 0; j < iLen; j++) {
|
||||
if (typeof (aData[j]) != 'object') {
|
||||
var selected = '';
|
||||
if (escape(aData[j]) == currentFilter || escape(aData[j]) == escape(currentFilter)) selected = 'selected '
|
||||
if (escape(aData[j]) == currentFilter
|
||||
|| escape(aData[j]) == escape(currentFilter)
|
||||
)
|
||||
selected = 'selected '
|
||||
r += '<option ' + selected + ' value="' + escape(aData[j]) + '">' + aData[j] + '</option>';
|
||||
}
|
||||
else {
|
||||
|
@ -358,7 +365,7 @@
|
|||
|
||||
var select = $(r + '</select>');
|
||||
nTh.html(select);
|
||||
nTh.wrapInner('<span class="filterColumn filter_select" />');
|
||||
nTh.wrapInner('<span class="filter_column filter_select" />');
|
||||
select.change(function () {
|
||||
//var val = $(this).val();
|
||||
if ($(this).val() != "") {
|
||||
|
@ -372,9 +379,11 @@
|
|||
oTable.fnFilter(unescape($(this).val()), iColumn); //Issue 25
|
||||
fnOnFiltered();
|
||||
});
|
||||
if (currentFilter != null && currentFilter != "")//Issue 81
|
||||
oTable.fnFilter(unescape(currentFilter), iColumn);
|
||||
}
|
||||
|
||||
function fnCreateSelect(oTable, aData, bRegex) {
|
||||
function fnCreateSelect(oTable, aData, bRegex, oSelected) {
|
||||
var oSettings = oTable.fnSettings();
|
||||
if (aData == null && oSettings.sAjaxSource != "" && !oSettings.oFeatures.bServerSide) {
|
||||
// Add a function to the draw callback, which will check for the Ajax data having
|
||||
|
@ -386,7 +395,7 @@
|
|||
// Only rebuild the select on the second draw - i.e. when the Ajax
|
||||
// data has been loaded.
|
||||
if (oSettings.iDraw == 2 && oSettings.sAjaxSource != null && oSettings.sAjaxSource != "" && !oSettings.oFeatures.bServerSide) {
|
||||
return fnCreateColumnSelect(oTable, null, _fnColumnIndex(iColumn), nTh, sLabel, bRegex); //Issue 37
|
||||
return fnCreateColumnSelect(oTable, null, _fnColumnIndex(iColumn), nTh, sLabel, bRegex, oSelected); //Issue 37
|
||||
}
|
||||
};
|
||||
})(i, th, label),
|
||||
|
@ -394,10 +403,26 @@
|
|||
});
|
||||
}
|
||||
// Regardless of the Ajax state, build the select on first pass
|
||||
fnCreateColumnSelect(oTable, aData, _fnColumnIndex(i), th, label, bRegex); //Issue 37
|
||||
fnCreateColumnSelect(oTable, aData, _fnColumnIndex(i), th, label, bRegex, oSelected); //Issue 37
|
||||
|
||||
}
|
||||
|
||||
function fnCreateDropdown(aData) {
|
||||
var index = i;
|
||||
var r = '<div class="dropdown select_filter"><a class="dropdown-toggle" data-toggle="dropdown" href="#">' + label + '<b class="caret"></b></a><ul class="dropdown-menu" role="menu"><li data-value=""><a>Show All</a></li>', j, iLen = aData.length;
|
||||
|
||||
for (j = 0; j < iLen; j++) {
|
||||
r += '<li data-value="' + aData[j] + '"><a>' + aData[j] + '</a></li>';
|
||||
}
|
||||
var select = $(r + '</ul></div>');
|
||||
th.html(select);
|
||||
th.wrapInner('<span class="filterColumn filter_select" />');
|
||||
select.find('li').click(function () {
|
||||
oTable.fnFilter($(this).data('value'), index);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function fnCreateCheckbox(oTable, aData) {
|
||||
|
||||
if (aData == null)
|
||||
|
@ -412,10 +437,9 @@
|
|||
//clean the string
|
||||
|
||||
//button label override
|
||||
var labelBtn = label;
|
||||
if (properties.sFilterButtonText != null || properties.sFilterButtonText != undefined) {
|
||||
labelBtn = properties.sFilterButtonText;
|
||||
} else {
|
||||
labelBtn = label;
|
||||
}
|
||||
|
||||
var relativeDivWidthToggleSize = 10;
|
||||
|
@ -442,8 +466,9 @@
|
|||
var checkToggleDiv = uniqueId + "-flt-toggle";
|
||||
r += '<button id="' + buttonId + '" class="checkbox_filter" > ' + labelBtn + '</button>'; //filter button witch open dialog
|
||||
r += '<div id="' + checkToggleDiv + '" '
|
||||
+ 'title="' + label + '" '
|
||||
+ 'class="toggle-check ui-widget-content ui-corner-all" style="width: ' + (divWidthToggle) + '%; " >'; //dialog div
|
||||
+ 'title="' + label + '" '
|
||||
+ 'rel="' + i + '" '
|
||||
+ 'class="toggle-check ui-widget-content ui-corner-all" style="width: ' + (divWidthToggle) + '%; " >'; //dialog div
|
||||
//r+= '<div align="center" style="margin-top: 5px; "> <button id="'+buttonId+'Reset" class="checkbox_filter" > reset </button> </div>'; //reset button and its div
|
||||
r += divRowDef;
|
||||
|
||||
|
@ -454,12 +479,20 @@
|
|||
r += divClose + divRowDef;
|
||||
}
|
||||
|
||||
var sLabel = aData[j];
|
||||
var sValue = aData[j];
|
||||
|
||||
if (typeof (aData[j]) == 'object') {
|
||||
sLabel = aData[j].label;
|
||||
sValue = aData[j].value;
|
||||
}
|
||||
|
||||
//check button
|
||||
r += '<input class="search_init checkbox_filter" type="checkbox" id= "' + aData[j] + '" name= "' + localLabel + '" value="' + aData[j] + '" >' + aData[j] + '<br/>';
|
||||
r += '<input class="search_init checkbox_filter" type="checkbox" id= "' + uniqueId + '_cb_' + sValue + '" name= "' + localLabel + '" value="' + sValue + '" >' + sLabel + '<br/>';
|
||||
|
||||
var checkbox = $(r);
|
||||
th.html(checkbox);
|
||||
th.wrapInner('<span class="filterColumn filter_checkbox" />');
|
||||
th.wrapInner('<span class="filter_column filter_checkbox" />');
|
||||
//on every checkbox selection
|
||||
checkbox.change(function () {
|
||||
|
||||
|
@ -471,7 +504,7 @@
|
|||
//search = search + ' ' + $(this).val();
|
||||
//concatenation for selected checks in or
|
||||
if ((index == 0 && resSize == 1)
|
||||
|| (index != 0 && index == resSize - 1)) {
|
||||
|| (index != 0 && index == resSize - 1)) {
|
||||
or = '';
|
||||
}
|
||||
//trim
|
||||
|
@ -481,6 +514,13 @@
|
|||
|
||||
});
|
||||
|
||||
|
||||
if (search != "") {
|
||||
$('input:checkbox[name="' + localLabel + '"]').removeClass("search_init");
|
||||
} else {
|
||||
$('input:checkbox[name="' + localLabel + '"]').addClass("search_init");
|
||||
}
|
||||
/* Old code for setting search_init CSS class on checkboxes if any of them is checked
|
||||
for (var jj = 0; jj < iLen; jj++) {
|
||||
if (search != "") {
|
||||
$('#' + aData[jj]).removeClass("search_init");
|
||||
|
@ -488,6 +528,7 @@
|
|||
$('#' + aData[jj]).addClass("search_init");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//execute search
|
||||
oTable.fnFilter(search, index, true, false);
|
||||
|
@ -516,11 +557,11 @@
|
|||
return false;
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Close",
|
||||
click: function () { $(this).dialog("close"); }
|
||||
}
|
||||
]
|
||||
{
|
||||
text: "Close",
|
||||
click: function () { $(this).dialog("close"); }
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
@ -578,25 +619,27 @@
|
|||
|
||||
|
||||
|
||||
oTable = this;
|
||||
var oTable = this;
|
||||
|
||||
var defaults = {
|
||||
sPlaceHolder: "foot",
|
||||
sRangeSeparator: "~",
|
||||
iFilteringDelay: 500,
|
||||
aoColumns: null,
|
||||
sRangeFormat: $.i18n._("From {from} to {to}")
|
||||
sRangeFormat: "From {from} to {to}",
|
||||
sDateFromToken: "from",
|
||||
sDateToToken: "to"
|
||||
};
|
||||
|
||||
properties = $.extend(defaults, options);
|
||||
|
||||
var properties = $.extend(defaults, options);
|
||||
|
||||
return this.each(function () {
|
||||
|
||||
if (!oTable.fnSettings().oFeatures.bFilter)
|
||||
return;
|
||||
asInitVals = new Array();
|
||||
|
||||
aoFilterCells = oTable.fnSettings().aoFooter[0];
|
||||
var aoFilterCells = oTable.fnSettings().aoFooter[0];
|
||||
|
||||
var oHost = oTable.fnSettings().nTFoot; //Before fix for ColVis
|
||||
var sFilterRow = "tr"; //Before fix for ColVis
|
||||
|
@ -679,7 +722,7 @@
|
|||
case "select":
|
||||
if (aoColumn.bRegex != true)
|
||||
aoColumn.bRegex = false;
|
||||
fnCreateSelect(oTable, aoColumn.values, aoColumn.bRegex);
|
||||
fnCreateSelect(oTable, aoColumn.values, aoColumn.bRegex, aoColumn.selected);
|
||||
break;
|
||||
case "number-range":
|
||||
fnCreateRangeInput(oTable);
|
||||
|
@ -689,6 +732,10 @@
|
|||
break;
|
||||
case "checkbox":
|
||||
fnCreateCheckbox(oTable, aoColumn.values);
|
||||
break;
|
||||
case "twitter-dropdown":
|
||||
case "dropdown":
|
||||
fnCreateDropdown(aoColumn.values);
|
||||
break;
|
||||
case "text":
|
||||
default:
|
||||
|
@ -700,7 +747,7 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
|
||||
//var index = aiCustomSearch_Indexes[j];
|
||||
var fnSearch_ = function () {
|
||||
|
@ -749,4 +796,4 @@
|
|||
|
||||
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery);
|
|
@ -1,799 +0,0 @@
|
|||
/*
|
||||
* File: jquery.dataTables.columnFilter.js
|
||||
* Version: 1.5.3.
|
||||
* Author: Jovan Popovic
|
||||
*
|
||||
* Copyright 2011-2014 Jovan Popovic, all rights reserved.
|
||||
*
|
||||
* This source file is free software, under either the GPL v2 license or a
|
||||
* BSD style license, as supplied with this software.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Parameters:"
|
||||
* @sPlaceHolder String Place where inline filtering function should be placed ("tfoot", "thead:before", "thead:after"). Default is "tfoot"
|
||||
* @sRangeSeparator String Separator that will be used when range values are sent to the server-side. Default value is "~".
|
||||
* @sRangeFormat string Default format of the From ... to ... range inputs. Default is From {from} to {to}
|
||||
* @aoColumns Array Array of the filter settings that will be applied on the columns
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
|
||||
$.fn.columnFilter = function (options) {
|
||||
|
||||
var asInitVals, i, label, th;
|
||||
|
||||
//var sTableId = "table";
|
||||
var sRangeFormat = "From {from} to {to}";
|
||||
//Array of the functions that will override sSearch_ parameters
|
||||
var afnSearch_ = new Array();
|
||||
var aiCustomSearch_Indexes = new Array();
|
||||
|
||||
var oFunctionTimeout = null;
|
||||
|
||||
var fnOnFiltered = function () { };
|
||||
|
||||
function _fnGetColumnValues(oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty) {
|
||||
///<summary>
|
||||
///Return values in the column
|
||||
///</summary>
|
||||
///<param name="oSettings" type="Object">DataTables settings</param>
|
||||
///<param name="iColumn" type="int">Id of the column</param>
|
||||
///<param name="bUnique" type="bool">Return only distinct values</param>
|
||||
///<param name="bFiltered" type="bool">Return values only from the filtered rows</param>
|
||||
///<param name="bIgnoreEmpty" type="bool">Ignore empty cells</param>
|
||||
|
||||
// check that we have a column id
|
||||
if (typeof iColumn == "undefined") return new Array();
|
||||
|
||||
// by default we only wany unique data
|
||||
if (typeof bUnique == "undefined") bUnique = true;
|
||||
|
||||
// by default we do want to only look at filtered data
|
||||
if (typeof bFiltered == "undefined") bFiltered = true;
|
||||
|
||||
// by default we do not wany to include empty values
|
||||
if (typeof bIgnoreEmpty == "undefined") bIgnoreEmpty = true;
|
||||
|
||||
// list of rows which we're going to loop through
|
||||
var aiRows;
|
||||
|
||||
// use only filtered rows
|
||||
if (bFiltered == true) aiRows = oSettings.aiDisplay;
|
||||
// use all rows
|
||||
else aiRows = oSettings.aiDisplayMaster; // all row numbers
|
||||
|
||||
// set up data array
|
||||
var asResultData = new Array();
|
||||
|
||||
for (var i = 0, c = aiRows.length; i < c; i++) {
|
||||
var iRow = aiRows[i];
|
||||
var aData = oTable.fnGetData(iRow);
|
||||
var sValue = aData[iColumn];
|
||||
|
||||
// ignore empty values?
|
||||
if (bIgnoreEmpty == true && sValue.length == 0) continue;
|
||||
|
||||
// ignore unique values?
|
||||
else if (bUnique == true && jQuery.inArray(sValue, asResultData) > -1) continue;
|
||||
|
||||
// else push the value onto the result data array
|
||||
else asResultData.push(sValue);
|
||||
}
|
||||
|
||||
return asResultData.sort();
|
||||
}
|
||||
|
||||
function _fnColumnIndex(iColumnIndex) {
|
||||
if (properties.bUseColVis)
|
||||
return iColumnIndex;
|
||||
else
|
||||
return oTable.fnSettings().oApi._fnVisibleToColumnIndex(oTable.fnSettings(), iColumnIndex);
|
||||
//return iColumnIndex;
|
||||
//return oTable.fnSettings().oApi._fnColumnIndexToVisible(oTable.fnSettings(), iColumnIndex);
|
||||
}
|
||||
|
||||
function fnCreateInput(oTable, regex, smart, bIsNumber, iFilterLength, iMaxLenght) {
|
||||
var sCSSClass = "text_filter";
|
||||
if (bIsNumber)
|
||||
sCSSClass = "number_filter";
|
||||
|
||||
label = label.replace(/(^\s*)|(\s*$)/g, "");
|
||||
var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
|
||||
var search_init = 'search_init ';
|
||||
var inputvalue = label;
|
||||
if (currentFilter != '' && currentFilter != '^') {
|
||||
if (bIsNumber && currentFilter.charAt(0) == '^')
|
||||
inputvalue = currentFilter.substr(1); //ignore trailing ^
|
||||
else
|
||||
inputvalue = currentFilter;
|
||||
search_init = '';
|
||||
}
|
||||
|
||||
var input = $('<input type="text" class="' + search_init + sCSSClass + '" value="' + inputvalue + '" rel="' + i + '"/>');
|
||||
if (iMaxLenght != undefined && iMaxLenght != -1) {
|
||||
input.attr('maxlength', iMaxLenght);
|
||||
}
|
||||
th.html(input);
|
||||
if (bIsNumber)
|
||||
th.wrapInner('<span class="filter_column filter_number" />');
|
||||
else
|
||||
th.wrapInner('<span class="filter_column filter_text" />');
|
||||
|
||||
asInitVals[i] = label;
|
||||
var index = i;
|
||||
|
||||
if (bIsNumber && !oTable.fnSettings().oFeatures.bServerSide) {
|
||||
input.keyup(function () {
|
||||
/* Filter on the column all numbers that starts with the entered value */
|
||||
oTable.fnFilter('^' + this.value, _fnColumnIndex(index), true, false); //Issue 37
|
||||
fnOnFiltered();
|
||||
});
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
/* Filter on the column (the index) of this element */
|
||||
oTable.fnFilter(this.value, _fnColumnIndex(index), regex, smart); //Issue 37
|
||||
fnOnFiltered();
|
||||
});
|
||||
}
|
||||
|
||||
input.focus(function () {
|
||||
if ($(this).hasClass("search_init")) {
|
||||
$(this).removeClass("search_init");
|
||||
this.value = "";
|
||||
}
|
||||
});
|
||||
input.blur(function () {
|
||||
if (this.value == "") {
|
||||
$(this).addClass("search_init");
|
||||
this.value = asInitVals[index];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fnCreateRangeInput(oTable) {
|
||||
|
||||
//var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
|
||||
th.html(_fnRangeLabelPart(0));
|
||||
var sFromId = oTable.attr("id") + '_range_from_' + i;
|
||||
var from = $('<input type="text" class="number_range_filter" id="' + sFromId + '" rel="' + i + '"/>');
|
||||
th.append(from);
|
||||
th.append(_fnRangeLabelPart(1));
|
||||
var sToId = oTable.attr("id") + '_range_to_' + i;
|
||||
var to = $('<input type="text" class="number_range_filter" id="' + sToId + '" rel="' + i + '"/>');
|
||||
th.append(to);
|
||||
th.append(_fnRangeLabelPart(2));
|
||||
th.wrapInner('<span class="filter_column filter_number_range" />');
|
||||
var index = i;
|
||||
aiCustomSearch_Indexes.push(i);
|
||||
|
||||
|
||||
|
||||
//------------start range filtering function
|
||||
|
||||
|
||||
/* Custom filtering function which will filter data in column four between two values
|
||||
* Author: Allan Jardine, Modified by Jovan Popovic
|
||||
*/
|
||||
//$.fn.dataTableExt.afnFiltering.push(
|
||||
oTable.dataTableExt.afnFiltering.push(
|
||||
function (oSettings, aData, iDataIndex) {
|
||||
if (oTable.attr("id") != oSettings.sTableId)
|
||||
return true;
|
||||
// Try to handle missing nodes more gracefully
|
||||
if (document.getElementById(sFromId) == null)
|
||||
return true;
|
||||
var iMin = document.getElementById(sFromId).value * 1;
|
||||
var iMax = document.getElementById(sToId).value * 1;
|
||||
var iValue = aData[_fnColumnIndex(index)] == "-" ? 0 : aData[_fnColumnIndex(index)] * 1;
|
||||
if (iMin == "" && iMax == "") {
|
||||
return true;
|
||||
}
|
||||
else if (iMin == "" && iValue <= iMax) {
|
||||
return true;
|
||||
}
|
||||
else if (iMin <= iValue && "" == iMax) {
|
||||
return true;
|
||||
}
|
||||
else if (iMin <= iValue && iValue <= iMax) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
//------------end range filtering function
|
||||
|
||||
|
||||
|
||||
$('#' + 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();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function fnCreateDateRangeInput(oTable) {
|
||||
|
||||
var aoFragments = sRangeFormat.split(/[}{]/);
|
||||
|
||||
th.html("");
|
||||
//th.html(_fnRangeLabelPart(0));
|
||||
var sFromId = oTable.attr("id") + '_range_from_' + i;
|
||||
var from = $('<input type="text" class="date_range_filter" id="' + sFromId + '" rel="' + i + '"/>');
|
||||
from.datepicker();
|
||||
//th.append(from);
|
||||
//th.append(_fnRangeLabelPart(1));
|
||||
var sToId = oTable.attr("id") + '_range_to_' + i;
|
||||
var to = $('<input type="text" class="date_range_filter" id="' + sToId + '" rel="' + i + '"/>');
|
||||
//th.append(to);
|
||||
//th.append(_fnRangeLabelPart(2));
|
||||
|
||||
for (ti = 0; ti < aoFragments.length; ti++) {
|
||||
|
||||
if (aoFragments[ti] == properties.sDateFromToken) {
|
||||
th.append(from);
|
||||
} else {
|
||||
if (aoFragments[ti] == properties.sDateToToken) {
|
||||
th.append(to);
|
||||
} else {
|
||||
th.append(aoFragments[ti]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
th.wrapInner('<span class="filter_column filter_date_range" />');
|
||||
to.datepicker();
|
||||
var index = i;
|
||||
aiCustomSearch_Indexes.push(i);
|
||||
|
||||
|
||||
//------------start date range filtering function
|
||||
|
||||
//$.fn.dataTableExt.afnFiltering.push(
|
||||
oTable.dataTableExt.afnFiltering.push(
|
||||
function (oSettings, aData, iDataIndex) {
|
||||
if (oTable.attr("id") != oSettings.sTableId)
|
||||
return true;
|
||||
|
||||
var dStartDate = from.datepicker("getDate");
|
||||
|
||||
var dEndDate = to.datepicker("getDate");
|
||||
|
||||
if (dStartDate == null && dEndDate == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var dCellDate = null;
|
||||
try {
|
||||
if (aData[_fnColumnIndex(index)] == null || aData[_fnColumnIndex(index)] == "")
|
||||
return false;
|
||||
dCellDate = $.datepicker.parseDate($.datepicker.regional[""].dateFormat, aData[_fnColumnIndex(index)]);
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
if (dCellDate == null)
|
||||
return false;
|
||||
|
||||
|
||||
if (dStartDate == null && dCellDate <= dEndDate) {
|
||||
return true;
|
||||
}
|
||||
else if (dStartDate <= dCellDate && dEndDate == null) {
|
||||
return true;
|
||||
}
|
||||
else if (dStartDate <= dCellDate && dCellDate <= dEndDate) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
//------------end date range filtering function
|
||||
|
||||
$('#' + sFromId + ',#' + sToId, th).change(function () {
|
||||
oTable.fnDraw();
|
||||
fnOnFiltered();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function fnCreateColumnSelect(oTable, aData, iColumn, nTh, sLabel, bRegex, oSelected) {
|
||||
if (aData == null)
|
||||
aData = _fnGetColumnValues(oTable.fnSettings(), iColumn, true, false, true);
|
||||
var index = iColumn;
|
||||
var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
|
||||
if (currentFilter == null || currentFilter == "")//Issue 81
|
||||
currentFilter = oSelected;
|
||||
|
||||
var r = '<select class="search_init select_filter" rel="' + i + '"><option value="" class="search_init">' + sLabel + '</option>';
|
||||
var j = 0;
|
||||
var iLen = aData.length;
|
||||
for (j = 0; j < iLen; j++) {
|
||||
if (typeof (aData[j]) != 'object') {
|
||||
var selected = '';
|
||||
if (escape(aData[j]) == currentFilter
|
||||
|| escape(aData[j]) == escape(currentFilter)
|
||||
)
|
||||
selected = 'selected '
|
||||
r += '<option ' + selected + ' value="' + escape(aData[j]) + '">' + aData[j] + '</option>';
|
||||
}
|
||||
else {
|
||||
var selected = '';
|
||||
if (bRegex) {
|
||||
//Do not escape values if they are explicitely set to avoid escaping special characters in the regexp
|
||||
if (aData[j].value == currentFilter) selected = 'selected ';
|
||||
r += '<option ' + selected + 'value="' + aData[j].value + '">' + aData[j].label + '</option>';
|
||||
} else {
|
||||
if (escape(aData[j].value) == currentFilter) selected = 'selected ';
|
||||
r += '<option ' + selected + 'value="' + escape(aData[j].value) + '">' + aData[j].label + '</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var select = $(r + '</select>');
|
||||
nTh.html(select);
|
||||
nTh.wrapInner('<span class="filter_column filter_select" />');
|
||||
select.change(function () {
|
||||
//var val = $(this).val();
|
||||
if ($(this).val() != "") {
|
||||
$(this).removeClass("search_init");
|
||||
} else {
|
||||
$(this).addClass("search_init");
|
||||
}
|
||||
if (bRegex)
|
||||
oTable.fnFilter($(this).val(), iColumn, bRegex); //Issue 41
|
||||
else
|
||||
oTable.fnFilter(unescape($(this).val()), iColumn); //Issue 25
|
||||
fnOnFiltered();
|
||||
});
|
||||
if (currentFilter != null && currentFilter != "")//Issue 81
|
||||
oTable.fnFilter(unescape(currentFilter), iColumn);
|
||||
}
|
||||
|
||||
function fnCreateSelect(oTable, aData, bRegex, oSelected) {
|
||||
var oSettings = oTable.fnSettings();
|
||||
if (aData == null && oSettings.sAjaxSource != "" && !oSettings.oFeatures.bServerSide) {
|
||||
// Add a function to the draw callback, which will check for the Ajax data having
|
||||
// been loaded. Use a closure for the individual column elements that are used to
|
||||
// built the column filter, since 'i' and 'th' (etc) are locally "global".
|
||||
oSettings.aoDrawCallback.push({
|
||||
"fn": (function (iColumn, nTh, sLabel) {
|
||||
return function () {
|
||||
// Only rebuild the select on the second draw - i.e. when the Ajax
|
||||
// data has been loaded.
|
||||
if (oSettings.iDraw == 2 && oSettings.sAjaxSource != null && oSettings.sAjaxSource != "" && !oSettings.oFeatures.bServerSide) {
|
||||
return fnCreateColumnSelect(oTable, null, _fnColumnIndex(iColumn), nTh, sLabel, bRegex, oSelected); //Issue 37
|
||||
}
|
||||
};
|
||||
})(i, th, label),
|
||||
"sName": "column_filter_" + i
|
||||
});
|
||||
}
|
||||
// Regardless of the Ajax state, build the select on first pass
|
||||
fnCreateColumnSelect(oTable, aData, _fnColumnIndex(i), th, label, bRegex, oSelected); //Issue 37
|
||||
|
||||
}
|
||||
|
||||
function fnCreateDropdown(aData) {
|
||||
var index = i;
|
||||
var r = '<div class="dropdown select_filter"><a class="dropdown-toggle" data-toggle="dropdown" href="#">' + label + '<b class="caret"></b></a><ul class="dropdown-menu" role="menu"><li data-value=""><a>Show All</a></li>', j, iLen = aData.length;
|
||||
|
||||
for (j = 0; j < iLen; j++) {
|
||||
r += '<li data-value="' + aData[j] + '"><a>' + aData[j] + '</a></li>';
|
||||
}
|
||||
var select = $(r + '</ul></div>');
|
||||
th.html(select);
|
||||
th.wrapInner('<span class="filterColumn filter_select" />');
|
||||
select.find('li').click(function () {
|
||||
oTable.fnFilter($(this).data('value'), index);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function fnCreateCheckbox(oTable, aData) {
|
||||
|
||||
if (aData == null)
|
||||
aData = _fnGetColumnValues(oTable.fnSettings(), i, true, true, true);
|
||||
var index = i;
|
||||
|
||||
var r = '', j, iLen = aData.length;
|
||||
|
||||
//clean the string
|
||||
var localLabel = label.replace('%', 'Perc').replace("&", "AND").replace("$", "DOL").replace("£", "STERL").replace("@", "AT").replace(/\s/g, "_");
|
||||
localLabel = localLabel.replace(/[^a-zA-Z 0-9]+/g, '');
|
||||
//clean the string
|
||||
|
||||
//button label override
|
||||
var labelBtn = label;
|
||||
if (properties.sFilterButtonText != null || properties.sFilterButtonText != undefined) {
|
||||
labelBtn = properties.sFilterButtonText;
|
||||
}
|
||||
|
||||
var relativeDivWidthToggleSize = 10;
|
||||
var numRow = 12; //numero di checkbox per colonna
|
||||
var numCol = Math.floor(iLen / numRow);
|
||||
if (iLen % numRow > 0) {
|
||||
numCol = numCol + 1;
|
||||
};
|
||||
|
||||
//count how many column should be generated and split the div size
|
||||
var divWidth = 100 / numCol - 2;
|
||||
|
||||
var divWidthToggle = relativeDivWidthToggleSize * numCol;
|
||||
|
||||
if (numCol == 1) {
|
||||
divWidth = 20;
|
||||
}
|
||||
|
||||
var divRowDef = '<div style="float:left; min-width: ' + divWidth + '%; " >';
|
||||
var divClose = '</div>';
|
||||
|
||||
var uniqueId = oTable.attr("id") + localLabel;
|
||||
var buttonId = "chkBtnOpen" + uniqueId;
|
||||
var checkToggleDiv = uniqueId + "-flt-toggle";
|
||||
r += '<button id="' + buttonId + '" class="checkbox_filter" > ' + labelBtn + '</button>'; //filter button witch open dialog
|
||||
r += '<div id="' + checkToggleDiv + '" '
|
||||
+ 'title="' + label + '" '
|
||||
+ 'rel="' + i + '" '
|
||||
+ 'class="toggle-check ui-widget-content ui-corner-all" style="width: ' + (divWidthToggle) + '%; " >'; //dialog div
|
||||
//r+= '<div align="center" style="margin-top: 5px; "> <button id="'+buttonId+'Reset" class="checkbox_filter" > reset </button> </div>'; //reset button and its div
|
||||
r += divRowDef;
|
||||
|
||||
for (j = 0; j < iLen; j++) {
|
||||
|
||||
//if last check close div
|
||||
if (j % numRow == 0 && j != 0) {
|
||||
r += divClose + divRowDef;
|
||||
}
|
||||
|
||||
var sLabel = aData[j];
|
||||
var sValue = aData[j];
|
||||
|
||||
if (typeof (aData[j]) == 'object') {
|
||||
sLabel = aData[j].label;
|
||||
sValue = aData[j].value;
|
||||
}
|
||||
|
||||
//check button
|
||||
r += '<input class="search_init checkbox_filter" type="checkbox" id= "' + uniqueId + '_cb_' + sValue + '" name= "' + localLabel + '" value="' + sValue + '" >' + sLabel + '<br/>';
|
||||
|
||||
var checkbox = $(r);
|
||||
th.html(checkbox);
|
||||
th.wrapInner('<span class="filter_column filter_checkbox" />');
|
||||
//on every checkbox selection
|
||||
checkbox.change(function () {
|
||||
|
||||
var search = '';
|
||||
var or = '|'; //var for select checks in 'or' into the regex
|
||||
var resSize = $('input:checkbox[name="' + localLabel + '"]:checked').size();
|
||||
$('input:checkbox[name="' + localLabel + '"]:checked').each(function (index) {
|
||||
|
||||
//search = search + ' ' + $(this).val();
|
||||
//concatenation for selected checks in or
|
||||
if ((index == 0 && resSize == 1)
|
||||
|| (index != 0 && index == resSize - 1)) {
|
||||
or = '';
|
||||
}
|
||||
//trim
|
||||
search = search.replace(/^\s+|\s+$/g, "");
|
||||
search = search + $(this).val() + or;
|
||||
or = '|';
|
||||
|
||||
});
|
||||
|
||||
|
||||
if (search != "") {
|
||||
$('input:checkbox[name="' + localLabel + '"]').removeClass("search_init");
|
||||
} else {
|
||||
$('input:checkbox[name="' + localLabel + '"]').addClass("search_init");
|
||||
}
|
||||
/* Old code for setting search_init CSS class on checkboxes if any of them is checked
|
||||
for (var jj = 0; jj < iLen; jj++) {
|
||||
if (search != "") {
|
||||
$('#' + aData[jj]).removeClass("search_init");
|
||||
} else {
|
||||
$('#' + aData[jj]).addClass("search_init");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//execute search
|
||||
oTable.fnFilter(search, index, true, false);
|
||||
fnOnFiltered();
|
||||
});
|
||||
}
|
||||
|
||||
//filter button
|
||||
$('#' + buttonId).button();
|
||||
//dialog
|
||||
$('#' + checkToggleDiv).dialog({
|
||||
//height: 140,
|
||||
autoOpen: false,
|
||||
//show: "blind",
|
||||
hide: "blind",
|
||||
buttons: [{
|
||||
text: "Reset",
|
||||
click: function () {
|
||||
//$('#'+buttonId).removeClass("filter_selected"); //LM remove border if filter selected
|
||||
$('input:checkbox[name="' + localLabel + '"]:checked').each(function (index3) {
|
||||
$(this).attr('checked', false);
|
||||
$(this).addClass("search_init");
|
||||
});
|
||||
oTable.fnFilter('', index, true, false);
|
||||
fnOnFiltered();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Close",
|
||||
click: function () { $(this).dialog("close"); }
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
$('#' + buttonId).click(function () {
|
||||
|
||||
$('#' + checkToggleDiv).dialog('open');
|
||||
var target = $(this);
|
||||
$('#' + checkToggleDiv).dialog("widget").position({ my: 'top',
|
||||
at: 'bottom',
|
||||
of: target
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
var fnOnFilteredCurrent = fnOnFiltered;
|
||||
|
||||
fnOnFiltered = function () {
|
||||
var target = $('#' + buttonId);
|
||||
$('#' + checkToggleDiv).dialog("widget").position({ my: 'top',
|
||||
at: 'bottom',
|
||||
of: target
|
||||
});
|
||||
fnOnFilteredCurrent();
|
||||
};
|
||||
//reset
|
||||
/*
|
||||
$('#'+buttonId+"Reset").button();
|
||||
$('#'+buttonId+"Reset").click(function(){
|
||||
$('#'+buttonId).removeClass("filter_selected"); //LM remove border if filter selected
|
||||
$('input:checkbox[name="'+localLabel+'"]:checked').each(function(index3) {
|
||||
$(this).attr('checked', false);
|
||||
$(this).addClass("search_init");
|
||||
});
|
||||
oTable.fnFilter('', index, true, false);
|
||||
return false;
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function _fnRangeLabelPart(iPlace) {
|
||||
switch (iPlace) {
|
||||
case 0:
|
||||
return sRangeFormat.substring(0, sRangeFormat.indexOf("{from}"));
|
||||
case 1:
|
||||
return sRangeFormat.substring(sRangeFormat.indexOf("{from}") + 6, sRangeFormat.indexOf("{to}"));
|
||||
default:
|
||||
return sRangeFormat.substring(sRangeFormat.indexOf("{to}") + 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var oTable = this;
|
||||
|
||||
var defaults = {
|
||||
sPlaceHolder: "foot",
|
||||
sRangeSeparator: "~",
|
||||
iFilteringDelay: 500,
|
||||
aoColumns: null,
|
||||
sRangeFormat: "From {from} to {to}",
|
||||
sDateFromToken: "from",
|
||||
sDateToToken: "to"
|
||||
};
|
||||
|
||||
var properties = $.extend(defaults, options);
|
||||
|
||||
return this.each(function () {
|
||||
|
||||
if (!oTable.fnSettings().oFeatures.bFilter)
|
||||
return;
|
||||
asInitVals = new Array();
|
||||
|
||||
var aoFilterCells = oTable.fnSettings().aoFooter[0];
|
||||
|
||||
var oHost = oTable.fnSettings().nTFoot; //Before fix for ColVis
|
||||
var sFilterRow = "tr"; //Before fix for ColVis
|
||||
|
||||
if (properties.sPlaceHolder == "head:after") {
|
||||
var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
|
||||
//tr.appendTo($(oTable.fnSettings().nTHead));
|
||||
if (oTable.fnSettings().bSortCellsTop) {
|
||||
tr.prependTo($(oTable.fnSettings().nTHead));
|
||||
//tr.appendTo($("thead", oTable));
|
||||
aoFilterCells = oTable.fnSettings().aoHeader[1];
|
||||
}
|
||||
else {
|
||||
tr.appendTo($(oTable.fnSettings().nTHead));
|
||||
//tr.prependTo($("thead", oTable));
|
||||
aoFilterCells = oTable.fnSettings().aoHeader[0];
|
||||
}
|
||||
|
||||
sFilterRow = "tr:last";
|
||||
oHost = oTable.fnSettings().nTHead;
|
||||
|
||||
} else if (properties.sPlaceHolder == "head:before") {
|
||||
|
||||
if (oTable.fnSettings().bSortCellsTop) {
|
||||
var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
|
||||
tr.appendTo($(oTable.fnSettings().nTHead));
|
||||
aoFilterCells = oTable.fnSettings().aoHeader[1];
|
||||
} else {
|
||||
aoFilterCells = oTable.fnSettings().aoHeader[0];
|
||||
}
|
||||
/*else {
|
||||
//tr.prependTo($("thead", oTable));
|
||||
sFilterRow = "tr:first";
|
||||
}*/
|
||||
|
||||
sFilterRow = "tr:first";
|
||||
|
||||
oHost = oTable.fnSettings().nTHead;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//$(sFilterRow + " th", oHost).each(function (index) {//bug with ColVis
|
||||
$(aoFilterCells).each(function (index) {//fix for ColVis
|
||||
i = index;
|
||||
var aoColumn = { type: "text",
|
||||
bRegex: false,
|
||||
bSmart: true,
|
||||
iMaxLenght: -1,
|
||||
iFilterLength: 0
|
||||
};
|
||||
if (properties.aoColumns != null) {
|
||||
if (properties.aoColumns.length < i || properties.aoColumns[i] == null)
|
||||
return;
|
||||
aoColumn = properties.aoColumns[i];
|
||||
}
|
||||
//label = $(this).text(); //Before fix for ColVis
|
||||
label = $($(this)[0].cell).text(); //Fix for ColVis
|
||||
if (aoColumn.sSelector == null) {
|
||||
//th = $($(this)[0]);//Before fix for ColVis
|
||||
th = $($(this)[0].cell); //Fix for ColVis
|
||||
}
|
||||
else {
|
||||
th = $(aoColumn.sSelector);
|
||||
if (th.length == 0)
|
||||
th = $($(this)[0].cell);
|
||||
}
|
||||
|
||||
if (aoColumn != null) {
|
||||
if (aoColumn.sRangeFormat != null)
|
||||
sRangeFormat = aoColumn.sRangeFormat;
|
||||
else
|
||||
sRangeFormat = properties.sRangeFormat;
|
||||
switch (aoColumn.type) {
|
||||
case "null":
|
||||
break;
|
||||
case "number":
|
||||
fnCreateInput(oTable, true, false, true, aoColumn.iFilterLength, aoColumn.iMaxLenght);
|
||||
break;
|
||||
case "select":
|
||||
if (aoColumn.bRegex != true)
|
||||
aoColumn.bRegex = false;
|
||||
fnCreateSelect(oTable, aoColumn.values, aoColumn.bRegex, aoColumn.selected);
|
||||
break;
|
||||
case "number-range":
|
||||
fnCreateRangeInput(oTable);
|
||||
break;
|
||||
case "date-range":
|
||||
fnCreateDateRangeInput(oTable);
|
||||
break;
|
||||
case "checkbox":
|
||||
fnCreateCheckbox(oTable, aoColumn.values);
|
||||
break;
|
||||
case "twitter-dropdown":
|
||||
case "dropdown":
|
||||
fnCreateDropdown(aoColumn.values);
|
||||
break;
|
||||
case "text":
|
||||
default:
|
||||
bRegex = (aoColumn.bRegex == null ? false : aoColumn.bRegex);
|
||||
bSmart = (aoColumn.bSmart == null ? false : aoColumn.bSmart);
|
||||
fnCreateInput(oTable, bRegex, bSmart, false, aoColumn.iFilterLength, aoColumn.iMaxLenght);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
|
||||
//var index = aiCustomSearch_Indexes[j];
|
||||
var fnSearch_ = function () {
|
||||
var id = oTable.attr("id");
|
||||
return $("#" + id + "_range_from_" + aiCustomSearch_Indexes[j]).val() + properties.sRangeSeparator + $("#" + id + "_range_to_" + aiCustomSearch_Indexes[j]).val()
|
||||
}
|
||||
afnSearch_.push(fnSearch_);
|
||||
}
|
||||
|
||||
if (oTable.fnSettings().oFeatures.bServerSide) {
|
||||
|
||||
var fnServerDataOriginal = oTable.fnSettings().fnServerData;
|
||||
|
||||
oTable.fnSettings().fnServerData = function (sSource, aoData, fnCallback) {
|
||||
|
||||
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
|
||||
var index = aiCustomSearch_Indexes[j];
|
||||
|
||||
for (k = 0; k < aoData.length; k++) {
|
||||
if (aoData[k].name == "sSearch_" + index)
|
||||
aoData[k].value = afnSearch_[j]();
|
||||
}
|
||||
}
|
||||
aoData.push({ "name": "sRangeSeparator", "value": properties.sRangeSeparator });
|
||||
|
||||
if (fnServerDataOriginal != null) {
|
||||
try {
|
||||
fnServerDataOriginal(sSource, aoData, fnCallback, oTable.fnSettings()); //TODO: See Issue 18
|
||||
} catch (ex) {
|
||||
fnServerDataOriginal(sSource, aoData, fnCallback);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$.getJSON(sSource, aoData, function (json) {
|
||||
fnCallback(json)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
})(jQuery);
|
Loading…
Reference in New Issue