commit
96f33f6250
49 changed files with 3719 additions and 169 deletions
|
@ -54,7 +54,8 @@ var AIRTIME = (function(AIRTIME) {
|
|||
"owner_id" : "s",
|
||||
"info_url" : "s",
|
||||
"replay_gain" : "n",
|
||||
"artwork" : "s"
|
||||
"artwork" : "s",
|
||||
"track_type" : "tt"
|
||||
};
|
||||
|
||||
if (AIRTIME.library === undefined) {
|
||||
|
@ -591,6 +592,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
/* Cue Out */ { "sTitle" : $.i18n._("Cue Out") , "mDataProp" : "cueout" , "bVisible" : false , "sClass" : "library_length" , "sWidth" : "80px" },
|
||||
/* Description */ { "sTitle" : $.i18n._("Description") , "mDataProp" : "description" , "bVisible" : false , "sClass" : "library_description" , "sWidth" : "150px" },
|
||||
/* Encoded */ { "sTitle" : $.i18n._("Encoded By") , "mDataProp" : "encoded_by" , "bVisible" : false , "sClass" : "library_encoded" , "sWidth" : "150px" },
|
||||
/* Track Type */ { "sTitle" : $.i18n._("Type") , "mDataProp" : "track_type" , "sClass" : "library_track_type" , "sWidth" : "60px" },
|
||||
/* Genre */ { "sTitle" : $.i18n._("Genre") , "mDataProp" : "genre" , "sClass" : "library_genre" , "sWidth" : "100px" },
|
||||
/* ISRC Number */ { "sTitle" : $.i18n._("ISRC") , "mDataProp" : "isrc_number" , "bVisible" : false , "sClass" : "library_isrc" , "sWidth" : "150px" },
|
||||
/* Label */ { "sTitle" : $.i18n._("Label") , "mDataProp" : "label" , "bVisible" : false , "sClass" : "library_label" , "sWidth" : "125px" },
|
||||
|
@ -615,7 +617,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
);
|
||||
}
|
||||
|
||||
var colExclude = onDashboard ? [0, 1, 2, 33] : [0, 1, 2];
|
||||
var colExclude = onDashboard ? [0, 1, 2, 3, 34] : [0, 1, 2];
|
||||
|
||||
/* ############################################
|
||||
DATATABLES
|
||||
|
@ -764,6 +766,60 @@ var AIRTIME = (function(AIRTIME) {
|
|||
.on('click', function (e) {
|
||||
$(this).contextMenu({x: $(e.target).offset().left, y: $(e.target).offset().top})
|
||||
}).html("<div class='library_actions_btn'>...</div>");
|
||||
|
||||
$(nRow).find('td.library_track_type')
|
||||
.on('click', function (e) {
|
||||
|
||||
$.getJSON(
|
||||
baseUrl + "api/track-types",
|
||||
function(json){
|
||||
var type_enabled = false;
|
||||
$.each(json, function(key, value) {
|
||||
|
||||
if(value['code'] == aData.track_type){
|
||||
$("#au_"+aData.id+" td.library_track_type div.library_track_type_btn").qtip({
|
||||
overwrite: false,
|
||||
content: {
|
||||
text: value['type_name']
|
||||
},
|
||||
style: {
|
||||
classes: 'track-type-tip',
|
||||
widget: true,
|
||||
def: false,
|
||||
position: {
|
||||
target: $("#au_"+aData.id+" td.library_track_type"), // my target
|
||||
my: 'bottom center',
|
||||
at: 'top center',
|
||||
adjust: {
|
||||
x: 50
|
||||
}
|
||||
},
|
||||
tip: {
|
||||
height: 5,
|
||||
width: 12,
|
||||
corner: 'bottom left',
|
||||
mimic: 'left'
|
||||
}
|
||||
},
|
||||
show: {
|
||||
ready: true
|
||||
},
|
||||
hide: {
|
||||
delay: 200,
|
||||
fixed: true,
|
||||
}
|
||||
});
|
||||
|
||||
type_enabled = true;
|
||||
}
|
||||
});
|
||||
|
||||
if(type_enabled == false){
|
||||
alert("This type is disabled.");
|
||||
}
|
||||
});
|
||||
|
||||
}).html("<div class='library_track_type_btn'>"+aData.track_type+"</div>");
|
||||
}
|
||||
|
||||
// add audio preview image/button
|
||||
|
@ -852,9 +908,12 @@ var AIRTIME = (function(AIRTIME) {
|
|||
|
||||
var inputClass = 'filter_column filter_number_text';
|
||||
var labelStyle = "style='margin-right:35px;'";
|
||||
if (libraryColumnTypes[ele.mDataProp] != "s") {
|
||||
if (libraryColumnTypes[ele.mDataProp] == "n" || libraryColumnTypes[ele.mDataProp] == "i") {
|
||||
inputClass = 'filterColumn filter_number_range';
|
||||
labelStyle = "";
|
||||
} else if (libraryColumnTypes[ele.mDataProp] == "tt") {
|
||||
inputClass = 'filterColumn filter_track_type_select';
|
||||
labelStyle = "";
|
||||
}
|
||||
|
||||
if (ele.bVisible) {
|
||||
|
@ -873,6 +932,8 @@ var AIRTIME = (function(AIRTIME) {
|
|||
|
||||
if (libraryColumnTypes[ele.mDataProp] == "s") {
|
||||
var obj = { sSelector: "#"+ele.mDataProp }
|
||||
} else if (libraryColumnTypes[ele.mDataProp] == "tt") {
|
||||
var obj = { sSelector: "#"+ele.mDataProp, type: "select" }
|
||||
} else {
|
||||
var obj = { sSelector: "#"+ele.mDataProp, type: "number-range" }
|
||||
}
|
||||
|
@ -1597,9 +1658,29 @@ var validationTypes = {
|
|||
"track_number" : "i",
|
||||
"info_url" : "s",
|
||||
"artwork" : "s",
|
||||
"track_type" : "s",
|
||||
"year" : "i"
|
||||
};
|
||||
|
||||
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||
}
|
||||
|
||||
function tracktypesJson() {
|
||||
$(function() {
|
||||
jQuery.getJSON(
|
||||
baseUrl + "api/track-types",
|
||||
function(json){
|
||||
var ttSelect = $('#track_type .filter_select .select_filter');
|
||||
$.each(json, function(key, value) {
|
||||
var option = $("<option/>", {
|
||||
value: value['code'],
|
||||
text: value['type_name']
|
||||
});
|
||||
ttSelect.append(option);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function readArtworkURL(input, id) {
|
||||
|
||||
|
@ -1666,6 +1747,8 @@ var resampleImg = (function (canvas) {
|
|||
|
||||
|
||||
$(document).ready(function() {
|
||||
tracktypesJson();
|
||||
|
||||
if (window.location.href.indexOf("showbuilder") > -1) {
|
||||
AIRTIME.library.initPodcastDatatable();
|
||||
}
|
||||
|
|
|
@ -203,4 +203,17 @@ $(document).ready(function () {
|
|||
self.recentUploadsTable = self.setupRecentUploadsTable();
|
||||
|
||||
//$("#recent_uploads_table.div.fg-toolbar").prepend('<b>Custom tool bar! Text/images etc.</b>');
|
||||
|
||||
$("#select_type").on("change",function(){
|
||||
var ttValue = $("#select_type").val();
|
||||
var ttText = $('#select_type option[value="'+ttValue+'"]').text();
|
||||
if (ttValue != ""){
|
||||
$("#upload_type").text(" " + ttText);
|
||||
$("#upload_type").css("color", "#ff611f");
|
||||
} else {
|
||||
$("#upload_type").text(" Tracks");
|
||||
$("#upload_type").css("color", "#ffffff");
|
||||
}
|
||||
Cookies.set('tt_upload', ttValue);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ function setSmartBlockEvents() {
|
|||
|
||||
/********** ADD CRITERIA ROW **********/
|
||||
form.find('#criteria_add').live('click', function(){
|
||||
|
||||
|
||||
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last');
|
||||
|
||||
if (div.length == 0) {
|
||||
|
@ -26,7 +26,7 @@ function setSmartBlockEvents() {
|
|||
|
||||
div.find('.db-logic-label').text('and').css('display', 'table');
|
||||
div.removeClass('search-row-or').addClass('search-row-and');
|
||||
|
||||
|
||||
div = div.next().show();
|
||||
|
||||
div.children().removeAttr('disabled');
|
||||
|
@ -45,11 +45,11 @@ function setSmartBlockEvents() {
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/********** ADD MODIFIER ROW **********/
|
||||
form.find('a[id^="modifier_add"]').live('click', function(){
|
||||
var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
|
||||
|
||||
|
||||
|
||||
//make new modifier row
|
||||
var newRow = $(this).parent().clone(),
|
||||
|
@ -63,13 +63,13 @@ function setSmartBlockEvents() {
|
|||
if (newRow.children().hasClass('errors sp-errors')) {
|
||||
newRow.find('span[class="errors sp-errors"]').remove();
|
||||
}
|
||||
|
||||
|
||||
//hide the critieria field select box
|
||||
newRowCrit.addClass('sp-invisible');
|
||||
|
||||
|
||||
//keep criteria value the same
|
||||
newRowCrit.val(criteria_value);
|
||||
|
||||
|
||||
//reset all other values
|
||||
newRowMod.val('0');
|
||||
newRowVal.val('');
|
||||
|
@ -78,12 +78,12 @@ function setSmartBlockEvents() {
|
|||
disableAndHideDateTimeDropdown(newRowVal);
|
||||
disableAndHideExtraDateTimeDropdown(newRowVal);
|
||||
sizeTextBoxes(newRowVal, 'sp_extra_input_text', 'sp_input_text');
|
||||
|
||||
|
||||
//remove the 'criteria add' button from new modifier row
|
||||
newRow.find('#criteria_add').remove();
|
||||
|
||||
$(this).parent().after(newRow);
|
||||
|
||||
|
||||
// remove extra spacing from previous row
|
||||
newRow.prev().removeClass('search-row-and').addClass('search-row-or');
|
||||
|
||||
|
@ -93,7 +93,7 @@ function setSmartBlockEvents() {
|
|||
removeButtonCheck();
|
||||
groupCriteriaRows();
|
||||
});
|
||||
|
||||
|
||||
/********** REMOVE ROW **********/
|
||||
form.find('a[id^="criteria_remove"]').live('click', function(){
|
||||
var curr = $(this).parent();
|
||||
|
@ -128,10 +128,10 @@ function setSmartBlockEvents() {
|
|||
|
||||
for (var i=0; i<count; i++) {
|
||||
index = getRowIndex(curr);
|
||||
|
||||
|
||||
var criteria = next.find('[name^="sp_criteria_field"]').val();
|
||||
curr.find('[name^="sp_criteria_field"]').val(criteria);
|
||||
|
||||
|
||||
var modifier = next.find('[name^="sp_criteria_modifier"]').val();
|
||||
populateModifierSelect(curr.find('[name^="sp_criteria_field"]'), false);
|
||||
curr.find('[name^="sp_criteria_modifier"]').val(modifier);
|
||||
|
@ -148,7 +148,7 @@ function setSmartBlockEvents() {
|
|||
*/
|
||||
if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled"
|
||||
&& next.find('#extra_criteria').is(':visible')) {
|
||||
|
||||
|
||||
var criteria_extra = next.find('[name^="sp_criteria_extra"]').val();
|
||||
curr.find('[name^="sp_criteria_extra"]').val(criteria_extra);
|
||||
disableAndHideExtraField(next.find(':first-child'), getRowIndex(next));
|
||||
|
@ -159,7 +159,7 @@ function setSmartBlockEvents() {
|
|||
} else if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled"
|
||||
&& next.find('#extra_criteria').not(':visible')) {
|
||||
disableAndHideExtraField(curr.find(':first-child'), index);
|
||||
|
||||
|
||||
/* if only the next row has the extra criteria value,
|
||||
* then add the extra criteria element to current row
|
||||
* and assign next row's value to it
|
||||
|
@ -231,12 +231,12 @@ function setSmartBlockEvents() {
|
|||
curr.find('select[name^="sp_criteria_field"]').removeClass('sp-invisible');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
curr = next;
|
||||
next = curr.next();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Disable the last visible row since it holds the values the user removed
|
||||
* Reset the values to empty and resize the criteria value textbox
|
||||
* in case the row had the extra criteria textbox
|
||||
|
@ -255,12 +255,12 @@ function setSmartBlockEvents() {
|
|||
.find('[name^="sp_criteria_value"]').val('').end()
|
||||
.find('[name^="sp_criteria_extra"]').val('')
|
||||
.find('[name^="sp_criteria_extra_datetime_select"]').end();
|
||||
|
||||
|
||||
sizeTextBoxes(item_to_hide.find('[name^="sp_criteria_value"]'), 'sp_extra_input_text', 'sp_input_text');
|
||||
item_to_hide.hide();
|
||||
|
||||
list.next().show();
|
||||
|
||||
|
||||
//check if last row is a modifier row
|
||||
var last_row = list.find('div:visible:last');
|
||||
if (last_row.find('[name^="sp_criteria_field"]').val() == last_row.prev().find('[name^="sp_criteria_field"]').val()) {
|
||||
|
@ -268,22 +268,22 @@ function setSmartBlockEvents() {
|
|||
last_row.find('select[name^="sp_criteria_field"]').addClass('sp-invisible');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// always put '+' button on the last enabled row
|
||||
appendAddButton();
|
||||
|
||||
|
||||
reindexElements();
|
||||
|
||||
|
||||
// always put '+' button on the last modifier row
|
||||
appendModAddButton();
|
||||
|
||||
|
||||
// remove the 'x' button if only one row is enabled
|
||||
removeButtonCheck();
|
||||
|
||||
groupCriteriaRows();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
/********** SAVE ACTION **********/
|
||||
// moved to spl.js
|
||||
|
||||
|
@ -291,12 +291,12 @@ function setSmartBlockEvents() {
|
|||
activeTab.find('button[id="generate_button"]').live("click", function(){
|
||||
buttonClickAction('generate', 'playlist/smart-block-generate');
|
||||
});
|
||||
|
||||
|
||||
/********** SHUFFLE ACTION **********/
|
||||
activeTab.find('button[id="shuffle_button"]').live("click", function(){
|
||||
buttonClickAction('shuffle', 'playlist/smart-block-shuffle');
|
||||
});
|
||||
|
||||
|
||||
/********** CHANGE PLAYLIST TYPE **********/
|
||||
form.find('dd[id="sp_type-element"]').live("change", function(){
|
||||
//buttonClickAction('generate', 'playlist/empty-content');
|
||||
|
@ -318,7 +318,7 @@ function setSmartBlockEvents() {
|
|||
|
||||
|
||||
/********** CRITERIA CHANGE **********/
|
||||
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"]):not([id^="sp_criteria_datetime"]):not([id^="sp_criteria_extra_datetime"])').live("change", function(){
|
||||
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"]):not([id^="sp_criteria_datetime"]):not([id^="sp_criteria_extra_datetime"]):not([id^="sp_criteria_value"])').live("change", function(){
|
||||
var index = getRowIndex($(this).parent());
|
||||
//need to change the criteria value for any modifier rows
|
||||
var critVal = $(this).val();
|
||||
|
@ -334,14 +334,21 @@ function setSmartBlockEvents() {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// disable extra field and hide the span
|
||||
disableAndHideExtraField($(this), index);
|
||||
disableAndHideDateTimeDropdown($(this), index);
|
||||
disableAndHideExtraDateTimeDropdown($(this),index);
|
||||
populateModifierSelect(this, true);
|
||||
|
||||
if ($( "#sp_criteria_field_" + index +" option:selected" ).val() === 'track_type') {
|
||||
populateTracktypeSelect(this, false);
|
||||
} else {
|
||||
disableAndHideTracktypeDropdown($(this),index);
|
||||
populateModifierSelect(this, true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/********** MODIFIER CHANGE **********/
|
||||
form.find('select[id^="sp_criteria_modifier"]').live("change", function(){
|
||||
var criteria_value = $(this).next(),
|
||||
|
@ -370,6 +377,16 @@ function setSmartBlockEvents() {
|
|||
else {
|
||||
disableAndHideExtraDateTimeDropdown(criteria_value,index_num);
|
||||
}
|
||||
|
||||
var get_crit_field = $(this).siblings(':first-child');
|
||||
var crit_field = get_crit_field[0]["id"];
|
||||
if ($( "#" + crit_field +" option:selected" ).val() === 'track_type') {
|
||||
if ($(this).val() == "is" || $(this).val() == "is not") {
|
||||
enableAndShowTracktypeDropdown(criteria_value, index_num);
|
||||
} else {
|
||||
disableAndHideTracktypeDropdown(criteria_value, index_num);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setupUI();
|
||||
|
@ -384,7 +401,7 @@ function getRowIndex(ele) {
|
|||
start = 3,
|
||||
tokens = id.split(delimiter).slice(start),
|
||||
index = tokens.join(delimiter);
|
||||
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
@ -428,7 +445,7 @@ function reindexElements() {
|
|||
|
||||
$.each(divs, function(i, div){
|
||||
if (i > 0 && index < 26) {
|
||||
|
||||
|
||||
/* If the current row's criteria field is hidden we know it is
|
||||
* a modifier row
|
||||
*/
|
||||
|
@ -444,13 +461,15 @@ function reindexElements() {
|
|||
index++;
|
||||
modIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
$(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex);
|
||||
$(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex);
|
||||
$(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex);
|
||||
$(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex);
|
||||
$(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex);
|
||||
$(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex);
|
||||
$(div).find('select[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex);
|
||||
$(div).find('select[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex);
|
||||
$(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex);
|
||||
$(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex);
|
||||
$(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index);
|
||||
|
@ -464,7 +483,7 @@ function reindexElements() {
|
|||
function buttonClickAction(clickType, url){
|
||||
var data = $('.active-tab .smart-block-form').serializeArray(),
|
||||
obj_id = $('.active-tab .obj_id').val();
|
||||
|
||||
|
||||
enableLoadingIcon();
|
||||
$.post(url, {format: "json", data: data, obj_id: obj_id, obj_type: "block",
|
||||
modified: AIRTIME.playlist.getModified()
|
||||
|
@ -499,7 +518,7 @@ function setupUI() {
|
|||
shuffleButton.addClass('ui-state-disabled');
|
||||
shuffleButton.attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
|
||||
if (activeTab.find('.obj_type').val() == 'block') {
|
||||
if (playlist_type == "1") {
|
||||
shuffleButton.removeAttr("disabled");
|
||||
|
@ -514,7 +533,7 @@ function setupUI() {
|
|||
//sortable.children().hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$(".playlist_type_help_icon").qtip({
|
||||
content: {
|
||||
text: $.i18n._("A static smart block will save the criteria and generate the block content immediately. This allows you to edit and view it in the Library before adding it to a show.")+"<br /><br />" +
|
||||
|
@ -536,7 +555,7 @@ function setupUI() {
|
|||
at: "right center"
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(".repeat_tracks_help_icon").qtip({
|
||||
content: {
|
||||
text: sprintf($.i18n._("The desired block length will not be reached if %s cannot find enough unique tracks to match your criteria. Enable this option if you wish to allow tracks to be added multiple times to the smart block."), PRODUCT_NAME)
|
||||
|
@ -586,6 +605,19 @@ function setupUI() {
|
|||
});
|
||||
}
|
||||
|
||||
function enableAndShowTracktypeDropdown(valEle, index) {
|
||||
console.log('tracktype show');
|
||||
$("#sp_criteria_value_"+index).replaceWith('<select name="sp_criteria_value_'+index+'" id="sp_criteria_value_'+index+'" class="input_select sp_input_select"></select>');
|
||||
$.each(stringTracktypeOptions, function(key, value){
|
||||
$("#sp_criteria_value_"+index).append($('<option></option>').attr('value', key).text(value));
|
||||
});
|
||||
}
|
||||
|
||||
function disableAndHideTracktypeDropdown(valEle, index) {
|
||||
console.log('tracktype hide');
|
||||
$("#sp_criteria_value_"+index).replaceWith('<input type="text" name="sp_criteria_value_'+index+'" id="sp_criteria_value_'+index+'" value="" class="input_text sp_input_text">');
|
||||
}
|
||||
|
||||
/* Utilizing jQuery this function finds the #datetime_select element on the given row
|
||||
* and shows the criteria drop-down
|
||||
*/
|
||||
|
@ -661,7 +693,7 @@ function disableAndHideExtraField(valEle, index) {
|
|||
spanExtra.children('#sp_criteria_extra_'+index).val("").attr("disabled", "disabled");
|
||||
spanExtra.hide();
|
||||
console.log('hidden');
|
||||
|
||||
|
||||
//make value input larger since we don't have extra field now
|
||||
var criteria_value = $('#sp_criteria_value_'+index);
|
||||
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
|
||||
|
@ -682,18 +714,19 @@ function sizeTextBoxes(ele, classToRemove, classToAdd) {
|
|||
}
|
||||
|
||||
function populateModifierSelect(e, popAllMods) {
|
||||
|
||||
var criteria_type = getCriteriaOptionType(e),
|
||||
index = getRowIndex($(e).parent()),
|
||||
divs;
|
||||
|
||||
|
||||
if (popAllMods) {
|
||||
index = index.substring(0, 1);
|
||||
}
|
||||
divs = $(e).parents().find('select[id^="sp_criteria_modifier_'+index+'"]');
|
||||
|
||||
|
||||
$.each(divs, function(i, div){
|
||||
$(div).children().remove();
|
||||
|
||||
|
||||
if (criteria_type == 's') {
|
||||
$.each(stringCriteriaOptions, function(key, value){
|
||||
$(div).append($('<option></option>')
|
||||
|
@ -708,6 +741,13 @@ function populateModifierSelect(e, popAllMods) {
|
|||
.text(value));
|
||||
});
|
||||
}
|
||||
else if(criteria_type == 'tt') {
|
||||
$.each(stringIsNotOptions, function(key, value){
|
||||
$(div).append($('<option></option>')
|
||||
.attr('value', key)
|
||||
.text(value));
|
||||
});
|
||||
}
|
||||
else {
|
||||
$.each(numericCriteriaOptions, function(key, value){
|
||||
$(div).append($('<option></option>')
|
||||
|
@ -718,11 +758,36 @@ function populateModifierSelect(e, popAllMods) {
|
|||
});
|
||||
}
|
||||
|
||||
function populateTracktypeSelect(e, popAllMods) {
|
||||
|
||||
var criteria_type = getTracktype(e),
|
||||
index = getRowIndex($(e).parent()),
|
||||
divs;
|
||||
|
||||
if (popAllMods) {
|
||||
index = index.substring(0, 1);
|
||||
}
|
||||
divs = $(e).parents().find('select[id^="sp_criteria_modifier_'+index+'"]');
|
||||
$.each(divs, function(i, div){
|
||||
$(div).children().remove();
|
||||
$.each(stringIsNotOptions, function(key, value){
|
||||
$(div).append($('<option></option>')
|
||||
.attr('value', key)
|
||||
.text(value));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getCriteriaOptionType(e) {
|
||||
var criteria = $(e).val();
|
||||
return criteriaTypes[criteria];
|
||||
}
|
||||
|
||||
function getTracktype(e) {
|
||||
var type = $(e).val();
|
||||
return stringTracktypeOptions[type];
|
||||
}
|
||||
|
||||
function callback(json, type) {
|
||||
var dt = $('table[id="library_display"]').dataTable(),
|
||||
form = $('.active-tab .smart-block-form');
|
||||
|
@ -777,7 +842,7 @@ function appendAddButton() {
|
|||
enabled = rows.find('select[name^="sp_criteria_field"]:enabled');
|
||||
|
||||
rows.find('#criteria_add').remove();
|
||||
|
||||
|
||||
if (enabled.length > 1) {
|
||||
rows.find('select[name^="sp_criteria_field"]:enabled:last')
|
||||
.siblings('a[id^="criteria_remove"]')
|
||||
|
@ -821,7 +886,7 @@ function disableLoadingIcon() {
|
|||
|
||||
function groupCriteriaRows() {
|
||||
// check whether rows should be "grouped" and shown with an "or" "logic label", or separated by an "and" "logic label"
|
||||
var visibleRows = $("#sp_criteria-element > div:visible"),
|
||||
var visibleRows = $("#sp_criteria-element > div:visible"),
|
||||
prevRowGroup = "0";
|
||||
|
||||
visibleRows.each(function (index){
|
||||
|
@ -837,7 +902,7 @@ function groupCriteriaRows() {
|
|||
}
|
||||
});
|
||||
|
||||
// ensure spacing below last visible row
|
||||
// ensure spacing below last visible row
|
||||
$("#sp_criteria-element > div:visible:last").addClass("search-row-and").removeClass("search-row-or");
|
||||
}
|
||||
|
||||
|
@ -874,7 +939,8 @@ var criteriaTypes = {
|
|||
"track_title" : "s",
|
||||
"track_number" : "n",
|
||||
"info_url" : "s",
|
||||
"year" : "n"
|
||||
"year" : "n",
|
||||
"track_type" : "tt"
|
||||
};
|
||||
|
||||
var stringCriteriaOptions = {
|
||||
|
@ -886,7 +952,7 @@ var stringCriteriaOptions = {
|
|||
"starts with" : $.i18n._("starts with"),
|
||||
"ends with" : $.i18n._("ends with")
|
||||
};
|
||||
|
||||
|
||||
var numericCriteriaOptions = {
|
||||
"0" : $.i18n._("Select modifier"),
|
||||
"is" : $.i18n._("is"),
|
||||
|
@ -907,3 +973,12 @@ var dateTimeCriteriaOptions = {
|
|||
"is less than" : $.i18n._("is less than"),
|
||||
"is in the range" : $.i18n._("is in the range")
|
||||
};
|
||||
|
||||
var stringIsNotOptions = {
|
||||
"0" : $.i18n._("Select modifier"),
|
||||
"is" : $.i18n._("is"),
|
||||
"is not" : $.i18n._("is not")
|
||||
};
|
||||
|
||||
let tracktypes = TRACKTYPES;
|
||||
var stringTracktypeOptions = Object.assign({"": "Select Track Type"}, tracktypes);
|
151
airtime_mvc/public/js/airtime/tracktype/tracktype.js
Normal file
151
airtime_mvc/public/js/airtime/tracktype/tracktype.js
Normal file
|
@ -0,0 +1,151 @@
|
|||
|
||||
function populateForm(entries){
|
||||
|
||||
$('.errors').remove();
|
||||
$('.success').remove();
|
||||
|
||||
$('#tracktype_id').val(entries.id);
|
||||
$('#code').val(entries.code);
|
||||
$('#type_name').val(entries.type_name);
|
||||
$('#description').val(entries.description);
|
||||
|
||||
if (entries.visibility) {
|
||||
var visibility_value = 1;
|
||||
} else {
|
||||
var visibility_value = 0;
|
||||
}
|
||||
$('#visibility').val(visibility_value);
|
||||
|
||||
if (entries.id.length != 0){
|
||||
$('#code').attr('readonly', 'readonly');
|
||||
} else {
|
||||
$('#code').removeAttr('readonly');
|
||||
}
|
||||
}
|
||||
|
||||
function rowClickCallback(row_id){
|
||||
$.ajax({ url: baseUrl+'Tracktype/get-tracktype-data/id/'+ row_id +'/format/json', dataType:"json", success:function(data){
|
||||
populateForm(data.entries);
|
||||
$("#tracktype_details").css("visibility", "visible");
|
||||
}});
|
||||
}
|
||||
|
||||
function removeTracktypeCallback(row_id, nRow) {
|
||||
if (confirm($.i18n._("Are you sure you want to delete this tracktype?"))) {
|
||||
$.ajax({
|
||||
url: baseUrl + 'Tracktype/remove-tracktype/id/' + row_id + '/format/json',
|
||||
dataType: "text",
|
||||
success: function (data) {
|
||||
var o = $('#tracktypes_datatable').dataTable().fnDeleteRow(nRow);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function rowCallback( nRow, aData, iDisplayIndex ){
|
||||
$(nRow).click(function(){rowClickCallback(aData['id'])});
|
||||
if( aData['delete'] != "self"){
|
||||
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeTracktypeCallback(aData['id'], nRow)});
|
||||
}else{
|
||||
$('td:eq(4)', nRow).empty().append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); alert("Can't delete yourself!")});
|
||||
}
|
||||
|
||||
if ( aData['visibility'] == "1" ) {
|
||||
$('td:eq(3)', nRow).html( $.i18n._('Enabled') );
|
||||
} else {
|
||||
$('td:eq(3)', nRow).html( $.i18n._('Disabled') );
|
||||
}
|
||||
|
||||
return nRow;
|
||||
}
|
||||
|
||||
function populateTracktypeTable() {
|
||||
var dt = $('#tracktypes_datatable');
|
||||
dt.dataTable( {
|
||||
"bProcessing": true,
|
||||
"bServerSide": true,
|
||||
"sAjaxSource": baseUrl+"Tracktype/get-tracktype-data-table-info/format/json",
|
||||
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
||||
$.ajax( {
|
||||
"dataType": 'json',
|
||||
"type": "POST",
|
||||
"url": sSource,
|
||||
"data": aoData,
|
||||
"success": fnCallback
|
||||
} );
|
||||
},
|
||||
"fnRowCallback": rowCallback,
|
||||
"aoColumns": [
|
||||
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id" },
|
||||
/* code */ { "sName": "code", "mDataProp": "code" },
|
||||
/* type_name */ { "sName": "type_name", "mDataProp": "type_name" },
|
||||
/* description */ { "sName": "description", "mDataProp": "description" },
|
||||
/* visibility */ { "sName": "visibility", "bSearchable": false, "mDataProp": "visibility" },
|
||||
/* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false, "mDataProp": "delete"}
|
||||
],
|
||||
"bJQueryUI": true,
|
||||
"bAutoWidth": false,
|
||||
"bLengthChange": false,
|
||||
"oLanguage": getDatatablesStrings({
|
||||
"sEmptyTable": $.i18n._("No track types were found."),
|
||||
"sEmptyTable": $.i18n._("No track types found"),
|
||||
"sZeroRecords": $.i18n._("No matching track types found"),
|
||||
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ track types"),
|
||||
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 track types"),
|
||||
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total track types)"),
|
||||
}),
|
||||
"sDom": '<"H"lf<"dt-process-rel"r>><"#tracktype_list_inner_wrapper"t><"F"ip>'
|
||||
});
|
||||
}
|
||||
|
||||
function sizeFormElements() {
|
||||
$("dt[id$='label']").addClass('tracktype-form-label');
|
||||
$("dd[id$='element']").addClass('tracktype-form-element');
|
||||
}
|
||||
|
||||
function initTracktypeData() {
|
||||
var visibility = $('#visibility');
|
||||
|
||||
var table = $("#tracktypes_datable");//.DataTable();
|
||||
$('.datatable tbody').on( 'click', 'tr', function () {
|
||||
$(this).parent().find('tr.selected').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
} );
|
||||
|
||||
$('#button').click( function () {
|
||||
table.row('.selected').remove().draw( false );
|
||||
} );
|
||||
|
||||
var newTracktype = {code:"", type_name:"", description:"", visibility:"1", id:""};
|
||||
|
||||
$('#add_tracktype_button').live('click', function(){
|
||||
populateForm(newTracktype);
|
||||
$("#tracktype_details").css("visibility", "visible");
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
populateTracktypeTable();
|
||||
initTracktypeData();
|
||||
|
||||
$('#save_tracktype').live('click', function(){
|
||||
var data = $('#tracktype_form').serialize();
|
||||
var url = baseUrl+'Tracktype/add-tracktype';
|
||||
|
||||
$.post(url, {format: "json", data: data}, function(json){
|
||||
if (json.valid === "true") {
|
||||
$('#content').empty().append(json.html);
|
||||
populateTracktypeTable();
|
||||
init(); // Reinitialize
|
||||
} else {
|
||||
//if form is invalid we only need to redraw the form
|
||||
$('#tracktype_form').empty().append($(json.html).find('#tracktype_form').children());
|
||||
}
|
||||
setTimeout(removeSuccessMsg, 5000);
|
||||
sizeFormElements();
|
||||
});
|
||||
});
|
||||
|
||||
sizeFormElements();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue