$(document).ready(function(){sortsManager.bindSortableTables();sortsManager.prepareSortIcons()});var sortsManager={sortSelectors:{holdingsSortBy:'input[name="HoldingsSortBy"]',holdingsSortByOrientation:'input[name="HoldingsSortByOrientation"]',previousHoldingsSortBy:'input[name="PreviousHoldingsSortBy"]',previousHoldingsSortByOrientation:'input[name="PreviousHoldingsSortByOrientation"]',watchlistSortBy:'input[name="WatchlistSortBy"]',watchlistSortByOrientation:'input[name="WatchlistSortByOrientation"]',fundResultsSortBy:'input:hidden[name="OrderBy"]',fundResultsSortByOrientation:'input:hidden[name="OrderByOrientation"]',suburbsSortBy:'input:hidden[name="OrderById"]',suburbsSortByOrientation:'input:hidden[name="OrderByOrientation"]',sortBy:'input[name="SortBy"]',sortByOrientation:'input[name="SortByOrientation"]'},getSortablesData:function(){return{holdingsSortBy:$("body").find(this.sortSelectors.holdingsSortBy).val(),holdingsSortByOrientation:$("body").find(this.sortSelectors.holdingsSortByOrientation).val(),previousHoldingsSortBy:$("body").find(this.sortSelectors.previousHoldingsSortBy).val(),previousHoldingsSortByOrientation:$("body").find(this.sortSelectors.previousHoldingsSortByOrientation).val(),watchlistSortBy:$("body").find(this.sortSelectors.watchlistSortBy).val(),watchlistSortByOrientation:$("body").find(this.sortSelectors.watchlistSortByOrientation).val(),fundResultsSortBy:$("body").find(this.sortSelectors.fundResultsSortBy).val(),fundResultsSortByOrientation:$("body").find(this.sortSelectors.fundResultsSortByOrientation).val(),suburbsSortBy:$("body").find(this.sortSelectors.suburbsSortBy).val(),suburbsSortByOrientation:$("body").find(this.sortSelectors.suburbsSortByOrientation).val(),sortBy:$("body").find(this.sortSelectors.sortBy).val(),sortByOrientation:$("body").find(this.sortSelectors.sortByOrientation).val()}},addSortIcons:function(n,t,i){var r='th[data-sortby="'+t+'"]',u=n.find(r);$("<i/>",{"class":"sorter "+("Descending"===i?"is-chevron-down  font-12":"is-chevron-up  font-12")}).prependTo(u)},bindSortableTables:function(){$("body").on("click","table.sortable th[data-sortby], table.sortable-ajax th[data-sortby]",function(){var t,n,u,e=$(this).parents("table").hasClass("sortable-ajax"),f=function(){$(".sortable-form").submit()},o="undefined"!=typeof RefreshHoldings?RefreshHoldings:f,r=e?o:f,s=$(this).attr("data-sortby"),i=$(this).parents("table").attr("data-sortable-name");"watchlist"===i?(r=RefreshWatchlist,t=$.find(sortsManager.sortSelectors.watchlistSortBy),n=$.find(sortsManager.sortSelectors.watchlistSortByOrientation)):"deleted-items"===i?(r=RefreshDeletedItems,t=$.find(sortsManager.sortSelectors.sortBy),n=$.find(sortsManager.sortSelectors.sortByOrientation)):"holdings"===i?(t=$.find(sortsManager.sortSelectors.holdingsSortBy),n=$.find(sortsManager.sortSelectors.holdingsSortByOrientation)):"fund-result"===i?(t=$.find(sortsManager.sortSelectors.fundResultsSortBy),n=$.find(sortsManager.sortSelectors.fundResultsSortByOrientation)):"data-table"===i?(t=$.find(sortsManager.sortSelectors.sortBy),n=$.find(sortsManager.sortSelectors.sortByOrientation)):"suburbs"===i?(t=$.find(sortsManager.sortSelectors.suburbsSortBy),n=$.find(sortsManager.sortSelectors.suburbsSortByOrientation)):(t=$.find(sortsManager.sortSelectors.previousHoldingsSortBy),n=$.find(sortsManager.sortSelectors.previousHoldingsSortByOrientation));u="Ascending"===$(n).val()?"Descending":"Ascending";$(n).val(u);$(t).val(s);r()})},prepareSortIcons:function(){$("table.sortable, table.sortable-ajax").each(function(n,t){var i="",r="",u=$(t).attr("data-sortable-name"),f;"watchlist"===u?(i=$("body").find(sortsManager.sortSelectors.watchlistSortBy).first().val(),r=$("body").find(sortsManager.sortSelectors.watchlistSortByOrientation).first().val()):"deleted-items"===u?(i=$("body").find(sortsManager.sortSelectors.sortBy).first().val(),r=$("body").find(sortsManager.sortSelectors.sortByOrientation).first().val()):"holdings"===u?(i=$("body").find(sortsManager.sortSelectors.holdingsSortBy).first().val(),r=$("body").find(sortsManager.sortSelectors.holdingsSortByOrientation).first().val()):"previous-holdings"===u?(i=$("body").find(sortsManager.sortSelectors.previousHoldingsSortBy).first().val(),r=$("body").find(sortsManager.sortSelectors.previousHoldingsSortByOrientation).first().val()):"fund-result"===u?(i=$("body").find(sortsManager.sortSelectors.fundResultsSortBy).first().val(),r=$("body").find(sortsManager.sortSelectors.fundResultsSortByOrientation).first().val()):"suburbs"===u?(i=$("body").find(sortsManager.sortSelectors.suburbsSortBy).first().val(),r=$("body").find(sortsManager.sortSelectors.suburbsSortByOrientation).first().val()):"data-table"===u&&(i=$("body").find(sortsManager.sortSelectors.sortBy).first().val(),r=$("body").find(sortsManager.sortSelectors.sortByOrientation).first().val());f=$(this).hasClass("sortable-ajax");sortsManager.addSortIcons($(this),i,r,f);$(this).hasClass("sortable")&&$("thead th",$(this)).on("click",function(){var n=$(this).parents("form");n&&n.length&&setTimeout(function(){n.submit()},300)})})}}