{"version":3,"sources":["honeywell.clientmodel.paginationcontroller.ts"],"names":["PaginationController","_itemCount","_queryStringParams","_norelad","_showLast","_this","this","renderPagination","values","length","pagination","itemCount","noreload","showLast","settings","IsEnabled","TotalResults","CurrentIndex","getCurentIndexFromQueryString","PageLinks","PerPage","IsFirstPage","CurrentPage","Math","ceil","TotalPages","IsLastPage","Number","lnksList","i","toString","startIndex","leftArrowPageLink1","display","link","arrow","prev","cssclass","push","leftArrowPageLink","getLink","startIndexKey","queryStringParams","Object","keys","k","hasOwnProperty","numbersLink","noLink","parseInt","rightArrowPageLink1","next","rightArrowPageLink","data","Pagination","$","html","document","on","e","JSRequest","EnsureSetup","Honeywell_ClientModel_MainHelper_1","MainHelper","configSettings","PaginationItemsPerPage","noReload","filter1Key","filter2Key","showLastLink","prototype","loadPagination","paginationFor","templatePromise","Honeywell_ClientModel_TemplateService_1","TemplateService","getTemplate","settingsPromise","getPaginationSettings","Q","all","then","catch","handleError","pp","ShowPaginationOnVideos","PaginationItemsPerPageOnVideos","ShowPaginationOnApps","PaginationItemsPerPageOnApps","ShowPaginationOnPressReleases","PaginationItemsPerPageOnPressReleases","ShowPaginationOnEvents","PaginationItemsPerPageOnEvents","ShowPaginationOnSearchResults","SearchPaginationItemsPerPage","ShowPaginationOnProductInfoResults","ProductInfoPaginationItemsPerPage","undefined","ShowPaginationOnFaq","PaginationItemsPerPageOnFaq","ShowPaginationOnTraining","PaginationItemsPerPageOnTraining","ShowPaginationOnNewsletter","PaginationItemsPerPageOnNewsletters","ShowPaginationOnNewsArticles","PaginationItemsPerPageOnNewsarticles","resolve","reason","startIndexKeyValue","window","location","pathname","aq","getallQueryKeyValues","each","ind","elem","filter","getValueFromQueryString","key","searchType","sort","getLinkWithFilters","list","max","val","toLowerCase","indexOf","startDate","trim","endDate","value","getQueryString","exports"],"mappings":"iMAKA,IAAAA,GAAA,WAWI,QAAAA,GAAYC,EAAiBC,EAAqCC,EAA0BC,OAA/D,KAAAF,IAAAA,EAAA,UA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KACjB,MAAZK,IAAmBA,EAAQH,QAAQ,MAAQG,EAAQH,QAAQ,OAAS,IACrE7F,GAAQ,YAAcgG,EAAQD,SAY1C,WAPahC,KAATwB,GAAsBA,EAAKhH,OAAS,IACpCyB,EAAOA,EAAO,SAAWuF,GAG7BvF,GAAQ,QAAU0F,EAClB1F,GAAQ,SAAWyF,GAKhB3H,EAAAsE,UAAApD,8BAAP,WACI,GAAIiH,GAAQrE,EAAAC,WAAWqE,eAAe9H,KAAKmC,cAC3C,OAAa,OAAT0F,EACO,EAGJlF,SAASkF,IAGbnI,EAAAsE,UAAAgD,wBAAP,SAA+BC,GAC3B,GAAIY,GAAQrE,EAAAC,WAAWqE,eAAeb,EACtC,OAAa,OAATY,EACO,GAGJA,GAEfnI,IAjWaqI,GAAArI,qBAAAA,EAmWbuD,EAAEE,UAAUC,GAAG,kBAAmB,SAAUC","file":"honeywell.clientmodel.paginationcontroller.js","sourcesContent":["///<reference path=\"typings/handlebar/handlebars.d.ts\"/>\r\nimport {DataService} from \"./Honeywell.ClientModel.DataService\";\r\nimport {TemplateService} from \"./Honeywell.ClientModel.TemplateService\";\r\nimport {MainHelper} from \"./Honeywell.ClientModel.MainHelper\";\r\nimport * as Q from \"q\";\r\nexport class PaginationController {\r\n\r\n\r\n    itemCount: any;\r\n    startIndexKey: string;\r\n    filter1Key: string;\r\n    filter2Key: string;\r\n    noReload: boolean;\r\n    queryStringParams: string[];\r\n    settings: any;\r\n    showLastLink: boolean;\r\n    constructor(_itemCount: any, _queryStringParams: string[] = null, _norelad: boolean = null, _showLast: boolean = true) {\r\n        $(document).on('SPContextLoaded', function (e) {\r\n            JSRequest.EnsureSetup();\r\n            if (MainHelper.configSettings.PaginationItemsPerPage !== null) {\r\n\r\n            }\r\n        });\r\n        this.itemCount = _itemCount;\r\n        this.noReload = _norelad;\r\n        this.queryStringParams = _queryStringParams;\r\n        this.startIndexKey = \"start1\";\r\n        this.filter1Key = \"filter1\";\r\n        this.filter2Key = \"filter2\";\r\n        this.showLastLink = _showLast;\r\n    }\r\n    \r\n    /**\r\n     * This methods loads info. and also applies template\r\n     */\r\n    loadPagination(paginationFor: string = null, configSettings: any = null, startIndex: number = null) {\r\n        var templatePromise = new TemplateService(\"tpl_Pagination.html\").getTemplate();\r\n        var settingsPromise = PaginationController.prototype.getPaginationSettings(paginationFor, configSettings);\r\n        return Q.all<any>([this.itemCount, templatePromise, settingsPromise, this.noReload, this.showLastLink, startIndex]).then(this.renderPagination).catch(this.handleError);\r\n    }\r\n\r\n    getPaginationSettings(pp, configSettings = null) {\r\n        var settings = {};\r\n        settings[\"List\"] = pp;\r\n\r\n        if (pp === \"Videos\") {\r\n            settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnVideos;\r\n            settings[\"ItemsPerPage\"] = MainHelper.configSettings.PaginationItemsPerPageOnVideos;\r\n        }\r\n        else if (pp === \"Apps\") {\r\n            settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnApps;\r\n            settings[\"ItemsPerPage\"] = MainHelper.configSettings.PaginationItemsPerPageOnApps;\r\n        }\r\n        else if (pp === \"PressReleasesList\") {\r\n            settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnPressReleases;\r\n            settings[\"ItemsPerPage\"] = MainHelper.configSettings.PaginationItemsPerPageOnPressReleases;\r\n        }\r\n        else if (pp === \"EventsList\") {\r\n            settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnEvents;\r\n            settings[\"ItemsPerPage\"] = MainHelper.configSettings.PaginationItemsPerPageOnEvents;\r\n        }\r\n        else if (pp === \"SearchResults\") {\r\n            settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnSearchResults;\r\n            settings[\"ItemsPerPage\"] = MainHelper.configSettings.SearchPaginationItemsPerPage;\r\n        }\r\n        else if (pp === \"ProductInfoResults\") {\r\n            settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnProductInfoResults;\r\n            settings[\"ItemsPerPage\"] = MainHelper.configSettings.ProductInfoPaginationItemsPerPage;\r\n        }\r\n        else if (pp === \"FAQ\") {\r\n            if (configSettings !== null && configSettings !== undefined) {\r\n                settings[\"PaginationEnabled\"] = configSettings.ShowPaginationOnFaq;\r\n                settings[\"ItemsPerPage\"] = configSettings.PaginationItemsPerPageOnFaq;\r\n            } else {\r\n                settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnFaq;\r\n                settings[\"ItemsPerPage\"] = MainHelper.configSettings.PaginationItemsPerPageOnFaq;\r\n            }\r\n        }\r\n        else if (pp === \"Training\") {\r\n            if (configSettings !== null && configSettings !== undefined) {\r\n                settings[\"PaginationEnabled\"] = configSettings.ShowPaginationOnTraining;\r\n                settings[\"ItemsPerPage\"] = configSettings.PaginationItemsPerPageOnTraining;\r\n            } else {\r\n                settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnTraining;\r\n                settings[\"ItemsPerPage\"] = MainHelper.configSettings.PaginationItemsPerPageOnTraining;\r\n            }\r\n        }\r\n        else if (pp === \"Newsletters\") {\r\n            if (configSettings !== null && configSettings !== \"\") {\r\n                settings[\"PaginationEnabled\"] = configSettings.ShowPaginationOnNewsletter;\r\n                settings[\"ItemsPerPage\"] = configSettings.PaginationItemsPerPageOnNewsletters;\r\n            } else {\r\n                settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnNewsletter;\r\n                settings[\"ItemsPerPage\"] = MainHelper.configSettings.PaginationItemsPerPageOnNewsletters;\r\n            }\r\n        }\r\n        else if (pp === \"NewsArticles\") {\r\n            if (configSettings !== null && configSettings !== \"\") {\r\n                settings[\"PaginationEnabled\"] = configSettings.ShowPaginationOnNewsArticles;\r\n                settings[\"ItemsPerPage\"] = configSettings.PaginationItemsPerPageOnNewsarticles;\r\n            } else {\r\n                settings[\"PaginationEnabled\"] = MainHelper.configSettings.ShowPaginationOnNewsArticles;\r\n                settings[\"ItemsPerPage\"] = MainHelper.configSettings.PaginationItemsPerPageOnNewsarticles;\r\n            }\r\n        }\r\n        else {\r\n            settings[\"PaginationEnabled\"] = true;\r\n            settings[\"ItemsPerPage\"] = 2;\r\n        }\r\n\r\n        return Q.resolve(settings);\r\n    }\r\n\r\n    /**\r\n     * I re-implemented this method to be synchronous.\r\n     */\r\n    renderPagination = (values: any[]) => {\r\n        //The array contains two elements.\r\n        if (values.length < 3) {\r\n            throw \"Too few elements in the array\";\r\n        }\r\n        var itemCount = <any[]> values[0];\r\n        var noreload = <boolean> values[3];\r\n        var showLast = <boolean> values[4];\r\n        // Creating the pagination object\r\n        var pagination: any;\r\n\r\n        this.settings = values[2];\r\n        pagination = {};\r\n        pagination.IsEnabled = values[2][\"PaginationEnabled\"] === 'True';\r\n        pagination.TotalResults = itemCount;\r\n        if (values[5] !== null) {\r\n            pagination.CurrentIndex = values[5];\r\n        }\r\n        else {\r\n            pagination.CurrentIndex = this.getCurentIndexFromQueryString();\r\n        }\r\n       \r\n        pagination.PageLinks = [];\r\n        pagination.PerPage = values[2][\"ItemsPerPage\"];\r\n        pagination.IsFirstPage = (pagination.CurrentIndex === 0);\r\n        if (values[5] !== null) {\r\n            pagination.CurrentPage = pagination.CurrentIndex + 1;\r\n        }\r\n        else {\r\n            pagination.CurrentPage = (pagination.CurrentIndex === 0) ? 1 : Math.ceil(pagination.CurrentIndex / pagination.PerPage) + 1;\r\n        }\r\n        pagination.TotalPages = Math.ceil(pagination.TotalResults / pagination.PerPage);\r\n        pagination.IsLastPage = pagination.CurrentPage == pagination.TotalPages;\r\n\r\n        if (pagination.TotalPages < 2) {\r\n            return;\r\n        }\r\n\r\n        if (Number(itemCount) > Number(pagination.PerPage)) {\r\n            var lnksList = {};\r\n\r\n            if (pagination.TotalPages < 5 && showLast) {\r\n                for (var i = 1; i <= pagination.TotalPages; i++) {\r\n                    lnksList[i] = i.toString();\r\n                }\r\n            } else if (pagination.TotalPages < 4) {\r\n                for (var i = 1; i <= pagination.TotalPages; i++) {\r\n                    lnksList[i] = i.toString();\r\n                }\r\n            }\r\n            else {\r\n                for (var i = 1; i <= pagination.TotalPages; i++) {\r\n                    if (pagination.CurrentPage === 1 && i < 4) {\r\n                        lnksList[i] = i.toString();\r\n                    }\r\n                    else if (pagination.CurrentPage === pagination.TotalPages && i > (pagination.TotalPages - 3)) {\r\n                        lnksList[i] = i.toString();\r\n                    }\r\n                    else if (pagination.TotalPages === i && showLast) {\r\n                        lnksList[i] = i.toString();\r\n                    }\r\n                    else if (i === 1) {\r\n                        lnksList[i] = i.toString();\r\n                    }\r\n                    else if (i === pagination.TotalPages && showLast) {\r\n                        lnksList[i] = i.toString();\r\n                    }\r\n                    else if (pagination.IsFirstPage && i === (pagination.CurrentPage + 3)) {\r\n                        lnksList[i] = '...';\r\n                    }\r\n                    else if (pagination.IsLastPage && i === (pagination.CurrentPage - 3)) {\r\n                        lnksList[i] = '...';\r\n                    }\r\n                    else if (i === (pagination.CurrentPage - 1) || i === pagination.CurrentPage || i === (pagination.CurrentPage + 1)) {\r\n                        lnksList[i] = i.toString();\r\n                    }\r\n                    else if (i === (pagination.CurrentPage - 2) || i === (pagination.CurrentPage + 2)) {\r\n                        lnksList[i] = '...';\r\n                    }\r\n                }\r\n            }\r\n            if (pagination.IsFirstPage) {\r\n                var startIndex = (pagination.CurrentPage * pagination.PerPage) - pagination.PerPage;\r\n\r\n                var leftArrowPageLink1 = { display: '<', link: '#', arrow: true, prev: true, cssclass: 'disabled' }\r\n                pagination.PageLinks.push(leftArrowPageLink1);\r\n            }\r\n            else {\r\n                var startIndex = ((pagination.CurrentPage - 1) * pagination.PerPage) - pagination.PerPage;\r\n\r\n                var leftArrowPageLink = { display: '<', link: this.getLink(this.startIndexKey + '=' + startIndex, this.queryStringParams, noreload, values[2]), arrow: true, prev: true }\r\n                pagination.PageLinks.push(leftArrowPageLink);\r\n            }\r\n            if (Object.keys(lnksList).length > 0) {\r\n                for (var k in lnksList) {\r\n                    // use hasOwnProperty to filter out keys from the Object.prototype\r\n                    if (lnksList.hasOwnProperty(k)) {\r\n                        var startIndex = ((pagination.CurrentPage - 1) * pagination.PerPage) - pagination.PerPage;\r\n                        if (lnksList[k] === '...') {\r\n                            var numbersLink = { display: lnksList[k], link: '#', noLink: true }\r\n                            pagination.PageLinks.push(numbersLink);\r\n                        }\r\n                        else if (parseInt(k) === pagination.CurrentPage) {\r\n                            var numbersLink = { display: lnksList[k], link: '', noLink: false }\r\n                            pagination.PageLinks.push(numbersLink);\r\n                        }\r\n                        else {\r\n                            var numbersLink = { display: lnksList[k], link: this.getLink(this.startIndexKey + '=' + (parseInt(k) - 1) * pagination.PerPage, this.queryStringParams, noreload, values[2]), noLink: false }\r\n                            pagination.PageLinks.push(numbersLink);\r\n                        }\r\n\r\n                    }\r\n                }\r\n\r\n            }\r\n            if (pagination.IsLastPage) {\r\n                var startIndex = pagination.CurrentPage * pagination.PerPage;\r\n                var rightArrowPageLink1 = { display: '>', link: '#', arrow: true, next: true, cssclass: 'disabled' };\r\n                pagination.PageLinks.push(rightArrowPageLink1);\r\n            }\r\n            else {\r\n                var startIndex = pagination.CurrentPage * pagination.PerPage;\r\n                var rightArrowPageLink = { display: '>', link: this.getLink(this.startIndexKey + '=' + startIndex, this.queryStringParams, noreload, values[2]), arrow: true, next: true }\r\n                pagination.PageLinks.push(rightArrowPageLink);\r\n            }\r\n  \r\n        }\r\n\r\n        var data = {\r\n            Pagination: pagination\r\n        }\r\n\r\n        $('.js-Pagination-List').html(values[1](data));\r\n\r\n        return values;\r\n    }\r\n\r\n    handleError(reason: string) {\r\n        $('#js-drawer-content').html(\"<h3>Failed To Load on page\" + reason + \"</h3>\");\r\n    }\r\n\r\n    public getLink(startIndexKeyValue: string, queryStringParams: string[], noreload: boolean, settings: any) {\r\n        var link = window.location.pathname + '?';\r\n        if (noreload !== null && noreload === true) {\r\n            link = '';\r\n        }\r\n        link = link + startIndexKeyValue;\r\n        if (queryStringParams.length > 0) {\r\n            var aq = MainHelper.getallQueryKeyValues();\r\n            $.each(queryStringParams, function (ind, elem) {\r\n                if (elem !== 'start1') {\r\n                    link = link + '&' + elem + '=' + aq[elem];\r\n                }\r\n            });\r\n\r\n        } else {\r\n\r\n            var filter = PaginationController.prototype.getValueFromQueryString('filter');\r\n            var key = PaginationController.prototype.getValueFromQueryString('k');\r\n            var searchType = PaginationController.prototype.getValueFromQueryString('t');\r\n            var sort = PaginationController.prototype.getValueFromQueryString('sort');\r\n\r\n            if (filter.length > 0) {\r\n                link = link + '&filter=' + filter;\r\n            }\r\n\r\n            if (key.length > 0) {\r\n                link = link + '&k=' + key;\r\n            }\r\n\r\n            if (searchType.length > 0) {\r\n                link = link + '&t=' + searchType;\r\n            }\r\n\r\n            if (sort.length > 0) {\r\n                link = link + '&sort=' + sort;\r\n            }\r\n\r\n            link += \"&max=\" + settings[\"ItemsPerPage\"];\r\n            if (settings[\"List\"] !== 'SearchResults' || settings[\"List\"] !== 'ProductInfoResults') {\r\n                link += \"&list=\" + settings[\"List\"];\r\n            }\r\n        }\r\n\r\n        return link;\r\n    }\r\n\r\n    public getLinkWithFilters(startIndex: any, filter: string, sort: string, list: string, max: string) {\r\n        var link = window.location.pathname;\r\n        link = link + '?start1=' + startIndex;\r\n        if (filter.length > 0) {\r\n            link = link + '&filter=' + filter;\r\n        }\r\n\r\n        if ($('#rowLimit').length === 1 && $('#rowLimit').val() != '' && link.toLowerCase().indexOf(\"rowlimit\") === -1) {\r\n            link += \"&rowlimit=\" + $('#rowLimit').val();\r\n        }\r\n\r\n        if (list === 'PressReleasesList') {\r\n            if ($('#datePickerStart') != undefined && $('#datePickerStart').val() != '') {\r\n                var startDate = $('#datePickerStart').val();\r\n                if ((startDate !== '' && (startDate.indexOf(\".\") || startDate.indexOf(\"/\")) > -1)) {\r\n                    link += '&startdate=' + startDate.trim();\r\n                }\r\n\r\n            }\r\n\r\n            if ($('#datePickerEnd') != undefined && $('#datePickerEnd').val() != '') {\r\n                var endDate = $('#datePickerEnd').val();\r\n                if ((endDate !== '' && (endDate.indexOf(\".\") || endDate.indexOf(\"/\")) > -1)) {\r\n                    link += '&enddate=' + endDate.trim();\r\n                }\r\n            }\r\n        }\r\n\r\n        if (sort !== undefined && sort.length > 0) {\r\n            link = link + '&sort=' + sort;\r\n        }\r\n\r\n        link += '&max=' + max;\r\n        link += '&list=' + list;\r\n        \r\n        return link;\r\n    }\r\n\r\n    public getCurentIndexFromQueryString() {\r\n        var value = MainHelper.getQueryString(this.startIndexKey);\r\n        if (value == null) {\r\n            return 0;\r\n        }\r\n\r\n        return parseInt(value);\r\n    }\r\n\r\n    public getValueFromQueryString(key: string) {\r\n        var value = MainHelper.getQueryString(key);\r\n        if (value == null) {\r\n            return '';\r\n        }\r\n\r\n        return value;\r\n    }\r\n}\r\n\r\n$(document).on('SPContextLoaded', function (e) {\r\n\r\n    // This is for testing only. This call should be made from the page after the list items are loaded. \r\n    //  var pc = new PaginationController(70); \r\n    //   pc.loadPagination();\r\n\r\n});"]}