Code Monkey home page Code Monkey logo

Comments (29)

chieffancypants avatar chieffancypants commented on June 24, 2024

I figured this question would come up, but I simply don't have any experience with the UI Router, nor am I using it in production, so it would be tough for me to support it. I'm happy to review/accept PRs from someone with more experience in it.

from angular-hotkeys.

joshbowdoin avatar joshbowdoin commented on June 24, 2024

I believe this pull request (partially) satisfies the request: #9

from angular-hotkeys.

willhoag avatar willhoag commented on June 24, 2024

+1

from angular-hotkeys.

julianpaulozzi avatar julianpaulozzi commented on June 24, 2024

+1

from angular-hotkeys.

jeffwhelpley avatar jeffwhelpley commented on June 24, 2024

+2

from angular-hotkeys.

cesarhdz avatar cesarhdz commented on June 24, 2024

+1

from angular-hotkeys.

madhat2r avatar madhat2r commented on June 24, 2024

+1

Excerpts from César Hernández's message of 2014-06-06 13:54:28 -0500:

+1


Reply to this email directly or view it on GitHub:
#5 (comment)

from angular-hotkeys.

gschuager avatar gschuager commented on June 24, 2024

+1

from angular-hotkeys.

Birowsky avatar Birowsky commented on June 24, 2024

+me and couple of friends

from angular-hotkeys.

reyx avatar reyx commented on June 24, 2024

+1

from angular-hotkeys.

towu avatar towu commented on June 24, 2024

+1

from angular-hotkeys.

apitts avatar apitts commented on June 24, 2024

+1

from angular-hotkeys.

bonatoc avatar bonatoc commented on June 24, 2024

Hello,

Most of you probably already figured this out, but just in case you need to go from a detail page to the next/previous one. This is based on ui-router's official sample (http://angular-ui.github.io/ui-router/sample/#/), and "contacts.detail" has been replaced with "pages.detail" (http://angular-ui.github.io/ui-router/sample/states.js). Anyway, this is what I have in my "pages.detail" controller :

                           // SEE contacts.detail IN UI-ROUTER EXAMPLE
      .state('pages.detail', {
        url: '/{pageID:[0-9]{1,4}}',
        views: {
          '': {
            templateUrl: 'pages.detail.html',
            controller: ['$scope', '$stateParams',
              function page_detail_function (  $scope,   $stateParams) {
                // $scope.contact = utils.findById($scope.contacts, $stateParams.contactId);
                $scope.pageID = $stateParams.pageID;
                $rootScope.pageID = $scope.pageID;
              }]
          },
           // ....

            // ID OF PAGE CALLED
            $scope.pageID = $stateParams.pageID; // ui-router
             pageID = $scope.pageID;
            pageIDasInt = intval(pageID);

                             // ...


            // CALCULATE PREV AND NEXT PAGES IDS
            function getPrevNextPages(pageID)
            {                   
                // mainarrayData.OrdersArray.Products : THE JSON OBJECT I USE FOR DETAIL PAGES (originally contacts.json), REPLACE WITH YOURS
                                    pagesArray = Object.keys(mainarrayData.OrdersArray.Products); 

                $.each(pagesArray, function(key, value) {
                            if(value === pageID)
                            {
                                currentKey = key;
                            }
                        });
                previousPageID = pagesArray[currentKey - 1];
                nextPageID = pagesArray[currentKey + 1];

                arrayOfResults['previousPageID'] = previousPageID;
                arrayOfResults['nextPageID'] = nextPageID;

                return(arrayOfResults);
            }
            // -------- EOF - CALCULATE PREV AND NEXT PAGES IDS



            arrayOfResults = [];
            arrayOfResults = getPrevNextPages(pageID);
            previousPageID = arrayOfResults['previousPageID'];
            nextPageID = arrayOfResults['nextPageID'];



            firstPage = pagesArray[0];
            console.log('---> firstPage : ');
            console.log(firstPage);

            lastPage = (pagesArray.length)-1;
            console.log('---> lastPage : ');
            console.log(lastPage);


            // INFINITE LOOP - IF LAST OR NEXT UNDEFINED, SET LAST TO FIRST, AND FIRST TO LAST
            if (typeof(previousPageID) == "undefined") {
                console.log('---> previousPageID IS UNDEFINED : ');
                previousPageID = lastPage;
                // DEBUGGING previousPageID
                console.log('---> previousPageID NOW IS : ');
                console.log(previousPageID);

            };
            if (typeof(nextPageID) == "undefined") {
                console.log('---> nextPageID IS UNDEFINED : ');
                nextPageID = firstPage;
                // DEBUGGING nextPageID
                console.log('---> nextPageID NOW IS : ');
                console.log(nextPageID);
            };
            // -------- EOF - INFINITE LOOP - IF LAST OR NEXT UNDEFINED, SET LAST TO FIRST, AND FIRST TO LAST


            $rootScope.previousPageID = previousPageID || '';
            $rootScope.nextPageID = nextPageID || '';   
            $rootScope.typeOfPreviousPageID = typeof(previousPageID) || '';
            $rootScope.typeOfNextPageID = typeof(nextPageID) || '';

            $rootScope.pagesArray = pagesArray;


            // ANGULAR HOTKEYS SETTINGS FOR GOING TO NEXT PAGE / PREV PAGE THROUGH KEYBOARD
            hotkeys.add({
                combo: 'right',
                description: 'Next page',
                callback: function() {
                  $state.go("pages.detail",{pageID:nextPageID});
                }
              });

            hotkeys.add({
                combo: 'left',
                description: 'Previous page',
                callback: function() {
                  $state.go("pages.detail",{pageID:previousPageID});
                }
              });
            // -------- EOF - ANGULAR HOTKEYS SETTINGS FOR GOING TO NEXT PAGE / PREV PAGE THROUGH KEYBOARD

from angular-hotkeys.

rmariuzzo avatar rmariuzzo commented on June 24, 2024

@chieffancypants what needs to be done to merge the PR? May I help?

from angular-hotkeys.

chieffancypants avatar chieffancypants commented on June 24, 2024

@rmariuzzo Do you mean #9? It was incomplete. I merged the code into a branch so others could help and participate but it's still in a pretty broken state. Essentially, all the current tests should also pass when using ui-router, so any help you can provide would be amazing!

from angular-hotkeys.

rmariuzzo avatar rmariuzzo commented on June 24, 2024

@chieffancypants, good! I will check it out to collaborate and add that feature. I will also make sure all test passes.

from angular-hotkeys.

aneuhauser avatar aneuhauser commented on June 24, 2024

+1

from angular-hotkeys.

jmls avatar jmls commented on June 24, 2024

@rmariuzzo were you able to get angular-ui working ?

from angular-hotkeys.

Evanion avatar Evanion commented on June 24, 2024

Any update on this?

from angular-hotkeys.

rmariuzzo avatar rmariuzzo commented on June 24, 2024

@jmls unfortunately I didn't have enough time… by that time. :/

from angular-hotkeys.

jondthompson avatar jondthompson commented on June 24, 2024

+1

from angular-hotkeys.

jmelosegui avatar jmelosegui commented on June 24, 2024

+1

from angular-hotkeys.

niemyjski avatar niemyjski commented on June 24, 2024

+1

from angular-hotkeys.

AshMcConnell avatar AshMcConnell commented on June 24, 2024

+1

from angular-hotkeys.

andrewmcconville avatar andrewmcconville commented on June 24, 2024

+1

from angular-hotkeys.

tejasrivastav avatar tejasrivastav commented on June 24, 2024

+1

from angular-hotkeys.

vaibhav-jain avatar vaibhav-jain commented on June 24, 2024

Any update ??

from angular-hotkeys.

lwthatcher avatar lwthatcher commented on June 24, 2024

+1

from angular-hotkeys.

fjakop avatar fjakop commented on June 24, 2024

+1

from angular-hotkeys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.