[Jifty-commit] r690 - in jifty/trunk: . lib/Jifty/Mason share/web/static/css share/web/static/js share/web/templates/_elements

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed Mar 15 00:30:26 EST 2006


Author: alexmv
Date: Wed Mar 15 00:30:25 2006
New Revision: 690

Added:
   jifty/trunk/share/web/templates/__jifty/halo
Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Mason/Halo.pm
   jifty/trunk/share/web/static/css/halos.css
   jifty/trunk/share/web/static/js/bps_util.js
   jifty/trunk/share/web/static/js/halo.js
   jifty/trunk/share/web/templates/_elements/javascript

Log:
 r8529 at zoq-fot-pik:  chmrr | 2006-03-15 00:30:14 -0500
  * Messing around with making halos more suave


Modified: jifty/trunk/lib/Jifty/Mason/Halo.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Mason/Halo.pm	(original)
+++ jifty/trunk/lib/Jifty/Mason/Halo.pm	Wed Mar 15 00:30:25 2006
@@ -28,6 +28,8 @@
     my $self    = shift;
     my $context = shift;
 
+    return if $context->comp->path eq "/__jifty/halo";
+
     my $DEPTH = $context->request->notes('_halo_depth') || 0;
     my $STACK = $context->request->notes('_halo_stack')
         || $context->request->notes( '_halo_stack' => [] );
@@ -41,22 +43,21 @@
         Jifty->handle->clear_sql_statement_log;
     }
 
-        push @$STACK,
-            {
-            id           => $halo_base,
-            args         => [map {UNIVERSAL::isa($_,"GLOB") ? "*GLOB*" : $_} @{$context->args}],
-            start_time   => Time::HiRes::time(),
-            path         => $context->comp->path,
-            subcomponent => (  $context->comp->is_subcomp() ? 1:0),
-            name         => $context->comp->name,
-            proscribed   => ($self->_unrendered_component($context) ? 1 :0 ),
-            depth        => $DEPTH
-            };
+    push @$STACK, {
+        id           => $halo_base,
+        args         => [map {UNIVERSAL::isa($_,"GLOB") ? "*GLOB*" : $_} @{$context->args}],
+        start_time   => Time::HiRes::time(),
+        path         => $context->comp->path,
+        subcomponent => (  $context->comp->is_subcomp() ? 1:0),
+        name         => $context->comp->name,
+        proscribed   => ($self->_unrendered_component($context) ? 1 :0 ),
+        depth        => $DEPTH
+    };
 
-        push @$INDEX_STACK, $#{@$STACK};
+    push @$INDEX_STACK, $#{@$STACK};
     return if $self->_unrendered_component($context);
 
-    $context->request->out('<span class="halo">');
+    $context->request->out(qq{<div id="halo-@{[$halo_base]}">});
 }
 
 =head2 end_component_hook CONTEXT_OBJECT
@@ -71,7 +72,7 @@
     my $self    = shift;
     my $context = shift;
 
-
+    return if $context->comp->path eq "/__jifty/halo";
 
     my $STACK = $context->request->notes('_halo_stack');
     my $INDEX_STACK = $context->request->notes('_halo_index_stack');
@@ -94,7 +95,7 @@
 
     # print out the div with our halo magic actions.
     # if we didn't render a beginning of the span, don't render an end
-    $context->request->out('</span>') unless ($frame->{'proscribed'});
+    $context->request->out('</div>') unless ($frame->{'proscribed'});
 
 }
 
@@ -111,28 +112,7 @@
     my $self    = shift;
     my $stack_frame = shift;
 
-    Jifty->web->mason->out( 
-        qq{
-<div class="halo_actions" id="halo-@{[$stack_frame->{'id'}]}-menu">
-<span class="halo_name" onClick="toggle_display('halo-@{[$stack_frame->{'id'}]}-menu')">@{[$stack_frame->{'name'}]}</span>
-<dl>
-<dt>Path</dt>
-<dd>@{[$stack_frame->{'path'}]}</dd>
-<dt>Render time</dt>
-<dd>@{[$stack_frame->{'render_time'}]}</dd>
-<dt>});
-# XXX TODO: we shouldn't be doing direct rendering of this if we can avoid it.
-# but it would require a rework of how the render_xxx subs work in jifty core
-Jifty->web->mason->out(Jifty->web->tangent( url =>"/=/edit/mason_component/".$stack_frame->{'path'}, label => 'Edit'));
-
-Jifty->web->mason->out(qq{</dt>
-<dt>Variables</dt>
-<dd><textarea rows="5" cols="80">@{[YAML::Dump($stack_frame->{'args'})]}</textarea></dd>
-<dt>SQL Statements</dt>
-<dd><textarea rows="5" cols="80">@{[YAML::Dump($stack_frame->{'sql_statements'})]}</textarea></dd>
-</dl>
-</div>
-})
+    Jifty->web->mason->comp("/__jifty/halo", frame => $stack_frame);
 }
 
 
@@ -172,8 +152,8 @@
     my @stack = @{ Jifty->web->mason->notes('_halo_stack') };
 
     my $depth = 1;
-    Jifty->web->mason->out(q{<div id="render_info" onClick="toggle_display('render_info_tree')">Page info</div>});
-    Jifty->web->mason->out('<div id="render_info_tree">');
+    Jifty->web->mason->out(q{<a href="#" id="render_info" onClick="Element.toggle('render_info_tree'); return false">Page info</a>});
+    Jifty->web->mason->out('<div style="display: none" id="render_info_tree">');
     Jifty->web->mason->out('<ul>');
 
     foreach my $item (@stack) {
@@ -186,17 +166,19 @@
 
         Jifty->web->mason->out( "<li>");
 
-        Jifty->web->mason->out(qq{<span class="halo_comp_info" } );
-        Jifty->web->mason->out(qq{onClick="toggle_display('halo-}.$item->{id}.qq{-menu');"});
-        Jifty->web->mason->out(qq{>}
-                . $item->{'path'} . " - "
+        Jifty->web->mason->out(qq{<a href="#" class="halo_comp_info" } );
+        my $id = $item->{id};
+        Jifty->web->mason->out(qq|onMouseOver="halo_over('@{[$id]}')" |); 
+        Jifty->web->mason->out(qq|onMouseOut="halo_out('@{[$id]}')" |); 
+        Jifty->web->mason->out(qq|onClick="halo_toggle('$id'); return false;">|);
+        Jifty->web->mason->out(
+                  $item->{'path'} . " - "
                 . $item->{'render_time'}
-                . qq{</span> }
+                . qq{</a> }
         );
 
         Jifty->web->mason->out(Jifty->web->tangent( url =>"/=/edit/mason_component/".$item->{'path'}, label => 'Edit'))
           unless ($item->{subcomponent});
-        $self->render_halo_actions($item);
         Jifty->web->mason->out( "</li>");
         $depth = $item->{'depth'};
     }
@@ -204,6 +186,9 @@
     Jifty->web->mason->out("</ul>\n") for (1 .. $depth);
     Jifty->web->mason->out('</div>');
 
+    foreach my $item (@stack) {
+        $self->render_halo_actions($item);
+    }
 }
 
 

Modified: jifty/trunk/share/web/static/css/halos.css
==============================================================================
--- jifty/trunk/share/web/static/css/halos.css	(original)
+++ jifty/trunk/share/web/static/css/halos.css	Wed Mar 15 00:30:25 2006
@@ -1,61 +1,89 @@
-div.halo_actions {
-  display: none;
-  position: fixed;
-  right: 0;
-  bottom: 0;
+.halo_actions {
+    position: fixed;
+    width: 300px;
+    border: 1px solid black;
+    background: #ccc;
+}
 
+.halo_actions h1 {
+    color: #fff;
+    background-color: #600;
+    border-bottom: 1px solid black;
+    padding: 0.25em;
+    margin: 0;
+    cursor: pointer;
+    font-size: 120%;
+}
 
+.halo_actions h1 a { 
+    color: #fff;
 }
 
-div.halo_actions dl {
- background: #ccc;
- list-style-type: none;
- border: yellow 2px solid;
+.halo_actions .section {
+    color: #ccc;
+    background-color: #300;
+    border-top: 1px solid black;
+    margin-top: 0.5em;
+    font-size: 120%;
+    font-weight: bold;
+}
 
- margin: 1em;
- padding:1em;
- 
+.halo_actions .section a {
+    text-align: center;
+    color: #ccc;
 }
 
-div.halo_actions dl a {
- color: black;
+.halo_actions .body {
+    font-size: 110%;
+    margin:0;
+    padding:0 1em;
 }
 
-span.halo_button {
-  color: yellow;
-  position: absolute;
-  z-index: 9999;
-  font-size:2em;
+.halo_actions .body ul {
+    margin:0;
+    padding:0;
+    margin-left: 1em;
 }
 
-div#render_info_tree {
-   display: none;
-   position: fixed;
-   background: white;
-   border: 1px solid yellow;
-   right: 1em;
-   bottom: 1em;
-   border: 2px solid #fc0;
-   padding: 1em;
+.halo_actions .body .path {
+    font-family: monospace;
+    font-size: 120%;
+    text-align: center;
 }
 
-div#render_info_tree ul {
-   list-style: none;
-   padding-left: 1em;
+.halo_actions .body .time {
+    font-style: italic;
+    text-align: center;
 }
 
+.halo_actions .body .fixed {
+    font-family: monospace;
+}
 
-div#render_info {
-  position: fixed;
-  right:0.5em;
-  bottom:0;
+.halo_button {
+    color: yellow;
+    position: absolute;
+    z-index: 9999;
+    font-size:2em;
 }
 
-span.halo_name {
-  color: black;
-  background-color: yellow;
-  border: 1px solid black;
-  position: static;
-  padding: 0.25em;
+#render_info_tree {
+    position: fixed;
+    background: white;
+    border: 1px solid yellow;
+    right: 1em;
+    bottom: 1em;
+    border: 2px solid #fc0;
+    padding: 1em;
 }
 
+#render_info_tree ul {
+    list-style: none;
+    padding-left: 1em;
+}
+
+#render_info {
+    position: fixed;
+    right:0.5em;
+    bottom:0;
+}

Modified: jifty/trunk/share/web/static/js/bps_util.js
==============================================================================
--- jifty/trunk/share/web/static/js/bps_util.js	(original)
+++ jifty/trunk/share/web/static/js/bps_util.js	Wed Mar 15 00:30:25 2006
@@ -83,14 +83,3 @@
         doOnLoadHooks();
     }
 }
-
-function toggle_display (id) {
-var e = document.getElementById(id);
-if (e.style.display !="block" ) {
-    e.style.display="block";
-} else {
-   e.style.display="none";
-} 
-
-
-}

Modified: jifty/trunk/share/web/static/js/halo.js
==============================================================================
--- jifty/trunk/share/web/static/js/halo.js	(original)
+++ jifty/trunk/share/web/static/js/halo.js	Wed Mar 15 00:30:25 2006
@@ -1,10 +1,24 @@
-function toggle_display (id) {
-var e = document.getElementById(id);
-if (e.style.display !="block" ) {
-    e.style.display="block";
-} else {
-   e.style.display="none";
-} 
 
+function halo_toggle (id) {
+    Element.toggle('halo-'+id+'-menu');
+    var e = $('halo-'+id);
+//    new Draggable( $('halo-'+id+'-menu'), {starteffect: null, endeffect: null} );
+    Drag.init( $('halo-'+id+'-menu') );
+    return false;
+}
+
+var halo_effects = {};
+
+function halo_over (id) {
+    var e = $('halo-'+id);
+    if (e) {
+        Element.setStyle(e, {background: '#ffff80'});
+    }
+}
 
+function halo_out (id) {
+    var e = $('halo-'+id);
+    if (e) {
+        Element.setStyle(e, {background: 'inherit'});
+    }
 }

Added: jifty/trunk/share/web/templates/__jifty/halo
==============================================================================
--- (empty file)
+++ jifty/trunk/share/web/templates/__jifty/halo	Wed Mar 15 00:30:25 2006
@@ -0,0 +1,55 @@
+<div class="halo_actions" id="halo-<% $id %>-menu" style="display: none; top: 5px; left: 500px"  onMouseOver="halo_over('<% $id %>')"onMouseOut="halo_out('<% $id %>')">
+<h1 id="halo-<% $id %>-title">
+  <span style="float: right;"><a href="#" onClick="halo_toggle('<% $id %>'); return false">[ X ]</a></span>
+  <% $frame->{name} %>
+</h1>
+<div class="body">
+<div class="path"><% $frame->{path} %></div>
+<div class="time">Rendered in <% $frame->{'render_time'} %>s</div>
+</div>
+% if (@args) {
+<div class="section">Variables</div>
+<div class="body"><ul class="fixed">
+% for my $e (@args) {
+<li><b><% $e->[0] %></b>:
+% if ($e->[1]) {
+% my $expanded = Jifty->web->serial;
+<span onmouseover="Element.show('<% $expanded %>')" onmouseout="Element.hide('<% $expanded %>')"><% $e->[1] %></span>
+<div id="<% $expanded %>" style="display: none; position: absolute; left: 200px; border: 1px solid black; background: #ccc; padding: 1em; padding-top: 0"><pre><% YAML::Dump($e->[2]) %></pre></div>
+% } else {
+<% $e->[2] %>
+% }
+</li>
+% }
+</ul></div>
+% }
+% if (@stmts) {
+<div class="section">SQL Statements</div>
+<div class="body"><ul>
+% for (@stmts) {
+<li class="fixed"><% $_ %></li>
+% }
+</ul></div>
+% }
+<div class="section"><% Jifty->web->tangent( url =>"/=/edit/mason_component/".$frame->{'path'}, label => 'Edit') %></div>
+</div>
+<%args>
+$frame
+</%args>
+<%init>
+my $id = $frame->{id};
+
+my @args;
+while (my ($key, $value) = splice(@{$frame->{args}},0,2)) {
+    push @args, [$key, ref($value), $value];
+}
+ at args = sort {$a->[0] cmp $b->[0]} @args;
+
+my $prev = '';
+my @stmts;
+for (@{$frame->{'sql_statements'}}) {
+    push @stmts, $_->[1] if $_->[1] ne $prev;
+    $prev = $_->[1];
+}
+
+</%init>
\ No newline at end of file

Modified: jifty/trunk/share/web/templates/_elements/javascript
==============================================================================
--- jifty/trunk/share/web/templates/_elements/javascript	(original)
+++ jifty/trunk/share/web/templates/_elements/javascript	Wed Mar 15 00:30:25 2006
@@ -3,6 +3,8 @@
   <script type="text/javascript" src="/js/behaviour.js"></script>
   <script type="text/javascript" src="/js/scriptaculous/scriptaculous.js"></script>
   <script type="text/javascript" src="/js/jifty.js"></script>
+  <script type="text/javascript" src="/js/dom-drag.js"></script>
+  <script type="text/javascript" src="/js/halo.js"></script>
   <script type="text/javascript" src="/js/combobox.js"></script>
   <script type="text/javascript" src="/js/key_bindings.js"></script>
   <script type="text/javascript" src="/js/bps_util.js"></script>


More information about the Jifty-commit mailing list