source: extensions/automatic_size/picture_js.tpl @ 27153

Last change on this file since 27153 was 23168, checked in by plg, 11 years ago

bug fixed: incorrect width with Simple, because #theMainImage border and
margin were not taken into account.

File size: 1.4 KB
Line 
1{footer_script require='jquery'}{literal}
2jQuery().ready(function() {
3  if (jQuery("#theImage").size() > 0) {
4    function save_available_size() {
5      var width = jQuery("#theImage").width()
6      width -= {/literal}{$asize_width_margin}{literal};
7
8      if (jQuery("#theMainImage").size() > 0) {
9        var imageMarginWidth = jQuery("#theMainImage").outerWidth(true)-jQuery("#theMainImage").width();
10        width -= imageMarginWidth;
11      }
12
13      var docHeight = "innerHeight" in window ? window.innerHeight : document.documentElement.offsetHeight;
14      var offset = jQuery("#theImage").offset();
15      var height = docHeight - Math.ceil(offset.top);
16      height -= {/literal}{$asize_height_margin}{literal};
17
18      document.cookie= 'available_size='+width+'x'+height+';path={/literal}{$COOKIE_PATH}{literal}';
19    }
20
21    save_available_size();
22    jQuery(window).resize(function() {
23      save_available_size();
24    });
25
26    jQuery("#aSize").click(function() {
27      var is_automatic_size;
28
29      if (jQuery(this).data("checked") == "yes") {
30        is_automatic_size = "no";
31        jQuery("#aSizeChecked").css("visibility", "hidden");
32      }
33      else {
34        is_automatic_size = "yes";
35        jQuery("#aSizeChecked").css("visibility", "visible");
36      }
37
38      jQuery(this).data("checked", is_automatic_size);
39      document.cookie= 'is_automatic_size='+is_automatic_size+';path={/literal}{$COOKIE_PATH}{literal}';
40    });
41  }
42});
43{/literal}{/footer_script}
Note: See TracBrowser for help on using the repository browser.