/*
* pettanR peta.apps.js
- * version 0.5.30
+ * version 0.5.31
*
* author:
* itozyun
//node.mesure();
app.onPaneResize( windowW, windowH );
- delete app.onFoemReady;
+ delete app.onFormReady;
};
this.submitError = function(){
app.addTimer( clickCancel , 5000, true );
var UploadConsole = gOS.registerApplication( function(){
var windowW, windowH,
- eventRoot, node,
+ eventRoot, node, nodeForm,
buttonSubmit, buttonCancel,
elmFile,
app = this;
app.rootElement.innerHTML = [
'<div id="upload-console-header" class="console-header">Upload Picture</div>',
'<div id="upload-console" class="console-inner">',
- '<div id="uploader"></div>',
+ '<div id="upload-console-uiform"></div>',
'<div class="console-button-container">',
'<div id="upload-console-post-button" class="button console-submit-button">upload</div>',
'<div id="upload-console-cancel-button" class="button console-cancel-button">cancel</div>',
app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
eventRoot = app.getPointingDeviceEventTreeRoot();
-
+ document.body.appendChild( Util.pullHtmlAsTemplete( '<div id="uploader"></div>' ) );
delete app.onInit;
};
this.elmProgressID = 'upload-console-progress';
this.scriptSrc = pettanr.CONST.UPLOAD_PICTURE_JS;
this.hideUploader = false;
FormApplicationHelper( this );
+ this.onOpen = function( w, h ){
+ node = eventRoot.createNode( app.rootElement, true, true );
+ nodeForm = node.createNode( document.getElementById( 'upload-console-uiform' ), false, true );
+ var ui = app.createUIGroup( node );
+
+ buttonSubmit = ui.createButton( document.getElementById( 'upload-console-post-button' ), clickOK );
+ buttonCancel = ui.createButton( document.getElementById( 'upload-console-cancel-button' ), clickCancel );
+
+ app.onPaneResize( w, h );
+ app.fetchScript();
+ };
+ this.onPaneResize = function( w, h ){
+ windowW = w;
+ windowH = h;
+ node.update( w / 2 - node.width() / 2, h / 2 - node.height() / 2 );
+ };
+ this.onClose = function(){
+ app.destroyHelper();
+ app = elmFile = buttonSubmit = buttonCancel = null;
+ };
this.onFormReady = function(){
- var _inputList = app.elmForm.getElementsByTagName( 'input' ),
+ var elmForm = app.elmForm,
+ _inputList = elmForm.getElementsByTagName( 'input' ),
_input;
for( var i = _inputList.length; i; ){
_input = _inputList[ --i ];
};
node.mesure();
app.onPaneResize( windowW, windowH );
+ app.createUIForm( nodeForm, elmForm );
node.mesureChildren();
- delete app.onFoemReady;
+ delete app.onFormReady;
};
this.submitError = function(){
app.addTimer( clickCancel , 5000, true );
this.submitSuccess = function(){
app.addTimer( clickCancel , 5000, true );
};
- this.onOpen = function( w, h ){
- node = eventRoot.createNode( app.rootElement, true, true );
- var ui = app.createUIGroup( node );
-
- buttonSubmit = ui.createButton( document.getElementById( 'upload-console-post-button' ), clickOK );
- buttonCancel = ui.createButton( document.getElementById( 'upload-console-cancel-button' ), clickCancel );
-
- app.onPaneResize( w, h );
- app.fetchScript();
- };
- this.onPaneResize = function( w, h ){
- windowW = w;
- windowH = h;
- //app.rootElement.style.cssText = [
- // 'left:', Math.floor( ( _w - app.rootElement.offsetWidth ) /2 ), 'px;',
- // 'top:', Math.floor( ( _h- app.rootElement.offsetHeight ) /2 ), 'px;'
- //].join( '' );
- node.update( w / 2 - node.width() / 2, h / 2 - node.height() / 2 );
- };
- this.onClose = function(){
- app.destroyHelper();
- app = elmFile = buttonSubmit = buttonCancel = null;
- };
}, true, true, 'Upload Console', 'uploadConsole', null, '#01A31C' );
var ArtistConsole = gOS.registerApplication( function(){
app.onPaneResize( windowW, windowH );
node.mesureChildren();
- delete app.onFoemReady;
+ delete app.onFormReady;
};
this.submitError = function(){
app.addTimer( clickCancel , 5000, true );
app.onPaneResize( windowW, windowH );
node.mesureChildren();
- delete app.onFoemReady;
+ delete app.onFormReady;
};
this.submitError = function(){
app.addTimer( clickCancel , 5000, true );
/*
* pettanR system.js
- * version 0.5.30
+ * version 0.5.31
*
* gadgetOS
* author:
var API_USER_LIST = [ SUPER_USER_KEY ];
var numApiUser = 1;
+ function EMPTY_FUNCTION(){};
+
function isApiUser( _user ){
return _user === SUPER_USER_KEY ||
File.isDriver( _user ) === true ||
};
var Class = ( function(){
+ var CLASS_LIST = [];
+
+ function getClass( instance ){
+ var list = CLASS_LIST,
+ l = list.length,
+ getIndex = Util.getIndex,
+ klass, live, pool;
+ 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;
+ if( instance instanceof klass ) return klass;
+ };
+ return null;
+ };
+
function clone( src ){
- var ret;
- if( Type.isArray(src) === true ){
+ var ret, key;
+ if( Type.isArray( src ) === true ){
ret = [];
} else
- if( Type.isObject(src) === true ){
+ if( Type.isObject( src ) === true ){
ret = {};
} else
- if( Type.isNumber(src) === true || Type.isString(src) === true || Type.isBoolean( src ) === true ){
+ if( Type.isNumber( src ) === true || Type.isString( src ) === true || Type.isBoolean( src ) === true ){
return src;
} else {
return null;
};
- for( var key in src ){
+ for( key in src ){
ret[ key ] = clone( src[ key ]);
};
return ret;
};
+ function copy( base, extend ){
+ for( var key in extend ){
+ base[ key ] = extend[ key ];
+ };
+ return base;
+ };
+
function extend(){
};
+ var basic = {
+ clear : function(){
+ var o = this,
+ p, v,
+ klass = getClass( o );
+ for( p in o ){
+ if( o.hasOwnProperty && !o.hasOwnProperty( p ) ) continue;
+ v = o[ p ];
+ delete o[ p ];
+ };
+ if( klass && klass.pool ){
+ klass.live.splice( Util.getIndex( klass.live, o ), 1 );
+ klass.pool.push( o );
+ };
+ }
+ };
+
var f = true;
var c = Util.copyArray;
-
+ var a;
function I(){
- var klass = this;
- f = false;
- var instance = klass.pool.shift() || new klass();
- f = true;
- instance.init.apply( instance, c( arguments ) );
- klass.live.push( instance );
+ var klass = this,
+ instance;
+ if( klass.abstract === true ){
+ throw new Error( 'AbstractClass!' );
+ };
+ if( klass.pool && klass.pool.length > 0 ){
+ instance = klass.pool.shift();
+ } else {
+ f = false;
+ instance = new klass();
+ f = true;
+ };
+ if( klass._super ){
+ instance._super = klass._super.prototype;
+ };
+ instance.init && instance.init.apply( instance, c( arguments ) );
+ klass.live && klass.live.push( instance );
return instance;
};
return {
create : function( def, final, pool, abstract ){
var klass = function(){
- var a = arguments;
+ a = arguments;
if( f ) return I.apply( a.collee, c( a ) );
};
- klass.prototype = def;
+ klass.prototype = copy( copy( {}, basic ), def );
+ if( final !== true ){
+ klass.extend = extend;
+ };
if( pool === true ){
klass.pool = [];
klass.live = [];
};
+ if( abstract === true ){
+ klass.abstract = true;
+ };
return klass;
}
- }
+ };
})();
var TicketBase = function(){
this.kill = function(){
- var t = this, v;
- for( var p in t ){
+ var t = this, v, p;
+ for( p in t ){
if( t.hasOwnProperty && !t.hasOwnProperty( p ) ) continue;
v = t[ p ];
v && v instanceof TicketBase && v.kill();
delete t[ p ];
- }
+ };
};
};
rootElement : null,
bgColor : '#C1CACF',
uiList : null,
+ formList : null,
finderList : null,
styleCursor : null,
eventRoot : null,
h : 0,
init : function( appClass, displayName, isOverlay ){
this.appClass = appClass;
+ // this.application = app;
this.displayName = displayName;
this.isOverlay = isOverlay;
this.rootElement = document.createElement( 'div' );
},
init : function(){
var data = ApplicationPrivateData.get( this );
- this.rootElement = data.rootElement;
- data.application = this;
+ // this.rootElement = data.rootElement;
+ // data.application = this;
data.phase = 1;
data.appClass === Page.appClass && Page.show();
this.onInit();
data.uiList.push( ui );
return ui;
},
+ createUIForm : function( nodeOrElm, opt_elmForm ){
+ var data = ApplicationPrivateData.get( this ),
+ form = UIForm.createForm( this, nodeOrElm, opt_elmForm );
+ if( data.formList === null ) data.formList = [];
+ data.formList.push( form );
+ return form;
+ },
createFinder : function( _elmTarget, _tree, _onSelect, _viewerOption, _editorOption ){
var data = ApplicationPrivateData.get( this ),
finder = Finder.create( this, _elmTarget, _tree, _onSelect, _viewerOption, _editorOption );
this.handler = stayhandler;
this.thisObject = opt_thisObject;
};
- StayEventTicketClass.prototype = {
- type : 'mousestay',
- mousestayHandler : function( e ){
+ StayEventTicketClass.prototype = Util.extend( new EventTicketClass( null, 'mousestay' ), {
+ // type : 'mousestay',
+ e : null,
+ mouseoverHandler : function( e ){
+ this.e = NodePrivateData.createEvent( e, this.type, this.data, true );
this.node.addEventListener( 'mouseout', this.mousestayHandler, this );
this.node.addEventListener( 'mousemove', this.mousemoveHandler, this );
SystemTimer.add( this.data.apiuser, this.timeoutHandler, null, this );
},
timeoutHandler : function(){
this.mouseoutHandler();
- return this.fire( );
+ return this.fire( this.e );
},
- mouseoutHandler : function( e ){
+ mousemoveHandler : function( e ){
+ this.e = NodePrivateData.createEvent( e, this.type, this.data, true );
SystemTimer.remove( this.data.apiuser, this.timeoutHandler );
SystemTimer.add( this.data.apiuser, this.timeoutHandler, null, this );
},
this.node.removeEventListener( 'mouseout', this.mousestayHandler );
this.node.removeEventListener( 'mousemove', this.mousemoveHandler );
SystemTimer.remove( this.data.apiuser, this.timeoutHandler );
+ delete this.e;
}
- };
+ });
var ScrollBarManager = ( function(){
var elmScroller = document.createElement( 'div' ),
var application = new appClass(),
data = ApplicationPrivateData.get( application );
+ application.rootElement = data.rootElement;
+ data.application = application;
+
coveredApplication = isOverlay === true ? currentApplication : null;
Application.onCurrentApplicationChange( application );
};
function asyncInit( /* arguments */ ){
application.init();
- elmContainer.insertBefore( application.rootElement, elmCloseButton );
- application.rootElement.style.display = 'none';
+ //application.rootElement.style.display = 'none';
};
function asyncOpen( /* arguments */ ){
var _arg = Util.copyArray( arguments );
application = _application;
//asyncInit();
-
+ elmContainer.insertBefore( application.rootElement, elmCloseButton );
_application.addAsyncCall( asyncInit );
_application.addAsyncCall( asyncOpen, _bootParams );
},
elmInput.value = data.value;
},
onWindowResize: function( _w, _h ){
- AsyncCall.add( currentData.apiuser, updateWrapperPosition );
+ AsyncCall.add( currentUser, updateWrapperPosition );
}
};
})();
var FileInputManager = ( function(){
var currentData,
elmForm,
- elmInput;
+ elmWrap,
+ evt;
function updateWrapperPosition(){
var p = Position.cumulativeOffset( currentData.elmValue ),
- w = currentData.elmValue.offsetWidth - 2,
+ w = currentData.elmValue.offsetWidth,
_w;
- elmInput.style.cssText = [
+ elmWrap.style.cssText = [
'left:', p[ 0 ], 'px;',
'top:', p[ 1 ], 'px;',//,
'width:', w, 'px;'//,
//'position:absolute;'
].join( '' );
- _w = elmInput.offsetWidth;
- if( w !== _w ) elmInput.style.width = ( w - ( _w - w ) ) + 'px;';
+ _w = elmWrap.offsetWidth;
+ if( w !== _w ) elmWrap.style.width = ( w - ( _w - w ) ) + 'px';
};
function change( e ){
var data = currentData,
file = data.elmFileInputReal.value;
+ file = file.split( '\\' );
+ file = file[ file.length - 1 ];
if( data.value !== file ){
data.onUpdate && AsyncCall.add( data.groupData.apiuser, data.onUpdate, [ file, data.value ], this );
- data.elmValue.innerHTML = data.value = value;
- currentData.blur();
- };
+ data.elmValue.innerHTML = data.value = file;
+ };
+ currentData.item.blur();
+ };
+ function asyncMouseout(){
+ currentData && currentData.item.blur();
};
return {
show : function( data ){
currentData = data;
- updateWrapperPosition();
-
- elmInput = data.elmFileInputReal;
- elmInput.focus();
- data.node.addEventListener( 'change', change, data );
+
+ elmWrap = data.elmFileInputReal.parentNode;
+ //
+ updateWrapperPosition();
+ data.elmFileInputReal.focus();
+ //data.node.addEventListener( 'change', change, data );
+ evt = new EventTicketClass( data.elmFileInputReal, 'change', change );
+ // MouseEvent.add( currentUser, data.elmFileInputReal, 'mouseout', asyncMouseout );
+ // MouseEvent.add( elmWrap, 'click', data.elmFileInputReal.focus, data.elmFileInputReal );
+ currentData.elmFileInputReal.onchange = change;
SystemTimer.add( SUPER_USER_KEY, updateWrapperPosition, 500 );
},
hide : function( data ){
if( currentData !== data ) return;
- data.node.removeEventListener( 'change', change );
+ // data.node.removeEventListener( 'change', change );
+ evt.destroy();
+ MouseEvent.remove( currentUser, currentData.elmFileInputReal, 'mouseout', asyncMouseout );
+ currentData.elmFileInputReal.onchange = null;
+ elmWrap.style.display = 'none';
currentData = null;
SystemTimer.remove( SUPER_USER_KEY, updateWrapperPosition );
},
onWindowResize: function( _w, _h ){
- AsyncCall.add( currentData.apiuser, updateWrapperPosition );
+ AsyncCall.add( currentUser, updateWrapperPosition );
}
};
})();
- var FileInputClass = function( groupData, elmWrapper, onUpdate, elmFileInputReal, elmValue ){
+ var FileInputClass = function( groupData, elmWrapper, onUpdate, validater, elmFileInputReal, elmValue ){
var data = new UIItemPrivateData();
data.init( groupData, this, elmWrapper, null, onUpdate, null, false, true, true );
data.node = groupData.node.createNode( elmWrapper, false, true, 'ui-fileinput-hover', 'pointer' );
};
var UIGroupClass = function( apiuser, node ){
- ( new UIGroupPrivateData() ).init( apiuser, node, this );
+ ( new UIGroupPrivateData() ).init( apiuser, node, this );
};
UIGroupClass.prototype = {
focus : function( _value ){
},
createFileInput : function( elm, onUpdate, validater, elmFileInputReal ){
var data = UIGroupPrivateData.get( this ),
- elmValue = Util.getElementsByClassName( elmWrapper, 'fileinput-value' )[ 0 ],
+ elmValue = Util.getElementsByClassName( elm, 'fileinput-value' )[ 0 ],
ret;
if( elmValue ){
ret = new FileInputClass( data, elm, onUpdate, validater, elmFileInputReal, elmValue );
onSystemShutdown: function(){
}
- }
+ };
})();
+var UIForm = ( function(){
+ var FORM_LIST = [];
+ var CLASSNAME_FORM = 'uiform-invisible';
+ var CLASSNAME_FILE_WRAP = 'ui-fileinput-wrapper';
+ var FormItemData = function(){};
+ FormItemData.prototype = {
+ formData : null,
+ uiItem : null,
+ init: function( formData, uiItem ){
+ this.formData = formData;
+ this.uiItem = uiItem;
+ }
+ };
+
+ var FormPrivateData = function(){};
+ FormPrivateData.prototype = {
+ apiuser : null,
+ node : null,
+ form : null,
+ elmForm : null,
+ itemList : null,
+ visible : true,
+ enabled : true,
+ init : function( apiuser, from, node, elm, elmForm ){
+ this.apiuser = apiuser;
+ this.form = form;
+ this.ui = apiuser.createUIGroup( node );
+ this.node = node;
+ this.elm = elm;
+ this.elmForm = elmForm;
+ this.itemList = [];
+ elmForm.className = CLASSNAME_FORM;
+ FormPrivateData.list.push( this );
+
+ var forms = Util.copyArray( elmForm.getElementsByTagName( '*' ) ),
+ l = forms.length,
+ i = 0,
+ items = 'input,select,textarea,button',
+ form, data, el, wrap;
+ for( ; i<l; ++i ){
+ form = forms[ i ];
+ if( form.nodeType !== 1 ) continue;
+ switch( form.tagName.toLowerCase() ){
+ case 'input':
+ switch( form.type.toLowerCase() ){
+ case 'text':
+ break;
+ case 'file':
+ el = Util.pullHtmlAsTemplete( '<div class="uiform-file-container"><div class="uiform-label"></div><div class="uiform-file fileinput-value"></div></div>' );
+ elm.appendChild( el );
+ data = new FormItemData();
+ wrap = document.createElement( 'div' );
+ form.parentNode.insertBefore( wrap, form );
+ wrap.className = CLASSNAME_FILE_WRAP;
+ wrap.appendChild( form );
+ data.init( this, this.ui.createFileInput( el, null, null, form ) );
+ this.itemList.push( data );
+ // alert( i )
+ break;
+ case 'button':
+ break;
+ default:
+ continue;
+ };
+ break;
+ case 'select':
+ break;
+ case 'button':
+ break;
+ case 'textarea':
+ break;
+ default:
+ continue;
+ };
+ };
+ },
+ destroy : function(){
+
+ }
+ };
+ FormPrivateData.list = [];
+ FormPrivateData.get = function( from ){
+ var list = FormPrivateData.list,
+ i = list.length;
+ for( ; i; ){
+ if( list[ --i ].form === form ) return list[ i ];
+ };
+ return null;
+ };
+
+ var FormClass = function( apiuser, node, elm, elmForm ){
+ ( new FormPrivateData() ).init( apiuser, this, node, elm, elmForm );
+ };
+ FormClass.prototype = {
+ createTextInput : function(){
+
+ },
+ createMultiLineInput : function(){
+
+ },
+ createFileInput : function(){
+
+ },
+ createButton : function(){
+
+ },
+ createComboBox : function(){
+
+ },
+ submit : function(){
+
+ }
+ };
+
+ return {
+ createForm: function( apiuser, nodeOrElm, opt_elmForm ){
+ var uid = apiuser.getUID(),
+ list = FORM_LIST[ uid ],
+ node, elm, form;
+ if( PointingDeviceEventTree.isNodeInstance( nodeOrElm ) === true ){
+ node = nodeOrElm;
+ elm = PointingDeviceEventTree._getNodePrivateData( nodeOrElm ).elm;
+ } else {
+ // App が eventTree を持っている?
+ // App が eventTree を持っていない
+ elm = nodeOrElm;
+ };
+ form = new FormClass( apiuser, node, elm, opt_elmForm );
+ if( Type.isArray( list ) === false ){
+ list = FORM_LIST[ uid ] = [];
+ };
+ list.push( form );
+ return form;
+ },
+ onWindowResize: function( w, h ){
+ windowW = w;
+ windowH = h;
+ currentItem instanceof ComboBoxClass && OptionControl.onWindowResize( w, h );
+ currentItem instanceof TextInputClass && TextInputManager.onWindowResize( w, h );
+ currentItem instanceof FileInputClass && FileInputManager.onWindowResize( w, h );
+ },
+ onCurrentApplicationChange: function( _apiuser ){
+ },
+ onApplicationShutdown: function( _apiuser ){
+ },
+ onSystemShutdown: function(){
+
+ }
+ };
+})();
var Finder = ( function(){
var HTML_FINDER_ICON = ( function(){