[jQuery] Re: remove() deletes events in jQuery 1.2.1. Why?

2007-11-07 Thread Felix Geisendörfer

Hey,


http://brandonaaron.net/docs/livequery/

 

Destroying events connected to a removed element helps prevent memory 
leaks -- it is really the correct behavior.
Well in most cases it probably is. However I actually got my own little 
framework used by all plugins I wrote, which attaches events to 
elements, and cleans them up when I destroy them . However, in this 
particularly case I was just temporarily removing an a from the DOM 
while replacing it with an input element for editing. I've changed it 
to use show() / hide() for now as it doesn't really make much of a 
difference, I was just interested in why I had to do it.


I don't use livequery b/c I don't want to deal with the performance hit. 
My solution is fairly similar in terms of defining hash table of 
selectors to apply whenever an element is generated, but its tied into 
my internal event system and knows about its scope so its not trying to 
bind stuff whenever some dom manipulation method is run.


Anyway thanks alot for the explanations!!
-- Felix
--
Blogger: http://www.thinkingphp.org/
Entrepreneur: http://www.posttask.com/ /-- currently in private beta, 
ask me for invite / password/

Freelancer: http://www.fg-webdesign.de/

AIM:theundefined87
Skype:  TimeFor23
Other IM:   felixge.de http://felixge.de/
Mobile (USA):   +1 404 3888693
Mobile (GER):   +49 162 9391612
Twitter:http://twitter.com/felixge




Jeffrey Kretz wrote:


If you haven't seen the livequery plugin, I would recommend looking it 
over -- this would really be the correct solution to this.


 


http://brandonaaron.net/docs/livequery/

 

Destroying events connected to a removed element helps prevent memory 
leaks -- it is really the correct behavior.


 


JK

 




*From:* jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] 
*On Behalf Of *Felix Geisendörfer

*Sent:* Tuesday, November 06, 2007 1:46 PM
*To:* jquery-en@googlegroups.com
*Subject:* [jQuery] remove() deletes events in jQuery 1.2.1. Why?

 


Hey,

I recently upgraded my app from jQuery 1.3.1 to 1.2.1 and the 
transition was incredibly easy.


However, yesterday I noticed that $().remove() now seems to behave 
differently then it did in 1.3.1. Thats because now it deletes any 
events attached to the element removed. This happens to be a problem 
in my app b/c I remove unneeded elements from the DOM instead of 
hiding them and inject them back in later on. So when they are 
injected again, they suddenly don't work anymore : ).


Now I looked through the manual and it says this is going to be the 
expected behavior in 1.2.2:


http://docs.jquery.com/Manipulation/remove

Which confuses me b/c it already seems to be the case in 1.2.1 and I'm 
also wondering how I could remove DOM elements without deleting their 
events in future? I'm also curious about why this change is being 
made, is it some anti-memory leak thingy?


Thanks a lot,
-- Felix
--
Blogger: http://www.thinkingphp.org/
Entrepreneur: http://www.posttask.com/ //-- currently in private beta, 
ask me for invite / password//

Freelancer: http://www.fg-webdesign.de/

*AIM:*



theundefined87

*Skype:*



TimeFor23

*Other IM:*



felixge.de http://felixge.de/

*Mobile** (USA):*



+1 404 3888693

*Mobile** (GER):*



+49 162 9391612

*Twitter:*



http://twitter.com/felixge

 



[jQuery] remove() deletes events in jQuery 1.2.1. Why?

2007-11-06 Thread Felix Geisendörfer

Hey,

I recently upgraded my app from jQuery 1.3.1 to 1.2.1 and the transition 
was incredibly easy.


However, yesterday I noticed that $().remove() now seems to behave 
differently then it did in 1.3.1. Thats because now it deletes any 
events attached to the element removed. This happens to be a problem in 
my app b/c I remove unneeded elements from the DOM instead of hiding 
them and inject them back in later on. So when they are injected again, 
they suddenly don't work anymore : ).


Now I looked through the manual and it says this is going to be the 
expected behavior in 1.2.2:


http://docs.jquery.com/Manipulation/remove

Which confuses me b/c it already seems to be the case in 1.2.1 and I'm 
also wondering how I could remove DOM elements without deleting their 
events in future? I'm also curious about why this change is being made, 
is it some anti-memory leak thingy?


Thanks a lot,
-- Felix
--
Blogger: http://www.thinkingphp.org/
Entrepreneur: http://www.posttask.com/ /-- currently in private beta, 
ask me for invite / password/

Freelancer: http://www.fg-webdesign.de/

AIM:theundefined87
Skype:  TimeFor23
Other IM:   felixge.de http://felixge.de/
Mobile (USA):   +1 404 3888693
Mobile (GER):   +49 162 9391612
Twitter:http://twitter.com/felixge



[jQuery] Re: SITE: http://www.foodnetwork.com/

2007-11-06 Thread Felix Geisendörfer

Hey,

We're taking over people...we'll soon be reaching critical mass where
businesses will be LOOKING for people who know jQuery!
Are you kidding me? This has long happened! I've seen a ton of job / gig 
advertisements asking for jQuery expertise in the past : ). But yeah, 
eventually people will be like Moo...jo...proto...what : )? (Dojo might 
be an exception actually, I can see reasons people would want to use dojo).


-- Felix
--
Blogger: http://www.thinkingphp.org/
Entrepreneur: http://www.posttask.com/ /-- currently in private beta, 
ask me for invite / password/

Freelancer: http://www.fg-webdesign.de/

AIM:theundefined87
Skype:  TimeFor23
Other IM:   felixge.de http://felixge.de/
Mobile (USA):   +1 404 3888693
Mobile (GER):   +49 162 9391612
Twitter:http://twitter.com/felixge



Andy Matthews wrote:

Don't know if this has already been posted or not, but it appears that
FoodTV giant FoodNetwork.com is using jQuery (1.1.4):

http://www.foodnetwork.com/

We're taking over people...we'll soon be reaching critical mass where
businesses will be LOOKING for people who know jQuery!

hip hip hooray.


andy


  


[jQuery] Faster then innerHTML

2007-09-12 Thread Felix Geisendörfer

Here is an interesting blog post that I came across:

http://blog.stevenlevithan.com/archives/faster-than-innerhtml

The synopsis basically is that one can gain dramatic speed improvements 
on setting innerHTML when removing items that are going to be 
overwritten using DOM methods before inserting stuff via innerHTML.


I could see how this would be a need addition to jQuery.

-- Felix
PS: If you like regex make sure to subscribe to this guys blog, he has 
some mad skills going on.

--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


[jQuery] Re: New plugin - Lazy Load

2007-09-03 Thread Felix Geisendörfer
Very cool! That's a great idea to save traffic and optimize load times 
on image heavy pages.


-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Mika Tuupola wrote:


Little something I worked on sunday.

http://www.appelsiini.net/projects/lazyload

Plugin which enables deferred loading (lazy loading) of images. In 
other words, images which are below the fold (far down the page not 
visible in browser) are not loaded before user scrolls down. This 
plugin should be useful with long pages which have lot of photo 
content. For example photoblogs.


Demo pages is available. You might want to use Firebug or liveHTTP 
headers to better see what is happening.


http://www.appelsiini.net/projects/lazyload/enabled.html



[jQuery] Re: Instant Messaging Capabilities

2007-09-02 Thread Felix Geisendörfer


Um, that's not really a donation then, is it?

--John
  
This probably needs a new / better term. I read a while ago about some 
independent musician making more money then he/she'd make on iTunes by 
letting the people decide how much they pay for it. Theoretically you 
could 'donate' $0.01. The idea is that the buyer shows that he 
values whatever he is interested in and is willing to make whatever 
big (commercial) effort to honor it.


I'd be interested in what you guys can come up with in terms of a new 
label / term for it? Donation is pretty misleading I'd think.


-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


John Resig wrote:

The home of yShout is at http://yurivish.com/yshout/ Yuri only requires a
small donation and he will send you the link to a zip file.



Um, that's not really a donation then, is it?

--John

  


[jQuery] Re: Looking for a calendar picker that allows for two instances on one page

2007-08-30 Thread Felix Geisendörfer




I saw that, but I want to
actually display the calendar itself, not just on popup, but fully
displayed.
AFAIK kevin's plugin is capable to do this. See: http://kelvinluck.com/assets/jquery/datePicker/v2/demo/renderCalendar.html

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de



Andy Matthews wrote:

  
  
  I saw that, but I want to
actually display the calendar itself, not just on popup, but fully
displayed.
  
  
  From:
jquery-en@googlegroups.com [mailto:jquery-en@googlegroups.com] On
Behalf Of Alex Ezell
  Sent: Thursday, August 30, 2007 4:40 PM
  To: jquery-en@googlegroups.com
  Subject: [jQuery] Re: Looking for a calendar picker that
allows for two instances on one page
  
  
Andy,
  I've used datePicker[1] from Kelvin Luck to do multiple date
fields on the same page. I am still using v1 (because I am too lazy to
update it and test the new v2), but I'm sure v2 would work fine for
you. 
  
  
  There are some cool things being done with time and date pickers
that work nicely if you need time.
  
  
  [1] http://kelvinluck.com/assets/jquery/datePicker
  
  
  /alex
  
  On 8/30/07, Andy Matthews [EMAIL PROTECTED]
wrote:
  

I'm working on an app which
allows users to search against data in our db using a date range
(start, end).

What I need is a calendar
which allows a user to select both dates, then click submit. So I need
a calendar which allows for two instances of itself on one page. 

I'm looking at jCalendar: http://tedserbinski.com/jcalendar/index.htmlwhich
looks really great. But
does anyone know if there's a better one?




Andy Matthews
Senior
ColdFusion Developer

Office: 877.707.5467 x747
Direct: 615.627.9747
Fax: 615.467.6249
[EMAIL PROTECTED]
www.dealerskins.com


  
  
  






[jQuery] Select all elements except the first and the 3 last ones?

2007-08-29 Thread Felix Geisendörfer

Hey folks,

I need to select all but the first and the 3 last rows of a table. I 
found out that the following works:


$('table tr:gt(0):not(:last:last:last)')

Whoever it does not seem particular elegant to me and jQuery is always 
(!) elegant, so I'm wondering if one of you could come up with something 
cooler : ).


(I know that giving the elements I'm looking for a class name is 
probably the desirable solution in the long run but I'm interested in 
the problem itself and changing the markup is cheating ^^)


-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


[jQuery] Re: Select all elements except the first and the 3 last ones?

2007-08-29 Thread Felix Geisendörfer
Yeah that one-liner is sweet. I guess I was thinking too much about a 
selector. The project I need this for does run an older jQuery version 
and the deadline is preparing to make this ugly ugly sound that you get 
when not only upsetting the client but also ruining his business - so 
updating, hoping none of the virtually several hundred JS enhanced pages 
won't break is not in reach right now ; ).


Anyway, thanks for the tip I'll keep it in mind : ).

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


John Resig wrote:

Here's a one-liner:
$('table tr').slice(1,-3);

--John

On 8/29/07, Joel Birch [EMAIL PROTECTED] wrote:
  

Hi Felix,

As of jQuery 1.1.4 there is a new slice() method which works similar to the
JavaScript native Array.slice() method, except on jQuery objects. Therefore,
I guess you could do something like:

var $rows = $('table tr');
$rows.slice(1,$rows.length-3);

I may not have calculated the slice parameters properly because I wanted to
post this quick enough to beat Karl to the punch :)

Joel Birch.




  


[jQuery] Re: One callback for two ajax requests

2007-08-16 Thread Felix Geisendörfer
This just cried for an elegant solution, and I'm in 
anything-but-client-work-mood again : ). So here it comes:


Usage:
---
var Stack = new Callstack();
$.getJSON(jsonA.js, {}, Stack.add('requestA'));
$.getJSON(jsonB.js, {}, Stack.add('requestB'));

Stack.onComplete = function(stack) {
   console.log('All request are completed, see:', stack);
   console.log('Response from requestA:', stack.requestA.arguments[0]);
}
---

Code you need to use the above:
---
var Callstack = function() {}
$.extend(Callstack.prototype, {
   stack: {_length: 0}
   , add: function(name, callback) {
   if ($.isFunction(name)) {
   callback = name;
   }
   if (arguments[1]  typeof arguments[1] == 'string') {
   name == arguments[1];
   }
   if (name == '_length') {
   throw 'Callstack::add - Forbidden stack item name _length!';
   }
   if (!name) {
   name = this.stack._length;
   }
  
   var item = {

   arguments: []
   , callback: callback
   , completed: false
   };
  
   this.stack[name] = item;

   this.stack._length++;
  
   var self = this;

   return function() {
   self.handle(item, arguments);
   }
   }
   , update: function() {
   var completed = true;
   $.each(this.stack, function(p) {
   if (p != '_length') {
   completed = completed  this.completed;
   }
   });
  
   if (completed == true) {

   delete this.stack['_length'];
   this.onComplete(this.stack);
   }
   }
   , handle: function(item, args) {
   var r;
   if ($.isFunction(item.callback)) {
   r = callback.apply(item.callback, args);
   if (r === false) {
   return r;
   }
   }
  
   item.arguments = args;

   item.completed = true;
   this.update();
   return r;
   }
   , onComplete: function() {
   alert('Stack done executing!');
   }
   , reset: function() {
   this.stack = {};
   }
});
---

I also threw in some good stuff, for example you do not have to 
explicitly name you stack items, it will use auto-incrementing values 
automatically if you don't. Also: You can pass a callback to the 
Stack.add() function that acts as a gatekeeper for determining if the 
stack item has executed successfully. If that function returns falls 
then the stack item will not be thought of as completed and the item can 
be triggered again using Callstack.handle().


One could also base a little plugin on this that will only trigger a 
function if all elements in the current selection have triggered a 
certain event:


Sample usage:
---
$(function() {
   $('a').stack('click', function(stack) {
   console.log('All links in this document where clicked once! 
See:', stack);

   }, function() {
   // Cancel link default event
   return false;
   });
});
---

Plugin code:
---
$.fn.stack = function(event, onComplete, fn) {
   var Stack = new Callstack();
   this.each(function() {
   var stackFn = Stack.add();
   $(this)[event](function() {
   var r;
   if ($.isFunction(fn)) {
   r = fn.apply(this, arguments);
   }
  
   stackFn.apply(this, arguments);

   return r;
   });
   });
   Stack.onComplete = onComplete;
}
---

Hmm, I guess I should have and eventually will make a blog post about 
this. Meanwhile I hope you or somebody else finds it useful : ).

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Michael Geary wrote:
Good ideas, Thiago. The second one - nested AJAX calls 
- will definitely work, and it is probably the simplest way to do this:

   $.getJSON(url1, {}, function( json1 ) {
  $.getJSON(url2, {}, function( json2 ) {
 // do something with json1 and json2
  });
   });
That does serialize the two AJAX/JSON calls instead of firing them 
both off at once, though. (The second request is made when the first 
one finishes.)
 
If you want to fire the two AJAX calls together (especially a good 
idea if they are coming from different servers), then you'd want 
something like your first idea. There is one bug in that 

[jQuery] Re: App similar to Google Homepages

2007-08-14 Thread Felix Geisendörfer




A bit dated, but maybe kind of what you are looking for:

http://sonspring.com/journal/jquery-portlets

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de



Andy Matthews wrote:

  
  
  Hey
all...
  
  I'm
in the process of writing an app that will offer information to our
clients. The interface is open at this point, but I'm looking at the
possibility of a display type similar to Google Homepages. It would be
"module" based in that there would be multiple boxes containing various
bits of information, and the user would be able to move these boxes
around in a grid based system.
  
  Can anyone
offer some input as to where I should start looking for this sort of
thing? I'm sure that there are drag and drop plugins already, but I'm
not sure of what all I would need.
  
  
  
  
Andy Matthews
  Senior
ColdFusion Developer
  
  Office: 877.707.5467 x747
Direct: 615.627.9747
Fax: 615.467.6249
  [EMAIL PROTECTED]
  www.dealerskins.com
  





[jQuery] Re: $.clone

2007-08-05 Thread Felix Geisendörfer
My function for cloning looks like this: It covers objects, arrays, 
functions and jQuery objects / custom objects with an own clone() function:


--
$.extend({
   clone: function(obj, deep) {
   // Clone a jQuery object / objects with a custom clone function
   if (obj  obj  obj.clone  $.isFunction(obj.clone)) {
   return obj.clone(deep);
   }
   // Clone a function
   if ($.isFunction(obj)) {
   return function() {return obj.apply(this, arguments);};
   }
  
   if (obj  obj.constructor == Array) {

   // Clone an array
   var clone = [];
   for(var i = 0; i  obj.length; i++) {
   clone[i] = (deep == true)
   ? obj[i]
   : $.clone(obj[i], deep);
   }
   return clone;
   } else if (obj  obj.constructor == Object) {
   // Clone an object
   var clone = {};
   for (var p in obj) {
   clone[p] = (deep == true)
   ? obj[p]
   : $.clone(obj[p], deep);
   }   
   }

   return clone;
   }
--

I'm interested to hear feedback,
-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Erik Beeson wrote:
Thanks for sharing this. I'm pretty sure what you suggest won't 
properly deal with arrays. Objects aren't the same as arrays. Here's 
how I do something like that:


function deepCopy(obj) {
if(obj  obj.constructor == Object) {
var newObj = new Object();
for(var field in obj) {
newObj[field] = deepCopy(obj[field]);
}
return newObj;
} else if(obj  obj.constructor == Array) {
var newArray = new Array();
for(var i = 0; i  obj.length; i++) {
newArray[i] = deepCopy(obj[i]);
}
return newArray;
}

return obj;
}

Also, while it's fine to use $ however you want in your own code, for 
code that you're making public, I suggest you checkout the plugin 
authoring guide about not using $ directly: 
http://docs.jquery.com/Plugins/Authoring#Custom_Alias


--Erik


On 8/5/07, *weepy * [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:



During assingment, if the object is not primative, Javascript will
return a pointer to the object rather than a copy.

E.g.

a = [1,2]
b = a
b[0]=3
a == [3,2]

This clone function makes it possible to copy an object.

$.clone = function (obj) {
if(typeof(obj) != 'object') return obj;
if(obj == null) return obj;
var newobj = new Object();
for(var i in obj)
 newobj[i] = $.clone(obj[i]);
return newobj;
}

a = [1,2]
b = $.clone(a)
b[0]=3
a == [1,2]

I have found this function invaluable when comparing and complex
Javascript objects.




[jQuery] Re: $.clone

2007-08-05 Thread Felix Geisendörfer


BTW: you are missing a final )
Haha, ok it's official - I suck. Or at least am not allowed to paste 
code in here that I haven't at least given a quick firebug trial ; ).

1) I tried to replace my version with it and it didn't work. I did add
in the  $.clone(xxx,true) to my code. It wasn't obvious why it didn't
work.

Can you paste the code you tried and that shows the function failing?

2) Speed. Cloning can be quite slow due to the recursion. Is it
possible to move the jQuery specific stuff to the end so it's not
always run by default ?
Give me a break ; ). I would of course need to benchmark this, but I 
doubt you'd gain any significant speed by that. Optimizing your jQuery 
selectors is a *much* better place to worry about speed. That being 
said,  I think none of the stuff could be moved to the bottom as 
$.isFunction could theoretically return true for objects that have the 
constructor Object (somebody correct me if I'm wrong).


-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


weepy wrote:

BTW: you are missing a final )

2 comments :

1) I tried to replace my version with it and it didn't work. I did add
in the  $.clone(xxx,true) to my code. It wasn't obvious why it didn't
work.

2) Speed. Cloning can be quite slow due to the recursion. Is it
possible to move the jQuery specific stuff to the end so it's not
always run by default ?

On Aug 5, 6:46 pm, the_undefined [EMAIL PROTECTED] wrote:
  

Sry for spamming the list, but I just spotted another error (that's
what you get when doing quick refactorings for posting stuff in public
without testing them properly ^^). Full code again / last post:

$.extend({
clone: function(obj, deep) {
// Clone a jQuery object / objects with a custom clone function
if (obj  obj  obj.clone  $.isFunction(obj.clone)) {
return obj.clone(deep);
}
// Clone a function
if ($.isFunction(obj)) {
return function() {return obj.apply(this, arguments);};
}

if (obj  obj.constructor == Array) {
// Clone an array
var clone = [];
for(var i = 0; i  obj.length; i++) {
clone[i] = (deep == true)
? obj[i]
: $.clone(obj[i], deep);
}
return clone;
} else if (obj  obj.constructor == Object) {
// Clone an object
var clone = {};
for (var p in obj) {
clone[p] = (deep == true)
? obj[p]
: $.clone(obj[p], deep);
}
return clone;
}
return obj;
}

}

-- Felix

On Aug 5, 7:42 pm, the_undefined [EMAIL PROTECTED] wrote:



Ups, that last line should read:
  
return obj;
  
not 'return clone;'.
  
On Aug 5, 7:30 pm, Felix Geisendörfer [EMAIL PROTECTED] wrote:
  

My function for cloning looks like this: It covers objects, arrays,
functions and jQuery objects / custom objects with an own clone() function:

--

$.extend({
clone: function(obj, deep) {
// Clone a jQuery object / objects with a custom clone function
if (obj  obj  obj.clone  $.isFunction(obj.clone)) {
return obj.clone(deep);
}
// Clone a function
if ($.isFunction(obj)) {
return function() {return obj.apply(this, arguments);};
}

if (obj  obj.constructor == Array) {

// Clone an array
var clone = [];
for(var i = 0; i  obj.length; i++) {
clone[i] = (deep == true)
? obj[i]
: $.clone(obj[i], deep);
}
return clone;
} else if (obj  obj.constructor == Object) {
// Clone an object
var clone = {};
for (var p in obj) {
clone[p] = (deep == true)
? obj[p]
: $.clone(obj[p], deep);
}
}
return clone;
}
--

I'm interested to hear feedback,

-- Felix
--
My Blog:http://www.thinkingphp.org
My Business:http://www.fg-webdesign.de

Erik Beeson wrote:


Thanks for sharing this. I'm pretty sure what you suggest won't
properly

[jQuery] Re: [ANN] Dimensions 1.0 final is finally here!

2007-07-22 Thread Felix Geisendörfer
You rock! I cannot imagine working without your plugin on complex/fancy 
UI stuff anymore ; ).


-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Brandon Aaron wrote:
The 1.0 release of Dimensions is finally here. It has been a long time 
in the making. Thanks to everyone who helped me test it!


You can get the details and see an example using the new position 
method over at my blog: 
http://blog.brandonaaron.net/2007/07/22/dimensions-10/


You can download dimensions from the project page: 
http://jquery.com/plugins/project/dimensions

Or via SVN: http://jqueryjs.googlecode.com/svn/trunk/plugins/dimensions/

If you find any bugs or have any feature requests ... be sure to 
report them at the dimensions project page.


Oh... and you can check out the documentation over here: 
http://brandonaaron.net/docs/dimensions/


Thanks!

--
Brandon Aaron


[jQuery] Re: Announce: Confirmer plugin

2007-07-17 Thread Felix Geisendörfer
Cool idea. Just add support for a class that's being added to the button 
when in 'confirm' mode - otherwise there is no way to visually highlight 
this new UI approach for the user ; ).

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Stephan Beal wrote:
 Hi again, all!

 Confirmer is a plugin for jQuery which implements a novel approach to
 the process of confirming an action. Normally this is achieved via a
 yes/no dialog box or a button with a confirm checkbox next to it.
 The Confirmer plugin instead sets up a single button which changes to
 a confirm the action state if it is clicked one time. If the button
 is clicked again within a specified time then the action is confirmed,
 otherwise it times out and returns to its initial state.

 http://wanderinghorse.net/computing/javascript/jquery/confirmer/

 Includes a live demo link.

 Happy hacking!


   


[jQuery] Re: Site Offline?

2007-07-16 Thread Felix Geisendörfer
 I have over 1000 emails a day frequently... and then there are RSS 
 feeds. I don't read them all. Wasn't trying to be smart, don't flame 
 someone until they earn it. :)
You should forward most of that to people who actually have the time to 
read that many emails and are chronically depressed because their inbox 
is always empty. Has worked great for me in the past : ).

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


John Farrar wrote:

 Rey,

 I have over 1000 emails a day frequently... and then there are RSS 
 feeds. I don't read them all. Wasn't trying to be smart, don't flame 
 someone until they earn it. :)

 John

 Rey Bango wrote:

 Smartass! ;)

 Let me see whats up.

 Rey...

 John Farrar wrote:

 Did I miss an announcement that jQuery.com would be down this morning?






[jQuery] Re: Getting user agent stats with jQuery...

2007-07-16 Thread Felix Geisendörfer





  Alternately,
does anyone know of some reliable piece of software which does this
same sort of thing, but maybe cheaper?

Google Analytics - it's free.

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de



Andy Matthews wrote:

  
  
  My
company currently uses a product called BrowserHawk, a combination
of_javascript_ and Java files, to get a set of user data which we then
store in our database. Currently this data set includes Flash player
version, OS, Browser (and version),Screen Res, and more. The drawback
is that this software is expensive, around $1000 per server (we have 3
right now), and we're not fully using the data it provides to us anyway.
  
  I
know that jQuery core can provide browser (and version?), and I also
know that you can get screen res with the dimensions plugin. I'm
wondering if anyone has considered writing a jQuery plugin which mimics
this behavior, returning an object containing user agent information.
  
  Alternately,
does anyone know of some reliable piece of software which does this
same sort of thing, but maybe cheaper?
  
  Thanks
for the input.
  
  
  
Andy Matthews
  Senior
ColdFusion Developer
  
  Office: 877.707.5467 x747
Direct: 615.627.9747
Fax: 615.467.6249
  [EMAIL PROTECTED]
  www.dealerskins.com
  





[jQuery] Re: Getting user agent stats with jQuery...

2007-07-16 Thread Felix Geisendörfer




We wouldn't use it in
"real-time" but we would need to be able to store that data ourselves
and not just access it via their interface.
You can aggregate and store it yourself. I wrote some code a while back
that does that (it's for the CakePHP framework but could be decoupled
from it or alternatively rewritten in any other language).

http://www.thinkingphp.org/2006/06/19/google-analytics-php-api-cakephp-model/

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de



Andy Matthews wrote:

  
  
  We wouldn't use it in
"real-time" but we would need to be able to store that data ourselves
and not just access it via their interface.
  
  Is that still possible?
  
  
  From:
jquery-en@googlegroups.com [mailto:jquery-en@googlegroups.com] On
Behalf Of Aaron Porter
  Sent: Monday, July 16, 2007 12:04 PM
  To: jquery-en@googlegroups.com
  Subject: [jQuery] Re: Getting user agent stats with jQuery...
  
  
If you are only interested in storing the data (not using it real time)
you may want to look into google analytics.
  
  http://www.google.com/analytics/
  
It has lots of info including browser type and version, operating
system, screen resolution, colors, flash version, java version, and
lots more. It has a very slick interface. Best of all it's free!
  
Aaron
  
Andy Matthews wrote:
  

My
company currently uses a product called BrowserHawk, a combination
of_javascript_ and Java files, to get a set of user data which we then
store in our database. Currently this data set includes Flash player
version, OS, Browser (and version),Screen Res, and more. The drawback
is that this software is expensive, around $1000 per server (we have 3
right now), and we're not fully using the data it provides to us anyway.

I
know that jQuery core can provide browser (and version?), and I also
know that you can get screen res with the dimensions plugin. I'm
wondering if anyone has considered writing a jQuery plugin which mimics
this behavior, returning an object containing user agent information.

Alternately,
does anyone know of some reliable piece of software which does this
same sort of thing, but maybe cheaper?

Thanks
for the input.



Andy Matthews
Senior
ColdFusion Developer

Office: 877.707.5467 x747
Direct: 615.627.9747
Fax: 615.467.6249
[EMAIL PROTECTED]
www.dealerskins.com

  
  





[jQuery] Re: Announce: jFeed - jQuery RSS/ATOM feed parser plugin

2007-07-15 Thread Felix Geisendörfer

 Nifty idea, but this will only work within a single domain, right?
   
No there is a proxy.php file to the package that allows you to load RSS 
files from other sites. Or just read the files locally on his server if 
you get bored (hint: check the fopen call : ).

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Michael Geary wrote:
 Nifty idea, but this will only work within a single domain, right?

   
 From: Jean-Francois Hovinne

 jFeed is a new jQuery plugin which parses RSS/ATOM feeds.
 It uses jQuery's built-in AJAX functions to get the XML and 
 basic selectors to parse it.

 More info on my blog:

 
 http://www.hovinne.com/blog/index.php/2007/07/15/132-jfeed-jquery-rss-atom-f
 eed-parser-plugin
   
 Download:
 http://www.hovinne.com/dev/jquery/jfeed/jquery.jfeed.tar.gz

 Any feedback is welcome.
 


   


[jQuery] Re: Announce: jFeed - jQuery RSS/ATOM feed parser plugin

2007-07-15 Thread Felix Geisendörfer

 BTW, a basic one is provided in the archive for testing purposes.
Oh in that case nevermind my last post. I guess the proxy.php is alright 
for *local* testing.

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Jean-Francois Hovinne wrote:
 Yes, though you can use a server-side proxy to load external feeds.
 BTW, a basic one is provided in the archive for testing purposes.

 On 15 juil, 23:25, Michael Geary [EMAIL PROTECTED] wrote:
   
 Nifty idea, but this will only work within a single domain, right?
 


   


[jQuery] Re: Interested in porting another DOM creation plugin?

2007-07-13 Thread Felix Geisendörfer
 No kidding.  I was disappointed to read about some of the missing 
 things from javascript's implementation of regular expressions.  No 
 named groups and no look behinds.  I'm still very new to javascript as 
 a language, so I'm still feeling my way around some things.  I'll post 
 some results as soon as I have something worth showing. 
I really miss look-behind too! Maybe this could be hacked, but that's a 
rather ambitious goal ; ).

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Josh Bush wrote:
 No kidding.  I was disappointed to read about some of the missing 
 things from javascript's implementation of regular expressions.  No 
 named groups and no look behinds.  I'm still very new to javascript as 
 a language, so I'm still feeling my way around some things.  I'll post 
 some results as soon as I have something worth showing.

 Josh

 On 7/13/07, *Jörn Zaefferer* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
 wrote:


 Josh Bush wrote:
  I think I may dig around the jQuery source to get some hints on
  parsing elements.  I've yet to even take a peek inside!
 Beware of those regexp monsters! They can eat your brain. But
 there is
 nothing like a good brain eater for parsing strings...

 --
 Jörn Zaefferer

 http://bassistance.de




[jQuery] Re: Syntactic sugar for checking whether an element exists

2007-07-12 Thread Felix Geisendörfer
Christof: I appreciate your comments. Even more however I would have 
appreciated if you'd have taken into consideration why I made the 
proposal. I didn't do so because I personally need this functionality, 
but because I think both exists() and hasClass() would make the library 
more accessible to newcomers who do not understand the inner workings 
100% perfectly. Now if you are saying that those should be educated 
rather then spoiled then you've got a valid point there. I just think 
that jQuery has gained a lot of it's popularity due to it's 
easy-to-learn factor (besides it's superiority and beauty that is : ) 
and think this could be a good addition to it.
 div class=myClass.../div
 div class=myOtherClass.../div

 $('div').hasClass('myClass');

 What should this return now?
It should return true. That's because $('a').attr('href') returns the 
'href' attribute of the first anchor matched (afaik).

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Christof Donat wrote:
 Hi,

   
 However, as you said this library is more then just code, it's art. And
 this is why I'm emphasizing those new functions: They empower the artist
 

 Perfection is achieved, not when there is nothing more to add, but when 
 there 
 is nothing left to take away.
  (Antoine de Saint-Exupéry)

 Don't try to add paint to the Mona Lisa ;-)

 Christof

   


[jQuery] Re: Syntactic sugar for checking whether an element exists

2007-07-10 Thread Felix Geisendörfer

 But I don't think we disagree at all. I wasn't talking about .get() with no
 arguments, but rather .get(n) and .size(), which are just slower synonyms
 for [n] and .length.
Yeah I agree with you on that. I just read: 'we should get rid of the 
get() function' and freaked : p

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Michael Geary wrote:
 There's no reason at all to stick with .get(n) and .size()
 now that the array-like jQuery object allows the 
 simpler and more efficient [n] and .length.
   

   
 I disagree. Whenever you need to sort the elements in an
 ul or something then you'll have to use the Array.sort() 
 function, so you need to do $('ul li').get().sort(...). Here 
 is an example of where I needed this functionality: 
 http://bin.cakephp.org/view/1632218532

 It's not a big deal that I have to call get(), but it would 
 be a big problem if it wasn't there!
 

 That's a good point about .get() with no arguments - it gives you a genuine
 Array object which can be quite useful.

 But I don't think we disagree at all. I wasn't talking about .get() with no
 arguments, but rather .get(n) and .size(), which are just slower synonyms
 for [n] and .length.

 -Mike


   


[jQuery] Re: Syntactic sugar for checking whether an element exists

2007-07-10 Thread Felix Geisendörfer

   if ($('#someID')) {
 // something matched the selector
   }
See, and there you go making a wrong assumption that beginners are much 
more likely to run into. !![] is evaluating to true and so is a jQuery 
object that has not matched any items. I'm not blaming you for it, it's 
counter-intuitive (if you don't know objects always evaluate to true) 
but that's how JS works.  So an exists() function could could probably 
help people avoiding this mistake.

(Your other example where using [0] is a workable solution however)

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


RobG wrote:
 On Jul 10, 4:50 am, Sean Catchpole [EMAIL PROTECTED] wrote:
   
 I believe that learning jquery returns an array like object is more
 useful than creating a .exists() function.
 

 It seems to me that the most common reason for testing if an element
 exists is to use it later, so why not:

   var element;
   if ( (element=$('#someID')[0]) ) {
 /* element exists */
   } else {
 /* damn... */
   }

 Another idea is that if the seletor doesn't select any elements,
 return null (as does getElementById() in that case):

   if ($('#someID')) {
 // something matched the selector
   }

 but that may not be backward compatible.  Of what use is an empty
 jQuery object?


 --
 Rob


   


[jQuery] Re: Syntactic sugar for checking whether an element exists

2007-07-10 Thread Felix Geisendörfer
 In fact, if you find yourself doing a lot of if(something exists) {
 ... } else { ...}, you might want to consider trying to move some of
 your code into a plugin.
The target audience for an exists() function would be new comers to 
jQuery. Those are generally a little scared about writing their own 
'plugin' even so there isn't much to be scared about I think and I'm 
just making this assumption here ; ).

Anyway, there are situations where plugins are not enough. For example 
if you have to modify other elements in case a certain screen element 
exists then a plugin won't really help you a lot unless it's very 
app-specifc.

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Erik Beeson wrote:

 In fact, if you find yourself doing a lot of if(something exists) {
 ... } else { ...}, you might want to consider trying to move some of
 your code into a plugin. Most jQuery functions/plugins already deal
 with the if(exists)... part by simply not executing if nothing is
 selected. If you really want the 'else' part, you could imagine a
 simple plugin, something like (untested):

 $.fn.ifEmpty = function(f) {
  if(this.length == 0) f.apply(this);
  return this;
 }

 And use it like this:

 $('#foo').show().ifEmpty(function() {
  alert(foo doesn't exist);
 });

 Which would show the element with ID foo, or show an alert if the
 element doesn't exist. Equivalent to:

 var $foo = $('#foo');
 if($foo.length  0) {
  $foo.show();
 } else {
  alert(foo doesn't exist);
 }

 Just an idea.

 --Erik


 On 7/9/07, Erik Beeson [EMAIL PROTECTED] wrote:
  Another idea is that if the seletor doesn't select any elements,
  return null (as does getElementById() in that case):
  ...
  but that may not be backward compatible.  Of what use is an empty
  jQuery object?

 An empty jQuery object doesn't break chainability:

 $('#foo').hide();

 Will hide the element with ID foo if it exists. Otherwise, it does
 nothing. If null were returned, that would generate a javascript
 error, so you would have to always check for the existence of the
 element if you wanted to be sure you didn't generate an error.

 This is one of the sweetest features of jQuery.

 --Erik




[jQuery] Re: Syntactic sugar for checking whether an element exists

2007-07-10 Thread Felix Geisendörfer
 jQuery is a language
It was a library last time I checked ; ).
 and as such requires you to read at least a bit
 of documentation or examples before starting.
Why? For me the sweetest thing about using jQuery has been it's 
intuitiveness right out of the box. When I started I just looked at some 
initial code samples (fancy API pages weren't around back then or I 
didn't know about them) and then was virtually able to 'guess' the 
jQuery functions I needed. Need to add a class? Hmm let me try 
addClass() - works, yeah! Now I want to remove an element from the DOM - 
oh remove() it is! So now I just need to check whether this element 
exists. Hm - exists() produces a fatal error. Let me search the docs:

* 
http://docs.jquery.com/Special:Search?search=element+existsfulltext=Search
  
http://docs.jquery.com/Special:Search?search=element+existsfulltext=Search
* 
http://www.google.com/search?q=site%3Adocs.jquery.com%20element%20existshl=en
  
http://www.google.com/search?q=site%3Adocs.jquery.com%20element%20existshl=en

At this point I would need to actually post to the group or read the 
complete API docs in detail to find that is() is the answer to the 
problem. Same goes for hasClass() I think.
 Maybe .is() and .length
 should be more prominently visible in the doc, but I see no point in
 adding the .exists() and .hasClass() cruft to the (beautiful) jQuery
 code. 
I think is() is beautiful as well and there is nothing wrong with 
.length. However both pose a certain barrier for something new-comers 
will possibly try to do quite often.

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Fil wrote:

 jQuery is a language and as such requires you to read at least a bit
 of documentation or examples before starting. Maybe .is() and .length
 should be more prominently visible in the doc, but I see no point in
 adding the .exists() and .hasClass() cruft to the (beautiful) jQuery
 code.

 -- Fil



[jQuery] Re: Syntactic sugar for checking whether an element exists

2007-07-10 Thread Felix Geisendörfer
 What about

 Array.prototype.sort.apply( $('li') );

 Not sue if that'll work... 
I think that could work, but it's breaking chainability so I think the 
array plugin mentioned by Jörn earlier is a better alternative. However 
since I all I need is sort(), I actually am fine with using get() that 
one time.

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Klaus Hartl wrote:

 Felix Geisendörfer wrote:
 Felix, not to worry, there's nothing wrong at all with using .length 
 - and it is obviously faster than a function call.
 I figured that by now. I think Matt was much better at explaining why 
 I think an alternative exists() function is useful - it simply is the 
 most intuitive thing a new jQuery user looks for. I also agree with 
 his hasClass argument. I love the is() function, but I would have 
 taken me a long time to find it if I my question was phrased Who can 
 I determine if an element has a certain class.is() is more powerful 
 but not nearly as intuitive as hasClass would be for new users.
 In the earliest versions of jQuery, the jQuery object was not an 
 array, but had a private array object that you accessed using 
 .get(n) and .size(). The only reason those functions still exist is 
 for compatibility with old code.
  
 There's no reason at all to stick with .get(n) and .size() now that 
 the array-like jQuery object allows the simpler and more efficient 
 [n] and .length.
 I disagree. Whenever you need to sort the elements in an ul or 
 something then you'll have to use the Array.sort() function, so you 
 need to do $('ul li').get().sort(...). Here is an example of where I 
 needed this functionality: http://bin.cakephp.org/view/1632218532

 It's not a big deal that I have to call get(), but it would be a big 
 problem if it wasn't there!


 What about

 Array.prototype.sort.apply( $('li') );

 Not sue if that'll work...


 --Klaus



[jQuery] Re: Syntactic sugar for checking whether an element exists

2007-07-10 Thread Felix Geisendörfer
 ok, so next time i want to code something in jquery i'll just write
 $(make coffee) ? 
Haha, now I'm questioning your ambition. This is the holy grail of all 
programming, it's almost blasphemy to make fun of it ; ).
 For me (and I really mean not speaking for everyone) it's more
 intuitive if there is an internal logic that I can understand;
Ok, I guess in this case the only language we share is jQuery ; ). 
Intuition irrational by definition, see: 
http://www.google.com/search?q=define:intuition.
 No, there are things that are intuitive **once you've understood the
 basics**. IOW intuitiveness is based on your assumptions and your
 knowledge. Why would you assume that .hasClass() exists? And not,
 e.g., isMemberOf() or .classMatches() ? It must depend of what you're
 already familiar with before you switch to jQuery. 
I agree with you that people will try to use stuff they know from other 
libraries first before falling back to intuition. So what would be two 
of the most popular ones to expect?

Mootools:

* includes a hasClass() function:
  http://docs.mootools.net/Native/Element.js#Element.hasClass
* includes a remove() function:
  http://docs.mootools.net/Native/Element.js#Element.remove

Prototype:

* includes a hasClassName() function:
  http://www.prototypejs.org/api/element#method-hasclassname
* includes a remove() function:
  http://www.prototypejs.org/api/element/remove

To be fair. Neither Mootools nor Prototype seem to include an exists() 
function. This however could also be traced back by the fact that they 
do not share the jQuery philosophy in terms of advocating their CSS 
selector engine as a) their main element retrieval method and b) don't 
use it as a wrapper for chainability.

Anyway I can see your argument about how an exists() function would be 
redundant. jQuery has a lot of convenience wrappers for things, but 
$.fn.exists = function(){return !!this.length}; would be the smallest 
and least functional one. Same is almost true for hasClass (return 
this.is('.'+class));. This is where you can convince me with a 
rational/scientific argument that those functions aren't needed. 
However, as you said this library is more then just code, it's art. And 
this is why I'm emphasizing those new functions: They empower the artist 
(who does not read the complete docs before getting started) and don't 
hurt the scientists 

What a rant ... haha

Anyway, interesting discussion and good arguments,
-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Fil wrote:

 jQuery is a language
 It was a library last time I checked ; ).

 yeah, well, it can be many things to many people; we all agree it's
 code. I think it's art, too

 Why? For me the sweetest thing about using jQuery has been it's 
 intuitiveness right out of the box.

 ok, so next time i want to code something in jquery i'll just write
 $(make coffee) ?

 No, there are things that are intuitive **once you've understood the
 basics**. IOW intuitiveness is based on your assumptions and your
 knowledge. Why would you assume that .hasClass() exists? And not,
 e.g., isMemberOf() or .classMatches() ? It must depend of what you're
 already familiar with before you switch to jQuery.

 For me (and I really mean not speaking for everyone) it's more
 intuitive if there is an internal logic that I can understand; adding
 stuff that is redundant is merely adding cruft, and hence
 counter-intuitive.

 That's why I wanted to add my I don't agree message -- though I
 understand and respect your position, I don't share it.

 -- Fil



[jQuery] Syntactic sugar for checking whether an element exists

2007-07-09 Thread Felix Geisendörfer
I've just been wondering if jQuery has some syntactic sugar for checking 
if an element exists. I know the following works:

if ($('#my-element').length) {
 // #my-element exists
}

but is there also something similar to the following?:

if ($('#my-element').exists()) {
 // #my-element exists
}

I'm asking because I know this was one of the things I was initially 
unsure about when learning jQuery and I just had a one of my many jQuery 
converted friends ask me about it again. So is anybody else thinking 
some syntactic sugar could be helpful here? Or what do you think about:

$('#my-element').is('*') ?

(Besides that it's probably inefficient *g*)

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


[jQuery] Re: Syntactic sugar for checking whether an element exists

2007-07-09 Thread Felix Geisendörfer
Sean, Mike: I agree with your notion that learning that the jQuery 
object is array-like (It'd be cool if it was a real array and .push / 
.sort would work on it) is very worthwhile. I knew that when I initially 
stumbled across the problem and knew that doing it via '.length' was one 
solution. I was only confused if it was the right way or could lead to 
undesired results as I was new to jQuery at this point and I didn't find 
it mentioned anywhere in specific. That's where my notion of an 
'exists()' function could be useful comes from. But it's probably just 
something that should be put in the manual somewhere (if it isn't 
already in there and I missed it).

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Sean Catchpole wrote:

 I believe that learning jquery returns an array like object is more
 useful than creating a .exists() function.

 ~Sean



[jQuery] Re: Syntactic sugar for checking whether an element exists

2007-07-09 Thread Felix Geisendörfer
 Felix, not to worry, there's nothing wrong at all with using .length 
 - and it is obviously faster than a function call.
I figured that by now. I think Matt was much better at explaining why I 
think an alternative exists() function is useful - it simply is the most 
intuitive thing a new jQuery user looks for. I also agree with his 
hasClass argument. I love the is() function, but I would have taken me a 
long time to find it if I my question was phrased Who can I determine 
if an element has a certain class.is() is more powerful but not nearly 
as intuitive as hasClass would be for new users.
 In the earliest versions of jQuery, the jQuery object was not an 
 array, but had a private array object that you accessed using .get(n) 
 and .size(). The only reason those functions still exist is for 
 compatibility with old code.
  
 There's no reason at all to stick with .get(n) and .size() now that 
 the array-like jQuery object allows the simpler and more efficient [n] 
 and .length.
I disagree. Whenever you need to sort the elements in an ul or 
something then you'll have to use the Array.sort() function, so you need 
to do $('ul li').get().sort(...). Here is an example of where I needed 
this functionality: http://bin.cakephp.org/view/1632218532

It's not a big deal that I have to call get(), but it would be a big 
problem if it wasn't there!

-- Felix
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de


Michael Geary wrote:
 Felix, not to worry, there's nothing wrong at all with using .length 
 - and it is obviously faster than a function call.
  
 In the earliest versions of jQuery, the jQuery object was not an 
 array, but had a private array object that you accessed using .get(n) 
 and .size(). The only reason those functions still exist is for 
 compatibility with old code.
  
 There's no reason at all to stick with .get(n) and .size() now that 
 the array-like jQuery object allows the simpler and more efficient [n] 
 and .length.
  
 -Mike

 
 *From:* Felix Geisendörfer 
 Sean, Mike: I agree with your notion that learning that the jQuery
 object is array-like (It'd be cool if it was a real array and
 .push / .sort would work on it) is very worthwhile. I knew that
 when I initially stumbled across the problem and knew that doing
 it via '.length' was one solution. I was only confused if it was
 the right way or could lead to undesired results as I was new to
 jQuery at this point and I didn't find it mentioned anywhere in
 specific. That's where my notion of an 'exists()' function could
 be useful comes from. But it's probably just something that should
 be put in the manual somewhere (if it isn't already in there and I
 missed it).

 -- Felix
 --
 My Blog: http://www.thinkingphp.org
 My Business: http://www.fg-webdesign.de


 Sean Catchpole wrote:

 I believe that learning jquery returns an array like object is more
 useful than creating a .exists() function.

 ~Sean



[jQuery] Re: Naming Conventions

2007-06-28 Thread Felix Geisendörfer




I like it simple:

[x] .mask
[ ] .maskInput

-- Felix
--
My latest blog posts:

  
 My Business: http://www.fg-webdesign.de





Josh Bush wrote:

  As my masked input plugin approaches 1.0, I'm noticing that my plugin
isn't following the conventions of the jQuery library itself.

Currently my plugins main method is .maskedinput(mask,options)

I'm thinking I should change it to .maskInput(mask,options) or
simpley .mask(mask,options)


I think this change is good because it's a verb and it shows action.

Also, there is a global method which allows user defined char
placeholders which Jrn advided me to namespace off.

So, I plan to put it in $.MaskedInput.addPlaceholder(character,regex).

What do you all think of the proposed name changes?  I think it's
important to remain consistent with the base library.  I want to make
sure that I get everything settled once I reach 1.0.

Thanks
Josh
digitalbush.com


  





[jQuery] Re: Naming Conventions

2007-06-28 Thread Felix Geisendörfer




I would prefer .maskInput as the method name,
coz, it conveys both the
intention and what it applies to. "mask" doesnt convey where it applies
to and probably can be used for a more generic plugin.
$('input.date').mask(...) should be good enough to imply what is meant
I think. I used to be in favor of longer function names myself a while
back, but recently found that shorter is better in most cases. A good
example is jQuery itself: we have css() instead of setStyle(), load()
instead of ajaxLoad() etc. The thing is as longer your name get's the
less intuitive it is. When I started using jQuery I would discover
functions by virtually guessing their names and only use the API if
that resulted in an error. So I'm going to vote for mask() again ; ).

-- Felix
--
My latest blog posts:

  
 My Business: http://www.fg-webdesign.de





Ganeshji Marwaha wrote:

  I would prefer .maskInput as the method name, coz, it conveys
both the intention and what it applies to. "mask" doesnt convey where
it applies to and probably can be used for a more generic plugin.
  
  Regarding, the namespace for additional methods. I agree that
MaskedInput is the one that actually makes sense. But for the sake of
simplicity and consistency, i would name it MaskInput instead.
  
  -GTG
  

  On 6/28/07, Josh Bush [EMAIL PROTECTED] wrote:
  
As my masked input plugin approaches 1.0, I'm noticing that my plugin
isn't following the conventions of the jQuery library itself.


Currently my plugins main method is .maskedinput(mask,options)

I'm thinking I should change it to .maskInput(mask,options) or
simpley .mask(mask,options)


I think this change is good because it's a verb and it shows action.


Also, there is a global method which allows user defined char
placeholders which Jrn advided me to namespace off.

So, I plan to put it in $.MaskedInput.addPlaceholder(character,regex).

What do you all think of the proposed name changes?I think it's

important to remain consistent with the base library.I want to make
sure that I get everything settled once I reach 1.0.

Thanks
Josh
digitalbush.com

  
  
  





[jQuery] Re: Overlay plugin?

2007-06-24 Thread Felix Geisendörfer




I want to maintain proportion, but scale it to
fit in the view port.0
Got some PHP code laying around that does just that. Should be easy to
convert to JS:


function fitObjectInBox($objectWidth, $objectHeight, $boxWidth,
$boxHeight)
{
 // Fit's our image in a box with a given width and heigth while
proportions remain,
 // *or* resizes it based on one site proportionally if only width
or height is given
 $widthRatio = @($boxWidth / $objectWidth);
 $heightRatio = @($boxHeight / $objectHeight);
 
 if (($widthRatio  $heightRatio)  ($widthRatio!=0) ||
($heightRatio==0))
 {
 $ratio = $widthRatio;
 }
 else
 {
 $ratio = $heightRatio;
 }
 
 $new_width = ceil($objectWidth * $ratio);
 $new_height = ceil($objectHeight * $ratio);
 
 return array($new_width, $new_height);
}


HTH, Felix
--
My latest blog posts:

  
 My Business: http://www.fg-webdesign.de





Glen Lipka wrote:
Sorry, working on it right now. :)
I fixed that. Trying to figure out how to position it in the middle of
the screen and adjust the height width so it makes sense.
The logic is a little tortuous on my mind.
  
I want to maintain proportion, but scale it to fit in the view port.
  
Is there a resize plugin?
  
Glen
  
  On 6/23/07, Aaron Heimlich [EMAIL PROTECTED]
wrote:
  
  I
got this error on FF 
2.0.0.4 (Mac OS 10.4.10):

e.css is not a function
http://www.commadot.com/jquery/easebox/easeBox.js


Line 59

Stack trace:


showZoom(a
 matt-big.jpg)easeBox.js
(line 59)
(no name)()easeBox.js
(line 27)
(no name)(
click clientX=0, clientY=0)jquery-latest.js
(line 1398)
handle
(click clientX=0, clientY=0)jquery-latest.js
(line 1302)


e.css("z-index","1001");



On 6/24/07, Glen Lipka [EMAIL PROTECTED]
 wrote:
dimScreen
is great.
Check it out:
  http://www.commadot.com/jquery/easebox/
  
  
Although, I changed it slighly to use $(window).width() instead of
$(document).width()
  
This might only work with the dimensiosn plugin included.
  
Glen
  
  
  On 6/23/07, Glen Lipka 
[EMAIL PROTECTED]
   wrote:
  
  It
should be Rey Bingo!
That's exactly it. Awesome. Thanks. :)


Glen


On 6/23/07, Rey Bango 
[EMAIL PROTECTED]
 wrote:

dimScreen:
  
  http://docs.jquery.com/Plugins/dimScreen
  
Glen Lipka wrote:
 I can't find it, but I vaguely remember someone had a plugin that
just
  
 puts a 50% opacity overlay over the page.
 Sort of like a thickbox thing, but without all the other stuff.
  
 Does anyone know where it is?

 Glen
  
--
BrightLight Development, LLC.
954-775- (o)
954-600-2726 (c)
  [EMAIL PROTECTED]
  http://www.iambright.com




  
  
  
  






-- 
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com


  
  





[jQuery] Re: Image resizing

2007-06-24 Thread Felix Geisendörfer




Untested, off the cuff:

centerPosition: function(objWidth, objHeight, boxWidth, boxHeight) {
 return {
  top: (boxWidth / 2) - (objWidth / 2)
  , left: (boxHeight / 2) - (objHeight / 2)
 }
}

var $myDiv = $('#my-div');
var $screen = $(document);
mvDiv.css(centerPosition(myDiv.width(), myDiv.height(),
$screen.width(), $screen.height()));

See if that helps,
-- Felix
--
My latest blog posts:

  
 My Business: http://www.fg-webdesign.de





Glen Lipka wrote:

  Felix Geisend hooked me up with some code, which seemed to work perfectly.
  function
fitObjectInViewPort(zoomedImage)
  
{
 // Fit's our image in a box with a given width and heigth while
proportions remain,
 // *or* resizes it based on one site proportionally if only width
or height is given
  
 var objectWidth = zoomedImage.width();
 var objectHeight = zoomedImage.height();
  
 var boxWidth = ($(window).width()) * maxImagePercent;
 var boxHeight = ($(window).height()) * maxImagePercent;
  
 widthRatio = (boxWidth / objectWidth);
  
 heightRatio = (boxHeight / objectHeight);
  
 if ((widthRatio  heightRatio)  (widthRatio!=0) ||
(heightRatio==0))
 {
 ratio = widthRatio;
 }
 else
 {
 ratio = heightRatio;
  
 }
  
 new_width = Math.ceil(objectWidth * ratio);
 new_height = Math.ceil(objectHeight * ratio);
  
 //return array(new_width, new_height);
  
 new_left = (boxWidth - new_width) / 2;
 new_top = (boxHeight - new_height) / 2;
  
 bigThumb.animate({width:new_width,height:new_height}, {duration: 750,
easing: "backinout"});
  
}
  
My math to figure out how to center it in the viewport is a little
sketchy, but I feel like it's making progress.
  
  
Thanks Felix!
  
Glen
  
  
  On 6/23/07, Glen Lipka
[EMAIL PROTECTED]
   wrote:
  I'm sorry I am asking so many questions about this.

Still working on this EaseBox thing.
http://www.commadot.com/jquery/easebox/

My question has to do with finding the proper image size based on the
viewport.


Logic:
maximum height and width of the zoomed image is a percentage of the
viewport.
var maxPercentage = 90%;
this means that height nor width can be more than 90% of the viewport.

if they are both less, then it should maximize to full size.


if width is more and height it less
it should reduce width to maxPercentage and keep height proportional
and vice versa for height more, but width less.

if height and width are higher, then it should pick the one that is
higher and reduce that to maxPercentage of either height orwidth of
viewport depending on which one is more.


Once the image size is calculated, it should center it in the viewport
horizontally and vertically. I guess that is
left: viewport width - image width /2
top: viewport height- image height/2

Is that right?


Man, this is making me dizzy.

Then I have to put these variables into an animate function.
What is the syntax to do that?

Any help is greatly appreciated.

Glen

  
  
  




[jQuery] Re: Masked Input Plugin RC1a

2007-06-22 Thread Felix Geisendörfer




Thanks for that plugin : ).

Call / apply are ones best friends when working with JS. Incredibly
powerful stuff when used right. One of my favorite uses apply is to use
it on a new array instance to force 'arguments' variable to behave like
a real array and re-route function arguments based on the first value
passed into the array:

Sample:
---
$.fn.task = function(fct) {
 var r = $.fn.task.fn[fct].apply(this[0], [].slice.call(arguments,
1));
 return r === undefined ? this : r;
};

$('tr[td]').task('field', 'value'); - calls $.fn.task.fn.field(value)
---

Anyway, keep up the good work and thanks for the improvement,
-- Felix
--
My latest blog posts:

  
 My Business: http://www.fg-webdesign.de





Josh Bush wrote:

  Hey guys and gals.  I learned about the .call() functionality today
and decided to modify the behavior of the optional mask completed
function.  Now you don't need to specify an parameter when you define
your function; you can simply use "this".

Before:
$("#product").maskedinput("99/99/",{completed:function(input)
{alert("You typed the following: "+input.val());}});

Now:
$("#product").maskedinput("99/99/",{completed:function()
{alert("You typed the following: "+this.val());}});

It's not a necessary change, I just wasn't happy with forcing the user
to add a param to their functions.  It seemed a bit kludgey to me.

The new version is up at: http://digitalbush.com/projects/masked-input-plugin
and also at the official jQuery plugin repository:
http://jquery.com/plugins/project/maskedinput

Thank You
Josh


  





[jQuery] Re: Macrumors running live udpates of WWDC

2007-06-12 Thread Felix Geisendörfer
On an (un)related note: Is anybody having rendering quirks with the 
Safari 3 beta on Win XP? I just noticed that a couple sites of mine that 
I thought would render well in Safari are messed up. Even Google Ads 
seems to be affected.


Anybody with similar problems?

-- Felix

PS: Click on the link below for thinkingphp.org to see what I mean.
--
http://www.thinkingphp.org
http://www.fg-webdesign.de


Klaus Hartl wrote:


Mike Alsup wrote:
I'm *really* excited to be able to run Safari on Windows, but has 
anyone used this beta?  I've never seen anything render so slowly.  
It's entirely unusable on my XP box.




It is also totally annoying that you can't run Safari 3 beta and 2 
side by side on a Mac... grrr, Apple is making the same mistakes as 
Microsoft.


Am I missing something?


-- Klaus



[jQuery] Re: SlickSpeed CSS Selector TestSuite

2007-06-12 Thread Felix Geisendörfer

Well here is my personal (and widely uneducated) opinion on this speed test.

First what I think is good about it:

   * each framework get's it's own iframe - avoid conflicts between them
   * the test itself is written without using a framework

What I think is bad about it:

   * There are 3 nth-child(x*n)-style tests that jQuery seems to choke
 on as those selectors are not implemented in 1.1.2 (correct me if
 I'm wrong). On my machine this equates in 617ms (20 %) of jQuery's
 total test time (2857ms)
   * The div ~ div selector seems to take jQuery really long to
 perform, 1125ms (43%) go into it
   * The div:only-child + div:contains selector seem to be slow in
 jQuery and 203ms total (12%) go into them

What does this mean? It means that jQuery is nowhere as slow as the 
final test results make it appear (26x slower then mootools). It means 
that mootools got the performance lead in some specific selector (and 
does good in general) which is given way too much weight by the test 
itself.


I'm also questioning how far one can even go in terms of benchmarking 
selector engines. I mean everybody has different needs. Most of the time 
I use very simple selectors which jQuery does very fast according to the 
test. So I'd actually be willing to loose performance on the more 
complicated selectors if that allows the more common ones to run faster. 
What's missing in my eyes is a survey or analysis of common selector 
usage that could be used to weigh in the different selector results.


That being said I'm not trying to say jQuery is actually the fastest 
library and the evil test just made it look bad. I'm sure there is room 
for improvements and who knows what 1.1.3 will bring. But what I'm 
trying to communicate is that it's not an easy job to actually interpret 
the results coming from those speed tests and hence one should be very 
careful when using them to make a point for one lib being faster then 
another.


-- Felix Geisendörfer aka the_undefined
--
http://www.thinkingphp.org
http://www.fg-webdesign.de


Robert O'Rourke wrote:


Michael Stuhr wrote:


my results:
FF 2.0.0.4 WinXP-SP2
http://onenterframe.de/temp/

micha




Is Jquery slower because it's more compact then? ie. better for light 
usage?
I much prefer the syntax and the community around jquery. I never got 
any helpful responses from anyone on the mootools forum when I was 
using that library.


Rob




[jQuery] Re: Macrumors running live udpates of WWDC

2007-06-11 Thread Felix Geisendörfer


I have SERIOUS, SERIOUS doubts that there are 18 million people using 
Safari.
 
I doubt there are that many people using Macs to be perfectly honest.
I also think that FF numbers are underestimated and IE numbers 
overesimtated: See http://www.w3schools.com/browsers/browsers_stats.asp


-- Felix
--
http://www.thinkingphp.org
http://www.fg-webdesign.de


Andy Matthews wrote:
I have SERIOUS, SERIOUS doubts that there are 18 million people using 
Safari.
 
I doubt there are that many people using Macs to be perfectly honest.



*From:* jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] 
*On Behalf Of *

*Sent:* Monday, June 11, 2007 1:11 PM
*To:* jquery-en@googlegroups.com
*Subject:* [jQuery] Re: Macrumors running live udpates of WWDC

11:09 amSafari On WINDOWS
11:09 am18 Million Safari users
Marketshare has climbed to 4.9%
IE has 78%, Firefox 15%, others 2%
We Dream Big



On 6/11/07, *Shelane Enos* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:


That's a feature they've previously announced that I'm looking
forward to.


On 6/11/07 10:52 AM, ?ⓐⓚⓔ [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:

10:49 amusing safari to make widgets from web pages


Woo hoo!

On 6/11/07, *?ⓐⓚⓔ* [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:

thanks Shelane! I've been tuned in since 10 am!!!


On 6/11/07, *Shelane Enos*  [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  wrote:


Macrumors.com http://Macrumors.com
http://Macrumors.com  is running a continuous AJAX
update of the keynote address
of WWDC.  No more update in 60 seconds countdown.







--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ 


[jQuery] Re: Best way to determine if a user has Javascript enabled?

2007-04-21 Thread Felix Geisendörfer


Detecting if JavaScript is enabled is actually fairly straightforward.
No need to make it so complicated.
Well I think this thread is about how to detect if JS is enabled on the 
Server-side ; ). Your method of course is the way to go if all one needs 
is to display a msg to the user.


-- Felix
--
http://www.thinkingphp.org
http://www.fg-webdesign.de


Giant Jam Sandwich wrote:

Detecting if JavaScript is enabled is actually fairly straightforward.
No need to make it so complicated.

$(function(){
   $(#is_disabled).css(display,none);
});

...

div id=is_disabledYou have JavaScript disabled./div

 
  


[jQuery] Re: Best way to determine if a user has Javascript enabled?

2007-04-20 Thread Felix Geisendörfer
Didn't read the entire thread but appending parameters like this to an 
url just doesn't seem right to me.


Maybe your problem can be solved by looking if the client sent a 
X-Requested-With == 'XMLHttpRequest' header. That's how we in CakePHP 
find out if a page was requested via Ajax or not ; ).


Note: This is nothing the XMLHttpRequest adds itself, but I know jQuery 
and also Prototype do it for all their ajax requests for you.


-- Felix
--
http://www.thinkingphp.org
http://www.fg-webdesign.de