Skip to content

Commit

Permalink
Editor foundation, UI panel system
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Burney committed Mar 19, 2010
1 parent a775011 commit fec8f28
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
4 changes: 4 additions & 0 deletions proj/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@

</script>

<script id='panel' type='haml'>
.panel{ id: 'panel-' + guid }= ''
</script>

<script id='browser-row' type='haml'>
%tr.list-item{ 'class': is_folder ? 'folder' : '' }
%td.icon
Expand Down
7 changes: 4 additions & 3 deletions proj/j/message.ui.browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@

init: function( args ){
this.guid = M.guid();
this.panel = args[0];

var el = $( args[0] ),
var el = $( this.panel.elem ),
loc = args[1],
opts = args[2];

Expand Down Expand Up @@ -175,8 +176,8 @@
bp.init.prototype = bp;

$(function(){
var browse_con = $( "<div class='panel' />" ).appendTo( '#main' );
M.ui.browse = browse( browse_con, { icon_size: 120 } );
var browse_panel = M.ui.panel({ title:'Browse', kind:'Browser' });
M.ui.browse = browse( browse_panel, { icon_size: 120 } );

M.history.listen( 'b', function( path ){
M.ui.browse.open( path );
Expand Down
14 changes: 9 additions & 5 deletions proj/j/message.ui.edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(function(){

var edit = function( opts ){
return new bp.init( Array.prototype.slice.call( arguments ) );
return new ep.init( Array.prototype.slice.call( arguments ) );
};

var ep = edit.prototype = {
Expand All @@ -34,10 +34,11 @@

if( typeof loc !== 'string' ){
opts = loc;
loc = '';
}
loc = ''; }

this.opts = $.extend( {}, this.defaults, opts );

M.ui.show_panel( this.opts.panel );
return this;
}
};
Expand Down Expand Up @@ -66,9 +67,12 @@
else if( typeof item === 'object' ){
var current = editing( item );
if( current )
return; // Show editor instead of making a new one
M.ui.show_panel( current.panel );
else
edit( )
edit({
panel: M.ui.panel({ title: item.title, kind: 'Editor' }),
item: item
});
}
}

Expand Down
28 changes: 27 additions & 1 deletion proj/j/message.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
M.ui = {
widgets: {},
toolbars: {},
buttons: {}
buttons: {},
panels: {}
};

function widget( kind, build, destroy ){
Expand All @@ -36,6 +37,31 @@

}

function panel( arg ){
if( typeof arg === 'number' )
return M.ui.panels[ arg ];

else if( typeof arg === 'object' ){
var guid = M.guid();
return M.ui.panels[ guid ] = {
guid: guid,
elem: $( M.templates.panel({ guid: guid }) ).appendTo( '#main' ),
type: ( arg.kind || 'Panel' ),
title: ( arg.title || 'Panel' )
};
}
}

function show_panel( panel ){
if( typeof panel === 'number' )
panel = panels[ panel ];
if( ! panel ) return;

panel.elem.show().siblings().hide();
}

M.ui.panel = panel;
M.ui.show_panel = show_panel;
M.ui.widget = widget;
M.ui.toolbar = toolbar;
M.ui.button = button;
Expand Down

0 comments on commit fec8f28

Please sign in to comment.