Comments (29)
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.
I believe this pull request (partially) satisfies the request: #9
from angular-hotkeys.
+1
from angular-hotkeys.
+1
from angular-hotkeys.
+2
from angular-hotkeys.
+1
from angular-hotkeys.
+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.
+1
from angular-hotkeys.
+me and couple of friends
from angular-hotkeys.
+1
from angular-hotkeys.
+1
from angular-hotkeys.
+1
from angular-hotkeys.
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.
@chieffancypants what needs to be done to merge the PR? May I help?
from angular-hotkeys.
@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.
@chieffancypants, good! I will check it out to collaborate and add that feature. I will also make sure all test passes.
from angular-hotkeys.
+1
from angular-hotkeys.
@rmariuzzo were you able to get angular-ui working ?
from angular-hotkeys.
Any update on this?
from angular-hotkeys.
@jmls unfortunately I didn't have enough time… by that time. :/
from angular-hotkeys.
+1
from angular-hotkeys.
+1
from angular-hotkeys.
+1
from angular-hotkeys.
+1
from angular-hotkeys.
+1
from angular-hotkeys.
+1
from angular-hotkeys.
Any update ??
from angular-hotkeys.
+1
from angular-hotkeys.
+1
from angular-hotkeys.
Related Issues (20)
- Translation of keys
- Programmatically open hotkeys dialog HOT 2
- Hotkey does not fire when changing routes in ngRoute HOT 1
- Can we trigger the Hotkey for particular element., HOT 1
- Improve Documentation of directive-based hotkeys HOT 1
- cheatsheet not displayed HOT 2
- Wildcard combo?
- Hotkey using only slash does not apper on the cheatsheet HOT 1
- hotkey with ctrl+alt++ is not working HOT 1
- Delete all binded hotkey HOT 1
- Compatibility AZERTY
- hotkey with mod+w closes the browser tab HOT 1
- In callback function array is not visible from scope HOT 3
- new hotkey not adding
- Is this a AMD module?
- Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context when configuring templateHeader
- iframe binding issue HOT 3
- Change the cheatsheet Shift icon (up arrow) to the word SHIFT. HOT 1
- How to test ESC press in angualr unit test? HOT 2
- Hotkeys are not working on text input focus HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-hotkeys.