").insertBefore( $(this)); $(this).appendTo($("#tblContainer"+divNo)); divNo += 1; }); $("#divItemContent img").each(function(){ $("
").insertBefore( $(this)); $(this).appendTo($("#tblContainer"+divNo)); divNo += 1; }); // $("#divItemContent img").addClass("img-responsive"); // $("#divItemContent a").addClass("linkText") $("#divItemContent ol").addClass("list-padding") $("#itemContent a") //replace all hardcoded links in richtext content holder .each(function(){ if (this.href) { var a = this.href.split('/'); var filename = a[a.length-1]; var folder = a[a.length-2]; var url = _spPageContextInfo.webAbsoluteUrl + "/Media_And_Research/Media Releases/"+ folder + "/"+ filename; if (this.href.toLowerCase().indexOf("http://www.bsp.gov.ph/") === -1) { } else { this.href = url; }}}); $("#itemContent img") //replace all hardcoded links in richtext content holder .each(function(){ if (this.src) { var a = this.src.split('/'); var filename = a[a.length-1]; var folder = a[a.length-2]; var url = _spPageContextInfo.webAbsoluteUrl + "/Media_And_Research/Media Releases/"+ folder + "/"+ filename;if (this.src.toLowerCase().indexOf("http://www.bsp.gov.ph/") === -1) { } else { this.src = url; } } }); } app.controller('CtrlMediaDisp', ['$scope', '$http', '$window', '$filter', '$timeout', '$q','$sce','$timeout', function Ctrl($scope, $http, $window, $filter, $timeout, $q, $sce,$timeout) { var waitDialog; var _sourceURL; $scope.HasAttachment = false; $scope.ItemId= getUrlParameter('ItemId'); $('#MAR').css({"border-bottom":"3px solid black", "margin-bottom":"-3px"}); $(function () { _sourceURL = document.referrer; waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Loading...', 'Please wait while request is in progress...', 150, 800); }); $scope.load=function(){ //waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Loading...', 'Please wait while request is in progress...', 150, 330); $scope.Content ="1"; var filterstring = "ID eq '" + $scope.ItemId+ "' and OData__ModerationStatus eq 0 and Status eq '2'" $pnp.sp.web.lists.getByTitle("Media Releases and Advisories") .items .select("*") .filter(filterstring) .expand("AttachmentFiles") .orderBy('Title', true) // sort asc .get().then(function(data){ if(data.length == 0){ //check if the requested content exists, if not redirects to error page waitDialog.close(); window.location.replace(_spPageContextInfo.webAbsoluteUrl + "/Pages/PageNotFoundError.aspx?requestUrl="+ window.location.href); } $scope.Issuances = data; var z; if ($scope.Issuances[0].Tag=="Media Releases") { z = "Press Releases"; } else { z = $scope.Issuances[0].Tag; } $('#PageHeader').html("Media and Research - " + z); document.title = "Bangko Sentral ng Pilipinas Media and Research " + z; $.each($scope.Issuances , function(index, item){ //var IssuedDate = new Date(item.DateIssued); // $scope.DateIssued = IssuedDate.toLocaleDateString('en-US'); var localdate = new Date(item.PDate); dt = localdate.toLocaleString('en-US', { timeZone: 'Asia/Manila' }); $scope.PublishedDate = moment(dt).format('MMMM DD, YYYY'); $scope.ItemTag = item.Tag; $scope.Title = item.Title; $scope.ItemContent = $sce.trustAsHtml(item.Content); if (item.AttachmentFiles.length > 0){ $scope.HasAttachment = true; $scope.ItemAttachment = item.AttachmentFiles[0].ServerRelativeUrl; $scope.AttachmentName = item.AttachmentFiles[0].Name;} }) $scope.$apply(); $timeout(function(){ contentMobileResponsive(); waitDialog.close(); },500); }); } $scope.load(); $scope.init = function() { } $scope.Back= function () { var url = ""; if ($scope.Issuances[0].Tag=='Media Releases') { url = _spPageContextInfo.webAbsoluteUrl+"/SitePages/MediaAndResearch/MediaList.aspx?TabId=1"; } else { url = _spPageContextInfo.webAbsoluteUrl+"/SitePages/MediaAndResearch/MediaList.aspx?TabId=2"; } if(_sourceURL){ url= _sourceURL; } window.open(url, "_self"); } }]);