[jQuery] Tablesorter - sort callback or sort based on external options...

2007-10-16 Thread Dmitrii 'Mamut' Dimandt

I have a table with a single column whose cells contain complex markup.

Let's say this markup contains a name and a price:

div
span class=item-nameName/span
span class=item-price70/span
/div


I have external links that let you sort on name or price:
  

var sort_by = 'name';

 $('#sort-by-price').click(
function(){
sort_by = 'price';

$('#results').trigger('sorton', [[[0, 1]]]);
return false;
}
);

I have a custom parser and data retriever:
$.tablesorter.addParser({
// set a unique id
id: 'itemsort',
is: function(s) {
return true;
},
format: function(s) {
return s;
},
type: 'numeric'
});

results.tablesorter({
headers: {
0: {
sorter:'hotelsort'
}
},
textExtraction: extractSortData
});

function extractSortData(n)
{
var node = $(n);
   
if(sort_by == 'price')
{
return node.find('span.item-price').text();
}
else if(sort_by == 'name')
{
return 1 /* for the purposes of the example*/;
}
}


However, this parser is only called once when the tablesorter is
initialized, so regardless of the click the table is still sorted by
name not by price. How do I make tablesorter reparse the table with new
values?


[jQuery] Re: UI tabs - find unique

2007-09-26 Thread Dmitrii 'Mamut' Dimandt

Richard D. Worth wrote:
 Please ask on the jQuery UI list:

 http://groups.google.com/group/jquery-ui

Sorry, didn't realize there was one :)


[jQuery] Ajax Tabs - multiple loads problem

2007-09-25 Thread Dmitrii 'Mamut' Dimandt

I've found a strange bug with jQuery tabs.

Let's say you add a new Ajax tab, let's call it tab-1. When you click on
it, a request is sent to the server.

Add another Ajax tab, let's call it tab-2. When you click on it, a
request is sent to the server. When you click on tab-1, the request to
the server is sent *twice*

Add a third Ajax tab, tab-3. Now clicking on
- tab-3 sends *one* request
- tab-2 sends *two* requests
- tab-3 sends *three* requests

And so on.


[jQuery] IE, Ajax and colspans

2007-09-10 Thread Dmitrii 'Mamut' Dimandt

I'm having a very weird problem that manifests itself only in IE - both
6.x and 7.x

I use taconite to retrieve a table from the server:

taconite
replaceContent select=#data
table style=width: 90%
 tbody
 tr
 td style=border: 1px solid #efefef; 
padding: 10px; valign=top
 /td
 td style=border: 1px solid #efefef; 
padding: 10px; valign=top
 strongBoard/strong
 /td
 td style=border: 1px solid #efefef; 
padding: 10px; valign=top colspan=2
 strong1 ADL/strong
 /td
 td style=border: 1px solid #efefef; 
padding: 10px; valign=top colspan=2
 strong1 ADL + 1 CHLD 
7-12/strong
 /td
 td style=border: 1px solid #efefef; 
padding: 10px; valign=top colspan=2
 strong1 ADL + 2 CHLD 
7-12/strong
 /td
/tr
tr
 td style=border: 1px solid #efefef; 
padding: 10px; valign=top
 Standart Room
 /td
 td style=border: 1px solid #efefef; 
padding: 10px; valign=top
 BB
 /td
 td align=center style=border: 1px 
solid #efefef; padding: 10px; valign=top125/td
 td align=center style=border: 1px 
solid #efefef; padding: 10px; valign=topstrong166/strong/td

 td align=center style=border: 1px 
solid #efefef; padding: 10px; valign=top140/td
 td align=center style=border: 1px 
solid #efefef; padding: 10px; valign=topstrong185/strong/td

 td align=center style=border: 1px 
solid #efefef; padding: 10px; valign=top158/td
 td align=center style=border: 1px 
solid #efefef; padding: 10px; valign=topstrong249/strong/td
/tr
/tbody
/table
/replaceContent
/taconite


When this taconite gets executed IE disregards the colspans and places a
single cell in each column:
Expected:
 --
|   |
 --
|   |   |
 --

Explorer:

 --
|   |
 --
|   |   |
 --


And I have no freaking idea why this is happening. Please, help :)


[jQuery] Re: tr[position() mod 3 = 0]

2007-08-10 Thread Dmitrii 'Mamut' Dimandt

John Resig wrote:
 As of jQuery 1.1.3 you can now do:
 $(tr:nth-child(3n))

   
Sorry for the late replay, but thank you!


[jQuery] Re: tr[position() mod 3 = 0]

2007-08-10 Thread Dmitrii 'Mamut' Dimandt
Sean Catchpole wrote:
 Dmitrii, the code Erik Beeson pasted works, here's another option:
 $.extend({expr:{::{mod: i%m[3]==0}}}); //adds mod selector

 $(tr:mod(3))


 ~Sean 
Sorry for the late reply. This is amazing!


[jQuery] Datepicker. Hide dates from next/prev month

2007-08-03 Thread Dmitrii 'Mamut' Dimandt

Hi all.

Right now the default behaviour of Kevin's datepicker,
http://kelvinluck.com/assets/jquery/datePicker/v2/demo/, is to show the
dates from the previous/next month as well as the dates from the current
month.

What would be the easy way to make the datepicker show the dates from
the current month only?

Thank you


[jQuery] tr[position() mod 3 = 0]

2007-07-30 Thread Dmitrii 'Mamut' Dimandt

What would be the jQuery way of doing tr[position() mod 3 = 0] ?

Thank you!



[jQuery] Re: tr[position() mod 3 = 0]

2007-07-30 Thread Dmitrii 'Mamut' Dimandt

Erik Beeson wrote:
 Untested:

 $('tr').filter(function(position) { return position % 3 == 0; });

I haven't tested it, but thanks anyway :)


[jQuery] Re: Attn. developers. Speed of getElementById

2007-06-27 Thread Dmitrii 'Mamut' Dimandt

Rey Bango wrote:

 Hi Dmitrii,

 Unfortunately, this isn't a JavaScript support mailing list. The list
 is here to support jQuery users. There are some great JavaScript
 support forums at WebmasterWorld and SitePoint.

 If you have a specific jQuery issue, we'll be glad to help.
Yeah, I know :) I just posted it here for others to see. I might repost
it to jQuery Dev list


[jQuery] Attn. developers. Speed of getElementById

2007-06-22 Thread Dmitrii 'Mamut' Dimandt




The original is in Russian:
http://blogs.gotdotnet.ru/personal/poigraem/PermaLink.aspx?guid=88FECDF4-739C-46C0-8496-589EFD553B60

Here's a quick translation:

We've hit a problem where getElementById is working slowly on a _very_
large page

After some research we've found out some interesting facts

- Speed of getElementById depends on the length of ids. Tests have
shown that for two identical documents, one with ids like a,
another with ids like , the speed
of getElementById would differ by a factor of two. This is especially
important for ASP.NET pages which usually have long ids 

- There are fast methods and slow methods:
-- Fast
 parentNode
 nextSibling
 ownerDocument
 firstChild
-- Slow
 previousSibling
 getElementById
 lastChild

The getElemenByTagName has a paradox. It returns the list of elements
very quickly. However, access to elements from that list is very slow.
It feels as if it were returning a proxy of sorts.

In a large tree it's faster to collect a hash of all element ids than
use getElementById. This may look like this:
[code]
function build_document_id_map()
   {
   var r = document;
   map = {}
   build_id_map( r, map )
   return map
   }

function build_id_map( node, map )
   {
   for ( var e = node.firstChild; e != null; e = e.nextSibling )
   {
   if ( e.id ) map[ e.id ] = e;
   if (e.firstChild ) build_id_map( e, map )
   }
   }

var cache;
function get_element_by_id( id )
{
if ( !cache )
cache = build_document_id_map(id)
return cache[id];
}
[/code]

To test this, you may use the test I wrote:
http://files.rsdn.ru/11521/test.htm

For each type of element access the test prepares test data anew and
runs the test three times. These three times appear in the table in
milliseconds
getDocumentById - find all nodes through
getDocumentById
getDocumentById2 - same, but after the test is run
there is a small DOM manipulation in the end. See below for explanation
of the test.
get_element_by_id -  find all nodes using the
get_element_by_id described above. The ids cache is cleared every time
before the test is run.
get_element_by_id2 -  same, but the cache is not
cleared. Expect to see speed increase in the second and the third run.
Here's the table of results for my FF:
http://files.rsdn.ru/11521/test_results.PNG


Note that FF caches results of getDocumentById and in the first test
the second and the third pass are much faster than the first one. But
as soon as we manipulate the DOM even a little, the cache is reset, as
we see it in the second test

I'm not going to comment on the third and the fourth test, the numbers
speak for themselves. I'm going to talk about disadvantages

The method works well for a static tree. If the tree is being changed,
there's problems with adding/removing elements. The problem of adding
elements can easily be solved by:
function get_element_by_id( id )
{
if ( !cache )
cache = build_document_id_map( id )
if( !cache[id] )
cache[id] = document.getElementById( id );
return cache[id];
}

Removal of elements in this case can only be done by a special method
which will correct the cache. In this case you can forget about 
someElem.innerHTML = "";
if you wish to remove a large portion of the tree





[jQuery] Compressed validator failing in IE 6.0

2007-06-02 Thread Dmitrii 'Mamut' Dimandt

Is there a way to make the compressed version of the validator plugin
work in IE? Because 5-6 KB of the compressed version is way better than
the 43 KB of the uncompressed version in terms of size.

IE fails somewhere inside the packed function with all sorts of weird
errors, the most innocent of which is ; is expected

:(



[jQuery] Re: Tabs decoration question

2007-05-25 Thread Dmitrii 'Mamut' Dimandt

Klaus Hartl wrote:

 Sean Catchpole wrote:

 Clever CSS is the solution.
 Set the top border of the tabs-container to 1px.
 Set the bottom-margin of the current tabs to -1px

 That should do the trick. If it doesn't work or you're confused, post
 a link of a page where this is and I'll try to give you exactly the
 css you need.

 ~Sean


 such css is already in place in the current style sheet delivered with
 the plugin. i'm using relative positioning though to push the current
 tab onto the container's border because negative vertical margins
 sometimes do not work reliably in IE, or you at least need to apply
 position: relative; anyway in IE to make it work. The trick is, that
 the current tab needs to be 1px higher than the rest to have them
 still in one line on top.

 apart from the background images used for the tab look its completely
 the same CSS setup. The first tabs looked very similiar to whats
 required here.




Can't get it to work :( Neither with negative margins nor with relative
positioning. It gets screwed up in all browsers but Firefox ;(

http://dmitriid.com/jquery/troubles/tabs/


[jQuery] Tabs decoration question

2007-05-24 Thread Dmitrii 'Mamut' Dimandt

Right now there is a horizontal line between the tab and its content.
However, our designer wants that there would be no border between the
active tab and its content. Is this doable?

Thank you


[jQuery] Re: Tabs decoration question

2007-05-24 Thread Dmitrii 'Mamut' Dimandt

Klaus Hartl wrote:

 Dmitrii 'Mamut' Dimandt wrote:
 Right now there is a horizontal line between the tab and its content.
 However, our designer wants that there would be no border between the
 active tab and its content. Is this doable?

 Thank you


 Yes it is, that's just a matter of the CSS. Just remove the following
 line in jquery.tabs.css (line 90, the rule with the selector
 .tabs-container):

 border-top: 1px solid #97a5b0;


Well... That's not exactly what I need. I need to keep the horizontal
line as is and only remove it under the active tab title


[jQuery] Re: question about a javascript syntax

2007-05-18 Thread Dmitrii 'Mamut' Dimandt


Look at this article: http://www.hunlock.com/blogs/Functional_Javascript

It explains a lot of things about functions including your question


 I found Jörn Zaefferer's jQuery plugin authoring guide at
 http://bassistance.de/2006/12/27/jquery-plugin-authoring-guide/,
 there i found javascript syntax like this:
 
 (function() {
  // some code here
 })();
 
 (function($) {
  // some code here
 })(jQuery);
 
 it really works,but i donno what exactly this syntax means,anyone can
 explain it? great thanks!




[jQuery] Tablesorter. Disable sorting on column

2007-05-10 Thread Dmitrii 'Mamut' Dimandt

I have to disable sorting on the first two columns in my table. Are
there any options that I can pass to tablesorter plugin that will
disable sorting on selected columns?

Thank you


[jQuery] Forms, Tables and jQuery

2007-05-02 Thread Dmitrii 'Mamut' Dimandt
I'll repost it from a russian forum (from here:
http://rsdn.ru/Forum/Message.aspx?mid=2469963)

Firefox/Opera won;t find form elements if the form tag is placed between
table and tr tags:

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
html
head
titleinput type query tests/title
script type=text/javascript src=./jquery.js/script
script type=text/javascript
$(document).ready(function() {
// Traditional iteration over elements (works always in every browser)
var fElements = document.forms['form1'].elements;
for (var i = 0; i  fElements.length; i++) {
alert(fElements[i].name + = + fElements[i].value);
}

// Can we find the form itself? (Yes)
alert($([EMAIL PROTECTED])[0].name);

// Traditional method (Opera/Firefox can't find anything)
$([EMAIL PROTECTED] input).each(function() {
alert(this.name + = + this.value);
});

// Advanced (Opera/Firefox can't find anything)
$(#form1 :checkbox).each(function() {
alert(this.name + = + this.value);
});
});
/script
/head
body

table
*form name=form1 action=? method=POST*
tr
td
input type=checkbox name=chbx1 value=1chbx1br/
input type=text name=txt1 value=2br/

input type=radio name=radio1 value=3chbx[]br/
input type=hidden name=hid1 value=4br/
/td
/tr
/form
/table

/body
/html



A small discussion started. Correct browsers probably remove the form
tag and place it outside the table element. The original poster
suggested out that jQuery should iterate over form.elements if special
form selectors are used because a lot of legacy code uses incorrectly
placed form tags.

So the question is: How can we find form elements when the form tag is
incorrectly placed in the table tag? Using jQuery of course :)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
jQuery (English) group.
To post to this group, send email to jquery-en@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-en?hl=en
-~--~~~~--~~--~--~---



[jQuery] Re: Taconite, tables and IE

2007-04-25 Thread Dmitrii 'Mamut' Dimandt

Worked like a charm. Thank you!

Mike Alsup wrote:

 Try changing that to use a tbody:

 tabletbody

yada yad yada ...

 /tbody/table


 Here's my taconite:

 append select=#data
  table
 tr
 td
 65
 /td
 /tr
 tr
 td
 70
 /td
 /tr
 /table
 /append

 It works fine in Firefox and Opera. In IE, however, the table doesn't
 show up. Other elements like div's and input's are displayed correctly

 alert($('#data').html()); displays all the appended html correctly

 What could be the problem? :(




[jQuery] Re: datePicker v2 beta

2007-04-24 Thread Dmitrii 'Mamut' Dimandt

Kelvin Luck wrote:
 Hi,

 I'd like to announce the beta release of v2 of my datePicker plugin for 
 jQuery. This release is a complete rewrite which makes the date picker 
 considerably more powerful and flexible than it previously was. Check out the 
 temporary project page:

 http://kelvinluck.com/assets/jquery/datePicker/v2/demo/

 Note, this is currently in beta and may be a little rough around the edges 
 but I'd love to get some feedback. I've tested in FF2, IE6 and Opera 9 but it 
 would be good to know if it works in other browsers (particulaly Safari). 
 Plus any other feedback on extra stuff you'd like adding or bugs you discover,

   
Wow. This looks truly amazing!


[jQuery] Re: The University of Murcia (Spain) takes jQuery as main JS Library for all new projects

2007-04-19 Thread Dmitrii 'Mamut' Dimandt

SeViR wrote:

 Hi there,

 recently I presented a seminar of JavaScript programming with jQuery
 in The University of Murcia (Spain) and the results are very good.

 http://www.um.es/atica/mncs/forja  (sorry in *spanish*)
Wow. Thank you for the link to YAV, http://yav.sourceforge.net/ that I
found on the university site. This is amazing!


[jQuery] Re: The University of Murcia (Spain) takes jQuery as main JS Library for all new projects

2007-04-19 Thread Dmitrii 'Mamut' Dimandt

Jörn Zaefferer wrote:
 I'm gonna take a look at that library for some inspiration. And maybe
 copy some validation methods (called rules at yav).

 Let me know if you have any specific requests for the jQuery
 validation plugin.

That would be the pre-condition, implies and post-condition. Those
definitely rule




[jQuery] Re: The University of Murcia (Spain) takes jQuery as main JS Library for all new projects

2007-04-19 Thread Dmitrii 'Mamut' Dimandt

Jörn Zaefferer wrote:

 Dmitrii 'Mamut' Dimandt schrieb:
 Jörn Zaefferer wrote:
  
 I'm gonna take a look at that library for some inspiration. And maybe
 copy some validation methods (called rules at yav).

 Let me know if you have any specific requests for the jQuery
 validation plugin.

 
 That would be the pre-condition, implies and post-condition. Those
 definitely rule
   
 That is an interesting concept that I'm currently trying to understand.

 My plugin supports required-dependencies using expressions and
 functions, but they have their limit.

 This would make field2 required only if field1 is blank:

 rules: {
  field2: { required: #field1:blank }
 }

 But I can't express that either field1 or field2 is required. How
 would I express that using pre/post-condition and implies?

That I don't know :)

'implies' is best seen with the advanced form in the example
(http://yav.sourceforge.net/en/learnbyexample.html). See how validation
on the last input field changes depending on what's selected in the
combo box.

If you chose email the input is validated against one set of rules:

rules[15]='contactType|equal|phone|pre-condition';
rules[16]='contact|regexp|^[0-9]{10}$|post-condition';
rules[17]='15|implies|16|Enter a phone (ten digits)

So if contactType value changes to phone, contact is validated against
^[0-9]{10}$

However:

rules[18]='contactType|equal|e-mail|pre-condition';
rules[19]='contact|regexp|[EMAIL PROTECTED]|post-condition';
rules[20]='18|implies|19|Enter a valid e-mail'

If contactType becomes 'e-mail' contact is validated against [EMAIL PROTECTED]


Same is with the 'Name required' checkbox. If the checkbox is checked,
you must input a name:

rules[11]='nameRequired|equal|checked|pre-condition';
rules[12]='name|required|post-condition';
rules[13]='11|implies|12|name required';



I guess what you want is something like:

rules[1]='field1|equal||pre-condition';
rules[2]='field2|regexp|^a-zA-Z$|post-condition';
rules[3]='1|implies|2|Enter either field 1 or field 2';

rules[4]='field2|equal||pre-condition';
rules[5]='field1|regexp|^a-zA-Z$|post-condition';
rules[6]='4|implies|5|Enter either field 1 or field 2';

Or some such. I'm not sure (I'm guessing from the examples, never used
the validator myself :) )



[jQuery] Re: The University of Murcia (Spain) takes jQuery as main JS Library for all new projects

2007-04-19 Thread Dmitrii 'Mamut' Dimandt



 I guess what you want is something like:

 rules[1]='field1|equal||pre-condition';
 rules[2]='field2|regexp|^a-zA-Z$|post-condition';
 rules[3]='1|implies|2|Enter either field 1 or field 2';

 rules[4]='field2|equal||pre-condition';
 rules[5]='field1|regexp|^a-zA-Z$|post-condition';
 rules[6]='4|implies|5|Enter either field 1 or field 2';

 Or some such. I'm not sure (I'm guessing from the examples, never used
 the validator myself :) )
   
Nope. I guess the answer would be something like this, I guess:

rule[1]= 'field1|regexp|^a-zA-Z$';
rule[2]= 'field2|regexp|^a-zA-Z$';
rule[3]= '1|and|2|Either field 1 or field 2 must be filled in';


[jQuery] Re: Spam on this list

2007-04-18 Thread Dmitrii 'Mamut' Dimandt

Christof Donat wrote:
 Hi,

 Since this list is a google group I recieve considerably more spam over this 
 list. Is that just me, or has anybody made the same experience?

 Christof

   
Subscribe to this group via gmail :) It cuts off spam


[jQuery] Re: åäö doesn't work with load ()

2007-04-11 Thread Dmitrii 'Mamut' Dimandt
Internet Explorer works reliably only with utf-8
Even if your entire site is ISO-..., you can still use utf-8 for all
your ajax-related stuff, i think

badtant wrote:
 my whole site is in ISO-8859-1 and it's to much work right now to
 convert to UTF-8. i think that this is something that should work
 automaticly.

 /N

 On Apr 11, 11:04 am, Mariusz Cieśla [EMAIL PROTECTED] wrote:
   
 Can't you just try to use UTF-8 for the pages? Conversion isn't hard
 and still it solves most problems with special characters. ; )

 Cheers,
 M.
 


   



[jQuery] Sort a table when a button is pressed

2007-04-03 Thread Dmitrii 'Mamut' Dimandt

Hi.

A friend of mine is using the tablesorter plugin on one of the tables on
the page. He needs to sort a column when a button on the page is
pressed. That is, not the header of the column, but a completely
separate button on the page.

How can this be achieved?

Thank you




[jQuery] Re: Sort a table when a button is pressed

2007-04-03 Thread Dmitrii 'Mamut' Dimandt

Jeez. That really is the most obvious solution :)


Jake McGraw wrote:

 Not sure this is the best way, but you could simulate a click on the
 header when the button is clicked like this:

 $([EMAIL PROTECTED]).click(function(){
 $(table th:eq(0)).click();
 });

 This will cause the first column (th:eq(0)) to be clicked and then
 sorted when a button is clicked. Note that $().click() without any
 arguments simulates a click.

 - jake

 On 4/3/07, Dmitrii 'Mamut' Dimandt [EMAIL PROTECTED] wrote:

 Hi.

 A friend of mine is using the tablesorter plugin on one of the tables on
 the page. He needs to sort a column when a button on the page is
 pressed. That is, not the header of the column, but a completely
 separate button on the page.

 How can this be achieved?

 Thank you