{"version":3,"sources":["app/newslanding.js"],"names":["define","$","type","take","page","isLoadMore","currentIndex","$resultListArea","results","$flexgridTitles","updateTitleHeights","this","width","i","length","css","outerHeight","LoadListItems","index","hide","show","ajaxUrl","ajax","url","done","p","append","fadeIn","redirectToSearch","keyword","window","location","href","encodeURIComponent","History","pushState","document","title","replace","parseInt","attr","data","JSON","stringify","categoryId","topicId","startPage","keyWord","contentType","dataType","success","response","d","html","error","xhr","ajaxOptions","thrownError","on","e","which","val","parent","find"],"mappings":"AAAAA,QAAQ,SAAU,kBAAmB,SAAUC,GAC3C,IAAIC,EAAO,GACPC,EAAO,EACPC,EAAO,EACPC,GAAa,EACbC,EAAe,EACfC,EAAkBN,EAAE,oBACpBO,KACAC,EAAkBR,EAAE,sBAexB,SAASS,IACL,GAAIT,EAAEU,MAAMC,QAAU,KAClB,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAgBK,OAAQD,IACpCJ,EAAgBI,EAAI,KACpBZ,EAAEQ,EAAgBI,IAAIE,IAAI,SAAU,QACpCd,EAAEQ,EAAgBI,EAAI,IAAIE,IAAI,SAAU,QAEpCd,EAAEQ,EAAgBI,IAAIG,cAAgBf,EAAEQ,EAAgBI,EAAI,IAAIG,cAChEf,EAAEQ,EAAgBI,EAAI,IAAIE,IAAI,SAAUd,EAAEQ,EAAgBI,IAAIG,eAE9Df,EAAEQ,EAAgBI,IAAIE,IAAI,SAAUd,EAAEQ,EAAgBI,EAAI,IAAIG,eAElEH,GAAQ,QAIhB,IAASA,EAAI,EAAGA,EAAIJ,EAAgBK,OAAQD,IACxCZ,EAAEQ,EAAgBI,IAAIE,IAAI,SAAU,QAuDhD,SAASE,EAAcC,GACnB,GAAIA,EAAQV,EAAQM,QAAUI,GAAUZ,EAAeH,EAUnD,OATIK,EAAQM,QAAWV,EAAOD,EAC1BF,EAAE,iBAAiBkB,OAEnBlB,EAAE,iBAAiBmB,OAEvBnB,EAAE,kBAAkBkB,OAEpBb,EAAeY,OACfd,IAIJ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KAIzB5B,EAAE,iBAAiByD,GAAG,QAAS,WAC3BrD,GAAa,EACbY,EAAcX","file":"newslanding.js","sourcesContent":["define(['jquery', 'jquery.history'], function ($) {\r\n var type = '';\r\n var take = 0;\r\n var page = 1;\r\n var isLoadMore = false;\r\n var currentIndex = 1;\r\n var $resultListArea = $(\".js-news-listing\");\r\n var results = [];\r\n var $flexgridTitles = $('.js-flexgrid-title');\r\n\r\n $(function () {\r\n History.pushState({}, document.title, window.location.href);\r\n $('.js-view-more').hide();\r\n take = parseInt($(\".js-news-landing\").attr(\"data-take\"));\r\n type = $(\".js-news-landing\").attr(\"data-type\");\r\n updateTitleHeights();\r\n GetSearchResults();\r\n }());\r\n\r\n $(window).on('resize', function () {\r\n updateTitleHeights();\r\n })\r\n\r\n function updateTitleHeights() {\r\n if ($(this).width() > 1200) {\r\n for (var i = 0; i < $flexgridTitles.length; i++) {\r\n if ($flexgridTitles[i + 1]) {\r\n $($flexgridTitles[i]).css('height', 'auto');\r\n $($flexgridTitles[i + 1]).css('height', 'auto');\r\n\r\n if ($($flexgridTitles[i]).outerHeight() > $($flexgridTitles[i + 1]).outerHeight()) {\r\n $($flexgridTitles[i + 1]).css('height', $($flexgridTitles[i]).outerHeight());\r\n } else {\r\n $($flexgridTitles[i]).css('height', $($flexgridTitles[i + 1]).outerHeight());\r\n }\r\n i = i + 1;\r\n }\r\n }\r\n } else {\r\n for (var i = 0; i < $flexgridTitles.length; i++) {\r\n $($flexgridTitles[i]).css('height', 'auto');\r\n }\r\n }\r\n }\r\n\r\n $('.js-landing-search__input').on('keypress', function (e) {\r\n if (e.which == 13) { redirectToSearch($(this).val()); }\r\n });\r\n\r\n $('.js-landing-search__button').on('click', function (e) {\r\n var keyword = $(this).parent().find('.js-landing-search__input.search-input-large').val();\r\n if (!keyword) {\r\n keyword = $(this).parent().find('.js-landing-search__input.search-input-small').val();\r\n }\r\n if (keyword) {\r\n redirectToSearch(keyword);\r\n }\r\n });\r\n\r\n $('.js-view-more').on('click', function () {\r\n isLoadMore = true;\r\n LoadListItems(currentIndex);\r\n });\r\n\r\n function GetSearchResults() {\r\n $(\".loading-image\").hide();\r\n $.ajax({\r\n type: \"POST\",\r\n url: \"/Layouts/WebUserControls/Main/Insights/InsightSearchService.asmx/GetListingResults\",\r\n data: JSON.stringify({ type: type, categoryId: '', topicId: '', startPage: page, keyWord: '' }),\r\n contentType: \"application/json; charset=utf-8\",\r\n dataType: \"json\",\r\n success: function (response) {\r\n results = response.d;\r\n currentIndex = 1;\r\n\r\n if (results.length == 0) {\r\n $(\".loading-image\").hide();\r\n }\r\n\r\n //clear previous search results if load more is false\r\n if (!isLoadMore) {\r\n $resultListArea.html('');\r\n }\r\n\r\n LoadListItems(currentIndex)\r\n\r\n $resultListArea.show();\r\n },\r\n error: function (xhr, ajaxOptions, thrownError) {\r\n\r\n }\r\n });\r\n }\r\n\r\n function LoadListItems(index) {\r\n if (index > results.length || index >= (currentIndex + take)) {\r\n if (results.length <= (page * take)) {\r\n $('.js-view-more').hide();\r\n } else {\r\n $('.js-view-more').show();\r\n }\r\n $(\".loading-image\").hide();\r\n\r\n currentIndex = index;\r\n page++;\r\n return;\r\n }\r\n\r\n var ajaxUrl = \"/Layouts/WebUserControls/Main/Insights/AjaxLoadListItem.aspx?guid=\" + results[index - 1];\r\n $.ajax({ url: ajaxUrl })\r\n .done(function (p) {\r\n $resultListArea.append(p);\r\n $resultListArea.fadeIn();\r\n LoadListItems(index + 1)\r\n $(\".loading-image\").hide();\r\n });\r\n }\r\n\r\n function redirectToSearch(keyword) {\r\n var url = window.location.href + '/search?keyword=' + encodeURIComponent(keyword);\r\n History.pushState({}, document.title, url);\r\n window.location.replace(url);\r\n }\r\n});"]}