From 51dca152ebe7bcd2fe387ebacf1ba54a1ead5259 Mon Sep 17 00:00:00 2001 From: itozyun Date: Fri, 31 Aug 2012 09:21:15 +0900 Subject: [PATCH] version 0.5.10, add folders: MyPanels, LatestPanel. --- Gemfile | 1 - Gemfile.lock | 3 - app/assets/javascripts/peta.apps.js | 58 +- app/assets/javascripts/peta.common.js | 198 +- app/assets/javascripts/system.js | 1042 +++++-- public/assets/peta.apps.js | 5088 --------------------------------- 6 files changed, 809 insertions(+), 5581 deletions(-) delete mode 100644 public/assets/peta.apps.js diff --git a/Gemfile b/Gemfile index 258ae6df..49c23c16 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,6 @@ gem "standard_licenses" gem "creative_commons_v30_licenses" gem 'pettan_commons_v01_licenses' gem 'pettan_protected_v01_licenses' -gem 'pettan_public_v01_licenses' gem 'public_domain_v01_licenses' gem 'unknown_v01_licenses' diff --git a/Gemfile.lock b/Gemfile.lock index 34911c79..6d848711 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,8 +103,6 @@ GEM rails (~> 3.1.1) pettan_protected_v01_licenses (0.0.5) rails (~> 3.1.1) - pettan_public_v01_licenses (0.0.5) - rails (~> 3.1.1) pg (0.14.0-x86-mingw32) polyglot (0.3.3) public_domain_v01_licenses (0.0.5) @@ -217,7 +215,6 @@ DEPENDENCIES moro-miso pettan_commons_v01_licenses pettan_protected_v01_licenses - pettan_public_v01_licenses pg public_domain_v01_licenses rails (= 3.1.1) diff --git a/app/assets/javascripts/peta.apps.js b/app/assets/javascripts/peta.apps.js index 3622d1a8..73403522 100644 --- a/app/assets/javascripts/peta.apps.js +++ b/app/assets/javascripts/peta.apps.js @@ -1,6 +1,6 @@ /* * pettanR peta.apps.js - * version 0.5.8 + * version 0.5.10 * * author: * itozyun @@ -8,8 +8,7 @@ * 3-clause BSD */ -( function( pettanr, gOS, window, undefined ){ - +( function( pettanr, gOS, window, document, undefined ){ /* * PettanR service driver. */ @@ -31,9 +30,9 @@ if( Type.isArray( _json ) === true ){ l = _json.length; - if( l === 0) return; + if( l === 0 ) return; for( var i=0; i 0 ){ - var _id = _data.id - 1, - __data = _array[ _id ], + if( Type.isNumber( _data.id ) === true && _data.id > 0 ){ + var _id = _data.id - 1, + __data = _array[ _id ], _reserved = Const.FILE.DATA_PROPERTY_RESERVED.join( ', ' ); if( __data ){ - for( var key in _data){ + for( var key in _data ){ if( _reserved.indexOf( key ) === -1 ){ __data[ key ] = _data[ key ]; }; @@ -118,7 +117,7 @@ _array[ _id ] = _data; }; } else { - alert( 'error' ); + // alert( 'error' + _parent.name + ' ' + _data.id ); }; // Author @@ -130,7 +129,7 @@ if( _parent.type === FILE_TYPE.COMIC || _parent === FILE_DATA_COMICS_ROOT ){ var _panels = _data.stories, _panel; - if( _panels && Type.isArray( _panels ) === true ){ + if( Type.isArray( _panels ) === true ){ for( i=0, l=_panels.length; i 1){ - var _cssTexts = _elm.style.cssText.split( ';'), _css, - _separate, - _cssObject = {}, _target, _value, _number, _px, - j; - for(var i=0, l=_cssTexts.length; i= 3){ - _target = _css.substr( 0, _separate +1); - _value = _css.substr( _separate +1); - /* - * ie filter - */ - if( _target === FILTER){ - for( j=0; j<_numAttributes; ++j){ - if( _targetAttributes[ j] === OPACITY){ - _cssTexts[ i] = [ - _target, ':', - _value.replace( REG_ALPHA, "alpha(opacity=" + _updateParameters[ j] * 100 + ")") - ].join( ''); - break; - } - } - /* - * other - */ - } else { - _number = '' + parseFloat( _value); - _px = _value.indexOf( _number); - _px = _px > 0 ? _value.substr( _px + _number.length) : ''; - for( j=0; j<_numAttributes; ++j){ - if( _targetAttributes[ j] === _target){ - _cssTexts[ i] = [ _target, ':', _updateParameters[ j], _px].join( ''); - break; - } - } - } - } - } - _elm.style.cssText = _cssTexts.join( ';'); - return; - } - /* - * 一度に update する Attributes が少ない場合、cssText は使用しない. - */ - } - - var AnimationTaskClass = function( ELM, currentParameters, offsetParameters, endParameters, targetAttributes, onComplete, onEnterFrame, numFrames){ - var l = targetAttributes.length; - return { - elm: ELM, - onEnterFrame: function(){ - var _updateCss = {}, i; - if( numFrames === 1){ - for( i=0; i= 0) ? tv: undefined; + acme.isKhtml = (dav.indexOf("Konqueror") >= 0) ? tv : undefined; + acme.isWebKit = parseFloat(dua.split("WebKit\/")[1]) || undefined; + acme.isChrome = parseFloat(dua.split("Chrome\/")[1]) || undefined; + acme.isGecko = (dua.indexOf("Gecko\/") >= 0) ? parseFloat(dua.split("rv:")[1].replace( /^(\d*\.\d*)\.(\d*)/, '$1$2' )) : undefined; + var index = Math.max(dav.indexOf("WebKit"), dav.indexOf("Safari"), 0); + if(index && !acme.isChrome){ + acme.isSafari = parseFloat(dav.split("Version/")[1]); + if(!acme.isSafari || parseFloat(dav.substr(index + 7)) <= 419.3){ + acme.isSafari = 2; + } + } + if(document.all && !acme.isOpera){ + acme.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined; + } + + return acme; + })(), + isIE = navigator.userAgent.toLowerCase().indexOf( 'msie') !== -1, + ieVersion = isIE === true ? parseInt( navigator.appVersion.toLowerCase().replace( /.*msie[ ]/, '').match( /^[0-9]+/)) : 0, + ieRenderingVersion = ieVersion === 8 ? document.documentMode : ieVersion, + isStanderdMode = document.compatMode === 'CSS1Compat', + ActiveX = ( function(){ + if( isIE === false || ieVersion > 8 ) return false; + var b = document.body, + c = b.className || '', + x, + ret = undefined, //pettanr.URL_PARAMS.ActiveX, + ns = 'pettanr-ActiveX-', + enabled = 'enabled', + disabled = 'disabled'; + if( ret !== true && ret !== false){ + if( b.className.indexOf( ns + enabled ) !== -1 ) return true; + if( b.className.indexOf( ns + disabled ) !== -1 ) return false; + x = document.createElement( 'div' ); + b.appendChild(x); + x.style.cssText = 'width:1px;height:1px;line-height:1px;filter:progid:DXImageTransform.Microsoft.Shadow()'; + ret = x.offsetHeight > 1; + b.removeChild(x); + } + b.className += [ c !== '' ? ' ' : c, ns, ret === true ? enabled : disabled ].join( ''); + return ret; + })(), + VML = ( function(){ + if( ActiveX === false || isIE === false || ieVersion > 8) return false; + var globalObjectName = 'detect_activex',//Util.createGlobalUniqueName(), + script, + id = 'detectVML'; + document.write( [ ''].join( '')); + if( window[ globalObjectName ] === 1 ){ + script = document.getElementById( id ); + script.parentNode.removeChild( script ); + window[ globalObjectName ] = null; + return true; + } + return false; + })(), + isStandAloneMode = ( function(){ + if( isIE === false) return false; + if( VML === true) return false; + var globalObjectName = 'detect_standalone', //Util.createGlobalUniqueName(), + script, + id = 'detectStandAlone'; + document.write( [ ''].join( '')); + if( window[globalObjectName] === 1){ + script = document.getElementById( id); + script.parentNode.removeChild( script); + window[globalObjectName] = null; + return false; + } + return true; + })(); + return { + IE: ua.isIE, + GECKO: ua.isGecko, + OPERA: ua.isOpera, + KHTML: ua.isKhtml, + WEBKIT: ua.isWebKit, + CHROME: ua.isChrome, + isIE: isIE, + ieVersion: ieVersion, + ieRenderingVersion: ieRenderingVersion, + isStanderdMode: isStanderdMode, + ACTIVEX: ActiveX, + VML: VML, + STANDALONE: isStandAloneMode, + VENDER_PREFIX: ( function() { + var ua = navigator.userAgent.toLowerCase(); + if ( ua.indexOf('opera') !== -1 ){ + return 'O'; + } else if ( ua.indexOf('msie') !== -1 ){ + return 'ms'; + } else if ( ua.indexOf('webkit') !== -1 ){ + return 'webkit'; + } else if ( navigator.product === 'Gecko' ){ + return 'Moz'; + } + return ''; + })(), + startVML: function(){ + delete UA.startVML; + if( UA.VML !== true) return false; + if (!document.namespaces["v"]) { + document.namespaces.add("v", "urn:schemas-microsoft-com:vml", "#default#VML"); + } + document.createStyleSheet().cssText = "v\:shape,v\:image{behavior:url(#default#VML);display:block;};"; + } + } + })(); + + /* ---------------------------------------------------- * Util * @@ -104,50 +229,153 @@ var ret = doc.createElement( 'DIV' ); body.appendChild( ret ); - ret.id = 'elmSizeGetter'; - ret.style.cssText = 'position:absolute;left:0;top:-9999px;visibility:hidden'; + ret.id = 'elmSizeGetter'; + ret.style.cssText = 'position:absolute;left:0;top:-9999px;visibility:hidden'; body.removeChild( ret ); return ret; })(), CLEAN_TARGET_ELEMENT = 'script,style,object,applet,embed,iframe,frame,base,bgsound,frameset,listing'.split( ',' ); - /* clean comment node */ - cleanCommnetNode(); + var UNIT_RATIO = ( function( elm ){ + var ret = {}, + unit, + units = 'px,cm,mm,in,pt,pc'.split( ',' ); + + body.appendChild( elm ); + + for( var i=units.length; i; ){ + unit = units[ --i ]; + elm.style.width = 1000 + unit; + ret[ unit ] = elm.offsetWidth / 1000; + }; + body.removeChild( elm ); + elm.style.cssText = ''; + + return ret; + })( ELM_SIZE_GETTER ); + + var FONT_SIZE_RATIO = ( function( elm ){ + var ret = {}, + size, + list = 'xx-large,x-large,large,larger,medium,small,smaller,x-small,xx-small'.split( ',' ); + + body.appendChild( elm ); + elm.style.cssText = 'font-size:100px;line-height:1em;'; + elm.appendChild( document.createTextNode( 'X' ) ); + + base = elm.offsetHeight; + + for( var i = list.length; i; ){ + size = list[ --i ]; + elm.style.fontSize = size; + ret[ size ] = elm.offsetHeight;// / base; + }; + body.removeChild( elm ); + elm.style.cssText = ''; + elm.removeChild( elm.firstChild ); + + return ret; + })( ELM_SIZE_GETTER ); - /* clean noscript */ - ( function(){ - var nodeNoscript = doc.getElementsByTagName( 'noscript' ), - noscript; - for( var i=0; i array - for( i=0, l=_children.length; i array + while( _array.length > 0 ) search( _array.shift() ); + }; + }; + }, cleanElement: function( _targetElm ){ - var _nodes, _elm, _array, j, m; - for( var i=0, l=CLEAN_TARGET_ELEMENT.length; i'; - return e.firstChild.href; + getAbsolutePath: function( path ){ + var elm = document.createElement('div'); + body.appendChild( elm ); + elm.innerHTML = ''; + body.removeChild( elm ); + return elm.firstChild.href; }, getAbsolutePosition: function( _elm ){ // Find the destination's position @@ -308,24 +606,36 @@ }, pullHtmlAsTemplete: function( html ){ var elm = document.createElement( 'div' ); + body.appendChild( elm ); elm.innerHTML = html; + body.removeChild( elm ); return elm.firstChild; }, - getElementsByClassName: function( _elm, _className, opt_tagName){ - var _all = !opt_tagName || opt_tagName === '*', - _nodes = _all === true ? ( _elm.all || _elm.getElementsByTagName( '*')) : _elm.getElementsByTagName( opt_tagName), - _node, _classes, ret = []; - for( var i=0, l = _nodes.length; i= 0) ? tv: undefined; - acme.isKhtml = (dav.indexOf("Konqueror") >= 0) ? tv : undefined; - acme.isWebKit = parseFloat(dua.split("WebKit\/")[1]) || undefined; - acme.isChrome = parseFloat(dua.split("Chrome\/")[1]) || undefined; - acme.isGecko = (dua.indexOf("Gecko\/") >= 0) ? parseFloat(dua.split("rv:")[1].replace( /^(\d*\.\d*)\.(\d*)/, '$1$2' )) : undefined; - var index = Math.max(dav.indexOf("WebKit"), dav.indexOf("Safari"), 0); - if(index && !acme.isChrome){ - acme.isSafari = parseFloat(dav.split("Version/")[1]); - if(!acme.isSafari || parseFloat(dav.substr(index + 7)) <= 419.3){ - acme.isSafari = 2; - } - } - if(document.all && !acme.isOpera){ - acme.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined; - } - - return acme; - })(), - isIE = navigator.userAgent.toLowerCase().indexOf( 'msie') !== -1, - ieVersion = isIE === true ? parseInt( navigator.appVersion.toLowerCase().replace( /.*msie[ ]/, '').match( /^[0-9]+/)) : 0, - ieRenderingVersion = ieVersion === 8 ? document.documentMode : ieVersion, - isStanderdMode = document.compatMode === 'CSS1Compat', - ActiveX = ( function(){ - if( isIE === false || ieVersion > 8 ) return false; - var b = document.body, - c = b.className || '', - x, - ret = undefined, //pettanr.URL_PARAMS.ActiveX, - ns = 'pettanr-ActiveX-', - enabled = 'enabled', - disabled = 'disabled'; - if( ret !== true && ret !== false){ - if( Util.hasClassName( b, ns + enabled) === true ) return true; - if( Util.hasClassName( b, ns + disabled) === true ) return false; - x = document.createElement( 'div' ); - b.appendChild(x); - x.style.cssText = 'width:1px;height:1px;line-height:1px;filter:progid:DXImageTransform.Microsoft.Shadow()'; - ret = x.offsetHeight > 1; - b.removeChild(x); - } - b.className += [ c !== '' ? ' ' : c, ns, ret === true ? enabled : disabled ].join( ''); - return ret; - })(), - VML = ( function(){ - if( ActiveX === false || isIE === false || ieVersion > 8) return false; - var globalObjectName = Util.createGlobalUniqueName(), - script, - id = 'detectVML'; - document.write( [ ''].join( '')); - if( window[globalObjectName] === 1){ - script = document.getElementById( id); - script.parentNode.removeChild( script); - window[globalObjectName] = null; - return true; - } - return false; - })(), - isStandAloneMode = ( function(){ - if( isIE === false) return false; - if( VML === true) return false; - var globalObjectName = Util.createGlobalUniqueName(), - script, - id = 'detectStandAlone'; - document.write( [ ''].join( '')); - if( window[globalObjectName] === 1){ - script = document.getElementById( id); - script.parentNode.removeChild( script); - window[globalObjectName] = null; - return false; - } - return true; - })(); - return { - IE: ua.isIE, - GECKO: ua.isGecko, - OPERA: ua.isOpera, - KHTML: ua.isKhtml, - WEBKIT: ua.isWebKit, - CHROME: ua.isChrome, - isIE: isIE, - ieVersion: ieVersion, - ieRenderingVersion: ieRenderingVersion, - isStanderdMode: isStanderdMode, - ACTIVEX: ActiveX, - VML: VML, - STANDALONE: isStandAloneMode, - VENDER_PREFIX: ( function() { - var ua = navigator.userAgent.toLowerCase(); - if ( ua.indexOf('opera') !== -1 ){ - return 'O'; - } else if ( ua.indexOf('msie') !== -1 ){ - return 'ms'; - } else if ( ua.indexOf('webkit') !== -1 ){ - return 'webkit'; - } else if ( navigator.product === 'Gecko' ){ - return 'Moz'; - } - return ''; - })(), - startVML: function(){ - delete UA.startVML; - if( UA.VML !== true) return false; - if (!document.namespaces["v"]) { - document.namespaces.add("v", "urn:schemas-microsoft-com:vml", "#default#VML"); - } - document.createStyleSheet().cssText = "v\:shape,v\:image{behavior:url(#default#VML);display:block;};"; - } - } + }; })(); @@ -570,7 +756,7 @@ * */ -( function( window, undefined ){ +( function( window, document, undefined ){ var doc = window.document; var body = doc.getElementsByTagName( 'body' )[ 0 ]; //( doc.compatMode || '' ) !== 'CSS1Compat' ? doc.body : doc.documentElement;// @@ -988,13 +1174,13 @@ var File = ( function(){ getFileUID: function( FILEDATAorFILE ){ if( FILEDATAorFILE instanceof FileClass ){ return FILEDATAorFILE.getUID(); - } + }; var uid = Util.getIndex( FILEDATA_RESITER, FILEDATAorFILE ); if( uid === -1 ){ uid = FILEDATA_RESITER.length; FILEDATA_RESITER.push( FILEDATAorFILE ); - } + }; return uid; }, getFileDataAccess: function( UIDorFILEorFILEDATA ){ @@ -1016,7 +1202,7 @@ var File = ( function(){ } else if( Util.getIndex( FILEDATA_RESITER, UIDorFILEorFILEDATA ) !== -1 ){ return UIDorFILEorFILEDATA; - } + }; return null; }, getChildren: function( UIDorFILEorFILEDATA ){ @@ -1060,8 +1246,8 @@ var File = ( function(){ if( _ticket.fileUID === _uid && _ticket.eventType === _eventType && _ticket.callBack === _callback ){ EVENT_LISTENER_REGISTER.splice( i, 1 ); _ticket.kill(); - } - } + }; + }; }, getTreeAccess: function(){ @@ -1081,11 +1267,11 @@ var File = ( function(){ if( FILE_CONTROLER.getFileData( _tree.getCurrentFile() ) === _data ){ _treeAccess = TREE_ACCESS_ARRAY[ _tree.getUID() ]; _treeAccess && _treeAccess.dispatchFileEvent( _event ); - } - } - } + }; + }; + }; } - } + }; var TreeClass = function( apiuser, rootFileData ){ var PARENT_FILE_RESITER = [], @@ -1116,9 +1302,9 @@ var File = ( function(){ if( _type === Const.TREE.EVENT.UPDATE && _eventType === Const.FILE.EVENT.GET_SEQENTIAL_FILES ){ //_callback( _eventType, _targetFile ); AsyncCall.add( apiuser, _callback, [ _eventType, _targetFile ] ); - } - } - } + }; + }; + }; this.getUID = function(){ return Util.getIndex( TREE_ACCESS_ARRAY, ACCESS ); @@ -1179,12 +1365,12 @@ var File = ( function(){ while( PARENT_FILE_RESITER.length > 0 ){ _currentFile = PARENT_FILE_RESITER.shift(); _currentFile.destroy(); - } + }; AsyncCall.remove( apiuser ); instance = apiuser = null; return true; - } + }; }; var FileEventTicketClass = function( _uid, _eventType, _callback ){ @@ -2163,10 +2349,10 @@ var Application = ( function(){ this.screenX = e.screenX; this.screenY = e.screenY; + this.charCode = e.keyCode; this.altKey = e.altKey; this.ctrlKey = e.ctrlKey; this.shiftKey = e.shiftKey; - this.charCode = e.keyCode; this.wheelDelta = e.wheelDelta; @@ -2349,55 +2535,52 @@ var Application = ( function(){ }; var ReadyEvent = ( function(){ - var timer = null, - script = null, - ticketReady, + var ticketReady, ticketLoad; - function detect(){ + function webkitDetect(){ var state = document.readyState; if( state === 'loaded' || state === 'complete' ){ - timer && window.clearInterval( timer ); + SystemTimer.remove( SUPER_USER_KEY, webkitDetect ); timer = null; onReady(); - } - } + }; + }; function ieDetect(){ - if( this.readyState === 'loaded' || this.readyState === 'complete' ){ + if( this.readyState === 'complete' ){ // this.readyState === 'loaded' || this.onreadystatechange = new Function(); this.onreadystatechange = null; this.parentNode.removeChild( this ); - script = null; onReady(); - } - } - + }; + }; + function onReady(){ + ticketReady && ticketReady.destroy(); + ticketLoad && ticketLoad.destroy(); + ticketReady = ticketLoad = null; Page.onReady(); if( Page.registered() === true ){ Page.boot(); } else { Home.boot(); - } - ticketReady && ticketReady.destroy(); - ticketLoad && ticketLoad.destroy(); - ticketReady = ticketLoad = null; - } + }; + }; // Apple WebKit (Safari, OmniWeb, ...) if( doc.readyState && !!UA.WEBKIT ){ - timer = window.setInterval( detect, 50 ); + SystemTimer.add( SUPER_USER_KEY, webkitDetect, 50 ); } else + /* if( document.readyState && UA.isIE && UA.ieVersion < 9 ){ - document.write('