Fix Issue 10: Remove need for right-click and just use shift-click for palette (works on all browsers)

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@135 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2009-06-17 02:17:22 +00:00
parent 66b15f760f
commit 8ce1b3fea7
3 changed files with 5 additions and 132 deletions

View File

@ -1,116 +0,0 @@
// jQuery Right-Click Plugin
//
// Version 1.01
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 20 December 2008
//
// Visit http://abeautifulsite.net/notebook/68 for more information
//
// Usage:
//
// // Capture right click
// $("#selector").rightClick( function(e) {
// // Do something
// });
//
// // Capture right mouse down
// $("#selector").rightMouseDown( function(e) {
// // Do something
// });
//
// // Capture right mouseup
// $("#selector").rightMouseUp( function(e) {
// // Do something
// });
//
// // Disable context menu on an element
// $("#selector").noContext();
//
// History:
//
// 1.01 - Updated (20 December 2008)
// - References to 'this' now work the same way as other jQuery plugins, thus
// the el parameter has been deprecated. Use this or $(this) instead
// - The mouse event is now passed to the callback function
// - Changed license to GNU GPL
//
// 1.00 - Released (13 May 2008)
//
// License:
//
// This plugin is dual-licensed under the GNU General Public License and the MIT License
// and is copyright 2008 A Beautiful Site, LLC.
//
if(jQuery) (function(){
$.extend($.fn, {
rightClick: function(handler) {
$(this).each( function() {
$(this).mousedown( function(e) {
var evt = e;
$(this).mouseup( function() {
$(this).unbind('mouseup');
if( evt.button == 2 ) {
handler.call( $(this), evt );
return false;
} else {
return true;
}
});
});
$(this)[0].oncontextmenu = function() {
return false;
}
});
return $(this);
},
rightMouseDown: function(handler) {
$(this).each( function() {
$(this).mousedown( function(e) {
if( e.button == 2 ) {
handler.call( $(this), e );
return false;
} else {
return true;
}
});
$(this)[0].oncontextmenu = function() {
return false;
}
});
return $(this);
},
rightMouseUp: function(handler) {
$(this).each( function() {
$(this).mouseup( function(e) {
if( e.button == 2 ) {
handler.call( $(this), e );
return false;
} else {
return true;
}
});
$(this)[0].oncontextmenu = function() {
return false;
}
});
return $(this);
},
noContext: function() {
$(this).each( function() {
$(this)[0].oncontextmenu = function() {
return false;
}
});
return $(this);
}
});
})(jQuery);

View File

@ -5,7 +5,6 @@
<link rel="stylesheet" href="svg-editor.css" type="text/css"/> <link rel="stylesheet" href="svg-editor.css" type="text/css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript" src="js-hotkeys/jquery.hotkeys.min.js"></script> <script type="text/javascript" src="js-hotkeys/jquery.hotkeys.min.js"></script>
<script type="text/javascript" src="jquery.rightClick.js"></script>
<script type="text/javascript" src="jpicker/jpicker.js"></script> <script type="text/javascript" src="jpicker/jpicker.js"></script>
<script type="text/javascript" src="svgcanvas.js"></script> <script type="text/javascript" src="svgcanvas.js"></script>
<script type="text/javascript" src="svg-editor.js"></script> <script type="text/javascript" src="svg-editor.js"></script>
@ -179,7 +178,7 @@
</div> </div>
<div id="palette_holder"> <div id="palette_holder">
<div id="palette" title="Left-click to change fill color, right-click to change stroke color"> <div id="palette" title="Click to change fill color, shift-click to change stroke color">
</div> </div>
</div> </div>

View File

@ -154,28 +154,18 @@ function svg_edit_setup() {
svgCanvas.setRectRadius(this.options[this.selectedIndex].value); svgCanvas.setRectRadius(this.options[this.selectedIndex].value);
}); });
$('.palette_item').click(function(){ $('.palette_item').click(function(evt){
var id = (evt.shiftKey ? '#stroke_color' : '#fill_color');
color = $(this).css('background-color'); color = $(this).css('background-color');
if (color == 'transparent') { if (color == 'transparent') {
color = 'none'; color = 'none';
$('#fill_color').css('background', 'url(\'images/none.png\')'); $(id).css('background', 'url(\'images/none.png\')');
} else { } else {
$('#fill_color').css('background', color); $(id).css('background', color);
} }
svgCanvas.setFillColor(color); svgCanvas.setFillColor(color);
}); });
$('.palette_item').rightClick(function(){
color = $(this).css('background-color');
if (color == 'transparent') {
color = 'none';
$('#stroke_color').css('background', 'url(\'images/none.png\')');
} else {
$('#stroke_color').css('background', color);
}
svgCanvas.setStrokeColor(color);
});
// This is a common function used when a tool has been clicked (chosen) // This is a common function used when a tool has been clicked (chosen)
// It does several common things: // It does several common things:
// - hides any flyout menus // - hides any flyout menus