Changeset 1659 in ExiteCMS


Ignore:
Timestamp:
08/19/08 19:20:49 (3 years ago)
Author:
hverton
Message:

updated the codeblock resize code, so that the blocks always will fit, even inside serveral nested quote blocks
fixed added tab at the start of news.php and at the end of _header.tpl causing a PHP warning

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/jscripts/core_functions.js

    r1655 r1659  
    251251function eraseCookie(name) { 
    252252    createCookie(name,"",-1); 
     253} 
     254 
     255function findPosX(obj) { 
     256    if (obj == null) return false; 
     257    var curleft = 0; 
     258    if(obj.offsetParent) { 
     259        while(1) { 
     260            curleft += obj.offsetLeft; 
     261            if(!obj.offsetParent) break; 
     262            obj = obj.offsetParent; 
     263        } 
     264    } else { 
     265        if(obj.x)  curleft += obj.x; 
     266    } 
     267    return curleft; 
     268} 
     269 
     270function findPosY(obj) { 
     271    if (obj == null) return false; 
     272    var curtop = 0; 
     273    if(obj.offsetParent) { 
     274        while(1) { 
     275            curtop += obj.offsetTop; 
     276            if(!obj.offsetParent) break; 
     277            obj = obj.offsetParent; 
     278        } 
     279    } else { 
     280        if(obj.y) curtop += obj.y; 
     281    } 
     282    return curtop; 
    253283} 
    254284 
  • trunk/includes/templates/forum.viewthread.tpl

    r1651 r1659  
    2121</script> 
    2222{include file="_opentable.tpl" name=$_name title=$locale.500 state=$_state style=$_style} 
    23 <table id='width_check' cellspacing='0' cellpadding='0' width='100%'> 
     23<table cellspacing='0' cellpadding='0' width='100%'> 
    2424    <tr> 
    2525        <td class='smallalt'> 
     
    199199    if (_timer) clearInterval(_timer); 
    200200 
    201     // calculate the width of a code block 
    202     var blockwidth = document.getElementById("width_check").offsetWidth-141; 
    203     var block_a = 0; 
    204     var block_b = 0; 
     201    // needed inside the loop 
     202    var parent_left = 0; 
     203    var parent_width = 0; 
     204    var obj = 1; 
     205    var i = 1; 
    205206 
    206207    // loop through all blocks found, and set the width correctly 
    207     var i = 1; 
    208208    while (document.getElementById("codeblock"+i+"a") != null && document.getElementById("codeblock"+i+"b") != null) { 
    209         // need to check and do something dynamic with margins and padding here... 
    210         block_a = blockwidth - 40 + "px"; 
    211         block_b = blockwidth - 50 + "px"; 
    212         document.getElementById("codeblock"+i+"a").style.width = block_a; 
    213         document.getElementById("codeblock"+i+"b").style.width = block_b; 
     209        // get the info about the objects parent 
     210        obj = document.getElementById("codeblock"+i+"a").parentNode; 
     211        // fall back gracefully if the parentNode can not be found 
     212        if (obj == null) obj = document.getElementById("codeblock"+i+"a").offsetParent; 
     213        parent_left = findPosX(obj); 
     214        parent_width = obj.offsetWidth; 
     215//      alert(parent_left + " : " + parent_width); 
     216        // calculate the new width of the block, leave plenty of space to handle browser subtleties  
     217        block_width = parent_left + parent_width - findPosX(document.getElementById("codeblock"+i+"a")) - 30; 
     218        // adjust the width of the code blocks 
     219        document.getElementById("codeblock"+i+"a").style.width = block_width + "px"; 
     220        document.getElementById("codeblock"+i+"b").style.width = block_width - 10 + "px"; 
    214221        i++; 
    215222    } 
  • trunk/news.php

    r1637 r1659  
    1     <?php 
     1<?php 
    22/*---------------------------------------------------+ 
    33| ExiteCMS Content Management System                 | 
  • trunk/themes/ExiteCMS/exitecms.css

    r1648 r1659  
    158158 
    159159                        /* code sections within the message body (note: total number of px for padding+margin must remain the same, the code expects this!!!) */ 
    160 .codeblock_source       { width:380px; margin-left:10px; border:1px #bbb solid; background-color:#fff; padding:0px; white-space:nowrap; overflow-x:auto; } 
    161 .codeblock_cmds         { width:370px; margin-left:10px; border:1px #bbb solid; background-color:#fff; padding:0px 5px 0px 5px; border-top:0px; text-align:right; } 
     160.codeblock_source       { width:250px; margin-left:10px; border:1px #bbb solid; background-color:#fff; padding:0px; white-space:nowrap; overflow-x:auto; } 
     161.codeblock_cmds         { width:240px; margin-left:10px; border:1px #bbb solid; background-color:#fff; padding:0px 5px 0px 5px; border-top:0px; text-align:right; } 
    162162 
    163163                        /* thumbnail caption in the message body */ 
Note: See TracChangeset for help on using the changeset viewer.