CC-3174 : showbuilder

check into issue that propel doesn't return DateTime object in UTC.
using table tools to keep track of selected rows.
This commit is contained in:
Naomi Aro 2012-01-31 18:59:27 +01:00
parent 3f3117cf0e
commit fbda0e733b
16 changed files with 3999 additions and 437 deletions

View file

@ -39,12 +39,15 @@ class LibraryController extends Zend_Controller_Action
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jjmenu.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorderResize.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/advancedsearch.js','text/javascript');
@ -52,6 +55,7 @@ class LibraryController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/TableTools.css');
$this->_helper->viewRenderer->setResponseSegment('library');

View file

@ -6,7 +6,9 @@ class ShowbuilderController extends Zend_Controller_Action
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('schedule', 'json')
$ajaxContext->addActionContext('schedule-update', 'json')
->addActionContext('schedule-add', 'json')
->addActionContext('schedule-remove', 'json')
->addActionContext('builder-feed', 'json')
->initContext();
}
@ -55,6 +57,38 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->schedule = $showBuilder->GetItems();
}
public function scheduleAddAction() {
$request = $this->getRequest();
$id = $request->getParam("id", null);
$instance = $request->getParam("instance", null);
$items = $request->getParam("items", array());
}
public function scheduleRemoveAction()
{
$request = $this->getRequest();
$ids = $request->getParam("ids", null);
Logging::log($ids);
$json = array();
try {
Application_Model_Scheduler::removeItems($ids);
$json["message"]="success... maybe";
}
catch (Exception $e) {
$json["message"]=$e->getMessage();
Logging::log($e->getMessage());
}
$this->view->data = $json;
}
public function scheduleAction() {
$request = $this->getRequest();

View file

@ -309,7 +309,8 @@ class Application_Model_Schedule {
$sql = "SELECT DISTINCT
showt.name AS show_name, showt.color AS show_color, showt.background_color AS show_background_colour,
showt.name AS show_name, showt.color AS show_color,
showt.background_color AS show_background_colour, showt.id AS show_id,
si.starts AS si_starts, si.ends AS si_ends, si.time_filled AS si_time_filled,
si.record AS si_record, si.rebroadcast AS si_rebroadcast, si.id AS si_id,

View file

@ -3,6 +3,7 @@
class Application_Model_Scheduler {
private $propSched;
private $con;
public function __construct($id = null) {
@ -15,13 +16,193 @@ class Application_Model_Scheduler {
}
/*
public function findScheduledItems($starts, $ends) {
* @param $id
* @param $type
*
* @return $files
*/
private static function retrieveMediaFiles($id, $type) {
CcScheduleQuery::create()
->filterByDbStarts(array('min' => $starts->format('Y-m-d H:i:s'), 'max' => $ends->format('Y-m-d H:i:s')))
$fileInfo = array(
"id" => "",
"cliplength" => "",
"cuein" => "00:00:00",
"cueout" => "00:00:00",
"fadein" => "00:00:00",
"fadeout" => "00:00:00"
);
$files = array();
if ($type === "file") {
$file = CcFilesQuery::create()->findByPK($id);
$data = $fileInfo;
$data["id"] = $id;
$data["cliplength"] = $file->getDbLength();
$files[] = $data;
}
else if ($type === "playlist") {
}
return $files;
}
/*
* @param array $scheduledIds
* @param array $fileIds
* @param array $playlistIds
*/
public static function scheduleAfter($scheduledIds, $mediaIds, $adjustSched = true) {
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$con->beginTransaction();
try {
$schedFiles = array();
foreach($mediaIds as $id => $type) {
$schedFiles = array_merge($schedFiles, self::retrieveMediaFiles($id, $type));
}
foreach ($scheduledIds as $id) {
$schedItem = CcScheduleQuery::create()->findByPK($id);
if ($adjustSched === true) {
$followingSchedItems = CcScheduleQuery::create()
->filterByDBStarts($schedItem->getDbStarts("Y-m-d H:i:s.u"), Criteria::GREATER_THAN)
->filterByDbInstanceId($instance)
->orderByDbStarts()
->find();
}
*/
$nextItemDT = $schedItem->getDbEnds(null);
$instance = $schedItem->getDbInstanceId();
foreach($schedFiles as $file) {
$durationDT = DateTime::createFromFormat("Y-m-d H:i:s.u", "1970-01-01 {$file['cliplength']}", new DateTimeZone("UTC"));
$endTimeEpoch = $nextItemDT->format("U.u") + $durationDT->format("U.u");
$endTimeDT = DateTime::createFromFormat("U.u", $endTimeEpoch, new DateTimeZone("UTC"));
$newItem = new CcSchedule();
$newItem->setDbStarts($nextItemDT);
$newItem->setDbEnds($endTimeDT);
$newItem->setDbFileId($file['id']);
$newItem->setDbCueIn($file['cuein']);
$newItem->setDbCueOut($file['cueout']);
$newItem->setDbFadeIn($file['fadein']);
$newItem->setDbFadeOut($file['fadeout']);
$newItem->setDbInstanceId($instance);
$newItem->save($con);
$nextItemDT = $endTimeDT;
}
if ($adjustSched === true) {
//recalculate the start/end times after the inserted items.
foreach($followingSchedItems as $followingItem) {
$durationDT = DateTime::createFromFormat("Y-m-d H:i:s.u", "1970-01-01 {$file['cliplength']}", new DateTimeZone("UTC"));
$endTimeEpoch = $nextItemDT->format("U.u") + $durationDT->format("U.u");
$endTimeDT = DateTime::createFromFormat("U.u", $endTimeEpoch, new DateTimeZone("UTC"));
$followingItem->setDbStarts($nextItemDT);
$followingItem->setDbEnds($endTimeDT);
$followingItem->save($con);
$nextItemDT = $endTimeDT;
}
}
}
}
catch (Exception $e) {
$con->rollback();
throw $e;
}
}
public function removeItems($scheduledIds, $adjustSched = true) {
$showInstances = array();
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$this->con->beginTransaction();
try {
$removedItems = CcScheduleQuery::create()->findPks($scheduledIds);
$removedItems->delete($this->con);
if ($adjustSched === true) {
//get the show instances of the shows we must adjust times for.
foreach ($removedItems as $item) {
$instance = $item->getDBInstanceId();
if (!in_array($instance, $showInstances)) {
$showInstances[] = $instance;
}
}
foreach($showInstances as $instance) {
self::removeGaps($instance);
}
}
}
catch (Exception $e) {
$this->con->rollback();
throw $e;
}
}
public function removeGaps($showInstance) {
Logging::log("removing gaps from show instance #".$showInstance);
$instance = CcShowInstancesQuery::create()->findPK($showInstance);
$itemStartDT = $instance->getDbStarts(null);
$schedule = CcScheduleQuery::create()
->filterByDbInstanceId($showInstance)
->orderByDbStarts()
->find();
foreach ($schedule as $item) {
Logging::log("adjusting item #".$item->getDbId());
if (!$item->isDeleted()) {
Logging::log("item #".$item->getDbId()." is not deleted");
$durationDT = new DateTime("1970-01-01 {$item->getDbClipLength()}", new DateTimeZone("UTC"));
$startEpoch = $itemStartDT->format("U");
Logging::log("new start time");
Logging::log($itemStartDT->format("Y-m-d H:i:s"));
Logging::log("duration");
Logging::log($durationDT->format("Y-m-d H:i:s"));
Logging::log($durationDT->format("U"). "seconds");
$endEpoch = $itemStartDT->format("U") + $durationDT->format("U");
$itemEndDT = DateTime::createFromFormat("U", $endEpoch, new DateTimeZone("UTC"));
Logging::log("new end time");
Logging::log($itemEndDT->format("Y-m-d H:i:s"));
$item->setDbStarts($itemStartDT);
$item->setDbEnds($itemEndDT);
$item->save($this->con);
$itemStartDT = $itemEndDT;
}
}
}
public function addScheduledItem($starts, $duration, $adjustSched = true) {

View file

@ -5,6 +5,7 @@ class Application_Model_ShowBuilder {
private $timezone;
private $startDT;
private $endDT;
private $user;
private $defaultRowArray = array(
"header" => false,
@ -32,6 +33,7 @@ class Application_Model_ShowBuilder {
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->user = Application_Model_User::GetCurrentUser();
}
/*
@ -96,8 +98,8 @@ class Application_Model_ShowBuilder {
$runtime = $schedStartDT->diff($schedEndDT);
$row["id"] = $p_item["sched_id"];
$row["instance"] = $p_item["si_id"];
$row["id"] = intval($p_item["sched_id"]);
$row["instance"] = intval($p_item["si_id"]);
$row["starts"] = $schedStartDT->format("H:i:s");
$row["startsUnix"] = $schedStartDT->format("U");
$row["ends"] = $schedEndDT->format("H:i:s");
@ -107,6 +109,10 @@ class Application_Model_ShowBuilder {
$row["title"] = $p_item["file_track_title"];
$row["creator"] = $p_item["file_artist_name"];
$row["album"] = $p_item["file_album_title"];
if ($this->user->canSchedule($item["show_id"]) === true) {
$row["checkbox"] = true;
}
}
//show is empty
else {

View file

@ -687,20 +687,6 @@ class Application_Model_StoredFile {
$results = Application_Model_StoredFile::searchFiles($fromTable, $datatables);
/*
type = aData["ftype"].substring(0,2);
id = aData["id"];
if(type == "au") {
$('td.library_type', nRow).html( '<img src="css/images/icon_audioclip.png">' );
} else if(type == "pl") {
$('td.library_type', nRow).html( '<img src="css/images/icon_playlist.png">' );
}
$(nRow).attr("id", type+'_'+id);
*/
foreach($results['aaData'] as &$row){
// add checkbox row
$row['checkbox'] = "<input type='checkbox' name='cb_".$row['id']."'>";

View file

@ -35,6 +35,19 @@ class Application_Model_User {
return $this->isUserType(UTYPE_ADMIN);
}
public function canSchedule($p_showId) {
$type = $this->getType();
if ( $type === UTYPE_ADMIN ||
$type === UTYPE_PROGRAM_MANAGER ||
CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0 )
{
return true;
}
return false;
}
public function isUserType($type, $showId=''){
if(is_array($type)){
$result = false;
@ -270,4 +283,9 @@ class Application_Model_User {
}
}
public static function GetCurrentUser() {
$userinfo = Zend_Auth::getInstance()->getStorage()->read();
return new self($userinfo->id);
}
}

View file

@ -0,0 +1,265 @@
/*
* File: TableTools.css
* Description: Styles for TableTools 2
* Author: Allan Jardine (www.sprymedia.co.uk)
* Language: Javascript
* License: LGPL / 3 point BSD
* Project: DataTables
*
* Copyright 2010 Allan Jardine, all rights reserved.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* CSS name space:
* DTTT DataTables TableTools
*
* Colour dictionary:
* Button border #d0d0d0
* Button border hover #999999
* Hover background #f0f0f0
* Action blue #4b66d9
*
* Style sheet provides:
* CONTAINER TableTools container element and styles applying to all components
* BUTTON_STYLES Action specific button styles
* SELECTING Row selection styles
* COLLECTIONS Drop down list (collection) styles
* PRINTING Print display styles
* MISC Minor misc styles
*/
/*
* CONTAINER
* TableTools container element and styles applying to all components
*/
div.DTTT_container {
position: relative;
float: left;
margin-bottom: 1em;
}
button.DTTT_button {
position: relative;
float: left;
height: 30px;
margin-right: 3px;
padding: 3px 5px;
border: 1px solid #d0d0d0;
background-color: #fff;
cursor: pointer;
*cursor: hand;
}
button.DTTT_button::-moz-focus-inner {
border: none !important;
padding: 0;
}
/*
* BUTTON_STYLES
* Action specific button styles
*/
button.DTTT_button_csv {
padding-right: 30px;
background: url(../images/csv.png) no-repeat center right;
}
button.DTTT_button_csv_hover {
padding-right: 30px;
border: 1px solid #999;
background: #f0f0f0 url(../images/csv_hover.png) no-repeat center right;
}
button.DTTT_button_xls {
padding-right: 30px;
background: url(../images/xls.png) no-repeat center right;
}
button.DTTT_button_xls_hover {
padding-right: 30px;
border: 1px solid #999;
background: #f0f0f0 url(../images/xls_hover.png) no-repeat center right;
}
button.DTTT_button_copy {
padding-right: 30px;
background: url(../images/copy.png) no-repeat center right;
}
button.DTTT_button_copy_hover {
padding-right: 30px;
border: 1px solid #999;
background: #f0f0f0 url(../images/copy_hover.png) no-repeat center right;
}
button.DTTT_button_pdf {
padding-right: 30px;
background: url(../images/pdf.png) no-repeat center right;
}
button.DTTT_button_pdf_hover {
padding-right: 30px;
border: 1px solid #999;
background: #f0f0f0 url(../images/pdf_hover.png) no-repeat center right;
}
button.DTTT_button_print {
padding-right: 30px;
background: url(../images/print.png) no-repeat center right;
}
button.DTTT_button_print_hover {
padding-right: 30px;
border: 1px solid #999;
background: #f0f0f0 url(../images/print_hover.png) no-repeat center right;
}
button.DTTT_button_text {
}
button.DTTT_button_text_hover {
border: 1px solid #999;
background-color: #f0f0f0;
}
button.DTTT_button_collection {
padding-right: 17px;
background: url(../images/collection.png) no-repeat center right;
}
button.DTTT_button_collection_hover {
padding-right: 17px;
border: 1px solid #999;
background: #f0f0f0 url(../images/collection_hover.png) no-repeat center right;
}
/*
* SELECTING
* Row selection styles
*/
table.DTTT_selectable tbody tr {
cursor: pointer;
*cursor: hand;
}
tr.DTTT_selected.odd {
background-color: #9FAFD1;
}
tr.DTTT_selected.odd td.sorting_1 {
background-color: #9FAFD1;
}
tr.DTTT_selected.odd td.sorting_2 {
background-color: #9FAFD1;
}
tr.DTTT_selected.odd td.sorting_3 {
background-color: #9FAFD1;
}
tr.DTTT_selected.even {
background-color: #B0BED9;
}
tr.DTTT_selected.even td.sorting_1 {
background-color: #B0BED9;
}
tr.DTTT_selected.even td.sorting_2 {
background-color: #B0BED9;
}
tr.DTTT_selected.even td.sorting_3 {
background-color: #B0BED9;
}
/*
* COLLECTIONS
* Drop down list (collection) styles
*/
div.DTTT_collection {
width: 150px;
padding: 3px;
border: 1px solid #ccc;
background-color: #f3f3f3;
overflow: hidden;
z-index: 2002;
}
div.DTTT_collection_background {
background: transparent url(../images/background.png) repeat top left;
z-index: 2001;
}
div.DTTT_collection button.DTTT_button {
float: none;
width: 100%;
margin-bottom: 2px;
background-color: white;
}
/*
* PRINTING
* Print display styles
*/
.DTTT_print_info {
position: absolute;
top: 50%;
left: 50%;
width: 400px;
height: 150px;
margin-left: -200px;
margin-top: -75px;
text-align: center;
background-color: #3f3f3f;
color: white;
padding: 10px 30px;
opacity: 0.9;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
}
.DTTT_print_info h6 {
font-weight: normal;
font-size: 28px;
line-height: 28px;
margin: 1em;
}
.DTTT_print_info p {
font-size: 14px;
line-height: 20px;
}
/*
* MISC
* Minor misc styles
*/
.DTTT_disabled {
color: #999;
}

View file

@ -0,0 +1,183 @@
/*
* File: TableTools.css
* Description: Styles for TableTools 2 with JUI theming
* Author: Allan Jardine (www.sprymedia.co.uk)
* Language: Javascript
* License: LGPL / 3 point BSD
* Project: DataTables
*
* Copyright 2010 Allan Jardine, all rights reserved.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Notes:
* Generally speaking, please refer to the TableTools.css file - this file contains basic
* modifications to that 'master' stylesheet for ThemeRoller.
*
* CSS name space:
* DTTT DataTables TableTools
*
* Colour dictionary:
* Button border #d0d0d0
* Button border hover #999999
* Hover background #f0f0f0
* Action blue #4b66d9
*
* Style sheet provides:
* CONTAINER TableTools container element and styles applying to all components
* SELECTING Row selection styles
* COLLECTIONS Drop down list (collection) styles
* PRINTING Print display styles
* MISC Minor misc styles
*/
/*
* CONTAINER
* TableTools container element and styles applying to all components
*/
div.DTTT_container {
position: relative;
float: left;
}
button.DTTT_button {
position: relative;
float: left;
height: 24px;
margin-right: 3px;
padding: 3px 10px;
border: 1px solid #d0d0d0;
background-color: #fff;
cursor: pointer;
*cursor: hand;
}
button.DTTT_button::-moz-focus-inner {
border: none !important;
padding: 0;
}
/*
* SELECTING
* Row selection styles
*/
table.DTTT_selectable tbody tr {
cursor: pointer;
*cursor: hand;
}
tr.DTTT_selected.odd {
background-color: #9FAFD1;
}
tr.DTTT_selected.odd td.sorting_1 {
background-color: #9FAFD1;
}
tr.DTTT_selected.odd td.sorting_2 {
background-color: #9FAFD1;
}
tr.DTTT_selected.odd td.sorting_3 {
background-color: #9FAFD1;
}
tr.DTTT_selected.even {
background-color: #B0BED9;
}
tr.DTTT_selected.even td.sorting_1 {
background-color: #B0BED9;
}
tr.DTTT_selected.even td.sorting_2 {
background-color: #B0BED9;
}
tr.DTTT_selected.even td.sorting_3 {
background-color: #B0BED9;
}
/*
* COLLECTIONS
* Drop down list (collection) styles
*/
div.DTTT_collection {
width: 150px;
background-color: #f3f3f3;
overflow: hidden;
z-index: 2002;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
}
div.DTTT_collection_background {
background: url(../images/background.png) repeat top left;
z-index: 2001;
}
div.DTTT_collection button.DTTT_button {
float: none;
width: 100%;
margin-bottom: -0.1em;
}
/*
* PRINTING
* Print display styles
*/
.DTTT_print_info {
position: absolute;
top: 50%;
left: 50%;
width: 400px;
height: 150px;
margin-left: -200px;
margin-top: -75px;
text-align: center;
background-color: #3f3f3f;
color: white;
padding: 10px 30px;
opacity: 0.9;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
}
.DTTT_print_info h6 {
font-weight: normal;
font-size: 28px;
line-height: 28px;
margin: 1em;
}
.DTTT_print_info p {
font-size: 14px;
line-height: 20px;
}
/*
* MISC
* Minor misc styles
*/
.DTTT_disabled {
color: #999;
}

View file

@ -9,7 +9,7 @@ function fnLibraryTableDrawCallback() {
addLibraryItemEvents();
addMetadataQtip();
//saveNumEntriesSetting();
setupGroupActions();
//setupGroupActions();
}
function addLibraryItemEvents() {
@ -20,16 +20,23 @@ function addLibraryItemEvents() {
cursor: 'pointer'
});
/*
$('#library_display tbody tr td').not('[class=library_checkbox]')
.jjmenu("click",
[{get:"/Library/context-menu/format/json/id/#id#/type/#type#"}],
{id: getId, type: getType},
{xposition: "mouse", yposition: "mouse"});
*/
}
function setupLibraryToolbar() {
$("div.library_toolbar").html('<span class="fg-button ui-button ui-state-default" id="library_order_reset">Reset Order</span>' +
'<span class="fg-button ui-button ui-state-default ui-state-disabled" id="library_group_delete">Delete</span>' +
'<span class="fg-button ui-button ui-state-default ui-state-disabled" id="library_group_add">Add</span>');
//[0] = button text
//[1] = id
//[2] = enabled
var aButtons = [["Reset Order", "library_order_reset", true],
["Delete", "library_group_delete", false],
["Add", "library_group_add", false]];
addToolBarButtonsLibrary(aButtons);
}

View file

@ -21,14 +21,33 @@ function addLibraryItemEvents() {
cursor: 'pointer',
connectToSortable: '#show_builder_table'
});
$('#library_display tbody tr td').not('[class=library_checkbox]')
.jjmenu("click",
[{get:"/Library/context-menu/format/json/id/#id#/type/#type#"}],
{id: getId, type: getType},
{xposition: "mouse", yposition: "mouse"});
}
function setupLibraryToolbar() {
var aButtons,
fnTest,
fnAddSelectedItems;
fnTest = function() {
alert("hi");
};
fnAddSelectedItems = function() {
var oTT = TableTools.fnGetInstance('show_builder_table'),
aData = oTT.fnGetSelectedData(),
i,
length = aData.length;
for (i=0, i<length; i+=1;) {
var x;
}
};
//[0] = button text
//[1] = id
//[2] = enabled
aButtons = [["Reset Order", "library_order_reset", true, fnTest],
["Delete", "library_group_delete", false, fnTest],
["Add", "library_group_add", false, fnTest]];
addToolBarButtonsLibrary(aButtons);
}

View file

@ -1,8 +1,5 @@
var dTable;
var checkedCount = 0;
var checkedPLCount = 0;
//used by jjmenu
/*
function getId() {
var tr_id = $(this.triggerElement).parent().attr("id");
tr_id = tr_id.split("_");
@ -16,8 +13,48 @@ function getType() {
return tr_id[0];
}
*/
//end functions used by jjmenu
function addToolBarButtonsLibrary(aButtons) {
var i,
length = aButtons.length,
libToolBar,
html,
buttonClass = '',
DEFAULT_CLASS = 'ui-button ui-state-default',
DISABLED_CLASS = 'ui-state-disabled';
libToolBar = $(".library_toolbar");
for ( i=0; i < length; i+=1 ) {
buttonClass = '';
//add disabled class if not enabled.
if (aButtons[i][2] === false) {
buttonClass+=DISABLED_CLASS;
}
html = '<div id="'+aButtons[i][1]+'" class="ColVis TableTools"><button class="'+DEFAULT_CLASS+' '+buttonClass+'"><span>'+aButtons[i][0]+'</span></button></div>';
libToolBar.append(html);
libToolBar.find("#"+aButtons[i][1]).click(aButtons[i][3]);
}
}
function enableGroupBtn(btnId, func) {
btnId = '#' + btnId;
if ($(btnId).hasClass('ui-state-disabled')) {
$(btnId).removeClass('ui-state-disabled');
}
}
function disableGroupBtn(btnId) {
btnId = '#' + btnId;
if (!$(btnId).hasClass('ui-state-disabled')) {
$(btnId).addClass('ui-state-disabled');
}
}
function deleteItem(type, id) {
var tr_id, tr, dt;
@ -38,7 +75,8 @@ function deleteAudioClip(json) {
for (var i = json.ids.length - 1; i >= 0; i--) {
deleteItem("au", json.ids[i]);
}
} else if (json.id != undefined) {
}
else if (json.id != undefined) {
deleteItem("au", json.id);
}
location.reload(true);
@ -50,28 +88,6 @@ function confirmDeleteGroup() {
}
}
//callbacks called by jjmenu
function confirmDeleteAudioClip(params){
if(confirm('The file will be deleted from disk, are you sure you want to delete?')){
var url = '/Library/delete' + params;
$.ajax({
url: url,
success: deleteAudioClip
});
}
}
//callbacks called by jjmenu
function confirmDeletePlaylist(params){
if(confirm('Are you sure you want to delete?')){
var url = '/Playlist/delete' + params;
$.ajax({
url: url,
success: deletePlaylist
});
}
}
function openFileOnSoundCloud(link){
window.open(link);
}
@ -102,7 +118,6 @@ function deletePlaylist(json) {
}
window.location.reload();
}
//end callbacks called by jjmenu
function addProgressIcon(id) {
if($("#au_"+id).find("td.library_title").find("span").length > 0){
@ -277,184 +292,17 @@ function getNumEntriesPreference(data) {
}
function groupAdd() {
if (checkedPLCount > 0) {
alert("Can't add playlist to another playlist");
return;
}
disableGroupBtn('library_group_add');
var ids = new Array();
var addGroupUrl = '/Playlist/add-group';
var newSPLUrl = '/Playlist/new/format/json';
var dirty = true;
$('#library_display tbody tr').each(function() {
var idSplit = $(this).attr('id').split("_");
var id = idSplit.pop();
var type = idSplit.pop();
if (dirty && $(this).find(":checkbox").attr("checked")) {
if (type == "au") {
ids.push(id);
} else if (type == "pl") {
alert("Can't add playlist to another playlist");
dirty = false;
}
}
});
if (dirty && ids.length > 0) {
stopAudioPreview();
if ($('#spl_sortable').length == 0) {
$.post(newSPLUrl, function(json) {
openDiffSPL(json);
redrawDataTablePage();
$.post(addGroupUrl, {format: "json", ids: ids}, setSPLContent);
});
} else {
$.post(addGroupUrl, {format: "json", ids: ids}, setSPLContent);
}
}
}
function groupDelete() {
disableGroupBtn('library_group_delete');
var auIds = new Array();
var plIds = new Array();
var auUrl = '/Library/delete-group';
var plUrl = '/Playlist/delete-group';
var dirty = true;
$('#library_display tbody tr').each(function() {
var idSplit = $(this).attr('id').split("_");
var id = idSplit.pop();
var type = idSplit.pop();
if (dirty && $(this).find(":checkbox").attr("checked")) {
if (type == "au") {
auIds.push(id);
} else if (type == "pl") {
plIds.push(id);
}
}
});
if (dirty && (auIds.length > 0 || plIds.length > 0)) {
stopAudioPreview();
if (auIds.length > 0) {
$.post(auUrl, {format: "json", ids: auIds}, deleteAudioClip);
}
if (plIds.length > 0) {
$.post(plUrl, {format: "json", ids: plIds}, deletePlaylist);
}
}
}
function toggleAll() {
var checked = $(this).attr("checked");
$('#library_display tr').each(function() {
var idSplit = $(this).attr('id').split("_");
var type = idSplit[0];
$(this).find(":checkbox").attr("checked", checked);
if (checked) {
if (type == "pl") {
checkedPLCount++;
}
$(this).addClass('selected');
} else {
$(this).removeClass('selected');
}
});
if (checked) {
checkedCount = $('#library_display tbody tr').size();
enableGroupBtn('library_group_add', groupAdd);
enableGroupBtn('library_group_delete', confirmDeleteGroup);
} else {
checkedCount = 0;
checkedPLCount = 0;
disableGroupBtn('library_group_add');
disableGroupBtn('library_group_delete');
}
}
function enableGroupBtn(btnId, func) {
btnId = '#' + btnId;
if ($(btnId).hasClass('ui-state-disabled')) {
$(btnId).removeClass('ui-state-disabled');
$(btnId).unbind("click").click(func);
}
}
function disableGroupBtn(btnId) {
btnId = '#' + btnId;
if (!$(btnId).hasClass('ui-state-disabled')) {
$(btnId).addClass('ui-state-disabled');
$(btnId).unbind("click");
}
}
function checkBoxChanged() {
var cbAll = $('#library_display thead').find(":checkbox");
var cbAllChecked = cbAll.attr("checked");
var checked = $(this).attr("checked");
var size = $('#library_display tbody tr').size();
var idSplit = $(this).parent().parent().attr('id').split("_");
var type = idSplit[0];
if (checked) {
if (checkedCount < size) {
checkedCount++;
}
if (type == "pl" && checkedPLCount < size) {
checkedPLCount++;
}
enableGroupBtn('library_group_add', groupAdd);
enableGroupBtn('library_group_delete', confirmDeleteGroup);
$(this).parent().parent().addClass('selected');
} else {
if (checkedCount > 0) {
checkedCount--;
}
if (type == "pl" && checkedPLCount > 0) {
checkedPLCount--;
}
if (checkedCount == 0) {
disableGroupBtn('library_group_add');
disableGroupBtn('library_group_delete');
}
$(this).parent().parent().removeClass('selected');
}
if (cbAllChecked && checkedCount < size) {
cbAll.attr("checked", false);
} else if (!cbAllChecked && checkedCount == size) {
cbAll.attr("checked", true);
}
}
function setupGroupActions() {
checkedCount = 0;
checkedPLCount = 0;
$('#library_display tr:nth-child(1)').find(":checkbox").attr("checked", false);
$('#library_display thead').find(":checkbox").unbind('change').change(toggleAll);
$('#library_display tbody tr').each(function() {
$(this).find(":checkbox").unbind('change').change(checkBoxChanged);
});
disableGroupBtn('library_group_add');
disableGroupBtn('library_group_delete');
}
function fnShowHide(iCol) {
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var oTable = dTable;
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, bVis ? false : true );
}
function createDataTable(data) {
dTable = $('#library_display').dataTable( {
var oTable;
oTable = $('#library_display').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/Library/contents",
@ -471,7 +319,7 @@ function createDataTable(data) {
"fnRowCallback": fnLibraryTableRowCallback,
"fnDrawCallback": fnLibraryTableDrawCallback,
"aoColumns": [
/* Checkbox */ {"sTitle": "<input type='checkbox' name='cb_all'>", "bSortable": false, "bSearchable": false, "mDataProp": "checkbox", "sWidth": "25px", "sClass": "library_checkbox"},
/* Checkbox */ {"sTitle": "<input type='checkbox' name='pl_cb_all'>", "bSortable": false, "bSearchable": false, "mDataProp": "checkbox", "sWidth": "25px", "sClass": "library_checkbox"},
/* Id */ {"sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id", "sClass": "library_id"},
/* Title */ {"sTitle": "Title", "sName": "track_title", "mDataProp": "track_title", "sClass": "library_title"},
/* Creator */ {"sTitle": "Creator", "sName": "artist_name", "mDataProp": "artist_name", "sClass": "library_creator"},
@ -493,7 +341,35 @@ function createDataTable(data) {
"iDisplayLength": getNumEntriesPreference(data),
// R = ColReorder, C = ColVis, see datatables doc for others
"sDom": 'Rlfr<"H"C<"library_toolbar">>t<"F"ip>',
"sDom": 'Rlfr<"H"T<"library_toolbar"C>>t<"F"ip>',
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [],
"fnRowSelected": function ( node ) {
var x;
//seems to happen if everything is selected
if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", true);
}
else {
$(node).find("input[type=checkbox]").attr("checked", true);
}
},
"fnRowDeselected": function ( node ) {
var x;
//seems to happen if everything is deselected
if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", false);
}
else {
$(node).find("input[type=checkbox]").attr("checked", false);
}
}
},
"oColVis": {
"buttonText": "Show/Hide Columns",
"sAlign": "right",
@ -502,14 +378,25 @@ function createDataTable(data) {
"bShowAll": true
}
});
dTable.fnSetFilteringDelay(350);
oTable.fnSetFilteringDelay(350);
setupLibraryToolbar();
$('#library_order_reset').click(function() {
ColReorder.fnReset( dTable );
ColReorder.fnReset( oTable );
return false;
});
$('[name="pl_cb_all"]').click(function(){
var oTT = TableTools.fnGetInstance('library_display');
if ($(this).is(":checked")) {
oTT.fnSelectAll();
}
else {
oTT.fnSelectNone();
}
});
}
$(document).ready(function() {
@ -519,8 +406,8 @@ $(document).ready(function() {
error:function(jqXHR, textStatus, errorThrown){}});
checkImportStatus();
setInterval( "checkImportStatus()", 5000 );
setInterval( "checkSCUploadStatus()", 5000 );
//setInterval( "checkImportStatus()", 5000 );
//setInterval( "checkSCUploadStatus()", 5000 );
addQtipToSCIcons();
});

View file

@ -1,48 +1,30 @@
/*
function tpStartOnHourShowCallback(hour) {
var tpEndHour = $('#show_builder_timepicker_end').timepicker('getHour');
$(document).ready(function() {
var tableDiv = $('#show_builder_table'),
oTable,
oBaseDatePickerSettings,
oBaseTimePickerSettings,
fnAddSelectedItems,
fnRemoveSelectedItems;
// Check if proposed hour is prior or equal to selected end time hour
if (hour <= tpEndHour) { return true; }
// if hour did not match, it can not be selected
return false;
}
oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd',
onSelect: function(sDate, oDatePicker) {
var oDate,
dInput;
function tpStartOnMinuteShowCallback(hour, minute) {
var tpEndHour = $('#show_builder_timepicker_end').timepicker('getHour'),
tpEndMinute = $('#show_builder_timepicker_end').timepicker('getMinute');
dInput = $(this);
oDate = dInput.datepicker( "setDate", sDate );
}
};
// Check if proposed hour is prior to selected end time hour
if (hour < tpEndHour) { return true; }
// Check if proposed hour is equal to selected end time hour and minutes is prior
if ( (hour == tpEndHour) && (minute < tpEndMinute) ) { return true; }
// if minute did not match, it can not be selected
return false;
}
oBaseTimePickerSettings = {
showPeriodLabels: false,
showCloseButton: true,
showLeadingZero: false,
defaultTime: '0:00'
};
function tpEndOnHourShowCallback(hour) {
var tpStartHour = $('#show_builder_timepicker_start').timepicker('getHour');
// Check if proposed hour is after or equal to selected start time hour
if (hour >= tpStartHour) { return true; }
// if hour did not match, it can not be selected
return false;
}
function tpEndOnMinuteShowCallback(hour, minute) {
var tpStartHour = $('#show_builder_timepicker_start').timepicker('getHour'),
tpStartMinute = $('#show_builder_timepicker_start').timepicker('getMinute');
// Check if proposed hour is after selected start time hour
if (hour > tpStartHour) { return true; }
// Check if proposed hour is equal to selected start time hour and minutes is after
if ( (hour == tpStartHour) && (minute > tpStartMinute) ) { return true; }
// if minute did not match, it can not be selected
return false;
}
*/
/*
/*
* Get the schedule range start in unix timestamp form (in seconds).
* defaults to NOW if nothing is selected.
*
@ -52,7 +34,7 @@ function tpEndOnMinuteShowCallback(hour, minute) {
*
* @return Number iTime
*/
function fnGetUIPickerUnixTimestamp(sDatePickerId, sTimePickerId) {
function fnGetUIPickerUnixTimestamp(sDatePickerId, sTimePickerId) {
var oDate,
oTimePicker = $( sTimePickerId ),
iTime,
@ -83,13 +65,13 @@ function fnGetUIPickerUnixTimestamp(sDatePickerId, sTimePickerId) {
iTime = iTime + iServerOffset + iClientOffset;
return iTime;
}
/*
}
/*
* Returns an object containing a unix timestamp in seconds for the start/end range
*
* @return Object {"start", "end", "range"}
*/
function fnGetScheduleRange() {
function fnGetScheduleRange() {
var iStart,
iEnd,
iRange,
@ -111,9 +93,9 @@ function fnGetScheduleRange() {
end: iEnd,
range: iRange
};
}
}
var fnServerData = function fnServerData( sSource, aoData, fnCallback ) {
var fnServerData = function ( sSource, aoData, fnCallback ) {
aoData.push( { name: "format", value: "json"} );
if (fnServerData.hasOwnProperty("start")) {
@ -130,9 +112,9 @@ var fnServerData = function fnServerData( sSource, aoData, fnCallback ) {
"data": aoData,
"success": fnCallback
} );
};
};
var fnShowBuilderRowCallback = function ( nRow, aData, iDisplayIndex, iDisplayIndexFull ){
var fnShowBuilderRowCallback = function ( nRow, aData, iDisplayIndex, iDisplayIndexFull ){
var i,
sSeparatorHTML,
fnPrepareSeparatorRow,
@ -175,37 +157,45 @@ var fnShowBuilderRowCallback = function ( nRow, aData, iDisplayIndex, iDisplayIn
}
else {
$(nRow).attr("id", "sched_"+aData.id);
node = nRow.children[0];
if (aData.checkbox === true) {
node.innerHTML = '<input type="checkbox" name="'+aData.id+'"></input>';
}
else {
node.innerHTML = '';
$(nRow).addClass("show-builder-not-allowed");
}
}
return nRow;
};
};
$(document).ready(function() {
var oTable,
oBaseDatePickerSettings,
oBaseTimePickerSettings;
fnRemoveSelectedItems = function() {
var oTT = TableTools.fnGetInstance('show_builder_table'),
aData = oTT.fnGetSelectedData(),
item,
temp,
ids = [];
oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd',
onSelect: function(sDate, oDatePicker) {
var oDate,
dInput;
dInput = $(this);
oDate = dInput.datepicker( "setDate", sDate );
for (item in aData) {
temp = aData[item];
if (temp !== null && temp.hasOwnProperty('id')) {
ids.push(temp.id);
}
}
$.post( "/showbuilder/schedule-remove",
{"ids": ids, "format": "json"},
function(data) {
var x;
});
};
oBaseTimePickerSettings = {
showPeriodLabels: false,
showCloseButton: true,
showLeadingZero: false,
defaultTime: '0:00'
};
oTable = $('#show_builder_table').dataTable( {
oTable = tableDiv.dataTable( {
"aoColumns": [
/* checkbox */ {"mDataProp": "checkbox", "sTitle": "<input type='checkbox' name='sb_all'>", "sWidth": "25px"},
/* checkbox */ {"mDataProp": "checkbox", "sTitle": "<input type='checkbox' name='sb_cb_all'>", "sWidth": "15px"},
// /* scheduled id */{"mDataProp": "id", "sTitle": "id"},
// /* instance */{"mDataProp": "instance", "sTitle": "si_id"},
/* starts */{"mDataProp": "starts", "sTitle": "Airtime"},
@ -233,8 +223,35 @@ $(document).ready(function() {
"aiExclude": [ 0, 1 ]
},
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [],
"fnRowSelected": function ( node ) {
var x;
//seems to happen if everything is selected
if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", true);
}
else {
$(node).find("input[type=checkbox]").attr("checked", true);
}
},
"fnRowDeselected": function ( node ) {
var x;
//seems to happen if everything is deselected
if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", false);
}
else {
$(node).find("input[type=checkbox]").attr("checked", false);
}
}
},
// R = ColReorder, C = ColVis, see datatables doc for others
"sDom": 'Rr<"H"C>t<"F">',
"sDom": 'Rr<"H"CT<"#show_builder_toolbar">>t<"F">',
//options for infinite scrolling
//"bScrollInfinite": true,
@ -246,6 +263,17 @@ $(document).ready(function() {
});
$('[name="sb_cb_all"]').click(function(){
var oTT = TableTools.fnGetInstance('show_builder_table');
if ($(this).is(":checked")) {
oTT.fnSelectAll();
}
else {
oTT.fnSelectNone();
}
});
$( "#show_builder_datepicker_start" ).datepicker(oBaseDatePickerSettings);
$( "#show_builder_timepicker_start" ).timepicker(oBaseTimePickerSettings);
@ -255,13 +283,11 @@ $(document).ready(function() {
$( "#show_builder_timepicker_end" ).timepicker(oBaseTimePickerSettings);
$( "#show_builder_timerange_button" ).click(function(ev){
var oTable,
oSettings,
var oSettings,
oRange;
oRange = fnGetScheduleRange();
oTable = $('#show_builder_table').dataTable({"bRetrieve": true});
oSettings = oTable.fnSettings();
oSettings.fnServerData.start = oRange.start;
oSettings.fnServerData.end = oRange.end;
@ -269,7 +295,7 @@ $(document).ready(function() {
oTable.fnDraw();
});
$( "#show_builder_table" ).sortable({
tableDiv.sortable({
placeholder: "placeholder show-builder-placeholder",
forceHelperSize: true,
forcePlaceholderSize: true,
@ -307,4 +333,9 @@ $(document).ready(function() {
}
});
$("#show_builder_toolbar")
.append('<span class="ui-icon ui-icon-trash"></span>')
.find(".ui-icon-trash")
.click(fnRemoveSelectedItems);
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,367 @@
// Simple Set Clipboard System
// Author: Joseph Huckaby
var ZeroClipboard = {
version: "1.0.4-TableTools2",
clients: {}, // registered upload clients on page, indexed by id
moviePath: '', // URL to movie
nextId: 1, // ID of next movie
$: function(thingy) {
// simple DOM lookup utility function
if (typeof(thingy) == 'string') thingy = document.getElementById(thingy);
if (!thingy.addClass) {
// extend element with a few useful methods
thingy.hide = function() { this.style.display = 'none'; };
thingy.show = function() { this.style.display = ''; };
thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
thingy.removeClass = function(name) {
this.className = this.className.replace( new RegExp("\\s*" + name + "\\s*"), " ").replace(/^\s+/, '').replace(/\s+$/, '');
};
thingy.hasClass = function(name) {
return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
}
}
return thingy;
},
setMoviePath: function(path) {
// set path to ZeroClipboard.swf
this.moviePath = path;
},
dispatch: function(id, eventName, args) {
// receive event from flash movie, send to client
var client = this.clients[id];
if (client) {
client.receiveEvent(eventName, args);
}
},
register: function(id, client) {
// register new client to receive events
this.clients[id] = client;
},
getDOMObjectPosition: function(obj) {
// get absolute coordinates for dom element
var info = {
left: 0,
top: 0,
width: obj.width ? obj.width : obj.offsetWidth,
height: obj.height ? obj.height : obj.offsetHeight
};
if ( obj.style.width != "" )
info.width = obj.style.width.replace("px","");
if ( obj.style.height != "" )
info.height = obj.style.height.replace("px","");
while (obj) {
info.left += obj.offsetLeft;
info.top += obj.offsetTop;
obj = obj.offsetParent;
}
return info;
},
Client: function(elem) {
// constructor for new simple upload client
this.handlers = {};
// unique ID
this.id = ZeroClipboard.nextId++;
this.movieId = 'ZeroClipboardMovie_' + this.id;
// register client with singleton to receive flash events
ZeroClipboard.register(this.id, this);
// create movie
if (elem) this.glue(elem);
}
};
ZeroClipboard.Client.prototype = {
id: 0, // unique ID for us
ready: false, // whether movie is ready to receive events or not
movie: null, // reference to movie object
clipText: '', // text to copy to clipboard
fileName: '', // default file save name
action: 'copy', // action to perform
handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor
cssEffects: true, // enable CSS mouse effects on dom container
handlers: null, // user event handlers
sized: false,
glue: function(elem, title) {
// glue to DOM element
// elem can be ID or actual DOM element object
this.domElement = ZeroClipboard.$(elem);
// float just above object, or zIndex 99 if dom element isn't set
var zIndex = 99;
if (this.domElement.style.zIndex) {
zIndex = parseInt(this.domElement.style.zIndex) + 1;
}
// find X/Y position of domElement
var box = ZeroClipboard.getDOMObjectPosition(this.domElement);
// create floating DIV above element
this.div = document.createElement('div');
var style = this.div.style;
style.position = 'absolute';
style.left = (this.domElement.offsetLeft)+'px';
//style.left = (this.domElement.offsetLeft+2)+'px';
style.top = this.domElement.offsetTop+'px';
style.width = (box.width) + 'px';
//style.width = (box.width-4) + 'px';
style.height = box.height + 'px';
style.zIndex = zIndex;
if ( typeof title != "undefined" && title != "" ) {
this.div.title = title;
}
if ( box.width != 0 && box.height != 0 ) {
this.sized = true;
}
// style.backgroundColor = '#f00'; // debug
this.domElement.parentNode.appendChild(this.div);
this.div.innerHTML = this.getHTML( box.width, box.height );
},
positionElement: function() {
var box = ZeroClipboard.getDOMObjectPosition(this.domElement);
var style = this.div.style;
style.position = 'absolute';
style.left = (this.domElement.offsetLeft)+'px';
style.top = this.domElement.offsetTop+'px';
style.width = box.width + 'px';
style.height = box.height + 'px';
if ( box.width != 0 && box.height != 0 ) {
this.sized = true;
} else {
return;
}
var flash = this.div.childNodes[0];
flash.width = box.width;
flash.height = box.height;
},
getHTML: function(width, height) {
// return HTML for movie
var html = '';
var flashvars = 'id=' + this.id +
'&width=' + width +
'&height=' + height;
if (navigator.userAgent.match(/MSIE/)) {
// IE gets an OBJECT tag
var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>';
}
else {
// all other browsers get an EMBED tag
html += '<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" />';
}
return html;
},
hide: function() {
// temporarily hide floater offscreen
if (this.div) {
this.div.style.left = '-2000px';
}
},
show: function() {
// show ourselves after a call to hide()
this.reposition();
},
destroy: function() {
// destroy control and floater
if (this.domElement && this.div) {
this.hide();
this.div.innerHTML = '';
var body = document.getElementsByTagName('body')[0];
try { body.removeChild( this.div ); } catch(e) {;}
this.domElement = null;
this.div = null;
}
},
reposition: function(elem) {
// reposition our floating div, optionally to new container
// warning: container CANNOT change size, only position
if (elem) {
this.domElement = ZeroClipboard.$(elem);
if (!this.domElement) this.hide();
}
if (this.domElement && this.div) {
var box = ZeroClipboard.getDOMObjectPosition(this.domElement);
var style = this.div.style;
style.left = '' + box.left + 'px';
style.top = '' + box.top + 'px';
}
},
clearText: function() {
// clear the text to be copy / saved
this.clipText = '';
if (this.ready) this.movie.clearText();
},
appendText: function(newText) {
// append text to that which is to be copied / saved
this.clipText += newText;
if (this.ready) { this.movie.appendText(newText) ;}
},
setText: function(newText) {
// set text to be copied to be copied / saved
this.clipText = newText;
if (this.ready) { this.movie.setText(newText) ;}
},
setCharSet: function(charSet) {
// set the character set (UTF16LE or UTF8)
this.charSet = charSet;
if (this.ready) { this.movie.setCharSet(charSet) ;}
},
setBomInc: function(bomInc) {
// set if the BOM should be included or not
this.incBom = bomInc;
if (this.ready) { this.movie.setBomInc(bomInc) ;}
},
setFileName: function(newText) {
// set the file name
this.fileName = newText;
if (this.ready) this.movie.setFileName(newText);
},
setAction: function(newText) {
// set action (save or copy)
this.action = newText;
if (this.ready) this.movie.setAction(newText);
},
addEventListener: function(eventName, func) {
// add user event listener for event
// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
if (!this.handlers[eventName]) this.handlers[eventName] = [];
this.handlers[eventName].push(func);
},
setHandCursor: function(enabled) {
// enable hand cursor (true), or default arrow cursor (false)
this.handCursorEnabled = enabled;
if (this.ready) this.movie.setHandCursor(enabled);
},
setCSSEffects: function(enabled) {
// enable or disable CSS effects on DOM container
this.cssEffects = !!enabled;
},
receiveEvent: function(eventName, args) {
// receive event from flash
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
// special behavior for certain events
switch (eventName) {
case 'load':
// movie claims it is ready, but in IE this isn't always the case...
// bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function
this.movie = document.getElementById(this.movieId);
if (!this.movie) {
var self = this;
setTimeout( function() { self.receiveEvent('load', null); }, 1 );
return;
}
// firefox on pc needs a "kick" in order to set these in certain cases
if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
var self = this;
setTimeout( function() { self.receiveEvent('load', null); }, 100 );
this.ready = true;
return;
}
this.ready = true;
this.movie.clearText();
this.movie.appendText( this.clipText );
this.movie.setFileName( this.fileName );
this.movie.setAction( this.action );
this.movie.setCharSet( this.charSet );
this.movie.setBomInc( this.incBom );
this.movie.setHandCursor( this.handCursorEnabled );
break;
case 'mouseover':
if (this.domElement && this.cssEffects) {
//this.domElement.addClass('hover');
if (this.recoverActive) this.domElement.addClass('active');
}
break;
case 'mouseout':
if (this.domElement && this.cssEffects) {
this.recoverActive = false;
if (this.domElement.hasClass('active')) {
this.domElement.removeClass('active');
this.recoverActive = true;
}
//this.domElement.removeClass('hover');
}
break;
case 'mousedown':
if (this.domElement && this.cssEffects) {
this.domElement.addClass('active');
}
break;
case 'mouseup':
if (this.domElement && this.cssEffects) {
this.domElement.removeClass('active');
this.recoverActive = false;
}
break;
} // switch eventName
if (this.handlers[eventName]) {
for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
var func = this.handlers[eventName][idx];
if (typeof(func) == 'function') {
// actual function reference
func(this, args);
}
else if ((typeof(func) == 'object') && (func.length == 2)) {
// PHP style object + method, i.e. [myObject, 'myMethod']
func[0][ func[1] ](this, args);
}
else if (typeof(func) == 'string') {
// name of function
window[func](this, args);
}
} // foreach event handler defined
} // user defined handler for event
}
};

File diff suppressed because one or more lines are too long