Skip to content

Loading…

Add live check for Picker open status #103

Closed
wants to merge 1 commit into from

2 participants

@caedes

No description provided.

@arian
Owner

The opened state should be consistent and correct.

@arian arian closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 6, 2012
  1. Add live check for Picker open status

    Romain committed
Showing with 9 additions and 7 deletions.
  1. +2 −2 Source/Picker.Attach.js
  2. +7 −5 Source/Picker.js
View
4 Source/Picker.Attach.js
@@ -73,7 +73,7 @@ Picker.Attach = new Class({
var getOpenEvent = function(element){
return function(event){
var tag = event.target.get('tag');
- if (tag == 'input' && event.type == 'click' && !element.match(':focus') || (self.opened && self.input == element)) return;
+ if (tag == 'input' && event.type == 'click' && !element.match(':focus') || (self.opened() && self.input == element)) return;
if (tag == 'a') event.stop();
self.position(element);
self.open();
@@ -83,7 +83,7 @@ Picker.Attach = new Class({
var getToggleEvent = function(open, close){
return function(event){
- if (self.opened) close(event);
+ if (self.opened()) close(event);
else open(event);
};
};
View
12 Source/Picker.js
@@ -125,9 +125,12 @@ var Picker = new Class({
}
},
+ opened: function(){
+ return this.picker.getStyle('display') == 'block' && this.picker.getStyle('opacity') == 1
+ },
+
open: function(noFx){
- if (this.opened == true) return this;
- this.opened = true;
+ if (this.opened()) return this;
var self = this,
picker = this.picker.setStyle('display', 'block').set('aria-hidden', 'false')
if (this.shim) this.shim.show();
@@ -149,8 +152,7 @@ var Picker = new Class({
},
close: function(noFx){
- if (this.opened == false) return this;
- this.opened = false;
+ if (!this.opened()) return this;
this.fireEvent('close');
var self = this, picker = this.picker, hide = function(){
picker.setStyle('display', 'none').set('aria-hidden', 'true');
@@ -171,7 +173,7 @@ var Picker = new Class({
},
toggle: function(){
- return this[this.opened == true ? 'close' : 'open']();
+ return this[this.opened() ? 'close' : 'open']();
},
destroy: function(){
Something went wrong with that request. Please try again.