/*
* pettanR system.js
- * version 0.5.34
+ * version 0.5.36
*
* gadgetOS
* author:
function getClass( instance ){
var list = CLASS_LIST,
- l = list.length,
+ i = list.length,
getIndex = Util.getIndex,
- klass, live, pool;
+ klass;
for( ; i; ){
- klass = list[ --i ]
- live = klass.live;
- if( live && getIndex( live, instance ) !== -1 ) return klass;
- pool = klass.pool;
- if( pool && getIndex( pool, instance ) !== -1 ) return klass;
+ klass = list[ --i ];
+ if( klass.live && getIndex( klass.live, instance ) !== -1 ) return klass;
+ if( klass.pool && getIndex( klass.pool, instance ) !== -1 ) return klass;
if( instance instanceof klass ) return klass;
};
return null;
function I(){
var klass = this,
instance;
- if( klass.abstract === true ){
+ if( klass.Abstract === true ){
throw new Error( 'AbstractClass!' );
};
if( klass.pool && klass.pool.length > 0 ){
};
return {
- create : function( def, final, pool, abstract ){
+ create : function( def, opt_final, pool, opt_abstract ){
var klass = function(){
a = arguments;
- if( f ) return I.apply( a.collee, c( a ) );
+ if( f ) return I.apply( a.callee, c( a ) );
};
klass.prototype = copy( copy( {}, basic ), def );
- if( final !== true ){
+ if( opt_final !== true ){
klass.extend = extend;
};
if( pool === true ){
klass.pool = [];
klass.live = [];
};
- if( abstract === true ){
- klass.abstract = true;
+ if( opt_abstract === true ){
+ klass.Abstract = true;
};
+ CLASS_LIST.push( klass );
return klass;
}
};
_scrollY : 0,
scrollingX : 0,
scrollingY : 0,
- scrollStartX : 0,
- scrollStartY : 0,
_cursor : '',
// parentLayer : null,
parentData : null,
if( this.x !== x || this.y !== y ){
this.x = x;
this.y = y;
- console.log( 'xy ' + ( this.elm ? this.elm.id : '' ) + ' x:' + x + ' y:' + y + ' w:' + w + ' h:' + h + ' absX:' + this.parentData.absoluteX )
+ //console.log( 'xy ' + ( this.elm ? this.elm.id : '' ) + ' x:' + x + ' y:' + y + ' w:' + w + ' h:' + h + ' absX:' + this.parentData.absoluteX )
parent = this.parentData;
parent && this._updateAbsoluteXY( parent.absoluteX, parent.absoluteY, parent.scrollingX, parent.scrollingY );
this.w === w && this.h === h && this._updateRectangle();
if( this.w !== w || this.h !== h ){
this.w = w;
this.h = h;
- console.log( 'wh ' + ( this.elm ? this.elm.id : '' ) + ' x:' + x + ' y:' + y + ' w:' + w + ' h:' + h )
+ //console.log( 'wh ' + ( this.elm ? this.elm.id : '' ) + ' x:' + x + ' y:' + y + ' w:' + w + ' h:' + h )
this._updateRectangle();
};
if( counter[ eventType ] ){
++counter[ eventType ];
} else {
- console.log( eventType );
+ //console.log( eventType );
counter[ eventType ] = 1;
MouseEvent.add( this.apiuser, this.rootData.elmMouseCatch, eventType, eventRellay );
};
x -= t.x;
y -= t.y;
if( nodes = t.childData ){
- _x = x - t._scrollX;
- _y = y - t._scrollY;
+ _x = x - t.scrollingX;
+ _y = y - t.scrollingY;
for( i = nodes.length; i; ){
child = nodes[ --i ];
if( child._disabled === false && child.l <= _x && _x < child.r && child.t <= _y && _y < child.b && child._capcher( _x, _y ) === true ){
clientX : e.clientX,
clientY : e.clientY,
dragOffsetX : e.dragOffsetX,
- dragOffsetY : e.dragOffsetY,
+ dragOffsetY : e.dragOffsetY,
+ dragPhase : e.dragPhase,
eventType : eventType,
hit : hit,
node : data.node,
var elmScroller = document.createElement( 'div' ),
elmBar = document.createElement( 'div' ),
smoothList = [],
+ dragPhase = 2,
+ dragOut = false,
currentNodeData = null,
+ dragStartY = 0,
currentEvent;
function tick(){
};
};
list.length === 0 && SystemTimer.remove( SUPER_USER_KEY, tick );
+ currentEvent.type = 'updateAfterScroll';
+ AsyncCall.add( data.apiuser, eventRellay, currentEvent ); // スクロール後の更新
};
- function onScrollStart( e ){
+ function scrollReady( e ){
var data = this;
- if( data === currentNodeData ) return;
- currentNodeData && onScrollComplete();
+ dragOut = false;
+ if( data === currentNodeData || dragPhase !== 2 ) return; // Drag中の場合は 他にスクロールを作らない
+ currentNodeData && scrollRelease();
+
+ dragPhase = 2;
data.elm.parentNode.appendChild( elmScroller );
elmScroller.appendChild( data.elm );
elmScroller.style.cssText = 'position:absolute;left:0;top:0;';
elmScroller.appendChild( elmBar );
- data.scrollStartX = data.scrollingX;
- data.scrollStartY = data.scrollingY;
data.elm.scrollTop = -data.scrollingY;
- data.addEventListener( 'mousewheel', onMouseWheelScroll, data );
- data.addEventListener( 'mousedrag', onMouseDragScroll, data );
- data.addEventListener( 'mouseout', onScrollComplete, data );
+ data.rootData.addEventListener( 'mousewheel', onMouseWheelScroll, data );
+ data.rootData.addEventListener( 'mousedrag', onMouseDragScroll, data );
+ data.addEventListener( 'mouseout', onMouseOut, data );
currentNodeData = data;
ScrollBarManager.update( data );
};
- function onScrollComplete( e ){
- if( currentNodeData === null ) return;
-
+ function scrollRelease(){
var data = currentNodeData;
var parent = elmScroller.parentNode;
parent.appendChild( currentNodeData.elm );
parent.removeChild( elmScroller );
currentNodeData.elm.scrollTop = -data.scrollingY;
- data.removeEventListener( 'mousewheel', onMouseWheelScroll, data );
- data.removeEventListener( 'mousedrag', onMouseDragScroll, data );
- data.removeEventListener( 'mouseout', onScrollComplete, data );
+ data.rootData.removeEventListener( 'mousewheel', onMouseWheelScroll, data );
+ data.rootData.removeEventListener( 'mousedrag', onMouseDragScroll, data );
+ data.removeEventListener( 'mouseout', onMouseOut, data );
currentNodeData = null;
- };
+ };
+ function onMouseOut( e ){
+ dragOut = true;
+ console.log( 'mouseOut ' + dragPhase );
+ dragPhase === 2 && scrollRelease(); // Dragしてのアウトの場合, scroll をリリースしない
+ };
function onMouseWheelScroll( e ){
var data = this;
this._scrollY += e.wheelDelta;
function onMouseDragScroll( e ){
var data = this;
//e.dragOffsetY;
- this._scrollY = this.scrollStartY + e.dragOffsetY;
- ScrollBarManager.update( this );
- this.scrollStartY = this._scrollY;
currentEvent = e;
- return true;
+ dragPhase = e.dragPhase;
+ switch( dragPhase ){
+ case 0:
+ dragStartY = this.scrollingY;
+ data.rootData.removeEventListener( 'mousewheel', onMouseWheelScroll, data );
+ case 1:
+ this._scrollY = dragStartY + e.dragOffsetY;
+ ScrollBarManager.update( this );
+ return true;
+ case 2:
+ dragOut === true ? scrollRelease() : data.rootData.addEventListener( 'mousewheel', onMouseWheelScroll, data );
+ return false;
+ };
};
return {
register : function( data ){
- data.addEventListener( 'mouseover', onScrollStart, data );
+ data.addEventListener( 'mouseover', scrollReady, data );
},
update : function( data ){
if( data !== currentNodeData ) return;
if( pageNodes.length !== 0 ){
if( Type.isFunction( gOS.PageApplicationClass ) === true ){
Page.appClass = gOS.PageApplicationClass;
- Page.appClass.bgColor = Page.appClass.bgColor || '#ffffff';
+ Page.appClass.bgColor = Page.appClass.bgColor;
Page.appClass.MIN_WIDTH = Page.appClass.MIN_WIDTH || 240;
Page.appClass.MIN_HEIGHT = Page.appClass.MIN_HEIGHT || 240;
} else {
};
};
ref = Application.register( Page.appClass, false, true, document.title, 'page', null, Page.appClass.tailColor || '#999999' );
+ if( Type.isFunction( gOS.PageApplicationClass ) === true ){
+ gOS.PageApplicationRef = ref;
+ };
};
delete Page.onReady;
},
this.mousemoveTicket = new EventTicketClass( this.element, 'mousemove', this.mousemoveHandler, this );
this.mouseupTicket = new EventTicketClass( this.element, 'mouseup', this.mouseupHandler, this );
- this.mouseoutTicket = new EventTicketClass( this.element, 'mouseout', this.mouseoutHandler, this );
+ this.mouseoutTicket = new EventTicketClass( this.element, 'mouseout', this.mouseoutHandler, this );
+ return false;
},
mousemoveHandler : function( e ){
var offsetX = e.clientX - this.startX,
offsetY = e.clientY - this.startY;
offsetX * offsetX + offsetY * offsetY >= CLICK_OFFSET && this.mouseoutHandler();
+ return false;
},
mouseupHandler : function( e ){
this.mouseoutHandler();
if( this.mousemoveTicket ) delete this.mousemoveTicket;
if( this.mouseupTicket ) delete this.mouseupTicket;
if( this.mouseoutTicket ) delete this.mouseoutTicket;
+ return false;
},
destroy : function( _element, _eventType, _handler ){
if( this.match( _element, _eventType, _handler ) === false ) return false;
this.mousemoveTicket = new EventTicketClass( this.element, 'mousemove', this.dragMoveHandler, this );
this.mouseupTicket = new EventTicketClass( this.element, 'mouseup', this.dragEndHandler, this );
this.mouseoutTicket = new EventTicketClass( this.element, 'mouseout', this.dragEndHandler, this );
+
+ return false;
},
dragMoveHandler : function( e ){
var offsetX = e.clientX - this.startX,
offsetY = e.clientY - this.startY;
if( this.dragging === false ){
if( offsetX * offsetX + offsetY * offsetY < DRAG_OFFSET ) return;
+ console.log( 'Drag start' );
// dragStart
this.dragging = true;
return this.fire( DragEventTicketClass.createEvent( e, offsetX, offsetY, 0 ) );
return this.fire( DragEventTicketClass.createEvent( e, offsetX, offsetY, 1 ) );
},
dragEndHandler : function( e ){
- var offsetX = e.clientX - this.startX,
- offsetY = e.clientY - this.startY;
if( this.dragging === true ){
+ console.log( 'Drag End ' + e.type );
this.removeEvents();
// dragEnd
- return this.fire( DragEventTicketClass.createEvent( e, offsetX, offsetY, 2 ) );
+ return this.fire( DragEventTicketClass.createEvent( e, e.clientX - this.startX, e.clientY - this.startY, 2 ) );
};
this.removeEvents();
+ return false;
},
removeEvents : function(){
this.dragging = false;
this.mouseupTicket.destroy();
delete this.mouseupTicket;
};
- if( this.mouseoutTicket ){
+ if( this.mouseoutTicke ){
this.mouseoutTicket.destroy();
delete this.mouseoutTicket;
};
this.elm.className = 'file-icon-' + this.file.getType();
this.elm.innerHTML = this.file.getName();
},
+ textWidth : function(){
+ this.elm.style.width = 'auto';
+ var ret = this.elm.offsetWidth;
+ this.elm.style.width = '';
+ return ret;
+ },
+ update : function( x, w ){
+ this.node.update( x, undefined, w - 15 );
+ },
resize : function(){
this.elm.style.left = ( this._index * 90 ) + 'px';
},
* FinderPrivateData
*/
var FinderPrivateData = function(){};
+ FinderPrivateData.MIN_PATH_WIDTH = 25;
FinderPrivateData.prototype = {
finder : null,
apiuser : null,
startIndex = 0 < iconList.length ? iconList[ 0 ]._index : 0,
icon;
- console.log( ' > ' + scrollY + ' , ' + rootH )
+ // console.log( ' > ' + scrollY + ' , ' + rootH )
for( ; i < l; ++i ){
if( ( i + 1 ) * ICON_HEIGHT < scrollY || rootH < i * ICON_HEIGHT ){
if( iconList.length <= j ) continue;
data.drawBody( _w, _h );
data.nodeRoot.invalidateScrollbar();
},
- drawPath : function( _w ){
+ drawPath : function( w ){
if( !this.elmPath.parentNode ) return;
-
+ w = this.nodePath.width();
var data = this,
tree = data.tree,
pathList = data.pathList,
i = 0,
l = tree.hierarchy() + 1,
m = pathList.length,
- file;
+ wList = [],
+ totalW = 0,
+ minW = FinderPrivateData.MIN_PATH_WIDTH,
+ file, path, pathW, offset, remove, pathX = 0, fit = false;
for( ; i < l; ++i ){
file = i !== l - 1 ? tree.getParentFileAt( i ) : tree.getCurrentFile();
};
};
while( l < pathList.length ) pathList.pop().destroy();
+
+ for( i = l; i; ){
+ pathW = pathList[ --i ].textWidth();
+ wList.push( pathW );
+ totalW += pathW;
+ };
+
+ //if( minW * ( l + 1 ) * 1.2 < w ){
+ console.log( totalW + ' , ' + w )
+ while( true ){
+ if( fit === true ) break;
+ for( i = 0; i < l; ++i ){
+ offset = totalW - w;
+ if( offset <= 0 ){
+ fit = true;
+ break;
+ };
+ remove = l - i;
+ remove = offset < remove ? offset : remove;
+ pathW = wList[ i ];
+ if( pathW - remove < minW ){
+ totalW -= ( pathW - minW );
+ wList[ i ] = minW;
+ } else {
+ wList[ i ] = pathW - remove;
+ totalW -= remove;
+ };
+ };
+ };
+ for( i = 0; i < l; ++i ){
+ path = pathList[ i ];
+ pathW = wList[ i ];
+ path.update( pathX, pathW );
+ pathX += pathW;
+ };
+ //} else {
+
+ //};
},
drawBody : function( _w, _h ){
var data = this,