[ 7 posts ]

he647

  • Joined: Wed Nov 28, 2012 12:26 am
  • Posts: 4
  • Offline
  • Profile

Cannot select text in Calendar textbox

Post Posted: Wed Nov 28, 2012 1:00 am
+0-
Hi everyone,

I am trying to append a textbox in each of the YUI3 calendar day using 'set custom renderer'. But here comes the problem: I cannot select the text in textbox, whether by using mouse click or shift key. Later I use purge() to remove all event listeners from the node, and that works in Firefox and Chrome, but not in IE.

Here is the code: http://jsfiddle.net/B6vy8/

So,
- Does anyone knows what is the problem here?
- What exact event prevent me of selecting text in the textbox?

Thanks.

Dante Netto

  • Username: dantenetto
  • Joined: Thu Oct 11, 2012 11:58 am
  • Posts: 12
  • Location: Brazil
  • GitHub: dantenetto
  • Gists: dantenetto
  • Offline
  • Profile

Re: Cannot select text in Calendar textbox

Post Posted: Wed Nov 28, 2012 5:12 am
+0-
The Y.Calendar adds in each "pane" a preventDefault() handler to the selectionstart event. I think this is just to avoid selecting the content while interacting with the calendar, to improve the user experience.

The easiest way to disable it is to extend the Y.Calendar and overwrite the method
_preventSelectionStart() with an empty function. Since it's protected, I don't see any problem in doing this.

However, the event wil still be attached. If you just do _preventSelectionStart: null, then the event will not be attached, but your Calendar will log an "invalid callback" error if you has the log enabled.

he647

  • Joined: Wed Nov 28, 2012 12:26 am
  • Posts: 4
  • Offline
  • Profile

Re: Cannot select text in Calendar textbox

Post Posted: Thu Nov 29, 2012 5:52 pm
+0-
Thank you Dante, that works for me.

And another question:

Why Y.one("#calendar").purge(true) does not work for pane.on("selectstart", this._preventSelectionStart), which in calendar/js/calendar.js line 85.
How can I only detach this event rather than extend the Y.Calendar and overwrite the method _preventSelectionStart().

Dante Netto

  • Username: dantenetto
  • Joined: Thu Oct 11, 2012 11:58 am
  • Posts: 12
  • Location: Brazil
  • GitHub: dantenetto
  • Gists: dantenetto
  • Offline
  • Profile

Re: Cannot select text in Calendar textbox

Post Posted: Fri Nov 30, 2012 4:19 pm
+0-
In your jsfiddle, you do the purge in '#calendar td', but the selectionstart is attached to the pane, which is in a higher hierarchy in the DOM.

maybe if you substitute the purge you did with:
calendar.get('contentBox').purge(true, 'selectionstart');

it might work.

Sorry, but I don't have IE to test it right now.

he647

  • Joined: Wed Nov 28, 2012 12:26 am
  • Posts: 4
  • Offline
  • Profile

Re: Cannot select text in Calendar textbox

Post Posted: Tue Dec 04, 2012 2:35 am
+0-
Sorry, I tried calendar.get('contentBox').purge(true, 'selectionstart'), but this is not working in Firefox and IE.

I also tried to put purge() in after render event, but still not working.

Please look at this: http://jsfiddle.net/B6vy8/2/

Anyway, I really appreciate your answer.

Dante Netto

  • Username: dantenetto
  • Joined: Thu Oct 11, 2012 11:58 am
  • Posts: 12
  • Location: Brazil
  • GitHub: dantenetto
  • Gists: dantenetto
  • Offline
  • Profile

Re: Cannot select text in Calendar textbox

Post Posted: Thu Dec 06, 2012 3:53 pm
+0-
In firefox, this happens because of the CSS rule:

.yui3-calendar-content:hover .yui3-calendar-day,
.yui3-calendar-content:hover .yui3-calendar-prevmonth-day,
.yui3-calendar-content:hover .yui3-calendar-nextmonth-day {
-moz-user-select: none;
}

which is in calendar-core.css

this will disable the selection for these matching elements.

you can overwrite it by setting its value to text

try setting this using all variations:
-webkit-touch-callout: text;
-webkit-user-select: text;
-khtml-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;

maybe it will work in IE, but I did not found anything in css files IE specific.
Sorry not being able to help on that.

he647

  • Joined: Wed Nov 28, 2012 12:26 am
  • Posts: 4
  • Offline
  • Profile

Re: Cannot select text in Calendar textbox

Post Posted: Sat Dec 08, 2012 1:27 am
+0-
CSS! I never thought about this. Thanks for your reminding.

About IE, I don't figure out the problem yet, so I just use the extended calendar in my code.

Thank you.
  [ 7 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum