[jQuery] jQuery AIR stripped

2009-04-17 Thread Spot


Someone might have already asked this, but I could not find anything.

Has there been any thought given to providing a dist of jQuery which has 
all cross-browser functionality and checks stripped, specifically for 
AIR? While those checks are limited and as streamlined as possible, 
would it not allow the most speed to be squeezed out of jQ in AIR?


[jQuery] Re: jQuery AIR stripped

2009-04-17 Thread Spot


Yeah, I can see why they would not be interested, but it might be pretty 
easy to mark cross browser checks, so that they can be parsed out. It 
wouldn't allow you to strip everything, but would think the browser 
checks could possibly be stripped.


However I could be completely off. :)

Andy Matthews wrote:

Interesting concept. I doubt that the jQuery team itself would approach that
project as it would require forked code, but it might be a fun project for
an individual.


andy 


-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Spot
Sent: Friday, April 17, 2009 9:05 AM
To: jQuery (English)
Subject: [jQuery] jQuery AIR stripped


Someone might have already asked this, but I could not find anything.

Has there been any thought given to providing a dist of jQuery which has all
cross-browser functionality and checks stripped, specifically for AIR? While
those checks are limited and as streamlined as possible, would it not allow
the most speed to be squeezed out of jQ in AIR?


  


[jQuery] Re: Plugin Development

2009-04-13 Thread Spot


Anyone else able to shed some light on this?

Spot wrote:


Nathan,

Ok, I am aware of the base use of each() (been coding in PHP for about 
eight years), but I cannot see how it is viable in this case.


Making a long story short...

This plug-in is a selector(auto-completer). To be more specific, it is 
several selectors. I have a specific plugin for each selector, and am 
$.extend()ing a base (external) DataSelector class, which has the 
boilerplate functionality (pulling data, building DOM elements, 
handling arrow keys, etc), and the plugins only have code specific to 
that data type.


The problem I am having, is that even when using two different 
plugins, I get namespace conflicts (e.g. the last called plugin on the 
page, overwrites the namespace for all the previous).


Ok, now because I am specifically hooking the plugin to only _one_ 
element each time, I cannot see how each() is helpful. Unless it needs 
to somehow return the one element with an index.


Does this make sense?

Again, I appreciate your assistance greatly.

Thanks!

Nathan wrote:

Yeah, Copy/paste gets ya no where for sure.

For each() you should check out: http://docs.jquery.com/Core/each
Which states: Execute a function within the context of every matched
element

From my previous example, this.each() is the same as saying:

$('#divNameHere').each();

So that runs your plugin only within that element.

So this:
$('#nav a', obj).click(function(){
$('#someDiv').fadeIn();
})

Is also this in each instance:
$('#divNameHere #nav a').click(function(){
$('#someDiv').fadeIn();
})

So it's changing out what '#divNameHere' is depending on what elements
you are applying your plugin to.

Hopefully that helps answer your question.

If you're not already. Use Firefox with Firebug and put something like
console.log('this is: ', this); in your plugin within the this.each()
funciton. Firebug then will log what this is in each instance. And FYI
console.log will give you a JS error in IE so comment it out before
testing in IE.








On Apr 7, 2:58 pm, Spot s...@napalmriot.com wrote:
 

Nathan, first off, thank you for responding.

I understand about passing the obj as scope. That makes perfect sense.
However I am a little confused as to the purpose of returning 
this.each.

What is the goal there?

I find it better to understand why something works, as opposed to just
copy/pasting. It saves everyone time in the long run. :)

Thanks again!



Nathan wrote:

   

To do this you need to have return this.each and optionally change
the instance of this which is the name of the object you are apply
the plugin to, to obj using var obj = $(this);.
  Then when you call a selector, you'll need to add $('#nav 
a', obj)

note the , obj.
  This will keep it within the name space of what ever selector 
you

apply this to when the plugin is initialize.
  (function($){
   $.fn.extend({
   plauginNameHere: function() {
   return this.each(function() {
   var obj = $(this); // this just changes 
the use of 'this' to obj

 $('#nav a', obj).click(function(){
   $('#someDiv').fadeIn();
   });
 })
   }
   });
})(jQuery);
  On the page level you will then need to initialize the plugin 
on the

HTML page level.
  script type=text/javascript charset=utf-8
   $(function(){
   $('#divNameHere'). plauginNameHere(); // first instance
   $('#secondDivNameHere'). plauginNameHere(); // second 
instance

   });
/script
  So what ever the selector name is above, for example
#secondDivNameHere, will then be the 'this' that we changed to 'obj'
using a var in plugin script. So in this example the plugin's obj is
#secondDivNameHere.
  Let me know if that helps.
  On Apr 6, 1:44 pm, Spot s...@napalmriot.com wrote:
 

How would one develop a plugin which can exist multiple times on the
same page, without conflicting with each others namespaces?



  


[jQuery] Re: Plugin Development

2009-04-07 Thread Spot


Nathan, first off, thank you for responding.

I understand about passing the obj as scope. That makes perfect sense. 
However I am a little confused as to the purpose of returning this.each. 
What is the goal there?


I find it better to understand why something works, as opposed to just 
copy/pasting. It saves everyone time in the long run. :)


Thanks again!


Nathan wrote:


To do this you need to have return this.each and optionally change
the instance of this which is the name of the object you are apply
the plugin to, to obj using var obj = $(this);.

Then when you call a selector, you'll need to add $('#nav a', obj)
note the , obj.

This will keep it within the name space of what ever selector you
apply this to when the plugin is initialize.

(function($){
$.fn.extend({
plauginNameHere: function() {
return this.each(function() {
var obj = $(this); // this just changes the use 
of 'this' to obj

$('#nav a', obj).click(function(){
$('#someDiv').fadeIn();
});

})
}
});
})(jQuery);

On the page level you will then need to initialize the plugin on the
HTML page level.

script type=text/javascript charset=utf-8
$(function(){
$('#divNameHere'). plauginNameHere(); // first instance
$('#secondDivNameHere'). plauginNameHere(); // second instance
});
/script

So what ever the selector name is above, for example
#secondDivNameHere, will then be the 'this' that we changed to 'obj'
using a var in plugin script. So in this example the plugin's obj is
#secondDivNameHere.

Let me know if that helps.





On Apr 6, 1:44 pm, Spot s...@napalmriot.com wrote:
  

How would one develop a plugin which can exist multiple times on the
same page, without conflicting with each others namespaces?



  


[jQuery] Re: Plugin Development

2009-04-07 Thread Spot


Nathan,

Ok, I am aware of the base use of each() (been coding in PHP for about 
eight years), but I cannot see how it is viable in this case.


Making a long story short...

This plug-in is a selector(auto-completer). To be more specific, it is 
several selectors. I have a specific plugin for each selector, and am 
$.extend()ing a base (external) DataSelector class, which has the 
boilerplate functionality (pulling data, building DOM elements, handling 
arrow keys, etc), and the plugins only have code specific to that data type.


The problem I am having, is that even when using two different plugins, 
I get namespace conflicts (e.g. the last called plugin on the page, 
overwrites the namespace for all the previous).


Ok, now because I am specifically hooking the plugin to only _one_ 
element each time, I cannot see how each() is helpful. Unless it needs 
to somehow return the one element with an index.


Does this make sense?

Again, I appreciate your assistance greatly.

Thanks!

Nathan wrote:

Yeah, Copy/paste gets ya no where for sure.

For each() you should check out: http://docs.jquery.com/Core/each
Which states: Execute a function within the context of every matched
element

From my previous example, this.each() is the same as saying:

$('#divNameHere').each();

So that runs your plugin only within that element.

So this:
$('#nav a', obj).click(function(){
$('#someDiv').fadeIn();
})

Is also this in each instance:
$('#divNameHere #nav a').click(function(){
$('#someDiv').fadeIn();
})

So it's changing out what '#divNameHere' is depending on what elements
you are applying your plugin to.

Hopefully that helps answer your question.

If you're not already. Use Firefox with Firebug and put something like
console.log('this is: ', this); in your plugin within the this.each()
funciton. Firebug then will log what this is in each instance. And FYI
console.log will give you a JS error in IE so comment it out before
testing in IE.








On Apr 7, 2:58 pm, Spot s...@napalmriot.com wrote:
  

Nathan, first off, thank you for responding.

I understand about passing the obj as scope. That makes perfect sense.
However I am a little confused as to the purpose of returning this.each.
What is the goal there?

I find it better to understand why something works, as opposed to just
copy/pasting. It saves everyone time in the long run. :)

Thanks again!



Nathan wrote:



To do this you need to have return this.each and optionally change
the instance of this which is the name of the object you are apply
the plugin to, to obj using var obj = $(this);.
  
Then when you call a selector, you'll need to add $('#nav a', obj)

note the , obj.
  
This will keep it within the name space of what ever selector you

apply this to when the plugin is initialize.
  
(function($){

   $.fn.extend({
   plauginNameHere: function() {
   return this.each(function() {
   var obj = $(this); // this just changes the use of 
'this' to obj
  
   $('#nav a', obj).click(function(){

   $('#someDiv').fadeIn();
   });
  
   })

   }
   });
})(jQuery);
  
On the page level you will then need to initialize the plugin on the

HTML page level.
  
script type=text/javascript charset=utf-8

   $(function(){
   $('#divNameHere'). plauginNameHere(); // first instance
   $('#secondDivNameHere'). plauginNameHere(); // second instance
   });
/script
  
So what ever the selector name is above, for example

#secondDivNameHere, will then be the 'this' that we changed to 'obj'
using a var in plugin script. So in this example the plugin's obj is
#secondDivNameHere.
  
Let me know if that helps.
  
On Apr 6, 1:44 pm, Spot s...@napalmriot.com wrote:
  

How would one develop a plugin which can exist multiple times on the
same page, without conflicting with each others namespaces?



  


[jQuery] Multiple Plugins on the same page

2009-04-06 Thread Spot


I have searched this extensively, so if it has been covered, please 
forgive me.


Let's see if I can describe this without confusing anyone.

We have a recurring need to give users quick lookup access to several 
tables of information. Therefore we use a custom build 
autocompleter/selector system.


Here is how it's laid out.

We have a jQ plugin for each different selector... and each of those 
$.extend()'s DataSelector, which holds the meat of the entire process.


Each plugin sets up the methods/vars which are specific to itself, and 
extends that over DataSelector.


The problem occurs when trying to use more than one of these selectors 
on the same page.


The last selector used overwrites all the vars, so that every selector 
acts like the last one.


I could somewhat understand this if it were several instances of the 
same type of selector, but it even happens with different types.


So my main question is, where can I find information on building plugins 
so that there can more than one instance running on the same page. I 
think if I can find out how it's normally accomplished, then I can 
modify that to work in this situation.



I apologize for the long post, and thank you in advance for any 
assistance you can provide.


Thanks,
Spot


[jQuery] Re: Multiple Plugins on the same page

2009-04-06 Thread Spot


Just to expand on this quickly...

It acts like $.extend() is referencing DataSelector, as opposed to 
copying it like the docs say it does.


*shrug*

Spot wrote:


I have searched this extensively, so if it has been covered, please 
forgive me.


Let's see if I can describe this without confusing anyone.

We have a recurring need to give users quick lookup access to several 
tables of information. Therefore we use a custom build 
autocompleter/selector system.


Here is how it's laid out.

We have a jQ plugin for each different selector... and each of those 
$.extend()'s DataSelector, which holds the meat of the entire process.


Each plugin sets up the methods/vars which are specific to itself, and 
extends that over DataSelector.


The problem occurs when trying to use more than one of these selectors 
on the same page.


The last selector used overwrites all the vars, so that every selector 
acts like the last one.


I could somewhat understand this if it were several instances of the 
same type of selector, but it even happens with different types.


So my main question is, where can I find information on building 
plugins so that there can more than one instance running on the same 
page. I think if I can find out how it's normally accomplished, then I 
can modify that to work in this situation.



I apologize for the long post, and thank you in advance for any 
assistance you can provide.


Thanks,
Spot


[jQuery] Re: Another newbie how do I

2009-04-06 Thread Spot


Jerry,

It sounds like you want a very very simple solution to this, so I am 
going to give it to you. This is _not_ considering clean. :)


You could give each of your line items a unique id like id=line-1  
id=line-2  etc.


Give your text container an id... like id=text-container

Then you should be able to bind clicks to them like this...

$('#line-1').click(function() {
   $('#text-container').html('two or three paragraphs appear, 
describing greyhounds,
   whippets, Italian 
greyhounds, their relative size, average top 
   speed, and so on.');

});

And repeat that for each line item. Again, this is like the most simple 
it can possibly be done. If you want to know more, look up each of those 
methods (click / html) in the jQuery docs.


Hope this helps!

Spot

Jerry wrote:

Hi all.

I'm totally new to jQuery, but have been assured this is the place to
do stuff.

I'm still trying to work through the most basic basics, but in the
meantime, hoping I can find an example of how to do this.

On a given web page, the user sees two side-by-side areas of text
(i.e. two columns).

On the left is a vertical bullet list of lines of text.
On the right is a container for text.  The contents of the container
vary according to which item in the bullet list is clicked.

In other words, if the user clicks on the 3rd one-line statement, the
box on the right has a corresponding body of text.

Example:
On the left, click on a line that reads Sight-hounds and other fast
dogs.
On the right, two or three paragraphs appear, describing greyhounds,
whippets, Italian greyhounds, their relative size, average top speed,
and so on.

Both the left and right boxes will be sized the same.

Is this doable?  If so, does someone have a working example I can look
at, please.

I'm primarily a photographer, not a developer so need to ask your
patience (and maybe use small words :))

Thank you very much!
Jerry

  


[jQuery] Re: jQuery.support -- No direct support for IE6 detection

2009-04-06 Thread Spot


Yes, key handling support would be a god send!

akzhan wrote:

Also I suppose that jQuery.support can add key handling browser mode.

WebKit, Mozilla and IE works different on key events.

On Apr 5, 8:45 am, Ricardo ricardob...@gmail.com wrote:
  

jQuery.support is for feature detection. The whole point of it is to
avoid browser detection - which is still available via jQuery.browser.
Instead of sniffing the browser and serving fixes according to
previous knowledge about it's flaws, you check for correct
implementations of the exact features you need, browser agnostic.

cheers,
- ricardo

On Apr 4, 1:43 pm, Joe joseph.is...@gmail.com wrote:



I'm all for migrating to the jQuery.support() utility method, but
there is not definitive test available to detect IE6 specifically.  Do
we have a consensus on this yet?
  


  


[jQuery] Plugin Development

2009-04-06 Thread Spot


How would one develop a plugin which can exist multiple times on the 
same page, without conflicting with each others namespaces?


[jQuery] Re: .append() into style element causes error in IE only

2009-01-27 Thread Spot

Hi, I found this thread when searching on this subject.

I have an app here where we let the user customize almost every single 
piece of the UI. This requires that we dynamically generate the CSS off 
a tagged template.

What I want to be able to do is completely scrap the current style data 
and replace it with a new copy. So far everything I have tried has not 
worked.

This solution looks great except that the style data could get very big 
if the user decides to make many changes to UI settings.

So I am looking for something like this, but does a replace as opposed 
to just an append.

Suggestions will be greatly appreciated.

Thanks.


Ricardo Tomasi wrote:
 appendChild on a style element fails on IE and you get an unknown
 error if you try to modify it's innerHTML. I haven't found any
 workaround.

 Use this to add styles:

 //addStyles 0.1
 // Ricardo Tomasi  ricardobeat at gmail com 
 // Licensed under the WTFPL - http://sam.zoy.org/wtfpl/
 function addStyles(rule){
  var sheet = document.styleSheets[0],
   ln = (sheet.cssRules||sheet.rules).length;
  if (sheet.addRule) {
  rule = rule.match(/(.*){(.*)}/);
  sheet.addRule(rule[1],rule[2], ln);
  } else {
  sheet.insertRule(rule, ln);
  };
  return arguments.callee;
 };
 addStyle(#div{display:none});

 the 'return arguments.callee' line is there to allow for some funky
 construction, you can remove it if you want:

 addStyle
 ('div { background: xxx }')
 ('.menu { whatever: #45 }')
 ('.hold { float: left }')

 This script will insert rules at the end of the stylesheet, that's
 important so that you can override earlier styles.

 cheers,
 - ricardo

 On Jan 15, 8:07 am, Ant kalli...@gmail.com wrote:
   
 Hi,
 Yea, I went for adding a new style element for every new style, which
 works, but isn't as neat as I was hoping for.
 I was trying to append a string into the style element:
 HTML
 style type=text/css
 body{color:#333;}
 /style
 JS
 $(style).append(#content{color:#f00;});
 In Firefox, this adds #content(color:#f00;} beneath the body
 declaration.
 Which is what I would expect to happen.
 In IE I get an error thrown in jquery-1.3b2.js

 It may well be that my expectations of append are wrong, if so, it
 would be a useful thing for me to know as I am quite new to jQuery.
 Many thanks for your time,
 Ant

 Ricardo Tomasi wrote:
 
 What are you trying to append? You can only append textnodes to a
 style element.
   
 Why not use the stylesheet object directly:
   
 document.styleSheets[0].insertRule(#wrapper {display:none}, 0) //
 'addRule' on IE
   
 Or, for a hassle-free alternative, create a new style element for it:
   
 $('style type=text/css/style').text(myClass).appendTo('head');
   
 On Jan 14, 12:05 pm, Ant kalli...@gmail.com wrote:
   
 Hi,
 I am trying to append css into a pre existing style element.
 $(style).append(myClass);
 This works as expected in Firefox, but not IE.
 The HTML on the page validates to HTML strict, so I'm fairly sure that
 it's not the issue with IE that append() won't work on incorrectly
 written elements.
 If I change my code to $(p).append(myClass); it works as expected.
 
 Was just wondering if this is a know issue with IE or jQuery and if
 anyone had a work around, I am out of ideas that don't involve
 considerable effort :)
 
 Thanks,
 Ant