| |||||||
| Top Tip : Click here to Boost Your PC & Chrome Browsing Speed |
![]() |
| | Thread Tools | Display Modes |
|
#21
| ||||
| ||||
| Quote:
__________________ ~ Projects ~ Specialized: Carapass Auction Watcher Libraries: bliplib Tools: manifest syntax highlighting & snippits |
|
#22
| ||||
| ||||
| TBH It's not a problem for me, it was my son who spotted it (I don't use FB myself)... ;-) Last edited by StevePaul; 07-12-2009 at 10:40 PM.. |
|
#23
| |||
| |||
| First off, I must say that this a great extension. I have a small fix that will re-enable the rightclick context menu if you are not performing a gesture, if do perform a gesture, it will not show up. I'm using the modified JS file from Waha, also I changed the default blank tab to open google, this way its a little more user friendly. I'm fairly new to frontend coding, I typically do backend php/sql work but I figured I would mess with this a little. Code:
/** READ THIS BEFORE EDITING **/
// Here you can create your own gestures. For the moment, how this works is that you create
// a Gesture and an Action.
//
// _____________
// _____/ Terminology |___________________________________________________________________________________________________________________________
// | |
// | Moves are either 'up', 'down', 'left' or 'right'. |
// | |
// | A Gesture is an array of Moves e.g.: myNewGesture = ["up","down","left"]. |
// | - You should never have a Gesture that has two identical consecutive moves. e.g.: ["left","right","right"] is not a valid Gesture. |
// | |
// | An Action is a function that takes no parameters and has no return value. e.g.: myNewAction = function(){ alert("OMG!") } |
// | |
// | You can then configure ChromeGesture by modifying the myGestures array. |
// | myGestures is an array where the index is your Gesture and the data is your Action. e.g.: myGestures[myNewGesture] = myNewAction; |
// | - Do not use the same Gesture for two Actions. |
// | |
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//
// In case of doubt, drop by the forums on chromeplugins.org and ask. We'll answer ;)
// ============ BEGIN STUFF YOU CAN (AND SHOULD) EDIT ============
var newTabGesture = ["down","right"];
var closeTabGesture = ["down","left"];
var historyBackGesture = ["left"];
var historyForwardGesture = ["right"];
var hidePageGesture = ["click","click"];
// TODO: Support for Chrome API
function newTabAction() {
window.open("http://google.com/",null);
}
function closeTabAction() {
window.close();
}
function historyBackAction() {
history.back();
}
function historyForwardAction() {
history.forward();
}
var ishiding = false;
var page = "",backgroundimage="";
function hidePageAction() {
if(ishiding){
document.body.innerHTML = page;
document.body.style.backgroundImage = backgroundimage;
ishiding = false;
} else {
page = document.body.innerHTML;
document.body.innerHTML = "";
backgroundimage = document.body.style.backgroundImage;
document.body.style.backgroundImage = "none";
ishiding = true;
console.log("Hiding?");
}
}
var myGestures = [];
myGestures[newTabGesture] = newTabAction;
myGestures[closeTabGesture] = closeTabAction;
myGestures[historyBackGesture] = historyBackAction;
myGestures[historyForwardGesture] = historyForwardAction;
myGestures[hidePageGesture] = hidePageAction;
// ============ UNLESS YOU KNOW WHAT YOU ARE DOING, DON'T EDIT PAST HERE :) ============
// CONSTANTS
var ChromeGesture = {
// If you think the Gesture detection sensitity too low, make these higher.
MINIMUM_DELTAY : 10, // tweak this - Minimum Y distance that needs to be travelled between 2 captures for a move to be detected
MINIMUM_DELTAX : 10, // tweak this - Same for X
DELAY_BETWEEN_CAPTURES : 10, // tweak this - Time between captures
LEFT_CLICK : 1, // Number associated with Left Click
RIGHT_CLICK : 3, // Number associated with Right Click
// Global variables
pastX : 0,
pastY : 0,
currentGesture : [],
pastTime : new Date(),
// Functions
captureGesture : function(event) {
var currentTime = new Date();
var diff = currentTime.getTime() - ChromeGesture.pastTime.getTime();
var currentX = event.clientX;
var currentY = event.clientY;
ChromeGesture.printLine(currentX, currentY);
if( diff < ChromeGesture.DELAY_BETWEEN_CAPTURES ){
return;
} else {
console.debug("Capture!");
var deltaX = currentX - ChromeGesture.pastX;
var deltaY = currentY - ChromeGesture.pastY;
console.log("Movement vector : (" + deltaX + ", " + deltaY + ")");
ChromeGesture.pastX = currentX;
ChromeGesture.pastY = currentY;
var move = ChromeGesture.determineMove(deltaX, deltaY);
if( move != null ){
if( move != ChromeGesture.currentGesture[ChromeGesture.currentGesture.length - 1]){
ChromeGesture.currentGesture.push(move);
}
}
console.warn("Moves : [" + ChromeGesture.currentGesture +"]");
ChromeGesture.pastTime = currentTime;
}
},
determineMove : function(deltaX, deltaY) {
var absDeltaX = Math.abs(deltaX);
var absDeltaY = Math.abs(deltaY);
if( absDeltaX < ChromeGesture.MINIMUM_DELTAX && absDeltaY < ChromeGesture.MINIMUM_DELTAY ) {
return null;
}
else {
document.oncontextmenu = function(){return false;} // Gesture detected, hide the context menu
}
if( absDeltaY > absDeltaX ) {
if( deltaY < 0 ){
return "up"
} else {
return "down"
}
} else {
if( deltaX > 0 ){
return "right"
} else {
return "left"
}
}
},
mouseButtonDown : function(event) {
console.log("Mouse button down : " + event.which);
if (event.which == ChromeGesture.RIGHT_CLICK){
//TODO: Don't stop propagation if time between mouseup / mousedown is < CONSTANT
document.oncontextmenu = function(){return true;} // Right-click detected, enable the context menu
ChromeGesture.pastX = event.clientX;
ChromeGesture.pastY = event.clientY;
window.addEventListener("mousemove", ChromeGesture.captureGesture);
}
},
mouseButtonUp : function(event) {
console.log("Mouse button up : " + event.which);
if(event.which == ChromeGesture.RIGHT_CLICK){
event.preventDefault();
event.stopPropagation();
console.log("Removing event listener");
window.removeEventListener("mousemove", ChromeGesture.captureGesture);
if(myGestures[ChromeGesture.currentGesture]){
// TODO: Support passing of parameters based on the origin of the gesture and such.
myGestures[ChromeGesture.currentGesture]();
}
ChromeGesture.currentGesture = [];
} else if (event.which == ChromeGesture.LEFT_CLICK){
ChromeGesture.currentGesture.push("click");
}
},
printLine : function() {
// TODO: Print stuff next to cursor, track cursor position, append a div with text in document.
}
}
// Initialization
window.addEventListener("mousedown", ChromeGesture.mouseButtonDown, false);
window.addEventListener("mouseup", ChromeGesture.mouseButtonUp, false); Last edited by Kryptyx; 07-13-2009 at 08:46 PM.. |
|
#24
| ||||
| ||||
| Cool, thanks. :] Maybe I'll keep it installed now. lol
__________________ ~ Projects ~ Specialized: Carapass Auction Watcher Libraries: bliplib Tools: manifest syntax highlighting & snippits |
|
#25
| ||||
| ||||
| @Kryptyx Great additions to Kyrax's original (and Waha's amendment) ... I took it a step further and changed the NewTab to show a page of my choice instead of the Google page you had put in (wasn't sure about the ,null at the end so left it in, it seems to work OK)... Works a treat ;-) Not missing CNT so much now ;-D |
|
#26
| |||
| |||
| lol yeah same issue I had, I loved the concept and I think it was really well done but I still needed the context menu for obvious reasons. |
|
#27
| ||||
| ||||
| @Kryptx Just as a matter of interest what does the null parameter do ... |
|
#28
| ||||
| ||||
| That argument is for where the window should load, leaving it null makes it open in a new window in the default position, which I believe is "_blank".
__________________ ~ Projects ~ Specialized: Carapass Auction Watcher Libraries: bliplib Tools: manifest syntax highlighting & snippits |
|
#29
| ||||
| ||||
| Thanks for that Waha ... @Kyrax As your the author of this extension could you repackage it with the amended JS (additions by Waha & Kryptyx) ... The reason I ask is that I frequent the official Chrome Help forum and one of the questions that is still being constantly asked is about the NEWTab page and either customising it or making it blank ... Previously I have always recommended CNT, but as that isn't working currently this extension (with its new bits) is ideal to replace it.... Just one thing I would ask is you put a note in the JS showing where to put your page of choice (rather than Google) ... If I remember rightly didn't you do that in the original version of CNT ... I think this is a really good extension and worthy of 'Flagshipping' this forum and the excellent work being done by all our 'developers' ... |
|
#30
| |||
| |||
| I was thinking of re-releasing this project to maintain a stable development build. Ofcourse cediting the original author and waha for their work. I believe the author stated that he did not have time to maintain this addon...that is why I mentioned doing it. I have started to look at mouse trail abilities to fill in the authors "todo"s. Any suggestions? Also about the null... its not needed really I have some tweaked version that iu will release soon. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Chrome Officially Out of Beta | Chrome | Chrome Talk | 1 | 12-16-2008 04:39 PM |
| Chrome To Come Out Of Beta | Chrome | Chrome Talk | 0 | 12-10-2008 11:38 AM |