+ this.displayName = 'Comic list';
+ this.ID = 'Comiclist';
+ this.rootElement = elmContainer;
+ this.onOpen = function( _w, _h, _option ){
+ finder = finder || pettanr.finder.createFinder( elmContainer, pettanr.driver.createComicTree() );
+ finder.open( _w, _h - pageHeaderH, _option );
+ }
+ this.onClose = function(){
+ finder.close();
+ }
+ this.onPaneResize = function( _w, _h){
+ finder.resize( _w, _h - pageHeaderH );
+ }
+});
+pettanr.cabinet.addToLancher();
+
+pettanr.gallery = pettanr.view.registerApplication( function(){
+ var finder,
+ elmContainer = document.getElementById( 'gallery' ),
+ option,
+ pageHeaderH = pettanr.util.getElementSize( document.getElementById( 'header' ) ).height;
+
+ this.displayName = 'Pictures';
+ this.ID = 'pictures';
+ this.rootElement = elmContainer;
+ this.onOpen = function( _w, _h, _option ){
+ finder = finder || pettanr.finder.createFinder( elmContainer, pettanr.driver.createPictureTree() );
+ finder.open( _w, _h - pageHeaderH, _option );
+ }
+ this.onClose = function(){
+ finder.close();
+ }
+ this.onPaneResize = function( _w, _h){
+ finder.resize( _w, _h - pageHeaderH );
+ }
+});
+pettanr.gallery.addToLancher();
+
+pettanr.backyard = pettanr.view.registerApplication( function(){
+ this.displayName = 'Settings';
+ this.ID = 'Settinds';
+ this.rootElement = document.getElementById( 'backyard' );
+ this.onOpen = function( _w, _h, _option ){
+ }
+ this.onClose = function(){
+ }
+ this.onPaneResize = function( _w, _h){
+ }
+});
+pettanr.backyard.addToLancher();
+
+if( pettanr.DEBUG === true){
+ pettanr.debug = pettanr.view.registerApplication( function(){
+ var elmDl = document.getElementById( 'useragent'),
+ elmDt, elmDd,
+ data = {
+ pettanR: pettanr.version,
+ ua: navigator.userAgent,
+ platform: navigator.platform,
+ appVersion: navigator.appVersion,
+ appCodeName:navigator.appCodeName,
+ appName: navigator.appName,
+ language: navigator.browserLanguage || navigator.language,
+ ActiveX: pettanr.ua.ACTIVEX
+ },
+ ua = pettanr.ua;
+ if( ua.IE){
+ //data.ua = 'Internet Explorer';
+ data.version = ua.IE;
+ if( ua.ieVersion >= 8) data.RenderingVersion = ua.ieRenderingVersion;
+ data.browserType = ua.STANDALONE === true ? 'Standalone' : 'bundle';
+ if( ua.ieVersion < 9) {
+ data.vml = ua.VML;
+ } else {
+ data.svg = ua.SVG;
+ }
+ }
+ data.RenderingMode = ua.isStanderdMode === true ? 'Standerd' : 'Quirks';
+
+ for( var key in data){
+ elmDt = document.createElement( 'dt');
+ elmDt.innerHTML = key;
+ elmDd = document.createElement( 'dd');
+ elmDd.innerHTML = '' + data[ key];
+ if( !data[ key]) elmDd.style.color = 'red';
+ elmDl.appendChild( elmDt);
+ elmDl.appendChild( elmDd);
+ }
+ this.displayName = 'Debug';
+ this.ID = 'debug';
+ this.rootElement = document.getElementById( 'debug' );
+ this.onOpen = function( _w, _h, _option ){
+ var pageHeaderH = pettanr.util.getElementSize( document.getElementById( 'header' )).height;
+ document.getElementById( 'inner-wrapper' ).style.height = ( _h - pageHeaderH ) + 'px';
+ }
+ this.onClose = function(){
+ document.getElementById( 'inner-wrapper' ).style.height = '0px';
+ }
+ this.onPaneResize = function( _w, _h ){
+ pettanr.debug.onOpen( _w, _h );
+ }
+ });
+ pettanr.debug.addToLancher();
+
+} else {
+ var _debug = document.getElementById( 'debug');
+ if( _debug){
+ pettanr.util.removeAllChildren( _debug);
+ _debug.parentNode.removeChild( _debug);
+ _debug = null;
+ }
+}
+
+/* ----------------------------------------
+ * Image Group Exproler
+ * - overlay
+ */
+pettanr.premiumSatge = pettanr.view.registerApplication( function(){
+ var ICON_ARRAY = [],
+ WHEEL_DELTA = 64,
+ ARTIST_TREE = pettanr.driver.createArtistTree(),
+ ARTIST_ROOT_FILE = ARTIST_TREE.getRootFile(),
+ instance = this,
+ winW, winH,
+ wrapX,
+ elmWrap = document.getElementById( 'image-gruop-wrapper' ),
+ elmContainer = document.getElementById( 'image-icon-container' ),
+ containerW,
+ containerH = pettanr.util.getElementSize( elmContainer ).height,
+ elmIconOrigin = ( function(){
+ var ret = document.createElement( 'div' ),
+ data = document.createElement( 'div' );
+ ret.appendChild( data );
+ ret.className = 'image-gruop-item';
+ data.className = 'image-gruop-item-title';
+ return ret;
+ })(),
+ jqContainer,
+ size = pettanr.util.getElementSize( elmIconOrigin ),
+ itemW = size.width,
+ itemH = size.height,
+ elmName = document.getElementById( 'gruop-name-display' ),
+ elmButton = document.getElementById( 'image-gruop-button' ),
+ buttonW = pettanr.util.getElementSize( elmButton ).width,
+ //onUpdateFunction,
+ _g_onUpdateFunction,
+ onEnterInterval = null;
+
+ elmButton.onclick = clickOK;
+
+ var BASE_PATH = pettanr.LOCAL === true ? 'resource_pictures\/' : pettanr.CONST.PETTANR_ROOT_PATH + 'resource_pictures\/',
+ THUMB_PATH = BASE_PATH, // + 'thumbnail/',
+ LIMIT_FILESIZE = 1024 * 10; // 10KB
+
+ var ImageGroupIconClass = function( INDEX, file ){
+ var elmIconWrap = elmIconOrigin.cloneNode( true ),
+ elmIconTitle = pettanr.util.getElementsByClassName( elmIconWrap, 'image-gruop-item-title' )[ 0 ],
+ data = pettanr.driver._getAPI().getFileData( file ),
+ SRC = [ BASE_PATH, data.id, '.', data.ext ].join( ''),
+ LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null,
+ reversibleImage = null,
+ onEnterFlag = false,
+ imgW, imgH;
+ elmContainer.appendChild( elmIconWrap );
+ elmIconWrap.style.left = ( INDEX * itemW ) + 'px';
+ elmIconTitle.appendChild( document.createTextNode( data.filesize + 'bytes' ));
+
+ function onImageLoad( url, _imgW, _imgH ){
+ if( reversibleImage === null) {
+ alert( url);
+ return;
+ }
+ data.width = imgW = _imgW || data.width || 64;
+ data.height = imgH = _imgH || data.height || 64;
+ elmIconTitle.firstChild.data = imgW + 'x' + imgH;
+ var zoom = 128 /( imgW > imgH ? imgW : imgH),
+ MATH_FLOOR = Math.floor
+ h = MATH_FLOOR( imgH *zoom ),
+ w = MATH_FLOOR( imgW *zoom );
+ reversibleImage.elm.style.cssText = [
+ 'width:', w, 'px;',
+ 'height:', h +'px;',
+ 'margin:', MATH_FLOOR( itemH /2 -h /2 ), 'px ', MATH_FLOOR( itemW /2 -w /2 ), 'px 0'
+ ].join('');
+ reversibleImage.resize( w, h );
+ elmIconWrap.onclick = onClick;
+ }
+
+ function onClick( e ){
+ if( _g_onUpdateFunction ) {
+ //if( LOW_SRC === null){
+ window[ _g_onUpdateFunction]( data );
+ window[ _g_onUpdateFunction] = null;
+ /*
+ } else {
+ var _onLoad = pettanr.util.createGlobalFunc( [
+ 'function( url, w, h ){',
+ 'window["', _g_onUpdateFunction, '"]( url, w || ', data.width,', h || ', data.height,');',
+ 'window["', _g_onUpdateFunction, '"] = null;',
+ '}'
+ ].join( '')),
+ _onError = pettanr.util.createGlobalFunc( [
+ 'function( url){',
+ 'window["', _g_onUpdateFunction, '"]( url, ', data.width || 64 ,', ', data.height || 64,');',
+ 'window["', _g_onUpdateFunction, '"] = null;',
+ '}'
+ ].join( ''));
+ pettanr.util.loadImage( SRC, window[ _onLoad], window[ _onError]);
+ window[ _onLoad] = window[ _onError] = undefined;
+ }*/
+ }
+ pettanr.premiumSatge.shutdown();
+ }
+
+ this.onEnter = function(){
+ if( onEnterFlag === true ) return;
+ reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad );
+ elmIconWrap.appendChild( reversibleImage.elm );
+ onEnterFlag = true;
+ }
+ this.destroy = function(){
+ reversibleImage && reversibleImage.destroy();
+ pettanr.util.removeAllChildren( elmIconWrap );
+ elmContainer.removeChild( elmIconWrap );
+ file.destroy();
+ reversibleImage = elmIconWrap = elmIconTitle = data = file = null;
+ delete this.destroy;
+ }
+ }
+
+ function onEnterShowImage(){
+ var l = ICON_ARRAY.length,
+ _start = -wrapX /itemW -1,
+ _end = _start + winW /itemW +1;
+ for( var i=0; i<l; ++i){
+ _start < i && i < _end && ICON_ARRAY[ i].onEnter();
+ }
+ onEnterInterval !== null && window.clearTimeout( onEnterInterval );
+ onEnterInterval = null;
+ }
+ function clickOK(){
+ pettanr.premiumSatge.shutdown();
+ }
+ function onMouseWheel( e, delta ){
+ if( winW < containerW){
+ wrapX += delta * WHEEL_DELTA;
+ wrapX = wrapX > 0 ? 0 : wrapX < winW -containerW ? winW -containerW : wrapX;
+ jqContainer.css( { left: wrapX});