fixes #914 - Add option to save metadata hidden

This commit is contained in:
Luke Pulverenti 2014-09-06 00:21:23 -04:00
parent 950fc7ee7a
commit 56d7a4b41f
8 changed files with 178 additions and 19 deletions

View file

@ -45,6 +45,8 @@
$('#chkEnableAlbumArtInDidl', page).checked(profile.EnableAlbumArtInDidl).checkboxradio('refresh');
renderXmlDocumentAttributes(page, profile.XmlRootAttributes || []);
var idInfo = profile.Identification || {};
renderIdentificationHeaders(page, idInfo.Headers || []);
@ -173,6 +175,73 @@
$('#identificationHeaderPopup', page).popup('close');
}
function renderXmlDocumentAttributes(page, attribute) {
var index = 0;
var html = '<ul data-role="listview" data-inset="true" data-split-icon="delete">' + attribute.map(function (h) {
var li = '<li>';
li += '<a href="#">';
li += '<div style="font-weight:normal;">' + h.Name + ' = ' + (h.Value || '') + '</div>';
li += '</a>';
li += '<a class="btnDeleteXmlAttribute" href="#" data-index="' + index + '"></a>';
li += '</li>';
index++;
return li;
}).join('') + '</ul>';
var elem = $('.xmlDocumentAttributeList', page).html(html).trigger('create');
$('.btnDeleteXmlAttribute', elem).on('click', function () {
var itemIndex = parseInt(this.getAttribute('data-index'));
currentProfile.XmlRootAttributes.splice(itemIndex, 1);
renderXmlDocumentAttributes(page, currentProfile.XmlRootAttributes);
});
}
function editXmlDocumentAttribute(page, attribute) {
isSubProfileNew = attribute == null;
attribute = attribute || {};
currentSubProfile = attribute;
var popup = $('#xmlAttributePopup', page);
$('#txtXmlAttributeName', popup).val(attribute.Name || '');
$('#txtXmlAttributeValue', popup).val(attribute.Value || '');
popup.popup('open');
}
function saveXmlDocumentAttribute(page) {
currentSubProfile.Name = $('#txtXmlAttributeName', page).val();
currentSubProfile.Value = $('#txtXmlAttributeValue', page).val();
if (isSubProfileNew) {
currentProfile.XmlRootAttributes.push(currentSubProfile);
}
renderXmlDocumentAttributes(page, currentProfile.XmlRootAttributes);
currentSubProfile = null;
$('#xmlAttributePopup', page).popup('close');
}
function renderSubProfiles(page, profile) {
renderDirectPlayProfiles(page, profile.DirectPlayProfiles);
@ -907,6 +976,11 @@
editIdentificationHeader(page);
});
$('.btnAddXmlDocumentAttribute', page).on('click', function () {
editXmlDocumentAttribute(page);
});
}).on('pageshow', "#dlnaProfilePage", function () {
var page = this;
@ -991,6 +1065,16 @@
saveIdentificationHeader(page);
return false;
},
onXmlAttributeFormSubmit: function () {
var form = this;
var page = $(form).parents('.page');
saveXmlDocumentAttribute(page);
return false;
}
};