Skip to content

Commit

Permalink
On-the-fly change of css to hide/show (jQuery), should work, not tested
Browse files Browse the repository at this point in the history
Signed-off-by: emanuele <emanuele45@gmail.com>
  • Loading branch information
emanuele45 committed Jun 3, 2013
1 parent 0ee0eab commit 97945aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions themes/default/ProfileAccount.template.php
Expand Up @@ -318,11 +318,11 @@ function ajax_getTemplatePreview ()
data: {item: "warning_preview", title: $("#warn_sub").val(), body: $("#warn_body").val(), issuing: true},
context: document.body,
success: function(request){
$("#box_preview").css({display:""});
$("#box_preview").show();
$("#body_preview").html($(request).find(\'body\').text());
if ($(request).find("error").text() != \'\')
{
$("#profile_error").css({display:""});
$("#profile_error").show();
var errors_html = \'<span>\' + $("#profile_error").find("span").html() + \'</span>\' + \'<ul class="list_errors" class="reset">\';
var errors = $(request).find(\'error\').each(function() {
errors_html += \'<li>\' + $(this).text() + \'</li>\';
Expand All @@ -333,7 +333,7 @@ function ajax_getTemplatePreview ()
}
else
{
$("#profile_error").css({display:"none"});
$("#profile_error").hide();
$("#error_list").html(\'\');
}
return false;
Expand Down

5 comments on commit 97945aa

@Spuds
Copy link

@Spuds Spuds commented on 97945aa Jun 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be fine, but do note that doing the show/hide (vs css display block/none) is slower ... show/hide will make jquery remember /store the state of the display attribute of the element, but if you are not using / polling that state its just lost cycles.

@emanuele45
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the two are more or less the same:
http://jsperf.com/jquery-show-hide222222222222222222222222222222222222 (yes, the name is correct :P)
Hoping the test I wrote is meaningful. Of course both are much slower than using "pure js" (I did the test, but jQuery was like 94% slower and the results were difficult to compare).

BTW the rest of the code is not that nice... I should rewrite it...

@Spuds
Copy link

@Spuds Spuds commented on 97945aa Jun 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more or less

All how you define more and less 😃 ... but lets abuse jquery a bit ... http://jsperf.com/jquery-show-hide222222222222222222222222222222222222/2

Of course both are much slower than using "pure js"

Eeewwwwwww pure js! ... why when you know write 10 characters less code and have it run 99% slower :P

@emanuele45
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FF is basically the same...Chrome is so fast that compare them is useless! 😛

http://jsperf.com/jquery-show-hide222222222222222222222222222222222222/3

@Spuds
Copy link

@Spuds Spuds commented on 97945aa Jun 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And SeaMonkey is so slow that one wonders why anyone is using it 😄 Anyway the tests show there are faster options both jquery an pure ... all depends what you are doing with it that will determine if any change should even be considered.

Please sign in to comment.