mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 02:40:08 +00:00
more refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
b90f0fde02
commit
6eb2e74f72
165
ui/lib/panels.js
165
ui/lib/panels.js
@ -15,8 +15,25 @@ var PANEL_HELPER_HIDE_DELAY = 50
|
|||||||
var PANEL_HELPER_HIDE_DELAY_NO_ROOT = 100
|
var PANEL_HELPER_HIDE_DELAY_NO_ROOT = 100
|
||||||
|
|
||||||
|
|
||||||
var PANELS = {
|
// Panel controller registry...
|
||||||
}
|
//
|
||||||
|
// Format:
|
||||||
|
// {
|
||||||
|
// <title>: <controller>,
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// The controller is generated by makePanelController(...) and is called
|
||||||
|
// automatically by openPanel(...)
|
||||||
|
var PANELS = {}
|
||||||
|
|
||||||
|
|
||||||
|
// XXX write real doc...
|
||||||
|
// XXX see getPanelState(...)
|
||||||
|
// XXX we should keep track of panel state while moving, opening, closing
|
||||||
|
// and resizing panels...
|
||||||
|
// XXX move this to config???
|
||||||
|
var PANEL_STATE = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -116,74 +133,10 @@ function getPanel(title){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function openPanel(panel){
|
|
||||||
var title = typeof(panel) == typeof('str') ? panel : null
|
|
||||||
panel = typeof(panel) == typeof('str')
|
|
||||||
? getPanel(panel)
|
|
||||||
: panel
|
|
||||||
title = title == null ? panel.attr('id') : title
|
|
||||||
var open = false
|
|
||||||
|
|
||||||
// create a new panel...
|
/**********************************************************************
|
||||||
if(panel.length == 0){
|
* Constructors...
|
||||||
if(title in PANELS){
|
*/
|
||||||
var builder = PANELS[title]
|
|
||||||
panel = builder({ open: true })
|
|
||||||
}
|
|
||||||
|
|
||||||
// show/open the panel and all it's parents...
|
|
||||||
} else {
|
|
||||||
open = isPanelVisible(panel)
|
|
||||||
panel
|
|
||||||
.prop('open', true)
|
|
||||||
.parents('.panel')
|
|
||||||
.prop('open', true)
|
|
||||||
// XXX show side panels too...
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the panel was not open trigger the event...
|
|
||||||
if(!open){
|
|
||||||
panel.trigger('panelOpening', panel)
|
|
||||||
}
|
|
||||||
|
|
||||||
return panel
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Close the panel...
|
|
||||||
//
|
|
||||||
// NOTE: this does not care if it's a panel or sub-panel...
|
|
||||||
// XXX do we need a panelRemoved event???
|
|
||||||
// ...and a symmetrical panelCreated??
|
|
||||||
function closePanel(panel){
|
|
||||||
panel = typeof(panel) == typeof('str')
|
|
||||||
? getPanel(panel)
|
|
||||||
: panel
|
|
||||||
panel.find('.sub-panel').each(function(){
|
|
||||||
var p = $(this)
|
|
||||||
if(p.prop('open')){
|
|
||||||
p.trigger('panelClosing', p)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return panel
|
|
||||||
.prop('open', false)
|
|
||||||
.trigger('panelClosing', panel)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Remove the panel after firing close events on it and all sub-panels...
|
|
||||||
//
|
|
||||||
function removePanel(panel){
|
|
||||||
panel = typeof(panel) == typeof('str')
|
|
||||||
? getPanel(panel)
|
|
||||||
: panel
|
|
||||||
return closePanel(panel)
|
|
||||||
.remove()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
|
||||||
|
|
||||||
// XXX dragging out, into another panel and back out behaves oddly:
|
// XXX dragging out, into another panel and back out behaves oddly:
|
||||||
// should:
|
// should:
|
||||||
@ -457,6 +410,80 @@ function makeSubPanel(title, content, parent, open, content_resizable, close_but
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Actions...
|
||||||
|
*/
|
||||||
|
|
||||||
|
// XXX this should take the state into consideration while opening panels
|
||||||
|
// and open panels in specific parents and locations, maybe even with
|
||||||
|
// other neighbor panels...
|
||||||
|
function openPanel(panel){
|
||||||
|
var title = typeof(panel) == typeof('str') ? panel : null
|
||||||
|
panel = typeof(panel) == typeof('str')
|
||||||
|
? getPanel(panel)
|
||||||
|
: panel
|
||||||
|
title = title == null ? panel.attr('id') : title
|
||||||
|
var open = false
|
||||||
|
|
||||||
|
// create a new panel...
|
||||||
|
if(panel.length == 0){
|
||||||
|
if(title in PANELS){
|
||||||
|
var builder = PANELS[title]
|
||||||
|
panel = builder({ open: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
// show/open the panel and all it's parents...
|
||||||
|
} else {
|
||||||
|
open = isPanelVisible(panel)
|
||||||
|
panel
|
||||||
|
.prop('open', true)
|
||||||
|
.parents('.panel')
|
||||||
|
.prop('open', true)
|
||||||
|
// XXX show side panels too...
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the panel was not open trigger the event...
|
||||||
|
if(!open){
|
||||||
|
panel.trigger('panelOpening', panel)
|
||||||
|
}
|
||||||
|
|
||||||
|
return panel
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Close the panel...
|
||||||
|
//
|
||||||
|
// NOTE: this does not care if it's a panel or sub-panel...
|
||||||
|
// XXX do we need a panelRemoved event???
|
||||||
|
// ...and a symmetrical panelCreated??
|
||||||
|
function closePanel(panel){
|
||||||
|
panel = typeof(panel) == typeof('str')
|
||||||
|
? getPanel(panel)
|
||||||
|
: panel
|
||||||
|
panel.find('.sub-panel').each(function(){
|
||||||
|
var p = $(this)
|
||||||
|
if(p.prop('open')){
|
||||||
|
p.trigger('panelClosing', p)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return panel
|
||||||
|
.prop('open', false)
|
||||||
|
.trigger('panelClosing', panel)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Remove the panel after firing close events on it and all sub-panels...
|
||||||
|
//
|
||||||
|
function removePanel(panel){
|
||||||
|
panel = typeof(panel) == typeof('str')
|
||||||
|
? getPanel(panel)
|
||||||
|
: panel
|
||||||
|
return closePanel(panel)
|
||||||
|
.remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* High level interface...
|
* High level interface...
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user