X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.4.x%2Fjavascripts%2Fcommon.js;h=c757ff2ec3e3b85b70095a22959997920aae7986;hb=67cb7059b2dab2d5d1c72214e7cfa026b0ec6b75;hp=3a2e2ff39b50b0a357c9ceb68aac9cd9089fe5ed;hpb=2e8aa8876f3549073b142ee6e75c60a4d71e6aaa;p=pettanr%2FclientJs.git diff --git a/0.4.x/javascripts/common.js b/0.4.x/javascripts/common.js index 3a2e2ff..c757ff2 100644 --- a/0.4.x/javascripts/common.js +++ b/0.4.x/javascripts/common.js @@ -1,6 +1,6 @@ /* * pettanR common.js - * version 0.4.33 + * version 0.4.37 * * author: itozyun */ @@ -108,7 +108,7 @@ var pettanr = ( function(){ IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true, jqWindow , jqDocument , jqBody; return { - version: '0.4.33', + version: '0.4.36', init: function(){ jqWindow = $( window ); jqDocument = $( document ); @@ -231,15 +231,15 @@ pettanr.util = ( function(){ } } return { - extend: function( baseInstance, extend){ - for( var key in extend){ - if( typeof baseInstance[ key] === 'undefined'){ - baseInstance[ key] = extend[ key]; + extend: function( baseInstance, extend ){ + for( var key in extend ){ + if( Type.isUndefined( baseInstance[ key ] ) === true ){ + baseInstance[ key ] = extend[ key ]; } else - if( typeof baseInstance[ key] === typeof extend[ key]){ - baseInstance[ key] = extend[ key]; + if( typeof baseInstance[ key ] === typeof extend[ key ] ){ + baseInstance[ key ] = extend[ key ]; } else { - alert( 'extend error'); + alert( 'extend error' ); } } return baseInstance; @@ -267,31 +267,31 @@ pettanr.util = ( function(){ _elm.style.behavior = ''; } }, - getElementSize: function( _elm){ - if( !_elm){ + getElementSize: function( _elm ){ + if( Type.isHTMLElement( _elm ) === false ){ return { width: 0, height: 0 - } - } - var parentElm = _elm.parentNode, - prevElm = _elm.previousSibling, - nextElm = _elm.nextSibling, + }; + }; + var parentElm = _elm.parentNode, + prevElm = _elm.previousSibling, + nextElm = _elm.nextSibling, displayNone = _elm.style.display === 'none'; - if( displayNone === true) _elm.style.display = ''; - ELM_SIZE_GETTER.appendChild( _elm); + if( displayNone === true ) _elm.style.display = ''; + ELM_SIZE_GETTER.appendChild( _elm ); var ret = { width: _elm.offsetWidth, height: _elm.offsetHeight } - if( displayNone === true) _elm.style.display = 'none'; - if( nextElm){ - parentElm.insertBefore( _elm, nextElm); + if( displayNone === true ) _elm.style.display = 'none'; + if( nextElm ){ + parentElm.insertBefore( _elm, nextElm ); } else - if( prevElm && prevElm.nextSibling){ - parentElm.insertBefore( _elm, prevElm.nextSibling); + if( prevElm && prevElm.nextSibling ){ + parentElm.insertBefore( _elm, prevElm.nextSibling ); } else { - parentElm && parentElm.appendChild( _elm); + parentElm && parentElm.appendChild( _elm ); } return ret; }, @@ -736,11 +736,11 @@ pettanr.view = ( function(){ if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){ if( Type.isHTMLElement( this.rootElement ) === true ){ // 小さすぎる!、と表示 - } + }; return; - } + }; this.onPaneResize( _w, _h ); - } + }; this.MIN_WIDTH = 240; this.MIN_HEIGHT = 240; } @@ -752,6 +752,9 @@ pettanr.view = ( function(){ this.rootElement = null; this.parentElement = null; this.nextSibling = null; + this.getUID = function(){ + return pettanr.util.getIndex( APPLICATION_LIST, instance ); + } this.open = function( _w, _h /*, _option */ ){ instance = this; if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){ @@ -765,22 +768,22 @@ pettanr.view = ( function(){ } else { this.onOpen( _w, _h ); } - } + }; this.close = function(){ if( this.onClose() === false ){ return false; } - } + }; this.onOpen = function( _w, _h /*, _option */ ){ // overrride }; this.onClose = function(){ // overrride return true; - } // false の場合、close の拒否 - this.addEventListener = function(){ - - } + }; // false の場合、close の拒否 + this.addMouseEventListener = function( _element, _eventType, _handler ){ + MouseEventManager.add( instance, _element, _eventType, _handler ); + }; } AbstractApplication.prototype = new AbstractBasicPane(); @@ -965,11 +968,11 @@ pettanr.view = ( function(){ pettanr.overlay = ( function(){ var SHADOW_OPACITY = 0.5, - ELM_CONTAINER = document.getElementById( 'overlay-container' ), - jqConteiner, jqShadow, jqCloseButton,// jqBody, + ELM_CONTAINER = document.getElementById( 'overlay-container' ), currentOverlay = null, - bootParams = null, - visible = false, + bootParams = null, + visible = false, + jqConteiner, jqShadow, jqCloseButton,// jqBody, windowW, windowH; function asyncResize(){ @@ -978,7 +981,7 @@ pettanr.overlay = ( function(){ function onCloseClick( e){ pettanr.overlay.hide(); e.preventDefault(); - return false; + return false; } function onFadeInComplete(){ @@ -992,8 +995,8 @@ pettanr.overlay = ( function(){ return { init: function(){ //jqBody = pettanr.jqBody(); - jqConteiner = $( '#overlay-container'); - jqShadow = $( '#overlay-shadow'); + jqConteiner = $( '#overlay-container'); + jqShadow = $( '#overlay-shadow'); jqCloseButton = $( '#overlay-close-button').click( onCloseClick ); pettanr.key.addKeyDownEvent( pettanr.view.OVERLAY, 27, false, false, pettanr.overlay.hide ); // 27.esc @@ -1005,6 +1008,7 @@ pettanr.overlay = ( function(){ if( pettanr.view.isApplicationInstance( _overlay ) === false ) return; document.body.style.overflow = 'hidden'; + document.body.appendChild( ELM_CONTAINER ); // ie6-8 で必要、なんで、、、? this.visible = visible = true; this.currentID = _overlay.ID; @@ -1822,7 +1826,7 @@ pettanr.balloon = ( function() { })(), vectorEnabled = ELM_BALLOON_ORIGIN !== null && pettanr.URL_PARAMS.vector !== false && - !( IS_VML === true && pettanr.ua.VML === false ) + !( IS_VML === true && pettanr.ua.VML === false ); var cos = Math.cos, sin = Math.sin, @@ -1846,16 +1850,7 @@ pettanr.balloon = ( function() { instance = this, l = ','; - function draw( _a, _w, _h ){ - a = isFinit( _a ) === true ? _a : a; - w = isFinit( _w ) === true ? _w - PADDING_TOP * 2 : w; - h = isFinit( _h ) === true ? _h - PADDING_LEFT * 2 : h; - - if( vectorEnabled === false){ - balloonElm.setAttribute( 'src', pettanr.balloon.getBalloonUrl( w, h, _a )); - return; - } - + function draw( _a ){ var rx = w / 2, ry = h / 2, tailRad = _a * DEG_TO_RAD, @@ -1894,10 +1889,6 @@ pettanr.balloon = ( function() { if( IS_VML === true ){ var _tailX = tailX *10, _tailY = tailY *10, - __startX = startX *10, - __startY = startY *10, - __endX = endX *10, - __endY = endY *10, __w = w *10, __h = h *10; @@ -1906,8 +1897,8 @@ pettanr.balloon = ( function() { shape.coordsize = [ __w, __h ].join( l ); shape.path = [ ' ar ', 0, l, 0, l, __w, l, __h, l, - round( __endX ), l, round( __endY ), l, - round( __startX ), l, round( __startY ), + round( endX * 10 ), l, round( endY * 10 ), l, + round( startX * 10 ), l, round( startY * 10 ), ' l ', round( _tailX ), l, round( _tailY ), ' x e' ].join( ''); @@ -1927,14 +1918,28 @@ pettanr.balloon = ( function() { ].join( ' ')); } } - - draw( a, w, h ); this.elm = balloonElm; - this.resize = draw; + this.resize = function ( _a, _w, _h ){ + w = isFinit( _w ) === true ? _w - PADDING_TOP * 2 : w; + h = isFinit( _h ) === true ? _h - PADDING_LEFT * 2 : h; + // ie6 でリサイズが反応しない対策 + if( vectorEnabled === false && pettanr.ua.isIE === true && pettanr.ua.ieVersion < 7 ){ + var parent = balloonElm.parentNode; + parent.removeChild( balloonElm ); + parent.insertBefore( balloonElm, parent.firstChild ); + } + instance.angle( _a ); + }; this.angle = function( _a ){ - _a !== undefined && _a !== a && - vectorEnabled === false ? pettanr.balloon.getBalloonUrl( w, h, _a ) : draw( _a ); + if( isFinit( _a ) === true ){ + a = _a; + if( vectorEnabled === false ){ + balloonElm.src = pettanr.balloon.getBalloonUrl( w, h, _a ); + } else { + draw( _a ); + } + } return a; } this.type = function( _type ){ @@ -1945,6 +1950,8 @@ pettanr.balloon = ( function() { balloonElm.parentNode && balloonElm.parentNode.removeChild( balloonElm ); balloonElm = path = shape = instance = null; } + + instance.resize( a, w, h ); }; IS_VML === false && vectorEnabled === true && ( function(){ @@ -1968,6 +1975,7 @@ pettanr.balloon = ( function() { return [ pettanr.CONST.SYSTEM_PICTURE_PATH, '_w', _a < 360 - d / 2 ? floor( _a / d ) : 0, + _w <= 400 || _h <= 400 ? '_b1' : '', '.gif' ].join( '' ); }, TYPE_NONE: 0, @@ -2082,10 +2090,10 @@ pettanr.image = ( function(){ destroy(); } function destroy(){ - finish = true; + finish = true; img.src = img.onload = img.onabort = img.onerror = ''; - img = void 0 - size = onLoadCallback = onErrorCallback = timer = null; + img = void 0; + size = onLoadCallback = onErrorCallback = timer = null; } this.stop = function(){ timer !== null && window.clearTimeout( timer ); @@ -2285,6 +2293,9 @@ pettanr.bind = ( function(){ var ret = document.createElement( 'div'); ret.style.cssText = 'width: auto;height: 0;padding: 0;margin: 0;display: block;visibility: hidden;float: none;position: static;'; return ret; + })(), + ELM_TITLE_ORIGN = ( function(){ + })(); /* @@ -2311,7 +2322,7 @@ pettanr.bind = ( function(){ var size = getInnerSize(); if (_size.w !== size.w || _size.h !== size.h) { // resized _size = size; // update - onResizeFunction( _size); + onResizeFunction( _size ); } setTimeout( unlock, 0); // delay unlock } @@ -2324,151 +2335,175 @@ pettanr.bind = ( function(){ } - var ElementBuilder = ( function(){ - var ELM_TITLE_ORIGN = ( function(){ - - })(), - ELM_TEXT_ORIGN = ( function(){ - var _table = document.createElement( 'table'), - _tr = document.createElement( 'tr'); - _table.appendChild( _tr); - _tr.appendChild( document.createElement( 'td')); - _table.cellspacing = '0'; - return _table; - })(); + var ElementBuilderClass = function( elmTarget, noClassnameMode ){ + var RIMG_ARRAY = [], + BALLOON_ARRAY = []; function buildComicElement(){ } - function buildPanelElement( elmTarget, json, noClassnameMode){ - var _elmPanel = document.createElement( 'div'), + function buildPanelElement( json, zoom ){ + var _elmPanel = document.createElement( 'div' ), _style = { - "border-width": typeof json.border === 'number' ? json.border + 'px' : 0, + 'border-width': typeof json.border === 'number' ? json.border + 'px' : 0, width: json.width + 'px', height: json.height + 'px' }, _cssText = [], _comicElements = json.panel_elements || [], - _comicElement, _elmImgWrap, _rImg, _rPic, _balloon, _elmBalloonWrap, _elmText; - if( noClassnameMode === true){ + _comicElement, _elmImg, _rImg, _rPic, + _balloon, _elmBalloonWrap, _elmText, _text, _speechesAttributes, _key; + if( noClassnameMode === true ){ } else { _elmPanel.className = NAMESPACE_CLASSNAME + 'panel'; } - for( var _key in _style){ - _cssText.push( _key + ':' + _style[ _key]); + for( var _key in _style ){ + _cssText.push( _key + ':' + _style[ _key ] ); } _elmPanel.style.cssText = _cssText.join( ';'); - elmTarget.appendChild( _elmPanel); + elmTarget.appendChild( _elmPanel ); - for( var i=0, l=_comicElements.length; i 0 ){ + RIMG_ARRAY.shift().destroy(); + } + while( BALLOON_ARRAY.length > 0 ){ + BALLOON_ARRAY.shift().destroy(); + } + pettanr.util.removeAllChildren( elmTarget ); + } + + this.build = function( json, zoom ){ + clean(); + + // json is Comic ? Panel ? + var panels = json.panels; + if( Type.isArray( panels ) === true ){ + // comic + for( var i=0, l=panels.length; i