Permalink
Browse files

Now snaps to elements that should be removed. Also bug fixes.

  • Loading branch information...
cantino committed Mar 6, 2009
1 parent 476be76 commit 94096ca904a7d8ec3ac017c0accff585849b19e8
Showing with 2,726 additions and 7 deletions.
  1. +9 −7 lib/interface.js
  2. +2,717 −0 sites/wunderground/paris.html
View
@@ -138,9 +138,9 @@ SelectorGadget.prototype.sgMouseover = function(e) {
if (gadget.unbound) return true;
if (this == document.body || this == document.body.parentNode) return false;
var self = jQuery(this);
- if (gadget.special_mode == 'd') { // Jump to any the first selected parent of this node.
+ if (gadget.special_mode != 'd') { // Jump to any the first selected parent of this node.
var parent = gadget.firstSelectedOrSuggestedParent(this);
- if (parent != this)
+ if (parent != null && parent != this)
gadget.makeBorders(parent, true);
else
gadget.makeBorders(this);
@@ -156,9 +156,10 @@ SelectorGadget.prototype.firstSelectedOrSuggestedParent = function(elem) {
var orig = elem;
if (jQuery(elem).hasClass('sg_suggested') || jQuery(elem).hasClass('sg_selected')) return elem
while (elem.parentNode && (elem = elem.parentNode)) {
- if (jQuery(elem).hasClass('sg_suggested') || jQuery(elem).hasClass('sg_selected')) return elem
+ if (jQuery.inArray(elem, this.restricted_elements) == -1)
+ if (jQuery(elem).hasClass('sg_suggested') || jQuery(elem).hasClass('sg_selected')) return elem
}
- return orig;
+ return null;
};
SelectorGadget.prototype.sgMouseout = function(e) {
@@ -182,10 +183,11 @@ SelectorGadget.prototype.sgMousedown = function(e) {
if (elem == document.body || elem == document.body.parentNode) return;
- if (gadget.special_mode == 'd') {
+ if (gadget.special_mode != 'd') {
var potential_elem = gadget.firstSelectedOrSuggestedParent(elem);
- if (potential_elem != elem) {
+ if (potential_elem != null && potential_elem != elem) {
elem = potential_elem;
+ w_elem = jQuery(elem);
}
} else {
if (jQuery('.sg_selected', this).get(0)) gadget.blockClicksOn(elem); // Don't allow selection of elements that have a selected child.
@@ -334,7 +336,7 @@ SelectorGadget.prototype.clearSuggested = function() {
};
SelectorGadget.prototype.showHelp = function() {
- alert("(Better help coming soon! Please visit http://selectorgadget.com!)\n\nClick on a page element that you would like your selector to match (it will turn green). SelectorGadget will then generate a minimal CSS selector for that element, and will highlight (yellow) everything that is matched by the selector. Now click on a highlighted element to remove it from the selector (red), or click on an unhighlighted element to add it to the selector. Through this process of selection and rejection, SelectorGadget helps you to come up with the perfect CSS selector for your needs.\n\nHolding 'shift' while moving the mouse will snap to already selected elements.");
+ alert("(Better help coming soon! Please visit http://selectorgadget.com!)\n\nClick on a page element that you would like your selector to match (it will turn green). SelectorGadget will then generate a minimal CSS selector for that element, and will highlight (yellow) everything that is matched by the selector. Now click on a highlighted element to remove it from the selector (red), or click on an unhighlighted element to add it to the selector. Through this process of selection and rejection, SelectorGadget helps you to come up with the perfect CSS selector for your needs.\n\nHolding 'shift' while moving the mouse will let you select elements inside of rejected ones.");
};
SelectorGadget.prototype.makeInterface = function() {
Oops, something went wrong.

0 comments on commit 94096ca

Please sign in to comment.