Make WordPress Core

Changeset 12205


Ignore:
Timestamp:
11/18/2009 12:19:55 AM (17 years ago)
Author:
azaozz
Message:

Let plugins predefine thickbox image vars, props aaroncampbell, fixes #6453

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/thickbox/thickbox.js

    r10428 r12205  
    55 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
    66*/
    7                  
    8 var tb_pathToImage = "../wp-includes/js/thickbox/loadingAnimation.gif";
    9 var tb_closeImage = "../wp-includes/js/thickbox/tb-close.png";
     7
     8if ( typeof tb_pathToImage != 'string' ) {
     9        var tb_pathToImage = "../wp-includes/js/thickbox/loadingAnimation.gif";
     10}
     11if ( typeof tb_closeImage != 'string' ) {
     12        var tb_closeImage = "../wp-includes/js/thickbox/tb-close.png";
     13}
    1014
    1115/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
    1216
    1317//on page load call tb_init
    14 jQuery(document).ready(function(){   
     18jQuery(document).ready(function(){
    1519        tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
    1620        imgLoader = new Image();// preload image
     
    4650                        }
    4751                }
    48                
     52
    4953                if(tb_detectMacXFF()){
    5054                        jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
     
    5256                        jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
    5357                }
    54                
     58
    5559                if(caption===null){caption="";}
    5660                jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
    5761                jQuery('#TB_load').show();//show loader
    58                
     62
    5963                var baseURL;
    6064           if(url.indexOf("?")!==-1){ //ff there is a query string involved
    6165                        baseURL = url.substr(0, url.indexOf("?"));
    62            }else{ 
     66           }else{
    6367                        baseURL = url;
    6468           }
    65            
     69
    6670           var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
    6771           var urlType = baseURL.toLowerCase().match(urlString);
    6872
    6973                if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
    70                                
     74
    7175                        TB_PrevCaption = "";
    7276                        TB_PrevURL = "";
     
    8185                                for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
    8286                                        var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
    83                                                 if (!(TB_TempArray[TB_Counter].href == url)) {                                         
     87                                                if (!(TB_TempArray[TB_Counter].href == url)) {
    8488                                                        if (TB_FoundURL) {
    8589                                                                TB_NextCaption = TB_TempArray[TB_Counter].title;
     
    9397                                                } else {
    9498                                                        TB_FoundURL = true;
    95                                                         TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);                                                                                     
     99                                                        TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);
    96100                                                }
    97101                                }
     
    99103
    100104                        imgPreloader = new Image();
    101                         imgPreloader.onload = function(){               
     105                        imgPreloader.onload = function(){
    102106                        imgPreloader.onload = null;
    103                                
     107
    104108                        // Resizing large images - orginal by Christian Montoya edited by me.
    105109                        var pagesize = tb_getPageSize();
     
    109113                        var imageHeight = imgPreloader.height;
    110114                        if (imageWidth > x) {
    111                                 imageHeight = imageHeight * (x / imageWidth); 
    112                                 imageWidth = x; 
    113                                 if (imageHeight > y) { 
    114                                         imageWidth = imageWidth * (y / imageHeight); 
    115                                         imageHeight = y; 
    116                                 }
    117                         } else if (imageHeight > y) { 
    118                                 imageWidth = imageWidth * (y / imageHeight); 
    119                                 imageHeight = y; 
    120                                 if (imageWidth > x) { 
    121                                         imageHeight = imageHeight * (x / imageWidth); 
     115                                imageHeight = imageHeight * (x / imageWidth);
     116                                imageWidth = x;
     117                                if (imageHeight > y) {
     118                                        imageWidth = imageWidth * (y / imageHeight);
     119                                        imageHeight = y;
     120                                }
     121                        } else if (imageHeight > y) {
     122                                imageWidth = imageWidth * (y / imageHeight);
     123                                imageHeight = y;
     124                                if (imageWidth > x) {
     125                                        imageHeight = imageHeight * (x / imageWidth);
    122126                                        imageWidth = x;
    123127                                }
    124128                        }
    125129                        // End Resizing
    126                        
     130
    127131                        TB_WIDTH = imageWidth + 30;
    128132                        TB_HEIGHT = imageHeight + 60;
    129                         jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='" + tb_closeImage + "' /></a></div>");         
    130                        
     133                        jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='" + tb_closeImage + "' /></a></div>");
     134
    131135                        jQuery("#TB_closeWindowButton").click(tb_remove);
    132                        
     136
    133137                        if (!(TB_PrevHTML === "")) {
    134138                                function goPrev(){
     
    137141                                        jQuery("body").append("<div id='TB_window'></div>");
    138142                                        tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
    139                                         return false;   
     143                                        return false;
    140144                                }
    141145                                jQuery("#TB_prev").click(goPrev);
    142146                        }
    143                        
    144                         if (!(TB_NextHTML === "")) {           
     147
     148                        if (!(TB_NextHTML === "")) {
    145149                                function goNext(){
    146150                                        jQuery("#TB_window").remove();
    147151                                        jQuery("body").append("<div id='TB_window'></div>");
    148                                         tb_show(TB_NextCaption, TB_NextURL, imageGroup);                               
    149                                         return false;   
     152                                        tb_show(TB_NextCaption, TB_NextURL, imageGroup);
     153                                        return false;
    150154                                }
    151155                                jQuery("#TB_next").click(goNext);
    152                                
    153                         }
    154 
    155                         document.onkeydown = function(e){       
     156
     157                        }
     158
     159                        document.onkeydown = function(e){
    156160                                if (e == null) { // ie
    157161                                        keycode = event.keyCode;
     
    171175                                                goPrev();
    172176                                        }
    173                                 }       
     177                                }
    174178                        };
    175                        
     179
    176180                        tb_position();
    177181                        jQuery("#TB_load").remove();
     
    179183                        jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show
    180184                        };
    181                        
     185
    182186                        imgPreloader.src = url;
    183187                }else{//code to show html
    184                        
     188
    185189                        var queryString = url.replace(/^[^\?]+\??/,'');
    186190                        var params = tb_parseQuery( queryString );
     
    190194                        ajaxContentW = TB_WIDTH - 30;
    191195                        ajaxContentH = TB_HEIGHT - 45;
    192                        
    193                         if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window             
     196
     197                        if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
    194198                                        urlNoQuery = url.split('TB_');
    195199                                        jQuery("#TB_iframeContent").remove();
     
    206210                                                }else{//ajax modal
    207211                                                jQuery("#TB_overlay").unbind();
    208                                                 jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");   
     212                                                jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
    209213                                                }
    210214                                        }else{//this means the window is already up, we are just loading new content via ajax
     
    215219                                        }
    216220                        }
    217                                        
     221
    218222                        jQuery("#TB_closeWindowButton").click(tb_remove);
    219                        
    220                                 if(url.indexOf('TB_inline') != -1){     
     223
     224                                if(url.indexOf('TB_inline') != -1){
    221225                                        jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
    222226                                        jQuery("#TB_window").unload(function () {
     
    225229                                        tb_position();
    226230                                        jQuery("#TB_load").remove();
    227                                         jQuery("#TB_window").css({display:"block"}); 
     231                                        jQuery("#TB_window").css({display:"block"});
    228232                                }else if(url.indexOf('TB_iframe') != -1){
    229233                                        tb_position();
     
    240244                                        });
    241245                                }
    242                        
     246
    243247                }
    244248
    245249                if(!params['modal']){
    246                         document.onkeyup = function(e){         
     250                        document.onkeyup = function(e){
    247251                                if (e == null) { // ie
    248252                                        keycode = event.keyCode;
     
    252256                                if(keycode == 27){ // close
    253257                                        tb_remove();
    254                                 }       
     258                                }
    255259                        };
    256260                }
    257                
     261
    258262        } catch(e) {
    259263                //nothing here
     
    318322  }
    319323}
    320 
    321 
  • trunk/wp-includes/script-loader.php

    r12188 r12205  
    165165        $scripts->add_data( 'jquery-table-hotkeys', 'group', 1 );
    166166
    167         $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20090123');
     167        $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20091117');
    168168        $scripts->add_data( 'thickbox', 'group', 1 );
    169169
Note: See TracChangeset for help on using the changeset viewer.