diff --git a/airtime_mvc/application/views/scripts/library/publish-dialog.phtml b/airtime_mvc/application/views/scripts/library/publish-dialog.phtml index 4b52b28dc..10bd54eb5 100644 --- a/airtime_mvc/application/views/scripts/library/publish-dialog.phtml +++ b/airtime_mvc/application/views/scripts/library/publish-dialog.phtml @@ -12,7 +12,7 @@
diff --git a/airtime_mvc/public/js/airtime/library/podcast.js b/airtime_mvc/public/js/airtime/library/podcast.js index f7d8cedaf..0c49185cc 100644 --- a/airtime_mvc/public/js/airtime/library/podcast.js +++ b/airtime_mvc/public/js/airtime/library/podcast.js @@ -68,7 +68,7 @@ var AIRTIME = (function (AIRTIME) { function _initAppFromResponse(data) { var podcast = JSON.parse(data.podcast), uid = AIRTIME.library.MediaTypeStringEnum.PODCAST+"_"+podcast.id, - tab = AIRTIME.tabs.openTab(data, uid, null), + tab = AIRTIME.tabs.openTab(data.html, uid, null), table = mod.initPodcastEpisodeDatatable(podcast.episodes); _bootstrapAngularApp(podcast, tab, table); } diff --git a/airtime_mvc/public/js/airtime/library/publish.js b/airtime_mvc/public/js/airtime/library/publish.js index 300356eb6..84afba671 100644 --- a/airtime_mvc/public/js/airtime/library/publish.js +++ b/airtime_mvc/public/js/airtime/library/publish.js @@ -15,13 +15,13 @@ var AIRTIME = (function (AIRTIME) { //AngularJS app var publishApp = angular.module(PUBLISH_APP_NAME, []) - .controller('RestController', function($scope, $http, mediaId) { + .controller('RestController', function($scope, $http, mediaId, tab) { $http.get(endpoint + mediaId, { csrf_token: jQuery("#csrf").val() }) .success(function(json) { console.log(json); $scope.media = json; - AIRTIME.tabs.setActiveTabName($scope.media.track_title); + tab.setName($scope.media.track_title); }); $scope.save = function() { @@ -46,8 +46,9 @@ var AIRTIME = (function (AIRTIME) { ids.push(el.id); });*/ - function _bootstrapAngularApp(mediaId) { + function _bootstrapAngularApp(mediaId, tab) { publishApp.value('mediaId', mediaId); + publishApp.value('tab', tab); var wrapper = AIRTIME.tabs.getActiveTab().contents.find(".editor_pane_wrapper"); wrapper.attr("ng-controller", "RestController"); angular.bootstrap(wrapper.get(0), [PUBLISH_APP_NAME]); @@ -75,10 +76,8 @@ var AIRTIME = (function (AIRTIME) { jQuery.get(dialogUrl, { csrf_token: jQuery("#csrf").val() }) .success(function(html) { - - var jsonWrapper = {'html' : html}; //Silly wrapper to make the openTab function happy - AIRTIME.tabs.openTab(jsonWrapper, mediaId); - _bootstrapAngularApp(mediaId); + var tab = AIRTIME.tabs.openTab(html, mediaId, null); + _bootstrapAngularApp(mediaId, tab); }); /* diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index f1349a188..57ba8c236 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -1074,7 +1074,7 @@ var AIRTIME = (function(AIRTIME){ {format: "json", type: 'playlist'}, function(json) { var uid = AIRTIME.library.MediaTypeStringEnum.PLAYLIST+"_"+json.id; - AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); + AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents); redrawLib(); }); }; @@ -1088,7 +1088,7 @@ var AIRTIME = (function(AIRTIME){ {format: "json"}, function(json) { var uid = AIRTIME.library.MediaTypeStringEnum.WEBSTREAM+"_"+json.id; - AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); + AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents); redrawLib(); }); }; @@ -1103,13 +1103,13 @@ var AIRTIME = (function(AIRTIME){ {format: "json", type: 'block'}, function(json){ var uid = AIRTIME.library.MediaTypeStringEnum.BLOCK+"_"+json.id; - AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); + AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents); redrawLib(); }); }; mod.fileMdEdit = function(json, uid) { - AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initFileMdEvents); + AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initFileMdEvents); }; mod.fnEdit = function(id, type, url) { @@ -1120,7 +1120,7 @@ var AIRTIME = (function(AIRTIME){ {format: "json", id: id, type: type}, function(json) { var uid = AIRTIME.library.MediaTypeFullToStringEnum.type+"_"+id; - AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); + AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents); redrawLib(); }); }; @@ -1156,7 +1156,7 @@ var AIRTIME = (function(AIRTIME){ {format: "json", ids: id, modified: lastMod, type: type}, function(json){ var uid = AIRTIME.library.MediaTypeStringEnum.WEBSTREAM+"_"+id; - AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); + AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents); redrawLib(); }); }; @@ -1204,7 +1204,7 @@ var AIRTIME = (function(AIRTIME){ mod.replaceForm = function(json){ $pl.find('.editor_pane_wrapper').html(json.html); var uid = AIRTIME.library.MediaTypeStringEnum.BLOCK+"_"+json.id; - AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); + AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents); }; diff --git a/airtime_mvc/public/js/airtime/showbuilder/tabs.js b/airtime_mvc/public/js/airtime/showbuilder/tabs.js index 93f30f281..774c50590 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/tabs.js +++ b/airtime_mvc/public/js/airtime/showbuilder/tabs.js @@ -49,17 +49,14 @@ var AIRTIME = (function(AIRTIME){ /** * Tab object constructor * - * @param {{}} json a javascript object of the form - * { - * 'html': the HTML to render as the tab contents - * } + * @param {string} html the HTML to render as the tab contents * @param {string} uid the unique ID for the tab. Uses the values in * AIRTIME.library.MediaTypeStringEnum and the object ID * to create a string of the form TYPE_ID. * @returns {Tab} the created Tab object * @constructor */ - var Tab = function(json, uid) { + var Tab = function(html, uid) { var self = this; AIRTIME.library.selectNone(); @@ -75,7 +72,7 @@ var AIRTIME = (function(AIRTIME){ // TODO: clean this up a bit and use js instead of strings to create elements var wrapper = "
", t = $("#show_builder").append(wrapper).find("#pl-tab-content-" + self.id), - pane = $(".editor_pane_wrapper:last").append(json.html), + pane = $(".editor_pane_wrapper:last").append(html), name = pane.find("#track_title").length > 0 ? pane.find("#track_title").val() + $.i18n._(" - Metadata Editor") : pane.find(".playlist_name_display").val(), tab = @@ -261,18 +258,15 @@ var AIRTIME = (function(AIRTIME){ /** * Create a new Tab object and open it in the ShowBuilder pane * - * @param {{}} json a javascript object of the form - * { - * 'html': the HTML to render as the tab contents - * } + * @param {string} html the HTML to render as the tab contents * @param {string} uid the unique ID for the tab. Uses the values in * AIRTIME.library.MediaTypeStringEnum and the object ID * @param {function} callback an optional callback function to call once the * Tab object is initialized * @returns {Tab} the created Tab object */ - mod.openTab = function(json, uid, callback) { - var newTab = new Tab(json, uid); + mod.openTab = function(html, uid, callback) { + var newTab = new Tab(html, uid); if (callback) callback(newTab); return newTab; };