';
- var imgUrl;
- var name = person.Name || "";
- var role = person.Role || "";
- var type = person.Type || "";
-
- if (person.PrimaryImageTag) {
-
- imgUrl = ApiClient.getPersonImageUrl(person.Name, {
- width: 150,
- tag: person.PrimaryImageTag,
- type: "primary"
- });
-
- } else {
-
- imgUrl = "css/images/items/list/person.png";
- }
- html += '';
- html += '
';
- html += '
';
- html += '';
- html += '';
- html += '';
-
- // The floats are to prevent jquery mobile from floating it
- html += '';
- html += ' ' + (name) + '';
- html += '';
- html += '';
- html += '
';
- html += '
';
- html += '';
- html += ' ' + (role) + '';
- html += '';
- html += '';
- html += '
';
- html += '
';
- html += '';
- html += ' ' + (type) + '';
- html += '';
- html += '';
- html += '
';
- html += '
';
-
- if (item.LocationType !== "Offline") {
- html += '';
- html += '';
- html += '';
- }
-
- html += '';
- html += '';
- html += '';
- html += '';
- html += '';
- html += '
';
- html += '
';
- html += '
';
- return html;
- }
-
- function generateTypes(type) {
- var types = new Array("", "Actor", "Director", "Composer", "Writer", "GuestStar", "Producer");
- var html = "";
-
- for (var i = 0; i < types.length; i++) {
- html += '';
- }
-
- return html;
- }
- function editItemPeoplePage() {
-
- var self = this;
- self.displayEdit = function (source) {
- $(source).parents('.tileItem').find('span.edit').show();
- $(source).parents('.tileItem').find('span.read').hide();
- };
- self.hideEdit = function (source) {
- var item = $(source).parents('.tileItem');
- item.find('span.edit').hide();
- item.find('span.read').show();
- item.find('input[name="txtName"]').val(item.find('input[name="originalName"]').val());
- item.find('input[name="txtRole"]').val(item.find('input[name="originalRole"]').val());
- item.find('select[name="selectType"]').val(item.find('input[name="originalType"]').val()).selectmenu('refresh');
- };
-
- self.removePerson = function (source) {
-
- var page = $.mobile.activePage;
-
- Dashboard.confirm("Are you sure you wish to delete this person?", "Delete Person", function (result) {
- if (result) {
- var item = $(source).parents('.tileItem');
- var originalName = item.find('input[name="originalName"]').val();
- var originalRole = item.find('input[name="originalRole"]').val();
- var originalType = item.find('input[name="originalType"]').val();
- for (var i = 0; i < currentItem.People.length; i++) {
- var name = currentItem.People[i].Name || "";
- var role = currentItem.People[i].Role || "";
- var type = currentItem.People[i].Type || "";
- if ((name + role + type) == (originalName + originalRole + originalType)) {
- currentItem.People.splice(i, 1);
- ApiClient.updateItem(currentItem).done(function () {
- reload(page);
- });
- }
- }
-
- }
- });
- };
- self.savePerson = function (source) {
-
- var page = $.mobile.activePage;
-
- var item = $(source).parents('.tileItem');
- var originalName = item.find('input[name="originalName"]').val();
- var originalRole = item.find('input[name="originalRole"]').val();
- var originalType = item.find('input[name="originalType"]').val();
- for (var i = 0; i < currentItem.People.length; i++) {
- var name = currentItem.People[i].Name || "";
- var role = currentItem.People[i].Role || "";
- var type = currentItem.People[i].Type || "";
- if ((name + role + type) == (originalName + originalRole + originalType)) {
- currentItem.People[i].Name = item.find('input[name="txtName"]').val();
- currentItem.People[i].Role = item.find('input[name="txtRole"]').val();
- currentItem.People[i].Type = item.find('select[name="selectType"]').val();
- ApiClient.updateItem(currentItem).done(function () {
- reload(page);
- });
- break;
- }
- }
- };
-
- self.addPerson = function () {
- var page = $.mobile.activePage;
-
- var html = '
';
-
- html += '
';
- html += '
Add Person
';
- html += '
';
-
- html += '
';
- html += '';
- html += '
';
- html += '
';
-
- $(page).append(html);
-
- var popup = $('#popupCreatePerson').popup().trigger('create').on("popupafteropen", function () {
- $('#popupCreatePerson input:first', this).focus();
- }).popup("open").on("popupafterclose", function () {
-
- $('form', this).off("submit");
- $(this).off("click").off("popupafterclose").remove();
-
- });
-
- $('form', popup).on('submit', function () {
-
- var form = $(this);
-
- var name = $('#txtPersonName', form).val();
- if (name != '') {
- var role = $('#txtPersonRole', form).val();
- var type = $('#selectPersonType', form).val();
- currentItem.People.push({ Name: name, Role: role, Type: type });
- ApiClient.updateItem(currentItem).done(function () {
- reload(page);
- });
- popup.popup("close");
- }
- return false;
- });
- };
- }
-
- window.EditItemPeoplePage = new editItemPeoplePage();
-
- $(document).on('pageinit', "#editItemPeoplePage", function () {
-
- var page = this;
-
- $('.libraryTree', page).on('itemclicked', function (event, data) {
-
- if (data.itemType == "livetvservice") {
- return;
- }
-
- if (data.id != currentItem.Id) {
- MetadataEditor.currentItemId = data.id;
- MetadataEditor.currentItemName = data.itemName;
- MetadataEditor.currentItemType = data.itemType;
- //Dashboard.navigate('edititemmetadata.html?id=' + data.id);
-
- //$.mobile.urlHistory.ignoreNextHashChange = true;
- window.location.hash = 'editItemPeoplePage?id=' + data.id;
-
- reload(page);
- }
- });
-
- }).on('pagebeforeshow', "#editItemPeoplePage", function () {
-
- var page = this;
-
- reload(page);
-
- }).on('pagehide', "#editItemPeoplePage", function () {
-
- var page = this;
-
- currentItem = null;
- });
-
-})(jQuery, document, window);
\ No newline at end of file