Plugin Directory

Changeset 607313


Ignore:
Timestamp:
10/03/2012 05:18:51 AM (13 years ago)
Author:
attosoft
Message:

FIXED: Invalid positioning. some mobile browsers, such as older iOS (iPhone/iPad/iPod touch) and older Android, do not support position:fixed style.

Location:
auto-thickbox-plus/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • auto-thickbox-plus/trunk/readme.txt

    r607300 r607313  
    282282* NEW: "View - Margin - Window" option
    283283* CHANGED: Removed CSS hacks for IE6. Replaced CSS Expression with JavaScript.
     284* FIXED: Invalid positioning. some mobile browsers, such as older iOS (iPhone/iPad/iPod touch) and older Android, do not support `position:fixed` style.
    284285* FIXED: Gallery images cannot be displayed in gallery style with [Cleaner Gallery](http://wordpress.org/extend/plugins/cleaner-gallery/)
    285286
  • auto-thickbox-plus/trunk/thickbox.js

    r607300 r607313  
    5757    imgLoader = new Image();// preload image
    5858    imgLoader.src = tb_pathToImage;
     59
     60    var result, ua = navigator.userAgent;
     61    var webKitMatch = (result = ua.match(/AppleWebKit\/([0-9]+)/)) && result[1] < 534;
     62    var operaMobiMatch = (result = ua.match(/Opera Mobi\/([0-9]+)/)) && result[1] < 7458;
     63    var fennecMatch = (result = ua.match(/Fennec\/([0-9]+)/)) && result[1] < 6;
     64
     65    notSupportedPositionFixed =  typeof document.body.style.maxHeight == 'undefined' // IE < 7
     66        || (/(iPhone|iPod|iPad)/.test(navigator.platform) && webKitMatch) // iOS < 5 (iPhone/iPad/iPod touch)
     67        || (ua.indexOf("Android") > -1 && webKitMatch) // Android < 3.0
     68        || (window.operamini && Object.prototype.toString.call(window.operamini) === "[object OperaMini]") // Opera Mini
     69        || operaMobiMatch // Opera Mobile < 11.0
     70        || fennecMatch // Firefox for Mobile < 6.0
     71        || (window.palmGetResource && webKitMatch) // HP webOS < 3.0
     72        || (ua.indexOf("MeeGo") > -1 && ua.indexOf("NokiaBrowser/8.5.0") > -1); // MeeGo
    5973});
    6074
     
    110124function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
    111125    try {
    112         if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
     126        if (notSupportedPositionFixed) {//if IE 6
    113127            jQuery("body","html").css({height: "100%", width: "100%"});
    114128            jQuery("html").css("overflow","hidden");
    115             if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
    116                 jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
     129            if (typeof document.body.style.maxHeight == "undefined" && document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
     130                jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe>");
     131            }
     132        }
     133        if(document.getElementById("TB_overlay") === null){
     134            jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
     135            if (notSupportedPositionFixed) {
    117136                jQuery("#TB_overlay, #TB_HideSelect").css({
    118137                    position: 'absolute',
    119138                    height: (document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight) + 'px'
    120139                });
    121                 if (tb_options.click_bg == "close")
    122                     jQuery("#TB_overlay").click(tb_remove);
    123             }
    124         }else{//all others
    125             if(document.getElementById("TB_overlay") === null){
    126                 jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
    127                 if (tb_options.click_bg == "close")
    128                     jQuery("#TB_overlay").click(tb_remove);
    129             }
     140            }
     141            if (tb_options.click_bg == "close")
     142                jQuery("#TB_overlay").click(tb_remove);
    130143        }
    131144
     
    137150
    138151        jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
    139         if (typeof document.body.style.maxHeight == "undefined") {
     152        if (notSupportedPositionFixed) {
    140153            jQuery("#TB_load").css({
    141154                position: 'absolute',
     
    622635        case "zoom":
    623636            jQuery("#TB_window").height(jQuery("#TB_window").height()); // for image
    624             if (typeof document.body.style.maxHeight == "undefined" && jQuery("body").css("position") != "relative")
     637            if (notSupportedPositionFixed && jQuery("body").css("position") != "relative")
    625638                jQuery("#TB_window").css({marginTop: -jQuery("#TB_window").height() / 2, top: jQuery(window).height() / 2 + jQuery(document).scrollTop()});
    626639            jQuery("#TB_Image").hide().show(tb_options.effect_speed);
     
    628641            break;
    629642        case "slide":
    630             if (typeof document.body.style.maxHeight == "undefined" && jQuery("body").css("position") != "relative")
     643            if (notSupportedPositionFixed && jQuery("body").css("position") != "relative")
    631644                jQuery("#TB_window").css({marginTop: -jQuery("#TB_window").height() / 2, top: jQuery(window).height() / 2 + jQuery(document).scrollTop()});
    632645            jQuery("#TB_window").slideDown(tb_options.effect_speed, callback);
     
    645658    jQuery("#TB_title").height(Math.max(jQuery("#TB_title").height(), jQuery("#TB_ajaxWindowTitle").height() + 13)); // TODO: workaround code for the height of multiline title (to be modified)
    646659
    647     if (typeof document.body.style.maxHeight == "undefined") {
     660    if (notSupportedPositionFixed) {
    648661        jQuery("#TB_window").css({
    649662            position: 'absolute',
     
    712725    var callback = function() {
    713726        jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("tb_unload").unbind().remove();
    714         if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
     727        if (notSupportedPositionFixed) {//if IE 6
    715728            jQuery("body","html").css({height: "auto", width: "auto"});
    716729            jQuery("html").css("overflow","");
     
    742755    var marginLeft = -parseInt((width / 2),10);
    743756    var marginTop = -parseInt((height / 2),10);
    744     var isIE6 = typeof document.body.style.maxHeight === "undefined";
     757    var isIE6 = notSupportedPositionFixed;
    745758    if (!isIE6 && jQuery("#TB_window").css("position") == "absolute") {
    746759        marginLeft += jQuery(document).scrollLeft();
     
    890903function tb_resize_init() {
    891904    jQuery("#TB_window").append("<div id='TB_Resize'><div id='TB_ResizeN'></div><div id='TB_ResizeE'></div><div id='TB_ResizeW'></div><div id='TB_ResizeS'></div><div id='TB_ResizeNE'></div><div id='TB_ResizeNW'></div><div id='TB_ResizeSE'></div><div id='TB_ResizeSW'></div></div>");
    892     if (typeof document.body.style.maxHeight == "undefined") // height:100% on position:absolute does not work in IE6
     905    if (notSupportedPositionFixed) // height:100% on position:absolute does not work in IE6
    893906        jQuery("#TB_ResizeE, #TB_ResizeW").height(jQuery("#TB_window").height());
    894907}
     
    903916    var offsetLeft = jQuery("#TB_window").offset().left - parseInt(jQuery("#TB_window").css("marginLeft")); // cancel negative margin
    904917    var offsetTop = jQuery("#TB_window").offset().top - parseInt(jQuery("#TB_window").css("marginTop"));
    905     if (typeof document.body.style.maxHeight != "undefined" && jQuery("#TB_window").css("position") != "absolute") { // IE6 has no scroll bar (width/height: 100%)
     918    if (!notSupportedPositionFixed && jQuery("#TB_window").css("position") != "absolute") { // IE6 has no scroll bar (width/height: 100%)
    906919        offsetLeft -= jQuery(document).scrollLeft();
    907920        offsetTop -= jQuery(document).scrollTop();
     
    927940        var signX = (action == "e-resize" || action == "ne-resize" || action == "se-resize") ? +1 : -1; // east (northeast, southeast) or not
    928941        var signY = (action == "s-resize" || action == "se-resize" || action == "sw-resize") ? +1 : -1; // south (southeast, southwest) or not
    929         if (typeof document.body.style.maxHeight == "undefined")
     942        if (notSupportedPositionFixed)
    930943            var startMarginTop = jQuery("#TB_window").css("marginTop");
    931944    }
     
    976989                    if (source == "image")
    977990                        jQuery("#TB_ImageClick > a").height(jQuery("#TB_Image").outerHeight(true));
    978                     if (typeof document.body.style.maxHeight == "undefined") // undo rewritten marginTop in IE6
     991                    if (notSupportedPositionFixed) // undo rewritten marginTop in IE6
    979992                        jQuery("#TB_window").css("marginTop", startMarginTop);
    980993                }
Note: See TracChangeset for help on using the changeset viewer.