Changeset 3442 for trunk/system/views

Show
Ignore:
Timestamp:
09/12/2008 10:15:39 PM (3 months ago)
Author:
JAAulde
Message:

Removed jQuery reliance in Kohana inline error displays

Location:
trunk/system/views/kohana
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/views/kohana/error.php

    r3418 r3442  
    1 <pre class="kohana_error"><a href="#show_trace"><?php echo $code ?></a>: <code><?php echo $error ?></code> [ <strong><?php echo $file ?></strong>, line <strong><?php echo $line ?></strong> ]</pre> 
    2 <div class="kohana_trace"> 
     1<pre class="kohana_error"><a href="#show_trace" id="kohana_error_trace_link_<?php echo $instance_identifier ?>"><?php echo $code ?></a>: <code><?php echo $error ?></code> [ <strong><?php echo $file ?></strong>, line <strong><?php echo $line ?></strong> ]</pre> 
     2<div class="kohana_trace" id="kohana_error_trace_<?php echo $instance_identifier ?>"> 
    33<?php if ( ! empty($source)): ?> 
    4 <div class="source"><a href="#show_source">Source</a><pre><?php echo $source ?></pre></div> 
     4<div class="source"><a href="#show_source" id="kohana_error_source_link_<?php echo $instance_identifier ?>">Source</a><pre id="kohana_error_source_<?php echo $instance_identifier ?>"><?php echo $source ?></pre></div> 
    55<?php endif ?> 
    66<?php if ( ! empty($trace)): ?> 
  • trunk/system/views/kohana/error_script.js

    r3366 r3442  
    1 (function($){ 
    2 // The $ variable is aliased and ready 
    3 $(document).ready(function() 
    4 { 
    5         $('pre.kohana_error a[href="#show_trace"]').click(function() 
     1var kohana_errors_ui = (function() 
     2{                                
     3        var kohana_trace_href = '#show_trace';                   
     4        var kohana_source_href = '#show_source'; 
     5 
     6        var old_onload = (typeof window.onload == 'function') ? window.onload : function(){}; 
     7 
     8        window.onload = function() 
    69        { 
    7                 $(this).parents('pre.kohana_error').next('div.kohana_trace').toggle(); 
     10                old_onload(); 
    811 
    9                 return false; 
    10         }); 
    11         $('div.kohana_trace a[href="#show_source"]').click(function() 
    12         { 
    13                 $(this).next('pre').toggle(); 
     12                var current_href; 
    1413 
    15                 return false; 
    16         }); 
    17 }); 
    18 // End of $ alias 
    19 })(jQuery.noConflict()); 
     14                var document_links = document.getElementsByTagName('a'); 
     15 
     16                for(var a = 0; a < document_links.length; a++) 
     17                { 
     18                        current_href = document_links[a].getAttribute('href'); 
     19                        if(typeof current_href == 'string') 
     20                        { 
     21                                switch(current_href) 
     22                                { 
     23                                        case kohana_trace_href: 
     24                                        case kohana_source_href: 
     25                                                document_links[a].onclick = kohana_errors_ui.toggler; 
     26                                                document_links[a].onclick(); 
     27                                                break; 
     28                                } 
     29                        } 
     30                } 
     31        } 
     32 
     33        return { 
     34                toggler : function() 
     35                { 
     36                        var id, list, instance_identifier; 
     37 
     38                        id = this.getAttribute('id'); 
     39                        if(typeof id == 'string') 
     40                        { 
     41                                list = id.split('_'); 
     42                                instance_identifier = list[4]; 
     43 
     44                                kohana_errors_ui.toggle_block_show('kohana_error_'+list[2]+'_'+instance_identifier); 
     45                        } 
     46 
     47                        return false; 
     48                }, 
     49                set_display : function(element, display) 
     50                { 
     51                        if(typeof element == 'string') 
     52                                element = document.getElementById(element); 
     53 
     54                        if(typeof element == 'object' && element !== 'null') 
     55                                element.style.display = display; 
     56                }, 
     57                toggle_block_show : function(element) 
     58                { 
     59                        if(typeof element == 'string') 
     60                                element = document.getElementById(element); 
     61 
     62                        if(typeof element == 'object' && element !== 'null') 
     63                                kohana_errors_ui.set_display(element, ( ! element.style.display || element.style.display == 'block' ? 'none' : 'block')); 
     64                } 
     65        } 
     66})(); 
  • trunk/system/views/kohana/error_style.css

    r3421 r3442  
    66        pre.kohana_error code { font-size: 1em; font-family: monospace; padding: 0 0.5em; } 
    77        pre.kohana_error strong { font-weight: bold; } 
    8 div.kohana_trace { display: none; border-top: dotted 1px #809953; } 
     8div.kohana_trace { border-top: dotted 1px #809953; } 
    99        div.kohana_trace div.source { margin-bottom: 1em; } 
    1010                div.kohana_trace div.source a { display: block; } 
    11                 div.kohana_trace div.source pre { display: none; padding: 1em; background: #fff; border: dotted 1px #809953; } 
     11                div.kohana_trace div.source pre { padding: 1em; background: #fff; border: dotted 1px #809953; } 
    1212                        div.kohana_trace div.source pre span { background: #ede33b; } 
    1313        div.kohana_trace ul.trace { list-style: none; padding: 0; margin: 0; line-height: 120%; }